(t,e,n,i,r,s)
| 1 | !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).ol={})}(this,function(t){"use strict";var e=Object.create,n=Object.defineProperty,i=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,s=Object.getPrototypeOf,o=Object.prototype.hasOwnProperty,a=(t,e)=>()=>(e||(t((e={exports:{}}).exports,e),t=null),e.exports),l=(t,a,l)=>(l=null!=t?e(s(t)):{},((t,e,s,a)=>{if(e&&"object"==typeof e||"function"==typeof e)for(var l,h=r(e),c=0,u=h.length;c<u;c++)l=h[c],o.call(t,l)||l===s||n(t,l,{get:(t=>e[t]).bind(null,l),enumerable:!(a=i(e,l))||a.enumerable});return t})(n(l,"default",{value:t,enumerable:!0}),t)),h={$version:8,$root:{version:{required:!0,type:"enum",values:[8]},name:{type:"string"},metadata:{type:"*"},center:{type:"array",value:"number",length:2},centerAltitude:{type:"number"},zoom:{type:"number"},bearing:{type:"number",default:0,period:360,units:"degrees"},pitch:{type:"number",default:0,units:"degrees"},roll:{type:"number",default:0,units:"degrees"},state:{type:"state",default:{}},light:{type:"light"},sky:{type:"sky"},projection:{type:"projection"},terrain:{type:"terrain"},sources:{required:!0,type:"sources"},sprite:{type:"sprite"},glyphs:{type:"string"},"font-faces":{type:"fontFaces"},transition:{type:"transition"},layers:{required:!0,type:"array",value:"layer"}},sources:{"*":{type:"source"}},source:["source_vector","source_raster","source_raster_dem","source_geojson","source_video","source_image"],source_vector:{type:{required:!0,type:"enum",values:{vector:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},attribution:{type:"string"},promoteId:{type:"promoteId"},volatile:{type:"boolean",default:!1},encoding:{type:"enum",values:{mvt:{},mlt:{}},default:"mvt"},"*":{type:"*"}},source_raster:{type:{required:!0,type:"enum",values:{raster:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},attribution:{type:"string"},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_raster_dem:{type:{required:!0,type:"enum",values:{"raster-dem":{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},attribution:{type:"string"},encoding:{type:"enum",values:{terrarium:{},mapbox:{},custom:{}},default:"mapbox"},redFactor:{type:"number",default:1},blueFactor:{type:"number",default:1},greenFactor:{type:"number",default:1},baseShift:{type:"number",default:0},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_geojson:{type:{required:!0,type:"enum",values:{geojson:{}}},data:{required:!0,type:"*"},maxzoom:{type:"number",default:18},attribution:{type:"string"},buffer:{type:"number",default:128,maximum:512,minimum:0},filter:{type:"filter"},tolerance:{type:"number",default:.375},cluster:{type:"boolean",default:!1},clusterRadius:{type:"number",default:50,minimum:0},clusterMaxZoom:{type:"number"},clusterMinPoints:{type:"number"},clusterProperties:{type:"*"},lineMetrics:{type:"boolean",default:!1},generateId:{type:"boolean",default:!1},promoteId:{type:"promoteId"}},source_video:{type:{required:!0,type:"enum",values:{video:{}}},urls:{required:!0,type:"array",value:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},source_image:{type:{required:!0,type:"enum",values:{image:{}}},url:{required:!0,type:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},layer:{id:{type:"string",required:!0},type:{type:"enum",values:{fill:{},line:{},symbol:{},circle:{},heatmap:{},"fill-extrusion":{},raster:{},hillshade:{},"color-relief":{},background:{}},required:!0},metadata:{type:"*"},source:{type:"string"},"source-layer":{type:"string"},minzoom:{type:"number",minimum:0,maximum:24},maxzoom:{type:"number",minimum:0,maximum:24},filter:{type:"filter"},layout:{type:"layout"},paint:{type:"paint"}},layout:["layout_fill","layout_line","layout_circle","layout_heatmap","layout_fill-extrusion","layout_symbol","layout_raster","layout_hillshade","layout_color-relief","layout_background"],layout_background:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_fill:{"fill-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_circle:{"circle-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_heatmap:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},"layout_fill-extrusion":{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_line:{"line-cap":{type:"enum",values:{butt:{},round:{},square:{}},default:"butt",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"line-join":{type:"enum",values:{bevel:{},round:{},miter:{}},default:"miter",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"line-miter-limit":{type:"number",default:2,requires:[{"line-join":"miter"}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"line-round-limit":{type:"number",default:1.05,requires:[{"line-join":"round"}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"line-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_symbol:{"symbol-placement":{type:"enum",values:{point:{},line:{},"line-center":{}},default:"point",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-spacing":{type:"number",default:250,minimum:1,units:"pixels",requires:[{"symbol-placement":"line"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"symbol-avoid-edges":{type:"boolean",default:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"symbol-z-order":{type:"enum",values:{auto:{},"viewport-y":{},source:{}},default:"auto",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-allow-overlap":{type:"boolean",default:!1,requires:["icon-image",{"!":"icon-overlap"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-overlap":{type:"enum",values:{never:{},always:{},cooperative:{}},requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-ignore-placement":{type:"boolean",default:!1,requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-optional":{type:"boolean",default:!1,requires:["icon-image","text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-rotation-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-size":{type:"number",default:1,minimum:0,units:"factor of the original icon size",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-text-fit":{type:"enum",values:{none:{},width:{},height:{},both:{}},default:"none",requires:["icon-image","text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-text-fit-padding":{type:"array",value:"number",length:4,default:[0,0,0,0],units:"pixels",requires:["icon-image","text-field",{"icon-text-fit":["both","width","height"]}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-image":{type:"resolvedImage",tokens:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-padding":{type:"padding",default:[2],units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-keep-upright":{type:"boolean",default:!1,requires:["icon-image",{"icon-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-offset":{type:"array",value:"number",length:2,default:[0,0],requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-anchor":{type:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-rotation-alignment":{type:"enum",values:{map:{},viewport:{},"viewport-glyph":{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-field":{type:"formatted",default:"",tokens:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-font":{type:"array",value:"string",default:["Open Sans Regular","Arial Unicode MS Regular"],requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-size":{type:"number",default:16,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-max-width":{type:"number",default:10,minimum:0,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-line-height":{type:"number",default:1.2,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-letter-spacing":{type:"number",default:0,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-justify":{type:"enum",values:{auto:{},left:{},center:{},right:{}},default:"center",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-radial-offset":{type:"number",units:"ems",default:0,requires:["text-field"],"property-type":"data-driven",expression:{interpolated:!0,parameters:["zoom","feature"]}},"text-variable-anchor":{type:"array",value:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-variable-anchor-offset":{type:"variableAnchorOffsetCollection",requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-anchor":{type:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["text-field",{"!":"text-variable-anchor"}],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-max-angle":{type:"number",default:45,units:"degrees",requires:["text-field",{"symbol-placement":["line","line-center"]}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-writing-mode":{type:"array",value:"enum",values:{horizontal:{},vertical:{}},requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-padding":{type:"number",default:2,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-keep-upright":{type:"boolean",default:!0,requires:["text-field",{"text-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-transform":{type:"enum",values:{none:{},uppercase:{},lowercase:{}},default:"none",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-offset":{type:"array",value:"number",units:"ems",length:2,default:[0,0],requires:["text-field",{"!":"text-radial-offset"}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-allow-overlap":{type:"boolean",default:!1,requires:["text-field",{"!":"text-overlap"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-overlap":{type:"enum",values:{never:{},always:{},cooperative:{}},requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-ignore-placement":{type:"boolean",default:!1,requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-optional":{type:"boolean",default:!1,requires:["text-field","icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_raster:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_hillshade:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},"layout_color-relief":{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},filter:{type:"boolean",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},filter_operator:{type:"enum",values:{"==":{},"!=":{},">":{},">=":{},"<":{},"<=":{},in:{},"!in":{},all:{},any:{},none:{},has:{},"!has":{}}},geometry_type:{type:"enum",values:{Point:{},LineString:{},Polygon:{}}},function:{expression:{type:"expression"},stops:{type:"array",value:"function_stop"},base:{type:"number",default:1,minimum:0},property:{type:"string",default:"$zoom"},type:{type:"enum",values:{identity:{},exponential:{},interval:{},categorical:{}},default:"exponential"},colorSpace:{type:"enum",values:{rgb:{},lab:{},hcl:{}},default:"rgb"},default:{type:"*",required:!1}},function_stop:{type:"array",minimum:0,maximum:24,value:["number","color"],length:2},expression:{type:"array",value:"expression_name",minimum:1},light:{anchor:{type:"enum",default:"viewport",values:{map:{},viewport:{}},"property-type":"data-constant",transition:!1,expression:{interpolated:!1,parameters:["zoom"]}},position:{type:"array",default:[1.15,210,30],length:3,value:"number","property-type":"data-constant",transition:!0,expression:{interpolated:!0,parameters:["zoom"]}},color:{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},intensity:{type:"number","property-type":"data-constant",default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},sky:{"sky-color":{type:"color","property-type":"data-constant",default:"#88C6FC",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"horizon-color":{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"fog-color":{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"fog-ground-blend":{type:"number","property-type":"data-constant",default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"horizon-fog-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"sky-horizon-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"atmosphere-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},terrain:{source:{type:"string",required:!0},exaggeration:{type:"number",minimum:0,default:1}},projection:{type:{type:"projectionDefinition",default:"mercator","property-type":"data-constant",transition:!1,expression:{interpolated:!0,parameters:["zoom"]}}},paint:["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_symbol","paint_raster","paint_hillshade","paint_color-relief","paint_background"],paint_fill:{"fill-antialias":{type:"boolean",default:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-outline-color":{type:"color",transition:!0,requires:[{"!":"fill-pattern"},{"fill-antialias":!0}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"}},"paint_fill-extrusion":{"fill-extrusion-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-extrusion-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-extrusion-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"fill-extrusion-height":{type:"number",default:0,minimum:0,units:"meters",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{type:"number",default:0,minimum:0,units:"meters",transition:!0,requires:["fill-extrusion-height"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-vertical-gradient":{type:"boolean",default:!0,transition:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_line:{"line-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"line-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["line-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"line-width":{type:"number",default:1,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-gap-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-offset":{type:"number",default:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-dasharray":{type:"array",value:"number",minimum:0,transition:!0,units:"line widths",requires:[{"!":"line-pattern"}],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-gradient":{type:"color",transition:!1,requires:[{"!":"line-dasharray"},{"!":"line-pattern"},{source:"geojson",has:{lineMetrics:!0}}],expression:{interpolated:!0,parameters:["line-progress"]},"property-type":"color-ramp"}},paint_circle:{"circle-radius":{type:"number",default:5,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-blur":{type:"number",default:0,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"circle-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["circle-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-scale":{type:"enum",values:{map:{},viewport:{}},default:"map",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-alignment":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-stroke-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"}},paint_heatmap:{"heatmap-radius":{type:"number",default:30,minimum:1,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-weight":{type:"number",default:1,minimum:0,transition:!1,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-intensity":{type:"number",default:1,minimum:0,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"heatmap-color":{type:"color",default:["interpolate",["linear"],["heatmap-density"],0,"rgba(0, 0, 255, 0)",.1,"royalblue",.3,"cyan",.5,"lime",.7,"yellow",1,"red"],transition:!1,expression:{interpolated:!0,parameters:["heatmap-density"]},"property-type":"color-ramp"},"heatmap-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_symbol:{"icon-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-color":{type:"color",default:"#000000",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["icon-image","icon-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-color":{type:"color",default:"#000000",transition:!0,overridable:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["text-field","text-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_raster:{"raster-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-hue-rotate":{type:"number",default:0,period:360,transition:!0,units:"degrees",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-min":{type:"number",default:0,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-max":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-saturation":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-contrast":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},resampling:{type:"enum",values:{linear:{},nearest:{}},default:"linear",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"raster-resampling":{type:"enum",values:{linear:{},nearest:{}},default:"linear",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"raster-fade-duration":{type:"number",default:300,minimum:0,transition:!1,units:"milliseconds",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_hillshade:{"hillshade-illumination-direction":{type:"numberArray",default:335,minimum:0,maximum:359,transition:!1,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-illumination-altitude":{type:"numberArray",default:45,minimum:0,maximum:90,transition:!1,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-illumination-anchor":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-exaggeration":{type:"number",default:.5,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-shadow-color":{type:"colorArray",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-highlight-color":{type:"colorArray",default:"#FFFFFF",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-accent-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-method":{type:"enum",values:{standard:{},basic:{},combined:{},igor:{},multidirectional:{}},default:"standard",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},resampling:{type:"enum",values:{linear:{},nearest:{}},default:"linear",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},"paint_color-relief":{"color-relief-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"color-relief-color":{type:"color",transition:!1,expression:{interpolated:!0,parameters:["elevation"]},"property-type":"color-ramp"},resampling:{type:"enum",values:{linear:{},nearest:{}},default:"linear",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_background:{"background-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"background-pattern"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"background-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"cross-faded"},"background-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},transition:{duration:{type:"number",default:300,minimum:0,units:"milliseconds"},delay:{type:"number",default:0,minimum:0,units:"milliseconds"}},"property-type":{"data-driven":{type:"property-type"},"cross-faded":{type:"property-type"},"cross-faded-data-driven":{type:"property-type"},"color-ramp":{type:"property-type"},"data-constant":{type:"property-type"},constant:{type:"property-type"}},promoteId:{"*":{type:"string"}},interpolation:{type:"array",value:"interpolation_name",minimum:1},interpolation_name:{type:"enum",values:{linear:{syntax:{overloads:[{parameters:[],"output-type":"interpolation"}],parameters:[]}},exponential:{syntax:{overloads:[{parameters:["base"],"output-type":"interpolation"}],parameters:[{name:"base",type:"number literal"}]}},"cubic-bezier":{syntax:{overloads:[{parameters:["x1","y1","x2","y2"],"output-type":"interpolation"}],parameters:[{name:"x1",type:"number literal"},{name:"y1",type:"number literal"},{name:"x2",type:"number literal"},{name:"y2",type:"number literal"}]}}}}};const c=["type","source","source-layer","minzoom","maxzoom","filter","layout"];function u(t,e){const n={};for(const e in t)"ref"!==e&&(n[e]=t[e]);return c.forEach(t=>{t in e&&(n[t]=e[t])}),n}function d(t){t=t.slice();const e=Object.create(null);for(let n=0;n<t.length;n++)e[t[n].id]=t[n];for(let n=0;n<t.length;n++)"ref"in t[n]&&(t[n]=u(t[n],e[t[n].ref]));return t}var f=class extends Error{constructor(t,e){super(e),this.message=e,this.key=t}},g=class t{constructor(t,e=[]){this.parent=t,this.bindings={};for(const[t,n]of e)this.bindings[t]=n}concat(e){return new t(this,e)}get(t){if(this.bindings[t])return this.bindings[t];if(this.parent)return this.parent.get(t);throw new Error(`${t} not found in scope.`)}has(t){return!!this.bindings[t]||!!this.parent&&this.parent.has(t)}};const p={kind:"null"},m={kind:"number"},_={kind:"string"},y={kind:"boolean"},x={kind:"color"},v={kind:"projectionDefinition"},b={kind:"object"},w={kind:"value"},S={kind:"collator"},C={kind:"formatted"},E={kind:"padding"},P={kind:"colorArray"},T={kind:"numberArray"},R={kind:"resolvedImage"},F={kind:"variableAnchorOffsetCollection"};function M(t,e){return{kind:"array",itemType:t,N:e}}function I(t){if("array"===t.kind){const e=I(t.itemType);return"number"==typeof t.N?`array<${e}, ${t.N}>`:"value"===t.itemType.kind?"array":`array<${e}>`}return t.kind}const k=[p,m,_,y,x,v,C,b,M(w),E,T,P,R,F];function L(t,e){if("error"===e.kind)return null;if("array"===t.kind){if("array"===e.kind&&(0===e.N&&"value"===e.itemType.kind||!L(t.itemType,e.itemType))&&("number"!=typeof t.N||t.N===e.N))return null}else{if(t.kind===e.kind)return null;if("value"===t.kind)for(const t of k)if(!L(t,e))return null}return`Expected ${I(t)} but found ${I(e)} instead.`}function A(t,e){return e.some(e=>e.kind===t.kind)}function D(t,e){return e.some(e=>"null"===e?null===t:"array"===e?Array.isArray(t):"object"===e?t&&!Array.isArray(t)&&"object"==typeof t:e===typeof t)}function O(t,e){return"array"===t.kind&&"array"===e.kind?t.itemType.kind===e.itemType.kind&&"number"==typeof t.N:t.kind===e.kind}const z=.96422,N=.82521,j=4/29,G=6/29,$=3*G*G,B=G*G*G,U=Math.PI/180,V=180/Math.PI;function X(t){return(t%=360)<0&&(t+=360),t}function W([t,e,n,i]){let r,s;const o=Z((.2225045*(t=q(t))+.7168786*(e=q(e))+.0606169*(n=q(n)))/1);t===e&&e===n?r=s=o:(r=Z((.4360747*t+.3850649*e+.1430804*n)/z),s=Z((.0139322*t+.0971045*e+.7141733*n)/N));const a=116*o-16;return[a<0?0:a,500*(r-o),200*(o-s),i]}function q(t){return t<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function Z(t){return t>B?Math.pow(t,1/3):t/$+j}function K([t,e,n,i]){let r=(t+16)/116,s=isNaN(e)?r:r+e/500,o=isNaN(n)?r:r-n/200;return r=1*H(r),s=z*H(s),o=N*H(o),[Y(3.1338561*s-1.6168667*r-.4906146*o),Y(-.9787684*s+1.9161415*r+.033454*o),Y(.0719453*s-.2289914*r+1.4052427*o),i]}function Y(t){return(t=t<=.00304?12.92*t:1.055*Math.pow(t,1/2.4)-.055)<0?0:t>1?1:t}function H(t){return t>G?t*t*t:$*(t-j)}const J=Object.hasOwn||function(t,e){return Object.prototype.hasOwnProperty.call(t,e)};function Q(t,e){return J(t,e)?t[e]:void 0}function tt(t){if("transparent"===(t=t.toLowerCase().trim()))return[0,0,0,0];const e=Q(st,t);if(e){const[t,n,i]=e;return[t/255,n/255,i/255,1]}if(t.startsWith("#")&&/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/.test(t)){const e=t.length<6?1:2;let n=1;return[et(t.slice(n,n+=e)),et(t.slice(n,n+=e)),et(t.slice(n,n+=e)),et(t.slice(n,n+e)||"ff")]}if(t.startsWith("rgb")){const e=t.match(/^rgba?\(\s*([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(e){const[t,n,i,r,s,o,a,l,h,c,u,d]=e,f=[r||" ",a||" ",c].join("");if(" "===f||" /"===f||",,"===f||",,,"===f){const t=[i,o,h].join(""),e="%%%"===t?100:""===t?255:0;if(e){const t=[it(+n/e,0,1),it(+s/e,0,1),it(+l/e,0,1),u?nt(+u,d):1];if(rt(t))return t}}return}}const n=t.match(/^hsla?\(\s*([\de.+-]+)(?:deg)?(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(n){const[t,e,i,r,s,o,a,l,h]=n,c=[i||" ",s||" ",a].join("");if(" "===c||" /"===c||",,"===c||",,,"===c){const t=[+e,it(+r,0,100),it(+o,0,100),l?nt(+l,h):1];if(rt(t))return function([t,e,n,i]){function r(i){const r=(i+t/30)%12,s=e*Math.min(n,1-n);return n-s*Math.max(-1,Math.min(r-3,9-r,1))}return t=X(t),e/=100,n/=100,[r(0),r(8),r(4),i]}(t)}}}function et(t){return parseInt(t.padEnd(2,t),16)/255}function nt(t,e){return it(e?t/100:t,0,1)}function it(t,e,n){return Math.min(Math.max(e,t),n)}function rt(t){return!t.some(Number.isNaN)}const st={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]};function ot(t,e,n){return t+n*(e-t)}function at(t,e,n){return t.map((t,i)=>ot(t,e[i],n))}var lt=class t{constructor(t,e,n,i=1,r=!0){this.r=t,this.g=e,this.b=n,this.a=i,r||(this.r*=i,this.g*=i,this.b*=i,i||this.overwriteGetter("rgb",[t,e,n,i]))}static{this.black=new t(0,0,0,1)}static{this.white=new t(1,1,1,1)}static{this.transparent=new t(0,0,0,0)}static{this.red=new t(1,0,0,1)}static parse(e){if(e instanceof t)return e;if("string"!=typeof e)return;const n=tt(e);return n?new t(...n,!1):void 0}get rgb(){const{r:t,g:e,b:n,a:i}=this,r=i||1/0;return this.overwriteGetter("rgb",[t/r,e/r,n/r,i])}get hcl(){return this.overwriteGetter("hcl",function(t){const[e,n,i,r]=W(t),s=Math.sqrt(n*n+i*i);return[Math.round(1e4*s)?X(Math.atan2(i,n)*V):NaN,s,e,r]}(this.rgb))}get lab(){return this.overwriteGetter("lab",W(this.rgb))}overwriteGetter(t,e){return Object.defineProperty(this,t,{value:e}),e}toString(){const[t,e,n,i]=this.rgb;return`rgba(${[t,e,n].map(t=>Math.round(255*t)).join(",")},${i})`}static interpolate(e,n,i,r="rgb"){switch(r){case"rgb":{const[r,s,o,a]=at(e.rgb,n.rgb,i);return new t(r,s,o,a,!1)}case"hcl":{const[r,s,o,a]=e.hcl,[l,h,c,u]=n.hcl;let d,f;if(isNaN(r)||isNaN(l))isNaN(r)?isNaN(l)?d=NaN:(d=l,1!==o&&0!==o||(f=h)):(d=r,1!==c&&0!==c||(f=s));else{let t=l-r;l>r&&t>180?t-=360:l<r&&r-l>180&&(t+=360),d=r+i*t}const[g,p,m,_]=function([t,e,n,i]){return t=isNaN(t)?0:t*U,K([n,Math.cos(t)*e,Math.sin(t)*e,i])}([d,f??ot(s,h,i),ot(o,c,i),ot(a,u,i)]);return new t(g,p,m,_,!1)}case"lab":{const[r,s,o,a]=K(at(e.lab,n.lab,i));return new t(r,s,o,a,!1)}}}},ht=class{constructor(t,e,n){this.sensitivity=t?e?"variant":"case":e?"accent":"base",this.locale=n,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(t,e){return this.collator.compare(t,e)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}};const ct=["bottom","center","top"];var ut=class{constructor(t,e,n,i,r,s){this.text=t,this.image=e,this.scale=n,this.fontStack=i,this.textColor=r,this.verticalAlign=s}},dt=class t{constructor(t){this.sections=t}static fromString(e){return new t([new ut(e,null,null,null,null,null)])}isEmpty(){return 0===this.sections.length||!this.sections.some(t=>0!==t.text.length||t.image&&0!==t.image.name.length)}static factory(e){return e instanceof t?e:t.fromString(e)}toString(){return 0===this.sections.length?"":this.sections.map(t=>t.text).join("")}},ft=class t{constructor(t){this.values=t.slice()}static parse(e){if(e instanceof t)return e;if("number"==typeof e)return new t([e,e,e,e]);if(Array.isArray(e)&&!(e.length<1||e.length>4)){for(const t of e)if("number"!=typeof t)return;switch(e.length){case 1:e=[e[0],e[0],e[0],e[0]];break;case 2:e=[e[0],e[1],e[0],e[1]];break;case 3:e=[e[0],e[1],e[2],e[1]]}return new t(e)}}toString(){return JSON.stringify(this.values)}static interpolate(e,n,i){return new t(at(e.values,n.values,i))}},gt=class t{constructor(t){this.values=t.slice()}static parse(e){if(e instanceof t)return e;if("number"==typeof e)return new t([e]);if(Array.isArray(e)){for(const t of e)if("number"!=typeof t)return;return new t(e)}}toString(){return JSON.stringify(this.values)}static interpolate(e,n,i){return new t(at(e.values,n.values,i))}},pt=class t{constructor(t){this.values=t.slice()}static parse(e){if(e instanceof t)return e;if("string"==typeof e){const n=lt.parse(e);if(!n)return;return new t([n])}if(!Array.isArray(e))return;const n=[];for(const t of e){if("string"!=typeof t)return;const e=lt.parse(t);if(!e)return;n.push(e)}return new t(n)}toString(){return JSON.stringify(this.values)}static interpolate(e,n,i,r="rgb"){const s=[];if(e.values.length!=n.values.length)throw new Error(`colorArray: Arrays have mismatched length (${e.values.length} vs. ${n.values.length}), cannot interpolate.`);for(let t=0;t<e.values.length;t++)s.push(lt.interpolate(e.values[t],n.values[t],i,r));return new t(s)}},mt=class extends Error{constructor(t){super(t),this.name="RuntimeError"}toJSON(){return this.message}};const _t=new Set(["center","left","right","top","bottom","top-left","top-right","bottom-left","bottom-right"]);var yt=class t{constructor(t){this.values=t.slice()}static parse(e){if(e instanceof t)return e;if(Array.isArray(e)&&!(e.length<1)&&e.length%2==0){for(let t=0;t<e.length;t+=2){const n=e[t],i=e[t+1];if("string"!=typeof n||!_t.has(n))return;if(!Array.isArray(i)||2!==i.length||"number"!=typeof i[0]||"number"!=typeof i[1])return}return new t(e)}}toString(){return JSON.stringify(this.values)}static interpolate(e,n,i){const r=e.values,s=n.values;if(r.length!==s.length)throw new mt(`Cannot interpolate values of different length. from: ${e.toString()}, to: ${n.toString()}`);const o=[];for(let t=0;t<r.length;t+=2){if(r[t]!==s[t])throw new mt(`Cannot interpolate values containing mismatched anchors. from[${t}]: ${r[t]}, to[${t}]: ${s[t]}`);o.push(r[t]);const[e,n]=r[t+1],[a,l]=s[t+1];o.push([ot(e,a,i),ot(n,l,i)])}return new t(o)}},xt=class t{constructor(t){this.name=t.name,this.available=t.available}toString(){return this.name}static fromString(e){return e?new t({name:e,available:!1}):null}},vt=class t{constructor(t,e,n){this.from=t,this.to=e,this.transition=n}static interpolate(e,n,i){return new t(e,n,i)}static parse(e){return e instanceof t?e:Array.isArray(e)&&3===e.length&&"string"==typeof e[0]&&"string"==typeof e[1]&&"number"==typeof e[2]?new t(e[0],e[1],e[2]):"object"==typeof e&&"string"==typeof e.from&&"string"==typeof e.to&&"number"==typeof e.transition?new t(e.from,e.to,e.transition):"string"==typeof e?new t(e,e,1):void 0}};function bt(t,e,n,i){return"number"==typeof t&&t>=0&&t<=255&&"number"==typeof e&&e>=0&&e<=255&&"number"==typeof n&&n>=0&&n<=255?void 0===i||"number"==typeof i&&i>=0&&i<=1?null:`Invalid rgba value [${[t,e,n,i].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${("number"==typeof i?[t,e,n,i]:[t,e,n]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function wt(t){if(null===t||"string"==typeof t||"boolean"==typeof t||"number"==typeof t||t instanceof vt||t instanceof lt||t instanceof ht||t instanceof dt||t instanceof ft||t instanceof gt||t instanceof pt||t instanceof yt||t instanceof xt)return!0;if(Array.isArray(t)){for(const e of t)if(!wt(e))return!1;return!0}if("object"==typeof t){for(const e in t)if(!wt(t[e]))return!1;return!0}return!1}function St(t){if(null===t)return p;if("string"==typeof t)return _;if("boolean"==typeof t)return y;if("number"==typeof t)return m;if(t instanceof lt)return x;if(t instanceof vt)return v;if(t instanceof ht)return S;if(t instanceof dt)return C;if(t instanceof ft)return E;if(t instanceof gt)return T;if(t instanceof pt)return P;if(t instanceof yt)return F;if(t instanceof xt)return R;if(Array.isArray(t)){const e=t.length;let n;for(const e of t){const t=St(e);if(n){if(n===t)continue;n=w;break}n=t}return M(n||w,e)}return b}function Ct(t){const e=typeof t;return null===t?"":"string"===e||"number"===e||"boolean"===e?String(t):t instanceof lt||t instanceof vt||t instanceof dt||t instanceof ft||t instanceof gt||t instanceof pt||t instanceof yt||t instanceof xt?t.toString():JSON.stringify(t)}var Et=class t{constructor(t,e){this.type=t,this.value=e}static parse(e,n){if(2!==e.length)return n.error(`'literal' expression requires exactly one argument, but found ${e.length-1} instead.`);if(!wt(e[1]))return n.error("invalid value");const i=e[1];let r=St(i);const s=n.expectedType;return"array"!==r.kind||0!==r.N||!s||"array"!==s.kind||"number"==typeof s.N&&0!==s.N||(r=s),new t(r,i)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}};const Pt={string:_,number:m,boolean:y,object:b};var Tt=class t{constructor(t,e){this.type=t,this.args=e}static parse(e,n){if(e.length<2)return n.error("Expected at least one argument.");let i,r=1;const s=e[0];if("array"===s){let t,s;if(e.length>2){const i=e[1];if("string"!=typeof i||!(i in Pt)||"object"===i)return n.error('The item type argument of "array" must be one of string, number, boolean',1);t=Pt[i],r++}else t=w;if(e.length>3){if(null!==e[2]&&("number"!=typeof e[2]||e[2]<0||e[2]!==Math.floor(e[2])))return n.error('The length argument to "array" must be a positive integer literal',2);s=e[2],r++}i=M(t,s)}else{if(!Pt[s])throw new Error(`Types doesn't contain name = ${s}`);i=Pt[s]}const o=[];for(;r<e.length;r++){const t=n.parse(e[r],r,w);if(!t)return null;o.push(t)}return new t(i,o)}evaluate(t){for(let e=0;e<this.args.length;e++){const n=this.args[e].evaluate(t);if(!L(this.type,St(n)))return n;if(e===this.args.length-1)throw new mt(`Expected value to be of type ${I(this.type)}, but found ${I(St(n))} instead.`)}throw new Error}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every(t=>t.outputDefined())}};const Rt={"to-boolean":y,"to-color":x,"to-number":m,"to-string":_};var Ft=class t{constructor(t,e){this.type=t,this.args=e}static parse(e,n){if(e.length<2)return n.error("Expected at least one argument.");const i=e[0];if(!Rt[i])throw new Error(`Can't parse ${i} as it is not part of the known types`);if(("to-boolean"===i||"to-string"===i)&&2!==e.length)return n.error("Expected one argument.");const r=Rt[i],s=[];for(let t=1;t<e.length;t++){const i=n.parse(e[t],t,w);if(!i)return null;s.push(i)}return new t(r,s)}evaluate(t){switch(this.type.kind){case"boolean":return Boolean(this.args[0].evaluate(t));case"color":{let e,n;for(const i of this.args){if(e=i.evaluate(t),n=null,e instanceof lt)return e;if("string"==typeof e){const n=t.parseColor(e);if(n)return n}else if(Array.isArray(e)&&(n=e.length<3||e.length>4?`Invalid rgba value ${JSON.stringify(e)}: expected an array containing either three or four numeric values.`:bt(e[0],e[1],e[2],e[3]),!n))return new lt(e[0]/255,e[1]/255,e[2]/255,e[3])}throw new mt(n||`Could not parse color from value '${"string"==typeof e?e:JSON.stringify(e)}'`)}case"padding":{let e;for(const n of this.args){e=n.evaluate(t);const i=ft.parse(e);if(i)return i}throw new mt(`Could not parse padding from value '${"string"==typeof e?e:JSON.stringify(e)}'`)}case"numberArray":{let e;for(const n of this.args){e=n.evaluate(t);const i=gt.parse(e);if(i)return i}throw new mt(`Could not parse numberArray from value '${"string"==typeof e?e:JSON.stringify(e)}'`)}case"colorArray":{let e;for(const n of this.args){e=n.evaluate(t);const i=pt.parse(e);if(i)return i}throw new mt(`Could not parse colorArray from value '${"string"==typeof e?e:JSON.stringify(e)}'`)}case"variableAnchorOffsetCollection":{let e;for(const n of this.args){e=n.evaluate(t);const i=yt.parse(e);if(i)return i}throw new mt(`Could not parse variableAnchorOffsetCollection from value '${"string"==typeof e?e:JSON.stringify(e)}'`)}case"number":{let e=null;for(const n of this.args){if(e=n.evaluate(t),null===e)return 0;const i=Number(e);if(!isNaN(i))return i}throw new mt(`Could not convert ${JSON.stringify(e)} to number.`)}case"formatted":return dt.fromString(Ct(this.args[0].evaluate(t)));case"resolvedImage":return xt.fromString(Ct(this.args[0].evaluate(t)));case"projectionDefinition":return this.args[0].evaluate(t);default:return Ct(this.args[0].evaluate(t))}}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every(t=>t.outputDefined())}};const Mt=["Unknown","Point","LineString","Polygon"];var It=class{constructor(){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache=new Map,this.availableImages=null,this.canonical=null}id(){return this.feature&&"id"in this.feature?this.feature.id:null}geometryType(){return this.feature?"number"==typeof this.feature.type?Mt[this.feature.type]:this.feature.type:null}geometry(){return this.feature&&"geometry"in this.feature?this.feature.geometry:null}canonicalID(){return this.canonical}properties(){return this.feature&&this.feature.properties||{}}parseColor(t){let e=this._parseColorCache.get(t);return e||(e=lt.parse(t),this._parseColorCache.set(t,e)),e}},kt=class t{constructor(t,e,n=[],i,r=new g,s=[]){this.registry=t,this.path=n,this.key=n.map(t=>`[${t}]`).join(""),this.scope=r,this.errors=s,this.expectedType=i,this._isConstant=e}parse(t,e,n,i,r={}){return e?this.concat(e,n,i)._parse(t,r):this._parse(t,r)}_parse(t,e){function n(t,e,n){return"assert"===n?new Tt(e,[t]):"coerce"===n?new Ft(e,[t]):t}if(null!==t&&"string"!=typeof t&&"boolean"!=typeof t&&"number"!=typeof t||(t=["literal",t]),Array.isArray(t)){if(0===t.length)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const i=t[0];if("string"!=typeof i)return this.error(`Expression name must be a string, but found ${typeof i} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;const r=this.registry[i];if(r){let i=r.parse(t,this);if(!i)return null;if(this.expectedType){const t=this.expectedType,r=i.type;if("string"!==t.kind&&"number"!==t.kind&&"boolean"!==t.kind&&"object"!==t.kind&&"array"!==t.kind||"value"!==r.kind){if("projectionDefinition"===t.kind&&["string","array"].includes(r.kind)||["color","formatted","resolvedImage"].includes(t.kind)&&["value","string"].includes(r.kind)||["padding","numberArray"].includes(t.kind)&&["value","number","array"].includes(r.kind)||"colorArray"===t.kind&&["value","string","array"].includes(r.kind)||"variableAnchorOffsetCollection"===t.kind&&["value","array"].includes(r.kind))i=n(i,t,e.typeAnnotation||"coerce");else if(this.checkSubtype(t,r))return null}else i=n(i,t,e.typeAnnotation||"assert")}if(!(i instanceof Et)&&"resolvedImage"!==i.type.kind&&this._isConstant(i)){const t=new It;try{i=new Et(i.type,i.evaluate(t))}catch(t){return this.error(t.message),null}}return i}return this.error(`Unknown expression "${i}". If you wanted a literal array, use ["literal", [...]].`,0)}return void 0===t?this.error("'undefined' value invalid. Use null instead."):"object"==typeof t?this.error('Bare objects invalid. Use ["literal", {...}] instead.'):this.error(`Expected an array, but found ${typeof t} instead.`)}concat(e,n,i){const r="number"==typeof e?this.path.concat(e):this.path,s=i?this.scope.concat(i):this.scope;return new t(this.registry,this._isConstant,r,n||null,s,this.errors)}error(t,...e){const n=`${this.key}${e.map(t=>`[${t}]`).join("")}`;this.errors.push(new f(n,t))}checkSubtype(t,e){const n=L(t,e);return n&&this.error(n),n}},Lt=class t{constructor(t,e){this.type=e.type,this.bindings=[].concat(t),this.result=e}evaluate(t){return this.result.evaluate(t)}eachChild(t){for(const e of this.bindings)t(e[1]);t(this.result)}static parse(e,n){if(e.length<4)return n.error(`Expected at least 3 arguments, but found ${e.length-1} instead.`);const i=[];for(let t=1;t<e.length-1;t+=2){const r=e[t];if("string"!=typeof r)return n.error(`Expected string, but found ${typeof r} instead.`,t);if(/[^a-zA-Z0-9_]/.test(r))return n.error("Variable names must contain only alphanumeric characters or '_'.",t);const s=n.parse(e[t+1],t+1);if(!s)return null;i.push([r,s])}const r=n.parse(e[e.length-1],e.length-1,n.expectedType,i);return r?new t(i,r):null}outputDefined(){return this.result.outputDefined()}},At=class t{constructor(t,e){this.type=e.type,this.name=t,this.boundExpression=e}static parse(e,n){if(2!==e.length||"string"!=typeof e[1])return n.error("'var' expression requires exactly one string literal argument.");const i=e[1];return n.scope.has(i)?new t(i,n.scope.get(i)):n.error(`Unknown variable "${i}". Make sure "${i}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(t){return this.boundExpression.evaluate(t)}eachChild(){}outputDefined(){return!1}};function Dt(t,e){const n=t.length-1;let i,r,s=0,o=n,a=0;for(;s<=o;)if(a=Math.floor((s+o)/2),i=t[a],r=t[a+1],i<=e){if(a===n||e<r)return a;s=a+1}else{if(!(i>e))throw new mt("Input is not a number.");o=a-1}return 0}var Ot=class t{constructor(t,e,n){this.type=t,this.input=e,this.labels=[],this.outputs=[];for(const[t,e]of n)this.labels.push(t),this.outputs.push(e)}static parse(e,n){if(e.length-1<4)return n.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return n.error("Expected an even number of arguments.");const i=n.parse(e[1],1,m);if(!i)return null;const r=[];let s=null;n.expectedType&&"value"!==n.expectedType.kind&&(s=n.expectedType);for(let t=1;t<e.length;t+=2){const i=1===t?-1/0:e[t],o=e[t+1],a=t,l=t+1;if("number"!=typeof i)return n.error('Input/output pairs for "step" expressions must be defined using literal numeric values (not computed expressions) for the input values.',a);if(r.length&&r[r.length-1][0]>=i)return n.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',a);const h=n.parse(o,l,s);if(!h)return null;s=s||h.type,r.push([i,h])}return new t(s,i,r)}evaluate(t){const e=this.labels,n=this.outputs;if(1===e.length)return n[0].evaluate(t);const i=this.input.evaluate(t);if(i<=e[0])return n[0].evaluate(t);const r=e.length;return i>=e[r-1]?n[r-1].evaluate(t):n[Dt(e,i)].evaluate(t)}eachChild(t){t(this.input);for(const e of this.outputs)t(e)}outputDefined(){return this.outputs.every(t=>t.outputDefined())}},zt=l(a((t,e)=>{function n(t,e,n,i){this.cx=3*t,this.bx=3*(n-t)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*e,this.by=3*(i-e)-this.cy,this.ay=1-this.cy-this.by,this.p1x=t,this.p1y=e,this.p2x=n,this.p2y=i}e.exports=n,n.prototype={sampleCurveX:function(t){return((this.ax*t+this.bx)*t+this.cx)*t},sampleCurveY:function(t){return((this.ay*t+this.by)*t+this.cy)*t},sampleCurveDerivativeX:function(t){return(3*this.ax*t+2*this.bx)*t+this.cx},solveCurveX:function(t,e){if(void 0===e&&(e=1e-6),t<0)return 0;if(t>1)return 1;for(var n=t,i=0;i<8;i++){var r=this.sampleCurveX(n)-t;if(Math.abs(r)<e)return n;var s=this.sampleCurveDerivativeX(n);if(Math.abs(s)<1e-6)break;n-=r/s}var o=0,a=1;for(n=t,i=0;i<20&&(r=this.sampleCurveX(n),!(Math.abs(r-t)<e));i++)t>r?o=n:a=n,n=.5*(a-o)+o;return n},solve:function(t,e){return this.sampleCurveY(this.solveCurveX(t,e))}}})()),Nt=class t{constructor(t,e,n,i,r){this.type=t,this.operator=e,this.interpolation=n,this.input=i,this.labels=[],this.outputs=[];for(const[t,e]of r)this.labels.push(t),this.outputs.push(e)}static interpolationFactor(t,e,n,i){let r=0;if("exponential"===t.name)r=jt(e,t.base,n,i);else if("linear"===t.name)r=jt(e,1,n,i);else if("cubic-bezier"===t.name){const s=t.controlPoints;r=new zt.default(s[0],s[1],s[2],s[3]).solve(jt(e,1,n,i))}return r}static parse(e,n){let[i,r,s,...o]=e;if(!Array.isArray(r)||0===r.length)return n.error("Expected an interpolation type expression.",1);if("linear"===r[0])r={name:"linear"};else if("exponential"===r[0]){const t=r[1];if("number"!=typeof t)return n.error("Exponential interpolation requires a numeric base.",1,1);r={name:"exponential",base:t}}else{if("cubic-bezier"!==r[0])return n.error(`Unknown interpolation type ${String(r[0])}`,1,0);{const t=r.slice(1);if(4!==t.length||t.some(t=>"number"!=typeof t||t<0||t>1))return n.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);r={name:"cubic-bezier",controlPoints:t}}}if(e.length-1<4)return n.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return n.error("Expected an even number of arguments.");if(s=n.parse(s,2,m),!s)return null;const a=[];let l=null;"interpolate-hcl"!==i&&"interpolate-lab"!==i||n.expectedType==P?n.expectedType&&"value"!==n.expectedType.kind&&(l=n.expectedType):l=x;for(let t=0;t<o.length;t+=2){const e=o[t],i=o[t+1],r=t+3,s=t+4;if("number"!=typeof e)return n.error('Input/output pairs for "interpolate" expressions must be defined using literal numeric values (not computed expressions) for the input values.',r);if(a.length&&a[a.length-1][0]>=e)return n.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',r);const h=n.parse(i,s,l);if(!h)return null;l=l||h.type,a.push([e,h])}return O(l,m)||O(l,v)||O(l,x)||O(l,E)||O(l,T)||O(l,P)||O(l,F)||O(l,M(m))?new t(l,i,r,s,a):n.error(`Type ${I(l)} is not interpolatable.`)}evaluate(e){const n=this.labels,i=this.outputs;if(1===n.length)return i[0].evaluate(e);const r=this.input.evaluate(e);if(r<=n[0])return i[0].evaluate(e);const s=n.length;if(r>=n[s-1])return i[s-1].evaluate(e);const o=Dt(n,r),a=n[o],l=n[o+1],h=t.interpolationFactor(this.interpolation,r,a,l),c=i[o].evaluate(e),u=i[o+1].evaluate(e);switch(this.operator){case"interpolate":switch(this.type.kind){case"number":return ot(c,u,h);case"color":return lt.interpolate(c,u,h);case"padding":return ft.interpolate(c,u,h);case"colorArray":return pt.interpolate(c,u,h);case"numberArray":return gt.interpolate(c,u,h);case"variableAnchorOffsetCollection":return yt.interpolate(c,u,h);case"array":return at(c,u,h);case"projectionDefinition":return vt.interpolate(c,u,h)}case"interpolate-hcl":switch(this.type.kind){case"color":return lt.interpolate(c,u,h,"hcl");case"colorArray":return pt.interpolate(c,u,h,"hcl")}case"interpolate-lab":switch(this.type.kind){case"color":return lt.interpolate(c,u,h,"lab");case"colorArray":return pt.interpolate(c,u,h,"lab")}}}eachChild(t){t(this.input);for(const e of this.outputs)t(e)}outputDefined(){return this.outputs.every(t=>t.outputDefined())}};function jt(t,e,n,i){const r=i-n,s=t-n;return 0===r?0:1===e?s/r:(Math.pow(e,s)-1)/(Math.pow(e,r)-1)}var Gt=class t{constructor(t,e){this.type=t,this.args=e}static parse(e,n){if(e.length<2)return n.error("Expected at least one argument.");let i=null;const r=n.expectedType;r&&"value"!==r.kind&&(i=r);const s=[];for(const t of e.slice(1)){const e=n.parse(t,1+s.length,i,void 0,{typeAnnotation:"omit"});if(!e)return null;i=i||e.type,s.push(e)}if(!i)throw new Error("No output type");return r&&s.some(t=>L(r,t.type))?new t(w,s):new t(i,s)}evaluate(t){let e,n=null,i=0;for(const r of this.args)if(i++,n=r.evaluate(t),n&&n instanceof xt&&!n.available&&(e||(e=n.name),n=null,i===this.args.length&&(n=e)),null!==n)break;return n}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every(t=>t.outputDefined())}};function $t(t,e){return"=="===t||"!="===t?"boolean"===e.kind||"string"===e.kind||"number"===e.kind||"null"===e.kind||"value"===e.kind:"string"===e.kind||"number"===e.kind||"value"===e.kind}function Bt(t,e,n,i){return 0===i.compare(e,n)}function Ut(t,e,n){const i="=="!==t&&"!="!==t;return class r{constructor(t,e,n){this.type=y,this.lhs=t,this.rhs=e,this.collator=n,this.hasUntypedArgument="value"===t.type.kind||"value"===e.type.kind}static parse(t,e){if(3!==t.length&&4!==t.length)return e.error("Expected two or three arguments.");const n=t[0];let s=e.parse(t[1],1,w);if(!s)return null;if(!$t(n,s.type))return e.concat(1).error(`"${n}" comparisons are not supported for type '${I(s.type)}'.`);let o=e.parse(t[2],2,w);if(!o)return null;if(!$t(n,o.type))return e.concat(2).error(`"${n}" comparisons are not supported for type '${I(o.type)}'.`);if(s.type.kind!==o.type.kind&&"value"!==s.type.kind&&"value"!==o.type.kind)return e.error(`Cannot compare types '${I(s.type)}' and '${I(o.type)}'.`);i&&("value"===s.type.kind&&"value"!==o.type.kind?s=new Tt(o.type,[s]):"value"!==s.type.kind&&"value"===o.type.kind&&(o=new Tt(s.type,[o])));let a=null;if(4===t.length){if("string"!==s.type.kind&&"string"!==o.type.kind&&"value"!==s.type.kind&&"value"!==o.type.kind)return e.error("Cannot use collator to compare non-string types.");if(a=e.parse(t[3],3,S),!a)return null}return new r(s,o,a)}evaluate(r){const s=this.lhs.evaluate(r),o=this.rhs.evaluate(r);if(i&&this.hasUntypedArgument){const e=St(s),n=St(o);if(e.kind!==n.kind||"string"!==e.kind&&"number"!==e.kind)throw new mt(`Expected arguments for "${t}" to be (string, string) or (number, number), but found (${e.kind}, ${n.kind}) instead.`)}if(this.collator&&!i&&this.hasUntypedArgument){const t=St(s),n=St(o);if("string"!==t.kind||"string"!==n.kind)return e(r,s,o)}return this.collator?n(r,s,o,this.collator.evaluate(r)):e(r,s,o)}eachChild(t){t(this.lhs),t(this.rhs),this.collator&&t(this.collator)}outputDefined(){return!0}}}const Vt=Ut("==",function(t,e,n){return e===n},Bt),Xt=Ut("!=",function(t,e,n){return e!==n},function(t,e,n,i){return!Bt(0,e,n,i)}),Wt=Ut("<",function(t,e,n){return e<n},function(t,e,n,i){return i.compare(e,n)<0}),qt=Ut(">",function(t,e,n){return e>n},function(t,e,n,i){return i.compare(e,n)>0}),Zt=Ut("<=",function(t,e,n){return e<=n},function(t,e,n,i){return i.compare(e,n)<=0}),Kt=Ut(">=",function(t,e,n){return e>=n},function(t,e,n,i){return i.compare(e,n)>=0});var Yt=class t{constructor(t,e,n){this.type=S,this.locale=n,this.caseSensitive=t,this.diacriticSensitive=e}static parse(e,n){if(2!==e.length)return n.error("Expected one argument.");const i=e[1];if("object"!=typeof i||Array.isArray(i))return n.error("Collator options argument must be an object.");const r=n.parse(void 0!==i["case-sensitive"]&&i["case-sensitive"],1,y);if(!r)return null;const s=n.parse(void 0!==i["diacritic-sensitive"]&&i["diacritic-sensitive"],1,y);if(!s)return null;let o=null;return i.locale&&(o=n.parse(i.locale,1,_),!o)?null:new t(r,s,o)}evaluate(t){return new ht(this.caseSensitive.evaluate(t),this.diacriticSensitive.evaluate(t),this.locale?this.locale.evaluate(t):null)}eachChild(t){t(this.caseSensitive),t(this.diacriticSensitive),this.locale&&t(this.locale)}outputDefined(){return!1}};const Ht=8192;function Jt(t,e){const n=(180+t[0])/360;const i=(r=t[1],(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+r*Math.PI/360)))/360);var r;const s=Math.pow(2,e.z);return[Math.round(n*s*Ht),Math.round(i*s*Ht)]}function Qt(t,e){const n=Math.pow(2,e.z),i=(t[0]/Ht+e.x)/n,r=(t[1]/Ht+e.y)/n;return[(o=i,360*o-180),(s=r,360/Math.PI*Math.atan(Math.exp((180-360*s)*Math.PI/180))-90)];var s,o}function te(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 ee(t,e){return!(t[0]<=e[0])&&(!(t[2]>=e[2])&&(!(t[1]<=e[1])&&!(t[3]>=e[3])))}function ne(t,e,n){return e[1]>t[1]!=n[1]>t[1]&&t[0]<(n[0]-e[0])*(t[1]-e[1])/(n[1]-e[1])+e[0]}function ie(t,e,n){const i=t[0]-e[0],r=t[1]-e[1],s=t[0]-n[0],o=t[1]-n[1];return i*o-s*r===0&&i*s<=0&&r*o<=0}function re(t,e,n,i){const r=[e[0]-t[0],e[1]-t[1]];return 0!==(s=[i[0]-n[0],i[1]-n[1]],o=r,s[0]*o[1]-s[1]*o[0])&&!(!ce(t,e,n,i)||!ce(n,i,t,e));var s,o}function se(t,e,n){for(const i of n)for(let n=0;n<i.length-1;++n)if(re(t,e,i[n],i[n+1]))return!0;return!1}function oe(t,e,n=!1){let i=!1;for(const r of e)for(let e=0;e<r.length-1;e++){if(ie(t,r[e],r[e+1]))return n;ne(t,r[e],r[e+1])&&(i=!i)}return i}function ae(t,e){for(const n of e)if(oe(t,n))return!0;return!1}function le(t,e){for(const n of t)if(!oe(n,e))return!1;for(let n=0;n<t.length-1;++n)if(se(t[n],t[n+1],e))return!1;return!0}function he(t,e){for(const n of e)if(le(t,n))return!0;return!1}function ce(t,e,n,i){const r=t[0]-n[0],s=t[1]-n[1],o=e[0]-n[0],a=e[1]-n[1],l=i[0]-n[0],h=i[1]-n[1],c=r*h-l*s,u=o*h-l*a;return c>0&&u<0||c<0&&u>0}function ue(t,e,n){const i=[];for(let r=0;r<t.length;r++){const s=[];for(let i=0;i<t[r].length;i++){const o=Jt(t[r][i],n);te(e,o),s.push(o)}i.push(s)}return i}function de(t,e,n){const i=[];for(let r=0;r<t.length;r++){const s=ue(t[r],e,n);i.push(s)}return i}function fe(t,e,n,i){if(t[0]<n[0]||t[0]>n[2]){const e=.5*i;let r=t[0]-n[0]>e?-i:n[0]-t[0]>e?i:0;0===r&&(r=t[0]-n[2]>e?-i:n[2]-t[0]>e?i:0),t[0]+=r}te(e,t)}function ge(t,e,n,i){const r=Math.pow(2,i.z)*Ht,s=[i.x*Ht,i.y*Ht],o=[];for(const i of t)for(const t of i){const i=[t.x+s[0],t.y+s[1]];fe(i,e,n,r),o.push(i)}return o}function pe(t,e,n,i){const r=Math.pow(2,i.z)*Ht,s=[i.x*Ht,i.y*Ht],o=[];for(const n of t){const t=[];for(const i of n){const n=[i.x+s[0],i.y+s[1]];te(e,n),t.push(n)}o.push(t)}if(e[2]-e[0]<=r/2){!function(t){t[0]=t[1]=1/0,t[2]=t[3]=-1/0}(e);for(const t of o)for(const i of t)fe(i,e,n,r)}return o}var me=class t{constructor(t,e){this.type=y,this.geojson=t,this.geometries=e}static parse(e,n){if(2!==e.length)return n.error(`'within' expression requires exactly one argument, but found ${e.length-1} instead.`);if(wt(e[1])){const n=e[1];if("FeatureCollection"===n.type){const e=[];for(const t of n.features){const{type:n,coordinates:i}=t.geometry;"Polygon"===n&&e.push(i),"MultiPolygon"===n&&e.push(...i)}if(e.length)return new t(n,{type:"MultiPolygon",coordinates:e})}else if("Feature"===n.type){const e=n.geometry.type;if("Polygon"===e||"MultiPolygon"===e)return new t(n,n.geometry)}else if("Polygon"===n.type||"MultiPolygon"===n.type)return new t(n,n)}return n.error("'within' expression requires valid geojson object that contains polygon geometry type.")}evaluate(t){if(null!=t.geometry()&&null!=t.canonicalID()){if("Point"===t.geometryType())return function(t,e){const n=[1/0,1/0,-1/0,-1/0],i=[1/0,1/0,-1/0,-1/0],r=t.canonicalID();if("Polygon"===e.type){const s=ue(e.coordinates,i,r),o=ge(t.geometry(),n,i,r);if(!ee(n,i))return!1;for(const t of o)if(!oe(t,s))return!1}if("MultiPolygon"===e.type){const s=de(e.coordinates,i,r),o=ge(t.geometry(),n,i,r);if(!ee(n,i))return!1;for(const t of o)if(!ae(t,s))return!1}return!0}(t,this.geometries);if("LineString"===t.geometryType())return function(t,e){const n=[1/0,1/0,-1/0,-1/0],i=[1/0,1/0,-1/0,-1/0],r=t.canonicalID();if("Polygon"===e.type){const s=ue(e.coordinates,i,r),o=pe(t.geometry(),n,i,r);if(!ee(n,i))return!1;for(const t of o)if(!le(t,s))return!1}if("MultiPolygon"===e.type){const s=de(e.coordinates,i,r),o=pe(t.geometry(),n,i,r);if(!ee(n,i))return!1;for(const t of o)if(!he(t,s))return!1}return!0}(t,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}},_e=class{constructor(t=[],e=(t,e)=>t<e?-1:t>e?1:0){if(this.data=t,this.length=this.data.length,this.compare=e,this.length>0)for(let t=(this.length>>1)-1;t>=0;t--)this._down(t)}push(t){this.data.push(t),this._up(this.length++)}pop(){if(0===this.length)return;const t=this.data[0],e=this.data.pop();return--this.length>0&&(this.data[0]=e,this._down(0)),t}peek(){return this.data[0]}_up(t){const{data:e,compare:n}=this,i=e[t];for(;t>0;){const r=t-1>>1,s=e[r];if(n(i,s)>=0)break;e[t]=s,t=r}e[t]=i}_down(t){const{data:e,compare:n}=this,i=this.length>>1,r=e[t];for(;t<i;){let i=1+(t<<1);const s=i+1;if(s<this.length&&n(e[s],e[i])<0&&(i=s),n(e[i],r)>=0)break;e[t]=e[i],t=i}e[t]=r}};function ye(t){let e=0;for(let n,i,r=0,s=t.length,o=s-1;r<s;o=r++)n=t[r],i=t[o],e+=(i.x-n.x)*(n.y+i.y);return e}const xe=1/298.257223563,ve=xe*(2-xe),be=Math.PI/180;var we=class{constructor(t){const e=6378.137*be*1e3,n=Math.cos(t*be),i=1/(1-ve*(1-n*n)),r=Math.sqrt(i);this.kx=e*r*n,this.ky=e*r*i*(1-ve)}distance(t,e){const n=this.wrap(t[0]-e[0])*this.kx,i=(t[1]-e[1])*this.ky;return Math.sqrt(n*n+i*i)}pointOnLine(t,e){let n,i,r,s,o=1/0;for(let a=0;a<t.length-1;a++){let l=t[a][0],h=t[a][1],c=this.wrap(t[a+1][0]-l)*this.kx,u=(t[a+1][1]-h)*this.ky,d=0;0===c&&0===u||(d=(this.wrap(e[0]-l)*this.kx*c+(e[1]-h)*this.ky*u)/(c*c+u*u),d>1?(l=t[a+1][0],h=t[a+1][1]):d>0&&(l+=c/this.kx*d,h+=u/this.ky*d)),c=this.wrap(e[0]-l)*this.kx,u=(e[1]-h)*this.ky;const f=c*c+u*u;f<o&&(o=f,n=l,i=h,r=a,s=d)}return{point:[n,i],index:r,t:Math.max(0,Math.min(1,s))}}wrap(t){for(;t<-180;)t+=360;for(;t>180;)t-=360;return t}};function Se(t,e){return e[0]-t[0]}function Ce(t){return t[1]-t[0]+1}function Ee(t,e){return t[1]>=t[0]&&t[1]<e}function Pe(t,e){if(t[0]>t[1])return[null,null];const n=Ce(t);if(e){if(2===n)return[t,null];const e=Math.floor(n/2);return[[t[0],t[0]+e],[t[0]+e,t[1]]]}if(1===n)return[t,null];const i=Math.floor(n/2)-1;return[[t[0],t[0]+i],[t[0]+i+1,t[1]]]}function Te(t,e){if(!Ee(e,t.length))return[1/0,1/0,-1/0,-1/0];const n=[1/0,1/0,-1/0,-1/0];for(let i=e[0];i<=e[1];++i)te(n,t[i]);return n}function Re(t){const e=[1/0,1/0,-1/0,-1/0];for(const n of t)for(const t of n)te(e,t);return e}function Fe(t){return t[0]!==-1/0&&t[1]!==-1/0&&t[2]!==1/0&&t[3]!==1/0}function Me(t,e,n){if(!Fe(t)||!Fe(e))return NaN;let i=0,r=0;return t[2]<e[0]&&(i=e[0]-t[2]),t[0]>e[2]&&(i=t[0]-e[2]),t[1]>e[3]&&(r=t[1]-e[3]),t[3]<e[1]&&(r=e[1]-t[3]),n.distance([0,0],[i,r])}function Ie(t,e,n){const i=n.pointOnLine(e,t);return n.distance(t,i.point)}function ke(t,e,n,i,r){const s=Math.min(Ie(t,[n,i],r),Ie(e,[n,i],r)),o=Math.min(Ie(n,[t,e],r),Ie(i,[t,e],r));return Math.min(s,o)}function Le(t,e,n,i,r){if(!Ee(e,t.length)||!Ee(i,n.length))return 1/0;let s=1/0;for(let o=e[0];o<e[1];++o){const e=t[o],a=t[o+1];for(let t=i[0];t<i[1];++t){const i=n[t],o=n[t+1];if(re(e,a,i,o))return 0;s=Math.min(s,ke(e,a,i,o,r))}}return s}function Ae(t,e,n,i,r){if(!Ee(e,t.length)||!Ee(i,n.length))return NaN;let s=1/0;for(let o=e[0];o<=e[1];++o)for(let e=i[0];e<=i[1];++e)if(s=Math.min(s,r.distance(t[o],n[e])),0===s)return s;return s}function De(t,e,n){if(oe(t,e,!0))return 0;let i=1/0;for(const r of e){const e=r[0],s=r[r.length-1];if(e!==s&&(i=Math.min(i,Ie(t,[s,e],n)),0===i))return i;const o=n.pointOnLine(r,t);if(i=Math.min(i,n.distance(t,o.point)),0===i)return i}return i}function Oe(t,e,n,i){if(!Ee(e,t.length))return NaN;for(let i=e[0];i<=e[1];++i)if(oe(t[i],n,!0))return 0;let r=1/0;for(let s=e[0];s<e[1];++s){const e=t[s],o=t[s+1];for(const t of n)for(let n=0,s=t.length,a=s-1;n<s;a=n++){const s=t[a],l=t[n];if(re(e,o,s,l))return 0;r=Math.min(r,ke(e,o,s,l,i))}}return r}function ze(t,e){for(const n of t)for(const t of n)if(oe(t,e,!0))return!0;return!1}function Ne(t,e,n,i=1/0){const r=Re(t),s=Re(e);if(i!==1/0&&Me(r,s,n)>=i)return i;if(ee(r,s)){if(ze(t,e))return 0}else if(ze(e,t))return 0;let o=1/0;for(const i of t)for(let t=0,r=i.length,s=r-1;t<r;s=t++){const r=i[s],a=i[t];for(const t of e)for(let e=0,i=t.length,s=i-1;e<i;s=e++){const i=t[s],l=t[e];if(re(r,a,i,l))return 0;o=Math.min(o,ke(r,a,i,l,n))}}return o}function je(t,e,n,i,r,s){if(!s)return;const o=Me(Te(i,s),r,n);o<e&&t.push([o,s,[0,0]])}function Ge(t,e,n,i,r,s,o){if(!s||!o)return;const a=Me(Te(i,s),Te(r,o),n);a<e&&t.push([a,s,o])}function $e(t,e,n,i,r=1/0){let s=Math.min(i.distance(t[0],n[0][0]),r);if(0===s)return s;const o=new _e([[0,[0,t.length-1],[0,0]]],Se),a=Re(n);for(;o.length>0;){const r=o.pop();if(r[0]>=s)continue;const l=r[1],h=e?50:100;if(Ce(l)<=h){if(!Ee(l,t.length))return NaN;if(e){const e=Oe(t,l,n,i);if(isNaN(e)||0===e)return e;s=Math.min(s,e)}else for(let e=l[0];e<=l[1];++e){const r=De(t[e],n,i);if(s=Math.min(s,r),0===s)return 0}}else{const n=Pe(l,e);je(o,s,i,t,a,n[0]),je(o,s,i,t,a,n[1])}}return s}function Be(t,e,n,i,r,s=1/0){let o=Math.min(s,r.distance(t[0],n[0]));if(0===o)return o;const a=new _e([[0,[0,t.length-1],[0,n.length-1]]],Se);for(;a.length>0;){const s=a.pop();if(s[0]>=o)continue;const l=s[1],h=s[2],c=e?50:100,u=i?50:100;if(Ce(l)<=c&&Ce(h)<=u){if(!Ee(l,t.length)&&Ee(h,n.length))return NaN;let s;if(e&&i)s=Le(t,l,n,h,r),o=Math.min(o,s);else if(e&&!i){const e=t.slice(l[0],l[1]+1);for(let t=h[0];t<=h[1];++t)if(s=Ie(n[t],e,r),o=Math.min(o,s),0===o)return o}else if(!e&&i){const e=n.slice(h[0],h[1]+1);for(let n=l[0];n<=l[1];++n)if(s=Ie(t[n],e,r),o=Math.min(o,s),0===o)return o}else s=Ae(t,l,n,h,r),o=Math.min(o,s)}else{const s=Pe(l,e),c=Pe(h,i);Ge(a,o,r,t,n,s[0],c[0]),Ge(a,o,r,t,n,s[0],c[1]),Ge(a,o,r,t,n,s[1],c[0]),Ge(a,o,r,t,n,s[1],c[1])}}return o}function Ue(t,e){const n=t.geometry();if(0===n.length||0===n[0].length)return NaN;const i=function(t){if(t.length<=1)return[t];const e=[];let n,i;for(const r of t){const t=ye(r);0!==t&&(r.area=Math.abs(t),void 0===i&&(i=t<0),i===t<0?(n&&e.push(n),n=[r]):n.push(r))}return n&&e.push(n),e}(n).map(e=>e.map(e=>e.map(e=>Qt([e.x,e.y],t.canonical)))),r=new we(i[0][0][0][1]);let s=1/0;for(const t of e)for(const e of i){switch(t.type){case"Point":s=Math.min(s,$e([t.coordinates],!1,e,r,s));break;case"LineString":s=Math.min(s,$e(t.coordinates,!0,e,r,s));break;case"Polygon":s=Math.min(s,Ne(e,t.coordinates,r,s))}if(0===s)return s}return s}function Ve(t){return"MultiPolygon"===t.type?t.coordinates.map(t=>({type:"Polygon",coordinates:t})):"MultiLineString"===t.type?t.coordinates.map(t=>({type:"LineString",coordinates:t})):"MultiPoint"===t.type?t.coordinates.map(t=>({type:"Point",coordinates:t})):[t]}var Xe=class t{constructor(t,e){this.type=m,this.geojson=t,this.geometries=e}static parse(e,n){if(2!==e.length)return n.error(`'distance' expression requires exactly one argument, but found ${e.length-1} instead.`);if(wt(e[1])){const n=e[1];if("FeatureCollection"===n.type)return new t(n,n.features.map(t=>Ve(t.geometry)).flat());if("Feature"===n.type)return new t(n,Ve(n.geometry));if("type"in n&&"coordinates"in n)return new t(n,Ve(n))}return n.error("'distance' expression requires valid geojson object that contains polygon geometry type.")}evaluate(t){if(null!=t.geometry()&&null!=t.canonicalID()){if("Point"===t.geometryType())return function(t,e){const n=t.geometry(),i=n.flat().map(e=>Qt([e.x,e.y],t.canonical));if(0===n.length)return NaN;const r=new we(i[0][1]);let s=1/0;for(const t of e){switch(t.type){case"Point":s=Math.min(s,Be(i,!1,[t.coordinates],!1,r,s));break;case"LineString":s=Math.min(s,Be(i,!1,t.coordinates,!0,r,s));break;case"Polygon":s=Math.min(s,$e(i,!1,t.coordinates,r,s))}if(0===s)return s}return s}(t,this.geometries);if("LineString"===t.geometryType())return function(t,e){const n=t.geometry(),i=n.flat().map(e=>Qt([e.x,e.y],t.canonical));if(0===n.length)return NaN;const r=new we(i[0][1]);let s=1/0;for(const t of e){switch(t.type){case"Point":s=Math.min(s,Be(i,!0,[t.coordinates],!1,r,s));break;case"LineString":s=Math.min(s,Be(i,!0,t.coordinates,!0,r,s));break;case"Polygon":s=Math.min(s,$e(i,!0,t.coordinates,r,s))}if(0===s)return s}return s}(t,this.geometries);if("Polygon"===t.geometryType())return Ue(t,this.geometries)}return NaN}eachChild(){}outputDefined(){return!0}},We=class t{constructor(t){this.type=w,this.key=t}static parse(e,n){if(2!==e.length)return n.error(`Expected 1 argument, but found ${e.length-1} instead.`);const i=e[1];return null==i?n.error("Global state property must be defined."):"string"!=typeof i?n.error(`Global state property must be string, but found ${typeof e[1]} instead.`):new t(i)}evaluate(t){const e=t.globals?.globalState;return e&&0!==Object.keys(e).length?Q(e,this.key):null}eachChild(){}outputDefined(){return!1}};const qe={"==":Vt,"!=":Xt,">":qt,"<":Wt,">=":Kt,"<=":Zt,array:Tt,at:class t{constructor(t,e,n){this.type=t,this.index=e,this.input=n}static parse(e,n){if(3!==e.length)return n.error(`Expected 2 arguments, but found ${e.length-1} instead.`);const i=n.parse(e[1],1,m),r=n.parse(e[2],2,M(n.expectedType||w));if(!i||!r)return null;const s=r.type;return new t(s.itemType,i,r)}evaluate(t){const e=this.index.evaluate(t),n=this.input.evaluate(t);if(e<0)throw new mt(`Array index out of bounds: ${e} < 0.`);if(e>=n.length)throw new mt(`Array index out of bounds: ${e} > ${n.length-1}.`);if(e!==Math.floor(e))throw new mt(`Array index must be an integer, but found ${e} instead.`);return n[e]}eachChild(t){t(this.index),t(this.input)}outputDefined(){return!1}},boolean:Tt,case:class t{constructor(t,e,n){this.type=t,this.branches=e,this.otherwise=n}static parse(e,n){if(e.length<4)return n.error(`Expected at least 3 arguments, but found only ${e.length-1}.`);if(e.length%2!=0)return n.error("Expected an odd number of arguments.");let i;n.expectedType&&"value"!==n.expectedType.kind&&(i=n.expectedType);const r=[];for(let t=1;t<e.length-1;t+=2){const s=n.parse(e[t],t,y);if(!s)return null;const o=n.parse(e[t+1],t+1,i);if(!o)return null;r.push([s,o]),i=i||o.type}const s=n.parse(e[e.length-1],e.length-1,i);if(!s)return null;if(!i)throw new Error("Can't infer output type");return new t(i,r,s)}evaluate(t){for(const[e,n]of this.branches)if(e.evaluate(t))return n.evaluate(t);return this.otherwise.evaluate(t)}eachChild(t){for(const[e,n]of this.branches)t(e),t(n);t(this.otherwise)}outputDefined(){return this.branches.every(([t,e])=>e.outputDefined())&&this.otherwise.outputDefined()}},coalesce:Gt,collator:Yt,format:class t{constructor(t){this.type=C,this.sections=t}static parse(e,n){if(e.length<2)return n.error("Expected at least one argument.");const i=e[1];if(!Array.isArray(i)&&"object"==typeof i)return n.error("First argument must be an image or text section.");const r=[];let s=!1;for(let t=1;t<=e.length-1;++t){const i=e[t];if(s&&"object"==typeof i&&!Array.isArray(i)){s=!1;let t=null;if(i["font-scale"]&&(t=n.parse(i["font-scale"],1,m),!t))return null;let e=null;if(i["text-font"]&&(e=n.parse(i["text-font"],1,M(_)),!e))return null;let o=null;if(i["text-color"]&&(o=n.parse(i["text-color"],1,x),!o))return null;let a=null;if(i["vertical-align"]){if("string"==typeof i["vertical-align"]&&!ct.includes(i["vertical-align"]))return n.error(`'vertical-align' must be one of: 'bottom', 'center', 'top' but found '${i["vertical-align"]}' instead.`);if(a=n.parse(i["vertical-align"],1,_),!a)return null}const l=r[r.length-1];l.scale=t,l.font=e,l.textColor=o,l.verticalAlign=a}else{const i=n.parse(e[t],1,w);if(!i)return null;const o=i.type.kind;if("string"!==o&&"value"!==o&&"null"!==o&&"resolvedImage"!==o)return n.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");s=!0,r.push({content:i,scale:null,font:null,textColor:null,verticalAlign:null})}}return new t(r)}evaluate(t){return new dt(this.sections.map(e=>{const n=e.content.evaluate(t);return St(n)===R?new ut("",n,null,null,null,e.verticalAlign?e.verticalAlign.evaluate(t):null):new ut(Ct(n),null,e.scale?e.scale.evaluate(t):null,e.font?e.font.evaluate(t).join(","):null,e.textColor?e.textColor.evaluate(t):null,e.verticalAlign?e.verticalAlign.evaluate(t):null)}))}eachChild(t){for(const e of this.sections)t(e.content),e.scale&&t(e.scale),e.font&&t(e.font),e.textColor&&t(e.textColor),e.verticalAlign&&t(e.verticalAlign)}outputDefined(){return!1}},image:class t{constructor(t){this.type=R,this.input=t}static parse(e,n){if(2!==e.length)return n.error("Expected two arguments.");const i=n.parse(e[1],1,_);return i?new t(i):n.error("No image name provided.")}evaluate(t){const e=this.input.evaluate(t),n=xt.fromString(e);return n&&t.availableImages&&(n.available=t.availableImages.indexOf(e)>-1),n}eachChild(t){t(this.input)}outputDefined(){return!1}},in:class t{constructor(t,e){this.type=y,this.needle=t,this.haystack=e}static parse(e,n){if(3!==e.length)return n.error(`Expected 2 arguments, but found ${e.length-1} instead.`);const i=n.parse(e[1],1,w),r=n.parse(e[2],2,w);return i&&r?A(i.type,[y,_,m,p,w])?new t(i,r):n.error(`Expected first argument to be of type boolean, string, number or null, but found ${I(i.type)} instead`):null}evaluate(t){const e=this.needle.evaluate(t),n=this.haystack.evaluate(t);if(!n)return!1;if(!D(e,["boolean","string","number","null"]))throw new mt(`Expected first argument to be of type boolean, string, number or null, but found ${I(St(e))} instead.`);if(!D(n,["string","array"]))throw new mt(`Expected second argument to be of type array or string, but found ${I(St(n))} instead.`);return n.indexOf(e)>=0}eachChild(t){t(this.needle),t(this.haystack)}outputDefined(){return!0}},"index-of":class t{constructor(t,e,n){this.type=m,this.needle=t,this.haystack=e,this.fromIndex=n}static parse(e,n){if(e.length<=2||e.length>=5)return n.error(`Expected 2 or 3 arguments, but found ${e.length-1} instead.`);const i=n.parse(e[1],1,w),r=n.parse(e[2],2,w);if(!i||!r)return null;if(!A(i.type,[y,_,m,p,w]))return n.error(`Expected first argument to be of type boolean, string, number or null, but found ${I(i.type)} instead`);if(4===e.length){const s=n.parse(e[3],3,m);return s?new t(i,r,s):null}return new t(i,r)}evaluate(t){const e=this.needle.evaluate(t),n=this.haystack.evaluate(t);if(!D(e,["boolean","string","number","null"]))throw new mt(`Expected first argument to be of type boolean, string, number or null, but found ${I(St(e))} instead.`);let i;if(this.fromIndex&&(i=this.fromIndex.evaluate(t)),D(n,["string"])){const t=n.indexOf(e,i);return-1===t?-1:[...n.slice(0,t)].length}if(D(n,["array"]))return n.indexOf(e,i);throw new mt(`Expected second argument to be of type array or string, but found ${I(St(n))} instead.`)}eachChild(t){t(this.needle),t(this.haystack),this.fromIndex&&t(this.fromIndex)}outputDefined(){return!1}},interpolate:Nt,"interpolate-hcl":Nt,"interpolate-lab":Nt,length:class t{constructor(t){this.type=m,this.input=t}static parse(e,n){if(2!==e.length)return n.error(`Expected 1 argument, but found ${e.length-1} instead.`);const i=n.parse(e[1],1);return i?"array"!==i.type.kind&&"string"!==i.type.kind&&"value"!==i.type.kind?n.error(`Expected argument of type string or array, but found ${I(i.type)} instead.`):new t(i):null}evaluate(t){const e=this.input.evaluate(t);if("string"==typeof e)return[...e].length;if(Array.isArray(e))return e.length;throw new mt(`Expected value to be of type string or array, but found ${I(St(e))} instead.`)}eachChild(t){t(this.input)}outputDefined(){return!1}},let:Lt,literal:Et,match:class t{constructor(t,e,n,i,r,s){this.inputType=t,this.type=e,this.input=n,this.cases=i,this.outputs=r,this.otherwise=s}static parse(e,n){if(e.length<5)return n.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if(e.length%2!=1)return n.error("Expected an even number of arguments.");let i,r;n.expectedType&&"value"!==n.expectedType.kind&&(r=n.expectedType);const s={},o=[];for(let t=2;t<e.length-1;t+=2){let a=e[t];const l=e[t+1];Array.isArray(a)||(a=[a]);const h=n.concat(t);if(0===a.length)return h.error("Expected at least one branch label.");for(const t of a){if("number"!=typeof t&&"string"!=typeof t)return h.error("Branch labels must be numbers or strings.");if("number"==typeof t&&Math.abs(t)>Number.MAX_SAFE_INTEGER)return h.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if("number"==typeof t&&Math.floor(t)!==t)return h.error("Numeric branch labels must be integer values.");if(i){if(h.checkSubtype(i,St(t)))return null}else i=St(t);if(void 0!==s[String(t)])return h.error("Branch labels must be unique.");s[String(t)]=o.length}const c=n.parse(l,t,r);if(!c)return null;r=r||c.type,o.push(c)}const a=n.parse(e[1],1,w);if(!a)return null;const l=n.parse(e[e.length-1],e.length-1,r);return l?"value"!==a.type.kind&&n.concat(1).checkSubtype(i,a.type)?null:new t(i,r,a,s,o,l):null}evaluate(t){const e=this.input.evaluate(t);return(St(e)===this.inputType&&this.outputs[this.cases[e]]||this.otherwise).evaluate(t)}eachChild(t){t(this.input),this.outputs.forEach(t),t(this.otherwise)}outputDefined(){return this.outputs.every(t=>t.outputDefined())&&this.otherwise.outputDefined()}},number:Tt,"number-format":class t{constructor(t,e,n,i,r,s){this.type=_,this.number=t,this.locale=e,this.currency=n,this.unit=i,this.minFractionDigits=r,this.maxFractionDigits=s}static parse(e,n){if(3!==e.length)return n.error("Expected two arguments.");const i=n.parse(e[1],1,m);if(!i)return null;const r=e[2];if("object"!=typeof r||Array.isArray(r))return n.error("NumberFormat options argument must be an object.");let s=null;if(r.locale&&(s=n.parse(r.locale,1,_),!s))return null;let o=null;if(r.currency&&(o=n.parse(r.currency,1,_),!o))return null;let a=null;if(r.unit&&(a=n.parse(r.unit,1,_),!a))return null;if(o&&a)return n.error("NumberFormat options `currency` and `unit` are mutually exclusive");let l=null;if(r["min-fraction-digits"]&&(l=n.parse(r["min-fraction-digits"],1,m),!l))return null;let h=null;return r["max-fraction-digits"]&&(h=n.parse(r["max-fraction-digits"],1,m),!h)?null:new t(i,s,o,a,l,h)}evaluate(t){return new Intl.NumberFormat(this.locale?this.locale.evaluate(t):[],{style:this.currency?"currency":this.unit?"unit":"decimal",currency:this.currency?this.currency.evaluate(t):void 0,unit:this.unit?this.unit.evaluate(t):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(t):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(t):void 0}).format(this.number.evaluate(t))}eachChild(t){t(this.number),this.locale&&t(this.locale),this.currency&&t(this.currency),this.unit&&t(this.unit),this.minFractionDigits&&t(this.minFractionDigits),this.maxFractionDigits&&t(this.maxFractionDigits)}outputDefined(){return!1}},object:Tt,slice:class t{constructor(t,e,n,i){this.type=t,this.input=e,this.beginIndex=n,this.endIndex=i}static parse(e,n){if(e.length<=2||e.length>=5)return n.error(`Expected 2 or 3 arguments, but found ${e.length-1} instead.`);const i=n.parse(e[1],1,w),r=n.parse(e[2],2,m);if(!i||!r)return null;if(!A(i.type,[M(w),_,w]))return n.error(`Expected first argument to be of type array or string, but found ${I(i.type)} instead`);if(4===e.length){const s=n.parse(e[3],3,m);return s?new t(i.type,i,r,s):null}return new t(i.type,i,r)}evaluate(t){const e=this.input.evaluate(t),n=this.beginIndex.evaluate(t);let i;if(this.endIndex&&(i=this.endIndex.evaluate(t)),D(e,["string"]))return[...e].slice(n,i).join("");if(D(e,["array"]))return e.slice(n,i);throw new mt(`Expected first argument to be of type array or string, but found ${I(St(e))} instead.`)}eachChild(t){t(this.input),t(this.beginIndex),this.endIndex&&t(this.endIndex)}outputDefined(){return!1}},step:Ot,string:Tt,"to-boolean":Ft,"to-color":Ft,"to-number":Ft,"to-string":Ft,var:At,within:me,distance:Xe,"global-state":We};var Ze=class t{constructor(t,e,n,i){this.name=t,this.type=e,this._evaluate=n,this.args=i}evaluate(t){return this._evaluate(t,this.args)}eachChild(t){this.args.forEach(t)}outputDefined(){return!1}static parse(e,n){const i=e[0],r=t.definitions[i];if(!r)return n.error(`Unknown expression "${i}". If you wanted a literal array, use ["literal", [...]].`,0);const s=Array.isArray(r)?r[0]:r.type,o=Array.isArray(r)?[[r[1],r[2]]]:r.overloads,a=o.filter(([t])=>!Array.isArray(t)||t.length===e.length-1);let l=null;for(const[r,o]of a){l=new kt(n.registry,Qe,n.path,null,n.scope);const a=[];let h=!1;for(let t=1;t<e.length;t++){const n=e[t],i=Array.isArray(r)?r[t-1]:r.type,s=l.parse(n,1+a.length,i);if(!s){h=!0;break}a.push(s)}if(!h)if(Array.isArray(r)&&r.length!==a.length)l.error(`Expected ${r.length} arguments, but found ${a.length} instead.`);else{for(let t=0;t<a.length;t++){const e=Array.isArray(r)?r[t]:r.type,n=a[t];l.concat(t+1).checkSubtype(e,n.type)}if(0===l.errors.length)return new t(i,s,o,a)}}if(1===a.length)n.errors.push(...l.errors);else{const t=(a.length?a:o).map(([t])=>{return e=t,Array.isArray(e)?`(${e.map(I).join(", ")})`:`(${I(e.type)}...)`;var e}).join(" | "),i=[];for(let t=1;t<e.length;t++){const r=n.parse(e[t],1+i.length);if(!r)return null;i.push(I(r.type))}n.error(`Expected arguments of type ${t}, but found (${i.join(", ")}) instead.`)}return null}static register(e,n){t.definitions=n;for(const i in n)e[i]=t}};function Ke(t,[e,n,i,r]){e=e.evaluate(t),n=n.evaluate(t),i=i.evaluate(t);const s=r?r.evaluate(t):1,o=bt(e,n,i,s);if(o)throw new mt(o);return new lt(e/255,n/255,i/255,s,!1)}function Ye(t,e){return t in e}function He(t,e){const n=e[t];return void 0===n?null:n}function Je(t){return{type:t}}function Qe(t){if(t instanceof At)return Qe(t.boundExpression);if(t instanceof Ze&&"error"===t.name)return!1;if(t instanceof Yt)return!1;if(t instanceof me)return!1;if(t instanceof Xe)return!1;if(t instanceof We)return!1;const e=t instanceof Ft||t instanceof Tt;let n=!0;return t.eachChild(t=>{n=e?n&&Qe(t):n&&t instanceof Et}),!!n&&(tn(t)&&nn(t,["zoom","heatmap-density","elevation","line-progress","accumulated","is-supported-script"]))}function tn(t){if(t instanceof Ze){if("get"===t.name&&1===t.args.length)return!1;if("feature-state"===t.name)return!1;if("has"===t.name&&1===t.args.length)return!1;if("properties"===t.name||"geometry-type"===t.name||"id"===t.name)return!1;if(/^filter-/.test(t.name))return!1}if(t instanceof me)return!1;if(t instanceof Xe)return!1;let e=!0;return t.eachChild(t=>{e&&!tn(t)&&(e=!1)}),e}function en(t){if(t instanceof Ze&&"feature-state"===t.name)return!1;let e=!0;return t.eachChild(t=>{e&&!en(t)&&(e=!1)}),e}function nn(t,e){if(t instanceof Ze&&e.indexOf(t.name)>=0)return!1;let n=!0;return t.eachChild(t=>{n&&!nn(t,e)&&(n=!1)}),n}function rn(t){return{result:"success",value:t}}function sn(t){return{result:"error",value:t}}function on(t){return"object"==typeof t&&null!==t&&!Array.isArray(t)&&St(t)===b}Ze.register(qe,{error:[{kind:"error"},[_],(t,[e])=>{throw new mt(e.evaluate(t))}],typeof:[_,[w],(t,[e])=>I(St(e.evaluate(t)))],"to-rgba":[M(m,4),[x],(t,[e])=>{const[n,i,r,s]=e.evaluate(t).rgb;return[255*n,255*i,255*r,s]}],rgb:[x,[m,m,m],Ke],rgba:[x,[m,m,m,m],Ke],has:{type:y,overloads:[[[_],(t,[e])=>Ye(e.evaluate(t),t.properties())],[[_,b],(t,[e,n])=>Ye(e.evaluate(t),n.evaluate(t))]]},get:{type:w,overloads:[[[_],(t,[e])=>He(e.evaluate(t),t.properties())],[[_,b],(t,[e,n])=>He(e.evaluate(t),n.evaluate(t))]]},"feature-state":[w,[_],(t,[e])=>He(e.evaluate(t),t.featureState||{})],properties:[b,[],t=>t.properties()],"geometry-type":[_,[],t=>t.geometryType()],id:[w,[],t=>t.id()],zoom:[m,[],t=>t.globals.zoom],"heatmap-density":[m,[],t=>t.globals.heatmapDensity||0],elevation:[m,[],t=>t.globals.elevation||0],"line-progress":[m,[],t=>t.globals.lineProgress||0],accumulated:[w,[],t=>void 0===t.globals.accumulated?null:t.globals.accumulated],"+":[m,Je(m),(t,e)=>{let n=0;for(const i of e)n+=i.evaluate(t);return n}],"*":[m,Je(m),(t,e)=>{let n=1;for(const i of e)n*=i.evaluate(t);return n}],"-":{type:m,overloads:[[[m,m],(t,[e,n])=>e.evaluate(t)-n.evaluate(t)],[[m],(t,[e])=>-e.evaluate(t)]]},"/":[m,[m,m],(t,[e,n])=>e.evaluate(t)/n.evaluate(t)],"%":[m,[m,m],(t,[e,n])=>e.evaluate(t)%n.evaluate(t)],ln2:[m,[],()=>Math.LN2],pi:[m,[],()=>Math.PI],e:[m,[],()=>Math.E],"^":[m,[m,m],(t,[e,n])=>Math.pow(e.evaluate(t),n.evaluate(t))],sqrt:[m,[m],(t,[e])=>Math.sqrt(e.evaluate(t))],log10:[m,[m],(t,[e])=>Math.log(e.evaluate(t))/Math.LN10],ln:[m,[m],(t,[e])=>Math.log(e.evaluate(t))],log2:[m,[m],(t,[e])=>Math.log(e.evaluate(t))/Math.LN2],sin:[m,[m],(t,[e])=>Math.sin(e.evaluate(t))],cos:[m,[m],(t,[e])=>Math.cos(e.evaluate(t))],tan:[m,[m],(t,[e])=>Math.tan(e.evaluate(t))],asin:[m,[m],(t,[e])=>Math.asin(e.evaluate(t))],acos:[m,[m],(t,[e])=>Math.acos(e.evaluate(t))],atan:[m,[m],(t,[e])=>Math.atan(e.evaluate(t))],min:[m,Je(m),(t,e)=>Math.min(...e.map(e=>e.evaluate(t)))],max:[m,Je(m),(t,e)=>Math.max(...e.map(e=>e.evaluate(t)))],abs:[m,[m],(t,[e])=>Math.abs(e.evaluate(t))],round:[m,[m],(t,[e])=>{const n=e.evaluate(t);return n<0?-Math.round(-n):Math.round(n)}],floor:[m,[m],(t,[e])=>Math.floor(e.evaluate(t))],ceil:[m,[m],(t,[e])=>Math.ceil(e.evaluate(t))],"filter-==":[y,[_,w],(t,[e,n])=>t.properties()[e.value]===n.value],"filter-id-==":[y,[w],(t,[e])=>t.id()===e.value],"filter-type-==":[y,[_],(t,[e])=>t.geometryType()===e.value],"filter-<":[y,[_,w],(t,[e,n])=>{const i=t.properties()[e.value],r=n.value;return typeof i==typeof r&&i<r}],"filter-id-<":[y,[w],(t,[e])=>{const n=t.id(),i=e.value;return typeof n==typeof i&&n<i}],"filter->":[y,[_,w],(t,[e,n])=>{const i=t.properties()[e.value],r=n.value;return typeof i==typeof r&&i>r}],"filter-id->":[y,[w],(t,[e])=>{const n=t.id(),i=e.value;return typeof n==typeof i&&n>i}],"filter-<=":[y,[_,w],(t,[e,n])=>{const i=t.properties()[e.value],r=n.value;return typeof i==typeof r&&i<=r}],"filter-id-<=":[y,[w],(t,[e])=>{const n=t.id(),i=e.value;return typeof n==typeof i&&n<=i}],"filter->=":[y,[_,w],(t,[e,n])=>{const i=t.properties()[e.value],r=n.value;return typeof i==typeof r&&i>=r}],"filter-id->=":[y,[w],(t,[e])=>{const n=t.id(),i=e.value;return typeof n==typeof i&&n>=i}],"filter-has":[y,[w],(t,[e])=>e.value in t.properties()],"filter-has-id":[y,[],t=>null!==t.id()&&void 0!==t.id()],"filter-type-in":[y,[M(_)],(t,[e])=>e.value.indexOf(t.geometryType())>=0],"filter-id-in":[y,[M(w)],(t,[e])=>e.value.indexOf(t.id())>=0],"filter-in-small":[y,[_,M(w)],(t,[e,n])=>n.value.indexOf(t.properties()[e.value])>=0],"filter-in-large":[y,[_,M(w)],(t,[e,n])=>function(t,e,n,i){for(;n<=i;){const r=n+i>>1;if(e[r]===t)return!0;e[r]>t?i=r-1:n=r+1}return!1}(t.properties()[e.value],n.value,0,n.value.length-1)],all:{type:y,overloads:[[[y,y],(t,[e,n])=>e.evaluate(t)&&n.evaluate(t)],[Je(y),(t,e)=>{for(const n of e)if(!n.evaluate(t))return!1;return!0}]]},any:{type:y,overloads:[[[y,y],(t,[e,n])=>e.evaluate(t)||n.evaluate(t)],[Je(y),(t,e)=>{for(const n of e)if(n.evaluate(t))return!0;return!1}]]},"!":[y,[y],(t,[e])=>!e.evaluate(t)],"is-supported-script":[y,[_],(t,[e])=>{const n=t.globals&&t.globals.isSupportedScript;return!n||n(e.evaluate(t))}],upcase:[_,[_],(t,[e])=>e.evaluate(t).toUpperCase()],downcase:[_,[_],(t,[e])=>e.evaluate(t).toLowerCase()],concat:[_,Je(w),(t,e)=>e.map(e=>Ct(e.evaluate(t))).join("")],split:[M(_),[_,_],(t,[e,n])=>e.evaluate(t).split(n.evaluate(t))],join:[_,[M(_),_],(t,[e,n])=>e.evaluate(t).join(n.evaluate(t))],"resolved-locale":[_,[S],(t,[e])=>e.evaluate(t).resolvedLocale()]});var an=class{constructor(t,e,n){this.expression=t,this._warningHistory={},this._evaluator=new It,this._defaultValue=e?function(t){if("color"===t.type&&on(t.default))return new lt(0,0,0,0);switch(t.type){case"color":return lt.parse(t.default)||null;case"padding":return ft.parse(t.default)||null;case"numberArray":return gt.parse(t.default)||null;case"colorArray":return pt.parse(t.default)||null;case"variableAnchorOffsetCollection":return yt.parse(t.default)||null;case"projectionDefinition":return vt.parse(t.default)||null;default:return void 0===t.default?null:t.default}}(e):null,this._enumValues=e&&"enum"===e.type?e.values:null,this._globalState=n}evaluateWithoutErrorHandling(t,e,n,i,r,s){return this._globalState&&(t=pn(t,this._globalState)),this._evaluator.globals=t,this._evaluator.feature=e,this._evaluator.featureState=n,this._evaluator.canonical=i,this._evaluator.availableImages=r||null,this._evaluator.formattedSection=s,this.expression.evaluate(this._evaluator)}evaluate(t,e,n,i,r,s){this._globalState&&(t=pn(t,this._globalState)),this._evaluator.globals=t,this._evaluator.feature=e||null,this._evaluator.featureState=n||null,this._evaluator.canonical=i,this._evaluator.availableImages=r||null,this._evaluator.formattedSection=s||null;try{const t=this.expression.evaluate(this._evaluator);if(null==t||"number"==typeof t&&t!=t)return this._defaultValue;if(this._enumValues&&!(t in this._enumValues))throw new mt(`Expected value to be one of ${Object.keys(this._enumValues).map(t=>JSON.stringify(t)).join(", ")}, but found ${JSON.stringify(t)} instead.`);return t}catch(t){return this._warningHistory[t.message]||(this._warningHistory[t.message]=!0,"undefined"!=typeof console&&console.warn(t.message)),this._defaultValue}}};function ln(t){return Array.isArray(t)&&t.length>0&&"string"==typeof t[0]&&t[0]in qe}function hn(t,e,n){const i=new kt(qe,Qe,[],e?function(t){const e={color:x,string:_,number:m,enum:_,boolean:y,formatted:C,padding:E,numberArray:T,colorArray:P,projectionDefinition:v,resolvedImage:R,variableAnchorOffsetCollection:F};return"array"===t.type?M(e[t.value]||w,t.length):e[t.type]}(e):void 0),r=i.parse(t,void 0,void 0,void 0,e&&"string"===e.type?{typeAnnotation:"coerce"}:void 0);return r?rn(new an(r,e,n)):sn(i.errors)}var cn=class{constructor(t,e,n){this.kind=t,this._styleExpression=e,this.isStateDependent="constant"!==t&&!en(e.expression),this.globalStateRefs=gn(e.expression),this._globalState=n}evaluateWithoutErrorHandling(t,e,n,i,r,s){return this._globalState&&(t=pn(t,this._globalState)),this._styleExpression.evaluateWithoutErrorHandling(t,e,n,i,r,s)}evaluate(t,e,n,i,r,s){return this._globalState&&(t=pn(t,this._globalState)),this._styleExpression.evaluate(t,e,n,i,r,s)}},un=class{constructor(t,e,n,i,r){this.kind=t,this.zoomStops=n,this._styleExpression=e,this.isStateDependent="camera"!==t&&!en(e.expression),this.globalStateRefs=gn(e.expression),this.interpolationType=i,this._globalState=r}evaluateWithoutErrorHandling(t,e,n,i,r,s){return this._globalState&&(t=pn(t,this._globalState)),this._styleExpression.evaluateWithoutErrorHandling(t,e,n,i,r,s)}evaluate(t,e,n,i,r,s){return this._globalState&&(t=pn(t,this._globalState)),this._styleExpression.evaluate(t,e,n,i,r,s)}interpolationFactor(t,e,n){return this.interpolationType?Nt.interpolationFactor(this.interpolationType,t,e,n):0}};function dn(t,e,n){const i=hn(t,e,n);if("error"===i.result)return i;const r=i.value.expression,s=tn(r);if(!s&&("data-driven"!==(o=e)["property-type"]&&"cross-faded-data-driven"!==o["property-type"]))return sn([new f("","data expressions not supported")]);var o;const a=nn(r,["zoom"]);if(!a&&!function(t){return!!t.expression&&t.expression.parameters.indexOf("zoom")>-1}(e))return sn([new f("","zoom expressions not supported")]);const l=fn(r);if(!l&&!a)return sn([new f("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')]);if(l instanceof f)return sn([l]);if(l instanceof Nt&&!function(t){return!!t.expression&&t.expression.interpolated}(e))return sn([new f("",'"interpolate" expressions cannot be used with this property')]);if(!l)return rn(new cn(s?"constant":"source",i.value,n));const h=l instanceof Nt?l.interpolation:void 0;return rn(new un(s?"camera":"composite",i.value,l.labels,h,n))}function fn(t){let e=null;if(t instanceof Lt)e=fn(t.result);else if(t instanceof Gt){for(const n of t.args)if(e=fn(n),e)break}else(t instanceof Ot||t instanceof Nt)&&t.input instanceof Ze&&"zoom"===t.input.name&&(e=t);return e instanceof f||t.eachChild(t=>{const n=fn(t);n instanceof f?e=n:!e&&n?e=new f("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):e&&n&&e!==n&&(e=new f("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))}),e}function gn(t,e=new Set){return t instanceof We&&e.add(t.key),t.eachChild(t=>{gn(t,e)}),e}function pn(t,e){const{zoom:n,heatmapDensity:i,elevation:r,lineProgress:s,isSupportedScript:o,accumulated:a}=t??{};return{zoom:n,heatmapDensity:i,elevation:r,lineProgress:s,isSupportedScript:o,accumulated:a,globalState:e}}function mn(t){if(!0===t||!1===t)return!0;if(!Array.isArray(t)||0===t.length)return!1;switch(t[0]){case"has":return t.length>=2&&"$id"!==t[1]&&"$type"!==t[1];case"in":return t.length>=3&&("string"!=typeof t[1]||Array.isArray(t[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return 3!==t.length||Array.isArray(t[1])||Array.isArray(t[2]);case"any":case"all":for(const e of t.slice(1))if(!mn(e)&&"boolean"!=typeof e)return!1;return!0;default:return!0}}const _n={type:"boolean",default:!1,transition:!1,"property-type":"data-driven",expression:{interpolated:!1,parameters:["zoom","feature"]}};function yn(t,e){if(null==t)return{filter:()=>!0,needGeometry:!1,getGlobalStateRefs:()=>new Set};mn(t)||(t=bn(t));const n=hn(t,_n,e);if("error"===n.result)throw new Error(n.value.map(t=>`${t.key}: ${t.message}`).join(", "));return{filter:(t,e,i)=>n.value.evaluate(t,e,{},i),needGeometry:vn(t),getGlobalStateRefs:()=>gn(n.value.expression)}}function xn(t,e){return t<e?-1:t>e?1:0}function vn(t){if(!Array.isArray(t))return!1;if("within"===t[0]||"distance"===t[0])return!0;for(let e=1;e<t.length;e++)if(vn(t[e]))return!0;return!1}function bn(t){if(!t)return!0;const e=t[0];return t.length<=1?"any"!==e:"=="===e?wn(t[1],t[2],"=="):"!="===e?En(wn(t[1],t[2],"==")):"<"===e||">"===e||"<="===e||">="===e?wn(t[1],t[2],e):"any"===e?(n=t.slice(1),["any"].concat(n.map(bn))):"all"===e?["all"].concat(t.slice(1).map(bn)):"none"===e?["all"].concat(t.slice(1).map(bn).map(En)):"in"===e?Sn(t[1],t.slice(2)):"!in"===e?En(Sn(t[1],t.slice(2))):"has"===e?Cn(t[1]):"!has"!==e||En(Cn(t[1]));var n}function wn(t,e,n){switch(t){case"$type":return[`filter-type-${n}`,e];case"$id":return[`filter-id-${n}`,e];default:return[`filter-${n}`,t,e]}}function Sn(t,e){if(0===e.length)return!1;switch(t){case"$type":return["filter-type-in",["literal",e]];case"$id":return["filter-id-in",["literal",e]];default:return e.length>200&&!e.some(t=>typeof t!=typeof e[0])?["filter-in-large",t,["literal",e.sort(xn)]]:["filter-in-small",t,["literal",e]]}}function Cn(t){switch(t){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",t]}}function En(t){return["!",t]}function Pn(t){return"object"==typeof t?["literal",t]:t}function Tn(t,e){let n=t.stops;if(!n)return function(t,e){const n=["get",t.property];if(void 0===t.default)return"string"===e.type?["string",n]:n;if("enum"===e.type)return["match",n,Object.keys(e.values),n,t.default];{const i=["color"===e.type?"to-color":e.type,n,Pn(t.default)];return"array"===e.type&&i.splice(1,0,e.value,e.length||null),i}}(t,e);const i=n&&"object"==typeof n[0][0],r=i||void 0!==t.property,s=i||!r;return n=n.map(t=>!r&&e.tokens&&"string"==typeof t[1]?[t[0],An(t[1])]:[t[0],Pn(t[1])]),i?function(t,e,n){const i={},r={},s=[];for(let e=0;e<n.length;e++){const o=n[e],a=o[0].zoom;void 0===i[a]&&(i[a]={zoom:a,type:t.type,property:t.property,default:t.default},r[a]=[],s.push(a)),r[a].push([o[0].value,o[1]])}if("exponential"===Ln({},e)){const n=[Rn(t),["linear"],["zoom"]];for(const t of s)kn(n,t,Mn(i[t],e,r[t]),!1);return n}{const t=["step",["zoom"]];for(const n of s)kn(t,n,Mn(i[n],e,r[n]),!0);return In(t),t}}(t,e,n):s?function(t,e,n,i=["zoom"]){const r=Ln(t,e);let s,o=!1;if("interval"===r)s=["step",i],o=!0;else{if("exponential"!==r)throw new Error(`Unknown zoom function type "${r}"`);{const e=void 0!==t.base?t.base:1;s=[Rn(t),1===e?["linear"]:["exponential",e],i]}}for(const t of n)kn(s,t[0],t[1],o);return In(s),s}(t,e,n):Mn(t,e,n)}function Rn(t){switch(t.colorSpace){case"hcl":return"interpolate-hcl";case"lab":return"interpolate-lab";default:return"interpolate"}}function Fn(t,e){const n=Pn((i=t.default,r=e.default,void 0!==i?i:void 0!==r?r:void 0));var i,r;return void 0===n&&"resolvedImage"===e.type?"":n}function Mn(t,e,n){const i=Ln(t,e),r=["get",t.property];if("categorical"===i&&"boolean"==typeof n[0][0]){const i=["case"];for(const t of n)i.push(["==",r,t[0]],t[1]);return i.push(Fn(t,e)),i}if("categorical"===i){const i=["match",r];for(const t of n)kn(i,t[0],t[1],!1);return i.push(Fn(t,e)),i}if("interval"===i){const e=["step",["number",r]];for(const t of n)kn(e,t[0],t[1],!0);return In(e),void 0===t.default?e:["case",["==",["typeof",r],"number"],e,Pn(t.default)]}if("exponential"===i){const e=void 0!==t.base?t.base:1,i=[Rn(t),1===e?["linear"]:["exponential",e],["number",r]];for(const t of n)kn(i,t[0],t[1],!1);return void 0===t.default?i:["case",["==",["typeof",r],"number"],i,Pn(t.default)]}throw new Error(`Unknown property function type ${i}`)}function In(t){"step"===t[0]&&3===t.length&&(t.push(0),t.push(t[3]))}function kn(t,e,n,i){t.length>3&&e===t[t.length-2]||(i&&2===t.length||t.push(e),t.push(n))}function Ln(t,e){return t.type?t.type:e.expression.interpolated?"exponential":"interval"}function An(t){const e=["concat"],n=/{([^{}]+)}/g;let i=0;for(let r=n.exec(t);null!==r;r=n.exec(t)){const s=t.slice(i,n.lastIndex-r[0].length);i=n.lastIndex,s.length>0&&e.push(s),e.push(["get",r[1]])}if(1===e.length)return t;if(i<t.length)e.push(t.slice(i));else if(2===e.length)return["to-string",e[1]];return e}const Dn=h;var On="add",zn="remove",Nn="propertychange";function jn(t){for(const e in t)delete t[e]}function Gn(t){let e;for(e in t)return!1;return!e}function $n(t,e,n,i,r){if(r){const r=n;n=function(s){return t.removeEventListener(e,n),r.call(i??this,s)}}else i&&i!==t&&(n=n.bind(i));const s={target:t,type:e,listener:n};return t.addEventListener(e,n),s}function Bn(t,e,n,i){return $n(t,e,n,i,!0)}function Un(t){t&&t.target&&(t.target.removeEventListener(t.type,t.listener),jn(t))}var Vn="change",Xn="error",Wn="contextmenu",qn="click",Zn="dblclick",Kn="dragenter",Yn="dragover",Hn="drop",Jn="keydown",Qn="keypress",ti="load",ei="touchmove",ni="wheel";class ii{constructor(){this.disposed=!1}dispose(){this.disposed||(this.disposed=!0,this.disposeInternal())}disposeInternal(){}}function ri(t,e){return t>e?1:t<e?-1:0}function si(t,e){return t<e?1:t>e?-1:0}function oi(t,e,n){if(t[0]<=e)return 0;const i=t.length;if(e<=t[i-1])return i-1;if("function"==typeof n){for(let r=1;r<i;++r){const i=t[r];if(i===e)return r;if(i<e)return n(e,t[r-1],i)>0?r-1:r}return i-1}if(n>0){for(let n=1;n<i;++n)if(t[n]<e)return n-1;return i-1}if(n<0){for(let n=1;n<i;++n)if(t[n]<=e)return n;return i-1}for(let n=1;n<i;++n){if(t[n]==e)return n;if(t[n]<e)return t[n-1]-e<e-t[n]?n-1:n}return i-1}function ai(t,e,n){for(;e<n;){const i=t[e];t[e]=t[n],t[n]=i,++e,--n}}function li(t,e){const n=Array.isArray(e)?e:[e],i=n.length;for(let e=0;e<i;e++)t[t.length]=n[e]}function hi(t,e){const n=t.length;if(n!==e.length)return!1;for(let i=0;i<n;i++)if(t[i]!==e[i])return!1;return!0}function ci(){return!0}function ui(){return!1}function di(){}function fi(t){let e,n,i;return function(){const r=Array.prototype.slice.call(arguments);return n&&this===i&&hi(r,n)||(i=this,n=r,e=t.apply(this,arguments)),e}}function gi(t){return function(){let e;try{e=t()}catch(t){return Promise.reject(t)}return e instanceof Promise?e:Promise.resolve(e)}()}class pi{constructor(t){this.propagationStopped,this.defaultPrevented,this.type=t,this.target=null}preventDefault(){this.defaultPrevented=!0}stopPropagation(){this.propagationStopped=!0}}class mi extends ii{constructor(t){super(),this.eventTarget_=t,this.pendingRemovals_=null,this.dispatching_=null,this.listeners_=null}addEventListener(t,e){if(!t||!e)return;const n=this.listeners_||(this.listeners_={}),i=n[t]||(n[t]=[]);i.includes(e)||i.push(e)}dispatchEvent(t){const e="string"==typeof t,n=e?t:t.type,i=this.listeners_&&this.listeners_[n];if(!i)return;const r=e?new pi(t):t;r.target||(r.target=this.eventTarget_||this);const s=this.dispatching_||(this.dispatching_={}),o=this.pendingRemovals_||(this.pendingRemovals_={});let a;n in s||(s[n]=0,o[n]=0),++s[n];for(let t=0,e=i.length;t<e;++t)if(a="handleEvent"in i[t]?i[t].handleEvent(r):i[t].call(this,r),!1===a||r.propagationStopped){a=!1;break}if(0===--s[n]){let t=o[n];for(delete o[n];t--;)this.removeEventListener(n,di);delete s[n]}return a}disposeInternal(){this.listeners_&&jn(this.listeners_)}getListeners(t){return this.listeners_&&this.listeners_[t]||void 0}hasListener(t){return!!this.listeners_&&(t?t in this.listeners_:Object.keys(this.listeners_).length>0)}removeEventListener(t,e){if(!this.listeners_)return;const n=this.listeners_[t];if(!n)return;const i=n.indexOf(e);-1!==i&&(this.pendingRemovals_&&t in this.pendingRemovals_?(n[i]=di,++this.pendingRemovals_[t]):(n.splice(i,1),0===n.length&&delete this.listeners_[t]))}}class _i extends mi{constructor(){super(),this.on=this.onInternal,this.once=this.onceInternal,this.un=this.unInternal,this.revision_=0}changed(){++this.revision_,this.dispatchEvent(Vn)}getRevision(){return this.revision_}onInternal(t,e){if(Array.isArray(t)){const n=t.length,i=new Array(n);for(let r=0;r<n;++r)i[r]=$n(this,t[r],e);return i}return $n(this,t,e)}onceInternal(t,e){let n;if(Array.isArray(t)){const i=t.length;n=new Array(i);for(let r=0;r<i;++r)n[r]=Bn(this,t[r],e)}else n=Bn(this,t,e);return e.ol_key=n,n}unInternal(t,e){const n=e.ol_key;if(n)yi(n);else if(Array.isArray(t))for(let n=0,i=t.length;n<i;++n)this.removeEventListener(t[n],e);else this.removeEventListener(t,e)}}function yi(t){if(Array.isArray(t))for(let e=0,n=t.length;e<n;++e)Un(t[e]);else Un(t)}_i.prototype.on,_i.prototype.once,_i.prototype.un;var xi=Object.freeze({__proto__:null,default:_i,unByKey:yi});function vi(){throw new Error("Unimplemented abstract method.")}let bi=0;function wi(t){return t.ol_uid||(t.ol_uid=String(++bi))}class Si extends pi{constructor(t,e,n){super(t),this.key=e,this.oldValue=n}}class Ci extends _i{constructor(t){super(),this.on,this.once,this.un,wi(this),this.values_=null,void 0!==t&&this.setProperties(t)}get(t){let e;return this.values_&&this.values_.hasOwnProperty(t)&&(e=this.values_[t]),e}getKeys(){return this.values_&&Object.keys(this.values_)||[]}getProperties(){return this.values_&&Object.assign({},this.values_)||{}}getPropertiesInternal(){return this.values_}hasProperties(){return!!this.values_}notify(t,e){let n;n=`change:${t}`,this.hasListener(n)&&this.dispatchEvent(new Si(n,t,e)),n=Nn,this.hasListener(n)&&this.dispatchEvent(new Si(n,t,e))}addChangeListener(t,e){this.addEventListener(`change:${t}`,e)}removeChangeListener(t,e){this.removeEventListener(`change:${t}`,e)}set(t,e,n){const i=this.values_||(this.values_={});if(n)i[t]=e;else{const n=i[t];i[t]=e,n!==e&&this.notify(t,n)}}setProperties(t,e){for(const n in t)this.set(n,t[n],e)}applyProperties(t){t.values_&&Object.assign(this.values_||(this.values_={}),t.values_)}unset(t,e){if(this.values_&&t in this.values_){const n=this.values_[t];delete this.values_[t],Gn(this.values_)&&(this.values_=null),e||this.notify(t,n)}}}const Ei="length";class Pi extends pi{constructor(t,e,n){super(t),this.element=e,this.index=n}}class Ti extends Ci{constructor(t,e){if(super(),this.on,this.once,this.un,e=e||{},this.unique_=!!e.unique,this.array_=t??[],this.unique_)for(let t=1,e=this.array_.length;t<e;++t)this.assertUnique_(this.array_[t],t);this.updateLength_()}clear(){for(;this.getLength()>0;)this.pop()}extend(t){for(let e=0,n=t.length;e<n;++e)this.push(t[e]);return this}forEach(t){const e=this.array_;for(let n=0,i=e.length;n<i;++n)t(e[n],n,e)}getArray(){return this.array_}item(t){return this.array_[t]}getLength(){return this.get(Ei)}insertAt(t,e){if(t<0||t>this.getLength())throw new Error("Index out of bounds: "+t);this.unique_&&this.assertUnique_(e),this.array_.splice(t,0,e),this.updateLength_(),this.dispatchEvent(new Pi(On,e,t))}pop(){return this.removeAt(this.getLength()-1)}push(t){const e=this.getLength();return this.insertAt(e,t),this.getLength()}remove(t){const e=this.array_;for(let n=0,i=e.length;n<i;++n)if(e[n]===t)return this.removeAt(n)}removeAt(t){if(t<0||t>=this.getLength())return;const e=this.array_[t];return this.array_.splice(t,1),this.updateLength_(),this.dispatchEvent(new Pi(zn,e,t)),e}setAt(t,e){if(t>=this.getLength())return void this.insertAt(t,e);if(t<0)throw new Error("Index out of bounds: "+t);this.unique_&&this.assertUnique_(e,t);const n=this.array_[t];this.array_[t]=e,this.dispatchEvent(new Pi(zn,n,t)),this.dispatchEvent(new Pi(On,e,t))}updateLength_(){this.set(Ei,this.array_.length)}assertUnique_(t,e){const n=this.array_;for(let i=0,r=n.length;i<r;++i)if(n[i]===t&&i!==e)throw new Error("Duplicate item added to a unique collection")}}class Ri extends pi{constructor(t,e,n){super(t),this.map=e,this.frameState=void 0!==n?n:null}}class Fi extends Ri{constructor(t,e,n,i,r,s){super(t,e,r),this.originalEvent=n,this.pixel_=null,this.coordinate_=null,this.dragging=void 0!==i&&i,this.activePointers=s}get pixel(){return this.pixel_||(this.pixel_=this.map.getEventPixel(this.originalEvent)),this.pixel_}set pixel(t){this.pixel_=t}get coordinate(){return this.coordinate_||(this.coordinate_=this.map.getCoordinateFromPixel(this.pixel)),this.coordinate_}set coordinate(t){this.coordinate_=t}preventDefault(){super.preventDefault(),"preventDefault"in this.originalEvent&&this.originalEvent.preventDefault()}stopPropagation(){super.stopPropagation(),"stopPropagation"in this.originalEvent&&this.originalEvent.stopPropagation()}}var Mi={SINGLECLICK:"singleclick",CLICK:qn,DBLCLICK:Zn,POINTERDRAG:"pointerdrag",POINTERMOVE:"pointermove",POINTERDOWN:"pointerdown",POINTERUP:"pointerup",POINTEROVER:"pointerover",POINTEROUT:"pointerout",POINTERENTER:"pointerenter",POINTERLEAVE:"pointerleave",POINTERCANCEL:"pointercancel"};const Ii="undefined"!=typeof navigator&&void 0!==navigator.userAgent?navigator.userAgent.toLowerCase():"",ki=Ii.includes("safari")&&!Ii.includes("chrom")&&(Ii.includes("version/15.4")||/cpu (os|iphone os) 15_4 like mac os x/.test(Ii)),Li=Ii.includes("webkit")&&!Ii.includes("edge"),Ai=Ii.includes("macintosh"),Di="undefined"!=typeof devicePixelRatio?devicePixelRatio:1,Oi="undefined"!=typeof WorkerGlobalScope&&"undefined"!=typeof OffscreenCanvas&&self instanceof WorkerGlobalScope,zi="undefined"!=typeof Image&&Image.prototype.decode,Ni="function"==typeof createImageBitmap,ji=function(){let t=!1;try{const e=Object.defineProperty({},"passive",{get:function(){t=!0}});window.addEventListener("_",null,e),window.removeEventListener("_",null,e)}catch{}return t}();var Gi="pointermove",$i="pointerdown";class Bi extends mi{constructor(t,e){super(t),this.map_=t,this.clickTimeoutId_,this.emulateClicks_=!1,this.dragging_=!1,this.dragListenerKeys_=[],this.moveTolerance_=void 0===e?1:e,this.down_=null;const n=this.map_.getViewport();this.activePointers_=[],this.trackedTouches_={},this.element_=n,this.pointerdownListenerKey_=$n(n,$i,this.handlePointerDown_,this),this.originalPointerMoveEvent_,this.relayedListenerKey_=$n(n,Gi,this.relayMoveEvent_,this),this.boundHandleTouchMove_=this.handleTouchMove_.bind(this),this.element_.addEventListener(ei,this.boundHandleTouchMove_,!!ji&&{passive:!1})}emulateClick_(t){let e=new Fi(Mi.CLICK,this.map_,t);this.dispatchEvent(e),void 0!==this.clickTimeoutId_?(clearTimeout(this.clickTimeoutId_),this.clickTimeoutId_=void 0,e=new Fi(Mi.DBLCLICK,this.map_,t),this.dispatchEvent(e)):this.clickTimeoutId_=setTimeout(()=>{this.clickTimeoutId_=void 0;const e=new Fi(Mi.SINGLECLICK,this.map_,t);this.dispatchEvent(e)},250)}updateActivePointers_(t){const e=t,n=e.pointerId;if(e.type==Mi.POINTERUP||e.type==Mi.POINTERCANCEL){delete this.trackedTouches_[n];for(const t in this.trackedTouches_)if(this.trackedTouches_[t].target!==e.target){delete this.trackedTouches_[t];break}}else e.type!=Mi.POINTERDOWN&&e.type!=Mi.POINTERMOVE||(this.trackedTouches_[n]=e);this.activePointers_=Object.values(this.trackedTouches_)}handlePointerUp_(t){this.updateActivePointers_(t);const e=new Fi(Mi.POINTERUP,this.map_,t,void 0,void 0,this.activePointers_);this.dispatchEvent(e),this.emulateClicks_&&!e.defaultPrevented&&!this.dragging_&&this.isMouseActionButton_(t)&&this.emulateClick_(this.down_),0===this.activePointers_.length&&(this.dragListenerKeys_.forEach(Un),this.dragListenerKeys_.length=0,this.dragging_=!1,this.down_=null)}isMouseActionButton_(t){return 0===t.button}handlePointerDown_(t){this.emulateClicks_=0===this.activePointers_.length,this.updateActivePointers_(t);const e=new Fi(Mi.POINTERDOWN,this.map_,t,void 0,void 0,this.activePointers_);if(this.dispatchEvent(e),this.down_=new PointerEvent(t.type,t),Object.defineProperty(this.down_,"target",{writable:!1,value:t.target}),0===this.dragListenerKeys_.length){const t=this.map_.getOwnerDocument();this.dragListenerKeys_.push($n(t,Mi.POINTERMOVE,this.handlePointerMove_,this),$n(t,Mi.POINTERUP,this.handlePointerUp_,this),$n(this.element_,Mi.POINTERCANCEL,this.handlePointerUp_,this)),this.element_.getRootNode&&this.element_.getRootNode()!==t&&this.dragListenerKeys_.push($n(this.element_.getRootNode(),Mi.POINTERUP,this.handlePointerUp_,this))}}handlePointerMove_(t){if(this.isMoving_(t)){this.updateActivePointers_(t),this.dragging_=!0;const e=new Fi(Mi.POINTERDRAG,this.map_,t,this.dragging_,void 0,this.activePointers_);this.dispatchEvent(e)}}relayMoveEvent_(t){this.originalPointerMoveEvent_=t;const e=!(!this.down_||!this.isMoving_(t));this.dispatchEvent(new Fi(Mi.POINTERMOVE,this.map_,t,e))}handleTouchMove_(t){const e=this.originalPointerMoveEvent_;e&&!e.defaultPrevented||"boolean"==typeof t.cancelable&&!0!==t.cancelable||t.preventDefault()}isMoving_(t){return this.dragging_||Math.abs(t.clientX-this.down_.clientX)>this.moveTolerance_||Math.abs(t.clientY-this.down_.clientY)>this.moveTolerance_}disposeInternal(){this.relayedListenerKey_&&(Un(this.relayedListenerKey_),this.relayedListenerKey_=null),this.element_.removeEventListener(ei,this.boundHandleTouchMove_),this.pointerdownListenerKey_&&(Un(this.pointerdownListenerKey_),this.pointerdownListenerKey_=null),this.dragListenerKeys_.forEach(Un),this.dragListenerKeys_.length=0,this.element_=null,super.disposeInternal()}}var Ui="postrender",Vi="movestart",Xi="moveend",Wi="loadstart",qi="loadend",Zi="layergroup",Ki="size",Yi="target",Hi="view",Ji=0,Qi=1,tr=2,er=3,nr=4;function ir(t,e){if(!t)throw new Error(e)}const rr=1/0;class sr{constructor(t,e){this.priorityFunction_=t,this.keyFunction_=e,this.elements_=[],this.priorities_=[],this.queuedElements_={}}clear(){this.elements_.length=0,this.priorities_.length=0,jn(this.queuedElements_)}dequeue(){const t=this.elements_,e=this.priorities_,n=t[0];1==t.length?(t.length=0,e.length=0):(t[0]=t.pop(),e[0]=e.pop(),this.siftUp_(0));const i=this.keyFunction_(n);return delete this.queuedElements_[i],n}enqueue(t){ir(!(this.keyFunction_(t)in this.queuedElements_),"Tried to enqueue an `element` that was already added to the queue");const e=this.priorityFunction_(t);return e!=rr&&(this.elements_.push(t),this.priorities_.push(e),this.queuedElements_[this.keyFunction_(t)]=!0,this.siftDown_(0,this.elements_.length-1),!0)}getCount(){return this.elements_.length}getLeftChildIndex_(t){return 2*t+1}getRightChildIndex_(t){return 2*t+2}getParentIndex_(t){return t-1>>1}heapify_(){let t;for(t=(this.elements_.length>>1)-1;t>=0;t--)this.siftUp_(t)}isEmpty(){return 0===this.elements_.length}isKeyQueued(t){return t in this.queuedElements_}isQueued(t){return this.isKeyQueued(this.keyFunction_(t))}siftUp_(t){const e=this.elements_,n=this.priorities_,i=e.length,r=e[t],s=n[t],o=t;for(;t<i>>1;){const r=this.getLeftChildIndex_(t),s=this.getRightChildIndex_(t),o=s<i&&n[s]<n[r]?s:r;e[t]=e[o],n[t]=n[o],t=o}e[t]=r,n[t]=s,this.siftDown_(o,t)}siftDown_(t,e){const n=this.elements_,i=this.priorities_,r=n[e],s=i[e];for(;e>t;){const t=this.getParentIndex_(e);if(!(i[t]>s))break;n[e]=n[t],i[e]=i[t],e=t}n[e]=r,i[e]=s}reprioritize(){const t=this.priorityFunction_,e=this.elements_,n=this.priorities_;let i=0;const r=e.length;let s,o,a;for(o=0;o<r;++o)s=e[o],a=t(s),a==rr?delete this.queuedElements_[this.keyFunction_(s)]:(n[i]=a,e[i++]=s);e.length=i,n.length=i,this.heapify_()}}class or extends sr{constructor(t,e){super(e=>t.apply(null,e),t=>t[0].getKey()),this.boundHandleTileChange_=this.handleTileChange.bind(this),this.tileChangeCallback_=e,this.tilesLoading_=0,this.tilesLoadingKeys_={}}enqueue(t){const e=super.enqueue(t);if(e){t[0].addEventListener(Vn,this.boundHandleTileChange_)}return e}getTilesLoading(){return this.tilesLoading_}handleTileChange(t){const e=t.target,n=e.getState();if(n===tr||n===er||n===nr){n!==er&&e.removeEventListener(Vn,this.boundHandleTileChange_);const t=e.getKey();t in this.tilesLoadingKeys_&&(delete this.tilesLoadingKeys_[t],--this.tilesLoading_),this.tileChangeCallback_()}}loadMoreTiles(t,e){let n=0;for(;this.tilesLoading_<t&&n<e&&this.getCount()>0;){const t=this.dequeue()[0],e=t.getKey();t.getState()!==Ji||e in this.tilesLoadingKeys_||(this.tilesLoadingKeys_[e]=!0,++this.tilesLoading_,++n,t.load())}}}var ar=0,lr=1,hr={CENTER:"center",RESOLUTION:"resolution",ROTATION:"rotation"};function cr(t,e,n){return Math.min(Math.max(t,e),n)}function ur(t,e,n,i,r,s){const o=r-n,a=s-i;if(0!==o||0!==a){const l=((t-n)*o+(e-i)*a)/(o*o+a*a);l>1?(n=r,i=s):l>0&&(n+=o*l,i+=a*l)}return dr(t,e,n,i)}function dr(t,e,n,i){const r=n-t,s=i-e;return r*r+s*s}function fr(t){return 180*t/Math.PI}function gr(t){return t*Math.PI/180}function pr(t,e){const n=t%e;return n*e<0?n+e:n}function mr(t,e,n){return t+n*(e-t)}function _r(t,e){const n=Math.pow(10,e);return Math.round(t*n)/n}function yr(t,e){return Math.round(_r(t,e))}function xr(t,e){return Math.floor(_r(t,e))}function vr(t,e){return Math.ceil(_r(t,e))}function br(t,e,n){if(t>=e&&t<n)return t;const i=n-e;return((t-e)%i+i)%i+e}function wr(t,e,n){return function(i,r,s,o,a){if(!i)return;if(!r&&!e)return i;const l=e?0:s[0]*r,h=e?0:s[1]*r,c=a?a[0]:0,u=a?a[1]:0;let d=t[0]+l/2+c,f=t[2]-l/2+c,g=t[1]+h/2+u,p=t[3]-h/2+u;d>f&&(d=(f+d)/2,f=d),g>p&&(g=(p+g)/2,p=g);let m=cr(i[0],d,f),_=cr(i[1],g,p);if(o&&n&&r){const t=30*r;m+=-t*Math.log(1+Math.max(0,d-i[0])/t)+t*Math.log(1+Math.max(0,i[0]-f)/t),_+=-t*Math.log(1+Math.max(0,g-i[1])/t)+t*Math.log(1+Math.max(0,i[1]-p)/t)}return[m,_]}}function Sr(t){return t}var Cr=0,Er=1,Pr=2,Tr=4,Rr=8,Fr=16;function Mr(t){const e=Nr();for(let n=0,i=t.length;n<i;++n)Xr(e,t[n]);return e}function Ir(t,e,n){return n?(n[0]=t[0]-e,n[1]=t[1]-e,n[2]=t[2]+e,n[3]=t[3]+e,n):[t[0]-e,t[1]-e,t[2]+e,t[3]+e]}function kr(t,e){return e?(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e):t.slice()}function Lr(t,e,n){let i,r;return i=e<t[0]?t[0]-e:t[2]<e?e-t[2]:0,r=n<t[1]?t[1]-n:t[3]<n?n-t[3]:0,i*i+r*r}function Ar(t,e){return Or(t,e[0],e[1])}function Dr(t,e){return t[0]<=e[0]&&e[2]<=t[2]&&t[1]<=e[1]&&e[3]<=t[3]}function Or(t,e,n){return t[0]<=e&&e<=t[2]&&t[1]<=n&&n<=t[3]}function zr(t,e){const n=t[0],i=t[1],r=t[2],s=t[3],o=e[0],a=e[1];let l=Cr;return o<n?l|=Fr:o>r&&(l|=Tr),a<i?l|=Rr:a>s&&(l|=Pr),l===Cr&&(l=Er),l}function Nr(){return[1/0,1/0,-1/0,-1/0]}function jr(t,e,n,i,r){return r?(r[0]=t,r[1]=e,r[2]=n,r[3]=i,r):[t,e,n,i]}function Gr(t){return jr(1/0,1/0,-1/0,-1/0,t)}function $r(t,e){const n=t[0],i=t[1];return jr(n,i,n,i,e)}function Br(t,e,n,i,r){return Wr(Gr(r),t,e,n,i)}function Ur(t,e){return t[0]==e[0]&&t[2]==e[2]&&t[1]==e[1]&&t[3]==e[3]}function Vr(t,e){return e[0]<t[0]&&(t[0]=e[0]),e[2]>t[2]&&(t[2]=e[2]),e[1]<t[1]&&(t[1]=e[1]),e[3]>t[3]&&(t[3]=e[3]),t}function Xr(t,e){e[0]<t[0]&&(t[0]=e[0]),e[0]>t[2]&&(t[2]=e[0]),e[1]<t[1]&&(t[1]=e[1]),e[1]>t[3]&&(t[3]=e[1])}function Wr(t,e,n,i,r){for(;n<i;n+=r)qr(t,e[n],e[n+1]);return t}function qr(t,e,n){t[0]=Math.min(t[0],e),t[1]=Math.min(t[1],n),t[2]=Math.max(t[2],e),t[3]=Math.max(t[3],n)}function Zr(t,e){let n;return n=e(Yr(t)),n||(n=e(Hr(t)),n||(n=e(ss(t)),n||(n=e(rs(t)),n||!1)))}function Kr(t){let e=0;return ls(t)||(e=os(t)*ns(t)),e}function Yr(t){return[t[0],t[1]]}function Hr(t){return[t[2],t[1]]}function Jr(t){return[(t[0]+t[2])/2,(t[1]+t[3])/2]}function Qr(t,e){let n;if("bottom-left"===e)n=Yr(t);else if("bottom-right"===e)n=Hr(t);else if("top-left"===e)n=rs(t);else{if("top-right"!==e)throw new Error("Invalid corner");n=ss(t)}return n}function ts(t,e,n,i,r){const[s,o,a,l,h,c,u,d]=es(t,e,n,i);return jr(Math.min(s,a,h,u),Math.min(o,l,c,d),Math.max(s,a,h,u),Math.max(o,l,c,d),r)}function es(t,e,n,i){const r=e*i[0]/2,s=e*i[1]/2,o=Math.cos(n),a=Math.sin(n),l=r*o,h=r*a,c=s*o,u=s*a,d=t[0],f=t[1];return[d-l+u,f-h-c,d-l-u,f-h+c,d+l-u,f+h+c,d+l+u,f+h-c,d-l+u,f-h-c]}function ns(t){return t[3]-t[1]}function is(t,e,n){const i=n||[1/0,1/0,-1/0,-1/0];return as(t,e)?(t[0]>e[0]?i[0]=t[0]:i[0]=e[0],t[1]>e[1]?i[1]=t[1]:i[1]=e[1],t[2]<e[2]?i[2]=t[2]:i[2]=e[2],t[3]<e[3]?i[3]=t[3]:i[3]=e[3]):Gr(i),i}function rs(t){return[t[0],t[3]]}function ss(t){return[t[2],t[3]]}function os(t){return t[2]-t[0]}function as(t,e){return t[0]<=e[2]&&t[2]>=e[0]&&t[1]<=e[3]&&t[3]>=e[1]}function ls(t){return t[2]<t[0]||t[3]<t[1]}function hs(t,e,n,i){if(ls(t))return Gr(n);let r=[];if(i>1){const e=t[2]-t[0],n=t[3]-t[1];for(let s=0;s<i;++s)r.push(t[0]+e*s/i,t[1],t[2],t[1]+n*s/i,t[2]-e*s/i,t[3],t[0],t[3]-n*s/i)}else r=[t[0],t[1],t[2],t[1],t[2],t[3],t[0],t[3]];e(r,r,2);const s=[],o=[];for(let t=0,e=r.length;t<e;t+=2)s.push(r[t]),o.push(r[t+1]);return function(t,e,n){return jr(Math.min.apply(null,t),Math.min.apply(null,e),Math.max.apply(null,t),Math.max.apply(null,e),n)}(s,o,n)}function cs(t,e){const n=e.getExtent(),i=Jr(t);if(e.canWrapX()&&(i[0]<n[0]||i[0]>=n[2])){const e=os(n),r=Math.floor((i[0]-n[0])/e)*e;t[0]-=r,t[2]-=r}return t}function us(t,e,n){if(e.canWrapX()){const i=e.getExtent();if(!isFinite(t[0])||!isFinite(t[2]))return[[i[0],t[1],i[2],t[3]]];cs(t,e);const r=os(i);if(os(t)>r&&!n)return[[i[0],t[1],i[2],t[3]]];if(t[0]<i[0])return[[t[0]+r,t[1],i[2],t[3]],[i[0],t[1],t[2],t[3]]];if(t[2]>i[2])return[[t[0],t[1],i[2],t[3]],[i[0],t[1],t[2]-r,t[3]]]}return[t]}function ds(t,e){const n=(""+t).split("."),i=(""+e).split(".");for(let t=0;t<Math.max(n.length,i.length);t++){const e=parseInt(n[t]||"0",10),r=parseInt(i[t]||"0",10);if(e>r)return 1;if(r>e)return-1}return 0}function fs(t,e){const n=e.getRadius(),i=e.getCenter(),r=i[0],s=i[1];let o=t[0]-r;const a=t[1]-s;0===o&&0===a&&(o=1);const l=Math.sqrt(o*o+a*a);return[r+n*o/l,s+n*a/l]}function gs(t,e){const n=t[0],i=t[1],r=e[0],s=e[1],o=r[0],a=r[1],l=s[0],h=s[1],c=l-o,u=h-a,d=0===c&&0===u?0:(c*(n-o)+u*(i-a))/(c*c+u*u||0);let f,g;return d<=0?(f=o,g=a):d>=1?(f=l,g=h):(f=o+d*c,g=a+d*u),[f,g]}function ps(t,e){let n=!0;for(let i=t.length-1;i>=0;--i)if(t[i]!=e[i]){n=!1;break}return n}function ms(t,e){const n=Math.cos(e),i=Math.sin(e),r=t[0]*n-t[1]*i,s=t[1]*n+t[0]*i;return t[0]=r,t[1]=s,t}function _s(t,e){const n=t[0]-e[0],i=t[1]-e[1];return n*n+i*i}function ys(t,e){return Math.sqrt(_s(t,e))}function xs(t,e){return _s(t,gs(t,e))}function vs(t,e){if(e.canWrapX()){const n=os(e.getExtent()),i=bs(t,e,n);i&&(t[0]-=i*n)}return t}function bs(t,e,n){const i=e.getExtent();let r=0;return e.canWrapX()&&(t[0]<i[0]||t[0]>i[2])&&(n=n||os(i),r=Math.floor((t[0]-i[0])/n)),r}function ws(t){return Math.pow(t,3)}function Ss(t){return 1-ws(1-t)}function Cs(t){return 3*t*t-2*t*t*t}function Es(t){return t}const Ps=6371008.8;function Ts(t,e,n){n=n||Ps;const i=gr(t[1]),r=gr(e[1]),s=(r-i)/2,o=gr(e[0]-t[0])/2,a=Math.sin(s)*Math.sin(s)+Math.sin(o)*Math.sin(o)*Math.cos(i)*Math.cos(r);return 2*n*Math.atan2(Math.sqrt(a),Math.sqrt(1-a))}function Rs(t,e){let n=0;for(let i=0,r=t.length;i<r-1;++i)n+=Ts(t[i],t[i+1],e);return n}function Fs(t,e){let n=0;const i=t.length;let r=t[i-1][0],s=t[i-1][1];for(let e=0;e<i;e++){const i=t[e][0],o=t[e][1];n+=gr(i-r)*(2+Math.sin(gr(s))+Math.sin(gr(o))),r=i,s=o}return n*e*e/2}var Ms=Object.freeze({__proto__:null,DEFAULT_RADIUS:Ps,getArea:function t(e,n){const i=(n=n||{}).radius||Ps,r=n.projection||"EPSG:3857",s=e.getType();"GeometryCollection"!==s&&(e=e.clone().transform(r,"EPSG:4326"));let o,a,l,h,c,u,d=0;switch(s){case"Point":case"MultiPoint":case"LineString":case"MultiLineString":case"LinearRing":break;case"Polygon":for(o=e.getCoordinates(),d=Math.abs(Fs(o[0],i)),l=1,h=o.length;l<h;++l)d-=Math.abs(Fs(o[l],i));break;case"MultiPolygon":for(o=e.getCoordinates(),l=0,h=o.length;l<h;++l)for(a=o[l],d+=Math.abs(Fs(a[0],i)),c=1,u=a.length;c<u;++c)d-=Math.abs(Fs(a[c],i));break;case"GeometryCollection":{const i=e.getGeometries();for(l=0,h=i.length;l<h;++l)d+=t(i[l],n);break}default:throw new Error("Unsupported geometry type: "+s)}return d},getDistance:Ts,getLength:function t(e,n){const i=(n=n||{}).radius||Ps,r=n.projection||"EPSG:3857",s=e.getType();"GeometryCollection"!==s&&(e=e.clone().transform(r,"EPSG:4326"));let o,a,l,h,c,u,d=0;switch(s){case"Point":case"MultiPoint":break;case"LineString":case"LinearRing":o=e.getCoordinates(),d=Rs(o,i);break;case"MultiLineString":case"Polygon":for(o=e.getCoordinates(),l=0,h=o.length;l<h;++l)d+=Rs(o[l],i);break;case"MultiPolygon":for(o=e.getCoordinates(),l=0,h=o.length;l<h;++l)for(a=o[l],c=0,u=a.length;c<u;++c)d+=Rs(a[c],i);break;case"GeometryCollection":{const i=e.getGeometries();for(l=0,h=i.length;l<h;++l)d+=t(i[l],n);break}default:throw new Error("Unsupported geometry type: "+s)}return d},offset:function(t,e,n,i){i=i||Ps;const r=gr(t[1]),s=gr(t[0]),o=e/i,a=Math.asin(Math.sin(r)*Math.cos(o)+Math.cos(r)*Math.sin(o)*Math.cos(n));return[fr(s+Math.atan2(Math.sin(n)*Math.sin(o)*Math.cos(r),Math.cos(o)-Math.sin(r)*Math.sin(a))),fr(a)]}});function Is(...t){console.warn(...t)}const ks={radians:6370997/(2*Math.PI),degrees:2*Math.PI*6370997/360,ft:.3048,m:1,"us-ft":1200/3937};class Ls{constructor(t){this.code_=t.code,this.units_=t.units,this.extent_=void 0!==t.extent?t.extent:null,this.worldExtent_=void 0!==t.worldExtent?t.worldExtent:null,this.axisOrientation_=void 0!==t.axisOrientation?t.axisOrientation:"enu",this.global_=void 0!==t.global&&t.global,this.canWrapX_=!(!this.global_||!this.extent_),this.getPointResolutionFunc_=t.getPointResolution,this.defaultTileGrid_=null,this.metersPerUnit_=t.metersPerUnit}canWrapX(){return this.canWrapX_}getCode(){return this.code_}getExtent(){return this.extent_}getUnits(){return this.units_}getMetersPerUnit(){return this.metersPerUnit_||ks[this.units_]}getWorldExtent(){return this.worldExtent_}getAxisOrientation(){return this.axisOrientation_}isGlobal(){return this.global_}setGlobal(t){this.global_=t,this.canWrapX_=!(!t||!this.extent_)}getDefaultTileGrid(){return this.defaultTileGrid_}setDefaultTileGrid(t){this.defaultTileGrid_=t}setExtent(t){this.extent_=t,this.canWrapX_=!(!this.global_||!t)}setWorldExtent(t){this.worldExtent_=t}setGetPointResolution(t){this.getPointResolutionFunc_=t}getPointResolutionFunc(){return this.getPointResolutionFunc_}}const As=6378137,Ds=Math.PI*As,Os=[-Ds,-Ds,Ds,Ds],zs=[-180,-85,180,85],Ns=As*Math.log(Math.tan(Math.PI/2));class js extends Ls{constructor(t){super({code:t,units:"m",extent:Os,global:!0,worldExtent:zs,getPointResolution:function(t,e){return t/Math.cosh(e[1]/As)}})}}const Gs=[new js("EPSG:3857"),new js("EPSG:102100"),new js("EPSG:102113"),new js("EPSG:900913"),new js("http://www.opengis.net/def/crs/EPSG/0/3857"),new js("http://www.opengis.net/gml/srs/epsg.xml#3857")];function $s(t,e,n,i){const r=t.length;n=n>1?n:2,i=i??n,void 0===e&&(e=n>2?t.slice():new Array(r));for(let n=0;n<r;n+=i){e[n]=Ds*t[n]/180;let i=As*Math.log(Math.tan(Math.PI*(+t[n+1]+90)/360));i>Ns?i=Ns:i<-Ns&&(i=-Ns),e[n+1]=i}return e}function Bs(t,e,n,i){const r=t.length;n=n>1?n:2,i=i??n,void 0===e&&(e=n>2?t.slice():new Array(r));for(let n=0;n<r;n+=i)e[n]=180*t[n]/Ds,e[n+1]=360*Math.atan(Math.exp(t[n+1]/As))/Math.PI-90;return e}const Us=[-180,-90,180,90],Vs=6378137*Math.PI/180;class Xs extends Ls{constructor(t,e){super({code:t,units:"degrees",extent:Us,axisOrientation:e,global:!0,metersPerUnit:Vs,worldExtent:Us})}}const Ws=[new Xs("CRS:84"),new Xs("EPSG:4326","neu"),new Xs("urn:ogc:def:crs:OGC:1.3:CRS84"),new Xs("urn:ogc:def:crs:OGC:2:84"),new Xs("http://www.opengis.net/def/crs/OGC/1.3/CRS84"),new Xs("http://www.opengis.net/gml/srs/epsg.xml#4326","neu"),new Xs("http://www.opengis.net/def/crs/EPSG/0/4326","neu")];let qs={};let Zs={};function Ks(t,e,n){const i=t.getCode(),r=e.getCode();i in Zs||(Zs[i]={}),Zs[i][r]=n}function Ys(t,e){return t in Zs&&e in Zs[t]?Zs[t][e]:null}const Hs=.9996,Js=.00669438,Qs=Js*Js,to=Qs*Js,eo=Js/(1-Js),no=Math.sqrt(1-Js),io=(1-no)/(1+no),ro=io*io,so=ro*io,oo=so*io,ao=oo*io,lo=.9983242984503243,ho=15*Qs/256+45*to/1024,co=35*to/3072,uo=1.5*io-27/32*so+269/512*ao,fo=21/16*ro-55/32*oo,go=151/96*so-417/128*ao,po=1097/512*oo,mo=6378137;function _o(t,e,n){const i=t-5e5,r=(n.north?e:e-1e7)/Hs/(mo*lo),s=r+uo*Math.sin(2*r)+fo*Math.sin(4*r)+go*Math.sin(6*r)+po*Math.sin(8*r),o=Math.sin(s),a=o*o,l=Math.cos(s),h=o/l,c=h*h,u=c*c,d=1-Js*a,f=Math.sqrt(1-Js*a),g=eo*l**2,p=g*g,m=i/(mo/f*Hs),_=m*m,y=_*m,x=y*m,v=x*m,b=s-h/((1-Js)/d)*(_/2-x/24*(5+3*c+10*g-4*p-9*eo))+v*m/720*(61+90*c+298*g+45*u-252*eo-3*p);let w=(m-y/6*(1+2*c+g)+v/120*(5-2*g+28*c-3*p+8*eo+24*u))/l;return w=br(w+gr(xo(n.number)),-Math.PI,Math.PI),[fr(w),fr(b)]}function yo(t,e,n){t=br(t,-180,180),e<-80?e=-80:e>84&&(e=84);const i=gr(e),r=Math.sin(i),s=Math.cos(i),o=r/s,a=o*o,l=a*a,h=gr(t),c=gr(xo(n.number)),u=mo/Math.sqrt(1-Js*r**2),d=eo*s**2,f=s*br(h-c,-Math.PI,Math.PI),g=f*f,p=g*f,m=p*f,_=m*f,y=_*f,x=mo*(lo*i-.002514607064228144*Math.sin(2*i)+ho*Math.sin(4*i)-co*Math.sin(6*i)),v=Hs*u*(f+p/6*(1-a+d)+_/120*(5-18*a+l+72*d-58*eo))+5e5;let b=Hs*(x+u*o*(g/2+m/24*(5-a+9*d+4*d**2)+y/720*(61-58*a+l+600*d-330*eo)));return n.north||(b+=1e7),[v,b]}function xo(t){return 6*(t-1)-180+3}const vo=[/^EPSG:(\d+)$/,/^urn:ogc:def:crs:EPSG::(\d+)$/,/^http:\/\/www\.opengis\.net\/def\/crs\/EPSG\/0\/(\d+)$/];function bo(t){let e=0;for(const n of vo){const i=t.match(n);if(i){e=parseInt(i[1]);break}}if(!e)return null;let n=0,i=!1;return e>32700&&e<32761?n=e-32700:e>32600&&e<32661&&(i=!0,n=e-32600),n?{number:n,north:i}:null}function wo(t,e){return function(n,i,r,s){const o=n.length;r=r>1?r:2,s=s??r,i||(i=r>2?n.slice():new Array(o));for(let r=0;r<o;r+=s){const s=n[r],o=n[r+1],a=t(s,o,e);i[r]=a[0],i[r+1]=a[1]}return i}}const So=[function(t){const e=bo(t.getCode());return e?{forward:wo(yo,e),inverse:wo(_o,e)}:null}],Co=[function(t){return bo(t)?new Ls({code:t,units:"m"}):null}];let Eo=!0;function Po(t){Eo=!(void 0===t||t)}function To(t,e){if(void 0!==e)for(let n=0,i=t.length;n<i;++n)e[n]=t[n];else e=t.slice();return e}function Ro(t){!function(t,e){qs[t]=e}(t.getCode(),t),Ks(t,t,To)}function Fo(t){t.forEach(Ro)}function Mo(t){if("string"!=typeof t)return t;const e=qs[n=t]||qs[n.replace(/urn:(x-)?ogc:def:crs:EPSG:(.*:)?(\w+)$/,"EPSG:$3")]||null;var n;if(e)return e;for(const e of Co){const n=e(t);if(n)return n}return null}function Io(t,e,n,i){let r;const s=(t=Mo(t)).getPointResolutionFunc();if(s){if(r=s(e,n),i&&i!==t.getUnits()){const e=t.getMetersPerUnit();e&&(r=r*e/ks[i])}}else{const s=t.getUnits();if("degrees"==s&&!i||"degrees"==i)r=e;else{const o=No(t,Mo("EPSG:4326"));if(o||"degrees"===s){let t=[n[0]-e/2,n[1],n[0]+e/2,n[1],n[0],n[1]-e/2,n[0],n[1]+e/2];t=o(t,t,2);r=(Ts(t.slice(0,2),t.slice(2,4))+Ts(t.slice(4,6),t.slice(6,8)))/2}else r=e*t.getMetersPerUnit();const a=i?ks[i]:t.getMetersPerUnit();void 0!==a&&(r/=a)}}return r}function ko(t){Fo(t),t.forEach(function(e){t.forEach(function(t){e!==t&&Ks(e,t,To)})})}function Lo(t,e,n,i){t.forEach(function(t){e.forEach(function(e){Ks(t,e,n),Ks(e,t,i)})})}function Ao(t,e){return t?"string"==typeof t?Mo(t):t:Mo(e)}function Do(t){return function(e,n,i,r){const s=e.length;i=void 0!==i?i:2,r=r??i,n=void 0!==n?n:new Array(s);for(let o=0;o<s;o+=r){const s=t(e.slice(o,o+i)),a=s.length;for(let t=0,i=r;t<i;++t)n[o+t]=t>=a?e[o+t]:s[t]}return n}}function Oo(t,e){return Po(),$o(t,"EPSG:4326",void 0!==e?e:"EPSG:3857")}function zo(t,e){if(t===e)return!0;const n=t.getUnits()===e.getUnits();if(t.getCode()===e.getCode())return n;return No(t,e)===To&&n}function No(t,e){const n=t.getCode(),i=e.getCode();let r=Ys(n,i);if(r)return r;let s=null,o=null;for(const n of So)s||(s=n(t)),o||(o=n(e));if(!s&&!o)return null;const a="EPSG:4326";if(o)if(s)r=jo(s.inverse,o.forward);else{const t=Ys(n,a);t&&(r=jo(t,o.forward))}else{const t=Ys(a,i);t&&(r=jo(s.inverse,t))}return r&&(Ro(t),Ro(e),Ks(t,e,r)),r}function jo(t,e){return function(n,i,r,s){return i=t(n,i,r,s),e(i,i,r,s)}}function Go(t,e){return No(Mo(t),Mo(e))}function $o(t,e,n){const i=Go(e,n);if(!i){const t=Mo(e).getCode(),i=Mo(n).getCode();throw new Error(`No transform available between ${t} and ${i}`)}return i(t,void 0,t.length)}function Bo(t,e,n,i){return hs(t,Go(e,n),void 0,i)}let Uo=null;function Vo(t){Uo=Mo(t)}function Xo(){return Uo}function Wo(t,e){return Uo?$o(t,e,Uo):t}function qo(t,e){return Uo?$o(t,Uo,e):(Eo&&!ps(t,[0,0])&&t[0]>=-180&&t[0]<=180&&t[1]>=-90&&t[1]<=90&&(Eo=!1,Is("Call useGeographic() from ol/proj once to work with [longitude, latitude] coordinates.")),t)}function Zo(t,e){return Uo?Bo(t,e,Uo):t}function Ko(t,e){return Uo?Bo(t,Uo,e):t}function Yo(t,e){if(!Uo)return t;const n=Mo(e).getMetersPerUnit(),i=Uo.getMetersPerUnit();return n&&i?t*n/i:t}function Ho(){ko(Gs),ko(Ws),Lo(Ws,Gs,$s,Bs)}Ho();var Jo=Object.freeze({__proto__:null,METERS_PER_UNIT:ks,Projection:Ls,addCommon:Ho,addCoordinateTransforms:function(t,e,n,i){const r=Mo(t),s=Mo(e);Ks(r,s,Do(n)),Ks(s,r,Do(i))},addEquivalentProjections:ko,addEquivalentTransforms:Lo,addProjection:Ro,addProjections:Fo,clearAllProjections:function(){qs={},Zs={}},clearUserProjection:function(){Uo=null},cloneTransform:To,createProjection:Ao,createSafeCoordinateTransform:function(t,e,n){return function(i){let r,s;if(t.canWrapX()){const e=t.getExtent(),o=os(e);s=bs(i=i.slice(0),t,o),s&&(i[0]=i[0]-s*o),i[0]=cr(i[0],e[0],e[2]),i[1]=cr(i[1],e[1],e[3]),r=n(i)}else r=n(i);return s&&e.canWrapX()&&(r[0]+=s*os(e.getExtent())),r}},createTransformFromCoordinateTransform:Do,disableCoordinateWarning:Po,equivalent:zo,fromLonLat:Oo,fromUserCoordinate:qo,fromUserExtent:Ko,fromUserResolution:function(t,e){if(!Uo)return t;const n=Mo(e).getMetersPerUnit(),i=Uo.getMetersPerUnit();return n&&i?t*i/n:t},get:Mo,getPointResolution:Io,getTransform:Go,getTransformFromProjections:No,getUserProjection:Xo,identityTransform:function(t,e){if(void 0!==e&&t!==e){for(let n=0,i=t.length;n<i;++n)e[n]=t[n];t=e}return t},setUserProjection:Vo,toLonLat:function(t,e){const n=$o(t,void 0!==e?e:"EPSG:3857","EPSG:4326"),i=n[0];return(i<-180||i>180)&&(n[0]=pr(i+180,360)-180),n},toUserCoordinate:Wo,toUserExtent:Zo,toUserResolution:Yo,transform:$o,transformExtent:Bo,transformWithProjections:function(t,e,n){return No(e,n)(t)},useGeographic:function(){Vo("EPSG:4326")}});const Qo=new Array(6);function ta(t){return na(t,1,0,0,1,0,0)}function ea(t,e){const n=t[0],i=t[1],r=t[2],s=t[3],o=t[4],a=t[5],l=e[0],h=e[1],c=e[2],u=e[3],d=e[4],f=e[5];return t[0]=n*l+r*h,t[1]=i*l+s*h,t[2]=n*c+r*u,t[3]=i*c+s*u,t[4]=n*d+r*f+o,t[5]=i*d+s*f+a,t}function na(t,e,n,i,r,s,o){return t[0]=e,t[1]=n,t[2]=i,t[3]=r,t[4]=s,t[5]=o,t}function ia(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t}function ra(t,e){const n=e[0],i=e[1];return e[0]=t[0]*n+t[2]*i+t[4],e[1]=t[1]*n+t[3]*i+t[5],e}function sa(t,e,n){return ea(t,na(Qo,e,0,0,n,0,0))}function oa(t,e,n){return ea(t,na(Qo,1,0,0,1,e,n))}function aa(t,e,n,i,r,s,o,a){const l=Math.sin(s),h=Math.cos(s);return t[0]=i*h,t[1]=r*l,t[2]=-i*l,t[3]=r*h,t[4]=o*i*h-a*i*l+e,t[5]=o*r*l+a*r*h+n,t}function la(t,e){const n=(i=e)[0]*i[3]-i[1]*i[2];var i;ir(0!==n,"Transformation matrix cannot be inverted");const r=e[0],s=e[1],o=e[2],a=e[3],l=e[4],h=e[5];return t[0]=a/n,t[1]=-s/n,t[2]=-o/n,t[3]=r/n,t[4]=(o*h-a*l)/n,t[5]=-(r*h-s*l)/n,t}const ha=[1e5,1e5,1e5,1e5,2,2];function ca(t){return t.substring(7,t.length-1).split(",").map(parseFloat)}function ua(t,e,n,i,r,s,o){s=s||[],o=o||2;let a=0;for(let l=e;l<n;l+=i){const e=t[l],n=t[l+1];s[a++]=r[0]*e+r[2]*n+r[4],s[a++]=r[1]*e+r[3]*n+r[5];for(let e=2;e<o;e++)s[a++]=t[l+e]}return s&&s.length!=a&&(s.length=a),s}function da(t,e,n,i,r,s,o){o=o||[];const a=Math.cos(r),l=Math.sin(r),h=s[0],c=s[1];let u=0;for(let r=e;r<n;r+=i){const e=t[r]-h,n=t[r+1]-c;o[u++]=h+e*a-n*l,o[u++]=c+e*l+n*a;for(let e=r+2;e<r+i;++e)o[u++]=t[e]}return o&&o.length!=u&&(o.length=u),o}const fa=[1,0,0,1,0,0],ga=[NaN,NaN];class pa extends Ci{constructor(){super(),this.extent_=[1/0,1/0,-1/0,-1/0],this.extentRevision_=-1,this.simplifiedGeometryMaxMinSquaredTolerance=0,this.simplifiedGeometryRevision=0,this.simplifyTransformedInternal=fi((t,e,n)=>{if(!n)return this.getSimplifiedGeometry(e);const i=this.clone();return i.applyTransform(n),i.getSimplifiedGeometry(e)})}simplifyTransformed(t,e){return this.simplifyTransformedInternal(this.getRevision(),t,e)}clone(){return vi()}closestPointXY(t,e,n,i){return vi()}containsXY(t,e){return 0===this.closestPointXY(t,e,ga,Number.MIN_VALUE)}getClosestPoint(t,e){return e=e||[NaN,NaN],this.closestPointXY(t[0],t[1],e,1/0),e}intersectsCoordinate(t){return this.containsXY(t[0],t[1])}computeExtent(t){return vi()}getExtent(t){if(this.extentRevision_!=this.getRevision()){const t=this.computeExtent(this.extent_);(isNaN(t[0])||isNaN(t[1]))&&Gr(t),this.extentRevision_=this.getRevision()}return function(t,e){return e?(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e):t}(this.extent_,t)}rotate(t,e){vi()}scale(t,e,n){vi()}simplify(t){return this.getSimplifiedGeometry(t*t)}getSimplifiedGeometry(t){return vi()}getType(){return vi()}applyTransform(t){vi()}intersectsExtent(t){return vi()}translate(t,e){vi()}transform(t,e){const n=Mo(t),i="tile-pixels"==n.getUnits()?function(t,i,r){const s=n.getExtent(),o=n.getWorldExtent(),a=ns(o)/ns(s);aa(fa,o[0],o[3],a,-a,0,0,0);const l=ua(t,0,t.length,r,fa,i),h=Go(n,e);return h?h(l,l,r):l}:Go(n,e);return this.applyTransform(i),this}}class ma extends pa{constructor(){super(),this.layout="XY",this.stride=2,this.flatCoordinates}computeExtent(t){return Br(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t)}getCoordinates(){return vi()}getFirstCoordinate(){return this.flatCoordinates.slice(0,this.stride)}getFlatCoordinates(){return this.flatCoordinates}getLastCoordinate(){return this.flatCoordinates.slice(this.flatCoordinates.length-this.stride)}getLayout(){return this.layout}getSimplifiedGeometry(t){if(this.simplifiedGeometryRevision!==this.getRevision()&&(this.simplifiedGeometryMaxMinSquaredTolerance=0,this.simplifiedGeometryRevision=this.getRevision()),t<0||0!==this.simplifiedGeometryMaxMinSquaredTolerance&&t<=this.simplifiedGeometryMaxMinSquaredTolerance)return this;const e=this.getSimplifiedGeometryInternal(t);return e.getFlatCoordinates().length<this.flatCoordinates.length?e:(this.simplifiedGeometryMaxMinSquaredTolerance=t,this)}getSimplifiedGeometryInternal(t){return this}getStride(){return this.stride}setFlatCoordinates(t,e){this.stride=ya(t),this.layout=t,this.flatCoordinates=e}setCoordinates(t,e){vi()}setLayout(t,e,n){let i;if(t)i=ya(t);else{for(let t=0;t<n;++t){if(0===e.length)return this.layout="XY",void(this.stride=2);e=e[0]}i=e.length,t=_a(i)}this.layout=t,this.stride=i}applyTransform(t){this.flatCoordinates&&(t(this.flatCoordinates,this.flatCoordinates,this.layout.startsWith("XYZ")?3:2,this.stride),this.changed())}rotate(t,e){const n=this.getFlatCoordinates();if(n){const i=this.getStride();da(n,0,n.length,i,t,e,n),this.changed()}}scale(t,e,n){void 0===e&&(e=t),n||(n=Jr(this.getExtent()));const i=this.getFlatCoordinates();if(i){const r=this.getStride();!function(t,e,n,i,r,s,o,a){a=a||[];const l=o[0],h=o[1];let c=0;for(let o=e;o<n;o+=i){const e=t[o]-l,n=t[o+1]-h;a[c++]=l+r*e,a[c++]=h+s*n;for(let e=o+2;e<o+i;++e)a[c++]=t[e]}a&&a.length!=c&&(a.length=c)}(i,0,i.length,r,t,e,n,i),this.changed()}}translate(t,e){const n=this.getFlatCoordinates();if(n){const i=this.getStride();!function(t,e,n,i,r,s,o){o=o||[];let a=0;for(let l=e;l<n;l+=i){o[a++]=t[l]+r,o[a++]=t[l+1]+s;for(let e=l+2;e<l+i;++e)o[a++]=t[e]}o&&o.length!=a&&(o.length=a)}(n,0,n.length,i,t,e,n),this.changed()}}}function _a(t){let e;return 2==t?e="XY":3==t?e="XYZ":4==t&&(e="XYZM"),e}function ya(t){let e;return"XY"==t?e=2:"XYZ"==t||"XYM"==t?e=3:"XYZM"==t&&(e=4),e}function xa(t,e,n,i){let r=0;const s=t[n-i],o=t[n-i+1];let a=0,l=0;for(;e<n;e+=i){const n=t[e]-s,i=t[e+1]-o;r+=l*n-a*i,a=n,l=i}return r/2}function va(t,e,n,i){let r=0;for(let s=0,o=n.length;s<o;++s){const o=n[s];r+=xa(t,e,o,i),e=o}return r}function ba(t,e,n,i,r,s,o){const a=t[e],l=t[e+1],h=t[n]-a,c=t[n+1]-l;let u;if(0===h&&0===c)u=e;else{const d=((r-a)*h+(s-l)*c)/(h*h+c*c);if(d>1)u=n;else{if(d>0){for(let r=0;r<i;++r)o[r]=mr(t[e+r],t[n+r],d);return void(o.length=i)}u=e}}for(let e=0;e<i;++e)o[e]=t[u+e];o.length=i}function wa(t,e,n,i,r){let s=t[e],o=t[e+1];for(e+=i;e<n;e+=i){const n=t[e],i=t[e+1],a=dr(s,o,n,i);a>r&&(r=a),s=n,o=i}return r}function Sa(t,e,n,i,r){for(let s=0,o=n.length;s<o;++s){const o=n[s];r=wa(t,e,o,i,r),e=o}return r}function Ca(t,e,n,i,r,s,o,a,l,h,c){if(e==n)return h;let u,d;if(0===r){if(d=dr(o,a,t[e],t[e+1]),d<h){for(u=0;u<i;++u)l[u]=t[e+u];return l.length=i,d}return h}c=c||[NaN,NaN];let f=e+i;for(;f<n;)if(ba(t,f-i,f,i,o,a,c),d=dr(o,a,c[0],c[1]),d<h){for(h=d,u=0;u<i;++u)l[u]=c[u];l.length=i,f+=i}else f+=i*Math.max((Math.sqrt(d)-Math.sqrt(h))/r|0,1);if(s&&(ba(t,n-i,e,i,o,a,c),d=dr(o,a,c[0],c[1]),d<h)){for(h=d,u=0;u<i;++u)l[u]=c[u];l.length=i}return h}function Ea(t,e,n,i,r,s,o,a,l,h,c){c=c||[NaN,NaN];for(let u=0,d=n.length;u<d;++u){const d=n[u];h=Ca(t,e,d,i,r,s,o,a,l,h,c),e=d}return h}function Pa(t,e,n,i){for(let i=0,r=n.length;i<r;++i)t[e++]=n[i];return e}function Ta(t,e,n,i){for(let r=0,s=n.length;r<s;++r){const s=n[r];for(let n=0;n<i;++n)t[e++]=s[n]}return e}function Ra(t,e,n,i,r){r=r||[];let s=0;for(let o=0,a=n.length;o<a;++o){const a=Ta(t,e,n[o],i);r[s++]=a,e=a}return r.length=s,r}function Fa(t,e,n,i,r){r=r||[];let s=0;for(let o=0,a=n.length;o<a;++o){const a=Ra(t,e,n[o],i,r[s]);0===a.length&&(a[0]=e),r[s++]=a,e=a[a.length-1]}return r.length=s,r}function Ma(t,e,n,i,r){r=void 0!==r?r:[];let s=0;for(let o=e;o<n;o+=i)r[s++]=t.slice(o,o+i);return r.length=s,r}function Ia(t,e,n,i,r){r=void 0!==r?r:[];let s=0;for(let o=0,a=n.length;o<a;++o){const a=n[o];r[s++]=Ma(t,e,a,i,r[s]),e=a}return r.length=s,r}function ka(t,e,n,i,r){r=void 0!==r?r:[];let s=0;for(let o=0,a=n.length;o<a;++o){const a=n[o];r[s++]=1===a.length&&a[0]===e?[]:Ia(t,e,a,i,r[s]),e=a[a.length-1]}return r.length=s,r}function La(t,e,n,i,r,s,o){const a=(n-e)/i;if(a<3){for(;e<n;e+=i)s[o++]=t[e],s[o++]=t[e+1];return o}const l=new Array(a);l[0]=1,l[a-1]=1;const h=[e,n-i];let c=0;for(;h.length>0;){const n=h.pop(),s=h.pop();let o=0;const a=t[s],u=t[s+1],d=t[n],f=t[n+1];for(let e=s+i;e<n;e+=i){const n=ur(t[e],t[e+1],a,u,d,f);n>o&&(c=e,o=n)}o>r&&(l[(c-e)/i]=1,s+i<c&&h.push(s,c),c+i<n&&h.push(c,n))}for(let n=0;n<a;++n)l[n]&&(s[o++]=t[e+n*i],s[o++]=t[e+n*i+1]);return o}function Aa(t,e,n,i,r,s,o,a){for(let l=0,h=n.length;l<h;++l){const h=n[l];o=La(t,e,h,i,r,s,o),a.push(o),e=h}return o}function Da(t,e){return e*Math.round(t/e)}function Oa(t,e,n,i,r,s,o){if(e==n)return o;let a,l,h=Da(t[e],r),c=Da(t[e+1],r);e+=i,s[o++]=h,s[o++]=c;do{if(a=Da(t[e],r),l=Da(t[e+1],r),(e+=i)==n)return s[o++]=a,s[o++]=l,o}while(a==h&&l==c);for(;e<n;){const n=Da(t[e],r),u=Da(t[e+1],r);if(e+=i,n==a&&u==l)continue;const d=a-h,f=l-c,g=n-h,p=u-c;d*p==f*g&&(d<0&&g<d||d==g||d>0&&g>d)&&(f<0&&p<f||f==p||f>0&&p>f)?(a=n,l=u):(s[o++]=a,s[o++]=l,h=a,c=l,a=n,l=u)}return s[o++]=a,s[o++]=l,o}function za(t,e,n,i,r,s,o,a){for(let l=0,h=n.length;l<h;++l){const h=n[l];o=Oa(t,e,h,i,r,s,o),a.push(o),e=h}return o}class Na extends ma{constructor(t,e){super(),this.maxDelta_=-1,this.maxDeltaRevision_=-1,void 0===e||Array.isArray(t[0])?this.setCoordinates(t,e):this.setFlatCoordinates(e,t)}clone(){return new Na(this.flatCoordinates.slice(),this.layout)}closestPointXY(t,e,n,i){return i<Lr(this.getExtent(),t,e)?i:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(wa(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),Ca(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,this.maxDelta_,!0,t,e,n,i))}getArea(){return xa(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getCoordinates(){return Ma(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getSimplifiedGeometryInternal(t){const e=[];return e.length=La(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t,e,0),new Na(e,"XY")}getType(){return"LinearRing"}intersectsExtent(t){return!1}setCoordinates(t,e){this.setLayout(e,t,1),this.flatCoordinates||(this.flatCoordinates=[]),this.flatCoordinates.length=Ta(this.flatCoordinates,0,t,this.stride),this.changed()}}class ja extends ma{constructor(t,e){super(),this.setCoordinates(t,e)}clone(){const t=new ja(this.flatCoordinates.slice(),this.layout);return t.applyProperties(this),t}closestPointXY(t,e,n,i){const r=this.flatCoordinates,s=dr(t,e,r[0],r[1]);if(s<i){const t=this.stride;for(let e=0;e<t;++e)n[e]=r[e];return n.length=t,s}return i}getCoordinates(){return this.flatCoordinates.slice()}computeExtent(t){return $r(this.flatCoordinates,t)}getType(){return"Point"}intersectsExtent(t){return Or(t,this.flatCoordinates[0],this.flatCoordinates[1])}setCoordinates(t,e){this.setLayout(e,t,0),this.flatCoordinates||(this.flatCoordinates=[]),this.flatCoordinates.length=Pa(this.flatCoordinates,0,t,this.stride),this.changed()}}function Ga(t,e,n,i,r){return!Zr(r,function(r){return!$a(t,e,n,i,r[0],r[1])})}function $a(t,e,n,i,r,s){let o=0,a=t[n-i],l=t[n-i+1];for(;e<n;e+=i){const n=t[e],i=t[e+1];l<=s?i>s&&(n-a)*(s-l)-(r-a)*(i-l)>0&&o++:i<=s&&(n-a)*(s-l)-(r-a)*(i-l)<0&&o--,a=n,l=i}return 0!==o}function Ba(t,e,n,i,r,s){if(0===n.length)return!1;if(!$a(t,e,n[0],i,r,s))return!1;for(let e=1,o=n.length;e<o;++e)if($a(t,n[e-1],n[e],i,r,s))return!1;return!0}function Ua(t,e,n,i,r,s,o){let a,l,h,c,u,d,f;const g=r[s+1],p=[];for(let r=0,s=n.length;r<s;++r){const s=n[r];for(c=t[s-i],d=t[s-i+1],a=e;a<s;a+=i)u=t[a],f=t[a+1],(g<=d&&f<=g||d<=g&&g<=f)&&(h=(g-d)/(f-d)*(u-c)+c,p.push(h)),c=u,d=f}let m=NaN,_=-1/0;for(p.sort(ri),c=p[0],a=1,l=p.length;a<l;++a){u=p[a];const r=Math.abs(u-c);r>_&&(h=(c+u)/2,Ba(t,e,n,i,h,g)&&(m=h,_=r)),c=u}return isNaN(m)&&(m=r[s]),o?(o.push(m,g,_),o):[m,g,_]}function Va(t,e,n,i,r){let s=[];for(let o=0,a=n.length;o<a;++o){const a=n[o];s=Ua(t,e,a,i,r,2*o,s),e=a[a.length-1]}return s}function Xa(t,e,n,i,r){let s;for(e+=i;e<n;e+=i)if(s=r(t.slice(e-i,e),t.slice(e,e+i)),s)return s;return!1}function Wa(t,e){const[n,i]=t,[r,s]=e,o=((n[0]-r[0])*(r[1]-s[1])-(n[1]-r[1])*(r[0]-s[0]))/((n[0]-i[0])*(r[1]-s[1])-(n[1]-i[1])*(r[0]-s[0])),a=((n[0]-r[0])*(n[1]-i[1])-(n[1]-r[1])*(n[0]-i[0]))/((n[0]-i[0])*(r[1]-s[1])-(n[1]-i[1])*(r[0]-s[0]));if(0<=o&&o<=1&&0<=a&&a<=1)return[n[0]+o*(i[0]-n[0]),n[1]+o*(i[1]-n[1])]}function qa(t,e,n,i,r,s){return s=s??Wr([1/0,1/0,-1/0,-1/0],t,e,n,i),!!as(r,s)&&(s[0]>=r[0]&&s[2]<=r[2]||s[1]>=r[1]&&s[3]<=r[3]||Xa(t,e,n,i,function(t,e){return function(t,e,n){let i=!1;const r=zr(t,e),s=zr(t,n);if(r===Er||s===Er)i=!0;else{const o=t[0],a=t[1],l=t[2],h=t[3],c=e[0],u=e[1],d=n[0],f=n[1],g=(f-u)/(d-c);let p,m;s&Pr&&!(r&Pr)&&(p=d-(f-h)/g,i=p>=o&&p<=l),i||!(s&Tr)||r&Tr||(m=f-(d-l)*g,i=m>=a&&m<=h),i||!(s&Rr)||r&Rr||(p=d-(f-a)/g,i=p>=o&&p<=l),i||!(s&Fr)||r&Fr||(m=f-(d-o)*g,i=m>=a&&m<=h)}return i}(r,t,e)}))}function Za(t,e,n,i,r){return!!qa(t,e,n,i,r)||(!!$a(t,e,n,i,r[0],r[1])||(!!$a(t,e,n,i,r[0],r[3])||(!!$a(t,e,n,i,r[2],r[1])||!!$a(t,e,n,i,r[2],r[3]))))}function Ka(t,e,n,i,r){if(!Za(t,e,n[0],i,r))return!1;if(1===n.length)return!0;for(let e=1,s=n.length;e<s;++e)if(Ga(t,n[e-1],n[e],i,r)&&!qa(t,n[e-1],n[e],i,r))return!1;return!0}function Ya(t,e,n,i){for(;e<n-i;){for(let r=0;r<i;++r){const s=t[e+r];t[e+r]=t[n-i+r],t[n-i+r]=s}e+=i,n-=i}}function Ha(t,e,n,i){let r=0,s=t[n-i],o=t[n-i+1];for(;e<n;e+=i){const n=t[e],i=t[e+1];r+=(n-s)*(i+o),s=n,o=i}return 0===r?void 0:r>0}function Ja(t,e,n,i,r){r=void 0!==r&&r;for(let s=0,o=n.length;s<o;++s){const o=n[s],a=Ha(t,e,o,i);if(0===s){if(r&&a||!r&&!a)return!1}else if(r&&!a||!r&&a)return!1;e=o}return!0}function Qa(t,e,n,i,r){for(let s=0,o=n.length;s<o;++s){const o=n[s];if(!Ja(t,e,o,i,r))return!1;o.length&&(e=o[o.length-1])}return!0}function tl(t,e,n,i,r){r=void 0!==r&&r;for(let s=0,o=n.length;s<o;++s){const o=n[s],a=Ha(t,e,o,i);(0===s?r&&a||!r&&!a:r&&!a||!r&&a)&&Ya(t,e,o,i),e=o}return e}function el(t,e,n,i,r){for(let s=0,o=n.length;s<o;++s)e=tl(t,e,n[s],i,r);return e}function nl(t,e){const n=[];let i,r=0,s=0;for(let o=0,a=e.length;o<a;++o){const a=e[o],l=Ha(t,r,a,2);if(void 0===i&&(i=l),l===i)n.push(e.slice(s,o+1));else{if(0===n.length)continue;n[n.length-1].push(e[s])}s=o+1,r=a}return n}class il extends ma{constructor(t,e,n){super(),this.ends_=[],this.flatInteriorPointRevision_=-1,this.flatInteriorPoint_=null,this.maxDelta_=-1,this.maxDeltaRevision_=-1,this.orientedRevision_=-1,this.orientedFlatCoordinates_=null,void 0!==e&&n?(this.setFlatCoordinates(e,t),this.ends_=n):this.setCoordinates(t,e)}appendLinearRing(t){this.flatCoordinates?li(this.flatCoordinates,t.getFlatCoordinates()):this.flatCoordinates=t.getFlatCoordinates().slice(),this.ends_.push(this.flatCoordinates.length),this.changed()}clone(){const t=new il(this.flatCoordinates.slice(),this.layout,this.ends_.slice());return t.applyProperties(this),t}closestPointXY(t,e,n,i){return i<Lr(this.getExtent(),t,e)?i:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(Sa(this.flatCoordinates,0,this.ends_,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),Ea(this.flatCoordinates,0,this.ends_,this.stride,this.maxDelta_,!0,t,e,n,i))}containsXY(t,e){return Ba(this.getOrientedFlatCoordinates(),0,this.ends_,this.stride,t,e)}getArea(){return va(this.getOrientedFlatCoordinates(),0,this.ends_,this.stride)}getCoordinates(t){let e;return void 0!==t?(e=this.getOrientedFlatCoordinates().slice(),tl(e,0,this.ends_,this.stride,t)):e=this.flatCoordinates,Ia(e,0,this.ends_,this.stride)}getEnds(){return this.ends_}getFlatInteriorPoint(){if(this.flatInteriorPointRevision_!=this.getRevision()){const t=Jr(this.getExtent());this.flatInteriorPoint_=Ua(this.getOrientedFlatCoordinates(),0,this.ends_,this.stride,t,0),this.flatInteriorPointRevision_=this.getRevision()}return this.flatInteriorPoint_}getInteriorPoint(){return new ja(this.getFlatInteriorPoint(),"XYM")}getLinearRingCount(){return this.ends_.length}getLinearRing(t){return t<0||this.ends_.length<=t?null:new Na(this.flatCoordinates.slice(0===t?0:this.ends_[t-1],this.ends_[t]),this.layout)}getLinearRings(){const t=this.layout,e=this.flatCoordinates,n=this.ends_,i=[];let r=0;for(let s=0,o=n.length;s<o;++s){const o=n[s],a=new Na(e.slice(r,o),t);i.push(a),r=o}return i}getOrientedFlatCoordinates(){if(this.orientedRevision_!=this.getRevision()){const t=this.flatCoordinates;Ja(t,0,this.ends_,this.stride)?this.orientedFlatCoordinates_=t:(this.orientedFlatCoordinates_=t.slice(),this.orientedFlatCoordinates_.length=tl(this.orientedFlatCoordinates_,0,this.ends_,this.stride)),this.orientedRevision_=this.getRevision()}return this.orientedFlatCoordinates_}getSimplifiedGeometryInternal(t){const e=[],n=[];return e.length=za(this.flatCoordinates,0,this.ends_,this.stride,Math.sqrt(t),e,0,n),new il(e,"XY",n)}getType(){return"Polygon"}intersectsExtent(t){return Ka(this.getOrientedFlatCoordinates(),0,this.ends_,this.stride,t)}setCoordinates(t,e){this.setLayout(e,t,2),this.flatCoordinates||(this.flatCoordinates=[]);const n=Ra(this.flatCoordinates,0,t,this.stride,this.ends_);this.flatCoordinates.length=0===n.length?0:n[n.length-1],this.changed()}}function rl(t){if(ls(t))throw new Error("Cannot create polygon from empty extent");const e=t[0],n=t[1],i=t[2],r=t[3],s=[e,n,e,r,i,r,i,n,e,n];return new il(s,"XY",[s.length])}function sl(t,e,n){e=e||32;const i=t.getStride(),r=t.getLayout(),s=t.getCenter(),o=i*(e+1),a=new Array(o);for(let t=0;t<o;t+=i){a[t]=0,a[t+1]=0;for(let e=2;e<i;e++)a[t+e]=s[e]}const l=[a.length],h=new il(a,r,l);return function(t,e,n){const i=t.getFlatCoordinates(),r=t.getStride(),s=i.length/r-1,o=0;for(let t=0;t<=s;++t){const a=t*r,l=o+2*pr(t,s)*Math.PI/s;i[a]=e[0]+n*Math.cos(l),i[a+1]=e[1]+n*Math.sin(l)}t.changed()}(h,s,t.getRadius()),h}function ol(t,e,n,i){const r=os(e)/n[0],s=ns(e)/n[1];return i?Math.min(t,Math.max(r,s)):Math.min(t,Math.min(r,s))}function al(t,e,n){let i=Math.min(t,e);return i*=Math.log(1+50*Math.max(0,t/e-1))/50+1,n&&(i=Math.max(i,n),i/=Math.log(1+50*Math.max(0,n/t-1))/50+1),cr(i,n/2,2*e)}function ll(t,e,n,i,r){return n=void 0===n||n,function(s,o,a,l){if(void 0!==s){const o=i?ol(t,i,a,r):t;return n&&l?al(s,o,e):cr(s,e,o)}}}function hl(t){if(void 0!==t)return 0}function cl(t){if(void 0!==t)return t}const ul=256;class dl extends Ci{constructor(t){super(),this.on,this.once,this.un,t=Object.assign({},t),this.hints_=[0,0],this.animations_=[],this.updateAnimationKey_,this.projection_=Ao(t.projection,"EPSG:3857"),this.viewportSize_=[100,100],this.targetCenter_=null,this.targetResolution_,this.targetRotation_,this.nextCenter_=null,this.nextResolution_,this.nextRotation_,this.cancelAnchor_=void 0,t.projection&&Po(),t.center&&(t.center=qo(t.center,this.projection_)),t.extent&&(t.extent=Ko(t.extent,this.projection_)),this.applyOptions_(t)}applyOptions_(t){const e=Object.assign({},t);for(const t in hr)delete e[t];this.setProperties(e,!0);const n=function(t){let e,n,i;const r=28,s=2;let o=void 0!==t.minZoom?t.minZoom:0,a=void 0!==t.maxZoom?t.maxZoom:r;const l=void 0!==t.zoomFactor?t.zoomFactor:s,h=void 0!==t.multiWorld&&t.multiWorld,c=void 0===t.smoothResolutionConstraint||t.smoothResolutionConstraint,u=void 0!==t.showFullExtent&&t.showFullExtent,d=Ao(t.projection,"EPSG:3857"),f=d.getExtent();let g=t.constrainOnlyCenter,p=t.extent;h||p||!d.isGlobal()||(g=!1,p=f);if(void 0!==t.resolutions){const r=t.resolutions;n=r[o],i=void 0!==r[a]?r[a]:r[r.length-1],e=t.constrainResolution?function(t,e,n,i){return e=void 0===e||e,function(r,s,o,a){if(void 0!==r){const l=t[0],h=t[t.length-1],c=n?ol(l,n,o,i):l;if(a)return e?al(r,c,h):cr(r,h,c);const u=Math.min(c,r),d=Math.floor(oi(t,u,s));return t[d]>c&&d<t.length-1?t[d+1]:t[d]}}}(r,c,!g&&p,u):ll(n,i,c,!g&&p,u)}else{const h=(f?Math.max(os(f),ns(f)):360*ks.degrees/d.getMetersPerUnit())/ul/Math.pow(s,0),m=h/Math.pow(s,r-0);n=t.maxResolution,void 0!==n?o=0:n=h/Math.pow(l,o),i=t.minResolution,void 0===i&&(i=void 0!==t.maxZoom?void 0!==t.maxResolution?n/Math.pow(l,a):h/Math.pow(l,a):m),a=o+Math.floor(Math.log(n/i)/Math.log(l)),i=n/Math.pow(l,a-o),e=t.constrainResolution?function(t,e,n,i,r,s){return i=void 0===i||i,n=void 0!==n?n:0,function(o,a,l,h){if(void 0!==o){const c=r?ol(e,r,l,s):e;if(h)return i?al(o,c,n):cr(o,n,c);const u=1e-9,d=Math.ceil(Math.log(e/c)/Math.log(t)-u),f=-a*(.5-u)+.5,g=Math.min(c,o),p=Math.floor(Math.log(e/g)/Math.log(t)+f),m=Math.max(d,p);return cr(e/Math.pow(t,m),n,c)}}}(l,n,i,c,!g&&p,u):ll(n,i,c,!g&&p,u)}return{constraint:e,maxResolution:n,minResolution:i,minZoom:o,zoomFactor:l}}(t);this.maxResolution_=n.maxResolution,this.minResolution_=n.minResolution,this.zoomFactor_=n.zoomFactor,this.resolutions_=t.resolutions,this.padding_=t.padding,this.minZoom_=n.minZoom;const i=function(t){if(void 0!==t.extent){const e=void 0===t.smoothExtentConstraint||t.smoothExtentConstraint;return wr(t.extent,t.constrainOnlyCenter,e)}const e=Ao(t.projection,"EPSG:3857");if(!0!==t.multiWorld&&e.isGlobal()){const t=e.getExtent().slice();return t[0]=-1/0,t[2]=1/0,wr(t,!1,!1)}return Sr}(t),r=n.constraint,s=function(t){const e=void 0===t.enableRotation||t.enableRotation;if(e){const e=t.constrainRotation;return void 0===e||!0===e?function(){const t=gr(5);return function(e,n){return n||void 0===e?e:Math.abs(e)<=t?0:e}}():!1===e?cl:"number"==typeof e?function(t){const e=2*Math.PI/t;return function(t,n){return n?t:void 0!==t?t=Math.floor(t/e+.5)*e:void 0}}(e):cl}return hl}(t);this.constraints_={center:i,resolution:r,rotation:s},this.setRotation(void 0!==t.rotation?t.rotation:0),this.setCenterInternal(void 0!==t.center?t.center:null),void 0!==t.resolution?this.setResolution(t.resolution):void 0!==t.zoom&&this.setZoom(t.zoom)}get padding(){return this.padding_}set padding(t){let e=this.padding_;this.padding_=t;const n=this.getCenterInternal();if(n){const i=t||[0,0,0,0];e=e||[0,0,0,0];const r=this.getResolution(),s=r/2*(i[3]-e[3]+e[1]-i[1]),o=r/2*(i[0]-e[0]+e[2]-i[2]);this.setCenterInternal([n[0]+s,n[1]-o])}}getUpdatedOptions_(t){const e=this.getProperties();return void 0!==e.resolution?e.resolution=this.getResolution():e.zoom=this.getZoom(),e.center=this.getCenterInternal(),e.rotation=this.getRotation(),Object.assign({},e,t)}animate(t){this.isDef()&&!this.getAnimating()&&this.resolveConstraints(0);const e=new Array(arguments.length);for(let t=0;t<e.length;++t){let n=arguments[t];n.center&&(n=Object.assign({},n),n.center=qo(n.center,this.getProjection())),n.anchor&&(n=Object.assign({},n),n.anchor=qo(n.anchor,this.getProjection())),e[t]=n}this.animateInternal.apply(this,e)}animateInternal(t){let e,n=arguments.length;n>1&&"function"==typeof arguments[n-1]&&(e=arguments[n-1],--n);let i=0;for(;i<n&&!this.isDef();++i){const t=arguments[i];t.center&&this.setCenterInternal(t.center),void 0!==t.zoom?this.setZoom(t.zoom):t.resolution&&this.setResolution(t.resolution),void 0!==t.rotation&&this.setRotation(t.rotation)}if(i===n)return void(e&&fl(e,!0));let r=Date.now(),s=this.targetCenter_.slice(),o=this.targetResolution_,a=this.targetRotation_;const l=[];for(;i<n;++i){const t=arguments[i],n={start:r,complete:!1,anchor:t.anchor,duration:void 0!==t.duration?t.duration:1e3,easing:t.easing||Cs,callback:e};if(t.center&&(n.sourceCenter=s,n.targetCenter=t.center.slice(),s=n.targetCenter),void 0!==t.zoom?(n.sourceResolution=o,n.targetResolution=this.getResolutionForZoom(t.zoom),o=n.targetResolution):t.resolution&&(n.sourceResolution=o,n.targetResolution=t.resolution,o=n.targetResolution),void 0!==t.rotation){n.sourceRotation=a;const e=pr(t.rotation-a+Math.PI,2*Math.PI)-Math.PI;n.targetRotation=a+e,a=n.targetRotation}gl(n)?n.complete=!0:r+=n.duration,l.push(n)}this.animations_.push(l),this.setHint(ar,1),this.updateAnimations_()}getAnimating(){return this.hints_[ar]>0}getInteracting(){return this.hints_[lr]>0}cancelAnimations(){let t;this.setHint(ar,-this.hints_[ar]);for(let e=0,n=this.animations_.length;e<n;++e){const n=this.animations_[e];if(n[0].callback&&fl(n[0].callback,!1),!t)for(let e=0,i=n.length;e<i;++e){const i=n[e];if(!i.complete){t=i.anchor;break}}}this.animations_.length=0,this.cancelAnchor_=t,this.nextCenter_=null,this.nextResolution_=NaN,this.nextRotation_=NaN}updateAnimations_(){if(void 0!==this.updateAnimationKey_&&(cancelAnimationFrame(this.updateAnimationKey_),this.updateAnimationKey_=void 0),!this.getAnimating())return;const t=Date.now();let e=!1;for(let n=this.animations_.length-1;n>=0;--n){const i=this.animations_[n];let r=!0;for(let n=0,s=i.length;n<s;++n){const s=i[n];if(s.complete)continue;const o=t-s.start;let a=s.duration>0?o/s.duration:1;a>=1?(s.complete=!0,a=1):r=!1;const l=s.easing(a);if(s.sourceCenter){const t=s.sourceCenter[0],e=s.sourceCenter[1],n=s.targetCenter[0],i=s.targetCenter[1];this.nextCenter_=s.targetCenter;const r=t+l*(n-t),o=e+l*(i-e);this.targetCenter_=[r,o]}if(s.sourceResolution&&s.targetResolution){const t=1===l?s.targetResolution:s.sourceResolution+l*(s.targetResolution-s.sourceResolution);if(s.anchor){const e=this.getViewportSize_(this.getRotation()),n=this.constraints_.resolution(t,0,e,!0);this.targetCenter_=this.calculateCenterZoom(n,s.anchor)}this.nextResolution_=s.targetResolution,this.targetResolution_=t,this.applyTargetState_(!0)}if(void 0!==s.sourceRotation&&void 0!==s.targetRotation){const t=1===l?pr(s.targetRotation+Math.PI,2*Math.PI)-Math.PI:s.sourceRotation+l*(s.targetRotation-s.sourceRotation);if(s.anchor){const e=this.constraints_.rotation(t,!0);this.targetCenter_=this.calculateCenterRotate(e,s.anchor)}this.nextRotation_=s.targetRotation,this.targetRotation_=t}if(this.applyTargetState_(!0),e=!0,!s.complete)break}if(r){this.animations_[n]=null,this.setHint(ar,-1),this.nextCenter_=null,this.nextResolution_=NaN,this.nextRotation_=NaN;const t=i[0].callback;t&&fl(t,!0)}}this.animations_=this.animations_.filter(Boolean),e&&void 0===this.updateAnimationKey_&&(this.updateAnimationKey_=requestAnimationFrame(this.updateAnimations_.bind(this)))}calculateCenterRotate(t,e){let n;const i=this.getCenterInternal();var r,s;return void 0!==i&&(n=[i[0]-e[0],i[1]-e[1]],ms(n,t-this.getRotation()),s=e,(r=n)[0]+=+s[0],r[1]+=+s[1]),n}calculateCenterZoom(t,e){let n;const i=this.getCenterInternal(),r=this.getResolution();if(void 0!==i&&void 0!==r){n=[e[0]-t*(e[0]-i[0])/r,e[1]-t*(e[1]-i[1])/r]}return n}getViewportSize_(t){const e=this.viewportSize_;if(t){const n=e[0],i=e[1];return[Math.abs(n*Math.cos(t))+Math.abs(i*Math.sin(t)),Math.abs(n*Math.sin(t))+Math.abs(i*Math.cos(t))]}return e}setViewportSize(t){this.viewportSize_=Array.isArray(t)?t.slice():[100,100],this.getAnimating()||this.resolveConstraints(0)}getCenter(){const t=this.getCenterInternal();return t?Wo(t,this.getProjection()):t}getCenterInternal(){return this.get(hr.CENTER)}getConstraints(){return this.constraints_}getConstrainResolution(){return this.get("constrainResolution")}getHints(t){return void 0!==t?(t[0]=this.hints_[0],t[1]=this.hints_[1],t):this.hints_.slice()}calculateExtent(t){return Zo(this.calculateExtentInternal(t),this.getProjection())}calculateExtentInternal(t){t=t||this.getViewportSizeMinusPadding_();const e=this.getCenterInternal();ir(e,"The view center is not defined");const n=this.getResolution();ir(void 0!==n,"The view resolution is not defined");const i=this.getRotation();return ir(void 0!==i,"The view rotation is not defined"),ts(e,n,i,t)}getMaxResolution(){return this.maxResolution_}getMinResolution(){return this.minResolution_}getMaxZoom(){return this.getZoomForResolution(this.minResolution_)}setMaxZoom(t){this.applyOptions_(this.getUpdatedOptions_({maxZoom:t}))}getMinZoom(){return this.getZoomForResolution(this.maxResolution_)}setMinZoom(t){this.applyOptions_(this.getUpdatedOptions_({minZoom:t}))}setConstrainResolution(t){this.applyOptions_(this.getUpdatedOptions_({constrainResolution:t}))}getProjection(){return this.projection_}getResolution(){return this.get(hr.RESOLUTION)}getResolutions(){return this.resolutions_}getResolutionForExtent(t,e){return this.getResolutionForExtentInternal(Ko(t,this.getProjection()),e)}getResolutionForExtentInternal(t,e){e=e||this.getViewportSizeMinusPadding_();const n=os(t)/e[0],i=ns(t)/e[1];return Math.max(n,i)}getResolutionForValueFunction(t){t=t||2;const e=this.getConstrainedResolution(this.maxResolution_),n=this.minResolution_,i=Math.log(e/n)/Math.log(t);return function(n){return e/Math.pow(t,n*i)}}getRotation(){return this.get(hr.ROTATION)}getValueForResolutionFunction(t){const e=Math.log(t||2),n=this.getConstrainedResolution(this.maxResolution_),i=this.minResolution_,r=Math.log(n/i)/e;return function(t){return Math.log(n/t)/e/r}}getViewportSizeMinusPadding_(t){let e=this.getViewportSize_(t);const n=this.padding_;return n&&(e=[e[0]-n[1]-n[3],e[1]-n[0]-n[2]]),e}getState(){const t=this.getProjection(),e=this.getResolution(),n=this.getRotation();let i=this.getCenterInternal();const r=this.padding_;if(r){const t=this.getViewportSizeMinusPadding_();i=pl(i,this.getViewportSize_(),[t[0]/2+r[3],t[1]/2+r[0]],e,n)}return{center:i.slice(0),projection:void 0!==t?t:null,resolution:e,nextCenter:this.nextCenter_,nextResolution:this.nextResolution_,nextRotation:this.nextRotation_,rotation:n,zoom:this.getZoom()}}getViewStateAndExtent(){return{viewState:this.getState(),extent:this.calculateExtent()}}getZoom(){let t;const e=this.getResolution();return void 0!==e&&(t=this.getZoomForResolution(e)),t}getZoomForResolution(t){let e,n,i=this.minZoom_||0;if(this.resolutions_){const r=oi(this.resolutions_,t,1);i=r,e=this.resolutions_[r],n=r==this.resolutions_.length-1?2:e/this.resolutions_[r+1]}else e=this.maxResolution_,n=this.zoomFactor_;return i+Math.log(e/t)/Math.log(n)}getResolutionForZoom(t){if(this.resolutions_?.length){if(1===this.resolutions_.length)return this.resolutions_[0];const e=cr(Math.floor(t),0,this.resolutions_.length-2),n=this.resolutions_[e]/this.resolutions_[e+1];return this.resolutions_[e]/Math.pow(n,cr(t-e,0,1))}return this.maxResolution_/Math.pow(this.zoomFactor_,t-this.minZoom_)}fit(t,e){let n;if(ir(Array.isArray(t)||"function"==typeof t.getSimplifiedGeometry,"Invalid extent or geometry provided as `geometry`"),Array.isArray(t)){ir(!ls(t),"Cannot fit empty extent provided as `geometry`");n=rl(Ko(t,this.getProjection()))}else if("Circle"===t.getType()){const e=Ko(t.getExtent(),this.getProjection());n=rl(e),n.rotate(this.getRotation(),Jr(e))}else{const e=Xo();n=e?t.clone().transform(e,this.getProjection()):t}this.fitInternal(n,e)}rotatedExtentForGeometry(t){const e=this.getRotation(),n=Math.cos(e),i=Math.sin(-e),r=t.getFlatCoordinates(),s=t.getStride();let o=1/0,a=1/0,l=-1/0,h=-1/0;for(let t=0,e=r.length;t<e;t+=s){const e=r[t]*n-r[t+1]*i,s=r[t]*i+r[t+1]*n;o=Math.min(o,e),a=Math.min(a,s),l=Math.max(l,e),h=Math.max(h,s)}return[o,a,l,h]}fitInternal(t,e){let n=(e=e||{}).size;n||(n=this.getViewportSizeMinusPadding_());const i=void 0!==e.padding?e.padding:[0,0,0,0],r=void 0!==e.nearest&&e.nearest;let s;s=void 0!==e.minResolution?e.minResolution:void 0!==e.maxZoom?this.getResolutionForZoom(e.maxZoom):0;const o=this.rotatedExtentForGeometry(t);let a=this.getResolutionForExtentInternal(o,[n[0]-i[1]-i[3],n[1]-i[0]-i[2]]);a=isNaN(a)?s:Math.max(a,s),a=this.getConstrainedResolution(a,r?0:1);const l=this.getRotation(),h=Math.sin(l),c=Math.cos(l),u=Jr(o);u[0]+=(i[1]-i[3])/2*a,u[1]+=(i[0]-i[2])/2*a;const d=u[0]*c-u[1]*h,f=u[1]*c+u[0]*h,g=this.getConstrainedCenter([d,f],a),p=e.callback?e.callback:di;void 0!==e.duration?this.animateInternal({resolution:a,center:g,duration:e.duration,easing:e.easing},p):(this.targetResolution_=a,this.targetCenter_=g,this.applyTargetState_(!1,!0),fl(p,!0))}centerOn(t,e,n){this.centerOnInternal(qo(t,this.getProjection()),e,n)}centerOnInternal(t,e,n){this.setCenterInternal(pl(t,e,n,this.getResolution(),this.getRotation()))}calculateCenterShift(t,e,n,i){let r;const s=this.padding_;if(s&&t){const o=this.getViewportSizeMinusPadding_(-n),a=pl(t,i,[o[0]/2+s[3],o[1]/2+s[0]],e,n);r=[t[0]-a[0],t[1]-a[1]]}return r}isDef(){return!!this.getCenterInternal()&&void 0!==this.getResolution()}adjustCenter(t){const e=Wo(this.targetCenter_,this.getProjection());this.setCenter([e[0]+t[0],e[1]+t[1]])}adjustCenterInternal(t){const e=this.targetCenter_;this.setCenterInternal([e[0]+t[0],e[1]+t[1]])}adjustResolution(t,e){e=e&&qo(e,this.getProjection()),this.adjustResolutionInternal(t,e)}adjustResolutionInternal(t,e){const n=this.getAnimating()||this.getInteracting(),i=this.getViewportSize_(this.getRotation()),r=this.constraints_.resolution(this.targetResolution_*t,0,i,n);e&&(this.targetCenter_=this.calculateCenterZoom(r,e)),this.targetResolution_*=t,this.applyTargetState_()}adjustZoom(t,e){this.adjustResolution(Math.pow(this.zoomFactor_,-t),e)}adjustRotation(t,e){e&&(e=qo(e,this.getProjection())),this.adjustRotationInternal(t,e)}adjustRotationInternal(t,e){const n=this.getAnimating()||this.getInteracting(),i=this.constraints_.rotation(this.targetRotation_+t,n);e&&(this.targetCenter_=this.calculateCenterRotate(i,e)),this.targetRotation_+=t,this.applyTargetState_()}setCenter(t){this.setCenterInternal(t?qo(t,this.getProjection()):t)}setCenterInternal(t){this.targetCenter_=t,this.applyTargetState_()}setHint(t,e){return this.hints_[t]+=e,this.changed(),this.hints_[t]}setResolution(t){this.targetResolution_=t,this.applyTargetState_()}setRotation(t){this.targetRotation_=t,this.applyTargetState_()}setZoom(t){this.setResolution(this.getResolutionForZoom(t))}applyTargetState_(t,e){const n=this.getAnimating()||this.getInteracting()||e,i=this.constraints_.rotation(this.targetRotation_,n),r=this.getViewportSize_(i),s=this.constraints_.resolution(this.targetResolution_,0,r,n),o=this.constraints_.center(this.targetCenter_,s,r,n,this.calculateCenterShift(this.targetCenter_,s,i,r));this.get(hr.ROTATION)!==i&&this.set(hr.ROTATION,i),this.get(hr.RESOLUTION)!==s&&(this.set(hr.RESOLUTION,s),this.set("zoom",this.getZoom(),!0)),o&&this.get(hr.CENTER)&&ps(this.get(hr.CENTER),o)||this.set(hr.CENTER,o),this.getAnimating()&&!t&&this.cancelAnimations(),this.cancelAnchor_=void 0}resolveConstraints(t,e,n){t=void 0!==t?t:200;const i=e||0,r=this.constraints_.rotation(this.targetRotation_),s=this.getViewportSize_(r),o=this.constraints_.resolution(this.targetResolution_,i,s),a=this.constraints_.center(this.targetCenter_,o,s,!1,this.calculateCenterShift(this.targetCenter_,o,r,s));if(0===t&&!this.cancelAnchor_)return this.targetResolution_=o,this.targetRotation_=r,this.targetCenter_=a,void this.applyTargetState_();n=n||(0===t?this.cancelAnchor_:void 0),this.cancelAnchor_=void 0,this.getResolution()===o&&this.getRotation()===r&&this.getCenterInternal()&&ps(this.getCenterInternal(),a)||(this.getAnimating()&&this.cancelAnimations(),this.animateInternal({rotation:r,center:a,resolution:o,duration:t,easing:Ss,anchor:n}))}beginInteraction(){this.resolveConstraints(0),this.setHint(lr,1)}endInteraction(t,e,n){n=n&&qo(n,this.getProjection()),this.endInteractionInternal(t,e,n)}endInteractionInternal(t,e,n){this.getInteracting()&&(this.setHint(lr,-1),this.resolveConstraints(t,e,n))}getConstrainedCenter(t,e){const n=this.getViewportSize_(this.getRotation());return this.constraints_.center(t,e||this.getResolution(),n)}getConstrainedZoom(t,e){const n=this.getResolutionForZoom(t);return this.getZoomForResolution(this.getConstrainedResolution(n,e))}getConstrainedResolution(t,e){e=e||0;const n=this.getViewportSize_(this.getRotation());return this.constraints_.resolution(t,e,n)}}function fl(t,e){setTimeout(function(){t(e)},0)}function gl(t){return!(t.sourceCenter&&t.targetCenter&&!ps(t.sourceCenter,t.targetCenter))&&(t.sourceResolution===t.targetResolution&&t.sourceRotation===t.targetRotation)}function pl(t,e,n,i,r){const s=Math.cos(-r);let o=Math.sin(-r),a=t[0]*s-t[1]*o,l=t[1]*s+t[0]*o;a+=(e[0]/2-n[0])*i,l+=(n[1]-e[1]/2)*i,o=-o;return[a*s-l*o,l*s+a*o]}const ml="ol-hidden",_l="ol-unselectable",yl="ol-control",xl="ol-collapsed",vl=new RegExp(["^\\s*(?=(?:(?:[-a-z]+\\s*){0,2}(italic|oblique))?)","(?=(?:(?:[-a-z]+\\s*){0,2}(small-caps))?)","(?=(?:(?:[-a-z]+\\s*){0,2}(bold(?:er)?|lighter|[1-9]00 ))?)","(?:(?:normal|\\1|\\2|\\3)\\s*){0,3}((?:xx?-)?","(?:small|large)|medium|smaller|larger|[\\.\\d]+(?:\\%|in|[cem]m|ex|p[ctx]))","(?:\\s*\\/\\s*(normal|[\\.\\d]+(?:\\%|in|[cem]m|ex|p[ctx])?))","?\\s*([-,\\\"\\'\\sa-z0-9]+?)\\s*$"].join(""),"i"),bl=["style","variant","weight","size","lineHeight","family"],wl={normal:400,bold:700},Sl=function(t){const e=t.match(vl);if(!e)return null;const n={lineHeight:"normal",size:"1.2em",style:"normal",weight:"400",variant:"normal"};for(let t=0,i=bl.length;t<i;++t){const i=e[t+1];void 0!==i&&(n[bl[t]]="string"==typeof i?i.trim():i)}return isNaN(Number(n.weight))&&n.weight in wl&&(n.weight=wl[n.weight]),n.families=n.family.split(/,\s?/).map(t=>t.trim().replace(/^['"]|['"]$/g,"")),n};function Cl(t,e,n,i){let r;return r=n&&n.length?n.shift():Oi?new class extends OffscreenCanvas{style={}}(t??300,e??150):document.createElement("canvas"),t&&(r.width=t),e&&(r.height=e),r.getContext("2d",i)}let El;function Pl(){return El||(El=Cl(1,1)),El}function Tl(t){const e=t.canvas;e.width=1,e.height=1,t.clearRect(0,0,1,1)}function Rl(t){let e=t.offsetWidth;const n=getComputedStyle(t);return e+=parseInt(n.marginLeft,10)+parseInt(n.marginRight,10),e}function Fl(t){let e=t.offsetHeight;const n=getComputedStyle(t);return e+=parseInt(n.marginTop,10)+parseInt(n.marginBottom,10),e}function Ml(t,e){const n=e.parentNode;n&&n.replaceChild(t,e)}function Il(t){for(;t.lastChild;)t.lastChild.remove()}function kl(){const t=new Proxy({childNodes:[],appendChild:function(t){return this.childNodes.push(t),t},remove:function(){},removeChild:function(t){const e=this.childNodes.indexOf(t);if(-1===e)throw new Error("Node to remove was not found");return this.childNodes.splice(e,1),t},insertBefore:function(t,e){const n=this.childNodes.indexOf(e);if(-1===n)throw new Error("Reference node not found");return this.childNodes.splice(n,0,t),t},style:{}},{get:(t,e,n)=>"firstElementChild"===e?t.childNodes.length>0?t.childNodes[0]:null:Reflect.get(t,e,n)});return t}function Ll(t){return"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof OffscreenCanvas&&t instanceof OffscreenCanvas}class Al extends Ci{constructor(t){super();const e=t.element;!e||t.target||e.style.pointerEvents||(e.style.pointerEvents="auto"),this.element=e||null,this.target_=null,this.map_=null,this.listenerKeys=[],t.render&&(this.render=t.render),t.target&&this.setTarget(t.target)}disposeInternal(){this.element?.remove(),super.disposeInternal()}getMap(){return this.map_}setMap(t){this.map_&&this.element?.remove();for(let t=0,e=this.listenerKeys.length;t<e;++t)Un(this.listenerKeys[t]);if(this.listenerKeys.length=0,this.map_=t,t){const e=this.target_??t.getOverlayContainerStopEvent();this.element&&e.appendChild(this.element),this.render!==di&&this.listenerKeys.push($n(t,Ui,this.render,this)),t.render()}}render(t){}setTarget(t){this.target_="string"==typeof t?document.getElementById(t):t}}var Dl=Object.freeze({__proto__:null,default:Al});class Ol extends Al{constructor(t){t=t||{},super({element:document.createElement("div"),render:t.render,target:t.target}),this.ulElement_=document.createElement("ul"),this.collapsed_=void 0===t.collapsed||t.collapsed,this.userCollapsed_=this.collapsed_,this.overrideCollapsible_=void 0!==t.collapsible,this.collapsible_=void 0===t.collapsible||t.collapsible,this.collapsible_||(this.collapsed_=!1),this.attributions_=t.attributions;const e=void 0!==t.className?t.className:"ol-attribution",n=void 0!==t.tipLabel?t.tipLabel:"Attributions",i=void 0!==t.expandClassName?t.expandClassName:e+"-expand",r=void 0!==t.collapseLabel?t.collapseLabel:"›",s=void 0!==t.collapseClassName?t.collapseClassName:e+"-collapse";"string"==typeof r?(this.collapseLabel_=document.createElement("span"),this.collapseLabel_.textContent=r,this.collapseLabel_.className=s):this.collapseLabel_=r;const o=void 0!==t.label?t.label:"i";"string"==typeof o?(this.label_=document.createElement("span"),this.label_.textContent=o,this.label_.className=i):this.label_=o;const a=this.collapsible_&&!this.collapsed_?this.collapseLabel_:this.label_;this.toggleButton_=document.createElement("button"),this.toggleButton_.setAttribute("type","button"),this.toggleButton_.setAttribute("aria-expanded",String(!this.collapsed_)),this.toggleButton_.title=n,this.toggleButton_.appendChild(a),this.toggleButton_.addEventListener(qn,this.handleClick_.bind(this),!1);const l=e+" "+_l+" "+yl+(this.collapsed_&&this.collapsible_?" "+xl:"")+(this.collapsible_?"":" ol-uncollapsible"),h=this.element;h.className=l,h.appendChild(this.toggleButton_),h.appendChild(this.ulElement_),this.renderedAttributions_=[],this.renderedVisible_=!0}collectSourceAttributions_(t){const e=this.getMap().getAllLayers(),n=new Set(e.flatMap(e=>e.getAttributions(t)));if(void 0!==this.attributions_&&(Array.isArray(this.attributions_)?this.attributions_.forEach(t=>n.add(t)):n.add(this.attributions_)),!this.overrideCollapsible_){const t=!e.some(t=>!1===t.getSource()?.getAttributionsCollapsible());this.setCollapsible(t)}return Array.from(n)}async updateElement_(t){if(!t)return void(this.renderedVisible_&&(this.element.style.display="none",this.renderedVisible_=!1));const e=await Promise.all(this.collectSourceAttributions_(t).map(t=>gi(()=>t))),n=e.length>0;if(this.renderedVisible_!=n&&(this.element.style.display=n?"":"none",this.renderedVisible_=n),!hi(e,this.renderedAttributions_)){Il(this.ulElement_);for(let t=0,n=e.length;t<n;++t){const n=document.createElement("li");n.innerHTML=e[t],this.ulElement_.appendChild(n)}this.renderedAttributions_=e}}handleClick_(t){t.preventDefault(),this.handleToggle_(),this.userCollapsed_=this.collapsed_}handleToggle_(){this.element.classList.toggle(xl),this.collapsed_?Ml(this.collapseLabel_,this.label_):Ml(this.label_,this.collapseLabel_),this.collapsed_=!this.collapsed_,this.toggleButton_.setAttribute("aria-expanded",String(!this.collapsed_))}getCollapsible(){return this.collapsible_}setCollapsible(t){this.collapsible_!==t&&(this.collapsible_=t,this.element.classList.toggle("ol-uncollapsible"),this.userCollapsed_&&this.handleToggle_())}setCollapsed(t){this.userCollapsed_=t,this.collapsible_&&this.collapsed_!==t&&this.handleToggle_()}getCollapsed(){return this.collapsed_}render(t){this.updateElement_(t.frameState)}}class zl extends Al{constructor(t){t=t||{},super({element:document.createElement("div"),render:t.render,target:t.target});const e=void 0!==t.className?t.className:"ol-rotate",n=void 0!==t.label?t.label:"⇧",i=void 0!==t.compassClassName?t.compassClassName:"ol-compass";this.label_=null,"string"==typeof n?(this.label_=document.createElement("span"),this.label_.className=i,this.label_.textContent=n):(this.label_=n,this.label_.classList.add(i));const r=t.tipLabel?t.tipLabel:"Reset rotation",s=document.createElement("button");s.className=e+"-reset",s.setAttribute("type","button"),s.title=r,s.appendChild(this.label_),s.addEventListener(qn,this.handleClick_.bind(this),!1);const o=e+" "+_l+" "+yl,a=this.element;a.className=o,a.appendChild(s),this.callResetNorth_=t.resetNorth?t.resetNorth:void 0,this.duration_=void 0!==t.duration?t.duration:250,this.autoHide_=void 0===t.autoHide||t.autoHide,this.rotation_=void 0,this.autoHide_&&this.element.classList.add(ml)}handleClick_(t){t.preventDefault(),void 0!==this.callResetNorth_?this.callResetNorth_():this.resetNorth_()}resetNorth_(){const t=this.getMap().getView();if(!t)return;const e=t.getRotation();void 0!==e&&(this.duration_>0&&e%(2*Math.PI)!=0?t.animate({rotation:0,duration:this.duration_,easing:Ss}):t.setRotation(0))}render(t){const e=t.frameState;if(!e)return;const n=e.viewState.rotation;if(n!=this.rotation_){const t="rotate("+n+"rad)";if(this.autoHide_){const t=this.element.classList.contains(ml);t||0!==n?t&&0!==n&&this.element.classList.remove(ml):this.element.classList.add(ml)}this.label_.style.transform=t}this.rotation_=n}}class Nl extends Al{constructor(t){t=t||{},super({element:document.createElement("div"),target:t.target});const e=void 0!==t.className?t.className:"ol-zoom",n=void 0!==t.delta?t.delta:1,i=void 0!==t.zoomInClassName?t.zoomInClassName:e+"-in",r=void 0!==t.zoomOutClassName?t.zoomOutClassName:e+"-out",s=void 0!==t.zoomInLabel?t.zoomInLabel:"+",o=void 0!==t.zoomOutLabel?t.zoomOutLabel:"–",a=void 0!==t.zoomInTipLabel?t.zoomInTipLabel:"Zoom in",l=void 0!==t.zoomOutTipLabel?t.zoomOutTipLabel:"Zoom out",h=document.createElement("button");h.className=i,h.setAttribute("type","button"),h.title=a,h.appendChild("string"==typeof s?document.createTextNode(s):s),h.addEventListener(qn,this.handleClick_.bind(this,n),!1);const c=document.createElement("button");c.className=r,c.setAttribute("type","button"),c.title=l,c.appendChild("string"==typeof o?document.createTextNode(o):o),c.addEventListener(qn,this.handleClick_.bind(this,-n),!1);const u=e+" "+_l+" "+yl,d=this.element;d.className=u,d.appendChild(h),d.appendChild(c),this.duration_=void 0!==t.duration?t.duration:250}handleClick_(t,e){e.preventDefault(),this.zoomByDelta_(t)}zoomByDelta_(t){const e=this.getMap().getView();if(!e)return;const n=e.getZoom();if(void 0!==n){const i=e.getConstrainedZoom(n+t);this.duration_>0?(e.getAnimating()&&e.cancelAnimations(),e.animate({zoom:i,duration:this.duration_,easing:Ss})):e.setZoom(i)}}}class jl{constructor(t,e,n){this.decay_=t,this.minVelocity_=e,this.delay_=n,this.points_=[],this.angle_=0,this.initialVelocity_=0}begin(){this.points_.length=0,this.angle_=0,this.initialVelocity_=0}update(t,e){this.points_.push(t,e,Date.now())}end(){if(this.points_.length<6)return!1;const t=Date.now()-this.delay_,e=this.points_.length-3;if(this.points_[e+2]<t)return!1;let n=e-3;for(;n>0&&this.points_[n+2]>t;)n-=3;const i=this.points_[e+2]-this.points_[n+2];if(i<1e3/60)return!1;const r=this.points_[e]-this.points_[n],s=this.points_[e+1]-this.points_[n+1];return this.angle_=Math.atan2(s,r),this.initialVelocity_=Math.sqrt(r*r+s*s)/i,this.initialVelocity_>this.minVelocity_}getDistance(){return(this.minVelocity_-this.initialVelocity_)/this.decay_}getAngle(){return this.angle_}}var Gl="active";class $l extends Ci{constructor(t){super(),this.on,this.once,this.un,t&&t.handleEvent&&(this.handleEvent=t.handleEvent),this.map_=null,this.setActive(!0)}getActive(){return this.get(Gl)}getMap(){return this.map_}handleEvent(t){return!0}setActive(t){this.set(Gl,t)}setMap(t){this.map_=t}}function Bl(t,e,n,i){const r=t.getZoom();if(void 0===r)return;const s=t.getConstrainedZoom(r+e),o=t.getResolutionForZoom(s);t.getAnimating()&&t.cancelAnimations(),t.animate({resolution:o,anchor:n,duration:void 0!==i?i:250,easing:Ss})}class Ul extends $l{constructor(t){super(),t=t||{},this.delta_=t.delta?t.delta:1,this.duration_=void 0!==t.duration?t.duration:250}handleEvent(t){let e=!1;if(t.type==Mi.DBLCLICK){const n=t.originalEvent,i=t.map,r=t.coordinate,s=n.shiftKey?-this.delta_:this.delta_;Bl(i.getView(),s,r,this.duration_),n.preventDefault(),e=!0}return!e}}function Vl(t){const e=arguments;return function(t){let n=!0;for(let i=0,r=e.length;i<r&&(n=n&&e[i](t),n);++i);return n}}const Xl=function(t){const e=t.originalEvent;return e.altKey&&!(e.metaKey||e.ctrlKey)&&e.shiftKey},Wl=function(t){const e=t.map.getTargetElement(),n=e.getRootNode();return!(n instanceof ShadowRoot?n.host:e).hasAttribute("tabindex")||function(t){const e=t.map.getTargetElement(),n=e.getRootNode(),i=t.map.getOwnerDocument().activeElement;return n instanceof ShadowRoot?n.host.contains(i):e.contains(i)}(t)},ql=ci,Zl=function(t){const e=t.originalEvent;return"pointerId"in e&&0==e.button&&!(Li&&Ai&&e.ctrlKey)},Kl=ui,Yl=function(t){return t.type==Mi.SINGLECLICK},Hl=function(t){const e=t.originalEvent;return!e.altKey&&!(e.metaKey||e.ctrlKey)&&!e.shiftKey},Jl=function(t){const e=t.originalEvent;return!e.altKey&&!(e.metaKey||e.ctrlKey)&&e.shiftKey},Ql=function(t){const e=t.originalEvent,n=e.target.tagName;return"INPUT"!==n&&"SELECT"!==n&&"TEXTAREA"!==n&&!e.target.isContentEditable},th=function(t){const e=t.originalEvent;return"pointerId"in e&&"mouse"==e.pointerType},eh=function(t){const e=t.originalEvent;return"pointerId"in e&&e.isPrimary&&0===e.button};class nh extends $l{constructor(t){super(t=t||{}),t.handleDownEvent&&(this.handleDownEvent=t.handleDownEvent),t.handleDragEvent&&(this.handleDragEvent=t.handleDragEvent),t.handleMoveEvent&&(this.handleMoveEvent=t.handleMoveEvent),t.handleUpEvent&&(this.handleUpEvent=t.handleUpEvent),t.stopDown&&(this.stopDown=t.stopDown),this.handlingDownUpSequence=!1,this.targetPointers=[]}getPointerCount(){return this.targetPointers.length}handleDownEvent(t){return!1}handleDragEvent(t){}handleEvent(t){if(!t.originalEvent)return!0;let e=!1;if(this.updateTrackedPointers_(t),this.handlingDownUpSequence){if(t.type==Mi.POINTERDRAG)this.handleDragEvent(t),t.originalEvent.preventDefault();else if(t.type==Mi.POINTERUP){const e=this.handleUpEvent(t);this.handlingDownUpSequence=e&&this.targetPointers.length>0}}else if(t.type==Mi.POINTERDOWN){const n=this.handleDownEvent(t);this.handlingDownUpSequence=n,e=this.stopDown(n)}else t.type==Mi.POINTERMOVE&&this.handleMoveEvent(t);return!e}handleMoveEvent(t){}handleUpEvent(t){return!1}stopDown(t){return t}updateTrackedPointers_(t){t.activePointers&&(this.targetPointers=t.activePointers)}}function ih(t){const e=t.length;let n=0,i=0;for(let r=0;r<e;r++)n+=t[r].clientX,i+=t[r].clientY;return{clientX:n/e,clientY:i/e}}class rh extends nh{constructor(t){super({stopDown:ui}),t=t||{},this.kinetic_=t.kinetic,this.lastCentroid=null,this.lastPointersCount_,this.panning_=!1;const e=t.condition?t.condition:Vl(Hl,eh);this.condition_=t.onFocusOnly?Vl(Wl,e):e,this.noKinetic_=!1}handleDragEvent(t){const e=t.map;this.panning_||(this.panning_=!0,e.getView().beginInteraction());const n=this.targetPointers,i=e.getEventPixel(ih(n));if(n.length==this.lastPointersCount_){if(this.kinetic_&&this.kinetic_.update(i[0],i[1]),this.lastCentroid){const e=[this.lastCentroid[0]-i[0],i[1]-this.lastCentroid[1]],n=t.map.getView();!function(t,e){t[0]*=e,t[1]*=e}(e,n.getResolution()),ms(e,n.getRotation()),n.adjustCenterInternal(e)}}else this.kinetic_&&this.kinetic_.begin();this.lastCentroid=i,this.lastPointersCount_=n.length,t.originalEvent.preventDefault()}handleUpEvent(t){const e=t.map,n=e.getView();if(0===this.targetPointers.length){if(!this.noKinetic_&&this.kinetic_&&this.kinetic_.end()){const t=this.kinetic_.getDistance(),i=this.kinetic_.getAngle(),r=n.getCenterInternal(),s=e.getPixelFromCoordinateInternal(r),o=e.getCoordinateFromPixelInternal([s[0]-t*Math.cos(i),s[1]-t*Math.sin(i)]);n.animateInternal({center:n.getConstrainedCenter(o),duration:500,easing:Ss})}return this.panning_&&(this.panning_=!1,n.endInteraction()),!1}return this.kinetic_&&this.kinetic_.begin(),this.lastCentroid=null,!0}handleDownEvent(t){if(this.targetPointers.length>0&&this.condition_(t)){const e=t.map.getView();return this.lastCentroid=null,e.getAnimating()&&e.cancelAnimations(),this.kinetic_&&this.kinetic_.begin(),this.noKinetic_=this.targetPointers.length>1,!0}return!1}}class sh extends nh{constructor(t){t=t||{},super({stopDown:ui}),this.condition_=t.condition?t.condition:Xl,this.lastAngle_=void 0,this.duration_=void 0!==t.duration?t.duration:250}handleDragEvent(t){if(!th(t))return;const e=t.map,n=e.getView();if(n.getConstraints().rotation===hl)return;const i=e.getSize(),r=t.pixel,s=Math.atan2(i[1]/2-r[1],r[0]-i[0]/2);if(void 0!==this.lastAngle_){const t=s-this.lastAngle_;n.adjustRotationInternal(-t)}this.lastAngle_=s}handleUpEvent(t){if(!th(t))return!0;return t.map.getView().endInteraction(this.duration_),!1}handleDownEvent(t){if(!th(t))return!1;if(Zl(t)&&this.condition_(t)){return t.map.getView().beginInteraction(),this.lastAngle_=void 0,!0}return!1}}class oh extends ii{constructor(t){super(),this.geometry_=null,this.element_=document.createElement("div"),this.element_.style.position="absolute",this.element_.style.pointerEvents="auto",this.element_.className="ol-box "+t,this.map_=null,this.startPixel_=null,this.endPixel_=null}disposeInternal(){this.setMap(null)}render_(){const t=this.startPixel_,e=this.endPixel_,n="px",i=this.element_.style;i.left=Math.min(t[0],e[0])+n,i.top=Math.min(t[1],e[1])+n,i.width=Math.abs(e[0]-t[0])+n,i.height=Math.abs(e[1]-t[1])+n}setMap(t){if(this.map_){this.map_.getOverlayContainer().removeChild(this.element_);const t=this.element_.style;t.left="inherit",t.top="inherit",t.width="inherit",t.height="inherit"}this.map_=t,this.map_&&this.map_.getOverlayContainer().appendChild(this.element_)}setPixels(t,e){this.startPixel_=t,this.endPixel_=e,this.createOrUpdateGeometry(),this.render_()}createOrUpdateGeometry(){if(!this.map_)return;const t=this.startPixel_,e=this.endPixel_,n=[t,[t[0],e[1]],e,[e[0],t[1]]].map(this.map_.getCoordinateFromPixelInternal,this.map_);n[4]=n[0].slice(),this.geometry_?this.geometry_.setCoordinates([n]):this.geometry_=new il([n])}getGeometry(){return this.geometry_}}const ah="boxstart",lh="boxdrag",hh="boxend",ch="boxcancel";class uh extends pi{constructor(t,e,n){super(t),this.coordinate=e,this.mapBrowserEvent=n}}class dh extends nh{constructor(t){super(),this.on,this.once,this.un,t=t??{},this.box_=new oh(t.className||"ol-dragbox"),this.minArea_=t.minArea??64,t.onBoxEnd&&(this.onBoxEnd=t.onBoxEnd),this.startPixel_=null,this.condition_=t.condition??Zl,this.boxEndCondition_=t.boxEndCondition??this.defaultBoxEndCondition}defaultBoxEndCondition(t,e,n){const i=n[0]-e[0],r=n[1]-e[1];return i*i+r*r>=this.minArea_}getGeometry(){return this.box_.getGeometry()}handleDragEvent(t){this.startPixel_&&(this.box_.setPixels(this.startPixel_,t.pixel),this.dispatchEvent(new uh(lh,t.coordinate,t)))}handleUpEvent(t){if(!this.startPixel_)return!1;const e=this.boxEndCondition_(t,this.startPixel_,t.pixel);return e&&this.onBoxEnd(t),this.dispatchEvent(new uh(e?hh:ch,t.coordinate,t)),this.box_.setMap(null),this.startPixel_=null,!1}handleDownEvent(t){return!!this.condition_(t)&&(this.startPixel_=t.pixel,this.box_.setMap(t.map),this.box_.setPixels(this.startPixel_,this.startPixel_),this.dispatchEvent(new uh(ah,t.coordinate,t)),!0)}onBoxEnd(t){}setActive(t){t||(this.box_.setMap(null),this.startPixel_&&(this.dispatchEvent(new uh(ch,this.startPixel_,null)),this.startPixel_=null)),super.setActive(t)}setMap(t){this.getMap()&&(this.box_.setMap(null),this.startPixel_&&(this.dispatchEvent(new uh(ch,this.startPixel_,null)),this.startPixel_=null)),super.setMap(t)}}class fh extends dh{constructor(t){super({condition:(t=t||{}).condition?t.condition:Jl,className:t.className||"ol-dragzoom",minArea:t.minArea}),this.duration_=void 0!==t.duration?t.duration:200,this.out_=void 0!==t.out&&t.out}onBoxEnd(t){const e=this.getMap().getView();let n=this.getGeometry();if(this.out_){const t=e.rotatedExtentForGeometry(n),i=e.getResolutionForExtentInternal(t),r=e.getResolution()/i;n=n.clone(),n.scale(r*r)}e.fitInternal(n,{duration:this.duration_,easing:Ss})}}var gh="ArrowLeft",ph="ArrowUp",mh="ArrowRight",_h="ArrowDown";class yh extends $l{constructor(t){super(),t=t||{},this.defaultCondition_=function(t){return Hl(t)&&Ql(t)},this.condition_=void 0!==t.condition?t.condition:this.defaultCondition_,this.duration_=void 0!==t.duration?t.duration:100,this.pixelDelta_=void 0!==t.pixelDelta?t.pixelDelta:128}handleEvent(t){let e=!1;if(t.type==Jn){const n=t.originalEvent,i=n.key;if(this.condition_(t)&&(i==_h||i==gh||i==mh||i==ph)){const r=t.map.getView(),s=r.getResolution()*this.pixelDelta_;let o=0,a=0;i==_h?a=-s:i==gh?o=-s:i==mh?o=s:a=s;const l=[o,a];ms(l,r.getRotation()),function(t,e,n){const i=t.getCenterInternal();if(i){const r=[i[0]+e[0],i[1]+e[1]];t.animateInternal({duration:void 0!==n?n:250,easing:Es,center:t.getConstrainedCenter(r)})}}(r,l,this.duration_),n.preventDefault(),e=!0}}return!e}}class xh extends $l{constructor(t){super(),t=t||{},this.condition_=t.condition?t.condition:function(t){return!function(t){const e=t.originalEvent;return Ai?e.metaKey:e.ctrlKey}(t)&&Ql(t)},this.delta_=t.delta?t.delta:1,this.duration_=void 0!==t.duration?t.duration:100}handleEvent(t){let e=!1;if(t.type==Jn||t.type==Qn){const n=t.originalEvent,i=n.key;if(this.condition_(t)&&("+"===i||"-"===i)){const r=t.map,s="+"===i?this.delta_:-this.delta_;Bl(r.getView(),s,void 0,this.duration_),n.preventDefault(),e=!0}}return!e}}class vh extends $l{constructor(t){super(t=t||{}),this.totalDelta_=0,this.lastDelta_=0,this.maxDelta_=void 0!==t.maxDelta?t.maxDelta:1,this.duration_=void 0!==t.duration?t.duration:250,this.timeout_=void 0!==t.timeout?t.timeout:80,this.useAnchor_=void 0===t.useAnchor||t.useAnchor,this.constrainResolution_=void 0!==t.constrainResolution&&t.constrainResolution;const e=t.condition?t.condition:ql;this.condition_=t.onFocusOnly?Vl(Wl,e):e,this.lastAnchor_=null,this.startTime_=void 0,this.timeoutId_,this.mode_=void 0,this.trackpadEventGap_=400,this.trackpadTimeoutId_,this.deltaPerZoom_=300,this.ctrlKeyPressed_=!1,this.ctrlKeyListenerKeys_=[]}setMap(t){if(this.ctrlKeyListenerKeys_.forEach(Un),this.ctrlKeyListenerKeys_.length=0,this.ctrlKeyPressed_=!1,super.setMap(t),t){const e=t.getOwnerDocument();this.ctrlKeyListenerKeys_.push($n(e,"keydown",t=>{"Control"===t.key&&(this.ctrlKeyPressed_=!0)}),$n(e,"keyup",t=>{"Control"===t.key&&(this.ctrlKeyPressed_=!1)}))}}endInteraction_(){this.trackpadTimeoutId_=void 0;const t=this.getMap();if(!t)return;const e=t.getView(),n=this.lastDelta_?this.lastDelta_>0?1:-1:0;e.endInteraction(this.constrainResolution_||e.getConstrainResolution()?100:void 0,n,this.lastAnchor_?t.getCoordinateFromPixel(this.lastAnchor_):null)}handleEvent(t){if(!this.condition_(t))return!0;if(t.type!==ni)return!0;const e=t.map,n=t.originalEvent;n.preventDefault();const i=n.ctrlKey&&!this.ctrlKeyPressed_;n.ctrlKey||(this.ctrlKeyPressed_=!1),this.useAnchor_&&(this.lastAnchor_=t.pixel);let r=n.deltaY;switch(n.deltaMode){case WheelEvent.DOM_DELTA_LINE:r*=40;break;case WheelEvent.DOM_DELTA_PAGE:r*=300}if(0===r)return!1;this.lastDelta_=r;const s=Date.now();void 0===this.startTime_&&(this.startTime_=s),(!this.mode_||s-this.startTime_>this.trackpadEventGap_)&&(this.mode_=Math.abs(r)<4?"trackpad":"wheel");const o=e.getView();if("trackpad"===this.mode_)return this.trackpadTimeoutId_?clearTimeout(this.trackpadTimeoutId_):(o.getAnimating()&&o.cancelAnimations(),o.beginInteraction()),this.trackpadTimeoutId_=setTimeout(this.endInteraction_.bind(this),this.timeout_),i&&(r*=3),o.adjustZoom(-r/this.deltaPerZoom_,this.lastAnchor_?e.getCoordinateFromPixel(this.lastAnchor_):null),this.startTime_=s,!1;this.totalDelta_+=r;const a=Math.max(this.timeout_-(s-this.startTime_),0);return clearTimeout(this.timeoutId_),this.timeoutId_=setTimeout(this.handleWheelZoom_.bind(this,e),a),!1}handleWheelZoom_(t){const e=t.getView();e.getAnimating()&&e.cancelAnimations();let n=-cr(this.totalDelta_,-this.maxDelta_*this.deltaPerZoom_,this.maxDelta_*this.deltaPerZoom_)/this.deltaPerZoom_;(e.getConstrainResolution()||this.constrainResolution_)&&(n=n?n>0?1:-1:0),Bl(e,n,this.lastAnchor_?t.getCoordinateFromPixel(this.lastAnchor_):null,this.duration_),this.mode_=void 0,this.totalDelta_=0,this.lastAnchor_=null,this.startTime_=void 0,this.timeoutId_=void 0}setMouseAnchor(t){this.useAnchor_=t,t||(this.lastAnchor_=null)}}class bh extends nh{constructor(t){const e=t=t||{};e.stopDown||(e.stopDown=ui),super(e),this.anchor_=null,this.lastAngle_=void 0,this.rotating_=!1,this.rotationDelta_=0,this.threshold_=void 0!==t.threshold?t.threshold:.3,this.duration_=void 0!==t.duration?t.duration:250}handleDragEvent(t){let e=0;const n=this.targetPointers[0],i=this.targetPointers[1],r=Math.atan2(i.clientY-n.clientY,i.clientX-n.clientX);if(void 0!==this.lastAngle_){const t=r-this.lastAngle_;this.rotationDelta_+=t,!this.rotating_&&Math.abs(this.rotationDelta_)>this.threshold_&&(this.rotating_=!0),e=t}this.lastAngle_=r;const s=t.map,o=s.getView();o.getConstraints().rotation!==hl&&(this.anchor_=s.getCoordinateFromPixelInternal(s.getEventPixel(ih(this.targetPointers))),this.rotating_&&(s.render(),o.adjustRotationInternal(e,this.anchor_)))}handleUpEvent(t){if(this.targetPointers.length<2){return t.map.getView().endInteraction(this.duration_),!1}return!0}handleDownEvent(t){if(this.targetPointers.length>=2){const e=t.map;return this.anchor_=null,this.lastAngle_=void 0,this.rotating_=!1,this.rotationDelta_=0,this.handlingDownUpSequence||e.getView().beginInteraction(),!0}return!1}}class wh extends nh{constructor(t){const e=t=t||{};e.stopDown||(e.stopDown=ui),super(e),this.anchor_=null,this.duration_=void 0!==t.duration?t.duration:400,this.lastDistance_=void 0,this.lastScaleDelta_=1}handleDragEvent(t){let e=1;const n=this.targetPointers[0],i=this.targetPointers[1],r=n.clientX-i.clientX,s=n.clientY-i.clientY,o=Math.sqrt(r*r+s*s);void 0!==this.lastDistance_&&(e=this.lastDistance_/o),this.lastDistance_=o;const a=t.map,l=a.getView();1!=e&&(this.lastScaleDelta_=e),this.anchor_=a.getCoordinateFromPixelInternal(a.getEventPixel(ih(this.targetPointers))),a.render(),l.adjustResolutionInternal(e,this.anchor_)}handleUpEvent(t){if(this.targetPointers.length<2){const e=t.map.getView(),n=this.lastScaleDelta_>1?1:-1;return e.endInteraction(this.duration_,n),!1}return!0}handleDownEvent(t){if(this.targetPointers.length>=2){const e=t.map;return this.anchor_=null,this.lastDistance_=void 0,this.lastScaleDelta_=1,this.handlingDownUpSequence||e.getView().beginInteraction(),!0}return!1}}function Sh(t){t=t||{};const e=new Ti,n=new jl(-.005,.05,100);(void 0===t.altShiftDragRotate||t.altShiftDragRotate)&&e.push(new sh);(void 0===t.doubleClickZoom||t.doubleClickZoom)&&e.push(new Ul({delta:t.zoomDelta,duration:t.zoomDuration}));(void 0===t.dragPan||t.dragPan)&&e.push(new rh({onFocusOnly:t.onFocusOnly,kinetic:n}));(void 0===t.pinchRotate||t.pinchRotate)&&e.push(new bh);(void 0===t.pinchZoom||t.pinchZoom)&&e.push(new wh({duration:t.zoomDuration}));(void 0===t.keyboard||t.keyboard)&&(e.push(new yh),e.push(new xh({delta:t.zoomDelta,duration:t.zoomDuration})));(void 0===t.mouseWheelZoom||t.mouseWheelZoom)&&e.push(new vh({onFocusOnly:t.onFocusOnly,duration:t.zoomDuration}));return(void 0===t.shiftDragZoom||t.shiftDragZoom)&&e.push(new fh({duration:t.zoomDuration})),e}var Ch="opacity",Eh="visible",Ph="extent",Th="zIndex",Rh="maxResolution",Fh="minResolution",Mh="maxZoom",Ih="minZoom",kh="source",Lh="map";class Ah extends Ci{constructor(t){super(),this.on,this.once,this.un,this.background_=t.background;const e=Object.assign({},t);"object"==typeof t.properties&&(delete e.properties,Object.assign(e,t.properties)),e[Ch]=void 0!==t.opacity?t.opacity:1,ir("number"==typeof e[Ch],"Layer opacity must be a number"),e[Eh]=void 0===t.visible||t.visible,e[Th]=t.zIndex,e[Rh]=void 0!==t.maxResolution?t.maxResolution:1/0,e[Fh]=void 0!==t.minResolution?t.minResolution:0,e[Ih]=void 0!==t.minZoom?t.minZoom:-1/0,e[Mh]=void 0!==t.maxZoom?t.maxZoom:1/0,this.className_=void 0!==e.className?e.className:"ol-layer",delete e.className,this.setProperties(e),this.state_=null}getBackground(){return this.background_}getClassName(){return this.className_}getLayerState(t){const e=this.state_||{layer:this,managed:void 0===t||t},n=this.getZIndex();return e.opacity=cr(Math.round(100*this.getOpacity())/100,0,1),e.visible=this.getVisible(),e.extent=this.getExtent(),e.zIndex=void 0!==n||e.managed?n:1/0,e.maxResolution=this.getMaxResolution(),e.minResolution=Math.max(this.getMinResolution(),0),e.minZoom=this.getMinZoom(),e.maxZoom=this.getMaxZoom(),this.state_=e,e}getLayersArray(t){return vi()}getLayerStatesArray(t){return vi()}getExtent(){return this.get(Ph)}getMaxResolution(){return this.get(Rh)}getMinResolution(){return this.get(Fh)}getMinZoom(){return this.get(Ih)}getMaxZoom(){return this.get(Mh)}getOpacity(){return this.get(Ch)}getSourceState(){return vi()}getVisible(){return this.get(Eh)}getZIndex(){return this.get(Th)}setBackground(t){this.background_=t,this.changed()}setExtent(t){this.set(Ph,t)}setMaxResolution(t){this.set(Rh,t)}setMinResolution(t){this.set(Fh,t)}setMaxZoom(t){this.set(Mh,t)}setMinZoom(t){this.set(Ih,t)}setOpacity(t){ir("number"==typeof t,"Layer opacity must be a number"),this.set(Ch,t)}setVisible(t){this.set(Eh,t)}setZIndex(t){this.set(Th,t)}disposeInternal(){this.state_&&(this.state_.layer=null,this.state_=null),super.disposeInternal()}}const Dh="addlayer",Oh="removelayer";class zh extends pi{constructor(t,e){super(t),this.layer=e}}const Nh="layers";class jh extends Ah{constructor(t){t=t||{};const e=Object.assign({},t);delete e.layers;let n=t.layers;super(e),this.on,this.once,this.un,this.layersListenerKeys_=[],this.listenerKeys_={},this.addChangeListener(Nh,this.handleLayersChanged_),n?Array.isArray(n)?n=new Ti(n.slice(),{unique:!0}):ir("function"==typeof n.getArray,"Expected `layers` to be an array or a `Collection`"):n=new Ti(void 0,{unique:!0}),this.setLayers(n)}handleLayerChange_(){this.changed()}handleLayersChanged_(){this.layersListenerKeys_.forEach(Un),this.layersListenerKeys_.length=0;const t=this.getLayers();this.layersListenerKeys_.push($n(t,On,this.handleLayersAdd_,this),$n(t,zn,this.handleLayersRemove_,this));for(const t in this.listenerKeys_)this.listenerKeys_[t].forEach(Un);jn(this.listenerKeys_);const e=t.getArray();for(let t=0,n=e.length;t<n;t++){const n=e[t];this.registerLayerListeners_(n),this.dispatchEvent(new zh(Dh,n))}this.changed()}registerLayerListeners_(t){const e=[$n(t,Nn,this.handleLayerChange_,this),$n(t,Vn,this.handleLayerChange_,this)];t instanceof jh&&e.push($n(t,Dh,this.handleLayerGroupAdd_,this),$n(t,Oh,this.handleLayerGroupRemove_,this)),this.listenerKeys_[wi(t)]=e}handleLayerGroupAdd_(t){this.dispatchEvent(new zh(Dh,t.layer))}handleLayerGroupRemove_(t){this.dispatchEvent(new zh(Oh,t.layer))}handleLayersAdd_(t){const e=t.element;this.registerLayerListeners_(e),this.dispatchEvent(new zh(Dh,e)),this.changed()}handleLayersRemove_(t){const e=t.element,n=wi(e);this.listenerKeys_[n].forEach(Un),delete this.listenerKeys_[n],this.dispatchEvent(new zh(Oh,e)),this.changed()}getLayers(){return this.get(Nh)}setLayers(t){const e=this.getLayers();if(e){const t=e.getArray();for(let e=0,n=t.length;e<n;++e)this.dispatchEvent(new zh(Oh,t[e]))}this.set(Nh,t)}getLayersArray(t){return t=void 0!==t?t:[],this.getLayers().forEach(function(e){e.getLayersArray(t)}),t}getLayerStatesArray(t){const e=void 0!==t?t:[],n=e.length;this.getLayers().forEach(function(t){t.getLayerStatesArray(e)});const i=this.getLayerState();let r=i.zIndex;t||void 0!==i.zIndex||(r=0);for(let t=n,s=e.length;t<s;t++){const n=e[t];n.opacity*=i.opacity,n.visible=n.visible&&i.visible,n.maxResolution=Math.min(n.maxResolution,i.maxResolution),n.minResolution=Math.max(n.minResolution,i.minResolution),n.minZoom=Math.max(n.minZoom,i.minZoom),n.maxZoom=Math.min(n.maxZoom,i.maxZoom),void 0!==i.extent&&(void 0!==n.extent?n.extent=is(n.extent,i.extent):n.extent=i.extent),void 0===n.zIndex&&(n.zIndex=r)}return e}getSourceState(){return"ready"}}var Gh=Object.freeze({__proto__:null,GroupEvent:zh,default:jh}),$h="prerender",Bh="postrender",Uh="precompose",Vh="postcompose",Xh="rendercomplete";class Wh extends Ah{constructor(t){const e=Object.assign({},t);delete e.source,super(e),this.on,this.once,this.un,this.mapPrecomposeKey_=null,this.mapRenderKey_=null,this.sourceChangeKey_=null,this.renderer_=null,this.sourceReady_=!1,this.rendered=!1,t.render&&(this.render=t.render),t.map&&this.setMap(t.map),this.addChangeListener(kh,this.handleSourcePropertyChange_);const n=t.source?t.source:null;this.setSource(n)}getLayersArray(t){return(t=t||[]).push(this),t}getLayerStatesArray(t){return(t=t||[]).push(this.getLayerState()),t}getSource(){return this.get(kh)||null}getRenderSource(){return this.getSource()}getSourceState(){const t=this.getSource();return t?t.getState():"undefined"}handleSourceChange_(){this.changed(),this.sourceReady_||"ready"!==this.getSource().getState()||(this.sourceReady_=!0,this.dispatchEvent("sourceready"))}handleSourcePropertyChange_(){this.sourceChangeKey_&&(Un(this.sourceChangeKey_),this.sourceChangeKey_=null),this.sourceReady_=!1;const t=this.getSource();t&&(this.sourceChangeKey_=$n(t,Vn,this.handleSourceChange_,this),"ready"===t.getState()&&(this.sourceReady_=!0,setTimeout(()=>{this.dispatchEvent("sourceready")},0))),this.changed()}getFeatures(t){return this.renderer_?this.renderer_.getFeatures(t):Promise.resolve([])}getData(t){return this.renderer_&&this.rendered?this.renderer_.getData(t):null}isVisible(t){let e;const n=this.getMapInternal();let i;if(!t&&n&&(t=n.getView()),e=t instanceof dl?{viewState:t.getState(),extent:t.calculateExtent()}:t,!e.layerStatesArray&&n&&(e.layerStatesArray=n.getLayerGroup().getLayerStatesArray()),e.layerStatesArray){if(i=e.layerStatesArray.find(t=>t.layer===this),!i)return!1}else i=this.getLayerState();const r=this.getExtent();return qh(i,e.viewState)&&(!r||as(r,e.extent))}getAttributions(t){if(!this.isVisible(t))return[];const e=this.getSource()?.getAttributions();if(!e)return[];let n=e(t instanceof dl?t.getViewStateAndExtent():t);return Array.isArray(n)||(n=[n]),n}render(t,e){const n=this.getRenderer();return n.prepareFrame(t)?(this.rendered=!0,n.renderFrame(t,e)):null}unrender(){this.rendered=!1}getDeclutter(){}renderDeclutter(t,e){}renderDeferred(t){const e=this.getRenderer();e&&e.renderDeferred(t)}setMapInternal(t){t||this.unrender(),this.set(Lh,t)}getMapInternal(){return this.get(Lh)}setMap(t){this.mapPrecomposeKey_&&(Un(this.mapPrecomposeKey_),this.mapPrecomposeKey_=null),t||this.changed(),this.mapRenderKey_&&(Un(this.mapRenderKey_),this.mapRenderKey_=null),t&&(this.mapPrecomposeKey_=$n(t,Uh,this.handlePrecompose_,this),this.mapRenderKey_=$n(this,Vn,t.render,t),this.changed())}handlePrecompose_(t){const e=t.frameState.layerStatesArray,n=this.getLayerState(!1);ir(!e.some(t=>t.layer===n.layer),"A layer can only be added to the map once. Use either `layer.setMap()` or `map.addLayer()`, not both."),e.push(n)}setSource(t){this.set(kh,t)}getRenderer(){return this.renderer_||(this.renderer_=this.createRenderer()),this.renderer_}hasRenderer(){return!!this.renderer_}createRenderer(){return null}clearRenderer(){this.renderer_&&(this.renderer_.dispose(),delete this.renderer_)}disposeInternal(){this.clearRenderer(),this.setSource(null),super.disposeInternal()}}function qh(t,e){if(!t.visible)return!1;const n=e.resolution;if(n<t.minResolution||n>=t.maxResolution)return!1;const i=e.zoom;return i>t.minZoom&&i<=t.maxZoom}function Zh(t,e,n=0,i=t.length-1,r=Yh){for(;i>n;){if(i-n>600){const s=i-n+1,o=e-n+1,a=Math.log(s),l=.5*Math.exp(2*a/3),h=.5*Math.sqrt(a*l*(s-l)/s)*(o-s/2<0?-1:1);Zh(t,e,Math.max(n,Math.floor(e-o*l/s+h)),Math.min(i,Math.floor(e+(s-o)*l/s+h)),r)}const s=t[e];let o=n,a=i;for(Kh(t,n,e),r(t[i],s)>0&&Kh(t,n,i);o<a;){for(Kh(t,o,a),o++,a--;r(t[o],s)<0;)o++;for(;r(t[a],s)>0;)a--}0===r(t[n],s)?Kh(t,n,a):(a++,Kh(t,a,i)),a<=e&&(n=a+1),e<=a&&(i=a-1)}}function Kh(t,e,n){const i=t[e];t[e]=t[n],t[n]=i}function Yh(t,e){return t<e?-1:t>e?1:0}let Hh=class{constructor(t=9){this._maxEntries=Math.max(4,t),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),this.clear()}all(){return this._all(this.data,[])}search(t){let e=this.data;const n=[];if(!hc(t,e))return n;const i=this.toBBox,r=[];for(;e;){for(let s=0;s<e.children.length;s++){const o=e.children[s],a=e.leaf?i(o):o;hc(t,a)&&(e.leaf?n.push(o):lc(t,a)?this._all(o,n):r.push(o))}e=r.pop()}return n}collides(t){let e=this.data;if(!hc(t,e))return!1;const n=[];for(;e;){for(let i=0;i<e.children.length;i++){const r=e.children[i],s=e.leaf?this.toBBox(r):r;if(hc(t,s)){if(e.leaf||lc(t,s))return!0;n.push(r)}}e=n.pop()}return!1}load(t){if(!t||!t.length)return this;if(t.length<this._minEntries){for(let e=0;e<t.length;e++)this.insert(t[e]);return this}let e=this._build(t.slice(),0,t.length-1,0);if(this.data.children.length)if(this.data.height===e.height)this._splitRoot(this.data,e);else{if(this.data.height<e.height){const t=this.data;this.data=e,e=t}this._insert(e,this.data.height-e.height-1,!0)}else this.data=e;return this}insert(t){return t&&this._insert(t,this.data.height-1),this}clear(){return this.data=cc([]),this}remove(t,e){if(!t)return this;let n=this.data;const i=this.toBBox(t),r=[],s=[];let o,a,l;for(;n||r.length;){if(n||(n=r.pop(),a=r[r.length-1],o=s.pop(),l=!0),n.leaf){const i=Jh(t,n.children,e);if(-1!==i)return n.children.splice(i,1),r.push(n),this._condense(r),this}l||n.leaf||!lc(n,i)?a?(o++,n=a.children[o],l=!1):n=null:(r.push(n),s.push(o),o=0,a=n,n=n.children[0])}return this}toBBox(t){return t}compareMinX(t,e){return t.minX-e.minX}compareMinY(t,e){return t.minY-e.minY}toJSON(){return this.data}fromJSON(t){return this.data=t,this}_all(t,e){const n=[];for(;t;)t.leaf?e.push(...t.children):n.push(...t.children),t=n.pop();return e}_build(t,e,n,i){const r=n-e+1;let s,o=this._maxEntries;if(r<=o)return s=cc(t.slice(e,n+1)),Qh(s,this.toBBox),s;i||(i=Math.ceil(Math.log(r)/Math.log(o)),o=Math.ceil(r/Math.pow(o,i-1))),s=cc([]),s.leaf=!1,s.height=i;const a=Math.ceil(r/o),l=a*Math.ceil(Math.sqrt(o));uc(t,e,n,l,this.compareMinX);for(let r=e;r<=n;r+=l){const e=Math.min(r+l-1,n);uc(t,r,e,a,this.compareMinY);for(let n=r;n<=e;n+=a){const r=Math.min(n+a-1,e);s.children.push(this._build(t,n,r,i-1))}}return Qh(s,this.toBBox),s}_chooseSubtree(t,e,n,i){for(;i.push(e),!e.leaf&&i.length-1!==n;){let n,i=1/0,r=1/0;for(let s=0;s<e.children.length;s++){const o=e.children[s],a=rc(o),l=oc(t,o)-a;l<r?(r=l,i=a<i?a:i,n=o):l===r&&a<i&&(i=a,n=o)}e=n||e.children[0]}return e}_insert(t,e,n){const i=n?t:this.toBBox(t),r=[],s=this._chooseSubtree(i,this.data,e,r);for(s.children.push(t),ec(s,i);e>=0&&r[e].children.length>this._maxEntries;)this._split(r,e),e--;this._adjustParentBBoxes(i,r,e)}_split(t,e){const n=t[e],i=n.children.length,r=this._minEntries;this._chooseSplitAxis(n,r,i);const s=this._chooseSplitIndex(n,r,i),o=cc(n.children.splice(s,n.children.length-s));o.height=n.height,o.leaf=n.leaf,Qh(n,this.toBBox),Qh(o,this.toBBox),e?t[e-1].children.push(o):this._splitRoot(n,o)}_splitRoot(t,e){this.data=cc([t,e]),this.data.height=t.height+1,this.data.leaf=!1,Qh(this.data,this.toBBox)}_chooseSplitIndex(t,e,n){let i,r=1/0,s=1/0;for(let o=e;o<=n-e;o++){const e=tc(t,0,o,this.toBBox),a=tc(t,o,n,this.toBBox),l=ac(e,a),h=rc(e)+rc(a);l<r?(r=l,i=o,s=h<s?h:s):l===r&&h<s&&(s=h,i=o)}return i||n-e}_chooseSplitAxis(t,e,n){const i=t.leaf?this.compareMinX:nc,r=t.leaf?this.compareMinY:ic;this._allDistMargin(t,e,n,i)<this._allDistMargin(t,e,n,r)&&t.children.sort(i)}_allDistMargin(t,e,n,i){t.children.sort(i);const r=this.toBBox,s=tc(t,0,e,r),o=tc(t,n-e,n,r);let a=sc(s)+sc(o);for(let i=e;i<n-e;i++){const e=t.children[i];ec(s,t.leaf?r(e):e),a+=sc(s)}for(let i=n-e-1;i>=e;i--){const e=t.children[i];ec(o,t.leaf?r(e):e),a+=sc(o)}return a}_adjustParentBBoxes(t,e,n){for(let i=n;i>=0;i--)ec(e[i],t)}_condense(t){for(let e,n=t.length-1;n>=0;n--)0===t[n].children.length?n>0?(e=t[n-1].children,e.splice(e.indexOf(t[n]),1)):this.clear():Qh(t[n],this.toBBox)}};function Jh(t,e,n){if(!n)return e.indexOf(t);for(let i=0;i<e.length;i++)if(n(t,e[i]))return i;return-1}function Qh(t,e){tc(t,0,t.children.length,e,t)}function tc(t,e,n,i,r){r||(r=cc(null)),r.minX=1/0,r.minY=1/0,r.maxX=-1/0,r.maxY=-1/0;for(let s=e;s<n;s++){const e=t.children[s];ec(r,t.leaf?i(e):e)}return r}function ec(t,e){return t.minX=Math.min(t.minX,e.minX),t.minY=Math.min(t.minY,e.minY),t.maxX=Math.max(t.maxX,e.maxX),t.maxY=Math.max(t.maxY,e.maxY),t}function nc(t,e){return t.minX-e.minX}function ic(t,e){return t.minY-e.minY}function rc(t){return(t.maxX-t.minX)*(t.maxY-t.minY)}function sc(t){return t.maxX-t.minX+(t.maxY-t.minY)}function oc(t,e){return(Math.max(e.maxX,t.maxX)-Math.min(e.minX,t.minX))*(Math.max(e.maxY,t.maxY)-Math.min(e.minY,t.minY))}function ac(t,e){const n=Math.max(t.minX,e.minX),i=Math.max(t.minY,e.minY),r=Math.min(t.maxX,e.maxX),s=Math.min(t.maxY,e.maxY);return Math.max(0,r-n)*Math.max(0,s-i)}function lc(t,e){return t.minX<=e.minX&&t.minY<=e.minY&&e.maxX<=t.maxX&&e.maxY<=t.maxY}function hc(t,e){return e.minX<=t.maxX&&e.minY<=t.maxY&&e.maxX>=t.minX&&e.maxY>=t.minY}function cc(t){return{children:t,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function uc(t,e,n,i,r){const s=[e,n];for(;s.length;){if((n=s.pop())-(e=s.pop())<=i)continue;const o=e+Math.ceil((n-e)/i/2)*i;Zh(t,o,e,n,r),s.push(e,o,o,n)}}const dc=[NaN,NaN,NaN,0];let fc;const gc=/^rgba?\(\s*(\d+%?)\s+(\d+%?)\s+(\d+%?)(?:\s*\/\s*(\d+%|\d*\.\d+|[01]))?\s*\)$/i,pc=/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)(?:\s*,\s*(\d+%|\d*\.\d+|[01]))?\s*\)$/i,mc=/^rgba?\(\s*(\d+%)\s*,\s*(\d+%)\s*,\s*(\d+%)(?:\s*,\s*(\d+%|\d*\.\d+|[01]))?\s*\)$/i,_c=/^#([\da-f]{3,4}|[\da-f]{6}|[\da-f]{8})$/i;function yc(t,e){return t.endsWith("%")?Number(t.substring(0,t.length-1))/e:Number(t)}function xc(t){throw new Error('failed to parse "'+t+'" as color')}function vc(t){if(t.toLowerCase().startsWith("rgb")){const e=t.match(pc)||t.match(gc)||t.match(mc);if(e){const t=e[4],n=100/255;return[cr(yc(e[1],n)+.5|0,0,255),cr(yc(e[2],n)+.5|0,0,255),cr(yc(e[3],n)+.5|0,0,255),void 0!==t?cr(yc(t,100),0,1):1]}xc(t)}if(t.startsWith("#")){if(_c.test(t)){const e=t.substring(1),n=e.length<=4?1:2,i=[0,0,0,255];for(let t=0,r=e.length;t<r;t+=n){let r=parseInt(e.substring(t,t+n),16);1===n&&(r+=r<<4),i[t/n]=r}return i[3]=i[3]/255,i}xc(t)}const e=(fc||(fc=Cl(1,1,void 0,{willReadFrequently:!0,desynchronized:!0})),fc);e.fillStyle="#abcdef";let n=e.fillStyle;e.fillStyle=t,e.fillStyle===n&&(e.fillStyle="#fedcba",n=e.fillStyle,e.fillStyle=t,e.fillStyle===n&&xc(t));const i=e.fillStyle;if(i.startsWith("#")||i.startsWith("rgba"))return vc(i);e.clearRect(0,0,1,1),e.fillRect(0,0,1,1);const r=Array.from(e.getImageData(0,0,1,1).data);return r[3]=_r(r[3]/255,3),r}const bc={};let wc=0;function Sc(t){if(4===t.length)return t;const e=t.slice();return e[3]=1,e}function Cc(t){return t>.0031308?269.025*Math.pow(t,1/2.4)-14.025:3294.6*t}function Ec(t){return t>.2068965?Math.pow(t,3):108/841*(t-4/29)}function Pc(t){return t>10.314724?Math.pow((t+14.025)/269.025,2.4):t/3294.6}function Tc(t){return t>.0088564?Math.pow(t,1/3):t/(108/841)+4/29}function Rc(t){const e=Pc(t[0]),n=Pc(t[1]),i=Pc(t[2]),r=Tc(.222488403*e+.716873169*n+.06060791*i),s=500*(Tc(.452247074*e+.399439023*n+.148375274*i)-r),o=200*(r-Tc(.016863605*e+.117638439*n+.865350722*i)),a=Math.atan2(o,s)*(180/Math.PI);return[116*r-16,Math.sqrt(s*s+o*o),a<0?a+360:a,t[3]]}function Fc(t){if("none"===t)return dc;if(bc.hasOwnProperty(t))return bc[t];if(wc>=1024){let t=0;for(const e in bc)3&t++||(delete bc[e],--wc)}const e=vc(t);4!==e.length&&xc(t);for(const n of e)isNaN(n)&&xc(t);return bc[t]=e,++wc,e}function Mc(t){return Array.isArray(t)?t:Fc(t)}function Ic(t){let e=t[0];e!=(0|e)&&(e=e+.5|0);let n=t[1];n!=(0|n)&&(n=n+.5|0);let i=t[2];i!=(0|i)&&(i=i+.5|0);return"rgba("+e+","+n+","+i+","+(void 0===t[3]?1:Math.round(1e3*t[3])/1e3)+")"}function kc(t){return t[0]>0&&t[1]>0}function Lc(t,e){return Array.isArray(t)?t:(void 0===e?e=[t,t]:(e[0]=t,e[1]=t),e)}let Ac=0;const Dc=1<<Ac++,Oc=1<<Ac++,zc=1<<Ac++,Nc=1<<Ac++,jc=1<<Ac++,Gc=1<<Ac++,$c=Math.pow(2,6)-1,Bc={[Dc]:"boolean",[Oc]:"number",[zc]:"string",[Nc]:"color",[jc]:"number[]",[Gc]:"size"},Uc=Object.keys(Bc).map(Number).sort(ri);function Vc(t){const e=[];for(const n of Uc)Xc(t,n)&&e.push(Bc[n]);return 0===e.length?"untyped":e.length<3?e.join(" or "):e.slice(0,-1).join(", ")+", or "+e[e.length-1]}function Xc(t,e){return(t&e)===e}function Wc(t,e){return t===e}class qc{constructor(t,e){if(!function(t){return t in Bc}(t))throw new Error(`literal expressions must have a specific type, got ${Vc(t)}`);this.type=t,this.value=e}}class Zc{constructor(t,e,...n){this.type=t,this.operator=e,this.args=n}}function Kc(){return{variables:new Set,properties:new Set,featureId:!1,geometryType:!1,mCoordinate:!1,mapState:!1}}function Yc(t,e,n){switch(typeof t){case"boolean":if(Wc(e,zc))return new qc(zc,t?"true":"false");if(!Xc(e,Dc))throw new Error(`got a boolean, but expected ${Vc(e)}`);return new qc(Dc,t);case"number":if(Wc(e,Gc))return new qc(Gc,Lc(t));if(Wc(e,Dc))return new qc(Dc,!!t);if(Wc(e,zc))return new qc(zc,t.toString());if(!Xc(e,Oc))throw new Error(`got a number, but expected ${Vc(e)}`);return new qc(Oc,t);case"string":if(Wc(e,Nc))return new qc(Nc,Fc(t));if(Wc(e,Dc))return new qc(Dc,!!t);if(!Xc(e,zc))throw new Error(`got a string, but expected ${Vc(e)}`);return new qc(zc,t)}if(!Array.isArray(t))throw new Error("expression must be an array or a primitive value");if(0===t.length)throw new Error("empty expression");if("string"==typeof t[0])return function(t,e,n){const i=t[0],r=Vu[i];if(!r)throw new Error(`unknown operator: ${i}`);return r(t,e,n)}(t,e,n);for(const e of t)if("number"!=typeof e)throw new Error("expected an array of numbers");if(Wc(e,Gc)){if(2!==t.length)throw new Error(`expected an array of two values for a size, got ${t.length}`);return new qc(Gc,t)}if(Wc(e,Nc)){if(3===t.length)return new qc(Nc,[...t,1]);if(4===t.length)return new qc(Nc,t);throw new Error(`expected an array of 3 or 4 values for a color, got ${t.length}`)}if(!Xc(e,jc))throw new Error(`got an array of numbers, but expected ${Vc(e)}`);return new qc(jc,t)}const Hc="get",Jc="var",Qc="concat",tu="geometry-type",eu="line-metric",nu="any",iu="all",ru="!",su="resolution",ou="zoom",au="time",lu="==",hu="!=",cu=">",uu=">=",du="<",fu="<=",gu="*",pu="/",mu="+",_u="-",yu="clamp",xu="%",vu="^",bu="abs",wu="floor",Su="ceil",Cu="round",Eu="sin",Pu="cos",Tu="atan",Ru="sqrt",Fu="match",Mu="between",Iu="interpolate",ku="coalesce",Lu="case",Au="in",Du="number",Ou="string",zu="array",Nu="color",ju="id",Gu="band",$u="palette",Bu="to-string",Uu="has",Vu={[Hc]:Ju(Zu(1,1/0),Xu),[Jc]:Ju(Zu(1,1),function(t,e,n){const i=t[1];if("string"!=typeof i)throw new Error("expected a string argument for var operation");return n.variables.add(i),[new qc(zc,i)]}),[Uu]:Ju(Zu(1,1/0),Xu),[ju]:Ju(function(t,e,n){n.featureId=!0},qu),[Qc]:Ju(Zu(2,1/0),Yu(zc)),[tu]:Ju(function(t,e,n){n.geometryType=!0},qu),[eu]:Ju(function(t,e,n){n.mCoordinate=!0},qu),[su]:Ju(Wu,qu),[ou]:Ju(Wu,qu),[au]:Ju(Wu,qu),[nu]:Ju(Zu(2,1/0),Yu(Dc)),[iu]:Ju(Zu(2,1/0),Yu(Dc)),[ru]:Ju(Zu(1,1),Yu(Dc)),[lu]:Ju(Zu(2,2),Yu($c)),[hu]:Ju(Zu(2,2),Yu($c)),[cu]:Ju(Zu(2,2),Yu(Oc)),[uu]:Ju(Zu(2,2),Yu(Oc)),[du]:Ju(Zu(2,2),Yu(Oc)),[fu]:Ju(Zu(2,2),Yu(Oc)),[gu]:Ju(Zu(2,1/0),Ku),[ku]:Ju(Zu(2,1/0),Ku),[pu]:Ju(Zu(2,2),Yu(Oc)),[mu]:Ju(Zu(2,1/0),Yu(Oc)),[_u]:Ju(Zu(2,2),Yu(Oc)),[yu]:Ju(Zu(3,3),Yu(Oc)),[xu]:Ju(Zu(2,2),Yu(Oc)),[vu]:Ju(Zu(2,2),Yu(Oc)),[bu]:Ju(Zu(1,1),Yu(Oc)),[wu]:Ju(Zu(1,1),Yu(Oc)),[Su]:Ju(Zu(1,1),Yu(Oc)),[Cu]:Ju(Zu(1,1),Yu(Oc)),[Eu]:Ju(Zu(1,1),Yu(Oc)),[Pu]:Ju(Zu(1,1),Yu(Oc)),[Tu]:Ju(Zu(1,2),Yu(Oc)),[Ru]:Ju(Zu(1,1),Yu(Oc)),[Fu]:Ju(Zu(4,1/0),Hu,function(t,e,n){const i=t.length-1,r=zc|Oc|Dc,s=Yc(t[1],r,n),o=Yc(t[t.length-1],e,n),a=new Array(i-2);for(let e=0;e<i-2;e+=2){try{const i=Yc(t[e+2],s.type,n);a[e]=i}catch(t){throw new Error(`failed to parse argument ${e+1} of match expression: ${t.message}`)}try{const i=Yc(t[e+3],o.type,n);a[e+1]=i}catch(t){throw new Error(`failed to parse argument ${e+2} of match expression: ${t.message}`)}}return[s,...a,o]}),[Mu]:Ju(Zu(3,3),Yu(Oc)),[Iu]:Ju(Zu(6,1/0),Hu,function(t,e,n){const i=t[1];let r;switch(i[0]){case"linear":r=1;break;case"exponential":const t=i[1];if("number"!=typeof t||t<=0)throw new Error(`expected a number base for exponential interpolation, got ${JSON.stringify(t)} instead`);r=t;break;default:throw new Error(`invalid interpolation type: ${JSON.stringify(i)}`)}const s=new qc(Oc,r);let o;try{o=Yc(t[2],Oc,n)}catch(t){throw new Error(`failed to parse argument 1 in interpolate expression: ${t.message}`)}const a=new Array(t.length-3);for(let i=0;i<a.length;i+=2){try{const e=Yc(t[i+3],Oc,n);a[i]=e}catch(t){throw new Error(`failed to parse argument ${i+2} for interpolate expression: ${t.message}`)}try{const r=Yc(t[i+4],e,n);a[i+1]=r}catch(t){throw new Error(`failed to parse argument ${i+3} for interpolate expression: ${t.message}`)}}return[s,o,...a]}),[Lu]:Ju(Zu(3,1/0),function(t,e,n){const i=t[0],r=t.length-1;if(r%2==0)throw new Error(`expected an odd number of arguments for ${i}, got ${r} instead`)},function(t,e,n){const i=Yc(t[t.length-1],e,n),r=new Array(t.length-1);for(let e=0;e<r.length-1;e+=2){try{const i=Yc(t[e+1],Dc,n);r[e]=i}catch(t){throw new Error(`failed to parse argument ${e} of case expression: ${t.message}`)}try{const s=Yc(t[e+2],i.type,n);r[e+1]=s}catch(t){throw new Error(`failed to parse argument ${e+1} of case expression: ${t.message}`)}}return r[r.length-1]=i,r}),[Au]:Ju(Zu(2,2),function(t,e,n){let i,r=t[2];if(!Array.isArray(r))throw new Error('the second argument for the "in" operator must be an array');if("literal"===r[0]){if(r=r[1],!Array.isArray(r))throw new Error('failed to parse "in" expression: the literal operator must be followed by an array')}else if("string"==typeof r[0])throw new Error('for the "in" operator, a string array should be wrapped in a "literal" operator to disambiguate from expressions');i="string"==typeof r[0]?zc:Oc;const s=new Array(r.length);for(let t=0;t<s.length;t++)try{const e=Yc(r[t],i,n);s[t]=e}catch(e){throw new Error(`failed to parse haystack item ${t} for "in" expression: ${e.message}`)}return[Yc(t[1],i,n),...s]}),[Du]:Ju(Zu(1,1/0),Yu($c)),[Ou]:Ju(Zu(1,1/0),Yu($c)),[zu]:Ju(Zu(1,1/0),Yu(Oc)),[Nu]:Ju(Zu(1,4),Yu(Oc)),[Gu]:Ju(Zu(1,3),Yu(Oc)),[$u]:Ju(Zu(2,2),function(t,e,n){let i;try{i=Yc(t[1],Oc,n)}catch(t){throw new Error(`failed to parse first argument in palette expression: ${t.message}`)}const r=t[2];if(!Array.isArray(r))throw new Error("the second argument of palette must be an array");const s=new Array(r.length);for(let t=0;t<s.length;t++){let e;try{e=Yc(r[t],Nc,n)}catch(e){throw new Error(`failed to parse color at index ${t} in palette expression: ${e.message}`)}if(!(e instanceof qc))throw new Error(`the palette color at index ${t} must be a literal value`);s[t]=e}return[i,...s]}),[Bu]:Ju(Zu(1,1),Yu(Dc|Oc|zc|Nc))};function Xu(t,e,n){const i=t.length-1,r=new Array(i);for(let e=0;e<i;++e){const i=t[e+1];switch(typeof i){case"number":r[e]=new qc(Oc,i);break;case"string":r[e]=new qc(zc,i);break;default:throw new Error(`expected a string key or numeric array index for a get operation, got ${i}`)}0===e&&n.properties.add(String(i))}return r}function Wu(t,e,n){n.mapState=!0}function qu(t,e,n){const i=t[0];if(1!==t.length)throw new Error(`expected no arguments for ${i} operation`);return[]}function Zu(t,e){return function(n,i,r){const s=n[0],o=n.length-1;if(t===e){if(o!==t){throw new Error(`expected ${t} argument${1===t?"":"s"} for ${s}, got ${o}`)}}else if(o<t||o>e){throw new Error(`expected ${e===1/0?`${t} or more`:`${t} to ${e}`} arguments for ${s}, got ${o}`)}}}function Ku(t,e,n){const i=t.length-1,r=new Array(i);for(let s=0;s<i;++s){const i=Yc(t[s+1],e,n);r[s]=i}return r}function Yu(t){return function(e,n,i){const r=e.length-1,s=new Array(r);for(let n=0;n<r;++n){const r=Yc(e[n+1],t,i);s[n]=r}return s}}function Hu(t,e,n){const i=t[0],r=t.length-1;if(r%2==1)throw new Error(`expected an even number of arguments for operation ${i}, got ${r} instead`)}function Ju(...t){return function(e,n,i){const r=e[0];let s;for(let r=0;r<t.length;r++){const o=t[r](e,n,i);if(r==t.length-1){if(!o)throw new Error("expected last argument validator to return the parsed args");s=o}}return new Zc(n,r,...s)}}function Qu(t){if(!t)return"";const e=t.getType();switch(e){case"Point":case"LineString":case"Polygon":return e;case"MultiPoint":case"MultiLineString":case"MultiPolygon":return e.substring(5);case"Circle":return"Polygon";case"GeometryCollection":return Qu(t.getGeometries()[0]);default:return""}}function td(t,e,n){return ed(Yc(t,e,n))}function ed(t,e){if(t instanceof qc){if(t.type===Nc&&"string"==typeof t.value){const e=Fc(t.value);return function(){return e}}return function(){return t.value}}const n=t.operator;switch(n){case Du:case Ou:case ku:return function(t){const e=t.operator,n=t.args.length,i=new Array(n);for(let e=0;e<n;++e)i[e]=ed(t.args[e]);switch(e){case ku:return t=>{for(let e=0;e<n;++e){const n=i[e](t);if(null!=n)return n}throw new Error("Expected one of the values to be non-null")};case Du:case Ou:return t=>{for(let r=0;r<n;++r){const n=i[r](t);if(typeof n===e)return n}throw new Error(`Expected one of the values to be a ${e}`)};default:throw new Error(`Unsupported assertion operator ${e}`)}}(t);case Hc:case Jc:case Uu:return function(t){const e=t.args[0],n=e.value;switch(t.operator){case Hc:return e=>{const i=t.args;let r=e.properties[n];for(let t=1,e=i.length;t<e;++t){r=r[i[t].value]}return r};case Jc:return t=>t.variables[n];case Uu:return e=>{const i=t.args;if(!(n in e.properties))return!1;let r=e.properties[n];for(let t=1,e=i.length;t<e;++t){const e=i[t].value;if(!r||!Object.hasOwn(r,e))return!1;r=r[e]}return!0};default:throw new Error(`Unsupported accessor operator ${t.operator}`)}}(t);case ju:return t=>t.featureId;case tu:return t=>t.geometryType;case Qc:{const e=t.args.map(t=>ed(t));return t=>"".concat(...e.map(e=>e(t).toString()))}case su:return t=>t.resolution;case nu:case iu:case Mu:case Au:case ru:return function(t){const e=t.operator,n=t.args.length,i=new Array(n);for(let e=0;e<n;++e)i[e]=ed(t.args[e]);switch(e){case nu:return t=>{for(let e=0;e<n;++e)if(i[e](t))return!0;return!1};case iu:return t=>{for(let e=0;e<n;++e)if(!i[e](t))return!1;return!0};case Mu:return t=>{const e=i[0](t),n=i[1](t),r=i[2](t);return e>=n&&e<=r};case Au:return t=>{const e=i[0](t);for(let r=1;r<n;++r)if(e===i[r](t))return!0;return!1};case ru:return t=>!i[0](t);default:throw new Error(`Unsupported logical operator ${e}`)}}(t);case lu:case hu:case du:case fu:case cu:case uu:return function(t){const e=t.operator,n=ed(t.args[0]),i=ed(t.args[1]);switch(e){case lu:return t=>n(t)===i(t);case hu:return t=>n(t)!==i(t);case du:return t=>n(t)<i(t);case fu:return t=>n(t)<=i(t);case cu:return t=>n(t)>i(t);case uu:return t=>n(t)>=i(t);default:throw new Error(`Unsupported comparison operator ${e}`)}}(t);case gu:case pu:case mu:case _u:case yu:case xu:case vu:case bu:case wu:case Su:case Cu:case Eu:case Pu:case Tu:case Ru:return function(t){const e=t.operator,n=t.args.length,i=new Array(n);for(let e=0;e<n;++e)i[e]=ed(t.args[e]);switch(e){case gu:return t=>{let e=1;for(let r=0;r<n;++r)e*=i[r](t);return e};case pu:return t=>i[0](t)/i[1](t);case mu:return t=>{let e=0;for(let r=0;r<n;++r)e+=i[r](t);return e};case _u:return t=>i[0](t)-i[1](t);case yu:return t=>{const e=i[0](t),n=i[1](t);if(e<n)return n;const r=i[2](t);return e>r?r:e};case xu:return t=>i[0](t)%i[1](t);case vu:return t=>Math.pow(i[0](t),i[1](t));case bu:return t=>Math.abs(i[0](t));case wu:return t=>Math.floor(i[0](t));case Su:return t=>Math.ceil(i[0](t));case Cu:return t=>Math.round(i[0](t));case Eu:return t=>Math.sin(i[0](t));case Pu:return t=>Math.cos(i[0](t));case Tu:return 2===n?t=>Math.atan2(i[0](t),i[1](t)):t=>Math.atan(i[0](t));case Ru:return t=>Math.sqrt(i[0](t));default:throw new Error(`Unsupported numeric operator ${e}`)}}(t);case Lu:return function(t){const e=t.args.length,n=new Array(e);for(let i=0;i<e;++i)n[i]=ed(t.args[i]);return t=>{for(let i=0;i<e-1;i+=2){if(n[i](t))return n[i+1](t)}return n[e-1](t)}}(t);case Fu:return function(t){const e=t.args.length,n=new Array(e);for(let i=0;i<e;++i)n[i]=ed(t.args[i]);return t=>{const i=n[0](t);for(let r=1;r<e-1;r+=2)if(i===n[r](t))return n[r+1](t);return n[e-1](t)}}(t);case Iu:return function(t){const e=t.args.length,n=new Array(e);for(let i=0;i<e;++i)n[i]=ed(t.args[i]);return t=>{const i=n[0](t),r=n[1](t);let s,o;for(let a=2;a<e;a+=2){const e=n[a](t);let l=n[a+1](t);const h=Array.isArray(l);if(h&&(l=Sc(l)),e>=r)return 2===a?l:h?id(i,r,s,o,e,l):nd(i,r,s,o,e,l);s=e,o=l}return o}}(t);case Bu:return function(t){const e=t.operator,n=t.args.length,i=new Array(n);for(let e=0;e<n;++e)i[e]=ed(t.args[e]);if(e===Bu)return e=>{const n=i[0](e);return t.args[0].type===Nc?Ic(n):n.toString()};throw new Error(`Unsupported convert operator ${e}`)}(t);default:throw new Error(`Unsupported operator ${n}`)}}function nd(t,e,n,i,r,s){const o=r-n;if(0===o)return i;const a=e-n;return i+(1===t?a/o:(Math.pow(t,a)-1)/(Math.pow(t,o)-1))*(s-i)}function id(t,e,n,i,r,s){if(0===r-n)return i;const o=Rc(i),a=Rc(s);let l=a[2]-o[2];l>180?l-=360:l<-180&&(l+=360);return function(t){const e=(t[0]+16)/116,n=t[1],i=t[2]*Math.PI/180,r=Ec(e),s=Ec(e+n/500*Math.cos(i)),o=Ec(e-n/200*Math.sin(i)),a=Cc(3.021973625*s-1.617392459*r-.404875592*o),l=Cc(-.943766287*s+1.916279586*r+.027607165*o),h=Cc(.069407491*s-.22898585*r+1.159737864*o);return[cr(a+.5|0,0,255),cr(l+.5|0,0,255),cr(h+.5|0,0,255),t[3]]}([nd(t,e,n,o[0],r,a[0]),nd(t,e,n,o[1],r,a[1]),o[2]+nd(t,e,n,0,r,l),nd(t,e,n,i[3],r,s[3])])}var rd=0,sd=1,od=2,ad=3,ld=4;class hd extends mi{constructor(t,e,n,i){super(),this.extent=t,this.pixelRatio_=n,this.resolution=e,this.state="function"==typeof i?rd:i,this.image_=null,this.loader="function"==typeof i?i:null}changed(){this.dispatchEvent(Vn)}getExtent(){return this.extent}getImage(){return this.image_}getPixelRatio(){return this.pixelRatio_}getResolution(){return this.resolution}getState(){return this.state}load(){if(this.state==rd&&this.loader){this.state=sd,this.changed();const t=this.getResolution(),e=Array.isArray(t)?t[0]:t;gi(()=>this.loader(this.getExtent(),e,this.getPixelRatio())).then(t=>{"image"in t&&(this.image_=t.image),"extent"in t&&(this.extent=t.extent),"resolution"in t&&(this.resolution=t.resolution),"pixelRatio"in t&&(this.pixelRatio_=t.pixelRatio),(t instanceof HTMLImageElement||Ni&&t instanceof ImageBitmap||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement)&&(this.image_=t),this.state=od}).catch(t=>{this.state=ad,console.error(t)}).finally(()=>this.changed())}}setImage(t){this.image_=t}setResolution(t){this.resolution=t}}function cd(t,e){return e&&(t.src=e),t.src&&zi?new Promise((e,n)=>t.decode().then(()=>e(t)).catch(i=>t.complete&&t.width?e(t):n(i))):function(t){return new Promise((e,n)=>{function i(){s(),e(t)}function r(){s(),n(new Error("Image load error"))}function s(){t.removeEventListener("load",i),t.removeEventListener("error",r)}t.addEventListener("load",i),t.addEventListener("error",r)})}(t)}function ud(t,e){return e&&(t.src=e),t.src&&zi&&Ni?t.decode().then(()=>createImageBitmap(t)).catch(e=>{if(t.complete&&t.width)return t;throw e}):cd(t)}function dd(t,e){return t+":"+(e?Mc(e):"null")}const fd=new class{constructor(){this.cache_={},this.patternCache_={},this.cacheSize_=0,this.maxCacheSize_=1024}clear(){this.cache_={},this.patternCache_={},this.cacheSize_=0}canExpireCache(){return this.cacheSize_>this.maxCacheSize_}expire(){if(this.canExpireCache()){let t=0;for(const e in this.cache_){const n=this.cache_[e];3&t++||n.hasListener()||(delete this.cache_[e],delete this.patternCache_[e],--this.cacheSize_)}}}get(t,e){const n=dd(t,e);return n in this.cache_?this.cache_[n]:null}getPattern(t,e){const n=dd(t,e);return n in this.patternCache_?this.patternCache_[n]:null}set(t,e,n,i){const r=dd(t,e),s=r in this.cache_;this.cache_[r]=n,i&&(n.getImageState()===rd&&n.load(),n.getImageState()===sd?n.ready().then(()=>{this.patternCache_[r]=Pl().createPattern(n.getImage(1),"repeat")}):this.patternCache_[r]=Pl().createPattern(n.getImage(1),"repeat")),s||++this.cacheSize_}setSize(t){this.maxCacheSize_=t,this.expire()}};let gd=null;class pd extends mi{constructor(t,e,n,i,r){super(),this.hitDetectionImage_=null,this.image_=t,this.crossOrigin_=n?.crossOrigin,this.referrerPolicy_=n?.referrerPolicy,this.canvas_={},this.color_=r,this.imageState_=void 0===i?rd:i,this.size_=t&&t.width&&t.height?[t.width,t.height]:null,this.src_=e,this.tainted_,this.ready_=null}initializeImage_(){this.image_=new Image,null!==this.crossOrigin_&&(this.image_.crossOrigin=this.crossOrigin_),void 0!==this.referrerPolicy_&&(this.image_.referrerPolicy=this.referrerPolicy_)}isTainted_(){if(void 0===this.tainted_&&this.imageState_===od){gd||(gd=Cl(1,1,void 0,{willReadFrequently:!0})),gd.drawImage(this.image_,0,0);try{gd.getImageData(0,0,1,1),this.tainted_=!1}catch{gd=null,this.tainted_=!0}}return!0===this.tainted_}dispatchChangeEvent_(){this.dispatchEvent(Vn)}handleImageError_(){this.imageState_=ad,this.dispatchChangeEvent_()}handleImageLoad_(){this.imageState_=od,this.size_=[this.image_.width,this.image_.height],this.dispatchChangeEvent_()}getImage(t){return this.image_||this.initializeImage_(),this.replaceColor_(t),this.canvas_[t]?this.canvas_[t]:this.image_}setImage(t){this.image_=t}getPixelRatio(t){return this.replaceColor_(t),this.canvas_[t]?t:1}getImageState(){return this.imageState_}getHitDetectionImage(){if(this.image_||this.initializeImage_(),!this.hitDetectionImage_)if(this.isTainted_()){const t=this.size_[0],e=this.size_[1],n=Cl(t,e);n.fillRect(0,0,t,e),this.hitDetectionImage_=n.canvas}else this.hitDetectionImage_=this.image_;return this.hitDetectionImage_}getSize(){return this.size_}getSrc(){return this.src_}load(){if(this.imageState_===rd){this.image_||this.initializeImage_(),this.imageState_=sd;try{void 0!==this.src_&&(this.image_.src=this.src_)}catch{this.handleImageError_()}this.image_ instanceof HTMLImageElement&&cd(this.image_,this.src_).then(t=>{this.image_=t,this.handleImageLoad_()}).catch(this.handleImageError_.bind(this))}}replaceColor_(t){if(!this.color_||this.canvas_[t]||this.imageState_!==od)return;const e=this.image_,n=Cl(Math.ceil(e.width*t),Math.ceil(e.height*t)),i=n.canvas;var r;n.scale(t,t),n.drawImage(e,0,0),n.globalCompositeOperation="multiply",n.fillStyle="string"==typeof(r=this.color_)?r:Ic(r),n.fillRect(0,0,i.width/t,i.height/t),n.globalCompositeOperation="destination-in",n.drawImage(e,0,0),this.canvas_[t]=i}ready(){return this.ready_||(this.ready_=new Promise(t=>{if(this.imageState_===od||this.imageState_===ad)t();else{const e=()=>{this.imageState_!==od&&this.imageState_!==ad||(this.removeEventListener(Vn,e),t())};this.addEventListener(Vn,e)}})),this.ready_}}function md(t,e,n,i,r,s){let o=void 0===e?void 0:fd.get(e,r);return o||(o=new pd(t,t&&"src"in t?t.src||void 0:e,n,i,r),fd.set(e,r,o,s)),s&&o&&!fd.getPattern(e,r)&&fd.set(e,r,o,s),o}function _d(t){return t?Array.isArray(t)?Ic(t):"object"==typeof t&&"src"in t?function(t){if(!t.offset||!t.size)return fd.getPattern(t.src,t.color);const e=t.src+":"+t.offset,n=fd.getPattern(e,t.color);if(n)return n;const i=fd.get(t.src,null);if(i.getImageState()!==od)return null;const r=Cl(t.size[0],t.size[1]);return r.drawImage(i.getImage(1),t.offset[0],t.offset[1],t.size[0],t.size[1],0,0,t.size[0],t.size[1]),md(r.canvas,e,void 0,od,t.color,!0),fd.getPattern(e,t.color)}(t):t:null}const yd="10px sans-serif",xd="#000",vd="round",bd=[],wd="round",Sd="#000",Cd="center",Ed="middle",Pd=[0,0,0,0],Td=new Ci;let Rd,Fd=null;const Md={},Id=new Set(["serif","sans-serif","monospace","cursive","fantasy","system-ui","ui-serif","ui-sans-serif","ui-monospace","ui-rounded","emoji","math","fangsong"]);function kd(t,e,n){return`${t} ${e} 16px "${n}"`}const Ld=function(){const t=100;let e,n;async function i(t){await n.ready;const e=await n.load(t);if(0===e.length)return!1;const i=Sl(t),r=i.families[0].toLowerCase(),s=i.weight;return e.some(t=>{const e=t.family.replace(/^['"]|['"]$/g,"").toLowerCase(),n=wl[t.weight]||t.weight;return e===r&&t.style===i.style&&n==s})}async function r(){await n.ready;let s=!0;const o=Td.getProperties(),a=Object.keys(o).filter(e=>o[e]<t);for(let e=a.length-1;e>=0;--e){const n=a[e];let r=o[n];r<t&&(await i(n)?(jn(Md),Td.set(n,t)):(r+=10,Td.set(n,r,!0),r<t&&(s=!1)))}e=void 0,s||(e=setTimeout(r,100))}return async function(t){n||(n=Oi?self.fonts:document.fonts);const i=Sl(t);if(!i)return;const s=i.families;let o=!1;for(const t of s){if(Id.has(t))continue;const e=kd(i.style,i.weight,t);void 0===Td.get(e)&&(Td.set(e,0,!0),o=!0)}o&&(clearTimeout(e),e=setTimeout(r,100))}}(),Ad=function(){let t;return function(e){let n=Md[e];if(null==n){if(Oi){const t=Sl(e),i=Dd(e,"Žg");n=(isNaN(Number(t.lineHeight))?1.2:Number(t.lineHeight))*(i.actualBoundingBoxAscent+i.actualBoundingBoxDescent)}else t||(t=document.createElement("div"),t.innerHTML="M",t.style.minHeight="0",t.style.maxHeight="none",t.style.height="auto",t.style.padding="0",t.style.border="none",t.style.position="absolute",t.style.display="block",t.style.left="-99999px"),t.style.font=e,document.body.appendChild(t),n=t.offsetHeight,document.body.removeChild(t);Md[e]=n}return n}}();function Dd(t,e){return Fd||(Fd=Cl(1,1)),t!=Rd&&(Fd.font=t,Rd=Fd.font),Fd.measureText(e)}function Od(t,e){return Dd(t,e).width}function zd(t,e,n){if(e in n)return n[e];const i=e.split("\n").reduce((e,n)=>Math.max(e,Od(t,n)),0);return n[e]=i,i}function Nd(t,e,n,i,r,s,o,a,l,h,c){t.save(),1!==n&&(void 0===t.globalAlpha?t.globalAlpha=t=>t.globalAlpha*=n:t.globalAlpha*=n),e&&t.transform.apply(t,e),i.contextInstructions?(t.translate(l,h),t.scale(c[0],c[1]),function(t,e){const n=t.contextInstructions;for(let t=0,i=n.length;t<i;t+=2)Array.isArray(n[t+1])?e[n[t]].apply(e,n[t+1]):e[n[t]]=n[t+1]}(i,t)):c[0]<0||c[1]<0?(t.translate(l,h),t.scale(c[0],c[1]),t.drawImage(i,r,s,o,a,0,0,o,a)):t.drawImage(i,r,s,o,a,l,h,o*c[0],a*c[1]),t.restore()}class jd{constructor(t){this.opacity_=t.opacity,this.rotateWithView_=t.rotateWithView,this.rotation_=t.rotation,this.scale_=t.scale,this.scaleArray_=Lc(t.scale),this.displacement_=t.displacement,this.declutterMode_=t.declutterMode}clone(){const t=this.getScale();return new jd({opacity:this.getOpacity(),scale:Array.isArray(t)?t.slice():t,rotation:this.getRotation(),rotateWithView:this.getRotateWithView(),displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()})}getOpacity(){return this.opacity_}getRotateWithView(){return this.rotateWithView_}getRotation(){return this.rotation_}getScale(){return this.scale_}getScaleArray(){return this.scaleArray_}getDisplacement(){return this.displacement_}getDeclutterMode(){return this.declutterMode_}getAnchor(){return vi()}getImage(t){return vi()}getHitDetectionImage(){return vi()}getPixelRatio(t){return 1}getImageState(){return vi()}getImageSize(){return vi()}getOrigin(){return vi()}getSize(){return vi()}setDisplacement(t){this.displacement_=t}setOpacity(t){this.opacity_=t}setRotateWithView(t){this.rotateWithView_=t}setRotation(t){this.rotation_=t}setScale(t){this.scale_=t,this.scaleArray_=Lc(t)}listenImageChange(t){vi()}load(){vi()}unlistenImageChange(t){vi()}ready(){return Promise.resolve()}}class Gd extends jd{constructor(t){super({opacity:1,rotateWithView:void 0!==t.rotateWithView&&t.rotateWithView,rotation:void 0!==t.rotation?t.rotation:0,scale:void 0!==t.scale?t.scale:1,displacement:void 0!==t.displacement?t.displacement:[0,0],declutterMode:t.declutterMode}),this.hitDetectionCanvas_=null,this.fill_=void 0!==t.fill?t.fill:null,this.origin_=[0,0],this.points_=t.points,this.radius=t.radius,this.radius2_=t.radius2,this.angle_=void 0!==t.angle?t.angle:0,this.stroke_=void 0!==t.stroke?t.stroke:null,this.size_,this.renderOptions_,this.imageState_=this.fill_&&this.fill_.loading()?sd:od,this.imageState_===sd&&this.ready().then(()=>this.imageState_=od),this.render()}clone(){const t=this.getScale(),e=new Gd({fill:this.getFill()?this.getFill().clone():void 0,points:this.getPoints(),radius:this.getRadius(),radius2:this.getRadius2(),angle:this.getAngle(),stroke:this.getStroke()?this.getStroke().clone():void 0,rotation:this.getRotation(),rotateWithView:this.getRotateWithView(),scale:Array.isArray(t)?t.slice():t,displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()});return e.setOpacity(this.getOpacity()),e}getAnchor(){const t=this.size_,e=this.getDisplacement(),n=this.getScaleArray();return[t[0]/2-e[0]/n[0],t[1]/2+e[1]/n[1]]}getAngle(){return this.angle_}getFill(){return this.fill_}setFill(t){this.fill_=t,this.render()}getHitDetectionImage(){return this.hitDetectionCanvas_||(this.hitDetectionCanvas_=this.createHitDetectionCanvas_(this.renderOptions_)),this.hitDetectionCanvas_}getImage(t){const e=this.fill_?.getKey(),n=`${t},${this.angle_},${this.radius},${this.radius2_},${this.points_},${e}`+Object.values(this.renderOptions_).join(",");let i=fd.get(n,null)?.getImage(1);if(!i){const e=this.renderOptions_,r=Math.ceil(e.size*t),s=Cl(r,r);this.draw_(e,s,t),i=s.canvas;const o=new pd(i,void 0,null,od,null);fd.set(n,null,o),createImageBitmap(i).then(t=>{o.setImage(t)})}return i}getPixelRatio(t){return t}getImageSize(){return this.size_}getImageState(){return this.imageState_}getOrigin(){return this.origin_}getPoints(){return this.points_}getRadius(){return this.radius}setRadius(t){this.radius!==t&&(this.radius=t,this.render())}getRadius2(){return this.radius2_}setRadius2(t){this.radius2_!==t&&(this.radius2_=t,this.render())}getSize(){return this.size_}getStroke(){return this.stroke_}setStroke(t){this.stroke_=t,this.render()}listenImageChange(t){}load(){}unlistenImageChange(t){}calculateLineJoinSize_(t,e,n){if(0===e||this.points_===1/0||"bevel"!==t&&"miter"!==t)return e;let i=this.radius,r=void 0===this.radius2_?i:this.radius2_;if(i<r){const t=i;i=r,r=t}const s=void 0===this.radius2_?this.points_:2*this.points_,o=2*Math.PI/s,a=r*Math.sin(o),l=i-Math.sqrt(r*r-a*a),h=Math.sqrt(a*a+l*l),c=h/a;if("miter"===t&&c<=n)return c*e;const u=e/2/c,d=e/2*(l/h),f=Math.sqrt((i+u)*(i+u)+d*d)-i;if(void 0===this.radius2_||"bevel"===t)return 2*f;const g=i*Math.sin(o),p=r-Math.sqrt(i*i-g*g),m=Math.sqrt(g*g+p*p)/g;if(m<=n){const t=m*e/2-r-i;return 2*Math.max(f,t)}return 2*f}createRenderOptions(){let t,e=vd,n=wd,i=0,r=null,s=0,o=0;this.stroke_&&(t=_d(this.stroke_.getColor()??Sd),o=this.stroke_.getWidth()??1,r=this.stroke_.getLineDash(),s=this.stroke_.getLineDashOffset()??0,n=this.stroke_.getLineJoin()??wd,e=this.stroke_.getLineCap()??vd,i=this.stroke_.getMiterLimit()??10);const a=this.calculateLineJoinSize_(n,o,i),l=Math.max(this.radius,this.radius2_||0);return{strokeStyle:t,strokeWidth:o,size:Math.ceil(2*l+a),lineCap:e,lineDash:r,lineDashOffset:s,lineJoin:n,miterLimit:i}}render(){this.renderOptions_=this.createRenderOptions();const t=this.renderOptions_.size;this.hitDetectionCanvas_=null,this.size_=[t,t]}draw_(t,e,n){if(e.scale(n,n),e.translate(t.size/2,t.size/2),this.createPath_(e),this.fill_){let t=this.fill_.getColor();null===t&&(t=xd),e.fillStyle=_d(t),e.fill()}t.strokeStyle&&(e.strokeStyle=t.strokeStyle,e.lineWidth=t.strokeWidth,t.lineDash&&(e.setLineDash(t.lineDash),e.lineDashOffset=t.lineDashOffset),e.lineCap=t.lineCap,e.lineJoin=t.lineJoin,e.miterLimit=t.miterLimit,e.stroke())}createHitDetectionCanvas_(t){let e;if(this.fill_){let n=this.fill_.getColor(),i=0;"string"==typeof n&&(n=Mc(n)),null===n?i=1:Array.isArray(n)&&(i=4===n.length?n[3]:1),0===i&&(e=Cl(t.size,t.size),this.drawHitDetectionCanvas_(t,e))}return e?e.canvas:this.getImage(1)}createPath_(t){let e=this.points_;const n=this.radius;if(e===1/0)t.arc(0,0,n,0,2*Math.PI);else{const i=void 0===this.radius2_?n:this.radius2_;void 0!==this.radius2_&&(e*=2);const r=this.angle_-Math.PI/2,s=2*Math.PI/e;for(let o=0;o<e;o++){const e=r+o*s,a=o%2==0?n:i;t.lineTo(a*Math.cos(e),a*Math.sin(e))}t.closePath()}}drawHitDetectionCanvas_(t,e){e.translate(t.size/2,t.size/2),this.createPath_(e),e.fillStyle=xd,e.fill(),t.strokeStyle&&(e.strokeStyle=t.strokeStyle,e.lineWidth=t.strokeWidth,t.lineDash&&(e.setLineDash(t.lineDash),e.lineDashOffset=t.lineDashOffset),e.lineJoin=t.lineJoin,e.miterLimit=t.miterLimit,e.stroke())}ready(){return this.fill_?this.fill_.ready():Promise.resolve()}}class $d extends Gd{constructor(t){super({points:1/0,fill:(t=t||{radius:5}).fill,radius:t.radius,stroke:t.stroke,scale:void 0!==t.scale?t.scale:1,rotation:void 0!==t.rotation?t.rotation:0,rotateWithView:void 0!==t.rotateWithView&&t.rotateWithView,displacement:void 0!==t.displacement?t.displacement:[0,0],declutterMode:t.declutterMode})}clone(){const t=this.getScale(),e=new $d({fill:this.getFill()?this.getFill().clone():void 0,stroke:this.getStroke()?this.getStroke().clone():void 0,radius:this.getRadius(),scale:Array.isArray(t)?t.slice():t,rotation:this.getRotation(),rotateWithView:this.getRotateWithView(),displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()});return e.setOpacity(this.getOpacity()),e}}class Bd{constructor(t){t=t||{},this.patternImage_=null,this.color_=null,void 0!==t.color&&this.setColor(t.color)}clone(){const t=this.getColor();return new Bd({color:Array.isArray(t)?t.slice():t||void 0})}getColor(){return this.color_}setColor(t){if(null!==t&&"object"==typeof t&&"src"in t){const e=md(null,t.src,{crossOrigin:"anonymous"},void 0,t.offset?null:t.color?t.color:null,!(t.offset&&t.size));e.ready().then(()=>{this.patternImage_=null}),e.getImageState()===rd&&e.load(),e.getImageState()===sd&&(this.patternImage_=e)}this.color_=t}getKey(){const t=this.getColor();return t?t instanceof CanvasPattern||t instanceof CanvasGradient?wi(t):"object"==typeof t&&"src"in t?t.src+":"+t.offset:Mc(t).toString():""}loading(){return!!this.patternImage_}ready(){return this.patternImage_?this.patternImage_.ready():Promise.resolve()}}function Ud(t,e,n,i){return void 0!==n&&void 0!==i?[n/t,i/e]:void 0!==n?n/t:void 0!==i?i/e:1}class Vd extends jd{constructor(t){const e=void 0!==(t=t||{}).opacity?t.opacity:1,n=void 0!==t.rotation?t.rotation:0,i=void 0!==t.scale?t.scale:1,r=void 0!==t.rotateWithView&&t.rotateWithView;super({opacity:e,rotation:n,scale:i,displacement:void 0!==t.displacement?t.displacement:[0,0],rotateWithView:r,declutterMode:t.declutterMode}),this.anchor_=void 0!==t.anchor?t.anchor:[.5,.5],this.normalizedAnchor_=null,this.anchorOrigin_=void 0!==t.anchorOrigin?t.anchorOrigin:"top-left",this.anchorXUnits_=void 0!==t.anchorXUnits?t.anchorXUnits:"fraction",this.anchorYUnits_=void 0!==t.anchorYUnits?t.anchorYUnits:"fraction",this.crossOrigin_=void 0!==t.crossOrigin?t.crossOrigin:null,this.referrerPolicy_=t.referrerPolicy;const s=void 0!==t.img?t.img:null;let o,a=t.src;if(ir(!(void 0!==a&&s),"`image` and `src` cannot be provided at the same time"),void 0!==a&&0!==a.length||!s||(a=s.src||wi(s)),ir(void 0!==a&&a.length>0,"A defined and non-empty `src` or `image` must be provided"),ir(!((void 0!==t.width||void 0!==t.height)&&void 0!==t.scale),"`width` or `height` cannot be provided together with `scale`"),void 0!==t.src?o=rd:void 0!==s&&(o="complete"in s?s.complete?s.src?od:rd:sd:od),this.color_=void 0!==t.color?Mc(t.color):null,this.iconImage_=md(s,a,{crossOrigin:this.crossOrigin_,referrerPolicy:this.referrerPolicy_},o,this.color_),this.offset_=void 0!==t.offset?t.offset:[0,0],this.offsetOrigin_=void 0!==t.offsetOrigin?t.offsetOrigin:"top-left",this.origin_=null,this.size_=void 0!==t.size?t.size:null,this.initialOptions_,void 0!==t.width||void 0!==t.height){let e,n;if(t.size)[e,n]=t.size;else{const i=this.getImage(1);if(i.width&&i.height)e=i.width,n=i.height;else if(i instanceof HTMLImageElement){this.initialOptions_=t;const e=()=>{if(this.unlistenImageChange(e),!this.initialOptions_)return;const n=this.iconImage_.getSize();this.setScale(Ud(n[0],n[1],t.width,t.height))};return void this.listenImageChange(e)}}void 0!==e&&this.setScale(Ud(e,n,t.width,t.height))}}clone(){let t,e,n;return this.initialOptions_?(e=this.initialOptions_.width,n=this.initialOptions_.height):(t=this.getScale(),t=Array.isArray(t)?t.slice():t),new Vd({anchor:this.anchor_.slice(),anchorOrigin:this.anchorOrigin_,anchorXUnits:this.anchorXUnits_,anchorYUnits:this.anchorYUnits_,color:this.color_&&this.color_.slice?this.color_.slice():this.color_||void 0,crossOrigin:this.crossOrigin_,referrerPolicy:this.referrerPolicy_,offset:this.offset_.slice(),offsetOrigin:this.offsetOrigin_,opacity:this.getOpacity(),rotateWithView:this.getRotateWithView(),rotation:this.getRotation(),scale:t,width:e,height:n,size:null!==this.size_?this.size_.slice():void 0,src:this.getSrc(),displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()})}getAnchor(){let t=this.normalizedAnchor_;if(!t){t=this.anchor_;const e=this.getSize();if("fraction"==this.anchorXUnits_||"fraction"==this.anchorYUnits_){if(!e)return null;t=this.anchor_.slice(),"fraction"==this.anchorXUnits_&&(t[0]*=e[0]),"fraction"==this.anchorYUnits_&&(t[1]*=e[1])}if("top-left"!=this.anchorOrigin_){if(!e)return null;t===this.anchor_&&(t=this.anchor_.slice()),"top-right"!=this.anchorOrigin_&&"bottom-right"!=this.anchorOrigin_||(t[0]=-t[0]+e[0]),"bottom-left"!=this.anchorOrigin_&&"bottom-right"!=this.anchorOrigin_||(t[1]=-t[1]+e[1])}this.normalizedAnchor_=t}const e=this.getDisplacement(),n=this.getScaleArray();return[t[0]-e[0]/n[0],t[1]+e[1]/n[1]]}setAnchor(t){this.anchor_=t,this.normalizedAnchor_=null}getColor(){return this.color_}setColor(t){const e=t?Mc(t):null;if(this.color_===e||this.color_&&e&&this.color_.length===e.length&&this.color_.every((t,n)=>t===e[n]))return;this.color_=e;const n=this.getSrc(),i=void 0!==n?null:this.getHitDetectionImage(),r=void 0!==n?rd:this.iconImage_.getImageState();this.iconImage_=md(i,n,{crossOrigin:this.crossOrigin_,referrerPolicy:this.referrerPolicy_},r,this.color_)}getImage(t){return this.iconImage_.getImage(t)}getPixelRatio(t){return this.iconImage_.getPixelRatio(t)}getImageSize(){return this.iconImage_.getSize()}getImageState(){return this.iconImage_.getImageState()}getHitDetectionImage(){return this.iconImage_.getHitDetectionImage()}getOrigin(){if(this.origin_)return this.origin_;let t=this.offset_;if("top-left"!=this.offsetOrigin_){const e=this.getSize(),n=this.iconImage_.getSize();if(!e||!n)return null;t=t.slice(),"top-right"!=this.offsetOrigin_&&"bottom-right"!=this.offsetOrigin_||(t[0]=n[0]-e[0]-t[0]),"bottom-left"!=this.offsetOrigin_&&"bottom-right"!=this.offsetOrigin_||(t[1]=n[1]-e[1]-t[1])}return this.origin_=t,this.origin_}getSrc(){return this.iconImage_.getSrc()}setSrc(t){this.iconImage_=md(null,t,{crossOrigin:this.crossOrigin_,referrerPolicy:this.referrerPolicy_},rd,this.color_)}getSize(){return this.size_?this.size_:this.iconImage_.getSize()}getWidth(){const t=this.getScaleArray();return this.size_?this.size_[0]*t[0]:this.iconImage_.getImageState()==od?this.iconImage_.getSize()[0]*t[0]:void 0}getHeight(){const t=this.getScaleArray();return this.size_?this.size_[1]*t[1]:this.iconImage_.getImageState()==od?this.iconImage_.getSize()[1]*t[1]:void 0}setScale(t){delete this.initialOptions_,super.setScale(t)}listenImageChange(t){this.iconImage_.addEventListener(Vn,t)}load(){this.iconImage_.load()}unlistenImageChange(t){this.iconImage_.removeEventListener(Vn,t)}ready(){return this.iconImage_.ready()}}class Xd{constructor(t){t=t||{},this.color_=void 0!==t.color?t.color:null,this.lineCap_=t.lineCap,this.lineDash_=void 0!==t.lineDash?t.lineDash:null,this.lineDashOffset_=t.lineDashOffset,this.lineJoin_=t.lineJoin,this.miterLimit_=t.miterLimit,this.offset_=t.offset,this.width_=t.width}clone(){const t=this.getColor();return new Xd({color:Array.isArray(t)?t.slice():t||void 0,lineCap:this.getLineCap(),lineDash:this.getLineDash()?this.getLineDash().slice():void 0,lineDashOffset:this.getLineDashOffset(),lineJoin:this.getLineJoin(),miterLimit:this.getMiterLimit(),offset:this.getOffset(),width:this.getWidth()})}getColor(){return this.color_}getLineCap(){return this.lineCap_}getLineDash(){return this.lineDash_}getLineDashOffset(){return this.lineDashOffset_}getLineJoin(){return this.lineJoin_}getMiterLimit(){return this.miterLimit_}getOffset(){return this.offset_}getWidth(){return this.width_}setColor(t){this.color_=t}setLineCap(t){this.lineCap_=t}setLineDash(t){this.lineDash_=t}setLineDashOffset(t){this.lineDashOffset_=t}setLineJoin(t){this.lineJoin_=t}setMiterLimit(t){this.miterLimit_=t}setOffset(t){this.offset_=t}setWidth(t){this.width_=t}}class Wd{constructor(t){t=t||{},this.geometry_=null,this.geometryFunction_=Yd,void 0!==t.geometry&&this.setGeometry(t.geometry),this.fill_=void 0!==t.fill?t.fill:null,this.image_=void 0!==t.image?t.image:null,this.renderer_=void 0!==t.renderer?t.renderer:null,this.hitDetectionRenderer_=void 0!==t.hitDetectionRenderer?t.hitDetectionRenderer:null,this.stroke_=void 0!==t.stroke?t.stroke:null,this.text_=void 0!==t.text?t.text:null,this.zIndex_=t.zIndex}clone(){let t=this.getGeometry();return t&&"object"==typeof t&&(t=t.clone()),new Wd({geometry:t??void 0,fill:this.getFill()?this.getFill().clone():void 0,image:this.getImage()?this.getImage().clone():void 0,renderer:this.getRenderer()??void 0,stroke:this.getStroke()?this.getStroke().clone():void 0,text:this.getText()?this.getText().clone():void 0,zIndex:this.getZIndex()})}getRenderer(){return this.renderer_}setRenderer(t){this.renderer_=t}setHitDetectionRenderer(t){this.hitDetectionRenderer_=t}getHitDetectionRenderer(){return this.hitDetectionRenderer_}getGeometry(){return this.geometry_}getGeometryFunction(){return this.geometryFunction_}getFill(){return this.fill_}setFill(t){this.fill_=t}getImage(){return this.image_}setImage(t){this.image_=t}getStroke(){return this.stroke_}setStroke(t){this.stroke_=t}getText(){return this.text_}setText(t){this.text_=t}getZIndex(){return this.zIndex_}setGeometry(t){"function"==typeof t?this.geometryFunction_=t:"string"==typeof t?this.geometryFunction_=function(e){return e.get(t)}:t?void 0!==t&&(this.geometryFunction_=function(){return t}):this.geometryFunction_=Yd,this.geometry_=t}setZIndex(t){this.zIndex_=t}}let qd=null;function Zd(t,e){if(!qd){const t=new Bd({color:"rgba(255,255,255,0.4)"}),e=new Xd({color:"#3399CC",width:1.25});qd=[new Wd({image:new $d({fill:t,stroke:e,radius:5}),fill:t,stroke:e})]}return qd}function Kd(){const t={},e=[255,255,255,1],n=[0,153,255,1];return t.Polygon=[new Wd({fill:new Bd({color:[255,255,255,.5]})})],t.MultiPolygon=t.Polygon,t.LineString=[new Wd({stroke:new Xd({color:e,width:5})}),new Wd({stroke:new Xd({color:n,width:3})})],t.MultiLineString=t.LineString,t.Circle=t.Polygon.concat(t.LineString),t.Point=[new Wd({image:new $d({radius:6,fill:new Bd({color:n}),stroke:new Xd({color:e,width:1.5})}),zIndex:1/0})],t.MultiPoint=t.Point,t.GeometryCollection=t.Polygon.concat(t.LineString,t.Point),t}function Yd(t){return t.getGeometry()}class Hd{constructor(t){t=t||{},this.font_=t.font,this.rotation_=t.rotation,this.rotateWithView_=t.rotateWithView,this.keepUpright_=t.keepUpright,this.scale_=t.scale,this.scaleArray_=Lc(void 0!==t.scale?t.scale:1),this.text_=t.text,this.textAlign_=t.textAlign,this.justify_=t.justify,this.repeat_=t.repeat,this.textBaseline_=t.textBaseline,this.fill_=void 0!==t.fill?t.fill:new Bd({color:"#333"}),this.maxAngle_=void 0!==t.maxAngle?t.maxAngle:Math.PI/4,this.placement_=void 0!==t.placement?t.placement:"point",this.overflow_=!!t.overflow,this.stroke_=void 0!==t.stroke?t.stroke:null,this.offsetX_=void 0!==t.offsetX?t.offsetX:0,this.offsetY_=void 0!==t.offsetY?t.offsetY:0,this.backgroundFill_=t.backgroundFill?t.backgroundFill:null,this.backgroundStroke_=t.backgroundStroke?t.backgroundStroke:null,this.padding_=void 0===t.padding?null:t.padding,this.declutterMode_=t.declutterMode}clone(){const t=this.getScale();return new Hd({font:this.getFont(),placement:this.getPlacement(),repeat:this.getRepeat(),maxAngle:this.getMaxAngle(),overflow:this.getOverflow(),rotation:this.getRotation(),rotateWithView:this.getRotateWithView(),keepUpright:this.getKeepUpright(),scale:Array.isArray(t)?t.slice():t,text:this.getText(),textAlign:this.getTextAlign(),justify:this.getJustify(),textBaseline:this.getTextBaseline(),fill:this.getFill()instanceof Bd?this.getFill().clone():this.getFill(),stroke:this.getStroke()?this.getStroke().clone():void 0,offsetX:this.getOffsetX(),offsetY:this.getOffsetY(),backgroundFill:this.getBackgroundFill()?this.getBackgroundFill().clone():void 0,backgroundStroke:this.getBackgroundStroke()?this.getBackgroundStroke().clone():void 0,padding:this.getPadding()||void 0,declutterMode:this.getDeclutterMode()})}getOverflow(){return this.overflow_}getFont(){return this.font_}getMaxAngle(){return this.maxAngle_}getPlacement(){return this.placement_}getRepeat(){return this.repeat_}getOffsetX(){return this.offsetX_}getOffsetY(){return this.offsetY_}getFill(){return this.fill_}getRotateWithView(){return this.rotateWithView_}getKeepUpright(){return this.keepUpright_}getRotation(){return this.rotation_}getScale(){return this.scale_}getScaleArray(){return this.scaleArray_}getStroke(){return this.stroke_}getText(){return this.text_}getTextAlign(){return this.textAlign_}getJustify(){return this.justify_}getTextBaseline(){return this.textBaseline_}getBackgroundFill(){return this.backgroundFill_}getBackgroundStroke(){return this.backgroundStroke_}getPadding(){return this.padding_}getDeclutterMode(){return this.declutterMode_}setOverflow(t){this.overflow_=t}setFont(t){this.font_=t}setMaxAngle(t){this.maxAngle_=t}setOffsetX(t){this.offsetX_=t}setOffsetY(t){this.offsetY_=t}setPlacement(t){this.placement_=t}setRepeat(t){this.repeat_=t}setRotateWithView(t){this.rotateWithView_=t}setKeepUpright(t){this.keepUpright_=t}setFill(t){this.fill_=t}setRotation(t){this.rotation_=t}setScale(t){this.scale_=t,this.scaleArray_=Lc(void 0!==t?t:1)}setStroke(t){this.stroke_=t}setText(t){this.text_=t}setTextAlign(t){this.textAlign_=t}setJustify(t){this.justify_=t}setTextBaseline(t){this.textBaseline_=t}setBackgroundFill(t){this.backgroundFill_=t}setBackgroundStroke(t){this.backgroundStroke_=t}setPadding(t){this.padding_=t}}function Jd(t){return!0}function Qd(t){const e=Kc(),n=function(t,e){const n=t.length,i=new Array(n);for(let r=0;r<n;++r){const n=t[r],s="filter"in n?td(n.filter,Dc,e):Jd;let o;if(Array.isArray(n.style)){const t=n.style.length;o=new Array(t);for(let i=0;i<t;++i)o[i]=ef(n.style[i],e)}else o=[ef(n.style,e)];i[r]={filter:s,styles:o}}return function(e){const r=[];let s=!1;for(let o=0;o<n;++o){if((0,i[o].filter)(e)&&(!t[o].else||!s)){s=!0;for(const t of i[o].styles){const n=t(e);n&&r.push(n)}}}return r}}(t,e),i={variables:{},properties:{},resolution:NaN,featureId:null,geometryType:""};return function(t,r){if(i.properties=t.getPropertiesInternal(),i.resolution=r,e.featureId){const e=t.getId();i.featureId=void 0!==e?e:null}return e.geometryType&&(i.geometryType=Qu(t.getGeometry())),n(i)}}function tf(t){const e=Kc(),n=t.length,i=new Array(n);for(let r=0;r<n;++r)i[r]=ef(t[r],e);const r={variables:{},properties:{},resolution:NaN,featureId:null,geometryType:""},s=new Array(n);return function(t,o){if(r.properties=t.getPropertiesInternal(),r.resolution=o,e.featureId){const e=t.getId();r.featureId=void 0!==e?e:null}let a=0;for(let t=0;t<n;++t){const e=i[t](r);e&&(s[a]=e,a+=1)}return s.length=a,s}}function ef(t,e){const n=nf(t,"",e),i=rf(t,"",e),r=function(t,e){const n="text-",i=af(t,n+"value",e);if(!i)return null;const r=nf(t,n,e),s=nf(t,n+"background-",e),o=rf(t,n,e),a=rf(t,n+"background-",e),l=af(t,n+"font",e),h=of(t,n+"max-angle",e),c=of(t,n+"offset-x",e),u=of(t,n+"offset-y",e),d=lf(t,n+"overflow",e),f=af(t,n+"placement",e),g=of(t,n+"repeat",e),p=ff(t,n+"scale",e),m=lf(t,n+"rotate-with-view",e),_=of(t,n+"rotation",e),y=af(t,n+"align",e),x=af(t,n+"justify",e),v=af(t,n+"baseline",e),b=lf(t,n+"keep-upright",e),w=cf(t,n+"padding",e),S=_f(t,n+"declutter-mode"),C=new Hd({declutterMode:S});return function(t){if(C.setText(i(t)),r&&C.setFill(r(t)),s&&C.setBackgroundFill(s(t)),o&&C.setStroke(o(t)),a&&C.setBackgroundStroke(a(t)),l&&C.setFont(l(t)),h&&C.setMaxAngle(h(t)),c&&C.setOffsetX(c(t)),u&&C.setOffsetY(u(t)),d&&C.setOverflow(d(t)),f){const e=f(t);if("point"!==e&&"line"!==e)throw new Error("Expected point or line for text-placement");C.setPlacement(e)}if(g&&C.setRepeat(g(t)),p&&C.setScale(p(t)),m&&C.setRotateWithView(m(t)),_&&C.setRotation(_(t)),y){const e=y(t);if("left"!==e&&"center"!==e&&"right"!==e&&"end"!==e&&"start"!==e)throw new Error("Expected left, right, center, start, or end for text-align");C.setTextAlign(e)}if(x){const e=x(t);if("left"!==e&&"right"!==e&&"center"!==e)throw new Error("Expected left, right, or center for text-justify");C.setJustify(e)}if(v){const e=v(t);if("bottom"!==e&&"top"!==e&&"middle"!==e&&"alphabetic"!==e&&"hanging"!==e)throw new Error("Expected bottom, top, middle, alphabetic, or hanging for text-baseline");C.setTextBaseline(e)}return w&&C.setPadding(w(t)),b&&C.setKeepUpright(b(t)),C}}(t,e),s=function(t,e){if("icon-src"in t)return function(t,e){const n="icon-",i=n+"src",r=xf(t[i],i),s=uf(t,n+"anchor",e),o=ff(t,n+"scale",e),a=of(t,n+"opacity",e),l=uf(t,n+"displacement",e),h=of(t,n+"rotation",e),c=lf(t,n+"rotate-with-view",e),u=pf(t,n+"anchor-origin"),d=mf(t,n+"anchor-x-units"),f=mf(t,n+"anchor-y-units"),g=sf(t,n+"color");let p,m=null;if(void 0!==g){Array.isArray(g)&&g.length>0&&"string"==typeof g[0]?m=hf(t,n+"color",e):p=bf(g,n+"color")}const _=function(t,e){const n=t[e];if(void 0===n)return;if("string"!=typeof n)throw new Error(`Expected a string for ${e}`);return n}(t,n+"cross-origin"),y=function(t,e){const n=t[e];if(void 0===n)return;return yf(n,e)}(t,n+"offset"),x=pf(t,n+"offset-origin"),v=gf(t,n+"width"),b=gf(t,n+"height"),w=function(t,e){const n=t[e];if(void 0===n)return;if("number"==typeof n)return Lc(n);if(!Array.isArray(n))throw new Error(`Expected a number or size array for ${e}`);if(2!==n.length||"number"!=typeof n[0]||"number"!=typeof n[1])throw new Error(`Expected a number or size array for ${e}`);return n}(t,n+"size"),S=_f(t,n+"declutter-mode"),C={src:r,anchorOrigin:u,anchorXUnits:d,anchorYUnits:f,crossOrigin:_,offset:y,offsetOrigin:x,height:b,width:v,size:w,declutterMode:S};let E=null;return function(t){if(E)m&&E.setColor(m(t));else{const e=m?m(t):p;E=new Vd(void 0!==e?Object.assign({},C,{color:e}):Object.assign({},C))}return a&&E.setOpacity(a(t)),l&&E.setDisplacement(l(t)),h&&E.setRotation(h(t)),c&&E.setRotateWithView(c(t)),o&&E.setScale(o(t)),s&&E.setAnchor(s(t)),E}}(t,e);if("shape-points"in t)return function(t,e){const n="shape-",i=n+"points",r=n+"radius",s=vf(t[i],i);if(!(r in t))throw new Error(`Expected a number for ${r}`);const o=of(t,r,e),a="number"==typeof t[r]?t[r]:5,l=n+"radius2",h=of(t,l,e),c="number"==typeof t[l]?t[l]:void 0,u=nf(t,n,e),d=rf(t,n,e),f=ff(t,n+"scale",e),g=uf(t,n+"displacement",e),p=of(t,n+"rotation",e),m=lf(t,n+"rotate-with-view",e),_=gf(t,n+"angle"),y=_f(t,n+"declutter-mode"),x=new Gd({points:s,radius:a,radius2:c,angle:_,declutterMode:y});return function(t){return o&&x.setRadius(o(t)),h&&x.setRadius2(h(t)),u&&x.setFill(u(t)),d&&x.setStroke(d(t)),g&&x.setDisplacement(g(t)),p&&x.setRotation(p(t)),m&&x.setRotateWithView(m(t)),f&&x.setScale(f(t)),x}}(t,e);if("circle-radius"in t)return function(t,e){const n="circle-",i=nf(t,n,e),r=rf(t,n,e),s=of(t,n+"radius",e),o=ff(t,n+"scale",e),a=uf(t,n+"displacement",e),l=of(t,n+"rotation",e),h=lf(t,n+"rotate-with-view",e),c=_f(t,n+"declutter-mode"),u=new $d({radius:5,declutterMode:c});return function(t){return s&&u.setRadius(s(t)),i&&u.setFill(i(t)),r&&u.setStroke(r(t)),a&&u.setDisplacement(a(t)),l&&u.setRotation(l(t)),h&&u.setRotateWithView(h(t)),o&&u.setScale(o(t)),u}}(t,e);return null}(t,e),o=of(t,"z-index",e);if(!(n||i||r||s||Gn(t)))throw new Error("No fill, stroke, point, or text symbolizer properties in style: "+JSON.stringify(t));const a=new Wd;return function(t){let e=!0;if(n){const i=n(t);i&&(e=!1),a.setFill(i)}if(i){const n=i(t);n&&(e=!1),a.setStroke(n)}if(r){const n=r(t);n&&(e=!1),a.setText(n)}if(s){const n=s(t);n&&(e=!1),a.setImage(n)}return o&&a.setZIndex(o(t)),e?null:a}}function nf(t,e,n){let i;if(e+"fill-pattern-src"in t)i=function(t,e,n){const i=af(t,e+"pattern-src",n),r=df(t,e+"pattern-offset",n),s=df(t,e+"pattern-size",n),o=hf(t,e+"color",n);return function(t){return{src:i(t),offset:r&&r(t),size:s&&s(t),color:o&&o(t)}}}(t,e+"fill-",n);else{if("none"===t[e+"fill-color"])return t=>null;i=hf(t,e+"fill-color",n)}if(!i)return null;const r=new Bd;return function(t){const e=i(t);return e===dc?null:(r.setColor(e),r)}}function rf(t,e,n){const i=of(t,e+"stroke-width",n),r=hf(t,e+"stroke-color",n);if(!i&&!r)return null;const s=af(t,e+"stroke-line-cap",n),o=af(t,e+"stroke-line-join",n),a=cf(t,e+"stroke-line-dash",n),l=of(t,e+"stroke-line-dash-offset",n),h=of(t,e+"stroke-miter-limit",n),c=of(t,e+"stroke-offset",n),u=new Xd;return function(t){if(r){const e=r(t);if(e===dc)return null;u.setColor(e)}if(i&&u.setWidth(i(t)),s){const e=s(t);if("butt"!==e&&"round"!==e&&"square"!==e)throw new Error("Expected butt, round, or square line cap");u.setLineCap(e)}if(o){const e=o(t);if("bevel"!==e&&"round"!==e&&"miter"!==e)throw new Error("Expected bevel, round, or miter line join");u.setLineJoin(e)}return a&&u.setLineDash(a(t)),l&&u.setLineDashOffset(l(t)),h&&u.setMiterLimit(h(t)),c&&u.setOffset(c(t)),u}}function sf(t,e){if(!(e in t))return;const n=t[e];return void 0===n?void 0:n}function of(t,e,n){const i=sf(t,e);if(void 0===i)return;const r=td(i,Oc,n);return function(t){return vf(r(t),e)}}function af(t,e,n){const i=sf(t,e);if(void 0===i)return null;const r=td(i,zc,n);return function(t){return xf(r(t),e)}}function lf(t,e,n){const i=sf(t,e);if(void 0===i)return null;const r=td(i,Dc,n);return function(t){const n=r(t);if("boolean"!=typeof n)throw new Error(`Expected a boolean for ${e}`);return n}}function hf(t,e,n){const i=sf(t,e);if(void 0===i)return null;const r=td(i,Nc,n);return function(t){return bf(r(t),e)}}function cf(t,e,n){const i=sf(t,e);if(void 0===i)return null;if(Array.isArray(i)&&(0===i.length||"string"!=typeof i[0])){const t=i.map((t,i)=>{if("number"==typeof t)return()=>t;const r=td(t,Oc,n);return function(t){return vf(r(t),`${e}[${i}]`)}});return function(e){const n=new Array(t.length);for(let i=0;i<t.length;++i)n[i]=t[i](e);return n}}const r=td(i,jc,n);return function(t){return yf(r(t),e)}}function uf(t,e,n){const i=sf(t,e);if(void 0===i)return null;const r=td(i,jc,n);return function(t){const n=yf(r(t),e);if(2!==n.length)throw new Error(`Expected two numbers for ${e}`);return n}}function df(t,e,n){const i=sf(t,e);if(void 0===i)return null;const r=td(i,jc,n);return function(t){return wf(r(t),e)}}function ff(t,e,n){const i=sf(t,e);if(void 0===i)return null;const r=td(i,jc|Oc,n);return function(t){return function(t,e){if("number"==typeof t)return t;return wf(t,e)}(r(t),e)}}function gf(t,e){const n=t[e];if(void 0!==n){if("number"!=typeof n)throw new Error(`Expected a number for ${e}`);return n}}function pf(t,e){const n=t[e];if(void 0!==n){if("bottom-left"!==n&&"bottom-right"!==n&&"top-left"!==n&&"top-right"!==n)throw new Error(`Expected bottom-left, bottom-right, top-left, or top-right for ${e}`);return n}}function mf(t,e){const n=t[e];if(void 0!==n){if("pixels"!==n&&"fraction"!==n)throw new Error(`Expected pixels or fraction for ${e}`);return n}}function _f(t,e){const n=t[e];if(void 0!==n){if("string"!=typeof n)throw new Error(`Expected a string for ${e}`);if("declutter"!==n&&"obstacle"!==n&&"none"!==n)throw new Error(`Expected declutter, obstacle, or none for ${e}`);return n}}function yf(t,e){if(!Array.isArray(t))throw new Error(`Expected an array for ${e}`);const n=t.length;for(let i=0;i<n;++i)if("number"!=typeof t[i])throw new Error(`Expected an array of numbers for ${e}`);return t}function xf(t,e){if("string"!=typeof t)throw new Error(`Expected a string for ${e}`);return t}function vf(t,e){if("number"!=typeof t)throw new Error(`Expected a number for ${e}`);return t}function bf(t,e){if("string"==typeof t)return t;const n=yf(t,e),i=n.length;if(i<3||i>4)throw new Error(`Expected a color with 3 or 4 values for ${e}`);return n}function wf(t,e){const n=yf(t,e);if(2!==n.length)throw new Error(`Expected an array of two numbers for ${e}`);return n}const Sf="renderOrder";class Cf extends Wh{constructor(t){t=t||{};const e=Object.assign({},t);delete e.style,delete e.renderBuffer,delete e.updateWhileAnimating,delete e.updateWhileInteracting,super(e),this.declutter_=t.declutter?String(t.declutter):void 0,this.renderBuffer_=void 0!==t.renderBuffer?t.renderBuffer:100,this.style_=null,this.styleFunction_=void 0,this.setStyle(t.style),this.updateWhileAnimating_=void 0!==t.updateWhileAnimating&&t.updateWhileAnimating,this.updateWhileInteracting_=void 0!==t.updateWhileInteracting&&t.updateWhileInteracting}getDeclutter(){return this.declutter_}getFeatures(t){return super.getFeatures(t)}getRenderBuffer(){return this.renderBuffer_}getRenderOrder(){return this.get(Sf)}getStyle(){return this.style_}getStyleFunction(){return this.styleFunction_}getUpdateWhileAnimating(){return this.updateWhileAnimating_}getUpdateWhileInteracting(){return this.updateWhileInteracting_}renderDeclutter(t,e){const n=this.getDeclutter();n in t.declutter==!1&&(t.declutter[n]=new Hh(9)),this.getRenderer().renderDeclutter(t,e)}setRenderOrder(t){this.set(Sf,t)}setStyle(t){this.style_=void 0===t?Zd:t;const e=function(t){if(void 0===t)return Zd;if(!t)return null;if("function"==typeof t)return t;if(t instanceof Wd)return t;if(!Array.isArray(t))return tf([t]);if(0===t.length)return[];const e=t.length,n=t[0];if(n instanceof Wd){const n=new Array(e);for(let i=0;i<e;++i){const e=t[i];if(!(e instanceof Wd))throw new Error("Expected a list of style instances");n[i]=e}return n}if("style"in n){const n=new Array(e);for(let i=0;i<e;++i){const e=t[i];if(!("style"in e))throw new Error("Expected a list of rules with a style property");n[i]=e}return Qd(n)}const i=t;return tf(i)}(t);this.styleFunction_=null===t?void 0:function(t){let e;if("function"==typeof t)e=t;else{let n;Array.isArray(t)?n=t:(ir("function"==typeof t.getZIndex,"Expected an `Style` or an array of `Style`"),n=[t]),e=function(){return n}}return e}(e),this.changed()}setDeclutter(t){this.declutter_=t?String(t):void 0,this.changed()}}class Ef extends pi{constructor(t,e,n,i){super(t),this.inversePixelTransform=e,this.frameState=n,this.context=i}}class Pf extends ii{constructor(t){super(),this.map_=t}dispatchRenderEvent(t,e){vi()}calculateMatrices2D(t){const e=t.viewState,n=t.coordinateToPixelTransform,i=t.pixelToCoordinateTransform;aa(n,t.size[0]/2,t.size[1]/2,1/e.resolution,-1/e.resolution,-e.rotation,-e.center[0],-e.center[1]),la(i,n)}forEachFeatureAtCoordinate(t,e,n,i,r,s,o,a){let l;const h=e.viewState;function c(t,e,n,i){return r.call(s,e,t?n:null,i)}const u=h.projection,d=vs(t.slice(),u),f=[[0,0]];if(u.canWrapX()&&i){const t=os(u.getExtent());f.push([-t,0],[t,0])}const g=e.layerStatesArray,p=g.length,m=[],_=[];for(let i=0;i<f.length;i++)for(let r=p-1;r>=0;--r){const s=g[r],u=s.layer;if(u.hasRenderer()&&qh(s,h)&&o.call(a,u)){const r=u.getRenderer(),o=u.getSource();if(r&&o){const a=o.getWrapX()?d:t,h=c.bind(null,s.managed);_[0]=a[0]+f[i][0],_[1]=a[1]+f[i][1],l=r.forEachFeatureAtCoordinate(_,e,n,h,m)}if(l)return l}}if(0===m.length)return;const y=1/m.length;return m.forEach((t,e)=>t.distanceSq+=e*y),m.sort((t,e)=>t.distanceSq-e.distanceSq),m.some(t=>l=t.callback(t.feature,t.layer,t.geometry)),l}hasFeatureAtCoordinate(t,e,n,i,r,s){return void 0!==this.forEachFeatureAtCoordinate(t,e,n,i,ci,this,r,s)}getMap(){return this.map_}renderFrame(t){vi()}scheduleExpireIconCache(t){fd.canExpireCache()&&t.postRenderFunctions.push(Tf)}}function Tf(t,e){fd.expire()}class Rf extends Pf{constructor(t){super(t),this.fontChangeListenerKey_=$n(Td,Nn,t.redrawText,t),this.element_=Oi?kl():document.createElement("div");const e=this.element_.style;e.position="absolute",e.width="100%",e.height="100%",e.zIndex="0",this.element_.className=_l+" ol-layers";const n=t.getViewport();n&&n.insertBefore(this.element_,n.firstChild||null),this.children_=[],this.renderedVisible_=!0}dispatchRenderEvent(t,e){const n=this.getMap();if(n.hasListener(t)){const i=new Ef(t,void 0,e);n.dispatchEvent(i)}}disposeInternal(){Un(this.fontChangeListenerKey_),this.element_.remove(),super.disposeInternal()}renderFrame(t){if(!t)return void(this.renderedVisible_&&(this.element_.style.display="none",this.renderedVisible_=!1));this.calculateMatrices2D(t),this.dispatchRenderEvent(Uh,t);const e=t.layerStatesArray.sort((t,e)=>t.zIndex-e.zIndex);e.some(t=>t.layer instanceof Cf&&t.layer.getDeclutter())&&(t.declutter={});const n=t.viewState;this.children_.length=0;const i=[];let r=null;for(let s=0,o=e.length;s<o;++s){const o=e[s];t.layerIndex=s;const a=o.layer,l=a.getSourceState();if(!qh(o,n)||"ready"!=l&&"undefined"!=l){a.unrender();continue}const h=a.render(t,r);h&&(h!==r&&(this.children_.push(h),r=h),i.push(o))}this.declutter(t,i),function(t,e){const n=t.childNodes;for(let i=0;;++i){const r=n[i],s=e[i];if(!r&&!s)break;r!==s&&(r?s?t.insertBefore(s,r):(t.removeChild(r),--i):t.appendChild(s))}}(this.element_,this.children_);const s=this.getMap().getTargetElement();if(Ll(s)){const t=s.getContext("2d");for(const e of this.children_){const n=e.firstElementChild||e,i=e.style.backgroundColor;if(i&&(!Ll(n)||n.width>0)&&(t.fillStyle=i,t.fillRect(0,0,s.width,s.height)),Ll(n)&&n.width>0){t.save();const i=e.style.opacity||n.style.opacity;t.globalAlpha=""===i?1:Number(i);const r=n.style.transform;if(r)t.transform(...ca(r));else{const e=parseFloat(n.style.width)/n.width,i=parseFloat(n.style.height)/n.height;t.transform(e,0,0,i,0,0)}t.drawImage(n,0,0),t.restore()}}}this.dispatchRenderEvent(Vh,t),this.renderedVisible_||(this.element_.style.display="",this.renderedVisible_=!0),this.scheduleExpireIconCache(t)}declutter(t,e){if(t.declutter){for(let n=e.length-1;n>=0;--n){const i=e[n],r=i.layer;r.getDeclutter()&&r.renderDeclutter(t,i)}e.forEach(e=>e.layer.renderDeferred(t))}}}function Ff(t){t instanceof Wh?t.setMapInternal(null):t instanceof jh&&t.getLayers().forEach(Ff)}function Mf(t,e){if(t instanceof Wh)t.setMapInternal(e);else if(t instanceof jh){const n=t.getLayers().getArray();for(let t=0,i=n.length;t<i;++t)Mf(n[t],e)}}let If=class extends Ci{constructor(t){super(),t=t||{},this.on,this.once,this.un;const e=function(t){let e=null;void 0!==t.keyboardEventTarget&&(e="string"==typeof t.keyboardEventTarget?document.getElementById(t.keyboardEventTarget):t.keyboardEventTarget);const n={},i=t.layers&&"function"==typeof t.layers.getLayers?t.layers:new jh({layers:t.layers});let r,s,o;n[Zi]=i,n[Yi]=t.target,n[Hi]=t.view instanceof dl?t.view:new dl,void 0!==t.controls&&(Array.isArray(t.controls)?r=new Ti(t.controls.slice()):(ir("function"==typeof t.controls.getArray,"Expected `controls` to be an array or an `ol/Collection.js`"),r=t.controls));void 0!==t.interactions&&(Array.isArray(t.interactions)?s=new Ti(t.interactions.slice()):(ir("function"==typeof t.interactions.getArray,"Expected `interactions` to be an array or an `ol/Collection.js`"),s=t.interactions));void 0!==t.overlays?Array.isArray(t.overlays)?o=new Ti(t.overlays.slice()):(ir("function"==typeof t.overlays.getArray,"Expected `overlays` to be an array or an `ol/Collection.js`"),o=t.overlays):o=new Ti;return{controls:r,interactions:s,keyboardEventTarget:e,overlays:o,values:n}}(t);this.renderComplete_=!1,this.loaded_=!0,this.boundHandleBrowserEvent_=this.handleBrowserEvent.bind(this),this.maxTilesLoading_=void 0!==t.maxTilesLoading?t.maxTilesLoading:16,this.pixelRatio_=void 0!==t.pixelRatio?t.pixelRatio:Di,this.postRenderTimeoutHandle_,this.animationDelayKey_,this.animationDelay_=this.animationDelay_.bind(this),this.coordinateToPixelTransform_=[1,0,0,1,0,0],this.pixelToCoordinateTransform_=[1,0,0,1,0,0],this.frameIndex_=0,this.frameState_=null,this.previousExtent_=null,this.viewPropertyListenerKey_=null,this.viewChangeListenerKey_=null,this.layerGroupPropertyListenerKeys_=null,Oi||(this.viewport_=document.createElement("div"),this.viewport_.className="ol-viewport"+("ontouchstart"in window?" ol-touch":""),this.viewport_.style.position="relative",this.viewport_.style.overflow="hidden",this.viewport_.style.width="100%",this.viewport_.style.height="100%",this.overlayContainer_=document.createElement("div"),this.overlayContainer_.style.position="absolute",this.overlayContainer_.style.zIndex="0",this.overlayContainer_.style.width="100%",this.overlayContainer_.style.height="100%",this.overlayContainer_.style.pointerEvents="none",this.overlayContainer_.className="ol-overlaycontainer",this.viewport_.appendChild(this.overlayContainer_),this.overlayContainerStopEvent_=document.createElement("div"),this.overlayContainerStopEvent_.style.position="absolute",this.overlayContainerStopEvent_.style.zIndex="0",this.overlayContainerStopEvent_.style.width="100%",this.overlayContainerStopEvent_.style.height="100%",this.overlayContainerStopEvent_.style.pointerEvents="none",this.overlayContainerStopEvent_.className="ol-overlaycontainer-stopevent",this.viewport_.appendChild(this.overlayContainerStopEvent_)),this.mapBrowserEventHandler_=null,this.moveTolerance_=t.moveTolerance,this.keyboardEventTarget_=e.keyboardEventTarget,this.targetChangeHandlerKeys_=null,this.targetElement_=null,Oi||(this.resizeObserver_=new ResizeObserver(()=>this.updateSize())),this.controls=e.controls||(Oi?new Ti:function(t){t=t||{};const e=new Ti;return(void 0===t.zoom||t.zoom)&&e.push(new Nl(t.zoomOptions)),(void 0===t.rotate||t.rotate)&&e.push(new zl(t.rotateOptions)),(void 0===t.attribution||t.attribution)&&e.push(new Ol(t.attributionOptions)),e}()),this.interactions=e.interactions||(Oi?new Ti:Sh({onFocusOnly:!0})),this.overlays_=e.overlays,this.overlayIdIndex_={},this.renderer_=null,this.postRenderFunctions_=[],this.tileQueue_=new or(this.getTilePriority.bind(this),this.handleTileChange_.bind(this)),this.addChangeListener(Zi,this.handleLayerGroupChanged_),this.addChangeListener(Hi,this.handleViewChanged_),this.addChangeListener(Ki,this.handleSizeChanged_),this.addChangeListener(Yi,this.handleTargetChanged_),this.setProperties(e.values);const n=this;!t.view||t.view instanceof dl||t.view.then(function(t){n.setView(new dl(t))}),this.controls.addEventListener(On,t=>{t.element.setMap(this)}),this.controls.addEventListener(zn,t=>{t.element.setMap(null)}),this.interactions.addEventListener(On,t=>{t.element.setMap(this)}),this.interactions.addEventListener(zn,t=>{t.element.setMap(null)}),this.overlays_.addEventListener(On,t=>{this.addOverlayInternal_(t.element)}),this.overlays_.addEventListener(zn,t=>{const e=t.element.getId();void 0!==e&&delete this.overlayIdIndex_[e.toString()],t.element.setMap(null)}),this.controls.forEach(t=>{t.setMap(this)}),this.interactions.forEach(t=>{t.setMap(this)}),this.overlays_.forEach(this.addOverlayInternal_.bind(this))}addControl(t){this.getControls().push(t)}addInteraction(t){this.getInteractions().push(t)}addLayer(t){this.getLayerGroup().getLayers().push(t)}handleLayerAdd_(t){Mf(t.layer,this)}addOverlay(t){this.getOverlays().push(t)}addOverlayInternal_(t){const e=t.getId();void 0!==e&&(this.overlayIdIndex_[e.toString()]=t),t.setMap(this)}disposeInternal(){this.controls.clear(),this.interactions.clear(),this.overlays_.clear(),this.resizeObserver_?.disconnect(),this.setTarget(null),super.disposeInternal()}forEachFeatureAtPixel(t,e,n){if(!this.frameState_||!this.renderer_)return;const i=this.getCoordinateFromPixelInternal(t),r=void 0!==(n=void 0!==n?n:{}).hitTolerance?n.hitTolerance:0,s=void 0!==n.layerFilter?n.layerFilter:ci,o=!1!==n.checkWrapped;return this.renderer_.forEachFeatureAtCoordinate(i,this.frameState_,r,o,e,null,s,null)}getFeaturesAtPixel(t,e){const n=[];return this.forEachFeatureAtPixel(t,function(t){n.push(t)},e),n}getAllLayers(){const t=[];return function e(n){n.forEach(function(n){n instanceof jh?e(n.getLayers()):t.push(n)})}(this.getLayers()),t}hasFeatureAtPixel(t,e){if(!this.frameState_||!this.renderer_)return!1;const n=this.getCoordinateFromPixelInternal(t),i=void 0!==(e=void 0!==e?e:{}).layerFilter?e.layerFilter:ci,r=void 0!==e.hitTolerance?e.hitTolerance:0,s=!1!==e.checkWrapped;return this.renderer_.hasFeatureAtCoordinate(n,this.frameState_,r,s,i,null)}getEventCoordinate(t){return this.getCoordinateFromPixel(this.getEventPixel(t))}getEventCoordinateInternal(t){return this.getCoordinateFromPixelInternal(this.getEventPixel(t))}getEventPixel(t){const e=this.viewport_.getBoundingClientRect(),n=this.getSize(),i=e.width/n[0],r=e.height/n[1],s="changedTouches"in t?t.changedTouches[0]:t;return[(s.clientX-e.left)/i,(s.clientY-e.top)/r]}getTarget(){return this.get(Yi)}getTargetElement(){return this.targetElement_}getCoordinateFromPixel(t){return Wo(this.getCoordinateFromPixelInternal(t),this.getView().getProjection())}getCoordinateFromPixelInternal(t){const e=this.frameState_;return e?ra(e.pixelToCoordinateTransform,t.slice()):null}getControls(){return this.controls}getOverlays(){return this.overlays_}getOverlayById(t){const e=this.overlayIdIndex_[t.toString()];return void 0!==e?e:null}getInteractions(){return this.interactions}getLayerGroup(){return this.get(Zi)}setLayers(t){const e=this.getLayerGroup();if(t instanceof Ti)return void e.setLayers(t);const n=e.getLayers();n.clear(),n.extend(t)}getLayers(){return this.getLayerGroup().getLayers()}getLoadingOrNotReady(){const t=this.getLayerGroup().getLayerStatesArray();for(let e=0,n=t.length;e<n;++e){const n=t[e];if(!n.visible)continue;const i=n.layer.getRenderer();if(i&&!i.ready)return!0;const r=n.layer.getSource();if(r&&r.loading)return!0}return!1}getPixelFromCoordinate(t){const e=qo(t,this.getView().getProjection());return this.getPixelFromCoordinateInternal(e)}getPixelFromCoordinateInternal(t){const e=this.frameState_;return e?ra(e.coordinateToPixelTransform,t.slice(0,2)):null}getPixelRatio(){return this.pixelRatio_}setPixelRatio(t){this.pixelRatio_!==t&&(this.pixelRatio_=t,this.render())}getRenderer(){return this.renderer_}getSize(){return this.get(Ki)}getView(){return this.get(Hi)}getViewport(){return this.viewport_}getOverlayContainer(){return this.overlayContainer_}getOverlayContainerStopEvent(){return this.overlayContainerStopEvent_}getOwnerDocument(){const t=this.getTargetElement();return t?t.ownerDocument:document}getTilePriority(t,e,n,i){return function(t,e,n,i,r){if(!t||!(n in t.wantedTiles))return rr;if(!t.wantedTiles[n][e.getKey()])return rr;const s=t.viewState.center,o=i[0]-s[0],a=i[1]-s[1];return 65536*Math.log(r)+Math.sqrt(o*o+a*a)/r}(this.frameState_,t,e,n,i)}handleBrowserEvent(t,e){e=e||t.type;const n=new Fi(e,this,t);this.handleMapBrowserEvent(n)}handleMapBrowserEvent(t){if(!this.frameState_)return;const e=t.originalEvent,n=e.type;if(n===$i||n===ni||n===Jn){const t=this.getOwnerDocument(),n=this.viewport_.getRootNode?this.viewport_.getRootNode():t,i=e.target,r=n instanceof ShadowRoot?n.host===i?n.host.ownerDocument:n:n===t?t.documentElement:n;if(this.overlayContainerStopEvent_.contains(i)||!r.contains(i))return}if(t.frameState=this.frameState_,!1!==this.dispatchEvent(t)){const e=this.getInteractions().getArray().slice();for(let n=e.length-1;n>=0;n--){const i=e[n];if(i.getMap()!==this||!i.getActive()||!this.getTargetElement())continue;if(!i.handleEvent(t)||t.propagationStopped)break}}}handlePostRender(){const t=this.frameState_,e=this.tileQueue_;if(!e.isEmpty()){let n=this.maxTilesLoading_,i=n;const r=t?t.viewHints:void 0,s=!!r&&(r[ar]||r[lr]);if(s){const e=Date.now()-t.time>8;n=e?0:8,i=e?0:2}e.getTilesLoading()<n&&(s&&e.reprioritize(),e.loadMoreTiles(n,i))}t&&this.renderer_&&!t.animate&&(this.renderComplete_?(this.hasListener(Xh)&&this.renderer_.dispatchRenderEvent(Xh,t),!1===this.loaded_&&(this.loaded_=!0,this.dispatchEvent(new Ri(qi,this,t)))):!0===this.loaded_&&(this.loaded_=!1,this.dispatchEvent(new Ri(Wi,this,t))));const n=this.postRenderFunctions_;if(t)for(let e=0,i=n.length;e<i;++e)n[e](this,t);n.length=0}handleSizeChanged_(){this.getView()&&!this.getView().getAnimating()&&this.getView().resolveConstraints(0),this.render()}handleTargetChanged_(){if(this.mapBrowserEventHandler_){for(let t=0,e=this.targetChangeHandlerKeys_.length;t<e;++t)Un(this.targetChangeHandlerKeys_[t]);this.targetChangeHandlerKeys_=null,this.viewport_.removeEventListener(Wn,this.boundHandleBrowserEvent_),this.viewport_.removeEventListener(ni,this.boundHandleBrowserEvent_),this.mapBrowserEventHandler_.dispose(),this.mapBrowserEventHandler_=null,this.viewport_.remove()}if(this.targetElement_&&!Ll(this.targetElement_)){this.resizeObserver_?.unobserve(this.targetElement_);const t=this.targetElement_.getRootNode();t instanceof ShadowRoot&&this.resizeObserver_.unobserve(t.host),this.setSize(void 0)}const t=this.getTarget(),e="string"==typeof t?document.getElementById(t):t;if(this.targetElement_=e,e){if(Ll(e)||e.appendChild(this.viewport_),this.renderer_||(this.renderer_=new Rf(this)),!Ll(e)){this.mapBrowserEventHandler_=new Bi(this,this.moveTolerance_);for(const t in Mi)this.mapBrowserEventHandler_.addEventListener(Mi[t],this.handleMapBrowserEvent.bind(this));let t;if(this.viewport_.addEventListener(Wn,this.boundHandleBrowserEvent_,!1),this.viewport_.addEventListener(ni,this.boundHandleBrowserEvent_,!!ji&&{passive:!1}),this.keyboardEventTarget_)t=this.keyboardEventTarget_;else{const n=e.getRootNode();t=n instanceof ShadowRoot?n.host:e}if(this.targetChangeHandlerKeys_=[$n(t,Jn,this.handleBrowserEvent,this),$n(t,Qn,this.handleBrowserEvent,this)],e instanceof HTMLElement){const t=e.getRootNode();t instanceof ShadowRoot&&this.resizeObserver_.observe(t.host),this.resizeObserver_?.observe(e)}}this.updateSize()}else this.renderer_&&(clearTimeout(this.postRenderTimeoutHandle_),this.postRenderTimeoutHandle_=void 0,this.postRenderFunctions_.length=0,this.renderer_.dispose(),this.renderer_=null),this.animationDelayKey_&&(cancelAnimationFrame(this.animationDelayKey_),this.animationDelayKey_=void 0)}handleTileChange_(){this.render()}handleViewPropertyChanged_(){this.render()}handleViewChanged_(){this.viewPropertyListenerKey_&&(Un(this.viewPropertyListenerKey_),this.viewPropertyListenerKey_=null),this.viewChangeListenerKey_&&(Un(this.viewChangeListenerKey_),this.viewChangeListenerKey_=null);const t=this.getView();t&&(this.updateViewportSize_(this.getSize()),this.viewPropertyListenerKey_=$n(t,Nn,this.handleViewPropertyChanged_,this),this.viewChangeListenerKey_=$n(t,Vn,this.handleViewPropertyChanged_,this),t.resolveConstraints(0)),this.render()}handleLayerGroupChanged_(){this.layerGroupPropertyListenerKeys_&&(this.layerGroupPropertyListenerKeys_.forEach(Un),this.layerGroupPropertyListenerKeys_=null);const t=this.getLayerGroup();t&&(this.handleLayerAdd_(new zh("addlayer",t)),this.layerGroupPropertyListenerKeys_=[$n(t,Nn,this.render,this),$n(t,Vn,this.render,this),$n(t,"addlayer",this.handleLayerAdd_,this),$n(t,"removelayer",this.handleLayerRemove_,this)]),this.render()}isRendered(){return!!this.frameState_}animationDelay_(){this.animationDelayKey_=void 0,this.renderFrame_(Date.now())}renderSync(){this.animationDelayKey_&&cancelAnimationFrame(this.animationDelayKey_),this.animationDelay_()}redrawText(){if(!this.frameState_)return;const t=this.frameState_.layerStatesArray;for(let e=0,n=t.length;e<n;++e){const n=t[e].layer;n.hasRenderer()&&n.getRenderer().handleFontsChanged()}}render(){this.renderer_&&void 0===this.animationDelayKey_&&(this.animationDelayKey_=requestAnimationFrame(this.animationDelay_))}removeControl(t){return this.getControls().remove(t)}removeInteraction(t){return this.getInteractions().remove(t)}removeLayer(t){return this.getLayerGroup().getLayers().remove(t)}handleLayerRemove_(t){Ff(t.layer)}removeOverlay(t){return this.getOverlays().remove(t)}renderFrame_(t){const e=this.getSize(),n=this.getView(),i=this.frameState_;let r=null;if(void 0!==e&&kc(e)&&n&&n.isDef()){const i=n.getHints(this.frameState_?this.frameState_.viewHints:void 0),s=n.getState();if(r={animate:!1,coordinateToPixelTransform:this.coordinateToPixelTransform_,declutter:null,extent:ts(s.center,s.resolution,s.rotation,e),index:this.frameIndex_++,layerIndex:0,layerStatesArray:this.getLayerGroup().getLayerStatesArray(),pixelRatio:this.pixelRatio_,pixelToCoordinateTransform:this.pixelToCoordinateTransform_,postRenderFunctions:[],size:e,tileQueue:this.tileQueue_,time:t,usedTiles:{},viewState:s,viewHints:i,wantedTiles:{},mapId:wi(this),renderTargets:{}},s.nextCenter&&s.nextResolution){const t=isNaN(s.nextRotation)?s.rotation:s.nextRotation;r.nextExtent=ts(s.nextCenter,s.nextResolution,t,e)}}if(this.frameState_=r,this.renderer_.renderFrame(r),r){if(r.animate&&this.render(),Array.prototype.push.apply(this.postRenderFunctions_,r.postRenderFunctions),i){(!this.previousExtent_||!ls(this.previousExtent_)&&!Ur(r.extent,this.previousExtent_))&&(this.dispatchEvent(new Ri(Vi,this,i)),this.previousExtent_=Gr(this.previousExtent_))}this.previousExtent_&&!r.viewHints[ar]&&!r.viewHints[lr]&&!Ur(r.extent,this.previousExtent_)&&(this.dispatchEvent(new Ri(Xi,this,r)),kr(r.extent,this.previousExtent_))}this.dispatchEvent(new Ri(Ui,this,r)),this.renderComplete_=(this.hasListener(Wi)||this.hasListener(qi)||this.hasListener(Xh))&&!this.tileQueue_.getTilesLoading()&&!this.tileQueue_.getCount()&&!this.getLoadingOrNotReady(),this.postRenderTimeoutHandle_||(this.postRenderTimeoutHandle_=setTimeout(()=>{this.postRenderTimeoutHandle_=void 0,this.handlePostRender()},0))}setLayerGroup(t){const e=this.getLayerGroup();e&&this.handleLayerRemove_(new zh("removelayer",e)),this.set(Zi,t)}setSize(t){this.set(Ki,t)}setTarget(t){this.set(Yi,t)}setView(t){if(!t||t instanceof dl)return void this.set(Hi,t);this.set(Hi,new dl);const e=this;t.then(function(t){e.setView(new dl(t))})}updateSize(){const t=this.getTargetElement();let e;if(t){let n,i;if(Ll(t)){const e=t.getContext("2d").getTransform();n=t.width/e.a,i=t.height/e.d}else{const e=getComputedStyle(t);n=t.offsetWidth-parseFloat(e.borderLeftWidth)-parseFloat(e.paddingLeft)-parseFloat(e.paddingRight)-parseFloat(e.borderRightWidth),i=t.offsetHeight-parseFloat(e.borderTopWidth)-parseFloat(e.paddingTop)-parseFloat(e.paddingBottom)-parseFloat(e.borderBottomWidth)}isNaN(n)||isNaN(i)||(e=[Math.max(0,n),Math.max(0,i)],!kc(e)&&(t.offsetWidth||t.offsetHeight||t.getClientRects().length)&&Is("No map visible because the map container's width or height are 0."))}const n=this.getSize();!e||n&&hi(e,n)||(this.updateViewportSize_(e),this.setSize(e))}updateViewportSize_(t){const e=this.getView();e&&e.setViewportSize(t)}};class kf extends Ci{constructor(t){if(super(),this.on,this.once,this.un,this.id_=void 0,this.geometryName_="geometry",this.style_=null,this.styleFunction_=void 0,this.geometryChangeKey_=null,this.addChangeListener(this.geometryName_,this.handleGeometryChanged_),t)if("function"==typeof t.getSimplifiedGeometry){const e=t;this.setGeometry(e)}else{const e=t;this.setProperties(e)}}clone(){const t=new kf,e=this.geometryName_;t.setGeometryName(e);const n=this.getPropertiesInternal();if(n){const i=this.getGeometry();for(const r in n)r===e&&i?t.set(r,i.clone()):t.set(r,n[r],!0)}const i=this.getStyle();return i&&t.setStyle(i),t}getGeometry(){return this.get(this.geometryName_)}getId(){return this.id_}getGeometryName(){return this.geometryName_}getStyle(){return this.style_}getStyleFunction(){return this.styleFunction_}handleGeometryChange_(){this.changed()}handleGeometryChanged_(){this.geometryChangeKey_&&(Un(this.geometryChangeKey_),this.geometryChangeKey_=null);const t=this.getGeometry();t&&(this.geometryChangeKey_=$n(t,Vn,this.handleGeometryChange_,this)),this.changed()}setGeometry(t){this.set(this.geometryName_,t)}setStyle(t){this.style_=t,this.styleFunction_=t?function(t){if("function"==typeof t)return t;let e;if(Array.isArray(t))e=t;else{ir("function"==typeof t.getZIndex,"Expected an `ol/style/Style` or an array of `ol/style/Style.js`");e=[t]}return function(){return e}}(t):void 0,this.changed()}setId(t){this.id_=t,this.changed()}setGeometryName(t){t!==this.geometryName_&&(this.removeChangeListener(this.geometryName_,this.handleGeometryChanged_),this.geometryName_=t,this.addChangeListener(this.geometryName_,this.handleGeometryChanged_),this.handleGeometryChanged_())}}function Lf(t,e,n,i,r,s,o){let a,l;const h=(n-e)/i;if(1===h)a=e;else if(2===h)a=e,l=r;else if(0!==h){let s=t[e],o=t[e+1],h=0;const c=[0];for(let r=e+i;r<n;r+=i){const e=t[r],n=t[r+1];h+=Math.sqrt((e-s)*(e-s)+(n-o)*(n-o)),c.push(h),s=e,o=n}const u=r*h,d=function(t,e,n){let i,r;n=n||ri;let s=0,o=t.length,a=!1;for(;s<o;)i=s+(o-s>>1),r=+n(t[i],e),r<0?s=i+1:(o=i,a=!r);return a?s:~s}(c,u);d<0?(l=(u-c[-d-2])/(c[-d-1]-c[-d-2]),a=e+(-d-2)*i):a=e+d*i}o=o>1?o:2,s=s||new Array(o);for(let e=0;e<o;++e)s[e]=void 0===a?NaN:void 0===l?t[a+e]:mr(t[a+e],t[a+i+e],l);return s}function Af(t,e,n,i,r,s){if(n==e)return null;let o;if(r<t[e+i-1])return s?(o=t.slice(e,e+i),o[i-1]=r,o):null;if(t[n-1]<r)return s?(o=t.slice(n-i,n),o[i-1]=r,o):null;if(r==t[e+i-1])return t.slice(e,e+i);let a=e/i,l=n/i;for(;a<l;){const e=a+l>>1;r<t[(e+1)*i-1]?l=e:a=e+1}const h=t[a*i-1];if(r==h)return t.slice((a-1)*i,(a-1)*i+i);const c=(r-h)/(t[(a+1)*i-1]-h);o=[];for(let e=0;e<i-1;++e)o.push(mr(t[(a-1)*i+e],t[a*i+e],c));return o.push(r),o}function Df(t,e,n,i){let r=t[e],s=t[e+1],o=0;for(let a=e+i;a<n;a+=i){const e=t[a],n=t[a+1];o+=Math.sqrt((e-r)*(e-r)+(n-s)*(n-s)),r=e,s=n}return o}class Of extends ma{constructor(t,e){super(),this.flatMidpoint_=null,this.flatMidpointRevision_=-1,this.maxDelta_=-1,this.maxDeltaRevision_=-1,void 0===e||Array.isArray(t[0])?this.setCoordinates(t,e):this.setFlatCoordinates(e,t)}appendCoordinate(t){li(this.flatCoordinates,t),this.changed()}clone(){const t=new Of(this.flatCoordinates.slice(),this.layout);return t.applyProperties(this),t}closestPointXY(t,e,n,i){return i<Lr(this.getExtent(),t,e)?i:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(wa(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),Ca(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,this.maxDelta_,!1,t,e,n,i))}forEachSegment(t){return Xa(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t)}getCoordinateAtM(t,e){return"XYM"!=this.layout&&"XYZM"!=this.layout?null:(e=void 0!==e&&e,Af(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t,e))}getCoordinates(){return Ma(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getCoordinateAt(t,e){return Lf(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t,e,this.stride)}getLength(){return Df(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getFlatMidpoint(){return this.flatMidpointRevision_!=this.getRevision()&&(this.flatMidpoint_=this.getCoordinateAt(.5,this.flatMidpoint_??void 0),this.flatMidpointRevision_=this.getRevision()),this.flatMidpoint_}getSimplifiedGeometryInternal(t){const e=[];return e.length=La(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t,e,0),new Of(e,"XY")}getType(){return"LineString"}intersectsExtent(t){return qa(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t,this.getExtent())}setCoordinates(t,e){this.setLayout(e,t,1),this.flatCoordinates||(this.flatCoordinates=[]),this.flatCoordinates.length=Ta(this.flatCoordinates,0,t,this.stride),this.changed()}}class zf extends ma{constructor(t,e,n){if(super(),this.ends_=[],this.maxDelta_=-1,this.maxDeltaRevision_=-1,Array.isArray(t[0]))this.setCoordinates(t,e);else if(void 0!==e&&n)this.setFlatCoordinates(e,t),this.ends_=n;else{const e=t,n=[],i=[];for(let t=0,r=e.length;t<r;++t){li(n,e[t].getFlatCoordinates()),i.push(n.length)}const r=0===e.length?this.getLayout():e[0].getLayout();this.setFlatCoordinates(r,n),this.ends_=i}}appendLineString(t){li(this.flatCoordinates,t.getFlatCoordinates().slice()),this.ends_.push(this.flatCoordinates.length),this.changed()}clone(){const t=new zf(this.flatCoordinates.slice(),this.layout,this.ends_.slice());return t.applyProperties(this),t}closestPointXY(t,e,n,i){return i<Lr(this.getExtent(),t,e)?i:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(Sa(this.flatCoordinates,0,this.ends_,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),Ea(this.flatCoordinates,0,this.ends_,this.stride,this.maxDelta_,!1,t,e,n,i))}getCoordinateAtM(t,e,n){return"XYM"!=this.layout&&"XYZM"!=this.layout||0===this.flatCoordinates.length?null:(e=void 0!==e&&e,n=void 0!==n&&n,function(t,e,n,i,r,s,o){if(o)return Af(t,e,n[n.length-1],i,r,s);let a;if(r<t[i-1])return s?(a=t.slice(0,i),a[i-1]=r,a):null;if(t[t.length-1]<r)return s?(a=t.slice(t.length-i),a[i-1]=r,a):null;for(let s=0,o=n.length;s<o;++s){const o=n[s];if(e!=o){if(r<t[e+i-1])return null;if(r<=t[o-1])return Af(t,e,o,i,r,!1);e=o}}return null}(this.flatCoordinates,0,this.ends_,this.stride,t,e,n))}getCoordinates(){return Ia(this.flatCoordinates,0,this.ends_,this.stride)}getEnds(){return this.ends_}getLineString(t){return t<0||this.ends_.length<=t?null:new Of(this.flatCoordinates.slice(0===t?0:this.ends_[t-1],this.ends_[t]),this.layout)}getLineStrings(){const t=this.flatCoordinates,e=this.ends_,n=this.layout,i=[];let r=0;for(let s=0,o=e.length;s<o;++s){const o=e[s],a=new Of(t.slice(r,o),n);i.push(a),r=o}return i}getLength(){const t=this.ends_;let e=0,n=0;for(let i=0,r=t.length;i<r;++i)n+=Df(this.flatCoordinates,e,t[i],this.stride),e=t[i];return n}getFlatMidpoints(){const t=[],e=this.flatCoordinates;let n=0;const i=this.ends_,r=this.stride;for(let s=0,o=i.length;s<o;++s){const o=i[s];li(t,Lf(e,n,o,r,.5)),n=o}return t}getSimplifiedGeometryInternal(t){const e=[],n=[];return e.length=Aa(this.flatCoordinates,0,this.ends_,this.stride,t,e,0,n),new zf(e,"XY",n)}getType(){return"MultiLineString"}intersectsExtent(t){return function(t,e,n,i,r){for(let s=0,o=n.length;s<o;++s){if(qa(t,e,n[s],i,r))return!0;e=n[s]}return!1}(this.flatCoordinates,0,this.ends_,this.stride,t)}setCoordinates(t,e){this.setLayout(e,t,2),this.flatCoordinates||(this.flatCoordinates=[]);const n=Ra(this.flatCoordinates,0,t,this.stride,this.ends_);this.flatCoordinates.length=0===n.length?0:n[n.length-1],this.changed()}}class Nf extends ma{constructor(t,e){super(),e&&!Array.isArray(t[0])?this.setFlatCoordinates(e,t):this.setCoordinates(t,e)}appendPoint(t){li(this.flatCoordinates,t.getFlatCoordinates()),this.changed()}clone(){const t=new Nf(this.flatCoordinates.slice(),this.layout);return t.applyProperties(this),t}closestPointXY(t,e,n,i){if(i<Lr(this.getExtent(),t,e))return i;const r=this.flatCoordinates,s=this.stride;for(let o=0,a=r.length;o<a;o+=s){const a=dr(t,e,r[o],r[o+1]);if(a<i){i=a;for(let t=0;t<s;++t)n[t]=r[o+t];n.length=s}}return i}getCoordinates(){return Ma(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getPoint(t){const e=this.flatCoordinates.length/this.stride;return t<0||e<=t?null:new ja(this.flatCoordinates.slice(t*this.stride,(t+1)*this.stride),this.layout)}getPoints(){const t=this.flatCoordinates,e=this.layout,n=this.stride,i=[];for(let r=0,s=t.length;r<s;r+=n){const s=new ja(t.slice(r,r+n),e);i.push(s)}return i}getType(){return"MultiPoint"}intersectsExtent(t){const e=this.flatCoordinates,n=this.stride;for(let i=0,r=e.length;i<r;i+=n){if(Or(t,e[i],e[i+1]))return!0}return!1}setCoordinates(t,e){this.setLayout(e,t,1),this.flatCoordinates||(this.flatCoordinates=[]),this.flatCoordinates.length=Ta(this.flatCoordinates,0,t,this.stride),this.changed()}}function jf(t,e,n,i){const r=[];let s=[1/0,1/0,-1/0,-1/0];for(let o=0,a=n.length;o<a;++o){const a=n[o];s=Br(t,e,a[0],i),r.push((s[0]+s[2])/2,(s[1]+s[3])/2),e=a[a.length-1]}return r}class Gf extends ma{constructor(t,e,n){if(super(),this.endss_=[],this.flatInteriorPointsRevision_=-1,this.flatInteriorPoints_=null,this.maxDelta_=-1,this.maxDeltaRevision_=-1,this.orientedRevision_=-1,this.orientedFlatCoordinates_=null,!n&&!Array.isArray(t[0])){const i=t,r=[],s=[];for(let t=0,e=i.length;t<e;++t){const e=i[t],n=r.length,o=e.getEnds();for(let t=0,e=o.length;t<e;++t)o[t]+=n;li(r,e.getFlatCoordinates()),s.push(o)}e=0===i.length?this.getLayout():i[0].getLayout(),t=r,n=s}void 0!==e&&n?(this.setFlatCoordinates(e,t),this.endss_=n):this.setCoordinates(t,e)}appendPolygon(t){let e;if(this.flatCoordinates){const n=this.flatCoordinates.length;li(this.flatCoordinates,t.getFlatCoordinates()),e=t.getEnds().slice();for(let t=0,i=e.length;t<i;++t)e[t]+=n}else this.flatCoordinates=t.getFlatCoordinates().slice(),e=t.getEnds().slice(),this.endss_.push();this.endss_.push(e),this.changed()}clone(){const t=this.endss_.length,e=new Array(t);for(let n=0;n<t;++n)e[n]=this.endss_[n].slice();const n=new Gf(this.flatCoordinates.slice(),this.layout,e);return n.applyProperties(this),n}closestPointXY(t,e,n,i){return i<Lr(this.getExtent(),t,e)?i:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(function(t,e,n,i,r){for(let s=0,o=n.length;s<o;++s){const o=n[s];r=Sa(t,e,o,i,r),e=o[o.length-1]}return r}(this.flatCoordinates,0,this.endss_,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),function(t,e,n,i,r,s,o,a,l,h,c){c=c||[NaN,NaN];for(let u=0,d=n.length;u<d;++u){const d=n[u];h=Ea(t,e,d,i,r,s,o,a,l,h,c),e=d[d.length-1]}return h}(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride,this.maxDelta_,!0,t,e,n,i))}containsXY(t,e){return function(t,e,n,i,r,s){if(0===n.length)return!1;for(let o=0,a=n.length;o<a;++o){const a=n[o];if(Ba(t,e,a,i,r,s))return!0;e=a[a.length-1]}return!1}(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride,t,e)}getArea(){return function(t,e,n,i){let r=0;for(let s=0,o=n.length;s<o;++s){const o=n[s];r+=va(t,e,o,i),e=o[o.length-1]}return r}(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride)}getCoordinates(t){let e;return void 0!==t?(e=this.getOrientedFlatCoordinates().slice(),el(e,0,this.endss_,this.stride,t)):e=this.flatCoordinates,ka(e,0,this.endss_,this.stride)}getEndss(){return this.endss_}getFlatInteriorPoints(){if(this.flatInteriorPointsRevision_!=this.getRevision()){const t=jf(this.flatCoordinates,0,this.endss_,this.stride);this.flatInteriorPoints_=Va(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride,t),this.flatInteriorPointsRevision_=this.getRevision()}return this.flatInteriorPoints_}getInteriorPoints(){return new Nf(this.getFlatInteriorPoints().slice(),"XYM")}getOrientedFlatCoordinates(){if(this.orientedRevision_!=this.getRevision()){const t=this.flatCoordinates;Qa(t,0,this.endss_,this.stride)?this.orientedFlatCoordinates_=t:(this.orientedFlatCoordinates_=t.slice(),this.orientedFlatCoordinates_.length=el(this.orientedFlatCoordinates_,0,this.endss_,this.stride)),this.orientedRevision_=this.getRevision()}return this.orientedFlatCoordinates_}getSimplifiedGeometryInternal(t){const e=[],n=[];return e.length=function(t,e,n,i,r,s,o,a){for(let l=0,h=n.length;l<h;++l){const h=n[l],c=[];o=za(t,e,h,i,r,s,o,c),a.push(c),e=h[h.length-1]}return o}(this.flatCoordinates,0,this.endss_,this.stride,Math.sqrt(t),e,0,n),new Gf(e,"XY",n)}getPolygon(t){if(t<0||this.endss_.length<=t)return null;let e;if(0===t)e=0;else{const n=this.endss_[t-1];e=n[n.length-1]}const n=this.endss_[t].slice(),i=n[n.length-1];if(0!==e)for(let t=0,i=n.length;t<i;++t)n[t]-=e;return new il(this.flatCoordinates.slice(e,i),this.layout,n)}getPolygons(){const t=this.layout,e=this.flatCoordinates,n=this.endss_,i=[];let r=0;for(let s=0,o=n.length;s<o;++s){const o=n[s].slice(),a=o[o.length-1];if(0!==r)for(let t=0,e=o.length;t<e;++t)o[t]-=r;const l=new il(e.slice(r,a),t,o);i.push(l),r=a}return i}getType(){return"MultiPolygon"}intersectsExtent(t){return function(t,e,n,i,r){for(let s=0,o=n.length;s<o;++s){const o=n[s];if(Ka(t,e,o,i,r))return!0;e=o[o.length-1]}return!1}(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride,t)}setCoordinates(t,e){this.setLayout(e,t,3),this.flatCoordinates||(this.flatCoordinates=[]);const n=Fa(this.flatCoordinates,0,t,this.stride,this.endss_);if(0===n.length)this.flatCoordinates.length=0;else{const t=n[n.length-1];this.flatCoordinates.length=0===t.length?0:t[t.length-1]}this.changed()}}const $f=[1,0,0,1,0,0];class Bf{constructor(t,e,n,i,r,s){this.styleFunction,this.extent_,this.id_=s,this.type_=t,this.flatCoordinates_=e,this.flatInteriorPoints_=null,this.flatMidpoints_=null,this.ends_=n||null,this.properties_=r,this.squaredTolerance_,this.stride_=i,this.simplifiedGeometry_}get(t){return this.properties_[t]}getExtent(){return this.extent_||(this.extent_="Point"===this.type_?$r(this.flatCoordinates_):Br(this.flatCoordinates_,0,this.flatCoordinates_.length,this.stride_)),this.extent_}getFlatInteriorPoint(){if(!this.flatInteriorPoints_){const t=Jr(this.getExtent());this.flatInteriorPoints_=Ua(this.flatCoordinates_,0,this.ends_,this.stride_,t,0)}return this.flatInteriorPoints_}getFlatInteriorPoints(){if(!this.flatInteriorPoints_){const t=nl(this.flatCoordinates_,this.ends_),e=jf(this.flatCoordinates_,0,t,this.stride_);this.flatInteriorPoints_=Va(this.flatCoordinates_,0,t,this.stride_,e)}return this.flatInteriorPoints_}getFlatMidpoint(){return this.flatMidpoints_||(this.flatMidpoints_=Lf(this.flatCoordinates_,0,this.flatCoordinates_.length,this.stride_,.5)),this.flatMidpoints_}getFlatMidpoints(){if(!this.flatMidpoints_){this.flatMidpoints_=[];const t=this.flatCoordinates_;let e=0;const n=this.ends_;for(let i=0,r=n.length;i<r;++i){const r=n[i],s=Lf(t,e,r,this.stride_,.5);li(this.flatMidpoints_,s),e=r}}return this.flatMidpoints_}getId(){return this.id_}getOrientedFlatCoordinates(){return this.flatCoordinates_}getGeometry(){return this}getSimplifiedGeometry(t){return this}simplifyTransformed(t,e){return this}getProperties(){return this.properties_}getPropertiesInternal(){return this.properties_}getStride(){return this.stride_}getStyleFunction(){return this.styleFunction}getType(){return this.type_}transform(t){const e=(t=Mo(t)).getExtent(),n=t.getWorldExtent();if(e&&n){const t=ns(n)/ns(e);aa($f,n[0],n[3],t,-t,0,0,0),ua(this.flatCoordinates_,0,this.flatCoordinates_.length,this.stride_,$f,this.flatCoordinates_)}}applyTransform(t){t(this.flatCoordinates_,this.flatCoordinates_,this.stride_)}clone(){return new Bf(this.type_,this.flatCoordinates_.slice(),this.ends_?.slice(),this.stride_,Object.assign({},this.properties_),this.id_)}getEnds(){return this.ends_}enableSimplifyTransformed(){return this.simplifyTransformed=fi((t,e)=>{if(t===this.squaredTolerance_)return this.simplifiedGeometry_;this.simplifiedGeometry_=this.clone(),e&&this.simplifiedGeometry_.applyTransform(e);const n=this.simplifiedGeometry_.getFlatCoordinates();let i;switch(this.type_){case"LineString":n.length=La(n,0,this.simplifiedGeometry_.flatCoordinates_.length,this.simplifiedGeometry_.stride_,t,n,0),i=[n.length];break;case"MultiLineString":i=[],n.length=Aa(n,0,this.simplifiedGeometry_.ends_,this.simplifiedGeometry_.stride_,t,n,0,i);break;case"Polygon":i=[],n.length=za(n,0,this.simplifiedGeometry_.ends_,this.simplifiedGeometry_.stride_,Math.sqrt(t),n,0,i)}return i&&(this.simplifiedGeometry_=new Bf(this.type_,n,i,this.stride_,this.properties_,this.id_)),this.squaredTolerance_=t,this.simplifiedGeometry_}),this}}Bf.prototype.getFlatCoordinates=Bf.prototype.getOrientedFlatCoordinates;class Uf extends pa{constructor(t){super(),this.geometries_=t,this.changeEventsKeys_=[],this.listenGeometriesChange_()}unlistenGeometriesChange_(){this.changeEventsKeys_.forEach(Un),this.changeEventsKeys_.length=0}listenGeometriesChange_(){const t=this.geometries_;for(let e=0,n=t.length;e<n;++e)this.changeEventsKeys_.push($n(t[e],Vn,this.changed,this))}clone(){const t=new Uf(Vf(this.geometries_));return t.applyProperties(this),t}closestPointXY(t,e,n,i){if(i<Lr(this.getExtent(),t,e))return i;const r=this.geometries_;for(let s=0,o=r.length;s<o;++s)i=r[s].closestPointXY(t,e,n,i);return i}containsXY(t,e){const n=this.geometries_;for(let i=0,r=n.length;i<r;++i)if(n[i].containsXY(t,e))return!0;return!1}computeExtent(t){Gr(t);const e=this.geometries_;for(let n=0,i=e.length;n<i;++n)Vr(t,e[n].getExtent());return t}getGeometries(){return Vf(this.geometries_)}getGeometriesArray(){return this.geometries_}getGeometriesArrayRecursive(){let t=[];const e=this.geometries_;for(let n=0,i=e.length;n<i;++n)e[n].getType()===this.getType()?t=t.concat(e[n].getGeometriesArrayRecursive()):t.push(e[n]);return t}getSimplifiedGeometry(t){if(this.simplifiedGeometryRevision!==this.getRevision()&&(this.simplifiedGeometryMaxMinSquaredTolerance=0,this.simplifiedGeometryRevision=this.getRevision()),t<0||0!==this.simplifiedGeometryMaxMinSquaredTolerance&&t<this.simplifiedGeometryMaxMinSquaredTolerance)return this;const e=[],n=this.geometries_;let i=!1;for(let r=0,s=n.length;r<s;++r){const s=n[r],o=s.getSimplifiedGeometry(t);e.push(o),o!==s&&(i=!0)}if(i){return new Uf(e)}return this.simplifiedGeometryMaxMinSquaredTolerance=t,this}getType(){return"GeometryCollection"}intersectsExtent(t){const e=this.geometries_;for(let n=0,i=e.length;n<i;++n)if(e[n].intersectsExtent(t))return!0;return!1}isEmpty(){return 0===this.geometries_.length}rotate(t,e){const n=this.geometries_;for(let i=0,r=n.length;i<r;++i)n[i].rotate(t,e);this.changed()}scale(t,e,n){n||(n=Jr(this.getExtent()));const i=this.geometries_;for(let r=0,s=i.length;r<s;++r)i[r].scale(t,e,n);this.changed()}setGeometries(t){this.setGeometriesArray(Vf(t))}setGeometriesArray(t){this.unlistenGeometriesChange_(),this.geometries_=t,this.listenGeometriesChange_(),this.changed()}applyTransform(t){const e=this.geometries_;for(let n=0,i=e.length;n<i;++n)e[n].applyTransform(t);this.changed()}translate(t,e){const n=this.geometries_;for(let i=0,r=n.length;i<r;++i)n[i].translate(t,e);this.changed()}disposeInternal(){this.unlistenGeometriesChange_(),super.disposeInternal()}}function Vf(t){return t.map(t=>t.clone())}class Xf{constructor(){this.dataProjection=void 0,this.defaultFeatureProjection=void 0,this.featureClass=kf,this.supportedMediaTypes=null}getReadOptions(t,e){if(e){let n=e.dataProjection?Mo(e.dataProjection):this.readProjection(t);e.extent&&n&&"tile-pixels"===n.getUnits()&&(n=Mo(n),n.setWorldExtent(e.extent)),e={dataProjection:n,featureProjection:e.featureProjection}}return this.adaptOptions(e)}adaptOptions(t){return Object.assign({dataProjection:this.dataProjection,featureProjection:this.defaultFeatureProjection,featureClass:this.featureClass},t)}getType(){return vi()}readFeature(t,e){return vi()}readFeatures(t,e){return vi()}readGeometry(t,e){return vi()}readProjection(t){return vi()}writeFeature(t,e){return vi()}writeFeatures(t,e){return vi()}writeGeometry(t,e){return vi()}}function Wf(t,e,n){const i=n?Mo(n.featureProjection):null,r=n?Mo(n.dataProjection):null;let s=t;if(i&&r&&!zo(i,r)){e&&(s=t.clone());const n=e?i:r,o=e?r:i;"tile-pixels"===n.getUnits()?s.transform(n,o):s.applyTransform(Go(n,o))}if(e&&n&&void 0!==n.decimals){const e=Math.pow(10,n.decimals),i=function(t){for(let n=0,i=t.length;n<i;++n)t[n]=Math.round(t[n]*e)/e;return t};s===t&&(s=t.clone()),s.applyTransform(i)}return s}const qf={Point:ja,LineString:Of,Polygon:il,MultiPoint:Nf,MultiLineString:zf,MultiPolygon:Gf};function Zf(t,e){const n=t.geometry;if(!n)return[];if(Array.isArray(n))return n.map(e=>Zf({...t,geometry:e})).flat();const i="MultiPolygon"===n.type?"Polygon":n.type;if("GeometryCollection"===i||"Circle"===i)throw new Error("Unsupported geometry type: "+i);const r=n.layout.length;return Wf(new Bf(i,"Polygon"===i?function(t,e,n){return Array.isArray(e[0])?(Qa(t,0,e,n)||el(t=t.slice(),0,e,n),t):(Ja(t,0,e,n)||tl(t=t.slice(),0,e,n),t)}(n.flatCoordinates,n.ends,r):n.flatCoordinates,n.ends?.flat(),r,t.properties||{},t.id).enableSimplifyTransformed(),!1,e)}function Kf(t,e){if(!t)return null;if(Array.isArray(t)){const n=t.map(t=>Kf(t,e));return new Uf(n)}return Wf(new(0,qf[t.type])(t.flatCoordinates,t.layout||"XY",t.ends),!1,e)}class Yf extends Xf{constructor(){super()}getType(){return"json"}readFeature(t,e){return this.readFeatureFromObject(Hf(t),this.getReadOptions(t,e))}readFeatures(t,e){return this.readFeaturesFromObject(Hf(t),this.getReadOptions(t,e))}readFeatureFromObject(t,e){return vi()}readFeaturesFromObject(t,e){return vi()}readGeometry(t,e){return this.readGeometryFromObject(Hf(t),this.getReadOptions(t,e))}readGeometryFromObject(t,e){return vi()}readProjection(t){return this.readProjectionFromObject(Hf(t))}readProjectionFromObject(t){return vi()}writeFeature(t,e){return JSON.stringify(this.writeFeatureObject(t,e))}writeFeatureObject(t,e){return vi()}writeFeatures(t,e){return JSON.stringify(this.writeFeaturesObject(t,e))}writeFeaturesObject(t,e){return vi()}writeGeometry(t,e){return JSON.stringify(this.writeGeometryObject(t,e))}writeGeometryObject(t,e){return vi()}}function Hf(t){if("string"==typeof t){const e=JSON.parse(t);return e||null}return null!==t?t:null}class Jf extends Yf{constructor(t){t=t||{},super(),this.dataProjection=Mo(t.dataProjection?t.dataProjection:"EPSG:4326"),t.featureProjection&&(this.defaultFeatureProjection=Mo(t.featureProjection)),t.featureClass&&(this.featureClass=t.featureClass),this.geometryName_=t.geometryName,this.extractGeometryName_=t.extractGeometryName,this.supportedMediaTypes=["application/geo+json","application/vnd.geo+json"]}readFeatureFromObject(t,e){let n=null;n="Feature"===t.type?t:{type:"Feature",geometry:t,properties:null};const i=Qf(n.geometry);if(this.featureClass===Bf)return Zf({geometry:i,id:n.id,properties:n.properties},e);const r=new kf;return this.geometryName_?r.setGeometryName(this.geometryName_):this.extractGeometryName_&&n.geometry_name&&r.setGeometryName(n.geometry_name),r.setGeometry(Kf(i,e)),"id"in n&&r.setId(n.id),n.properties&&r.setProperties(n.properties,!0),r}readFeaturesFromObject(t,e){let n=null;if("FeatureCollection"===t.type){n=[];const i=t.features;for(let t=0,r=i.length;t<r;++t){const r=this.readFeatureFromObject(i[t],e);r&&n.push(r)}}else n=[this.readFeatureFromObject(t,e)];return n.flat()}readGeometryFromObject(t,e){return function(t,e){const n=Qf(t);return Kf(n,e)}(t,e)}readProjectionFromObject(t){const e=t.crs;let n;if(e)if("name"==e.type)n=Mo(e.properties.name);else{if("EPSG"!==e.type)throw new Error("Unknown SRS type");n=Mo("EPSG:"+e.properties.code)}else n=this.dataProjection;return n}writeFeatureObject(t,e){e=this.adaptOptions(e);const n={type:"Feature",geometry:null,properties:null},i=t.getId();if(void 0!==i&&(n.id=i),!t.hasProperties())return n;const r=t.getProperties(),s=t.getGeometry();return s&&(n.geometry=tg(s,e),delete r[t.getGeometryName()]),Gn(r)||(n.properties=r),n}writeFeaturesObject(t,e){e=this.adaptOptions(e);const n=[];for(let i=0,r=t.length;i<r;++i)n.push(this.writeFeatureObject(t[i],e));return{type:"FeatureCollection",features:n}}writeGeometryObject(t,e){return tg(t,this.adaptOptions(e))}}function Qf(t,e){if(!t)return null;let n;switch(t.type){case"Point":n=function(t){const e=t.coordinates;return{type:"Point",flatCoordinates:e,layout:_a(e.length)}}(t);break;case"LineString":n=function(t){const e=t.coordinates,n=e.flat();return{type:"LineString",flatCoordinates:n,ends:[n.length],layout:_a(e[0]?.length||2)}}(t);break;case"Polygon":n=function(t){const e=t.coordinates,n=[],i=e[0]?.[0]?.length,r=Ra(n,0,e,i);return{type:"Polygon",flatCoordinates:n,ends:r,layout:_a(i)}}(t);break;case"MultiPoint":n=function(t){const e=t.coordinates;return{type:"MultiPoint",flatCoordinates:e.flat(),layout:_a(e[0]?.length||2)}}(t);break;case"MultiLineString":n=function(t){const e=t.coordinates,n=e[0]?.[0]?.length||2,i=[],r=Ra(i,0,e,n);return{type:"MultiLineString",flatCoordinates:i,ends:r,layout:_a(n)}}(t);break;case"MultiPolygon":n=function(t){const e=t.coordinates,n=[],i=e[0]?.[0]?.[0].length||2,r=Fa(n,0,e,i);return{type:"MultiPolygon",flatCoordinates:n,ends:r,layout:_a(i)}}(t);break;case"GeometryCollection":n=function(t){const e=t.geometries.map(function(t){return Qf(t)});return e}(t);break;default:throw new Error("Unsupported GeoJSON type: "+t.type)}return n}function tg(t,e){const n=(t=Wf(t,!0,e)).getType();let i;switch(n){case"Point":i=function(t){return{type:"Point",coordinates:t.getCoordinates()}}(t);break;case"LineString":i=function(t){return{type:"LineString",coordinates:t.getCoordinates()}}(t);break;case"Polygon":i=function(t,e){let n;e&&(n=e.rightHanded);return{type:"Polygon",coordinates:t.getCoordinates(n)}}(t,e);break;case"MultiPoint":i=function(t){return{type:"MultiPoint",coordinates:t.getCoordinates()}}(t);break;case"MultiLineString":i=function(t){return{type:"MultiLineString",coordinates:t.getCoordinates()}}(t);break;case"MultiPolygon":i=function(t,e){let n;e&&(n=e.rightHanded);return{type:"MultiPolygon",coordinates:t.getCoordinates(n)}}(t,e);break;case"GeometryCollection":i=function(t,e){e=Object.assign({},e),delete e.featureProjection;const n=t.getGeometriesArray().map(function(t){return tg(t,e)});return{type:"GeometryCollection",geometries:n}}(t,e);break;case"Circle":i={type:"GeometryCollection",geometries:[]};break;default:throw new Error("Unsupported geometry type: "+n)}return i}const eg=4294967296,ng=1/eg,ig="undefined"==typeof TextDecoder?null:new TextDecoder("utf-8");class rg{constructor(t=new Uint8Array(16)){this.buf=ArrayBuffer.isView(t)?t:new Uint8Array(t),this.dataView=new DataView(this.buf.buffer),this.pos=0,this.type=0,this.length=this.buf.length}readFields(t,e,n=this.length){for(;this.pos<n;){const n=this.readVarint(),i=n>>3,r=this.pos;this.type=7&n,t(i,e,this),this.pos===r&&this.skip(n)}return e}readMessage(t,e){return this.readFields(t,e,this.readVarint()+this.pos)}readFixed32(){const t=this.dataView.getUint32(this.pos,!0);return this.pos+=4,t}readSFixed32(){const t=this.dataView.getInt32(this.pos,!0);return this.pos+=4,t}readFixed64(){const t=this.dataView.getUint32(this.pos,!0)+this.dataView.getUint32(this.pos+4,!0)*eg;return this.pos+=8,t}readSFixed64(){const t=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*eg;return this.pos+=8,t}readFloat(){const t=this.dataView.getFloat32(this.pos,!0);return this.pos+=4,t}readDouble(){const t=this.dataView.getFloat64(this.pos,!0);return this.pos+=8,t}readVarint(t){const e=this.buf;let n,i;return i=e[this.pos++],n=127&i,i<128?n:(i=e[this.pos++],n|=(127&i)<<7,i<128?n:(i=e[this.pos++],n|=(127&i)<<14,i<128?n:(i=e[this.pos++],n|=(127&i)<<21,i<128?n:(i=e[this.pos],n|=(15&i)<<28,function(t,e,n){const i=n.buf;let r,s;if(s=i[n.pos++],r=(112&s)>>4,s<128)return sg(t,r,e);if(s=i[n.pos++],r|=(127&s)<<3,s<128)return sg(t,r,e);if(s=i[n.pos++],r|=(127&s)<<10,s<128)return sg(t,r,e);if(s=i[n.pos++],r|=(127&s)<<17,s<128)return sg(t,r,e);if(s=i[n.pos++],r|=(127&s)<<24,s<128)return sg(t,r,e);if(s=i[n.pos++],r|=(1&s)<<31,s<128)return sg(t,r,e);throw new Error("Expected varint not more than 10 bytes")}(n,t,this)))))}readVarint64(){return this.readVarint(!0)}readSVarint(){const t=this.readVarint();return t%2==1?(t+1)/-2:t/2}readBoolean(){return Boolean(this.readVarint())}readString(){const t=this.readVarint()+this.pos,e=this.pos;return this.pos=t,t-e>=12&&ig?ig.decode(this.buf.subarray(e,t)):function(t,e,n){let i="",r=e;for(;r<n;){const e=t[r];let s,o,a,l=null,h=e>239?4:e>223?3:e>191?2:1;if(r+h>n)break;1===h?e<128&&(l=e):2===h?(s=t[r+1],128==(192&s)&&(l=(31&e)<<6|63&s,l<=127&&(l=null))):3===h?(s=t[r+1],o=t[r+2],128==(192&s)&&128==(192&o)&&(l=(15&e)<<12|(63&s)<<6|63&o,(l<=2047||l>=55296&&l<=57343)&&(l=null))):4===h&&(s=t[r+1],o=t[r+2],a=t[r+3],128==(192&s)&&128==(192&o)&&128==(192&a)&&(l=(15&e)<<18|(63&s)<<12|(63&o)<<6|63&a,(l<=65535||l>=1114112)&&(l=null))),null===l?(l=65533,h=1):l>65535&&(l-=65536,i+=String.fromCharCode(l>>>10&1023|55296),l=56320|1023&l),i+=String.fromCharCode(l),r+=h}return i}(this.buf,e,t)}readBytes(){const t=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,t);return this.pos=t,e}readPackedVarint(t=[],e){const n=this.readPackedEnd();for(;this.pos<n;)t.push(this.readVarint(e));return t}readPackedSVarint(t=[]){const e=this.readPackedEnd();for(;this.pos<e;)t.push(this.readSVarint());return t}readPackedBoolean(t=[]){const e=this.readPackedEnd();for(;this.pos<e;)t.push(this.readBoolean());return t}readPackedFloat(t=[]){const e=this.readPackedEnd();for(;this.pos<e;)t.push(this.readFloat());return t}readPackedDouble(t=[]){const e=this.readPackedEnd();for(;this.pos<e;)t.push(this.readDouble());return t}readPackedFixed32(t=[]){const e=this.readPackedEnd();for(;this.pos<e;)t.push(this.readFixed32());return t}readPackedSFixed32(t=[]){const e=this.readPackedEnd();for(;this.pos<e;)t.push(this.readSFixed32());return t}readPackedFixed64(t=[]){const e=this.readPackedEnd();for(;this.pos<e;)t.push(this.readFixed64());return t}readPackedSFixed64(t=[]){const e=this.readPackedEnd();for(;this.pos<e;)t.push(this.readSFixed64());return t}readPackedEnd(){return 2===this.type?this.readVarint()+this.pos:this.pos+1}skip(t){const e=7&t;if(0===e)for(;this.buf[this.pos++]>127;);else if(2===e)this.pos=this.readVarint()+this.pos;else if(5===e)this.pos+=4;else{if(1!==e)throw new Error(`Unimplemented type: ${e}`);this.pos+=8}}writeTag(t,e){this.writeVarint(t<<3|e)}realloc(t){let e=this.length||16;for(;e<this.pos+t;)e*=2;if(e!==this.length){const t=new Uint8Array(e);t.set(this.buf),this.buf=t,this.dataView=new DataView(t.buffer),this.length=e}}finish(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)}writeFixed32(t){this.realloc(4),this.dataView.setInt32(this.pos,t,!0),this.pos+=4}writeSFixed32(t){this.realloc(4),this.dataView.setInt32(this.pos,t,!0),this.pos+=4}writeFixed64(t){this.realloc(8),this.dataView.setInt32(this.pos,-1&t,!0),this.dataView.setInt32(this.pos+4,Math.floor(t*ng),!0),this.pos+=8}writeSFixed64(t){this.realloc(8),this.dataView.setInt32(this.pos,-1&t,!0),this.dataView.setInt32(this.pos+4,Math.floor(t*ng),!0),this.pos+=8}writeVarint(t){(t=+t||0)>268435455||t<0?function(t,e){let n,i;t>=0?(n=t%4294967296|0,i=t/4294967296|0):(n=~(-t%4294967296),i=~(-t/4294967296),4294967295^n?n=n+1|0:(n=0,i=i+1|0));if(t>=0x10000000000000000||t<-0x10000000000000000)throw new Error("Given varint doesn't fit into 10 bytes");e.realloc(10),function(t,e,n){n.buf[n.pos++]=127&t|128,t>>>=7,n.buf[n.pos++]=127&t|128,t>>>=7,n.buf[n.pos++]=127&t|128,t>>>=7,n.buf[n.pos++]=127&t|128,t>>>=7,n.buf[n.pos]=127&t}(n,0,e),function(t,e){const n=(7&t)<<4;if(e.buf[e.pos++]|=n|((t>>>=3)?128:0),!t)return;if(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),!t)return;if(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),!t)return;if(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),!t)return;if(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),!t)return;e.buf[e.pos++]=127&t}(i,e)}(t,this):(this.realloc(4),this.buf[this.pos++]=127&t|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=t>>>7&127))))}writeSVarint(t){this.writeVarint(t<0?2*-t-1:2*t)}writeBoolean(t){this.writeVarint(+t)}writeString(t){t=String(t),this.realloc(4*t.length),this.pos++;const e=this.pos;this.pos=function(t,e,n){for(let i,r,s=0;s<e.length;s++){if(i=e.charCodeAt(s),i>55295&&i<57344){if(!r){i>56319||s+1===e.length?(t[n++]=239,t[n++]=191,t[n++]=189):r=i;continue}if(i<56320){t[n++]=239,t[n++]=191,t[n++]=189,r=i;continue}i=r-55296<<10|i-56320|65536,r=null}else r&&(t[n++]=239,t[n++]=191,t[n++]=189,r=null);i<128?t[n++]=i:(i<2048?t[n++]=i>>6|192:(i<65536?t[n++]=i>>12|224:(t[n++]=i>>18|240,t[n++]=i>>12&63|128),t[n++]=i>>6&63|128),t[n++]=63&i|128)}return n}(this.buf,t,this.pos);const n=this.pos-e;n>=128&&og(e,n,this),this.pos=e-1,this.writeVarint(n),this.pos+=n}writeFloat(t){this.realloc(4),this.dataView.setFloat32(this.pos,t,!0),this.pos+=4}writeDouble(t){this.realloc(8),this.dataView.setFloat64(this.pos,t,!0),this.pos+=8}writeBytes(t){const e=t.length;this.writeVarint(e),this.realloc(e);for(let n=0;n<e;n++)this.buf[this.pos++]=t[n]}writeRawMessage(t,e){this.pos++;const n=this.pos;t(e,this);const i=this.pos-n;i>=128&&og(n,i,this),this.pos=n-1,this.writeVarint(i),this.pos+=i}writeMessage(t,e,n){this.writeTag(t,2),this.writeRawMessage(e,n)}writePackedVarint(t,e){e.length&&this.writeMessage(t,ag,e)}writePackedSVarint(t,e){e.length&&this.writeMessage(t,lg,e)}writePackedBoolean(t,e){e.length&&this.writeMessage(t,ug,e)}writePackedFloat(t,e){e.length&&this.writeMessage(t,hg,e)}writePackedDouble(t,e){e.length&&this.writeMessage(t,cg,e)}writePackedFixed32(t,e){e.length&&this.writeMessage(t,dg,e)}writePackedSFixed32(t,e){e.length&&this.writeMessage(t,fg,e)}writePackedFixed64(t,e){e.length&&this.writeMessage(t,gg,e)}writePackedSFixed64(t,e){e.length&&this.writeMessage(t,pg,e)}writeBytesField(t,e){this.writeTag(t,2),this.writeBytes(e)}writeFixed32Field(t,e){this.writeTag(t,5),this.writeFixed32(e)}writeSFixed32Field(t,e){this.writeTag(t,5),this.writeSFixed32(e)}writeFixed64Field(t,e){this.writeTag(t,1),this.writeFixed64(e)}writeSFixed64Field(t,e){this.writeTag(t,1),this.writeSFixed64(e)}writeVarintField(t,e){this.writeTag(t,0),this.writeVarint(e)}writeSVarintField(t,e){this.writeTag(t,0),this.writeSVarint(e)}writeStringField(t,e){this.writeTag(t,2),this.writeString(e)}writeFloatField(t,e){this.writeTag(t,5),this.writeFloat(e)}writeDoubleField(t,e){this.writeTag(t,1),this.writeDouble(e)}writeBooleanField(t,e){this.writeVarintField(t,+e)}}function sg(t,e,n){return n?4294967296*e+(t>>>0):4294967296*(e>>>0)+(t>>>0)}function og(t,e,n){const i=e<=16383?1:e<=2097151?2:e<=268435455?3:Math.floor(Math.log(e)/(7*Math.LN2));n.realloc(i);for(let e=n.pos-1;e>=t;e--)n.buf[e+i]=n.buf[e]}function ag(t,e){for(let n=0;n<t.length;n++)e.writeVarint(t[n])}function lg(t,e){for(let n=0;n<t.length;n++)e.writeSVarint(t[n])}function hg(t,e){for(let n=0;n<t.length;n++)e.writeFloat(t[n])}function cg(t,e){for(let n=0;n<t.length;n++)e.writeDouble(t[n])}function ug(t,e){for(let n=0;n<t.length;n++)e.writeBoolean(t[n])}function dg(t,e){for(let n=0;n<t.length;n++)e.writeFixed32(t[n])}function fg(t,e){for(let n=0;n<t.length;n++)e.writeSFixed32(t[n])}function gg(t,e){for(let n=0;n<t.length;n++)e.writeFixed64(t[n])}function pg(t,e){for(let n=0;n<t.length;n++)e.writeSFixed64(t[n])}class mg extends Xf{constructor(t){super(),t=t||{},this.dataProjection=new Ls({code:"",units:"tile-pixels"}),this.featureClass=t.featureClass?t.featureClass:Bf,this.geometryName_=t.geometryName,this.layerName_=t.layerName?t.layerName:"layer",this.layers_=t.layers?t.layers:null,this.idProperty_=t.idProperty,this.supportedMediaTypes=["application/vnd.mapbox-vector-tile","application/x-protobuf"]}readRawGeometry_(t,e,n,i){t.pos=e.geometry;const r=t.readVarint()+t.pos;let s=1,o=0,a=0,l=0,h=0,c=0;for(;t.pos<r;){if(!o){const e=t.readVarint();s=7&e,o=e>>3}if(o--,1===s||2===s)a+=t.readSVarint(),l+=t.readSVarint(),1===s&&h>c&&(i.push(h),c=h),n.push(a,l),h+=2;else{if(7!==s)throw new Error("Invalid command found in the PBF");h>c&&(n.push(n[c],n[c+1]),h+=2)}}h>c&&(i.push(h),c=h)}createFeature_(t,e,n){const i=e.type;if(0===i)return null;let r;const s=e.properties;let o;this.idProperty_?(o=s[this.idProperty_],delete s[this.idProperty_]):o=e.id,s[this.layerName_]=e.layer.name;const a=[],l=[];this.readRawGeometry_(t,e,a,l);const h=function(t,e){let n;1===t?n=1===e?"Point":"MultiPoint":2===t?n=1===e?"LineString":"MultiLineString":3===t&&(n="Polygon");return n}(i,l.length);if(this.featureClass===Bf)r=new this.featureClass(h,a,l,2,s,o),r.transform(n.dataProjection);else{let t;if("Polygon"==h){const e=nl(a,l);t=e.length>1?new Gf(a,"XY",e):new il(a,"XY",l)}else t="Point"===h?new ja(a,"XY"):"LineString"===h?new Of(a,"XY"):"MultiPoint"===h?new Nf(a,"XY"):"MultiLineString"===h?new zf(a,"XY",l):null;r=new(0,this.featureClass),this.geometryName_&&r.setGeometryName(this.geometryName_);const e=Wf(t,!1,n);r.setGeometry(e),void 0!==o&&r.setId(o),r.setProperties(s,!0)}return r}getType(){return"arraybuffer"}readFeatures(t,e){const n=this.layers_,i=Mo((e=this.adaptOptions(e)).dataProjection);i.setWorldExtent(e.extent),e.dataProjection=i;const r=new rg(t),s=r.readFields(_g,{}),o=[];for(const t in s){if(n&&!n.includes(t))continue;const a=s[t],l=a?[0,0,a.extent,a.extent]:null;i.setExtent(l);for(let t=0,n=a.length;t<n;++t){const n=vg(r,a,t),i=this.createFeature_(r,n,e);null!==i&&o.push(i)}}return o}readProjection(t){return this.dataProjection}setLayers(t){this.layers_=t}}function _g(t,e,n){if(3===t){const t={keys:[],values:[],features:[]},i=n.readVarint()+n.pos;n.readFields(yg,t,i),t.length=t.features.length,t.length&&(e[t.name]=t)}}function yg(t,e,n){if(15===t)e.version=n.readVarint();else if(1===t)e.name=n.readString();else if(5===t)e.extent=n.readVarint();else if(2===t)e.features.push(n.pos);else if(3===t)e.keys.push(n.readString());else if(4===t){let i=null;const r=n.readVarint()+n.pos;for(;n.pos<r;)i=1===(t=n.readVarint()>>3)?n.readString():2===t?n.readFloat():3===t?n.readDouble():4===t?n.readVarint64():5===t?n.readVarint():6===t?n.readSVarint():7===t?n.readBoolean():null;e.values.push(i)}}function xg(t,e,n){if(1==t)e.id=n.readVarint();else if(2==t){const t=n.readVarint()+n.pos;for(;n.pos<t;){const t=e.layer.keys[n.readVarint()],i=e.layer.values[n.readVarint()];e.properties[t]=i}}else 3==t?e.type=n.readVarint():4==t&&(e.geometry=n.pos)}function vg(t,e,n){t.pos=e.features[n];const i=t.readVarint()+t.pos,r={layer:e,type:0,properties:{}};return t.readFields(xg,r,i),r}class bg extends mi{constructor(t,e,n){super(),n=n||{},this.tileCoord=t,this.state=e,this.key="",this.transition_=void 0===n.transition?250:n.transition,this.transitionStarts_={},this.interpolate=!!n.interpolate}changed(){this.dispatchEvent(Vn)}release(){this.setState(nr)}getKey(){return this.key+"/"+this.tileCoord}getTileCoord(){return this.tileCoord}getState(){return this.state}setState(t){if(this.state!==nr){if(this.state!==er&&this.state>t)throw new Error("Tile load sequence violation");this.state=t,this.changed()}}load(){vi()}getAlpha(t,e){if(!this.transition_)return 1;let n=this.transitionStarts_[t];if(n){if(-1===n)return 1}else n=e,this.transitionStarts_[t]=n;const i=e-n+1e3/60;return i>=this.transition_?1:ws(i/this.transition_)}inTransition(t){return!!this.transition_&&-1!==this.transitionStarts_[t]}endTransition(t){this.transition_&&(this.transitionStarts_[t]=-1)}disposeInternal(){this.release(),super.disposeInternal()}}function wg(t){return t instanceof Image||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageBitmap?t:null}const Sg=new Error("disposed"),Cg=[256,256];class Eg extends bg{constructor(t){const e=Ji;super(t.tileCoord,e,{transition:t.transition,interpolate:t.interpolate}),this.loader_=t.loader,this.data_=null,this.error_=null,this.size_=t.size||null,this.controller_=t.controller||null}getSize(){if(this.size_)return this.size_;const t=wg(this.data_);return t?[t.width,t.height]:Cg}getData(){return this.data_}getError(){return this.error_}load(){if(this.state!==Ji&&this.state!==er)return;this.state=Qi,this.changed();const t=this;this.loader_().then(function(e){t.data_=e,t.state=tr,t.changed()}).catch(function(e){t.error_=e,t.state=er,t.changed()})}disposeInternal(){this.controller_&&(this.controller_.abort(Sg),this.controller_=null),super.disposeInternal()}}class Pg extends bg{constructor(t,e,n,i,r,s){super(t,e,s),this.crossOrigin_=i?.crossOrigin,this.referrerPolicy_=i?.referrerPolicy,this.src_=n,this.key=n,this.image_,Oi?this.image_=new OffscreenCanvas(1,1):(this.image_=new Image,null!==this.crossOrigin_&&(this.image_.crossOrigin=this.crossOrigin_),void 0!==this.referrerPolicy_&&(this.image_.referrerPolicy=this.referrerPolicy_)),this.unlisten_=null,this.tileLoadFunction_=r}getImage(){return this.image_}setImage(t){this.image_=t,this.state=tr,this.unlistenImage_(),this.changed()}getCrossOrigin(){return this.crossOrigin_}getReferrerPolicy(){return this.referrerPolicy_}handleImageError_(){this.state=er,this.unlistenImage_(),this.image_=function(){const t=Cl(1,1);return t.fillStyle="rgba(0,0,0,0)",t.fillRect(0,0,1,1),t.canvas}(),this.changed()}handleImageLoad_(){if(Oi)this.state=tr;else{const t=this.image_;t.naturalWidth&&t.naturalHeight?this.state=tr:this.state=nr}this.unlistenImage_(),this.changed()}load(){this.state==er&&(this.state=Ji,this.image_=new Image,null!==this.crossOrigin_&&(this.image_.crossOrigin=this.crossOrigin_),void 0!==this.referrerPolicy_&&(this.image_.referrerPolicy=this.referrerPolicy_)),this.state==Ji&&(this.state=Qi,this.changed(),this.tileLoadFunction_(this,this.src_),this.unlisten_=function(t,e,n){const i=t;let r=!0,s=!1,o=!1;const a=[Bn(i,ti,function(){o=!0,s||e()})];return i.src&&zi?(s=!0,i.decode().then(function(){r&&e()}).catch(function(t){r&&(o?e():n())})):a.push(Bn(i,Xn,n)),function(){r=!1,a.forEach(Un)}}(this.image_,this.handleImageLoad_.bind(this),this.handleImageError_.bind(this)))}unlistenImage_(){this.unlisten_&&(this.unlisten_(),this.unlisten_=null)}disposeInternal(){this.unlistenImage_(),this.image_=null,super.disposeInternal()}}class Tg{constructor(t,e,n,i){this.minX=t,this.maxX=e,this.minY=n,this.maxY=i}contains(t){return this.containsXY(t[1],t[2])}containsTileRange(t){return this.minX<=t.minX&&t.maxX<=this.maxX&&this.minY<=t.minY&&t.maxY<=this.maxY}containsXY(t,e){return this.minX<=t&&t<=this.maxX&&this.minY<=e&&e<=this.maxY}equals(t){return this.minX==t.minX&&this.minY==t.minY&&this.maxX==t.maxX&&this.maxY==t.maxY}extend(t){t.minX<this.minX&&(this.minX=t.minX),t.maxX>this.maxX&&(this.maxX=t.maxX),t.minY<this.minY&&(this.minY=t.minY),t.maxY>this.maxY&&(this.maxY=t.maxY)}getHeight(){return this.maxY-this.minY+1}getSize(){return[this.getWidth(),this.getHeight()]}getWidth(){return this.maxX-this.minX+1}intersects(t){return this.minX<=t.maxX&&this.maxX>=t.minX&&this.minY<=t.maxY&&this.maxY>=t.minY}}function Rg(t,e,n,i,r){return void 0!==r?(r.minX=t,r.maxX=e,r.minY=n,r.maxY=i,r):new Tg(t,e,n,i)}let Fg;const Mg=[];function Ig(t,e,n,i,r){t.beginPath(),t.moveTo(0,0),t.lineTo(e,n),t.lineTo(i,r),t.closePath(),t.save(),t.clip(),t.fillRect(0,0,Math.max(e,i)+1,Math.max(n,r)),t.restore()}function kg(t,e){return Math.abs(t[4*e]-210)>2||Math.abs(t[4*e+3]-191.25)>2}function Lg(t,e,n,i){const r=$o(n,e,t);let s=Io(e,i,n);const o=e.getMetersPerUnit();void 0!==o&&(s*=o);const a=t.getMetersPerUnit();void 0!==a&&(s/=a);const l=t.getExtent();if(!l||Ar(l,r)){const e=Io(t,s,r)/s;isFinite(e)&&e>0&&(s/=e)}return s}function Ag(t,e,n,i,r,s,o,a,l,h,c,u,d,f){const g=Cl(Math.round(n*t),Math.round(n*e),Mg);if(u||(g.imageSmoothingEnabled=!1),0===l.length)return g.canvas;function p(t){return Math.round(t*n)/n}g.scale(n,n),g.globalCompositeOperation="lighter";const m=[1/0,1/0,-1/0,-1/0];let _;l.forEach(function(t,e,n){Vr(m,t.extent)});const y=n/i,x=(u?1:1+Math.pow(2,-24))/y;d&&1===l.length&&0===h||(_=Cl(Math.round(os(m)*y),Math.round(ns(m)*y),Mg),u||(_.imageSmoothingEnabled=!1),l.forEach(function(t,e,n){if(t.image.width>0&&t.image.height>0){if(t.clipExtent){_.save();const e=(t.clipExtent[0]-m[0])*y,n=-(t.clipExtent[3]-m[3])*y,i=os(t.clipExtent)*y,r=ns(t.clipExtent)*y;_.rect(u?e:Math.round(e),u?n:Math.round(n),u?i:Math.round(e+i)-Math.round(e),u?r:Math.round(n+r)-Math.round(n)),_.clip()}const e=(t.extent[0]-m[0])*y,n=-(t.extent[3]-m[3])*y,i=os(t.extent)*y,r=ns(t.extent)*y;_.drawImage(t.image,h,h,t.image.width-2*h,t.image.height-2*h,u?e:Math.round(e),u?n:Math.round(n),u?i:Math.round(e+i)-Math.round(e),u?r:Math.round(n+r)-Math.round(n)),t.clipExtent&&_.restore()}}));const v=rs(o);return a.getTriangles().forEach(function(t,e,n){const i=t.source,r=t.target;let o=i[0][0],a=i[0][1],h=i[1][0],c=i[1][1],d=i[2][0],f=i[2][1];const y=p((r[0][0]-v[0])/s),b=p(-(r[0][1]-v[1])/s),w=p((r[1][0]-v[0])/s),S=p(-(r[1][1]-v[1])/s),C=p((r[2][0]-v[0])/s),E=p(-(r[2][1]-v[1])/s),P=o,T=a;o=0,a=0,h-=P,c-=T,d-=P,f-=T;const R=function(t){const e=t.length;for(let n=0;n<e;n++){let i=n,r=Math.abs(t[n][n]);for(let s=n+1;s<e;s++){const e=Math.abs(t[s][n]);e>r&&(r=e,i=s)}if(0===r)return null;const s=t[i];t[i]=t[n],t[n]=s;for(let i=n+1;i<e;i++){const r=-t[i][n]/t[n][n];for(let s=n;s<e+1;s++)n==s?t[i][s]=0:t[i][s]+=r*t[n][s]}}const n=new Array(e);for(let i=e-1;i>=0;i--){n[i]=t[i][e]/t[i][i];for(let r=i-1;r>=0;r--)t[r][e]-=t[r][i]*n[i]}return n}([[h,c,0,0,w-y],[d,f,0,0,C-y],[0,0,h,c,S-b],[0,0,d,f,E-b]]);if(!R)return;if(g.save(),g.beginPath(),function(){if(void 0===Fg){const t=Cl(6,6,Mg);t.globalCompositeOperation="lighter",t.fillStyle="rgba(210, 0, 0, 0.75)",Ig(t,4,5,4,0),Ig(t,4,5,0,5);const e=t.getImageData(0,0,3,3).data;Fg=kg(e,0)||kg(e,4)||kg(e,8),Tl(t),Mg.push(t.canvas)}return Fg}()||!u){g.moveTo(w,S);const t=4,e=y-w,n=b-S;for(let i=0;i<t;i++)g.lineTo(w+p((i+1)*e/t),S+p(i*n/(t-1))),i!=t-1&&g.lineTo(w+p((i+1)*e/t),S+p((i+1)*n/(t-1)));g.lineTo(C,E)}else g.moveTo(w,S),g.lineTo(y,b),g.lineTo(C,E);let F;if(g.clip(),g.transform(R[0],R[2],R[1],R[3],y,b),g.translate(m[0]-P,m[3]-T),_)F=_.canvas,g.scale(x,-x);else{const t=l[0],e=t.extent;F=t.image,g.scale(os(e)/F.width,-ns(e)/F.height)}g.drawImage(F,0,0),g.restore()}),_&&(Tl(_),Mg.push(_.canvas)),c&&(g.save(),g.globalCompositeOperation="source-over",g.strokeStyle="black",g.lineWidth=1,a.getTriangles().forEach(function(t,e,n){const i=t.target,r=(i[0][0]-v[0])/s,o=-(i[0][1]-v[1])/s,a=(i[1][0]-v[0])/s,l=-(i[1][1]-v[1])/s,h=(i[2][0]-v[0])/s,c=-(i[2][1]-v[1])/s;g.beginPath(),g.moveTo(a,l),g.lineTo(r,o),g.lineTo(h,c),g.closePath(),g.stroke()}),g.restore()),g.canvas}class Dg{constructor(t,e,n,i,r,s,o){this.sourceProj_=t,this.targetProj_=e;let a={};const l=o?Do(t=>ra(o,$o(t,this.targetProj_,this.sourceProj_))):Go(this.targetProj_,this.sourceProj_);this.transformInv_=function(t){const e=t[0]+"/"+t[1];return a[e]||(a[e]=l(t)),a[e]},this.maxSourceExtent_=i,this.errorThresholdSquared_=r*r,this.triangles_=[],this.wrapsXInSource_=!1,this.canWrapXInSource_=this.sourceProj_.canWrapX()&&!!i&&!!this.sourceProj_.getExtent()&&os(i)>=os(this.sourceProj_.getExtent()),this.sourceWorldWidth_=this.sourceProj_.getExtent()?os(this.sourceProj_.getExtent()):null,this.targetWorldWidth_=this.targetProj_.getExtent()?os(this.targetProj_.getExtent()):null;const h=rs(n),c=ss(n),u=Hr(n),d=Yr(n),f=this.transformInv_(h),g=this.transformInv_(c),p=this.transformInv_(u),m=this.transformInv_(d),_=10+(s?Math.max(0,Math.ceil(Math.log2(Kr(n)/(s*s*256*256)))):0);if(this.addQuad_(h,c,u,d,f,g,p,m,_),this.wrapsXInSource_){let t=1/0;this.triangles_.forEach(function(e,n,i){t=Math.min(t,e.source[0][0],e.source[1][0],e.source[2][0])}),this.triangles_.forEach(e=>{if(Math.max(e.source[0][0],e.source[1][0],e.source[2][0])-t>this.sourceWorldWidth_/2){const n=[[e.source[0][0],e.source[0][1]],[e.source[1][0],e.source[1][1]],[e.source[2][0],e.source[2][1]]];n[0][0]-t>this.sourceWorldWidth_/2&&(n[0][0]-=this.sourceWorldWidth_),n[1][0]-t>this.sourceWorldWidth_/2&&(n[1][0]-=this.sourceWorldWidth_),n[2][0]-t>this.sourceWorldWidth_/2&&(n[2][0]-=this.sourceWorldWidth_);const i=Math.min(n[0][0],n[1][0],n[2][0]);Math.max(n[0][0],n[1][0],n[2][0])-i<this.sourceWorldWidth_/2&&(e.source=n)}})}a={}}addTriangle_(t,e,n,i,r,s){this.triangles_.push({source:[i,r,s],target:[t,e,n]})}addQuad_(t,e,n,i,r,s,o,a,l){const h=Mr([r,s,o,a]),c=this.sourceWorldWidth_?os(h)/this.sourceWorldWidth_:null,u=this.sourceWorldWidth_,d=this.sourceProj_.canWrapX()&&c>.5&&c<1;let f=!1;if(l>0){if(this.targetProj_.isGlobal()&&this.targetWorldWidth_){f=os(Mr([t,e,n,i]))/this.targetWorldWidth_>.25||f}!d&&this.sourceProj_.isGlobal()&&c&&(f=c>.25||f)}if(!f&&this.maxSourceExtent_&&isFinite(h[0])&&isFinite(h[1])&&isFinite(h[2])&&isFinite(h[3])&&!as(h,this.maxSourceExtent_))return;let g=0;if(!(f||isFinite(r[0])&&isFinite(r[1])&&isFinite(s[0])&&isFinite(s[1])&&isFinite(o[0])&&isFinite(o[1])&&isFinite(a[0])&&isFinite(a[1])))if(l>0)f=!0;else if(g=(isFinite(r[0])&&isFinite(r[1])?0:8)+(isFinite(s[0])&&isFinite(s[1])?0:4)+(isFinite(o[0])&&isFinite(o[1])?0:2)+(isFinite(a[0])&&isFinite(a[1])?0:1),1!=g&&2!=g&&4!=g&&8!=g)return;if(l>0){if(!f){const e=[(t[0]+n[0])/2,(t[1]+n[1])/2],i=this.transformInv_(e);let s;if(d){s=(pr(r[0],u)+pr(o[0],u))/2-pr(i[0],u)}else s=(r[0]+o[0])/2-i[0];const a=(r[1]+o[1])/2-i[1];f=s*s+a*a>this.errorThresholdSquared_}if(f){if(Math.abs(t[0]-n[0])<=Math.abs(t[1]-n[1])){const h=[(e[0]+n[0])/2,(e[1]+n[1])/2],c=this.transformInv_(h),u=[(i[0]+t[0])/2,(i[1]+t[1])/2],d=this.transformInv_(u);this.addQuad_(t,e,h,u,r,s,c,d,l-1),this.addQuad_(u,h,n,i,d,c,o,a,l-1)}else{const h=[(t[0]+e[0])/2,(t[1]+e[1])/2],c=this.transformInv_(h),u=[(n[0]+i[0])/2,(n[1]+i[1])/2],d=this.transformInv_(u);this.addQuad_(t,h,u,i,r,c,d,a,l-1),this.addQuad_(h,e,n,u,c,s,o,d,l-1)}return}}if(d){if(!this.canWrapXInSource_)return;this.wrapsXInSource_=!0}11&g||this.addTriangle_(t,n,i,r,o,a),14&g||this.addTriangle_(t,n,e,r,o,s),g&&(13&g||this.addTriangle_(e,i,t,s,a,r),7&g||this.addTriangle_(e,i,n,s,a,o))}calculateSourceExtent(){const t=[1/0,1/0,-1/0,-1/0];return this.triangles_.forEach(function(e,n,i){const r=e.source;Xr(t,r[0]),Xr(t,r[1]),Xr(t,r[2])}),t}getTriangles(){return this.triangles_}}class Og extends bg{constructor(t,e,n,i,r,s,o,a,l,h,c,u){super(r,Ji,u),this.renderEdges_=void 0!==c&&c,this.pixelRatio_=o,this.gutter_=a,this.canvas_=null,this.sourceTileGrid_=e,this.targetTileGrid_=i,this.wrappedTileCoord_=s||r,this.sourceTiles_=[],this.sourcesListenerKeys_=null,this.sourceZ_=0,this.clipExtent_=t.canWrapX()?t.getExtent():void 0;const d=i.getTileCoordExtent(this.wrappedTileCoord_),f=this.targetTileGrid_.getExtent();let g=this.sourceTileGrid_.getExtent();const p=f?is(d,f):d;if(0===Kr(p))return void(this.state=nr);const m=t.getExtent();m&&(g=g?is(g,m):m);const _=i.getResolution(this.wrappedTileCoord_[0]),y=function(t,e,n,i){const r=Jr(n);let s=Lg(t,e,r,i);return(!isFinite(s)||s<=0)&&Zr(n,function(n){return s=Lg(t,e,n,i),isFinite(s)&&s>0}),s}(t,n,p,_);if(!isFinite(y)||y<=0)return void(this.state=nr);const x=void 0!==h?h:.5;if(this.triangulation_=new Dg(t,n,p,g,y*x,_),0===this.triangulation_.getTriangles().length)return void(this.state=nr);this.sourceZ_=e.getZForResolution(y);let v=this.triangulation_.calculateSourceExtent();if(g&&(t.canWrapX()?(v[1]=cr(v[1],g[1],g[3]),v[3]=cr(v[3],g[1],g[3])):v=is(v,g)),Kr(v)){let n=0,i=0;t.canWrapX()&&(n=os(m),i=Math.floor((v[0]-m[0])/n));us(v.slice(),t,!0).forEach(t=>{const r=e.getTileRangeForExtentAndZ(t,this.sourceZ_);for(let t=r.minX;t<=r.maxX;t++)for(let e=r.minY;e<=r.maxY;e++){const r=i*n;this.sourceTiles_.push({getTile:()=>l(this.sourceZ_,t,e,o),offset:r})}++i}),0===this.sourceTiles_.length&&(this.state=nr)}else this.state=nr}getImage(){return this.canvas_}reproject_(){const t=[];if(this.sourceTiles_.forEach(e=>{const n=e.tile;if(n&&n.getState()==tr){const i=this.sourceTileGrid_.getTileCoordExtent(n.tileCoord);i[0]+=e.offset,i[2]+=e.offset;const r=this.clipExtent_?.slice();r&&(r[0]+=e.offset,r[2]+=e.offset),t.push({extent:i,clipExtent:r,image:n.getImage()})}}),this.sourceTiles_.length=0,0===t.length)this.state=er;else{const e=this.wrappedTileCoord_[0],n=this.targetTileGrid_.getTileSize(e),i="number"==typeof n?n:n[0],r="number"==typeof n?n:n[1],s=this.targetTileGrid_.getResolution(e),o=this.sourceTileGrid_.getResolution(this.sourceZ_),a=this.targetTileGrid_.getTileCoordExtent(this.wrappedTileCoord_);this.canvas_=Ag(i,r,this.pixelRatio_,o,this.sourceTileGrid_.getExtent(),s,a,this.triangulation_,t,this.gutter_,this.renderEdges_,this.interpolate),this.state=tr}this.changed()}load(){for(const t of this.sourceTiles_)t.tile=t.getTile();if(this.state==Ji){this.state=Qi,this.changed();let t=0;this.sourcesListenerKeys_=[],this.sourceTiles_.forEach(({tile:e})=>{const n=e.getState();if(n==Ji||n==Qi){t++;const n=$n(e,Vn,i=>{const r=e.getState();r!=tr&&r!=er&&r!=nr||(Un(n),t--,0===t&&(this.unlistenSources_(),this.reproject_()))});this.sourcesListenerKeys_.push(n)}}),0===t?setTimeout(this.reproject_.bind(this),0):this.sourceTiles_.forEach(function({tile:t},e,n){t.getState()==Ji&&t.load()})}}unlistenSources_(){this.sourcesListenerKeys_.forEach(Un),this.sourcesListenerKeys_=null}release(){this.canvas_&&(Tl(this.canvas_.getContext("2d")),Mg.push(this.canvas_),this.canvas_=null),this.sourceTiles_.length=0,super.release()}}class zg{constructor(t){this.highWaterMark=void 0!==t?t:2048,this.count_=0,this.entries_={},this.oldest_=null,this.newest_=null}deleteOldest(){const t=this.pop();t instanceof ii&&t.dispose()}canExpireCache(){return this.highWaterMark>0&&this.getCount()>this.highWaterMark}expireCache(t){for(;this.canExpireCache();)this.deleteOldest()}clear(){for(;this.oldest_;)this.deleteOldest()}containsKey(t){return this.entries_.hasOwnProperty(t)}forEach(t){let e=this.oldest_;for(;e;)t(e.value_,e.key_,this),e=e.newer}get(t,e){const n=this.entries_[t];return ir(void 0!==n,"Tried to get a value for a key that does not exist in the cache"),n===this.newest_||(n===this.oldest_?(this.oldest_=this.oldest_.newer,this.oldest_.older=null):(n.newer.older=n.older,n.older.newer=n.newer),n.newer=null,n.older=this.newest_,this.newest_.newer=n,this.newest_=n),n.value_}remove(t){const e=this.entries_[t];return ir(void 0!==e,"Tried to get a value for a key that does not exist in the cache"),e===this.newest_?(this.newest_=e.older,this.newest_&&(this.newest_.newer=null)):e===this.oldest_?(this.oldest_=e.newer,this.oldest_&&(this.oldest_.older=null)):(e.newer.older=e.older,e.older.newer=e.newer),delete this.entries_[t],--this.count_,e.value_}getCount(){return this.count_}getKeys(){const t=new Array(this.count_);let e,n=0;for(e=this.newest_;e;e=e.older)t[n++]=e.key_;return t}getValues(){const t=new Array(this.count_);let e,n=0;for(e=this.newest_;e;e=e.older)t[n++]=e.value_;return t}peekLast(){return this.oldest_.value_}peekLastKey(){return this.oldest_.key_}peekFirstKey(){return this.newest_.key_}peek(t){return this.entries_[t]?.value_}pop(){const t=this.oldest_;return delete this.entries_[t.key_],t.newer&&(t.newer.older=null),this.oldest_=t.newer,this.oldest_||(this.newest_=null),--this.count_,t.value_}replace(t,e){this.get(t),this.entries_[t].value_=e}set(t,e){ir(!(t in this.entries_),"Tried to set a value for a key that is used already");const n={key_:t,newer:null,older:this.newest_,value_:e};this.newest_?this.newest_.newer=n:this.oldest_=n,this.newest_=n,this.entries_[t]=n,++this.count_}setSize(t){this.highWaterMark=t}}function Ng(t,e,n,i){return void 0!==i?(i[0]=t,i[1]=e,i[2]=n,i):[t,e,n]}function jg(t,e,n,i,r){return`${wi(t)},${e},${function(t,e,n){return t+"/"+e+"/"+n}(n,i,r)}`}function Gg(t){return e=t[0],n=t[1],i=t[2],(n<<e)+i;var e,n,i}class $g{constructor(){this.instructions_=[],this.zIndex=0,this.offset_=0,this.context_=new Proxy(Pl(),{get:(t,e)=>{if("function"==typeof Pl()[e])return this.push_(e),this.pushMethodArgs_},set:(t,e,n)=>(this.push_(e,n),!0)})}push_(...t){const e=this.instructions_,n=this.zIndex+this.offset_;e[n]||(e[n]=[]),e[n].push(...t)}pushMethodArgs_=(...t)=>(this.push_(t),this);pushFunction(t){this.push_(t)}getContext(){return this.context_}draw(t){this.instructions_.forEach(e=>{for(let n=0,i=e.length;n<i;++n){const i=e[n];if("function"==typeof i){i(t);continue}const r=e[++n];if("function"==typeof t[i])t[i](...r);else{if("function"==typeof r){t[i]=r(t);continue}t[i]=r}}})}clear(){this.instructions_.length=0,this.zIndex=0,this.offset_=0}offset(){this.offset_=this.instructions_.length,this.zIndex=0}}class Bg extends _i{constructor(t){super(),this.ready=!0,this.boundHandleImageChange_=this.handleImageChange_.bind(this),this.layer_=t,this.staleKeys_=new Array,this.maxStaleKeys=5}getStaleKeys(){return this.staleKeys_}prependStaleKey(t){this.staleKeys_.unshift(t),this.staleKeys_.length>this.maxStaleKeys&&(this.staleKeys_.length=this.maxStaleKeys)}getFeatures(t){return vi()}getData(t){return null}prepareFrame(t){return vi()}renderFrame(t,e){return vi()}forEachFeatureAtCoordinate(t,e,n,i,r){}getLayer(){return this.layer_}handleFontsChanged(){}handleImageChange_(t){const e=t.target;e.getState()!==od&&e.getState()!==ad||this.renderIfReadyAndVisible()}loadImage(t){let e=t.getState();return e!=od&&e!=ad&&t.addEventListener(Vn,this.boundHandleImageChange_),e==rd&&(t.load(),e=t.getState()),e==od}renderIfReadyAndVisible(){const t=this.getLayer();t&&t.getVisible()&&"ready"===t.getSourceState()&&t.changed()}renderDeferred(t){}disposeInternal(){delete this.layer_,super.disposeInternal()}}const Ug=[];let Vg=null;class Xg extends Bg{constructor(t){super(t),this.container=null,this.renderedResolution,this.tempTransform=[1,0,0,1,0,0],this.pixelTransform=[1,0,0,1,0,0],this.inversePixelTransform=[1,0,0,1,0,0],this.context=null,this.deferredContext_=null,this.containerReused=!1,this.frameState=null}getImageData(t,e,n){let i;Vg||(Vg=Cl(1,1,void 0,{willReadFrequently:!0})),Vg.clearRect(0,0,1,1);try{Vg.drawImage(t,e,n,1,1,0,0,1,1),i=Vg.getImageData(0,0,1,1).data}catch{return Vg=null,null}return i}getBackground(t){let e=this.getLayer().getBackground();return"function"==typeof e&&(e=e(t.viewState.resolution)),e||void 0}useContainer(t,e,n){const i=this.getLayer().getClassName();let r,s;if(t&&t.className===i&&(!n||t&&t.style.backgroundColor&&hi(Mc(t.style.backgroundColor),Mc(n)))){const e=t.firstElementChild;Ll(e)&&(s=e.getContext("2d"))}if(s&&function(t,e){const n=ca(t),i=ca(e);for(let t=0;t<6;++t)if(0!==Math.round((n[t]-i[t])*ha[t]))return!1;return!0}(s.canvas.style.transform,e)?(this.container=t,this.context=s,this.containerReused=!0):this.containerReused?(this.container=null,this.context=null,this.containerReused=!1):this.container&&(this.container.style.backgroundColor=null),!this.container){r=Oi?kl():document.createElement("div"),r.className=i;let t=r.style;t.position="absolute",t.width="100%",t.height="100%",s=Cl();const e=s.canvas;r.appendChild(e),t=e.style,t.position="absolute",t.left="0",t.transformOrigin="top left",this.container=r,this.context=s}this.containerReused||!n||this.container.style.backgroundColor||(this.container.style.backgroundColor=n)}clipUnrotated(t,e,n){const i=rs(n),r=ss(n),s=Hr(n),o=Yr(n);ra(e.coordinateToPixelTransform,i),ra(e.coordinateToPixelTransform,r),ra(e.coordinateToPixelTransform,s),ra(e.coordinateToPixelTransform,o);const a=this.inversePixelTransform;ra(a,i),ra(a,r),ra(a,s),ra(a,o),t.save(),t.beginPath(),t.moveTo(Math.round(i[0]),Math.round(i[1])),t.lineTo(Math.round(r[0]),Math.round(r[1])),t.lineTo(Math.round(s[0]),Math.round(s[1])),t.lineTo(Math.round(o[0]),Math.round(o[1])),t.clip()}prepareContainer(t,e){const n=t.extent,i=t.viewState.resolution,r=t.viewState.rotation,s=t.pixelRatio,o=Math.round(os(n)/i*s),a=Math.round(ns(n)/i*s);aa(this.pixelTransform,t.size[0]/2,t.size[1]/2,1/s,1/s,r,-o/2,-a/2),la(this.inversePixelTransform,this.pixelTransform);const l="matrix("+this.pixelTransform.join(", ")+")";if(this.useContainer(e,l,this.getBackground(t)),!this.containerReused){const t=this.context.canvas;t.width!=o||t.height!=a?(t.width=o,t.height=a):this.context.clearRect(0,0,o,a),l!==t.style.transform&&(t.style.transform=l)}}dispatchRenderEvent_(t,e,n){const i=this.getLayer();if(i.hasListener(t)){const r=new Ef(t,this.inversePixelTransform,n,e);i.dispatchEvent(r)}}preRender(t,e){this.frameState=e,e.declutter||this.dispatchRenderEvent_($h,t,e)}postRender(t,e){e.declutter||this.dispatchRenderEvent_(Bh,t,e)}renderDeferredInternal(t){}getRenderContext(t){return t.declutter&&!this.deferredContext_&&(this.deferredContext_=new $g),t.declutter?this.deferredContext_.getContext():this.context}renderDeferred(t){t.declutter&&(this.dispatchRenderEvent_($h,this.context,t),t.declutter&&this.deferredContext_&&(this.deferredContext_.draw(this.context),this.deferredContext_.clear()),this.renderDeferredInternal(t),this.dispatchRenderEvent_(Bh,this.context,t))}getRenderTransform(t,e,n,i,r,s,o){const a=r/2,l=s/2,h=i/e,c=-h,u=-t[0]+o,d=-t[1];return aa(this.tempTransform,a,l,h,c,-n,u,d)}disposeInternal(){delete this.frameState,super.disposeInternal()}}function Wg(t,e,n){if(!(n in t))return t[n]=new Set([e]),!0;const i=t[n],r=i.has(e);return r||i.add(e),!r}function qg(t,e,n){const i=t[n];return!!i&&i.delete(e)}function Zg(t,e){const n=t.layerStatesArray[t.layerIndex];n.extent&&(e=is(e,Ko(n.extent,t.viewState.projection)));const i=n.layer.getRenderSource();if(!i.getWrapX()){const n=i.getTileGridForProjection(t.viewState.projection).getExtent();n&&(e=is(e,n))}return e}class Kg extends Xg{constructor(t,e){super(t),e=e||{},this.extentChanged=!0,this.renderComplete=!1,this.renderedExtent_=null,this.renderedPixelRatio,this.renderedProjection=null,this.renderedTiles=[],this.renderedSourceKey_,this.renderedSourceRevision_,this.tempExtent=[1/0,1/0,-1/0,-1/0],this.tempTileRange_=new Tg(0,0,0,0),this.tempTileCoord_=Ng(0,0,0);const n=void 0!==e.cacheSize?e.cacheSize:512;this.tileCache_=new zg(n),this.sourceTileCache_=null,this.layerExtent=null,this.maxStaleKeys=.5*n}getTileCache(){return this.tileCache_}getSourceTileCache(){return this.sourceTileCache_||(this.sourceTileCache_=new zg(512)),this.sourceTileCache_}getOrCreateTile(t,e,n,i){const r=this.tileCache_,s=this.getLayer().getSource(),o=jg(s,s.getKey(),t,e,n);let a;if(r.containsKey(o))a=r.get(o);else{const l=i.viewState.projection,h=s.getProjection();if(a=s.getTile(t,e,n,i.pixelRatio,l,!h||zo(h,l)?void 0:this.getSourceTileCache()),!a)return null;r.set(o,a)}return a}getTile(t,e,n,i){const r=this.getOrCreateTile(t,e,n,i);return r||null}getData(t){const e=this.frameState;if(!e)return null;const n=this.getLayer(),i=ra(e.pixelToCoordinateTransform,t.slice()),r=n.getExtent();if(r&&!Ar(r,i))return null;const s=e.viewState,o=n.getRenderSource(),a=o.getTileGridForProjection(s.projection),l=o.getTilePixelRatio(e.pixelRatio);for(let t=a.getZForResolution(s.resolution);t>=a.getMinZoom();--t){const n=a.getTileCoordForCoordAndZ(i,t),r=this.getTile(t,n[1],n[2],e);if(!r||r.getState()!==tr)continue;const h=a.getOrigin(t),c=Lc(a.getTileSize(t)),u=a.getResolution(t);let d;if(r instanceof Pg||r instanceof Og)d=r.getImage();else{if(!(r instanceof Eg))continue;if(d=wg(r.getData()),!d)continue}const f=Math.floor(l*((i[0]-h[0])/u-n[1]*c[0])),g=Math.floor(l*((h[1]-i[1])/u-n[2]*c[1])),p=Math.round(l*o.getGutterForProjection(s.projection));return this.getImageData(d,f+p,g+p)}return null}prepareFrame(t){this.renderedProjection?t.viewState.projection!==this.renderedProjection&&(this.tileCache_.clear(),this.renderedProjection=t.viewState.projection):this.renderedProjection=t.viewState.projection;const e=this.getLayer().getSource();if(!e)return!1;const n=e.getRevision();return this.renderedSourceRevision_?this.renderedSourceRevision_!==n&&(this.renderedSourceRevision_=n,this.renderedSourceKey_===e.getKey()&&(this.tileCache_.clear(),this.sourceTileCache_?.clear())):this.renderedSourceRevision_=n,!0}enqueueTilesForNextExtent(){return!0}enqueueTiles(t,e,n,i,r){const s=t.viewState,o=this.getLayer(),a=o.getRenderSource(),l=a.getTileGridForProjection(s.projection),h=wi(a);h in t.wantedTiles||(t.wantedTiles[h]={});const c=t.wantedTiles[h],u=o.getMapInternal(),d=Math.max(n-r,l.getMinZoom(),l.getZForResolution(Math.min(o.getMaxResolution(),u?u.getView().getResolutionForZoom(Math.max(o.getMinZoom(),0)):l.getResolution(0)),a.zDirection)),f=s.rotation,g=f?es(s.center,s.resolution,f,t.size):void 0;for(let r=n;r>=d;--r){const n=l.getTileRangeForExtentAndZ(e,r,this.tempTileRange_),s=l.getResolution(r);for(let e=n.minX;e<=n.maxX;++e)for(let o=n.minY;o<=n.maxY;++o){if(f&&!l.tileCoordIntersectsViewport([r,e,o],g))continue;const n=this.getTile(r,e,o,t);if(!n)continue;if(!Wg(i,n,r))continue;const a=n.getKey();if(c[a]=!0,n.getState()===Ji&&!t.tileQueue.isKeyQueued(a)){const i=Ng(r,e,o,this.tempTileCoord_);t.tileQueue.enqueue([n,h,l.getTileCoordCenter(i),s])}}}}findStaleTile_(t,e){const n=this.tileCache_,i=t[0],r=t[1],s=t[2],o=this.getStaleKeys();for(let t=0;t<o.length;++t){const a=jg(this.getLayer().getSource(),o[t],i,r,s);if(n.containsKey(a)){const t=n.peek(a);if(t.getState()===tr)return t.endTransition(wi(this)),Wg(e,t,i),!0}}return!1}findAltTiles_(t,e,n,i){const r=t.getTileRangeForTileCoordAndZ(e,n,this.tempTileRange_);if(!r)return!1;let s=!0;const o=this.tileCache_,a=this.getLayer().getRenderSource(),l=a.getKey();for(let t=r.minX;t<=r.maxX;++t)for(let e=r.minY;e<=r.maxY;++e){const r=jg(a,l,n,t,e);let h=!1;if(o.containsKey(r)){const t=o.peek(r);t.getState()===tr&&(Wg(i,t,n),h=!0)}h||(s=!1)}return s}renderFrame(t,e){this.renderComplete=!0;const n=t.layerStatesArray[t.layerIndex],i=t.viewState,r=i.projection,s=i.resolution,o=i.center,a=t.pixelRatio,l=this.getLayer(),h=l.getSource(),c=h.getTileGridForProjection(r),u=c.getZForResolution(s,h.zDirection),d=c.getResolution(u),f=h.getKey();this.renderedSourceKey_?this.renderedSourceKey_!==f&&(this.prependStaleKey(this.renderedSourceKey_),this.renderedSourceKey_=f):this.renderedSourceKey_=f;let g=t.extent;const p=h.getTilePixelRatio(a);this.prepareContainer(t,e);const m=this.context.canvas.width,_=this.context.canvas.height;this.layerExtent=n.extent?Ko(n.extent,r):null,this.layerExtent&&(g=is(g,this.layerExtent));const y=d*m/2/p,x=d*_/2/p,v=[o[0]-y,o[1]-x,o[0]+y,o[1]+x],b={};this.renderedTiles.length=0;const w=l.getPreload();if(t.nextExtent&&this.enqueueTilesForNextExtent()){const e=c.getZForResolution(i.nextResolution,h.zDirection),n=Zg(t,t.nextExtent);this.enqueueTiles(t,n,e,b,w)}const S=Zg(t,g);if(this.enqueueTiles(t,S,u,b,0),w>0&&setTimeout(()=>{this.enqueueTiles(t,S,u-1,b,w-1)},0),!(u in b))return this.container;const C=wi(this),E=t.time;for(const e of b[u]){const n=e.getState();if(n===nr)continue;const i=e.tileCoord;if(n===tr){if(1===e.getAlpha(C,E)){e.endTransition(C);continue}}n!==er&&(this.renderComplete=!1);if(this.findStaleTile_(i,b)){qg(b,e,u),t.animate=!0;continue}if(this.findAltTiles_(c,i,u+1,b))continue;const r=c.getMinZoom();for(let t=u-1;t>=r;--t){if(this.findAltTiles_(c,i,t,b))break}}const P=d/s*a/p,T=this.getRenderContext(t);aa(this.tempTransform,m/2,_/2,P,P,0,-m/2,-_/2),this.layerExtent&&this.clipUnrotated(T,t,this.layerExtent),h.getInterpolate()||(T.imageSmoothingEnabled=!1),this.preRender(T,t);const R=Object.keys(b).map(Number);let F;R.sort(ri);const M=[],I=[];for(let e=R.length-1;e>=0;--e){const n=R[e],i=h.getTilePixelSize(n,a,r),s=c.getResolution(n)/d,o=i[0]*s*P,l=i[1]*s*P,u=c.getTileCoordForCoordAndZ(rs(v),n),f=c.getTileCoordExtent(u),g=ra(this.tempTransform,[p*(f[0]-v[0])/d,p*(v[3]-f[3])/d]),m=p*h.getGutterForProjection(r);for(const e of b[n]){if(e.getState()!==tr)continue;const i=e.tileCoord,r=u[1]-i[1],s=Math.round(g[0]-(r-1)*o),a=u[2]-i[2],c=Math.round(g[1]-(a-1)*l),d=Math.round(g[0]-r*o),f=Math.round(g[1]-a*l),p=s-d,_=c-f,y=1===R.length;let x=!1;F=[d,f,d+p,f,d+p,f+_,d,f+_];for(let t=0,e=M.length;t<e;++t)if(!y&&n<I[t]){const e=M[t];as([d,f,d+p,f+_],[e[0],e[3],e[4],e[7]])&&(x||(T.save(),x=!0),T.beginPath(),T.moveTo(F[0],F[1]),T.lineTo(F[2],F[3]),T.lineTo(F[4],F[5]),T.lineTo(F[6],F[7]),T.moveTo(e[6],e[7]),T.lineTo(e[4],e[5]),T.lineTo(e[2],e[3]),T.lineTo(e[0],e[1]),T.clip())}M.push(F),I.push(n),this.drawTile(e,t,d,f,p,_,m,y),x&&T.restore(),this.renderedTiles.unshift(e),this.updateUsedTiles(t.usedTiles,h,e)}}if(this.renderedResolution=d,this.extentChanged=!this.renderedExtent_||!Ur(this.renderedExtent_,v),this.renderedExtent_=v,this.renderedPixelRatio=a,this.postRender(this.context,t),this.layerExtent&&T.restore(),T.imageSmoothingEnabled=!0,this.renderComplete){const e=(t,e)=>{const n=wi(h),i=e.wantedTiles[n],r=i?Object.keys(i).length:0;this.updateCacheSize(r),this.tileCache_.expireCache(),this.sourceTileCache_?.expireCache()};t.postRenderFunctions.push(e)}return this.container}updateCacheSize(t){this.tileCache_.highWaterMark=Math.max(this.tileCache_.highWaterMark,2*t)}drawTile(t,e,n,i,r,s,o,a){let l;if(t instanceof Eg){if(l=wg(t.getData()),!l)throw new Error("Rendering array data is not yet supported")}else l=this.getTileImage(t);if(!l)return;const h=this.getRenderContext(e),c=wi(this),u=e.layerStatesArray[e.layerIndex],d=u.opacity*(a?t.getAlpha(c,e.time):1),f=d!==h.globalAlpha;f&&(h.save(),h.globalAlpha=d),h.drawImage(l,o,o,l.width-2*o,l.height-2*o,n,i,r,s),f&&h.restore(),d!==u.opacity?e.animate=!0:a&&t.endTransition(c)}getImage(){const t=this.context;return t?t.canvas:null}getTileImage(t){return t.getImage()}updateUsedTiles(t,e,n){const i=wi(e);i in t||(t[i]={}),t[i][n.getKey()]=!0}}var Yg="preload",Hg="useInterimTilesOnError";class Jg extends Wh{constructor(t){t=t||{};const e=Object.assign({},t),n=t.cacheSize;delete t.cacheSize,delete e.preload,delete e.useInterimTilesOnError,super(e),this.on,this.once,this.un,this.cacheSize_=n,this.setPreload(void 0!==t.preload?t.preload:0),this.setUseInterimTilesOnError(void 0===t.useInterimTilesOnError||t.useInterimTilesOnError)}getCacheSize(){return this.cacheSize_}getPreload(){return this.get(Yg)}setPreload(t){this.set(Yg,t)}getUseInterimTilesOnError(){return this.get(Hg)}setUseInterimTilesOnError(t){this.set(Hg,t)}getData(t){return super.getData(t)}}class Qg extends Jg{constructor(t){super(t)}createRenderer(){return new Kg(this,{cacheSize:this.getCacheSize()})}}class tp{drawCustom(t,e,n,i,r){}drawGeometry(t){}setStyle(t){}drawCircle(t,e,n){}drawFeature(t,e,n){}drawGeometryCollection(t,e,n){}drawLineString(t,e,n){}drawMultiLineString(t,e,n){}drawMultiPoint(t,e,n){}drawMultiPolygon(t,e,n){}drawPoint(t,e,n){}drawPolygon(t,e,n){}drawText(t,e,n){}setFillStrokeStyle(t,e){}setImageStyle(t,e){}setTextStyle(t,e){}}const ep=0,np=1,ip=2,rp=3,sp=4,op=5,ap=6,lp=7,hp=8,cp=9,up=10,dp=11,fp=12,gp=[hp],pp=[fp],mp=[np],_p=[rp];class yp extends tp{constructor(t,e,n,i){super(),this.tolerance=t,this.maxExtent=e,this.pixelRatio=i,this.maxLineWidth=0,this.resolution=n,this.beginGeometryInstruction1_=null,this.beginGeometryInstruction2_=null,this.bufferedMaxExtent_=null,this.instructions=[],this.coordinates=[],this.tmpCoordinate_=[],this.hitDetectionInstructions=[],this.state={}}applyPixelRatio(t){const e=this.pixelRatio;return 1==e?t:t.map(function(t){return t*e})}appendFlatPointCoordinates(t,e){const n=this.getBufferedMaxExtent(),i=this.tmpCoordinate_,r=this.coordinates;let s=r.length;for(let o=0,a=t.length;o<a;o+=e)i[0]=t[o],i[1]=t[o+1],Ar(n,i)&&(r[s++]=i[0],r[s++]=i[1]);return s}appendFlatLineCoordinates(t,e,n,i,r,s){const o=this.coordinates;let a=o.length;const l=this.getBufferedMaxExtent();s&&(e+=i);let h=t[e],c=t[e+1];const u=this.tmpCoordinate_;let d,f,g,p=!0;for(d=e+i;d<n;d+=i)u[0]=t[d],u[1]=t[d+1],g=zr(l,u),g!==f?(p&&(o[a++]=h,o[a++]=c,p=!1),o[a++]=u[0],o[a++]=u[1]):g===Er?(o[a++]=u[0],o[a++]=u[1],p=!1):p=!0,h=u[0],c=u[1],f=g;return(r&&p||d===e+i)&&(o[a++]=h,o[a++]=c),a}drawCustomCoordinates_(t,e,n,i,r){for(let s=0,o=n.length;s<o;++s){const o=n[s],a=this.appendFlatLineCoordinates(t,e,o,i,!1,!1);r.push(a),e=o}return e}drawCustom(t,e,n,i,r){this.beginGeometry(t,e,r);const s=t.getType(),o=t.getStride(),a=this.coordinates.length;let l,h,c,u,d;switch(s){case"MultiPolygon":l=t.getOrientedFlatCoordinates(),u=[];const e=t.getEndss();d=0;for(let t=0,n=e.length;t<n;++t){const n=[];d=this.drawCustomCoordinates_(l,d,e[t],o,n),u.push(n)}this.instructions.push([sp,a,u,t,n,ka,r]),this.hitDetectionInstructions.push([sp,a,u,t,i||n,ka,r]);break;case"Polygon":case"MultiLineString":c=[],l="Polygon"==s?t.getOrientedFlatCoordinates():t.getFlatCoordinates(),d=this.drawCustomCoordinates_(l,0,t.getEnds(),o,c),this.instructions.push([sp,a,c,t,n,Ia,r]),this.hitDetectionInstructions.push([sp,a,c,t,i||n,Ia,r]);break;case"LineString":case"Circle":l=t.getFlatCoordinates(),h=this.appendFlatLineCoordinates(l,0,l.length,o,!1,!1),this.instructions.push([sp,a,h,t,n,Ma,r]),this.hitDetectionInstructions.push([sp,a,h,t,i||n,Ma,r]);break;case"MultiPoint":l=t.getFlatCoordinates(),h=this.appendFlatPointCoordinates(l,o),h>a&&(this.instructions.push([sp,a,h,t,n,Ma,r]),this.hitDetectionInstructions.push([sp,a,h,t,i||n,Ma,r]));break;case"Point":l=t.getFlatCoordinates(),this.coordinates.push(l[0],l[1]),h=this.coordinates.length,this.instructions.push([sp,a,h,t,n,void 0,r]),this.hitDetectionInstructions.push([sp,a,h,t,i||n,void 0,r])}this.endGeometry(e)}beginGeometry(t,e,n){this.beginGeometryInstruction1_=[ep,e,0,t,n],this.instructions.push(this.beginGeometryInstruction1_),this.beginGeometryInstruction2_=[ep,e,0,t,n],this.hitDetectionInstructions.push(this.beginGeometryInstruction2_)}finish(){return{instructions:this.instructions,hitDetectionInstructions:this.hitDetectionInstructions,coordinates:this.coordinates}}reverseHitDetectionInstructions(){const t=this.hitDetectionInstructions;let e;t.reverse();const n=t.length;let i,r,s=-1;for(e=0;e<n;++e)i=t[e],r=i[0],r==lp?s=e:r==ep&&(i[2]=e,ai(this.hitDetectionInstructions,s,e),s=-1)}fillStyleToState(t,e={}){if(t){const n=t.getColor();e.fillPatternScale=n&&"object"==typeof n&&"src"in n?this.pixelRatio:1,e.fillStyle=_d(n||xd)??void 0}else e.fillStyle=void 0;return e}strokeStyleToState(t,e={}){if(t){const n=t.getColor();e.strokeStyle=_d(n||Sd);const i=t.getLineCap();e.lineCap=void 0!==i?i:vd;const r=t.getLineDash();e.lineDash=r?r.slice():bd;const s=t.getLineDashOffset();e.lineDashOffset=s||0;const o=t.getLineJoin();e.lineJoin=void 0!==o?o:wd;const a=t.getWidth();e.lineWidth=void 0!==a?a:1;const l=t.getMiterLimit();e.miterLimit=void 0!==l?l:10;const h=t.getOffset();e.strokeOffset=h??0,e.lineWidth>this.maxLineWidth&&(this.maxLineWidth=e.lineWidth,this.bufferedMaxExtent_=null)}else e.strokeStyle=void 0,e.lineCap=void 0,e.lineDash=null,e.lineDashOffset=void 0,e.lineJoin=void 0,e.lineWidth=void 0,e.miterLimit=void 0,e.strokeOffset=void 0;return e}setFillStrokeStyle(t,e){const n=this.state;this.fillStyleToState(t,n),this.strokeStyleToState(e,n)}createFill(t){const e=t.fillStyle,n=[up,e];return"string"!=typeof e&&n.push(t.fillPatternScale),n}applyStroke(t){this.instructions.push(this.createStroke(t))}createStroke(t){return[dp,t.strokeStyle,t.lineWidth*this.pixelRatio,t.lineCap,t.lineJoin,t.miterLimit,t.lineDash?this.applyPixelRatio(t.lineDash):null,t.lineDashOffset*this.pixelRatio]}updateFillStyle(t,e){const n=t.fillStyle;(void 0!==n&&"string"!=typeof n||t.currentFillStyle!=n)&&(this.instructions.push(e.call(this,t)),t.currentFillStyle=n)}updateStrokeStyle(t,e){const n=t.strokeStyle,i=t.lineCap,r=t.lineDash,s=t.lineDashOffset,o=t.lineJoin,a=t.lineWidth,l=t.miterLimit,h=t.strokeOffset;(t.currentStrokeStyle!=n||t.currentLineCap!=i||r!=t.currentLineDash&&!hi(t.currentLineDash,r)||t.currentLineDashOffset!=s||t.currentLineJoin!=o||t.currentLineWidth!=a||t.currentMiterLimit!=l||t.currentStrokeOffset!=h)&&(e.call(this,t),t.currentStrokeStyle=n,t.currentLineCap=i,t.currentLineDash=r,t.currentLineDashOffset=s,t.currentLineJoin=o,t.currentLineWidth=a,t.currentMiterLimit=l,t.currentStrokeOffset=h)}endGeometry(t){this.beginGeometryInstruction1_[2]=this.instructions.length,this.beginGeometryInstruction1_=null,this.beginGeometryInstruction2_[2]=this.hitDetectionInstructions.length,this.beginGeometryInstruction2_=null;const e=[lp,t];this.instructions.push(e),this.hitDetectionInstructions.push(e)}getBufferedMaxExtent(){if(!this.bufferedMaxExtent_&&(this.bufferedMaxExtent_=kr(this.maxExtent),this.maxLineWidth>0)){const t=this.resolution*(this.maxLineWidth+1)/2;Ir(this.bufferedMaxExtent_,t,this.bufferedMaxExtent_)}return this.bufferedMaxExtent_}}class xp extends yp{constructor(t,e,n,i){super(t,e,n,i)}drawFlatCoordinatess_(t,e,n,i,r){const s=this.state,o=void 0!==s.fillStyle,a=void 0!==s.strokeStyle,l=n.length;this.instructions.push(mp),this.hitDetectionInstructions.push(mp);for(let s=0;s<l;++s){const o=n[s],l=this.coordinates.length,h=this.appendFlatLineCoordinates(t,e,o,i,!0,!a);this.instructions.push([cp,l,h,r*this.pixelRatio,!0]),this.hitDetectionInstructions.push([cp,l,h,r,!0]),a&&(this.instructions.push(_p),this.hitDetectionInstructions.push(_p)),e=o}return o&&(this.instructions.push(gp),this.hitDetectionInstructions.push(gp)),a&&(this.instructions.push(pp),this.hitDetectionInstructions.push(pp)),e}drawCircle(t,e,n){const i=this.state,r=i.fillStyle,s=i.strokeStyle,o=i.strokeOffset;if(void 0===r&&void 0===s)return;if(this.handleStrokeOffset_(()=>this.drawCircle(t,e,n)))return;this.setFillStrokeStyles_(),this.beginGeometry(t,e,n),void 0!==i.fillStyle&&this.hitDetectionInstructions.push([up,xd]),void 0!==i.strokeStyle&&this.hitDetectionInstructions.push([dp,Sd,i.lineWidth,i.lineCap,i.lineJoin,i.miterLimit,bd,0]);const a=t.getFlatCoordinates(),l=t.getStride(),h=this.coordinates.length;this.appendFlatLineCoordinates(a,0,a.length,l,!1,!1);const c=[ip,h,o];this.instructions.push(mp,c),this.hitDetectionInstructions.push(mp,c),void 0!==i.fillStyle&&(this.instructions.push(gp),this.hitDetectionInstructions.push(gp)),void 0!==i.strokeStyle&&(this.instructions.push(pp),this.hitDetectionInstructions.push(pp)),this.endGeometry(e)}drawPolygon(t,e,n){const i=this.state,r=i.fillStyle,s=i.strokeStyle,o=i.strokeOffset;if(void 0===r&&void 0===s)return;if(this.handleStrokeOffset_(()=>this.drawPolygon(t,e,n)))return;this.setFillStrokeStyles_(),this.beginGeometry(t,e,n),void 0!==i.fillStyle&&this.hitDetectionInstructions.push([up,xd]),void 0!==i.strokeStyle&&this.hitDetectionInstructions.push([dp,Sd,i.lineWidth,i.lineCap,i.lineJoin,i.miterLimit,bd,0]);const a=t.getEnds(),l=t.getOrientedFlatCoordinates(),h=t.getStride();this.drawFlatCoordinatess_(l,0,a,h,o),this.endGeometry(e)}drawMultiPolygon(t,e,n){const i=this.state,r=i.fillStyle,s=i.strokeStyle,o=i.strokeOffset;if(void 0===r&&void 0===s)return;if(this.handleStrokeOffset_(()=>this.drawMultiPolygon(t,e,n)))return;this.setFillStrokeStyles_(),this.beginGeometry(t,e,n),void 0!==i.fillStyle&&this.hitDetectionInstructions.push([up,xd]),void 0!==i.strokeStyle&&this.hitDetectionInstructions.push([dp,Sd,i.lineWidth,i.lineCap,i.lineJoin,i.miterLimit,bd,0]);const a=t.getEndss(),l=t.getOrientedFlatCoordinates(),h=t.getStride();let c=0;for(let t=0,e=a.length;t<e;++t)c=this.drawFlatCoordinatess_(l,c,a[t],h,o);this.endGeometry(e)}finish(){this.reverseHitDetectionInstructions(),this.state=null;const t=this.tolerance;if(0!==t){const e=this.coordinates;for(let n=0,i=e.length;n<i;++n)e[n]=Da(e[n],t)}return super.finish()}setFillStrokeStyles_(){const t=this.state;this.updateFillStyle(t,this.createFill),this.updateStrokeStyle(t,this.applyStroke)}handleStrokeOffset_(t){const e=this.state,n=e.fillStyle,i=e.strokeStyle,r=e.strokeOffset;return Math.abs(r)>0&&void 0!==n&&void 0!==i&&(e.strokeStyle=void 0,e.strokeOffset=0,t(),e.fillStyle=void 0,e.strokeStyle=i,e.strokeOffset=r,t(),e.fillStyle=n,!0)}}function vp(t,e,n,i,r){const s=[];let o=n,a=0,l=e.slice(n,2);for(;a<t&&o+r<i;){const[n,i]=l.slice(-2),h=e[o+r],c=e[o+r+1],u=Math.sqrt((h-n)*(h-n)+(c-i)*(c-i));if(a+=u,a>=t){const e=(t-a+u)/u,d=mr(n,h,e),f=mr(i,c,e);l.push(d,f),s.push(l),l=[d,f],a==t&&(o+=r),a=0}else if(a<t)l.push(e[o+r],e[o+r+1]),o+=r;else{const t=u-a,e=mr(n,h,t/u),d=mr(i,c,t/u);l.push(e,d),s.push(l),l=[e,d],a=0,o+=r}}return a>0&&s.push(l),s}function bp(t,e,n,i,r){let s,o,a,l,h,c,u,d,f,g,p=n,m=n,_=0,y=0,x=n;for(o=n;o<i;o+=r){const n=e[o],i=e[o+1];void 0!==h&&(f=n-h,g=i-c,l=Math.sqrt(f*f+g*g),void 0!==u&&(y+=a,s=Math.acos((u*f+d*g)/(a*l)),s>t&&(y>_&&(_=y,p=x,m=o),y=0,x=o-r)),a=l,u=f,d=g),h=n,c=i}return y+=l,y>_?[x,o]:[p,m]}const wp={left:0,center:.5,right:1,top:0,middle:.5,hanging:.2,alphabetic:.8,ideographic:.8,bottom:1};const Sp={Circle:xp,Default:yp,Image:class extends yp{constructor(t,e,n,i){super(t,e,n,i),this.hitDetectionImage_=null,this.image_=null,this.imagePixelRatio_=void 0,this.anchorX_=void 0,this.anchorY_=void 0,this.height_=void 0,this.opacity_=void 0,this.originX_=void 0,this.originY_=void 0,this.rotateWithView_=void 0,this.rotation_=void 0,this.scale_=void 0,this.width_=void 0,this.declutterMode_=void 0,this.declutterImageWithText_=void 0}drawPoint(t,e,n){if(!this.image_||this.maxExtent&&!Ar(this.maxExtent,t.getFlatCoordinates()))return;this.beginGeometry(t,e,n);const i=t.getFlatCoordinates(),r=t.getStride(),s=this.coordinates.length,o=this.appendFlatPointCoordinates(i,r);this.instructions.push([ap,s,o,this.image_,this.anchorX_*this.imagePixelRatio_,this.anchorY_*this.imagePixelRatio_,Math.ceil(this.height_*this.imagePixelRatio_),this.opacity_,this.originX_*this.imagePixelRatio_,this.originY_*this.imagePixelRatio_,this.rotateWithView_,this.rotation_,[this.scale_[0]*this.pixelRatio/this.imagePixelRatio_,this.scale_[1]*this.pixelRatio/this.imagePixelRatio_],Math.ceil(this.width_*this.imagePixelRatio_),this.declutterMode_,this.declutterImageWithText_]),this.hitDetectionInstructions.push([ap,s,o,this.hitDetectionImage_,this.anchorX_,this.anchorY_,this.height_,1,this.originX_,this.originY_,this.rotateWithView_,this.rotation_,this.scale_,this.width_,this.declutterMode_,this.declutterImageWithText_]),this.endGeometry(e)}drawMultiPoint(t,e,n){if(!this.image_)return;this.beginGeometry(t,e,n);const i=t.getFlatCoordinates(),r=[];for(let e=0,n=i.length;e<n;e+=t.getStride())this.maxExtent&&!Ar(this.maxExtent,i.slice(e,e+2))||r.push(i[e],i[e+1]);const s=this.coordinates.length,o=this.appendFlatPointCoordinates(r,2);this.instructions.push([ap,s,o,this.image_,this.anchorX_*this.imagePixelRatio_,this.anchorY_*this.imagePixelRatio_,Math.ceil(this.height_*this.imagePixelRatio_),this.opacity_,this.originX_*this.imagePixelRatio_,this.originY_*this.imagePixelRatio_,this.rotateWithView_,this.rotation_,[this.scale_[0]*this.pixelRatio/this.imagePixelRatio_,this.scale_[1]*this.pixelRatio/this.imagePixelRatio_],Math.ceil(this.width_*this.imagePixelRatio_),this.declutterMode_,this.declutterImageWithText_]),this.hitDetectionInstructions.push([ap,s,o,this.hitDetectionImage_,this.anchorX_,this.anchorY_,this.height_,1,this.originX_,this.originY_,this.rotateWithView_,this.rotation_,this.scale_,this.width_,this.declutterMode_,this.declutterImageWithText_]),this.endGeometry(e)}finish(){return this.reverseHitDetectionInstructions(),this.anchorX_=void 0,this.anchorY_=void 0,this.hitDetectionImage_=null,this.image_=null,this.imagePixelRatio_=void 0,this.height_=void 0,this.scale_=void 0,this.opacity_=void 0,this.originX_=void 0,this.originY_=void 0,this.rotateWithView_=void 0,this.rotation_=void 0,this.width_=void 0,super.finish()}setImageStyle(t,e){const n=t.getAnchor(),i=t.getSize(),r=t.getOrigin();this.imagePixelRatio_=t.getPixelRatio(this.pixelRatio),this.anchorX_=n[0],this.anchorY_=n[1],this.hitDetectionImage_=t.getHitDetectionImage(),this.image_=t.getImage(this.pixelRatio),this.height_=i[1],this.opacity_=t.getOpacity(),this.originX_=r[0],this.originY_=r[1],this.rotateWithView_=t.getRotateWithView(),this.rotation_=t.getRotation(),this.scale_=t.getScaleArray(),this.width_=i[0],this.declutterMode_=t.getDeclutterMode(),this.declutterImageWithText_=e}},LineString:class extends yp{constructor(t,e,n,i){super(t,e,n,i)}drawFlatCoordinates_(t,e,n,i,r){const s=this.coordinates.length,o=this.appendFlatLineCoordinates(t,e,n,i,!1,!1);return this.instructions.push([cp,s,o,r*this.pixelRatio]),this.hitDetectionInstructions.push([cp,s,o,r]),n}drawLineString(t,e,n){const i=this.state,r=i.strokeStyle,s=i.lineWidth,o=i.strokeOffset;if(void 0===r||void 0===s)return;this.updateStrokeStyle(i,this.applyStroke),this.beginGeometry(t,e,n),this.hitDetectionInstructions.push([dp,Sd,i.lineWidth,i.lineCap,i.lineJoin,i.miterLimit,bd,0],mp);const a=t.getFlatCoordinates(),l=t.getStride();this.drawFlatCoordinates_(a,0,a.length,l,o),this.hitDetectionInstructions.push(pp),this.endGeometry(e)}drawMultiLineString(t,e,n){const i=this.state,r=i.strokeStyle,s=i.lineWidth,o=i.strokeOffset;if(void 0===r||void 0===s)return;this.updateStrokeStyle(i,this.applyStroke),this.beginGeometry(t,e,n),this.hitDetectionInstructions.push([dp,Sd,i.lineWidth,i.lineCap,i.lineJoin,i.miterLimit,bd,0],mp);const a=t.getEnds(),l=t.getFlatCoordinates(),h=t.getStride();let c=0;for(let t=0,e=a.length;t<e;++t)c=this.drawFlatCoordinates_(l,c,a[t],h,o);this.hitDetectionInstructions.push(pp),this.endGeometry(e)}finish(){const t=this.state;return null!=t.lastStroke&&t.lastStroke!=this.coordinates.length&&this.instructions.push(pp),this.reverseHitDetectionInstructions(),this.state=null,super.finish()}applyStroke(t){null!=t.lastStroke&&t.lastStroke!=this.coordinates.length&&(this.instructions.push(pp),t.lastStroke=this.coordinates.length),t.lastStroke=0,super.applyStroke(t),this.instructions.push(mp)}},Polygon:xp,Text:class extends yp{constructor(t,e,n,i){super(t,e,n,i),this.labels_=null,this.text_="",this.textOffsetX_=0,this.textOffsetY_=0,this.textRotateWithView_=void 0,this.textKeepUpright_=void 0,this.textRotation_=0,this.textFillState_=null,this.fillStates={},this.fillStates[xd]={fillStyle:xd},this.textStrokeState_=null,this.strokeStates={},this.textState_={},this.textStates={},this.textKey_="",this.fillKey_="",this.strokeKey_="",this.declutterMode_=void 0,this.declutterImageWithText_=void 0}finish(){const t=super.finish();return t.textStates=this.textStates,t.fillStates=this.fillStates,t.strokeStates=this.strokeStates,t}drawText(t,e,n){const i=this.textFillState_,r=this.textStrokeState_,s=this.textState_;if(""===this.text_||!s||!i&&!r)return;const o=this.coordinates;let a=o.length;const l=t.getType();let h=null,c=t.getStride();if("line"!==s.placement||"LineString"!=l&&"MultiLineString"!=l&&"Polygon"!=l&&"MultiPolygon"!=l){let i=s.overflow?null:[];switch(l){case"Point":case"MultiPoint":h=t.getFlatCoordinates();break;case"LineString":h=t.getFlatMidpoint();break;case"Circle":h=t.getCenter();break;case"MultiLineString":h=t.getFlatMidpoints(),c=2;break;case"Polygon":h=t.getFlatInteriorPoint(),s.overflow||i.push(h[2]/this.resolution),c=3;break;case"MultiPolygon":const e=t.getFlatInteriorPoints();h=[];for(let t=0,n=e.length;t<n;t+=3)s.overflow||i.push(e[t+2]/this.resolution),h.push(e[t],e[t+1]);if(0===h.length)return;c=2}const r=this.appendFlatPointCoordinates(h,c);if(r===a)return;if(i&&(r-a)/2!==h.length/c){let t=a/2;i=i.filter((e,n)=>{const i=o[2*(t+n)]===h[n*c]&&o[2*(t+n)+1]===h[n*c+1];return i||--t,i})}this.saveTextStates_();const u=s.backgroundFill?this.createFill(this.fillStyleToState(s.backgroundFill)):null,d=s.backgroundStroke?this.createStroke(this.strokeStyleToState(s.backgroundStroke)):null;this.beginGeometry(t,e,n);let f=s.padding;if(f!=Pd&&(s.scale[0]<0||s.scale[1]<0)){let t=s.padding[0],e=s.padding[1],n=s.padding[2],i=s.padding[3];s.scale[0]<0&&(e=-e,i=-i),s.scale[1]<0&&(t=-t,n=-n),f=[t,e,n,i]}const g=this.pixelRatio;this.instructions.push([ap,a,r,null,NaN,NaN,NaN,1,0,0,this.textRotateWithView_,this.textRotation_,[1,1],NaN,this.declutterMode_,this.declutterImageWithText_,f==Pd?Pd:f.map(function(t){return t*g}),u,d,this.text_,this.textKey_,this.strokeKey_,this.fillKey_,this.textOffsetX_,this.textOffsetY_,i]);const p=1/g,m=u?u.slice(0):null;m&&(m[1]=xd),this.hitDetectionInstructions.push([ap,a,r,null,NaN,NaN,NaN,1,0,0,this.textRotateWithView_,this.textRotation_,[p,p],NaN,this.declutterMode_,this.declutterImageWithText_,f,m,d,this.text_,this.textKey_,this.strokeKey_,this.fillKey_?xd:this.fillKey_,this.textOffsetX_,this.textOffsetY_,i]),this.endGeometry(e)}else{if(!as(this.maxExtent,t.getExtent()))return;let i;if(h=t.getFlatCoordinates(),"LineString"==l)i=[h.length];else if("MultiLineString"==l)i=t.getEnds();else if("Polygon"==l)i=t.getEnds().slice(0,1);else if("MultiPolygon"==l){const e=t.getEndss();i=[];for(let t=0,n=e.length;t<n;++t)i.push(e[t][0])}this.beginGeometry(t,e,n);const r=s.repeat,u=r?void 0:s.textAlign;let d=0;for(let t=0,e=i.length;t<e;++t){let e;e=r?vp(r*this.resolution,h,d,i[t],c):[h.slice(d,i[t])];for(let n=0,r=e.length;n<r;++n){const r=e[n];let l=0,h=r.length;if(null==u){const t=bp(s.maxAngle,r,0,r.length,2);l=t[0],h=t[1]}for(let t=l;t<h;t+=c)o.push(r[t],r[t+1]);const f=o.length;d=i[t],this.drawChars_(a,f),a=f}}this.endGeometry(e)}}saveTextStates_(){const t=this.textStrokeState_,e=this.textState_,n=this.textFillState_,i=this.strokeKey_;t&&(i in this.strokeStates||(this.strokeStates[i]={strokeStyle:t.strokeStyle,lineCap:t.lineCap,lineDashOffset:t.lineDashOffset,lineWidth:t.lineWidth,lineJoin:t.lineJoin,miterLimit:t.miterLimit,lineDash:t.lineDash}));const r=this.textKey_;r in this.textStates||(this.textStates[r]={font:e.font,textAlign:e.textAlign||Cd,justify:e.justify,textBaseline:e.textBaseline||Ed,scale:e.scale});const s=this.fillKey_;n&&(s in this.fillStates||(this.fillStates[s]={fillStyle:n.fillStyle}))}drawChars_(t,e){const n=this.textStrokeState_,i=this.textState_,r=this.strokeKey_,s=this.textKey_,o=this.fillKey_;this.saveTextStates_();const a=this.pixelRatio,l=wp[i.textBaseline],h=this.textOffsetY_*a,c=this.text_,u=n?n.lineWidth*Math.abs(i.scale[0])/2:0;this.instructions.push([op,t,e,l,i.overflow,o,i.maxAngle,a,h,r,u*a,c,s,1,this.declutterMode_,this.textKeepUpright_]),this.hitDetectionInstructions.push([op,t,e,l,i.overflow,o?xd:o,i.maxAngle,a,h,r,u*a,c,s,1/a,this.declutterMode_,this.textKeepUpright_])}setTextStyle(t,e){let n,i,r;if(t){const e=t.getFill();e?(i=this.textFillState_,i||(i={},this.textFillState_=i),i.fillStyle=_d(e.getColor()||xd)):(i=null,this.textFillState_=i);const s=t.getStroke();if(s){r=this.textStrokeState_,r||(r={},this.textStrokeState_=r);const t=s.getLineDash(),e=s.getLineDashOffset(),n=s.getWidth(),i=s.getMiterLimit();r.lineCap=s.getLineCap()||vd,r.lineDash=t?t.slice():bd,r.lineDashOffset=void 0===e?0:e,r.lineJoin=s.getLineJoin()||wd,r.lineWidth=void 0===n?1:n,r.miterLimit=void 0===i?10:i,r.strokeStyle=_d(s.getColor()||Sd)}else r=null,this.textStrokeState_=r;n=this.textState_;const o=t.getFont()||yd;Ld(o);const a=t.getScaleArray();n.overflow=t.getOverflow(),n.font=o,n.maxAngle=t.getMaxAngle(),n.placement=t.getPlacement(),n.textAlign=t.getTextAlign(),n.repeat=t.getRepeat(),n.justify=t.getJustify(),n.textBaseline=t.getTextBaseline()||Ed,n.backgroundFill=t.getBackgroundFill(),n.backgroundStroke=t.getBackgroundStroke(),n.padding=t.getPadding()||Pd,n.scale=void 0===a?[1,1]:a;const l=t.getOffsetX(),h=t.getOffsetY(),c=t.getRotateWithView(),u=t.getKeepUpright(),d=t.getRotation();this.text_=t.getText()||"",this.textOffsetX_=void 0===l?0:l,this.textOffsetY_=void 0===h?0:h,this.textRotateWithView_=void 0!==c&&c,this.textKeepUpright_=void 0===u||u,this.textRotation_=void 0===d?0:d,this.strokeKey_=r?("string"==typeof r.strokeStyle?r.strokeStyle:wi(r.strokeStyle))+r.lineCap+r.lineDashOffset+"|"+r.lineWidth+r.lineJoin+r.miterLimit+"["+r.lineDash.join()+"]":"",this.textKey_=n.font+n.scale+(n.textAlign||"?")+(n.repeat||"?")+(n.justify||"?")+(n.textBaseline||"?"),this.fillKey_=i&&i.fillStyle?"string"==typeof i.fillStyle?i.fillStyle:"|"+wi(i.fillStyle):""}else this.text_="";this.declutterMode_=t.getDeclutterMode(),this.declutterImageWithText_=e}}};class Cp{constructor(t,e,n,i){this.tolerance_=t,this.maxExtent_=e,this.pixelRatio_=i,this.resolution_=n,this.buildersByZIndex_={}}finish(){const t={};for(const e in this.buildersByZIndex_){t[e]=t[e]||{};const n=this.buildersByZIndex_[e];for(const i in n){const r=n[i].finish();t[e][i]=r}}return t}getBuilder(t,e){const n=void 0!==t?t.toString():"0";let i=this.buildersByZIndex_[n];void 0===i&&(i={},this.buildersByZIndex_[n]=i);let r=i[e];if(void 0===r){r=new(0,Sp[e])(this.tolerance_,this.maxExtent_,this.resolution_,this.pixelRatio_),i[e]=r}return r}}function Ep(t,e,n,i,r,s,o,a){o=o??[],a=a??i;const l=t[e+i],h=t[e+i+1],c=t[n-2*i],u=t[n-2*i+1];let d,f,g,p,m,_,y,x,v=0;for(let b=e;b<n;b+=i){g=d,p=f,m=void 0,_=void 0,b+i<n&&(m=t[b+i],_=t[b+i+1]),s&&b===e&&(g=c,p=u),s&&b===n-i&&(m=l,_=h),d=t[b],f=t[b+1],[y,x]=Pp(d,f,g,p,m,_,r),o[v++]=y,o[v++]=x;for(let e=2;e<a;e++)o[v++]=t[b+e]}return o.length!=v&&(o.length=v),o}function Pp(t,e,n,i,r,s,o){let a,l;void 0!==n&&void 0!==i?(a=t-n,l=e-i):void 0!==r&&void 0!==s?(a=r-t,l=s-e):(a=1,l=0);const h=Math.hypot(a,l),c=a/h,u=l/h;if(a=-u,l=c,void 0===n||void 0===i)return[t+a*o,e+l*o];if(void 0===r||void 0===s)return[t+a*o,e+l*o];const d=function(t,e,n){const i=Math.sqrt((e[0]-t[0])*(e[0]-t[0])+(e[1]-t[1])*(e[1]-t[1])),r=[(e[0]-t[0])/i,(e[1]-t[1])/i],s=[-r[1],r[0]],o=Math.sqrt((n[0]-t[0])*(n[0]-t[0])+(n[1]-t[1])*(n[1]-t[1])),a=[(n[0]-t[0])/o,(n[1]-t[1])/o];let l=0===i||0===o?0:Math.acos(cr(a[0]*r[0]+a[1]*r[1],-1,1));return l=Math.max(l,1e-5),a[0]*s[0]+a[1]*s[1]>0?l:2*Math.PI-l}([t,e],[n,i],[r,s]);if(Math.cos(d)>.998)return[t+c*o,e+u*o];const f=Math.cos(d/2),g=Math.sin(d/2);return[t+(g*a+f*l)*(1/g)*o,e+(-f*a+g*l)*(1/g)*o]}function Tp(t,e){for(let n=0,i=t.length-2;n<i;n+=e)for(let i=t.length-2*e;i>n+e;i-=e){const r=t[n],s=t[n+1],o=t[n+e],a=t[n+e+1],l=t[i],h=t[i+1],c=t[i+e],u=t[i+e+1],d=(u-h)*(o-r)-(c-l)*(a-s);if(0===d)continue;const f=((c-l)*(s-h)-(u-h)*(r-l))/d,g=((o-r)*(s-h)-(a-s)*(r-l))/d;if(f>0&&f<1&&g>0&&g<1){const l=r+f*(o-r),h=s+f*(a-s);t[n+e]=l,t[n+e+1]=h,t.splice(n+2*e,i-n-e);break}}return t}function Rp(t,e,n,i,r,s,o,a,l,h,c,u,d=!0){let f=t[e],g=t[e+1],p=0,m=0,_=0,y=0;function x(){p=f,m=g,f=t[e+=i],g=t[e+1],y+=_,_=Math.sqrt((f-p)*(f-p)+(g-m)*(g-m))}do{x()}while(e<n-i&&y+_<s);let v=0===_?0:(s-y)/_;const b=mr(p,f,v),w=mr(m,g,v),S=e-i,C=y,E=s+a*l(h,r,c);for(;e<n-i&&y+_<E;)x();v=0===_?0:(E-y)/_;const P=mr(p,f,v),T=mr(m,g,v);let R=!1;if(d)if(u){const t=[b,w,P,T];da(t,0,4,2,u,t,t),R=t[0]>t[2]}else R=b>P;const F=Math.PI,M=[],I=S+i===e;let k;if(_=0,y=C,f=t[e=S],g=t[e+1],I){x(),k=Math.atan2(g-m,f-p),R&&(k+=k>0?-F:F);const t=(P+b)/2,e=(T+w)/2;return M[0]=[t,e,(E-s)/2,k,r],M}for(let t=0,u=(r=r.replace(/\n/g," ")).length;t<u;){x();let d=Math.atan2(g-m,f-p);if(R&&(d+=d>0?-F:F),void 0!==k){let t=d-k;if(t+=t>F?-2*F:t<-F?2*F:0,Math.abs(t)>o)return null}k=d;const b=t;let w=0;for(;t<u;++t){const o=a*l(h,r[R?u-t-1:t],c);if(e+i<n&&y+_<s+w+o/2)break;w+=o}if(t===b)continue;const S=R?r.substring(u-b,u-t):r.substring(b,t);v=0===_?0:(s+w/2-y)/_;const C=mr(p,f,v),E=mr(m,g,v);M.push([C,E,w/2,d,S]),s+=w}return M}const Fp=[1/0,1/0,-1/0,-1/0],Mp=[],Ip=[],kp=[],Lp=[];function Ap(t){return t[3].declutterBox}const Dp=new RegExp("["+String.fromCharCode(1425)+"-"+String.fromCharCode(2303)+String.fromCharCode(64285)+"-"+String.fromCharCode(65023)+String.fromCharCode(65136)+"-"+String.fromCharCode(65276)+String.fromCharCode(67584)+"-"+String.fromCharCode(69631)+String.fromCharCode(124928)+"-"+String.fromCharCode(126975)+"]");function Op(t,e){return"start"===e?e=Dp.test(t)?"right":"left":"end"===e&&(e=Dp.test(t)?"left":"right"),wp[e]}function zp(t,e,n){return n>0&&t.push("\n",""),t.push(e,""),t}function Np(t,e,n){return n%2==0&&(t+=e),t}class jp{constructor(t,e,n,i,r){this.overlaps=n,this.pixelRatio=e,this.resolution=t,this.alignAndScaleFill_,this.instructions=i.instructions,this.coordinates=i.coordinates,this.coordinateCache_={},this.renderedTransform_=[1,0,0,1,0,0],this.hitDetectionInstructions=i.hitDetectionInstructions,this.pixelCoordinates_=null,this.viewRotation_=0,this.fillStates=i.fillStates||{},this.strokeStates=i.strokeStates||{},this.textStates=i.textStates||{},this.widths_={},this.labels_={},this.zIndexContext_=r?new $g:null}getZIndexContext(){return this.zIndexContext_}createLabel(t,e,n,i){const r=t+e+n+i;if(this.labels_[r])return this.labels_[r];const s=i?this.strokeStates[i]:null,o=n?this.fillStates[n]:null,a=this.textStates[e],l=this.pixelRatio,h=[a.scale[0]*l,a.scale[1]*l],c=a.justify?wp[a.justify]:Op(Array.isArray(t)?t[0]:t,a.textAlign||Cd),u=i&&s.lineWidth?s.lineWidth:0,d=Array.isArray(t)?t:String(t).split("\n").reduce(zp,[]),{width:f,height:g,widths:p,heights:m,lineWidths:_}=function(t,e){const n=[],i=[],r=[];let s=0,o=0,a=0,l=0;for(let h=0,c=e.length;h<=c;h+=2){const u=e[h];if("\n"===u||h===c){s=Math.max(s,o),r.push(o),o=0,a+=l,l=0;continue}const d=e[h+1]||t.font,f=Od(d,u);n.push(f),o+=f;const g=Ad(d);i.push(g),l=Math.max(l,g)}return{width:s,height:a,widths:n,heights:i,lineWidths:r}}(a,d),y=f+u,x=[],v=(y+2)*h[0],b=(g+u)*h[1],w={width:v<0?Math.floor(v):Math.ceil(v),height:b<0?Math.floor(b):Math.ceil(b),contextInstructions:x};1==h[0]&&1==h[1]||x.push("scale",h),i&&(x.push("strokeStyle",s.strokeStyle),x.push("lineWidth",u),x.push("lineCap",s.lineCap),x.push("lineJoin",s.lineJoin),x.push("miterLimit",s.miterLimit),x.push("setLineDash",[s.lineDash]),x.push("lineDashOffset",s.lineDashOffset)),n&&x.push("fillStyle",o.fillStyle),x.push("textBaseline","middle"),x.push("textAlign","center");const S=.5-c;let C=c*y+S*u;const E=[],P=[];let T,R=0,F=0,M=0,I=0;for(let t=0,e=d.length;t<e;t+=2){const e=d[t];if("\n"===e){F+=R,R=0,C=c*y+S*u,++I;continue}const r=d[t+1]||a.font;r!==T&&(i&&E.push("font",r),n&&P.push("font",r),T=r),R=Math.max(R,m[M]);const s=[e,C+S*p[M]+c*(p[M]-_[I]),.5*(u+R)+F];C+=p[M],i&&E.push("strokeText",s),n&&P.push("fillText",s),++M}return Array.prototype.push.apply(x,E),Array.prototype.push.apply(x,P),this.labels_[r]=w,w}replayTextBackground_(t,e,n,i,r,s,o){t.beginPath(),t.moveTo.apply(t,e),t.lineTo.apply(t,n),t.lineTo.apply(t,i),t.lineTo.apply(t,r),t.lineTo.apply(t,e),s&&(this.alignAndScaleFill_=s[2],t.fillStyle=s[1],this.fill_(t)),o&&(this.setStrokeStyle_(t,o),t.stroke())}calculateImageOrLabelDimensions_(t,e,n,i,r,s,o,a,l,h,c,u,d,f,g,p){let m=n-(o*=u[0]),_=i-(a*=u[1]);const y=r+l>t?t-l:r,x=s+h>e?e-h:s,v=f[3]+y*u[0]+f[1],b=f[0]+x*u[1]+f[2],w=m-f[3],S=_-f[0];let C;return(g||0!==c)&&(Mp[0]=w,Lp[0]=w,Mp[1]=S,Ip[1]=S,Ip[0]=w+v,kp[0]=Ip[0],kp[1]=S+b,Lp[1]=kp[1]),0!==c?(C=aa([1,0,0,1,0,0],n,i,1,1,c,-n,-i),ra(C,Mp),ra(C,Ip),ra(C,kp),ra(C,Lp),jr(Math.min(Mp[0],Ip[0],kp[0],Lp[0]),Math.min(Mp[1],Ip[1],kp[1],Lp[1]),Math.max(Mp[0],Ip[0],kp[0],Lp[0]),Math.max(Mp[1],Ip[1],kp[1],Lp[1]),Fp)):jr(Math.min(w,w+v),Math.min(S,S+b),Math.max(w,w+v),Math.max(S,S+b),Fp),d&&(m=Math.round(m),_=Math.round(_)),{drawImageX:m,drawImageY:_,drawImageW:y,drawImageH:x,originX:l,originY:h,declutterBox:{minX:Fp[0],minY:Fp[1],maxX:Fp[2],maxY:Fp[3],value:p},canvasTransform:C,scale:u}}replayImageOrLabel_(t,e,n,i,r,s,o){const a=!(!s&&!o),l=i.declutterBox,h=o?o[2]*i.scale[0]/2:0;return l.minX-h<=e[0]&&l.maxX+h>=0&&l.minY-h<=e[1]&&l.maxY+h>=0&&(a&&this.replayTextBackground_(t,Mp,Ip,kp,Lp,s,o),Nd(t,i.canvasTransform,r,n,i.originX,i.originY,i.drawImageW,i.drawImageH,i.drawImageX,i.drawImageY,i.scale)),!0}fill_(t){const e=this.alignAndScaleFill_;if(e){const n=ra(this.renderedTransform_,[0,0]),i=512*this.pixelRatio;t.save(),t.translate(n[0]%i,n[1]%i),1!==e&&t.scale(e,e)}t.fill(),e&&t.restore()}setStrokeStyle_(t,e){t.strokeStyle=e[1],e[1]&&(t.lineWidth=e[2],t.lineCap=e[3],t.lineJoin=e[4],t.miterLimit=e[5],t.lineDashOffset=e[7],t.setLineDash(e[6]))}drawLabelWithPointPlacement_(t,e,n,i){const r=this.textStates[e],s=this.createLabel(t,e,i,n),o=this.strokeStates[n],a=this.pixelRatio,l=Op(Array.isArray(t)?t[0]:t,r.textAlign||Cd),h=wp[r.textBaseline||Ed],c=o&&o.lineWidth?o.lineWidth:0;return{label:s,anchorX:l*(s.width/a-2*r.scale[0])+2*(.5-l)*c,anchorY:h*s.height/a+2*(.5-h)*c}}execute_(t,e,n,i,r,s,o,a){const l=this.zIndexContext_;let h;this.pixelCoordinates_&&hi(n,this.renderedTransform_)?h=this.pixelCoordinates_:(this.pixelCoordinates_||(this.pixelCoordinates_=[]),h=ua(this.coordinates,0,this.coordinates.length,2,n,this.pixelCoordinates_),ia(this.renderedTransform_,n));let c=0;const u=i.length;let d,f=0;const g=[];let p,m,_,y,x,v,b,w,S,C,E,P,T,R=0,F=0;const M=this.coordinateCache_,I=this.viewRotation_,k=Math.round(1e12*Math.atan2(-n[1],n[0]))/1e12,L={context:t,pixelRatio:this.pixelRatio,resolution:this.resolution,rotation:I},A=this.instructions!=i||this.overlaps?0:200;let D,O,z,N;for(;c<u;){const n=i[c];switch(n[0]){case ep:D=n[1],N=n[3],D.getGeometry()?void 0===o||as(o,N.getExtent())?++c:c=n[2]+1:c=n[2],l&&(l.zIndex=n[4]);break;case np:R>A&&(this.fill_(t),R=0),F>A&&(t.stroke(),F=0),R||F||(t.beginPath(),x=NaN,v=NaN),++c;break;case ip:f=n[1],_=n[2]??0;const i=h[f],u=h[f+1],j=h[f+2]-_-i,G=h[f+3]-_-u,$=Math.sqrt(j*j+G*G);t.moveTo(i+$,u),t.arc(i,u,$,0,2*Math.PI,!0),++c;break;case rp:t.closePath(),++c;break;case sp:f=n[1],d=n[2];const B=n[3],U=n[4],V=n[5];L.geometry=B,L.feature=D,c in M||(M[c]=[]);const X=M[c];V?V(h,f,d,2,X):(X[0]=h[f],X[1]=h[f+1],X.length=2),l&&(l.zIndex=n[6]),U(X,L),++c;break;case ap:f=n[1],d=n[2],S=n[3],p=n[4],m=n[5];let W=n[6];const q=n[7],Z=n[8],K=n[9],Y=n[10];let H=n[11];const J=n[12];let Q=n[13];y=n[14]||"declutter";const tt=n[15];if(!S&&n.length>=20){C=n[19],E=n[20],P=n[21],T=n[22];const t=this.drawLabelWithPointPlacement_(C,E,P,T);S=t.label,n[3]=S;const e=n[23];p=(t.anchorX-e)*this.pixelRatio,n[4]=p;const i=n[24];m=(t.anchorY-i)*this.pixelRatio,n[5]=m,W=S.height,n[6]=W,Q=S.width,n[13]=Q}let et,nt,it,rt;n.length>25&&(et=n[25]),n.length>17?(nt=n[16],it=n[17],rt=n[18]):(nt=Pd,it=null,rt=null),Y&&k?H+=I:Y||k||(H-=I);let st=0;for(;f<d;f+=2){if(et&&et[st++]<Q/this.pixelRatio)continue;const n=this.calculateImageOrLabelDimensions_(S.width,S.height,h[f],h[f+1],Q,W,p,m,Z,K,H,J,r,nt,!!it||!!rt,D),i=[t,e,S,n,q,it,rt];if(a){let t,e,r,s,o;if(tt){const n=d-f;if(!tt[n]){tt[n]={args:i,declutterMode:y};continue}const s=tt[n];t=s.args,e=s.declutterMode,delete tt[n],r=Ap(t)}if(!t||"declutter"===e&&a.collides(r)||(s=!0),"declutter"===y&&a.collides(n.declutterBox)||(o=!0),"declutter"===e&&"declutter"===y){const t=s&&o;s=t,o=t}s&&("none"!==e&&a.insert(r),this.replayImageOrLabel_.apply(this,t)),o&&("none"!==y&&a.insert(n.declutterBox),this.replayImageOrLabel_.apply(this,i))}else this.replayImageOrLabel_.apply(this,i)}++c;break;case op:const ot=n[1],at=n[2],lt=n[3],ht=n[4];T=n[5];const ct=n[6],ut=n[7],dt=n[8];P=n[9];const ft=n[10];C=n[11],Array.isArray(C)&&(C=C.reduce(Np,"")),E=n[12];const gt=[n[13],n[13]];y=n[14]||"declutter";const pt=n[15],mt=this.textStates[E],_t=mt.font,yt=[mt.scale[0]*ut,mt.scale[1]*ut];let xt;_t in this.widths_?xt=this.widths_[_t]:(xt={},this.widths_[_t]=xt);const vt=Df(h,ot,at,2),bt=Math.abs(yt[0])*zd(_t,C,xt);if(ht||bt<=vt){const n=Rp(h,ot,at,2,C,(vt-bt)*Op(C,this.textStates[E].textAlign),ct,Math.abs(yt[0]),zd,_t,xt,k?0:this.viewRotation_,pt);t:if(n){const i=[];let r,s,o,l,h;if(P)for(r=0,s=n.length;r<s;++r){h=n[r],o=h[4],l=this.createLabel(o,E,"",P),p=h[2]+(yt[0]<0?-ft:ft),m=lt*l.height+2*(.5-lt)*ft*yt[1]/yt[0]-dt;const s=this.calculateImageOrLabelDimensions_(l.width,l.height,h[0],h[1],l.width,l.height,p,m,0,0,h[3],gt,!1,Pd,!1,D);if(a&&"declutter"===y&&a.collides(s.declutterBox))break t;i.push([t,e,l,s,1,null,null])}if(T)for(r=0,s=n.length;r<s;++r){h=n[r],o=h[4],l=this.createLabel(o,E,T,""),p=h[2],m=lt*l.height-dt;const s=this.calculateImageOrLabelDimensions_(l.width,l.height,h[0],h[1],l.width,l.height,p,m,0,0,h[3],gt,!1,Pd,!1,D);if(a&&"declutter"===y&&a.collides(s.declutterBox))break t;i.push([t,e,l,s,1,null,null])}a&&"none"!==y&&a.load(i.map(Ap));for(let t=0,e=i.length;t<e;++t)this.replayImageOrLabel_.apply(this,i[t])}}++c;break;case lp:if(void 0!==s){D=n[1];const t=s(D,N,y);if(t)return t}++c;break;case hp:A?R++:this.fill_(t),++c;break;case cp:let wt,St,Ct;if(f=n[1],d=n[2],_=n[3],_){Ep(h,f,d,2,_,n[4]??!1,g),Tp(g,2),wt=g,St=0,Ct=wt.length}else wt=h,St=f,Ct=d;O=wt[St],z=wt[St+1],t.moveTo(O,z),x=O+.5|0,v=z+.5|0;for(let e=St+2;e<Ct;e+=2)O=wt[e],z=wt[e+1],b=O+.5|0,w=z+.5|0,e!=Ct-2&&b===x&&w===v||(t.lineTo(O,z),x=b,v=w);++c;break;case up:this.alignAndScaleFill_=n[2],R?(this.fill_(t),R=0,F&&(t.stroke(),F=0)):F&&n[1]&&(t.stroke(),F=0),t.fillStyle=n[1],++c;break;case dp:R&&n[1]&&(this.fill_(t),R=0),F&&(t.stroke(),F=0),this.setStrokeStyle_(t,n),++c;break;case fp:A?F++:t.stroke(),++c;break;default:++c}}R&&this.fill_(t),F&&t.stroke()}execute(t,e,n,i,r,s){this.viewRotation_=i,this.execute_(t,e,n,this.instructions,r,void 0,void 0,s)}executeHitDetection(t,e,n,i,r){return this.viewRotation_=n,this.execute_(t,[t.canvas.width,t.canvas.height],e,this.hitDetectionInstructions,!0,i,r)}}const Gp=["Polygon","Circle","LineString","Image","Text","Default"],$p=["Image","Text"],Bp=Gp.filter(t=>!$p.includes(t));let Up=!1,Vp=!1;class Xp{constructor(t,e,n,i,r,s,o){this.maxExtent_=t,this.overlaps_=i,this.pixelRatio_=n,this.resolution_=e,this.renderBuffer_=s,this.executorsByZIndex_={},this.hitDetectionContext_=null,this.hitDetectionTransform_=[1,0,0,1,0,0],this.renderedContext_=null,this.deferredZIndexContexts_={},this.createExecutors_(r,o)}clip(t,e){const n=this.getClipCoords(e);t.beginPath(),t.moveTo(n[0],n[1]),t.lineTo(n[2],n[3]),t.lineTo(n[4],n[5]),t.lineTo(n[6],n[7]),t.clip()}createExecutors_(t,e){for(const n in t){let i=this.executorsByZIndex_[n];void 0===i&&(i={},this.executorsByZIndex_[n]=i);const r=t[n];for(const t in r){const n=r[t];i[t]=new jp(this.resolution_,this.pixelRatio_,this.overlaps_,n,e)}}}hasExecutors(t){for(const e in this.executorsByZIndex_){const n=this.executorsByZIndex_[e];for(let e=0,i=t.length;e<i;++e)if(t[e]in n)return!0}return!1}forEachFeatureAtCoordinate(t,e,n,i,r,s){!1===Vp&&function(){let t=0;const e=e=>{const n=Cl(1,1,null,{willReadFrequently:e});let i=0;const r=performance.now();for(;performance.now()-r<50;++i)n.fillStyle=`rgba(255,0,${i%256},1)`,n.fillRect(0,0,1,1),n.getImageData(0,0,1,1);return t=i>t?i:t,i},n={[e(!0)]:!0,[e(!1)]:!1,[e(void 0)]:void 0};Up=n[t],Vp=!0}();const o=2*(i=Math.round(i))+1,a=aa(this.hitDetectionTransform_,i+.5,i+.5,1/e,-1/e,-n,-t[0],-t[1]),l=!this.hitDetectionContext_;l&&(this.hitDetectionContext_=Cl(o,o,null,{willReadFrequently:Up}));const h=this.hitDetectionContext_;let c;h.canvas.width!==o||h.canvas.height!==o?(h.canvas.width=o,h.canvas.height=o):l||h.clearRect(0,0,o,o),void 0!==this.renderBuffer_&&(c=[1/0,1/0,-1/0,-1/0],Xr(c,t),Ir(c,e*(this.renderBuffer_+i),c));const u=function(t){if(void 0!==Wp[t])return Wp[t];const e=2*t+1,n=t*t,i=new Array(n+1);for(let r=0;r<=t;++r)for(let s=0;s<=t;++s){const o=r*r+s*s;if(o>n)break;let a=i[o];a||(a=[],i[o]=a),a.push(4*((t+r)*e+(t+s))+3),r>0&&a.push(4*((t-r)*e+(t+s))+3),s>0&&(a.push(4*((t+r)*e+(t-s))+3),r>0&&a.push(4*((t-r)*e+(t-s))+3))}const r=[];for(let t=0,e=i.length;t<e;++t)i[t]&&r.push(...i[t]);return Wp[t]=r,r}(i);let d;function f(t,e,n){const a=h.getImageData(0,0,o,o).data;for(let l=0,c=u.length;l<c;l++)if(a[u[l]]>0){if(!s||"none"===n||"Image"!==d&&"Text"!==d||s.includes(t)){const n=(u[l]-3)/4,s=i-n%o,a=i-(n/o|0),h=r(t,e,s*s+a*a);if(h)return h}h.clearRect(0,0,o,o);break}}const g=Object.keys(this.executorsByZIndex_).map(Number);let p,m,_,y,x;for(g.sort(ri),p=g.length-1;p>=0;--p){const t=g[p].toString();for(_=this.executorsByZIndex_[t],m=Gp.length-1;m>=0;--m)if(d=Gp[m],y=_[d],void 0!==y&&(x=y.executeHitDetection(h,a,n,f,c),x))return x}}getClipCoords(t){const e=this.maxExtent_;if(!e)return null;const n=e[0],i=e[1],r=e[2],s=e[3],o=[n,i,n,s,r,s,r,i];return ua(o,0,8,2,t,o),o}isEmpty(){return Gn(this.executorsByZIndex_)}execute(t,e,n,i,r,s,o){const a=Object.keys(this.executorsByZIndex_).map(Number);a.sort(o?si:ri),s=s||Gp;const l=Gp.length;for(let h=0,c=a.length;h<c;++h){const c=a[h].toString(),u=this.executorsByZIndex_[c];for(let c=0,d=s.length;c<d;++c){const d=s[c],f=u[d];if(void 0!==f){const s=null===o?void 0:f.getZIndexContext(),c=s?s.getContext():t,u=this.maxExtent_&&"Image"!==d&&"Text"!==d;if(u&&(c.save(),this.clip(c,n)),s&&"Text"!==d&&"Image"!==d?s.pushFunction(t=>f.execute(t,e,n,i,r,o)):f.execute(c,e,n,i,r,o),u&&c.restore(),s){s.offset();const t=a[h]*l+Gp.indexOf(d);this.deferredZIndexContexts_[t]||(this.deferredZIndexContexts_[t]=[]),this.deferredZIndexContexts_[t].push(s)}}}}this.renderedContext_=t}getDeferredZIndexContexts(){return this.deferredZIndexContexts_}getRenderedContext(){return this.renderedContext_}renderDeferred(){const t=this.deferredZIndexContexts_,e=Object.keys(t).map(Number).sort(ri);for(let n=0,i=e.length;n<i;++n)t[e[n]].forEach(t=>{t.draw(this.renderedContext_),t.clear()}),t[e[n]].length=0}}const Wp={};class qp extends tp{constructor(t,e,n,i,r,s,o){super(),this.context_=t,this.pixelRatio_=e,this.extent_=n,this.transform_=i,this.transformRotation_=i?_r(Math.atan2(i[1],i[0]),10):0,this.viewRotation_=r,this.squaredTolerance_=s,this.userTransform_=o,this.contextFillState_=null,this.contextStrokeState_=null,this.contextTextState_=null,this.fillState_=null,this.strokeState_=null,this.image_=null,this.imageAnchorX_=0,this.imageAnchorY_=0,this.imageHeight_=0,this.imageOpacity_=0,this.imageOriginX_=0,this.imageOriginY_=0,this.imageRotateWithView_=!1,this.imageRotation_=0,this.imageScale_=[0,0],this.imageWidth_=0,this.text_="",this.textOffsetX_=0,this.textOffsetY_=0,this.textRotateWithView_=!1,this.textRotation_=0,this.textScale_=[0,0],this.textFillState_=null,this.textStrokeState_=null,this.textState_=null,this.pixelCoordinates_=[],this.tmpLocalTransform_=[1,0,0,1,0,0]}drawImages_(t,e,n,i){if(!this.image_)return;const r=ua(t,e,n,i,this.transform_,this.pixelCoordinates_),s=this.context_,o=this.tmpLocalTransform_,a=s.globalAlpha;1!=this.imageOpacity_&&(s.globalAlpha=a*this.imageOpacity_);let l=this.imageRotation_;0===this.transformRotation_&&(l-=this.viewRotation_),this.imageRotateWithView_&&(l+=this.viewRotation_);for(let t=0,e=r.length;t<e;t+=2){const e=r[t]-this.imageAnchorX_,n=r[t+1]-this.imageAnchorY_;if(0!==l||1!=this.imageScale_[0]||1!=this.imageScale_[1]){const t=e+this.imageAnchorX_,i=n+this.imageAnchorY_;aa(o,t,i,1,1,l,-t,-i),s.save(),s.transform.apply(s,o),s.translate(t,i),s.scale(this.imageScale_[0],this.imageScale_[1]),s.drawImage(this.image_,this.imageOriginX_,this.imageOriginY_,this.imageWidth_,this.imageHeight_,-this.imageAnchorX_,-this.imageAnchorY_,this.imageWidth_,this.imageHeight_),s.restore()}else s.drawImage(this.image_,this.imageOriginX_,this.imageOriginY_,this.imageWidth_,this.imageHeight_,e,n,this.imageWidth_,this.imageHeight_)}1!=this.imageOpacity_&&(s.globalAlpha=a)}drawText_(t,e,n,i){if(!this.textState_||""===this.text_)return;this.textFillState_&&this.setContextFillState_(this.textFillState_),this.textStrokeState_&&this.setContextStrokeState_(this.textStrokeState_),this.setContextTextState_(this.textState_);const r=ua(t,e,n,i,this.transform_,this.pixelCoordinates_),s=this.context_;let o=this.textRotation_;for(0===this.transformRotation_&&(o-=this.viewRotation_),this.textRotateWithView_&&(o+=this.viewRotation_);e<n;e+=i){const t=r[e]+this.textOffsetX_,n=r[e+1]+this.textOffsetY_;0!==o||1!=this.textScale_[0]||1!=this.textScale_[1]?(s.save(),s.translate(t-this.textOffsetX_,n-this.textOffsetY_),s.rotate(o),s.translate(this.textOffsetX_,this.textOffsetY_),s.scale(this.textScale_[0],this.textScale_[1]),this.textStrokeState_&&s.strokeText(this.text_,0,0),this.textFillState_&&s.fillText(this.text_,0,0),s.restore()):(this.textStrokeState_&&s.strokeText(this.text_,t,n),this.textFillState_&&s.fillText(this.text_,t,n))}}moveToLineTo_(t,e,n,i,r,s){const o=this.context_;let a=ua(t,e,n,i,this.transform_,this.pixelCoordinates_);Math.abs(s)>0&&(a=Ep(a,0,a.length,2,s,r,a),Tp(a,2)),o.moveTo(a[0],a[1]);let l=a.length;r&&(l-=2);for(let t=2;t<l;t+=2)o.lineTo(a[t],a[t+1]);return r&&o.closePath(),n}drawRings_(t,e,n,i,r){for(let s=0,o=n.length;s<o;++s)e=this.moveToLineTo_(t,e,n[s],i,!0,r);return e}drawCircle(t){if(this.squaredTolerance_&&(t=t.simplifyTransformed(this.squaredTolerance_,this.userTransform_)),as(this.extent_,t.getExtent())){if(this.fillState_||this.strokeState_){this.fillState_&&this.setContextFillState_(this.fillState_),this.strokeState_&&this.setContextStrokeState_(this.strokeState_);const e=function(t,e,n){const i=t.getFlatCoordinates();if(!i)return null;const r=t.getStride();return ua(i,0,i.length,r,e,n)}(t,this.transform_,this.pixelCoordinates_),n=e[2]-e[0],i=e[3]-e[1],r=Math.sqrt(n*n+i*i),s=this.context_;s.beginPath(),s.arc(e[0],e[1],r,0,2*Math.PI),this.fillState_&&s.fill(),this.strokeState_&&s.stroke()}""!==this.text_&&this.drawText_(t.getCenter(),0,2,2)}}setStyle(t){this.setFillStrokeStyle(t.getFill(),t.getStroke()),this.setImageStyle(t.getImage()),this.setTextStyle(t.getText())}setTransform(t){this.transform_=t}drawGeometry(t){switch(t.getType()){case"Point":this.drawPoint(t);break;case"LineString":this.drawLineString(t);break;case"Polygon":this.drawPolygon(t);break;case"MultiPoint":this.drawMultiPoint(t);break;case"MultiLineString":this.drawMultiLineString(t);break;case"MultiPolygon":this.drawMultiPolygon(t);break;case"GeometryCollection":this.drawGeometryCollection(t);break;case"Circle":this.drawCircle(t)}}drawFeature(t,e){const n=e.getGeometryFunction()(t);n&&(this.setStyle(e),this.drawGeometry(n))}drawGeometryCollection(t){const e=t.getGeometriesArray();for(let t=0,n=e.length;t<n;++t)this.drawGeometry(e[t])}drawPoint(t){this.squaredTolerance_&&(t=t.simplifyTransformed(this.squaredTolerance_,this.userTransform_));const e=t.getFlatCoordinates(),n=t.getStride();this.image_&&this.drawImages_(e,0,e.length,n),""!==this.text_&&this.drawText_(e,0,e.length,n)}drawMultiPoint(t){this.squaredTolerance_&&(t=t.simplifyTransformed(this.squaredTolerance_,this.userTransform_));const e=t.getFlatCoordinates(),n=t.getStride();this.image_&&this.drawImages_(e,0,e.length,n),""!==this.text_&&this.drawText_(e,0,e.length,n)}drawLineString(t){if(this.squaredTolerance_&&(t=t.simplifyTransformed(this.squaredTolerance_,this.userTransform_)),as(this.extent_,t.getExtent())){if(this.strokeState_){this.setContextStrokeState_(this.strokeState_);const e=this.context_,n=t.getFlatCoordinates();e.beginPath(),this.moveToLineTo_(n,0,n.length,t.getStride(),!1,this.strokeState_.strokeOffset),e.stroke()}if(""!==this.text_){const e=t.getFlatMidpoint();this.drawText_(e,0,2,2)}}}drawMultiLineString(t){this.squaredTolerance_&&(t=t.simplifyTransformed(this.squaredTolerance_,this.userTransform_));const e=t.getExtent();if(as(this.extent_,e)){if(this.strokeState_){this.setContextStrokeState_(this.strokeState_);const e=this.context_,n=t.getFlatCoordinates();let i=0;const r=t.getEnds(),s=t.getStride();e.beginPath();for(let t=0,e=r.length;t<e;++t)i=this.moveToLineTo_(n,i,r[t],s,!1,this.strokeState_.strokeOffset);e.stroke()}if(""!==this.text_){const e=t.getFlatMidpoints();this.drawText_(e,0,e.length,2)}}}drawPolygon(t){if(this.squaredTolerance_&&(t=t.simplifyTransformed(this.squaredTolerance_,this.userTransform_)),as(this.extent_,t.getExtent())){if(this.strokeState_||this.fillState_){this.fillState_&&this.setContextFillState_(this.fillState_),this.strokeState_&&this.setContextStrokeState_(this.strokeState_);const e=this.context_;e.beginPath(),this.drawRings_(t.getOrientedFlatCoordinates(),0,t.getEnds(),t.getStride(),this.strokeState_?.strokeOffset),this.fillState_&&e.fill(),this.strokeState_&&e.stroke()}if(""!==this.text_){const e=t.getFlatInteriorPoint();this.drawText_(e,0,2,2)}}}drawMultiPolygon(t){if(this.squaredTolerance_&&(t=t.simplifyTransformed(this.squaredTolerance_,this.userTransform_)),as(this.extent_,t.getExtent())){if(this.strokeState_||this.fillState_){this.fillState_&&this.setContextFillState_(this.fillState_),this.strokeState_&&this.setContextStrokeState_(this.strokeState_);const e=this.context_,n=t.getOrientedFlatCoordinates();let i=0;const r=t.getEndss(),s=t.getStride();e.beginPath();for(let t=0,e=r.length;t<e;++t){const e=r[t];i=this.drawRings_(n,i,e,s,this.strokeState_?.strokeOffset)}this.fillState_&&e.fill(),this.strokeState_&&e.stroke()}if(""!==this.text_){const e=t.getFlatInteriorPoints();this.drawText_(e,0,e.length,2)}}}setContextFillState_(t){const e=this.context_,n=this.contextFillState_;n?n.fillStyle!=t.fillStyle&&(n.fillStyle=t.fillStyle,e.fillStyle=t.fillStyle):(e.fillStyle=t.fillStyle,this.contextFillState_={fillStyle:t.fillStyle})}setContextStrokeState_(t){const e=this.context_,n=this.contextStrokeState_;n?(n.lineCap!=t.lineCap&&(n.lineCap=t.lineCap,e.lineCap=t.lineCap),hi(n.lineDash,t.lineDash)||e.setLineDash(n.lineDash=t.lineDash),n.lineDashOffset!=t.lineDashOffset&&(n.lineDashOffset=t.lineDashOffset,e.lineDashOffset=t.lineDashOffset),n.lineJoin!=t.lineJoin&&(n.lineJoin=t.lineJoin,e.lineJoin=t.lineJoin),n.lineWidth!=t.lineWidth&&(n.lineWidth=t.lineWidth,e.lineWidth=t.lineWidth),n.miterLimit!=t.miterLimit&&(n.miterLimit=t.miterLimit,e.miterLimit=t.miterLimit),n.strokeStyle!=t.strokeStyle&&(n.strokeStyle=t.strokeStyle,e.strokeStyle=t.strokeStyle)):(e.lineCap=t.lineCap,e.setLineDash(t.lineDash),e.lineDashOffset=t.lineDashOffset,e.lineJoin=t.lineJoin,e.lineWidth=t.lineWidth,e.miterLimit=t.miterLimit,e.strokeStyle=t.strokeStyle,this.contextStrokeState_={lineCap:t.lineCap,lineDash:t.lineDash,lineDashOffset:t.lineDashOffset,lineJoin:t.lineJoin,lineWidth:t.lineWidth,miterLimit:t.miterLimit,strokeStyle:t.strokeStyle})}setContextTextState_(t){const e=this.context_,n=this.contextTextState_,i=t.textAlign?t.textAlign:Cd;n?(n.font!=t.font&&(n.font=t.font,e.font=t.font),n.textAlign!=i&&(n.textAlign=i,e.textAlign=i),n.textBaseline!=t.textBaseline&&(n.textBaseline=t.textBaseline,e.textBaseline=t.textBaseline)):(e.font=t.font,e.textAlign=i,e.textBaseline=t.textBaseline,this.contextTextState_={font:t.font,textAlign:i,textBaseline:t.textBaseline})}setFillStrokeStyle(t,e){if(t){const e=t.getColor();this.fillState_={fillStyle:_d(e||xd)}}else this.fillState_=null;if(e){const t=e.getColor(),n=e.getLineCap(),i=e.getLineDash(),r=e.getLineDashOffset(),s=e.getLineJoin(),o=e.getWidth(),a=e.getMiterLimit(),l=i||bd,h=e.getOffset();this.strokeState_={lineCap:void 0!==n?n:vd,lineDash:1===this.pixelRatio_?l:l.map(t=>t*this.pixelRatio_),lineDashOffset:(r||0)*this.pixelRatio_,lineJoin:void 0!==s?s:wd,lineWidth:(void 0!==o?o:1)*this.pixelRatio_,miterLimit:void 0!==a?a:10,strokeStyle:_d(t||Sd),strokeOffset:(h??0)*this.pixelRatio_}}else this.strokeState_=null}setImageStyle(t){let e;if(!t||!(e=t.getSize()))return void(this.image_=null);const n=t.getPixelRatio(this.pixelRatio_),i=t.getAnchor(),r=t.getOrigin();this.image_=t.getImage(this.pixelRatio_),this.imageAnchorX_=i[0]*n,this.imageAnchorY_=i[1]*n,this.imageHeight_=e[1]*n,this.imageOpacity_=t.getOpacity(),this.imageOriginX_=r[0],this.imageOriginY_=r[1],this.imageRotateWithView_=t.getRotateWithView(),this.imageRotation_=t.getRotation();const s=t.getScaleArray();this.imageScale_=[s[0]*this.pixelRatio_/n,s[1]*this.pixelRatio_/n],this.imageWidth_=e[0]*n}setTextStyle(t){if(t){const e=t.getFill();if(e){const t=e.getColor();this.textFillState_={fillStyle:_d(t||xd)}}else this.textFillState_=null;const n=t.getStroke();if(n){const t=n.getColor(),e=n.getLineCap(),i=n.getLineDash(),r=n.getLineDashOffset(),s=n.getLineJoin(),o=n.getWidth(),a=n.getMiterLimit();this.textStrokeState_={lineCap:void 0!==e?e:vd,lineDash:i||bd,lineDashOffset:r||0,lineJoin:void 0!==s?s:wd,lineWidth:void 0!==o?o:1,miterLimit:void 0!==a?a:10,strokeStyle:_d(t||Sd)}}else this.textStrokeState_=null;const i=t.getFont(),r=t.getOffsetX(),s=t.getOffsetY(),o=t.getRotateWithView(),a=t.getRotation(),l=t.getScaleArray(),h=t.getText(),c=t.getTextAlign(),u=t.getTextBaseline();this.textState_={font:void 0!==i?i:yd,textAlign:void 0!==c?c:Cd,textBaseline:void 0!==u?u:Ed},this.text_=void 0!==h?Array.isArray(h)?h.reduce((t,e,n)=>t+(n%2?" ":e),""):h:"",this.textOffsetX_=void 0!==r?this.pixelRatio_*r:0,this.textOffsetY_=void 0!==s?this.pixelRatio_*s:0,this.textRotateWithView_=void 0!==o&&o,this.textRotation_=void 0!==a?a:0,this.textScale_=[this.pixelRatio_*l[0],this.pixelRatio_*l[1]]}else this.text_=""}}const Zp=.5;function Kp(t,e,n,i,r,s,o,a,l){const h=l?Zo(r,l):r,c=Cl(t[0]*Zp,t[1]*Zp);c.imageSmoothingEnabled=!1;const u=c.canvas,d=new qp(c,Zp,r,null,o,a,l?No(Xo(),l):null),f=n.length,g=Math.floor(16777215/f),p={};for(let t=1;t<=f;++t){const e=n[t-1],r=e.getStyleFunction()||i;if(!r)continue;let o=r(e,s);if(!o)continue;Array.isArray(o)||(o=[o]);const a=(t*g).toString(16).padStart(7,"#00000");for(let t=0,n=o.length;t<n;++t){const n=o[t],i=n.getGeometryFunction()(e);if(!i||!as(h,i.getExtent()))continue;const r=n.clone(),s=r.getFill();s&&s.setColor(a);const l=r.getStroke();l&&(l.setColor(a),l.setLineDash(null)),r.setText(void 0);const c=n.getImage();if(c){const t=c.getImageSize();if(!t)continue;const e=Cl(t[0],t[1],void 0,{alpha:!1}),n=e.canvas;e.fillStyle=a,e.fillRect(0,0,n.width,n.height),r.setImage(new Vd({img:n,anchor:c.getAnchor(),anchorXUnits:"pixels",anchorYUnits:"pixels",offset:c.getOrigin(),opacity:1,size:c.getSize(),scale:c.getScale(),rotation:c.getRotation(),rotateWithView:c.getRotateWithView()}))}const u=r.getZIndex()||0;let d=p[u];d||(d={},p[u]=d,d.Polygon=[],d.Circle=[],d.LineString=[],d.Point=[]);const f=i.getType();if("GeometryCollection"===f){const t=i.getGeometriesArrayRecursive();for(let e=0,n=t.length;e<n;++e){const n=t[e];d[n.getType().replace("Multi","")].push(n,r)}}else d[f.replace("Multi","")].push(i,r)}}const m=Object.keys(p).map(Number).sort(ri);for(let t=0,n=m.length;t<n;++t){const n=p[m[t]];for(const t in n){const i=n[t];for(let t=0,n=i.length;t<n;t+=2){d.setStyle(i[t+1]);for(let n=0,r=e.length;n<r;++n)d.setTransform(e[n]),d.drawGeometry(i[t])}}}return c.getImageData(0,0,u.width,u.height)}function Yp(t,e,n){const i=[];if(n){const r=Math.floor(Math.round(t[0])*Zp),s=Math.floor(Math.round(t[1])*Zp),o=4*(cr(r,0,n.width-1)+cr(s,0,n.height-1)*n.width),a=n.data[o],l=n.data[o+1],h=n.data[o+2]+256*(l+256*a),c=Math.floor(16777215/e.length);h&&h%c===0&&i.push(e[h/c-1])}return i}const Hp={Point:function(t,e,n,i,r,s){const o=n.getImage(),a=n.getText(),l=a&&a.getText(),h=s&&o&&l?{}:void 0;if(o){if(o.getImageState()!=od)return;const s=t.getBuilder(n.getZIndex(),"Image");s.setImageStyle(o,h),s.drawPoint(e,i,r)}if(l){const s=t.getBuilder(n.getZIndex(),"Text");s.setTextStyle(a,h),s.drawText(e,i,r)}},LineString:function(t,e,n,i,r){const s=n.getStroke();if(s){const o=t.getBuilder(n.getZIndex(),"LineString");o.setFillStrokeStyle(null,s),o.drawLineString(e,i,r)}const o=n.getText();if(o&&o.getText()){const s=t.getBuilder(n.getZIndex(),"Text");s.setTextStyle(o),s.drawText(e,i,r)}},Polygon:function(t,e,n,i,r){const s=n.getFill(),o=n.getStroke();if(s||o){const a=t.getBuilder(n.getZIndex(),"Polygon");a.setFillStrokeStyle(s,o),a.drawPolygon(e,i,r)}const a=n.getText();if(a&&a.getText()){const s=t.getBuilder(n.getZIndex(),"Text");s.setTextStyle(a),s.drawText(e,i,r)}},MultiPoint:function(t,e,n,i,r,s){const o=n.getImage(),a=o&&0!==o.getOpacity(),l=n.getText(),h=l&&l.getText(),c=s&&a&&h?{}:void 0;if(a){if(o.getImageState()!=od)return;const s=t.getBuilder(n.getZIndex(),"Image");s.setImageStyle(o,c),s.drawMultiPoint(e,i,r)}if(h){const s=t.getBuilder(n.getZIndex(),"Text");s.setTextStyle(l,c),s.drawText(e,i,r)}},MultiLineString:function(t,e,n,i,r){const s=n.getStroke();if(s){const o=t.getBuilder(n.getZIndex(),"LineString");o.setFillStrokeStyle(null,s),o.drawMultiLineString(e,i,r)}const o=n.getText();if(o&&o.getText()){const s=t.getBuilder(n.getZIndex(),"Text");s.setTextStyle(o),s.drawText(e,i,r)}},MultiPolygon:function(t,e,n,i,r){const s=n.getFill(),o=n.getStroke();if(o||s){const a=t.getBuilder(n.getZIndex(),"Polygon");a.setFillStrokeStyle(s,o),a.drawMultiPolygon(e,i,r)}const a=n.getText();if(a&&a.getText()){const s=t.getBuilder(n.getZIndex(),"Text");s.setTextStyle(a),s.drawText(e,i,r)}},GeometryCollection:function(t,e,n,i,r,s){const o=e.getGeometriesArray();let a,l;for(a=0,l=o.length;a<l;++a){(0,Hp[o[a].getType()])(t,o[a],n,i,r,s)}},Circle:function(t,e,n,i,r){const s=n.getFill(),o=n.getStroke();if(s||o){const a=t.getBuilder(n.getZIndex(),"Circle");a.setFillStrokeStyle(s,o),a.drawCircle(e,i,r)}const a=n.getText();if(a&&a.getText()){const s=t.getBuilder(n.getZIndex(),"Text");s.setTextStyle(a),s.drawText(e,i,r)}}};function Jp(t,e){return parseInt(wi(t),10)-parseInt(wi(e),10)}function Qp(t,e){const n=tm(t,e);return n*n}function tm(t,e){return.5*t/e}function em(t,e,n,i,r,s,o,a){const l=[],h=n.getImage();if(h){let t=!0;const e=h.getImageState();e==od||e==ad?t=!1:e==rd&&h.load(),t&&l.push(h.ready())}const c=n.getFill();c&&c.loading()&&l.push(c.ready());const u=l.length>0;return u&&Promise.all(l).then(()=>r(null)),function(t,e,n,i,r,s,o){const a=n.getGeometryFunction()(e);if(!a)return;const l=a.simplifyTransformed(i,r),h=n.getRenderer();if(h)nm(t,l,n,e,o);else{(0,Hp[l.getType()])(t,l,n,e,o,s)}}(t,e,n,i,s,o,a),u}function nm(t,e,n,i,r){if("GeometryCollection"==e.getType()){const s=e.getGeometries();for(let e=0,o=s.length;e<o;++e)nm(t,s[e],n,i,r);return}t.getBuilder(n.getZIndex(),"Default").drawCustom(e,i,n.getRenderer(),n.getHitDetectionRenderer(),r)}class im extends Xg{constructor(t){super(t),this.boundHandleStyleImageChange_=this.handleStyleImageChange_.bind(this),this.animatingOrInteracting_,this.hitDetectionImageData_=null,this.clipExtent_=null,this.extendX_=!1,this.renderedFeatures_=null,this.renderedRevision_=-1,this.renderedResolution_=NaN,this.renderedExtent_=[1/0,1/0,-1/0,-1/0],this.wrappedRenderedExtent_=[1/0,1/0,-1/0,-1/0],this.renderedRotation_,this.renderedCenter_=null,this.renderedProjection_=null,this.renderedPixelRatio_=1,this.renderedRenderOrder_=null,this.renderedFrameDeclutter_,this.replayGroup_=null,this.replayGroupChanged=!0,this.clipping=!0,this.targetContext_=null,this.opacity_=1}renderWorlds(t,e,n){const i=e.extent,r=e.viewState,s=r.center,o=r.resolution,a=r.projection,l=r.rotation,h=a.getExtent(),c=this.getLayer().getSource(),u=this.getLayer().getDeclutter(),d=e.pixelRatio,f=e.viewHints,g=!(f[ar]||f[lr]),p=this.context,m=Math.round(os(i)/o*d),_=Math.round(ns(i)/o*d),y=c.getWrapX()&&a.canWrapX(),x=y?os(h):null,v=y?Math.ceil((i[2]-h[2])/x)+(this.extendX_?2:1):1;let b=y?Math.floor((i[0]-h[0])/x)-(this.extendX_?1:0):0;do{let i=this.getRenderTransform(s,o,0,d,m,_,b*x);e.declutter&&(i=i.slice(0)),t.execute(p,[p.canvas.width,p.canvas.height],i,l,g,void 0===n?Gp:n?$p:Bp,n?u&&e.declutter[u]:void 0)}while(++b<v)}setDrawContext_(){1!==this.opacity_&&(this.targetContext_=this.context,this.context=Cl(this.context.canvas.width,this.context.canvas.height,Ug))}resetDrawContext_(){if(1!==this.opacity_&&this.targetContext_){const t=this.targetContext_.globalAlpha;this.targetContext_.globalAlpha=this.opacity_,this.targetContext_.drawImage(this.context.canvas,0,0),this.targetContext_.globalAlpha=t,Tl(this.context),Ug.push(this.context.canvas),this.context=this.targetContext_,this.targetContext_=null}}renderDeclutter(t){this.replayGroup_&&this.getLayer().getDeclutter()&&this.renderWorlds(this.replayGroup_,t,!0)}renderDeferredInternal(t){this.replayGroup_&&(this.clipExtent_&&this.clipUnrotated(this.context,t,this.clipExtent_),this.replayGroup_.renderDeferred(),this.clipExtent_&&(this.context.restore(),this.clipExtent_=null),this.resetDrawContext_())}renderFrame(t,e){const n=t.layerStatesArray[t.layerIndex];this.opacity_=n.opacity;const i=t.viewState;this.prepareContainer(t,e);const r=this.context,s=this.replayGroup_;let o=s&&!s.isEmpty();if(!o){if(!(this.getLayer().hasListener($h)||this.getLayer().hasListener(Bh)))return this.container}this.setDrawContext_(),this.preRender(r,t);const a=i.projection;this.clipExtent_=null;let l=!1;if(o&&n.extent&&this.clipping){const e=Ko(n.extent,a);o=as(e,t.extent);o&&!Dr(e,t.extent)&&(t.declutter?this.clipExtent_=e:(this.clipUnrotated(r,t,e),l=!0))}return o&&this.renderWorlds(s,t,!this.getLayer().getDeclutter()&&void 0),l&&r.restore(),this.postRender(r,t),this.renderedRotation_!==i.rotation&&(this.renderedRotation_=i.rotation,this.hitDetectionImageData_=null),t.declutter||this.resetDrawContext_(),this.container}getFeatures(t){return new Promise(e=>{if(this.frameState&&!this.hitDetectionImageData_&&!this.animatingOrInteracting_){const t=this.frameState.size.slice(),e=this.renderedCenter_,n=this.renderedResolution_,i=this.renderedRotation_,r=this.renderedProjection_,s=this.wrappedRenderedExtent_,o=this.getLayer(),a=[],l=t[0]*Zp,h=t[1]*Zp;a.push(this.getRenderTransform(e,n,i,Zp,l,h,0).slice());const c=o.getSource(),u=r.getExtent();if(c.getWrapX()&&r.canWrapX()&&!Dr(u,s)){let t=s[0];const r=os(u);let o,c=0;for(;t<u[0];)--c,o=r*c,a.push(this.getRenderTransform(e,n,i,Zp,l,h,o).slice()),t+=r;for(c=0,t=s[2];t>u[2];)++c,o=r*c,a.push(this.getRenderTransform(e,n,i,Zp,l,h,o).slice()),t-=r}const d=Xo();this.hitDetectionImageData_=Kp(t,a,this.renderedFeatures_,o.getStyleFunction(),s,n,i,Qp(n,this.renderedPixelRatio_),d?r:null)}e(Yp(t,this.renderedFeatures_,this.hitDetectionImageData_))})}forEachFeatureAtCoordinate(t,e,n,i,r){if(!this.replayGroup_)return;const s=e.viewState.resolution,o=e.viewState.rotation,a=this.getLayer(),l={},h=this.getLayer().getDeclutter();return this.replayGroup_.forEachFeatureAtCoordinate(t,s,o,n,function(t,e,n){const s=wi(t),o=l[s];if(o){if(!0!==o&&n<o.distanceSq){if(0===n)return l[s]=!0,r.splice(r.lastIndexOf(o),1),i(t,a,e);o.geometry=e,o.distanceSq=n}}else{if(0===n)return l[s]=!0,i(t,a,e);r.push(l[s]={feature:t,layer:a,geometry:e,distanceSq:n,callback:i})}},h?e.declutter?.[h]?.all().map(t=>t.value):null)}handleFontsChanged(){const t=this.getLayer();t.getVisible()&&this.replayGroup_&&t.changed()}handleStyleImageChange_(t){this.renderIfReadyAndVisible()}prepareFrame(t){const e=this.getLayer(),n=e.getSource();if(!n)return!1;const i=t.viewHints[ar],r=t.viewHints[lr],s=e.getUpdateWhileAnimating(),o=e.getUpdateWhileInteracting();if(this.ready&&!s&&i||!o&&r)return this.animatingOrInteracting_=!0,!0;this.animatingOrInteracting_=!1;const a=t.extent,l=t.viewState,h=l.projection,c=l.resolution,u=t.pixelRatio,d=e.getRevision(),f=e.getRenderBuffer();let g=e.getRenderOrder();void 0===g&&(g=Jp);const p=l.center.slice(),m=Ir(a,f*c),_=m.slice(),y=[m.slice()],x=h.getExtent(),v=n.getWrapX()&&h.canWrapX();if(this.extendX_=!1,v){const t=n.getExtent();t&&!ls(t)&&(this.extendX_=t[0]<x[0]||t[2]>x[2])}if(v&&(!Dr(x,t.extent)||this.extendX_)){const t=os(x),e=Math.max(os(m)/2,t);let n=x[0],i=x[2];this.extendX_&&(n-=t,i+=t),m[0]=n-e,m[2]=i+e,vs(p,h);const r=cs(y[0],h);r[0]<x[0]&&r[2]<x[2]?y.push([r[0]+t,r[1],r[2]+t,r[3]]):r[0]>x[0]&&r[2]>x[2]&&y.push([r[0]-t,r[1],r[2]-t,r[3]])}if(this.ready&&this.renderedResolution_==c&&this.renderedPixelRatio_===u&&this.renderedRevision_==d&&this.renderedRenderOrder_==g&&this.renderedFrameDeclutter_===!!t.declutter&&Dr(this.wrappedRenderedExtent_,m))return hi(this.renderedExtent_,_)||(this.hitDetectionImageData_=null,this.renderedExtent_=_),this.renderedCenter_=p,this.replayGroupChanged=!1,!0;this.replayGroup_=null;const b=new Cp(tm(c,u),m,c,u),w=Xo();let S;if(w){for(let t=0,e=y.length;t<e;++t){const e=Zo(y[t],h);n.loadFeatures(e,Yo(c,h),w)}S=No(w,h)}else for(let t=0,e=y.length;t<e;++t)n.loadFeatures(y[t],c,h);const C=Qp(c,u);let E=!0;const P=(t,n)=>{let i;const r=t.getStyleFunction()||e.getStyleFunction();if(r&&(i=r(t,c)),i){const e=this.renderFeature(t,C,i,b,S,this.getLayer().getDeclutter(),n);E=E&&!e}},T=Zo(m,h),R=n.getFeaturesInExtent(T);g&&R.sort(g);for(let t=0,e=R.length;t<e;++t)P(R[t],t);this.renderedFeatures_=R,this.ready=E;const F=b.finish(),M=new Xp(m,c,u,n.getOverlaps(),F,e.getRenderBuffer(),!!t.declutter);return this.renderedResolution_=c,this.renderedRevision_=d,this.renderedRenderOrder_=g,this.renderedFrameDeclutter_=!!t.declutter,this.renderedExtent_=_,this.wrappedRenderedExtent_=m,this.renderedCenter_=p,this.renderedProjection_=h,this.renderedPixelRatio_=u,this.replayGroup_=M,this.hitDetectionImageData_=null,this.replayGroupChanged=!0,!0}renderFeature(t,e,n,i,r,s,o){if(!n)return!1;let a=!1;if(Array.isArray(n))for(let l=0,h=n.length;l<h;++l)a=em(i,t,n[l],e,this.boundHandleStyleImageChange_,r,s,o)||a;else a=em(i,t,n,e,this.boundHandleStyleImageChange_,r,s,o);return a}}class rm extends Cf{constructor(t){super(t)}createRenderer(){return new im(this)}}const sm={image:["Polygon","Circle","LineString","Image","Text"],hybrid:["Polygon","LineString"],vector:[]},om={hybrid:["Image","Text","Default"],vector:["Polygon","Circle","LineString","Image","Text","Default"]};class am extends Kg{constructor(t,e){super(t,e),this.boundHandleStyleImageChange_=this.handleStyleImageChange_.bind(this),this.renderedLayerRevision_,this.renderedPixelToCoordinateTransform_=null,this.renderedRotation_,this.renderedOpacity_=1,this.tmpTransform_=[1,0,0,1,0,0],this.tileClipContexts_=null}enqueueTilesForNextExtent(){return"vector"!==this.getLayer().getRenderMode()}drawTile(t,e,n,i,r,s,o,a){this.updateExecutorGroup_(t,e.pixelRatio,e.viewState.projection),this.tileImageNeedsRender_(t)&&this.renderTileImage_(t,e),super.drawTile(t,e,n,i,r,s,o,a)}getTile(t,e,n,i){const r=this.getOrCreateTile(t,e,n,i);if(!r)return null;const s=i.viewState,o=s.resolution,a=i.viewHints,l=this.getLayer().getSource(),h=l.getTileGridForProjection(s.projection),c=!(a[ar]||a[lr]),u=h.getZForResolution(o,l.zDirection)===t;return c&&u?r.wantedResolution=o:r.wantedResolution||(r.wantedResolution=h.getResolution(t)),r}prepareFrame(t){const e=this.getLayer().getRevision();return this.renderedLayerRevision_!==e&&(this.renderedLayerRevision_=e,this.renderedTiles.length=0),super.prepareFrame(t)}updateExecutorGroup_(t,e,n){const i=this.getLayer(),r=i.getRevision(),s=i.getRenderOrder()||null,o=t.wantedResolution,a=t.getReplayState(i);if(!a.dirty&&a.renderedResolution===o&&a.renderedRevision==r&&a.renderedPixelRatio===e&&a.renderedRenderOrder==s)return;const l=i.getSource(),h=!!i.getDeclutter(),c=l.getTileGrid(),u=l.getTileGridForProjection(n).getTileCoordExtent(t.wrappedTileCoord),d=l.getSourceTiles(e,n,t),f=wi(i);delete t.hitDetectionImageData[f],t.executorGroups[f]=[],a.dirty=!1;for(let r=0,g=d.length;r<g;++r){const g=d[r];if(g.getState()!=tr)continue;const p=l.getProjection(),m=g.tileCoord;let _=c.getTileCoordExtent(m);n&&p&&!zo(n,p)&&(_=Bo(_,p,n,32));const y=is(u,_),x=Ir(y,i.getRenderBuffer()*o,this.tempExtent),v=Ur(_,y)?null:x,b=new Cp(0,y,o,e),w=Qp(o,e),S=function(t,e){let n;const r=t.getStyleFunction()||i.getStyleFunction();if(r&&(n=r(t,o)),n){const i=this.renderFeature(t,w,n,b,h,e);a.dirty=a.dirty||i}},C=g.getFeatures();s&&s!==a.renderedRenderOrder&&C.sort(s);for(let t=0,e=C.length;t<e;++t){let e=C[t];n&&g.projection&&!zo(n,g.projection)&&(e=e.clone(),e.getGeometry().applyTransform(Go(g.projection,n))),v&&!as(v,e.getGeometry().getExtent())||S.call(this,e,t)}const E=b.finish(),P="vector"!==i.getRenderMode()&&h&&1===d.length?null:y,T=new Xp(P,o,e,l.getOverlaps(),E,i.getRenderBuffer(),!0);t.executorGroups[f].push(T)}a.renderedRevision=r,a.renderedPixelRatio=e,a.renderedRenderOrder=s,a.renderedResolution=o}forEachFeatureAtCoordinate(t,e,n,i,r){const s=e.viewState.resolution,o=e.viewState.rotation;n=null==n?0:n;const a=this.getLayer(),l=a.getSource().getTileGridForProjection(e.viewState.projection),h=a.getRenderBuffer(),c=Mr([t]);Ir(c,s*(h+n),c);const u={},d=function(t,e,n){let s=t.getId();void 0===s&&(s=wi(t));const o=u[s];if(o){if(!0!==o&&n<o.distanceSq){if(0===n)return u[s]=!0,r.splice(r.lastIndexOf(o),1),i(t,a,e);o.geometry=e,o.distanceSq=n}}else{if(0===n)return u[s]=!0,i(t,a,e);r.push(u[s]={feature:t,layer:a,geometry:e,distanceSq:n,callback:i})}},f=this.renderedTiles,g=wi(a),p=a.getDeclutter(),m=p?e.declutter?.[p]?.all().map(t=>t.value):null;let _;t:for(let e=f.length-1;e>=0;--e){const i=f[e];if(!as(l.getTileCoordExtent(i.wrappedTileCoord),c))continue;const r=i.executorGroups[g];for(let e=0,i=r.length;e<i;++e)if(_=r[e].forEachFeatureAtCoordinate(t,s,o,n,d,m),_)break t}return _}getFeatures(t){return 0===this.renderedTiles.length?Promise.resolve([]):new Promise((e,n)=>{const i=this.getLayer(),r=i.getSource(),s=this.renderedProjection,o=s.getExtent(),a=this.renderedResolution,l=r.getTileGridForProjection(s),h=ra(this.renderedPixelToCoordinateTransform_,t.slice()),c=l.getTileCoordForCoordAndResolution(h,a).toString(),u=this.renderedTiles.find(t=>t.tileCoord.toString()===c&&t.getState()===tr);if(!u||u.loadingSourceTiles>0)return void e([]);r.getWrapX()&&s.canWrapX()&&!Dr(o,l.getTileCoordExtent(u.tileCoord))&&vs(h,s);const d=wi(i),f=rs(l.getTileCoordExtent(u.wrappedTileCoord)),g=[(h[0]-f[0])/a,(f[1]-h[1])/a],p=u.getSourceTiles().reduce((t,e)=>t.concat(e.getFeatures()),[]);let m=u.hitDetectionImageData[d];if(!m){const t=Lc(l.getTileSize(l.getZForResolution(a,r.zDirection))),e=this.renderedRotation_;m=Kp(t,[this.getRenderTransform(l.getTileCoordCenter(u.wrappedTileCoord),a,0,Zp,t[0]*Zp,t[1]*Zp,0)],p,i.getStyleFunction(),l.getTileCoordExtent(u.wrappedTileCoord),u.getReplayState(i).renderedResolution,e),u.hitDetectionImageData[d]=m}e(Yp(g,p,m))})}getFeaturesInExtent(t){const e=[],n=this.getTileCache();if(0===n.getCount())return e;const i=this.getLayer().getSource().getTileGridForProjection(this.frameState.viewState.projection),r=i.getZForResolution(this.renderedResolution),s={};return n.forEach(n=>{if(n.tileCoord[0]!==r||n.getState()!==tr)return;const o=n.getSourceTiles();for(let n=0,r=o.length;n<r;++n){const r=o[n],a=r.getKey();if(a in s)continue;s[a]=!0;const l=r.tileCoord;if(as(t,i.getTileCoordExtent(l))){const n=r.getFeatures();if(n)for(let i=0,r=n.length;i<r;++i){const r=n[i],s=r.getGeometry();as(t,s.getExtent())&&e.push(r)}}}}),e}handleFontsChanged(){const t=this.getLayer();t.getVisible()&&void 0!==this.renderedLayerRevision_&&t.changed()}handleStyleImageChange_(t){this.renderIfReadyAndVisible()}renderDeclutter(t,e){const n=this.context,i=n.globalAlpha;n.globalAlpha=e.opacity;const r=t.viewHints,s=!(r[ar]||r[lr]),o=[this.context.canvas.width,this.context.canvas.height],a=this.getLayer().getDeclutter(),l=a?t.declutter?.[a]:void 0,h=wi(this.getLayer()),c=this.renderedTiles;for(let e=0,n=c.length;e<n;++e){const n=c[e],i=n.executorGroups[h];if(i)for(let e=i.length-1;e>=0;--e)i[e].execute(this.context,o,this.getTileRenderTransform(n,t),t.viewState.rotation,s,$p,l)}n.globalAlpha=i}renderDeferredInternal(t){const e=this.renderedTiles,n=wi(this.getLayer()),i=e.reduce((t,e,i)=>(e.executorGroups[n].forEach(e=>t.push({executorGroup:e,index:i})),t),[]),r=i.map(({executorGroup:t})=>t.getDeferredZIndexContexts()),s={};for(let t=0,e=i.length;t<e;++t){const e=i[t].executorGroup.getDeferredZIndexContexts();for(const t in e)s[t]=!0}const o=Object.keys(s).map(Number).sort(ri);this.layerExtent&&this.clipUnrotated(this.context,t,this.layerExtent),o.forEach(t=>{r.forEach((e,n)=>{e[t]&&(e[t].forEach(t=>{const{executorGroup:e,index:r}=i[n],s=e.getRenderedContext(),o=s.globalAlpha;s.globalAlpha=this.renderedOpacity_;const a=this.tileClipContexts_[r];a&&a.draw(s),t.draw(s),a&&s.restore(),s.globalAlpha=o,t.clear()}),e[t].length=0)})}),this.layerExtent&&this.context.restore()}getTileRenderTransform(t,e){const n=e.pixelRatio,i=e.viewState,r=i.center,s=i.resolution,o=i.rotation,a=e.size,l=Math.round(a[0]*n),h=Math.round(a[1]*n),c=this.getLayer().getSource().getTileGridForProjection(e.viewState.projection),u=t.tileCoord,d=c.getTileCoordExtent(t.wrappedTileCoord),f=c.getTileCoordExtent(u,this.tempExtent)[0]-d[0];return ea(sa(this.inversePixelTransform.slice(),1/n,1/n),this.getRenderTransform(r,s,o,n,l,h,f))}postRender(t,e){const n=e.viewHints,i=!(n[ar]||n[lr]);this.renderedPixelToCoordinateTransform_=e.pixelToCoordinateTransform.slice(),this.renderedRotation_=e.viewState.rotation,this.renderedOpacity_=e.layerStatesArray[e.layerIndex].opacity;const r=this.getLayer(),s=r.getRenderMode(),o=t.globalAlpha;t.globalAlpha=this.renderedOpacity_;const a=r.getDeclutter(),l=a?om[s].filter(t=>!$p.includes(t)):om[s],h=e.viewState,c=h.rotation;this.layerExtent&&this.clipUnrotated(t,e,this.layerExtent);const u=r.getSource(),d=u.getTileGridForProjection(h.projection).getZForResolution(h.resolution,u.zDirection),f=this.renderedTiles,g=[],p=[],m=[],_=wi(r);let y=!0;for(let n=f.length-1;n>=0;--n){const s=f[n];y=y&&!s.getReplayState(r).dirty;const o=s.executorGroups[_].filter(t=>t.hasExecutors(l));if(0===o.length)continue;const h=this.getTileRenderTransform(s,e),u=s.tileCoord[0];let x=!1;const v=o[0].getClipCoords(h);let b,w=t;if(v){b=new $g,w=b.getContext();for(let t=0,e=g.length;t<e;++t)if(d!==u&&u<p[t]){const e=g[t];as([v[0],v[3],v[4],v[7]],[e[0],e[3],e[4],e[7]])&&(x||(w.save(),x=!0),w.beginPath(),w.moveTo(v[0],v[1]),w.lineTo(v[2],v[3]),w.lineTo(v[4],v[5]),w.lineTo(v[6],v[7]),w.moveTo(e[6],e[7]),w.lineTo(e[4],e[5]),w.lineTo(e[2],e[3]),w.lineTo(e[0],e[1]),w.clip())}g.push(v),p.push(u)}for(let n=0,r=o.length;n<r;++n){o[n].execute(t,[t.canvas.width,t.canvas.height],h,c,i,l,e.declutter?.[a])}x&&(w===t?w.restore():m[n]=b)}this.layerExtent&&t.restore(),t.globalAlpha=o,this.ready=y,this.tileClipContexts_=m,e.declutter||this.renderDeferredInternal(e),super.postRender(t,e)}renderFeature(t,e,n,i,r,s){if(!n)return!1;let o=!1;if(Array.isArray(n))for(let a=0,l=n.length;a<l;++a)o=em(i,t,n[a],e,this.boundHandleStyleImageChange_,void 0,r,s)||o;else o=em(i,t,n,e,this.boundHandleStyleImageChange_,void 0,r,s);return o}tileImageNeedsRender_(t){const e=this.getLayer();if("vector"===e.getRenderMode())return!1;const n=t.getReplayState(e),i=e.getRevision(),r=t.wantedResolution;return n.renderedTileResolution!==r||n.renderedTileRevision!==i}renderTileImage_(t,e){const n=this.getLayer(),i=t.getReplayState(n),r=n.getRevision(),s=t.executorGroups[wi(n)];i.renderedTileRevision=r;const o=t.wrappedTileCoord,a=o[0],l=n.getSource();let h=e.pixelRatio;const c=e.viewState.projection,u=l.getTileGridForProjection(c),d=u.getResolution(t.tileCoord[0]),f=e.pixelRatio/t.wantedResolution*d,g=u.getResolution(a),p=t.getContext();h=Math.round(Math.max(h,f/h));const m=l.getTilePixelSize(a,h,c);p.canvas.width=m[0],p.canvas.height=m[1];const _=h/f;if(1!==_){const t=ta(this.tmpTransform_);sa(t,_,_),p.setTransform.apply(p,t)}const y=u.getTileCoordExtent(o,this.tempExtent),x=f/g,v=ta(this.tmpTransform_);sa(v,x,-x),oa(v,-y[0],-y[3]);for(let t=0,e=s.length;t<e;++t){s[t].execute(p,[p.canvas.width*_,p.canvas.height*_],v,0,!0,sm[n.getRenderMode()],null)}i.renderedTileResolution=t.wantedResolution}}class lm extends Cf{constructor(t){t=t||{};const e=Object.assign({},t);delete e.preload;const n=void 0===t.cacheSize?0:t.cacheSize;delete t.cacheSize,delete e.useInterimTilesOnError,super(e),this.on,this.once,this.un,this.cacheSize_=n;const i=t.renderMode||"hybrid";ir("hybrid"==i||"vector"==i,"`renderMode` must be `'hybrid'` or `'vector'`"),this.renderMode_=i,this.setPreload(t.preload?t.preload:0),this.setUseInterimTilesOnError(void 0===t.useInterimTilesOnError||t.useInterimTilesOnError),this.getBackground,this.setBackground}createRenderer(){return new am(this,{cacheSize:this.cacheSize_})}getFeatures(t){return super.getFeatures(t)}getFeaturesInExtent(t){return this.getRenderer().getFeaturesInExtent(t)}getRenderMode(){return this.renderMode_}getPreload(){return this.get(Yg)}getUseInterimTilesOnError(){return this.get(Hg)}setPreload(t){this.set(Yg,t)}setUseInterimTilesOnError(t){this.set(Hg,t)}}function hm(t,e){return[[-1/0,-1/0,1/0,1/0]]}function cm(t,e){return[t]}class um extends Ci{constructor(t){super(),this.projection=Mo(t.projection),this.attributions_=dm(t.attributions),this.attributionsCollapsible_=t.attributionsCollapsible??!0,this.loading=!1,this.state_=void 0!==t.state?t.state:"ready",this.wrapX_=void 0!==t.wrapX&&t.wrapX,this.interpolate_=!!t.interpolate,this.viewResolver=null,this.viewRejector=null;const e=this;this.viewPromise_=new Promise(function(t,n){e.viewResolver=t,e.viewRejector=n})}getAttributions(){return this.attributions_}getAttributionsCollapsible(){return this.attributionsCollapsible_}getProjection(){return this.projection}getResolutions(t){return null}getView(){return this.viewPromise_}getState(){return this.state_}getWrapX(){return this.wrapX_}getInterpolate(){return this.interpolate_}refresh(){this.changed()}setAttributions(t){this.attributions_=dm(t),this.changed()}setState(t){this.state_=t,this.changed()}}function dm(t){return t?"function"==typeof t?t:(Array.isArray(t)||(t=[t]),e=>t):null}const fm=[0,0,0];class gm{constructor(t){let e;if(this.minZoom=void 0!==t.minZoom?t.minZoom:0,this.resolutions_=t.resolutions,ir(function(t,e){const n=e||ri;return t.every(function(e,i){if(0===i)return!0;const r=n(t[i-1],e);return!(r>0||0===r)})}(this.resolutions_,(t,e)=>e-t),"`resolutions` must be sorted in descending order"),!t.origins)for(let t=0,n=this.resolutions_.length-1;t<n;++t)if(e){if(this.resolutions_[t]/this.resolutions_[t+1]!==e){e=void 0;break}}else e=this.resolutions_[t]/this.resolutions_[t+1];this.zoomFactor_=e,this.maxZoom=this.resolutions_.length-1,this.origin_=void 0!==t.origin?t.origin:null,this.origins_=null,void 0!==t.origins&&(this.origins_=t.origins,ir(this.origins_.length==this.resolutions_.length,"Number of `origins` and `resolutions` must be equal"));const n=t.extent;void 0===n||this.origin_||this.origins_||(this.origin_=rs(n)),ir(!this.origin_&&this.origins_||this.origin_&&!this.origins_,"Either `origin` or `origins` must be configured, never both"),this.tileSizes_=null,void 0!==t.tileSizes&&(this.tileSizes_=t.tileSizes,ir(this.tileSizes_.length==this.resolutions_.length,"Number of `tileSizes` and `resolutions` must be equal")),this.tileSize_=void 0!==t.tileSize?t.tileSize:this.tileSizes_?null:ul,ir(!this.tileSize_&&this.tileSizes_||this.tileSize_&&!this.tileSizes_,"Either `tileSize` or `tileSizes` must be configured, never both"),this.extent_=void 0!==n?n:null,this.fullTileRanges_=null,this.tmpSize_=[0,0],this.tmpExtent_=[0,0,0,0],void 0!==t.sizes?this.fullTileRanges_=t.sizes.map((t,e)=>{const i=new Tg(Math.min(0,t[0]),Math.max(t[0]-1,-1),Math.min(0,t[1]),Math.max(t[1]-1,-1));if(n){const t=this.getTileRangeForExtentAndZ(n,e);i.minX=Math.max(t.minX,i.minX),i.maxX=Math.min(t.maxX,i.maxX),i.minY=Math.max(t.minY,i.minY),i.maxY=Math.min(t.maxY,i.maxY)}return i}):n&&this.calculateTileRanges_(n)}forEachTileCoord(t,e,n){const i=this.getTileRangeForExtentAndZ(t,e);for(let t=i.minX,r=i.maxX;t<=r;++t)for(let r=i.minY,s=i.maxY;r<=s;++r)n([e,t,r])}forEachTileCoordParentTileRange(t,e,n,i){let r,s,o,a=null,l=t[0]-1;for(2===this.zoomFactor_?(s=t[1],o=t[2]):a=this.getTileCoordExtent(t,i);l>=this.minZoom;){if(void 0!==s&&void 0!==o?(s=Math.floor(s/2),o=Math.floor(o/2),r=Rg(s,s,o,o,n)):r=this.getTileRangeForExtentAndZ(a,l,n),e(l,r))return!0;--l}return!1}getExtent(){return this.extent_}getMaxZoom(){return this.maxZoom}getMinZoom(){return this.minZoom}getOrigin(t){return this.origin_?this.origin_:this.origins_[t]}getOrigins(){return this.origins_}getResolution(t){return this.resolutions_[t]}getResolutions(){return this.resolutions_}getTileCoordChildTileRange(t,e,n){if(t[0]<this.maxZoom){if(2===this.zoomFactor_){const n=2*t[1],i=2*t[2];return Rg(n,n+1,i,i+1,e)}const i=this.getTileCoordExtent(t,n||this.tmpExtent_);return this.getTileRangeForExtentAndZ(i,t[0]+1,e)}return null}getTileRangeForTileCoordAndZ(t,e,n){if(e>this.maxZoom||e<this.minZoom)return null;const i=t[0],r=t[1],s=t[2];if(e===i)return Rg(r,s,r,s,n);if(this.zoomFactor_){const t=Math.pow(this.zoomFactor_,e-i),o=Math.floor(r*t),a=Math.floor(s*t);if(e<i)return Rg(o,o,a,a,n);return Rg(o,Math.floor(t*(r+1))-1,a,Math.floor(t*(s+1))-1,n)}const o=this.getTileCoordExtent(t,this.tmpExtent_);return this.getTileRangeForExtentAndZ(o,e,n)}getTileRangeForExtentAndZ(t,e,n){this.getTileCoordForXYAndZ_(t[0],t[3],e,!1,fm);const i=fm[1],r=fm[2];this.getTileCoordForXYAndZ_(t[2],t[1],e,!0,fm);return Rg(i,fm[1],r,fm[2],n)}getTileCoordCenter(t){const e=this.getOrigin(t[0]),n=this.getResolution(t[0]),i=Lc(this.getTileSize(t[0]),this.tmpSize_);return[e[0]+(t[1]+.5)*i[0]*n,e[1]-(t[2]+.5)*i[1]*n]}getTileCoordExtent(t,e){const n=this.getOrigin(t[0]),i=this.getResolution(t[0]),r=Lc(this.getTileSize(t[0]),this.tmpSize_),s=n[0]+t[1]*r[0]*i,o=n[1]-(t[2]+1)*r[1]*i;return jr(s,o,s+r[0]*i,o+r[1]*i,e)}getTileCoordForCoordAndResolution(t,e,n){return this.getTileCoordForXYAndResolution_(t[0],t[1],e,!1,n)}getTileCoordForXYAndResolution_(t,e,n,i,r){const s=this.getZForResolution(n),o=n/this.getResolution(s),a=this.getOrigin(s),l=Lc(this.getTileSize(s),this.tmpSize_);let h=o*(t-a[0])/n/l[0],c=o*(a[1]-e)/n/l[1];return i?(h=vr(h,5)-1,c=vr(c,5)-1):(h=xr(h,5),c=xr(c,5)),Ng(s,h,c,r)}getTileCoordForXYAndZ_(t,e,n,i,r){const s=this.getOrigin(n),o=this.getResolution(n),a=Lc(this.getTileSize(n),this.tmpSize_);let l=(t-s[0])/o/a[0],h=(s[1]-e)/o/a[1];return i?(l=vr(l,5)-1,h=vr(h,5)-1):(l=xr(l,5),h=xr(h,5)),Ng(n,l,h,r)}getTileCoordForCoordAndZ(t,e,n){return this.getTileCoordForXYAndZ_(t[0],t[1],e,!1,n)}getTileCoordResolution(t){return this.resolutions_[t[0]]}getTileSize(t){return this.tileSize_?this.tileSize_:this.tileSizes_[t]}getFullTileRange(t){return this.fullTileRanges_?this.fullTileRanges_[t]:this.extent_?this.getTileRangeForExtentAndZ(this.extent_,t):null}getZForResolution(t,e){return cr(oi(this.resolutions_,t,e||0),this.minZoom,this.maxZoom)}tileCoordIntersectsViewport(t,e){return Za(e,0,e.length,2,this.getTileCoordExtent(t))}calculateTileRanges_(t){const e=this.resolutions_.length,n=new Array(e);for(let i=this.minZoom;i<e;++i)n[i]=this.getTileRangeForExtentAndZ(t,i);this.fullTileRanges_=n}}function pm(t){let e=t.getDefaultTileGrid();return e||(e=vm(t),t.setDefaultTileGrid(e)),e}function mm(t,e,n){const i=e[0],r=t.getTileCoordCenter(e),s=bm(n);if(!Ar(s,r)){const e=os(s),n=Math.ceil((s[0]-r[0])/e);return r[0]+=e*n,t.getTileCoordForCoordAndZ(r,i)}return e}function _m(t,e,n,i){i=void 0!==i?i:"top-left";const r=xm(t,e,n);return new gm({extent:t,origin:Qr(t,i),resolutions:r,tileSize:n})}function ym(t){const e=t||{},n=e.extent||Mo("EPSG:3857").getExtent(),i={extent:n,minZoom:e.minZoom,tileSize:e.tileSize,resolutions:xm(n,e.maxZoom,e.tileSize,e.maxResolution)};return new gm(i)}function xm(t,e,n,i){e=void 0!==e?e:42,n=Lc(void 0!==n?n:ul);const r=ns(t),s=os(t);i=i>0?i:Math.max(s/n[0],r/n[1]);const o=e+1,a=new Array(o);for(let t=0;t<o;++t)a[t]=i/Math.pow(2,t);return a}function vm(t,e,n,i){return _m(bm(t),e,n,i)}function bm(t){let e=(t=Mo(t)).getExtent();if(!e){const n=180*ks.degrees/t.getMetersPerUnit();e=jr(-n,-n,n,n)}return e}var wm=Object.freeze({__proto__:null,TileGrid:gm,WMTS:class extends gm{constructor(t){super({extent:t.extent,origin:t.origin,origins:t.origins,resolutions:t.resolutions,tileSize:t.tileSize,tileSizes:t.tileSizes,sizes:t.sizes}),this.matrixIds_=t.matrixIds}getMatrixId(t){return this.matrixIds_[t]}getMatrixIds(){return this.matrixIds_}},createForExtent:_m,createForProjection:vm,createXYZ:ym,extentFromProjection:bm,getForProjection:pm,wrapX:mm});function Sm(t,e){const n=[];Object.keys(e).forEach(function(t){null!==e[t]&&void 0!==e[t]&&n.push(t+"="+encodeURIComponent(e[t]))});const i=n.join("&");return t=t.replace(/[?&]$/,""),(t+=t.includes("?")?"&":"?")+i}const Cm=/\{z\}/g,Em=/\{x\}/g,Pm=/\{y\}/g,Tm=/\{-y\}/g;function Rm(t,e){return function(n,i,r){if(!n)return;let s;const o=n[0];if(e){const t=e.getFullTileRange(o);t&&(s=t.getHeight()-1)}return function(t,e,n,i,r){return t.replace(Cm,e.toString()).replace(Em,n.toString()).replace(Pm,i.toString()).replace(Tm,function(){if(void 0===r)throw new Error("If the URL template has a {-y} placeholder, the grid extent must be known");return(r-i).toString()})}(t,o,n[1],n[2],s)}}function Fm(t,e){const n=t.length,i=new Array(n);for(let r=0;r<n;++r)i[r]=Rm(t[r],e);return Mm(i)}function Mm(t){return 1===t.length?t[0]:function(e,n,i){if(!e)return;const r=pr(Gg(e),t.length);return t[r](e,n,i)}}class Im extends um{constructor(t){super({attributions:t.attributions,attributionsCollapsible:t.attributionsCollapsible,projection:t.projection,state:t.state,wrapX:t.wrapX,interpolate:t.interpolate}),this.on,this.once,this.un,this.tilePixelRatio_=void 0!==t.tilePixelRatio?t.tilePixelRatio:1,this.tileGrid=void 0!==t.tileGrid?t.tileGrid:null;const e=[256,256];this.tileGrid&&Lc(this.tileGrid.getTileSize(this.tileGrid.getMinZoom()),e),this.tmpSize=[0,0],this.key_=t.key||wi(this),this.tileOptions={transition:t.transition,interpolate:t.interpolate},this.zDirection=t.zDirection?t.zDirection:0}getGutterForProjection(t){return 0}getKey(){return this.key_}setKey(t){this.key_!==t&&(this.key_=t,this.changed())}getResolutions(t){const e=t?this.getTileGridForProjection(t):this.tileGrid;return e?e.getResolutions():null}getTile(t,e,n,i,r,s){return vi()}getTileGrid(){return this.tileGrid}getTileGridForProjection(t){return this.tileGrid?this.tileGrid:pm(t)}getTilePixelRatio(t){return this.tilePixelRatio_}getTilePixelSize(t,e,n){const i=this.getTileGridForProjection(n),r=this.getTilePixelRatio(e),s=Lc(i.getTileSize(t),this.tmpSize);return 1==r?s:(o=s,a=r,void 0===(l=this.tmpSize)&&(l=[0,0]),l[0]=o[0]*a+.5|0,l[1]=o[1]*a+.5|0,l);var o,a,l}getTileCoordForTileUrlFunction(t,e){const n=void 0!==e?e:this.getProjection(),i=void 0!==e?this.getTileGridForProjection(n):this.tileGrid||this.getTileGridForProjection(n);return this.getWrapX()&&n.isGlobal()&&(t=mm(i,t,n)),function(t,e){const n=t[0],i=t[1],r=t[2];if(e.getMinZoom()>n||n>e.getMaxZoom())return!1;const s=e.getFullTileRange(n);return!s||s.containsXY(i,r)}(t,i)?t:null}clear(){}refresh(){this.clear(),super.refresh()}}class km extends pi{constructor(t,e){super(t),this.tile=e}}var Lm="tileloadstart",Am="tileloadend",Dm="tileloaderror";class Om extends Im{constructor(t){super({attributions:t.attributions,cacheSize:t.cacheSize,projection:t.projection,state:t.state,tileGrid:t.tileGrid,tilePixelRatio:t.tilePixelRatio,wrapX:t.wrapX,transition:t.transition,interpolate:t.interpolate,key:t.key,attributionsCollapsible:t.attributionsCollapsible,zDirection:t.zDirection}),this.generateTileUrlFunction_=this.tileUrlFunction===Om.prototype.tileUrlFunction,this.tileLoadFunction=t.tileLoadFunction,t.tileUrlFunction&&(this.tileUrlFunction=t.tileUrlFunction),this.urls=null,t.urls?this.setUrls(t.urls):t.url&&this.setUrl(t.url),this.tileLoadingKeys_={}}getTileLoadFunction(){return this.tileLoadFunction}getTileUrlFunction(){return Object.getPrototypeOf(this).tileUrlFunction===this.tileUrlFunction?this.tileUrlFunction.bind(this):this.tileUrlFunction}getUrls(){return this.urls}handleTileChange(t){const e=t.target,n=wi(e),i=e.getState();let r;i==Qi?(this.tileLoadingKeys_[n]=!0,r=Lm):n in this.tileLoadingKeys_&&(delete this.tileLoadingKeys_[n],r=i==er?Dm:i==tr?Am:void 0),null!=r&&this.dispatchEvent(new km(r,e))}setTileLoadFunction(t){this.tileLoadFunction=t,this.changed()}setTileUrlFunction(t,e){this.tileUrlFunction=t,void 0!==e?this.setKey(e):this.changed()}setUrl(t){const e=function(t){const e=[];let n=/\{([a-z])-([a-z])\}/.exec(t);if(n){const i=n[1].charCodeAt(0),r=n[2].charCodeAt(0);let s;for(s=i;s<=r;++s)e.push(t.replace(n[0],String.fromCharCode(s)));return e}if(n=/\{(\d+)-(\d+)\}/.exec(t),n){const i=parseInt(n[2],10);for(let r=parseInt(n[1],10);r<=i;r++)e.push(t.replace(n[0],r.toString()));return e}return e.push(t),e}(t);this.urls=e,this.setUrls(e)}setUrls(t){this.urls=t;const e=t.join("\n");this.generateTileUrlFunction_?this.setTileUrlFunction(Fm(t,this.tileGrid),e):this.setKey(e)}tileUrlFunction(t,e,n){}}class zm extends Om{constructor(t){super({attributions:t.attributions,cacheSize:t.cacheSize,projection:t.projection,state:t.state,tileGrid:t.tileGrid,tileLoadFunction:t.tileLoadFunction?t.tileLoadFunction:Nm,tilePixelRatio:t.tilePixelRatio,tileUrlFunction:t.tileUrlFunction,url:t.url,urls:t.urls,wrapX:t.wrapX,transition:t.transition,interpolate:void 0===t.interpolate||t.interpolate,key:t.key,attributionsCollapsible:t.attributionsCollapsible,zDirection:t.zDirection}),this.crossOrigin=void 0!==t.crossOrigin?t.crossOrigin:null,this.referrerPolicy=t.referrerPolicy,this.tileClass=void 0!==t.tileClass?t.tileClass:Pg,this.tileGridForProjection={},this.reprojectionErrorThreshold_=t.reprojectionErrorThreshold,this.renderReprojectionEdges_=!1}getGutterForProjection(t){return this.getProjection()&&t&&!zo(this.getProjection(),t)?0:this.getGutter()}getGutter(){return 0}getKey(){let t=super.getKey();return this.getInterpolate()||(t+=":disable-interpolation"),t}getTileGridForProjection(t){const e=this.getProjection();if(this.tileGrid&&(!e||zo(e,t)))return this.tileGrid;const n=wi(t);return n in this.tileGridForProjection||(this.tileGridForProjection[n]=pm(t)),this.tileGridForProjection[n]}createTile_(t,e,n,i,r,s){const o=[t,e,n],a=this.getTileCoordForTileUrlFunction(o,r),l=a?this.tileUrlFunction(a,i,r):void 0,h=new this.tileClass(o,void 0!==l?Ji:nr,void 0!==l?l:"",{crossOrigin:this.crossOrigin,referrerPolicy:this.referrerPolicy},this.tileLoadFunction,this.tileOptions);return h.key=s,h.addEventListener(Vn,this.handleTileChange.bind(this)),h}getTile(t,e,n,i,r,s){const o=this.getProjection();if(!o||!r||zo(o,r))return this.getTileInternal(t,e,n,i,o||r);const a=[t,e,n],l=this.getKey(),h=this.getTileGridForProjection(o),c=this.getTileGridForProjection(r),u=this.getTileCoordForTileUrlFunction(a,r),d=new Og(o,h,r,c,a,u,this.getTilePixelRatio(i),this.getGutter(),(t,e,n,i)=>this.getTileInternal(t,e,n,i,o,s),this.reprojectionErrorThreshold_,this.renderReprojectionEdges_,this.tileOptions);return d.key=l,d}getTileInternal(t,e,n,i,r,s){const o=this.getKey(),a=jg(this,o,t,e,n);if(s&&s.containsKey(a)){return s.get(a)}const l=this.createTile_(t,e,n,i,r,o);return s?.set(a,l),l}setRenderReprojectionEdges(t){this.renderReprojectionEdges_!=t&&(this.renderReprojectionEdges_=t,this.changed())}setTileGridForProjection(t,e){const n=Mo(t);if(n){const t=wi(n);t in this.tileGridForProjection||(this.tileGridForProjection[t]=e)}}}function Nm(t,e){if(Oi){const n=t.getCrossOrigin();let i="same-origin",r="same-origin";"anonymous"===n||""===n?(i="cors",r="omit"):"use-credentials"===n&&(i="cors",r="include");const s={mode:i,credentials:r,referrerPolicy:t.getReferrerPolicy()};return void fetch(e,s).then(t=>{if(!t.ok)throw new Error(`HTTP ${t.status}`);return t.blob()}).then(t=>createImageBitmap(t)).then(e=>{const n=t.getImage();n.width=e.width,n.height=e.height;n.getContext("2d").drawImage(e,0,0),e.close?.(),n.dispatchEvent(new Event("load"))}).catch(()=>{t.getImage().dispatchEvent(new Event("error"))})}t.getImage().src=e}class jm extends zm{constructor(t){if(super({attributions:t.attributions,cacheSize:t.cacheSize,crossOrigin:t.crossOrigin,interpolate:t.interpolate,projection:Mo("EPSG:3857"),reprojectionErrorThreshold:t.reprojectionErrorThreshold,state:"loading",tileLoadFunction:t.tileLoadFunction,wrapX:void 0===t.wrapX||t.wrapX,transition:t.transition,zDirection:t.zDirection}),this.tileJSON_=null,this.tileSize_=t.tileSize,t.url)if(t.jsonp)!function(t,e,n){const i=document.createElement("script"),r="olc_"+wi(e);function s(){delete window[r],i.parentNode.removeChild(i)}i.async=!0,i.src=t+(t.includes("?")?"&":"?")+"callback="+r;const o=setTimeout(function(){s(),n&&n()},1e4);window[r]=function(t){clearTimeout(o),s(),e(t)},document.head.appendChild(i)}(t.url,this.handleTileJSONResponse.bind(this),this.handleTileJSONError.bind(this));else{const e=new XMLHttpRequest;e.addEventListener("load",this.onXHRLoad_.bind(this)),e.addEventListener("error",this.onXHRError_.bind(this)),e.open("GET",t.url),e.send()}else{if(!t.tileJSON)throw new Error("Either `url` or `tileJSON` options must be provided");this.handleTileJSONResponse(t.tileJSON)}}onXHRLoad_(t){const e=t.target;if(!e.status||e.status>=200&&e.status<300){let t;try{t=JSON.parse(e.responseText)}catch{return void this.handleTileJSONError()}this.handleTileJSONResponse(t)}else this.handleTileJSONError()}onXHRError_(t){this.handleTileJSONError()}getTileJSON(){return this.tileJSON_}handleTileJSONResponse(t){const e=Mo("EPSG:4326"),n=this.getProjection();let i;if(void 0!==t.bounds){const r=No(e,n);i=hs(t.bounds,r)}const r=bm(n),s=t.minzoom||0,o=ym({extent:r,maxZoom:t.maxzoom||22,minZoom:s,tileSize:this.tileSize_});if(this.tileGrid=o,this.tileUrlFunction=Fm(t.tiles,o),t.attribution&&!this.getAttributions()){const e=void 0!==i?i:r;this.setAttributions(function(n){return as(e,n.extent)?[t.attribution]:null})}this.tileJSON_=t,this.setState("ready")}handleTileJSONError(){this.setState("error")}}function Gm(t,e,n,i,r,s,o){const a=new XMLHttpRequest;a.open("GET","function"==typeof t?t(n,i,r):t,!0),"arraybuffer"==e.getType()&&(a.responseType="arraybuffer"),a.withCredentials=false,a.onload=function(t){if(!a.status||a.status>=200&&a.status<300){const t=e.getType();try{let i;"text"==t||"json"==t?i=a.responseText:"xml"==t?i=a.responseXML||a.responseText:"arraybuffer"==t&&(i=a.response),i?s(e.readFeatures(i,{extent:n,featureProjection:r}),e.readProjection(i)):o()}catch{o()}}else o()},a.onerror=o,a.send()}function $m(t,e){return function(n,i,r,s,o){Gm(t,e,n,i,r,(t,e)=>{this.addFeatures(t),void 0!==s&&s(t)},()=>{this.changed(),void 0!==o&&o()})}}class Bm{constructor(t){this.rbush_=new Hh(t),this.items_={}}insert(t,e){const n={minX:t[0],minY:t[1],maxX:t[2],maxY:t[3],value:e};this.rbush_.insert(n),this.items_[wi(e)]=n}load(t,e){const n=new Array(e.length);for(let i=0,r=e.length;i<r;i++){const r=t[i],s=e[i],o={minX:r[0],minY:r[1],maxX:r[2],maxY:r[3],value:s};n[i]=o,this.items_[wi(s)]=o}this.rbush_.load(n)}remove(t){const e=wi(t),n=this.items_[e];return delete this.items_[e],null!==this.rbush_.remove(n)}update(t,e){const n=this.items_[wi(e)];Ur([n.minX,n.minY,n.maxX,n.maxY],t)||(this.remove(e),this.insert(t,e))}getAll(){return this.rbush_.all().map(function(t){return t.value})}getInExtent(t){const e={minX:t[0],minY:t[1],maxX:t[2],maxY:t[3]};return this.rbush_.search(e).map(function(t){return t.value})}forEach(t){return this.forEach_(this.getAll(),t)}forEachInExtent(t,e){return this.forEach_(this.getInExtent(t),e)}forEach_(t,e){let n;for(let i=0,r=t.length;i<r;i++)if(n=e(t[i]),n)return n;return n}isEmpty(){return Gn(this.items_)}clear(){this.rbush_.clear(),this.items_={}}getExtent(t){const e=this.rbush_.toJSON();return jr(e.minX,e.minY,e.maxX,e.maxY,t)}concat(t){this.rbush_.load(t.rbush_.all());for(const e in t.items_)this.items_[e]=t.items_[e]}}var Um="addfeature",Vm="changefeature",Xm="clear",Wm="removefeature",qm="featuresloadstart",Zm="featuresloadend",Km="featuresloaderror";class Ym extends pi{constructor(t,e,n){super(t),this.feature=e,this.features=n}}class Hm extends um{constructor(t){super({attributions:(t=t||{}).attributions,interpolate:!0,projection:void 0,state:"ready",wrapX:void 0===t.wrapX||t.wrapX}),this.on,this.once,this.un,this.loader_=di,this.format_=t.format||null,this.overlaps_=void 0===t.overlaps||t.overlaps,this.url_=t.url,void 0!==t.loader?this.loader_=t.loader:void 0!==this.url_&&(ir(this.format_,"`format` must be set when `url` is set"),this.loader_=$m(this.url_,this.format_)),this.strategy_=void 0!==t.strategy?t.strategy:hm;const e=void 0===t.useSpatialIndex||t.useSpatialIndex;let n,i;this.featuresRtree_=e?new Bm:null,this.loadedExtentsRtree_=new Bm,this.nullGeometryFeatures_={},this.idIndex_={},this.uidIndex_={},this.featureChangeKeys_={},this.featuresCollection_=null,Array.isArray(t.features)?i=t.features:t.features&&(n=t.features,i=n.getArray()),e||void 0!==n||(n=new Ti(i)),void 0!==i&&this.addFeaturesInternal(i),void 0!==n&&this.bindFeaturesCollection_(n)}addFeature(t){this.addFeatureInternal(t),this.changed()}addFeatureInternal(t){const e=wi(t);if(!this.addToIndex_(e,t))return void(this.featuresCollection_&&this.featuresCollection_.remove(t));this.setupChangeEvents_(e,t);const n=t.getGeometry();if(n){const e=n.getExtent();this.featuresRtree_&&this.featuresRtree_.insert(e,t)}else this.nullGeometryFeatures_[e]=t;this.dispatchEvent(new Ym(Um,t))}setupChangeEvents_(t,e){e instanceof Bf||(this.featureChangeKeys_[t]=[$n(e,Vn,this.handleFeatureChange_,this),$n(e,Nn,this.handleFeatureChange_,this)])}addToIndex_(t,e){let n=!0;if(void 0!==e.getId()){const t=String(e.getId());if(t in this.idIndex_)if(e instanceof Bf){const i=this.idIndex_[t];i instanceof Bf?Array.isArray(i)?i.push(e):this.idIndex_[t]=[i,e]:n=!1}else n=!1;else this.idIndex_[t]=e}return n&&(ir(!(t in this.uidIndex_),"The passed `feature` was already added to the source"),this.uidIndex_[t]=e),n}addFeatures(t){this.addFeaturesInternal(t),this.changed()}addFeaturesInternal(t){const e=[],n=[],i=[];for(let e=0,i=t.length;e<i;e++){const i=t[e],r=wi(i);this.addToIndex_(r,i)&&n.push(i)}for(let t=0,r=n.length;t<r;t++){const r=n[t],s=wi(r);this.setupChangeEvents_(s,r);const o=r.getGeometry();if(o){const t=o.getExtent();e.push(t),i.push(r)}else this.nullGeometryFeatures_[s]=r}if(this.featuresRtree_&&this.featuresRtree_.load(e,i),this.hasListener(Um))for(let t=0,e=n.length;t<e;t++)this.dispatchEvent(new Ym(Um,n[t]))}bindFeaturesCollection_(t){let e=!1;this.addEventListener(Um,function(n){e||(e=!0,t.push(n.feature),e=!1)}),this.addEventListener(Wm,function(n){e||(e=!0,t.remove(n.feature),e=!1)}),t.addEventListener(On,t=>{e||(e=!0,this.addFeature(t.element),e=!1)}),t.addEventListener(zn,t=>{e||(e=!0,this.removeFeature(t.element),e=!1)}),this.featuresCollection_=t}clear(t){if(t){for(const t in this.featureChangeKeys_){this.featureChangeKeys_[t].forEach(Un)}this.featuresCollection_||(this.featureChangeKeys_={},this.idIndex_={},this.uidIndex_={})}else if(this.featuresRtree_){this.featuresRtree_.forEach(t=>{this.removeFeatureInternal(t)});for(const t in this.nullGeometryFeatures_)this.removeFeatureInternal(this.nullGeometryFeatures_[t])}this.featuresCollection_&&this.featuresCollection_.clear(),this.featuresRtree_&&this.featuresRtree_.clear(),this.nullGeometryFeatures_={};const e=new Ym(Xm);this.dispatchEvent(e),this.changed()}forEachFeature(t){if(this.featuresRtree_)return this.featuresRtree_.forEach(t);this.featuresCollection_&&this.featuresCollection_.forEach(t)}forEachFeatureAtCoordinateDirect(t,e){const n=[t[0],t[1],t[0],t[1]];return this.forEachFeatureInExtent(n,function(n){const i=n.getGeometry();if(i instanceof Bf||i.intersectsCoordinate(t))return e(n)})}forEachFeatureInExtent(t,e){if(this.featuresRtree_)return this.featuresRtree_.forEachInExtent(t,e);this.featuresCollection_&&this.featuresCollection_.forEach(e)}forEachFeatureIntersectingExtent(t,e){return this.forEachFeatureInExtent(t,function(n){const i=n.getGeometry();if(i instanceof Bf||i.intersectsExtent(t)){const t=e(n);if(t)return t}})}getFeaturesCollection(){return this.featuresCollection_}getFeatures(){let t;return this.featuresCollection_?t=this.featuresCollection_.getArray().slice(0):this.featuresRtree_&&(t=this.featuresRtree_.getAll(),Gn(this.nullGeometryFeatures_)||li(t,Object.values(this.nullGeometryFeatures_))),t}getFeaturesAtCoordinate(t){const e=[];return this.forEachFeatureAtCoordinateDirect(t,function(t){e.push(t)}),e}getFeaturesInExtent(t,e){if(this.featuresRtree_){if(!(e&&e.canWrapX()&&this.getWrapX()))return this.featuresRtree_.getInExtent(t);const n=us(t,e);return[].concat(...n.map(t=>this.featuresRtree_.getInExtent(t)))}return this.featuresCollection_?this.featuresCollection_.getArray().slice(0):[]}getClosestFeatureToCoordinate(t,e){const n=t[0],i=t[1];let r=null;const s=[NaN,NaN];let o=1/0;const a=[-1/0,-1/0,1/0,1/0];return e=e||ci,this.featuresRtree_.forEachInExtent(a,function(t){if(e(t)){const e=t.getGeometry(),l=o;if(o=e instanceof Bf?0:e.closestPointXY(n,i,s,o),o<l){r=t;const e=Math.sqrt(o);a[0]=n-e,a[1]=i-e,a[2]=n+e,a[3]=i+e}}}),r}getExtent(t){return this.featuresRtree_?.getExtent(t)??null}getFeatureById(t){const e=this.idIndex_[t.toString()];return void 0!==e?e:null}getFeatureByUid(t){const e=this.uidIndex_[t];return void 0!==e?e:null}getFormat(){return this.format_}getOverlaps(){return this.overlaps_}getUrl(){return this.url_}handleFeatureChange_(t){const e=t.target,n=wi(e),i=e.getGeometry();if(i){const t=i.getExtent();n in this.nullGeometryFeatures_?(delete this.nullGeometryFeatures_[n],this.featuresRtree_&&this.featuresRtree_.insert(t,e)):this.featuresRtree_&&this.featuresRtree_.update(t,e)}else n in this.nullGeometryFeatures_||(this.featuresRtree_&&this.featuresRtree_.remove(e),this.nullGeometryFeatures_[n]=e);const r=e.getId();if(void 0!==r){const t=r.toString();this.idIndex_[t]!==e&&(this.removeFromIdIndex_(e),this.idIndex_[t]=e)}else this.removeFromIdIndex_(e),this.uidIndex_[n]=e;this.changed(),this.dispatchEvent(new Ym(Vm,e))}hasFeature(t){const e=t.getId();return void 0!==e?e in this.idIndex_:wi(t)in this.uidIndex_}isEmpty(){return this.featuresRtree_?this.featuresRtree_.isEmpty()&&Gn(this.nullGeometryFeatures_):!this.featuresCollection_||0===this.featuresCollection_.getLength()}loadFeatures(t,e,n){const i=this.loadedExtentsRtree_,r=this.strategy_(t,e,n);for(let t=0,s=r.length;t<s;++t){const s=r[t];if(!i.forEachInExtent(s,function(t){return Dr(t.extent,s)})){this.loading=Number(this.loading)+1,this.dispatchEvent(new Ym(qm));const t=t=>{this.loading=Number(this.loading)-1,this.dispatchEvent(new Ym(Zm,void 0,t))},r=()=>{this.changed(),this.loading=Number(this.loading)-1,this.dispatchEvent(new Ym(Km))};let o=!1;const a=this.loader_.call(this,s,e,n,e=>o||t(e),()=>o||r());a instanceof Promise?(o=!0,a.then(e=>{this.addFeatures(e),t(e)}).catch(r)):this.loader_.length<4&&(this.loading=!1),i.insert(s,{extent:s.slice()})}}}refresh(){this.clear(!0),this.loadedExtentsRtree_.clear(),super.refresh()}removeLoadedExtent(t){const e=this.loadedExtentsRtree_,n=e.forEachInExtent(t,function(e){if(Ur(e.extent,t))return e});n&&e.remove(n)}removeFeatures(t){let e=!1;for(let n=0,i=t.length;n<i;++n)e=this.removeFeatureInternal(t[n])||e;e&&this.changed()}removeFeature(t){if(!t)return;this.removeFeatureInternal(t)&&this.changed()}removeFeatureInternal(t){const e=wi(t);if(!(e in this.uidIndex_))return!1;e in this.nullGeometryFeatures_?delete this.nullGeometryFeatures_[e]:this.featuresRtree_&&this.featuresRtree_.remove(t);const n=this.featureChangeKeys_[e];n?.forEach(Un),delete this.featureChangeKeys_[e];const i=t.getId();if(void 0!==i){const e=i.toString(),n=this.idIndex_[e];n===t?delete this.idIndex_[e]:Array.isArray(n)&&(n.splice(n.indexOf(t),1),1===n.length&&(this.idIndex_[e]=n[0]))}return delete this.uidIndex_[e],this.hasListener(Wm)&&this.dispatchEvent(new Ym(Wm,t)),!0}removeFromIdIndex_(t){for(const e in this.idIndex_)if(this.idIndex_[e]===t){delete this.idIndex_[e];break}}setLoader(t){this.loader_=t}setUrl(t){ir(this.format_,"`format` must be set when `url` is set"),this.url_=t,this.setLoader($m(t,this.format_))}setOverlaps(t){this.overlaps_=t,this.changed()}}const Jm=[];class Qm extends bg{constructor(t,e,n,i,r){super(t,e,{transition:0}),this.context_=null,this.executorGroups={},this.loadingSourceTiles=0,this.hitDetectionImageData={},this.replayState_={},this.sourceTiles=[],this.errorTileKeys={},this.wantedResolution,this.getSourceTiles=i.bind(void 0,this),this.removeSourceTiles_=r,this.wrappedTileCoord=n}getContext(){return this.context_||(this.context_=Cl(1,1,Jm)),this.context_}hasContext(){return!!this.context_}getImage(){return this.hasContext()?this.getContext().canvas:null}getReplayState(t){const e=wi(t);return e in this.replayState_||(this.replayState_[e]={dirty:!1,renderedRenderOrder:null,renderedResolution:NaN,renderedPixelRatio:NaN,renderedRevision:-1,renderedTileResolution:NaN,renderedTileRevision:-1,renderedTileZ:-1}),this.replayState_[e]}load(){this.getSourceTiles()}release(){this.context_&&(Tl(this.context_),Jm.push(this.context_.canvas),this.context_=null),this.removeSourceTiles_(this),this.sourceTiles.length=0,super.release()}}let t_=class extends bg{constructor(t,e,n,i,r,s){super(t,e,s),this.extent=null,this.format_=i,this.features_=null,this.loader_,this.projection=null,this.resolution,this.tileLoadFunction_=r,this.url_=n,this.key=n}getTileUrl(){return this.url_}getFormat(){return this.format_}getFeatures(){return this.features_}load(){this.state==Ji&&(this.setState(Qi),this.tileLoadFunction_(this,this.url_),this.loader_&&this.loader_(this.extent,this.resolution,this.projection))}onLoad(t,e){this.setFeatures(t)}onError(){this.setState(er)}setFeatures(t){this.features_=t,this.setState(tr)}setLoader(t){this.loader_=t}};class e_ extends Om{constructor(t){const e=t.projection||"EPSG:3857",n=t.extent||bm(e),i=t.tileGrid||ym({extent:n,maxResolution:t.maxResolution,maxZoom:void 0!==t.maxZoom?t.maxZoom:22,minZoom:t.minZoom,tileSize:t.tileSize||512});super({attributions:t.attributions,attributionsCollapsible:t.attributionsCollapsible,cacheSize:t.cacheSize,interpolate:!0,projection:e,state:t.state,tileGrid:i,tileLoadFunction:t.tileLoadFunction?t.tileLoadFunction:n_,tileUrlFunction:t.tileUrlFunction,url:t.url,urls:t.urls,wrapX:void 0===t.wrapX||t.wrapX,transition:t.transition,zDirection:void 0===t.zDirection?1:t.zDirection}),this.format_=t.format?t.format:null,this.tileKeysBySourceTileUrl_={},this.sourceTiles_={},this.overlaps_=null==t.overlaps||t.overlaps,this.tileClass=t.tileClass?t.tileClass:t_,this.tileGrids_={}}getOverlaps(){return this.overlaps_}getSourceTiles(t,e,n,i){if(n.getState()===Ji){n.setState(Qi);const r=n.wrappedTileCoord,s=this.getTileGridForProjection(e);let o=s.getTileCoordExtent(r);const a=r[0],l=s.getResolution(a);Ir(o,-l,o);const h=this.projection;e&&this.projection&&!zo(e,h)&&(o=Bo(o,e,h));const c=this.tileGrid,u=c.getExtent();u&&is(o,u,o);let d=l;e&&h&&!zo(e,h)&&(d=l/h.getMetersPerUnit()/e.getMetersPerUnit());const f=c.getZForResolution(d,this.zDirection),g=i||this.tileUrlFunction;c.forEachTileCoord(o,f,i=>{const r=g(i,t,e);this.sourceTiles_[r]||(this.sourceTiles_[r]=new this.tileClass(i,r?Ji:nr,r,this.format_,this.tileLoadFunction));const s=this.sourceTiles_[r];n.sourceTiles.push(s),this.tileKeysBySourceTileUrl_[r]||(this.tileKeysBySourceTileUrl_[r]=[]),this.tileKeysBySourceTileUrl_[r].push(n.getKey());const o=s.getState();if(o<tr){const t=e=>{this.handleTileChange(e);const i=s.getState();if(i===tr||i===er){const e=s.getKey();e in n.errorTileKeys?s.getState()===tr&&delete n.errorTileKeys[e]:n.loadingSourceTiles--,i===er?n.errorTileKeys[e]=!0:s.removeEventListener(Vn,t),0===n.loadingSourceTiles&&n.setState(Gn(n.errorTileKeys)?tr:er)}};s.addEventListener(Vn,t),n.loadingSourceTiles++}o===Ji&&(s.extent=c.getTileCoordExtent(i),s.projection=this.projection,s.resolution=c.getResolution(i[0]),s.load())}),n.loadingSourceTiles||n.setState(n.sourceTiles.some(t=>t.getState()===er)?er:tr)}return n.sourceTiles}removeSourceTiles(t){const e=t.getKey(),n=t.sourceTiles;for(let t=0,i=n.length;t<i;++t){const i=n[t].getTileUrl();if(!this.tileKeysBySourceTileUrl_[i])return;const r=this.tileKeysBySourceTileUrl_[i].indexOf(e);-1!==r&&(this.tileKeysBySourceTileUrl_[i].splice(r,1),0===this.tileKeysBySourceTileUrl_[i].length&&(delete this.tileKeysBySourceTileUrl_[i],delete this.sourceTiles_[i]))}}getTile(t,e,n,i,r){const s=[t,e,n];let o=this.getTileCoordForTileUrlFunction(s,r);const a=this.getTileGrid().getExtent(),l=this.projection,h=this.getTileGridForProjection(r);if(o&&a){const e=h.getTileCoordExtent(o);Ir(e,-h.getResolution(t),e),as(a,r&&l&&!zo(r,l)?Bo(e,r,l):e)||(o=null)}let c=!0;if(null!==o){const e=this.tileGrid,n=h.getResolution(t);let s=n;r&&l&&!zo(r,l)&&(s=n/l.getMetersPerUnit()/r.getMetersPerUnit());const a=e.getZForResolution(s,1),u=h.getTileCoordExtent(o);Ir(u,-n,u),e.forEachTileCoord(r&&l&&!zo(r,l)?Bo(u,r,l):u,a,t=>{c=c&&!this.tileUrlFunction(t,i,l)})}const u=this.tileUrlFunction,d=new Qm(s,c?nr:Ji,o,t=>this.getSourceTiles(i,r,t,u),this.removeSourceTiles.bind(this));return d.key=this.getKey(),d}getTileGridForProjection(t){const e=t.getCode();let n=this.tileGrids_[e];if(!n){const i=this.projection;if(null!==i&&!zo(i,t))return pm(t);const r=this.tileGrid,s=r.getResolutions().slice(),o=s.map(function(t,e){return r.getOrigin(e)}),a=s.map(function(t,e){return r.getTileSize(e)}),l=43;for(let t=s.length;t<l;++t)s.push(s[t-1]/2),o.push(o[t-1]),a.push(a[t-1]);n=new gm({extent:r.getExtent(),origins:o,resolutions:s,tileSizes:a}),this.tileGrids_[e]=n}return n}getTilePixelRatio(t){return t}getTilePixelSize(t,e,n){const i=Lc(this.getTileGridForProjection(n).getTileSize(t),this.tmpSize);return[Math.round(i[0]*e),Math.round(i[1]*e)]}setOverlaps(t){this.overlaps_=t,this.changed()}}function n_(t,e){t.setLoader(function(n,i,r){Gm(e,t.getFormat(),n,i,r,t.onLoad.bind(t),t.onError.bind(t))})}function i_(t,e){const n=e[0].evaluate(t),i=e[1].evaluate(t),r=e[2].evaluate(t),s=e[3]?e[3].evaluate(t):1;return lt.parse(`hsla(${n}, ${i}%, ${r}%, ${s})`)}function r_(t){if(Array.isArray(t)){if(0===t.length)return t;const e=t[0];if("literal"===e)return t;if("image"===e&&3===t.length&&"object"==typeof t[2]&&null!==t[2]&&!Array.isArray(t[2])){return["image-config",r_(t[1]),["literal",t[2]]]}const n=t.length;for(let i=1;i<n;++i){const r=t[i],s=r_(r);if(s!==r){const r=[e];for(let e=1;e<i;++e)r.push(t[e]);r.push(s);for(let e=i+1;e<n;++e)r.push(r_(t[e]));return r}}}return t}const s_={},o_={zoom:0,distanceFromCenter:0};Ze.register(qe,{...Ze.definitions,pitch:[{kind:"number"},[],t=>o_.pitch||0],"distance-from-center":[{kind:"number"},[],t=>o_.distanceFromCenter||0],"to-hsla":[{kind:"array",itemType:{kind:"number"},N:4},[{kind:"string"}],(t,[e])=>function(t){const e=t[0]/255,n=t[1]/255,i=t[2]/255,r=t[3],s=Math.max(e,n,i),o=Math.min(e,n,i),a=(s+o)/2;let l,h;if(s===o)l=0,h=0;else{const t=s-o;switch(h=a>.5?t/(2-s-o):t/(s+o),s){case e:l=(n-i)/t+(n<i?6:0);break;case n:l=(i-e)/t+2;break;case i:l=(e-n)/t+4;break;default:l=0}l/=6}return[360*l,100*h,100*a,r]}(Fc(e.evaluate(t)))],hsl:[{kind:"color"},[{kind:"number"},{kind:"number"},{kind:"number"}],i_],hsla:[{kind:"color"},[{kind:"number"},{kind:"number"},{kind:"number"},{kind:"number"}],i_],"image-config":[{kind:"value"},[{kind:"string"},{kind:"value"}],(t,[e,n])=>e.evaluate(t)],"measure-light":[{kind:"number"},[{kind:"value"}],()=>1],config:[{kind:"value"},[{kind:"string"}],(t,[e])=>{const n=s_[e.evaluate(t)];return void 0===n?{}:n}]});const a_="https://api.mapbox.com";function l_(t){const e="mapbox://";return 0!==t.indexOf(e)?"":t.slice(9)}function h_(t,e,n){const i=l_(t);if(!e||!i)return decodeURI(new URL(t,n).href);const r="sprites/";if(0!==i.indexOf(r))throw new Error(`unexpected sprites url: ${t}`);const s=i.slice(8);return`${a_}/styles/v1/${s}/sprite?access_token=${e}`}function c_(t,e){const n=l_(t);if(!n||!e)return decodeURI(new URL(t,location.href).href);const i="styles/";if(0!==n.indexOf(i))throw new Error(`unexpected style url: ${t}`);const r=n.slice(7);return`${a_}/styles/v1/${r}?&access_token=${e}`}const u_=["a","b","c","d"];function d_(t,e,n,i){const r=new URL(t,i||location.href),s=l_(t);if(!s)return e?(r.searchParams.has(n)||r.searchParams.set(n,e),[decodeURI(r.href)]):[decodeURI(r.href)];if("mapbox.satellite"===s){const t=window.devicePixelRatio>=1.5?"@2x":"";return[`https://api.mapbox.com/v4/${s}/{z}/{x}/{y}${t}.webp?access_token=${e}`]}return u_.map(t=>`https://${t}.tiles.mapbox.com/v4/${s}/{z}/{x}/{y}.vector.pbf?access_token=${e}`)}class f_ extends Xg{constructor(t){super(t),this.image=null,this.renderedSourceRevision_=0}getImage(){return this.image?this.image.getImage():null}prepareFrame(t){const e=t.layerStatesArray[t.layerIndex],n=t.pixelRatio,i=t.viewState,r=i.resolution,s=this.getLayer().getSource(),o=t.viewHints;let a=t.extent;if(void 0!==e.extent&&(a=is(a,Ko(e.extent,i.projection))),!o[ar]&&!o[lr]&&!ls(a))if(s){this.getLayer().rendered||this.renderedSourceRevision_===s.getRevision()||(this.image=null),this.renderedSourceRevision_=s.getRevision();const t=i.projection,e=s.getImage(a,r,n,t);e&&(this.loadImage(e)?this.image=e:e.getState()===ld&&(this.image=null))}else this.image=null;return!!this.image}getData(t){const e=this.frameState;if(!e)return null;const n=this.getLayer(),i=ra(e.pixelToCoordinateTransform,t.slice()),r=n.getExtent();if(r&&!Ar(r,i))return null;const s=this.image.getExtent(),o=this.image.getImage(),a=os(s),l=Math.floor(o.width*((i[0]-s[0])/a));if(l<0||l>=o.width)return null;const h=ns(s),c=Math.floor(o.height*((s[3]-i[1])/h));return c<0||c>=o.height?null:this.getImageData(o,l,c)}renderFrame(t,e){const n=this.image,i=n.getExtent(),r=n.getResolution(),[s,o]=Array.isArray(r)?r:[r,r],a=n.getPixelRatio(),l=t.layerStatesArray[t.layerIndex],h=t.pixelRatio,c=t.viewState,u=c.center,d=c.resolution,f=h*s/(d*a),g=h*o/(d*a);this.prepareContainer(t,e);const p=this.context.canvas.width,m=this.context.canvas.height,_=this.getRenderContext(t);let y=!1,x=!0;if(l.extent){const e=Ko(l.extent,c.projection);x=as(e,t.extent),y=x&&!Dr(e,t.extent),y&&this.clipUnrotated(_,t,e)}const v=n.getImage(),b=aa(this.tempTransform,p/2,m/2,f,g,0,a*(i[0]-u[0])/s,a*(u[1]-i[3])/o);this.renderedResolution=o*h/a;const w=v.width*b[0],S=v.height*b[3];if(this.getLayer().getSource().getInterpolate()||(_.imageSmoothingEnabled=!1),this.preRender(_,t),x&&w>=.5&&S>=.5){const t=b[4],e=b[5],n=l.opacity;1!==n&&(_.save(),_.globalAlpha=n),_.drawImage(v,0,0,+v.width,+v.height,t,e,w,S),1!==n&&_.restore()}return this.postRender(this.context,t),y&&_.restore(),_.imageSmoothingEnabled=!0,this.container}}class g_ extends Wh{constructor(t){super(t=t||{})}}class p_ extends g_{constructor(t){super(t)}createRenderer(){return new f_(this)}getData(t){return super.getData(t)}}class m_ extends hd{constructor(t,e,n,i,r){super(t,e,n,void 0!==r?rd:od),this.loader_=void 0!==r?r:null,this.canvas_=i,this.error_=null}getError(){return this.error_}handleLoad_(t){t?(this.error_=t,this.state=ad):this.state=od,this.changed()}load(){this.state==rd&&(this.state=sd,this.changed(),this.loader_(this.handleLoad_.bind(this)))}getImage(){return this.canvas_}}function __(t){return Array.isArray(t)?Math.min(...t):t}class y_ extends hd{constructor(t,e,n,i,r,s,o){let a=t.getExtent();a&&t.canWrapX()&&(a=a.slice(),a[0]=-1/0,a[2]=1/0);let l=e.getExtent();l&&e.canWrapX()&&(l=l.slice(),l[0]=-1/0,l[2]=1/0);const h=l?is(n,l):n,c=Lg(t,e,Jr(h),i),u=new Dg(t,e,h,a,.5*c,i),d=u.calculateSourceExtent(),f=ls(d)?null:s(d,c,r),g=f?rd:ld,p=f?f.getPixelRatio():1;super(n,i,p,g),this.targetProj_=e,this.maxSourceExtent_=a,this.triangulation_=u,this.targetResolution_=i,this.targetExtent_=n,this.sourceImage_=f,this.sourcePixelRatio_=p,this.interpolate_=o,this.canvas_=null,this.sourceListenerKey_=null}disposeInternal(){this.state==sd&&this.unlistenSource_(),super.disposeInternal()}getImage(){return this.canvas_}getProjection(){return this.targetProj_}reproject_(){const t=this.sourceImage_.getState();if(t==od){const t=os(this.targetExtent_)/this.targetResolution_,e=ns(this.targetExtent_)/this.targetResolution_;this.canvas_=Ag(t,e,this.sourcePixelRatio_,__(this.sourceImage_.getResolution()),this.maxSourceExtent_,this.targetResolution_,this.targetExtent_,this.triangulation_,[{extent:this.sourceImage_.getExtent(),image:this.sourceImage_.getImage()}],0,void 0,this.interpolate_,!0)}this.state=t,this.changed()}load(){if(this.state==rd){this.state=sd,this.changed();const t=this.sourceImage_.getState();t==od||t==ad?this.reproject_():(this.sourceListenerKey_=$n(this.sourceImage_,Vn,t=>{const e=this.sourceImage_.getState();e!=od&&e!=ad||(this.unlistenSource_(),this.reproject_())}),this.sourceImage_.load())}}unlistenSource_(){Un(this.sourceListenerKey_),this.sourceListenerKey_=null}}const x_="imageloadstart",v_="imageloadend",b_="imageloaderror";class w_ extends pi{constructor(t,e){super(t),this.image=e}}class S_ extends um{constructor(t){super({attributions:t.attributions,projection:t.projection,state:t.state,interpolate:void 0===t.interpolate||t.interpolate}),this.on,this.once,this.un,this.loader=t.loader||null,this.resolutions_=void 0!==t.resolutions?t.resolutions:null,this.reprojectedImage_=null,this.reprojectedRevision_=0,this.image=null,this.wantedExtent_,this.wantedResolution_,this.static_=!!t.loader&&0===t.loader.length,this.wantedProjection_=null}getResolutions(){return this.resolutions_}setResolutions(t){this.resolutions_=t}findNearestResolution(t){const e=this.getResolutions();if(e){t=e[oi(e,t,0)]}return t}getImage(t,e,n,i){const r=this.getProjection();if(!r||!i||zo(r,i))return r&&(i=r),this.getImageInternal(t,e,n,i);if(this.reprojectedImage_){if(this.reprojectedRevision_==this.getRevision()&&zo(this.reprojectedImage_.getProjection(),i)&&this.reprojectedImage_.getResolution()==e&&Ur(this.reprojectedImage_.getExtent(),t))return this.reprojectedImage_;this.reprojectedImage_.dispose(),this.reprojectedImage_=null}return this.reprojectedImage_=new y_(r,i,t,e,n,(t,e,n)=>this.getImageInternal(t,e,n,r),this.getInterpolate()),this.reprojectedRevision_=this.getRevision(),this.reprojectedImage_}getImageInternal(t,e,n,i){if(this.loader){const r=E_(t,e,n,1),s=this.findNearestResolution(e);if(this.image&&(this.static_||this.wantedProjection_===i&&(this.wantedExtent_&&Dr(this.wantedExtent_,r)||Dr(this.image.getExtent(),r))&&(this.wantedResolution_&&__(this.wantedResolution_)===s||__(this.image.getResolution())===s)))return this.image;this.wantedProjection_=i,this.wantedExtent_=r,this.wantedResolution_=s,this.image=new hd(r,s,n,this.loader),this.image.addEventListener(Vn,this.handleImageChange.bind(this))}return this.image}handleImageChange(t){const e=t.target;let n;switch(e.getState()){case sd:this.loading=!0,n=x_;break;case od:this.loading=!1,n=v_;break;case ad:this.loading=!1,n=b_;break;default:return}this.hasListener(n)&&this.dispatchEvent(new w_(n,e))}}function C_(t,e){t.getImage().src=e}function E_(t,e,n,i){const r=e/n,s=Jr(t),o=vr(os(t)/r,4),a=vr(ns(t)/r,4);return ts(s,r,0,[o+2*vr((i-1)*o/2,4),a+2*vr((i-1)*a/2,4)])}function P_(t){return function(e){const n=e.buffers,i=e.meta,r=e.imageOps,s=e.width,o=e.height,a=n.length,l=n[0].byteLength;if(r){const e=new Array(a);for(let t=0;t<a;++t)e[t]=new ImageData(new Uint8ClampedArray(n[t]),s,o);return t(e,i).data.buffer}const h=new Uint8ClampedArray(l),c=new Array(a),u=new Array(a);for(let t=0;t<a;++t)c[t]=new Uint8ClampedArray(n[t]),u[t]=[0,0,0,0];for(let e=0;e<l;e+=4){for(let t=0;t<a;++t){const n=c[t];u[t][0]=n[e],u[t][1]=n[e+1],u[t][2]=n[e+2],u[t][3]=n[e+3]}const n=t(u,i);h[e]=n[0],h[e+1]=n[1],h[e+2]=n[2],h[e+3]=n[3]}return h.buffer}}function T_(t,e){const n=Object.keys(t.lib||{}).map(function(e){return"const "+e+" = "+t.lib[e].toString()+";"}).concat(["const __minion__ = ("+P_.toString()+")(",t.operation.toString(),");",'self.addEventListener("message", function(event) {'," const buffer = __minion__(event.data);"," self.postMessage({buffer: buffer, meta: event.data.meta}, [buffer]);","});"]),i=new Worker("undefined"==typeof Blob?"data:text/javascript;base64,"+Buffer.from(n.join("\n"),"binary").toString("base64"):URL.createObjectURL(new Blob(n,{type:"text/javascript"})));return i.addEventListener("message",e),i}class R_ extends ii{constructor(t){let e;super(),this.imageOps_=!!t.imageOps,e=0===t.threads?0:this.imageOps_?1:t.threads||1;const n=new Array(e);if(e)for(let i=0;i<e;++i)n[i]=T_(t,this.onWorkerMessage_.bind(this,i));else n[0]=function(t,e){const n=P_(t.operation);let i=!1;return{postMessage:function(t){setTimeout(function(){i||e({data:{buffer:n(t),meta:t.meta}})},0)},terminate:function(){i=!0}}}(t,this.onWorkerMessage_.bind(this,0));this.workers_=n,this.queue_=[],this.maxQueueLength_=t.queue||1/0,this.running_=0,this.dataLookup_={},this.job_=null}process(t,e,n){this.enqueue_({inputs:t,meta:e,callback:n}),this.dispatch_()}enqueue_(t){for(this.queue_.push(t);this.queue_.length>this.maxQueueLength_;)this.queue_.shift().callback(null,null)}dispatch_(){if(this.running_||0===this.queue_.length)return;const t=this.queue_.shift();this.job_=t;const e=t.inputs[0].width,n=t.inputs[0].height,i=t.inputs.map(function(t){return t.data.buffer}),r=this.workers_.length;if(this.running_=r,1===r)return void this.workers_[0].postMessage({buffers:i,meta:t.meta,imageOps:this.imageOps_,width:e,height:n},i);const s=t.inputs[0].data.length,o=4*Math.ceil(s/4/r);for(let s=0;s<r;++s){const r=s*o,a=[];for(let t=0,e=i.length;t<e;++t)a.push(i[t].slice(r,r+o));this.workers_[s].postMessage({buffers:a,meta:t.meta,imageOps:this.imageOps_,width:e,height:n},a)}}onWorkerMessage_(t,e){this.disposed||(this.dataLookup_[t]=e.data,--this.running_,0===this.running_&&this.resolveJob_())}resolveJob_(){const t=this.job_,e=this.workers_.length;let n,i;if(1===e)n=new Uint8ClampedArray(this.dataLookup_[0].buffer),i=this.dataLookup_[0].meta;else{const r=t.inputs[0].data.length;n=new Uint8ClampedArray(r),i=new Array(e);const s=4*Math.ceil(r/4/e);for(let t=0;t<e;++t){const e=this.dataLookup_[t].buffer,r=t*s;n.set(new Uint8ClampedArray(e),r),i[t]=this.dataLookup_[t].meta}}this.job_=null,this.dataLookup_={},t.callback(null,new ImageData(n,t.inputs[0].width,t.inputs[0].height),i),this.dispatch_()}disposeInternal(){for(let t=0;t<this.workers_.length;++t)this.workers_[t].terminate();this.workers_.length=0}}const F_="beforeoperations",M_="afteroperations";class I_ extends pi{constructor(t,e,n){super(t),this.extent=e.extent,this.resolution=e.viewState.resolution/e.pixelRatio,this.data=n}}class k_ extends S_{constructor(t){super({projection:null}),this.on,this.once,this.un,this.processor_=null,this.operationType_=void 0!==t.operationType?t.operationType:"pixel",this.threads_=void 0!==t.threads?t.threads:1,this.layers_=function(t){const e=t.length,n=new Array(e);for(let i=0;i<e;++i)n[i]=D_(t[i]);return n}(t.sources);const e=this.changed.bind(this);for(let t=0,n=this.layers_.length;t<n;++t)this.layers_[t].addEventListener(Vn,e);var n;this.useResolutions_=null!==t.resolutions,this.tileQueue_=new or(function(){return 1},this.processSources_.bind(this)),this.requestedFrameState_,this.renderedImageCanvas_=null,this.renderedRevision_,this.frameState_={animate:!1,coordinateToPixelTransform:[1,0,0,1,0,0],declutter:null,extent:null,index:0,layerIndex:0,layerStatesArray:(n=this.layers_,n.map(function(t){return t.getLayerState()})),pixelRatio:1,pixelToCoordinateTransform:[1,0,0,1,0,0],postRenderFunctions:[],size:[0,0],tileQueue:this.tileQueue_,time:Date.now(),usedTiles:{},viewState:{rotation:0},viewHints:[],wantedTiles:{},mapId:wi(this),renderTargets:{}},this.setAttributions(function(e){const n=[];for(let i=0,r=t.sources.length;i<r;++i){const r=t.sources[i],s=r instanceof um?r:r.getSource();if(!s)continue;const o=s.getAttributions()?.(e);"string"==typeof o?n.push(o):void 0!==o&&n.push(...o)}return n}),void 0!==t.operation&&this.setOperation(t.operation,t.lib)}setOperation(t,e){this.processor_&&this.processor_.dispose(),this.processor_=new R_({operation:t,imageOps:"image"===this.operationType_,queue:1,lib:e,threads:this.threads_}),this.changed()}updateFrameState_(t,e,n){const i=Object.assign({},this.frameState_);i.viewState=Object.assign({},i.viewState);const r=Jr(t);i.size[0]=Math.ceil(os(t)/e),i.size[1]=Math.ceil(ns(t)/e),i.extent=[r[0]-i.size[0]*e/2,r[1]-i.size[1]*e/2,r[0]+i.size[0]*e/2,r[1]+i.size[1]*e/2],i.time=Date.now();const s=i.viewState;return s.center=r,s.projection=n,s.resolution=e,i}allSourcesReady_(){let t,e=!0;for(let n=0,i=this.layers_.length;n<i;++n)if(t=this.layers_[n].getSource(),!t||"ready"!==t.getState()){e=!1;break}return e}getImage(t,e,n,i){if(!this.allSourcesReady_())return null;this.tileQueue_.loadMoreTiles(16,16),e=this.findNearestResolution(e);const r=this.updateFrameState_(t,e,i);if(this.requestedFrameState_=r,this.renderedImageCanvas_){const t=this.renderedImageCanvas_.getResolution(),n=this.renderedImageCanvas_.getExtent();e===t&&Ur(r.extent,n)||(this.renderedImageCanvas_=null)}return this.renderedImageCanvas_&&this.getRevision()===this.renderedRevision_||this.processSources_(),r.animate&&requestAnimationFrame(this.changed.bind(this)),this.renderedImageCanvas_}processSources_(){const t=this.requestedFrameState_,e=this.layers_.length,n=new Array(e);for(let i=0;i<e;++i){t.layerIndex=i,t.renderTargets={};const e=A_(this.layers_[i],t);if(!e)return;n[i]=e}const i={};this.dispatchEvent(new I_(F_,t,i)),this.processor_.process(n,i,this.onWorkerComplete_.bind(this,t))}onWorkerComplete_(t,e,n,i){if(e||!n)return;const r=t.extent,s=t.viewState.resolution;if(s!==this.requestedFrameState_.viewState.resolution||!Ur(r,this.requestedFrameState_.extent))return;let o;if(this.renderedImageCanvas_)o=this.renderedImageCanvas_.getImage().getContext("2d");else{o=Cl(Math.round(os(r)/s),Math.round(ns(r)/s)),this.renderedImageCanvas_=new m_(r,s,1,o.canvas)}o.putImageData(n,0,0),t.animate?requestAnimationFrame(this.changed.bind(this)):this.changed(),this.renderedRevision_=this.getRevision(),this.dispatchEvent(new I_(M_,t,i))}getResolutions(t){if(!this.useResolutions_)return null;let e=super.getResolutions();if(!e)for(let n=0,i=this.layers_.length;n<i;++n){if(e=this.layers_[n].getSource().getResolutions(t),e)break}return e}disposeInternal(){this.processor_&&this.processor_.dispose(),super.disposeInternal()}}k_.prototype.dispose;let L_=null;function A_(t,e){const n=t.getRenderer();if(!n)throw new Error("Unsupported layer type: "+t);if(!n.prepareFrame(e))return null;const i=e.size[0],r=e.size[1];if(0===i||0===r)return null;const s=n.renderFrame(e,null);let o;if(s instanceof HTMLCanvasElement)o=s;else{if(s&&(o=s.firstElementChild),!(o instanceof HTMLCanvasElement))throw new Error("Unsupported rendered element: "+o);if(o.width===i&&o.height===r){return o.getContext("2d").getImageData(0,0,i,r)}}if(L_){const t=L_.canvas;t.width!==i||t.height!==r?L_=Cl(i,r,void 0,{willReadFrequently:!0}):L_.clearRect(0,0,i,r)}else L_=Cl(i,r,void 0,{willReadFrequently:!0});return L_.drawImage(o,0,0,i,r),L_.getImageData(0,0,i,r)}function D_(t){let e;return t instanceof um?t instanceof Im?e=new Qg({source:t}):t instanceof S_&&(e=new p_({source:t})):e=t,e}function O_(t,e){const n=t[0],i=n.width,r=n.height,s=n.data,o=new Uint8ClampedArray(s.length),a=2*e.resolution,l=i-1,h=r-1,c=[0,0,0,0],u=Math.PI,d=e.encoding,f=e.exaggeration,g=e.zoom,p=e.method||"standard",m=e.accentColor,_=e.shadowColors||[e.shadowColor],y=e.highlightColors||[e.highlightColor],x=(e.azimuths||[e.sunAz]).map(t=>t*u/180),v=(e.altitudes||[45]).map(t=>t*u/180),b=Math.min(x.length,v.length,_.length,y.length,4),w=g<2?.4:g<4.5?.35:.3,S=g<15?Math.pow(2,(15-g)*w):1;function C(t,e="mapbox"){return"mapbox"===e?.1*(256*t[0]*256+256*t[1]+t[2])-1e4:"terrarium"===e?256*t[0]+t[1]+t[2]/256-32768:0}function E(t,e){return 0!==t?Math.atan2(e,-t):u/2*(e>0?1:-1)}const P="igor"===p?function(t,e){const n=E(t*=2*f,e*=2*f),i=x[0]+u,r=Math.atan(Math.sqrt(t*t+e*e))*(2/u);let s=(n+i)/u+.5;s%=2,s<0&&(s+=2);const o=1-Math.abs(s-1),a=r*o,l=r*(1-o),h=_[0],c=y[0];return[h.r*a+c.r*l,h.g*a+c.g*l,h.b*a+c.b*l,h.a*a+c.a*l]}:"basic"===p?function(t,e){t*=2*f,e*=2*f;const n=x[0]+u,i=Math.cos(n),r=Math.sin(n),s=Math.cos(v[0]),o=(Math.sin(v[0])-(e*i*s-t*r*s))/Math.sqrt(1+t*t+e*e),a=Math.max(0,Math.min(1,o));if(a>.5){const t=2*a-1,e=y[0];return[e.r*t,e.g*t,e.b*t,e.a*t]}const l=1-2*a,h=_[0];return[h.r*l,h.g*l,h.b*l,h.a*l]}:"combined"===p?function(t,e){t*=2*f,e*=2*f;const n=x[0]+u,i=Math.cos(n),r=Math.sin(n),s=Math.cos(v[0]),o=Math.sin(v[0]);let a=Math.acos((o-(e*i*s-t*r*s))/Math.sqrt(1+t*t+e*e));a=Math.max(0,Math.min(u/2,a));const l=Math.atan(Math.sqrt(t*t+e*e))*(4/u/u),h=a*l,c=(u/2-a)*l,d=_[0],g=y[0];return[d.r*h+g.r*c,d.g*h+g.g*c,d.b*h+g.b*c,d.a*h+g.a*c]}:"multidirectional"===p?function(t,e){const n=(t*=2*f)*t+(e*=2*f)*e,i=Math.sqrt(1+n);let r=0,s=0,o=0,a=0;for(let n=0;n<b;n++){const l=Math.cos(v[n]),h=(Math.sin(v[n])-(e*-Math.cos(x[n])*l-t*-Math.sin(x[n])*l))/i,c=Math.max(0,Math.min(1,h)),u=_[Math.min(n,_.length-1)],d=y[Math.min(n,y.length-1)];if(c>.5){const t=(2*c-1)/b;r+=d.r*t,s+=d.g*t,o+=d.b*t,a+=d.a*t}else{const t=(1-2*c)/b;r+=u.r*t,s+=u.g*t,o+=u.b*t,a+=u.a*t}}return[r,s,o,a]}:function(t,e){const n=x[0]+u,i=Math.atan(.625*Math.sqrt(t*t+e*e)),r=E(t,e),s=1.875-1.75*f,o=.5*u,a=.5!==f?(Math.pow(s,i)-1)/(Math.pow(s,o)-1)*o:i,l=Math.cos(a),h=Math.min(Math.max(2*f,0),1),c=(1-l)*h,d=m,g=d.r*c,p=d.g*c,v=d.b*c,b=d.a*c;let w=(r+n)/u+.5;w%=2,w<0&&(w+=2);const S=Math.abs(w-1),C=Math.sin(a)*h,P=_[0],T=y[0],R=(P.r*(1-S)+T.r*S)*C,F=(P.g*(1-S)+T.g*S)*C,M=(P.b*(1-S)+T.b*S)*C,I=(P.a*(1-S)+T.a*S)*C;return[g*(1-I)+R,p*(1-I)+F,v*(1-I)+M,b*(1-I)+I]};let T,R,F,M,I,k,L,A,D,O,z;for(R=0;R<=h;++R)for(I=0===R?0:R-1,k=R===h?h:R+1,T=0;T<=l;++T){F=0===T?0:T-1,M=T===l?l:T+1,L=4*(R*i+F),c[0]=s[L],c[1]=s[L+1],c[2]=s[L+2],c[3]=s[L+3],A=C(c,d),L=4*(R*i+M),c[0]=s[L],c[1]=s[L+1],c[2]=s[L+2],c[3]=s[L+3],D=C(c,d),O=(D-A)/a*S,L=4*(I*i+T),c[0]=s[L],c[1]=s[L+1],c[2]=s[L+2],c[3]=s[L+3],A=C(c,d),L=4*(k*i+T),c[0]=s[L],c[1]=s[L+1],c[2]=s[L+2],c[3]=s[L+3],D=C(c,d),z=(D-A)/a*S;const t=P(O,z),e=t[3];L=4*(R*i+T),e>0&&(o[L]=t[0]/e*255,o[L+1]=t[1]/e*255,o[L+2]=t[2]/e*255),o[L+3]=255*e}return new ImageData(o,i,r)}function z_(t,e){const n=t[0],i=n.width,r=n.height,s=n.data,o=new Uint8ClampedArray(s.length),a=i-1,l=r-1,h=[0,0,0,0];let c,u,d;const f=(g=e.saturation)>0?1-1/(1.001-g):-g;var g;const p=(m=e.contrast)>0?1/(1-m):1+m;var m;const _=function(t){t*=Math.PI/180;const e=Math.sin(t),n=Math.cos(t);return[(2*n+1)/3,(-Math.sqrt(3)*e-n+1)/3,(Math.sqrt(3)*e-n+1)/3]}(e.hueRotate),y=_,x=[_[2],_[0],_[1]],v=[_[1],_[2],_[0]],b=e.brightnessLow,w=e.brightnessHigh;for(u=0;u<=l;++u)for(c=0;c<=a;++c){d=4*(u*i+c),h[0]=s[d],h[1]=s[d+1],h[2]=s[d+2],h[3]=s[d+3];const t=h[0],e=h[1],n=h[2],r=(t,e)=>{let n=0;for(let i=0;i<t.length;i++)n+=t[i]*e[i];return n};let a=r([t,e,n],y),l=r([t,e,n],x),g=r([t,e,n],v);const m=(a+l+g)/3;a+=(m-a)*f,l+=(m-l)*f,g+=(m-g)*f,a=(a-127.5)*p+127.5,l=(l-127.5)*p+127.5,g=(g-127.5)*p+127.5,a=b*(255-a)+w*a,l=b*(255-l)+w*l,g=b*(255-g)+w*g,o[d]=a,o[d+1]=l,o[d+2]=g,o[d+3]=h[3]}return new ImageData(o,i,r)}var N_={thin:100,hairline:100,"ultra-light":200,"extra-light":200,light:300,book:300,regular:400,normal:400,plain:400,roman:400,standard:400,medium:500,"semi-bold":600,"demi-bold":600,bold:700,"extra-bold":800,"ultra-bold":800,heavy:900,black:900,"heavy-black":900,fat:900,poster:900,"ultra-black":950,"extra-black":950},j_=" ",G_=/(italic|oblique)$/i,$_={};function B_(t,e,n){var i=$_[t];if(!i){Array.isArray(t)||(t=[t]);for(var r,s,o=400,a="normal",l=[],h=0,c=t.length;h<c;++h){var u=t[h].split(" "),d=u[u.length-1].toLowerCase();for(var f in"normal"==d||"italic"==d||"oblique"==d?(a=s?a:d,s=!0,u.pop(),d=u[u.length-1].toLowerCase()):G_.test(d)&&(d=d.replace(G_,""),a=s?a:u[u.length-1].replace(d,""),s=!0),N_){var g=u.length>1?u[u.length-2].toLowerCase():"";if(d==f||d==f.replace("-","")||g+"-"+d==f){o=r?o:N_[f],u.pop(),g&&f.startsWith(g)&&u.pop();break}}r||"number"!=typeof d||(o=d,r=!0);var p=u.join(j_).replace("Klokantech Noto Sans","Noto Sans").replace("DIN Pro","Barlow").replace("Arial Unicode MS","Arial");-1!==p.indexOf(j_)&&(p='"'+p+'"'),l.push(p)}i=$_[t]=[a,o,l]}return i[0]+j_+i[1]+j_+e+"px"+(n?"/"+n:"")+j_+i[2]}const U_="element",V_="map",X_="offset",W_="position",q_="positioning";const Z_=Object.freeze({}),K_={},Y_={};let H_=0;function J_(t){return t.id||(t.id=H_++),t.id}function Q_(t,e){return J_(t)+"."+wi(e)}function ty(t){let e=K_[t.id];return e||(e={},K_[J_(t)]=e),e}function ey(t){let e=Y_[t.id];return e||(e={},Y_[J_(t)]=e),e}function ny(t){return t*Math.PI/180}const iy=function(){const t=[];for(let e=78271.51696402048;t.length<=24;e/=2)t.push(e);return t}();function ry(t,e){if("undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope&&"undefined"!=typeof OffscreenCanvas)return new OffscreenCanvas(t,e);const n=document.createElement("canvas");return n.width=t,n.height=e,n}function sy(t,e){let n=0;const i=e.length;for(;n<i;++n){if(e[n]<t&&n+1<i){const i=e[n]/e[n+1];return n+Math.log(e[n]/t)/Math.log(i)}}return i-1}function oy(t,e){const n=Math.floor(t),i=Math.pow(2,t-n);return e[n]/i}const ay={};function ly(t,e,n={},i){if(e in ay)return i&&(i.url=ay[e][0].url),ay[e][1];const r=n.transformRequest&&n.transformRequest(e,t)||e,s=function(t){return delete ay[e],Promise.reject(new Error("Error fetching source "+e))},o=function(t){return delete ay[e],t.ok?t.json():Promise.reject(new Error("Error fetching source "+e))},a=gi(()=>r).then(t=>t instanceof Response?(i&&(i.url=t.url),o(t)):(t instanceof Request||(t=new Request(t)),t.headers.get("Accept")||t.headers.set("Accept","application/json"),i&&(i.url=t.url),fetch(t).then(o).catch(s))).catch(s);return ay[e]=[r,a],a}function hy(t,e){if("string"!=typeof t)return Promise.resolve(t);if(!t.trim().startsWith("{"))return ly("Style",t=c_(t,e.accessToken),e);try{const e=JSON.parse(t);return Promise.resolve(e)}catch(t){return Promise.reject(t)}}const cy={};function uy(t,e,n={}){const i=[e,JSON.stringify(t)].toString();let r=cy[i];if(!r||n.transformRequest){let s;n.transformRequest&&(s=(t,e)=>{const i=n.transformRequest&&n.transformRequest(e,"Tiles")||e;if(t instanceof t_)t.setLoader((e,n,r)=>{const s=function(n){n.arrayBuffer().then(n=>{const i=t.getFormat().readFeatures(n,{extent:e,featureProjection:r});t.setFeatures(i)})};gi(()=>i).then(e=>{if(e instanceof Response)return s(e);fetch(e).then(s).catch(e=>t.setState(er))}).catch(e=>t.setState(er))});else{const e=t.getImage();gi(()=>i).then(n=>{if("string"==typeof n)return void(e.src=n);const i=t=>t.blob().then(t=>{const n=URL.createObjectURL(t);e.addEventListener("load",()=>URL.revokeObjectURL(n)),e.addEventListener("error",()=>URL.revokeObjectURL(n)),e.src=n});if(n instanceof Response)return i(n);fetch(n).then(i).catch(e=>t.setState(er))}).catch(e=>t.setState(er))}});const o=t.url;if(o&&!t.tiles){const i=d_(o,n.accessToken,n.accessTokenParam||"access_token",e||location.href);if(o.startsWith("mapbox://"))r=Promise.resolve({tileJson:Object.assign({},t,{url:void 0,tiles:i}),tileLoadFunction:s});else{const t={};r=ly("Source",i[0],n,t).then(function(e){return e.tiles=e.tiles.map(function(i){return"tms"===e.scheme&&(i=i.replace("{y}","{-y}")),d_(i,n.accessToken,n.accessTokenParam||"access_token",t.url)[0]}),Promise.resolve({tileJson:e,tileLoadFunction:s})})}}else t.tiles?(t=Object.assign({},t,{tiles:t.tiles.map(function(i){return"tms"===t.scheme&&(i=i.replace("{y}","{-y}")),d_(i,n.accessToken,n.accessTokenParam||"access_token",e||location.href)[0]})}),r=Promise.resolve({tileJson:Object.assign({},t),tileLoadFunction:s})):r=Promise.reject(new Error("source has no `tiles` nor `url`"));cy[i]=r}return r}function dy(t,e,n,i){const r=[2*n*e.pixelRatio+e.width,2*n*e.pixelRatio+e.height],s=ry(r[0],r[1]),o=s.getContext("2d");o.drawImage(t,e.x,e.y,e.width,e.height,n*e.pixelRatio,n*e.pixelRatio,e.width,e.height);const a=o.getImageData(0,0,r[0],r[1]);o.globalCompositeOperation="destination-over",o.fillStyle=`rgba(${255*i.r},${255*i.g},${255*i.b},${i.a})`;const l=a.data;for(let t=0,i=a.width;t<i;++t)for(let r=0,s=a.height;r<s;++r){l[4*(r*i+t)+3]>0&&o.arc(t,r,n*e.pixelRatio,0,2*Math.PI)}return o.fill(),s}function fy(t,e,n){const i=Math.max(0,Math.min(1,(n-t)/(e-t)));return i*i*(3-2*i)}function gy(t,e,n){const i=ry(e.width,e.height),r=i.getContext("2d");r.drawImage(t,e.x,e.y,e.width,e.height,0,0,e.width,e.height);const s=r.getImageData(0,0,e.width,e.height),o=s.data;for(let t=0,e=s.width;t<e;++t)for(let i=0,r=s.height;i<r;++i){const r=4*(i*e+t),s=.75,a=.1,l=fy(s-a,s+a,o[r+3]/255);l>0?(o[r+0]=Math.round(255*n.r*l),o[r+1]=Math.round(255*n.g*l),o[r+2]=Math.round(255*n.b*l),o[r+3]=Math.round(255*l)):o[r+3]=0}return r.putImageData(s,0,0),i}const py=Array(256).join(" ");function my(t,e){if(e>=.05){let n="";const i=t.split("\n"),r=py.slice(0,Math.round(e/.1));for(let t=0,e=i.length;t<e;++t)t>0&&(n+="\n"),n+=i[t].split("").join(r);return n}return t}let _y;function yy(){return _y||(_y=ry(1,1).getContext("2d")),_y}function xy(t,e){if(/\d+ \d+/.test(t)){const[n,i]=t.split(" ").map(Number);return n<=e&&e<=i}return t==e}function vy(t,e){return yy().measureText(t).width+(t.length-1)*e}const by={};function wy(t,e,n,i){if(-1!==t.indexOf("\n")){const r=t.split("\n"),s=[];for(let t=0,o=r.length;t<o;++t)s.push(wy(r[t],e,n,i));return s.join("\n")}const r=n+","+e+","+t+","+i;let s=by[r];if(!s){const o=t.split(" ");if(o.length>1){const t=yy();t.font=e;const r=t.measureText("M").width*n;let a="";const l=[];for(let t=0,e=o.length;t<e;++t){const e=o[t],n=a+(a?" ":"")+e;vy(n,i)<=r?a=n:(a&&l.push(a),a=e)}a&&l.push(a);for(let t=0,e=l.length;t<e&&e>1;++t){const n=l[t];if(vy(n,i)<.35*r){const r=t>0?vy(l[t-1],i):1/0,s=t<e-1?vy(l[t+1],i):1/0;l.splice(t,1),e-=1,r<s?(l[t-1]+=" "+n,t-=1):l[t]=n+" "+l[t]}}for(let t=0,e=l.length-1;t<e;++t){const n=l[t],s=l[t+1];if(vy(n,i)>.7*r&&vy(s,i)<.6*r){const o=n.split(" "),a=o.pop();vy(a,i)<.2*r&&(l[t]=o.join(" "),l[t+1]=a+" "+s),e-=1}}s=l.join("\n")}else s=t;s=my(s,i),by[r]=s}return s}Td.on("propertychange",()=>{for(const t in by)delete by[t]});const Sy=["Arial","Courier New","Times New Roman","Verdana","sans-serif","serif","monospace","cursive","fantasy"],Cy={};const Ey={Point:1,MultiPoint:1,LineString:2,MultiLineString:2,Polygon:3,MultiPolygon:3},Py={center:[.5,.5],left:[0,.5],right:[1,.5],top:[.5,0],bottom:[.5,1],"top-left":[0,0],"top-right":[1,0],"bottom-left":[0,1],"bottom-right":[1,1]},Ty=function(t,e){let n=dn(t,e);if("error"===n.result){const i=r_(t);i!==t&&(n=dn(i,e))}if("error"===n.result){const i=n.value[0];return console.error("Error parsing expression:",t,i.key,i.message),{evaluate:()=>e.default}}return n.value};let Ry,Fy;function My(t,e,n,i,r,s){const o=t.id;r||(r={},console.warn("No functionCache provided to getValue()")),r[o]||(r[o]={});const a=r[o];if(!a[n]){let i=(t[e]||Z_)[n];const r=Dn[`${e}_${t.type}`]&&Dn[`${e}_${t.type}`][n];void 0===i&&r&&(i=r.default);let s=ln(i);if(!s&&on(i)&&(i=Tn(i,r),s=!0),s){const t=Ty(i,r);a[n]=t.evaluate.bind(t)}else{const t=r?r.type:typeof i;"color"!==t&&"colorArray"!==t||(i=lt.parse(i));let e=!1;if("array"===t)for(let t=0;t<i.length;++t){const n=i[t];if(ln(n)||on(n)){e=!0;break}}if(e){const t=Object.assign({},r,{type:r.value}),e=[];for(let n=0;n<i.length;++n){let r=i[n];if(!ln(r)&&on(r)&&(r=Tn(r,t)),ln(r)){const n=Ty(r,t);e.push(n.evaluate.bind(n))}else e.push(function(){return r})}a[n]=function(t,n,i){const r=[];for(let s=0;s<e.length;++s)r[s]=e[s](t,n,i);return r}}else a[n]=function(){return i}}}return a[n](o_,i,s)}function Iy(t,e,n,i){if(!My(t,"layout",`${n}-allow-overlap`,e,i))return"declutter";return My(t,"layout",`${n}-ignore-placement`,e,i)?"none":"obstacle"}function ky(t,e,n,i){if(i||console.warn("No filterCache provided to evaluateFilter()"),!(t in i))try{i[t]=yn(e).filter}catch(e){console.warn("Filter will evaluate to false: "+e.message),i[t]=function(){return!1}}return i[t](o_,n)}let Ly=!1;function Ay(t,e){if(t){if(!Ly&&(0===t.a||0===e))return;const n=t.a;return e=void 0===e?1:e,0===n?"transparent":"rgba("+Math.round(255*t.r/n)+","+Math.round(255*t.g/n)+","+Math.round(255*t.b/n)+","+n*e+")"}return t}const Dy=/\{[^{}}]*\}/g;function Oy(t,e){return t.replace(Dy,function(t){return e[t.slice(1,-1)]||""})}function zy(t,e){let n=t.split(":")[0];return n===t&&(n="default"),e[n]}let Ny=!1;const jy={};function Gy(t,e,n,i=iy,r=void 0,s=void 0,o=void 0,a=void 0){if("string"==typeof e&&(e=JSON.parse(e)),e.schema)for(const t in e.schema){const n=e.schema[t];"default"in n&&(s_[t]=n.default)}if(8!=e.version)throw new Error("glStyle version 8 required.");jy[Q_(e,t)]=Array.from(arguments);const l={};("string"==typeof s||s instanceof Request||s instanceof Response||s instanceof Promise)&&(s={default:s});for(const e in s){const n=s[e];gi(()=>n).then(async n=>{let i;if("undefined"!=typeof Image){const r=new Image;if("string"==typeof n)r.crossOrigin="anonymous",r.src=n;else{let t;n instanceof Request?t=await fetch(n):n instanceof Response&&(t=n);const e=await t.blob();i=URL.createObjectURL(e),r.src=i}r.addEventListener("load",function n(){r.removeEventListener("load",n),l[e]={image:r,size:[r.width,r.height]},t.changed(),i&&URL.revokeObjectURL(i)}),r.addEventListener("error",function t(){URL.revokeObjectURL(i),r.removeEventListener("error",t)})}else if("undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope){const t=self;t.postMessage({action:"loadImage",src:n}),t.addEventListener("message",function(t){"imageLoaded"===t.data.action&&t.data.src===n&&(l[e]={image:t.data.image,size:[t.data.image.width,t.data.image.height]})})}})}const h=d(e.layers),c={},u=[],f={},g={},p=ty(e),m=ey(e);let _;for(let t=0,i=h.length;t<i;++t){const i=h[t],r=i.id;if("string"==typeof n&&i.source==n||Array.isArray(n)&&-1!==n.indexOf(r)){const n=i["source-layer"];if(_){if(i.source!==_)throw new Error(`Layer "${r}" does not use source "${_}`)}else{_=i.source;const t=e.sources[_];if(!t)throw new Error(`Source "${_}" is not defined`);const n=t.type;if("vector"!==n&&"geojson"!==n)throw new Error(`Source "${_}" is not of type "vector" or "geojson", but "${n}"`)}let s=c[n];s||(s=[],c[n]=s),s.push({layer:i,index:t}),u.push(r)}}const y=[],x=function(n,s,h){const u=t.getSource?.()?.format_?.layerName_??"mvt:layer",d=n.getProperties(),_=c[d[u]];if(!_)return;let x=i.indexOf(s);-1==x&&(x=sy(s,i)),o_.zoom=x,o_.distanceFromCenter=0;const v=n.getGeometry(),b=Ey[v.getType()],w=t.get("map");if(w&&w instanceof If&&1===b){const t=w.getSize();if(t){const e=w.getView().getCenter(),n=Jr(v.getExtent());o_.distanceFromCenter=ys(e,n)/s/t[1]}}const S={id:n.getId(),properties:d,type:b},C=t.get("mapbox-featurestate")[n.getId()];let E,P=-1;for(let i=0,c=_.length;i<c;++i){const c=_[i],u=c.layer,v=u.id;if(void 0!==h&&h!==v)continue;const w=u.layout||Z_,T=u.paint||Z_;if("none"===My(u,"layout","visibility",S,p,C)||"minzoom"in u&&x<u.minzoom||"maxzoom"in u&&x>=u.maxzoom)continue;const R=u.filter;if(!R||ky(v,R,S,m)){let i,h,m,_,x,v;E=u;const R=c.index;if(3==b&&("fill"==u.type||"fill-extrusion"==u.type))if(h=My(u,"paint",u.type+"-opacity",S,p,C),u.type+"-pattern"in T){const t=My(u,"paint",u.type+"-pattern",S,p,C);if(t){const e="string"==typeof t?Oy(t,d):t.toString(),n=zy(e,l);if(r&&r[e]&&n){++P,v=y[P],v&&v.getFill()&&!v.getStroke()&&!v.getText()||(v=new Wd({fill:new Bd}),y[P]=v),m=v.getFill(),v.setZIndex(R);const t=e+"."+h;let i=g[t];if(!i){const s=r[e],o=ry(s.width,s.height),a=o.getContext("2d");a.globalAlpha=h,a.drawImage(n.image,s.x,s.y,s.width,s.height,0,0,s.width,s.height),i=a.createPattern(o,"repeat"),g[t]=i}m.setColor(i)}}}else if(i=Ay(My(u,"paint",u.type+"-color",S,p,C),h),u.type+"-outline-color"in T&&(x=Ay(My(u,"paint",u.type+"-outline-color",S,p,C),h)),x||(x=i),i||x){if(++P,v=y[P],(!v||i&&!v.getFill()||!i&&v.getFill()||x&&!v.getStroke()||!x&&v.getStroke()||v.getText())&&(v=new Wd({fill:i?new Bd:void 0,stroke:x?new Xd:void 0}),y[P]=v),i&&(m=v.getFill(),m.setColor(i)),"fill-extrusion"===u.type){const t=My(u,"paint","fill-extrusion-height",S,p,C);if(t>0){const e=Math.max(.1,.9-Math.min(t,225)/280);if(x&&"transparent"!==x){const t=lt.parse(x);x=`rgba(${Math.round(255*t.r*e)},${Math.round(255*t.g*e)},${Math.round(255*t.b*e)},${t.a})`}}}x&&(_=v.getStroke(),_.setColor(x),_.setWidth(.5)),v.setZIndex(R)}if(1!=b&&"line"==u.type){i="line-pattern"in T?void 0:Ay(My(u,"paint","line-color",S,p,C),My(u,"paint","line-opacity",S,p,C));const t=My(u,"paint","line-width",S,p,C);i&&t>0&&(++P,v=y[P],v&&v.getStroke()&&!v.getFill()&&!v.getText()||(v=new Wd({stroke:new Xd}),y[P]=v),_=v.getStroke(),_.setLineCap(My(u,"layout","line-cap",S,p,C)),_.setLineJoin(My(u,"layout","line-join",S,p,C)),_.setMiterLimit(My(u,"layout","line-miter-limit",S,p,C)),_.setColor(i),_.setWidth(t),_.setLineDash(T["line-dasharray"]?My(u,"paint","line-dasharray",S,p,C).map(function(e){return e*t}):null),"function"==typeof _.setOffset&&_.setOffset(My(u,"paint","line-offset",S,p,C)),v.setZIndex(R))}let F,M,I,k,L,A,D,O,z,N=!1,j=null,G=0;if((1==b||2==b)&&"icon-image"in w){const e=My(u,"layout","icon-image",S,p,C);if(e){let i;F="string"==typeof e?Oy(e,d):e.toString();const o=a?a(t,F):void 0,h=zy(F,l);if(r&&r[F]&&h||o){const t=My(u,"layout","icon-rotation-alignment",S,p,C);if(2==b){const e=n.getGeometry();if(e.getFlatMidpoint||e.getFlatMidpoints){const n=e.getExtent();if(Math.sqrt(Math.max(Math.pow((n[2]-n[0])/s,2),Math.pow((n[3]-n[1])/s,2)))>150){const n="MultiLineString"===e.getType()?e.getFlatMidpoints():e.getFlatMidpoint();Fy||(Ry=[NaN,NaN],Fy=new Bf("Point",Ry,[],2,{},void 0)),i=Fy,Ry[0]=n[0],Ry[1]=n[1];if("line"===My(u,"layout","symbol-placement",S,p,C)&&"map"===t){const t=e.getStride(),i=e.getFlatCoordinates();for(let e=0,r=i.length-t;e<r;e+=t){const r=i[e],s=i[e+1],o=i[e+t],a=i[e+t+1],l=Math.min(r,o),h=Math.max(r,o),c=n[0],u=(a-s)*(c-r)-(o-r)*(n[1]-s);if(Math.abs(u)<.001&&c<=h&&c>=l){G=Math.atan2(s-a,o-r);break}}}}}}if(2!==b||i){const e=My(u,"layout","icon-size",S,p,C),n=void 0!==T["icon-color"]?My(u,"paint","icon-color",S,p,C):null;if(!n||0!==n.a){const i=My(u,"paint","icon-halo-color",S,p,C),s=My(u,"paint","icon-halo-width",S,p,C);let a=`${F}.${e}.${s}.${i}`;if(null!==n&&(a+=`.${n}`),M=f[a],!M){const l=Iy(u,S,"icon",p);let c;"icon-offset"in w&&(c=My(u,"layout","icon-offset",S,p,C).slice(0),c[0]*=e,c[1]*=-e);let d=n?[255*n.r,255*n.g,255*n.b,n.a]:void 0;if(o){const n={color:d,rotateWithView:"map"===t,displacement:c,declutterMode:l,scale:e};"string"==typeof o?n.src=o:(n.img=o,n.imgSize=[o.width,o.height]),M=new Vd(n)}else{const o=r[F];let a,u,f;if(s)o.sdf?(a=dy(gy(h.image,o,n||[0,0,0,1]),{x:0,y:0,width:o.width,height:o.height,pixelRatio:o.pixelRatio},s,i),d=void 0):a=dy(h.image,o,s,i);else{if(o.sdf&&!h.unSDFed){const t=gy(h.image,{x:0,y:0,width:h.size[0],height:h.size[1]},{r:1,g:1,b:1});h.image=t,h.unSDFed=!0}a=h.image,u=[o.width,o.height],f=[o.x,o.y]}M=new Vd({color:d,img:a,imgSize:h.size,size:u,offset:f,rotateWithView:"map"===t,scale:e/o.pixelRatio,displacement:c,declutterMode:l})}f[a]=M}}M&&(++P,v=y[P],v&&v.getImage()&&!v.getFill()&&!v.getStroke()||(v=new Wd,y[P]=v),v.setGeometry(i),M.setRotation(G+ny(My(u,"layout","icon-rotate",S,p,C))),M.setOpacity(My(u,"paint","icon-opacity",S,p,C)),M.setAnchor(Py[My(u,"layout","icon-anchor",S,p,C)]),v.setImage(M),j=v.getText(),v.setText(void 0),v.setZIndex(R),N=!0,I=!1)}else I=!0}}}if(1==b&&"circle"===u.type){++P,v=y[P],v&&v.getImage()&&!v.getFill()&&!v.getStroke()||(v=new Wd,y[P]=v);const t="circle-radius"in T?My(u,"paint","circle-radius",S,p,C):5,e=Ay(My(u,"paint","circle-stroke-color",S,p,C),My(u,"paint","circle-stroke-opacity",S,p,C)),n=My(u,"paint","circle-translate",S,p,C),i=Ay(My(u,"paint","circle-color",S,p,C),My(u,"paint","circle-opacity",S,p,C)),r=My(u,"paint","circle-stroke-width",S,p,C),s=t+"."+e+"."+i+"."+r+"."+n[0]+"."+n[1];M=f[s],M||(M=new $d({radius:t,displacement:[n[0],-n[1]],stroke:e&&r>0?new Xd({width:r,color:e}):void 0,fill:i?new Bd({color:i}):void 0,declutterMode:"none"}),f[s]=M),v.setImage(M),j=v.getText(),v.setText(void 0),v.setGeometry(void 0),v.setZIndex(R),N=!0}if("text-field"in w){D=Math.round(My(u,"layout","text-size",S,p,C));const t=My(u,"layout","text-font",S,p,C);A=My(u,"layout","text-line-height",S,p,C),L=B_(o?o(t,e.metadata?e.metadata["ol:webfonts"]:void 0):t,D,A),L.includes("sans-serif")||(L+=",sans-serif"),O=My(u,"layout","text-letter-spacing",S,p,C),z=My(u,"layout","text-max-width",S,p,C);const n=My(u,"layout","text-field",S,p,C);k="object"==typeof n&&n.sections?1===n.sections.length?n.toString():n.sections.reduce((e,n,i)=>{const r=n.fontStack?n.fontStack.split(","):t,s=B_(o?o(r):r,D*(n.scale||1),A);let a=n.text;if("\n"===a)return e.push("\n",""),e;if(2==b)return e.push(my(a,O),s),e;a=wy(a,s,z,O).split("\n");for(let t=0,n=a.length;t<n;++t)t>0&&e.push("\n",""),e.push(a[t],s);return e},[]):Oy(n,d).trim(),h=My(u,"paint","text-opacity",S,p,C)}if(k&&h&&!I){N||(++P,v=y[P],v&&v.getText()&&!v.getFill()&&!v.getStroke()||(v=new Wd,y[P]=v),v.setImage(void 0),v.setGeometry(void 0));const t=Iy(u,S,"text",p);v.getText()||v.setText(j),j=v.getText(),(!j||"getDeclutterMode"in j&&j.getDeclutterMode()!==t)&&(j=new Hd({padding:[2,2,2,2],declutterMode:t}),v.setText(j));const e=My(u,"layout","text-transform",S,p,C);"uppercase"==e?k=Array.isArray(k)?k.map((t,e)=>e%2?t:t.toUpperCase()):k.toUpperCase():"lowercase"==e&&(k=Array.isArray(k)?k.map((t,e)=>e%2?t:t.toLowerCase()):k.toLowerCase());const n=Array.isArray(k)?k:2==b?my(k,O):wy(k,L,z,O);if(j.setText(n),j.setFont(L),j.setRotation(ny(My(u,"layout","text-rotate",S,p,C))),"function"==typeof j.setKeepUpright){const t=My(u,"layout","text-keep-upright",S,p,C);j.setKeepUpright(t)}const i=My(u,"layout","text-anchor",S,p,C),r=N||1==b?"point":My(u,"layout","symbol-placement",S,p,C);let s;if("line-center"===r?(j.setPlacement("line"),s="center"):j.setPlacement(r),"line"===r&&"function"==typeof j.setRepeat){const t=My(u,"layout","symbol-spacing",S,p,C);j.setRepeat(2*t)}j.setOverflow("point"===r);let o=My(u,"paint","text-halo-width",S,p,C);const a=My(u,"layout","text-offset",S,p,C),l=My(u,"paint","text-translate",S,p,C);let c=0,d=0;if("point"==r){s="center",-1!==i.indexOf("left")?(s="left",d=o):-1!==i.indexOf("right")&&(s="right",d=-o);const t=My(u,"layout","text-rotation-alignment",S,p,C);j.setRotateWithView("map"==t)}else j.setMaxAngle(ny(My(u,"layout","text-max-angle",S,p,C))*k.length/n.length),j.setRotateWithView(!1);j.setTextAlign(s);let f="middle";0==i.indexOf("bottom")?(f="bottom",c=-o-.5*(A-1)*D):0==i.indexOf("top")&&(f="top",c=o+.5*(A-1)*D),j.setTextBaseline(f);const g=My(u,"layout","text-justify",S,p,C);j.setJustify("auto"===g?void 0:g),j.setOffsetX(a[0]*D+d+l[0]),j.setOffsetY(a[1]*D+c+l[1]);const m=j.getFill()||new Bd;m.setColor(Ay(My(u,"paint","text-color",S,p,C),h)),j.setFill(m);const _=Ay(My(u,"paint","text-halo-color",S,p,C),h);if(_&&o>0){const t=j.getStroke()||new Xd;t.setColor(_),o*=2;const e=.5*D;t.setWidth(o<=e?o:e),j.setStroke(t)}else j.setStroke(void 0);const x=My(u,"layout","text-padding",S,p,C),w=j.getPadding();x!==w[0]&&(w[0]=x,w[1]=x,w[2]=x,w[3]=x),v.setZIndex(R)}}}return P>-1?(y.length=P+1,Ny&&("set"in n?n.set("mapbox-layer",E):n.getProperties()["mapbox-layer"]=E),y):void 0};return t.setStyle(x),t.set("mapbox-layers",u),t.set("mapbox-source",_),t.set("mapbox-featurestate",t.get("mapbox-featurestate")||{}),x}const $y=lt.parse("#000000"),By=lt.parse("#FFFFFF"),Uy=lt.parse("#000000");const Vy=["raster-saturation","raster-contrast","raster-brightness-max","raster-brightness-min","raster-hue-rotate"];function Xy(t,e,n){let i=null;return function(r){t.paint&&"raster-opacity"in t.paint&&r.frameState.viewState.zoom!==i&&(i=r.frameState.viewState.zoom,delete n[t.id],function(t,e,n,i){o_.zoom=n,o_.distanceFromCenter=0;const r=My(t,"paint","raster-opacity",Z_,i);e.setOpacity(r)}(t,e,i,n))}}const Wy=["background","circle","fill","fill-extrusion","line","symbol","raster","hillshade"];function qy(t,e=512){return t.getExtent()?ym({extent:t.getExtent(),tileSize:e,maxZoom:22}).getResolutions():iy}function Zy(t,e){if(!e.accessToken){e=Object.assign({},e);new URL(t).searchParams.forEach((t,n)=>{e.accessToken=t,e.accessTokenParam=n})}return e}function Ky(t,e,n="",i={},r=void 0){let s,o,a,l,h=!0;return"string"==typeof n||Array.isArray(n)?l=n:(a=n,l=a.source||a.layers,i=a),"string"==typeof i?(s=i,a={}):(s=i.styleUrl,a=i),!1===a.updateSource&&(h=!1),r||(r=a.resolutions),s||"string"!=typeof e||e.trim().startsWith("{")||(s=e),s&&(s=s.startsWith("data:")?location.href:c_(s,a.accessToken),a=Zy(s,a)),new Promise(function(n,i){hy(e,a).then(function(e){if(8!=e.version)return i(new Error("glStyle version 8 required."));if(!(t instanceof rm||t instanceof lm))return i(new Error("Can only apply to VectorLayer or VectorTileLayer"));const c=t instanceof lm?"vector":"geojson";if(l?o=Array.isArray(l)?e.layers.find(function(t){return t.id===l[0]}).source:l:(o=e.layers.find(function(t){return t.source&&e.sources[t.source].type===c}).source,l=o),!o)return i(new Error(`No ${c} source found in the glStyle.`));function u(){if(!h)return Promise.resolve();if(t instanceof lm)return nx(e.sources[o],s,a).then(function(e){const n=t.getSource();n?e!==n&&(n.setTileUrlFunction(e.getTileUrlFunction()),"function"==typeof n.setUrls&&"function"==typeof e.getUrls&&n.setUrls(e.getUrls()),n.format_||(n.format_=e.format_),n.getAttributions()||n.setAttributions(e.getAttributions()),n.getTileLoadFunction()===n_&&n.setTileLoadFunction(e.getTileLoadFunction()),zo(n.getProjection(),e.getProjection())&&(n.tileGrid=e.getTileGrid())):t.setSource(e);const i=t.getSource().getTileGrid();!isFinite(t.getMaxResolution())&&!isFinite(t.getMinZoom())&&i.getMinZoom()>0&&t.setMaxResolution(oy(Math.max(0,i.getMinZoom()-1e-12),i.getResolutions()))});const n=e.sources[o];let i=t.getSource();i&&i.get("mapbox-source")===n||(i=ox(n,s,a));const r=t.getSource();return r?i!==r&&(r.getAttributions()||r.setAttributions(i.getAttributions()),r.format_||(r.format_=i.getFormat()),r.url_=i.getUrl()):t.setSource(i),Promise.resolve()}let d,f;const g={},p={};function m(){if(f||e.sprite&&!g)f?(t.setStyle(f),u().then(n).catch(i)):i(new Error("Something went wrong trying to apply style."));else{if(a.projection&&!r){const t=Mo(a.projection).getUnits();"m"!==t&&(r=iy.map(e=>e/ks[t]))}let s;const h=t.getSource();h instanceof e_&&h.format_ instanceof mg&&(s=h.format_.layerName_),f=Gy(t,e,l,r,g,p,(t,e=a.webfonts)=>function(t,e="https://cdn.jsdelivr.net/npm/@fontsource/{font-family}/{fontweight}{-fontstyle}.css"){if(Oi)return t;let n;for(let e=0,i=t.length;e<i;++e){const i=t[e];if(i in Cy)continue;Cy[i]=!0;const r=B_(i,16).split(" ");n||(n=[]),n.push([r.slice(3).join(" ").replace(/"/g,""),r[1],r[0]])}return n?((async()=>{await document.fonts.ready;for(let t=0,i=n.length;t<i;++t){const i=n[t],r=i[0];if(Sy.includes(r))continue;const s=i[1],o=i[2];if(!(await document.fonts.load(`${o} ${s} 16px "${r}"`)).some(t=>t.family.replace(/^['"]|['"]$/g,"").toLowerCase()===r.toLowerCase()&&xy(t.weight,s)&&t.style===o)){const t=e.replace("{font-family}",r.replace(/ /g,"-").toLowerCase()).replace("{Font+Family}",r.replace(/ /g,"+")).replace("{fontweight}",s).replace("{-fontstyle}",o.replace("normal","").replace(/(.+)/,"-$1")).replace("{fontstyle}",o);if(!document.querySelector('link[href="'+t+'"]')){const e=document.createElement("link");e.href=t,e.rel="stylesheet",document.head.appendChild(e)}}}})(),t):t}(t,e),a.getImage,s),t.getStyle()?u().then(n).catch(i):i(new Error(`Nothing to show for source [${o}]`))}}if(e.sprite){const t=function(t,e,n){if("string"==typeof t)return[{id:"default",url:h_(t,e,n)}];for(const i of t)i.url=h_(i.url,e,n);return t}(e.sprite,a.accessToken,s||location.href);d=Oi?1:window.devicePixelRatio>=1.5?.5:1;const n=.5==d?"@2x":"";Promise.all(t.map(function(t){const e=new URL(t.url);let r=e.origin+e.pathname+n+".json"+e.search;return new Promise(function(t,n){ly("Sprite",r,a).then(t).catch(function(i){r=e.origin+e.pathname+".json"+e.search,ly("Sprite",r,a).then(t).catch(n)})}).then(function(r){let s;if(void 0===r&&i(new Error("No sprites found.")),s=e.origin+e.pathname+n+".png"+e.search,a.transformRequest){const t=a.transformRequest(s,"SpriteImage")||s;(t instanceof Request||t instanceof Promise)&&(s=t)}p[t.id]=s;for(const e in r){const n="default"==t.id?e:`${t.id}:${e}`;g[n]=r[e]}}).catch(function(t){i(new Error(`Sprites cannot be loaded: ${r}: ${t.message}`))})})).then(m).catch(i)}else m()}).catch(i)})}function Yy(t,e,n={}){return hy(e,n).then(function(e){!function(t,e,n){e.layers.some(function(e){if("background"===e.type){if(t instanceof Wh)return t.setBackground(function(t){return tx(e,t,n,{})}),!0;if(t instanceof If||t instanceof jh)return t.getLayers().insertAt(0,ex(e,n,{})),!0}})}(t,e,n)})}const Hy=["type","source","source-layer","minzoom","maxzoom","filter","layout"];function Jy(t,e){if(!e.ref)return e;const n=t.find(t=>t.id===e.ref);if(!n)return e;const i=Object.assign({},e);for(const t of Hy)!(t in i)&&t in n&&(i[t]=n[t]);return i}function Qy(t,e,n){const i=new jm({tileJSON:e,tileSize:t.tileSize||e.tileSize||512}),r=i.getTileJSON(),s=i.getTileGrid(),o=Mo(n.projection||"EPSG:3857"),a=function(t,e){const n=t.bounds;if(n){const t=Oo([n[0],n[1]],e),i=Oo([n[2],n[3]],e);return[t[0],t[1],i[0],i[1]]}return Mo(e).getExtent()}(r,o),l=o.getExtent(),h=r.minzoom||0,c=r.maxzoom||22,u={attributions:i.getAttributions(),projection:o,tileGrid:new gm({origin:l?rs(l):s.getOrigin(0),extent:a||s.getExtent(),minZoom:h,resolutions:qy(o,e.tileSize).slice(0,c+1),tileSize:s.getTileSize(0)})};return Array.isArray(r.tiles)?u.urls=r.tiles:u.url=r.tiles,u}function tx(t,e,n,i){const r={id:t.id,type:t.type},s=t.paint||{};let o;r.paint=s,o_.zoom=sy(e,n.resolutions||iy),o_.distanceFromCenter=0;const a=My(r,"paint","background-color",Z_,i);return void 0!==s["background-opacity"]&&(o=My(r,"paint","background-opacity",Z_,i)),"none"===My(r,"layout","visibility",Z_,i)?void 0:Ay(a,o)}function ex(t,e,n){const i=Oi?{style:{}}:document.createElement("div");return i.className="ol-mapbox-style-background",i.style.position="absolute",i.style.width="100%",i.style.height="100%",new Wh({source:new um({}),render(r){const s=tx(t,r.viewState.resolution,e,n);return i.style.backgroundColor=s,i}})}function nx(t,e,n){return new Promise(function(i,r){uy(t,e,n).then(function({tileJson:e,tileLoadFunction:r}){const s=Qy(t,e,n);s.tileLoadFunction=r,s.format=new mg({layerName:"mvt:layer"});const o=new e_(s);o.set("mapbox-source",t),i(o)}).catch(r)})}function ix(t){return`{bbox-${(t?t.getCode():"EPSG:3857").toLowerCase().replace(/[^a-z0-9]/g,"-")}}`}function rx(t,e,n){return new Promise(function(i,r){uy(t,e,n).then(function({tileJson:e,tileLoadFunction:r}){const s=new jm({interpolate:void 0===n.interpolate||n.interpolate,transition:0,crossOrigin:"anonymous",tileJSON:e});s.tileGrid=Qy(t,e,n).tileGrid,n.projection&&(s.projection=Mo(n.projection));const o=s.getTileUrlFunction();r&&s.setTileLoadFunction(r),s.setTileUrlFunction(function(t,e,n){const i=ix(n);let r=o(t,e,n);if(-1!=r.indexOf(i)){const e=s.getTileGrid().getTileCoordExtent(t);r=r.replace(i,e.toString())}return r}),s.set("mapbox-source",t),i(s)}).catch(function(t){r(t)})})}function sx(t,e,n){const i=new Qg;return rx(t,e,n).then(function(t){i.setSource(t)}).catch(function(){i.setSource(void 0)}),i}function ox(t,e,n){const i=n.projection?new Jf({dataProjection:n.projection}):new Jf,r=t.data,s={};if("string"==typeof r){const[s]=d_(r,n.accessToken,n.accessTokenParam||"access_token",e||location.href);if(/\{bbox-[0-9a-z-]+\}/.test(s)){const e=(t,e,n)=>{const i=ix(n);return s.replace(i,`${t.join(",")}`)},r=new Hm({attributions:t.attribution,format:i,loader:(t,i,s,o,a)=>{ly("GeoJSON","function"==typeof e?e(t,i,s):e,n).then(t=>{const e=r.getFormat().readFeatures(t,{featureProjection:s});r.addFeatures(e),o(e)}).catch(e=>{r.removeLoadedExtent(t),a()})},strategy:cm});return r.set("mapbox-source",t),r}const o=new Hm({attributions:t.attribution,format:i,url:s,loader:(t,e,i,r,a)=>{ly("GeoJSON",s,n).then(t=>{const e=o.getFormat().readFeatures(t,{featureProjection:i});o.addFeatures(e),r(e)}).catch(e=>{o.removeLoadedExtent(t),a()})}});return o}s.features=i.readFeatures(r,{featureProjection:Xo()||"EPSG:3857"});const o=new Hm(Object.assign({attributions:t.attribution,format:i},s));return o.set("mapbox-source",t),o}function ax(t,e,n,i){n=Jy(t.layers,n);const r=ty(t),s=n.type;let o=n.source;const a=t.sources[o];let l;if("background"==s)l=ex(n,i,r),o=void 0;else if("vector"==a.type)l=function(t,e,n){const i=new lm({declutter:!0,visible:!1});return nx(t,e,n).then(function(t){i.setSource(t)}).catch(function(t){i.setSource(void 0)}),i}(a,e,i);else if("raster"==a.type){if(!!Object.keys(n.paint||{}).find(t=>Vy.includes(t))){l=function(t){return new p_({source:new k_({operationType:"image",operation:z_,sources:[t]})})}(sx(a,e,i)),function(t,e,n,i){t.getSource().on("beforeoperations",function(t){o_.zoom=sy(t.resolution,n.resolutions||iy),o_.distanceFromCenter=0;const r=t.data;r.saturation=My(e,"paint","raster-saturation",Z_,i),r.contrast=My(e,"paint","raster-contrast",Z_,i),r.brightnessHigh=My(e,"paint","raster-brightness-max",Z_,i),r.brightnessLow=My(e,"paint","raster-brightness-min",Z_,i),r.hueRotate=My(e,"paint","raster-hue-rotate",Z_,i)})}(l,n,i,r)}else l=sx(a,e,i);l.setVisible(!n.layout||"none"!==My(n,"layout","visibility",Z_,r)),l.on("prerender",Xy(n,l,r))}else if("geojson"==a.type)l=function(t,e,n){return new rm({declutter:!0,source:ox(t,e,n),visible:!1})}(a,e,i);else if("raster-dem"==a.type&&"hillshade"==n.type){l=function(t){return new p_({source:new k_({operationType:"image",operation:O_,sources:[t]})})}(sx(a,e,i)),function(t,e,n,i,r){t.getSource().on("beforeoperations",function(t){const s=t.data;s.resolution=Io(i.projection||"EPSG:3857",t.resolution,Jr(t.extent),"m");const o=sy(t.resolution,i.resolutions||iy);o_.zoom=o,o_.distanceFromCenter=0,s.zoom=o,s.encoding=e.encoding,s.method=My(n,"paint","hillshade-method",Z_,r)||"standard",s.exaggeration=My(n,"paint","hillshade-exaggeration",Z_,r);let a=My(n,"paint","hillshade-illumination-direction",Z_,r);null==a&&(a=335),s.azimuths=Array.isArray(a)?a:[a],s.sunAz=s.azimuths[0];let l=My(n,"paint","hillshade-illumination-altitude",Z_,r);function h(t){return t&&t.values?t.values[0]:t}function c(t){const e=n.paint?.[t];if(Array.isArray(e)&&e.length>0&&"string"==typeof e[0]&&void 0!==lt.parse(e[0]))return e.map(t=>lt.parse(t));let i=My(n,"paint",t,Z_,r);return i=h(i),i?[i]:void 0}null==l&&(l=45),s.altitudes=Array.isArray(l)?l:[l],s.highlightColors=c("hillshade-highlight-color"),s.highlightColor=s.highlightColors?.[0]||By,s.highlightColors||(s.highlightColors=[s.highlightColor]),s.shadowColors=c("hillshade-shadow-color"),s.shadowColor=s.shadowColors?.[0]||$y,s.shadowColors||(s.shadowColors=[s.shadowColor]),s.accentColor=h(My(n,"paint","hillshade-accent-color",Z_,r))||Uy})}(l,a,n,i,r),l.setVisible(!n.layout||"none"!==My(n,"layout","visibility",Z_,r))}return l&&l.set("mapbox-source",o),l}function lx(t,e,n,i){t.schema&&Object.assign(s_,Object.keys(t.schema).reduce((e,n)=>(e[n]=t.schema[n]?.default,e),{}));const r=[];let s=null;if(e instanceof If){if(s=e.getView(),!s.isDef()&&!s.getRotation()&&!s.getResolutions()){const t=i.projection?Mo(i.projection):s.getProjection();s=new dl(Object.assign(s.getProperties(),{maxResolution:iy[0]/ks[t.getUnits()],projection:i.projection||s.getProjection()})),e.setView(s)}"center"in t&&!s.getCenter()&&s.setCenter(Oo(t.center,s.getProjection())),"zoom"in t&&void 0===s.getZoom()&&s.setResolution(iy[0]/ks[s.getProjection().getUnits()]/Math.pow(2,t.zoom)),s.getCenter()&&void 0!==s.getZoom()||s.fit(s.getProjection().getExtent(),{nearest:!0,size:e.getSize()})}e.set("mapbox-style",t),e.set("mapbox-metadata",{styleUrl:n,options:i});const o=t.layers;let a,l,h,c=[];for(let s=0,u=o.length;s<u;++s){const u=Jy(o,o[s]),d=u.type;Wy.includes(d)?(h=u.source,h&&h==l||(c.length&&(r.push(cx(a,c,t,n,e,i)),c=[]),a=ax(t,n,u,i),a instanceof rm||a instanceof lm||(c=[]),l=a.get("mapbox-source")),c.push(u.id)):console.warn(`layers[${s}].type "${d}" not supported`)}return r.push(cx(a,c,t,n,e,i)),Promise.all(r)}function hx(t,e,n={}){let i,r;if(Oi){if(!(t instanceof If||t instanceof jh))throw new Error("ol-mapbox-style in a web worker requires a Map or a LayerGroup as first argument");r=t}else r="string"==typeof t||t instanceof HTMLElement?new If({target:t}):t;if("string"==typeof e){const t=e.startsWith("data:")?location.href:c_(e,n.accessToken);n=Zy(t,n),i=new Promise(function(i,s){hy(e,n).then(function(e){lx(e,r,t,n).then(function(){i(r)}).catch(s)}).catch(function(t){s(new Error(`Could not load ${e}: ${t.message}`))})})}else i=new Promise(function(t,i){lx(e,r,!n.styleUrl||n.styleUrl.startsWith("data:")?location.href:c_(n.styleUrl,n.accessToken),n).then(function(){t(r)}).catch(i)});return i}function cx(t,e,n,i,r,s={}){let o=24,a=0;const l=n.layers;for(let t=0,n=l.length;t<n;++t){const n=l[t];-1!==e.indexOf(n.id)&&(o=Math.min("minzoom"in n?n.minzoom:0,o),a=Math.max("maxzoom"in n?n.maxzoom:24,a))}return new Promise(function(l,h){const c=function(){const c=t.getSource();if(c&&"error"!==c.getState()){if("getTileGrid"in c){const e=c.getTileGrid();if(e){const n=e.getMinZoom();(o>0||n>0)&&t.setMaxResolution(Math.min(oy(Math.max(0,o-1e-12),iy),oy(Math.max(0,n-1e-12),e.getResolutions()))),a<24&&t.setMinResolution(oy(a,iy))}}else o>0&&t.setMaxResolution(oy(Math.max(0,o-1e-12),iy));c instanceof Hm||c instanceof e_?Ky(t,n,e,Object.assign({styleUrl:i},s)).then(function(){!function(t,e,n){function i(){const i=e.get("mapbox-style");if(!i)return;const r=d(i.layers),s=t.get("mapbox-layers"),o=r.filter(function(t){return s.includes(t.id)}).some(function(t){return!t.layout||"visible"===My(t,"layout","visibility",Z_,n)});t.get("visible")!==o&&t.setVisible(o)}t.on("change",i),i()}(t,r,ty(n)),l()}).catch(h):l()}else h(new Error("Error accessing data for source "+t.get("mapbox-source")))};t.set("mapbox-layers",e);const u=r.getLayers();-1===u.getArray().indexOf(t)&&u.push(t),t.getSource()?c():t.once("change:source",c)})}function ux(t,e){const n=t.get("mapbox-style").layers.find(function(t){return t.id===e});return n}function dx(t,e){const n=t.getLayers().getArray();for(let t=0,i=n.length;t<i;++t){const i=n[t].get("mapbox-layers");if(i&&-1!==i.indexOf(e))return n[t]}}function fx(t,e){const n=[],i=t.getLayers().getArray();for(let t=0,r=i.length;t<r;++t)i[t].get("mapbox-source")===e&&n.push(i[t]);return n}function gx(t,e){const n=t.getLayers().getArray();for(let t=0,i=n.length;t<i;++t){const i=n[t].getSource();if(n[t].get("mapbox-source")===e)return i}}class px extends pi{constructor(t){super(Xn),this.error=t}}var mx=Object.freeze({__proto__:null,MapboxVectorLayer:class extends lm{constructor(t){const e=!("declutter"in t)||t.declutter,n=new e_({state:"loading",format:new mg({layerName:"mvt:layer"})});super({source:n,background:!1===t.background?null:t.background,declutter:e,extent:t.extent,className:t.className,opacity:t.opacity,visible:t.visible,zIndex:t.zIndex,minResolution:t.minResolution,maxResolution:t.maxResolution,minZoom:t.minZoom,maxZoom:t.maxZoom,renderOrder:t.renderOrder,renderBuffer:t.renderBuffer,renderMode:t.renderMode,map:t.map,updateWhileAnimating:t.updateWhileAnimating,updateWhileInteracting:t.updateWhileInteracting,preload:t.preload,useInterimTilesOnError:t.useInterimTilesOnError,properties:t.properties}),t.accessToken&&(this.accessToken=t.accessToken);const i=[Ky(this,t.styleUrl,t.layers||t.source,{accessToken:this.accessToken})];void 0===this.getBackground()&&i.push(Yy(this,t.styleUrl,{accessToken:this.accessToken})),Promise.all(i).then(()=>{n.setState("ready")}).catch(t=>{this.dispatchEvent(new px(t));this.getSource().setState("error")})}},addMapboxLayer:function(t,e,n){const i=t.get("mapbox-style"),r=i.layers;let s,o,a=-1;if(void 0!==n){const e=ux(t,n);if(void 0===e)throw new Error(`Layer with id "${n}" not found.`);s=r.indexOf(e)}else s=r.length;if(s>0&&r[s-1].source===e.source?(a=s-1,o=-1):s<r.length&&r[s].source===e.source&&(a=s,o=0),-1===a){const{options:o,styleUrl:a}=t.get("mapbox-metadata"),l=ax(i,a,e,o);if(n){const e=dx(t,n),i=t.getLayers().getArray().indexOf(e);t.getLayers().insertAt(i,l)}return r.splice(s,0,e),cx(l,[e.id],i,a,t,o)}if(r.some(t=>t.id===e.id))throw new Error(`Layer with id "${e.id}" already exists.`);const l=r[a].id,h=jy[Q_(t.get("mapbox-style"),dx(t,l))];if(r.splice(s,0,e),h){const[t,n,i,r,s,a,c,u]=h;if(Array.isArray(i)){const t=i.indexOf(l)+o;i.splice(t,0,e.id)}Gy(t,n,i,r,s,a,c,u)}else dx(t,r[a].id).changed();return Promise.resolve()},apply:hx,applyBackground:Yy,applyStyle:Ky,default:hx,getFeatureState:function(t,e){const n="getLayers"in t?fx(t,e.source):[t];for(let t=0,i=n.length;t<i;++t){const i=n[t].get("mapbox-featurestate");if(i&&i[e.id])return i[e.id]}},getLayer:dx,getLayers:fx,getMapboxLayer:ux,getSource:gx,getStyleForLayer:function(t,e,n,i){const r=n.getStyleFunction();if(3===r.length)return r(t,e,i)},recordStyleLayer:function(t=!1){Ny=t},removeMapboxLayer:function(t,e){const n="string"==typeof e?e:e.id,i=dx(t,n),r=i.get("mapbox-layers");if(1===r.length)throw new Error("Cannot remove last Mapbox layer from an OpenLayers layer.");r.splice(r.indexOf(n),1);const s=t.get("mapbox-style"),o=s.layers;o.splice(o.findIndex(t=>t.id===n),1);const a=jy[Q_(s,i)];if(a){const[t,e,i,r,s,o,l,h]=a;Array.isArray(i)&&i.splice(i.findIndex(t=>t===n),1),Gy(t,e,i,r,s,o,l,h)}else dx(t,n).changed()},renderTransparent:function(t){t!==Ly&&(!function(){for(const t in K_)delete K_[t]}(),Ly=t)},setFeatureState:function(t,e,n){const i="getLayers"in t?fx(t,e.source):[t];for(let t=0,r=i.length;t<r;++t){const r=i[t].get("mapbox-featurestate");if(!r)throw new Error(`Map or layer for source "${e.source}" not found.`);n?r[e.id]=n:delete r[e.id],i[t].changed()}},styleConfig:s_,stylefunction:Gy,updateMapboxLayer:function(t,e){const n=t.get("mapbox-style"),i=n.layers,r=i.findIndex(function(t){return t.id===e.id});if(-1===r)throw new Error(`Layer with id "${e.id}" not found.`);if(i[r].source!==e.source)throw new Error("Updated layer and previous version must use the same source.");delete ty(n)[e.id],delete ey(n)[e.id],i[r]=e;const s=jy[Q_(t.get("mapbox-style"),dx(t,e.id))];if(s)return Gy.apply(void 0,s),Promise.resolve();const o=dx(t,e.id),{options:a,styleUrl:l}=t.get("mapbox-metadata");return cx(o,[e.id],n,l,t,a)},updateMapboxSource:function(t,e,n){const i=gx(t,e),r=t.getLayers().getArray().filter(function(t){return(t instanceof rm||t instanceof Qg||t instanceof lm)&&t.getSource()===i}),s=t.get("mapbox-metadata");let o;switch(n.type){case"vector":o=nx(n,s.styleUrl,s.options);break;case"geojson":o=Promise.resolve(ox(n,s.styleUrl,s.options));break;case"raster":case"raster-dem":o=rx(n,s.styleUrl,s.options);break;default:return Promise.reject(new Error("Unsupported source type "+n.type))}return o.then(function(t){r.forEach(function(e){e.setSource(t)})}),o}});const _x="units",yx=[1,2,5],xx=25.4/.28;function vx(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function bx(t){if(Object.prototype.hasOwnProperty.call(t,"__esModule"))return t;var e=t.default;if("function"==typeof e){var n=function t(){var n=!1;try{n=this instanceof t}catch{}return n?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};n.prototype=e.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(t).forEach(function(e){var i=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(n,e,i.get?i:{enumerable:!0,get:function(){return t[e]}})}),n}var wx,Sx={exports:{}},Cx=bx(Dl),Ex=bx(xi),Px=bx(Gh);var Tx=(wx||(wx=1,function(t){t.exports=function(t,e,n){t="default"in t?t.default:t,n="default"in n?n.default:n;const i="layer-switcher-";class r extends t{constructor(t){const e=Object.assign({},t),n=document.createElement("div");super({element:n,target:e.target}),this.activationMode=e.activationMode||"mouseover",this.startActive=!0===e.startActive,this.label=void 0!==e.label?e.label:"",this.collapseLabel=void 0!==e.collapseLabel?e.collapseLabel:"»",this.tipLabel=e.tipLabel?e.tipLabel:"Legend",this.collapseTipLabel=e.collapseTipLabel?e.collapseTipLabel:"Collapse legend",this.groupSelectStyle=r.getGroupSelectStyle(e.groupSelectStyle),this.reverse=!1!==e.reverse,this.mapListeners=[],this.hiddenClassName="ol-unselectable ol-control layer-switcher",r.isTouchDevice_()&&(this.hiddenClassName+=" touch"),this.shownClassName="shown",n.className=this.hiddenClassName,this.button=document.createElement("button"),n.appendChild(this.button),this.panel=document.createElement("div"),this.panel.className="panel",n.appendChild(this.panel),r.enableTouchScroll_(this.panel),n.classList.add(i+"group-select-style-"+this.groupSelectStyle),n.classList.add(i+"activation-mode-"+this.activationMode),"click"===this.activationMode?(n.classList.add("activationModeClick"),this.button.onclick=t=>{const e=t||window.event;this.element.classList.contains(this.shownClassName)?this.hidePanel():this.showPanel(),e.preventDefault()}):(this.button.onmouseover=()=>{this.showPanel()},this.button.onclick=t=>{const e=t||window.event;this.showPanel(),e.preventDefault()},this.panel.onmouseout=t=>{this.panel.contains(t.relatedTarget)||this.hidePanel()}),this.updateButton()}setMap(t){for(let t=0;t<this.mapListeners.length;t++)e.unByKey(this.mapListeners[t]);this.mapListeners.length=0,super.setMap(t),t&&(this.startActive?this.showPanel():this.renderPanel(),"click"!==this.activationMode&&this.mapListeners.push(t.on("pointerdown",()=>{this.hidePanel()})))}showPanel(){this.element.classList.contains(this.shownClassName)||(this.element.classList.add(this.shownClassName),this.updateButton(),this.renderPanel()),this.dispatchEvent("show")}hidePanel(){this.element.classList.contains(this.shownClassName)&&(this.element.classList.remove(this.shownClassName),this.updateButton()),this.dispatchEvent("hide")}updateButton(){this.element.classList.contains(this.shownClassName)?(this.button.textContent=this.collapseLabel,this.button.setAttribute("title",this.collapseTipLabel),this.button.setAttribute("aria-label",this.collapseTipLabel)):(this.button.textContent=this.label,this.button.setAttribute("title",this.tipLabel),this.button.setAttribute("aria-label",this.tipLabel))}renderPanel(){this.dispatchEvent("render"),r.renderPanel(this.getMap(),this.panel,{groupSelectStyle:this.groupSelectStyle,reverse:this.reverse}),this.dispatchEvent("rendercomplete")}static renderPanel(t,e,n){const i=new Event("render");for(e.dispatchEvent(i),(n=n||{}).groupSelectStyle=r.getGroupSelectStyle(n.groupSelectStyle),r.ensureTopVisibleBaseLayerShown(t,n.groupSelectStyle);e.firstChild;)e.removeChild(e.firstChild);r.forEachRecursive(t,function(t,e,n){t.set("indeterminate",!1)}),"children"===n.groupSelectStyle||"none"===n.groupSelectStyle?r.setGroupVisibility(t):"group"===n.groupSelectStyle&&r.setChildVisibility(t);const s=document.createElement("ul");e.appendChild(s),r.renderLayers_(t,t,s,n,function(i){r.renderPanel(t,e,n)});const o=new Event("rendercomplete");e.dispatchEvent(o)}static isBaseGroup(t){if(t instanceof n){const e=t.getLayers().getArray();return e.length&&"base"===e[0].get("type")}return!1}static setGroupVisibility(t){r.getGroupsAndLayers(t,function(t){return t instanceof n&&!t.get("combine")&&!r.isBaseGroup(t)}).reverse().forEach(function(t){const e=t.getLayersArray().map(function(t){return t.getVisible()});e.every(function(t){return!0===t})?(t.setVisible(!0),t.set("indeterminate",!1)):e.every(function(t){return!1===t})?(t.setVisible(!1),t.set("indeterminate",!1)):(t.setVisible(!0),t.set("indeterminate",!0))})}static setChildVisibility(t){r.getGroupsAndLayers(t,function(t){return t instanceof n&&!t.get("combine")&&!r.isBaseGroup(t)}).forEach(function(t){const e=t,n=e.getVisible(),i=e.get("indeterminate");e.getLayers().getArray().forEach(function(t){t.set("indeterminate",!1),n&&!i||!t.getVisible()||t.set("indeterminate",!0)})})}static ensureTopVisibleBaseLayerShown(t,e){let n;r.forEachRecursive(t,function(t,e,i){"base"===t.get("type")&&t.getVisible()&&(n=t)}),n&&r.setVisible_(t,n,!0,e)}static getGroupsAndLayers(t,e){const n=[];return e=e||function(t,e,n){return!0},r.forEachRecursive(t,function(t,i,r){t.get("title")&&e(t,i,r)&&n.push(t)}),n}static setVisible_(t,e,i,s){e.setVisible(i),i&&"base"===e.get("type")&&r.forEachRecursive(t,function(t,n,i){t!=e&&"base"===t.get("type")&&t.setVisible(!1)}),e instanceof n&&!e.get("combine")&&"children"===s&&e.getLayers().forEach(n=>{r.setVisible_(t,n,e.getVisible(),s)})}static renderLayer_(t,e,s,o,a){const l=document.createElement("li"),h=e.get("title"),c=r.uuid(),u=document.createElement("label");if(e instanceof n&&!e.get("combine")){const n=r.isBaseGroup(e);if(l.classList.add("group"),n&&l.classList.add(i+"base-group"),e.get("fold")){l.classList.add(i+"fold"),l.classList.add(i+e.get("fold"));const t=document.createElement("button");t.onclick=function(t){const n=t||window.event;r.toggleFold_(e,l),n.preventDefault()},l.appendChild(t)}if(!n&&"none"!=o.groupSelectStyle){const n=document.createElement("input");n.type="checkbox",n.id=c,n.checked=e.getVisible(),n.indeterminate=e.get("indeterminate"),n.onchange=function(n){const i=n.target;r.setVisible_(t,e,i.checked,o.groupSelectStyle),a(e)},l.appendChild(n),u.htmlFor=c}u.innerHTML=h,l.appendChild(u);const s=document.createElement("ul");l.appendChild(s),r.renderLayers_(t,e,s,o,a)}else{l.className="layer";const n=document.createElement("input");"base"===e.get("type")?n.type="radio":n.type="checkbox",n.id=c,n.checked=e.get("visible"),n.indeterminate=e.get("indeterminate"),n.onchange=function(n){const i=n.target;r.setVisible_(t,e,i.checked,o.groupSelectStyle),a(e)},l.appendChild(n),u.htmlFor=c,u.innerHTML=h;const i=t.getView().getResolution();if(i>=e.getMaxResolution()||i<e.getMinResolution())u.className+=" disabled";else if(e.getMinZoom&&e.getMaxZoom){const n=t.getView().getZoom();(n<=e.getMinZoom()||n>e.getMaxZoom())&&(u.className+=" disabled")}l.appendChild(u)}return l}static renderLayers_(t,e,n,i,s){let o=e.getLayers().getArray().slice();i.reverse&&(o=o.reverse());for(let e,a=0;a<o.length;a++)e=o[a],e.get("title")&&n.appendChild(r.renderLayer_(t,e,a,i,s))}static forEachRecursive(t,e){t.getLayers().forEach(function(t,i,s){e(t,i,s),t instanceof n&&r.forEachRecursive(t,e)})}static uuid(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){const e=16*Math.random()|0;return("x"==t?e:3&e|8).toString(16)})}static enableTouchScroll_(t){if(r.isTouchDevice_()){let e=0;t.addEventListener("touchstart",function(t){e=this.scrollTop+t.touches[0].pageY},!1),t.addEventListener("touchmove",function(t){this.scrollTop=e-t.touches[0].pageY},!1)}}static isTouchDevice_(){try{return document.createEvent("TouchEvent"),!0}catch(t){return!1}}static toggleFold_(t,e){e.classList.remove(i+t.get("fold")),t.set("fold","open"===t.get("fold")?"close":"open"),e.classList.add(i+t.get("fold"))}static getGroupSelectStyle(t){return["none","children","group"].indexOf(t)>=0?t:"children"}}return window.ol&&window.ol.control&&(window.ol.control.LayerSwitcher=r),r}(Cx,Ex,Px)}(Sx)),Sx.exports),Rx=vx(Tx);const Fx="addfeatures";class Mx extends pi{constructor(t,e,n,i){super(t),this.features=n,this.file=e,this.projection=i}}class Ix extends ma{constructor(t,e,n){super(),void 0!==n&&void 0===e?this.setFlatCoordinates(n,t):(e=e||0,this.setCenterAndRadius(t,e,n))}clone(){const t=new Ix(this.flatCoordinates.slice(),void 0,this.layout);return t.applyProperties(this),t}closestPointXY(t,e,n,i){const r=this.flatCoordinates,s=t-r[0],o=e-r[1],a=s*s+o*o;if(a<i){if(0===a)for(let t=0;t<this.stride;++t)n[t]=r[t];else{const t=this.getRadius()/Math.sqrt(a);n[0]=r[0]+t*s,n[1]=r[1]+t*o;for(let t=2;t<this.stride;++t)n[t]=r[t]}return n.length=this.stride,a}return i}containsXY(t,e){const n=this.flatCoordinates,i=t-n[0],r=e-n[1];return i*i+r*r<=this.getRadiusSquared_()}getCenter(){return this.flatCoordinates.slice(0,this.stride)}computeExtent(t){const e=this.flatCoordinates,n=e[this.stride]-e[0];return jr(e[0]-n,e[1]-n,e[0]+n,e[1]+n,t)}getRadius(){return Math.sqrt(this.getRadiusSquared_())}getRadiusSquared_(){const t=this.flatCoordinates[this.stride]-this.flatCoordinates[0],e=this.flatCoordinates[this.stride+1]-this.flatCoordinates[1];return t*t+e*e}getType(){return"Circle"}intersectsExtent(t){if(as(t,this.getExtent())){const e=this.getCenter();return t[0]<=e[0]&&t[2]>=e[0]||(t[1]<=e[1]&&t[3]>=e[1]||Zr(t,this.intersectsCoordinate.bind(this)))}return!1}setCenter(t){const e=this.stride,n=this.flatCoordinates[e]-this.flatCoordinates[0],i=t.slice();i[e]=i[0]+n;for(let n=1;n<e;++n)i[e+n]=t[n];this.setFlatCoordinates(this.layout,i),this.changed()}setCenterAndRadius(t,e,n){this.setLayout(n,t,0),this.flatCoordinates||(this.flatCoordinates=[]);const i=this.flatCoordinates;let r=Pa(i,0,t,this.stride);i[r++]=i[0]+e;for(let t=1,e=this.stride;t<e;++t)i[r++]=i[t];i.length=r,this.changed()}getCoordinates(){return null}setCoordinates(t,e){}setRadius(t){this.flatCoordinates[this.stride]=this.flatCoordinates[0]+t,this.changed()}rotate(t,e){const n=this.getCenter(),i=this.getStride();this.setCenter(da(n,0,n.length,i,t,e,n)),this.changed()}}function kx(t,e){const n=t.length;return e<0?t[e+n]:e>=n?t[e-n]:t[e]}function Lx(t,e){const n=t.length;let i=Math.floor(e);const r=e-i;i>=n?i-=n:i<0&&(i+=n);let s=i+1;s>=n&&(s-=n);const o=t[i],a=o[0],l=o[1],h=t[s];return[a+(h[0]-a)*r,l+(h[1]-l)*r]}Ix.prototype.transform;const Ax={index:-1,endIndex:NaN,closestTargetDistance:1/0};function Dx(t,e,n,i){const r=t[0],s=t[1];let o=1/0,a=-1,l=NaN;for(let t=0;t<e.targets.length;++t){const n=e.targets[t],i=n.coordinates;let h,c=1/0;for(let t=0;t<i.length-1;++t){const e=Bx(r,s,i[t],i[t+1]);e.squaredDistance<c&&(c=e.squaredDistance,h=t+e.along)}c<o&&(o=c,n.ring&&e.targetIndex===t&&(n.endIndex>n.startIndex?h<n.startIndex&&(h+=i.length):n.endIndex<n.startIndex&&h>n.startIndex&&(h-=i.length)),l=h,a=t)}const h=e.targets[a];let c=h.ring;if(e.targetIndex===a&&c){const t=Lx(h.coordinates,l);ys(n.getPixelFromCoordinate(t),n.getPixelFromCoordinate(e.startCoord))>i&&(c=!1)}if(c){const t=h.coordinates,e=t.length,n=h.startIndex,i=l;if(n<i){const r=Gx(t,n,i);Gx(t,n,i-e)<r&&(l-=e)}else{const r=Gx(t,n,i);Gx(t,n,i+e)<r&&(l+=e)}}return Ax.index=a,Ax.endIndex=l,Ax.closestTargetDistance=o,Ax}function Ox(t,e){const n=[];for(let i=0;i<e.length;++i){zx(t,e[i].getGeometry(),n)}return n}function zx(t,e,n){if(e instanceof Of)Nx(t,e.getCoordinates(),!1,n);else{if(e instanceof zf){const i=e.getCoordinates();for(let e=0,r=i.length;e<r;++e)Nx(t,i[e],!1,n);return}if(e instanceof il){const i=e.getCoordinates();for(let e=0,r=i.length;e<r;++e)Nx(t,i[e],!0,n);return}if(e instanceof Gf){const i=e.getCoordinates();for(let e=0,r=i.length;e<r;++e){const r=i[e];for(let e=0,i=r.length;e<i;++e)Nx(t,r[e],!0,n)}return}if(e instanceof Uf){const i=e.getGeometries();for(let e=0;e<i.length;++e)zx(t,i[e],n);return}}}function Nx(t,e,n,i){const r=t[0],s=t[1];for(let t=0,o=e.length-1;t<o;++t){const o=Bx(r,s,e[t],e[t+1]);if(0===o.squaredDistance){const r=t+o.along;return void i.push({coordinates:e,ring:n,startIndex:r,endIndex:r})}}}function jx(t,e){return dr(t[0],t[1],e[0],e[1])}function Gx(t,e,n){let i,r;e<n?(i=e,r=n):(i=n,r=e);const s=Math.ceil(i),o=Math.floor(r);if(s>o){return jx(Lx(t,i),Lx(t,r))}let a=0;if(i<s){a+=jx(Lx(t,i),kx(t,s))}if(o<r){a+=jx(kx(t,o),Lx(t,r))}for(let e=s;e<o-1;++e){a+=jx(kx(t,e),kx(t,e+1))}return a}const $x={along:0,squaredDistance:0};function Bx(t,e,n,i){const r=n[0],s=n[1],o=i[0]-r,a=i[1]-s;let l=0,h=r,c=s;return 0===o&&0===a||(l=cr(((t-r)*o+(e-s)*a)/(o*o+a*a),0,1),h+=o*l,c+=a*l),$x.along=l,$x.squaredDistance=_r(dr(t,e,h,c),10),$x}const Ux="drawstart",Vx="drawend",Xx="drawabort";class Wx extends pi{constructor(t,e){super(t),this.feature=e}}function qx(){const t=Kd();return function(e,n){return t[e.getGeometry().getType()]}}const Zx="extentchanged";class Kx extends pi{constructor(t){super(Zx),this.extent=t}}function Yx(){const t=Kd();return function(e,n){return t.Polygon}}function Hx(){const t=Kd();return function(e,n){return t.Point}}function Jx(t){return function(e){return Mr([t,e])}}function Qx(t,e){return t[0]==e[0]?function(n){return Mr([t,[n[0],e[1]]])}:t[1]==e[1]?function(n){return Mr([t,[e[0],n[1]]])}:null}function tv(t){return parseFloat(t)}function ev(t){return function(t){return _r(t,5)}(t).toString()}function nv(t,e){return!isNaN(t)&&t!==tv(ev(e))}const iv=[0,0,0,0],rv=[],sv="modifystart",ov="modifyend";function av(t,e,n){let i;switch(e){case"LineString":i=t;break;case"MultiLineString":case"Polygon":i=t[n[0]];break;case"MultiPolygon":i=t[n[1]][n[0]]}return i}class lv extends pi{constructor(t,e,n){super(t),this.features=e,this.mapBrowserEvent=n}}function hv(t,e){return t.index-e.index}function cv(t,e,n){const i=e.geometry;if("Circle"===i.getType()){let r=i;if(1===e.index){const e=Xo();e&&(r=r.clone().transform(e,n));const i=_s(r.getCenter(),qo(t,n)),s=Math.sqrt(i)-r.getRadius();return s*s}}const r=qo(t,n);return rv[0]=qo(e.segment[0],n),rv[1]=qo(e.segment[1],n),xs(r,rv)}function uv(t,e,n){const i=e.geometry;if("Circle"===i.getType()&&1===e.index){let e=i;const r=Xo();return r&&(e=e.clone().transform(r,n)),Wo(e.getClosestPoint(qo(t,n)),n)}const r=qo(t,n);return rv[0]=qo(e.segment[0],n),rv[1]=qo(e.segment[1],n),Wo(gs(r,rv),n)}function dv(){const t=Kd();return function(e,n){return t.Point}}const fv="select";class gv extends pi{constructor(t,e,n,i){super(t),this.selected=e,this.deselected=n,this.mapBrowserEvent=i}}const pv={};class mv extends $l{constructor(t){let e;if(super(),this.on,this.once,this.un,t=t||{},this.boundAddFeature_=this.addFeature_.bind(this),this.boundRemoveFeature_=this.removeFeature_.bind(this),this.condition_=t.condition?t.condition:Yl,this.addCondition_=t.addCondition?t.addCondition:Kl,this.removeCondition_=t.removeCondition?t.removeCondition:Kl,this.toggleCondition_=t.toggleCondition?t.toggleCondition:Jl,this.multi_=!!t.multi&&t.multi,this.filter_=t.filter?t.filter:ci,this.hitTolerance_=t.hitTolerance?t.hitTolerance:0,this.style_=void 0!==t.style?t.style:function(){const t=Kd();return li(t.Polygon,t.LineString),li(t.GeometryCollection,t.LineString),function(e){return e.getGeometry()?t[e.getGeometry().getType()]:null}}(),this.features_=t.features||new Ti,t.layers)if("function"==typeof t.layers)e=t.layers;else{const n=t.layers;e=function(t){return n.includes(t)}}else e=ci;this.layerFilter_=e,this.featureLayerAssociation_={}}addFeatureLayerAssociation_(t,e){this.featureLayerAssociation_[wi(t)]=e}getFeatures(){return this.features_}getHitTolerance(){return this.hitTolerance_}getLayer(t){return this.featureLayerAssociation_[wi(t)]}setHitTolerance(t){this.hitTolerance_=t}setMap(t){this.getMap()&&this.style_&&this.features_.forEach(this.restorePreviousStyle_.bind(this)),super.setMap(t),t?(this.features_.addEventListener(On,this.boundAddFeature_),this.features_.addEventListener(zn,this.boundRemoveFeature_),this.style_&&this.features_.forEach(this.applySelectedStyle_.bind(this))):(this.features_.removeEventListener(On,this.boundAddFeature_),this.features_.removeEventListener(zn,this.boundRemoveFeature_))}addFeature_(t){const e=t.element;if(this.style_&&this.applySelectedStyle_(e),!this.getLayer(e)){const t=this.findLayerOfFeature_(e);t&&this.addFeatureLayerAssociation_(e,t)}}removeFeature_(t){this.style_&&this.restorePreviousStyle_(t.element),this.removeFeatureLayerAssociation_(t.element)}findLayerOfFeature_(t){return this.getMap().getAllLayers().find(function(e){if(e instanceof rm&&e.getSource()&&e.getSource().hasFeature(t))return e})}getStyle(){return this.style_}applySelectedStyle_(t){const e=wi(t);e in pv||(pv[e]=t.getStyle()),t.setStyle(this.style_)}restorePreviousStyle_(t){const e=this.getMap().getInteractions().getArray();for(let n=e.length-1;n>=0;--n){const i=e[n];if(i!==this&&i instanceof mv&&i.getStyle()&&-1!==i.getFeatures().getArray().lastIndexOf(t))return void t.setStyle(i.getStyle())}const n=wi(t);t.setStyle(pv[n]),delete pv[n]}removeFeatureLayerAssociation_(t){delete this.featureLayerAssociation_[wi(t)]}selectFeature(t){const e=this.findLayerOfFeature_(t);if(!this.layerFilter_(e)||!this.filter_(t,e))return!1;const n=this.getFeatures();return!n.getArray().includes(t)&&(this.addFeatureLayerAssociation_(t,e),n.push(t),this.dispatchEvent(new gv(fv,[t],[],void 0)),!0)}deselectFeature(t){const e=this.getFeatures(),n=e.getArray().indexOf(t);return-1!==n&&(e.removeAt(n),this.dispatchEvent(new gv(fv,[],[t],void 0)),!0)}toggleFeature(t){this.deselectFeature(t)||this.selectFeature(t)}clearSelection(){const t=this.getFeatures();if(0!==t.getLength()){const e=t.getArray().slice();t.clear(),this.dispatchEvent(new gv(fv,[],e,void 0))}}handleEvent(t){if(!this.condition_(t))return!0;const e=this.addCondition_(t),n=this.removeCondition_(t),i=this.toggleCondition_(t),r=!e&&!n&&!i,s=t.map,o=this.getFeatures(),a=[],l=[];if(r){s.forEachFeatureAtPixel(t.pixel,(t,e)=>{if(t instanceof kf&&this.filter_(t,e))return this.addFeatureLayerAssociation_(t,e),l.push(t),!this.multi_},{layerFilter:this.layerFilter_,hitTolerance:this.hitTolerance_});for(let t=o.getLength()-1;t>=0;--t){const e=o.item(t),n=l.indexOf(e);-1===n?(o.removeAt(t),a.push(e)):l.splice(n,1)}0!==l.length&&o.extend(l)}else{s.forEachFeatureAtPixel(t.pixel,(t,r)=>{if(!(t instanceof kf&&this.filter_(t,r)))return;const s=o.getArray().includes(t);return s&&(n||i)?a.push(t):s||!e&&!i||(this.addFeatureLayerAssociation_(t,r),l.push(t)),!this.multi_},{layerFilter:this.layerFilter_,hitTolerance:this.hitTolerance_});for(let t=a.length-1;t>=0;--t)o.remove(a[t]);o.extend(l)}return(l.length>0||a.length>0)&&this.dispatchEvent(new gv(fv,l,a,t)),!0}}const _v="snap",yv="unsnap";class xv extends pi{constructor(t,e){super(t),this.vertex=e.vertex,this.vertexPixel=e.vertexPixel,this.feature=e.feature,this.segment=e.segment}}const vv={Circle(t,e){let n=t;const i=Xo();i&&(n=n.clone().transform(i,e));const r=sl(n);return i&&r.transform(e,i),vv.Polygon(r)},GeometryCollection(t,e){const n=[],i=t.getGeometriesArray();for(let t=0;t<i.length;++t){const r=this[i[t].getType()];r&&n.push(r(i[t],e))}return n.flat()},LineString(t){const e=[],n=t.getFlatCoordinates(),i=t.getStride();for(let t=0,r=n.length-i;t<r;t+=i)e.push([n.slice(t,t+2),n.slice(t+i,t+i+2)]);return e},MultiLineString(t){const e=[],n=t.getFlatCoordinates(),i=t.getStride(),r=t.getEnds();let s=0;for(let t=0,o=r.length;t<o;++t){const o=r[t];for(let t=s,r=o-i;t<r;t+=i)e.push([n.slice(t,t+2),n.slice(t+i,t+i+2)]);s=o}return e},MultiPoint(t){const e=[],n=t.getFlatCoordinates(),i=t.getStride();for(let t=0,r=n.length;t<r;t+=i)e.push([n.slice(t,t+2)]);return e},MultiPolygon(t){const e=[],n=t.getFlatCoordinates(),i=t.getStride(),r=t.getEndss();let s=0;for(let t=0,o=r.length;t<o;++t){const o=r[t];for(let t=0,r=o.length;t<r;++t){const r=o[t];for(let t=s,o=r-i;t<o;t+=i)e.push([n.slice(t,t+2),n.slice(t+i,t+i+2)]);s=r}}return e},Point:t=>[[t.getFlatCoordinates().slice(0,2)]],Polygon(t){const e=[],n=t.getFlatCoordinates(),i=t.getStride(),r=t.getEnds();let s=0;for(let t=0,o=r.length;t<o;++t){const o=r[t];for(let t=s,r=o-i;t<r;t+=i)e.push([n.slice(t,t+2),n.slice(t+i,t+i+2)]);s=o}return e}};function bv(t){return t.feature?t.feature:t.element?t.element:null}const wv=[],Sv=[],Cv=[];const Ev="translatestart",Pv="translating",Tv="translateend";class Rv extends pi{constructor(t,e,n,i,r){super(t),this.features=e,this.coordinate=n,this.startCoordinate=i,this.mapBrowserEvent=r}}var Fv=Object.freeze({__proto__:null,DblClickDragZoom:class extends $l{constructor(t){const e=t||{};super(e),e.stopDown&&(this.stopDown=e.stopDown),this.scaleDeltaByPixel_=e.delta?e.delta:.01,this.duration_=void 0!==e.duration?e.duration:250,this.handlingDownUpSequence_=!1,this.handlingDoubleDownSequence_=!1,this.doubleTapTimeoutId_=void 0,this.trackedPointers_={},this.down_=null,this.targetPointers=[]}handleEvent(t){if(!t.originalEvent)return!0;let e=!1;if(this.updateTrackedPointers_(t),this.handlingDownUpSequence_){if(t.type==Mi.POINTERDRAG)this.handleDragEvent(t),t.originalEvent.preventDefault();else if(t.type==Mi.POINTERUP){const e=this.handleUpEvent(t);this.handlingDownUpSequence_=e}}else if(t.type==Mi.POINTERDOWN)if(this.handlingDoubleDownSequence_){this.handlingDoubleDownSequence_=!1;const n=this.handleDownEvent(t);this.handlingDownUpSequence_=n,e=this.stopDown(n)}else e=this.stopDown(!1),this.waitForDblTap_();return!e}handleDragEvent(t){let e=1;const n=this.targetPointers[0],i=this.down_,r=n.clientY-i.clientY;void 0!==this.lastDistance_&&(e=1-(this.lastDistance_-r)*this.scaleDeltaByPixel_),this.lastDistance_=r,1!=e&&(this.lastScaleDelta_=e);const s=t.map,o=s.getView();s.render(),o.adjustResolutionInternal(e)}handleDownEvent(t){if(1==this.targetPointers.length){const e=t.map;return this.anchor_=null,this.lastDistance_=void 0,this.lastScaleDelta_=1,this.down_=t.originalEvent,this.handlingDownUpSequence_||e.getView().beginInteraction(),!0}return!1}handleUpEvent(t){if(0==this.targetPointers.length){const e=t.map.getView(),n=this.lastScaleDelta_>1?1:-1;return e.endInteraction(this.duration_,n),this.handlingDownUpSequence_=!1,this.handlingDoubleDownSequence_=!1,!1}return!0}stopDown(t){return t}updateTrackedPointers_(t){if(function(t){const e=t.type;return e===Mi.POINTERDOWN||e===Mi.POINTERDRAG||e===Mi.POINTERUP}(t)){const e=t.originalEvent,n=e.pointerId.toString();t.type==Mi.POINTERUP?delete this.trackedPointers_[n]:(t.type==Mi.POINTERDOWN||n in this.trackedPointers_)&&(this.trackedPointers_[n]=e),this.targetPointers=Object.values(this.trackedPointers_)}}waitForDblTap_(){void 0!==this.doubleTapTimeoutId_?(clearTimeout(this.doubleTapTimeoutId_),this.doubleTapTimeoutId_=void 0):(this.handlingDoubleDownSequence_=!0,this.doubleTapTimeoutId_=setTimeout(this.endInteraction_.bind(this),250))}endInteraction_(){this.handlingDoubleDownSequence_=!1,this.doubleTapTimeoutId_=void 0}},DoubleClickZoom:Ul,DragAndDrop:class extends $l{constructor(t){t=t||{},super({handleEvent:ci}),this.on,this.once,this.un,this.readAsBuffer_=!1,this.formats_=[];const e=t.formatConstructors?t.formatConstructors:[];for(let t=0,n=e.length;t<n;++t){let n=e[t];"function"==typeof n&&(n=new n),this.formats_.push(n),this.readAsBuffer_=this.readAsBuffer_||"arraybuffer"===n.getType()}this.projection_=t.projection?Mo(t.projection):null,this.dropListenKeys_=null,this.source_=t.source||null,this.target=t.target?t.target:null}handleResult_(t,e){const n=e.target.result,i=this.getMap();let r,s=this.projection_;if(!s&&(s=Xo(),!s)){s=i.getView().getProjection()}const o=this.formats_;for(let e=0,i=o.length;e<i;++e){const i=o[e];let a=n;this.readAsBuffer_&&"arraybuffer"!==i.getType()&&(void 0===r&&(r=(new TextDecoder).decode(n)),a=r);const l=this.tryReadFeatures_(i,a,{featureProjection:s});if(l&&l.length>0){this.source_&&(this.source_.clear(),this.source_.addFeatures(l)),this.dispatchEvent(new Mx(Fx,t,l,s));break}}}registerListeners_(){const t=this.getMap();if(t){const e=this.target?this.target:t.getViewport();this.dropListenKeys_=[$n(e,Hn,this.handleDrop,this),$n(e,Kn,this.handleStop,this),$n(e,Yn,this.handleStop,this),$n(e,Hn,this.handleStop,this)]}}setActive(t){!this.getActive()&&t&&this.registerListeners_(),this.getActive()&&!t&&this.unregisterListeners_(),super.setActive(t)}setMap(t){this.unregisterListeners_(),super.setMap(t),this.getActive()&&this.registerListeners_()}tryReadFeatures_(t,e,n){try{return t.readFeatures(e,n)}catch{return null}}unregisterListeners_(){this.dropListenKeys_&&(this.dropListenKeys_.forEach(Un),this.dropListenKeys_=null)}handleDrop(t){const e=t.dataTransfer.files;for(let t=0,n=e.length;t<n;++t){const n=e.item(t),i=new FileReader;i.addEventListener(ti,this.handleResult_.bind(this,n)),this.readAsBuffer_?i.readAsArrayBuffer(n):i.readAsText(n)}}handleStop(t){t.stopPropagation(),t.preventDefault(),t.dataTransfer.dropEffect="copy"}},DragBox:dh,DragPan:rh,DragRotate:sh,DragRotateAndZoom:class extends nh{constructor(t){super(t=t||{}),this.condition_=t.condition?t.condition:Jl,this.lastAngle_=void 0,this.lastMagnitude_=void 0,this.lastScaleDelta_=0,this.duration_=void 0!==t.duration?t.duration:400}handleDragEvent(t){if(!th(t))return;const e=t.map,n=e.getSize(),i=t.pixel,r=i[0]-n[0]/2,s=n[1]/2-i[1],o=Math.atan2(s,r),a=Math.sqrt(r*r+s*s),l=e.getView();if(void 0!==this.lastAngle_){const t=this.lastAngle_-o;l.adjustRotationInternal(t)}this.lastAngle_=o,void 0!==this.lastMagnitude_&&l.adjustResolutionInternal(this.lastMagnitude_/a),void 0!==this.lastMagnitude_&&(this.lastScaleDelta_=this.lastMagnitude_/a),this.lastMagnitude_=a}handleUpEvent(t){if(!th(t))return!0;const e=t.map.getView(),n=this.lastScaleDelta_>1?1:-1;return e.endInteraction(this.duration_,n),this.lastScaleDelta_=0,!1}handleDownEvent(t){return!!th(t)&&(!!this.condition_(t)&&(t.map.getView().beginInteraction(),this.lastAngle_=void 0,this.lastMagnitude_=void 0,!0))}},DragZoom:fh,Draw:class extends nh{constructor(t){const e=t;e.stopDown||(e.stopDown=ui),super(e),this.on,this.once,this.un,this.options_=t,this.shouldHandle_=!1,this.downPx_=null,this.downTimeout_,this.lastDragTime_,this.pointerType_,this.freehand_=!1,this.source_=t.source?t.source:null,this.features_=t.features?t.features:null,this.snapTolerance_=t.snapTolerance?t.snapTolerance:12,this.type_=t.type,this.mode_=function(t){switch(t){case"Point":case"MultiPoint":return"Point";case"LineString":case"MultiLineString":return"LineString";case"Polygon":case"MultiPolygon":return"Polygon";case"Circle":return"Circle";default:throw new Error("Invalid type: "+t)}}(this.type_),this.stopClick_=!!t.stopClick,this.ignoreNextUpEvent_=!1,this.minPoints_=t.minPoints?t.minPoints:"Polygon"===this.mode_?3:2,this.maxPoints_="Circle"===this.mode_?2:t.maxPoints?t.maxPoints:1/0,this.finishCondition_=t.finishCondition?t.finishCondition:ci,this.geometryLayout_=t.geometryLayout?t.geometryLayout:"XY";let n=t.geometryFunction;if(!n){const t=this.mode_;if("Circle"===t)n=(t,e,n)=>{const i=e||new Ix([NaN,NaN]),r=qo(t[0],n),s=_s(r,qo(t[t.length-1],n));i.setCenterAndRadius(r,Math.sqrt(s),this.geometryLayout_);const o=Xo();return o&&i.transform(n,o),i};else{let e;"Point"===t?e=ja:"LineString"===t?e=Of:"Polygon"===t&&(e=il),n=(n,i,r)=>(i?"Polygon"===t?n[0].length?i.setCoordinates([n[0].concat([n[0][0]])],this.geometryLayout_):i.setCoordinates([],this.geometryLayout_):i.setCoordinates(n,this.geometryLayout_):i=new e(n,this.geometryLayout_),i)}}this.geometryFunction_=n,this.dragVertexDelay_=void 0!==t.dragVertexDelay?t.dragVertexDelay:500,this.finishCoordinate_=null,this.sketchFeature_=null,this.sketchPoint_=null,this.sketchCoords_=null,this.sketchLine_=null,this.sketchLineCoords_=null,this.squaredClickTolerance_=t.clickTolerance?t.clickTolerance*t.clickTolerance:36,this.overlay_=new rm({source:new Hm({useSpatialIndex:!1,wrapX:!!t.wrapX&&t.wrapX}),style:t.style?t.style:qx(),updateWhileInteracting:!0}),this.geometryName_=t.geometryName,this.condition_=t.condition?t.condition:Hl,this.freehandCondition_,t.freehand?this.freehandCondition_=ql:this.freehandCondition_=t.freehandCondition?t.freehandCondition:Jl,this.traceCondition_,this.setTrace(t.trace||!1),this.traceState_={active:!1},this.traceSource_=t.traceSource||t.source||null,this.addChangeListener(Gl,this.updateState_)}setTrace(t){let e;e=t?!0===t?ql:t:Kl,this.traceCondition_=e}setMap(t){super.setMap(t),this.updateState_()}setFreehand(t){this.freehand_=t,this.freehand_?this.freehandCondition_=ql:this.freehandCondition_=this.options_&&this.options_.freehandCondition?this.options_.freehandCondition:Jl}getOverlay(){return this.overlay_}getFreehand(){return this.freehand_}handleEvent(t){t.originalEvent.type===Wn&&t.originalEvent.preventDefault(),this.freehand_="Point"!==this.mode_&&this.freehandCondition_(t);let e=t.type===Mi.POINTERMOVE,n=!0;if(!this.freehand_&&this.lastDragTime_&&t.type===Mi.POINTERDRAG){Date.now()-this.lastDragTime_>=this.dragVertexDelay_?(this.downPx_=t.pixel,this.shouldHandle_=!this.freehand_,e=!0):this.lastDragTime_=void 0,this.shouldHandle_&&void 0!==this.downTimeout_&&(clearTimeout(this.downTimeout_),this.downTimeout_=void 0)}return this.freehand_&&t.type===Mi.POINTERDRAG&&null!==this.sketchFeature_?(this.addToDrawing_(t.coordinate),n=!1):this.freehand_&&t.type===Mi.POINTERDOWN?n=!1:e&&this.getPointerCount()<2?(n=t.type===Mi.POINTERMOVE,n&&this.freehand_?(this.handlePointerMove_(t),this.shouldHandle_&&t.originalEvent.preventDefault()):("mouse"===t.originalEvent.pointerType||t.type===Mi.POINTERDRAG&&void 0===this.downTimeout_)&&this.handlePointerMove_(t)):t.type===Mi.DBLCLICK&&(n=!1),super.handleEvent(t)&&n}handleDownEvent(t){return this.shouldHandle_=!this.freehand_,this.freehand_?(this.downPx_=t.pixel,this.finishCoordinate_||this.startDrawing_(t.coordinate),!0):this.condition_(t)?(this.lastDragTime_=Date.now(),this.downTimeout_=setTimeout(()=>{this.handlePointerMove_(new Fi(Mi.POINTERMOVE,t.map,t.originalEvent,!1,t.frameState))},this.dragVertexDelay_),this.downPx_=t.pixel,!0):(this.lastDragTime_=void 0,!1)}deactivateTrace_(){this.traceState_={active:!1}}toggleTraceState_(t){if(!this.traceSource_||!this.traceCondition_(t))return;if(this.traceState_.active)return void this.deactivateTrace_();const e=this.getMap(),n=Mr([e.getCoordinateFromPixel([t.pixel[0]-this.snapTolerance_,t.pixel[1]+this.snapTolerance_]),e.getCoordinateFromPixel([t.pixel[0]+this.snapTolerance_,t.pixel[1]-this.snapTolerance_])]),i=this.traceSource_.getFeaturesInExtent(n);if(0===i.length)return;const r=Ox(t.coordinate,i);r.length&&(this.traceState_={active:!0,startCoord:t.coordinate.slice(),targets:r,targetIndex:-1})}addOrRemoveTracedCoordinates_(t,e){const n=t.startIndex<=t.endIndex;n===t.startIndex<=e?n&&e>t.endIndex||!n&&e<t.endIndex?this.addTracedCoordinates_(t,t.endIndex,e):(n&&e<t.endIndex||!n&&e>t.endIndex)&&this.removeTracedCoordinates_(e,t.endIndex):(this.removeTracedCoordinates_(t.startIndex,t.endIndex),this.addTracedCoordinates_(t,t.startIndex,e))}removeTracedCoordinates_(t,e){if(t===e)return;let n=0;if(t<e){const i=Math.ceil(t);let r=Math.floor(e);r===e&&(r-=1),n=r-i+1}else{const i=Math.floor(t);let r=Math.ceil(e);r===e&&(r+=1),n=i-r+1}n>0&&this.removeLastPoints_(n)}addTracedCoordinates_(t,e,n){if(e===n)return;const i=[];if(e<n){const r=Math.ceil(e);let s=Math.floor(n);s===n&&(s-=1);for(let e=r;e<=s;++e)i.push(kx(t.coordinates,e))}else{const r=Math.floor(e);let s=Math.ceil(n);s===n&&(s+=1);for(let e=r;e>=s;--e)i.push(kx(t.coordinates,e))}i.length&&this.appendCoordinates(i)}updateTrace_(t){const e=this.traceState_;if(!e.active)return;if(-1===e.targetIndex){if(ys(t.map.getPixelFromCoordinate(e.startCoord),t.pixel)<this.snapTolerance_)return}const n=Dx(t.coordinate,e,this.getMap(),this.snapTolerance_);if(e.targetIndex!==n.index){if(-1!==e.targetIndex){const t=e.targets[e.targetIndex];this.removeTracedCoordinates_(t.startIndex,t.endIndex)}const t=e.targets[n.index];this.addTracedCoordinates_(t,t.startIndex,n.endIndex)}else{const t=e.targets[e.targetIndex];this.addOrRemoveTracedCoordinates_(t,n.endIndex)}e.targetIndex=n.index;const i=e.targets[e.targetIndex];i.endIndex=n.endIndex;const r=Lx(i.coordinates,i.endIndex),s=this.getMap().getPixelFromCoordinate(r);t.coordinate=r,t.pixel=[Math.round(s[0]),Math.round(s[1])]}handleDragEvent(t){this.ignoreNextUpEvent_=!0,super.handleDragEvent(t)}handleUpEvent(t){let e=!0;if(0===this.getPointerCount()){this.downTimeout_&&(clearTimeout(this.downTimeout_),this.downTimeout_=void 0),this.handlePointerMove_(t);const n=this.traceState_.active;if(this.ignoreNextUpEvent_||this.toggleTraceState_(t),this.shouldHandle_){const i=!this.finishCoordinate_;i&&this.startDrawing_(t.coordinate),!i&&this.freehand_?this.finishDrawing():this.freehand_||i&&"Point"!==this.mode_||(this.atFinish_(t.pixel,n)?this.finishCondition_(t)&&this.finishDrawing():this.addToDrawing_(t.coordinate)),e=!1}else this.freehand_&&this.abortDrawing()}return this.ignoreNextUpEvent_=!1,!e&&this.stopClick_&&t.preventDefault(),e}handlePointerMove_(t){if(this.pointerType_=t.originalEvent.pointerType,this.downPx_&&(!this.freehand_&&this.shouldHandle_||this.freehand_&&!this.shouldHandle_)){const e=this.downPx_,n=t.pixel,i=e[0]-n[0],r=e[1]-n[1],s=i*i+r*r;if(this.shouldHandle_=this.freehand_?s>this.squaredClickTolerance_:s<=this.squaredClickTolerance_,!this.shouldHandle_)return}this.finishCoordinate_?(this.updateTrace_(t),this.modifyDrawing_(t.coordinate)):this.createOrUpdateSketchPoint_(t.coordinate.slice())}atFinish_(t,e){let n=!1;if(this.sketchFeature_){let i=!1,r=[this.finishCoordinate_];const s=this.mode_;if("Point"===s)n=!0;else if("Circle"===s)n=2===this.sketchCoords_.length;else if("LineString"===s)i=!e&&this.sketchCoords_.length>this.minPoints_;else if("Polygon"===s){const t=this.sketchCoords_;i=t[0].length>this.minPoints_,r=[t[0][0],t[0][t[0].length-2]],r=e?[t[0][0]]:[t[0][0],t[0][t[0].length-2]]}if(i){const e=this.getMap();for(let i=0,s=r.length;i<s;i++){const s=r[i],o=e.getPixelFromCoordinate(s),a=t[0]-o[0],l=t[1]-o[1],h=this.freehand_?1:this.snapTolerance_;if(n=Math.sqrt(a*a+l*l)<=h,n){this.finishCoordinate_=s;break}}}}return n}createOrUpdateSketchPoint_(t){if(this.sketchPoint_){this.sketchPoint_.getGeometry().setCoordinates(t)}else this.sketchPoint_=new kf(new ja(t)),this.updateSketchFeatures_()}createOrUpdateCustomSketchLine_(t){this.sketchLine_||(this.sketchLine_=new kf);const e=t.getLinearRing(0);let n=this.sketchLine_.getGeometry();n?(n.setFlatCoordinates(e.getLayout(),e.getFlatCoordinates()),n.changed()):(n=new Of(e.getFlatCoordinates(),e.getLayout()),this.sketchLine_.setGeometry(n))}startDrawing_(t){const e=this.getMap().getView().getProjection(),n=ya(this.geometryLayout_);for(;t.length<n;)t.push(0);this.finishCoordinate_=t,"Point"===this.mode_?this.sketchCoords_=t.slice():"Polygon"===this.mode_?(this.sketchCoords_=[[t.slice(),t.slice()]],this.sketchLineCoords_=this.sketchCoords_[0]):this.sketchCoords_=[t.slice(),t.slice()],this.sketchLineCoords_&&(this.sketchLine_=new kf(new Of(this.sketchLineCoords_)));const i=this.geometryFunction_(this.sketchCoords_,void 0,e);this.sketchFeature_=new kf,this.geometryName_&&this.sketchFeature_.setGeometryName(this.geometryName_),this.sketchFeature_.setGeometry(i),this.updateSketchFeatures_(),this.dispatchEvent(new Wx(Ux,this.sketchFeature_))}modifyDrawing_(t){const e=this.getMap(),n=this.sketchFeature_.getGeometry(),i=e.getView().getProjection(),r=ya(this.geometryLayout_);let s,o;for(;t.length<r;)t.push(0);if("Point"===this.mode_?o=this.sketchCoords_:"Polygon"===this.mode_?(s=this.sketchCoords_[0],o=s[s.length-1],this.atFinish_(e.getPixelFromCoordinate(t))&&(t=this.finishCoordinate_.slice())):(s=this.sketchCoords_,o=s[s.length-1]),o[0]=t[0],o[1]=t[1],this.geometryFunction_(this.sketchCoords_,n,i),this.sketchPoint_){this.sketchPoint_.getGeometry().setCoordinates(t)}if("Polygon"===n.getType()&&"Polygon"!==this.mode_)this.createOrUpdateCustomSketchLine_(n);else if(this.sketchLineCoords_){this.sketchLine_.getGeometry().setCoordinates(this.sketchLineCoords_)}this.updateSketchFeatures_()}addToDrawing_(t){const e=this.sketchFeature_.getGeometry(),n=this.getMap().getView().getProjection();let i,r;const s=this.mode_;return"LineString"===s||"Circle"===s?(this.finishCoordinate_=t.slice(),r=this.sketchCoords_,r.length>=this.maxPoints_&&(this.freehand_?r.pop():i=!0),r.push(t.slice()),this.geometryFunction_(r,e,n)):"Polygon"===s&&(r=this.sketchCoords_[0],r.length>=this.maxPoints_&&(this.freehand_?r.pop():i=!0),r.push(t.slice()),i&&(this.finishCoordinate_=r[0]),this.geometryFunction_(this.sketchCoords_,e,n)),this.createOrUpdateSketchPoint_(t.slice()),this.updateSketchFeatures_(),i?this.finishDrawing():this.sketchFeature_}removeLastPoints_(t){if(!this.sketchFeature_)return;const e=this.sketchFeature_.getGeometry(),n=this.getMap().getView().getProjection(),i=this.mode_;for(let r=0;r<t;++r){let t;if("LineString"===i||"Circle"===i){if(t=this.sketchCoords_,t.splice(-2,1),t.length>=2){this.finishCoordinate_=t[t.length-2].slice();const e=this.finishCoordinate_.slice();t[t.length-1]=e,this.createOrUpdateSketchPoint_(e)}this.geometryFunction_(t,e,n),"Polygon"===e.getType()&&this.sketchLine_&&this.createOrUpdateCustomSketchLine_(e)}else if("Polygon"===i){t=this.sketchCoords_[0],t.splice(-2,1);const i=this.sketchLine_.getGeometry();if(t.length>=2){const e=t[t.length-2].slice();t[t.length-1]=e,this.createOrUpdateSketchPoint_(e)}i.setCoordinates(t),this.geometryFunction_(this.sketchCoords_,e,n)}if(1===t.length){this.abortDrawing();break}}this.updateSketchFeatures_()}removeLastPoint(){this.removeLastPoints_(1)}finishDrawing(){const t=this.abortDrawing_();if(!t)return null;let e=this.sketchCoords_;const n=t.getGeometry(),i=this.getMap().getView().getProjection();return"LineString"===this.mode_?(e.pop(),this.geometryFunction_(e,n,i)):"Polygon"===this.mode_&&(e[0].pop(),this.geometryFunction_(e,n,i),e=n.getCoordinates()),"MultiPoint"===this.type_?t.setGeometry(new Nf([e])):"MultiLineString"===this.type_?t.setGeometry(new zf([e])):"MultiPolygon"===this.type_&&t.setGeometry(new Gf([e])),this.dispatchEvent(new Wx(Vx,t)),this.features_&&this.features_.push(t),this.source_&&this.source_.addFeature(t),t}abortDrawing_(){this.finishCoordinate_=null;const t=this.sketchFeature_;return this.sketchFeature_=null,this.sketchPoint_=null,this.sketchLine_=null,this.overlay_.getSource().clear(!0),this.deactivateTrace_(),t}abortDrawing(){const t=this.abortDrawing_();t&&this.dispatchEvent(new Wx(Xx,t))}appendCoordinates(t){const e=this.mode_,n=!this.sketchFeature_;let i;if(n&&this.startDrawing_(t[0]),"LineString"===e||"Circle"===e)i=this.sketchCoords_;else{if("Polygon"!==e)return;i=this.sketchCoords_&&this.sketchCoords_.length?this.sketchCoords_[0]:[]}n&&i.shift(),i.pop();for(let e=0;e<t.length;e++)this.addToDrawing_(t[e]);const r=t[t.length-1];this.sketchFeature_=this.addToDrawing_(r),this.modifyDrawing_(r)}extend(t){const e=t.getGeometry();this.sketchFeature_=t,this.sketchCoords_=e.getCoordinates();const n=this.sketchCoords_[this.sketchCoords_.length-1];this.finishCoordinate_=n.slice(),this.sketchCoords_.push(n.slice()),this.sketchPoint_=new kf(new ja(n)),this.updateSketchFeatures_(),this.dispatchEvent(new Wx(Ux,this.sketchFeature_))}updateSketchFeatures_(){const t=[];this.sketchFeature_&&t.push(this.sketchFeature_),this.sketchLine_&&t.push(this.sketchLine_),this.sketchPoint_&&t.push(this.sketchPoint_);const e=this.overlay_.getSource();e.clear(!0),e.addFeatures(t)}updateState_(){const t=this.getMap(),e=this.getActive();t&&e||this.abortDrawing(),this.overlay_.setMap(e?t:null)}},Extent:class extends nh{constructor(t){super(t=t||{}),this.on,this.once,this.un,this.condition_=t.condition?t.condition:ql,this.createCondition_=t.createCondition||this.condition_,this.drag_=t.drag||!1,this.extent_=null,this.pointerHandler_=null,this.pixelTolerance_=void 0!==t.pixelTolerance?t.pixelTolerance:10,this.snappedToVertex_=!1,this.extentFeature_=null,this.vertexFeature_=null,t||(t={}),this.extentOverlay_=new rm({source:new Hm({useSpatialIndex:!1,wrapX:!!t.wrapX}),style:t.boxStyle?t.boxStyle:Yx(),updateWhileAnimating:!0,updateWhileInteracting:!0}),this.vertexOverlay_=new rm({source:new Hm({useSpatialIndex:!1,wrapX:!!t.wrapX}),style:t.pointerStyle?t.pointerStyle:Hx(),updateWhileAnimating:!0,updateWhileInteracting:!0}),t.extent&&this.setExtent(t.extent)}snapToVertex_(t,e){const n=e.getCoordinateFromPixelInternal(t),i=function(t,e){return xs(n,t)-xs(n,e)},r=this.getExtentInternal();if(r){const s=function(t){return[[[t[0],t[1]],[t[0],t[3]]],[[t[0],t[3]],[t[2],t[3]]],[[t[2],t[3]],[t[2],t[1]]],[[t[2],t[1]],[t[0],t[1]]]]}(r);s.sort(i);const o=s[0];let a=gs(n,o);const l=e.getPixelFromCoordinateInternal(a);if(ys(t,l)<=this.pixelTolerance_){const t=e.getPixelFromCoordinateInternal(o[0]),n=e.getPixelFromCoordinateInternal(o[1]),i=_s(l,t),r=_s(l,n),s=Math.sqrt(Math.min(i,r));return this.snappedToVertex_=s<=this.pixelTolerance_,this.snappedToVertex_&&(a=i>r?o[1]:o[0]),a}}return null}handlePointerMove_(t){const e=t.pixel,n=t.map,i=this.drag_&&Ar(this.extent_,t.coordinate);let r=this.snapToVertex_(e,n);return r||!this.createCondition_(t)||i||(r=n.getCoordinateFromPixelInternal(e)),i&&!r?this.getMap().getViewport().classList.add("ol-grab"):this.getMap().getViewport().classList.remove("ol-grab"),r?(this.updatePointerFeature_(r),!0):(this.noVertexFeature_(),!1)}createOrUpdateExtentFeature_(t){let e=this.extentFeature_;return e?t?e.setGeometry(rl(t)):e.setGeometry(void 0):(e=new kf(t?rl(t):{}),this.extentFeature_=e,this.extentOverlay_.getSource().addFeature(e)),e}updatePointerFeature_(t,e=!0){let n=this.vertexFeature_;if(e&&!n&&(n=new kf(new ja(t)),this.vertexFeature_=n,this.vertexOverlay_.getSource().addFeature(n)),n){n.getGeometry().setCoordinates(t)}return n}noVertexFeature_(){this.vertexFeature_&&(this.vertexOverlay_.getSource().removeFeature(this.vertexFeature_),this.vertexFeature_=null)}handleEvent(t){if(!t.originalEvent||!this.condition_(t))return this.noVertexFeature_(),!0;let e=this.handlingDownUpSequence;return t.type!=Mi.POINTERMOVE||this.handlingDownUpSequence||(e=this.handlePointerMove_(t)),super.handleEvent(t),!e}handleDownEvent(t){const e=t.pixel,n=t.map,i=this.getExtentInternal();let r=this.snapToVertex_(e,n);const s=function(t){let e=null,n=null;return t[0]==i[0]?e=i[2]:t[0]==i[2]&&(e=i[0]),t[1]==i[1]?n=i[3]:t[1]==i[3]&&(n=i[1]),null!==e&&null!==n?[e,n]:null};if(r&&i){const t=r[0]==i[0]||r[0]==i[2]?r[0]:null,e=r[1]==i[1]||r[1]==i[3]?r[1]:null;null!==t&&null!==e?this.pointerHandler_=Jx(s(r)):null!==t?this.pointerHandler_=Qx(s([t,i[1]]),s([t,i[3]])):null!==e&&(this.pointerHandler_=Qx(s([i[0],e]),s([i[2],e])))}else{r=n.getCoordinateFromPixelInternal(e);let s=!1;this.drag_&&Ar(i,r)&&(this.pointerHandler_=function(t,e){return function(n){const i=n[0]-e[0],r=n[1]-e[1];return[t[0]+i,t[1]+r,t[2]+i,t[3]+r]}}(i,r),s=!0),!s&&this.createCondition_(t)&&(this.setExtent([r[0],r[1],r[0],r[1]]),this.pointerHandler_=Jx(r))}return!!this.pointerHandler_}handleDragEvent(t){if(this.pointerHandler_){const e=t.coordinate;this.setExtent(this.pointerHandler_(e)),this.updatePointerFeature_(e,!1)}}handleUpEvent(t){this.pointerHandler_=null;const e=this.getExtentInternal();return e&&0!==Kr(e)||this.setExtent(null),!1}setMap(t){this.extentOverlay_.setMap(t),this.vertexOverlay_.setMap(t),super.setMap(t)}getExtent(){return Zo(this.getExtentInternal(),this.getMap().getView().getProjection())}getExtentInternal(){return this.extent_}setExtent(t){this.extent_=t||null,this.createOrUpdateExtentFeature_(t),this.dispatchEvent(new Kx(this.extent_))}},Interaction:$l,KeyboardPan:yh,KeyboardZoom:xh,Link:class extends $l{constructor(t){let e;super(),e=!0===(t=Object.assign({animate:!0,params:["x","y","z","r","l"],replace:!1,prefix:""},t||{})).animate?{duration:250}:t.animate?t.animate:null,this.animationOptions_=e,this.params_=t.params.reduce((t,e)=>(t[e]=!0,t),{}),this.replace_=t.replace,this.prefix_=t.prefix,this.listenerKeys_=[],this.initial_=!0,this.updateState_=this.updateState_.bind(this),this.trackedCallbacks_={},this.trackedValues_={}}getParamName_(t){return this.prefix_?this.prefix_+t:t}get_(t,e){return t.get(this.getParamName_(e))}set_(t,e,n){e in this.params_&&t.set(this.getParamName_(e),n)}delete_(t,e){e in this.params_&&t.delete(this.getParamName_(e))}setMap(t){const e=this.getMap();super.setMap(t),t!==e&&(e&&this.unregisterListeners_(e),t&&(this.initial_=!0,this.updateState_(),this.registerListeners_(t)))}registerListeners_(t){this.listenerKeys_.push($n(t,Xi,this.updateUrl_,this),$n(t.getLayerGroup(),Vn,this.updateUrl_,this),$n(t,"change:layergroup",this.handleChangeLayerGroup_,this)),this.replace_||addEventListener("popstate",this.updateState_)}unregisterListeners_(t){for(let t=0,e=this.listenerKeys_.length;t<e;++t)Un(this.listenerKeys_[t]);this.listenerKeys_.length=0,this.replace_||removeEventListener("popstate",this.updateState_);const e=new URL(window.location.href),n=e.searchParams;this.delete_(n,"x"),this.delete_(n,"y"),this.delete_(n,"z"),this.delete_(n,"r"),this.delete_(n,"l"),window.history.replaceState(null,"",e)}handleChangeLayerGroup_(){const t=this.getMap();t&&(this.unregisterListeners_(t),this.registerListeners_(t),this.initial_=!0,this.updateUrl_())}updateState_(){const t=new URL(window.location.href).searchParams;for(const e in this.trackedCallbacks_){const n=t.get(e);e in this.trackedCallbacks_&&n!==this.trackedValues_[e]&&(this.trackedValues_[e]=n,this.trackedCallbacks_[e](n))}const e=this.getMap();if(!e)return;const n=e.getView();if(!n||!n.isDef())return;let i=!1;const r={},s=tv(this.get_(t,"z"));"z"in this.params_&&nv(s,n.getZoom())&&(i=!0,r.zoom=s);const o=tv(this.get_(t,"r"));"r"in this.params_&&nv(o,n.getRotation())&&(i=!0,r.rotation=o);const a=[tv(this.get_(t,"x")),tv(this.get_(t,"y"))];var l,h;("x"in this.params_||"y"in this.params_)&&(l=a,h=n.getCenter(),nv(l[0],h[0])||nv(l[1],h[1]))&&(i=!0,r.center=a),i&&(!this.initial_&&this.animationOptions_?n.animate(Object.assign(r,this.animationOptions_)):(r.center&&n.setCenter(r.center),"zoom"in r&&n.setZoom(r.zoom),"rotation"in r&&n.setRotation(r.rotation)));const c=e.getAllLayers(),u=this.get_(t,"l");if("l"in this.params_&&u&&u.length===c.length)for(let t=0,e=c.length;t<e;++t){const e=parseInt(u[t]);if(!isNaN(e)){const n=Boolean(e),i=c[t];i.getVisible()!==n&&i.setVisible(n)}}}track(t,e){this.trackedCallbacks_[t]=e;const n=new URL(window.location.href).searchParams.get(t);return this.trackedValues_[t]=n,n}update(t,e){const n=new URL(window.location.href),i=n.searchParams;null===e?i.delete(t):i.set(t,e),t in this.trackedValues_&&(this.trackedValues_[t]=e),this.updateHistory_(n)}updateUrl_(){const t=this.getMap();if(!t)return;const e=t.getView();if(!e||!e.isDef())return;const n=e.getCenter(),i=e.getZoom(),r=e.getRotation(),s=t.getAllLayers(),o=new Array(s.length);for(let t=0,e=s.length;t<e;++t)o[t]=s[t].getVisible()?"1":"0";const a=new URL(window.location.href),l=a.searchParams;this.set_(l,"x",ev(n[0])),this.set_(l,"y",ev(n[1])),this.set_(l,"z",ev(i)),this.set_(l,"r",ev(r)),this.set_(l,"l",o.join("")),this.updateHistory_(a),this.initial_=!1}updateHistory_(t){t.href!==window.location.href&&(this.initial_||this.replace_?window.history.replaceState(history.state,"",t):window.history.pushState(null,"",t))}},Modify:class extends nh{constructor(t){if(super(t),this.handleSourceAdd_=this.handleSourceAdd_.bind(this),this.handleSourceRemove_=this.handleSourceRemove_.bind(this),this.handleExternalCollectionAdd_=this.handleExternalCollectionAdd_.bind(this),this.handleExternalCollectionRemove_=this.handleExternalCollectionRemove_.bind(this),this.handleFeatureChange_=this.handleFeatureChange_.bind(this),this.on,this.once,this.un,this.condition_=t.condition?t.condition:eh,this.defaultDeleteCondition_=function(t){return function(t){const e=t.originalEvent;return e.altKey&&!(e.metaKey||e.ctrlKey)&&!e.shiftKey}(t)&&Yl(t)},this.deleteCondition_=t.deleteCondition?t.deleteCondition:this.defaultDeleteCondition_,this.insertVertexCondition_=t.insertVertexCondition?t.insertVertexCondition:ql,this.vertexFeature_=null,this.vertexSegments_=null,this.lastCoordinate_=[0,0],this.ignoreNextSingleClick_=!1,this.featuresBeingModified_=null,this.rBush_=new Bm,this.pixelTolerance_=void 0!==t.pixelTolerance?t.pixelTolerance:10,this.snappedToVertex_=!1,this.changingFeature_=!1,this.dragSegments_=[],this.overlay_=new rm({source:new Hm({useSpatialIndex:!1,wrapX:!!t.wrapX}),style:t.style?t.style:dv(),updateWhileAnimating:!0,updateWhileInteracting:!0}),this.SEGMENT_WRITERS_={Point:this.writePointGeometry_.bind(this),LineString:this.writeLineStringGeometry_.bind(this),LinearRing:this.writeLineStringGeometry_.bind(this),Polygon:this.writePolygonGeometry_.bind(this),MultiPoint:this.writeMultiPointGeometry_.bind(this),MultiLineString:this.writeMultiLineStringGeometry_.bind(this),MultiPolygon:this.writeMultiPolygonGeometry_.bind(this),Circle:this.writeCircleGeometry_.bind(this),GeometryCollection:this.writeGeometryCollectionGeometry_.bind(this)},this.source_=null,this.traceSource_=t.traceSource||t.source||null,this.traceCondition_,this.setTrace(t.trace||!1),this.traceState_={active:!1},this.traceSegments_=null,this.hitDetection_=null,this.filterFunctionWasSupplied_=null!=t.filter,this.filter_=t.filter?t.filter:()=>!0,this.coordinatesEqual_=t.sharedVerticesEqual?t.sharedVerticesEqual:ps,!t.features&&!t.source)throw new Error("The modify interaction requires features collection or a source");let e;t.features?(e=t.features.getArray(),t.features.addEventListener(On,this.handleExternalCollectionAdd_),t.features.addEventListener(zn,this.handleExternalCollectionRemove_),this.featuresCollection_=t.features):t.source&&(e=t.source.getFeatures(),t.source.addEventListener(Um,this.handleSourceAdd_),t.source.addEventListener(Wm,this.handleSourceRemove_),this.source_=t.source),e.forEach(t=>{t.addEventListener(Vn,this.handleFeatureChange_),this.filterFunctionWasSupplied_&&t.addEventListener(Nn,this.handleFeatureChange_)}),t.hitDetection&&(this.hitDetection_=t.hitDetection),this.features_=[],e.filter(this.filter_).forEach(t=>this.addFeature_(t)),this.lastPointerEvent_=null,this.delta_=[0,0],this.snapToPointer_=void 0===t.snapToPointer?!this.hitDetection_:t.snapToPointer}setTrace(t){let e;e=t?!0===t?ql:t:Kl,this.traceCondition_=e}addFeature_(t){this.features_.push(t);const e=t.getGeometry();if(e){const n=this.SEGMENT_WRITERS_[e.getType()];n&&n(t,e)}const n=this.getMap();n&&n.isRendered()&&this.getActive()&&this.handlePointerAtPixel_(this.lastCoordinate_)}willModifyFeatures_(t,e){if(!this.featuresBeingModified_){this.featuresBeingModified_=new Ti;const n=this.featuresBeingModified_.getArray();for(let t=0,i=e.length;t<i;++t){const i=e[t].feature;i&&!n.includes(i)&&this.featuresBeingModified_.push(i)}0===this.featuresBeingModified_.getLength()?this.featuresBeingModified_=null:this.dispatchEvent(new lv(sv,this.featuresBeingModified_,t))}}removeFeature_(t){const e=this.features_.indexOf(t);this.features_.splice(e,1),this.removeFeatureSegmentData_(t),this.vertexFeature_&&0===this.features_.length&&(this.overlay_.getSource().removeFeature(this.vertexFeature_),this.vertexFeature_=null)}removeFeatureSegmentData_(t){const e=this.rBush_,n=[];e.forEach(function(e){t===e.feature&&n.push(e)});for(let t=n.length-1;t>=0;--t){const i=n[t];for(let t=this.dragSegments_.length-1;t>=0;--t)this.dragSegments_[t][0]===i&&this.dragSegments_.splice(t,1);e.remove(i)}}setActive(t){this.vertexFeature_&&!t&&(this.overlay_.getSource().removeFeature(this.vertexFeature_),this.vertexFeature_=null),super.setActive(t)}setMap(t){this.overlay_.setMap(t),super.setMap(t)}getOverlay(){return this.overlay_}handleSourceAdd_(t){const e=t.feature;e&&this.externalAddFeatureHandler_(e)}handleSourceRemove_(t){const e=t.feature;e&&this.externalRemoveFeatureHandler_(e)}handleExternalCollectionAdd_(t){const e=t.element;e&&this.externalAddFeatureHandler_(e)}handleExternalCollectionRemove_(t){const e=t.element;e&&this.externalRemoveFeatureHandler_(e)}externalAddFeatureHandler_(t){t.addEventListener(Vn,this.handleFeatureChange_),this.filterFunctionWasSupplied_&&t.addEventListener(Nn,this.handleFeatureChange_),this.filter_(t)&&this.addFeature_(t)}externalRemoveFeatureHandler_(t){t.removeEventListener(Vn,this.handleFeatureChange_),this.filterFunctionWasSupplied_&&t.removeEventListener(Nn,this.handleFeatureChange_),this.removeFeature_(t)}handleFeatureChange_(t){if(!this.changingFeature_){const e=t.target;this.removeFeature_(e),this.filter_(e)&&this.addFeature_(e)}}writePointGeometry_(t,e){const n=e.getCoordinates(),i={feature:t,geometry:e,segment:[n,n]};this.rBush_.insert(e.getExtent(),i)}writeMultiPointGeometry_(t,e){const n=e.getCoordinates();for(let i=0,r=n.length;i<r;++i){const r=n[i],s={feature:t,geometry:e,depth:[i],index:i,segment:[r,r]};this.rBush_.insert(e.getExtent(),s)}}writeLineStringGeometry_(t,e){const n=e.getCoordinates();for(let i=0,r=n.length-1;i<r;++i){const r=n.slice(i,i+2),s={feature:t,geometry:e,index:i,segment:r};this.rBush_.insert(Mr(r),s)}}writeMultiLineStringGeometry_(t,e){const n=e.getCoordinates();for(let i=0,r=n.length;i<r;++i){const r=n[i];for(let n=0,s=r.length-1;n<s;++n){const s=r.slice(n,n+2),o={feature:t,geometry:e,depth:[i],index:n,segment:s};this.rBush_.insert(Mr(s),o)}}}writePolygonGeometry_(t,e){const n=e.getCoordinates();for(let i=0,r=n.length;i<r;++i){const r=n[i];for(let n=0,s=r.length-1;n<s;++n){const s=r.slice(n,n+2),o={feature:t,geometry:e,depth:[i],index:n,segment:s};this.rBush_.insert(Mr(s),o)}}}writeMultiPolygonGeometry_(t,e){const n=e.getCoordinates();for(let i=0,r=n.length;i<r;++i){const r=n[i];for(let n=0,s=r.length;n<s;++n){const s=r[n];for(let r=0,o=s.length-1;r<o;++r){const o=s.slice(r,r+2),a={feature:t,geometry:e,depth:[n,i],index:r,segment:o};this.rBush_.insert(Mr(o),a)}}}}writeCircleGeometry_(t,e){const n=e.getCenter(),i={feature:t,geometry:e,index:0,segment:[n,n]},r={feature:t,geometry:e,index:1,segment:[n,n]},s=[i,r];i.featureSegments=s,r.featureSegments=s,this.rBush_.insert($r(n),i);let o=e;const a=Xo();if(a&&this.getMap()){const t=this.getMap().getView().getProjection();o=o.clone().transform(a,t),o=sl(o).transform(t,a)}this.rBush_.insert(o.getExtent(),r)}writeGeometryCollectionGeometry_(t,e){const n=e.getGeometriesArray();for(let e=0;e<n.length;++e){const i=n[e];(0,this.SEGMENT_WRITERS_[i.getType()])(t,i)}}createOrUpdateVertexFeature_(t,e,n,i){let r=this.vertexFeature_;if(r){r.getGeometry().setCoordinates(t)}else r=new kf(new ja(t)),this.vertexFeature_=r,this.overlay_.getSource().addFeature(r);return r.set("features",e),r.set("geometries",n),r.set("existing",i),r}handleEvent(t){if(!t.originalEvent)return!0;let e;return this.lastPointerEvent_=t,t.map.getView().getInteracting()||t.type!=Mi.POINTERMOVE||this.handlingDownUpSequence||this.handlePointerMove_(t),this.vertexFeature_&&this.deleteCondition_(t)&&(e=!(t.type!=Mi.SINGLECLICK||!this.ignoreNextSingleClick_)||this.removePoint()),t.type==Mi.SINGLECLICK&&(this.ignoreNextSingleClick_=!1),super.handleEvent(t)&&!e}findInsertVerticesAndUpdateDragSegments_(t){this.handlePointerAtPixel_(t),this.dragSegments_.length=0,this.featuresBeingModified_=null;if(!this.vertexFeature_)return;const e=this.getMap().getView().getProjection(),n=[],i=this.vertexFeature_.getGeometry().getCoordinates(),r=Mr([i]),s=this.rBush_.getInExtent(r),o={};s.sort(hv);for(let r=0,a=s.length;r<a;++r){const a=s[r],l=a.segment;let h=wi(a.geometry);const c=a.depth;if(c&&(h+="-"+c.join("-")),o[h]||(o[h]=new Array(2)),"Circle"===a.geometry.getType()&&1===a.index){const n=uv(t,a,e);this.coordinatesEqual_(n,i)&&!o[h][0]&&(this.dragSegments_.push([a,0]),o[h][0]=a);continue}if(!this.coordinatesEqual_(l[0],i)||o[h][0])if(!this.coordinatesEqual_(l[1],i)||o[h][1])!(wi(l)in this.vertexSegments_)||o[h][0]||o[h][1]||n.push(a);else{if(o[h][0]&&0===o[h][0].index){let t=a.geometry.getCoordinates();switch(a.geometry.getType()){case"LineString":case"MultiLineString":continue;case"MultiPolygon":t=t[c[1]];case"Polygon":if(a.index!==t[c[0]].length-2)continue}}this.dragSegments_.push([a,1]),o[h][1]=a}else this.dragSegments_.push([a,0]),o[h][0]=a}return n}deactivateTrace_(){this.traceState_={active:!1}}updateTrace_(t){const e=this.traceState_;if(!e.active)return;if(-1===e.targetIndex){if(ys(t.map.getPixelFromCoordinate(e.startCoord),t.pixel)<this.pixelTolerance_)return}const n=Dx(t.coordinate,e,t.map,this.pixelTolerance_);if(-1===e.targetIndex&&Math.sqrt(n.closestTargetDistance)/t.map.getView().getResolution()>this.pixelTolerance_)return;if(e.targetIndex!==n.index){if(-1!==e.targetIndex){const t=e.targets[e.targetIndex];this.removeTracedCoordinates_(t.startIndex,t.endIndex)}else for(const t of this.traceSegments_){const e=t[0],n=e.geometry,i=t[1],r=n.getCoordinates();av(r,n.getType(),e.depth).splice(e.index+i,1),n.setCoordinates(r),0===i&&(e.index-=1)}const t=e.targets[n.index];this.addTracedCoordinates_(t,t.startIndex,n.endIndex)}else{const t=e.targets[e.targetIndex];this.addOrRemoveTracedCoordinates_(t,n.endIndex)}e.targetIndex=n.index;e.targets[e.targetIndex].endIndex=n.endIndex}getTraceCandidates_(t){const e=this.getMap(),n=this.pixelTolerance_,i=Mr([e.getCoordinateFromPixel([t.pixel[0]-n,t.pixel[1]+n]),e.getCoordinateFromPixel([t.pixel[0]+n,t.pixel[1]-n])]);return this.traceSource_.getFeaturesInExtent(i)}toggleTraceState_(t){if(!this.traceSource_||!this.traceCondition_(t))return;if(this.traceState_.active)return this.deactivateTrace_(),void(this.traceSegments_=null);const e=this.getTraceCandidates_(t);if(0===e.length)return;const n=Ox(t.coordinate,e);n.length&&(this.traceState_={active:!0,startCoord:t.coordinate.slice(),targets:n,targetIndex:-1})}addOrRemoveTracedCoordinates_(t,e){const n=t.startIndex<=t.endIndex;n===t.startIndex<=e?n&&e>t.endIndex||!n&&e<t.endIndex?this.addTracedCoordinates_(t,t.endIndex,e):(n&&e<t.endIndex||!n&&e>t.endIndex)&&this.removeTracedCoordinates_(e,t.endIndex):(this.removeTracedCoordinates_(t.startIndex,t.endIndex),this.addTracedCoordinates_(t,t.startIndex,e))}removeTracedCoordinates_(t,e){if(t===e)return;let n=0;if(t<e){const i=Math.ceil(t);let r=Math.floor(e);r===e&&(r-=1),n=r-i+1}else{const i=Math.floor(t);let r=Math.ceil(e);r===e&&(r+=1),n=i-r+1}if(n>0)for(const t of this.traceSegments_){const e=t[0],i=e.geometry,r=t[1];let s=t[0].index+1;1===r&&(s-=n);const o=i.getCoordinates();av(o,i.getType(),e.depth).splice(s,n),i.setCoordinates(o),1===r&&(e.index-=n)}}addTracedCoordinates_(t,e,n){if(e===n)return;const i=[];if(e<n){const r=Math.ceil(e);let s=Math.floor(n);s===n&&(s-=1);for(let e=r;e<=s;++e)i.push(kx(t.coordinates,e))}else{const r=Math.floor(e);let s=Math.ceil(n);s===n&&(s+=1);for(let e=r;e>=s;--e)i.push(kx(t.coordinates,e))}if(i.length)for(const t of this.traceSegments_){const e=t[0],n=e.geometry,r=t[1],s=e.index+1;0===r&&i.reverse();const o=n.getCoordinates();av(o,n.getType(),e.depth).splice(s,0,...i),n.setCoordinates(o),1===r&&(e.index+=i.length)}}updateGeometry_(t,e){const n=e[0],i=n.depth;let r;const s=n.segment,o=n.geometry,a=e[1],l=o.getStride();for(let e=2;e<l;++e)t[e]=s[a][e];switch(t.length=l,o.getType()){case"Point":r=t,s[0]=t,s[1]=t;break;case"MultiPoint":r=o.getCoordinates(),r[n.index]=t,s[0]=t,s[1]=t;break;case"LineString":r=o.getCoordinates(),r[n.index+a]=t,s[a]=t;break;case"MultiLineString":r=o.getCoordinates(),r[i[0]][n.index+a]=t,s[a]=t;break;case"Polygon":{r=o.getCoordinates();const e=r[i[0]],l=n.index+a;e[l][0]===t[0]&&e[l][1]===t[1]?r=null:(e[l]=t,0===l?e[e.length-1]=t:l===e.length-1&&(e[0]=t)),s[a]=t;break}case"MultiPolygon":{r=o.getCoordinates();const e=r[i[1]][i[0]],l=n.index+a;e[l][0]===t[0]&&e[l][1]===t[1]?r=null:(e[l]=t,0===l?e[e.length-1]=t:l===e.length-1&&(e[0]=t)),s[a]=t;break}case"Circle":const e=o;if(s[0]=t,s[1]=t,0===n.index)this.changingFeature_=!0,e.setCenter(t),this.changingFeature_=!1;else{this.changingFeature_=!0;const n=this.getMap().getView().getProjection();let i=ys(qo(e.getCenter(),n),qo(t,n));const r=Xo();if(r){const t=e.clone().transform(r,n);t.setRadius(i),i=t.transform(n,r).getRadius()}e.setRadius(i),this.changingFeature_=!1}}r&&this.setGeometryCoordinates_(o,r)}handleDragEvent(t){this.ignoreNextSingleClick_=!1,this.willModifyFeatures_(t,this.dragSegments_.map(([t])=>t));const e=[t.coordinate[0]+this.delta_[0],t.coordinate[1]+this.delta_[1]],n=[],i=[],r=this.traceState_.active&&!this.traceSegments_?this.traceState_.startCoord:null;if(r){this.traceSegments_=[];for(const e of this.dragSegments_){ys(gs(r,e[0].segment),r)/t.map.getView().getResolution()<1&&this.traceSegments_.push(e)}}for(let t=0,r=this.dragSegments_.length;t<r;++t){const r=this.dragSegments_[t],s=r[0],o=s.feature;n.includes(o)||n.push(o);const a=s.geometry;i.includes(a)||i.push(a),this.updateGeometry_(e,r)}this.updateTrace_(t),this.createOrUpdateVertexFeature_(e,n,i,!0)}handleDownEvent(t){if(!this.condition_(t))return!1;const e=t.coordinate,n=this.findInsertVerticesAndUpdateDragSegments_(e);if(n?.length&&this.insertVertexCondition_(t)&&(this.willModifyFeatures_(t,n),this.vertexFeature_)){const t=this.vertexFeature_.getGeometry().getCoordinates();for(let e=n.length-1;e>=0;--e)this.insertVertex_(n[e],t);this.ignoreNextSingleClick_=!0}return!!this.vertexFeature_}handleUpEvent(t){for(let e=this.dragSegments_.length-1;e>=0;--e){const n=this.dragSegments_[e][0],i=n.geometry;if("Circle"===i.getType()){const e=i,r=e.getCenter(),s=n.featureSegments[0],o=n.featureSegments[1];s.segment[0]=r,s.segment[1]=r,o.segment[0]=r,o.segment[1]=r,this.rBush_.update($r(r),s);let a=e;const l=Xo();if(l){const e=t.map.getView().getProjection();a=a.clone().transform(l,e),a=sl(a).transform(e,l)}this.rBush_.update(a.getExtent(),o)}else this.rBush_.update(Mr(n.segment),n)}return this.featuresBeingModified_&&(this.toggleTraceState_(t),this.dispatchEvent(new lv(ov,this.featuresBeingModified_,t)),this.featuresBeingModified_=null),!1}handlePointerMove_(t){this.lastCoordinate_=t.coordinate,this.handlePointerAtPixel_(this.lastCoordinate_)}handlePointerAtPixel_(t){const e=this.getMap(),n=e.getPixelFromCoordinate(t),i=e.getView().getProjection(),r=function(e,n){return cv(t,e,i)-cv(t,n,i)};let s,o;if(this.hitDetection_){const t="object"==typeof this.hitDetection_?t=>t===this.hitDetection_:void 0;e.forEachFeatureAtPixel(n,(t,e,n)=>{n&&"Point"===n.getType()&&(n=new ja(Wo(n.getCoordinates(),i)));const r=n||t.getGeometry();if(r&&"Point"===r.getType()&&t instanceof kf&&this.features_.includes(t)){o=r;const e=t.getGeometry().getFlatCoordinates().slice(0,2);s=[{feature:t,geometry:o,segment:[e,e]}]}return!0},{layerFilter:t})}if(!s){const n=Zo(Ir(Ko($r(t,iv),i),e.getView().getResolution()*this.pixelTolerance_,iv),i);s=this.rBush_.getInExtent(n)}if(s&&s.length>0){const a=s.sort(r)[0],l=a.segment;let h=uv(t,a,i);const c=e.getPixelFromCoordinate(h);let u=ys(n,c);if(o||u<=this.pixelTolerance_){const n={};if(n[wi(l)]=!0,this.snapToPointer_||(this.delta_[0]=h[0]-t[0],this.delta_[1]=h[1]-t[1]),"Circle"===a.geometry.getType()&&1===a.index)this.snappedToVertex_=!0,this.createOrUpdateVertexFeature_(h,[a.feature],[a.geometry],this.snappedToVertex_);else{const t=e.getPixelFromCoordinate(l[0]),i=e.getPixelFromCoordinate(l[1]),r=_s(c,t),o=_s(c,i);if(u=Math.sqrt(Math.min(r,o)),this.snappedToVertex_=u<=this.pixelTolerance_,!this.snappedToVertex_&&!this.insertVertexCondition_(this.lastPointerEvent_))return void(this.vertexFeature_&&(this.overlay_.getSource().removeFeature(this.vertexFeature_),this.vertexFeature_=null));this.snappedToVertex_&&(h=r>o?l[1]:l[0]),this.createOrUpdateVertexFeature_(h,[a.feature],[a.geometry],this.snappedToVertex_);const d={};d[wi(a.geometry)]=!0;for(let t=1,e=s.length;t<e;++t){const e=s[t].segment;if(!(this.coordinatesEqual_(l[0],e[0])&&this.coordinatesEqual_(l[1],e[1])||this.coordinatesEqual_(l[0],e[1])&&this.coordinatesEqual_(l[1],e[0])))break;{const i=wi(s[t].geometry);i in d||(d[i]=!0,n[wi(e)]=!0)}}}return void(this.vertexSegments_=n)}}this.vertexFeature_&&(this.overlay_.getSource().removeFeature(this.vertexFeature_),this.vertexFeature_=null)}insertVertex_(t,e){const n=t.segment,i=t.feature,r=t.geometry,s=t.depth,o=t.index;let a;for(;e.length<r.getStride();)e.push(0);switch(r.getType()){case"MultiLineString":case"Polygon":a=r.getCoordinates(),a[s[0]].splice(o+1,0,e);break;case"MultiPolygon":a=r.getCoordinates(),a[s[1]][s[0]].splice(o+1,0,e);break;case"LineString":a=r.getCoordinates(),a.splice(o+1,0,e);break;default:return!1}this.setGeometryCoordinates_(r,a);const l=this.rBush_;l.remove(t),this.updateSegmentIndices_(r,o,s,1);const h={segment:[n[0],e],feature:i,geometry:r,depth:s,index:o};l.insert(Mr(h.segment),h),this.dragSegments_.push([h,1]);const c={segment:[e,n[1]],feature:i,geometry:r,depth:s,index:o+1};return l.insert(Mr(c.segment),c),this.dragSegments_.push([c,0]),!0}updatePointer_(t){return t&&this.findInsertVerticesAndUpdateDragSegments_(t),this.vertexFeature_?.getGeometry().getCoordinates()}getPoint(){const t=this.vertexFeature_?.getGeometry().getCoordinates();return t?Wo(t,this.getMap().getView().getProjection()):null}canRemovePoint(){if(!this.vertexFeature_)return!1;if(this.vertexFeature_.get("geometries").every(t=>"Circle"===t.getType()||t.getType().endsWith("Point")))return!1;const t=this.vertexFeature_.getGeometry().getCoordinates();return this.rBush_.getInExtent(Mr([t])).some(({segment:e})=>this.coordinatesEqual_(e[0],t)||this.coordinatesEqual_(e[1],t))}removePoint(t){if(t&&(t=qo(t,this.getMap().getView().getProjection()),this.updatePointer_(t)),!this.lastPointerEvent_||this.lastPointerEvent_&&this.lastPointerEvent_.type!=Mi.POINTERDRAG){const t=this.lastPointerEvent_;this.willModifyFeatures_(t,this.dragSegments_.map(([t])=>t));const e=this.removeVertex_();return this.featuresBeingModified_&&this.dispatchEvent(new lv(ov,this.featuresBeingModified_,t)),this.featuresBeingModified_=null,e}return!1}removeVertex_(){const t=this.dragSegments_,e={};let n,i,r,s,o,a,l,h,c,u,d,f=!1;for(o=t.length-1;o>=0;--o)r=t[o],u=r[0],d=wi(u.feature),u.depth&&(d+="-"+u.depth.join("-")),d in e||(e[d]={}),0===r[1]?(e[d].right=u,e[d].index=u.index):1==r[1]&&(e[d].left=u,e[d].index=u.index+1);for(d in e){switch(c=e[d].right,l=e[d].left,a=e[d].index,h=a-1,u=void 0!==l?l:c,h<0&&(h=0),s=u.geometry,i=s.getCoordinates(),n=i,f=!1,s.getType()){case"MultiLineString":i[u.depth[0]].length>2&&(i[u.depth[0]].splice(a,1),f=!0);break;case"LineString":i.length>2&&(i.splice(a,1),f=!0);break;case"MultiPolygon":n=n[u.depth[1]];case"Polygon":n=n[u.depth[0]],n.length>4&&(a==n.length-1&&(a=0),n.splice(a,1),f=!0,0===a&&(n.pop(),n.push(n[0]),h=n.length-1))}if(f){this.setGeometryCoordinates_(s,i);const e=[];if(void 0!==l&&(this.rBush_.remove(l),e.push(l.segment[0])),void 0!==c&&(this.rBush_.remove(c),e.push(c.segment[1])),void 0!==l&&void 0!==c){const t={depth:u.depth,feature:u.feature,geometry:u.geometry,index:h,segment:e};this.rBush_.insert(Mr(t.segment),t)}this.updateSegmentIndices_(s,a,u.depth,-1),this.vertexFeature_&&(this.overlay_.getSource().removeFeature(this.vertexFeature_),this.vertexFeature_=null),t.length=0}}return f}canInsertPoint(){if(!this.vertexFeature_)return!1;if(this.vertexFeature_.get("geometries").every(t=>"Circle"===t.getType()||t.getType().endsWith("Point")))return!1;const t=this.vertexFeature_.getGeometry().getCoordinates();return this.rBush_.getInExtent(Mr([t])).some(({segment:e})=>!(this.coordinatesEqual_(e[0],t)||this.coordinatesEqual_(e[1],t)))}insertPoint(t){const e=t?qo(t,this.getMap().getView().getProjection()):this.vertexFeature_?.getGeometry().getCoordinates();if(!e)return!1;return this.findInsertVerticesAndUpdateDragSegments_(e).reduce((t,n)=>t||this.insertVertex_(n,e),!1)}setGeometryCoordinates_(t,e){this.changingFeature_=!0,t.setCoordinates(e),this.changingFeature_=!1}updateSegmentIndices_(t,e,n,i){this.rBush_.forEachInExtent(t.getExtent(),function(r){r.geometry===t&&(void 0===n||void 0===r.depth||hi(r.depth,n))&&r.index>e&&(r.index+=i)})}disposeInternal(){if(super.disposeInternal(),this.featuresCollection_){this.featuresCollection_.removeEventListener(On,this.handleExternalCollectionAdd_),this.featuresCollection_.removeEventListener(zn,this.handleExternalCollectionRemove_);for(const t of this.featuresCollection_.getArray())t.removeEventListener(Vn,this.handleFeatureChange_),this.filterFunctionWasSupplied_&&t.removeEventListener(Nn,this.handleFeatureChange_)}else if(this.source_){this.source_.removeEventListener(Um,this.handleSourceAdd_),this.source_.removeEventListener(Wm,this.handleSourceRemove_);for(const t of this.source_.getFeatures())t.removeEventListener(Vn,this.handleFeatureChange_),this.filterFunctionWasSupplied_&&t.removeEventListener(Nn,this.handleFeatureChange_)}}},MouseWheelZoom:vh,PinchRotate:bh,PinchZoom:wh,Pointer:nh,Select:mv,Snap:class extends nh{constructor(t){t=t||{},super({handleDownEvent:ci,stopDown:ui}),this.on,this.once,this.un,this.source_=t.source?t.source:null,this.vertex_=void 0===t.vertex||t.vertex,this.edge_=void 0===t.edge||t.edge,this.intersection_=void 0!==t.intersection&&t.intersection,this.features_=t.features?t.features:null,this.featuresListenerKeys_=[],this.featureChangeListenerKeys_={},this.indexedFeaturesExtents_={},this.pendingFeatures_={},this.pixelTolerance_=void 0!==t.pixelTolerance?t.pixelTolerance:10,this.rBush_=new Bm,this.snapped_=null,this.segmenters_=Object.assign({},vv,t.segmenters)}addFeature(t,e){e=void 0===e||e;const n=wi(t),i=t.getGeometry();if(i){const e=this.segmenters_[i.getType()];if(e){this.indexedFeaturesExtents_[n]=i.getExtent([1/0,1/0,-1/0,-1/0]);const r=e.call(this.segmenters_,i,this.getMap().getView().getProjection());let s=r.length;for(let e=0;e<s;++e){const n=r[e];Sv[e]=Mr(n),Cv[e]={feature:t,segment:n}}if(this.intersection_)for(let e=0,n=r.length;e<n;++e){const n=r[e];if(1===n.length)continue;const i=Sv[e];for(let o=0,a=e-1;o<a;++o){const e=r[o];if(1===e.length||!as(i,Sv[o]))continue;const a=Wa(n,e);if(!a)continue;const l=[a];Sv[s]=Mr(l),Cv[s++]={feature:t,intersectionFeature:t,segment:l}}const o=this.rBush_.getInExtent(Sv[e]);for(let e=0,i=o.length;e<i;++e){const i=o[e].segment;if(1===i.length)continue;const r=Wa(n,i);if(!r)continue;const a=[r];Sv[s]=Mr(a),Cv[s++]={feature:t,intersectionFeature:o[e].feature,segment:a}}}1===s?this.rBush_.insert(Sv[0],Cv[0]):(Sv.length=s,Cv.length=s,this.rBush_.load(Sv,Cv))}}e&&(this.featureChangeListenerKeys_[n]&&Un(this.featureChangeListenerKeys_[n]),this.featureChangeListenerKeys_[n]=$n(t,Vn,this.handleFeatureChange_,this))}getFeatures_(){let t;return this.features_?t=this.features_:this.source_&&(t=this.source_.getFeatures()),t}areSnapDataEqual_(t,e){return t.segment===e.segment&&t.feature===e.feature}handleEvent(t){const e=this.snapTo(t.pixel,t.coordinate,t.map);return e?(t.coordinate=e.vertex.slice(0,2),t.pixel=e.vertexPixel,this.snapped_&&!this.areSnapDataEqual_(this.snapped_,e)&&this.dispatchEvent(new xv(yv,this.snapped_)),this.snapped_={vertex:t.coordinate,vertexPixel:t.pixel,feature:e.feature,segment:e.segment},this.dispatchEvent(new xv(_v,this.snapped_))):this.snapped_&&(this.dispatchEvent(new xv(yv,this.snapped_)),this.snapped_=null),super.handleEvent(t)}handleFeatureAdd_(t){const e=bv(t);e&&this.addFeature(e)}handleFeatureRemove_(t){const e=bv(t);e&&(this.removeFeature(e),delete this.pendingFeatures_[wi(e)])}handleFeatureChange_(t){const e=t.target;this.handlingDownUpSequence?this.pendingFeatures_[wi(e)]=e:this.updateFeature_(e)}handleUpEvent(t){const e=Object.values(this.pendingFeatures_);if(e.length){for(const t of e)this.updateFeature_(t);jn(this.pendingFeatures_)}return!1}removeFeature(t,e){const n=void 0===e||e,i=wi(t),r=this.indexedFeaturesExtents_[i];if(r){const e=this.rBush_;e.getInExtent(r).forEach(n=>{t!==n.feature&&t!==n.intersectionFeature||e.remove(n)})}n&&(Un(this.featureChangeListenerKeys_[i]),delete this.featureChangeListenerKeys_[i])}setMap(t){const e=this.getMap(),n=this.featuresListenerKeys_;let i=this.getFeatures_();if(Array.isArray(i)||(i=i.getArray()),e&&(n.forEach(Un),n.length=0,this.rBush_.clear(),Object.values(this.featureChangeListenerKeys_).forEach(Un),this.featureChangeListenerKeys_={}),super.setMap(t),t){this.features_?n.push($n(this.features_,On,this.handleFeatureAdd_,this),$n(this.features_,zn,this.handleFeatureRemove_,this)):this.source_&&n.push($n(this.source_,Um,this.handleFeatureAdd_,this),$n(this.source_,Wm,this.handleFeatureRemove_,this));for(const t of i)this.addFeature(t)}}snapTo(t,e,n){const i=n.getView().getProjection(),r=qo(e,i),s=Zo(Ir(Mr([r]),n.getView().getResolution()*this.pixelTolerance_),i),o=this.rBush_.getInExtent(s),a=o.length;if(0===a)return null;let l,h,c=1/0,u=null;const d=this.pixelTolerance_*this.pixelTolerance_,f=()=>{if(!l)return null;const e=n.getPixelFromCoordinate(l);return _s(t,e)>d?null:{vertex:l,vertexPixel:[Math.round(e[0]),Math.round(e[1])],feature:h,segment:u}};if(this.vertex_||this.intersection_){for(let t=0;t<a;++t){const e=o[t];if("Circle"!==e.feature.getGeometry().getType())for(const t of e.segment){const n=_s(r,qo(t,i));n<c&&(this.intersection_&&e.intersectionFeature||this.vertex_&&!e.intersectionFeature)&&(l=t,c=n,h=e.feature)}}const t=f();if(t)return t}if(this.edge_){for(let t=0;t<a;++t){let e=null;const n=o[t];if("Circle"===n.feature.getGeometry().getType()){let t=n.feature.getGeometry();const s=Xo();s&&(t=t.clone().transform(s,i)),e=fs(r,t)}else{const[t,s]=n.segment;s&&(wv[0]=qo(t,i),wv[1]=qo(s,i),e=gs(r,wv))}if(e){const t=_s(r,e);t<c&&(l=Wo(e,i),u="Circle"===n.feature.getGeometry().getType()?null:n.segment,c=t,h=n.feature)}}const t=f();if(t)return t}return null}updateFeature_(t){this.removeFeature(t,!1),this.addFeature(t,!1)}},Translate:class extends nh{constructor(t){let e;if(super(t=t||{}),this.on,this.once,this.un,this.lastCoordinate_=null,this.startCoordinate_=null,this.features_=void 0!==t.features?t.features:null,t.layers&&!this.features_)if("function"==typeof t.layers)e=t.layers;else{const n=t.layers;e=function(t){return n.includes(t)}}else e=ci;this.layerFilter_=e,this.filter_=t.filter&&!this.features_?t.filter:ci,this.hitTolerance_=t.hitTolerance?t.hitTolerance:0,this.condition_=t.condition?t.condition:ql,this.lastFeature_=null,this.addChangeListener(Gl,this.handleActiveChanged_)}handleDownEvent(t){if(!t.originalEvent||!this.condition_(t))return!1;if(this.lastFeature_=this.featuresAtPixel_(t.pixel,t.map),!this.lastCoordinate_&&this.lastFeature_){this.startCoordinate_=t.coordinate,this.lastCoordinate_=t.coordinate,this.handleMoveEvent(t);const e=this.features_||new Ti([this.lastFeature_]);return this.dispatchEvent(new Rv(Ev,e,t.coordinate,this.startCoordinate_,t)),!0}return!1}handleUpEvent(t){if(this.lastCoordinate_){this.lastCoordinate_=null,this.handleMoveEvent(t);const e=this.features_||new Ti([this.lastFeature_]);return this.dispatchEvent(new Rv(Tv,e,t.coordinate,this.startCoordinate_,t)),this.startCoordinate_=null,!0}return!1}handleDragEvent(t){if(this.lastCoordinate_){const e=t.coordinate,n=t.map.getView().getProjection(),i=qo(e,n),r=qo(this.lastCoordinate_,n),s=i[0]-r[0],o=i[1]-r[1],a=this.features_||new Ti([this.lastFeature_]),l=Xo();a.forEach(function(t){const e=t.getGeometry();l?(e.transform(l,n),e.translate(s,o),e.transform(n,l)):e.translate(s,o),t.setGeometry(e)}),this.lastCoordinate_=e,this.dispatchEvent(new Rv(Pv,a,e,this.startCoordinate_,t))}}handleMoveEvent(t){const e=t.map.getViewport();this.featuresAtPixel_(t.pixel,t.map)?(e.classList.remove(this.lastCoordinate_?"ol-grab":"ol-grabbing"),e.classList.add(this.lastCoordinate_?"ol-grabbing":"ol-grab")):e.classList.remove("ol-grab","ol-grabbing")}featuresAtPixel_(t,e){return e.forEachFeatureAtPixel(t,(t,e)=>{if(t instanceof kf&&this.filter_(t,e)&&(!this.features_||this.features_.getArray().includes(t)))return t},{layerFilter:this.layerFilter_,hitTolerance:this.hitTolerance_})}getHitTolerance(){return this.hitTolerance_}setHitTolerance(t){this.hitTolerance_=t}setMap(t){const e=this.getMap();super.setMap(t),this.updateState_(e)}handleActiveChanged_(){this.updateState_(null)}updateState_(t){let e=this.getMap();const n=this.getActive();if((!e||!n)&&(e=e||t,e)){e.getViewport().classList.remove("ol-grab","ol-grabbing")}}},defaults:Sh});const Mv="http://www.w3.org/2001/XMLSchema-instance";function Iv(t,e){return Yv().createElementNS(t,e)}function kv(t,e){return Lv(t,e,[]).join("")}function Lv(t,e,n){if(t.nodeType==Node.CDATA_SECTION_NODE||t.nodeType==Node.TEXT_NODE)n.push(t.nodeValue);else{let i;for(i=t.firstChild;i;i=i.nextSibling)Lv(i,e,n)}return n}function Av(t){return"documentElement"in t}function Dv(t){return(new DOMParser).parseFromString(t,"application/xml")}function Ov(t,e){return function(n,i){const r=t.call(e??this,n,i);if(void 0!==r){li(i[i.length-1],r)}}}function zv(t,e){return function(n,i){const r=t.call(e??this,n,i);if(void 0!==r){i[i.length-1].push(r)}}}function Nv(t,e){return function(e,n){const i=t.call(this,e,n);void 0!==i&&(n[n.length-1]=i)}}function jv(t,e,n){return function(n,i){const r=t.call(this,n,i);if(void 0!==r){i[i.length-1][void 0!==e?e:n.localName]=r}}}function Gv(t,e){return function(e,n,i){t.call(this,e,n,i);i[i.length-1].node.appendChild(e)}}function $v(t,e){return function(e,n,i){const r=n[n.length-1].node;let s=t;void 0===s&&(s=i);return Iv(r.namespaceURI,s)}}const Bv=$v();function Uv(t,e){const n=e.length,i=new Array(n);for(let r=0;r<n;++r)i[r]=t[e[r]];return i}function Vv(t,e,n){let i,r;for(n=void 0!==n?n:{},i=0,r=t.length;i<r;++i)n[t[i]]=e;return n}function Xv(t,e,n,i){let r;for(r=e.firstElementChild;r;r=r.nextElementSibling){const e=t[r.namespaceURI];if(void 0!==e){const t=e[r.localName];void 0!==t&&t.call(i,r,n)}}}function Wv(t,e,n,i,r){return i.push(t),Xv(e,n,i,r),i.pop()}function qv(t,e,n,i,r,s,o){return r.push(t),function(t,e,n,i,r,s){const o=(void 0!==r?r:n).length;let a,l;for(let h=0;h<o;++h)a=n[h],void 0!==a&&(l=e.call(s,a,i,void 0!==r?r[h]:void 0),void 0!==l&&t[l.namespaceURI][l.localName].call(s,l,a,i))}(e,n,i,r,s,o),r.pop()}let Zv,Kv;function Yv(){return void 0===Kv&&"undefined"!=typeof document&&(Kv=document.implementation.createDocument("","",null)),Kv}class Hv extends Xf{constructor(){super(),this.xmlSerializer_=(void 0===Zv&&"undefined"!=typeof XMLSerializer&&(Zv=new XMLSerializer),Zv)}getType(){return"xml"}readFeature(t,e){if(!t)return null;if("string"==typeof t){const n=Dv(t);return this.readFeatureFromDocument(n,e)}return Av(t)?this.readFeatureFromDocument(t,e):this.readFeatureFromNode(t,e)}readFeatureFromDocument(t,e){const n=this.readFeaturesFromDocument(t,e);return n.length>0?n[0]:null}readFeatureFromNode(t,e){return null}readFeatures(t,e){if(!t)return[];if("string"==typeof t){const n=Dv(t);return this.readFeaturesFromDocument(n,e)}return Av(t)?this.readFeaturesFromDocument(t,e):this.readFeaturesFromNode(t,e)}readFeaturesFromDocument(t,e){const n=[];for(let i=t.firstChild;i;i=i.nextSibling)i.nodeType==Node.ELEMENT_NODE&&li(n,this.readFeaturesFromNode(i,e));return n}readFeaturesFromNode(t,e){return vi()}readGeometry(t,e){if(!t)return null;if("string"==typeof t){const n=Dv(t);return this.readGeometryFromDocument(n,e)}return Av(t)?this.readGeometryFromDocument(t,e):this.readGeometryFromNode(t,e)}readGeometryFromDocument(t,e){return null}readGeometryFromNode(t,e){return null}readProjection(t){if(!t)return null;if("string"==typeof t){const e=Dv(t);return this.readProjectionFromDocument(e)}return Av(t)?this.readProjectionFromDocument(t):this.readProjectionFromNode(t)}readProjectionFromDocument(t){return this.dataProjection}readProjectionFromNode(t){return this.dataProjection}writeFeature(t,e){const n=this.writeFeatureNode(t,e);return this.xmlSerializer_.serializeToString(n)}writeFeatureNode(t,e){return null}writeFeatures(t,e){const n=this.writeFeaturesNode(t,e);return this.xmlSerializer_.serializeToString(n)}writeFeaturesNode(t,e){return null}writeGeometry(t,e){const n=this.writeGeometryNode(t,e);return this.xmlSerializer_.serializeToString(n)}writeGeometryNode(t,e){return null}}function Jv(t){return function(t){const e=/^\s*(true|1)|(false|0)\s*$/.exec(t);if(e)return void 0!==e[1]||!1;return}(kv(t,!1))}function Qv(t){return function(t){const e=/^\s*([+\-]?\d*\.?\d+(?:e[+\-]?\d+)?)\s*$/i.exec(t);if(e)return parseFloat(e[1]);return}(kv(t,!1))}function tb(t){return kv(t,!1).trim()}function eb(t,e){ob(t,e?"1":"0")}function nb(t,e){const n=e.toPrecision();t.appendChild(Yv().createTextNode(n))}const ib=/^\s/,rb=/\s$/,sb=/(\n|\t|\r|<|&| {2})/;function ob(t,e){"string"==typeof e&&(ib.test(e)||rb.test(e)||sb.test(e))?e.split("]]>").forEach((e,n,i)=>{n<i.length-1&&(e+="]]"),n>0&&(e=">"+e),function(t,e){t.appendChild(Yv().createCDATASection(e))}(t,e)}):t.appendChild(Yv().createTextNode(e))}const ab=["http://www.google.com/kml/ext/2.2"],lb=[null,"http://earth.google.com/kml/2.0","http://earth.google.com/kml/2.1","http://earth.google.com/kml/2.2","http://www.opengis.net/kml/2.2"],hb={fraction:"fraction",pixels:"pixels",insetPixels:"pixels"},cb=Vv(lb,{ExtendedData:fw,Region:gw,MultiGeometry:jv(rw,"geometry"),LineString:jv(ew,"geometry"),LinearRing:jv(nw,"geometry"),Point:jv(sw,"geometry"),Polygon:jv(aw,"geometry"),Style:jv(hw),StyleMap:function(t,e){const n=$b.call(this,t,e);if(!n)return;const i=e[e.length-1];if(Array.isArray(n))i.Style=n;else{if("string"!=typeof n)throw new Error("`styleMapValue` has an unknown type");i.styleUrl=n}},address:jv(tb),description:jv(tb),name:jv(tb),open:jv(Jv),phoneNumber:jv(tb),styleUrl:jv(Nb),visibility:jv(Jv)},Vv(ab,{MultiTrack:jv(function(t,e){const n=Wv([],Zb,t,e);if(!n)return;return new zf(n)},"geometry"),Track:jv(Yb,"geometry")})),ub=Vv(lb,{ExtendedData:fw,Region:gw,Link:function(t,e){Xv(db,t,e)},address:jv(tb),description:jv(tb),name:jv(tb),open:jv(Jv),phoneNumber:jv(tb),visibility:jv(Jv)}),db=Vv(lb,{href:jv(zb)}),fb=Vv(lb,{Altitude:jv(Qv),Longitude:jv(Qv),Latitude:jv(Qv),Tilt:jv(Qv),AltitudeMode:jv(tb),Heading:jv(Qv),Roll:jv(Qv)}),gb=Vv(lb,{LatLonAltBox:function(t,e){const n=Wv({},_w,t,e);if(!n)return;const i=e[e.length-1],r=[parseFloat(n.west),parseFloat(n.south),parseFloat(n.east),parseFloat(n.north)];i.extent=r,i.altitudeMode=n.altitudeMode,i.minAltitude=parseFloat(n.minAltitude),i.maxAltitude=parseFloat(n.maxAltitude)},Lod:function(t,e){const n=Wv({},yw,t,e);if(!n)return;const i=e[e.length-1];i.minLodPixels=parseFloat(n.minLodPixels),i.maxLodPixels=parseFloat(n.maxLodPixels),i.minFadeExtent=parseFloat(n.minFadeExtent),i.maxFadeExtent=parseFloat(n.maxFadeExtent)}}),pb=Vv(lb,["Document","Placemark"]),mb=Vv(lb,{Document:Gv(function(t,e,n){qv({node:t},Sw,Cw,e,n,void 0,this)}),Placemark:Gv(Zw)});let _b,yb,xb,vb,bb,wb,Sb,Cb,Eb,Pb=null,Tb=null,Rb=null,Fb=null,Mb=null,Ib=null;function kb(t){return 32/Math.min(t[0],t[1])}function Lb(t){return t}function Ab(t,e,n){return Array.isArray(t)?t:"string"==typeof t?Ab(n[t],e,n):e}function Db(t){const e=kv(t,!1),n=/^\s*#?\s*([0-9A-Fa-f]{8})\s*$/.exec(e);if(n){const t=n[1];return[parseInt(t.substr(6,2),16),parseInt(t.substr(4,2),16),parseInt(t.substr(2,2),16),parseInt(t.substr(0,2),16)/255]}}function Ob(t){let e=kv(t,!1);const n=[];e=e.replace(/\s*,\s*/g,",");const i=/^\s*([+\-]?\d*\.?\d+(?:e[+\-]?\d+)?),([+\-]?\d*\.?\d+(?:e[+\-]?\d+)?)(?:\s+|,|$)(?:([+\-]?\d*\.?\d+(?:e[+\-]?\d+)?)(?:\s+|$))?\s*/i;let r;for(;r=i.exec(e);){const t=parseFloat(r[1]),i=parseFloat(r[2]),s=r[3]?parseFloat(r[3]):0;n.push(t,i,s),e=e.substr(r[0].length)}if(""===e)return n}function zb(t){const e=kv(t,!1).trim();let n=t.baseURI;if(n&&"about:blank"!=n||(n=window.location.href),n){return new URL(e,n).href}return e}function Nb(t){const e=kv(t,!1).trim().replace(/^(?!.*#)/,"#");let n=t.baseURI;if(n&&"about:blank"!=n||(n=window.location.href),n){return new URL(e,n).href}return e}function jb(t){return Qv(t)}const Gb=Vv(lb,{Pair:function(t,e){const n=Wv({},pw,t,e,this);if(!n)return;const i=n.key;if(i&&"normal"==i){const t=n.styleUrl;t&&(e[e.length-1]=t);const i=n.Style;i&&(e[e.length-1]=i)}}});function $b(t,e){return Wv(void 0,Gb,t,e,this)}const Bb=Vv(lb,{Icon:jv(function(t,e){const n=Wv({},Hb,t,e);if(n)return n;return null}),color:jv(Db),heading:jv(Qv),hotSpot:jv(function(t){const e=t.getAttribute("xunits"),n=t.getAttribute("yunits");let i;return i="insetPixels"!==e?"insetPixels"!==n?"bottom-left":"top-left":"insetPixels"!==n?"bottom-right":"top-right",{x:parseFloat(t.getAttribute("x")),xunits:hb[e],y:parseFloat(t.getAttribute("y")),yunits:hb[n],origin:i}}),scale:jv(jb)});const Ub=Vv(lb,{color:jv(Db),scale:jv(jb)});const Vb=Vv(lb,{color:jv(Db),width:jv(Qv)});const Xb=Vv(lb,{color:jv(Db),fill:jv(Jv),outline:jv(Jv)});const Wb=Vv(lb,{coordinates:Nv(Ob)});function qb(t,e){return Wv(null,Wb,t,e)}const Zb=Vv(ab,{Track:zv(Yb)});const Kb=Vv(lb,{when:function(t,e){const n=e[e.length-1].whens,i=kv(t,!1),r=Date.parse(i);n.push(isNaN(r)?0:r)}},Vv(ab,{coord:function(t,e){const n=e[e.length-1].coordinates,i=kv(t,!1),r=/^\s*([+\-]?\d+(?:\.\d*)?(?:e[+\-]?\d*)?)\s+([+\-]?\d+(?:\.\d*)?(?:e[+\-]?\d*)?)\s+([+\-]?\d+(?:\.\d*)?(?:e[+\-]?\d*)?)\s*$/i.exec(i);if(r){const t=parseFloat(r[1]),e=parseFloat(r[2]),i=parseFloat(r[3]);n.push([t,e,i])}else n.push([])}}));function Yb(t,e){const n=Wv({coordinates:[],whens:[]},Kb,t,e);if(!n)return;const i=[],r=n.coordinates,s=n.whens;for(let t=0,e=Math.min(r.length,s.length);t<e;++t)3==r[t].length&&i.push(r[t][0],r[t][1],r[t][2],s[t]);return new Of(i,"XYZM")}const Hb=Vv(lb,{href:jv(zb)},Vv(ab,{x:jv(Qv),y:jv(Qv),w:jv(Qv),h:jv(Qv)}));const Jb=Vv(lb,{coordinates:Nv(Ob)});function Qb(t,e){return Wv(null,Jb,t,e)}const tw=Vv(lb,{extrude:jv(Jv),tessellate:jv(Jv),altitudeMode:jv(tb)});function ew(t,e){const n=Wv({},tw,t,e),i=Qb(t,e);if(i){const t=new Of(i,"XYZ");return t.setProperties(n,!0),t}}function nw(t,e){const n=Wv({},tw,t,e),i=Qb(t,e);if(i){const t=new il(i,"XYZ",[i.length]);return t.setProperties(n,!0),t}}const iw=Vv(lb,{LineString:zv(ew),LinearRing:zv(nw),MultiGeometry:zv(rw),Point:zv(sw),Polygon:zv(aw)});function rw(t,e){const n=Wv([],iw,t,e);if(!n)return null;if(0===n.length)return new Uf(n);let i,r=!0;const s=n[0].getType();let o;for(let t=1,e=n.length;t<e;++t)if(o=n[t],o.getType()!=s){r=!1;break}if(r){let t,e;if("Point"==s){const r=n[0];t=r.getLayout(),e=r.getFlatCoordinates();for(let t=1,i=n.length;t<i;++t)o=n[t],li(e,o.getFlatCoordinates());i=new Nf(e,t),cw(i,n)}else if("LineString"==s)i=new zf(n),cw(i,n);else if("Polygon"==s)i=new Gf(n),cw(i,n);else{if("GeometryCollection"!=s&&!s.startsWith("Multi"))throw new Error("Unknown geometry type found");i=new Uf(n)}}else i=new Uf(n);return i}function sw(t,e){const n=Wv({},tw,t,e),i=Qb(t,e);if(i){const t=new ja(i,"XYZ");return t.setProperties(n,!0),t}}const ow=Vv(lb,{innerBoundaryIs:function(t,e){const n=Wv([],xw,t,e);if(n.length>0){e[e.length-1].push(...n)}},outerBoundaryIs:function(t,e){const n=Wv(void 0,vw,t,e);if(n){e[e.length-1][0]=n}}});function aw(t,e){const n=Wv({},tw,t,e),i=Wv([null],ow,t,e);if(i&&i[0]){const t=i[0],e=[t.length];for(let n=1,r=i.length;n<r;++n)li(t,i[n]),e.push(t.length);const r=new il(t,"XYZ",e);return r.setProperties(n,!0),r}}const lw=Vv(lb,{IconStyle:function(t,e){const n=Wv({},Bb,t,e);if(!n)return;const i=e[e.length-1],r="Icon"in n?n.Icon:{},s=!("Icon"in n)||Object.keys(r).length>0;let o;const a=r.href;let l,h,c;a?o=a:s&&(o=wb);let u="bottom-left";const d=n.hotSpot;let f;d?(l=[d.x,d.y],h=d.xunits,c=d.yunits,u=d.origin):/^https?:\/\/maps\.(?:google|gstatic)\.com\//.test(o)&&(o.includes("pushpin")?(l=yb,h=xb,c=vb):o.includes("arrow-reverse")?(l=[54,42],h=xb,c=vb):o.includes("paddle")&&(l=[32,1],h=xb,c=vb));const g=r.x,p=r.y;let m;void 0!==g&&void 0!==p&&(f=[g,p]);const _=r.w,y=r.h;let x;void 0!==_&&void 0!==y&&(m=[_,y]);const v=n.heading;void 0!==v&&(x=gr(v));const b=n.scale,w=n.color;if(s){o==wb&&(m=bb);const t=new Vd({anchor:l,anchorOrigin:u,anchorXUnits:h,anchorYUnits:c,crossOrigin:this.crossOrigin_,referrerPolicy:this.referrerPolicy_,offset:f,offsetOrigin:"bottom-left",rotation:x,scale:b,size:m,src:this.iconUrlFunction_(o),color:w}),e=t.getScaleArray()[0],n=t.getSize();if(null===n){const n=t.getImageState();if(n===rd||n===sd){const i=function(){const n=t.getImageState();if(n!==rd&&n!==sd){const n=t.getSize();if(n&&2==n.length){const i=kb(n);t.setScale(e*i)}t.unlistenImageChange(i)}};t.listenImageChange(i),n===rd&&t.load()}}else if(2==n.length){const i=kb(n);t.setScale(e*i)}i.imageStyle=t}else i.imageStyle=Sb},LabelStyle:function(t,e){const n=Wv({},Ub,t,e);if(!n)return;const i=e[e.length-1],r=new Hd({fill:new Bd({color:"color"in n?n.color:_b}),scale:n.scale});i.textStyle=r},LineStyle:function(t,e){const n=Wv({},Vb,t,e);if(!n)return;const i=e[e.length-1],r=new Xd({color:"color"in n?n.color:_b,width:"width"in n?n.width:1});i.strokeStyle=r},PolyStyle:function(t,e){const n=Wv({},Xb,t,e);if(!n)return;const i=e[e.length-1],r=new Bd({color:"color"in n?n.color:_b});i.fillStyle=r;const s=n.fill;void 0!==s&&(i.fill=s);const o=n.outline;void 0!==o&&(i.outline=o)}});function hw(t,e){const n=Wv({},lw,t,e,this);if(!n)return null;let i="fillStyle"in n?n.fillStyle:Pb;const r=n.fill;let s;void 0===r||r||(i=null),"imageStyle"in n?n.imageStyle!=Sb&&(s=n.imageStyle):s=Tb;const o="textStyle"in n?n.textStyle:Fb,a="strokeStyle"in n?n.strokeStyle:Rb,l=n.outline;return void 0===l||l?[new Wd({fill:i,image:s,stroke:a,text:o,zIndex:void 0})]:[new Wd({geometry:function(t){const e=t.getGeometry(),n=e.getType();if("GeometryCollection"===n){return new Uf(e.getGeometriesArrayRecursive().filter(function(t){const e=t.getType();return"Polygon"!==e&&"MultiPolygon"!==e}))}if("Polygon"!==n&&"MultiPolygon"!==n)return e},fill:i,image:s,stroke:a,text:o,zIndex:void 0}),new Wd({geometry:function(t){const e=t.getGeometry(),n=e.getType();if("GeometryCollection"===n){return new Uf(e.getGeometriesArrayRecursive().filter(function(t){const e=t.getType();return"Polygon"===e||"MultiPolygon"===e}))}if("Polygon"===n||"MultiPolygon"===n)return e},fill:i,stroke:null,zIndex:void 0})]}function cw(t,e){const n=e.length,i=new Array(e.length),r=new Array(e.length),s=new Array(e.length);let o,a,l;o=!1,a=!1,l=!1;for(let t=0;t<n;++t){const n=e[t];i[t]=n.get("extrude"),r[t]=n.get("tessellate"),s[t]=n.get("altitudeMode"),o=o||void 0!==i[t],a=a||void 0!==r[t],l=l||s[t]}o&&t.set("extrude",i),a&&t.set("tessellate",r),l&&t.set("altitudeMode",s)}const uw=Vv(lb,{displayName:jv(tb),value:jv(tb)});const dw=Vv(lb,{Data:function(t,e){const n=t.getAttribute("name");Xv(uw,t,e);const i=e[e.length-1];n&&i.displayName?i[n]={value:i.value,displayName:i.displayName,toString:function(){return i.value}}:null!==n?i[n]=i.value:null!==i.displayName&&(i[i.displayName]=i.value),delete i.value},SchemaData:function(t,e){Xv(mw,t,e)}});function fw(t,e){Xv(dw,t,e)}function gw(t,e){Xv(gb,t,e)}const pw=Vv(lb,{Style:jv(hw),key:jv(tb),styleUrl:jv(Nb)});const mw=Vv(lb,{SimpleData:function(t,e){const n=t.getAttribute("name");if(null!==n){const i=tb(t);e[e.length-1][n]=i}}});const _w=Vv(lb,{altitudeMode:jv(tb),minAltitude:jv(Qv),maxAltitude:jv(Qv),north:jv(Qv),south:jv(Qv),east:jv(Qv),west:jv(Qv)});const yw=Vv(lb,{minLodPixels:jv(Qv),maxLodPixels:jv(Qv),minFadeExtent:jv(Qv),maxFadeExtent:jv(Qv)});const xw=Vv(lb,{LinearRing:zv(qb)});const vw=Vv(lb,{LinearRing:Nv(qb)});function bw(t,e){const n=Mc(e),i=[255*(4==n.length?n[3]:1),n[2],n[1],n[0]];for(let t=0;t<4;++t){const e=Math.floor(i[t]).toString(16);i[t]=1==e.length?"0"+e:e}ob(t,i.join(""))}const ww=Vv(lb,{Data:Gv(function(t,e,n){t.setAttribute("name",e.name);const i={node:t},r=e.value;"object"==typeof r?(null!==r&&r.displayName&&qv(i,ww,Bv,[r.displayName],n,["displayName"]),null!==r&&r.value&&qv(i,ww,Bv,[r.value],n,["value"])):qv(i,ww,Bv,[r],n,["value"])}),value:Gv(function(t,e){ob(t,e)}),displayName:Gv(function(t,e){ob(t,e)})});const Sw=Vv(lb,{Placemark:Gv(Zw)}),Cw=function(t,e,n){return Iv(e[e.length-1].node.namespaceURI,"Placemark")};const Ew=$v("Data");const Pw=Vv(lb,["href"],Vv(ab,["x","y","w","h"])),Tw=Vv(lb,{href:Gv(ob)},Vv(ab,{x:Gv(nb),y:Gv(nb),w:Gv(nb),h:Gv(nb)})),Rw=function(t,e,n){return Iv(ab[0],"gx:"+n)};const Fw=Vv(lb,["scale","heading","Icon","color","hotSpot"]),Mw=Vv(lb,{Icon:Gv(function(t,e,n){const i={node:t},r=n[n.length-1].node;let s=Pw[r.namespaceURI],o=Uv(e,s);qv(i,Tw,Bv,o,n,s),s=Pw[ab[0]],o=Uv(e,s),qv(i,Tw,Rw,o,n,s)}),color:Gv(bw),heading:Gv(nb),hotSpot:Gv(function(t,e){t.setAttribute("x",String(e.x)),t.setAttribute("y",String(e.y)),t.setAttribute("xunits",e.xunits),t.setAttribute("yunits",e.yunits)}),scale:Gv(rS)});const Iw=Vv(lb,["color","scale"]),kw=Vv(lb,{color:Gv(bw),scale:Gv(rS)});const Lw=Vv(lb,["color","width"]),Aw=Vv(lb,{color:Gv(bw),width:Gv(nb)});const Dw={Point:"Point",LineString:"LineString",LinearRing:"LinearRing",Polygon:"Polygon",MultiPoint:"MultiGeometry",MultiLineString:"MultiGeometry",MultiPolygon:"MultiGeometry",GeometryCollection:"MultiGeometry"},Ow=function(t,e,n){if(t){return Iv(e[e.length-1].node.namespaceURI,Dw[t.getType()])}},zw=$v("Point"),Nw=$v("LineString"),jw=$v("LinearRing"),Gw=$v("Polygon"),$w=Vv(lb,{LineString:Gv(Hw),Point:Gv(Hw),Polygon:Gv(nS),GeometryCollection:Gv(Bw)});function Bw(t,e,n){const i={node:t},r=e.getType();let s,o=[];if("GeometryCollection"===r)e.getGeometriesArrayRecursive().forEach(function(t){const e=t.getType();if("MultiPoint"===e)o=o.concat(t.getPoints());else if("MultiLineString"===e)o=o.concat(t.getLineStrings());else if("MultiPolygon"===e)o=o.concat(t.getPolygons());else{if("Point"!==e&&"LineString"!==e&&"Polygon"!==e)throw new Error("Unknown geometry type");o.push(t)}}),s=Ow;else if("MultiPoint"===r)o=e.getPoints(),s=zw;else if("MultiLineString"===r)o=e.getLineStrings(),s=Nw;else{if("MultiPolygon"!==r)throw new Error("Unknown geometry type");o=e.getPolygons(),s=Gw}qv(i,$w,s,o,n)}const Uw=Vv(lb,{LinearRing:Gv(Hw)});function Vw(t,e,n){qv({node:t},Uw,jw,[e],n)}const Xw=Vv(lb,{ExtendedData:Gv(function(t,e,n){const i={node:t},r=e.names,s=e.values,o=r.length;for(let t=0;t<o;t++)qv(i,ww,Ew,[{name:r[t],value:s[t]}],n)}),MultiGeometry:Gv(Bw),LineString:Gv(Hw),LinearRing:Gv(Hw),Point:Gv(Hw),Polygon:Gv(nS),Style:Gv(function(t,e,n){const i={node:t},r={};if(e.pointStyles.length){const t=e.pointStyles[0].getText();t&&(r.LabelStyle=t);const n=e.pointStyles[0].getImage();n&&"function"==typeof n.getSrc&&(r.IconStyle=n)}if(e.lineStyles.length){const t=e.lineStyles[0].getStroke();t&&(r.LineStyle=t)}if(e.polyStyles.length){const t=e.polyStyles[0].getStroke();t&&!r.LineStyle&&(r.LineStyle=t),r.PolyStyle=e.polyStyles[0]}const s=n[n.length-1].node,o=sS[s.namespaceURI],a=Uv(r,o);qv(i,oS,Bv,a,n,o)}),address:Gv(ob),description:Gv(ob),name:Gv(ob),open:Gv(eb),phoneNumber:Gv(ob),styleUrl:Gv(ob),visibility:Gv(eb)}),Ww=Vv(lb,["name","open","visibility","address","phoneNumber","description","styleUrl","Style"]),qw=$v("ExtendedData");function Zw(t,e,n){const i={node:t};e.getId()&&t.setAttribute("id",e.getId());const r=e.getProperties(),s={address:1,description:1,name:1,open:1,phoneNumber:1,styleUrl:1,visibility:1};s[e.getGeometryName()]=1;const o=Object.keys(r||{}).sort().filter(function(t){return!s[t]}),a=e.getStyleFunction();if(a){const t=a(e,0);if(t){const n=Array.isArray(t)?t:[t];let i=n;if(e.getGeometry()&&(i=n.filter(function(t){const n=t.getGeometryFunction()(e);if(n){const t=n.getType();return"GeometryCollection"===t?n.getGeometriesArrayRecursive().filter(function(t){const e=t.getType();return"Point"===e||"MultiPoint"===e}).length:"Point"===t||"MultiPoint"===t}})),this.writeStyles_){let t=n,s=n;e.getGeometry()&&(t=n.filter(function(t){const n=t.getGeometryFunction()(e);if(n){const t=n.getType();return"GeometryCollection"===t?n.getGeometriesArrayRecursive().filter(function(t){const e=t.getType();return"LineString"===e||"MultiLineString"===e}).length:"LineString"===t||"MultiLineString"===t}}),s=n.filter(function(t){const n=t.getGeometryFunction()(e);if(n){const t=n.getType();return"GeometryCollection"===t?n.getGeometriesArrayRecursive().filter(function(t){const e=t.getType();return"Polygon"===e||"MultiPolygon"===e}).length:"Polygon"===t||"MultiPolygon"===t}})),r.Style={pointStyles:i,lineStyles:t,polyStyles:s}}if(i.length&&void 0===r.name){const t=i[0].getText();t&&(r.name=t.getText())}}}const l=n[n.length-1].node,h=Ww[l.namespaceURI],c=Uv(r,h);if(qv(i,Xw,Bv,c,n,h),o.length>0){const t=Uv(r,o);qv(i,Xw,qw,[{names:o,values:t}],n)}const u=n[0];let d=e.getGeometry();d&&(d=Wf(d,!0,u)),qv(i,Xw,Ow,[d],n)}const Kw=Vv(lb,["extrude","tessellate","altitudeMode","coordinates"]),Yw=Vv(lb,{extrude:Gv(eb),tessellate:Gv(eb),altitudeMode:Gv(ob),coordinates:Gv(function(t,e,n){const i=n[n.length-1],r=i.layout,s=i.stride;let o;if("XY"==r||"XYM"==r)o=2;else{if("XYZ"!=r&&"XYZM"!=r)throw new Error("Invalid geometry layout");o=3}const a=e.length;let l="";if(a>0){l+=e[0];for(let t=1;t<o;++t)l+=","+e[t];for(let t=s;t<a;t+=s){l+=" "+e[t];for(let n=1;n<o;++n)l+=","+e[t+n]}}ob(t,l)})});function Hw(t,e,n){const i=e.getFlatCoordinates(),r={node:t};r.layout=e.getLayout(),r.stride=e.getStride();const s=e.getProperties();s.coordinates=i;const o=n[n.length-1].node,a=Kw[o.namespaceURI],l=Uv(s,a);qv(r,Yw,Bv,l,n,a)}const Jw=Vv(lb,["color","fill","outline"]),Qw=Vv(lb,{outerBoundaryIs:Gv(Vw),innerBoundaryIs:Gv(Vw)}),tS=$v("innerBoundaryIs"),eS=$v("outerBoundaryIs");function nS(t,e,n){const i=e.getLinearRings(),r=i.shift(),s={node:t};qv(s,Qw,tS,i,n),qv(s,Qw,eS,[r],n)}const iS=Vv(lb,{color:Gv(bw),fill:Gv(eb),outline:Gv(eb)});function rS(t,e){nb(t,Math.round(1e6*e)/1e6)}const sS=Vv(lb,["IconStyle","LabelStyle","LineStyle","PolyStyle"]),oS=Vv(lb,{IconStyle:Gv(function(t,e,n){const i={node:t},r={},s=e.getSrc(),o=e.getSize(),a=e.getImageSize(),l={href:s};if(o){l.w=o[0],l.h=o[1];const t=e.getAnchor(),n=e.getOrigin();if(n&&a&&0!==n[0]&&n[1]!==o[1]&&(l.x=n[0],l.y=a[1]-(n[1]+o[1])),t&&(t[0]!==o[0]/2||t[1]!==o[1]/2)){const e={x:t[0],xunits:"pixels",y:o[1]-t[1],yunits:"pixels"};r.hotSpot=e}}r.Icon=l;let h=e.getScaleArray()[0],c=o;if(null===c&&(c=bb),2==c.length){h/=kb(c)}1!==h&&(r.scale=h);const u=e.getRotation();0!==u&&(r.heading=u);const d=e.getColor();d&&(r.color=d);const f=n[n.length-1].node,g=Fw[f.namespaceURI],p=Uv(r,g);qv(i,Mw,Bv,p,n,g)}),LabelStyle:Gv(function(t,e,n){const i={node:t},r={},s=e.getFill();s&&(r.color=s.getColor());const o=e.getScale();o&&1!==o&&(r.scale=o);const a=n[n.length-1].node,l=Iw[a.namespaceURI],h=Uv(r,l);qv(i,kw,Bv,h,n,l)}),LineStyle:Gv(function(t,e,n){const i={node:t},r={color:e.getColor(),width:Number(e.getWidth())||1},s=n[n.length-1].node,o=Lw[s.namespaceURI],a=Uv(r,o);qv(i,Aw,Bv,a,n,o)}),PolyStyle:Gv(function(t,e,n){const i={node:t},r=e.getFill(),s=e.getStroke(),o={color:r?r.getColor():void 0,fill:!!r&&void 0,outline:!!s&&void 0},a=n[n.length-1].node,l=Jw[a.namespaceURI],h=Uv(o,l);qv(i,iS,Bv,h,n,l)})});function aS(t,e){return t[0]=e[0],t[1]=e[1],t[4]=e[2],t[5]=e[3],t[12]=e[4],t[13]=e[5],t}const lS=34962,hS=34963,cS=35048,uS=["experimental-webgl","webgl","webkit-3d","moz-webgl"];const dS=35044;class fS{constructor(t,e){this.array_=null,this.type_=t,ir(t===lS||t===hS,"A `WebGLArrayBuffer` must either be of type `ELEMENT_ARRAY_BUFFER` or `ARRAY_BUFFER`"),this.usage_=void 0!==e?e:dS}ofSize(t){return this.array_=new(gS(this.type_))(t),this}fromArray(t){return this.array_=gS(this.type_).from(t),this}fromArrayBuffer(t){return this.array_=new(gS(this.type_))(t),this}getType(){return this.type_}getArray(){return this.array_}setArray(t){const e=gS(this.type_);if(!(t instanceof e))throw new Error(`Expected ${e}`);this.array_=t}getUsage(){return this.usage_}getSize(){return this.array_?this.array_.length:0}}function gS(t){switch(t){case lS:return Float32Array;case hS:return Uint32Array;default:return Float32Array}}var pS="webglcontextlost",mS="webglcontextrestored";class _S{constructor(t){this.gl_=t.webGlContext;const e=this.gl_;this.scaleRatio_=t.scaleRatio||1,this.renderTargetTexture_=e.createTexture(),this.renderTargetTextureSize_=null,this.frameBuffer_=e.createFramebuffer(),this.depthBuffer_=e.createRenderbuffer();const n=e.createShader(e.VERTEX_SHADER);e.shaderSource(n,t.vertexShader||"\n precision mediump float;\n\n attribute vec2 a_position;\n varying vec2 v_texCoord;\n varying vec2 v_screenCoord;\n\n uniform vec2 u_screenSize;\n\n void main() {\n v_texCoord = a_position * 0.5 + 0.5;\n v_screenCoord = v_texCoord * u_screenSize;\n gl_Position = vec4(a_position, 0.0, 1.0);\n }\n"),e.compileShader(n);const i=e.createShader(e.FRAGMENT_SHADER);e.shaderSource(i,t.fragmentShader||"\n precision mediump float;\n\n uniform sampler2D u_image;\n uniform float u_opacity;\n\n varying vec2 v_texCoord;\n\n void main() {\n gl_FragColor = texture2D(u_image, v_texCoord) * u_opacity;\n }\n"),e.compileShader(i),this.renderTargetProgram_=e.createProgram(),e.attachShader(this.renderTargetProgram_,n),e.attachShader(this.renderTargetProgram_,i),e.linkProgram(this.renderTargetProgram_),this.renderTargetVerticesBuffer_=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,this.renderTargetVerticesBuffer_),e.bufferData(e.ARRAY_BUFFER,new Float32Array([-1,-1,1,-1,-1,1,1,-1,1,1,-1,1]),e.STATIC_DRAW),this.renderTargetAttribLocation_=e.getAttribLocation(this.renderTargetProgram_,"a_position"),this.renderTargetUniformLocation_=e.getUniformLocation(this.renderTargetProgram_,"u_screenSize"),this.renderTargetOpacityLocation_=e.getUniformLocation(this.renderTargetProgram_,"u_opacity"),this.renderTargetTextureLocation_=e.getUniformLocation(this.renderTargetProgram_,"u_image"),this.uniforms_=[],t.uniforms&&Object.keys(t.uniforms).forEach(n=>{this.uniforms_.push({value:t.uniforms[n],location:e.getUniformLocation(this.renderTargetProgram_,n)})})}getRenderTargetTexture(){return this.renderTargetTexture_}getGL(){return this.gl_}init(t){const e=this.getGL(),n=[e.drawingBufferWidth*this.scaleRatio_,e.drawingBufferHeight*this.scaleRatio_];if(e.bindFramebuffer(e.FRAMEBUFFER,this.getFrameBuffer()),e.bindRenderbuffer(e.RENDERBUFFER,this.getDepthBuffer()),e.viewport(0,0,n[0],n[1]),!this.renderTargetTextureSize_||this.renderTargetTextureSize_[0]!==n[0]||this.renderTargetTextureSize_[1]!==n[1]){this.renderTargetTextureSize_=n;const t=0,i=e.RGBA,r=0,s=e.RGBA,o=e.UNSIGNED_BYTE,a=null;e.bindTexture(e.TEXTURE_2D,this.renderTargetTexture_),e.texImage2D(e.TEXTURE_2D,t,i,n[0],n[1],r,s,o,a),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,this.renderTargetTexture_,0),e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_COMPONENT16,n[0],n[1]),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.RENDERBUFFER,this.depthBuffer_)}}apply(t,e,n,i){const r=this.getGL(),s=t.size;if(r.bindFramebuffer(r.FRAMEBUFFER,e?e.getFrameBuffer():null),r.activeTexture(r.TEXTURE0),r.bindTexture(r.TEXTURE_2D,this.renderTargetTexture_),!e){const e=wi(r.canvas);if(!t.renderTargets[e]){const n=r.getContextAttributes();n&&n.preserveDrawingBuffer&&(r.clearColor(0,0,0,0),r.clearDepth(1),r.clear(r.COLOR_BUFFER_BIT|r.DEPTH_BUFFER_BIT)),t.renderTargets[e]=!0}}r.disable(r.DEPTH_TEST),r.enable(r.BLEND),r.blendFunc(r.ONE,r.ONE_MINUS_SRC_ALPHA),r.viewport(0,0,r.drawingBufferWidth,r.drawingBufferHeight),r.bindBuffer(r.ARRAY_BUFFER,this.renderTargetVerticesBuffer_),r.useProgram(this.renderTargetProgram_),r.enableVertexAttribArray(this.renderTargetAttribLocation_),r.vertexAttribPointer(this.renderTargetAttribLocation_,2,r.FLOAT,!1,0,0),r.uniform2f(this.renderTargetUniformLocation_,s[0],s[1]),r.uniform1i(this.renderTargetTextureLocation_,0);const o=t.layerStatesArray[t.layerIndex].opacity;r.uniform1f(this.renderTargetOpacityLocation_,o),this.applyUniforms(t),n&&n(r,t),r.drawArrays(r.TRIANGLES,0,6),i&&i(r,t)}getFrameBuffer(){return this.frameBuffer_}getDepthBuffer(){return this.depthBuffer_}applyUniforms(t){const e=this.getGL();let n,i=1;this.uniforms_.forEach(function(r){if(n="function"==typeof r.value?r.value(t):r.value,n instanceof HTMLCanvasElement||n instanceof ImageData)r.texture||(r.texture=e.createTexture()),e.activeTexture(e[`TEXTURE${i}`]),e.bindTexture(e.TEXTURE_2D,r.texture),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),n instanceof ImageData?e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,n.width,n.height,0,e.UNSIGNED_BYTE,new Uint8Array(n.data)):e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,n),e.uniform1i(r.location,i++);else if(Array.isArray(n))switch(n.length){case 2:return void e.uniform2f(r.location,n[0],n[1]);case 3:return void e.uniform3f(r.location,n[0],n[1],n[2]);case 4:return void e.uniform4f(r.location,n[0],n[1],n[2],n[3]);default:return}else"number"==typeof n&&e.uniform1f(r.location,n)})}}const yS={PROJECTION_MATRIX:"u_projectionMatrix",INVERT_PROJECTION_MATRIX:"u_invertProjectionMatrix",TIME:"u_time",ZOOM:"u_zoom",RESOLUTION:"u_resolution",ROTATION:"u_rotation",VIEWPORT_SIZE_PX:"u_viewportSizePx",PIXEL_RATIO:"u_pixelRatio",HIT_DETECTION:"u_hitDetection"},xS=5121,vS=5123,bS=5125,wS=5126,SS={};function CS(t){return"shared/"+t}let ES=0;function PS(t){let e=SS[t];if(!e){const n=document.createElement("canvas");n.width=1,n.height=1,n.style.position="absolute",n.style.left="0";const i=function(t,e){e=Object.assign({preserveDrawingBuffer:!0,antialias:!ki},e);const n=uS.length;for(let i=0;i<n;++i)try{const n=t.getContext(uS[i],e);if(n)return n}catch{}return null}(n);e={users:0,context:i},SS[t]=e}return e.users+=1,e.context}class TS extends ii{constructor(t){super(),t=t||{},this.boundHandleWebGLContextLost_=this.handleWebGLContextLost.bind(this),this.boundHandleWebGLContextRestored_=this.handleWebGLContextRestored.bind(this),this.canvasCacheKey_=t.canvasCacheKey?CS(t.canvasCacheKey):function(){const t="unique/"+ES;return ES+=1,t}(),this.gl_=PS(this.canvasCacheKey_),this.bufferCache_={},this.extensionCache_={},this.currentProgram_=null,this.needsToBeRecreated_=!1;const e=this.gl_.canvas;e.addEventListener(pS,this.boundHandleWebGLContextLost_),e.addEventListener(mS,this.boundHandleWebGLContextRestored_),this.offsetRotateMatrix_=[1,0,0,1,0,0],this.offsetScaleMatrix_=[1,0,0,1,0,0],this.tmpMat4_=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],this.uniformLocationsByProgram_={},this.attribLocationsByProgram_={},this.uniforms_=[],t.uniforms&&this.setUniforms(t.uniforms),this.postProcessPasses_=t.postProcesses?t.postProcesses.map(t=>new _S({webGlContext:this.gl_,scaleRatio:t.scaleRatio,vertexShader:t.vertexShader,fragmentShader:t.fragmentShader,uniforms:t.uniforms})):[new _S({webGlContext:this.gl_})],this.shaderCompileErrors_=null,this.startTime_=Date.now(),this.maxAttributeCount_=this.gl_.getParameter(this.gl_.MAX_VERTEX_ATTRIBS)}setUniforms(t){this.uniforms_=[],this.addUniforms(t)}addUniforms(t){for(const e in t)this.uniforms_.push({name:e,value:t[e]})}canvasCacheKeyMatches(t){return this.canvasCacheKey_===CS(t)}getExtension(t){if(t in this.extensionCache_)return this.extensionCache_[t];const e=this.gl_.getExtension(t);return this.extensionCache_[t]=e,e}getInstancedRenderingExtension_(){const t=this.getExtension("ANGLE_instanced_arrays");return ir(!!t,"WebGL extension 'ANGLE_instanced_arrays' is required for vector rendering"),t}bindBuffer(t){const e=this.gl_,n=wi(t);let i=this.bufferCache_[n];if(!i){i={buffer:t,webGlBuffer:e.createBuffer()},this.bufferCache_[n]=i}e.bindBuffer(t.getType(),i.webGlBuffer)}flushBufferData(t){const e=this.gl_;this.bindBuffer(t),e.bufferData(t.getType(),t.getArray(),t.getUsage())}deleteBuffer(t){const e=wi(t);delete this.bufferCache_[e]}disposeInternal(){const t=this.gl_.canvas;t.removeEventListener(pS,this.boundHandleWebGLContextLost_),t.removeEventListener(mS,this.boundHandleWebGLContextRestored_),function(t){const e=SS[t];if(!e)return;if(e.users-=1,e.users>0)return;const n=e.context,i=n.getExtension("WEBGL_lose_context");i&&i.loseContext();const r=n.canvas;r.width=1,r.height=1,delete SS[t]}(this.canvasCacheKey_),delete this.gl_}prepareDraw(t,e,n){const i=this.gl_,r=this.getCanvas(),s=t.size,o=t.pixelRatio;r.width===s[0]*o&&r.height===s[1]*o||(r.width=s[0]*o,r.height=s[1]*o,r.style.width=s[0]+"px",r.style.height=s[1]+"px");for(let e=this.postProcessPasses_.length-1;e>=0;e--)this.postProcessPasses_[e].init(t);i.bindTexture(i.TEXTURE_2D,null),i.clearColor(0,0,0,0),i.depthRange(0,1),i.clearDepth(1),i.clear(i.COLOR_BUFFER_BIT|i.DEPTH_BUFFER_BIT),i.enable(i.BLEND),i.blendFunc(i.ONE,e?i.ZERO:i.ONE_MINUS_SRC_ALPHA),n?(i.enable(i.DEPTH_TEST),i.depthFunc(i.LEQUAL)):i.disable(i.DEPTH_TEST)}bindFrameBuffer(t,e){const n=this.getGL();n.bindFramebuffer(n.FRAMEBUFFER,t),e&&n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,e,0)}bindInitialFrameBuffer(){const t=this.getGL(),e=this.postProcessPasses_[0].getFrameBuffer();t.bindFramebuffer(t.FRAMEBUFFER,e);const n=this.postProcessPasses_[0].getRenderTargetTexture();t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,n,0)}bindTexture(t,e,n){const i=this.gl_;i.activeTexture(i.TEXTURE0+e),i.bindTexture(i.TEXTURE_2D,t),i.uniform1i(this.getUniformLocation(n),e)}bindAttribute(t,e,n){const i=this.getGL();this.bindBuffer(t);const r=this.getAttributeLocation(e);i.enableVertexAttribArray(r),i.vertexAttribPointer(r,n,i.FLOAT,!1,0,0)}prepareDrawToRenderTarget(t,e,n,i){const r=this.gl_,s=e.getSize();r.bindFramebuffer(r.FRAMEBUFFER,e.getFramebuffer()),r.bindRenderbuffer(r.RENDERBUFFER,e.getDepthbuffer()),r.viewport(0,0,s[0],s[1]),r.bindTexture(r.TEXTURE_2D,e.getTexture()),r.clearColor(0,0,0,0),r.depthRange(0,1),r.clearDepth(1),r.clear(r.COLOR_BUFFER_BIT|r.DEPTH_BUFFER_BIT),r.enable(r.BLEND),r.blendFunc(r.ONE,n?r.ZERO:r.ONE_MINUS_SRC_ALPHA),i?(r.enable(r.DEPTH_TEST),r.depthFunc(r.LEQUAL)):r.disable(r.DEPTH_TEST)}drawElements(t,e){const n=this.gl_;this.getExtension("OES_element_index_uint");const i=n.UNSIGNED_INT,r=e-t,s=4*t;n.drawElements(n.TRIANGLES,r,i,s)}drawElementsInstanced(t,e,n){const i=this.gl_;this.getExtension("OES_element_index_uint");const r=this.getInstancedRenderingExtension_(),s=i.UNSIGNED_INT,o=e-t,a=4*t;r.drawElementsInstancedANGLE(i.TRIANGLES,o,s,a,n);for(let t=0;t<this.maxAttributeCount_;t++)r.vertexAttribDivisorANGLE(t,0)}finalizeDraw(t,e,n){for(let i=0,r=this.postProcessPasses_.length;i<r;i++)i===r-1?this.postProcessPasses_[i].apply(t,null,e,n):this.postProcessPasses_[i].apply(t,this.postProcessPasses_[i+1])}getCanvas(){return this.gl_.canvas}getGL(){return this.gl_}applyFrameState(t){const e=t.size,n=t.viewState.rotation,i=t.pixelRatio;this.setUniformFloatValue(yS.TIME,.001*(Date.now()-this.startTime_)),this.setUniformFloatValue(yS.ZOOM,t.viewState.zoom),this.setUniformFloatValue(yS.RESOLUTION,t.viewState.resolution),this.setUniformFloatValue(yS.PIXEL_RATIO,i),this.setUniformFloatVec2(yS.VIEWPORT_SIZE_PX,[e[0],e[1]]),this.setUniformFloatValue(yS.ROTATION,n)}applyHitDetectionUniform(t){const e=this.getUniformLocation(yS.HIT_DETECTION);this.getGL().uniform1i(e,t?1:0),t&&this.setUniformFloatValue(yS.PIXEL_RATIO,.5)}applyUniforms(t){const e=this.gl_;let n,i=0;this.uniforms_.forEach(r=>{if(n="function"==typeof r.value?r.value(t):r.value,n instanceof HTMLCanvasElement||n instanceof HTMLImageElement||n instanceof ImageData||n instanceof WebGLTexture){n instanceof WebGLTexture&&!r.texture?(r.prevValue=void 0,r.texture=n):r.texture||(r.prevValue=void 0,r.texture=e.createTexture()),this.bindTexture(r.texture,i,r.name),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE);const t=!(n instanceof HTMLImageElement)||n.complete;n instanceof WebGLTexture||!t||r.prevValue===n||(r.prevValue=n,e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,n)),i++}else if(Array.isArray(n)&&6===n.length)this.setUniformMatrixValue(r.name,aS(this.tmpMat4_,n));else if(Array.isArray(n)&&n.length<=4)switch(n.length){case 2:return void e.uniform2f(this.getUniformLocation(r.name),n[0],n[1]);case 3:return void e.uniform3f(this.getUniformLocation(r.name),n[0],n[1],n[2]);case 4:return void e.uniform4f(this.getUniformLocation(r.name),n[0],n[1],n[2],n[3]);default:return}else"number"==typeof n&&e.uniform1f(this.getUniformLocation(r.name),n)})}useProgram(t,e){this.disableAllAttributes_();this.gl_.useProgram(t),this.currentProgram_=t,e&&(this.applyFrameState(e),this.applyUniforms(e))}compileShader(t,e){const n=this.gl_,i=n.createShader(e);return n.shaderSource(i,t),n.compileShader(i),i}getProgram(t,e){const n=this.gl_,i=this.compileShader(t,n.FRAGMENT_SHADER),r=this.compileShader(e,n.VERTEX_SHADER),s=n.createProgram();if(n.attachShader(s,i),n.attachShader(s,r),n.linkProgram(s),!n.getShaderParameter(i,n.COMPILE_STATUS)){const t=`Fragment shader compilation failed: ${n.getShaderInfoLog(i)}`;throw new Error(t)}if(n.deleteShader(i),!n.getShaderParameter(r,n.COMPILE_STATUS)){const t=`Vertex shader compilation failed: ${n.getShaderInfoLog(r)}`;throw new Error(t)}if(n.deleteShader(r),!n.getProgramParameter(s,n.LINK_STATUS)){const t=`GL program linking failed: ${n.getProgramInfoLog(s)}`;throw new Error(t)}return s}getUniformLocation(t){const e=wi(this.currentProgram_);return void 0===this.uniformLocationsByProgram_[e]&&(this.uniformLocationsByProgram_[e]={}),void 0===this.uniformLocationsByProgram_[e][t]&&(this.uniformLocationsByProgram_[e][t]=this.gl_.getUniformLocation(this.currentProgram_,t)),this.uniformLocationsByProgram_[e][t]}getAttributeLocation(t){const e=wi(this.currentProgram_);return void 0===this.attribLocationsByProgram_[e]&&(this.attribLocationsByProgram_[e]={}),void 0===this.attribLocationsByProgram_[e][t]&&(this.attribLocationsByProgram_[e][t]=this.gl_.getAttribLocation(this.currentProgram_,t)),this.attribLocationsByProgram_[e][t]}makeProjectionTransform(t,e){const n=t.size,i=t.viewState.rotation,r=t.viewState.resolution,s=t.viewState.center;return aa(e,0,0,2/(r*n[0]),2/(r*n[1]),-i,-s[0],-s[1]),e}setUniformFloatValue(t,e){this.gl_.uniform1f(this.getUniformLocation(t),e)}setUniformFloatVec2(t,e){this.gl_.uniform2fv(this.getUniformLocation(t),e)}setUniformFloatVec4(t,e){this.gl_.uniform4fv(this.getUniformLocation(t),e)}setUniformMatrixValue(t,e){this.gl_.uniformMatrix4fv(this.getUniformLocation(t),!1,e)}disableAllAttributes_(){for(let t=0;t<this.maxAttributeCount_;t++)this.gl_.disableVertexAttribArray(t)}enableAttributeArray_(t,e,n,i,r,s){const o=this.getAttributeLocation(t);o<0||(this.gl_.enableVertexAttribArray(o),this.gl_.vertexAttribPointer(o,e,n,!1,i,r),s&&this.getInstancedRenderingExtension_().vertexAttribDivisorANGLE(o,1))}enableAttributes_(t,e){const n=function(t){let e=0;for(let n=0;n<t.length;n++){const i=t[n];e+=i.size*RS(i.type)}return e}(t);let i=0;for(let r=0;r<t.length;r++){const s=t[r];s.name&&this.enableAttributeArray_(s.name,s.size,s.type||5126,n,i,e),i+=s.size*RS(s.type)}}enableAttributes(t){this.enableAttributes_(t,!1)}enableAttributesInstanced(t){this.enableAttributes_(t,!0)}handleWebGLContextLost(t){jn(this.bufferCache_),this.currentProgram_=null,t.preventDefault()}handleWebGLContextRestored(){this.needsToBeRecreated_=!0}needsToBeRecreated(){return this.needsToBeRecreated_}createTexture(t,e,n,i){const r=this.gl_;n=n||r.createTexture();const s=i?r.NEAREST:r.LINEAR;r.bindTexture(r.TEXTURE_2D,n),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,s),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,s),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE);const o=r.RGBA,a=r.RGBA,l=r.UNSIGNED_BYTE;return e instanceof Uint8Array?r.texImage2D(r.TEXTURE_2D,0,o,t[0],t[1],0,a,l,e):e?r.texImage2D(r.TEXTURE_2D,0,o,a,l,e):r.texImage2D(r.TEXTURE_2D,0,o,t[0],t[1],0,a,l,null),n}}function RS(t){switch(t){case xS:return Uint8Array.BYTES_PER_ELEMENT;case vS:return Uint16Array.BYTES_PER_ELEMENT;case bS:return Uint32Array.BYTES_PER_ELEMENT;default:return Float32Array.BYTES_PER_ELEMENT}}class FS extends Bg{constructor(t,e){super(t),e=e||{},this.inversePixelTransform_=[1,0,0,1,0,0],this.postProcesses_=e.postProcesses,this.uniforms_=e.uniforms,this.helper,this.onMapChanged_=()=>{this.clearCache(),this.removeHelper()},t.addChangeListener(Lh,this.onMapChanged_),this.dispatchPreComposeEvent=this.dispatchPreComposeEvent.bind(this),this.dispatchPostComposeEvent=this.dispatchPostComposeEvent.bind(this)}dispatchPreComposeEvent(t,e){const n=this.getLayer();if(n.hasListener(Uh)){const i=new Ef(Uh,void 0,e,t);n.dispatchEvent(i)}}dispatchPostComposeEvent(t,e){const n=this.getLayer();if(n.hasListener(Vh)){const i=new Ef(Vh,void 0,e,t);n.dispatchEvent(i)}}reset(t){this.uniforms_=t.uniforms,this.helper&&this.helper.setUniforms(this.uniforms_)}removeHelper(){this.helper&&(this.helper.dispose(),delete this.helper)}prepareFrame(t){if(this.getLayer().getRenderSource()){let e,n=!0,i=-1;for(let r=0,s=t.layerStatesArray.length;r<s;r++){const s=t.layerStatesArray[r].layer,o=s.getRenderer();if(!(o instanceof FS)){n=!0;continue}const a=s.getClassName();if((n||a!==e)&&(i+=1,n=!1),e=a,o===this)break}const r="map/"+t.mapId+"/group/"+i;this.helper&&this.helper.canvasCacheKeyMatches(r)&&!this.helper.needsToBeRecreated()||(this.removeHelper(),this.helper=new TS({postProcesses:this.postProcesses_,uniforms:this.uniforms_,canvasCacheKey:r}),e&&(this.helper.getCanvas().className=e),this.afterHelperCreated())}return this.prepareFrameInternal(t)}afterHelperCreated(){}prepareFrameInternal(t){return!0}clearCache(){}disposeInternal(){this.clearCache(),this.removeHelper(),this.getLayer()?.removeChangeListener(Lh,this.onMapChanged_),super.disposeInternal()}dispatchRenderEvent_(t,e,n){const i=this.getLayer();if(i.hasListener(t)){aa(this.inversePixelTransform_,0,0,n.pixelRatio,-n.pixelRatio,0,0,-n.size[1]);const r=new Ef(t,this.inversePixelTransform_,n,e);i.dispatchEvent(r)}}preRender(t,e){this.dispatchRenderEvent_($h,t,e)}postRender(t,e){this.dispatchRenderEvent_(Bh,t,e)}}const MS="u_tileTextures",IS="u_texturePixelWidth",kS="u_texturePixelHeight";class LS{constructor(t,e){this.name=t,this.data=e,this.texture_=null}getTexture(t){if(!this.texture_){const e=t.createTexture();t.bindTexture(t.TEXTURE_2D,e),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.NEAREST),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,this.data.length/4,1,0,t.RGBA,t.UNSIGNED_BYTE,this.data),this.texture_=e}return this.texture_}delete(t){this.texture_&&t.deleteTexture(this.texture_),this.texture_=null}}function AS(t){const e=t.toString();return e.includes(".")?e:e+".0"}function DS(t){if(t.length<2||t.length>4)throw new Error("`formatArray` can only output `vec2`, `vec3` or `vec4` arrays.");return`vec${t.length}(${t.map(AS).join(", ")})`}function OS(t){const e=Mc(t),n=e.length>3?e[3]:1;return DS([e[0]/255,e[1]/255,e[2]/255,n])}const zS={};let NS=0;function jS(t){return t in zS||(zS[t]=NS++),zS[t]}function GS(t){return AS(jS(t))}function $S(t){return"u_var_"+t}const BS="getBandValue",US="featureId",VS="geometryType",XS=-9999999;function WS(t){return(e,n,i)=>{const r=n.args.length,s=new Array(r);for(let t=0;t<r;++t)s[t]=ZS(n.args[t],i,e);return t(s,e)}}const qS={[Hc]:(t,e)=>{const n=e.args[0].value;n in t.properties||(t.properties[n]={name:n,type:e.type});let i="a_prop_"+n;return Wc(e.type,Dc)&&(i=`(${i} > 0.0)`),i},[ju]:t=>(t.featureId=!0,"a_"+US),[tu]:t=>(t.geometryType=!0,"a_"+VS),[eu]:()=>"currentLineMetric",[Jc]:(t,e)=>{const n=e.args[0].value;n in t.variables||(t.variables[n]={name:n,type:e.type});let i=$S(n);return Wc(e.type,Dc)&&(i=`(${i} > 0.0)`),i},[Uu]:(t,e)=>{const n=e.args[0].value;return n in t.properties||(t.properties[n]={name:n,type:e.type}),`(a_prop_${n} != ${AS(XS)})`},[su]:()=>"u_resolution",[ou]:()=>"u_zoom",[au]:()=>"u_time",[nu]:WS(t=>`(${t.join(" || ")})`),[iu]:WS(t=>`(${t.join(" && ")})`),[ru]:WS(([t])=>`(!${t})`),[lu]:WS(([t,e])=>`(${t} == ${e})`),[hu]:WS(([t,e])=>`(${t} != ${e})`),[cu]:WS(([t,e])=>`(${t} > ${e})`),[uu]:WS(([t,e])=>`(${t} >= ${e})`),[du]:WS(([t,e])=>`(${t} < ${e})`),[fu]:WS(([t,e])=>`(${t} <= ${e})`),[gu]:WS(t=>`(${t.join(" * ")})`),[pu]:WS(([t,e])=>`(${t} / ${e})`),[mu]:WS(t=>`(${t.join(" + ")})`),[_u]:WS(([t,e])=>`(${t} - ${e})`),[yu]:WS(([t,e,n])=>`clamp(${t}, ${e}, ${n})`),[xu]:WS(([t,e])=>`mod(${t}, ${e})`),[vu]:WS(([t,e])=>`pow(${t}, ${e})`),[bu]:WS(([t])=>`abs(${t})`),[wu]:WS(([t])=>`floor(${t})`),[Su]:WS(([t])=>`ceil(${t})`),[Cu]:WS(([t])=>`floor(${t} + 0.5)`),[Eu]:WS(([t])=>`sin(${t})`),[Pu]:WS(([t])=>`cos(${t})`),[Tu]:WS(([t,e])=>void 0!==e?`atan(${t}, ${e})`:`atan(${t})`),[Ru]:WS(([t])=>`sqrt(${t})`),[Fu]:WS(t=>{const e=t[0],n=t[t.length-1];let i=null;for(let r=t.length-3;r>=1;r-=2){i=`(${e} == ${t[r]} ? ${t[r+1]} : ${i||n})`}return i}),[Mu]:WS(([t,e,n])=>`(${t} >= ${e} && ${t} <= ${n})`),[Iu]:WS(([t,e,...n])=>{let i="";for(let r=0;r<n.length-2;r+=2){const s=n[r],o=i||n[r+1],a=n[r+2],l=n[r+3];let h;h=t===AS(1)?`(${e} - ${s}) / (${a} - ${s})`:`(pow(${t}, (${e} - ${s})) - 1.0) / (pow(${t}, (${a} - ${s})) - 1.0)`,i=`mix(${o}, ${l}, clamp(${h}, 0.0, 1.0))`}return i}),[Lu]:WS(t=>{const e=t[t.length-1];let n=null;for(let i=t.length-3;i>=0;i-=2){n=`(${t[i]} ? ${t[i+1]} : ${n||e})`}return n}),[Au]:WS(([t,...e],n)=>{const i=function(t,e){return`operator_${t}_${Object.keys(e.functions).length}`}("in",n),r=[];for(let t=0;t<e.length;t+=1)r.push(` if (inputValue == ${e[t]}) { return true; }`);return n.functions[i]=`bool ${i}(float inputValue) {\n${r.join("\n")}\n return false;\n}`,`${i}(${t})`}),[zu]:WS(t=>`vec${t.length}(${t.join(", ")})`),[Nu]:WS(t=>{if(1===t.length)return`vec4(vec3(${t[0]} / 255.0), 1.0)`;if(2===t.length)return`vec4(vec3(${t[0]} / 255.0), ${t[1]})`;const e=t.slice(0,3).map(t=>`${t} / 255.0`);if(3===t.length)return`vec4(${e.join(", ")}, 1.0)`;const n=t[3];return`vec4(${e.join(", ")}, ${n})`}),[Gu]:WS(([t,e,n],i)=>{if(!(BS in i.functions)){let t="";const e=i.bandCount||1;for(let n=0;n<e;n++){const i=Math.floor(n/4);let r=n%4;n===e-1&&1===r&&(r=3);t+=` if (band == ${n+1}.0) {\n return texture2D(${`${MS}[${i}]`}, v_textureCoord + vec2(dx, dy))[${r}];\n }\n`}i.functions[BS]=`float getBandValue(float band, float xOffset, float yOffset) {\n float dx = xOffset / ${IS};\n float dy = yOffset / ${kS};\n${t}\n}`}return`${BS}(${t}, ${e??"0.0"}, ${n??"0.0"})`}),[$u]:(t,e)=>{const[n,...i]=e.args,r=i.length,s=new Uint8Array(4*r);for(let t=0;t<i.length;t++){const e=Mc(i[t].value),n=4*t;s[n]=e[0],s[n+1]=e[1],s[n+2]=e[2],s[n+3]=255*e[3]}t.paletteTextures||(t.paletteTextures=[]);const o=`u_paletteTextures[${t.paletteTextures.length}]`,a=new LS(o,s);t.paletteTextures.push(a);return`texture2D(${o}, vec2((${ZS(n,Oc,t)} + 0.5) / ${r}.0, 0.5))`}};function ZS(t,e,n){if(t instanceof Zc){const i=qS[t.operator];if(void 0===i)throw new Error(`No compiler defined for this operator: ${JSON.stringify(t.operator)}`);return i(n,t,e)}if((t.type&Oc)>0)return AS(t.value);if((t.type&Dc)>0)return t.value.toString();if((t.type&zc)>0)return GS(t.value.toString());if((t.type&Nc)>0)return OS(t.value);if((t.type&jc)>0)return DS(t.value);if((t.type&Gc)>0)return DS(Lc(t.value));throw new Error(`Unexpected expression ${t.value} (expected type ${Vc(e)})`)}function KS(t,e,n,i){return function(t,e,n,i){return ZS(Yc(t,e,n),e,i)}(e,n,i??Kc(),t)}function YS(t){const e=Mc(t);return[256*e[0]+e[1],256*e[2]+Math.round(255*e[3])]}function HS(t){return t===Nc||t===Gc?2:t===jc?4:1}function JS(t){const e=HS(t);return e>1?`vec${e}`:"float"}function QS(t,e){for(const n in e.variables){const i=e.variables[n],r=$S(i.name);let s=JS(i.type);i.type===Nc&&(s="vec4"),t.addUniform(r,s)}for(const n in e.properties){const i=e.properties[n],r=JS(i.type),s=`a_prop_${i.name}`;i.type===Nc?t.addAttribute(s,r,`unpackColor(${s})`,"vec4"):t.addAttribute(s,r)}for(const n in e.functions)t.addVertexShaderFunction(e.functions[n]),t.addFragmentShaderFunction(e.functions[n])}function tC(t,e){const n={};for(const i in t.variables){const r=t.variables[i];n[$S(r.name)]=()=>{const t=e[r.name];if("number"==typeof t)return t;if("boolean"==typeof t)return t?1:0;if(r.type===Nc){const e=[...Mc(t||"#eee")];return e[0]/=255,e[1]/=255,e[2]/=255,e[3]??=1,e}return"string"==typeof t?jS(t):t}}return n}function eC(t){const e={};for(const n in t.properties){const i=t.properties[n],r=t=>{const e=t.get(i.name);return i.type===Nc?YS([...Mc(e||"#eee")]):"string"==typeof e?jS(e):"boolean"==typeof e?e?1:0:e};e[`prop_${i.name}`]={size:HS(i.type),callback:r}}return e}function nC(t){return t-iC(t)}function iC(t){return Math.fround(t)}const rC="#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\nuniform float u_one;\nuniform mat4 u_projectionMatrix;\nuniform mat4 u_invertProjectionMatrix;\nuniform vec2 u_viewportSizePx;\nuniform float u_pixelRatio;\nuniform float u_globalAlpha;\nuniform float u_time;\nuniform float u_zoom;\nuniform float u_resolution;\nuniform float u_rotation;\nuniform vec4 u_renderExtent;\nuniform float u_depth;\nuniform mediump int u_hitDetection;\n\n// these 64-bits floats are split into high/low\nuniform vec2 u_df_patternOriginX;\nuniform vec2 u_df_patternOriginY;\nuniform vec2 u_df_patternScaleRatio;\n\nconst float PI = 3.141592653589793238;\nconst float TWO_PI = 2.0 * PI;\nfloat currentLineMetric = 0.; // an actual value will be used in the stroke shaders\n\nvec2 pxToWorld(vec2 pxPos) {\n vec2 screenPos = 2.0 * pxPos / u_viewportSizePx - 1.0;\n return (u_invertProjectionMatrix * vec4(screenPos, 0.0, 1.0)).xy;\n}\n\nvec2 worldToPx(vec2 worldPos) {\n vec4 screenPos = u_projectionMatrix * vec4(worldPos, 0.0, 1.0);\n return (0.5 * screenPos.xy + 0.5) * u_viewportSizePx;\n}\nvec4 unpackColor(vec2 packedColor) {\n return vec4(\n min(floor(packedColor[0] / 256.0) / 255.0, 1.0),\n min(mod(packedColor[0], 256.0) / 255.0, 1.0),\n min(floor(packedColor[1] / 256.0) / 255.0, 1.0),\n min(mod(packedColor[1], 256.0) / 255.0, 1.0)\n );\n}\n\nvec2 df_from(float value) {\n return vec2(value, 0.);\n}\n\nfloat df_float(vec2 df) {\n return df.x;\n}\n\nvec2 df_add(vec2 dfa, vec2 dfb) {\n vec2 dfc;\n float t1, t2, e;\n \n t1 = dfa.x * u_one + dfb.x * u_one;\n e = t1 * u_one - dfa.x * u_one;\n t2 = ((dfb.x - e) + (dfa.x - (t1 - e))) * u_one + dfa.y + dfb.y * u_one;\n \n dfc.x = t1 * u_one + t2 * u_one;\n dfc.y = t2 - (dfc.x - t1) * u_one;\n return dfc;\n}\n\nvec2 df_sub(vec2 dfa, vec2 dfb) {\n vec2 dfc;\n float e, t1, t2;\n \n t1 = dfa.x - dfb.x;\n e = t1 - dfa.x;\n t2 = ((-dfb.x - e) + (dfa.x - (t1 - e))) + dfa.y - dfb.y;\n \n dfc.x = t1 + t2;\n dfc.y = t2 - (dfc.x - t1);\n return dfc;\n}\n\nvec2 df_mul(vec2 dfa, vec2 dfb) {\n vec2 dfc;\n float c11, c21, c2, e, t1, t2;\n float a1, a2, b1, b2, cona, conb, split = 4097.;\n\n cona = dfa.x * split * u_one;\n conb = dfb.x * split * u_one;\n a1 = cona * u_one - (cona - dfa.x);\n b1 = conb * u_one - (conb - dfb.x);\n a2 = dfa.x * u_one - a1;\n b2 = dfb.x * u_one - b1 * u_one;\n\n c11 = dfa.x * u_one * dfb.x * u_one;\n c21 = a2 * b2 * u_one + (a2 * b1 + (a1 * b2 + (a1 * b1 - c11))) * u_one;\n\n c2 = dfa.x * dfb.y * u_one + dfa.y * dfb.x * u_one;\n\n t1 = c11 + c2 * u_one;\n e = t1 - c11 * u_one;\n t2 = dfa.y * dfb.y * u_one + ((c2 - e) + (c11 - (t1 - e))) + c21 * u_one;\n\n dfc.x = t1 * u_one + t2 * u_one;\n dfc.y = t2 - (dfc.x - t1) * u_one;\n\n return dfc;\n}\n\nvec2 df_div(vec2 dfa, vec2 dfb) {\n vec2 dfc;\n float c11, c21, c2, e, t1, t2, t11, t12, t21, t22;\n float a1, a2, b1, b2, cona, conb, split = 4097.;\n float s1, s2;\n \n s1 = dfa.x / dfb.x * u_one;\n cona = s1 * split * u_one;\n conb = dfb.x * split * u_one;\n a1 = cona - (cona - s1) * u_one;\n b1 = conb - (conb - dfb.x) * u_one;\n a2 = s1 - a1 * u_one;\n b2 = dfb.x - b1 * u_one;\n \n c11 = s1 * dfb.x * u_one;\n c21 = (((a1 * b1 - c11) + a1 * b2) + a2 * b1) + a2 * b2 * u_one;\n \n c2 = s1 * dfb.y * u_one;\n \n t1 = c11 + c2 * u_one;\n e = t1 - c11 * u_one;\n t2 = ((c2 - e) + (c11 - (t1 - e))) + c21 * u_one;\n \n t12 = t1 + t2 * u_one;\n t22 = t2 - (t12 - t1) * u_one;\n \n t11 = dfa.x - t12 * u_one;\n e = t11 - dfa.x * u_one;\n t21 = ((-t12 - e) + (dfa.x - (t11 - e))) + dfa.y - t22 * u_one;\n \n s2 = (t11 + t21) / dfb.x * u_one;\n \n dfc.x = s1 + s2 * u_one;\n dfc.y = s2 - (dfc.x - s1) * u_one;\n \n return dfc;\n}\n\nfloat df_mod(vec2 df, vec2 m) {\n vec2 q = df_div(df, m) * u_one;\n float qf = floor(q.x);\n float frac = q.x - qf + q.y * u_one;\n if (frac < 0.0) qf -= 1.0;\n if (frac >= 1.0) qf += 1.0;\n vec2 prod = df_mul(df_from(qf), m);\n vec2 rem = df_add(df_from(df.x), df_from(-prod.x)) * u_one;\n rem.y += df.y - prod.y;\n return rem.x + rem.y * u_one;\n}\n\n",sC={"fill-color":"rgba(255,255,255,0.4)","stroke-color":"#3399CC","stroke-width":1.25,"circle-radius":5,"circle-fill-color":"rgba(255,255,255,0.4)","circle-stroke-width":1.25,"circle-stroke-color":"#3399CC"};class oC{constructor(){this.uniforms_=[],this.attributes_=[],this.hasSymbol_=!1,this.symbolSizeExpression_=`vec2(${AS(sC["circle-radius"])} + ${AS(.5*sC["circle-stroke-width"])})`,this.symbolRotationExpression_="0.0",this.symbolOffsetExpression_="vec2(0.0)",this.symbolColorExpression_=OS(sC["circle-fill-color"]),this.texCoordExpression_="vec4(0.0, 0.0, 1.0, 1.0)",this.fragmentDiscardExpression_=null,this.shapeDiscardExpression_=null,this.symbolRotateWithView_=!1,this.hasStroke_=!1,this.strokeWidthExpression_=AS(sC["stroke-width"]),this.strokeColorExpression_=OS(sC["stroke-color"]),this.strokeOffsetExpression_="0.",this.strokeCapExpression_=GS("round"),this.strokeJoinExpression_=GS("round"),this.strokeMiterLimitExpression_="10.",this.strokeDistanceFieldExpression_="-1000.",this.strokePatternLengthExpression_=null,this.hasFill_=!1,this.fillColorExpression_=OS(sC["fill-color"]),this.fillPatternSizeExpression_=null,this.vertexShaderFunctions_=[],this.fragmentShaderFunctions_=[]}addUniform(t,e){return this.uniforms_.push({name:t,type:e}),this}addAttribute(t,e,n,i){return this.attributes_.push({name:t,type:e,varyingName:t.replace(/^a_/,"v_"),varyingType:i??e,varyingExpression:n??t}),this}setSymbolSizeExpression(t){return this.hasSymbol_=!0,this.symbolSizeExpression_=t,this}getSymbolSizeExpression(){return this.symbolSizeExpression_}setSymbolRotationExpression(t){return this.symbolRotationExpression_=t,this}setSymbolOffsetExpression(t){return this.symbolOffsetExpression_=t,this}getSymbolOffsetExpression(){return this.symbolOffsetExpression_}setSymbolColorExpression(t){return this.hasSymbol_=!0,this.symbolColorExpression_=t,this}getSymbolColorExpression(){return this.symbolColorExpression_}setTextureCoordinateExpression(t){return this.texCoordExpression_=t,this}setFragmentDiscardExpression(t){return this.fragmentDiscardExpression_=t,this}getFragmentDiscardExpression(){return this.fragmentDiscardExpression_}setShapeDiscardExpression(t){return this.shapeDiscardExpression_=t,this}getShapeDiscardExpression(){return this.shapeDiscardExpression_}setSymbolRotateWithView(t){return this.symbolRotateWithView_=t,this}setStrokeWidthExpression(t){return this.hasStroke_=!0,this.strokeWidthExpression_=t,this}setStrokeColorExpression(t){return this.hasStroke_=!0,this.strokeColorExpression_=t,this}getStrokeColorExpression(){return this.strokeColorExpression_}setStrokeOffsetExpression(t){return this.strokeOffsetExpression_=t,this}setStrokeCapExpression(t){return this.strokeCapExpression_=t,this}setStrokeJoinExpression(t){return this.strokeJoinExpression_=t,this}setStrokeMiterLimitExpression(t){return this.strokeMiterLimitExpression_=t,this}setStrokeDistanceFieldExpression(t){return this.strokeDistanceFieldExpression_=t,this}setStrokePatternLengthExpression(t){return this.strokePatternLengthExpression_=t,this}getStrokePatternLengthExpression(){return this.strokePatternLengthExpression_}setFillColorExpression(t){return this.hasFill_=!0,this.fillColorExpression_=t,this}getFillColorExpression(){return this.fillColorExpression_}setFillPatternSizeExpression(t){return this.fillPatternSizeExpression_=t,this}getFillPatternSizeExpression(){return this.fillPatternSizeExpression_}addVertexShaderFunction(t){return this.vertexShaderFunctions_.includes(t)||this.vertexShaderFunctions_.push(t),this}addFragmentShaderFunction(t){return this.fragmentShaderFunctions_.includes(t)||this.fragmentShaderFunctions_.push(t),this}getSymbolVertexShader(){return this.hasSymbol_?`${rC}\n${this.uniforms_.map(t=>`uniform ${t.type} ${t.name};`).join("\n")}\nattribute vec2 a_position;\nattribute vec2 a_localPosition;\nattribute vec2 a_hitColor;\n\nvarying vec2 v_texCoord;\nvarying vec2 v_quadCoord;\nvarying vec4 v_hitColor;\nvarying vec2 v_centerPx;\nvarying float v_angle;\nvarying vec2 v_quadSizePx;\n\n${this.attributes_.map(t=>`attribute ${t.type} ${t.name};\nvarying ${t.varyingType} ${t.varyingName};`).join("\n")}\n${this.vertexShaderFunctions_.join("\n")}\nvec2 pxToScreen(vec2 coordPx) {\n vec2 scaled = coordPx / u_viewportSizePx / 0.5;\n return scaled;\n}\n\nvec2 screenToPx(vec2 coordScreen) {\n return (coordScreen * 0.5 + 0.5) * u_viewportSizePx;\n}\n\nvoid main(void) {\n v_quadSizePx = ${this.symbolSizeExpression_};\n vec2 halfSizePx = v_quadSizePx * 0.5;\n vec2 centerOffsetPx = ${this.symbolOffsetExpression_};\n vec2 offsetPx = centerOffsetPx + a_localPosition * halfSizePx * vec2(1., -1.);\n float angle = ${this.symbolRotationExpression_}${this.symbolRotateWithView_?" + u_rotation":""};\n float c = cos(-angle);\n float s = sin(-angle);\n offsetPx = vec2(c * offsetPx.x - s * offsetPx.y, s * offsetPx.x + c * offsetPx.y);\n vec4 center = u_projectionMatrix * vec4(a_position, 0.0, 1.0);\n gl_Position = center + vec4(pxToScreen(offsetPx), u_depth, 0.);\n vec4 texCoord = ${this.texCoordExpression_};\n float u = mix(texCoord.s, texCoord.p, a_localPosition.x * 0.5 + 0.5);\n float v = mix(texCoord.t, texCoord.q, a_localPosition.y * 0.5 + 0.5);\n v_texCoord = vec2(u, v);\n v_hitColor = unpackColor(a_hitColor);\n v_angle = angle;\n c = cos(-v_angle);\n s = sin(-v_angle);\n centerOffsetPx = vec2(c * centerOffsetPx.x - s * centerOffsetPx.y, s * centerOffsetPx.x + c * centerOffsetPx.y);\n v_centerPx = screenToPx(center.xy) + centerOffsetPx;\n${this.attributes_.map(t=>` ${t.varyingName} = ${t.varyingExpression};`).join("\n")}\n${this.shapeDiscardExpression_?` if (${this.shapeDiscardExpression_}) { gl_Position = vec4(2.0, 2.0, 0.0, 0.0); }`:""}\n}`:null}getSymbolFragmentShader(){return this.hasSymbol_?`${rC}\n${this.uniforms_.map(t=>`uniform ${t.type} ${t.name};`).join("\n")}\nvarying vec2 v_texCoord;\nvarying vec4 v_hitColor;\nvarying vec2 v_centerPx;\nvarying float v_angle;\nvarying vec2 v_quadSizePx;\n${this.attributes_.map(t=>`varying ${t.varyingType} ${t.varyingName};`).join("\n")}\n${this.fragmentShaderFunctions_.join("\n")}\n\nvoid main(void) {\n${this.attributes_.map(t=>` ${t.varyingType} ${t.name} = ${t.varyingName}; // assign to original attribute name`).join("\n")}\n${this.fragmentDiscardExpression_?` if (${this.fragmentDiscardExpression_}) { discard; }`:""}\n vec2 coordsPx = gl_FragCoord.xy / u_pixelRatio - v_centerPx; // relative to center\n float c = cos(v_angle);\n float s = sin(v_angle);\n coordsPx = vec2(c * coordsPx.x - s * coordsPx.y, s * coordsPx.x + c * coordsPx.y);\n gl_FragColor = ${this.symbolColorExpression_};\n gl_FragColor.rgb *= gl_FragColor.a;\n if (u_hitDetection > 0) {\n if (gl_FragColor.a < 0.05) { discard; };\n gl_FragColor = v_hitColor;\n }\n}`:null}getStrokeVertexShader(){return this.hasStroke_?`${rC}\n${this.uniforms_.map(t=>`uniform ${t.type} ${t.name};`).join("\n")}\nattribute vec2 a_segmentStart;\nattribute vec2 a_segmentEnd;\nattribute vec2 a_localPosition;\nattribute float a_measureStart;\nattribute float a_measureEnd;\nattribute float a_angleTangentSum;\nattribute float a_distanceLow;\nattribute float a_distanceHigh;\nattribute vec2 a_joinAngles;\nattribute vec2 a_hitColor;\n\nvarying vec2 v_segmentStartPx;\nvarying vec2 v_segmentEndPx;\nvarying float v_angleStart;\nvarying float v_angleEnd;\nvarying float v_width;\nvarying vec4 v_hitColor;\nvarying float v_distancePx;\nvarying float v_measureStart;\nvarying float v_measureEnd;\n\n${this.attributes_.map(t=>`attribute ${t.type} ${t.name};\nvarying ${t.varyingType} ${t.varyingName};`).join("\n")}\n${this.vertexShaderFunctions_.join("\n")}\n\nvec4 pxToScreen(vec2 pxPos) {\n vec2 screenPos = 2.0 * pxPos / u_viewportSizePx - 1.0;\n return vec4(screenPos, u_depth, 1.0);\n}\n\nbool isCap(float joinAngle) {\n return joinAngle < -0.1;\n}\n\nvec2 getJoinOffsetDirection(vec2 normalPx, float joinAngle) {\n float halfAngle = joinAngle / 2.0;\n float c = cos(halfAngle);\n float s = sin(halfAngle);\n vec2 angleBisectorNormal = vec2(s * normalPx.x + c * normalPx.y, -c * normalPx.x + s * normalPx.y);\n float length = 1.0 / s;\n return angleBisectorNormal * length;\n}\n\nvec2 getOffsetPoint(vec2 point, vec2 normal, float joinAngle, float offsetPx) {\n // if on a cap or the join angle is too high, offset the line along the segment normal\n if (cos(joinAngle) > 0.998 || isCap(joinAngle)) {\n return point - normal * offsetPx;\n }\n // offset is applied along the inverted normal (positive offset goes "right" relative to line direction)\n return point - getJoinOffsetDirection(normal, joinAngle) * offsetPx;\n}\n\nvoid main(void) {\n v_angleStart = a_joinAngles.x;\n v_angleEnd = a_joinAngles.y;\n float startEndRatio = a_localPosition.x * 0.5 + 0.5;\n currentLineMetric = mix(a_measureStart, a_measureEnd, startEndRatio);\n // we're reading the fractional part while keeping the sign (so -4.12 gives -0.12, 3.45 gives 0.45)\n\n float lineWidth = ${this.strokeWidthExpression_};\n float lineOffsetPx = ${this.strokeOffsetExpression_};\n\n // compute segment start/end in px with offset\n vec2 segmentStartPx = worldToPx(a_segmentStart);\n vec2 segmentEndPx = worldToPx(a_segmentEnd);\n vec2 tangentPx = normalize(segmentEndPx - segmentStartPx);\n vec2 normalPx = vec2(-tangentPx.y, tangentPx.x);\n segmentStartPx = getOffsetPoint(segmentStartPx, normalPx, v_angleStart, lineOffsetPx),\n segmentEndPx = getOffsetPoint(segmentEndPx, normalPx, v_angleEnd, lineOffsetPx);\n\n // compute current vertex position\n float normalDir = -1. * a_localPosition.y;\n float tangentDir = -1. * a_localPosition.x;\n float angle = mix(v_angleStart, v_angleEnd, startEndRatio);\n vec2 joinDirection;\n vec2 positionPx = mix(segmentStartPx, segmentEndPx, startEndRatio);\n // if angle is too high, do not make a proper join\n if (cos(angle) > 0.985 || isCap(angle)) {\n joinDirection = normalPx * normalDir - tangentPx * tangentDir;\n } else {\n joinDirection = getJoinOffsetDirection(normalPx * normalDir, angle);\n }\n positionPx = positionPx + joinDirection * (lineWidth * 0.5 + 1.); // adding 1 pixel for antialiasing\n gl_Position = pxToScreen(positionPx);\n\n v_segmentStartPx = segmentStartPx;\n v_segmentEndPx = segmentEndPx;\n v_width = lineWidth;\n v_hitColor = unpackColor(a_hitColor);\n\n v_distancePx = a_distanceLow / u_resolution - (lineOffsetPx * a_angleTangentSum);\n float distanceHighPx = a_distanceHigh / u_resolution;\n ${null!==this.strokePatternLengthExpression_?`v_distancePx = mod(v_distancePx, ${this.strokePatternLengthExpression_});\n distanceHighPx = mod(distanceHighPx, ${this.strokePatternLengthExpression_});\n `:""}v_distancePx += distanceHighPx;\n\n v_measureStart = a_measureStart;\n v_measureEnd = a_measureEnd;\n${this.attributes_.map(t=>` ${t.varyingName} = ${t.varyingExpression};`).join("\n")}\n${this.shapeDiscardExpression_?` if (${this.shapeDiscardExpression_}) { gl_Position = vec4(2.0, 2.0, 0.0, 0.0); }`:""}\n}`:null}getStrokeFragmentShader(){return this.hasStroke_?`${rC}\n${this.uniforms_.map(t=>`uniform ${t.type} ${t.name};`).join("\n")}\nvarying vec2 v_segmentStartPx;\nvarying vec2 v_segmentEndPx;\nvarying float v_angleStart;\nvarying float v_angleEnd;\nvarying float v_width;\nvarying vec4 v_hitColor;\nvarying float v_distancePx;\nvarying float v_measureStart;\nvarying float v_measureEnd;\n${this.attributes_.map(t=>`varying ${t.varyingType} ${t.varyingName};`).join("\n")}\n${this.fragmentShaderFunctions_.join("\n")}\n\nbool isCap(float joinAngle) {\n return joinAngle < -0.1;\n}\n\nfloat segmentDistanceField(vec2 point, vec2 start, vec2 end, float width) {\n vec2 tangent = normalize(end - start);\n vec2 normal = vec2(-tangent.y, tangent.x);\n vec2 startToPoint = point - start;\n return abs(dot(startToPoint, normal)) - width * 0.5;\n}\n\nfloat buttCapDistanceField(vec2 point, vec2 start, vec2 end) {\n vec2 startToPoint = point - start;\n vec2 tangent = normalize(end - start);\n return dot(startToPoint, -tangent);\n}\n\nfloat squareCapDistanceField(vec2 point, vec2 start, vec2 end, float width) {\n return buttCapDistanceField(point, start, end) - width * 0.5;\n}\n\nfloat roundCapDistanceField(vec2 point, vec2 start, vec2 end, float width) {\n float onSegment = max(0., 1000. * dot(point - start, end - start)); // this is very high when inside the segment\n return length(point - start) - width * 0.5 - onSegment;\n}\n\nfloat roundJoinDistanceField(vec2 point, vec2 start, vec2 end, float width) {\n return roundCapDistanceField(point, start, end, width);\n}\n\nfloat bevelJoinField(vec2 point, vec2 start, vec2 end, float width, float joinAngle) {\n vec2 startToPoint = point - start;\n vec2 tangent = normalize(end - start);\n float c = cos(joinAngle * 0.5);\n float s = sin(joinAngle * 0.5);\n float direction = -sign(sin(joinAngle));\n vec2 bisector = vec2(c * tangent.x - s * tangent.y, s * tangent.x + c * tangent.y);\n float radius = width * 0.5 * s;\n return dot(startToPoint, bisector * direction) - radius;\n}\n\nfloat miterJoinDistanceField(vec2 point, vec2 start, vec2 end, float width, float joinAngle) {\n if (cos(joinAngle) > 0.985) { // avoid risking a division by zero\n return bevelJoinField(point, start, end, width, joinAngle);\n }\n float miterLength = 1. / sin(joinAngle * 0.5);\n float miterLimit = ${this.strokeMiterLimitExpression_};\n if (miterLength > miterLimit) {\n return bevelJoinField(point, start, end, width, joinAngle);\n }\n return -1000.;\n}\n\nfloat capDistanceField(vec2 point, vec2 start, vec2 end, float width, float capType) {\n if (capType == ${GS("butt")}) {\n return buttCapDistanceField(point, start, end);\n } else if (capType == ${GS("square")}) {\n return squareCapDistanceField(point, start, end, width);\n }\n return roundCapDistanceField(point, start, end, width);\n}\n\nfloat joinDistanceField(vec2 point, vec2 start, vec2 end, float width, float joinAngle, float joinType) {\n if (joinType == ${GS("bevel")}) {\n return bevelJoinField(point, start, end, width, joinAngle);\n } else if (joinType == ${GS("miter")}) {\n return miterJoinDistanceField(point, start, end, width, joinAngle);\n }\n return roundJoinDistanceField(point, start, end, width);\n}\n\nfloat computeSegmentPointDistance(vec2 point, vec2 start, vec2 end, float width, float joinAngle, float capType, float joinType) {\n if (isCap(joinAngle)) {\n return capDistanceField(point, start, end, width, capType);\n }\n return joinDistanceField(point, start, end, width, joinAngle, joinType);\n}\n\nfloat distanceFromSegment(vec2 point, vec2 start, vec2 end) {\n vec2 tangent = end - start;\n vec2 startToPoint = point - start;\n // inspire by capsule fn in https://iquilezles.org/articles/distfunctions/\n float h = clamp(dot(startToPoint, tangent) / dot(tangent, tangent), 0.0, 1.0);\n return length(startToPoint - tangent * h);\n}\n\nvoid main(void) {\n${this.attributes_.map(t=>` ${t.varyingType} ${t.name} = ${t.varyingName}; // assign to original attribute name`).join("\n")}\n\n vec2 currentPointPx = gl_FragCoord.xy / u_pixelRatio;\n vec2 worldPos = pxToWorld(currentPointPx);\n if (\n abs(u_renderExtent[0] - u_renderExtent[2]) > 0.0 && (\n worldPos[0] < u_renderExtent[0] ||\n worldPos[1] < u_renderExtent[1] ||\n worldPos[0] > u_renderExtent[2] ||\n worldPos[1] > u_renderExtent[3]\n )\n ) {\n discard;\n }\n\n float segmentLengthPx = length(v_segmentEndPx - v_segmentStartPx);\n segmentLengthPx = max(segmentLengthPx, 1.17549429e-38); // avoid divide by zero\n vec2 segmentTangent = (v_segmentEndPx - v_segmentStartPx) / segmentLengthPx;\n vec2 segmentNormal = vec2(-segmentTangent.y, segmentTangent.x);\n vec2 startToPointPx = currentPointPx - v_segmentStartPx;\n float lengthToPointPx = max(0., min(dot(segmentTangent, startToPointPx), segmentLengthPx));\n float currentLengthPx = lengthToPointPx + v_distancePx;\n float currentRadiusPx = distanceFromSegment(currentPointPx, v_segmentStartPx, v_segmentEndPx);\n float currentRadiusRatio = dot(segmentNormal, startToPointPx) * 2. / v_width;\n currentLineMetric = mix(v_measureStart, v_measureEnd, lengthToPointPx / segmentLengthPx);\n\n${this.fragmentDiscardExpression_?` if (${this.fragmentDiscardExpression_}) { discard; }`:""}\n\n float capType = ${this.strokeCapExpression_};\n float joinType = ${this.strokeJoinExpression_};\n float segmentStartDistance = computeSegmentPointDistance(currentPointPx, v_segmentStartPx, v_segmentEndPx, v_width, v_angleStart, capType, joinType);\n float segmentEndDistance = computeSegmentPointDistance(currentPointPx, v_segmentEndPx, v_segmentStartPx, v_width, v_angleEnd, capType, joinType);\n float distanceField = max(\n segmentDistanceField(currentPointPx, v_segmentStartPx, v_segmentEndPx, v_width),\n max(segmentStartDistance, segmentEndDistance)\n );\n distanceField = max(distanceField, ${this.strokeDistanceFieldExpression_});\n\n vec4 color = ${this.strokeColorExpression_};\n color.a *= smoothstep(0.5, -0.5, distanceField);\n gl_FragColor = color;\n gl_FragColor.a *= u_globalAlpha;\n gl_FragColor.rgb *= gl_FragColor.a;\n if (u_hitDetection > 0) {\n if (gl_FragColor.a < 0.1) { discard; };\n gl_FragColor = v_hitColor;\n }\n}`:null}getFillVertexShader(){return this.hasFill_?`${rC}\n${this.uniforms_.map(t=>`uniform ${t.type} ${t.name};`).join("\n")}\nattribute vec2 a_position;\nattribute vec2 a_hitColor;\n\nvarying vec4 v_hitColor;\nvarying vec2 v_patternOriginPx;\nvarying vec2 v_patternSizePx;\n\n${this.attributes_.map(t=>`attribute ${t.type} ${t.name};\nvarying ${t.varyingType} ${t.varyingName};`).join("\n")}\n${this.vertexShaderFunctions_.join("\n")}\nvoid main(void) {\n gl_Position = u_projectionMatrix * vec4(a_position, u_depth, 1.0);\n v_hitColor = unpackColor(a_hitColor);\n${null!==this.fillPatternSizeExpression_?`\n // this computes the pattern offset in screenspace using double-float arithmetics\n v_patternSizePx = ${this.fillPatternSizeExpression_};\n vec2 patternSizeScaledX = df_mul(df_from(v_patternSizePx.x), u_df_patternScaleRatio);\n vec2 patternSizeScaledY = df_mul(df_from(v_patternSizePx.y), u_df_patternScaleRatio);\n v_patternOriginPx = vec2(\n df_mod(u_df_patternOriginX, patternSizeScaledX),\n df_mod(u_df_patternOriginY, patternSizeScaledY)\n );\n\n // reapply rotation to the pattern origin\n v_patternOriginPx -= u_viewportSizePx / 2.; // translate to viewport center\n v_patternOriginPx = vec2(\n cos(-u_rotation) * v_patternOriginPx.x - sin(-u_rotation) * v_patternOriginPx.y,\n sin(-u_rotation) * v_patternOriginPx.x + cos(-u_rotation) * v_patternOriginPx.y\n );\n v_patternOriginPx += u_viewportSizePx / 2.; // translate back\n`:" v_patternOriginPx = vec2(0.);"}\n${this.attributes_.map(t=>` ${t.varyingName} = ${t.varyingExpression};`).join("\n")}\n${this.shapeDiscardExpression_?` if (${this.shapeDiscardExpression_}) { gl_Position = vec4(2.0, 2.0, 0.0, 0.0); }`:""}\n}`:null}getFillFragmentShader(){return this.hasFill_?`${rC}\n${this.uniforms_.map(t=>`uniform ${t.type} ${t.name};`).join("\n")}\nvarying vec4 v_hitColor;\nvarying vec2 v_patternOriginPx;\nvarying vec2 v_patternSizePx;\n${this.attributes_.map(t=>`varying ${t.varyingType} ${t.varyingName};`).join("\n")}\n${this.fragmentShaderFunctions_.join("\n")}\n\nvoid main(void) {\n${this.attributes_.map(t=>` ${t.varyingType} ${t.name} = ${t.varyingName}; // assign to original attribute name`).join("\n")}\n vec2 pxPos = gl_FragCoord.xy / u_pixelRatio;\n vec2 worldPos = pxToWorld(pxPos);\n if (\n abs(u_renderExtent[0] - u_renderExtent[2]) > 0.0 && (\n worldPos[0] < u_renderExtent[0] ||\n worldPos[1] < u_renderExtent[1] ||\n worldPos[0] > u_renderExtent[2] ||\n worldPos[1] > u_renderExtent[3]\n )\n ) {\n discard;\n }\n${this.fragmentDiscardExpression_?` if (${this.fragmentDiscardExpression_}) { discard; }`:""}\n gl_FragColor = ${this.fillColorExpression_};\n gl_FragColor.a *= u_globalAlpha;\n gl_FragColor.rgb *= gl_FragColor.a;\n if (u_hitDetection > 0) {\n if (gl_FragColor.a < 0.1) { discard; };\n gl_FragColor = v_hitColor;\n }\n}`:null}}class aC{constructor(){this.globalCounter_=0,this.refToFeature_=new Map,this.uidToRef_=new Map,this.freeGlobalRef_=[],this.polygonBatch={entries:{},geometriesCount:0,verticesCount:0,ringsCount:0},this.pointBatch={entries:{},geometriesCount:0},this.lineStringBatch={entries:{},geometriesCount:0,verticesCount:0}}addFeatures(t,e){for(let n=0;n<t.length;n++)this.addFeature(t[n],e)}addFeature(t,e){let n=t.getGeometry();n&&(e&&(n=n.clone(),n.applyTransform(e)),this.addGeometry_(n,t))}clearFeatureEntryInPointBatch_(t){const e=wi(t),n=this.pointBatch.entries[e];if(n)return this.pointBatch.geometriesCount-=n.flatCoordss.length,delete this.pointBatch.entries[e],n}clearFeatureEntryInLineStringBatch_(t){const e=wi(t),n=this.lineStringBatch.entries[e];if(n)return this.lineStringBatch.verticesCount-=n.verticesCount,this.lineStringBatch.geometriesCount-=n.flatCoordss.length,delete this.lineStringBatch.entries[e],n}clearFeatureEntryInPolygonBatch_(t){const e=wi(t),n=this.polygonBatch.entries[e];if(n)return this.polygonBatch.verticesCount-=n.verticesCount,this.polygonBatch.ringsCount-=n.ringsCount,this.polygonBatch.geometriesCount-=n.flatCoordss.length,delete this.polygonBatch.entries[e],n}addGeometry_(t,e){const n=t.getType();switch(n){case"GeometryCollection":{const n=t.getGeometriesArray();for(const t of n)this.addGeometry_(t,e);break}case"MultiPolygon":{const i=t;this.addCoordinates_(n,i.getFlatCoordinates(),i.getEndss(),e,wi(e),i.getStride());break}case"MultiLineString":{const i=t;this.addCoordinates_(n,i.getFlatCoordinates(),i.getEnds(),e,wi(e),i.getStride());break}case"MultiPoint":{const i=t;this.addCoordinates_(n,i.getFlatCoordinates(),null,e,wi(e),i.getStride());break}case"Polygon":{const i=t;this.addCoordinates_(n,i.getFlatCoordinates(),i.getEnds(),e,wi(e),i.getStride());break}case"Point":{const i=t;this.addCoordinates_(n,i.getFlatCoordinates(),null,e,wi(e),i.getStride());break}case"LineString":case"LinearRing":{const i=t,r=i.getStride();this.addCoordinates_(n,i.getFlatCoordinates(),null,e,wi(e),r,i.getLayout?.());break}}}addCoordinates_(t,e,n,i,r,s,o){let a;switch(t){case"MultiPolygon":{const t=n;for(let n=0,a=t.length;n<a;n++){let a=t[n];const l=n>0?t[n-1]:null,h=l?l[l.length-1]:0,c=a[a.length-1];a=h>0?a.map(t=>t-h):a,this.addCoordinates_("Polygon",e.slice(h,c),a,i,r,s,o)}break}case"MultiLineString":{const t=n;for(let n=0,a=t.length;n<a;n++){const a=n>0?t[n-1]:0;this.addCoordinates_("LineString",e.slice(a,t[n]),null,i,r,s,o)}break}case"MultiPoint":for(let t=0,n=e.length;t<n;t+=s)this.addCoordinates_("Point",e.slice(t,t+2),null,i,r,null,null);break;case"Polygon":{const t=n;if(i instanceof Bf){const n=nl(e,t);if(n.length>1)return void this.addCoordinates_("MultiPolygon",e,n,i,r,s,o)}this.polygonBatch.entries[r]||(this.polygonBatch.entries[r]=this.addRefToEntry_(r,{feature:i,flatCoordss:[],verticesCount:0,ringsCount:0,ringsVerticesCounts:[]})),a=e.length/s;const l=n.length,h=n.map((t,e,n)=>e>0?(t-n[e-1])/s:t/s);this.polygonBatch.verticesCount+=a,this.polygonBatch.ringsCount+=l,this.polygonBatch.geometriesCount++,this.polygonBatch.entries[r].flatCoordss.push(function(t,e){if(2===e)return t;return t.filter((t,n)=>n%e<2)}(e,s)),this.polygonBatch.entries[r].ringsVerticesCounts.push(h),this.polygonBatch.entries[r].verticesCount+=a,this.polygonBatch.entries[r].ringsCount+=l;for(let n=0,a=t.length;n<a;n++){const a=n>0?t[n-1]:0;this.addCoordinates_("LinearRing",e.slice(a,t[n]),null,i,r,s,o)}break}case"Point":this.pointBatch.entries[r]||(this.pointBatch.entries[r]=this.addRefToEntry_(r,{feature:i,flatCoordss:[]})),this.pointBatch.geometriesCount++,this.pointBatch.entries[r].flatCoordss.push(e);break;case"LineString":case"LinearRing":this.lineStringBatch.entries[r]||(this.lineStringBatch.entries[r]=this.addRefToEntry_(r,{feature:i,flatCoordss:[],verticesCount:0})),a=e.length/s,this.lineStringBatch.verticesCount+=a,this.lineStringBatch.geometriesCount++,this.lineStringBatch.entries[r].flatCoordss.push(function(t,e,n){if(3===e&&"XYM"===n)return t;if(4===e)return t.filter((t,n)=>n%e!==2);if(3===e)return t.map((t,n)=>n%e!==2?t:0);return new Array(1.5*t.length).fill(0).map((e,n)=>n%3==2?0:t[Math.round(n/1.5)])}(e,s,o)),this.lineStringBatch.entries[r].verticesCount+=a}}addRefToEntry_(t,e){const n=this.uidToRef_.get(t),i=n||this.freeGlobalRef_.pop()||++this.globalCounter_;return e.ref=i,n||(this.refToFeature_.set(i,e.feature),this.uidToRef_.set(t,i)),e}removeRef_(t,e){if(!t)throw new Error("This feature has no ref: "+e);this.refToFeature_.delete(t),this.uidToRef_.delete(e),this.freeGlobalRef_.push(t)}changeFeature(t,e){if(!this.uidToRef_.get(wi(t)))return;this.removeFeature(t);let n=t.getGeometry();n&&(e&&(n=n.clone(),n.applyTransform(e)),this.addGeometry_(n,t))}removeFeature(t){let e=this.clearFeatureEntryInPointBatch_(t);e=this.clearFeatureEntryInPolygonBatch_(t)||e,e=this.clearFeatureEntryInLineStringBatch_(t)||e,e&&this.removeRef_(e.ref,wi(e.feature))}clear(){this.polygonBatch.entries={},this.polygonBatch.geometriesCount=0,this.polygonBatch.verticesCount=0,this.polygonBatch.ringsCount=0,this.lineStringBatch.entries={},this.lineStringBatch.geometriesCount=0,this.lineStringBatch.verticesCount=0,this.pointBatch.entries={},this.pointBatch.geometriesCount=0,this.globalCounter_=0,this.freeGlobalRef_=[],this.refToFeature_.clear(),this.uidToRef_.clear()}getFeatureFromRef(t){return this.refToFeature_.get(t)}isEmpty(){return 0===this.globalCounter_}filter(t){const e=new aC;e.globalCounter_=this.globalCounter_,e.uidToRef_=this.uidToRef_,e.refToFeature_=this.refToFeature_;let n=!0;for(const i of this.refToFeature_.values())t(i)&&(e.addFeature(i),n=!1);return n?new aC:e}}function lC(){const t='function t(t,n,x=2){const o=n&&n.length,i=o?n[0]*x:t.length;let f=e(t,0,i,x,!0);const l=[];if(!f||f.next===f.prev)return l;let c,y,h;if(o&&(f=function(t,n,r,x){const o=[];for(let r=0,i=n.length;r<i;r++){const f=e(t,n[r]*x,r<i-1?n[r+1]*x:t.length,x,!1);f===f.next&&(f.steiner=!0),o.push(a(f))}o.sort(u);for(let t=0;t<o.length;t++)r=s(o[t],r);return r}(t,n,f,x)),t.length>80*x){c=t[0],y=t[1];let e=c,n=y;for(let r=x;r<i;r+=x){const x=t[r],o=t[r+1];x<c&&(c=x),o<y&&(y=o),x>e&&(e=x),o>n&&(n=o)}h=Math.max(e-c,n-y),h=0!==h?32767/h:0}return r(f,l,x,c,y,h,0),l}function e(t,e,n,r,x){let o;if(x===function(t,e,n,r){let x=0;for(let o=e,i=n-r;o<n;o+=r)x+=(t[i]-t[o])*(t[o+1]+t[i+1]),i=o;return x}(t,e,n,r)>0)for(let x=e;x<n;x+=r)o=d(x/r|0,t[x],t[x+1],o);else for(let x=n-r;x>=e;x-=r)o=d(x/r|0,t[x],t[x+1],o);return o&&b(o,o.next)&&(w(o),o=o.next),o}function n(t,e){if(!t)return t;e||(e=t);let n,r=t;do{if(n=!1,r.steiner||!b(r,r.next)&&0!==v(r.prev,r,r.next))r=r.next;else{if(w(r),r=e=r.prev,r===r.next)break;n=!0}}while(n||r!==e);return e}function r(t,e,u,s,l,a,y){if(!t)return;!y&&a&&function(t,e,n,r){let x=t;do{0===x.z&&(x.z=c(x.x,x.y,e,n,r)),x.prevZ=x.prev,x.nextZ=x.next,x=x.next}while(x!==t);x.prevZ.nextZ=null,x.prevZ=null,function(t){let e,n=1;do{let r,x=t;t=null;let o=null;for(e=0;x;){e++;let i=x,f=0;for(let t=0;t<n&&(f++,i=i.nextZ,i);t++);let u=n;for(;f>0||u>0&&i;)0!==f&&(0===u||!i||x.z<=i.z)?(r=x,x=x.nextZ,f--):(r=i,i=i.nextZ,u--),o?o.nextZ=r:t=r,r.prevZ=o,o=r;x=i}o.nextZ=null,n*=2}while(e>1)}(x)}(t,s,l,a);let h=t;for(;t.prev!==t.next;){const c=t.prev,p=t.next;if(a?o(t,s,l,a):x(t))e.push(c.i,t.i,p.i),w(t),t=p.next,h=p.next;else if((t=p)===h){y?1===y?r(t=i(n(t),e),e,u,s,l,a,2):2===y&&f(t,e,u,s,l,a):r(n(t),e,u,s,l,a,1);break}}}function x(t){const e=t.prev,n=t,r=t.next;if(v(e,n,r)>=0)return!1;const x=e.x,o=n.x,i=r.x,f=e.y,u=n.y,s=r.y,l=Math.min(x,o,i),c=Math.min(f,u,s),a=Math.max(x,o,i),y=Math.max(f,u,s);let p=r.next;for(;p!==e;){if(p.x>=l&&p.x<=a&&p.y>=c&&p.y<=y&&h(x,f,o,u,i,s,p.x,p.y)&&v(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function o(t,e,n,r){const x=t.prev,o=t,i=t.next;if(v(x,o,i)>=0)return!1;const f=x.x,u=o.x,s=i.x,l=x.y,a=o.y,y=i.y,p=Math.min(f,u,s),b=Math.min(l,a,y),M=Math.max(f,u,s),m=Math.max(l,a,y),A=c(p,b,e,n,r),g=c(M,m,e,n,r);let Z=t.prevZ,d=t.nextZ;for(;Z&&Z.z>=A&&d&&d.z<=g;){if(Z.x>=p&&Z.x<=M&&Z.y>=b&&Z.y<=m&&Z!==x&&Z!==i&&h(f,l,u,a,s,y,Z.x,Z.y)&&v(Z.prev,Z,Z.next)>=0)return!1;if(Z=Z.prevZ,d.x>=p&&d.x<=M&&d.y>=b&&d.y<=m&&d!==x&&d!==i&&h(f,l,u,a,s,y,d.x,d.y)&&v(d.prev,d,d.next)>=0)return!1;d=d.nextZ}for(;Z&&Z.z>=A;){if(Z.x>=p&&Z.x<=M&&Z.y>=b&&Z.y<=m&&Z!==x&&Z!==i&&h(f,l,u,a,s,y,Z.x,Z.y)&&v(Z.prev,Z,Z.next)>=0)return!1;Z=Z.prevZ}for(;d&&d.z<=g;){if(d.x>=p&&d.x<=M&&d.y>=b&&d.y<=m&&d!==x&&d!==i&&h(f,l,u,a,s,y,d.x,d.y)&&v(d.prev,d,d.next)>=0)return!1;d=d.nextZ}return!0}function i(t,e){let r=t;do{const n=r.prev,x=r.next.next;!b(n,x)&&M(n,r,r.next,x)&&g(n,x)&&g(x,n)&&(e.push(n.i,r.i,x.i),w(r),w(r.next),r=t=x),r=r.next}while(r!==t);return n(r)}function f(t,e,x,o,i,f){let u=t;do{let t=u.next.next;for(;t!==u.prev;){if(u.i!==t.i&&p(u,t)){let s=Z(u,t);return u=n(u,u.next),s=n(s,s.next),r(u,e,x,o,i,f,0),void r(s,e,x,o,i,f,0)}t=t.next}u=u.next}while(u!==t)}function u(t,e){let n=t.x-e.x;if(0===n&&(n=t.y-e.y,0===n)){n=(t.next.y-t.y)/(t.next.x-t.x)-(e.next.y-e.y)/(e.next.x-e.x)}return n}function s(t,e){const r=function(t,e){let n=e;const r=t.x,x=t.y;let o,i=-1/0;if(b(t,n))return n;do{if(b(t,n.next))return n.next;if(x<=n.y&&x>=n.next.y&&n.next.y!==n.y){const t=n.x+(x-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(t<=r&&t>i&&(i=t,o=n.x<n.next.x?n:n.next,t===r))return o}n=n.next}while(n!==e);if(!o)return null;const f=o,u=o.x,s=o.y;let c=1/0;n=o;do{if(r>=n.x&&n.x>=u&&r!==n.x&&y(x<s?r:i,x,u,s,x<s?i:r,x,n.x,n.y)){const e=Math.abs(x-n.y)/(r-n.x);g(n,t)&&(e<c||e===c&&(n.x>o.x||n.x===o.x&&l(o,n)))&&(o=n,c=e)}n=n.next}while(n!==f);return o}(t,e);if(!r)return e;const x=Z(r,t);return n(x,x.next),n(r,r.next)}function l(t,e){return v(t.prev,t,e.prev)<0&&v(e.next,t,t.next)<0}function c(t,e,n,r,x){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-n)*x|0)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-r)*x|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function a(t){let e=t,n=t;do{(e.x<n.x||e.x===n.x&&e.y<n.y)&&(n=e),e=e.next}while(e!==t);return n}function y(t,e,n,r,x,o,i,f){return(x-i)*(e-f)>=(t-i)*(o-f)&&(t-i)*(r-f)>=(n-i)*(e-f)&&(n-i)*(o-f)>=(x-i)*(r-f)}function h(t,e,n,r,x,o,i,f){return!(t===i&&e===f)&&y(t,e,n,r,x,o,i,f)}function p(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){let n=t;do{if(n.i!==t.i&&n.next.i!==t.i&&n.i!==e.i&&n.next.i!==e.i&&M(n,n.next,t,e))return!0;n=n.next}while(n!==t);return!1}(t,e)&&(g(t,e)&&g(e,t)&&function(t,e){let n=t,r=!1;const x=(t.x+e.x)/2,o=(t.y+e.y)/2;do{n.y>o!=n.next.y>o&&n.next.y!==n.y&&x<(n.next.x-n.x)*(o-n.y)/(n.next.y-n.y)+n.x&&(r=!r),n=n.next}while(n!==t);return r}(t,e)&&(v(t.prev,t,e.prev)||v(t,e.prev,e))||b(t,e)&&v(t.prev,t,t.next)>0&&v(e.prev,e,e.next)>0)}function v(t,e,n){return(e.y-t.y)*(n.x-e.x)-(e.x-t.x)*(n.y-e.y)}function b(t,e){return t.x===e.x&&t.y===e.y}function M(t,e,n,r){const x=A(v(t,e,n)),o=A(v(t,e,r)),i=A(v(n,r,t)),f=A(v(n,r,e));return x!==o&&i!==f||(!(0!==x||!m(t,n,e))||(!(0!==o||!m(t,r,e))||(!(0!==i||!m(n,t,r))||!(0!==f||!m(n,e,r)))))}function m(t,e,n){return e.x<=Math.max(t.x,n.x)&&e.x>=Math.min(t.x,n.x)&&e.y<=Math.max(t.y,n.y)&&e.y>=Math.min(t.y,n.y)}function A(t){return t>0?1:t<0?-1:0}function g(t,e){return v(t.prev,t,t.next)<0?v(t,e,t.next)>=0&&v(t,t.prev,e)>=0:v(t,e,t.prev)<0||v(t,t.next,e)<0}function Z(t,e){const n=F(t.i,t.x,t.y),r=F(e.i,e.x,e.y),x=t.next,o=e.prev;return t.next=e,e.prev=t,n.next=x,x.prev=n,r.next=n,n.prev=r,o.next=r,r.prev=o,r}function d(t,e,n,r){const x=F(t,e,n);return r?(x.next=r.next,x.prev=r,r.next.prev=x,r.next=x):(x.prev=x,x.next=x),x}function w(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 F(t,e,n){return{i:t,x:e,y:n,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function E(t,e,n){const r=Math.sqrt((e[0]-t[0])*(e[0]-t[0])+(e[1]-t[1])*(e[1]-t[1])),x=[(e[0]-t[0])/r,(e[1]-t[1])/r],o=[-x[1],x[0]],i=Math.sqrt((n[0]-t[0])*(n[0]-t[0])+(n[1]-t[1])*(n[1]-t[1])),f=[(n[0]-t[0])/i,(n[1]-t[1])/i];let u=0===r||0===i?0:Math.acos((s=f[0]*x[0]+f[1]*x[1],l=-1,c=1,Math.min(Math.max(s,l),c)));var s,l,c;u=Math.max(u,1e-5);return f[0]*o[0]+f[1]*o[1]>0?u:2*Math.PI-u}function I(t,e){const n=e[0],r=e[1];return e[0]=t[0]*n+t[2]*r+t[4],e[1]=t[1]*n+t[3]*r+t[5],e}function z(t,e){const n=(r=e)[0]*r[3]-r[1]*r[2];var r;!function(t,e){if(!t)throw new Error(e)}(0!==n,"Transformation matrix cannot be inverted");const x=e[0],o=e[1],i=e[2],f=e[3],u=e[4],s=e[5];return t[0]=f/n,t[1]=-o/n,t[2]=-i/n,t[3]=x/n,t[4]=(i*s-f*u)/n,t[5]=-(x*s-o*u)/n,t}new Array(6);const B=[],P={vertexAttributesPosition:0,instanceAttributesPosition:0,indicesPosition:0};function N(t,e,n,r,x){const o=t[e++],i=t[e++],f=B;f.length=r;for(let n=0;n<f.length;n++)f[n]=t[e+n];let u=x?x.instanceAttributesPosition:0;return n[u++]=o,n[u++]=i,f.length&&(n.set(f,u),u+=f.length),P.instanceAttributesPosition=u,P}function R(t,e,n,r,x,o,i,f,u,s){const l=[t[e],t[e+1]],c=[t[n],t[n+1]],a=t[e+2],y=t[n+2],h=I(f,[...l]),p=I(f,[...c]);let v=-1,b=-1,M=s;const m=null!==x;if(null!==r){v=E(h,p,I(f,[...[t[r],t[r+1]]])),Math.cos(v)<=.985&&(M+=Math.tan((v-Math.PI)/2))}if(m){b=E(p,h,I(f,[...[t[x],t[x+1]]])),Math.cos(b)<=.985&&(M+=Math.tan((Math.PI-b)/2))}const A=Math.pow(2,24),g=u%A,Z=Math.floor(u/A)*A;return o.push(l[0],l[1],a,c[0],c[1],y,v,b,g,Z,s),o.push(...i),{length:u+Math.sqrt((p[0]-h[0])*(p[0]-h[0])+(p[1]-h[1])*(p[1]-h[1])),angle:M}}function S(e,n,r,x,o){const i=2+o;let f=n;const u=e.slice(f,f+o);f+=o;const s=e[f++];let l=0;const c=new Array(s-1);for(let t=0;t<s;t++)l+=e[f++],t<s-1&&(c[t]=l);const a=e.slice(f,f+2*l),y=t(a,c,2);for(let t=0;t<y.length;t++)x.push(y[t]+r.length/i);for(let t=0;t<a.length;t+=2)r.push(a[t],a[t+1],...u);return f+2*l}const T="GENERATE_POLYGON_BUFFERS",_="GENERATE_POINT_BUFFERS",O="GENERATE_LINE_STRING_BUFFERS",U=self;U.onmessage=t=>{const e=t.data;switch(e.type){case _:{const t=2,n=2,r=e.customAttributesSize,x=n+r,o=new Float32Array(e.renderInstructions),i=o.length/x*(t+r),f=Uint32Array.from([0,1,3,1,2,3]),u=Float32Array.from([-1,-1,1,-1,1,1,-1,1]),s=new Float32Array(i);let l;for(let t=0;t<o.length;t+=x)l=N(o,t,s,r,l);const c=Object.assign({indicesBuffer:f.buffer,vertexAttributesBuffer:u.buffer,instanceAttributesBuffer:s.buffer,renderInstructions:o.buffer},e);U.postMessage(c,[u.buffer,s.buffer,f.buffer,o.buffer]);break}case O:{const t=[],n=e.customAttributesSize,r=3,x=new Float32Array(e.renderInstructions);let o=0;const i=[1,0,0,1,0,0];let f,u;for(z(i,e.renderInstructionsTransform);o<x.length;){u=Array.from(x.slice(o,o+n)),o+=n,f=x[o++];const e=o,s=o+(f-1)*r,l=x[e]===x[s]&&x[e+1]===x[s+1];let c=0,a=0;for(let n=0;n<f-1;n++){let y=null;n>0?y=o+(n-1)*r:l&&(y=s-r);let h=null;n<f-2?h=o+(n+2)*r:l&&(h=e+r);const p=R(x,o+n*r,o+(n+1)*r,y,h,t,u,i,c,a);c=p.length,a=p.angle}o+=f*r}const s=Uint32Array.from([0,1,3,1,2,3]),l=Float32Array.from([-1,-1,1,-1,1,1,-1,1]),c=Float32Array.from(t),a=Object.assign({indicesBuffer:s.buffer,vertexAttributesBuffer:l.buffer,instanceAttributesBuffer:c.buffer,renderInstructions:x.buffer},e);U.postMessage(a,[l.buffer,c.buffer,s.buffer,x.buffer]);break}case T:{const t=[],n=[],r=e.customAttributesSize,x=new Float32Array(e.renderInstructions);let o=0;for(;o<x.length;)o=S(x,o,t,n,r);const i=Uint32Array.from(n),f=Float32Array.from(t),u=Float32Array.from([]),s=Object.assign({indicesBuffer:i.buffer,vertexAttributesBuffer:f.buffer,instanceAttributesBuffer:u.buffer,renderInstructions:x.buffer},e);U.postMessage(s,[f.buffer,u.buffer,i.buffer,x.buffer]);break}}};';return new Worker("undefined"==typeof Blob?"data:application/javascript;base64,"+Buffer.from(t,"binary").toString("base64"):URL.createObjectURL(new Blob([t],{type:"application/javascript"})))}const hC="GENERATE_POLYGON_BUFFERS",cC="GENERATE_POINT_BUFFERS",uC="GENERATE_LINE_STRING_BUFFERS";function dC(t,e){e=e||[];const n=256,i=255,r=Math.floor(t/n/n/n)/i,s=Math.floor(t/n/n)%n/i,o=Math.floor(t/n)%n/i,a=t%n/i;return e[0]=256*r*255+255*s,e[1]=256*o*255+255*a,e}function fC(t){let e=0;const n=256,i=255;return e+=Math.round(t[0]*n*n*n*i),e+=Math.round(t[1]*n*n*i),e+=Math.round(t[2]*n*i),e+=Math.round(t[3]*i),e}function gC(t,e,n,i){let r=0;for(const s in e){const o=e[s],a=o.callback.call(n,n.feature);let l=a?.[0]??a;l===XS&&console.warn('The "has" operator might return false positives.'),void 0===l?l=XS:null===l&&(l=0),t[i+r++]=l,o.size&&1!==o.size&&(t[i+r++]=a[1],o.size<3||(t[i+r++]=a[2],o.size<4||(t[i+r++]=a[3])))}return r}function pC(t){return Object.keys(t).reduce((e,n)=>e+(t[n].size||1),0)}function mC(t){return(JSON.stringify(t).split("").reduce((t,e)=>(t<<5)-t+e.charCodeAt(0),0)>>>0).toString()}function _C(t,e,n,i){if(`${i}radius`in t&&"icon-"!==i){let r=KS(n,t[`${i}radius`],Oc);if(`${i}radius2`in t){r=`max(${r}, ${KS(n,t[`${i}radius2`],Oc)})`}`${i}stroke-width`in t&&(r=`(${r} + ${KS(n,t[`${i}stroke-width`],Oc)} * 0.5)`),e.setSymbolSizeExpression(`vec2(${r} * 2. + 0.5)`)}if(`${i}scale`in t){const r=KS(n,t[`${i}scale`],Gc);e.setSymbolSizeExpression(`${e.getSymbolSizeExpression()} * ${r}`)}`${i}displacement`in t&&e.setSymbolOffsetExpression(KS(n,t[`${i}displacement`],jc)),`${i}rotation`in t&&e.setSymbolRotationExpression(KS(n,t[`${i}rotation`],Oc)),`${i}rotate-with-view`in t&&e.setSymbolRotateWithView(!!t[`${i}rotate-with-view`])}function yC(t,e,n,i,r){let s="vec4(0.)";if(null!==e&&(s=e),null!==n&&null!==i){s=`mix(${n}, ${s}, ${`smoothstep(-${i} + 0.63, -${i} - 0.58, ${t})`})`}let o=`${s} * vec4(1.0, 1.0, 1.0, ${`(1.0 - smoothstep(-0.63, 0.58, ${t}))`})`;return null!==r&&(o=`${o} * vec4(1.0, 1.0, 1.0, ${r})`),o}function xC(t,e,n,i,r){const s=new Image;s.crossOrigin=void 0===t[`${i}cross-origin`]?"anonymous":t[`${i}cross-origin`],ir("string"==typeof t[`${i}src`],`WebGL layers do not support expressions for the ${i}src style property`),s.src=t[`${i}src`],n[`u_texture${r}_size`]=()=>s.complete?[s.width,s.height]:[0,0],e.addUniform(`u_texture${r}_size`,"vec2");const o=`u_texture${r}_size`;return n[`u_texture${r}`]=s,e.addUniform(`u_texture${r}`,"sampler2D"),o}function vC(t,e,n,i,r){let s=KS(n,t[`${e}offset`],Gc);if(`${e}offset-origin`in t)switch(t[`${e}offset-origin`]){case"top-right":s=`vec2(${i}.x, 0.) + ${r} * vec2(-1., 0.) + ${s} * vec2(-1., 1.)`;break;case"bottom-left":s=`vec2(0., ${i}.y) + ${r} * vec2(0., -1.) + ${s} * vec2(1., -1.)`;break;case"bottom-right":s=`${i} - ${r} - ${s}`}return s}function bC(t,e,n){const i={variables:{},properties:{},functions:{},bandCount:0,featureId:!1,geometryType:!1},r=new oC,s={};if("icon-src"in t?function(t,e,n,i){let r="vec4(1.0)";"icon-color"in t&&(r=KS(i,t["icon-color"],Nc)),"icon-opacity"in t&&(r=`${r} * vec4(1.0, 1.0, 1.0, ${KS(i,t["icon-opacity"],Oc)})`);const s=mC(t["icon-src"]),o=xC(t,e,n,"icon-",s);if(e.setSymbolColorExpression(`${r} * texture2D(u_texture${s}, v_texCoord)`).setSymbolSizeExpression(o),"icon-width"in t&&"icon-height"in t&&e.setSymbolSizeExpression(`vec2(${KS(i,t["icon-width"],Oc)}, ${KS(i,t["icon-height"],Oc)})`),"icon-offset"in t&&"icon-size"in t){const n=KS(i,t["icon-size"],jc),r=e.getSymbolSizeExpression();e.setSymbolSizeExpression(n);const s=vC(t,"icon-",i,"v_quadSizePx",n);e.setTextureCoordinateExpression(`(vec4((${s}).xyxy) + vec4(0., 0., ${n})) / (${r}).xyxy`)}if(_C(t,e,i,"icon-"),"icon-anchor"in t){const n=KS(i,t["icon-anchor"],jc);let r,s="1.0";"icon-scale"in t&&(s=KS(i,t["icon-scale"],Gc)),r="pixels"===t["icon-anchor-x-units"]&&"pixels"===t["icon-anchor-y-units"]?`${n} * ${s}`:"pixels"===t["icon-anchor-x-units"]?`${n} * vec2(vec2(${s}).x, v_quadSizePx.y)`:"pixels"===t["icon-anchor-y-units"]?`${n} * vec2(v_quadSizePx.x, vec2(${s}).x)`:`${n} * v_quadSizePx`;let o=`v_quadSizePx * vec2(0.5, -0.5) + ${r} * vec2(-1., 1.)`;if("icon-anchor-origin"in t)switch(t["icon-anchor-origin"]){case"top-right":o=`v_quadSizePx * -0.5 + ${r}`;break;case"bottom-left":o=`v_quadSizePx * 0.5 - ${r}`;break;case"bottom-right":o=`v_quadSizePx * vec2(-0.5, 0.5) + ${r} * vec2(1., -1.)`}e.setSymbolOffsetExpression(`${e.getSymbolOffsetExpression()} + ${o}`)}}(t,r,s,i):"shape-points"in t?function(t,e,n,i){i.functions.round="float round(float v) {\n return sign(v) * floor(abs(v) + 0.5);\n}",i.functions.starDistanceField="float starDistanceField(vec2 point, float numPoints, float radius, float radius2, float angle) {\n float startAngle = -PI * 0.5 + angle; // tip starts upwards and rotates clockwise with angle\n float c = cos(startAngle);\n float s = sin(startAngle);\n vec2 pointRotated = vec2(c * point.x - s * point.y, s * point.x + c * point.y);\n float alpha = TWO_PI / numPoints; // the angle of one sector\n float beta = atan(pointRotated.y, pointRotated.x);\n float gamma = round(beta / alpha) * alpha; // angle in sector\n c = cos(-gamma);\n s = sin(-gamma);\n vec2 inSector = vec2(c * pointRotated.x - s * pointRotated.y, abs(s * pointRotated.x + c * pointRotated.y));\n vec2 tipToPoint = inSector + vec2(-radius, 0.);\n vec2 edgeNormal = vec2(radius2 * sin(alpha * 0.5), -radius2 * cos(alpha * 0.5) + radius);\n return dot(normalize(edgeNormal), tipToPoint);\n}",i.functions.regularDistanceField="float regularDistanceField(vec2 point, float numPoints, float radius, float angle) {\n float startAngle = -PI * 0.5 + angle; // tip starts upwards and rotates clockwise with angle\n float c = cos(startAngle);\n float s = sin(startAngle);\n vec2 pointRotated = vec2(c * point.x - s * point.y, s * point.x + c * point.y);\n float alpha = TWO_PI / numPoints; // the angle of one sector\n float radiusIn = radius * cos(PI / numPoints);\n float beta = atan(pointRotated.y, pointRotated.x);\n float gamma = round((beta - alpha * 0.5) / alpha) * alpha + alpha * 0.5; // angle in sector from mid\n c = cos(-gamma);\n s = sin(-gamma);\n vec2 inSector = vec2(c * pointRotated.x - s * pointRotated.y, abs(s * pointRotated.x + c * pointRotated.y));\n return inSector.x - radiusIn;\n}",_C(t,e,i,"shape-");let r=null;"shape-opacity"in t&&(r=KS(i,t["shape-opacity"],Oc));let s="coordsPx";"shape-scale"in t&&(s=`coordsPx / ${KS(i,t["shape-scale"],Gc)}`);let o=null;"shape-fill-color"in t&&(o=KS(i,t["shape-fill-color"],Nc));let a=null;"shape-stroke-color"in t&&(a=KS(i,t["shape-stroke-color"],Nc));let l=null;"shape-stroke-width"in t&&(l=KS(i,t["shape-stroke-width"],Oc));const h=KS(i,t["shape-points"],Oc);let c,u="0.";"shape-angle"in t&&(u=KS(i,t["shape-angle"],Oc));let d=KS(i,t["shape-radius"],Oc);if(null!==l&&(d=`${d} + ${l} * 0.5`),"shape-radius2"in t){let e=KS(i,t["shape-radius2"],Oc);null!==l&&(e=`${e} + ${l} * 0.5`),c=`starDistanceField(${s}, ${h}, ${d}, ${e}, ${u})`}else c=`regularDistanceField(${s}, ${h}, ${d}, ${u})`;const f=yC(c,o,a,l,r);e.setSymbolColorExpression(f)}(t,r,0,i):"circle-radius"in t&&function(t,e,n,i){i.functions.circleDistanceField="float circleDistanceField(vec2 point, float radius) {\n return length(point) - radius;\n}",_C(t,e,i,"circle-");let r=null;"circle-opacity"in t&&(r=KS(i,t["circle-opacity"],Oc));let s="coordsPx";"circle-scale"in t&&(s=`coordsPx / ${KS(i,t["circle-scale"],Gc)}`);let o=null;"circle-fill-color"in t&&(o=KS(i,t["circle-fill-color"],Nc));let a=null;"circle-stroke-color"in t&&(a=KS(i,t["circle-stroke-color"],Nc));let l=KS(i,t["circle-radius"],Oc),h=null;"circle-stroke-width"in t&&(h=KS(i,t["circle-stroke-width"],Oc),l=`(${l} + ${h} * 0.5)`);const c=yC(`circleDistanceField(${s}, ${l})`,o,a,h,r);e.setSymbolColorExpression(c)}(t,r,0,i),function(t,e,n,i){if("stroke-color"in t&&e.setStrokeColorExpression(KS(i,t["stroke-color"],Nc)),"stroke-pattern-src"in t){const r=mC(t["stroke-pattern-src"]),s=xC(t,e,n,"stroke-pattern-",r);let o=s,a="vec2(0.)";"stroke-pattern-offset"in t&&"stroke-pattern-size"in t&&(o=KS(i,t["stroke-pattern-size"],jc),a=vC(t,"stroke-pattern-",i,s,o));let l="0.";"stroke-pattern-spacing"in t&&(l=KS(i,t["stroke-pattern-spacing"],Oc));let h="0.";"stroke-pattern-start-offset"in t&&(h=KS(i,t["stroke-pattern-start-offset"],Oc)),i.functions.sampleStrokePattern="vec4 sampleStrokePattern(sampler2D texture, vec2 textureSize, vec2 textureOffset, vec2 sampleSize, float spacingPx, float startOffsetPx, float currentLengthPx, float currentRadiusRatio, float lineWidth) {\n float currentLengthScaled = (currentLengthPx - startOffsetPx) * sampleSize.y / lineWidth;\n float spacingScaled = spacingPx * sampleSize.y / lineWidth;\n float uCoordPx = mod(currentLengthScaled, (sampleSize.x + spacingScaled));\n float isInsideOfPattern = step(uCoordPx, sampleSize.x);\n float vCoordPx = (-currentRadiusRatio * 0.5 + 0.5) * sampleSize.y;\n // make sure that we're not sampling too close to the borders to avoid interpolation with outside pixels\n uCoordPx = clamp(uCoordPx, 0.5, sampleSize.x - 0.5);\n vCoordPx = clamp(vCoordPx, 0.5, sampleSize.y - 0.5);\n vec2 texCoord = (vec2(uCoordPx, vCoordPx) + textureOffset) / textureSize;\n return texture2D(texture, texCoord) * vec4(1.0, 1.0, 1.0, isInsideOfPattern);\n}";const c=`u_texture${r}`;let u="1.";"stroke-color"in t&&(u=e.getStrokeColorExpression()),e.setStrokeColorExpression(`${u} * sampleStrokePattern(${c}, ${s}, ${a}, ${o}, ${l}, ${h}, currentLengthPx, currentRadiusRatio, v_width)`),i.functions.computeStrokePatternLength="float computeStrokePatternLength(vec2 sampleSize, float spacingPx, float lineWidth) {\n float patternLengthPx = sampleSize.x / sampleSize.y * lineWidth;\n return patternLengthPx + spacingPx;\n}",e.setStrokePatternLengthExpression(`computeStrokePatternLength(${o}, ${l}, v_width)`)}if("stroke-width"in t&&e.setStrokeWidthExpression(KS(i,t["stroke-width"],Oc)),"stroke-offset"in t&&e.setStrokeOffsetExpression(KS(i,t["stroke-offset"],Oc)),"stroke-line-cap"in t&&e.setStrokeCapExpression(KS(i,t["stroke-line-cap"],zc)),"stroke-line-join"in t&&e.setStrokeJoinExpression(KS(i,t["stroke-line-join"],zc)),"stroke-miter-limit"in t&&e.setStrokeMiterLimitExpression(KS(i,t["stroke-miter-limit"],Oc)),"stroke-line-dash"in t){i.functions.getSingleDashDistance=`float getSingleDashDistance(float distance, float radius, float dashOffset, float dashLength, float dashLengthTotal, float capType, float lineWidth) {\n float localDistance = mod(distance, dashLengthTotal);\n float distanceSegment = abs(localDistance - dashOffset - dashLength * 0.5) - dashLength * 0.5;\n distanceSegment = min(distanceSegment, dashLengthTotal - localDistance);\n if (capType == ${GS("square")}) {\n distanceSegment -= lineWidth * 0.5;\n } else if (capType == ${GS("round")}) {\n distanceSegment = min(distanceSegment, sqrt(distanceSegment * distanceSegment + radius * radius) - lineWidth * 0.5);\n }\n return distanceSegment;\n}`;let n=t["stroke-line-dash"].map(t=>KS(i,t,Oc));n.length%2==1&&(n=[...n,...n]);let r="0.";"stroke-line-dash-offset"in t&&(r=KS(i,t["stroke-line-dash-offset"],Oc));const s=`dashDistanceField_${mC(t["stroke-line-dash"])}`,o=n.map((t,e)=>`float dashLength${e}`).join(", "),a=n.map((t,e)=>`dashLength${e}`).join(" + ");let l="0.",h=`getSingleDashDistance(distance, radius, ${l}, dashLength0, totalDashLength, capType, lineWidth)`;for(let t=2;t<n.length;t+=2)l=`${l} + dashLength${t-2} + dashLength${t-1}`,h=`min(${h}, getSingleDashDistance(distance, radius, ${l}, dashLength${t}, totalDashLength, capType, lineWidth))`;i.functions[s]=`float ${s}(float distance, float radius, float capType, float lineWidth, ${o}) {\n float totalDashLength = ${a};\n return ${h};\n}`;const c=n.map((t,e)=>`${t}`).join(", ");e.setStrokeDistanceFieldExpression(`${s}(currentLengthPx + ${r}, currentRadiusPx, capType, v_width, ${c})`);let u=n.join(" + ");e.getStrokePatternLengthExpression()&&(i.functions.combinePatternLengths="float combinePatternLengths(float patternLength1, float patternLength2) {\n return patternLength1 * patternLength2;\n}",u=`combinePatternLengths(${e.getStrokePatternLengthExpression()}, ${u})`),e.setStrokePatternLengthExpression(u)}}(t,r,s,i),function(t,e,n,i){if("fill-color"in t&&e.setFillColorExpression(KS(i,t["fill-color"],Nc)),"fill-pattern-src"in t){const r=mC(t["fill-pattern-src"]),s=xC(t,e,n,"fill-pattern-",r);e.setFillPatternSizeExpression(s);let o="vec2(0.)";if("fill-pattern-offset"in t&&"fill-pattern-size"in t){const n=KS(i,t["fill-pattern-size"],jc);e.setFillPatternSizeExpression(n),o=vC(t,"fill-pattern-",i,s,"v_patternSizePx")}i.functions.sampleFillPattern="vec4 sampleFillPattern(sampler2D texture, vec2 textureSize, vec2 textureOffset, vec2 sampleSize, vec2 patternOriginPx, vec2 pxPosition, float sampleScaleRatio) {\n vec2 pxRelativePos = pxPosition - patternOriginPx;\n\n // rotate the relative position from origin by the current view rotation\n pxRelativePos = vec2(pxRelativePos.x * cos(u_rotation) - pxRelativePos.y * sin(u_rotation), pxRelativePos.x * sin(u_rotation) + pxRelativePos.y * cos(u_rotation));\n // sample position is computed according to the sample offset & size\n vec2 samplePos = mod(pxRelativePos / sampleScaleRatio, sampleSize);\n // also make sure that we're not sampling too close to the borders to avoid interpolation with outside pixels\n samplePos = clamp(samplePos, vec2(0.5), sampleSize - vec2(0.5));\n samplePos.y = sampleSize.y - samplePos.y; // invert y axis so that images appear upright\n return texture2D(texture, (samplePos + textureOffset) / textureSize);\n}";const a=`u_texture${r}`;let l="1.";"fill-color"in t&&(l=e.getFillColorExpression()),e.setFillColorExpression(`${l} * sampleFillPattern(${a}, ${s}, ${o}, v_patternSizePx, v_patternOriginPx, pxPos, df_float(u_df_patternScaleRatio))`)}}(t,r,s,i),n){const t=Kc(),e=KS(i,n,Dc,t);t.mCoordinate?r.setFragmentDiscardExpression(`!${e}`):r.setShapeDiscardExpression(`!${e}`)}const o={};function a(t,e,n,s){if(!i[t])return;const a=JS(n),l=HS(n);r.addAttribute(`a_${e}`,a),o[e]={size:l,callback:s}}return a("geometryType",VS,zc,t=>jS(Qu(t.getGeometry()))),a("featureId",US,zc|Oc,t=>{const e=t.getId()??null;return"string"==typeof e?jS(e):e}),QS(r,i),{builder:r,attributes:{...o,...eC(i)},uniforms:{...s,...tC(i,e)}}}const wC=[];let SC;function CC(){return SC||(SC=lC()),SC}let EC=0;const PC="a_position",TC="a_localPosition",RC="a_segmentStart",FC="a_segmentEnd",MC="a_measureStart",IC="a_measureEnd",kC="a_angleTangentSum",LC="a_joinAngles",AC="a_distanceLow",DC="a_distanceHigh";class OC{constructor(t,e,n,i){this.helper_,this.hitDetectionEnabled_=!!i,this.styleShaders=function(t,e){const n=Array.isArray(t)?t:[t];if("style"in n[0]){const t=[],i=n,r=[];for(const n of i){const i=Array.isArray(n.style)?n.style:[n.style];let s=n.filter;n.else&&r.length&&(s=["all",...r.map(t=>["!",t])],n.filter&&s.push(n.filter),s.length<3&&(s=s[1])),n.filter&&r.push(n.filter);const o=i.map(t=>bC(t,e,s));t.push(...o)}return t}if("builder"in n[0])return n;return n.map(t=>bC(t,e,null))}(t,e),this.customAttributes_={},this.uniforms_={},this.hitDetectionEnabled_&&(this.customAttributes_.hitColor={callback(){return dC(this.ref,wC)},size:2});for(const t of this.styleShaders){for(const e in t.attributes)e in this.customAttributes_||(this.customAttributes_[e]=t.attributes[e]);for(const e in t.uniforms)e in this.uniforms_||(this.uniforms_[e]=t.uniforms[e])}this.renderPasses_=this.styleShaders.map(t=>{const e={},n=Object.entries(this.customAttributes_).map(([e,n])=>({name:e in t.attributes||"hitColor"===e?`a_${e}`:null,size:n.size||1,type:wS}));return t.builder.getFillVertexShader()&&(e.fillRenderPass={vertexShader:t.builder.getFillVertexShader(),fragmentShader:t.builder.getFillFragmentShader(),attributesDesc:[{name:PC,size:2,type:wS},...n],instancedAttributesDesc:[],instancePrimitiveVertexCount:3}),t.builder.getStrokeVertexShader()&&(e.strokeRenderPass={vertexShader:t.builder.getStrokeVertexShader(),fragmentShader:t.builder.getStrokeFragmentShader(),attributesDesc:[{name:TC,size:2,type:wS}],instancedAttributesDesc:[{name:RC,size:2,type:wS},{name:MC,size:1,type:wS},{name:FC,size:2,type:wS},{name:IC,size:1,type:wS},{name:LC,size:2,type:wS},{name:AC,size:1,type:wS},{name:DC,size:1,type:wS},{name:kC,size:1,type:wS},...n],instancePrimitiveVertexCount:6}),t.builder.getSymbolVertexShader()&&(e.symbolRenderPass={vertexShader:t.builder.getSymbolVertexShader(),fragmentShader:t.builder.getSymbolFragmentShader(),attributesDesc:[{name:TC,size:2,type:wS}],instancedAttributesDesc:[{name:PC,size:2,type:wS},...n],instancePrimitiveVertexCount:6}),e}),this.hasFill_=this.renderPasses_.some(t=>t.fillRenderPass),this.hasStroke_=this.renderPasses_.some(t=>t.strokeRenderPass),this.hasSymbol_=this.renderPasses_.some(t=>t.symbolRenderPass),this.setHelper(n)}async generateBuffers(t,e){if(t.isEmpty())return null;const n=this.generateRenderInstructions_(t,e),[i,r,s]=await Promise.all([this.generateBuffersForType_(n.polygonInstructions,"Polygon",e),this.generateBuffersForType_(n.lineStringInstructions,"LineString",e),this.generateBuffersForType_(n.pointInstructions,"Point",e)]);return{polygonBuffers:i,lineStringBuffers:r,pointBuffers:s,invertVerticesTransform:la([1,0,0,1,0,0],e)}}generateRenderInstructions_(t,e){const n=this.hasFill_?function(t,e,n,i){const r=2*t.verticesCount+(1+pC(n))*t.geometriesCount+t.ringsCount;e&&e.length===r||(e=new Float32Array(r));const s=[];let o=0;for(const r in t.entries){const a=t.entries[r];for(let t=0,r=a.flatCoordss.length;t<r;t++){s.length=a.flatCoordss[t].length,ua(a.flatCoordss[t],0,s.length,2,i,s),o+=gC(e,n,a,o),e[o++]=a.ringsVerticesCounts[t].length;for(let n=0,i=a.ringsVerticesCounts[t].length;n<i;n++)e[o++]=a.ringsVerticesCounts[t][n];for(let t=0,n=s.length;t<n;t+=2)e[o++]=s[t],e[o++]=s[t+1]}}return e}(t.polygonBatch,new Float32Array(0),this.customAttributes_,e):null,i=this.hasStroke_?function(t,e,n,i){const r=3*t.verticesCount+(1+pC(n))*t.geometriesCount;e&&e.length===r||(e=new Float32Array(r));const s=[];let o=0;for(const r in t.entries){const a=t.entries[r];for(let t=0,r=a.flatCoordss.length;t<r;t++){s.length=a.flatCoordss[t].length,ua(a.flatCoordss[t],0,s.length,3,i,s,3),o+=gC(e,n,a,o),e[o++]=s.length/3;for(let t=0,n=s.length;t<n;t+=3)e[o++]=s[t],e[o++]=s[t+1],e[o++]=s[t+2]}}return e}(t.lineStringBatch,new Float32Array(0),this.customAttributes_,e):null,r=this.hasSymbol_?function(t,e,n,i){const r=(2+pC(n))*t.geometriesCount;e&&e.length===r||(e=new Float32Array(r));const s=[];let o=0;for(const r in t.entries){const a=t.entries[r];for(let t=0,r=a.flatCoordss.length;t<r;t++)s[0]=a.flatCoordss[t][0],s[1]=a.flatCoordss[t][1],ra(i,s),e[o++]=s[0],e[o++]=s[1],o+=gC(e,n,a,o)}return e}(t.pointBatch,new Float32Array(0),this.customAttributes_,e):null;return{polygonInstructions:n,lineStringInstructions:i,pointInstructions:r}}generateBuffersForType_(t,e,n){if(null===t)return null;const i=EC++;let r;switch(e){case"Polygon":r=hC;break;case"LineString":r=uC;break;case"Point":r=cC}const s={id:i,type:r,renderInstructions:t.buffer,renderInstructionsTransform:n,customAttributesSize:pC(this.customAttributes_)},o=CC();return o.postMessage(s,[t.buffer]),t=null,new Promise(t=>{const e=n=>{const r=n.data;if(r.id!==i)return;if(o.removeEventListener("message",e),!this.helper_.getGL())return;const s=new fS(hS,cS).fromArrayBuffer(r.indicesBuffer),a=new fS(lS,cS).fromArrayBuffer(r.vertexAttributesBuffer),l=new fS(lS,cS).fromArrayBuffer(r.instanceAttributesBuffer);this.helper_.flushBufferData(s),this.helper_.flushBufferData(a),this.helper_.flushBufferData(l),t([s,a,l])};o.addEventListener("message",e)})}render(t,e,n){for(const i of this.renderPasses_)i.fillRenderPass&&this.renderInternal_(t.polygonBuffers[0],t.polygonBuffers[1],t.polygonBuffers[2],i.fillRenderPass,e,n),i.strokeRenderPass&&this.renderInternal_(t.lineStringBuffers[0],t.lineStringBuffers[1],t.lineStringBuffers[2],i.strokeRenderPass,e,n),i.symbolRenderPass&&this.renderInternal_(t.pointBuffers[0],t.pointBuffers[1],t.pointBuffers[2],i.symbolRenderPass,e,n)}renderInternal_(t,e,n,i,r,s){const o=t.getSize();if(0===o)return;const a=i.instancedAttributesDesc.length;if(this.helper_.useProgram(i.program,r),this.helper_.bindBuffer(e),this.helper_.bindBuffer(t),this.helper_.enableAttributes(i.attributesDesc),this.helper_.bindBuffer(n),this.helper_.enableAttributesInstanced(i.instancedAttributesDesc),s(),a){const t=i.instancedAttributesDesc.reduce((t,e)=>t+(e.size||1),0),e=n.getSize()/t;this.helper_.drawElementsInstanced(0,o,e)}else this.helper_.drawElements(0,o)}setHelper(t,e=null){this.helper_=t;for(const t of this.renderPasses_)t.fillRenderPass&&(t.fillRenderPass.program=this.helper_.getProgram(t.fillRenderPass.fragmentShader,t.fillRenderPass.vertexShader)),t.strokeRenderPass&&(t.strokeRenderPass.program=this.helper_.getProgram(t.strokeRenderPass.fragmentShader,t.strokeRenderPass.vertexShader)),t.symbolRenderPass&&(t.symbolRenderPass.program=this.helper_.getProgram(t.symbolRenderPass.fragmentShader,t.symbolRenderPass.vertexShader));this.helper_.addUniforms(this.uniforms_),e&&(e.polygonBuffers&&(this.helper_.flushBufferData(e.polygonBuffers[0]),this.helper_.flushBufferData(e.polygonBuffers[1]),this.helper_.flushBufferData(e.polygonBuffers[2])),e.lineStringBuffers&&(this.helper_.flushBufferData(e.lineStringBuffers[0]),this.helper_.flushBufferData(e.lineStringBuffers[1]),this.helper_.flushBufferData(e.lineStringBuffers[2])),e.pointBuffers&&(this.helper_.flushBufferData(e.pointBuffers[0]),this.helper_.flushBufferData(e.pointBuffers[1]),this.helper_.flushBufferData(e.pointBuffers[2])))}}const zC=new Uint8Array(4);class NC{constructor(t,e){this.helper_=t;const n=t.getGL();this.texture_=n.createTexture(),this.framebuffer_=n.createFramebuffer(),this.depthbuffer_=n.createRenderbuffer(),this.size_=e||[1,1],this.data_=new Uint8Array(0),this.dataCacheDirty_=!0,this.updateSize_()}setSize(t){hi(t,this.size_)||(this.size_[0]=t[0],this.size_[1]=t[1],this.updateSize_())}getSize(){return this.size_}clearCachedData(){this.dataCacheDirty_=!0}readAll(){if(this.dataCacheDirty_){const t=this.size_,e=this.helper_.getGL();e.bindFramebuffer(e.FRAMEBUFFER,this.framebuffer_),e.readPixels(0,0,t[0],t[1],e.RGBA,e.UNSIGNED_BYTE,this.data_),this.dataCacheDirty_=!1}return this.data_}readPixel(t,e){if(t<0||e<0||t>this.size_[0]||e>=this.size_[1])return zC[0]=0,zC[1]=0,zC[2]=0,zC[3]=0,zC;this.readAll();const n=Math.floor(t)+(this.size_[1]-Math.floor(e)-1)*this.size_[0];return zC[0]=this.data_[4*n],zC[1]=this.data_[4*n+1],zC[2]=this.data_[4*n+2],zC[3]=this.data_[4*n+3],zC}getTexture(){return this.texture_}getFramebuffer(){return this.framebuffer_}getDepthbuffer(){return this.depthbuffer_}updateSize_(){const t=this.size_,e=this.helper_.getGL();this.texture_=this.helper_.createTexture(t,null,this.texture_),e.bindFramebuffer(e.FRAMEBUFFER,this.framebuffer_),e.viewport(0,0,t[0],t[1]),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,this.texture_,0),e.bindRenderbuffer(e.RENDERBUFFER,this.depthbuffer_),e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_COMPONENT16,t[0],t[1]),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.RENDERBUFFER,this.depthbuffer_),this.data_=new Uint8Array(t[0]*t[1]*4)}}const jC={PATTERN_ORIGIN_X_DOUBLE:"u_df_patternOriginX",PATTERN_ORIGIN_Y_DOUBLE:"u_df_patternOriginY",PATTERN_SCALE_RATIO_DOUBLE:"u_df_patternScaleRatio",ONE:"u_one"},GC=[0,0],$C=[0,0],BC=[1,0,0,1,0,0],UC=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function VC(t,e){const n=t.viewState.projection,i=e.getSource().getWrapX()&&n.canWrapX(),r=n.getExtent(),s=t.extent,o=i?os(r):null,a=i?Math.ceil((s[2]-r[2])/o)+1:1;return[i?Math.floor((s[0]-r[0])/o):0,a,o]}const XC={...yS,...jC,RENDER_EXTENT:"u_renderExtent",GLOBAL_ALPHA:"u_globalAlpha"};class WC extends FS{constructor(t,e){super(t,{uniforms:{[XC.RENDER_EXTENT]:[0,0,0,0],[XC.GLOBAL_ALPHA]:1,[XC.ONE]:1},postProcesses:e.postProcesses}),this.hitDetectionEnabled_=!e.disableHitDetection,this.hitRenderTarget_,this.sourceRevision_=-1,this.previousExtent_=[1/0,1/0,-1/0,-1/0],this.currentTransform_=[1,0,0,1,0,0],this.currentFrameStateTransform_=[1,0,0,1,0,0],this.styleVariables_={},this.style_=[],this.styleRenderer_=null,this.buffers_=null,this.applyOptions_(e),this.batch_=new aC,this.initialFeaturesAdded_=!1,this.sourceListenKeys_=null}addInitialFeatures_(t){const e=this.getLayer().getSource(),n=Xo();let i;n&&(i=No(n,t.viewState.projection)),this.batch_.addFeatures(e.getFeatures(),i),this.sourceListenKeys_=[$n(e,Um,this.handleSourceFeatureAdded_.bind(this,i)),$n(e,Vm,this.handleSourceFeatureChanged_.bind(this,i),this),$n(e,Wm,this.handleSourceFeatureDelete_,this),$n(e,Xm,this.handleSourceFeatureClear_,this)]}applyOptions_(t){this.styleVariables_=t.variables,this.style_=t.style}createRenderers_(){this.buffers_=null,this.styleRenderer_=new OC(this.style_,this.styleVariables_,this.helper,this.hitDetectionEnabled_)}reset(t){this.applyOptions_(t),this.helper&&this.createRenderers_(),super.reset(t)}afterHelperCreated(){this.styleRenderer_?this.styleRenderer_.setHelper(this.helper,this.buffers_):this.createRenderers_(),this.hitDetectionEnabled_&&(this.hitRenderTarget_=new NC(this.helper))}handleSourceFeatureAdded_(t,e){const n=e.feature;this.batch_.addFeature(n,t)}handleSourceFeatureChanged_(t,e){const n=e.feature;this.batch_.changeFeature(n,t)}handleSourceFeatureDelete_(t){const e=t.feature;this.batch_.removeFeature(e)}handleSourceFeatureClear_(){this.batch_.clear()}applyUniforms_(t,e){!function(t,e,n,i){ia(BC,e),ea(BC,n),t.setUniformMatrixValue(yS.PROJECTION_MATRIX,aS(UC,BC)),la(BC,BC),t.setUniformMatrixValue(yS.INVERT_PROJECTION_MATRIX,aS(UC,BC)),GC[0]=0,GC[1]=0;const r=i.size,s=i.viewState.resolution,o=i.viewState.center;aa(BC,r[0]/2,r[1]/2,1/s,1/s,0,-o[0],-o[1]),ra(BC,GC),$C[0]=iC(GC[0]),$C[1]=nC(GC[0]),t.setUniformFloatVec2(jC.PATTERN_ORIGIN_X_DOUBLE,$C),$C[0]=iC(GC[1]),$C[1]=nC(GC[1]),t.setUniformFloatVec2(jC.PATTERN_ORIGIN_Y_DOUBLE,$C);const a=Math.pow(2,(i.viewState.zoom+.5)%1-.5);GC[0]=iC(a),GC[1]=nC(a),t.setUniformFloatVec2(jC.PATTERN_SCALE_RATIO_DOUBLE,GC)}(this.helper,this.currentFrameStateTransform_,t,e)}renderFrame(t){const e=this.helper.getGL();this.preRender(e,t);const[n,i,r]=VC(t,this.getLayer());this.helper.prepareDraw(t),this.renderWorlds(t,!1,n,i,r),this.helper.finalizeDraw(t,this.dispatchPreComposeEvent,this.dispatchPostComposeEvent);const s=this.helper.getCanvas();return this.hitDetectionEnabled_&&(this.renderWorlds(t,!0,n,i,r),this.hitRenderTarget_.clearCachedData()),this.postRender(e,t),s}prepareFrameInternal(t){this.initialFeaturesAdded_||(this.addInitialFeatures_(t),this.initialFeaturesAdded_=!0);const e=this.getLayer(),n=e.getSource(),i=t.viewState,r=!t.viewHints[ar]&&!t.viewHints[lr],s=!Ur(this.previousExtent_,t.extent),o=this.sourceRevision_<n.getRevision();if(o&&(this.sourceRevision_=n.getRevision()),r&&(s||o)){const r=i.projection,s=i.resolution,o=e instanceof Cf?e.getRenderBuffer():0,a=Ir(t.extent,o*s),l=Xo();l?n.loadFeatures(Zo(a,l),Yo(s,r),l):n.loadFeatures(a,s,r),this.ready=!1;const h=this.helper.makeProjectionTransform(t,[1,0,0,1,0,0]);this.styleRenderer_.generateBuffers(this.batch_,h).then(t=>{this.buffers_&&this.disposeBuffers(this.buffers_),this.buffers_=t,this.ready=!0,this.getLayer().changed()}),this.previousExtent_=t.extent.slice()}return!0}renderWorlds(t,e,n,i,r){let s=n;e&&(this.hitRenderTarget_.setSize([Math.floor(t.size[0]/2),Math.floor(t.size[1]/2)]),this.helper.prepareDrawToRenderTarget(t,this.hitRenderTarget_,!0));do{this.helper.makeProjectionTransform(t,this.currentFrameStateTransform_),oa(this.currentFrameStateTransform_,s*r,0),this.buffers_&&this.styleRenderer_.render(this.buffers_,t,()=>{this.applyUniforms_(this.buffers_.invertVerticesTransform,t),this.helper.applyHitDetectionUniform(e)})}while(++s<i)}forEachFeatureAtCoordinate(t,e,n,i,r){if(ir(this.hitDetectionEnabled_,"`forEachFeatureAtCoordinate` cannot be used on a WebGL layer if the hit detection logic has been disabled using the `disableHitDetection: true` option."),!this.styleRenderer_||!this.hitDetectionEnabled_)return;const s=ra(e.coordinateToPixelTransform,t.slice()),o=this.hitRenderTarget_.readPixel(s[0]/2,s[1]/2),a=fC([o[0]/255,o[1]/255,o[2]/255,o[3]/255]),l=this.batch_.getFeatureFromRef(a);return l?i(l,this.getLayer(),null):void 0}disposeBuffers(t){const e=t=>{for(const e of t)e&&this.helper.deleteBuffer(e)};t.pointBuffers&&e(t.pointBuffers),t.lineStringBuffers&&e(t.lineStringBuffers),t.polygonBuffers&&e(t.polygonBuffers)}disposeInternal(){this.buffers_&&this.disposeBuffers(this.buffers_),this.sourceListenKeys_&&(this.sourceListenKeys_.forEach(function(t){Un(t)}),this.sourceListenKeys_=null),super.disposeInternal()}renderDeclutter(){}}const qC="blur",ZC="gradient",KC="radius",YC=["#00f","#0ff","#0f0","#ff0","#f00"];class HC extends f_{constructor(t){super(t),this.vectorRenderer_=new im(t),this.layerImageRatio_=t.getImageRatio(),this.coordinateToVectorPixelTransform_=[1,0,0,1,0,0],this.renderedPixelToCoordinateTransform_=null}disposeInternal(){this.vectorRenderer_.dispose(),super.disposeInternal()}getFeatures(t){if(!this.vectorRenderer_)return Promise.resolve([]);const e=ra(this.coordinateToVectorPixelTransform_,ra(this.renderedPixelToCoordinateTransform_,t.slice()));return this.vectorRenderer_.getFeatures(e)}handleFontsChanged(){this.vectorRenderer_.handleFontsChanged()}prepareFrame(t){const e=t.pixelRatio,n=t.viewState,i=n.resolution,r=t.viewHints,s=this.vectorRenderer_;let o=t.extent;1!==this.layerImageRatio_&&(o=o.slice(0),function(t,e){const n=(t[2]-t[0])/2*(e-1),i=(t[3]-t[1])/2*(e-1);t[0]-=n,t[2]+=n,t[1]-=i,t[3]+=i}(o,this.layerImageRatio_));const a=os(o)/i,l=ns(o)/i;if(!r[ar]&&!r[lr]&&!ls(o)){s.useContainer(null,null);const r=s.context,h=t.layerStatesArray[t.layerIndex],c=Object.assign({},h,{opacity:1}),u=Object.assign({},t,{extent:o,size:[a,l],viewState:Object.assign({},t.viewState,{rotation:0}),layerStatesArray:[c],layerIndex:0,declutter:null}),d=this.getLayer().getDeclutter();d&&(u.declutter={[d]:new Hh(9)});const f=new m_(o,i,e,r.canvas,function(t){s.prepareFrame(u)&&s.replayGroupChanged&&(s.clipping=!1,s.renderFrame(u,null),s.renderDeclutter(u),s.renderDeferred(u),t())});f.addEventListener(Vn,()=>{if(f.getState()!==od)return;this.image=f;const t=f.getPixelRatio(),i=__(f.getResolution())*e/t;this.renderedResolution=i,this.coordinateToVectorPixelTransform_=aa(this.coordinateToVectorPixelTransform_,a/2,l/2,1/i,-1/i,0,-n.center[0],-n.center[1])}),f.load()}return this.image&&(this.renderedPixelToCoordinateTransform_=t.pixelToCoordinateTransform.slice()),!this.getLayer().getSource()?.loading&&!!this.image}preRender(){}postRender(){}renderDeclutter(){}forEachFeatureAtCoordinate(t,e,n,i,r){return this.vectorRenderer_?this.vectorRenderer_.forEachFeatureAtCoordinate(t,e,n,i,r):super.forEachFeatureAtCoordinate(t,e,n,i,r)}}class JC extends FS{constructor(t,e){const n=e.uniforms||{},i=[1,0,0,1,0,0];n[yS.PROJECTION_MATRIX]=i,super(t,{uniforms:n,postProcesses:e.postProcesses}),this.sourceRevision_=-1,this.verticesBuffer_=new fS(lS,cS),this.instanceAttributesBuffer_=new fS(lS,cS),this.indicesBuffer_=new fS(hS,cS),this.vertexShader_=e.vertexShader,this.fragmentShader_=e.fragmentShader,this.program_,this.hitDetectionEnabled_=e.hitDetectionEnabled??!0;const r=e.attributes?e.attributes.map(function(t){return{name:"a_"+t.name,size:1,type:wS}}):[];this.attributes=[{name:"a_localPosition",size:2,type:wS}],this.instanceAttributes=[{name:"a_position",size:2,type:wS}],this.hitDetectionEnabled_&&(this.instanceAttributes.push({name:"a_hitColor",size:2,type:wS}),this.instanceAttributes.push({name:"a_featureUid",size:1,type:wS})),this.instanceAttributes.push(...r),this.customAttributes=e.attributes?e.attributes:[],this.previousExtent_=[1/0,1/0,-1/0,-1/0],this.currentTransform_=i,this.renderTransform_=[1,0,0,1,0,0],this.invertRenderTransform_=[1,0,0,1,0,0],this.renderInstructions_=new Float32Array(0),this.hitRenderTarget_,this.lastSentId=0,this.worker_=lC(),this.worker_.addEventListener("message",t=>{const e=t.data;if(e.type===cC){const n=e.projectionTransform;this.verticesBuffer_.fromArrayBuffer(e.vertexAttributesBuffer),this.instanceAttributesBuffer_.fromArrayBuffer(e.instanceAttributesBuffer),this.helper.flushBufferData(this.verticesBuffer_),this.helper.flushBufferData(this.instanceAttributesBuffer_),this.indicesBuffer_.fromArrayBuffer(e.indicesBuffer),this.helper.flushBufferData(this.indicesBuffer_),this.renderTransform_=n,la(this.invertRenderTransform_,this.renderTransform_),this.renderInstructions_=new Float32Array(t.data.renderInstructions),e.id===this.lastSentId&&(this.ready=!0),this.getLayer().changed()}}),this.featureCache_={},this.featureCount_=0;const s=this.getLayer().getSource();this.sourceListenKeys_=[$n(s,Um,this.handleSourceFeatureAdded_,this),$n(s,Vm,this.handleSourceFeatureChanged_,this),$n(s,Wm,this.handleSourceFeatureDelete_,this),$n(s,Xm,this.handleSourceFeatureClear_,this)],s.forEachFeature(t=>{const e=t.getGeometry();e&&"Point"===e.getType()&&(this.featureCache_[wi(t)]={feature:t,properties:t.getProperties(),flatCoordinates:e.getFlatCoordinates()},this.featureCount_++)})}afterHelperCreated(){this.program_=this.helper.getProgram(this.fragmentShader_,this.vertexShader_),this.hitDetectionEnabled_&&(this.hitRenderTarget_=new NC(this.helper)),this.verticesBuffer_.getArray()&&this.helper.flushBufferData(this.verticesBuffer_),this.indicesBuffer_.getArray()&&this.helper.flushBufferData(this.indicesBuffer_)}handleSourceFeatureAdded_(t){const e=t.feature,n=e.getGeometry();n&&"Point"===n.getType()&&(this.featureCache_[wi(e)]={feature:e,properties:e.getProperties(),flatCoordinates:n.getFlatCoordinates()},this.featureCount_++)}handleSourceFeatureChanged_(t){const e=t.feature,n=wi(e),i=this.featureCache_[n],r=e.getGeometry();i?r&&"Point"===r.getType()?(i.properties=e.getProperties(),i.flatCoordinates=r.getFlatCoordinates()):(delete this.featureCache_[n],this.featureCount_--):r&&"Point"===r.getType()&&(this.featureCache_[n]={feature:e,properties:e.getProperties(),flatCoordinates:r.getFlatCoordinates()},this.featureCount_++)}handleSourceFeatureDelete_(t){const e=wi(t.feature);e in this.featureCache_&&(delete this.featureCache_[e],this.featureCount_--)}handleSourceFeatureClear_(){this.featureCache_={},this.featureCount_=0}renderFrame(t){const e=this.helper.getGL();this.preRender(e,t);const[n,i,r]=VC(t,this.getLayer());this.renderWorlds(t,!1,n,i,r),this.helper.finalizeDraw(t,this.dispatchPreComposeEvent,this.dispatchPostComposeEvent),this.hitDetectionEnabled_&&(this.renderWorlds(t,!0,n,i,r),this.hitRenderTarget_.clearCachedData()),this.postRender(e,t);return this.helper.getCanvas()}prepareFrameInternal(t){const e=this.getLayer(),n=e.getSource(),i=t.viewState,r=!t.viewHints[ar]&&!t.viewHints[lr],s=!Ur(this.previousExtent_,t.extent),o=this.sourceRevision_<n.getRevision();if(o&&(this.sourceRevision_=n.getRevision()),r&&(s||o)){const r=i.projection,s=i.resolution,o=e instanceof Cf?e.getRenderBuffer():0,a=Ir(t.extent,o*s);n.loadFeatures(a,s,r),this.rebuildBuffers_(t),this.previousExtent_=t.extent.slice()}return this.helper.useProgram(this.program_,t),this.helper.prepareDraw(t),!0}rebuildBuffers_(t){const e=[1,0,0,1,0,0];this.helper.makeProjectionTransform(t,e);const n=Xo(),i=(this.hitDetectionEnabled_?5:2)+this.customAttributes.length,r=i*this.featureCount_,s=this.renderInstructions_&&this.renderInstructions_.length===r?this.renderInstructions_:new Float32Array(r);this.renderInstructions_=null;let o=[];const a=[];let l=-1;const h=t.viewState.projection;for(const t in this.featureCache_){const i=this.featureCache_[t];if(n?o=qo(i.flatCoordinates,h):(o[0]=i.flatCoordinates[0],o[1]=i.flatCoordinates[1]),ra(e,o),s[++l]=o[0],s[++l]=o[1],this.hitDetectionEnabled_){const e=dC(l+3,a);s[++l]=e[0],s[++l]=e[1],s[++l]=Number(t)}for(let t=0;t<this.customAttributes.length;t++){const e=this.customAttributes[t].callback(i.feature,i.properties);s[++l]=e}}const c={id:++this.lastSentId,type:cC,renderInstructions:s.buffer,customAttributesSize:i-2};c.projectionTransform=e,this.ready=!1,this.worker_.postMessage(c,[s.buffer])}forEachFeatureAtCoordinate(t,e,n,i,r){if(ir(this.hitDetectionEnabled_,"`forEachFeatureAtCoordinate` cannot be used on a WebGL layer if the hit detection logic has been disabled using the `disableHitDetection: true` option."),!this.renderInstructions_||!this.hitDetectionEnabled_)return;const s=ra(e.coordinateToPixelTransform,t.slice()),o=this.hitRenderTarget_.readPixel(s[0]/2,s[1]/2),a=fC([o[0]/255,o[1]/255,o[2]/255,o[3]/255]),l=this.renderInstructions_[a],h=Math.floor(l).toString(),c=this.getLayer().getSource().getFeatureByUid(h);return c?i(c,this.getLayer(),null):void 0}renderWorlds(t,e,n,i,r){let s=n;this.helper.useProgram(this.program_,t),e&&(this.hitRenderTarget_.setSize([Math.floor(t.size[0]/2),Math.floor(t.size[1]/2)]),this.helper.prepareDrawToRenderTarget(t,this.hitRenderTarget_,!0));const o=this.instanceAttributes.reduce((t,e)=>t+(e.size||1),0),a=this.instanceAttributesBuffer_.getSize()/o;do{this.helper.bindBuffer(this.indicesBuffer_),this.helper.bindBuffer(this.verticesBuffer_),this.helper.enableAttributes(this.attributes),this.helper.bindBuffer(this.instanceAttributesBuffer_),this.helper.enableAttributesInstanced(this.instanceAttributes),this.helper.makeProjectionTransform(t,this.currentTransform_),oa(this.currentTransform_,s*r,0),ea(this.currentTransform_,this.invertRenderTransform_),this.helper.applyUniforms(t),this.helper.applyHitDetectionUniform(e);const n=this.indicesBuffer_.getSize();this.helper.drawElementsInstanced(0,n,a)}while(++s<i)}disposeInternal(){this.worker_.terminate(),this.sourceListenKeys_.forEach(function(t){Un(t)}),this.sourceListenKeys_=null,super.disposeInternal()}renderDeclutter(){}}class QC extends zm{constructor(t){const e=void 0!==(t=t||{}).projection?t.projection:"EPSG:3857",n=void 0!==t.tileGrid?t.tileGrid:ym({extent:bm(e),maxResolution:t.maxResolution,maxZoom:t.maxZoom,minZoom:t.minZoom,tileSize:t.tileSize});super({attributions:t.attributions,cacheSize:t.cacheSize,crossOrigin:t.crossOrigin,referrerPolicy:t.referrerPolicy,interpolate:t.interpolate,projection:e,reprojectionErrorThreshold:t.reprojectionErrorThreshold,tileGrid:n,tileLoadFunction:t.tileLoadFunction,tilePixelRatio:t.tilePixelRatio,tileUrlFunction:t.tileUrlFunction,url:t.url,urls:t.urls,wrapX:void 0===t.wrapX||t.wrapX,transition:t.transition,attributionsCollapsible:t.attributionsCollapsible,zDirection:t.zDirection}),this.gutter_=void 0!==t.gutter?t.gutter:0}getGutter(){return this.gutter_}}const tE="1.3.0",eE=[101,101];function nE(t,e,n,i,r){r.WIDTH=n[0],r.HEIGHT=n[1];const s=i.getAxisOrientation(),o=ds(r.VERSION,"1.3")>=0;r[o?"CRS":"SRS"]=i.getCode();const a=o&&s.startsWith("ne")?[e[1],e[0],e[3],e[2]]:e;return r.BBOX=a.join(","),Sm(t,r)}function iE(t,e,n,i,r,s,o){s=Object.assign({REQUEST:"GetMap"},s);const a=e/n,l=[yr(os(t)/a,4),yr(ns(t)/a,4)];if(1!=n)switch(o){case"geoserver":const t=90*n+.5|0;"FORMAT_OPTIONS"in s?s.FORMAT_OPTIONS+=";dpi:"+t:s.FORMAT_OPTIONS="dpi:"+t;break;case"mapserver":s.MAP_RESOLUTION=90*n;break;case"carmentaserver":case"qgis":s.DPI=90*n;break;default:throw new Error("Unknown `serverType` configured")}return nE(r,t,l,i,s)}function rE(t,e){return Object.assign({REQUEST:e,SERVICE:"WMS",VERSION:tE,FORMAT:"image/png",STYLES:"",TRANSPARENT:"TRUE"},t)}_i.unByKey=yi;let sE={Control:Al,Zoom:Nl,Attribution:Ol,ScaleLine:class extends Al{constructor(t){t=t||{};const e=document.createElement("div");e.style.pointerEvents="none",super({element:e,render:t.render,target:t.target}),this.on,this.once,this.un;const n=void 0!==t.className?t.className:t.bar?"ol-scale-bar":"ol-scale-line";this.innerElement_=document.createElement("div"),this.innerElement_.className=n+"-inner",this.element.className=n+" "+_l,this.element.appendChild(this.innerElement_),this.viewState_=null,this.minWidth_=void 0!==t.minWidth?t.minWidth:64,this.maxWidth_=t.maxWidth,this.renderedVisible_=!1,this.renderedWidth_=void 0,this.renderedHTML_="",this.addChangeListener(_x,this.handleUnitsChanged_),this.setUnits(t.units||"metric"),this.scaleBar_=t.bar||!1,this.scaleBarSteps_=t.steps||4,this.scaleBarText_=t.text||!1,this.dpi_=t.dpi||void 0}getUnits(){return this.get(_x)}handleUnitsChanged_(){this.updateElement_()}setUnits(t){this.set(_x,t)}setDpi(t){this.dpi_=t}updateElement_(){const t=this.viewState_;if(!t)return void(this.renderedVisible_&&(this.element.style.display="none",this.renderedVisible_=!1));const e=t.center,n=t.projection,i=this.getUnits(),r="degrees"==i?"degrees":"m";let s=Io(n,t.resolution,e,r);const o=this.minWidth_*(this.dpi_||xx)/xx,a=void 0!==this.maxWidth_?this.maxWidth_*(this.dpi_||xx)/xx:void 0;let l=o*s,h="";if("degrees"==i){const t=ks.degrees;l*=t,l<t/60?(h="″",s*=3600):l<t?(h="′",s*=60):h="°"}else if("imperial"==i)l<.9144?(h="in",s/=.0254):l<1609.344?(h="ft",s/=.3048):(h="mi",s/=1609.344);else if("nautical"==i)s/=1852,h="NM";else if("metric"==i)l<1e-6?(h="nm",s*=1e9):l<.001?(h="μm",s*=1e6):l<1?(h="mm",s*=1e3):l<1e3?h="m":(h="km",s/=1e3);else{if("us"!=i)throw new Error("Invalid units");l<.9144?(h="in",s*=39.37):l<1609.344?(h="ft",s/=.30480061):(h="mi",s/=1609.3472)}let c,u,d,f,g,p=3*Math.floor(Math.log(o*s)/Math.log(10)),m=0;for(;;){d=Math.floor(p/3);const t=Math.pow(10,d);if(c=yx[(p%3+3)%3]*t,u=Math.round(c/s),isNaN(u))return this.element.style.display="none",void(this.renderedVisible_=!1);if(void 0!==a&&u>=a){c=m,u=f,d=g;break}if(u>=o)break;m=c,f=u,g=d,++p}const _=this.scaleBar_?this.createScaleBar(u,c,h):c.toFixed(d<0?-d:0)+" "+h;this.renderedHTML_!=_&&(this.innerElement_.innerHTML=_,this.renderedHTML_=_),this.renderedWidth_!=u&&(this.innerElement_.style.width=u+"px",this.renderedWidth_=u),this.renderedVisible_||(this.element.style.display="",this.renderedVisible_=!0)}createScaleBar(t,e,n){const i=this.getScaleForResolution(),r=i<1?Math.round(1/i).toLocaleString()+" : 1":"1 : "+Math.round(i).toLocaleString(),s=this.scaleBarSteps_,o=t/s,a=[this.createMarker("absolute")];for(let i=0;i<s;++i){const r=i%2==0?"ol-scale-singlebar-odd":"ol-scale-singlebar-even";a.push(`<div><div class="ol-scale-singlebar ${r}" style="width: ${o}px;"></div>`+this.createMarker("relative")+(i%2==0||2===s?this.createStepText(i,t,!1,e,n):"")+"</div>")}a.push(this.createStepText(s,t,!0,e,n));return(this.scaleBarText_?`<div class="ol-scale-text" style="width: ${t}px;">`+r+"</div>":"")+a.join("")}createMarker(t){return`<div class="ol-scale-step-marker" style="position: ${t}; top: ${"absolute"===t?3:-10}px;"></div>`}createStepText(t,e,n,i,r){const s=(0===t?0:Math.round(i/this.scaleBarSteps_*t*100)/100)+(0===t?"":" "+r);return`<div class="ol-scale-step-text" style="margin-left: ${0===t?-3:e/this.scaleBarSteps_*-1}px;text-align: ${0===t?"left":"center"};min-width: ${0===t?0:e/this.scaleBarSteps_*2}px;left: ${n?e+"px":"unset"};">`+s+"</div>"}getScaleForResolution(){return Io(this.viewState_.projection,this.viewState_.resolution,this.viewState_.center,"m")*(1e3/25.4)*(this.dpi_||xx)}render(t){const e=t.frameState;this.viewState_=e?e.viewState:null,this.updateElement_()}},LayerSwitcher:Rx},oE={GeoJSON:Jf,KML:class extends Hv{constructor(t){super(),t=t||{},Ib||(_b=[255,255,255,1],Pb=new Bd({color:_b}),yb=[20,2],xb="pixels",vb="pixels",bb=[64,64],wb="https://maps.google.com/mapfiles/kml/pushpin/ylw-pushpin.png",Tb=new Vd({anchor:yb,anchorOrigin:"bottom-left",anchorXUnits:xb,anchorYUnits:vb,crossOrigin:"anonymous",rotation:0,scale:kb(bb),size:bb,src:wb}),Sb="NO_IMAGE",Rb=new Xd({color:_b,width:1}),Cb=new Xd({color:[51,51,51,1],width:2}),Fb=new Hd({font:"bold 16px Helvetica",fill:Pb,stroke:Cb,scale:.8}),Mb=new Wd({fill:Pb,image:Tb,text:Fb,stroke:Rb,zIndex:0}),Ib=[Mb]),this.dataProjection=Mo("EPSG:4326"),this.defaultStyle_=t.defaultStyle?t.defaultStyle:Ib,this.extractStyles_=void 0===t.extractStyles||t.extractStyles,this.writeStyles_=void 0===t.writeStyles||t.writeStyles,this.sharedStyles_={},this.showPointNames_=void 0===t.showPointNames||t.showPointNames,this.crossOrigin_=void 0!==t.crossOrigin?t.crossOrigin:"anonymous",this.referrerPolicy_=t.referrerPolicy,this.iconUrlFunction_=t.iconUrlFunction?t.iconUrlFunction:Lb,this.supportedMediaTypes=["application/vnd.google-earth.kml+xml"]}readDocumentOrFolder_(t,e){const n=Wv([],Vv(lb,{Document:Ov(this.readDocumentOrFolder_,this),Folder:Ov(this.readDocumentOrFolder_,this),Placemark:zv(this.readPlacemark_,this),Style:this.readSharedStyle_.bind(this),StyleMap:this.readSharedStyleMap_.bind(this)}),t,e,this);if(n)return n}readPlacemark_(t,e){const n=Wv({geometry:null},cb,t,e,this);if(!n)return;const i=new kf,r=t.getAttribute("id");null!==r&&i.setId(r);const s=e[0],o=n.geometry;if(o&&Wf(o,!1,s),i.setGeometry(o),delete n.geometry,this.extractStyles_){const t=function(t,e,n,i,r){return function(s,o){let a=r,l="",h=[];if(a){const t=s.getGeometry();if(t)if(t instanceof Uf)h=t.getGeometriesArrayRecursive().filter(function(t){const e=t.getType();return"Point"===e||"MultiPoint"===e}),a=h.length>0;else{const e=t.getType();a="Point"===e||"MultiPoint"===e}}a&&(l=s.get("name"),a=a&&!!l,a&&/&[^&]+;/.test(l)&&(Eb||(Eb=document.createElement("textarea")),Eb.innerHTML=l,l=Eb.value));let c=n;if(t?c=t:e&&(c=Ab(e,n,i)),a){const t=function(t,e){const n=[0,0];let i="start";const r=t.getImage();if(r){const t=r.getSize();if(t&&2==t.length){const e=r.getScaleArray(),s=r.getAnchor();n[0]=e[0]*(t[0]-s[0]),n[1]=e[1]*(t[1]/2-s[1]),i="left"}}let s=t.getText();s?(s=s.clone(),s.setFont(s.getFont()||Fb.getFont()),s.setScale(s.getScale()||Fb.getScale()),s.setFill(s.getFill()||Fb.getFill()),s.setStroke(s.getStroke()||Cb)):s=Fb.clone();s.setText(e),s.setOffsetX(n[0]),s.setOffsetY(n[1]),s.setTextAlign(i);const o=new Wd({image:r,text:s});return o}(c[0],l);if(h.length>0){t.setGeometry(new Uf(h));return[t,new Wd({geometry:c[0].getGeometry(),image:null,fill:c[0].getFill(),stroke:c[0].getStroke(),text:null})].concat(c.slice(1))}return t}return c}}(n.Style,n.styleUrl,this.defaultStyle_,this.sharedStyles_,this.showPointNames_);i.setStyle(t)}return delete n.Style,i.setProperties(n,!0),i}readSharedStyle_(t,e){const n=t.getAttribute("id");if(null!==n){const i=hw.call(this,t,e);if(i){let e,r=t.baseURI;if(r&&"about:blank"!=r||(r=window.location.href),r){e=new URL("#"+n,r).href}else e="#"+n;this.sharedStyles_[e]=i}}}readSharedStyleMap_(t,e){const n=t.getAttribute("id");if(null===n)return;const i=$b.call(this,t,e);if(!i)return;let r,s=t.baseURI;if(s&&"about:blank"!=s||(s=window.location.href),s){r=new URL("#"+n,s).href}else r="#"+n;this.sharedStyles_[r]=i}readFeatureFromNode(t,e){if(!lb.includes(t.namespaceURI))return null;const n=this.readPlacemark_(t,[this.getReadOptions(t,e)]);return n||null}readFeaturesFromNode(t,e){if(!lb.includes(t.namespaceURI))return[];let n;const i=t.localName;if("Document"==i||"Folder"==i)return n=this.readDocumentOrFolder_(t,[this.getReadOptions(t,e)]),n||[];if("Placemark"==i){const n=this.readPlacemark_(t,[this.getReadOptions(t,e)]);return n?[n]:[]}if("kml"==i){n=[];for(let i=t.firstElementChild;i;i=i.nextElementSibling){const t=this.readFeaturesFromNode(i,e);t&&li(n,t)}return n}return[]}readName(t){if(t){if("string"==typeof t){const e=Dv(t);return this.readNameFromDocument(e)}return Av(t)?this.readNameFromDocument(t):this.readNameFromNode(t)}}readNameFromDocument(t){for(let e=t.firstChild;e;e=e.nextSibling)if(e.nodeType==Node.ELEMENT_NODE){const t=this.readNameFromNode(e);if(t)return t}}readNameFromNode(t){for(let e=t.firstElementChild;e;e=e.nextElementSibling)if(lb.includes(e.namespaceURI)&&"name"==e.localName)return tb(e);for(let e=t.firstElementChild;e;e=e.nextElementSibling){const t=e.localName;if(lb.includes(e.namespaceURI)&&("Document"==t||"Folder"==t||"Placemark"==t||"kml"==t)){const t=this.readNameFromNode(e);if(t)return t}}}readNetworkLinks(t){const e=[];if("string"==typeof t){const n=Dv(t);li(e,this.readNetworkLinksFromDocument(n))}else Av(t)?li(e,this.readNetworkLinksFromDocument(t)):li(e,this.readNetworkLinksFromNode(t));return e}readNetworkLinksFromDocument(t){const e=[];for(let n=t.firstChild;n;n=n.nextSibling)n.nodeType==Node.ELEMENT_NODE&&li(e,this.readNetworkLinksFromNode(n));return e}readNetworkLinksFromNode(t){const e=[];for(let n=t.firstElementChild;n;n=n.nextElementSibling)if(lb.includes(n.namespaceURI)&&"NetworkLink"==n.localName){const t=Wv({},ub,n,[]);e.push(t)}for(let n=t.firstElementChild;n;n=n.nextElementSibling){const t=n.localName;!lb.includes(n.namespaceURI)||"Document"!=t&&"Folder"!=t&&"kml"!=t||li(e,this.readNetworkLinksFromNode(n))}return e}readRegion(t){const e=[];if("string"==typeof t){const n=Dv(t);li(e,this.readRegionFromDocument(n))}else Av(t)?li(e,this.readRegionFromDocument(t)):li(e,this.readRegionFromNode(t));return e}readRegionFromDocument(t){const e=[];for(let n=t.firstChild;n;n=n.nextSibling)n.nodeType==Node.ELEMENT_NODE&&li(e,this.readRegionFromNode(n));return e}readRegionFromNode(t){const e=[];for(let n=t.firstElementChild;n;n=n.nextElementSibling)if(lb.includes(n.namespaceURI)&&"Region"==n.localName){const t=Wv({},gb,n,[]);e.push(t)}for(let n=t.firstElementChild;n;n=n.nextElementSibling){const t=n.localName;!lb.includes(n.namespaceURI)||"Document"!=t&&"Folder"!=t&&"kml"!=t||li(e,this.readRegionFromNode(n))}return e}readCamera(t){const e=[];if("string"==typeof t){const n=Dv(t);li(e,this.readCameraFromDocument(n))}else Av(t)?li(e,this.readCameraFromDocument(t)):li(e,this.readCameraFromNode(t));return e}readCameraFromDocument(t){const e=[];for(let n=t.firstChild;n;n=n.nextSibling)n.nodeType===Node.ELEMENT_NODE&&li(e,this.readCameraFromNode(n));return e}readCameraFromNode(t){const e=[];for(let n=t.firstElementChild;n;n=n.nextElementSibling)if(lb.includes(n.namespaceURI)&&"Camera"===n.localName){const t=Wv({},fb,n,[]);e.push(t)}for(let n=t.firstElementChild;n;n=n.nextElementSibling){const t=n.localName;!lb.includes(n.namespaceURI)||"Document"!==t&&"Folder"!==t&&"Placemark"!==t&&"kml"!==t||li(e,this.readCameraFromNode(n))}return e}writeFeaturesNode(t,e){e=this.adaptOptions(e);const n=Iv(lb[4],"kml"),i="http://www.w3.org/2000/xmlns/";n.setAttributeNS(i,"xmlns:gx",ab[0]),n.setAttributeNS(i,"xmlns:xsi",Mv),n.setAttributeNS(Mv,"xsi:schemaLocation","http://www.opengis.net/kml/2.2 https://developers.google.com/kml/schema/kml22gx.xsd");const r={node:n},s={};t.length>1?s.Document=t:1==t.length&&(s.Placemark=t[0]);const o=pb[n.namespaceURI],a=Uv(s,o);return qv(r,mb,Bv,a,[e],o,this),n}},MVT:mg},aE={Group:jh,Tile:Qg,Vector:rm,VectorImage:class extends Cf{constructor(t){t=t||{};const e=Object.assign({},t);delete e.imageRatio,super(e),this.imageRatio_=void 0!==t.imageRatio?t.imageRatio:1}getImageRatio(){return this.imageRatio_}createRenderer(){return new HC(this)}},VectorTile:lm,WebGLPoints:class extends Wh{constructor(t){super(Object.assign({},t)),this.styleVariables_=t.variables||{},this.parseResult_=bC(t.style,this.styleVariables_,t.filter),this.hitDetectionDisabled_=!!t.disableHitDetection}createRenderer(){const t=Object.keys(this.parseResult_.attributes).map(t=>({name:t,...this.parseResult_.attributes[t]}));return new JC(this,{vertexShader:this.parseResult_.builder.getSymbolVertexShader(),fragmentShader:this.parseResult_.builder.getSymbolFragmentShader(),hitDetectionEnabled:!this.hitDetectionDisabled_,uniforms:this.parseResult_.uniforms,attributes:t})}updateStyleVariables(t){Object.assign(this.styleVariables_,t),this.changed()}},Heatmap:class extends Cf{constructor(t){t=t||{};const e=Object.assign({},t);delete e.gradient,delete e.radius,delete e.blur,delete e.weight,super(e),this.on,this.once,this.un,this.filter_=t.filter??!0,this.styleVariables_=t.variables||{},this.gradient_=null,this.addChangeListener(ZC,this.handleGradientChanged_),this.setGradient(t.gradient?t.gradient:YC),this.setBlur(void 0!==t.blur?t.blur:15),this.setRadius(void 0!==t.radius?t.radius:8);const n=t.weight?t.weight:"weight";this.weight_=n,this.setRenderOrder(null)}getBlur(){return this.get(qC)}getGradient(){return this.get(ZC)}getRadius(){return this.get(KC)}handleGradientChanged_(){this.gradient_=function(t){const e=1,n=256,i=Cl(e,n),r=i.createLinearGradient(0,0,e,n),s=1/(t.length-1);for(let e=0,n=t.length;e<n;++e)r.addColorStop(e*s,t[e]);return i.fillStyle=r,i.fillRect(0,0,e,n),i.canvas}(this.getGradient())}setBlur(t){const e=this.get(qC);this.set(qC,t),"number"!=typeof t||"number"!=typeof e?this.clearRenderer():this.changed()}setGradient(t){this.set(ZC,t)}setRadius(t){const e=this.get(KC);this.set(KC,t),"number"!=typeof t||"number"!=typeof e?this.clearRenderer():this.changed()}setFilter(t){this.filter_=t,this.changed(),this.clearRenderer()}setWeight(t){this.weight_=t,this.changed(),this.clearRenderer()}createRenderer(){const t=new oC,e={variables:{},properties:{},functions:{},bandCount:0,featureId:!1,geometryType:!1},n=Kc(),i=KS(e,this.filter_,Dc,n);let r=KS(e,this.getRadius(),Oc),s=KS(e,this.getBlur(),Oc);const o={};"number"==typeof this.getBlur()&&(s="a_blur",o.a_blur=()=>this.getBlur(),t.addUniform("a_blur","float")),"number"==typeof this.getRadius()&&(r="a_radius",o.a_radius=()=>this.getRadius(),t.addUniform("a_radius","float"));const a={};let l=null;if("string"==typeof this.weight_||"function"==typeof this.weight_){const e="string"==typeof this.weight_?t=>t.get(this.weight_):this.weight_;a.prop_weight={size:1,callback:t=>{const n=e(t);return void 0!==n?cr(n,0,1):1}},l="a_prop_weight",t.addAttribute("a_prop_weight","float")}else{l=KS(e,["clamp",this.weight_,0,1],Oc)}const h=`(${r} / max(1., ${s}))`;t.setSymbolSizeExpression(`vec2(${r} + ${s}) * 2.`).setSymbolColorExpression(`vec4(smoothstep(0., 1., (1. - length(coordsPx * 2. / v_quadSizePx)) * ${h}) * ${l})`).setStrokeColorExpression(`vec4(smoothstep(0., 1., (1. - length(currentRadiusPx * 2. / v_width)) * ${h}) * ${l})`).setStrokeWidthExpression(`(${r} + ${s}) * 2.`).setFillColorExpression(`vec4(${l})`),n.mCoordinate?t.setFragmentDiscardExpression(`!${i}`):t.setShapeDiscardExpression(`!${i}`),QS(t,e);const c=eC(e),u=tC(e,this.styleVariables_);return new WC(this,{className:this.getClassName(),variables:this.styleVariables_,style:{builder:t,attributes:{...c,...a},uniforms:{...u,...o}},disableHitDetection:!1,postProcesses:[{fragmentShader:"\n precision mediump float;\n\n uniform sampler2D u_image;\n uniform sampler2D u_gradientTexture;\n uniform float u_opacity;\n\n varying vec2 v_texCoord;\n\n void main() {\n vec4 color = texture2D(u_image, v_texCoord);\n gl_FragColor.a = color.a * u_opacity;\n gl_FragColor.rgb = texture2D(u_gradientTexture, vec2(0.5, color.a)).rgb;\n gl_FragColor.rgb *= gl_FragColor.a;\n }",uniforms:{u_gradientTexture:()=>this.gradient_,u_opacity:()=>this.getOpacity()}}]})}updateStyleVariables(t){Object.assign(this.styleVariables_,t),this.changed()}renderDeclutter(){}},Image:p_},lE={LineString:Of,Point:ja,MultiPoint:Nf},hE={Icon:Vd,Style:Wd,Text:Hd,Stroke:Xd,Fill:Bd,Circle:$d},cE={OSM:class extends QC{constructor(t){let e;e=void 0!==(t=t||{}).attributions?t.attributions:['© <a href="https://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap</a> contributors.'];const n=void 0!==t.url?t.url:"https://tile.openstreetmap.org/{z}/{x}/{y}.png";super({attributions:e,attributionsCollapsible:!1,cacheSize:t.cacheSize,crossOrigin:void 0!==t.crossOrigin?t.crossOrigin:"anonymous",referrerPolicy:t.referrerPolicy||"origin-when-cross-origin",interpolate:t.interpolate,maxZoom:void 0!==t.maxZoom?t.maxZoom:19,reprojectionErrorThreshold:t.reprojectionErrorThreshold,tileLoadFunction:t.tileLoadFunction,transition:t.transition,url:n,wrapX:t.wrapX,zDirection:t.zDirection})}},XYZ:QC,TileWMS:class extends zm{constructor(t){t=t||{};const e=Object.assign({},t.params);super({attributions:t.attributions,attributionsCollapsible:t.attributionsCollapsible,cacheSize:t.cacheSize,crossOrigin:t.crossOrigin,interpolate:t.interpolate,projection:t.projection,reprojectionErrorThreshold:t.reprojectionErrorThreshold,tileClass:t.tileClass,tileGrid:t.tileGrid,tileLoadFunction:t.tileLoadFunction,url:t.url,urls:t.urls,wrapX:void 0===t.wrapX||t.wrapX,transition:t.transition,zDirection:t.zDirection}),this.gutter_=void 0!==t.gutter?t.gutter:0,this.params_=e,this.v13_=!0,this.serverType_=t.serverType,this.hidpi_=void 0===t.hidpi||t.hidpi,this.tmpExtent_=[1/0,1/0,-1/0,-1/0],this.updateV13_(),this.setKey(this.getKeyForParams_())}getFeatureInfoUrl(t,e,n,i){const r=Mo(n),s=this.getProjection()||r;let o=this.getTileGrid();o||(o=this.getTileGridForProjection(s));const a=$o(t,r,s),l=Lg(s,r,t,e),h=o.getZForResolution(l,this.zDirection),c=o.getResolution(h),u=o.getTileCoordForCoordAndZ(a,h);if(o.getResolutions().length<=u[0])return;let d=o.getTileCoordExtent(u,this.tmpExtent_);const f=this.gutter_;0!==f&&(d=Ir(d,c*f,d));const g={QUERY_LAYERS:this.params_.LAYERS};Object.assign(g,rE(this.params_,"GetFeatureInfo"),i);const p=Math.floor((a[0]-d[0])/c),m=Math.floor((d[3]-a[1])/c);return g[this.v13_?"I":"X"]=p,g[this.v13_?"J":"Y"]=m,this.getRequestUrl_(u,d,1,s||r,g)}getLegendUrl(t,e){if(void 0===this.urls[0])return;const n={SERVICE:"WMS",VERSION:tE,REQUEST:"GetLegendGraphic",FORMAT:"image/png"};if(void 0===e||void 0===e.LAYER){const t=this.params_.LAYERS;if(!(!Array.isArray(t)||1===t.length))return;n.LAYER=t}if(void 0!==t){const e=this.getProjection()?this.getProjection().getMetersPerUnit():1,i=28e-5;n.SCALE=t*e/i}return Object.assign(n,e),Sm(this.urls[0],n)}getGutter(){return this.gutter_}getParams(){return this.params_}getRequestUrl_(t,e,n,i,r){const s=this.urls;if(!s)return;let o;if(1==s.length)o=s[0];else{o=s[pr(Gg(t),s.length)]}return iE(e,(this.tileGrid||this.getTileGridForProjection(i)).getResolution(t[0]),n,i,o,r,this.serverType_)}getTilePixelRatio(t){return this.hidpi_&&void 0!==this.serverType_?t:1}getKeyForParams_(){let t=0;const e=[];for(const n in this.params_)e[t++]=n+"-"+this.params_[n];return e.join("/")}setParams_(t){this.params_=t,this.updateV13_(),this.setKey(this.getKeyForParams_())}setParams(t){this.setParams_(Object.assign({},t))}updateParams(t){this.setParams_(Object.assign(this.params_,t))}updateV13_(){const t=this.params_.VERSION||tE;this.v13_=ds(t,"1.3")>=0}tileUrlFunction(t,e,n){let i=this.getTileGrid();if(i||(i=this.getTileGridForProjection(n)),i.getResolutions().length<=t[0])return;1==e||this.hidpi_&&void 0!==this.serverType_||(e=1);const r=i.getResolution(t[0]);let s=i.getTileCoordExtent(t,this.tmpExtent_);const o=this.gutter_;0!==o&&(s=Ir(s,r*o,s));const a=Object.assign({},rE(this.params_,"GetMap"));return this.getRequestUrl_(t,s,e,n,a)}},BingMaps:class extends zm{constructor(t){const e=void 0!==t.hidpi&&t.hidpi;super({cacheSize:t.cacheSize,crossOrigin:"anonymous",interpolate:t.interpolate,projection:Mo("EPSG:3857"),reprojectionErrorThreshold:t.reprojectionErrorThreshold,state:"loading",tileLoadFunction:t.tileLoadFunction,tilePixelRatio:e?2:1,wrapX:void 0===t.wrapX||t.wrapX,transition:t.transition,zDirection:t.zDirection}),this.hidpi_=e,this.culture_=void 0!==t.culture?t.culture:"en-us",this.maxZoom_=void 0!==t.maxZoom?t.maxZoom:-1,this.apiKey_=t.key,this.imagerySet_=t.imagerySet,this.placeholderTiles_=t.placeholderTiles;const n=(t.url||"https://dev.virtualearth.net/REST/v1/Imagery/Metadata/")+this.imagerySet_+"?uriScheme=https&include=ImageryProviders&key="+this.apiKey_+"&c="+this.culture_;fetch(n).then(t=>t.json()).then(t=>this.handleImageryMetadataResponse(t))}getApiKey(){return this.apiKey_}getImagerySet(){return this.imagerySet_}handleImageryMetadataResponse(t){if(200!=t.statusCode||"OK"!=t.statusDescription||"ValidCredentials"!=t.authenticationResultCode||1!=t.resourceSets.length||1!=t.resourceSets[0].resources.length)return void this.setState("error");const e=t.resourceSets[0].resources[0],n=-1==this.maxZoom_?e.zoomMax:this.maxZoom_,i=bm(this.getProjection()),r=this.hidpi_?2:1,s=e.imageWidth==e.imageHeight?e.imageWidth/r:[e.imageWidth/r,e.imageHeight/r],o=ym({extent:i,minZoom:e.zoomMin,maxZoom:n,tileSize:s});this.tileGrid=o;const a=this.culture_,l=this.hidpi_,h=this.placeholderTiles_;if(this.tileUrlFunction=Mm(e.imageUrlSubdomains.map(function(t){const n=[0,0,0],i=e.imageUrl.replace("{subdomain}",t).replace("{culture}",a);return function(t,e,r){if(!t)return;Ng(t[0],t[1],t[2],n);const s=new URL(i.replace("{quadkey}",function(t){const e=t[0],n=new Array(e);let i,r,s=1<<e-1;for(i=0;i<e;++i)r=48,t[1]&s&&(r+=1),t[2]&s&&(r+=2),n[i]=String.fromCharCode(r),s>>=1;return n.join("")}(n))),o=s.searchParams;return l&&(o.set("dpi","d1"),o.set("device","mobile")),!0===h?o.delete("n"):!1===h&&o.set("n","z"),s.toString()}})),e.imageryProviders){const t=No(Mo("EPSG:4326"),this.getProjection());this.setAttributions(n=>{const i=[],r=n.viewState,s=this.getTileGrid(),o=s.getZForResolution(r.resolution,this.zDirection),a=s.getTileCoordForCoordAndZ(r.center,o)[0];return e.imageryProviders.map(function(e){let r=!1;const s=e.coverageAreas;for(let e=0,i=s.length;e<i;++e){const i=s[e];if(a>=i.zoomMin&&a<=i.zoomMax){const e=i.bbox;if(as(hs([e[1],e[0],e[3],e[2]],t),n.extent)){r=!0;break}}}r&&i.push(e.attribution)}),i.push('<a class="ol-attribution-bing-tos" href="https://www.microsoft.com/maps/product/terms.html" target="_blank">Terms of Use</a>'),i})}this.setState("ready")}},Vector:Hm,VectorTile:e_,ImageWMS:class extends S_{constructor(t){super({attributions:(t=t||{}).attributions,interpolate:t.interpolate,projection:t.projection,resolutions:t.resolutions}),this.crossOrigin_=void 0!==t.crossOrigin?t.crossOrigin:null,this.referrerPolicy_=t.referrerPolicy,this.url_=t.url,this.imageLoadFunction_=void 0!==t.imageLoadFunction?t.imageLoadFunction:C_,this.params_=Object.assign({},t.params),this.serverType_=t.serverType,this.hidpi_=void 0===t.hidpi||t.hidpi,this.renderedRevision_=0,this.ratio_=void 0!==t.ratio?t.ratio:1.5,this.loaderProjection_=null}getFeatureInfoUrl(t,e,n,i){const r=Mo(n),s=this.getProjection();s&&s!==r&&(e=Lg(s,r,t,e),t=$o(t,r,s));return function(t,e,n){if(void 0===t.url)return;const i=Mo(t.projection||"EPSG:3857"),r=ts(e,n,0,eE),s={QUERY_LAYERS:t.params.LAYERS,INFO_FORMAT:"application/json"};Object.assign(s,rE(t.params,"GetFeatureInfo"),t.params);const o=xr((e[0]-r[0])/n,4),a=xr((r[3]-e[1])/n,4),l=ds(s.VERSION,"1.3")>=0;return s[l?"I":"X"]=o,s[l?"J":"Y"]=a,nE(t.url,r,eE,i,s)}({url:this.url_,params:{...this.params_,...i},projection:s||r},t,e)}getLegendUrl(t,e){return function(t,e){if(void 0===t.url)return;const n={SERVICE:"WMS",VERSION:tE,REQUEST:"GetLegendGraphic",FORMAT:"image/png"};if(void 0!==e){const i=Mo(t.projection||"EPSG:3857").getMetersPerUnit()||1,r=28e-5;n.SCALE=e*i/r}if(Object.assign(n,t.params),void 0!==t.params&&void 0===n.LAYER){const t=n.LAYERS;if(Array.isArray(t)&&1===t.length)return;n.LAYER=t}return Sm(t.url,n)}({url:this.url_,params:{...this.params_,...e}},t)}getParams(){return this.params_}getImageInternal(t,e,n,i){return void 0===this.url_?null:(this.loader&&this.loaderProjection_===i||(this.loaderProjection_=i,this.loader=function(t){const e=void 0===t.hidpi||t.hidpi,n=Mo(t.projection||"EPSG:3857"),i=t.ratio||1.5,r=t.load||ud,s=t.crossOrigin??null,o=t.referrerPolicy;return(a,l,h)=>{a=E_(a,l,h,i),1==h||e&&void 0!==t.serverType||(h=1);const c=iE(a,l,h,n,t.url,rE(t.params,"GetMap"),t.serverType),u=new Image;return u.crossOrigin=s,void 0!==o&&(u.referrerPolicy=o),r(u,c).then(t=>({image:t,extent:a,pixelRatio:h}))}}({crossOrigin:this.crossOrigin_,referrerPolicy:this.referrerPolicy_,params:this.params_,projection:i,serverType:this.serverType_,hidpi:this.hidpi_,url:this.url_,ratio:this.ratio_,load:(t,e)=>(this.image.setImage(t),this.imageLoadFunction_(this.image,e),ud(t))})),super.getImageInternal(t,e,n,i))}getImageLoadFunction(){return this.imageLoadFunction_}getUrl(){return this.url_}setImageLoadFunction(t){this.imageLoadFunction_=t,this.changed()}setUrl(t){t!=this.url_&&(this.url_=t,this.loader=null,this.changed())}setParams(t){this.params_=Object.assign({},t),this.loader=null,this.changed()}updateParams(t){Object.assign(this.params_,t),this.changed()}changed(){this.image=null,super.changed()}},ImageStatic:class extends S_{constructor(t){const e=void 0!==t.crossOrigin?t.crossOrigin:null,n=void 0!==t.imageLoadFunction?t.imageLoadFunction:C_;super({attributions:t.attributions,interpolate:t.interpolate,projection:Mo(t.projection)}),this.url_=t.url,this.imageExtent_=t.imageExtent,this.image=null,this.image=new hd(this.imageExtent_,void 0,1,function(t){const e=t.load||ud,n=t.imageExtent,i=t.crossOrigin??null;return()=>{const r=new Image;return r.crossOrigin=i,void 0!==t.referrerPolicy&&(r.referrerPolicy=t.referrerPolicy),e(r,t.url).then(t=>{const e=os(n)/t.width,i=ns(n)/t.height;return{image:t,extent:n,resolution:e!==i?[e,i]:i,pixelRatio:1}})}}({url:t.url,imageExtent:t.imageExtent,crossOrigin:e,referrerPolicy:t.referrerPolicy,load:(t,e)=>(this.image.setImage(t),n(this.image,e),ud(t))})),this.image.addEventListener(Vn,this.handleImageChange.bind(this))}getImageExtent(){return this.imageExtent_}getImageInternal(t,e,n,i){return as(t,this.image.getExtent())?this.image:null}getUrl(){return this.url_}}};t.Collection=Ti,t.Feature=kf,t.Map=If,t.Observable=_i,t.Overlay=class extends Ci{constructor(t){super(),this.on,this.once,this.un,this.options=t,this.id=t.id,this.insertFirst=void 0===t.insertFirst||t.insertFirst,this.stopEvent=void 0===t.stopEvent||t.stopEvent,this.element=document.createElement("div"),this.element.className=void 0!==t.className?t.className:"ol-overlay-container ol-selectable",this.element.style.position="absolute",this.element.style.pointerEvents="auto",this.autoPan=!0===t.autoPan?{}:t.autoPan||void 0,this.rendered={transform_:"",visible:!0},this.mapPostrenderListenerKey=null,this.addChangeListener(U_,this.handleElementChanged),this.addChangeListener(V_,this.handleMapChanged),this.addChangeListener(X_,this.handleOffsetChanged),this.addChangeListener(W_,this.handlePositionChanged),this.addChangeListener(q_,this.handlePositioningChanged),void 0!==t.element&&this.setElement(t.element),this.setOffset(void 0!==t.offset?t.offset:[0,0]),this.setPositioning(t.positioning||"top-left"),void 0!==t.position&&this.setPosition(t.position)}getElement(){return this.get(U_)}getId(){return this.id}getMap(){return this.get(V_)||null}getOffset(){return this.get(X_)}getPosition(){return this.get(W_)}getPositioning(){return this.get(q_)}handleElementChanged(){Il(this.element);const t=this.getElement();t&&this.element.appendChild(t)}handleMapChanged(){this.mapPostrenderListenerKey&&(this.element?.remove(),Un(this.mapPostrenderListenerKey),this.mapPostrenderListenerKey=null);const t=this.getMap();if(t){this.mapPostrenderListenerKey=$n(t,Ui,this.render,this),this.updatePixelPosition();const e=this.stopEvent?t.getOverlayContainerStopEvent():t.getOverlayContainer();this.insertFirst?e.insertBefore(this.element,e.childNodes[0]||null):e.appendChild(this.element),this.performAutoPan()}}render(){this.updatePixelPosition()}handleOffsetChanged(){this.updatePixelPosition()}handlePositionChanged(){this.updatePixelPosition(),this.performAutoPan()}handlePositioningChanged(){this.updatePixelPosition()}setElement(t){this.set(U_,t)}setMap(t){this.set(V_,t)}setOffset(t){this.set(X_,t)}setPosition(t){this.set(W_,t)}performAutoPan(){this.autoPan&&this.panIntoView(this.autoPan)}panIntoView(t){const e=this.getMap();if(!e||!e.getTargetElement()||!this.get(W_))return;const n=this.getRect(e.getTargetElement(),e.getSize()),i=this.getElement(),r=this.getRect(i,[Rl(i),Fl(i)]),s=void 0===(t=t||{}).margin?20:t.margin;if(!Dr(n,r)){const i=r[0]-n[0],o=n[2]-r[2],a=r[1]-n[1],l=n[3]-r[3],h=[0,0];if(i<0?h[0]=i-s:o<0&&(h[0]=Math.abs(o)+s),a<0?h[1]=a-s:l<0&&(h[1]=Math.abs(l)+s),0!==h[0]||0!==h[1]){const n=e.getView().getCenterInternal(),i=e.getPixelFromCoordinateInternal(n);if(!i)return;const r=[i[0]+h[0],i[1]+h[1]],s=t.animation||{};e.getView().animateInternal({center:e.getCoordinateFromPixelInternal(r),duration:s.duration,easing:s.easing})}}}getRect(t,e){const n=t.getBoundingClientRect(),i=n.left+window.pageXOffset,r=n.top+window.pageYOffset;return[i,r,i+e[0],r+e[1]]}setPositioning(t){this.set(q_,t)}setVisible(t){this.rendered.visible!==t&&(this.element.style.display=t?"":"none",this.rendered.visible=t)}updatePixelPosition(){const t=this.getMap(),e=this.getPosition();if(!t||!t.isRendered()||!e)return void this.setVisible(!1);const n=t.getPixelFromCoordinate(e),i=t.getSize();this.updateRenderedPosition(n,i)}updateRenderedPosition(t,e){const n=this.element.style,i=this.getOffset(),r=this.getPositioning();this.setVisible(!0);let s="0%",o="0%";"bottom-right"==r||"center-right"==r||"top-right"==r?s="-100%":"bottom-center"!=r&&"center-center"!=r&&"top-center"!=r||(s="-50%"),"bottom-left"==r||"bottom-center"==r||"bottom-right"==r?o="-100%":"center-left"!=r&&"center-center"!=r&&"center-right"!=r||(o="-50%");const a=`translate(${s}, ${o}) translate(${`${t[0]+i[0]}px`}, ${`${t[1]+i[1]}px`})`;this.rendered.transform_!=a&&(this.rendered.transform_=a,n.transform=a)}getOptions(){return this.options}},t.View=dl,t.control=sE,t.format=oE,t.geom=lE,t.interaction=Fv,t.layer=aE,t.mapboxStyle=mx,t.proj=Jo,t.source=cE,t.sphere=Ms,t.style=hE,t.tilegrid=wm}); |
| 2 | //# sourceMappingURL=ol-custom.js.map |
no test coverage detected