text: import{B as t,n as e,u as i,l as s,E as n,a as o,aI as r,Q as a,a3 as l,W as h,N as c,Y as d,L as u,z as g,aJ as f,b as _,aK as m,aL as p,aM as y,aN as x,aO as S,aP as I,aQ as v,aR as C,k as w,aS as F,aT as O,aU as T,aV as L,aW as k,aX as R,ap as E,am as N,aY as b,a0 as D,aZ as P,a_ as G,a$ as A,b0 as M,b1 as Y,p as W,K as U,b2 as X,b3 as B,b4 as z,d as j,ah as V,b5 as J,b6 as Z,b7 as H,b8 as K,b9 as q,_ as $,ba as Q,s as tt,g as et,bb as it,m as st,bc as nt,a6 as ot,a1 as rt,bd as at,aa as lt,al as ht,ad as ct,S as dt,O as ut,av as gt,h as ft,T as _t,G as mt,be as pt,M as yt,I as xt,bf as St,U as It,aH as vt,y as Ct,aF as wt}from"./size-aa14a1dc.js";import{S as Ft,m as Ot,d as Tt,f as Lt,e as kt,i as Rt,g as Et,G as Nt,h as bt,j as Dt,k as Pt,l as Gt,p as At,q as Mt,r as Yt,t as Wt,P as Ut,u as Xt,v as Bt,w as zt,x as jt,y as Vt,z as Jt,A as Zt,B as Ht,D as Kt,E as qt,F as $t,H as Qt,J as te,K as ee,L as ie,M as se,N as ne,O as oe,Q as re,R as ae,T as le,V as he,U as ce,b as de,c as ue,W as ge,o as fe}from"./olMap-8ffb7ea3.js";import{I as _e,l as me,C as pe,S as ye}from"./Source-441004cf.js";import{p as xe}from"./string-4ef30a9f.js";import{r as Se,s as Ie}from"./rasters-f91a0263.js";import{$ as ve}from"./mapDef-32126832.js";var Ce="arraybuffer",we="json",Fe="text",Oe="xml";class Te extends t{constructor(t){if(super(),this.id_=void 0,this.geometryName_="geometry",this.style_=null,this.styleFunction_=void 0,this.geometryChangeKey_=null,this.addEventListener(e(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 Te(this.hasProperties()?this.getProperties():null);t.setGeometryName(this.getGeometryName());const e=this.getGeometry();e&&t.setGeometry(e.clone());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_&&(i(this.geometryChangeKey_),this.geometryChangeKey_=null);const t=this.getGeometry();t&&(this.geometryChangeKey_=s(t,n.CHANGE,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{o("function"==typeof t.getZIndex,41);e=[t]}return function(){return e}}}(t):void 0,this.changed()}setId(t){this.id_=t,this.changed()}setGeometryName(t){this.removeEventListener(e(this.geometryName_),this.handleGeometryChanged_),this.geometryName_=t,this.addEventListener(e(this.geometryName_),this.handleGeometryChanged_),this.handleGeometryChanged_()}}function Le(t,e,i,s,n,o,l){let h,c;const d=(i-e)/s;if(1===d)h=e;else if(2===d)h=e,c=n;else if(0!==d){let o=t[e],a=t[e+1],l=0;const d=[0];for(let n=e+s;n<i;n+=s){const e=t[n],i=t[n+1];l+=Math.sqrt((e-o)*(e-o)+(i-a)*(i-a)),d.push(l),o=e,a=i}const u=n*l,g=r(d,u);g<0?(c=(u-d[-g-2])/(d[-g-1]-d[-g-2]),h=e+(-g-2)*s):h=e+g*s}const u=l>1?l:2,g=o||new Array(u);for(let e=0;e<u;++e)g[e]=void 0===h?NaN:void 0===c?t[h+e]:a(t[h+e],t[h+s+e],c);return g}function ke(t,e,i,s,n,o){if(i==e)return null;let r;if(n<t[e+s-1])return o?(r=t.slice(e,e+s),r[s-1]=n,r):null;if(t[i-1]<n)return o?(r=t.slice(i-s,i),r[s-1]=n,r):null;if(n==t[e+s-1])return t.slice(e,e+s);let l=e/s,h=i/s;for(;l<h;){const e=l+h>>1;n<t[(e+1)*s-1]?h=e:l=e+1}const c=t[l*s-1];if(n==c)return t.slice((l-1)*s,(l-1)*s+s);const d=(n-c)/(t[(l+1)*s-1]-c);r=[];for(let e=0;e<s-1;++e)r.push(a(t[(l-1)*s+e],t[l*s+e],d));return r.push(n),r}function Re(t,e,i,s){let n=t[e],o=t[e+1],r=0;for(let a=e+s;a<i;a+=s){const e=t[a],i=t[a+1];r+=Math.sqrt((e-n)*(e-n)+(i-o)*(i-o)),n=e,o=i}return r}class Ee extends Ft{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){this.flatCoordinates?l(this.flatCoordinates,t):this.flatCoordinates=t.slice(),this.changed()}clone(){const t=new Ee(this.flatCoordinates.slice(),this.layout);return t.applyProperties(this),t}closestPointXY(t,e,i,s){return s<h(this.getExtent(),t,e)?s:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(Ot(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),Tt(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,this.maxDelta_,!1,t,e,i,s))}forEachSegment(t){return Lt(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t)}getCoordinateAtM(t,e){if(this.layout!=kt.XYM&&this.layout!=kt.XYZM)return null;const i=void 0!==e&&e;return ke(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t,i)}getCoordinates(){return Rt(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getCoordinateAt(t,e){return Le(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t,e,this.stride)}getLength(){return Re(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getFlatMidpoint(){return this.flatMidpointRevision_!=this.getRevision()&&(this.flatMidpoint_=this.getCoordinateAt(.5,this.flatMidpoint_),this.flatMidpointRevision_=this.getRevision()),this.flatMidpoint_}getSimplifiedGeometryInternal(t){const e=[];return e.length=Et(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t,e,0),new Ee(e,kt.XY)}getType(){return Nt.LINE_STRING}intersectsExtent(t){return bt(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t)}setCoordinates(t,e){this.setLayout(e,t,1),this.flatCoordinates||(this.flatCoordinates=[]),this.flatCoordinates.length=Dt(this.flatCoordinates,0,t,this.stride),this.changed()}}class Ne extends Ft{constructor(t,e,i){if(super(),this.ends_=[],this.maxDelta_=-1,this.maxDeltaRevision_=-1,Array.isArray(t[0]))this.setCoordinates(t,e);else if(void 0!==e&&i)this.setFlatCoordinates(e,t),this.ends_=i;else{let e=this.getLayout();const i=t,s=[],n=[];for(let t=0,o=i.length;t<o;++t){const o=i[t];0===t&&(e=o.getLayout()),l(s,o.getFlatCoordinates()),n.push(s.length)}this.setFlatCoordinates(e,s),this.ends_=n}}appendLineString(t){this.flatCoordinates?l(this.flatCoordinates,t.getFlatCoordinates().slice()):this.flatCoordinates=t.getFlatCoordinates().slice(),this.ends_.push(this.flatCoordinates.length),this.changed()}clone(){const t=new Ne(this.flatCoordinates.slice(),this.layout,this.ends_.slice());return t.applyProperties(this),t}closestPointXY(t,e,i,s){return s<h(this.getExtent(),t,e)?s:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(Pt(this.flatCoordinates,0,this.ends_,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),Gt(this.flatCoordinates,0,this.ends_,this.stride,this.maxDelta_,!1,t,e,i,s))}getCoordinateAtM(t,e,i){if(this.layout!=kt.XYM&&this.layout!=kt.XYZM||0===this.flatCoordinates.length)return null;const s=void 0!==e&&e,n=void 0!==i&&i;return function(t,e,i,s,n,o,r){if(r)return ke(t,e,i[i.length-1],s,n,o);let a;if(n<t[s-1])return o?(a=t.slice(0,s),a[s-1]=n,a):null;if(t[t.length-1]<n)return o?(a=t.slice(t.length-s),a[s-1]=n,a):null;for(let o=0,r=i.length;o<r;++o){const r=i[o];if(e!=r){if(n<t[e+s-1])return null;if(n<=t[r-1])return ke(t,e,r,s,n,!1);e=r}}return null}(this.flatCoordinates,0,this.ends_,this.stride,t,s,n)}getCoordinates(){return At(this.flatCoordinates,0,this.ends_,this.stride)}getEnds(){return this.ends_}getLineString(t){return t<0||this.ends_.length<=t?null:new Ee(this.flatCoordinates.slice(0===t?0:this.ends_[t-1],this.ends_[t]),this.layout)}getLineStrings(){const t=this.flatCoordinates,e=this.ends_,i=this.layout,s=[];let n=0;for(let o=0,r=e.length;o<r;++o){const r=e[o],a=new Ee(t.slice(n,r),i);s.push(a),n=r}return s}getFlatMidpoints(){const t=[],e=this.flatCoordinates;let i=0;const s=this.ends_,n=this.stride;for(let o=0,r=s.length;o<r;++o){const r=s[o],a=Le(e,i,r,n,.5);l(t,a),i=r}return t}getSimplifiedGeometryInternal(t){const e=[],i=[];return e.length=Mt(this.flatCoordinates,0,this.ends_,this.stride,t,e,0,i),new Ne(e,kt.XY,i)}getType(){return Nt.MULTI_LINE_STRING}intersectsExtent(t){return Yt(this.flatCoordinates,0,this.ends_,this.stride,t)}setCoordinates(t,e){this.setLayout(e,t,2),this.flatCoordinates||(this.flatCoordinates=[]);const i=Wt(this.flatCoordinates,0,t,this.stride,this.ends_);this.flatCoordinates.length=0===i.length?0:i[i.length-1],this.changed()}}class be extends Ft{constructor(t,e){super(),e&&!Array.isArray(t[0])?this.setFlatCoordinates(e,t):this.setCoordinates(t,e)}appendPoint(t){this.flatCoordinates?l(this.flatCoordinates,t.getFlatCoordinates()):this.flatCoordinates=t.getFlatCoordinates().slice(),this.changed()}clone(){const t=new be(this.flatCoordinates.slice(),this.layout);return t.applyProperties(this),t}closestPointXY(t,e,i,s){if(s<h(this.getExtent(),t,e))return s;const n=this.flatCoordinates,o=this.stride;for(let r=0,a=n.length;r<a;r+=o){const a=c(t,e,n[r],n[r+1]);if(a<s){s=a;for(let t=0;t<o;++t)i[t]=n[r+t];i.length=o}}return s}getCoordinates(){return Rt(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getPoint(t){const e=this.flatCoordinates?this.flatCoordinates.length/this.stride:0;return t<0||e<=t?null:new Ut(this.flatCoordinates.slice(t*this.stride,(t+1)*this.stride),this.layout)}getPoints(){const t=this.flatCoordinates,e=this.layout,i=this.stride,s=[];for(let n=0,o=t.length;n<o;n+=i){const o=new Ut(t.slice(n,n+i),e);s.push(o)}return s}getType(){return Nt.MULTI_POINT}intersectsExtent(t){const e=this.flatCoordinates,i=this.stride;for(let s=0,n=e.length;s<n;s+=i){const i=e[s],n=e[s+1];if(d(t,i,n))return!0}return!1}setCoordinates(t,e){this.setLayout(e,t,1),this.flatCoordinates||(this.flatCoordinates=[]),this.flatCoordinates.length=Dt(this.flatCoordinates,0,t,this.stride),this.changed()}}class De extends Ft{constructor(t,e,i){if(super(),this.endss_=[],this.flatInteriorPointsRevision_=-1,this.flatInteriorPoints_=null,this.maxDelta_=-1,this.maxDeltaRevision_=-1,this.orientedRevision_=-1,this.orientedFlatCoordinates_=null,!i&&!Array.isArray(t[0])){let s=this.getLayout();const n=t,o=[],r=[];for(let t=0,e=n.length;t<e;++t){const e=n[t];0===t&&(s=e.getLayout());const i=o.length,a=e.getEnds();for(let t=0,e=a.length;t<e;++t)a[t]+=i;l(o,e.getFlatCoordinates()),r.push(a)}e=s,t=o,i=r}void 0!==e&&i?(this.setFlatCoordinates(e,t),this.endss_=i):this.setCoordinates(t,e)}appendPolygon(t){let e;if(this.flatCoordinates){const i=this.flatCoordinates.length;l(this.flatCoordinates,t.getFlatCoordinates()),e=t.getEnds().slice();for(let t=0,s=e.length;t<s;++t)e[t]+=i}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 i=0;i<t;++i)e[i]=this.endss_[i].slice();const i=new De(this.flatCoordinates.slice(),this.layout,e);return i.applyProperties(this),i}closestPointXY(t,e,i,s){return s<h(this.getExtent(),t,e)?s:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(Xt(this.flatCoordinates,0,this.endss_,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),Bt(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride,this.maxDelta_,!0,t,e,i,s))}containsXY(t,e){return zt(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride,t,e)}getArea(){return jt(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride)}getCoordinates(t){let e;return void 0!==t?(e=this.getOrientedFlatCoordinates().slice(),Vt(e,0,this.endss_,this.stride,t)):e=this.flatCoordinates,Jt(e,0,this.endss_,this.stride)}getEndss(){return this.endss_}getFlatInteriorPoints(){if(this.flatInteriorPointsRevision_!=this.getRevision()){const t=function(t,e,i,s){const n=[];let o=g();for(let r=0,a=i.length;r<a;++r){const a=i[r];o=u(t,e,a[0],s),n.push((o[0]+o[2])/2,(o[1]+o[3])/2),e=a[a.length-1]}return n}(this.flatCoordinates,0,this.endss_,this.stride);this.flatInteriorPoints_=Zt(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride,t),this.flatInteriorPointsRevision_=this.getRevision()}return this.flatInteriorPoints_}getInteriorPoints(){return new be(this.getFlatInteriorPoints().slice(),kt.XYM)}getOrientedFlatCoordinates(){if(this.orientedRevision_!=this.getRevision()){const t=this.flatCoordinates;Ht(t,0,this.endss_,this.stride)?this.orientedFlatCoordinates_=t:(this.orientedFlatCoordinates_=t.slice(),this.orientedFlatCoordinates_.length=Vt(this.orientedFlatCoordinates_,0,this.endss_,this.stride)),this.orientedRevision_=this.getRevision()}return this.orientedFlatCoordinates_}getSimplifiedGeometryInternal(t){const e=[],i=[];return e.length=Kt(this.flatCoordinates,0,this.endss_,this.stride,Math.sqrt(t),e,0,i),new De(e,kt.XY,i)}getPolygon(t){if(t<0||this.endss_.length<=t)return null;let e;if(0===t)e=0;else{const i=this.endss_[t-1];e=i[i.length-1]}const i=this.endss_[t].slice(),s=i[i.length-1];if(0!==e)for(let t=0,s=i.length;t<s;++t)i[t]-=e;return new qt(this.flatCoordinates.slice(e,s),this.layout,i)}getPolygons(){const t=this.layout,e=this.flatCoordinates,i=this.endss_,s=[];let n=0;for(let o=0,r=i.length;o<r;++o){const r=i[o].slice(),a=r[r.length-1];if(0!==n)for(let t=0,e=r.length;t<e;++t)r[t]-=n;const l=new qt(e.slice(n,a),t,r);s.push(l),n=a}return s}getType(){return Nt.MULTI_POLYGON}intersectsExtent(t){return $t(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride,t)}setCoordinates(t,e){this.setLayout(e,t,3),this.flatCoordinates||(this.flatCoordinates=[]);const i=Qt(this.flatCoordinates,0,t,this.stride,this.endss_);if(0===i.length)this.flatCoordinates.length=0;else{const t=i[i.length-1];this.flatCoordinates.length=0===t.length?0:t[t.length-1]}this.changed()}}class Pe{constructor(t){this.opacity_=t.opacity,this.rotateWithView_=t.rotateWithView,this.rotation_=t.rotation,this.scale_=t.scale,this.scaleArray_=f(t.scale),this.displacement_=t.displacement}clone(){const t=this.getScale();return new Pe({opacity:this.getOpacity(),scale:Array.isArray(t)?t.slice():t,rotation:this.getRotation(),rotateWithView:this.getRotateWithView(),displacement:this.getDisplacement().slice()})}getOpacity(){return this.opacity_}getRotateWithView(){return this.rotateWithView_}getRotation(){return this.rotation_}getScale(){return this.scale_}getScaleArray(){return this.scaleArray_}getDisplacement(){return this.displacement_}getAnchor(){return _()}getImage(t){return _()}getHitDetectionImage(){return _()}getPixelRatio(t){return 1}getImageState(){return _()}getImageSize(){return _()}getHitDetectionImageSize(){return _()}getOrigin(){return _()}getSize(){return _()}setOpacity(t){this.opacity_=t}setRotateWithView(t){this.rotateWithView_=t}setRotation(t){this.rotation_=t}setScale(t){this.scale_=t,this.scaleArray_=f(t)}listenImageChange(t){_()}load(){_()}unlistenImageChange(t){_()}}function Ge(t){return Array.isArray(t)?te(t):t}class Ae extends Pe{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]}),this.canvas_={},this.hitDetectionCanvas_=null,this.fill_=void 0!==t.fill?t.fill:null,this.origin_=[0,0],this.points_=t.points,this.radius_=void 0!==t.radius?t.radius:t.radius1,this.radius2_=t.radius2,this.angle_=void 0!==t.angle?t.angle:0,this.stroke_=void 0!==t.stroke?t.stroke:null,this.anchor_=null,this.size_=null,this.imageSize_=null,this.hitDetectionImageSize_=null,this.render()}clone(){const t=this.getScale(),e=new Ae({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()});return e.setOpacity(this.getOpacity()),e}getAnchor(){return this.anchor_}getAngle(){return this.angle_}getFill(){return this.fill_}getHitDetectionImage(){if(!this.hitDetectionCanvas_){const t=this.createRenderOptions();this.createHitDetectionCanvas_(t)}return this.hitDetectionCanvas_}getImage(t){if(!this.canvas_[t||1]){const e=this.createRenderOptions(),i=m(e.size*t||1,e.size*t||1);this.draw_(e,i,0,0,t||1),this.canvas_[t||1]=i.canvas}return this.canvas_[t||1]}getPixelRatio(t){return t}getImageSize(){return this.imageSize_}getHitDetectionImageSize(){return this.hitDetectionImageSize_}getImageState(){return _e.LOADED}getOrigin(){return this.origin_}getPoints(){return this.points_}getRadius(){return this.radius_}getRadius2(){return this.radius2_}getSize(){return this.size_}getStroke(){return this.stroke_}listenImageChange(t){}load(){}unlistenImageChange(t){}createRenderOptions(){let t,e=y,i=x,s=0,n=null,o=0,r=0;this.stroke_&&(t=this.stroke_.getColor(),null===t&&(t=S),t=Ge(t),r=this.stroke_.getWidth(),void 0===r&&(r=I),n=this.stroke_.getLineDash(),o=this.stroke_.getLineDashOffset(),i=this.stroke_.getLineJoin(),void 0===i&&(i=x),e=this.stroke_.getLineCap(),void 0===e&&(e=y),s=this.stroke_.getMiterLimit(),void 0===s&&(s=v));return{strokeStyle:t,strokeWidth:r,size:2*(this.radius_+r)+1,lineCap:e,lineDash:n,lineDashOffset:o,lineJoin:i,miterLimit:s}}render(){const t=this.createRenderOptions(),e=m(t.size,t.size);this.draw_(t,e,0,0,1),this.canvas_={},this.canvas_[1]=e.canvas;const i=e.canvas.width,s=i,n=this.getDisplacement();this.hitDetectionImageSize_=[t.size,t.size],this.createHitDetectionCanvas_(t),this.anchor_=[i/2-n[0],i/2+n[1]],this.size_=[i,i],this.imageSize_=[s,s]}draw_(t,e,i,s,n){let o,r,a;e.setTransform(n,0,0,n,0,0),e.translate(i,s),e.beginPath();let l=this.points_;if(l===1/0)e.arc(t.size/2,t.size/2,this.radius_,0,2*Math.PI,!0);else{const i=void 0!==this.radius2_?this.radius2_:this.radius_;for(i!==this.radius_&&(l*=2),o=0;o<=l;o++)r=2*o*Math.PI/l-Math.PI/2+this.angle_,a=o%2==0?this.radius_:i,e.lineTo(t.size/2+a*Math.cos(r),t.size/2+a*Math.sin(r))}if(this.fill_){let t=this.fill_.getColor();null===t&&(t=p),e.fillStyle=Ge(t),e.fill()}this.stroke_&&(e.strokeStyle=t.strokeStyle,e.lineWidth=t.strokeWidth,e.setLineDash&&t.lineDash&&(e.setLineDash(t.lineDash),e.lineDashOffset=t.lineDashOffset),e.lineCap=t.lineCap,e.lineJoin=t.lineJoin,e.miterLimit=t.miterLimit,e.stroke()),e.closePath()}createHitDetectionCanvas_(t){if(this.hitDetectionCanvas_=this.getImage(1),this.fill_){let e=this.fill_.getColor(),i=0;if("string"==typeof e&&(e=ee(e)),null===e?i=1:Array.isArray(e)&&(i=4===e.length?e[3]:1),0===i){const e=m(t.size,t.size);this.hitDetectionCanvas_=e.canvas,this.drawHitDetectionCanvas_(t,e,0,0)}}}drawHitDetectionCanvas_(t,e,i,s){e.translate(i,s),e.beginPath();let n=this.points_;if(n===1/0)e.arc(t.size/2,t.size/2,this.radius_,0,2*Math.PI,!0);else{const i=void 0!==this.radius2_?this.radius2_:this.radius_;let s,o,r;for(i!==this.radius_&&(n*=2),s=0;s<=n;s++)r=2*s*Math.PI/n-Math.PI/2+this.angle_,o=s%2==0?this.radius_:i,e.lineTo(t.size/2+o*Math.cos(r),t.size/2+o*Math.sin(r))}e.fillStyle=p,e.fill(),this.stroke_&&(e.strokeStyle=t.strokeStyle,e.lineWidth=t.strokeWidth,t.lineDash&&(e.setLineDash(t.lineDash),e.lineDashOffset=t.lineDashOffset),e.stroke()),e.closePath()}}class Me extends Ae{constructor(t){const e=t||{};super({points:1/0,fill:e.fill,radius:e.radius,stroke:e.stroke,scale:void 0!==e.scale?e.scale:1,rotation:void 0!==e.rotation?e.rotation:0,rotateWithView:void 0!==e.rotateWithView&&e.rotateWithView,displacement:void 0!==e.displacement?e.displacement:[0,0]})}clone(){const t=this.getScale(),e=new Me({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()});return e.setOpacity(this.getOpacity()),e}setRadius(t){this.radius_=t,this.render()}}class Ye{constructor(t){const e=t||{};this.color_=void 0!==e.color?e.color:null}clone(){const t=this.getColor();return new Ye({color:Array.isArray(t)?t.slice():t||void 0})}getColor(){return this.color_}setColor(t){this.color_=t}}class We{constructor(t){const e=t||{};this.color_=void 0!==e.color?e.color:null,this.lineCap_=e.lineCap,this.lineDash_=void 0!==e.lineDash?e.lineDash:null,this.lineDashOffset_=e.lineDashOffset,this.lineJoin_=e.lineJoin,this.miterLimit_=e.miterLimit,this.width_=e.width}clone(){const t=this.getColor();return new We({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(),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_}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}setWidth(t){this.width_=t}}class Ue{constructor(t){const e=t||{};this.geometry_=null,this.geometryFunction_=je,void 0!==e.geometry&&this.setGeometry(e.geometry),this.fill_=void 0!==e.fill?e.fill:null,this.image_=void 0!==e.image?e.image:null,this.renderer_=void 0!==e.renderer?e.renderer:null,this.stroke_=void 0!==e.stroke?e.stroke:null,this.text_=void 0!==e.text?e.text:null,this.zIndex_=e.zIndex}clone(){let t=this.getGeometry();return t&&"object"==typeof t&&(t=t.clone()),new Ue({geometry:t,fill:this.getFill()?this.getFill().clone():void 0,image:this.getImage()?this.getImage().clone():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}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_=je,this.geometry_=t}setZIndex(t){this.zIndex_=t}}let Xe=null;function Be(t,e){if(!Xe){const t=new Ye({color:"rgba(255,255,255,0.4)"}),e=new We({color:"#3399CC",width:1.25});Xe=[new Ue({image:new Me({fill:t,stroke:e,radius:5}),fill:t,stroke:e})]}return Xe}function ze(){const t={},e=[255,255,255,1],i=[0,153,255,1];return t[Nt.POLYGON]=[new Ue({fill:new Ye({color:[255,255,255,.5]})})],t[Nt.MULTI_POLYGON]=t[Nt.POLYGON],t[Nt.LINE_STRING]=[new Ue({stroke:new We({color:e,width:5})}),new Ue({stroke:new We({color:i,width:3})})],t[Nt.MULTI_LINE_STRING]=t[Nt.LINE_STRING],t[Nt.CIRCLE]=t[Nt.POLYGON].concat(t[Nt.LINE_STRING]),t[Nt.POINT]=[new Ue({image:new Me({radius:6,fill:new Ye({color:i}),stroke:new We({color:e,width:1.5})}),zIndex:1/0})],t[Nt.MULTI_POINT]=t[Nt.POINT],t[Nt.GEOMETRY_COLLECTION]=t[Nt.POLYGON].concat(t[Nt.LINE_STRING],t[Nt.POINT]),t}function je(t){return t.getGeometry()}const Ve="renderOrder";class Je extends C{constructor(t){const e=t||{},i=w({},e);delete i.style,delete i.renderBuffer,delete i.updateWhileAnimating,delete i.updateWhileInteracting,super(i),this.declutter_=void 0!==e.declutter&&e.declutter,this.renderBuffer_=void 0!==e.renderBuffer?e.renderBuffer:100,this.style_=null,this.styleFunction_=void 0,this.setStyle(e.style),this.updateWhileAnimating_=void 0!==e.updateWhileAnimating&&e.updateWhileAnimating,this.updateWhileInteracting_=void 0!==e.updateWhileInteracting&&e.updateWhileInteracting}getDeclutter(){return this.declutter_}getFeatures(t){return super.getFeatures(t)}getRenderBuffer(){return this.renderBuffer_}getRenderOrder(){return this.get(Ve)}getStyle(){return this.style_}getStyleFunction(){return this.styleFunction_}getUpdateWhileAnimating(){return this.updateWhileAnimating_}getUpdateWhileInteracting(){return this.updateWhileInteracting_}renderDeclutter(t){t.declutterTree||(t.declutterTree=new ie(9)),this.getRenderer().renderDeclutter(t)}setRenderOrder(t){this.set(Ve,t)}setStyle(t){this.style_=void 0!==t?t:Be,this.styleFunction_=null===t?void 0:function(t){let e;if("function"==typeof t)e=t;else{let i;Array.isArray(t)?i=t:(o("function"==typeof t.getZIndex,41),i=[t]),e=function(){return i}}return e}(this.style_),this.changed()}}const Ze=0,He=1,Ke=2,qe=3,$e=4,Qe=5,ti=6,ei=7,ii=8,si=9,ni=10,oi=11,ri=12,ai=[ii],li=[ri],hi=[He],ci=[qe];class di{drawCustom(t,e,i){}drawGeometry(t){}setStyle(t){}drawCircle(t,e){}drawFeature(t,e){}drawGeometryCollection(t,e){}drawLineString(t,e){}drawMultiLineString(t,e){}drawMultiPoint(t,e){}drawMultiPolygon(t,e){}drawPoint(t,e){}drawPolygon(t,e){}drawText(t,e){}setFillStrokeStyle(t,e){}setImageStyle(t,e){}setTextStyle(t,e){}}class ui extends di{constructor(t,e,i,s){super(),this.tolerance=t,this.maxExtent=e,this.pixelRatio=s,this.maxLineWidth=0,this.resolution=i,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 i=this.getBufferedMaxExtent(),s=this.tmpCoordinate_,n=this.coordinates;let o=n.length;for(let r=0,a=t.length;r<a;r+=e)s[0]=t[r],s[1]=t[r+1],F(i,s)&&(n[o++]=s[0],n[o++]=s[1]);return o}appendFlatLineCoordinates(t,e,i,s,n,o){const r=this.coordinates;let a=r.length;const l=this.getBufferedMaxExtent();o&&(e+=s);let h=t[e],c=t[e+1];const d=this.tmpCoordinate_;let u,g,f,_=!0;for(u=e+s;u<i;u+=s)d[0]=t[u],d[1]=t[u+1],f=O(l,d),f!==g?(_&&(r[a++]=h,r[a++]=c,_=!1),r[a++]=d[0],r[a++]=d[1]):f===T.INTERSECTING?(r[a++]=d[0],r[a++]=d[1],_=!1):_=!0,h=d[0],c=d[1],g=f;return(n&&_||u===e+s)&&(r[a++]=h,r[a++]=c),a}drawCustomCoordinates_(t,e,i,s,n){for(let o=0,r=i.length;o<r;++o){const r=i[o],a=this.appendFlatLineCoordinates(t,e,r,s,!1,!1);n.push(a),e=r}return e}drawCustom(t,e,i){this.beginGeometry(t,e);const s=t.getType(),n=t.getStride(),o=this.coordinates.length;let r,a,l,h,c;if(s==Nt.MULTI_POLYGON){r=t.getOrientedFlatCoordinates(),h=[];const e=t.getEndss();c=0;for(let t=0,i=e.length;t<i;++t){const i=[];c=this.drawCustomCoordinates_(r,c,e[t],n,i),h.push(i)}this.instructions.push([$e,o,h,t,i,Jt])}else s==Nt.POLYGON||s==Nt.MULTI_LINE_STRING?(l=[],r=s==Nt.POLYGON?t.getOrientedFlatCoordinates():t.getFlatCoordinates(),c=this.drawCustomCoordinates_(r,0,t.getEnds(),n,l),this.instructions.push([$e,o,l,t,i,At])):s==Nt.LINE_STRING||s==Nt.CIRCLE?(r=t.getFlatCoordinates(),a=this.appendFlatLineCoordinates(r,0,r.length,n,!1,!1),this.instructions.push([$e,o,a,t,i,Rt])):s==Nt.MULTI_POINT?(r=t.getFlatCoordinates(),a=this.appendFlatPointCoordinates(r,n),a>o&&this.instructions.push([$e,o,a,t,i,Rt])):s==Nt.POINT&&(r=t.getFlatCoordinates(),this.coordinates.push(r[0],r[1]),a=this.coordinates.length,this.instructions.push([$e,o,a,t,i]));this.endGeometry(e)}beginGeometry(t,e){this.beginGeometryInstruction1_=[Ze,e,0,t],this.instructions.push(this.beginGeometryInstruction1_),this.beginGeometryInstruction2_=[Ze,e,0,t],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 i=t.length;let s,n,o=-1;for(e=0;e<i;++e)s=t[e],n=s[0],n==ei?o=e:n==Ze&&(s[2]=e,L(this.hitDetectionInstructions,o,e),o=-1)}setFillStrokeStyle(t,e){const i=this.state;if(t){const e=t.getColor();i.fillStyle=Ge(e||p)}else i.fillStyle=void 0;if(e){const t=e.getColor();i.strokeStyle=Ge(t||S);const s=e.getLineCap();i.lineCap=void 0!==s?s:y;const n=e.getLineDash();i.lineDash=n?n.slice():k;const o=e.getLineDashOffset();i.lineDashOffset=o||R;const r=e.getLineJoin();i.lineJoin=void 0!==r?r:x;const a=e.getWidth();i.lineWidth=void 0!==a?a:I;const l=e.getMiterLimit();i.miterLimit=void 0!==l?l:v,i.lineWidth>this.maxLineWidth&&(this.maxLineWidth=i.lineWidth,this.bufferedMaxExtent_=null)}else i.strokeStyle=void 0,i.lineCap=void 0,i.lineDash=null,i.lineDashOffset=void 0,i.lineJoin=void 0,i.lineWidth=void 0,i.miterLimit=void 0}createFill(t){const e=t.fillStyle,i=[ni,e];return"string"!=typeof e&&i.push(!0),i}applyStroke(t){this.instructions.push(this.createStroke(t))}createStroke(t){return[oi,t.strokeStyle,t.lineWidth*this.pixelRatio,t.lineCap,t.lineJoin,t.miterLimit,this.applyPixelRatio(t.lineDash),t.lineDashOffset*this.pixelRatio]}updateFillStyle(t,e){const i=t.fillStyle;"string"==typeof i&&t.currentFillStyle==i||(void 0!==i&&this.instructions.push(e.call(this,t)),t.currentFillStyle=i)}updateStrokeStyle(t,e){const i=t.strokeStyle,s=t.lineCap,n=t.lineDash,o=t.lineDashOffset,r=t.lineJoin,a=t.lineWidth,l=t.miterLimit;(t.currentStrokeStyle!=i||t.currentLineCap!=s||n!=t.currentLineDash&&!E(t.currentLineDash,n)||t.currentLineDashOffset!=o||t.currentLineJoin!=r||t.currentLineWidth!=a||t.currentMiterLimit!=l)&&(void 0!==i&&e.call(this,t),t.currentStrokeStyle=i,t.currentLineCap=s,t.currentLineDash=n,t.currentLineDashOffset=o,t.currentLineJoin=r,t.currentLineWidth=a,t.currentMiterLimit=l)}endGeometry(t){this.beginGeometryInstruction1_[2]=this.instructions.length,this.beginGeometryInstruction1_=null,this.beginGeometryInstruction2_[2]=this.hitDetectionInstructions.length,this.beginGeometryInstruction2_=null;const e=[ei,t];this.instructions.push(e),this.hitDetectionInstructions.push(e)}getBufferedMaxExtent(){if(!this.bufferedMaxExtent_&&(this.bufferedMaxExtent_=N(this.maxExtent),this.maxLineWidth>0)){const t=this.resolution*(this.maxLineWidth+1)/2;b(this.bufferedMaxExtent_,t,this.bufferedMaxExtent_)}return this.bufferedMaxExtent_}}class gi extends ui{constructor(t,e,i,s){super(t,e,i,s)}drawFlatCoordinatess_(t,e,i,s){const n=this.state,o=void 0!==n.fillStyle,r=void 0!==n.strokeStyle,a=i.length;this.instructions.push(hi),this.hitDetectionInstructions.push(hi);for(let n=0;n<a;++n){const o=i[n],a=this.coordinates.length,l=this.appendFlatLineCoordinates(t,e,o,s,!0,!r),h=[si,a,l];this.instructions.push(h),this.hitDetectionInstructions.push(h),r&&(this.instructions.push(ci),this.hitDetectionInstructions.push(ci)),e=o}return o&&(this.instructions.push(ai),this.hitDetectionInstructions.push(ai)),r&&(this.instructions.push(li),this.hitDetectionInstructions.push(li)),e}drawCircle(t,e){const i=this.state,s=i.fillStyle,n=i.strokeStyle;if(void 0===s&&void 0===n)return;this.setFillStrokeStyles_(),this.beginGeometry(t,e),void 0!==i.fillStyle&&this.hitDetectionInstructions.push([ni,p]),void 0!==i.strokeStyle&&this.hitDetectionInstructions.push([oi,i.strokeStyle,i.lineWidth,i.lineCap,i.lineJoin,i.miterLimit,i.lineDash,i.lineDashOffset]);const o=t.getFlatCoordinates(),r=t.getStride(),a=this.coordinates.length;this.appendFlatLineCoordinates(o,0,o.length,r,!1,!1);const l=[Ke,a];this.instructions.push(hi,l),this.hitDetectionInstructions.push(hi,l),void 0!==i.fillStyle&&(this.instructions.push(ai),this.hitDetectionInstructions.push(ai)),void 0!==i.strokeStyle&&(this.instructions.push(li),this.hitDetectionInstructions.push(li)),this.endGeometry(e)}drawPolygon(t,e){const i=this.state,s=i.fillStyle,n=i.strokeStyle;if(void 0===s&&void 0===n)return;this.setFillStrokeStyles_(),this.beginGeometry(t,e),void 0!==i.fillStyle&&this.hitDetectionInstructions.push([ni,p]),void 0!==i.strokeStyle&&this.hitDetectionInstructions.push([oi,i.strokeStyle,i.lineWidth,i.lineCap,i.lineJoin,i.miterLimit,i.lineDash,i.lineDashOffset]);const o=t.getEnds(),r=t.getOrientedFlatCoordinates(),a=t.getStride();this.drawFlatCoordinatess_(r,0,o,a),this.endGeometry(e)}drawMultiPolygon(t,e){const i=this.state,s=i.fillStyle,n=i.strokeStyle;if(void 0===s&&void 0===n)return;this.setFillStrokeStyles_(),this.beginGeometry(t,e),void 0!==i.fillStyle&&this.hitDetectionInstructions.push([ni,p]),void 0!==i.strokeStyle&&this.hitDetectionInstructions.push([oi,i.strokeStyle,i.lineWidth,i.lineCap,i.lineJoin,i.miterLimit,i.lineDash,i.lineDashOffset]);const o=t.getEndss(),r=t.getOrientedFlatCoordinates(),a=t.getStride();let l=0;for(let t=0,e=o.length;t<e;++t)l=this.drawFlatCoordinatess_(r,l,o[t],a);this.endGeometry(e)}finish(){this.reverseHitDetectionInstructions(),this.state=null;const t=this.tolerance;if(0!==t){const e=this.coordinates;for(let i=0,s=e.length;i<s;++i)e[i]=se(e[i],t)}return super.finish()}setFillStrokeStyles_(){const t=this.state;void 0!==t.fillStyle&&this.updateFillStyle(t,this.createFill),void 0!==t.strokeStyle&&this.updateStrokeStyle(t,this.applyStroke)}}var fi="point",_i="line";function mi(t,e,i,s,n){let o,r,a,l,h,c,d,u,g,f,_=i,m=i,p=0,y=0,x=i;for(r=i;r<s;r+=n){const i=e[r],s=e[r+1];void 0!==h&&(g=i-h,f=s-c,l=Math.sqrt(g*g+f*f),void 0!==d&&(y+=a,o=Math.acos((d*g+u*f)/(a*l)),o>t&&(y>p&&(p=y,_=x,m=r),y=0,x=r-n)),a=l,d=g,u=f),h=i,c=s}return y+=l,y>p?[x,r]:[_,m]}const pi={left:0,end:0,center:.5,right:1,start:1,top:0,middle:.5,hanging:.2,alphabetic:.8,ideographic:.8,bottom:1};const yi={Circle:gi,Default:ui,Image:class extends ui{constructor(t,e,i,s){super(t,e,i,s),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.declutterImageWithText_=void 0}drawPoint(t,e){if(!this.image_)return;this.beginGeometry(t,e);const i=t.getFlatCoordinates(),s=t.getStride(),n=this.coordinates.length,o=this.appendFlatPointCoordinates(i,s);this.instructions.push([ti,n,o,this.image_,this.anchorX_*this.imagePixelRatio_,this.anchorY_*this.imagePixelRatio_,Math.ceil(this.height_*this.imagePixelRatio_),this.opacity_,this.originX_,this.originY_,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.declutterImageWithText_]),this.hitDetectionInstructions.push([ti,n,o,this.hitDetectionImage_,this.anchorX_,this.anchorY_,this.height_,this.opacity_,this.originX_,this.originY_,this.rotateWithView_,this.rotation_,this.scale_,this.width_,this.declutterImageWithText_]),this.endGeometry(e)}drawMultiPoint(t,e){if(!this.image_)return;this.beginGeometry(t,e);const i=t.getFlatCoordinates(),s=t.getStride(),n=this.coordinates.length,o=this.appendFlatPointCoordinates(i,s);this.instructions.push([ti,n,o,this.image_,this.anchorX_*this.imagePixelRatio_,this.anchorY_*this.imagePixelRatio_,Math.ceil(this.height_*this.imagePixelRatio_),this.opacity_,this.originX_,this.originY_,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.declutterImageWithText_]),this.hitDetectionInstructions.push([ti,n,o,this.hitDetectionImage_,this.anchorX_,this.anchorY_,this.height_,this.opacity_,this.originX_,this.originY_,this.rotateWithView_,this.rotation_,this.scale_,this.width_,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 i=t.getAnchor(),s=t.getSize(),n=t.getHitDetectionImage(),o=t.getImage(this.pixelRatio),r=t.getOrigin();this.imagePixelRatio_=t.getPixelRatio(this.pixelRatio),this.anchorX_=i[0],this.anchorY_=i[1],this.hitDetectionImage_=n,this.image_=o,this.height_=s[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_=s[0],this.declutterImageWithText_=e}},LineString:class extends ui{constructor(t,e,i,s){super(t,e,i,s)}drawFlatCoordinates_(t,e,i,s){const n=this.coordinates.length,o=this.appendFlatLineCoordinates(t,e,i,s,!1,!1),r=[si,n,o];return this.instructions.push(r),this.hitDetectionInstructions.push(r),i}drawLineString(t,e){const i=this.state,s=i.strokeStyle,n=i.lineWidth;if(void 0===s||void 0===n)return;this.updateStrokeStyle(i,this.applyStroke),this.beginGeometry(t,e),this.hitDetectionInstructions.push([oi,i.strokeStyle,i.lineWidth,i.lineCap,i.lineJoin,i.miterLimit,i.lineDash,i.lineDashOffset],hi);const o=t.getFlatCoordinates(),r=t.getStride();this.drawFlatCoordinates_(o,0,o.length,r),this.hitDetectionInstructions.push(li),this.endGeometry(e)}drawMultiLineString(t,e){const i=this.state,s=i.strokeStyle,n=i.lineWidth;if(void 0===s||void 0===n)return;this.updateStrokeStyle(i,this.applyStroke),this.beginGeometry(t,e),this.hitDetectionInstructions.push([oi,i.strokeStyle,i.lineWidth,i.lineCap,i.lineJoin,i.miterLimit,i.lineDash,i.lineDashOffset],hi);const o=t.getEnds(),r=t.getFlatCoordinates(),a=t.getStride();let l=0;for(let t=0,e=o.length;t<e;++t)l=this.drawFlatCoordinates_(r,l,o[t],a);this.hitDetectionInstructions.push(li),this.endGeometry(e)}finish(){const t=this.state;return null!=t.lastStroke&&t.lastStroke!=this.coordinates.length&&this.instructions.push(li),this.reverseHitDetectionInstructions(),this.state=null,super.finish()}applyStroke(t){null!=t.lastStroke&&t.lastStroke!=this.coordinates.length&&(this.instructions.push(li),t.lastStroke=this.coordinates.length),t.lastStroke=0,super.applyStroke(t),this.instructions.push(hi)}},Polygon:gi,Text:class extends ui{constructor(t,e,i,s){super(t,e,i,s),this.labels_=null,this.text_="",this.textOffsetX_=0,this.textOffsetY_=0,this.textRotateWithView_=void 0,this.textRotation_=0,this.textFillState_=null,this.fillStates={},this.textStrokeState_=null,this.strokeStates={},this.textState_={},this.textStates={},this.textKey_="",this.fillKey_="",this.strokeKey_="",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){const i=this.textFillState_,s=this.textStrokeState_,n=this.textState_;if(""===this.text_||!n||!i&&!s)return;const o=this.coordinates;let r=o.length;const a=t.getType();let l=null,h=t.getStride();if(n.placement!==_i||a!=Nt.LINE_STRING&&a!=Nt.MULTI_LINE_STRING&&a!=Nt.POLYGON&&a!=Nt.MULTI_POLYGON){const i=n.overflow?null:[];switch(a){case Nt.POINT:case Nt.MULTI_POINT:l=t.getFlatCoordinates();break;case Nt.LINE_STRING:l=t.getFlatMidpoint();break;case Nt.CIRCLE:l=t.getCenter();break;case Nt.MULTI_LINE_STRING:l=t.getFlatMidpoints(),h=2;break;case Nt.POLYGON:l=t.getFlatInteriorPoint(),n.overflow||i.push(l[2]/this.resolution),h=3;break;case Nt.MULTI_POLYGON:const e=t.getFlatInteriorPoints();l=[];for(let t=0,s=e.length;t<s;t+=3)n.overflow||i.push(e[t+2]/this.resolution),l.push(e[t],e[t+1]);if(0===l.length)return;h=2}const s=this.appendFlatPointCoordinates(l,h);if(s===r)return;this.saveTextStates_(),(n.backgroundFill||n.backgroundStroke)&&(this.setFillStrokeStyle(n.backgroundFill,n.backgroundStroke),n.backgroundFill&&(this.updateFillStyle(this.state,this.createFill),this.hitDetectionInstructions.push(this.createFill(this.state))),n.backgroundStroke&&(this.updateStrokeStyle(this.state,this.applyStroke),this.hitDetectionInstructions.push(this.createStroke(this.state)))),this.beginGeometry(t,e);let o=n.padding;if(o!=P&&(n.scale[0]<0||n.scale[1]<0)){let t=n.padding[0],e=n.padding[1],i=n.padding[2],s=n.padding[3];n.scale[0]<0&&(e=-e,s=-s),n.scale[1]<0&&(t=-t,i=-i),o=[t,e,i,s]}const c=this.pixelRatio;this.instructions.push([ti,r,s,null,NaN,NaN,NaN,1,0,0,this.textRotateWithView_,this.textRotation_,[1,1],NaN,this.declutterImageWithText_,o==P?P:o.map((function(t){return t*c})),!!n.backgroundFill,!!n.backgroundStroke,this.text_,this.textKey_,this.strokeKey_,this.fillKey_,this.textOffsetX_,this.textOffsetY_,i]);const d=1/c;this.hitDetectionInstructions.push([ti,r,s,null,NaN,NaN,NaN,1,0,0,this.textRotateWithView_,this.textRotation_,[d,d],NaN,this.declutterImageWithText_,o,!!n.backgroundFill,!!n.backgroundStroke,this.text_,this.textKey_,this.strokeKey_,this.fillKey_,this.textOffsetX_,this.textOffsetY_,i]),this.endGeometry(e)}else{if(!D(this.getBufferedMaxExtent(),t.getExtent()))return;let i;if(l=t.getFlatCoordinates(),a==Nt.LINE_STRING)i=[l.length];else if(a==Nt.MULTI_LINE_STRING)i=t.getEnds();else if(a==Nt.POLYGON)i=t.getEnds().slice(0,1);else if(a==Nt.MULTI_POLYGON){const e=t.getEndss();i=[];for(let t=0,s=e.length;t<s;++t)i.push(e[t][0])}this.beginGeometry(t,e);const s=n.textAlign;let c,d=0;for(let t=0,e=i.length;t<e;++t){if(null==s){const e=mi(n.maxAngle,l,d,i[t],h);d=e[0],c=e[1]}else c=i[t];for(let t=d;t<c;t+=h)o.push(l[t],l[t+1]);const e=o.length;d=i[t],this.drawChars_(r,e),r=e}this.endGeometry(e)}}saveTextStates_(){const t=this.textStrokeState_,e=this.textState_,i=this.textFillState_,s=this.strokeKey_;t&&(s in this.strokeStates||(this.strokeStates[s]={strokeStyle:t.strokeStyle,lineCap:t.lineCap,lineDashOffset:t.lineDashOffset,lineWidth:t.lineWidth,lineJoin:t.lineJoin,miterLimit:t.miterLimit,lineDash:t.lineDash}));const n=this.textKey_;n in this.textStates||(this.textStates[n]={font:e.font,textAlign:e.textAlign||G,textBaseline:e.textBaseline||A,scale:e.scale});const o=this.fillKey_;i&&(o in this.fillStates||(this.fillStates[o]={fillStyle:i.fillStyle}))}drawChars_(t,e){const i=this.textStrokeState_,s=this.textState_,n=this.strokeKey_,o=this.textKey_,r=this.fillKey_;this.saveTextStates_();const a=this.pixelRatio,l=pi[s.textBaseline],h=this.textOffsetY_*a,c=this.text_,d=i?i.lineWidth*Math.abs(s.scale[0])/2:0;this.instructions.push([Qe,t,e,l,s.overflow,r,s.maxAngle,a,h,n,d*a,c,o,1]),this.hitDetectionInstructions.push([Qe,t,e,l,s.overflow,r,s.maxAngle,1,h,n,d,c,o,1/a])}setTextStyle(t,e){let i,s,n;if(t){const e=t.getFill();e?(s=this.textFillState_,s||(s={},this.textFillState_=s),s.fillStyle=Ge(e.getColor()||p)):(s=null,this.textFillState_=s);const o=t.getStroke();if(o){n=this.textStrokeState_,n||(n={},this.textStrokeState_=n);const t=o.getLineDash(),e=o.getLineDashOffset(),i=o.getWidth(),s=o.getMiterLimit();n.lineCap=o.getLineCap()||y,n.lineDash=t?t.slice():k,n.lineDashOffset=void 0===e?R:e,n.lineJoin=o.getLineJoin()||x,n.lineWidth=void 0===i?I:i,n.miterLimit=void 0===s?v:s,n.strokeStyle=Ge(o.getColor()||S)}else n=null,this.textStrokeState_=n;i=this.textState_;const r=t.getFont()||M;Y(r);const a=t.getScaleArray();i.overflow=t.getOverflow(),i.font=r,i.maxAngle=t.getMaxAngle(),i.placement=t.getPlacement(),i.textAlign=t.getTextAlign(),i.textBaseline=t.getTextBaseline()||A,i.backgroundFill=t.getBackgroundFill(),i.backgroundStroke=t.getBackgroundStroke(),i.padding=t.getPadding()||P,i.scale=void 0===a?[1,1]:a;const l=t.getOffsetX(),h=t.getOffsetY(),c=t.getRotateWithView(),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.textRotation_=void 0===d?0:d,this.strokeKey_=n?("string"==typeof n.strokeStyle?n.strokeStyle:W(n.strokeStyle))+n.lineCap+n.lineDashOffset+"|"+n.lineWidth+n.lineJoin+n.miterLimit+"["+n.lineDash.join()+"]":"",this.textKey_=i.font+i.scale+(i.textAlign||"?")+(i.textBaseline||"?"),this.fillKey_=s?"string"==typeof s.fillStyle?s.fillStyle:"|"+W(s.fillStyle):""}else this.text_="";this.declutterImageWithText_=e}}};class xi{constructor(t,e,i,s){this.tolerance_=t,this.maxExtent_=e,this.pixelRatio_=s,this.resolution_=i,this.buildersByZIndex_={}}finish(){const t={};for(const e in this.buildersByZIndex_){t[e]=t[e]||{};const i=this.buildersByZIndex_[e];for(const s in i){const n=i[s].finish();t[e][s]=n}}return t}getBuilder(t,e){const i=void 0!==t?t.toString():"0";let s=this.buildersByZIndex_[i];void 0===s&&(s={},this.buildersByZIndex_[i]=s);let n=s[e];if(void 0===n){n=new(0,yi[e])(this.tolerance_,this.maxExtent_,this.resolution_,this.pixelRatio_),s[e]=n}return n}}var Si="Circle",Ii="Default",vi="Image",Ci="LineString",wi="Polygon",Fi="Text";function Oi(t,e,i,s,n,o,r,l,h,c,d,u){let g=t[e],f=t[e+1],_=0,m=0,p=0,y=0;function x(){_=g,m=f,g=t[e+=s],f=t[e+1],y+=p,p=Math.sqrt((g-_)*(g-_)+(f-m)*(f-m))}do{x()}while(e<i-s&&y+p<o);let S=(o-y)/p;const I=a(_,g,S),v=a(m,f,S),C=e-s,w=y,F=o+l*h(c,n,d);for(;e<i-s&&y+p<F;)x();S=(F-y)/p;const O=a(_,g,S),T=a(m,f,S);let L;if(u){const t=[I,v,O,T];ne(t,0,4,2,u,t,t),L=t[0]>t[2]}else L=I>O;const k=Math.PI,R=[],E=C+s===e;if(p=0,y=w,g=t[e=C],f=t[e+1],E){x();let t=Math.atan2(f-m,g-_);L&&(t+=t>0?-k:k);const e=(O+I)/2,i=(T+v)/2;return R[0]=[e,i,(F-o)/2,t,n],R}let N;for(let t=0,u=n.length;t<u;){x();let I=Math.atan2(f-m,g-_);if(L&&(I+=I>0?-k:k),void 0!==N){let t=I-N;if(t+=t>k?-2*k:t<-k?2*k:0,Math.abs(t)>r)return null}N=I;const v=t;let C=0;for(;t<u;++t){const r=l*h(c,n[L?u-t-1:t],d);if(e+s<i&&y+p<o+C+r/2)break;C+=r}if(t===v)continue;const w=L?n.substring(u-v,u-t):n.substring(v,t);S=(o+C/2-y)/p;const F=a(_,g,S),O=a(m,f,S);R.push([F,O,C/2,I,w]),o+=C}return R}const Ti=g(),Li=[],ki=[],Ri=[],Ei=[];function Ni(t){return t[3].declutterBox}const bi=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 Di(t,e){return"start"!==e&&"end"!==e||bi.test(t)||(e="start"===e?"left":"right"),pi[e]}class Pi{constructor(t,e,i,s,n){this.overlaps=i,this.pixelRatio=e,this.resolution=t,this.alignFill_,this.instructions=s.instructions,this.coordinates=s.coordinates,this.coordinateCache_={},this.renderBuffer_=n,this.renderedTransform_=U(),this.hitDetectionInstructions=s.hitDetectionInstructions,this.pixelCoordinates_=null,this.viewRotation_=0,this.fillStates=s.fillStates||{},this.strokeStates=s.strokeStates||{},this.textStates=s.textStates||{},this.widths_={},this.labels_={}}createLabel(t,e,i,s){const n=t+e+i+s;if(this.labels_[n])return this.labels_[n];const o=s?this.strokeStates[s]:null,r=i?this.fillStates[i]:null,a=this.textStates[e],l=this.pixelRatio,h=[a.scale[0]*l,a.scale[1]*l],c=Di(t,a.textAlign||G),d=s&&o.lineWidth?o.lineWidth:0,u=t.split("\n"),g=u.length,f=[],_=X(a.font,u,f),m=B(a.font),p=_+d,y=[],x=(p+2)*h[0],S=(m*g+d)*h[1],I={width:x<0?Math.floor(x):Math.ceil(x),height:S<0?Math.floor(S):Math.ceil(S),contextInstructions:y};if(1==h[0]&&1==h[1]||y.push("scale",h),y.push("font",a.font),s){y.push("strokeStyle",o.strokeStyle),y.push("lineWidth",d),y.push("lineCap",o.lineCap),y.push("lineJoin",o.lineJoin),y.push("miterLimit",o.miterLimit);(z?OffscreenCanvasRenderingContext2D:CanvasRenderingContext2D).prototype.setLineDash&&(y.push("setLineDash",[o.lineDash]),y.push("lineDashOffset",o.lineDashOffset))}i&&y.push("fillStyle",r.fillStyle),y.push("textBaseline","middle"),y.push("textAlign","center");const v=.5-c,C=c*p+v*d;let w;if(s)for(w=0;w<g;++w)y.push("strokeText",[u[w],C+v*f[w],.5*(d+m)+w*m]);if(i)for(w=0;w<g;++w)y.push("fillText",[u[w],C+v*f[w],.5*(d+m)+w*m]);return this.labels_[n]=I,I}replayTextBackground_(t,e,i,s,n,o,r){t.beginPath(),t.moveTo.apply(t,e),t.lineTo.apply(t,i),t.lineTo.apply(t,s),t.lineTo.apply(t,n),t.lineTo.apply(t,e),o&&(this.alignFill_=o[2],this.fill_(t)),r&&(this.setStrokeStyle_(t,r),t.stroke())}calculateImageOrLabelDimensions_(t,e,i,s,n,o,r,a,l,h,c,d,u,g,f,_){let m=i-(r*=d[0]),p=s-(a*=d[1]);const y=n+l>t?t-l:n,x=o+h>e?e-h:o,S=g[3]+y*d[0]+g[1],I=g[0]+x*d[1]+g[2],v=m-g[3],C=p-g[0];let w;return(f||0!==c)&&(Li[0]=v,Ei[0]=v,Li[1]=C,ki[1]=C,ki[0]=v+S,Ri[0]=ki[0],Ri[1]=C+I,Ei[1]=Ri[1]),0!==c?(w=j(U(),i,s,1,1,c,-i,-s),V(w,Li),V(w,ki),V(w,Ri),V(w,Ei),J(Math.min(Li[0],ki[0],Ri[0],Ei[0]),Math.min(Li[1],ki[1],Ri[1],Ei[1]),Math.max(Li[0],ki[0],Ri[0],Ei[0]),Math.max(Li[1],ki[1],Ri[1],Ei[1]),Ti)):J(Math.min(v,v+S),Math.min(C,C+I),Math.max(v,v+S),Math.max(C,C+I),Ti),u&&(m=Math.round(m),p=Math.round(p)),{drawImageX:m,drawImageY:p,drawImageW:y,drawImageH:x,originX:l,originY:h,declutterBox:{minX:Ti[0],minY:Ti[1],maxX:Ti[2],maxY:Ti[3],value:_},canvasTransform:w,scale:d}}replayImageOrLabel_(t,e,i,s,n,o,r){const a=!(!o&&!r),l=s.declutterBox,h=t.canvas,c=r?r[2]*s.scale[0]/2:0;return l.minX-c<=h.width/e&&l.maxX+c>=0&&l.minY-c<=h.height/e&&l.maxY+c>=0&&(a&&this.replayTextBackground_(t,Li,ki,Ri,Ei,o,r),Z(t,s.canvasTransform,n,i,s.originX,s.originY,s.drawImageW,s.drawImageH,s.drawImageX,s.drawImageY,s.scale)),!0}fill_(t){if(this.alignFill_){const e=V(this.renderedTransform_,[0,0]),i=512*this.pixelRatio;t.save(),t.translate(e[0]%i,e[1]%i),t.rotate(this.viewRotation_)}t.fill(),this.alignFill_&&t.restore()}setStrokeStyle_(t,e){t.strokeStyle=e[1],t.lineWidth=e[2],t.lineCap=e[3],t.lineJoin=e[4],t.miterLimit=e[5],t.setLineDash&&(t.lineDashOffset=e[7],t.setLineDash(e[6]))}drawLabelWithPointPlacement_(t,e,i,s){const n=this.textStates[e],o=this.createLabel(t,e,s,i),r=this.strokeStates[i],a=this.pixelRatio,l=Di(t,n.textAlign||G),h=pi[n.textBaseline||A],c=r&&r.lineWidth?r.lineWidth:0;return{label:o,anchorX:l*(o.width/a-2*n.scale[0])+2*(.5-l)*c,anchorY:h*o.height/a+2*(.5-h)*c}}execute_(t,e,i,s,n,o,r,a){let l;this.pixelCoordinates_&&E(i,this.renderedTransform_)?l=this.pixelCoordinates_:(this.pixelCoordinates_||(this.pixelCoordinates_=[]),l=oe(this.coordinates,0,this.coordinates.length,2,i,this.pixelCoordinates_),H(this.renderedTransform_,i));let h=0;const c=s.length;let d,u,g,f,_,m,p,y,x,S,I,v,C=0,w=0,F=0,O=null,T=null;const L=this.coordinateCache_,k=this.viewRotation_,R=Math.round(1e12*Math.atan2(-i[1],i[0]))/1e12,N={context:t,pixelRatio:this.pixelRatio,resolution:this.resolution,rotation:k},b=this.instructions!=s||this.overlaps?0:200;let G,A,M,Y;for(;h<c;){const i=s[h];switch(i[0]){case Ze:G=i[1],Y=i[3],G.getGeometry()?void 0===r||D(r,Y.getExtent())?++h:h=i[2]+1:h=i[2];break;case He:w>b&&(this.fill_(t),w=0),F>b&&(t.stroke(),F=0),w||F||(t.beginPath(),f=NaN,_=NaN),++h;break;case Ke:C=i[1];const s=l[C],c=l[C+1],E=l[C+2]-s,W=l[C+3]-c,U=Math.sqrt(E*E+W*W);t.moveTo(s+U,c),t.arc(s,c,U,0,2*Math.PI,!0),++h;break;case qe:t.closePath(),++h;break;case $e:C=i[1],d=i[2];const X=i[3],B=i[4],z=6==i.length?i[5]:void 0;N.geometry=X,N.feature=G,h in L||(L[h]=[]);const j=L[h];z?z(l,C,d,2,j):(j[0]=l[C],j[1]=l[C+1],j.length=2),B(j,N),++h;break;case ti:C=i[1],d=i[2],y=i[3],u=i[4],g=i[5];let V=i[6];const J=i[7],Z=i[8],H=i[9],q=i[10];let $=i[11];const Q=i[12];let tt=i[13];const et=i[14];if(!y&&i.length>=19){x=i[18],S=i[19],I=i[20],v=i[21];const t=this.drawLabelWithPointPlacement_(x,S,I,v);y=t.label,i[3]=y;const e=i[22];u=(t.anchorX-e)*this.pixelRatio,i[4]=u;const s=i[23];g=(t.anchorY-s)*this.pixelRatio,i[5]=g,V=y.height,i[6]=V,tt=y.width,i[13]=tt}let it,st,nt,ot;i.length>24&&(it=i[24]),i.length>16?(st=i[15],nt=i[16],ot=i[17]):(st=P,nt=!1,ot=!1),q&&R?$+=k:q||R||($-=k);let rt=0;for(;C<d;C+=2){if(it&&it[rt++]<tt/this.pixelRatio)continue;const i=this.calculateImageOrLabelDimensions_(y.width,y.height,l[C],l[C+1],tt,V,u,g,Z,H,$,Q,n,st,nt||ot,G),s=[t,e,y,i,J,nt?O:null,ot?T:null];let o,r;if(a&&et){if(!et[C]){et[C]=s;continue}if(o=et[C],delete et[C],r=Ni(o),a.collides(r))continue}a&&a.collides(i.declutterBox)||(o&&(a&&a.insert(r),this.replayImageOrLabel_.apply(this,o)),a&&a.insert(i.declutterBox),this.replayImageOrLabel_.apply(this,s))}++h;break;case Qe:const at=i[1],lt=i[2],ht=i[3],ct=i[4];v=i[5];const dt=i[6],ut=i[7],gt=i[8];I=i[9];const ft=i[10];x=i[11],S=i[12];const _t=[i[13],i[13]],mt=this.textStates[S],pt=mt.font,yt=[mt.scale[0]*ut,mt.scale[1]*ut];let xt;pt in this.widths_?xt=this.widths_[pt]:(xt={},this.widths_[pt]=xt);const St=Re(l,at,lt,2),It=Math.abs(yt[0])*K(pt,x,xt);if(ct||It<=St){const i=this.textStates[S].textAlign,s=Oi(l,at,lt,2,x,(St-It)*pi[i],dt,Math.abs(yt[0]),K,pt,xt,R?0:this.viewRotation_);t:if(s){const i=[];let n,o,r,l,h;if(I)for(n=0,o=s.length;n<o;++n){h=s[n],r=h[4],l=this.createLabel(r,S,"",I),u=h[2]+(yt[0]<0?-ft:ft),g=ht*l.height+2*(.5-ht)*ft*yt[1]/yt[0]-gt;const o=this.calculateImageOrLabelDimensions_(l.width,l.height,h[0],h[1],l.width,l.height,u,g,0,0,h[3],_t,!1,P,!1,G);if(a&&a.collides(o.declutterBox))break t;i.push([t,e,l,o,1,null,null])}if(v)for(n=0,o=s.length;n<o;++n){h=s[n],r=h[4],l=this.createLabel(r,S,v,""),u=h[2],g=ht*l.height-gt;const o=this.calculateImageOrLabelDimensions_(l.width,l.height,h[0],h[1],l.width,l.height,u,g,0,0,h[3],_t,!1,P,!1,G);if(a&&a.collides(o.declutterBox))break t;i.push([t,e,l,o,1,null,null])}a&&a.load(i.map(Ni));for(let t=0,e=i.length;t<e;++t)this.replayImageOrLabel_.apply(this,i[t])}}++h;break;case ei:if(void 0!==o){G=i[1];const t=o(G,Y);if(t)return t}++h;break;case ii:b?w++:this.fill_(t),++h;break;case si:for(C=i[1],d=i[2],A=l[C],M=l[C+1],m=A+.5|0,p=M+.5|0,m===f&&p===_||(t.moveTo(A,M),f=m,_=p),C+=2;C<d;C+=2)A=l[C],M=l[C+1],m=A+.5|0,p=M+.5|0,C!=d-2&&m===f&&p===_||(t.lineTo(A,M),f=m,_=p);++h;break;case ni:O=i,this.alignFill_=i[2],w&&(this.fill_(t),w=0,F&&(t.stroke(),F=0)),t.fillStyle=i[1],++h;break;case oi:T=i,F&&(t.stroke(),F=0),this.setStrokeStyle_(t,i),++h;break;case ri:b?F++:t.stroke(),++h;break;default:++h}}w&&this.fill_(t),F&&t.stroke()}execute(t,e,i,s,n,o){this.viewRotation_=s,this.execute_(t,e,i,this.instructions,n,void 0,void 0,o)}executeHitDetection(t,e,i,s,n){return this.viewRotation_=i,this.execute_(t,1,e,this.hitDetectionInstructions,!0,s,n)}}const Gi=[wi,Si,Ci,vi,Fi,Ii];class Ai{constructor(t,e,i,s,n,o){this.maxExtent_=t,this.overlaps_=s,this.pixelRatio_=i,this.resolution_=e,this.renderBuffer_=o,this.executorsByZIndex_={},this.hitDetectionContext_=null,this.hitDetectionTransform_=U(),this.createExecutors_(n)}clip(t,e){const i=this.getClipCoords(e);t.beginPath(),t.moveTo(i[0],i[1]),t.lineTo(i[2],i[3]),t.lineTo(i[4],i[5]),t.lineTo(i[6],i[7]),t.clip()}createExecutors_(t){for(const e in t){let i=this.executorsByZIndex_[e];void 0===i&&(i={},this.executorsByZIndex_[e]=i);const s=t[e],n=[this.renderBuffer_||0,this.renderBuffer_||0];for(const t in s){const e=s[t];i[t]=new Pi(this.resolution_,this.pixelRatio_,this.overlaps_,e,n)}}}hasExecutors(t){for(const e in this.executorsByZIndex_){const i=this.executorsByZIndex_[e];for(let e=0,s=t.length;e<s;++e)if(t[e]in i)return!0}return!1}forEachFeatureAtCoordinate(t,e,i,s,n,o){const r=2*(s=Math.round(s))+1,a=j(this.hitDetectionTransform_,s+.5,s+.5,1/e,-1/e,-i,-t[0],-t[1]),l=!this.hitDetectionContext_;l&&(this.hitDetectionContext_=m(r,r));const h=this.hitDetectionContext_;let c;h.canvas.width!==r||h.canvas.height!==r?(h.canvas.width=r,h.canvas.height=r):l||h.clearRect(0,0,r,r),void 0!==this.renderBuffer_&&(c=g(),q(c,t),b(c,e*(this.renderBuffer_+s),c));const d=function(t){if(void 0!==Mi[t])return Mi[t];const e=2*t+1,i=t*t,s=new Array(i+1);for(let n=0;n<=t;++n)for(let o=0;o<=t;++o){const r=n*n+o*o;if(r>i)break;let a=s[r];a||(a=[],s[r]=a),a.push(4*((t+n)*e+(t+o))+3),n>0&&a.push(4*((t-n)*e+(t+o))+3),o>0&&(a.push(4*((t+n)*e+(t-o))+3),n>0&&a.push(4*((t-n)*e+(t-o))+3))}const n=[];for(let t=0,e=s.length;t<e;++t)s[t]&&n.push(...s[t]);return Mi[t]=n,n}(s);let u;function f(t,e){const i=h.getImageData(0,0,r,r).data;for(let a=0,l=d.length;a<l;a++)if(i[d[a]]>0){if(!o||u!==vi&&u!==Fi||-1!==o.indexOf(t)){const i=(d[a]-3)/4,o=s-i%r,l=s-(i/r|0),h=n(t,e,o*o+l*l);if(h)return h}h.clearRect(0,0,r,r);break}}const _=Object.keys(this.executorsByZIndex_).map(Number);let p,y,x,S,I;for(_.sort($),p=_.length-1;p>=0;--p){const t=_[p].toString();for(x=this.executorsByZIndex_[t],y=Gi.length-1;y>=0;--y)if(u=Gi[y],S=x[u],void 0!==S&&(I=S.executeHitDetection(h,a,i,f,c),I))return I}}getClipCoords(t){const e=this.maxExtent_;if(!e)return null;const i=e[0],s=e[1],n=e[2],o=e[3],r=[i,s,i,o,n,o,n,s];return oe(r,0,8,2,t,r),r}isEmpty(){return Q(this.executorsByZIndex_)}execute(t,e,i,s,n,o,r){const a=Object.keys(this.executorsByZIndex_).map(Number);a.sort($),this.maxExtent_&&(t.save(),this.clip(t,i));const l=o||Gi;let h,c,d,u,g,f;for(r&&a.reverse(),h=0,c=a.length;h<c;++h){const o=a[h].toString();for(g=this.executorsByZIndex_[o],d=0,u=l.length;d<u;++d){f=g[l[d]],void 0!==f&&f.execute(t,e,i,s,n,r)}}this.maxExtent_&&t.restore()}}const Mi={};class Yi extends di{constructor(t,e,i,s,n,o,r){super(),this.context_=t,this.pixelRatio_=e,this.extent_=i,this.transform_=s,this.viewRotation_=n,this.squaredTolerance_=o,this.userTransform_=r,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_=U()}drawImages_(t,e,i,s){if(!this.image_)return;const n=oe(t,e,i,2,this.transform_,this.pixelCoordinates_),o=this.context_,r=this.tmpLocalTransform_,a=o.globalAlpha;1!=this.imageOpacity_&&(o.globalAlpha=a*this.imageOpacity_);let l=this.imageRotation_;this.imageRotateWithView_&&(l+=this.viewRotation_);for(let t=0,e=n.length;t<e;t+=2){const e=n[t]-this.imageAnchorX_,i=n[t+1]-this.imageAnchorY_;if(0!==l||1!=this.imageScale_[0]||1!=this.imageScale_[1]){const t=e+this.imageAnchorX_,s=i+this.imageAnchorY_;j(r,t,s,1,1,l,-t,-s),o.setTransform.apply(o,r),o.translate(t,s),o.scale(this.imageScale_[0],this.imageScale_[1]),o.drawImage(this.image_,this.imageOriginX_,this.imageOriginY_,this.imageWidth_,this.imageHeight_,-this.imageAnchorX_,-this.imageAnchorY_,this.imageWidth_,this.imageHeight_),o.setTransform(1,0,0,1,0,0)}else o.drawImage(this.image_,this.imageOriginX_,this.imageOriginY_,this.imageWidth_,this.imageHeight_,e,i,this.imageWidth_,this.imageHeight_)}1!=this.imageOpacity_&&(o.globalAlpha=a)}drawText_(t,e,i,s){if(!this.textState_||""===this.text_)return;this.textFillState_&&this.setContextFillState_(this.textFillState_),this.textStrokeState_&&this.setContextStrokeState_(this.textStrokeState_),this.setContextTextState_(this.textState_);const n=oe(t,e,i,s,this.transform_,this.pixelCoordinates_),o=this.context_;let r=this.textRotation_;for(this.textRotateWithView_&&(r+=this.viewRotation_);e<i;e+=s){const t=n[e]+this.textOffsetX_,i=n[e+1]+this.textOffsetY_;if(0!==r||1!=this.textScale_[0]||1!=this.textScale_[1]){const e=j(this.tmpLocalTransform_,t,i,1,1,r,-t,-i);o.setTransform.apply(o,e),o.translate(t,i),o.scale(this.textScale_[0],this.textScale_[1]),this.textStrokeState_&&o.strokeText(this.text_,0,0),this.textFillState_&&o.fillText(this.text_,0,0),o.setTransform(1,0,0,1,0,0)}else this.textStrokeState_&&o.strokeText(this.text_,t,i),this.textFillState_&&o.fillText(this.text_,t,i)}}moveToLineTo_(t,e,i,s,n){const o=this.context_,r=oe(t,e,i,s,this.transform_,this.pixelCoordinates_);o.moveTo(r[0],r[1]);let a=r.length;n&&(a-=2);for(let t=2;t<a;t+=2)o.lineTo(r[t],r[t+1]);return n&&o.closePath(),i}drawRings_(t,e,i,s){for(let n=0,o=i.length;n<o;++n)e=this.moveToLineTo_(t,e,i[n],s,!0);return e}drawCircle(t){if(D(this.extent_,t.getExtent())){if(this.fillState_||this.strokeState_){this.fillState_&&this.setContextFillState_(this.fillState_),this.strokeState_&&this.setContextStrokeState_(this.strokeState_);const e=re(t,this.transform_,this.pixelCoordinates_),i=e[2]-e[0],s=e[3]-e[1],n=Math.sqrt(i*i+s*s),o=this.context_;o.beginPath(),o.arc(e[0],e[1],n,0,2*Math.PI),this.fillState_&&o.fill(),this.strokeState_&&o.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 Nt.POINT:this.drawPoint(t);break;case Nt.LINE_STRING:this.drawLineString(t);break;case Nt.POLYGON:this.drawPolygon(t);break;case Nt.MULTI_POINT:this.drawMultiPoint(t);break;case Nt.MULTI_LINE_STRING:this.drawMultiLineString(t);break;case Nt.MULTI_POLYGON:this.drawMultiPolygon(t);break;case Nt.GEOMETRY_COLLECTION:this.drawGeometryCollection(t);break;case Nt.CIRCLE:this.drawCircle(t)}}drawFeature(t,e){const i=e.getGeometryFunction()(t);i&&D(this.extent_,i.getExtent())&&(this.setStyle(e),this.drawGeometry(i))}drawGeometryCollection(t){const e=t.getGeometriesArray();for(let t=0,i=e.length;t<i;++t)this.drawGeometry(e[t])}drawPoint(t){this.squaredTolerance_&&(t=t.simplifyTransformed(this.squaredTolerance_,this.userTransform_));const e=t.getFlatCoordinates(),i=t.getStride();this.image_&&this.drawImages_(e,0,e.length,i),""!==this.text_&&this.drawText_(e,0,e.length,i)}drawMultiPoint(t){this.squaredTolerance_&&(t=t.simplifyTransformed(this.squaredTolerance_,this.userTransform_));const e=t.getFlatCoordinates(),i=t.getStride();this.image_&&this.drawImages_(e,0,e.length,i),""!==this.text_&&this.drawText_(e,0,e.length,i)}drawLineString(t){if(this.squaredTolerance_&&(t=t.simplifyTransformed(this.squaredTolerance_,this.userTransform_)),D(this.extent_,t.getExtent())){if(this.strokeState_){this.setContextStrokeState_(this.strokeState_);const e=this.context_,i=t.getFlatCoordinates();e.beginPath(),this.moveToLineTo_(i,0,i.length,t.getStride(),!1),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(D(this.extent_,e)){if(this.strokeState_){this.setContextStrokeState_(this.strokeState_);const e=this.context_,i=t.getFlatCoordinates();let s=0;const n=t.getEnds(),o=t.getStride();e.beginPath();for(let t=0,e=n.length;t<e;++t)s=this.moveToLineTo_(i,s,n[t],o,!1);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_)),D(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.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_)),D(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_,i=t.getOrientedFlatCoordinates();let s=0;const n=t.getEndss(),o=t.getStride();e.beginPath();for(let t=0,e=n.length;t<e;++t){const e=n[t];s=this.drawRings_(i,s,e,o)}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_,i=this.contextFillState_;i?i.fillStyle!=t.fillStyle&&(i.fillStyle=t.fillStyle,e.fillStyle=t.fillStyle):(e.fillStyle=t.fillStyle,this.contextFillState_={fillStyle:t.fillStyle})}setContextStrokeState_(t){const e=this.context_,i=this.contextStrokeState_;i?(i.lineCap!=t.lineCap&&(i.lineCap=t.lineCap,e.lineCap=t.lineCap),e.setLineDash&&(E(i.lineDash,t.lineDash)||e.setLineDash(i.lineDash=t.lineDash),i.lineDashOffset!=t.lineDashOffset&&(i.lineDashOffset=t.lineDashOffset,e.lineDashOffset=t.lineDashOffset)),i.lineJoin!=t.lineJoin&&(i.lineJoin=t.lineJoin,e.lineJoin=t.lineJoin),i.lineWidth!=t.lineWidth&&(i.lineWidth=t.lineWidth,e.lineWidth=t.lineWidth),i.miterLimit!=t.miterLimit&&(i.miterLimit=t.miterLimit,e.miterLimit=t.miterLimit),i.strokeStyle!=t.strokeStyle&&(i.strokeStyle=t.strokeStyle,e.strokeStyle=t.strokeStyle)):(e.lineCap=t.lineCap,e.setLineDash&&(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_,i=this.contextTextState_,s=t.textAlign?t.textAlign:G;i?(i.font!=t.font&&(i.font=t.font,e.font=t.font),i.textAlign!=s&&(i.textAlign=s,e.textAlign=s),i.textBaseline!=t.textBaseline&&(i.textBaseline=t.textBaseline,e.textBaseline=t.textBaseline)):(e.font=t.font,e.textAlign=s,e.textBaseline=t.textBaseline,this.contextTextState_={font:t.font,textAlign:s,textBaseline:t.textBaseline})}setFillStrokeStyle(t,e){if(t){const e=t.getColor();this.fillState_={fillStyle:Ge(e||p)}}else this.fillState_=null;if(e){const t=e.getColor(),i=e.getLineCap(),s=e.getLineDash(),n=e.getLineDashOffset(),o=e.getLineJoin(),r=e.getWidth(),a=e.getMiterLimit();this.strokeState_={lineCap:void 0!==i?i:y,lineDash:s||k,lineDashOffset:n||R,lineJoin:void 0!==o?o:x,lineWidth:this.pixelRatio_*(void 0!==r?r:I),miterLimit:void 0!==a?a:v,strokeStyle:Ge(t||S)}}else this.strokeState_=null}setImageStyle(t){if(t){const e=t.getSize();if(e){const i=t.getAnchor(),s=t.getImage(1),n=t.getOrigin(),o=t.getScaleArray();this.imageAnchorX_=i[0],this.imageAnchorY_=i[1],this.imageHeight_=e[1],this.image_=s,this.imageOpacity_=t.getOpacity(),this.imageOriginX_=n[0],this.imageOriginY_=n[1],this.imageRotateWithView_=t.getRotateWithView(),this.imageRotation_=t.getRotation(),this.imageScale_=[this.pixelRatio_*o[0],this.pixelRatio_*o[1]],this.imageWidth_=e[0]}else this.image_=null}else this.image_=null}setTextStyle(t){if(t){const e=t.getFill();if(e){const t=e.getColor();this.textFillState_={fillStyle:Ge(t||p)}}else this.textFillState_=null;const i=t.getStroke();if(i){const t=i.getColor(),e=i.getLineCap(),s=i.getLineDash(),n=i.getLineDashOffset(),o=i.getLineJoin(),r=i.getWidth(),a=i.getMiterLimit();this.textStrokeState_={lineCap:void 0!==e?e:y,lineDash:s||k,lineDashOffset:n||R,lineJoin:void 0!==o?o:x,lineWidth:void 0!==r?r:I,miterLimit:void 0!==a?a:v,strokeStyle:Ge(t||S)}}else this.textStrokeState_=null;const s=t.getFont(),n=t.getOffsetX(),o=t.getOffsetY(),r=t.getRotateWithView(),a=t.getRotation(),l=t.getScaleArray(),h=t.getText(),c=t.getTextAlign(),d=t.getTextBaseline();this.textState_={font:void 0!==s?s:M,textAlign:void 0!==c?c:G,textBaseline:void 0!==d?d:A},this.text_=void 0!==h?h:"",this.textOffsetX_=void 0!==n?this.pixelRatio_*n:0,this.textOffsetY_=void 0!==o?this.pixelRatio_*o:0,this.textRotateWithView_=void 0!==r&&r,this.textRotation_=void 0!==a?a:0,this.textScale_=[this.pixelRatio_*l[0],this.pixelRatio_*l[1]]}else this.text_=""}}var Wi="fraction",Ui="pixels",Xi="bottom-left",Bi="bottom-right",zi="top-left",ji="top-right";let Vi=null;class Ji extends tt{constructor(t,e,i,s,n,o){super(),this.hitDetectionImage_=null,this.image_=t||new Image,null!==s&&(this.image_.crossOrigin=s),this.canvas_={},this.color_=o,this.unlisten_=null,this.imageState_=n,this.size_=i,this.src_=e,this.tainted_}isTainted_(){if(void 0===this.tainted_&&this.imageState_===_e.LOADED){Vi||(Vi=m(1,1)),Vi.drawImage(this.image_,0,0);try{Vi.getImageData(0,0,1,1),this.tainted_=!1}catch(t){Vi=null,this.tainted_=!0}}return!0===this.tainted_}dispatchChangeEvent_(){this.dispatchEvent(n.CHANGE)}handleImageError_(){this.imageState_=_e.ERROR,this.unlistenImage_(),this.dispatchChangeEvent_()}handleImageLoad_(){this.imageState_=_e.LOADED,this.size_?(this.image_.width=this.size_[0],this.image_.height=this.size_[1]):this.size_=[this.image_.width,this.image_.height],this.unlistenImage_(),this.dispatchChangeEvent_()}getImage(t){return this.replaceColor_(t),this.canvas_[t]?this.canvas_[t]:this.image_}getPixelRatio(t){return this.replaceColor_(t),this.canvas_[t]?t:1}getImageState(){return this.imageState_}getHitDetectionImage(){if(!this.hitDetectionImage_)if(this.isTainted_()){const t=this.size_[0],e=this.size_[1],i=m(t,e);i.fillRect(0,0,t,e),this.hitDetectionImage_=i.canvas}else this.hitDetectionImage_=this.image_;return this.hitDetectionImage_}getSize(){return this.size_}getSrc(){return this.src_}load(){if(this.imageState_==_e.IDLE){this.imageState_=_e.LOADING;try{this.image_.src=this.src_}catch(t){this.handleImageError_()}this.unlisten_=me(this.image_,this.handleImageLoad_.bind(this),this.handleImageError_.bind(this))}}replaceColor_(t){if(!this.color_||this.canvas_[t])return;const e=document.createElement("canvas");this.canvas_[t]=e,e.width=Math.ceil(this.image_.width*t),e.height=Math.ceil(this.image_.height*t);const i=e.getContext("2d");if(i.scale(t,t),i.drawImage(this.image_,0,0),i.globalCompositeOperation="multiply","multiply"===i.globalCompositeOperation||this.isTainted_())i.fillStyle=le(this.color_),i.fillRect(0,0,e.width,e.height),i.globalCompositeOperation="destination-in",i.drawImage(this.image_,0,0);else{const t=i.getImageData(0,0,e.width,e.height),s=t.data,n=this.color_[0]/255,o=this.color_[1]/255,r=this.color_[2]/255,a=this.color_[3];for(let t=0,e=s.length;t<e;t+=4)s[t]*=n,s[t+1]*=o,s[t+2]*=r,s[t+3]*=a;i.putImageData(t,0,0)}}unlistenImage_(){this.unlisten_&&(this.unlisten_(),this.unlisten_=null)}}class Zi extends Pe{constructor(t){const e=t||{},i=void 0!==e.opacity?e.opacity:1,s=void 0!==e.rotation?e.rotation:0,n=void 0!==e.scale?e.scale:1,r=void 0!==e.rotateWithView&&e.rotateWithView;super({opacity:i,rotation:s,scale:n,displacement:void 0!==e.displacement?e.displacement:[0,0],rotateWithView:r}),this.anchor_=void 0!==e.anchor?e.anchor:[.5,.5],this.normalizedAnchor_=null,this.anchorOrigin_=void 0!==e.anchorOrigin?e.anchorOrigin:zi,this.anchorXUnits_=void 0!==e.anchorXUnits?e.anchorXUnits:Wi,this.anchorYUnits_=void 0!==e.anchorYUnits?e.anchorYUnits:Wi,this.crossOrigin_=void 0!==e.crossOrigin?e.crossOrigin:null;const a=void 0!==e.img?e.img:null,l=void 0!==e.imgSize?e.imgSize:null;let h=e.src;o(!(void 0!==h&&a),4),o(!a||a&&l,5),void 0!==h&&0!==h.length||!a||(h=a.src||W(a)),o(void 0!==h&&h.length>0,6);const c=void 0!==e.src?_e.IDLE:_e.LOADED;this.color_=void 0!==e.color?ee(e.color):null,this.iconImage_=function(t,e,i,s,n,o){let r=ae.get(e,s,o);return r||(r=new Ji(t,e,i,s,n,o),ae.set(e,s,o,r)),r}(a,h,l,this.crossOrigin_,c,this.color_),this.offset_=void 0!==e.offset?e.offset:[0,0],this.offsetOrigin_=void 0!==e.offsetOrigin?e.offsetOrigin:zi,this.origin_=null,this.size_=void 0!==e.size?e.size:null}clone(){const t=this.getScale();return new Zi({anchor:this.anchor_.slice(),anchorOrigin:this.anchorOrigin_,anchorXUnits:this.anchorXUnits_,anchorYUnits:this.anchorYUnits_,crossOrigin:this.crossOrigin_,color:this.color_&&this.color_.slice?this.color_.slice():this.color_||void 0,src:this.getSrc(),offset:this.offset_.slice(),offsetOrigin:this.offsetOrigin_,size:null!==this.size_?this.size_.slice():void 0,opacity:this.getOpacity(),scale:Array.isArray(t)?t.slice():t,rotation:this.getRotation(),rotateWithView:this.getRotateWithView()})}getAnchor(){if(this.normalizedAnchor_)return this.normalizedAnchor_;let t=this.anchor_;const e=this.getSize();if(this.anchorXUnits_==Wi||this.anchorYUnits_==Wi){if(!e)return null;t=this.anchor_.slice(),this.anchorXUnits_==Wi&&(t[0]*=e[0]),this.anchorYUnits_==Wi&&(t[1]*=e[1])}if(this.anchorOrigin_!=zi){if(!e)return null;t===this.anchor_&&(t=this.anchor_.slice()),this.anchorOrigin_!=ji&&this.anchorOrigin_!=Bi||(t[0]=-t[0]+e[0]),this.anchorOrigin_!=Xi&&this.anchorOrigin_!=Bi||(t[1]=-t[1]+e[1])}return this.normalizedAnchor_=t,this.normalizedAnchor_}setAnchor(t){this.anchor_=t,this.normalizedAnchor_=null}getColor(){return this.color_}getImage(t){return this.iconImage_.getImage(t)}getPixelRatio(t){return this.iconImage_.getPixelRatio(t)}getImageSize(){return this.iconImage_.getSize()}getHitDetectionImageSize(){return this.getImageSize()}getImageState(){return this.iconImage_.getImageState()}getHitDetectionImage(){return this.iconImage_.getHitDetectionImage()}getOrigin(){if(this.origin_)return this.origin_;let t=this.offset_;const e=this.getDisplacement();if(this.offsetOrigin_!=zi){const e=this.getSize(),i=this.iconImage_.getSize();if(!e||!i)return null;t=t.slice(),this.offsetOrigin_!=ji&&this.offsetOrigin_!=Bi||(t[0]=i[0]-e[0]-t[0]),this.offsetOrigin_!=Xi&&this.offsetOrigin_!=Bi||(t[1]=i[1]-e[1]-t[1])}return t[0]+=e[0],t[1]+=e[1],this.origin_=t,this.origin_}getSrc(){return this.iconImage_.getSrc()}getSize(){return this.size_?this.size_:this.iconImage_.getSize()}listenImageChange(t){this.iconImage_.addEventListener(n.CHANGE,t)}load(){this.iconImage_.load()}unlistenImageChange(t){this.iconImage_.removeEventListener(n.CHANGE,t)}}class Hi{constructor(t){const e=t||{};this.font_=e.font,this.rotation_=e.rotation,this.rotateWithView_=e.rotateWithView,this.scale_=e.scale,this.scaleArray_=f(void 0!==e.scale?e.scale:1),this.text_=e.text,this.textAlign_=e.textAlign,this.textBaseline_=e.textBaseline,this.fill_=void 0!==e.fill?e.fill:new Ye({color:"#333"}),this.maxAngle_=void 0!==e.maxAngle?e.maxAngle:Math.PI/4,this.placement_=void 0!==e.placement?e.placement:fi,this.overflow_=!!e.overflow,this.stroke_=void 0!==e.stroke?e.stroke:null,this.offsetX_=void 0!==e.offsetX?e.offsetX:0,this.offsetY_=void 0!==e.offsetY?e.offsetY:0,this.backgroundFill_=e.backgroundFill?e.backgroundFill:null,this.backgroundStroke_=e.backgroundStroke?e.backgroundStroke:null,this.padding_=void 0===e.padding?null:e.padding}clone(){const t=this.getScale();return new Hi({font:this.getFont(),placement:this.getPlacement(),maxAngle:this.getMaxAngle(),overflow:this.getOverflow(),rotation:this.getRotation(),rotateWithView:this.getRotateWithView(),scale:Array.isArray(t)?t.slice():t,text:this.getText(),textAlign:this.getTextAlign(),textBaseline:this.getTextBaseline(),fill:this.getFill()?this.getFill().clone():void 0,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()})}getOverflow(){return this.overflow_}getFont(){return this.font_}getMaxAngle(){return this.maxAngle_}getPlacement(){return this.placement_}getOffsetX(){return this.offsetX_}getOffsetY(){return this.offsetY_}getFill(){return this.fill_}getRotateWithView(){return this.rotateWithView_}getRotation(){return this.rotation_}getScale(){return this.scale_}getScaleArray(){return this.scaleArray_}getStroke(){return this.stroke_}getText(){return this.text_}getTextAlign(){return this.textAlign_}getTextBaseline(){return this.textBaseline_}getBackgroundFill(){return this.backgroundFill_}getBackgroundStroke(){return this.backgroundStroke_}getPadding(){return this.padding_}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}setRotateWithView(t){this.rotateWithView_=t}setFill(t){this.fill_=t}setRotation(t){this.rotation_=t}setScale(t){this.scale_=t,this.scaleArray_=f(void 0!==t?t:1)}setStroke(t){this.stroke_=t}setText(t){this.text_=t}setTextAlign(t){this.textAlign_=t}setTextBaseline(t){this.textBaseline_=t}setBackgroundFill(t){this.backgroundFill_=t}setBackgroundStroke(t){this.backgroundStroke_=t}setPadding(t){this.padding_=t}}const Ki={Point:function(t,e,i,s,n){const o=i.getImage(),r=i.getText();let a;n&&(t=n,a=o&&r&&r.getText()?{}:void 0);if(o){if(o.getImageState()!=_e.LOADED)return;const n=t.getBuilder(i.getZIndex(),vi);n.setImageStyle(o,a),n.drawPoint(e,s)}if(r&&r.getText()){const n=t.getBuilder(i.getZIndex(),Fi);n.setTextStyle(r,a),n.drawText(e,s)}},LineString:function(t,e,i,s,n){const o=i.getStroke();if(o){const n=t.getBuilder(i.getZIndex(),Ci);n.setFillStrokeStyle(null,o),n.drawLineString(e,s)}const r=i.getText();if(r&&r.getText()){const o=(n||t).getBuilder(i.getZIndex(),Fi);o.setTextStyle(r),o.drawText(e,s)}},Polygon:function(t,e,i,s,n){const o=i.getFill(),r=i.getStroke();if(o||r){const n=t.getBuilder(i.getZIndex(),wi);n.setFillStrokeStyle(o,r),n.drawPolygon(e,s)}const a=i.getText();if(a&&a.getText()){const o=(n||t).getBuilder(i.getZIndex(),Fi);o.setTextStyle(a),o.drawText(e,s)}},MultiPoint:function(t,e,i,s,n){const o=i.getImage(),r=i.getText();let a;n&&(t=n,a=o&&r&&r.getText()?{}:void 0);if(o){if(o.getImageState()!=_e.LOADED)return;const n=t.getBuilder(i.getZIndex(),vi);n.setImageStyle(o,a),n.drawMultiPoint(e,s)}if(r&&r.getText()){const o=(n||t).getBuilder(i.getZIndex(),Fi);o.setTextStyle(r,a),o.drawText(e,s)}},MultiLineString:function(t,e,i,s,n){const o=i.getStroke();if(o){const n=t.getBuilder(i.getZIndex(),Ci);n.setFillStrokeStyle(null,o),n.drawMultiLineString(e,s)}const r=i.getText();if(r&&r.getText()){const o=(n||t).getBuilder(i.getZIndex(),Fi);o.setTextStyle(r),o.drawText(e,s)}},MultiPolygon:function(t,e,i,s,n){const o=i.getFill(),r=i.getStroke();if(r||o){const n=t.getBuilder(i.getZIndex(),wi);n.setFillStrokeStyle(o,r),n.drawMultiPolygon(e,s)}const a=i.getText();if(a&&a.getText()){const o=(n||t).getBuilder(i.getZIndex(),Fi);o.setTextStyle(a),o.drawText(e,s)}},GeometryCollection:function(t,e,i,s,n){const o=e.getGeometriesArray();let r,a;for(r=0,a=o.length;r<a;++r){(0,Ki[o[r].getType()])(t,o[r],i,s,n)}},Circle:function(t,e,i,s,n){const o=i.getFill(),r=i.getStroke();if(o||r){const n=t.getBuilder(i.getZIndex(),Si);n.setFillStrokeStyle(o,r),n.drawCircle(e,s)}const a=i.getText();if(a&&a.getText()){const o=(n||t).getBuilder(i.getZIndex(),Fi);o.setTextStyle(a),o.drawText(e,s)}}};function qi(t,e){return parseInt(W(t),10)-parseInt(W(e),10)}function $i(t,e){return.5*t/e}function Qi(t,e,i,s,n,o,r){let a=!1;const l=i.getImage();if(l){let t=l.getImageState();t==_e.LOADED||t==_e.ERROR?l.unlistenImageChange(n):(t==_e.IDLE&&l.load(),t=l.getImageState(),l.listenImageChange(n),a=!0)}return function(t,e,i,s,n,o){const r=i.getGeometryFunction()(e);if(!r)return;const a=r.simplifyTransformed(s,n);if(i.getRenderer())!function t(e,i,s,n){if(i.getType()==Nt.GEOMETRY_COLLECTION){const o=i.getGeometries();for(let i=0,r=o.length;i<r;++i)t(e,o[i],s,n);return}e.getBuilder(s.getZIndex(),Ii).drawCustom(i,n,s.getRenderer())}(t,a,i,e);else{(0,Ki[a.getType()])(t,a,i,e,o)}}(t,e,i,s,o,r),a}class ts extends pe{constructor(t){super(t),this.boundHandleStyleImageChange_=this.handleStyleImageChange_.bind(this),this.animatingOrInteracting_,this.dirty_=!1,this.hitDetectionImageData_=null,this.renderedFeatures_=null,this.renderedRevision_=-1,this.renderedResolution_=NaN,this.renderedExtent_=g(),this.renderedRotation_,this.renderedCenter_=null,this.renderedProjection_=null,this.renderedRenderOrder_=null,this.replayGroup_=null,this.replayGroupChanged=!0,this.declutterExecutorGroup=null,this.clipping=!0}useContainer(t,e,i){i<1&&(t=null),super.useContainer(t,e,i)}renderWorlds(t,e,i){const s=e.extent,n=e.viewState,o=n.center,r=n.resolution,a=n.projection,l=n.rotation,h=a.getExtent(),c=this.getLayer().getSource(),d=e.pixelRatio,u=e.viewHints,g=!(u[he.ANIMATING]||u[he.INTERACTING]),f=this.context,_=Math.round(e.size[0]*d),m=Math.round(e.size[1]*d),p=c.getWrapX()&&a.canWrapX(),y=p?et(h):null,x=p?Math.ceil((s[2]-h[2])/y)+1:1;let S=p?Math.floor((s[0]-h[0])/y):0;do{const e=this.getRenderTransform(o,r,l,d,_,m,S*y);t.execute(f,1,e,l,g,void 0,i)}while(++S<x)}renderDeclutter(t){this.declutterExecutorGroup&&this.renderWorlds(this.declutterExecutorGroup,t,t.declutterTree)}renderFrame(t,e){const i=t.pixelRatio,s=t.layerStatesArray[t.layerIndex];it(this.pixelTransform,1/i,1/i),st(this.inversePixelTransform,this.pixelTransform);const n=nt(this.pixelTransform);this.useContainer(e,n,s.opacity);const o=this.context,r=o.canvas,a=this.replayGroup_,l=this.declutterExecutorGroup;if((!a||a.isEmpty())&&(!l||l.isEmpty()))return!this.containerReused&&r.width>0&&(r.width=0),this.container;const h=Math.round(t.size[0]*i),c=Math.round(t.size[1]*i);r.width!=h||r.height!=c?(r.width=h,r.height=c,r.style.transform!==n&&(r.style.transform=n)):this.containerReused||o.clearRect(0,0,h,c),this.preRender(o,t);const d=t.viewState;d.projection;let u=!1;if(s.extent&&this.clipping){const e=ot(s.extent);u=!rt(e,t.extent)&&D(e,t.extent),u&&this.clipUnrotated(o,t,e)}this.renderWorlds(a,t),u&&o.restore(),this.postRender(o,t);const g=s.opacity,f=this.container;return g!==parseFloat(f.style.opacity)&&(f.style.opacity=1===g?"":String(g)),this.renderedRotation_!==d.rotation&&(this.renderedRotation_=d.rotation,this.hitDetectionImageData_=null),this.container}getFeatures(t){return new Promise(function(e){if(!this.hitDetectionImageData_&&!this.animatingOrInteracting_){const t=[this.context.canvas.width,this.context.canvas.height];V(this.pixelTransform,t);const e=this.renderedCenter_,i=this.renderedResolution_,s=this.renderedRotation_,n=this.renderedProjection_,o=this.renderedExtent_,r=this.getLayer(),a=[],l=t[0]/2,h=t[1]/2;a.push(this.getRenderTransform(e,i,s,.5,l,h,0).slice());const c=r.getSource(),d=n.getExtent();if(c.getWrapX()&&n.canWrapX()&&!rt(d,o)){let t=o[0];const n=et(d);let r,c=0;for(;t<d[0];)--c,r=n*c,a.push(this.getRenderTransform(e,i,s,.5,l,h,r).slice()),t+=n;for(c=0,t=o[2];t>d[2];)++c,r=n*c,a.push(this.getRenderTransform(e,i,s,.5,l,h,r).slice()),t-=n}this.hitDetectionImageData_=function(t,e,i,s,n,o,r){const a=t[0]/2,l=t[1]/2,h=m(a,l);h.imageSmoothingEnabled=!1;const c=h.canvas,d=new Yi(h,.5,n,null,r),u=i.length,g=Math.floor(16777215/u),f={};for(let t=1;t<=u;++t){const e=i[t-1],r=e.getStyleFunction()||s;if(!s)continue;let a=r(e,o);if(!a)continue;Array.isArray(a)||(a=[a]);const l="#"+("000000"+(t*g).toString(16)).slice(-6);for(let t=0,i=a.length;t<i;++t){const i=a[t],s=i.clone(),o=s.getFill();o&&o.setColor(l);const r=s.getStroke();r&&r.setColor(l),s.setText(void 0);const h=i.getImage();if(h){const t=h.getImageSize();if(!t)continue;const e=document.createElement("canvas");e.width=t[0],e.height=t[1];const i=e.getContext("2d",{alpha:!1});i.fillStyle=l;const n=i.canvas;i.fillRect(0,0,n.width,n.height);const o=t?t[0]:n.width,r=t?t[1]:n.height;m(o,r).drawImage(n,0,0),s.setImage(new Zi({img:n,imgSize:t,anchor:h.getAnchor(),anchorXUnits:Ui,anchorYUnits:Ui,offset:h.getOrigin(),size:h.getSize(),opacity:h.getOpacity(),scale:h.getScale(),rotation:h.getRotation(),rotateWithView:h.getRotateWithView()}))}const c=Number(s.getZIndex());let d=f[c];d||(d={},f[c]=d,d[Nt.POLYGON]=[],d[Nt.CIRCLE]=[],d[Nt.LINE_STRING]=[],d[Nt.POINT]=[]);const u=s.getGeometryFunction()(e);u&&D(n,u.getExtent())&&d[u.getType().replace("Multi","")].push(u,s)}}const _=Object.keys(f).map(Number).sort($);for(let t=0,i=_.length;t<i;++t){const i=f[_[t]];for(const t in i){const s=i[t];for(let t=0,i=s.length;t<i;t+=2){d.setStyle(s[t+1]);for(let i=0,n=e.length;i<n;++i)d.setTransform(e[i]),d.drawGeometry(s[t])}}}return h.getImageData(0,0,c.width,c.height)}(t,a,this.renderedFeatures_,r.getStyleFunction(),o,i,s)}e(function(t,e,i){const s=[];if(i){const n=4*(Math.round(t[0]/2)+Math.round(t[1]/2)*i.width),o=i.data[n],r=i.data[n+1],a=i.data[n+2]+256*(r+256*o),l=Math.floor(16777215/e.length);a&&a%l==0&&s.push(e[a/l-1])}return s}(t,this.renderedFeatures_,this.hitDetectionImageData_))}.bind(this))}forEachFeatureAtCoordinate(t,e,i,s,n){if(!this.replayGroup_)return;const o=e.viewState.resolution,r=e.viewState.rotation,a=this.getLayer(),l={},h=function(t,e,i){const o=W(t),r=l[o];if(r){if(!0!==r&&i<r.distanceSq){if(0===i)return l[o]=!0,n.splice(n.lastIndexOf(r),1),s(t,a,e);r.geometry=e,r.distanceSq=i}}else{if(0===i)return l[o]=!0,s(t,a,e);n.push(l[o]={feature:t,layer:a,geometry:e,distanceSq:i,callback:s})}};let c;const d=[this.replayGroup_];return this.declutterExecutorGroup&&d.push(this.declutterExecutorGroup),d.some(s=>c=s.forEachFeatureAtCoordinate(t,o,r,i,h,s===this.declutterExecutorGroup?e.declutterTree.all().map(t=>t.value):null)),c}handleFontsChanged(){const t=this.getLayer();t.getVisible()&&this.replayGroup_&&t.changed()}handleStyleImageChange_(t){this.renderIfReadyAndVisible()}prepareFrame(t){const e=this.getLayer(),i=e.getSource();if(!i)return!1;const s=t.viewHints[he.ANIMATING],n=t.viewHints[he.INTERACTING],o=e.getUpdateWhileAnimating(),r=e.getUpdateWhileInteracting();if(!this.dirty_&&!o&&s||!r&&n)return this.animatingOrInteracting_=!0,!0;this.animatingOrInteracting_=!1;const a=t.extent,l=t.viewState,h=l.projection,c=l.resolution,d=t.pixelRatio,u=e.getRevision(),g=e.getRenderBuffer();let f=e.getRenderOrder();void 0===f&&(f=qi);const _=l.center.slice(),m=b(a,g*c),p=[m.slice()],y=h.getExtent();if(i.getWrapX()&&h.canWrapX()&&!rt(y,t.extent)){const t=et(y),e=Math.max(et(m)/2,t);m[0]=y[0]-e,m[2]=y[2]+e,ce(_,h);const i=at(p[0],h);i[0]<y[0]&&i[2]<y[2]?p.push([i[0]+t,i[1],i[2]+t,i[3]]):i[0]>y[0]&&i[2]>y[2]&&p.push([i[0]-t,i[1],i[2]-t,i[3]])}if(!this.dirty_&&this.renderedResolution_==c&&this.renderedRevision_==u&&this.renderedRenderOrder_==f&&rt(this.renderedExtent_,m))return this.replayGroupChanged=!1,!0;this.replayGroup_=null,this.dirty_=!1;const x=new xi($i(c,d),m,c,d);let S;this.getLayer().getDeclutter()&&(S=new xi($i(c,d),m,c,d));for(let t=0,e=p.length;t<e;++t)i.loadFeatures(p[t],c,h);const I=function(t,e){const i=$i(t,e);return i*i}(c,d),v=function(t){let i;const s=t.getStyleFunction()||e.getStyleFunction();if(s&&(i=s(t,c)),i){const e=this.renderFeature(t,I,i,x,undefined,S);this.dirty_=this.dirty_||e}}.bind(this),C=lt(m),w=i.getFeaturesInExtent(C);f&&w.sort(f);for(let t=0,e=w.length;t<e;++t)v(w[t]);this.renderedFeatures_=w;const F=x.finish(),O=new Ai(m,c,d,i.getOverlaps(),F,e.getRenderBuffer());return S&&(this.declutterExecutorGroup=new Ai(m,c,d,i.getOverlaps(),S.finish(),e.getRenderBuffer())),this.renderedResolution_=c,this.renderedRevision_=u,this.renderedRenderOrder_=f,this.renderedExtent_=m,this.renderedCenter_=_,this.renderedProjection_=h,this.replayGroup_=O,this.hitDetectionImageData_=null,this.replayGroupChanged=!0,!0}renderFeature(t,e,i,s,n,o){if(!i)return!1;let r=!1;if(Array.isArray(i))for(let a=0,l=i.length;a<l;++a)r=Qi(s,t,i[a],e,this.boundHandleStyleImageChange_,n,o)||r;else r=Qi(s,t,i,e,this.boundHandleStyleImageChange_,n,o);return r}}class es extends Je{constructor(t){super(t)}createRenderer(){return new ts(this)}}class is{constructor(t){this.rbush_=new ie(t),this.items_={}}insert(t,e){const i={minX:t[0],minY:t[1],maxX:t[2],maxY:t[3],value:e};this.rbush_.insert(i),this.items_[W(e)]=i}load(t,e){const i=new Array(e.length);for(let s=0,n=e.length;s<n;s++){const n=t[s],o=e[s],r={minX:n[0],minY:n[1],maxX:n[2],maxY:n[3],value:o};i[s]=r,this.items_[W(o)]=r}this.rbush_.load(i)}remove(t){const e=W(t),i=this.items_[e];return delete this.items_[e],null!==this.rbush_.remove(i)}update(t,e){const i=this.items_[W(e)],s=[i.minX,i.minY,i.maxX,i.maxY];ht(s,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 i;for(let s=0,n=t.length;s<n;s++)if(i=e(t[s]),i)return i;return i}isEmpty(){return Q(this.items_)}clear(){this.rbush_.clear(),this.items_={}}getExtent(t){const e=this.rbush_.toJSON();return J(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 ss={ADDFEATURE:"addfeature",CHANGEFEATURE:"changefeature",CLEAR:"clear",REMOVEFEATURE:"removefeature",FEATURESLOADSTART:"featuresloadstart",FEATURESLOADEND:"featuresloadend",FEATURESLOADERROR:"featuresloaderror"};function ns(t,e){return[[-1/0,-1/0,1/0,1/0]]}function os(t,e){return function(i,s,n,o,r){const a=this;!function(t,e,i,s,n,o,r){const a=new XMLHttpRequest;a.open("GET","function"==typeof t?t(i,s,n):t,!0),e.getType()==Ce&&(a.responseType="arraybuffer"),a.withCredentials=!1,a.onload=function(t){if(!a.status||a.status>=200&&a.status<300){const t=e.getType();let s;t==we||t==Fe?s=a.responseText:t==Oe?(s=a.responseXML,s||(s=(new DOMParser).parseFromString(a.responseText,"application/xml"))):t==Ce&&(s=a.response),s?o(e.readFeatures(s,{extent:i,featureProjection:n}),e.readProjection(s)):r()}else r()},a.onerror=r,a.send()}(t,e,i,s,n,(function(t,e){void 0!==o&&o(t),a.addFeatures(t)}),r||ct)}}class rs extends ft{constructor(t,e,i){super(t),this.feature=e,this.features=i}}class as extends ye{constructor(t){const e=t||{};super({attributions:e.attributions,projection:void 0,state:dt.READY,wrapX:void 0===e.wrapX||e.wrapX}),this.loader_=ct,this.format_=e.format,this.overlaps_=void 0===e.overlaps||e.overlaps,this.url_=e.url,void 0!==e.loader?this.loader_=e.loader:void 0!==this.url_&&(o(this.format_,7),this.loader_=os(this.url_,this.format_)),this.strategy_=void 0!==e.strategy?e.strategy:ns;const i=void 0===e.useSpatialIndex||e.useSpatialIndex;let s,n;this.featuresRtree_=i?new is:null,this.loadedExtentsRtree_=new is,this.nullGeometryFeatures_={},this.idIndex_={},this.uidIndex_={},this.featureChangeKeys_={},this.featuresCollection_=null,Array.isArray(e.features)?n=e.features:e.features&&(s=e.features,n=s.getArray()),i||void 0!==s||(s=new de(n)),void 0!==n&&this.addFeaturesInternal(n),void 0!==s&&this.bindFeaturesCollection_(s)}addFeature(t){this.addFeatureInternal(t),this.changed()}addFeatureInternal(t){const e=W(t);if(!this.addToIndex_(e,t))return void(this.featuresCollection_&&this.featuresCollection_.remove(t));this.setupChangeEvents_(e,t);const i=t.getGeometry();if(i){const e=i.getExtent();this.featuresRtree_&&this.featuresRtree_.insert(e,t)}else this.nullGeometryFeatures_[e]=t;this.dispatchEvent(new rs(ss.ADDFEATURE,t))}setupChangeEvents_(t,e){this.featureChangeKeys_[t]=[s(e,n.CHANGE,this.handleFeatureChange_,this),s(e,ut.PROPERTYCHANGE,this.handleFeatureChange_,this)]}addToIndex_(t,e){let i=!0;const s=e.getId();return void 0!==s&&(s.toString()in this.idIndex_?i=!1:this.idIndex_[s.toString()]=e),i&&(o(!(t in this.uidIndex_),30),this.uidIndex_[t]=e),i}addFeatures(t){this.addFeaturesInternal(t),this.changed()}addFeaturesInternal(t){const e=[],i=[],s=[];for(let e=0,s=t.length;e<s;e++){const s=t[e],n=W(s);this.addToIndex_(n,s)&&i.push(s)}for(let t=0,n=i.length;t<n;t++){const n=i[t],o=W(n);this.setupChangeEvents_(o,n);const r=n.getGeometry();if(r){const t=r.getExtent();e.push(t),s.push(n)}else this.nullGeometryFeatures_[o]=n}this.featuresRtree_&&this.featuresRtree_.load(e,s);for(let t=0,e=i.length;t<e;t++)this.dispatchEvent(new rs(ss.ADDFEATURE,i[t]))}bindFeaturesCollection_(t){let e=!1;this.addEventListener(ss.ADDFEATURE,(function(i){e||(e=!0,t.push(i.feature),e=!1)})),this.addEventListener(ss.REMOVEFEATURE,(function(i){e||(e=!0,t.remove(i.feature),e=!1)})),t.addEventListener(ue.ADD,function(t){e||(e=!0,this.addFeature(t.element),e=!1)}.bind(this)),t.addEventListener(ue.REMOVE,function(t){e||(e=!0,this.removeFeature(t.element),e=!1)}.bind(this)),this.featuresCollection_=t}clear(t){if(t){for(const t in this.featureChangeKeys_){this.featureChangeKeys_[t].forEach(i)}this.featuresCollection_||(this.featureChangeKeys_={},this.idIndex_={},this.uidIndex_={})}else if(this.featuresRtree_){this.featuresRtree_.forEach(this.removeFeatureInternal.bind(this));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 rs(ss.CLEAR);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 i=[t[0],t[1],t[0],t[1]];return this.forEachFeatureInExtent(i,(function(i){return i.getGeometry().intersectsCoordinate(t)?e(i):void 0}))}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(i){if(i.getGeometry().intersectsExtent(t)){const t=e(i);if(t)return t}}))}getFeaturesCollection(){return this.featuresCollection_}getFeatures(){let t;return this.featuresCollection_?t=this.featuresCollection_.getArray():this.featuresRtree_&&(t=this.featuresRtree_.getAll(),Q(this.nullGeometryFeatures_)||l(t,gt(this.nullGeometryFeatures_))),t}getFeaturesAtCoordinate(t){const e=[];return this.forEachFeatureAtCoordinateDirect(t,(function(t){e.push(t)})),e}getFeaturesInExtent(t){return this.featuresRtree_?this.featuresRtree_.getInExtent(t):this.featuresCollection_?this.featuresCollection_.getArray():[]}getClosestFeatureToCoordinate(t,e){const i=t[0],s=t[1];let n=null;const o=[NaN,NaN];let r=1/0;const a=[-1/0,-1/0,1/0,1/0],l=e||_t;return this.featuresRtree_.forEachInExtent(a,(function(t){if(l(t)){const e=t.getGeometry(),l=r;if(r=e.closestPointXY(i,s,o,r),r<l){n=t;const e=Math.sqrt(r);a[0]=i-e,a[1]=s-e,a[2]=i+e,a[3]=s+e}}})),n}getExtent(t){return this.featuresRtree_.getExtent(t)}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,i=W(e),s=e.getGeometry();if(s){const t=s.getExtent();i in this.nullGeometryFeatures_?(delete this.nullGeometryFeatures_[i],this.featuresRtree_&&this.featuresRtree_.insert(t,e)):this.featuresRtree_&&this.featuresRtree_.update(t,e)}else i in this.nullGeometryFeatures_||(this.featuresRtree_&&this.featuresRtree_.remove(e),this.nullGeometryFeatures_[i]=e);const n=e.getId();if(void 0!==n){const t=n.toString();this.idIndex_[t]!==e&&(this.removeFromIdIndex_(e),this.idIndex_[t]=e)}else this.removeFromIdIndex_(e),this.uidIndex_[i]=e;this.changed(),this.dispatchEvent(new rs(ss.CHANGEFEATURE,e))}hasFeature(t){const e=t.getId();return void 0!==e?e in this.idIndex_:W(t)in this.uidIndex_}isEmpty(){return this.featuresRtree_.isEmpty()&&Q(this.nullGeometryFeatures_)}loadFeatures(t,e,i){const s=this.loadedExtentsRtree_,n=this.strategy_(t,e);this.loading=!1;for(let t=0,o=n.length;t<o;++t){const o=n[t];s.forEachInExtent(o,(function(t){return rt(t.extent,o)}))||(this.dispatchEvent(new rs(ss.FEATURESLOADSTART)),this.loader_.call(this,o,e,i,function(t){this.dispatchEvent(new rs(ss.FEATURESLOADEND,void 0,t))}.bind(this),function(){this.dispatchEvent(new rs(ss.FEATURESLOADERROR))}.bind(this)),s.insert(o,{extent:o.slice()}),this.loading=this.loader_!==ct)}}refresh(){this.clear(!0),this.loadedExtentsRtree_.clear(),super.refresh()}removeLoadedExtent(t){const e=this.loadedExtentsRtree_;let i;e.forEachInExtent(t,(function(e){if(ht(e.extent,t))return i=e,!0})),i&&e.remove(i)}removeFeature(t){const e=W(t);e in this.nullGeometryFeatures_?delete this.nullGeometryFeatures_[e]:this.featuresRtree_&&this.featuresRtree_.remove(t),this.removeFeatureInternal(t),this.changed()}removeFeatureInternal(t){const e=W(t);this.featureChangeKeys_[e].forEach(i),delete this.featureChangeKeys_[e];const s=t.getId();void 0!==s&&delete this.idIndex_[s.toString()],delete this.uidIndex_[e],this.dispatchEvent(new rs(ss.REMOVEFEATURE,t))}removeFromIdIndex_(t){let e=!1;for(const i in this.idIndex_)if(this.idIndex_[i]===t){delete this.idIndex_[i],e=!0;break}return e}setLoader(t){this.loader_=t}setUrl(t){o(this.format_,7),this.setLoader(os(t,this.format_))}}class ls extends ge{constructor(t){super(),this.geometries_=t||null,this.changeEventsKeys_=[],this.listenGeometriesChange_()}unlistenGeometriesChange_(){this.changeEventsKeys_.forEach(i),this.changeEventsKeys_.length=0}listenGeometriesChange_(){if(this.geometries_)for(let t=0,e=this.geometries_.length;t<e;++t)this.changeEventsKeys_.push(s(this.geometries_[t],n.CHANGE,this.changed,this))}clone(){const t=new ls(null);return t.setGeometries(this.geometries_),t.applyProperties(this),t}closestPointXY(t,e,i,s){if(s<h(this.getExtent(),t,e))return s;const n=this.geometries_;for(let o=0,r=n.length;o<r;++o)s=n[o].closestPointXY(t,e,i,s);return s}containsXY(t,e){const i=this.geometries_;for(let s=0,n=i.length;s<n;++s)if(i[s].containsXY(t,e))return!0;return!1}computeExtent(t){mt(t);const e=this.geometries_;for(let i=0,s=e.length;i<s;++i)pt(t,e[i].getExtent());return t}getGeometries(){return hs(this.geometries_)}getGeometriesArray(){return this.geometries_}getGeometriesArrayRecursive(){let t=[];const e=this.geometries_;for(let i=0,s=e.length;i<s;++i)e[i].getType()===this.getType()?t=t.concat(e[i].getGeometriesArrayRecursive()):t.push(e[i]);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=[],i=this.geometries_;let s=!1;for(let n=0,o=i.length;n<o;++n){const o=i[n],r=o.getSimplifiedGeometry(t);e.push(r),r!==o&&(s=!0)}if(s){const t=new ls(null);return t.setGeometriesArray(e),t}return this.simplifiedGeometryMaxMinSquaredTolerance=t,this}getType(){return Nt.GEOMETRY_COLLECTION}intersectsExtent(t){const e=this.geometries_;for(let i=0,s=e.length;i<s;++i)if(e[i].intersectsExtent(t))return!0;return!1}isEmpty(){return 0===this.geometries_.length}rotate(t,e){const i=this.geometries_;for(let s=0,n=i.length;s<n;++s)i[s].rotate(t,e);this.changed()}scale(t,e,i){let s=i;s||(s=yt(this.getExtent()));const n=this.geometries_;for(let i=0,o=n.length;i<o;++i)n[i].scale(t,e,s);this.changed()}setGeometries(t){this.setGeometriesArray(hs(t))}setGeometriesArray(t){this.unlistenGeometriesChange_(),this.geometries_=t,this.listenGeometriesChange_(),this.changed()}applyTransform(t){const e=this.geometries_;for(let i=0,s=e.length;i<s;++i)e[i].applyTransform(t);this.changed()}translate(t,e){const i=this.geometries_;for(let s=0,n=i.length;s<n;++s)i[s].translate(t,e);this.changed()}disposeInternal(){this.unlistenGeometriesChange_(),super.disposeInternal()}}function hs(t){const e=[];for(let i=0,s=t.length;i<s;++i)e.push(t[i].clone());return e}class cs{constructor(){this.dataProjection=null,this.defaultFeatureProjection=null}getReadOptions(t,e){let i;if(e){let s=e.dataProjection?xt(e.dataProjection):this.readProjection(t);e.extent&&s&&s.getUnits()===It.TILE_PIXELS&&(s=xt(s),s.setWorldExtent(e.extent)),i={dataProjection:s,featureProjection:e.featureProjection}}return this.adaptOptions(i)}adaptOptions(t){return w({dataProjection:this.dataProjection,featureProjection:this.defaultFeatureProjection},t)}getType(){return _()}readFeature(t,e){return _()}readFeatures(t,e){return _()}readGeometry(t,e){return _()}readProjection(t){return _()}writeFeature(t,e){return _()}writeFeatures(t,e){return _()}writeGeometry(t,e){return _()}}function ds(t,e,i){const s=i?xt(i.featureProjection):null,n=i?xt(i.dataProjection):null;let o;if(o=s&&n&&!St(s,n)?(e?t.clone():t).transform(e?s:n,e?n:s):t,e&&i&&void 0!==i.decimals){const e=Math.pow(10,i.decimals),s=function(t){for(let i=0,s=t.length;i<s;++i)t[i]=Math.round(t[i]*e)/e;return t};o===t&&(o=t.clone()),o.applyTransform(s)}return o}class us extends cs{constructor(){super()}getType(){return we}readFeature(t,e){return this.readFeatureFromObject(gs(t),this.getReadOptions(t,e))}readFeatures(t,e){return this.readFeaturesFromObject(gs(t),this.getReadOptions(t,e))}readFeatureFromObject(t,e){return _()}readFeaturesFromObject(t,e){return _()}readGeometry(t,e){return this.readGeometryFromObject(gs(t),this.getReadOptions(t,e))}readGeometryFromObject(t,e){return _()}readProjection(t){return this.readProjectionFromObject(gs(t))}readProjectionFromObject(t){return _()}writeFeature(t,e){return JSON.stringify(this.writeFeatureObject(t,e))}writeFeatureObject(t,e){return _()}writeFeatures(t,e){return JSON.stringify(this.writeFeaturesObject(t,e))}writeFeaturesObject(t,e){return _()}writeGeometry(t,e){return JSON.stringify(this.writeGeometryObject(t,e))}writeGeometryObject(t,e){return _()}}function gs(t){if("string"==typeof t){const e=JSON.parse(t);return e||null}return null!==t?t:null}class fs extends us{constructor(t){const e=t||{};super(),this.dataProjection=xt(e.dataProjection?e.dataProjection:"EPSG:4326"),e.featureProjection&&(this.defaultFeatureProjection=xt(e.featureProjection)),this.geometryName_=e.geometryName,this.extractGeometryName_=e.extractGeometryName}readFeatureFromObject(t,e){let i=null;i="Feature"===t.type?t:{type:"Feature",geometry:t,properties:null};const s=_s(i.geometry,e),n=new Te;return this.geometryName_?n.setGeometryName(this.geometryName_):this.extractGeometryName_&&"geometry_name"in i!==void 0&&n.setGeometryName(i.geometry_name),n.setGeometry(s),"id"in i&&n.setId(i.id),i.properties&&n.setProperties(i.properties,!0),n}readFeaturesFromObject(t,e){let i=null;if("FeatureCollection"===t.type){i=[];const s=t.features;for(let t=0,n=s.length;t<n;++t)i.push(this.readFeatureFromObject(s[t],e))}else i=[this.readFeatureFromObject(t,e)];return i}readGeometryFromObject(t,e){return _s(t,e)}readProjectionFromObject(t){const e=t.crs;let i;return e?"name"==e.type?i=xt(e.properties.name):"EPSG"===e.type?i=xt("EPSG:"+e.properties.code):o(!1,36):i=this.dataProjection,i}writeFeatureObject(t,e){e=this.adaptOptions(e);const i={type:"Feature",geometry:null,properties:null},s=t.getId();if(void 0!==s&&(i.id=s),!t.hasProperties())return i;const n=t.getProperties(),o=t.getGeometry();return o&&(i.geometry=ms(o,e),delete n[t.getGeometryName()]),Q(n)||(i.properties=n),i}writeFeaturesObject(t,e){e=this.adaptOptions(e);const i=[];for(let s=0,n=t.length;s<n;++s)i.push(this.writeFeatureObject(t[s],e));return{type:"FeatureCollection",features:i}}writeGeometryObject(t,e){return ms(t,this.adaptOptions(e))}}function _s(t,e){if(!t)return null;let i;switch(t.type){case Nt.POINT:i=function(t){return new Ut(t.coordinates)}(t);break;case Nt.LINE_STRING:i=function(t){return new Ee(t.coordinates)}(t);break;case Nt.POLYGON:i=function(t){return new qt(t.coordinates)}(t);break;case Nt.MULTI_POINT:i=function(t){return new be(t.coordinates)}(t);break;case Nt.MULTI_LINE_STRING:i=function(t){return new Ne(t.coordinates)}(t);break;case Nt.MULTI_POLYGON:i=function(t){return new De(t.coordinates)}(t);break;case Nt.GEOMETRY_COLLECTION:i=function(t,e){const i=t.geometries.map((function(t){return _s(t,e)}));return new ls(i)}(t);break;default:throw new Error("Unsupported GeoJSON type: "+t.type)}return ds(i,!1,e)}function ms(t,e){const i=(t=ds(t,!0,e)).getType();let s;switch(i){case Nt.POINT:s=function(t,e){return{type:"Point",coordinates:t.getCoordinates()}}(t);break;case Nt.LINE_STRING:s=function(t,e){return{type:"LineString",coordinates:t.getCoordinates()}}(t);break;case Nt.POLYGON:s=function(t,e){let i;e&&(i=e.rightHanded);return{type:"Polygon",coordinates:t.getCoordinates(i)}}(t,e);break;case Nt.MULTI_POINT:s=function(t,e){return{type:"MultiPoint",coordinates:t.getCoordinates()}}(t);break;case Nt.MULTI_LINE_STRING:s=function(t,e){return{type:"MultiLineString",coordinates:t.getCoordinates()}}(t);break;case Nt.MULTI_POLYGON:s=function(t,e){let i;e&&(i=e.rightHanded);return{type:"MultiPolygon",coordinates:t.getCoordinates(i)}}(t,e);break;case Nt.GEOMETRY_COLLECTION:s=function(t,e){return{type:"GeometryCollection",geometries:t.getGeometriesArray().map((function(t){const i=w({},e);return delete i.featureProjection,ms(t,i)}))}}(t,e);break;case Nt.CIRCLE:s={type:"GeometryCollection",geometries:[]};break;default:throw new Error("Unsupported geometry type: "+i)}return s}const ps="http://www.w3.org/2001/XMLSchema-instance";function ys(t,e){return Ms().createElementNS(t,e)}function xs(t,e){return function t(e,i,s){if(e.nodeType==Node.CDATA_SECTION_NODE||e.nodeType==Node.TEXT_NODE)i?s.push(String(e.nodeValue).replace(/(\r\n|\r|\n)/g,"")):s.push(e.nodeValue);else{let n;for(n=e.firstChild;n;n=n.nextSibling)t(n,i,s)}return s}(t,e,[]).join("")}function Ss(t){return"documentElement"in t}function Is(t){return(new DOMParser).parseFromString(t,"application/xml")}function vs(t,e){return function(i,s){const n=t.call(void 0!==e?e:this,i,s);if(void 0!==n){const t=s[s.length-1];l(t,n)}}}function Cs(t,e){return function(i,s){const n=t.call(void 0!==e?e:this,i,s);if(void 0!==n){s[s.length-1].push(n)}}}function ws(t,e){return function(i,s){const n=t.call(void 0!==e?e:this,i,s);void 0!==n&&(s[s.length-1]=n)}}function Fs(t,e,i){return function(s,n){const o=t.call(void 0!==i?i:this,s,n);if(void 0!==o){n[n.length-1][void 0!==e?e:s.localName]=o}}}function Os(t,e){return function(i,s,n){t.call(void 0!==e?e:this,i,s,n);n[n.length-1].node.appendChild(i)}}function Ts(t,e){let i,s;return function(e,n,o){if(void 0===i){i={};const n={};n[e.localName]=t,i[e.namespaceURI]=n,s=Ls(e.localName)}Ds(i,s,n,o)}}function Ls(t,e){const i=t;return function(t,s,n){const o=s[s.length-1].node;let r=i;void 0===r&&(r=n);return ys(void 0!==e?e:o.namespaceURI,r)}}const ks=Ls();function Rs(t,e){const i=e.length,s=new Array(i);for(let n=0;n<i;++n)s[n]=t[e[n]];return s}function Es(t,e,i){const s=void 0!==i?i:{};let n,o;for(n=0,o=t.length;n<o;++n)s[t[n]]=e;return s}function Ns(t,e,i,s){let n;for(n=e.firstElementChild;n;n=n.nextElementSibling){const e=t[n.namespaceURI];if(void 0!==e){const t=e[n.localName];void 0!==t&&t.call(s,n,i)}}}function bs(t,e,i,s,n){return s.push(t),Ns(e,i,s,n),s.pop()}function Ds(t,e,i,s,n,o){const r=(void 0!==n?n:i).length;let a,l;for(let h=0;h<r;++h)a=i[h],void 0!==a&&(l=e.call(void 0!==o?o:this,a,s,void 0!==n?n[h]:void 0),void 0!==l&&t[l.namespaceURI][l.localName].call(o,l,a,s))}function Ps(t,e,i,s,n,o,r){return n.push(t),Ds(e,i,s,n,o,r),n.pop()}let Gs=void 0;let As=void 0;function Ms(){return void 0===As&&"undefined"!=typeof document&&(As=document.implementation.createDocument("","",null)),As}class Ys extends cs{constructor(){super(),this.xmlSerializer_=(void 0===Gs&&"undefined"!=typeof XMLSerializer&&(Gs=new XMLSerializer),Gs)}getType(){return Oe}readFeature(t,e){if(t){if("string"==typeof t){const i=Is(t);return this.readFeatureFromDocument(i,e)}return Ss(t)?this.readFeatureFromDocument(t,e):this.readFeatureFromNode(t,e)}return null}readFeatureFromDocument(t,e){const i=this.readFeaturesFromDocument(t,e);return i.length>0?i[0]:null}readFeatureFromNode(t,e){return null}readFeatures(t,e){if(t){if("string"==typeof t){const i=Is(t);return this.readFeaturesFromDocument(i,e)}return Ss(t)?this.readFeaturesFromDocument(t,e):this.readFeaturesFromNode(t,e)}return[]}readFeaturesFromDocument(t,e){const i=[];for(let s=t.firstChild;s;s=s.nextSibling)s.nodeType==Node.ELEMENT_NODE&&l(i,this.readFeaturesFromNode(s,e));return i}readFeaturesFromNode(t,e){return _()}readGeometry(t,e){if(t){if("string"==typeof t){const i=Is(t);return this.readGeometryFromDocument(i,e)}return Ss(t)?this.readGeometryFromDocument(t,e):this.readGeometryFromNode(t,e)}return null}readGeometryFromDocument(t,e){return null}readGeometryFromNode(t,e){return null}readProjection(t){if(t){if("string"==typeof t){const e=Is(t);return this.readProjectionFromDocument(e)}return Ss(t)?this.readProjectionFromDocument(t):this.readProjectionFromNode(t)}return null}readProjectionFromDocument(t){return this.dataProjection}readProjectionFromNode(t){return this.dataProjection}writeFeature(t,e){const i=this.writeFeatureNode(t,e);return this.xmlSerializer_.serializeToString(i)}writeFeatureNode(t,e){return null}writeFeatures(t,e){const i=this.writeFeaturesNode(t,e);return this.xmlSerializer_.serializeToString(i)}writeFeaturesNode(t,e){return null}writeGeometry(t,e){const i=this.writeGeometryNode(t,e);return this.xmlSerializer_.serializeToString(i)}writeGeometryNode(t,e){return null}}function Ws(t){return function(t){const e=/^\s*(true|1)|(false|0)\s*$/.exec(t);return e?void 0!==e[1]||!1:void 0}(xs(t,!1))}function Us(t){const e=xs(t,!1),i=Date.parse(e);return isNaN(i)?void 0:i/1e3}function Xs(t){return function(t){const e=/^\s*([+\-]?\d*\.?\d+(?:e[+\-]?\d+)?)\s*$/i.exec(t);return e?parseFloat(e[1]):void 0}(xs(t,!1))}function Bs(t){return function(t){const e=/^\s*(\d+)\s*$/.exec(t);return e?parseInt(e[1],10):void 0}(xs(t,!1))}function zs(t){return xs(t,!1).trim()}function js(t,e){Zs(t,e?"1":"0")}function Vs(t,e){const i=e.toPrecision();t.appendChild(Ms().createTextNode(i))}function Js(t,e){const i=e.toString();t.appendChild(Ms().createTextNode(i))}function Zs(t,e){t.appendChild(Ms().createTextNode(e))}const Hs=[null,"http://www.topografix.com/GPX/1/0","http://www.topografix.com/GPX/1/1"],Ks={rte:Fn,trk:On,wpt:Tn},qs=Es(Hs,{rte:Cs(Fn),trk:Cs(On),wpt:Cs(Tn)}),$s=Es(Hs,{text:Fs(zs,"linkText"),type:Fs(zs,"linkType")}),Qs=Es(Hs,{rte:Os((function(t,e,i){const s=i[0],n=e.getProperties(),o={node:t};o.properties=n;const r=e.getGeometry();if(r.getType()==Nt.LINE_STRING){const t=ds(r,!0,s);o.geometryLayout=t.getLayout(),n.rtept=t.getCoordinates()}const a=i[i.length-1].node,l=cn[a.namespaceURI],h=Rs(n,l);Ps(o,dn,ks,h,i,l)})),trk:Os((function(t,e,i){const s=i[0],n=e.getProperties(),o={node:t};o.properties=n;const r=e.getGeometry();if(r.getType()==Nt.MULTI_LINE_STRING){const t=ds(r,!0,s);n.trkseg=t.getLineStrings()}const a=i[i.length-1].node,l=gn[a.namespaceURI],h=Rs(n,l);Ps(o,fn,ks,h,i,l)})),wpt:Os((function(t,e,i){const s=i[0],n=i[i.length-1];n.properties=e.getProperties();const o=e.getGeometry();if(o.getType()==Nt.POINT){const e=ds(o,!0,s);n.geometryLayout=e.getLayout(),kn(t,e.getCoordinates(),i)}}))});class tn extends Ys{constructor(t){super();const e=t||{};this.dataProjection=xt("EPSG:4326"),this.readExtensions_=e.readExtensions}handleReadExtensions_(t){t||(t=[]);for(let e=0,i=t.length;e<i;++e){const i=t[e];if(this.readExtensions_){const t=i.get("extensionsNode_")||null;this.readExtensions_(i,t)}i.set("extensionsNode_",void 0)}}readFeatureFromNode(t,e){if(!vt(Hs,t.namespaceURI))return null;const i=Ks[t.localName];if(!i)return null;const s=i(t,[this.getReadOptions(t,e)]);return s?(this.handleReadExtensions_([s]),s):null}readFeaturesFromNode(t,e){if(!vt(Hs,t.namespaceURI))return[];if("gpx"==t.localName){const i=bs([],qs,t,[this.getReadOptions(t,e)]);return i?(this.handleReadExtensions_(i),i):[]}return[]}writeFeaturesNode(t,e){e=this.adaptOptions(e);const i=ys("http://www.topografix.com/GPX/1/1","gpx");return i.setAttributeNS("http://www.w3.org/2000/xmlns/","xmlns:xsi",ps),i.setAttributeNS(ps,"xsi:schemaLocation","http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd"),i.setAttribute("version","1.1"),i.setAttribute("creator","OpenLayers"),Ps({node:i},Qs,Sn,t,[e]),i}}const en=Es(Hs,{name:Fs(zs),cmt:Fs(zs),desc:Fs(zs),src:Fs(zs),link:Cn,number:Fs(Bs),extensions:wn,type:Fs(zs),rtept:function(t,e){const i=bs({},sn,t,e);if(i){const s=e[e.length-1],n=s.flatCoordinates,o=s.layoutOptions;In(n,o,t,i)}}}),sn=Es(Hs,{ele:Fs(Xs),time:Fs(Us)}),nn=Es(Hs,{name:Fs(zs),cmt:Fs(zs),desc:Fs(zs),src:Fs(zs),link:Cn,number:Fs(Bs),type:Fs(zs),extensions:wn,trkseg:function(t,e){const i=e[e.length-1];Ns(on,t,e);const s=i.flatCoordinates;i.ends.push(s.length)}}),on=Es(Hs,{trkpt:function(t,e){const i=bs({},rn,t,e);if(i){const s=e[e.length-1],n=s.flatCoordinates,o=s.layoutOptions;In(n,o,t,i)}}}),rn=Es(Hs,{ele:Fs(Xs),time:Fs(Us)}),an=Es(Hs,{ele:Fs(Xs),time:Fs(Us),magvar:Fs(Xs),geoidheight:Fs(Xs),name:Fs(zs),cmt:Fs(zs),desc:Fs(zs),src:Fs(zs),link:Cn,sym:Fs(zs),type:Fs(zs),fix:Fs(zs),sat:Fs(Bs),hdop:Fs(Xs),vdop:Fs(Xs),pdop:Fs(Xs),ageofdgpsdata:Fs(Xs),dgpsid:Fs(Bs),extensions:wn}),ln=["text","type"],hn=Es(Hs,{text:Os(Zs),type:Os(Zs)}),cn=Es(Hs,["name","cmt","desc","src","link","number","type","rtept"]),dn=Es(Hs,{name:Os(Zs),cmt:Os(Zs),desc:Os(Zs),src:Os(Zs),link:Os(Ln),number:Os(Js),type:Os(Zs),rtept:Ts(Os(kn))}),un=Es(Hs,["ele","time"]),gn=Es(Hs,["name","cmt","desc","src","link","number","type","trkseg"]),fn=Es(Hs,{name:Os(Zs),cmt:Os(Zs),desc:Os(Zs),src:Os(Zs),link:Os(Ln),number:Os(Js),type:Os(Zs),trkseg:Ts(Os((function(t,e,i){const s={node:t};s.geometryLayout=e.getLayout(),s.properties={},Ps(s,mn,_n,e.getCoordinates(),i)})))}),_n=Ls("trkpt"),mn=Es(Hs,{trkpt:Os(kn)}),pn=Es(Hs,["ele","time","magvar","geoidheight","name","cmt","desc","src","link","sym","type","fix","sat","hdop","vdop","pdop","ageofdgpsdata","dgpsid"]),yn=Es(Hs,{ele:Os(Vs),time:Os((function(t,e){const i=new Date(1e3*e),s=i.getUTCFullYear()+"-"+xe(i.getUTCMonth()+1,2)+"-"+xe(i.getUTCDate(),2)+"T"+xe(i.getUTCHours(),2)+":"+xe(i.getUTCMinutes(),2)+":"+xe(i.getUTCSeconds(),2)+"Z";t.appendChild(Ms().createTextNode(s))})),magvar:Os(Vs),geoidheight:Os(Vs),name:Os(Zs),cmt:Os(Zs),desc:Os(Zs),src:Os(Zs),link:Os(Ln),sym:Os(Zs),type:Os(Zs),fix:Os(Zs),sat:Os(Js),hdop:Os(Vs),vdop:Os(Vs),pdop:Os(Vs),ageofdgpsdata:Os(Vs),dgpsid:Os(Js)}),xn={Point:"wpt",LineString:"rte",MultiLineString:"trk"};function Sn(t,e,i){const s=t.getGeometry();if(s){const t=xn[s.getType()];if(t){return ys(e[e.length-1].node.namespaceURI,t)}}}function In(t,e,i,s){return t.push(parseFloat(i.getAttribute("lon")),parseFloat(i.getAttribute("lat"))),"ele"in s?(t.push(s.ele),delete s.ele,e.hasZ=!0):t.push(0),"time"in s?(t.push(s.time),delete s.time,e.hasM=!0):t.push(0),t}function vn(t,e,i){let s=kt.XY,n=2;if(t.hasZ&&t.hasM?(s=kt.XYZM,n=4):t.hasZ?(s=kt.XYZ,n=3):t.hasM&&(s=kt.XYM,n=3),4!==n){for(let i=0,s=e.length/4;i<s;i++)e[i*n]=e[4*i],e[i*n+1]=e[4*i+1],t.hasZ&&(e[i*n+2]=e[4*i+2]),t.hasM&&(e[i*n+2]=e[4*i+3]);if(e.length=e.length/4*n,i)for(let t=0,e=i.length;t<e;t++)i[t]=i[t]/4*n}return s}function Cn(t,e){const i=e[e.length-1],s=t.getAttribute("href");null!==s&&(i.link=s),Ns($s,t,e)}function wn(t,e){e[e.length-1].extensionsNode_=t}function Fn(t,e){const i=e[0],s=bs({flatCoordinates:[],layoutOptions:{}},en,t,e);if(!s)return;const n=s.flatCoordinates;delete s.flatCoordinates;const o=s.layoutOptions;delete s.layoutOptions;const r=vn(o,n),a=new Ee(n,r);ds(a,!1,i);const l=new Te(a);return l.setProperties(s,!0),l}function On(t,e){const i=e[0],s=bs({flatCoordinates:[],ends:[],layoutOptions:{}},nn,t,e);if(!s)return;const n=s.flatCoordinates;delete s.flatCoordinates;const o=s.ends;delete s.ends;const r=s.layoutOptions;delete s.layoutOptions;const a=vn(r,n,o),l=new Ne(n,a,o);ds(l,!1,i);const h=new Te(l);return h.setProperties(s,!0),h}function Tn(t,e){const i=e[0],s=bs({},an,t,e);if(!s)return;const n={},o=In([],n,t,s),r=vn(n,o),a=new Ut(o,r);ds(a,!1,i);const l=new Te(a);return l.setProperties(s,!0),l}function Ln(t,e,i){t.setAttribute("href",e);const s=i[i.length-1].properties,n=[s.linkText,s.linkType];Ps({node:t},hn,ks,n,i,ln)}function kn(t,e,i){const s=i[i.length-1],n=s.node.namespaceURI,o=s.properties;t.setAttributeNS(null,"lat",String(e[1])),t.setAttributeNS(null,"lon",String(e[0]));switch(s.geometryLayout){case kt.XYZM:0!==e[3]&&(o.time=e[3]);case kt.XYZ:0!==e[2]&&(o.ele=e[2]);break;case kt.XYM:0!==e[2]&&(o.time=e[2])}const r="rtept"==t.nodeName?un[n]:pn[n],a=Rs(o,r);Ps({node:t,properties:o},yn,ks,a,i,r)}const Rn=["http://www.google.com/kml/ext/2.2"],En=[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"],Nn={fraction:Wi,pixels:Ui,insetPixels:Ui},bn=Es(En,{ExtendedData:Go,Region:Ao,MultiGeometry:Fs(To,"geometry"),LineString:Fs(wo,"geometry"),LinearRing:Fs(Fo,"geometry"),Point:Fs(Lo,"geometry"),Polygon:Fs(Ro,"geometry"),Style:Fs(No),StyleMap:function(t,e){const i=ho.call(this,t,e);if(!i)return;const s=e[e.length-1];Array.isArray(i)?s.Style=i:"string"==typeof i?s.styleUrl=i:o(!1,38)},address:Fs(zs),description:Fs(zs),name:Fs(zs),open:Fs(Ws),phoneNumber:Fs(zs),styleUrl:Fs(ro),visibility:Fs(Ws)},Es(Rn,{MultiTrack:Fs((function(t,e){const i=bs([],po,t,e);if(!i)return;return new Ne(i)}),"geometry"),Track:Fs(xo,"geometry")})),Dn=Es(En,{ExtendedData:Go,Region:Ao,Link:function(t,e){Ns(Pn,t,e)},address:Fs(zs),description:Fs(zs),name:Fs(zs),open:Fs(Ws),phoneNumber:Fs(zs),visibility:Fs(Ws)}),Pn=Es(En,{href:Fs(oo)}),Gn=Es(En,{LatLonAltBox:function(t,e){const i=bs({},Wo,t,e);if(!i)return;const s=e[e.length-1],n=[parseFloat(i.west),parseFloat(i.south),parseFloat(i.east),parseFloat(i.north)];s.extent=n,s.altitudeMode=i.altitudeMode,s.minAltitude=parseFloat(i.minAltitude),s.maxAltitude=parseFloat(i.maxAltitude)},Lod:function(t,e){const i=bs({},Uo,t,e);if(!i)return;const s=e[e.length-1];s.minLodPixels=parseFloat(i.minLodPixels),s.maxLodPixels=parseFloat(i.maxLodPixels),s.minFadeExtent=parseFloat(i.minFadeExtent),s.maxFadeExtent=parseFloat(i.maxFadeExtent)}}),An=Es(En,["Document","Placemark"]),Mn=Es(En,{Document:Os((function(t,e,i){Ps({node:t},Vo,Jo,e,i,void 0,this)})),Placemark:Os(pr)});let Yn,Wn,Un,Xn,Bn,zn,jn,Vn,Jn,Zn,Hn=null,Kn=null,qn=null,$n=null,Qn=null,to=null;function eo(t){return t}class io extends Ys{constructor(t){super();const e=t||{};to||(Yn=[255,255,255,1],Hn=new Ye({color:Yn}),Wn=[20,2],Un=Ui,Xn=Ui,Bn=[64,64],zn="https://maps.google.com/mapfiles/kml/pushpin/ylw-pushpin.png",jn=.5,Kn=new Zi({anchor:Wn,anchorOrigin:Xi,anchorXUnits:Un,anchorYUnits:Xn,crossOrigin:"anonymous",rotation:0,scale:jn,size:Bn,src:zn}),Vn="NO_IMAGE",qn=new We({color:Yn,width:1}),Jn=new We({color:[51,51,51,1],width:2}),$n=new Hi({font:"bold 16px Helvetica",fill:Hn,stroke:Jn,scale:.8}),Qn=new Ue({fill:Hn,image:Kn,text:$n,stroke:qn,zIndex:0}),to=[Qn]),this.dataProjection=xt("EPSG:4326"),this.defaultStyle_=e.defaultStyle?e.defaultStyle:to,this.extractStyles_=void 0===e.extractStyles||e.extractStyles,this.writeStyles_=void 0===e.writeStyles||e.writeStyles,this.sharedStyles_={},this.showPointNames_=void 0===e.showPointNames||e.showPointNames,this.crossOrigin_=void 0!==e.crossOrigin?e.crossOrigin:"anonymous",this.iconUrlFunction_=e.iconUrlFunction?e.iconUrlFunction:eo}readDocumentOrFolder_(t,e){const i=bs([],Es(En,{Document:vs(this.readDocumentOrFolder_,this),Folder:vs(this.readDocumentOrFolder_,this),Placemark:Cs(this.readPlacemark_,this),Style:this.readSharedStyle_.bind(this),StyleMap:this.readSharedStyleMap_.bind(this)}),t,e,this);return i||void 0}readPlacemark_(t,e){const i=bs({geometry:null},bn,t,e,this);if(!i)return;const s=new Te,n=t.getAttribute("id");null!==n&&s.setId(n);const o=e[0],r=i.geometry;if(r&&ds(r,!1,o),s.setGeometry(r),delete i.geometry,this.extractStyles_){const t=function(t,e,i,s,n){return function(o,r){let a=n,l="",h=[];if(a){const t=o.getGeometry();if(t){const e=t.getType();e===Nt.GEOMETRY_COLLECTION?(h=t.getGeometriesArrayRecursive().filter((function(t){const e=t.getType();return e===Nt.POINT||e===Nt.MULTI_POINT})),a=h.length>0):a=e===Nt.POINT||e===Nt.MULTI_POINT}}a&&(l=o.get("name"),a=a&&!!l,a&&l.search(/&[^&]+;/)>-1&&(Zn||(Zn=document.createElement("textarea")),Zn.innerHTML=l,l=Zn.value));let c=i;if(t?c=t:e&&(c=function t(e,i,s){return Array.isArray(e)?e:"string"==typeof e?t(s[e],i,s):i}(e,i,s)),a){const t=function(t,e){const i=[0,0];let s="start";const n=t.getImage();if(n){let t=n.getImageSize();if(null===t&&(t=Bn),2==t.length){const e=n.getScaleArray();i[0]=e[0]*t[0]/2,i[1]=-e[1]*t[1]/2,s="left"}}let o=t.getText();o?(o=o.clone(),o.setFont(o.getFont()||$n.getFont()),o.setScale(o.getScale()||$n.getScale()),o.setFill(o.getFill()||$n.getFill()),o.setStroke(o.getStroke()||Jn)):o=$n.clone();o.setText(e),o.setOffsetX(i[0]),o.setOffsetY(i[1]),o.setTextAlign(s);return new Ue({image:n,text:o})}(c[0],l);if(h.length>0){t.setGeometry(new ls(h));return[t,new Ue({geometry:c[0].getGeometry(),image:null,fill:c[0].getFill(),stroke:c[0].getStroke(),text:null})].concat(c.slice(1))}return t}return c}}(i.Style,i.styleUrl,this.defaultStyle_,this.sharedStyles_,this.showPointNames_);s.setStyle(t)}return delete i.Style,s.setProperties(i,!0),s}readSharedStyle_(t,e){const i=t.getAttribute("id");if(null!==i){const s=No.call(this,t,e);if(s){let e,n=t.baseURI;if(n&&"about:blank"!=n||(n=window.location.href),n){e=new URL("#"+i,n).href}else e="#"+i;this.sharedStyles_[e]=s}}}readSharedStyleMap_(t,e){const i=t.getAttribute("id");if(null===i)return;const s=ho.call(this,t,e);if(!s)return;let n,o=t.baseURI;if(o&&"about:blank"!=o||(o=window.location.href),o){n=new URL("#"+i,o).href}else n="#"+i;this.sharedStyles_[n]=s}readFeatureFromNode(t,e){if(!vt(En,t.namespaceURI))return null;const i=this.readPlacemark_(t,[this.getReadOptions(t,e)]);return i||null}readFeaturesFromNode(t,e){if(!vt(En,t.namespaceURI))return[];let i;const s=t.localName;if("Document"==s||"Folder"==s)return i=this.readDocumentOrFolder_(t,[this.getReadOptions(t,e)]),i||[];if("Placemark"==s){const i=this.readPlacemark_(t,[this.getReadOptions(t,e)]);return i?[i]:[]}if("kml"==s){i=[];for(let s=t.firstElementChild;s;s=s.nextElementSibling){const t=this.readFeaturesFromNode(s,e);t&&l(i,t)}return i}return[]}readName(t){if(t){if("string"==typeof t){const e=Is(t);return this.readNameFromDocument(e)}return Ss(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(vt(En,e.namespaceURI)&&"name"==e.localName)return zs(e);for(let e=t.firstElementChild;e;e=e.nextElementSibling){const t=e.localName;if(vt(En,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 i=Is(t);l(e,this.readNetworkLinksFromDocument(i))}else Ss(t)?l(e,this.readNetworkLinksFromDocument(t)):l(e,this.readNetworkLinksFromNode(t));return e}readNetworkLinksFromDocument(t){const e=[];for(let i=t.firstChild;i;i=i.nextSibling)i.nodeType==Node.ELEMENT_NODE&&l(e,this.readNetworkLinksFromNode(i));return e}readNetworkLinksFromNode(t){const e=[];for(let i=t.firstElementChild;i;i=i.nextElementSibling)if(vt(En,i.namespaceURI)&&"NetworkLink"==i.localName){const t=bs({},Dn,i,[]);e.push(t)}for(let i=t.firstElementChild;i;i=i.nextElementSibling){const t=i.localName;!vt(En,i.namespaceURI)||"Document"!=t&&"Folder"!=t&&"kml"!=t||l(e,this.readNetworkLinksFromNode(i))}return e}readRegion(t){const e=[];if("string"==typeof t){const i=Is(t);l(e,this.readRegionFromDocument(i))}else Ss(t)?l(e,this.readRegionFromDocument(t)):l(e,this.readRegionFromNode(t));return e}readRegionFromDocument(t){const e=[];for(let i=t.firstChild;i;i=i.nextSibling)i.nodeType==Node.ELEMENT_NODE&&l(e,this.readRegionFromNode(i));return e}readRegionFromNode(t){const e=[];for(let i=t.firstElementChild;i;i=i.nextElementSibling)if(vt(En,i.namespaceURI)&&"Region"==i.localName){const t=bs({},Gn,i,[]);e.push(t)}for(let i=t.firstElementChild;i;i=i.nextElementSibling){const t=i.localName;!vt(En,i.namespaceURI)||"Document"!=t&&"Folder"!=t&&"kml"!=t||l(e,this.readRegionFromNode(i))}return e}writeFeaturesNode(t,e){e=this.adaptOptions(e);const i=ys(En[4],"kml"),s="http://www.w3.org/2000/xmlns/";i.setAttributeNS(s,"xmlns:gx",Rn[0]),i.setAttributeNS(s,"xmlns:xsi",ps),i.setAttributeNS(ps,"xsi:schemaLocation","http://www.opengis.net/kml/2.2 https://developers.google.com/kml/schema/kml22gx.xsd");const n={node:i},o={};t.length>1?o.Document=t:1==t.length&&(o.Placemark=t[0]);const r=An[i.namespaceURI],a=Rs(o,r);return Ps(n,Mn,ks,a,[e],r,this),i}}function so(t){const e=xs(t,!1),i=/^\s*#?\s*([0-9A-Fa-f]{8})\s*$/.exec(e);if(i){const t=i[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 no(t){let e=xs(t,!1);const i=[];e=e.replace(/\s*,\s*/g,",");const s=/^\s*([+\-]?\d*\.?\d+(?:e[+\-]?\d+)?),([+\-]?\d*\.?\d+(?:e[+\-]?\d+)?)(?:\s+|,|$)(?:([+\-]?\d*\.?\d+(?:e[+\-]?\d+)?)(?:\s+|$))?\s*/i;let n;for(;n=s.exec(e);){const t=parseFloat(n[1]),s=parseFloat(n[2]),o=n[3]?parseFloat(n[3]):0;i.push(t,s,o),e=e.substr(n[0].length)}if(""===e)return i}function oo(t){const e=xs(t,!1).trim();let i=t.baseURI;if(i&&"about:blank"!=i||(i=window.location.href),i){return new URL(e,i).href}return e}function ro(t){const e=xs(t,!1).trim().replace(/^(?!.*#)/,"#");let i=t.baseURI;if(i&&"about:blank"!=i||(i=window.location.href),i){return new URL(e,i).href}return e}function ao(t){return Xs(t)}const lo=Es(En,{Pair:function(t,e){const i=bs({},Mo,t,e,this);if(!i)return;const s=i.key;if(s&&"normal"==s){const t=i.styleUrl;t&&(e[e.length-1]=t);const s=i.Style;s&&(e[e.length-1]=s)}}});function ho(t,e){return bs(void 0,lo,t,e,this)}const co=Es(En,{Icon:Fs((function(t,e){const i=bs({},So,t,e);return i||null})),color:Fs(so),heading:Fs(Xs),hotSpot:Fs((function(t){const e=t.getAttribute("xunits"),i=t.getAttribute("yunits");let s;return s="insetPixels"!==e?"insetPixels"!==i?Xi:zi:"insetPixels"!==i?Bi:ji,{x:parseFloat(t.getAttribute("x")),xunits:Nn[e],y:parseFloat(t.getAttribute("y")),yunits:Nn[i],origin:s}})),scale:Fs(ao)});const uo=Es(En,{color:Fs(so),scale:Fs(ao)});const go=Es(En,{color:Fs(so),width:Fs(Xs)});const fo=Es(En,{color:Fs(so),fill:Fs(Ws),outline:Fs(Ws)});const _o=Es(En,{coordinates:ws(no)});function mo(t,e){return bs(null,_o,t,e)}const po=Es(Rn,{Track:Cs(xo)});const yo=Es(En,{when:function(t,e){const i=e[e.length-1].whens,s=xs(t,!1),n=Date.parse(s);i.push(isNaN(n)?0:n)}},Es(Rn,{coord:function(t,e){const i=e[e.length-1].flatCoordinates,s=xs(t,!1),n=/^\s*([+\-]?\d+(?:\.\d*)?(?:e[+\-]?\d*)?)\s+([+\-]?\d+(?:\.\d*)?(?:e[+\-]?\d*)?)\s+([+\-]?\d+(?:\.\d*)?(?:e[+\-]?\d*)?)\s*$/i.exec(s);if(n){const t=parseFloat(n[1]),e=parseFloat(n[2]),s=parseFloat(n[3]);i.push(t,e,s,0)}else i.push(0,0,0,0)}}));function xo(t,e){const i=bs({flatCoordinates:[],whens:[]},yo,t,e);if(!i)return;const s=i.flatCoordinates,n=i.whens;for(let t=0,e=Math.min(s.length,n.length);t<e;++t)s[4*t+3]=n[t];return new Ee(s,kt.XYZM)}const So=Es(En,{href:Fs(oo)},Es(Rn,{x:Fs(Xs),y:Fs(Xs),w:Fs(Xs),h:Fs(Xs)}));const Io=Es(En,{coordinates:ws(no)});function vo(t,e){return bs(null,Io,t,e)}const Co=Es(En,{extrude:Fs(Ws),tessellate:Fs(Ws),altitudeMode:Fs(zs)});function wo(t,e){const i=bs({},Co,t,e),s=vo(t,e);if(s){const t=new Ee(s,kt.XYZ);return t.setProperties(i,!0),t}}function Fo(t,e){const i=bs({},Co,t,e),s=vo(t,e);if(s){const t=new qt(s,kt.XYZ,[s.length]);return t.setProperties(i,!0),t}}const Oo=Es(En,{LineString:Cs(wo),LinearRing:Cs(Fo),MultiGeometry:Cs(To),Point:Cs(Lo),Polygon:Cs(Ro)});function To(t,e){const i=bs([],Oo,t,e);if(!i)return null;if(0===i.length)return new ls(i);let s,n=!0;const r=i[0].getType();let a;for(let t=1,e=i.length;t<e;++t)if(a=i[t],a.getType()!=r){n=!1;break}if(n){let t,e;if(r==Nt.POINT){const n=i[0];t=n.getLayout(),e=n.getFlatCoordinates();for(let t=1,s=i.length;t<s;++t)a=i[t],l(e,a.getFlatCoordinates());s=new be(e,t),bo(s,i)}else r==Nt.LINE_STRING?(s=new Ne(i),bo(s,i)):r==Nt.POLYGON?(s=new De(i),bo(s,i)):r==Nt.GEOMETRY_COLLECTION?s=new ls(i):o(!1,37)}else s=new ls(i);return s}function Lo(t,e){const i=bs({},Co,t,e),s=vo(t,e);if(s){const t=new Ut(s,kt.XYZ);return t.setProperties(i,!0),t}}const ko=Es(En,{innerBoundaryIs:function(t,e){const i=bs(void 0,Xo,t,e);if(i){e[e.length-1].push(i)}},outerBoundaryIs:function(t,e){const i=bs(void 0,Bo,t,e);if(i){e[e.length-1][0]=i}}});function Ro(t,e){const i=bs({},Co,t,e),s=bs([null],ko,t,e);if(s&&s[0]){const t=s[0],e=[t.length];for(let i=1,n=s.length;i<n;++i)l(t,s[i]),e.push(t.length);const n=new qt(t,kt.XYZ,e);return n.setProperties(i,!0),n}}const Eo=Es(En,{IconStyle:function(t,e){const i=bs({},co,t,e);if(!i)return;const s=e[e.length-1],n="Icon"in i?i.Icon:{},o=!("Icon"in i)||Object.keys(n).length>0;let r;const a=n.href;let l,h,c;a?r=a:o&&(r=zn);let d=Xi;const u=i.hotSpot;let g;u?(l=[u.x,u.y],h=u.xunits,c=u.yunits,d=u.origin):r===zn?(l=Wn,h=Un,c=Xn):/^http:\/\/maps\.(?:google|gstatic)\.com\//.test(r)&&(l=[.5,0],h=Wi,c=Wi);const f=n.x,_=n.y;let m;void 0!==f&&void 0!==_&&(g=[f,_]);const p=n.w,y=n.h;let x;void 0!==p&&void 0!==y&&(m=[p,y]);const S=i.heading;void 0!==S&&(x=Ct(S));let I=i.scale;const v=i.color;if(o){r==zn&&(m=Bn,void 0===I&&(I=jn));const t=new Zi({anchor:l,anchorOrigin:d,anchorXUnits:h,anchorYUnits:c,crossOrigin:this.crossOrigin_,offset:g,offsetOrigin:Xi,rotation:x,scale:I,size:m,src:this.iconUrlFunction_(r),color:v});s.imageStyle=t}else s.imageStyle=Vn},LabelStyle:function(t,e){const i=bs({},uo,t,e);if(!i)return;const s=e[e.length-1],n=new Hi({fill:new Ye({color:"color"in i?i.color:Yn}),scale:i.scale});s.textStyle=n},LineStyle:function(t,e){const i=bs({},go,t,e);if(!i)return;const s=e[e.length-1],n=new We({color:"color"in i?i.color:Yn,width:"width"in i?i.width:1});s.strokeStyle=n},PolyStyle:function(t,e){const i=bs({},fo,t,e);if(!i)return;const s=e[e.length-1],n=new Ye({color:"color"in i?i.color:Yn});s.fillStyle=n;const o=i.fill;void 0!==o&&(s.fill=o);const r=i.outline;void 0!==r&&(s.outline=r)}});function No(t,e){const i=bs({},Eo,t,e,this);if(!i)return null;let s="fillStyle"in i?i.fillStyle:Hn;const n=i.fill;let o;void 0===n||n||(s=null),"imageStyle"in i?i.imageStyle!=Vn&&(o=i.imageStyle):o=Kn;const r="textStyle"in i?i.textStyle:$n,a="strokeStyle"in i?i.strokeStyle:qn,l=i.outline;return void 0===l||l?[new Ue({fill:s,image:o,stroke:a,text:r,zIndex:void 0})]:[new Ue({geometry:function(t){const e=t.getGeometry(),i=e.getType();return i===Nt.GEOMETRY_COLLECTION?new ls(e.getGeometriesArrayRecursive().filter((function(t){const e=t.getType();return e!==Nt.POLYGON&&e!==Nt.MULTI_POLYGON}))):i!==Nt.POLYGON&&i!==Nt.MULTI_POLYGON?e:void 0},fill:s,image:o,stroke:a,text:r,zIndex:void 0}),new Ue({geometry:function(t){const e=t.getGeometry(),i=e.getType();return i===Nt.GEOMETRY_COLLECTION?new ls(e.getGeometriesArrayRecursive().filter((function(t){const e=t.getType();return e===Nt.POLYGON||e===Nt.MULTI_POLYGON}))):i===Nt.POLYGON||i===Nt.MULTI_POLYGON?e:void 0},fill:s,stroke:null,zIndex:void 0})]}function bo(t,e){const i=e.length,s=new Array(e.length),n=new Array(e.length),o=new Array(e.length);let r,a,l;r=!1,a=!1,l=!1;for(let t=0;t<i;++t){const i=e[t];s[t]=i.get("extrude"),n[t]=i.get("tessellate"),o[t]=i.get("altitudeMode"),r=r||void 0!==s[t],a=a||void 0!==n[t],l=l||o[t]}r&&t.set("extrude",s),a&&t.set("tessellate",n),l&&t.set("altitudeMode",o)}const Do=Es(En,{displayName:Fs(zs),value:Fs(zs)});const Po=Es(En,{Data:function(t,e){const i=t.getAttribute("name");Ns(Do,t,e);const s=e[e.length-1];i&&s.displayName?s[i]={value:s.value,displayName:s.displayName,toString:function(){return s.value}}:null!==i?s[i]=s.value:null!==s.displayName&&(s[s.displayName]=s.value),delete s.value},SchemaData:function(t,e){Ns(Yo,t,e)}});function Go(t,e){Ns(Po,t,e)}function Ao(t,e){Ns(Gn,t,e)}const Mo=Es(En,{Style:Fs(No),key:Fs(zs),styleUrl:Fs(ro)});const Yo=Es(En,{SimpleData:function(t,e){const i=t.getAttribute("name");if(null!==i){const s=zs(t);e[e.length-1][i]=s}}});const Wo=Es(En,{altitudeMode:Fs(zs),minAltitude:Fs(Xs),maxAltitude:Fs(Xs),north:Fs(Xs),south:Fs(Xs),east:Fs(Xs),west:Fs(Xs)});const Uo=Es(En,{minLodPixels:Fs(Xs),maxLodPixels:Fs(Xs),minFadeExtent:Fs(Xs),maxFadeExtent:Fs(Xs)});const Xo=Es(En,{LinearRing:ws(mo)});const Bo=Es(En,{LinearRing:ws(mo)});function zo(t,e){const i=ee(e),s=[255*(4==i.length?i[3]:1),i[2],i[1],i[0]];for(let t=0;t<4;++t){const e=Math.floor(s[t]).toString(16);s[t]=1==e.length?"0"+e:e}Zs(t,s.join(""))}const jo=Es(En,{Data:Os((function(t,e,i){t.setAttribute("name",e.name);const s={node:t},n=e.value;"object"==typeof n?(null!==n&&n.displayName&&Ps(s,jo,ks,[n.displayName],i,["displayName"]),null!==n&&n.value&&Ps(s,jo,ks,[n.value],i,["value"])):Ps(s,jo,ks,[n],i,["value"])})),value:Os((function(t,e){Zs(t,e)})),displayName:Os((function(t,e){!function(t,e){t.appendChild(Ms().createCDATASection(e))}(t,e)}))});const Vo=Es(En,{Placemark:Os(pr)}),Jo=function(t,e,i){return ys(e[e.length-1].node.namespaceURI,"Placemark")};const Zo=Ls("Data");const Ho=Es(En,["href"],Es(Rn,["x","y","w","h"])),Ko=Es(En,{href:Os(Zs)},Es(Rn,{x:Os(Vs),y:Os(Vs),w:Os(Vs),h:Os(Vs)})),qo=function(t,e,i){return ys(Rn[0],"gx:"+i)};const $o=Es(En,["scale","heading","Icon","color","hotSpot"]),Qo=Es(En,{Icon:Os((function(t,e,i){const s={node:t},n=i[i.length-1].node;let o=Ho[n.namespaceURI],r=Rs(e,o);Ps(s,Ko,ks,r,i,o),o=Ho[Rn[0]],r=Rs(e,o),Ps(s,Ko,qo,r,i,o)})),color:Os(zo),heading:Os(Vs),hotSpot:Os((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:Os(Tr)});const tr=Es(En,["color","scale"]),er=Es(En,{color:Os(zo),scale:Os(Tr)});const ir=Es(En,["color","width"]),sr=Es(En,{color:Os(zo),width:Os(Vs)});const nr={Point:"Point",LineString:"LineString",LinearRing:"LinearRing",Polygon:"Polygon",MultiPoint:"MultiGeometry",MultiLineString:"MultiGeometry",MultiPolygon:"MultiGeometry",GeometryCollection:"MultiGeometry"},or=function(t,e,i){if(t){return ys(e[e.length-1].node.namespaceURI,nr[t.getType()])}},rr=Ls("Point"),ar=Ls("LineString"),lr=Ls("LinearRing"),hr=Ls("Polygon"),cr=Es(En,{LineString:Os(Sr),Point:Os(Sr),Polygon:Os(Fr),GeometryCollection:Os(dr)});function dr(t,e,i){const s={node:t},n=e.getType();let r,a=[];n===Nt.GEOMETRY_COLLECTION?(e.getGeometriesArrayRecursive().forEach((function(t){const e=t.getType();e===Nt.MULTI_POINT?a=a.concat(t.getPoints()):e===Nt.MULTI_LINE_STRING?a=a.concat(t.getLineStrings()):e===Nt.MULTI_POLYGON?a=a.concat(t.getPolygons()):e===Nt.POINT||e===Nt.LINE_STRING||e===Nt.POLYGON?a.push(t):o(!1,39)})),r=or):n===Nt.MULTI_POINT?(a=e.getPoints(),r=rr):n===Nt.MULTI_LINE_STRING?(a=e.getLineStrings(),r=ar):n===Nt.MULTI_POLYGON?(a=e.getPolygons(),r=hr):o(!1,39),Ps(s,cr,r,a,i)}const ur=Es(En,{LinearRing:Os(Sr)});function gr(t,e,i){Ps({node:t},ur,lr,[e],i)}const fr=Es(En,{ExtendedData:Os((function(t,e,i){const s={node:t},n=e.names,o=e.values,r=n.length;for(let t=0;t<r;t++)Ps(s,jo,Zo,[{name:n[t],value:o[t]}],i)})),MultiGeometry:Os(dr),LineString:Os(Sr),LinearRing:Os(Sr),Point:Os(Sr),Polygon:Os(Fr),Style:Os((function(t,e,i){const s={node:t},n={};if(e.pointStyles.length){const t=e.pointStyles[0].getText();t&&(n.LabelStyle=t);const i=e.pointStyles[0].getImage();i&&"function"==typeof i.getSrc&&(n.IconStyle=i)}if(e.lineStyles.length){const t=e.lineStyles[0].getStroke();t&&(n.LineStyle=t)}if(e.polyStyles.length){const t=e.polyStyles[0].getStroke();t&&!n.LineStyle&&(n.LineStyle=t),n.PolyStyle=e.polyStyles[0]}const o=i[i.length-1].node,r=Lr[o.namespaceURI],a=Rs(n,r);Ps(s,kr,ks,a,i,r)})),address:Os(Zs),description:Os(Zs),name:Os(Zs),open:Os(js),phoneNumber:Os(Zs),styleUrl:Os(Zs),visibility:Os(js)}),_r=Es(En,["name","open","visibility","address","phoneNumber","description","styleUrl","Style"]),mr=Ls("ExtendedData");function pr(t,e,i){const s={node:t};e.getId()&&t.setAttribute("id",e.getId());const n=e.getProperties(),o={address:1,description:1,name:1,open:1,phoneNumber:1,styleUrl:1,visibility:1};o[e.getGeometryName()]=1;const r=Object.keys(n||{}).sort().filter((function(t){return!o[t]})),a=e.getStyleFunction();if(a){const t=a(e,0);if(t){const i=Array.isArray(t)?t:[t];let s=i;if(e.getGeometry()&&(s=i.filter((function(t){const i=t.getGeometryFunction()(e);if(i){const t=i.getType();return t===Nt.GEOMETRY_COLLECTION?i.getGeometriesArrayRecursive().filter((function(t){const e=t.getType();return e===Nt.POINT||e===Nt.MULTI_POINT})).length:t===Nt.POINT||t===Nt.MULTI_POINT}}))),this.writeStyles_){let t=i,o=i;e.getGeometry()&&(t=i.filter((function(t){const i=t.getGeometryFunction()(e);if(i){const t=i.getType();return t===Nt.GEOMETRY_COLLECTION?i.getGeometriesArrayRecursive().filter((function(t){const e=t.getType();return e===Nt.LINE_STRING||e===Nt.MULTI_LINE_STRING})).length:t===Nt.LINE_STRING||t===Nt.MULTI_LINE_STRING}})),o=i.filter((function(t){const i=t.getGeometryFunction()(e);if(i){const t=i.getType();return t===Nt.GEOMETRY_COLLECTION?i.getGeometriesArrayRecursive().filter((function(t){const e=t.getType();return e===Nt.POLYGON||e===Nt.MULTI_POLYGON})).length:t===Nt.POLYGON||t===Nt.MULTI_POLYGON}}))),n.Style={pointStyles:s,lineStyles:t,polyStyles:o}}if(s.length&&void 0===n.name){const t=s[0].getText();t&&(n.name=t.getText())}}}const l=i[i.length-1].node,h=_r[l.namespaceURI],c=Rs(n,h);if(Ps(s,fr,ks,c,i,h),r.length>0){const t=Rs(n,r);Ps(s,fr,mr,[{names:r,values:t}],i)}const d=i[0];let u=e.getGeometry();u&&(u=ds(u,!0,d)),Ps(s,fr,or,[u],i)}const yr=Es(En,["extrude","tessellate","altitudeMode","coordinates"]),xr=Es(En,{extrude:Os(js),tessellate:Os(js),altitudeMode:Os(Zs),coordinates:Os((function(t,e,i){const s=i[i.length-1],n=s.layout,r=s.stride;let a;n==kt.XY||n==kt.XYM?a=2:n==kt.XYZ||n==kt.XYZM?a=3:o(!1,34);const l=e.length;let h="";if(l>0){h+=e[0];for(let t=1;t<a;++t)h+=","+e[t];for(let t=r;t<l;t+=r){h+=" "+e[t];for(let i=1;i<a;++i)h+=","+e[t+i]}}Zs(t,h)}))});function Sr(t,e,i){const s=e.getFlatCoordinates(),n={node:t};n.layout=e.getLayout(),n.stride=e.getStride();const o=e.getProperties();o.coordinates=s;const r=i[i.length-1].node,a=yr[r.namespaceURI],l=Rs(o,a);Ps(n,xr,ks,l,i,a)}const Ir=Es(En,["color","fill","outline"]),vr=Es(En,{outerBoundaryIs:Os(gr),innerBoundaryIs:Os(gr)}),Cr=Ls("innerBoundaryIs"),wr=Ls("outerBoundaryIs");function Fr(t,e,i){const s=e.getLinearRings(),n=s.shift(),o={node:t};Ps(o,vr,Cr,s,i),Ps(o,vr,wr,[n],i)}const Or=Es(En,{color:Os(zo),fill:Os(js),outline:Os(js)});function Tr(t,e){Vs(t,Math.round(1e6*e)/1e6)}const Lr=Es(En,["IconStyle","LabelStyle","LineStyle","PolyStyle"]),kr=Es(En,{IconStyle:Os((function(t,e,i){const s={node:t},n={},o=e.getSrc(),r=e.getSize(),a=e.getImageSize(),l={href:o};if(r){l.w=r[0],l.h=r[1];const t=e.getAnchor(),i=e.getOrigin();if(i&&a&&0!==i[0]&&i[1]!==r[1]&&(l.x=i[0],l.y=a[1]-(i[1]+r[1])),t&&(t[0]!==r[0]/2||t[1]!==r[1]/2)){const e={x:t[0],xunits:Ui,y:r[1]-t[1],yunits:Ui};n.hotSpot=e}}n.Icon=l;const h=e.getScale();1!==h&&(n.scale=h);const c=e.getRotation();0!==c&&(n.heading=c);const d=e.getColor();d&&(n.color=d);const u=i[i.length-1].node,g=$o[u.namespaceURI],f=Rs(n,g);Ps(s,Qo,ks,f,i,g)})),LabelStyle:Os((function(t,e,i){const s={node:t},n={},o=e.getFill();o&&(n.color=o.getColor());const r=e.getScale();r&&1!==r&&(n.scale=r);const a=i[i.length-1].node,l=tr[a.namespaceURI],h=Rs(n,l);Ps(s,er,ks,h,i,l)})),LineStyle:Os((function(t,e,i){const s={node:t},n={color:e.getColor(),width:Number(e.getWidth())||1},o=i[i.length-1].node,r=ir[o.namespaceURI],a=Rs(n,r);Ps(s,sr,ks,a,i,r)})),PolyStyle:Os((function(t,e,i){const s={node:t},n=e.getFill(),o=e.getStroke(),r={color:n?n.getColor():void 0,fill:!!n&&void 0,outline:!!o&&void 0},a=i[i.length-1].node,l=Ir[a.namespaceURI],h=Rs(r,l);Ps(s,Or,ks,h,i,l)}))});var Rr={readFeatures:function(t,e){"string"==typeof t&&(t=JSON.parse(t));const i=[];return t.forEach(t=>{const s=new Te;for(const i in t)if("id"==i)s.setId(t[i]);else if(t[i]&&t[i].type&&t[i].coordinates){let n=new ol[t[i].type](t[i].coordinates);e&&e.featureProjection&&n.transform("EPSG:4326",e.featureProjection),s.setGeometry(n)}else s.set(i,t[i]);i.push(s)}),i},writeFeatures:function(t,e){const i=[],s=new fs;return JSON.parse(s.writeFeatures(t,e)).features.forEach(t=>{const e={id:t.id,geometry:t.geometry};for(const i in t.properties)e[i]=t.properties[i];i.push(e)}),JSON.stringify(i)}};const Er=fe.get(),Nr={normal:{stroke:{color:"rgba(0, 0, 255, 0.6)",width:3},fill:{color:"rgba(255, 255, 255, 0.6)"},image:{radius:7,fillColor:"#ffcc33"}},highlight:{stroke:{color:"rgba(255, 0, 0, 0.6)",width:3},fill:{color:"rgba(255, 0, 0, 0.1)"},image:{radius:7,fillColor:"#ffcc33"}}};function br(t){return{GeoJSON:new fs,GPX:new tn,KML:new io,mongo:Rr}[t]}function Dr(){return Er.getLayers().item(1).get("layers")}function Pr(t){const e=document.getElementById(t.target.htmlFor)||t.target;this.getLayers().item(1).get("layers").getArray().filter((function(t){return t.getProperties().id==e.value}))[0].set("visible",e.checked)}function Gr(t){t.vectors.forEach(e=>{let i,s=e.url;const n={featureProjection:Er.get("view").getProjection()},o={attributions:e.attribution||""},r=s||e.filename;if(r&&!e.format){const t={geojson:"GeoJSON",gpx:"GPX",kml:"KML"},e=r.substring(r.lastIndexOf(".")+1);i=t[e]}i=e.format||i,i&&(o.format=br(i)),e.file?o.features=o.format.readFeatures(e.file,n):s&&(e.strategy&&"bbox"==e.strategy&&(o.strategy=(t,e)=>[t]),o.loader=(t,r,a)=>{if(e.strategy&&"bbox"==e.strategy){const i=wt(t,a,"EPSG:4326");s=e.url+[[i[0].toFixed(6),i[1].toFixed(6)],[i[2].toFixed(6),i[1].toFixed(6)],[i[2].toFixed(6),i[3].toFixed(6)],[i[0].toFixed(6),i[3].toFixed(6)],[i[0].toFixed(6),i[1].toFixed(6)]].join("],[")+"]]]}}}}"}fetch(s).then(t=>"GeoJSON"==i||"mongo"==i?t.json():t.text()).then(t=>{const i=o.format.readFeatures(t,n);Dr().getArray().filter((function(t){return t.getProperties().id==e.id}))[0].get("source").addFeatures(i)}).catch(t=>{console.log(t),alert("Unable to load vector file")})});const a=new as(o);!0!==e.add||!s||e.strategy&&"bbox"==e.strategy||a.once("change",t=>{Er.get("view").fit(t.target.getExtent())});const l={source:a,id:e.id||s},h={};for(const t in Nr.normal)h[t]=Nr.normal[t];if(e.style)for(const t in e.style)h[t]=e.style[t];Nr[l.id]=h,l.style=t=>Ar(l.id,t);const c=new es(l);Dr().push(c),!0===e.add&&e.file&&Er.get("view").fit(a.getExtent()),e.noDisplay&&c.set("visible",!1);const d=Ie.addVectorDiv(e);if(d[0].addEventListener("click",Pr.bind(Er)),d[1]){const e=t.components||[];-1==e.indexOf("popup")&&(ve("#featuredisplayoption").style.display="block"),-1==e.indexOf("tooltip")&&(ve("#tooltipoption").style.display="block")}})}function Ar(t,e){const i={width:Nr[t].stroke.width,color:Nr[t].stroke.color,lineDash:Nr[t].stroke.lineDash};["color","width","lineDash"].forEach(t=>{if(Array.isArray(i[t])){const s=e.get(i[t][0]);"object"==typeof i[t][1]?i[t]=i[t][1][s]:i[t]=s==i[t][1]?i[t][2]:i[t][3]}});let s=Nr[t].image.fillColor;return Array.isArray(s)&&(s=e.get(s[0])==s[1]?s[2]:s[3]),new Ue({stroke:new We(i),fill:new Ye(Nr[t].fill),image:new Me({radius:Nr[t].image.radius,fill:new Ye({color:s})})})}var Mr={addInitial:function(t){Gr(t),t.center||t.zoom?t.rasters&&Se.makeActiveLayerVisible():function(){const t=Dr().getArray(),e=[1/0,1/0,-1/0,-1/0];let i=0;const s=s=>{var n,o;n=e,(o=s.target.getExtent())[0]<n[0]&&(n[0]=o[0]),o[2]>n[2]&&(n[2]=o[2]),o[1]<n[1]&&(n[1]=o[1]),o[3]>n[3]&&(n[3]=o[3]),i++,i==t.length&&(Er.get("view").fit(e),Se.makeActiveLayerVisible(),ve("#status").style.display="none")};t.forEach(t=>{t.get("source").once("change",s)})}(),t.rasters||fe.use4326View()},add:Gr,getFormat:br,getLayers:Dr,getStyle:Ar},Yr=Object.freeze({__proto__:null,default:Mr});export{Te as F,Ee as L,be as M,is as R,es as V,as as a,Ne as b,ze as c,De as d,ss as e,Yr as f,Mr as v};
  