UNPKG

maplair

Version:

JavaScript library for mobile-friendly interactive maps

7 lines • 142 kB
/* @preserve
 * Maplair 4.0.0-alpha.1, a JS library for interactive maps. https://maplair.org
 * (c) 2026 Maplair contributors, (c) 2010-2026 Volodymyr Agafonkin, (c) 2010-2011 CloudMade
 */

var e=Object.defineProperty,t=(t,n)=>{let r={};for(var i in t)e(r,i,{get:t[i],enumerable:!0});return n||e(r,Symbol.toStringTag,{value:`Module`}),r},n=`4.0.0-alpha.1`,r=/* @__PURE__ */ t({falseFn:()=>c,formatNum:()=>l,lastId:()=>i,setOptions:()=>f,splitWords:()=>d,stamp:()=>a,template:()=>m,throttle:()=>o,wrapNum:()=>s});let i=0;function a(e){return`_maplair_id`in e||(e._maplair_id=++i),e._maplair_id}function o(e,t,n){let r,i;function a(){r=!1,i&&=(o.apply(n,i),!1)}function o(...o){r?i=o:(e.apply(n,o),setTimeout(a,t),r=!0)}return o}function s(e,t,n){let r=t[1],i=t[0],a=r-i;return e===r&&n?e:((e-i)%a+a)%a+i}function c(){return!1}function l(e,t){if(t===!1)return e;let n=10**(t===void 0?6:t);return Math.round(e*n)/n}const u=/\s+/;function d(e){return e.trim().split(u)}function f(e,t){Object.hasOwn(e,`options`)||(e.options=e.options?Object.create(e.options):{});for(let n in t)Object.hasOwn(t,n)&&(e.options[n]=t[n]);return e.options}const p=/\{ *([\w_ -]+) *\}/g;function m(e,t){return e.replace(p,(e,n)=>{let r=t[n];if(r===void 0)throw Error(`No value provided for variable ${e}`);return typeof r==`function`&&(r=r(t)),r})}var h=class{static include(e){let t=this.prototype.options;for(let t of n(e))this.prototype[t]=e[t];return e.options&&(this.prototype.options=t,this.mergeOptions(e.options)),this;function*n(e){do{if(e===Object||e===Object.prototype)break;for(let t of Object.getOwnPropertyNames(e))yield t}while((e=Object.getPrototypeOf(e))!==void 0)}}static setDefaultOptions(e){return f(this.prototype,e),this}static mergeOptions(e){return this.prototype.options??={},Object.assign(this.prototype.options,e),this}static addInitHook(e,...t){let n=typeof e==`function`?e:function(){this[e](...t)};return Object.hasOwn(this,`_initHooks`)||(this._initHooks=[]),this._initHooks.push(n),this}constructor(){f(this)}callInitHooks(e=this.constructor){let t=this._initHooksCalledFor;if(t&&(t===e||t.prototype instanceof e))return this;let n=[];for(let r=e;r&&r!==Function.prototype&&r!==t;r=Object.getPrototypeOf(r))n.unshift(r);this._initHooksCalledFor=e;for(let e of n)if(Object.hasOwn(e,`_initHooks`))for(let t of e._initHooks)t.call(this);return this}},g=class e{constructor(t,n,r){if(!e.validate(t,n))throw Error(`Invalid Point object: (${t}, ${n})`);let i,a;t instanceof e?(i=t.x,a=t.y):Array.isArray(t)?(i=t[0],a=t[1]):typeof t==`object`&&`x`in t&&`y`in t?(i=t.x,a=t.y):(i=t,a=n),this.x=r?Math.round(i):i,this.y=r?Math.round(a):a}static validate(t,n){return!!(t instanceof e||Array.isArray(t)||t&&typeof t==`object`&&`x`in t&&`y`in t||(t||t===0)&&(n||n===0))}add(t){return new e(this)._add(new e(t))}_add(e){return this.x+=e.x,this.y+=e.y,this}subtract(t){return new e(this)._subtract(new e(t))}_subtract(e){return this.x-=e.x,this.y-=e.y,this}divideBy(t){return new e(this)._divideBy(t)}_divideBy(e){return this.x/=e,this.y/=e,this}multiplyBy(t){return new e(this)._multiplyBy(t)}_multiplyBy(e){return this.x*=e,this.y*=e,this}scaleBy(t){return new e(this.x*t.x,this.y*t.y)}unscaleBy(t){return new e(this.x/t.x,this.y/t.y)}round(){return new e(this)._round()}_round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}floor(){return new e(this)._floor()}_floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return new e(this)._ceil()}_ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}trunc(){return new e(this)._trunc()}_trunc(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}distanceTo(t){t=new e(t);let n=t.x-this.x,r=t.y-this.y;return Math.sqrt(n*n+r*r)}equals(t){return t=new e(t),t.x===this.x&&t.y===this.y}contains(t){return t=new e(t),Math.abs(t.x)<=Math.abs(this.x)&&Math.abs(t.y)<=Math.abs(this.y)}toString(){return`Point(${l(this.x)}, ${l(this.y)})`}};const ee=ue(`chrome`),te=!ee&&ue(`safari`),ne=typeof orientation<`u`,re=navigator.preferences?.reducedMotion?.value?navigator.preferences.reducedMotion.value===`reduce`:typeof window>`u`||window?.matchMedia(`(prefers-reduced-motion: reduce)`).matches,ie=typeof window>`u`?!1:!!window.PointerEvent,ae=typeof window>`u`?!1:`ontouchstart`in window||!!window.TouchEvent,oe=ae||ie,se=typeof window>`u`||window.devicePixelRatio===void 0?!1:window.devicePixelRatio>1,ce=typeof navigator>`u`||navigator.platform===void 0?!1:navigator.platform.startsWith(`Mac`),le=typeof navigator>`u`||navigator.platform===void 0?!1:navigator.platform.startsWith(`Linux`);function ue(e){return typeof navigator>`u`||navigator.userAgent===void 0?!1:navigator.userAgent.toLowerCase().includes(e)}var _={chrome:ee,safari:te,mobile:ne,reducedMotion:re,pointer:ie,touch:oe,touchNative:ae,retina:se,mac:ce,linux:le};function de(e){let t={bubbles:e.bubbles,cancelable:e.cancelable,composed:e.composed,detail:2,view:e.view,screenX:e.screenX,screenY:e.screenY,clientX:e.clientX,clientY:e.clientY,ctrlKey:e.ctrlKey,shiftKey:e.shiftKey,altKey:e.altKey,metaKey:e.metaKey,button:e.button,buttons:e.buttons,relatedTarget:e.relatedTarget,region:e.region},n;return e instanceof PointerEvent?(t={...t,pointerId:e.pointerId,width:e.width,height:e.height,pressure:e.pressure,tangentialPressure:e.tangentialPressure,tiltX:e.tiltX,tiltY:e.tiltY,twist:e.twist,pointerType:e.pointerType,isPrimary:e.isPrimary},n=new PointerEvent(`dblclick`,t)):n=new MouseEvent(`dblclick`,t),n}function fe(e,t){e.addEventListener(`dblclick`,t);let n=0,r;function i(e){if(e.detail!==1){r=e.detail;return}if(e.pointerType===`mouse`||e.sourceCapabilities&&!e.sourceCapabilities.firesTouchEvents)return;let t=De(e);if(t.some(e=>e instanceof HTMLLabelElement&&e.attributes.for)&&!t.some(e=>e instanceof HTMLInputElement||e instanceof HTMLSelectElement))return;let i=Date.now();i-n<=200?(r++,r===2&&e.target.dispatchEvent(de(e))):r=1,n=i}return e.addEventListener(`click`,i),{dblclick:t,simDblclick:i}}function pe(e,t){e.removeEventListener(`dblclick`,t.dblclick),e.removeEventListener(`click`,t.simDblclick)}var me=/* @__PURE__ */ t({cleanupPointers:()=>ye,disablePointerDetection:()=>ge,enablePointerDetection:()=>he,getPointers:()=>b});const v=/* @__PURE__ */ new Map;function he(e){e.addEventListener(`pointerdown`,_e,{capture:!0}),e.addEventListener(`pointermove`,ve,{capture:!0}),e.addEventListener(`pointerup`,y,{capture:!0}),e.addEventListener(`pointercancel`,y,{capture:!0}),v.clear()}function ge(e){e.removeEventListener(`pointerdown`,_e,{capture:!0}),e.removeEventListener(`pointermove`,ve,{capture:!0}),e.removeEventListener(`pointerup`,y,{capture:!0}),e.removeEventListener(`pointercancel`,y,{capture:!0})}function _e(e){e.target.setPointerCapture(e.pointerId),v.set(e.pointerId,e)}function ve(e){v.has(e.pointerId)&&v.set(e.pointerId,e)}function y(e){e.target.releasePointerCapture(e.pointerId),v.delete(e.pointerId)}function b(){return[...v.values()]}function ye(){for(let e of v.values())try{e.target.releasePointerCapture(e.pointerId)}catch{}v.clear()}var be=/* @__PURE__ */ t({PointerEvents:()=>me,disableClickPropagation:()=>T,disableScrollPropagation:()=>Ee,getPointerPosition:()=>Oe,getPropagationPath:()=>De,getWheelDelta:()=>Ae,getWheelPxFactor:()=>ke,isExternalTarget:()=>je,off:()=>C,on:()=>x,preventDefault:()=>E,stop:()=>D,stopPropagation:()=>w});function x(e,t,n,r){if(t&&typeof t==`object`)for(let[r,i]of Object.entries(t))we(e,r,i,n);else for(let i of d(t))we(e,i,n,r);return this}const S=`_maplair_events`;function C(e,t,n,r){if(arguments.length===1)Se(e),delete e[S];else if(t&&typeof t==`object`)for(let[r,i]of Object.entries(t))Te(e,r,i,n);else if(t=d(t),arguments.length===2)Se(e,e=>t.includes(e));else for(let i of t)Te(e,i,n,r);return this}const xe=/\d/;function Se(e,t){for(let n of Object.keys(e[S]??{})){let r=n.split(xe)[0];(!t||t(r))&&Te(e,r,null,null,n)}}const Ce={pointerenter:`pointerover`,pointerleave:`pointerout`,wheel:typeof window>`u`?!1:!(`onwheel`in window)&&`mousewheel`};function we(e,t,n,r){let i=t+a(n)+(r?`_${a(r)}`:``);if(e[S]&&e[S][i])return this;let o=function(t){return n.call(r||e,t)},s=o;_.touch&&t===`dblclick`?o=fe(e,o):`addEventListener`in e?t===`wheel`||t===`mousewheel`?e.addEventListener(Ce[t]||t,o,{passive:!1}):t===`pointerenter`||t===`pointerleave`?(o=function(t){je(e,t)&&s(t)},e.addEventListener(Ce[t],o,!1)):e.addEventListener(t,s,!1):e.attachEvent(`on${t}`,o),e[S]??={},e[S][i]=o}function Te(e,t,n,r,i){i??=t+a(n)+(r?`_${a(r)}`:``);let o=e[S]&&e[S][i];if(!o)return this;_.touch&&t===`dblclick`?pe(e,o):`removeEventListener`in e?e.removeEventListener(Ce[t]||t,o,!1):e.detachEvent(`on${t}`,o),e[S][i]=null}function w(e){return e.stopPropagation?e.stopPropagation():e.originalEvent?e.originalEvent._stopped=!0:console.debug(`Unsupported event`,e),this}function Ee(e){return we(e,`wheel`,w),this}function T(e){return x(e,`pointerdown dblclick contextmenu`,w),e._maplair_disable_click=!0,this}function E(e){return e.preventDefault?.(),this}function D(e){return E(e),w(e),this}function De(e){return e.composedPath()}function Oe(e,t){if(!t)return new g(e.clientX,e.clientY);let n=Ge(t),r=n.boundingClientRect;return new g((e.clientX-r.left)/n.x-t.clientLeft,(e.clientY-r.top)/n.y-t.clientTop)}function ke(){let e=window.devicePixelRatio;return _.linux&&_.chrome?e:_.mac?e*3:e>0?2*e:1}function Ae(e){return e.deltaY&&e.deltaMode===0?-e.deltaY/ke():e.deltaY&&e.deltaMode===1?-e.deltaY*20:e.deltaY&&e.deltaMode===2?-e.deltaY*60:(e.deltaX||e.deltaZ,0)}function je(e,t){let n=t.relatedTarget;if(!n)return!0;try{for(;n&&n!==e;)n=n.parentNode}catch{return!1}return n!==e}var Me=/* @__PURE__ */ t({create:()=>O,disableImageDrag:()=>ze,disableTextSelection:()=>Le,enableImageDrag:()=>Be,enableTextSelection:()=>Re,get:()=>Ne,getPosition:()=>N,getScale:()=>Ge,getSizedParentNode:()=>We,preventOutline:()=>Ue,restoreOutline:()=>F,setPosition:()=>M,setTransform:()=>j,toBack:()=>A,toFront:()=>k});function Ne(e){return typeof e==`string`?document.getElementById(e):e}function O(e,t,n){let r=document.createElement(e);return r.className=t??``,n?.appendChild(r),r}function k(e){let t=e.parentNode;t&&t.lastChild!==e&&t.appendChild(e)}function A(e){let t=e.parentNode;t&&t.firstChild!==e&&t.insertBefore(e,t.firstChild)}function j(e,t,n){let r=t??new g(0,0),i=`translate3d(${r.x}px, ${r.y}px, 0px)${n?` scale(${n})`:``}`;e.style.transform!==i&&(e.style.transform=i)}const Pe=/* @__PURE__ */ new WeakMap;function M(e,t){Pe.set(e,t),j(e,t)}function N(e){return Pe.get(e)??new g(0,0)}const Fe=typeof document>`u`?{}:document.documentElement.style,Ie=[`userSelect`,`WebkitUserSelect`].find(e=>e in Fe);let P;function Le(){let e=Fe[Ie];e!==`none`&&(P=e,Fe[Ie]=`none`)}function Re(){P!==void 0&&(Fe[Ie]=P,P=void 0)}function ze(){x(window,`dragstart`,E)}function Be(){C(window,`dragstart`,E)}let Ve,He;function Ue(e){for(;e.tabIndex===-1;)e=e.parentNode;e.style&&(F(),Ve=e,He=e.style.outlineStyle,e.style.outlineStyle=`none`,x(window,`keydown`,F))}function F(){Ve&&(Ve.style.outlineStyle=He,Ve=void 0,He=void 0,C(window,`keydown`,F))}function We(e){do e=e.parentNode;while((!e.offsetWidth||!e.offsetHeight)&&e!==document.body);return e}function Ge(e){let t=e.getBoundingClientRect();return{x:t.width/e.offsetWidth||1,y:t.height/e.offsetHeight||1,boundingClientRect:t}}var I=class e extends h{static{this.setDefaultOptions({position:`topright`})}constructor(t){super(),f(this,t),this.callInitHooks(e)}getPosition(){return this.options.position}setPosition(e){let t=this._map;return t?.removeControl(this),this.options.position=e,t?.addControl(this),this}getContainer(){return this._container}addTo(e){this.remove(),this._map=e;let t=this._container=this.onAdd(e),n=this.getPosition(),r=e._controlCorners[n];return t.classList.add(`maplair-control`),n.includes(`bottom`)?r.insertBefore(t,r.firstChild):r.appendChild(t),this._map.on(`unload`,this.remove,this),this}remove(){return this._map?(this._container.remove(),this.onRemove&&this.onRemove(this._map),this._map.off(`unload`,this.remove,this),this._map=null,this):this}_refocusOnMap(e){this._map&&e&&(e.screenX!==0||e.screenY!==0)&&this._map.getContainer().focus()}static register(e){e.include({addControl(e){return e.addTo(this),this},removeControl(e){return e.remove(),this},_initControlPos(){let e=this._controlCorners={},t=`maplair-`,n=this._controlContainer=O(`div`,`${t}control-container`,this._container);function r(r,i){let a=`${t+r} ${t}${i}`;e[r+i]=O(`div`,a,n)}r(`top`,`left`),r(`top`,`right`),r(`bottom`,`left`),r(`bottom`,`right`)},_clearControlPos(){for(let e of Object.values(this._controlCorners))e.remove();this._controlContainer.remove(),delete this._controlCorners,delete this._controlContainer}})}},L=class{static#e={};static#t=null;static registerLocale(e,t){this.#e[e]={...this.#e[e],...t}}static setLocale(e){this.#t=e}static getLocale(){return this.#t}static translate(e,t={}){if(this.#t===null)return m(e,t);let n=this.#e[this.#t]?.[e];if(!n)return console.warn(`No translation found for "${e}", falling back to the original string.`),m(e,t);try{return m(n,t)}catch(e){return console.error(`Error while translating "${n}".`,e),n}}},Ke=class e extends I{static{this.setDefaultOptions({position:`bottomright`,prefix:null})}constructor(t){if(super(t),this.options.prefix===null){let e=L.translate(`A JavaScript library for interactive maps`);this.options.prefix=`<a target="_blank" href="https://maplair.org" title="${e}"><span aria-hidden="true" class="maplair-attribution-leaf">&#x1F341;</span>Maplair</a>`}this._attributions={},this.callInitHooks(e)}onAdd(e){e.attributionControl=this,this._container=O(`div`,`maplair-control-attribution`),T(this._container);for(let t of Object.values(e._layers))t.getAttribution&&this.addAttribution(t.getAttribution());return this._update(),e.on(`layeradd`,this._addAttribution,this),this._container}onRemove(e){e.off(`layeradd`,this._addAttribution,this)}_addAttribution(e){e.layer.getAttribution&&(this.addAttribution(e.layer.getAttribution()),e.layer.once(`remove`,()=>this.removeAttribution(e.layer.getAttribution())))}setPrefix(e){return this.options.prefix=e,this._update(),this}addAttribution(e){return e?(this._attributions[e]||(this._attributions[e]=0),this._attributions[e]++,this._update(),this):this}removeAttribution(e){return e&&this._attributions[e]&&(this._attributions[e]--,this._update()),this}_update(){if(!this._map)return;let e=Object.keys(this._attributions).filter(e=>this._attributions[e]),t=[];this.options.prefix&&t.push(this.options.prefix),e.length&&t.push(e.join(`, `)),this._container.innerHTML=t.join(` <span aria-hidden="true">|</span> `)}static register(t){t.mergeOptions({attributionControl:!0}),t.addInitHook(function(){this.options.attributionControl&&new e().addTo(this)})}},qe=class e extends I{static{this.setDefaultOptions({collapsed:!0,collapseDelay:0,position:`topright`,autoZIndex:!0,hideSingleBase:!1,sortLayers:!1,sortFunction(e,t,n,r){return n<r?-1:+(r<n)}})}constructor(t,n,r){super(r),this._layerControlInputs=[],this._layers=[],this._lastZIndex=0,this._handlingClick=!1,this._preventClick=!1;for(let[e,n]of Object.entries(t??{}))this._addLayer(n,e);for(let[e,t]of Object.entries(n??{}))this._addLayer(t,e,!0);this.callInitHooks(e)}onAdd(e){this._initLayout(),this._update(),this._map=e,e.on(`zoomend`,this._checkDisabledLayers,this);for(let e of this._layers)e.layer.on(`add remove`,this._onLayerChange,this);return this.options.collapsed||e.on(`resize`,this._expandIfNotCollapsed,this),this._container}addTo(e){return super.addTo(e),this._expandIfNotCollapsed()}onRemove(){this._map.off(`zoomend`,this._checkDisabledLayers,this);for(let e of this._layers)e.layer.off(`add remove`,this._onLayerChange,this);this._map.off(`resize`,this._expandIfNotCollapsed,this)}addBaseLayer(e,t){return this._addLayer(e,t),this._map?this._update():this}addOverlay(e,t){return this._addLayer(e,t,!0),this._map?this._update():this}removeLayer(e){e.off(`add remove`,this._onLayerChange,this);let t=this._getLayer(a(e));return t&&this._layers.splice(this._layers.indexOf(t),1),this._map?this._update():this}expand(){clearTimeout(this._collapseDelayTimeout),this._container.classList.add(`maplair-control-layers-expanded`),this._section.style.height=null;let e=this._map.getSize().y-(this._container.offsetTop+50);return e<this._section.clientHeight?(this._section.classList.add(`maplair-control-layers-scrollbar`),this._section.style.height=`${e}px`):this._section.classList.remove(`maplair-control-layers-scrollbar`),this._checkDisabledLayers(),this}collapse(e){if(!e||e.type!==`pointerleave`&&e.type!==`pointerout`||e.pointerType!==`touch`){if(this.options.collapseDelay>0)return this._collapseDelayTimeout=setTimeout(()=>{this._container.classList.remove(`maplair-control-layers-expanded`)},this.options.collapseDelay),this;this._container.classList.remove(`maplair-control-layers-expanded`)}return this}_initLayout(){let e=`maplair-control-layers`,t=this._container=O(`div`,e),n=this.options.collapsed;T(t),Ee(t);let r=this._section=O(`fieldset`,`${e}-list`);n&&(this._map.on(`click`,this.collapse,this),x(t,{pointerenter:this._expandSafely,pointerleave:this.collapse},this));let i=this._layersLink=O(`a`,`${e}-toggle`,t);i.href=`#`,i.title=L.translate(`Layers`),i.setAttribute(`role`,`button`),x(i,{keydown(e){e.code===`Enter`&&this._expandSafely()},click(e){e.preventDefault(),this._expandSafely()}},this),n||this.expand(),this._baseLayersList=O(`div`,`${e}-base`,r),this._separator=O(`div`,`${e}-separator`,r),this._overlaysList=O(`div`,`${e}-overlays`,r),t.appendChild(r)}_getLayer(e){for(let t of this._layers)if(t&&a(t.layer)===e)return t}_addLayer(e,t,n){this._map&&e.on(`add remove`,this._onLayerChange,this),this._layers.push({layer:e,name:t,overlay:n}),this.options.sortLayers&&this._layers.sort(((e,t)=>this.options.sortFunction(e.layer,t.layer,e.name,t.name))),this.options.autoZIndex&&e.setZIndex&&(this._lastZIndex++,e.setZIndex(this._lastZIndex)),this._expandIfNotCollapsed()}_update(){if(!this._container)return this;this._baseLayersList.replaceChildren(),this._overlaysList.replaceChildren(),this._layerControlInputs=[];let e,t,n=0;for(let r of this._layers)this._addItem(r),t||=r.overlay,e||=!r.overlay,n+=+!r.overlay;return this.options.hideSingleBase&&(e&&=n>1,this._baseLayersList.style.display=e?``:`none`),this._separator.style.display=t&&e?``:`none`,this}_onLayerChange(e){this._handlingClick||this._update();let t=this._getLayer(a(e.target)),n=t.overlay?e.type===`add`?`overlayadd`:`overlayremove`:e.type===`add`?`baselayerchange`:null;n&&this._map.fire(n,t)}_addItem(e){let t=document.createElement(`label`),n=this._map.hasLayer(e.layer),r=document.createElement(`input`);r.type=e.overlay?`checkbox`:`radio`,r.className=`maplair-control-layers-selector`,r.defaultChecked=n,e.overlay||(r.name=`maplair-base-layers_${a(this)}`),this._layerControlInputs.push(r),r.layerId=a(e.layer),x(r,`click`,this._onInputClick,this);let i=document.createElement(`span`);i.innerHTML=` ${e.name}`;let o=document.createElement(`span`);return t.appendChild(o),o.appendChild(r),o.appendChild(i),(e.overlay?this._overlaysList:this._baseLayersList).appendChild(t),this._checkDisabledLayers(),t}_onInputClick(e){if(this._preventClick)return;let t=this._layerControlInputs,n=[],r=[];this._handlingClick=!0;for(let e of t){let t=this._getLayer(e.layerId).layer;e.checked?n.push(t):e.checked||r.push(t)}for(let e of r)this._map.hasLayer(e)&&this._map.removeLayer(e);for(let e of n)this._map.hasLayer(e)||this._map.addLayer(e);this._handlingClick=!1,this._refocusOnMap(e)}_checkDisabledLayers(){let e=this._layerControlInputs,t=this._map.getZoom();for(let n of e){let e=this._getLayer(n.layerId).layer;n.disabled=e.options.minZoom!==void 0&&t<e.options.minZoom||e.options.maxZoom!==void 0&&t>e.options.maxZoom}}_expandIfNotCollapsed(){return this._map&&!this.options.collapsed&&this.expand(),this}_expandSafely(){let e=this._section;this._preventClick=!0,x(e,`click`,E),this.expand(),setTimeout(()=>{C(e,`click`,E),this._preventClick=!1})}},Je=class e extends I{static{this.setDefaultOptions({position:`bottomleft`,maxWidth:100,metric:!0,imperial:!0,updateWhenIdle:!1})}constructor(...t){super(...t),this.callInitHooks(e)}onAdd(e){let t=`maplair-control-scale`,n=O(`div`,t),r=this.options;return this._addScales(r,`${t}-line`,n),e.on(r.updateWhenIdle?`moveend`:`move`,this._update,this),e.whenReady(this._update,this),n}onRemove(e){e.off(this.options.updateWhenIdle?`moveend`:`move`,this._update,this)}_addScales(e,t,n){e.metric&&(this._mScale=O(`div`,t,n)),e.imperial&&(this._iScale=O(`div`,t,n))}_update(){let e=this._map,t=e.getSize().y/2,n=e.distance(e.containerPointToLatLng([0,t]),e.containerPointToLatLng([this.options.maxWidth,t]));this._updateScales(n)}_updateScales(e){this.options.metric&&e&&this._updateMetric(e),this.options.imperial&&e&&this._updateImperial(e)}_updateMetric(e){let t=this._getRoundNum(e),n=t<1e3?L.translate(`{meters} m`,{meters:t}):L.translate(`{kilometers} km`,{kilometers:t/1e3});this._updateScale(this._mScale,n,t/e)}_updateImperial(e){let t=e*3.2808399,n,r,i;t>5280?(n=t/5280,r=this._getRoundNum(n),this._updateScale(this._iScale,L.translate(`{miles} mi`,{miles:r}),r/n)):(i=this._getRoundNum(t),this._updateScale(this._iScale,L.translate(`{feet} ft`,{feet:i}),i/t))}_updateScale(e,t,n){e.style.width=`${Math.round(this.options.maxWidth*n)}px`,e.innerHTML=t}_getRoundNum(e){let t=10**(`${Math.floor(e)}`.length-1),n=e/t;return n=n>=10?10:n>=5?5:n>=3?3:n>=2?2:1,t*n}},Ye=class e extends I{static{this.setDefaultOptions({position:`topleft`,zoomInText:`<span aria-hidden="true">+</span>`,zoomOutText:`<span aria-hidden="true">&#x2212;</span>`})}constructor(...t){super(...t),this.callInitHooks(e)}onAdd(e){let t=`maplair-control-zoom`,n=O(`div`,`${t} maplair-bar`),r=this.options;return this._zoomInButton=this._createButton(r.zoomInText,L.translate(`Zoom in`),`${t}-in`,n,this._zoomIn),this._zoomOutButton=this._createButton(r.zoomOutText,L.translate(`Zoom out`),`${t}-out`,n,this._zoomOut),this._updateDisabled(),e.on(`zoomend zoomlevelschange`,this._updateDisabled,this),n}onRemove(e){e.off(`zoomend zoomlevelschange`,this._updateDisabled,this)}disable(){return this._disabled=!0,this._updateDisabled(),this}enable(){return this._disabled=!1,this._updateDisabled(),this}_zoomIn(e){!this._disabled&&this._map._zoom<this._map.getMaxZoom()&&this._map.zoomIn(this._map.options.zoomDelta*(e.shiftKey?3:1))}_zoomOut(e){!this._disabled&&this._map._zoom>this._map.getMinZoom()&&this._map.zoomOut(this._map.options.zoomDelta*(e.shiftKey?3:1))}_createButton(e,t,n,r,i){let a=O(`a`,n,r);return a.innerHTML=e,a.href=`#`,a.title=t,a.setAttribute(`role`,`button`),a.setAttribute(`aria-label`,t),T(a),x(a,`click`,D),x(a,`click`,i,this),x(a,`click`,this._refocusOnMap,this),a}_updateDisabled(){let e=this._map,t=`maplair-disabled`;this._zoomInButton.classList.remove(t),this._zoomOutButton.classList.remove(t),this._zoomInButton.setAttribute(`aria-disabled`,`false`),this._zoomOutButton.setAttribute(`aria-disabled`,`false`),(this._disabled||e._zoom===e.getMinZoom())&&(this._zoomOutButton.classList.add(t),this._zoomOutButton.setAttribute(`aria-disabled`,`true`)),(this._disabled||e._zoom===e.getMaxZoom())&&(this._zoomInButton.classList.add(t),this._zoomInButton.setAttribute(`aria-disabled`,`true`))}static register(t){t.mergeOptions({zoomControl:!0}),t.addInitHook(function(){this.options.zoomControl&&(this.zoomControl=new e,this.addControl(this.zoomControl))})}},R=class e extends h{on(e,t,n){if(typeof e==`object`)for(let[n,r]of Object.entries(e))this._on(n,r,t);else for(let r of d(e))this._on(r,t,n);return this}off(e,t,n){if(!arguments.length)delete this._events,delete this._listenerIndex;else if(typeof e==`object`)for(let[n,r]of Object.entries(e))this._off(n,r,t);else{let r=arguments.length===1;for(let i of d(e))r?this._off(i):this._off(i,t,n)}return this}static __REMOVED_EVENTS=[`mousedown`,`mouseup`,`mouseover`,`mouseout`,`mousemove`];_on(t,n,r,i){if(e.__REMOVED_EVENTS.includes(t)&&console.error(`The event ${t} has been removed. Use the PointerEvent variant instead.`),typeof n!=`function`){console.warn(`wrong listener type: ${typeof n}`);return}r===this&&(r=void 0);let a=this._getListenerIndex(t).get(n);if(a?.has(r))return;let o={fn:n,ctx:r};i&&(o.once=!0),this._events??={},this._events[t]??=/* @__PURE__ */ new Set,this._events[t].add(o),a?a.set(r,o):this._listenerIndex[t].set(n,/* @__PURE__ */ new Map([[r,o]]))}_getListenerIndex(e){return this._listenerIndex??={},this._listenerIndex[e]??=/* @__PURE__ */ new Map}_off(e,t,n){if(!this._events)return;let r=this._events[e];if(!r)return;if(arguments.length===1){if(this._firingCount)for(let e of r)e.fn=c;delete this._events[e],delete this._listenerIndex?.[e];return}if(typeof t!=`function`){console.warn(`wrong listener type: ${typeof t}`);return}n===this&&(n=void 0);let i=this._listenerIndex?.[e]?.get(t),a=i?.get(n);a&&(i.delete(n),i.size||this._listenerIndex[e].delete(t),this._firingCount&&(a.fn=c,this._events[e]=r=new Set(r)),r.delete(a))}fire(e,t,n){if(!this.listens(e,n))return this;let r={...t,type:e,target:this,sourceTarget:t?.sourceTarget||this};if(this._events){let t=this._events[e];if(t){this._firingCount=this._firingCount+1||1;for(let n of t){let t=n.fn;n.once&&this.off(e,t,n.ctx),t.call(n.ctx||this,r)}this._firingCount--}}return n&&this._propagateEvent(r),this}listens(e,t,n,r){typeof e!=`string`&&console.warn(`"string" type argument expected`);let i=t;if(typeof t!=`function`&&(r=!!t,i=void 0,n=void 0),this._events?.[e]?.size&&this._listens(e,i,n)!==!1)return!0;if(r){for(let i of Object.values(this._eventParents??{}))if(i.listens(e,t,n,r))return!0}return!1}_listens(e,t,n){if(!this._events)return!1;let r=this._events[e];return t?(n===this&&(n=void 0),!!this._listenerIndex?.[e]?.get(t)?.has(n)):!!r?.size}once(e,t,n){if(typeof e==`object`)for(let[n,r]of Object.entries(e))this._on(n,r,t,!0);else for(let r of d(e))this._on(r,t,n,!0);return this}addEventParent(e){return this._eventParents??={},this._eventParents[a(e)]=e,this}removeEventParent(e){return this._eventParents&&delete this._eventParents[a(e)],this}_propagateEvent(e){for(let t of Object.values(this._eventParents??{}))t.fire(e.type,{propagatedFrom:e.target,...e},!0)}},z=class e extends h{constructor(t){super(),this._map=t,this.callInitHooks(e)}enable(){return this._enabled?this:(this._enabled=!0,this.addHooks(),this)}disable(){return this._enabled?(this._enabled=!1,this.removeHooks(),this):this}enabled(){return!!this._enabled}};z.addTo=function(e,t){return e.addHandler(t,this),this};var Xe=class e extends R{constructor(...t){super(...t),this.callInitHooks(e)}run(e,t,n,r){this.stop(),this._el=e,this._inProgress=!0,this._duration=n??.25,this._easeOutPower=1/Math.max(r??.5,.2),this._startPos=N(e),this._offset=t.subtract(this._startPos),this._startTime=Date.now(),this.fire(`start`),this._animate()}stop(){this._inProgress&&(this._step(!0),this._complete())}_animate(){this._animId=requestAnimationFrame(this._animate.bind(this)),this._step()}_step(e){let t=Date.now()-this._startTime,n=this._duration*1e3;t<n?this._runFrame(this._easeOut(t/n),e):(this._runFrame(1),this._complete())}_runFrame(e,t){let n=this._startPos.add(this._offset.multiplyBy(e));t&&n._round(),M(this._el,n),this.fire(`step`)}_complete(){cancelAnimationFrame(this._animId),this._inProgress=!1,this.fire(`end`)}_easeOut(e){return 1-(1-e)**this._easeOutPower}},Ze=class e extends R{static{this.setDefaultOptions({clickTolerance:3})}constructor(t,n,r,i){super(),f(this,i),this._element=t,this._dragStartTarget=n??t,this._preventOutline=r,this.callInitHooks(e)}enable(){this._enabled||=(x(this._dragStartTarget,`pointerdown`,this._onDown,this),!0)}disable(){this._enabled&&(e._dragging===this&&this.finishDrag(!0),C(this._dragStartTarget,`pointerdown`,this._onDown,this),this._enabled=!1,this._moved=!1)}_onDown(t){if(this._moved=!1,this._element.classList.contains(`maplair-zoom-anim`))return;if(b().length!==1){e._dragging===this&&this.finishDrag();return}if(e._dragging||t.shiftKey||t.button!==0&&t.pointerType!==`touch`||(e._dragging=this,this._preventOutline&&Ue(this._element),ze(),Le(),this._moving))return;this.fire(`down`);let n=We(this._element);this._startPoint=new g(t.clientX,t.clientY),this._startPos=N(this._element),this._parentScale=Ge(n),x(this._dragStartTarget,`pointermove`,this._onMove,this),x(this._dragStartTarget,`pointerup pointercancel`,this._onUp,this)}_onMove(e){if(b().length>1){this._moved=!0;return}let t=new g(e.clientX,e.clientY)._subtract(this._startPoint);(t.x||t.y)&&(Math.abs(t.x)+Math.abs(t.y)<this.options.clickTolerance||(t.x/=this._parentScale.x,t.y/=this._parentScale.y,e.cancelable&&e.preventDefault(),this._moved||(this.fire(`dragstart`),this._moved=!0,this._element.ownerDocument.body.classList.add(`maplair-dragging`),this._lastTarget=e.target??e.srcElement,this._lastTarget.classList.add(`maplair-drag-target`)),this._newPos=this._startPos.add(t),this._moving=!0,this._lastEvent=e,this._updatePosition()))}_updatePosition(){let e={originalEvent:this._lastEvent};this.fire(`predrag`,e),M(this._element,this._newPos),this.fire(`drag`,e)}_onUp(){this.finishDrag()}finishDrag(t){this._element.ownerDocument.body.classList.remove(`maplair-dragging`),this._lastTarget&&=(this._lastTarget.classList.remove(`maplair-drag-target`),null),C(this._dragStartTarget,`pointermove`,this._onMove,this),C(this._dragStartTarget,`pointerup pointercancel`,this._onUp,this),Be(),Re();let n=this._moved&&this._moving;this._moving=!1,e._dragging=!1,n&&this.fire(`dragend`,{noInertia:t,distance:this._newPos.distanceTo(this._startPos)})}},B=class e{constructor(t,n){if(!t)return;if(t instanceof e){t.isValid()&&(this.min=new g(t.min),this.max=new g(t.max));return}let r=n?[t,n]:t;for(let e of r)this.extend(e)}extend(t){let n,r;if(!t)return this;if(t instanceof g||typeof t[0]==`number`||`x`in t)n=r=new g(t);else if(t=new e(t),n=t.min,r=t.max,!n||!r)return this;return!this.min&&!this.max?(this.min=new g(n),this.max=new g(r)):(this.min.x=Math.min(n.x,this.min.x),this.max.x=Math.max(r.x,this.max.x),this.min.y=Math.min(n.y,this.min.y),this.max.y=Math.max(r.y,this.max.y)),this}getCenter(e){return new g((this.min.x+this.max.x)/2,(this.min.y+this.max.y)/2,e)}getBottomLeft(){return new g(this.min.x,this.max.y)}getTopRight(){return new g(this.max.x,this.min.y)}getTopLeft(){return this.min}getBottomRight(){return this.max}getSize(){return this.max.subtract(this.min)}contains(t){let n,r;return t=typeof t[0]==`number`||t instanceof g?new g(t):new e(t),t instanceof e?(n=t.min,r=t.max):n=r=t,n.x>=this.min.x&&r.x<=this.max.x&&n.y>=this.min.y&&r.y<=this.max.y}intersects(t){t=new e(t);let n=this.min,r=this.max,i=t.min,a=t.max,o=a.x>=n.x&&i.x<=r.x,s=a.y>=n.y&&i.y<=r.y;return o&&s}overlaps(t){t=new e(t);let n=this.min,r=this.max,i=t.min,a=t.max,o=a.x>n.x&&i.x<r.x,s=a.y>n.y&&i.y<r.y;return o&&s}isValid(){return!!(this.min&&this.max)}pad(t){let n=this.min,r=this.max,i=Math.abs(n.x-r.x)*t,a=Math.abs(n.y-r.y)*t;return new e(new g(n.x-i,n.y-a),new g(r.x+i,r.y+a))}equals(t){return t?(t=new e(t),this.min.equals(t.getTopLeft())&&this.max.equals(t.getBottomRight())):!1}},V=class{constructor(e,t,n,r){if(Array.isArray(e)){this._a=e[0],this._b=e[1],this._c=e[2],this._d=e[3];return}this._a=e,this._b=t,this._c=n,this._d=r}transform(e,t){return this._transform(new g(e),t)}_transform(e,t){return t||=1,e.x=t*(this._a*e.x+this._b),e.y=t*(this._c*e.y+this._d),e}untransform(e,t){return t||=1,new g((e.x/t-this._b)/this._a,(e.y/t-this._d)/this._c)}},H=class e{constructor(t,n){if(!t)return;if(t instanceof e){t.isValid()&&(this._southWest=new W(t._southWest),this._northEast=new W(t._northEast));return}let r=n?[t,n]:t;for(let e of r)this.extend(e)}extend(t){let n=this._southWest,r=this._northEast,i,a;if(t instanceof W)i=t,a=t;else if(t instanceof e){if(i=t._southWest,a=t._northEast,!i||!a)return this}else return t?W.validate(t)?this.extend(new W(t)):this.extend(new e(t)):this;return!n&&!r?(this._southWest=new W(i.lat,i.lng),this._northEast=new W(a.lat,a.lng)):(n.lat=Math.min(i.lat,n.lat),n.lng=Math.min(i.lng,n.lng),r.lat=Math.max(a.lat,r.lat),r.lng=Math.max(a.lng,r.lng)),this}pad(t){let n=this._southWest,r=this._northEast,i=Math.abs(n.lat-r.lat)*t,a=Math.abs(n.lng-r.lng)*t;return new e(new W(n.lat-i,n.lng-a),new W(r.lat+i,r.lng+a))}getCenter(){return new W((this._southWest.lat+this._northEast.lat)/2,(this._southWest.lng+this._northEast.lng)/2)}getSouthWest(){return this._southWest}getNorthEast(){return this._northEast}getNorthWest(){return new W(this.getNorth(),this.getWest())}getSouthEast(){return new W(this.getSouth(),this.getEast())}getWest(){return this._southWest.lng}getSouth(){return this._southWest.lat}getEast(){return this._northEast.lng}getNorth(){return this._northEast.lat}contains(t){t=W.validate(t)?new W(t):new e(t);let n=this._southWest,r=this._northEast,i,a;return t instanceof e?(i=t.getSouthWest(),a=t.getNorthEast()):i=a=t,i.lat>=n.lat&&a.lat<=r.lat&&i.lng>=n.lng&&a.lng<=r.lng}intersects(t){t=new e(t);let n=this._southWest,r=this._northEast,i=t.getSouthWest(),a=t.getNorthEast(),o=a.lat>=n.lat&&i.lat<=r.lat,s=a.lng>=n.lng&&i.lng<=r.lng;return o&&s}overlaps(t){t=new e(t);let n=this._southWest,r=this._northEast,i=t.getSouthWest(),a=t.getNorthEast(),o=a.lat>n.lat&&i.lat<r.lat,s=a.lng>n.lng&&i.lng<r.lng;return o&&s}toBBoxString(){return[this.getWest(),this.getSouth(),this.getEast(),this.getNorth()].join(`,`)}equals(t,n){return t?(t=new e(t),this._southWest.equals(t.getSouthWest(),n)&&this._northEast.equals(t.getNorthEast(),n)):!1}isValid(){return!!(this._southWest&&this._northEast)}},Qe=class{static projection=void 0;static transformation=void 0;static latLngToPoint(e,t){let n=this.projection.project(e),r=this.scale(t);return this.transformation._transform(n,r)}static pointToLatLng(e,t){let n=this.scale(t),r=this.transformation.untransform(e,n);return this.projection.unproject(r)}static project(e){return this.projection.project(e)}static unproject(e){return this.projection.unproject(e)}static scale(e){return 256*2**e}static zoom(e){return Math.log(e/256)/Math.LN2}static getProjectedBounds(e){if(this.infinite)return null;let t=this.projection.bounds,n=this.scale(e);return new B(this.transformation.transform(t.min,n),this.transformation.transform(t.max,n))}static infinite=!1;static wrapLatLng(e){e=new W(e);let t=this.wrapLng?s(e.lng,this.wrapLng,!0):e.lng,n=this.wrapLat?s(e.lat,this.wrapLat,!0):e.lat,r=e.alt;return new W(n,t,r)}static wrapLatLngBounds(e){e=new H(e);let t=e.getCenter(),n=this.wrapLatLng(t),r=t.lat-n.lat,i=t.lng-n.lng;if(r===0&&i===0)return e;let a=e.getSouthWest(),o=e.getNorthEast();return new H(new W(a.lat-r,a.lng-i),new W(o.lat-r,o.lng-i))}},U=class extends Qe{static wrapLng=[-180,180];static R=6371e3;static distance(e,t){let n=Math.PI/180,r=e.lat*n,i=t.lat*n,a=Math.sin((t.lat-e.lat)*n/2),o=Math.sin((t.lng-e.lng)*n/2),s=a*a+Math.cos(r)*Math.cos(i)*o*o,c=2*Math.atan2(Math.sqrt(s),Math.sqrt(1-s));return this.R*c}},W=class e{constructor(t,n,r){if(!e.validate(t,n,r))throw Error(`Invalid LatLng object: (${t}, ${n})`);let i,a,o;t instanceof e?(i=t.lat,a=t.lng,o=t.alt):Array.isArray(t)&&typeof t[0]!=`object`?t.length===3?(i=t[0],a=t[1],o=t[2]):t.length===2&&(i=t[0],a=t[1]):typeof t==`object`&&`lat`in t?(i=t.lat,a=`lng`in t?t.lng:t.lon,o=t.alt):(i=t,a=n,o=r),this.lat=+i,this.lng=+a,o!==void 0&&(this.alt=+o)}static validate(t,n,r){return t instanceof e||typeof t==`object`&&t&&`lat`in t?!0:t&&Array.isArray(t)&&typeof t[0]!=`object`?t.length===3||t.length===2:!(!t&&t!==0||!n&&n!==0)}equals(t,n){return t?(t=new e(t),Math.max(Math.abs(this.lat-t.lat),Math.abs(this.lng-t.lng))<=(n??1e-9)):!1}toString(e){return`LatLng(${l(this.lat,e)}, ${l(this.lng,e)})`}distanceTo(t){return U.distance(this,new e(t))}wrap(){return U.wrapLatLng(this)}toBounds(e){let t=180*e/40075017,n=t/Math.cos(Math.PI/180*this.lat);return new H([this.lat-t,this.lng-n],[this.lat+t,this.lng+n])}},$e=/* @__PURE__ */ t({centroid:()=>nt,clipPolygon:()=>et,polygonCenter:()=>tt});function et(e,t,n){let r,i,a,o,s,c,l,u,d,f=[1,4,2,8];for(i=0,l=e.length;i<l;i++)e[i]._code=G(e[i],t);for(o=0;o<4;o++){for(u=f[o],r=[],i=0,l=e.length,a=l-1;i<l;a=i++)s=e[i],c=e[a],s._code&u?c._code&u||(d=ft(c,s,u,t,n),d._code=G(d,t),r.push(d)):(c._code&u&&(d=ft(c,s,u,t,n),d._code=G(d,t),r.push(d)),r.push(s));e=r}return e}function tt(e,t){let n,r,i,a,o,s,c,l,u;if(!e||e.length===0)throw Error(`latlngs not passed`);q(e)||(console.warn(`latlngs are not flat! Only the first ring will be used`),e=e[0]);let d=new W([0,0]),f=new H(e);f.getNorthWest().distanceTo(f.getSouthWest())*f.getNorthEast().distanceTo(f.getNorthWest())<1700&&(d=nt(e));let p=e.length,m=[];for(n=0;n<p;n++){let r=new W(e[n]);m.push(t.project(new W([r.lat-d.lat,r.lng-d.lng])))}for(s=c=l=0,n=0,r=p-1;n<p;r=n++)i=m[n],a=m[r],o=i.y*a.x-a.y*i.x,c+=(i.x+a.x)*o,l+=(i.y+a.y)*o,s+=o*3;u=s===0?m[0]:[c/s,l/s];let h=t.unproject(new g(u));return new W([h.lat+d.lat,h.lng+d.lng])}function nt(e){let t=0,n=0,r=0;for(let i of e){let e=new W(i);t+=e.lat,n+=e.lng,r++}return new W([t/r,n/r])}var rt=/* @__PURE__ */ t({_getBitCode:()=>G,_getEdgeIntersection:()=>ft,_sqClosestPointOnSegment:()=>K,clipSegment:()=>dt,closestPointOnSegment:()=>ot,isFlat:()=>q,pointToSegmentDistance:()=>at,polylineCenter:()=>mt,simplify:()=>it});function it(e,t){if(!t||!e.length)return e.slice();let n=t*t;return e=lt(e,n),e=st(e,n),e}function at(e,t,n){return Math.sqrt(K(e,t,n,!0))}function ot(e,t,n){return K(e,t,n)}function st(e,t){let n=e.length,r=new Uint8Array(n);r[0]=r[n-1]=1,ct(e,r,t,0,n-1);let i,a=[];for(i=0;i<n;i++)r[i]&&a.push(e[i]);return a}function ct(e,t,n,r,i){let a=0,o,s,c;for(s=r+1;s<=i-1;s++)c=K(e[s],e[r],e[i],!0),c>a&&(o=s,a=c);a>n&&(t[o]=1,ct(e,t,n,r,o),ct(e,t,n,o,i))}function lt(e,t){let n=[e[0]],r=0;for(let i=1;i<e.length;i++)pt(e[i],e[r])>t&&(n.push(e[i]),r=i);return r<e.length-1&&n.push(e[e.length-1]),n}let ut;function dt(e,t,n,r,i){let a=r?ut:G(e,n),o=G(t,n),s,c,l;for(ut=o;;){if(!(a|o))return[e,t];if(a&o)return!1;s=a||o,c=ft(e,t,s,n,i),l=G(c,n),s===a?(e=c,a=l):(t=c,o=l)}}function ft(e,t,n,r,i){let a=t.x-e.x,o=t.y-e.y,s=r.min,c=r.max,l,u;return n&8?(l=e.x+a*(c.y-e.y)/o,u=c.y):n&4?(l=e.x+a*(s.y-e.y)/o,u=s.y):n&2?(l=c.x,u=e.y+o*(c.x-e.x)/a):n&1&&(l=s.x,u=e.y+o*(s.x-e.x)/a),new g(l,u,i)}function G(e,t){let n=0;return e.x<t.min.x?n|=1:e.x>t.max.x&&(n|=2),e.y<t.min.y?n|=4:e.y>t.max.y&&(n|=8),n}function pt(e,t){let n=t.x-e.x,r=t.y-e.y;return n*n+r*r}function K(e,t,n,r){let i=t.x,a=t.y,o=n.x-i,s=n.y-a,c,l=o*o+s*s;return l>0&&(c=((e.x-i)*o+(e.y-a)*s)/l,c>1?(i=n.x,a=n.y):c>0&&(i+=o*c,a+=s*c)),o=e.x-i,s=e.y-a,r?o*o+s*s:new g(i,a)}function q(e){return!Array.isArray(e[0])||typeof e[0][0]!=`object`&&e[0][0]!==void 0}function mt(e,t){let n,r,i,a,o,s,c,l;if(!e||e.length===0)throw Error(`latlngs not passed`);q(e)||(console.warn(`latlngs are not flat! Only the first ring will be used`),e=e[0]);let u=new W([0,0]),d=new H(e);d.getNorthWest().distanceTo(d.getSouthWest())*d.getNorthEast().distanceTo(d.getNorthWest())<1700&&(u=nt(e));let f=e.length,p=[];for(n=0;n<f;n++){let r=new W(e[n]);p.push(t.project(new W([r.lat-u.lat,r.lng-u.lng])))}for(n=0,r=0;n<f-1;n++)r+=p[n].distanceTo(p[n+1])/2;if(r===0)l=p[0];else for(n=0,a=0;n<f-1;n++)if(o=p[n],s=p[n+1],i=o.distanceTo(s),a+=i,a>r){c=(a-r)/i,l=[s.x-c*(s.x-o.x),s.y-c*(s.y-o.y)];break}let m=t.unproject(new g(l));return new W([m.lat+u.lat,m.lng+u.lng])}const ht={project(e){return e=new W(e),new g(e.lng,e.lat)},unproject(e){return e=new g(e),new W(e.y,e.x)},bounds:new B([-180,-90],[180,90])},gt={R:6378137,R_MINOR:6356752.314245179,bounds:new B([-20037508.34279,-15496570.73972],[20037508.34279,18764656.23138]),project(e){e=new W(e);let t=Math.PI/180,n=this.R,r=this.R_MINOR/n,i=Math.sqrt(1-r*r),a=e.lat*t,o=i*Math.sin(a),s=Math.tan(Math.PI/4-a/2)/((1-o)/(1+o))**(i/2);return a=-n*Math.log(Math.max(s,1e-10)),new g(e.lng*t*n,a)},unproject(e){e=new g(e);let t=180/Math.PI,n=this.R,r=this.R_MINOR/n,i=Math.sqrt(1-r*r),a=Math.exp(-e.y/n),o=Math.PI/2-2*Math.atan(a);for(let e=0,t=.1,n;e<15&&Math.abs(t)>1e-7;e++)n=i*Math.sin(o),n=((1-n)/(1+n))**(i/2),t=Math.PI/2-2*Math.atan(a*n)-o,o+=t;return new W(o*t,e.x*t/n)}},_t=6378137,vt={R:_t,MAX_LATITUDE:85.0511287798,project(e){e=new W(e);let t=Math.PI/180,n=this.MAX_LATITUDE,r=Math.max(Math.min(n,e.lat),-n),i=Math.sin(r*t);return new g(this.R*e.lng*t,this.R*Math.log((1+i)/(1-i))/2)},unproject(e){e=new g(e);let t=180/Math.PI;return new W((2*Math.atan(Math.exp(e.y/this.R))-Math.PI/2)*t,e.x*t/this.R)},bounds:(()=>{let e=_t*Math.PI;return new B([-e,-e],[e,e])})()};var yt=/* @__PURE__ */ t({LonLat:()=>ht,Mercator:()=>gt,SphericalMercator:()=>vt}),bt=class extends U{static code=`EPSG:3395`;static projection=gt;static transformation=(()=>{let e=.5/(Math.PI*gt.R);return new V(e,.5,-e,.5)})()},xt=class extends U{static code=`EPSG:3857`;static projection=vt;static transformation=(()=>{let e=.5/(Math.PI*vt.R);return new V(e,.5,-e,.5)})()},St=class extends xt{static code=`EPSG:900913`},Ct=class extends U{static code=`EPSG:4326`;static projection=ht;static transformation=new V(1/180,1,-1/180,.5)},wt=class extends Qe{static projection=ht;static transformation=new V(1,0,-1,0);static scale(e){return 2**e}static zoom(e){return Math.log(e)/Math.LN2}static distance(e,t){let n=t.lng-e.lng,r=t.lat-e.lat;return Math.sqrt(n*n+r*r)}static infinite=!0},J=class extends R{static{this.setDefaultOptions({pane:`overlayPane`,attribution:null,bubblingPointerEvents:!0})}addTo(e){return e.addLayer(this),this}remove(){return this.removeFrom(this._map||this._mapToAdd)}removeFrom(e){return e?.removeLayer(this),this}getPane(e){return this._map.getPane(e?this.options[e]||e:this.options.pane)}addInteractiveTarget(e){return this._map._targets[a(e)]=this,this}removeInteractiveTarget(e){return delete this._map._targets[a(e)],this}getAttribution(){return this.options.attribution}_layerAdd(e){let t=e.target;if(t.hasLayer(this)){if(this._map=t,this._zoomAnimated=t._zoomAnimated,this.getEvents){let e=this.getEvents();t.on(e,this),this.once(`remove`,()=>t.off(e,this))}this.onAdd(t),this.fire(`add`),t.fire(`layeradd`,{layer:this})}}static register(e){e.include({addLayer(e){if(!e._layerAdd)throw Error(`The provided object is not a Layer.`);let t=a(e);return this._layers[t]?this:(this._layers[t]=e,e._mapToAdd=this,e.beforeAdd&&e.beforeAdd(this),this.whenReady(e._layerAdd,e),this)},removeLayer(e){let t=a(e);return this._layers[t]?(this._loaded&&e.onRemove(this),delete this._layers[t],this._loaded&&(this.fire(`layerremove`,{layer:e}),e.fire(`remove`)),e._map=e._mapToAdd=null,this):this},hasLayer(e){return a(e)in this._layers},eachLayer(e,t){for(let n of Object.values(this._layers))e.call(t,n);return this},_addLayers(e){e=e?Array.isArray(e)?e:[e]:[];for(let t of e)this.addLayer(t)},_addZoomLimit(e){(!isNaN(e.options.maxZoom)||!isNaN(e.options.minZoom))&&(this._zoomBoundLayers[a(e)]=e,this._updateZoomLevels())},_removeZoomLimit(e){let t=a(e);this._zoomBoundLayers[t]&&(delete this._zoomBoundLayers[t],this._updateZoomLevels())},_updateZoomLevels(){let e=1/0,t=-1/0,n=this._getZoomSpan();for(let n of Object.values(this._zoomBoundLayers)){let r=n.options;e=Math.min(e,r.minZoom??1/0),t=Math.max(t,r.maxZoom??-1/0)}this._layersMaxZoom=t===-1/0?void 0:t,this._layersMinZoom=e===1/0?void 0:e,n!==this._getZoomSpan()&&this.fire(`zoomlevelschange`),this.options.maxZoom===void 0&&this._layersMaxZoom&&this.getZoom()>this._layersMaxZoom&&this.setZoom(this._layersMaxZoom),this.options.minZoom===void 0&&this._layersMinZoom&&this.getZoom()<this._layersMinZoom&&this.setZoom(this._layersMinZoom)}})}},Tt=class e extends J{constructor(t,n){super(),f(this,n),this._layers={};for(let e of t??[])this.addLayer(e);this.callInitHooks(e)}addLayer(e){let t=this.getLayerId(e);return this._layers[t]=e,this._map?.addLayer(e),this}removeLayer(e){let t=e in this._layers?e:this.getLayerId(e);return this._map&&this._layers[t]&&this._map.removeLayer(this._layers[t]),delete this._layers[t],this}hasLayer(e){return(typeof e==`number`?e:this.getLayerId(e))in this._layers}clearLayers(){return this.eachLayer(this.removeLayer,this)}onAdd(e){this.eachLayer(e.addLayer,e)}onRemove(e){this.eachLayer(e.removeLayer,e)}eachLayer(e,t){for(let n of Object.values(this._layers))e.call(t,n);return this}getLayer(e){return this._layers[e]}getLayers(){let e=[];return this.eachLayer(e.push,e),e}setZIndex(e){return this.eachLayer(t=>t.setZIndex?.(e))}getLayerId(e){return a(e)}},Y=class e extends Tt{constructor(...t){super(...t),this.callInitHooks(e)}addLayer(e){return this.hasLayer(e)?this:(e.addEventParent(this),super.addLayer(e),this.fire(`layeradd`,{layer:e}))}removeLayer(e){return this.hasLayer(e)?(e in this._layers&&(e=this._layers[e]),e.removeEventParent(this),super.removeLayer(e),this.fire(`layerremove`,{layer:e})):this}setStyle(e){return this.eachLayer(t=>t.setStyle?.(e))}bringToFront(){return this.eachLayer(e=>e.bringToFront?.())}bringToBack(){return this.eachLayer(e=>e.bringToBack?.())}getBounds(){let e=new H;for(let t of Object.values(this._layers))e.extend(t.getBounds?t.getBounds():t.getLatLng());return e}},Et=class e extends h{static{this.setDefaultOptions({popupAnchor:[0,0],tooltipAnchor:[0,0],crossOrigin:!1})}constructor(t){super(),f(this,t),this.callInitHooks(e)}createIcon(e){return this._createIcon(`icon`,e)}createShadow(e){return this._createIcon(`shadow`,e)}_createIcon(e,t){let n=this._getIconUrl(e);if(!n){if(e===`icon`)throw Error(`iconUrl not set in Icon options (see the docs).`);return null}let r=this._createImg(n,t&&t.tagName===`IMG`?t:null);return this._setIconStyles(r,e),(this.options.crossOrigin||this.options.crossOrigin===``)&&(r.crossOrigin=this.options.crossOrigin===!0?``:this.options.crossOrigin),r}_setIconStyles(e,t){let n=this.options,r=n[`${t}Size`];typeof r==`number`&&(r=[r,r]);let i=g.validate(r)&&new g(r),a=t===`shadow`&&n.shadowAnchor||n.iconAnchor||i&&i.divideBy(2,!0),o=g.validate(a)&&new g(a);e.className=`maplair-marker-${t} ${n.className||``}`,o&&(e.style.marginLeft=`${-o.x}px`,e.style.marginTop=`${-o.y}px`),i&&(e.style.width=`${i.x}px`,e.style.height=`${i.y}px`)}_createImg(e,t){return t??=document.createElement(`img`),t.src=e,t}_getIconUrl(e){return _.retina&&this.options[`${e}RetinaUrl`]||this.options[`${e}Url`]}};const Dt=/^url\((['"])?(.+)\1\)$/,Ot=/^(.*)marker-icon\.svg$/;var kt=class e extends Et{static{this.setDefaultOptions({iconUrl:`marker-icon.svg`,iconRetinaUrl:`marker-icon.svg`,shadowUrl:`marker-shadow.svg`,iconSize:[25,41],iconAnchor:[12,41],popupAnchor:[1,-34],tooltipAnchor:[16,-28],shadowSize:[41,41]})}constructor(...t){super(...t),this.callInitHooks(e)}_getIconUrl(t){e.imagePath||=this._detectIconPath();let n=super._getIconUrl(t);return n?(this.options.imagePath??e.imagePath)+n:null}_stripUrl(e){let t=function(e,t,n){let r=t.exec(e);return r&&r[n]};return e=t(e,Dt,2),e&&t(e,Ot,1)}_detectIconPath(){let e=O(`div`,`maplair-default-icon-path`,document.body),t=this._stripUrl(getComputedStyle(e).backgroundImage);if(document.body.removeChild(e),t)return t;let n=document.querySelector(`link[href$="maplair.css"]`);return n?n.href.substring(0,n.href.length-11-1):``}},At=class e extends z{constructor(t){super(t._map),this._marker=t,this.callInitHooks(e)}addHooks(){let e=this._marker._icon;this._draggable||=new Ze(e,e,!0),this._draggable.on({dragstart:this._onDragStart,predrag:this._onPreDrag,drag:this._onDrag,dragend:this._onDragEnd},this).enable(),e.classList.add(`maplair-marker-draggable`)}removeHooks(){this._draggable.off({dragstart:this._onDragStart,predrag:this._onPreDrag,drag:this._onDrag,dragend:this._onDragEnd},this).disable(),this._marker._icon?.classList.remove(`maplair-marker-draggable`)}moved(){return this._draggable?._moved}_adjustPan(e){let t=this._marker,n=t._map,r=this._marker.options.autoPanSpeed,i=this._marker.options.autoPanPadding,a=N(t._icon),o=n.getPixelBounds(),s=n.getPixelOrigin(),c=new B(o.min._subtract(s).add(i),o.max._subtract(s).subtract(i));if(!c.contains(a)){let i=new g((Math.max(c.max.x,a.x)-c.max.x)/(o.max.x-c.max.x)-(Math.min(c.min.x,a.x)-c.min.x)/(o.min.x-c.min.x),(Math.max(c.max.y,a.y)-c.max.y)/(o.max.y-c.max.y)-(Math.min(c.min.y,a.y)-c.min.y)/(o.min.y-c.min.y)).multiplyBy(r);n.panBy(i,{animate:!1}),this._draggable._newPos._add(i),this._draggable._startPos._add(i),M(t._icon,this._draggable._newPos),this._onDrag(e),this._panRequest=requestAnimationFrame(this._adjustPan.bind(this,e))}}_onDragStart(){this._oldLatLng=this._marker.getLatLng(),this._marker.closePopup?.(),this._marker.fire(`movestart`).fire(`dragstart`)}_onPreDrag(e){this._marker.options.autoPan&&(cancelAnimationFrame(this._panRequest),this._panRequest=requestAnimationFrame(this._adjustPan.bind(this,e)))}_onDrag(e){let t=this._marker,n=t._shadow,r=N(t._icon),i=t._map.layerPointToLatLng(r);n&&M(n,r),t._latlng=i,e.latlng=i,e.oldLatLng=this._oldLatLng,t.fire(`move`,e).fire(`drag`,e)}_onDragEnd(e){cancelAnimationFrame(this._panRequest),delete this._oldLatLng,this._marker.fire(`moveend`).fire(`dragend`,e)}},jt=class e extends J{static{this.setDefaultOptions({icon:new kt,interactive:!0,keyboard:!0,title:``,alt:`Marker`,zIndexOffset:0,opacity:1,riseOnHover:!1,riseOffset:250,pane:`markerPane`,shadowPane:`shadowPane`,shadow:!0,bubblingPointerEvents:!1,autoPanOnFocus:!0,draggable:!1,autoPan:!1,autoPanPadding:[50,50],autoPanSpeed:10})}constructor(t,n){super(),f(this,n),this._latlng=new W(t),this.callInitHooks(e)}onAdd(e){this._zoomAnimated=this._zoomAnimated&&e.options.markerZoomAnimation,this._zoomAnimated&&e.on(`zoomanim`,this._animateZoom,this),this._initIcon(),this.update(),e.options.markerCulling&&this._updateCulling()}onRemove(e){this.dragging?.enabled()&&(this.options.draggable=!0,this.dragging.removeHooks()),delete this.dragging,this._zoomAnimated&&e.off(`zoomanim`,this._animateZoom,this),this._removeIcon(),this._removeShadow(),this._culled=!1}getEvents(){let e={zoom:this.update,viewreset:this.update};return this._map?.options.markerCulling&&(e.moveend=this._updateCulling),e}getLatLng(){return this._latlng}setLatLng(e){let t=this._latlng;return this._latlng=new W(e),this._map?.options.markerCulling&&this._updateCulling(),this.update(),this.fire(`move`,{oldLatLng:t,latlng:this._latlng})}setZIndexOffset(e){return this.options.zIndexOffset=e,this.update()}getIcon(){return this.options.icon}setIcon(e){return this.options.icon=e,this._map&&(this._initIcon(),this.update()),this._popup&&this.bindPopup(this._popup,this._popup.options),this}getElement(){return this._icon}update(){if(this._icon&&this._map&&!this._culled){let e=this._map.latLngToLayerPoint(this._latlng).round();this._setPos(e)}return this}_initIcon(){let e=this.options,t=`maplair-zoom-${this._zoomAnimated?`animated`:`hide`}`,n=e.icon.createIcon(this._icon),r=!1;n!==this._icon&&(this._icon&&this._removeIcon(),r=!0,e.title&&(n.title=e.title),n.tagName===`IMG`&&(n.alt=e.alt??``)),n.classList.add(t),e.keyboard&&(n.tabIndex=`0`,n.setAttribute(`role`,`button`)),this._icon=n,e.riseOnHover&&this.on({pointerover:this._bringToFront,pointerout:this._resetZIndex}),this.options.autoPanOnFocus&&x(n,`focus`,this._panOnFocus,this);let i=e.shadow?e.icon.createShadow(this._shadow):null,a=!1;i!==this._shadow&&(this._removeShadow(),a=!0),i&&(i.classList.add(t),i.alt=``),this._shadow=i,e.opacity<1&&this._updateOpacity(),r&&this.getPane().appendChild(this._icon),this._initInteraction(),i&&a&&this.getPane(e.shadowPane).appendChild(this._shadow)}_removeIcon(){this.options.riseOnHover&&this.off({pointerover:this._bringToFront,pointerout:this._resetZIndex}),this.options.autoPanOnFocus&&C(this._icon,`focus`,this._panOnFocus,this),this._icon.remove(),this.removeInteractiveTarget(this._icon),this._icon=null}_updateCulling(){if(!this._icon||!this._map)return;let e=this._map.getBounds().pad(.5).contains(this._latlng)||!!this.dragging?._draggable?._moving||this._icon.contains(document.activeElement);e!==!this._culled&&(this._culled=!e,e?(this.getPane().appendChild(this._icon),this._shadow&&this.getPane(this.options.shadowPane).appendChild(this._shadow),this.update()):(this._icon.remove(),this._shadow?.remove()))}_removeShadow(){this._shadow?.remove(),this._shadow=null}_setPos(e){this._icon&&M(this._icon,e),this._shadow&&M(this._shadow,e),this._zIndex=e.y+this.options.zIndexOffset,this._resetZIndex()}_updateZIndex(e){let t=String(this._zIndex+e);this._icon&&this._icon.style.zIndex!==t&&(this._icon.style.zIndex=t)}_animateZoom(e){if(this._culled)return;let t=this._map._latLngToNewLayerPoint(this._latlng,e.zoom,e.center).round();this._setPos(t)}_initInteraction(){if(this.options.interactive&&(this._icon.classList.add(`maplair-interactive`),this.addInteractiveTarget(this._icon),At)){let e=this.options.draggable;this.dragging&&(e=this.dragging.enabled(),this.dragging.disable()),this.dragging=new At(this),e&&this.dragging.enable()}}setOpacity(e){return this.options.opacity=e,this._map&&this._updateOpacity(),this}_updateOpacity(){let e=this.options.opacity;this._icon&&(this._icon.style.opacity=e),this._shadow&&(this._shadow.style.opacity=e)}_bringToFront(){this._updateZIndex(this.options.riseOffset)}_resetZIndex(){this._updateZIndex(0)}_panOnFocus(){let e=this._map;if(!e)return;let t=this.options.icon.options,n=t.iconSize?new g(t.iconSize):new g(0,0),r=t.iconAnchor?new g(t.iconAnchor):new g(0,0);e.panInside(this._latlng,{paddingTopLeft:r,paddingBottomRight:n.subtract(r)})}_getPopupAnchor(){return this.options.icon.options.popupAnchor}_getTooltipAnchor(){return this.options.icon.options.tooltipAnchor}},X=class extends J{static{this.setDefaultOptions({stroke:!0,color:`#3388ff`,weight:3,opacity:1,lineCap:`round`,lineJoin:`round`,dashArray:null,dashOffset:null,fill:!1,fillColor:null,fillOpacity:.2,fillRule:`evenodd`,interactive:!0,bubblingPointerEvents:!0})}beforeAdd(e){this._renderer=e.getRenderer(this)}onAdd(){this._renderer._initPath(this),this._reset(),this._renderer._addPath(this)}onRemove(){this._renderer._removePath(this)}redraw(){return this._map&&this._renderer._updatePath(this),this}setStyle(e){return f(this,e),this._renderer&&(this._renderer._updateStyle(this),this.options.stroke&&e&&Object.hasOwn(e,`weight`)&&this._updateBounds()),this}bringToFront(){return this._renderer?._bringToFront(this),this}bringToBack(){return this._renderer?._bringToBack(this),this}getElement(){return this._path}_reset(){this._project(),this._update()}_clickTolerance(){return(this.options.stroke?this.options.weight/2:0)+(this._renderer.options.tolerance||0)}},Mt=class e extends X{static{this.setDefaultOptions({fill:!0,radius:10})}constructor(t,n){super(),f(this,n),this._latlng=new W(t),this._radius=this.options.radius,this.callInitHooks(e)}setLatLng(e){let t=this._latlng;return this._latlng=new W(e),this.redraw(),this.fire(`move`,{oldLatLng:t,latlng:this._latlng})}getLatLng(){return this._latlng}setRadius(e){return this.options.radius=this._radius=e,this.redraw()}getRadius(){return this._radius}setStyle(e){return super.setStyle(e),e?.radius!==void 0&&this.setRadius(e.radius),this}_project(){this._point=this._map.latLngToLayerPoint(this._latlng),this._pxRadius=this._radius,this._updateBounds()}_updateBounds(){let e=this._pxRadius,t=this._pxRadiusY??e,n=this._clickTolerance(),r=[e+n,t+n];this._pxBounds=new B(this._point.subtract(r),this._point.add(r))}_update(){this._map&&this._updatePath()}_updatePath(){this._renderer._updateCircle(this)}_empty(){return this._pxRadius&&!this._renderer._bounds.intersects(this._pxBounds)}_containsPoint(e){return e.distanceTo(this._point)<=this._pxRadius+this._clickTolerance()}},Nt=class e extends Mt{constructor(t,n){if(super(t,n),isNaN(this.options.radius))throw Error(`Circle radius cannot be NaN`);this.callInitHooks(e)}getBounds(){let e=[this._pxRadius,this._pxRadiusY??this._pxRadius];return new H(this._map.layerPointToLatLng(this._point.subtract(e)),this._map.layerPointToLatLng(this._point.add(e)))}_project(){let e=this._latlng.lng,t=this._latlng.lat,n=this._map,r=n.options.crs;if(r.distance===U.distance){let r=Math.PI/180,i=this._radius/U.R/r,a=n.project([t+i,e]),o=n.project([t-i,e]),s=a.add(o).divideBy(2),c=n.unproject(s).lat,l=Math.acos((Math.cos(i*r)-Math.sin(t*r)*Math.sin(c*r))/(Math.cos(t*r)*Math.cos(c*r)))/r;(isNaN(l)||l===0)&&(l=i/Math.cos(Math.PI/180*t)),this._point=s.subtract(n.getPixelOrigin()),this._pxRadius=isNaN(l)?0:s.x-n.project([c,e-l]).x,this._pxRadiusY=s.y-a.y}else{let e=r.unproject(r.project(this._latlng).subtract([this._radius,0]));this._point=n.latLngToLayerPoint(this._latlng),this._pxRadius=Math.abs(this._point.x-n.latLngToLayerPoint(e).x)}this._updateBounds()}},Pt=class e extends X{static{this.setDefaultOptions({smoothFactor:.5,noClip:!1})}constructor(t,n){super(),f(this,n),this._setLatLngs(t),this.callInitHooks(e)}getLatLngs(){return this._latlngs}setLatLngs(e){return this._setLatLngs(e),this.redraw()}isEmpty(){return!this._latlngs.length}closestLayerPoint(e){e=new g(e);let t=1/0,n=null,r,i,a=K;for(let o of this._parts)for(let s=1,c=o.length;s<c;s++){r=o[s-1],i=o[s];let c=a(e,r,i,!0);c<t&&(t=c,n=a(e,r,i))}return n&&(n.distance=Math.sqrt(t)),n}getCenter(){if(!this._map)throw Error(`Must add layer to map before using getCenter()`);return mt(this._defaultShape(),this._map.options.crs)}getBounds(){return this._bounds}addLatLng(e,t){return t??=this._defaultShape(),e=new W(e),t.push(e),this._bounds.extend(e),this.redraw()}_setLatLngs(e){this._bounds=new H,this._latlngs=this._convertLatLngs(e)}_defaultShape(){return q(this._latlngs)?this._latlngs:this._latlngs[0]}_convertLatLngs(e){let t=[],n=q(e);for(let r=0,i=e.length;r<i;r++)n?(t[r]=new W(e[r]),this._bounds.extend(t[r])):t[r]=this._convertLatLngs(e[r]);return t}_project(){let e=new B;this._rings=[],this._projectLatlngs(this._latlngs,this._rings,e),this._bounds.isValid()&&e.isValid()&&(this._rawPxBounds=e,this._updateBounds())}_updateBounds(){let e=this._clickTolerance(),t=new g(e,e);this._rawPxBounds&&(this._pxBounds=new B([this._rawPxBounds.min.subtract(t),this._rawPxBounds.max.add(t)]))}_projectLatlngs(e,t,n){if(e[0]instanceof W){let r=e.map(e=>this._map.latLngToLayerPoint(e));r.forEach(e=>n.extend(e)),t.push(r)}else e.forEach(e=>this._projectLatlngs(e,t,n))}_clipPoints(){let e=this._renderer._bounds;if(this._parts=[],!this._pxBounds||!this._pxBounds.intersects(e))return;if(this.options.noClip){this._parts=this._rings;return}let t=this._parts,n,r,i,a,o,s,c;for(n=0,i=0,a=this._rings.length;n<a;n++)for(c=this._rings[n],r=0,o=c.length;r<o-1;r++)s=dt(c[r],c[r+1],e,r,!0),s&&(t[i]??=[],t[i].push(s[0]),(s[1]!==c[r+1]||r===o-2)&&(t[i].push(s[1]),i++))}_simplifyPoints(){let e=this._parts,t=this.options.smoothFactor;for(let n=0,r=e.length;n<r;n++)e[n]=it(e[n],t)}_update(){this._map&&(this._clipPoints(),this._simplifyPoints(),this._updatePath())}_updatePath(){this._renderer._updatePoly(this)}_containsPoint(e,t){let n,r,i,a,o,s,c=this._clickTolerance();if(!this._pxBounds||!this._pxBounds.contains(e))return!1;for(n=0,a=this._parts.length;n<a;n++)for(s=this._parts[n],r=0,o=s.length,i=o-1;r<o;i=r++)if((t||r!==0)&&at(e,s[i],s[r])<=c)return!0;return!1}},Z=class e extends Pt{static{this.setDefaultOptions({fill:!0})}constructor(...t){super(...t),this.callInitHooks(e)}isEmpty(){return!this._latlngs.length||!this._latlngs[0].length}getCenter(){if(!this._map)throw Error(`Must add layer to map before using getCenter()`);return tt(this._defaultShape(),this._map.options.crs)}_convertLatLngs(e){let t=super._convertLatLngs(e),n=t.length;return n>=2&&t[0]instanceof W&&t[0].equals(t[n-1])&&t.pop(),t}_setLatLngs(e){super._setLatLngs(e),q(this._latlngs)&&(this._latlngs=[this._latlngs])}_defaultShape(){return q(this._latlngs[0])?this._latlngs[0]:this._latlngs[0][0]}_clipPoints(){let e=this._renderer._bounds,t=this.options.weight,n=new g(t,t);if(e=new B(e.min.subtract(n),e.max.add(n)),this._parts=[],this._pxBounds&&this._pxBounds.intersects(e)){if(this.options.noClip){this._parts=this._rings;return}for(let t of this._rings){let n=et(t,e,!0);n.length&&this._parts.push(n)}}}_updatePath(){this._renderer._updatePoly(this,!0)}_containsPoint(e){let t=!1,n,r,i,a,o,s,c,l;if(!this._pxBounds||!this._pxBounds.contains(e))return!1;for(a=0,c=this._parts.length;a<c;a++)for(n=this._parts[a],o=0,l=n.length,s=l-1;o<l;s=o++)r=n[o],i=n[s],r.y>e.y!=i.y>e.y&&e.x<(i.x-r.x)*(e.y-r.y)/(i.y-r.y)+r.x&&(t=!t);return t||super._containsPoint(e,!0)}},Q=class e extends Y{constructor(t,n){super(void 0,n),t&&this.addData(t),this.callInitHooks(e)}addData(t){let n=Array.isArray(t)?t:t.features;if(n){for(let e of n)(e.geometries||e.geometry||e.features||e.coordinates)&&this.addData(e);return this}let r=this.options;if(r.filter&&!r.filter(t))return this;let i=e.geometryToLayer(t,r);return i?(i.feature=e.asFeature(t),i.defaultOptions=i.options,this.resetStyle(i),r.onEachFeature&&r.onEachFeature(t,i),this.addLayer(i)):this}resetStyle(e){return e===void 0?this.eachLayer(this.resetStyle,this):(e.options=Object.create(e.defaultOptions),this._setLayerStyle(e,this.options.style),this)}setStyle(e){return this.eachLayer(t=>this._setLayerStyle(t,e))}_setLayerStyle(e,t){e.setStyle&&(typeof t==`function`&&(t=t(e.feature)),e.setStyle(t))}static geometryToLayer(t,n){let r=t.type===`Feature`?t.geometry:t,i=r?.coordinates,a=[],o=n?.pointToLayer,s=n?.coordsToLatLng??e.coordsToLatLng,c,l;if(!i&&!r)return null;switch(r.type){case`Point`:return c=s(i),e._pointToLayer(o,t,c,n);case`MultiPoint`:for(let r of i)c=s(r),a.push(e._pointToLayer(o,t,c,n));return new Y(a);case`LineString`:case`MultiLineString`:return l=e.coordsToLatLngs(i,r.type===`LineString`?0:1,s),new Pt(l,n);case`Polygon`:case`MultiPolygon`:return l=e.coordsToLatLngs(i,r.type===`Polygon`?1:2,s),new Z(l,n);case`GeometryCollection`:for(let i of r.geometries){let r=e.geometryToLayer({geometry:i,type:`Feature`,properties:t.properties},n);r&&a.push(r)}return new Y(a);case`FeatureCollection`:for(let t of r.features){let r=e.geometryToLayer(t,n);r&&a.push(r)}return new Y(a);default:throw Error(`Invalid GeoJSON object.`)}}static _pointToLayer(e,t,n,r){return e?e(t,n):new jt(n,r?.markersInheritOptions&&r)}static coordsToLatLng(e){return new W(e[1],e[0],e[2])}static coordsToLatLngs(t,n,r){return t.map(t=>n?e.coordsToLatLngs(t,n-1,r):(r||e.coordsToLatLng)(t))}static latLngToCoords(e,t){return e=new W(e),e.alt===void 0?[l(e.lng,t),l(e.lat,t)]:[l(e.lng,t),l(e.lat,t),l(e.alt,t)]}static latLngsToCoords(t,n,r,i){let a=t.map(t=>n?e.latLngsToCoords(t,q(t)?0:n-1,r,i):e.latLngToCoords(t,i));return!n&&r&&a.length>0&&a.push(a[0].slice()),a}static getFeature(t,n){return t.feature?{...t.feature,geometry:n}:e.asFeature(n)}static asFeature(e){return e.type===`Feature`||e.type===`FeatureCollection`?e:{type:`Feature`,properties:{},geometry:e}}};const Ft={toGeoJSON(e){return Q.getFeature(this,{type:`Point`,coordinates:Q.latLngToCoords(this.getLatLng(),e)})}};jt.include(Ft),Nt.include(Ft),Mt.include(Ft),Pt.include({toGeoJSON(e){let t=!q(this._latlngs),n=Q.latLngsToCoords(this._latlngs,+!!t,!1,e);return Q.getFeature(this,{type:`${t?`Multi`:``}LineString`,coordinates:n})}}),Z.include({toGeoJSON(e){let t=!q(this._latlngs),n=t&&!q(this._latlngs[0]),r=Q.latLngsToCoords(this._latlngs,n?2:+!!t,!0,e);return t||(r=[r]),Q.getFeature(this,{type:`${n?`Multi`:``}Polygon`,coordinates:r})}}),Tt.include({toMultiPoint(e){let t=[];return this.eachLayer(n=>{t.push(n.toGeoJSON(e).geometry.coordinates)}),Q.getFeature(this,{type:`MultiPoint`,coordinates:t})},toGeoJSON(e){let t=this.feature?.geometry?.type;if(t===`MultiPoint`)return this.toMultiPoint(e);let n=t===`GeometryCollection`,r=[];return this.eachLayer(t=>{if(t.toGeoJSON){let i=t.toGeoJSON(e);if(n)r.push(i.geometry);else{let e=Q.asFeature(i);e.type===`FeatureCollection`?r.push(...e.features):r.push(e)}}}),n?Q.getFeature(this,{geometries:r,type:`GeometryCollection`}):{type:`FeatureCollection`,features:r}}});var It=class e extends J{static{this.setDefaultOptions({padding:.1,continuous:!1})}constructor(t){super(),f(this,t),this.callInitHooks(e)}onAdd(){this._container||(this._initContainer(),this._container.classList.add(`maplair-zoom-animated`)),this.getPane().appendChild(this._container),this._resizeContainer(),this._onMoveEnd()}onRemove(){this._destroyContainer()}getEvents(){let e={viewreset:this._reset,zoom:this._onZoom,moveend:this._onMoveEnd,resize:this._resizeContainer,zoomend:this._onZoomEnd};return this._zoomAnimated&&(e.zoomanim=this._onAnimZoom),this.options.continuous&&(e.move=this._onMoveEnd),e}_onAnimZoom(e){this._updateTransform(e.center,e.zoom)}_onZoom(){this._updateTransform(this._map.getCenter(),this._map.getZoom())}_updateTransform(e,t){let n=this._map.getZoomScale(t,this._zoom),r=this._map.getSize().multiplyBy(.5+this.options.padding),i=this._map.project(this._center,t),a=r.multiplyBy(-n)._add(i)._subtract(this._map._getNewPixelOrigin(e,t))._round();j(this._container,a,n)}_onMoveEnd(e){let t=this.options.padding,n=this._map.getSize(),r=this._map.containerPointToLayerPoint(n.multiplyBy(-t)).round();this._bounds=new B(r,r.add(n.multiplyBy(1+t*2)).round()),this._center=this._map.getCenter(),this._zoom=this._map.getZoom(),this._updateTransform(this._center,this._zoom),this._onSettled(e)}_reset(){this._onSettled(),this._updateTransform(this._center,this._zoom),this._onViewReset()}_initContainer(){this._container=O(`div`)}_destroyContainer(){C(this._container),this._container.remove(),delete this._container}_resizeContainer(){let e=this.options.padding,t=this._map.getSize().multiplyBy(1+e*2).round();return this._container.style.width=`${t.x}px`,this._container.style.height=`${t.y}px`,t}_onZoomEnd(){}_onViewReset(){}_onSettled(){}},Lt=class e extends J{static{this.setDefaultOptions({opacity:1,alt:``,interactive:!1,crossOrigin:!1,errorOverlayUrl:``,zIndex:1,className:``,decoding:`auto`})}constructor(t,n,r){super(),this._url=t,this._bounds=new H(n),f(this,r),this.callInitHooks(e)}onAdd(){this._image||(this._initImage(),this.options.opacity<1&&this._updateOpacity()),this.options.interactive&&(this._image.classList.add(`maplair-interactive`),this.addInteractiveTarget(this._image)),this.getPane().appendChild(this._image),this._reset()}onRemove(){this._image.remove(),this.options.interactive&&this.removeInteractiveTarget(this._image)}setOpacity(e){return this.options.opacity=e,this._image&&this._updateOpacity(),this}setStyle(e){return e.opacity&&this.setOpacity(e.opacity),this}bringToFront(){return this._map&&k(this._image),this}bringToBack(){return this._map&&A(this._image),this}setUrl(e){return this._url=e,this._image&&(this._image.src=e),this}setBounds(e){return this._bounds=new H(e),this._map&&this._reset(),this}getEvents(){let e={zoom:this._reset,viewreset:this._reset};return this._zoomAnimated&&(e.zoomanim=this._animateZoom),e}setZIndex(e){return this.options.zIndex=e,this._updateZIndex(),this}getBounds(){return this._bounds}getElement(){return this._image}_initImage(){let e=this._url.tagName===`IMG`,t=this._image=e?this._url:O(`img`);if(t.classList.add(`maplair-image-layer`),this._zoomAnimated&&t.classList.add(`maplair-zoom-animated`),this.options.className&&t.classList.add(...d(this.options.className)),t.onselectstart=c,t.onpointermove=c,t.onload=this.fire.bind(this,`load`),t.onerror=this._overlayOnError.bind(this),(this.options.crossOrigin||this.options.crossOrigin===``)&&(t.crossOrigin=this.options.crossOrigin===!0?``:this.options.crossOrigin),t.decoding=this.options.decoding,this.options.zIndex&&this._updateZIndex(),e){this._url=t.src;return}t.src=this._url,t.alt=this.options.alt}_animateZoom(e){let t=this._map.getZoomScale(e.zoom),n=this._map._latLngBoundsToNewLayerBounds(this._bounds,e.zoom,e.center).min;j(this._image,n,t)}_reset(){let e=this._image,t=new B(this._map.latLngToLayerPoint(this._bounds.getNorthWest()),this._map.latLngToLayerPoint(this._bounds.getSouthEast())),n=t.getSize();M(e,t.min),e.style.width=`${n.x}px`,e.style.height=`${n.y}px`}_updateOpacity(){this._image.style.opacity=this.options.opacity}_updateZIndex(){this._image&&this.options.zIndex!==void 0&&this.options.zIndex!==null&&(this._image.style.zIndex=this.options.zIndex)}_overlayOnError(){this.fire(`error`);let e=this.options.errorOverlayUrl;e&&this._url!==e&&(this._url=e,this._image.src=e)}getCenter(){return this._bounds.getCenter()}},Rt=class e extends Lt{static{this.setDefaultOptions({autoplay:!0,controls:!1,loop:!0,keepAspectRatio:!0,muted:!1,playsInline:!0})}constructor(...t){super(...t),this.callInitHooks(e)}_initImage(){let e=this._url.tagName===`VIDEO`,t=this._image=e?this._url:O(`video`);if(t.classList.add(`maplair-image-layer`),this._zoomAnimated&&t.classList.add(`maplair-zoom-animated`),this.options.className&&t.classList.add(...d(this.options.className)),x(t,`pointerdown`,e=>{t.controls&&w(e)}),t.onloadeddata=this.fire.bind(this,`load`),e){let e=t.getElementsByTagName(`source`),n=e.map(e=>e.src);this._url=e.length>0?n:[t.src];return}Array.isArray(this._url)||(this._url=[this._url]),!this.options.keepAspectRatio&&Object.hasOwn(t.style,`objectFit`)&&(t.style.objectFit=`fill`),t.autoplay=!!this.options.autoplay,t.controls=!!this.options.controls,t.loop=!!this.options.loop,t.muted=!!this.options.muted,t.playsInline=!!this.options.playsInline;for(let e of this._url){let n=O(`source`);n.src=e,t.appendChild(n)}}},zt=class e extends Lt{constructor(...t){super(...t),this.callInitHooks(e)}_initImage(){let e=this._image=this._url;e.classList.add(`maplair-image-layer`),this._zoomAnimated&&e.classList.add(`maplair-zoom-animated`),this.options.className&&e.classList.add(...d(this.options.className)),e.onselectstart=c,e.onpointermove=c}},$=class e extends J{static{this.setDefaultOptions({interactive:!1,offset:[0,0],className:``,pane:void 0,content:``})}constructor(t,n){super(),t instanceof W||Array.isArray(t)?(this._latlng=new W(t),f(this,n)):(f(this,t),this._source=n),this.options.content&&(this._content=this.options.content),this.callInitHooks(e)}openOn(e){return e=arguments.length?e:this._source._map,e.hasLayer(this)||e.addLayer(this),this}close(){return this._map?.removeLayer(this),this}toggle(e){return this._map?this.close():(arguments.length?this._source=e:e=this._source,this._prepareOpen(),this.openOn(e._map)),this}onAdd(e){this._zoomAnimated=e._zoomAnimated,this._container||this._initLayout(),e._fadeAnimated&&(this._container.style.opacity=0),clearTimeout(this._removeTimeout),this.getPane().appendChild(this._container),this.update(),e._fadeAnimated&&(this._container.style.opacity=1),this.bringToFront(),this.options.interactive&&(this._container.classList.add(`maplair-interactive`),this.addInteractiveTarget(this._container))}onRemove(e){e._fadeAnimated?(this._container.style.opacity=0,this._removeTimeout=setTimeout(()=>this._container.remove(),200)):this._container.remove(),this.options.interactive&&(this._container.classList.remove(`maplair-interactive`),this.removeInteractiveTarget(this._container))}getLatLng(){return this._latlng}setLatLng(e){return this._latlng=new W(e),this._map&&(this._updatePosition(),this._adjustPan()),this}getContent(){return this._content}setContent(e){return this._content=e,this.update(),this}getElement(){return this._container}update(){this._map&&(this._container.style.visibility=`hidden`,this._updateContent(),this._updateLayout(),this._updatePosition(),this._container.style.visibility=``,this._adjustPan())}getEvents(){let e={zoom:this._updatePosition,viewreset:this._updatePosition};return this._zoomAnimated&&(e.zoomanim=this._animateZoom),e}isOpen(){return!!this._map&&this._map.hasLayer(this)}bringToFront(){return this._map&&k(this._container),this}bringToBack(){return this._map&&A(this._container),this}_prepareOpen(e){let t=this._source;if(!t._map)return!1;if(t instanceof Y){t=null;for(let e of Object.values(this._source._layers))if(e._map){t=e;break}if(!t)return!1;this._source=t}if(!e){if(t.getCenter)e=t.getCenter();else if(t.getLatLng)e=t.getLatLng();else if(t.getBounds)e=t.getBounds().getCenter();else throw Error(`Unable to get source layer LatLng.`)}return this.setLatLng(e),this._map&&this.update(),!0}_updateContent(){if(!this._content)return;let e=this._contentNode,t=typeof this._content==`function`?this._content(this._source??this):this._content;if(typeof t==`string`)e.innerHTML=t;else{for(;e.hasChildNodes();)e.removeChild(e.firstChild);e.appendChild(t)}this.fire(`contentupdate`)}_updatePosition(){if(!this._map)return;let e=this._map.latLngToLayerPoint(this._latlng),t=this._getAnchor(),n=new g(this.options.offset);this._zoomAnimated?M(this._container,e.add(t)):n=n.add(e).add(t);let r=this._containerBottom=-n.y,i=this._containerLeft=-Math.round(this._containerWidth/2)+n.x;this._container.style.bottom=`${r}px`,this._container.style.left=`${i}px`}_getAnchor(){return[0,0]}static register(e){e.include({_initOverlay(e,t,n,r){let i=t;return i instanceof e||(i=new e(r).setContent(t)),n&&i.setLatLng(n),i}}),J.include({_initOverlay(e,t,n,r){let i=n;return i instanceof e?(f(i,r),i._source=this):(i=t&&!r?t:new e(r,this),i.setContent(n)),i}})}},Bt=class e extends ${static{this.setDefaultOptions({pane:`popupPane`,offset:[0,7],maxWidth:300,minWidth:50,maxHeight:null,autoPan:!_.reducedMotion,autoPanPaddingTopLeft:null,autoPanPaddingBottomRight:null,autoPanPadding:[5,5],keepInView:!1,closeButton:!0,autoClose:!0,closeOnEscapeKey:!0,className:``,trackResize:!0})}constructor(...t){super(...t),this.callInitHooks(e)}openOn(e){return e=arguments.length?e:this._source._map,!e.hasLayer(this)&&e._popup&&e._popup.options.autoClose&&e.removeLayer(e._popup),e._popup=this,super.openOn(e)}onAdd(e){super.onAdd(e),e.fire(`popupopen`,{popup:this}),this._source&&(this._source.fire(`popupopen`,{popup:this},!0),this._source instanceof X||this._source.on(`preclick`,w))}onRemove(e){super.onRemove(e),e.fire(`popupclose`,{popup:this}),this._source&&(this._source.fire(`popupclose`,{popup:this},!0),this._source instanceof X||this._source.off(`preclick`,w))}getEvents(){let e=super.getEvents();return(this.options.closeOnClick??this._map.options.closePopupOnClick)&&(e.preclick=this.close),this.options.keepInView&&(e.moveend=this._adjustPan),e}_initLayout(){let e=`maplair-popup`,t=this._container=O(`div`,`${e} ${this.options.className||``} maplair-zoom-animated`),n=this._wrapper=O(`div`,`${e}-content-wrapper`,t);if(this._contentNode=O(`div`,`${e}-content`,n),T(t),Ee(this._contentNode),x(t,`contextmenu`,w),this._tipContainer=O(`div`,`${e}-tip-container`,t),this._tip=O(`div`,`${e}-tip`,this._tipContainer),this.options.closeButton){let n=this._closeButton=O(`a`,`${e}-close-button`,t);n.setAttribute(`role`,`button`),n.setAttribute(`aria-label`,L.translate(`Close popup`)),n.href=`#close`,n.innerHTML=`<span aria-hidden="true">&#215;</span>`,x(n,`click`,e=>{e.preventDefault(),this.close()})}this.options.trackResize&&(this._resizeObserver=new ResizeObserver((e=>{this._map&&(this._containerWidth=e[0]?.contentRect?.width,this._containerHeight=e[0]?.contentRect?.height,this._updateLayout(),this._updatePosition(),this._adjustPan())})),this._resizeObserver.observe(this._contentNode))}_updateLayout(){let e=this._contentNode,t=e.style;t.maxWidth=`${this.options.maxWidth}px`,t.minWidth=`${this.options.minWidth}px`;let n=this.options.maxHeight,r=`maplair-popup-scrolled`;n&&(this._containerHeight??e.offsetHeight)>n?(t.height=`${n}px`,e.classList.add(r)):e.classList.remove(r),this._containerWidth=this._container.offsetWidth,this._containerHeight=this._container.offsetHeight,this._containerMarginBottom=parseInt(getComputedStyle(this._container).marginBottom,10)||0}_animateZoom(e){let t=this._map._latLngToNewLayerPoint(this._latlng,e.zoom,e.center),n=this._getAnchor();M(this._container,t.add(n))}_adjustPan(){if(!this.options.autoPan)return;if(this._map._panAnim?.stop(),this._autopanning){this._autopanning=!1;return}let e=this._map,t=this._containerMarginBottom??(parseInt(getComputedStyle(this._container).marginBottom,10)||0),n=this._containerHeight+t,r=this._containerWidth,i=new g(this._containerLeft,-n-this._containerBottom);i._add(N(this._container));let a=e.layerPointToContainerPoint(i),o=new g(this.options.autoPanPadding),s=new g(this.options.autoPanPaddingTopLeft??o),c=new g(this.options.autoPanPaddingBottomRight??o),l=e.getSize(),u=0,d=0;a.x+r+c.x>l.x&&(u=a.x+r-l.x+c.x),a.x-u-s.x<0&&(u=a.x-s.x),a.y+n+c.y>l.y&&(d=a.y+n-l.y+c.y),a.y-d-s.y<0&&(d=a.y-s.y),(u||d)&&(this.options.keepInView&&(this._autopanning=!0),e.fire(`autopanstart`).panBy([u,d]))}_getAnchor(){return new g(this._source?._getPopupAnchor?this._source._getPopupAnchor():[0,0])}static register(t){t.mergeOptions({closePopupOnClick:!0}),t.include({openPopup(t,n,r){return this._initOverlay(e,t,n,r).openOn(this),this},closePopup(e){return e=arguments.length?e:this._popup,e?.close(),this}}),J.include({bindPopup(t,n){return this._popup=this._initOverlay(e,this._popup,t,n),this._popupHandlersAdded||=(this.on({click:this._openPopup,keypress:this._onKeyPress,remove:this.closePopup,move:this._movePopup}),!0),this},unbindPopup(){return this._popup&&=(this.off({click:this._openPopup,keypress:this._onKeyPress,remove:this.closePopup,move:this._movePopup}),this._popupHandlersAdded=!1,null),this},openPopup(e){return this._popup&&(this instanceof Y||(this._popup._source=this),this._popup._prepareOpen(e||this._latlng)&&this._popup.openOn(this._map)),this},closePopup(){return this._popup?.close(),this},togglePopup(){return this._popup?.toggle(this),this},isPopupOpen(){return this._popup?.isOpen()??!1},setPopupContent(e){return this._popup?.setContent(e),this},getPopup(){return this._popup},_openPopup(e){if(!this._popup||!this._map)return;D(e);let t=e.propagatedFrom??e.target;if(this._popup._source===t&&!(t instanceof X)){this._map.hasLayer(this._popup)?this.closePopup():this.openPopup(e.latlng);return}this._popup._source=t,this.openPopup(e.latlng)},_movePopup(e){this._popup.setLatLng(e.latlng)},_onKeyPress(e){e.originalEvent.code===`Enter`&&this._openPopup(e)}})}},Vt=class e extends ${static{this.setDefaultOptions({pane:`tooltipPane`,offset:[0,0],direction:`auto`,permanent:!1,sticky:!1,opacity:.9})}constructor(...t){super(...t),this.callInitHooks(e)}onAdd(e){super.onAdd(e),this.setOpacity(this.options.opacity),e.fire(`tooltipopen`,{tooltip:this}),this._source&&(this.addEventParent(this._source),this._source.fire(`tooltipopen`,{tooltip:this},!0))}onRemove(e){super.onRemove(e),e.fire(`tooltipclose`,{tooltip:this}),this._source&&(this.removeEventParent(this._source),this._source.fire(`tooltipclose`,{tooltip:this},!0))}getEvents(){let e=super.getEvents();return this.options.permanent||(e.preclick=this.close),e}_initLayout(){let e=`maplair-tooltip ${this.options.className||``} maplair-zoom-${this._zoomAnimated?`animated`:`hide`}`;this._contentNode=this._container=O(`div`,e),this._container.setAttribute(`role`,`tooltip`),this._container.setAttribute(`id`,`maplair-tooltip-${a(this)}`)}_updateLayout(){}_adjustPan(){}_setPosition(e){let t,n,r=this.options.direction,i=this._map,a=this._container,o=i.latLngToContainerPoint(i.getCenter()),s=i.layerPointToContainerPoint(e),c=a.offsetWidth,l=a.offsetHeight,u=new g(this.options.offset),d=this._getAnchor();r===`top`?(t=c/2,n=l):r===`bottom`?(t=c/2,n=0):r===`center`?(t=c/2,n=l/2):r===`right`?(t=0,n=l/2):r===`left`?(t=c,n=l/2):s.x<o.x?(r=`right`,t=0,n=l/2):(r=`left`,t=c+(u.x+d.x)*2,n=l/2),e=e.subtract(new g(t,n,!0)).add(u).add(d),a.classList.remove(`maplair-tooltip-right`,`maplair-tooltip-left`,`maplair-tooltip-top`,`maplair-tooltip-bottom`),a.classList.add(`maplair-tooltip-${r}`),M(a,e)}_updatePosition(){let e=this._map.latLngToLayerPoint(this._latlng);this._setPosition(e)}setOpacity(e){this.options.opacity=e,this._container&&(this._container.style.opacity=e)}_animateZoom(e){let t=this._map._latLngToNewLayerPoint(this._latlng,e.zoom,e.center);this._setPosition(t)}_getAnchor(){return new g(this._source?._getTooltipAnchor&&!this.options.sticky?this._source._getTooltipAnchor():[0,0])}static register(t){t.include({openTooltip(t,n,r){return this._initOverlay(e,t,n,r).openOn(this),this},closeTooltip(e){return e.close(),this}}),J.include({bindTooltip(t,n){return this._tooltip&&this.isTooltipOpen()&&this.unbindTooltip(),this._tooltip=this._initOverlay(e,this._tooltip,t,n),this._initTooltipInteractions(),this._tooltip.options.permanent&&this._map&&this._map.hasLayer(this)&&this.openTooltip(),this},unbindTooltip(){return this._tooltip&&=(this._initTooltipInteractions(!0),this.closeTooltip(),null),this},_initTooltipInteractions(e){if(!e&&this._tooltipHandlersAdded)return;let t=e?`off`:`on`,n={remove:this.closeTooltip,move:this._moveTooltip};this._tooltip.options.permanent?n.add=this._openTooltip:(n.pointerover=this._openTooltip,n.pointerout=this.closeTooltip,n.click=this._openTooltip,this._map?this._addFocusListeners(e):n.add=()=>this._addFocusListeners(e)),this._tooltip.options.sticky&&(n.pointermove=this._moveTooltip),this[t](n),this._tooltipHandlersAdded=!e},openTooltip(e){return this._tooltip&&(this instanceof Y||(this._tooltip._source=this),this._tooltip._prepareOpen(e)&&(this._tooltip.openOn(this._map),this.getElement?this._setAriaDescribedByOnLayer(this):this.eachLayer&&this.eachLayer(this._setAriaDescribedByOnLayer,this))),this},closeTooltip(){if(this._tooltip)return this._tooltip.close()},toggleTooltip(){return this._tooltip?.toggle(this),this},isTooltipOpen(){return this._tooltip.isOpen()},setTooltipContent(e){return this._tooltip?.setContent(e),this},getTooltip(){return this._tooltip},_addFocusListeners(e){this.getElement?this._addFocusListenersOnLayer(this,e):this.eachLayer&&this.eachLayer(t=>this._addFocusListenersOnLayer(t,e),this)},_addFocusListenersOnLayer(e,t){let n=typeof e.getElement==`function`&&e.getElement();if(n){let r=t?C:x;t||(n._maplair_focus_handler&&C(n,`focus`,n._maplair_focus_handler,this),n._maplair_focus_handler=()=>{this._tooltip&&(this._tooltip._source=e,this.openTooltip())}),n._maplair_focus_handler&&r(n,`focus`,n._maplair_focus_handler,this),r(n,`blur`,this.closeTooltip,this),t&&delete n._maplair_focus_handler}},_setAriaDescribedByOnLayer(e){(typeof e.getElement==`function`&&e.getElement())?.setAttribute?.(`aria-describedby`,this._tooltip._container.id)},_openTooltip(e){if(this._tooltip&&this._map){if(this._map.dragging?.moving()){e.type===`add`&&!this._moveEndOpensTooltip&&(this._moveEndOpensTooltip=!0,this._map.once(`moveend`,()=>{this._moveEndOpensTooltip=!1,this._openTooltip(e)}));return}this._tooltip._source=e.propagatedFrom??e.target,this.openTooltip(this._tooltip.options.sticky?e.latlng:void 0)}},_moveTooltip(e){let t=e.latlng,n,r;this._tooltip.options.sticky&&e.originalEvent&&(n=this._map.pointerEventToContainerPoint(e.originalEvent),r=this._map.containerPointToLayerPoint(n),t=this._map.layerPointToLatLng(r)),this._tooltip.setLatLng(t)}})}},Ht=class e extends Et{static{this.setDefaultOptions({iconSize:[12,12],html:!1,bgPos:null,className:`maplair-div-icon`})}constructor(...t){super(...t),this.callInitHooks(e)}createIcon(e){let t=e&&e.tagName===`DIV`?e:document.createElement(`div`),n=this.options;if(n.html instanceof Element?(t.replaceChildren(),t.appendChild(n.html)):t.innerHTML=n.html===!1?``:n.html,n.bgPos){let e=new g(n.bgPos);t.style.backgroundPosition=`${-e.x}px ${-e.y}px`}return this._setIconStyles(t,`icon`),t}createShadow(){return null}},Ut=class e extends J{static{this.setDefaultOptions({tileSize:256,opacity:1,updateWhenIdle:!_.reducedMotion,updateWhenZooming:!0,updateInterval:_.reducedMotion?5e3:200,zIndex:1,bounds:null,minZoom:0,maxZoom:void 0,maxNativeZoom:void 0,minNativeZoom:void 0,noWrap:!1,pane:`tilePane`,className:``,keepBuffer:2})}constructor(t){super(),f(this,t),this.callInitHooks(e)}onAdd(){this._initContainer(),this._levels={},this._tiles={},this._resetView()}beforeAdd(e){e._addZoomLimit(this)}onRemove(e){this._removeAllTiles(),this._container.remove(),e._removeZoomLimit(this),this._container=null,this._tileZoom=void 0,clearTimeout(this._pruneTimeout)}bringToFront(){return this._map&&(k(this._container),this._setAutoZIndex(Math.max)),this}bringToBack(){return this._map&&(A(this._container),this._setAutoZIndex(Math.min)),this}getContainer(){return this._container}setOpacity(e){return this.options.opacity=e,this._updateOpacity(),this}setZIndex(e){return this.options.zIndex=e,this._updateZIndex(),this}isLoading(){return this._loading}redraw(){if(this._map){this._removeAllTiles();let e=this._clampZoom(this._map.getZoom());e!==this._tileZoom&&(this._tileZoom=e,this._updateLevels()),this._update()}return this}getEvents(){let e={viewprereset:this._invalidateAll,viewreset:this._resetView,zoom:this._resetView,moveend:this._onMoveEnd};return this.options.updateWhenIdle||(this._onMove||=o(this._onMoveEnd,this.options.updateInterval,this),e.move=this._onMove),this._zoomAnimated&&(e.zoomanim=this._animateZoom),e}createTile(){return document.createElement(`div`)}getTileSize(){let e=this.options.tileSize;return e instanceof g?e:new g(e,e)}_updateZIndex(){this._container&&this.options.zIndex!==void 0&&this.options.zIndex!==null&&(this._container.style.zIndex=this.options.zIndex)}_setAutoZIndex(e){let t=this.getPane().children,n=-e(-1/0,1/0);for(let r of t){let t=r.style.zIndex;r!==this._container&&t&&(n=e(n,+t))}isFinite(n)&&(this.options.zIndex=n+e(-1,1),this._updateZIndex())}_updateOpacity(){if(!this._map)return;this._container.style.opacity=this.options.opacity;let e=Date.now(),t=!1,n=!1;for(let r of Object.values(this._tiles??{})){if(!r.current||!r.loaded)continue;let i=Math.min(1,(e-r.loaded)/200);r.el.style.opacity=i,i<1?t=!0:(r.active?n=!0:this._onOpaqueTile(r),r.active=!0)}n&&!this._noPrune&&this._pruneTiles(),t&&(cancelAnimationFrame(this._fadeFrame),this._fadeFrame=requestAnimationFrame(this._updateOpacity.bind(this)))}_onOpaqueTile(){}_initContainer(){this._container||(this._container=O(`div`,`maplair-layer ${this.options.className??``}`),this._updateZIndex(),this.options.opacity<1&&this._updateOpacity(),this.getPane().appendChild(this._container))}_updateLevels(){let e=this._tileZoom,t=this.options.maxZoom;if(e===void 0)return;for(let n of Object.keys(this._levels))n=Number(n),this._levels[n].el.children.length||n===e?(this._levels[n].el.style.zIndex=t-Math.abs(e-n),this._onUpdateLevel(n)):(this._levels[n].el.remove(),this._removeTilesAtZoom(n),this._onRemoveLevel(n),delete this._levels[n]);let n=this._levels[e],r=this._map;return n||(n=this._levels[e]={},n.el=O(`div`,`maplair-tile-container maplair-zoom-animated`,this._container),n.el.style.zIndex=t,n.origin=r.project(r.unproject(r.getPixelOrigin()),e).round(),n.zoom=e,this._setZoomTransform(n,r.getCenter(),r.getZoom()),n.el.offsetWidth,this._onCreateLevel(n)),this._level=n,n}_onUpdateLevel(){}_onRemoveLevel(){}_onCreateLevel(){}_pruneTiles(){if(!this._map)return;let e=this._map.getZoom();if(e>this.options.maxZoom||e<this.options.minZoom){this._removeAllTiles();return}for(let e of Object.values(this._tiles))e.retain=e.current;for(let e of Object.values(this._tiles))if(e.current&&!e.active){let t=e.coords;this._retainParent(t.x,t.y,t.z,t.z-5)||this._retainChildren(t.x,t.y,t.z,t.z+2)}for(let[e,t]of Object.entries(this._tiles))t.retain||this._removeTile(e)}_removeTilesAtZoom(e){for(let[t,n]of Object.entries(this._tiles))n.coords.z===e&&this._removeTile(t)}_removeAllTiles(){for(let e of Object.keys(this._tiles))this._removeTile(e)}_invalidateAll(){for(let e of Object.keys(this._levels))this._levels[e].el.remove(),this._onRemoveLevel(Number(e)),delete this._levels[e];this._removeAllTiles(),this._tileZoom=void 0}_retainParent(e,t,n,r){let i=Math.floor(e/2),a=Math.floor(t/2),o=n-1,s=new g(+i,+a);s.z=+o;let c=this._tileCoordsToKey(s),l=this._tiles[c];return l?.active?(l.retain=!0,!0):(l?.loaded&&(l.retain=!0),o>r&&this._retainParent(i,a,o,r))}_retainChildren(e,t,n,r){for(let i=2*e;i<2*e+2;i++)for(let e=2*t;e<2*t+2;e++){let t=new g(i,e);t.z=n+1;let a=this._tileCoordsToKey(t),o=this._tiles[a];if(o?.active){o.retain=!0;continue}o?.loaded&&(o.retain=!0),n+1<r&&this._retainChildren(i,e,n+1,r)}}_resetView(e){let t=e&&(e.pinch||e.flyTo);this._setView(this._map.getCenter(),this._map.getZoom(),t,t)}_animateZoom(e){this._setView(e.center,e.zoom,!0,e.noUpdate)}_clampZoom(e){let t=this.options;return t.minNativeZoom!==void 0&&e<t.minNativeZoom?t.minNativeZoom:t.maxNativeZoom!==void 0&&t.maxNativeZoom<e?t.maxNativeZoom:e}_setView(e,t,n,r){let i=Math.round(t);i=this.options.maxZoom!==void 0&&i>this.options.maxZoom||this.options.minZoom!==void 0&&i<this.options.minZoom?void 0:this._clampZoom(i);let a=this.options.updateWhenZooming&&i!==this._tileZoom;(!r||a)&&(this._tileZoom=i,this._abortLoading&&this._abortLoading(),this._updateLevels(),this._resetGrid(),i!==void 0&&this._update(e),n||this._pruneTiles(),this._noPrune=!!n),this._setZoomTransforms(e,t)}_setZoomTransforms(e,t){for(let n of Object.values(this._levels))this._setZoomTransform(n,e,t)}_setZoomTransform(e,t,n){let r=this._map.getZoomScale(n,e.zoom),i=e.origin.multiplyBy(r).subtract(this._map._getNewPixelOrigin(t,n)).round();j(e.el,i,r)}_resetGrid(){let e=this._map,t=e.options.crs,n=this._tileSize=this.getTileSize(),r=this._tileZoom,i=this._map.getPixelWorldBounds(this._tileZoom);i&&(this._globalTileRange=this._pxBoundsToTileRange(i)),this._wrapX=t.wrapLng&&!this.options.noWrap&&[Math.floor(e.project([0,t.wrapLng[0]],r).x/n.x),Math.ceil(e.project([0,t.wrapLng[1]],r).x/n.y)],this._wrapY=t.wrapLat&&!this.options.noWrap&&[Math.floor(e.project([t.wrapLat[0],0],r).y/n.x),Math.ceil(e.project([t.wrapLat[1],0],r).y/n.y)]}_onMoveEnd(){this._map&&!this._map._animatingZoom&&this._update()}_getTiledPixelBounds(e){let t=this._map,n=t._animatingZoom?Math.max(t._animateToZoom,t.getZoom()):t.getZoom(),r=t.getZoomScale(n,this._tileZoom),i=t.project(e,this._tileZoom).floor(),a=t.getSize().divideBy(r*2);return new B(i.subtract(a),i.add(a))}_update(e){let t=this._map;if(!t)return;let n=this._clampZoom(t.getZoom());if(e===void 0&&(e=t.getCenter()),this._tileZoom===void 0)return;let r=this._getTiledPixelBounds(e),i=this._pxBoundsToTileRange(r),a=i.getCenter(),o=[],s=this.options.keepBuffer,c=new B(i.getBottomLeft().subtract([s,-s]),i.getTopRight().add([s,-s]));if(!(isFinite(i.min.x)&&isFinite(i.min.y)&&isFinite(i.max.x)&&isFinite(i.max.y)))throw Error(`Attempted to load an infinite number of tiles`);for(let e of Object.values(this._tiles)){let t=e.coords;(t.z!==this._tileZoom||!c.contains(new g(t.x,t.y)))&&(e.current=!1)}if(Math.abs(n-this._tileZoom)>1){this._setView(e,n);return}for(let e=i.min.y;e<=i.max.y;e++)for(let t=i.min.x;t<=i.max.x;t++){let n=new g(t,e);if(n.z=this._tileZoom,!this._isValidTile(n))continue;let r=this._tiles[this._tileCoordsToKey(n)];r?r.current=!0:o.push(n)}if(o.sort((e,t)=>e.distanceTo(a)-t.distanceTo(a)),o.length!==0){this._loading||(this._loading=!0,this.fire(`loading`));let e=document.createDocumentFragment();for(let t of o)this._addTile(t,e);this._level.el.appendChild(e)}}_isValidTile(e){let t=this._map.options.crs;if(!t.infinite){let n=this._globalTileRange;if(!t.wrapLng&&(e.x<n.min.x||e.x>n.max.x)||!t.wrapLat&&(e.y<n.min.y||e.y>n.max.y))return!1}if(!this.options.bounds)return!0;let n=this._tileCoordsToBounds(e);return new H(this.options.bounds).overlaps(n)}_keyToBounds(e){return this._tileCoordsToBounds(this._keyToTileCoords(e))}_tileCoordsToNwSe(e){let t=this._map,n=this.getTileSize(),r=e.scaleBy(n),i=r.add(n);return[t.unproject(r,e.z),t.unproject(i,e.z)]}_tileCoordsToBounds(e){let t=this._tileCoordsToNwSe(e),n=new H(t[0],t[1]);return this.options.noWrap||(n=this._map.wrapLatLngBounds(n)),n}_tileCoordsToKey(e){return`${e.x}:${e.y}:${e.z}`}_keyToTileCoords(e){let t=e.split(`:`),n=new g(+t[0],+t[1]);return n.z=+t[2],n}_removeTile(e){let t=this._tiles[e];t&&(t.el.remove(),delete this._tiles[e],this.fire(`tileunload`,{tile:t.el,coords:this._keyToTileCoords(e)}))}_initTile(e){e.classList.add(`maplair-tile`);let t=this.getTileSize();e.style.width=`${t.x}px`,e.style.height=`${t.y}px`,e.onselectstart=c,e.onpointermove=c}_addTile(e,t){let n=this._getTilePos(e),r=this._tileCoordsToKey(e),i=this.createTile(this._wrapCoords(e),this._tileReady.bind(this,e));this._initTile(i),this.createTile.length<2&&requestAnimationFrame(this._tileReady.bind(this,e,null,i)),M(i,n),this._tiles[r]={el:i,coords:e,current:!0},t.appendChild(i),this.fire(`tileloadstart`,{tile:i,coords:e})}_tileReady(e,t,n){t&&this.fire(`tileerror`,{error:t,tile:n,coords:e});let r=this._tileCoordsToKey(e);n=this._tiles[r],n&&(n.loaded=Date.now(),this._map._fadeAnimated?(n.el.style.opacity=0,cancelAnimationFrame(this._fadeFrame),this._fadeFrame=requestAnimationFrame(this._updateOpacity.bind(this))):(n.active=!0,this._pruneTiles()),t||(n.el.classList.add(`maplair-tile-loaded`),this.fire(`tileload`,{tile:n.el,coords:e})),this._noTilesToLoad()&&(this._loading=!1,this.fire(`load`),this._map._fadeAnimated?this._pruneTimeout=setTimeout(this._pruneTiles.bind(this),250):requestAnimationFrame(this._pruneTiles.bind(this))))}_getTilePos(e){return e.scaleBy(this.getTileSize()).subtract(this._level.origin)}_wrapCoords(e){let t=new g(this._wrapX?s(e.x,this._wrapX):e.x,this._wrapY?s(e.y,this._wrapY):e.y);return t.z=e.z,t}_pxBoundsToTileRange(e){let t=this.getTileSize();return new B(e.min.unscaleBy(t).floor(),e.max.unscaleBy(t).ceil().subtract([1,1]))}_noTilesToLoad(){return Object.values(this._tiles).every(e=>e.loaded)}},Wt=class e extends Ut{static{this.setDefaultOptions({minZoom:0,maxZoom:18,subdomains:`abc`,errorTileUrl:``,zoomOffset:0,tms:!1,zoomReverse:!1,detectRetina:!1,crossOrigin:!1,referrerPolicy:`strict-origin-when-cross-origin`})}constructor(t,n){super(n),this._url=t,n=f(this,n);let r=new URL(this._url,location.href),i=r.hostname;[`tile.openstreetmap.org`,`tile.osm.org`].some(e=>i.endsWith(e))&&(n.attribution===null&&(n.attribution=`&copy; <a href="https://www.openstreetmap.org/copyright">${L.translate(`OpenStreetMap contributors`)}</a>`),r.protocol===`http:`&&(r.protocol=`https:`,this._url=r.toString())),this.options.detectRetina&&_.retina&&this.options.maxZoom>0?(this.options.tileSize=Math.floor(this.options.tileSize/2),this.options.zoomReverse?(this.options.zoomOffset--,this.options.minZoom=Math.min(this.options.maxZoom,this.options.minZoom+1)):(this.options.zoomOffset++,this.options.maxZoom=Math.max(this.options.minZoom,this.options.maxZoom-1)),this.options.minZoom=Math.max(0,this.options.minZoom)):this.options.zoomReverse?this.options.minZoom=Math.min(this.options.maxZoom,this.options.minZoom):this.options.maxZoom=Math.max(this.options.minZoom,this.options.maxZoom),typeof this.options.subdomains==`string`&&(this.options.subdomains=this.options.subdomains.split(``)),this.on(`tileunload`,this._onTileRemove),this.callInitHooks(e)}setUrl(e,t){return this._url===e&&t===void 0&&(t=!0),this._url=e,t||this.redraw(),this}createTile(e,t){let n=document.createElement(`img`);return x(n,`load`,this._tileOnLoad.bind(this,t,n)),x(n,`error`,this._tileOnError.bind(this,t,n)),(this.options.crossOrigin||this.options.crossOrigin===``)&&(n.crossOrigin=this.options.crossOrigin===!0?``:this.options.crossOrigin),typeof this.options.referrerPolicy==`string`&&(n.referrerPolicy=this.options.referrerPolicy),n.alt=``,n.src=this.getTileUrl(e),n}getTileUrl(e){let t=Object.create(this.options);if(Object.assign(t,{r:_.retina?`@2x`:``,s:this._getSubdomain(e),x:e.x,y:e.y,z:this._getZoomForUrl()}),this._map&&!this._map.options.crs.infinite){let n=this._globalTileRange.max.y-e.y;this.options.tms&&(t.y=n),t[`-y`]=n}return m(this._url,t)}_tileOnLoad(e,t){e(null,t)}_tileOnError(e,t,n){let r=this.options.errorTileUrl;r&&t.getAttribute(`src`)!==r&&(t.src=r),e(n,t)}_onTileRemove(e){e.tile.onload=null}_getZoomForUrl(){let e=this._tileZoom,t=this.options.maxZoom,n=this.options.zoomReverse,r=this.options.zoomOffset;return n&&(e=t-e),e+r}_getSubdomain(e){let t=Math.abs(e.x+e.y)%this.options.subdomains.length;return this.options.subdomains[t]}_abortLoading(){let e,t;for(e of Object.keys(this._tiles))if(this._tiles[e].coords.z!==this._tileZoom&&(t=this._tiles[e].el,t.onload=c,t.onerror=c,!t.complete)){t.setAttribute(`src`,``);let n=this._tiles[e].coords;t.remove(),delete this._tiles[e],this.fire(`tileabort`,{tile:t,coords:n})}}_removeTile(e){let t=this._tiles[e];if(t)return t.el.setAttribute(`src`,``),super._removeTile(e)}_tileReady(e,t,n){if(!(!this._map||n&&n.getAttribute(`src`)===``))return super._tileReady(e,t,n)}_clampZoom(e){return Math.round(super._clampZoom(e))}},Gt=class e extends Wt{static{this.prototype.defaultWmsParams={service:`WMS`,request:`GetMap`,layers:``,styles:``,format:`image/jpeg`,transparent:!1,version:`1.1.1`},this.setDefaultOptions({crs:null,uppercase:!1})}constructor(t,n){super(t,n);let r={...this.defaultWmsParams};for(let[t,i]of Object.entries(n))t in e.prototype.options||(r[t]=i);let i=this.options.detectRetina&&_.retina?2:1,a=this.getTileSize();r.width=a.x*i,r.height=a.y*i,this.wmsParams=r,this.callInitHooks(e)}onAdd(e){this._crs=this.options.crs??e.options.crs,this._wmsVersion=parseFloat(this.wmsParams.version);let t=this._wmsVersion>=1.3?`crs`:`srs`;this.wmsParams[t]=this._crs.code,super.onAdd(e)}getTileUrl(e){let t=this._tileCoordsToNwSe(e),n=this._crs,r=new B(n.project(t[0]),n.project(t[1])),i=r.min,a=r.max,o=(this._wmsVersion>=1.3&&this._crs===Ct?[i.y,i.x,a.y,a.x]:[i.x,i.y,a.x,a.y]).join(`,`),s=new URL(super.getTileUrl(e));for(let[e,t]of Object.entries({...this.wmsParams,bbox:o}))s.searchParams.append(this.options.uppercase?e.toUpperCase():e,t);return s.toString()}setParams(e,t){return Object.assign(this.wmsParams,e),t||this.redraw(),this}},Kt=class e extends It{constructor(t){super({...t,continuous:!1}),a(this),this._layers??={},this.callInitHooks(e)}onAdd(e){super.onAdd(e),this.on(`update`,this._updatePaths,this)}onRemove(){super.onRemove(),this.off(`update`,this._updatePaths,this)}_onZoomEnd(){for(let e of Object.values(this._layers))e._project()}_updatePaths(){for(let e of Object.values(this._layers))e._update()}_onViewReset(){for(let e of Object.values(this._layers))e._reset()}_onSettled(){this._update()}_update(){}};const qt=/[, ]+/;var Jt=class e extends Kt{static{this.setDefaultOptions({tolerance:0})}constructor(...t){super(...t),this.callInitHooks(e)}getEvents(){let e=super.getEvents();return e.viewprereset=this._onViewPreReset,e}_onViewPreReset(){this._postponeUpdatePaths=!0}onAdd(e){super.onAdd(e),this._draw()}onRemove(){super.onRemove(),clearTimeout(this._pointerHoverThrottleTimeout)}_initContainer(){let e=this._container=document.createElement(`canvas`);x(e,`pointermove`,this._onPointerMove,this),x(e,`click dblclick pointerdown pointerup contextmenu`,this._onClick,this),x(e,`pointerout`,this._handlePointerOut,this),e._maplair_disable_events=!0,this._ctx=e.getContext(`2d`)}_destroyContainer(){cancelAnimationFrame(this._redrawRequest),this._redrawRequest=null,delete this._ctx,super._destroyContainer()}_resizeContainer(){let e=super._resizeContainer(),t=this._ctxScale=window.devicePixelRatio;this._container.width=t*e.x,this._container.height=t*e.y}_updatePaths(){if(!this._postponeUpdatePaths){this._redrawBounds=null;for(let e of Object.values(this._layers))e._update();this._redraw()}}_update(){if(this._map._animatingZoom&&this._bounds)return;let e=this._bounds,t=this._ctxScale;this._ctx.setTransform(t,0,0,t,-e.min.x*t,-e.min.y*t),this.fire(`update`)}_reset(){super._reset(),this._postponeUpdatePaths&&(this._postponeUpdatePaths=!1,this._updatePaths())}_initPath(e){this._updateDashArray(e),this._layers[a(e)]=e;let t=e._order={layer:e,prev:this._drawLast,next:null};this._drawLast&&(this._drawLast.next=t),this._drawLast=t,this._drawFirst??=this._drawLast}_addPath(e){this._requestRedraw(e)}_removePath(e){let t=e._order,n=t.next,r=t.prev;n?n.prev=r:this._drawLast=r,r?r.next=n:this._drawFirst=n,delete e._order,delete this._layers[a(e)],this._requestRedraw(e)}_updatePath(e){this._extendRedrawBounds(e),e._project(),e._update(),this._requestRedraw(e)}_updateStyle(e){this._updateDashArray(e),this._requestRedraw(e)}_updateDashArray(e){if(typeof e.options.dashArray==`string`){let t=e.options.dashArray.split(qt);e.options._dashArray=t.map(e=>Number(e)).filter(e=>!isNaN(e))}else e.options._dashArray=e.options.dashArray}_requestRedraw(e){this._map&&(this._extendRedrawBounds(e),this._redrawRequest??=requestAnimationFrame(this._redraw.bind(this)))}_extendRedrawBounds(e){if(e._pxBounds){let t=(e.options.weight??0)+1;this._redrawBounds??=new B,this._redrawBounds.extend(e._pxBounds.min.subtract([t,t])),this._redrawBounds.extend(e._pxBounds.max.add([t,t]))}}_redraw(){this._redrawRequest=null,this._redrawBounds&&(this._redrawBounds.min._floor(),this._redrawBounds.max._ceil()),this._clear(),this._draw(),this._redrawBounds=null}_clear(){let e=this._redrawBounds;if(e){let t=e.getSize();this._ctx.clearRect(e.min.x,e.min.y,t.x,t.y)}else this._ctx.save(),this._ctx.setTransform(1,0,0,1,0,0),this._ctx.clearRect(0,0,this._container.width,this._container.height),this._ctx.restore()}_draw(){let e,t=this._redrawBounds;if(this._ctx.save(),t){let e=t.getSize();this._ctx.beginPath(),this._ctx.rect(t.min.x,t.min.y,e.x,e.y),this._ctx.clip()}this._drawing=!0;for(let n=this._drawFirst;n;n=n.next)e=n.layer,(!t||e._pxBounds&&e._pxBounds.intersects(t))&&e._updatePath();this._drawing=!1,this._ctx.restore()}_updatePoly(e,t){if(!this._drawing)return;let n=e._parts,r=this._ctx;n.length&&(r.beginPath(),n.forEach(e=>{e.forEach((e,t)=>{r[t?`lineTo`:`moveTo`](e.x,e.y)}),t&&r.closePath()}),this._fillStroke(r,e))}_updateCircle(e){if(!this._drawing||e._empty())return;let t=e._point,n=this._ctx,r=Math.max(Math.round(e._pxRadius),1),i=(Math.max(Math.round(e._pxRadiusY),1)||r)/r;i!==1&&(n.save(),n.scale(1,i)),n.beginPath(),n.arc(t.x,t.y/i,r,0,Math.PI*2,!1),i!==1&&n.restore(),this._fillStroke(n,e)}_fillStroke(e,t){let n=t.options;n.fill&&(e.globalAlpha=n.fillOpacity,e.fillStyle=n.fillColor??n.color,e.fill(n.fillRule||`evenodd`)),n.stroke&&n.weight!==0&&(e.lineDashOffset=Number(n.dashOffset??0),e.setLineDash(n._dashArray??[]),e.globalAlpha=n.opacity,e.lineWidth=n.weight,e.strokeStyle=n.color,e.lineCap=n.lineCap,e.lineJoin=n.lineJoin,e.stroke())}_onClick(e){let t=this._map.pointerEventToLayerPoint(e),n,r;for(let i=this._drawFirst;i;i=i.next)n=i.layer,n.options.interactive&&n._containsPoint(t)&&(e.type!==`click`&&e.type!==`preclick`||!this._map._draggableMoved(n))&&(r=n);this._fireEvent(r?[r]:!1,e)}_onPointerMove(e){if(!this._map||this._map.dragging.moving()||this._map._animatingZoom)return;let t=this._map.pointerEventToLayerPoint(e);this._handlePointerHover(e,t)}_handlePointerOut(e){let t=this._hoveredLayer;t&&(this._container.classList.remove(`maplair-interactive`),this._fireEvent([t],e,`pointerout`),this._hoveredLayer=null,this._pointerHoverThrottled=!1)}_handlePointerHover(e,t){if(this._pointerHoverThrottled)return;let n,r;for(let e=this._drawFirst;e;e=e.next)n=e.layer,n.options.interactive&&n._containsPoint(t)&&(r=n);r!==this._hoveredLayer&&(this._handlePointerOut(e),r&&(this._container.classList.add(`maplair-interactive`),this._fireEvent([r],e,`pointerover`),this._hoveredLayer=r)),this._fireEvent(this._hoveredLayer?[this._hoveredLayer]:!1,e),this._pointerHoverThrottled=!0,this._pointerHoverThrottleTimeout=setTimeout((()=>{this._pointerHoverThrottled=!1}),32)}_fireEvent(e,t,n){this._map._fireDOMEvent(t,n||t.type,e)}_bringToFront(e){let t=e._order;if(!t)return;let n=t.next,r=t.prev;if(n)n.prev=r;else return;r?r.next=n:n&&(this._drawFirst=n),t.prev=this._drawLast,this._drawLast.next=t,t.next=null,this._drawLast=t,this._requestRedraw(e)}_bringToBack(e){let t=e._order;if(!t)return;let n=t.next,r=t.prev;if(r)r.next=n;else return;n?n.prev=r:r&&(this._drawLast=r),t.prev=null,t.next=this._drawFirst,this._drawFirst.prev=t,this._drawFirst=t,this._requestRedraw(e)}},Yt=class e extends Kt{constructor(...t){super(...t),this.callInitHooks(e)}_initContainer(){this._container=e.create(`svg`),this._container.setAttribute(`pointer-events`,`none`),this._rootGroup=e.create(`g`),this._container.appendChild(this._rootGroup)}_destroyContainer(){super._destroyContainer(),delete this._rootGroup,delete this._svgSize}_resizeContainer(){let e=super._resizeContainer();(!this._svgSize||!this._svgSize.equals(e))&&(this._svgSize=e,this._container.setAttribute(`width`,e.x),this._container.setAttribute(`height`,e.y));let t=this._bounds;t&&this._container.setAttribute(`viewBox`,[t.min.x,t.min.y,e.x,e.y].join(` `))}_update(){if(this._map._animatingZoom&&this._bounds)return;let e=this._bounds,t=e.getSize();this._container.setAttribute(`viewBox`,[e.min.x,e.min.y,t.x,t.y].join(` `)),this.fire(`update`)}_initPath(t){let n=t._path=e.create(`path`);t.options.className&&n.classList.add(...d(t.options.className)),t.options.interactive&&n.classList.add(`maplair-interactive`),this._updateStyle(t),this._layers[a(t)]=t}_addPath(e){this._rootGroup||this._initContainer(),this._rootGroup.appendChild(e._path),e.addInteractiveTarget(e._path)}_removePath(e){e._path.remove(),e.removeInteractiveTarget(e._path),delete this._layers[a(e)]}_updatePath(e){e._project(),e._update()}_updateStyle(e){let t=e._path,n=e.options;t&&(n.stroke?(t.setAttribute(`stroke`,n.color),t.setAttribute(`stroke-opacity`,n.opacity),t.setAttribute(`stroke-width`,n.weight),t.setAttribute(`stroke-linecap`,n.lineCap),t.setAttribute(`stroke-linejoin`,n.lineJoin),n.dashArray?t.setAttribute(`stroke-dasharray`,n.dashArray):t.removeAttribute(`stroke-dasharray`),n.dashOffset?t.setAttribute(`stroke-dashoffset`,n.dashOffset):t.removeAttribute(`stroke-dashoffset`)):t.setAttribute(`stroke`,`none`),n.fill?(t.setAttribute(`fill`,n.fillColor||n.color),t.setAttribute(`fill-opacity`,n.fillOpacity),t.setAttribute(`fill-rule`,n.fillRule||`evenodd`)):t.setAttribute(`fill`,`none`))}_updatePoly(t,n){this._setPath(t,e.pointsToPath(t._parts,n))}_updateCircle(e){let t=e._point,n=Math.max(Math.round(e._pxRadius),1),r=`a${n},${Math.max(Math.round(e._pxRadiusY),1)||n} 0 1,0 `,i=e._empty()?`M0 0`:`M${t.x-n},${t.y}${r}${n*2},0 ${r}${-n*2},0 `;this._setPath(e,i)}_setPath(e,t){e._path.setAttribute(`d`,t)}_bringToFront(e){k(e._path)}_bringToBack(e){A(e._path)}static create(e){return document.createElementNS(`http://www.w3.org/2000/svg`,e)}static pointsToPath(e,t){return e.flatMap(e=>[...e.map((e,t)=>`${(t?`L`:`M`)+e.x} ${e.y}`),t?`z`:``]).join(``)||`M0 0`}},Xt=class e extends Z{constructor(t,n){super(e._boundsToLatLngs(t),n),this.callInitHooks(e)}setBounds(t){return this.setLatLngs(e._boundsToLatLngs(t))}static _boundsToLatLngs(e){return e=new H(e),[e.getSouthWest(),e.getNorthWest(),e.getNorthEast(),e.getSouthEast()]}},Zt=/* @__PURE__ */ t({register:()=>Qt});function Qt(e){e.include({getRenderer(e){let t=e.options.renderer??this._getPaneRenderer(e.options.pane)??this.options.renderer??this._renderer;return t||=this._renderer=this._createRenderer(),this.hasLayer(t)||this.addLayer(t),t},_getPaneRenderer(e){if(e===`overlayPane`||e===void 0)return;let t=this._paneRenderers[e];return t===void 0&&(t=this._createRenderer({pane:e}),this._paneRenderers[e]=t),t},_createRenderer(e){return this.options.preferCanvas&&new Jt(e)||new Yt(e)}})}var $t=class e extends z{constructor(t){super(t),this._container=t._container,this._pane=t._panes.overlayPane,this._resetStateTimeout=0,t.on(`unload`,this._destroy,this),this.callInitHooks(e)}addHooks(){x(this._container,`pointerdown`,this._onPointerDown,this)}removeHooks(){C(this._container,`pointerdown`,this._onPointerDown,this)}moved(){return this._moved}_destroy(){this._pane.remove(),delete this._pane}_resetState(){this._resetStateTimeout=0,this._moved=!1}_clearDeferredResetState(){this._resetStateTimeout!==0&&(clearTimeout(this._resetStateTimeout),this._resetStateTimeout=0)}_onPointerDown(e){if(!e.shiftKey||e.button!==0)return!1;this._clearDeferredResetState(),this._resetState(),Le(),ze(),this._startPoint=this._map.pointerEventToContainerPoint(e),x(this._container,{contextmenu:D,pointermove:this._onPointerMove,pointerup:this._onPointerUp,keydown:this._onKeyDown},this),x(document,`keydown`,this._onKeyDown,this)}_onPointerMove(e){this._moved||(this._moved=!0,this._box=O(`div`,`maplair-zoom-box`,this._container),this._container.classList.add(`maplair-crosshair`),this._map.fire(`boxzoomstart`)),this._point=this._map.pointerEventToContainerPoint(e);let t=new B(this._point,this._startPoint),n=t.getSize();M(this._box,t.min),this._box.style.width=`${n.x}px`,this._box.style.height=`${n.y}px`}_finish(){this._moved&&(this._box.remove(),this._container.classList.remove(`maplair-crosshair`)),Re(),Be(),C(this._container,{contextmenu:D,pointermove:this._onPointerMove,pointerup:this._onPointerUp},this),C(document,`keydown`,this._onKeyDown,this)}_onPointerUp(e){if(e.button!==0||(this._finish(),!this._moved))return;this._clearDeferredResetState(),this._resetStateTimeout=setTimeout(this._resetState.bind(this),0);let t=new H(this._map.containerPointToLatLng(this._startPoint),this._map.containerPointToLatLng(this._point));this._map.fitBounds(t).fire(`boxzoomend`,{boxZoomBounds:t})}_onKeyDown(e){e.code===`Escape`&&(this._finish(),this._clearDeferredResetState(),this._resetState())}static register(t){t.mergeOptions({boxZoom:!0}),t.addInitHook(`addHandler`,`boxZoom`,e)}},en=class e extends z{constructor(...t){super(...t),this.callInitHooks(e)}addHooks(){this._map.on(`dblclick`,this._onDoubleClick,this)}removeHooks(){this._map.off(`dblclick`,this._onDoubleClick,this)}_onDoubleClick(e){let t=this._map,n=t.getZoom(),r=t.options.zoomDelta,i=e.originalEvent.shiftKey?n-r:n+r;t.options.doubleClickZoom===`center`?t.setZoom(i):t.setZoomAround(e.containerPoint,i)}static register(t){t.mergeOptions({doubleClickZoom:!0}),t.addInitHook(`addHandler`,`doubleClickZoom`,e)}},tn=class e extends z{constructor(...t){super(...t),this.callInitHooks(e)}addHooks(){if(!this._draggable){let e=this._map;this._draggable=new Ze(e._mapPane,e._container),this._draggable.on({dragstart:this._onDragStart,drag:this._onDrag,dragend:this._onDragEnd},this),this._draggable.on(`predrag`,this._onPreDragLimit,this),e.options.worldCopyJump&&(this._draggable.on(`predrag`,this._onPreDragWrap,this),e.on(`zoomend`,this._onZoomEnd,this),e.whenReady(this._onZoomEnd,this))}this._map._container.classList.add(`maplair-grab`,`maplair-touch-drag`),this._draggable.enable(),this._positions=[],this._times=[]}removeHooks(){this._map._container.classList.remove(`maplair-grab`,`maplair-touch-drag`),this._draggable.disable()}moved(){return this._draggable?._moved}moving(){return this._draggable?._moving}_onDragStart(){let e=this._map;if(e._stop(),this._map.options.maxBounds&&this._map.options.maxBoundsViscosity){let e=new H(this._map.options.maxBounds);this._offsetLimit=new B(this._map.latLngToContainerPoint(e.getNorthWest()).multiplyBy(-1),this._map.latLngToContainerPoint(e.getSouthEast()).multiplyBy(-1).add(this._map.getSize())),this._viscosity=Math.min(1,Math.max(0,this._map.options.maxBoundsViscosity))}else this._offsetLimit=null;e.fire(`movestart`).fire(`dragstart`),e.options.inertia&&(this._positions=[],this._times=[])}_onDrag(e){if(this._map.options.inertia){let e=this._lastTime=Date.now(),t=this._lastPos=this._draggable._absPos||this._draggable._newPos;this._positions.push(t),this._times.push(e),this._prunePositions(e)}this._map.fire(`move`,e).fire(`drag`,e)}_prunePositions(e){for(;this._positions.length>1&&e-this._times[0]>50;)this._positions.shift(),this._times.shift()}_onZoomEnd(){let e=this._map.getSize().divideBy(2),t=this._map.latLngToLayerPoint([0,0]);this._initialWorldOffset=t.subtract(e).x,this._worldWidth=this._map.getPixelWorldBounds().getSize().x}_viscousLimit(e,t){return e-(e-t)*this._viscosity}_onPreDragLimit(){if(!this._viscosity||!this._offsetLimit)return;let e=this._draggable._newPos.subtract(this._draggable._startPos),t=this._offsetLimit;e.x<t.min.x&&(e.x=this._viscousLimit(e.x,t.min.x)),e.y<t.min.y&&(e.y=this._viscousLimit(e.y,t.min.y)),e.x>t.max.x&&(e.x=this._viscousLimit(e.x,t.max.x)),e.y>t.max.y&&(e.y=this._viscousLimit(e.y,t.max.y)),this._draggable._newPos=this._draggable._startPos.add(e)}_onPreDragWrap(){let e=this._worldWidth,t=Math.round(e/2),n=this._initialWorldOffset,r=this._draggable._newPos.x,i=(r-t+n)%e+t-n,a=(r+t+n)%e-t-n,o=Math.abs(i+n)<Math.abs(a+n)?i:a;this._draggable._absPos=new g(this._draggable._newPos),this._draggable._newPos.x=o}_onDragEnd(e){let t=this._map,n=t.options,r=!n.inertia||e.noInertia||this._times.length<2;if(t.fire(`dragend`,e),r)t.fire(`moveend`);else{this._prunePositions(Date.now());let e=this._lastPos.subtract(this._positions[0]),r=(this._lastTime-this._times[0])/1e3,i=n.easeLinearity,a=e.multiplyBy(i/r),o=a.distanceTo([0,0]),s=Math.min(n.inertiaMaxSpeed,o),c=a.multiplyBy(s/o),l=s/(n.inertiaDeceleration*i),u=c.multiplyBy(-l/2).round();!u.x&&!u.y?t.fire(`moveend`):(u=t._limitOffset(u,t.options.maxBounds),requestAnimationFrame(()=>{t.panBy(u,{duration:l,easeLinearity:i,noMoveStart:!0,animate:!0})}))}}static register(t){t.mergeOptions({dragging:!0,inertia:!0,inertiaDeceleration:3400,inertiaMaxSpeed:1/0,easeLinearity:.2,worldCopyJump:!1,maxBoundsViscosity:0}),t.addInitHook(`addHandler`,`dragging`,e)}},nn=class e extends z{static keyCodes={left:[`ArrowLeft`],right:[`ArrowRight`],down:[`ArrowDown`],up:[`ArrowUp`],zoomIn:[`Equal`,`NumpadAdd`,`BracketRight`],zoomOut:[`Minus`,`NumpadSubtract`,`Digit6`,`Slash`]};constructor(t){super(t),this._setPanDelta(t.options.keyboardPanDelta),this._setZoomDelta(t.options.zoomDelta),this.callInitHooks(e)}addHooks(){let t=this._map._container;t.tabIndex<=0&&(t.tabIndex=`0`),t.ariaKeyShortcuts=Object.values(e.keyCodes).flat().join(` `),x(t,{focus:this._onFocus,blur:this._onBlur,pointerdown:this._onPointerDown},this),this._map.on({focus:this._addHooks,blur:this._removeHooks},this)}removeHooks(){this._removeHooks(),C(this._map._container,{focus:this._onFocus,blur:this._onBlur,pointerdown:this._onPointerDown},this),this._map.off({focus:this._addHooks,blur:this._removeHooks},this)}_onPointerDown(){if(this._focused)return;let e=document.body,t=document.documentElement,n=e.scrollTop||t.scrollTop,r=e.scrollLeft||t.scrollLeft;this._map._container.focus(),window.scrollTo(r,n)}_onFocus(){this._focused=!0,this._map.fire(`focus`)}_onBlur(){this._focused=!1,this._map.fire(`blur`)}_setPanDelta(t){let n=this._panKeys={},r=e.keyCodes;for(let e of r.left)n[e]=[-1*t,0];for(let e of r.right)n[e]=[t,0];for(let e of r.down)n[e]=[0,t];for(let e of r.up)n[e]=[0,-1*t]}_setZoomDelta(t){let n=this._zoomKeys={},r=e.keyCodes;for(let e of r.zoomIn)n[e]=t;for(let e of r.zoomOut)n[e]=-t}_addHooks(){x(document,`keydown`,this._onKeyDown,this)}_removeHooks(){C(document,`keydown`,this._onKeyDown,this)}_onKeyDown(e){if(e.altKey||e.ctrlKey||e.metaKey)return;let t=e.code,n=this._map,r;if(t in this._panKeys){if(!n._panAnim||!n._panAnim._inProgress){if(r=this._panKeys[t],e.shiftKey&&(r=new g(r).multiplyBy(3)),n.options.maxBounds&&(r=n._limitOffset(new g(r),n.options.maxBounds)),n.options.worldCopyJump){let e=n.wrapLatLng(n.unproject(n.project(n.getCenter()).add(r)));n.panTo(e)}else n.panBy(r)}}else if(t in this._zoomKeys)n.setZoom(n.getZoom()+(e.shiftKey?3:1)*this._zoomKeys[t]);else if(t===`Escape`&&n._popup&&n._popup.options.closeOnEscapeKey)n.closePopup();else return;D(e)}static register(t){t.mergeOptions({keyboard:!0,keyboardPanDelta:80}),t.addInitHook(`addHandler`,`keyboard`,e)}},rn=class e extends z{constructor(...t){super(...t),this.callInitHooks(e)}addHooks(){this._map._container.classList.add(`maplair-touch-zoom`),x(this._map._container,`pointerdown`,this._onPointerStart,this)}removeHooks(){this._map._container.classList.remove(`maplair-touch-zoom`),C(this._map._container,`pointerdown`,this._onPointerStart,this),C(this._map._container,`pointermove`,this._onPointerMove,this),C(this._map._container,`pointerup pointercancel`,this._onPointerEnd,this)}_onPointerStart(e){let t=this._map,n=b();if(n.length!==2||t._animatingZoom||this._zooming)return;let r=t.pointerEventToContainerPoint(n[0]),i=t.pointerEventToContainerPoint(n[1]);this._centerPoint=t.getSize()._divideBy(2),this._startLatLng=t.containerPointToLatLng(this._centerPoint),t.options.pinchZoom!==`center`&&(this._pinchStartLatLng=t.containerPointToLatLng(r.add(i)._divideBy(2))),this._startDist=r.distanceTo(i),this._startZoom=t.getZoom(),this._moved=!1,this._zooming=!0,t._stop(),x(this._map._container,`pointermove`,this._onPointerMove,this),x(this._map._container,`pointerup pointercancel`,this._onPointerEnd,this),e.preventDefault()}_onPointerMove(e){let t=b();if(t.length!==2||!this._zooming)return;let n=this._map,r=n.pointerEventToContainerPoint(t[0]),i=n.pointerEventToContainerPoint(t[1]),a=r.distanceTo(i)/this._startDist;if(this._zoom=n.getScaleZoom(a,this._startZoom),!n.options.bounceAtZoomLimits&&(this._zoom<n.getMinZoom()&&a<1||this._zoom>n.getMaxZoom()&&a>1)&&(this._zoom=n._limitZoom(this._zoom)),n.options.pinchZoom===`center`){if(this._center=this._startLatLng,a===1)return}else{let e=r._add(i)._divideBy(2)._subtract(this._centerPoint);if(a===1&&e.x===0&&e.y===0)return;this._center=n.unproject(n.project(this._pinchStartLatLng,this._zoom).subtract(e),this._zoom)}this._moved||=(n._moveStart(!0,!1),!0),cancelAnimationFrame(this._animRequest);let o=n._move.bind(n,this._center,this._zoom,{pinch:!0,round:!1},void 0);this._animRequest=requestAnimationFrame(o.bind(this)),e.preventDefault()}_onPointerEnd(){if(C(this._map._container,`pointermove`,this._onPointerMove,this),C(this._map._container,`pointerup pointercancel`,this._onPointerEnd,this),!this._moved||!this._zooming){this._zooming=!1;return}this._zooming=!1,cancelAnimationFrame(this._animRequest),this._map.options.zoomAnimation?this._map._animateZoom(this._center,this._map._limitZoom(this._zoom),!0,this._map.options.zoomSnap):this._map._resetView(this._center,this._map._limitZoom(this._zoom))}static register(t){t.mergeOptions({pinchZoom:!0,bounceAtZoomLimits:!0}),t.addInitHook(`addHandler`,`pinchZoom`,e),t.addInitHook(function(){this.touchZoom=this.pinchZoom,this.options.touchZoom!==void 0&&(console.warn(`Map: touchZoom option is deprecated and will be removed in future versions. Use pinchZoom instead.`),this.options.pinchZoom=this.options.touchZoom,delete this.options.touchZoom),this.options.pinchZoom?this.pinchZoom.enable():this.pinchZoom.disable()})}},an=class e extends z{constructor(...t){super(...t),this.callInitHooks(e)}addHooks(){x(this._map._container,`wheel`,this._onWheelScroll,this),this._delta=0}removeHooks(){C(this._map._container,`wheel`,this._onWheelScroll,this),clearTimeout(this._timer)}_onWheelScroll(e){let t=Ae(e),n=this._map.options.wheelDebounceTime;this._delta+=t,this._lastMousePos=this._map.pointerEventToContainerPoint(e),this._startTime||=Date.now();let r=Math.max(n-(Date.now()-this._startTime),0);clearTimeout(this._timer),this._timer=setTimeout(this._performZoom.bind(this),r),D(e)}_performZoom(){let e=this._map,t=e.getZoom(),n=this._map.options.zoomSnap??0;e._stop();let r=this._delta/(this._map.options.wheelPxPerZoomLevel*4),i=4*Math.log(2/(1+Math.exp(-Math.abs(r))))/Math.LN2,a=n?Math.ceil(i/n)*n:i,o=e._limitZoom(t+(this._delta>0?a:-a))-t;this._delta=0,this._startTime=null,o&&(e.options.scrollWheelZoom===`center`?e.setZoom(t+o):e.setZoomAround(this._lastMousePos,t+o))}static register(t){t.mergeOptions({scrollWheelZoom:!0,wheelDebounceTime:40,wheelPxPerZoomLevel:60}),t.addInitHook(`addHandler`,`scrollWheelZoom`,e)}},on=class e extends z{constructor(...t){super(...t),this.callInitHooks(e)}addHooks(){x(this._map._container,`pointerdown`,this._onDown,this)}removeHooks(){C(this._map._container,`pointerdown`,this._onDown,this),this._cancel(),this._cancelClickPrevent()}_onDown(e){if(clearTimeout(this._holdTimeout),b().length!==1||e.pointerType===`mouse`)return;let t=this._map._container;this._startPos=this._newPos=new g(e.clientX,e.clientY),this._holdTimeout=setTimeout((()=>{this._cancel(),this._isTapValid()&&(x(t,`pointerup`,E),x(t,`pointerup pointercancel`,this._cancelClickPrevent,this),this._simulateEvent(`contextmenu`,e))}),600),x(t,`pointerup pointercancel contextmenu`,this._cancel,this),x(t,`pointermove`,this._onMove,this)}_cancelClickPrevent(){let e=this._map._container;C(e,`pointerup`,E),C(e,`pointerup pointercancel`,this._cancelClickPrevent,this)}_cancel(){clearTimeout(this._holdTimeout);let e=this._map._container;C(e,`pointerup pointercancel contextmenu`,this._cancel,this),C(e,`pointermove`,this._onMove,this)}_onMove(e){this._newPos=new g(e.clientX,e.clientY)}_isTapValid(){return this._newPos.distanceTo(this._startPos)<=this._map.options.tapTolerance}_simulateEvent(e,t){let n=new MouseEvent(e,{bubbles:!0,cancelable:!0,view:window,screenX:t.screenX,screenY:t.screenY,clientX:t.clientX,clientY:t.clientY});n._simulated=!0,t.target.dispatchEvent(n)}static register(t){t.mergeOptions({tapHold:_.safari&&_.mobile,tapTolerance:15}),t.addInitHook(`addHandler`,`tapHold`,e)}},sn=class e extends R{static{this.setDefaultOptions({crs:xt,center:void 0,zoom:void 0,minZoom:void 0,maxZoom:void 0,layers:[],maxBounds:void 0,renderer:void 0,zoomAnimation:!_.reducedMotion,zoomAnimationThreshold:4,fadeAnimation:!_.reducedMotion,markerZoomAnimation:!0,markerCulling:!1,transform3DLimit:8388608,zoomSnap:1,zoomDelta:1,trackResize:!0})}constructor(t,n){super(),n=f(this,n),this._handlers=[],this._layers={},this._zoomBoundLayers={},this._sizeChanged=!0,this._initContainer(t),this._initLayout(),this._initEvents(),n.maxBounds&&this.setMaxBounds(n.maxBounds),n.zoom!==void 0&&(this._zoom=this._limitZoom(n.zoom)),n.center&&n.zoom!==void 0&&this.setView(new W(n.center),n.zoom,{reset:!0}),this.callInitHooks(e),this._zoomAnimated=this.options.zoomAnimation,this._zoomAnimated&&this._createAnimProxy(),this._addLayers(this.options.layers)}setView(e,t,n){return t=t===void 0?this._zoom:this._limitZoom(t),e=this._limitCenter(new W(e),t,this.options.maxBounds),n??={},this._stop(),this._loaded&&!n.reset&&n!==!0&&(n.animate!==void 0&&(n.zoom={animate:n.animate,...n.zoom},n.pan={animate:n.animate,duration:n.duration,...n.pan}),this._zoom===t?this._tryAnimatedPan(e,n.pan):this._tryAnimatedZoom&&this._tryAnimatedZoom(e,t,n.zoom))?(clearTimeout(this._sizeTimer),this):(this._resetView(e,t,n.pan?.noMoveStart),this)}setZoom(e,t){return this._loaded?this.setView(this.getCenter(),e,{zoom:t}):(this._zoom=e,this)}zoomIn(e,t){return e??=this.options.zoomDelta,this.setZoom(this._zoom+e,t)}zoomOut(e,t){return e??=this.options.zoomDelta,this.setZoom(this._zoom-e,t)}setZoomAround(e,t,n){let r=this.getZoomScale(t),i=this.getSize().divideBy(2),a=(e instanceof g?e:this.latLngToContainerPoint(e)).subtract(i).multiplyBy(1-1/r),o=this.containerPointToLatLng(i.add(a));return this.setView(o,t,{zoom:n})}_getBoundsCenterZoom(e,t){t??={},e=e.getBounds?e.getBounds():new H(e);let n=new g(t.paddingTopLeft||t.padding||[0,0]),r=new g(t.paddingBottomRight||t.padding||[0,0]),i=this.getBoundsZoom(e,!1,n.add(r));if(i=typeof t.maxZoom==`number`?Math.min(t.maxZoom,i):i,i===1/0)return{center:e.getCenter(),zoom:i};let a=r.subtract(n).divideBy(2),o=this.project(e.getSouthWest(),i),s=this.project(e.getNorthEast(),i);return{center:this.unproject(o.add(s).divideBy(2).add(a),i),zoom:i}}fitBounds(e,t){if(e=new H(e),!e.isValid())throw Error(`Bounds are not valid.`);let n=this._getBoundsCenterZoom(e,t);return this.setView(n.center,n.zoom,t)}fitWorld(e){return this.fitBounds([[-90,-180],[90,180]],e)}panTo(e,t){return this.setView(e,this._zoom,{pan:t})}panBy(e,t){if(e=new g(e).round(),t??={},!e.x&&!e.y)return this.fire(`moveend`);if(t.animate!==!0&&!this.getSize().contains(e))return this._resetView(this.unproject(this.project(this.getCenter()).add(e)),this.getZoom()),this;if(this._panAnim||(this._panAnim=new Xe,this._panAnim.on({step:this._onPanTransitionStep,end:this._onPanTransitionEnd},this)),t.noMoveStart||this.fire(`movestart`),!_.reducedMotion&&t.animate!==!1){this._mapPane.classList.add(`maplair-pan-anim`);let n=this._getMapPanePos().subtract(e).round();this._panAnim.run(this._mapPane,n,t.duration||.25,t.easeLinearity)}else this._rawPanBy(e),this.fire(`move`).fire(`moveend`);return this}flyTo(e,t,n){if(n??={},_.reducedMotion||n.animate===!1)return this.setView(e,t,n);this._stop();let r=this.project(this.getCenter()),i=this.project(e),a=this.getSize(),o=this._zoom;e=new W(e),t=t===void 0?o:this._limitZoom(t);let s=Math.max(a.x,a.y),c=s*this.getZoomScale(o,t),l=i.distanceTo(r)||1,u=1.42,d=u*u;function f(e){let t=e?-1:1,n=e?c:s,r=(c*c-s*s+t*d*d*l*l)/(2*n*d*l),i=Math.sqrt(r*r+1)-r;return i<15e-9?-18:Math.log(i)}function p(e){return(Math.exp(e)-Math.exp(-e))/2}function m(e){return(Math.exp(e)+Math.exp(-e))/2}function h(e){return p(e)/m(e)}let g=f(0);function ee(e){return s*(m(g)/m(g+u*e))}function te(e){return s*(m(g)*h(g+u*e)-p(g))/d}function ne(e){return 1-(1-e)**1.5}let re=Date.now(),ie=(f(1)-g)/u,ae=n.duration?1e3*n.duration:1e3*ie*.8,oe=()=>{let n=(Date.now()-re)/ae,a=ne(n)*ie;n<=1?(this._flyToFrame=requestAnimationFrame(oe),this._move(this.unproject(r.add(i.subtract(r).multiplyBy(te(a)/l)),o),this.getScaleZoom(s/ee(a),o),{flyTo:!0})):this._move(e,t)._moveEnd(!0)};return this._moveStart(!0,n.noMoveStart),oe(this),this}flyToBounds(e,t){let n=this._getBoundsCenterZoom(e,t);return this.flyTo(n.center,n.zoom,t)}setMaxBounds(e){return e=new H(e),this.listens(`moveend`,this._panInsideMaxBounds)&&this.off(`moveend`,this._panInsideMaxBounds),e.isValid()?(this.options.maxBounds=e,this._loaded&&this._panInsideMaxBounds(),this.on(`moveend`,this._panInsideMaxBounds)):(this.options.maxBounds=null,this)}setMinZoom(e){let t=this.options.minZoom;return this.options.minZoom=e,this._loaded&&t!==e&&(this.fire(`zoomlevelschange`),this.getZoom()<this.options.minZoom)?this.setZoom(e):this}setMaxZoom(e){let t=this.options.maxZoom;return this.options.maxZoom=e,this._loaded&&t!==e&&(this.fire(`zoomlevelschange`),this.getZoom()>this.options.maxZoom)?this.setZoom(e):this}panInsideBounds(e,t){this._enforcingBounds=!0;let n=this.getCenter(),r=this._limitCenter(n,this._zoom,new H(e));return n.equals(r)||this.panTo(r,t),this._enforcingBounds=!1,this}panInside(e,t){t??={};let n=new g(t.paddingTopLeft||t.padding||[0,0]),r=new g(t.paddingBottomRight||t.padding||[0,0]),i=this.project(this.getCenter()),a=this.project(e),o=this.getPixelBounds(),s=new B([o.min.add(n),o.max.subtract(r)]),c=s.getSize();if(!s.contains(a)){this._enforcingBounds=!0;let e=a.subtract(s.getCenter()),n=s.extend(a).getSize().subtract(c);i.x+=e.x<0?-n.x:n.x,i.y+=e.y<0?-n.y:n.y,this.panTo(this.unproject(i),t),this._enforcingBounds=!1}return this}invalidateSize(e){if(!this._loaded)return this;e={animate:!1,pan:!0,...e===!0?{animate:!0}:e};let t=this.getSize();this._sizeChanged=!0,this._lastCenter=null;let n=this.getSize(),r=t.divideBy(2).round(),i=n.divideBy(2).round(),a=r.subtract(i);return!a.x&&!a.y?this:(e.animate&&e.pan?this.panBy(a):(e.pan&&this._rawPanBy(a),this.fire(`move`),e.debounceMoveend?(clearTimeout(this._sizeTimer),this._sizeTimer=setTimeout(this.fire.bind(this,`moveend`),200)):this.fire(`moveend`)),this.fire(`resize`,{oldSize:t,newSize:n}))}stop(){return this.setZoom(this._limitZoom(this._zoom)),this.options.zoomSnap||this.fire(`viewreset`),this._stop()}locate(e){if(e=this._locateOptions={timeout:1e4,watch:!1,...e},!(`geolocation`in navigator))return this._handleGeolocationError({code:0,message:`Geolocation not supported.`}),this;let t=this._handleGeolocationResponse.bind(this),n=this._handleGeolocationError.bind(this);return e.watch?(this._locationWatchId!==void 0&&navigator.geolocation.clearWatch(this._locationWatchId),this._locationWatchId=navigator.geolocation.watchPosition(t,n,e)):navigator.geolocation.getCurrentPosition(t,n,e),this}stopLocate(){return navigator.geolocation?.clearWatch?.(this._locationWatchId),this._locateOptions&&(this._locateOptions.setView=!1),this}_handleGeolocationError(e){if(!this._container._maplair_id)return;let t=e.code,n=e.message||(t===1?`permission denied`:t===2?`position unavailable`:`timeout`);this._locateOptions.setView&&!this._loaded&&this.fitWorld(),this.fire(`locationerror`,{code:t,message:`Geolocation error: ${n}.`})}_handleGeolocationResponse(e){if(!this._container._maplair_id)return;let t=e.coords.latitude,n=e.coords.longitude,r=new W(t,n),i=r.toBounds(e.coords.accuracy*2),a=this._locateOptions;if(a.setView){let e=this.getBoundsZoom(i);this.setView(r,a.maxZoom?Math.min(e,a.maxZoom):e)}let o={latlng:r,bounds:i,timestamp:e.timestamp};for(let t in e.coords)typeof e.coords[t]==`number`&&(o[t]=e.coords[t]);this.fire(`locationfound`,o)}addHandler(e,t){if(!t)return this;let n=this[e]=new t(this);return this._handlers.push(n),this.options[e]&&n.enable(),this}remove(){if(this._initEvents(!0),this.options.maxBounds&&this.off(`moveend`,this._panInsideMaxBounds),this._containerId!==this._container._maplair_id)throw Error(`Map container is being reused by another instance`);delete this._container._maplair_id,delete this._containerId,this._locationWatchId!==void 0&&this.stopLocate(),this._stop(),ge(this._container),this._mapPane.remove(),this._clearControlPos&&this._clearControlPos(),this._resizeRequest&&=(cancelAnimationFrame(this._resizeRequest),null),this._clearHandlers(),clearTimeout(this._transitionEndTimer),clearTimeout(this._sizeTimer),this._loaded&&this.fire(`unload`),this._destroyAnimProxy();for(let e of Object.values(this._layers))e.remove();for(let e of Object.values(this._panes))e.remove();return this._layers={},this._panes={},delete this._mapPane,delete this._renderer,this}createPane(e,t){let n=O(`div`,`maplair-pane${e?` maplair-${e.replace(`Pane`,``)}-pane`:``}`,t||this._mapPane);return e&&(this._panes[e]=n),n}getCenter(){return this._checkIfLoaded(),this._lastCenter&&!this._moved()?new W(this._lastCenter):this.layerPointToLatLng(this._getCenterLayerPoint())}getZoom(){return this._zoom}getBounds(){let e=this.getPixelBounds();return new H(this.unproject(e.getBottomLeft()),this.unproject(e.getTopRight()))}getMinZoom(){return this.options.minZoom??this._layersMinZoom??0}getMaxZoom(){return this.options.maxZoom??this._layersMaxZoom??1/0}getBoundsZoom(e,t,n){e=new H(e),n=new g(n??[0,0]);let r=this.getZoom()??0,i=this.getMinZoom(),a=this.getMaxZoom(),o=e.getNorthWest(),s=e.getSouthEast(),c=this.getSize().subtract(n),l=new B(this.project(s,r),this.project(o,r)).getSize(),u=this.options.zoomSnap,d=c.x/l.x,f=c.y/l.y,p=t?Math.max(d,f):Math.min(d,f);return r=this.getScaleZoom(p,r),u&&(r=Math.round(r/(u/100))*(u/100),r=t?Math.ceil(r/u)*u:Math.floor(r/u)*u),Math.max(i,Math.min(a,r))}getSize(){return(!this._size||this._sizeChanged)&&(this._size=new g(this._container.clientWidth||0,this._container.clientHeight||0),this._sizeChanged=!1),new g(this._size)}getPixelBounds(e,t){let n=this._getTopLeftPoint(e,t);return new B(n,n.add(this.getSize()))}getPixelOrigin(){return this._checkIfLoaded(),this._pixelOrigin}getPixelWorldBounds(e){return this.options.crs.getProjectedBounds(e??this.getZoom())}getPane(e){return typeof e==`string`?this._panes[e]:e}getPanes(){return this._panes}getContainer(){return this._container}getZoomScale(e,t){let n=this.options.crs;return t??=this._zoom,n.scale(e)/n.scale(t)}getScaleZoom(e,t){let n=this.options.crs;t??=this._zoom;let r=n.zoom(e*n.scale(t));return isNaN(r)?1/0:r}project(e,t){return t??=this._zoom,this.options.crs.latLngToPoint(new W(e),t)}unproject(e,t){return t??=this._zoom,this.options.crs.pointToLatLng(new g(e),t)}layerPointToLatLng(e){let t=new g(e).add(this.getPixelOrigin());return this.unproject(t)}latLngToLayerPoint(e){return this.project(new W(e))._round()._subtract(this.getPixelOrigin())}wrapLatLng(e){return this.options.crs.wrapLatLng(new W(e))}wrapLatLngBounds(e){return this.options.crs.wrapLatLngBounds(new H(e))}distance(e,t){return this.options.crs.distance(new W(e),new W(t))}containerPointToLayerPoint(e){return new g(e).subtract(this._getMapPanePos())}layerPointToContainerPoint(e){return new g(e).add(this._getMapPanePos())}containerPointToLatLng(e){let t=this.containerPointToLayerPoint(new g(e));return this.layerPointToLatLng(t)}latLngToContainerPoint(e){return this.layerPointToContainerPoint(this.latLngToLayerPoint(new W(e)))}pointerEventToContainerPoint(e){return Oe(e,this._container)}pointerEventToLayerPoint(e){return this.containerPointToLayerPoint(this.pointerEventToContainerPoint(e))}pointerEventToLatLng(e){return this.layerPointToLatLng(this.pointerEventToLayerPoint(e))}_initContainer(e){let t=this._container=Ne(e);if(!t)throw Error(`Map container not found.`);if(t._maplair_id)throw Error(`Map container is already initialized.`);he(t),x(t,`scroll`,this._onScroll,this),this._containerId=a(t)}_initLayout(){let e=this._container;this._fadeAnimated=this.options.fadeAnimation;let t=[`maplair-container`,`maplair-touch`];_.retina&&t.push(`maplair-retina`),_.safari&&t.push(`maplair-safari`),this._fadeAnimated&&t.push(`maplair-fade-anim`),e.classList.add(...t);let{position:n}=getComputedStyle(e);n!==`absolute`&&n!==`relative`&&n!==`fixed`&&n!==`sticky`&&(e.style.position=`relative`),this._initPanes(),this._initControlPos&&this._initControlPos()}_initPanes(){let e=this._panes={};this._paneRenderers={},this._mapPane=this.createPane(`mapPane`,this._container),M(this._mapPane,new g(0,0)),this.createPane(`tilePane`),this.createPane(`overlayPane`),this.createPane(`shadowPane`),this.createPane(`markerPane`),this.createPane(`tooltipPane`),this.createPane(`popupPane`),this.options.markerZoomAnimation||(e.markerPane.classList.add(`maplair-zoom-hide`),e.shadowPane.classList.add(`maplair-zoom-hide`))}_resetView(e,t,n){M(this._mapPane,new g(0,0));let r=!this._loaded;this._loaded=!0,t=this._limitZoom(t),this.fire(`viewprereset`);let i=this._zoom!==t;this._moveStart(i,n)._move(e,t)._moveEnd(i),this.fire(`viewreset`),r&&this.fire(`load`)}_moveStart(e,t){return e&&this.fire(`zoomstart`),t||this.fire(`movestart`),this}_move(e,t,n,r){t===void 0&&(t=this._zoom);let i=this._zoom!==t;return this._zoom=t,this._lastCenter=e,this._pixelOrigin=this._getNewPixelOrigin(e),r?n?.pinch&&this.fire(`zoom`,n):((i||n?.pinch)&&this.fire(`zoom`,n),this.fire(`move`,n)),this}_moveEnd(e){return e&&this.fire(`zoomend`),this.fire(`moveend`)}_stop(){return cancelAnimationFrame(this._flyToFrame),cancelAnimationFrame(this._zoomAnimFrame),this._panAnim?.stop(),this}_rawPanBy(e){M(this._mapPane,this._getMapPanePos().subtract(e))}_getZoomSpan(){return this.getMaxZoom()-this.getMinZoom()}_panInsideMaxBounds(){this._enforcingBounds||this.panInsideBounds(this.options.maxBounds)}_checkIfLoaded(){if(!this._loaded)throw Error(`Set map center and zoom first.`)}_initEvents(e){this._targets={},this._targets[a(this._container)]=this,(e?C:x)(this._container,`click dblclick pointerdown pointerup pointerover pointerout pointermove contextmenu keypress keydown keyup`,this._handleDOMEvent,this),this.options.trackResize&&(e?this._resizeObserver.disconnect():(this._resizeObserver||=new ResizeObserver(this._onResize.bind(this)),this._resizeObserver.observe(this._container))),this.options.transform3DLimit&&(e?this.off:this.on).call(this,`moveend`,this._onMoveEnd)}_onResize(){cancelAnimationFrame(this._resizeRequest),this._resizeRequest=requestAnimationFrame(()=>{this.invalidateSize({debounceMoveend:!0})})}_onScroll(){this._container.scrollTop=0,this._container.scrollLeft=0}_onMoveEnd(){let e=this._getMapPanePos();Math.max(Math.abs(e.x),Math.abs(e.y))>=this.options.transform3DLimit&&this._resetView(this.getCenter(),this.getZoom())}_findEventTargets(e,t){let n=[],r,i=e.target||e.srcElement,o=!1,s=t===`pointerout`||t===`pointerover`;for(;i;){if(r=this._targets[a(i)],r&&(t===`click`||t===`preclick`)&&this._draggableMoved(r)){o=!0;break}if(r&&r.listens(t,!0)&&(s&&!je(i,e)||(n.push(r),s))||i===this._container)break;i=i.parentNode}return!n.length&&!o&&!s&&this.listens(t,!0)&&(n=[this]),n}_isClickDisabled(e){for(;e&&e!==this._container;){if(e._maplair_disable_click||!e.parentNode)return!0;e=e.parentNode}}_handleDOMEvent(e){let t=e.target??e.srcElement;if(!this._loaded||t._maplair_disable_events||e.type===`click`&&this._isClickDisabled(t))return;let n=e.type;n===`pointerdown`&&Ue(t),this._fireDOMEvent(e,n)}static _pointerEvents=[`click`,`dblclick`,`pointerover`,`pointerout`,`contextmenu`];_fireDOMEvent(t,n,r){n===`click`&&this._fireDOMEvent(t,`preclick`,r);let i=this._findEventTargets(t,n);if(r&&(i=[...r.filter(e=>e.listens(n,!0)),...i]),!i.length)return;n===`contextmenu`&&t.preventDefault();let a=i[0],o={originalEvent:t};if(t.type!==`keypress`&&t.type!==`keydown`&&t.type!==`keyup`){let e=a.getLatLng&&(!a._pxRadius||a._pxRadius<=10);o.containerPoint=e?this.latLngToContainerPoint(a.getLatLng()):this.pointerEventToContainerPoint(t),o.layerPoint=this.containerPointToLayerPoint(o.containerPoint),o.latlng=e?a.getLatLng():this.layerPointToLatLng(o.layerPoint)}for(let t of i)if(t.fire(n,o,!0),o.originalEvent._stopped||t.options.bubblingPointerEvents===!1&&e._pointerEvents.includes(n))return}_draggableMoved(e){return e=e.dragging?.enabled()?e:this,e.dragging?.moved()||this.boxZoom?.moved()}_clearHandlers(){for(let e of this._handlers)e.disable()}whenReady(e,t){return this._loaded?e.call(t||this,{target:this}):this.on(`load`,e,t),this}_getMapPanePos(){return N(this._mapPane)}_moved(){let e=this._getMapPanePos();return e&&!e.equals([0,0])}_getTopLeftPoint(e,t){return(e&&t!==void 0?this._getNewPixelOrigin(e,t):this.getPixelOrigin()).subtract(this._getMapPanePos())}_getNewPixelOrigin(e,t){let n=this.getSize()._divideBy(2);return this.project(e,t)._subtract(n)._add(this._getMapPanePos())._round()}_latLngToNewLayerPoint(e,t,n){let r=this._getNewPixelOrigin(n,t);return this.project(e,t)._subtract(r)}_latLngBoundsToNewLayerBounds(e,t,n){let r=this._getNewPixelOrigin(n,t);return new B([this.project(e.getSouthWest(),t)._subtract(r),this.project(e.getNorthWest(),t)._subtract(r),this.project(e.getSouthEast(),t)._subtract(r),this.project(e.getNorthEast(),t)._subtract(r)])}_getCenterLayerPoint(){return this.containerPointToLayerPoint(this.getSize()._divideBy(2))}_getCenterOffset(e){return this.latLngToLayerPoint(e).subtract(this._getCenterLayerPoint())}_limitCenter(e,t,n){if(!n)return e;let r=this.project(e,t),i=this.getSize().divideBy(2),a=new B(r.subtract(i),r.add(i)),o=this._getBoundsOffset(a,n,t);return Math.abs(o.x)<=1&&Math.abs(o.y)<=1?e:this.unproject(r.add(o),t)}_limitOffset(e,t){if(!t)return e;let n=this.getPixelBounds(),r=new B(n.min.add(e),n.max.add(e));return e.add(this._getBoundsOffset(r,t))}_getBoundsOffset(e,t,n){let r=new B(this.project(t.getNorthEast(),n),this.project(t.getSouthWest(),n)),i=r.min.subtract(e.min),a=r.max.subtract(e.max);return new g(this._rebound(i.x,-a.x),this._rebound(i.y,-a.y))}_rebound(e,t){return e+t>0?Math.round(e-t)/2:Math.max(0,Math.ceil(e))-Math.max(0,Math.floor(t))}_limitZoom(e){let t=this.getMinZoom(),n=this.getMaxZoom(),r=this.options.zoomSnap;return r&&(e=Math.round(e/r)*r),Math.max(t,Math.min(n,e))}_onPanTransitionStep(){this.fire(`move`)}_onPanTransitionEnd(){this._mapPane.classList.remove(`maplair-pan-anim`),this.fire(`moveend`)}_tryAnimatedPan(e,t){let n=this._getCenterOffset(e)._trunc();return t?.animate!==!0&&!this.getSize().contains(n)?!1:(this.panBy(n,t),!0)}_createAnimProxy(){this._proxy=O(`div`,`maplair-proxy maplair-zoom-animated`),this._panes.mapPane.appendChild(this._proxy),this.on(`zoomanim`,this._animateProxyZoom,this),this.on(`load moveend`,this._animMoveEnd,this),x(this._proxy,`transitionend`,this._catchTransitionEnd,this)}_animateProxyZoom(e){let t=this._proxy.style.transform;j(this._proxy,this.project(e.center,e.zoom),this.getZoomScale(e.zoom,1)),t===this._proxy.style.transform&&this._animatingZoom&&this._onZoomTransitionEnd()}_animMoveEnd(){let e=this.getCenter(),t=this.getZoom();j(this._proxy,this.project(e,t),this.getZoomScale(t,1))}_destroyAnimProxy(){this._proxy&&(C(this._proxy,`transitionend`,this._catchTransitionEnd,this),this._proxy.remove(),this.off(`zoomanim`,this._animateProxyZoom,this),this.off(`load moveend`,this._animMoveEnd,this),delete this._proxy)}_catchTransitionEnd(e){this._animatingZoom&&e.propertyName.includes(`transform`)&&this._onZoomTransitionEnd()}_nothingToAnimate(){return!this._container.getElementsByClassName(`maplair-zoom-animated`).length}_tryAnimatedZoom(e,t,n){if(this._animatingZoom)return!0;if(n??={},!this._zoomAnimated||n.animate===!1||this._nothingToAnimate()||Math.abs(t-this._zoom)>this.options.zoomAnimationThreshold)return!1;let r=this.getZoomScale(t),i=this._getCenterOffset(e)._divideBy(1-1/r);return n.animate!==!0&&!this.getSize().contains(i)?!1:(this._zoomAnimFrame=requestAnimationFrame(()=>{this._zoomAnimFrame=null,this._moveStart(!0,n.noMoveStart??!1)._animateZoom(e,t,!0)}),!0)}_animateZoom(e,t,n,r){this._mapPane&&(n&&(this._animatingZoom=!0,this._animateToCenter=e,this._animateToZoom=t,this._mapPane.classList.add(`maplair-zoom-anim`)),this.fire(`zoomanim`,{center:e,zoom:t,noUpdate:r}),this._tempFireZoomEvent||=this._zoom!==this._animateToZoom,this._move(this._animateToCenter,this._animateToZoom,void 0,!0),this._transitionEndTimer=setTimeout(this._onZoomTransitionEnd.bind(this),250))}_onZoomTransitionEnd(){this._animatingZoom&&(this._mapPane?.classList.remove(`maplair-zoom-anim`),this._animatingZoom=!1,this._move(this._animateToCenter,this._animateToZoom,void 0,!0),this._tempFireZoomEvent&&this.fire(`zoom`),delete this._tempFireZoomEvent,this.fire(`move`),this._moveEnd(!0))}};for(let e of[Ke,I,$,J,$t,en,tn,nn,rn,an,on,Bt,Vt,Zt,Ye])e.register(sn);const cn=sn,ln=n;export{Ke as AttributionControl,It as BlanketOverlay,B as Bounds,$t as BoxZoomHandler,_ as Browser,Qe as CRS,Jt as Canvas,Nt as Circle,Mt as CircleMarker,h as Class,I as Control,kt as DefaultIcon,Ht as DivIcon,$ as DivOverlay,be as DomEvent,Me as DomUtil,en as DoubleClickZoomHandler,tn as DragHandler,Ze as Draggable,bt as EPSG3395,xt as EPSG3857,Ct as EPSG4326,St as EPSG900913,U as EarthCRS,R as Evented,Y as FeatureGroup,Q as GeoJSON,Ut as GridLayer,z as Handler,L as I18n,Et as Icon,Lt as ImageOverlay,nn as KeyboardHandler,W as LatLng,H as LatLngBounds,J as Layer,Tt as LayerGroup,qe as LayersControl,rt as LineUtil,cn as Map,sn as MaplairMap,jt as Marker,X as Path,rn as PinchZoomHandler,g as Point,$e as PolyUtil,Z as Polygon,Pt as Polyline,Bt as Popup,Xe as PosAnimation,yt as Projection,Xt as Rectangle,Kt as Renderer,Yt as SVG,zt as SVGOverlay,Je as ScaleControl,an as ScrollWheelZoomHandler,wt as SimpleCRS,on as TapHoldHandler,Wt as TileLayer,Vt as Tooltip,V as Transformation,r as Util,Rt as VideoOverlay,Gt as WMSTileLayer,Ye as ZoomControl,ln as version};
//# sourceMappingURL=maplair.js.map