Major: - GPS trail recording: reusable, dependency-free engine in src/geotracker/ (GeoTracker + geo-utils) with pluggable storage/sync adapters; LUPMIS wiring in src/geotracker-lupmis.js. Expandable My Location control (Locate Me + Record Trail), live navbar GPS readout, on-map trail/position rendering, gps_trails/gps_trail_points SQLocal tables, and store-and-forward sync via pushGpsTrail() -> save_gps_trail.php (server side documented, not yet built). - SSO authentication: public/index.php entry point validates the LUSPA SSO cookie and injects window.LUPMIS_SESSION; remotedb district_id is now a session-resolved getter. Adds public/.htaccess (DirectoryIndex). - Account menu offcanvas (navbar burger) with sign-in/out states. UI / fixes: - LayerSwitcher modernisation; base-map "None" option in picker + settings. - Mobile drawing toolbar wraps to two rows below 576px and shows only in Draw mode; second row right-aligned and clears the Select option bar. - Safari bottom-dock clipping fixed (app-container 100dvh -> 100svh). - Rename public/icons -> app-icons to dodge Apache's default /icons/ alias. - Service Worker bumped to v8 (network-first HTML, per-provider tile clear). Docs: reusable-mapping and OSM-3D-buildings concept notes; ignore Office lock files (~$*). Rebuilt dist/. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
574 lines
519 KiB
JavaScript
574 lines
519 KiB
JavaScript
const sf="modulepreload",rf=function(s){return"/"+s},_h={},E0=function(e,t,n){let i=Promise.resolve();if(t&&t.length>0){let o=function(h){return Promise.all(h.map(c=>Promise.resolve(c).then(u=>({status:"fulfilled",value:u}),u=>({status:"rejected",reason:u}))))};document.getElementsByTagName("link");const a=document.querySelector("meta[property=csp-nonce]"),l=a?.nonce||a?.getAttribute("nonce");i=o(t.map(h=>{if(h=rf(h),h in _h)return;_h[h]=!0;const c=h.endsWith(".css"),u=c?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${h}"]${u}`))return;const d=document.createElement("link");if(d.rel=c?"stylesheet":sf,c||(d.as="script"),d.crossOrigin="",d.href=h,l&&d.setAttribute("nonce",l),document.head.appendChild(d),c)return new Promise((f,g)=>{d.addEventListener("load",f),d.addEventListener("error",()=>g(new Error(`Unable to preload CSS for ${h}`)))})}))}function r(o){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=o,window.dispatchEvent(a),!a.defaultPrevented)throw o}return i.then(o=>{for(const a of o||[])a.status==="rejected"&&r(a.reason);return e().catch(r)})},Re={ADD:"add",REMOVE:"remove"},Oi={PROPERTYCHANGE:"propertychange"},V={CHANGE:"change",ERROR:"error",CONTEXTMENU:"contextmenu",CLICK:"click",DBLCLICK:"dblclick",KEYDOWN:"keydown",KEYPRESS:"keypress",LOAD:"load",TOUCHMOVE:"touchmove",WHEEL:"wheel"};class bs{constructor(){this.disposed=!1}dispose(){this.disposed||(this.disposed=!0,this.disposeInternal())}disposeInternal(){}}function of(s,e,t){let n,i;t=t||Ot;let r=0,o=s.length,a=!1;for(;r<o;)n=r+(o-r>>1),i=+t(s[n],e),i<0?r=n+1:(o=n,a=!i);return a?r:~r}function Ot(s,e){return s>e?1:s<e?-1:0}function af(s,e){return s<e?1:s>e?-1:0}function Za(s,e,t){if(s[0]<=e)return 0;const n=s.length;if(e<=s[n-1])return n-1;if(typeof t=="function"){for(let i=1;i<n;++i){const r=s[i];if(r===e)return i;if(r<e)return t(e,s[i-1],r)>0?i-1:i}return n-1}if(t>0){for(let i=1;i<n;++i)if(s[i]<e)return i-1;return n-1}if(t<0){for(let i=1;i<n;++i)if(s[i]<=e)return i;return n-1}for(let i=1;i<n;++i){if(s[i]==e)return i;if(s[i]<e)return s[i-1]-e<e-s[i]?i-1:i}return n-1}function lf(s,e,t){for(;e<t;){const n=s[e];s[e]=s[t],s[t]=n,++e,--t}}function se(s,e){const t=Array.isArray(e)?e:[e],n=t.length;for(let i=0;i<n;i++)s[s.length]=t[i]}function Ut(s,e){const t=s.length;if(t!==e.length)return!1;for(let n=0;n<t;n++)if(s[n]!==e[n])return!1;return!0}function hf(s,e,t){const n=e||Ot;return s.every(function(i,r){if(r===0)return!0;const o=n(s[r-1],i);return!(o>0||o===0)})}function wn(){return!0}function $i(){return!1}function Es(){}function Mc(s){let e,t,n;return function(){const i=Array.prototype.slice.call(arguments);return(!t||this!==n||!Ut(i,t))&&(n=this,t=i,e=s.apply(this,arguments)),e}}function Dc(s){function e(){let t;try{t=s()}catch(n){return Promise.reject(n)}return t instanceof Promise?t:Promise.resolve(t)}return e()}function Qn(s){for(const e in s)delete s[e]}function jn(s){let e;for(e in s)return!1;return!e}class Tt{constructor(e){this.propagationStopped,this.defaultPrevented,this.type=e,this.target=null}preventDefault(){this.defaultPrevented=!0}stopPropagation(){this.propagationStopped=!0}}class Ms extends bs{constructor(e){super(),this.eventTarget_=e,this.pendingRemovals_=null,this.dispatching_=null,this.listeners_=null}addEventListener(e,t){if(!e||!t)return;const n=this.listeners_||(this.listeners_={}),i=n[e]||(n[e]=[]);i.includes(t)||i.push(t)}dispatchEvent(e){const t=typeof e=="string",n=t?e:e.type,i=this.listeners_&&this.listeners_[n];if(!i)return;const r=t?new Tt(e):e;r.target||(r.target=this.eventTarget_||this);const o=this.dispatching_||(this.dispatching_={}),a=this.pendingRemovals_||(this.pendingRemovals_={});n in o||(o[n]=0,a[n]=0),++o[n];let l;for(let h=0,c=i.length;h<c;++h)if("handleEvent"in i[h]?l=i[h].handleEvent(r):l=i[h].call(this,r),l===!1||r.propagationStopped){l=!1;break}if(--o[n]===0){let h=a[n];for(delete a[n];h--;)this.removeEventListener(n,Es);delete o[n]}return l}disposeInternal(){this.listeners_&&Qn(this.listeners_)}getListeners(e){return this.listeners_&&this.listeners_[e]||void 0}hasListener(e){return this.listeners_?e?e in this.listeners_:Object.keys(this.listeners_).length>0:!1}removeEventListener(e,t){if(!this.listeners_)return;const n=this.listeners_[e];if(!n)return;const i=n.indexOf(t);i!==-1&&(this.pendingRemovals_&&e in this.pendingRemovals_?(n[i]=Es,++this.pendingRemovals_[e]):(n.splice(i,1),n.length===0&&delete this.listeners_[e]))}}function J(s,e,t,n,i){if(i){const o=t;t=function(a){return s.removeEventListener(e,t),o.call(n??this,a)}}else n&&n!==s&&(t=t.bind(n));const r={target:s,type:e,listener:t};return s.addEventListener(e,t),r}function Sr(s,e,t,n){return J(s,e,t,n,!0)}function ue(s){s&&s.target&&(s.target.removeEventListener(s.type,s.listener),Qn(s))}class Ds extends Ms{constructor(){super(),this.on=this.onInternal,this.once=this.onceInternal,this.un=this.unInternal,this.revision_=0}changed(){++this.revision_,this.dispatchEvent(V.CHANGE)}getRevision(){return this.revision_}onInternal(e,t){if(Array.isArray(e)){const n=e.length,i=new Array(n);for(let r=0;r<n;++r)i[r]=J(this,e[r],t);return i}return J(this,e,t)}onceInternal(e,t){let n;if(Array.isArray(e)){const i=e.length;n=new Array(i);for(let r=0;r<i;++r)n[r]=Sr(this,e[r],t)}else n=Sr(this,e,t);return t.ol_key=n,n}unInternal(e,t){const n=t.ol_key;if(n)cf(n);else if(Array.isArray(e))for(let i=0,r=e.length;i<r;++i)this.removeEventListener(e[i],t);else this.removeEventListener(e,t)}}Ds.prototype.on;Ds.prototype.once;Ds.prototype.un;function cf(s){if(Array.isArray(s))for(let e=0,t=s.length;e<t;++e)ue(s[e]);else ue(s)}function $(){throw new Error("Unimplemented abstract method.")}let uf=0;function D(s){return s.ol_uid||(s.ol_uid=String(++uf))}class mh extends Tt{constructor(e,t,n){super(e),this.key=t,this.oldValue=n}}class It extends Ds{constructor(e){super(),this.on,this.once,this.un,D(this),this.values_=null,e!==void 0&&this.setProperties(e)}get(e){let t;return this.values_&&this.values_.hasOwnProperty(e)&&(t=this.values_[e]),t}getKeys(){return this.values_&&Object.keys(this.values_)||[]}getProperties(){return this.values_&&Object.assign({},this.values_)||{}}getPropertiesInternal(){return this.values_}hasProperties(){return!!this.values_}notify(e,t){let n;n=`change:${e}`,this.hasListener(n)&&this.dispatchEvent(new mh(n,e,t)),n=Oi.PROPERTYCHANGE,this.hasListener(n)&&this.dispatchEvent(new mh(n,e,t))}addChangeListener(e,t){this.addEventListener(`change:${e}`,t)}removeChangeListener(e,t){this.removeEventListener(`change:${e}`,t)}set(e,t,n){const i=this.values_||(this.values_={});if(n)i[e]=t;else{const r=i[e];i[e]=t,r!==t&&this.notify(e,r)}}setProperties(e,t){for(const n in e)this.set(n,e[n],t)}applyProperties(e){e.values_&&Object.assign(this.values_||(this.values_={}),e.values_)}unset(e,t){if(this.values_&&e in this.values_){const n=this.values_[e];delete this.values_[e],jn(this.values_)&&(this.values_=null),t||this.notify(e,n)}}}const ph={LENGTH:"length"};class Zs extends Tt{constructor(e,t,n){super(e),this.element=t,this.index=n}}class Ve extends It{constructor(e,t){if(super(),this.on,this.once,this.un,t=t||{},this.unique_=!!t.unique,this.array_=e??[],this.unique_)for(let n=1,i=this.array_.length;n<i;++n)this.assertUnique_(this.array_[n],n);this.updateLength_()}clear(){for(;this.getLength()>0;)this.pop()}extend(e){for(let t=0,n=e.length;t<n;++t)this.push(e[t]);return this}forEach(e){const t=this.array_;for(let n=0,i=t.length;n<i;++n)e(t[n],n,t)}getArray(){return this.array_}item(e){return this.array_[e]}getLength(){return this.get(ph.LENGTH)}insertAt(e,t){if(e<0||e>this.getLength())throw new Error("Index out of bounds: "+e);this.unique_&&this.assertUnique_(t),this.array_.splice(e,0,t),this.updateLength_(),this.dispatchEvent(new Zs(Re.ADD,t,e))}pop(){return this.removeAt(this.getLength()-1)}push(e){const t=this.getLength();return this.insertAt(t,e),this.getLength()}remove(e){const t=this.array_;for(let n=0,i=t.length;n<i;++n)if(t[n]===e)return this.removeAt(n)}removeAt(e){if(e<0||e>=this.getLength())return;const t=this.array_[e];return this.array_.splice(e,1),this.updateLength_(),this.dispatchEvent(new Zs(Re.REMOVE,t,e)),t}setAt(e,t){const n=this.getLength();if(e>=n){this.insertAt(e,t);return}if(e<0)throw new Error("Index out of bounds: "+e);this.unique_&&this.assertUnique_(t,e);const i=this.array_[e];this.array_[e]=t,this.dispatchEvent(new Zs(Re.REMOVE,i,e)),this.dispatchEvent(new Zs(Re.ADD,t,e))}updateLength_(){this.set(ph.LENGTH,this.array_.length)}assertUnique_(e,t){const n=this.array_;for(let i=0,r=n.length;i<r;++i)if(n[i]===e&&i!==t)throw new Error("Duplicate item added to a unique collection")}}class Ei extends Tt{constructor(e,t,n){super(e),this.map=t,this.frameState=n!==void 0?n:null}}class Vt extends Ei{constructor(e,t,n,i,r,o){super(e,t,r),this.originalEvent=n,this.pixel_=null,this.coordinate_=null,this.dragging=i!==void 0?i:!1,this.activePointers=o}get pixel(){return this.pixel_||(this.pixel_=this.map.getEventPixel(this.originalEvent)),this.pixel_}set pixel(e){this.pixel_=e}get coordinate(){return this.coordinate_||(this.coordinate_=this.map.getCoordinateFromPixel(this.pixel)),this.coordinate_}set coordinate(e){this.coordinate_=e}preventDefault(){super.preventDefault(),"preventDefault"in this.originalEvent&&this.originalEvent.preventDefault()}stopPropagation(){super.stopPropagation(),"stopPropagation"in this.originalEvent&&this.originalEvent.stopPropagation()}}const ee={SINGLECLICK:"singleclick",CLICK:V.CLICK,DBLCLICK:V.DBLCLICK,POINTERDRAG:"pointerdrag",POINTERMOVE:"pointermove",POINTERDOWN:"pointerdown",POINTERUP:"pointerup",POINTEROVER:"pointerover",POINTEROUT:"pointerout",POINTERENTER:"pointerenter",POINTERLEAVE:"pointerleave",POINTERCANCEL:"pointercancel"},Vn=typeof navigator<"u"&&typeof navigator.userAgent<"u"?navigator.userAgent.toLowerCase():"",df=Vn.includes("safari")&&!Vn.includes("chrom"),ff=df&&(Vn.includes("version/15.4")||/cpu (os|iphone os) 15_4 like mac os x/.test(Vn)),gf=Vn.includes("webkit")&&!Vn.includes("edge"),Oc=Vn.includes("macintosh"),_f=typeof devicePixelRatio<"u"?devicePixelRatio:1,rt=typeof WorkerGlobalScope<"u"&&typeof OffscreenCanvas<"u"&&self instanceof WorkerGlobalScope,Nc=typeof Image<"u"&&Image.prototype.decode,mf=typeof createImageBitmap=="function",Gc=(function(){let s=!1;try{const e=Object.defineProperty({},"passive",{get:function(){s=!0}});window.addEventListener("_",null,e),window.removeEventListener("_",null,e)}catch{}return s})(),ga={POINTERMOVE:"pointermove",POINTERDOWN:"pointerdown"};class pf extends Ms{constructor(e,t){super(e),this.map_=e,this.clickTimeoutId_,this.emulateClicks_=!1,this.dragging_=!1,this.dragListenerKeys_=[],this.moveTolerance_=t===void 0?1:t,this.down_=null;const n=this.map_.getViewport();this.activePointers_=[],this.trackedTouches_={},this.element_=n,this.pointerdownListenerKey_=J(n,ga.POINTERDOWN,this.handlePointerDown_,this),this.originalPointerMoveEvent_,this.relayedListenerKey_=J(n,ga.POINTERMOVE,this.relayMoveEvent_,this),this.boundHandleTouchMove_=this.handleTouchMove_.bind(this),this.element_.addEventListener(V.TOUCHMOVE,this.boundHandleTouchMove_,Gc?{passive:!1}:!1)}emulateClick_(e){let t=new Vt(ee.CLICK,this.map_,e);this.dispatchEvent(t),this.clickTimeoutId_!==void 0?(clearTimeout(this.clickTimeoutId_),this.clickTimeoutId_=void 0,t=new Vt(ee.DBLCLICK,this.map_,e),this.dispatchEvent(t)):this.clickTimeoutId_=setTimeout(()=>{this.clickTimeoutId_=void 0;const n=new Vt(ee.SINGLECLICK,this.map_,e);this.dispatchEvent(n)},250)}updateActivePointers_(e){const t=e,n=t.pointerId;if(t.type==ee.POINTERUP||t.type==ee.POINTERCANCEL){delete this.trackedTouches_[n];for(const i in this.trackedTouches_)if(this.trackedTouches_[i].target!==t.target){delete this.trackedTouches_[i];break}}else(t.type==ee.POINTERDOWN||t.type==ee.POINTERMOVE)&&(this.trackedTouches_[n]=t);this.activePointers_=Object.values(this.trackedTouches_)}handlePointerUp_(e){this.updateActivePointers_(e);const t=new Vt(ee.POINTERUP,this.map_,e,void 0,void 0,this.activePointers_);this.dispatchEvent(t),this.emulateClicks_&&!t.defaultPrevented&&!this.dragging_&&this.isMouseActionButton_(e)&&this.emulateClick_(this.down_),this.activePointers_.length===0&&(this.dragListenerKeys_.forEach(ue),this.dragListenerKeys_.length=0,this.dragging_=!1,this.down_=null)}isMouseActionButton_(e){return e.button===0}handlePointerDown_(e){this.emulateClicks_=this.activePointers_.length===0,this.updateActivePointers_(e);const t=new Vt(ee.POINTERDOWN,this.map_,e,void 0,void 0,this.activePointers_);if(this.dispatchEvent(t),this.down_=new PointerEvent(e.type,e),Object.defineProperty(this.down_,"target",{writable:!1,value:e.target}),this.dragListenerKeys_.length===0){const n=this.map_.getOwnerDocument();this.dragListenerKeys_.push(J(n,ee.POINTERMOVE,this.handlePointerMove_,this),J(n,ee.POINTERUP,this.handlePointerUp_,this),J(this.element_,ee.POINTERCANCEL,this.handlePointerUp_,this)),this.element_.getRootNode&&this.element_.getRootNode()!==n&&this.dragListenerKeys_.push(J(this.element_.getRootNode(),ee.POINTERUP,this.handlePointerUp_,this))}}handlePointerMove_(e){if(this.isMoving_(e)){this.updateActivePointers_(e),this.dragging_=!0;const t=new Vt(ee.POINTERDRAG,this.map_,e,this.dragging_,void 0,this.activePointers_);this.dispatchEvent(t)}}relayMoveEvent_(e){this.originalPointerMoveEvent_=e;const t=!!(this.down_&&this.isMoving_(e));this.dispatchEvent(new Vt(ee.POINTERMOVE,this.map_,e,t))}handleTouchMove_(e){const t=this.originalPointerMoveEvent_;(!t||t.defaultPrevented)&&(typeof e.cancelable!="boolean"||e.cancelable===!0)&&e.preventDefault()}isMoving_(e){return this.dragging_||Math.abs(e.clientX-this.down_.clientX)>this.moveTolerance_||Math.abs(e.clientY-this.down_.clientY)>this.moveTolerance_}disposeInternal(){this.relayedListenerKey_&&(ue(this.relayedListenerKey_),this.relayedListenerKey_=null),this.element_.removeEventListener(V.TOUCHMOVE,this.boundHandleTouchMove_),this.pointerdownListenerKey_&&(ue(this.pointerdownListenerKey_),this.pointerdownListenerKey_=null),this.dragListenerKeys_.forEach(ue),this.dragListenerKeys_.length=0,this.element_=null,super.disposeInternal()}}const Zt={POSTRENDER:"postrender",MOVESTART:"movestart",MOVEEND:"moveend",LOADSTART:"loadstart",LOADEND:"loadend"},Ue={LAYERGROUP:"layergroup",SIZE:"size",TARGET:"target",VIEW:"view"},B={IDLE:0,LOADING:1,LOADED:2,ERROR:3,EMPTY:4};function te(s,e){if(!s)throw new Error(e)}const vr=1/0;class yf{constructor(e,t){this.priorityFunction_=e,this.keyFunction_=t,this.elements_=[],this.priorities_=[],this.queuedElements_={}}clear(){this.elements_.length=0,this.priorities_.length=0,Qn(this.queuedElements_)}dequeue(){const e=this.elements_,t=this.priorities_,n=e[0];e.length==1?(e.length=0,t.length=0):(e[0]=e.pop(),t[0]=t.pop(),this.siftUp_(0));const i=this.keyFunction_(n);return delete this.queuedElements_[i],n}enqueue(e){te(!(this.keyFunction_(e)in this.queuedElements_),"Tried to enqueue an `element` that was already added to the queue");const t=this.priorityFunction_(e);return t!=vr?(this.elements_.push(e),this.priorities_.push(t),this.queuedElements_[this.keyFunction_(e)]=!0,this.siftDown_(0,this.elements_.length-1),!0):!1}getCount(){return this.elements_.length}getLeftChildIndex_(e){return e*2+1}getRightChildIndex_(e){return e*2+2}getParentIndex_(e){return e-1>>1}heapify_(){let e;for(e=(this.elements_.length>>1)-1;e>=0;e--)this.siftUp_(e)}isEmpty(){return this.elements_.length===0}isKeyQueued(e){return e in this.queuedElements_}isQueued(e){return this.isKeyQueued(this.keyFunction_(e))}siftUp_(e){const t=this.elements_,n=this.priorities_,i=t.length,r=t[e],o=n[e],a=e;for(;e<i>>1;){const l=this.getLeftChildIndex_(e),h=this.getRightChildIndex_(e),c=h<i&&n[h]<n[l]?h:l;t[e]=t[c],n[e]=n[c],e=c}t[e]=r,n[e]=o,this.siftDown_(a,e)}siftDown_(e,t){const n=this.elements_,i=this.priorities_,r=n[t],o=i[t];for(;t>e;){const a=this.getParentIndex_(t);if(i[a]>o)n[t]=n[a],i[t]=i[a],t=a;else break}n[t]=r,i[t]=o}reprioritize(){const e=this.priorityFunction_,t=this.elements_,n=this.priorities_;let i=0;const r=t.length;let o,a,l;for(a=0;a<r;++a)o=t[a],l=e(o),l==vr?delete this.queuedElements_[this.keyFunction_(o)]:(n[i]=l,t[i++]=o);t.length=i,n.length=i,this.heapify_()}}class xf extends yf{constructor(e,t){super(n=>e.apply(null,n),n=>n[0].getKey()),this.boundHandleTileChange_=this.handleTileChange.bind(this),this.tileChangeCallback_=t,this.tilesLoading_=0,this.tilesLoadingKeys_={}}enqueue(e){const t=super.enqueue(e);return t&&e[0].addEventListener(V.CHANGE,this.boundHandleTileChange_),t}getTilesLoading(){return this.tilesLoading_}handleTileChange(e){const t=e.target,n=t.getState();if(n===B.LOADED||n===B.ERROR||n===B.EMPTY){n!==B.ERROR&&t.removeEventListener(V.CHANGE,this.boundHandleTileChange_);const i=t.getKey();i in this.tilesLoadingKeys_&&(delete this.tilesLoadingKeys_[i],--this.tilesLoading_),this.tileChangeCallback_()}}loadMoreTiles(e,t){let n=0;for(;this.tilesLoading_<e&&n<t&&this.getCount()>0;){const i=this.dequeue()[0],r=i.getKey();i.getState()===B.IDLE&&!(r in this.tilesLoadingKeys_)&&(this.tilesLoadingKeys_[r]=!0,++this.tilesLoading_,++n,i.load())}}}function Ef(s,e,t,n,i){if(!s||!(t in s.wantedTiles)||!s.wantedTiles[t][e.getKey()])return vr;const r=s.viewState.center,o=n[0]-r[0],a=n[1]-r[1];return 65536*Math.log(i)+Math.sqrt(o*o+a*a)/i}const he={ANIMATING:0,INTERACTING:1},Rt={CENTER:"center",RESOLUTION:"resolution",ROTATION:"rotation"};function fe(s,e,t){return Math.min(Math.max(s,e),t)}function Tf(s,e,t,n,i,r){const o=i-t,a=r-n;if(o!==0||a!==0){const l=((s-t)*o+(e-n)*a)/(o*o+a*a);l>1?(t=i,n=r):l>0&&(t+=o*l,n+=a*l)}return Jt(s,e,t,n)}function Jt(s,e,t,n){const i=t-s,r=n-e;return i*i+r*r}function Cf(s){const e=s.length;for(let n=0;n<e;n++){let i=n,r=Math.abs(s[n][n]);for(let a=n+1;a<e;a++){const l=Math.abs(s[a][n]);l>r&&(r=l,i=a)}if(r===0)return null;const o=s[i];s[i]=s[n],s[n]=o;for(let a=n+1;a<e;a++){const l=-s[a][n]/s[n][n];for(let h=n;h<e+1;h++)n==h?s[a][h]=0:s[a][h]+=l*s[n][h]}}const t=new Array(e);for(let n=e-1;n>=0;n--){t[n]=s[n][e]/s[n][n];for(let i=n-1;i>=0;i--)s[i][e]-=s[i][n]*t[n]}return t}function yh(s){return s*180/Math.PI}function pt(s){return s*Math.PI/180}function Qt(s,e){const t=s%e;return t*e<0?t+e:t}function it(s,e,t){return s+t*(e-s)}function Xi(s,e){const t=Math.pow(10,e);return Math.round(s*t)/t}function xh(s,e){return Math.round(Xi(s,e))}function Ks(s,e){return Math.floor(Xi(s,e))}function Hs(s,e){return Math.ceil(Xi(s,e))}function _a(s,e,t){if(s>=e&&s<t)return s;const n=t-e;return((s-e)%n+n)%n+e}function Eh(s,e,t){return(function(n,i,r,o,a){if(!n)return;if(!i&&!e)return n;const l=e?0:r[0]*i,h=e?0:r[1]*i,c=a?a[0]:0,u=a?a[1]:0;let d=s[0]+l/2+c,f=s[2]-l/2+c,g=s[1]+h/2+u,m=s[3]-h/2+u;d>f&&(d=(f+d)/2,f=d),g>m&&(g=(m+g)/2,m=g);let _=fe(n[0],d,f),p=fe(n[1],g,m);if(o&&t&&i){const y=30*i;_+=-y*Math.log(1+Math.max(0,d-n[0])/y)+y*Math.log(1+Math.max(0,n[0]-f)/y),p+=-y*Math.log(1+Math.max(0,g-n[1])/y)+y*Math.log(1+Math.max(0,n[1]-m)/y)}return[_,p]})}function Rf(s){return s}const Ae={UNKNOWN:0,INTERSECTING:1,ABOVE:2,RIGHT:4,BELOW:8,LEFT:16};function Be(s){const e=Je();for(let t=0,n=s.length;t<n;++t)fs(e,s[t]);return e}function Sf(s,e,t){const n=Math.min.apply(null,s),i=Math.min.apply(null,e),r=Math.max.apply(null,s),o=Math.max.apply(null,e);return kt(n,i,r,o,t)}function sn(s,e,t){return t?(t[0]=s[0]-e,t[1]=s[1]-e,t[2]=s[2]+e,t[3]=s[3]+e,t):[s[0]-e,s[1]-e,s[2]+e,s[3]+e]}function kc(s,e){return e?(e[0]=s[0],e[1]=s[1],e[2]=s[2],e[3]=s[3],e):s.slice()}function ei(s,e,t){let n,i;return e<s[0]?n=s[0]-e:s[2]<e?n=e-s[2]:n=0,t<s[1]?i=s[1]-t:s[3]<t?i=t-s[3]:i=0,n*n+i*i}function Zn(s,e){return Ka(s,e[0],e[1])}function pn(s,e){return s[0]<=e[0]&&e[2]<=s[2]&&s[1]<=e[1]&&e[3]<=s[3]}function Ka(s,e,t){return s[0]<=e&&e<=s[2]&&s[1]<=t&&t<=s[3]}function ma(s,e){const t=s[0],n=s[1],i=s[2],r=s[3],o=e[0],a=e[1];let l=Ae.UNKNOWN;return o<t?l=l|Ae.LEFT:o>i&&(l=l|Ae.RIGHT),a<n?l=l|Ae.BELOW:a>r&&(l=l|Ae.ABOVE),l===Ae.UNKNOWN&&(l=Ae.INTERSECTING),l}function Je(){return[1/0,1/0,-1/0,-1/0]}function kt(s,e,t,n,i){return i?(i[0]=s,i[1]=e,i[2]=t,i[3]=n,i):[s,e,t,n]}function Wi(s){return kt(1/0,1/0,-1/0,-1/0,s)}function ds(s,e){const t=s[0],n=s[1];return kt(t,n,t,n,e)}function Ha(s,e,t,n,i){const r=Wi(i);return Bc(r,s,e,t,n)}function Kn(s,e){return s[0]==e[0]&&s[2]==e[2]&&s[1]==e[1]&&s[3]==e[3]}function Uc(s,e){return e[0]<s[0]&&(s[0]=e[0]),e[2]>s[2]&&(s[2]=e[2]),e[1]<s[1]&&(s[1]=e[1]),e[3]>s[3]&&(s[3]=e[3]),s}function fs(s,e){e[0]<s[0]&&(s[0]=e[0]),e[0]>s[2]&&(s[2]=e[0]),e[1]<s[1]&&(s[1]=e[1]),e[1]>s[3]&&(s[3]=e[1])}function Bc(s,e,t,n,i){for(;t<n;t+=i)vf(s,e[t],e[t+1]);return s}function vf(s,e,t){s[0]=Math.min(s[0],e),s[1]=Math.min(s[1],t),s[2]=Math.max(s[2],e),s[3]=Math.max(s[3],t)}function qa(s,e){let t;return t=e(Kr(s)),t||(t=e(Hr(s)),t)||(t=e(qr(s)),t)||(t=e(An(s)),t)?t:!1}function pa(s){let e=0;return ti(s)||(e=ne(s)*be(s)),e}function Kr(s){return[s[0],s[1]]}function Hr(s){return[s[2],s[1]]}function Pn(s){return[(s[0]+s[2])/2,(s[1]+s[3])/2]}function wf(s,e){let t;if(e==="bottom-left")t=Kr(s);else if(e==="bottom-right")t=Hr(s);else if(e==="top-left")t=An(s);else if(e==="top-right")t=qr(s);else throw new Error("Invalid corner");return t}function ya(s,e,t,n,i){const[r,o,a,l,h,c,u,d]=zc(s,e,t,n);return kt(Math.min(r,a,h,u),Math.min(o,l,c,d),Math.max(r,a,h,u),Math.max(o,l,c,d),i)}function zc(s,e,t,n){const i=e*n[0]/2,r=e*n[1]/2,o=Math.cos(t),a=Math.sin(t),l=i*o,h=i*a,c=r*o,u=r*a,d=s[0],f=s[1];return[d-l+u,f-h-c,d-l-u,f-h+c,d+l-u,f+h+c,d+l+u,f+h-c,d-l+u,f-h-c]}function be(s){return s[3]-s[1]}function en(s,e,t){const n=t||Je();return Ee(s,e)?(s[0]>e[0]?n[0]=s[0]:n[0]=e[0],s[1]>e[1]?n[1]=s[1]:n[1]=e[1],s[2]<e[2]?n[2]=s[2]:n[2]=e[2],s[3]<e[3]?n[3]=s[3]:n[3]=e[3]):Wi(n),n}function An(s){return[s[0],s[3]]}function qr(s){return[s[2],s[3]]}function ne(s){return s[2]-s[0]}function Ee(s,e){return s[0]<=e[2]&&s[2]>=e[0]&&s[1]<=e[3]&&s[3]>=e[1]}function ti(s){return s[2]<s[0]||s[3]<s[1]}function Pf(s,e){return e?(e[0]=s[0],e[1]=s[1],e[2]=s[2],e[3]=s[3],e):s}function If(s,e){const t=(s[2]-s[0])/2*(e-1),n=(s[3]-s[1])/2*(e-1);s[0]-=t,s[2]+=t,s[1]-=n,s[3]+=n}function Lf(s,e,t){let n=!1;const i=ma(s,e),r=ma(s,t);if(i===Ae.INTERSECTING||r===Ae.INTERSECTING)n=!0;else{const o=s[0],a=s[1],l=s[2],h=s[3],c=e[0],u=e[1],d=t[0],f=t[1],g=(f-u)/(d-c);let m,_;r&Ae.ABOVE&&!(i&Ae.ABOVE)&&(m=d-(f-h)/g,n=m>=o&&m<=l),!n&&r&Ae.RIGHT&&!(i&Ae.RIGHT)&&(_=f-(d-l)*g,n=_>=a&&_<=h),!n&&r&Ae.BELOW&&!(i&Ae.BELOW)&&(m=d-(f-a)/g,n=m>=o&&m<=l),!n&&r&Ae.LEFT&&!(i&Ae.LEFT)&&(_=f-(d-o)*g,n=_>=a&&_<=h)}return n}function Af(s,e,t,n){if(ti(s))return Wi(t);let i=[];{const a=s[2]-s[0],l=s[3]-s[1];for(let h=0;h<n;++h)i.push(s[0]+a*h/n,s[1],s[2],s[1]+l*h/n,s[2]-a*h/n,s[3],s[0],s[3]-l*h/n)}e(i,i,2);const r=[],o=[];for(let a=0,l=i.length;a<l;a+=2)r.push(i[a]),o.push(i[a+1]);return Sf(r,o,t)}function $c(s,e){const t=e.getExtent(),n=Pn(s);if(e.canWrapX()&&(n[0]<t[0]||n[0]>=t[2])){const i=ne(t),o=Math.floor((n[0]-t[0])/i)*i;s[0]-=o,s[2]-=o}return s}function Xc(s,e,t){if(e.canWrapX()){const n=e.getExtent();if(!isFinite(s[0])||!isFinite(s[2]))return[[n[0],s[1],n[2],s[3]]];$c(s,e);const i=ne(n);if(ne(s)>i&&!t)return[[n[0],s[1],n[2],s[3]]];if(s[0]<n[0])return[[s[0]+i,s[1],n[2],s[3]],[n[0],s[1],s[2],s[3]]];if(s[2]>n[2])return[[s[0],s[1],n[2],s[3]],[n[0],s[1],s[2]-i,s[3]]]}return[s]}function Wc(s,e){const t=(""+s).split("."),n=(""+e).split(".");for(let i=0;i<Math.max(t.length,n.length);i++){const r=parseInt(t[i]||"0",10),o=parseInt(n[i]||"0",10);if(r>o)return 1;if(o>r)return-1}return 0}function Ff(s,e){return s[0]+=+e[0],s[1]+=+e[1],s}function Ja(s,e){const t=s[0],n=s[1],i=e[0],r=e[1],o=i[0],a=i[1],l=r[0],h=r[1],c=l-o,u=h-a,d=c===0&&u===0?0:(c*(t-o)+u*(n-a))/(c*c+u*u||0);let f,g;return d<=0?(f=o,g=a):d>=1?(f=l,g=h):(f=o+d*c,g=a+d*u),[f,g]}function je(s,e){let t=!0;for(let n=s.length-1;n>=0;--n)if(s[n]!=e[n]){t=!1;break}return t}function Qa(s,e){const t=Math.cos(e),n=Math.sin(e),i=s[0]*t-s[1]*n,r=s[1]*t+s[0]*n;return s[0]=i,s[1]=r,s}function bf(s,e){return s[0]*=e,s[1]*=e,s}function Ni(s,e){const t=s[0]-e[0],n=s[1]-e[1];return t*t+n*n}function Si(s,e){return Math.sqrt(Ni(s,e))}function Mf(s,e){return Ni(s,Ja(s,e))}function el(s,e){if(e.canWrapX()){const t=ne(e.getExtent()),n=Df(s,e,t);n&&(s[0]-=n*t)}return s}function Df(s,e,t){const n=e.getExtent();let i=0;return e.canWrapX()&&(s[0]<n[0]||s[0]>n[2])&&(t=t||ne(n),i=Math.floor((s[0]-n[0])/t)),i}function Yc(s){return Math.pow(s,3)}function Yi(s){return 1-Yc(1-s)}function Of(s){return 3*s*s-2*s*s*s}function Nf(s){return s}const tl=63710088e-1;function xa(s,e,t){t=t||tl;const n=pt(s[1]),i=pt(e[1]),r=(i-n)/2,o=pt(e[0]-s[0])/2,a=Math.sin(r)*Math.sin(r)+Math.sin(o)*Math.sin(o)*Math.cos(n)*Math.cos(i);return 2*t*Math.atan2(Math.sqrt(a),Math.sqrt(1-a))}function vo(s,e){let t=0;for(let n=0,i=s.length;n<i-1;++n)t+=xa(s[n],s[n+1],e);return t}function Gf(s,e){e=e||{};const t=e.radius||tl,n=e.projection||"EPSG:3857",i=s.getType();i!=="GeometryCollection"&&(s=s.clone().transform(n,"EPSG:4326"));let r=0,o,a,l,h,c,u;switch(i){case"Point":case"MultiPoint":break;case"LineString":case"LinearRing":{o=s.getCoordinates(),r=vo(o,t);break}case"MultiLineString":case"Polygon":{for(o=s.getCoordinates(),l=0,h=o.length;l<h;++l)r+=vo(o[l],t);break}case"MultiPolygon":{for(o=s.getCoordinates(),l=0,h=o.length;l<h;++l)for(a=o[l],c=0,u=a.length;c<u;++c)r+=vo(a[c],t);break}case"GeometryCollection":{const d=s.getGeometries();for(l=0,h=d.length;l<h;++l)r+=Gf(d[l],e);break}default:throw new Error("Unsupported geometry type: "+i)}return r}function qs(s,e){let t=0;const n=s.length;let i=s[n-1][0],r=s[n-1][1];for(let o=0;o<n;o++){const a=s[o][0],l=s[o][1];t+=pt(a-i)*(2+Math.sin(pt(r))+Math.sin(pt(l))),i=a,r=l}return t*e*e/2}function kf(s,e){e=e||{};const t=e.radius||tl,n=e.projection||"EPSG:3857",i=s.getType();i!=="GeometryCollection"&&(s=s.clone().transform(n,"EPSG:4326"));let r=0,o,a,l,h,c,u;switch(i){case"Point":case"MultiPoint":case"LineString":case"MultiLineString":case"LinearRing":break;case"Polygon":{for(o=s.getCoordinates(),r=Math.abs(qs(o[0],t)),l=1,h=o.length;l<h;++l)r-=Math.abs(qs(o[l],t));break}case"MultiPolygon":{for(o=s.getCoordinates(),l=0,h=o.length;l<h;++l)for(a=o[l],r+=Math.abs(qs(a[0],t)),c=1,u=a.length;c<u;++c)r-=Math.abs(qs(a[c],t));break}case"GeometryCollection":{const d=s.getGeometries();for(l=0,h=d.length;l<h;++l)r+=kf(d[l],e);break}default:throw new Error("Unsupported geometry type: "+i)}return r}function jc(...s){console.warn(...s)}const Gi={radians:6370997/(2*Math.PI),degrees:2*Math.PI*6370997/360,ft:.3048,m:1,"us-ft":1200/3937};class nl{constructor(e){this.code_=e.code,this.units_=e.units,this.extent_=e.extent!==void 0?e.extent:null,this.worldExtent_=e.worldExtent!==void 0?e.worldExtent:null,this.axisOrientation_=e.axisOrientation!==void 0?e.axisOrientation:"enu",this.global_=e.global!==void 0?e.global:!1,this.canWrapX_=!!(this.global_&&this.extent_),this.getPointResolutionFunc_=e.getPointResolution,this.defaultTileGrid_=null,this.metersPerUnit_=e.metersPerUnit}canWrapX(){return this.canWrapX_}getCode(){return this.code_}getExtent(){return this.extent_}getUnits(){return this.units_}getMetersPerUnit(){return this.metersPerUnit_||Gi[this.units_]}getWorldExtent(){return this.worldExtent_}getAxisOrientation(){return this.axisOrientation_}isGlobal(){return this.global_}setGlobal(e){this.global_=e,this.canWrapX_=!!(e&&this.extent_)}getDefaultTileGrid(){return this.defaultTileGrid_}setDefaultTileGrid(e){this.defaultTileGrid_=e}setExtent(e){this.extent_=e,this.canWrapX_=!!(this.global_&&e)}setWorldExtent(e){this.worldExtent_=e}setGetPointResolution(e){this.getPointResolutionFunc_=e}getPointResolutionFunc(){return this.getPointResolutionFunc_}}const Os=6378137,vi=Math.PI*Os,Uf=[-vi,-vi,vi,vi],Bf=[-180,-85,180,85],Js=Os*Math.log(Math.tan(Math.PI/2));class ci extends nl{constructor(e){super({code:e,units:"m",extent:Uf,global:!0,worldExtent:Bf,getPointResolution:function(t,n){return t/Math.cosh(n[1]/Os)}})}}const Th=[new ci("EPSG:3857"),new ci("EPSG:102100"),new ci("EPSG:102113"),new ci("EPSG:900913"),new ci("http://www.opengis.net/def/crs/EPSG/0/3857"),new ci("http://www.opengis.net/gml/srs/epsg.xml#3857")];function zf(s,e,t,n){const i=s.length;t=t>1?t:2,n=n??t,e===void 0&&(t>2?e=s.slice():e=new Array(i));for(let r=0;r<i;r+=n){e[r]=vi*s[r]/180;let o=Os*Math.log(Math.tan(Math.PI*(+s[r+1]+90)/360));o>Js?o=Js:o<-Js&&(o=-Js),e[r+1]=o}return e}function $f(s,e,t,n){const i=s.length;t=t>1?t:2,n=n??t,e===void 0&&(t>2?e=s.slice():e=new Array(i));for(let r=0;r<i;r+=n)e[r]=180*s[r]/vi,e[r+1]=360*Math.atan(Math.exp(s[r+1]/Os))/Math.PI-90;return e}const Xf=6378137,Ch=[-180,-90,180,90],Wf=Math.PI*Xf/180;class On extends nl{constructor(e,t){super({code:e,units:"degrees",extent:Ch,axisOrientation:t,global:!0,metersPerUnit:Wf,worldExtent:Ch})}}const Rh=[new On("CRS:84"),new On("EPSG:4326","neu"),new On("urn:ogc:def:crs:OGC:1.3:CRS84"),new On("urn:ogc:def:crs:OGC:2:84"),new On("http://www.opengis.net/def/crs/OGC/1.3/CRS84"),new On("http://www.opengis.net/gml/srs/epsg.xml#4326","neu"),new On("http://www.opengis.net/def/crs/EPSG/0/4326","neu")];let Ea={};function Yf(s){return Ea[s]||Ea[s.replace(/urn:(x-)?ogc:def:crs:EPSG:(.*:)?(\w+)$/,"EPSG:$3")]||null}function jf(s,e){Ea[s]=e}let Ii={};function Ts(s,e,t){const n=s.getCode(),i=e.getCode();n in Ii||(Ii[n]={}),Ii[n][i]=t}function wo(s,e){return s in Ii&&e in Ii[s]?Ii[s][e]:null}const wr=.9996,yt=.00669438,Jr=yt*yt,Qr=Jr*yt,Un=yt/(1-yt),Sh=Math.sqrt(1-yt),ki=(1-Sh)/(1+Sh),Vc=ki*ki,il=Vc*ki,sl=il*ki,Zc=sl*ki,Kc=1-yt/4-3*Jr/64-5*Qr/256,Vf=3*yt/8+3*Jr/32+45*Qr/1024,Zf=15*Jr/256+45*Qr/1024,Kf=35*Qr/3072,Hf=3/2*ki-27/32*il+269/512*Zc,qf=21/16*Vc-55/32*sl,Jf=151/96*il-417/128*Zc,Qf=1097/512*sl,Pr=6378137;function eg(s,e,t){const n=s-5e5,o=(t.north?e:e-1e7)/wr/(Pr*Kc),a=o+Hf*Math.sin(2*o)+qf*Math.sin(4*o)+Jf*Math.sin(6*o)+Qf*Math.sin(8*o),l=Math.sin(a),h=l*l,c=Math.cos(a),u=l/c,d=u*u,f=d*d,g=1-yt*h,m=Math.sqrt(1-yt*h),_=Pr/m,p=(1-yt)/g,y=Un*c**2,E=y*y,x=n/(_*wr),T=x*x,R=T*x,S=R*x,v=S*x,w=v*x,I=a-u/p*(T/2-S/24*(5+3*d+10*y-4*E-9*Un))+w/720*(61+90*d+298*y+45*f-252*Un-3*E);let F=(x-R/6*(1+2*d+y)+v/120*(5-2*y+28*d-3*E+8*Un+24*f))/c;return F=_a(F+pt(Hc(t.number)),-Math.PI,Math.PI),[yh(F),yh(I)]}const vh=-80,wh=84,tg=-180,ng=180;function ig(s,e,t){s=_a(s,tg,ng),e<vh?e=vh:e>wh&&(e=wh);const n=pt(e),i=Math.sin(n),r=Math.cos(n),o=i/r,a=o*o,l=a*a,h=pt(s),c=Hc(t.number),u=pt(c),d=Pr/Math.sqrt(1-yt*i**2),f=Un*r**2,g=r*_a(h-u,-Math.PI,Math.PI),m=g*g,_=m*g,p=_*g,y=p*g,E=y*g,x=Pr*(Kc*n-Vf*Math.sin(2*n)+Zf*Math.sin(4*n)-Kf*Math.sin(6*n)),T=wr*d*(g+_/6*(1-a+f)+y/120*(5-18*a+l+72*f-58*Un))+5e5;let R=wr*(x+d*o*(m/2+p/24*(5-a+9*f+4*f**2)+E/720*(61-58*a+l+600*f-330*Un)));return t.north||(R+=1e7),[T,R]}function Hc(s){return(s-1)*6-180+3}const sg=[/^EPSG:(\d+)$/,/^urn:ogc:def:crs:EPSG::(\d+)$/,/^http:\/\/www\.opengis\.net\/def\/crs\/EPSG\/0\/(\d+)$/];function qc(s){let e=0;for(const i of sg){const r=s.match(i);if(r){e=parseInt(r[1]);break}}if(!e)return null;let t=0,n=!1;return e>32700&&e<32761?t=e-32700:e>32600&&e<32661&&(n=!0,t=e-32600),t?{number:t,north:n}:null}function Ph(s,e){return function(t,n,i,r){const o=t.length;i=i>1?i:2,r=r??i,n||(i>2?n=t.slice():n=new Array(o));for(let a=0;a<o;a+=r){const l=t[a],h=t[a+1],c=s(l,h,e);n[a]=c[0],n[a+1]=c[1]}return n}}function rg(s){return qc(s)?new nl({code:s,units:"m"}):null}function og(s){const e=qc(s.getCode());return e?{forward:Ph(ig,e),inverse:Ph(eg,e)}:null}const ag=[og],lg=[rg];let Ta=!0;function Jc(s){Ta=!1}function rl(s,e){if(e!==void 0){for(let t=0,n=s.length;t<n;++t)e[t]=s[t];e=e}else e=s.slice();return e}function Ca(s){jf(s.getCode(),s),Ts(s,s,rl)}function hg(s){s.forEach(Ca)}function _e(s){if(typeof s!="string")return s;const e=Yf(s);if(e)return e;for(const t of lg){const n=t(s);if(n)return n}return null}function Ir(s,e,t,n){s=_e(s);let i;const r=s.getPointResolutionFunc();if(r){if(i=r(e,t),n&&n!==s.getUnits()){const o=s.getMetersPerUnit();o&&(i=i*o/Gi[n])}}else{const o=s.getUnits();if(o=="degrees"&&!n||n=="degrees")i=e;else{const a=eo(s,_e("EPSG:4326"));if(!a&&o!=="degrees")i=e*s.getMetersPerUnit();else{let h=[t[0]-e/2,t[1],t[0]+e/2,t[1],t[0],t[1]-e/2,t[0],t[1]+e/2];h=a(h,h,2);const c=xa(h.slice(0,2),h.slice(2,4)),u=xa(h.slice(4,6),h.slice(6,8));i=(c+u)/2}const l=n?Gi[n]:s.getMetersPerUnit();l!==void 0&&(i/=l)}}return i}function Ih(s){hg(s),s.forEach(function(e){s.forEach(function(t){e!==t&&Ts(e,t,rl)})})}function cg(s,e,t,n){s.forEach(function(i){e.forEach(function(r){Ts(i,r,t),Ts(r,i,n)})})}function ol(s,e){return s?typeof s=="string"?_e(s):s:_e(e)}function ug(s){return(function(e,t,n,i){const r=e.length;n=n!==void 0?n:2,i=i??n,t=t!==void 0?t:new Array(r);for(let o=0;o<r;o+=i){const a=s(e.slice(o,o+n)),l=a.length;for(let h=0,c=i;h<c;++h)t[o+h]=h>=l?e[o+h]:a[h]}return t})}function T0(s,e){return Jc(),Ns(s,"EPSG:4326","EPSG:3857")}function C0(s,e){const t=Ns(s,"EPSG:3857","EPSG:4326"),n=t[0];return(n<-180||n>180)&&(t[0]=Qt(n+180,360)-180),t}function Yn(s,e){if(s===e)return!0;const t=s.getUnits()===e.getUnits();return(s.getCode()===e.getCode()||eo(s,e)===rl)&&t}function eo(s,e){const t=s.getCode(),n=e.getCode();let i=wo(t,n);if(i)return i;let r=null,o=null;for(const l of ag)r||(r=l(s)),o||(o=l(e));if(!r&&!o)return null;const a="EPSG:4326";if(o)if(r)i=Po(r.inverse,o.forward);else{const l=wo(t,a);l&&(i=Po(l,o.forward))}else{const l=wo(a,n);l&&(i=Po(r.inverse,l))}return i&&(Ca(s),Ca(e),Ts(s,e,i)),i}function Po(s,e){return function(t,n,i,r){return n=s(t,n,i,r),e(n,n,i,r)}}function Hn(s,e){const t=_e(s),n=_e(e);return eo(t,n)}function Ns(s,e,t){const n=Hn(e,t);if(!n){const i=_e(e).getCode(),r=_e(t).getCode();throw new Error(`No transform available between ${i} and ${r}`)}return n(s,void 0,s.length)}function dg(s,e,t,n){const i=Hn(e,t);return Af(s,i,void 0,n)}let fg=null;function gg(){return fg}function qn(s,e){return s}function me(s,e){return Ta&&!je(s,[0,0])&&s[0]>=-180&&s[0]<=180&&s[1]>=-90&&s[1]<=90&&(Ta=!1,jc("Call useGeographic() from ol/proj once to work with [longitude, latitude] coordinates.")),s}function to(s,e){return s}function St(s,e){return s}function _g(){Ih(Th),Ih(Rh),cg(Rh,Th,zf,$f)}_g();const Qc=new Array(6);function Te(){return[1,0,0,1,0,0]}function Lh(s){return al(s,1,0,0,1,0,0)}function no(s,e){const t=s[0],n=s[1],i=s[2],r=s[3],o=s[4],a=s[5],l=e[0],h=e[1],c=e[2],u=e[3],d=e[4],f=e[5];return s[0]=t*l+i*h,s[1]=n*l+r*h,s[2]=t*c+i*u,s[3]=n*c+r*u,s[4]=t*d+i*f+o,s[5]=n*d+r*f+a,s}function al(s,e,t,n,i,r,o){return s[0]=e,s[1]=t,s[2]=n,s[3]=i,s[4]=r,s[5]=o,s}function eu(s,e){return s[0]=e[0],s[1]=e[1],s[2]=e[2],s[3]=e[3],s[4]=e[4],s[5]=e[5],s}function de(s,e){const t=e[0],n=e[1];return e[0]=s[0]*t+s[2]*n+s[4],e[1]=s[1]*t+s[3]*n+s[5],e}function Io(s,e,t){return no(s,al(Qc,e,0,0,t,0,0))}function tu(s,e,t){return no(s,al(Qc,1,0,0,1,e,t))}function lt(s,e,t,n,i,r,o,a){const l=Math.sin(r),h=Math.cos(r);return s[0]=n*h,s[1]=i*l,s[2]=-n*l,s[3]=i*h,s[4]=o*n*h-a*n*l+e,s[5]=o*i*l+a*i*h+t,s}function Cs(s,e){const t=mg(e);te(t!==0,"Transformation matrix cannot be inverted");const n=e[0],i=e[1],r=e[2],o=e[3],a=e[4],l=e[5];return s[0]=o/t,s[1]=-i/t,s[2]=-r/t,s[3]=n/t,s[4]=(r*l-o*a)/t,s[5]=-(n*l-i*a)/t,s}function mg(s){return s[0]*s[3]-s[1]*s[2]}const pg=[1e5,1e5,1e5,1e5,2,2];function yg(s){return"matrix("+s.join(", ")+")"}function Ra(s){return s.substring(7,s.length-1).split(",").map(parseFloat)}function xg(s,e){const t=Ra(s),n=Ra(e);for(let i=0;i<6;++i)if(Math.round((t[i]-n[i])*pg[i])!==0)return!1;return!0}function Nt(s,e,t,n,i,r,o){r=r||[],o=o||2;let a=0;for(let l=e;l<t;l+=n){const h=s[l],c=s[l+1];r[a++]=i[0]*h+i[2]*c+i[4],r[a++]=i[1]*h+i[3]*c+i[5];for(let u=2;u<o;u++)r[a++]=s[l+u]}return r&&r.length!=a&&(r.length=a),r}function ll(s,e,t,n,i,r,o){o=o||[];const a=Math.cos(i),l=Math.sin(i),h=r[0],c=r[1];let u=0;for(let d=e;d<t;d+=n){const f=s[d]-h,g=s[d+1]-c;o[u++]=h+f*a-g*l,o[u++]=c+f*l+g*a;for(let m=d+2;m<d+n;++m)o[u++]=s[m]}return o&&o.length!=u&&(o.length=u),o}function Eg(s,e,t,n,i,r,o,a){a=a||[];const l=o[0],h=o[1];let c=0;for(let u=e;u<t;u+=n){const d=s[u]-l,f=s[u+1]-h;a[c++]=l+i*d,a[c++]=h+r*f;for(let g=u+2;g<u+n;++g)a[c++]=s[g]}return a&&a.length!=c&&(a.length=c),a}function Tg(s,e,t,n,i,r,o){o=o||[];let a=0;for(let l=e;l<t;l+=n){o[a++]=s[l]+i,o[a++]=s[l+1]+r;for(let h=l+2;h<l+n;++h)o[a++]=s[h]}return o&&o.length!=a&&(o.length=a),o}const Ah=Te(),Cg=[NaN,NaN];class nu extends It{constructor(){super(),this.extent_=Je(),this.extentRevision_=-1,this.simplifiedGeometryMaxMinSquaredTolerance=0,this.simplifiedGeometryRevision=0,this.simplifyTransformedInternal=Mc((e,t,n)=>{if(!n)return this.getSimplifiedGeometry(t);const i=this.clone();return i.applyTransform(n),i.getSimplifiedGeometry(t)})}simplifyTransformed(e,t){return this.simplifyTransformedInternal(this.getRevision(),e,t)}clone(){return $()}closestPointXY(e,t,n,i){return $()}containsXY(e,t){return this.closestPointXY(e,t,Cg,Number.MIN_VALUE)===0}getClosestPoint(e,t){return t=t||[NaN,NaN],this.closestPointXY(e[0],e[1],t,1/0),t}intersectsCoordinate(e){return this.containsXY(e[0],e[1])}computeExtent(e){return $()}getExtent(e){if(this.extentRevision_!=this.getRevision()){const t=this.computeExtent(this.extent_);(isNaN(t[0])||isNaN(t[1]))&&Wi(t),this.extentRevision_=this.getRevision()}return Pf(this.extent_,e)}rotate(e,t){$()}scale(e,t,n){$()}simplify(e){return this.getSimplifiedGeometry(e*e)}getSimplifiedGeometry(e){return $()}getType(){return $()}applyTransform(e){$()}intersectsExtent(e){return $()}translate(e,t){$()}transform(e,t){const n=_e(e),i=n.getUnits()=="tile-pixels"?function(r,o,a){const l=n.getExtent(),h=n.getWorldExtent(),c=be(h)/be(l);lt(Ah,h[0],h[3],c,-c,0,0,0);const u=Nt(r,0,r.length,a,Ah,o),d=Hn(n,t);return d?d(u,u,a):u}:Hn(n,t);return this.applyTransform(i),this}}class Fn extends nu{constructor(){super(),this.layout="XY",this.stride=2,this.flatCoordinates}computeExtent(e){return Ha(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,e)}getCoordinates(){return $()}getFirstCoordinate(){return this.flatCoordinates.slice(0,this.stride)}getFlatCoordinates(){return this.flatCoordinates}getLastCoordinate(){return this.flatCoordinates.slice(this.flatCoordinates.length-this.stride)}getLayout(){return this.layout}getSimplifiedGeometry(e){if(this.simplifiedGeometryRevision!==this.getRevision()&&(this.simplifiedGeometryMaxMinSquaredTolerance=0,this.simplifiedGeometryRevision=this.getRevision()),e<0||this.simplifiedGeometryMaxMinSquaredTolerance!==0&&e<=this.simplifiedGeometryMaxMinSquaredTolerance)return this;const t=this.getSimplifiedGeometryInternal(e);return t.getFlatCoordinates().length<this.flatCoordinates.length?t:(this.simplifiedGeometryMaxMinSquaredTolerance=e,this)}getSimplifiedGeometryInternal(e){return this}getStride(){return this.stride}setFlatCoordinates(e,t){this.stride=Lr(e),this.layout=e,this.flatCoordinates=t}setCoordinates(e,t){$()}setLayout(e,t,n){let i;if(e)i=Lr(e);else{for(let r=0;r<n;++r){if(t.length===0){this.layout="XY",this.stride=2;return}t=t[0]}i=t.length,e=ni(i)}this.layout=e,this.stride=i}applyTransform(e){this.flatCoordinates&&(e(this.flatCoordinates,this.flatCoordinates,this.layout.startsWith("XYZ")?3:2,this.stride),this.changed())}rotate(e,t){const n=this.getFlatCoordinates();if(n){const i=this.getStride();ll(n,0,n.length,i,e,t,n),this.changed()}}scale(e,t,n){t===void 0&&(t=e),n||(n=Pn(this.getExtent()));const i=this.getFlatCoordinates();if(i){const r=this.getStride();Eg(i,0,i.length,r,e,t,n,i),this.changed()}}translate(e,t){const n=this.getFlatCoordinates();if(n){const i=this.getStride();Tg(n,0,n.length,i,e,t,n),this.changed()}}}function ni(s){let e;return s==2?e="XY":s==3?e="XYZ":s==4&&(e="XYZM"),e}function Lr(s){let e;return s=="XY"?e=2:s=="XYZ"||s=="XYM"?e=3:s=="XYZM"&&(e=4),e}function Rg(s,e,t){const n=s.getFlatCoordinates();if(!n)return null;const i=s.getStride();return Nt(n,0,n.length,i,e,t)}function iu(s,e,t,n){let i=0;const r=s[t-n],o=s[t-n+1];let a=0,l=0;for(;e<t;e+=n){const h=s[e]-r,c=s[e+1]-o;i+=l*h-a*c,a=h,l=c}return i/2}function su(s,e,t,n){let i=0;for(let r=0,o=t.length;r<o;++r){const a=t[r];i+=iu(s,e,a,n),e=a}return i}function Sg(s,e,t,n){let i=0;for(let r=0,o=t.length;r<o;++r){const a=t[r];i+=su(s,e,a,n),e=a[a.length-1]}return i}function Fh(s,e,t,n,i,r,o){const a=s[e],l=s[e+1],h=s[t]-a,c=s[t+1]-l;let u;if(h===0&&c===0)u=e;else{const d=((i-a)*h+(r-l)*c)/(h*h+c*c);if(d>1)u=t;else if(d>0){for(let f=0;f<n;++f)o[f]=it(s[e+f],s[t+f],d);o.length=n;return}else u=e}for(let d=0;d<n;++d)o[d]=s[u+d];o.length=n}function hl(s,e,t,n,i){let r=s[e],o=s[e+1];for(e+=n;e<t;e+=n){const a=s[e],l=s[e+1],h=Jt(r,o,a,l);h>i&&(i=h),r=a,o=l}return i}function cl(s,e,t,n,i){for(let r=0,o=t.length;r<o;++r){const a=t[r];i=hl(s,e,a,n,i),e=a}return i}function vg(s,e,t,n,i){for(let r=0,o=t.length;r<o;++r){const a=t[r];i=cl(s,e,a,n,i),e=a[a.length-1]}return i}function ul(s,e,t,n,i,r,o,a,l,h,c){if(e==t)return h;let u,d;if(i===0){if(d=Jt(o,a,s[e],s[e+1]),d<h){for(u=0;u<n;++u)l[u]=s[e+u];return l.length=n,d}return h}c=c||[NaN,NaN];let f=e+n;for(;f<t;)if(Fh(s,f-n,f,n,o,a,c),d=Jt(o,a,c[0],c[1]),d<h){for(h=d,u=0;u<n;++u)l[u]=c[u];l.length=n,f+=n}else f+=n*Math.max((Math.sqrt(d)-Math.sqrt(h))/i|0,1);if(r&&(Fh(s,t-n,e,n,o,a,c),d=Jt(o,a,c[0],c[1]),d<h)){for(h=d,u=0;u<n;++u)l[u]=c[u];l.length=n}return h}function dl(s,e,t,n,i,r,o,a,l,h,c){c=c||[NaN,NaN];for(let u=0,d=t.length;u<d;++u){const f=t[u];h=ul(s,e,f,n,i,r,o,a,l,h,c),e=f}return h}function wg(s,e,t,n,i,r,o,a,l,h,c){c=c||[NaN,NaN];for(let u=0,d=t.length;u<d;++u){const f=t[u];h=dl(s,e,f,n,i,r,o,a,l,h,c),e=f[f.length-1]}return h}function ru(s,e,t,n){for(let i=0,r=t.length;i<r;++i)s[e++]=t[i];return e}function io(s,e,t,n){for(let i=0,r=t.length;i<r;++i){const o=t[i];for(let a=0;a<n;++a)s[e++]=o[a]}return e}function Gs(s,e,t,n,i){i=i||[];let r=0;for(let o=0,a=t.length;o<a;++o){const l=io(s,e,t[o],n);i[r++]=l,e=l}return i.length=r,i}function ou(s,e,t,n,i){i=i||[];let r=0;for(let o=0,a=t.length;o<a;++o){const l=Gs(s,e,t[o],n,i[r]);l.length===0&&(l[0]=e),i[r++]=l,e=l[l.length-1]}return i.length=r,i}function yn(s,e,t,n,i){i=i!==void 0?i:[];let r=0;for(let o=e;o<t;o+=n)i[r++]=s.slice(o,o+n);return i.length=r,i}function Rs(s,e,t,n,i){i=i!==void 0?i:[];let r=0;for(let o=0,a=t.length;o<a;++o){const l=t[o];i[r++]=yn(s,e,l,n,i[r]),e=l}return i.length=r,i}function Sa(s,e,t,n,i){i=i!==void 0?i:[];let r=0;for(let o=0,a=t.length;o<a;++o){const l=t[o];i[r++]=l.length===1&&l[0]===e?[]:Rs(s,e,l,n,i[r]),e=l[l.length-1]}return i.length=r,i}function so(s,e,t,n,i,r,o){const a=(t-e)/n;if(a<3){for(;e<t;e+=n)r[o++]=s[e],r[o++]=s[e+1];return o}const l=new Array(a);l[0]=1,l[a-1]=1;const h=[e,t-n];let c=0;for(;h.length>0;){const u=h.pop(),d=h.pop();let f=0;const g=s[d],m=s[d+1],_=s[u],p=s[u+1];for(let y=d+n;y<u;y+=n){const E=s[y],x=s[y+1],T=Tf(E,x,g,m,_,p);T>f&&(c=y,f=T)}f>i&&(l[(c-e)/n]=1,d+n<c&&h.push(d,c),c+n<u&&h.push(c,u))}for(let u=0;u<a;++u)l[u]&&(r[o++]=s[e+u*n],r[o++]=s[e+u*n+1]);return o}function au(s,e,t,n,i,r,o,a){for(let l=0,h=t.length;l<h;++l){const c=t[l];o=so(s,e,c,n,i,r,o),a.push(o),e=c}return o}function Gn(s,e){return e*Math.round(s/e)}function Pg(s,e,t,n,i,r,o){if(e==t)return o;let a=Gn(s[e],i),l=Gn(s[e+1],i);e+=n,r[o++]=a,r[o++]=l;let h,c;do if(h=Gn(s[e],i),c=Gn(s[e+1],i),e+=n,e==t)return r[o++]=h,r[o++]=c,o;while(h==a&&c==l);for(;e<t;){const u=Gn(s[e],i),d=Gn(s[e+1],i);if(e+=n,u==h&&d==c)continue;const f=h-a,g=c-l,m=u-a,_=d-l;if(f*_==g*m&&(f<0&&m<f||f==m||f>0&&m>f)&&(g<0&&_<g||g==_||g>0&&_>g)){h=u,c=d;continue}r[o++]=h,r[o++]=c,a=h,l=c,h=u,c=d}return r[o++]=h,r[o++]=c,o}function fl(s,e,t,n,i,r,o,a){for(let l=0,h=t.length;l<h;++l){const c=t[l];o=Pg(s,e,c,n,i,r,o),a.push(o),e=c}return o}function Ig(s,e,t,n,i,r,o,a){for(let l=0,h=t.length;l<h;++l){const c=t[l],u=[];o=fl(s,e,c,n,i,r,o,u),a.push(u),e=c[c.length-1]}return o}class Ss extends Fn{constructor(e,t){super(),this.maxDelta_=-1,this.maxDeltaRevision_=-1,t!==void 0&&!Array.isArray(e[0])?this.setFlatCoordinates(t,e):this.setCoordinates(e,t)}clone(){return new Ss(this.flatCoordinates.slice(),this.layout)}closestPointXY(e,t,n,i){return i<ei(this.getExtent(),e,t)?i:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(hl(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),ul(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,this.maxDelta_,!0,e,t,n,i))}getArea(){return iu(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getCoordinates(){return yn(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getSimplifiedGeometryInternal(e){const t=[];return t.length=so(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,e,t,0),new Ss(t,"XY")}getType(){return"LinearRing"}intersectsExtent(e){return!1}setCoordinates(e,t){this.setLayout(t,e,1),this.flatCoordinates||(this.flatCoordinates=[]),this.flatCoordinates.length=io(this.flatCoordinates,0,e,this.stride),this.changed()}}class ot extends Fn{constructor(e,t){super(),this.setCoordinates(e,t)}clone(){const e=new ot(this.flatCoordinates.slice(),this.layout);return e.applyProperties(this),e}closestPointXY(e,t,n,i){const r=this.flatCoordinates,o=Jt(e,t,r[0],r[1]);if(o<i){const a=this.stride;for(let l=0;l<a;++l)n[l]=r[l];return n.length=a,o}return i}getCoordinates(){return this.flatCoordinates.slice()}computeExtent(e){return ds(this.flatCoordinates,e)}getType(){return"Point"}intersectsExtent(e){return Ka(e,this.flatCoordinates[0],this.flatCoordinates[1])}setCoordinates(e,t){this.setLayout(t,e,0),this.flatCoordinates||(this.flatCoordinates=[]),this.flatCoordinates.length=ru(this.flatCoordinates,0,e,this.stride),this.changed()}}function Lg(s,e,t,n,i){return!qa(i,function(o){return!Bn(s,e,t,n,o[0],o[1])})}function Bn(s,e,t,n,i,r){let o=0,a=s[t-n],l=s[t-n+1];for(;e<t;e+=n){const h=s[e],c=s[e+1];l<=r?c>r&&(h-a)*(r-l)-(i-a)*(c-l)>0&&o++:c<=r&&(h-a)*(r-l)-(i-a)*(c-l)<0&&o--,a=h,l=c}return o!==0}function gl(s,e,t,n,i,r){if(t.length===0||!Bn(s,e,t[0],n,i,r))return!1;for(let o=1,a=t.length;o<a;++o)if(Bn(s,t[o-1],t[o],n,i,r))return!1;return!0}function Ag(s,e,t,n,i,r){if(t.length===0)return!1;for(let o=0,a=t.length;o<a;++o){const l=t[o];if(gl(s,e,l,n,i,r))return!0;e=l[l.length-1]}return!1}function _l(s,e,t,n,i,r,o){let a,l,h,c,u,d,f;const g=i[r+1],m=[];for(let y=0,E=t.length;y<E;++y){const x=t[y];for(c=s[x-n],d=s[x-n+1],a=e;a<x;a+=n)u=s[a],f=s[a+1],(g<=d&&f<=g||d<=g&&g<=f)&&(h=(g-d)/(f-d)*(u-c)+c,m.push(h)),c=u,d=f}let _=NaN,p=-1/0;for(m.sort(Ot),c=m[0],a=1,l=m.length;a<l;++a){u=m[a];const y=Math.abs(u-c);y>p&&(h=(c+u)/2,gl(s,e,t,n,h,g)&&(_=h,p=y)),c=u}return isNaN(_)&&(_=i[r]),o?(o.push(_,g,p),o):[_,g,p]}function lu(s,e,t,n,i){let r=[];for(let o=0,a=t.length;o<a;++o){const l=t[o];r=_l(s,e,l,n,i,2*o,r),e=l[l.length-1]}return r}function hu(s,e,t,n,i){let r;for(e+=n;e<t;e+=n)if(r=i(s.slice(e-n,e),s.slice(e,e+n)),r)return r;return!1}function ro(s,e,t,n,i,r){return r=r??Bc(Je(),s,e,t,n),Ee(i,r)?r[0]>=i[0]&&r[2]<=i[2]||r[1]>=i[1]&&r[3]<=i[3]?!0:hu(s,e,t,n,function(o,a){return Lf(i,o,a)}):!1}function Fg(s,e,t,n,i){for(let r=0,o=t.length;r<o;++r){if(ro(s,e,t[r],n,i))return!0;e=t[r]}return!1}function cu(s,e,t,n,i){return!!(ro(s,e,t,n,i)||Bn(s,e,t,n,i[0],i[1])||Bn(s,e,t,n,i[0],i[3])||Bn(s,e,t,n,i[2],i[1])||Bn(s,e,t,n,i[2],i[3]))}function uu(s,e,t,n,i){if(!cu(s,e,t[0],n,i))return!1;if(t.length===1)return!0;for(let r=1,o=t.length;r<o;++r)if(Lg(s,t[r-1],t[r],n,i)&&!ro(s,t[r-1],t[r],n,i))return!1;return!0}function bg(s,e,t,n,i){for(let r=0,o=t.length;r<o;++r){const a=t[r];if(uu(s,e,a,n,i))return!0;e=a[a.length-1]}return!1}function Mg(s,e,t,n){for(;e<t-n;){for(let i=0;i<n;++i){const r=s[e+i];s[e+i]=s[t-n+i],s[t-n+i]=r}e+=n,t-=n}}function ml(s,e,t,n){let i=0,r=s[t-n],o=s[t-n+1];for(;e<t;e+=n){const a=s[e],l=s[e+1];i+=(a-r)*(l+o),r=a,o=l}return i===0?void 0:i>0}function pl(s,e,t,n,i){i=i!==void 0?i:!1;for(let r=0,o=t.length;r<o;++r){const a=t[r],l=ml(s,e,a,n);if(r===0){if(i&&l||!i&&!l)return!1}else if(i&&!l||!i&&l)return!1;e=a}return!0}function du(s,e,t,n,i){for(let r=0,o=t.length;r<o;++r){const a=t[r];if(!pl(s,e,a,n,i))return!1;a.length&&(e=a[a.length-1])}return!0}function Ar(s,e,t,n,i){i=i!==void 0?i:!1;for(let r=0,o=t.length;r<o;++r){const a=t[r],l=ml(s,e,a,n);(r===0?i&&l||!i&&!l:i&&!l||!i&&l)&&Mg(s,e,a,n),e=a}return e}function va(s,e,t,n,i){for(let r=0,o=t.length;r<o;++r)e=Ar(s,e,t[r],n,i);return e}function fu(s,e){const t=[];let n=0,i=0,r;for(let o=0,a=e.length;o<a;++o){const l=e[o],h=ml(s,n,l,2);if(r===void 0&&(r=h),h===r)t.push(e.slice(i,o+1));else{if(t.length===0)continue;t[t.length-1].push(e[i])}i=o+1,n=l}return t}class Qe extends Fn{constructor(e,t,n){super(),this.ends_=[],this.flatInteriorPointRevision_=-1,this.flatInteriorPoint_=null,this.maxDelta_=-1,this.maxDeltaRevision_=-1,this.orientedRevision_=-1,this.orientedFlatCoordinates_=null,t!==void 0&&n?(this.setFlatCoordinates(t,e),this.ends_=n):this.setCoordinates(e,t)}appendLinearRing(e){this.flatCoordinates?se(this.flatCoordinates,e.getFlatCoordinates()):this.flatCoordinates=e.getFlatCoordinates().slice(),this.ends_.push(this.flatCoordinates.length),this.changed()}clone(){const e=new Qe(this.flatCoordinates.slice(),this.layout,this.ends_.slice());return e.applyProperties(this),e}closestPointXY(e,t,n,i){return i<ei(this.getExtent(),e,t)?i:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(cl(this.flatCoordinates,0,this.ends_,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),dl(this.flatCoordinates,0,this.ends_,this.stride,this.maxDelta_,!0,e,t,n,i))}containsXY(e,t){return gl(this.getOrientedFlatCoordinates(),0,this.ends_,this.stride,e,t)}getArea(){return su(this.getOrientedFlatCoordinates(),0,this.ends_,this.stride)}getCoordinates(e){let t;return e!==void 0?(t=this.getOrientedFlatCoordinates().slice(),Ar(t,0,this.ends_,this.stride,e)):t=this.flatCoordinates,Rs(t,0,this.ends_,this.stride)}getEnds(){return this.ends_}getFlatInteriorPoint(){if(this.flatInteriorPointRevision_!=this.getRevision()){const e=Pn(this.getExtent());this.flatInteriorPoint_=_l(this.getOrientedFlatCoordinates(),0,this.ends_,this.stride,e,0),this.flatInteriorPointRevision_=this.getRevision()}return this.flatInteriorPoint_}getInteriorPoint(){return new ot(this.getFlatInteriorPoint(),"XYM")}getLinearRingCount(){return this.ends_.length}getLinearRing(e){return e<0||this.ends_.length<=e?null:new Ss(this.flatCoordinates.slice(e===0?0:this.ends_[e-1],this.ends_[e]),this.layout)}getLinearRings(){const e=this.layout,t=this.flatCoordinates,n=this.ends_,i=[];let r=0;for(let o=0,a=n.length;o<a;++o){const l=n[o],h=new Ss(t.slice(r,l),e);i.push(h),r=l}return i}getOrientedFlatCoordinates(){if(this.orientedRevision_!=this.getRevision()){const e=this.flatCoordinates;pl(e,0,this.ends_,this.stride)?this.orientedFlatCoordinates_=e:(this.orientedFlatCoordinates_=e.slice(),this.orientedFlatCoordinates_.length=Ar(this.orientedFlatCoordinates_,0,this.ends_,this.stride)),this.orientedRevision_=this.getRevision()}return this.orientedFlatCoordinates_}getSimplifiedGeometryInternal(e){const t=[],n=[];return t.length=fl(this.flatCoordinates,0,this.ends_,this.stride,Math.sqrt(e),t,0,n),new Qe(t,"XY",n)}getType(){return"Polygon"}intersectsExtent(e){return uu(this.getOrientedFlatCoordinates(),0,this.ends_,this.stride,e)}setCoordinates(e,t){this.setLayout(t,e,2),this.flatCoordinates||(this.flatCoordinates=[]);const n=Gs(this.flatCoordinates,0,e,this.stride,this.ends_);this.flatCoordinates.length=n.length===0?0:n[n.length-1],this.changed()}}function bh(s){if(ti(s))throw new Error("Cannot create polygon from empty extent");const e=s[0],t=s[1],n=s[2],i=s[3],r=[e,t,e,i,n,i,n,t,e,t];return new Qe(r,"XY",[r.length])}function R0(s,e,t){e=e||32;const n=s.getStride(),i=s.getLayout(),r=s.getCenter(),o=n*(e+1),a=new Array(o);for(let c=0;c<o;c+=n){a[c]=0,a[c+1]=0;for(let u=2;u<n;u++)a[c+u]=r[u]}const l=[a.length],h=new Qe(a,i,l);return Dg(h,r,s.getRadius(),t),h}function Dg(s,e,t,n){const i=s.getFlatCoordinates(),r=s.getStride(),o=i.length/r-1,a=n||0;for(let l=0;l<=o;++l){const h=l*r,c=a+Qt(l,o)*2*Math.PI/o;i[h]=e[0]+t*Math.cos(c),i[h+1]=e[1]+t*Math.sin(c)}s.changed()}function yl(s,e,t,n){const i=ne(e)/t[0],r=be(e)/t[1];return n?Math.min(s,Math.max(i,r)):Math.min(s,Math.min(i,r))}function xl(s,e,t){let n=Math.min(s,e);const i=50;return n*=Math.log(1+i*Math.max(0,s/e-1))/i+1,t&&(n=Math.max(n,t),n/=Math.log(1+i*Math.max(0,t/s-1))/i+1),fe(n,t/2,e*2)}function Og(s,e,t,n){return e=e!==void 0?e:!0,(function(i,r,o,a){if(i!==void 0){const l=s[0],h=s[s.length-1],c=t?yl(l,t,o,n):l;if(a)return e?xl(i,c,h):fe(i,h,c);const u=Math.min(c,i),d=Math.floor(Za(s,u,r));return s[d]>c&&d<s.length-1?s[d+1]:s[d]}})}function Ng(s,e,t,n,i,r){return n=n!==void 0?n:!0,t=t!==void 0?t:0,(function(o,a,l,h){if(o!==void 0){const c=i?yl(e,i,l,r):e;if(h)return n?xl(o,c,t):fe(o,t,c);const u=1e-9,d=Math.ceil(Math.log(e/c)/Math.log(s)-u),f=-a*(.5-u)+.5,g=Math.min(c,o),m=Math.floor(Math.log(e/g)/Math.log(s)+f),_=Math.max(d,m),p=e/Math.pow(s,_);return fe(p,t,c)}})}function Mh(s,e,t,n,i){return t=t!==void 0?t:!0,(function(r,o,a,l){if(r!==void 0){const h=n?yl(s,n,a,i):s;return!t||!l?fe(r,e,h):xl(r,h,e)}})}function El(s){if(s!==void 0)return 0}function Dh(s){if(s!==void 0)return s}function Gg(s){const e=2*Math.PI/s;return(function(t,n){if(n)return t;if(t!==void 0)return t=Math.floor(t/e+.5)*e,t})}function kg(s){const e=pt(5);return(function(t,n){return n||t===void 0?t:Math.abs(t)<=e?0:t})}const Ug=42,Tl=256,Lo=0;class qt extends It{constructor(e){super(),this.on,this.once,this.un,e=Object.assign({},e),this.hints_=[0,0],this.animations_=[],this.updateAnimationKey_,this.projection_=ol(e.projection,"EPSG:3857"),this.viewportSize_=[100,100],this.targetCenter_=null,this.targetResolution_,this.targetRotation_,this.nextCenter_=null,this.nextResolution_,this.nextRotation_,this.cancelAnchor_=void 0,e.projection&&Jc(),e.center&&(e.center=me(e.center,this.projection_)),e.extent&&(e.extent=St(e.extent,this.projection_)),this.applyOptions_(e)}applyOptions_(e){const t=Object.assign({},e);for(const a in Rt)delete t[a];this.setProperties(t,!0);const n=zg(e);this.maxResolution_=n.maxResolution,this.minResolution_=n.minResolution,this.zoomFactor_=n.zoomFactor,this.resolutions_=e.resolutions,this.padding_=e.padding,this.minZoom_=n.minZoom;const i=Bg(e),r=n.constraint,o=$g(e);this.constraints_={center:i,resolution:r,rotation:o},this.setRotation(e.rotation!==void 0?e.rotation:0),this.setCenterInternal(e.center!==void 0?e.center:null),e.resolution!==void 0?this.setResolution(e.resolution):e.zoom!==void 0&&this.setZoom(e.zoom)}get padding(){return this.padding_}set padding(e){let t=this.padding_;this.padding_=e;const n=this.getCenterInternal();if(n){const i=e||[0,0,0,0];t=t||[0,0,0,0];const r=this.getResolution(),o=r/2*(i[3]-t[3]+t[1]-i[1]),a=r/2*(i[0]-t[0]+t[2]-i[2]);this.setCenterInternal([n[0]+o,n[1]-a])}}getUpdatedOptions_(e){const t=this.getProperties();return t.resolution!==void 0?t.resolution=this.getResolution():t.zoom=this.getZoom(),t.center=this.getCenterInternal(),t.rotation=this.getRotation(),Object.assign({},t,e)}animate(e){this.isDef()&&!this.getAnimating()&&this.resolveConstraints(0);const t=new Array(arguments.length);for(let n=0;n<t.length;++n){let i=arguments[n];i.center&&(i=Object.assign({},i),i.center=me(i.center,this.getProjection())),i.anchor&&(i=Object.assign({},i),i.anchor=me(i.anchor,this.getProjection())),t[n]=i}this.animateInternal.apply(this,t)}animateInternal(e){let t=arguments.length,n;t>1&&typeof arguments[t-1]=="function"&&(n=arguments[t-1],--t);let i=0;for(;i<t&&!this.isDef();++i){const c=arguments[i];c.center&&this.setCenterInternal(c.center),c.zoom!==void 0?this.setZoom(c.zoom):c.resolution&&this.setResolution(c.resolution),c.rotation!==void 0&&this.setRotation(c.rotation)}if(i===t){n&&Qs(n,!0);return}let r=Date.now(),o=this.targetCenter_.slice(),a=this.targetResolution_,l=this.targetRotation_;const h=[];for(;i<t;++i){const c=arguments[i],u={start:r,complete:!1,anchor:c.anchor,duration:c.duration!==void 0?c.duration:1e3,easing:c.easing||Of,callback:n};if(c.center&&(u.sourceCenter=o,u.targetCenter=c.center.slice(),o=u.targetCenter),c.zoom!==void 0?(u.sourceResolution=a,u.targetResolution=this.getResolutionForZoom(c.zoom),a=u.targetResolution):c.resolution&&(u.sourceResolution=a,u.targetResolution=c.resolution,a=u.targetResolution),c.rotation!==void 0){u.sourceRotation=l;const d=Qt(c.rotation-l+Math.PI,2*Math.PI)-Math.PI;u.targetRotation=l+d,l=u.targetRotation}Xg(u)?u.complete=!0:r+=u.duration,h.push(u)}this.animations_.push(h),this.setHint(he.ANIMATING,1),this.updateAnimations_()}getAnimating(){return this.hints_[he.ANIMATING]>0}getInteracting(){return this.hints_[he.INTERACTING]>0}cancelAnimations(){this.setHint(he.ANIMATING,-this.hints_[he.ANIMATING]);let e;for(let t=0,n=this.animations_.length;t<n;++t){const i=this.animations_[t];if(i[0].callback&&Qs(i[0].callback,!1),!e)for(let r=0,o=i.length;r<o;++r){const a=i[r];if(!a.complete){e=a.anchor;break}}}this.animations_.length=0,this.cancelAnchor_=e,this.nextCenter_=null,this.nextResolution_=NaN,this.nextRotation_=NaN}updateAnimations_(){if(this.updateAnimationKey_!==void 0&&(cancelAnimationFrame(this.updateAnimationKey_),this.updateAnimationKey_=void 0),!this.getAnimating())return;const e=Date.now();let t=!1;for(let n=this.animations_.length-1;n>=0;--n){const i=this.animations_[n];let r=!0;for(let o=0,a=i.length;o<a;++o){const l=i[o];if(l.complete)continue;const h=e-l.start;let c=l.duration>0?h/l.duration:1;c>=1?(l.complete=!0,c=1):r=!1;const u=l.easing(c);if(l.sourceCenter){const d=l.sourceCenter[0],f=l.sourceCenter[1],g=l.targetCenter[0],m=l.targetCenter[1];this.nextCenter_=l.targetCenter;const _=d+u*(g-d),p=f+u*(m-f);this.targetCenter_=[_,p]}if(l.sourceResolution&&l.targetResolution){const d=u===1?l.targetResolution:l.sourceResolution+u*(l.targetResolution-l.sourceResolution);if(l.anchor){const f=this.getViewportSize_(this.getRotation()),g=this.constraints_.resolution(d,0,f,!0);this.targetCenter_=this.calculateCenterZoom(g,l.anchor)}this.nextResolution_=l.targetResolution,this.targetResolution_=d,this.applyTargetState_(!0)}if(l.sourceRotation!==void 0&&l.targetRotation!==void 0){const d=u===1?Qt(l.targetRotation+Math.PI,2*Math.PI)-Math.PI:l.sourceRotation+u*(l.targetRotation-l.sourceRotation);if(l.anchor){const f=this.constraints_.rotation(d,!0);this.targetCenter_=this.calculateCenterRotate(f,l.anchor)}this.nextRotation_=l.targetRotation,this.targetRotation_=d}if(this.applyTargetState_(!0),t=!0,!l.complete)break}if(r){this.animations_[n]=null,this.setHint(he.ANIMATING,-1),this.nextCenter_=null,this.nextResolution_=NaN,this.nextRotation_=NaN;const o=i[0].callback;o&&Qs(o,!0)}}this.animations_=this.animations_.filter(Boolean),t&&this.updateAnimationKey_===void 0&&(this.updateAnimationKey_=requestAnimationFrame(this.updateAnimations_.bind(this)))}calculateCenterRotate(e,t){let n;const i=this.getCenterInternal();return i!==void 0&&(n=[i[0]-t[0],i[1]-t[1]],Qa(n,e-this.getRotation()),Ff(n,t)),n}calculateCenterZoom(e,t){let n;const i=this.getCenterInternal(),r=this.getResolution();if(i!==void 0&&r!==void 0){const o=t[0]-e*(t[0]-i[0])/r,a=t[1]-e*(t[1]-i[1])/r;n=[o,a]}return n}getViewportSize_(e){const t=this.viewportSize_;if(e){const n=t[0],i=t[1];return[Math.abs(n*Math.cos(e))+Math.abs(i*Math.sin(e)),Math.abs(n*Math.sin(e))+Math.abs(i*Math.cos(e))]}return t}setViewportSize(e){this.viewportSize_=Array.isArray(e)?e.slice():[100,100],this.getAnimating()||this.resolveConstraints(0)}getCenter(){const e=this.getCenterInternal();return e&&qn(e,this.getProjection())}getCenterInternal(){return this.get(Rt.CENTER)}getConstraints(){return this.constraints_}getConstrainResolution(){return this.get("constrainResolution")}getHints(e){return e!==void 0?(e[0]=this.hints_[0],e[1]=this.hints_[1],e):this.hints_.slice()}calculateExtent(e){const t=this.calculateExtentInternal(e);return to(t,this.getProjection())}calculateExtentInternal(e){e=e||this.getViewportSizeMinusPadding_();const t=this.getCenterInternal();te(t,"The view center is not defined");const n=this.getResolution();te(n!==void 0,"The view resolution is not defined");const i=this.getRotation();return te(i!==void 0,"The view rotation is not defined"),ya(t,n,i,e)}getMaxResolution(){return this.maxResolution_}getMinResolution(){return this.minResolution_}getMaxZoom(){return this.getZoomForResolution(this.minResolution_)}setMaxZoom(e){this.applyOptions_(this.getUpdatedOptions_({maxZoom:e}))}getMinZoom(){return this.getZoomForResolution(this.maxResolution_)}setMinZoom(e){this.applyOptions_(this.getUpdatedOptions_({minZoom:e}))}setConstrainResolution(e){this.applyOptions_(this.getUpdatedOptions_({constrainResolution:e}))}getProjection(){return this.projection_}getResolution(){return this.get(Rt.RESOLUTION)}getResolutions(){return this.resolutions_}getResolutionForExtent(e,t){return this.getResolutionForExtentInternal(St(e,this.getProjection()),t)}getResolutionForExtentInternal(e,t){t=t||this.getViewportSizeMinusPadding_();const n=ne(e)/t[0],i=be(e)/t[1];return Math.max(n,i)}getResolutionForValueFunction(e){e=e||2;const t=this.getConstrainedResolution(this.maxResolution_),n=this.minResolution_,i=Math.log(t/n)/Math.log(e);return(function(r){return t/Math.pow(e,r*i)})}getRotation(){return this.get(Rt.ROTATION)}getValueForResolutionFunction(e){const t=Math.log(e||2),n=this.getConstrainedResolution(this.maxResolution_),i=this.minResolution_,r=Math.log(n/i)/t;return(function(o){return Math.log(n/o)/t/r})}getViewportSizeMinusPadding_(e){let t=this.getViewportSize_(e);const n=this.padding_;return n&&(t=[t[0]-n[1]-n[3],t[1]-n[0]-n[2]]),t}getState(){const e=this.getProjection(),t=this.getResolution(),n=this.getRotation();let i=this.getCenterInternal();const r=this.padding_;if(r){const o=this.getViewportSizeMinusPadding_();i=Ao(i,this.getViewportSize_(),[o[0]/2+r[3],o[1]/2+r[0]],t,n)}return{center:i.slice(0),projection:e!==void 0?e:null,resolution:t,nextCenter:this.nextCenter_,nextResolution:this.nextResolution_,nextRotation:this.nextRotation_,rotation:n,zoom:this.getZoom()}}getViewStateAndExtent(){return{viewState:this.getState(),extent:this.calculateExtent()}}getZoom(){let e;const t=this.getResolution();return t!==void 0&&(e=this.getZoomForResolution(t)),e}getZoomForResolution(e){let t=this.minZoom_||0,n,i;if(this.resolutions_){const r=Za(this.resolutions_,e,1);t=r,n=this.resolutions_[r],r==this.resolutions_.length-1?i=2:i=n/this.resolutions_[r+1]}else n=this.maxResolution_,i=this.zoomFactor_;return t+Math.log(n/e)/Math.log(i)}getResolutionForZoom(e){if(this.resolutions_?.length){if(this.resolutions_.length===1)return this.resolutions_[0];const t=fe(Math.floor(e),0,this.resolutions_.length-2),n=this.resolutions_[t]/this.resolutions_[t+1];return this.resolutions_[t]/Math.pow(n,fe(e-t,0,1))}return this.maxResolution_/Math.pow(this.zoomFactor_,e-this.minZoom_)}fit(e,t){let n;if(te(Array.isArray(e)||typeof e.getSimplifiedGeometry=="function","Invalid extent or geometry provided as `geometry`"),Array.isArray(e)){te(!ti(e),"Cannot fit empty extent provided as `geometry`");const i=St(e,this.getProjection());n=bh(i)}else if(e.getType()==="Circle"){const i=St(e.getExtent(),this.getProjection());n=bh(i),n.rotate(this.getRotation(),Pn(i))}else n=e;this.fitInternal(n,t)}rotatedExtentForGeometry(e){const t=this.getRotation(),n=Math.cos(t),i=Math.sin(-t),r=e.getFlatCoordinates(),o=e.getStride();let a=1/0,l=1/0,h=-1/0,c=-1/0;for(let u=0,d=r.length;u<d;u+=o){const f=r[u]*n-r[u+1]*i,g=r[u]*i+r[u+1]*n;a=Math.min(a,f),l=Math.min(l,g),h=Math.max(h,f),c=Math.max(c,g)}return[a,l,h,c]}fitInternal(e,t){t=t||{};let n=t.size;n||(n=this.getViewportSizeMinusPadding_());const i=t.padding!==void 0?t.padding:[0,0,0,0],r=t.nearest!==void 0?t.nearest:!1;let o;t.minResolution!==void 0?o=t.minResolution:t.maxZoom!==void 0?o=this.getResolutionForZoom(t.maxZoom):o=0;const a=this.rotatedExtentForGeometry(e);let l=this.getResolutionForExtentInternal(a,[n[0]-i[1]-i[3],n[1]-i[0]-i[2]]);l=isNaN(l)?o:Math.max(l,o),l=this.getConstrainedResolution(l,r?0:1);const h=this.getRotation(),c=Math.sin(h),u=Math.cos(h),d=Pn(a);d[0]+=(i[1]-i[3])/2*l,d[1]+=(i[0]-i[2])/2*l;const f=d[0]*u-d[1]*c,g=d[1]*u+d[0]*c,m=this.getConstrainedCenter([f,g],l),_=t.callback?t.callback:Es;t.duration!==void 0?this.animateInternal({resolution:l,center:m,duration:t.duration,easing:t.easing},_):(this.targetResolution_=l,this.targetCenter_=m,this.applyTargetState_(!1,!0),Qs(_,!0))}centerOn(e,t,n){this.centerOnInternal(me(e,this.getProjection()),t,n)}centerOnInternal(e,t,n){this.setCenterInternal(Ao(e,t,n,this.getResolution(),this.getRotation()))}calculateCenterShift(e,t,n,i){let r;const o=this.padding_;if(o&&e){const a=this.getViewportSizeMinusPadding_(-n),l=Ao(e,i,[a[0]/2+o[3],a[1]/2+o[0]],t,n);r=[e[0]-l[0],e[1]-l[1]]}return r}isDef(){return!!this.getCenterInternal()&&this.getResolution()!==void 0}adjustCenter(e){const t=qn(this.targetCenter_,this.getProjection());this.setCenter([t[0]+e[0],t[1]+e[1]])}adjustCenterInternal(e){const t=this.targetCenter_;this.setCenterInternal([t[0]+e[0],t[1]+e[1]])}adjustResolution(e,t){t=t&&me(t,this.getProjection()),this.adjustResolutionInternal(e,t)}adjustResolutionInternal(e,t){const n=this.getAnimating()||this.getInteracting(),i=this.getViewportSize_(this.getRotation()),r=this.constraints_.resolution(this.targetResolution_*e,0,i,n);t&&(this.targetCenter_=this.calculateCenterZoom(r,t)),this.targetResolution_*=e,this.applyTargetState_()}adjustZoom(e,t){this.adjustResolution(Math.pow(this.zoomFactor_,-e),t)}adjustRotation(e,t){t&&(t=me(t,this.getProjection())),this.adjustRotationInternal(e,t)}adjustRotationInternal(e,t){const n=this.getAnimating()||this.getInteracting(),i=this.constraints_.rotation(this.targetRotation_+e,n);t&&(this.targetCenter_=this.calculateCenterRotate(i,t)),this.targetRotation_+=e,this.applyTargetState_()}setCenter(e){this.setCenterInternal(e&&me(e,this.getProjection()))}setCenterInternal(e){this.targetCenter_=e,this.applyTargetState_()}setHint(e,t){return this.hints_[e]+=t,this.changed(),this.hints_[e]}setResolution(e){this.targetResolution_=e,this.applyTargetState_()}setRotation(e){this.targetRotation_=e,this.applyTargetState_()}setZoom(e){this.setResolution(this.getResolutionForZoom(e))}applyTargetState_(e,t){const n=this.getAnimating()||this.getInteracting()||t,i=this.constraints_.rotation(this.targetRotation_,n),r=this.getViewportSize_(i),o=this.constraints_.resolution(this.targetResolution_,0,r,n),a=this.constraints_.center(this.targetCenter_,o,r,n,this.calculateCenterShift(this.targetCenter_,o,i,r));this.get(Rt.ROTATION)!==i&&this.set(Rt.ROTATION,i),this.get(Rt.RESOLUTION)!==o&&(this.set(Rt.RESOLUTION,o),this.set("zoom",this.getZoom(),!0)),(!a||!this.get(Rt.CENTER)||!je(this.get(Rt.CENTER),a))&&this.set(Rt.CENTER,a),this.getAnimating()&&!e&&this.cancelAnimations(),this.cancelAnchor_=void 0}resolveConstraints(e,t,n){e=e!==void 0?e:200;const i=t||0,r=this.constraints_.rotation(this.targetRotation_),o=this.getViewportSize_(r),a=this.constraints_.resolution(this.targetResolution_,i,o),l=this.constraints_.center(this.targetCenter_,a,o,!1,this.calculateCenterShift(this.targetCenter_,a,r,o));if(e===0&&!this.cancelAnchor_){this.targetResolution_=a,this.targetRotation_=r,this.targetCenter_=l,this.applyTargetState_();return}n=n||(e===0?this.cancelAnchor_:void 0),this.cancelAnchor_=void 0,(this.getResolution()!==a||this.getRotation()!==r||!this.getCenterInternal()||!je(this.getCenterInternal(),l))&&(this.getAnimating()&&this.cancelAnimations(),this.animateInternal({rotation:r,center:l,resolution:a,duration:e,easing:Yi,anchor:n}))}beginInteraction(){this.resolveConstraints(0),this.setHint(he.INTERACTING,1)}endInteraction(e,t,n){n=n&&me(n,this.getProjection()),this.endInteractionInternal(e,t,n)}endInteractionInternal(e,t,n){this.getInteracting()&&(this.setHint(he.INTERACTING,-1),this.resolveConstraints(e,t,n))}getConstrainedCenter(e,t){const n=this.getViewportSize_(this.getRotation());return this.constraints_.center(e,t||this.getResolution(),n)}getConstrainedZoom(e,t){const n=this.getResolutionForZoom(e);return this.getZoomForResolution(this.getConstrainedResolution(n,t))}getConstrainedResolution(e,t){t=t||0;const n=this.getViewportSize_(this.getRotation());return this.constraints_.resolution(e,t,n)}}function Qs(s,e){setTimeout(function(){s(e)},0)}function Bg(s){if(s.extent!==void 0){const t=s.smoothExtentConstraint!==void 0?s.smoothExtentConstraint:!0;return Eh(s.extent,s.constrainOnlyCenter,t)}const e=ol(s.projection,"EPSG:3857");if(s.multiWorld!==!0&&e.isGlobal()){const t=e.getExtent().slice();return t[0]=-1/0,t[2]=1/0,Eh(t,!1,!1)}return Rf}function zg(s){let e,t,n,o=s.minZoom!==void 0?s.minZoom:Lo,a=s.maxZoom!==void 0?s.maxZoom:28;const l=s.zoomFactor!==void 0?s.zoomFactor:2,h=s.multiWorld!==void 0?s.multiWorld:!1,c=s.smoothResolutionConstraint!==void 0?s.smoothResolutionConstraint:!0,u=s.showFullExtent!==void 0?s.showFullExtent:!1,d=ol(s.projection,"EPSG:3857"),f=d.getExtent();let g=s.constrainOnlyCenter,m=s.extent;if(!h&&!m&&d.isGlobal()&&(g=!1,m=f),s.resolutions!==void 0){const _=s.resolutions;t=_[o],n=_[a]!==void 0?_[a]:_[_.length-1],s.constrainResolution?e=Og(_,c,!g&&m,u):e=Mh(t,n,c,!g&&m,u)}else{const p=(f?Math.max(ne(f),be(f)):360*Gi.degrees/d.getMetersPerUnit())/Tl/Math.pow(2,Lo),y=p/Math.pow(2,28-Lo);t=s.maxResolution,t!==void 0?o=0:t=p/Math.pow(l,o),n=s.minResolution,n===void 0&&(s.maxZoom!==void 0?s.maxResolution!==void 0?n=t/Math.pow(l,a):n=p/Math.pow(l,a):n=y),a=o+Math.floor(Math.log(t/n)/Math.log(l)),n=t/Math.pow(l,a-o),s.constrainResolution?e=Ng(l,t,n,c,!g&&m,u):e=Mh(t,n,c,!g&&m,u)}return{constraint:e,maxResolution:t,minResolution:n,minZoom:o,zoomFactor:l}}function $g(s){if(s.enableRotation!==void 0?s.enableRotation:!0){const t=s.constrainRotation;return t===void 0||t===!0?kg():t===!1?Dh:typeof t=="number"?Gg(t):Dh}return El}function Xg(s){return!(s.sourceCenter&&s.targetCenter&&!je(s.sourceCenter,s.targetCenter)||s.sourceResolution!==s.targetResolution||s.sourceRotation!==s.targetRotation)}function Ao(s,e,t,n,i){const r=Math.cos(-i);let o=Math.sin(-i),a=s[0]*r-s[1]*o,l=s[1]*r+s[0]*o;a+=(e[0]/2-t[0])*n,l+=(t[1]-e[1]/2)*n,o=-o;const h=a*r-l*o,c=l*r+a*o;return[h,c]}const er="ol-hidden",Wg="ol-selectable",ks="ol-unselectable",Cl="ol-control",Oh="ol-collapsed",Yg=new RegExp(["^\\s*(?=(?:(?:[-a-z]+\\s*){0,2}(italic|oblique))?)","(?=(?:(?:[-a-z]+\\s*){0,2}(small-caps))?)","(?=(?:(?:[-a-z]+\\s*){0,2}(bold(?:er)?|lighter|[1-9]00 ))?)","(?:(?:normal|\\1|\\2|\\3)\\s*){0,3}((?:xx?-)?","(?:small|large)|medium|smaller|larger|[\\.\\d]+(?:\\%|in|[cem]m|ex|p[ctx]))","(?:\\s*\\/\\s*(normal|[\\.\\d]+(?:\\%|in|[cem]m|ex|p[ctx])?))",`?\\s*([-,\\"\\'\\sa-z0-9]+?)\\s*$`].join(""),"i"),Nh=["style","variant","weight","size","lineHeight","family"],wa={normal:400,bold:700},Pa=function(s){const e=s.match(Yg);if(!e)return null;const t={lineHeight:"normal",size:"1.2em",style:"normal",weight:"400",variant:"normal"};for(let n=0,i=Nh.length;n<i;++n){const r=e[n+1];r!==void 0&&(t[Nh[n]]=typeof r=="string"?r.trim():r)}return isNaN(Number(t.weight))&&t.weight in wa&&(t.weight=wa[t.weight]),t.families=t.family.split(/,\s?/).map(n=>n.trim().replace(/^['"]|['"]$/g,"")),t};function ve(s,e,t,n){let i;return t&&t.length?i=t.shift():rt?i=new class extends OffscreenCanvas{style={}}(s??300,e??150):i=document.createElement("canvas"),s&&(i.width=s),e&&(i.height=e),i.getContext("2d",n)}let Fo;function Fr(){return Fo||(Fo=ve(1,1)),Fo}function oo(s){const e=s.canvas;e.width=1,e.height=1,s.clearRect(0,0,1,1)}function jg(s){let e=s.offsetWidth;const t=getComputedStyle(s);return e+=parseInt(t.marginLeft,10)+parseInt(t.marginRight,10),e}function Vg(s){let e=s.offsetHeight;const t=getComputedStyle(s);return e+=parseInt(t.marginTop,10)+parseInt(t.marginBottom,10),e}function Gh(s,e){const t=e.parentNode;t&&t.replaceChild(s,e)}function gu(s){for(;s.lastChild;)s.lastChild.remove()}function Zg(s,e){const t=s.childNodes;for(let n=0;;++n){const i=t[n],r=e[n];if(!i&&!r)break;if(i!==r){if(!i){s.appendChild(r);continue}if(!r){s.removeChild(i),--n;continue}s.insertBefore(r,i)}}}function _u(){return new Proxy({childNodes:[],appendChild:function(e){return this.childNodes.push(e),e},remove:function(){},removeChild:function(e){const t=this.childNodes.indexOf(e);if(t===-1)throw new Error("Node to remove was not found");return this.childNodes.splice(t,1),e},insertBefore:function(e,t){const n=this.childNodes.indexOf(t);if(n===-1)throw new Error("Reference node not found");return this.childNodes.splice(n,0,e),e},style:{}},{get(e,t,n){return t==="firstElementChild"?e.childNodes.length>0?e.childNodes[0]:null:Reflect.get(e,t,n)}})}function xn(s){return typeof HTMLCanvasElement<"u"&&s instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&s instanceof OffscreenCanvas}class ao extends It{constructor(e){super();const t=e.element;t&&!e.target&&!t.style.pointerEvents&&(t.style.pointerEvents="auto"),this.element=t||null,this.target_=null,this.map_=null,this.listenerKeys=[],e.render&&(this.render=e.render),e.target&&this.setTarget(e.target)}disposeInternal(){this.element?.remove(),super.disposeInternal()}getMap(){return this.map_}setMap(e){this.map_&&this.element?.remove();for(let t=0,n=this.listenerKeys.length;t<n;++t)ue(this.listenerKeys[t]);if(this.listenerKeys.length=0,this.map_=e,e){const t=this.target_??e.getOverlayContainerStopEvent();this.element&&t.appendChild(this.element),this.render!==Es&&this.listenerKeys.push(J(e,Zt.POSTRENDER,this.render,this)),e.render()}}render(e){}setTarget(e){this.target_=typeof e=="string"?document.getElementById(e):e}}class Kg extends ao{constructor(e){e=e||{},super({element:document.createElement("div"),render:e.render,target:e.target}),this.ulElement_=document.createElement("ul"),this.collapsed_=e.collapsed!==void 0?e.collapsed:!0,this.userCollapsed_=this.collapsed_,this.overrideCollapsible_=e.collapsible!==void 0,this.collapsible_=e.collapsible!==void 0?e.collapsible:!0,this.collapsible_||(this.collapsed_=!1),this.attributions_=e.attributions;const t=e.className!==void 0?e.className:"ol-attribution",n=e.tipLabel!==void 0?e.tipLabel:"Attributions",i=e.expandClassName!==void 0?e.expandClassName:t+"-expand",r=e.collapseLabel!==void 0?e.collapseLabel:"›",o=e.collapseClassName!==void 0?e.collapseClassName:t+"-collapse";typeof r=="string"?(this.collapseLabel_=document.createElement("span"),this.collapseLabel_.textContent=r,this.collapseLabel_.className=o):this.collapseLabel_=r;const a=e.label!==void 0?e.label:"i";typeof a=="string"?(this.label_=document.createElement("span"),this.label_.textContent=a,this.label_.className=i):this.label_=a;const l=this.collapsible_&&!this.collapsed_?this.collapseLabel_:this.label_;this.toggleButton_=document.createElement("button"),this.toggleButton_.setAttribute("type","button"),this.toggleButton_.setAttribute("aria-expanded",String(!this.collapsed_)),this.toggleButton_.title=n,this.toggleButton_.appendChild(l),this.toggleButton_.addEventListener(V.CLICK,this.handleClick_.bind(this),!1);const h=t+" "+ks+" "+Cl+(this.collapsed_&&this.collapsible_?" "+Oh:"")+(this.collapsible_?"":" ol-uncollapsible"),c=this.element;c.className=h,c.appendChild(this.toggleButton_),c.appendChild(this.ulElement_),this.renderedAttributions_=[],this.renderedVisible_=!0}collectSourceAttributions_(e){const t=this.getMap().getAllLayers(),n=new Set(t.flatMap(i=>i.getAttributions(e)));if(this.attributions_!==void 0&&(Array.isArray(this.attributions_)?this.attributions_.forEach(i=>n.add(i)):n.add(this.attributions_)),!this.overrideCollapsible_){const i=!t.some(r=>r.getSource()?.getAttributionsCollapsible()===!1);this.setCollapsible(i)}return Array.from(n)}async updateElement_(e){if(!e){this.renderedVisible_&&(this.element.style.display="none",this.renderedVisible_=!1);return}const t=await Promise.all(this.collectSourceAttributions_(e).map(i=>Dc(()=>i))),n=t.length>0;if(this.renderedVisible_!=n&&(this.element.style.display=n?"":"none",this.renderedVisible_=n),!Ut(t,this.renderedAttributions_)){gu(this.ulElement_);for(let i=0,r=t.length;i<r;++i){const o=document.createElement("li");o.innerHTML=t[i],this.ulElement_.appendChild(o)}this.renderedAttributions_=t}}handleClick_(e){e.preventDefault(),this.handleToggle_(),this.userCollapsed_=this.collapsed_}handleToggle_(){this.element.classList.toggle(Oh),this.collapsed_?Gh(this.collapseLabel_,this.label_):Gh(this.label_,this.collapseLabel_),this.collapsed_=!this.collapsed_,this.toggleButton_.setAttribute("aria-expanded",String(!this.collapsed_))}getCollapsible(){return this.collapsible_}setCollapsible(e){this.collapsible_!==e&&(this.collapsible_=e,this.element.classList.toggle("ol-uncollapsible"),this.userCollapsed_&&this.handleToggle_())}setCollapsed(e){this.userCollapsed_=e,!(!this.collapsible_||this.collapsed_===e)&&this.handleToggle_()}getCollapsed(){return this.collapsed_}render(e){this.updateElement_(e.frameState)}}class Hg extends ao{constructor(e){e=e||{},super({element:document.createElement("div"),render:e.render,target:e.target});const t=e.className!==void 0?e.className:"ol-rotate",n=e.label!==void 0?e.label:"⇧",i=e.compassClassName!==void 0?e.compassClassName:"ol-compass";this.label_=null,typeof n=="string"?(this.label_=document.createElement("span"),this.label_.className=i,this.label_.textContent=n):(this.label_=n,this.label_.classList.add(i));const r=e.tipLabel?e.tipLabel:"Reset rotation",o=document.createElement("button");o.className=t+"-reset",o.setAttribute("type","button"),o.title=r,o.appendChild(this.label_),o.addEventListener(V.CLICK,this.handleClick_.bind(this),!1);const a=t+" "+ks+" "+Cl,l=this.element;l.className=a,l.appendChild(o),this.callResetNorth_=e.resetNorth?e.resetNorth:void 0,this.duration_=e.duration!==void 0?e.duration:250,this.autoHide_=e.autoHide!==void 0?e.autoHide:!0,this.rotation_=void 0,this.autoHide_&&this.element.classList.add(er)}handleClick_(e){e.preventDefault(),this.callResetNorth_!==void 0?this.callResetNorth_():this.resetNorth_()}resetNorth_(){const t=this.getMap().getView();if(!t)return;const n=t.getRotation();n!==void 0&&(this.duration_>0&&n%(2*Math.PI)!==0?t.animate({rotation:0,duration:this.duration_,easing:Yi}):t.setRotation(0))}render(e){const t=e.frameState;if(!t)return;const n=t.viewState.rotation;if(n!=this.rotation_){const i="rotate("+n+"rad)";if(this.autoHide_){const r=this.element.classList.contains(er);!r&&n===0?this.element.classList.add(er):r&&n!==0&&this.element.classList.remove(er)}this.label_.style.transform=i}this.rotation_=n}}class qg extends ao{constructor(e){e=e||{},super({element:document.createElement("div"),target:e.target});const t=e.className!==void 0?e.className:"ol-zoom",n=e.delta!==void 0?e.delta:1,i=e.zoomInClassName!==void 0?e.zoomInClassName:t+"-in",r=e.zoomOutClassName!==void 0?e.zoomOutClassName:t+"-out",o=e.zoomInLabel!==void 0?e.zoomInLabel:"+",a=e.zoomOutLabel!==void 0?e.zoomOutLabel:"–",l=e.zoomInTipLabel!==void 0?e.zoomInTipLabel:"Zoom in",h=e.zoomOutTipLabel!==void 0?e.zoomOutTipLabel:"Zoom out",c=document.createElement("button");c.className=i,c.setAttribute("type","button"),c.title=l,c.appendChild(typeof o=="string"?document.createTextNode(o):o),c.addEventListener(V.CLICK,this.handleClick_.bind(this,n),!1);const u=document.createElement("button");u.className=r,u.setAttribute("type","button"),u.title=h,u.appendChild(typeof a=="string"?document.createTextNode(a):a),u.addEventListener(V.CLICK,this.handleClick_.bind(this,-n),!1);const d=t+" "+ks+" "+Cl,f=this.element;f.className=d,f.appendChild(c),f.appendChild(u),this.duration_=e.duration!==void 0?e.duration:250}handleClick_(e,t){t.preventDefault(),this.zoomByDelta_(e)}zoomByDelta_(e){const n=this.getMap().getView();if(!n)return;const i=n.getZoom();if(i!==void 0){const r=n.getConstrainedZoom(i+e);this.duration_>0?(n.getAnimating()&&n.cancelAnimations(),n.animate({zoom:r,duration:this.duration_,easing:Yi})):n.setZoom(r)}}}function Jg(s){s=s||{};const e=new Ve;return(s.zoom!==void 0?s.zoom:!0)&&e.push(new qg(s.zoomOptions)),(s.rotate!==void 0?s.rotate:!0)&&e.push(new Hg(s.rotateOptions)),(s.attribution!==void 0?s.attribution:!0)&&e.push(new Kg(s.attributionOptions)),e}class Qg{constructor(e,t,n){this.decay_=e,this.minVelocity_=t,this.delay_=n,this.points_=[],this.angle_=0,this.initialVelocity_=0}begin(){this.points_.length=0,this.angle_=0,this.initialVelocity_=0}update(e,t){this.points_.push(e,t,Date.now())}end(){if(this.points_.length<6)return!1;const e=Date.now()-this.delay_,t=this.points_.length-3;if(this.points_[t+2]<e)return!1;let n=t-3;for(;n>0&&this.points_[n+2]>e;)n-=3;const i=this.points_[t+2]-this.points_[n+2];if(i<1e3/60)return!1;const r=this.points_[t]-this.points_[n],o=this.points_[t+1]-this.points_[n+1];return this.angle_=Math.atan2(o,r),this.initialVelocity_=Math.sqrt(r*r+o*o)/i,this.initialVelocity_>this.minVelocity_}getDistance(){return(this.minVelocity_-this.initialVelocity_)/this.decay_}getAngle(){return this.angle_}}const Ia={ACTIVE:"active"};class ji extends It{constructor(e){super(),this.on,this.once,this.un,e&&e.handleEvent&&(this.handleEvent=e.handleEvent),this.map_=null,this.setActive(!0)}getActive(){return this.get(Ia.ACTIVE)}getMap(){return this.map_}handleEvent(e){return!0}setActive(e){this.set(Ia.ACTIVE,e)}setMap(e){this.map_=e}}function e_(s,e,t){const n=s.getCenterInternal();if(n){const i=[n[0]+e[0],n[1]+e[1]];s.animateInternal({duration:t!==void 0?t:250,easing:Nf,center:s.getConstrainedCenter(i)})}}function Rl(s,e,t,n){const i=s.getZoom();if(i===void 0)return;const r=s.getConstrainedZoom(i+e),o=s.getResolutionForZoom(r);s.getAnimating()&&s.cancelAnimations(),s.animate({resolution:o,anchor:t,duration:n!==void 0?n:250,easing:Yi})}class t_ extends ji{constructor(e){super(),e=e||{},this.delta_=e.delta?e.delta:1,this.duration_=e.duration!==void 0?e.duration:250}handleEvent(e){let t=!1;if(e.type==ee.DBLCLICK){const n=e.originalEvent,i=e.map,r=e.coordinate,o=n.shiftKey?-this.delta_:this.delta_,a=i.getView();Rl(a,o,r,this.duration_),n.preventDefault(),t=!0}return!t}}function La(s){const e=arguments;return function(t){let n=!0;for(let i=0,r=e.length;i<r&&(n=n&&e[i](t),!!n);++i);return n}}const n_=function(s){const e=s.originalEvent;return e.altKey&&!(e.metaKey||e.ctrlKey)&&!e.shiftKey},i_=function(s){const e=s.originalEvent;return e.altKey&&!(e.metaKey||e.ctrlKey)&&e.shiftKey},s_=function(s){const e=s.map.getTargetElement(),t=e.getRootNode(),n=s.map.getOwnerDocument().activeElement;return t instanceof ShadowRoot?t.host.contains(n):e.contains(n)},mu=function(s){const e=s.map.getTargetElement(),t=e.getRootNode();return(t instanceof ShadowRoot?t.host:e).hasAttribute("tabindex")?s_(s):!0},Li=wn,S0=function(s){return s.type==ee.CLICK},pu=function(s){const e=s.originalEvent;return"pointerId"in e&&e.button==0&&!(gf&&Oc&&e.ctrlKey)},br=$i,yu=function(s){return s.type==ee.SINGLECLICK},Sl=function(s){const e=s.originalEvent;return!e.altKey&&!(e.metaKey||e.ctrlKey)&&!e.shiftKey},r_=function(s){const e=s.originalEvent;return Oc?e.metaKey:e.ctrlKey},Mr=function(s){const e=s.originalEvent;return!e.altKey&&!(e.metaKey||e.ctrlKey)&&e.shiftKey},xu=function(s){const e=s.originalEvent,t=e.target.tagName;return t!=="INPUT"&&t!=="SELECT"&&t!=="TEXTAREA"&&!e.target.isContentEditable},bo=function(s){const e=s.originalEvent;return"pointerId"in e&&e.pointerType=="mouse"},Eu=function(s){const e=s.originalEvent;return"pointerId"in e&&e.isPrimary&&e.button===0};class ii extends ji{constructor(e){e=e||{},super(e),e.handleDownEvent&&(this.handleDownEvent=e.handleDownEvent),e.handleDragEvent&&(this.handleDragEvent=e.handleDragEvent),e.handleMoveEvent&&(this.handleMoveEvent=e.handleMoveEvent),e.handleUpEvent&&(this.handleUpEvent=e.handleUpEvent),e.stopDown&&(this.stopDown=e.stopDown),this.handlingDownUpSequence=!1,this.targetPointers=[]}getPointerCount(){return this.targetPointers.length}handleDownEvent(e){return!1}handleDragEvent(e){}handleEvent(e){if(!e.originalEvent)return!0;let t=!1;if(this.updateTrackedPointers_(e),this.handlingDownUpSequence){if(e.type==ee.POINTERDRAG)this.handleDragEvent(e),e.originalEvent.preventDefault();else if(e.type==ee.POINTERUP){const n=this.handleUpEvent(e);this.handlingDownUpSequence=n&&this.targetPointers.length>0}}else if(e.type==ee.POINTERDOWN){const n=this.handleDownEvent(e);this.handlingDownUpSequence=n,t=this.stopDown(n)}else e.type==ee.POINTERMOVE&&this.handleMoveEvent(e);return!t}handleMoveEvent(e){}handleUpEvent(e){return!1}stopDown(e){return e}updateTrackedPointers_(e){e.activePointers&&(this.targetPointers=e.activePointers)}}function vl(s){const e=s.length;let t=0,n=0;for(let i=0;i<e;i++)t+=s[i].clientX,n+=s[i].clientY;return{clientX:t/e,clientY:n/e}}class o_ extends ii{constructor(e){super({stopDown:$i}),e=e||{},this.kinetic_=e.kinetic,this.lastCentroid=null,this.lastPointersCount_,this.panning_=!1;const t=e.condition?e.condition:La(Sl,Eu);this.condition_=e.onFocusOnly?La(mu,t):t,this.noKinetic_=!1}handleDragEvent(e){const t=e.map;this.panning_||(this.panning_=!0,t.getView().beginInteraction());const n=this.targetPointers,i=t.getEventPixel(vl(n));if(n.length==this.lastPointersCount_){if(this.kinetic_&&this.kinetic_.update(i[0],i[1]),this.lastCentroid){const r=[this.lastCentroid[0]-i[0],i[1]-this.lastCentroid[1]],a=e.map.getView();bf(r,a.getResolution()),Qa(r,a.getRotation()),a.adjustCenterInternal(r)}}else this.kinetic_&&this.kinetic_.begin();this.lastCentroid=i,this.lastPointersCount_=n.length,e.originalEvent.preventDefault()}handleUpEvent(e){const t=e.map,n=t.getView();if(this.targetPointers.length===0){if(!this.noKinetic_&&this.kinetic_&&this.kinetic_.end()){const i=this.kinetic_.getDistance(),r=this.kinetic_.getAngle(),o=n.getCenterInternal(),a=t.getPixelFromCoordinateInternal(o),l=t.getCoordinateFromPixelInternal([a[0]-i*Math.cos(r),a[1]-i*Math.sin(r)]);n.animateInternal({center:n.getConstrainedCenter(l),duration:500,easing:Yi})}return this.panning_&&(this.panning_=!1,n.endInteraction()),!1}return this.kinetic_&&this.kinetic_.begin(),this.lastCentroid=null,!0}handleDownEvent(e){if(this.targetPointers.length>0&&this.condition_(e)){const n=e.map.getView();return this.lastCentroid=null,n.getAnimating()&&n.cancelAnimations(),this.kinetic_&&this.kinetic_.begin(),this.noKinetic_=this.targetPointers.length>1,!0}return!1}}class a_ extends ii{constructor(e){e=e||{},super({stopDown:$i}),this.condition_=e.condition?e.condition:i_,this.lastAngle_=void 0,this.duration_=e.duration!==void 0?e.duration:250}handleDragEvent(e){if(!bo(e))return;const t=e.map,n=t.getView();if(n.getConstraints().rotation===El)return;const i=t.getSize(),r=e.pixel,o=Math.atan2(i[1]/2-r[1],r[0]-i[0]/2);if(this.lastAngle_!==void 0){const a=o-this.lastAngle_;n.adjustRotationInternal(-a)}this.lastAngle_=o}handleUpEvent(e){return bo(e)?(e.map.getView().endInteraction(this.duration_),!1):!0}handleDownEvent(e){return bo(e)&&pu(e)&&this.condition_(e)?(e.map.getView().beginInteraction(),this.lastAngle_=void 0,!0):!1}}class l_ extends bs{constructor(e){super(),this.geometry_=null,this.element_=document.createElement("div"),this.element_.style.position="absolute",this.element_.style.pointerEvents="auto",this.element_.className="ol-box "+e,this.map_=null,this.startPixel_=null,this.endPixel_=null}disposeInternal(){this.setMap(null)}render_(){const e=this.startPixel_,t=this.endPixel_,n="px",i=this.element_.style;i.left=Math.min(e[0],t[0])+n,i.top=Math.min(e[1],t[1])+n,i.width=Math.abs(t[0]-e[0])+n,i.height=Math.abs(t[1]-e[1])+n}setMap(e){if(this.map_){this.map_.getOverlayContainer().removeChild(this.element_);const t=this.element_.style;t.left="inherit",t.top="inherit",t.width="inherit",t.height="inherit"}this.map_=e,this.map_&&this.map_.getOverlayContainer().appendChild(this.element_)}setPixels(e,t){this.startPixel_=e,this.endPixel_=t,this.createOrUpdateGeometry(),this.render_()}createOrUpdateGeometry(){if(!this.map_)return;const e=this.startPixel_,t=this.endPixel_,i=[e,[e[0],t[1]],t,[t[0],e[1]]].map(this.map_.getCoordinateFromPixelInternal,this.map_);i[4]=i[0].slice(),this.geometry_?this.geometry_.setCoordinates([i]):this.geometry_=new Qe([i])}getGeometry(){return this.geometry_}}const ui={BOXSTART:"boxstart",BOXDRAG:"boxdrag",BOXEND:"boxend",BOXCANCEL:"boxcancel"};class ns extends Tt{constructor(e,t,n){super(e),this.coordinate=t,this.mapBrowserEvent=n}}class h_ extends ii{constructor(e){super(),this.on,this.once,this.un,e=e??{},this.box_=new l_(e.className||"ol-dragbox"),this.minArea_=e.minArea??64,e.onBoxEnd&&(this.onBoxEnd=e.onBoxEnd),this.startPixel_=null,this.condition_=e.condition??pu,this.boxEndCondition_=e.boxEndCondition??this.defaultBoxEndCondition}defaultBoxEndCondition(e,t,n){const i=n[0]-t[0],r=n[1]-t[1];return i*i+r*r>=this.minArea_}getGeometry(){return this.box_.getGeometry()}handleDragEvent(e){this.startPixel_&&(this.box_.setPixels(this.startPixel_,e.pixel),this.dispatchEvent(new ns(ui.BOXDRAG,e.coordinate,e)))}handleUpEvent(e){if(!this.startPixel_)return!1;const t=this.boxEndCondition_(e,this.startPixel_,e.pixel);return t&&this.onBoxEnd(e),this.dispatchEvent(new ns(t?ui.BOXEND:ui.BOXCANCEL,e.coordinate,e)),this.box_.setMap(null),this.startPixel_=null,!1}handleDownEvent(e){return this.condition_(e)?(this.startPixel_=e.pixel,this.box_.setMap(e.map),this.box_.setPixels(this.startPixel_,this.startPixel_),this.dispatchEvent(new ns(ui.BOXSTART,e.coordinate,e)),!0):!1}onBoxEnd(e){}setActive(e){e||(this.box_.setMap(null),this.startPixel_&&(this.dispatchEvent(new ns(ui.BOXCANCEL,this.startPixel_,null)),this.startPixel_=null)),super.setActive(e)}setMap(e){this.getMap()&&(this.box_.setMap(null),this.startPixel_&&(this.dispatchEvent(new ns(ui.BOXCANCEL,this.startPixel_,null)),this.startPixel_=null)),super.setMap(e)}}class c_ extends h_{constructor(e){e=e||{};const t=e.condition?e.condition:Mr;super({condition:t,className:e.className||"ol-dragzoom",minArea:e.minArea}),this.duration_=e.duration!==void 0?e.duration:200,this.out_=e.out!==void 0?e.out:!1}onBoxEnd(e){const n=this.getMap().getView();let i=this.getGeometry();if(this.out_){const r=n.rotatedExtentForGeometry(i),o=n.getResolutionForExtentInternal(r),a=n.getResolution()/o;i=i.clone(),i.scale(a*a)}n.fitInternal(i,{duration:this.duration_,easing:Yi})}}const Nn={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",DOWN:"ArrowDown"};class u_ extends ji{constructor(e){super(),e=e||{},this.defaultCondition_=function(t){return Sl(t)&&xu(t)},this.condition_=e.condition!==void 0?e.condition:this.defaultCondition_,this.duration_=e.duration!==void 0?e.duration:100,this.pixelDelta_=e.pixelDelta!==void 0?e.pixelDelta:128}handleEvent(e){let t=!1;if(e.type==V.KEYDOWN){const n=e.originalEvent,i=n.key;if(this.condition_(e)&&(i==Nn.DOWN||i==Nn.LEFT||i==Nn.RIGHT||i==Nn.UP)){const o=e.map.getView(),a=o.getResolution()*this.pixelDelta_;let l=0,h=0;i==Nn.DOWN?h=-a:i==Nn.LEFT?l=-a:i==Nn.RIGHT?l=a:h=a;const c=[l,h];Qa(c,o.getRotation()),e_(o,c,this.duration_),n.preventDefault(),t=!0}}return!t}}class d_ extends ji{constructor(e){super(),e=e||{},this.condition_=e.condition?e.condition:function(t){return!r_(t)&&xu(t)},this.delta_=e.delta?e.delta:1,this.duration_=e.duration!==void 0?e.duration:100}handleEvent(e){let t=!1;if(e.type==V.KEYDOWN||e.type==V.KEYPRESS){const n=e.originalEvent,i=n.key;if(this.condition_(e)&&(i==="+"||i==="-")){const r=e.map,o=i==="+"?this.delta_:-this.delta_,a=r.getView();Rl(a,o,void 0,this.duration_),n.preventDefault(),t=!0}}return!t}}const f_=40,g_=300;class __ extends ji{constructor(e){e=e||{},super(e),this.totalDelta_=0,this.lastDelta_=0,this.maxDelta_=e.maxDelta!==void 0?e.maxDelta:1,this.duration_=e.duration!==void 0?e.duration:250,this.timeout_=e.timeout!==void 0?e.timeout:80,this.useAnchor_=e.useAnchor!==void 0?e.useAnchor:!0,this.constrainResolution_=e.constrainResolution!==void 0?e.constrainResolution:!1;const t=e.condition?e.condition:Li;this.condition_=e.onFocusOnly?La(mu,t):t,this.lastAnchor_=null,this.startTime_=void 0,this.timeoutId_,this.mode_=void 0,this.trackpadEventGap_=400,this.trackpadTimeoutId_,this.deltaPerZoom_=300}endInteraction_(){this.trackpadTimeoutId_=void 0;const e=this.getMap();if(!e)return;e.getView().endInteraction(void 0,this.lastDelta_?this.lastDelta_>0?1:-1:0,this.lastAnchor_?e.getCoordinateFromPixel(this.lastAnchor_):null)}handleEvent(e){if(!this.condition_(e)||e.type!==V.WHEEL)return!0;const n=e.map,i=e.originalEvent;i.preventDefault(),this.useAnchor_&&(this.lastAnchor_=e.pixel);let r=i.deltaY;switch(i.deltaMode){case WheelEvent.DOM_DELTA_LINE:r*=f_;break;case WheelEvent.DOM_DELTA_PAGE:r*=g_;break}if(r===0)return!1;this.lastDelta_=r;const o=Date.now();this.startTime_===void 0&&(this.startTime_=o),(!this.mode_||o-this.startTime_>this.trackpadEventGap_)&&(this.mode_=Math.abs(r)<4?"trackpad":"wheel");const a=n.getView();if(this.mode_==="trackpad"&&!(a.getConstrainResolution()||this.constrainResolution_))return this.trackpadTimeoutId_?clearTimeout(this.trackpadTimeoutId_):(a.getAnimating()&&a.cancelAnimations(),a.beginInteraction()),this.trackpadTimeoutId_=setTimeout(this.endInteraction_.bind(this),this.timeout_),a.adjustZoom(-r/this.deltaPerZoom_,this.lastAnchor_?n.getCoordinateFromPixel(this.lastAnchor_):null),this.startTime_=o,!1;this.totalDelta_+=r;const l=Math.max(this.timeout_-(o-this.startTime_),0);return clearTimeout(this.timeoutId_),this.timeoutId_=setTimeout(this.handleWheelZoom_.bind(this,n),l),!1}handleWheelZoom_(e){const t=e.getView();t.getAnimating()&&t.cancelAnimations();let n=-fe(this.totalDelta_,-this.maxDelta_*this.deltaPerZoom_,this.maxDelta_*this.deltaPerZoom_)/this.deltaPerZoom_;(t.getConstrainResolution()||this.constrainResolution_)&&(n=n?n>0?1:-1:0),Rl(t,n,this.lastAnchor_?e.getCoordinateFromPixel(this.lastAnchor_):null,this.duration_),this.mode_=void 0,this.totalDelta_=0,this.lastAnchor_=null,this.startTime_=void 0,this.timeoutId_=void 0}setMouseAnchor(e){this.useAnchor_=e,e||(this.lastAnchor_=null)}}class m_ extends ii{constructor(e){e=e||{};const t=e;t.stopDown||(t.stopDown=$i),super(t),this.anchor_=null,this.lastAngle_=void 0,this.rotating_=!1,this.rotationDelta_=0,this.threshold_=e.threshold!==void 0?e.threshold:.3,this.duration_=e.duration!==void 0?e.duration:250}handleDragEvent(e){let t=0;const n=this.targetPointers[0],i=this.targetPointers[1],r=Math.atan2(i.clientY-n.clientY,i.clientX-n.clientX);if(this.lastAngle_!==void 0){const l=r-this.lastAngle_;this.rotationDelta_+=l,!this.rotating_&&Math.abs(this.rotationDelta_)>this.threshold_&&(this.rotating_=!0),t=l}this.lastAngle_=r;const o=e.map,a=o.getView();a.getConstraints().rotation!==El&&(this.anchor_=o.getCoordinateFromPixelInternal(o.getEventPixel(vl(this.targetPointers))),this.rotating_&&(o.render(),a.adjustRotationInternal(t,this.anchor_)))}handleUpEvent(e){return this.targetPointers.length<2?(e.map.getView().endInteraction(this.duration_),!1):!0}handleDownEvent(e){if(this.targetPointers.length>=2){const t=e.map;return this.anchor_=null,this.lastAngle_=void 0,this.rotating_=!1,this.rotationDelta_=0,this.handlingDownUpSequence||t.getView().beginInteraction(),!0}return!1}}class p_ extends ii{constructor(e){e=e||{};const t=e;t.stopDown||(t.stopDown=$i),super(t),this.anchor_=null,this.duration_=e.duration!==void 0?e.duration:400,this.lastDistance_=void 0,this.lastScaleDelta_=1}handleDragEvent(e){let t=1;const n=this.targetPointers[0],i=this.targetPointers[1],r=n.clientX-i.clientX,o=n.clientY-i.clientY,a=Math.sqrt(r*r+o*o);this.lastDistance_!==void 0&&(t=this.lastDistance_/a),this.lastDistance_=a;const l=e.map,h=l.getView();t!=1&&(this.lastScaleDelta_=t),this.anchor_=l.getCoordinateFromPixelInternal(l.getEventPixel(vl(this.targetPointers))),l.render(),h.adjustResolutionInternal(t,this.anchor_)}handleUpEvent(e){if(this.targetPointers.length<2){const n=e.map.getView(),i=this.lastScaleDelta_>1?1:-1;return n.endInteraction(this.duration_,i),!1}return!0}handleDownEvent(e){if(this.targetPointers.length>=2){const t=e.map;return this.anchor_=null,this.lastDistance_=void 0,this.lastScaleDelta_=1,this.handlingDownUpSequence||t.getView().beginInteraction(),!0}return!1}}function y_(s){s=s||{};const e=new Ve,t=new Qg(-.005,.05,100);return(s.altShiftDragRotate!==void 0?s.altShiftDragRotate:!0)&&e.push(new a_),(s.doubleClickZoom!==void 0?s.doubleClickZoom:!0)&&e.push(new t_({delta:s.zoomDelta,duration:s.zoomDuration})),(s.dragPan!==void 0?s.dragPan:!0)&&e.push(new o_({onFocusOnly:s.onFocusOnly,kinetic:t})),(s.pinchRotate!==void 0?s.pinchRotate:!0)&&e.push(new m_),(s.pinchZoom!==void 0?s.pinchZoom:!0)&&e.push(new p_({duration:s.zoomDuration})),(s.keyboard!==void 0?s.keyboard:!0)&&(e.push(new u_),e.push(new d_({delta:s.zoomDelta,duration:s.zoomDuration}))),(s.mouseWheelZoom!==void 0?s.mouseWheelZoom:!0)&&e.push(new __({onFocusOnly:s.onFocusOnly,duration:s.zoomDuration})),(s.shiftDragZoom!==void 0?s.shiftDragZoom:!0)&&e.push(new c_({duration:s.zoomDuration})),e}const ae={OPACITY:"opacity",VISIBLE:"visible",EXTENT:"extent",Z_INDEX:"zIndex",MAX_RESOLUTION:"maxResolution",MIN_RESOLUTION:"minResolution",MAX_ZOOM:"maxZoom",MIN_ZOOM:"minZoom",SOURCE:"source",MAP:"map"};class Tu extends It{constructor(e){super(),this.on,this.once,this.un,this.background_=e.background;const t=Object.assign({},e);typeof e.properties=="object"&&(delete t.properties,Object.assign(t,e.properties)),t[ae.OPACITY]=e.opacity!==void 0?e.opacity:1,te(typeof t[ae.OPACITY]=="number","Layer opacity must be a number"),t[ae.VISIBLE]=e.visible!==void 0?e.visible:!0,t[ae.Z_INDEX]=e.zIndex,t[ae.MAX_RESOLUTION]=e.maxResolution!==void 0?e.maxResolution:1/0,t[ae.MIN_RESOLUTION]=e.minResolution!==void 0?e.minResolution:0,t[ae.MIN_ZOOM]=e.minZoom!==void 0?e.minZoom:-1/0,t[ae.MAX_ZOOM]=e.maxZoom!==void 0?e.maxZoom:1/0,this.className_=t.className!==void 0?t.className:"ol-layer",delete t.className,this.setProperties(t),this.state_=null}getBackground(){return this.background_}getClassName(){return this.className_}getLayerState(e){const t=this.state_||{layer:this,managed:e===void 0?!0:e},n=this.getZIndex();return t.opacity=fe(Math.round(this.getOpacity()*100)/100,0,1),t.visible=this.getVisible(),t.extent=this.getExtent(),t.zIndex=n===void 0&&!t.managed?1/0:n,t.maxResolution=this.getMaxResolution(),t.minResolution=Math.max(this.getMinResolution(),0),t.minZoom=this.getMinZoom(),t.maxZoom=this.getMaxZoom(),this.state_=t,t}getLayersArray(e){return $()}getLayerStatesArray(e){return $()}getExtent(){return this.get(ae.EXTENT)}getMaxResolution(){return this.get(ae.MAX_RESOLUTION)}getMinResolution(){return this.get(ae.MIN_RESOLUTION)}getMinZoom(){return this.get(ae.MIN_ZOOM)}getMaxZoom(){return this.get(ae.MAX_ZOOM)}getOpacity(){return this.get(ae.OPACITY)}getSourceState(){return $()}getVisible(){return this.get(ae.VISIBLE)}getZIndex(){return this.get(ae.Z_INDEX)}setBackground(e){this.background_=e,this.changed()}setExtent(e){this.set(ae.EXTENT,e)}setMaxResolution(e){this.set(ae.MAX_RESOLUTION,e)}setMinResolution(e){this.set(ae.MIN_RESOLUTION,e)}setMaxZoom(e){this.set(ae.MAX_ZOOM,e)}setMinZoom(e){this.set(ae.MIN_ZOOM,e)}setOpacity(e){te(typeof e=="number","Layer opacity must be a number"),this.set(ae.OPACITY,e)}setVisible(e){this.set(ae.VISIBLE,e)}setZIndex(e){this.set(ae.Z_INDEX,e)}disposeInternal(){this.state_&&(this.state_.layer=null,this.state_=null),super.disposeInternal()}}const cn={ADDLAYER:"addlayer",REMOVELAYER:"removelayer"};class _n extends Tt{constructor(e,t){super(e),this.layer=t}}const Mo={LAYERS:"layers"};class Vi extends Tu{constructor(e){e=e||{};const t=Object.assign({},e);delete t.layers;let n=e.layers;super(t),this.on,this.once,this.un,this.layersListenerKeys_=[],this.listenerKeys_={},this.addChangeListener(Mo.LAYERS,this.handleLayersChanged_),n?Array.isArray(n)?n=new Ve(n.slice(),{unique:!0}):te(typeof n.getArray=="function","Expected `layers` to be an array or a `Collection`"):n=new Ve(void 0,{unique:!0}),this.setLayers(n)}handleLayerChange_(){this.changed()}handleLayersChanged_(){this.layersListenerKeys_.forEach(ue),this.layersListenerKeys_.length=0;const e=this.getLayers();this.layersListenerKeys_.push(J(e,Re.ADD,this.handleLayersAdd_,this),J(e,Re.REMOVE,this.handleLayersRemove_,this));for(const n in this.listenerKeys_)this.listenerKeys_[n].forEach(ue);Qn(this.listenerKeys_);const t=e.getArray();for(let n=0,i=t.length;n<i;n++){const r=t[n];this.registerLayerListeners_(r),this.dispatchEvent(new _n(cn.ADDLAYER,r))}this.changed()}registerLayerListeners_(e){const t=[J(e,Oi.PROPERTYCHANGE,this.handleLayerChange_,this),J(e,V.CHANGE,this.handleLayerChange_,this)];e instanceof Vi&&t.push(J(e,cn.ADDLAYER,this.handleLayerGroupAdd_,this),J(e,cn.REMOVELAYER,this.handleLayerGroupRemove_,this)),this.listenerKeys_[D(e)]=t}handleLayerGroupAdd_(e){this.dispatchEvent(new _n(cn.ADDLAYER,e.layer))}handleLayerGroupRemove_(e){this.dispatchEvent(new _n(cn.REMOVELAYER,e.layer))}handleLayersAdd_(e){const t=e.element;this.registerLayerListeners_(t),this.dispatchEvent(new _n(cn.ADDLAYER,t)),this.changed()}handleLayersRemove_(e){const t=e.element,n=D(t);this.listenerKeys_[n].forEach(ue),delete this.listenerKeys_[n],this.dispatchEvent(new _n(cn.REMOVELAYER,t)),this.changed()}getLayers(){return this.get(Mo.LAYERS)}setLayers(e){const t=this.getLayers();if(t){const n=t.getArray();for(let i=0,r=n.length;i<r;++i)this.dispatchEvent(new _n(cn.REMOVELAYER,n[i]))}this.set(Mo.LAYERS,e)}getLayersArray(e){return e=e!==void 0?e:[],this.getLayers().forEach(function(t){t.getLayersArray(e)}),e}getLayerStatesArray(e){const t=e!==void 0?e:[],n=t.length;this.getLayers().forEach(function(o){o.getLayerStatesArray(t)});const i=this.getLayerState();let r=i.zIndex;!e&&i.zIndex===void 0&&(r=0);for(let o=n,a=t.length;o<a;o++){const l=t[o];l.opacity*=i.opacity,l.visible=l.visible&&i.visible,l.maxResolution=Math.min(l.maxResolution,i.maxResolution),l.minResolution=Math.max(l.minResolution,i.minResolution),l.minZoom=Math.max(l.minZoom,i.minZoom),l.maxZoom=Math.min(l.maxZoom,i.maxZoom),i.extent!==void 0&&(l.extent!==void 0?l.extent=en(l.extent,i.extent):l.extent=i.extent),l.zIndex===void 0&&(l.zIndex=r)}return t}getSourceState(){return"ready"}}const Fe={PRERENDER:"prerender",POSTRENDER:"postrender",PRECOMPOSE:"precompose",POSTCOMPOSE:"postcompose",RENDERCOMPLETE:"rendercomplete"};class Us extends Tu{constructor(e){const t=Object.assign({},e);delete t.source,super(t),this.on,this.once,this.un,this.mapPrecomposeKey_=null,this.mapRenderKey_=null,this.sourceChangeKey_=null,this.renderer_=null,this.sourceReady_=!1,this.rendered=!1,e.render&&(this.render=e.render),e.map&&this.setMap(e.map),this.addChangeListener(ae.SOURCE,this.handleSourcePropertyChange_);const n=e.source?e.source:null;this.setSource(n)}getLayersArray(e){return e=e||[],e.push(this),e}getLayerStatesArray(e){return e=e||[],e.push(this.getLayerState()),e}getSource(){return this.get(ae.SOURCE)||null}getRenderSource(){return this.getSource()}getSourceState(){const e=this.getSource();return e?e.getState():"undefined"}handleSourceChange_(){this.changed(),!(this.sourceReady_||this.getSource().getState()!=="ready")&&(this.sourceReady_=!0,this.dispatchEvent("sourceready"))}handleSourcePropertyChange_(){this.sourceChangeKey_&&(ue(this.sourceChangeKey_),this.sourceChangeKey_=null),this.sourceReady_=!1;const e=this.getSource();e&&(this.sourceChangeKey_=J(e,V.CHANGE,this.handleSourceChange_,this),e.getState()==="ready"&&(this.sourceReady_=!0,setTimeout(()=>{this.dispatchEvent("sourceready")},0))),this.changed()}getFeatures(e){return this.renderer_?this.renderer_.getFeatures(e):Promise.resolve([])}getData(e){return!this.renderer_||!this.rendered?null:this.renderer_.getData(e)}isVisible(e){let t;const n=this.getMapInternal();!e&&n&&(e=n.getView()),e instanceof qt?t={viewState:e.getState(),extent:e.calculateExtent()}:t=e,!t.layerStatesArray&&n&&(t.layerStatesArray=n.getLayerGroup().getLayerStatesArray());let i;if(t.layerStatesArray){if(i=t.layerStatesArray.find(o=>o.layer===this),!i)return!1}else i=this.getLayerState();const r=this.getExtent();return wl(i,t.viewState)&&(!r||Ee(r,t.extent))}getAttributions(e){if(!this.isVisible(e))return[];const t=this.getSource()?.getAttributions();if(!t)return[];const n=e instanceof qt?e.getViewStateAndExtent():e;let i=t(n);return Array.isArray(i)||(i=[i]),i}render(e,t){const n=this.getRenderer();return n.prepareFrame(e)?(this.rendered=!0,n.renderFrame(e,t)):null}unrender(){this.rendered=!1}getDeclutter(){}renderDeclutter(e,t){}renderDeferred(e){const t=this.getRenderer();t&&t.renderDeferred(e)}setMapInternal(e){e||this.unrender(),this.set(ae.MAP,e)}getMapInternal(){return this.get(ae.MAP)}setMap(e){this.mapPrecomposeKey_&&(ue(this.mapPrecomposeKey_),this.mapPrecomposeKey_=null),e||this.changed(),this.mapRenderKey_&&(ue(this.mapRenderKey_),this.mapRenderKey_=null),e&&(this.mapPrecomposeKey_=J(e,Fe.PRECOMPOSE,this.handlePrecompose_,this),this.mapRenderKey_=J(this,V.CHANGE,e.render,e),this.changed())}handlePrecompose_(e){const t=e.frameState.layerStatesArray,n=this.getLayerState(!1);te(!t.some(i=>i.layer===n.layer),"A layer can only be added to the map once. Use either `layer.setMap()` or `map.addLayer()`, not both."),t.push(n)}setSource(e){this.set(ae.SOURCE,e)}getRenderer(){return this.renderer_||(this.renderer_=this.createRenderer()),this.renderer_}hasRenderer(){return!!this.renderer_}createRenderer(){return null}clearRenderer(){this.renderer_&&(this.renderer_.dispose(),delete this.renderer_)}disposeInternal(){this.clearRenderer(),this.setSource(null),super.disposeInternal()}}function wl(s,e){if(!s.visible)return!1;const t=e.resolution;if(t<s.minResolution||t>=s.maxResolution)return!1;const n=e.zoom;return n>s.minZoom&&n<=s.maxZoom}function Cu(s,e,t=0,n=s.length-1,i=x_){for(;n>t;){if(n-t>600){const l=n-t+1,h=e-t+1,c=Math.log(l),u=.5*Math.exp(2*c/3),d=.5*Math.sqrt(c*u*(l-u)/l)*(h-l/2<0?-1:1),f=Math.max(t,Math.floor(e-h*u/l+d)),g=Math.min(n,Math.floor(e+(l-h)*u/l+d));Cu(s,e,f,g,i)}const r=s[e];let o=t,a=n;for(is(s,t,e),i(s[n],r)>0&&is(s,t,n);o<a;){for(is(s,o,a),o++,a--;i(s[o],r)<0;)o++;for(;i(s[a],r)>0;)a--}i(s[t],r)===0?is(s,t,a):(a++,is(s,a,n)),a<=e&&(t=a+1),e<=a&&(n=a-1)}}function is(s,e,t){const n=s[e];s[e]=s[t],s[t]=n}function x_(s,e){return s<e?-1:s>e?1:0}let Pl=class{constructor(e=9){this._maxEntries=Math.max(4,e),this._minEntries=Math.max(2,Math.ceil(this._maxEntries*.4)),this.clear()}all(){return this._all(this.data,[])}search(e){let t=this.data;const n=[];if(!nr(e,t))return n;const i=this.toBBox,r=[];for(;t;){for(let o=0;o<t.children.length;o++){const a=t.children[o],l=t.leaf?i(a):a;nr(e,l)&&(t.leaf?n.push(a):Oo(e,l)?this._all(a,n):r.push(a))}t=r.pop()}return n}collides(e){let t=this.data;if(!nr(e,t))return!1;const n=[];for(;t;){for(let i=0;i<t.children.length;i++){const r=t.children[i],o=t.leaf?this.toBBox(r):r;if(nr(e,o)){if(t.leaf||Oo(e,o))return!0;n.push(r)}}t=n.pop()}return!1}load(e){if(!(e&&e.length))return this;if(e.length<this._minEntries){for(let n=0;n<e.length;n++)this.insert(e[n]);return this}let t=this._build(e.slice(),0,e.length-1,0);if(!this.data.children.length)this.data=t;else if(this.data.height===t.height)this._splitRoot(this.data,t);else{if(this.data.height<t.height){const n=this.data;this.data=t,t=n}this._insert(t,this.data.height-t.height-1,!0)}return this}insert(e){return e&&this._insert(e,this.data.height-1),this}clear(){return this.data=Ti([]),this}remove(e,t){if(!e)return this;let n=this.data;const i=this.toBBox(e),r=[],o=[];let a,l,h;for(;n||r.length;){if(n||(n=r.pop(),l=r[r.length-1],a=o.pop(),h=!0),n.leaf){const c=E_(e,n.children,t);if(c!==-1)return n.children.splice(c,1),r.push(n),this._condense(r),this}!h&&!n.leaf&&Oo(n,i)?(r.push(n),o.push(a),a=0,l=n,n=n.children[0]):l?(a++,n=l.children[a],h=!1):n=null}return this}toBBox(e){return e}compareMinX(e,t){return e.minX-t.minX}compareMinY(e,t){return e.minY-t.minY}toJSON(){return this.data}fromJSON(e){return this.data=e,this}_all(e,t){const n=[];for(;e;)e.leaf?t.push(...e.children):n.push(...e.children),e=n.pop();return t}_build(e,t,n,i){const r=n-t+1;let o=this._maxEntries,a;if(r<=o)return a=Ti(e.slice(t,n+1)),di(a,this.toBBox),a;i||(i=Math.ceil(Math.log(r)/Math.log(o)),o=Math.ceil(r/Math.pow(o,i-1))),a=Ti([]),a.leaf=!1,a.height=i;const l=Math.ceil(r/o),h=l*Math.ceil(Math.sqrt(o));kh(e,t,n,h,this.compareMinX);for(let c=t;c<=n;c+=h){const u=Math.min(c+h-1,n);kh(e,c,u,l,this.compareMinY);for(let d=c;d<=u;d+=l){const f=Math.min(d+l-1,u);a.children.push(this._build(e,d,f,i-1))}}return di(a,this.toBBox),a}_chooseSubtree(e,t,n,i){for(;i.push(t),!(t.leaf||i.length-1===n);){let r=1/0,o=1/0,a;for(let l=0;l<t.children.length;l++){const h=t.children[l],c=Do(h),u=R_(e,h)-c;u<o?(o=u,r=c<r?c:r,a=h):u===o&&c<r&&(r=c,a=h)}t=a||t.children[0]}return t}_insert(e,t,n){const i=n?e:this.toBBox(e),r=[],o=this._chooseSubtree(i,this.data,t,r);for(o.children.push(e),hs(o,i);t>=0&&r[t].children.length>this._maxEntries;)this._split(r,t),t--;this._adjustParentBBoxes(i,r,t)}_split(e,t){const n=e[t],i=n.children.length,r=this._minEntries;this._chooseSplitAxis(n,r,i);const o=this._chooseSplitIndex(n,r,i),a=Ti(n.children.splice(o,n.children.length-o));a.height=n.height,a.leaf=n.leaf,di(n,this.toBBox),di(a,this.toBBox),t?e[t-1].children.push(a):this._splitRoot(n,a)}_splitRoot(e,t){this.data=Ti([e,t]),this.data.height=e.height+1,this.data.leaf=!1,di(this.data,this.toBBox)}_chooseSplitIndex(e,t,n){let i,r=1/0,o=1/0;for(let a=t;a<=n-t;a++){const l=ls(e,0,a,this.toBBox),h=ls(e,a,n,this.toBBox),c=S_(l,h),u=Do(l)+Do(h);c<r?(r=c,i=a,o=u<o?u:o):c===r&&u<o&&(o=u,i=a)}return i||n-t}_chooseSplitAxis(e,t,n){const i=e.leaf?this.compareMinX:T_,r=e.leaf?this.compareMinY:C_,o=this._allDistMargin(e,t,n,i),a=this._allDistMargin(e,t,n,r);o<a&&e.children.sort(i)}_allDistMargin(e,t,n,i){e.children.sort(i);const r=this.toBBox,o=ls(e,0,t,r),a=ls(e,n-t,n,r);let l=tr(o)+tr(a);for(let h=t;h<n-t;h++){const c=e.children[h];hs(o,e.leaf?r(c):c),l+=tr(o)}for(let h=n-t-1;h>=t;h--){const c=e.children[h];hs(a,e.leaf?r(c):c),l+=tr(a)}return l}_adjustParentBBoxes(e,t,n){for(let i=n;i>=0;i--)hs(t[i],e)}_condense(e){for(let t=e.length-1,n;t>=0;t--)e[t].children.length===0?t>0?(n=e[t-1].children,n.splice(n.indexOf(e[t]),1)):this.clear():di(e[t],this.toBBox)}};function E_(s,e,t){if(!t)return e.indexOf(s);for(let n=0;n<e.length;n++)if(t(s,e[n]))return n;return-1}function di(s,e){ls(s,0,s.children.length,e,s)}function ls(s,e,t,n,i){i||(i=Ti(null)),i.minX=1/0,i.minY=1/0,i.maxX=-1/0,i.maxY=-1/0;for(let r=e;r<t;r++){const o=s.children[r];hs(i,s.leaf?n(o):o)}return i}function hs(s,e){return s.minX=Math.min(s.minX,e.minX),s.minY=Math.min(s.minY,e.minY),s.maxX=Math.max(s.maxX,e.maxX),s.maxY=Math.max(s.maxY,e.maxY),s}function T_(s,e){return s.minX-e.minX}function C_(s,e){return s.minY-e.minY}function Do(s){return(s.maxX-s.minX)*(s.maxY-s.minY)}function tr(s){return s.maxX-s.minX+(s.maxY-s.minY)}function R_(s,e){return(Math.max(e.maxX,s.maxX)-Math.min(e.minX,s.minX))*(Math.max(e.maxY,s.maxY)-Math.min(e.minY,s.minY))}function S_(s,e){const t=Math.max(s.minX,e.minX),n=Math.max(s.minY,e.minY),i=Math.min(s.maxX,e.maxX),r=Math.min(s.maxY,e.maxY);return Math.max(0,i-t)*Math.max(0,r-n)}function Oo(s,e){return s.minX<=e.minX&&s.minY<=e.minY&&e.maxX<=s.maxX&&e.maxY<=s.maxY}function nr(s,e){return e.minX<=s.maxX&&e.minY<=s.maxY&&e.maxX>=s.minX&&e.maxY>=s.minY}function Ti(s){return{children:s,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function kh(s,e,t,n,i){const r=[e,t];for(;r.length;){if(t=r.pop(),e=r.pop(),t-e<=n)continue;const o=e+Math.ceil((t-e)/n/2)*n;Cu(s,o,e,t,i),r.push(e,o,o,t)}}const Il=[NaN,NaN,NaN,0];let No;function v_(){return No||(No=ve(1,1,void 0,{willReadFrequently:!0,desynchronized:!0})),No}const w_=/^rgba?\(\s*(\d+%?)\s+(\d+%?)\s+(\d+%?)(?:\s*\/\s*(\d+%|\d*\.\d+|[01]))?\s*\)$/i,P_=/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)(?:\s*,\s*(\d+%|\d*\.\d+|[01]))?\s*\)$/i,I_=/^rgba?\(\s*(\d+%)\s*,\s*(\d+%)\s*,\s*(\d+%)(?:\s*,\s*(\d+%|\d*\.\d+|[01]))?\s*\)$/i,L_=/^#([\da-f]{3,4}|[\da-f]{6}|[\da-f]{8})$/i;function ir(s,e){return s.endsWith("%")?Number(s.substring(0,s.length-1))/e:Number(s)}function gs(s){throw new Error('failed to parse "'+s+'" as color')}function Ru(s){if(s.toLowerCase().startsWith("rgb")){const r=s.match(P_)||s.match(w_)||s.match(I_);if(r){const o=r[4],a=100/255;return[fe(ir(r[1],a)+.5|0,0,255),fe(ir(r[2],a)+.5|0,0,255),fe(ir(r[3],a)+.5|0,0,255),o!==void 0?fe(ir(o,100),0,1):1]}gs(s)}if(s.startsWith("#")){if(L_.test(s)){const r=s.substring(1),o=r.length<=4?1:2,a=[0,0,0,255];for(let l=0,h=r.length;l<h;l+=o){let c=parseInt(r.substring(l,l+o),16);o===1&&(c+=c<<4),a[l/o]=c}return a[3]=a[3]/255,a}gs(s)}const e=v_();e.fillStyle="#abcdef";let t=e.fillStyle;e.fillStyle=s,e.fillStyle===t&&(e.fillStyle="#fedcba",t=e.fillStyle,e.fillStyle=s,e.fillStyle===t&&gs(s));const n=e.fillStyle;if(n.startsWith("#")||n.startsWith("rgba"))return Ru(n);e.clearRect(0,0,1,1),e.fillRect(0,0,1,1);const i=Array.from(e.getImageData(0,0,1,1).data);return i[3]=Xi(i[3]/255,3),i}function A_(s){return typeof s=="string"?s:Al(s)}const F_=1024,ss={};let Go=0;function b_(s){if(s.length===4)return s;const e=s.slice();return e[3]=1,e}function ko(s){return s>.0031308?Math.pow(s,1/2.4)*269.025-14.025:s*3294.6}function Uo(s){return s>.2068965?Math.pow(s,3):(s-4/29)*(108/841)}function Bo(s){return s>10.314724?Math.pow((s+14.025)/269.025,2.4):s/3294.6}function zo(s){return s>.0088564?Math.pow(s,1/3):s/(108/841)+4/29}function Uh(s){const e=Bo(s[0]),t=Bo(s[1]),n=Bo(s[2]),i=zo(e*.222488403+t*.716873169+n*.06060791),r=500*(zo(e*.452247074+t*.399439023+n*.148375274)-i),o=200*(i-zo(e*.016863605+t*.117638439+n*.865350722)),a=Math.atan2(o,r)*(180/Math.PI);return[116*i-16,Math.sqrt(r*r+o*o),a<0?a+360:a,s[3]]}function M_(s){const e=(s[0]+16)/116,t=s[1],n=s[2]*Math.PI/180,i=Uo(e),r=Uo(e+t/500*Math.cos(n)),o=Uo(e-t/200*Math.sin(n)),a=ko(r*3.021973625-i*1.617392459-o*.404875592),l=ko(r*-.943766287+i*1.916279586+o*.027607165),h=ko(r*.069407491-i*.22898585+o*1.159737864);return[fe(a+.5|0,0,255),fe(l+.5|0,0,255),fe(h+.5|0,0,255),s[3]]}function Ll(s){if(s==="none")return Il;if(ss.hasOwnProperty(s))return ss[s];if(Go>=F_){let t=0;for(const n in ss)(t++&3)===0&&(delete ss[n],--Go)}const e=Ru(s);e.length!==4&&gs(s);for(const t of e)isNaN(t)&&gs(s);return ss[s]=e,++Go,e}function Et(s){return Array.isArray(s)?s:Ll(s)}function Al(s){let e=s[0];e!=(e|0)&&(e=e+.5|0);let t=s[1];t!=(t|0)&&(t=t+.5|0);let n=s[2];n!=(n|0)&&(n=n+.5|0);const i=s[3]===void 0?1:Math.round(s[3]*1e3)/1e3;return"rgba("+e+","+t+","+n+","+i+")"}function Bh(s){return s[0]>0&&s[1]>0}function D_(s,e,t){return t===void 0&&(t=[0,0]),t[0]=s[0]*e+.5|0,t[1]=s[1]*e+.5|0,t}function $e(s,e){return Array.isArray(s)?s:(e===void 0?e=[s,s]:(e[0]=s,e[1]=s),e)}let si=0;const Se=1<<si++,N=1<<si++,Pe=1<<si++,ge=1<<si++,et=1<<si++,_t=1<<si++,sr=Math.pow(2,si)-1,Fl={[Se]:"boolean",[N]:"number",[Pe]:"string",[ge]:"color",[et]:"number[]",[_t]:"size"},O_=Object.keys(Fl).map(Number).sort(Ot);function N_(s){return s in Fl}function wi(s){const e=[];for(const t of O_)cs(s,t)&&e.push(Fl[t]);return e.length===0?"untyped":e.length<3?e.join(" or "):e.slice(0,-1).join(", ")+", or "+e[e.length-1]}function cs(s,e){return(s&e)===e}function Mt(s,e){return s===e}class we{constructor(e,t){if(!N_(e))throw new Error(`literal expressions must have a specific type, got ${wi(e)}`);this.type=e,this.value=t}}class Su{constructor(e,t,...n){this.type=e,this.operator=t,this.args=n}}function bl(){return{variables:new Set,properties:new Set,featureId:!1,geometryType:!1,mapState:!1}}function Me(s,e,t){switch(typeof s){case"boolean":{if(Mt(e,Pe))return new we(Pe,s?"true":"false");if(!cs(e,Se))throw new Error(`got a boolean, but expected ${wi(e)}`);return new we(Se,s)}case"number":{if(Mt(e,_t))return new we(_t,$e(s));if(Mt(e,Se))return new we(Se,!!s);if(Mt(e,Pe))return new we(Pe,s.toString());if(!cs(e,N))throw new Error(`got a number, but expected ${wi(e)}`);return new we(N,s)}case"string":{if(Mt(e,ge))return new we(ge,Ll(s));if(Mt(e,Se))return new we(Se,!!s);if(!cs(e,Pe))throw new Error(`got a string, but expected ${wi(e)}`);return new we(Pe,s)}}if(!Array.isArray(s))throw new Error("expression must be an array or a primitive value");if(s.length===0)throw new Error("empty expression");if(typeof s[0]=="string")return V_(s,e,t);for(const n of s)if(typeof n!="number")throw new Error("expected an array of numbers");if(Mt(e,_t)){if(s.length!==2)throw new Error(`expected an array of two values for a size, got ${s.length}`);return new we(_t,s)}if(Mt(e,ge)){if(s.length===3)return new we(ge,[...s,1]);if(s.length===4)return new we(ge,s);throw new Error(`expected an array of 3 or 4 values for a color, got ${s.length}`)}if(!cs(e,et))throw new Error(`got an array of numbers, but expected ${wi(e)}`);return new we(et,s)}const C={Get:"get",Var:"var",Concat:"concat",GeometryType:"geometry-type",LineMetric:"line-metric",Any:"any",All:"all",Not:"!",Resolution:"resolution",Zoom:"zoom",Time:"time",Equal:"==",NotEqual:"!=",GreaterThan:">",GreaterThanOrEqualTo:">=",LessThan:"<",LessThanOrEqualTo:"<=",Multiply:"*",Divide:"/",Add:"+",Subtract:"-",Clamp:"clamp",Mod:"%",Pow:"^",Abs:"abs",Floor:"floor",Ceil:"ceil",Round:"round",Sin:"sin",Cos:"cos",Atan:"atan",Sqrt:"sqrt",Match:"match",Between:"between",Interpolate:"interpolate",Coalesce:"coalesce",Case:"case",In:"in",Number:"number",String:"string",Array:"array",Color:"color",Id:"id",Band:"band",Palette:"palette",ToString:"to-string",Has:"has"},G_={[C.Get]:Y(q(1,1/0),zh),[C.Var]:Y(q(1,1),k_),[C.Has]:Y(q(1,1/0),zh),[C.Id]:Y(U_,fi),[C.Concat]:Y(q(2,1/0),re(Pe)),[C.GeometryType]:Y(B_,fi),[C.LineMetric]:Y(fi),[C.Resolution]:Y($o,fi),[C.Zoom]:Y($o,fi),[C.Time]:Y($o,fi),[C.Any]:Y(q(2,1/0),re(Se)),[C.All]:Y(q(2,1/0),re(Se)),[C.Not]:Y(q(1,1),re(Se)),[C.Equal]:Y(q(2,2),re(sr)),[C.NotEqual]:Y(q(2,2),re(sr)),[C.GreaterThan]:Y(q(2,2),re(N)),[C.GreaterThanOrEqualTo]:Y(q(2,2),re(N)),[C.LessThan]:Y(q(2,2),re(N)),[C.LessThanOrEqualTo]:Y(q(2,2),re(N)),[C.Multiply]:Y(q(2,1/0),$h),[C.Coalesce]:Y(q(2,1/0),$h),[C.Divide]:Y(q(2,2),re(N)),[C.Add]:Y(q(2,1/0),re(N)),[C.Subtract]:Y(q(2,2),re(N)),[C.Clamp]:Y(q(3,3),re(N)),[C.Mod]:Y(q(2,2),re(N)),[C.Pow]:Y(q(2,2),re(N)),[C.Abs]:Y(q(1,1),re(N)),[C.Floor]:Y(q(1,1),re(N)),[C.Ceil]:Y(q(1,1),re(N)),[C.Round]:Y(q(1,1),re(N)),[C.Sin]:Y(q(1,1),re(N)),[C.Cos]:Y(q(1,1),re(N)),[C.Atan]:Y(q(1,2),re(N)),[C.Sqrt]:Y(q(1,1),re(N)),[C.Match]:Y(q(4,1/0),Xh,$_),[C.Between]:Y(q(3,3),re(N)),[C.Interpolate]:Y(q(6,1/0),Xh,X_),[C.Case]:Y(q(3,1/0),z_,W_),[C.In]:Y(q(2,2),Y_),[C.Number]:Y(q(1,1/0),re(sr)),[C.String]:Y(q(1,1/0),re(sr)),[C.Array]:Y(q(1,1/0),re(N)),[C.Color]:Y(q(1,4),re(N)),[C.Band]:Y(q(1,3),re(N)),[C.Palette]:Y(q(2,2),j_),[C.ToString]:Y(q(1,1),re(Se|N|Pe|ge))};function zh(s,e,t){const n=s.length-1,i=new Array(n);for(let r=0;r<n;++r){const o=s[r+1];switch(typeof o){case"number":{i[r]=new we(N,o);break}case"string":{i[r]=new we(Pe,o);break}default:throw new Error(`expected a string key or numeric array index for a get operation, got ${o}`)}r===0&&t.properties.add(String(o))}return i}function k_(s,e,t){const n=s[1];if(typeof n!="string")throw new Error("expected a string argument for var operation");return t.variables.add(n),[new we(Pe,n)]}function U_(s,e,t){t.featureId=!0}function B_(s,e,t){t.geometryType=!0}function $o(s,e,t){t.mapState=!0}function fi(s,e,t){const n=s[0];if(s.length!==1)throw new Error(`expected no arguments for ${n} operation`);return[]}function q(s,e){return function(t,n,i){const r=t[0],o=t.length-1;if(s===e){if(o!==s){const a=s===1?"":"s";throw new Error(`expected ${s} argument${a} for ${r}, got ${o}`)}}else if(o<s||o>e){const a=e===1/0?`${s} or more`:`${s} to ${e}`;throw new Error(`expected ${a} arguments for ${r}, got ${o}`)}}}function $h(s,e,t){const n=s.length-1,i=new Array(n);for(let r=0;r<n;++r){const o=Me(s[r+1],e,t);i[r]=o}return i}function re(s){return function(e,t,n){const i=e.length-1,r=new Array(i);for(let o=0;o<i;++o){const a=Me(e[o+1],s,n);r[o]=a}return r}}function z_(s,e,t){const n=s[0],i=s.length-1;if(i%2===0)throw new Error(`expected an odd number of arguments for ${n}, got ${i} instead`)}function Xh(s,e,t){const n=s[0],i=s.length-1;if(i%2===1)throw new Error(`expected an even number of arguments for operation ${n}, got ${i} instead`)}function $_(s,e,t){const n=s.length-1,i=Pe|N|Se,r=Me(s[1],i,t),o=Me(s[s.length-1],e,t),a=new Array(n-2);for(let l=0;l<n-2;l+=2){try{const h=Me(s[l+2],r.type,t);a[l]=h}catch(h){throw new Error(`failed to parse argument ${l+1} of match expression: ${h.message}`)}try{const h=Me(s[l+3],o.type,t);a[l+1]=h}catch(h){throw new Error(`failed to parse argument ${l+2} of match expression: ${h.message}`)}}return[r,...a,o]}function X_(s,e,t){const n=s[1];let i;switch(n[0]){case"linear":i=1;break;case"exponential":const l=n[1];if(typeof l!="number"||l<=0)throw new Error(`expected a number base for exponential interpolation, got ${JSON.stringify(l)} instead`);i=l;break;default:throw new Error(`invalid interpolation type: ${JSON.stringify(n)}`)}const r=new we(N,i);let o;try{o=Me(s[2],N,t)}catch(l){throw new Error(`failed to parse argument 1 in interpolate expression: ${l.message}`)}const a=new Array(s.length-3);for(let l=0;l<a.length;l+=2){try{const h=Me(s[l+3],N,t);a[l]=h}catch(h){throw new Error(`failed to parse argument ${l+2} for interpolate expression: ${h.message}`)}try{const h=Me(s[l+4],e,t);a[l+1]=h}catch(h){throw new Error(`failed to parse argument ${l+3} for interpolate expression: ${h.message}`)}}return[r,o,...a]}function W_(s,e,t){const n=Me(s[s.length-1],e,t),i=new Array(s.length-1);for(let r=0;r<i.length-1;r+=2){try{const o=Me(s[r+1],Se,t);i[r]=o}catch(o){throw new Error(`failed to parse argument ${r} of case expression: ${o.message}`)}try{const o=Me(s[r+2],n.type,t);i[r+1]=o}catch(o){throw new Error(`failed to parse argument ${r+1} of case expression: ${o.message}`)}}return i[i.length-1]=n,i}function Y_(s,e,t){let n=s[2];if(!Array.isArray(n))throw new Error('the second argument for the "in" operator must be an array');let i;if(typeof n[0]=="string"){if(n[0]!=="literal")throw new Error('for the "in" operator, a string array should be wrapped in a "literal" operator to disambiguate from expressions');if(!Array.isArray(n[1]))throw new Error('failed to parse "in" expression: the literal operator must be followed by an array');n=n[1],i=Pe}else i=N;const r=new Array(n.length);for(let a=0;a<r.length;a++)try{const l=Me(n[a],i,t);r[a]=l}catch(l){throw new Error(`failed to parse haystack item ${a} for "in" expression: ${l.message}`)}return[Me(s[1],i,t),...r]}function j_(s,e,t){let n;try{n=Me(s[1],N,t)}catch(o){throw new Error(`failed to parse first argument in palette expression: ${o.message}`)}const i=s[2];if(!Array.isArray(i))throw new Error("the second argument of palette must be an array");const r=new Array(i.length);for(let o=0;o<r.length;o++){let a;try{a=Me(i[o],ge,t)}catch(l){throw new Error(`failed to parse color at index ${o} in palette expression: ${l.message}`)}if(!(a instanceof we))throw new Error(`the palette color at index ${o} must be a literal value`);r[o]=a}return[n,...r]}function Y(...s){return function(e,t,n){const i=e[0];let r;for(let o=0;o<s.length;o++){const a=s[o](e,t,n);if(o==s.length-1){if(!a)throw new Error("expected last argument validator to return the parsed args");r=a}}return new Su(t,i,...r)}}function V_(s,e,t){const n=s[0],i=G_[n];if(!i)throw new Error(`unknown operator: ${n}`);return i(s,e,t)}function Ml(s){if(!s)return"";const e=s.getType();switch(e){case"Point":case"LineString":case"Polygon":return e;case"MultiPoint":case"MultiLineString":case"MultiPolygon":return e.substring(5);case"Circle":return"Polygon";case"GeometryCollection":return Ml(s.getGeometries()[0]);default:return""}}function vu(){return{variables:{},properties:{},resolution:NaN,featureId:null,geometryType:""}}function on(s,e,t){const n=Me(s,e,t);return vt(n)}function vt(s,e){if(s instanceof we){if(s.type===ge&&typeof s.value=="string"){const n=Ll(s.value);return function(){return n}}return function(){return s.value}}const t=s.operator;switch(t){case C.Number:case C.String:case C.Coalesce:return Z_(s);case C.Get:case C.Var:case C.Has:return K_(s);case C.Id:return n=>n.featureId;case C.GeometryType:return n=>n.geometryType;case C.Concat:{const n=s.args.map(i=>vt(i));return i=>"".concat(...n.map(r=>r(i).toString()))}case C.Resolution:return n=>n.resolution;case C.Any:case C.All:case C.Between:case C.In:case C.Not:return q_(s);case C.Equal:case C.NotEqual:case C.LessThan:case C.LessThanOrEqualTo:case C.GreaterThan:case C.GreaterThanOrEqualTo:return H_(s);case C.Multiply:case C.Divide:case C.Add:case C.Subtract:case C.Clamp:case C.Mod:case C.Pow:case C.Abs:case C.Floor:case C.Ceil:case C.Round:case C.Sin:case C.Cos:case C.Atan:case C.Sqrt:return J_(s);case C.Case:return Q_(s);case C.Match:return em(s);case C.Interpolate:return tm(s);case C.ToString:return nm(s);default:throw new Error(`Unsupported operator ${t}`)}}function Z_(s,e){const t=s.operator,n=s.args.length,i=new Array(n);for(let r=0;r<n;++r)i[r]=vt(s.args[r]);switch(t){case C.Coalesce:return r=>{for(let o=0;o<n;++o){const a=i[o](r);if(typeof a<"u"&&a!==null)return a}throw new Error("Expected one of the values to be non-null")};case C.Number:case C.String:return r=>{for(let o=0;o<n;++o){const a=i[o](r);if(typeof a===t)return a}throw new Error(`Expected one of the values to be a ${t}`)};default:throw new Error(`Unsupported assertion operator ${t}`)}}function K_(s,e){const n=s.args[0].value;switch(s.operator){case C.Get:return i=>{const r=s.args;let o=i.properties[n];for(let a=1,l=r.length;a<l;++a){const c=r[a].value;o=o[c]}return o};case C.Var:return i=>i.variables[n];case C.Has:return i=>{const r=s.args;if(!(n in i.properties))return!1;let o=i.properties[n];for(let a=1,l=r.length;a<l;++a){const c=r[a].value;if(!o||!Object.hasOwn(o,c))return!1;o=o[c]}return!0};default:throw new Error(`Unsupported accessor operator ${s.operator}`)}}function H_(s,e){const t=s.operator,n=vt(s.args[0]),i=vt(s.args[1]);switch(t){case C.Equal:return r=>n(r)===i(r);case C.NotEqual:return r=>n(r)!==i(r);case C.LessThan:return r=>n(r)<i(r);case C.LessThanOrEqualTo:return r=>n(r)<=i(r);case C.GreaterThan:return r=>n(r)>i(r);case C.GreaterThanOrEqualTo:return r=>n(r)>=i(r);default:throw new Error(`Unsupported comparison operator ${t}`)}}function q_(s,e){const t=s.operator,n=s.args.length,i=new Array(n);for(let r=0;r<n;++r)i[r]=vt(s.args[r]);switch(t){case C.Any:return r=>{for(let o=0;o<n;++o)if(i[o](r))return!0;return!1};case C.All:return r=>{for(let o=0;o<n;++o)if(!i[o](r))return!1;return!0};case C.Between:return r=>{const o=i[0](r),a=i[1](r),l=i[2](r);return o>=a&&o<=l};case C.In:return r=>{const o=i[0](r);for(let a=1;a<n;++a)if(o===i[a](r))return!0;return!1};case C.Not:return r=>!i[0](r);default:throw new Error(`Unsupported logical operator ${t}`)}}function J_(s,e){const t=s.operator,n=s.args.length,i=new Array(n);for(let r=0;r<n;++r)i[r]=vt(s.args[r]);switch(t){case C.Multiply:return r=>{let o=1;for(let a=0;a<n;++a)o*=i[a](r);return o};case C.Divide:return r=>i[0](r)/i[1](r);case C.Add:return r=>{let o=0;for(let a=0;a<n;++a)o+=i[a](r);return o};case C.Subtract:return r=>i[0](r)-i[1](r);case C.Clamp:return r=>{const o=i[0](r),a=i[1](r);if(o<a)return a;const l=i[2](r);return o>l?l:o};case C.Mod:return r=>i[0](r)%i[1](r);case C.Pow:return r=>Math.pow(i[0](r),i[1](r));case C.Abs:return r=>Math.abs(i[0](r));case C.Floor:return r=>Math.floor(i[0](r));case C.Ceil:return r=>Math.ceil(i[0](r));case C.Round:return r=>Math.round(i[0](r));case C.Sin:return r=>Math.sin(i[0](r));case C.Cos:return r=>Math.cos(i[0](r));case C.Atan:return n===2?r=>Math.atan2(i[0](r),i[1](r)):r=>Math.atan(i[0](r));case C.Sqrt:return r=>Math.sqrt(i[0](r));default:throw new Error(`Unsupported numeric operator ${t}`)}}function Q_(s,e){const t=s.args.length,n=new Array(t);for(let i=0;i<t;++i)n[i]=vt(s.args[i]);return i=>{for(let r=0;r<t-1;r+=2)if(n[r](i))return n[r+1](i);return n[t-1](i)}}function em(s,e){const t=s.args.length,n=new Array(t);for(let i=0;i<t;++i)n[i]=vt(s.args[i]);return i=>{const r=n[0](i);for(let o=1;o<t-1;o+=2)if(r===n[o](i))return n[o+1](i);return n[t-1](i)}}function tm(s,e){const t=s.args.length,n=new Array(t);for(let i=0;i<t;++i)n[i]=vt(s.args[i]);return i=>{const r=n[0](i),o=n[1](i);let a,l;for(let h=2;h<t;h+=2){const c=n[h](i);let u=n[h+1](i);const d=Array.isArray(u);if(d&&(u=b_(u)),c>=o)return h===2?u:d?im(r,o,a,l,c,u):us(r,o,a,l,c,u);a=c,l=u}return l}}function nm(s,e){const t=s.operator,n=s.args.length,i=new Array(n);for(let r=0;r<n;++r)i[r]=vt(s.args[r]);switch(t){case C.ToString:return r=>{const o=i[0](r);return s.args[0].type===ge?Al(o):o.toString()};default:throw new Error(`Unsupported convert operator ${t}`)}}function us(s,e,t,n,i,r){const o=i-t;if(o===0)return n;const a=e-t,l=s===1?a/o:(Math.pow(s,a)-1)/(Math.pow(s,o)-1);return n+l*(r-n)}function im(s,e,t,n,i,r){if(i-t===0)return n;const a=Uh(n),l=Uh(r);let h=l[2]-a[2];h>180?h-=360:h<-180&&(h+=360);const c=[us(s,e,t,a[0],i,l[0]),us(s,e,t,a[1],i,l[1]),a[2]+us(s,e,t,0,i,h),us(s,e,t,n[3],i,r[3])];return M_(c)}const U={IDLE:0,LOADING:1,LOADED:2,ERROR:3,EMPTY:4};class sm extends Ms{constructor(e,t,n,i){super(),this.extent=e,this.pixelRatio_=n,this.resolution=t,this.state=typeof i=="function"?U.IDLE:i,this.image_=null,this.loader=typeof i=="function"?i:null}changed(){this.dispatchEvent(V.CHANGE)}getExtent(){return this.extent}getImage(){return this.image_}getPixelRatio(){return this.pixelRatio_}getResolution(){return this.resolution}getState(){return this.state}load(){if(this.state==U.IDLE&&this.loader){this.state=U.LOADING,this.changed();const e=this.getResolution(),t=Array.isArray(e)?e[0]:e;Dc(()=>this.loader(this.getExtent(),t,this.getPixelRatio())).then(n=>{"image"in n&&(this.image_=n.image),"extent"in n&&(this.extent=n.extent),"resolution"in n&&(this.resolution=n.resolution),"pixelRatio"in n&&(this.pixelRatio_=n.pixelRatio),(n instanceof HTMLImageElement||mf&&n instanceof ImageBitmap||n instanceof HTMLCanvasElement||n instanceof HTMLVideoElement)&&(this.image_=n),this.state=U.LOADED}).catch(n=>{this.state=U.ERROR,console.error(n)}).finally(()=>this.changed())}}setImage(e){this.image_=e}setResolution(e){this.resolution=e}}function rm(s,e,t){const n=s;let i=!0,r=!1,o=!1;const a=[Sr(n,V.LOAD,function(){o=!0,r||e()})];return n.src&&Nc?(r=!0,n.decode().then(function(){i&&e()}).catch(function(l){i&&(o?e():t())})):a.push(Sr(n,V.ERROR,t)),function(){i=!1,a.forEach(ue)}}function om(s,e){return new Promise((t,n)=>{function i(){o(),t(s)}function r(){o(),n(new Error("Image load error"))}function o(){s.removeEventListener("load",i),s.removeEventListener("error",r)}s.addEventListener("load",i),s.addEventListener("error",r)})}function am(s,e){return e&&(s.src=e),s.src&&Nc?new Promise((t,n)=>s.decode().then(()=>t(s)).catch(i=>s.complete&&s.width?t(s):n(i))):om(s)}class lm{constructor(){this.cache_={},this.patternCache_={},this.cacheSize_=0,this.maxCacheSize_=1024}clear(){this.cache_={},this.patternCache_={},this.cacheSize_=0}canExpireCache(){return this.cacheSize_>this.maxCacheSize_}expire(){if(this.canExpireCache()){let e=0;for(const t in this.cache_){const n=this.cache_[t];(e++&3)===0&&!n.hasListener()&&(delete this.cache_[t],delete this.patternCache_[t],--this.cacheSize_)}}}get(e,t,n){const i=Xo(e,t,n);return i in this.cache_?this.cache_[i]:null}getPattern(e,t,n){const i=Xo(e,t,n);return i in this.patternCache_?this.patternCache_[i]:null}set(e,t,n,i,r){const o=Xo(e,t,n),a=o in this.cache_;this.cache_[o]=i,r&&(i.getImageState()===U.IDLE&&i.load(),i.getImageState()===U.LOADING?i.ready().then(()=>{this.patternCache_[o]=Fr().createPattern(i.getImage(1),"repeat")}):this.patternCache_[o]=Fr().createPattern(i.getImage(1),"repeat")),a||++this.cacheSize_}setSize(e){this.maxCacheSize_=e,this.expire()}}function Xo(s,e,t){const n=t?Et(t):"null";return e+":"+s+":"+n}const mt=new lm;let rs=null;class wu extends Ms{constructor(e,t,n,i,r){super(),this.hitDetectionImage_=null,this.image_=e,this.crossOrigin_=n,this.canvas_={},this.color_=r,this.imageState_=i===void 0?U.IDLE:i,this.size_=e&&e.width&&e.height?[e.width,e.height]:null,this.src_=t,this.tainted_,this.ready_=null}initializeImage_(){this.image_=new Image,this.crossOrigin_!==null&&(this.image_.crossOrigin=this.crossOrigin_)}isTainted_(){if(this.tainted_===void 0&&this.imageState_===U.LOADED){rs||(rs=ve(1,1,void 0,{willReadFrequently:!0})),rs.drawImage(this.image_,0,0);try{rs.getImageData(0,0,1,1),this.tainted_=!1}catch{rs=null,this.tainted_=!0}}return this.tainted_===!0}dispatchChangeEvent_(){this.dispatchEvent(V.CHANGE)}handleImageError_(){this.imageState_=U.ERROR,this.dispatchChangeEvent_()}handleImageLoad_(){this.imageState_=U.LOADED,this.size_=[this.image_.width,this.image_.height],this.dispatchChangeEvent_()}getImage(e){return this.image_||this.initializeImage_(),this.replaceColor_(e),this.canvas_[e]?this.canvas_[e]:this.image_}getPixelRatio(e){return this.replaceColor_(e),this.canvas_[e]?e:1}getImageState(){return this.imageState_}getHitDetectionImage(){if(this.image_||this.initializeImage_(),!this.hitDetectionImage_)if(this.isTainted_()){const e=this.size_[0],t=this.size_[1],n=ve(e,t);n.fillRect(0,0,e,t),this.hitDetectionImage_=n.canvas}else this.hitDetectionImage_=this.image_;return this.hitDetectionImage_}getSize(){return this.size_}getSrc(){return this.src_}load(){if(this.imageState_===U.IDLE){this.image_||this.initializeImage_(),this.imageState_=U.LOADING;try{this.src_!==void 0&&(this.image_.src=this.src_)}catch{this.handleImageError_()}this.image_ instanceof HTMLImageElement&&am(this.image_,this.src_).then(e=>{this.image_=e,this.handleImageLoad_()}).catch(this.handleImageError_.bind(this))}}replaceColor_(e){if(!this.color_||this.canvas_[e]||this.imageState_!==U.LOADED)return;const t=this.image_,n=ve(Math.ceil(t.width*e),Math.ceil(t.height*e)),i=n.canvas;n.scale(e,e),n.drawImage(t,0,0),n.globalCompositeOperation="multiply",n.fillStyle=A_(this.color_),n.fillRect(0,0,i.width/e,i.height/e),n.globalCompositeOperation="destination-in",n.drawImage(t,0,0),this.canvas_[e]=i}ready(){return this.ready_||(this.ready_=new Promise(e=>{if(this.imageState_===U.LOADED||this.imageState_===U.ERROR)e();else{const t=()=>{(this.imageState_===U.LOADED||this.imageState_===U.ERROR)&&(this.removeEventListener(V.CHANGE,t),e())};this.addEventListener(V.CHANGE,t)}})),this.ready_}}function Dr(s,e,t,n,i,r){let o=e===void 0?void 0:mt.get(e,t,i);return o||(o=new wu(s,s&&"src"in s?s.src||void 0:e,t,n,i),mt.set(e,t,i,o,r)),r&&o&&!mt.getPattern(e,t,i)&&mt.set(e,t,i,o,r),o}function Dt(s){return s?Array.isArray(s)?Al(s):typeof s=="object"&&"src"in s?hm(s):s:null}function hm(s){if(!s.offset||!s.size)return mt.getPattern(s.src,"anonymous",s.color);const e=s.src+":"+s.offset,t=mt.getPattern(e,void 0,s.color);if(t)return t;const n=mt.get(s.src,"anonymous",null);if(n.getImageState()!==U.LOADED)return null;const i=ve(s.size[0],s.size[1]);return i.drawImage(n.getImage(1),s.offset[0],s.offset[1],s.size[0],s.size[1],0,0,s.size[0],s.size[1]),Dr(i.canvas,e,void 0,U.LOADED,s.color,!0),mt.getPattern(e,void 0,s.color)}const Pu="10px sans-serif",Ke="#000",Ui="round",tn=[],nn=0,Bi="round",vs=10,ws="#000",Ps="center",Or="middle",zn=[0,0,0,0],Is=1,Ci=new It;let os=null,Wh;const Aa={},cm=new Set(["serif","sans-serif","monospace","cursive","fantasy","system-ui","ui-serif","ui-sans-serif","ui-monospace","ui-rounded","emoji","math","fangsong"]);function um(s,e,t){return`${s} ${e} 16px "${t}"`}const dm=(function(){let e,t;async function n(r){await t.ready;const o=await t.load(r);if(o.length===0)return!1;const a=Pa(r),l=a.families[0].toLowerCase(),h=a.weight;return o.some(c=>{const u=c.family.replace(/^['"]|['"]$/g,"").toLowerCase(),d=wa[c.weight]||c.weight;return u===l&&c.style===a.style&&d==h})}async function i(){await t.ready;let r=!0;const o=Ci.getProperties(),a=Object.keys(o).filter(l=>o[l]<100);for(let l=a.length-1;l>=0;--l){const h=a[l];let c=o[h];c<100&&(await n(h)?(Qn(Aa),Ci.set(h,100)):(c+=10,Ci.set(h,c,!0),c<100&&(r=!1)))}e=void 0,r||(e=setTimeout(i,100))}return async function(r){t||(t=rt?self.fonts:document.fonts);const o=Pa(r);if(!o)return;const a=o.families;let l=!1;for(const h of a){if(cm.has(h))continue;const c=um(o.style,o.weight,h);Ci.get(c)===void 0&&(Ci.set(c,0,!0),l=!0)}l&&(clearTimeout(e),e=setTimeout(i,100))}})(),fm=(function(){let s;return function(e){let t=Aa[e];if(t==null){if(rt){const n=Pa(e),i=Iu(e,"Žg");t=(isNaN(Number(n.lineHeight))?1.2:Number(n.lineHeight))*(i.actualBoundingBoxAscent+i.actualBoundingBoxDescent)}else s||(s=document.createElement("div"),s.innerHTML="M",s.style.minHeight="0",s.style.maxHeight="none",s.style.height="auto",s.style.padding="0",s.style.border="none",s.style.position="absolute",s.style.display="block",s.style.left="-99999px"),s.style.font=e,document.body.appendChild(s),t=s.offsetHeight,document.body.removeChild(s);Aa[e]=t}return t}})();function Iu(s,e){return os||(os=ve(1,1)),s!=Wh&&(os.font=s,Wh=os.font),os.measureText(e)}function Lu(s,e){return Iu(s,e).width}function Yh(s,e,t){if(e in t)return t[e];const n=e.split(`
|
||
`).reduce((i,r)=>Math.max(i,Lu(s,r)),0);return t[e]=n,n}function gm(s,e){const t=[],n=[],i=[];let r=0,o=0,a=0,l=0;for(let h=0,c=e.length;h<=c;h+=2){const u=e[h];if(u===`
|
||
`||h===c){r=Math.max(r,o),i.push(o),o=0,a+=l,l=0;continue}const d=e[h+1]||s.font,f=Lu(d,u);t.push(f),o+=f;const g=fm(d);n.push(g),l=Math.max(l,g)}return{width:r,height:a,widths:t,heights:n,lineWidths:i}}function _m(s,e,t,n,i,r,o,a,l,h,c){s.save(),t!==1&&(s.globalAlpha===void 0?s.globalAlpha=u=>u.globalAlpha*=t:s.globalAlpha*=t),e&&s.transform.apply(s,e),n.contextInstructions?(s.translate(l,h),s.scale(c[0],c[1]),mm(n,s)):c[0]<0||c[1]<0?(s.translate(l,h),s.scale(c[0],c[1]),s.drawImage(n,i,r,o,a,0,0,o,a)):s.drawImage(n,i,r,o,a,l,h,o*c[0],a*c[1]),s.restore()}function mm(s,e){const t=s.contextInstructions;for(let n=0,i=t.length;n<i;n+=2)Array.isArray(t[n+1])?e[t[n]].apply(e,t[n+1]):e[t[n]]=t[n+1]}class lo{constructor(e){this.opacity_=e.opacity,this.rotateWithView_=e.rotateWithView,this.rotation_=e.rotation,this.scale_=e.scale,this.scaleArray_=$e(e.scale),this.displacement_=e.displacement,this.declutterMode_=e.declutterMode}clone(){const e=this.getScale();return new lo({opacity:this.getOpacity(),scale:Array.isArray(e)?e.slice():e,rotation:this.getRotation(),rotateWithView:this.getRotateWithView(),displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()})}getOpacity(){return this.opacity_}getRotateWithView(){return this.rotateWithView_}getRotation(){return this.rotation_}getScale(){return this.scale_}getScaleArray(){return this.scaleArray_}getDisplacement(){return this.displacement_}getDeclutterMode(){return this.declutterMode_}getAnchor(){return $()}getImage(e){return $()}getHitDetectionImage(){return $()}getPixelRatio(e){return 1}getImageState(){return $()}getImageSize(){return $()}getOrigin(){return $()}getSize(){return $()}setDisplacement(e){this.displacement_=e}setOpacity(e){this.opacity_=e}setRotateWithView(e){this.rotateWithView_=e}setRotation(e){this.rotation_=e}setScale(e){this.scale_=e,this.scaleArray_=$e(e)}listenImageChange(e){$()}load(){$()}unlistenImageChange(e){$()}ready(){return Promise.resolve()}}class ho extends lo{constructor(e){super({opacity:1,rotateWithView:e.rotateWithView!==void 0?e.rotateWithView:!1,rotation:e.rotation!==void 0?e.rotation:0,scale:e.scale!==void 0?e.scale:1,displacement:e.displacement!==void 0?e.displacement:[0,0],declutterMode:e.declutterMode}),this.hitDetectionCanvas_=null,this.fill_=e.fill!==void 0?e.fill:null,this.origin_=[0,0],this.points_=e.points,this.radius=e.radius,this.radius2_=e.radius2,this.angle_=e.angle!==void 0?e.angle:0,this.stroke_=e.stroke!==void 0?e.stroke:null,this.size_,this.renderOptions_,this.imageState_=this.fill_&&this.fill_.loading()?U.LOADING:U.LOADED,this.imageState_===U.LOADING&&this.ready().then(()=>this.imageState_=U.LOADED),this.render()}clone(){const e=this.getScale(),t=new ho({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(e)?e.slice():e,displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()});return t.setOpacity(this.getOpacity()),t}getAnchor(){const e=this.size_,t=this.getDisplacement(),n=this.getScaleArray();return[e[0]/2-t[0]/n[0],e[1]/2+t[1]/n[1]]}getAngle(){return this.angle_}getFill(){return this.fill_}setFill(e){this.fill_=e,this.render()}getHitDetectionImage(){return this.hitDetectionCanvas_||(this.hitDetectionCanvas_=this.createHitDetectionCanvas_(this.renderOptions_)),this.hitDetectionCanvas_}getImage(e){const t=this.fill_?.getKey(),n=`${e},${this.angle_},${this.radius},${this.radius2_},${this.points_},${t}`+Object.values(this.renderOptions_).join(",");let i=mt.get(n,null,null)?.getImage(1);if(!i){const r=this.renderOptions_,o=Math.ceil(r.size*e),a=ve(o,o);this.draw_(r,a,e),i=a.canvas,mt.set(n,null,null,new wu(i,void 0,null,U.LOADED,null))}return i}getPixelRatio(e){return e}getImageSize(){return this.size_}getImageState(){return this.imageState_}getOrigin(){return this.origin_}getPoints(){return this.points_}getRadius(){return this.radius}getRadius2(){return this.radius2_}getSize(){return this.size_}getStroke(){return this.stroke_}setStroke(e){this.stroke_=e,this.render()}listenImageChange(e){}load(){}unlistenImageChange(e){}calculateLineJoinSize_(e,t,n){if(t===0||this.points_===1/0||e!=="bevel"&&e!=="miter")return t;let i=this.radius,r=this.radius2_===void 0?i:this.radius2_;if(i<r){const R=i;i=r,r=R}const o=this.radius2_===void 0?this.points_:this.points_*2,a=2*Math.PI/o,l=r*Math.sin(a),h=Math.sqrt(r*r-l*l),c=i-h,u=Math.sqrt(l*l+c*c),d=u/l;if(e==="miter"&&d<=n)return d*t;const f=t/2/d,g=t/2*(c/u),_=Math.sqrt((i+f)*(i+f)+g*g)-i;if(this.radius2_===void 0||e==="bevel")return _*2;const p=i*Math.sin(a),y=Math.sqrt(i*i-p*p),E=r-y,T=Math.sqrt(p*p+E*E)/p;if(T<=n){const R=T*t/2-r-i;return 2*Math.max(_,R)}return _*2}createRenderOptions(){let e=Ui,t=Bi,n=0,i=null,r=0,o,a=0;this.stroke_&&(o=Dt(this.stroke_.getColor()??ws),a=this.stroke_.getWidth()??Is,i=this.stroke_.getLineDash(),r=this.stroke_.getLineDashOffset()??0,t=this.stroke_.getLineJoin()??Bi,e=this.stroke_.getLineCap()??Ui,n=this.stroke_.getMiterLimit()??vs);const l=this.calculateLineJoinSize_(t,a,n),h=Math.max(this.radius,this.radius2_||0),c=Math.ceil(2*h+l);return{strokeStyle:o,strokeWidth:a,size:c,lineCap:e,lineDash:i,lineDashOffset:r,lineJoin:t,miterLimit:n}}render(){this.renderOptions_=this.createRenderOptions();const e=this.renderOptions_.size;this.hitDetectionCanvas_=null,this.size_=[e,e]}draw_(e,t,n){if(t.scale(n,n),t.translate(e.size/2,e.size/2),this.createPath_(t),this.fill_){let i=this.fill_.getColor();i===null&&(i=Ke),t.fillStyle=Dt(i),t.fill()}e.strokeStyle&&(t.strokeStyle=e.strokeStyle,t.lineWidth=e.strokeWidth,e.lineDash&&(t.setLineDash(e.lineDash),t.lineDashOffset=e.lineDashOffset),t.lineCap=e.lineCap,t.lineJoin=e.lineJoin,t.miterLimit=e.miterLimit,t.stroke())}createHitDetectionCanvas_(e){let t;if(this.fill_){let n=this.fill_.getColor(),i=0;typeof n=="string"&&(n=Et(n)),n===null?i=1:Array.isArray(n)&&(i=n.length===4?n[3]:1),i===0&&(t=ve(e.size,e.size),this.drawHitDetectionCanvas_(e,t))}return t?t.canvas:this.getImage(1)}createPath_(e){let t=this.points_;const n=this.radius;if(t===1/0)e.arc(0,0,n,0,2*Math.PI);else{const i=this.radius2_===void 0?n:this.radius2_;this.radius2_!==void 0&&(t*=2);const r=this.angle_-Math.PI/2,o=2*Math.PI/t;for(let a=0;a<t;a++){const l=r+a*o,h=a%2===0?n:i;e.lineTo(h*Math.cos(l),h*Math.sin(l))}e.closePath()}}drawHitDetectionCanvas_(e,t){t.translate(e.size/2,e.size/2),this.createPath_(t),t.fillStyle=Ke,t.fill(),e.strokeStyle&&(t.strokeStyle=e.strokeStyle,t.lineWidth=e.strokeWidth,e.lineDash&&(t.setLineDash(e.lineDash),t.lineDashOffset=e.lineDashOffset),t.lineJoin=e.lineJoin,t.miterLimit=e.miterLimit,t.stroke())}ready(){return this.fill_?this.fill_.ready():Promise.resolve()}}class Bs extends ho{constructor(e){e=e||{radius:5},super({points:1/0,fill:e.fill,radius:e.radius,stroke:e.stroke,scale:e.scale!==void 0?e.scale:1,rotation:e.rotation!==void 0?e.rotation:0,rotateWithView:e.rotateWithView!==void 0?e.rotateWithView:!1,displacement:e.displacement!==void 0?e.displacement:[0,0],declutterMode:e.declutterMode})}clone(){const e=this.getScale(),t=new Bs({fill:this.getFill()?this.getFill().clone():void 0,stroke:this.getStroke()?this.getStroke().clone():void 0,radius:this.getRadius(),scale:Array.isArray(e)?e.slice():e,rotation:this.getRotation(),rotateWithView:this.getRotateWithView(),displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()});return t.setOpacity(this.getOpacity()),t}setRadius(e){this.radius=e,this.render()}}class wt{constructor(e){e=e||{},this.patternImage_=null,this.color_=null,e.color!==void 0&&this.setColor(e.color)}clone(){const e=this.getColor();return new wt({color:Array.isArray(e)?e.slice():e||void 0})}getColor(){return this.color_}setColor(e){if(e!==null&&typeof e=="object"&&"src"in e){const t=Dr(null,e.src,"anonymous",void 0,e.offset?null:e.color?e.color:null,!(e.offset&&e.size));t.ready().then(()=>{this.patternImage_=null}),t.getImageState()===U.IDLE&&t.load(),t.getImageState()===U.LOADING&&(this.patternImage_=t)}this.color_=e}getKey(){const e=this.getColor();return e?e instanceof CanvasPattern||e instanceof CanvasGradient?D(e):typeof e=="object"&&"src"in e?e.src+":"+e.offset:Et(e).toString():""}loading(){return!!this.patternImage_}ready(){return this.patternImage_?this.patternImage_.ready():Promise.resolve()}}function jh(s,e,t,n){return t!==void 0&&n!==void 0?[t/s,n/e]:t!==void 0?t/s:n!==void 0?n/e:1}class Zi extends lo{constructor(e){e=e||{};const t=e.opacity!==void 0?e.opacity:1,n=e.rotation!==void 0?e.rotation:0,i=e.scale!==void 0?e.scale:1,r=e.rotateWithView!==void 0?e.rotateWithView:!1;super({opacity:t,rotation:n,scale:i,displacement:e.displacement!==void 0?e.displacement:[0,0],rotateWithView:r,declutterMode:e.declutterMode}),this.anchor_=e.anchor!==void 0?e.anchor:[.5,.5],this.normalizedAnchor_=null,this.anchorOrigin_=e.anchorOrigin!==void 0?e.anchorOrigin:"top-left",this.anchorXUnits_=e.anchorXUnits!==void 0?e.anchorXUnits:"fraction",this.anchorYUnits_=e.anchorYUnits!==void 0?e.anchorYUnits:"fraction",this.crossOrigin_=e.crossOrigin!==void 0?e.crossOrigin:null;const o=e.img!==void 0?e.img:null;let a=e.src;te(!(a!==void 0&&o),"`image` and `src` cannot be provided at the same time"),(a===void 0||a.length===0)&&o&&(a=o.src||D(o)),te(a!==void 0&&a.length>0,"A defined and non-empty `src` or `image` must be provided"),te(!((e.width!==void 0||e.height!==void 0)&&e.scale!==void 0),"`width` or `height` cannot be provided together with `scale`");let l;if(e.src!==void 0?l=U.IDLE:o!==void 0&&("complete"in o?o.complete?l=o.src?U.LOADED:U.IDLE:l=U.LOADING:l=U.LOADED),this.color_=e.color!==void 0?Et(e.color):null,this.iconImage_=Dr(o,a,this.crossOrigin_,l,this.color_),this.offset_=e.offset!==void 0?e.offset:[0,0],this.offsetOrigin_=e.offsetOrigin!==void 0?e.offsetOrigin:"top-left",this.origin_=null,this.size_=e.size!==void 0?e.size:null,this.initialOptions_,e.width!==void 0||e.height!==void 0){let h,c;if(e.size)[h,c]=e.size;else{const u=this.getImage(1);if(u.width&&u.height)h=u.width,c=u.height;else if(u instanceof HTMLImageElement){this.initialOptions_=e;const d=()=>{if(this.unlistenImageChange(d),!this.initialOptions_)return;const f=this.iconImage_.getSize();this.setScale(jh(f[0],f[1],e.width,e.height))};this.listenImageChange(d);return}}h!==void 0&&this.setScale(jh(h,c,e.width,e.height))}}clone(){let e,t,n;return this.initialOptions_?(t=this.initialOptions_.width,n=this.initialOptions_.height):(e=this.getScale(),e=Array.isArray(e)?e.slice():e),new Zi({anchor:this.anchor_.slice(),anchorOrigin:this.anchorOrigin_,anchorXUnits:this.anchorXUnits_,anchorYUnits:this.anchorYUnits_,color:this.color_&&this.color_.slice?this.color_.slice():this.color_||void 0,crossOrigin:this.crossOrigin_,offset:this.offset_.slice(),offsetOrigin:this.offsetOrigin_,opacity:this.getOpacity(),rotateWithView:this.getRotateWithView(),rotation:this.getRotation(),scale:e,width:t,height:n,size:this.size_!==null?this.size_.slice():void 0,src:this.getSrc(),displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()})}getAnchor(){let e=this.normalizedAnchor_;if(!e){e=this.anchor_;const i=this.getSize();if(this.anchorXUnits_=="fraction"||this.anchorYUnits_=="fraction"){if(!i)return null;e=this.anchor_.slice(),this.anchorXUnits_=="fraction"&&(e[0]*=i[0]),this.anchorYUnits_=="fraction"&&(e[1]*=i[1])}if(this.anchorOrigin_!="top-left"){if(!i)return null;e===this.anchor_&&(e=this.anchor_.slice()),(this.anchorOrigin_=="top-right"||this.anchorOrigin_=="bottom-right")&&(e[0]=-e[0]+i[0]),(this.anchorOrigin_=="bottom-left"||this.anchorOrigin_=="bottom-right")&&(e[1]=-e[1]+i[1])}this.normalizedAnchor_=e}const t=this.getDisplacement(),n=this.getScaleArray();return[e[0]-t[0]/n[0],e[1]+t[1]/n[1]]}setAnchor(e){this.anchor_=e,this.normalizedAnchor_=null}getColor(){return this.color_}getImage(e){return this.iconImage_.getImage(e)}getPixelRatio(e){return this.iconImage_.getPixelRatio(e)}getImageSize(){return this.iconImage_.getSize()}getImageState(){return this.iconImage_.getImageState()}getHitDetectionImage(){return this.iconImage_.getHitDetectionImage()}getOrigin(){if(this.origin_)return this.origin_;let e=this.offset_;if(this.offsetOrigin_!="top-left"){const t=this.getSize(),n=this.iconImage_.getSize();if(!t||!n)return null;e=e.slice(),(this.offsetOrigin_=="top-right"||this.offsetOrigin_=="bottom-right")&&(e[0]=n[0]-t[0]-e[0]),(this.offsetOrigin_=="bottom-left"||this.offsetOrigin_=="bottom-right")&&(e[1]=n[1]-t[1]-e[1])}return this.origin_=e,this.origin_}getSrc(){return this.iconImage_.getSrc()}setSrc(e){this.iconImage_=Dr(null,e,this.crossOrigin_,U.IDLE,this.color_)}getSize(){return this.size_?this.size_:this.iconImage_.getSize()}getWidth(){const e=this.getScaleArray();if(this.size_)return this.size_[0]*e[0];if(this.iconImage_.getImageState()==U.LOADED)return this.iconImage_.getSize()[0]*e[0]}getHeight(){const e=this.getScaleArray();if(this.size_)return this.size_[1]*e[1];if(this.iconImage_.getImageState()==U.LOADED)return this.iconImage_.getSize()[1]*e[1]}setScale(e){delete this.initialOptions_,super.setScale(e)}listenImageChange(e){this.iconImage_.addEventListener(V.CHANGE,e)}load(){this.iconImage_.load()}unlistenImageChange(e){this.iconImage_.removeEventListener(V.CHANGE,e)}ready(){return this.iconImage_.ready()}}class Gt{constructor(e){e=e||{},this.color_=e.color!==void 0?e.color:null,this.lineCap_=e.lineCap,this.lineDash_=e.lineDash!==void 0?e.lineDash:null,this.lineDashOffset_=e.lineDashOffset,this.lineJoin_=e.lineJoin,this.miterLimit_=e.miterLimit,this.width_=e.width}clone(){const e=this.getColor();return new Gt({color:Array.isArray(e)?e.slice():e||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(e){this.color_=e}setLineCap(e){this.lineCap_=e}setLineDash(e){this.lineDash_=e}setLineDashOffset(e){this.lineDashOffset_=e}setLineJoin(e){this.lineJoin_=e}setMiterLimit(e){this.miterLimit_=e}setWidth(e){this.width_=e}}class Oe{constructor(e){e=e||{},this.geometry_=null,this.geometryFunction_=Vh,e.geometry!==void 0&&this.setGeometry(e.geometry),this.fill_=e.fill!==void 0?e.fill:null,this.image_=e.image!==void 0?e.image:null,this.renderer_=e.renderer!==void 0?e.renderer:null,this.hitDetectionRenderer_=e.hitDetectionRenderer!==void 0?e.hitDetectionRenderer:null,this.stroke_=e.stroke!==void 0?e.stroke:null,this.text_=e.text!==void 0?e.text:null,this.zIndex_=e.zIndex}clone(){let e=this.getGeometry();return e&&typeof e=="object"&&(e=e.clone()),new Oe({geometry:e??void 0,fill:this.getFill()?this.getFill().clone():void 0,image:this.getImage()?this.getImage().clone():void 0,renderer:this.getRenderer()??void 0,stroke:this.getStroke()?this.getStroke().clone():void 0,text:this.getText()?this.getText().clone():void 0,zIndex:this.getZIndex()})}getRenderer(){return this.renderer_}setRenderer(e){this.renderer_=e}setHitDetectionRenderer(e){this.hitDetectionRenderer_=e}getHitDetectionRenderer(){return this.hitDetectionRenderer_}getGeometry(){return this.geometry_}getGeometryFunction(){return this.geometryFunction_}getFill(){return this.fill_}setFill(e){this.fill_=e}getImage(){return this.image_}setImage(e){this.image_=e}getStroke(){return this.stroke_}setStroke(e){this.stroke_=e}getText(){return this.text_}setText(e){this.text_=e}getZIndex(){return this.zIndex_}setGeometry(e){typeof e=="function"?this.geometryFunction_=e:typeof e=="string"?this.geometryFunction_=function(t){return t.get(e)}:e?e!==void 0&&(this.geometryFunction_=function(){return e}):this.geometryFunction_=Vh,this.geometry_=e}setZIndex(e){this.zIndex_=e}}function pm(s){let e;if(typeof s=="function")e=s;else{let t;Array.isArray(s)?t=s:(te(typeof s.getZIndex=="function","Expected an `Style` or an array of `Style`"),t=[s]),e=function(){return t}}return e}let Wo=null;function Au(s,e){if(!Wo){const t=new wt({color:"rgba(255,255,255,0.4)"}),n=new Gt({color:"#3399CC",width:1.25});Wo=[new Oe({image:new Bs({fill:t,stroke:n,radius:5}),fill:t,stroke:n})]}return Wo}function Dl(){const s={},e=[255,255,255,1],t=[0,153,255,1],n=3;return s.Polygon=[new Oe({fill:new wt({color:[255,255,255,.5]})})],s.MultiPolygon=s.Polygon,s.LineString=[new Oe({stroke:new Gt({color:e,width:n+2})}),new Oe({stroke:new Gt({color:t,width:n})})],s.MultiLineString=s.LineString,s.Circle=s.Polygon.concat(s.LineString),s.Point=[new Oe({image:new Bs({radius:n*2,fill:new wt({color:t}),stroke:new Gt({color:e,width:n/2})}),zIndex:1/0})],s.MultiPoint=s.Point,s.GeometryCollection=s.Polygon.concat(s.LineString,s.Point),s}function Vh(s){return s.getGeometry()}const ym="#333";class zs{constructor(e){e=e||{},this.font_=e.font,this.rotation_=e.rotation,this.rotateWithView_=e.rotateWithView,this.keepUpright_=e.keepUpright,this.scale_=e.scale,this.scaleArray_=$e(e.scale!==void 0?e.scale:1),this.text_=e.text,this.textAlign_=e.textAlign,this.justify_=e.justify,this.repeat_=e.repeat,this.textBaseline_=e.textBaseline,this.fill_=e.fill!==void 0?e.fill:new wt({color:ym}),this.maxAngle_=e.maxAngle!==void 0?e.maxAngle:Math.PI/4,this.placement_=e.placement!==void 0?e.placement:"point",this.overflow_=!!e.overflow,this.stroke_=e.stroke!==void 0?e.stroke:null,this.offsetX_=e.offsetX!==void 0?e.offsetX:0,this.offsetY_=e.offsetY!==void 0?e.offsetY:0,this.backgroundFill_=e.backgroundFill?e.backgroundFill:null,this.backgroundStroke_=e.backgroundStroke?e.backgroundStroke:null,this.padding_=e.padding===void 0?null:e.padding,this.declutterMode_=e.declutterMode}clone(){const e=this.getScale();return new zs({font:this.getFont(),placement:this.getPlacement(),repeat:this.getRepeat(),maxAngle:this.getMaxAngle(),overflow:this.getOverflow(),rotation:this.getRotation(),rotateWithView:this.getRotateWithView(),keepUpright:this.getKeepUpright(),scale:Array.isArray(e)?e.slice():e,text:this.getText(),textAlign:this.getTextAlign(),justify:this.getJustify(),textBaseline:this.getTextBaseline(),fill:this.getFill()instanceof wt?this.getFill().clone():this.getFill(),stroke:this.getStroke()?this.getStroke().clone():void 0,offsetX:this.getOffsetX(),offsetY:this.getOffsetY(),backgroundFill:this.getBackgroundFill()?this.getBackgroundFill().clone():void 0,backgroundStroke:this.getBackgroundStroke()?this.getBackgroundStroke().clone():void 0,padding:this.getPadding()||void 0,declutterMode:this.getDeclutterMode()})}getOverflow(){return this.overflow_}getFont(){return this.font_}getMaxAngle(){return this.maxAngle_}getPlacement(){return this.placement_}getRepeat(){return this.repeat_}getOffsetX(){return this.offsetX_}getOffsetY(){return this.offsetY_}getFill(){return this.fill_}getRotateWithView(){return this.rotateWithView_}getKeepUpright(){return this.keepUpright_}getRotation(){return this.rotation_}getScale(){return this.scale_}getScaleArray(){return this.scaleArray_}getStroke(){return this.stroke_}getText(){return this.text_}getTextAlign(){return this.textAlign_}getJustify(){return this.justify_}getTextBaseline(){return this.textBaseline_}getBackgroundFill(){return this.backgroundFill_}getBackgroundStroke(){return this.backgroundStroke_}getPadding(){return this.padding_}getDeclutterMode(){return this.declutterMode_}setOverflow(e){this.overflow_=e}setFont(e){this.font_=e}setMaxAngle(e){this.maxAngle_=e}setOffsetX(e){this.offsetX_=e}setOffsetY(e){this.offsetY_=e}setPlacement(e){this.placement_=e}setRepeat(e){this.repeat_=e}setRotateWithView(e){this.rotateWithView_=e}setKeepUpright(e){this.keepUpright_=e}setFill(e){this.fill_=e}setRotation(e){this.rotation_=e}setScale(e){this.scale_=e,this.scaleArray_=$e(e!==void 0?e:1)}setStroke(e){this.stroke_=e}setText(e){this.text_=e}setTextAlign(e){this.textAlign_=e}setJustify(e){this.justify_=e}setTextBaseline(e){this.textBaseline_=e}setBackgroundFill(e){this.backgroundFill_=e}setBackgroundStroke(e){this.backgroundStroke_=e}setPadding(e){this.padding_=e}}function xm(s){return!0}function Em(s){const e=bl(),t=Tm(s,e),n=vu();return function(i,r){if(n.properties=i.getPropertiesInternal(),n.resolution=r,e.featureId){const o=i.getId();o!==void 0?n.featureId=o:n.featureId=null}return e.geometryType&&(n.geometryType=Ml(i.getGeometry())),t(n)}}function Zh(s){const e=bl(),t=s.length,n=new Array(t);for(let o=0;o<t;++o)n[o]=Fa(s[o],e);const i=vu(),r=new Array(t);return function(o,a){if(i.properties=o.getPropertiesInternal(),i.resolution=a,e.featureId){const h=o.getId();h!==void 0?i.featureId=h:i.featureId=null}let l=0;for(let h=0;h<t;++h){const c=n[h](i);c&&(r[l]=c,l+=1)}return r.length=l,r}}function Tm(s,e){const t=s.length,n=new Array(t);for(let i=0;i<t;++i){const r=s[i],o="filter"in r?on(r.filter,Se,e):xm;let a;if(Array.isArray(r.style)){const l=r.style.length;a=new Array(l);for(let h=0;h<l;++h)a[h]=Fa(r.style[h],e)}else a=[Fa(r.style,e)];n[i]={filter:o,styles:a}}return function(i){const r=[];let o=!1;for(let a=0;a<t;++a){const l=n[a].filter;if(l(i)&&!(s[a].else&&o)){o=!0;for(const h of n[a].styles){const c=h(i);c&&r.push(c)}}}return r}}function Fa(s,e){const t=Ls(s,"",e),n=As(s,"",e),i=Cm(s,e),r=Rm(s,e),o=qe(s,"z-index",e);if(!t&&!n&&!i&&!r&&!jn(s))throw new Error("No fill, stroke, point, or text symbolizer properties in style: "+JSON.stringify(s));const a=new Oe;return function(l){let h=!0;if(t){const c=t(l);c&&(h=!1),a.setFill(c)}if(n){const c=n(l);c&&(h=!1),a.setStroke(c)}if(i){const c=i(l);c&&(h=!1),a.setText(c)}if(r){const c=r(l);c&&(h=!1),a.setImage(c)}return o&&a.setZIndex(o(l)),h?null:a}}function Ls(s,e,t){let n;if(e+"fill-pattern-src"in s)n=Pm(s,e+"fill-",t);else{if(s[e+"fill-color"]==="none")return r=>null;n=Ol(s,e+"fill-color",t)}if(!n)return null;const i=new wt;return function(r){const o=n(r);return o===Il?null:(i.setColor(o),i)}}function As(s,e,t){const n=qe(s,e+"stroke-width",t),i=Ol(s,e+"stroke-color",t);if(!n&&!i)return null;const r=Kt(s,e+"stroke-line-cap",t),o=Kt(s,e+"stroke-line-join",t),a=Fu(s,e+"stroke-line-dash",t),l=qe(s,e+"stroke-line-dash-offset",t),h=qe(s,e+"stroke-miter-limit",t),c=new Gt;return function(u){if(i){const d=i(u);if(d===Il)return null;c.setColor(d)}if(n&&c.setWidth(n(u)),r){const d=r(u);if(d!=="butt"&&d!=="round"&&d!=="square")throw new Error("Expected butt, round, or square line cap");c.setLineCap(d)}if(o){const d=o(u);if(d!=="bevel"&&d!=="round"&&d!=="miter")throw new Error("Expected bevel, round, or miter line join");c.setLineJoin(d)}return a&&c.setLineDash(a(u)),l&&c.setLineDashOffset(l(u)),h&&c.setMiterLimit(h(u)),c}}function Cm(s,e){const t="text-",n=Kt(s,t+"value",e);if(!n)return null;const i=Ls(s,t,e),r=Ls(s,t+"background-",e),o=As(s,t,e),a=As(s,t+"background-",e),l=Kt(s,t+"font",e),h=qe(s,t+"max-angle",e),c=qe(s,t+"offset-x",e),u=qe(s,t+"offset-y",e),d=Ai(s,t+"overflow",e),f=Kt(s,t+"placement",e),g=qe(s,t+"repeat",e),m=co(s,t+"scale",e),_=Ai(s,t+"rotate-with-view",e),p=qe(s,t+"rotation",e),y=Kt(s,t+"align",e),E=Kt(s,t+"justify",e),x=Kt(s,t+"baseline",e),T=Ai(s,t+"keep-upright",e),R=Fu(s,t+"padding",e),S=uo(s,t+"declutter-mode"),v=new zs({declutterMode:S});return function(w){if(v.setText(n(w)),i&&v.setFill(i(w)),r&&v.setBackgroundFill(r(w)),o&&v.setStroke(o(w)),a&&v.setBackgroundStroke(a(w)),l&&v.setFont(l(w)),h&&v.setMaxAngle(h(w)),c&&v.setOffsetX(c(w)),u&&v.setOffsetY(u(w)),d&&v.setOverflow(d(w)),f){const I=f(w);if(I!=="point"&&I!=="line")throw new Error("Expected point or line for text-placement");v.setPlacement(I)}if(g&&v.setRepeat(g(w)),m&&v.setScale(m(w)),_&&v.setRotateWithView(_(w)),p&&v.setRotation(p(w)),y){const I=y(w);if(I!=="left"&&I!=="center"&&I!=="right"&&I!=="end"&&I!=="start")throw new Error("Expected left, right, center, start, or end for text-align");v.setTextAlign(I)}if(E){const I=E(w);if(I!=="left"&&I!=="right"&&I!=="center")throw new Error("Expected left, right, or center for text-justify");v.setJustify(I)}if(x){const I=x(w);if(I!=="bottom"&&I!=="top"&&I!=="middle"&&I!=="alphabetic"&&I!=="hanging")throw new Error("Expected bottom, top, middle, alphabetic, or hanging for text-baseline");v.setTextBaseline(I)}return R&&v.setPadding(R(w)),T&&v.setKeepUpright(T(w)),v}}function Rm(s,e){return"icon-src"in s?Sm(s,e):"shape-points"in s?vm(s,e):"circle-radius"in s?wm(s,e):null}function Sm(s,e){const t="icon-",n=t+"src",i=bu(s[n],n),r=Nr(s,t+"anchor",e),o=co(s,t+"scale",e),a=qe(s,t+"opacity",e),l=Nr(s,t+"displacement",e),h=qe(s,t+"rotation",e),c=Ai(s,t+"rotate-with-view",e),u=Hh(s,t+"anchor-origin"),d=qh(s,t+"anchor-x-units"),f=qh(s,t+"anchor-y-units"),g=Fm(s,t+"color"),m=Lm(s,t+"cross-origin"),_=Am(s,t+"offset"),p=Hh(s,t+"offset-origin"),y=Gr(s,t+"width"),E=Gr(s,t+"height"),x=Im(s,t+"size"),T=uo(s,t+"declutter-mode"),R=new Zi({src:i,anchorOrigin:u,anchorXUnits:d,anchorYUnits:f,color:g,crossOrigin:m,offset:_,offsetOrigin:p,height:E,width:y,size:x,declutterMode:T});return function(S){return a&&R.setOpacity(a(S)),l&&R.setDisplacement(l(S)),h&&R.setRotation(h(S)),c&&R.setRotateWithView(c(S)),o&&R.setScale(o(S)),r&&R.setAnchor(r(S)),R}}function vm(s,e){const t="shape-",n=t+"points",i=t+"radius",r=ba(s[n],n),o=ba(s[i],i),a=Ls(s,t,e),l=As(s,t,e),h=co(s,t+"scale",e),c=Nr(s,t+"displacement",e),u=qe(s,t+"rotation",e),d=Ai(s,t+"rotate-with-view",e),f=Gr(s,t+"radius2"),g=Gr(s,t+"angle"),m=uo(s,t+"declutter-mode"),_=new ho({points:r,radius:o,radius2:f,angle:g,declutterMode:m});return function(p){return a&&_.setFill(a(p)),l&&_.setStroke(l(p)),c&&_.setDisplacement(c(p)),u&&_.setRotation(u(p)),d&&_.setRotateWithView(d(p)),h&&_.setScale(h(p)),_}}function wm(s,e){const t="circle-",n=Ls(s,t,e),i=As(s,t,e),r=qe(s,t+"radius",e),o=co(s,t+"scale",e),a=Nr(s,t+"displacement",e),l=qe(s,t+"rotation",e),h=Ai(s,t+"rotate-with-view",e),c=uo(s,t+"declutter-mode"),u=new Bs({radius:5,declutterMode:c});return function(d){return r&&u.setRadius(r(d)),n&&u.setFill(n(d)),i&&u.setStroke(i(d)),a&&u.setDisplacement(a(d)),l&&u.setRotation(l(d)),h&&u.setRotateWithView(h(d)),o&&u.setScale(o(d)),u}}function qe(s,e,t){if(!(e in s))return;const n=on(s[e],N,t);return function(i){return ba(n(i),e)}}function Kt(s,e,t){if(!(e in s))return null;const n=on(s[e],Pe,t);return function(i){return bu(n(i),e)}}function Pm(s,e,t){const n=Kt(s,e+"pattern-src",t),i=Kh(s,e+"pattern-offset",t),r=Kh(s,e+"pattern-size",t),o=Ol(s,e+"color",t);return function(a){return{src:n(a),offset:i&&i(a),size:r&&r(a),color:o&&o(a)}}}function Ai(s,e,t){if(!(e in s))return null;const n=on(s[e],Se,t);return function(i){const r=n(i);if(typeof r!="boolean")throw new Error(`Expected a boolean for ${e}`);return r}}function Ol(s,e,t){if(!(e in s))return null;const n=on(s[e],ge,t);return function(i){return Mu(n(i),e)}}function Fu(s,e,t){if(!(e in s))return null;const n=on(s[e],et,t);return function(i){return $s(n(i),e)}}function Nr(s,e,t){if(!(e in s))return null;const n=on(s[e],et,t);return function(i){const r=$s(n(i),e);if(r.length!==2)throw new Error(`Expected two numbers for ${e}`);return r}}function Kh(s,e,t){if(!(e in s))return null;const n=on(s[e],et,t);return function(i){return Du(n(i),e)}}function co(s,e,t){if(!(e in s))return null;const n=on(s[e],et|N,t);return function(i){return bm(n(i),e)}}function Gr(s,e){const t=s[e];if(t!==void 0){if(typeof t!="number")throw new Error(`Expected a number for ${e}`);return t}}function Im(s,e){const t=s[e];if(t!==void 0){if(typeof t=="number")return $e(t);if(!Array.isArray(t))throw new Error(`Expected a number or size array for ${e}`);if(t.length!==2||typeof t[0]!="number"||typeof t[1]!="number")throw new Error(`Expected a number or size array for ${e}`);return t}}function Lm(s,e){const t=s[e];if(t!==void 0){if(typeof t!="string")throw new Error(`Expected a string for ${e}`);return t}}function Hh(s,e){const t=s[e];if(t!==void 0){if(t!=="bottom-left"&&t!=="bottom-right"&&t!=="top-left"&&t!=="top-right")throw new Error(`Expected bottom-left, bottom-right, top-left, or top-right for ${e}`);return t}}function qh(s,e){const t=s[e];if(t!==void 0){if(t!=="pixels"&&t!=="fraction")throw new Error(`Expected pixels or fraction for ${e}`);return t}}function Am(s,e){const t=s[e];if(t!==void 0)return $s(t,e)}function uo(s,e){const t=s[e];if(t!==void 0){if(typeof t!="string")throw new Error(`Expected a string for ${e}`);if(t!=="declutter"&&t!=="obstacle"&&t!=="none")throw new Error(`Expected declutter, obstacle, or none for ${e}`);return t}}function Fm(s,e){const t=s[e];if(t!==void 0)return Mu(t,e)}function $s(s,e){if(!Array.isArray(s))throw new Error(`Expected an array for ${e}`);const t=s.length;for(let n=0;n<t;++n)if(typeof s[n]!="number")throw new Error(`Expected an array of numbers for ${e}`);return s}function bu(s,e){if(typeof s!="string")throw new Error(`Expected a string for ${e}`);return s}function ba(s,e){if(typeof s!="number")throw new Error(`Expected a number for ${e}`);return s}function Mu(s,e){if(typeof s=="string")return s;const t=$s(s,e),n=t.length;if(n<3||n>4)throw new Error(`Expected a color with 3 or 4 values for ${e}`);return t}function Du(s,e){const t=$s(s,e);if(t.length!==2)throw new Error(`Expected an array of two numbers for ${e}`);return t}function bm(s,e){return typeof s=="number"?s:Du(s,e)}const Jh={RENDER_ORDER:"renderOrder"};class Ki extends Us{constructor(e){e=e||{};const t=Object.assign({},e);delete t.style,delete t.renderBuffer,delete t.updateWhileAnimating,delete t.updateWhileInteracting,super(t),this.declutter_=e.declutter?String(e.declutter):void 0,this.renderBuffer_=e.renderBuffer!==void 0?e.renderBuffer:100,this.style_=null,this.styleFunction_=void 0,this.setStyle(e.style),this.updateWhileAnimating_=e.updateWhileAnimating!==void 0?e.updateWhileAnimating:!1,this.updateWhileInteracting_=e.updateWhileInteracting!==void 0?e.updateWhileInteracting:!1}getDeclutter(){return this.declutter_}getFeatures(e){return super.getFeatures(e)}getRenderBuffer(){return this.renderBuffer_}getRenderOrder(){return this.get(Jh.RENDER_ORDER)}getStyle(){return this.style_}getStyleFunction(){return this.styleFunction_}getUpdateWhileAnimating(){return this.updateWhileAnimating_}getUpdateWhileInteracting(){return this.updateWhileInteracting_}renderDeclutter(e,t){const n=this.getDeclutter();n in e.declutter||(e.declutter[n]=new Pl(9)),this.getRenderer().renderDeclutter(e,t)}setRenderOrder(e){this.set(Jh.RENDER_ORDER,e)}setStyle(e){this.style_=e===void 0?Au:e;const t=Mm(e);this.styleFunction_=e===null?void 0:pm(t),this.changed()}setDeclutter(e){this.declutter_=e?String(e):void 0,this.changed()}}function Mm(s){if(s===void 0)return Au;if(!s)return null;if(typeof s=="function"||s instanceof Oe)return s;if(!Array.isArray(s))return Zh([s]);if(s.length===0)return[];const e=s.length,t=s[0];if(t instanceof Oe){const i=new Array(e);for(let r=0;r<e;++r){const o=s[r];if(!(o instanceof Oe))throw new Error("Expected a list of style instances");i[r]=o}return i}if("style"in t){const i=new Array(e);for(let r=0;r<e;++r){const o=s[r];if(!("style"in o))throw new Error("Expected a list of rules with a style property");i[r]=o}return Em(i)}return Zh(s)}class _s extends Tt{constructor(e,t,n,i){super(e),this.inversePixelTransform=t,this.frameState=n,this.context=i}}class Dm extends bs{constructor(e){super(),this.map_=e}dispatchRenderEvent(e,t){$()}calculateMatrices2D(e){const t=e.viewState,n=e.coordinateToPixelTransform,i=e.pixelToCoordinateTransform;lt(n,e.size[0]/2,e.size[1]/2,1/t.resolution,-1/t.resolution,-t.rotation,-t.center[0],-t.center[1]),Cs(i,n)}forEachFeatureAtCoordinate(e,t,n,i,r,o,a,l){let h;const c=t.viewState;function u(x,T,R,S){return r.call(o,T,x?R:null,S)}const d=c.projection,f=el(e.slice(),d),g=[[0,0]];if(d.canWrapX()&&i){const x=d.getExtent(),T=ne(x);g.push([-T,0],[T,0])}const m=t.layerStatesArray,_=m.length,p=[],y=[];for(let x=0;x<g.length;x++)for(let T=_-1;T>=0;--T){const R=m[T],S=R.layer;if(S.hasRenderer()&&wl(R,c)&&a.call(l,S)){const v=S.getRenderer(),w=S.getSource();if(v&&w){const I=w.getWrapX()?f:e,F=u.bind(null,R.managed);y[0]=I[0]+g[x][0],y[1]=I[1]+g[x][1],h=v.forEachFeatureAtCoordinate(y,t,n,F,p)}if(h)return h}}if(p.length===0)return;const E=1/p.length;return p.forEach((x,T)=>x.distanceSq+=T*E),p.sort((x,T)=>x.distanceSq-T.distanceSq),p.some(x=>h=x.callback(x.feature,x.layer,x.geometry)),h}hasFeatureAtCoordinate(e,t,n,i,r,o){return this.forEachFeatureAtCoordinate(e,t,n,i,wn,this,r,o)!==void 0}getMap(){return this.map_}renderFrame(e){$()}scheduleExpireIconCache(e){mt.canExpireCache()&&e.postRenderFunctions.push(Om)}}function Om(s,e){mt.expire()}class Nm extends Dm{constructor(e){super(e),this.fontChangeListenerKey_=J(Ci,Oi.PROPERTYCHANGE,e.redrawText,e),this.element_=rt?_u():document.createElement("div");const t=this.element_.style;t.position="absolute",t.width="100%",t.height="100%",t.zIndex="0",this.element_.className=ks+" ol-layers";const n=e.getViewport();n&&n.insertBefore(this.element_,n.firstChild||null),this.children_=[],this.renderedVisible_=!0}dispatchRenderEvent(e,t){const n=this.getMap();if(n.hasListener(e)){const i=new _s(e,void 0,t);n.dispatchEvent(i)}}disposeInternal(){ue(this.fontChangeListenerKey_),this.element_.remove(),super.disposeInternal()}renderFrame(e){if(!e){this.renderedVisible_&&(this.element_.style.display="none",this.renderedVisible_=!1);return}this.calculateMatrices2D(e),this.dispatchRenderEvent(Fe.PRECOMPOSE,e);const t=e.layerStatesArray.sort((h,c)=>h.zIndex-c.zIndex);t.some(h=>h.layer instanceof Ki&&h.layer.getDeclutter())&&(e.declutter={});const i=e.viewState;this.children_.length=0;const r=[];let o=null;for(let h=0,c=t.length;h<c;++h){const u=t[h];e.layerIndex=h;const d=u.layer,f=d.getSourceState();if(!wl(u,i)||f!="ready"&&f!="undefined"){d.unrender();continue}const g=d.render(e,o);g&&(g!==o&&(this.children_.push(g),o=g),r.push(u))}this.declutter(e,r),Zg(this.element_,this.children_);const l=this.getMap().getTargetElement();if(xn(l)){const h=l.getContext("2d");for(const c of this.children_){const u=c.firstElementChild||c,d=c.style.backgroundColor;if(d&&(!xn(u)||u.width>0)&&(h.fillStyle=d,h.fillRect(0,0,l.width,l.height)),xn(u)&&u.width>0){const f=c.style.opacity||u.style.opacity;h.globalAlpha=f===""?1:Number(f);const g=u.style.transform;if(g)h.setTransform(...Ra(g));else{const m=parseFloat(u.style.width)/u.width,_=parseFloat(u.style.height)/u.height;h.setTransform(m,0,0,_,0,0)}h.drawImage(u,0,0)}}h.globalAlpha=1,h.setTransform(1,0,0,1,0,0)}this.dispatchRenderEvent(Fe.POSTCOMPOSE,e),this.renderedVisible_||(this.element_.style.display="",this.renderedVisible_=!0),this.scheduleExpireIconCache(e)}declutter(e,t){if(e.declutter){for(let n=t.length-1;n>=0;--n){const i=t[n],r=i.layer;r.getDeclutter()&&r.renderDeclutter(e,i)}t.forEach(n=>n.layer.renderDeferred(e))}}}function Ou(s){if(s instanceof Us){s.setMapInternal(null);return}s instanceof Vi&&s.getLayers().forEach(Ou)}function Nu(s,e){if(s instanceof Us){s.setMapInternal(e);return}if(s instanceof Vi){const t=s.getLayers().getArray();for(let n=0,i=t.length;n<i;++n)Nu(t[n],e)}}let w0=class extends It{constructor(e){super(),e=e||{},this.on,this.once,this.un;const t=Gm(e);this.renderComplete_=!1,this.loaded_=!0,this.boundHandleBrowserEvent_=this.handleBrowserEvent.bind(this),this.maxTilesLoading_=e.maxTilesLoading!==void 0?e.maxTilesLoading:16,this.pixelRatio_=e.pixelRatio!==void 0?e.pixelRatio:_f,this.postRenderTimeoutHandle_,this.animationDelayKey_,this.animationDelay_=this.animationDelay_.bind(this),this.coordinateToPixelTransform_=Te(),this.pixelToCoordinateTransform_=Te(),this.frameIndex_=0,this.frameState_=null,this.previousExtent_=null,this.viewPropertyListenerKey_=null,this.viewChangeListenerKey_=null,this.layerGroupPropertyListenerKeys_=null,rt||(this.viewport_=document.createElement("div"),this.viewport_.className="ol-viewport"+("ontouchstart"in window?" ol-touch":""),this.viewport_.style.position="relative",this.viewport_.style.overflow="hidden",this.viewport_.style.width="100%",this.viewport_.style.height="100%",this.overlayContainer_=document.createElement("div"),this.overlayContainer_.style.position="absolute",this.overlayContainer_.style.zIndex="0",this.overlayContainer_.style.width="100%",this.overlayContainer_.style.height="100%",this.overlayContainer_.style.pointerEvents="none",this.overlayContainer_.className="ol-overlaycontainer",this.viewport_.appendChild(this.overlayContainer_),this.overlayContainerStopEvent_=document.createElement("div"),this.overlayContainerStopEvent_.style.position="absolute",this.overlayContainerStopEvent_.style.zIndex="0",this.overlayContainerStopEvent_.style.width="100%",this.overlayContainerStopEvent_.style.height="100%",this.overlayContainerStopEvent_.style.pointerEvents="none",this.overlayContainerStopEvent_.className="ol-overlaycontainer-stopevent",this.viewport_.appendChild(this.overlayContainerStopEvent_)),this.mapBrowserEventHandler_=null,this.moveTolerance_=e.moveTolerance,this.keyboardEventTarget_=t.keyboardEventTarget,this.targetChangeHandlerKeys_=null,this.targetElement_=null,rt||(this.resizeObserver_=new ResizeObserver(()=>this.updateSize())),this.controls=t.controls||(rt?new Ve:Jg()),this.interactions=t.interactions||(rt?new Ve:y_({onFocusOnly:!0})),this.overlays_=t.overlays,this.overlayIdIndex_={},this.renderer_=null,this.postRenderFunctions_=[],this.tileQueue_=new xf(this.getTilePriority.bind(this),this.handleTileChange_.bind(this)),this.addChangeListener(Ue.LAYERGROUP,this.handleLayerGroupChanged_),this.addChangeListener(Ue.VIEW,this.handleViewChanged_),this.addChangeListener(Ue.SIZE,this.handleSizeChanged_),this.addChangeListener(Ue.TARGET,this.handleTargetChanged_),this.setProperties(t.values);const n=this;e.view&&!(e.view instanceof qt)&&e.view.then(function(i){n.setView(new qt(i))}),this.controls.addEventListener(Re.ADD,i=>{i.element.setMap(this)}),this.controls.addEventListener(Re.REMOVE,i=>{i.element.setMap(null)}),this.interactions.addEventListener(Re.ADD,i=>{i.element.setMap(this)}),this.interactions.addEventListener(Re.REMOVE,i=>{i.element.setMap(null)}),this.overlays_.addEventListener(Re.ADD,i=>{this.addOverlayInternal_(i.element)}),this.overlays_.addEventListener(Re.REMOVE,i=>{const r=i.element.getId();r!==void 0&&delete this.overlayIdIndex_[r.toString()],i.element.setMap(null)}),this.controls.forEach(i=>{i.setMap(this)}),this.interactions.forEach(i=>{i.setMap(this)}),this.overlays_.forEach(this.addOverlayInternal_.bind(this))}addControl(e){this.getControls().push(e)}addInteraction(e){this.getInteractions().push(e)}addLayer(e){this.getLayerGroup().getLayers().push(e)}handleLayerAdd_(e){Nu(e.layer,this)}addOverlay(e){this.getOverlays().push(e)}addOverlayInternal_(e){const t=e.getId();t!==void 0&&(this.overlayIdIndex_[t.toString()]=e),e.setMap(this)}disposeInternal(){this.controls.clear(),this.interactions.clear(),this.overlays_.clear(),this.resizeObserver_?.disconnect(),this.setTarget(null),super.disposeInternal()}forEachFeatureAtPixel(e,t,n){if(!this.frameState_||!this.renderer_)return;const i=this.getCoordinateFromPixelInternal(e);n=n!==void 0?n:{};const r=n.hitTolerance!==void 0?n.hitTolerance:0,o=n.layerFilter!==void 0?n.layerFilter:wn,a=n.checkWrapped!==!1;return this.renderer_.forEachFeatureAtCoordinate(i,this.frameState_,r,a,t,null,o,null)}getFeaturesAtPixel(e,t){const n=[];return this.forEachFeatureAtPixel(e,function(i){n.push(i)},t),n}getAllLayers(){const e=[];function t(n){n.forEach(function(i){i instanceof Vi?t(i.getLayers()):e.push(i)})}return t(this.getLayers()),e}hasFeatureAtPixel(e,t){if(!this.frameState_||!this.renderer_)return!1;const n=this.getCoordinateFromPixelInternal(e);t=t!==void 0?t:{};const i=t.layerFilter!==void 0?t.layerFilter:wn,r=t.hitTolerance!==void 0?t.hitTolerance:0,o=t.checkWrapped!==!1;return this.renderer_.hasFeatureAtCoordinate(n,this.frameState_,r,o,i,null)}getEventCoordinate(e){return this.getCoordinateFromPixel(this.getEventPixel(e))}getEventCoordinateInternal(e){return this.getCoordinateFromPixelInternal(this.getEventPixel(e))}getEventPixel(e){const n=this.viewport_.getBoundingClientRect(),i=this.getSize(),r=n.width/i[0],o=n.height/i[1],a="changedTouches"in e?e.changedTouches[0]:e;return[(a.clientX-n.left)/r,(a.clientY-n.top)/o]}getTarget(){return this.get(Ue.TARGET)}getTargetElement(){return this.targetElement_}getCoordinateFromPixel(e){return qn(this.getCoordinateFromPixelInternal(e),this.getView().getProjection())}getCoordinateFromPixelInternal(e){const t=this.frameState_;return t?de(t.pixelToCoordinateTransform,e.slice()):null}getControls(){return this.controls}getOverlays(){return this.overlays_}getOverlayById(e){const t=this.overlayIdIndex_[e.toString()];return t!==void 0?t:null}getInteractions(){return this.interactions}getLayerGroup(){return this.get(Ue.LAYERGROUP)}setLayers(e){const t=this.getLayerGroup();if(e instanceof Ve){t.setLayers(e);return}const n=t.getLayers();n.clear(),n.extend(e)}getLayers(){return this.getLayerGroup().getLayers()}getLoadingOrNotReady(){const e=this.getLayerGroup().getLayerStatesArray();for(let t=0,n=e.length;t<n;++t){const i=e[t];if(!i.visible)continue;const r=i.layer.getRenderer();if(r&&!r.ready)return!0;const o=i.layer.getSource();if(o&&o.loading)return!0}return!1}getPixelFromCoordinate(e){const t=me(e,this.getView().getProjection());return this.getPixelFromCoordinateInternal(t)}getPixelFromCoordinateInternal(e){const t=this.frameState_;return t?de(t.coordinateToPixelTransform,e.slice(0,2)):null}getRenderer(){return this.renderer_}getSize(){return this.get(Ue.SIZE)}getView(){return this.get(Ue.VIEW)}getViewport(){return this.viewport_}getOverlayContainer(){return this.overlayContainer_}getOverlayContainerStopEvent(){return this.overlayContainerStopEvent_}getOwnerDocument(){const e=this.getTargetElement();return e?e.ownerDocument:document}getTilePriority(e,t,n,i){return Ef(this.frameState_,e,t,n,i)}handleBrowserEvent(e,t){t=t||e.type;const n=new Vt(t,this,e);this.handleMapBrowserEvent(n)}handleMapBrowserEvent(e){if(!this.frameState_)return;const t=e.originalEvent,n=t.type;if(n===ga.POINTERDOWN||n===V.WHEEL||n===V.KEYDOWN){const i=this.getOwnerDocument(),r=this.viewport_.getRootNode?this.viewport_.getRootNode():i,o=t.target,a=r instanceof ShadowRoot?r.host===o?r.host.ownerDocument:r:r===i?i.documentElement:r;if(this.overlayContainerStopEvent_.contains(o)||!a.contains(o))return}if(e.frameState=this.frameState_,this.dispatchEvent(e)!==!1){const i=this.getInteractions().getArray().slice();for(let r=i.length-1;r>=0;r--){const o=i[r];if(o.getMap()!==this||!o.getActive()||!this.getTargetElement())continue;if(!o.handleEvent(e)||e.propagationStopped)break}}}handlePostRender(){const e=this.frameState_,t=this.tileQueue_;if(!t.isEmpty()){let i=this.maxTilesLoading_,r=i;if(e){const o=e.viewHints;if(o[he.ANIMATING]||o[he.INTERACTING]){const a=Date.now()-e.time>8;i=a?0:8,r=a?0:2}}t.getTilesLoading()<i&&(t.reprioritize(),t.loadMoreTiles(i,r))}e&&this.renderer_&&!e.animate&&(this.renderComplete_?(this.hasListener(Fe.RENDERCOMPLETE)&&this.renderer_.dispatchRenderEvent(Fe.RENDERCOMPLETE,e),this.loaded_===!1&&(this.loaded_=!0,this.dispatchEvent(new Ei(Zt.LOADEND,this,e)))):this.loaded_===!0&&(this.loaded_=!1,this.dispatchEvent(new Ei(Zt.LOADSTART,this,e))));const n=this.postRenderFunctions_;if(e)for(let i=0,r=n.length;i<r;++i)n[i](this,e);n.length=0}handleSizeChanged_(){this.getView()&&!this.getView().getAnimating()&&this.getView().resolveConstraints(0),this.render()}handleTargetChanged_(){if(this.mapBrowserEventHandler_){for(let n=0,i=this.targetChangeHandlerKeys_.length;n<i;++n)ue(this.targetChangeHandlerKeys_[n]);this.targetChangeHandlerKeys_=null,this.viewport_.removeEventListener(V.CONTEXTMENU,this.boundHandleBrowserEvent_),this.viewport_.removeEventListener(V.WHEEL,this.boundHandleBrowserEvent_),this.mapBrowserEventHandler_.dispose(),this.mapBrowserEventHandler_=null,this.viewport_.remove()}if(this.targetElement_&&!xn(this.targetElement_)){this.resizeObserver_?.unobserve(this.targetElement_);const n=this.targetElement_.getRootNode();n instanceof ShadowRoot&&this.resizeObserver_.unobserve(n.host),this.setSize(void 0)}const e=this.getTarget(),t=typeof e=="string"?document.getElementById(e):e;if(this.targetElement_=t,!t)this.renderer_&&(clearTimeout(this.postRenderTimeoutHandle_),this.postRenderTimeoutHandle_=void 0,this.postRenderFunctions_.length=0,this.renderer_.dispose(),this.renderer_=null),this.animationDelayKey_&&(cancelAnimationFrame(this.animationDelayKey_),this.animationDelayKey_=void 0);else{if(xn(t)||t.appendChild(this.viewport_),this.renderer_||(this.renderer_=new Nm(this)),!xn(t)){this.mapBrowserEventHandler_=new pf(this,this.moveTolerance_);for(const i in ee)this.mapBrowserEventHandler_.addEventListener(ee[i],this.handleMapBrowserEvent.bind(this));this.viewport_.addEventListener(V.CONTEXTMENU,this.boundHandleBrowserEvent_,!1),this.viewport_.addEventListener(V.WHEEL,this.boundHandleBrowserEvent_,Gc?{passive:!1}:!1);let n;if(this.keyboardEventTarget_)n=this.keyboardEventTarget_;else{const i=t.getRootNode();n=i instanceof ShadowRoot?i.host:t}if(this.targetChangeHandlerKeys_=[J(n,V.KEYDOWN,this.handleBrowserEvent,this),J(n,V.KEYPRESS,this.handleBrowserEvent,this)],t instanceof HTMLElement){const i=t.getRootNode();i instanceof ShadowRoot&&this.resizeObserver_.observe(i.host),this.resizeObserver_?.observe(t)}}this.updateSize()}}handleTileChange_(){this.render()}handleViewPropertyChanged_(){this.render()}handleViewChanged_(){this.viewPropertyListenerKey_&&(ue(this.viewPropertyListenerKey_),this.viewPropertyListenerKey_=null),this.viewChangeListenerKey_&&(ue(this.viewChangeListenerKey_),this.viewChangeListenerKey_=null);const e=this.getView();e&&(this.updateViewportSize_(this.getSize()),this.viewPropertyListenerKey_=J(e,Oi.PROPERTYCHANGE,this.handleViewPropertyChanged_,this),this.viewChangeListenerKey_=J(e,V.CHANGE,this.handleViewPropertyChanged_,this),e.resolveConstraints(0)),this.render()}handleLayerGroupChanged_(){this.layerGroupPropertyListenerKeys_&&(this.layerGroupPropertyListenerKeys_.forEach(ue),this.layerGroupPropertyListenerKeys_=null);const e=this.getLayerGroup();e&&(this.handleLayerAdd_(new _n("addlayer",e)),this.layerGroupPropertyListenerKeys_=[J(e,Oi.PROPERTYCHANGE,this.render,this),J(e,V.CHANGE,this.render,this),J(e,"addlayer",this.handleLayerAdd_,this),J(e,"removelayer",this.handleLayerRemove_,this)]),this.render()}isRendered(){return!!this.frameState_}animationDelay_(){this.animationDelayKey_=void 0,this.renderFrame_(Date.now())}renderSync(){this.animationDelayKey_&&cancelAnimationFrame(this.animationDelayKey_),this.animationDelay_()}redrawText(){if(!this.frameState_)return;const e=this.frameState_.layerStatesArray;for(let t=0,n=e.length;t<n;++t){const i=e[t].layer;i.hasRenderer()&&i.getRenderer().handleFontsChanged()}}render(){this.renderer_&&this.animationDelayKey_===void 0&&(this.animationDelayKey_=requestAnimationFrame(this.animationDelay_))}removeControl(e){return this.getControls().remove(e)}removeInteraction(e){return this.getInteractions().remove(e)}removeLayer(e){return this.getLayerGroup().getLayers().remove(e)}handleLayerRemove_(e){Ou(e.layer)}removeOverlay(e){return this.getOverlays().remove(e)}renderFrame_(e){const t=this.getSize(),n=this.getView(),i=this.frameState_;let r=null;if(t!==void 0&&Bh(t)&&n&&n.isDef()){const o=n.getHints(this.frameState_?this.frameState_.viewHints:void 0),a=n.getState();if(r={animate:!1,coordinateToPixelTransform:this.coordinateToPixelTransform_,declutter:null,extent:ya(a.center,a.resolution,a.rotation,t),index:this.frameIndex_++,layerIndex:0,layerStatesArray:this.getLayerGroup().getLayerStatesArray(),pixelRatio:this.pixelRatio_,pixelToCoordinateTransform:this.pixelToCoordinateTransform_,postRenderFunctions:[],size:t,tileQueue:this.tileQueue_,time:e,usedTiles:{},viewState:a,viewHints:o,wantedTiles:{},mapId:D(this),renderTargets:{}},a.nextCenter&&a.nextResolution){const l=isNaN(a.nextRotation)?a.rotation:a.nextRotation;r.nextExtent=ya(a.nextCenter,a.nextResolution,l,t)}}this.frameState_=r,this.renderer_.renderFrame(r),r&&(r.animate&&this.render(),Array.prototype.push.apply(this.postRenderFunctions_,r.postRenderFunctions),i&&(!this.previousExtent_||!ti(this.previousExtent_)&&!Kn(r.extent,this.previousExtent_))&&(this.dispatchEvent(new Ei(Zt.MOVESTART,this,i)),this.previousExtent_=Wi(this.previousExtent_)),this.previousExtent_&&!r.viewHints[he.ANIMATING]&&!r.viewHints[he.INTERACTING]&&!Kn(r.extent,this.previousExtent_)&&(this.dispatchEvent(new Ei(Zt.MOVEEND,this,r)),kc(r.extent,this.previousExtent_))),this.dispatchEvent(new Ei(Zt.POSTRENDER,this,r)),this.renderComplete_=(this.hasListener(Zt.LOADSTART)||this.hasListener(Zt.LOADEND)||this.hasListener(Fe.RENDERCOMPLETE))&&!this.tileQueue_.getTilesLoading()&&!this.tileQueue_.getCount()&&!this.getLoadingOrNotReady(),this.postRenderTimeoutHandle_||(this.postRenderTimeoutHandle_=setTimeout(()=>{this.postRenderTimeoutHandle_=void 0,this.handlePostRender()},0))}setLayerGroup(e){const t=this.getLayerGroup();t&&this.handleLayerRemove_(new _n("removelayer",t)),this.set(Ue.LAYERGROUP,e)}setSize(e){this.set(Ue.SIZE,e)}setTarget(e){this.set(Ue.TARGET,e)}setView(e){if(!e||e instanceof qt){this.set(Ue.VIEW,e);return}this.set(Ue.VIEW,new qt);const t=this;e.then(function(n){t.setView(new qt(n))})}updateSize(){const e=this.getTargetElement();let t;if(e){let i,r;if(xn(e))i=e.width,r=e.height;else{const o=getComputedStyle(e);i=e.offsetWidth-parseFloat(o.borderLeftWidth)-parseFloat(o.paddingLeft)-parseFloat(o.paddingRight)-parseFloat(o.borderRightWidth),r=e.offsetHeight-parseFloat(o.borderTopWidth)-parseFloat(o.paddingTop)-parseFloat(o.paddingBottom)-parseFloat(o.borderBottomWidth)}!isNaN(i)&&!isNaN(r)&&(t=[Math.max(0,i),Math.max(0,r)],!Bh(t)&&(e.offsetWidth||e.offsetHeight||e.getClientRects().length)&&jc("No map visible because the map container's width or height are 0."))}const n=this.getSize();t&&(!n||!Ut(t,n))&&(this.setSize(t),this.updateViewportSize_(t))}updateViewportSize_(e){const t=this.getView();t&&t.setViewportSize(e)}};function Gm(s){let e=null;s.keyboardEventTarget!==void 0&&(e=typeof s.keyboardEventTarget=="string"?document.getElementById(s.keyboardEventTarget):s.keyboardEventTarget);const t={},n=s.layers&&typeof s.layers.getLayers=="function"?s.layers:new Vi({layers:s.layers});t[Ue.LAYERGROUP]=n,t[Ue.TARGET]=s.target,t[Ue.VIEW]=s.view instanceof qt?s.view:new qt;let i;s.controls!==void 0&&(Array.isArray(s.controls)?i=new Ve(s.controls.slice()):(te(typeof s.controls.getArray=="function","Expected `controls` to be an array or an `ol/Collection.js`"),i=s.controls));let r;s.interactions!==void 0&&(Array.isArray(s.interactions)?r=new Ve(s.interactions.slice()):(te(typeof s.interactions.getArray=="function","Expected `interactions` to be an array or an `ol/Collection.js`"),r=s.interactions));let o;return s.overlays!==void 0?Array.isArray(s.overlays)?o=new Ve(s.overlays.slice()):(te(typeof s.overlays.getArray=="function","Expected `overlays` to be an array or an `ol/Collection.js`"),o=s.overlays):o=new Ve,{controls:i,interactions:r,keyboardEventTarget:e,overlays:o,values:t}}const ke={ELEMENT:"element",MAP:"map",OFFSET:"offset",POSITION:"position",POSITIONING:"positioning"};class I0 extends It{constructor(e){super(),this.on,this.once,this.un,this.options=e,this.id=e.id,this.insertFirst=e.insertFirst!==void 0?e.insertFirst:!0,this.stopEvent=e.stopEvent!==void 0?e.stopEvent:!0,this.element=document.createElement("div"),this.element.className=e.className!==void 0?e.className:"ol-overlay-container "+Wg,this.element.style.position="absolute",this.element.style.pointerEvents="auto",this.autoPan=e.autoPan===!0?{}:e.autoPan||void 0,this.rendered={transform_:"",visible:!0},this.mapPostrenderListenerKey=null,this.addChangeListener(ke.ELEMENT,this.handleElementChanged),this.addChangeListener(ke.MAP,this.handleMapChanged),this.addChangeListener(ke.OFFSET,this.handleOffsetChanged),this.addChangeListener(ke.POSITION,this.handlePositionChanged),this.addChangeListener(ke.POSITIONING,this.handlePositioningChanged),e.element!==void 0&&this.setElement(e.element),this.setOffset(e.offset!==void 0?e.offset:[0,0]),this.setPositioning(e.positioning||"top-left"),e.position!==void 0&&this.setPosition(e.position)}getElement(){return this.get(ke.ELEMENT)}getId(){return this.id}getMap(){return this.get(ke.MAP)||null}getOffset(){return this.get(ke.OFFSET)}getPosition(){return this.get(ke.POSITION)}getPositioning(){return this.get(ke.POSITIONING)}handleElementChanged(){gu(this.element);const e=this.getElement();e&&this.element.appendChild(e)}handleMapChanged(){this.mapPostrenderListenerKey&&(this.element?.remove(),ue(this.mapPostrenderListenerKey),this.mapPostrenderListenerKey=null);const e=this.getMap();if(e){this.mapPostrenderListenerKey=J(e,Zt.POSTRENDER,this.render,this),this.updatePixelPosition();const t=this.stopEvent?e.getOverlayContainerStopEvent():e.getOverlayContainer();this.insertFirst?t.insertBefore(this.element,t.childNodes[0]||null):t.appendChild(this.element),this.performAutoPan()}}render(){this.updatePixelPosition()}handleOffsetChanged(){this.updatePixelPosition()}handlePositionChanged(){this.updatePixelPosition(),this.performAutoPan()}handlePositioningChanged(){this.updatePixelPosition()}setElement(e){this.set(ke.ELEMENT,e)}setMap(e){this.set(ke.MAP,e)}setOffset(e){this.set(ke.OFFSET,e)}setPosition(e){this.set(ke.POSITION,e)}performAutoPan(){this.autoPan&&this.panIntoView(this.autoPan)}panIntoView(e){const t=this.getMap();if(!t||!t.getTargetElement()||!this.get(ke.POSITION))return;const n=this.getRect(t.getTargetElement(),t.getSize()),i=this.getElement(),r=this.getRect(i,[jg(i),Vg(i)]);e=e||{};const o=e.margin===void 0?20:e.margin;if(!pn(n,r)){const a=r[0]-n[0],l=n[2]-r[2],h=r[1]-n[1],c=n[3]-r[3],u=[0,0];if(a<0?u[0]=a-o:l<0&&(u[0]=Math.abs(l)+o),h<0?u[1]=h-o:c<0&&(u[1]=Math.abs(c)+o),u[0]!==0||u[1]!==0){const d=t.getView().getCenterInternal(),f=t.getPixelFromCoordinateInternal(d);if(!f)return;const g=[f[0]+u[0],f[1]+u[1]],m=e.animation||{};t.getView().animateInternal({center:t.getCoordinateFromPixelInternal(g),duration:m.duration,easing:m.easing})}}}getRect(e,t){const n=e.getBoundingClientRect(),i=n.left+window.pageXOffset,r=n.top+window.pageYOffset;return[i,r,i+t[0],r+t[1]]}setPositioning(e){this.set(ke.POSITIONING,e)}setVisible(e){this.rendered.visible!==e&&(this.element.style.display=e?"":"none",this.rendered.visible=e)}updatePixelPosition(){const e=this.getMap(),t=this.getPosition();if(!e||!e.isRendered()||!t){this.setVisible(!1);return}const n=e.getPixelFromCoordinate(t),i=e.getSize();this.updateRenderedPosition(n,i)}updateRenderedPosition(e,t){const n=this.element.style,i=this.getOffset(),r=this.getPositioning();this.setVisible(!0);const o=`${e[0]+i[0]}px`,a=`${e[1]+i[1]}px`;let l="0%",h="0%";r=="bottom-right"||r=="center-right"||r=="top-right"?l="-100%":(r=="bottom-center"||r=="center-center"||r=="top-center")&&(l="-50%"),r=="bottom-left"||r=="bottom-center"||r=="bottom-right"?h="-100%":(r=="center-left"||r=="center-center"||r=="center-right")&&(h="-50%");const c=`translate(${l}, ${h}) translate(${o}, ${a})`;this.rendered.transform_!=c&&(this.rendered.transform_=c,n.transform=c)}getOptions(){return this.options}}class Nl extends Ms{constructor(e,t,n){super(),n=n||{},this.tileCoord=e,this.state=t,this.key="",this.transition_=n.transition===void 0?250:n.transition,this.transitionStarts_={},this.interpolate=!!n.interpolate}changed(){this.dispatchEvent(V.CHANGE)}release(){this.setState(B.EMPTY)}getKey(){return this.key+"/"+this.tileCoord}getTileCoord(){return this.tileCoord}getState(){return this.state}setState(e){if(this.state!==B.EMPTY){if(this.state!==B.ERROR&&this.state>e)throw new Error("Tile load sequence violation");this.state=e,this.changed()}}load(){$()}getAlpha(e,t){if(!this.transition_)return 1;let n=this.transitionStarts_[e];if(!n)n=t,this.transitionStarts_[e]=n;else if(n===-1)return 1;const i=t-n+1e3/60;return i>=this.transition_?1:Yc(i/this.transition_)}inTransition(e){return this.transition_?this.transitionStarts_[e]!==-1:!1}endTransition(e){this.transition_&&(this.transitionStarts_[e]=-1)}disposeInternal(){this.release(),super.disposeInternal()}}function Ma(s){return s instanceof Image||s instanceof HTMLCanvasElement||s instanceof HTMLVideoElement||s instanceof ImageBitmap?s:null}const km=new Error("disposed"),Um=[256,256];class Qh extends Nl{constructor(e){const t=B.IDLE;super(e.tileCoord,t,{transition:e.transition,interpolate:e.interpolate}),this.loader_=e.loader,this.data_=null,this.error_=null,this.size_=e.size||null,this.controller_=e.controller||null}getSize(){if(this.size_)return this.size_;const e=Ma(this.data_);return e?[e.width,e.height]:Um}getData(){return this.data_}getError(){return this.error_}load(){if(this.state!==B.IDLE&&this.state!==B.ERROR)return;this.state=B.LOADING,this.changed();const e=this;this.loader_().then(function(t){e.data_=t,e.state=B.LOADED,e.changed()}).catch(function(t){e.error_=t,e.state=B.ERROR,e.changed()})}disposeInternal(){this.controller_&&(this.controller_.abort(km),this.controller_=null),super.disposeInternal()}}class Gu extends Nl{constructor(e,t,n,i,r,o){super(e,t,o),this.crossOrigin_=i,this.src_=n,this.key=n,this.image_,rt?this.image_=new OffscreenCanvas(1,1):(this.image_=new Image,i!==null&&(this.image_.crossOrigin=i)),this.unlisten_=null,this.tileLoadFunction_=r}getImage(){return this.image_}setImage(e){this.image_=e,this.state=B.LOADED,this.unlistenImage_(),this.changed()}getCrossOrigin(){return this.crossOrigin_}handleImageError_(){this.state=B.ERROR,this.unlistenImage_(),this.image_=Bm(),this.changed()}handleImageLoad_(){if(rt)this.state=B.LOADED;else{const e=this.image_;e.naturalWidth&&e.naturalHeight?this.state=B.LOADED:this.state=B.EMPTY}this.unlistenImage_(),this.changed()}load(){this.state==B.ERROR&&(this.state=B.IDLE,this.image_=new Image,this.crossOrigin_!==null&&(this.image_.crossOrigin=this.crossOrigin_)),this.state==B.IDLE&&(this.state=B.LOADING,this.changed(),this.tileLoadFunction_(this,this.src_),this.unlisten_=rm(this.image_,this.handleImageLoad_.bind(this),this.handleImageError_.bind(this)))}unlistenImage_(){this.unlisten_&&(this.unlisten_(),this.unlisten_=null)}disposeInternal(){this.unlistenImage_(),this.image_=null,super.disposeInternal()}}function Bm(){const s=ve(1,1);return s.fillStyle="rgba(0,0,0,0)",s.fillRect(0,0,1,1),s.canvas}class Gl{constructor(e,t,n,i){this.minX=e,this.maxX=t,this.minY=n,this.maxY=i}contains(e){return this.containsXY(e[1],e[2])}containsTileRange(e){return this.minX<=e.minX&&e.maxX<=this.maxX&&this.minY<=e.minY&&e.maxY<=this.maxY}containsXY(e,t){return this.minX<=e&&e<=this.maxX&&this.minY<=t&&t<=this.maxY}equals(e){return this.minX==e.minX&&this.minY==e.minY&&this.maxX==e.maxX&&this.maxY==e.maxY}extend(e){e.minX<this.minX&&(this.minX=e.minX),e.maxX>this.maxX&&(this.maxX=e.maxX),e.minY<this.minY&&(this.minY=e.minY),e.maxY>this.maxY&&(this.maxY=e.maxY)}getHeight(){return this.maxY-this.minY+1}getSize(){return[this.getWidth(),this.getHeight()]}getWidth(){return this.maxX-this.minX+1}intersects(e){return this.minX<=e.maxX&&this.maxX>=e.minX&&this.minY<=e.maxY&&this.maxY>=e.minY}}function gi(s,e,t,n,i){return i!==void 0?(i.minX=s,i.maxX=e,i.minY=t,i.maxY=n,i):new Gl(s,e,t,n)}let Yo;const Fi=[];function ec(s,e,t,n,i){s.beginPath(),s.moveTo(0,0),s.lineTo(e,t),s.lineTo(n,i),s.closePath(),s.save(),s.clip(),s.fillRect(0,0,Math.max(e,n)+1,Math.max(t,i)),s.restore()}function jo(s,e){return Math.abs(s[e*4]-210)>2||Math.abs(s[e*4+3]-.75*255)>2}function zm(){if(Yo===void 0){const s=ve(6,6,Fi);s.globalCompositeOperation="lighter",s.fillStyle="rgba(210, 0, 0, 0.75)",ec(s,4,5,4,0),ec(s,4,5,0,5);const e=s.getImageData(0,0,3,3).data;Yo=jo(e,0)||jo(e,4)||jo(e,8),oo(s),Fi.push(s.canvas)}return Yo}function Da(s,e,t,n){const i=Ns(t,e,s);let r=Ir(e,n,t);const o=e.getMetersPerUnit();o!==void 0&&(r*=o);const a=s.getMetersPerUnit();a!==void 0&&(r/=a);const l=s.getExtent();if(!l||Zn(l,i)){const h=Ir(s,r,i)/r;isFinite(h)&&h>0&&(r/=h)}return r}function $m(s,e,t,n){const i=Pn(t);let r=Da(s,e,i,n);return(!isFinite(r)||r<=0)&&qa(t,function(o){return r=Da(s,e,o,n),isFinite(r)&&r>0}),r}function Xm(s,e,t,n,i,r,o,a,l,h,c,u,d,f){const g=ve(Math.round(t*s),Math.round(t*e),Fi);if(u||(g.imageSmoothingEnabled=!1),l.length===0)return g.canvas;g.scale(t,t);function m(T){return Math.round(T*t)/t}g.globalCompositeOperation="lighter";const _=Je();l.forEach(function(T,R,S){Uc(_,T.extent)});let p;const y=t/n,E=(u?1:1+Math.pow(2,-24))/y;p=ve(Math.round(ne(_)*y),Math.round(be(_)*y),Fi),u||(p.imageSmoothingEnabled=!1),l.forEach(function(T,R,S){if(T.image.width>0&&T.image.height>0){if(T.clipExtent){p.save();const L=(T.clipExtent[0]-_[0])*y,b=-(T.clipExtent[3]-_[3])*y,M=ne(T.clipExtent)*y,K=be(T.clipExtent)*y;p.rect(u?L:Math.round(L),u?b:Math.round(b),u?M:Math.round(L+M)-Math.round(L),u?K:Math.round(b+K)-Math.round(b)),p.clip()}const v=(T.extent[0]-_[0])*y,w=-(T.extent[3]-_[3])*y,I=ne(T.extent)*y,F=be(T.extent)*y;p.drawImage(T.image,h,h,T.image.width-2*h,T.image.height-2*h,u?v:Math.round(v),u?w:Math.round(w),u?I:Math.round(v+I)-Math.round(v),u?F:Math.round(w+F)-Math.round(w)),T.clipExtent&&p.restore()}});const x=An(o);return a.getTriangles().forEach(function(T,R,S){const v=T.source,w=T.target;let I=v[0][0],F=v[0][1],L=v[1][0],b=v[1][1],M=v[2][0],K=v[2][1];const A=m((w[0][0]-x[0])/r),Z=m(-(w[0][1]-x[1])/r),G=m((w[1][0]-x[0])/r),H=m(-(w[1][1]-x[1])/r),Q=m((w[2][0]-x[0])/r),le=m(-(w[2][1]-x[1])/r),P=I,Ne=F;I=0,F=0,L-=P,b-=Ne,M-=P,K-=Ne;const We=[[L,b,0,0,G-A],[M,K,0,0,Q-A],[0,0,L,b,H-Z],[0,0,M,K,le-Z]],xe=Cf(We);if(!xe)return;if(g.save(),g.beginPath(),zm()||!u){g.moveTo(G,H);const Ge=4,Lt=A-G,Ct=Z-H;for(let nt=0;nt<Ge;nt++)g.lineTo(G+m((nt+1)*Lt/Ge),H+m(nt*Ct/(Ge-1))),nt!=Ge-1&&g.lineTo(G+m((nt+1)*Lt/Ge),H+m((nt+1)*Ct/(Ge-1)));g.lineTo(Q,le)}else g.moveTo(G,H),g.lineTo(A,Z),g.lineTo(Q,le);g.clip(),g.transform(xe[0],xe[2],xe[1],xe[3],A,Z),g.translate(_[0]-P,_[3]-Ne);let tt;if(p)tt=p.canvas,g.scale(E,-E);else{const Ge=l[0],Lt=Ge.extent;tt=Ge.image,g.scale(ne(Lt)/tt.width,-be(Lt)/tt.height)}g.drawImage(tt,0,0),g.restore()}),p&&(oo(p),Fi.push(p.canvas)),c&&(g.save(),g.globalCompositeOperation="source-over",g.strokeStyle="black",g.lineWidth=1,a.getTriangles().forEach(function(T,R,S){const v=T.target,w=(v[0][0]-x[0])/r,I=-(v[0][1]-x[1])/r,F=(v[1][0]-x[0])/r,L=-(v[1][1]-x[1])/r,b=(v[2][0]-x[0])/r,M=-(v[2][1]-x[1])/r;g.beginPath(),g.moveTo(F,L),g.lineTo(w,I),g.lineTo(b,M),g.closePath(),g.stroke()}),g.restore()),g.canvas}const Wm=10,tc=.25;class Ym{constructor(e,t,n,i,r,o,a){this.sourceProj_=e,this.targetProj_=t;let l={};const h=a?ug(E=>de(a,Ns(E,this.targetProj_,this.sourceProj_))):Hn(this.targetProj_,this.sourceProj_);this.transformInv_=function(E){const x=E[0]+"/"+E[1];return l[x]||(l[x]=h(E)),l[x]},this.maxSourceExtent_=i,this.errorThresholdSquared_=r*r,this.triangles_=[],this.wrapsXInSource_=!1,this.canWrapXInSource_=this.sourceProj_.canWrapX()&&!!i&&!!this.sourceProj_.getExtent()&&ne(i)>=ne(this.sourceProj_.getExtent()),this.sourceWorldWidth_=this.sourceProj_.getExtent()?ne(this.sourceProj_.getExtent()):null,this.targetWorldWidth_=this.targetProj_.getExtent()?ne(this.targetProj_.getExtent()):null;const c=An(n),u=qr(n),d=Hr(n),f=Kr(n),g=this.transformInv_(c),m=this.transformInv_(u),_=this.transformInv_(d),p=this.transformInv_(f),y=Wm+(o?Math.max(0,Math.ceil(Math.log2(pa(n)/(o*o*256*256)))):0);if(this.addQuad_(c,u,d,f,g,m,_,p,y),this.wrapsXInSource_){let E=1/0;this.triangles_.forEach(function(x,T,R){E=Math.min(E,x.source[0][0],x.source[1][0],x.source[2][0])}),this.triangles_.forEach(x=>{if(Math.max(x.source[0][0],x.source[1][0],x.source[2][0])-E>this.sourceWorldWidth_/2){const T=[[x.source[0][0],x.source[0][1]],[x.source[1][0],x.source[1][1]],[x.source[2][0],x.source[2][1]]];T[0][0]-E>this.sourceWorldWidth_/2&&(T[0][0]-=this.sourceWorldWidth_),T[1][0]-E>this.sourceWorldWidth_/2&&(T[1][0]-=this.sourceWorldWidth_),T[2][0]-E>this.sourceWorldWidth_/2&&(T[2][0]-=this.sourceWorldWidth_);const R=Math.min(T[0][0],T[1][0],T[2][0]);Math.max(T[0][0],T[1][0],T[2][0])-R<this.sourceWorldWidth_/2&&(x.source=T)}})}l={}}addTriangle_(e,t,n,i,r,o){this.triangles_.push({source:[i,r,o],target:[e,t,n]})}addQuad_(e,t,n,i,r,o,a,l,h){const c=Be([r,o,a,l]),u=this.sourceWorldWidth_?ne(c)/this.sourceWorldWidth_:null,d=this.sourceWorldWidth_,f=this.sourceProj_.canWrapX()&&u>.5&&u<1;let g=!1;if(h>0){if(this.targetProj_.isGlobal()&&this.targetWorldWidth_){const _=Be([e,t,n,i]);g=ne(_)/this.targetWorldWidth_>tc||g}!f&&this.sourceProj_.isGlobal()&&u&&(g=u>tc||g)}if(!g&&this.maxSourceExtent_&&isFinite(c[0])&&isFinite(c[1])&&isFinite(c[2])&&isFinite(c[3])&&!Ee(c,this.maxSourceExtent_))return;let m=0;if(!g&&(!isFinite(r[0])||!isFinite(r[1])||!isFinite(o[0])||!isFinite(o[1])||!isFinite(a[0])||!isFinite(a[1])||!isFinite(l[0])||!isFinite(l[1]))){if(h>0)g=!0;else if(m=(!isFinite(r[0])||!isFinite(r[1])?8:0)+(!isFinite(o[0])||!isFinite(o[1])?4:0)+(!isFinite(a[0])||!isFinite(a[1])?2:0)+(!isFinite(l[0])||!isFinite(l[1])?1:0),m!=1&&m!=2&&m!=4&&m!=8)return}if(h>0){if(!g){const _=[(e[0]+n[0])/2,(e[1]+n[1])/2],p=this.transformInv_(_);let y;f?y=(Qt(r[0],d)+Qt(a[0],d))/2-Qt(p[0],d):y=(r[0]+a[0])/2-p[0];const E=(r[1]+a[1])/2-p[1];g=y*y+E*E>this.errorThresholdSquared_}if(g){if(Math.abs(e[0]-n[0])<=Math.abs(e[1]-n[1])){const _=[(t[0]+n[0])/2,(t[1]+n[1])/2],p=this.transformInv_(_),y=[(i[0]+e[0])/2,(i[1]+e[1])/2],E=this.transformInv_(y);this.addQuad_(e,t,_,y,r,o,p,E,h-1),this.addQuad_(y,_,n,i,E,p,a,l,h-1)}else{const _=[(e[0]+t[0])/2,(e[1]+t[1])/2],p=this.transformInv_(_),y=[(n[0]+i[0])/2,(n[1]+i[1])/2],E=this.transformInv_(y);this.addQuad_(e,_,y,i,r,p,E,l,h-1),this.addQuad_(_,t,n,y,p,o,a,E,h-1)}return}}if(f){if(!this.canWrapXInSource_)return;this.wrapsXInSource_=!0}(m&11)==0&&this.addTriangle_(e,n,i,r,a,l),(m&14)==0&&this.addTriangle_(e,n,t,r,a,o),m&&((m&13)==0&&this.addTriangle_(t,i,e,o,l,r),(m&7)==0&&this.addTriangle_(t,i,n,o,l,a))}calculateSourceExtent(){const e=Je();return this.triangles_.forEach(function(t,n,i){const r=t.source;fs(e,r[0]),fs(e,r[1]),fs(e,r[2])}),e}getTriangles(){return this.triangles_}}const jm=.5;class ku extends Nl{constructor(e,t,n,i,r,o,a,l,h,c,u,d){super(r,B.IDLE,d),this.renderEdges_=u!==void 0?u:!1,this.pixelRatio_=a,this.gutter_=l,this.canvas_=null,this.sourceTileGrid_=t,this.targetTileGrid_=i,this.wrappedTileCoord_=o||r,this.sourceTiles_=[],this.sourcesListenerKeys_=null,this.sourceZ_=0,this.clipExtent_=e.canWrapX()?e.getExtent():void 0;const f=i.getTileCoordExtent(this.wrappedTileCoord_),g=this.targetTileGrid_.getExtent();let m=this.sourceTileGrid_.getExtent();const _=g?en(f,g):f;if(pa(_)===0){this.state=B.EMPTY;return}const p=e.getExtent();p&&(m?m=en(m,p):m=p);const y=i.getResolution(this.wrappedTileCoord_[0]),E=$m(e,n,_,y);if(!isFinite(E)||E<=0){this.state=B.EMPTY;return}const x=c!==void 0?c:jm;if(this.triangulation_=new Ym(e,n,_,m,E*x,y),this.triangulation_.getTriangles().length===0){this.state=B.EMPTY;return}this.sourceZ_=t.getZForResolution(E);let T=this.triangulation_.calculateSourceExtent();if(m&&(e.canWrapX()?(T[1]=fe(T[1],m[1],m[3]),T[3]=fe(T[3],m[1],m[3])):T=en(T,m)),!pa(T))this.state=B.EMPTY;else{let R=0,S=0;e.canWrapX()&&(R=ne(p),S=Math.floor((T[0]-p[0])/R)),Xc(T.slice(),e,!0).forEach(w=>{const I=t.getTileRangeForExtentAndZ(w,this.sourceZ_);for(let F=I.minX;F<=I.maxX;F++)for(let L=I.minY;L<=I.maxY;L++){const b=h(this.sourceZ_,F,L,a);if(b){const M=S*R;this.sourceTiles_.push({tile:b,offset:M})}}++S}),this.sourceTiles_.length===0&&(this.state=B.EMPTY)}}getImage(){return this.canvas_}reproject_(){const e=[];if(this.sourceTiles_.forEach(t=>{const n=t.tile;if(n&&n.getState()==B.LOADED){const i=this.sourceTileGrid_.getTileCoordExtent(n.tileCoord);i[0]+=t.offset,i[2]+=t.offset;const r=this.clipExtent_?.slice();r&&(r[0]+=t.offset,r[2]+=t.offset),e.push({extent:i,clipExtent:r,image:n.getImage()})}}),this.sourceTiles_.length=0,e.length===0)this.state=B.ERROR;else{const t=this.wrappedTileCoord_[0],n=this.targetTileGrid_.getTileSize(t),i=typeof n=="number"?n:n[0],r=typeof n=="number"?n:n[1],o=this.targetTileGrid_.getResolution(t),a=this.sourceTileGrid_.getResolution(this.sourceZ_),l=this.targetTileGrid_.getTileCoordExtent(this.wrappedTileCoord_);this.canvas_=Xm(i,r,this.pixelRatio_,a,this.sourceTileGrid_.getExtent(),o,l,this.triangulation_,e,this.gutter_,this.renderEdges_,this.interpolate),this.state=B.LOADED}this.changed()}load(){if(this.state==B.IDLE){this.state=B.LOADING,this.changed();let e=0;this.sourcesListenerKeys_=[],this.sourceTiles_.forEach(({tile:t})=>{const n=t.getState();if(n==B.IDLE||n==B.LOADING){e++;const i=J(t,V.CHANGE,r=>{const o=t.getState();(o==B.LOADED||o==B.ERROR||o==B.EMPTY)&&(ue(i),e--,e===0&&(this.unlistenSources_(),this.reproject_()))});this.sourcesListenerKeys_.push(i)}}),e===0?setTimeout(this.reproject_.bind(this),0):this.sourceTiles_.forEach(function({tile:t},n,i){t.getState()==B.IDLE&&t.load()})}}unlistenSources_(){this.sourcesListenerKeys_.forEach(ue),this.sourcesListenerKeys_=null}release(){this.canvas_&&(oo(this.canvas_.getContext("2d")),Fi.push(this.canvas_),this.canvas_=null),super.release()}}class nc{constructor(e){this.highWaterMark=e!==void 0?e:2048,this.count_=0,this.entries_={},this.oldest_=null,this.newest_=null}deleteOldest(){const e=this.pop();e instanceof bs&&e.dispose()}canExpireCache(){return this.highWaterMark>0&&this.getCount()>this.highWaterMark}expireCache(e){for(;this.canExpireCache();)this.deleteOldest()}clear(){for(;this.oldest_;)this.deleteOldest()}containsKey(e){return this.entries_.hasOwnProperty(e)}forEach(e){let t=this.oldest_;for(;t;)e(t.value_,t.key_,this),t=t.newer}get(e,t){const n=this.entries_[e];return te(n!==void 0,"Tried to get a value for a key that does not exist in the cache"),n===this.newest_||(n===this.oldest_?(this.oldest_=this.oldest_.newer,this.oldest_.older=null):(n.newer.older=n.older,n.older.newer=n.newer),n.newer=null,n.older=this.newest_,this.newest_.newer=n,this.newest_=n),n.value_}remove(e){const t=this.entries_[e];return te(t!==void 0,"Tried to get a value for a key that does not exist in the cache"),t===this.newest_?(this.newest_=t.older,this.newest_&&(this.newest_.newer=null)):t===this.oldest_?(this.oldest_=t.newer,this.oldest_&&(this.oldest_.older=null)):(t.newer.older=t.older,t.older.newer=t.newer),delete this.entries_[e],--this.count_,t.value_}getCount(){return this.count_}getKeys(){const e=new Array(this.count_);let t=0,n;for(n=this.newest_;n;n=n.older)e[t++]=n.key_;return e}getValues(){const e=new Array(this.count_);let t=0,n;for(n=this.newest_;n;n=n.older)e[t++]=n.value_;return e}peekLast(){return this.oldest_.value_}peekLastKey(){return this.oldest_.key_}peekFirstKey(){return this.newest_.key_}peek(e){return this.entries_[e]?.value_}pop(){const e=this.oldest_;return delete this.entries_[e.key_],e.newer&&(e.newer.older=null),this.oldest_=e.newer,this.oldest_||(this.newest_=null),--this.count_,e.value_}replace(e,t){this.get(e),this.entries_[e].value_=t}set(e,t){te(!(e in this.entries_),"Tried to set a value for a key that is used already");const n={key_:e,newer:null,older:this.newest_,value_:t};this.newest_?this.newest_.newer=n:this.oldest_=n,this.newest_=n,this.entries_[e]=n,++this.count_}setSize(e){this.highWaterMark=e}}function kr(s,e,t,n){return n!==void 0?(n[0]=s,n[1]=e,n[2]=t,n):[s,e,t]}function Vm(s,e,t){return s+"/"+e+"/"+t}function Er(s,e,t,n,i){return`${D(s)},${e},${Vm(t,n,i)}`}function Uu(s){return Zm(s[0],s[1],s[2])}function Zm(s,e,t){return(e<<s)+t}function Km(s,e){const t=s[0],n=s[1],i=s[2];if(e.getMinZoom()>t||t>e.getMaxZoom())return!1;const r=e.getFullTileRange(t);return r?r.containsXY(n,i):!0}class kl{constructor(){this.instructions_=[],this.zIndex=0,this.offset_=0,this.context_=new Proxy(Fr(),{get:(e,t)=>{if(typeof Fr()[t]=="function")return this.push_(t),this.pushMethodArgs_},set:(e,t,n)=>(this.push_(t,n),!0)})}push_(...e){const t=this.instructions_,n=this.zIndex+this.offset_;t[n]||(t[n]=[]),t[n].push(...e)}pushMethodArgs_=(...e)=>(this.push_(e),this);pushFunction(e){this.push_(e)}getContext(){return this.context_}draw(e){this.instructions_.forEach(t=>{for(let n=0,i=t.length;n<i;++n){const r=t[n];if(typeof r=="function"){r(e);continue}const o=t[++n];if(typeof e[r]=="function")e[r](...o);else{if(typeof o=="function"){e[r]=o(e);continue}e[r]=o}}})}clear(){this.instructions_.length=0,this.zIndex=0,this.offset_=0}offset(){this.offset_=this.instructions_.length,this.zIndex=0}}const Hm=5;class Bu extends Ds{constructor(e){super(),this.ready=!0,this.boundHandleImageChange_=this.handleImageChange_.bind(this),this.layer_=e,this.staleKeys_=new Array,this.maxStaleKeys=Hm}getStaleKeys(){return this.staleKeys_}prependStaleKey(e){this.staleKeys_.unshift(e),this.staleKeys_.length>this.maxStaleKeys&&(this.staleKeys_.length=this.maxStaleKeys)}getFeatures(e){return $()}getData(e){return null}prepareFrame(e){return $()}renderFrame(e,t){return $()}forEachFeatureAtCoordinate(e,t,n,i,r){}getLayer(){return this.layer_}handleFontsChanged(){}handleImageChange_(e){const t=e.target;(t.getState()===U.LOADED||t.getState()===U.ERROR)&&this.renderIfReadyAndVisible()}loadImage(e){let t=e.getState();return t!=U.LOADED&&t!=U.ERROR&&e.addEventListener(V.CHANGE,this.boundHandleImageChange_),t==U.IDLE&&(e.load(),t=e.getState()),t==U.LOADED}renderIfReadyAndVisible(){const e=this.getLayer();e&&e.getVisible()&&e.getSourceState()==="ready"&&e.changed()}renderDeferred(e){}disposeInternal(){delete this.layer_,super.disposeInternal()}}const ic=[];let Ri=null;function qm(){Ri=ve(1,1,void 0,{willReadFrequently:!0})}class Ul extends Bu{constructor(e){super(e),this.container=null,this.renderedResolution,this.tempTransform=Te(),this.pixelTransform=Te(),this.inversePixelTransform=Te(),this.context=null,this.deferredContext_=null,this.containerReused=!1,this.frameState=null}getImageData(e,t,n){Ri||qm(),Ri.clearRect(0,0,1,1);let i;try{Ri.drawImage(e,t,n,1,1,0,0,1,1),i=Ri.getImageData(0,0,1,1).data}catch{return Ri=null,null}return i}getBackground(e){let n=this.getLayer().getBackground();return typeof n=="function"&&(n=n(e.viewState.resolution)),n||void 0}useContainer(e,t,n){const i=this.getLayer().getClassName();let r,o;if(e&&e.className===i&&(!n||e&&e.style.backgroundColor&&Ut(Et(e.style.backgroundColor),Et(n)))){const a=e.firstElementChild;xn(a)&&(o=a.getContext("2d"))}if(o&&xg(o.canvas.style.transform,t)?(this.container=e,this.context=o,this.containerReused=!0):this.containerReused?(this.container=null,this.context=null,this.containerReused=!1):this.container&&(this.container.style.backgroundColor=null),!this.container){r=rt?_u():document.createElement("div"),r.className=i;let a=r.style;a.position="absolute",a.width="100%",a.height="100%",o=ve();const l=o.canvas;r.appendChild(l),a=l.style,a.position="absolute",a.left="0",a.transformOrigin="top left",this.container=r,this.context=o}!this.containerReused&&n&&!this.container.style.backgroundColor&&(this.container.style.backgroundColor=n)}clipUnrotated(e,t,n){const i=An(n),r=qr(n),o=Hr(n),a=Kr(n);de(t.coordinateToPixelTransform,i),de(t.coordinateToPixelTransform,r),de(t.coordinateToPixelTransform,o),de(t.coordinateToPixelTransform,a);const l=this.inversePixelTransform;de(l,i),de(l,r),de(l,o),de(l,a),e.save(),e.beginPath(),e.moveTo(Math.round(i[0]),Math.round(i[1])),e.lineTo(Math.round(r[0]),Math.round(r[1])),e.lineTo(Math.round(o[0]),Math.round(o[1])),e.lineTo(Math.round(a[0]),Math.round(a[1])),e.clip()}prepareContainer(e,t){const n=e.extent,i=e.viewState.resolution,r=e.viewState.rotation,o=e.pixelRatio,a=Math.round(ne(n)/i*o),l=Math.round(be(n)/i*o);lt(this.pixelTransform,e.size[0]/2,e.size[1]/2,1/o,1/o,r,-a/2,-l/2),Cs(this.inversePixelTransform,this.pixelTransform);const h=yg(this.pixelTransform);if(this.useContainer(t,h,this.getBackground(e)),!this.containerReused){const c=this.context.canvas;c.width!=a||c.height!=l?(c.width=a,c.height=l):this.context.clearRect(0,0,a,l),h!==c.style.transform&&(c.style.transform=h)}}dispatchRenderEvent_(e,t,n){const i=this.getLayer();if(i.hasListener(e)){const r=new _s(e,this.inversePixelTransform,n,t);i.dispatchEvent(r)}}preRender(e,t){this.frameState=t,!t.declutter&&this.dispatchRenderEvent_(Fe.PRERENDER,e,t)}postRender(e,t){t.declutter||this.dispatchRenderEvent_(Fe.POSTRENDER,e,t)}renderDeferredInternal(e){}getRenderContext(e){return e.declutter&&!this.deferredContext_&&(this.deferredContext_=new kl),e.declutter?this.deferredContext_.getContext():this.context}renderDeferred(e){e.declutter&&(this.dispatchRenderEvent_(Fe.PRERENDER,this.context,e),e.declutter&&this.deferredContext_&&(this.deferredContext_.draw(this.context),this.deferredContext_.clear()),this.renderDeferredInternal(e),this.dispatchRenderEvent_(Fe.POSTRENDER,this.context,e))}getRenderTransform(e,t,n,i,r,o,a){const l=r/2,h=o/2,c=i/t,u=-c,d=-e[0]+a,f=-e[1];return lt(this.tempTransform,l,h,c,u,-n,d,f)}disposeInternal(){delete this.frameState,super.disposeInternal()}}function Vo(s,e,t){if(!(t in s))return s[t]=new Set([e]),!0;const n=s[t],i=n.has(e);return i||n.add(e),!i}function Jm(s,e,t){const n=s[t];return n?n.delete(e):!1}function sc(s,e){const t=s.layerStatesArray[s.layerIndex];t.extent&&(e=en(e,St(t.extent,s.viewState.projection)));const n=t.layer.getRenderSource();if(!n.getWrapX()){const i=n.getTileGridForProjection(s.viewState.projection).getExtent();i&&(e=en(e,i))}return e}class zu extends Ul{constructor(e,t){super(e),t=t||{},this.extentChanged=!0,this.renderComplete=!1,this.renderedExtent_=null,this.renderedPixelRatio,this.renderedProjection=null,this.renderedTiles=[],this.renderedSourceKey_,this.renderedSourceRevision_,this.tempExtent=Je(),this.tempTileRange_=new Gl(0,0,0,0),this.tempTileCoord_=kr(0,0,0);const n=t.cacheSize!==void 0?t.cacheSize:512;this.tileCache_=new nc(n),this.sourceTileCache_=null,this.maxStaleKeys=n*.5}getTileCache(){return this.tileCache_}getSourceTileCache(){return this.sourceTileCache_||(this.sourceTileCache_=new nc(512)),this.sourceTileCache_}getOrCreateTile(e,t,n,i){const r=this.tileCache_,a=this.getLayer().getSource(),l=Er(a,a.getKey(),e,t,n);let h;if(r.containsKey(l))h=r.get(l);else{const c=i.viewState.projection,u=a.getProjection();if(h=a.getTile(e,t,n,i.pixelRatio,c,!u||Yn(u,c)?void 0:this.getSourceTileCache()),!h)return null;r.set(l,h)}return h}getTile(e,t,n,i){const r=this.getOrCreateTile(e,t,n,i);return r||null}getData(e){const t=this.frameState;if(!t)return null;const n=this.getLayer(),i=de(t.pixelToCoordinateTransform,e.slice()),r=n.getExtent();if(r&&!Zn(r,i))return null;const o=t.viewState,a=n.getRenderSource(),l=a.getTileGridForProjection(o.projection),h=a.getTilePixelRatio(t.pixelRatio);for(let c=l.getZForResolution(o.resolution);c>=l.getMinZoom();--c){const u=l.getTileCoordForCoordAndZ(i,c),d=this.getTile(c,u[1],u[2],t);if(!d||d.getState()!==B.LOADED)continue;const f=l.getOrigin(c),g=$e(l.getTileSize(c)),m=l.getResolution(c);let _;if(d instanceof Gu||d instanceof ku)_=d.getImage();else if(d instanceof Qh){if(_=Ma(d.getData()),!_)continue}else continue;const p=Math.floor(h*((i[0]-f[0])/m-u[1]*g[0])),y=Math.floor(h*((f[1]-i[1])/m-u[2]*g[1])),E=Math.round(h*a.getGutterForProjection(o.projection));return this.getImageData(_,p+E,y+E)}return null}prepareFrame(e){this.renderedProjection?e.viewState.projection!==this.renderedProjection&&(this.tileCache_.clear(),this.renderedProjection=e.viewState.projection):this.renderedProjection=e.viewState.projection;const t=this.getLayer().getSource();if(!t)return!1;const n=t.getRevision();return this.renderedSourceRevision_?this.renderedSourceRevision_!==n&&(this.renderedSourceRevision_=n,this.renderedSourceKey_===t.getKey()&&(this.tileCache_.clear(),this.sourceTileCache_?.clear())):this.renderedSourceRevision_=n,!0}enqueueTilesForNextExtent(){return!0}enqueueTiles(e,t,n,i,r){const o=e.viewState,a=this.getLayer(),l=a.getRenderSource(),h=l.getTileGridForProjection(o.projection),c=D(l);c in e.wantedTiles||(e.wantedTiles[c]={});const u=e.wantedTiles[c],d=a.getMapInternal(),f=Math.max(n-r,h.getMinZoom(),h.getZForResolution(Math.min(a.getMaxResolution(),d?d.getView().getResolutionForZoom(Math.max(a.getMinZoom(),0)):h.getResolution(0)),l.zDirection)),g=o.rotation,m=g?zc(o.center,o.resolution,g,e.size):void 0;for(let _=n;_>=f;--_){const p=h.getTileRangeForExtentAndZ(t,_,this.tempTileRange_),y=h.getResolution(_);for(let E=p.minX;E<=p.maxX;++E)for(let x=p.minY;x<=p.maxY;++x){if(g&&!h.tileCoordIntersectsViewport([_,E,x],m))continue;const T=this.getTile(_,E,x,e);if(!T||!Vo(i,T,_))continue;const S=T.getKey();if(u[S]=!0,T.getState()===B.IDLE&&!e.tileQueue.isKeyQueued(S)){const v=kr(_,E,x,this.tempTileCoord_);e.tileQueue.enqueue([T,c,h.getTileCoordCenter(v),y])}}}}findStaleTile_(e,t){const n=this.tileCache_,i=e[0],r=e[1],o=e[2],a=this.getStaleKeys();for(let l=0;l<a.length;++l){const h=Er(this.getLayer().getSource(),a[l],i,r,o);if(n.containsKey(h)){const c=n.peek(h);if(c.getState()===B.LOADED)return c.endTransition(D(this)),Vo(t,c,i),!0}}return!1}findAltTiles_(e,t,n,i){const r=e.getTileRangeForTileCoordAndZ(t,n,this.tempTileRange_);if(!r)return!1;let o=!0;const a=this.tileCache_,l=this.getLayer().getRenderSource(),h=l.getKey();for(let c=r.minX;c<=r.maxX;++c)for(let u=r.minY;u<=r.maxY;++u){const d=Er(l,h,n,c,u);let f=!1;if(a.containsKey(d)){const g=a.peek(d);g.getState()===B.LOADED&&(Vo(i,g,n),f=!0)}f||(o=!1)}return o}renderFrame(e,t){this.renderComplete=!0;const n=e.layerStatesArray[e.layerIndex],i=e.viewState,r=i.projection,o=i.resolution,a=i.center,l=e.pixelRatio,h=this.getLayer(),c=h.getSource(),u=c.getTileGridForProjection(r),d=u.getZForResolution(o,c.zDirection),f=u.getResolution(d),g=c.getKey();this.renderedSourceKey_?this.renderedSourceKey_!==g&&(this.prependStaleKey(this.renderedSourceKey_),this.renderedSourceKey_=g):this.renderedSourceKey_=g;let m=e.extent;const _=c.getTilePixelRatio(l);this.prepareContainer(e,t);const p=this.context.canvas.width,y=this.context.canvas.height,E=n.extent&&St(n.extent);E&&(m=en(m,St(n.extent)));const x=f*p/2/_,T=f*y/2/_,R=[a[0]-x,a[1]-T,a[0]+x,a[1]+T],S={};this.renderedTiles.length=0;const v=h.getPreload();if(e.nextExtent&&this.enqueueTilesForNextExtent()){const G=u.getZForResolution(i.nextResolution,c.zDirection),H=sc(e,e.nextExtent);this.enqueueTiles(e,H,G,S,v)}const w=sc(e,m);if(this.enqueueTiles(e,w,d,S,0),v>0&&setTimeout(()=>{this.enqueueTiles(e,w,d-1,S,v-1)},0),!(d in S))return this.container;const I=D(this),F=e.time;for(const G of S[d]){const H=G.getState();if(H===B.EMPTY)continue;const Q=G.tileCoord;if(H===B.LOADED&&G.getAlpha(I,F)===1){G.endTransition(I);continue}if(H!==B.ERROR&&(this.renderComplete=!1),this.findStaleTile_(Q,S)){Jm(S,G,d),e.animate=!0;continue}if(this.findAltTiles_(u,Q,d+1,S))continue;const Ne=u.getMinZoom();for(let We=d-1;We>=Ne&&!this.findAltTiles_(u,Q,We,S);--We);}const L=f/o*l/_,b=this.getRenderContext(e);lt(this.tempTransform,p/2,y/2,L,L,0,-p/2,-y/2),n.extent&&this.clipUnrotated(b,e,E),c.getInterpolate()||(b.imageSmoothingEnabled=!1),this.preRender(b,e);const M=Object.keys(S).map(Number);M.sort(Ot);let K;const A=[],Z=[];for(let G=M.length-1;G>=0;--G){const H=M[G],Q=c.getTilePixelSize(H,l,r),P=u.getResolution(H)/f,Ne=Q[0]*P*L,We=Q[1]*P*L,xe=u.getTileCoordForCoordAndZ(An(R),H),tt=u.getTileCoordExtent(xe),Ge=de(this.tempTransform,[_*(tt[0]-R[0])/f,_*(R[3]-tt[3])/f]),Lt=_*c.getGutterForProjection(r);for(const Ct of S[H]){if(Ct.getState()!==B.LOADED)continue;const nt=Ct.tileCoord,Ys=xe[1]-nt[1],xo=Math.round(Ge[0]-(Ys-1)*Ne),qi=xe[2]-nt[2],bn=Math.round(Ge[1]-(qi-1)*We),ht=Math.round(Ge[0]-Ys*Ne),At=Math.round(Ge[1]-qi*We),oi=xo-ht,ai=bn-At,Ji=M.length===1;let Mn=!1;K=[ht,At,ht+oi,At,ht+oi,At+ai,ht,At+ai];for(let li=0,hi=A.length;li<hi;++li)if(!Ji&&H<Z[li]){const Ie=A[li];Ee([ht,At,ht+oi,At+ai],[Ie[0],Ie[3],Ie[4],Ie[7]])&&(Mn||(b.save(),Mn=!0),b.beginPath(),b.moveTo(K[0],K[1]),b.lineTo(K[2],K[3]),b.lineTo(K[4],K[5]),b.lineTo(K[6],K[7]),b.moveTo(Ie[6],Ie[7]),b.lineTo(Ie[4],Ie[5]),b.lineTo(Ie[2],Ie[3]),b.lineTo(Ie[0],Ie[1]),b.clip())}A.push(K),Z.push(H),this.drawTile(Ct,e,ht,At,oi,ai,Lt,Ji),Mn&&b.restore(),this.renderedTiles.unshift(Ct),this.updateUsedTiles(e.usedTiles,c,Ct)}}if(this.renderedResolution=f,this.extentChanged=!this.renderedExtent_||!Kn(this.renderedExtent_,R),this.renderedExtent_=R,this.renderedPixelRatio=l,this.postRender(this.context,e),n.extent&&b.restore(),b.imageSmoothingEnabled=!0,this.renderComplete){const G=(H,Q)=>{const le=D(c),P=Q.wantedTiles[le],Ne=P?Object.keys(P).length:0;this.updateCacheSize(Ne),this.tileCache_.expireCache(),this.sourceTileCache_?.expireCache()};e.postRenderFunctions.push(G)}return this.container}updateCacheSize(e){this.tileCache_.highWaterMark=Math.max(this.tileCache_.highWaterMark,e*2)}drawTile(e,t,n,i,r,o,a,l){let h;if(e instanceof Qh){if(h=Ma(e.getData()),!h)throw new Error("Rendering array data is not yet supported")}else h=this.getTileImage(e);if(!h)return;const c=this.getRenderContext(t),u=D(this),d=t.layerStatesArray[t.layerIndex],f=d.opacity*(l?e.getAlpha(u,t.time):1),g=f!==c.globalAlpha;g&&(c.save(),c.globalAlpha=f),c.drawImage(h,a,a,h.width-2*a,h.height-2*a,n,i,r,o),g&&c.restore(),f!==d.opacity?t.animate=!0:l&&e.endTransition(u)}getImage(){const e=this.context;return e?e.canvas:null}getTileImage(e){return e.getImage()}updateUsedTiles(e,t,n){const i=D(t);i in e||(e[i]={}),e[i][n.getKey()]=!0}}const En={PRELOAD:"preload",USE_INTERIM_TILES_ON_ERROR:"useInterimTilesOnError"};class Qm extends Us{constructor(e){e=e||{};const t=Object.assign({},e),n=e.cacheSize;delete e.cacheSize,delete t.preload,delete t.useInterimTilesOnError,super(t),this.on,this.once,this.un,this.cacheSize_=n,this.setPreload(e.preload!==void 0?e.preload:0),this.setUseInterimTilesOnError(e.useInterimTilesOnError!==void 0?e.useInterimTilesOnError:!0)}getCacheSize(){return this.cacheSize_}getPreload(){return this.get(En.PRELOAD)}setPreload(e){this.set(En.PRELOAD,e)}getUseInterimTilesOnError(){return this.get(En.USE_INTERIM_TILES_ON_ERROR)}setUseInterimTilesOnError(e){this.set(En.USE_INTERIM_TILES_ON_ERROR,e)}getData(e){return super.getData(e)}}class L0 extends Qm{constructor(e){super(e)}createRenderer(){return new zu(this,{cacheSize:this.getCacheSize()})}}class $u extends Ul{constructor(e){super(e),this.image=null}getImage(){return this.image?this.image.getImage():null}prepareFrame(e){const t=e.layerStatesArray[e.layerIndex],n=e.pixelRatio,i=e.viewState,r=i.resolution,o=this.getLayer().getSource(),a=e.viewHints;let l=e.extent;if(t.extent!==void 0&&(l=en(l,St(t.extent,i.projection))),!a[he.ANIMATING]&&!a[he.INTERACTING]&&!ti(l))if(o){const h=i.projection,c=o.getImage(l,r,n,h);c&&(this.loadImage(c)?this.image=c:c.getState()===U.EMPTY&&(this.image=null))}else this.image=null;return!!this.image}getData(e){const t=this.frameState;if(!t)return null;const n=this.getLayer(),i=de(t.pixelToCoordinateTransform,e.slice()),r=n.getExtent();if(r&&!Zn(r,i))return null;const o=this.image.getExtent(),a=this.image.getImage(),l=ne(o),h=Math.floor(a.width*((i[0]-o[0])/l));if(h<0||h>=a.width)return null;const c=be(o),u=Math.floor(a.height*((o[3]-i[1])/c));return u<0||u>=a.height?null:this.getImageData(a,h,u)}renderFrame(e,t){const n=this.image,i=n.getExtent(),r=n.getResolution(),[o,a]=Array.isArray(r)?r:[r,r],l=n.getPixelRatio(),h=e.layerStatesArray[e.layerIndex],c=e.pixelRatio,u=e.viewState,d=u.center,f=u.resolution,g=c*o/(f*l),m=c*a/(f*l);this.prepareContainer(e,t);const _=this.context.canvas.width,p=this.context.canvas.height,y=this.getRenderContext(e);let E=!1,x=!0;if(h.extent){const w=St(h.extent,u.projection);x=Ee(w,e.extent),E=x&&!pn(w,e.extent),E&&this.clipUnrotated(y,e,w)}const T=n.getImage(),R=lt(this.tempTransform,_/2,p/2,g,m,0,l*(i[0]-d[0])/o,l*(d[1]-i[3])/a);this.renderedResolution=a*c/l;const S=T.width*R[0],v=T.height*R[3];if(this.getLayer().getSource().getInterpolate()||(y.imageSmoothingEnabled=!1),this.preRender(y,e),x&&S>=.5&&v>=.5){const w=R[4],I=R[5],F=h.opacity;F!==1&&(y.save(),y.globalAlpha=F),y.drawImage(T,0,0,+T.width,+T.height,w,I,S,v),F!==1&&y.restore()}return this.postRender(this.context,e),E&&y.restore(),y.imageSmoothingEnabled=!0,this.container}}class ep extends Us{constructor(e){e=e||{},super(e)}}class A0 extends ep{constructor(e){super(e)}createRenderer(){return new $u(this)}getData(e){return super.getData(e)}}class Xu{drawCustom(e,t,n,i,r){}drawGeometry(e){}setStyle(e){}drawCircle(e,t,n){}drawFeature(e,t,n){}drawGeometryCollection(e,t,n){}drawLineString(e,t,n){}drawMultiLineString(e,t,n){}drawMultiPoint(e,t,n){}drawMultiPolygon(e,t,n){}drawPoint(e,t,n){}drawPolygon(e,t,n){}drawText(e,t,n){}setFillStrokeStyle(e,t){}setImageStyle(e,t){}setTextStyle(e,t){}}const X={BEGIN_GEOMETRY:0,BEGIN_PATH:1,CIRCLE:2,CLOSE_PATH:3,CUSTOM:4,DRAW_CHARS:5,DRAW_IMAGE:6,END_GEOMETRY:7,FILL:8,MOVE_TO_LINE_TO:9,SET_FILL_STYLE:10,SET_STROKE_STYLE:11,STROKE:12},rr=[X.FILL],Tn=[X.STROKE],$n=[X.BEGIN_PATH],rc=[X.CLOSE_PATH];class Xs extends Xu{constructor(e,t,n,i){super(),this.tolerance=e,this.maxExtent=t,this.pixelRatio=i,this.maxLineWidth=0,this.resolution=n,this.beginGeometryInstruction1_=null,this.beginGeometryInstruction2_=null,this.bufferedMaxExtent_=null,this.instructions=[],this.coordinates=[],this.tmpCoordinate_=[],this.hitDetectionInstructions=[],this.state={}}applyPixelRatio(e){const t=this.pixelRatio;return t==1?e:e.map(function(n){return n*t})}appendFlatPointCoordinates(e,t){const n=this.getBufferedMaxExtent(),i=this.tmpCoordinate_,r=this.coordinates;let o=r.length;for(let a=0,l=e.length;a<l;a+=t)i[0]=e[a],i[1]=e[a+1],Zn(n,i)&&(r[o++]=i[0],r[o++]=i[1]);return o}appendFlatLineCoordinates(e,t,n,i,r,o){const a=this.coordinates;let l=a.length;const h=this.getBufferedMaxExtent();o&&(t+=i);let c=e[t],u=e[t+1];const d=this.tmpCoordinate_;let f=!0,g,m,_;for(g=t+i;g<n;g+=i)d[0]=e[g],d[1]=e[g+1],_=ma(h,d),_!==m?(f&&(a[l++]=c,a[l++]=u,f=!1),a[l++]=d[0],a[l++]=d[1]):_===Ae.INTERSECTING?(a[l++]=d[0],a[l++]=d[1],f=!1):f=!0,c=d[0],u=d[1],m=_;return(r&&f||g===t+i)&&(a[l++]=c,a[l++]=u),l}drawCustomCoordinates_(e,t,n,i,r){for(let o=0,a=n.length;o<a;++o){const l=n[o],h=this.appendFlatLineCoordinates(e,t,l,i,!1,!1);r.push(h),t=l}return t}drawCustom(e,t,n,i,r){this.beginGeometry(e,t,r);const o=e.getType(),a=e.getStride(),l=this.coordinates.length;let h,c,u,d,f;switch(o){case"MultiPolygon":h=e.getOrientedFlatCoordinates(),d=[];const g=e.getEndss();f=0;for(let m=0,_=g.length;m<_;++m){const p=[];f=this.drawCustomCoordinates_(h,f,g[m],a,p),d.push(p)}this.instructions.push([X.CUSTOM,l,d,e,n,Sa,r]),this.hitDetectionInstructions.push([X.CUSTOM,l,d,e,i||n,Sa,r]);break;case"Polygon":case"MultiLineString":u=[],h=o=="Polygon"?e.getOrientedFlatCoordinates():e.getFlatCoordinates(),f=this.drawCustomCoordinates_(h,0,e.getEnds(),a,u),this.instructions.push([X.CUSTOM,l,u,e,n,Rs,r]),this.hitDetectionInstructions.push([X.CUSTOM,l,u,e,i||n,Rs,r]);break;case"LineString":case"Circle":h=e.getFlatCoordinates(),c=this.appendFlatLineCoordinates(h,0,h.length,a,!1,!1),this.instructions.push([X.CUSTOM,l,c,e,n,yn,r]),this.hitDetectionInstructions.push([X.CUSTOM,l,c,e,i||n,yn,r]);break;case"MultiPoint":h=e.getFlatCoordinates(),c=this.appendFlatPointCoordinates(h,a),c>l&&(this.instructions.push([X.CUSTOM,l,c,e,n,yn,r]),this.hitDetectionInstructions.push([X.CUSTOM,l,c,e,i||n,yn,r]));break;case"Point":h=e.getFlatCoordinates(),this.coordinates.push(h[0],h[1]),c=this.coordinates.length,this.instructions.push([X.CUSTOM,l,c,e,n,void 0,r]),this.hitDetectionInstructions.push([X.CUSTOM,l,c,e,i||n,void 0,r]);break}this.endGeometry(t)}beginGeometry(e,t,n){this.beginGeometryInstruction1_=[X.BEGIN_GEOMETRY,t,0,e,n],this.instructions.push(this.beginGeometryInstruction1_),this.beginGeometryInstruction2_=[X.BEGIN_GEOMETRY,t,0,e,n],this.hitDetectionInstructions.push(this.beginGeometryInstruction2_)}finish(){return{instructions:this.instructions,hitDetectionInstructions:this.hitDetectionInstructions,coordinates:this.coordinates}}reverseHitDetectionInstructions(){const e=this.hitDetectionInstructions;e.reverse();let t;const n=e.length;let i,r,o=-1;for(t=0;t<n;++t)i=e[t],r=i[0],r==X.END_GEOMETRY?o=t:r==X.BEGIN_GEOMETRY&&(i[2]=t,lf(this.hitDetectionInstructions,o,t),o=-1)}fillStyleToState(e,t={}){if(e){const n=e.getColor();t.fillPatternScale=n&&typeof n=="object"&&"src"in n?this.pixelRatio:1,t.fillStyle=Dt(n||Ke)}else t.fillStyle=void 0;return t}strokeStyleToState(e,t={}){if(e){const n=e.getColor();t.strokeStyle=Dt(n||ws);const i=e.getLineCap();t.lineCap=i!==void 0?i:Ui;const r=e.getLineDash();t.lineDash=r?r.slice():tn;const o=e.getLineDashOffset();t.lineDashOffset=o||nn;const a=e.getLineJoin();t.lineJoin=a!==void 0?a:Bi;const l=e.getWidth();t.lineWidth=l!==void 0?l:Is;const h=e.getMiterLimit();t.miterLimit=h!==void 0?h:vs,t.lineWidth>this.maxLineWidth&&(this.maxLineWidth=t.lineWidth,this.bufferedMaxExtent_=null)}else t.strokeStyle=void 0,t.lineCap=void 0,t.lineDash=null,t.lineDashOffset=void 0,t.lineJoin=void 0,t.lineWidth=void 0,t.miterLimit=void 0;return t}setFillStrokeStyle(e,t){const n=this.state;this.fillStyleToState(e,n),this.strokeStyleToState(t,n)}createFill(e){const t=e.fillStyle,n=[X.SET_FILL_STYLE,t];return typeof t!="string"&&n.push(e.fillPatternScale),n}applyStroke(e){this.instructions.push(this.createStroke(e))}createStroke(e){return[X.SET_STROKE_STYLE,e.strokeStyle,e.lineWidth*this.pixelRatio,e.lineCap,e.lineJoin,e.miterLimit,e.lineDash?this.applyPixelRatio(e.lineDash):null,e.lineDashOffset*this.pixelRatio]}updateFillStyle(e,t){const n=e.fillStyle;(typeof n!="string"||e.currentFillStyle!=n)&&(this.instructions.push(t.call(this,e)),e.currentFillStyle=n)}updateStrokeStyle(e,t){const n=e.strokeStyle,i=e.lineCap,r=e.lineDash,o=e.lineDashOffset,a=e.lineJoin,l=e.lineWidth,h=e.miterLimit;(e.currentStrokeStyle!=n||e.currentLineCap!=i||r!=e.currentLineDash&&!Ut(e.currentLineDash,r)||e.currentLineDashOffset!=o||e.currentLineJoin!=a||e.currentLineWidth!=l||e.currentMiterLimit!=h)&&(t.call(this,e),e.currentStrokeStyle=n,e.currentLineCap=i,e.currentLineDash=r,e.currentLineDashOffset=o,e.currentLineJoin=a,e.currentLineWidth=l,e.currentMiterLimit=h)}endGeometry(e){this.beginGeometryInstruction1_[2]=this.instructions.length,this.beginGeometryInstruction1_=null,this.beginGeometryInstruction2_[2]=this.hitDetectionInstructions.length,this.beginGeometryInstruction2_=null;const t=[X.END_GEOMETRY,e];this.instructions.push(t),this.hitDetectionInstructions.push(t)}getBufferedMaxExtent(){if(!this.bufferedMaxExtent_&&(this.bufferedMaxExtent_=kc(this.maxExtent),this.maxLineWidth>0)){const e=this.resolution*(this.maxLineWidth+1)/2;sn(this.bufferedMaxExtent_,e,this.bufferedMaxExtent_)}return this.bufferedMaxExtent_}}class tp extends Xs{constructor(e,t,n,i){super(e,t,n,i),this.hitDetectionImage_=null,this.image_=null,this.imagePixelRatio_=void 0,this.anchorX_=void 0,this.anchorY_=void 0,this.height_=void 0,this.opacity_=void 0,this.originX_=void 0,this.originY_=void 0,this.rotateWithView_=void 0,this.rotation_=void 0,this.scale_=void 0,this.width_=void 0,this.declutterMode_=void 0,this.declutterImageWithText_=void 0}drawPoint(e,t,n){if(!this.image_||this.maxExtent&&!Zn(this.maxExtent,e.getFlatCoordinates()))return;this.beginGeometry(e,t,n);const i=e.getFlatCoordinates(),r=e.getStride(),o=this.coordinates.length,a=this.appendFlatPointCoordinates(i,r);this.instructions.push([X.DRAW_IMAGE,o,a,this.image_,this.anchorX_*this.imagePixelRatio_,this.anchorY_*this.imagePixelRatio_,Math.ceil(this.height_*this.imagePixelRatio_),this.opacity_,this.originX_*this.imagePixelRatio_,this.originY_*this.imagePixelRatio_,this.rotateWithView_,this.rotation_,[this.scale_[0]*this.pixelRatio/this.imagePixelRatio_,this.scale_[1]*this.pixelRatio/this.imagePixelRatio_],Math.ceil(this.width_*this.imagePixelRatio_),this.declutterMode_,this.declutterImageWithText_]),this.hitDetectionInstructions.push([X.DRAW_IMAGE,o,a,this.hitDetectionImage_,this.anchorX_,this.anchorY_,this.height_,1,this.originX_,this.originY_,this.rotateWithView_,this.rotation_,this.scale_,this.width_,this.declutterMode_,this.declutterImageWithText_]),this.endGeometry(t)}drawMultiPoint(e,t,n){if(!this.image_)return;this.beginGeometry(e,t,n);const i=e.getFlatCoordinates(),r=[];for(let l=0,h=i.length;l<h;l+=e.getStride())(!this.maxExtent||Zn(this.maxExtent,i.slice(l,l+2)))&&r.push(i[l],i[l+1]);const o=this.coordinates.length,a=this.appendFlatPointCoordinates(r,2);this.instructions.push([X.DRAW_IMAGE,o,a,this.image_,this.anchorX_*this.imagePixelRatio_,this.anchorY_*this.imagePixelRatio_,Math.ceil(this.height_*this.imagePixelRatio_),this.opacity_,this.originX_*this.imagePixelRatio_,this.originY_*this.imagePixelRatio_,this.rotateWithView_,this.rotation_,[this.scale_[0]*this.pixelRatio/this.imagePixelRatio_,this.scale_[1]*this.pixelRatio/this.imagePixelRatio_],Math.ceil(this.width_*this.imagePixelRatio_),this.declutterMode_,this.declutterImageWithText_]),this.hitDetectionInstructions.push([X.DRAW_IMAGE,o,a,this.hitDetectionImage_,this.anchorX_,this.anchorY_,this.height_,1,this.originX_,this.originY_,this.rotateWithView_,this.rotation_,this.scale_,this.width_,this.declutterMode_,this.declutterImageWithText_]),this.endGeometry(t)}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(e,t){const n=e.getAnchor(),i=e.getSize(),r=e.getOrigin();this.imagePixelRatio_=e.getPixelRatio(this.pixelRatio),this.anchorX_=n[0],this.anchorY_=n[1],this.hitDetectionImage_=e.getHitDetectionImage(),this.image_=e.getImage(this.pixelRatio),this.height_=i[1],this.opacity_=e.getOpacity(),this.originX_=r[0],this.originY_=r[1],this.rotateWithView_=e.getRotateWithView(),this.rotation_=e.getRotation(),this.scale_=e.getScaleArray(),this.width_=i[0],this.declutterMode_=e.getDeclutterMode(),this.declutterImageWithText_=t}}class np extends Xs{constructor(e,t,n,i){super(e,t,n,i)}drawFlatCoordinates_(e,t,n,i){const r=this.coordinates.length,o=this.appendFlatLineCoordinates(e,t,n,i,!1,!1),a=[X.MOVE_TO_LINE_TO,r,o];return this.instructions.push(a),this.hitDetectionInstructions.push(a),n}drawLineString(e,t,n){const i=this.state,r=i.strokeStyle,o=i.lineWidth;if(r===void 0||o===void 0)return;this.updateStrokeStyle(i,this.applyStroke),this.beginGeometry(e,t,n),this.hitDetectionInstructions.push([X.SET_STROKE_STYLE,i.strokeStyle,i.lineWidth,i.lineCap,i.lineJoin,i.miterLimit,tn,nn],$n);const a=e.getFlatCoordinates(),l=e.getStride();this.drawFlatCoordinates_(a,0,a.length,l),this.hitDetectionInstructions.push(Tn),this.endGeometry(t)}drawMultiLineString(e,t,n){const i=this.state,r=i.strokeStyle,o=i.lineWidth;if(r===void 0||o===void 0)return;this.updateStrokeStyle(i,this.applyStroke),this.beginGeometry(e,t,n),this.hitDetectionInstructions.push([X.SET_STROKE_STYLE,i.strokeStyle,i.lineWidth,i.lineCap,i.lineJoin,i.miterLimit,tn,nn],$n);const a=e.getEnds(),l=e.getFlatCoordinates(),h=e.getStride();let c=0;for(let u=0,d=a.length;u<d;++u)c=this.drawFlatCoordinates_(l,c,a[u],h);this.hitDetectionInstructions.push(Tn),this.endGeometry(t)}finish(){const e=this.state;return e.lastStroke!=null&&e.lastStroke!=this.coordinates.length&&this.instructions.push(Tn),this.reverseHitDetectionInstructions(),this.state=null,super.finish()}applyStroke(e){e.lastStroke!=null&&e.lastStroke!=this.coordinates.length&&(this.instructions.push(Tn),e.lastStroke=this.coordinates.length),e.lastStroke=0,super.applyStroke(e),this.instructions.push($n)}}class oc extends Xs{constructor(e,t,n,i){super(e,t,n,i)}drawFlatCoordinatess_(e,t,n,i){const r=this.state,o=r.fillStyle!==void 0,a=r.strokeStyle!==void 0,l=n.length;this.instructions.push($n),this.hitDetectionInstructions.push($n);for(let h=0;h<l;++h){const c=n[h],u=this.coordinates.length,d=this.appendFlatLineCoordinates(e,t,c,i,!0,!a),f=[X.MOVE_TO_LINE_TO,u,d];this.instructions.push(f),this.hitDetectionInstructions.push(f),a&&(this.instructions.push(rc),this.hitDetectionInstructions.push(rc)),t=c}return o&&(this.instructions.push(rr),this.hitDetectionInstructions.push(rr)),a&&(this.instructions.push(Tn),this.hitDetectionInstructions.push(Tn)),t}drawCircle(e,t,n){const i=this.state,r=i.fillStyle,o=i.strokeStyle;if(r===void 0&&o===void 0)return;this.setFillStrokeStyles_(),this.beginGeometry(e,t,n),i.fillStyle!==void 0&&this.hitDetectionInstructions.push([X.SET_FILL_STYLE,Ke]),i.strokeStyle!==void 0&&this.hitDetectionInstructions.push([X.SET_STROKE_STYLE,i.strokeStyle,i.lineWidth,i.lineCap,i.lineJoin,i.miterLimit,tn,nn]);const a=e.getFlatCoordinates(),l=e.getStride(),h=this.coordinates.length;this.appendFlatLineCoordinates(a,0,a.length,l,!1,!1);const c=[X.CIRCLE,h];this.instructions.push($n,c),this.hitDetectionInstructions.push($n,c),i.fillStyle!==void 0&&(this.instructions.push(rr),this.hitDetectionInstructions.push(rr)),i.strokeStyle!==void 0&&(this.instructions.push(Tn),this.hitDetectionInstructions.push(Tn)),this.endGeometry(t)}drawPolygon(e,t,n){const i=this.state,r=i.fillStyle,o=i.strokeStyle;if(r===void 0&&o===void 0)return;this.setFillStrokeStyles_(),this.beginGeometry(e,t,n),i.fillStyle!==void 0&&this.hitDetectionInstructions.push([X.SET_FILL_STYLE,Ke]),i.strokeStyle!==void 0&&this.hitDetectionInstructions.push([X.SET_STROKE_STYLE,i.strokeStyle,i.lineWidth,i.lineCap,i.lineJoin,i.miterLimit,tn,nn]);const a=e.getEnds(),l=e.getOrientedFlatCoordinates(),h=e.getStride();this.drawFlatCoordinatess_(l,0,a,h),this.endGeometry(t)}drawMultiPolygon(e,t,n){const i=this.state,r=i.fillStyle,o=i.strokeStyle;if(r===void 0&&o===void 0)return;this.setFillStrokeStyles_(),this.beginGeometry(e,t,n),i.fillStyle!==void 0&&this.hitDetectionInstructions.push([X.SET_FILL_STYLE,Ke]),i.strokeStyle!==void 0&&this.hitDetectionInstructions.push([X.SET_STROKE_STYLE,i.strokeStyle,i.lineWidth,i.lineCap,i.lineJoin,i.miterLimit,tn,nn]);const a=e.getEndss(),l=e.getOrientedFlatCoordinates(),h=e.getStride();let c=0;for(let u=0,d=a.length;u<d;++u)c=this.drawFlatCoordinatess_(l,c,a[u],h);this.endGeometry(t)}finish(){this.reverseHitDetectionInstructions(),this.state=null;const e=this.tolerance;if(e!==0){const t=this.coordinates;for(let n=0,i=t.length;n<i;++n)t[n]=Gn(t[n],e)}return super.finish()}setFillStrokeStyles_(){const e=this.state;this.updateFillStyle(e,this.createFill),this.updateStrokeStyle(e,this.applyStroke)}}function ip(s,e,t,n,i){const r=[];let o=t,a=0,l=e.slice(t,2);for(;a<s&&o+i<n;){const[h,c]=l.slice(-2),u=e[o+i],d=e[o+i+1],f=Math.sqrt((u-h)*(u-h)+(d-c)*(d-c));if(a+=f,a>=s){const g=(s-a+f)/f,m=it(h,u,g),_=it(c,d,g);l.push(m,_),r.push(l),l=[m,_],a==s&&(o+=i),a=0}else if(a<s)l.push(e[o+i],e[o+i+1]),o+=i;else{const g=f-a,m=it(h,u,g/f),_=it(c,d,g/f);l.push(m,_),r.push(l),l=[m,_],a=0,o+=i}}return a>0&&r.push(l),r}function sp(s,e,t,n,i){let r=t,o=t,a=0,l=0,h=t,c,u,d,f,g,m,_,p,y,E;for(u=t;u<n;u+=i){const x=e[u],T=e[u+1];g!==void 0&&(y=x-g,E=T-m,f=Math.sqrt(y*y+E*E),_!==void 0&&(l+=d,c=Math.acos((_*y+p*E)/(d*f)),c>s&&(l>a&&(a=l,r=h,o=u),l=0,h=u-i)),d=f,_=y,p=E),g=x,m=T}return l+=f,l>a?[h,u]:[r,o]}const Ur={left:0,center:.5,right:1,top:0,middle:.5,hanging:.2,alphabetic:.8,ideographic:.8,bottom:1};class rp extends Xs{constructor(e,t,n,i){super(e,t,n,i),this.labels_=null,this.text_="",this.textOffsetX_=0,this.textOffsetY_=0,this.textRotateWithView_=void 0,this.textKeepUpright_=void 0,this.textRotation_=0,this.textFillState_=null,this.fillStates={},this.fillStates[Ke]={fillStyle:Ke},this.textStrokeState_=null,this.strokeStates={},this.textState_={},this.textStates={},this.textKey_="",this.fillKey_="",this.strokeKey_="",this.declutterMode_=void 0,this.declutterImageWithText_=void 0}finish(){const e=super.finish();return e.textStates=this.textStates,e.fillStates=this.fillStates,e.strokeStates=this.strokeStates,e}drawText(e,t,n){const i=this.textFillState_,r=this.textStrokeState_,o=this.textState_;if(this.text_===""||!o||!i&&!r)return;const a=this.coordinates;let l=a.length;const h=e.getType();let c=null,u=e.getStride();if(o.placement==="line"&&(h=="LineString"||h=="MultiLineString"||h=="Polygon"||h=="MultiPolygon")){if(!Ee(this.maxExtent,e.getExtent()))return;let d;if(c=e.getFlatCoordinates(),h=="LineString")d=[c.length];else if(h=="MultiLineString")d=e.getEnds();else if(h=="Polygon")d=e.getEnds().slice(0,1);else if(h=="MultiPolygon"){const _=e.getEndss();d=[];for(let p=0,y=_.length;p<y;++p)d.push(_[p][0])}this.beginGeometry(e,t,n);const f=o.repeat,g=f?void 0:o.textAlign;let m=0;for(let _=0,p=d.length;_<p;++_){let y;f?y=ip(f*this.resolution,c,m,d[_],u):y=[c.slice(m,d[_])];for(let E=0,x=y.length;E<x;++E){const T=y[E];let R=0,S=T.length;if(g==null){const w=sp(o.maxAngle,T,0,T.length,2);R=w[0],S=w[1]}for(let w=R;w<S;w+=u)a.push(T[w],T[w+1]);const v=a.length;m=d[_],this.drawChars_(l,v),l=v}}this.endGeometry(t)}else{let d=o.overflow?null:[];switch(h){case"Point":case"MultiPoint":c=e.getFlatCoordinates();break;case"LineString":c=e.getFlatMidpoint();break;case"Circle":c=e.getCenter();break;case"MultiLineString":c=e.getFlatMidpoints(),u=2;break;case"Polygon":c=e.getFlatInteriorPoint(),o.overflow||d.push(c[2]/this.resolution),u=3;break;case"MultiPolygon":const x=e.getFlatInteriorPoints();c=[];for(let T=0,R=x.length;T<R;T+=3)o.overflow||d.push(x[T+2]/this.resolution),c.push(x[T],x[T+1]);if(c.length===0)return;u=2;break}const f=this.appendFlatPointCoordinates(c,u);if(f===l)return;if(d&&(f-l)/2!==c.length/u){let x=l/2;d=d.filter((T,R)=>{const S=a[(x+R)*2]===c[R*u]&&a[(x+R)*2+1]===c[R*u+1];return S||--x,S})}this.saveTextStates_();const g=o.backgroundFill?this.createFill(this.fillStyleToState(o.backgroundFill)):null,m=o.backgroundStroke?this.createStroke(this.strokeStyleToState(o.backgroundStroke)):null;this.beginGeometry(e,t,n);let _=o.padding;if(_!=zn&&(o.scale[0]<0||o.scale[1]<0)){let x=o.padding[0],T=o.padding[1],R=o.padding[2],S=o.padding[3];o.scale[0]<0&&(T=-T,S=-S),o.scale[1]<0&&(x=-x,R=-R),_=[x,T,R,S]}const p=this.pixelRatio;this.instructions.push([X.DRAW_IMAGE,l,f,null,NaN,NaN,NaN,1,0,0,this.textRotateWithView_,this.textRotation_,[1,1],NaN,this.declutterMode_,this.declutterImageWithText_,_==zn?zn:_.map(function(x){return x*p}),g,m,this.text_,this.textKey_,this.strokeKey_,this.fillKey_,this.textOffsetX_,this.textOffsetY_,d]);const y=1/p,E=g?g.slice(0):null;E&&(E[1]=Ke),this.hitDetectionInstructions.push([X.DRAW_IMAGE,l,f,null,NaN,NaN,NaN,1,0,0,this.textRotateWithView_,this.textRotation_,[y,y],NaN,this.declutterMode_,this.declutterImageWithText_,_,E,m,this.text_,this.textKey_,this.strokeKey_,this.fillKey_?Ke:this.fillKey_,this.textOffsetX_,this.textOffsetY_,d]),this.endGeometry(t)}}saveTextStates_(){const e=this.textStrokeState_,t=this.textState_,n=this.textFillState_,i=this.strokeKey_;e&&(i in this.strokeStates||(this.strokeStates[i]={strokeStyle:e.strokeStyle,lineCap:e.lineCap,lineDashOffset:e.lineDashOffset,lineWidth:e.lineWidth,lineJoin:e.lineJoin,miterLimit:e.miterLimit,lineDash:e.lineDash}));const r=this.textKey_;r in this.textStates||(this.textStates[r]={font:t.font,textAlign:t.textAlign||Ps,justify:t.justify,textBaseline:t.textBaseline||Or,scale:t.scale});const o=this.fillKey_;n&&(o in this.fillStates||(this.fillStates[o]={fillStyle:n.fillStyle}))}drawChars_(e,t){const n=this.textStrokeState_,i=this.textState_,r=this.strokeKey_,o=this.textKey_,a=this.fillKey_;this.saveTextStates_();const l=this.pixelRatio,h=Ur[i.textBaseline],c=this.textOffsetY_*l,u=this.text_,d=n?n.lineWidth*Math.abs(i.scale[0])/2:0;this.instructions.push([X.DRAW_CHARS,e,t,h,i.overflow,a,i.maxAngle,l,c,r,d*l,u,o,1,this.declutterMode_,this.textKeepUpright_]),this.hitDetectionInstructions.push([X.DRAW_CHARS,e,t,h,i.overflow,a&&Ke,i.maxAngle,l,c,r,d*l,u,o,1/l,this.declutterMode_,this.textKeepUpright_])}setTextStyle(e,t){let n,i,r;if(!e)this.text_="";else{const o=e.getFill();o?(i=this.textFillState_,i||(i={},this.textFillState_=i),i.fillStyle=Dt(o.getColor()||Ke)):(i=null,this.textFillState_=i);const a=e.getStroke();if(!a)r=null,this.textStrokeState_=r;else{r=this.textStrokeState_,r||(r={},this.textStrokeState_=r);const m=a.getLineDash(),_=a.getLineDashOffset(),p=a.getWidth(),y=a.getMiterLimit();r.lineCap=a.getLineCap()||Ui,r.lineDash=m?m.slice():tn,r.lineDashOffset=_===void 0?nn:_,r.lineJoin=a.getLineJoin()||Bi,r.lineWidth=p===void 0?Is:p,r.miterLimit=y===void 0?vs:y,r.strokeStyle=Dt(a.getColor()||ws)}n=this.textState_;const l=e.getFont()||Pu;dm(l);const h=e.getScaleArray();n.overflow=e.getOverflow(),n.font=l,n.maxAngle=e.getMaxAngle(),n.placement=e.getPlacement(),n.textAlign=e.getTextAlign(),n.repeat=e.getRepeat(),n.justify=e.getJustify(),n.textBaseline=e.getTextBaseline()||Or,n.backgroundFill=e.getBackgroundFill(),n.backgroundStroke=e.getBackgroundStroke(),n.padding=e.getPadding()||zn,n.scale=h===void 0?[1,1]:h;const c=e.getOffsetX(),u=e.getOffsetY(),d=e.getRotateWithView(),f=e.getKeepUpright(),g=e.getRotation();this.text_=e.getText()||"",this.textOffsetX_=c===void 0?0:c,this.textOffsetY_=u===void 0?0:u,this.textRotateWithView_=d===void 0?!1:d,this.textKeepUpright_=f===void 0?!0:f,this.textRotation_=g===void 0?0:g,this.strokeKey_=r?(typeof r.strokeStyle=="string"?r.strokeStyle:D(r.strokeStyle))+r.lineCap+r.lineDashOffset+"|"+r.lineWidth+r.lineJoin+r.miterLimit+"["+r.lineDash.join()+"]":"",this.textKey_=n.font+n.scale+(n.textAlign||"?")+(n.repeat||"?")+(n.justify||"?")+(n.textBaseline||"?"),this.fillKey_=i&&i.fillStyle?typeof i.fillStyle=="string"?i.fillStyle:"|"+D(i.fillStyle):""}this.declutterMode_=e.getDeclutterMode(),this.declutterImageWithText_=t}}const op={Circle:oc,Default:Xs,Image:tp,LineString:np,Polygon:oc,Text:rp};class Wu{constructor(e,t,n,i){this.tolerance_=e,this.maxExtent_=t,this.pixelRatio_=i,this.resolution_=n,this.buildersByZIndex_={}}finish(){const e={};for(const t in this.buildersByZIndex_){e[t]=e[t]||{};const n=this.buildersByZIndex_[t];for(const i in n){const r=n[i].finish();e[t][i]=r}}return e}getBuilder(e,t){const n=e!==void 0?e.toString():"0";let i=this.buildersByZIndex_[n];i===void 0&&(i={},this.buildersByZIndex_[n]=i);let r=i[t];if(r===void 0){const o=op[t];r=new o(this.tolerance_,this.maxExtent_,this.resolution_,this.pixelRatio_),i[t]=r}return r}}function Bl(s,e,t,n){let i=s[e],r=s[e+1],o=0;for(let a=e+n;a<t;a+=n){const l=s[a],h=s[a+1];o+=Math.sqrt((l-i)*(l-i)+(h-r)*(h-r)),i=l,r=h}return o}function ap(s,e,t,n,i,r,o,a,l,h,c,u,d=!0){let f=s[e],g=s[e+1],m=0,_=0,p=0,y=0;function E(){m=f,_=g,e+=n,f=s[e],g=s[e+1],y+=p,p=Math.sqrt((f-m)*(f-m)+(g-_)*(g-_))}do E();while(e<t-n&&y+p<r);let x=p===0?0:(r-y)/p;const T=it(m,f,x),R=it(_,g,x),S=e-n,v=y,w=r+a*l(h,i,c);for(;e<t-n&&y+p<w;)E();x=p===0?0:(w-y)/p;const I=it(m,f,x),F=it(_,g,x);let L=!1;if(d)if(u){const Z=[T,R,I,F];ll(Z,0,4,2,u,Z,Z),L=Z[0]>Z[2]}else L=T>I;const b=Math.PI,M=[],K=S+n===e;e=S,p=0,y=v,f=s[e],g=s[e+1];let A;if(K){E(),A=Math.atan2(g-_,f-m),L&&(A+=A>0?-b:b);const Z=(I+T)/2,G=(F+R)/2;return M[0]=[Z,G,(w-r)/2,A,i],M}i=i.replace(/\n/g," ");for(let Z=0,G=i.length;Z<G;){E();let H=Math.atan2(g-_,f-m);if(L&&(H+=H>0?-b:b),A!==void 0){let xe=H-A;if(xe+=xe>b?-2*b:xe<-b?2*b:0,Math.abs(xe)>o)return null}A=H;const Q=Z;let le=0;for(;Z<G;++Z){const xe=L?G-Z-1:Z,tt=a*l(h,i[xe],c);if(e+n<t&&y+p<r+le+tt/2)break;le+=tt}if(Z===Q)continue;const P=L?i.substring(G-Q,G-Z):i.substring(Q,Z);x=p===0?0:(r+le/2-y)/p;const Ne=it(m,f,x),We=it(_,g,x);M.push([Ne,We,le/2,H,P]),r+=le}return M}const _i=Je(),un=[],Xt=[],Wt=[],dn=[];function ac(s){return s[3].declutterBox}const lc=new RegExp("[֑-ࣿיִ-﷿ﹰ-ﻼࠀ--]");function Zo(s,e){return e==="start"?e=lc.test(s)?"right":"left":e==="end"&&(e=lc.test(s)?"left":"right"),Ur[e]}function lp(s,e,t){return t>0&&s.push(`
|
||
`,""),s.push(e,""),s}function hp(s,e,t){return t%2===0&&(s+=e),s}class cp{constructor(e,t,n,i,r){this.overlaps=n,this.pixelRatio=t,this.resolution=e,this.alignAndScaleFill_,this.instructions=i.instructions,this.coordinates=i.coordinates,this.coordinateCache_={},this.renderedTransform_=Te(),this.hitDetectionInstructions=i.hitDetectionInstructions,this.pixelCoordinates_=null,this.viewRotation_=0,this.fillStates=i.fillStates||{},this.strokeStates=i.strokeStates||{},this.textStates=i.textStates||{},this.widths_={},this.labels_={},this.zIndexContext_=r?new kl:null}getZIndexContext(){return this.zIndexContext_}createLabel(e,t,n,i){const r=e+t+n+i;if(this.labels_[r])return this.labels_[r];const o=i?this.strokeStates[i]:null,a=n?this.fillStates[n]:null,l=this.textStates[t],h=this.pixelRatio,c=[l.scale[0]*h,l.scale[1]*h],u=l.justify?Ur[l.justify]:Zo(Array.isArray(e)?e[0]:e,l.textAlign||Ps),d=i&&o.lineWidth?o.lineWidth:0,f=Array.isArray(e)?e:String(e).split(`
|
||
`).reduce(lp,[]),{width:g,height:m,widths:_,heights:p,lineWidths:y}=gm(l,f),E=g+d,x=[],T=(E+2)*c[0],R=(m+d)*c[1],S={width:T<0?Math.floor(T):Math.ceil(T),height:R<0?Math.floor(R):Math.ceil(R),contextInstructions:x};(c[0]!=1||c[1]!=1)&&x.push("scale",c),i&&(x.push("strokeStyle",o.strokeStyle),x.push("lineWidth",d),x.push("lineCap",o.lineCap),x.push("lineJoin",o.lineJoin),x.push("miterLimit",o.miterLimit),x.push("setLineDash",[o.lineDash]),x.push("lineDashOffset",o.lineDashOffset)),n&&x.push("fillStyle",a.fillStyle),x.push("textBaseline","middle"),x.push("textAlign","center");const v=.5-u;let w=u*E+v*d;const I=[],F=[];let L=0,b=0,M=0,K=0,A;for(let Z=0,G=f.length;Z<G;Z+=2){const H=f[Z];if(H===`
|
||
`){b+=L,L=0,w=u*E+v*d,++K;continue}const Q=f[Z+1]||l.font;Q!==A&&(i&&I.push("font",Q),n&&F.push("font",Q),A=Q),L=Math.max(L,p[M]);const le=[H,w+v*_[M]+u*(_[M]-y[K]),.5*(d+L)+b];w+=_[M],i&&I.push("strokeText",le),n&&F.push("fillText",le),++M}return Array.prototype.push.apply(x,I),Array.prototype.push.apply(x,F),this.labels_[r]=S,S}replayTextBackground_(e,t,n,i,r,o,a){e.beginPath(),e.moveTo.apply(e,t),e.lineTo.apply(e,n),e.lineTo.apply(e,i),e.lineTo.apply(e,r),e.lineTo.apply(e,t),o&&(this.alignAndScaleFill_=o[2],e.fillStyle=o[1],this.fill_(e)),a&&(this.setStrokeStyle_(e,a),e.stroke())}calculateImageOrLabelDimensions_(e,t,n,i,r,o,a,l,h,c,u,d,f,g,m,_){a*=d[0],l*=d[1];let p=n-a,y=i-l;const E=r+h>e?e-h:r,x=o+c>t?t-c:o,T=g[3]+E*d[0]+g[1],R=g[0]+x*d[1]+g[2],S=p-g[3],v=y-g[0];(m||u!==0)&&(un[0]=S,dn[0]=S,un[1]=v,Xt[1]=v,Xt[0]=S+T,Wt[0]=Xt[0],Wt[1]=v+R,dn[1]=Wt[1]);let w;return u!==0?(w=lt(Te(),n,i,1,1,u,-n,-i),de(w,un),de(w,Xt),de(w,Wt),de(w,dn),kt(Math.min(un[0],Xt[0],Wt[0],dn[0]),Math.min(un[1],Xt[1],Wt[1],dn[1]),Math.max(un[0],Xt[0],Wt[0],dn[0]),Math.max(un[1],Xt[1],Wt[1],dn[1]),_i)):kt(Math.min(S,S+T),Math.min(v,v+R),Math.max(S,S+T),Math.max(v,v+R),_i),f&&(p=Math.round(p),y=Math.round(y)),{drawImageX:p,drawImageY:y,drawImageW:E,drawImageH:x,originX:h,originY:c,declutterBox:{minX:_i[0],minY:_i[1],maxX:_i[2],maxY:_i[3],value:_},canvasTransform:w,scale:d}}replayImageOrLabel_(e,t,n,i,r,o,a){const l=!!(o||a),h=i.declutterBox,c=a?a[2]*i.scale[0]/2:0;return h.minX-c<=t[0]&&h.maxX+c>=0&&h.minY-c<=t[1]&&h.maxY+c>=0&&(l&&this.replayTextBackground_(e,un,Xt,Wt,dn,o,a),_m(e,i.canvasTransform,r,n,i.originX,i.originY,i.drawImageW,i.drawImageH,i.drawImageX,i.drawImageY,i.scale)),!0}fill_(e){const t=this.alignAndScaleFill_;if(t){const n=de(this.renderedTransform_,[0,0]),i=512*this.pixelRatio;e.save(),e.translate(n[0]%i,n[1]%i),t!==1&&e.scale(t,t),e.rotate(this.viewRotation_)}e.fill(),t&&e.restore()}setStrokeStyle_(e,t){e.strokeStyle=t[1],t[1]&&(e.lineWidth=t[2],e.lineCap=t[3],e.lineJoin=t[4],e.miterLimit=t[5],e.lineDashOffset=t[7],e.setLineDash(t[6]))}drawLabelWithPointPlacement_(e,t,n,i){const r=this.textStates[t],o=this.createLabel(e,t,i,n),a=this.strokeStates[n],l=this.pixelRatio,h=Zo(Array.isArray(e)?e[0]:e,r.textAlign||Ps),c=Ur[r.textBaseline||Or],u=a&&a.lineWidth?a.lineWidth:0,d=o.width/l-2*r.scale[0],f=h*d+2*(.5-h)*u,g=c*o.height/l+2*(.5-c)*u;return{label:o,anchorX:f,anchorY:g}}execute_(e,t,n,i,r,o,a,l){const h=this.zIndexContext_;let c;this.pixelCoordinates_&&Ut(n,this.renderedTransform_)?c=this.pixelCoordinates_:(this.pixelCoordinates_||(this.pixelCoordinates_=[]),c=Nt(this.coordinates,0,this.coordinates.length,2,n,this.pixelCoordinates_),eu(this.renderedTransform_,n));let u=0;const d=i.length;let f=0,g,m,_,p,y,E,x,T,R,S,v,w,I,F=0,L=0;const b=this.coordinateCache_,M=this.viewRotation_,K=Math.round(Math.atan2(-n[1],n[0])*1e12)/1e12,A={context:e,pixelRatio:this.pixelRatio,resolution:this.resolution,rotation:M},Z=this.instructions!=i||this.overlaps?0:200;let G,H,Q,le;for(;u<d;){const P=i[u];switch(P[0]){case X.BEGIN_GEOMETRY:G=P[1],le=P[3],G.getGeometry()?a!==void 0&&!Ee(a,le.getExtent())?u=P[2]+1:++u:u=P[2],h&&(h.zIndex=P[4]);break;case X.BEGIN_PATH:F>Z&&(this.fill_(e),F=0),L>Z&&(e.stroke(),L=0),!F&&!L&&(e.beginPath(),y=NaN,E=NaN),++u;break;case X.CIRCLE:f=P[1];const We=c[f],xe=c[f+1],tt=c[f+2],Ge=c[f+3],Lt=tt-We,Ct=Ge-xe,nt=Math.sqrt(Lt*Lt+Ct*Ct);e.moveTo(We+nt,xe),e.arc(We,xe,nt,0,2*Math.PI,!0),++u;break;case X.CLOSE_PATH:e.closePath(),++u;break;case X.CUSTOM:f=P[1],g=P[2];const Ys=P[3],xo=P[4],qi=P[5];A.geometry=Ys,A.feature=G,u in b||(b[u]=[]);const bn=b[u];qi?qi(c,f,g,2,bn):(bn[0]=c[f],bn[1]=c[f+1],bn.length=2),h&&(h.zIndex=P[6]),xo(bn,A),++u;break;case X.DRAW_IMAGE:f=P[1],g=P[2],R=P[3],m=P[4],_=P[5];let ht=P[6];const At=P[7],oi=P[8],ai=P[9],Ji=P[10];let Mn=P[11];const li=P[12];let hi=P[13];p=P[14]||"declutter";const Ie=P[15];if(!R&&P.length>=20){S=P[19],v=P[20],w=P[21],I=P[22];const ct=this.drawLabelWithPointPlacement_(S,v,w,I);R=ct.label,P[3]=R;const Dn=P[23];m=(ct.anchorX-Dn)*this.pixelRatio,P[4]=m;const ut=P[24];_=(ct.anchorY-ut)*this.pixelRatio,P[5]=_,ht=R.height,P[6]=ht,hi=R.width,P[13]=hi}let Eo;P.length>25&&(Eo=P[25]);let To,js,Vs;P.length>17?(To=P[16],js=P[17],Vs=P[18]):(To=zn,js=null,Vs=null),Ji&&K?Mn+=M:!Ji&&!K&&(Mn-=M);let Jd=0;for(;f<g;f+=2){if(Eo&&Eo[Jd++]<hi/this.pixelRatio)continue;const ct=this.calculateImageOrLabelDimensions_(R.width,R.height,c[f],c[f+1],hi,ht,m,_,oi,ai,Mn,li,r,To,!!js||!!Vs,G),Dn=[e,t,R,ct,At,js,Vs];if(l){let ut,Ft,dt;if(Ie){const ye=g-f;if(!Ie[ye]){Ie[ye]={args:Dn,declutterMode:p};continue}const Ye=Ie[ye];ut=Ye.args,Ft=Ye.declutterMode,delete Ie[ye],dt=ac(ut)}let Bt,zt;if(ut&&(Ft!=="declutter"||!l.collides(dt))&&(Bt=!0),(p!=="declutter"||!l.collides(ct.declutterBox))&&(zt=!0),Ft==="declutter"&&p==="declutter"){const ye=Bt&&zt;Bt=ye,zt=ye}Bt&&(Ft!=="none"&&l.insert(dt),this.replayImageOrLabel_.apply(this,ut)),zt&&(p!=="none"&&l.insert(ct.declutterBox),this.replayImageOrLabel_.apply(this,Dn))}else this.replayImageOrLabel_.apply(this,Dn)}++u;break;case X.DRAW_CHARS:const lh=P[1],hh=P[2],Co=P[3],Qd=P[4];I=P[5];const ef=P[6],ch=P[7],uh=P[8];w=P[9];const Ro=P[10];S=P[11],Array.isArray(S)&&(S=S.reduce(hp,"")),v=P[12];const dh=[P[13],P[13]];p=P[14]||"declutter";const tf=P[15],So=this.textStates[v],Qi=So.font,es=[So.scale[0]*ch,So.scale[1]*ch];let ts;Qi in this.widths_?ts=this.widths_[Qi]:(ts={},this.widths_[Qi]=ts);const fh=Bl(c,lh,hh,2),gh=Math.abs(es[0])*Yh(Qi,S,ts);if(Qd||gh<=fh){const ct=this.textStates[v].textAlign,Dn=(fh-gh)*Zo(S,ct),ut=ap(c,lh,hh,2,S,Dn,ef,Math.abs(es[0]),Yh,Qi,ts,K?0:this.viewRotation_,tf);e:if(ut){const Ft=[];let dt,Bt,zt,ye,Ye;if(w)for(dt=0,Bt=ut.length;dt<Bt;++dt){Ye=ut[dt],zt=Ye[4],ye=this.createLabel(zt,v,"",w),m=Ye[2]+(es[0]<0?-Ro:Ro),_=Co*ye.height+(.5-Co)*2*Ro*es[1]/es[0]-uh;const $t=this.calculateImageOrLabelDimensions_(ye.width,ye.height,Ye[0],Ye[1],ye.width,ye.height,m,_,0,0,Ye[3],dh,!1,zn,!1,G);if(l&&p==="declutter"&&l.collides($t.declutterBox))break e;Ft.push([e,t,ye,$t,1,null,null])}if(I)for(dt=0,Bt=ut.length;dt<Bt;++dt){Ye=ut[dt],zt=Ye[4],ye=this.createLabel(zt,v,I,""),m=Ye[2],_=Co*ye.height-uh;const $t=this.calculateImageOrLabelDimensions_(ye.width,ye.height,Ye[0],Ye[1],ye.width,ye.height,m,_,0,0,Ye[3],dh,!1,zn,!1,G);if(l&&p==="declutter"&&l.collides($t.declutterBox))break e;Ft.push([e,t,ye,$t,1,null,null])}l&&p!=="none"&&l.load(Ft.map(ac));for(let $t=0,nf=Ft.length;$t<nf;++$t)this.replayImageOrLabel_.apply(this,Ft[$t])}}++u;break;case X.END_GEOMETRY:if(o!==void 0){G=P[1];const ct=o(G,le,p);if(ct)return ct}++u;break;case X.FILL:Z?F++:this.fill_(e),++u;break;case X.MOVE_TO_LINE_TO:for(f=P[1],g=P[2],H=c[f],Q=c[f+1],e.moveTo(H,Q),y=H+.5|0,E=Q+.5|0,f+=2;f<g;f+=2)H=c[f],Q=c[f+1],x=H+.5|0,T=Q+.5|0,(f==g-2||x!==y||T!==E)&&(e.lineTo(H,Q),y=x,E=T);++u;break;case X.SET_FILL_STYLE:this.alignAndScaleFill_=P[2],F&&(this.fill_(e),F=0,L&&(e.stroke(),L=0)),e.fillStyle=P[1],++u;break;case X.SET_STROKE_STYLE:L&&(e.stroke(),L=0),this.setStrokeStyle_(e,P),++u;break;case X.STROKE:Z?L++:e.stroke(),++u;break;default:++u;break}}F&&this.fill_(e),L&&e.stroke()}execute(e,t,n,i,r,o){this.viewRotation_=i,this.execute_(e,t,n,this.instructions,r,void 0,void 0,o)}executeHitDetection(e,t,n,i,r){return this.viewRotation_=n,this.execute_(e,[e.canvas.width,e.canvas.height],t,this.hitDetectionInstructions,!0,i,r)}}const kn=["Polygon","Circle","LineString","Image","Text","Default"],Br=["Image","Text"],up=kn.filter(s=>!Br.includes(s));class Yu{constructor(e,t,n,i,r,o,a){this.maxExtent_=e,this.overlaps_=i,this.pixelRatio_=n,this.resolution_=t,this.renderBuffer_=o,this.executorsByZIndex_={},this.hitDetectionContext_=null,this.hitDetectionTransform_=Te(),this.renderedContext_=null,this.deferredZIndexContexts_={},this.createExecutors_(r,a)}clip(e,t){const n=this.getClipCoords(t);e.beginPath(),e.moveTo(n[0],n[1]),e.lineTo(n[2],n[3]),e.lineTo(n[4],n[5]),e.lineTo(n[6],n[7]),e.clip()}createExecutors_(e,t){for(const n in e){let i=this.executorsByZIndex_[n];i===void 0&&(i={},this.executorsByZIndex_[n]=i);const r=e[n];for(const o in r){const a=r[o];i[o]=new cp(this.resolution_,this.pixelRatio_,this.overlaps_,a,t)}}}hasExecutors(e){for(const t in this.executorsByZIndex_){const n=this.executorsByZIndex_[t];for(let i=0,r=e.length;i<r;++i)if(e[i]in n)return!0}return!1}forEachFeatureAtCoordinate(e,t,n,i,r,o){i=Math.round(i);const a=i*2+1,l=lt(this.hitDetectionTransform_,i+.5,i+.5,1/t,-1/t,-n,-e[0],-e[1]),h=!this.hitDetectionContext_;h&&(this.hitDetectionContext_=ve(a,a));const c=this.hitDetectionContext_;c.canvas.width!==a||c.canvas.height!==a?(c.canvas.width=a,c.canvas.height=a):h||c.clearRect(0,0,a,a);let u;this.renderBuffer_!==void 0&&(u=Je(),fs(u,e),sn(u,t*(this.renderBuffer_+i),u));const d=dp(i);let f;function g(T,R,S){const v=c.getImageData(0,0,a,a).data;for(let w=0,I=d.length;w<I;w++)if(v[d[w]]>0){if(!o||S==="none"||f!=="Image"&&f!=="Text"||o.includes(T)){const F=(d[w]-3)/4,L=i-F%a,b=i-(F/a|0),M=r(T,R,L*L+b*b);if(M)return M}c.clearRect(0,0,a,a);break}}const m=Object.keys(this.executorsByZIndex_).map(Number);m.sort(Ot);let _,p,y,E,x;for(_=m.length-1;_>=0;--_){const T=m[_].toString();for(y=this.executorsByZIndex_[T],p=kn.length-1;p>=0;--p)if(f=kn[p],E=y[f],E!==void 0&&(x=E.executeHitDetection(c,l,n,g,u),x))return x}}getClipCoords(e){const t=this.maxExtent_;if(!t)return null;const n=t[0],i=t[1],r=t[2],o=t[3],a=[n,i,n,o,r,o,r,i];return Nt(a,0,8,2,e,a),a}isEmpty(){return jn(this.executorsByZIndex_)}execute(e,t,n,i,r,o,a){const l=Object.keys(this.executorsByZIndex_).map(Number);l.sort(a?af:Ot),o=o||kn;const h=kn.length;for(let c=0,u=l.length;c<u;++c){const d=l[c].toString(),f=this.executorsByZIndex_[d];for(let g=0,m=o.length;g<m;++g){const _=o[g],p=f[_];if(p!==void 0){const y=a===null?void 0:p.getZIndexContext(),E=y?y.getContext():e,x=this.maxExtent_&&_!=="Image"&&_!=="Text";if(x&&(E.save(),this.clip(E,n)),!y||_==="Text"||_==="Image"?p.execute(E,t,n,i,r,a):y.pushFunction(T=>p.execute(T,t,n,i,r,a)),x&&E.restore(),y){y.offset();const T=l[c]*h+kn.indexOf(_);this.deferredZIndexContexts_[T]||(this.deferredZIndexContexts_[T]=[]),this.deferredZIndexContexts_[T].push(y)}}}}this.renderedContext_=e}getDeferredZIndexContexts(){return this.deferredZIndexContexts_}getRenderedContext(){return this.renderedContext_}renderDeferred(){const e=this.deferredZIndexContexts_,t=Object.keys(e).map(Number).sort(Ot);for(let n=0,i=t.length;n<i;++n)e[t[n]].forEach(r=>{r.draw(this.renderedContext_),r.clear()}),e[t[n]].length=0}}const Ko={};function dp(s){if(Ko[s]!==void 0)return Ko[s];const e=s*2+1,t=s*s,n=new Array(t+1);for(let r=0;r<=s;++r)for(let o=0;o<=s;++o){const a=r*r+o*o;if(a>t)break;let l=n[a];l||(l=[],n[a]=l),l.push(((s+r)*e+(s+o))*4+3),r>0&&l.push(((s-r)*e+(s+o))*4+3),o>0&&(l.push(((s+r)*e+(s-o))*4+3),r>0&&l.push(((s-r)*e+(s-o))*4+3))}const i=[];for(let r=0,o=n.length;r<o;++r)n[r]&&i.push(...n[r]);return Ko[s]=i,i}class fp extends Xu{constructor(e,t,n,i,r,o,a){super(),this.context_=e,this.pixelRatio_=t,this.extent_=n,this.transform_=i,this.transformRotation_=i?Xi(Math.atan2(i[1],i[0]),10):0,this.viewRotation_=r,this.squaredTolerance_=o,this.userTransform_=a,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_=Te()}drawImages_(e,t,n,i){if(!this.image_)return;const r=Nt(e,t,n,i,this.transform_,this.pixelCoordinates_),o=this.context_,a=this.tmpLocalTransform_,l=o.globalAlpha;this.imageOpacity_!=1&&(o.globalAlpha=l*this.imageOpacity_);let h=this.imageRotation_;this.transformRotation_===0&&(h-=this.viewRotation_),this.imageRotateWithView_&&(h+=this.viewRotation_);for(let c=0,u=r.length;c<u;c+=2){const d=r[c]-this.imageAnchorX_,f=r[c+1]-this.imageAnchorY_;if(h!==0||this.imageScale_[0]!=1||this.imageScale_[1]!=1){const g=d+this.imageAnchorX_,m=f+this.imageAnchorY_;lt(a,g,m,1,1,h,-g,-m),o.save(),o.transform.apply(o,a),o.translate(g,m),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.restore()}else o.drawImage(this.image_,this.imageOriginX_,this.imageOriginY_,this.imageWidth_,this.imageHeight_,d,f,this.imageWidth_,this.imageHeight_)}this.imageOpacity_!=1&&(o.globalAlpha=l)}drawText_(e,t,n,i){if(!this.textState_||this.text_==="")return;this.textFillState_&&this.setContextFillState_(this.textFillState_),this.textStrokeState_&&this.setContextStrokeState_(this.textStrokeState_),this.setContextTextState_(this.textState_);const r=Nt(e,t,n,i,this.transform_,this.pixelCoordinates_),o=this.context_;let a=this.textRotation_;for(this.transformRotation_===0&&(a-=this.viewRotation_),this.textRotateWithView_&&(a+=this.viewRotation_);t<n;t+=i){const l=r[t]+this.textOffsetX_,h=r[t+1]+this.textOffsetY_;a!==0||this.textScale_[0]!=1||this.textScale_[1]!=1?(o.save(),o.translate(l-this.textOffsetX_,h-this.textOffsetY_),o.rotate(a),o.translate(this.textOffsetX_,this.textOffsetY_),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.restore()):(this.textStrokeState_&&o.strokeText(this.text_,l,h),this.textFillState_&&o.fillText(this.text_,l,h))}}moveToLineTo_(e,t,n,i,r){const o=this.context_,a=Nt(e,t,n,i,this.transform_,this.pixelCoordinates_);o.moveTo(a[0],a[1]);let l=a.length;r&&(l-=2);for(let h=2;h<l;h+=2)o.lineTo(a[h],a[h+1]);return r&&o.closePath(),n}drawRings_(e,t,n,i){for(let r=0,o=n.length;r<o;++r)t=this.moveToLineTo_(e,t,n[r],i,!0);return t}drawCircle(e){if(this.squaredTolerance_&&(e=e.simplifyTransformed(this.squaredTolerance_,this.userTransform_)),!!Ee(this.extent_,e.getExtent())){if(this.fillState_||this.strokeState_){this.fillState_&&this.setContextFillState_(this.fillState_),this.strokeState_&&this.setContextStrokeState_(this.strokeState_);const t=Rg(e,this.transform_,this.pixelCoordinates_),n=t[2]-t[0],i=t[3]-t[1],r=Math.sqrt(n*n+i*i),o=this.context_;o.beginPath(),o.arc(t[0],t[1],r,0,2*Math.PI),this.fillState_&&o.fill(),this.strokeState_&&o.stroke()}this.text_!==""&&this.drawText_(e.getCenter(),0,2,2)}}setStyle(e){this.setFillStrokeStyle(e.getFill(),e.getStroke()),this.setImageStyle(e.getImage()),this.setTextStyle(e.getText())}setTransform(e){this.transform_=e}drawGeometry(e){switch(e.getType()){case"Point":this.drawPoint(e);break;case"LineString":this.drawLineString(e);break;case"Polygon":this.drawPolygon(e);break;case"MultiPoint":this.drawMultiPoint(e);break;case"MultiLineString":this.drawMultiLineString(e);break;case"MultiPolygon":this.drawMultiPolygon(e);break;case"GeometryCollection":this.drawGeometryCollection(e);break;case"Circle":this.drawCircle(e);break}}drawFeature(e,t){const n=t.getGeometryFunction()(e);n&&(this.setStyle(t),this.drawGeometry(n))}drawGeometryCollection(e){const t=e.getGeometriesArray();for(let n=0,i=t.length;n<i;++n)this.drawGeometry(t[n])}drawPoint(e){this.squaredTolerance_&&(e=e.simplifyTransformed(this.squaredTolerance_,this.userTransform_));const t=e.getFlatCoordinates(),n=e.getStride();this.image_&&this.drawImages_(t,0,t.length,n),this.text_!==""&&this.drawText_(t,0,t.length,n)}drawMultiPoint(e){this.squaredTolerance_&&(e=e.simplifyTransformed(this.squaredTolerance_,this.userTransform_));const t=e.getFlatCoordinates(),n=e.getStride();this.image_&&this.drawImages_(t,0,t.length,n),this.text_!==""&&this.drawText_(t,0,t.length,n)}drawLineString(e){if(this.squaredTolerance_&&(e=e.simplifyTransformed(this.squaredTolerance_,this.userTransform_)),!!Ee(this.extent_,e.getExtent())){if(this.strokeState_){this.setContextStrokeState_(this.strokeState_);const t=this.context_,n=e.getFlatCoordinates();t.beginPath(),this.moveToLineTo_(n,0,n.length,e.getStride(),!1),t.stroke()}if(this.text_!==""){const t=e.getFlatMidpoint();this.drawText_(t,0,2,2)}}}drawMultiLineString(e){this.squaredTolerance_&&(e=e.simplifyTransformed(this.squaredTolerance_,this.userTransform_));const t=e.getExtent();if(Ee(this.extent_,t)){if(this.strokeState_){this.setContextStrokeState_(this.strokeState_);const n=this.context_,i=e.getFlatCoordinates();let r=0;const o=e.getEnds(),a=e.getStride();n.beginPath();for(let l=0,h=o.length;l<h;++l)r=this.moveToLineTo_(i,r,o[l],a,!1);n.stroke()}if(this.text_!==""){const n=e.getFlatMidpoints();this.drawText_(n,0,n.length,2)}}}drawPolygon(e){if(this.squaredTolerance_&&(e=e.simplifyTransformed(this.squaredTolerance_,this.userTransform_)),!!Ee(this.extent_,e.getExtent())){if(this.strokeState_||this.fillState_){this.fillState_&&this.setContextFillState_(this.fillState_),this.strokeState_&&this.setContextStrokeState_(this.strokeState_);const t=this.context_;t.beginPath(),this.drawRings_(e.getOrientedFlatCoordinates(),0,e.getEnds(),e.getStride()),this.fillState_&&t.fill(),this.strokeState_&&t.stroke()}if(this.text_!==""){const t=e.getFlatInteriorPoint();this.drawText_(t,0,2,2)}}}drawMultiPolygon(e){if(this.squaredTolerance_&&(e=e.simplifyTransformed(this.squaredTolerance_,this.userTransform_)),!!Ee(this.extent_,e.getExtent())){if(this.strokeState_||this.fillState_){this.fillState_&&this.setContextFillState_(this.fillState_),this.strokeState_&&this.setContextStrokeState_(this.strokeState_);const t=this.context_,n=e.getOrientedFlatCoordinates();let i=0;const r=e.getEndss(),o=e.getStride();t.beginPath();for(let a=0,l=r.length;a<l;++a){const h=r[a];i=this.drawRings_(n,i,h,o)}this.fillState_&&t.fill(),this.strokeState_&&t.stroke()}if(this.text_!==""){const t=e.getFlatInteriorPoints();this.drawText_(t,0,t.length,2)}}}setContextFillState_(e){const t=this.context_,n=this.contextFillState_;n?n.fillStyle!=e.fillStyle&&(n.fillStyle=e.fillStyle,t.fillStyle=e.fillStyle):(t.fillStyle=e.fillStyle,this.contextFillState_={fillStyle:e.fillStyle})}setContextStrokeState_(e){const t=this.context_,n=this.contextStrokeState_;n?(n.lineCap!=e.lineCap&&(n.lineCap=e.lineCap,t.lineCap=e.lineCap),Ut(n.lineDash,e.lineDash)||t.setLineDash(n.lineDash=e.lineDash),n.lineDashOffset!=e.lineDashOffset&&(n.lineDashOffset=e.lineDashOffset,t.lineDashOffset=e.lineDashOffset),n.lineJoin!=e.lineJoin&&(n.lineJoin=e.lineJoin,t.lineJoin=e.lineJoin),n.lineWidth!=e.lineWidth&&(n.lineWidth=e.lineWidth,t.lineWidth=e.lineWidth),n.miterLimit!=e.miterLimit&&(n.miterLimit=e.miterLimit,t.miterLimit=e.miterLimit),n.strokeStyle!=e.strokeStyle&&(n.strokeStyle=e.strokeStyle,t.strokeStyle=e.strokeStyle)):(t.lineCap=e.lineCap,t.setLineDash(e.lineDash),t.lineDashOffset=e.lineDashOffset,t.lineJoin=e.lineJoin,t.lineWidth=e.lineWidth,t.miterLimit=e.miterLimit,t.strokeStyle=e.strokeStyle,this.contextStrokeState_={lineCap:e.lineCap,lineDash:e.lineDash,lineDashOffset:e.lineDashOffset,lineJoin:e.lineJoin,lineWidth:e.lineWidth,miterLimit:e.miterLimit,strokeStyle:e.strokeStyle})}setContextTextState_(e){const t=this.context_,n=this.contextTextState_,i=e.textAlign?e.textAlign:Ps;n?(n.font!=e.font&&(n.font=e.font,t.font=e.font),n.textAlign!=i&&(n.textAlign=i,t.textAlign=i),n.textBaseline!=e.textBaseline&&(n.textBaseline=e.textBaseline,t.textBaseline=e.textBaseline)):(t.font=e.font,t.textAlign=i,t.textBaseline=e.textBaseline,this.contextTextState_={font:e.font,textAlign:i,textBaseline:e.textBaseline})}setFillStrokeStyle(e,t){if(!e)this.fillState_=null;else{const n=e.getColor();this.fillState_={fillStyle:Dt(n||Ke)}}if(!t)this.strokeState_=null;else{const n=t.getColor(),i=t.getLineCap(),r=t.getLineDash(),o=t.getLineDashOffset(),a=t.getLineJoin(),l=t.getWidth(),h=t.getMiterLimit(),c=r||tn;this.strokeState_={lineCap:i!==void 0?i:Ui,lineDash:this.pixelRatio_===1?c:c.map(u=>u*this.pixelRatio_),lineDashOffset:(o||nn)*this.pixelRatio_,lineJoin:a!==void 0?a:Bi,lineWidth:(l!==void 0?l:Is)*this.pixelRatio_,miterLimit:h!==void 0?h:vs,strokeStyle:Dt(n||ws)}}}setImageStyle(e){let t;if(!e||!(t=e.getSize())){this.image_=null;return}const n=e.getPixelRatio(this.pixelRatio_),i=e.getAnchor(),r=e.getOrigin();this.image_=e.getImage(this.pixelRatio_),this.imageAnchorX_=i[0]*n,this.imageAnchorY_=i[1]*n,this.imageHeight_=t[1]*n,this.imageOpacity_=e.getOpacity(),this.imageOriginX_=r[0],this.imageOriginY_=r[1],this.imageRotateWithView_=e.getRotateWithView(),this.imageRotation_=e.getRotation();const o=e.getScaleArray();this.imageScale_=[o[0]*this.pixelRatio_/n,o[1]*this.pixelRatio_/n],this.imageWidth_=t[0]*n}setTextStyle(e){if(!e)this.text_="";else{const t=e.getFill();if(!t)this.textFillState_=null;else{const f=t.getColor();this.textFillState_={fillStyle:Dt(f||Ke)}}const n=e.getStroke();if(!n)this.textStrokeState_=null;else{const f=n.getColor(),g=n.getLineCap(),m=n.getLineDash(),_=n.getLineDashOffset(),p=n.getLineJoin(),y=n.getWidth(),E=n.getMiterLimit();this.textStrokeState_={lineCap:g!==void 0?g:Ui,lineDash:m||tn,lineDashOffset:_||nn,lineJoin:p!==void 0?p:Bi,lineWidth:y!==void 0?y:Is,miterLimit:E!==void 0?E:vs,strokeStyle:Dt(f||ws)}}const i=e.getFont(),r=e.getOffsetX(),o=e.getOffsetY(),a=e.getRotateWithView(),l=e.getRotation(),h=e.getScaleArray(),c=e.getText(),u=e.getTextAlign(),d=e.getTextBaseline();this.textState_={font:i!==void 0?i:Pu,textAlign:u!==void 0?u:Ps,textBaseline:d!==void 0?d:Or},this.text_=c!==void 0?Array.isArray(c)?c.reduce((f,g,m)=>f+=m%2?" ":g,""):c:"",this.textOffsetX_=r!==void 0?this.pixelRatio_*r:0,this.textOffsetY_=o!==void 0?this.pixelRatio_*o:0,this.textRotateWithView_=a!==void 0?a:!1,this.textRotation_=l!==void 0?l:0,this.textScale_=[this.pixelRatio_*h[0],this.pixelRatio_*h[1]]}}}const st=.5;function ju(s,e,t,n,i,r,o,a,l){const h=l?to(i):i,c=s[0]*st,u=s[1]*st,d=ve(c,u);d.imageSmoothingEnabled=!1;const f=d.canvas,g=new fp(d,st,i,null,o,a,l?eo(gg(),l):null),m=t.length,_=Math.floor((256*256*256-1)/m),p={};for(let E=1;E<=m;++E){const x=t[E-1],T=x.getStyleFunction()||n;if(!T)continue;let R=T(x,r);if(!R)continue;Array.isArray(R)||(R=[R]);const v=(E*_).toString(16).padStart(7,"#00000");for(let w=0,I=R.length;w<I;++w){const F=R[w],L=F.getGeometryFunction()(x);if(!L||!Ee(h,L.getExtent()))continue;const b=F.clone(),M=b.getFill();M&&M.setColor(v);const K=b.getStroke();K&&(K.setColor(v),K.setLineDash(null)),b.setText(void 0);const A=F.getImage();if(A){const Q=A.getImageSize();if(!Q)continue;const le=ve(Q[0],Q[1],void 0,{alpha:!1}),P=le.canvas;le.fillStyle=v,le.fillRect(0,0,P.width,P.height),b.setImage(new Zi({img:P,anchor:A.getAnchor(),anchorXUnits:"pixels",anchorYUnits:"pixels",offset:A.getOrigin(),opacity:1,size:A.getSize(),scale:A.getScale(),rotation:A.getRotation(),rotateWithView:A.getRotateWithView()}))}const Z=b.getZIndex()||0;let G=p[Z];G||(G={},p[Z]=G,G.Polygon=[],G.Circle=[],G.LineString=[],G.Point=[]);const H=L.getType();if(H==="GeometryCollection"){const Q=L.getGeometriesArrayRecursive();for(let le=0,P=Q.length;le<P;++le){const Ne=Q[le];G[Ne.getType().replace("Multi","")].push(Ne,b)}}else G[H.replace("Multi","")].push(L,b)}}const y=Object.keys(p).map(Number).sort(Ot);for(let E=0,x=y.length;E<x;++E){const T=p[y[E]];for(const R in T){const S=T[R];for(let v=0,w=S.length;v<w;v+=2){g.setStyle(S[v+1]);for(let I=0,F=e.length;I<F;++I)g.setTransform(e[I]),g.drawGeometry(S[v])}}}return d.getImageData(0,0,f.width,f.height)}function Vu(s,e,t){const n=[];if(t){const i=Math.floor(Math.round(s[0])*st),r=Math.floor(Math.round(s[1])*st),o=(fe(i,0,t.width-1)+fe(r,0,t.height-1)*t.width)*4,a=t.data[o],l=t.data[o+1],c=t.data[o+2]+256*(l+256*a),u=Math.floor((256*256*256-1)/e.length);c&&c%u===0&&n.push(e[c/u-1])}return n}const gp=.5,Zu={Point:Cp,LineString:xp,Polygon:Sp,MultiPoint:Rp,MultiLineString:Ep,MultiPolygon:Tp,GeometryCollection:yp,Circle:mp};function _p(s,e){return parseInt(D(s),10)-parseInt(D(e),10)}function Oa(s,e){const t=Ku(s,e);return t*t}function Ku(s,e){return gp*s/e}function mp(s,e,t,n,i){const r=t.getFill(),o=t.getStroke();if(r||o){const l=s.getBuilder(t.getZIndex(),"Circle");l.setFillStrokeStyle(r,o),l.drawCircle(e,n,i)}const a=t.getText();if(a&&a.getText()){const l=s.getBuilder(t.getZIndex(),"Text");l.setTextStyle(a),l.drawText(e,n)}}function zr(s,e,t,n,i,r,o,a){const l=[],h=t.getImage();if(h){let d=!0;const f=h.getImageState();f==U.LOADED||f==U.ERROR?d=!1:f==U.IDLE&&h.load(),d&&l.push(h.ready())}const c=t.getFill();c&&c.loading()&&l.push(c.ready());const u=l.length>0;return u&&Promise.all(l).then(()=>i(null)),pp(s,e,t,n,r,o,a),u}function pp(s,e,t,n,i,r,o){const a=t.getGeometryFunction()(e);if(!a)return;const l=a.simplifyTransformed(n,i);if(t.getRenderer())Hu(s,l,t,e,o);else{const c=Zu[l.getType()];c(s,l,t,e,o,r)}}function Hu(s,e,t,n,i){if(e.getType()=="GeometryCollection"){const o=e.getGeometries();for(let a=0,l=o.length;a<l;++a)Hu(s,o[a],t,n,i);return}s.getBuilder(t.getZIndex(),"Default").drawCustom(e,n,t.getRenderer(),t.getHitDetectionRenderer(),i)}function yp(s,e,t,n,i,r){const o=e.getGeometriesArray();let a,l;for(a=0,l=o.length;a<l;++a){const h=Zu[o[a].getType()];h(s,o[a],t,n,i,r)}}function xp(s,e,t,n,i){const r=t.getStroke();if(r){const a=s.getBuilder(t.getZIndex(),"LineString");a.setFillStrokeStyle(null,r),a.drawLineString(e,n,i)}const o=t.getText();if(o&&o.getText()){const a=s.getBuilder(t.getZIndex(),"Text");a.setTextStyle(o),a.drawText(e,n,i)}}function Ep(s,e,t,n,i){const r=t.getStroke();if(r){const a=s.getBuilder(t.getZIndex(),"LineString");a.setFillStrokeStyle(null,r),a.drawMultiLineString(e,n,i)}const o=t.getText();if(o&&o.getText()){const a=s.getBuilder(t.getZIndex(),"Text");a.setTextStyle(o),a.drawText(e,n,i)}}function Tp(s,e,t,n,i){const r=t.getFill(),o=t.getStroke();if(o||r){const l=s.getBuilder(t.getZIndex(),"Polygon");l.setFillStrokeStyle(r,o),l.drawMultiPolygon(e,n,i)}const a=t.getText();if(a&&a.getText()){const l=s.getBuilder(t.getZIndex(),"Text");l.setTextStyle(a),l.drawText(e,n,i)}}function Cp(s,e,t,n,i,r){const o=t.getImage(),a=t.getText(),l=a&&a.getText(),h=r&&o&&l?{}:void 0;if(o){if(o.getImageState()!=U.LOADED)return;const c=s.getBuilder(t.getZIndex(),"Image");c.setImageStyle(o,h),c.drawPoint(e,n,i)}if(l){const c=s.getBuilder(t.getZIndex(),"Text");c.setTextStyle(a,h),c.drawText(e,n,i)}}function Rp(s,e,t,n,i,r){const o=t.getImage(),a=o&&o.getOpacity()!==0,l=t.getText(),h=l&&l.getText(),c=r&&a&&h?{}:void 0;if(a){if(o.getImageState()!=U.LOADED)return;const u=s.getBuilder(t.getZIndex(),"Image");u.setImageStyle(o,c),u.drawMultiPoint(e,n,i)}if(h){const u=s.getBuilder(t.getZIndex(),"Text");u.setTextStyle(l,c),u.drawText(e,n,i)}}function Sp(s,e,t,n,i){const r=t.getFill(),o=t.getStroke();if(r||o){const l=s.getBuilder(t.getZIndex(),"Polygon");l.setFillStrokeStyle(r,o),l.drawPolygon(e,n,i)}const a=t.getText();if(a&&a.getText()){const l=s.getBuilder(t.getZIndex(),"Text");l.setTextStyle(a),l.drawText(e,n,i)}}class qu extends Ul{constructor(e){super(e),this.boundHandleStyleImageChange_=this.handleStyleImageChange_.bind(this),this.animatingOrInteracting_,this.hitDetectionImageData_=null,this.clipped_=!1,this.renderedFeatures_=null,this.renderedRevision_=-1,this.renderedResolution_=NaN,this.renderedExtent_=Je(),this.wrappedRenderedExtent_=Je(),this.renderedRotation_,this.renderedCenter_=null,this.renderedProjection_=null,this.renderedPixelRatio_=1,this.renderedRenderOrder_=null,this.renderedFrameDeclutter_,this.replayGroup_=null,this.replayGroupChanged=!0,this.clipping=!0,this.targetContext_=null,this.opacity_=1}renderWorlds(e,t,n){const i=t.extent,r=t.viewState,o=r.center,a=r.resolution,l=r.projection,h=r.rotation,c=l.getExtent(),u=this.getLayer().getSource(),d=this.getLayer().getDeclutter(),f=t.pixelRatio,g=t.viewHints,m=!(g[he.ANIMATING]||g[he.INTERACTING]),_=this.context,p=Math.round(ne(i)/a*f),y=Math.round(be(i)/a*f),E=u.getWrapX()&&l.canWrapX(),x=E?ne(c):null,T=E?Math.ceil((i[2]-c[2])/x)+1:1;let R=E?Math.floor((i[0]-c[0])/x):0;do{let S=this.getRenderTransform(o,a,0,f,p,y,R*x);t.declutter&&(S=S.slice(0)),e.execute(_,[_.canvas.width,_.canvas.height],S,h,m,n===void 0?kn:n?Br:up,n?d&&t.declutter[d]:void 0)}while(++R<T)}setDrawContext_(){this.opacity_!==1&&(this.targetContext_=this.context,this.context=ve(this.context.canvas.width,this.context.canvas.height,ic))}resetDrawContext_(){if(this.opacity_!==1&&this.targetContext_){const e=this.targetContext_.globalAlpha;this.targetContext_.globalAlpha=this.opacity_,this.targetContext_.drawImage(this.context.canvas,0,0),this.targetContext_.globalAlpha=e,oo(this.context),ic.push(this.context.canvas),this.context=this.targetContext_,this.targetContext_=null}}renderDeclutter(e){!this.replayGroup_||!this.getLayer().getDeclutter()||this.renderWorlds(this.replayGroup_,e,!0)}renderDeferredInternal(e){this.replayGroup_&&(this.replayGroup_.renderDeferred(),this.clipped_&&this.context.restore(),this.resetDrawContext_())}renderFrame(e,t){const n=e.layerStatesArray[e.layerIndex];this.opacity_=n.opacity;const i=e.viewState;this.prepareContainer(e,t);const r=this.context,o=this.replayGroup_;let a=o&&!o.isEmpty();if(!a&&!(this.getLayer().hasListener(Fe.PRERENDER)||this.getLayer().hasListener(Fe.POSTRENDER)))return this.container;if(this.setDrawContext_(),this.preRender(r,e),i.projection,this.clipped_=!1,a&&n.extent&&this.clipping){const l=St(n.extent);a=Ee(l,e.extent),this.clipped_=a&&!pn(l,e.extent),this.clipped_&&this.clipUnrotated(r,e,l)}return a&&this.renderWorlds(o,e,this.getLayer().getDeclutter()?!1:void 0),!e.declutter&&this.clipped_&&r.restore(),this.postRender(r,e),this.renderedRotation_!==i.rotation&&(this.renderedRotation_=i.rotation,this.hitDetectionImageData_=null),e.declutter||this.resetDrawContext_(),this.container}getFeatures(e){return new Promise(t=>{if(this.frameState&&!this.hitDetectionImageData_&&!this.animatingOrInteracting_){const n=this.frameState.size.slice(),i=this.renderedCenter_,r=this.renderedResolution_,o=this.renderedRotation_,a=this.renderedProjection_,l=this.wrappedRenderedExtent_,h=this.getLayer(),c=[],u=n[0]*st,d=n[1]*st;c.push(this.getRenderTransform(i,r,o,st,u,d,0).slice());const f=h.getSource(),g=a.getExtent();if(f.getWrapX()&&a.canWrapX()&&!pn(g,l)){let m=l[0];const _=ne(g);let p=0,y;for(;m<g[0];)--p,y=_*p,c.push(this.getRenderTransform(i,r,o,st,u,d,y).slice()),m+=_;for(p=0,m=l[2];m>g[2];)++p,y=_*p,c.push(this.getRenderTransform(i,r,o,st,u,d,y).slice()),m-=_}this.hitDetectionImageData_=ju(n,c,this.renderedFeatures_,h.getStyleFunction(),l,r,o,Oa(r,this.renderedPixelRatio_),null)}t(Vu(e,this.renderedFeatures_,this.hitDetectionImageData_))})}forEachFeatureAtCoordinate(e,t,n,i,r){if(!this.replayGroup_)return;const o=t.viewState.resolution,a=t.viewState.rotation,l=this.getLayer(),h={},c=function(d,f,g){const m=D(d),_=h[m];if(_){if(_!==!0&&g<_.distanceSq){if(g===0)return h[m]=!0,r.splice(r.lastIndexOf(_),1),i(d,l,f);_.geometry=f,_.distanceSq=g}}else{if(g===0)return h[m]=!0,i(d,l,f);r.push(h[m]={feature:d,layer:l,geometry:f,distanceSq:g,callback:i})}},u=this.getLayer().getDeclutter();return this.replayGroup_.forEachFeatureAtCoordinate(e,o,a,n,c,u?t.declutter?.[u]?.all().map(d=>d.value):null)}handleFontsChanged(){const e=this.getLayer();e.getVisible()&&this.replayGroup_&&e.changed()}handleStyleImageChange_(e){this.renderIfReadyAndVisible()}prepareFrame(e){const t=this.getLayer(),n=t.getSource();if(!n)return!1;const i=e.viewHints[he.ANIMATING],r=e.viewHints[he.INTERACTING],o=t.getUpdateWhileAnimating(),a=t.getUpdateWhileInteracting();if(this.ready&&!o&&i||!a&&r)return this.animatingOrInteracting_=!0,!0;this.animatingOrInteracting_=!1;const l=e.extent,h=e.viewState,c=h.projection,u=h.resolution,d=e.pixelRatio,f=t.getRevision(),g=t.getRenderBuffer();let m=t.getRenderOrder();m===void 0&&(m=_p);const _=h.center.slice(),p=sn(l,g*u),y=p.slice(),E=[p.slice()],x=c.getExtent();if(n.getWrapX()&&c.canWrapX()&&!pn(x,e.extent)){const M=ne(x),K=Math.max(ne(p)/2,M);p[0]=x[0]-K,p[2]=x[2]+K,el(_,c);const A=$c(E[0],c);A[0]<x[0]&&A[2]<x[2]?E.push([A[0]+M,A[1],A[2]+M,A[3]]):A[0]>x[0]&&A[2]>x[2]&&E.push([A[0]-M,A[1],A[2]-M,A[3]])}if(this.ready&&this.renderedResolution_==u&&this.renderedRevision_==f&&this.renderedRenderOrder_==m&&this.renderedFrameDeclutter_===!!e.declutter&&pn(this.wrappedRenderedExtent_,p))return Ut(this.renderedExtent_,y)||(this.hitDetectionImageData_=null,this.renderedExtent_=y),this.renderedCenter_=_,this.replayGroupChanged=!1,!0;this.replayGroup_=null;const T=new Wu(Ku(u,d),p,u,d);let R;for(let M=0,K=E.length;M<K;++M)n.loadFeatures(E[M],u,c);const S=Oa(u,d);let v=!0;const w=(M,K)=>{let A;const Z=M.getStyleFunction()||t.getStyleFunction();if(Z&&(A=Z(M,u)),A){const G=this.renderFeature(M,S,A,T,R,this.getLayer().getDeclutter(),K);v=v&&!G}},I=to(p),F=n.getFeaturesInExtent(I);m&&F.sort(m);for(let M=0,K=F.length;M<K;++M)w(F[M],M);this.renderedFeatures_=F,this.ready=v;const L=T.finish(),b=new Yu(p,u,d,n.getOverlaps(),L,t.getRenderBuffer(),!!e.declutter);return this.renderedResolution_=u,this.renderedRevision_=f,this.renderedRenderOrder_=m,this.renderedFrameDeclutter_=!!e.declutter,this.renderedExtent_=y,this.wrappedRenderedExtent_=p,this.renderedCenter_=_,this.renderedProjection_=c,this.renderedPixelRatio_=d,this.replayGroup_=b,this.hitDetectionImageData_=null,this.replayGroupChanged=!0,!0}renderFeature(e,t,n,i,r,o,a){if(!n)return!1;let l=!1;if(Array.isArray(n))for(let h=0,c=n.length;h<c;++h)l=zr(i,e,n[h],t,this.boundHandleStyleImageChange_,r,o,a)||l;else l=zr(i,e,n,t,this.boundHandleStyleImageChange_,r,o,a);return l}}class zl extends Ki{constructor(e){super(e)}createRenderer(){return new qu(this)}}class vp extends sm{constructor(e,t,n,i,r){const o=r!==void 0?U.IDLE:U.LOADED;super(e,t,n,o),this.loader_=r!==void 0?r:null,this.canvas_=i,this.error_=null}getError(){return this.error_}handleLoad_(e){e?(this.error_=e,this.state=U.ERROR):this.state=U.LOADED,this.changed()}load(){this.state==U.IDLE&&(this.state=U.LOADING,this.changed(),this.loader_(this.handleLoad_.bind(this)))}getImage(){return this.canvas_}}function wp(s){return Array.isArray(s)?Math.min(...s):s}class Pp extends $u{constructor(e){super(e),this.vectorRenderer_=new qu(e),this.layerImageRatio_=e.getImageRatio(),this.coordinateToVectorPixelTransform_=Te(),this.renderedPixelToCoordinateTransform_=null}disposeInternal(){this.vectorRenderer_.dispose(),super.disposeInternal()}getFeatures(e){if(!this.vectorRenderer_)return Promise.resolve([]);const t=de(this.coordinateToVectorPixelTransform_,de(this.renderedPixelToCoordinateTransform_,e.slice()));return this.vectorRenderer_.getFeatures(t)}handleFontsChanged(){this.vectorRenderer_.handleFontsChanged()}prepareFrame(e){const t=e.pixelRatio,n=e.viewState,i=n.resolution,r=e.viewHints,o=this.vectorRenderer_;let a=e.extent;this.layerImageRatio_!==1&&(a=a.slice(0),If(a,this.layerImageRatio_));const l=ne(a)/i,h=be(a)/i;if(!r[he.ANIMATING]&&!r[he.INTERACTING]&&!ti(a)){o.useContainer(null,null);const c=o.context,u=e.layerStatesArray[e.layerIndex],d=Object.assign({},u,{opacity:1}),f=Object.assign({},e,{extent:a,size:[l,h],viewState:Object.assign({},e.viewState,{rotation:0}),layerStatesArray:[d],layerIndex:0,declutter:null}),g=this.getLayer().getDeclutter();g&&(f.declutter={[g]:new Pl(9)});const m=new vp(a,i,t,c.canvas,function(_){o.prepareFrame(f)&&o.replayGroupChanged&&(o.clipping=!1,o.renderFrame(f,null),o.renderDeclutter(f),o.renderDeferred(f),_())});m.addEventListener(V.CHANGE,()=>{if(m.getState()!==U.LOADED)return;this.image=m;const _=m.getPixelRatio(),p=wp(m.getResolution())*t/_;this.renderedResolution=p,this.coordinateToVectorPixelTransform_=lt(this.coordinateToVectorPixelTransform_,l/2,h/2,1/p,-1/p,0,-n.center[0],-n.center[1])}),m.load()}return this.image&&(this.renderedPixelToCoordinateTransform_=e.pixelToCoordinateTransform.slice()),!this.getLayer().getSource()?.loading&&!!this.image}preRender(){}postRender(){}renderDeclutter(){}forEachFeatureAtCoordinate(e,t,n,i,r){return this.vectorRenderer_?this.vectorRenderer_.forEachFeatureAtCoordinate(e,t,n,i,r):super.forEachFeatureAtCoordinate(e,t,n,i,r)}}class F0 extends Ki{constructor(e){e=e||{};const t=Object.assign({},e);delete t.imageRatio,super(t),this.imageRatio_=e.imageRatio!==void 0?e.imageRatio:1}getImageRatio(){return this.imageRatio_}createRenderer(){return new Pp(this)}}let Ip=!1;function Lp(s,e,t,n,i,r,o){const a=new XMLHttpRequest;a.open("GET",typeof s=="function"?s(t,n,i):s,!0),e.getType()=="arraybuffer"&&(a.responseType="arraybuffer"),a.withCredentials=Ip,a.onload=function(l){if(!a.status||a.status>=200&&a.status<300){const h=e.getType();try{let c;h=="text"||h=="json"?c=a.responseText:h=="xml"?c=a.responseXML||a.responseText:h=="arraybuffer"&&(c=a.response),c?r(e.readFeatures(c,{extent:t,featureProjection:i}),e.readProjection(c)):o()}catch{o()}}else o()},a.onerror=o,a.send()}function hc(s,e){return function(t,n,i,r,o){Lp(s,e,t,n,i,(a,l)=>{this.addFeatures(a),r!==void 0&&r(a)},()=>{this.changed(),o!==void 0&&o()})}}function Ap(s,e){return[[-1/0,-1/0,1/0,1/0]]}class ze extends It{constructor(e){if(super(),this.on,this.once,this.un,this.id_=void 0,this.geometryName_="geometry",this.style_=null,this.styleFunction_=void 0,this.geometryChangeKey_=null,this.addChangeListener(this.geometryName_,this.handleGeometryChanged_),e)if(typeof e.getSimplifiedGeometry=="function"){const t=e;this.setGeometry(t)}else{const t=e;this.setProperties(t)}}clone(){const e=new ze(this.hasProperties()?this.getProperties():null);e.setGeometryName(this.getGeometryName());const t=this.getGeometry();t&&e.setGeometry(t.clone());const n=this.getStyle();return n&&e.setStyle(n),e}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_&&(ue(this.geometryChangeKey_),this.geometryChangeKey_=null);const e=this.getGeometry();e&&(this.geometryChangeKey_=J(e,V.CHANGE,this.handleGeometryChange_,this)),this.changed()}setGeometry(e){this.set(this.geometryName_,e)}setStyle(e){this.style_=e,this.styleFunction_=e?Fp(e):void 0,this.changed()}setId(e){this.id_=e,this.changed()}setGeometryName(e){this.removeChangeListener(this.geometryName_,this.handleGeometryChanged_),this.geometryName_=e,this.addChangeListener(this.geometryName_,this.handleGeometryChanged_),this.handleGeometryChanged_()}}function Fp(s){if(typeof s=="function")return s;let e;return Array.isArray(s)?e=s:(te(typeof s.getZIndex=="function","Expected an `ol/style/Style` or an array of `ol/style/Style.js`"),e=[s]),function(){return e}}function Ju(s,e,t,n){const i=[];let r=Je();for(let o=0,a=t.length;o<a;++o){const l=t[o];r=Ha(s,e,l[0],n),i.push((r[0]+r[2])/2,(r[1]+r[3])/2),e=l[l.length-1]}return i}function $r(s,e,t,n,i,r,o){let a,l;const h=(t-e)/n;if(h===1)a=e;else if(h===2)a=e,l=i;else if(h!==0){let c=s[e],u=s[e+1],d=0;const f=[0];for(let _=e+n;_<t;_+=n){const p=s[_],y=s[_+1];d+=Math.sqrt((p-c)*(p-c)+(y-u)*(y-u)),f.push(d),c=p,u=y}const g=i*d,m=of(f,g);m<0?(l=(g-f[-m-2])/(f[-m-1]-f[-m-2]),a=e+(-m-2)*n):a=e+m*n}o=o>1?o:2,r=r||new Array(o);for(let c=0;c<o;++c)r[c]=a===void 0?NaN:l===void 0?s[a+c]:it(s[a+c],s[a+n+c],l);return r}function Na(s,e,t,n,i,r){if(t==e)return null;let o;if(i<s[e+n-1])return r?(o=s.slice(e,e+n),o[n-1]=i,o):null;if(s[t-1]<i)return r?(o=s.slice(t-n,t),o[n-1]=i,o):null;if(i==s[e+n-1])return s.slice(e,e+n);let a=e/n,l=t/n;for(;a<l;){const d=a+l>>1;i<s[(d+1)*n-1]?l=d:a=d+1}const h=s[a*n-1];if(i==h)return s.slice((a-1)*n,(a-1)*n+n);const c=s[(a+1)*n-1],u=(i-h)/(c-h);o=[];for(let d=0;d<n-1;++d)o.push(it(s[(a-1)*n+d],s[a*n+d],u));return o.push(i),o}function bp(s,e,t,n,i,r,o){if(o)return Na(s,e,t[t.length-1],n,i,r);let a;if(i<s[n-1])return r?(a=s.slice(0,n),a[n-1]=i,a):null;if(s[s.length-1]<i)return r?(a=s.slice(s.length-n),a[n-1]=i,a):null;for(let l=0,h=t.length;l<h;++l){const c=t[l];if(e!=c){if(i<s[e+n-1])return null;if(i<=s[c-1])return Na(s,e,c,n,i,!1);e=c}}return null}class fo extends Fn{constructor(e,t,n){super(),n!==void 0&&t===void 0?this.setFlatCoordinates(n,e):(t=t||0,this.setCenterAndRadius(e,t,n))}clone(){const e=new fo(this.flatCoordinates.slice(),void 0,this.layout);return e.applyProperties(this),e}closestPointXY(e,t,n,i){const r=this.flatCoordinates,o=e-r[0],a=t-r[1],l=o*o+a*a;if(l<i){if(l===0)for(let h=0;h<this.stride;++h)n[h]=r[h];else{const h=this.getRadius()/Math.sqrt(l);n[0]=r[0]+h*o,n[1]=r[1]+h*a;for(let c=2;c<this.stride;++c)n[c]=r[c]}return n.length=this.stride,l}return i}containsXY(e,t){const n=this.flatCoordinates,i=e-n[0],r=t-n[1];return i*i+r*r<=this.getRadiusSquared_()}getCenter(){return this.flatCoordinates.slice(0,this.stride)}computeExtent(e){const t=this.flatCoordinates,n=t[this.stride]-t[0];return kt(t[0]-n,t[1]-n,t[0]+n,t[1]+n,e)}getRadius(){return Math.sqrt(this.getRadiusSquared_())}getRadiusSquared_(){const e=this.flatCoordinates[this.stride]-this.flatCoordinates[0],t=this.flatCoordinates[this.stride+1]-this.flatCoordinates[1];return e*e+t*t}getType(){return"Circle"}intersectsExtent(e){const t=this.getExtent();if(Ee(e,t)){const n=this.getCenter();return e[0]<=n[0]&&e[2]>=n[0]||e[1]<=n[1]&&e[3]>=n[1]?!0:qa(e,this.intersectsCoordinate.bind(this))}return!1}setCenter(e){const t=this.stride,n=this.flatCoordinates[t]-this.flatCoordinates[0],i=e.slice();i[t]=i[0]+n;for(let r=1;r<t;++r)i[t+r]=e[r];this.setFlatCoordinates(this.layout,i),this.changed()}setCenterAndRadius(e,t,n){this.setLayout(n,e,0),this.flatCoordinates||(this.flatCoordinates=[]);const i=this.flatCoordinates;let r=ru(i,0,e,this.stride);i[r++]=i[0]+t;for(let o=1,a=this.stride;o<a;++o)i[r++]=i[o];i.length=r,this.changed()}getCoordinates(){return null}setCoordinates(e,t){}setRadius(e){this.flatCoordinates[this.stride]=this.flatCoordinates[0]+e,this.changed()}rotate(e,t){const n=this.getCenter(),i=this.getStride();this.setCenter(ll(n,0,n.length,i,e,t,n)),this.changed()}}fo.prototype.transform;class Ze extends nu{constructor(e){super(),this.geometries_=e,this.changeEventsKeys_=[],this.listenGeometriesChange_()}unlistenGeometriesChange_(){this.changeEventsKeys_.forEach(ue),this.changeEventsKeys_.length=0}listenGeometriesChange_(){const e=this.geometries_;for(let t=0,n=e.length;t<n;++t)this.changeEventsKeys_.push(J(e[t],V.CHANGE,this.changed,this))}clone(){const e=new Ze(Ho(this.geometries_));return e.applyProperties(this),e}closestPointXY(e,t,n,i){if(i<ei(this.getExtent(),e,t))return i;const r=this.geometries_;for(let o=0,a=r.length;o<a;++o)i=r[o].closestPointXY(e,t,n,i);return i}containsXY(e,t){const n=this.geometries_;for(let i=0,r=n.length;i<r;++i)if(n[i].containsXY(e,t))return!0;return!1}computeExtent(e){Wi(e);const t=this.geometries_;for(let n=0,i=t.length;n<i;++n)Uc(e,t[n].getExtent());return e}getGeometries(){return Ho(this.geometries_)}getGeometriesArray(){return this.geometries_}getGeometriesArrayRecursive(){let e=[];const t=this.geometries_;for(let n=0,i=t.length;n<i;++n)t[n].getType()===this.getType()?e=e.concat(t[n].getGeometriesArrayRecursive()):e.push(t[n]);return e}getSimplifiedGeometry(e){if(this.simplifiedGeometryRevision!==this.getRevision()&&(this.simplifiedGeometryMaxMinSquaredTolerance=0,this.simplifiedGeometryRevision=this.getRevision()),e<0||this.simplifiedGeometryMaxMinSquaredTolerance!==0&&e<this.simplifiedGeometryMaxMinSquaredTolerance)return this;const t=[],n=this.geometries_;let i=!1;for(let r=0,o=n.length;r<o;++r){const a=n[r],l=a.getSimplifiedGeometry(e);t.push(l),l!==a&&(i=!0)}return i?new Ze(t):(this.simplifiedGeometryMaxMinSquaredTolerance=e,this)}getType(){return"GeometryCollection"}intersectsExtent(e){const t=this.geometries_;for(let n=0,i=t.length;n<i;++n)if(t[n].intersectsExtent(e))return!0;return!1}isEmpty(){return this.geometries_.length===0}rotate(e,t){const n=this.geometries_;for(let i=0,r=n.length;i<r;++i)n[i].rotate(e,t);this.changed()}scale(e,t,n){n||(n=Pn(this.getExtent()));const i=this.geometries_;for(let r=0,o=i.length;r<o;++r)i[r].scale(e,t,n);this.changed()}setGeometries(e){this.setGeometriesArray(Ho(e))}setGeometriesArray(e){this.unlistenGeometriesChange_(),this.geometries_=e,this.listenGeometriesChange_(),this.changed()}applyTransform(e){const t=this.geometries_;for(let n=0,i=t.length;n<i;++n)t[n].applyTransform(e);this.changed()}translate(e,t){const n=this.geometries_;for(let i=0,r=n.length;i<r;++i)n[i].translate(e,t);this.changed()}disposeInternal(){this.unlistenGeometriesChange_(),super.disposeInternal()}}function Ho(s){return s.map(e=>e.clone())}class at extends Fn{constructor(e,t){super(),this.flatMidpoint_=null,this.flatMidpointRevision_=-1,this.maxDelta_=-1,this.maxDeltaRevision_=-1,t!==void 0&&!Array.isArray(e[0])?this.setFlatCoordinates(t,e):this.setCoordinates(e,t)}appendCoordinate(e){se(this.flatCoordinates,e),this.changed()}clone(){const e=new at(this.flatCoordinates.slice(),this.layout);return e.applyProperties(this),e}closestPointXY(e,t,n,i){return i<ei(this.getExtent(),e,t)?i:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(hl(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),ul(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,this.maxDelta_,!1,e,t,n,i))}forEachSegment(e){return hu(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,e)}getCoordinateAtM(e,t){return this.layout!="XYM"&&this.layout!="XYZM"?null:(t=t!==void 0?t:!1,Na(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,e,t))}getCoordinates(){return yn(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getCoordinateAt(e,t){return $r(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,e,t,this.stride)}getLength(){return Bl(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getFlatMidpoint(){return this.flatMidpointRevision_!=this.getRevision()&&(this.flatMidpoint_=this.getCoordinateAt(.5,this.flatMidpoint_??void 0),this.flatMidpointRevision_=this.getRevision()),this.flatMidpoint_}getSimplifiedGeometryInternal(e){const t=[];return t.length=so(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,e,t,0),new at(t,"XY")}getType(){return"LineString"}intersectsExtent(e){return ro(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,e,this.getExtent())}setCoordinates(e,t){this.setLayout(t,e,1),this.flatCoordinates||(this.flatCoordinates=[]),this.flatCoordinates.length=io(this.flatCoordinates,0,e,this.stride),this.changed()}}class rn extends Fn{constructor(e,t,n){if(super(),this.ends_=[],this.maxDelta_=-1,this.maxDeltaRevision_=-1,Array.isArray(e[0]))this.setCoordinates(e,t);else if(t!==void 0&&n)this.setFlatCoordinates(t,e),this.ends_=n;else{const i=e,r=[],o=[];for(let l=0,h=i.length;l<h;++l){const c=i[l];se(r,c.getFlatCoordinates()),o.push(r.length)}const a=i.length===0?this.getLayout():i[0].getLayout();this.setFlatCoordinates(a,r),this.ends_=o}}appendLineString(e){se(this.flatCoordinates,e.getFlatCoordinates().slice()),this.ends_.push(this.flatCoordinates.length),this.changed()}clone(){const e=new rn(this.flatCoordinates.slice(),this.layout,this.ends_.slice());return e.applyProperties(this),e}closestPointXY(e,t,n,i){return i<ei(this.getExtent(),e,t)?i:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(cl(this.flatCoordinates,0,this.ends_,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),dl(this.flatCoordinates,0,this.ends_,this.stride,this.maxDelta_,!1,e,t,n,i))}getCoordinateAtM(e,t,n){return this.layout!="XYM"&&this.layout!="XYZM"||this.flatCoordinates.length===0?null:(t=t!==void 0?t:!1,n=n!==void 0?n:!1,bp(this.flatCoordinates,0,this.ends_,this.stride,e,t,n))}getCoordinates(){return Rs(this.flatCoordinates,0,this.ends_,this.stride)}getEnds(){return this.ends_}getLineString(e){return e<0||this.ends_.length<=e?null:new at(this.flatCoordinates.slice(e===0?0:this.ends_[e-1],this.ends_[e]),this.layout)}getLineStrings(){const e=this.flatCoordinates,t=this.ends_,n=this.layout,i=[];let r=0;for(let o=0,a=t.length;o<a;++o){const l=t[o],h=new at(e.slice(r,l),n);i.push(h),r=l}return i}getLength(){const e=this.ends_;let t=0,n=0;for(let i=0,r=e.length;i<r;++i)n+=Bl(this.flatCoordinates,t,e[i],this.stride),t=e[i];return n}getFlatMidpoints(){const e=[],t=this.flatCoordinates;let n=0;const i=this.ends_,r=this.stride;for(let o=0,a=i.length;o<a;++o){const l=i[o],h=$r(t,n,l,r,.5);se(e,h),n=l}return e}getSimplifiedGeometryInternal(e){const t=[],n=[];return t.length=au(this.flatCoordinates,0,this.ends_,this.stride,e,t,0,n),new rn(t,"XY",n)}getType(){return"MultiLineString"}intersectsExtent(e){return Fg(this.flatCoordinates,0,this.ends_,this.stride,e)}setCoordinates(e,t){this.setLayout(t,e,2),this.flatCoordinates||(this.flatCoordinates=[]);const n=Gs(this.flatCoordinates,0,e,this.stride,this.ends_);this.flatCoordinates.length=n.length===0?0:n[n.length-1],this.changed()}}class ri extends Fn{constructor(e,t){super(),t&&!Array.isArray(e[0])?this.setFlatCoordinates(t,e):this.setCoordinates(e,t)}appendPoint(e){se(this.flatCoordinates,e.getFlatCoordinates()),this.changed()}clone(){const e=new ri(this.flatCoordinates.slice(),this.layout);return e.applyProperties(this),e}closestPointXY(e,t,n,i){if(i<ei(this.getExtent(),e,t))return i;const r=this.flatCoordinates,o=this.stride;for(let a=0,l=r.length;a<l;a+=o){const h=Jt(e,t,r[a],r[a+1]);if(h<i){i=h;for(let c=0;c<o;++c)n[c]=r[a+c];n.length=o}}return i}getCoordinates(){return yn(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getPoint(e){const t=this.flatCoordinates.length/this.stride;return e<0||t<=e?null:new ot(this.flatCoordinates.slice(e*this.stride,(e+1)*this.stride),this.layout)}getPoints(){const e=this.flatCoordinates,t=this.layout,n=this.stride,i=[];for(let r=0,o=e.length;r<o;r+=n){const a=new ot(e.slice(r,r+n),t);i.push(a)}return i}getType(){return"MultiPoint"}intersectsExtent(e){const t=this.flatCoordinates,n=this.stride;for(let i=0,r=t.length;i<r;i+=n){const o=t[i],a=t[i+1];if(Ka(e,o,a))return!0}return!1}setCoordinates(e,t){this.setLayout(t,e,1),this.flatCoordinates||(this.flatCoordinates=[]),this.flatCoordinates.length=io(this.flatCoordinates,0,e,this.stride),this.changed()}}class In extends Fn{constructor(e,t,n){if(super(),this.endss_=[],this.flatInteriorPointsRevision_=-1,this.flatInteriorPoints_=null,this.maxDelta_=-1,this.maxDeltaRevision_=-1,this.orientedRevision_=-1,this.orientedFlatCoordinates_=null,!n&&!Array.isArray(e[0])){const i=e,r=[],o=[];for(let a=0,l=i.length;a<l;++a){const h=i[a],c=r.length,u=h.getEnds();for(let d=0,f=u.length;d<f;++d)u[d]+=c;se(r,h.getFlatCoordinates()),o.push(u)}t=i.length===0?this.getLayout():i[0].getLayout(),e=r,n=o}t!==void 0&&n?(this.setFlatCoordinates(t,e),this.endss_=n):this.setCoordinates(e,t)}appendPolygon(e){let t;if(!this.flatCoordinates)this.flatCoordinates=e.getFlatCoordinates().slice(),t=e.getEnds().slice(),this.endss_.push();else{const n=this.flatCoordinates.length;se(this.flatCoordinates,e.getFlatCoordinates()),t=e.getEnds().slice();for(let i=0,r=t.length;i<r;++i)t[i]+=n}this.endss_.push(t),this.changed()}clone(){const e=this.endss_.length,t=new Array(e);for(let i=0;i<e;++i)t[i]=this.endss_[i].slice();const n=new In(this.flatCoordinates.slice(),this.layout,t);return n.applyProperties(this),n}closestPointXY(e,t,n,i){return i<ei(this.getExtent(),e,t)?i:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(vg(this.flatCoordinates,0,this.endss_,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),wg(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride,this.maxDelta_,!0,e,t,n,i))}containsXY(e,t){return Ag(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride,e,t)}getArea(){return Sg(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride)}getCoordinates(e){let t;return e!==void 0?(t=this.getOrientedFlatCoordinates().slice(),va(t,0,this.endss_,this.stride,e)):t=this.flatCoordinates,Sa(t,0,this.endss_,this.stride)}getEndss(){return this.endss_}getFlatInteriorPoints(){if(this.flatInteriorPointsRevision_!=this.getRevision()){const e=Ju(this.flatCoordinates,0,this.endss_,this.stride);this.flatInteriorPoints_=lu(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride,e),this.flatInteriorPointsRevision_=this.getRevision()}return this.flatInteriorPoints_}getInteriorPoints(){return new ri(this.getFlatInteriorPoints().slice(),"XYM")}getOrientedFlatCoordinates(){if(this.orientedRevision_!=this.getRevision()){const e=this.flatCoordinates;du(e,0,this.endss_,this.stride)?this.orientedFlatCoordinates_=e:(this.orientedFlatCoordinates_=e.slice(),this.orientedFlatCoordinates_.length=va(this.orientedFlatCoordinates_,0,this.endss_,this.stride)),this.orientedRevision_=this.getRevision()}return this.orientedFlatCoordinates_}getSimplifiedGeometryInternal(e){const t=[],n=[];return t.length=Ig(this.flatCoordinates,0,this.endss_,this.stride,Math.sqrt(e),t,0,n),new In(t,"XY",n)}getPolygon(e){if(e<0||this.endss_.length<=e)return null;let t;if(e===0)t=0;else{const r=this.endss_[e-1];t=r[r.length-1]}const n=this.endss_[e].slice(),i=n[n.length-1];if(t!==0)for(let r=0,o=n.length;r<o;++r)n[r]-=t;return new Qe(this.flatCoordinates.slice(t,i),this.layout,n)}getPolygons(){const e=this.layout,t=this.flatCoordinates,n=this.endss_,i=[];let r=0;for(let o=0,a=n.length;o<a;++o){const l=n[o].slice(),h=l[l.length-1];if(r!==0)for(let u=0,d=l.length;u<d;++u)l[u]-=r;const c=new Qe(t.slice(r,h),e,l);i.push(c),r=h}return i}getType(){return"MultiPolygon"}intersectsExtent(e){return bg(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride,e)}setCoordinates(e,t){this.setLayout(t,e,3),this.flatCoordinates||(this.flatCoordinates=[]);const n=ou(this.flatCoordinates,0,e,this.stride,this.endss_);if(n.length===0)this.flatCoordinates.length=0;else{const i=n[n.length-1];this.flatCoordinates.length=i.length===0?0:i[i.length-1]}this.changed()}}const cc=Te();class He{constructor(e,t,n,i,r,o){this.styleFunction,this.extent_,this.id_=o,this.type_=e,this.flatCoordinates_=t,this.flatInteriorPoints_=null,this.flatMidpoints_=null,this.ends_=n||null,this.properties_=r,this.squaredTolerance_,this.stride_=i,this.simplifiedGeometry_}get(e){return this.properties_[e]}getExtent(){return this.extent_||(this.extent_=this.type_==="Point"?ds(this.flatCoordinates_):Ha(this.flatCoordinates_,0,this.flatCoordinates_.length,2)),this.extent_}getFlatInteriorPoint(){if(!this.flatInteriorPoints_){const e=Pn(this.getExtent());this.flatInteriorPoints_=_l(this.flatCoordinates_,0,this.ends_,2,e,0)}return this.flatInteriorPoints_}getFlatInteriorPoints(){if(!this.flatInteriorPoints_){const e=fu(this.flatCoordinates_,this.ends_),t=Ju(this.flatCoordinates_,0,e,2);this.flatInteriorPoints_=lu(this.flatCoordinates_,0,e,2,t)}return this.flatInteriorPoints_}getFlatMidpoint(){return this.flatMidpoints_||(this.flatMidpoints_=$r(this.flatCoordinates_,0,this.flatCoordinates_.length,2,.5)),this.flatMidpoints_}getFlatMidpoints(){if(!this.flatMidpoints_){this.flatMidpoints_=[];const e=this.flatCoordinates_;let t=0;const n=this.ends_;for(let i=0,r=n.length;i<r;++i){const o=n[i],a=$r(e,t,o,2,.5);se(this.flatMidpoints_,a),t=o}}return this.flatMidpoints_}getId(){return this.id_}getOrientedFlatCoordinates(){return this.flatCoordinates_}getGeometry(){return this}getSimplifiedGeometry(e){return this}simplifyTransformed(e,t){return this}getProperties(){return this.properties_}getPropertiesInternal(){return this.properties_}getStride(){return this.stride_}getStyleFunction(){return this.styleFunction}getType(){return this.type_}transform(e){e=_e(e);const t=e.getExtent(),n=e.getWorldExtent();if(t&&n){const i=be(n)/be(t);lt(cc,n[0],n[3],i,-i,0,0,0),Nt(this.flatCoordinates_,0,this.flatCoordinates_.length,2,cc,this.flatCoordinates_)}}applyTransform(e){e(this.flatCoordinates_,this.flatCoordinates_,this.stride_)}clone(){return new He(this.type_,this.flatCoordinates_.slice(),this.ends_?.slice(),this.stride_,Object.assign({},this.properties_),this.id_)}getEnds(){return this.ends_}enableSimplifyTransformed(){return this.simplifyTransformed=Mc((e,t)=>{if(e===this.squaredTolerance_)return this.simplifiedGeometry_;this.simplifiedGeometry_=this.clone(),t&&this.simplifiedGeometry_.applyTransform(t);const n=this.simplifiedGeometry_.getFlatCoordinates();let i;switch(this.type_){case"LineString":n.length=so(n,0,this.simplifiedGeometry_.flatCoordinates_.length,this.simplifiedGeometry_.stride_,e,n,0),i=[n.length];break;case"MultiLineString":i=[],n.length=au(n,0,this.simplifiedGeometry_.ends_,this.simplifiedGeometry_.stride_,e,n,0,i);break;case"Polygon":i=[],n.length=fl(n,0,this.simplifiedGeometry_.ends_,this.simplifiedGeometry_.stride_,Math.sqrt(e),n,0,i);break}return i&&(this.simplifiedGeometry_=new He(this.type_,n,i,2,this.properties_,this.id_)),this.squaredTolerance_=e,this.simplifiedGeometry_}),this}}He.prototype.getFlatCoordinates=He.prototype.getOrientedFlatCoordinates;class Ga{constructor(e){this.rbush_=new Pl(e),this.items_={}}insert(e,t){const n={minX:e[0],minY:e[1],maxX:e[2],maxY:e[3],value:t};this.rbush_.insert(n),this.items_[D(t)]=n}load(e,t){const n=new Array(t.length);for(let i=0,r=t.length;i<r;i++){const o=e[i],a=t[i],l={minX:o[0],minY:o[1],maxX:o[2],maxY:o[3],value:a};n[i]=l,this.items_[D(a)]=l}this.rbush_.load(n)}remove(e){const t=D(e),n=this.items_[t];return delete this.items_[t],this.rbush_.remove(n)!==null}update(e,t){const n=this.items_[D(t)],i=[n.minX,n.minY,n.maxX,n.maxY];Kn(i,e)||(this.remove(t),this.insert(e,t))}getAll(){return this.rbush_.all().map(function(t){return t.value})}getInExtent(e){const t={minX:e[0],minY:e[1],maxX:e[2],maxY:e[3]};return this.rbush_.search(t).map(function(i){return i.value})}forEach(e){return this.forEach_(this.getAll(),e)}forEachInExtent(e,t){return this.forEach_(this.getInExtent(e),t)}forEach_(e,t){let n;for(let i=0,r=e.length;i<r;i++)if(n=t(e[i]),n)return n;return n}isEmpty(){return jn(this.items_)}clear(){this.rbush_.clear(),this.items_={}}getExtent(e){const t=this.rbush_.toJSON();return kt(t.minX,t.minY,t.maxX,t.maxY,e)}concat(e){this.rbush_.load(e.rbush_.all());for(const t in e.items_)this.items_[t]=e.items_[t]}}class Qu extends It{constructor(e){super(),this.projection=_e(e.projection),this.attributions_=uc(e.attributions),this.attributionsCollapsible_=e.attributionsCollapsible??!0,this.loading=!1,this.state_=e.state!==void 0?e.state:"ready",this.wrapX_=e.wrapX!==void 0?e.wrapX:!1,this.interpolate_=!!e.interpolate,this.viewResolver=null,this.viewRejector=null;const t=this;this.viewPromise_=new Promise(function(n,i){t.viewResolver=n,t.viewRejector=i})}getAttributions(){return this.attributions_}getAttributionsCollapsible(){return this.attributionsCollapsible_}getProjection(){return this.projection}getResolutions(e){return null}getView(){return this.viewPromise_}getState(){return this.state_}getWrapX(){return this.wrapX_}getInterpolate(){return this.interpolate_}refresh(){this.changed()}setAttributions(e){this.attributions_=uc(e),this.changed()}setState(e){this.state_=e,this.changed()}}function uc(s){return s?typeof s=="function"?s:(Array.isArray(s)||(s=[s]),e=>s):null}const Le={ADDFEATURE:"addfeature",CHANGEFEATURE:"changefeature",CLEAR:"clear",REMOVEFEATURE:"removefeature",FEATURESLOADSTART:"featuresloadstart",FEATURESLOADEND:"featuresloadend",FEATURESLOADERROR:"featuresloaderror"};class fn extends Tt{constructor(e,t,n){super(e),this.feature=t,this.features=n}}class ed extends Qu{constructor(e){e=e||{},super({attributions:e.attributions,interpolate:!0,projection:void 0,state:"ready",wrapX:e.wrapX!==void 0?e.wrapX:!0}),this.on,this.once,this.un,this.loader_=Es,this.format_=e.format||null,this.overlaps_=e.overlaps===void 0?!0:e.overlaps,this.url_=e.url,e.loader!==void 0?this.loader_=e.loader:this.url_!==void 0&&(te(this.format_,"`format` must be set when `url` is set"),this.loader_=hc(this.url_,this.format_)),this.strategy_=e.strategy!==void 0?e.strategy:Ap;const t=e.useSpatialIndex!==void 0?e.useSpatialIndex:!0;this.featuresRtree_=t?new Ga:null,this.loadedExtentsRtree_=new Ga,this.loadingExtentsCount_=0,this.nullGeometryFeatures_={},this.idIndex_={},this.uidIndex_={},this.featureChangeKeys_={},this.featuresCollection_=null;let n,i;Array.isArray(e.features)?i=e.features:e.features&&(n=e.features,i=n.getArray()),!t&&n===void 0&&(n=new Ve(i)),i!==void 0&&this.addFeaturesInternal(i),n!==void 0&&this.bindFeaturesCollection_(n)}addFeature(e){this.addFeatureInternal(e),this.changed()}addFeatureInternal(e){const t=D(e);if(!this.addToIndex_(t,e)){this.featuresCollection_&&this.featuresCollection_.remove(e);return}this.setupChangeEvents_(t,e);const n=e.getGeometry();if(n){const i=n.getExtent();this.featuresRtree_&&this.featuresRtree_.insert(i,e)}else this.nullGeometryFeatures_[t]=e;this.dispatchEvent(new fn(Le.ADDFEATURE,e))}setupChangeEvents_(e,t){t instanceof He||(this.featureChangeKeys_[e]=[J(t,V.CHANGE,this.handleFeatureChange_,this),J(t,Oi.PROPERTYCHANGE,this.handleFeatureChange_,this)])}addToIndex_(e,t){let n=!0;if(t.getId()!==void 0){const i=String(t.getId());if(!(i in this.idIndex_))this.idIndex_[i]=t;else if(t instanceof He){const r=this.idIndex_[i];r instanceof He?Array.isArray(r)?r.push(t):this.idIndex_[i]=[r,t]:n=!1}else n=!1}return n&&(te(!(e in this.uidIndex_),"The passed `feature` was already added to the source"),this.uidIndex_[e]=t),n}addFeatures(e){this.addFeaturesInternal(e),this.changed()}addFeaturesInternal(e){const t=[],n=[],i=[];for(let r=0,o=e.length;r<o;r++){const a=e[r],l=D(a);this.addToIndex_(l,a)&&n.push(a)}for(let r=0,o=n.length;r<o;r++){const a=n[r],l=D(a);this.setupChangeEvents_(l,a);const h=a.getGeometry();if(h){const c=h.getExtent();t.push(c),i.push(a)}else this.nullGeometryFeatures_[l]=a}if(this.featuresRtree_&&this.featuresRtree_.load(t,i),this.hasListener(Le.ADDFEATURE))for(let r=0,o=n.length;r<o;r++)this.dispatchEvent(new fn(Le.ADDFEATURE,n[r]))}bindFeaturesCollection_(e){let t=!1;this.addEventListener(Le.ADDFEATURE,function(n){t||(t=!0,e.push(n.feature),t=!1)}),this.addEventListener(Le.REMOVEFEATURE,function(n){t||(t=!0,e.remove(n.feature),t=!1)}),e.addEventListener(Re.ADD,n=>{t||(t=!0,this.addFeature(n.element),t=!1)}),e.addEventListener(Re.REMOVE,n=>{t||(t=!0,this.removeFeature(n.element),t=!1)}),this.featuresCollection_=e}clear(e){if(e){for(const n in this.featureChangeKeys_)this.featureChangeKeys_[n].forEach(ue);this.featuresCollection_||(this.featureChangeKeys_={},this.idIndex_={},this.uidIndex_={})}else if(this.featuresRtree_){this.featuresRtree_.forEach(n=>{this.removeFeatureInternal(n)});for(const n in this.nullGeometryFeatures_)this.removeFeatureInternal(this.nullGeometryFeatures_[n])}this.featuresCollection_&&this.featuresCollection_.clear(),this.featuresRtree_&&this.featuresRtree_.clear(),this.nullGeometryFeatures_={};const t=new fn(Le.CLEAR);this.dispatchEvent(t),this.changed()}forEachFeature(e){if(this.featuresRtree_)return this.featuresRtree_.forEach(e);this.featuresCollection_&&this.featuresCollection_.forEach(e)}forEachFeatureAtCoordinateDirect(e,t){const n=[e[0],e[1],e[0],e[1]];return this.forEachFeatureInExtent(n,function(i){const r=i.getGeometry();if(r instanceof He||r.intersectsCoordinate(e))return t(i)})}forEachFeatureInExtent(e,t){if(this.featuresRtree_)return this.featuresRtree_.forEachInExtent(e,t);this.featuresCollection_&&this.featuresCollection_.forEach(t)}forEachFeatureIntersectingExtent(e,t){return this.forEachFeatureInExtent(e,function(n){const i=n.getGeometry();if(i instanceof He||i.intersectsExtent(e)){const r=t(n);if(r)return r}})}getFeaturesCollection(){return this.featuresCollection_}getFeatures(){let e;return this.featuresCollection_?e=this.featuresCollection_.getArray().slice(0):this.featuresRtree_&&(e=this.featuresRtree_.getAll(),jn(this.nullGeometryFeatures_)||se(e,Object.values(this.nullGeometryFeatures_))),e}getFeaturesAtCoordinate(e){const t=[];return this.forEachFeatureAtCoordinateDirect(e,function(n){t.push(n)}),t}getFeaturesInExtent(e,t){if(this.featuresRtree_){if(!(t&&t.canWrapX()&&this.getWrapX()))return this.featuresRtree_.getInExtent(e);const i=Xc(e,t);return[].concat(...i.map(r=>this.featuresRtree_.getInExtent(r)))}return this.featuresCollection_?this.featuresCollection_.getArray().slice(0):[]}getClosestFeatureToCoordinate(e,t){const n=e[0],i=e[1];let r=null;const o=[NaN,NaN];let a=1/0;const l=[-1/0,-1/0,1/0,1/0];return t=t||wn,this.featuresRtree_.forEachInExtent(l,function(h){if(t(h)){const c=h.getGeometry(),u=a;if(a=c instanceof He?0:c.closestPointXY(n,i,o,a),a<u){r=h;const d=Math.sqrt(a);l[0]=n-d,l[1]=i-d,l[2]=n+d,l[3]=i+d}}}),r}getExtent(e){return this.featuresRtree_.getExtent(e)}getFeatureById(e){const t=this.idIndex_[e.toString()];return t!==void 0?t:null}getFeatureByUid(e){const t=this.uidIndex_[e];return t!==void 0?t:null}getFormat(){return this.format_}getOverlaps(){return this.overlaps_}getUrl(){return this.url_}handleFeatureChange_(e){const t=e.target,n=D(t),i=t.getGeometry();if(!i)n in this.nullGeometryFeatures_||(this.featuresRtree_&&this.featuresRtree_.remove(t),this.nullGeometryFeatures_[n]=t);else{const o=i.getExtent();n in this.nullGeometryFeatures_?(delete this.nullGeometryFeatures_[n],this.featuresRtree_&&this.featuresRtree_.insert(o,t)):this.featuresRtree_&&this.featuresRtree_.update(o,t)}const r=t.getId();if(r!==void 0){const o=r.toString();this.idIndex_[o]!==t&&(this.removeFromIdIndex_(t),this.idIndex_[o]=t)}else this.removeFromIdIndex_(t),this.uidIndex_[n]=t;this.changed(),this.dispatchEvent(new fn(Le.CHANGEFEATURE,t))}hasFeature(e){const t=e.getId();return t!==void 0?t in this.idIndex_:D(e)in this.uidIndex_}isEmpty(){return this.featuresRtree_?this.featuresRtree_.isEmpty()&&jn(this.nullGeometryFeatures_):this.featuresCollection_?this.featuresCollection_.getLength()===0:!0}loadFeatures(e,t,n){const i=this.loadedExtentsRtree_,r=this.strategy_(e,t,n);for(let o=0,a=r.length;o<a;++o){const l=r[o];i.forEachInExtent(l,function(c){return pn(c.extent,l)})||(++this.loadingExtentsCount_,this.dispatchEvent(new fn(Le.FEATURESLOADSTART)),this.loader_.call(this,l,t,n,c=>{--this.loadingExtentsCount_,this.dispatchEvent(new fn(Le.FEATURESLOADEND,void 0,c))},()=>{--this.loadingExtentsCount_,this.dispatchEvent(new fn(Le.FEATURESLOADERROR))}),i.insert(l,{extent:l.slice()}))}this.loading=this.loader_.length<4?!1:this.loadingExtentsCount_>0}refresh(){this.clear(!0),this.loadedExtentsRtree_.clear(),super.refresh()}removeLoadedExtent(e){const t=this.loadedExtentsRtree_,n=t.forEachInExtent(e,function(i){if(Kn(i.extent,e))return i});n&&t.remove(n)}removeFeatures(e){let t=!1;for(let n=0,i=e.length;n<i;++n)t=this.removeFeatureInternal(e[n])||t;t&&this.changed()}removeFeature(e){if(!e)return;this.removeFeatureInternal(e)&&this.changed()}removeFeatureInternal(e){const t=D(e);if(!(t in this.uidIndex_))return!1;t in this.nullGeometryFeatures_?delete this.nullGeometryFeatures_[t]:this.featuresRtree_&&this.featuresRtree_.remove(e),this.featureChangeKeys_[t]?.forEach(ue),delete this.featureChangeKeys_[t];const i=e.getId();if(i!==void 0){const r=i.toString(),o=this.idIndex_[r];o===e?delete this.idIndex_[r]:Array.isArray(o)&&(o.splice(o.indexOf(e),1),o.length===1&&(this.idIndex_[r]=o[0]))}return delete this.uidIndex_[t],this.hasListener(Le.REMOVEFEATURE)&&this.dispatchEvent(new fn(Le.REMOVEFEATURE,e)),!0}removeFromIdIndex_(e){for(const t in this.idIndex_)if(this.idIndex_[t]===e){delete this.idIndex_[t];break}}setLoader(e){this.loader_=e}setUrl(e){te(this.format_,"`format` must be set when `url` is set"),this.url_=e,this.setLoader(hc(e,this.format_))}setOverlaps(e){this.overlaps_=e,this.changed()}}const dc=4;function td(s,e){const t=[];Object.keys(e).forEach(function(i){e[i]!==null&&e[i]!==void 0&&t.push(i+"="+encodeURIComponent(e[i]))});const n=t.join("&");return s=s.replace(/[?&]$/,""),s+=s.includes("?")?"&":"?",s+n}const Mp=/\{z\}/g,Dp=/\{x\}/g,Op=/\{y\}/g,Np=/\{-y\}/g;function Gp(s,e,t,n,i){return s.replace(Mp,e.toString()).replace(Dp,t.toString()).replace(Op,n.toString()).replace(Np,function(){if(i===void 0)throw new Error("If the URL template has a {-y} placeholder, the grid extent must be known");return(i-n).toString()})}function kp(s){const e=[];let t=/\{([a-z])-([a-z])\}/.exec(s);if(t){const n=t[1].charCodeAt(0),i=t[2].charCodeAt(0);let r;for(r=n;r<=i;++r)e.push(s.replace(t[0],String.fromCharCode(r)));return e}if(t=/\{(\d+)-(\d+)\}/.exec(s),t){const n=parseInt(t[2],10);for(let i=parseInt(t[1],10);i<=n;i++)e.push(s.replace(t[0],i.toString()));return e}return e.push(s),e}const ka="1.3.0";function Up(s,e,t,n,i){i.WIDTH=t[0],i.HEIGHT=t[1];const r=n.getAxisOrientation(),o=Wc(i.VERSION,"1.3")>=0;i[o?"CRS":"SRS"]=n.getCode();const a=o&&r.startsWith("ne")?[e[1],e[0],e[3],e[2]]:e;return i.BBOX=a.join(","),td(s,i)}function Bp(s,e,t,n,i,r,o){r=Object.assign({REQUEST:"GetMap"},r);const a=e/t,l=[xh(ne(s)/a,dc),xh(be(s)/a,dc)];if(t!=1)switch(o){case"geoserver":const c=90*t+.5|0;"FORMAT_OPTIONS"in r?r.FORMAT_OPTIONS+=";dpi:"+c:r.FORMAT_OPTIONS="dpi:"+c;break;case"mapserver":r.MAP_RESOLUTION=90*t;break;case"carmentaserver":case"qgis":r.DPI=90*t;break;default:throw new Error("Unknown `serverType` configured")}return Up(i,s,l,n,r)}function fc(s,e){return Object.assign({REQUEST:e,SERVICE:"WMS",VERSION:ka,FORMAT:"image/png",STYLES:"",TRANSPARENT:"TRUE"},s)}const mi=[0,0,0],gn=5;class nd{constructor(e){this.minZoom=e.minZoom!==void 0?e.minZoom:0,this.resolutions_=e.resolutions,te(hf(this.resolutions_,(i,r)=>r-i),"`resolutions` must be sorted in descending order");let t;if(!e.origins){for(let i=0,r=this.resolutions_.length-1;i<r;++i)if(!t)t=this.resolutions_[i]/this.resolutions_[i+1];else if(this.resolutions_[i]/this.resolutions_[i+1]!==t){t=void 0;break}}this.zoomFactor_=t,this.maxZoom=this.resolutions_.length-1,this.origin_=e.origin!==void 0?e.origin:null,this.origins_=null,e.origins!==void 0&&(this.origins_=e.origins,te(this.origins_.length==this.resolutions_.length,"Number of `origins` and `resolutions` must be equal"));const n=e.extent;n!==void 0&&!this.origin_&&!this.origins_&&(this.origin_=An(n)),te(!this.origin_&&this.origins_||this.origin_&&!this.origins_,"Either `origin` or `origins` must be configured, never both"),this.tileSizes_=null,e.tileSizes!==void 0&&(this.tileSizes_=e.tileSizes,te(this.tileSizes_.length==this.resolutions_.length,"Number of `tileSizes` and `resolutions` must be equal")),this.tileSize_=e.tileSize!==void 0?e.tileSize:this.tileSizes_?null:Tl,te(!this.tileSize_&&this.tileSizes_||this.tileSize_&&!this.tileSizes_,"Either `tileSize` or `tileSizes` must be configured, never both"),this.extent_=n!==void 0?n:null,this.fullTileRanges_=null,this.tmpSize_=[0,0],this.tmpExtent_=[0,0,0,0],e.sizes!==void 0?this.fullTileRanges_=e.sizes.map((i,r)=>{const o=new Gl(Math.min(0,i[0]),Math.max(i[0]-1,-1),Math.min(0,i[1]),Math.max(i[1]-1,-1));if(n){const a=this.getTileRangeForExtentAndZ(n,r);o.minX=Math.max(a.minX,o.minX),o.maxX=Math.min(a.maxX,o.maxX),o.minY=Math.max(a.minY,o.minY),o.maxY=Math.min(a.maxY,o.maxY)}return o}):n&&this.calculateTileRanges_(n)}forEachTileCoord(e,t,n){const i=this.getTileRangeForExtentAndZ(e,t);for(let r=i.minX,o=i.maxX;r<=o;++r)for(let a=i.minY,l=i.maxY;a<=l;++a)n([t,r,a])}forEachTileCoordParentTileRange(e,t,n,i){let r,o,a,l=null,h=e[0]-1;for(this.zoomFactor_===2?(o=e[1],a=e[2]):l=this.getTileCoordExtent(e,i);h>=this.minZoom;){if(o!==void 0&&a!==void 0?(o=Math.floor(o/2),a=Math.floor(a/2),r=gi(o,o,a,a,n)):r=this.getTileRangeForExtentAndZ(l,h,n),t(h,r))return!0;--h}return!1}getExtent(){return this.extent_}getMaxZoom(){return this.maxZoom}getMinZoom(){return this.minZoom}getOrigin(e){return this.origin_?this.origin_:this.origins_[e]}getResolution(e){return this.resolutions_[e]}getResolutions(){return this.resolutions_}getTileCoordChildTileRange(e,t,n){if(e[0]<this.maxZoom){if(this.zoomFactor_===2){const r=e[1]*2,o=e[2]*2;return gi(r,r+1,o,o+1,t)}const i=this.getTileCoordExtent(e,n||this.tmpExtent_);return this.getTileRangeForExtentAndZ(i,e[0]+1,t)}return null}getTileRangeForTileCoordAndZ(e,t,n){if(t>this.maxZoom||t<this.minZoom)return null;const i=e[0],r=e[1],o=e[2];if(t===i)return gi(r,o,r,o,n);if(this.zoomFactor_){const l=Math.pow(this.zoomFactor_,t-i),h=Math.floor(r*l),c=Math.floor(o*l);if(t<i)return gi(h,h,c,c,n);const u=Math.floor(l*(r+1))-1,d=Math.floor(l*(o+1))-1;return gi(h,u,c,d,n)}const a=this.getTileCoordExtent(e,this.tmpExtent_);return this.getTileRangeForExtentAndZ(a,t,n)}getTileRangeForExtentAndZ(e,t,n){this.getTileCoordForXYAndZ_(e[0],e[3],t,!1,mi);const i=mi[1],r=mi[2];this.getTileCoordForXYAndZ_(e[2],e[1],t,!0,mi);const o=mi[1],a=mi[2];return gi(i,o,r,a,n)}getTileCoordCenter(e){const t=this.getOrigin(e[0]),n=this.getResolution(e[0]),i=$e(this.getTileSize(e[0]),this.tmpSize_);return[t[0]+(e[1]+.5)*i[0]*n,t[1]-(e[2]+.5)*i[1]*n]}getTileCoordExtent(e,t){const n=this.getOrigin(e[0]),i=this.getResolution(e[0]),r=$e(this.getTileSize(e[0]),this.tmpSize_),o=n[0]+e[1]*r[0]*i,a=n[1]-(e[2]+1)*r[1]*i,l=o+r[0]*i,h=a+r[1]*i;return kt(o,a,l,h,t)}getTileCoordForCoordAndResolution(e,t,n){return this.getTileCoordForXYAndResolution_(e[0],e[1],t,!1,n)}getTileCoordForXYAndResolution_(e,t,n,i,r){const o=this.getZForResolution(n),a=n/this.getResolution(o),l=this.getOrigin(o),h=$e(this.getTileSize(o),this.tmpSize_);let c=a*(e-l[0])/n/h[0],u=a*(l[1]-t)/n/h[1];return i?(c=Hs(c,gn)-1,u=Hs(u,gn)-1):(c=Ks(c,gn),u=Ks(u,gn)),kr(o,c,u,r)}getTileCoordForXYAndZ_(e,t,n,i,r){const o=this.getOrigin(n),a=this.getResolution(n),l=$e(this.getTileSize(n),this.tmpSize_);let h=(e-o[0])/a/l[0],c=(o[1]-t)/a/l[1];return i?(h=Hs(h,gn)-1,c=Hs(c,gn)-1):(h=Ks(h,gn),c=Ks(c,gn)),kr(n,h,c,r)}getTileCoordForCoordAndZ(e,t,n){return this.getTileCoordForXYAndZ_(e[0],e[1],t,!1,n)}getTileCoordResolution(e){return this.resolutions_[e[0]]}getTileSize(e){return this.tileSize_?this.tileSize_:this.tileSizes_[e]}getFullTileRange(e){return this.fullTileRanges_?this.fullTileRanges_[e]:this.extent_?this.getTileRangeForExtentAndZ(this.extent_,e):null}getZForResolution(e,t){const n=Za(this.resolutions_,e,t||0);return fe(n,this.minZoom,this.maxZoom)}tileCoordIntersectsViewport(e,t){return cu(t,0,t.length,2,this.getTileCoordExtent(e))}calculateTileRanges_(e){const t=this.resolutions_.length,n=new Array(t);for(let i=this.minZoom;i<t;++i)n[i]=this.getTileRangeForExtentAndZ(e,i);this.fullTileRanges_=n}}function id(s){let e=s.getDefaultTileGrid();return e||(e=Wp(s),s.setDefaultTileGrid(e)),e}function zp(s,e,t){const n=e[0],i=s.getTileCoordCenter(e),r=$l(t);if(!Zn(r,i)){const o=ne(r),a=Math.ceil((r[0]-i[0])/o);return i[0]+=o*a,s.getTileCoordForCoordAndZ(i,n)}return e}function $p(s,e,t,n){n=n!==void 0?n:"top-left";const i=sd(s,e,t);return new nd({extent:s,origin:wf(s,n),resolutions:i,tileSize:t})}function Xp(s){const e=s||{},t=e.extent||_e("EPSG:3857").getExtent(),n={extent:t,minZoom:e.minZoom,tileSize:e.tileSize,resolutions:sd(t,e.maxZoom,e.tileSize,e.maxResolution)};return new nd(n)}function sd(s,e,t,n){e=e!==void 0?e:Ug,t=$e(t!==void 0?t:Tl);const i=be(s),r=ne(s);n=n>0?n:Math.max(r/t[0],i/t[1]);const o=e+1,a=new Array(o);for(let l=0;l<o;++l)a[l]=n/Math.pow(2,l);return a}function Wp(s,e,t,n){const i=$l(s);return $p(i,e,t,n)}function $l(s){s=_e(s);let e=s.getExtent();if(!e){const t=180*Gi.degrees/s.getMetersPerUnit();e=kt(-t,-t,t,t)}return e}function Yp(s,e){return(function(t,n,i){if(!t)return;let r;const o=t[0];if(e){const a=e.getFullTileRange(o);a&&(r=a.getHeight()-1)}return Gp(s,o,t[1],t[2],r)})}function jp(s,e){const t=s.length,n=new Array(t);for(let i=0;i<t;++i)n[i]=Yp(s[i],e);return Vp(n)}function Vp(s){return s.length===1?s[0]:(function(e,t,n){if(!e)return;const i=Uu(e),r=Qt(i,s.length);return s[r](e,t,n)})}class Zp extends Qu{constructor(e){super({attributions:e.attributions,attributionsCollapsible:e.attributionsCollapsible,projection:e.projection,state:e.state,wrapX:e.wrapX,interpolate:e.interpolate}),this.on,this.once,this.un,this.tilePixelRatio_=e.tilePixelRatio!==void 0?e.tilePixelRatio:1,this.tileGrid=e.tileGrid!==void 0?e.tileGrid:null;const t=[256,256];this.tileGrid&&$e(this.tileGrid.getTileSize(this.tileGrid.getMinZoom()),t),this.tmpSize=[0,0],this.key_=e.key||D(this),this.tileOptions={transition:e.transition,interpolate:e.interpolate},this.zDirection=e.zDirection?e.zDirection:0}getGutterForProjection(e){return 0}getKey(){return this.key_}setKey(e){this.key_!==e&&(this.key_=e,this.changed())}getResolutions(e){const t=e?this.getTileGridForProjection(e):this.tileGrid;return t?t.getResolutions():null}getTile(e,t,n,i,r,o){return $()}getTileGrid(){return this.tileGrid}getTileGridForProjection(e){return this.tileGrid?this.tileGrid:id(e)}getTilePixelRatio(e){return this.tilePixelRatio_}getTilePixelSize(e,t,n){const i=this.getTileGridForProjection(n),r=this.getTilePixelRatio(t),o=$e(i.getTileSize(e),this.tmpSize);return r==1?o:D_(o,r,this.tmpSize)}getTileCoordForTileUrlFunction(e,t){const n=t!==void 0?t:this.getProjection(),i=t!==void 0?this.getTileGridForProjection(n):this.tileGrid||this.getTileGridForProjection(n);return this.getWrapX()&&n.isGlobal()&&(e=zp(i,e,n)),Km(e,i)?e:null}clear(){}refresh(){this.clear(),super.refresh()}}class Kp extends Tt{constructor(e,t){super(e),this.tile=t}}const qo={TILELOADSTART:"tileloadstart",TILELOADEND:"tileloadend",TILELOADERROR:"tileloaderror"};class Xl extends Zp{constructor(e){super({attributions:e.attributions,cacheSize:e.cacheSize,projection:e.projection,state:e.state,tileGrid:e.tileGrid,tilePixelRatio:e.tilePixelRatio,wrapX:e.wrapX,transition:e.transition,interpolate:e.interpolate,key:e.key,attributionsCollapsible:e.attributionsCollapsible,zDirection:e.zDirection}),this.generateTileUrlFunction_=this.tileUrlFunction===Xl.prototype.tileUrlFunction,this.tileLoadFunction=e.tileLoadFunction,e.tileUrlFunction&&(this.tileUrlFunction=e.tileUrlFunction),this.urls=null,e.urls?this.setUrls(e.urls):e.url&&this.setUrl(e.url),this.tileLoadingKeys_={}}getTileLoadFunction(){return this.tileLoadFunction}getTileUrlFunction(){return Object.getPrototypeOf(this).tileUrlFunction===this.tileUrlFunction?this.tileUrlFunction.bind(this):this.tileUrlFunction}getUrls(){return this.urls}handleTileChange(e){const t=e.target,n=D(t),i=t.getState();let r;i==B.LOADING?(this.tileLoadingKeys_[n]=!0,r=qo.TILELOADSTART):n in this.tileLoadingKeys_&&(delete this.tileLoadingKeys_[n],r=i==B.ERROR?qo.TILELOADERROR:i==B.LOADED?qo.TILELOADEND:void 0),r!=null&&this.dispatchEvent(new Kp(r,t))}setTileLoadFunction(e){this.tileLoadFunction=e,this.changed()}setTileUrlFunction(e,t){this.tileUrlFunction=e,typeof t<"u"?this.setKey(t):this.changed()}setUrl(e){const t=kp(e);this.urls=t,this.setUrls(t)}setUrls(e){this.urls=e;const t=e.join(`
|
||
`);this.generateTileUrlFunction_?this.setTileUrlFunction(jp(e,this.tileGrid),t):this.setKey(t)}tileUrlFunction(e,t,n){}}class rd extends Xl{constructor(e){super({attributions:e.attributions,cacheSize:e.cacheSize,projection:e.projection,state:e.state,tileGrid:e.tileGrid,tileLoadFunction:e.tileLoadFunction?e.tileLoadFunction:od,tilePixelRatio:e.tilePixelRatio,tileUrlFunction:e.tileUrlFunction,url:e.url,urls:e.urls,wrapX:e.wrapX,transition:e.transition,interpolate:e.interpolate!==void 0?e.interpolate:!0,key:e.key,attributionsCollapsible:e.attributionsCollapsible,zDirection:e.zDirection}),this.crossOrigin=e.crossOrigin!==void 0?e.crossOrigin:null,this.tileClass=e.tileClass!==void 0?e.tileClass:Gu,this.tileGridForProjection={},this.reprojectionErrorThreshold_=e.reprojectionErrorThreshold,this.renderReprojectionEdges_=!1}getGutterForProjection(e){return this.getProjection()&&e&&!Yn(this.getProjection(),e)?0:this.getGutter()}getGutter(){return 0}getKey(){let e=super.getKey();return this.getInterpolate()||(e+=":disable-interpolation"),e}getTileGridForProjection(e){const t=this.getProjection();if(this.tileGrid&&(!t||Yn(t,e)))return this.tileGrid;const n=D(e);return n in this.tileGridForProjection||(this.tileGridForProjection[n]=id(e)),this.tileGridForProjection[n]}createTile_(e,t,n,i,r,o){const a=[e,t,n],l=this.getTileCoordForTileUrlFunction(a,r),h=l?this.tileUrlFunction(l,i,r):void 0,c=new this.tileClass(a,h!==void 0?B.IDLE:B.EMPTY,h!==void 0?h:"",this.crossOrigin,this.tileLoadFunction,this.tileOptions);return c.key=o,c.addEventListener(V.CHANGE,this.handleTileChange.bind(this)),c}getTile(e,t,n,i,r,o){const a=this.getProjection();if(!a||!r||Yn(a,r))return this.getTileInternal(e,t,n,i,a||r);const l=[e,t,n],h=this.getKey(),c=this.getTileGridForProjection(a),u=this.getTileGridForProjection(r),d=this.getTileCoordForTileUrlFunction(l,r),f=new ku(a,c,r,u,l,d,this.getTilePixelRatio(i),this.getGutter(),(g,m,_,p)=>this.getTileInternal(g,m,_,p,a,o),this.reprojectionErrorThreshold_,this.renderReprojectionEdges_,this.tileOptions);return f.key=h,f}getTileInternal(e,t,n,i,r,o){const a=this.getKey(),l=Er(this,a,e,t,n);if(o&&o.containsKey(l))return o.get(l);const h=this.createTile_(e,t,n,i,r,a);return o?.set(l,h),h}setRenderReprojectionEdges(e){this.renderReprojectionEdges_!=e&&(this.renderReprojectionEdges_=e,this.changed())}setTileGridForProjection(e,t){const n=_e(e);if(n){const i=D(n);i in this.tileGridForProjection||(this.tileGridForProjection[i]=t)}}}function od(s,e){if(rt){const t=s.getCrossOrigin();let n="same-origin",i="same-origin";t==="anonymous"||t===""?(n="cors",i="omit"):t==="use-credentials"&&(n="cors",i="include"),fetch(e,{mode:n,credentials:i}).then(r=>{if(!r.ok)throw new Error(`HTTP ${r.status}`);return r.blob()}).then(r=>createImageBitmap(r)).then(r=>{const o=s.getImage();o.width=r.width,o.height=r.height,o.getContext("2d").drawImage(r,0,0),r.close?.(),o.dispatchEvent(new Event("load"))}).catch(()=>{s.getImage().dispatchEvent(new Event("error"))});return}s.getImage().src=e}class b0 extends rd{constructor(e){e=e||{};const t=Object.assign({},e.params);super({attributions:e.attributions,attributionsCollapsible:e.attributionsCollapsible,cacheSize:e.cacheSize,crossOrigin:e.crossOrigin,interpolate:e.interpolate,projection:e.projection,reprojectionErrorThreshold:e.reprojectionErrorThreshold,tileClass:e.tileClass,tileGrid:e.tileGrid,tileLoadFunction:e.tileLoadFunction,url:e.url,urls:e.urls,wrapX:e.wrapX!==void 0?e.wrapX:!0,transition:e.transition,zDirection:e.zDirection}),this.gutter_=e.gutter!==void 0?e.gutter:0,this.params_=t,this.v13_=!0,this.serverType_=e.serverType,this.hidpi_=e.hidpi!==void 0?e.hidpi:!0,this.tmpExtent_=Je(),this.updateV13_(),this.setKey(this.getKeyForParams_())}getFeatureInfoUrl(e,t,n,i){const r=_e(n),o=this.getProjection()||r;let a=this.getTileGrid();a||(a=this.getTileGridForProjection(o));const l=Ns(e,r,o),h=Da(o,r,e,t),c=a.getZForResolution(h,this.zDirection),u=a.getResolution(c),d=a.getTileCoordForCoordAndZ(l,c);if(a.getResolutions().length<=d[0])return;let f=a.getTileCoordExtent(d,this.tmpExtent_);const g=this.gutter_;g!==0&&(f=sn(f,u*g,f));const m={QUERY_LAYERS:this.params_.LAYERS};Object.assign(m,fc(this.params_,"GetFeatureInfo"),i);const _=Math.floor((l[0]-f[0])/u),p=Math.floor((f[3]-l[1])/u);return m[this.v13_?"I":"X"]=_,m[this.v13_?"J":"Y"]=p,this.getRequestUrl_(d,f,1,o||r,m)}getLegendUrl(e,t){if(this.urls[0]===void 0)return;const n={SERVICE:"WMS",VERSION:ka,REQUEST:"GetLegendGraphic",FORMAT:"image/png"};if(t===void 0||t.LAYER===void 0){const i=this.params_.LAYERS;if(!(!Array.isArray(i)||i.length===1))return;n.LAYER=i}if(e!==void 0){const i=this.getProjection()?this.getProjection().getMetersPerUnit():1,r=28e-5;n.SCALE=e*i/r}return Object.assign(n,t),td(this.urls[0],n)}getGutter(){return this.gutter_}getParams(){return this.params_}getRequestUrl_(e,t,n,i,r){const o=this.urls;if(!o)return;let a;if(o.length==1)a=o[0];else{const l=Qt(Uu(e),o.length);a=o[l]}return Bp(t,(this.tileGrid||this.getTileGridForProjection(i)).getResolution(e[0]),n,i,a,r,this.serverType_)}getTilePixelRatio(e){return!this.hidpi_||this.serverType_===void 0?1:e}getKeyForParams_(){let e=0;const t=[];for(const n in this.params_)t[e++]=n+"-"+this.params_[n];return t.join("/")}setParams_(e){this.params_=e,this.updateV13_(),this.setKey(this.getKeyForParams_())}setParams(e){this.setParams_(Object.assign({},e))}updateParams(e){this.setParams_(Object.assign(this.params_,e))}updateV13_(){const e=this.params_.VERSION||ka;this.v13_=Wc(e,"1.3")>=0}tileUrlFunction(e,t,n){let i=this.getTileGrid();if(i||(i=this.getTileGridForProjection(n)),i.getResolutions().length<=e[0])return;t!=1&&(!this.hidpi_||this.serverType_===void 0)&&(t=1);const r=i.getResolution(e[0]);let o=i.getTileCoordExtent(e,this.tmpExtent_);const a=this.gutter_;a!==0&&(o=sn(o,r*a,o));const l=Object.assign({},fc(this.params_,"GetMap"));return this.getRequestUrl_(e,o,t,n,l)}}class Hp extends rd{constructor(e){e=e||{};const t=e.projection!==void 0?e.projection:"EPSG:3857",n=e.tileGrid!==void 0?e.tileGrid:Xp({extent:$l(t),maxResolution:e.maxResolution,maxZoom:e.maxZoom,minZoom:e.minZoom,tileSize:e.tileSize});super({attributions:e.attributions,cacheSize:e.cacheSize,crossOrigin:e.crossOrigin,interpolate:e.interpolate,projection:t,reprojectionErrorThreshold:e.reprojectionErrorThreshold,tileGrid:n,tileLoadFunction:e.tileLoadFunction,tilePixelRatio:e.tilePixelRatio,tileUrlFunction:e.tileUrlFunction,url:e.url,urls:e.urls,wrapX:e.wrapX!==void 0?e.wrapX:!0,transition:e.transition,attributionsCollapsible:e.attributionsCollapsible,zDirection:e.zDirection}),this.gutter_=e.gutter!==void 0?e.gutter:0}getGutter(){return this.gutter_}}const qp='© <a href="https://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap</a> contributors.';class M0 extends Hp{constructor(e){e=e||{};let t;e.attributions!==void 0?t=e.attributions:t=[qp];const n=e.crossOrigin!==void 0?e.crossOrigin:"anonymous",i=e.url!==void 0?e.url:"https://tile.openstreetmap.org/{z}/{x}/{y}.png";super({attributions:t,attributionsCollapsible:!1,cacheSize:e.cacheSize,crossOrigin:n,interpolate:e.interpolate,maxZoom:e.maxZoom!==void 0?e.maxZoom:19,reprojectionErrorThreshold:e.reprojectionErrorThreshold,tileLoadFunction:(r,o)=>{const a=r.getImage();!rt&&a instanceof HTMLImageElement&&(a.referrerPolicy="origin-when-cross-origin"),(e.tileLoadFunction||od)(r,o)},transition:e.transition,url:i,wrapX:e.wrapX,zDirection:e.zDirection})}}class Wl{constructor(){this.dataProjection=void 0,this.defaultFeatureProjection=void 0,this.featureClass=ze,this.supportedMediaTypes=null}getReadOptions(e,t){if(t){let n=t.dataProjection?_e(t.dataProjection):this.readProjection(e);t.extent&&n&&n.getUnits()==="tile-pixels"&&(n=_e(n),n.setWorldExtent(t.extent)),t={dataProjection:n,featureProjection:t.featureProjection}}return this.adaptOptions(t)}adaptOptions(e){return Object.assign({dataProjection:this.dataProjection,featureProjection:this.defaultFeatureProjection,featureClass:this.featureClass},e)}getType(){return $()}readFeature(e,t){return $()}readFeatures(e,t){return $()}readGeometry(e,t){return $()}readProjection(e){return $()}writeFeature(e,t){return $()}writeFeatures(e,t){return $()}writeGeometry(e,t){return $()}}function Jn(s,e,t){const n=t?_e(t.featureProjection):null,i=t?_e(t.dataProjection):null;let r=s;if(n&&i&&!Yn(n,i)){e&&(r=s.clone());const o=e?n:i,a=e?i:n;o.getUnits()==="tile-pixels"?r.transform(o,a):r.applyTransform(Hn(o,a))}if(e&&t&&t.decimals!==void 0){const o=Math.pow(10,t.decimals),a=function(l){for(let h=0,c=l.length;h<c;++h)l[h]=Math.round(l[h]*o)/o;return l};r===s&&(r=s.clone()),r.applyTransform(a)}return r}const Jp={Point:ot,LineString:at,Polygon:Qe,MultiPoint:ri,MultiLineString:rn,MultiPolygon:In};function Qp(s,e,t){return Array.isArray(e[0])?(du(s,0,e,t)||(s=s.slice(),va(s,0,e,t)),s):(pl(s,0,e,t)||(s=s.slice(),Ar(s,0,e,t)),s)}function ad(s,e){const t=s.geometry;if(!t)return[];if(Array.isArray(t))return t.map(r=>ad({...s,geometry:r})).flat();const n=t.type==="MultiPolygon"?"Polygon":t.type;if(n==="GeometryCollection"||n==="Circle")throw new Error("Unsupported geometry type: "+n);const i=t.layout.length;return Jn(new He(n,n==="Polygon"?Qp(t.flatCoordinates,t.ends,i):t.flatCoordinates,t.ends?.flat(),i,s.properties||{},s.id).enableSimplifyTransformed(),!1,e)}function Yl(s,e){if(!s)return null;if(Array.isArray(s)){const n=s.map(i=>Yl(i,e));return new Ze(n)}const t=Jp[s.type];return Jn(new t(s.flatCoordinates,s.layout||"XY",s.ends),!1,e)}class ey extends Wl{constructor(){super()}getType(){return"json"}readFeature(e,t){return this.readFeatureFromObject(or(e),this.getReadOptions(e,t))}readFeatures(e,t){return this.readFeaturesFromObject(or(e),this.getReadOptions(e,t))}readFeatureFromObject(e,t){return $()}readFeaturesFromObject(e,t){return $()}readGeometry(e,t){return this.readGeometryFromObject(or(e),this.getReadOptions(e,t))}readGeometryFromObject(e,t){return $()}readProjection(e){return this.readProjectionFromObject(or(e))}readProjectionFromObject(e){return $()}writeFeature(e,t){return JSON.stringify(this.writeFeatureObject(e,t))}writeFeatureObject(e,t){return $()}writeFeatures(e,t){return JSON.stringify(this.writeFeaturesObject(e,t))}writeFeaturesObject(e,t){return $()}writeGeometry(e,t){return JSON.stringify(this.writeGeometryObject(e,t))}writeGeometryObject(e,t){return $()}}function or(s){if(typeof s=="string"){const e=JSON.parse(s);return e||null}return s!==null?s:null}class D0 extends ey{constructor(e){e=e||{},super(),this.dataProjection=_e(e.dataProjection?e.dataProjection:"EPSG:4326"),e.featureProjection&&(this.defaultFeatureProjection=_e(e.featureProjection)),e.featureClass&&(this.featureClass=e.featureClass),this.geometryName_=e.geometryName,this.extractGeometryName_=e.extractGeometryName,this.supportedMediaTypes=["application/geo+json","application/vnd.geo+json"]}readFeatureFromObject(e,t){let n=null;e.type==="Feature"?n=e:n={type:"Feature",geometry:e,properties:null};const i=jl(n.geometry);if(this.featureClass===He)return ad({geometry:i,id:n.id,properties:n.properties},t);const r=new ze;return this.geometryName_?r.setGeometryName(this.geometryName_):this.extractGeometryName_&&n.geometry_name&&r.setGeometryName(n.geometry_name),r.setGeometry(Yl(i,t)),"id"in n&&r.setId(n.id),n.properties&&r.setProperties(n.properties,!0),r}readFeaturesFromObject(e,t){const n=e;let i=null;if(n.type==="FeatureCollection"){const r=e;i=[];const o=r.features;for(let a=0,l=o.length;a<l;++a){const h=this.readFeatureFromObject(o[a],t);h&&i.push(h)}}else i=[this.readFeatureFromObject(e,t)];return i.flat()}readGeometryFromObject(e,t){return ty(e,t)}readProjectionFromObject(e){const t=e.crs;let n;if(t)if(t.type=="name")n=_e(t.properties.name);else if(t.type==="EPSG")n=_e("EPSG:"+t.properties.code);else throw new Error("Unknown SRS type");else n=this.dataProjection;return n}writeFeatureObject(e,t){t=this.adaptOptions(t);const n={type:"Feature",geometry:null,properties:null},i=e.getId();if(i!==void 0&&(n.id=i),!e.hasProperties())return n;const r=e.getProperties(),o=e.getGeometry();return o&&(n.geometry=Ua(o,t),delete r[e.getGeometryName()]),jn(r)||(n.properties=r),n}writeFeaturesObject(e,t){t=this.adaptOptions(t);const n=[];for(let i=0,r=e.length;i<r;++i)n.push(this.writeFeatureObject(e[i],t));return{type:"FeatureCollection",features:n}}writeGeometryObject(e,t){return Ua(e,this.adaptOptions(t))}}function jl(s,e){if(!s)return null;let t;switch(s.type){case"Point":{t=iy(s);break}case"LineString":{t=sy(s);break}case"Polygon":{t=ly(s);break}case"MultiPoint":{t=oy(s);break}case"MultiLineString":{t=ry(s);break}case"MultiPolygon":{t=ay(s);break}case"GeometryCollection":{t=ny(s);break}default:throw new Error("Unsupported GeoJSON type: "+s.type)}return t}function ty(s,e){const t=jl(s);return Yl(t,e)}function ny(s,e){return s.geometries.map(function(n){return jl(n)})}function iy(s){const e=s.coordinates;return{type:"Point",flatCoordinates:e,layout:ni(e.length)}}function sy(s){const e=s.coordinates,t=e.flat();return{type:"LineString",flatCoordinates:t,ends:[t.length],layout:ni(e[0]?.length||2)}}function ry(s){const e=s.coordinates,t=e[0]?.[0]?.length||2,n=[],i=Gs(n,0,e,t);return{type:"MultiLineString",flatCoordinates:n,ends:i,layout:ni(t)}}function oy(s){const e=s.coordinates;return{type:"MultiPoint",flatCoordinates:e.flat(),layout:ni(e[0]?.length||2)}}function ay(s){const e=s.coordinates,t=[],n=e[0]?.[0]?.[0].length||2,i=ou(t,0,e,n);return{type:"MultiPolygon",flatCoordinates:t,ends:i,layout:ni(n)}}function ly(s){const e=s.coordinates,t=[],n=e[0]?.[0]?.length,i=Gs(t,0,e,n);return{type:"Polygon",flatCoordinates:t,ends:i,layout:ni(n)}}function Ua(s,e){s=Jn(s,!0,e);const t=s.getType();let n;switch(t){case"Point":{n=gy(s);break}case"LineString":{n=cy(s);break}case"Polygon":{n=_y(s,e);break}case"MultiPoint":{n=dy(s);break}case"MultiLineString":{n=uy(s);break}case"MultiPolygon":{n=fy(s,e);break}case"GeometryCollection":{n=hy(s,e);break}case"Circle":{n={type:"GeometryCollection",geometries:[]};break}default:throw new Error("Unsupported geometry type: "+t)}return n}function hy(s,e){return e=Object.assign({},e),delete e.featureProjection,{type:"GeometryCollection",geometries:s.getGeometriesArray().map(function(n){return Ua(n,e)})}}function cy(s,e){return{type:"LineString",coordinates:s.getCoordinates()}}function uy(s,e){return{type:"MultiLineString",coordinates:s.getCoordinates()}}function dy(s,e){return{type:"MultiPoint",coordinates:s.getCoordinates()}}function fy(s,e){let t;return e&&(t=e.rightHanded),{type:"MultiPolygon",coordinates:s.getCoordinates(t)}}function gy(s,e){return{type:"Point",coordinates:s.getCoordinates()}}function _y(s,e){let t;return e&&(t=e.rightHanded),{type:"Polygon",coordinates:s.getCoordinates(t)}}const Jo="units",my=[1,2,5],as=25.4/.28;class O0 extends ao{constructor(e){e=e||{};const t=document.createElement("div");t.style.pointerEvents="none",super({element:t,render:e.render,target:e.target}),this.on,this.once,this.un;const n=e.className!==void 0?e.className:e.bar?"ol-scale-bar":"ol-scale-line";this.innerElement_=document.createElement("div"),this.innerElement_.className=n+"-inner",this.element.className=n+" "+ks,this.element.appendChild(this.innerElement_),this.viewState_=null,this.minWidth_=e.minWidth!==void 0?e.minWidth:64,this.maxWidth_=e.maxWidth,this.renderedVisible_=!1,this.renderedWidth_=void 0,this.renderedHTML_="",this.addChangeListener(Jo,this.handleUnitsChanged_),this.setUnits(e.units||"metric"),this.scaleBar_=e.bar||!1,this.scaleBarSteps_=e.steps||4,this.scaleBarText_=e.text||!1,this.dpi_=e.dpi||void 0}getUnits(){return this.get(Jo)}handleUnitsChanged_(){this.updateElement_()}setUnits(e){this.set(Jo,e)}setDpi(e){this.dpi_=e}updateElement_(){const e=this.viewState_;if(!e){this.renderedVisible_&&(this.element.style.display="none",this.renderedVisible_=!1);return}const t=e.center,n=e.projection,i=this.getUnits(),r=i=="degrees"?"degrees":"m";let o=Ir(n,e.resolution,t,r);const a=this.minWidth_*(this.dpi_||as)/as,l=this.maxWidth_!==void 0?this.maxWidth_*(this.dpi_||as)/as:void 0;let h=a*o,c="";if(i=="degrees"){const E=Gi.degrees;h*=E,h<E/60?(c="″",o*=3600):h<E?(c="′",o*=60):c="°"}else if(i=="imperial")h<.9144?(c="in",o/=.0254):h<1609.344?(c="ft",o/=.3048):(c="mi",o/=1609.344);else if(i=="nautical")o/=1852,c="NM";else if(i=="metric")h<1e-6?(c="nm",o*=1e9):h<.001?(c="μm",o*=1e6):h<1?(c="mm",o*=1e3):h<1e3?c="m":(c="km",o/=1e3);else if(i=="us")h<.9144?(c="in",o*=39.37):h<1609.344?(c="ft",o/=.30480061):(c="mi",o/=1609.3472);else throw new Error("Invalid units");let u=3*Math.floor(Math.log(a*o)/Math.log(10)),d,f,g,m=0,_,p;for(;;){g=Math.floor(u/3);const E=Math.pow(10,g);if(d=my[(u%3+3)%3]*E,f=Math.round(d/o),isNaN(f)){this.element.style.display="none",this.renderedVisible_=!1;return}if(l!==void 0&&f>=l){d=m,f=_,g=p;break}else if(f>=a)break;m=d,_=f,p=g,++u}const y=this.scaleBar_?this.createScaleBar(f,d,c):d.toFixed(g<0?-g:0)+" "+c;this.renderedHTML_!=y&&(this.innerElement_.innerHTML=y,this.renderedHTML_=y),this.renderedWidth_!=f&&(this.innerElement_.style.width=f+"px",this.renderedWidth_=f),this.renderedVisible_||(this.element.style.display="",this.renderedVisible_=!0)}createScaleBar(e,t,n){const i=this.getScaleForResolution(),r=i<1?Math.round(1/i).toLocaleString()+" : 1":"1 : "+Math.round(i).toLocaleString(),o=this.scaleBarSteps_,a=e/o,l=[this.createMarker("absolute")];for(let c=0;c<o;++c){const u=c%2===0?"ol-scale-singlebar-odd":"ol-scale-singlebar-even";l.push(`<div><div class="ol-scale-singlebar ${u}" style="width: ${a}px;"></div>`+this.createMarker("relative")+(c%2===0||o===2?this.createStepText(c,e,!1,t,n):"")+"</div>")}return l.push(this.createStepText(o,e,!0,t,n)),(this.scaleBarText_?`<div class="ol-scale-text" style="width: ${e}px;">`+r+"</div>":"")+l.join("")}createMarker(e){return`<div class="ol-scale-step-marker" style="position: ${e}; top: ${e==="absolute"?3:-10}px;"></div>`}createStepText(e,t,n,i,r){const a=(e===0?0:Math.round(i/this.scaleBarSteps_*e*100)/100)+(e===0?"":" "+r),l=e===0?-3:t/this.scaleBarSteps_*-1,h=e===0?0:t/this.scaleBarSteps_*2;return`<div class="ol-scale-step-text" style="margin-left: ${l}px;text-align: ${e===0?"left":"center"};min-width: ${h}px;left: ${n?t+"px":"unset"};">`+a+"</div>"}getScaleForResolution(){const e=Ir(this.viewState_.projection,this.viewState_.resolution,this.viewState_.center,"m"),t=this.dpi_||as,n=1e3/25.4;return e*n*t}render(e){const t=e.frameState;t?this.viewState_=t.viewState:this.viewState_=null,this.updateElement_()}}const py={image:["Polygon","Circle","LineString","Image","Text"],hybrid:["Polygon","LineString"],vector:[]},gc={hybrid:["Image","Text","Default"],vector:["Polygon","Circle","LineString","Image","Text","Default"]};class yy extends zu{constructor(e,t){super(e,t),this.boundHandleStyleImageChange_=this.handleStyleImageChange_.bind(this),this.renderedLayerRevision_,this.renderedPixelToCoordinateTransform_=null,this.renderedRotation_,this.renderedOpacity_=1,this.tmpTransform_=Te(),this.tileClipContexts_=null}enqueueTilesForNextExtent(){return this.getLayer().getRenderMode()!=="vector"}drawTile(e,t,n,i,r,o,a,l){this.updateExecutorGroup_(e,t.pixelRatio,t.viewState.projection),this.tileImageNeedsRender_(e)&&this.renderTileImage_(e,t),super.drawTile(e,t,n,i,r,o,a,l)}getTile(e,t,n,i){const r=this.getOrCreateTile(e,t,n,i);if(!r)return null;const o=i.viewState,a=o.resolution,l=i.viewHints,h=this.getLayer().getSource(),c=h.getTileGridForProjection(o.projection),u=!(l[he.ANIMATING]||l[he.INTERACTING]),d=c.getZForResolution(a,h.zDirection)===e;return u&&d?r.wantedResolution=a:r.wantedResolution||(r.wantedResolution=c.getResolution(e)),r}prepareFrame(e){const t=this.getLayer().getRevision();return this.renderedLayerRevision_!==t&&(this.renderedLayerRevision_=t,this.renderedTiles.length=0),super.prepareFrame(e)}updateExecutorGroup_(e,t,n){const i=this.getLayer(),r=i.getRevision(),o=i.getRenderOrder()||null,a=e.wantedResolution,l=e.getReplayState(i);if(!l.dirty&&l.renderedResolution===a&&l.renderedRevision==r&&l.renderedRenderOrder==o)return;const h=i.getSource(),c=!!i.getDeclutter(),u=h.getTileGrid(),f=h.getTileGridForProjection(n).getTileCoordExtent(e.wrappedTileCoord),g=h.getSourceTiles(t,n,e),m=D(i);delete e.hitDetectionImageData[m],e.executorGroups[m]=[],l.dirty=!1;for(let _=0,p=g.length;_<p;++_){const y=g[_];if(y.getState()!=B.LOADED)continue;const E=h.getProjection(),x=y.tileCoord;let T=u.getTileCoordExtent(x);n&&E&&!Yn(n,E)&&(T=dg(T,E,n,32));const R=en(f,T),S=sn(R,i.getRenderBuffer()*a,this.tempExtent),v=Kn(T,R)?null:S,w=new Wu(0,R,a,t),I=Oa(a,t),F=function(A,Z){let G;const H=A.getStyleFunction()||i.getStyleFunction();if(H&&(G=H(A,a)),G){const Q=this.renderFeature(A,I,G,w,c,Z);l.dirty=l.dirty||Q}},L=y.getFeatures();o&&o!==l.renderedRenderOrder&&L.sort(o);for(let A=0,Z=L.length;A<Z;++A){let G=L[A];n&&y.projection&&!Yn(n,y.projection)&&(G=G.clone(),G.getGeometry().applyTransform(Hn(y.projection,n))),(!v||Ee(v,G.getGeometry().getExtent()))&&F.call(this,G,A)}const b=w.finish(),M=i.getRenderMode()!=="vector"&&c&&g.length===1?null:R,K=new Yu(M,a,t,h.getOverlaps(),b,i.getRenderBuffer(),!0);e.executorGroups[m].push(K)}l.renderedRevision=r,l.renderedRenderOrder=o,l.renderedResolution=a}forEachFeatureAtCoordinate(e,t,n,i,r){const o=t.viewState.resolution,a=t.viewState.rotation;n=n??0;const l=this.getLayer(),c=l.getSource().getTileGridForProjection(t.viewState.projection),u=Be([e]);sn(u,o*n,u);const d={},f=function(E,x,T){let R=E.getId();R===void 0&&(R=D(E));const S=d[R];if(S){if(S!==!0&&T<S.distanceSq){if(T===0)return d[R]=!0,r.splice(r.lastIndexOf(S),1),i(E,l,x);S.geometry=x,S.distanceSq=T}}else{if(T===0)return d[R]=!0,i(E,l,x);r.push(d[R]={feature:E,layer:l,geometry:x,distanceSq:T,callback:i})}},g=this.renderedTiles,m=D(l),_=l.getDeclutter(),p=_?t.declutter?.[_]?.all().map(E=>E.value):null;let y;e:for(let E=0,x=g.length;E<x;++E){const T=g[E],R=c.getTileCoordExtent(T.wrappedTileCoord);if(!Ee(R,u))continue;const S=T.executorGroups[m];for(let v=0,w=S.length;v<w;++v)if(y=S[v].forEachFeatureAtCoordinate(e,o,a,n,f,p),y)break e}return y}getFeatures(e){return this.renderedTiles.length===0?Promise.resolve([]):new Promise((t,n)=>{const i=this.getLayer(),r=i.getSource(),o=this.renderedProjection,a=o.getExtent(),l=this.renderedResolution,h=r.getTileGridForProjection(o),c=de(this.renderedPixelToCoordinateTransform_,e.slice()),u=h.getTileCoordForCoordAndResolution(c,l).toString(),d=this.renderedTiles.find(E=>E.tileCoord.toString()===u&&E.getState()===B.LOADED);if(!d||d.loadingSourceTiles>0){t([]);return}r.getWrapX()&&o.canWrapX()&&!pn(a,h.getTileCoordExtent(d.tileCoord))&&el(c,o);const f=D(i),g=h.getTileCoordExtent(d.wrappedTileCoord),m=An(g),_=[(c[0]-m[0])/l,(m[1]-c[1])/l],p=d.getSourceTiles().reduce((E,x)=>E.concat(x.getFeatures()),[]);let y=d.hitDetectionImageData[f];if(!y){const E=$e(h.getTileSize(h.getZForResolution(l,r.zDirection))),x=this.renderedRotation_,T=[this.getRenderTransform(h.getTileCoordCenter(d.wrappedTileCoord),l,0,st,E[0]*st,E[1]*st,0)];y=ju(E,T,p,i.getStyleFunction(),h.getTileCoordExtent(d.wrappedTileCoord),d.getReplayState(i).renderedResolution,x),d.hitDetectionImageData[f]=y}t(Vu(_,p,y))})}getFeaturesInExtent(e){const t=[],n=this.getTileCache();if(n.getCount()===0)return t;const r=this.getLayer().getSource().getTileGridForProjection(this.frameState.viewState.projection),o=r.getZForResolution(this.renderedResolution),a={};return n.forEach(l=>{if(l.tileCoord[0]!==o||l.getState()!==B.LOADED)return;const h=l.getSourceTiles();for(let c=0,u=h.length;c<u;++c){const d=h[c],f=d.getKey();if(f in a)continue;a[f]=!0;const g=d.tileCoord;if(Ee(e,r.getTileCoordExtent(g))){const m=d.getFeatures();if(m)for(let _=0,p=m.length;_<p;++_){const y=m[_],E=y.getGeometry();Ee(e,E.getExtent())&&t.push(y)}}}}),t}handleFontsChanged(){const e=this.getLayer();e.getVisible()&&this.renderedLayerRevision_!==void 0&&e.changed()}handleStyleImageChange_(e){this.renderIfReadyAndVisible()}renderDeclutter(e,t){const n=this.context,i=n.globalAlpha;n.globalAlpha=t.opacity;const r=e.viewHints,o=!(r[he.ANIMATING]||r[he.INTERACTING]),a=[this.context.canvas.width,this.context.canvas.height],l=this.getLayer().getDeclutter(),h=l?e.declutter?.[l]:void 0,c=D(this.getLayer()),u=this.renderedTiles;for(let d=0,f=u.length;d<f;++d){const g=u[d],m=g.executorGroups[c];if(m)for(let _=m.length-1;_>=0;--_)m[_].execute(this.context,a,this.getTileRenderTransform(g,e),e.viewState.rotation,o,Br,h)}n.globalAlpha=i}renderDeferredInternal(e){const t=this.renderedTiles,n=D(this.getLayer()),i=t.reduce((l,h,c)=>(h.executorGroups[n].forEach(u=>l.push({executorGroup:u,index:c})),l),[]),r=i.map(({executorGroup:l})=>l.getDeferredZIndexContexts()),o={};for(let l=0,h=i.length;l<h;++l){const c=i[l].executorGroup.getDeferredZIndexContexts();for(const u in c)o[u]=!0}Object.keys(o).map(Number).sort(Ot).forEach(l=>{r.forEach((h,c)=>{h[l]&&(h[l].forEach(u=>{const{executorGroup:d,index:f}=i[c],g=d.getRenderedContext(),m=g.globalAlpha;g.globalAlpha=this.renderedOpacity_;const _=this.tileClipContexts_[f];_&&_.draw(g),u.draw(g),_&&g.restore(),g.globalAlpha=m,u.clear()}),h[l].length=0)})})}getTileRenderTransform(e,t){const n=t.pixelRatio,i=t.viewState,r=i.center,o=i.resolution,a=i.rotation,l=t.size,h=Math.round(l[0]*n),c=Math.round(l[1]*n),d=this.getLayer().getSource().getTileGridForProjection(t.viewState.projection),f=e.tileCoord,g=d.getTileCoordExtent(e.wrappedTileCoord),m=d.getTileCoordExtent(f,this.tempExtent)[0]-g[0];return no(Io(this.inversePixelTransform.slice(),1/n,1/n),this.getRenderTransform(r,o,a,n,h,c,m))}postRender(e,t){const n=t.viewHints,i=!(n[he.ANIMATING]||n[he.INTERACTING]);this.renderedPixelToCoordinateTransform_=t.pixelToCoordinateTransform.slice(),this.renderedRotation_=t.viewState.rotation,this.renderedOpacity_=t.layerStatesArray[t.layerIndex].opacity;const r=this.getLayer(),o=r.getRenderMode(),a=e.globalAlpha;e.globalAlpha=this.renderedOpacity_;const l=r.getDeclutter(),h=l?gc[o].filter(T=>!Br.includes(T)):gc[o],c=t.viewState,u=c.rotation,d=r.getSource(),g=d.getTileGridForProjection(c.projection).getZForResolution(c.resolution,d.zDirection),m=this.renderedTiles,_=[],p=[],y=[],E=D(r);let x=!0;for(let T=m.length-1;T>=0;--T){const R=m[T];x=x&&!R.getReplayState(r).dirty;const S=R.executorGroups[E].filter(M=>M.hasExecutors(h));if(S.length===0)continue;const v=this.getTileRenderTransform(R,t),w=R.tileCoord[0];let I=!1;const F=S[0].getClipCoords(v);let L=e,b;if(F){b=new kl,L=b.getContext();for(let M=0,K=_.length;M<K;++M)if(g!==w&&w<p[M]){const A=_[M];Ee([F[0],F[3],F[4],F[7]],[A[0],A[3],A[4],A[7]])&&(I||(L.save(),I=!0),L.beginPath(),L.moveTo(F[0],F[1]),L.lineTo(F[2],F[3]),L.lineTo(F[4],F[5]),L.lineTo(F[6],F[7]),L.moveTo(A[6],A[7]),L.lineTo(A[4],A[5]),L.lineTo(A[2],A[3]),L.lineTo(A[0],A[1]),L.clip())}_.push(F),p.push(w)}for(let M=0,K=S.length;M<K;++M)S[M].execute(e,[e.canvas.width,e.canvas.height],v,u,i,h,t.declutter?.[l]);I&&(L===e?L.restore():y[T]=b)}e.globalAlpha=a,this.ready=x,this.tileClipContexts_=y,t.declutter||this.renderDeferredInternal(t),super.postRender(e,t)}renderFeature(e,t,n,i,r,o){if(!n)return!1;let a=!1;if(Array.isArray(n))for(let l=0,h=n.length;l<h;++l)a=zr(i,e,n[l],t,this.boundHandleStyleImageChange_,void 0,r,o)||a;else a=zr(i,e,n,t,this.boundHandleStyleImageChange_,void 0,r,o);return a}tileImageNeedsRender_(e){const t=this.getLayer();if(t.getRenderMode()==="vector")return!1;const n=e.getReplayState(t),i=t.getRevision(),r=e.wantedResolution;return n.renderedTileResolution!==r||n.renderedTileRevision!==i}renderTileImage_(e,t){const n=this.getLayer(),i=e.getReplayState(n),r=n.getRevision(),o=e.executorGroups[D(n)];i.renderedTileRevision=r;const a=e.wrappedTileCoord,l=a[0],h=n.getSource();let c=t.pixelRatio;const d=t.viewState.projection,f=h.getTileGridForProjection(d),g=f.getResolution(e.tileCoord[0]),m=t.pixelRatio/e.wantedResolution*g,_=f.getResolution(l),p=e.getContext();c=Math.round(Math.max(c,m/c));const y=h.getTilePixelSize(l,c,d);p.canvas.width=y[0],p.canvas.height=y[1];const E=c/m;if(E!==1){const S=Lh(this.tmpTransform_);Io(S,E,E),p.setTransform.apply(p,S)}const x=f.getTileCoordExtent(a,this.tempExtent),T=m/_,R=Lh(this.tmpTransform_);Io(R,T,-T),tu(R,-x[0],-x[3]);for(let S=0,v=o.length;S<v;++S)o[S].execute(p,[p.canvas.width*E,p.canvas.height*E],R,0,!0,py[n.getRenderMode()],null);i.renderedTileResolution=e.wantedResolution}}class N0 extends Ki{constructor(e){e=e||{};const t=Object.assign({},e);delete t.preload;const n=e.cacheSize===void 0?0:e.cacheSize;delete e.cacheSize,delete t.useInterimTilesOnError,super(t),this.on,this.once,this.un,this.cacheSize_=n;const i=e.renderMode||"hybrid";te(i=="hybrid"||i=="vector","`renderMode` must be `'hybrid'` or `'vector'`"),this.renderMode_=i,this.setPreload(e.preload?e.preload:0),this.setUseInterimTilesOnError(e.useInterimTilesOnError!==void 0?e.useInterimTilesOnError:!0),this.getBackground,this.setBackground}createRenderer(){return new yy(this,{cacheSize:this.cacheSize_})}getFeatures(e){return super.getFeatures(e)}getFeaturesInExtent(e){return this.getRenderer().getFeaturesInExtent(e)}getRenderMode(){return this.renderMode_}getPreload(){return this.get(En.PRELOAD)}getUseInterimTilesOnError(){return this.get(En.USE_INTERIM_TILES_ON_ERROR)}setPreload(e){this.set(En.PRELOAD,e)}setUseInterimTilesOnError(e){this.set(En.USE_INTERIM_TILES_ON_ERROR,e)}}function ld(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function Ba(s,e){return s[0]=e[0],s[1]=e[1],s[4]=e[2],s[5]=e[3],s[12]=e[4],s[13]=e[5],s}const Xr=34962,Vl=34963,xy=35044,Qo=35048,Ey=5121,Ty=5123,Cy=5125,hd=5126,_c=["experimental-webgl","webgl","webkit-3d","moz-webgl"];function Ry(s,e){e=Object.assign({preserveDrawingBuffer:!0,antialias:!ff},e);const t=_c.length;for(let n=0;n<t;++n)try{const i=s.getContext(_c[n],e);if(i)return i}catch{}return null}const Sy={STATIC_DRAW:xy};class ea{constructor(e,t){this.array_=null,this.type_=e,te(e===Xr||e===Vl,"A `WebGLArrayBuffer` must either be of type `ELEMENT_ARRAY_BUFFER` or `ARRAY_BUFFER`"),this.usage_=t!==void 0?t:Sy.STATIC_DRAW}ofSize(e){return this.array_=new(ar(this.type_))(e),this}fromArray(e){return this.array_=ar(this.type_).from(e),this}fromArrayBuffer(e){return this.array_=new(ar(this.type_))(e),this}getType(){return this.type_}getArray(){return this.array_}setArray(e){const t=ar(this.type_);if(!(e instanceof t))throw new Error(`Expected ${t}`);this.array_=e}getUsage(){return this.usage_}getSize(){return this.array_?this.array_.length:0}}function ar(s){switch(s){case Xr:return Float32Array;case Vl:return Uint32Array;default:return Float32Array}}const lr={LOST:"webglcontextlost",RESTORED:"webglcontextrestored"},vy=`
|
||
precision mediump float;
|
||
|
||
attribute vec2 a_position;
|
||
varying vec2 v_texCoord;
|
||
varying vec2 v_screenCoord;
|
||
|
||
uniform vec2 u_screenSize;
|
||
|
||
void main() {
|
||
v_texCoord = a_position * 0.5 + 0.5;
|
||
v_screenCoord = v_texCoord * u_screenSize;
|
||
gl_Position = vec4(a_position, 0.0, 1.0);
|
||
}
|
||
`,wy=`
|
||
precision mediump float;
|
||
|
||
uniform sampler2D u_image;
|
||
uniform float u_opacity;
|
||
|
||
varying vec2 v_texCoord;
|
||
|
||
void main() {
|
||
gl_FragColor = texture2D(u_image, v_texCoord) * u_opacity;
|
||
}
|
||
`;class mc{constructor(e){this.gl_=e.webGlContext;const t=this.gl_;this.scaleRatio_=e.scaleRatio||1,this.renderTargetTexture_=t.createTexture(),this.renderTargetTextureSize_=null,this.frameBuffer_=t.createFramebuffer(),this.depthBuffer_=t.createRenderbuffer();const n=t.createShader(t.VERTEX_SHADER);t.shaderSource(n,e.vertexShader||vy),t.compileShader(n);const i=t.createShader(t.FRAGMENT_SHADER);t.shaderSource(i,e.fragmentShader||wy),t.compileShader(i),this.renderTargetProgram_=t.createProgram(),t.attachShader(this.renderTargetProgram_,n),t.attachShader(this.renderTargetProgram_,i),t.linkProgram(this.renderTargetProgram_),this.renderTargetVerticesBuffer_=t.createBuffer();const r=[-1,-1,1,-1,-1,1,1,-1,1,1,-1,1];t.bindBuffer(t.ARRAY_BUFFER,this.renderTargetVerticesBuffer_),t.bufferData(t.ARRAY_BUFFER,new Float32Array(r),t.STATIC_DRAW),this.renderTargetAttribLocation_=t.getAttribLocation(this.renderTargetProgram_,"a_position"),this.renderTargetUniformLocation_=t.getUniformLocation(this.renderTargetProgram_,"u_screenSize"),this.renderTargetOpacityLocation_=t.getUniformLocation(this.renderTargetProgram_,"u_opacity"),this.renderTargetTextureLocation_=t.getUniformLocation(this.renderTargetProgram_,"u_image"),this.uniforms_=[],e.uniforms&&Object.keys(e.uniforms).forEach(o=>{this.uniforms_.push({value:e.uniforms[o],location:t.getUniformLocation(this.renderTargetProgram_,o)})})}getRenderTargetTexture(){return this.renderTargetTexture_}getGL(){return this.gl_}init(e){const t=this.getGL(),n=[t.drawingBufferWidth*this.scaleRatio_,t.drawingBufferHeight*this.scaleRatio_];if(t.bindFramebuffer(t.FRAMEBUFFER,this.getFrameBuffer()),t.bindRenderbuffer(t.RENDERBUFFER,this.getDepthBuffer()),t.viewport(0,0,n[0],n[1]),!this.renderTargetTextureSize_||this.renderTargetTextureSize_[0]!==n[0]||this.renderTargetTextureSize_[1]!==n[1]){this.renderTargetTextureSize_=n;const i=0,r=t.RGBA,o=0,a=t.RGBA,l=t.UNSIGNED_BYTE,h=null;t.bindTexture(t.TEXTURE_2D,this.renderTargetTexture_),t.texImage2D(t.TEXTURE_2D,i,r,n[0],n[1],o,a,l,h),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,this.renderTargetTexture_,0),t.renderbufferStorage(t.RENDERBUFFER,t.DEPTH_COMPONENT16,n[0],n[1]),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.RENDERBUFFER,this.depthBuffer_)}}apply(e,t,n,i){const r=this.getGL(),o=e.size;if(r.bindFramebuffer(r.FRAMEBUFFER,t?t.getFrameBuffer():null),r.activeTexture(r.TEXTURE0),r.bindTexture(r.TEXTURE_2D,this.renderTargetTexture_),!t){const l=D(r.canvas);if(!e.renderTargets[l]){const h=r.getContextAttributes();h&&h.preserveDrawingBuffer&&(r.clearColor(0,0,0,0),r.clearDepth(1),r.clear(r.COLOR_BUFFER_BIT|r.DEPTH_BUFFER_BIT)),e.renderTargets[l]=!0}}r.disable(r.DEPTH_TEST),r.enable(r.BLEND),r.blendFunc(r.ONE,r.ONE_MINUS_SRC_ALPHA),r.viewport(0,0,r.drawingBufferWidth,r.drawingBufferHeight),r.bindBuffer(r.ARRAY_BUFFER,this.renderTargetVerticesBuffer_),r.useProgram(this.renderTargetProgram_),r.enableVertexAttribArray(this.renderTargetAttribLocation_),r.vertexAttribPointer(this.renderTargetAttribLocation_,2,r.FLOAT,!1,0,0),r.uniform2f(this.renderTargetUniformLocation_,o[0],o[1]),r.uniform1i(this.renderTargetTextureLocation_,0);const a=e.layerStatesArray[e.layerIndex].opacity;r.uniform1f(this.renderTargetOpacityLocation_,a),this.applyUniforms(e),n&&n(r,e),r.drawArrays(r.TRIANGLES,0,6),i&&i(r,e)}getFrameBuffer(){return this.frameBuffer_}getDepthBuffer(){return this.depthBuffer_}applyUniforms(e){const t=this.getGL();let n,i=1;this.uniforms_.forEach(function(r){if(n=typeof r.value=="function"?r.value(e):r.value,n instanceof HTMLCanvasElement||n instanceof ImageData)r.texture||(r.texture=t.createTexture()),t.activeTexture(t[`TEXTURE${i}`]),t.bindTexture(t.TEXTURE_2D,r.texture),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),n instanceof ImageData?t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,n.width,n.height,0,t.UNSIGNED_BYTE,new Uint8Array(n.data)):t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,n),t.uniform1i(r.location,i++);else if(Array.isArray(n))switch(n.length){case 2:t.uniform2f(r.location,n[0],n[1]);return;case 3:t.uniform3f(r.location,n[0],n[1],n[2]);return;case 4:t.uniform4f(r.location,n[0],n[1],n[2],n[3]);return;default:return}else typeof n=="number"&&t.uniform1f(r.location,n)})}}const jt={PROJECTION_MATRIX:"u_projectionMatrix",SCREEN_TO_WORLD_MATRIX:"u_screenToWorldMatrix",TIME:"u_time",ZOOM:"u_zoom",RESOLUTION:"u_resolution",ROTATION:"u_rotation",VIEWPORT_SIZE_PX:"u_viewportSizePx",PIXEL_RATIO:"u_pixelRatio",HIT_DETECTION:"u_hitDetection"},De={UNSIGNED_BYTE:Ey,UNSIGNED_SHORT:Ty,UNSIGNED_INT:Cy,FLOAT:hd},Wr={};function pc(s){return"shared/"+s}let yc=0;function Py(){const s="unique/"+yc;return yc+=1,s}function Iy(s){let e=Wr[s];if(!e){const t=document.createElement("canvas");t.width=1,t.height=1,t.style.position="absolute",t.style.left="0",e={users:0,context:Ry(t)},Wr[s]=e}return e.users+=1,e.context}function Ly(s){const e=Wr[s];if(!e||(e.users-=1,e.users>0))return;const t=e.context,n=t.getExtension("WEBGL_lose_context");n&&n.loseContext();const i=t.canvas;i.width=1,i.height=1,delete Wr[s]}class Ay extends bs{constructor(e){super(),e=e||{},this.boundHandleWebGLContextLost_=this.handleWebGLContextLost.bind(this),this.boundHandleWebGLContextRestored_=this.handleWebGLContextRestored.bind(this),this.canvasCacheKey_=e.canvasCacheKey?pc(e.canvasCacheKey):Py(),this.gl_=Iy(this.canvasCacheKey_),this.bufferCache_={},this.extensionCache_={},this.currentProgram_=null,this.needsToBeRecreated_=!1;const t=this.gl_.canvas;t.addEventListener(lr.LOST,this.boundHandleWebGLContextLost_),t.addEventListener(lr.RESTORED,this.boundHandleWebGLContextRestored_),this.offsetRotateMatrix_=Te(),this.offsetScaleMatrix_=Te(),this.tmpMat4_=ld(),this.uniformLocationsByProgram_={},this.attribLocationsByProgram_={},this.uniforms_=[],e.uniforms&&this.setUniforms(e.uniforms),this.postProcessPasses_=e.postProcesses?e.postProcesses.map(n=>new mc({webGlContext:this.gl_,scaleRatio:n.scaleRatio,vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,uniforms:n.uniforms})):[new mc({webGlContext:this.gl_})],this.shaderCompileErrors_=null,this.startTime_=Date.now(),this.maxAttributeCount_=this.gl_.getParameter(this.gl_.MAX_VERTEX_ATTRIBS)}setUniforms(e){this.uniforms_=[],this.addUniforms(e)}addUniforms(e){for(const t in e)this.uniforms_.push({name:t,value:e[t]})}canvasCacheKeyMatches(e){return this.canvasCacheKey_===pc(e)}getExtension(e){if(e in this.extensionCache_)return this.extensionCache_[e];const t=this.gl_.getExtension(e);return this.extensionCache_[e]=t,t}getInstancedRenderingExtension_(){const e=this.getExtension("ANGLE_instanced_arrays");return te(!!e,"WebGL extension 'ANGLE_instanced_arrays' is required for vector rendering"),e}bindBuffer(e){const t=this.gl_,n=D(e);let i=this.bufferCache_[n];if(!i){const r=t.createBuffer();i={buffer:e,webGlBuffer:r},this.bufferCache_[n]=i}t.bindBuffer(e.getType(),i.webGlBuffer)}flushBufferData(e){const t=this.gl_;this.bindBuffer(e),t.bufferData(e.getType(),e.getArray(),e.getUsage())}deleteBuffer(e){const t=D(e);delete this.bufferCache_[t]}disposeInternal(){const e=this.gl_.canvas;e.removeEventListener(lr.LOST,this.boundHandleWebGLContextLost_),e.removeEventListener(lr.RESTORED,this.boundHandleWebGLContextRestored_),Ly(this.canvasCacheKey_),delete this.gl_}prepareDraw(e,t,n){const i=this.gl_,r=this.getCanvas(),o=e.size,a=e.pixelRatio;(r.width!==o[0]*a||r.height!==o[1]*a)&&(r.width=o[0]*a,r.height=o[1]*a,r.style.width=o[0]+"px",r.style.height=o[1]+"px");for(let l=this.postProcessPasses_.length-1;l>=0;l--)this.postProcessPasses_[l].init(e);i.bindTexture(i.TEXTURE_2D,null),i.clearColor(0,0,0,0),i.depthRange(0,1),i.clearDepth(1),i.clear(i.COLOR_BUFFER_BIT|i.DEPTH_BUFFER_BIT),i.enable(i.BLEND),i.blendFunc(i.ONE,t?i.ZERO:i.ONE_MINUS_SRC_ALPHA),n?(i.enable(i.DEPTH_TEST),i.depthFunc(i.LEQUAL)):i.disable(i.DEPTH_TEST)}bindFrameBuffer(e,t){const n=this.getGL();n.bindFramebuffer(n.FRAMEBUFFER,e),t&&n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,t,0)}bindInitialFrameBuffer(){const e=this.getGL(),t=this.postProcessPasses_[0].getFrameBuffer();e.bindFramebuffer(e.FRAMEBUFFER,t);const n=this.postProcessPasses_[0].getRenderTargetTexture();e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,n,0)}bindTexture(e,t,n){const i=this.gl_;i.activeTexture(i.TEXTURE0+t),i.bindTexture(i.TEXTURE_2D,e),i.uniform1i(this.getUniformLocation(n),t)}bindAttribute(e,t,n){const i=this.getGL();this.bindBuffer(e);const r=this.getAttributeLocation(t);i.enableVertexAttribArray(r),i.vertexAttribPointer(r,n,i.FLOAT,!1,0,0)}prepareDrawToRenderTarget(e,t,n,i){const r=this.gl_,o=t.getSize();r.bindFramebuffer(r.FRAMEBUFFER,t.getFramebuffer()),r.bindRenderbuffer(r.RENDERBUFFER,t.getDepthbuffer()),r.viewport(0,0,o[0],o[1]),r.bindTexture(r.TEXTURE_2D,t.getTexture()),r.clearColor(0,0,0,0),r.depthRange(0,1),r.clearDepth(1),r.clear(r.COLOR_BUFFER_BIT|r.DEPTH_BUFFER_BIT),r.enable(r.BLEND),r.blendFunc(r.ONE,n?r.ZERO:r.ONE_MINUS_SRC_ALPHA),i?(r.enable(r.DEPTH_TEST),r.depthFunc(r.LEQUAL)):r.disable(r.DEPTH_TEST)}drawElements(e,t){const n=this.gl_;this.getExtension("OES_element_index_uint");const i=n.UNSIGNED_INT,r=4,o=t-e,a=e*r;n.drawElements(n.TRIANGLES,o,i,a)}drawElementsInstanced(e,t,n){const i=this.gl_;this.getExtension("OES_element_index_uint");const r=this.getInstancedRenderingExtension_(),o=i.UNSIGNED_INT,a=4,l=t-e,h=e*a;r.drawElementsInstancedANGLE(i.TRIANGLES,l,o,h,n);for(let c=0;c<this.maxAttributeCount_;c++)r.vertexAttribDivisorANGLE(c,0)}finalizeDraw(e,t,n){for(let i=0,r=this.postProcessPasses_.length;i<r;i++)i===r-1?this.postProcessPasses_[i].apply(e,null,t,n):this.postProcessPasses_[i].apply(e,this.postProcessPasses_[i+1])}getCanvas(){return this.gl_.canvas}getGL(){return this.gl_}applyFrameState(e){const t=e.size,n=e.viewState.rotation,i=e.pixelRatio;this.setUniformFloatValue(jt.TIME,(Date.now()-this.startTime_)*.001),this.setUniformFloatValue(jt.ZOOM,e.viewState.zoom),this.setUniformFloatValue(jt.RESOLUTION,e.viewState.resolution),this.setUniformFloatValue(jt.PIXEL_RATIO,i),this.setUniformFloatVec2(jt.VIEWPORT_SIZE_PX,[t[0],t[1]]),this.setUniformFloatValue(jt.ROTATION,n)}applyHitDetectionUniform(e){const t=this.getUniformLocation(jt.HIT_DETECTION);this.getGL().uniform1i(t,e?1:0),e&&this.setUniformFloatValue(jt.PIXEL_RATIO,.5)}applyUniforms(e){const t=this.gl_;let n,i=0;this.uniforms_.forEach(r=>{if(n=typeof r.value=="function"?r.value(e):r.value,n instanceof HTMLCanvasElement||n instanceof HTMLImageElement||n instanceof ImageData||n instanceof WebGLTexture){n instanceof WebGLTexture&&!r.texture?(r.prevValue=void 0,r.texture=n):r.texture||(r.prevValue=void 0,r.texture=t.createTexture()),this.bindTexture(r.texture,i,r.name),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE);const o=!(n instanceof HTMLImageElement)||n.complete;!(n instanceof WebGLTexture)&&o&&r.prevValue!==n&&(r.prevValue=n,t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,n)),i++}else if(Array.isArray(n)&&n.length===6)this.setUniformMatrixValue(r.name,Ba(this.tmpMat4_,n));else if(Array.isArray(n)&&n.length<=4)switch(n.length){case 2:t.uniform2f(this.getUniformLocation(r.name),n[0],n[1]);return;case 3:t.uniform3f(this.getUniformLocation(r.name),n[0],n[1],n[2]);return;case 4:t.uniform4f(this.getUniformLocation(r.name),n[0],n[1],n[2],n[3]);return;default:return}else typeof n=="number"&&t.uniform1f(this.getUniformLocation(r.name),n)})}useProgram(e,t){this.disableAllAttributes_(),this.gl_.useProgram(e),this.currentProgram_=e,t&&(this.applyFrameState(t),this.applyUniforms(t))}compileShader(e,t){const n=this.gl_,i=n.createShader(t);return n.shaderSource(i,e),n.compileShader(i),i}getProgram(e,t){const n=this.gl_,i=this.compileShader(e,n.FRAGMENT_SHADER),r=this.compileShader(t,n.VERTEX_SHADER),o=n.createProgram();if(n.attachShader(o,i),n.attachShader(o,r),n.linkProgram(o),!n.getShaderParameter(i,n.COMPILE_STATUS)){const a=`Fragment shader compilation failed: ${n.getShaderInfoLog(i)}`;throw new Error(a)}if(n.deleteShader(i),!n.getShaderParameter(r,n.COMPILE_STATUS)){const a=`Vertex shader compilation failed: ${n.getShaderInfoLog(r)}`;throw new Error(a)}if(n.deleteShader(r),!n.getProgramParameter(o,n.LINK_STATUS)){const a=`GL program linking failed: ${n.getProgramInfoLog(o)}`;throw new Error(a)}return o}getUniformLocation(e){const t=D(this.currentProgram_);return this.uniformLocationsByProgram_[t]===void 0&&(this.uniformLocationsByProgram_[t]={}),this.uniformLocationsByProgram_[t][e]===void 0&&(this.uniformLocationsByProgram_[t][e]=this.gl_.getUniformLocation(this.currentProgram_,e)),this.uniformLocationsByProgram_[t][e]}getAttributeLocation(e){const t=D(this.currentProgram_);return this.attribLocationsByProgram_[t]===void 0&&(this.attribLocationsByProgram_[t]={}),this.attribLocationsByProgram_[t][e]===void 0&&(this.attribLocationsByProgram_[t][e]=this.gl_.getAttribLocation(this.currentProgram_,e)),this.attribLocationsByProgram_[t][e]}makeProjectionTransform(e,t){const n=e.size,i=e.viewState.rotation,r=e.viewState.resolution,o=e.viewState.center;return lt(t,0,0,2/(r*n[0]),2/(r*n[1]),-i,-o[0],-o[1]),t}setUniformFloatValue(e,t){this.gl_.uniform1f(this.getUniformLocation(e),t)}setUniformFloatVec2(e,t){this.gl_.uniform2fv(this.getUniformLocation(e),t)}setUniformFloatVec4(e,t){this.gl_.uniform4fv(this.getUniformLocation(e),t)}setUniformMatrixValue(e,t){this.gl_.uniformMatrix4fv(this.getUniformLocation(e),!1,t)}disableAllAttributes_(){for(let e=0;e<this.maxAttributeCount_;e++)this.gl_.disableVertexAttribArray(e)}enableAttributeArray_(e,t,n,i,r,o){const a=this.getAttributeLocation(e);a<0||(this.gl_.enableVertexAttribArray(a),this.gl_.vertexAttribPointer(a,t,n,!1,i,r),o&&this.getInstancedRenderingExtension_().vertexAttribDivisorANGLE(a,1))}enableAttributes_(e,t){const n=Fy(e);let i=0;for(let r=0;r<e.length;r++){const o=e[r];o.name&&this.enableAttributeArray_(o.name,o.size,o.type||hd,n,i,t),i+=o.size*cd(o.type)}}enableAttributes(e){this.enableAttributes_(e,!1)}enableAttributesInstanced(e){this.enableAttributes_(e,!0)}handleWebGLContextLost(e){Qn(this.bufferCache_),this.currentProgram_=null,e.preventDefault()}handleWebGLContextRestored(){this.needsToBeRecreated_=!0}needsToBeRecreated(){return this.needsToBeRecreated_}createTexture(e,t,n,i){const r=this.gl_;n=n||r.createTexture();const o=i?r.NEAREST:r.LINEAR;r.bindTexture(r.TEXTURE_2D,n),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,o),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,o),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE);const a=0,l=r.RGBA,h=0,c=r.RGBA,u=r.UNSIGNED_BYTE;return t instanceof Uint8Array?r.texImage2D(r.TEXTURE_2D,a,l,e[0],e[1],h,c,u,t):t?r.texImage2D(r.TEXTURE_2D,a,l,c,u,t):r.texImage2D(r.TEXTURE_2D,a,l,e[0],e[1],h,c,u,null),n}}function Fy(s){let e=0;for(let t=0;t<s.length;t++){const n=s[t];e+=n.size*cd(n.type)}return e}function cd(s){switch(s){case De.UNSIGNED_BYTE:return Uint8Array.BYTES_PER_ELEMENT;case De.UNSIGNED_SHORT:return Uint16Array.BYTES_PER_ELEMENT;case De.UNSIGNED_INT:return Uint32Array.BYTES_PER_ELEMENT;case De.FLOAT:default:return Float32Array.BYTES_PER_ELEMENT}}class Zl extends Bu{constructor(e,t){super(e),t=t||{},this.inversePixelTransform_=Te(),this.postProcesses_=t.postProcesses,this.uniforms_=t.uniforms,this.helper,this.onMapChanged_=()=>{this.clearCache(),this.removeHelper()},e.addChangeListener(ae.MAP,this.onMapChanged_),this.dispatchPreComposeEvent=this.dispatchPreComposeEvent.bind(this),this.dispatchPostComposeEvent=this.dispatchPostComposeEvent.bind(this)}dispatchPreComposeEvent(e,t){const n=this.getLayer();if(n.hasListener(Fe.PRECOMPOSE)){const i=new _s(Fe.PRECOMPOSE,void 0,t,e);n.dispatchEvent(i)}}dispatchPostComposeEvent(e,t){const n=this.getLayer();if(n.hasListener(Fe.POSTCOMPOSE)){const i=new _s(Fe.POSTCOMPOSE,void 0,t,e);n.dispatchEvent(i)}}reset(e){this.uniforms_=e.uniforms,this.helper&&this.helper.setUniforms(this.uniforms_)}removeHelper(){this.helper&&(this.helper.dispose(),delete this.helper)}prepareFrame(e){if(this.getLayer().getRenderSource()){let t=!0,n=-1,i;for(let o=0,a=e.layerStatesArray.length;o<a;o++){const l=e.layerStatesArray[o].layer,h=l.getRenderer();if(!(h instanceof Zl)){t=!0;continue}const c=l.getClassName();if((t||c!==i)&&(n+=1,t=!1),i=c,h===this)break}const r="map/"+e.mapId+"/group/"+n;(!this.helper||!this.helper.canvasCacheKeyMatches(r)||this.helper.needsToBeRecreated())&&(this.removeHelper(),this.helper=new Ay({postProcesses:this.postProcesses_,uniforms:this.uniforms_,canvasCacheKey:r}),i&&(this.helper.getCanvas().className=i),this.afterHelperCreated())}return this.prepareFrameInternal(e)}afterHelperCreated(){}prepareFrameInternal(e){return!0}clearCache(){}disposeInternal(){this.clearCache(),this.removeHelper(),this.getLayer()?.removeChangeListener(ae.MAP,this.onMapChanged_),super.disposeInternal()}dispatchRenderEvent_(e,t,n){const i=this.getLayer();if(i.hasListener(e)){lt(this.inversePixelTransform_,0,0,n.pixelRatio,-n.pixelRatio,0,0,-n.size[1]);const r=new _s(e,this.inversePixelTransform_,n,t);i.dispatchEvent(r)}}preRender(e,t){this.dispatchRenderEvent_(Fe.PRERENDER,e,t)}postRender(e,t){this.dispatchRenderEvent_(Fe.POSTRENDER,e,t)}}const ta={TILE_TEXTURE_ARRAY:"u_tileTextures",TEXTURE_PIXEL_WIDTH:"u_texturePixelWidth",TEXTURE_PIXEL_HEIGHT:"u_texturePixelHeight"};class by{constructor(e,t){this.name=e,this.data=t,this.texture_=null}getTexture(e){if(!this.texture_){const t=e.createTexture();e.bindTexture(e.TEXTURE_2D,t),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.NEAREST),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,this.data.length/4,1,0,e.RGBA,e.UNSIGNED_BYTE,this.data),this.texture_=t}return this.texture_}delete(e){this.texture_&&e.deleteTexture(this.texture_),this.texture_=null}}function My(s,e){return`operator_${s}_${Object.keys(e.functions).length}`}function vn(s){const e=s.toString();return e.includes(".")?e:e+".0"}function Kl(s){if(s.length<2||s.length>4)throw new Error("`formatArray` can only output `vec2`, `vec3` or `vec4` arrays.");return`vec${s.length}(${s.map(vn).join(", ")})`}function Tr(s){const e=Et(s),t=e.length>3?e[3]:1;return Kl([e[0]/255,e[1]/255,e[2]/255,t])}function Dy(s){const e=$e(s);return Kl(e)}const na={};let Oy=0;function Fs(s){return s in na||(na[s]=Oy++),na[s]}function Ht(s){return vn(Fs(s))}function Hl(s){return"u_var_"+s}function ud(){return{variables:{},properties:{},functions:{},bandCount:0,featureId:!1,geometryType:!1}}const ia="getBandValue",Ny="u_paletteTextures",dd="featureId",fd="geometryType",za=-9999999;function Gy(s,e,t,n){const i=Me(s,e,t);return ql(i,e,n)}function ie(s){return(e,t,n)=>{const i=t.args.length,r=new Array(i);for(let o=0;o<i;++o)r[o]=ql(t.args[o],n,e);return s(r,e)}}const ky={[C.Get]:(s,e)=>{const n=e.args[0].value;n in s.properties||(s.properties[n]={name:n,type:e.type});let r="a_prop_"+n;return Mt(e.type,Se)&&(r=`(${r} > 0.0)`),r},[C.Id]:s=>(s.featureId=!0,"a_"+dd),[C.GeometryType]:s=>(s.geometryType=!0,"a_"+fd),[C.LineMetric]:()=>"currentLineMetric",[C.Var]:(s,e)=>{const n=e.args[0].value;n in s.variables||(s.variables[n]={name:n,type:e.type});let r=Hl(n);return Mt(e.type,Se)&&(r=`(${r} > 0.0)`),r},[C.Has]:(s,e)=>{const n=e.args[0].value;return n in s.properties||(s.properties[n]={name:n,type:e.type}),`(a_prop_${n} != ${vn(za)})`},[C.Resolution]:()=>"u_resolution",[C.Zoom]:()=>"u_zoom",[C.Time]:()=>"u_time",[C.Any]:ie(s=>`(${s.join(" || ")})`),[C.All]:ie(s=>`(${s.join(" && ")})`),[C.Not]:ie(([s])=>`(!${s})`),[C.Equal]:ie(([s,e])=>`(${s} == ${e})`),[C.NotEqual]:ie(([s,e])=>`(${s} != ${e})`),[C.GreaterThan]:ie(([s,e])=>`(${s} > ${e})`),[C.GreaterThanOrEqualTo]:ie(([s,e])=>`(${s} >= ${e})`),[C.LessThan]:ie(([s,e])=>`(${s} < ${e})`),[C.LessThanOrEqualTo]:ie(([s,e])=>`(${s} <= ${e})`),[C.Multiply]:ie(s=>`(${s.join(" * ")})`),[C.Divide]:ie(([s,e])=>`(${s} / ${e})`),[C.Add]:ie(s=>`(${s.join(" + ")})`),[C.Subtract]:ie(([s,e])=>`(${s} - ${e})`),[C.Clamp]:ie(([s,e,t])=>`clamp(${s}, ${e}, ${t})`),[C.Mod]:ie(([s,e])=>`mod(${s}, ${e})`),[C.Pow]:ie(([s,e])=>`pow(${s}, ${e})`),[C.Abs]:ie(([s])=>`abs(${s})`),[C.Floor]:ie(([s])=>`floor(${s})`),[C.Ceil]:ie(([s])=>`ceil(${s})`),[C.Round]:ie(([s])=>`floor(${s} + 0.5)`),[C.Sin]:ie(([s])=>`sin(${s})`),[C.Cos]:ie(([s])=>`cos(${s})`),[C.Atan]:ie(([s,e])=>e!==void 0?`atan(${s}, ${e})`:`atan(${s})`),[C.Sqrt]:ie(([s])=>`sqrt(${s})`),[C.Match]:ie(s=>{const e=s[0],t=s[s.length-1];let n=null;for(let i=s.length-3;i>=1;i-=2){const r=s[i],o=s[i+1];n=`(${e} == ${r} ? ${o} : ${n||t})`}return n}),[C.Between]:ie(([s,e,t])=>`(${s} >= ${e} && ${s} <= ${t})`),[C.Interpolate]:ie(([s,e,...t])=>{let n="";for(let i=0;i<t.length-2;i+=2){const r=t[i],o=n||t[i+1],a=t[i+2],l=t[i+3];let h;s===vn(1)?h=`(${e} - ${r}) / (${a} - ${r})`:h=`(pow(${s}, (${e} - ${r})) - 1.0) / (pow(${s}, (${a} - ${r})) - 1.0)`,n=`mix(${o}, ${l}, clamp(${h}, 0.0, 1.0))`}return n}),[C.Case]:ie(s=>{const e=s[s.length-1];let t=null;for(let n=s.length-3;n>=0;n-=2){const i=s[n],r=s[n+1];t=`(${i} ? ${r} : ${t||e})`}return t}),[C.In]:ie(([s,...e],t)=>{const n=My("in",t),i=[];for(let r=0;r<e.length;r+=1)i.push(` if (inputValue == ${e[r]}) { return true; }`);return t.functions[n]=`bool ${n}(float inputValue) {
|
||
${i.join(`
|
||
`)}
|
||
return false;
|
||
}`,`${n}(${s})`}),[C.Array]:ie(s=>`vec${s.length}(${s.join(", ")})`),[C.Color]:ie(s=>{if(s.length===1)return`vec4(vec3(${s[0]} / 255.0), 1.0)`;if(s.length===2)return`vec4(vec3(${s[0]} / 255.0), ${s[1]})`;const e=s.slice(0,3).map(n=>`${n} / 255.0`);if(s.length===3)return`vec4(${e.join(", ")}, 1.0)`;const t=s[3];return`vec4(${e.join(", ")}, ${t})`}),[C.Band]:ie(([s,e,t],n)=>{if(!(ia in n.functions)){let i="";const r=n.bandCount||1;for(let o=0;o<r;o++){const a=Math.floor(o/4);let l=o%4;o===r-1&&l===1&&(l=3);const h=`${ta.TILE_TEXTURE_ARRAY}[${a}]`;i+=` if (band == ${o+1}.0) {
|
||
return texture2D(${h}, v_textureCoord + vec2(dx, dy))[${l}];
|
||
}
|
||
`}n.functions[ia]=`float getBandValue(float band, float xOffset, float yOffset) {
|
||
float dx = xOffset / ${ta.TEXTURE_PIXEL_WIDTH};
|
||
float dy = yOffset / ${ta.TEXTURE_PIXEL_HEIGHT};
|
||
${i}
|
||
}`}return`${ia}(${s}, ${e??"0.0"}, ${t??"0.0"})`}),[C.Palette]:(s,e)=>{const[t,...n]=e.args,i=n.length,r=new Uint8Array(i*4);for(let h=0;h<n.length;h++){const c=n[h].value,u=Et(c),d=h*4;r[d]=u[0],r[d+1]=u[1],r[d+2]=u[2],r[d+3]=u[3]*255}s.paletteTextures||(s.paletteTextures=[]);const o=`${Ny}[${s.paletteTextures.length}]`,a=new by(o,r);s.paletteTextures.push(a);const l=ql(t,N,s);return`texture2D(${o}, vec2((${l} + 0.5) / ${i}.0, 0.5))`}};function ql(s,e,t){if(s instanceof Su){const n=ky[s.operator];if(n===void 0)throw new Error(`No compiler defined for this operator: ${JSON.stringify(s.operator)}`);return n(t,s,e)}if((s.type&N)>0)return vn(s.value);if((s.type&Se)>0)return s.value.toString();if((s.type&Pe)>0)return Ht(s.value.toString());if((s.type&ge)>0)return Tr(s.value);if((s.type&et)>0)return Kl(s.value);if((s.type&_t)>0)return Dy(s.value);throw new Error(`Unexpected expression ${s.value} (expected type ${wi(e)})`)}function Uy(){return{"fill-color":"rgba(255,255,255,0.4)","stroke-color":"#3399CC","stroke-width":1.25,"circle-radius":5,"circle-fill-color":"rgba(255,255,255,0.4)","circle-stroke-width":1.25,"circle-stroke-color":"#3399CC"}}const xc=.985;function j(s,e,t){const n=bl();return Gy(e,t,n,s)}function By(s){const e=Et(s),t=e[0]*256,n=e[1],i=e[2]*256,r=Math.round(e[3]*255);return[t+n,i+r]}const zy=`vec4 unpackColor(vec2 packedColor) {
|
||
return vec4(
|
||
min(floor(packedColor[0] / 256.0) / 255.0, 1.0),
|
||
min(mod(packedColor[0], 256.0) / 255.0, 1.0),
|
||
min(floor(packedColor[1] / 256.0) / 255.0, 1.0),
|
||
min(mod(packedColor[1], 256.0) / 255.0, 1.0)
|
||
);
|
||
}`;function Jl(s){return s===ge||s===_t?2:s===et?4:1}function $a(s){const e=Jl(s);return e>1?`vec${e}`:"float"}function gd(s,e){for(const t in e.variables){const n=e.variables[t],i=Hl(n.name);let r=$a(n.type);n.type===ge&&(r="vec4"),s.addUniform(i,r)}for(const t in e.properties){const n=e.properties[t],i=$a(n.type),r=`a_prop_${n.name}`;n.type===ge?s.addAttribute(r,i,`unpackColor(${r})`,"vec4"):s.addAttribute(r,i)}for(const t in e.functions)s.addVertexShaderFunction(e.functions[t]),s.addFragmentShaderFunction(e.functions[t])}function _d(s,e){const t={};for(const n in s.variables){const i=s.variables[n],r=Hl(i.name);t[r]=()=>{const o=e[i.name];if(typeof o=="number")return o;if(typeof o=="boolean")return o?1:0;if(i.type===ge){const a=[...Et(o||"#eee")];return a[0]/=255,a[1]/=255,a[2]/=255,a[3]??=1,a}return typeof o=="string"?Fs(o):o}}return t}function md(s){const e={};for(const t in s.properties){const n=s.properties[t],i=r=>{const o=r.get(n.name);return n.type===ge?By([...Et(o||"#eee")]):typeof o=="string"?Fs(o):typeof o=="boolean"?o?1:0:o};e[`prop_${n.name}`]={size:Jl(n.type),callback:i}}return e}const pi=`#ifdef GL_FRAGMENT_PRECISION_HIGH
|
||
precision highp float;
|
||
#else
|
||
precision mediump float;
|
||
#endif
|
||
uniform mat4 u_projectionMatrix;
|
||
uniform mat4 u_screenToWorldMatrix;
|
||
uniform vec2 u_viewportSizePx;
|
||
uniform float u_pixelRatio;
|
||
uniform float u_globalAlpha;
|
||
uniform float u_time;
|
||
uniform float u_zoom;
|
||
uniform float u_resolution;
|
||
uniform float u_rotation;
|
||
uniform vec4 u_renderExtent;
|
||
uniform vec2 u_patternOrigin;
|
||
uniform float u_depth;
|
||
uniform mediump int u_hitDetection;
|
||
|
||
const float PI = 3.141592653589793238;
|
||
const float TWO_PI = 2.0 * PI;
|
||
float currentLineMetric = 0.; // an actual value will be used in the stroke shaders
|
||
|
||
${zy}
|
||
`,yi=Uy();class pd{constructor(){this.uniforms_=[],this.attributes_=[],this.hasSymbol_=!1,this.symbolSizeExpression_=`vec2(${vn(yi["circle-radius"])} + ${vn(yi["circle-stroke-width"]*.5)})`,this.symbolRotationExpression_="0.0",this.symbolOffsetExpression_="vec2(0.0)",this.symbolColorExpression_=Tr(yi["circle-fill-color"]),this.texCoordExpression_="vec4(0.0, 0.0, 1.0, 1.0)",this.discardExpression_="false",this.symbolRotateWithView_=!1,this.hasStroke_=!1,this.strokeWidthExpression_=vn(yi["stroke-width"]),this.strokeColorExpression_=Tr(yi["stroke-color"]),this.strokeOffsetExpression_="0.",this.strokeCapExpression_=Ht("round"),this.strokeJoinExpression_=Ht("round"),this.strokeMiterLimitExpression_="10.",this.strokeDistanceFieldExpression_="-1000.",this.strokePatternLengthExpression_=null,this.hasFill_=!1,this.fillColorExpression_=Tr(yi["fill-color"]),this.vertexShaderFunctions_=[],this.fragmentShaderFunctions_=[]}addUniform(e,t){return this.uniforms_.push({name:e,type:t}),this}addAttribute(e,t,n,i){return this.attributes_.push({name:e,type:t,varyingName:e.replace(/^a_/,"v_"),varyingType:i??t,varyingExpression:n??e}),this}setSymbolSizeExpression(e){return this.hasSymbol_=!0,this.symbolSizeExpression_=e,this}getSymbolSizeExpression(){return this.symbolSizeExpression_}setSymbolRotationExpression(e){return this.symbolRotationExpression_=e,this}setSymbolOffsetExpression(e){return this.symbolOffsetExpression_=e,this}getSymbolOffsetExpression(){return this.symbolOffsetExpression_}setSymbolColorExpression(e){return this.hasSymbol_=!0,this.symbolColorExpression_=e,this}getSymbolColorExpression(){return this.symbolColorExpression_}setTextureCoordinateExpression(e){return this.texCoordExpression_=e,this}setFragmentDiscardExpression(e){return this.discardExpression_=e,this}getFragmentDiscardExpression(){return this.discardExpression_}setSymbolRotateWithView(e){return this.symbolRotateWithView_=e,this}setStrokeWidthExpression(e){return this.hasStroke_=!0,this.strokeWidthExpression_=e,this}setStrokeColorExpression(e){return this.hasStroke_=!0,this.strokeColorExpression_=e,this}getStrokeColorExpression(){return this.strokeColorExpression_}setStrokeOffsetExpression(e){return this.strokeOffsetExpression_=e,this}setStrokeCapExpression(e){return this.strokeCapExpression_=e,this}setStrokeJoinExpression(e){return this.strokeJoinExpression_=e,this}setStrokeMiterLimitExpression(e){return this.strokeMiterLimitExpression_=e,this}setStrokeDistanceFieldExpression(e){return this.strokeDistanceFieldExpression_=e,this}setStrokePatternLengthExpression(e){return this.strokePatternLengthExpression_=e,this}getStrokePatternLengthExpression(){return this.strokePatternLengthExpression_}setFillColorExpression(e){return this.hasFill_=!0,this.fillColorExpression_=e,this}getFillColorExpression(){return this.fillColorExpression_}addVertexShaderFunction(e){return this.vertexShaderFunctions_.includes(e)?this:(this.vertexShaderFunctions_.push(e),this)}addFragmentShaderFunction(e){return this.fragmentShaderFunctions_.includes(e)?this:(this.fragmentShaderFunctions_.push(e),this)}getSymbolVertexShader(){return this.hasSymbol_?`${pi}
|
||
${this.uniforms_.map(e=>`uniform ${e.type} ${e.name};`).join(`
|
||
`)}
|
||
attribute vec2 a_position;
|
||
attribute vec2 a_localPosition;
|
||
attribute vec2 a_hitColor;
|
||
|
||
varying vec2 v_texCoord;
|
||
varying vec2 v_quadCoord;
|
||
varying vec4 v_hitColor;
|
||
varying vec2 v_centerPx;
|
||
varying float v_angle;
|
||
varying vec2 v_quadSizePx;
|
||
|
||
${this.attributes_.map(e=>`attribute ${e.type} ${e.name};
|
||
varying ${e.varyingType} ${e.varyingName};`).join(`
|
||
`)}
|
||
${this.vertexShaderFunctions_.join(`
|
||
`)}
|
||
vec2 pxToScreen(vec2 coordPx) {
|
||
vec2 scaled = coordPx / u_viewportSizePx / 0.5;
|
||
return scaled;
|
||
}
|
||
|
||
vec2 screenToPx(vec2 coordScreen) {
|
||
return (coordScreen * 0.5 + 0.5) * u_viewportSizePx;
|
||
}
|
||
|
||
void main(void) {
|
||
v_quadSizePx = ${this.symbolSizeExpression_};
|
||
vec2 halfSizePx = v_quadSizePx * 0.5;
|
||
vec2 centerOffsetPx = ${this.symbolOffsetExpression_};
|
||
vec2 offsetPx = centerOffsetPx + a_localPosition * halfSizePx * vec2(1., -1.);
|
||
float angle = ${this.symbolRotationExpression_}${this.symbolRotateWithView_?" + u_rotation":""};
|
||
float c = cos(-angle);
|
||
float s = sin(-angle);
|
||
offsetPx = vec2(c * offsetPx.x - s * offsetPx.y, s * offsetPx.x + c * offsetPx.y);
|
||
vec4 center = u_projectionMatrix * vec4(a_position, 0.0, 1.0);
|
||
gl_Position = center + vec4(pxToScreen(offsetPx), u_depth, 0.);
|
||
vec4 texCoord = ${this.texCoordExpression_};
|
||
float u = mix(texCoord.s, texCoord.p, a_localPosition.x * 0.5 + 0.5);
|
||
float v = mix(texCoord.t, texCoord.q, a_localPosition.y * 0.5 + 0.5);
|
||
v_texCoord = vec2(u, v);
|
||
v_hitColor = unpackColor(a_hitColor);
|
||
v_angle = angle;
|
||
c = cos(-v_angle);
|
||
s = sin(-v_angle);
|
||
centerOffsetPx = vec2(c * centerOffsetPx.x - s * centerOffsetPx.y, s * centerOffsetPx.x + c * centerOffsetPx.y);
|
||
v_centerPx = screenToPx(center.xy) + centerOffsetPx;
|
||
${this.attributes_.map(e=>` ${e.varyingName} = ${e.varyingExpression};`).join(`
|
||
`)}
|
||
}`:null}getSymbolFragmentShader(){return this.hasSymbol_?`${pi}
|
||
${this.uniforms_.map(e=>`uniform ${e.type} ${e.name};`).join(`
|
||
`)}
|
||
varying vec2 v_texCoord;
|
||
varying vec4 v_hitColor;
|
||
varying vec2 v_centerPx;
|
||
varying float v_angle;
|
||
varying vec2 v_quadSizePx;
|
||
${this.attributes_.map(e=>`varying ${e.varyingType} ${e.varyingName};`).join(`
|
||
`)}
|
||
${this.fragmentShaderFunctions_.join(`
|
||
`)}
|
||
|
||
void main(void) {
|
||
${this.attributes_.map(e=>` ${e.varyingType} ${e.name} = ${e.varyingName}; // assign to original attribute name`).join(`
|
||
`)}
|
||
if (${this.discardExpression_}) { discard; }
|
||
vec2 coordsPx = gl_FragCoord.xy / u_pixelRatio - v_centerPx; // relative to center
|
||
float c = cos(v_angle);
|
||
float s = sin(v_angle);
|
||
coordsPx = vec2(c * coordsPx.x - s * coordsPx.y, s * coordsPx.x + c * coordsPx.y);
|
||
gl_FragColor = ${this.symbolColorExpression_};
|
||
gl_FragColor.rgb *= gl_FragColor.a;
|
||
if (u_hitDetection > 0) {
|
||
if (gl_FragColor.a < 0.05) { discard; };
|
||
gl_FragColor = v_hitColor;
|
||
}
|
||
}`:null}getStrokeVertexShader(){return this.hasStroke_?`${pi}
|
||
${this.uniforms_.map(e=>`uniform ${e.type} ${e.name};`).join(`
|
||
`)}
|
||
attribute vec2 a_segmentStart;
|
||
attribute vec2 a_segmentEnd;
|
||
attribute vec2 a_localPosition;
|
||
attribute float a_measureStart;
|
||
attribute float a_measureEnd;
|
||
attribute float a_angleTangentSum;
|
||
attribute float a_distanceLow;
|
||
attribute float a_distanceHigh;
|
||
attribute vec2 a_joinAngles;
|
||
attribute vec2 a_hitColor;
|
||
|
||
varying vec2 v_segmentStartPx;
|
||
varying vec2 v_segmentEndPx;
|
||
varying float v_angleStart;
|
||
varying float v_angleEnd;
|
||
varying float v_width;
|
||
varying vec4 v_hitColor;
|
||
varying float v_distancePx;
|
||
varying float v_measureStart;
|
||
varying float v_measureEnd;
|
||
|
||
${this.attributes_.map(e=>`attribute ${e.type} ${e.name};
|
||
varying ${e.varyingType} ${e.varyingName};`).join(`
|
||
`)}
|
||
${this.vertexShaderFunctions_.join(`
|
||
`)}
|
||
vec2 worldToPx(vec2 worldPos) {
|
||
vec4 screenPos = u_projectionMatrix * vec4(worldPos, 0.0, 1.0);
|
||
return (0.5 * screenPos.xy + 0.5) * u_viewportSizePx;
|
||
}
|
||
|
||
vec4 pxToScreen(vec2 pxPos) {
|
||
vec2 screenPos = 2.0 * pxPos / u_viewportSizePx - 1.0;
|
||
return vec4(screenPos, u_depth, 1.0);
|
||
}
|
||
|
||
bool isCap(float joinAngle) {
|
||
return joinAngle < -0.1;
|
||
}
|
||
|
||
vec2 getJoinOffsetDirection(vec2 normalPx, float joinAngle) {
|
||
float halfAngle = joinAngle / 2.0;
|
||
float c = cos(halfAngle);
|
||
float s = sin(halfAngle);
|
||
vec2 angleBisectorNormal = vec2(s * normalPx.x + c * normalPx.y, -c * normalPx.x + s * normalPx.y);
|
||
float length = 1.0 / s;
|
||
return angleBisectorNormal * length;
|
||
}
|
||
|
||
vec2 getOffsetPoint(vec2 point, vec2 normal, float joinAngle, float offsetPx) {
|
||
// if on a cap or the join angle is too high, offset the line along the segment normal
|
||
if (cos(joinAngle) > 0.998 || isCap(joinAngle)) {
|
||
return point - normal * offsetPx;
|
||
}
|
||
// offset is applied along the inverted normal (positive offset goes "right" relative to line direction)
|
||
return point - getJoinOffsetDirection(normal, joinAngle) * offsetPx;
|
||
}
|
||
|
||
void main(void) {
|
||
v_angleStart = a_joinAngles.x;
|
||
v_angleEnd = a_joinAngles.y;
|
||
float startEndRatio = a_localPosition.x * 0.5 + 0.5;
|
||
currentLineMetric = mix(a_measureStart, a_measureEnd, startEndRatio);
|
||
// we're reading the fractional part while keeping the sign (so -4.12 gives -0.12, 3.45 gives 0.45)
|
||
|
||
float lineWidth = ${this.strokeWidthExpression_};
|
||
float lineOffsetPx = ${this.strokeOffsetExpression_};
|
||
|
||
// compute segment start/end in px with offset
|
||
vec2 segmentStartPx = worldToPx(a_segmentStart);
|
||
vec2 segmentEndPx = worldToPx(a_segmentEnd);
|
||
vec2 tangentPx = normalize(segmentEndPx - segmentStartPx);
|
||
vec2 normalPx = vec2(-tangentPx.y, tangentPx.x);
|
||
segmentStartPx = getOffsetPoint(segmentStartPx, normalPx, v_angleStart, lineOffsetPx),
|
||
segmentEndPx = getOffsetPoint(segmentEndPx, normalPx, v_angleEnd, lineOffsetPx);
|
||
|
||
// compute current vertex position
|
||
float normalDir = -1. * a_localPosition.y;
|
||
float tangentDir = -1. * a_localPosition.x;
|
||
float angle = mix(v_angleStart, v_angleEnd, startEndRatio);
|
||
vec2 joinDirection;
|
||
vec2 positionPx = mix(segmentStartPx, segmentEndPx, startEndRatio);
|
||
// if angle is too high, do not make a proper join
|
||
if (cos(angle) > ${xc} || isCap(angle)) {
|
||
joinDirection = normalPx * normalDir - tangentPx * tangentDir;
|
||
} else {
|
||
joinDirection = getJoinOffsetDirection(normalPx * normalDir, angle);
|
||
}
|
||
positionPx = positionPx + joinDirection * (lineWidth * 0.5 + 1.); // adding 1 pixel for antialiasing
|
||
gl_Position = pxToScreen(positionPx);
|
||
|
||
v_segmentStartPx = segmentStartPx;
|
||
v_segmentEndPx = segmentEndPx;
|
||
v_width = lineWidth;
|
||
v_hitColor = unpackColor(a_hitColor);
|
||
|
||
v_distancePx = a_distanceLow / u_resolution - (lineOffsetPx * a_angleTangentSum);
|
||
float distanceHighPx = a_distanceHigh / u_resolution;
|
||
${this.strokePatternLengthExpression_!==null?`v_distancePx = mod(v_distancePx, ${this.strokePatternLengthExpression_});
|
||
distanceHighPx = mod(distanceHighPx, ${this.strokePatternLengthExpression_});
|
||
`:""}v_distancePx += distanceHighPx;
|
||
|
||
v_measureStart = a_measureStart;
|
||
v_measureEnd = a_measureEnd;
|
||
${this.attributes_.map(e=>` ${e.varyingName} = ${e.varyingExpression};`).join(`
|
||
`)}
|
||
}`:null}getStrokeFragmentShader(){return this.hasStroke_?`${pi}
|
||
${this.uniforms_.map(e=>`uniform ${e.type} ${e.name};`).join(`
|
||
`)}
|
||
varying vec2 v_segmentStartPx;
|
||
varying vec2 v_segmentEndPx;
|
||
varying float v_angleStart;
|
||
varying float v_angleEnd;
|
||
varying float v_width;
|
||
varying vec4 v_hitColor;
|
||
varying float v_distancePx;
|
||
varying float v_measureStart;
|
||
varying float v_measureEnd;
|
||
${this.attributes_.map(e=>`varying ${e.varyingType} ${e.varyingName};`).join(`
|
||
`)}
|
||
${this.fragmentShaderFunctions_.join(`
|
||
`)}
|
||
|
||
vec2 pxToWorld(vec2 pxPos) {
|
||
vec2 screenPos = 2.0 * pxPos / u_viewportSizePx - 1.0;
|
||
return (u_screenToWorldMatrix * vec4(screenPos, 0.0, 1.0)).xy;
|
||
}
|
||
|
||
bool isCap(float joinAngle) {
|
||
return joinAngle < -0.1;
|
||
}
|
||
|
||
float segmentDistanceField(vec2 point, vec2 start, vec2 end, float width) {
|
||
vec2 tangent = normalize(end - start);
|
||
vec2 normal = vec2(-tangent.y, tangent.x);
|
||
vec2 startToPoint = point - start;
|
||
return abs(dot(startToPoint, normal)) - width * 0.5;
|
||
}
|
||
|
||
float buttCapDistanceField(vec2 point, vec2 start, vec2 end) {
|
||
vec2 startToPoint = point - start;
|
||
vec2 tangent = normalize(end - start);
|
||
return dot(startToPoint, -tangent);
|
||
}
|
||
|
||
float squareCapDistanceField(vec2 point, vec2 start, vec2 end, float width) {
|
||
return buttCapDistanceField(point, start, end) - width * 0.5;
|
||
}
|
||
|
||
float roundCapDistanceField(vec2 point, vec2 start, vec2 end, float width) {
|
||
float onSegment = max(0., 1000. * dot(point - start, end - start)); // this is very high when inside the segment
|
||
return length(point - start) - width * 0.5 - onSegment;
|
||
}
|
||
|
||
float roundJoinDistanceField(vec2 point, vec2 start, vec2 end, float width) {
|
||
return roundCapDistanceField(point, start, end, width);
|
||
}
|
||
|
||
float bevelJoinField(vec2 point, vec2 start, vec2 end, float width, float joinAngle) {
|
||
vec2 startToPoint = point - start;
|
||
vec2 tangent = normalize(end - start);
|
||
float c = cos(joinAngle * 0.5);
|
||
float s = sin(joinAngle * 0.5);
|
||
float direction = -sign(sin(joinAngle));
|
||
vec2 bisector = vec2(c * tangent.x - s * tangent.y, s * tangent.x + c * tangent.y);
|
||
float radius = width * 0.5 * s;
|
||
return dot(startToPoint, bisector * direction) - radius;
|
||
}
|
||
|
||
float miterJoinDistanceField(vec2 point, vec2 start, vec2 end, float width, float joinAngle) {
|
||
if (cos(joinAngle) > ${xc}) { // avoid risking a division by zero
|
||
return bevelJoinField(point, start, end, width, joinAngle);
|
||
}
|
||
float miterLength = 1. / sin(joinAngle * 0.5);
|
||
float miterLimit = ${this.strokeMiterLimitExpression_};
|
||
if (miterLength > miterLimit) {
|
||
return bevelJoinField(point, start, end, width, joinAngle);
|
||
}
|
||
return -1000.;
|
||
}
|
||
|
||
float capDistanceField(vec2 point, vec2 start, vec2 end, float width, float capType) {
|
||
if (capType == ${Ht("butt")}) {
|
||
return buttCapDistanceField(point, start, end);
|
||
} else if (capType == ${Ht("square")}) {
|
||
return squareCapDistanceField(point, start, end, width);
|
||
}
|
||
return roundCapDistanceField(point, start, end, width);
|
||
}
|
||
|
||
float joinDistanceField(vec2 point, vec2 start, vec2 end, float width, float joinAngle, float joinType) {
|
||
if (joinType == ${Ht("bevel")}) {
|
||
return bevelJoinField(point, start, end, width, joinAngle);
|
||
} else if (joinType == ${Ht("miter")}) {
|
||
return miterJoinDistanceField(point, start, end, width, joinAngle);
|
||
}
|
||
return roundJoinDistanceField(point, start, end, width);
|
||
}
|
||
|
||
float computeSegmentPointDistance(vec2 point, vec2 start, vec2 end, float width, float joinAngle, float capType, float joinType) {
|
||
if (isCap(joinAngle)) {
|
||
return capDistanceField(point, start, end, width, capType);
|
||
}
|
||
return joinDistanceField(point, start, end, width, joinAngle, joinType);
|
||
}
|
||
|
||
float distanceFromSegment(vec2 point, vec2 start, vec2 end) {
|
||
vec2 tangent = end - start;
|
||
vec2 startToPoint = point - start;
|
||
// inspire by capsule fn in https://iquilezles.org/articles/distfunctions/
|
||
float h = clamp(dot(startToPoint, tangent) / dot(tangent, tangent), 0.0, 1.0);
|
||
return length(startToPoint - tangent * h);
|
||
}
|
||
|
||
void main(void) {
|
||
${this.attributes_.map(e=>` ${e.varyingType} ${e.name} = ${e.varyingName}; // assign to original attribute name`).join(`
|
||
`)}
|
||
|
||
vec2 currentPointPx = gl_FragCoord.xy / u_pixelRatio;
|
||
#ifdef GL_FRAGMENT_PRECISION_HIGH
|
||
vec2 worldPos = pxToWorld(currentPointPx);
|
||
if (
|
||
abs(u_renderExtent[0] - u_renderExtent[2]) > 0.0 && (
|
||
worldPos[0] < u_renderExtent[0] ||
|
||
worldPos[1] < u_renderExtent[1] ||
|
||
worldPos[0] > u_renderExtent[2] ||
|
||
worldPos[1] > u_renderExtent[3]
|
||
)
|
||
) {
|
||
discard;
|
||
}
|
||
#endif
|
||
|
||
float segmentLengthPx = length(v_segmentEndPx - v_segmentStartPx);
|
||
segmentLengthPx = max(segmentLengthPx, 1.17549429e-38); // avoid divide by zero
|
||
vec2 segmentTangent = (v_segmentEndPx - v_segmentStartPx) / segmentLengthPx;
|
||
vec2 segmentNormal = vec2(-segmentTangent.y, segmentTangent.x);
|
||
vec2 startToPointPx = currentPointPx - v_segmentStartPx;
|
||
float lengthToPointPx = max(0., min(dot(segmentTangent, startToPointPx), segmentLengthPx));
|
||
float currentLengthPx = lengthToPointPx + v_distancePx;
|
||
float currentRadiusPx = distanceFromSegment(currentPointPx, v_segmentStartPx, v_segmentEndPx);
|
||
float currentRadiusRatio = dot(segmentNormal, startToPointPx) * 2. / v_width;
|
||
currentLineMetric = mix(v_measureStart, v_measureEnd, lengthToPointPx / segmentLengthPx);
|
||
|
||
if (${this.discardExpression_}) { discard; }
|
||
|
||
float capType = ${this.strokeCapExpression_};
|
||
float joinType = ${this.strokeJoinExpression_};
|
||
float segmentStartDistance = computeSegmentPointDistance(currentPointPx, v_segmentStartPx, v_segmentEndPx, v_width, v_angleStart, capType, joinType);
|
||
float segmentEndDistance = computeSegmentPointDistance(currentPointPx, v_segmentEndPx, v_segmentStartPx, v_width, v_angleEnd, capType, joinType);
|
||
float distanceField = max(
|
||
segmentDistanceField(currentPointPx, v_segmentStartPx, v_segmentEndPx, v_width),
|
||
max(segmentStartDistance, segmentEndDistance)
|
||
);
|
||
distanceField = max(distanceField, ${this.strokeDistanceFieldExpression_});
|
||
|
||
vec4 color = ${this.strokeColorExpression_};
|
||
color.a *= smoothstep(0.5, -0.5, distanceField);
|
||
gl_FragColor = color;
|
||
gl_FragColor.a *= u_globalAlpha;
|
||
gl_FragColor.rgb *= gl_FragColor.a;
|
||
if (u_hitDetection > 0) {
|
||
if (gl_FragColor.a < 0.1) { discard; };
|
||
gl_FragColor = v_hitColor;
|
||
}
|
||
}`:null}getFillVertexShader(){return this.hasFill_?`${pi}
|
||
${this.uniforms_.map(e=>`uniform ${e.type} ${e.name};`).join(`
|
||
`)}
|
||
attribute vec2 a_position;
|
||
attribute vec2 a_hitColor;
|
||
|
||
varying vec4 v_hitColor;
|
||
|
||
${this.attributes_.map(e=>`attribute ${e.type} ${e.name};
|
||
varying ${e.varyingType} ${e.varyingName};`).join(`
|
||
`)}
|
||
${this.vertexShaderFunctions_.join(`
|
||
`)}
|
||
void main(void) {
|
||
gl_Position = u_projectionMatrix * vec4(a_position, u_depth, 1.0);
|
||
v_hitColor = unpackColor(a_hitColor);
|
||
${this.attributes_.map(e=>` ${e.varyingName} = ${e.varyingExpression};`).join(`
|
||
`)}
|
||
}`:null}getFillFragmentShader(){return this.hasFill_?`${pi}
|
||
${this.uniforms_.map(e=>`uniform ${e.type} ${e.name};`).join(`
|
||
`)}
|
||
varying vec4 v_hitColor;
|
||
${this.attributes_.map(e=>`varying ${e.varyingType} ${e.varyingName};`).join(`
|
||
`)}
|
||
${this.fragmentShaderFunctions_.join(`
|
||
`)}
|
||
vec2 pxToWorld(vec2 pxPos) {
|
||
vec2 screenPos = 2.0 * pxPos / u_viewportSizePx - 1.0;
|
||
return (u_screenToWorldMatrix * vec4(screenPos, 0.0, 1.0)).xy;
|
||
}
|
||
|
||
vec2 worldToPx(vec2 worldPos) {
|
||
vec4 screenPos = u_projectionMatrix * vec4(worldPos, 0.0, 1.0);
|
||
return (0.5 * screenPos.xy + 0.5) * u_viewportSizePx;
|
||
}
|
||
|
||
void main(void) {
|
||
${this.attributes_.map(e=>` ${e.varyingType} ${e.name} = ${e.varyingName}; // assign to original attribute name`).join(`
|
||
`)}
|
||
vec2 pxPos = gl_FragCoord.xy / u_pixelRatio;
|
||
vec2 pxOrigin = worldToPx(u_patternOrigin);
|
||
#ifdef GL_FRAGMENT_PRECISION_HIGH
|
||
vec2 worldPos = pxToWorld(pxPos);
|
||
if (
|
||
abs(u_renderExtent[0] - u_renderExtent[2]) > 0.0 && (
|
||
worldPos[0] < u_renderExtent[0] ||
|
||
worldPos[1] < u_renderExtent[1] ||
|
||
worldPos[0] > u_renderExtent[2] ||
|
||
worldPos[1] > u_renderExtent[3]
|
||
)
|
||
) {
|
||
discard;
|
||
}
|
||
#endif
|
||
if (${this.discardExpression_}) { discard; }
|
||
gl_FragColor = ${this.fillColorExpression_};
|
||
gl_FragColor.a *= u_globalAlpha;
|
||
gl_FragColor.rgb *= gl_FragColor.a;
|
||
if (u_hitDetection > 0) {
|
||
if (gl_FragColor.a < 0.1) { discard; };
|
||
gl_FragColor = v_hitColor;
|
||
}
|
||
}`:null}}class Yr{constructor(){this.globalCounter_=0,this.refToFeature_=new Map,this.uidToRef_=new Map,this.freeGlobalRef_=[],this.polygonBatch={entries:{},geometriesCount:0,verticesCount:0,ringsCount:0},this.pointBatch={entries:{},geometriesCount:0},this.lineStringBatch={entries:{},geometriesCount:0,verticesCount:0}}addFeatures(e,t){for(let n=0;n<e.length;n++)this.addFeature(e[n],t)}addFeature(e,t){let n=e.getGeometry();n&&(t&&(n=n.clone(),n.applyTransform(t)),this.addGeometry_(n,e))}clearFeatureEntryInPointBatch_(e){const t=D(e),n=this.pointBatch.entries[t];if(n)return this.pointBatch.geometriesCount-=n.flatCoordss.length,delete this.pointBatch.entries[t],n}clearFeatureEntryInLineStringBatch_(e){const t=D(e),n=this.lineStringBatch.entries[t];if(n)return this.lineStringBatch.verticesCount-=n.verticesCount,this.lineStringBatch.geometriesCount-=n.flatCoordss.length,delete this.lineStringBatch.entries[t],n}clearFeatureEntryInPolygonBatch_(e){const t=D(e),n=this.polygonBatch.entries[t];if(n)return this.polygonBatch.verticesCount-=n.verticesCount,this.polygonBatch.ringsCount-=n.ringsCount,this.polygonBatch.geometriesCount-=n.flatCoordss.length,delete this.polygonBatch.entries[t],n}addGeometry_(e,t){const n=e.getType();switch(n){case"GeometryCollection":{const i=e.getGeometriesArray();for(const r of i)this.addGeometry_(r,t);break}case"MultiPolygon":{const i=e;this.addCoordinates_(n,i.getFlatCoordinates(),i.getEndss(),t,D(t),i.getStride());break}case"MultiLineString":{const i=e;this.addCoordinates_(n,i.getFlatCoordinates(),i.getEnds(),t,D(t),i.getStride());break}case"MultiPoint":{const i=e;this.addCoordinates_(n,i.getFlatCoordinates(),null,t,D(t),i.getStride());break}case"Polygon":{const i=e;this.addCoordinates_(n,i.getFlatCoordinates(),i.getEnds(),t,D(t),i.getStride());break}case"Point":{const i=e;this.addCoordinates_(n,i.getFlatCoordinates(),null,t,D(t),i.getStride());break}case"LineString":case"LinearRing":{const i=e,r=i.getStride();this.addCoordinates_(n,i.getFlatCoordinates(),null,t,D(t),r,i.getLayout?.());break}}}addCoordinates_(e,t,n,i,r,o,a){let l;switch(e){case"MultiPolygon":{const h=n;for(let c=0,u=h.length;c<u;c++){let d=h[c];const f=c>0?h[c-1]:null,g=f?f[f.length-1]:0,m=d[d.length-1];d=g>0?d.map(_=>_-g):d,this.addCoordinates_("Polygon",t.slice(g,m),d,i,r,o,a)}break}case"MultiLineString":{const h=n;for(let c=0,u=h.length;c<u;c++){const d=c>0?h[c-1]:0;this.addCoordinates_("LineString",t.slice(d,h[c]),null,i,r,o,a)}break}case"MultiPoint":for(let h=0,c=t.length;h<c;h+=o)this.addCoordinates_("Point",t.slice(h,h+2),null,i,r,null,null);break;case"Polygon":{const h=n;if(i instanceof He){const d=fu(t,h);if(d.length>1){this.addCoordinates_("MultiPolygon",t,d,i,r,o,a);return}}this.polygonBatch.entries[r]||(this.polygonBatch.entries[r]=this.addRefToEntry_(r,{feature:i,flatCoordss:[],verticesCount:0,ringsCount:0,ringsVerticesCounts:[]})),l=t.length/o;const c=n.length,u=n.map((d,f,g)=>f>0?(d-g[f-1])/o:d/o);this.polygonBatch.verticesCount+=l,this.polygonBatch.ringsCount+=c,this.polygonBatch.geometriesCount++,this.polygonBatch.entries[r].flatCoordss.push($y(t,o)),this.polygonBatch.entries[r].ringsVerticesCounts.push(u),this.polygonBatch.entries[r].verticesCount+=l,this.polygonBatch.entries[r].ringsCount+=c;for(let d=0,f=h.length;d<f;d++){const g=d>0?h[d-1]:0;this.addCoordinates_("LinearRing",t.slice(g,h[d]),null,i,r,o,a)}break}case"Point":this.pointBatch.entries[r]||(this.pointBatch.entries[r]=this.addRefToEntry_(r,{feature:i,flatCoordss:[]})),this.pointBatch.geometriesCount++,this.pointBatch.entries[r].flatCoordss.push(t);break;case"LineString":case"LinearRing":this.lineStringBatch.entries[r]||(this.lineStringBatch.entries[r]=this.addRefToEntry_(r,{feature:i,flatCoordss:[],verticesCount:0})),l=t.length/o,this.lineStringBatch.verticesCount+=l,this.lineStringBatch.geometriesCount++,this.lineStringBatch.entries[r].flatCoordss.push(Xy(t,o,a)),this.lineStringBatch.entries[r].verticesCount+=l;break}}addRefToEntry_(e,t){const n=this.uidToRef_.get(e),i=n||this.freeGlobalRef_.pop()||++this.globalCounter_;return t.ref=i,n||(this.refToFeature_.set(i,t.feature),this.uidToRef_.set(e,i)),t}removeRef_(e,t){if(!e)throw new Error("This feature has no ref: "+t);this.refToFeature_.delete(e),this.uidToRef_.delete(t),this.freeGlobalRef_.push(e)}changeFeature(e,t){if(!this.uidToRef_.get(D(e)))return;this.removeFeature(e);let n=e.getGeometry();n&&(t&&(n=n.clone(),n.applyTransform(t)),this.addGeometry_(n,e))}removeFeature(e){let t=this.clearFeatureEntryInPointBatch_(e);t=this.clearFeatureEntryInPolygonBatch_(e)||t,t=this.clearFeatureEntryInLineStringBatch_(e)||t,t&&this.removeRef_(t.ref,D(t.feature))}clear(){this.polygonBatch.entries={},this.polygonBatch.geometriesCount=0,this.polygonBatch.verticesCount=0,this.polygonBatch.ringsCount=0,this.lineStringBatch.entries={},this.lineStringBatch.geometriesCount=0,this.lineStringBatch.verticesCount=0,this.pointBatch.entries={},this.pointBatch.geometriesCount=0,this.globalCounter_=0,this.freeGlobalRef_=[],this.refToFeature_.clear(),this.uidToRef_.clear()}getFeatureFromRef(e){return this.refToFeature_.get(e)}isEmpty(){return this.globalCounter_===0}filter(e){const t=new Yr;t.globalCounter_=this.globalCounter_,t.uidToRef_=this.uidToRef_,t.refToFeature_=this.refToFeature_;let n=!0;for(const i of this.refToFeature_.values())e(i)&&(t.addFeature(i),n=!1);return n?new Yr:t}}function $y(s,e){return e===2?s:s.filter((t,n)=>n%e<2)}function Xy(s,e,t){return e===3&&t==="XYM"?s:e===4?s.filter((n,i)=>i%e!==2):e===3?s.map((n,i)=>i%e!==2?n:0):new Array(s.length*1.5).fill(0).map((n,i)=>i%3===2?0:s[Math.round(i/1.5)])}function Wy(){const s='function t(t,n,x=2){const o=n&&n.length,i=o?n[0]*x:t.length;let f=e(t,0,i,x,!0);const l=[];if(!f||f.next===f.prev)return l;let c,y,h;if(o&&(f=function(t,n,r,x){const o=[];for(let r=0,i=n.length;r<i;r++){const f=e(t,n[r]*x,r<i-1?n[r+1]*x:t.length,x,!1);f===f.next&&(f.steiner=!0),o.push(a(f))}o.sort(u);for(let t=0;t<o.length;t++)r=s(o[t],r);return r}(t,n,f,x)),t.length>80*x){c=t[0],y=t[1];let e=c,n=y;for(let r=x;r<i;r+=x){const x=t[r],o=t[r+1];x<c&&(c=x),o<y&&(y=o),x>e&&(e=x),o>n&&(n=o)}h=Math.max(e-c,n-y),h=0!==h?32767/h:0}return r(f,l,x,c,y,h,0),l}function e(t,e,n,r,x){let o;if(x===function(t,e,n,r){let x=0;for(let o=e,i=n-r;o<n;o+=r)x+=(t[i]-t[o])*(t[o+1]+t[i+1]),i=o;return x}(t,e,n,r)>0)for(let x=e;x<n;x+=r)o=d(x/r|0,t[x],t[x+1],o);else for(let x=n-r;x>=e;x-=r)o=d(x/r|0,t[x],t[x+1],o);return o&&b(o,o.next)&&(w(o),o=o.next),o}function n(t,e){if(!t)return t;e||(e=t);let n,r=t;do{if(n=!1,r.steiner||!b(r,r.next)&&0!==v(r.prev,r,r.next))r=r.next;else{if(w(r),r=e=r.prev,r===r.next)break;n=!0}}while(n||r!==e);return e}function r(t,e,u,s,l,a,y){if(!t)return;!y&&a&&function(t,e,n,r){let x=t;do{0===x.z&&(x.z=c(x.x,x.y,e,n,r)),x.prevZ=x.prev,x.nextZ=x.next,x=x.next}while(x!==t);x.prevZ.nextZ=null,x.prevZ=null,function(t){let e,n=1;do{let r,x=t;t=null;let o=null;for(e=0;x;){e++;let i=x,f=0;for(let t=0;t<n&&(f++,i=i.nextZ,i);t++);let u=n;for(;f>0||u>0&&i;)0!==f&&(0===u||!i||x.z<=i.z)?(r=x,x=x.nextZ,f--):(r=i,i=i.nextZ,u--),o?o.nextZ=r:t=r,r.prevZ=o,o=r;x=i}o.nextZ=null,n*=2}while(e>1)}(x)}(t,s,l,a);let h=t;for(;t.prev!==t.next;){const c=t.prev,p=t.next;if(a?o(t,s,l,a):x(t))e.push(c.i,t.i,p.i),w(t),t=p.next,h=p.next;else if((t=p)===h){y?1===y?r(t=i(n(t),e),e,u,s,l,a,2):2===y&&f(t,e,u,s,l,a):r(n(t),e,u,s,l,a,1);break}}}function x(t){const e=t.prev,n=t,r=t.next;if(v(e,n,r)>=0)return!1;const x=e.x,o=n.x,i=r.x,f=e.y,u=n.y,s=r.y,l=Math.min(x,o,i),c=Math.min(f,u,s),a=Math.max(x,o,i),y=Math.max(f,u,s);let p=r.next;for(;p!==e;){if(p.x>=l&&p.x<=a&&p.y>=c&&p.y<=y&&h(x,f,o,u,i,s,p.x,p.y)&&v(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function o(t,e,n,r){const x=t.prev,o=t,i=t.next;if(v(x,o,i)>=0)return!1;const f=x.x,u=o.x,s=i.x,l=x.y,a=o.y,y=i.y,p=Math.min(f,u,s),b=Math.min(l,a,y),M=Math.max(f,u,s),m=Math.max(l,a,y),A=c(p,b,e,n,r),g=c(M,m,e,n,r);let Z=t.prevZ,d=t.nextZ;for(;Z&&Z.z>=A&&d&&d.z<=g;){if(Z.x>=p&&Z.x<=M&&Z.y>=b&&Z.y<=m&&Z!==x&&Z!==i&&h(f,l,u,a,s,y,Z.x,Z.y)&&v(Z.prev,Z,Z.next)>=0)return!1;if(Z=Z.prevZ,d.x>=p&&d.x<=M&&d.y>=b&&d.y<=m&&d!==x&&d!==i&&h(f,l,u,a,s,y,d.x,d.y)&&v(d.prev,d,d.next)>=0)return!1;d=d.nextZ}for(;Z&&Z.z>=A;){if(Z.x>=p&&Z.x<=M&&Z.y>=b&&Z.y<=m&&Z!==x&&Z!==i&&h(f,l,u,a,s,y,Z.x,Z.y)&&v(Z.prev,Z,Z.next)>=0)return!1;Z=Z.prevZ}for(;d&&d.z<=g;){if(d.x>=p&&d.x<=M&&d.y>=b&&d.y<=m&&d!==x&&d!==i&&h(f,l,u,a,s,y,d.x,d.y)&&v(d.prev,d,d.next)>=0)return!1;d=d.nextZ}return!0}function i(t,e){let r=t;do{const n=r.prev,x=r.next.next;!b(n,x)&&M(n,r,r.next,x)&&g(n,x)&&g(x,n)&&(e.push(n.i,r.i,x.i),w(r),w(r.next),r=t=x),r=r.next}while(r!==t);return n(r)}function f(t,e,x,o,i,f){let u=t;do{let t=u.next.next;for(;t!==u.prev;){if(u.i!==t.i&&p(u,t)){let s=Z(u,t);return u=n(u,u.next),s=n(s,s.next),r(u,e,x,o,i,f,0),void r(s,e,x,o,i,f,0)}t=t.next}u=u.next}while(u!==t)}function u(t,e){let n=t.x-e.x;if(0===n&&(n=t.y-e.y,0===n)){n=(t.next.y-t.y)/(t.next.x-t.x)-(e.next.y-e.y)/(e.next.x-e.x)}return n}function s(t,e){const r=function(t,e){let n=e;const r=t.x,x=t.y;let o,i=-1/0;if(b(t,n))return n;do{if(b(t,n.next))return n.next;if(x<=n.y&&x>=n.next.y&&n.next.y!==n.y){const t=n.x+(x-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(t<=r&&t>i&&(i=t,o=n.x<n.next.x?n:n.next,t===r))return o}n=n.next}while(n!==e);if(!o)return null;const f=o,u=o.x,s=o.y;let c=1/0;n=o;do{if(r>=n.x&&n.x>=u&&r!==n.x&&y(x<s?r:i,x,u,s,x<s?i:r,x,n.x,n.y)){const e=Math.abs(x-n.y)/(r-n.x);g(n,t)&&(e<c||e===c&&(n.x>o.x||n.x===o.x&&l(o,n)))&&(o=n,c=e)}n=n.next}while(n!==f);return o}(t,e);if(!r)return e;const x=Z(r,t);return n(x,x.next),n(r,r.next)}function l(t,e){return v(t.prev,t,e.prev)<0&&v(e.next,t,t.next)<0}function c(t,e,n,r,x){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-n)*x|0)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-r)*x|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function a(t){let e=t,n=t;do{(e.x<n.x||e.x===n.x&&e.y<n.y)&&(n=e),e=e.next}while(e!==t);return n}function y(t,e,n,r,x,o,i,f){return(x-i)*(e-f)>=(t-i)*(o-f)&&(t-i)*(r-f)>=(n-i)*(e-f)&&(n-i)*(o-f)>=(x-i)*(r-f)}function h(t,e,n,r,x,o,i,f){return!(t===i&&e===f)&&y(t,e,n,r,x,o,i,f)}function p(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){let n=t;do{if(n.i!==t.i&&n.next.i!==t.i&&n.i!==e.i&&n.next.i!==e.i&&M(n,n.next,t,e))return!0;n=n.next}while(n!==t);return!1}(t,e)&&(g(t,e)&&g(e,t)&&function(t,e){let n=t,r=!1;const x=(t.x+e.x)/2,o=(t.y+e.y)/2;do{n.y>o!=n.next.y>o&&n.next.y!==n.y&&x<(n.next.x-n.x)*(o-n.y)/(n.next.y-n.y)+n.x&&(r=!r),n=n.next}while(n!==t);return r}(t,e)&&(v(t.prev,t,e.prev)||v(t,e.prev,e))||b(t,e)&&v(t.prev,t,t.next)>0&&v(e.prev,e,e.next)>0)}function v(t,e,n){return(e.y-t.y)*(n.x-e.x)-(e.x-t.x)*(n.y-e.y)}function b(t,e){return t.x===e.x&&t.y===e.y}function M(t,e,n,r){const x=A(v(t,e,n)),o=A(v(t,e,r)),i=A(v(n,r,t)),f=A(v(n,r,e));return x!==o&&i!==f||(!(0!==x||!m(t,n,e))||(!(0!==o||!m(t,r,e))||(!(0!==i||!m(n,t,r))||!(0!==f||!m(n,e,r)))))}function m(t,e,n){return e.x<=Math.max(t.x,n.x)&&e.x>=Math.min(t.x,n.x)&&e.y<=Math.max(t.y,n.y)&&e.y>=Math.min(t.y,n.y)}function A(t){return t>0?1:t<0?-1:0}function g(t,e){return v(t.prev,t,t.next)<0?v(t,e,t.next)>=0&&v(t,t.prev,e)>=0:v(t,e,t.prev)<0||v(t,t.next,e)<0}function Z(t,e){const n=F(t.i,t.x,t.y),r=F(e.i,e.x,e.y),x=t.next,o=e.prev;return t.next=e,e.prev=t,n.next=x,x.prev=n,r.next=n,n.prev=r,o.next=r,r.prev=o,r}function d(t,e,n,r){const x=F(t,e,n);return r?(x.next=r.next,x.prev=r,r.next.prev=x,r.next=x):(x.prev=x,x.next=x),x}function w(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function F(t,e,n){return{i:t,x:e,y:n,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function E(t,e){const n=e[0],r=e[1];return e[0]=t[0]*n+t[2]*r+t[4],e[1]=t[1]*n+t[3]*r+t[5],e}function I(t,e){const n=(r=e)[0]*r[3]-r[1]*r[2];var r;!function(t,e){if(!t)throw new Error(e)}(0!==n,"Transformation matrix cannot be inverted");const x=e[0],o=e[1],i=e[2],f=e[3],u=e[4],s=e[5];return t[0]=f/n,t[1]=-o/n,t[2]=-i/n,t[3]=x/n,t[4]=(i*s-f*u)/n,t[5]=-(x*s-o*u)/n,t}new Array(6);const z=[],B={vertexAttributesPosition:0,instanceAttributesPosition:0,indicesPosition:0};function P(t,e,n,r,x){const o=t[e++],i=t[e++],f=z;f.length=r;for(let n=0;n<f.length;n++)f[n]=t[e+n];let u=x?x.instanceAttributesPosition:0;return n[u++]=o,n[u++]=i,f.length&&(n.set(f,u),u+=f.length),B.instanceAttributesPosition=u,B}function N(t,e,n,r,x,o,i,f,u,s){const l=[t[e],t[e+1]],c=[t[n],t[n+1]],a=t[e+2],y=t[n+2],h=E(f,[...l]),p=E(f,[...c]);function v(t,e,n){const r=Math.sqrt((e[0]-t[0])*(e[0]-t[0])+(e[1]-t[1])*(e[1]-t[1])),x=[(e[0]-t[0])/r,(e[1]-t[1])/r],o=[-x[1],x[0]],i=Math.sqrt((n[0]-t[0])*(n[0]-t[0])+(n[1]-t[1])*(n[1]-t[1])),f=[(n[0]-t[0])/i,(n[1]-t[1])/i];let u=0===r||0===i?0:Math.acos((s=f[0]*x[0]+f[1]*x[1],l=-1,c=1,Math.min(Math.max(s,l),c)));var s,l,c;u=Math.max(u,1e-5);return f[0]*o[0]+f[1]*o[1]>0?u:2*Math.PI-u}let b=-1,M=-1,m=s;const A=null!==x;if(null!==r){b=v(h,p,E(f,[...[t[r],t[r+1]]])),Math.cos(b)<=.985&&(m+=Math.tan((b-Math.PI)/2))}if(A){M=v(p,h,E(f,[...[t[x],t[x+1]]])),Math.cos(M)<=.985&&(m+=Math.tan((Math.PI-M)/2))}const g=Math.pow(2,24),Z=u%g,d=Math.floor(u/g)*g;return o.push(l[0],l[1],a,c[0],c[1],y,b,M,Z,d,s),o.push(...i),{length:u+Math.sqrt((p[0]-h[0])*(p[0]-h[0])+(p[1]-h[1])*(p[1]-h[1])),angle:m}}function R(e,n,r,x,o){const i=2+o;let f=n;const u=e.slice(f,f+o);f+=o;const s=e[f++];let l=0;const c=new Array(s-1);for(let t=0;t<s;t++)l+=e[f++],t<s-1&&(c[t]=l);const a=e.slice(f,f+2*l),y=t(a,c,2);for(let t=0;t<y.length;t++)x.push(y[t]+r.length/i);for(let t=0;t<a.length;t+=2)r.push(a[t],a[t+1],...u);return f+2*l}const S="GENERATE_POLYGON_BUFFERS",T="GENERATE_POINT_BUFFERS",_="GENERATE_LINE_STRING_BUFFERS",O=self;O.onmessage=t=>{const e=t.data;switch(e.type){case T:{const t=2,n=2,r=e.customAttributesSize,x=n+r,o=new Float32Array(e.renderInstructions),i=o.length/x*(t+r),f=Uint32Array.from([0,1,3,1,2,3]),u=Float32Array.from([-1,-1,1,-1,1,1,-1,1]),s=new Float32Array(i);let l;for(let t=0;t<o.length;t+=x)l=P(o,t,s,r,l);const c=Object.assign({indicesBuffer:f.buffer,vertexAttributesBuffer:u.buffer,instanceAttributesBuffer:s.buffer,renderInstructions:o.buffer},e);O.postMessage(c,[u.buffer,s.buffer,f.buffer,o.buffer]);break}case _:{const t=[],n=e.customAttributesSize,r=3,x=new Float32Array(e.renderInstructions);let o=0;const i=[1,0,0,1,0,0];let f,u;for(I(i,e.renderInstructionsTransform);o<x.length;){u=Array.from(x.slice(o,o+n)),o+=n,f=x[o++];const e=o,s=o+(f-1)*r,l=x[e]===x[s]&&x[e+1]===x[s+1];let c=0,a=0;for(let n=0;n<f-1;n++){let y=null;n>0?y=o+(n-1)*r:l&&(y=s-r);let h=null;n<f-2?h=o+(n+2)*r:l&&(h=e+r);const p=N(x,o+n*r,o+(n+1)*r,y,h,t,u,i,c,a);c=p.length,a=p.angle}o+=f*r}const s=Uint32Array.from([0,1,3,1,2,3]),l=Float32Array.from([-1,-1,1,-1,1,1,-1,1]),c=Float32Array.from(t),a=Object.assign({indicesBuffer:s.buffer,vertexAttributesBuffer:l.buffer,instanceAttributesBuffer:c.buffer,renderInstructions:x.buffer},e);O.postMessage(a,[l.buffer,c.buffer,s.buffer,x.buffer]);break}case S:{const t=[],n=[],r=e.customAttributesSize,x=new Float32Array(e.renderInstructions);let o=0;for(;o<x.length;)o=R(x,o,t,n,r);const i=Uint32Array.from(n),f=Float32Array.from(t),u=Float32Array.from([]),s=Object.assign({indicesBuffer:i.buffer,vertexAttributesBuffer:f.buffer,instanceAttributesBuffer:u.buffer,renderInstructions:x.buffer},e);O.postMessage(s,[f.buffer,u.buffer,i.buffer,x.buffer]);break}}};';return new Worker(typeof Blob>"u"?"data:application/javascript;base64,"+Buffer.from(s,"binary").toString("base64"):URL.createObjectURL(new Blob([s],{type:"application/javascript"})))}const sa={GENERATE_POLYGON_BUFFERS:"GENERATE_POLYGON_BUFFERS",GENERATE_POINT_BUFFERS:"GENERATE_POINT_BUFFERS",GENERATE_LINE_STRING_BUFFERS:"GENERATE_LINE_STRING_BUFFERS"};function Yy(s,e){e=e||[];const t=256,n=t-1,i=Math.floor(s/t/t/t)/n,r=Math.floor(s/t/t)%t/n,o=Math.floor(s/t)%t/n,a=s%t/n;return e[0]=i*256*255+r*255,e[1]=o*256*255+a*255,e}function jy(s){let e=0;const t=256,n=t-1;return e+=Math.round(s[0]*t*t*t*n),e+=Math.round(s[1]*t*t*n),e+=Math.round(s[2]*t*n),e+=Math.round(s[3]*n),e}function Ql(s,e,t,n){let i=0;for(const r in e){const o=e[r],a=o.callback.call(t,t.feature);let l=a?.[0]??a;l===za&&console.warn('The "has" operator might return false positives.'),l===void 0?l=za:l===null&&(l=0),s[n+i++]=l,!(!o.size||o.size===1)&&(s[n+i++]=a[1],!(o.size<3)&&(s[n+i++]=a[2],!(o.size<4)&&(s[n+i++]=a[3])))}return i}function go(s){return Object.keys(s).reduce((e,t)=>e+(s[t].size||1),0)}function Vy(s,e,t,n){const i=(2+go(t))*s.geometriesCount;(!e||e.length!==i)&&(e=new Float32Array(i));const r=[];let o=0;for(const a in s.entries){const l=s.entries[a];for(let h=0,c=l.flatCoordss.length;h<c;h++)r[0]=l.flatCoordss[h][0],r[1]=l.flatCoordss[h][1],de(n,r),e[o++]=r[0],e[o++]=r[1],o+=Ql(e,t,l,o)}return e}function Zy(s,e,t,n){const i=3*s.verticesCount+(1+go(t))*s.geometriesCount;(!e||e.length!==i)&&(e=new Float32Array(i));const r=[];let o=0;for(const a in s.entries){const l=s.entries[a];for(let h=0,c=l.flatCoordss.length;h<c;h++){r.length=l.flatCoordss[h].length,Nt(l.flatCoordss[h],0,r.length,3,n,r,3),o+=Ql(e,t,l,o),e[o++]=r.length/3;for(let u=0,d=r.length;u<d;u+=3)e[o++]=r[u],e[o++]=r[u+1],e[o++]=r[u+2]}}return e}function Ky(s,e,t,n){const i=2*s.verticesCount+(1+go(t))*s.geometriesCount+s.ringsCount;(!e||e.length!==i)&&(e=new Float32Array(i));const r=[];let o=0;for(const a in s.entries){const l=s.entries[a];for(let h=0,c=l.flatCoordss.length;h<c;h++){r.length=l.flatCoordss[h].length,Nt(l.flatCoordss[h],0,r.length,2,n,r),o+=Ql(e,t,l,o),e[o++]=l.ringsVerticesCounts[h].length;for(let u=0,d=l.ringsVerticesCounts[h].length;u<d;u++)e[o++]=l.ringsVerticesCounts[h][u];for(let u=0,d=r.length;u<d;u+=2)e[o++]=r[u],e[o++]=r[u+1]}}return e}function jr(s){return(JSON.stringify(s).split("").reduce((t,n)=>(t<<5)-t+n.charCodeAt(0),0)>>>0).toString()}function eh(s,e,t,n){if(`${n}radius`in s&&n!=="icon-"){let i=j(t,s[`${n}radius`],N);if(`${n}radius2`in s){const r=j(t,s[`${n}radius2`],N);i=`max(${i}, ${r})`}`${n}stroke-width`in s&&(i=`(${i} + ${j(t,s[`${n}stroke-width`],N)} * 0.5)`),e.setSymbolSizeExpression(`vec2(${i} * 2. + 0.5)`)}if(`${n}scale`in s){const i=j(t,s[`${n}scale`],_t);e.setSymbolSizeExpression(`${e.getSymbolSizeExpression()} * ${i}`)}`${n}displacement`in s&&e.setSymbolOffsetExpression(j(t,s[`${n}displacement`],et)),`${n}rotation`in s&&e.setSymbolRotationExpression(j(t,s[`${n}rotation`],N)),`${n}rotate-with-view`in s&&e.setSymbolRotateWithView(!!s[`${n}rotate-with-view`])}function yd(s,e,t,n,i){let r="vec4(0.)";if(e!==null&&(r=e),t!==null&&n!==null){const l=`smoothstep(-${n} + 0.63, -${n} - 0.58, ${s})`;r=`mix(${t}, ${r}, ${l})`}const o=`(1.0 - smoothstep(-0.63, 0.58, ${s}))`;let a=`${r} * vec4(1.0, 1.0, 1.0, ${o})`;return i!==null&&(a=`${a} * vec4(1.0, 1.0, 1.0, ${i})`),a}function th(s,e,t,n,i){const r=new Image;r.crossOrigin=s[`${n}cross-origin`]===void 0?"anonymous":s[`${n}cross-origin`],te(typeof s[`${n}src`]=="string",`WebGL layers do not support expressions for the ${n}src style property`),r.src=s[`${n}src`],t[`u_texture${i}_size`]=()=>r.complete?[r.width,r.height]:[0,0],e.addUniform(`u_texture${i}_size`,"vec2");const o=`u_texture${i}_size`;return t[`u_texture${i}`]=r,e.addUniform(`u_texture${i}`,"sampler2D"),o}function nh(s,e,t,n,i){let r=j(t,s[`${e}offset`],_t);if(`${e}offset-origin`in s)switch(s[`${e}offset-origin`]){case"top-right":r=`vec2(${n}.x, 0.) + ${i} * vec2(-1., 0.) + ${r} * vec2(-1., 1.)`;break;case"bottom-left":r=`vec2(0., ${n}.y) + ${i} * vec2(0., -1.) + ${r} * vec2(1., -1.)`;break;case"bottom-right":r=`${n} - ${i} - ${r}`;break}return r}function Hy(s,e,t,n){n.functions.circleDistanceField=`float circleDistanceField(vec2 point, float radius) {
|
||
return length(point) - radius;
|
||
}`,eh(s,e,n,"circle-");let i=null;"circle-opacity"in s&&(i=j(n,s["circle-opacity"],N));let r="coordsPx";"circle-scale"in s&&(r=`coordsPx / ${j(n,s["circle-scale"],_t)}`);let o=null;"circle-fill-color"in s&&(o=j(n,s["circle-fill-color"],ge));let a=null;"circle-stroke-color"in s&&(a=j(n,s["circle-stroke-color"],ge));let l=j(n,s["circle-radius"],N),h=null;"circle-stroke-width"in s&&(h=j(n,s["circle-stroke-width"],N),l=`(${l} + ${h} * 0.5)`);const c=`circleDistanceField(${r}, ${l})`,u=yd(c,o,a,h,i);e.setSymbolColorExpression(u)}function qy(s,e,t,n){n.functions.round=`float round(float v) {
|
||
return sign(v) * floor(abs(v) + 0.5);
|
||
}`,n.functions.starDistanceField=`float starDistanceField(vec2 point, float numPoints, float radius, float radius2, float angle) {
|
||
float startAngle = -PI * 0.5 + angle; // tip starts upwards and rotates clockwise with angle
|
||
float c = cos(startAngle);
|
||
float s = sin(startAngle);
|
||
vec2 pointRotated = vec2(c * point.x - s * point.y, s * point.x + c * point.y);
|
||
float alpha = TWO_PI / numPoints; // the angle of one sector
|
||
float beta = atan(pointRotated.y, pointRotated.x);
|
||
float gamma = round(beta / alpha) * alpha; // angle in sector
|
||
c = cos(-gamma);
|
||
s = sin(-gamma);
|
||
vec2 inSector = vec2(c * pointRotated.x - s * pointRotated.y, abs(s * pointRotated.x + c * pointRotated.y));
|
||
vec2 tipToPoint = inSector + vec2(-radius, 0.);
|
||
vec2 edgeNormal = vec2(radius2 * sin(alpha * 0.5), -radius2 * cos(alpha * 0.5) + radius);
|
||
return dot(normalize(edgeNormal), tipToPoint);
|
||
}`,n.functions.regularDistanceField=`float regularDistanceField(vec2 point, float numPoints, float radius, float angle) {
|
||
float startAngle = -PI * 0.5 + angle; // tip starts upwards and rotates clockwise with angle
|
||
float c = cos(startAngle);
|
||
float s = sin(startAngle);
|
||
vec2 pointRotated = vec2(c * point.x - s * point.y, s * point.x + c * point.y);
|
||
float alpha = TWO_PI / numPoints; // the angle of one sector
|
||
float radiusIn = radius * cos(PI / numPoints);
|
||
float beta = atan(pointRotated.y, pointRotated.x);
|
||
float gamma = round((beta - alpha * 0.5) / alpha) * alpha + alpha * 0.5; // angle in sector from mid
|
||
c = cos(-gamma);
|
||
s = sin(-gamma);
|
||
vec2 inSector = vec2(c * pointRotated.x - s * pointRotated.y, abs(s * pointRotated.x + c * pointRotated.y));
|
||
return inSector.x - radiusIn;
|
||
}`,eh(s,e,n,"shape-");let i=null;"shape-opacity"in s&&(i=j(n,s["shape-opacity"],N));let r="coordsPx";"shape-scale"in s&&(r=`coordsPx / ${j(n,s["shape-scale"],_t)}`);let o=null;"shape-fill-color"in s&&(o=j(n,s["shape-fill-color"],ge));let a=null;"shape-stroke-color"in s&&(a=j(n,s["shape-stroke-color"],ge));let l=null;"shape-stroke-width"in s&&(l=j(n,s["shape-stroke-width"],N));const h=j(n,s["shape-points"],N);let c="0.";"shape-angle"in s&&(c=j(n,s["shape-angle"],N));let u,d=j(n,s["shape-radius"],N);if(l!==null&&(d=`${d} + ${l} * 0.5`),"shape-radius2"in s){let g=j(n,s["shape-radius2"],N);l!==null&&(g=`${g} + ${l} * 0.5`),u=`starDistanceField(${r}, ${h}, ${d}, ${g}, ${c})`}else u=`regularDistanceField(${r}, ${h}, ${d}, ${c})`;const f=yd(u,o,a,l,i);e.setSymbolColorExpression(f)}function Jy(s,e,t,n){let i="vec4(1.0)";"icon-color"in s&&(i=j(n,s["icon-color"],ge)),"icon-opacity"in s&&(i=`${i} * vec4(1.0, 1.0, 1.0, ${j(n,s["icon-opacity"],N)})`);const r=jr(s["icon-src"]),o=th(s,e,t,"icon-",r);if(e.setSymbolColorExpression(`${i} * texture2D(u_texture${r}, v_texCoord)`).setSymbolSizeExpression(o),"icon-width"in s&&"icon-height"in s&&e.setSymbolSizeExpression(`vec2(${j(n,s["icon-width"],N)}, ${j(n,s["icon-height"],N)})`),"icon-offset"in s&&"icon-size"in s){const a=j(n,s["icon-size"],et),l=e.getSymbolSizeExpression();e.setSymbolSizeExpression(a);const h=nh(s,"icon-",n,"v_quadSizePx",a);e.setTextureCoordinateExpression(`(vec4((${h}).xyxy) + vec4(0., 0., ${a})) / (${l}).xyxy`)}if(eh(s,e,n,"icon-"),"icon-anchor"in s){const a=j(n,s["icon-anchor"],et);let l="1.0";"icon-scale"in s&&(l=j(n,s["icon-scale"],_t));let h;s["icon-anchor-x-units"]==="pixels"&&s["icon-anchor-y-units"]==="pixels"?h=`${a} * ${l}`:s["icon-anchor-x-units"]==="pixels"?h=`${a} * vec2(vec2(${l}).x, v_quadSizePx.y)`:s["icon-anchor-y-units"]==="pixels"?h=`${a} * vec2(v_quadSizePx.x, vec2(${l}).x)`:h=`${a} * v_quadSizePx`;let c=`v_quadSizePx * vec2(0.5, -0.5) + ${h} * vec2(-1., 1.)`;if("icon-anchor-origin"in s)switch(s["icon-anchor-origin"]){case"top-right":c=`v_quadSizePx * -0.5 + ${h}`;break;case"bottom-left":c=`v_quadSizePx * 0.5 - ${h}`;break;case"bottom-right":c=`v_quadSizePx * vec2(-0.5, 0.5) + ${h} * vec2(1., -1.)`;break}e.setSymbolOffsetExpression(`${e.getSymbolOffsetExpression()} + ${c}`)}}function Qy(s,e,t,n){if("stroke-color"in s&&e.setStrokeColorExpression(j(n,s["stroke-color"],ge)),"stroke-pattern-src"in s){const i=jr(s["stroke-pattern-src"]),r=th(s,e,t,"stroke-pattern-",i);let o=r,a="vec2(0.)";"stroke-pattern-offset"in s&&"stroke-pattern-size"in s&&(o=j(n,s["stroke-pattern-size"],et),a=nh(s,"stroke-pattern-",n,r,o));let l="0.";"stroke-pattern-spacing"in s&&(l=j(n,s["stroke-pattern-spacing"],N));let h="0.";"stroke-pattern-start-offset"in s&&(h=j(n,s["stroke-pattern-start-offset"],N)),n.functions.sampleStrokePattern=`vec4 sampleStrokePattern(sampler2D texture, vec2 textureSize, vec2 textureOffset, vec2 sampleSize, float spacingPx, float startOffsetPx, float currentLengthPx, float currentRadiusRatio, float lineWidth) {
|
||
float currentLengthScaled = (currentLengthPx - startOffsetPx) * sampleSize.y / lineWidth;
|
||
float spacingScaled = spacingPx * sampleSize.y / lineWidth;
|
||
float uCoordPx = mod(currentLengthScaled, (sampleSize.x + spacingScaled));
|
||
float isInsideOfPattern = step(uCoordPx, sampleSize.x);
|
||
float vCoordPx = (-currentRadiusRatio * 0.5 + 0.5) * sampleSize.y;
|
||
// make sure that we're not sampling too close to the borders to avoid interpolation with outside pixels
|
||
uCoordPx = clamp(uCoordPx, 0.5, sampleSize.x - 0.5);
|
||
vCoordPx = clamp(vCoordPx, 0.5, sampleSize.y - 0.5);
|
||
vec2 texCoord = (vec2(uCoordPx, vCoordPx) + textureOffset) / textureSize;
|
||
return texture2D(texture, texCoord) * vec4(1.0, 1.0, 1.0, isInsideOfPattern);
|
||
}`;const c=`u_texture${i}`;let u="1.";"stroke-color"in s&&(u=e.getStrokeColorExpression()),e.setStrokeColorExpression(`${u} * sampleStrokePattern(${c}, ${r}, ${a}, ${o}, ${l}, ${h}, currentLengthPx, currentRadiusRatio, v_width)`),n.functions.computeStrokePatternLength=`float computeStrokePatternLength(vec2 sampleSize, float spacingPx, float lineWidth) {
|
||
float patternLengthPx = sampleSize.x / sampleSize.y * lineWidth;
|
||
return patternLengthPx + spacingPx;
|
||
}`,e.setStrokePatternLengthExpression(`computeStrokePatternLength(${o}, ${l}, v_width)`)}if("stroke-width"in s&&e.setStrokeWidthExpression(j(n,s["stroke-width"],N)),"stroke-offset"in s&&e.setStrokeOffsetExpression(j(n,s["stroke-offset"],N)),"stroke-line-cap"in s&&e.setStrokeCapExpression(j(n,s["stroke-line-cap"],Pe)),"stroke-line-join"in s&&e.setStrokeJoinExpression(j(n,s["stroke-line-join"],Pe)),"stroke-miter-limit"in s&&e.setStrokeMiterLimitExpression(j(n,s["stroke-miter-limit"],N)),"stroke-line-dash"in s){n.functions.getSingleDashDistance=`float getSingleDashDistance(float distance, float radius, float dashOffset, float dashLength, float dashLengthTotal, float capType, float lineWidth) {
|
||
float localDistance = mod(distance, dashLengthTotal);
|
||
float distanceSegment = abs(localDistance - dashOffset - dashLength * 0.5) - dashLength * 0.5;
|
||
distanceSegment = min(distanceSegment, dashLengthTotal - localDistance);
|
||
if (capType == ${Ht("square")}) {
|
||
distanceSegment -= lineWidth * 0.5;
|
||
} else if (capType == ${Ht("round")}) {
|
||
distanceSegment = min(distanceSegment, sqrt(distanceSegment * distanceSegment + radius * radius) - lineWidth * 0.5);
|
||
}
|
||
return distanceSegment;
|
||
}`;let i=s["stroke-line-dash"].map(g=>j(n,g,N));i.length%2===1&&(i=[...i,...i]);let r="0.";"stroke-line-dash-offset"in s&&(r=j(n,s["stroke-line-dash-offset"],N));const a=`dashDistanceField_${jr(s["stroke-line-dash"])}`,l=i.map((g,m)=>`float dashLength${m}`).join(", "),h=i.map((g,m)=>`dashLength${m}`).join(" + ");let c="0.",u=`getSingleDashDistance(distance, radius, ${c}, dashLength0, totalDashLength, capType, lineWidth)`;for(let g=2;g<i.length;g+=2)c=`${c} + dashLength${g-2} + dashLength${g-1}`,u=`min(${u}, getSingleDashDistance(distance, radius, ${c}, dashLength${g}, totalDashLength, capType, lineWidth))`;n.functions[a]=`float ${a}(float distance, float radius, float capType, float lineWidth, ${l}) {
|
||
float totalDashLength = ${h};
|
||
return ${u};
|
||
}`;const d=i.map((g,m)=>`${g}`).join(", ");e.setStrokeDistanceFieldExpression(`${a}(currentLengthPx + ${r}, currentRadiusPx, capType, v_width, ${d})`);let f=i.join(" + ");e.getStrokePatternLengthExpression()&&(n.functions.combinePatternLengths=`float combinePatternLengths(float patternLength1, float patternLength2) {
|
||
return patternLength1 * patternLength2;
|
||
}`,f=`combinePatternLengths(${e.getStrokePatternLengthExpression()}, ${f})`),e.setStrokePatternLengthExpression(f)}}function ex(s,e,t,n){if("fill-color"in s&&e.setFillColorExpression(j(n,s["fill-color"],ge)),"fill-pattern-src"in s){const i=jr(s["fill-pattern-src"]),r=th(s,e,t,"fill-pattern-",i);let o=r,a="vec2(0.)";"fill-pattern-offset"in s&&"fill-pattern-size"in s&&(o=j(n,s["fill-pattern-size"],et),a=nh(s,"fill-pattern-",n,r,o)),n.functions.sampleFillPattern=`vec4 sampleFillPattern(sampler2D texture, vec2 textureSize, vec2 textureOffset, vec2 sampleSize, vec2 pxOrigin, vec2 pxPosition) {
|
||
float scaleRatio = pow(2., mod(u_zoom + 0.5, 1.) - 0.5);
|
||
vec2 pxRelativePos = pxPosition - pxOrigin;
|
||
// rotate the relative position from origin by the current view rotation
|
||
pxRelativePos = vec2(pxRelativePos.x * cos(u_rotation) - pxRelativePos.y * sin(u_rotation), pxRelativePos.x * sin(u_rotation) + pxRelativePos.y * cos(u_rotation));
|
||
// sample position is computed according to the sample offset & size
|
||
vec2 samplePos = mod(pxRelativePos / scaleRatio, sampleSize);
|
||
// also make sure that we're not sampling too close to the borders to avoid interpolation with outside pixels
|
||
samplePos = clamp(samplePos, vec2(0.5), sampleSize - vec2(0.5));
|
||
samplePos.y = sampleSize.y - samplePos.y; // invert y axis so that images appear upright
|
||
return texture2D(texture, (samplePos + textureOffset) / textureSize);
|
||
}`;const l=`u_texture${i}`;let h="1.";"fill-color"in s&&(h=e.getFillColorExpression()),e.setFillColorExpression(`${h} * sampleFillPattern(${l}, ${r}, ${a}, ${o}, pxOrigin, pxPos)`)}}function Ec(s,e,t){const n=ud(),i=new pd,r={};if("icon-src"in s?Jy(s,i,r,n):"shape-points"in s?qy(s,i,r,n):"circle-radius"in s&&Hy(s,i,r,n),Qy(s,i,r,n),ex(s,i,r,n),t){const l=j(n,t,Se);i.setFragmentDiscardExpression(`!${l}`)}const o={};function a(l,h,c,u){if(!n[l])return;const d=$a(c),f=Jl(c);i.addAttribute(`a_${h}`,d),o[h]={size:f,callback:u}}return a("geometryType",fd,Pe,l=>Fs(Ml(l.getGeometry()))),a("featureId",dd,Pe|N,l=>{const h=l.getId()??null;return typeof h=="string"?Fs(h):h}),gd(i,n),{builder:i,attributes:{...o,...md(n)},uniforms:{...r,..._d(n,e)}}}const tx=[];let ra;function nx(){return ra||(ra=Wy()),ra}let ix=0;const ft={POSITION:"a_position",LOCAL_POSITION:"a_localPosition",SEGMENT_START:"a_segmentStart",SEGMENT_END:"a_segmentEnd",MEASURE_START:"a_measureStart",MEASURE_END:"a_measureEnd",ANGLE_TANGENT_SUM:"a_angleTangentSum",JOIN_ANGLES:"a_joinAngles",DISTANCE_LOW:"a_distanceLow",DISTANCE_HIGH:"a_distanceHigh"};class sx{constructor(e,t,n,i){this.helper_,this.hitDetectionEnabled_=!!i,this.styleShaders=rx(e,t),this.customAttributes_={},this.uniforms_={},this.hitDetectionEnabled_&&(this.customAttributes_.hitColor={callback(){return Yy(this.ref,tx)},size:2});for(const r of this.styleShaders){for(const o in r.attributes)o in this.customAttributes_||(this.customAttributes_[o]=r.attributes[o]);for(const o in r.uniforms)o in this.uniforms_||(this.uniforms_[o]=r.uniforms[o])}this.renderPasses_=this.styleShaders.map(r=>{const o={},a=Object.entries(this.customAttributes_).map(([l,h])=>({name:l in r.attributes||l==="hitColor"?`a_${l}`:null,size:h.size||1,type:De.FLOAT}));return r.builder.getFillVertexShader()&&(o.fillRenderPass={vertexShader:r.builder.getFillVertexShader(),fragmentShader:r.builder.getFillFragmentShader(),attributesDesc:[{name:ft.POSITION,size:2,type:De.FLOAT},...a],instancedAttributesDesc:[],instancePrimitiveVertexCount:3}),r.builder.getStrokeVertexShader()&&(o.strokeRenderPass={vertexShader:r.builder.getStrokeVertexShader(),fragmentShader:r.builder.getStrokeFragmentShader(),attributesDesc:[{name:ft.LOCAL_POSITION,size:2,type:De.FLOAT}],instancedAttributesDesc:[{name:ft.SEGMENT_START,size:2,type:De.FLOAT},{name:ft.MEASURE_START,size:1,type:De.FLOAT},{name:ft.SEGMENT_END,size:2,type:De.FLOAT},{name:ft.MEASURE_END,size:1,type:De.FLOAT},{name:ft.JOIN_ANGLES,size:2,type:De.FLOAT},{name:ft.DISTANCE_LOW,size:1,type:De.FLOAT},{name:ft.DISTANCE_HIGH,size:1,type:De.FLOAT},{name:ft.ANGLE_TANGENT_SUM,size:1,type:De.FLOAT},...a],instancePrimitiveVertexCount:6}),r.builder.getSymbolVertexShader()&&(o.symbolRenderPass={vertexShader:r.builder.getSymbolVertexShader(),fragmentShader:r.builder.getSymbolFragmentShader(),attributesDesc:[{name:ft.LOCAL_POSITION,size:2,type:De.FLOAT}],instancedAttributesDesc:[{name:ft.POSITION,size:2,type:De.FLOAT},...a],instancePrimitiveVertexCount:6}),o}),this.hasFill_=this.renderPasses_.some(r=>r.fillRenderPass),this.hasStroke_=this.renderPasses_.some(r=>r.strokeRenderPass),this.hasSymbol_=this.renderPasses_.some(r=>r.symbolRenderPass),this.setHelper(n)}async generateBuffers(e,t){if(e.isEmpty())return null;const n=this.generateRenderInstructions_(e,t),[i,r,o]=await Promise.all([this.generateBuffersForType_(n.polygonInstructions,"Polygon",t),this.generateBuffersForType_(n.lineStringInstructions,"LineString",t),this.generateBuffersForType_(n.pointInstructions,"Point",t)]),a=Cs(Te(),t);return{polygonBuffers:i,lineStringBuffers:r,pointBuffers:o,invertVerticesTransform:a}}generateRenderInstructions_(e,t){const n=this.hasFill_?Ky(e.polygonBatch,new Float32Array(0),this.customAttributes_,t):null,i=this.hasStroke_?Zy(e.lineStringBatch,new Float32Array(0),this.customAttributes_,t):null,r=this.hasSymbol_?Vy(e.pointBatch,new Float32Array(0),this.customAttributes_,t):null;return{polygonInstructions:n,lineStringInstructions:i,pointInstructions:r}}generateBuffersForType_(e,t,n){if(e===null)return null;const i=ix++;let r;switch(t){case"Polygon":r=sa.GENERATE_POLYGON_BUFFERS;break;case"LineString":r=sa.GENERATE_LINE_STRING_BUFFERS;break;case"Point":r=sa.GENERATE_POINT_BUFFERS;break}const o={id:i,type:r,renderInstructions:e.buffer,renderInstructionsTransform:n,customAttributesSize:go(this.customAttributes_)},a=nx();return a.postMessage(o,[e.buffer]),e=null,new Promise(l=>{const h=c=>{const u=c.data;if(u.id!==i||(a.removeEventListener("message",h),!this.helper_.getGL()))return;const d=new ea(Vl,Qo).fromArrayBuffer(u.indicesBuffer),f=new ea(Xr,Qo).fromArrayBuffer(u.vertexAttributesBuffer),g=new ea(Xr,Qo).fromArrayBuffer(u.instanceAttributesBuffer);this.helper_.flushBufferData(d),this.helper_.flushBufferData(f),this.helper_.flushBufferData(g),l([d,f,g])};a.addEventListener("message",h)})}render(e,t,n){for(const i of this.renderPasses_)i.fillRenderPass&&this.renderInternal_(e.polygonBuffers[0],e.polygonBuffers[1],e.polygonBuffers[2],i.fillRenderPass,t,n),i.strokeRenderPass&&this.renderInternal_(e.lineStringBuffers[0],e.lineStringBuffers[1],e.lineStringBuffers[2],i.strokeRenderPass,t,n),i.symbolRenderPass&&this.renderInternal_(e.pointBuffers[0],e.pointBuffers[1],e.pointBuffers[2],i.symbolRenderPass,t,n)}renderInternal_(e,t,n,i,r,o){const a=e.getSize();if(a===0)return;const l=i.instancedAttributesDesc.length;if(this.helper_.useProgram(i.program,r),this.helper_.bindBuffer(t),this.helper_.bindBuffer(e),this.helper_.enableAttributes(i.attributesDesc),this.helper_.bindBuffer(n),this.helper_.enableAttributesInstanced(i.instancedAttributesDesc),o(),l){const h=i.instancedAttributesDesc.reduce((u,d)=>u+(d.size||1),0),c=n.getSize()/h;this.helper_.drawElementsInstanced(0,a,c)}else this.helper_.drawElements(0,a)}setHelper(e,t=null){this.helper_=e;for(const n of this.renderPasses_)n.fillRenderPass&&(n.fillRenderPass.program=this.helper_.getProgram(n.fillRenderPass.fragmentShader,n.fillRenderPass.vertexShader)),n.strokeRenderPass&&(n.strokeRenderPass.program=this.helper_.getProgram(n.strokeRenderPass.fragmentShader,n.strokeRenderPass.vertexShader)),n.symbolRenderPass&&(n.symbolRenderPass.program=this.helper_.getProgram(n.symbolRenderPass.fragmentShader,n.symbolRenderPass.vertexShader));this.helper_.addUniforms(this.uniforms_),t&&(t.polygonBuffers&&(this.helper_.flushBufferData(t.polygonBuffers[0]),this.helper_.flushBufferData(t.polygonBuffers[1]),this.helper_.flushBufferData(t.polygonBuffers[2])),t.lineStringBuffers&&(this.helper_.flushBufferData(t.lineStringBuffers[0]),this.helper_.flushBufferData(t.lineStringBuffers[1]),this.helper_.flushBufferData(t.lineStringBuffers[2])),t.pointBuffers&&(this.helper_.flushBufferData(t.pointBuffers[0]),this.helper_.flushBufferData(t.pointBuffers[1]),this.helper_.flushBufferData(t.pointBuffers[2])))}}function rx(s,e){const t=Array.isArray(s)?s:[s];if("style"in t[0]){const n=[],i=t,r=[];for(const o of i){const a=Array.isArray(o.style)?o.style:[o.style];let l=o.filter;o.else&&r.length&&(l=["all",...r.map(c=>["!",c])],o.filter&&l.push(o.filter),l.length<3&&(l=l[1])),o.filter&&r.push(o.filter);const h=a.map(c=>Ec(c,e,l));n.push(...h)}return n}return"builder"in t[0]?t:t.map(n=>Ec(n,e,null))}const bt=new Uint8Array(4);class ox{constructor(e,t){this.helper_=e;const n=e.getGL();this.texture_=n.createTexture(),this.framebuffer_=n.createFramebuffer(),this.depthbuffer_=n.createRenderbuffer(),this.size_=t||[1,1],this.data_=new Uint8Array(0),this.dataCacheDirty_=!0,this.updateSize_()}setSize(e){Ut(e,this.size_)||(this.size_[0]=e[0],this.size_[1]=e[1],this.updateSize_())}getSize(){return this.size_}clearCachedData(){this.dataCacheDirty_=!0}readAll(){if(this.dataCacheDirty_){const e=this.size_,t=this.helper_.getGL();t.bindFramebuffer(t.FRAMEBUFFER,this.framebuffer_),t.readPixels(0,0,e[0],e[1],t.RGBA,t.UNSIGNED_BYTE,this.data_),this.dataCacheDirty_=!1}return this.data_}readPixel(e,t){if(e<0||t<0||e>this.size_[0]||t>=this.size_[1])return bt[0]=0,bt[1]=0,bt[2]=0,bt[3]=0,bt;this.readAll();const n=Math.floor(e)+(this.size_[1]-Math.floor(t)-1)*this.size_[0];return bt[0]=this.data_[n*4],bt[1]=this.data_[n*4+1],bt[2]=this.data_[n*4+2],bt[3]=this.data_[n*4+3],bt}getTexture(){return this.texture_}getFramebuffer(){return this.framebuffer_}getDepthbuffer(){return this.depthbuffer_}updateSize_(){const e=this.size_,t=this.helper_.getGL();this.texture_=this.helper_.createTexture(e,null,this.texture_),t.bindFramebuffer(t.FRAMEBUFFER,this.framebuffer_),t.viewport(0,0,e[0],e[1]),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,this.texture_,0),t.bindRenderbuffer(t.RENDERBUFFER,this.depthbuffer_),t.renderbufferStorage(t.RENDERBUFFER,t.DEPTH_COMPONENT16,e[0],e[1]),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.RENDERBUFFER,this.depthbuffer_),this.data_=new Uint8Array(e[0]*e[1]*4)}}function ax(s,e){const t=s.viewState.projection,i=e.getSource().getWrapX()&&t.canWrapX(),r=t.getExtent(),o=s.extent,a=i?ne(r):null,l=i?Math.ceil((o[2]-r[2])/a)+1:1;return[i?Math.floor((o[0]-r[0])/a):0,l,a]}const xi={...jt,RENDER_EXTENT:"u_renderExtent",PATTERN_ORIGIN:"u_patternOrigin",GLOBAL_ALPHA:"u_globalAlpha"};class lx extends Zl{constructor(e,t){const n={[xi.RENDER_EXTENT]:[0,0,0,0],[xi.PATTERN_ORIGIN]:[0,0],[xi.GLOBAL_ALPHA]:1};super(e,{uniforms:n,postProcesses:t.postProcesses}),this.hitDetectionEnabled_=!t.disableHitDetection,this.hitRenderTarget_,this.sourceRevision_=-1,this.previousExtent_=Je(),this.currentTransform_=Te(),this.tmpCoords_=[0,0],this.tmpTransform_=Te(),this.tmpMat4_=ld(),this.currentFrameStateTransform_=Te(),this.styleVariables_={},this.style_=[],this.styleRenderer_=null,this.buffers_=null,this.applyOptions_(t),this.batch_=new Yr,this.initialFeaturesAdded_=!1,this.sourceListenKeys_=null}addInitialFeatures_(e){const t=this.getLayer().getSource();let n;this.batch_.addFeatures(t.getFeatures(),n),this.sourceListenKeys_=[J(t,Le.ADDFEATURE,this.handleSourceFeatureAdded_.bind(this,n)),J(t,Le.CHANGEFEATURE,this.handleSourceFeatureChanged_.bind(this,n),this),J(t,Le.REMOVEFEATURE,this.handleSourceFeatureDelete_,this),J(t,Le.CLEAR,this.handleSourceFeatureClear_,this)]}applyOptions_(e){this.styleVariables_=e.variables,this.style_=e.style}createRenderers_(){this.buffers_=null,this.styleRenderer_=new sx(this.style_,this.styleVariables_,this.helper,this.hitDetectionEnabled_)}reset(e){this.applyOptions_(e),this.helper&&this.createRenderers_(),super.reset(e)}afterHelperCreated(){this.styleRenderer_?this.styleRenderer_.setHelper(this.helper,this.buffers_):this.createRenderers_(),this.hitDetectionEnabled_&&(this.hitRenderTarget_=new ox(this.helper))}handleSourceFeatureAdded_(e,t){const n=t.feature;this.batch_.addFeature(n,e)}handleSourceFeatureChanged_(e,t){const n=t.feature;this.batch_.changeFeature(n,e)}handleSourceFeatureDelete_(e){const t=e.feature;this.batch_.removeFeature(t)}handleSourceFeatureClear_(){this.batch_.clear()}applyUniforms_(e){eu(this.tmpTransform_,this.currentFrameStateTransform_),no(this.tmpTransform_,e),this.helper.setUniformMatrixValue(xi.PROJECTION_MATRIX,Ba(this.tmpMat4_,this.tmpTransform_)),Cs(this.tmpTransform_,this.tmpTransform_),this.helper.setUniformMatrixValue(xi.SCREEN_TO_WORLD_MATRIX,Ba(this.tmpMat4_,this.tmpTransform_)),this.tmpCoords_[0]=0,this.tmpCoords_[1]=0,Cs(this.tmpTransform_,e),de(this.tmpTransform_,this.tmpCoords_),this.helper.setUniformFloatVec2(xi.PATTERN_ORIGIN,this.tmpCoords_)}renderFrame(e){const t=this.helper.getGL();this.preRender(t,e);const[n,i,r]=ax(e,this.getLayer());this.helper.prepareDraw(e),this.renderWorlds(e,!1,n,i,r),this.helper.finalizeDraw(e,this.dispatchPreComposeEvent,this.dispatchPostComposeEvent);const o=this.helper.getCanvas();return this.hitDetectionEnabled_&&(this.renderWorlds(e,!0,n,i,r),this.hitRenderTarget_.clearCachedData()),this.postRender(t,e),o}prepareFrameInternal(e){this.initialFeaturesAdded_||(this.addInitialFeatures_(e),this.initialFeaturesAdded_=!0);const t=this.getLayer(),n=t.getSource(),i=e.viewState,r=!e.viewHints[he.ANIMATING]&&!e.viewHints[he.INTERACTING],o=!Kn(this.previousExtent_,e.extent),a=this.sourceRevision_<n.getRevision();if(a&&(this.sourceRevision_=n.getRevision()),r&&(o||a)){const l=i.projection,h=i.resolution,c=t instanceof Ki?t.getRenderBuffer():0,u=sn(e.extent,c*h);n.loadFeatures(u,h,l),this.ready=!1;const d=this.helper.makeProjectionTransform(e,Te());this.styleRenderer_.generateBuffers(this.batch_,d).then(f=>{this.buffers_&&this.disposeBuffers(this.buffers_),this.buffers_=f,this.ready=!0,this.getLayer().changed()}),this.previousExtent_=e.extent.slice()}return!0}renderWorlds(e,t,n,i,r){let o=n;t&&(this.hitRenderTarget_.setSize([Math.floor(e.size[0]/2),Math.floor(e.size[1]/2)]),this.helper.prepareDrawToRenderTarget(e,this.hitRenderTarget_,!0));do this.helper.makeProjectionTransform(e,this.currentFrameStateTransform_),tu(this.currentFrameStateTransform_,o*r,0),this.buffers_&&this.styleRenderer_.render(this.buffers_,e,()=>{this.applyUniforms_(this.buffers_.invertVerticesTransform),this.helper.applyHitDetectionUniform(t)});while(++o<i)}forEachFeatureAtCoordinate(e,t,n,i,r){if(te(this.hitDetectionEnabled_,"`forEachFeatureAtCoordinate` cannot be used on a WebGL layer if the hit detection logic has been disabled using the `disableHitDetection: true` option."),!this.styleRenderer_||!this.hitDetectionEnabled_)return;const o=de(t.coordinateToPixelTransform,e.slice()),a=this.hitRenderTarget_.readPixel(o[0]/2,o[1]/2),l=[a[0]/255,a[1]/255,a[2]/255,a[3]/255],h=jy(l),c=this.batch_.getFeatureFromRef(h);if(c)return i(c,this.getLayer(),null)}disposeBuffers(e){const t=n=>{for(const i of n)i&&this.helper.deleteBuffer(i)};e.pointBuffers&&t(e.pointBuffers),e.lineStringBuffers&&t(e.lineStringBuffers),e.polygonBuffers&&t(e.polygonBuffers)}disposeInternal(){this.buffers_&&this.disposeBuffers(this.buffers_),this.sourceListenKeys_&&(this.sourceListenKeys_.forEach(function(e){ue(e)}),this.sourceListenKeys_=null),super.disposeInternal()}renderDeclutter(){}}const Yt={BLUR:"blur",GRADIENT:"gradient",RADIUS:"radius"},hx=["#00f","#0ff","#0f0","#ff0","#f00"];class G0 extends Ki{constructor(e){e=e||{};const t=Object.assign({},e);delete t.gradient,delete t.radius,delete t.blur,delete t.weight,super(t),this.filter_=e.filter??!0,this.styleVariables_=e.variables||{},this.gradient_=null,this.addChangeListener(Yt.GRADIENT,this.handleGradientChanged_),this.setGradient(e.gradient?e.gradient:hx),this.setBlur(e.blur!==void 0?e.blur:15),this.setRadius(e.radius!==void 0?e.radius:8);const n=e.weight?e.weight:"weight";this.weight_=n,this.setRenderOrder(null)}getBlur(){return this.get(Yt.BLUR)}getGradient(){return this.get(Yt.GRADIENT)}getRadius(){return this.get(Yt.RADIUS)}handleGradientChanged_(){this.gradient_=cx(this.getGradient())}setBlur(e){const t=this.get(Yt.BLUR);if(this.set(Yt.BLUR,e),typeof e=="number"&&typeof t=="number"){this.changed();return}this.clearRenderer()}setGradient(e){this.set(Yt.GRADIENT,e)}setRadius(e){const t=this.get(Yt.RADIUS);if(this.set(Yt.RADIUS,e),typeof e=="number"&&typeof t=="number"){this.changed();return}this.clearRenderer()}setFilter(e){this.filter_=e,this.changed(),this.clearRenderer()}setWeight(e){this.weight_=e,this.changed(),this.clearRenderer()}createRenderer(){const e=new pd,t=ud(),n=j(t,this.filter_,Se);let i=j(t,this.getRadius(),N),r=j(t,this.getBlur(),N);const o={};typeof this.getBlur()=="number"&&(r="a_blur",o.a_blur=()=>this.getBlur(),e.addUniform("a_blur","float")),typeof this.getRadius()=="number"&&(i="a_radius",o.a_radius=()=>this.getRadius(),e.addUniform("a_radius","float"));const a={};let l=null;if(typeof this.weight_=="string"||typeof this.weight_=="function"){const u=typeof this.weight_=="string"?d=>d.get(this.weight_):this.weight_;a.prop_weight={size:1,callback:d=>{const f=u(d);return f!==void 0?fe(f,0,1):1}},l="a_prop_weight",e.addAttribute("a_prop_weight","float")}else{const u=["clamp",this.weight_,0,1];l=j(t,u,N)}e.addFragmentShaderFunction(`float getBlurSlope() {
|
||
float blur = max(1., ${r});
|
||
float radius = ${i};
|
||
return radius / blur;
|
||
}`).setSymbolSizeExpression(`vec2(${i} + ${r}) * 2.`).setSymbolColorExpression(`vec4(smoothstep(0., 1., (1. - length(coordsPx * 2. / v_quadSizePx)) * getBlurSlope()) * ${l})`).setStrokeColorExpression(`vec4(smoothstep(0., 1., (1. - length(currentRadiusPx * 2. / v_width)) * getBlurSlope()) * ${l})`).setStrokeWidthExpression(`(${i} + ${r}) * 2.`).setFillColorExpression(`vec4(${l})`).setFragmentDiscardExpression(`!${n}`),gd(e,t);const h=md(t),c=_d(t,this.styleVariables_);return new lx(this,{className:this.getClassName(),variables:this.styleVariables_,style:{builder:e,attributes:{...h,...a},uniforms:{...c,...o}},disableHitDetection:!1,postProcesses:[{fragmentShader:`
|
||
precision mediump float;
|
||
|
||
uniform sampler2D u_image;
|
||
uniform sampler2D u_gradientTexture;
|
||
uniform float u_opacity;
|
||
|
||
varying vec2 v_texCoord;
|
||
|
||
void main() {
|
||
vec4 color = texture2D(u_image, v_texCoord);
|
||
gl_FragColor.a = color.a * u_opacity;
|
||
gl_FragColor.rgb = texture2D(u_gradientTexture, vec2(0.5, color.a)).rgb;
|
||
gl_FragColor.rgb *= gl_FragColor.a;
|
||
}`,uniforms:{u_gradientTexture:()=>this.gradient_,u_opacity:()=>this.getOpacity()}}]})}updateStyleVariables(e){Object.assign(this.styleVariables_,e),this.changed()}renderDeclutter(){}}function cx(s){const n=ve(1,256),i=n.createLinearGradient(0,0,1,256),r=1/(s.length-1);for(let o=0,a=s.length;o<a;++o)i.addColorStop(o*r,s[o]);return n.fillStyle=i,n.fillRect(0,0,1,256),n.canvas}function Cn(s,e){const t=s.length;return e<0?s[e+t]:e>=t?s[e-t]:s[e]}function Pi(s,e){const t=s.length;let n=Math.floor(e);const i=e-n;n>=t?n-=t:n<0&&(n+=t);let r=n+1;r>=t&&(r-=t);const o=s[n],a=o[0],l=o[1],h=s[r],c=h[0]-a,u=h[1]-l;return[a+c*i,l+u*i]}const hr={index:-1,endIndex:NaN,closestTargetDistance:1/0};function xd(s,e,t,n){const i=s[0],r=s[1];let o=1/0,a=-1,l=NaN;for(let u=0;u<e.targets.length;++u){const d=e.targets[u],f=d.coordinates;let g=1/0,m;for(let _=0;_<f.length-1;++_){const p=f[_],y=f[_+1],E=Cd(i,r,p,y);E.squaredDistance<g&&(g=E.squaredDistance,m=_+E.along)}g<o&&(o=g,d.ring&&e.targetIndex===u&&(d.endIndex>d.startIndex?m<d.startIndex&&(m+=f.length):d.endIndex<d.startIndex&&m>d.startIndex&&(m-=f.length)),l=m,a=u)}const h=e.targets[a];let c=h.ring;if(e.targetIndex===a&&c){const u=Pi(h.coordinates,l),d=t.getPixelFromCoordinate(u),f=t.getPixelFromCoordinate(e.startCoord);Si(d,f)>n&&(c=!1)}if(c){const u=h.coordinates,d=u.length,f=h.startIndex,g=l;if(f<g){const m=dr(u,f,g);dr(u,f,g-d)<m&&(l-=d)}else{const m=dr(u,f,g);dr(u,f,g+d)<m&&(l+=d)}}return hr.index=a,hr.endIndex=l,hr.closestTargetDistance=o,hr}function Ed(s,e){const t=[];for(let n=0;n<e.length;++n){const r=e[n].getGeometry();Td(s,r,t)}return t}function Td(s,e,t){if(e instanceof at){cr(s,e.getCoordinates(),!1,t);return}if(e instanceof rn){const n=e.getCoordinates();for(let i=0,r=n.length;i<r;++i)cr(s,n[i],!1,t);return}if(e instanceof Qe){const n=e.getCoordinates();for(let i=0,r=n.length;i<r;++i)cr(s,n[i],!0,t);return}if(e instanceof In){const n=e.getCoordinates();for(let i=0,r=n.length;i<r;++i){const o=n[i];for(let a=0,l=o.length;a<l;++a)cr(s,o[a],!0,t)}return}if(e instanceof Ze){const n=e.getGeometries();for(let i=0;i<n.length;++i)Td(s,n[i],t);return}}function cr(s,e,t,n){const i=s[0],r=s[1];for(let o=0,a=e.length-1;o<a;++o){const l=e[o],h=e[o+1],c=Cd(i,r,l,h);if(c.squaredDistance===0){const u=o+c.along;n.push({coordinates:e,ring:t,startIndex:u,endIndex:u});return}}}function ur(s,e){return Jt(s[0],s[1],e[0],e[1])}function dr(s,e,t){let n,i;e<t?(n=e,i=t):(n=t,i=e);const r=Math.ceil(n),o=Math.floor(i);if(r>o){const l=Pi(s,n),h=Pi(s,i);return ur(l,h)}let a=0;if(n<r){const l=Pi(s,n),h=Cn(s,r);a+=ur(l,h)}if(o<i){const l=Cn(s,o),h=Pi(s,i);a+=ur(l,h)}for(let l=r;l<o-1;++l){const h=Cn(s,l),c=Cn(s,l+1);a+=ur(h,c)}return a}const oa={along:0,squaredDistance:0};function Cd(s,e,t,n){const i=t[0],r=t[1],o=n[0],a=n[1],l=o-i,h=a-r;let c=0,u=i,d=r;return(l!==0||h!==0)&&(c=fe(((s-i)*l+(e-r)*h)/(l*l+h*h),0,1),u+=l*c,d+=h*c),oa.along=c,oa.squaredDistance=Xi(Jt(s,e,u,d),10),oa}const fr={DRAWSTART:"drawstart",DRAWEND:"drawend",DRAWABORT:"drawabort"};class gr extends Tt{constructor(e,t){super(e),this.feature=t}}class k0 extends ii{constructor(e){const t=e;t.stopDown||(t.stopDown=$i),super(t),this.on,this.once,this.un,this.options_=e,this.shouldHandle_=!1,this.downPx_=null,this.downTimeout_,this.lastDragTime_,this.pointerType_,this.freehand_=!1,this.source_=e.source?e.source:null,this.features_=e.features?e.features:null,this.snapTolerance_=e.snapTolerance?e.snapTolerance:12,this.type_=e.type,this.mode_=dx(this.type_),this.stopClick_=!!e.stopClick,this.ignoreNextUpEvent_=!1,this.minPoints_=e.minPoints?e.minPoints:this.mode_==="Polygon"?3:2,this.maxPoints_=this.mode_==="Circle"?2:e.maxPoints?e.maxPoints:1/0,this.finishCondition_=e.finishCondition?e.finishCondition:wn,this.geometryLayout_=e.geometryLayout?e.geometryLayout:"XY";let n=e.geometryFunction;if(!n){const i=this.mode_;if(i==="Circle")n=(r,o,a)=>{const l=o||new fo([NaN,NaN]),h=me(r[0]),c=Ni(h,me(r[r.length-1]));return l.setCenterAndRadius(h,Math.sqrt(c),this.geometryLayout_),l};else{let r;i==="Point"?r=ot:i==="LineString"?r=at:i==="Polygon"&&(r=Qe),n=(o,a,l)=>(a?i==="Polygon"?o[0].length?a.setCoordinates([o[0].concat([o[0][0]])],this.geometryLayout_):a.setCoordinates([],this.geometryLayout_):a.setCoordinates(o,this.geometryLayout_):a=new r(o,this.geometryLayout_),a)}}this.geometryFunction_=n,this.dragVertexDelay_=e.dragVertexDelay!==void 0?e.dragVertexDelay:500,this.finishCoordinate_=null,this.sketchFeature_=null,this.sketchPoint_=null,this.sketchCoords_=null,this.sketchLine_=null,this.sketchLineCoords_=null,this.squaredClickTolerance_=e.clickTolerance?e.clickTolerance*e.clickTolerance:36,this.overlay_=new zl({source:new ed({useSpatialIndex:!1,wrapX:e.wrapX?e.wrapX:!1}),style:e.style?e.style:ux(),updateWhileInteracting:!0}),this.geometryName_=e.geometryName,this.condition_=e.condition?e.condition:Sl,this.freehandCondition_,e.freehand?this.freehandCondition_=Li:this.freehandCondition_=e.freehandCondition?e.freehandCondition:Mr,this.traceCondition_,this.setTrace(e.trace||!1),this.traceState_={active:!1},this.traceSource_=e.traceSource||e.source||null,this.addChangeListener(Ia.ACTIVE,this.updateState_)}setTrace(e){let t;e?e===!0?t=Li:t=e:t=br,this.traceCondition_=t}setMap(e){super.setMap(e),this.updateState_()}setFreehand(e){this.freehand_=e,this.freehand_?this.freehandCondition_=Li:this.freehandCondition_=this.options_&&this.options_.freehandCondition?this.options_.freehandCondition:Mr}getOverlay(){return this.overlay_}getFreehand(){return this.freehand_}handleEvent(e){e.originalEvent.type===V.CONTEXTMENU&&e.originalEvent.preventDefault(),this.freehand_=this.mode_!=="Point"&&this.freehandCondition_(e);let t=e.type===ee.POINTERMOVE,n=!0;return!this.freehand_&&this.lastDragTime_&&e.type===ee.POINTERDRAG&&(Date.now()-this.lastDragTime_>=this.dragVertexDelay_?(this.downPx_=e.pixel,this.shouldHandle_=!this.freehand_,t=!0):this.lastDragTime_=void 0,this.shouldHandle_&&this.downTimeout_!==void 0&&(clearTimeout(this.downTimeout_),this.downTimeout_=void 0)),this.freehand_&&e.type===ee.POINTERDRAG&&this.sketchFeature_!==null?(this.addToDrawing_(e.coordinate),n=!1):this.freehand_&&e.type===ee.POINTERDOWN?n=!1:t&&this.getPointerCount()<2?(n=e.type===ee.POINTERMOVE,n&&this.freehand_?(this.handlePointerMove_(e),this.shouldHandle_&&e.originalEvent.preventDefault()):(e.originalEvent.pointerType==="mouse"||e.type===ee.POINTERDRAG&&this.downTimeout_===void 0)&&this.handlePointerMove_(e)):e.type===ee.DBLCLICK&&(n=!1),super.handleEvent(e)&&n}handleDownEvent(e){return this.shouldHandle_=!this.freehand_,this.freehand_?(this.downPx_=e.pixel,this.finishCoordinate_||this.startDrawing_(e.coordinate),!0):this.condition_(e)?(this.lastDragTime_=Date.now(),this.downTimeout_=setTimeout(()=>{this.handlePointerMove_(new Vt(ee.POINTERMOVE,e.map,e.originalEvent,!1,e.frameState))},this.dragVertexDelay_),this.downPx_=e.pixel,!0):(this.lastDragTime_=void 0,!1)}deactivateTrace_(){this.traceState_={active:!1}}toggleTraceState_(e){if(!this.traceSource_||!this.traceCondition_(e))return;if(this.traceState_.active){this.deactivateTrace_();return}const t=this.getMap(),n=t.getCoordinateFromPixel([e.pixel[0]-this.snapTolerance_,e.pixel[1]+this.snapTolerance_]),i=t.getCoordinateFromPixel([e.pixel[0]+this.snapTolerance_,e.pixel[1]-this.snapTolerance_]),r=Be([n,i]),o=this.traceSource_.getFeaturesInExtent(r);if(o.length===0)return;const a=Ed(e.coordinate,o);a.length&&(this.traceState_={active:!0,startCoord:e.coordinate.slice(),targets:a,targetIndex:-1})}addOrRemoveTracedCoordinates_(e,t){const n=e.startIndex<=e.endIndex,i=e.startIndex<=t;n===i?n&&t>e.endIndex||!n&&t<e.endIndex?this.addTracedCoordinates_(e,e.endIndex,t):(n&&t<e.endIndex||!n&&t>e.endIndex)&&this.removeTracedCoordinates_(t,e.endIndex):(this.removeTracedCoordinates_(e.startIndex,e.endIndex),this.addTracedCoordinates_(e,e.startIndex,t))}removeTracedCoordinates_(e,t){if(e===t)return;let n=0;if(e<t){const i=Math.ceil(e);let r=Math.floor(t);r===t&&(r-=1),n=r-i+1}else{const i=Math.floor(e);let r=Math.ceil(t);r===t&&(r+=1),n=i-r+1}n>0&&this.removeLastPoints_(n)}addTracedCoordinates_(e,t,n){if(t===n)return;const i=[];if(t<n){const r=Math.ceil(t);let o=Math.floor(n);o===n&&(o-=1);for(let a=r;a<=o;++a)i.push(Cn(e.coordinates,a))}else{const r=Math.floor(t);let o=Math.ceil(n);o===n&&(o+=1);for(let a=r;a>=o;--a)i.push(Cn(e.coordinates,a))}i.length&&this.appendCoordinates(i)}updateTrace_(e){const t=this.traceState_;if(!t.active)return;if(t.targetIndex===-1){const a=e.map.getPixelFromCoordinate(t.startCoord);if(Si(a,e.pixel)<this.snapTolerance_)return}const n=xd(e.coordinate,t,this.getMap(),this.snapTolerance_);if(t.targetIndex!==n.index){if(t.targetIndex!==-1){const l=t.targets[t.targetIndex];this.removeTracedCoordinates_(l.startIndex,l.endIndex)}const a=t.targets[n.index];this.addTracedCoordinates_(a,a.startIndex,n.endIndex)}else{const a=t.targets[t.targetIndex];this.addOrRemoveTracedCoordinates_(a,n.endIndex)}t.targetIndex=n.index;const i=t.targets[t.targetIndex];i.endIndex=n.endIndex;const r=Pi(i.coordinates,i.endIndex),o=this.getMap().getPixelFromCoordinate(r);e.coordinate=r,e.pixel=[Math.round(o[0]),Math.round(o[1])]}handleDragEvent(e){this.ignoreNextUpEvent_=!0,super.handleDragEvent(e)}handleUpEvent(e){let t=!0;if(this.getPointerCount()===0){this.downTimeout_&&(clearTimeout(this.downTimeout_),this.downTimeout_=void 0),this.handlePointerMove_(e);const n=this.traceState_.active;if(this.ignoreNextUpEvent_||this.toggleTraceState_(e),this.shouldHandle_){const i=!this.finishCoordinate_;i&&this.startDrawing_(e.coordinate),!i&&this.freehand_?this.finishDrawing():!this.freehand_&&(!i||this.mode_==="Point")&&(this.atFinish_(e.pixel,n)?this.finishCondition_(e)&&this.finishDrawing():this.addToDrawing_(e.coordinate)),t=!1}else this.freehand_&&this.abortDrawing()}return this.ignoreNextUpEvent_=!1,!t&&this.stopClick_&&e.preventDefault(),t}handlePointerMove_(e){if(this.pointerType_=e.originalEvent.pointerType,this.downPx_&&(!this.freehand_&&this.shouldHandle_||this.freehand_&&!this.shouldHandle_)){const t=this.downPx_,n=e.pixel,i=t[0]-n[0],r=t[1]-n[1],o=i*i+r*r;if(this.shouldHandle_=this.freehand_?o>this.squaredClickTolerance_:o<=this.squaredClickTolerance_,!this.shouldHandle_)return}if(!this.finishCoordinate_){this.createOrUpdateSketchPoint_(e.coordinate.slice());return}this.updateTrace_(e),this.modifyDrawing_(e.coordinate)}atFinish_(e,t){let n=!1;if(this.sketchFeature_){let i=!1,r=[this.finishCoordinate_];const o=this.mode_;if(o==="Point")n=!0;else if(o==="Circle")n=this.sketchCoords_.length===2;else if(o==="LineString")i=!t&&this.sketchCoords_.length>this.minPoints_;else if(o==="Polygon"){const a=this.sketchCoords_;i=a[0].length>this.minPoints_,r=[a[0][0],a[0][a[0].length-2]],t?r=[a[0][0]]:r=[a[0][0],a[0][a[0].length-2]]}if(i){const a=this.getMap();for(let l=0,h=r.length;l<h;l++){const c=r[l],u=a.getPixelFromCoordinate(c),d=e[0]-u[0],f=e[1]-u[1],g=this.freehand_?1:this.snapTolerance_;if(n=Math.sqrt(d*d+f*f)<=g,n){this.finishCoordinate_=c;break}}}}return n}createOrUpdateSketchPoint_(e){this.sketchPoint_?this.sketchPoint_.getGeometry().setCoordinates(e):(this.sketchPoint_=new ze(new ot(e)),this.updateSketchFeatures_())}createOrUpdateCustomSketchLine_(e){this.sketchLine_||(this.sketchLine_=new ze);const t=e.getLinearRing(0);let n=this.sketchLine_.getGeometry();n?(n.setFlatCoordinates(t.getLayout(),t.getFlatCoordinates()),n.changed()):(n=new at(t.getFlatCoordinates(),t.getLayout()),this.sketchLine_.setGeometry(n))}startDrawing_(e){const t=this.getMap().getView().getProjection(),n=Lr(this.geometryLayout_);for(;e.length<n;)e.push(0);this.finishCoordinate_=e,this.mode_==="Point"?this.sketchCoords_=e.slice():this.mode_==="Polygon"?(this.sketchCoords_=[[e.slice(),e.slice()]],this.sketchLineCoords_=this.sketchCoords_[0]):this.sketchCoords_=[e.slice(),e.slice()],this.sketchLineCoords_&&(this.sketchLine_=new ze(new at(this.sketchLineCoords_)));const i=this.geometryFunction_(this.sketchCoords_,void 0,t);this.sketchFeature_=new ze,this.geometryName_&&this.sketchFeature_.setGeometryName(this.geometryName_),this.sketchFeature_.setGeometry(i),this.updateSketchFeatures_(),this.dispatchEvent(new gr(fr.DRAWSTART,this.sketchFeature_))}modifyDrawing_(e){const t=this.getMap(),n=this.sketchFeature_.getGeometry(),i=t.getView().getProjection(),r=Lr(this.geometryLayout_);let o,a;for(;e.length<r;)e.push(0);this.mode_==="Point"?a=this.sketchCoords_:this.mode_==="Polygon"?(o=this.sketchCoords_[0],a=o[o.length-1],this.atFinish_(t.getPixelFromCoordinate(e))&&(e=this.finishCoordinate_.slice())):(o=this.sketchCoords_,a=o[o.length-1]),a[0]=e[0],a[1]=e[1],this.geometryFunction_(this.sketchCoords_,n,i),this.sketchPoint_&&this.sketchPoint_.getGeometry().setCoordinates(e),n.getType()==="Polygon"&&this.mode_!=="Polygon"?this.createOrUpdateCustomSketchLine_(n):this.sketchLineCoords_&&this.sketchLine_.getGeometry().setCoordinates(this.sketchLineCoords_),this.updateSketchFeatures_()}addToDrawing_(e){const t=this.sketchFeature_.getGeometry(),n=this.getMap().getView().getProjection();let i,r;const o=this.mode_;return o==="LineString"||o==="Circle"?(this.finishCoordinate_=e.slice(),r=this.sketchCoords_,r.length>=this.maxPoints_&&(this.freehand_?r.pop():i=!0),r.push(e.slice()),this.geometryFunction_(r,t,n)):o==="Polygon"&&(r=this.sketchCoords_[0],r.length>=this.maxPoints_&&(this.freehand_?r.pop():i=!0),r.push(e.slice()),i&&(this.finishCoordinate_=r[0]),this.geometryFunction_(this.sketchCoords_,t,n)),this.createOrUpdateSketchPoint_(e.slice()),this.updateSketchFeatures_(),i?this.finishDrawing():this.sketchFeature_}removeLastPoints_(e){if(!this.sketchFeature_)return;const t=this.sketchFeature_.getGeometry(),n=this.getMap().getView().getProjection(),i=this.mode_;for(let r=0;r<e;++r){let o;if(i==="LineString"||i==="Circle"){if(o=this.sketchCoords_,o.splice(-2,1),o.length>=2){this.finishCoordinate_=o[o.length-2].slice();const a=this.finishCoordinate_.slice();o[o.length-1]=a,this.createOrUpdateSketchPoint_(a)}this.geometryFunction_(o,t,n),t.getType()==="Polygon"&&this.sketchLine_&&this.createOrUpdateCustomSketchLine_(t)}else if(i==="Polygon"){o=this.sketchCoords_[0],o.splice(-2,1);const a=this.sketchLine_.getGeometry();if(o.length>=2){const l=o[o.length-2].slice();o[o.length-1]=l,this.createOrUpdateSketchPoint_(l)}a.setCoordinates(o),this.geometryFunction_(this.sketchCoords_,t,n)}if(o.length===1){this.abortDrawing();break}}this.updateSketchFeatures_()}removeLastPoint(){this.removeLastPoints_(1)}finishDrawing(){const e=this.abortDrawing_();if(!e)return null;let t=this.sketchCoords_;const n=e.getGeometry(),i=this.getMap().getView().getProjection();return this.mode_==="LineString"?(t.pop(),this.geometryFunction_(t,n,i)):this.mode_==="Polygon"&&(t[0].pop(),this.geometryFunction_(t,n,i),t=n.getCoordinates()),this.type_==="MultiPoint"?e.setGeometry(new ri([t])):this.type_==="MultiLineString"?e.setGeometry(new rn([t])):this.type_==="MultiPolygon"&&e.setGeometry(new In([t])),this.dispatchEvent(new gr(fr.DRAWEND,e)),this.features_&&this.features_.push(e),this.source_&&this.source_.addFeature(e),e}abortDrawing_(){this.finishCoordinate_=null;const e=this.sketchFeature_;return this.sketchFeature_=null,this.sketchPoint_=null,this.sketchLine_=null,this.overlay_.getSource().clear(!0),this.deactivateTrace_(),e}abortDrawing(){const e=this.abortDrawing_();e&&this.dispatchEvent(new gr(fr.DRAWABORT,e))}appendCoordinates(e){const t=this.mode_,n=!this.sketchFeature_;n&&this.startDrawing_(e[0]);let i;if(t==="LineString"||t==="Circle")i=this.sketchCoords_;else if(t==="Polygon")i=this.sketchCoords_&&this.sketchCoords_.length?this.sketchCoords_[0]:[];else return;n&&i.shift(),i.pop();for(let o=0;o<e.length;o++)this.addToDrawing_(e[o]);const r=e[e.length-1];this.sketchFeature_=this.addToDrawing_(r),this.modifyDrawing_(r)}extend(e){const n=e.getGeometry();this.sketchFeature_=e,this.sketchCoords_=n.getCoordinates();const i=this.sketchCoords_[this.sketchCoords_.length-1];this.finishCoordinate_=i.slice(),this.sketchCoords_.push(i.slice()),this.sketchPoint_=new ze(new ot(i)),this.updateSketchFeatures_(),this.dispatchEvent(new gr(fr.DRAWSTART,this.sketchFeature_))}updateSketchFeatures_(){const e=[];this.sketchFeature_&&e.push(this.sketchFeature_),this.sketchLine_&&e.push(this.sketchLine_),this.sketchPoint_&&e.push(this.sketchPoint_);const t=this.overlay_.getSource();t.clear(!0),t.addFeatures(e)}updateState_(){const e=this.getMap(),t=this.getActive();(!e||!t)&&this.abortDrawing(),this.overlay_.setMap(t?e:null)}}function ux(){const s=Dl();return function(e,t){return s[e.getGeometry().getType()]}}function dx(s){switch(s){case"Point":case"MultiPoint":return"Point";case"LineString":case"MultiLineString":return"LineString";case"Polygon":case"MultiPolygon":return"Polygon";case"Circle":return"Circle";default:throw new Error("Invalid type: "+s)}}const _r={SELECT:"select"};class mr extends Tt{constructor(e,t,n,i){super(e),this.selected=t,this.deselected=n,this.mapBrowserEvent=i}}const pr={};class Rd extends ji{constructor(e){super(),this.on,this.once,this.un,e=e||{},this.boundAddFeature_=this.addFeature_.bind(this),this.boundRemoveFeature_=this.removeFeature_.bind(this),this.condition_=e.condition?e.condition:yu,this.addCondition_=e.addCondition?e.addCondition:br,this.removeCondition_=e.removeCondition?e.removeCondition:br,this.toggleCondition_=e.toggleCondition?e.toggleCondition:Mr,this.multi_=e.multi?e.multi:!1,this.filter_=e.filter?e.filter:wn,this.hitTolerance_=e.hitTolerance?e.hitTolerance:0,this.style_=e.style!==void 0?e.style:fx(),this.features_=e.features||new Ve;let t;if(e.layers)if(typeof e.layers=="function")t=e.layers;else{const n=e.layers;t=function(i){return n.includes(i)}}else t=wn;this.layerFilter_=t,this.featureLayerAssociation_={}}addFeatureLayerAssociation_(e,t){this.featureLayerAssociation_[D(e)]=t}getFeatures(){return this.features_}getHitTolerance(){return this.hitTolerance_}getLayer(e){return this.featureLayerAssociation_[D(e)]}setHitTolerance(e){this.hitTolerance_=e}setMap(e){this.getMap()&&this.style_&&this.features_.forEach(this.restorePreviousStyle_.bind(this)),super.setMap(e),e?(this.features_.addEventListener(Re.ADD,this.boundAddFeature_),this.features_.addEventListener(Re.REMOVE,this.boundRemoveFeature_),this.style_&&this.features_.forEach(this.applySelectedStyle_.bind(this))):(this.features_.removeEventListener(Re.ADD,this.boundAddFeature_),this.features_.removeEventListener(Re.REMOVE,this.boundRemoveFeature_))}addFeature_(e){const t=e.element;if(this.style_&&this.applySelectedStyle_(t),!this.getLayer(t)){const n=this.findLayerOfFeature_(t);n&&this.addFeatureLayerAssociation_(t,n)}}removeFeature_(e){this.style_&&this.restorePreviousStyle_(e.element)}findLayerOfFeature_(e){return this.getMap().getAllLayers().find(function(n){if(n instanceof zl&&n.getSource()&&n.getSource().hasFeature(e))return n})}getStyle(){return this.style_}applySelectedStyle_(e){const t=D(e);t in pr||(pr[t]=e.getStyle()),e.setStyle(this.style_)}restorePreviousStyle_(e){const t=this.getMap().getInteractions().getArray();for(let i=t.length-1;i>=0;--i){const r=t[i];if(r!==this&&r instanceof Rd&&r.getStyle()&&r.getFeatures().getArray().lastIndexOf(e)!==-1){e.setStyle(r.getStyle());return}}const n=D(e);e.setStyle(pr[n]),delete pr[n]}removeFeatureLayerAssociation_(e){delete this.featureLayerAssociation_[D(e)]}selectFeatureInternal_(e,t,n){if(!(e instanceof ze)||!this.filter_(e,t))return;const i=this.getFeatures();return i.getArray().includes(e)||(this.addFeatureLayerAssociation_(e,t),i.push(e),n?.push(e)),e}selectFeature(e){const t=this.findLayerOfFeature_(e);if(!this.layerFilter_(t))return!1;const n=this.selectFeatureInternal_(e,t);return n&&this.dispatchEvent(new mr(_r.SELECT,[n],[],void 0)),!!n}removeFeatureInternal_(e,t){const n=this.getFeatures();if(!(!(e instanceof ze)||!n.getArray().includes(e)))return n.remove(e),this.removeFeatureLayerAssociation_(e),t?.push(e),e}deselectFeature(e){const t=this.removeFeatureInternal_(e);return t&&this.dispatchEvent(new mr(_r.SELECT,[],[t],void 0)),!!t}toggleFeature(e){this.deselectFeature(e)||this.selectFeature(e)}clearSelection(){Qn(this.featureLayerAssociation_);const e=this.getFeatures(),t=e.getArray().slice();e.clear(),t.length!==0&&this.dispatchEvent(new mr(_r.SELECT,[],t,void 0))}handleEvent(e){if(!this.condition_(e))return!0;const t=this.addCondition_(e),n=this.removeCondition_(e),i=this.toggleCondition_(e),r=!t&&!n&&!i,o=e.map,a=this.getFeatures(),l=[],h=[];if(r){let c=!1;o.forEachFeatureAtPixel(e.pixel,(u,d)=>{if(c=!0,!!this.selectFeatureInternal_(u,d,h))return!this.multi_},{layerFilter:this.layerFilter_,hitTolerance:this.hitTolerance_});for(let u=a.getLength()-1;u>=0;--u){const d=a.item(u);(h.length>0&&!h.includes(d)||!c)&&this.removeFeatureInternal_(d,l)}}else o.forEachFeatureAtPixel(e.pixel,(c,u)=>{let d;if((n||i)&&(d=this.removeFeatureInternal_(c,l)),(t||i)&&!d&&(d=this.selectFeatureInternal_(c,u,h)),!!d)return!this.multi_},{layerFilter:this.layerFilter_,hitTolerance:this.hitTolerance_});return(h.length>0||l.length>0)&&this.dispatchEvent(new mr(_r.SELECT,h,l,e)),!0}}function fx(){const s=Dl();return se(s.Polygon,s.LineString),se(s.GeometryCollection,s.LineString),function(e){return e.getGeometry()?s[e.getGeometry().getType()]:null}}const Tc=0,ms=1,Cc=[0,0,0,0],bi=[],aa={MODIFYSTART:"modifystart",MODIFYEND:"modifyend"};function la(s,e,t){let n;switch(e){case"LineString":n=s;break;case"MultiLineString":case"Polygon":n=s[t[0]];break;case"MultiPolygon":n=s[t[1]][t[0]];break}return n}class ha extends Tt{constructor(e,t,n){super(e),this.features=t,this.mapBrowserEvent=n}}class U0 extends ii{constructor(e){super(e),this.on,this.once,this.un,this.boundHandleFeatureChange_=this.handleFeatureChange_.bind(this),this.condition_=e.condition?e.condition:Eu,this.defaultDeleteCondition_=function(n){return n_(n)&&yu(n)},this.deleteCondition_=e.deleteCondition?e.deleteCondition:this.defaultDeleteCondition_,this.insertVertexCondition_=e.insertVertexCondition?e.insertVertexCondition:Li,this.vertexFeature_=null,this.vertexSegments_=null,this.lastCoordinate_=[0,0],this.ignoreNextSingleClick_=!1,this.featuresBeingModified_=null,this.rBush_=new Ga,this.pixelTolerance_=e.pixelTolerance!==void 0?e.pixelTolerance:10,this.snappedToVertex_=!1,this.changingFeature_=!1,this.dragSegments_=[],this.overlay_=new zl({source:new ed({useSpatialIndex:!1,wrapX:!!e.wrapX}),style:e.style?e.style:_x(),updateWhileAnimating:!0,updateWhileInteracting:!0}),this.SEGMENT_WRITERS_={Point:this.writePointGeometry_.bind(this),LineString:this.writeLineStringGeometry_.bind(this),LinearRing:this.writeLineStringGeometry_.bind(this),Polygon:this.writePolygonGeometry_.bind(this),MultiPoint:this.writeMultiPointGeometry_.bind(this),MultiLineString:this.writeMultiLineStringGeometry_.bind(this),MultiPolygon:this.writeMultiPolygonGeometry_.bind(this),Circle:this.writeCircleGeometry_.bind(this),GeometryCollection:this.writeGeometryCollectionGeometry_.bind(this)},this.source_=null,this.traceSource_=e.traceSource||e.source||null,this.traceCondition_,this.setTrace(e.trace||!1),this.traceState_={active:!1},this.traceSegments_=null,this.hitDetection_=null;let t;if(e.features?t=e.features:e.source&&(this.source_=e.source,t=new Ve(this.source_.getFeatures()),this.source_.addEventListener(Le.ADDFEATURE,this.handleSourceAdd_.bind(this)),this.source_.addEventListener(Le.REMOVEFEATURE,this.handleSourceRemove_.bind(this))),!t)throw new Error("The modify interaction requires features, a source or a layer");e.hitDetection&&(this.hitDetection_=e.hitDetection),this.features_=t,this.features_.forEach(this.addFeature_.bind(this)),this.features_.addEventListener(Re.ADD,this.handleFeatureAdd_.bind(this)),this.features_.addEventListener(Re.REMOVE,this.handleFeatureRemove_.bind(this)),this.lastPointerEvent_=null,this.delta_=[0,0],this.snapToPointer_=e.snapToPointer===void 0?!this.hitDetection_:e.snapToPointer}setTrace(e){let t;e?e===!0?t=Li:t=e:t=br,this.traceCondition_=t}addFeature_(e){const t=e.getGeometry();if(t){const i=this.SEGMENT_WRITERS_[t.getType()];i&&i(e,t)}const n=this.getMap();n&&n.isRendered()&&this.getActive()&&this.handlePointerAtPixel_(this.lastCoordinate_),e.addEventListener(V.CHANGE,this.boundHandleFeatureChange_)}willModifyFeatures_(e,t){if(!this.featuresBeingModified_){this.featuresBeingModified_=new Ve;const n=this.featuresBeingModified_.getArray();for(let i=0,r=t.length;i<r;++i){const o=t[i].feature;o&&!n.includes(o)&&this.featuresBeingModified_.push(o)}this.featuresBeingModified_.getLength()===0?this.featuresBeingModified_=null:this.dispatchEvent(new ha(aa.MODIFYSTART,this.featuresBeingModified_,e))}}removeFeature_(e){this.removeFeatureSegmentData_(e),this.vertexFeature_&&this.features_.getLength()===0&&(this.overlay_.getSource().removeFeature(this.vertexFeature_),this.vertexFeature_=null),e.removeEventListener(V.CHANGE,this.boundHandleFeatureChange_)}removeFeatureSegmentData_(e){const t=this.rBush_,n=[];t.forEach(function(i){e===i.feature&&n.push(i)});for(let i=n.length-1;i>=0;--i){const r=n[i];for(let o=this.dragSegments_.length-1;o>=0;--o)this.dragSegments_[o][0]===r&&this.dragSegments_.splice(o,1);t.remove(r)}}setActive(e){this.vertexFeature_&&!e&&(this.overlay_.getSource().removeFeature(this.vertexFeature_),this.vertexFeature_=null),super.setActive(e)}setMap(e){this.overlay_.setMap(e),super.setMap(e)}getOverlay(){return this.overlay_}handleSourceAdd_(e){e.feature&&this.features_.push(e.feature)}handleSourceRemove_(e){e.feature&&this.features_.remove(e.feature)}handleFeatureAdd_(e){this.addFeature_(e.element)}handleFeatureChange_(e){if(!this.changingFeature_){const t=e.target;this.removeFeature_(t),this.addFeature_(t)}}handleFeatureRemove_(e){this.removeFeature_(e.element)}writePointGeometry_(e,t){const n=t.getCoordinates(),i={feature:e,geometry:t,segment:[n,n]};this.rBush_.insert(t.getExtent(),i)}writeMultiPointGeometry_(e,t){const n=t.getCoordinates();for(let i=0,r=n.length;i<r;++i){const o=n[i],a={feature:e,geometry:t,depth:[i],index:i,segment:[o,o]};this.rBush_.insert(t.getExtent(),a)}}writeLineStringGeometry_(e,t){const n=t.getCoordinates();for(let i=0,r=n.length-1;i<r;++i){const o=n.slice(i,i+2),a={feature:e,geometry:t,index:i,segment:o};this.rBush_.insert(Be(o),a)}}writeMultiLineStringGeometry_(e,t){const n=t.getCoordinates();for(let i=0,r=n.length;i<r;++i){const o=n[i];for(let a=0,l=o.length-1;a<l;++a){const h=o.slice(a,a+2),c={feature:e,geometry:t,depth:[i],index:a,segment:h};this.rBush_.insert(Be(h),c)}}}writePolygonGeometry_(e,t){const n=t.getCoordinates();for(let i=0,r=n.length;i<r;++i){const o=n[i];for(let a=0,l=o.length-1;a<l;++a){const h=o.slice(a,a+2),c={feature:e,geometry:t,depth:[i],index:a,segment:h};this.rBush_.insert(Be(h),c)}}}writeMultiPolygonGeometry_(e,t){const n=t.getCoordinates();for(let i=0,r=n.length;i<r;++i){const o=n[i];for(let a=0,l=o.length;a<l;++a){const h=o[a];for(let c=0,u=h.length-1;c<u;++c){const d=h.slice(c,c+2),f={feature:e,geometry:t,depth:[a,i],index:c,segment:d};this.rBush_.insert(Be(d),f)}}}}writeCircleGeometry_(e,t){const n=t.getCenter(),i={feature:e,geometry:t,index:Tc,segment:[n,n]},r={feature:e,geometry:t,index:ms,segment:[n,n]},o=[i,r];i.featureSegments=o,r.featureSegments=o,this.rBush_.insert(ds(n),i);let a=t;this.rBush_.insert(a.getExtent(),r)}writeGeometryCollectionGeometry_(e,t){const n=t.getGeometriesArray();for(let i=0;i<n.length;++i){const r=n[i],o=this.SEGMENT_WRITERS_[r.getType()];o(e,r)}}createOrUpdateVertexFeature_(e,t,n,i){let r=this.vertexFeature_;return r?r.getGeometry().setCoordinates(e):(r=new ze(new ot(e)),this.vertexFeature_=r,this.overlay_.getSource().addFeature(r)),r.set("features",t),r.set("geometries",n),r.set("existing",i),r}handleEvent(e){if(!e.originalEvent)return!0;this.lastPointerEvent_=e;let t;return!e.map.getView().getInteracting()&&e.type==ee.POINTERMOVE&&!this.handlingDownUpSequence&&this.handlePointerMove_(e),this.vertexFeature_&&this.deleteCondition_(e)&&(e.type!=ee.SINGLECLICK||!this.ignoreNextSingleClick_?t=this.removePoint():t=!0),e.type==ee.SINGLECLICK&&(this.ignoreNextSingleClick_=!1),super.handleEvent(e)&&!t}findInsertVerticesAndUpdateDragSegments_(e){if(this.handlePointerAtPixel_(e),this.dragSegments_.length=0,this.featuresBeingModified_=null,!this.vertexFeature_)return;this.getMap().getView().getProjection();const n=[],i=this.vertexFeature_.getGeometry().getCoordinates(),r=Be([i]),o=this.rBush_.getInExtent(r),a={};o.sort(gx);for(let l=0,h=o.length;l<h;++l){const c=o[l],u=c.segment;let d=D(c.geometry);const f=c.depth;if(f&&(d+="-"+f.join("-")),a[d]||(a[d]=new Array(2)),c.geometry.getType()==="Circle"&&c.index===ms){const g=Sc(e,c);je(g,i)&&!a[d][0]&&(this.dragSegments_.push([c,0]),a[d][0]=c);continue}if(je(u[0],i)&&!a[d][0]){this.dragSegments_.push([c,0]),a[d][0]=c;continue}if(je(u[1],i)&&!a[d][1]){if(a[d][0]&&a[d][0].index===0){let g=c.geometry.getCoordinates();switch(c.geometry.getType()){case"LineString":case"MultiLineString":continue;case"MultiPolygon":g=g[f[1]];case"Polygon":if(c.index!==g[f[0]].length-2)continue;break}}this.dragSegments_.push([c,1]),a[d][1]=c;continue}D(u)in this.vertexSegments_&&!a[d][0]&&!a[d][1]&&n.push(c)}return n}deactivateTrace_(){this.traceState_={active:!1}}updateTrace_(e){const t=this.traceState_;if(!t.active)return;if(t.targetIndex===-1){const r=e.map.getPixelFromCoordinate(t.startCoord);if(Si(r,e.pixel)<this.pixelTolerance_)return}const n=xd(e.coordinate,t,e.map,this.pixelTolerance_);if(t.targetIndex===-1&&Math.sqrt(n.closestTargetDistance)/e.map.getView().getResolution()>this.pixelTolerance_)return;if(t.targetIndex!==n.index){if(t.targetIndex!==-1){const o=t.targets[t.targetIndex];this.removeTracedCoordinates_(o.startIndex,o.endIndex)}else for(const o of this.traceSegments_){const a=o[0],l=a.geometry,h=o[1],c=l.getCoordinates();la(c,l.getType(),a.depth).splice(a.index+h,1),l.setCoordinates(c),h===0&&(a.index-=1)}const r=t.targets[n.index];this.addTracedCoordinates_(r,r.startIndex,n.endIndex)}else{const r=t.targets[t.targetIndex];this.addOrRemoveTracedCoordinates_(r,n.endIndex)}t.targetIndex=n.index;const i=t.targets[t.targetIndex];i.endIndex=n.endIndex}getTraceCandidates_(e){const t=this.getMap(),n=this.pixelTolerance_,i=t.getCoordinateFromPixel([e.pixel[0]-n,e.pixel[1]+n]),r=t.getCoordinateFromPixel([e.pixel[0]+n,e.pixel[1]-n]),o=Be([i,r]);return this.traceSource_.getFeaturesInExtent(o)}toggleTraceState_(e){if(!this.traceSource_||!this.traceCondition_(e))return;if(this.traceState_.active){this.deactivateTrace_(),this.traceSegments_=null;return}const t=this.getTraceCandidates_(e);if(t.length===0)return;const n=Ed(e.coordinate,t);n.length&&(this.traceState_={active:!0,startCoord:e.coordinate.slice(),targets:n,targetIndex:-1})}addOrRemoveTracedCoordinates_(e,t){const n=e.startIndex<=e.endIndex,i=e.startIndex<=t;n===i?n&&t>e.endIndex||!n&&t<e.endIndex?this.addTracedCoordinates_(e,e.endIndex,t):(n&&t<e.endIndex||!n&&t>e.endIndex)&&this.removeTracedCoordinates_(t,e.endIndex):(this.removeTracedCoordinates_(e.startIndex,e.endIndex),this.addTracedCoordinates_(e,e.startIndex,t))}removeTracedCoordinates_(e,t){if(e===t)return;let n=0;if(e<t){const i=Math.ceil(e);let r=Math.floor(t);r===t&&(r-=1),n=r-i+1}else{const i=Math.floor(e);let r=Math.ceil(t);r===t&&(r+=1),n=i-r+1}if(n>0)for(const i of this.traceSegments_){const r=i[0],o=r.geometry,a=i[1];let l=i[0].index+1;a===1&&(l-=n);const h=o.getCoordinates();la(h,o.getType(),r.depth).splice(l,n),o.setCoordinates(h),a===1&&(r.index-=n)}}addTracedCoordinates_(e,t,n){if(t===n)return;const i=[];if(t<n){const r=Math.ceil(t);let o=Math.floor(n);o===n&&(o-=1);for(let a=r;a<=o;++a)i.push(Cn(e.coordinates,a))}else{const r=Math.floor(t);let o=Math.ceil(n);o===n&&(o+=1);for(let a=r;a>=o;--a)i.push(Cn(e.coordinates,a))}if(i.length)for(const r of this.traceSegments_){const o=r[0],a=o.geometry,l=r[1],h=o.index+1;l===0&&i.reverse();const c=a.getCoordinates();la(c,a.getType(),o.depth).splice(h,0,...i),a.setCoordinates(c),l===1&&(o.index+=i.length)}}updateGeometry_(e,t){const n=t[0],i=n.depth;let r;const o=n.segment,a=n.geometry,l=t[1];for(;e.length<a.getStride();)e.push(o[l][e.length]);switch(a.getType()){case"Point":r=e,o[0]=e,o[1]=e;break;case"MultiPoint":r=a.getCoordinates(),r[n.index]=e,o[0]=e,o[1]=e;break;case"LineString":r=a.getCoordinates(),r[n.index+l]=e,o[l]=e;break;case"MultiLineString":r=a.getCoordinates(),r[i[0]][n.index+l]=e,o[l]=e;break;case"Polygon":r=a.getCoordinates(),r[i[0]][n.index+l]=e,o[l]=e;break;case"MultiPolygon":r=a.getCoordinates(),r[i[1]][i[0]][n.index+l]=e,o[l]=e;break;case"Circle":const h=a;if(o[0]=e,o[1]=e,n.index===Tc)this.changingFeature_=!0,h.setCenter(e),this.changingFeature_=!1;else{this.changingFeature_=!0,this.getMap().getView().getProjection();let c=Si(me(h.getCenter()),me(e));h.setRadius(c),this.changingFeature_=!1}break}r&&this.setGeometryCoordinates_(a,r)}handleDragEvent(e){this.ignoreNextSingleClick_=!1,this.willModifyFeatures_(e,this.dragSegments_.map(([o])=>o));const t=[e.coordinate[0]+this.delta_[0],e.coordinate[1]+this.delta_[1]],n=[],i=[],r=this.traceState_.active&&!this.traceSegments_?this.traceState_.startCoord:null;if(r){this.traceSegments_=[];for(const o of this.dragSegments_){const a=o[0];Si(Ja(r,a.segment),r)/e.map.getView().getResolution()<1&&this.traceSegments_.push(o)}}for(let o=0,a=this.dragSegments_.length;o<a;++o){const l=this.dragSegments_[o],h=l[0],c=h.feature;n.includes(c)||n.push(c);const u=h.geometry;i.includes(u)||i.push(u),this.updateGeometry_(t,l)}this.updateTrace_(e),this.createOrUpdateVertexFeature_(t,n,i,!0)}handleDownEvent(e){if(!this.condition_(e))return!1;const t=e.coordinate,n=this.findInsertVerticesAndUpdateDragSegments_(t);if(n?.length&&this.insertVertexCondition_(e)&&(this.willModifyFeatures_(e,n),this.vertexFeature_)){const i=this.vertexFeature_.getGeometry().getCoordinates();for(let r=n.length-1;r>=0;--r)this.insertVertex_(n[r],i);this.ignoreNextSingleClick_=!0}return!!this.vertexFeature_}handleUpEvent(e){for(let t=this.dragSegments_.length-1;t>=0;--t){const n=this.dragSegments_[t][0],i=n.geometry;if(i.getType()==="Circle"){const r=i,o=r.getCenter(),a=n.featureSegments[0],l=n.featureSegments[1];a.segment[0]=o,a.segment[1]=o,l.segment[0]=o,l.segment[1]=o,this.rBush_.update(ds(o),a);let h=r;this.rBush_.update(h.getExtent(),l)}else this.rBush_.update(Be(n.segment),n)}return this.featuresBeingModified_&&(this.toggleTraceState_(e),this.dispatchEvent(new ha(aa.MODIFYEND,this.featuresBeingModified_,e)),this.featuresBeingModified_=null),!1}handlePointerMove_(e){this.lastCoordinate_=e.coordinate,this.handlePointerAtPixel_(this.lastCoordinate_)}handlePointerAtPixel_(e){const t=this.getMap(),n=t.getPixelFromCoordinate(e);t.getView().getProjection();const i=function(a,l){return Rc(e,a)-Rc(e,l)};let r,o;if(this.hitDetection_){const a=typeof this.hitDetection_=="object"?l=>l===this.hitDetection_:void 0;t.forEachFeatureAtPixel(n,(l,h,c)=>{c&&c.getType()==="Point"&&(c=new ot(qn(c.getCoordinates())));const u=c||l.getGeometry();if(u&&u.getType()==="Point"&&l instanceof ze&&this.features_.getArray().includes(l)){o=u;const d=l.getGeometry().getFlatCoordinates().slice(0,2);r=[{feature:l,geometry:o,segment:[d,d]}]}return!0},{layerFilter:a})}if(!r){const a=St(ds(e,Cc)),l=t.getView().getResolution()*this.pixelTolerance_,h=to(sn(a,l,Cc));r=this.rBush_.getInExtent(h)}if(r&&r.length>0){const a=r.sort(i)[0],l=a.segment;let h=Sc(e,a);const c=t.getPixelFromCoordinate(h);let u=Si(n,c);if(o||u<=this.pixelTolerance_){const d={};if(d[D(l)]=!0,this.snapToPointer_||(this.delta_[0]=h[0]-e[0],this.delta_[1]=h[1]-e[1]),a.geometry.getType()==="Circle"&&a.index===ms)this.snappedToVertex_=!0,this.createOrUpdateVertexFeature_(h,[a.feature],[a.geometry],this.snappedToVertex_);else{const f=t.getPixelFromCoordinate(l[0]),g=t.getPixelFromCoordinate(l[1]),m=Ni(c,f),_=Ni(c,g);if(u=Math.sqrt(Math.min(m,_)),this.snappedToVertex_=u<=this.pixelTolerance_,!this.snappedToVertex_&&!this.insertVertexCondition_(this.lastPointerEvent_)){this.vertexFeature_&&(this.overlay_.getSource().removeFeature(this.vertexFeature_),this.vertexFeature_=null);return}this.snappedToVertex_&&(h=m>_?l[1]:l[0]),this.createOrUpdateVertexFeature_(h,[a.feature],[a.geometry],this.snappedToVertex_);const p={};p[D(a.geometry)]=!0;for(let y=1,E=r.length;y<E;++y){const x=r[y].segment;if(je(l[0],x[0])&&je(l[1],x[1])||je(l[0],x[1])&&je(l[1],x[0])){const T=D(r[y].geometry);T in p||(p[T]=!0,d[D(x)]=!0)}else break}}this.vertexSegments_=d;return}}this.vertexFeature_&&(this.overlay_.getSource().removeFeature(this.vertexFeature_),this.vertexFeature_=null)}insertVertex_(e,t){const n=e.segment,i=e.feature,r=e.geometry,o=e.depth,a=e.index;let l;for(;t.length<r.getStride();)t.push(0);switch(r.getType()){case"MultiLineString":l=r.getCoordinates(),l[o[0]].splice(a+1,0,t);break;case"Polygon":l=r.getCoordinates(),l[o[0]].splice(a+1,0,t);break;case"MultiPolygon":l=r.getCoordinates(),l[o[1]][o[0]].splice(a+1,0,t);break;case"LineString":l=r.getCoordinates(),l.splice(a+1,0,t);break;default:return!1}this.setGeometryCoordinates_(r,l);const h=this.rBush_;h.remove(e),this.updateSegmentIndices_(r,a,o,1);const c={segment:[n[0],t],feature:i,geometry:r,depth:o,index:a};h.insert(Be(c.segment),c),this.dragSegments_.push([c,1]);const u={segment:[t,n[1]],feature:i,geometry:r,depth:o,index:a+1};return h.insert(Be(u.segment),u),this.dragSegments_.push([u,0]),!0}updatePointer_(e){return e&&this.findInsertVerticesAndUpdateDragSegments_(e),this.vertexFeature_?.getGeometry().getCoordinates()}getPoint(){const e=this.vertexFeature_?.getGeometry().getCoordinates();return e?qn(e,this.getMap().getView().getProjection()):null}canRemovePoint(){if(!this.vertexFeature_||this.vertexFeature_.get("geometries").every(n=>n.getType()==="Circle"||n.getType().endsWith("Point")))return!1;const e=this.vertexFeature_.getGeometry().getCoordinates();return this.rBush_.getInExtent(Be([e])).some(({segment:n})=>je(n[0],e)||je(n[1],e))}removePoint(e){if(e&&(e=me(e,this.getMap().getView().getProjection()),this.updatePointer_(e)),!this.lastPointerEvent_||this.lastPointerEvent_&&this.lastPointerEvent_.type!=ee.POINTERDRAG){const t=this.lastPointerEvent_;this.willModifyFeatures_(t,this.dragSegments_.map(([i])=>i));const n=this.removeVertex_();return this.featuresBeingModified_&&this.dispatchEvent(new ha(aa.MODIFYEND,this.featuresBeingModified_,t)),this.featuresBeingModified_=null,n}return!1}removeVertex_(){const e=this.dragSegments_,t={};let n=!1,i,r,o,a,l,h,c,u,d,f,g;for(l=e.length-1;l>=0;--l)o=e[l],f=o[0],g=D(f.feature),f.depth&&(g+="-"+f.depth.join("-")),g in t||(t[g]={}),o[1]===0?(t[g].right=f,t[g].index=f.index):o[1]==1&&(t[g].left=f,t[g].index=f.index+1);for(g in t){switch(d=t[g].right,c=t[g].left,h=t[g].index,u=h-1,c!==void 0?f=c:f=d,u<0&&(u=0),a=f.geometry,r=a.getCoordinates(),i=r,n=!1,a.getType()){case"MultiLineString":r[f.depth[0]].length>2&&(r[f.depth[0]].splice(h,1),n=!0);break;case"LineString":r.length>2&&(r.splice(h,1),n=!0);break;case"MultiPolygon":i=i[f.depth[1]];case"Polygon":i=i[f.depth[0]],i.length>4&&(h==i.length-1&&(h=0),i.splice(h,1),n=!0,h===0&&(i.pop(),i.push(i[0]),u=i.length-1));break}if(n){this.setGeometryCoordinates_(a,r);const m=[];if(c!==void 0&&(this.rBush_.remove(c),m.push(c.segment[0])),d!==void 0&&(this.rBush_.remove(d),m.push(d.segment[1])),c!==void 0&&d!==void 0){const _={depth:f.depth,feature:f.feature,geometry:f.geometry,index:u,segment:m};this.rBush_.insert(Be(_.segment),_)}this.updateSegmentIndices_(a,h,f.depth,-1),this.vertexFeature_&&(this.overlay_.getSource().removeFeature(this.vertexFeature_),this.vertexFeature_=null),e.length=0}}return n}canInsertPoint(){if(!this.vertexFeature_||this.vertexFeature_.get("geometries").every(n=>n.getType()==="Circle"||n.getType().endsWith("Point")))return!1;const e=this.vertexFeature_.getGeometry().getCoordinates();return this.rBush_.getInExtent(Be([e])).some(({segment:n})=>!(je(n[0],e)||je(n[1],e)))}insertPoint(e){const t=e?me(e,this.getMap().getView().getProjection()):this.vertexFeature_?.getGeometry().getCoordinates();return t?this.findInsertVerticesAndUpdateDragSegments_(t).reduce((i,r)=>i||this.insertVertex_(r,t),!1):!1}setGeometryCoordinates_(e,t){this.changingFeature_=!0,e.setCoordinates(t),this.changingFeature_=!1}updateSegmentIndices_(e,t,n,i){this.rBush_.forEachInExtent(e.getExtent(),function(r){r.geometry===e&&(n===void 0||r.depth===void 0||Ut(r.depth,n))&&r.index>t&&(r.index+=i)})}}function gx(s,e){return s.index-e.index}function Rc(s,e,t){const n=e.geometry;if(n.getType()==="Circle"){let r=n;if(e.index===ms){const o=Ni(r.getCenter(),me(s)),a=Math.sqrt(o)-r.getRadius();return a*a}}const i=me(s);return bi[0]=me(e.segment[0]),bi[1]=me(e.segment[1]),Mf(i,bi)}function Sc(s,e,t){const n=e.geometry;if(n.getType()==="Circle"&&e.index===ms)return qn(n.getClosestPoint(me(s)));const i=me(s);return bi[0]=me(e.segment[0]),bi[1]=me(e.segment[1]),qn(Ja(i,bi))}function _x(){const s=Dl();return function(e,t){return s.Point}}class mx extends Wl{constructor(){super()}getType(){return"text"}readFeature(e,t){return this.readFeatureFromText(yr(e),this.adaptOptions(t))}readFeatureFromText(e,t){return $()}readFeatures(e,t){return this.readFeaturesFromText(yr(e),this.adaptOptions(t))}readFeaturesFromText(e,t){return $()}readGeometry(e,t){return this.readGeometryFromText(yr(e),this.adaptOptions(t))}readGeometryFromText(e,t){return $()}readProjection(e){return this.readProjectionFromText(yr(e))}readProjectionFromText(e){return this.dataProjection}writeFeature(e,t){return this.writeFeatureText(e,this.adaptOptions(t))}writeFeatureText(e,t){return $()}writeFeatures(e,t){return this.writeFeaturesText(e,this.adaptOptions(t))}writeFeaturesText(e,t){return $()}writeGeometry(e,t){return this.writeGeometryText(e,this.adaptOptions(t))}writeGeometryText(e,t){return $()}}function yr(s){return typeof s=="string"?s:""}const px={POINT:ot,LINESTRING:at,POLYGON:Qe,MULTIPOINT:ri,MULTILINESTRING:rn,MULTIPOLYGON:In},Sd="EMPTY",vd="Z",wd="M",yx="ZM",oe={START:0,TEXT:1,LEFT_PAREN:2,RIGHT_PAREN:3,NUMBER:4,COMMA:5,EOF:6},xx={Point:"POINT",LineString:"LINESTRING",Polygon:"POLYGON",MultiPoint:"MULTIPOINT",MultiLineString:"MULTILINESTRING",MultiPolygon:"MULTIPOLYGON",GeometryCollection:"GEOMETRYCOLLECTION",Circle:"CIRCLE"};class Ex{constructor(e){this.wkt=e,this.index_=-1}isAlpha_(e){return e>="a"&&e<="z"||e>="A"&&e<="Z"}isNumeric_(e,t){return t=t!==void 0?t:!1,e>="0"&&e<="9"||e=="."&&!t}isWhiteSpace_(e){return e==" "||e==" "||e=="\r"||e==`
|
||
`}nextChar_(){return this.wkt.charAt(++this.index_)}nextToken(){const e=this.nextChar_(),t=this.index_;let n=e,i;if(e=="(")i=oe.LEFT_PAREN;else if(e==",")i=oe.COMMA;else if(e==")")i=oe.RIGHT_PAREN;else if(this.isNumeric_(e)||e=="-")i=oe.NUMBER,n=this.readNumber_();else if(this.isAlpha_(e))i=oe.TEXT,n=this.readText_();else{if(this.isWhiteSpace_(e))return this.nextToken();if(e==="")i=oe.EOF;else throw new Error("Unexpected character: "+e)}return{position:t,value:n,type:i}}readNumber_(){let e;const t=this.index_;let n=!1,i=!1;do e=="."?n=!0:(e=="e"||e=="E")&&(i=!0),e=this.nextChar_();while(this.isNumeric_(e,n)||!i&&(e=="e"||e=="E")||i&&(e=="-"||e=="+"));return parseFloat(this.wkt.substring(t,this.index_--))}readText_(){let e;const t=this.index_;do e=this.nextChar_();while(this.isAlpha_(e));return this.wkt.substring(t,this.index_--).toUpperCase()}}class Tx{constructor(e){this.lexer_=e,this.token_={position:0,type:oe.START},this.layout_="XY"}consume_(){this.token_=this.lexer_.nextToken()}isTokenType(e){return this.token_.type==e}match(e){const t=this.isTokenType(e);return t&&this.consume_(),t}parse(){return this.consume_(),this.parseGeometry_()}parseGeometryLayout_(){let e="XY";const t=this.token_;if(this.isTokenType(oe.TEXT)){const n=t.value;n===vd?e="XYZ":n===wd?e="XYM":n===yx&&(e="XYZM"),e!=="XY"&&this.consume_()}return e}parseGeometryCollectionText_(){if(this.match(oe.LEFT_PAREN)){const e=[];do e.push(this.parseGeometry_());while(this.match(oe.COMMA));if(this.match(oe.RIGHT_PAREN))return e}throw new Error(this.formatErrorMessage_())}parsePointText_(){if(this.match(oe.LEFT_PAREN)){const e=this.parsePoint_();if(this.match(oe.RIGHT_PAREN))return e}throw new Error(this.formatErrorMessage_())}parseLineStringText_(){if(this.match(oe.LEFT_PAREN)){const e=this.parsePointList_();if(this.match(oe.RIGHT_PAREN))return e}throw new Error(this.formatErrorMessage_())}parsePolygonText_(){if(this.match(oe.LEFT_PAREN)){const e=this.parseLineStringTextList_();if(this.match(oe.RIGHT_PAREN))return e}throw new Error(this.formatErrorMessage_())}parseMultiPointText_(){if(this.match(oe.LEFT_PAREN)){let e;if(this.token_.type==oe.LEFT_PAREN?e=this.parsePointTextList_():e=this.parsePointList_(),this.match(oe.RIGHT_PAREN))return e}throw new Error(this.formatErrorMessage_())}parseMultiLineStringText_(){if(this.match(oe.LEFT_PAREN)){const e=this.parseLineStringTextList_();if(this.match(oe.RIGHT_PAREN))return e}throw new Error(this.formatErrorMessage_())}parseMultiPolygonText_(){if(this.match(oe.LEFT_PAREN)){const e=this.parsePolygonTextList_();if(this.match(oe.RIGHT_PAREN))return e}throw new Error(this.formatErrorMessage_())}parsePoint_(){const e=[],t=this.layout_.length;for(let n=0;n<t;++n){const i=this.token_;if(this.match(oe.NUMBER))e.push(i.value);else break}if(e.length==t)return e;throw new Error(this.formatErrorMessage_())}parsePointList_(){const e=[this.parsePoint_()];for(;this.match(oe.COMMA);)e.push(this.parsePoint_());return e}parsePointTextList_(){const e=[this.parsePointText_()];for(;this.match(oe.COMMA);)e.push(this.parsePointText_());return e}parseLineStringTextList_(){const e=[this.parseLineStringText_()];for(;this.match(oe.COMMA);)e.push(this.parseLineStringText_());return e}parsePolygonTextList_(){const e=[this.parsePolygonText_()];for(;this.match(oe.COMMA);)e.push(this.parsePolygonText_());return e}isEmptyGeometry_(){const e=this.isTokenType(oe.TEXT)&&this.token_.value==Sd;return e&&this.consume_(),e}formatErrorMessage_(){return"Unexpected `"+this.token_.value+"` at position "+this.token_.position+" in `"+this.lexer_.wkt+"`"}parseGeometry_(){const e=this.token_;if(this.match(oe.TEXT)){const t=e.value;this.layout_=this.parseGeometryLayout_();const n=this.isEmptyGeometry_();if(t=="GEOMETRYCOLLECTION"){if(n)return new Ze([]);const o=this.parseGeometryCollectionText_();return new Ze(o)}const i=px[t];if(!i)throw new Error("Invalid geometry type: "+t);let r;if(n)t=="POINT"?r=[NaN,NaN]:r=[];else switch(t){case"POINT":{r=this.parsePointText_();break}case"LINESTRING":{r=this.parseLineStringText_();break}case"POLYGON":{r=this.parsePolygonText_();break}case"MULTIPOINT":{r=this.parseMultiPointText_();break}case"MULTILINESTRING":{r=this.parseMultiLineStringText_();break}case"MULTIPOLYGON":{r=this.parseMultiPolygonText_();break}}return new i(r,this.layout_)}throw new Error(this.formatErrorMessage_())}}class B0 extends mx{constructor(e){super(),e=e||{},this.splitCollection_=e.splitCollection!==void 0?e.splitCollection:!1}parse_(e){const t=new Ex(e);return new Tx(t).parse()}readFeatureFromText(e,t){const n=this.readGeometryFromText(e,t),i=new ze;return i.setGeometry(n),i}readFeaturesFromText(e,t){let n=[];const i=this.readGeometryFromText(e,t);this.splitCollection_&&i.getType()=="GeometryCollection"?n=i.getGeometriesArray():n=[i];const r=[];for(let o=0,a=n.length;o<a;++o){const l=new ze;l.setGeometry(n[o]),r.push(l)}return r}readGeometryFromText(e,t){const n=this.parse_(e);return Jn(n,!1,t)}writeFeatureText(e,t){const n=e.getGeometry();return n?this.writeGeometryText(n,t):""}writeFeaturesText(e,t){if(e.length==1)return this.writeFeatureText(e[0],t);const n=[];for(let r=0,o=e.length;r<o;++r)n.push(e[r].getGeometry());const i=new Ze(n);return this.writeGeometryText(i,t)}writeGeometryText(e,t){return Ld(Jn(e,!0,t))}}function Pd(s){const e=s.getCoordinates();return e.length===0?"":e.join(" ")}function Cx(s){const e=[],t=s.getPoints();for(let n=0,i=t.length;n<i;++n)e.push("("+Pd(t[n])+")");return e.join(",")}function Rx(s){const e=[],t=s.getGeometries();for(let n=0,i=t.length;n<i;++n)e.push(Ld(t[n]));return e.join(",")}function ih(s){const e=s.getCoordinates(),t=[];for(let n=0,i=e.length;n<i;++n)t.push(e[n].join(" "));return t.join(",")}function Sx(s){const e=[],t=s.getLineStrings();for(let n=0,i=t.length;n<i;++n)e.push("("+ih(t[n])+")");return e.join(",")}function Id(s){const e=[],t=s.getLinearRings();for(let n=0,i=t.length;n<i;++n)e.push("("+ih(t[n])+")");return e.join(",")}function vx(s){const e=[],t=s.getPolygons();for(let n=0,i=t.length;n<i;++n)e.push("("+Id(t[n])+")");return e.join(",")}function wx(s){const e=s.getLayout();let t="";return(e==="XYZ"||e==="XYZM")&&(t+=vd),(e==="XYM"||e==="XYZM")&&(t+=wd),t}const Px={Point:Pd,LineString:ih,Polygon:Id,MultiPoint:Cx,MultiLineString:Sx,MultiPolygon:vx,GeometryCollection:Rx};function Ld(s){const e=s.getType(),t=Px[e],n=t(s);let i=xx[e];if(typeof s.getFlatCoordinates=="function"){const r=wx(s);r.length>0&&(i+=" "+r)}return n.length===0?i+" "+Sd:i+"("+n+")"}const vc="http://www.w3.org/2001/XMLSchema-instance";function Ws(s,e){return _o().createElementNS(s,e)}function an(s,e){return Ad(s,e,[]).join("")}function Ad(s,e,t){if(s.nodeType==Node.CDATA_SECTION_NODE||s.nodeType==Node.TEXT_NODE)t.push(s.nodeValue);else{let n;for(n=s.firstChild;n;n=n.nextSibling)Ad(n,e,t)}return t}function Rn(s){return"documentElement"in s}function Sn(s){return new DOMParser().parseFromString(s,"application/xml")}function wc(s,e){return(function(t,n){const i=s.call(e??this,t,n);if(i!==void 0){const r=n[n.length-1];se(r,i)}})}function mn(s,e){return(function(t,n){const i=s.call(e??this,t,n);i!==void 0&&n[n.length-1].push(i)})}function sh(s,e){return(function(t,n){const i=s.call(this,t,n);i!==void 0&&(n[n.length-1]=i)})}function O(s,e,t){return(function(n,i){const r=s.call(this,n,i);if(r!==void 0){const o=i[i.length-1],a=e!==void 0?e:n.localName;o[a]=r}})}function W(s,e){return(function(t,n,i){s.call(this,t,n,i),i[i.length-1].node.appendChild(t)})}function ln(s,e){return(function(t,n,i){const o=n[n.length-1].node;let a=s;a===void 0&&(a=i);const l=o.namespaceURI;return Ws(l,a)})}const xt=ln();function Pt(s,e){const t=e.length,n=new Array(t);for(let i=0;i<t;++i)n[i]=s[e[i]];return n}function z(s,e,t){t=t!==void 0?t:{};let n,i;for(n=0,i=s.length;n<i;++n)t[s[n]]=e;return t}function Hi(s,e,t,n){let i;for(i=e.firstElementChild;i;i=i.nextElementSibling){const r=s[i.namespaceURI];if(r!==void 0){const o=r[i.localName];o!==void 0&&o.call(n,i,t)}}}function ce(s,e,t,n,i){return n.push(s),Hi(e,t,n,i),n.pop()}function Ix(s,e,t,n,i,r){const o=(i!==void 0?i:t).length;let a,l;for(let h=0;h<o;++h)a=t[h],a!==void 0&&(l=e.call(r,a,n,i!==void 0?i[h]:void 0),l!==void 0&&s[l.namespaceURI][l.localName].call(r,l,a,n))}function Ce(s,e,t,n,i,r,o){return i.push(s),Ix(e,t,n,i,r,o),i.pop()}let ca;function Lx(){return ca===void 0&&typeof XMLSerializer<"u"&&(ca=new XMLSerializer),ca}let ua;function _o(){return ua===void 0&&typeof document<"u"&&(ua=document.implementation.createDocument("","",null)),ua}class Ax extends Wl{constructor(){super(),this.xmlSerializer_=Lx()}getType(){return"xml"}readFeature(e,t){if(!e)return null;if(typeof e=="string"){const n=Sn(e);return this.readFeatureFromDocument(n,t)}return Rn(e)?this.readFeatureFromDocument(e,t):this.readFeatureFromNode(e,t)}readFeatureFromDocument(e,t){const n=this.readFeaturesFromDocument(e,t);return n.length>0?n[0]:null}readFeatureFromNode(e,t){return null}readFeatures(e,t){if(!e)return[];if(typeof e=="string"){const n=Sn(e);return this.readFeaturesFromDocument(n,t)}return Rn(e)?this.readFeaturesFromDocument(e,t):this.readFeaturesFromNode(e,t)}readFeaturesFromDocument(e,t){const n=[];for(let i=e.firstChild;i;i=i.nextSibling)i.nodeType==Node.ELEMENT_NODE&&se(n,this.readFeaturesFromNode(i,t));return n}readFeaturesFromNode(e,t){return $()}readGeometry(e,t){if(!e)return null;if(typeof e=="string"){const n=Sn(e);return this.readGeometryFromDocument(n,t)}return Rn(e)?this.readGeometryFromDocument(e,t):this.readGeometryFromNode(e,t)}readGeometryFromDocument(e,t){return null}readGeometryFromNode(e,t){return null}readProjection(e){if(!e)return null;if(typeof e=="string"){const t=Sn(e);return this.readProjectionFromDocument(t)}return Rn(e)?this.readProjectionFromDocument(e):this.readProjectionFromNode(e)}readProjectionFromDocument(e){return this.dataProjection}readProjectionFromNode(e){return this.dataProjection}writeFeature(e,t){const n=this.writeFeatureNode(e,t);return this.xmlSerializer_.serializeToString(n)}writeFeatureNode(e,t){return null}writeFeatures(e,t){const n=this.writeFeaturesNode(e,t);return this.xmlSerializer_.serializeToString(n)}writeFeaturesNode(e,t){return null}writeGeometry(e,t){const n=this.writeGeometryNode(e,t);return this.xmlSerializer_.serializeToString(n)}writeGeometryNode(e,t){return null}}function Ln(s){const e=an(s,!1);return Fx(e)}function Fx(s){const e=/^\s*(true|1)|(false|0)\s*$/.exec(s);if(e)return e[1]!==void 0||!1}function pe(s){const e=an(s,!1);return bx(e)}function bx(s){const e=/^\s*([+\-]?\d*\.?\d+(?:e[+\-]?\d+)?)\s*$/i.exec(s);if(e)return parseFloat(e[1])}function Xe(s){return an(s,!1).trim()}function zi(s,e){gt(s,e?"1":"0")}function Mx(s,e){s.appendChild(_o().createCDATASection(e))}function Xn(s,e){const t=e.toPrecision();s.appendChild(_o().createTextNode(t))}const Dx=/^\s/,Ox=/\s$/,Nx=/(\n|\t|\r|<|&| {2})/;function gt(s,e){typeof e=="string"&&(Dx.test(e)||Ox.test(e)||Nx.test(e))?e.split("]]>").forEach((t,n,i)=>{n<i.length-1&&(t+="]]"),n>0&&(t=">"+t),Mx(s,t)}):s.appendChild(_o().createTextNode(e))}const hn=["http://www.google.com/kml/ext/2.2"],k=[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"],Gx="http://www.opengis.net/kml/2.2 https://developers.google.com/kml/schema/kml22gx.xsd",Pc={fraction:"fraction",pixels:"pixels",insetPixels:"pixels"},kx=z(k,{ExtendedData:Yd,Region:jd,MultiGeometry:O($d,"geometry"),LineString:O(Bd,"geometry"),LinearRing:O(zd,"geometry"),Point:O(Xd,"geometry"),Polygon:O(Wd,"geometry"),Style:O(ah),StyleMap:EE,address:O(Xe),description:O(Xe),name:O(Xe),open:O(Ln),phoneNumber:O(Xe),styleUrl:O(Od),visibility:O(Ln)},z(hn,{MultiTrack:O(aE,"geometry"),Track:O(Ud,"geometry")})),Ux=z(k,{ExtendedData:Yd,Region:jd,Link:bE,address:O(Xe),description:O(Xe),name:O(Xe),open:O(Ln),phoneNumber:O(Xe),visibility:O(Ln)}),Bx=z(k,{href:O(Dd)}),zx=z(k,{Altitude:O(pe),Longitude:O(pe),Latitude:O(pe),Tilt:O(pe),AltitudeMode:O(Xe),Heading:O(pe),Roll:O(pe)}),Fd=z(k,{LatLonAltBox:vE,Lod:PE}),$x=z(k,["Document","Placemark"]),Xx=z(k,{Document:W(BE),Placemark:W(Kd)});let Mi,Cr=null,Xa,ps,ys,xs,Vr,Wa=null,rh,Ya=null,ja,Wn=null,Ic=null,Va=null;function Zr(s){return 32/Math.min(s[0],s[1])}function Wx(){Mi=[255,255,255,1],Cr=new wt({color:Mi}),Xa=[20,2],ps="pixels",ys="pixels",xs=[64,64],Vr="https://maps.google.com/mapfiles/kml/pushpin/ylw-pushpin.png",Wa=new Zi({anchor:Xa,anchorOrigin:"bottom-left",anchorXUnits:ps,anchorYUnits:ys,crossOrigin:"anonymous",rotation:0,scale:Zr(xs),size:xs,src:Vr}),rh="NO_IMAGE",Ya=new Gt({color:Mi,width:1}),ja=new Gt({color:[51,51,51,1],width:2}),Wn=new zs({font:"bold 16px Helvetica",fill:Cr,stroke:ja,scale:.8}),Ic=new Oe({fill:Cr,image:Wa,text:Wn,stroke:Ya,zIndex:0}),Va=[Ic]}let xr;function Yx(s){return s}class z0 extends Ax{constructor(e){super(),e=e||{},Va||Wx(),this.dataProjection=_e("EPSG:4326"),this.defaultStyle_=e.defaultStyle?e.defaultStyle:Va,this.extractStyles_=e.extractStyles!==void 0?e.extractStyles:!0,this.writeStyles_=e.writeStyles!==void 0?e.writeStyles:!0,this.sharedStyles_={},this.showPointNames_=e.showPointNames!==void 0?e.showPointNames:!0,this.crossOrigin_=e.crossOrigin!==void 0?e.crossOrigin:"anonymous",this.iconUrlFunction_=e.iconUrlFunction?e.iconUrlFunction:Yx,this.supportedMediaTypes=["application/vnd.google-earth.kml+xml"]}readDocumentOrFolder_(e,t){const n=z(k,{Document:wc(this.readDocumentOrFolder_,this),Folder:wc(this.readDocumentOrFolder_,this),Placemark:mn(this.readPlacemark_,this),Style:this.readSharedStyle_.bind(this),StyleMap:this.readSharedStyleMap_.bind(this)}),i=ce([],n,e,t,this);if(i)return i}readPlacemark_(e,t){const n=ce({geometry:null},kx,e,t,this);if(!n)return;const i=new ze,r=e.getAttribute("id");r!==null&&i.setId(r);const o=t[0],a=n.geometry;if(a&&Jn(a,!1,o),i.setGeometry(a),delete n.geometry,this.extractStyles_){const l=n.Style,h=n.styleUrl,c=Vx(l,h,this.defaultStyle_,this.sharedStyles_,this.showPointNames_);i.setStyle(c)}return delete n.Style,i.setProperties(n,!0),i}readSharedStyle_(e,t){const n=e.getAttribute("id");if(n!==null){const i=ah.call(this,e,t);if(i){let r,o=e.baseURI;(!o||o=="about:blank")&&(o=window.location.href),o?r=new URL("#"+n,o).href:r="#"+n,this.sharedStyles_[r]=i}}}readSharedStyleMap_(e,t){const n=e.getAttribute("id");if(n===null)return;const i=Gd.call(this,e,t);if(!i)return;let r,o=e.baseURI;(!o||o=="about:blank")&&(o=window.location.href),o?r=new URL("#"+n,o).href:r="#"+n,this.sharedStyles_[r]=i}readFeatureFromNode(e,t){if(!k.includes(e.namespaceURI))return null;const n=this.readPlacemark_(e,[this.getReadOptions(e,t)]);return n||null}readFeaturesFromNode(e,t){if(!k.includes(e.namespaceURI))return[];let n;const i=e.localName;if(i=="Document"||i=="Folder")return n=this.readDocumentOrFolder_(e,[this.getReadOptions(e,t)]),n||[];if(i=="Placemark"){const r=this.readPlacemark_(e,[this.getReadOptions(e,t)]);return r?[r]:[]}if(i=="kml"){n=[];for(let r=e.firstElementChild;r;r=r.nextElementSibling){const o=this.readFeaturesFromNode(r,t);o&&se(n,o)}return n}return[]}readName(e){if(e){if(typeof e=="string"){const t=Sn(e);return this.readNameFromDocument(t)}return Rn(e)?this.readNameFromDocument(e):this.readNameFromNode(e)}}readNameFromDocument(e){for(let t=e.firstChild;t;t=t.nextSibling)if(t.nodeType==Node.ELEMENT_NODE){const n=this.readNameFromNode(t);if(n)return n}}readNameFromNode(e){for(let t=e.firstElementChild;t;t=t.nextElementSibling)if(k.includes(t.namespaceURI)&&t.localName=="name")return Xe(t);for(let t=e.firstElementChild;t;t=t.nextElementSibling){const n=t.localName;if(k.includes(t.namespaceURI)&&(n=="Document"||n=="Folder"||n=="Placemark"||n=="kml")){const i=this.readNameFromNode(t);if(i)return i}}}readNetworkLinks(e){const t=[];if(typeof e=="string"){const n=Sn(e);se(t,this.readNetworkLinksFromDocument(n))}else Rn(e)?se(t,this.readNetworkLinksFromDocument(e)):se(t,this.readNetworkLinksFromNode(e));return t}readNetworkLinksFromDocument(e){const t=[];for(let n=e.firstChild;n;n=n.nextSibling)n.nodeType==Node.ELEMENT_NODE&&se(t,this.readNetworkLinksFromNode(n));return t}readNetworkLinksFromNode(e){const t=[];for(let n=e.firstElementChild;n;n=n.nextElementSibling)if(k.includes(n.namespaceURI)&&n.localName=="NetworkLink"){const i=ce({},Ux,n,[]);t.push(i)}for(let n=e.firstElementChild;n;n=n.nextElementSibling){const i=n.localName;k.includes(n.namespaceURI)&&(i=="Document"||i=="Folder"||i=="kml")&&se(t,this.readNetworkLinksFromNode(n))}return t}readRegion(e){const t=[];if(typeof e=="string"){const n=Sn(e);se(t,this.readRegionFromDocument(n))}else Rn(e)?se(t,this.readRegionFromDocument(e)):se(t,this.readRegionFromNode(e));return t}readRegionFromDocument(e){const t=[];for(let n=e.firstChild;n;n=n.nextSibling)n.nodeType==Node.ELEMENT_NODE&&se(t,this.readRegionFromNode(n));return t}readRegionFromNode(e){const t=[];for(let n=e.firstElementChild;n;n=n.nextElementSibling)if(k.includes(n.namespaceURI)&&n.localName=="Region"){const i=ce({},Fd,n,[]);t.push(i)}for(let n=e.firstElementChild;n;n=n.nextElementSibling){const i=n.localName;k.includes(n.namespaceURI)&&(i=="Document"||i=="Folder"||i=="kml")&&se(t,this.readRegionFromNode(n))}return t}readCamera(e){const t=[];if(typeof e=="string"){const n=Sn(e);se(t,this.readCameraFromDocument(n))}else Rn(e)?se(t,this.readCameraFromDocument(e)):se(t,this.readCameraFromNode(e));return t}readCameraFromDocument(e){const t=[];for(let n=e.firstChild;n;n=n.nextSibling)n.nodeType===Node.ELEMENT_NODE&&se(t,this.readCameraFromNode(n));return t}readCameraFromNode(e){const t=[];for(let n=e.firstElementChild;n;n=n.nextElementSibling)if(k.includes(n.namespaceURI)&&n.localName==="Camera"){const i=ce({},zx,n,[]);t.push(i)}for(let n=e.firstElementChild;n;n=n.nextElementSibling){const i=n.localName;k.includes(n.namespaceURI)&&(i==="Document"||i==="Folder"||i==="Placemark"||i==="kml")&&se(t,this.readCameraFromNode(n))}return t}writeFeaturesNode(e,t){t=this.adaptOptions(t);const n=Ws(k[4],"kml"),i="http://www.w3.org/2000/xmlns/";n.setAttributeNS(i,"xmlns:gx",hn[0]),n.setAttributeNS(i,"xmlns:xsi",vc),n.setAttributeNS(vc,"xsi:schemaLocation",Gx);const r={node:n},o={};e.length>1?o.Document=e:e.length==1&&(o.Placemark=e[0]);const a=$x[n.namespaceURI],l=Pt(o,a);return Ce(r,Xx,xt,l,[t],a,this),n}}function jx(s,e){const t=[0,0];let n="start";const i=s.getImage();if(i){const a=i.getSize();if(a&&a.length==2){const l=i.getScaleArray(),h=i.getAnchor();t[0]=l[0]*(a[0]-h[0]),t[1]=l[1]*(a[1]/2-h[1]),n="left"}}let r=s.getText();return r?(r=r.clone(),r.setFont(r.getFont()||Wn.getFont()),r.setScale(r.getScale()||Wn.getScale()),r.setFill(r.getFill()||Wn.getFill()),r.setStroke(r.getStroke()||ja)):r=Wn.clone(),r.setText(e),r.setOffsetX(t[0]),r.setOffsetY(t[1]),r.setTextAlign(n),new Oe({image:i,text:r})}function Vx(s,e,t,n,i){return(function(r,o){let a=i,l="",h=[];if(a){const u=r.getGeometry();if(u)if(u instanceof Ze)h=u.getGeometriesArrayRecursive().filter(function(d){const f=d.getType();return f==="Point"||f==="MultiPoint"}),a=h.length>0;else{const d=u.getType();a=d==="Point"||d==="MultiPoint"}}a&&(l=r.get("name"),a=a&&!!l,a&&/&[^&]+;/.test(l)&&(xr||(xr=document.createElement("textarea")),xr.innerHTML=l,l=xr.value));let c=t;if(s?c=s:e&&(c=bd(e,t,n)),a){const u=jx(c[0],l);if(h.length>0){u.setGeometry(new Ze(h));const d=new Oe({geometry:c[0].getGeometry(),image:null,fill:c[0].getFill(),stroke:c[0].getStroke(),text:null});return[u,d].concat(c.slice(1))}return u}return c})}function bd(s,e,t){return Array.isArray(s)?s:typeof s=="string"?bd(t[s],e,t):e}function mo(s){const e=an(s,!1),t=/^\s*#?\s*([0-9A-Fa-f]{8})\s*$/.exec(e);if(t){const n=t[1];return[parseInt(n.substr(6,2),16),parseInt(n.substr(4,2),16),parseInt(n.substr(2,2),16),parseInt(n.substr(0,2),16)/255]}}function Md(s){let e=an(s,!1);const t=[];e=e.replace(/\s*,\s*/g,",");const n=/^\s*([+\-]?\d*\.?\d+(?:e[+\-]?\d+)?),([+\-]?\d*\.?\d+(?:e[+\-]?\d+)?)(?:\s+|,|$)(?:([+\-]?\d*\.?\d+(?:e[+\-]?\d+)?)(?:\s+|$))?\s*/i;let i;for(;i=n.exec(e);){const r=parseFloat(i[1]),o=parseFloat(i[2]),a=i[3]?parseFloat(i[3]):0;t.push(r,o,a),e=e.substr(i[0].length)}if(e==="")return t}function Dd(s){const e=an(s,!1).trim();let t=s.baseURI;return(!t||t=="about:blank")&&(t=window.location.href),t?new URL(e,t).href:e}function Od(s){const e=an(s,!1).trim().replace(/^(?!.*#)/,"#");let t=s.baseURI;return(!t||t=="about:blank")&&(t=window.location.href),t?new URL(e,t).href:e}function Zx(s){const e=s.getAttribute("xunits"),t=s.getAttribute("yunits");let n;return e!=="insetPixels"?t!=="insetPixels"?n="bottom-left":n="top-left":t!=="insetPixels"?n="bottom-right":n="top-right",{x:parseFloat(s.getAttribute("x")),xunits:Pc[e],y:parseFloat(s.getAttribute("y")),yunits:Pc[t],origin:n}}function Nd(s){return pe(s)}const Kx=z(k,{Pair:xE});function Gd(s,e){return ce(void 0,Kx,s,e,this)}const Hx=z(k,{Icon:O(cE),color:O(mo),heading:O(pe),hotSpot:O(Zx),scale:O(Nd)});function qx(s,e){const t=ce({},Hx,s,e);if(!t)return;const n=e[e.length-1],i="Icon"in t?t.Icon:{},r=!("Icon"in t)||Object.keys(i).length>0;let o;const a=i.href;a?o=a:r&&(o=Vr);let l,h,c,u="bottom-left";const d=t.hotSpot;d?(l=[d.x,d.y],h=d.xunits,c=d.yunits,u=d.origin):/^https?:\/\/maps\.(?:google|gstatic)\.com\//.test(o)&&(o.includes("pushpin")?(l=Xa,h=ps,c=ys):o.includes("arrow-reverse")?(l=[54,42],h=ps,c=ys):o.includes("paddle")&&(l=[32,1],h=ps,c=ys));let f;const g=i.x,m=i.y;g!==void 0&&m!==void 0&&(f=[g,m]);let _;const p=i.w,y=i.h;p!==void 0&&y!==void 0&&(_=[p,y]);let E;const x=t.heading;x!==void 0&&(E=pt(x));const T=t.scale,R=t.color;if(r){o==Vr&&(_=xs);const S=new Zi({anchor:l,anchorOrigin:u,anchorXUnits:h,anchorYUnits:c,crossOrigin:this.crossOrigin_,offset:f,offsetOrigin:"bottom-left",rotation:E,scale:T,size:_,src:this.iconUrlFunction_(o),color:R}),v=S.getScaleArray()[0],w=S.getSize();if(w===null){const I=S.getImageState();if(I===U.IDLE||I===U.LOADING){const F=function(){const L=S.getImageState();if(!(L===U.IDLE||L===U.LOADING)){const b=S.getSize();if(b&&b.length==2){const M=Zr(b);S.setScale(v*M)}S.unlistenImageChange(F)}};S.listenImageChange(F),I===U.IDLE&&S.load()}}else if(w.length==2){const I=Zr(w);S.setScale(v*I)}n.imageStyle=S}else n.imageStyle=rh}const Jx=z(k,{color:O(mo),scale:O(Nd)});function Qx(s,e){const t=ce({},Jx,s,e);if(!t)return;const n=e[e.length-1],i=new zs({fill:new wt({color:"color"in t?t.color:Mi}),scale:t.scale});n.textStyle=i}const eE=z(k,{color:O(mo),width:O(pe)});function tE(s,e){const t=ce({},eE,s,e);if(!t)return;const n=e[e.length-1],i=new Gt({color:"color"in t?t.color:Mi,width:"width"in t?t.width:1});n.strokeStyle=i}const nE=z(k,{color:O(mo),fill:O(Ln),outline:O(Ln)});function iE(s,e){const t=ce({},nE,s,e);if(!t)return;const n=e[e.length-1],i=new wt({color:"color"in t?t.color:Mi});n.fillStyle=i;const r=t.fill;r!==void 0&&(n.fill=r);const o=t.outline;o!==void 0&&(n.outline=o)}const sE=z(k,{coordinates:sh(Md)});function kd(s,e){return ce(null,sE,s,e)}function rE(s,e){const n=e[e.length-1].coordinates,i=an(s,!1),o=/^\s*([+\-]?\d+(?:\.\d*)?(?:e[+\-]?\d*)?)\s+([+\-]?\d+(?:\.\d*)?(?:e[+\-]?\d*)?)\s+([+\-]?\d+(?:\.\d*)?(?:e[+\-]?\d*)?)\s*$/i.exec(i);if(o){const a=parseFloat(o[1]),l=parseFloat(o[2]),h=parseFloat(o[3]);n.push([a,l,h])}else n.push([])}const oE=z(hn,{Track:mn(Ud)});function aE(s,e){const t=ce([],oE,s,e);if(t)return new rn(t)}const lE=z(k,{when:ME},z(hn,{coord:rE}));function Ud(s,e){const t=ce({coordinates:[],whens:[]},lE,s,e);if(!t)return;const n=[],i=t.coordinates,r=t.whens;for(let o=0,a=Math.min(i.length,r.length);o<a;++o)i[o].length==3&&n.push(i[o][0],i[o][1],i[o][2],r[o]);return new at(n,"XYZM")}const hE=z(k,{href:O(Dd)},z(hn,{x:O(pe),y:O(pe),w:O(pe),h:O(pe)}));function cE(s,e){const t=ce({},hE,s,e);return t||null}const uE=z(k,{coordinates:sh(Md)});function oh(s,e){return ce(null,uE,s,e)}const po=z(k,{extrude:O(Ln),tessellate:O(Ln),altitudeMode:O(Xe)});function Bd(s,e){const t=ce({},po,s,e),n=oh(s,e);if(n){const i=new at(n,"XYZ");return i.setProperties(t,!0),i}}function zd(s,e){const t=ce({},po,s,e),n=oh(s,e);if(n){const i=new Qe(n,"XYZ",[n.length]);return i.setProperties(t,!0),i}}const dE=z(k,{LineString:mn(Bd),LinearRing:mn(zd),MultiGeometry:mn($d),Point:mn(Xd),Polygon:mn(Wd)});function $d(s,e){const t=ce([],dE,s,e);if(!t)return null;if(t.length===0)return new Ze(t);let n,i=!0;const r=t[0].getType();let o;for(let a=1,l=t.length;a<l;++a)if(o=t[a],o.getType()!=r){i=!1;break}if(i){let a,l;if(r=="Point"){const h=t[0];a=h.getLayout(),l=h.getFlatCoordinates();for(let c=1,u=t.length;c<u;++c)o=t[c],se(l,o.getFlatCoordinates());n=new ri(l,a),da(n,t)}else if(r=="LineString")n=new rn(t),da(n,t);else if(r=="Polygon")n=new In(t),da(n,t);else if(r=="GeometryCollection"||r.startsWith("Multi"))n=new Ze(t);else throw new Error("Unknown geometry type found")}else n=new Ze(t);return n}function Xd(s,e){const t=ce({},po,s,e),n=oh(s,e);if(n){const i=new ot(n,"XYZ");return i.setProperties(t,!0),i}}const fE=z(k,{innerBoundaryIs:LE,outerBoundaryIs:FE});function Wd(s,e){const t=ce({},po,s,e),n=ce([null],fE,s,e);if(n&&n[0]){const i=n[0],r=[i.length];for(let a=1,l=n.length;a<l;++a)se(i,n[a]),r.push(i.length);const o=new Qe(i,"XYZ",r);return o.setProperties(t,!0),o}}const gE=z(k,{IconStyle:qx,LabelStyle:Qx,LineStyle:tE,PolyStyle:iE});function ah(s,e){const t=ce({},gE,s,e,this);if(!t)return null;let n="fillStyle"in t?t.fillStyle:Cr;const i=t.fill;i!==void 0&&!i&&(n=null);let r;"imageStyle"in t?t.imageStyle!=rh&&(r=t.imageStyle):r=Wa;const o="textStyle"in t?t.textStyle:Wn,a="strokeStyle"in t?t.strokeStyle:Ya,l=t.outline;return l!==void 0&&!l?[new Oe({geometry:function(h){const c=h.getGeometry(),u=c.getType();if(u==="GeometryCollection"){const d=c;return new Ze(d.getGeometriesArrayRecursive().filter(function(f){const g=f.getType();return g!=="Polygon"&&g!=="MultiPolygon"}))}if(u!=="Polygon"&&u!=="MultiPolygon")return c},fill:n,image:r,stroke:a,text:o,zIndex:void 0}),new Oe({geometry:function(h){const c=h.getGeometry(),u=c.getType();if(u==="GeometryCollection"){const d=c;return new Ze(d.getGeometriesArrayRecursive().filter(function(f){const g=f.getType();return g==="Polygon"||g==="MultiPolygon"}))}if(u==="Polygon"||u==="MultiPolygon")return c},fill:n,stroke:null,zIndex:void 0})]:[new Oe({fill:n,image:r,stroke:a,text:o,zIndex:void 0})]}function da(s,e){const t=e.length,n=new Array(e.length),i=new Array(e.length),r=new Array(e.length);let o,a,l;o=!1,a=!1,l=!1;for(let h=0;h<t;++h){const c=e[h];n[h]=c.get("extrude"),i[h]=c.get("tessellate"),r[h]=c.get("altitudeMode"),o=o||n[h]!==void 0,a=a||i[h]!==void 0,l=l||r[h]}o&&s.set("extrude",n),a&&s.set("tessellate",i),l&&s.set("altitudeMode",r)}const _E=z(k,{displayName:O(Xe),value:O(Xe)});function mE(s,e){const t=s.getAttribute("name");Hi(_E,s,e);const n=e[e.length-1];t&&n.displayName?n[t]={value:n.value,displayName:n.displayName,toString:function(){return n.value}}:t!==null?n[t]=n.value:n.displayName!==null&&(n[n.displayName]=n.value),delete n.value}const pE=z(k,{Data:mE,SchemaData:CE});function Yd(s,e){Hi(pE,s,e)}function jd(s,e){Hi(Fd,s,e)}const yE=z(k,{Style:O(ah),key:O(Xe),styleUrl:O(Od)});function xE(s,e){const t=ce({},yE,s,e,this);if(!t)return;const n=t.key;if(n&&n=="normal"){const i=t.styleUrl;i&&(e[e.length-1]=i);const r=t.Style;r&&(e[e.length-1]=r)}}function EE(s,e){const t=Gd.call(this,s,e);if(!t)return;const n=e[e.length-1];if(Array.isArray(t))n.Style=t;else if(typeof t=="string")n.styleUrl=t;else throw new Error("`styleMapValue` has an unknown type")}const TE=z(k,{SimpleData:RE});function CE(s,e){Hi(TE,s,e)}function RE(s,e){const t=s.getAttribute("name");if(t!==null){const n=Xe(s),i=e[e.length-1];i[t]=n}}const SE=z(k,{altitudeMode:O(Xe),minAltitude:O(pe),maxAltitude:O(pe),north:O(pe),south:O(pe),east:O(pe),west:O(pe)});function vE(s,e){const t=ce({},SE,s,e);if(!t)return;const n=e[e.length-1],i=[parseFloat(t.west),parseFloat(t.south),parseFloat(t.east),parseFloat(t.north)];n.extent=i,n.altitudeMode=t.altitudeMode,n.minAltitude=parseFloat(t.minAltitude),n.maxAltitude=parseFloat(t.maxAltitude)}const wE=z(k,{minLodPixels:O(pe),maxLodPixels:O(pe),minFadeExtent:O(pe),maxFadeExtent:O(pe)});function PE(s,e){const t=ce({},wE,s,e);if(!t)return;const n=e[e.length-1];n.minLodPixels=parseFloat(t.minLodPixels),n.maxLodPixels=parseFloat(t.maxLodPixels),n.minFadeExtent=parseFloat(t.minFadeExtent),n.maxFadeExtent=parseFloat(t.maxFadeExtent)}const IE=z(k,{LinearRing:mn(kd)});function LE(s,e){const t=ce([],IE,s,e);t.length>0&&e[e.length-1].push(...t)}const AE=z(k,{LinearRing:sh(kd)});function FE(s,e){const t=ce(void 0,AE,s,e);if(t){const n=e[e.length-1];n[0]=t}}function bE(s,e){Hi(Bx,s,e)}function ME(s,e){const n=e[e.length-1].whens,i=an(s,!1),r=Date.parse(i);n.push(isNaN(r)?0:r)}function yo(s,e){const t=Et(e),i=[(t.length==4?t[3]:1)*255,t[2],t[1],t[0]];for(let r=0;r<4;++r){const o=Math.floor(i[r]).toString(16);i[r]=o.length==1?"0"+o:o}gt(s,i.join(""))}function DE(s,e,t){const n=t[t.length-1],i=n.layout,r=n.stride;let o;if(i=="XY"||i=="XYM")o=2;else if(i=="XYZ"||i=="XYZM")o=3;else throw new Error("Invalid geometry layout");const a=e.length;let l="";if(a>0){l+=e[0];for(let h=1;h<o;++h)l+=","+e[h];for(let h=r;h<a;h+=r){l+=" "+e[h];for(let c=1;c<o;++c)l+=","+e[h+c]}}gt(s,l)}const Rr=z(k,{Data:W(OE),value:W(GE),displayName:W(NE)});function OE(s,e,t){s.setAttribute("name",e.name);const n={node:s},i=e.value;typeof i=="object"?(i!==null&&i.displayName&&Ce(n,Rr,xt,[i.displayName],t,["displayName"]),i!==null&&i.value&&Ce(n,Rr,xt,[i.value],t,["value"])):Ce(n,Rr,xt,[i],t,["value"])}function NE(s,e){gt(s,e)}function GE(s,e){gt(s,e)}const kE=z(k,{Placemark:W(Kd)}),UE=function(s,e,t){const n=e[e.length-1].node;return Ws(n.namespaceURI,"Placemark")};function BE(s,e,t){Ce({node:s},kE,UE,e,t,void 0,this)}const zE=ln("Data");function $E(s,e,t){const n={node:s},i=e.names,r=e.values,o=i.length;for(let a=0;a<o;a++)Ce(n,Rr,zE,[{name:i[a],value:r[a]}],t)}const Lc=z(k,["href"],z(hn,["x","y","w","h"])),Ac=z(k,{href:W(gt)},z(hn,{x:W(Xn),y:W(Xn),w:W(Xn),h:W(Xn)})),XE=function(s,e,t){return Ws(hn[0],"gx:"+t)};function WE(s,e,t){const n={node:s},i=t[t.length-1].node;let r=Lc[i.namespaceURI],o=Pt(e,r);Ce(n,Ac,xt,o,t,r),r=Lc[hn[0]],o=Pt(e,r),Ce(n,Ac,XE,o,t,r)}const YE=z(k,["scale","heading","Icon","color","hotSpot"]),jE=z(k,{Icon:W(WE),color:W(yo),heading:W(Xn),hotSpot:W(x0),scale:W(qd)});function VE(s,e,t){const n={node:s},i={},r=e.getSrc(),o=e.getSize(),a=e.getImageSize(),l={href:r};if(o){l.w=o[0],l.h=o[1];const _=e.getAnchor(),p=e.getOrigin();if(p&&a&&p[0]!==0&&p[1]!==o[1]&&(l.x=p[0],l.y=a[1]-(p[1]+o[1])),_&&(_[0]!==o[0]/2||_[1]!==o[1]/2)){const y={x:_[0],xunits:"pixels",y:o[1]-_[1],yunits:"pixels"};i.hotSpot=y}}i.Icon=l;let h=e.getScaleArray()[0],c=o;if(c===null&&(c=xs),c.length==2){const _=Zr(c);h=h/_}h!==1&&(i.scale=h);const u=e.getRotation();u!==0&&(i.heading=u);const d=e.getColor();d&&(i.color=d);const f=t[t.length-1].node,g=YE[f.namespaceURI],m=Pt(i,g);Ce(n,jE,xt,m,t,g)}const ZE=z(k,["color","scale"]),KE=z(k,{color:W(yo),scale:W(qd)});function HE(s,e,t){const n={node:s},i={},r=e.getFill();r&&(i.color=r.getColor());const o=e.getScale();o&&o!==1&&(i.scale=o);const a=t[t.length-1].node,l=ZE[a.namespaceURI],h=Pt(i,l);Ce(n,KE,xt,h,t,l)}const qE=z(k,["color","width"]),JE=z(k,{color:W(yo),width:W(Xn)});function QE(s,e,t){const n={node:s},i={color:e.getColor(),width:Number(e.getWidth())||1},r=t[t.length-1].node,o=qE[r.namespaceURI],a=Pt(i,o);Ce(n,JE,xt,a,t,o)}const e0={Point:"Point",LineString:"LineString",LinearRing:"LinearRing",Polygon:"Polygon",MultiPoint:"MultiGeometry",MultiLineString:"MultiGeometry",MultiPolygon:"MultiGeometry",GeometryCollection:"MultiGeometry"},Vd=function(s,e,t){if(s){const n=e[e.length-1].node;return Ws(n.namespaceURI,e0[s.getType()])}},t0=ln("Point"),n0=ln("LineString"),i0=ln("LinearRing"),s0=ln("Polygon"),r0=z(k,{LineString:W(Di),Point:W(Di),Polygon:W(Hd),GeometryCollection:W(Zd)});function Zd(s,e,t){const n={node:s},i=e.getType();let r=[],o;if(i==="GeometryCollection")e.getGeometriesArrayRecursive().forEach(function(a){const l=a.getType();if(l==="MultiPoint")r=r.concat(a.getPoints());else if(l==="MultiLineString")r=r.concat(a.getLineStrings());else if(l==="MultiPolygon")r=r.concat(a.getPolygons());else if(l==="Point"||l==="LineString"||l==="Polygon")r.push(a);else throw new Error("Unknown geometry type")}),o=Vd;else if(i==="MultiPoint")r=e.getPoints(),o=t0;else if(i==="MultiLineString")r=e.getLineStrings(),o=n0;else if(i==="MultiPolygon")r=e.getPolygons(),o=s0;else throw new Error("Unknown geometry type");Ce(n,r0,o,r,t)}const o0=z(k,{LinearRing:W(Di)});function Fc(s,e,t){Ce({node:s},o0,i0,[e],t)}const fa=z(k,{ExtendedData:W($E),MultiGeometry:W(Zd),LineString:W(Di),LinearRing:W(Di),Point:W(Di),Polygon:W(Hd),Style:W(y0),address:W(gt),description:W(gt),name:W(gt),open:W(zi),phoneNumber:W(gt),styleUrl:W(gt),visibility:W(zi)}),a0=z(k,["name","open","visibility","address","phoneNumber","description","styleUrl","Style"]),l0=ln("ExtendedData");function Kd(s,e,t){const n={node:s};e.getId()&&s.setAttribute("id",e.getId());const i=e.getProperties(),r={address:1,description:1,name:1,open:1,phoneNumber:1,styleUrl:1,visibility:1};r[e.getGeometryName()]=1;const o=Object.keys(i||{}).sort().filter(function(f){return!r[f]}),a=e.getStyleFunction();if(a){const f=a(e,0);if(f){const g=Array.isArray(f)?f:[f];let m=g;if(e.getGeometry()&&(m=g.filter(function(_){const p=_.getGeometryFunction()(e);if(p){const y=p.getType();return y==="GeometryCollection"?p.getGeometriesArrayRecursive().filter(function(E){const x=E.getType();return x==="Point"||x==="MultiPoint"}).length:y==="Point"||y==="MultiPoint"}})),this.writeStyles_){let _=g,p=g;e.getGeometry()&&(_=g.filter(function(y){const E=y.getGeometryFunction()(e);if(E){const x=E.getType();return x==="GeometryCollection"?E.getGeometriesArrayRecursive().filter(function(T){const R=T.getType();return R==="LineString"||R==="MultiLineString"}).length:x==="LineString"||x==="MultiLineString"}}),p=g.filter(function(y){const E=y.getGeometryFunction()(e);if(E){const x=E.getType();return x==="GeometryCollection"?E.getGeometriesArrayRecursive().filter(function(T){const R=T.getType();return R==="Polygon"||R==="MultiPolygon"}).length:x==="Polygon"||x==="MultiPolygon"}})),i.Style={pointStyles:m,lineStyles:_,polyStyles:p}}if(m.length&&i.name===void 0){const _=m[0].getText();_&&(i.name=_.getText())}}}const l=t[t.length-1].node,h=a0[l.namespaceURI],c=Pt(i,h);if(Ce(n,fa,xt,c,t,h),o.length>0){const f=Pt(i,o);Ce(n,fa,l0,[{names:o,values:f}],t)}const u=t[0];let d=e.getGeometry();d&&(d=Jn(d,!0,u)),Ce(n,fa,Vd,[d],t)}const h0=z(k,["extrude","tessellate","altitudeMode","coordinates"]),c0=z(k,{extrude:W(zi),tessellate:W(zi),altitudeMode:W(gt),coordinates:W(DE)});function Di(s,e,t){const n=e.getFlatCoordinates(),i={node:s};i.layout=e.getLayout(),i.stride=e.getStride();const r=e.getProperties();r.coordinates=n;const o=t[t.length-1].node,a=h0[o.namespaceURI],l=Pt(r,a);Ce(i,c0,xt,l,t,a)}const u0=z(k,["color","fill","outline"]),bc=z(k,{outerBoundaryIs:W(Fc),innerBoundaryIs:W(Fc)}),d0=ln("innerBoundaryIs"),f0=ln("outerBoundaryIs");function Hd(s,e,t){const n=e.getLinearRings(),i=n.shift(),r={node:s};Ce(r,bc,d0,n,t),Ce(r,bc,f0,[i],t)}const g0=z(k,{color:W(yo),fill:W(zi),outline:W(zi)});function _0(s,e,t){const n={node:s},i=e.getFill(),r=e.getStroke(),o={color:i?i.getColor():void 0,fill:i?void 0:!1,outline:r?void 0:!1},a=t[t.length-1].node,l=u0[a.namespaceURI],h=Pt(o,l);Ce(n,g0,xt,h,t,l)}function qd(s,e){Xn(s,Math.round(e*1e6)/1e6)}const m0=z(k,["IconStyle","LabelStyle","LineStyle","PolyStyle"]),p0=z(k,{IconStyle:W(VE),LabelStyle:W(HE),LineStyle:W(QE),PolyStyle:W(_0)});function y0(s,e,t){const n={node:s},i={};if(e.pointStyles.length){const l=e.pointStyles[0].getText();l&&(i.LabelStyle=l);const h=e.pointStyles[0].getImage();h&&typeof h.getSrc=="function"&&(i.IconStyle=h)}if(e.lineStyles.length){const l=e.lineStyles[0].getStroke();l&&(i.LineStyle=l)}if(e.polyStyles.length){const l=e.polyStyles[0].getStroke();l&&!i.LineStyle&&(i.LineStyle=l),i.PolyStyle=e.polyStyles[0]}const r=t[t.length-1].node,o=m0[r.namespaceURI],a=Pt(i,o);Ce(n,p0,xt,a,t,o)}function x0(s,e){s.setAttribute("x",String(e.x)),s.setAttribute("y",String(e.y)),s.setAttribute("xunits",e.xunits),s.setAttribute("yunits",e.yunits)}var $0=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function X0(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}export{kf as $,R0 as A,It as B,ao as C,k0 as D,Ss as E,wt as F,S0 as G,G0 as H,A0 as I,Mr as J,U0 as K,at as L,w0 as M,Zn as N,I0 as O,Qe as P,zs as Q,ho as R,Rd as S,L0 as T,Vi as U,zl as V,qt as W,T0 as X,O0 as Y,F0 as Z,E0 as _,N0 as a,Gf as a0,C0 as a1,Hp as a2,M0 as a3,D0 as a4,b0 as a5,B0 as a6,z0 as a7,$0 as a8,X0 as a9,ed as b,rn as c,In as d,fo as e,sn as f,D as g,Oe as h,Ee as i,Gt as j,Bs as k,ii as l,ji as m,ze as n,ot as o,Ve as p,Uc as q,bh as r,Pn as s,Ns as t,cf as u,Be as v,Je as w,Eu as x,n_ as y,Li as z};
|
||
//# sourceMappingURL=openlayers-CvK8xBSr.js.map
|