@convergeapp/chat-widget 1.0.1 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/widget.js +7 -6
- package/package.json +1 -1
package/dist/widget.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
(function(){"use strict";var Tn,st,Eo,Ge,wo,vo,Co,Ro,bs,Ms,Ls,So,Fi={},Io=[],Mh=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,bn=Array.isArray;function he(n,t){for(var e in t)n[e]=t[e];return n}function As(n){n&&n.parentNode&&n.parentNode.removeChild(n)}function Lh(n,t,e){var i,s,r,o={};for(r in t)r=="key"?i=t[r]:r=="ref"?s=t[r]:o[r]=t[r];if(arguments.length>2&&(o.children=arguments.length>3?Tn.call(arguments,2):e),typeof n=="function"&&n.defaultProps!=null)for(r in n.defaultProps)o[r]===void 0&&(o[r]=n.defaultProps[r]);return Mn(n,o,i,s,null)}function Mn(n,t,e,i,s){var r={type:n,props:t,key:e,ref:i,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:s??++Eo,__i:-1,__u:0};return s==null&&st.vnode!=null&&st.vnode(r),r}function Ni(n){return n.children}function Ln(n,t){this.props=n,this.context=t}function ni(n,t){if(t==null)return n.__?ni(n.__,n.__i+1):null;for(var e;t<n.__k.length;t++)if((e=n.__k[t])!=null&&e.__e!=null)return e.__e;return typeof n.type=="function"?ni(n):null}function To(n){var t,e;if((n=n.__)!=null&&n.__c!=null){for(n.__e=n.__c.base=null,t=0;t<n.__k.length;t++)if((e=n.__k[t])!=null&&e.__e!=null){n.__e=n.__c.base=e.__e;break}return To(n)}}function Os(n){(!n.__d&&(n.__d=!0)&&Ge.push(n)&&!An.__r++||wo!=st.debounceRendering)&&((wo=st.debounceRendering)||vo)(An)}function An(){for(var n,t,e,i,s,r,o,a=1;Ge.length;)Ge.length>a&&Ge.sort(Co),n=Ge.shift(),a=Ge.length,n.__d&&(e=void 0,i=void 0,s=(i=(t=n).__v).__e,r=[],o=[],t.__P&&((e=he({},i)).__v=i.__v+1,st.vnode&&st.vnode(e),Ps(t.__P,e,i,t.__n,t.__P.namespaceURI,32&i.__u?[s]:null,r,s??ni(i),!!(32&i.__u),o),e.__v=i.__v,e.__.__k[e.__i]=e,Oo(r,e,o),i.__e=i.__=null,e.__e!=s&&To(e)));An.__r=0}function bo(n,t,e,i,s,r,o,a,l,h,c){var u,d,f,g,m,_,p,y=i&&i.__k||Io,v=t.length;for(l=Ah(e,t,y,l,v),u=0;u<v;u++)(f=e.__k[u])!=null&&(d=f.__i==-1?Fi:y[f.__i]||Fi,f.__i=u,_=Ps(n,f,d,s,r,o,a,l,h,c),g=f.__e,f.ref&&d.ref!=f.ref&&(d.ref&&ks(d.ref,null,f),c.push(f.ref,f.__c||g,f)),m==null&&g!=null&&(m=g),(p=!!(4&f.__u))||d.__k===f.__k?l=Mo(f,l,n,p):typeof f.type=="function"&&_!==void 0?l=_:g&&(l=g.nextSibling),f.__u&=-7);return e.__e=m,l}function Ah(n,t,e,i,s){var r,o,a,l,h,c=e.length,u=c,d=0;for(n.__k=new Array(s),r=0;r<s;r++)(o=t[r])!=null&&typeof o!="boolean"&&typeof o!="function"?(l=r+d,(o=n.__k[r]=typeof o=="string"||typeof o=="number"||typeof o=="bigint"||o.constructor==String?Mn(null,o,null,null,null):bn(o)?Mn(Ni,{children:o},null,null,null):o.constructor==null&&o.__b>0?Mn(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):o).__=n,o.__b=n.__b+1,a=null,(h=o.__i=Oh(o,e,l,u))!=-1&&(u--,(a=e[h])&&(a.__u|=2)),a==null||a.__v==null?(h==-1&&(s>c?d--:s<c&&d++),typeof o.type!="function"&&(o.__u|=4)):h!=l&&(h==l-1?d--:h==l+1?d++:(h>l?d--:d++,o.__u|=4))):n.__k[r]=null;if(u)for(r=0;r<c;r++)(a=e[r])!=null&&(2&a.__u)==0&&(a.__e==i&&(i=ni(a)),Do(a,a));return i}function Mo(n,t,e,i){var s,r;if(typeof n.type=="function"){for(s=n.__k,r=0;s&&r<s.length;r++)s[r]&&(s[r].__=n,t=Mo(s[r],t,e,i));return t}n.__e!=t&&(i&&(t&&n.type&&!t.parentNode&&(t=ni(n)),e.insertBefore(n.__e,t||null)),t=n.__e);do t=t&&t.nextSibling;while(t!=null&&t.nodeType==8);return t}function Oh(n,t,e,i){var s,r,o,a=n.key,l=n.type,h=t[e],c=h!=null&&(2&h.__u)==0;if(h===null&&n.key==null||c&&a==h.key&&l==h.type)return e;if(i>(c?1:0)){for(s=e-1,r=e+1;s>=0||r<t.length;)if((h=t[o=s>=0?s--:r++])!=null&&(2&h.__u)==0&&a==h.key&&l==h.type)return o}return-1}function Lo(n,t,e){t[0]=="-"?n.setProperty(t,e??""):n[t]=e==null?"":typeof e!="number"||Mh.test(t)?e:e+"px"}function On(n,t,e,i,s){var r,o;t:if(t=="style")if(typeof e=="string")n.style.cssText=e;else{if(typeof i=="string"&&(n.style.cssText=i=""),i)for(t in i)e&&t in e||Lo(n.style,t,"");if(e)for(t in e)i&&e[t]==i[t]||Lo(n.style,t,e[t])}else if(t[0]=="o"&&t[1]=="n")r=t!=(t=t.replace(Ro,"$1")),o=t.toLowerCase(),t=o in n||t=="onFocusOut"||t=="onFocusIn"?o.slice(2):t.slice(2),n.l||(n.l={}),n.l[t+r]=e,e?i?e.u=i.u:(e.u=bs,n.addEventListener(t,r?Ls:Ms,r)):n.removeEventListener(t,r?Ls:Ms,r);else{if(s=="http://www.w3.org/2000/svg")t=t.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(t!="width"&&t!="height"&&t!="href"&&t!="list"&&t!="form"&&t!="tabIndex"&&t!="download"&&t!="rowSpan"&&t!="colSpan"&&t!="role"&&t!="popover"&&t in n)try{n[t]=e??"";break t}catch{}typeof e=="function"||(e==null||e===!1&&t[4]!="-"?n.removeAttribute(t):n.setAttribute(t,t=="popover"&&e==1?"":e))}}function Ao(n){return function(t){if(this.l){var e=this.l[t.type+n];if(t.t==null)t.t=bs++;else if(t.t<e.u)return;return e(st.event?st.event(t):t)}}}function Ps(n,t,e,i,s,r,o,a,l,h){var c,u,d,f,g,m,_,p,y,v,x,w,R,T,S,I,M,O=t.type;if(t.constructor!=null)return null;128&e.__u&&(l=!!(32&e.__u),r=[a=t.__e=e.__e]),(c=st.__b)&&c(t);t:if(typeof O=="function")try{if(p=t.props,y="prototype"in O&&O.prototype.render,v=(c=O.contextType)&&i[c.__c],x=c?v?v.props.value:c.__:i,e.__c?_=(u=t.__c=e.__c).__=u.__E:(y?t.__c=u=new O(p,x):(t.__c=u=new Ln(p,x),u.constructor=O,u.render=Dh),v&&v.sub(u),u.props=p,u.state||(u.state={}),u.context=x,u.__n=i,d=u.__d=!0,u.__h=[],u._sb=[]),y&&u.__s==null&&(u.__s=u.state),y&&O.getDerivedStateFromProps!=null&&(u.__s==u.state&&(u.__s=he({},u.__s)),he(u.__s,O.getDerivedStateFromProps(p,u.__s))),f=u.props,g=u.state,u.__v=t,d)y&&O.getDerivedStateFromProps==null&&u.componentWillMount!=null&&u.componentWillMount(),y&&u.componentDidMount!=null&&u.__h.push(u.componentDidMount);else{if(y&&O.getDerivedStateFromProps==null&&p!==f&&u.componentWillReceiveProps!=null&&u.componentWillReceiveProps(p,x),!u.__e&&u.shouldComponentUpdate!=null&&u.shouldComponentUpdate(p,u.__s,x)===!1||t.__v==e.__v){for(t.__v!=e.__v&&(u.props=p,u.state=u.__s,u.__d=!1),t.__e=e.__e,t.__k=e.__k,t.__k.some(function(L){L&&(L.__=t)}),w=0;w<u._sb.length;w++)u.__h.push(u._sb[w]);u._sb=[],u.__h.length&&o.push(u);break t}u.componentWillUpdate!=null&&u.componentWillUpdate(p,u.__s,x),y&&u.componentDidUpdate!=null&&u.__h.push(function(){u.componentDidUpdate(f,g,m)})}if(u.context=x,u.props=p,u.__P=n,u.__e=!1,R=st.__r,T=0,y){for(u.state=u.__s,u.__d=!1,R&&R(t),c=u.render(u.props,u.state,u.context),S=0;S<u._sb.length;S++)u.__h.push(u._sb[S]);u._sb=[]}else do u.__d=!1,R&&R(t),c=u.render(u.props,u.state,u.context),u.state=u.__s;while(u.__d&&++T<25);u.state=u.__s,u.getChildContext!=null&&(i=he(he({},i),u.getChildContext())),y&&!d&&u.getSnapshotBeforeUpdate!=null&&(m=u.getSnapshotBeforeUpdate(f,g)),I=c,c!=null&&c.type===Ni&&c.key==null&&(I=Po(c.props.children)),a=bo(n,bn(I)?I:[I],t,e,i,s,r,o,a,l,h),u.base=t.__e,t.__u&=-161,u.__h.length&&o.push(u),_&&(u.__E=u.__=null)}catch(L){if(t.__v=null,l||r!=null)if(L.then){for(t.__u|=l?160:128;a&&a.nodeType==8&&a.nextSibling;)a=a.nextSibling;r[r.indexOf(a)]=null,t.__e=a}else{for(M=r.length;M--;)As(r[M]);Ds(t)}else t.__e=e.__e,t.__k=e.__k,L.then||Ds(t);st.__e(L,t,e)}else r==null&&t.__v==e.__v?(t.__k=e.__k,t.__e=e.__e):a=t.__e=Ph(e.__e,t,e,i,s,r,o,l,h);return(c=st.diffed)&&c(t),128&t.__u?void 0:a}function Ds(n){n&&n.__c&&(n.__c.__e=!0),n&&n.__k&&n.__k.forEach(Ds)}function Oo(n,t,e){for(var i=0;i<e.length;i++)ks(e[i],e[++i],e[++i]);st.__c&&st.__c(t,n),n.some(function(s){try{n=s.__h,s.__h=[],n.some(function(r){r.call(s)})}catch(r){st.__e(r,s.__v)}})}function Po(n){return typeof n!="object"||n==null||n.__b&&n.__b>0?n:bn(n)?n.map(Po):he({},n)}function Ph(n,t,e,i,s,r,o,a,l){var h,c,u,d,f,g,m,_=e.props,p=t.props,y=t.type;if(y=="svg"?s="http://www.w3.org/2000/svg":y=="math"?s="http://www.w3.org/1998/Math/MathML":s||(s="http://www.w3.org/1999/xhtml"),r!=null){for(h=0;h<r.length;h++)if((f=r[h])&&"setAttribute"in f==!!y&&(y?f.localName==y:f.nodeType==3)){n=f,r[h]=null;break}}if(n==null){if(y==null)return document.createTextNode(p);n=document.createElementNS(s,y,p.is&&p),a&&(st.__m&&st.__m(t,r),a=!1),r=null}if(y==null)_===p||a&&n.data==p||(n.data=p);else{if(r=r&&Tn.call(n.childNodes),_=e.props||Fi,!a&&r!=null)for(_={},h=0;h<n.attributes.length;h++)_[(f=n.attributes[h]).name]=f.value;for(h in _)if(f=_[h],h!="children"){if(h=="dangerouslySetInnerHTML")u=f;else if(!(h in p)){if(h=="value"&&"defaultValue"in p||h=="checked"&&"defaultChecked"in p)continue;On(n,h,null,f,s)}}for(h in p)f=p[h],h=="children"?d=f:h=="dangerouslySetInnerHTML"?c=f:h=="value"?g=f:h=="checked"?m=f:a&&typeof f!="function"||_[h]===f||On(n,h,f,_[h],s);if(c)a||u&&(c.__html==u.__html||c.__html==n.innerHTML)||(n.innerHTML=c.__html),t.__k=[];else if(u&&(n.innerHTML=""),bo(t.type=="template"?n.content:n,bn(d)?d:[d],t,e,i,y=="foreignObject"?"http://www.w3.org/1999/xhtml":s,r,o,r?r[0]:e.__k&&ni(e,0),a,l),r!=null)for(h=r.length;h--;)As(r[h]);a||(h="value",y=="progress"&&g==null?n.removeAttribute("value"):g!=null&&(g!==n[h]||y=="progress"&&!g||y=="option"&&g!=_[h])&&On(n,h,g,_[h],s),h="checked",m!=null&&m!=n[h]&&On(n,h,m,_[h],s))}return n}function ks(n,t,e){try{if(typeof n=="function"){var i=typeof n.__u=="function";i&&n.__u(),i&&t==null||(n.__u=n(t))}else n.current=t}catch(s){st.__e(s,e)}}function Do(n,t,e){var i,s;if(st.unmount&&st.unmount(n),(i=n.ref)&&(i.current&&i.current!=n.__e||ks(i,null,t)),(i=n.__c)!=null){if(i.componentWillUnmount)try{i.componentWillUnmount()}catch(r){st.__e(r,t)}i.base=i.__P=null}if(i=n.__k)for(s=0;s<i.length;s++)i[s]&&Do(i[s],t,e||typeof n.type!="function");e||As(n.__e),n.__c=n.__=n.__e=void 0}function Dh(n,t,e){return this.constructor(n,e)}function kh(n,t,e){var i,s,r,o;t==document&&(t=document.documentElement),st.__&&st.__(n,t),s=(i=!1)?null:t.__k,r=[],o=[],Ps(t,n=t.__k=Lh(Ni,null,[n]),s||Fi,Fi,t.namespaceURI,s?null:t.firstChild?Tn.call(t.childNodes):null,r,s?s.__e:t.firstChild,i,o),Oo(r,n,o)}function Fh(n){function t(e){var i,s;return this.getChildContext||(i=new Set,(s={})[t.__c]=this,this.getChildContext=function(){return s},this.componentWillUnmount=function(){i=null},this.shouldComponentUpdate=function(r){this.props.value!=r.value&&i.forEach(function(o){o.__e=!0,Os(o)})},this.sub=function(r){i.add(r);var o=r.componentWillUnmount;r.componentWillUnmount=function(){i&&i.delete(r),o&&o.call(r)}}),e.children}return t.__c="__cC"+So++,t.__=n,t.Provider=t.__l=(t.Consumer=function(e,i){return e.children(i)}).contextType=t,t}Tn=Io.slice,st={__e:function(n,t,e,i){for(var s,r,o;t=t.__;)if((s=t.__c)&&!s.__)try{if((r=s.constructor)&&r.getDerivedStateFromError!=null&&(s.setState(r.getDerivedStateFromError(n)),o=s.__d),s.componentDidCatch!=null&&(s.componentDidCatch(n,i||{}),o=s.__d),o)return s.__E=s}catch(a){n=a}throw n}},Eo=0,Ln.prototype.setState=function(n,t){var e;e=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=he({},this.state),typeof n=="function"&&(n=n(he({},e),this.props)),n&&he(e,n),n!=null&&this.__v&&(t&&this._sb.push(t),Os(this))},Ln.prototype.forceUpdate=function(n){this.__v&&(this.__e=!0,n&&this.__h.push(n),Os(this))},Ln.prototype.render=Ni,Ge=[],vo=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,Co=function(n,t){return n.__v.__b-t.__v.__b},An.__r=0,Ro=/(PointerCapture)$|Capture$/i,bs=0,Ms=Ao(!1),Ls=Ao(!0),So=0;var Nh=0;function E(n,t,e,i,s,r){t||(t={});var o,a,l=t;if("ref"in l)for(a in l={},t)a=="ref"?o=t[a]:l[a]=t[a];var h={type:n,props:l,key:e,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--Nh,__i:-1,__u:0,__source:s,__self:r};if(typeof n=="function"&&(o=n.defaultProps))for(a in o)l[a]===void 0&&(l[a]=o[a]);return st.vnode&&st.vnode(h),h}var We,ot,Fs,ko,zi=0,Fo=[],dt=st,No=dt.__b,zo=dt.__r,Go=dt.diffed,Wo=dt.__c,Xo=dt.unmount,Yo=dt.__;function Gi(n,t){dt.__h&&dt.__h(ot,n,zi||t),zi=0;var e=ot.__H||(ot.__H={__:[],__h:[]});return n>=e.__.length&&e.__.push({}),e.__[n]}function vt(n){return zi=1,Bo(jo,n)}function Bo(n,t,e){var i=Gi(We++,2);if(i.t=n,!i.__c&&(i.__=[jo(void 0,t),function(a){var l=i.__N?i.__N[0]:i.__[0],h=i.t(l,a);l!==h&&(i.__N=[h,i.__[1]],i.__c.setState({}))}],i.__c=ot,!ot.__f)){var s=function(a,l,h){if(!i.__c.__H)return!0;var c=i.__c.__H.__.filter(function(d){return!!d.__c});if(c.every(function(d){return!d.__N}))return!r||r.call(this,a,l,h);var u=i.__c.props!==a;return c.forEach(function(d){if(d.__N){var f=d.__[0];d.__=d.__N,d.__N=void 0,f!==d.__[0]&&(u=!0)}}),r&&r.call(this,a,l,h)||u};ot.__f=!0;var r=ot.shouldComponentUpdate,o=ot.componentWillUpdate;ot.componentWillUpdate=function(a,l,h){if(this.__e){var c=r;r=void 0,s(a,l,h),r=c}o&&o.call(this,a,l,h)},ot.shouldComponentUpdate=s}return i.__N||i.__}function ee(n,t){var e=Gi(We++,3);!dt.__s&&zs(e.__H,t)&&(e.__=n,e.u=t,ot.__H.__h.push(e))}function zh(n,t){var e=Gi(We++,4);!dt.__s&&zs(e.__H,t)&&(e.__=n,e.u=t,ot.__h.push(e))}function Wi(n){return zi=5,Uo(function(){return{current:n}},[])}function Uo(n,t){var e=Gi(We++,7);return zs(e.__H,t)&&(e.__=n(),e.__H=t,e.__h=n),e.__}function At(n,t){return zi=8,Uo(function(){return n},t)}function Gh(n){var t=ot.context[n.__c],e=Gi(We++,9);return e.c=n,t?(e.__==null&&(e.__=!0,t.sub(ot)),t.props.value):n.__}function Wh(){for(var n;n=Fo.shift();)if(n.__P&&n.__H)try{n.__H.__h.forEach(Pn),n.__H.__h.forEach(Ns),n.__H.__h=[]}catch(t){n.__H.__h=[],dt.__e(t,n.__v)}}dt.__b=function(n){ot=null,No&&No(n)},dt.__=function(n,t){n&&t.__k&&t.__k.__m&&(n.__m=t.__k.__m),Yo&&Yo(n,t)},dt.__r=function(n){zo&&zo(n),We=0;var t=(ot=n.__c).__H;t&&(Fs===ot?(t.__h=[],ot.__h=[],t.__.forEach(function(e){e.__N&&(e.__=e.__N),e.u=e.__N=void 0})):(t.__h.forEach(Pn),t.__h.forEach(Ns),t.__h=[],We=0)),Fs=ot},dt.diffed=function(n){Go&&Go(n);var t=n.__c;t&&t.__H&&(t.__H.__h.length&&(Fo.push(t)!==1&&ko===dt.requestAnimationFrame||((ko=dt.requestAnimationFrame)||Xh)(Wh)),t.__H.__.forEach(function(e){e.u&&(e.__H=e.u),e.u=void 0})),Fs=ot=null},dt.__c=function(n,t){t.some(function(e){try{e.__h.forEach(Pn),e.__h=e.__h.filter(function(i){return!i.__||Ns(i)})}catch(i){t.some(function(s){s.__h&&(s.__h=[])}),t=[],dt.__e(i,e.__v)}}),Wo&&Wo(n,t)},dt.unmount=function(n){Xo&&Xo(n);var t,e=n.__c;e&&e.__H&&(e.__H.__.forEach(function(i){try{Pn(i)}catch(s){t=s}}),e.__H=void 0,t&&dt.__e(t,e.__v))};var Ko=typeof requestAnimationFrame=="function";function Xh(n){var t,e=function(){clearTimeout(i),Ko&&cancelAnimationFrame(t),setTimeout(n)},i=setTimeout(e,35);Ko&&(t=requestAnimationFrame(e))}function Pn(n){var t=ot,e=n.__c;typeof e=="function"&&(n.__c=void 0,e()),ot=t}function Ns(n){var t=ot;n.__c=n.__(),ot=t}function zs(n,t){return!n||n.length!==t.length||t.some(function(e,i){return e!==n[i]})}function jo(n,t){return typeof t=="function"?t(n):t}const Gs="converge_widget_",ie={get(n,t){try{const e=localStorage.getItem(Gs+n);return e?JSON.parse(e):t}catch{return t}},set(n,t){try{localStorage.setItem(Gs+n,JSON.stringify(t))}catch(e){console.error("Failed to save to localStorage:",e)}},remove(n){try{localStorage.removeItem(Gs+n)}catch(t){console.error("Failed to remove from localStorage:",t)}}};function Yh(n){const t={id:n.id,isSupport:n.from==="agent",timestamp:n.timestamp},e=n.messageType||"text";if(e==="location")try{const i=JSON.parse(n.content);return{...t,type:"location",latitude:i.latitude,longitude:i.longitude,name:i.name,address:i.address}}catch{return{...t,type:"text",content:n.content}}return e==="photo"?{...t,type:"photo",url:n.contentUrl||"",filename:n.fileName||void 0,size:n.fileSize||void 0,content:n.content}:e==="video"?{...t,type:"video",url:n.contentUrl||"",filename:n.fileName||void 0,size:n.fileSize||void 0,content:n.content}:e==="file"?{...t,type:"file",url:n.contentUrl||"",filename:n.fileName||"file",size:n.fileSize||void 0,mimeType:n.mimeType||void 0}:{...t,type:"text",content:n.content}}const Vo=Fh(null);function Bh({children:n,config:t}){const[e]=vt(!1),[i,s]=vt(!1),[r,o]=vt(""),[a,l]=vt(ie.get("token","")),[h,c]=vt(!1),[u,d]=vt(ie.get("name","")),[f,g]=vt(ie.get("email","")),[m,_]=vt(ie.get("customer_id","")),[p,y]=vt(!1),[v,x]=vt(!0),[w,R]=vt([]),[T,S]=vt(ie.get("platform","")),[I,M]=vt(!1),[O,L]=vt(!1),[A,P]=vt([]),X=Wi(),k=Wi(void 0);ee(()=>{ie.set("token",a)},[a]),ee(()=>{ie.set("name",u)},[u]),ee(()=>{ie.set("email",f)},[f]),ee(()=>{ie.set("customer_id",m)},[m]),ee(()=>{ie.set("platform",T)},[T]);const G=At(async()=>{if(console.log("session token?"),!!a){console.log("Yes");try{const W=k.current?`${t.apiUrl}/messages?since=${encodeURIComponent(k.current)}`:`${t.apiUrl}/messages`;console.log("fetching");const rt=await fetch(W,{headers:{Authorization:`Bearer ${a}`}});if(console.log("Fetched"),!rt.ok)throw new Error("Failed to poll messages");console.log("parsing");const j=await rt.json();if(j.messages&&j.messages.length>0){console.log("setting");const nt=j.messages.map(Yh);P(mt=>[...mt,...nt]),k.current=nt[nt.length-1].timestamp}}catch(W){console.error("Failed to poll messages:",W)}finally{console.log("finally"),X.current=setTimeout(G,100)}}},[a,t.apiUrl]),D=At(()=>{X.current||!a||G()},[a,G]),Y=At(async()=>{try{const W=await fetch(`${t.apiUrl}/platforms`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:t.apiKey})});if(!W.ok)throw new Error("Failed to fetch platforms");const rt=await W.json();R(rt.platforms||[])}catch(W){console.error("Failed to fetch platforms:",W),R([{type:"widget",name:"Website Chat"}])}},[t.apiUrl,t.apiKey]);ee(()=>((async()=>{a&&T==="widget"?(D(),c(!0),x(!1)):await Y()})(),()=>{X.current&&clearTimeout(X.current)}),[a]);const V=At(async(W,rt)=>{if(!W.trim())return;const j=m||`widget_${Date.now()}_${Math.random().toString(36).substring(2,15)}`;try{const nt=await fetch(`${t.apiUrl}/init`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:t.apiKey,customerId:j,customerName:W,customerEmail:rt||void 0})});if(!nt.ok)throw new Error("Failed to initialize");const mt=await nt.json();l(mt.token),_(j),d(W),g(rt||""),S("widget"),c(!0),y(!1),D()}catch(nt){console.error("Widget initialization failed:",nt)}},[m,t.apiUrl,t.apiKey,D]),tt=At(W=>{W.type==="widget"?(S(W.type),x(!1),y(!a||!u),c(!!(a&&u))):W.link&&(window.open(W.link,"_blank"),s(!1))},[a,u]),b=At(()=>{y(!1),x(!0),c(!1)},[]),xt=At(async()=>{if(!r.trim()||!a||I)return;const W=r.trim();o(""),M(!0);try{const rt={type:"text",content:W};if(!(await fetch(`${t.apiUrl}/message`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`},body:JSON.stringify(rt)})).ok)throw new Error("Failed to send message")}catch(rt){console.error("Failed to send message:",rt),o(W)}finally{M(!1)}},[r,a,I,t.apiUrl]),ft=At(async(W,rt)=>{if(!(!a||I)){M(!0);try{const j=new FormData;if(j.append("file",rt),j.append("messageData",JSON.stringify(W)),!(await fetch(`${t.apiUrl}/message`,{method:"POST",headers:{Authorization:`Bearer ${a}`},body:j})).ok)throw new Error("Failed to send attachment")}catch(j){console.error("Failed to send attachment:",j)}finally{M(!1)}}},[a,I,t.apiUrl]),ht=At(()=>{const W=document.createElement("input");W.type="file",W.accept="image/*,video/*",W.onchange=async rt=>{const j=rt.target.files?.[0];if(!j)return;const nt=10*1024*1024;if(j.size>nt){alert("File size must be less than 10MB");return}const ze=j.type.startsWith("video/")?{type:"video",filename:j.name,size:j.size}:{type:"photo",filename:j.name,size:j.size};await ft(ze,j)},W.click(),L(!1)},[ft]),bt=At(()=>{const W=document.createElement("input");W.type="file",W.accept=".pdf,.doc,.docx,.xls,.xlsx,.txt,.zip,.rar",W.onchange=async rt=>{const j=rt.target.files?.[0];if(!j)return;const nt=10*1024*1024;if(j.size>nt){alert("File size must be less than 10MB");return}const mt={type:"file",filename:j.name,size:j.size,mimeType:j.type};await ft(mt,j)},W.click(),L(!1)},[ft]),Et=At(async()=>{if(L(!1),!navigator.geolocation){console.error("Geolocation is not supported");return}if(!I){M(!0);try{const W=await new Promise((nt,mt)=>{navigator.geolocation.getCurrentPosition(nt,mt)}),rt={type:"location",latitude:W.coords.latitude,longitude:W.coords.longitude};if(!(await fetch(`${t.apiUrl}/message`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`},body:JSON.stringify(rt)})).ok)throw new Error("Failed to send location")}catch(W){console.error("Failed to send location:",W)}finally{M(!1)}}},[I,a,t.apiUrl]),jt=At(()=>{s(W=>!W)},[]),Gt=At(()=>{L(W=>!W)},[]),Mt=At(()=>{L(!1)},[]),Oi={config:t,isOpen:i,inputMessage:r,sessionToken:a,isInitialized:h,customerName:u,customerEmail:f,customerId:m,showNamePrompt:p,showPlatformChoice:v,availablePlatforms:w,selectedPlatform:T,isSending:I,showAttachmentMenu:O,messages:A,setInputMessage:o,toggleChat:jt,toggleAttachmentMenu:Gt,closeAttachmentMenu:Mt,fetchAvailablePlatforms:Y,selectPlatform:tt,goBackToPlatforms:b,initializeWidgetSession:V,sendMessage:xt,sendAttachment:ft,handleGalleryUpload:ht,handleFileUpload:bt,handleLocationShare:Et,isLoadingMessages:e};return E(Vo.Provider,{value:Oi,children:n})}function Uh(){const n=Gh(Vo);if(!n)throw new Error("useWidget must be used within WidgetProvider");return n}const Kh="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20stroke='currentColor'%20stroke-width='2'%20stroke-linecap='round'%20stroke-linejoin='round'%20class='lucide%20lucide-arrow-up-icon%20lucide-arrow-up'%3e%3cpath%20d='m5%2012%207-7%207%207'/%3e%3cpath%20d='M12%2019V5'/%3e%3c/svg%3e";function si(n,t,e){let i=e.initialDeps??[],s;function r(){var o,a,l,h;let c;e.key&&((o=e.debug)!=null&&o.call(e))&&(c=Date.now());const u=n();if(!(u.length!==i.length||u.some((g,m)=>i[m]!==g)))return s;i=u;let f;if(e.key&&((a=e.debug)!=null&&a.call(e))&&(f=Date.now()),s=t(...u),e.key&&((l=e.debug)!=null&&l.call(e))){const g=Math.round((Date.now()-c)*100)/100,m=Math.round((Date.now()-f)*100)/100,_=m/16,p=(y,v)=>{for(y=String(y);y.length<v;)y=" "+y;return y};console.info(`%c⏱ ${p(m,5)} /${p(g,5)} ms`,`
|
|
1
|
+
(function(){"use strict";try{if(typeof document<"u"){var o=document.createElement("style");o.appendChild(document.createTextNode(':root,:host{--ol-background-color: white;--ol-accent-background-color: #F5F5F5;--ol-subtle-background-color: rgba(128, 128, 128, .25);--ol-partial-background-color: rgba(255, 255, 255, .75);--ol-foreground-color: #333333;--ol-subtle-foreground-color: #666666;--ol-brand-color: #00AAFF}.ol-box{box-sizing:border-box;border-radius:2px;border:1.5px solid var(--ol-background-color);background-color:var(--ol-partial-background-color)}.ol-mouse-position{top:8px;right:8px;position:absolute}.ol-scale-line{background:var(--ol-partial-background-color);border-radius:4px;bottom:8px;left:8px;padding:2px;position:absolute}.ol-scale-line-inner{border:1px solid var(--ol-subtle-foreground-color);border-top:none;color:var(--ol-foreground-color);font-size:10px;text-align:center;margin:1px;will-change:contents,width;transition:all .25s}.ol-scale-bar{position:absolute;bottom:8px;left:8px}.ol-scale-bar-inner{display:flex}.ol-scale-step-marker{width:1px;height:15px;background-color:var(--ol-foreground-color);float:right;z-index:10}.ol-scale-step-text{position:absolute;bottom:-5px;font-size:10px;z-index:11;color:var(--ol-foreground-color);text-shadow:-1.5px 0 var(--ol-partial-background-color),0 1.5px var(--ol-partial-background-color),1.5px 0 var(--ol-partial-background-color),0 -1.5px var(--ol-partial-background-color)}.ol-scale-text{position:absolute;font-size:12px;text-align:center;bottom:25px;color:var(--ol-foreground-color);text-shadow:-1.5px 0 var(--ol-partial-background-color),0 1.5px var(--ol-partial-background-color),1.5px 0 var(--ol-partial-background-color),0 -1.5px var(--ol-partial-background-color)}.ol-scale-singlebar{position:relative;height:10px;z-index:9;box-sizing:border-box;border:1px solid var(--ol-foreground-color)}.ol-scale-singlebar-even{background-color:var(--ol-subtle-foreground-color)}.ol-scale-singlebar-odd{background-color:var(--ol-background-color)}.ol-unsupported{display:none}.ol-viewport,.ol-unselectable{-webkit-touch-callout:none;-webkit-user-select:none;-moz-user-select:none;user-select:none;-webkit-tap-highlight-color:transparent}.ol-viewport canvas{all:unset;overflow:hidden}.ol-viewport{touch-action:pan-x pan-y}.ol-selectable{-webkit-touch-callout:default;-webkit-user-select:text;-moz-user-select:text;user-select:text}.ol-grabbing{cursor:-webkit-grabbing;cursor:-moz-grabbing;cursor:grabbing}.ol-grab{cursor:move;cursor:-webkit-grab;cursor:-moz-grab;cursor:grab}.ol-control{position:absolute;background-color:var(--ol-subtle-background-color);border-radius:4px}.ol-zoom{top:.5em;left:.5em}.ol-rotate{top:.5em;right:.5em;transition:opacity .25s linear,visibility 0s linear}.ol-rotate.ol-hidden{opacity:0;visibility:hidden;transition:opacity .25s linear,visibility 0s linear .25s}.ol-zoom-extent{top:4.643em;left:.5em}.ol-full-screen{right:.5em;top:.5em}.ol-control button{display:block;margin:1px;padding:0;color:var(--ol-subtle-foreground-color);font-weight:700;text-decoration:none;font-size:inherit;text-align:center;height:1.375em;width:1.375em;line-height:.4em;background-color:var(--ol-background-color);border:none;border-radius:2px}.ol-control button::-moz-focus-inner{border:none;padding:0}.ol-zoom-extent button{line-height:1.4em}.ol-compass{display:block;font-weight:400;will-change:transform}.ol-touch .ol-control button{font-size:1.5em}.ol-touch .ol-zoom-extent{top:5.5em}.ol-control button:hover,.ol-control button:focus{text-decoration:none;outline:1px solid var(--ol-subtle-foreground-color);color:var(--ol-foreground-color)}.ol-zoom .ol-zoom-in{border-radius:2px 2px 0 0}.ol-zoom .ol-zoom-out{border-radius:0 0 2px 2px}.ol-attribution{text-align:right;bottom:.5em;right:.5em;max-width:calc(100% - 1.3em);display:flex;flex-flow:row-reverse;align-items:center}.ol-attribution a{color:var(--ol-subtle-foreground-color);text-decoration:none}.ol-attribution ul{margin:0;padding:1px .5em;color:var(--ol-foreground-color);text-shadow:0 0 2px var(--ol-background-color);font-size:12px}.ol-attribution li{display:inline;list-style:none}.ol-attribution li:not(:last-child):after{content:" "}.ol-attribution img{max-height:2em;max-width:inherit;vertical-align:middle}.ol-attribution button{flex-shrink:0}.ol-attribution.ol-collapsed ul{display:none}.ol-attribution:not(.ol-collapsed){background:var(--ol-partial-background-color)}.ol-attribution.ol-uncollapsible{bottom:0;right:0;border-radius:4px 0 0}.ol-attribution.ol-uncollapsible img{margin-top:-.2em;max-height:1.6em}.ol-attribution.ol-uncollapsible button{display:none}.ol-zoomslider{top:4.5em;left:.5em;height:200px}.ol-zoomslider button{position:relative;height:10px}.ol-touch .ol-zoomslider{top:5.5em}.ol-overviewmap{left:.5em;bottom:.5em}.ol-overviewmap.ol-uncollapsible{bottom:0;left:0;border-radius:0 4px 0 0}.ol-overviewmap .ol-overviewmap-map,.ol-overviewmap button{display:block}.ol-overviewmap .ol-overviewmap-map{border:1px solid var(--ol-subtle-foreground-color);height:150px;width:150px}.ol-overviewmap:not(.ol-collapsed) button{bottom:0;left:0;position:absolute}.ol-overviewmap.ol-collapsed .ol-overviewmap-map,.ol-overviewmap.ol-uncollapsible button{display:none}.ol-overviewmap:not(.ol-collapsed){background:var(--ol-subtle-background-color)}.ol-overviewmap-box{border:1.5px dotted var(--ol-subtle-foreground-color)}.ol-overviewmap .ol-overviewmap-box:hover{cursor:move}.ol-overviewmap .ol-viewport:hover{cursor:pointer}/*! tailwindcss v4.1.16 | MIT License | https://tailwindcss.com */@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-translate-x:0;--tw-translate-y:0;--tw-translate-z:0;--tw-rotate-x:initial;--tw-rotate-y:initial;--tw-rotate-z:initial;--tw-skew-x:initial;--tw-skew-y:initial;--tw-space-y-reverse:0;--tw-border-style:solid;--tw-leading:initial;--tw-font-weight:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000}}}@layer theme{:root,:host{--font-sans:ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";--font-mono:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;--color-red-500:oklch(63.7% .237 25.331);--color-red-600:oklch(57.7% .245 27.325);--color-green-600:oklch(62.7% .194 149.214);--color-blue-50:oklch(97% .014 254.604);--color-blue-100:oklch(93.2% .032 255.585);--color-blue-400:oklch(70.7% .165 254.624);--color-blue-500:oklch(62.3% .214 259.815);--color-blue-600:oklch(54.6% .245 262.881);--color-blue-700:oklch(48.8% .243 264.376);--color-indigo-500:oklch(58.5% .233 277.117);--color-zinc-50:oklch(98.5% 0 0);--color-zinc-100:oklch(96.7% .001 286.375);--color-zinc-200:oklch(92% .004 286.32);--color-zinc-300:oklch(87.1% .006 286.286);--color-zinc-400:oklch(70.5% .015 286.067);--color-zinc-500:oklch(55.2% .016 285.938);--color-zinc-600:oklch(44.2% .017 285.786);--color-zinc-700:oklch(37% .013 285.805);--color-zinc-800:oklch(27.4% .006 286.033);--color-zinc-900:oklch(21% .006 285.885);--color-white:#fff;--spacing:.25rem;--container-2xl:42rem;--container-3xl:48rem;--container-5xl:64rem;--container-6xl:72rem;--text-xs:.75rem;--text-xs--line-height:calc(1/.75);--text-sm:.875rem;--text-sm--line-height:calc(1.25/.875);--text-lg:1.125rem;--text-lg--line-height:calc(1.75/1.125);--text-xl:1.25rem;--text-xl--line-height:calc(1.75/1.25);--text-2xl:1.5rem;--text-2xl--line-height:calc(2/1.5);--text-3xl:1.875rem;--text-3xl--line-height: 1.2 ;--text-4xl:2.25rem;--text-4xl--line-height:calc(2.5/2.25);--text-6xl:3.75rem;--text-6xl--line-height:1;--font-weight-normal:400;--font-weight-medium:500;--font-weight-semibold:600;--font-weight-bold:700;--leading-relaxed:1.625;--radius-lg:.5rem;--animate-spin:spin 1s linear infinite;--default-transition-duration:.15s;--default-transition-timing-function:cubic-bezier(.4,0,.2,1);--default-font-family:var(--font-sans);--default-mono-font-family:var(--font-mono)}}@layer base{*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;tab-size:4;line-height:1.5;font-family:var(--default-font-family,ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-mono-font-family,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-variation-settings:var(--default-mono-font-variation-settings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring{outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab,red,red)){::placeholder{color:color-mix(in oklab,currentcolor 50%,transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit{padding-block:0}::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-month-field{padding-block:0}::-webkit-datetime-edit-day-field{padding-block:0}::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field{padding-block:0}::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-datetime-edit-meridiem-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){appearance:button}::file-selector-button{appearance:button}::-webkit-inner-spin-button{height:auto}::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}}@layer components;@layer utilities{.absolute{position:absolute}.fixed{position:fixed}.relative{position:relative}.inset-0{inset:calc(var(--spacing)*0)}.-top-4{top:calc(var(--spacing)*-4)}.right-6{right:calc(var(--spacing)*6)}.bottom-6{bottom:calc(var(--spacing)*6)}.left-1\\/2{left:50%}.z-2147483647{z-index:2147483647}.container{width:100%}@media(min-width:40rem){.container{max-width:40rem}}@media(min-width:48rem){.container{max-width:48rem}}@media(min-width:64rem){.container{max-width:64rem}}@media(min-width:80rem){.container{max-width:80rem}}@media(min-width:96rem){.container{max-width:96rem}}.mx-auto{margin-inline:auto}.mt-1{margin-top:calc(var(--spacing)*1)}.mt-2{margin-top:calc(var(--spacing)*2)}.mb-2{margin-bottom:calc(var(--spacing)*2)}.mb-3{margin-bottom:calc(var(--spacing)*3)}.mb-4{margin-bottom:calc(var(--spacing)*4)}.mb-6{margin-bottom:calc(var(--spacing)*6)}.mb-8{margin-bottom:calc(var(--spacing)*8)}.mb-16{margin-bottom:calc(var(--spacing)*16)}.block{display:block}.flex{display:flex}.grid{display:grid}.hidden{display:none}.h-3{height:calc(var(--spacing)*3)}.h-4{height:calc(var(--spacing)*4)}.h-5{height:calc(var(--spacing)*5)}.h-6{height:calc(var(--spacing)*6)}.h-8{height:calc(var(--spacing)*8)}.h-10{height:calc(var(--spacing)*10)}.h-12{height:calc(var(--spacing)*12)}.h-14{height:calc(var(--spacing)*14)}.h-32{height:calc(var(--spacing)*32)}.h-\\[600px\\]{height:600px}.max-h-80{max-height:calc(var(--spacing)*80)}.min-h-\\[180px\\]{min-height:180px}.min-h-screen{min-height:100vh}.w-3{width:calc(var(--spacing)*3)}.w-4{width:calc(var(--spacing)*4)}.w-5{width:calc(var(--spacing)*5)}.w-6{width:calc(var(--spacing)*6)}.w-8{width:calc(var(--spacing)*8)}.w-10{width:calc(var(--spacing)*10)}.w-12{width:calc(var(--spacing)*12)}.w-14{width:calc(var(--spacing)*14)}.w-96{width:calc(var(--spacing)*96)}.w-full{width:100%}.max-w-2xl{max-width:var(--container-2xl)}.max-w-3xl{max-width:var(--container-3xl)}.max-w-5xl{max-width:var(--container-5xl)}.max-w-6xl{max-width:var(--container-6xl)}.max-w-\\[75\\%\\]{max-width:75%}.max-w-full{max-width:100%}.min-w-0{min-width:calc(var(--spacing)*0)}.flex-1{flex:1}.flex-shrink-0,.shrink-0{flex-shrink:0}.-translate-x-1\\/2{--tw-translate-x: -50% ;translate:var(--tw-translate-x)var(--tw-translate-y)}.transform{transform:var(--tw-rotate-x,)var(--tw-rotate-y,)var(--tw-rotate-z,)var(--tw-skew-x,)var(--tw-skew-y,)}.animate-spin{animation:var(--animate-spin)}.flex-col{flex-direction:column}.items-center{align-items:center}.items-start{align-items:flex-start}.justify-between{justify-content:space-between}.justify-center{justify-content:center}.justify-end{justify-content:flex-end}.justify-start{justify-content:flex-start}.gap-0\\.5{gap:calc(var(--spacing)*.5)}.gap-1{gap:calc(var(--spacing)*1)}.gap-2{gap:calc(var(--spacing)*2)}.gap-3{gap:calc(var(--spacing)*3)}.gap-4{gap:calc(var(--spacing)*4)}.gap-6{gap:calc(var(--spacing)*6)}.gap-8{gap:calc(var(--spacing)*8)}:where(.space-y-2>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*2)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*2)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-3>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*3)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*3)*calc(1 - var(--tw-space-y-reverse)))}.truncate{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.overflow-hidden{overflow:hidden}.overflow-y-auto{overflow-y:auto}.rounded{border-radius:.25rem}.rounded-full{border-radius:3.40282e38px}.rounded-lg{border-radius:var(--radius-lg)}.border{border-style:var(--tw-border-style);border-width:1px}.border-2{border-style:var(--tw-border-style);border-width:2px}.border-t{border-top-style:var(--tw-border-style);border-top-width:1px}.border-b{border-bottom-style:var(--tw-border-style);border-bottom-width:1px}.border-blue-400{border-color:var(--color-blue-400)}.border-blue-600{border-color:var(--color-blue-600)}.border-zinc-200{border-color:var(--color-zinc-200)}.border-zinc-300{border-color:var(--color-zinc-300)}.border-t-transparent{border-top-color:#0000}.bg-blue-500{background-color:var(--color-blue-500)}.bg-blue-600{background-color:var(--color-blue-600)}.bg-white{background-color:var(--color-white)}.bg-zinc-50{background-color:var(--color-zinc-50)}.bg-zinc-100{background-color:var(--color-zinc-100)}.bg-zinc-900{background-color:var(--color-zinc-900)}.object-contain{object-fit:contain}.p-1{padding:calc(var(--spacing)*1)}.p-2{padding:calc(var(--spacing)*2)}.p-3{padding:calc(var(--spacing)*3)}.p-4{padding:calc(var(--spacing)*4)}.p-6{padding:calc(var(--spacing)*6)}.p-8{padding:calc(var(--spacing)*8)}.px-2{padding-inline:calc(var(--spacing)*2)}.px-3{padding-inline:calc(var(--spacing)*3)}.px-4{padding-inline:calc(var(--spacing)*4)}.px-6{padding-inline:calc(var(--spacing)*6)}.px-8{padding-inline:calc(var(--spacing)*8)}.py-1{padding-block:calc(var(--spacing)*1)}.py-2{padding-block:calc(var(--spacing)*2)}.py-3{padding-block:calc(var(--spacing)*3)}.py-4{padding-block:calc(var(--spacing)*4)}.py-12{padding-block:calc(var(--spacing)*12)}.py-20{padding-block:calc(var(--spacing)*20)}.pt-2{padding-top:calc(var(--spacing)*2)}.pb-3{padding-bottom:calc(var(--spacing)*3)}.text-center{text-align:center}.text-left{text-align:left}.font-sans{font-family:var(--font-sans)}.text-2xl{font-size:var(--text-2xl);line-height:var(--tw-leading,var(--text-2xl--line-height))}.text-3xl{font-size:var(--text-3xl);line-height:var(--tw-leading,var(--text-3xl--line-height))}.text-4xl{font-size:var(--text-4xl);line-height:var(--tw-leading,var(--text-4xl--line-height))}.text-lg{font-size:var(--text-lg);line-height:var(--tw-leading,var(--text-lg--line-height))}.text-sm{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.text-xl{font-size:var(--text-xl);line-height:var(--tw-leading,var(--text-xl--line-height))}.text-xs{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}.leading-relaxed{--tw-leading:var(--leading-relaxed);line-height:var(--leading-relaxed)}.font-bold{--tw-font-weight:var(--font-weight-bold);font-weight:var(--font-weight-bold)}.font-medium{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.font-normal{--tw-font-weight:var(--font-weight-normal);font-weight:var(--font-weight-normal)}.font-semibold{--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.wrap-break-word{overflow-wrap:break-word}.text-blue-100{color:var(--color-blue-100)}.text-blue-500{color:var(--color-blue-500)}.text-blue-600{color:var(--color-blue-600)}.text-green-600{color:var(--color-green-600)}.text-indigo-500{color:var(--color-indigo-500)}.text-red-500{color:var(--color-red-500)}.text-red-600{color:var(--color-red-600)}.text-white{color:var(--color-white)}.text-zinc-300{color:var(--color-zinc-300)}.text-zinc-400{color:var(--color-zinc-400)}.text-zinc-500{color:var(--color-zinc-500)}.text-zinc-600{color:var(--color-zinc-600)}.text-zinc-700{color:var(--color-zinc-700)}.text-zinc-900{color:var(--color-zinc-900)}.opacity-25{opacity:.25}.opacity-75{opacity:.75}.shadow-\\[0_0_20px_rgba\\(0\\,0\\,0\\,0\\.15\\)\\]{--tw-shadow:0 0 20px var(--tw-shadow-color,#00000026);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-lg{--tw-shadow:0 10px 15px -3px var(--tw-shadow-color,#0000001a),0 4px 6px -4px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.transition-all{transition-property:all;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-colors{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.placeholder\\:text-zinc-300::placeholder{color:var(--color-zinc-300)}@media(hover:hover){.hover\\:border-blue-500:hover{border-color:var(--color-blue-500)}.hover\\:bg-blue-50:hover{background-color:var(--color-blue-50)}.hover\\:bg-blue-500:hover{background-color:var(--color-blue-500)}.hover\\:bg-blue-700:hover{background-color:var(--color-blue-700)}.hover\\:bg-white\\/20:hover{background-color:#fff3}@supports (color:color-mix(in lab,red,red)){.hover\\:bg-white\\/20:hover{background-color:color-mix(in oklab,var(--color-white)20%,transparent)}}.hover\\:bg-zinc-50:hover{background-color:var(--color-zinc-50)}.hover\\:bg-zinc-100:hover{background-color:var(--color-zinc-100)}.hover\\:bg-zinc-800:hover{background-color:var(--color-zinc-800)}.hover\\:text-zinc-900:hover{color:var(--color-zinc-900)}}.focus\\:ring-2:focus{--tw-ring-shadow:var(--tw-ring-inset,)0 0 0 calc(2px + var(--tw-ring-offset-width))var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.focus\\:ring-blue-500:focus{--tw-ring-color:var(--color-blue-500)}.focus\\:outline-none:focus{--tw-outline-style:none;outline-style:none}.disabled\\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\\:opacity-50:disabled{opacity:.5}@media(min-width:40rem){.sm\\:flex{display:flex}.sm\\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.sm\\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.sm\\:flex-row{flex-direction:row}.sm\\:px-6{padding-inline:calc(var(--spacing)*6)}.sm\\:py-32{padding-block:calc(var(--spacing)*32)}.sm\\:text-4xl{font-size:var(--text-4xl);line-height:var(--tw-leading,var(--text-4xl--line-height))}.sm\\:text-6xl{font-size:var(--text-6xl);line-height:var(--tw-leading,var(--text-6xl--line-height))}.sm\\:text-xl{font-size:var(--text-xl);line-height:var(--tw-leading,var(--text-xl--line-height))}}@media(min-width:64rem){.lg\\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}}}*{box-sizing:border-box;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,sans-serif}@media(max-width:640px){#__converge-chat-widget>div>div:last-child{width:calc(100vw - 2rem)!important;height:calc(100vh - 2rem)!important;bottom:1rem!important;right:1rem!important}}@property --tw-translate-x{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-y{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-z{syntax:"*";inherits:false;initial-value:0}@property --tw-rotate-x{syntax:"*";inherits:false}@property --tw-rotate-y{syntax:"*";inherits:false}@property --tw-rotate-z{syntax:"*";inherits:false}@property --tw-skew-x{syntax:"*";inherits:false}@property --tw-skew-y{syntax:"*";inherits:false}@property --tw-space-y-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-leading{syntax:"*";inherits:false}@property --tw-font-weight{syntax:"*";inherits:false}@property --tw-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:"*";inherits:false}@property --tw-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:"*";inherits:false}@property --tw-inset-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:"*";inherits:false}@property --tw-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:"*";inherits:false}@property --tw-inset-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:"*";inherits:false}@property --tw-ring-offset-width{syntax:"<length>";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:"*";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@keyframes spin{to{transform:rotate(360deg)}}')),document.head.appendChild(o)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}})();
|
|
2
|
+
(function(Ge){typeof define=="function"&&define.amd?define(Ge):Ge()})((function(){"use strict";var Ge,st,Eo,We,wo,vo,Co,Ro,bs,Ms,Ls,So,Ni={},Io=[],Mh=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,bn=Array.isArray;function he(n,t){for(var e in t)n[e]=t[e];return n}function As(n){n&&n.parentNode&&n.parentNode.removeChild(n)}function Lh(n,t,e){var i,s,r,o={};for(r in t)r=="key"?i=t[r]:r=="ref"?s=t[r]:o[r]=t[r];if(arguments.length>2&&(o.children=arguments.length>3?Ge.call(arguments,2):e),typeof n=="function"&&n.defaultProps!=null)for(r in n.defaultProps)o[r]===void 0&&(o[r]=n.defaultProps[r]);return Mn(n,o,i,s,null)}function Mn(n,t,e,i,s){var r={type:n,props:t,key:e,ref:i,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:s??++Eo,__i:-1,__u:0};return s==null&&st.vnode!=null&&st.vnode(r),r}function zi(n){return n.children}function Ln(n,t){this.props=n,this.context=t}function si(n,t){if(t==null)return n.__?si(n.__,n.__i+1):null;for(var e;t<n.__k.length;t++)if((e=n.__k[t])!=null&&e.__e!=null)return e.__e;return typeof n.type=="function"?si(n):null}function To(n){var t,e;if((n=n.__)!=null&&n.__c!=null){for(n.__e=n.__c.base=null,t=0;t<n.__k.length;t++)if((e=n.__k[t])!=null&&e.__e!=null){n.__e=n.__c.base=e.__e;break}return To(n)}}function Os(n){(!n.__d&&(n.__d=!0)&&We.push(n)&&!An.__r++||wo!=st.debounceRendering)&&((wo=st.debounceRendering)||vo)(An)}function An(){for(var n,t,e,i,s,r,o,a=1;We.length;)We.length>a&&We.sort(Co),n=We.shift(),a=We.length,n.__d&&(e=void 0,i=void 0,s=(i=(t=n).__v).__e,r=[],o=[],t.__P&&((e=he({},i)).__v=i.__v+1,st.vnode&&st.vnode(e),Ps(t.__P,e,i,t.__n,t.__P.namespaceURI,32&i.__u?[s]:null,r,s??si(i),!!(32&i.__u),o),e.__v=i.__v,e.__.__k[e.__i]=e,Oo(r,e,o),i.__e=i.__=null,e.__e!=s&&To(e)));An.__r=0}function bo(n,t,e,i,s,r,o,a,l,h,c){var u,d,f,g,m,_,p,y=i&&i.__k||Io,v=t.length;for(l=Ah(e,t,y,l,v),u=0;u<v;u++)(f=e.__k[u])!=null&&(d=f.__i==-1?Ni:y[f.__i]||Ni,f.__i=u,_=Ps(n,f,d,s,r,o,a,l,h,c),g=f.__e,f.ref&&d.ref!=f.ref&&(d.ref&&ks(d.ref,null,f),c.push(f.ref,f.__c||g,f)),m==null&&g!=null&&(m=g),(p=!!(4&f.__u))||d.__k===f.__k?l=Mo(f,l,n,p):typeof f.type=="function"&&_!==void 0?l=_:g&&(l=g.nextSibling),f.__u&=-7);return e.__e=m,l}function Ah(n,t,e,i,s){var r,o,a,l,h,c=e.length,u=c,d=0;for(n.__k=new Array(s),r=0;r<s;r++)(o=t[r])!=null&&typeof o!="boolean"&&typeof o!="function"?(l=r+d,(o=n.__k[r]=typeof o=="string"||typeof o=="number"||typeof o=="bigint"||o.constructor==String?Mn(null,o,null,null,null):bn(o)?Mn(zi,{children:o},null,null,null):o.constructor==null&&o.__b>0?Mn(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):o).__=n,o.__b=n.__b+1,a=null,(h=o.__i=Oh(o,e,l,u))!=-1&&(u--,(a=e[h])&&(a.__u|=2)),a==null||a.__v==null?(h==-1&&(s>c?d--:s<c&&d++),typeof o.type!="function"&&(o.__u|=4)):h!=l&&(h==l-1?d--:h==l+1?d++:(h>l?d--:d++,o.__u|=4))):n.__k[r]=null;if(u)for(r=0;r<c;r++)(a=e[r])!=null&&(2&a.__u)==0&&(a.__e==i&&(i=si(a)),Do(a,a));return i}function Mo(n,t,e,i){var s,r;if(typeof n.type=="function"){for(s=n.__k,r=0;s&&r<s.length;r++)s[r]&&(s[r].__=n,t=Mo(s[r],t,e,i));return t}n.__e!=t&&(i&&(t&&n.type&&!t.parentNode&&(t=si(n)),e.insertBefore(n.__e,t||null)),t=n.__e);do t=t&&t.nextSibling;while(t!=null&&t.nodeType==8);return t}function Oh(n,t,e,i){var s,r,o,a=n.key,l=n.type,h=t[e],c=h!=null&&(2&h.__u)==0;if(h===null&&n.key==null||c&&a==h.key&&l==h.type)return e;if(i>(c?1:0)){for(s=e-1,r=e+1;s>=0||r<t.length;)if((h=t[o=s>=0?s--:r++])!=null&&(2&h.__u)==0&&a==h.key&&l==h.type)return o}return-1}function Lo(n,t,e){t[0]=="-"?n.setProperty(t,e??""):n[t]=e==null?"":typeof e!="number"||Mh.test(t)?e:e+"px"}function On(n,t,e,i,s){var r,o;t:if(t=="style")if(typeof e=="string")n.style.cssText=e;else{if(typeof i=="string"&&(n.style.cssText=i=""),i)for(t in i)e&&t in e||Lo(n.style,t,"");if(e)for(t in e)i&&e[t]==i[t]||Lo(n.style,t,e[t])}else if(t[0]=="o"&&t[1]=="n")r=t!=(t=t.replace(Ro,"$1")),o=t.toLowerCase(),t=o in n||t=="onFocusOut"||t=="onFocusIn"?o.slice(2):t.slice(2),n.l||(n.l={}),n.l[t+r]=e,e?i?e.u=i.u:(e.u=bs,n.addEventListener(t,r?Ls:Ms,r)):n.removeEventListener(t,r?Ls:Ms,r);else{if(s=="http://www.w3.org/2000/svg")t=t.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(t!="width"&&t!="height"&&t!="href"&&t!="list"&&t!="form"&&t!="tabIndex"&&t!="download"&&t!="rowSpan"&&t!="colSpan"&&t!="role"&&t!="popover"&&t in n)try{n[t]=e??"";break t}catch{}typeof e=="function"||(e==null||e===!1&&t[4]!="-"?n.removeAttribute(t):n.setAttribute(t,t=="popover"&&e==1?"":e))}}function Ao(n){return function(t){if(this.l){var e=this.l[t.type+n];if(t.t==null)t.t=bs++;else if(t.t<e.u)return;return e(st.event?st.event(t):t)}}}function Ps(n,t,e,i,s,r,o,a,l,h){var c,u,d,f,g,m,_,p,y,v,x,w,R,T,S,I,M,O=t.type;if(t.constructor!=null)return null;128&e.__u&&(l=!!(32&e.__u),r=[a=t.__e=e.__e]),(c=st.__b)&&c(t);t:if(typeof O=="function")try{if(p=t.props,y="prototype"in O&&O.prototype.render,v=(c=O.contextType)&&i[c.__c],x=c?v?v.props.value:c.__:i,e.__c?_=(u=t.__c=e.__c).__=u.__E:(y?t.__c=u=new O(p,x):(t.__c=u=new Ln(p,x),u.constructor=O,u.render=Dh),v&&v.sub(u),u.props=p,u.state||(u.state={}),u.context=x,u.__n=i,d=u.__d=!0,u.__h=[],u._sb=[]),y&&u.__s==null&&(u.__s=u.state),y&&O.getDerivedStateFromProps!=null&&(u.__s==u.state&&(u.__s=he({},u.__s)),he(u.__s,O.getDerivedStateFromProps(p,u.__s))),f=u.props,g=u.state,u.__v=t,d)y&&O.getDerivedStateFromProps==null&&u.componentWillMount!=null&&u.componentWillMount(),y&&u.componentDidMount!=null&&u.__h.push(u.componentDidMount);else{if(y&&O.getDerivedStateFromProps==null&&p!==f&&u.componentWillReceiveProps!=null&&u.componentWillReceiveProps(p,x),!u.__e&&u.shouldComponentUpdate!=null&&u.shouldComponentUpdate(p,u.__s,x)===!1||t.__v==e.__v){for(t.__v!=e.__v&&(u.props=p,u.state=u.__s,u.__d=!1),t.__e=e.__e,t.__k=e.__k,t.__k.some(function(L){L&&(L.__=t)}),w=0;w<u._sb.length;w++)u.__h.push(u._sb[w]);u._sb=[],u.__h.length&&o.push(u);break t}u.componentWillUpdate!=null&&u.componentWillUpdate(p,u.__s,x),y&&u.componentDidUpdate!=null&&u.__h.push(function(){u.componentDidUpdate(f,g,m)})}if(u.context=x,u.props=p,u.__P=n,u.__e=!1,R=st.__r,T=0,y){for(u.state=u.__s,u.__d=!1,R&&R(t),c=u.render(u.props,u.state,u.context),S=0;S<u._sb.length;S++)u.__h.push(u._sb[S]);u._sb=[]}else do u.__d=!1,R&&R(t),c=u.render(u.props,u.state,u.context),u.state=u.__s;while(u.__d&&++T<25);u.state=u.__s,u.getChildContext!=null&&(i=he(he({},i),u.getChildContext())),y&&!d&&u.getSnapshotBeforeUpdate!=null&&(m=u.getSnapshotBeforeUpdate(f,g)),I=c,c!=null&&c.type===zi&&c.key==null&&(I=Po(c.props.children)),a=bo(n,bn(I)?I:[I],t,e,i,s,r,o,a,l,h),u.base=t.__e,t.__u&=-161,u.__h.length&&o.push(u),_&&(u.__E=u.__=null)}catch(L){if(t.__v=null,l||r!=null)if(L.then){for(t.__u|=l?160:128;a&&a.nodeType==8&&a.nextSibling;)a=a.nextSibling;r[r.indexOf(a)]=null,t.__e=a}else{for(M=r.length;M--;)As(r[M]);Ds(t)}else t.__e=e.__e,t.__k=e.__k,L.then||Ds(t);st.__e(L,t,e)}else r==null&&t.__v==e.__v?(t.__k=e.__k,t.__e=e.__e):a=t.__e=Ph(e.__e,t,e,i,s,r,o,l,h);return(c=st.diffed)&&c(t),128&t.__u?void 0:a}function Ds(n){n&&n.__c&&(n.__c.__e=!0),n&&n.__k&&n.__k.forEach(Ds)}function Oo(n,t,e){for(var i=0;i<e.length;i++)ks(e[i],e[++i],e[++i]);st.__c&&st.__c(t,n),n.some(function(s){try{n=s.__h,s.__h=[],n.some(function(r){r.call(s)})}catch(r){st.__e(r,s.__v)}})}function Po(n){return typeof n!="object"||n==null||n.__b&&n.__b>0?n:bn(n)?n.map(Po):he({},n)}function Ph(n,t,e,i,s,r,o,a,l){var h,c,u,d,f,g,m,_=e.props,p=t.props,y=t.type;if(y=="svg"?s="http://www.w3.org/2000/svg":y=="math"?s="http://www.w3.org/1998/Math/MathML":s||(s="http://www.w3.org/1999/xhtml"),r!=null){for(h=0;h<r.length;h++)if((f=r[h])&&"setAttribute"in f==!!y&&(y?f.localName==y:f.nodeType==3)){n=f,r[h]=null;break}}if(n==null){if(y==null)return document.createTextNode(p);n=document.createElementNS(s,y,p.is&&p),a&&(st.__m&&st.__m(t,r),a=!1),r=null}if(y==null)_===p||a&&n.data==p||(n.data=p);else{if(r=r&&Ge.call(n.childNodes),_=e.props||Ni,!a&&r!=null)for(_={},h=0;h<n.attributes.length;h++)_[(f=n.attributes[h]).name]=f.value;for(h in _)if(f=_[h],h!="children"){if(h=="dangerouslySetInnerHTML")u=f;else if(!(h in p)){if(h=="value"&&"defaultValue"in p||h=="checked"&&"defaultChecked"in p)continue;On(n,h,null,f,s)}}for(h in p)f=p[h],h=="children"?d=f:h=="dangerouslySetInnerHTML"?c=f:h=="value"?g=f:h=="checked"?m=f:a&&typeof f!="function"||_[h]===f||On(n,h,f,_[h],s);if(c)a||u&&(c.__html==u.__html||c.__html==n.innerHTML)||(n.innerHTML=c.__html),t.__k=[];else if(u&&(n.innerHTML=""),bo(t.type=="template"?n.content:n,bn(d)?d:[d],t,e,i,y=="foreignObject"?"http://www.w3.org/1999/xhtml":s,r,o,r?r[0]:e.__k&&si(e,0),a,l),r!=null)for(h=r.length;h--;)As(r[h]);a||(h="value",y=="progress"&&g==null?n.removeAttribute("value"):g!=null&&(g!==n[h]||y=="progress"&&!g||y=="option"&&g!=_[h])&&On(n,h,g,_[h],s),h="checked",m!=null&&m!=n[h]&&On(n,h,m,_[h],s))}return n}function ks(n,t,e){try{if(typeof n=="function"){var i=typeof n.__u=="function";i&&n.__u(),i&&t==null||(n.__u=n(t))}else n.current=t}catch(s){st.__e(s,e)}}function Do(n,t,e){var i,s;if(st.unmount&&st.unmount(n),(i=n.ref)&&(i.current&&i.current!=n.__e||ks(i,null,t)),(i=n.__c)!=null){if(i.componentWillUnmount)try{i.componentWillUnmount()}catch(r){st.__e(r,t)}i.base=i.__P=null}if(i=n.__k)for(s=0;s<i.length;s++)i[s]&&Do(i[s],t,e||typeof n.type!="function");e||As(n.__e),n.__c=n.__=n.__e=void 0}function Dh(n,t,e){return this.constructor(n,e)}function kh(n,t,e){var i,s,r,o;t==document&&(t=document.documentElement),st.__&&st.__(n,t),s=(i=!1)?null:t.__k,r=[],o=[],Ps(t,n=t.__k=Lh(zi,null,[n]),s||Ni,Ni,t.namespaceURI,s?null:t.firstChild?Ge.call(t.childNodes):null,r,s?s.__e:t.firstChild,i,o),Oo(r,n,o)}function Fh(n){function t(e){var i,s;return this.getChildContext||(i=new Set,(s={})[t.__c]=this,this.getChildContext=function(){return s},this.componentWillUnmount=function(){i=null},this.shouldComponentUpdate=function(r){this.props.value!=r.value&&i.forEach(function(o){o.__e=!0,Os(o)})},this.sub=function(r){i.add(r);var o=r.componentWillUnmount;r.componentWillUnmount=function(){i&&i.delete(r),o&&o.call(r)}}),e.children}return t.__c="__cC"+So++,t.__=n,t.Provider=t.__l=(t.Consumer=function(e,i){return e.children(i)}).contextType=t,t}Ge=Io.slice,st={__e:function(n,t,e,i){for(var s,r,o;t=t.__;)if((s=t.__c)&&!s.__)try{if((r=s.constructor)&&r.getDerivedStateFromError!=null&&(s.setState(r.getDerivedStateFromError(n)),o=s.__d),s.componentDidCatch!=null&&(s.componentDidCatch(n,i||{}),o=s.__d),o)return s.__E=s}catch(a){n=a}throw n}},Eo=0,Ln.prototype.setState=function(n,t){var e;e=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=he({},this.state),typeof n=="function"&&(n=n(he({},e),this.props)),n&&he(e,n),n!=null&&this.__v&&(t&&this._sb.push(t),Os(this))},Ln.prototype.forceUpdate=function(n){this.__v&&(this.__e=!0,n&&this.__h.push(n),Os(this))},Ln.prototype.render=zi,We=[],vo=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,Co=function(n,t){return n.__v.__b-t.__v.__b},An.__r=0,Ro=/(PointerCapture)$|Capture$/i,bs=0,Ms=Ao(!1),Ls=Ao(!0),So=0;var Nh=0;function E(n,t,e,i,s,r){t||(t={});var o,a,l=t;if("ref"in l)for(a in l={},t)a=="ref"?o=t[a]:l[a]=t[a];var h={type:n,props:l,key:e,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--Nh,__i:-1,__u:0,__source:s,__self:r};if(typeof n=="function"&&(o=n.defaultProps))for(a in o)l[a]===void 0&&(l[a]=o[a]);return st.vnode&&st.vnode(h),h}var Xe,ot,Fs,ko,Gi=0,Fo=[],dt=st,No=dt.__b,zo=dt.__r,Go=dt.diffed,Wo=dt.__c,Xo=dt.unmount,Yo=dt.__;function Wi(n,t){dt.__h&&dt.__h(ot,n,Gi||t),Gi=0;var e=ot.__H||(ot.__H={__:[],__h:[]});return n>=e.__.length&&e.__.push({}),e.__[n]}function vt(n){return Gi=1,Bo(jo,n)}function Bo(n,t,e){var i=Wi(Xe++,2);if(i.t=n,!i.__c&&(i.__=[jo(void 0,t),function(a){var l=i.__N?i.__N[0]:i.__[0],h=i.t(l,a);l!==h&&(i.__N=[h,i.__[1]],i.__c.setState({}))}],i.__c=ot,!ot.__f)){var s=function(a,l,h){if(!i.__c.__H)return!0;var c=i.__c.__H.__.filter(function(d){return!!d.__c});if(c.every(function(d){return!d.__N}))return!r||r.call(this,a,l,h);var u=i.__c.props!==a;return c.forEach(function(d){if(d.__N){var f=d.__[0];d.__=d.__N,d.__N=void 0,f!==d.__[0]&&(u=!0)}}),r&&r.call(this,a,l,h)||u};ot.__f=!0;var r=ot.shouldComponentUpdate,o=ot.componentWillUpdate;ot.componentWillUpdate=function(a,l,h){if(this.__e){var c=r;r=void 0,s(a,l,h),r=c}o&&o.call(this,a,l,h)},ot.shouldComponentUpdate=s}return i.__N||i.__}function ee(n,t){var e=Wi(Xe++,3);!dt.__s&&zs(e.__H,t)&&(e.__=n,e.u=t,ot.__H.__h.push(e))}function zh(n,t){var e=Wi(Xe++,4);!dt.__s&&zs(e.__H,t)&&(e.__=n,e.u=t,ot.__h.push(e))}function Xi(n){return Gi=5,Uo(function(){return{current:n}},[])}function Uo(n,t){var e=Wi(Xe++,7);return zs(e.__H,t)&&(e.__=n(),e.__H=t,e.__h=n),e.__}function At(n,t){return Gi=8,Uo(function(){return n},t)}function Gh(n){var t=ot.context[n.__c],e=Wi(Xe++,9);return e.c=n,t?(e.__==null&&(e.__=!0,t.sub(ot)),t.props.value):n.__}function Wh(){for(var n;n=Fo.shift();)if(n.__P&&n.__H)try{n.__H.__h.forEach(Pn),n.__H.__h.forEach(Ns),n.__H.__h=[]}catch(t){n.__H.__h=[],dt.__e(t,n.__v)}}dt.__b=function(n){ot=null,No&&No(n)},dt.__=function(n,t){n&&t.__k&&t.__k.__m&&(n.__m=t.__k.__m),Yo&&Yo(n,t)},dt.__r=function(n){zo&&zo(n),Xe=0;var t=(ot=n.__c).__H;t&&(Fs===ot?(t.__h=[],ot.__h=[],t.__.forEach(function(e){e.__N&&(e.__=e.__N),e.u=e.__N=void 0})):(t.__h.forEach(Pn),t.__h.forEach(Ns),t.__h=[],Xe=0)),Fs=ot},dt.diffed=function(n){Go&&Go(n);var t=n.__c;t&&t.__H&&(t.__H.__h.length&&(Fo.push(t)!==1&&ko===dt.requestAnimationFrame||((ko=dt.requestAnimationFrame)||Xh)(Wh)),t.__H.__.forEach(function(e){e.u&&(e.__H=e.u),e.u=void 0})),Fs=ot=null},dt.__c=function(n,t){t.some(function(e){try{e.__h.forEach(Pn),e.__h=e.__h.filter(function(i){return!i.__||Ns(i)})}catch(i){t.some(function(s){s.__h&&(s.__h=[])}),t=[],dt.__e(i,e.__v)}}),Wo&&Wo(n,t)},dt.unmount=function(n){Xo&&Xo(n);var t,e=n.__c;e&&e.__H&&(e.__H.__.forEach(function(i){try{Pn(i)}catch(s){t=s}}),e.__H=void 0,t&&dt.__e(t,e.__v))};var Ko=typeof requestAnimationFrame=="function";function Xh(n){var t,e=function(){clearTimeout(i),Ko&&cancelAnimationFrame(t),setTimeout(n)},i=setTimeout(e,35);Ko&&(t=requestAnimationFrame(e))}function Pn(n){var t=ot,e=n.__c;typeof e=="function"&&(n.__c=void 0,e()),ot=t}function Ns(n){var t=ot;n.__c=n.__(),ot=t}function zs(n,t){return!n||n.length!==t.length||t.some(function(e,i){return e!==n[i]})}function jo(n,t){return typeof t=="function"?t(n):t}const Gs="converge_widget_",ie={get(n,t){try{const e=localStorage.getItem(Gs+n);return e?JSON.parse(e):t}catch{return t}},set(n,t){try{localStorage.setItem(Gs+n,JSON.stringify(t))}catch(e){console.error("Failed to save to localStorage:",e)}},remove(n){try{localStorage.removeItem(Gs+n)}catch(t){console.error("Failed to remove from localStorage:",t)}}};function Yh(n){const t={id:n.id,isSupport:n.from==="agent",timestamp:n.timestamp},e=n.messageType||"text";if(e==="location")try{const i=JSON.parse(n.content);return{...t,type:"location",latitude:i.latitude,longitude:i.longitude,name:i.name,address:i.address}}catch{return{...t,type:"text",content:n.content}}return e==="photo"?{...t,type:"photo",url:n.contentUrl||"",filename:n.fileName||void 0,size:n.fileSize||void 0,content:n.content}:e==="video"?{...t,type:"video",url:n.contentUrl||"",filename:n.fileName||void 0,size:n.fileSize||void 0,content:n.content}:e==="file"?{...t,type:"file",url:n.contentUrl||"",filename:n.fileName||"file",size:n.fileSize||void 0,mimeType:n.mimeType||void 0}:{...t,type:"text",content:n.content}}const Vo=Fh(null);function Bh({children:n,config:t}){const[e]=vt(!1),[i,s]=vt(!1),[r,o]=vt(""),[a,l]=vt(ie.get("token","")),[h,c]=vt(!1),[u,d]=vt(ie.get("name","")),[f,g]=vt(ie.get("email","")),[m,_]=vt(ie.get("customer_id","")),[p,y]=vt(!1),[v,x]=vt(!0),[w,R]=vt([]),[T,S]=vt(ie.get("platform","")),[I,M]=vt(!1),[O,L]=vt(!1),[A,P]=vt([]),X=Xi(),k=Xi(void 0);ee(()=>{ie.set("token",a)},[a]),ee(()=>{ie.set("name",u)},[u]),ee(()=>{ie.set("email",f)},[f]),ee(()=>{ie.set("customer_id",m)},[m]),ee(()=>{ie.set("platform",T)},[T]);const G=At(async()=>{if(console.log("session token?"),!!a){console.log("Yes");try{const W=k.current?`${t.apiUrl}/messages?since=${encodeURIComponent(k.current)}`:`${t.apiUrl}/messages`;console.log("fetching");const rt=await fetch(W,{headers:{Authorization:`Bearer ${a}`}});if(console.log("Fetched"),!rt.ok)throw new Error("Failed to poll messages");console.log("parsing");const j=await rt.json();if(j.messages&&j.messages.length>0){console.log("setting");const nt=j.messages.map(Yh);P(mt=>[...mt,...nt]),k.current=nt[nt.length-1].timestamp}}catch(W){console.error("Failed to poll messages:",W)}finally{console.log("finally"),X.current=setTimeout(G,1e3)}}},[a,t.apiUrl]),D=At(()=>{X.current||!a||G()},[a,G]),Y=At(async()=>{try{const W=await fetch(`${t.apiUrl}/platforms`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:t.apiKey})});if(!W.ok)throw new Error("Failed to fetch platforms");const rt=await W.json();R(rt.platforms||[])}catch(W){console.error("Failed to fetch platforms:",W),R([{type:"widget",name:"Website Chat"}])}},[t.apiUrl,t.apiKey]);ee(()=>((async()=>{a&&T==="widget"?(D(),c(!0),x(!1)):await Y()})(),()=>{X.current&&clearTimeout(X.current)}),[a]);const V=At(async(W,rt)=>{if(!W.trim())return;const j=m||`widget_${Date.now()}_${Math.random().toString(36).substring(2,15)}`;try{const nt=await fetch(`${t.apiUrl}/init`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:t.apiKey,customerId:j,customerName:W,customerEmail:rt||void 0})});if(!nt.ok)throw new Error("Failed to initialize");const mt=await nt.json();l(mt.token),_(j),d(W),g(rt||""),S("widget"),c(!0),y(!1),D()}catch(nt){console.error("Widget initialization failed:",nt)}},[m,t.apiUrl,t.apiKey,D]),tt=At(W=>{W.type==="widget"?(S(W.type),x(!1),y(!a||!u),c(!!(a&&u))):W.link&&(window.open(W.link,"_blank"),s(!1))},[a,u]),b=At(()=>{y(!1),x(!0),c(!1)},[]),xt=At(async()=>{if(!r.trim()||!a||I)return;const W=r.trim();o(""),M(!0);try{const rt={type:"text",content:W};if(!(await fetch(`${t.apiUrl}/message`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`},body:JSON.stringify(rt)})).ok)throw new Error("Failed to send message")}catch(rt){console.error("Failed to send message:",rt),o(W)}finally{M(!1)}},[r,a,I,t.apiUrl]),ft=At(async(W,rt)=>{if(!(!a||I)){M(!0);try{const j=new FormData;if(j.append("file",rt),j.append("messageData",JSON.stringify(W)),!(await fetch(`${t.apiUrl}/message`,{method:"POST",headers:{Authorization:`Bearer ${a}`},body:j})).ok)throw new Error("Failed to send attachment")}catch(j){console.error("Failed to send attachment:",j)}finally{M(!1)}}},[a,I,t.apiUrl]),ht=At(()=>{const W=document.createElement("input");W.type="file",W.accept="image/*,video/*",W.onchange=async rt=>{const j=rt.target.files?.[0];if(!j)return;const nt=10*1024*1024;if(j.size>nt){alert("File size must be less than 10MB");return}const ze=j.type.startsWith("video/")?{type:"video",filename:j.name,size:j.size}:{type:"photo",filename:j.name,size:j.size};await ft(ze,j)},W.click(),L(!1)},[ft]),bt=At(()=>{const W=document.createElement("input");W.type="file",W.accept=".pdf,.doc,.docx,.xls,.xlsx,.txt,.zip,.rar",W.onchange=async rt=>{const j=rt.target.files?.[0];if(!j)return;const nt=10*1024*1024;if(j.size>nt){alert("File size must be less than 10MB");return}const mt={type:"file",filename:j.name,size:j.size,mimeType:j.type};await ft(mt,j)},W.click(),L(!1)},[ft]),Et=At(async()=>{if(L(!1),!navigator.geolocation){console.error("Geolocation is not supported");return}if(!I){M(!0);try{const W=await new Promise((nt,mt)=>{navigator.geolocation.getCurrentPosition(nt,mt)}),rt={type:"location",latitude:W.coords.latitude,longitude:W.coords.longitude};if(!(await fetch(`${t.apiUrl}/message`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`},body:JSON.stringify(rt)})).ok)throw new Error("Failed to send location")}catch(W){console.error("Failed to send location:",W)}finally{M(!1)}}},[I,a,t.apiUrl]),jt=At(()=>{s(W=>!W)},[]),Gt=At(()=>{L(W=>!W)},[]),Mt=At(()=>{L(!1)},[]),Pi={config:t,isOpen:i,inputMessage:r,sessionToken:a,isInitialized:h,customerName:u,customerEmail:f,customerId:m,showNamePrompt:p,showPlatformChoice:v,availablePlatforms:w,selectedPlatform:T,isSending:I,showAttachmentMenu:O,messages:A,setInputMessage:o,toggleChat:jt,toggleAttachmentMenu:Gt,closeAttachmentMenu:Mt,fetchAvailablePlatforms:Y,selectPlatform:tt,goBackToPlatforms:b,initializeWidgetSession:V,sendMessage:xt,sendAttachment:ft,handleGalleryUpload:ht,handleFileUpload:bt,handleLocationShare:Et,isLoadingMessages:e};return E(Vo.Provider,{value:Pi,children:n})}function Uh(){const n=Gh(Vo);if(!n)throw new Error("useWidget must be used within WidgetProvider");return n}const Kh="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20stroke='currentColor'%20stroke-width='2'%20stroke-linecap='round'%20stroke-linejoin='round'%20class='lucide%20lucide-arrow-up-icon%20lucide-arrow-up'%3e%3cpath%20d='m5%2012%207-7%207%207'/%3e%3cpath%20d='M12%2019V5'/%3e%3c/svg%3e";function ri(n,t,e){let i=e.initialDeps??[],s;function r(){var o,a,l,h;let c;e.key&&((o=e.debug)!=null&&o.call(e))&&(c=Date.now());const u=n();if(!(u.length!==i.length||u.some((g,m)=>i[m]!==g)))return s;i=u;let f;if(e.key&&((a=e.debug)!=null&&a.call(e))&&(f=Date.now()),s=t(...u),e.key&&((l=e.debug)!=null&&l.call(e))){const g=Math.round((Date.now()-c)*100)/100,m=Math.round((Date.now()-f)*100)/100,_=m/16,p=(y,v)=>{for(y=String(y);y.length<v;)y=" "+y;return y};console.info(`%c⏱ ${p(m,5)} /${p(g,5)} ms`,`
|
|
2
3
|
font-size: .6rem;
|
|
3
4
|
font-weight: bold;
|
|
4
|
-
color: hsl(${Math.max(0,Math.min(120-120*_,120))}deg 100% 31%);`,e?.key)}return(h=e?.onChange)==null||h.call(e,s),s}return r.updateDeps=o=>{i=o},r}function Zo(n,t){if(n===void 0)throw new Error("Unexpected undefined");return n}const jh=(n,t)=>Math.abs(n-t)<1.01,Vh=(n,t,e)=>{let i;return function(...s){n.clearTimeout(i),i=n.setTimeout(()=>t.apply(this,s),e)}},$o=n=>{const{offsetWidth:t,offsetHeight:e}=n;return{width:t,height:e}},Zh=n=>n,$h=n=>{const t=Math.max(n.startIndex-n.overscan,0),e=Math.min(n.endIndex+n.overscan,n.count-1),i=[];for(let s=t;s<=e;s++)i.push(s);return i},Hh=(n,t)=>{const e=n.scrollElement;if(!e)return;const i=n.targetWindow;if(!i)return;const s=o=>{const{width:a,height:l}=o;t({width:Math.round(a),height:Math.round(l)})};if(s($o(e)),!i.ResizeObserver)return()=>{};const r=new i.ResizeObserver(o=>{const a=()=>{const l=o[0];if(l?.borderBoxSize){const h=l.borderBoxSize[0];if(h){s({width:h.inlineSize,height:h.blockSize});return}}s($o(e))};n.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(a):a()});return r.observe(e,{box:"border-box"}),()=>{r.unobserve(e)}},Ho={passive:!0},qo=typeof window>"u"?!0:"onscrollend"in window,qh=(n,t)=>{const e=n.scrollElement;if(!e)return;const i=n.targetWindow;if(!i)return;let s=0;const r=n.options.useScrollendEvent&&qo?()=>{}:Vh(i,()=>{t(s,!1)},n.options.isScrollingResetDelay),o=c=>()=>{const{horizontal:u,isRtl:d}=n.options;s=u?e.scrollLeft*(d&&-1||1):e.scrollTop,r(),t(s,c)},a=o(!0),l=o(!1);l(),e.addEventListener("scroll",a,Ho);const h=n.options.useScrollendEvent&&qo;return h&&e.addEventListener("scrollend",l,Ho),()=>{e.removeEventListener("scroll",a),h&&e.removeEventListener("scrollend",l)}},Jh=(n,t,e)=>{if(t?.borderBoxSize){const i=t.borderBoxSize[0];if(i)return Math.round(i[e.options.horizontal?"inlineSize":"blockSize"])}return n[e.options.horizontal?"offsetWidth":"offsetHeight"]},Qh=(n,{adjustments:t=0,behavior:e},i)=>{var s,r;const o=n+t;(r=(s=i.scrollElement)==null?void 0:s.scrollTo)==null||r.call(s,{[i.options.horizontal?"left":"top"]:o,behavior:e})};class tc{constructor(t){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.measurementsCache=[],this.itemSizeCache=new Map,this.pendingMeasuredCacheIndexes=[],this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this.elementsCache=new Map,this.observer=(()=>{let e=null;const i=()=>e||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:e=new this.targetWindow.ResizeObserver(s=>{s.forEach(r=>{const o=()=>{this._measureElement(r.target,r)};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(o):o()})}));return{disconnect:()=>{var s;(s=i())==null||s.disconnect(),e=null},observe:s=>{var r;return(r=i())==null?void 0:r.observe(s,{box:"border-box"})},unobserve:s=>{var r;return(r=i())==null?void 0:r.unobserve(s)}}})(),this.range=null,this.setOptions=e=>{Object.entries(e).forEach(([i,s])=>{typeof s>"u"&&delete e[i]}),this.options={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:Zh,rangeExtractor:$h,onChange:()=>{},measureElement:Jh,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,...e}},this.notify=e=>{var i,s;(s=(i=this.options).onChange)==null||s.call(i,this,e)},this.maybeNotify=si(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),e=>{this.notify(e)},{key:process.env.NODE_ENV!=="production"&&"maybeNotify",debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(e=>e()),this.unsubs=[],this.observer.disconnect(),this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var e;const i=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==i){if(this.cleanup(),!i){this.maybeNotify();return}this.scrollElement=i,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((e=this.scrollElement)==null?void 0:e.window)??null,this.elementsCache.forEach(s=>{this.observer.observe(s)}),this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0}),this.unsubs.push(this.options.observeElementRect(this,s=>{this.scrollRect=s,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(s,r)=>{this.scrollAdjustments=0,this.scrollDirection=r?this.getScrollOffset()<s?"forward":"backward":null,this.scrollOffset=s,this.isScrolling=r,this.maybeNotify()}))}},this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset=="function"?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(e,i)=>{const s=new Map,r=new Map;for(let o=i-1;o>=0;o--){const a=e[o];if(s.has(a.lane))continue;const l=r.get(a.lane);if(l==null||a.end>l.end?r.set(a.lane,a):a.end<l.end&&s.set(a.lane,!0),s.size===this.options.lanes)break}return r.size===this.options.lanes?Array.from(r.values()).sort((o,a)=>o.end===a.end?o.index-a.index:o.end-a.end)[0]:void 0},this.getMeasurementOptions=si(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled],(e,i,s,r,o)=>(this.pendingMeasuredCacheIndexes=[],{count:e,paddingStart:i,scrollMargin:s,getItemKey:r,enabled:o}),{key:!1}),this.getMeasurements=si(()=>[this.getMeasurementOptions(),this.itemSizeCache],({count:e,paddingStart:i,scrollMargin:s,getItemKey:r,enabled:o},a)=>{if(!o)return this.measurementsCache=[],this.itemSizeCache.clear(),[];this.measurementsCache.length===0&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(c=>{this.itemSizeCache.set(c.key,c.size)}));const l=this.pendingMeasuredCacheIndexes.length>0?Math.min(...this.pendingMeasuredCacheIndexes):0;this.pendingMeasuredCacheIndexes=[];const h=this.measurementsCache.slice(0,l);for(let c=l;c<e;c++){const u=r(c),d=this.options.lanes===1?h[c-1]:this.getFurthestMeasurement(h,c),f=d?d.end+this.options.gap:i+s,g=a.get(u),m=typeof g=="number"?g:this.options.estimateSize(c),_=f+m,p=d?d.lane:c%this.options.lanes;h[c]={index:c,start:f,size:m,end:_,key:u,lane:p}}return this.measurementsCache=h,h},{key:process.env.NODE_ENV!=="production"&&"getMeasurements",debug:()=>this.options.debug}),this.calculateRange=si(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(e,i,s,r)=>this.range=e.length>0&&i>0?ec({measurements:e,outerSize:i,scrollOffset:s,lanes:r}):null,{key:process.env.NODE_ENV!=="production"&&"calculateRange",debug:()=>this.options.debug}),this.getVirtualIndexes=si(()=>{let e=null,i=null;const s=this.calculateRange();return s&&(e=s.startIndex,i=s.endIndex),this.maybeNotify.updateDeps([this.isScrolling,e,i]),[this.options.rangeExtractor,this.options.overscan,this.options.count,e,i]},(e,i,s,r,o)=>r===null||o===null?[]:e({startIndex:r,endIndex:o,overscan:i,count:s}),{key:process.env.NODE_ENV!=="production"&&"getVirtualIndexes",debug:()=>this.options.debug}),this.indexFromElement=e=>{const i=this.options.indexAttribute,s=e.getAttribute(i);return s?parseInt(s,10):(console.warn(`Missing attribute name '${i}={index}' on measured element.`),-1)},this._measureElement=(e,i)=>{const s=this.indexFromElement(e),r=this.measurementsCache[s];if(!r)return;const o=r.key,a=this.elementsCache.get(o);a!==e&&(a&&this.observer.unobserve(a),this.observer.observe(e),this.elementsCache.set(o,e)),e.isConnected&&this.resizeItem(s,this.options.measureElement(e,i,this))},this.resizeItem=(e,i)=>{const s=this.measurementsCache[e];if(!s)return;const r=this.itemSizeCache.get(s.key)??s.size,o=i-r;o!==0&&((this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(s,o,this):s.start<this.getScrollOffset()+this.scrollAdjustments)&&(process.env.NODE_ENV!=="production"&&this.options.debug&&console.info("correction",o),this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=o,behavior:void 0})),this.pendingMeasuredCacheIndexes.push(s.index),this.itemSizeCache=new Map(this.itemSizeCache.set(s.key,i)),this.notify(!1))},this.measureElement=e=>{if(!e){this.elementsCache.forEach((i,s)=>{i.isConnected||(this.observer.unobserve(i),this.elementsCache.delete(s))});return}this._measureElement(e,void 0)},this.getVirtualItems=si(()=>[this.getVirtualIndexes(),this.getMeasurements()],(e,i)=>{const s=[];for(let r=0,o=e.length;r<o;r++){const a=e[r],l=i[a];s.push(l)}return s},{key:process.env.NODE_ENV!=="production"&&"getVirtualItems",debug:()=>this.options.debug}),this.getVirtualItemForOffset=e=>{const i=this.getMeasurements();if(i.length!==0)return Zo(i[Jo(0,i.length-1,s=>Zo(i[s]).start,e)])},this.getOffsetForAlignment=(e,i,s=0)=>{const r=this.getSize(),o=this.getScrollOffset();i==="auto"&&(i=e>=o+r?"end":"start"),i==="center"?e+=(s-r)/2:i==="end"&&(e-=r);const a=this.getTotalSize()+this.options.scrollMargin-r;return Math.max(Math.min(a,e),0)},this.getOffsetForIndex=(e,i="auto")=>{e=Math.max(0,Math.min(e,this.options.count-1));const s=this.measurementsCache[e];if(!s)return;const r=this.getSize(),o=this.getScrollOffset();if(i==="auto")if(s.end>=o+r-this.options.scrollPaddingEnd)i="end";else if(s.start<=o+this.options.scrollPaddingStart)i="start";else return[o,i];const a=i==="end"?s.end+this.options.scrollPaddingEnd:s.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,i,s.size),i]},this.isDynamicMode=()=>this.elementsCache.size>0,this.scrollToOffset=(e,{align:i="start",behavior:s}={})=>{s==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),this._scrollToOffset(this.getOffsetForAlignment(e,i),{adjustments:void 0,behavior:s})},this.scrollToIndex=(e,{align:i="auto",behavior:s}={})=>{s==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),e=Math.max(0,Math.min(e,this.options.count-1));let r=0;const o=10,a=h=>{if(!this.targetWindow)return;const c=this.getOffsetForIndex(e,h);if(!c){console.warn("Failed to get offset for index:",e);return}const[u,d]=c;this._scrollToOffset(u,{adjustments:void 0,behavior:s}),this.targetWindow.requestAnimationFrame(()=>{const f=this.getScrollOffset(),g=this.getOffsetForIndex(e,d);if(!g){console.warn("Failed to get offset for index:",e);return}jh(g[0],f)||l(d)})},l=h=>{this.targetWindow&&(r++,r<o?(process.env.NODE_ENV!=="production"&&this.options.debug&&console.info("Schedule retry",r,o),this.targetWindow.requestAnimationFrame(()=>a(h))):console.warn(`Failed to scroll to index ${e} after ${o} attempts.`))};a(i)},this.scrollBy=(e,{behavior:i}={})=>{i==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),this._scrollToOffset(this.getScrollOffset()+e,{adjustments:void 0,behavior:i})},this.getTotalSize=()=>{var e;const i=this.getMeasurements();let s;if(i.length===0)s=this.options.paddingStart;else if(this.options.lanes===1)s=((e=i[i.length-1])==null?void 0:e.end)??0;else{const r=Array(this.options.lanes).fill(null);let o=i.length-1;for(;o>=0&&r.some(a=>a===null);){const a=i[o];r[a.lane]===null&&(r[a.lane]=a.end),o--}s=Math.max(...r.filter(a=>a!==null))}return Math.max(s-this.options.scrollMargin+this.options.paddingEnd,0)},this._scrollToOffset=(e,{adjustments:i,behavior:s})=>{this.options.scrollToFn(e,{behavior:s,adjustments:i},this)},this.measure=()=>{this.itemSizeCache=new Map,this.notify(!1)},this.setOptions(t)}}const Jo=(n,t,e,i)=>{for(;n<=t;){const s=(n+t)/2|0,r=e(s);if(r<i)n=s+1;else if(r>i)t=s-1;else return s}return n>0?n-1:0};function ec({measurements:n,outerSize:t,scrollOffset:e,lanes:i}){const s=n.length-1,r=l=>n[l].start;if(n.length<=i)return{startIndex:0,endIndex:s};let o=Jo(0,s,r,e),a=o;if(i===1)for(;a<s&&n[a].end<e+t;)a++;else if(i>1){const l=Array(i).fill(0);for(;a<s&&l.some(c=>c<e+t);){const c=n[a];l[c.lane]=c.end,a++}const h=Array(i).fill(e+t);for(;o>=0&&h.some(c=>c>=e);){const c=n[o];h[c.lane]=c.start,o--}o=Math.max(0,o-o%i),a=Math.min(s,a+(i-1-a%i))}return{startIndex:o,endIndex:a}}const ic=typeof window<"u"?zh:ee;function nc(n){const t=Bo(()=>({}),{})[1],e={...n,onChange:s=>{t(),n.onChange?.(s)}},[i]=vt(()=>new tc(e));return i.setOptions(e),ee(()=>i._didMount(),[]),ic(()=>i._willUpdate()),i}function sc(n){return nc({observeElementRect:Hh,observeElementOffset:qh,scrollToFn:Qh,...n})}function rc({content:n,timestamp:t,isFromCustomer:e}){return E("div",{class:`flex ${e?"justify-end":"justify-start"} mb-3`,children:E("div",{class:`max-w-[75%] px-3 py-2 rounded-lg ${e?"bg-blue-600 text-white":"bg-white border border-zinc-200 text-zinc-900"}`,children:[E("p",{class:"text-sm wrap-break-word",children:n}),E("span",{class:`text-xs mt-1 block ${e?"text-blue-100":"text-zinc-500"}`,children:new Date(t).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})})]})})}function oc({url:n,filename:t,size:e,caption:i,timestamp:s,isFromCustomer:r}){const o=()=>{const a=document.createElement("a");a.href=n,a.download=t||"image.jpg",a.click()};return E("div",{class:`flex ${r?"justify-end":"justify-start"} mb-3`,children:E("div",{class:`max-w-[75%] rounded-lg overflow-hidden ${r?"bg-blue-600":"bg-white border border-zinc-200"}`,children:E("div",{class:"p-2",children:[E("img",{src:n,alt:t||"Photo",class:"max-w-full max-h-80 rounded object-contain"}),i&&E("p",{class:`text-sm mt-2 wrap-break-word ${r?"text-white":"text-zinc-900"}`,children:i}),E("div",{class:"flex items-center justify-between mt-2 gap-2",children:[E("div",{class:"flex flex-col gap-0.5 min-w-0",children:[t&&E("span",{class:`text-xs truncate ${r?"text-blue-100":"text-zinc-500"}`,children:t}),e&&E("span",{class:`text-xs ${r?"text-blue-100":"text-zinc-500"}`,children:[(e/1024).toFixed(1)," KB"]})]}),E("button",{type:"button",onClick:o,class:`p-1 rounded transition-colors shrink-0 ${r?"text-white hover:bg-white/20":"text-zinc-600 hover:bg-zinc-100"}`,title:"Download",children:E("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[E("title",{children:"Download"}),E("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4"})]})})]}),E("span",{class:`text-xs mt-1 block ${r?"text-blue-100":"text-zinc-500"}`,children:new Date(s).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})})]})})})}function ac({url:n,filename:t,size:e,caption:i,timestamp:s,isFromCustomer:r}){const[o,a]=vt(!0);return E("div",{class:`flex ${r?"justify-end":"justify-start"} mb-3`,children:E("div",{class:`max-w-[75%] rounded-lg overflow-hidden ${r?"bg-blue-600":"bg-white border border-zinc-200"}`,children:E("div",{class:"p-2",children:[E("div",{class:"relative",children:[o&&E("div",{class:"absolute inset-0 flex items-center justify-center bg-zinc-100 rounded min-h-[180px]",children:E("svg",{class:"w-8 h-8 animate-spin text-zinc-400",fill:"none",viewBox:"0 0 24 24",children:[E("title",{children:"Loading"}),E("circle",{class:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor","stroke-width":"4"}),E("path",{class:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]})}),E("video",{controls:!0,class:"rounded max-w-full",preload:"metadata",style:{opacity:o?0:1},onLoadedData:()=>a(!1),children:[E("source",{src:n,type:"video/mp4"}),E("track",{kind:"captions"})]})]}),i&&E("p",{class:`text-sm mt-2 wrap-break-word ${r?"text-white":"text-zinc-900"}`,children:i}),E("div",{class:"flex items-center justify-between mt-2 gap-2",children:[t&&E("span",{class:`text-xs truncate ${r?"text-blue-100":"text-zinc-500"}`,children:t}),E("button",{type:"button",onClick:()=>{const h=document.createElement("a");h.href=n,h.download=t||"video.mp4",h.click()},class:`p-1 rounded transition-colors shrink-0 ${r?"text-white hover:bg-white/20":"text-zinc-600 hover:bg-zinc-100"}`,title:"Download",children:E("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[E("title",{children:"Download"}),E("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4"})]})})]}),E("span",{class:`text-xs mt-1 block ${r?"text-blue-100":"text-zinc-500"}`,children:new Date(s).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})})]})})})}function lc({url:n,filename:t,size:e,mimeType:i,timestamp:s,isFromCustomer:r}){const o=()=>{const l=document.createElement("a");l.href=n,l.download=t,l.click()};return E("div",{class:`flex ${r?"justify-end":"justify-start"} mb-3`,children:E("div",{class:`max-w-[75%] rounded-lg ${r?"bg-blue-600 text-white":"bg-white border border-zinc-200 text-zinc-900"}`,children:E("div",{class:"p-3",children:[E("div",{class:"flex items-center gap-3",children:[E("div",{class:"shrink-0",children:i?.startsWith("application/pdf")?E("svg",{class:"w-8 h-8 text-red-500",fill:"currentColor",viewBox:"0 0 24 24",children:[E("title",{children:"PDF"}),E("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8l-6-6z"}),E("path",{d:"M14 2v6h6"}),E("path",{d:"M9 13h6"}),E("path",{d:"M9 17h6"})]}):E("svg",{class:"w-8 h-8 text-zinc-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[E("title",{children:"File"}),E("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})]})}),E("div",{class:"flex-1 min-w-0",children:[E("p",{class:`text-sm font-medium truncate ${r?"text-white":"text-zinc-900"}`,children:t}),e&&E("p",{class:`text-xs ${r?"text-blue-100":"text-zinc-500"}`,children:[(e/1024).toFixed(1)," KB"]})]}),E("button",{type:"button",onClick:o,class:`p-2 rounded transition-colors shrink-0 ${r?"text-white hover:bg-white/20":"text-zinc-600 hover:bg-zinc-100"}`,title:"Download",children:E("svg",{class:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[E("title",{children:"Download"}),E("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4"})]})})]}),E("span",{class:`text-xs mt-2 block ${r?"text-blue-100":"text-zinc-500"}`,children:new Date(s).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})})]})})})}const Ot={ADD:"add",REMOVE:"remove"},ri={PROPERTYCHANGE:"propertychange"},B={CHANGE:"change",ERROR:"error",CONTEXTMENU:"contextmenu",CLICK:"click",DBLCLICK:"dblclick",KEYDOWN:"keydown",KEYPRESS:"keypress",LOAD:"load",TOUCHMOVE:"touchmove",WHEEL:"wheel"};class Dn{constructor(){this.disposed=!1}dispose(){this.disposed||(this.disposed=!0,this.disposeInternal())}disposeInternal(){}}function hc(n,t,e){let i,s;e=e||ce;let r=0,o=n.length,a=!1;for(;r<o;)i=r+(o-r>>1),s=+e(n[i],t),s<0?r=i+1:(o=i,a=!s);return a?r:~r}function ce(n,t){return n>t?1:n<t?-1:0}function cc(n,t){return n<t?1:n>t?-1:0}function Ws(n,t,e){if(n[0]<=t)return 0;const i=n.length;if(t<=n[i-1])return i-1;if(typeof e=="function"){for(let s=1;s<i;++s){const r=n[s];if(r===t)return s;if(r<t)return e(t,n[s-1],r)>0?s-1:s}return i-1}if(e>0){for(let s=1;s<i;++s)if(n[s]<t)return s-1;return i-1}if(e<0){for(let s=1;s<i;++s)if(n[s]<=t)return s;return i-1}for(let s=1;s<i;++s){if(n[s]==t)return s;if(n[s]<t)return n[s-1]-t<t-n[s]?s-1:s}return i-1}function uc(n,t,e){for(;t<e;){const i=n[t];n[t]=n[e],n[e]=i,++t,--e}}function Xs(n,t){const e=Array.isArray(t)?t:[t],i=e.length;for(let s=0;s<i;s++)n[n.length]=e[s]}function Ce(n,t){const e=n.length;if(e!==t.length)return!1;for(let i=0;i<e;i++)if(n[i]!==t[i])return!1;return!0}function dc(n,t,e){const i=t||ce;return n.every(function(s,r){if(r===0)return!0;const o=i(n[r-1],s);return!(o>0||o===0)})}function Xi(){return!0}function kn(){return!1}function Yi(){}function Qo(n){let t,e,i;return function(){const s=Array.prototype.slice.call(arguments);return(!e||this!==i||!Ce(s,e))&&(i=this,e=s,t=n.apply(this,arguments)),t}}function fc(n){function t(){let e;try{e=n()}catch(i){return Promise.reject(i)}return e instanceof Promise?e:Promise.resolve(e)}return t()}function Bi(n){for(const t in n)delete n[t]}function oi(n){let t;for(t in n)return!1;return!t}class ue{constructor(t){this.propagationStopped,this.defaultPrevented,this.type=t,this.target=null}preventDefault(){this.defaultPrevented=!0}stopPropagation(){this.propagationStopped=!0}}class Fn extends Dn{constructor(t){super(),this.eventTarget_=t,this.pendingRemovals_=null,this.dispatching_=null,this.listeners_=null}addEventListener(t,e){if(!t||!e)return;const i=this.listeners_||(this.listeners_={}),s=i[t]||(i[t]=[]);s.includes(e)||s.push(e)}dispatchEvent(t){const e=typeof t=="string",i=e?t:t.type,s=this.listeners_&&this.listeners_[i];if(!s)return;const r=e?new ue(t):t;r.target||(r.target=this.eventTarget_||this);const o=this.dispatching_||(this.dispatching_={}),a=this.pendingRemovals_||(this.pendingRemovals_={});i in o||(o[i]=0,a[i]=0),++o[i];let l;for(let h=0,c=s.length;h<c;++h)if("handleEvent"in s[h]?l=s[h].handleEvent(r):l=s[h].call(this,r),l===!1||r.propagationStopped){l=!1;break}if(--o[i]===0){let h=a[i];for(delete a[i];h--;)this.removeEventListener(i,Yi);delete o[i]}return l}disposeInternal(){this.listeners_&&Bi(this.listeners_)}getListeners(t){return this.listeners_&&this.listeners_[t]||void 0}hasListener(t){return this.listeners_?t?t in this.listeners_:Object.keys(this.listeners_).length>0:!1}removeEventListener(t,e){if(!this.listeners_)return;const i=this.listeners_[t];if(!i)return;const s=i.indexOf(e);s!==-1&&(this.pendingRemovals_&&t in this.pendingRemovals_?(i[s]=Yi,++this.pendingRemovals_[t]):(i.splice(s,1),i.length===0&&delete this.listeners_[t]))}}function $(n,t,e,i,s){if(s){const o=e;e=function(a){return n.removeEventListener(t,e),o.call(i??this,a)}}else i&&i!==n&&(e=e.bind(i));const r={target:n,type:t,listener:e};return n.addEventListener(t,e),r}function Nn(n,t,e,i){return $(n,t,e,i,!0)}function at(n){n&&n.target&&(n.target.removeEventListener(n.type,n.listener),Bi(n))}class Ui extends Fn{constructor(){super(),this.on=this.onInternal,this.once=this.onceInternal,this.un=this.unInternal,this.revision_=0}changed(){++this.revision_,this.dispatchEvent(B.CHANGE)}getRevision(){return this.revision_}onInternal(t,e){if(Array.isArray(t)){const i=t.length,s=new Array(i);for(let r=0;r<i;++r)s[r]=$(this,t[r],e);return s}return $(this,t,e)}onceInternal(t,e){let i;if(Array.isArray(t)){const s=t.length;i=new Array(s);for(let r=0;r<s;++r)i[r]=Nn(this,t[r],e)}else i=Nn(this,t,e);return e.ol_key=i,i}unInternal(t,e){const i=e.ol_key;if(i)gc(i);else if(Array.isArray(t))for(let s=0,r=t.length;s<r;++s)this.removeEventListener(t[s],e);else this.removeEventListener(t,e)}}Ui.prototype.on,Ui.prototype.once,Ui.prototype.un;function gc(n){if(Array.isArray(n))for(let t=0,e=n.length;t<e;++t)at(n[t]);else at(n)}function H(){throw new Error("Unimplemented abstract method.")}let _c=0;function q(n){return n.ol_uid||(n.ol_uid=String(++_c))}class ta extends ue{constructor(t,e,i){super(t),this.key=e,this.oldValue=i}}class ne extends Ui{constructor(t){super(),this.on,this.once,this.un,q(this),this.values_=null,t!==void 0&&this.setProperties(t)}get(t){let e;return this.values_&&this.values_.hasOwnProperty(t)&&(e=this.values_[t]),e}getKeys(){return this.values_&&Object.keys(this.values_)||[]}getProperties(){return this.values_&&Object.assign({},this.values_)||{}}getPropertiesInternal(){return this.values_}hasProperties(){return!!this.values_}notify(t,e){let i;i=`change:${t}`,this.hasListener(i)&&this.dispatchEvent(new ta(i,t,e)),i=ri.PROPERTYCHANGE,this.hasListener(i)&&this.dispatchEvent(new ta(i,t,e))}addChangeListener(t,e){this.addEventListener(`change:${t}`,e)}removeChangeListener(t,e){this.removeEventListener(`change:${t}`,e)}set(t,e,i){const s=this.values_||(this.values_={});if(i)s[t]=e;else{const r=s[t];s[t]=e,r!==e&&this.notify(t,r)}}setProperties(t,e){for(const i in t)this.set(i,t[i],e)}applyProperties(t){t.values_&&Object.assign(this.values_||(this.values_={}),t.values_)}unset(t,e){if(this.values_&&t in this.values_){const i=this.values_[t];delete this.values_[t],oi(this.values_)&&(this.values_=null),e||this.notify(t,i)}}}const ea={LENGTH:"length"};class zn extends ue{constructor(t,e,i){super(t),this.element=e,this.index=i}}class se extends ne{constructor(t,e){if(super(),this.on,this.once,this.un,e=e||{},this.unique_=!!e.unique,this.array_=t||[],this.unique_)for(let i=0,s=this.array_.length;i<s;++i)this.assertUnique_(this.array_[i],i);this.updateLength_()}clear(){for(;this.getLength()>0;)this.pop()}extend(t){for(let e=0,i=t.length;e<i;++e)this.push(t[e]);return this}forEach(t){const e=this.array_;for(let i=0,s=e.length;i<s;++i)t(e[i],i,e)}getArray(){return this.array_}item(t){return this.array_[t]}getLength(){return this.get(ea.LENGTH)}insertAt(t,e){if(t<0||t>this.getLength())throw new Error("Index out of bounds: "+t);this.unique_&&this.assertUnique_(e),this.array_.splice(t,0,e),this.updateLength_(),this.dispatchEvent(new zn(Ot.ADD,e,t))}pop(){return this.removeAt(this.getLength()-1)}push(t){this.unique_&&this.assertUnique_(t);const e=this.getLength();return this.insertAt(e,t),this.getLength()}remove(t){const e=this.array_;for(let i=0,s=e.length;i<s;++i)if(e[i]===t)return this.removeAt(i)}removeAt(t){if(t<0||t>=this.getLength())return;const e=this.array_[t];return this.array_.splice(t,1),this.updateLength_(),this.dispatchEvent(new zn(Ot.REMOVE,e,t)),e}setAt(t,e){const i=this.getLength();if(t>=i){this.insertAt(t,e);return}if(t<0)throw new Error("Index out of bounds: "+t);this.unique_&&this.assertUnique_(e,t);const s=this.array_[t];this.array_[t]=e,this.dispatchEvent(new zn(Ot.REMOVE,s,t)),this.dispatchEvent(new zn(Ot.ADD,e,t))}updateLength_(){this.set(ea.LENGTH,this.array_.length)}assertUnique_(t,e){for(let i=0,s=this.array_.length;i<s;++i)if(this.array_[i]===t&&i!==e)throw new Error("Duplicate item added to a unique collection")}}class ai extends ue{constructor(t,e,i){super(t),this.map=e,this.frameState=i!==void 0?i:null}}class Re extends ai{constructor(t,e,i,s,r,o){super(t,e,r),this.originalEvent=i,this.pixel_=null,this.coordinate_=null,this.dragging=s!==void 0?s:!1,this.activePointers=o}get pixel(){return this.pixel_||(this.pixel_=this.map.getEventPixel(this.originalEvent)),this.pixel_}set pixel(t){this.pixel_=t}get coordinate(){return this.coordinate_||(this.coordinate_=this.map.getCoordinateFromPixel(this.pixel)),this.coordinate_}set coordinate(t){this.coordinate_=t}preventDefault(){super.preventDefault(),"preventDefault"in this.originalEvent&&this.originalEvent.preventDefault()}stopPropagation(){super.stopPropagation(),"stopPropagation"in this.originalEvent&&this.originalEvent.stopPropagation()}}const ct={SINGLECLICK:"singleclick",CLICK:B.CLICK,DBLCLICK:B.DBLCLICK,POINTERDRAG:"pointerdrag",POINTERMOVE:"pointermove",POINTERDOWN:"pointerdown",POINTERUP:"pointerup",POINTEROVER:"pointerover",POINTEROUT:"pointerout",POINTERENTER:"pointerenter",POINTERLEAVE:"pointerleave",POINTERCANCEL:"pointercancel"},Xe=typeof navigator<"u"&&typeof navigator.userAgent<"u"?navigator.userAgent.toLowerCase():"";Xe.includes("safari")&&!Xe.includes("chrom")&&(Xe.includes("version/15.4")||/cpu (os|iphone os) 15_4 like mac os x/.test(Xe));const mc=Xe.includes("webkit")&&!Xe.includes("edge"),ia=Xe.includes("macintosh"),pc=typeof devicePixelRatio<"u"?devicePixelRatio:1,Ys=typeof WorkerGlobalScope<"u"&&typeof OffscreenCanvas<"u"&&self instanceof WorkerGlobalScope,na=typeof Image<"u"&&Image.prototype.decode,sa=(function(){let n=!1;try{const t=Object.defineProperty({},"passive",{get:function(){n=!0}});window.addEventListener("_",null,t),window.removeEventListener("_",null,t)}catch{}return n})(),Bs={POINTERMOVE:"pointermove",POINTERDOWN:"pointerdown"};class yc extends Fn{constructor(t,e){super(t),this.map_=t,this.clickTimeoutId_,this.emulateClicks_=!1,this.dragging_=!1,this.dragListenerKeys_=[],this.moveTolerance_=e===void 0?1:e,this.down_=null;const i=this.map_.getViewport();this.activePointers_=[],this.trackedTouches_={},this.element_=i,this.pointerdownListenerKey_=$(i,Bs.POINTERDOWN,this.handlePointerDown_,this),this.originalPointerMoveEvent_,this.relayedListenerKey_=$(i,Bs.POINTERMOVE,this.relayMoveEvent_,this),this.boundHandleTouchMove_=this.handleTouchMove_.bind(this),this.element_.addEventListener(B.TOUCHMOVE,this.boundHandleTouchMove_,sa?{passive:!1}:!1)}emulateClick_(t){let e=new Re(ct.CLICK,this.map_,t);this.dispatchEvent(e),this.clickTimeoutId_!==void 0?(clearTimeout(this.clickTimeoutId_),this.clickTimeoutId_=void 0,e=new Re(ct.DBLCLICK,this.map_,t),this.dispatchEvent(e)):this.clickTimeoutId_=setTimeout(()=>{this.clickTimeoutId_=void 0;const i=new Re(ct.SINGLECLICK,this.map_,t);this.dispatchEvent(i)},250)}updateActivePointers_(t){const e=t,i=e.pointerId;if(e.type==ct.POINTERUP||e.type==ct.POINTERCANCEL){delete this.trackedTouches_[i];for(const s in this.trackedTouches_)if(this.trackedTouches_[s].target!==e.target){delete this.trackedTouches_[s];break}}else(e.type==ct.POINTERDOWN||e.type==ct.POINTERMOVE)&&(this.trackedTouches_[i]=e);this.activePointers_=Object.values(this.trackedTouches_)}handlePointerUp_(t){this.updateActivePointers_(t);const e=new Re(ct.POINTERUP,this.map_,t,void 0,void 0,this.activePointers_);this.dispatchEvent(e),this.emulateClicks_&&!e.defaultPrevented&&!this.dragging_&&this.isMouseActionButton_(t)&&this.emulateClick_(this.down_),this.activePointers_.length===0&&(this.dragListenerKeys_.forEach(at),this.dragListenerKeys_.length=0,this.dragging_=!1,this.down_=null)}isMouseActionButton_(t){return t.button===0}handlePointerDown_(t){this.emulateClicks_=this.activePointers_.length===0,this.updateActivePointers_(t);const e=new Re(ct.POINTERDOWN,this.map_,t,void 0,void 0,this.activePointers_);if(this.dispatchEvent(e),this.down_=new PointerEvent(t.type,t),Object.defineProperty(this.down_,"target",{writable:!1,value:t.target}),this.dragListenerKeys_.length===0){const i=this.map_.getOwnerDocument();this.dragListenerKeys_.push($(i,ct.POINTERMOVE,this.handlePointerMove_,this),$(i,ct.POINTERUP,this.handlePointerUp_,this),$(this.element_,ct.POINTERCANCEL,this.handlePointerUp_,this)),this.element_.getRootNode&&this.element_.getRootNode()!==i&&this.dragListenerKeys_.push($(this.element_.getRootNode(),ct.POINTERUP,this.handlePointerUp_,this))}}handlePointerMove_(t){if(this.isMoving_(t)){this.updateActivePointers_(t),this.dragging_=!0;const e=new Re(ct.POINTERDRAG,this.map_,t,this.dragging_,void 0,this.activePointers_);this.dispatchEvent(e)}}relayMoveEvent_(t){this.originalPointerMoveEvent_=t;const e=!!(this.down_&&this.isMoving_(t));this.dispatchEvent(new Re(ct.POINTERMOVE,this.map_,t,e))}handleTouchMove_(t){const e=this.originalPointerMoveEvent_;(!e||e.defaultPrevented)&&(typeof t.cancelable!="boolean"||t.cancelable===!0)&&t.preventDefault()}isMoving_(t){return this.dragging_||Math.abs(t.clientX-this.down_.clientX)>this.moveTolerance_||Math.abs(t.clientY-this.down_.clientY)>this.moveTolerance_}disposeInternal(){this.relayedListenerKey_&&(at(this.relayedListenerKey_),this.relayedListenerKey_=null),this.element_.removeEventListener(B.TOUCHMOVE,this.boundHandleTouchMove_),this.pointerdownListenerKey_&&(at(this.pointerdownListenerKey_),this.pointerdownListenerKey_=null),this.dragListenerKeys_.forEach(at),this.dragListenerKeys_.length=0,this.element_=null,super.disposeInternal()}}const Se={POSTRENDER:"postrender",MOVESTART:"movestart",MOVEEND:"moveend",LOADSTART:"loadstart",LOADEND:"loadend"},Rt={LAYERGROUP:"layergroup",SIZE:"size",TARGET:"target",VIEW:"view"},N={IDLE:0,LOADING:1,LOADED:2,ERROR:3,EMPTY:4};function Q(n,t){if(!n)throw new Error(t)}const Gn=1/0;class xc{constructor(t,e){this.priorityFunction_=t,this.keyFunction_=e,this.elements_=[],this.priorities_=[],this.queuedElements_={}}clear(){this.elements_.length=0,this.priorities_.length=0,Bi(this.queuedElements_)}dequeue(){const t=this.elements_,e=this.priorities_,i=t[0];t.length==1?(t.length=0,e.length=0):(t[0]=t.pop(),e[0]=e.pop(),this.siftUp_(0));const s=this.keyFunction_(i);return delete this.queuedElements_[s],i}enqueue(t){Q(!(this.keyFunction_(t)in this.queuedElements_),"Tried to enqueue an `element` that was already added to the queue");const e=this.priorityFunction_(t);return e!=Gn?(this.elements_.push(t),this.priorities_.push(e),this.queuedElements_[this.keyFunction_(t)]=!0,this.siftDown_(0,this.elements_.length-1),!0):!1}getCount(){return this.elements_.length}getLeftChildIndex_(t){return t*2+1}getRightChildIndex_(t){return t*2+2}getParentIndex_(t){return t-1>>1}heapify_(){let t;for(t=(this.elements_.length>>1)-1;t>=0;t--)this.siftUp_(t)}isEmpty(){return this.elements_.length===0}isKeyQueued(t){return t in this.queuedElements_}isQueued(t){return this.isKeyQueued(this.keyFunction_(t))}siftUp_(t){const e=this.elements_,i=this.priorities_,s=e.length,r=e[t],o=i[t],a=t;for(;t<s>>1;){const l=this.getLeftChildIndex_(t),h=this.getRightChildIndex_(t),c=h<s&&i[h]<i[l]?h:l;e[t]=e[c],i[t]=i[c],t=c}e[t]=r,i[t]=o,this.siftDown_(a,t)}siftDown_(t,e){const i=this.elements_,s=this.priorities_,r=i[e],o=s[e];for(;e>t;){const a=this.getParentIndex_(e);if(s[a]>o)i[e]=i[a],s[e]=s[a],e=a;else break}i[e]=r,s[e]=o}reprioritize(){const t=this.priorityFunction_,e=this.elements_,i=this.priorities_;let s=0;const r=e.length;let o,a,l;for(a=0;a<r;++a)o=e[a],l=t(o),l==Gn?delete this.queuedElements_[this.keyFunction_(o)]:(i[s]=l,e[s++]=o);e.length=s,i.length=s,this.heapify_()}}class Ec extends xc{constructor(t,e){super(i=>t.apply(null,i),i=>i[0].getKey()),this.boundHandleTileChange_=this.handleTileChange.bind(this),this.tileChangeCallback_=e,this.tilesLoading_=0,this.tilesLoadingKeys_={}}enqueue(t){const e=super.enqueue(t);return e&&t[0].addEventListener(B.CHANGE,this.boundHandleTileChange_),e}getTilesLoading(){return this.tilesLoading_}handleTileChange(t){const e=t.target,i=e.getState();if(i===N.LOADED||i===N.ERROR||i===N.EMPTY){i!==N.ERROR&&e.removeEventListener(B.CHANGE,this.boundHandleTileChange_);const s=e.getKey();s in this.tilesLoadingKeys_&&(delete this.tilesLoadingKeys_[s],--this.tilesLoading_),this.tileChangeCallback_()}}loadMoreTiles(t,e){let i=0;for(;this.tilesLoading_<t&&i<e&&this.getCount()>0;){const s=this.dequeue()[0],r=s.getKey();s.getState()===N.IDLE&&!(r in this.tilesLoadingKeys_)&&(this.tilesLoadingKeys_[r]=!0,++this.tilesLoading_,++i,s.load())}}}function wc(n,t,e,i,s){if(!n||!(e in n.wantedTiles)||!n.wantedTiles[e][t.getKey()])return Gn;const r=n.viewState.center,o=i[0]-r[0],a=i[1]-r[1];return 65536*Math.log(s)+Math.sqrt(o*o+a*a)/s}const St={ANIMATING:0,INTERACTING:1},Ht={CENTER:"center",RESOLUTION:"resolution",ROTATION:"rotation"};function lt(n,t,e){return Math.min(Math.max(n,t),e)}function vc(n,t,e,i,s,r){const o=s-e,a=r-i;if(o!==0||a!==0){const l=((n-e)*o+(t-i)*a)/(o*o+a*a);l>1?(e=s,i=r):l>0&&(e+=o*l,i+=a*l)}return li(n,t,e,i)}function li(n,t,e,i){const s=e-n,r=i-t;return s*s+r*r}function Cc(n){const t=n.length;for(let i=0;i<t;i++){let s=i,r=Math.abs(n[i][i]);for(let a=i+1;a<t;a++){const l=Math.abs(n[a][i]);l>r&&(r=l,s=a)}if(r===0)return null;const o=n[s];n[s]=n[i],n[i]=o;for(let a=i+1;a<t;a++){const l=-n[a][i]/n[i][i];for(let h=i;h<t+1;h++)i==h?n[a][h]=0:n[a][h]+=l*n[i][h]}}const e=new Array(t);for(let i=t-1;i>=0;i--){e[i]=n[i][t]/n[i][i];for(let s=i-1;s>=0;s--)n[s][t]-=n[s][i]*e[i]}return e}function ra(n){return n*180/Math.PI}function Ie(n){return n*Math.PI/180}function hi(n,t){const e=n%t;return e*t<0?e+t:e}function Wt(n,t,e){return n+e*(t-n)}function Wn(n,t){const e=Math.pow(10,t);return Math.round(n*e)/e}function Xn(n,t){return Math.floor(Wn(n,t))}function Yn(n,t){return Math.ceil(Wn(n,t))}function Us(n,t,e){if(n>=t&&n<e)return n;const i=e-t;return((n-t)%i+i)%i+t}function oa(n,t,e){return(function(i,s,r,o,a){if(!i)return;if(!s&&!t)return i;const l=t?0:r[0]*s,h=t?0:r[1]*s,c=a?a[0]:0,u=a?a[1]:0;let d=n[0]+l/2+c,f=n[2]-l/2+c,g=n[1]+h/2+u,m=n[3]-h/2+u;d>f&&(d=(f+d)/2,f=d),g>m&&(g=(m+g)/2,m=g);let _=lt(i[0],d,f),p=lt(i[1],g,m);if(o&&e&&s){const y=30*s;_+=-y*Math.log(1+Math.max(0,d-i[0])/y)+y*Math.log(1+Math.max(0,i[0]-f)/y),p+=-y*Math.log(1+Math.max(0,g-i[1])/y)+y*Math.log(1+Math.max(0,i[1]-m)/y)}return[_,p]})}function Rc(n){return n}const pt={UNKNOWN:0,INTERSECTING:1,ABOVE:2,RIGHT:4,BELOW:8,LEFT:16};function aa(n){const t=Xt();for(let e=0,i=n.length;e<i;++e)Vi(t,n[e]);return t}function Ks(n,t,e){return e?(e[0]=n[0]-t,e[1]=n[1]-t,e[2]=n[2]+t,e[3]=n[3]+t,e):[n[0]-t,n[1]-t,n[2]+t,n[3]+t]}function la(n,t){return t?(t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t):n.slice()}function ha(n,t,e){let i,s;return t<n[0]?i=n[0]-t:n[2]<t?i=t-n[2]:i=0,e<n[1]?s=n[1]-e:n[3]<e?s=e-n[3]:s=0,i*i+s*s}function ci(n,t){return ca(n,t[0],t[1])}function Ki(n,t){return n[0]<=t[0]&&t[2]<=n[2]&&n[1]<=t[1]&&t[3]<=n[3]}function ca(n,t,e){return n[0]<=t&&t<=n[2]&&n[1]<=e&&e<=n[3]}function js(n,t){const e=n[0],i=n[1],s=n[2],r=n[3],o=t[0],a=t[1];let l=pt.UNKNOWN;return o<e?l=l|pt.LEFT:o>s&&(l=l|pt.RIGHT),a<i?l=l|pt.BELOW:a>r&&(l=l|pt.ABOVE),l===pt.UNKNOWN&&(l=pt.INTERSECTING),l}function Xt(){return[1/0,1/0,-1/0,-1/0]}function Te(n,t,e,i,s){return s?(s[0]=n,s[1]=t,s[2]=e,s[3]=i,s):[n,t,e,i]}function Bn(n){return Te(1/0,1/0,-1/0,-1/0,n)}function ua(n,t){const e=n[0],i=n[1];return Te(e,i,e,i,t)}function Vs(n,t,e,i,s){const r=Bn(s);return da(r,n,t,e,i)}function ji(n,t){return n[0]==t[0]&&n[2]==t[2]&&n[1]==t[1]&&n[3]==t[3]}function Sc(n,t){return t[0]<n[0]&&(n[0]=t[0]),t[2]>n[2]&&(n[2]=t[2]),t[1]<n[1]&&(n[1]=t[1]),t[3]>n[3]&&(n[3]=t[3]),n}function Vi(n,t){t[0]<n[0]&&(n[0]=t[0]),t[0]>n[2]&&(n[2]=t[0]),t[1]<n[1]&&(n[1]=t[1]),t[1]>n[3]&&(n[3]=t[1])}function da(n,t,e,i,s){for(;e<i;e+=s)Ic(n,t[e],t[e+1]);return n}function Ic(n,t,e){n[0]=Math.min(n[0],t),n[1]=Math.min(n[1],e),n[2]=Math.max(n[2],t),n[3]=Math.max(n[3],e)}function fa(n,t){let e;return e=t(Un(n)),e||(e=t(Kn(n)),e)||(e=t(jn(n)),e)||(e=t(Ue(n)),e)?e:!1}function Zs(n){let t=0;return Vn(n)||(t=et(n)*It(n)),t}function Un(n){return[n[0],n[1]]}function Kn(n){return[n[2],n[1]]}function Ye(n){return[(n[0]+n[2])/2,(n[1]+n[3])/2]}function Tc(n,t){let e;if(t==="bottom-left")e=Un(n);else if(t==="bottom-right")e=Kn(n);else if(t==="top-left")e=Ue(n);else if(t==="top-right")e=jn(n);else throw new Error("Invalid corner");return e}function $s(n,t,e,i,s){const[r,o,a,l,h,c,u,d]=ga(n,t,e,i);return Te(Math.min(r,a,h,u),Math.min(o,l,c,d),Math.max(r,a,h,u),Math.max(o,l,c,d),s)}function ga(n,t,e,i){const s=t*i[0]/2,r=t*i[1]/2,o=Math.cos(e),a=Math.sin(e),l=s*o,h=s*a,c=r*o,u=r*a,d=n[0],f=n[1];return[d-l+u,f-h-c,d-l-u,f-h+c,d+l-u,f+h+c,d+l+u,f+h-c,d-l+u,f-h-c]}function It(n){return n[3]-n[1]}function Be(n,t,e){const i=e||Xt();return Pt(n,t)?(n[0]>t[0]?i[0]=n[0]:i[0]=t[0],n[1]>t[1]?i[1]=n[1]:i[1]=t[1],n[2]<t[2]?i[2]=n[2]:i[2]=t[2],n[3]<t[3]?i[3]=n[3]:i[3]=t[3]):Bn(i),i}function Ue(n){return[n[0],n[3]]}function jn(n){return[n[2],n[3]]}function et(n){return n[2]-n[0]}function Pt(n,t){return n[0]<=t[2]&&n[2]>=t[0]&&n[1]<=t[3]&&n[3]>=t[1]}function Vn(n){return n[2]<n[0]||n[3]<n[1]}function bc(n,t){return t?(t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t):n}function Mc(n,t,e){let i=!1;const s=js(n,t),r=js(n,e);if(s===pt.INTERSECTING||r===pt.INTERSECTING)i=!0;else{const o=n[0],a=n[1],l=n[2],h=n[3],c=t[0],u=t[1],d=e[0],f=e[1],g=(f-u)/(d-c);let m,_;r&pt.ABOVE&&!(s&pt.ABOVE)&&(m=d-(f-h)/g,i=m>=o&&m<=l),!i&&r&pt.RIGHT&&!(s&pt.RIGHT)&&(_=f-(d-l)*g,i=_>=a&&_<=h),!i&&r&pt.BELOW&&!(s&pt.BELOW)&&(m=d-(f-a)/g,i=m>=o&&m<=l),!i&&r&pt.LEFT&&!(s&pt.LEFT)&&(_=f-(d-o)*g,i=_>=a&&_<=h)}return i}function _a(n,t){const e=t.getExtent(),i=Ye(n);if(t.canWrapX()&&(i[0]<e[0]||i[0]>=e[2])){const s=et(e),o=Math.floor((i[0]-e[0])/s)*s;n[0]-=o,n[2]-=o}return n}function ma(n,t,e){if(t.canWrapX()){const i=t.getExtent();if(!isFinite(n[0])||!isFinite(n[2]))return[[i[0],n[1],i[2],n[3]]];_a(n,t);const s=et(i);if(et(n)>s&&!e)return[[i[0],n[1],i[2],n[3]]];if(n[0]<i[0])return[[n[0]+s,n[1],i[2],n[3]],[i[0],n[1],n[2],n[3]]];if(n[2]>i[2])return[[n[0],n[1],i[2],n[3]],[i[0],n[1],n[2]-s,n[3]]]}return[n]}function Lc(n,t){return n[0]+=+t[0],n[1]+=+t[1],n}function Zn(n,t){let e=!0;for(let i=n.length-1;i>=0;--i)if(n[i]!=t[i]){e=!1;break}return e}function Hs(n,t){const e=Math.cos(t),i=Math.sin(t),s=n[0]*e-n[1]*i,r=n[1]*e+n[0]*i;return n[0]=s,n[1]=r,n}function Ac(n,t){return n[0]*=t,n[1]*=t,n}function pa(n,t){if(t.canWrapX()){const e=et(t.getExtent()),i=Oc(n,t,e);i&&(n[0]-=i*e)}return n}function Oc(n,t,e){const i=t.getExtent();let s=0;return t.canWrapX()&&(n[0]<i[0]||n[0]>i[2])&&(e=e||et(i),s=Math.floor((n[0]-i[0])/e)),s}function ya(n){return Math.pow(n,3)}function ui(n){return 1-ya(1-n)}function Pc(n){return 3*n*n-2*n*n*n}function Dc(n){return n}const kc=63710088e-1;function xa(n,t,e){e=e||kc;const i=Ie(n[1]),s=Ie(t[1]),r=(s-i)/2,o=Ie(t[0]-n[0])/2,a=Math.sin(r)*Math.sin(r)+Math.sin(o)*Math.sin(o)*Math.cos(i)*Math.cos(s);return 2*e*Math.atan2(Math.sqrt(a),Math.sqrt(1-a))}function Ea(...n){console.warn(...n)}const qs={radians:6370997/(2*Math.PI),degrees:2*Math.PI*6370997/360,ft:.3048,m:1,"us-ft":1200/3937};class Js{constructor(t){this.code_=t.code,this.units_=t.units,this.extent_=t.extent!==void 0?t.extent:null,this.worldExtent_=t.worldExtent!==void 0?t.worldExtent:null,this.axisOrientation_=t.axisOrientation!==void 0?t.axisOrientation:"enu",this.global_=t.global!==void 0?t.global:!1,this.canWrapX_=!!(this.global_&&this.extent_),this.getPointResolutionFunc_=t.getPointResolution,this.defaultTileGrid_=null,this.metersPerUnit_=t.metersPerUnit}canWrapX(){return this.canWrapX_}getCode(){return this.code_}getExtent(){return this.extent_}getUnits(){return this.units_}getMetersPerUnit(){return this.metersPerUnit_||qs[this.units_]}getWorldExtent(){return this.worldExtent_}getAxisOrientation(){return this.axisOrientation_}isGlobal(){return this.global_}setGlobal(t){this.global_=t,this.canWrapX_=!!(t&&this.extent_)}getDefaultTileGrid(){return this.defaultTileGrid_}setDefaultTileGrid(t){this.defaultTileGrid_=t}setExtent(t){this.extent_=t,this.canWrapX_=!!(this.global_&&t)}setWorldExtent(t){this.worldExtent_=t}setGetPointResolution(t){this.getPointResolutionFunc_=t}getPointResolutionFunc(){return this.getPointResolutionFunc_}}const Zi=6378137,di=Math.PI*Zi,Fc=[-di,-di,di,di],Nc=[-180,-85,180,85],$n=Zi*Math.log(Math.tan(Math.PI/2));class fi extends Js{constructor(t){super({code:t,units:"m",extent:Fc,global:!0,worldExtent:Nc,getPointResolution:function(e,i){return e/Math.cosh(i[1]/Zi)}})}}const wa=[new fi("EPSG:3857"),new fi("EPSG:102100"),new fi("EPSG:102113"),new fi("EPSG:900913"),new fi("http://www.opengis.net/def/crs/EPSG/0/3857"),new fi("http://www.opengis.net/gml/srs/epsg.xml#3857")];function zc(n,t,e,i){const s=n.length;e=e>1?e:2,i=i??e,t===void 0&&(e>2?t=n.slice():t=new Array(s));for(let r=0;r<s;r+=i){t[r]=di*n[r]/180;let o=Zi*Math.log(Math.tan(Math.PI*(+n[r+1]+90)/360));o>$n?o=$n:o<-$n&&(o=-$n),t[r+1]=o}return t}function Gc(n,t,e,i){const s=n.length;e=e>1?e:2,i=i??e,t===void 0&&(e>2?t=n.slice():t=new Array(s));for(let r=0;r<s;r+=i)t[r]=180*n[r]/di,t[r+1]=360*Math.atan(Math.exp(n[r+1]/Zi))/Math.PI-90;return t}const Wc=6378137,va=[-180,-90,180,90],Xc=Math.PI*Wc/180;class Ke extends Js{constructor(t,e){super({code:t,units:"degrees",extent:va,axisOrientation:e,global:!0,metersPerUnit:Xc,worldExtent:va})}}const Ca=[new Ke("CRS:84"),new Ke("EPSG:4326","neu"),new Ke("urn:ogc:def:crs:OGC:1.3:CRS84"),new Ke("urn:ogc:def:crs:OGC:2:84"),new Ke("http://www.opengis.net/def/crs/OGC/1.3/CRS84"),new Ke("http://www.opengis.net/gml/srs/epsg.xml#4326","neu"),new Ke("http://www.opengis.net/def/crs/EPSG/0/4326","neu")];let Qs={};function Yc(n){return Qs[n]||Qs[n.replace(/urn:(x-)?ogc:def:crs:EPSG:(.*:)?(\w+)$/,"EPSG:$3")]||null}function Bc(n,t){Qs[n]=t}let gi={};function $i(n,t,e){const i=n.getCode(),s=t.getCode();i in gi||(gi[i]={}),gi[i][s]=e}function tr(n,t){return n in gi&&t in gi[n]?gi[n][t]:null}const Hn=.9996,Yt=.00669438,qn=Yt*Yt,Jn=qn*Yt,je=Yt/(1-Yt),Ra=Math.sqrt(1-Yt),_i=(1-Ra)/(1+Ra),Sa=_i*_i,er=Sa*_i,ir=er*_i,Ia=ir*_i,Ta=1-Yt/4-3*qn/64-5*Jn/256,Uc=3*Yt/8+3*qn/32+45*Jn/1024,Kc=15*qn/256+45*Jn/1024,jc=35*Jn/3072,Vc=3/2*_i-27/32*er+269/512*Ia,Zc=21/16*Sa-55/32*ir,$c=151/96*er-417/128*Ia,Hc=1097/512*ir,Qn=6378137;function qc(n,t,e){const i=n-5e5,o=(e.north?t:t-1e7)/Hn/(Qn*Ta),a=o+Vc*Math.sin(2*o)+Zc*Math.sin(4*o)+$c*Math.sin(6*o)+Hc*Math.sin(8*o),l=Math.sin(a),h=l*l,c=Math.cos(a),u=l/c,d=u*u,f=d*d,g=1-Yt*h,m=Math.sqrt(1-Yt*h),_=Qn/m,p=(1-Yt)/g,y=je*c**2,v=y*y,x=i/(_*Hn),w=x*x,R=w*x,T=R*x,S=T*x,I=S*x,M=a-u/p*(w/2-T/24*(5+3*d+10*y-4*v-9*je))+I/720*(61+90*d+298*y+45*f-252*je-3*v);let O=(x-R/6*(1+2*d+y)+S/120*(5-2*y+28*d-3*v+8*je+24*f))/c;return O=Us(O+Ie(La(e.number)),-Math.PI,Math.PI),[ra(O),ra(M)]}const ba=-80,Ma=84,Jc=-180,Qc=180;function tu(n,t,e){n=Us(n,Jc,Qc),t<ba?t=ba:t>Ma&&(t=Ma);const i=Ie(t),s=Math.sin(i),r=Math.cos(i),o=s/r,a=o*o,l=a*a,h=Ie(n),c=La(e.number),u=Ie(c),d=Qn/Math.sqrt(1-Yt*s**2),f=je*r**2,g=r*Us(h-u,-Math.PI,Math.PI),m=g*g,_=m*g,p=_*g,y=p*g,v=y*g,x=Qn*(Ta*i-Uc*Math.sin(2*i)+Kc*Math.sin(4*i)-jc*Math.sin(6*i)),w=Hn*d*(g+_/6*(1-a+f)+y/120*(5-18*a+l+72*f-58*je))+5e5;let R=Hn*(x+d*o*(m/2+p/24*(5-a+9*f+4*f**2)+v/720*(61-58*a+l+600*f-330*je)));return e.north||(R+=1e7),[w,R]}function La(n){return(n-1)*6-180+3}const eu=[/^EPSG:(\d+)$/,/^urn:ogc:def:crs:EPSG::(\d+)$/,/^http:\/\/www\.opengis\.net\/def\/crs\/EPSG\/0\/(\d+)$/];function Aa(n){let t=0;for(const s of eu){const r=n.match(s);if(r){t=parseInt(r[1]);break}}if(!t)return null;let e=0,i=!1;return t>32700&&t<32761?e=t-32700:t>32600&&t<32661&&(i=!0,e=t-32600),e?{number:e,north:i}:null}function Oa(n,t){return function(e,i,s,r){const o=e.length;s=s>1?s:2,r=r??s,i||(s>2?i=e.slice():i=new Array(o));for(let a=0;a<o;a+=r){const l=e[a],h=e[a+1],c=n(l,h,t);i[a]=c[0],i[a+1]=c[1]}return i}}function iu(n){return Aa(n)?new Js({code:n,units:"m"}):null}function nu(n){const t=Aa(n.getCode());return t?{forward:Oa(tu,t),inverse:Oa(qc,t)}:null}const su=[nu],ru=[iu];let nr=!0;function Pa(n){nr=!1}function sr(n,t){if(t!==void 0){for(let e=0,i=n.length;e<i;++e)t[e]=n[e];t=t}else t=n.slice();return t}function rr(n){Bc(n.getCode(),n),$i(n,n,sr)}function ou(n){n.forEach(rr)}function Dt(n){if(typeof n!="string")return n;const t=Yc(n);if(t)return t;for(const e of ru){const i=e(n);if(i)return i}return null}function Da(n,t,e,i){n=Dt(n);let s;const r=n.getPointResolutionFunc();if(r)s=r(t,e);else{const o=n.getUnits();if(o=="degrees"&&!i||i=="degrees")s=t;else{const a=lr(n,Dt("EPSG:4326"));if(!a&&o!=="degrees")s=t*n.getMetersPerUnit();else{let h=[e[0]-t/2,e[1],e[0]+t/2,e[1],e[0],e[1]-t/2,e[0],e[1]+t/2];h=a(h,h,2);const c=xa(h.slice(0,2),h.slice(2,4)),u=xa(h.slice(4,6),h.slice(6,8));s=(c+u)/2}const l=n.getMetersPerUnit();l!==void 0&&(s/=l)}}return s}function ka(n){ou(n),n.forEach(function(t){n.forEach(function(e){t!==e&&$i(t,e,sr)})})}function au(n,t,e,i){n.forEach(function(s){t.forEach(function(r){$i(s,r,e),$i(r,s,i)})})}function or(n,t){return n?typeof n=="string"?Dt(n):n:Dt(t)}function lu(n){return(function(t,e,i,s){const r=t.length;i=i!==void 0?i:2,s=s??i,e=e!==void 0?e:new Array(r);for(let o=0;o<r;o+=s){const a=n(t.slice(o,o+i)),l=a.length;for(let h=0,c=s;h<c;++h)e[o+h]=h>=l?t[o+h]:a[h]}return e})}function hu(n,t){return Pa(),cr(n,"EPSG:4326","EPSG:3857")}function ar(n,t){if(n===t)return!0;const e=n.getUnits()===t.getUnits();return(n.getCode()===t.getCode()||lr(n,t)===sr)&&e}function lr(n,t){const e=n.getCode(),i=t.getCode();let s=tr(e,i);if(s)return s;let r=null,o=null;for(const l of su)r||(r=l(n)),o||(o=l(t));if(!r&&!o)return null;const a="EPSG:4326";if(o)if(r)s=hr(r.inverse,o.forward);else{const l=tr(e,a);l&&(s=hr(l,o.forward))}else{const l=tr(a,i);l&&(s=hr(r.inverse,l))}return s&&(rr(n),rr(t),$i(n,t,s)),s}function hr(n,t){return function(e,i,s,r){return i=n(e,i,s,r),t(i,i,s,r)}}function ts(n,t){const e=Dt(n),i=Dt(t);return lr(e,i)}function cr(n,t,e){const i=ts(t,e);if(!i){const s=Dt(t).getCode(),r=Dt(e).getCode();throw new Error(`No transform available between ${s} and ${r}`)}return i(n,void 0,n.length)}function ur(n,t){return n}function de(n,t){return nr&&!Zn(n,[0,0])&&n[0]>=-180&&n[0]<=180&&n[1]>=-90&&n[1]<=90&&(nr=!1,Ea("Call useGeographic() from ol/proj once to work with [longitude, latitude] coordinates.")),n}function Fa(n,t){return n}function be(n,t){return n}function cu(){ka(wa),ka(Ca),au(Ca,wa,zc,Gc)}cu(),new Array(6);function qt(){return[1,0,0,1,0,0]}function uu(n,t){return n[0]=t[0],n[1]=t[1],n[2]=t[2],n[3]=t[3],n[4]=t[4],n[5]=t[5],n}function yt(n,t){const e=t[0],i=t[1];return t[0]=n[0]*e+n[2]*i+n[4],t[1]=n[1]*e+n[3]*i+n[5],t}function fe(n,t,e,i,s,r,o,a){const l=Math.sin(r),h=Math.cos(r);return n[0]=i*h,n[1]=s*l,n[2]=-i*l,n[3]=s*h,n[4]=o*i*h-a*i*l+t,n[5]=o*s*l+a*s*h+e,n}function Na(n,t){const e=du(t);Q(e!==0,"Transformation matrix cannot be inverted");const i=t[0],s=t[1],r=t[2],o=t[3],a=t[4],l=t[5];return n[0]=o/e,n[1]=-s/e,n[2]=-r/e,n[3]=i/e,n[4]=(r*l-o*a)/e,n[5]=-(i*l-s*a)/e,n}function du(n){return n[0]*n[3]-n[1]*n[2]}const fu=[1e5,1e5,1e5,1e5,2,2];function gu(n){return"matrix("+n.join(", ")+")"}function za(n){return n.substring(7,n.length-1).split(",").map(parseFloat)}function _u(n,t){const e=za(n),i=za(t);for(let s=0;s<6;++s)if(Math.round((e[s]-i[s])*fu[s])!==0)return!1;return!0}function Me(n,t,e,i,s,r,o){r=r||[],o=o||2;let a=0;for(let l=t;l<e;l+=i){const h=n[l],c=n[l+1];r[a++]=s[0]*h+s[2]*c+s[4],r[a++]=s[1]*h+s[3]*c+s[5];for(let u=2;u<o;u++)r[a++]=n[l+u]}return r&&r.length!=a&&(r.length=a),r}function Ga(n,t,e,i,s,r,o){o=o||[];const a=Math.cos(s),l=Math.sin(s),h=r[0],c=r[1];let u=0;for(let d=t;d<e;d+=i){const f=n[d]-h,g=n[d+1]-c;o[u++]=h+f*a-g*l,o[u++]=c+f*l+g*a;for(let m=d+2;m<d+i;++m)o[u++]=n[m]}return o&&o.length!=u&&(o.length=u),o}function mu(n,t,e,i,s,r,o,a){a=a||[];const l=o[0],h=o[1];let c=0;for(let u=t;u<e;u+=i){const d=n[u]-l,f=n[u+1]-h;a[c++]=l+s*d,a[c++]=h+r*f;for(let g=u+2;g<u+i;++g)a[c++]=n[g]}return a&&a.length!=c&&(a.length=c),a}function pu(n,t,e,i,s,r,o){o=o||[];let a=0;for(let l=t;l<e;l+=i){o[a++]=n[l]+s,o[a++]=n[l+1]+r;for(let h=l+2;h<l+i;++h)o[a++]=n[h]}return o&&o.length!=a&&(o.length=a),o}const Wa=qt(),yu=[NaN,NaN];class xu extends ne{constructor(){super(),this.extent_=Xt(),this.extentRevision_=-1,this.simplifiedGeometryMaxMinSquaredTolerance=0,this.simplifiedGeometryRevision=0,this.simplifyTransformedInternal=Qo((t,e,i)=>{if(!i)return this.getSimplifiedGeometry(e);const s=this.clone();return s.applyTransform(i),s.getSimplifiedGeometry(e)})}simplifyTransformed(t,e){return this.simplifyTransformedInternal(this.getRevision(),t,e)}clone(){return H()}closestPointXY(t,e,i,s){return H()}containsXY(t,e){return this.closestPointXY(t,e,yu,Number.MIN_VALUE)===0}getClosestPoint(t,e){return e=e||[NaN,NaN],this.closestPointXY(t[0],t[1],e,1/0),e}intersectsCoordinate(t){return this.containsXY(t[0],t[1])}computeExtent(t){return H()}getExtent(t){if(this.extentRevision_!=this.getRevision()){const e=this.computeExtent(this.extent_);(isNaN(e[0])||isNaN(e[1]))&&Bn(e),this.extentRevision_=this.getRevision()}return bc(this.extent_,t)}rotate(t,e){H()}scale(t,e,i){H()}simplify(t){return this.getSimplifiedGeometry(t*t)}getSimplifiedGeometry(t){return H()}getType(){return H()}applyTransform(t){H()}intersectsExtent(t){return H()}translate(t,e){H()}transform(t,e){const i=Dt(t),s=i.getUnits()=="tile-pixels"?function(r,o,a){const l=i.getExtent(),h=i.getWorldExtent(),c=It(h)/It(l);fe(Wa,h[0],h[3],c,-c,0,0,0);const u=Me(r,0,r.length,a,Wa,o),d=ts(i,e);return d?d(u,u,a):u}:ts(i,e);return this.applyTransform(s),this}}class dr extends xu{constructor(){super(),this.layout="XY",this.stride=2,this.flatCoordinates}computeExtent(t){return Vs(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t)}getCoordinates(){return H()}getFirstCoordinate(){return this.flatCoordinates.slice(0,this.stride)}getFlatCoordinates(){return this.flatCoordinates}getLastCoordinate(){return this.flatCoordinates.slice(this.flatCoordinates.length-this.stride)}getLayout(){return this.layout}getSimplifiedGeometry(t){if(this.simplifiedGeometryRevision!==this.getRevision()&&(this.simplifiedGeometryMaxMinSquaredTolerance=0,this.simplifiedGeometryRevision=this.getRevision()),t<0||this.simplifiedGeometryMaxMinSquaredTolerance!==0&&t<=this.simplifiedGeometryMaxMinSquaredTolerance)return this;const e=this.getSimplifiedGeometryInternal(t);return e.getFlatCoordinates().length<this.flatCoordinates.length?e:(this.simplifiedGeometryMaxMinSquaredTolerance=t,this)}getSimplifiedGeometryInternal(t){return this}getStride(){return this.stride}setFlatCoordinates(t,e){this.stride=Xa(t),this.layout=t,this.flatCoordinates=e}setCoordinates(t,e){H()}setLayout(t,e,i){let s;if(t)s=Xa(t);else{for(let r=0;r<i;++r){if(e.length===0){this.layout="XY",this.stride=2;return}e=e[0]}s=e.length,t=Eu(s)}this.layout=t,this.stride=s}applyTransform(t){this.flatCoordinates&&(t(this.flatCoordinates,this.flatCoordinates,this.layout.startsWith("XYZ")?3:2,this.stride),this.changed())}rotate(t,e){const i=this.getFlatCoordinates();if(i){const s=this.getStride();Ga(i,0,i.length,s,t,e,i),this.changed()}}scale(t,e,i){e===void 0&&(e=t),i||(i=Ye(this.getExtent()));const s=this.getFlatCoordinates();if(s){const r=this.getStride();mu(s,0,s.length,r,t,e,i,s),this.changed()}}translate(t,e){const i=this.getFlatCoordinates();if(i){const s=this.getStride();pu(i,0,i.length,s,t,e,i),this.changed()}}}function Eu(n){let t;return n==2?t="XY":n==3?t="XYZ":n==4&&(t="XYZM"),t}function Xa(n){let t;return n=="XY"?t=2:n=="XYZ"||n=="XYM"?t=3:n=="XYZM"&&(t=4),t}function wu(n,t,e){const i=n.getFlatCoordinates();if(!i)return null;const s=n.getStride();return Me(i,0,i.length,s,t,e)}function Ya(n,t,e,i){let s=0;const r=n[e-i],o=n[e-i+1];let a=0,l=0;for(;t<e;t+=i){const h=n[t]-r,c=n[t+1]-o;s+=l*h-a*c,a=h,l=c}return s/2}function vu(n,t,e,i){let s=0;for(let r=0,o=e.length;r<o;++r){const a=e[r];s+=Ya(n,t,a,i),t=a}return s}function Ba(n,t,e,i,s,r,o){const a=n[t],l=n[t+1],h=n[e]-a,c=n[e+1]-l;let u;if(h===0&&c===0)u=t;else{const d=((s-a)*h+(r-l)*c)/(h*h+c*c);if(d>1)u=e;else if(d>0){for(let f=0;f<i;++f)o[f]=Wt(n[t+f],n[e+f],d);o.length=i;return}else u=t}for(let d=0;d<i;++d)o[d]=n[u+d];o.length=i}function Ua(n,t,e,i,s){let r=n[t],o=n[t+1];for(t+=i;t<e;t+=i){const a=n[t],l=n[t+1],h=li(r,o,a,l);h>s&&(s=h),r=a,o=l}return s}function Cu(n,t,e,i,s){for(let r=0,o=e.length;r<o;++r){const a=e[r];s=Ua(n,t,a,i,s),t=a}return s}function Ka(n,t,e,i,s,r,o,a,l,h,c){if(t==e)return h;let u,d;if(s===0){if(d=li(o,a,n[t],n[t+1]),d<h){for(u=0;u<i;++u)l[u]=n[t+u];return l.length=i,d}return h}c=c||[NaN,NaN];let f=t+i;for(;f<e;)if(Ba(n,f-i,f,i,o,a,c),d=li(o,a,c[0],c[1]),d<h){for(h=d,u=0;u<i;++u)l[u]=c[u];l.length=i,f+=i}else f+=i*Math.max((Math.sqrt(d)-Math.sqrt(h))/s|0,1);if(Ba(n,e-i,t,i,o,a,c),d=li(o,a,c[0],c[1]),d<h){for(h=d,u=0;u<i;++u)l[u]=c[u];l.length=i}return h}function Ru(n,t,e,i,s,r,o,a,l,h,c){c=c||[NaN,NaN];for(let u=0,d=e.length;u<d;++u){const f=e[u];h=Ka(n,t,f,i,s,r,o,a,l,h,c),t=f}return h}function Su(n,t,e,i){for(let s=0,r=e.length;s<r;++s)n[t++]=e[s];return t}function ja(n,t,e,i){for(let s=0,r=e.length;s<r;++s){const o=e[s];for(let a=0;a<i;++a)n[t++]=o[a]}return t}function Iu(n,t,e,i,s){s=s||[];let r=0;for(let o=0,a=e.length;o<a;++o){const l=ja(n,t,e[o],i);s[r++]=l,t=l}return s.length=r,s}function mi(n,t,e,i,s){s=s!==void 0?s:[];let r=0;for(let o=t;o<e;o+=i)s[r++]=n.slice(o,o+i);return s.length=r,s}function es(n,t,e,i,s){s=s!==void 0?s:[];let r=0;for(let o=0,a=e.length;o<a;++o){const l=e[o];s[r++]=mi(n,t,l,i,s[r]),t=l}return s.length=r,s}function Va(n,t,e,i,s){s=s!==void 0?s:[];let r=0;for(let o=0,a=e.length;o<a;++o){const l=e[o];s[r++]=l.length===1&&l[0]===t?[]:es(n,t,l,i,s[r]),t=l[l.length-1]}return s.length=r,s}function fr(n,t,e,i,s,r,o){const a=(e-t)/i;if(a<3){for(;t<e;t+=i)r[o++]=n[t],r[o++]=n[t+1];return o}const l=new Array(a);l[0]=1,l[a-1]=1;const h=[t,e-i];let c=0;for(;h.length>0;){const u=h.pop(),d=h.pop();let f=0;const g=n[d],m=n[d+1],_=n[u],p=n[u+1];for(let y=d+i;y<u;y+=i){const v=n[y],x=n[y+1],w=vc(v,x,g,m,_,p);w>f&&(c=y,f=w)}f>s&&(l[(c-t)/i]=1,d+i<c&&h.push(d,c),c+i<u&&h.push(c,u))}for(let u=0;u<a;++u)l[u]&&(r[o++]=n[t+u*i],r[o++]=n[t+u*i+1]);return o}function Tu(n,t,e,i,s,r,o,a){for(let l=0,h=e.length;l<h;++l){const c=e[l];o=fr(n,t,c,i,s,r,o),a.push(o),t=c}return o}function Ve(n,t){return t*Math.round(n/t)}function bu(n,t,e,i,s,r,o){if(t==e)return o;let a=Ve(n[t],s),l=Ve(n[t+1],s);t+=i,r[o++]=a,r[o++]=l;let h,c;do if(h=Ve(n[t],s),c=Ve(n[t+1],s),t+=i,t==e)return r[o++]=h,r[o++]=c,o;while(h==a&&c==l);for(;t<e;){const u=Ve(n[t],s),d=Ve(n[t+1],s);if(t+=i,u==h&&d==c)continue;const f=h-a,g=c-l,m=u-a,_=d-l;if(f*_==g*m&&(f<0&&m<f||f==m||f>0&&m>f)&&(g<0&&_<g||g==_||g>0&&_>g)){h=u,c=d;continue}r[o++]=h,r[o++]=c,a=h,l=c,h=u,c=d}return r[o++]=h,r[o++]=c,o}function Za(n,t,e,i,s,r,o,a){for(let l=0,h=e.length;l<h;++l){const c=e[l];o=bu(n,t,c,i,s,r,o),a.push(o),t=c}return o}class Hi extends dr{constructor(t,e){super(),this.maxDelta_=-1,this.maxDeltaRevision_=-1,e!==void 0&&!Array.isArray(t[0])?this.setFlatCoordinates(e,t):this.setCoordinates(t,e)}clone(){return new Hi(this.flatCoordinates.slice(),this.layout)}closestPointXY(t,e,i,s){return s<ha(this.getExtent(),t,e)?s:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(Ua(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),Ka(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,this.maxDelta_,!0,t,e,i,s))}getArea(){return Ya(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getCoordinates(){return mi(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getSimplifiedGeometryInternal(t){const e=[];return e.length=fr(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t,e,0),new Hi(e,"XY")}getType(){return"LinearRing"}intersectsExtent(t){return!1}setCoordinates(t,e){this.setLayout(e,t,1),this.flatCoordinates||(this.flatCoordinates=[]),this.flatCoordinates.length=ja(this.flatCoordinates,0,t,this.stride),this.changed()}}class is extends dr{constructor(t,e){super(),this.setCoordinates(t,e)}clone(){const t=new is(this.flatCoordinates.slice(),this.layout);return t.applyProperties(this),t}closestPointXY(t,e,i,s){const r=this.flatCoordinates,o=li(t,e,r[0],r[1]);if(o<s){const a=this.stride;for(let l=0;l<a;++l)i[l]=r[l];return i.length=a,o}return s}getCoordinates(){return this.flatCoordinates.slice()}computeExtent(t){return ua(this.flatCoordinates,t)}getType(){return"Point"}intersectsExtent(t){return ca(t,this.flatCoordinates[0],this.flatCoordinates[1])}setCoordinates(t,e){this.setLayout(e,t,0),this.flatCoordinates||(this.flatCoordinates=[]),this.flatCoordinates.length=Su(this.flatCoordinates,0,t,this.stride),this.changed()}}function Mu(n,t,e,i,s){return!fa(s,function(o){return!Ze(n,t,e,i,o[0],o[1])})}function Ze(n,t,e,i,s,r){let o=0,a=n[e-i],l=n[e-i+1];for(;t<e;t+=i){const h=n[t],c=n[t+1];l<=r?c>r&&(h-a)*(r-l)-(s-a)*(c-l)>0&&o++:c<=r&&(h-a)*(r-l)-(s-a)*(c-l)<0&&o--,a=h,l=c}return o!==0}function $a(n,t,e,i,s,r){if(e.length===0||!Ze(n,t,e[0],i,s,r))return!1;for(let o=1,a=e.length;o<a;++o)if(Ze(n,e[o-1],e[o],i,s,r))return!1;return!0}function gr(n,t,e,i,s,r,o){let a,l,h,c,u,d,f;const g=s[r+1],m=[];for(let y=0,v=e.length;y<v;++y){const x=e[y];for(c=n[x-i],d=n[x-i+1],a=t;a<x;a+=i)u=n[a],f=n[a+1],(g<=d&&f<=g||d<=g&&g<=f)&&(h=(g-d)/(f-d)*(u-c)+c,m.push(h)),c=u,d=f}let _=NaN,p=-1/0;for(m.sort(ce),c=m[0],a=1,l=m.length;a<l;++a){u=m[a];const y=Math.abs(u-c);y>p&&(h=(c+u)/2,$a(n,t,e,i,h,g)&&(_=h,p=y)),c=u}return isNaN(_)&&(_=s[r]),o?(o.push(_,g,p),o):[_,g,p]}function Lu(n,t,e,i,s){let r=[];for(let o=0,a=e.length;o<a;++o){const l=e[o];r=gr(n,t,l,i,s,2*o,r),t=l[l.length-1]}return r}function Au(n,t,e,i,s){let r;for(t+=i;t<e;t+=i)if(r=s(n.slice(t-i,t),n.slice(t,t+i)),r)return r;return!1}function Ha(n,t,e,i,s,r){return r=r??da(Xt(),n,t,e,i),Pt(s,r)?r[0]>=s[0]&&r[2]<=s[2]||r[1]>=s[1]&&r[3]<=s[3]?!0:Au(n,t,e,i,function(o,a){return Mc(s,o,a)}):!1}function qa(n,t,e,i,s){return!!(Ha(n,t,e,i,s)||Ze(n,t,e,i,s[0],s[1])||Ze(n,t,e,i,s[0],s[3])||Ze(n,t,e,i,s[2],s[1])||Ze(n,t,e,i,s[2],s[3]))}function Ou(n,t,e,i,s){if(!qa(n,t,e[0],i,s))return!1;if(e.length===1)return!0;for(let r=1,o=e.length;r<o;++r)if(Mu(n,e[r-1],e[r],i,s)&&!Ha(n,e[r-1],e[r],i,s))return!1;return!0}function Pu(n,t,e,i){for(;t<e-i;){for(let s=0;s<i;++s){const r=n[t+s];n[t+s]=n[e-i+s],n[e-i+s]=r}t+=i,e-=i}}function _r(n,t,e,i){let s=0,r=n[e-i],o=n[e-i+1];for(;t<e;t+=i){const a=n[t],l=n[t+1];s+=(a-r)*(l+o),r=a,o=l}return s===0?void 0:s>0}function Du(n,t,e,i,s){s=s!==void 0?s:!1;for(let r=0,o=e.length;r<o;++r){const a=e[r],l=_r(n,t,a,i);if(r===0){if(s&&l||!s&&!l)return!1}else if(s&&!l||!s&&l)return!1;t=a}return!0}function Ja(n,t,e,i,s){s=s!==void 0?s:!1;for(let r=0,o=e.length;r<o;++r){const a=e[r],l=_r(n,t,a,i);(r===0?s&&l||!s&&!l:s&&!l||!s&&l)&&Pu(n,t,a,i),t=a}return t}function ku(n,t){const e=[];let i=0,s=0,r;for(let o=0,a=t.length;o<a;++o){const l=t[o],h=_r(n,i,l,2);if(r===void 0&&(r=h),h===r)e.push(t.slice(s,o+1));else{if(e.length===0)continue;e[e.length-1].push(t[s])}s=o+1,i=l}return e}class qi extends dr{constructor(t,e,i){super(),this.ends_=[],this.flatInteriorPointRevision_=-1,this.flatInteriorPoint_=null,this.maxDelta_=-1,this.maxDeltaRevision_=-1,this.orientedRevision_=-1,this.orientedFlatCoordinates_=null,e!==void 0&&i?(this.setFlatCoordinates(e,t),this.ends_=i):this.setCoordinates(t,e)}appendLinearRing(t){this.flatCoordinates?Xs(this.flatCoordinates,t.getFlatCoordinates()):this.flatCoordinates=t.getFlatCoordinates().slice(),this.ends_.push(this.flatCoordinates.length),this.changed()}clone(){const t=new qi(this.flatCoordinates.slice(),this.layout,this.ends_.slice());return t.applyProperties(this),t}closestPointXY(t,e,i,s){return s<ha(this.getExtent(),t,e)?s:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(Cu(this.flatCoordinates,0,this.ends_,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),Ru(this.flatCoordinates,0,this.ends_,this.stride,this.maxDelta_,!0,t,e,i,s))}containsXY(t,e){return $a(this.getOrientedFlatCoordinates(),0,this.ends_,this.stride,t,e)}getArea(){return vu(this.getOrientedFlatCoordinates(),0,this.ends_,this.stride)}getCoordinates(t){let e;return t!==void 0?(e=this.getOrientedFlatCoordinates().slice(),Ja(e,0,this.ends_,this.stride,t)):e=this.flatCoordinates,es(e,0,this.ends_,this.stride)}getEnds(){return this.ends_}getFlatInteriorPoint(){if(this.flatInteriorPointRevision_!=this.getRevision()){const t=Ye(this.getExtent());this.flatInteriorPoint_=gr(this.getOrientedFlatCoordinates(),0,this.ends_,this.stride,t,0),this.flatInteriorPointRevision_=this.getRevision()}return this.flatInteriorPoint_}getInteriorPoint(){return new is(this.getFlatInteriorPoint(),"XYM")}getLinearRingCount(){return this.ends_.length}getLinearRing(t){return t<0||this.ends_.length<=t?null:new Hi(this.flatCoordinates.slice(t===0?0:this.ends_[t-1],this.ends_[t]),this.layout)}getLinearRings(){const t=this.layout,e=this.flatCoordinates,i=this.ends_,s=[];let r=0;for(let o=0,a=i.length;o<a;++o){const l=i[o],h=new Hi(e.slice(r,l),t);s.push(h),r=l}return s}getOrientedFlatCoordinates(){if(this.orientedRevision_!=this.getRevision()){const t=this.flatCoordinates;Du(t,0,this.ends_,this.stride)?this.orientedFlatCoordinates_=t:(this.orientedFlatCoordinates_=t.slice(),this.orientedFlatCoordinates_.length=Ja(this.orientedFlatCoordinates_,0,this.ends_,this.stride)),this.orientedRevision_=this.getRevision()}return this.orientedFlatCoordinates_}getSimplifiedGeometryInternal(t){const e=[],i=[];return e.length=Za(this.flatCoordinates,0,this.ends_,this.stride,Math.sqrt(t),e,0,i),new qi(e,"XY",i)}getType(){return"Polygon"}intersectsExtent(t){return Ou(this.getOrientedFlatCoordinates(),0,this.ends_,this.stride,t)}setCoordinates(t,e){this.setLayout(e,t,2),this.flatCoordinates||(this.flatCoordinates=[]);const i=Iu(this.flatCoordinates,0,t,this.stride,this.ends_);this.flatCoordinates.length=i.length===0?0:i[i.length-1],this.changed()}}function Qa(n){if(Vn(n))throw new Error("Cannot create polygon from empty extent");const t=n[0],e=n[1],i=n[2],s=n[3],r=[t,e,t,s,i,s,i,e,t,e];return new qi(r,"XY",[r.length])}function mr(n,t,e,i){const s=et(t)/e[0],r=It(t)/e[1];return i?Math.min(n,Math.max(s,r)):Math.min(n,Math.min(s,r))}function pr(n,t,e){let i=Math.min(n,t);const s=50;return i*=Math.log(1+s*Math.max(0,n/t-1))/s+1,e&&(i=Math.max(i,e),i/=Math.log(1+s*Math.max(0,e/n-1))/s+1),lt(i,e/2,t*2)}function Fu(n,t,e,i){return t=t!==void 0?t:!0,(function(s,r,o,a){if(s!==void 0){const l=n[0],h=n[n.length-1],c=e?mr(l,e,o,i):l;if(a)return t?pr(s,c,h):lt(s,h,c);const u=Math.min(c,s),d=Math.floor(Ws(n,u,r));return n[d]>c&&d<n.length-1?n[d+1]:n[d]}})}function Nu(n,t,e,i,s,r){return i=i!==void 0?i:!0,e=e!==void 0?e:0,(function(o,a,l,h){if(o!==void 0){const c=s?mr(t,s,l,r):t;if(h)return i?pr(o,c,e):lt(o,e,c);const u=1e-9,d=Math.ceil(Math.log(t/c)/Math.log(n)-u),f=-a*(.5-u)+.5,g=Math.min(c,o),m=Math.floor(Math.log(t/g)/Math.log(n)+f),_=Math.max(d,m),p=t/Math.pow(n,_);return lt(p,e,c)}})}function tl(n,t,e,i,s){return e=e!==void 0?e:!0,(function(r,o,a,l){if(r!==void 0){const h=i?mr(n,i,a,s):n;return!e||!l?lt(r,t,h):pr(r,h,t)}})}function yr(n){if(n!==void 0)return 0}function el(n){if(n!==void 0)return n}function zu(n){const t=2*Math.PI/n;return(function(e,i){if(i)return e;if(e!==void 0)return e=Math.floor(e/t+.5)*t,e})}function Gu(n){const t=Ie(5);return(function(e,i){return i||e===void 0?e:Math.abs(e)<=t?0:e})}const Wu=42,xr=256,Er=0;class re extends ne{constructor(t){super(),this.on,this.once,this.un,t=Object.assign({},t),this.hints_=[0,0],this.animations_=[],this.updateAnimationKey_,this.projection_=or(t.projection,"EPSG:3857"),this.viewportSize_=[100,100],this.targetCenter_=null,this.targetResolution_,this.targetRotation_,this.nextCenter_=null,this.nextResolution_,this.nextRotation_,this.cancelAnchor_=void 0,t.projection&&Pa(),t.center&&(t.center=de(t.center,this.projection_)),t.extent&&(t.extent=be(t.extent,this.projection_)),this.applyOptions_(t)}applyOptions_(t){const e=Object.assign({},t);for(const a in Ht)delete e[a];this.setProperties(e,!0);const i=Yu(t);this.maxResolution_=i.maxResolution,this.minResolution_=i.minResolution,this.zoomFactor_=i.zoomFactor,this.resolutions_=t.resolutions,this.padding_=t.padding,this.minZoom_=i.minZoom;const s=Xu(t),r=i.constraint,o=Bu(t);this.constraints_={center:s,resolution:r,rotation:o},this.setRotation(t.rotation!==void 0?t.rotation:0),this.setCenterInternal(t.center!==void 0?t.center:null),t.resolution!==void 0?this.setResolution(t.resolution):t.zoom!==void 0&&this.setZoom(t.zoom)}get padding(){return this.padding_}set padding(t){let e=this.padding_;this.padding_=t;const i=this.getCenterInternal();if(i){const s=t||[0,0,0,0];e=e||[0,0,0,0];const r=this.getResolution(),o=r/2*(s[3]-e[3]+e[1]-s[1]),a=r/2*(s[0]-e[0]+e[2]-s[2]);this.setCenterInternal([i[0]+o,i[1]-a])}}getUpdatedOptions_(t){const e=this.getProperties();return e.resolution!==void 0?e.resolution=this.getResolution():e.zoom=this.getZoom(),e.center=this.getCenterInternal(),e.rotation=this.getRotation(),Object.assign({},e,t)}animate(t){this.isDef()&&!this.getAnimating()&&this.resolveConstraints(0);const e=new Array(arguments.length);for(let i=0;i<e.length;++i){let s=arguments[i];s.center&&(s=Object.assign({},s),s.center=de(s.center,this.getProjection())),s.anchor&&(s=Object.assign({},s),s.anchor=de(s.anchor,this.getProjection())),e[i]=s}this.animateInternal.apply(this,e)}animateInternal(t){let e=arguments.length,i;e>1&&typeof arguments[e-1]=="function"&&(i=arguments[e-1],--e);let s=0;for(;s<e&&!this.isDef();++s){const c=arguments[s];c.center&&this.setCenterInternal(c.center),c.zoom!==void 0?this.setZoom(c.zoom):c.resolution&&this.setResolution(c.resolution),c.rotation!==void 0&&this.setRotation(c.rotation)}if(s===e){i&&ns(i,!0);return}let r=Date.now(),o=this.targetCenter_.slice(),a=this.targetResolution_,l=this.targetRotation_;const h=[];for(;s<e;++s){const c=arguments[s],u={start:r,complete:!1,anchor:c.anchor,duration:c.duration!==void 0?c.duration:1e3,easing:c.easing||Pc,callback:i};if(c.center&&(u.sourceCenter=o,u.targetCenter=c.center.slice(),o=u.targetCenter),c.zoom!==void 0?(u.sourceResolution=a,u.targetResolution=this.getResolutionForZoom(c.zoom),a=u.targetResolution):c.resolution&&(u.sourceResolution=a,u.targetResolution=c.resolution,a=u.targetResolution),c.rotation!==void 0){u.sourceRotation=l;const d=hi(c.rotation-l+Math.PI,2*Math.PI)-Math.PI;u.targetRotation=l+d,l=u.targetRotation}Uu(u)?u.complete=!0:r+=u.duration,h.push(u)}this.animations_.push(h),this.setHint(St.ANIMATING,1),this.updateAnimations_()}getAnimating(){return this.hints_[St.ANIMATING]>0}getInteracting(){return this.hints_[St.INTERACTING]>0}cancelAnimations(){this.setHint(St.ANIMATING,-this.hints_[St.ANIMATING]);let t;for(let e=0,i=this.animations_.length;e<i;++e){const s=this.animations_[e];if(s[0].callback&&ns(s[0].callback,!1),!t)for(let r=0,o=s.length;r<o;++r){const a=s[r];if(!a.complete){t=a.anchor;break}}}this.animations_.length=0,this.cancelAnchor_=t,this.nextCenter_=null,this.nextResolution_=NaN,this.nextRotation_=NaN}updateAnimations_(){if(this.updateAnimationKey_!==void 0&&(cancelAnimationFrame(this.updateAnimationKey_),this.updateAnimationKey_=void 0),!this.getAnimating())return;const t=Date.now();let e=!1;for(let i=this.animations_.length-1;i>=0;--i){const s=this.animations_[i];let r=!0;for(let o=0,a=s.length;o<a;++o){const l=s[o];if(l.complete)continue;const h=t-l.start;let c=l.duration>0?h/l.duration:1;c>=1?(l.complete=!0,c=1):r=!1;const u=l.easing(c);if(l.sourceCenter){const d=l.sourceCenter[0],f=l.sourceCenter[1],g=l.targetCenter[0],m=l.targetCenter[1];this.nextCenter_=l.targetCenter;const _=d+u*(g-d),p=f+u*(m-f);this.targetCenter_=[_,p]}if(l.sourceResolution&&l.targetResolution){const d=u===1?l.targetResolution:l.sourceResolution+u*(l.targetResolution-l.sourceResolution);if(l.anchor){const f=this.getViewportSize_(this.getRotation()),g=this.constraints_.resolution(d,0,f,!0);this.targetCenter_=this.calculateCenterZoom(g,l.anchor)}this.nextResolution_=l.targetResolution,this.targetResolution_=d,this.applyTargetState_(!0)}if(l.sourceRotation!==void 0&&l.targetRotation!==void 0){const d=u===1?hi(l.targetRotation+Math.PI,2*Math.PI)-Math.PI:l.sourceRotation+u*(l.targetRotation-l.sourceRotation);if(l.anchor){const f=this.constraints_.rotation(d,!0);this.targetCenter_=this.calculateCenterRotate(f,l.anchor)}this.nextRotation_=l.targetRotation,this.targetRotation_=d}if(this.applyTargetState_(!0),e=!0,!l.complete)break}if(r){this.animations_[i]=null,this.setHint(St.ANIMATING,-1),this.nextCenter_=null,this.nextResolution_=NaN,this.nextRotation_=NaN;const o=s[0].callback;o&&ns(o,!0)}}this.animations_=this.animations_.filter(Boolean),e&&this.updateAnimationKey_===void 0&&(this.updateAnimationKey_=requestAnimationFrame(this.updateAnimations_.bind(this)))}calculateCenterRotate(t,e){let i;const s=this.getCenterInternal();return s!==void 0&&(i=[s[0]-e[0],s[1]-e[1]],Hs(i,t-this.getRotation()),Lc(i,e)),i}calculateCenterZoom(t,e){let i;const s=this.getCenterInternal(),r=this.getResolution();if(s!==void 0&&r!==void 0){const o=e[0]-t*(e[0]-s[0])/r,a=e[1]-t*(e[1]-s[1])/r;i=[o,a]}return i}getViewportSize_(t){const e=this.viewportSize_;if(t){const i=e[0],s=e[1];return[Math.abs(i*Math.cos(t))+Math.abs(s*Math.sin(t)),Math.abs(i*Math.sin(t))+Math.abs(s*Math.cos(t))]}return e}setViewportSize(t){this.viewportSize_=Array.isArray(t)?t.slice():[100,100],this.getAnimating()||this.resolveConstraints(0)}getCenter(){const t=this.getCenterInternal();return t&&ur(t,this.getProjection())}getCenterInternal(){return this.get(Ht.CENTER)}getConstraints(){return this.constraints_}getConstrainResolution(){return this.get("constrainResolution")}getHints(t){return t!==void 0?(t[0]=this.hints_[0],t[1]=this.hints_[1],t):this.hints_.slice()}calculateExtent(t){const e=this.calculateExtentInternal(t);return Fa(e,this.getProjection())}calculateExtentInternal(t){t=t||this.getViewportSizeMinusPadding_();const e=this.getCenterInternal();Q(e,"The view center is not defined");const i=this.getResolution();Q(i!==void 0,"The view resolution is not defined");const s=this.getRotation();return Q(s!==void 0,"The view rotation is not defined"),$s(e,i,s,t)}getMaxResolution(){return this.maxResolution_}getMinResolution(){return this.minResolution_}getMaxZoom(){return this.getZoomForResolution(this.minResolution_)}setMaxZoom(t){this.applyOptions_(this.getUpdatedOptions_({maxZoom:t}))}getMinZoom(){return this.getZoomForResolution(this.maxResolution_)}setMinZoom(t){this.applyOptions_(this.getUpdatedOptions_({minZoom:t}))}setConstrainResolution(t){this.applyOptions_(this.getUpdatedOptions_({constrainResolution:t}))}getProjection(){return this.projection_}getResolution(){return this.get(Ht.RESOLUTION)}getResolutions(){return this.resolutions_}getResolutionForExtent(t,e){return this.getResolutionForExtentInternal(be(t,this.getProjection()),e)}getResolutionForExtentInternal(t,e){e=e||this.getViewportSizeMinusPadding_();const i=et(t)/e[0],s=It(t)/e[1];return Math.max(i,s)}getResolutionForValueFunction(t){t=t||2;const e=this.getConstrainedResolution(this.maxResolution_),i=this.minResolution_,s=Math.log(e/i)/Math.log(t);return(function(r){return e/Math.pow(t,r*s)})}getRotation(){return this.get(Ht.ROTATION)}getValueForResolutionFunction(t){const e=Math.log(t||2),i=this.getConstrainedResolution(this.maxResolution_),s=this.minResolution_,r=Math.log(i/s)/e;return(function(o){return Math.log(i/o)/e/r})}getViewportSizeMinusPadding_(t){let e=this.getViewportSize_(t);const i=this.padding_;return i&&(e=[e[0]-i[1]-i[3],e[1]-i[0]-i[2]]),e}getState(){const t=this.getProjection(),e=this.getResolution(),i=this.getRotation();let s=this.getCenterInternal();const r=this.padding_;if(r){const o=this.getViewportSizeMinusPadding_();s=wr(s,this.getViewportSize_(),[o[0]/2+r[3],o[1]/2+r[0]],e,i)}return{center:s.slice(0),projection:t!==void 0?t:null,resolution:e,nextCenter:this.nextCenter_,nextResolution:this.nextResolution_,nextRotation:this.nextRotation_,rotation:i,zoom:this.getZoom()}}getViewStateAndExtent(){return{viewState:this.getState(),extent:this.calculateExtent()}}getZoom(){let t;const e=this.getResolution();return e!==void 0&&(t=this.getZoomForResolution(e)),t}getZoomForResolution(t){let e=this.minZoom_||0,i,s;if(this.resolutions_){const r=Ws(this.resolutions_,t,1);e=r,i=this.resolutions_[r],r==this.resolutions_.length-1?s=2:s=i/this.resolutions_[r+1]}else i=this.maxResolution_,s=this.zoomFactor_;return e+Math.log(i/t)/Math.log(s)}getResolutionForZoom(t){if(this.resolutions_?.length){if(this.resolutions_.length===1)return this.resolutions_[0];const e=lt(Math.floor(t),0,this.resolutions_.length-2),i=this.resolutions_[e]/this.resolutions_[e+1];return this.resolutions_[e]/Math.pow(i,lt(t-e,0,1))}return this.maxResolution_/Math.pow(this.zoomFactor_,t-this.minZoom_)}fit(t,e){let i;if(Q(Array.isArray(t)||typeof t.getSimplifiedGeometry=="function","Invalid extent or geometry provided as `geometry`"),Array.isArray(t)){Q(!Vn(t),"Cannot fit empty extent provided as `geometry`");const s=be(t,this.getProjection());i=Qa(s)}else if(t.getType()==="Circle"){const s=be(t.getExtent(),this.getProjection());i=Qa(s),i.rotate(this.getRotation(),Ye(s))}else i=t;this.fitInternal(i,e)}rotatedExtentForGeometry(t){const e=this.getRotation(),i=Math.cos(e),s=Math.sin(-e),r=t.getFlatCoordinates(),o=t.getStride();let a=1/0,l=1/0,h=-1/0,c=-1/0;for(let u=0,d=r.length;u<d;u+=o){const f=r[u]*i-r[u+1]*s,g=r[u]*s+r[u+1]*i;a=Math.min(a,f),l=Math.min(l,g),h=Math.max(h,f),c=Math.max(c,g)}return[a,l,h,c]}fitInternal(t,e){e=e||{};let i=e.size;i||(i=this.getViewportSizeMinusPadding_());const s=e.padding!==void 0?e.padding:[0,0,0,0],r=e.nearest!==void 0?e.nearest:!1;let o;e.minResolution!==void 0?o=e.minResolution:e.maxZoom!==void 0?o=this.getResolutionForZoom(e.maxZoom):o=0;const a=this.rotatedExtentForGeometry(t);let l=this.getResolutionForExtentInternal(a,[i[0]-s[1]-s[3],i[1]-s[0]-s[2]]);l=isNaN(l)?o:Math.max(l,o),l=this.getConstrainedResolution(l,r?0:1);const h=this.getRotation(),c=Math.sin(h),u=Math.cos(h),d=Ye(a);d[0]+=(s[1]-s[3])/2*l,d[1]+=(s[0]-s[2])/2*l;const f=d[0]*u-d[1]*c,g=d[1]*u+d[0]*c,m=this.getConstrainedCenter([f,g],l),_=e.callback?e.callback:Yi;e.duration!==void 0?this.animateInternal({resolution:l,center:m,duration:e.duration,easing:e.easing},_):(this.targetResolution_=l,this.targetCenter_=m,this.applyTargetState_(!1,!0),ns(_,!0))}centerOn(t,e,i){this.centerOnInternal(de(t,this.getProjection()),e,i)}centerOnInternal(t,e,i){this.setCenterInternal(wr(t,e,i,this.getResolution(),this.getRotation()))}calculateCenterShift(t,e,i,s){let r;const o=this.padding_;if(o&&t){const a=this.getViewportSizeMinusPadding_(-i),l=wr(t,s,[a[0]/2+o[3],a[1]/2+o[0]],e,i);r=[t[0]-l[0],t[1]-l[1]]}return r}isDef(){return!!this.getCenterInternal()&&this.getResolution()!==void 0}adjustCenter(t){const e=ur(this.targetCenter_,this.getProjection());this.setCenter([e[0]+t[0],e[1]+t[1]])}adjustCenterInternal(t){const e=this.targetCenter_;this.setCenterInternal([e[0]+t[0],e[1]+t[1]])}adjustResolution(t,e){e=e&&de(e,this.getProjection()),this.adjustResolutionInternal(t,e)}adjustResolutionInternal(t,e){const i=this.getAnimating()||this.getInteracting(),s=this.getViewportSize_(this.getRotation()),r=this.constraints_.resolution(this.targetResolution_*t,0,s,i);e&&(this.targetCenter_=this.calculateCenterZoom(r,e)),this.targetResolution_*=t,this.applyTargetState_()}adjustZoom(t,e){this.adjustResolution(Math.pow(this.zoomFactor_,-t),e)}adjustRotation(t,e){e&&(e=de(e,this.getProjection())),this.adjustRotationInternal(t,e)}adjustRotationInternal(t,e){const i=this.getAnimating()||this.getInteracting(),s=this.constraints_.rotation(this.targetRotation_+t,i);e&&(this.targetCenter_=this.calculateCenterRotate(s,e)),this.targetRotation_+=t,this.applyTargetState_()}setCenter(t){this.setCenterInternal(t&&de(t,this.getProjection()))}setCenterInternal(t){this.targetCenter_=t,this.applyTargetState_()}setHint(t,e){return this.hints_[t]+=e,this.changed(),this.hints_[t]}setResolution(t){this.targetResolution_=t,this.applyTargetState_()}setRotation(t){this.targetRotation_=t,this.applyTargetState_()}setZoom(t){this.setResolution(this.getResolutionForZoom(t))}applyTargetState_(t,e){const i=this.getAnimating()||this.getInteracting()||e,s=this.constraints_.rotation(this.targetRotation_,i),r=this.getViewportSize_(s),o=this.constraints_.resolution(this.targetResolution_,0,r,i),a=this.constraints_.center(this.targetCenter_,o,r,i,this.calculateCenterShift(this.targetCenter_,o,s,r));this.get(Ht.ROTATION)!==s&&this.set(Ht.ROTATION,s),this.get(Ht.RESOLUTION)!==o&&(this.set(Ht.RESOLUTION,o),this.set("zoom",this.getZoom(),!0)),(!a||!this.get(Ht.CENTER)||!Zn(this.get(Ht.CENTER),a))&&this.set(Ht.CENTER,a),this.getAnimating()&&!t&&this.cancelAnimations(),this.cancelAnchor_=void 0}resolveConstraints(t,e,i){t=t!==void 0?t:200;const s=e||0,r=this.constraints_.rotation(this.targetRotation_),o=this.getViewportSize_(r),a=this.constraints_.resolution(this.targetResolution_,s,o),l=this.constraints_.center(this.targetCenter_,a,o,!1,this.calculateCenterShift(this.targetCenter_,a,r,o));if(t===0&&!this.cancelAnchor_){this.targetResolution_=a,this.targetRotation_=r,this.targetCenter_=l,this.applyTargetState_();return}i=i||(t===0?this.cancelAnchor_:void 0),this.cancelAnchor_=void 0,(this.getResolution()!==a||this.getRotation()!==r||!this.getCenterInternal()||!Zn(this.getCenterInternal(),l))&&(this.getAnimating()&&this.cancelAnimations(),this.animateInternal({rotation:r,center:l,resolution:a,duration:t,easing:ui,anchor:i}))}beginInteraction(){this.resolveConstraints(0),this.setHint(St.INTERACTING,1)}endInteraction(t,e,i){i=i&&de(i,this.getProjection()),this.endInteractionInternal(t,e,i)}endInteractionInternal(t,e,i){this.getInteracting()&&(this.setHint(St.INTERACTING,-1),this.resolveConstraints(t,e,i))}getConstrainedCenter(t,e){const i=this.getViewportSize_(this.getRotation());return this.constraints_.center(t,e||this.getResolution(),i)}getConstrainedZoom(t,e){const i=this.getResolutionForZoom(t);return this.getZoomForResolution(this.getConstrainedResolution(i,e))}getConstrainedResolution(t,e){e=e||0;const i=this.getViewportSize_(this.getRotation());return this.constraints_.resolution(t,e,i)}}function ns(n,t){setTimeout(function(){n(t)},0)}function Xu(n){if(n.extent!==void 0){const e=n.smoothExtentConstraint!==void 0?n.smoothExtentConstraint:!0;return oa(n.extent,n.constrainOnlyCenter,e)}const t=or(n.projection,"EPSG:3857");if(n.multiWorld!==!0&&t.isGlobal()){const e=t.getExtent().slice();return e[0]=-1/0,e[2]=1/0,oa(e,!1,!1)}return Rc}function Yu(n){let t,e,i,o=n.minZoom!==void 0?n.minZoom:Er,a=n.maxZoom!==void 0?n.maxZoom:28;const l=n.zoomFactor!==void 0?n.zoomFactor:2,h=n.multiWorld!==void 0?n.multiWorld:!1,c=n.smoothResolutionConstraint!==void 0?n.smoothResolutionConstraint:!0,u=n.showFullExtent!==void 0?n.showFullExtent:!1,d=or(n.projection,"EPSG:3857"),f=d.getExtent();let g=n.constrainOnlyCenter,m=n.extent;if(!h&&!m&&d.isGlobal()&&(g=!1,m=f),n.resolutions!==void 0){const _=n.resolutions;e=_[o],i=_[a]!==void 0?_[a]:_[_.length-1],n.constrainResolution?t=Fu(_,c,!g&&m,u):t=tl(e,i,c,!g&&m,u)}else{const p=(f?Math.max(et(f),It(f)):360*qs.degrees/d.getMetersPerUnit())/xr/Math.pow(2,Er),y=p/Math.pow(2,28-Er);e=n.maxResolution,e!==void 0?o=0:e=p/Math.pow(l,o),i=n.minResolution,i===void 0&&(n.maxZoom!==void 0?n.maxResolution!==void 0?i=e/Math.pow(l,a):i=p/Math.pow(l,a):i=y),a=o+Math.floor(Math.log(e/i)/Math.log(l)),i=e/Math.pow(l,a-o),n.constrainResolution?t=Nu(l,e,i,c,!g&&m,u):t=tl(e,i,c,!g&&m,u)}return{constraint:t,maxResolution:e,minResolution:i,minZoom:o,zoomFactor:l}}function Bu(n){if(n.enableRotation!==void 0?n.enableRotation:!0){const e=n.constrainRotation;return e===void 0||e===!0?Gu():e===!1?el:typeof e=="number"?zu(e):el}return yr}function Uu(n){return!(n.sourceCenter&&n.targetCenter&&!Zn(n.sourceCenter,n.targetCenter)||n.sourceResolution!==n.targetResolution||n.sourceRotation!==n.targetRotation)}function wr(n,t,e,i,s){const r=Math.cos(-s);let o=Math.sin(-s),a=n[0]*r-n[1]*o,l=n[1]*r+n[0]*o;a+=(t[0]/2-e[0])*i,l+=(e[1]-t[1]/2)*i,o=-o;const h=a*r-l*o,c=l*r+a*o;return[h,c]}const ss="ol-hidden",rs="ol-unselectable",vr="ol-control",il="ol-collapsed",Ku=new RegExp(["^\\s*(?=(?:(?:[-a-z]+\\s*){0,2}(italic|oblique))?)","(?=(?:(?:[-a-z]+\\s*){0,2}(small-caps))?)","(?=(?:(?:[-a-z]+\\s*){0,2}(bold(?:er)?|lighter|[1-9]00 ))?)","(?:(?:normal|\\1|\\2|\\3)\\s*){0,3}((?:xx?-)?","(?:small|large)|medium|smaller|larger|[\\.\\d]+(?:\\%|in|[cem]m|ex|p[ctx]))","(?:\\s*\\/\\s*(normal|[\\.\\d]+(?:\\%|in|[cem]m|ex|p[ctx])?))",`?\\s*([-,\\"\\'\\sa-z0-9]+?)\\s*$`].join(""),"i"),nl=["style","variant","weight","size","lineHeight","family"],Cr={normal:400,bold:700},Rr=function(n){const t=n.match(Ku);if(!t)return null;const e={lineHeight:"normal",size:"1.2em",style:"normal",weight:"400",variant:"normal"};for(let i=0,s=nl.length;i<s;++i){const r=t[i+1];r!==void 0&&(e[nl[i]]=typeof r=="string"?r.trim():r)}return isNaN(Number(e.weight))&&e.weight in Cr&&(e.weight=Cr[e.weight]),e.families=e.family.split(/,\s?/).map(i=>i.trim().replace(/^['"]|['"]$/g,"")),e};function gt(n,t,e,i){let s;return e&&e.length?s=e.shift():Ys?s=new OffscreenCanvas(n||300,t||300):s=document.createElement("canvas"),n&&(s.width=n),t&&(s.height=t),s.getContext("2d",i)}let Sr;function os(){return Sr||(Sr=gt(1,1)),Sr}function as(n){const t=n.canvas;t.width=1,t.height=1,n.clearRect(0,0,1,1)}function sl(n,t){const e=t.parentNode;e&&e.replaceChild(n,t)}function ju(n){for(;n.lastChild;)n.lastChild.remove()}function Vu(n,t){const e=n.childNodes;for(let i=0;;++i){const s=e[i],r=t[i];if(!s&&!r)break;if(s!==r){if(!s){n.appendChild(r);continue}if(!r){n.removeChild(s),--i;continue}n.insertBefore(r,s)}}}class Ir extends ne{constructor(t){super();const e=t.element;e&&!t.target&&!e.style.pointerEvents&&(e.style.pointerEvents="auto"),this.element=e||null,this.target_=null,this.map_=null,this.listenerKeys=[],t.render&&(this.render=t.render),t.target&&this.setTarget(t.target)}disposeInternal(){this.element?.remove(),super.disposeInternal()}getMap(){return this.map_}setMap(t){this.map_&&this.element?.remove();for(let e=0,i=this.listenerKeys.length;e<i;++e)at(this.listenerKeys[e]);if(this.listenerKeys.length=0,this.map_=t,t){const e=this.target_??t.getOverlayContainerStopEvent();this.element&&e.appendChild(this.element),this.render!==Yi&&this.listenerKeys.push($(t,Se.POSTRENDER,this.render,this)),t.render()}}render(t){}setTarget(t){this.target_=typeof t=="string"?document.getElementById(t):t}}class Zu extends Ir{constructor(t){t=t||{},super({element:document.createElement("div"),render:t.render,target:t.target}),this.ulElement_=document.createElement("ul"),this.collapsed_=t.collapsed!==void 0?t.collapsed:!0,this.userCollapsed_=this.collapsed_,this.overrideCollapsible_=t.collapsible!==void 0,this.collapsible_=t.collapsible!==void 0?t.collapsible:!0,this.collapsible_||(this.collapsed_=!1),this.attributions_=t.attributions;const e=t.className!==void 0?t.className:"ol-attribution",i=t.tipLabel!==void 0?t.tipLabel:"Attributions",s=t.expandClassName!==void 0?t.expandClassName:e+"-expand",r=t.collapseLabel!==void 0?t.collapseLabel:"›",o=t.collapseClassName!==void 0?t.collapseClassName:e+"-collapse";typeof r=="string"?(this.collapseLabel_=document.createElement("span"),this.collapseLabel_.textContent=r,this.collapseLabel_.className=o):this.collapseLabel_=r;const a=t.label!==void 0?t.label:"i";typeof a=="string"?(this.label_=document.createElement("span"),this.label_.textContent=a,this.label_.className=s):this.label_=a;const l=this.collapsible_&&!this.collapsed_?this.collapseLabel_:this.label_;this.toggleButton_=document.createElement("button"),this.toggleButton_.setAttribute("type","button"),this.toggleButton_.setAttribute("aria-expanded",String(!this.collapsed_)),this.toggleButton_.title=i,this.toggleButton_.appendChild(l),this.toggleButton_.addEventListener(B.CLICK,this.handleClick_.bind(this),!1);const h=e+" "+rs+" "+vr+(this.collapsed_&&this.collapsible_?" "+il:"")+(this.collapsible_?"":" ol-uncollapsible"),c=this.element;c.className=h,c.appendChild(this.toggleButton_),c.appendChild(this.ulElement_),this.renderedAttributions_=[],this.renderedVisible_=!0}collectSourceAttributions_(t){const e=this.getMap().getAllLayers(),i=new Set(e.flatMap(s=>s.getAttributions(t)));if(this.attributions_!==void 0&&(Array.isArray(this.attributions_)?this.attributions_.forEach(s=>i.add(s)):i.add(this.attributions_)),!this.overrideCollapsible_){const s=!e.some(r=>r.getSource()?.getAttributionsCollapsible()===!1);this.setCollapsible(s)}return Array.from(i)}async updateElement_(t){if(!t){this.renderedVisible_&&(this.element.style.display="none",this.renderedVisible_=!1);return}const e=await Promise.all(this.collectSourceAttributions_(t).map(s=>fc(()=>s))),i=e.length>0;if(this.renderedVisible_!=i&&(this.element.style.display=i?"":"none",this.renderedVisible_=i),!Ce(e,this.renderedAttributions_)){ju(this.ulElement_);for(let s=0,r=e.length;s<r;++s){const o=document.createElement("li");o.innerHTML=e[s],this.ulElement_.appendChild(o)}this.renderedAttributions_=e}}handleClick_(t){t.preventDefault(),this.handleToggle_(),this.userCollapsed_=this.collapsed_}handleToggle_(){this.element.classList.toggle(il),this.collapsed_?sl(this.collapseLabel_,this.label_):sl(this.label_,this.collapseLabel_),this.collapsed_=!this.collapsed_,this.toggleButton_.setAttribute("aria-expanded",String(!this.collapsed_))}getCollapsible(){return this.collapsible_}setCollapsible(t){this.collapsible_!==t&&(this.collapsible_=t,this.element.classList.toggle("ol-uncollapsible"),this.userCollapsed_&&this.handleToggle_())}setCollapsed(t){this.userCollapsed_=t,!(!this.collapsible_||this.collapsed_===t)&&this.handleToggle_()}getCollapsed(){return this.collapsed_}render(t){this.updateElement_(t.frameState)}}class $u extends Ir{constructor(t){t=t||{},super({element:document.createElement("div"),render:t.render,target:t.target});const e=t.className!==void 0?t.className:"ol-rotate",i=t.label!==void 0?t.label:"⇧",s=t.compassClassName!==void 0?t.compassClassName:"ol-compass";this.label_=null,typeof i=="string"?(this.label_=document.createElement("span"),this.label_.className=s,this.label_.textContent=i):(this.label_=i,this.label_.classList.add(s));const r=t.tipLabel?t.tipLabel:"Reset rotation",o=document.createElement("button");o.className=e+"-reset",o.setAttribute("type","button"),o.title=r,o.appendChild(this.label_),o.addEventListener(B.CLICK,this.handleClick_.bind(this),!1);const a=e+" "+rs+" "+vr,l=this.element;l.className=a,l.appendChild(o),this.callResetNorth_=t.resetNorth?t.resetNorth:void 0,this.duration_=t.duration!==void 0?t.duration:250,this.autoHide_=t.autoHide!==void 0?t.autoHide:!0,this.rotation_=void 0,this.autoHide_&&this.element.classList.add(ss)}handleClick_(t){t.preventDefault(),this.callResetNorth_!==void 0?this.callResetNorth_():this.resetNorth_()}resetNorth_(){const e=this.getMap().getView();if(!e)return;const i=e.getRotation();i!==void 0&&(this.duration_>0&&i%(2*Math.PI)!==0?e.animate({rotation:0,duration:this.duration_,easing:ui}):e.setRotation(0))}render(t){const e=t.frameState;if(!e)return;const i=e.viewState.rotation;if(i!=this.rotation_){const s="rotate("+i+"rad)";if(this.autoHide_){const r=this.element.classList.contains(ss);!r&&i===0?this.element.classList.add(ss):r&&i!==0&&this.element.classList.remove(ss)}this.label_.style.transform=s}this.rotation_=i}}class Hu extends Ir{constructor(t){t=t||{},super({element:document.createElement("div"),target:t.target});const e=t.className!==void 0?t.className:"ol-zoom",i=t.delta!==void 0?t.delta:1,s=t.zoomInClassName!==void 0?t.zoomInClassName:e+"-in",r=t.zoomOutClassName!==void 0?t.zoomOutClassName:e+"-out",o=t.zoomInLabel!==void 0?t.zoomInLabel:"+",a=t.zoomOutLabel!==void 0?t.zoomOutLabel:"–",l=t.zoomInTipLabel!==void 0?t.zoomInTipLabel:"Zoom in",h=t.zoomOutTipLabel!==void 0?t.zoomOutTipLabel:"Zoom out",c=document.createElement("button");c.className=s,c.setAttribute("type","button"),c.title=l,c.appendChild(typeof o=="string"?document.createTextNode(o):o),c.addEventListener(B.CLICK,this.handleClick_.bind(this,i),!1);const u=document.createElement("button");u.className=r,u.setAttribute("type","button"),u.title=h,u.appendChild(typeof a=="string"?document.createTextNode(a):a),u.addEventListener(B.CLICK,this.handleClick_.bind(this,-i),!1);const d=e+" "+rs+" "+vr,f=this.element;f.className=d,f.appendChild(c),f.appendChild(u),this.duration_=t.duration!==void 0?t.duration:250}handleClick_(t,e){e.preventDefault(),this.zoomByDelta_(t)}zoomByDelta_(t){const i=this.getMap().getView();if(!i)return;const s=i.getZoom();if(s!==void 0){const r=i.getConstrainedZoom(s+t);this.duration_>0?(i.getAnimating()&&i.cancelAnimations(),i.animate({zoom:r,duration:this.duration_,easing:ui})):i.setZoom(r)}}}function qu(n){n=n||{};const t=new se;return(n.zoom!==void 0?n.zoom:!0)&&t.push(new Hu(n.zoomOptions)),(n.rotate!==void 0?n.rotate:!0)&&t.push(new $u(n.rotateOptions)),(n.attribution!==void 0?n.attribution:!0)&&t.push(new Zu(n.attributionOptions)),t}class Ju{constructor(t,e,i){this.decay_=t,this.minVelocity_=e,this.delay_=i,this.points_=[],this.angle_=0,this.initialVelocity_=0}begin(){this.points_.length=0,this.angle_=0,this.initialVelocity_=0}update(t,e){this.points_.push(t,e,Date.now())}end(){if(this.points_.length<6)return!1;const t=Date.now()-this.delay_,e=this.points_.length-3;if(this.points_[e+2]<t)return!1;let i=e-3;for(;i>0&&this.points_[i+2]>t;)i-=3;const s=this.points_[e+2]-this.points_[i+2];if(s<1e3/60)return!1;const r=this.points_[e]-this.points_[i],o=this.points_[e+1]-this.points_[i+1];return this.angle_=Math.atan2(o,r),this.initialVelocity_=Math.sqrt(r*r+o*o)/s,this.initialVelocity_>this.minVelocity_}getDistance(){return(this.minVelocity_-this.initialVelocity_)/this.decay_}getAngle(){return this.angle_}}const rl={ACTIVE:"active"};class Ji extends ne{constructor(t){super(),this.on,this.once,this.un,t&&t.handleEvent&&(this.handleEvent=t.handleEvent),this.map_=null,this.setActive(!0)}getActive(){return this.get(rl.ACTIVE)}getMap(){return this.map_}handleEvent(t){return!0}setActive(t){this.set(rl.ACTIVE,t)}setMap(t){this.map_=t}}function Qu(n,t,e){const i=n.getCenterInternal();if(i){const s=[i[0]+t[0],i[1]+t[1]];n.animateInternal({duration:e!==void 0?e:250,easing:Dc,center:n.getConstrainedCenter(s)})}}function Tr(n,t,e,i){const s=n.getZoom();if(s===void 0)return;const r=n.getConstrainedZoom(s+t),o=n.getResolutionForZoom(r);n.getAnimating()&&n.cancelAnimations(),n.animate({resolution:o,anchor:e,duration:i!==void 0?i:250,easing:ui})}class td extends Ji{constructor(t){super(),t=t||{},this.delta_=t.delta?t.delta:1,this.duration_=t.duration!==void 0?t.duration:250}handleEvent(t){let e=!1;if(t.type==ct.DBLCLICK){const i=t.originalEvent,s=t.map,r=t.coordinate,o=i.shiftKey?-this.delta_:this.delta_,a=s.getView();Tr(a,o,r,this.duration_),i.preventDefault(),e=!0}return!e}}function br(n){const t=arguments;return function(e){let i=!0;for(let s=0,r=t.length;s<r&&(i=i&&t[s](e),!!i);++s);return i}}const ed=function(n){const t=n.originalEvent;return t.altKey&&!(t.metaKey||t.ctrlKey)&&t.shiftKey},id=function(n){const t=n.map.getTargetElement(),e=t.getRootNode(),i=n.map.getOwnerDocument().activeElement;return e instanceof ShadowRoot?e.host.contains(i):t.contains(i)},ol=function(n){const t=n.map.getTargetElement(),e=t.getRootNode();return(e instanceof ShadowRoot?e.host:t).hasAttribute("tabindex")?id(n):!0},nd=Xi,al=function(n){const t=n.originalEvent;return"pointerId"in t&&t.button==0&&!(mc&&ia&&t.ctrlKey)},ll=function(n){const t=n.originalEvent;return!t.altKey&&!(t.metaKey||t.ctrlKey)&&!t.shiftKey},sd=function(n){const t=n.originalEvent;return ia?t.metaKey:t.ctrlKey},rd=function(n){const t=n.originalEvent;return!t.altKey&&!(t.metaKey||t.ctrlKey)&&t.shiftKey},hl=function(n){const t=n.originalEvent,e=t.target.tagName;return e!=="INPUT"&&e!=="SELECT"&&e!=="TEXTAREA"&&!t.target.isContentEditable},Mr=function(n){const t=n.originalEvent;return"pointerId"in t&&t.pointerType=="mouse"},od=function(n){const t=n.originalEvent;return"pointerId"in t&&t.isPrimary&&t.button===0};class Qi extends Ji{constructor(t){t=t||{},super(t),t.handleDownEvent&&(this.handleDownEvent=t.handleDownEvent),t.handleDragEvent&&(this.handleDragEvent=t.handleDragEvent),t.handleMoveEvent&&(this.handleMoveEvent=t.handleMoveEvent),t.handleUpEvent&&(this.handleUpEvent=t.handleUpEvent),t.stopDown&&(this.stopDown=t.stopDown),this.handlingDownUpSequence=!1,this.targetPointers=[]}getPointerCount(){return this.targetPointers.length}handleDownEvent(t){return!1}handleDragEvent(t){}handleEvent(t){if(!t.originalEvent)return!0;let e=!1;if(this.updateTrackedPointers_(t),this.handlingDownUpSequence){if(t.type==ct.POINTERDRAG)this.handleDragEvent(t),t.originalEvent.preventDefault();else if(t.type==ct.POINTERUP){const i=this.handleUpEvent(t);this.handlingDownUpSequence=i&&this.targetPointers.length>0}}else if(t.type==ct.POINTERDOWN){const i=this.handleDownEvent(t);this.handlingDownUpSequence=i,e=this.stopDown(i)}else t.type==ct.POINTERMOVE&&this.handleMoveEvent(t);return!e}handleMoveEvent(t){}handleUpEvent(t){return!1}stopDown(t){return t}updateTrackedPointers_(t){t.activePointers&&(this.targetPointers=t.activePointers)}}function Lr(n){const t=n.length;let e=0,i=0;for(let s=0;s<t;s++)e+=n[s].clientX,i+=n[s].clientY;return{clientX:e/t,clientY:i/t}}class ad extends Qi{constructor(t){super({stopDown:kn}),t=t||{},this.kinetic_=t.kinetic,this.lastCentroid=null,this.lastPointersCount_,this.panning_=!1;const e=t.condition?t.condition:br(ll,od);this.condition_=t.onFocusOnly?br(ol,e):e,this.noKinetic_=!1}handleDragEvent(t){const e=t.map;this.panning_||(this.panning_=!0,e.getView().beginInteraction());const i=this.targetPointers,s=e.getEventPixel(Lr(i));if(i.length==this.lastPointersCount_){if(this.kinetic_&&this.kinetic_.update(s[0],s[1]),this.lastCentroid){const r=[this.lastCentroid[0]-s[0],s[1]-this.lastCentroid[1]],a=t.map.getView();Ac(r,a.getResolution()),Hs(r,a.getRotation()),a.adjustCenterInternal(r)}}else this.kinetic_&&this.kinetic_.begin();this.lastCentroid=s,this.lastPointersCount_=i.length,t.originalEvent.preventDefault()}handleUpEvent(t){const e=t.map,i=e.getView();if(this.targetPointers.length===0){if(!this.noKinetic_&&this.kinetic_&&this.kinetic_.end()){const s=this.kinetic_.getDistance(),r=this.kinetic_.getAngle(),o=i.getCenterInternal(),a=e.getPixelFromCoordinateInternal(o),l=e.getCoordinateFromPixelInternal([a[0]-s*Math.cos(r),a[1]-s*Math.sin(r)]);i.animateInternal({center:i.getConstrainedCenter(l),duration:500,easing:ui})}return this.panning_&&(this.panning_=!1,i.endInteraction()),!1}return this.kinetic_&&this.kinetic_.begin(),this.lastCentroid=null,!0}handleDownEvent(t){if(this.targetPointers.length>0&&this.condition_(t)){const i=t.map.getView();return this.lastCentroid=null,i.getAnimating()&&i.cancelAnimations(),this.kinetic_&&this.kinetic_.begin(),this.noKinetic_=this.targetPointers.length>1,!0}return!1}}class ld extends Qi{constructor(t){t=t||{},super({stopDown:kn}),this.condition_=t.condition?t.condition:ed,this.lastAngle_=void 0,this.duration_=t.duration!==void 0?t.duration:250}handleDragEvent(t){if(!Mr(t))return;const e=t.map,i=e.getView();if(i.getConstraints().rotation===yr)return;const s=e.getSize(),r=t.pixel,o=Math.atan2(s[1]/2-r[1],r[0]-s[0]/2);if(this.lastAngle_!==void 0){const a=o-this.lastAngle_;i.adjustRotationInternal(-a)}this.lastAngle_=o}handleUpEvent(t){return Mr(t)?(t.map.getView().endInteraction(this.duration_),!1):!0}handleDownEvent(t){return Mr(t)&&al(t)&&this.condition_(t)?(t.map.getView().beginInteraction(),this.lastAngle_=void 0,!0):!1}}class hd extends Dn{constructor(t){super(),this.geometry_=null,this.element_=document.createElement("div"),this.element_.style.position="absolute",this.element_.style.pointerEvents="auto",this.element_.className="ol-box "+t,this.map_=null,this.startPixel_=null,this.endPixel_=null}disposeInternal(){this.setMap(null)}render_(){const t=this.startPixel_,e=this.endPixel_,i="px",s=this.element_.style;s.left=Math.min(t[0],e[0])+i,s.top=Math.min(t[1],e[1])+i,s.width=Math.abs(e[0]-t[0])+i,s.height=Math.abs(e[1]-t[1])+i}setMap(t){if(this.map_){this.map_.getOverlayContainer().removeChild(this.element_);const e=this.element_.style;e.left="inherit",e.top="inherit",e.width="inherit",e.height="inherit"}this.map_=t,this.map_&&this.map_.getOverlayContainer().appendChild(this.element_)}setPixels(t,e){this.startPixel_=t,this.endPixel_=e,this.createOrUpdateGeometry(),this.render_()}createOrUpdateGeometry(){if(!this.map_)return;const t=this.startPixel_,e=this.endPixel_,s=[t,[t[0],e[1]],e,[e[0],t[1]]].map(this.map_.getCoordinateFromPixelInternal,this.map_);s[4]=s[0].slice(),this.geometry_?this.geometry_.setCoordinates([s]):this.geometry_=new qi([s])}getGeometry(){return this.geometry_}}const pi={BOXSTART:"boxstart",BOXDRAG:"boxdrag",BOXEND:"boxend",BOXCANCEL:"boxcancel"};class tn extends ue{constructor(t,e,i){super(t),this.coordinate=e,this.mapBrowserEvent=i}}class cd extends Qi{constructor(t){super(),this.on,this.once,this.un,t=t??{},this.box_=new hd(t.className||"ol-dragbox"),this.minArea_=t.minArea??64,t.onBoxEnd&&(this.onBoxEnd=t.onBoxEnd),this.startPixel_=null,this.condition_=t.condition??al,this.boxEndCondition_=t.boxEndCondition??this.defaultBoxEndCondition}defaultBoxEndCondition(t,e,i){const s=i[0]-e[0],r=i[1]-e[1];return s*s+r*r>=this.minArea_}getGeometry(){return this.box_.getGeometry()}handleDragEvent(t){this.startPixel_&&(this.box_.setPixels(this.startPixel_,t.pixel),this.dispatchEvent(new tn(pi.BOXDRAG,t.coordinate,t)))}handleUpEvent(t){if(!this.startPixel_)return!1;const e=this.boxEndCondition_(t,this.startPixel_,t.pixel);return e&&this.onBoxEnd(t),this.dispatchEvent(new tn(e?pi.BOXEND:pi.BOXCANCEL,t.coordinate,t)),this.box_.setMap(null),this.startPixel_=null,!1}handleDownEvent(t){return this.condition_(t)?(this.startPixel_=t.pixel,this.box_.setMap(t.map),this.box_.setPixels(this.startPixel_,this.startPixel_),this.dispatchEvent(new tn(pi.BOXSTART,t.coordinate,t)),!0):!1}onBoxEnd(t){}setActive(t){t||(this.box_.setMap(null),this.startPixel_&&(this.dispatchEvent(new tn(pi.BOXCANCEL,this.startPixel_,null)),this.startPixel_=null)),super.setActive(t)}setMap(t){this.getMap()&&(this.box_.setMap(null),this.startPixel_&&(this.dispatchEvent(new tn(pi.BOXCANCEL,this.startPixel_,null)),this.startPixel_=null)),super.setMap(t)}}class ud extends cd{constructor(t){t=t||{};const e=t.condition?t.condition:rd;super({condition:e,className:t.className||"ol-dragzoom",minArea:t.minArea}),this.duration_=t.duration!==void 0?t.duration:200,this.out_=t.out!==void 0?t.out:!1}onBoxEnd(t){const i=this.getMap().getView();let s=this.getGeometry();if(this.out_){const r=i.rotatedExtentForGeometry(s),o=i.getResolutionForExtentInternal(r),a=i.getResolution()/o;s=s.clone(),s.scale(a*a)}i.fitInternal(s,{duration:this.duration_,easing:ui})}}const $e={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",DOWN:"ArrowDown"};class dd extends Ji{constructor(t){super(),t=t||{},this.defaultCondition_=function(e){return ll(e)&&hl(e)},this.condition_=t.condition!==void 0?t.condition:this.defaultCondition_,this.duration_=t.duration!==void 0?t.duration:100,this.pixelDelta_=t.pixelDelta!==void 0?t.pixelDelta:128}handleEvent(t){let e=!1;if(t.type==B.KEYDOWN){const i=t.originalEvent,s=i.key;if(this.condition_(t)&&(s==$e.DOWN||s==$e.LEFT||s==$e.RIGHT||s==$e.UP)){const o=t.map.getView(),a=o.getResolution()*this.pixelDelta_;let l=0,h=0;s==$e.DOWN?h=-a:s==$e.LEFT?l=-a:s==$e.RIGHT?l=a:h=a;const c=[l,h];Hs(c,o.getRotation()),Qu(o,c,this.duration_),i.preventDefault(),e=!0}}return!e}}class fd extends Ji{constructor(t){super(),t=t||{},this.condition_=t.condition?t.condition:function(e){return!sd(e)&&hl(e)},this.delta_=t.delta?t.delta:1,this.duration_=t.duration!==void 0?t.duration:100}handleEvent(t){let e=!1;if(t.type==B.KEYDOWN||t.type==B.KEYPRESS){const i=t.originalEvent,s=i.key;if(this.condition_(t)&&(s==="+"||s==="-")){const r=t.map,o=s==="+"?this.delta_:-this.delta_,a=r.getView();Tr(a,o,void 0,this.duration_),i.preventDefault(),e=!0}}return!e}}const gd=40,_d=300;class md extends Ji{constructor(t){t=t||{},super(t),this.totalDelta_=0,this.lastDelta_=0,this.maxDelta_=t.maxDelta!==void 0?t.maxDelta:1,this.duration_=t.duration!==void 0?t.duration:250,this.timeout_=t.timeout!==void 0?t.timeout:80,this.useAnchor_=t.useAnchor!==void 0?t.useAnchor:!0,this.constrainResolution_=t.constrainResolution!==void 0?t.constrainResolution:!1;const e=t.condition?t.condition:nd;this.condition_=t.onFocusOnly?br(ol,e):e,this.lastAnchor_=null,this.startTime_=void 0,this.timeoutId_,this.mode_=void 0,this.trackpadEventGap_=400,this.trackpadTimeoutId_,this.deltaPerZoom_=300}endInteraction_(){this.trackpadTimeoutId_=void 0;const t=this.getMap();if(!t)return;t.getView().endInteraction(void 0,this.lastDelta_?this.lastDelta_>0?1:-1:0,this.lastAnchor_?t.getCoordinateFromPixel(this.lastAnchor_):null)}handleEvent(t){if(!this.condition_(t)||t.type!==B.WHEEL)return!0;const i=t.map,s=t.originalEvent;s.preventDefault(),this.useAnchor_&&(this.lastAnchor_=t.pixel);let r=s.deltaY;switch(s.deltaMode){case WheelEvent.DOM_DELTA_LINE:r*=gd;break;case WheelEvent.DOM_DELTA_PAGE:r*=_d;break}if(r===0)return!1;this.lastDelta_=r;const o=Date.now();this.startTime_===void 0&&(this.startTime_=o),(!this.mode_||o-this.startTime_>this.trackpadEventGap_)&&(this.mode_=Math.abs(r)<4?"trackpad":"wheel");const a=i.getView();if(this.mode_==="trackpad"&&!(a.getConstrainResolution()||this.constrainResolution_))return this.trackpadTimeoutId_?clearTimeout(this.trackpadTimeoutId_):(a.getAnimating()&&a.cancelAnimations(),a.beginInteraction()),this.trackpadTimeoutId_=setTimeout(this.endInteraction_.bind(this),this.timeout_),a.adjustZoom(-r/this.deltaPerZoom_,this.lastAnchor_?i.getCoordinateFromPixel(this.lastAnchor_):null),this.startTime_=o,!1;this.totalDelta_+=r;const l=Math.max(this.timeout_-(o-this.startTime_),0);return clearTimeout(this.timeoutId_),this.timeoutId_=setTimeout(this.handleWheelZoom_.bind(this,i),l),!1}handleWheelZoom_(t){const e=t.getView();e.getAnimating()&&e.cancelAnimations();let i=-lt(this.totalDelta_,-this.maxDelta_*this.deltaPerZoom_,this.maxDelta_*this.deltaPerZoom_)/this.deltaPerZoom_;(e.getConstrainResolution()||this.constrainResolution_)&&(i=i?i>0?1:-1:0),Tr(e,i,this.lastAnchor_?t.getCoordinateFromPixel(this.lastAnchor_):null,this.duration_),this.mode_=void 0,this.totalDelta_=0,this.lastAnchor_=null,this.startTime_=void 0,this.timeoutId_=void 0}setMouseAnchor(t){this.useAnchor_=t,t||(this.lastAnchor_=null)}}class pd extends Qi{constructor(t){t=t||{};const e=t;e.stopDown||(e.stopDown=kn),super(e),this.anchor_=null,this.lastAngle_=void 0,this.rotating_=!1,this.rotationDelta_=0,this.threshold_=t.threshold!==void 0?t.threshold:.3,this.duration_=t.duration!==void 0?t.duration:250}handleDragEvent(t){let e=0;const i=this.targetPointers[0],s=this.targetPointers[1],r=Math.atan2(s.clientY-i.clientY,s.clientX-i.clientX);if(this.lastAngle_!==void 0){const l=r-this.lastAngle_;this.rotationDelta_+=l,!this.rotating_&&Math.abs(this.rotationDelta_)>this.threshold_&&(this.rotating_=!0),e=l}this.lastAngle_=r;const o=t.map,a=o.getView();a.getConstraints().rotation!==yr&&(this.anchor_=o.getCoordinateFromPixelInternal(o.getEventPixel(Lr(this.targetPointers))),this.rotating_&&(o.render(),a.adjustRotationInternal(e,this.anchor_)))}handleUpEvent(t){return this.targetPointers.length<2?(t.map.getView().endInteraction(this.duration_),!1):!0}handleDownEvent(t){if(this.targetPointers.length>=2){const e=t.map;return this.anchor_=null,this.lastAngle_=void 0,this.rotating_=!1,this.rotationDelta_=0,this.handlingDownUpSequence||e.getView().beginInteraction(),!0}return!1}}class yd extends Qi{constructor(t){t=t||{};const e=t;e.stopDown||(e.stopDown=kn),super(e),this.anchor_=null,this.duration_=t.duration!==void 0?t.duration:400,this.lastDistance_=void 0,this.lastScaleDelta_=1}handleDragEvent(t){let e=1;const i=this.targetPointers[0],s=this.targetPointers[1],r=i.clientX-s.clientX,o=i.clientY-s.clientY,a=Math.sqrt(r*r+o*o);this.lastDistance_!==void 0&&(e=this.lastDistance_/a),this.lastDistance_=a;const l=t.map,h=l.getView();e!=1&&(this.lastScaleDelta_=e),this.anchor_=l.getCoordinateFromPixelInternal(l.getEventPixel(Lr(this.targetPointers))),l.render(),h.adjustResolutionInternal(e,this.anchor_)}handleUpEvent(t){if(this.targetPointers.length<2){const i=t.map.getView(),s=this.lastScaleDelta_>1?1:-1;return i.endInteraction(this.duration_,s),!1}return!0}handleDownEvent(t){if(this.targetPointers.length>=2){const e=t.map;return this.anchor_=null,this.lastDistance_=void 0,this.lastScaleDelta_=1,this.handlingDownUpSequence||e.getView().beginInteraction(),!0}return!1}}function xd(n){n=n||{};const t=new se,e=new Ju(-.005,.05,100);return(n.altShiftDragRotate!==void 0?n.altShiftDragRotate:!0)&&t.push(new ld),(n.doubleClickZoom!==void 0?n.doubleClickZoom:!0)&&t.push(new td({delta:n.zoomDelta,duration:n.zoomDuration})),(n.dragPan!==void 0?n.dragPan:!0)&&t.push(new ad({onFocusOnly:n.onFocusOnly,kinetic:e})),(n.pinchRotate!==void 0?n.pinchRotate:!0)&&t.push(new pd),(n.pinchZoom!==void 0?n.pinchZoom:!0)&&t.push(new yd({duration:n.zoomDuration})),(n.keyboard!==void 0?n.keyboard:!0)&&(t.push(new dd),t.push(new fd({delta:n.zoomDelta,duration:n.zoomDuration}))),(n.mouseWheelZoom!==void 0?n.mouseWheelZoom:!0)&&t.push(new md({onFocusOnly:n.onFocusOnly,duration:n.zoomDuration})),(n.shiftDragZoom!==void 0?n.shiftDragZoom:!0)&&t.push(new ud({duration:n.zoomDuration})),t}const it={OPACITY:"opacity",VISIBLE:"visible",EXTENT:"extent",Z_INDEX:"zIndex",MAX_RESOLUTION:"maxResolution",MIN_RESOLUTION:"minResolution",MAX_ZOOM:"maxZoom",MIN_ZOOM:"minZoom",SOURCE:"source",MAP:"map"};class cl extends ne{constructor(t){super(),this.on,this.once,this.un,this.background_=t.background;const e=Object.assign({},t);typeof t.properties=="object"&&(delete e.properties,Object.assign(e,t.properties)),e[it.OPACITY]=t.opacity!==void 0?t.opacity:1,Q(typeof e[it.OPACITY]=="number","Layer opacity must be a number"),e[it.VISIBLE]=t.visible!==void 0?t.visible:!0,e[it.Z_INDEX]=t.zIndex,e[it.MAX_RESOLUTION]=t.maxResolution!==void 0?t.maxResolution:1/0,e[it.MIN_RESOLUTION]=t.minResolution!==void 0?t.minResolution:0,e[it.MIN_ZOOM]=t.minZoom!==void 0?t.minZoom:-1/0,e[it.MAX_ZOOM]=t.maxZoom!==void 0?t.maxZoom:1/0,this.className_=e.className!==void 0?e.className:"ol-layer",delete e.className,this.setProperties(e),this.state_=null}getBackground(){return this.background_}getClassName(){return this.className_}getLayerState(t){const e=this.state_||{layer:this,managed:t===void 0?!0:t},i=this.getZIndex();return e.opacity=lt(Math.round(this.getOpacity()*100)/100,0,1),e.visible=this.getVisible(),e.extent=this.getExtent(),e.zIndex=i===void 0&&!e.managed?1/0:i,e.maxResolution=this.getMaxResolution(),e.minResolution=Math.max(this.getMinResolution(),0),e.minZoom=this.getMinZoom(),e.maxZoom=this.getMaxZoom(),this.state_=e,e}getLayersArray(t){return H()}getLayerStatesArray(t){return H()}getExtent(){return this.get(it.EXTENT)}getMaxResolution(){return this.get(it.MAX_RESOLUTION)}getMinResolution(){return this.get(it.MIN_RESOLUTION)}getMinZoom(){return this.get(it.MIN_ZOOM)}getMaxZoom(){return this.get(it.MAX_ZOOM)}getOpacity(){return this.get(it.OPACITY)}getSourceState(){return H()}getVisible(){return this.get(it.VISIBLE)}getZIndex(){return this.get(it.Z_INDEX)}setBackground(t){this.background_=t,this.changed()}setExtent(t){this.set(it.EXTENT,t)}setMaxResolution(t){this.set(it.MAX_RESOLUTION,t)}setMinResolution(t){this.set(it.MIN_RESOLUTION,t)}setMaxZoom(t){this.set(it.MAX_ZOOM,t)}setMinZoom(t){this.set(it.MIN_ZOOM,t)}setOpacity(t){Q(typeof t=="number","Layer opacity must be a number"),this.set(it.OPACITY,t)}setVisible(t){this.set(it.VISIBLE,t)}setZIndex(t){this.set(it.Z_INDEX,t)}disposeInternal(){this.state_&&(this.state_.layer=null,this.state_=null),super.disposeInternal()}}class Le extends ue{constructor(t,e){super(t),this.layer=e}}const Ar={LAYERS:"layers"};class yi extends cl{constructor(t){t=t||{};const e=Object.assign({},t);delete e.layers;let i=t.layers;super(e),this.on,this.once,this.un,this.layersListenerKeys_=[],this.listenerKeys_={},this.addChangeListener(Ar.LAYERS,this.handleLayersChanged_),i?Array.isArray(i)?i=new se(i.slice(),{unique:!0}):Q(typeof i.getArray=="function","Expected `layers` to be an array or a `Collection`"):i=new se(void 0,{unique:!0}),this.setLayers(i)}handleLayerChange_(){this.changed()}handleLayersChanged_(){this.layersListenerKeys_.forEach(at),this.layersListenerKeys_.length=0;const t=this.getLayers();this.layersListenerKeys_.push($(t,Ot.ADD,this.handleLayersAdd_,this),$(t,Ot.REMOVE,this.handleLayersRemove_,this));for(const i in this.listenerKeys_)this.listenerKeys_[i].forEach(at);Bi(this.listenerKeys_);const e=t.getArray();for(let i=0,s=e.length;i<s;i++){const r=e[i];this.registerLayerListeners_(r),this.dispatchEvent(new Le("addlayer",r))}this.changed()}registerLayerListeners_(t){const e=[$(t,ri.PROPERTYCHANGE,this.handleLayerChange_,this),$(t,B.CHANGE,this.handleLayerChange_,this)];t instanceof yi&&e.push($(t,"addlayer",this.handleLayerGroupAdd_,this),$(t,"removelayer",this.handleLayerGroupRemove_,this)),this.listenerKeys_[q(t)]=e}handleLayerGroupAdd_(t){this.dispatchEvent(new Le("addlayer",t.layer))}handleLayerGroupRemove_(t){this.dispatchEvent(new Le("removelayer",t.layer))}handleLayersAdd_(t){const e=t.element;this.registerLayerListeners_(e),this.dispatchEvent(new Le("addlayer",e)),this.changed()}handleLayersRemove_(t){const e=t.element,i=q(e);this.listenerKeys_[i].forEach(at),delete this.listenerKeys_[i],this.dispatchEvent(new Le("removelayer",e)),this.changed()}getLayers(){return this.get(Ar.LAYERS)}setLayers(t){const e=this.getLayers();if(e){const i=e.getArray();for(let s=0,r=i.length;s<r;++s)this.dispatchEvent(new Le("removelayer",i[s]))}this.set(Ar.LAYERS,t)}getLayersArray(t){return t=t!==void 0?t:[],this.getLayers().forEach(function(e){e.getLayersArray(t)}),t}getLayerStatesArray(t){const e=t!==void 0?t:[],i=e.length;this.getLayers().forEach(function(o){o.getLayerStatesArray(e)});const s=this.getLayerState();let r=s.zIndex;!t&&s.zIndex===void 0&&(r=0);for(let o=i,a=e.length;o<a;o++){const l=e[o];l.opacity*=s.opacity,l.visible=l.visible&&s.visible,l.maxResolution=Math.min(l.maxResolution,s.maxResolution),l.minResolution=Math.max(l.minResolution,s.minResolution),l.minZoom=Math.max(l.minZoom,s.minZoom),l.maxZoom=Math.min(l.maxZoom,s.maxZoom),s.extent!==void 0&&(l.extent!==void 0?l.extent=Be(l.extent,s.extent):l.extent=s.extent),l.zIndex===void 0&&(l.zIndex=r)}return e}getSourceState(){return"ready"}}const Bt={PRERENDER:"prerender",POSTRENDER:"postrender",PRECOMPOSE:"precompose",POSTCOMPOSE:"postcompose",RENDERCOMPLETE:"rendercomplete"};class ls extends cl{constructor(t){const e=Object.assign({},t);delete e.source,super(e),this.on,this.once,this.un,this.mapPrecomposeKey_=null,this.mapRenderKey_=null,this.sourceChangeKey_=null,this.renderer_=null,this.sourceReady_=!1,this.rendered=!1,t.render&&(this.render=t.render),t.map&&this.setMap(t.map),this.addChangeListener(it.SOURCE,this.handleSourcePropertyChange_);const i=t.source?t.source:null;this.setSource(i)}getLayersArray(t){return t=t||[],t.push(this),t}getLayerStatesArray(t){return t=t||[],t.push(this.getLayerState()),t}getSource(){return this.get(it.SOURCE)||null}getRenderSource(){return this.getSource()}getSourceState(){const t=this.getSource();return t?t.getState():"undefined"}handleSourceChange_(){this.changed(),!(this.sourceReady_||this.getSource().getState()!=="ready")&&(this.sourceReady_=!0,this.dispatchEvent("sourceready"))}handleSourcePropertyChange_(){this.sourceChangeKey_&&(at(this.sourceChangeKey_),this.sourceChangeKey_=null),this.sourceReady_=!1;const t=this.getSource();t&&(this.sourceChangeKey_=$(t,B.CHANGE,this.handleSourceChange_,this),t.getState()==="ready"&&(this.sourceReady_=!0,setTimeout(()=>{this.dispatchEvent("sourceready")},0))),this.changed()}getFeatures(t){return this.renderer_?this.renderer_.getFeatures(t):Promise.resolve([])}getData(t){return!this.renderer_||!this.rendered?null:this.renderer_.getData(t)}isVisible(t){let e;const i=this.getMapInternal();!t&&i&&(t=i.getView()),t instanceof re?e={viewState:t.getState(),extent:t.calculateExtent()}:e=t,!e.layerStatesArray&&i&&(e.layerStatesArray=i.getLayerGroup().getLayerStatesArray());let s;if(e.layerStatesArray){if(s=e.layerStatesArray.find(o=>o.layer===this),!s)return!1}else s=this.getLayerState();const r=this.getExtent();return Or(s,e.viewState)&&(!r||Pt(r,e.extent))}getAttributions(t){if(!this.isVisible(t))return[];const e=this.getSource()?.getAttributions();if(!e)return[];const i=t instanceof re?t.getViewStateAndExtent():t;let s=e(i);return Array.isArray(s)||(s=[s]),s}render(t,e){const i=this.getRenderer();return i.prepareFrame(t)?(this.rendered=!0,i.renderFrame(t,e)):null}unrender(){this.rendered=!1}getDeclutter(){}renderDeclutter(t,e){}renderDeferred(t){const e=this.getRenderer();e&&e.renderDeferred(t)}setMapInternal(t){t||this.unrender(),this.set(it.MAP,t)}getMapInternal(){return this.get(it.MAP)}setMap(t){this.mapPrecomposeKey_&&(at(this.mapPrecomposeKey_),this.mapPrecomposeKey_=null),t||this.changed(),this.mapRenderKey_&&(at(this.mapRenderKey_),this.mapRenderKey_=null),t&&(this.mapPrecomposeKey_=$(t,Bt.PRECOMPOSE,this.handlePrecompose_,this),this.mapRenderKey_=$(this,B.CHANGE,t.render,t),this.changed())}handlePrecompose_(t){const e=t.frameState.layerStatesArray,i=this.getLayerState(!1);Q(!e.some(s=>s.layer===i.layer),"A layer can only be added to the map once. Use either `layer.setMap()` or `map.addLayer()`, not both."),e.push(i)}setSource(t){this.set(it.SOURCE,t)}getRenderer(){return this.renderer_||(this.renderer_=this.createRenderer()),this.renderer_}hasRenderer(){return!!this.renderer_}createRenderer(){return null}clearRenderer(){this.renderer_&&(this.renderer_.dispose(),delete this.renderer_)}disposeInternal(){this.clearRenderer(),this.setSource(null),super.disposeInternal()}}function Or(n,t){if(!n.visible)return!1;const e=t.resolution;if(e<n.minResolution||e>=n.maxResolution)return!1;const i=t.zoom;return i>n.minZoom&&i<=n.maxZoom}function ul(n,t,e=0,i=n.length-1,s=Ed){for(;i>e;){if(i-e>600){const l=i-e+1,h=t-e+1,c=Math.log(l),u=.5*Math.exp(2*c/3),d=.5*Math.sqrt(c*u*(l-u)/l)*(h-l/2<0?-1:1),f=Math.max(e,Math.floor(t-h*u/l+d)),g=Math.min(i,Math.floor(t+(l-h)*u/l+d));ul(n,t,f,g,s)}const r=n[t];let o=e,a=i;for(en(n,e,t),s(n[i],r)>0&&en(n,e,i);o<a;){for(en(n,o,a),o++,a--;s(n[o],r)<0;)o++;for(;s(n[a],r)>0;)a--}s(n[e],r)===0?en(n,e,a):(a++,en(n,a,i)),a<=t&&(e=a+1),t<=a&&(i=a-1)}}function en(n,t,e){const i=n[t];n[t]=n[e],n[e]=i}function Ed(n,t){return n<t?-1:n>t?1:0}let dl=class{constructor(t=9){this._maxEntries=Math.max(4,t),this._minEntries=Math.max(2,Math.ceil(this._maxEntries*.4)),this.clear()}all(){return this._all(this.data,[])}search(t){let e=this.data;const i=[];if(!cs(t,e))return i;const s=this.toBBox,r=[];for(;e;){for(let o=0;o<e.children.length;o++){const a=e.children[o],l=e.leaf?s(a):a;cs(t,l)&&(e.leaf?i.push(a):Dr(t,l)?this._all(a,i):r.push(a))}e=r.pop()}return i}collides(t){let e=this.data;if(!cs(t,e))return!1;const i=[];for(;e;){for(let s=0;s<e.children.length;s++){const r=e.children[s],o=e.leaf?this.toBBox(r):r;if(cs(t,o)){if(e.leaf||Dr(t,o))return!0;i.push(r)}}e=i.pop()}return!1}load(t){if(!(t&&t.length))return this;if(t.length<this._minEntries){for(let i=0;i<t.length;i++)this.insert(t[i]);return this}let e=this._build(t.slice(),0,t.length-1,0);if(!this.data.children.length)this.data=e;else if(this.data.height===e.height)this._splitRoot(this.data,e);else{if(this.data.height<e.height){const i=this.data;this.data=e,e=i}this._insert(e,this.data.height-e.height-1,!0)}return this}insert(t){return t&&this._insert(t,this.data.height-1),this}clear(){return this.data=Ei([]),this}remove(t,e){if(!t)return this;let i=this.data;const s=this.toBBox(t),r=[],o=[];let a,l,h;for(;i||r.length;){if(i||(i=r.pop(),l=r[r.length-1],a=o.pop(),h=!0),i.leaf){const c=wd(t,i.children,e);if(c!==-1)return i.children.splice(c,1),r.push(i),this._condense(r),this}!h&&!i.leaf&&Dr(i,s)?(r.push(i),o.push(a),a=0,l=i,i=i.children[0]):l?(a++,i=l.children[a],h=!1):i=null}return this}toBBox(t){return t}compareMinX(t,e){return t.minX-e.minX}compareMinY(t,e){return t.minY-e.minY}toJSON(){return this.data}fromJSON(t){return this.data=t,this}_all(t,e){const i=[];for(;t;)t.leaf?e.push(...t.children):i.push(...t.children),t=i.pop();return e}_build(t,e,i,s){const r=i-e+1;let o=this._maxEntries,a;if(r<=o)return a=Ei(t.slice(e,i+1)),xi(a,this.toBBox),a;s||(s=Math.ceil(Math.log(r)/Math.log(o)),o=Math.ceil(r/Math.pow(o,s-1))),a=Ei([]),a.leaf=!1,a.height=s;const l=Math.ceil(r/o),h=l*Math.ceil(Math.sqrt(o));fl(t,e,i,h,this.compareMinX);for(let c=e;c<=i;c+=h){const u=Math.min(c+h-1,i);fl(t,c,u,l,this.compareMinY);for(let d=c;d<=u;d+=l){const f=Math.min(d+l-1,u);a.children.push(this._build(t,d,f,s-1))}}return xi(a,this.toBBox),a}_chooseSubtree(t,e,i,s){for(;s.push(e),!(e.leaf||s.length-1===i);){let r=1/0,o=1/0,a;for(let l=0;l<e.children.length;l++){const h=e.children[l],c=Pr(h),u=Rd(t,h)-c;u<o?(o=u,r=c<r?c:r,a=h):u===o&&c<r&&(r=c,a=h)}e=a||e.children[0]}return e}_insert(t,e,i){const s=i?t:this.toBBox(t),r=[],o=this._chooseSubtree(s,this.data,e,r);for(o.children.push(t),sn(o,s);e>=0&&r[e].children.length>this._maxEntries;)this._split(r,e),e--;this._adjustParentBBoxes(s,r,e)}_split(t,e){const i=t[e],s=i.children.length,r=this._minEntries;this._chooseSplitAxis(i,r,s);const o=this._chooseSplitIndex(i,r,s),a=Ei(i.children.splice(o,i.children.length-o));a.height=i.height,a.leaf=i.leaf,xi(i,this.toBBox),xi(a,this.toBBox),e?t[e-1].children.push(a):this._splitRoot(i,a)}_splitRoot(t,e){this.data=Ei([t,e]),this.data.height=t.height+1,this.data.leaf=!1,xi(this.data,this.toBBox)}_chooseSplitIndex(t,e,i){let s,r=1/0,o=1/0;for(let a=e;a<=i-e;a++){const l=nn(t,0,a,this.toBBox),h=nn(t,a,i,this.toBBox),c=Sd(l,h),u=Pr(l)+Pr(h);c<r?(r=c,s=a,o=u<o?u:o):c===r&&u<o&&(o=u,s=a)}return s||i-e}_chooseSplitAxis(t,e,i){const s=t.leaf?this.compareMinX:vd,r=t.leaf?this.compareMinY:Cd,o=this._allDistMargin(t,e,i,s),a=this._allDistMargin(t,e,i,r);o<a&&t.children.sort(s)}_allDistMargin(t,e,i,s){t.children.sort(s);const r=this.toBBox,o=nn(t,0,e,r),a=nn(t,i-e,i,r);let l=hs(o)+hs(a);for(let h=e;h<i-e;h++){const c=t.children[h];sn(o,t.leaf?r(c):c),l+=hs(o)}for(let h=i-e-1;h>=e;h--){const c=t.children[h];sn(a,t.leaf?r(c):c),l+=hs(a)}return l}_adjustParentBBoxes(t,e,i){for(let s=i;s>=0;s--)sn(e[s],t)}_condense(t){for(let e=t.length-1,i;e>=0;e--)t[e].children.length===0?e>0?(i=t[e-1].children,i.splice(i.indexOf(t[e]),1)):this.clear():xi(t[e],this.toBBox)}};function wd(n,t,e){if(!e)return t.indexOf(n);for(let i=0;i<t.length;i++)if(e(n,t[i]))return i;return-1}function xi(n,t){nn(n,0,n.children.length,t,n)}function nn(n,t,e,i,s){s||(s=Ei(null)),s.minX=1/0,s.minY=1/0,s.maxX=-1/0,s.maxY=-1/0;for(let r=t;r<e;r++){const o=n.children[r];sn(s,n.leaf?i(o):o)}return s}function sn(n,t){return n.minX=Math.min(n.minX,t.minX),n.minY=Math.min(n.minY,t.minY),n.maxX=Math.max(n.maxX,t.maxX),n.maxY=Math.max(n.maxY,t.maxY),n}function vd(n,t){return n.minX-t.minX}function Cd(n,t){return n.minY-t.minY}function Pr(n){return(n.maxX-n.minX)*(n.maxY-n.minY)}function hs(n){return n.maxX-n.minX+(n.maxY-n.minY)}function Rd(n,t){return(Math.max(t.maxX,n.maxX)-Math.min(t.minX,n.minX))*(Math.max(t.maxY,n.maxY)-Math.min(t.minY,n.minY))}function Sd(n,t){const e=Math.max(n.minX,t.minX),i=Math.max(n.minY,t.minY),s=Math.min(n.maxX,t.maxX),r=Math.min(n.maxY,t.maxY);return Math.max(0,s-e)*Math.max(0,r-i)}function Dr(n,t){return n.minX<=t.minX&&n.minY<=t.minY&&t.maxX<=n.maxX&&t.maxY<=n.maxY}function cs(n,t){return t.minX<=n.maxX&&t.minY<=n.maxY&&t.maxX>=n.minX&&t.maxY>=n.minY}function Ei(n){return{children:n,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function fl(n,t,e,i,s){const r=[t,e];for(;r.length;){if(e=r.pop(),t=r.pop(),e-t<=i)continue;const o=t+Math.ceil((e-t)/i/2)*i;ul(n,o,t,e,s),r.push(t,o,o,e)}}const kr=[NaN,NaN,NaN,0];let Fr;function Id(){return Fr||(Fr=gt(1,1,void 0,{willReadFrequently:!0,desynchronized:!0})),Fr}const Td=/^rgba?\(\s*(\d+%?)\s+(\d+%?)\s+(\d+%?)(?:\s*\/\s*(\d+%|\d*\.\d+|[01]))?\s*\)$/i,bd=/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)(?:\s*,\s*(\d+%|\d*\.\d+|[01]))?\s*\)$/i,Md=/^rgba?\(\s*(\d+%)\s*,\s*(\d+%)\s*,\s*(\d+%)(?:\s*,\s*(\d+%|\d*\.\d+|[01]))?\s*\)$/i,Ld=/^#([\da-f]{3,4}|[\da-f]{6}|[\da-f]{8})$/i;function us(n,t){return n.endsWith("%")?Number(n.substring(0,n.length-1))/t:Number(n)}function rn(n){throw new Error('failed to parse "'+n+'" as color')}function gl(n){if(n.toLowerCase().startsWith("rgb")){const r=n.match(bd)||n.match(Td)||n.match(Md);if(r){const o=r[4],a=100/255;return[lt(us(r[1],a)+.5|0,0,255),lt(us(r[2],a)+.5|0,0,255),lt(us(r[3],a)+.5|0,0,255),o!==void 0?lt(us(o,100),0,1):1]}rn(n)}if(n.startsWith("#")){if(Ld.test(n)){const r=n.substring(1),o=r.length<=4?1:2,a=[0,0,0,255];for(let l=0,h=r.length;l<h;l+=o){let c=parseInt(r.substring(l,l+o),16);o===1&&(c+=c<<4),a[l/o]=c}return a[3]=a[3]/255,a}rn(n)}const t=Id();t.fillStyle="#abcdef";let e=t.fillStyle;t.fillStyle=n,t.fillStyle===e&&(t.fillStyle="#fedcba",e=t.fillStyle,t.fillStyle=n,t.fillStyle===e&&rn(n));const i=t.fillStyle;if(i.startsWith("#")||i.startsWith("rgba"))return gl(i);t.clearRect(0,0,1,1),t.fillRect(0,0,1,1);const s=Array.from(t.getImageData(0,0,1,1).data);return s[3]=Wn(s[3]/255,3),s}function Ad(n){return typeof n=="string"?n:Br(n)}const Od=1024,on={};let Nr=0;function Pd(n){if(n.length===4)return n;const t=n.slice();return t[3]=1,t}function zr(n){return n>.0031308?Math.pow(n,1/2.4)*269.025-14.025:n*3294.6}function Gr(n){return n>.2068965?Math.pow(n,3):(n-4/29)*(108/841)}function Wr(n){return n>10.314724?Math.pow((n+14.025)/269.025,2.4):n/3294.6}function Xr(n){return n>.0088564?Math.pow(n,1/3):n/(108/841)+4/29}function _l(n){const t=Wr(n[0]),e=Wr(n[1]),i=Wr(n[2]),s=Xr(t*.222488403+e*.716873169+i*.06060791),r=500*(Xr(t*.452247074+e*.399439023+i*.148375274)-s),o=200*(s-Xr(t*.016863605+e*.117638439+i*.865350722)),a=Math.atan2(o,r)*(180/Math.PI);return[116*s-16,Math.sqrt(r*r+o*o),a<0?a+360:a,n[3]]}function Dd(n){const t=(n[0]+16)/116,e=n[1],i=n[2]*Math.PI/180,s=Gr(t),r=Gr(t+e/500*Math.cos(i)),o=Gr(t-e/200*Math.sin(i)),a=zr(r*3.021973625-s*1.617392459-o*.404875592),l=zr(r*-.943766287+s*1.916279586+o*.027607165),h=zr(r*.069407491-s*.22898585+o*1.159737864);return[lt(a+.5|0,0,255),lt(l+.5|0,0,255),lt(h+.5|0,0,255),n[3]]}function Yr(n){if(n==="none")return kr;if(on.hasOwnProperty(n))return on[n];if(Nr>=Od){let e=0;for(const i in on)(e++&3)===0&&(delete on[i],--Nr)}const t=gl(n);t.length!==4&&rn(n);for(const e of t)isNaN(e)&&rn(n);return on[n]=t,++Nr,t}function wi(n){return Array.isArray(n)?n:Yr(n)}function Br(n){let t=n[0];t!=(t|0)&&(t=t+.5|0);let e=n[1];e!=(e|0)&&(e=e+.5|0);let i=n[2];i!=(i|0)&&(i=i+.5|0);const s=n[3]===void 0?1:Math.round(n[3]*1e3)/1e3;return"rgba("+t+","+e+","+i+","+s+")"}function ml(n){return n[0]>0&&n[1]>0}function kd(n,t,e){return e===void 0&&(e=[0,0]),e[0]=n[0]*t+.5|0,e[1]=n[1]*t+.5|0,e}function kt(n,t){return Array.isArray(n)?n:(t===void 0?t=[n,n]:(t[0]=n,t[1]=n),t)}let He=0;const Tt=1<<He++,Z=1<<He++,Ft=1<<He++,Jt=1<<He++,qe=1<<He++,an=1<<He++,ds=Math.pow(2,He)-1,Ur={[Tt]:"boolean",[Z]:"number",[Ft]:"string",[Jt]:"color",[qe]:"number[]",[an]:"size"},Fd=Object.keys(Ur).map(Number).sort(ce);function Nd(n){return n in Ur}function ln(n){const t=[];for(const e of Fd)hn(n,e)&&t.push(Ur[e]);return t.length===0?"untyped":t.length<3?t.join(" or "):t.slice(0,-1).join(", ")+", or "+t[t.length-1]}function hn(n,t){return(n&t)===t}function Ae(n,t){return n===t}class _t{constructor(t,e){if(!Nd(t))throw new Error(`literal expressions must have a specific type, got ${ln(t)}`);this.type=t,this.value=e}}class zd{constructor(t,e,...i){this.type=t,this.operator=e,this.args=i}}function pl(){return{variables:new Set,properties:new Set,featureId:!1,geometryType:!1,mapState:!1}}function Ct(n,t,e){switch(typeof n){case"boolean":{if(Ae(t,Ft))return new _t(Ft,n?"true":"false");if(!hn(t,Tt))throw new Error(`got a boolean, but expected ${ln(t)}`);return new _t(Tt,n)}case"number":{if(Ae(t,an))return new _t(an,kt(n));if(Ae(t,Tt))return new _t(Tt,!!n);if(Ae(t,Ft))return new _t(Ft,n.toString());if(!hn(t,Z))throw new Error(`got a number, but expected ${ln(t)}`);return new _t(Z,n)}case"string":{if(Ae(t,Jt))return new _t(Jt,Yr(n));if(Ae(t,Tt))return new _t(Tt,!!n);if(!hn(t,Ft))throw new Error(`got a string, but expected ${ln(t)}`);return new _t(Ft,n)}}if(!Array.isArray(n))throw new Error("expression must be an array or a primitive value");if(n.length===0)throw new Error("empty expression");if(typeof n[0]=="string")return $d(n,t,e);for(const i of n)if(typeof i!="number")throw new Error("expected an array of numbers");if(Ae(t,an)){if(n.length!==2)throw new Error(`expected an array of two values for a size, got ${n.length}`);return new _t(an,n)}if(Ae(t,Jt)){if(n.length===3)return new _t(Jt,[...n,1]);if(n.length===4)return new _t(Jt,n);throw new Error(`expected an array of 3 or 4 values for a color, got ${n.length}`)}if(!hn(t,qe))throw new Error(`got an array of numbers, but expected ${ln(t)}`);return new _t(qe,n)}const C={Get:"get",Var:"var",Concat:"concat",GeometryType:"geometry-type",LineMetric:"line-metric",Any:"any",All:"all",Not:"!",Resolution:"resolution",Zoom:"zoom",Time:"time",Equal:"==",NotEqual:"!=",GreaterThan:">",GreaterThanOrEqualTo:">=",LessThan:"<",LessThanOrEqualTo:"<=",Multiply:"*",Divide:"/",Add:"+",Subtract:"-",Clamp:"clamp",Mod:"%",Pow:"^",Abs:"abs",Floor:"floor",Ceil:"ceil",Round:"round",Sin:"sin",Cos:"cos",Atan:"atan",Sqrt:"sqrt",Match:"match",Between:"between",Interpolate:"interpolate",Coalesce:"coalesce",Case:"case",In:"in",Number:"number",String:"string",Array:"array",Color:"color",Id:"id",Band:"band",Palette:"palette",ToString:"to-string",Has:"has"},Gd={[C.Get]:z(U(1,1/0),yl),[C.Var]:z(U(1,1),Wd),[C.Has]:z(U(1,1/0),yl),[C.Id]:z(Xd,vi),[C.Concat]:z(U(2,1/0),J(Ft)),[C.GeometryType]:z(Yd,vi),[C.LineMetric]:z(vi),[C.Resolution]:z(Kr,vi),[C.Zoom]:z(Kr,vi),[C.Time]:z(Kr,vi),[C.Any]:z(U(2,1/0),J(Tt)),[C.All]:z(U(2,1/0),J(Tt)),[C.Not]:z(U(1,1),J(Tt)),[C.Equal]:z(U(2,2),J(ds)),[C.NotEqual]:z(U(2,2),J(ds)),[C.GreaterThan]:z(U(2,2),J(Z)),[C.GreaterThanOrEqualTo]:z(U(2,2),J(Z)),[C.LessThan]:z(U(2,2),J(Z)),[C.LessThanOrEqualTo]:z(U(2,2),J(Z)),[C.Multiply]:z(U(2,1/0),xl),[C.Coalesce]:z(U(2,1/0),xl),[C.Divide]:z(U(2,2),J(Z)),[C.Add]:z(U(2,1/0),J(Z)),[C.Subtract]:z(U(2,2),J(Z)),[C.Clamp]:z(U(3,3),J(Z)),[C.Mod]:z(U(2,2),J(Z)),[C.Pow]:z(U(2,2),J(Z)),[C.Abs]:z(U(1,1),J(Z)),[C.Floor]:z(U(1,1),J(Z)),[C.Ceil]:z(U(1,1),J(Z)),[C.Round]:z(U(1,1),J(Z)),[C.Sin]:z(U(1,1),J(Z)),[C.Cos]:z(U(1,1),J(Z)),[C.Atan]:z(U(1,2),J(Z)),[C.Sqrt]:z(U(1,1),J(Z)),[C.Match]:z(U(4,1/0),El,Ud),[C.Between]:z(U(3,3),J(Z)),[C.Interpolate]:z(U(6,1/0),El,Kd),[C.Case]:z(U(3,1/0),Bd,jd),[C.In]:z(U(2,2),Vd),[C.Number]:z(U(1,1/0),J(ds)),[C.String]:z(U(1,1/0),J(ds)),[C.Array]:z(U(1,1/0),J(Z)),[C.Color]:z(U(1,4),J(Z)),[C.Band]:z(U(1,3),J(Z)),[C.Palette]:z(U(2,2),Zd),[C.ToString]:z(U(1,1),J(Tt|Z|Ft|Jt))};function yl(n,t,e){const i=n.length-1,s=new Array(i);for(let r=0;r<i;++r){const o=n[r+1];switch(typeof o){case"number":{s[r]=new _t(Z,o);break}case"string":{s[r]=new _t(Ft,o);break}default:throw new Error(`expected a string key or numeric array index for a get operation, got ${o}`)}r===0&&e.properties.add(String(o))}return s}function Wd(n,t,e){const i=n[1];if(typeof i!="string")throw new Error("expected a string argument for var operation");return e.variables.add(i),[new _t(Ft,i)]}function Xd(n,t,e){e.featureId=!0}function Yd(n,t,e){e.geometryType=!0}function Kr(n,t,e){e.mapState=!0}function vi(n,t,e){const i=n[0];if(n.length!==1)throw new Error(`expected no arguments for ${i} operation`);return[]}function U(n,t){return function(e,i,s){const r=e[0],o=e.length-1;if(n===t){if(o!==n){const a=n===1?"":"s";throw new Error(`expected ${n} argument${a} for ${r}, got ${o}`)}}else if(o<n||o>t){const a=t===1/0?`${n} or more`:`${n} to ${t}`;throw new Error(`expected ${a} arguments for ${r}, got ${o}`)}}}function xl(n,t,e){const i=n.length-1,s=new Array(i);for(let r=0;r<i;++r){const o=Ct(n[r+1],t,e);s[r]=o}return s}function J(n){return function(t,e,i){const s=t.length-1,r=new Array(s);for(let o=0;o<s;++o){const a=Ct(t[o+1],n,i);r[o]=a}return r}}function Bd(n,t,e){const i=n[0],s=n.length-1;if(s%2===0)throw new Error(`expected an odd number of arguments for ${i}, got ${s} instead`)}function El(n,t,e){const i=n[0],s=n.length-1;if(s%2===1)throw new Error(`expected an even number of arguments for operation ${i}, got ${s} instead`)}function Ud(n,t,e){const i=n.length-1,s=Ft|Z|Tt,r=Ct(n[1],s,e),o=Ct(n[n.length-1],t,e),a=new Array(i-2);for(let l=0;l<i-2;l+=2){try{const h=Ct(n[l+2],r.type,e);a[l]=h}catch(h){throw new Error(`failed to parse argument ${l+1} of match expression: ${h.message}`)}try{const h=Ct(n[l+3],o.type,e);a[l+1]=h}catch(h){throw new Error(`failed to parse argument ${l+2} of match expression: ${h.message}`)}}return[r,...a,o]}function Kd(n,t,e){const i=n[1];let s;switch(i[0]){case"linear":s=1;break;case"exponential":const l=i[1];if(typeof l!="number"||l<=0)throw new Error(`expected a number base for exponential interpolation, got ${JSON.stringify(l)} instead`);s=l;break;default:throw new Error(`invalid interpolation type: ${JSON.stringify(i)}`)}const r=new _t(Z,s);let o;try{o=Ct(n[2],Z,e)}catch(l){throw new Error(`failed to parse argument 1 in interpolate expression: ${l.message}`)}const a=new Array(n.length-3);for(let l=0;l<a.length;l+=2){try{const h=Ct(n[l+3],Z,e);a[l]=h}catch(h){throw new Error(`failed to parse argument ${l+2} for interpolate expression: ${h.message}`)}try{const h=Ct(n[l+4],t,e);a[l+1]=h}catch(h){throw new Error(`failed to parse argument ${l+3} for interpolate expression: ${h.message}`)}}return[r,o,...a]}function jd(n,t,e){const i=Ct(n[n.length-1],t,e),s=new Array(n.length-1);for(let r=0;r<s.length-1;r+=2){try{const o=Ct(n[r+1],Tt,e);s[r]=o}catch(o){throw new Error(`failed to parse argument ${r} of case expression: ${o.message}`)}try{const o=Ct(n[r+2],i.type,e);s[r+1]=o}catch(o){throw new Error(`failed to parse argument ${r+1} of case expression: ${o.message}`)}}return s[s.length-1]=i,s}function Vd(n,t,e){let i=n[2];if(!Array.isArray(i))throw new Error('the second argument for the "in" operator must be an array');let s;if(typeof i[0]=="string"){if(i[0]!=="literal")throw new Error('for the "in" operator, a string array should be wrapped in a "literal" operator to disambiguate from expressions');if(!Array.isArray(i[1]))throw new Error('failed to parse "in" expression: the literal operator must be followed by an array');i=i[1],s=Ft}else s=Z;const r=new Array(i.length);for(let a=0;a<r.length;a++)try{const l=Ct(i[a],s,e);r[a]=l}catch(l){throw new Error(`failed to parse haystack item ${a} for "in" expression: ${l.message}`)}return[Ct(n[1],s,e),...r]}function Zd(n,t,e){let i;try{i=Ct(n[1],Z,e)}catch(o){throw new Error(`failed to parse first argument in palette expression: ${o.message}`)}const s=n[2];if(!Array.isArray(s))throw new Error("the second argument of palette must be an array");const r=new Array(s.length);for(let o=0;o<r.length;o++){let a;try{a=Ct(s[o],Jt,e)}catch(l){throw new Error(`failed to parse color at index ${o} in palette expression: ${l.message}`)}if(!(a instanceof _t))throw new Error(`the palette color at index ${o} must be a literal value`);r[o]=a}return[i,...r]}function z(...n){return function(t,e,i){const s=t[0];let r;for(let o=0;o<n.length;o++){const a=n[o](t,e,i);if(o==n.length-1){if(!a)throw new Error("expected last argument validator to return the parsed args");r=a}}return new zd(e,s,...r)}}function $d(n,t,e){const i=n[0],s=Gd[i];if(!s)throw new Error(`unknown operator: ${i}`);return s(n,t,e)}function wl(n){if(!n)return"";const t=n.getType();switch(t){case"Point":case"LineString":case"Polygon":return t;case"MultiPoint":case"MultiLineString":case"MultiPolygon":return t.substring(5);case"Circle":return"Polygon";case"GeometryCollection":return wl(n.getGeometries()[0]);default:return""}}function vl(){return{variables:{},properties:{},resolution:NaN,featureId:null,geometryType:""}}function ge(n,t,e){const i=Ct(n,t,e);return Qt(i)}function Qt(n,t){if(n instanceof _t){if(n.type===Jt&&typeof n.value=="string"){const i=Yr(n.value);return function(){return i}}return function(){return n.value}}const e=n.operator;switch(e){case C.Number:case C.String:case C.Coalesce:return Hd(n);case C.Get:case C.Var:case C.Has:return qd(n);case C.Id:return i=>i.featureId;case C.GeometryType:return i=>i.geometryType;case C.Concat:{const i=n.args.map(s=>Qt(s));return s=>"".concat(...i.map(r=>r(s).toString()))}case C.Resolution:return i=>i.resolution;case C.Any:case C.All:case C.Between:case C.In:case C.Not:return Qd(n);case C.Equal:case C.NotEqual:case C.LessThan:case C.LessThanOrEqualTo:case C.GreaterThan:case C.GreaterThanOrEqualTo:return Jd(n);case C.Multiply:case C.Divide:case C.Add:case C.Subtract:case C.Clamp:case C.Mod:case C.Pow:case C.Abs:case C.Floor:case C.Ceil:case C.Round:case C.Sin:case C.Cos:case C.Atan:case C.Sqrt:return tf(n);case C.Case:return ef(n);case C.Match:return nf(n);case C.Interpolate:return sf(n);case C.ToString:return rf(n);default:throw new Error(`Unsupported operator ${e}`)}}function Hd(n,t){const e=n.operator,i=n.args.length,s=new Array(i);for(let r=0;r<i;++r)s[r]=Qt(n.args[r]);switch(e){case C.Coalesce:return r=>{for(let o=0;o<i;++o){const a=s[o](r);if(typeof a<"u"&&a!==null)return a}throw new Error("Expected one of the values to be non-null")};case C.Number:case C.String:return r=>{for(let o=0;o<i;++o){const a=s[o](r);if(typeof a===e)return a}throw new Error(`Expected one of the values to be a ${e}`)};default:throw new Error(`Unsupported assertion operator ${e}`)}}function qd(n,t){const i=n.args[0].value;switch(n.operator){case C.Get:return s=>{const r=n.args;let o=s.properties[i];for(let a=1,l=r.length;a<l;++a){const c=r[a].value;o=o[c]}return o};case C.Var:return s=>s.variables[i];case C.Has:return s=>{const r=n.args;if(!(i in s.properties))return!1;let o=s.properties[i];for(let a=1,l=r.length;a<l;++a){const c=r[a].value;if(!o||!Object.hasOwn(o,c))return!1;o=o[c]}return!0};default:throw new Error(`Unsupported accessor operator ${n.operator}`)}}function Jd(n,t){const e=n.operator,i=Qt(n.args[0]),s=Qt(n.args[1]);switch(e){case C.Equal:return r=>i(r)===s(r);case C.NotEqual:return r=>i(r)!==s(r);case C.LessThan:return r=>i(r)<s(r);case C.LessThanOrEqualTo:return r=>i(r)<=s(r);case C.GreaterThan:return r=>i(r)>s(r);case C.GreaterThanOrEqualTo:return r=>i(r)>=s(r);default:throw new Error(`Unsupported comparison operator ${e}`)}}function Qd(n,t){const e=n.operator,i=n.args.length,s=new Array(i);for(let r=0;r<i;++r)s[r]=Qt(n.args[r]);switch(e){case C.Any:return r=>{for(let o=0;o<i;++o)if(s[o](r))return!0;return!1};case C.All:return r=>{for(let o=0;o<i;++o)if(!s[o](r))return!1;return!0};case C.Between:return r=>{const o=s[0](r),a=s[1](r),l=s[2](r);return o>=a&&o<=l};case C.In:return r=>{const o=s[0](r);for(let a=1;a<i;++a)if(o===s[a](r))return!0;return!1};case C.Not:return r=>!s[0](r);default:throw new Error(`Unsupported logical operator ${e}`)}}function tf(n,t){const e=n.operator,i=n.args.length,s=new Array(i);for(let r=0;r<i;++r)s[r]=Qt(n.args[r]);switch(e){case C.Multiply:return r=>{let o=1;for(let a=0;a<i;++a)o*=s[a](r);return o};case C.Divide:return r=>s[0](r)/s[1](r);case C.Add:return r=>{let o=0;for(let a=0;a<i;++a)o+=s[a](r);return o};case C.Subtract:return r=>s[0](r)-s[1](r);case C.Clamp:return r=>{const o=s[0](r),a=s[1](r);if(o<a)return a;const l=s[2](r);return o>l?l:o};case C.Mod:return r=>s[0](r)%s[1](r);case C.Pow:return r=>Math.pow(s[0](r),s[1](r));case C.Abs:return r=>Math.abs(s[0](r));case C.Floor:return r=>Math.floor(s[0](r));case C.Ceil:return r=>Math.ceil(s[0](r));case C.Round:return r=>Math.round(s[0](r));case C.Sin:return r=>Math.sin(s[0](r));case C.Cos:return r=>Math.cos(s[0](r));case C.Atan:return i===2?r=>Math.atan2(s[0](r),s[1](r)):r=>Math.atan(s[0](r));case C.Sqrt:return r=>Math.sqrt(s[0](r));default:throw new Error(`Unsupported numeric operator ${e}`)}}function ef(n,t){const e=n.args.length,i=new Array(e);for(let s=0;s<e;++s)i[s]=Qt(n.args[s]);return s=>{for(let r=0;r<e-1;r+=2)if(i[r](s))return i[r+1](s);return i[e-1](s)}}function nf(n,t){const e=n.args.length,i=new Array(e);for(let s=0;s<e;++s)i[s]=Qt(n.args[s]);return s=>{const r=i[0](s);for(let o=1;o<e-1;o+=2)if(r===i[o](s))return i[o+1](s);return i[e-1](s)}}function sf(n,t){const e=n.args.length,i=new Array(e);for(let s=0;s<e;++s)i[s]=Qt(n.args[s]);return s=>{const r=i[0](s),o=i[1](s);let a,l;for(let h=2;h<e;h+=2){const c=i[h](s);let u=i[h+1](s);const d=Array.isArray(u);if(d&&(u=Pd(u)),c>=o)return h===2?u:d?of(r,o,a,l,c,u):cn(r,o,a,l,c,u);a=c,l=u}return l}}function rf(n,t){const e=n.operator,i=n.args.length,s=new Array(i);for(let r=0;r<i;++r)s[r]=Qt(n.args[r]);switch(e){case C.ToString:return r=>{const o=s[0](r);return n.args[0].type===Jt?Br(o):o.toString()};default:throw new Error(`Unsupported convert operator ${e}`)}}function cn(n,t,e,i,s,r){const o=s-e;if(o===0)return i;const a=t-e,l=n===1?a/o:(Math.pow(n,a)-1)/(Math.pow(n,o)-1);return i+l*(r-i)}function of(n,t,e,i,s,r){if(s-e===0)return i;const a=_l(i),l=_l(r);let h=l[2]-a[2];h>180?h-=360:h<-180&&(h+=360);const c=[cn(n,t,e,a[0],s,l[0]),cn(n,t,e,a[1],s,l[1]),a[2]+cn(n,t,e,0,s,h),cn(n,t,e,i[3],s,r[3])];return Dd(c)}const K={IDLE:0,LOADING:1,LOADED:2,ERROR:3};function af(n,t,e){const i=n;let s=!0,r=!1,o=!1;const a=[Nn(i,B.LOAD,function(){o=!0,r||t()})];return i.src&&na?(r=!0,i.decode().then(function(){s&&t()}).catch(function(l){s&&(o?t():e())})):a.push(Nn(i,B.ERROR,e)),function(){s=!1,a.forEach(at)}}function lf(n,t){return new Promise((e,i)=>{function s(){o(),e(n)}function r(){o(),i(new Error("Image load error"))}function o(){n.removeEventListener("load",s),n.removeEventListener("error",r)}n.addEventListener("load",s),n.addEventListener("error",r)})}function hf(n,t){return t&&(n.src=t),n.src&&na?new Promise((e,i)=>n.decode().then(()=>e(n)).catch(s=>n.complete&&n.width?e(n):i(s))):lf(n)}class cf{constructor(){this.cache_={},this.patternCache_={},this.cacheSize_=0,this.maxCacheSize_=1024}clear(){this.cache_={},this.patternCache_={},this.cacheSize_=0}canExpireCache(){return this.cacheSize_>this.maxCacheSize_}expire(){if(this.canExpireCache()){let t=0;for(const e in this.cache_){const i=this.cache_[e];(t++&3)===0&&!i.hasListener()&&(delete this.cache_[e],delete this.patternCache_[e],--this.cacheSize_)}}}get(t,e,i){const s=jr(t,e,i);return s in this.cache_?this.cache_[s]:null}getPattern(t,e,i){const s=jr(t,e,i);return s in this.patternCache_?this.patternCache_[s]:null}set(t,e,i,s,r){const o=jr(t,e,i),a=o in this.cache_;this.cache_[o]=s,r&&(s.getImageState()===K.IDLE&&s.load(),s.getImageState()===K.LOADING?s.ready().then(()=>{this.patternCache_[o]=os().createPattern(s.getImage(1),"repeat")}):this.patternCache_[o]=os().createPattern(s.getImage(1),"repeat")),a||++this.cacheSize_}setSize(t){this.maxCacheSize_=t,this.expire()}}function jr(n,t,e){const i=e?wi(e):"null";return t+":"+n+":"+i}const Ut=new cf;let un=null;class Cl extends Fn{constructor(t,e,i,s,r){super(),this.hitDetectionImage_=null,this.image_=t,this.crossOrigin_=i,this.canvas_={},this.color_=r,this.imageState_=s===void 0?K.IDLE:s,this.size_=t&&t.width&&t.height?[t.width,t.height]:null,this.src_=e,this.tainted_,this.ready_=null}initializeImage_(){this.image_=new Image,this.crossOrigin_!==null&&(this.image_.crossOrigin=this.crossOrigin_)}isTainted_(){if(this.tainted_===void 0&&this.imageState_===K.LOADED){un||(un=gt(1,1,void 0,{willReadFrequently:!0})),un.drawImage(this.image_,0,0);try{un.getImageData(0,0,1,1),this.tainted_=!1}catch{un=null,this.tainted_=!0}}return this.tainted_===!0}dispatchChangeEvent_(){this.dispatchEvent(B.CHANGE)}handleImageError_(){this.imageState_=K.ERROR,this.dispatchChangeEvent_()}handleImageLoad_(){this.imageState_=K.LOADED,this.size_=[this.image_.width,this.image_.height],this.dispatchChangeEvent_()}getImage(t){return this.image_||this.initializeImage_(),this.replaceColor_(t),this.canvas_[t]?this.canvas_[t]:this.image_}getPixelRatio(t){return this.replaceColor_(t),this.canvas_[t]?t:1}getImageState(){return this.imageState_}getHitDetectionImage(){if(this.image_||this.initializeImage_(),!this.hitDetectionImage_)if(this.isTainted_()){const t=this.size_[0],e=this.size_[1],i=gt(t,e);i.fillRect(0,0,t,e),this.hitDetectionImage_=i.canvas}else this.hitDetectionImage_=this.image_;return this.hitDetectionImage_}getSize(){return this.size_}getSrc(){return this.src_}load(){if(this.imageState_===K.IDLE){this.image_||this.initializeImage_(),this.imageState_=K.LOADING;try{this.src_!==void 0&&(this.image_.src=this.src_)}catch{this.handleImageError_()}this.image_ instanceof HTMLImageElement&&hf(this.image_,this.src_).then(t=>{this.image_=t,this.handleImageLoad_()}).catch(this.handleImageError_.bind(this))}}replaceColor_(t){if(!this.color_||this.canvas_[t]||this.imageState_!==K.LOADED)return;const e=this.image_,i=gt(Math.ceil(e.width*t),Math.ceil(e.height*t)),s=i.canvas;i.scale(t,t),i.drawImage(e,0,0),i.globalCompositeOperation="multiply",i.fillStyle=Ad(this.color_),i.fillRect(0,0,s.width/t,s.height/t),i.globalCompositeOperation="destination-in",i.drawImage(e,0,0),this.canvas_[t]=s}ready(){return this.ready_||(this.ready_=new Promise(t=>{if(this.imageState_===K.LOADED||this.imageState_===K.ERROR)t();else{const e=()=>{(this.imageState_===K.LOADED||this.imageState_===K.ERROR)&&(this.removeEventListener(B.CHANGE,e),t())};this.addEventListener(B.CHANGE,e)}})),this.ready_}}function Vr(n,t,e,i,s,r){let o=t===void 0?void 0:Ut.get(t,e,s);return o||(o=new Cl(n,n&&"src"in n?n.src||void 0:t,e,i,s),Ut.set(t,e,s,o,r)),r&&o&&!Ut.getPattern(t,e,s)&&Ut.set(t,e,s,o,r),o}function oe(n){return n?Array.isArray(n)?Br(n):typeof n=="object"&&"src"in n?uf(n):n:null}function uf(n){if(!n.offset||!n.size)return Ut.getPattern(n.src,"anonymous",n.color);const t=n.src+":"+n.offset,e=Ut.getPattern(t,void 0,n.color);if(e)return e;const i=Ut.get(n.src,"anonymous",null);if(i.getImageState()!==K.LOADED)return null;const s=gt(n.size[0],n.size[1]);return s.drawImage(i.getImage(1),n.offset[0],n.offset[1],n.size[0],n.size[1],0,0,n.size[0],n.size[1]),Vr(s.canvas,t,void 0,K.LOADED,n.color,!0),Ut.getPattern(t,void 0,n.color)}const Rl="10px sans-serif",Nt="#000",Ci="round",_e=[],me=0,Ri="round",dn=10,fn="#000",gn="center",fs="middle",Je=[0,0,0,0],_n=1,Si=new ne;let mn=null,Sl;const Zr={},df=new Set(["serif","sans-serif","monospace","cursive","fantasy","system-ui","ui-serif","ui-sans-serif","ui-monospace","ui-rounded","emoji","math","fangsong"]);function ff(n,t,e){return`${n} ${t} 16px "${e}"`}const gf=(function(){let t,e;async function i(r){await e.ready;const o=await e.load(r);if(o.length===0)return!1;const a=Rr(r),l=a.families[0].toLowerCase(),h=a.weight;return o.some(c=>{const u=c.family.replace(/^['"]|['"]$/g,"").toLowerCase(),d=Cr[c.weight]||c.weight;return u===l&&c.style===a.style&&d==h})}async function s(){await e.ready;let r=!0;const o=Si.getProperties(),a=Object.keys(o).filter(l=>o[l]<100);for(let l=a.length-1;l>=0;--l){const h=a[l];let c=o[h];c<100&&(await i(h)?(Bi(Zr),Si.set(h,100)):(c+=10,Si.set(h,c,!0),c<100&&(r=!1)))}t=void 0,r||(t=setTimeout(s,100))}return async function(r){e||(e=Ys?self.fonts:document.fonts);const o=Rr(r);if(!o)return;const a=o.families;let l=!1;for(const h of a){if(df.has(h))continue;const c=ff(o.style,o.weight,h);Si.get(c)===void 0&&(Si.set(c,0,!0),l=!0)}l&&(clearTimeout(t),t=setTimeout(s,100))}})(),_f=(function(){let n;return function(t){let e=Zr[t];if(e==null){if(Ys){const i=Rr(t),s=Il(t,"Žg");e=(isNaN(Number(i.lineHeight))?1.2:Number(i.lineHeight))*(s.actualBoundingBoxAscent+s.actualBoundingBoxDescent)}else n||(n=document.createElement("div"),n.innerHTML="M",n.style.minHeight="0",n.style.maxHeight="none",n.style.height="auto",n.style.padding="0",n.style.border="none",n.style.position="absolute",n.style.display="block",n.style.left="-99999px"),n.style.font=t,document.body.appendChild(n),e=n.offsetHeight,document.body.removeChild(n);Zr[t]=e}return e}})();function Il(n,t){return mn||(mn=gt(1,1)),n!=Sl&&(mn.font=n,Sl=mn.font),mn.measureText(t)}function Tl(n,t){return Il(n,t).width}function bl(n,t,e){if(t in e)return e[t];const i=t.split(`
|
|
5
|
+
color: hsl(${Math.max(0,Math.min(120-120*_,120))}deg 100% 31%);`,e?.key)}return(h=e?.onChange)==null||h.call(e,s),s}return r.updateDeps=o=>{i=o},r}function Zo(n,t){if(n===void 0)throw new Error("Unexpected undefined");return n}const jh=(n,t)=>Math.abs(n-t)<1.01,Vh=(n,t,e)=>{let i;return function(...s){n.clearTimeout(i),i=n.setTimeout(()=>t.apply(this,s),e)}},$o=n=>{const{offsetWidth:t,offsetHeight:e}=n;return{width:t,height:e}},Zh=n=>n,$h=n=>{const t=Math.max(n.startIndex-n.overscan,0),e=Math.min(n.endIndex+n.overscan,n.count-1),i=[];for(let s=t;s<=e;s++)i.push(s);return i},Hh=(n,t)=>{const e=n.scrollElement;if(!e)return;const i=n.targetWindow;if(!i)return;const s=o=>{const{width:a,height:l}=o;t({width:Math.round(a),height:Math.round(l)})};if(s($o(e)),!i.ResizeObserver)return()=>{};const r=new i.ResizeObserver(o=>{const a=()=>{const l=o[0];if(l?.borderBoxSize){const h=l.borderBoxSize[0];if(h){s({width:h.inlineSize,height:h.blockSize});return}}s($o(e))};n.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(a):a()});return r.observe(e,{box:"border-box"}),()=>{r.unobserve(e)}},Ho={passive:!0},qo=typeof window>"u"?!0:"onscrollend"in window,qh=(n,t)=>{const e=n.scrollElement;if(!e)return;const i=n.targetWindow;if(!i)return;let s=0;const r=n.options.useScrollendEvent&&qo?()=>{}:Vh(i,()=>{t(s,!1)},n.options.isScrollingResetDelay),o=c=>()=>{const{horizontal:u,isRtl:d}=n.options;s=u?e.scrollLeft*(d&&-1||1):e.scrollTop,r(),t(s,c)},a=o(!0),l=o(!1);l(),e.addEventListener("scroll",a,Ho);const h=n.options.useScrollendEvent&&qo;return h&&e.addEventListener("scrollend",l,Ho),()=>{e.removeEventListener("scroll",a),h&&e.removeEventListener("scrollend",l)}},Jh=(n,t,e)=>{if(t?.borderBoxSize){const i=t.borderBoxSize[0];if(i)return Math.round(i[e.options.horizontal?"inlineSize":"blockSize"])}return n[e.options.horizontal?"offsetWidth":"offsetHeight"]},Qh=(n,{adjustments:t=0,behavior:e},i)=>{var s,r;const o=n+t;(r=(s=i.scrollElement)==null?void 0:s.scrollTo)==null||r.call(s,{[i.options.horizontal?"left":"top"]:o,behavior:e})};class tc{constructor(t){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.measurementsCache=[],this.itemSizeCache=new Map,this.pendingMeasuredCacheIndexes=[],this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this.elementsCache=new Map,this.observer=(()=>{let e=null;const i=()=>e||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:e=new this.targetWindow.ResizeObserver(s=>{s.forEach(r=>{const o=()=>{this._measureElement(r.target,r)};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(o):o()})}));return{disconnect:()=>{var s;(s=i())==null||s.disconnect(),e=null},observe:s=>{var r;return(r=i())==null?void 0:r.observe(s,{box:"border-box"})},unobserve:s=>{var r;return(r=i())==null?void 0:r.unobserve(s)}}})(),this.range=null,this.setOptions=e=>{Object.entries(e).forEach(([i,s])=>{typeof s>"u"&&delete e[i]}),this.options={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:Zh,rangeExtractor:$h,onChange:()=>{},measureElement:Jh,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,...e}},this.notify=e=>{var i,s;(s=(i=this.options).onChange)==null||s.call(i,this,e)},this.maybeNotify=ri(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),e=>{this.notify(e)},{key:process.env.NODE_ENV!=="production"&&"maybeNotify",debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(e=>e()),this.unsubs=[],this.observer.disconnect(),this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var e;const i=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==i){if(this.cleanup(),!i){this.maybeNotify();return}this.scrollElement=i,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((e=this.scrollElement)==null?void 0:e.window)??null,this.elementsCache.forEach(s=>{this.observer.observe(s)}),this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0}),this.unsubs.push(this.options.observeElementRect(this,s=>{this.scrollRect=s,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(s,r)=>{this.scrollAdjustments=0,this.scrollDirection=r?this.getScrollOffset()<s?"forward":"backward":null,this.scrollOffset=s,this.isScrolling=r,this.maybeNotify()}))}},this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset=="function"?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(e,i)=>{const s=new Map,r=new Map;for(let o=i-1;o>=0;o--){const a=e[o];if(s.has(a.lane))continue;const l=r.get(a.lane);if(l==null||a.end>l.end?r.set(a.lane,a):a.end<l.end&&s.set(a.lane,!0),s.size===this.options.lanes)break}return r.size===this.options.lanes?Array.from(r.values()).sort((o,a)=>o.end===a.end?o.index-a.index:o.end-a.end)[0]:void 0},this.getMeasurementOptions=ri(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled],(e,i,s,r,o)=>(this.pendingMeasuredCacheIndexes=[],{count:e,paddingStart:i,scrollMargin:s,getItemKey:r,enabled:o}),{key:!1}),this.getMeasurements=ri(()=>[this.getMeasurementOptions(),this.itemSizeCache],({count:e,paddingStart:i,scrollMargin:s,getItemKey:r,enabled:o},a)=>{if(!o)return this.measurementsCache=[],this.itemSizeCache.clear(),[];this.measurementsCache.length===0&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(c=>{this.itemSizeCache.set(c.key,c.size)}));const l=this.pendingMeasuredCacheIndexes.length>0?Math.min(...this.pendingMeasuredCacheIndexes):0;this.pendingMeasuredCacheIndexes=[];const h=this.measurementsCache.slice(0,l);for(let c=l;c<e;c++){const u=r(c),d=this.options.lanes===1?h[c-1]:this.getFurthestMeasurement(h,c),f=d?d.end+this.options.gap:i+s,g=a.get(u),m=typeof g=="number"?g:this.options.estimateSize(c),_=f+m,p=d?d.lane:c%this.options.lanes;h[c]={index:c,start:f,size:m,end:_,key:u,lane:p}}return this.measurementsCache=h,h},{key:process.env.NODE_ENV!=="production"&&"getMeasurements",debug:()=>this.options.debug}),this.calculateRange=ri(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(e,i,s,r)=>this.range=e.length>0&&i>0?ec({measurements:e,outerSize:i,scrollOffset:s,lanes:r}):null,{key:process.env.NODE_ENV!=="production"&&"calculateRange",debug:()=>this.options.debug}),this.getVirtualIndexes=ri(()=>{let e=null,i=null;const s=this.calculateRange();return s&&(e=s.startIndex,i=s.endIndex),this.maybeNotify.updateDeps([this.isScrolling,e,i]),[this.options.rangeExtractor,this.options.overscan,this.options.count,e,i]},(e,i,s,r,o)=>r===null||o===null?[]:e({startIndex:r,endIndex:o,overscan:i,count:s}),{key:process.env.NODE_ENV!=="production"&&"getVirtualIndexes",debug:()=>this.options.debug}),this.indexFromElement=e=>{const i=this.options.indexAttribute,s=e.getAttribute(i);return s?parseInt(s,10):(console.warn(`Missing attribute name '${i}={index}' on measured element.`),-1)},this._measureElement=(e,i)=>{const s=this.indexFromElement(e),r=this.measurementsCache[s];if(!r)return;const o=r.key,a=this.elementsCache.get(o);a!==e&&(a&&this.observer.unobserve(a),this.observer.observe(e),this.elementsCache.set(o,e)),e.isConnected&&this.resizeItem(s,this.options.measureElement(e,i,this))},this.resizeItem=(e,i)=>{const s=this.measurementsCache[e];if(!s)return;const r=this.itemSizeCache.get(s.key)??s.size,o=i-r;o!==0&&((this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(s,o,this):s.start<this.getScrollOffset()+this.scrollAdjustments)&&(process.env.NODE_ENV!=="production"&&this.options.debug&&console.info("correction",o),this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=o,behavior:void 0})),this.pendingMeasuredCacheIndexes.push(s.index),this.itemSizeCache=new Map(this.itemSizeCache.set(s.key,i)),this.notify(!1))},this.measureElement=e=>{if(!e){this.elementsCache.forEach((i,s)=>{i.isConnected||(this.observer.unobserve(i),this.elementsCache.delete(s))});return}this._measureElement(e,void 0)},this.getVirtualItems=ri(()=>[this.getVirtualIndexes(),this.getMeasurements()],(e,i)=>{const s=[];for(let r=0,o=e.length;r<o;r++){const a=e[r],l=i[a];s.push(l)}return s},{key:process.env.NODE_ENV!=="production"&&"getVirtualItems",debug:()=>this.options.debug}),this.getVirtualItemForOffset=e=>{const i=this.getMeasurements();if(i.length!==0)return Zo(i[Jo(0,i.length-1,s=>Zo(i[s]).start,e)])},this.getOffsetForAlignment=(e,i,s=0)=>{const r=this.getSize(),o=this.getScrollOffset();i==="auto"&&(i=e>=o+r?"end":"start"),i==="center"?e+=(s-r)/2:i==="end"&&(e-=r);const a=this.getTotalSize()+this.options.scrollMargin-r;return Math.max(Math.min(a,e),0)},this.getOffsetForIndex=(e,i="auto")=>{e=Math.max(0,Math.min(e,this.options.count-1));const s=this.measurementsCache[e];if(!s)return;const r=this.getSize(),o=this.getScrollOffset();if(i==="auto")if(s.end>=o+r-this.options.scrollPaddingEnd)i="end";else if(s.start<=o+this.options.scrollPaddingStart)i="start";else return[o,i];const a=i==="end"?s.end+this.options.scrollPaddingEnd:s.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,i,s.size),i]},this.isDynamicMode=()=>this.elementsCache.size>0,this.scrollToOffset=(e,{align:i="start",behavior:s}={})=>{s==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),this._scrollToOffset(this.getOffsetForAlignment(e,i),{adjustments:void 0,behavior:s})},this.scrollToIndex=(e,{align:i="auto",behavior:s}={})=>{s==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),e=Math.max(0,Math.min(e,this.options.count-1));let r=0;const o=10,a=h=>{if(!this.targetWindow)return;const c=this.getOffsetForIndex(e,h);if(!c){console.warn("Failed to get offset for index:",e);return}const[u,d]=c;this._scrollToOffset(u,{adjustments:void 0,behavior:s}),this.targetWindow.requestAnimationFrame(()=>{const f=this.getScrollOffset(),g=this.getOffsetForIndex(e,d);if(!g){console.warn("Failed to get offset for index:",e);return}jh(g[0],f)||l(d)})},l=h=>{this.targetWindow&&(r++,r<o?(process.env.NODE_ENV!=="production"&&this.options.debug&&console.info("Schedule retry",r,o),this.targetWindow.requestAnimationFrame(()=>a(h))):console.warn(`Failed to scroll to index ${e} after ${o} attempts.`))};a(i)},this.scrollBy=(e,{behavior:i}={})=>{i==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),this._scrollToOffset(this.getScrollOffset()+e,{adjustments:void 0,behavior:i})},this.getTotalSize=()=>{var e;const i=this.getMeasurements();let s;if(i.length===0)s=this.options.paddingStart;else if(this.options.lanes===1)s=((e=i[i.length-1])==null?void 0:e.end)??0;else{const r=Array(this.options.lanes).fill(null);let o=i.length-1;for(;o>=0&&r.some(a=>a===null);){const a=i[o];r[a.lane]===null&&(r[a.lane]=a.end),o--}s=Math.max(...r.filter(a=>a!==null))}return Math.max(s-this.options.scrollMargin+this.options.paddingEnd,0)},this._scrollToOffset=(e,{adjustments:i,behavior:s})=>{this.options.scrollToFn(e,{behavior:s,adjustments:i},this)},this.measure=()=>{this.itemSizeCache=new Map,this.notify(!1)},this.setOptions(t)}}const Jo=(n,t,e,i)=>{for(;n<=t;){const s=(n+t)/2|0,r=e(s);if(r<i)n=s+1;else if(r>i)t=s-1;else return s}return n>0?n-1:0};function ec({measurements:n,outerSize:t,scrollOffset:e,lanes:i}){const s=n.length-1,r=l=>n[l].start;if(n.length<=i)return{startIndex:0,endIndex:s};let o=Jo(0,s,r,e),a=o;if(i===1)for(;a<s&&n[a].end<e+t;)a++;else if(i>1){const l=Array(i).fill(0);for(;a<s&&l.some(c=>c<e+t);){const c=n[a];l[c.lane]=c.end,a++}const h=Array(i).fill(e+t);for(;o>=0&&h.some(c=>c>=e);){const c=n[o];h[c.lane]=c.start,o--}o=Math.max(0,o-o%i),a=Math.min(s,a+(i-1-a%i))}return{startIndex:o,endIndex:a}}const ic=typeof window<"u"?zh:ee;function nc(n){const t=Bo(()=>({}),{})[1],e={...n,onChange:s=>{t(),n.onChange?.(s)}},[i]=vt(()=>new tc(e));return i.setOptions(e),ee(()=>i._didMount(),[]),ic(()=>i._willUpdate()),i}function sc(n){return nc({observeElementRect:Hh,observeElementOffset:qh,scrollToFn:Qh,...n})}function rc({content:n,timestamp:t,isFromCustomer:e}){return E("div",{class:`flex ${e?"justify-end":"justify-start"} mb-3`,children:E("div",{class:`max-w-[75%] px-3 py-2 rounded-lg ${e?"bg-blue-600 text-white":"bg-white border border-zinc-200 text-zinc-900"}`,children:[E("p",{class:"text-sm wrap-break-word",children:n}),E("span",{class:`text-xs mt-1 block ${e?"text-blue-100":"text-zinc-500"}`,children:new Date(t).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})})]})})}function oc({url:n,filename:t,size:e,caption:i,timestamp:s,isFromCustomer:r}){const o=()=>{const a=document.createElement("a");a.href=n,a.download=t||"image.jpg",a.click()};return E("div",{class:`flex ${r?"justify-end":"justify-start"} mb-3`,children:E("div",{class:`max-w-[75%] rounded-lg overflow-hidden ${r?"bg-blue-600":"bg-white border border-zinc-200"}`,children:E("div",{class:"p-2",children:[E("img",{src:n,alt:t||"Photo",class:"max-w-full max-h-80 rounded object-contain"}),i&&E("p",{class:`text-sm mt-2 wrap-break-word ${r?"text-white":"text-zinc-900"}`,children:i}),E("div",{class:"flex items-center justify-between mt-2 gap-2",children:[E("div",{class:"flex flex-col gap-0.5 min-w-0",children:[t&&E("span",{class:`text-xs truncate ${r?"text-blue-100":"text-zinc-500"}`,children:t}),e&&E("span",{class:`text-xs ${r?"text-blue-100":"text-zinc-500"}`,children:[(e/1024).toFixed(1)," KB"]})]}),E("button",{type:"button",onClick:o,class:`p-1 rounded transition-colors shrink-0 ${r?"text-white hover:bg-white/20":"text-zinc-600 hover:bg-zinc-100"}`,title:"Download",children:E("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[E("title",{children:"Download"}),E("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4"})]})})]}),E("span",{class:`text-xs mt-1 block ${r?"text-blue-100":"text-zinc-500"}`,children:new Date(s).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})})]})})})}function ac({url:n,filename:t,size:e,caption:i,timestamp:s,isFromCustomer:r}){const[o,a]=vt(!0);return E("div",{class:`flex ${r?"justify-end":"justify-start"} mb-3`,children:E("div",{class:`max-w-[75%] rounded-lg overflow-hidden ${r?"bg-blue-600":"bg-white border border-zinc-200"}`,children:E("div",{class:"p-2",children:[E("div",{class:"relative",children:[o&&E("div",{class:"absolute inset-0 flex items-center justify-center bg-zinc-100 rounded min-h-[180px]",children:E("svg",{class:"w-8 h-8 animate-spin text-zinc-400",fill:"none",viewBox:"0 0 24 24",children:[E("title",{children:"Loading"}),E("circle",{class:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor","stroke-width":"4"}),E("path",{class:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]})}),E("video",{controls:!0,class:"rounded max-w-full",preload:"metadata",style:{opacity:o?0:1},onLoadedData:()=>a(!1),children:[E("source",{src:n,type:"video/mp4"}),E("track",{kind:"captions"})]})]}),i&&E("p",{class:`text-sm mt-2 wrap-break-word ${r?"text-white":"text-zinc-900"}`,children:i}),E("div",{class:"flex items-center justify-between mt-2 gap-2",children:[t&&E("span",{class:`text-xs truncate ${r?"text-blue-100":"text-zinc-500"}`,children:t}),E("button",{type:"button",onClick:()=>{const h=document.createElement("a");h.href=n,h.download=t||"video.mp4",h.click()},class:`p-1 rounded transition-colors shrink-0 ${r?"text-white hover:bg-white/20":"text-zinc-600 hover:bg-zinc-100"}`,title:"Download",children:E("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[E("title",{children:"Download"}),E("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4"})]})})]}),E("span",{class:`text-xs mt-1 block ${r?"text-blue-100":"text-zinc-500"}`,children:new Date(s).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})})]})})})}function lc({url:n,filename:t,size:e,mimeType:i,timestamp:s,isFromCustomer:r}){const o=()=>{const l=document.createElement("a");l.href=n,l.download=t,l.click()};return E("div",{class:`flex ${r?"justify-end":"justify-start"} mb-3`,children:E("div",{class:`max-w-[75%] rounded-lg ${r?"bg-blue-600 text-white":"bg-white border border-zinc-200 text-zinc-900"}`,children:E("div",{class:"p-3",children:[E("div",{class:"flex items-center gap-3",children:[E("div",{class:"shrink-0",children:i?.startsWith("application/pdf")?E("svg",{class:"w-8 h-8 text-red-500",fill:"currentColor",viewBox:"0 0 24 24",children:[E("title",{children:"PDF"}),E("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8l-6-6z"}),E("path",{d:"M14 2v6h6"}),E("path",{d:"M9 13h6"}),E("path",{d:"M9 17h6"})]}):E("svg",{class:"w-8 h-8 text-zinc-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[E("title",{children:"File"}),E("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})]})}),E("div",{class:"flex-1 min-w-0",children:[E("p",{class:`text-sm font-medium truncate ${r?"text-white":"text-zinc-900"}`,children:t}),e&&E("p",{class:`text-xs ${r?"text-blue-100":"text-zinc-500"}`,children:[(e/1024).toFixed(1)," KB"]})]}),E("button",{type:"button",onClick:o,class:`p-2 rounded transition-colors shrink-0 ${r?"text-white hover:bg-white/20":"text-zinc-600 hover:bg-zinc-100"}`,title:"Download",children:E("svg",{class:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[E("title",{children:"Download"}),E("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4"})]})})]}),E("span",{class:`text-xs mt-2 block ${r?"text-blue-100":"text-zinc-500"}`,children:new Date(s).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})})]})})})}const Ot={ADD:"add",REMOVE:"remove"},oi={PROPERTYCHANGE:"propertychange"},B={CHANGE:"change",ERROR:"error",CONTEXTMENU:"contextmenu",CLICK:"click",DBLCLICK:"dblclick",KEYDOWN:"keydown",KEYPRESS:"keypress",LOAD:"load",TOUCHMOVE:"touchmove",WHEEL:"wheel"};class Dn{constructor(){this.disposed=!1}dispose(){this.disposed||(this.disposed=!0,this.disposeInternal())}disposeInternal(){}}function hc(n,t,e){let i,s;e=e||ce;let r=0,o=n.length,a=!1;for(;r<o;)i=r+(o-r>>1),s=+e(n[i],t),s<0?r=i+1:(o=i,a=!s);return a?r:~r}function ce(n,t){return n>t?1:n<t?-1:0}function cc(n,t){return n<t?1:n>t?-1:0}function Ws(n,t,e){if(n[0]<=t)return 0;const i=n.length;if(t<=n[i-1])return i-1;if(typeof e=="function"){for(let s=1;s<i;++s){const r=n[s];if(r===t)return s;if(r<t)return e(t,n[s-1],r)>0?s-1:s}return i-1}if(e>0){for(let s=1;s<i;++s)if(n[s]<t)return s-1;return i-1}if(e<0){for(let s=1;s<i;++s)if(n[s]<=t)return s;return i-1}for(let s=1;s<i;++s){if(n[s]==t)return s;if(n[s]<t)return n[s-1]-t<t-n[s]?s-1:s}return i-1}function uc(n,t,e){for(;t<e;){const i=n[t];n[t]=n[e],n[e]=i,++t,--e}}function Xs(n,t){const e=Array.isArray(t)?t:[t],i=e.length;for(let s=0;s<i;s++)n[n.length]=e[s]}function Ce(n,t){const e=n.length;if(e!==t.length)return!1;for(let i=0;i<e;i++)if(n[i]!==t[i])return!1;return!0}function dc(n,t,e){const i=t||ce;return n.every(function(s,r){if(r===0)return!0;const o=i(n[r-1],s);return!(o>0||o===0)})}function Yi(){return!0}function kn(){return!1}function Bi(){}function Qo(n){let t,e,i;return function(){const s=Array.prototype.slice.call(arguments);return(!e||this!==i||!Ce(s,e))&&(i=this,e=s,t=n.apply(this,arguments)),t}}function fc(n){function t(){let e;try{e=n()}catch(i){return Promise.reject(i)}return e instanceof Promise?e:Promise.resolve(e)}return t()}function Ui(n){for(const t in n)delete n[t]}function ai(n){let t;for(t in n)return!1;return!t}class ue{constructor(t){this.propagationStopped,this.defaultPrevented,this.type=t,this.target=null}preventDefault(){this.defaultPrevented=!0}stopPropagation(){this.propagationStopped=!0}}class Fn extends Dn{constructor(t){super(),this.eventTarget_=t,this.pendingRemovals_=null,this.dispatching_=null,this.listeners_=null}addEventListener(t,e){if(!t||!e)return;const i=this.listeners_||(this.listeners_={}),s=i[t]||(i[t]=[]);s.includes(e)||s.push(e)}dispatchEvent(t){const e=typeof t=="string",i=e?t:t.type,s=this.listeners_&&this.listeners_[i];if(!s)return;const r=e?new ue(t):t;r.target||(r.target=this.eventTarget_||this);const o=this.dispatching_||(this.dispatching_={}),a=this.pendingRemovals_||(this.pendingRemovals_={});i in o||(o[i]=0,a[i]=0),++o[i];let l;for(let h=0,c=s.length;h<c;++h)if("handleEvent"in s[h]?l=s[h].handleEvent(r):l=s[h].call(this,r),l===!1||r.propagationStopped){l=!1;break}if(--o[i]===0){let h=a[i];for(delete a[i];h--;)this.removeEventListener(i,Bi);delete o[i]}return l}disposeInternal(){this.listeners_&&Ui(this.listeners_)}getListeners(t){return this.listeners_&&this.listeners_[t]||void 0}hasListener(t){return this.listeners_?t?t in this.listeners_:Object.keys(this.listeners_).length>0:!1}removeEventListener(t,e){if(!this.listeners_)return;const i=this.listeners_[t];if(!i)return;const s=i.indexOf(e);s!==-1&&(this.pendingRemovals_&&t in this.pendingRemovals_?(i[s]=Bi,++this.pendingRemovals_[t]):(i.splice(s,1),i.length===0&&delete this.listeners_[t]))}}function $(n,t,e,i,s){if(s){const o=e;e=function(a){return n.removeEventListener(t,e),o.call(i??this,a)}}else i&&i!==n&&(e=e.bind(i));const r={target:n,type:t,listener:e};return n.addEventListener(t,e),r}function Nn(n,t,e,i){return $(n,t,e,i,!0)}function at(n){n&&n.target&&(n.target.removeEventListener(n.type,n.listener),Ui(n))}class Ki extends Fn{constructor(){super(),this.on=this.onInternal,this.once=this.onceInternal,this.un=this.unInternal,this.revision_=0}changed(){++this.revision_,this.dispatchEvent(B.CHANGE)}getRevision(){return this.revision_}onInternal(t,e){if(Array.isArray(t)){const i=t.length,s=new Array(i);for(let r=0;r<i;++r)s[r]=$(this,t[r],e);return s}return $(this,t,e)}onceInternal(t,e){let i;if(Array.isArray(t)){const s=t.length;i=new Array(s);for(let r=0;r<s;++r)i[r]=Nn(this,t[r],e)}else i=Nn(this,t,e);return e.ol_key=i,i}unInternal(t,e){const i=e.ol_key;if(i)gc(i);else if(Array.isArray(t))for(let s=0,r=t.length;s<r;++s)this.removeEventListener(t[s],e);else this.removeEventListener(t,e)}}Ki.prototype.on,Ki.prototype.once,Ki.prototype.un;function gc(n){if(Array.isArray(n))for(let t=0,e=n.length;t<e;++t)at(n[t]);else at(n)}function H(){throw new Error("Unimplemented abstract method.")}let _c=0;function q(n){return n.ol_uid||(n.ol_uid=String(++_c))}class ta extends ue{constructor(t,e,i){super(t),this.key=e,this.oldValue=i}}class ne extends Ki{constructor(t){super(),this.on,this.once,this.un,q(this),this.values_=null,t!==void 0&&this.setProperties(t)}get(t){let e;return this.values_&&this.values_.hasOwnProperty(t)&&(e=this.values_[t]),e}getKeys(){return this.values_&&Object.keys(this.values_)||[]}getProperties(){return this.values_&&Object.assign({},this.values_)||{}}getPropertiesInternal(){return this.values_}hasProperties(){return!!this.values_}notify(t,e){let i;i=`change:${t}`,this.hasListener(i)&&this.dispatchEvent(new ta(i,t,e)),i=oi.PROPERTYCHANGE,this.hasListener(i)&&this.dispatchEvent(new ta(i,t,e))}addChangeListener(t,e){this.addEventListener(`change:${t}`,e)}removeChangeListener(t,e){this.removeEventListener(`change:${t}`,e)}set(t,e,i){const s=this.values_||(this.values_={});if(i)s[t]=e;else{const r=s[t];s[t]=e,r!==e&&this.notify(t,r)}}setProperties(t,e){for(const i in t)this.set(i,t[i],e)}applyProperties(t){t.values_&&Object.assign(this.values_||(this.values_={}),t.values_)}unset(t,e){if(this.values_&&t in this.values_){const i=this.values_[t];delete this.values_[t],ai(this.values_)&&(this.values_=null),e||this.notify(t,i)}}}const ea={LENGTH:"length"};class zn extends ue{constructor(t,e,i){super(t),this.element=e,this.index=i}}class se extends ne{constructor(t,e){if(super(),this.on,this.once,this.un,e=e||{},this.unique_=!!e.unique,this.array_=t||[],this.unique_)for(let i=0,s=this.array_.length;i<s;++i)this.assertUnique_(this.array_[i],i);this.updateLength_()}clear(){for(;this.getLength()>0;)this.pop()}extend(t){for(let e=0,i=t.length;e<i;++e)this.push(t[e]);return this}forEach(t){const e=this.array_;for(let i=0,s=e.length;i<s;++i)t(e[i],i,e)}getArray(){return this.array_}item(t){return this.array_[t]}getLength(){return this.get(ea.LENGTH)}insertAt(t,e){if(t<0||t>this.getLength())throw new Error("Index out of bounds: "+t);this.unique_&&this.assertUnique_(e),this.array_.splice(t,0,e),this.updateLength_(),this.dispatchEvent(new zn(Ot.ADD,e,t))}pop(){return this.removeAt(this.getLength()-1)}push(t){this.unique_&&this.assertUnique_(t);const e=this.getLength();return this.insertAt(e,t),this.getLength()}remove(t){const e=this.array_;for(let i=0,s=e.length;i<s;++i)if(e[i]===t)return this.removeAt(i)}removeAt(t){if(t<0||t>=this.getLength())return;const e=this.array_[t];return this.array_.splice(t,1),this.updateLength_(),this.dispatchEvent(new zn(Ot.REMOVE,e,t)),e}setAt(t,e){const i=this.getLength();if(t>=i){this.insertAt(t,e);return}if(t<0)throw new Error("Index out of bounds: "+t);this.unique_&&this.assertUnique_(e,t);const s=this.array_[t];this.array_[t]=e,this.dispatchEvent(new zn(Ot.REMOVE,s,t)),this.dispatchEvent(new zn(Ot.ADD,e,t))}updateLength_(){this.set(ea.LENGTH,this.array_.length)}assertUnique_(t,e){for(let i=0,s=this.array_.length;i<s;++i)if(this.array_[i]===t&&i!==e)throw new Error("Duplicate item added to a unique collection")}}class li extends ue{constructor(t,e,i){super(t),this.map=e,this.frameState=i!==void 0?i:null}}class Re extends li{constructor(t,e,i,s,r,o){super(t,e,r),this.originalEvent=i,this.pixel_=null,this.coordinate_=null,this.dragging=s!==void 0?s:!1,this.activePointers=o}get pixel(){return this.pixel_||(this.pixel_=this.map.getEventPixel(this.originalEvent)),this.pixel_}set pixel(t){this.pixel_=t}get coordinate(){return this.coordinate_||(this.coordinate_=this.map.getCoordinateFromPixel(this.pixel)),this.coordinate_}set coordinate(t){this.coordinate_=t}preventDefault(){super.preventDefault(),"preventDefault"in this.originalEvent&&this.originalEvent.preventDefault()}stopPropagation(){super.stopPropagation(),"stopPropagation"in this.originalEvent&&this.originalEvent.stopPropagation()}}const ct={SINGLECLICK:"singleclick",CLICK:B.CLICK,DBLCLICK:B.DBLCLICK,POINTERDRAG:"pointerdrag",POINTERMOVE:"pointermove",POINTERDOWN:"pointerdown",POINTERUP:"pointerup",POINTEROVER:"pointerover",POINTEROUT:"pointerout",POINTERENTER:"pointerenter",POINTERLEAVE:"pointerleave",POINTERCANCEL:"pointercancel"},Ye=typeof navigator<"u"&&typeof navigator.userAgent<"u"?navigator.userAgent.toLowerCase():"";Ye.includes("safari")&&!Ye.includes("chrom")&&(Ye.includes("version/15.4")||/cpu (os|iphone os) 15_4 like mac os x/.test(Ye));const mc=Ye.includes("webkit")&&!Ye.includes("edge"),ia=Ye.includes("macintosh"),pc=typeof devicePixelRatio<"u"?devicePixelRatio:1,Ys=typeof WorkerGlobalScope<"u"&&typeof OffscreenCanvas<"u"&&self instanceof WorkerGlobalScope,na=typeof Image<"u"&&Image.prototype.decode,sa=(function(){let n=!1;try{const t=Object.defineProperty({},"passive",{get:function(){n=!0}});window.addEventListener("_",null,t),window.removeEventListener("_",null,t)}catch{}return n})(),Bs={POINTERMOVE:"pointermove",POINTERDOWN:"pointerdown"};class yc extends Fn{constructor(t,e){super(t),this.map_=t,this.clickTimeoutId_,this.emulateClicks_=!1,this.dragging_=!1,this.dragListenerKeys_=[],this.moveTolerance_=e===void 0?1:e,this.down_=null;const i=this.map_.getViewport();this.activePointers_=[],this.trackedTouches_={},this.element_=i,this.pointerdownListenerKey_=$(i,Bs.POINTERDOWN,this.handlePointerDown_,this),this.originalPointerMoveEvent_,this.relayedListenerKey_=$(i,Bs.POINTERMOVE,this.relayMoveEvent_,this),this.boundHandleTouchMove_=this.handleTouchMove_.bind(this),this.element_.addEventListener(B.TOUCHMOVE,this.boundHandleTouchMove_,sa?{passive:!1}:!1)}emulateClick_(t){let e=new Re(ct.CLICK,this.map_,t);this.dispatchEvent(e),this.clickTimeoutId_!==void 0?(clearTimeout(this.clickTimeoutId_),this.clickTimeoutId_=void 0,e=new Re(ct.DBLCLICK,this.map_,t),this.dispatchEvent(e)):this.clickTimeoutId_=setTimeout(()=>{this.clickTimeoutId_=void 0;const i=new Re(ct.SINGLECLICK,this.map_,t);this.dispatchEvent(i)},250)}updateActivePointers_(t){const e=t,i=e.pointerId;if(e.type==ct.POINTERUP||e.type==ct.POINTERCANCEL){delete this.trackedTouches_[i];for(const s in this.trackedTouches_)if(this.trackedTouches_[s].target!==e.target){delete this.trackedTouches_[s];break}}else(e.type==ct.POINTERDOWN||e.type==ct.POINTERMOVE)&&(this.trackedTouches_[i]=e);this.activePointers_=Object.values(this.trackedTouches_)}handlePointerUp_(t){this.updateActivePointers_(t);const e=new Re(ct.POINTERUP,this.map_,t,void 0,void 0,this.activePointers_);this.dispatchEvent(e),this.emulateClicks_&&!e.defaultPrevented&&!this.dragging_&&this.isMouseActionButton_(t)&&this.emulateClick_(this.down_),this.activePointers_.length===0&&(this.dragListenerKeys_.forEach(at),this.dragListenerKeys_.length=0,this.dragging_=!1,this.down_=null)}isMouseActionButton_(t){return t.button===0}handlePointerDown_(t){this.emulateClicks_=this.activePointers_.length===0,this.updateActivePointers_(t);const e=new Re(ct.POINTERDOWN,this.map_,t,void 0,void 0,this.activePointers_);if(this.dispatchEvent(e),this.down_=new PointerEvent(t.type,t),Object.defineProperty(this.down_,"target",{writable:!1,value:t.target}),this.dragListenerKeys_.length===0){const i=this.map_.getOwnerDocument();this.dragListenerKeys_.push($(i,ct.POINTERMOVE,this.handlePointerMove_,this),$(i,ct.POINTERUP,this.handlePointerUp_,this),$(this.element_,ct.POINTERCANCEL,this.handlePointerUp_,this)),this.element_.getRootNode&&this.element_.getRootNode()!==i&&this.dragListenerKeys_.push($(this.element_.getRootNode(),ct.POINTERUP,this.handlePointerUp_,this))}}handlePointerMove_(t){if(this.isMoving_(t)){this.updateActivePointers_(t),this.dragging_=!0;const e=new Re(ct.POINTERDRAG,this.map_,t,this.dragging_,void 0,this.activePointers_);this.dispatchEvent(e)}}relayMoveEvent_(t){this.originalPointerMoveEvent_=t;const e=!!(this.down_&&this.isMoving_(t));this.dispatchEvent(new Re(ct.POINTERMOVE,this.map_,t,e))}handleTouchMove_(t){const e=this.originalPointerMoveEvent_;(!e||e.defaultPrevented)&&(typeof t.cancelable!="boolean"||t.cancelable===!0)&&t.preventDefault()}isMoving_(t){return this.dragging_||Math.abs(t.clientX-this.down_.clientX)>this.moveTolerance_||Math.abs(t.clientY-this.down_.clientY)>this.moveTolerance_}disposeInternal(){this.relayedListenerKey_&&(at(this.relayedListenerKey_),this.relayedListenerKey_=null),this.element_.removeEventListener(B.TOUCHMOVE,this.boundHandleTouchMove_),this.pointerdownListenerKey_&&(at(this.pointerdownListenerKey_),this.pointerdownListenerKey_=null),this.dragListenerKeys_.forEach(at),this.dragListenerKeys_.length=0,this.element_=null,super.disposeInternal()}}const Se={POSTRENDER:"postrender",MOVESTART:"movestart",MOVEEND:"moveend",LOADSTART:"loadstart",LOADEND:"loadend"},Rt={LAYERGROUP:"layergroup",SIZE:"size",TARGET:"target",VIEW:"view"},N={IDLE:0,LOADING:1,LOADED:2,ERROR:3,EMPTY:4};function Q(n,t){if(!n)throw new Error(t)}const Gn=1/0;class xc{constructor(t,e){this.priorityFunction_=t,this.keyFunction_=e,this.elements_=[],this.priorities_=[],this.queuedElements_={}}clear(){this.elements_.length=0,this.priorities_.length=0,Ui(this.queuedElements_)}dequeue(){const t=this.elements_,e=this.priorities_,i=t[0];t.length==1?(t.length=0,e.length=0):(t[0]=t.pop(),e[0]=e.pop(),this.siftUp_(0));const s=this.keyFunction_(i);return delete this.queuedElements_[s],i}enqueue(t){Q(!(this.keyFunction_(t)in this.queuedElements_),"Tried to enqueue an `element` that was already added to the queue");const e=this.priorityFunction_(t);return e!=Gn?(this.elements_.push(t),this.priorities_.push(e),this.queuedElements_[this.keyFunction_(t)]=!0,this.siftDown_(0,this.elements_.length-1),!0):!1}getCount(){return this.elements_.length}getLeftChildIndex_(t){return t*2+1}getRightChildIndex_(t){return t*2+2}getParentIndex_(t){return t-1>>1}heapify_(){let t;for(t=(this.elements_.length>>1)-1;t>=0;t--)this.siftUp_(t)}isEmpty(){return this.elements_.length===0}isKeyQueued(t){return t in this.queuedElements_}isQueued(t){return this.isKeyQueued(this.keyFunction_(t))}siftUp_(t){const e=this.elements_,i=this.priorities_,s=e.length,r=e[t],o=i[t],a=t;for(;t<s>>1;){const l=this.getLeftChildIndex_(t),h=this.getRightChildIndex_(t),c=h<s&&i[h]<i[l]?h:l;e[t]=e[c],i[t]=i[c],t=c}e[t]=r,i[t]=o,this.siftDown_(a,t)}siftDown_(t,e){const i=this.elements_,s=this.priorities_,r=i[e],o=s[e];for(;e>t;){const a=this.getParentIndex_(e);if(s[a]>o)i[e]=i[a],s[e]=s[a],e=a;else break}i[e]=r,s[e]=o}reprioritize(){const t=this.priorityFunction_,e=this.elements_,i=this.priorities_;let s=0;const r=e.length;let o,a,l;for(a=0;a<r;++a)o=e[a],l=t(o),l==Gn?delete this.queuedElements_[this.keyFunction_(o)]:(i[s]=l,e[s++]=o);e.length=s,i.length=s,this.heapify_()}}class Ec extends xc{constructor(t,e){super(i=>t.apply(null,i),i=>i[0].getKey()),this.boundHandleTileChange_=this.handleTileChange.bind(this),this.tileChangeCallback_=e,this.tilesLoading_=0,this.tilesLoadingKeys_={}}enqueue(t){const e=super.enqueue(t);return e&&t[0].addEventListener(B.CHANGE,this.boundHandleTileChange_),e}getTilesLoading(){return this.tilesLoading_}handleTileChange(t){const e=t.target,i=e.getState();if(i===N.LOADED||i===N.ERROR||i===N.EMPTY){i!==N.ERROR&&e.removeEventListener(B.CHANGE,this.boundHandleTileChange_);const s=e.getKey();s in this.tilesLoadingKeys_&&(delete this.tilesLoadingKeys_[s],--this.tilesLoading_),this.tileChangeCallback_()}}loadMoreTiles(t,e){let i=0;for(;this.tilesLoading_<t&&i<e&&this.getCount()>0;){const s=this.dequeue()[0],r=s.getKey();s.getState()===N.IDLE&&!(r in this.tilesLoadingKeys_)&&(this.tilesLoadingKeys_[r]=!0,++this.tilesLoading_,++i,s.load())}}}function wc(n,t,e,i,s){if(!n||!(e in n.wantedTiles)||!n.wantedTiles[e][t.getKey()])return Gn;const r=n.viewState.center,o=i[0]-r[0],a=i[1]-r[1];return 65536*Math.log(s)+Math.sqrt(o*o+a*a)/s}const St={ANIMATING:0,INTERACTING:1},Ht={CENTER:"center",RESOLUTION:"resolution",ROTATION:"rotation"};function lt(n,t,e){return Math.min(Math.max(n,t),e)}function vc(n,t,e,i,s,r){const o=s-e,a=r-i;if(o!==0||a!==0){const l=((n-e)*o+(t-i)*a)/(o*o+a*a);l>1?(e=s,i=r):l>0&&(e+=o*l,i+=a*l)}return hi(n,t,e,i)}function hi(n,t,e,i){const s=e-n,r=i-t;return s*s+r*r}function Cc(n){const t=n.length;for(let i=0;i<t;i++){let s=i,r=Math.abs(n[i][i]);for(let a=i+1;a<t;a++){const l=Math.abs(n[a][i]);l>r&&(r=l,s=a)}if(r===0)return null;const o=n[s];n[s]=n[i],n[i]=o;for(let a=i+1;a<t;a++){const l=-n[a][i]/n[i][i];for(let h=i;h<t+1;h++)i==h?n[a][h]=0:n[a][h]+=l*n[i][h]}}const e=new Array(t);for(let i=t-1;i>=0;i--){e[i]=n[i][t]/n[i][i];for(let s=i-1;s>=0;s--)n[s][t]-=n[s][i]*e[i]}return e}function ra(n){return n*180/Math.PI}function Ie(n){return n*Math.PI/180}function ci(n,t){const e=n%t;return e*t<0?e+t:e}function Wt(n,t,e){return n+e*(t-n)}function Wn(n,t){const e=Math.pow(10,t);return Math.round(n*e)/e}function Xn(n,t){return Math.floor(Wn(n,t))}function Yn(n,t){return Math.ceil(Wn(n,t))}function Us(n,t,e){if(n>=t&&n<e)return n;const i=e-t;return((n-t)%i+i)%i+t}function oa(n,t,e){return(function(i,s,r,o,a){if(!i)return;if(!s&&!t)return i;const l=t?0:r[0]*s,h=t?0:r[1]*s,c=a?a[0]:0,u=a?a[1]:0;let d=n[0]+l/2+c,f=n[2]-l/2+c,g=n[1]+h/2+u,m=n[3]-h/2+u;d>f&&(d=(f+d)/2,f=d),g>m&&(g=(m+g)/2,m=g);let _=lt(i[0],d,f),p=lt(i[1],g,m);if(o&&e&&s){const y=30*s;_+=-y*Math.log(1+Math.max(0,d-i[0])/y)+y*Math.log(1+Math.max(0,i[0]-f)/y),p+=-y*Math.log(1+Math.max(0,g-i[1])/y)+y*Math.log(1+Math.max(0,i[1]-m)/y)}return[_,p]})}function Rc(n){return n}const pt={UNKNOWN:0,INTERSECTING:1,ABOVE:2,RIGHT:4,BELOW:8,LEFT:16};function aa(n){const t=Xt();for(let e=0,i=n.length;e<i;++e)Zi(t,n[e]);return t}function Ks(n,t,e){return e?(e[0]=n[0]-t,e[1]=n[1]-t,e[2]=n[2]+t,e[3]=n[3]+t,e):[n[0]-t,n[1]-t,n[2]+t,n[3]+t]}function la(n,t){return t?(t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t):n.slice()}function ha(n,t,e){let i,s;return t<n[0]?i=n[0]-t:n[2]<t?i=t-n[2]:i=0,e<n[1]?s=n[1]-e:n[3]<e?s=e-n[3]:s=0,i*i+s*s}function ui(n,t){return ca(n,t[0],t[1])}function ji(n,t){return n[0]<=t[0]&&t[2]<=n[2]&&n[1]<=t[1]&&t[3]<=n[3]}function ca(n,t,e){return n[0]<=t&&t<=n[2]&&n[1]<=e&&e<=n[3]}function js(n,t){const e=n[0],i=n[1],s=n[2],r=n[3],o=t[0],a=t[1];let l=pt.UNKNOWN;return o<e?l=l|pt.LEFT:o>s&&(l=l|pt.RIGHT),a<i?l=l|pt.BELOW:a>r&&(l=l|pt.ABOVE),l===pt.UNKNOWN&&(l=pt.INTERSECTING),l}function Xt(){return[1/0,1/0,-1/0,-1/0]}function Te(n,t,e,i,s){return s?(s[0]=n,s[1]=t,s[2]=e,s[3]=i,s):[n,t,e,i]}function Bn(n){return Te(1/0,1/0,-1/0,-1/0,n)}function ua(n,t){const e=n[0],i=n[1];return Te(e,i,e,i,t)}function Vs(n,t,e,i,s){const r=Bn(s);return da(r,n,t,e,i)}function Vi(n,t){return n[0]==t[0]&&n[2]==t[2]&&n[1]==t[1]&&n[3]==t[3]}function Sc(n,t){return t[0]<n[0]&&(n[0]=t[0]),t[2]>n[2]&&(n[2]=t[2]),t[1]<n[1]&&(n[1]=t[1]),t[3]>n[3]&&(n[3]=t[3]),n}function Zi(n,t){t[0]<n[0]&&(n[0]=t[0]),t[0]>n[2]&&(n[2]=t[0]),t[1]<n[1]&&(n[1]=t[1]),t[1]>n[3]&&(n[3]=t[1])}function da(n,t,e,i,s){for(;e<i;e+=s)Ic(n,t[e],t[e+1]);return n}function Ic(n,t,e){n[0]=Math.min(n[0],t),n[1]=Math.min(n[1],e),n[2]=Math.max(n[2],t),n[3]=Math.max(n[3],e)}function fa(n,t){let e;return e=t(Un(n)),e||(e=t(Kn(n)),e)||(e=t(jn(n)),e)||(e=t(Ke(n)),e)?e:!1}function Zs(n){let t=0;return Vn(n)||(t=et(n)*It(n)),t}function Un(n){return[n[0],n[1]]}function Kn(n){return[n[2],n[1]]}function Be(n){return[(n[0]+n[2])/2,(n[1]+n[3])/2]}function Tc(n,t){let e;if(t==="bottom-left")e=Un(n);else if(t==="bottom-right")e=Kn(n);else if(t==="top-left")e=Ke(n);else if(t==="top-right")e=jn(n);else throw new Error("Invalid corner");return e}function $s(n,t,e,i,s){const[r,o,a,l,h,c,u,d]=ga(n,t,e,i);return Te(Math.min(r,a,h,u),Math.min(o,l,c,d),Math.max(r,a,h,u),Math.max(o,l,c,d),s)}function ga(n,t,e,i){const s=t*i[0]/2,r=t*i[1]/2,o=Math.cos(e),a=Math.sin(e),l=s*o,h=s*a,c=r*o,u=r*a,d=n[0],f=n[1];return[d-l+u,f-h-c,d-l-u,f-h+c,d+l-u,f+h+c,d+l+u,f+h-c,d-l+u,f-h-c]}function It(n){return n[3]-n[1]}function Ue(n,t,e){const i=e||Xt();return Pt(n,t)?(n[0]>t[0]?i[0]=n[0]:i[0]=t[0],n[1]>t[1]?i[1]=n[1]:i[1]=t[1],n[2]<t[2]?i[2]=n[2]:i[2]=t[2],n[3]<t[3]?i[3]=n[3]:i[3]=t[3]):Bn(i),i}function Ke(n){return[n[0],n[3]]}function jn(n){return[n[2],n[3]]}function et(n){return n[2]-n[0]}function Pt(n,t){return n[0]<=t[2]&&n[2]>=t[0]&&n[1]<=t[3]&&n[3]>=t[1]}function Vn(n){return n[2]<n[0]||n[3]<n[1]}function bc(n,t){return t?(t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t):n}function Mc(n,t,e){let i=!1;const s=js(n,t),r=js(n,e);if(s===pt.INTERSECTING||r===pt.INTERSECTING)i=!0;else{const o=n[0],a=n[1],l=n[2],h=n[3],c=t[0],u=t[1],d=e[0],f=e[1],g=(f-u)/(d-c);let m,_;r&pt.ABOVE&&!(s&pt.ABOVE)&&(m=d-(f-h)/g,i=m>=o&&m<=l),!i&&r&pt.RIGHT&&!(s&pt.RIGHT)&&(_=f-(d-l)*g,i=_>=a&&_<=h),!i&&r&pt.BELOW&&!(s&pt.BELOW)&&(m=d-(f-a)/g,i=m>=o&&m<=l),!i&&r&pt.LEFT&&!(s&pt.LEFT)&&(_=f-(d-o)*g,i=_>=a&&_<=h)}return i}function _a(n,t){const e=t.getExtent(),i=Be(n);if(t.canWrapX()&&(i[0]<e[0]||i[0]>=e[2])){const s=et(e),o=Math.floor((i[0]-e[0])/s)*s;n[0]-=o,n[2]-=o}return n}function ma(n,t,e){if(t.canWrapX()){const i=t.getExtent();if(!isFinite(n[0])||!isFinite(n[2]))return[[i[0],n[1],i[2],n[3]]];_a(n,t);const s=et(i);if(et(n)>s&&!e)return[[i[0],n[1],i[2],n[3]]];if(n[0]<i[0])return[[n[0]+s,n[1],i[2],n[3]],[i[0],n[1],n[2],n[3]]];if(n[2]>i[2])return[[n[0],n[1],i[2],n[3]],[i[0],n[1],n[2]-s,n[3]]]}return[n]}function Lc(n,t){return n[0]+=+t[0],n[1]+=+t[1],n}function Zn(n,t){let e=!0;for(let i=n.length-1;i>=0;--i)if(n[i]!=t[i]){e=!1;break}return e}function Hs(n,t){const e=Math.cos(t),i=Math.sin(t),s=n[0]*e-n[1]*i,r=n[1]*e+n[0]*i;return n[0]=s,n[1]=r,n}function Ac(n,t){return n[0]*=t,n[1]*=t,n}function pa(n,t){if(t.canWrapX()){const e=et(t.getExtent()),i=Oc(n,t,e);i&&(n[0]-=i*e)}return n}function Oc(n,t,e){const i=t.getExtent();let s=0;return t.canWrapX()&&(n[0]<i[0]||n[0]>i[2])&&(e=e||et(i),s=Math.floor((n[0]-i[0])/e)),s}function ya(n){return Math.pow(n,3)}function di(n){return 1-ya(1-n)}function Pc(n){return 3*n*n-2*n*n*n}function Dc(n){return n}const kc=63710088e-1;function xa(n,t,e){e=e||kc;const i=Ie(n[1]),s=Ie(t[1]),r=(s-i)/2,o=Ie(t[0]-n[0])/2,a=Math.sin(r)*Math.sin(r)+Math.sin(o)*Math.sin(o)*Math.cos(i)*Math.cos(s);return 2*e*Math.atan2(Math.sqrt(a),Math.sqrt(1-a))}function Ea(...n){console.warn(...n)}const qs={radians:6370997/(2*Math.PI),degrees:2*Math.PI*6370997/360,ft:.3048,m:1,"us-ft":1200/3937};class Js{constructor(t){this.code_=t.code,this.units_=t.units,this.extent_=t.extent!==void 0?t.extent:null,this.worldExtent_=t.worldExtent!==void 0?t.worldExtent:null,this.axisOrientation_=t.axisOrientation!==void 0?t.axisOrientation:"enu",this.global_=t.global!==void 0?t.global:!1,this.canWrapX_=!!(this.global_&&this.extent_),this.getPointResolutionFunc_=t.getPointResolution,this.defaultTileGrid_=null,this.metersPerUnit_=t.metersPerUnit}canWrapX(){return this.canWrapX_}getCode(){return this.code_}getExtent(){return this.extent_}getUnits(){return this.units_}getMetersPerUnit(){return this.metersPerUnit_||qs[this.units_]}getWorldExtent(){return this.worldExtent_}getAxisOrientation(){return this.axisOrientation_}isGlobal(){return this.global_}setGlobal(t){this.global_=t,this.canWrapX_=!!(t&&this.extent_)}getDefaultTileGrid(){return this.defaultTileGrid_}setDefaultTileGrid(t){this.defaultTileGrid_=t}setExtent(t){this.extent_=t,this.canWrapX_=!!(this.global_&&t)}setWorldExtent(t){this.worldExtent_=t}setGetPointResolution(t){this.getPointResolutionFunc_=t}getPointResolutionFunc(){return this.getPointResolutionFunc_}}const $i=6378137,fi=Math.PI*$i,Fc=[-fi,-fi,fi,fi],Nc=[-180,-85,180,85],$n=$i*Math.log(Math.tan(Math.PI/2));class gi extends Js{constructor(t){super({code:t,units:"m",extent:Fc,global:!0,worldExtent:Nc,getPointResolution:function(e,i){return e/Math.cosh(i[1]/$i)}})}}const wa=[new gi("EPSG:3857"),new gi("EPSG:102100"),new gi("EPSG:102113"),new gi("EPSG:900913"),new gi("http://www.opengis.net/def/crs/EPSG/0/3857"),new gi("http://www.opengis.net/gml/srs/epsg.xml#3857")];function zc(n,t,e,i){const s=n.length;e=e>1?e:2,i=i??e,t===void 0&&(e>2?t=n.slice():t=new Array(s));for(let r=0;r<s;r+=i){t[r]=fi*n[r]/180;let o=$i*Math.log(Math.tan(Math.PI*(+n[r+1]+90)/360));o>$n?o=$n:o<-$n&&(o=-$n),t[r+1]=o}return t}function Gc(n,t,e,i){const s=n.length;e=e>1?e:2,i=i??e,t===void 0&&(e>2?t=n.slice():t=new Array(s));for(let r=0;r<s;r+=i)t[r]=180*n[r]/fi,t[r+1]=360*Math.atan(Math.exp(n[r+1]/$i))/Math.PI-90;return t}const Wc=6378137,va=[-180,-90,180,90],Xc=Math.PI*Wc/180;class je extends Js{constructor(t,e){super({code:t,units:"degrees",extent:va,axisOrientation:e,global:!0,metersPerUnit:Xc,worldExtent:va})}}const Ca=[new je("CRS:84"),new je("EPSG:4326","neu"),new je("urn:ogc:def:crs:OGC:1.3:CRS84"),new je("urn:ogc:def:crs:OGC:2:84"),new je("http://www.opengis.net/def/crs/OGC/1.3/CRS84"),new je("http://www.opengis.net/gml/srs/epsg.xml#4326","neu"),new je("http://www.opengis.net/def/crs/EPSG/0/4326","neu")];let Qs={};function Yc(n){return Qs[n]||Qs[n.replace(/urn:(x-)?ogc:def:crs:EPSG:(.*:)?(\w+)$/,"EPSG:$3")]||null}function Bc(n,t){Qs[n]=t}let _i={};function Hi(n,t,e){const i=n.getCode(),s=t.getCode();i in _i||(_i[i]={}),_i[i][s]=e}function tr(n,t){return n in _i&&t in _i[n]?_i[n][t]:null}const Hn=.9996,Yt=.00669438,qn=Yt*Yt,Jn=qn*Yt,Ve=Yt/(1-Yt),Ra=Math.sqrt(1-Yt),mi=(1-Ra)/(1+Ra),Sa=mi*mi,er=Sa*mi,ir=er*mi,Ia=ir*mi,Ta=1-Yt/4-3*qn/64-5*Jn/256,Uc=3*Yt/8+3*qn/32+45*Jn/1024,Kc=15*qn/256+45*Jn/1024,jc=35*Jn/3072,Vc=3/2*mi-27/32*er+269/512*Ia,Zc=21/16*Sa-55/32*ir,$c=151/96*er-417/128*Ia,Hc=1097/512*ir,Qn=6378137;function qc(n,t,e){const i=n-5e5,o=(e.north?t:t-1e7)/Hn/(Qn*Ta),a=o+Vc*Math.sin(2*o)+Zc*Math.sin(4*o)+$c*Math.sin(6*o)+Hc*Math.sin(8*o),l=Math.sin(a),h=l*l,c=Math.cos(a),u=l/c,d=u*u,f=d*d,g=1-Yt*h,m=Math.sqrt(1-Yt*h),_=Qn/m,p=(1-Yt)/g,y=Ve*c**2,v=y*y,x=i/(_*Hn),w=x*x,R=w*x,T=R*x,S=T*x,I=S*x,M=a-u/p*(w/2-T/24*(5+3*d+10*y-4*v-9*Ve))+I/720*(61+90*d+298*y+45*f-252*Ve-3*v);let O=(x-R/6*(1+2*d+y)+S/120*(5-2*y+28*d-3*v+8*Ve+24*f))/c;return O=Us(O+Ie(La(e.number)),-Math.PI,Math.PI),[ra(O),ra(M)]}const ba=-80,Ma=84,Jc=-180,Qc=180;function tu(n,t,e){n=Us(n,Jc,Qc),t<ba?t=ba:t>Ma&&(t=Ma);const i=Ie(t),s=Math.sin(i),r=Math.cos(i),o=s/r,a=o*o,l=a*a,h=Ie(n),c=La(e.number),u=Ie(c),d=Qn/Math.sqrt(1-Yt*s**2),f=Ve*r**2,g=r*Us(h-u,-Math.PI,Math.PI),m=g*g,_=m*g,p=_*g,y=p*g,v=y*g,x=Qn*(Ta*i-Uc*Math.sin(2*i)+Kc*Math.sin(4*i)-jc*Math.sin(6*i)),w=Hn*d*(g+_/6*(1-a+f)+y/120*(5-18*a+l+72*f-58*Ve))+5e5;let R=Hn*(x+d*o*(m/2+p/24*(5-a+9*f+4*f**2)+v/720*(61-58*a+l+600*f-330*Ve)));return e.north||(R+=1e7),[w,R]}function La(n){return(n-1)*6-180+3}const eu=[/^EPSG:(\d+)$/,/^urn:ogc:def:crs:EPSG::(\d+)$/,/^http:\/\/www\.opengis\.net\/def\/crs\/EPSG\/0\/(\d+)$/];function Aa(n){let t=0;for(const s of eu){const r=n.match(s);if(r){t=parseInt(r[1]);break}}if(!t)return null;let e=0,i=!1;return t>32700&&t<32761?e=t-32700:t>32600&&t<32661&&(i=!0,e=t-32600),e?{number:e,north:i}:null}function Oa(n,t){return function(e,i,s,r){const o=e.length;s=s>1?s:2,r=r??s,i||(s>2?i=e.slice():i=new Array(o));for(let a=0;a<o;a+=r){const l=e[a],h=e[a+1],c=n(l,h,t);i[a]=c[0],i[a+1]=c[1]}return i}}function iu(n){return Aa(n)?new Js({code:n,units:"m"}):null}function nu(n){const t=Aa(n.getCode());return t?{forward:Oa(tu,t),inverse:Oa(qc,t)}:null}const su=[nu],ru=[iu];let nr=!0;function Pa(n){nr=!1}function sr(n,t){if(t!==void 0){for(let e=0,i=n.length;e<i;++e)t[e]=n[e];t=t}else t=n.slice();return t}function rr(n){Bc(n.getCode(),n),Hi(n,n,sr)}function ou(n){n.forEach(rr)}function Dt(n){if(typeof n!="string")return n;const t=Yc(n);if(t)return t;for(const e of ru){const i=e(n);if(i)return i}return null}function Da(n,t,e,i){n=Dt(n);let s;const r=n.getPointResolutionFunc();if(r)s=r(t,e);else{const o=n.getUnits();if(o=="degrees"&&!i||i=="degrees")s=t;else{const a=lr(n,Dt("EPSG:4326"));if(!a&&o!=="degrees")s=t*n.getMetersPerUnit();else{let h=[e[0]-t/2,e[1],e[0]+t/2,e[1],e[0],e[1]-t/2,e[0],e[1]+t/2];h=a(h,h,2);const c=xa(h.slice(0,2),h.slice(2,4)),u=xa(h.slice(4,6),h.slice(6,8));s=(c+u)/2}const l=n.getMetersPerUnit();l!==void 0&&(s/=l)}}return s}function ka(n){ou(n),n.forEach(function(t){n.forEach(function(e){t!==e&&Hi(t,e,sr)})})}function au(n,t,e,i){n.forEach(function(s){t.forEach(function(r){Hi(s,r,e),Hi(r,s,i)})})}function or(n,t){return n?typeof n=="string"?Dt(n):n:Dt(t)}function lu(n){return(function(t,e,i,s){const r=t.length;i=i!==void 0?i:2,s=s??i,e=e!==void 0?e:new Array(r);for(let o=0;o<r;o+=s){const a=n(t.slice(o,o+i)),l=a.length;for(let h=0,c=s;h<c;++h)e[o+h]=h>=l?t[o+h]:a[h]}return e})}function hu(n,t){return Pa(),cr(n,"EPSG:4326","EPSG:3857")}function ar(n,t){if(n===t)return!0;const e=n.getUnits()===t.getUnits();return(n.getCode()===t.getCode()||lr(n,t)===sr)&&e}function lr(n,t){const e=n.getCode(),i=t.getCode();let s=tr(e,i);if(s)return s;let r=null,o=null;for(const l of su)r||(r=l(n)),o||(o=l(t));if(!r&&!o)return null;const a="EPSG:4326";if(o)if(r)s=hr(r.inverse,o.forward);else{const l=tr(e,a);l&&(s=hr(l,o.forward))}else{const l=tr(a,i);l&&(s=hr(r.inverse,l))}return s&&(rr(n),rr(t),Hi(n,t,s)),s}function hr(n,t){return function(e,i,s,r){return i=n(e,i,s,r),t(i,i,s,r)}}function ts(n,t){const e=Dt(n),i=Dt(t);return lr(e,i)}function cr(n,t,e){const i=ts(t,e);if(!i){const s=Dt(t).getCode(),r=Dt(e).getCode();throw new Error(`No transform available between ${s} and ${r}`)}return i(n,void 0,n.length)}function ur(n,t){return n}function de(n,t){return nr&&!Zn(n,[0,0])&&n[0]>=-180&&n[0]<=180&&n[1]>=-90&&n[1]<=90&&(nr=!1,Ea("Call useGeographic() from ol/proj once to work with [longitude, latitude] coordinates.")),n}function Fa(n,t){return n}function be(n,t){return n}function cu(){ka(wa),ka(Ca),au(Ca,wa,zc,Gc)}cu(),new Array(6);function qt(){return[1,0,0,1,0,0]}function uu(n,t){return n[0]=t[0],n[1]=t[1],n[2]=t[2],n[3]=t[3],n[4]=t[4],n[5]=t[5],n}function yt(n,t){const e=t[0],i=t[1];return t[0]=n[0]*e+n[2]*i+n[4],t[1]=n[1]*e+n[3]*i+n[5],t}function fe(n,t,e,i,s,r,o,a){const l=Math.sin(r),h=Math.cos(r);return n[0]=i*h,n[1]=s*l,n[2]=-i*l,n[3]=s*h,n[4]=o*i*h-a*i*l+t,n[5]=o*s*l+a*s*h+e,n}function Na(n,t){const e=du(t);Q(e!==0,"Transformation matrix cannot be inverted");const i=t[0],s=t[1],r=t[2],o=t[3],a=t[4],l=t[5];return n[0]=o/e,n[1]=-s/e,n[2]=-r/e,n[3]=i/e,n[4]=(r*l-o*a)/e,n[5]=-(i*l-s*a)/e,n}function du(n){return n[0]*n[3]-n[1]*n[2]}const fu=[1e5,1e5,1e5,1e5,2,2];function gu(n){return"matrix("+n.join(", ")+")"}function za(n){return n.substring(7,n.length-1).split(",").map(parseFloat)}function _u(n,t){const e=za(n),i=za(t);for(let s=0;s<6;++s)if(Math.round((e[s]-i[s])*fu[s])!==0)return!1;return!0}function Me(n,t,e,i,s,r,o){r=r||[],o=o||2;let a=0;for(let l=t;l<e;l+=i){const h=n[l],c=n[l+1];r[a++]=s[0]*h+s[2]*c+s[4],r[a++]=s[1]*h+s[3]*c+s[5];for(let u=2;u<o;u++)r[a++]=n[l+u]}return r&&r.length!=a&&(r.length=a),r}function Ga(n,t,e,i,s,r,o){o=o||[];const a=Math.cos(s),l=Math.sin(s),h=r[0],c=r[1];let u=0;for(let d=t;d<e;d+=i){const f=n[d]-h,g=n[d+1]-c;o[u++]=h+f*a-g*l,o[u++]=c+f*l+g*a;for(let m=d+2;m<d+i;++m)o[u++]=n[m]}return o&&o.length!=u&&(o.length=u),o}function mu(n,t,e,i,s,r,o,a){a=a||[];const l=o[0],h=o[1];let c=0;for(let u=t;u<e;u+=i){const d=n[u]-l,f=n[u+1]-h;a[c++]=l+s*d,a[c++]=h+r*f;for(let g=u+2;g<u+i;++g)a[c++]=n[g]}return a&&a.length!=c&&(a.length=c),a}function pu(n,t,e,i,s,r,o){o=o||[];let a=0;for(let l=t;l<e;l+=i){o[a++]=n[l]+s,o[a++]=n[l+1]+r;for(let h=l+2;h<l+i;++h)o[a++]=n[h]}return o&&o.length!=a&&(o.length=a),o}const Wa=qt(),yu=[NaN,NaN];class xu extends ne{constructor(){super(),this.extent_=Xt(),this.extentRevision_=-1,this.simplifiedGeometryMaxMinSquaredTolerance=0,this.simplifiedGeometryRevision=0,this.simplifyTransformedInternal=Qo((t,e,i)=>{if(!i)return this.getSimplifiedGeometry(e);const s=this.clone();return s.applyTransform(i),s.getSimplifiedGeometry(e)})}simplifyTransformed(t,e){return this.simplifyTransformedInternal(this.getRevision(),t,e)}clone(){return H()}closestPointXY(t,e,i,s){return H()}containsXY(t,e){return this.closestPointXY(t,e,yu,Number.MIN_VALUE)===0}getClosestPoint(t,e){return e=e||[NaN,NaN],this.closestPointXY(t[0],t[1],e,1/0),e}intersectsCoordinate(t){return this.containsXY(t[0],t[1])}computeExtent(t){return H()}getExtent(t){if(this.extentRevision_!=this.getRevision()){const e=this.computeExtent(this.extent_);(isNaN(e[0])||isNaN(e[1]))&&Bn(e),this.extentRevision_=this.getRevision()}return bc(this.extent_,t)}rotate(t,e){H()}scale(t,e,i){H()}simplify(t){return this.getSimplifiedGeometry(t*t)}getSimplifiedGeometry(t){return H()}getType(){return H()}applyTransform(t){H()}intersectsExtent(t){return H()}translate(t,e){H()}transform(t,e){const i=Dt(t),s=i.getUnits()=="tile-pixels"?function(r,o,a){const l=i.getExtent(),h=i.getWorldExtent(),c=It(h)/It(l);fe(Wa,h[0],h[3],c,-c,0,0,0);const u=Me(r,0,r.length,a,Wa,o),d=ts(i,e);return d?d(u,u,a):u}:ts(i,e);return this.applyTransform(s),this}}class dr extends xu{constructor(){super(),this.layout="XY",this.stride=2,this.flatCoordinates}computeExtent(t){return Vs(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t)}getCoordinates(){return H()}getFirstCoordinate(){return this.flatCoordinates.slice(0,this.stride)}getFlatCoordinates(){return this.flatCoordinates}getLastCoordinate(){return this.flatCoordinates.slice(this.flatCoordinates.length-this.stride)}getLayout(){return this.layout}getSimplifiedGeometry(t){if(this.simplifiedGeometryRevision!==this.getRevision()&&(this.simplifiedGeometryMaxMinSquaredTolerance=0,this.simplifiedGeometryRevision=this.getRevision()),t<0||this.simplifiedGeometryMaxMinSquaredTolerance!==0&&t<=this.simplifiedGeometryMaxMinSquaredTolerance)return this;const e=this.getSimplifiedGeometryInternal(t);return e.getFlatCoordinates().length<this.flatCoordinates.length?e:(this.simplifiedGeometryMaxMinSquaredTolerance=t,this)}getSimplifiedGeometryInternal(t){return this}getStride(){return this.stride}setFlatCoordinates(t,e){this.stride=Xa(t),this.layout=t,this.flatCoordinates=e}setCoordinates(t,e){H()}setLayout(t,e,i){let s;if(t)s=Xa(t);else{for(let r=0;r<i;++r){if(e.length===0){this.layout="XY",this.stride=2;return}e=e[0]}s=e.length,t=Eu(s)}this.layout=t,this.stride=s}applyTransform(t){this.flatCoordinates&&(t(this.flatCoordinates,this.flatCoordinates,this.layout.startsWith("XYZ")?3:2,this.stride),this.changed())}rotate(t,e){const i=this.getFlatCoordinates();if(i){const s=this.getStride();Ga(i,0,i.length,s,t,e,i),this.changed()}}scale(t,e,i){e===void 0&&(e=t),i||(i=Be(this.getExtent()));const s=this.getFlatCoordinates();if(s){const r=this.getStride();mu(s,0,s.length,r,t,e,i,s),this.changed()}}translate(t,e){const i=this.getFlatCoordinates();if(i){const s=this.getStride();pu(i,0,i.length,s,t,e,i),this.changed()}}}function Eu(n){let t;return n==2?t="XY":n==3?t="XYZ":n==4&&(t="XYZM"),t}function Xa(n){let t;return n=="XY"?t=2:n=="XYZ"||n=="XYM"?t=3:n=="XYZM"&&(t=4),t}function wu(n,t,e){const i=n.getFlatCoordinates();if(!i)return null;const s=n.getStride();return Me(i,0,i.length,s,t,e)}function Ya(n,t,e,i){let s=0;const r=n[e-i],o=n[e-i+1];let a=0,l=0;for(;t<e;t+=i){const h=n[t]-r,c=n[t+1]-o;s+=l*h-a*c,a=h,l=c}return s/2}function vu(n,t,e,i){let s=0;for(let r=0,o=e.length;r<o;++r){const a=e[r];s+=Ya(n,t,a,i),t=a}return s}function Ba(n,t,e,i,s,r,o){const a=n[t],l=n[t+1],h=n[e]-a,c=n[e+1]-l;let u;if(h===0&&c===0)u=t;else{const d=((s-a)*h+(r-l)*c)/(h*h+c*c);if(d>1)u=e;else if(d>0){for(let f=0;f<i;++f)o[f]=Wt(n[t+f],n[e+f],d);o.length=i;return}else u=t}for(let d=0;d<i;++d)o[d]=n[u+d];o.length=i}function Ua(n,t,e,i,s){let r=n[t],o=n[t+1];for(t+=i;t<e;t+=i){const a=n[t],l=n[t+1],h=hi(r,o,a,l);h>s&&(s=h),r=a,o=l}return s}function Cu(n,t,e,i,s){for(let r=0,o=e.length;r<o;++r){const a=e[r];s=Ua(n,t,a,i,s),t=a}return s}function Ka(n,t,e,i,s,r,o,a,l,h,c){if(t==e)return h;let u,d;if(s===0){if(d=hi(o,a,n[t],n[t+1]),d<h){for(u=0;u<i;++u)l[u]=n[t+u];return l.length=i,d}return h}c=c||[NaN,NaN];let f=t+i;for(;f<e;)if(Ba(n,f-i,f,i,o,a,c),d=hi(o,a,c[0],c[1]),d<h){for(h=d,u=0;u<i;++u)l[u]=c[u];l.length=i,f+=i}else f+=i*Math.max((Math.sqrt(d)-Math.sqrt(h))/s|0,1);if(Ba(n,e-i,t,i,o,a,c),d=hi(o,a,c[0],c[1]),d<h){for(h=d,u=0;u<i;++u)l[u]=c[u];l.length=i}return h}function Ru(n,t,e,i,s,r,o,a,l,h,c){c=c||[NaN,NaN];for(let u=0,d=e.length;u<d;++u){const f=e[u];h=Ka(n,t,f,i,s,r,o,a,l,h,c),t=f}return h}function Su(n,t,e,i){for(let s=0,r=e.length;s<r;++s)n[t++]=e[s];return t}function ja(n,t,e,i){for(let s=0,r=e.length;s<r;++s){const o=e[s];for(let a=0;a<i;++a)n[t++]=o[a]}return t}function Iu(n,t,e,i,s){s=s||[];let r=0;for(let o=0,a=e.length;o<a;++o){const l=ja(n,t,e[o],i);s[r++]=l,t=l}return s.length=r,s}function pi(n,t,e,i,s){s=s!==void 0?s:[];let r=0;for(let o=t;o<e;o+=i)s[r++]=n.slice(o,o+i);return s.length=r,s}function es(n,t,e,i,s){s=s!==void 0?s:[];let r=0;for(let o=0,a=e.length;o<a;++o){const l=e[o];s[r++]=pi(n,t,l,i,s[r]),t=l}return s.length=r,s}function Va(n,t,e,i,s){s=s!==void 0?s:[];let r=0;for(let o=0,a=e.length;o<a;++o){const l=e[o];s[r++]=l.length===1&&l[0]===t?[]:es(n,t,l,i,s[r]),t=l[l.length-1]}return s.length=r,s}function fr(n,t,e,i,s,r,o){const a=(e-t)/i;if(a<3){for(;t<e;t+=i)r[o++]=n[t],r[o++]=n[t+1];return o}const l=new Array(a);l[0]=1,l[a-1]=1;const h=[t,e-i];let c=0;for(;h.length>0;){const u=h.pop(),d=h.pop();let f=0;const g=n[d],m=n[d+1],_=n[u],p=n[u+1];for(let y=d+i;y<u;y+=i){const v=n[y],x=n[y+1],w=vc(v,x,g,m,_,p);w>f&&(c=y,f=w)}f>s&&(l[(c-t)/i]=1,d+i<c&&h.push(d,c),c+i<u&&h.push(c,u))}for(let u=0;u<a;++u)l[u]&&(r[o++]=n[t+u*i],r[o++]=n[t+u*i+1]);return o}function Tu(n,t,e,i,s,r,o,a){for(let l=0,h=e.length;l<h;++l){const c=e[l];o=fr(n,t,c,i,s,r,o),a.push(o),t=c}return o}function Ze(n,t){return t*Math.round(n/t)}function bu(n,t,e,i,s,r,o){if(t==e)return o;let a=Ze(n[t],s),l=Ze(n[t+1],s);t+=i,r[o++]=a,r[o++]=l;let h,c;do if(h=Ze(n[t],s),c=Ze(n[t+1],s),t+=i,t==e)return r[o++]=h,r[o++]=c,o;while(h==a&&c==l);for(;t<e;){const u=Ze(n[t],s),d=Ze(n[t+1],s);if(t+=i,u==h&&d==c)continue;const f=h-a,g=c-l,m=u-a,_=d-l;if(f*_==g*m&&(f<0&&m<f||f==m||f>0&&m>f)&&(g<0&&_<g||g==_||g>0&&_>g)){h=u,c=d;continue}r[o++]=h,r[o++]=c,a=h,l=c,h=u,c=d}return r[o++]=h,r[o++]=c,o}function Za(n,t,e,i,s,r,o,a){for(let l=0,h=e.length;l<h;++l){const c=e[l];o=bu(n,t,c,i,s,r,o),a.push(o),t=c}return o}class qi extends dr{constructor(t,e){super(),this.maxDelta_=-1,this.maxDeltaRevision_=-1,e!==void 0&&!Array.isArray(t[0])?this.setFlatCoordinates(e,t):this.setCoordinates(t,e)}clone(){return new qi(this.flatCoordinates.slice(),this.layout)}closestPointXY(t,e,i,s){return s<ha(this.getExtent(),t,e)?s:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(Ua(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),Ka(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,this.maxDelta_,!0,t,e,i,s))}getArea(){return Ya(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getCoordinates(){return pi(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getSimplifiedGeometryInternal(t){const e=[];return e.length=fr(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t,e,0),new qi(e,"XY")}getType(){return"LinearRing"}intersectsExtent(t){return!1}setCoordinates(t,e){this.setLayout(e,t,1),this.flatCoordinates||(this.flatCoordinates=[]),this.flatCoordinates.length=ja(this.flatCoordinates,0,t,this.stride),this.changed()}}class is extends dr{constructor(t,e){super(),this.setCoordinates(t,e)}clone(){const t=new is(this.flatCoordinates.slice(),this.layout);return t.applyProperties(this),t}closestPointXY(t,e,i,s){const r=this.flatCoordinates,o=hi(t,e,r[0],r[1]);if(o<s){const a=this.stride;for(let l=0;l<a;++l)i[l]=r[l];return i.length=a,o}return s}getCoordinates(){return this.flatCoordinates.slice()}computeExtent(t){return ua(this.flatCoordinates,t)}getType(){return"Point"}intersectsExtent(t){return ca(t,this.flatCoordinates[0],this.flatCoordinates[1])}setCoordinates(t,e){this.setLayout(e,t,0),this.flatCoordinates||(this.flatCoordinates=[]),this.flatCoordinates.length=Su(this.flatCoordinates,0,t,this.stride),this.changed()}}function Mu(n,t,e,i,s){return!fa(s,function(o){return!$e(n,t,e,i,o[0],o[1])})}function $e(n,t,e,i,s,r){let o=0,a=n[e-i],l=n[e-i+1];for(;t<e;t+=i){const h=n[t],c=n[t+1];l<=r?c>r&&(h-a)*(r-l)-(s-a)*(c-l)>0&&o++:c<=r&&(h-a)*(r-l)-(s-a)*(c-l)<0&&o--,a=h,l=c}return o!==0}function $a(n,t,e,i,s,r){if(e.length===0||!$e(n,t,e[0],i,s,r))return!1;for(let o=1,a=e.length;o<a;++o)if($e(n,e[o-1],e[o],i,s,r))return!1;return!0}function gr(n,t,e,i,s,r,o){let a,l,h,c,u,d,f;const g=s[r+1],m=[];for(let y=0,v=e.length;y<v;++y){const x=e[y];for(c=n[x-i],d=n[x-i+1],a=t;a<x;a+=i)u=n[a],f=n[a+1],(g<=d&&f<=g||d<=g&&g<=f)&&(h=(g-d)/(f-d)*(u-c)+c,m.push(h)),c=u,d=f}let _=NaN,p=-1/0;for(m.sort(ce),c=m[0],a=1,l=m.length;a<l;++a){u=m[a];const y=Math.abs(u-c);y>p&&(h=(c+u)/2,$a(n,t,e,i,h,g)&&(_=h,p=y)),c=u}return isNaN(_)&&(_=s[r]),o?(o.push(_,g,p),o):[_,g,p]}function Lu(n,t,e,i,s){let r=[];for(let o=0,a=e.length;o<a;++o){const l=e[o];r=gr(n,t,l,i,s,2*o,r),t=l[l.length-1]}return r}function Au(n,t,e,i,s){let r;for(t+=i;t<e;t+=i)if(r=s(n.slice(t-i,t),n.slice(t,t+i)),r)return r;return!1}function Ha(n,t,e,i,s,r){return r=r??da(Xt(),n,t,e,i),Pt(s,r)?r[0]>=s[0]&&r[2]<=s[2]||r[1]>=s[1]&&r[3]<=s[3]?!0:Au(n,t,e,i,function(o,a){return Mc(s,o,a)}):!1}function qa(n,t,e,i,s){return!!(Ha(n,t,e,i,s)||$e(n,t,e,i,s[0],s[1])||$e(n,t,e,i,s[0],s[3])||$e(n,t,e,i,s[2],s[1])||$e(n,t,e,i,s[2],s[3]))}function Ou(n,t,e,i,s){if(!qa(n,t,e[0],i,s))return!1;if(e.length===1)return!0;for(let r=1,o=e.length;r<o;++r)if(Mu(n,e[r-1],e[r],i,s)&&!Ha(n,e[r-1],e[r],i,s))return!1;return!0}function Pu(n,t,e,i){for(;t<e-i;){for(let s=0;s<i;++s){const r=n[t+s];n[t+s]=n[e-i+s],n[e-i+s]=r}t+=i,e-=i}}function _r(n,t,e,i){let s=0,r=n[e-i],o=n[e-i+1];for(;t<e;t+=i){const a=n[t],l=n[t+1];s+=(a-r)*(l+o),r=a,o=l}return s===0?void 0:s>0}function Du(n,t,e,i,s){s=s!==void 0?s:!1;for(let r=0,o=e.length;r<o;++r){const a=e[r],l=_r(n,t,a,i);if(r===0){if(s&&l||!s&&!l)return!1}else if(s&&!l||!s&&l)return!1;t=a}return!0}function Ja(n,t,e,i,s){s=s!==void 0?s:!1;for(let r=0,o=e.length;r<o;++r){const a=e[r],l=_r(n,t,a,i);(r===0?s&&l||!s&&!l:s&&!l||!s&&l)&&Pu(n,t,a,i),t=a}return t}function ku(n,t){const e=[];let i=0,s=0,r;for(let o=0,a=t.length;o<a;++o){const l=t[o],h=_r(n,i,l,2);if(r===void 0&&(r=h),h===r)e.push(t.slice(s,o+1));else{if(e.length===0)continue;e[e.length-1].push(t[s])}s=o+1,i=l}return e}class Ji extends dr{constructor(t,e,i){super(),this.ends_=[],this.flatInteriorPointRevision_=-1,this.flatInteriorPoint_=null,this.maxDelta_=-1,this.maxDeltaRevision_=-1,this.orientedRevision_=-1,this.orientedFlatCoordinates_=null,e!==void 0&&i?(this.setFlatCoordinates(e,t),this.ends_=i):this.setCoordinates(t,e)}appendLinearRing(t){this.flatCoordinates?Xs(this.flatCoordinates,t.getFlatCoordinates()):this.flatCoordinates=t.getFlatCoordinates().slice(),this.ends_.push(this.flatCoordinates.length),this.changed()}clone(){const t=new Ji(this.flatCoordinates.slice(),this.layout,this.ends_.slice());return t.applyProperties(this),t}closestPointXY(t,e,i,s){return s<ha(this.getExtent(),t,e)?s:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(Cu(this.flatCoordinates,0,this.ends_,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),Ru(this.flatCoordinates,0,this.ends_,this.stride,this.maxDelta_,!0,t,e,i,s))}containsXY(t,e){return $a(this.getOrientedFlatCoordinates(),0,this.ends_,this.stride,t,e)}getArea(){return vu(this.getOrientedFlatCoordinates(),0,this.ends_,this.stride)}getCoordinates(t){let e;return t!==void 0?(e=this.getOrientedFlatCoordinates().slice(),Ja(e,0,this.ends_,this.stride,t)):e=this.flatCoordinates,es(e,0,this.ends_,this.stride)}getEnds(){return this.ends_}getFlatInteriorPoint(){if(this.flatInteriorPointRevision_!=this.getRevision()){const t=Be(this.getExtent());this.flatInteriorPoint_=gr(this.getOrientedFlatCoordinates(),0,this.ends_,this.stride,t,0),this.flatInteriorPointRevision_=this.getRevision()}return this.flatInteriorPoint_}getInteriorPoint(){return new is(this.getFlatInteriorPoint(),"XYM")}getLinearRingCount(){return this.ends_.length}getLinearRing(t){return t<0||this.ends_.length<=t?null:new qi(this.flatCoordinates.slice(t===0?0:this.ends_[t-1],this.ends_[t]),this.layout)}getLinearRings(){const t=this.layout,e=this.flatCoordinates,i=this.ends_,s=[];let r=0;for(let o=0,a=i.length;o<a;++o){const l=i[o],h=new qi(e.slice(r,l),t);s.push(h),r=l}return s}getOrientedFlatCoordinates(){if(this.orientedRevision_!=this.getRevision()){const t=this.flatCoordinates;Du(t,0,this.ends_,this.stride)?this.orientedFlatCoordinates_=t:(this.orientedFlatCoordinates_=t.slice(),this.orientedFlatCoordinates_.length=Ja(this.orientedFlatCoordinates_,0,this.ends_,this.stride)),this.orientedRevision_=this.getRevision()}return this.orientedFlatCoordinates_}getSimplifiedGeometryInternal(t){const e=[],i=[];return e.length=Za(this.flatCoordinates,0,this.ends_,this.stride,Math.sqrt(t),e,0,i),new Ji(e,"XY",i)}getType(){return"Polygon"}intersectsExtent(t){return Ou(this.getOrientedFlatCoordinates(),0,this.ends_,this.stride,t)}setCoordinates(t,e){this.setLayout(e,t,2),this.flatCoordinates||(this.flatCoordinates=[]);const i=Iu(this.flatCoordinates,0,t,this.stride,this.ends_);this.flatCoordinates.length=i.length===0?0:i[i.length-1],this.changed()}}function Qa(n){if(Vn(n))throw new Error("Cannot create polygon from empty extent");const t=n[0],e=n[1],i=n[2],s=n[3],r=[t,e,t,s,i,s,i,e,t,e];return new Ji(r,"XY",[r.length])}function mr(n,t,e,i){const s=et(t)/e[0],r=It(t)/e[1];return i?Math.min(n,Math.max(s,r)):Math.min(n,Math.min(s,r))}function pr(n,t,e){let i=Math.min(n,t);const s=50;return i*=Math.log(1+s*Math.max(0,n/t-1))/s+1,e&&(i=Math.max(i,e),i/=Math.log(1+s*Math.max(0,e/n-1))/s+1),lt(i,e/2,t*2)}function Fu(n,t,e,i){return t=t!==void 0?t:!0,(function(s,r,o,a){if(s!==void 0){const l=n[0],h=n[n.length-1],c=e?mr(l,e,o,i):l;if(a)return t?pr(s,c,h):lt(s,h,c);const u=Math.min(c,s),d=Math.floor(Ws(n,u,r));return n[d]>c&&d<n.length-1?n[d+1]:n[d]}})}function Nu(n,t,e,i,s,r){return i=i!==void 0?i:!0,e=e!==void 0?e:0,(function(o,a,l,h){if(o!==void 0){const c=s?mr(t,s,l,r):t;if(h)return i?pr(o,c,e):lt(o,e,c);const u=1e-9,d=Math.ceil(Math.log(t/c)/Math.log(n)-u),f=-a*(.5-u)+.5,g=Math.min(c,o),m=Math.floor(Math.log(t/g)/Math.log(n)+f),_=Math.max(d,m),p=t/Math.pow(n,_);return lt(p,e,c)}})}function tl(n,t,e,i,s){return e=e!==void 0?e:!0,(function(r,o,a,l){if(r!==void 0){const h=i?mr(n,i,a,s):n;return!e||!l?lt(r,t,h):pr(r,h,t)}})}function yr(n){if(n!==void 0)return 0}function el(n){if(n!==void 0)return n}function zu(n){const t=2*Math.PI/n;return(function(e,i){if(i)return e;if(e!==void 0)return e=Math.floor(e/t+.5)*t,e})}function Gu(n){const t=Ie(5);return(function(e,i){return i||e===void 0?e:Math.abs(e)<=t?0:e})}const Wu=42,xr=256,Er=0;class re extends ne{constructor(t){super(),this.on,this.once,this.un,t=Object.assign({},t),this.hints_=[0,0],this.animations_=[],this.updateAnimationKey_,this.projection_=or(t.projection,"EPSG:3857"),this.viewportSize_=[100,100],this.targetCenter_=null,this.targetResolution_,this.targetRotation_,this.nextCenter_=null,this.nextResolution_,this.nextRotation_,this.cancelAnchor_=void 0,t.projection&&Pa(),t.center&&(t.center=de(t.center,this.projection_)),t.extent&&(t.extent=be(t.extent,this.projection_)),this.applyOptions_(t)}applyOptions_(t){const e=Object.assign({},t);for(const a in Ht)delete e[a];this.setProperties(e,!0);const i=Yu(t);this.maxResolution_=i.maxResolution,this.minResolution_=i.minResolution,this.zoomFactor_=i.zoomFactor,this.resolutions_=t.resolutions,this.padding_=t.padding,this.minZoom_=i.minZoom;const s=Xu(t),r=i.constraint,o=Bu(t);this.constraints_={center:s,resolution:r,rotation:o},this.setRotation(t.rotation!==void 0?t.rotation:0),this.setCenterInternal(t.center!==void 0?t.center:null),t.resolution!==void 0?this.setResolution(t.resolution):t.zoom!==void 0&&this.setZoom(t.zoom)}get padding(){return this.padding_}set padding(t){let e=this.padding_;this.padding_=t;const i=this.getCenterInternal();if(i){const s=t||[0,0,0,0];e=e||[0,0,0,0];const r=this.getResolution(),o=r/2*(s[3]-e[3]+e[1]-s[1]),a=r/2*(s[0]-e[0]+e[2]-s[2]);this.setCenterInternal([i[0]+o,i[1]-a])}}getUpdatedOptions_(t){const e=this.getProperties();return e.resolution!==void 0?e.resolution=this.getResolution():e.zoom=this.getZoom(),e.center=this.getCenterInternal(),e.rotation=this.getRotation(),Object.assign({},e,t)}animate(t){this.isDef()&&!this.getAnimating()&&this.resolveConstraints(0);const e=new Array(arguments.length);for(let i=0;i<e.length;++i){let s=arguments[i];s.center&&(s=Object.assign({},s),s.center=de(s.center,this.getProjection())),s.anchor&&(s=Object.assign({},s),s.anchor=de(s.anchor,this.getProjection())),e[i]=s}this.animateInternal.apply(this,e)}animateInternal(t){let e=arguments.length,i;e>1&&typeof arguments[e-1]=="function"&&(i=arguments[e-1],--e);let s=0;for(;s<e&&!this.isDef();++s){const c=arguments[s];c.center&&this.setCenterInternal(c.center),c.zoom!==void 0?this.setZoom(c.zoom):c.resolution&&this.setResolution(c.resolution),c.rotation!==void 0&&this.setRotation(c.rotation)}if(s===e){i&&ns(i,!0);return}let r=Date.now(),o=this.targetCenter_.slice(),a=this.targetResolution_,l=this.targetRotation_;const h=[];for(;s<e;++s){const c=arguments[s],u={start:r,complete:!1,anchor:c.anchor,duration:c.duration!==void 0?c.duration:1e3,easing:c.easing||Pc,callback:i};if(c.center&&(u.sourceCenter=o,u.targetCenter=c.center.slice(),o=u.targetCenter),c.zoom!==void 0?(u.sourceResolution=a,u.targetResolution=this.getResolutionForZoom(c.zoom),a=u.targetResolution):c.resolution&&(u.sourceResolution=a,u.targetResolution=c.resolution,a=u.targetResolution),c.rotation!==void 0){u.sourceRotation=l;const d=ci(c.rotation-l+Math.PI,2*Math.PI)-Math.PI;u.targetRotation=l+d,l=u.targetRotation}Uu(u)?u.complete=!0:r+=u.duration,h.push(u)}this.animations_.push(h),this.setHint(St.ANIMATING,1),this.updateAnimations_()}getAnimating(){return this.hints_[St.ANIMATING]>0}getInteracting(){return this.hints_[St.INTERACTING]>0}cancelAnimations(){this.setHint(St.ANIMATING,-this.hints_[St.ANIMATING]);let t;for(let e=0,i=this.animations_.length;e<i;++e){const s=this.animations_[e];if(s[0].callback&&ns(s[0].callback,!1),!t)for(let r=0,o=s.length;r<o;++r){const a=s[r];if(!a.complete){t=a.anchor;break}}}this.animations_.length=0,this.cancelAnchor_=t,this.nextCenter_=null,this.nextResolution_=NaN,this.nextRotation_=NaN}updateAnimations_(){if(this.updateAnimationKey_!==void 0&&(cancelAnimationFrame(this.updateAnimationKey_),this.updateAnimationKey_=void 0),!this.getAnimating())return;const t=Date.now();let e=!1;for(let i=this.animations_.length-1;i>=0;--i){const s=this.animations_[i];let r=!0;for(let o=0,a=s.length;o<a;++o){const l=s[o];if(l.complete)continue;const h=t-l.start;let c=l.duration>0?h/l.duration:1;c>=1?(l.complete=!0,c=1):r=!1;const u=l.easing(c);if(l.sourceCenter){const d=l.sourceCenter[0],f=l.sourceCenter[1],g=l.targetCenter[0],m=l.targetCenter[1];this.nextCenter_=l.targetCenter;const _=d+u*(g-d),p=f+u*(m-f);this.targetCenter_=[_,p]}if(l.sourceResolution&&l.targetResolution){const d=u===1?l.targetResolution:l.sourceResolution+u*(l.targetResolution-l.sourceResolution);if(l.anchor){const f=this.getViewportSize_(this.getRotation()),g=this.constraints_.resolution(d,0,f,!0);this.targetCenter_=this.calculateCenterZoom(g,l.anchor)}this.nextResolution_=l.targetResolution,this.targetResolution_=d,this.applyTargetState_(!0)}if(l.sourceRotation!==void 0&&l.targetRotation!==void 0){const d=u===1?ci(l.targetRotation+Math.PI,2*Math.PI)-Math.PI:l.sourceRotation+u*(l.targetRotation-l.sourceRotation);if(l.anchor){const f=this.constraints_.rotation(d,!0);this.targetCenter_=this.calculateCenterRotate(f,l.anchor)}this.nextRotation_=l.targetRotation,this.targetRotation_=d}if(this.applyTargetState_(!0),e=!0,!l.complete)break}if(r){this.animations_[i]=null,this.setHint(St.ANIMATING,-1),this.nextCenter_=null,this.nextResolution_=NaN,this.nextRotation_=NaN;const o=s[0].callback;o&&ns(o,!0)}}this.animations_=this.animations_.filter(Boolean),e&&this.updateAnimationKey_===void 0&&(this.updateAnimationKey_=requestAnimationFrame(this.updateAnimations_.bind(this)))}calculateCenterRotate(t,e){let i;const s=this.getCenterInternal();return s!==void 0&&(i=[s[0]-e[0],s[1]-e[1]],Hs(i,t-this.getRotation()),Lc(i,e)),i}calculateCenterZoom(t,e){let i;const s=this.getCenterInternal(),r=this.getResolution();if(s!==void 0&&r!==void 0){const o=e[0]-t*(e[0]-s[0])/r,a=e[1]-t*(e[1]-s[1])/r;i=[o,a]}return i}getViewportSize_(t){const e=this.viewportSize_;if(t){const i=e[0],s=e[1];return[Math.abs(i*Math.cos(t))+Math.abs(s*Math.sin(t)),Math.abs(i*Math.sin(t))+Math.abs(s*Math.cos(t))]}return e}setViewportSize(t){this.viewportSize_=Array.isArray(t)?t.slice():[100,100],this.getAnimating()||this.resolveConstraints(0)}getCenter(){const t=this.getCenterInternal();return t&&ur(t,this.getProjection())}getCenterInternal(){return this.get(Ht.CENTER)}getConstraints(){return this.constraints_}getConstrainResolution(){return this.get("constrainResolution")}getHints(t){return t!==void 0?(t[0]=this.hints_[0],t[1]=this.hints_[1],t):this.hints_.slice()}calculateExtent(t){const e=this.calculateExtentInternal(t);return Fa(e,this.getProjection())}calculateExtentInternal(t){t=t||this.getViewportSizeMinusPadding_();const e=this.getCenterInternal();Q(e,"The view center is not defined");const i=this.getResolution();Q(i!==void 0,"The view resolution is not defined");const s=this.getRotation();return Q(s!==void 0,"The view rotation is not defined"),$s(e,i,s,t)}getMaxResolution(){return this.maxResolution_}getMinResolution(){return this.minResolution_}getMaxZoom(){return this.getZoomForResolution(this.minResolution_)}setMaxZoom(t){this.applyOptions_(this.getUpdatedOptions_({maxZoom:t}))}getMinZoom(){return this.getZoomForResolution(this.maxResolution_)}setMinZoom(t){this.applyOptions_(this.getUpdatedOptions_({minZoom:t}))}setConstrainResolution(t){this.applyOptions_(this.getUpdatedOptions_({constrainResolution:t}))}getProjection(){return this.projection_}getResolution(){return this.get(Ht.RESOLUTION)}getResolutions(){return this.resolutions_}getResolutionForExtent(t,e){return this.getResolutionForExtentInternal(be(t,this.getProjection()),e)}getResolutionForExtentInternal(t,e){e=e||this.getViewportSizeMinusPadding_();const i=et(t)/e[0],s=It(t)/e[1];return Math.max(i,s)}getResolutionForValueFunction(t){t=t||2;const e=this.getConstrainedResolution(this.maxResolution_),i=this.minResolution_,s=Math.log(e/i)/Math.log(t);return(function(r){return e/Math.pow(t,r*s)})}getRotation(){return this.get(Ht.ROTATION)}getValueForResolutionFunction(t){const e=Math.log(t||2),i=this.getConstrainedResolution(this.maxResolution_),s=this.minResolution_,r=Math.log(i/s)/e;return(function(o){return Math.log(i/o)/e/r})}getViewportSizeMinusPadding_(t){let e=this.getViewportSize_(t);const i=this.padding_;return i&&(e=[e[0]-i[1]-i[3],e[1]-i[0]-i[2]]),e}getState(){const t=this.getProjection(),e=this.getResolution(),i=this.getRotation();let s=this.getCenterInternal();const r=this.padding_;if(r){const o=this.getViewportSizeMinusPadding_();s=wr(s,this.getViewportSize_(),[o[0]/2+r[3],o[1]/2+r[0]],e,i)}return{center:s.slice(0),projection:t!==void 0?t:null,resolution:e,nextCenter:this.nextCenter_,nextResolution:this.nextResolution_,nextRotation:this.nextRotation_,rotation:i,zoom:this.getZoom()}}getViewStateAndExtent(){return{viewState:this.getState(),extent:this.calculateExtent()}}getZoom(){let t;const e=this.getResolution();return e!==void 0&&(t=this.getZoomForResolution(e)),t}getZoomForResolution(t){let e=this.minZoom_||0,i,s;if(this.resolutions_){const r=Ws(this.resolutions_,t,1);e=r,i=this.resolutions_[r],r==this.resolutions_.length-1?s=2:s=i/this.resolutions_[r+1]}else i=this.maxResolution_,s=this.zoomFactor_;return e+Math.log(i/t)/Math.log(s)}getResolutionForZoom(t){if(this.resolutions_?.length){if(this.resolutions_.length===1)return this.resolutions_[0];const e=lt(Math.floor(t),0,this.resolutions_.length-2),i=this.resolutions_[e]/this.resolutions_[e+1];return this.resolutions_[e]/Math.pow(i,lt(t-e,0,1))}return this.maxResolution_/Math.pow(this.zoomFactor_,t-this.minZoom_)}fit(t,e){let i;if(Q(Array.isArray(t)||typeof t.getSimplifiedGeometry=="function","Invalid extent or geometry provided as `geometry`"),Array.isArray(t)){Q(!Vn(t),"Cannot fit empty extent provided as `geometry`");const s=be(t,this.getProjection());i=Qa(s)}else if(t.getType()==="Circle"){const s=be(t.getExtent(),this.getProjection());i=Qa(s),i.rotate(this.getRotation(),Be(s))}else i=t;this.fitInternal(i,e)}rotatedExtentForGeometry(t){const e=this.getRotation(),i=Math.cos(e),s=Math.sin(-e),r=t.getFlatCoordinates(),o=t.getStride();let a=1/0,l=1/0,h=-1/0,c=-1/0;for(let u=0,d=r.length;u<d;u+=o){const f=r[u]*i-r[u+1]*s,g=r[u]*s+r[u+1]*i;a=Math.min(a,f),l=Math.min(l,g),h=Math.max(h,f),c=Math.max(c,g)}return[a,l,h,c]}fitInternal(t,e){e=e||{};let i=e.size;i||(i=this.getViewportSizeMinusPadding_());const s=e.padding!==void 0?e.padding:[0,0,0,0],r=e.nearest!==void 0?e.nearest:!1;let o;e.minResolution!==void 0?o=e.minResolution:e.maxZoom!==void 0?o=this.getResolutionForZoom(e.maxZoom):o=0;const a=this.rotatedExtentForGeometry(t);let l=this.getResolutionForExtentInternal(a,[i[0]-s[1]-s[3],i[1]-s[0]-s[2]]);l=isNaN(l)?o:Math.max(l,o),l=this.getConstrainedResolution(l,r?0:1);const h=this.getRotation(),c=Math.sin(h),u=Math.cos(h),d=Be(a);d[0]+=(s[1]-s[3])/2*l,d[1]+=(s[0]-s[2])/2*l;const f=d[0]*u-d[1]*c,g=d[1]*u+d[0]*c,m=this.getConstrainedCenter([f,g],l),_=e.callback?e.callback:Bi;e.duration!==void 0?this.animateInternal({resolution:l,center:m,duration:e.duration,easing:e.easing},_):(this.targetResolution_=l,this.targetCenter_=m,this.applyTargetState_(!1,!0),ns(_,!0))}centerOn(t,e,i){this.centerOnInternal(de(t,this.getProjection()),e,i)}centerOnInternal(t,e,i){this.setCenterInternal(wr(t,e,i,this.getResolution(),this.getRotation()))}calculateCenterShift(t,e,i,s){let r;const o=this.padding_;if(o&&t){const a=this.getViewportSizeMinusPadding_(-i),l=wr(t,s,[a[0]/2+o[3],a[1]/2+o[0]],e,i);r=[t[0]-l[0],t[1]-l[1]]}return r}isDef(){return!!this.getCenterInternal()&&this.getResolution()!==void 0}adjustCenter(t){const e=ur(this.targetCenter_,this.getProjection());this.setCenter([e[0]+t[0],e[1]+t[1]])}adjustCenterInternal(t){const e=this.targetCenter_;this.setCenterInternal([e[0]+t[0],e[1]+t[1]])}adjustResolution(t,e){e=e&&de(e,this.getProjection()),this.adjustResolutionInternal(t,e)}adjustResolutionInternal(t,e){const i=this.getAnimating()||this.getInteracting(),s=this.getViewportSize_(this.getRotation()),r=this.constraints_.resolution(this.targetResolution_*t,0,s,i);e&&(this.targetCenter_=this.calculateCenterZoom(r,e)),this.targetResolution_*=t,this.applyTargetState_()}adjustZoom(t,e){this.adjustResolution(Math.pow(this.zoomFactor_,-t),e)}adjustRotation(t,e){e&&(e=de(e,this.getProjection())),this.adjustRotationInternal(t,e)}adjustRotationInternal(t,e){const i=this.getAnimating()||this.getInteracting(),s=this.constraints_.rotation(this.targetRotation_+t,i);e&&(this.targetCenter_=this.calculateCenterRotate(s,e)),this.targetRotation_+=t,this.applyTargetState_()}setCenter(t){this.setCenterInternal(t&&de(t,this.getProjection()))}setCenterInternal(t){this.targetCenter_=t,this.applyTargetState_()}setHint(t,e){return this.hints_[t]+=e,this.changed(),this.hints_[t]}setResolution(t){this.targetResolution_=t,this.applyTargetState_()}setRotation(t){this.targetRotation_=t,this.applyTargetState_()}setZoom(t){this.setResolution(this.getResolutionForZoom(t))}applyTargetState_(t,e){const i=this.getAnimating()||this.getInteracting()||e,s=this.constraints_.rotation(this.targetRotation_,i),r=this.getViewportSize_(s),o=this.constraints_.resolution(this.targetResolution_,0,r,i),a=this.constraints_.center(this.targetCenter_,o,r,i,this.calculateCenterShift(this.targetCenter_,o,s,r));this.get(Ht.ROTATION)!==s&&this.set(Ht.ROTATION,s),this.get(Ht.RESOLUTION)!==o&&(this.set(Ht.RESOLUTION,o),this.set("zoom",this.getZoom(),!0)),(!a||!this.get(Ht.CENTER)||!Zn(this.get(Ht.CENTER),a))&&this.set(Ht.CENTER,a),this.getAnimating()&&!t&&this.cancelAnimations(),this.cancelAnchor_=void 0}resolveConstraints(t,e,i){t=t!==void 0?t:200;const s=e||0,r=this.constraints_.rotation(this.targetRotation_),o=this.getViewportSize_(r),a=this.constraints_.resolution(this.targetResolution_,s,o),l=this.constraints_.center(this.targetCenter_,a,o,!1,this.calculateCenterShift(this.targetCenter_,a,r,o));if(t===0&&!this.cancelAnchor_){this.targetResolution_=a,this.targetRotation_=r,this.targetCenter_=l,this.applyTargetState_();return}i=i||(t===0?this.cancelAnchor_:void 0),this.cancelAnchor_=void 0,(this.getResolution()!==a||this.getRotation()!==r||!this.getCenterInternal()||!Zn(this.getCenterInternal(),l))&&(this.getAnimating()&&this.cancelAnimations(),this.animateInternal({rotation:r,center:l,resolution:a,duration:t,easing:di,anchor:i}))}beginInteraction(){this.resolveConstraints(0),this.setHint(St.INTERACTING,1)}endInteraction(t,e,i){i=i&&de(i,this.getProjection()),this.endInteractionInternal(t,e,i)}endInteractionInternal(t,e,i){this.getInteracting()&&(this.setHint(St.INTERACTING,-1),this.resolveConstraints(t,e,i))}getConstrainedCenter(t,e){const i=this.getViewportSize_(this.getRotation());return this.constraints_.center(t,e||this.getResolution(),i)}getConstrainedZoom(t,e){const i=this.getResolutionForZoom(t);return this.getZoomForResolution(this.getConstrainedResolution(i,e))}getConstrainedResolution(t,e){e=e||0;const i=this.getViewportSize_(this.getRotation());return this.constraints_.resolution(t,e,i)}}function ns(n,t){setTimeout(function(){n(t)},0)}function Xu(n){if(n.extent!==void 0){const e=n.smoothExtentConstraint!==void 0?n.smoothExtentConstraint:!0;return oa(n.extent,n.constrainOnlyCenter,e)}const t=or(n.projection,"EPSG:3857");if(n.multiWorld!==!0&&t.isGlobal()){const e=t.getExtent().slice();return e[0]=-1/0,e[2]=1/0,oa(e,!1,!1)}return Rc}function Yu(n){let t,e,i,o=n.minZoom!==void 0?n.minZoom:Er,a=n.maxZoom!==void 0?n.maxZoom:28;const l=n.zoomFactor!==void 0?n.zoomFactor:2,h=n.multiWorld!==void 0?n.multiWorld:!1,c=n.smoothResolutionConstraint!==void 0?n.smoothResolutionConstraint:!0,u=n.showFullExtent!==void 0?n.showFullExtent:!1,d=or(n.projection,"EPSG:3857"),f=d.getExtent();let g=n.constrainOnlyCenter,m=n.extent;if(!h&&!m&&d.isGlobal()&&(g=!1,m=f),n.resolutions!==void 0){const _=n.resolutions;e=_[o],i=_[a]!==void 0?_[a]:_[_.length-1],n.constrainResolution?t=Fu(_,c,!g&&m,u):t=tl(e,i,c,!g&&m,u)}else{const p=(f?Math.max(et(f),It(f)):360*qs.degrees/d.getMetersPerUnit())/xr/Math.pow(2,Er),y=p/Math.pow(2,28-Er);e=n.maxResolution,e!==void 0?o=0:e=p/Math.pow(l,o),i=n.minResolution,i===void 0&&(n.maxZoom!==void 0?n.maxResolution!==void 0?i=e/Math.pow(l,a):i=p/Math.pow(l,a):i=y),a=o+Math.floor(Math.log(e/i)/Math.log(l)),i=e/Math.pow(l,a-o),n.constrainResolution?t=Nu(l,e,i,c,!g&&m,u):t=tl(e,i,c,!g&&m,u)}return{constraint:t,maxResolution:e,minResolution:i,minZoom:o,zoomFactor:l}}function Bu(n){if(n.enableRotation!==void 0?n.enableRotation:!0){const e=n.constrainRotation;return e===void 0||e===!0?Gu():e===!1?el:typeof e=="number"?zu(e):el}return yr}function Uu(n){return!(n.sourceCenter&&n.targetCenter&&!Zn(n.sourceCenter,n.targetCenter)||n.sourceResolution!==n.targetResolution||n.sourceRotation!==n.targetRotation)}function wr(n,t,e,i,s){const r=Math.cos(-s);let o=Math.sin(-s),a=n[0]*r-n[1]*o,l=n[1]*r+n[0]*o;a+=(t[0]/2-e[0])*i,l+=(e[1]-t[1]/2)*i,o=-o;const h=a*r-l*o,c=l*r+a*o;return[h,c]}const ss="ol-hidden",rs="ol-unselectable",vr="ol-control",il="ol-collapsed",Ku=new RegExp(["^\\s*(?=(?:(?:[-a-z]+\\s*){0,2}(italic|oblique))?)","(?=(?:(?:[-a-z]+\\s*){0,2}(small-caps))?)","(?=(?:(?:[-a-z]+\\s*){0,2}(bold(?:er)?|lighter|[1-9]00 ))?)","(?:(?:normal|\\1|\\2|\\3)\\s*){0,3}((?:xx?-)?","(?:small|large)|medium|smaller|larger|[\\.\\d]+(?:\\%|in|[cem]m|ex|p[ctx]))","(?:\\s*\\/\\s*(normal|[\\.\\d]+(?:\\%|in|[cem]m|ex|p[ctx])?))",`?\\s*([-,\\"\\'\\sa-z0-9]+?)\\s*$`].join(""),"i"),nl=["style","variant","weight","size","lineHeight","family"],Cr={normal:400,bold:700},Rr=function(n){const t=n.match(Ku);if(!t)return null;const e={lineHeight:"normal",size:"1.2em",style:"normal",weight:"400",variant:"normal"};for(let i=0,s=nl.length;i<s;++i){const r=t[i+1];r!==void 0&&(e[nl[i]]=typeof r=="string"?r.trim():r)}return isNaN(Number(e.weight))&&e.weight in Cr&&(e.weight=Cr[e.weight]),e.families=e.family.split(/,\s?/).map(i=>i.trim().replace(/^['"]|['"]$/g,"")),e};function gt(n,t,e,i){let s;return e&&e.length?s=e.shift():Ys?s=new OffscreenCanvas(n||300,t||300):s=document.createElement("canvas"),n&&(s.width=n),t&&(s.height=t),s.getContext("2d",i)}let Sr;function os(){return Sr||(Sr=gt(1,1)),Sr}function as(n){const t=n.canvas;t.width=1,t.height=1,n.clearRect(0,0,1,1)}function sl(n,t){const e=t.parentNode;e&&e.replaceChild(n,t)}function ju(n){for(;n.lastChild;)n.lastChild.remove()}function Vu(n,t){const e=n.childNodes;for(let i=0;;++i){const s=e[i],r=t[i];if(!s&&!r)break;if(s!==r){if(!s){n.appendChild(r);continue}if(!r){n.removeChild(s),--i;continue}n.insertBefore(r,s)}}}class Ir extends ne{constructor(t){super();const e=t.element;e&&!t.target&&!e.style.pointerEvents&&(e.style.pointerEvents="auto"),this.element=e||null,this.target_=null,this.map_=null,this.listenerKeys=[],t.render&&(this.render=t.render),t.target&&this.setTarget(t.target)}disposeInternal(){this.element?.remove(),super.disposeInternal()}getMap(){return this.map_}setMap(t){this.map_&&this.element?.remove();for(let e=0,i=this.listenerKeys.length;e<i;++e)at(this.listenerKeys[e]);if(this.listenerKeys.length=0,this.map_=t,t){const e=this.target_??t.getOverlayContainerStopEvent();this.element&&e.appendChild(this.element),this.render!==Bi&&this.listenerKeys.push($(t,Se.POSTRENDER,this.render,this)),t.render()}}render(t){}setTarget(t){this.target_=typeof t=="string"?document.getElementById(t):t}}class Zu extends Ir{constructor(t){t=t||{},super({element:document.createElement("div"),render:t.render,target:t.target}),this.ulElement_=document.createElement("ul"),this.collapsed_=t.collapsed!==void 0?t.collapsed:!0,this.userCollapsed_=this.collapsed_,this.overrideCollapsible_=t.collapsible!==void 0,this.collapsible_=t.collapsible!==void 0?t.collapsible:!0,this.collapsible_||(this.collapsed_=!1),this.attributions_=t.attributions;const e=t.className!==void 0?t.className:"ol-attribution",i=t.tipLabel!==void 0?t.tipLabel:"Attributions",s=t.expandClassName!==void 0?t.expandClassName:e+"-expand",r=t.collapseLabel!==void 0?t.collapseLabel:"›",o=t.collapseClassName!==void 0?t.collapseClassName:e+"-collapse";typeof r=="string"?(this.collapseLabel_=document.createElement("span"),this.collapseLabel_.textContent=r,this.collapseLabel_.className=o):this.collapseLabel_=r;const a=t.label!==void 0?t.label:"i";typeof a=="string"?(this.label_=document.createElement("span"),this.label_.textContent=a,this.label_.className=s):this.label_=a;const l=this.collapsible_&&!this.collapsed_?this.collapseLabel_:this.label_;this.toggleButton_=document.createElement("button"),this.toggleButton_.setAttribute("type","button"),this.toggleButton_.setAttribute("aria-expanded",String(!this.collapsed_)),this.toggleButton_.title=i,this.toggleButton_.appendChild(l),this.toggleButton_.addEventListener(B.CLICK,this.handleClick_.bind(this),!1);const h=e+" "+rs+" "+vr+(this.collapsed_&&this.collapsible_?" "+il:"")+(this.collapsible_?"":" ol-uncollapsible"),c=this.element;c.className=h,c.appendChild(this.toggleButton_),c.appendChild(this.ulElement_),this.renderedAttributions_=[],this.renderedVisible_=!0}collectSourceAttributions_(t){const e=this.getMap().getAllLayers(),i=new Set(e.flatMap(s=>s.getAttributions(t)));if(this.attributions_!==void 0&&(Array.isArray(this.attributions_)?this.attributions_.forEach(s=>i.add(s)):i.add(this.attributions_)),!this.overrideCollapsible_){const s=!e.some(r=>r.getSource()?.getAttributionsCollapsible()===!1);this.setCollapsible(s)}return Array.from(i)}async updateElement_(t){if(!t){this.renderedVisible_&&(this.element.style.display="none",this.renderedVisible_=!1);return}const e=await Promise.all(this.collectSourceAttributions_(t).map(s=>fc(()=>s))),i=e.length>0;if(this.renderedVisible_!=i&&(this.element.style.display=i?"":"none",this.renderedVisible_=i),!Ce(e,this.renderedAttributions_)){ju(this.ulElement_);for(let s=0,r=e.length;s<r;++s){const o=document.createElement("li");o.innerHTML=e[s],this.ulElement_.appendChild(o)}this.renderedAttributions_=e}}handleClick_(t){t.preventDefault(),this.handleToggle_(),this.userCollapsed_=this.collapsed_}handleToggle_(){this.element.classList.toggle(il),this.collapsed_?sl(this.collapseLabel_,this.label_):sl(this.label_,this.collapseLabel_),this.collapsed_=!this.collapsed_,this.toggleButton_.setAttribute("aria-expanded",String(!this.collapsed_))}getCollapsible(){return this.collapsible_}setCollapsible(t){this.collapsible_!==t&&(this.collapsible_=t,this.element.classList.toggle("ol-uncollapsible"),this.userCollapsed_&&this.handleToggle_())}setCollapsed(t){this.userCollapsed_=t,!(!this.collapsible_||this.collapsed_===t)&&this.handleToggle_()}getCollapsed(){return this.collapsed_}render(t){this.updateElement_(t.frameState)}}class $u extends Ir{constructor(t){t=t||{},super({element:document.createElement("div"),render:t.render,target:t.target});const e=t.className!==void 0?t.className:"ol-rotate",i=t.label!==void 0?t.label:"⇧",s=t.compassClassName!==void 0?t.compassClassName:"ol-compass";this.label_=null,typeof i=="string"?(this.label_=document.createElement("span"),this.label_.className=s,this.label_.textContent=i):(this.label_=i,this.label_.classList.add(s));const r=t.tipLabel?t.tipLabel:"Reset rotation",o=document.createElement("button");o.className=e+"-reset",o.setAttribute("type","button"),o.title=r,o.appendChild(this.label_),o.addEventListener(B.CLICK,this.handleClick_.bind(this),!1);const a=e+" "+rs+" "+vr,l=this.element;l.className=a,l.appendChild(o),this.callResetNorth_=t.resetNorth?t.resetNorth:void 0,this.duration_=t.duration!==void 0?t.duration:250,this.autoHide_=t.autoHide!==void 0?t.autoHide:!0,this.rotation_=void 0,this.autoHide_&&this.element.classList.add(ss)}handleClick_(t){t.preventDefault(),this.callResetNorth_!==void 0?this.callResetNorth_():this.resetNorth_()}resetNorth_(){const e=this.getMap().getView();if(!e)return;const i=e.getRotation();i!==void 0&&(this.duration_>0&&i%(2*Math.PI)!==0?e.animate({rotation:0,duration:this.duration_,easing:di}):e.setRotation(0))}render(t){const e=t.frameState;if(!e)return;const i=e.viewState.rotation;if(i!=this.rotation_){const s="rotate("+i+"rad)";if(this.autoHide_){const r=this.element.classList.contains(ss);!r&&i===0?this.element.classList.add(ss):r&&i!==0&&this.element.classList.remove(ss)}this.label_.style.transform=s}this.rotation_=i}}class Hu extends Ir{constructor(t){t=t||{},super({element:document.createElement("div"),target:t.target});const e=t.className!==void 0?t.className:"ol-zoom",i=t.delta!==void 0?t.delta:1,s=t.zoomInClassName!==void 0?t.zoomInClassName:e+"-in",r=t.zoomOutClassName!==void 0?t.zoomOutClassName:e+"-out",o=t.zoomInLabel!==void 0?t.zoomInLabel:"+",a=t.zoomOutLabel!==void 0?t.zoomOutLabel:"–",l=t.zoomInTipLabel!==void 0?t.zoomInTipLabel:"Zoom in",h=t.zoomOutTipLabel!==void 0?t.zoomOutTipLabel:"Zoom out",c=document.createElement("button");c.className=s,c.setAttribute("type","button"),c.title=l,c.appendChild(typeof o=="string"?document.createTextNode(o):o),c.addEventListener(B.CLICK,this.handleClick_.bind(this,i),!1);const u=document.createElement("button");u.className=r,u.setAttribute("type","button"),u.title=h,u.appendChild(typeof a=="string"?document.createTextNode(a):a),u.addEventListener(B.CLICK,this.handleClick_.bind(this,-i),!1);const d=e+" "+rs+" "+vr,f=this.element;f.className=d,f.appendChild(c),f.appendChild(u),this.duration_=t.duration!==void 0?t.duration:250}handleClick_(t,e){e.preventDefault(),this.zoomByDelta_(t)}zoomByDelta_(t){const i=this.getMap().getView();if(!i)return;const s=i.getZoom();if(s!==void 0){const r=i.getConstrainedZoom(s+t);this.duration_>0?(i.getAnimating()&&i.cancelAnimations(),i.animate({zoom:r,duration:this.duration_,easing:di})):i.setZoom(r)}}}function qu(n){n=n||{};const t=new se;return(n.zoom!==void 0?n.zoom:!0)&&t.push(new Hu(n.zoomOptions)),(n.rotate!==void 0?n.rotate:!0)&&t.push(new $u(n.rotateOptions)),(n.attribution!==void 0?n.attribution:!0)&&t.push(new Zu(n.attributionOptions)),t}class Ju{constructor(t,e,i){this.decay_=t,this.minVelocity_=e,this.delay_=i,this.points_=[],this.angle_=0,this.initialVelocity_=0}begin(){this.points_.length=0,this.angle_=0,this.initialVelocity_=0}update(t,e){this.points_.push(t,e,Date.now())}end(){if(this.points_.length<6)return!1;const t=Date.now()-this.delay_,e=this.points_.length-3;if(this.points_[e+2]<t)return!1;let i=e-3;for(;i>0&&this.points_[i+2]>t;)i-=3;const s=this.points_[e+2]-this.points_[i+2];if(s<1e3/60)return!1;const r=this.points_[e]-this.points_[i],o=this.points_[e+1]-this.points_[i+1];return this.angle_=Math.atan2(o,r),this.initialVelocity_=Math.sqrt(r*r+o*o)/s,this.initialVelocity_>this.minVelocity_}getDistance(){return(this.minVelocity_-this.initialVelocity_)/this.decay_}getAngle(){return this.angle_}}const rl={ACTIVE:"active"};class Qi extends ne{constructor(t){super(),this.on,this.once,this.un,t&&t.handleEvent&&(this.handleEvent=t.handleEvent),this.map_=null,this.setActive(!0)}getActive(){return this.get(rl.ACTIVE)}getMap(){return this.map_}handleEvent(t){return!0}setActive(t){this.set(rl.ACTIVE,t)}setMap(t){this.map_=t}}function Qu(n,t,e){const i=n.getCenterInternal();if(i){const s=[i[0]+t[0],i[1]+t[1]];n.animateInternal({duration:e!==void 0?e:250,easing:Dc,center:n.getConstrainedCenter(s)})}}function Tr(n,t,e,i){const s=n.getZoom();if(s===void 0)return;const r=n.getConstrainedZoom(s+t),o=n.getResolutionForZoom(r);n.getAnimating()&&n.cancelAnimations(),n.animate({resolution:o,anchor:e,duration:i!==void 0?i:250,easing:di})}class td extends Qi{constructor(t){super(),t=t||{},this.delta_=t.delta?t.delta:1,this.duration_=t.duration!==void 0?t.duration:250}handleEvent(t){let e=!1;if(t.type==ct.DBLCLICK){const i=t.originalEvent,s=t.map,r=t.coordinate,o=i.shiftKey?-this.delta_:this.delta_,a=s.getView();Tr(a,o,r,this.duration_),i.preventDefault(),e=!0}return!e}}function br(n){const t=arguments;return function(e){let i=!0;for(let s=0,r=t.length;s<r&&(i=i&&t[s](e),!!i);++s);return i}}const ed=function(n){const t=n.originalEvent;return t.altKey&&!(t.metaKey||t.ctrlKey)&&t.shiftKey},id=function(n){const t=n.map.getTargetElement(),e=t.getRootNode(),i=n.map.getOwnerDocument().activeElement;return e instanceof ShadowRoot?e.host.contains(i):t.contains(i)},ol=function(n){const t=n.map.getTargetElement(),e=t.getRootNode();return(e instanceof ShadowRoot?e.host:t).hasAttribute("tabindex")?id(n):!0},nd=Yi,al=function(n){const t=n.originalEvent;return"pointerId"in t&&t.button==0&&!(mc&&ia&&t.ctrlKey)},ll=function(n){const t=n.originalEvent;return!t.altKey&&!(t.metaKey||t.ctrlKey)&&!t.shiftKey},sd=function(n){const t=n.originalEvent;return ia?t.metaKey:t.ctrlKey},rd=function(n){const t=n.originalEvent;return!t.altKey&&!(t.metaKey||t.ctrlKey)&&t.shiftKey},hl=function(n){const t=n.originalEvent,e=t.target.tagName;return e!=="INPUT"&&e!=="SELECT"&&e!=="TEXTAREA"&&!t.target.isContentEditable},Mr=function(n){const t=n.originalEvent;return"pointerId"in t&&t.pointerType=="mouse"},od=function(n){const t=n.originalEvent;return"pointerId"in t&&t.isPrimary&&t.button===0};class tn extends Qi{constructor(t){t=t||{},super(t),t.handleDownEvent&&(this.handleDownEvent=t.handleDownEvent),t.handleDragEvent&&(this.handleDragEvent=t.handleDragEvent),t.handleMoveEvent&&(this.handleMoveEvent=t.handleMoveEvent),t.handleUpEvent&&(this.handleUpEvent=t.handleUpEvent),t.stopDown&&(this.stopDown=t.stopDown),this.handlingDownUpSequence=!1,this.targetPointers=[]}getPointerCount(){return this.targetPointers.length}handleDownEvent(t){return!1}handleDragEvent(t){}handleEvent(t){if(!t.originalEvent)return!0;let e=!1;if(this.updateTrackedPointers_(t),this.handlingDownUpSequence){if(t.type==ct.POINTERDRAG)this.handleDragEvent(t),t.originalEvent.preventDefault();else if(t.type==ct.POINTERUP){const i=this.handleUpEvent(t);this.handlingDownUpSequence=i&&this.targetPointers.length>0}}else if(t.type==ct.POINTERDOWN){const i=this.handleDownEvent(t);this.handlingDownUpSequence=i,e=this.stopDown(i)}else t.type==ct.POINTERMOVE&&this.handleMoveEvent(t);return!e}handleMoveEvent(t){}handleUpEvent(t){return!1}stopDown(t){return t}updateTrackedPointers_(t){t.activePointers&&(this.targetPointers=t.activePointers)}}function Lr(n){const t=n.length;let e=0,i=0;for(let s=0;s<t;s++)e+=n[s].clientX,i+=n[s].clientY;return{clientX:e/t,clientY:i/t}}class ad extends tn{constructor(t){super({stopDown:kn}),t=t||{},this.kinetic_=t.kinetic,this.lastCentroid=null,this.lastPointersCount_,this.panning_=!1;const e=t.condition?t.condition:br(ll,od);this.condition_=t.onFocusOnly?br(ol,e):e,this.noKinetic_=!1}handleDragEvent(t){const e=t.map;this.panning_||(this.panning_=!0,e.getView().beginInteraction());const i=this.targetPointers,s=e.getEventPixel(Lr(i));if(i.length==this.lastPointersCount_){if(this.kinetic_&&this.kinetic_.update(s[0],s[1]),this.lastCentroid){const r=[this.lastCentroid[0]-s[0],s[1]-this.lastCentroid[1]],a=t.map.getView();Ac(r,a.getResolution()),Hs(r,a.getRotation()),a.adjustCenterInternal(r)}}else this.kinetic_&&this.kinetic_.begin();this.lastCentroid=s,this.lastPointersCount_=i.length,t.originalEvent.preventDefault()}handleUpEvent(t){const e=t.map,i=e.getView();if(this.targetPointers.length===0){if(!this.noKinetic_&&this.kinetic_&&this.kinetic_.end()){const s=this.kinetic_.getDistance(),r=this.kinetic_.getAngle(),o=i.getCenterInternal(),a=e.getPixelFromCoordinateInternal(o),l=e.getCoordinateFromPixelInternal([a[0]-s*Math.cos(r),a[1]-s*Math.sin(r)]);i.animateInternal({center:i.getConstrainedCenter(l),duration:500,easing:di})}return this.panning_&&(this.panning_=!1,i.endInteraction()),!1}return this.kinetic_&&this.kinetic_.begin(),this.lastCentroid=null,!0}handleDownEvent(t){if(this.targetPointers.length>0&&this.condition_(t)){const i=t.map.getView();return this.lastCentroid=null,i.getAnimating()&&i.cancelAnimations(),this.kinetic_&&this.kinetic_.begin(),this.noKinetic_=this.targetPointers.length>1,!0}return!1}}class ld extends tn{constructor(t){t=t||{},super({stopDown:kn}),this.condition_=t.condition?t.condition:ed,this.lastAngle_=void 0,this.duration_=t.duration!==void 0?t.duration:250}handleDragEvent(t){if(!Mr(t))return;const e=t.map,i=e.getView();if(i.getConstraints().rotation===yr)return;const s=e.getSize(),r=t.pixel,o=Math.atan2(s[1]/2-r[1],r[0]-s[0]/2);if(this.lastAngle_!==void 0){const a=o-this.lastAngle_;i.adjustRotationInternal(-a)}this.lastAngle_=o}handleUpEvent(t){return Mr(t)?(t.map.getView().endInteraction(this.duration_),!1):!0}handleDownEvent(t){return Mr(t)&&al(t)&&this.condition_(t)?(t.map.getView().beginInteraction(),this.lastAngle_=void 0,!0):!1}}class hd extends Dn{constructor(t){super(),this.geometry_=null,this.element_=document.createElement("div"),this.element_.style.position="absolute",this.element_.style.pointerEvents="auto",this.element_.className="ol-box "+t,this.map_=null,this.startPixel_=null,this.endPixel_=null}disposeInternal(){this.setMap(null)}render_(){const t=this.startPixel_,e=this.endPixel_,i="px",s=this.element_.style;s.left=Math.min(t[0],e[0])+i,s.top=Math.min(t[1],e[1])+i,s.width=Math.abs(e[0]-t[0])+i,s.height=Math.abs(e[1]-t[1])+i}setMap(t){if(this.map_){this.map_.getOverlayContainer().removeChild(this.element_);const e=this.element_.style;e.left="inherit",e.top="inherit",e.width="inherit",e.height="inherit"}this.map_=t,this.map_&&this.map_.getOverlayContainer().appendChild(this.element_)}setPixels(t,e){this.startPixel_=t,this.endPixel_=e,this.createOrUpdateGeometry(),this.render_()}createOrUpdateGeometry(){if(!this.map_)return;const t=this.startPixel_,e=this.endPixel_,s=[t,[t[0],e[1]],e,[e[0],t[1]]].map(this.map_.getCoordinateFromPixelInternal,this.map_);s[4]=s[0].slice(),this.geometry_?this.geometry_.setCoordinates([s]):this.geometry_=new Ji([s])}getGeometry(){return this.geometry_}}const yi={BOXSTART:"boxstart",BOXDRAG:"boxdrag",BOXEND:"boxend",BOXCANCEL:"boxcancel"};class en extends ue{constructor(t,e,i){super(t),this.coordinate=e,this.mapBrowserEvent=i}}class cd extends tn{constructor(t){super(),this.on,this.once,this.un,t=t??{},this.box_=new hd(t.className||"ol-dragbox"),this.minArea_=t.minArea??64,t.onBoxEnd&&(this.onBoxEnd=t.onBoxEnd),this.startPixel_=null,this.condition_=t.condition??al,this.boxEndCondition_=t.boxEndCondition??this.defaultBoxEndCondition}defaultBoxEndCondition(t,e,i){const s=i[0]-e[0],r=i[1]-e[1];return s*s+r*r>=this.minArea_}getGeometry(){return this.box_.getGeometry()}handleDragEvent(t){this.startPixel_&&(this.box_.setPixels(this.startPixel_,t.pixel),this.dispatchEvent(new en(yi.BOXDRAG,t.coordinate,t)))}handleUpEvent(t){if(!this.startPixel_)return!1;const e=this.boxEndCondition_(t,this.startPixel_,t.pixel);return e&&this.onBoxEnd(t),this.dispatchEvent(new en(e?yi.BOXEND:yi.BOXCANCEL,t.coordinate,t)),this.box_.setMap(null),this.startPixel_=null,!1}handleDownEvent(t){return this.condition_(t)?(this.startPixel_=t.pixel,this.box_.setMap(t.map),this.box_.setPixels(this.startPixel_,this.startPixel_),this.dispatchEvent(new en(yi.BOXSTART,t.coordinate,t)),!0):!1}onBoxEnd(t){}setActive(t){t||(this.box_.setMap(null),this.startPixel_&&(this.dispatchEvent(new en(yi.BOXCANCEL,this.startPixel_,null)),this.startPixel_=null)),super.setActive(t)}setMap(t){this.getMap()&&(this.box_.setMap(null),this.startPixel_&&(this.dispatchEvent(new en(yi.BOXCANCEL,this.startPixel_,null)),this.startPixel_=null)),super.setMap(t)}}class ud extends cd{constructor(t){t=t||{};const e=t.condition?t.condition:rd;super({condition:e,className:t.className||"ol-dragzoom",minArea:t.minArea}),this.duration_=t.duration!==void 0?t.duration:200,this.out_=t.out!==void 0?t.out:!1}onBoxEnd(t){const i=this.getMap().getView();let s=this.getGeometry();if(this.out_){const r=i.rotatedExtentForGeometry(s),o=i.getResolutionForExtentInternal(r),a=i.getResolution()/o;s=s.clone(),s.scale(a*a)}i.fitInternal(s,{duration:this.duration_,easing:di})}}const He={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",DOWN:"ArrowDown"};class dd extends Qi{constructor(t){super(),t=t||{},this.defaultCondition_=function(e){return ll(e)&&hl(e)},this.condition_=t.condition!==void 0?t.condition:this.defaultCondition_,this.duration_=t.duration!==void 0?t.duration:100,this.pixelDelta_=t.pixelDelta!==void 0?t.pixelDelta:128}handleEvent(t){let e=!1;if(t.type==B.KEYDOWN){const i=t.originalEvent,s=i.key;if(this.condition_(t)&&(s==He.DOWN||s==He.LEFT||s==He.RIGHT||s==He.UP)){const o=t.map.getView(),a=o.getResolution()*this.pixelDelta_;let l=0,h=0;s==He.DOWN?h=-a:s==He.LEFT?l=-a:s==He.RIGHT?l=a:h=a;const c=[l,h];Hs(c,o.getRotation()),Qu(o,c,this.duration_),i.preventDefault(),e=!0}}return!e}}class fd extends Qi{constructor(t){super(),t=t||{},this.condition_=t.condition?t.condition:function(e){return!sd(e)&&hl(e)},this.delta_=t.delta?t.delta:1,this.duration_=t.duration!==void 0?t.duration:100}handleEvent(t){let e=!1;if(t.type==B.KEYDOWN||t.type==B.KEYPRESS){const i=t.originalEvent,s=i.key;if(this.condition_(t)&&(s==="+"||s==="-")){const r=t.map,o=s==="+"?this.delta_:-this.delta_,a=r.getView();Tr(a,o,void 0,this.duration_),i.preventDefault(),e=!0}}return!e}}const gd=40,_d=300;class md extends Qi{constructor(t){t=t||{},super(t),this.totalDelta_=0,this.lastDelta_=0,this.maxDelta_=t.maxDelta!==void 0?t.maxDelta:1,this.duration_=t.duration!==void 0?t.duration:250,this.timeout_=t.timeout!==void 0?t.timeout:80,this.useAnchor_=t.useAnchor!==void 0?t.useAnchor:!0,this.constrainResolution_=t.constrainResolution!==void 0?t.constrainResolution:!1;const e=t.condition?t.condition:nd;this.condition_=t.onFocusOnly?br(ol,e):e,this.lastAnchor_=null,this.startTime_=void 0,this.timeoutId_,this.mode_=void 0,this.trackpadEventGap_=400,this.trackpadTimeoutId_,this.deltaPerZoom_=300}endInteraction_(){this.trackpadTimeoutId_=void 0;const t=this.getMap();if(!t)return;t.getView().endInteraction(void 0,this.lastDelta_?this.lastDelta_>0?1:-1:0,this.lastAnchor_?t.getCoordinateFromPixel(this.lastAnchor_):null)}handleEvent(t){if(!this.condition_(t)||t.type!==B.WHEEL)return!0;const i=t.map,s=t.originalEvent;s.preventDefault(),this.useAnchor_&&(this.lastAnchor_=t.pixel);let r=s.deltaY;switch(s.deltaMode){case WheelEvent.DOM_DELTA_LINE:r*=gd;break;case WheelEvent.DOM_DELTA_PAGE:r*=_d;break}if(r===0)return!1;this.lastDelta_=r;const o=Date.now();this.startTime_===void 0&&(this.startTime_=o),(!this.mode_||o-this.startTime_>this.trackpadEventGap_)&&(this.mode_=Math.abs(r)<4?"trackpad":"wheel");const a=i.getView();if(this.mode_==="trackpad"&&!(a.getConstrainResolution()||this.constrainResolution_))return this.trackpadTimeoutId_?clearTimeout(this.trackpadTimeoutId_):(a.getAnimating()&&a.cancelAnimations(),a.beginInteraction()),this.trackpadTimeoutId_=setTimeout(this.endInteraction_.bind(this),this.timeout_),a.adjustZoom(-r/this.deltaPerZoom_,this.lastAnchor_?i.getCoordinateFromPixel(this.lastAnchor_):null),this.startTime_=o,!1;this.totalDelta_+=r;const l=Math.max(this.timeout_-(o-this.startTime_),0);return clearTimeout(this.timeoutId_),this.timeoutId_=setTimeout(this.handleWheelZoom_.bind(this,i),l),!1}handleWheelZoom_(t){const e=t.getView();e.getAnimating()&&e.cancelAnimations();let i=-lt(this.totalDelta_,-this.maxDelta_*this.deltaPerZoom_,this.maxDelta_*this.deltaPerZoom_)/this.deltaPerZoom_;(e.getConstrainResolution()||this.constrainResolution_)&&(i=i?i>0?1:-1:0),Tr(e,i,this.lastAnchor_?t.getCoordinateFromPixel(this.lastAnchor_):null,this.duration_),this.mode_=void 0,this.totalDelta_=0,this.lastAnchor_=null,this.startTime_=void 0,this.timeoutId_=void 0}setMouseAnchor(t){this.useAnchor_=t,t||(this.lastAnchor_=null)}}class pd extends tn{constructor(t){t=t||{};const e=t;e.stopDown||(e.stopDown=kn),super(e),this.anchor_=null,this.lastAngle_=void 0,this.rotating_=!1,this.rotationDelta_=0,this.threshold_=t.threshold!==void 0?t.threshold:.3,this.duration_=t.duration!==void 0?t.duration:250}handleDragEvent(t){let e=0;const i=this.targetPointers[0],s=this.targetPointers[1],r=Math.atan2(s.clientY-i.clientY,s.clientX-i.clientX);if(this.lastAngle_!==void 0){const l=r-this.lastAngle_;this.rotationDelta_+=l,!this.rotating_&&Math.abs(this.rotationDelta_)>this.threshold_&&(this.rotating_=!0),e=l}this.lastAngle_=r;const o=t.map,a=o.getView();a.getConstraints().rotation!==yr&&(this.anchor_=o.getCoordinateFromPixelInternal(o.getEventPixel(Lr(this.targetPointers))),this.rotating_&&(o.render(),a.adjustRotationInternal(e,this.anchor_)))}handleUpEvent(t){return this.targetPointers.length<2?(t.map.getView().endInteraction(this.duration_),!1):!0}handleDownEvent(t){if(this.targetPointers.length>=2){const e=t.map;return this.anchor_=null,this.lastAngle_=void 0,this.rotating_=!1,this.rotationDelta_=0,this.handlingDownUpSequence||e.getView().beginInteraction(),!0}return!1}}class yd extends tn{constructor(t){t=t||{};const e=t;e.stopDown||(e.stopDown=kn),super(e),this.anchor_=null,this.duration_=t.duration!==void 0?t.duration:400,this.lastDistance_=void 0,this.lastScaleDelta_=1}handleDragEvent(t){let e=1;const i=this.targetPointers[0],s=this.targetPointers[1],r=i.clientX-s.clientX,o=i.clientY-s.clientY,a=Math.sqrt(r*r+o*o);this.lastDistance_!==void 0&&(e=this.lastDistance_/a),this.lastDistance_=a;const l=t.map,h=l.getView();e!=1&&(this.lastScaleDelta_=e),this.anchor_=l.getCoordinateFromPixelInternal(l.getEventPixel(Lr(this.targetPointers))),l.render(),h.adjustResolutionInternal(e,this.anchor_)}handleUpEvent(t){if(this.targetPointers.length<2){const i=t.map.getView(),s=this.lastScaleDelta_>1?1:-1;return i.endInteraction(this.duration_,s),!1}return!0}handleDownEvent(t){if(this.targetPointers.length>=2){const e=t.map;return this.anchor_=null,this.lastDistance_=void 0,this.lastScaleDelta_=1,this.handlingDownUpSequence||e.getView().beginInteraction(),!0}return!1}}function xd(n){n=n||{};const t=new se,e=new Ju(-.005,.05,100);return(n.altShiftDragRotate!==void 0?n.altShiftDragRotate:!0)&&t.push(new ld),(n.doubleClickZoom!==void 0?n.doubleClickZoom:!0)&&t.push(new td({delta:n.zoomDelta,duration:n.zoomDuration})),(n.dragPan!==void 0?n.dragPan:!0)&&t.push(new ad({onFocusOnly:n.onFocusOnly,kinetic:e})),(n.pinchRotate!==void 0?n.pinchRotate:!0)&&t.push(new pd),(n.pinchZoom!==void 0?n.pinchZoom:!0)&&t.push(new yd({duration:n.zoomDuration})),(n.keyboard!==void 0?n.keyboard:!0)&&(t.push(new dd),t.push(new fd({delta:n.zoomDelta,duration:n.zoomDuration}))),(n.mouseWheelZoom!==void 0?n.mouseWheelZoom:!0)&&t.push(new md({onFocusOnly:n.onFocusOnly,duration:n.zoomDuration})),(n.shiftDragZoom!==void 0?n.shiftDragZoom:!0)&&t.push(new ud({duration:n.zoomDuration})),t}const it={OPACITY:"opacity",VISIBLE:"visible",EXTENT:"extent",Z_INDEX:"zIndex",MAX_RESOLUTION:"maxResolution",MIN_RESOLUTION:"minResolution",MAX_ZOOM:"maxZoom",MIN_ZOOM:"minZoom",SOURCE:"source",MAP:"map"};class cl extends ne{constructor(t){super(),this.on,this.once,this.un,this.background_=t.background;const e=Object.assign({},t);typeof t.properties=="object"&&(delete e.properties,Object.assign(e,t.properties)),e[it.OPACITY]=t.opacity!==void 0?t.opacity:1,Q(typeof e[it.OPACITY]=="number","Layer opacity must be a number"),e[it.VISIBLE]=t.visible!==void 0?t.visible:!0,e[it.Z_INDEX]=t.zIndex,e[it.MAX_RESOLUTION]=t.maxResolution!==void 0?t.maxResolution:1/0,e[it.MIN_RESOLUTION]=t.minResolution!==void 0?t.minResolution:0,e[it.MIN_ZOOM]=t.minZoom!==void 0?t.minZoom:-1/0,e[it.MAX_ZOOM]=t.maxZoom!==void 0?t.maxZoom:1/0,this.className_=e.className!==void 0?e.className:"ol-layer",delete e.className,this.setProperties(e),this.state_=null}getBackground(){return this.background_}getClassName(){return this.className_}getLayerState(t){const e=this.state_||{layer:this,managed:t===void 0?!0:t},i=this.getZIndex();return e.opacity=lt(Math.round(this.getOpacity()*100)/100,0,1),e.visible=this.getVisible(),e.extent=this.getExtent(),e.zIndex=i===void 0&&!e.managed?1/0:i,e.maxResolution=this.getMaxResolution(),e.minResolution=Math.max(this.getMinResolution(),0),e.minZoom=this.getMinZoom(),e.maxZoom=this.getMaxZoom(),this.state_=e,e}getLayersArray(t){return H()}getLayerStatesArray(t){return H()}getExtent(){return this.get(it.EXTENT)}getMaxResolution(){return this.get(it.MAX_RESOLUTION)}getMinResolution(){return this.get(it.MIN_RESOLUTION)}getMinZoom(){return this.get(it.MIN_ZOOM)}getMaxZoom(){return this.get(it.MAX_ZOOM)}getOpacity(){return this.get(it.OPACITY)}getSourceState(){return H()}getVisible(){return this.get(it.VISIBLE)}getZIndex(){return this.get(it.Z_INDEX)}setBackground(t){this.background_=t,this.changed()}setExtent(t){this.set(it.EXTENT,t)}setMaxResolution(t){this.set(it.MAX_RESOLUTION,t)}setMinResolution(t){this.set(it.MIN_RESOLUTION,t)}setMaxZoom(t){this.set(it.MAX_ZOOM,t)}setMinZoom(t){this.set(it.MIN_ZOOM,t)}setOpacity(t){Q(typeof t=="number","Layer opacity must be a number"),this.set(it.OPACITY,t)}setVisible(t){this.set(it.VISIBLE,t)}setZIndex(t){this.set(it.Z_INDEX,t)}disposeInternal(){this.state_&&(this.state_.layer=null,this.state_=null),super.disposeInternal()}}class Le extends ue{constructor(t,e){super(t),this.layer=e}}const Ar={LAYERS:"layers"};class xi extends cl{constructor(t){t=t||{};const e=Object.assign({},t);delete e.layers;let i=t.layers;super(e),this.on,this.once,this.un,this.layersListenerKeys_=[],this.listenerKeys_={},this.addChangeListener(Ar.LAYERS,this.handleLayersChanged_),i?Array.isArray(i)?i=new se(i.slice(),{unique:!0}):Q(typeof i.getArray=="function","Expected `layers` to be an array or a `Collection`"):i=new se(void 0,{unique:!0}),this.setLayers(i)}handleLayerChange_(){this.changed()}handleLayersChanged_(){this.layersListenerKeys_.forEach(at),this.layersListenerKeys_.length=0;const t=this.getLayers();this.layersListenerKeys_.push($(t,Ot.ADD,this.handleLayersAdd_,this),$(t,Ot.REMOVE,this.handleLayersRemove_,this));for(const i in this.listenerKeys_)this.listenerKeys_[i].forEach(at);Ui(this.listenerKeys_);const e=t.getArray();for(let i=0,s=e.length;i<s;i++){const r=e[i];this.registerLayerListeners_(r),this.dispatchEvent(new Le("addlayer",r))}this.changed()}registerLayerListeners_(t){const e=[$(t,oi.PROPERTYCHANGE,this.handleLayerChange_,this),$(t,B.CHANGE,this.handleLayerChange_,this)];t instanceof xi&&e.push($(t,"addlayer",this.handleLayerGroupAdd_,this),$(t,"removelayer",this.handleLayerGroupRemove_,this)),this.listenerKeys_[q(t)]=e}handleLayerGroupAdd_(t){this.dispatchEvent(new Le("addlayer",t.layer))}handleLayerGroupRemove_(t){this.dispatchEvent(new Le("removelayer",t.layer))}handleLayersAdd_(t){const e=t.element;this.registerLayerListeners_(e),this.dispatchEvent(new Le("addlayer",e)),this.changed()}handleLayersRemove_(t){const e=t.element,i=q(e);this.listenerKeys_[i].forEach(at),delete this.listenerKeys_[i],this.dispatchEvent(new Le("removelayer",e)),this.changed()}getLayers(){return this.get(Ar.LAYERS)}setLayers(t){const e=this.getLayers();if(e){const i=e.getArray();for(let s=0,r=i.length;s<r;++s)this.dispatchEvent(new Le("removelayer",i[s]))}this.set(Ar.LAYERS,t)}getLayersArray(t){return t=t!==void 0?t:[],this.getLayers().forEach(function(e){e.getLayersArray(t)}),t}getLayerStatesArray(t){const e=t!==void 0?t:[],i=e.length;this.getLayers().forEach(function(o){o.getLayerStatesArray(e)});const s=this.getLayerState();let r=s.zIndex;!t&&s.zIndex===void 0&&(r=0);for(let o=i,a=e.length;o<a;o++){const l=e[o];l.opacity*=s.opacity,l.visible=l.visible&&s.visible,l.maxResolution=Math.min(l.maxResolution,s.maxResolution),l.minResolution=Math.max(l.minResolution,s.minResolution),l.minZoom=Math.max(l.minZoom,s.minZoom),l.maxZoom=Math.min(l.maxZoom,s.maxZoom),s.extent!==void 0&&(l.extent!==void 0?l.extent=Ue(l.extent,s.extent):l.extent=s.extent),l.zIndex===void 0&&(l.zIndex=r)}return e}getSourceState(){return"ready"}}const Bt={PRERENDER:"prerender",POSTRENDER:"postrender",PRECOMPOSE:"precompose",POSTCOMPOSE:"postcompose",RENDERCOMPLETE:"rendercomplete"};class ls extends cl{constructor(t){const e=Object.assign({},t);delete e.source,super(e),this.on,this.once,this.un,this.mapPrecomposeKey_=null,this.mapRenderKey_=null,this.sourceChangeKey_=null,this.renderer_=null,this.sourceReady_=!1,this.rendered=!1,t.render&&(this.render=t.render),t.map&&this.setMap(t.map),this.addChangeListener(it.SOURCE,this.handleSourcePropertyChange_);const i=t.source?t.source:null;this.setSource(i)}getLayersArray(t){return t=t||[],t.push(this),t}getLayerStatesArray(t){return t=t||[],t.push(this.getLayerState()),t}getSource(){return this.get(it.SOURCE)||null}getRenderSource(){return this.getSource()}getSourceState(){const t=this.getSource();return t?t.getState():"undefined"}handleSourceChange_(){this.changed(),!(this.sourceReady_||this.getSource().getState()!=="ready")&&(this.sourceReady_=!0,this.dispatchEvent("sourceready"))}handleSourcePropertyChange_(){this.sourceChangeKey_&&(at(this.sourceChangeKey_),this.sourceChangeKey_=null),this.sourceReady_=!1;const t=this.getSource();t&&(this.sourceChangeKey_=$(t,B.CHANGE,this.handleSourceChange_,this),t.getState()==="ready"&&(this.sourceReady_=!0,setTimeout(()=>{this.dispatchEvent("sourceready")},0))),this.changed()}getFeatures(t){return this.renderer_?this.renderer_.getFeatures(t):Promise.resolve([])}getData(t){return!this.renderer_||!this.rendered?null:this.renderer_.getData(t)}isVisible(t){let e;const i=this.getMapInternal();!t&&i&&(t=i.getView()),t instanceof re?e={viewState:t.getState(),extent:t.calculateExtent()}:e=t,!e.layerStatesArray&&i&&(e.layerStatesArray=i.getLayerGroup().getLayerStatesArray());let s;if(e.layerStatesArray){if(s=e.layerStatesArray.find(o=>o.layer===this),!s)return!1}else s=this.getLayerState();const r=this.getExtent();return Or(s,e.viewState)&&(!r||Pt(r,e.extent))}getAttributions(t){if(!this.isVisible(t))return[];const e=this.getSource()?.getAttributions();if(!e)return[];const i=t instanceof re?t.getViewStateAndExtent():t;let s=e(i);return Array.isArray(s)||(s=[s]),s}render(t,e){const i=this.getRenderer();return i.prepareFrame(t)?(this.rendered=!0,i.renderFrame(t,e)):null}unrender(){this.rendered=!1}getDeclutter(){}renderDeclutter(t,e){}renderDeferred(t){const e=this.getRenderer();e&&e.renderDeferred(t)}setMapInternal(t){t||this.unrender(),this.set(it.MAP,t)}getMapInternal(){return this.get(it.MAP)}setMap(t){this.mapPrecomposeKey_&&(at(this.mapPrecomposeKey_),this.mapPrecomposeKey_=null),t||this.changed(),this.mapRenderKey_&&(at(this.mapRenderKey_),this.mapRenderKey_=null),t&&(this.mapPrecomposeKey_=$(t,Bt.PRECOMPOSE,this.handlePrecompose_,this),this.mapRenderKey_=$(this,B.CHANGE,t.render,t),this.changed())}handlePrecompose_(t){const e=t.frameState.layerStatesArray,i=this.getLayerState(!1);Q(!e.some(s=>s.layer===i.layer),"A layer can only be added to the map once. Use either `layer.setMap()` or `map.addLayer()`, not both."),e.push(i)}setSource(t){this.set(it.SOURCE,t)}getRenderer(){return this.renderer_||(this.renderer_=this.createRenderer()),this.renderer_}hasRenderer(){return!!this.renderer_}createRenderer(){return null}clearRenderer(){this.renderer_&&(this.renderer_.dispose(),delete this.renderer_)}disposeInternal(){this.clearRenderer(),this.setSource(null),super.disposeInternal()}}function Or(n,t){if(!n.visible)return!1;const e=t.resolution;if(e<n.minResolution||e>=n.maxResolution)return!1;const i=t.zoom;return i>n.minZoom&&i<=n.maxZoom}function ul(n,t,e=0,i=n.length-1,s=Ed){for(;i>e;){if(i-e>600){const l=i-e+1,h=t-e+1,c=Math.log(l),u=.5*Math.exp(2*c/3),d=.5*Math.sqrt(c*u*(l-u)/l)*(h-l/2<0?-1:1),f=Math.max(e,Math.floor(t-h*u/l+d)),g=Math.min(i,Math.floor(t+(l-h)*u/l+d));ul(n,t,f,g,s)}const r=n[t];let o=e,a=i;for(nn(n,e,t),s(n[i],r)>0&&nn(n,e,i);o<a;){for(nn(n,o,a),o++,a--;s(n[o],r)<0;)o++;for(;s(n[a],r)>0;)a--}s(n[e],r)===0?nn(n,e,a):(a++,nn(n,a,i)),a<=t&&(e=a+1),t<=a&&(i=a-1)}}function nn(n,t,e){const i=n[t];n[t]=n[e],n[e]=i}function Ed(n,t){return n<t?-1:n>t?1:0}let dl=class{constructor(t=9){this._maxEntries=Math.max(4,t),this._minEntries=Math.max(2,Math.ceil(this._maxEntries*.4)),this.clear()}all(){return this._all(this.data,[])}search(t){let e=this.data;const i=[];if(!cs(t,e))return i;const s=this.toBBox,r=[];for(;e;){for(let o=0;o<e.children.length;o++){const a=e.children[o],l=e.leaf?s(a):a;cs(t,l)&&(e.leaf?i.push(a):Dr(t,l)?this._all(a,i):r.push(a))}e=r.pop()}return i}collides(t){let e=this.data;if(!cs(t,e))return!1;const i=[];for(;e;){for(let s=0;s<e.children.length;s++){const r=e.children[s],o=e.leaf?this.toBBox(r):r;if(cs(t,o)){if(e.leaf||Dr(t,o))return!0;i.push(r)}}e=i.pop()}return!1}load(t){if(!(t&&t.length))return this;if(t.length<this._minEntries){for(let i=0;i<t.length;i++)this.insert(t[i]);return this}let e=this._build(t.slice(),0,t.length-1,0);if(!this.data.children.length)this.data=e;else if(this.data.height===e.height)this._splitRoot(this.data,e);else{if(this.data.height<e.height){const i=this.data;this.data=e,e=i}this._insert(e,this.data.height-e.height-1,!0)}return this}insert(t){return t&&this._insert(t,this.data.height-1),this}clear(){return this.data=wi([]),this}remove(t,e){if(!t)return this;let i=this.data;const s=this.toBBox(t),r=[],o=[];let a,l,h;for(;i||r.length;){if(i||(i=r.pop(),l=r[r.length-1],a=o.pop(),h=!0),i.leaf){const c=wd(t,i.children,e);if(c!==-1)return i.children.splice(c,1),r.push(i),this._condense(r),this}!h&&!i.leaf&&Dr(i,s)?(r.push(i),o.push(a),a=0,l=i,i=i.children[0]):l?(a++,i=l.children[a],h=!1):i=null}return this}toBBox(t){return t}compareMinX(t,e){return t.minX-e.minX}compareMinY(t,e){return t.minY-e.minY}toJSON(){return this.data}fromJSON(t){return this.data=t,this}_all(t,e){const i=[];for(;t;)t.leaf?e.push(...t.children):i.push(...t.children),t=i.pop();return e}_build(t,e,i,s){const r=i-e+1;let o=this._maxEntries,a;if(r<=o)return a=wi(t.slice(e,i+1)),Ei(a,this.toBBox),a;s||(s=Math.ceil(Math.log(r)/Math.log(o)),o=Math.ceil(r/Math.pow(o,s-1))),a=wi([]),a.leaf=!1,a.height=s;const l=Math.ceil(r/o),h=l*Math.ceil(Math.sqrt(o));fl(t,e,i,h,this.compareMinX);for(let c=e;c<=i;c+=h){const u=Math.min(c+h-1,i);fl(t,c,u,l,this.compareMinY);for(let d=c;d<=u;d+=l){const f=Math.min(d+l-1,u);a.children.push(this._build(t,d,f,s-1))}}return Ei(a,this.toBBox),a}_chooseSubtree(t,e,i,s){for(;s.push(e),!(e.leaf||s.length-1===i);){let r=1/0,o=1/0,a;for(let l=0;l<e.children.length;l++){const h=e.children[l],c=Pr(h),u=Rd(t,h)-c;u<o?(o=u,r=c<r?c:r,a=h):u===o&&c<r&&(r=c,a=h)}e=a||e.children[0]}return e}_insert(t,e,i){const s=i?t:this.toBBox(t),r=[],o=this._chooseSubtree(s,this.data,e,r);for(o.children.push(t),rn(o,s);e>=0&&r[e].children.length>this._maxEntries;)this._split(r,e),e--;this._adjustParentBBoxes(s,r,e)}_split(t,e){const i=t[e],s=i.children.length,r=this._minEntries;this._chooseSplitAxis(i,r,s);const o=this._chooseSplitIndex(i,r,s),a=wi(i.children.splice(o,i.children.length-o));a.height=i.height,a.leaf=i.leaf,Ei(i,this.toBBox),Ei(a,this.toBBox),e?t[e-1].children.push(a):this._splitRoot(i,a)}_splitRoot(t,e){this.data=wi([t,e]),this.data.height=t.height+1,this.data.leaf=!1,Ei(this.data,this.toBBox)}_chooseSplitIndex(t,e,i){let s,r=1/0,o=1/0;for(let a=e;a<=i-e;a++){const l=sn(t,0,a,this.toBBox),h=sn(t,a,i,this.toBBox),c=Sd(l,h),u=Pr(l)+Pr(h);c<r?(r=c,s=a,o=u<o?u:o):c===r&&u<o&&(o=u,s=a)}return s||i-e}_chooseSplitAxis(t,e,i){const s=t.leaf?this.compareMinX:vd,r=t.leaf?this.compareMinY:Cd,o=this._allDistMargin(t,e,i,s),a=this._allDistMargin(t,e,i,r);o<a&&t.children.sort(s)}_allDistMargin(t,e,i,s){t.children.sort(s);const r=this.toBBox,o=sn(t,0,e,r),a=sn(t,i-e,i,r);let l=hs(o)+hs(a);for(let h=e;h<i-e;h++){const c=t.children[h];rn(o,t.leaf?r(c):c),l+=hs(o)}for(let h=i-e-1;h>=e;h--){const c=t.children[h];rn(a,t.leaf?r(c):c),l+=hs(a)}return l}_adjustParentBBoxes(t,e,i){for(let s=i;s>=0;s--)rn(e[s],t)}_condense(t){for(let e=t.length-1,i;e>=0;e--)t[e].children.length===0?e>0?(i=t[e-1].children,i.splice(i.indexOf(t[e]),1)):this.clear():Ei(t[e],this.toBBox)}};function wd(n,t,e){if(!e)return t.indexOf(n);for(let i=0;i<t.length;i++)if(e(n,t[i]))return i;return-1}function Ei(n,t){sn(n,0,n.children.length,t,n)}function sn(n,t,e,i,s){s||(s=wi(null)),s.minX=1/0,s.minY=1/0,s.maxX=-1/0,s.maxY=-1/0;for(let r=t;r<e;r++){const o=n.children[r];rn(s,n.leaf?i(o):o)}return s}function rn(n,t){return n.minX=Math.min(n.minX,t.minX),n.minY=Math.min(n.minY,t.minY),n.maxX=Math.max(n.maxX,t.maxX),n.maxY=Math.max(n.maxY,t.maxY),n}function vd(n,t){return n.minX-t.minX}function Cd(n,t){return n.minY-t.minY}function Pr(n){return(n.maxX-n.minX)*(n.maxY-n.minY)}function hs(n){return n.maxX-n.minX+(n.maxY-n.minY)}function Rd(n,t){return(Math.max(t.maxX,n.maxX)-Math.min(t.minX,n.minX))*(Math.max(t.maxY,n.maxY)-Math.min(t.minY,n.minY))}function Sd(n,t){const e=Math.max(n.minX,t.minX),i=Math.max(n.minY,t.minY),s=Math.min(n.maxX,t.maxX),r=Math.min(n.maxY,t.maxY);return Math.max(0,s-e)*Math.max(0,r-i)}function Dr(n,t){return n.minX<=t.minX&&n.minY<=t.minY&&t.maxX<=n.maxX&&t.maxY<=n.maxY}function cs(n,t){return t.minX<=n.maxX&&t.minY<=n.maxY&&t.maxX>=n.minX&&t.maxY>=n.minY}function wi(n){return{children:n,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function fl(n,t,e,i,s){const r=[t,e];for(;r.length;){if(e=r.pop(),t=r.pop(),e-t<=i)continue;const o=t+Math.ceil((e-t)/i/2)*i;ul(n,o,t,e,s),r.push(t,o,o,e)}}const kr=[NaN,NaN,NaN,0];let Fr;function Id(){return Fr||(Fr=gt(1,1,void 0,{willReadFrequently:!0,desynchronized:!0})),Fr}const Td=/^rgba?\(\s*(\d+%?)\s+(\d+%?)\s+(\d+%?)(?:\s*\/\s*(\d+%|\d*\.\d+|[01]))?\s*\)$/i,bd=/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)(?:\s*,\s*(\d+%|\d*\.\d+|[01]))?\s*\)$/i,Md=/^rgba?\(\s*(\d+%)\s*,\s*(\d+%)\s*,\s*(\d+%)(?:\s*,\s*(\d+%|\d*\.\d+|[01]))?\s*\)$/i,Ld=/^#([\da-f]{3,4}|[\da-f]{6}|[\da-f]{8})$/i;function us(n,t){return n.endsWith("%")?Number(n.substring(0,n.length-1))/t:Number(n)}function on(n){throw new Error('failed to parse "'+n+'" as color')}function gl(n){if(n.toLowerCase().startsWith("rgb")){const r=n.match(bd)||n.match(Td)||n.match(Md);if(r){const o=r[4],a=100/255;return[lt(us(r[1],a)+.5|0,0,255),lt(us(r[2],a)+.5|0,0,255),lt(us(r[3],a)+.5|0,0,255),o!==void 0?lt(us(o,100),0,1):1]}on(n)}if(n.startsWith("#")){if(Ld.test(n)){const r=n.substring(1),o=r.length<=4?1:2,a=[0,0,0,255];for(let l=0,h=r.length;l<h;l+=o){let c=parseInt(r.substring(l,l+o),16);o===1&&(c+=c<<4),a[l/o]=c}return a[3]=a[3]/255,a}on(n)}const t=Id();t.fillStyle="#abcdef";let e=t.fillStyle;t.fillStyle=n,t.fillStyle===e&&(t.fillStyle="#fedcba",e=t.fillStyle,t.fillStyle=n,t.fillStyle===e&&on(n));const i=t.fillStyle;if(i.startsWith("#")||i.startsWith("rgba"))return gl(i);t.clearRect(0,0,1,1),t.fillRect(0,0,1,1);const s=Array.from(t.getImageData(0,0,1,1).data);return s[3]=Wn(s[3]/255,3),s}function Ad(n){return typeof n=="string"?n:Br(n)}const Od=1024,an={};let Nr=0;function Pd(n){if(n.length===4)return n;const t=n.slice();return t[3]=1,t}function zr(n){return n>.0031308?Math.pow(n,1/2.4)*269.025-14.025:n*3294.6}function Gr(n){return n>.2068965?Math.pow(n,3):(n-4/29)*(108/841)}function Wr(n){return n>10.314724?Math.pow((n+14.025)/269.025,2.4):n/3294.6}function Xr(n){return n>.0088564?Math.pow(n,1/3):n/(108/841)+4/29}function _l(n){const t=Wr(n[0]),e=Wr(n[1]),i=Wr(n[2]),s=Xr(t*.222488403+e*.716873169+i*.06060791),r=500*(Xr(t*.452247074+e*.399439023+i*.148375274)-s),o=200*(s-Xr(t*.016863605+e*.117638439+i*.865350722)),a=Math.atan2(o,r)*(180/Math.PI);return[116*s-16,Math.sqrt(r*r+o*o),a<0?a+360:a,n[3]]}function Dd(n){const t=(n[0]+16)/116,e=n[1],i=n[2]*Math.PI/180,s=Gr(t),r=Gr(t+e/500*Math.cos(i)),o=Gr(t-e/200*Math.sin(i)),a=zr(r*3.021973625-s*1.617392459-o*.404875592),l=zr(r*-.943766287+s*1.916279586+o*.027607165),h=zr(r*.069407491-s*.22898585+o*1.159737864);return[lt(a+.5|0,0,255),lt(l+.5|0,0,255),lt(h+.5|0,0,255),n[3]]}function Yr(n){if(n==="none")return kr;if(an.hasOwnProperty(n))return an[n];if(Nr>=Od){let e=0;for(const i in an)(e++&3)===0&&(delete an[i],--Nr)}const t=gl(n);t.length!==4&&on(n);for(const e of t)isNaN(e)&&on(n);return an[n]=t,++Nr,t}function vi(n){return Array.isArray(n)?n:Yr(n)}function Br(n){let t=n[0];t!=(t|0)&&(t=t+.5|0);let e=n[1];e!=(e|0)&&(e=e+.5|0);let i=n[2];i!=(i|0)&&(i=i+.5|0);const s=n[3]===void 0?1:Math.round(n[3]*1e3)/1e3;return"rgba("+t+","+e+","+i+","+s+")"}function ml(n){return n[0]>0&&n[1]>0}function kd(n,t,e){return e===void 0&&(e=[0,0]),e[0]=n[0]*t+.5|0,e[1]=n[1]*t+.5|0,e}function kt(n,t){return Array.isArray(n)?n:(t===void 0?t=[n,n]:(t[0]=n,t[1]=n),t)}let qe=0;const Tt=1<<qe++,Z=1<<qe++,Ft=1<<qe++,Jt=1<<qe++,Je=1<<qe++,ln=1<<qe++,ds=Math.pow(2,qe)-1,Ur={[Tt]:"boolean",[Z]:"number",[Ft]:"string",[Jt]:"color",[Je]:"number[]",[ln]:"size"},Fd=Object.keys(Ur).map(Number).sort(ce);function Nd(n){return n in Ur}function hn(n){const t=[];for(const e of Fd)cn(n,e)&&t.push(Ur[e]);return t.length===0?"untyped":t.length<3?t.join(" or "):t.slice(0,-1).join(", ")+", or "+t[t.length-1]}function cn(n,t){return(n&t)===t}function Ae(n,t){return n===t}class _t{constructor(t,e){if(!Nd(t))throw new Error(`literal expressions must have a specific type, got ${hn(t)}`);this.type=t,this.value=e}}class zd{constructor(t,e,...i){this.type=t,this.operator=e,this.args=i}}function pl(){return{variables:new Set,properties:new Set,featureId:!1,geometryType:!1,mapState:!1}}function Ct(n,t,e){switch(typeof n){case"boolean":{if(Ae(t,Ft))return new _t(Ft,n?"true":"false");if(!cn(t,Tt))throw new Error(`got a boolean, but expected ${hn(t)}`);return new _t(Tt,n)}case"number":{if(Ae(t,ln))return new _t(ln,kt(n));if(Ae(t,Tt))return new _t(Tt,!!n);if(Ae(t,Ft))return new _t(Ft,n.toString());if(!cn(t,Z))throw new Error(`got a number, but expected ${hn(t)}`);return new _t(Z,n)}case"string":{if(Ae(t,Jt))return new _t(Jt,Yr(n));if(Ae(t,Tt))return new _t(Tt,!!n);if(!cn(t,Ft))throw new Error(`got a string, but expected ${hn(t)}`);return new _t(Ft,n)}}if(!Array.isArray(n))throw new Error("expression must be an array or a primitive value");if(n.length===0)throw new Error("empty expression");if(typeof n[0]=="string")return $d(n,t,e);for(const i of n)if(typeof i!="number")throw new Error("expected an array of numbers");if(Ae(t,ln)){if(n.length!==2)throw new Error(`expected an array of two values for a size, got ${n.length}`);return new _t(ln,n)}if(Ae(t,Jt)){if(n.length===3)return new _t(Jt,[...n,1]);if(n.length===4)return new _t(Jt,n);throw new Error(`expected an array of 3 or 4 values for a color, got ${n.length}`)}if(!cn(t,Je))throw new Error(`got an array of numbers, but expected ${hn(t)}`);return new _t(Je,n)}const C={Get:"get",Var:"var",Concat:"concat",GeometryType:"geometry-type",LineMetric:"line-metric",Any:"any",All:"all",Not:"!",Resolution:"resolution",Zoom:"zoom",Time:"time",Equal:"==",NotEqual:"!=",GreaterThan:">",GreaterThanOrEqualTo:">=",LessThan:"<",LessThanOrEqualTo:"<=",Multiply:"*",Divide:"/",Add:"+",Subtract:"-",Clamp:"clamp",Mod:"%",Pow:"^",Abs:"abs",Floor:"floor",Ceil:"ceil",Round:"round",Sin:"sin",Cos:"cos",Atan:"atan",Sqrt:"sqrt",Match:"match",Between:"between",Interpolate:"interpolate",Coalesce:"coalesce",Case:"case",In:"in",Number:"number",String:"string",Array:"array",Color:"color",Id:"id",Band:"band",Palette:"palette",ToString:"to-string",Has:"has"},Gd={[C.Get]:z(U(1,1/0),yl),[C.Var]:z(U(1,1),Wd),[C.Has]:z(U(1,1/0),yl),[C.Id]:z(Xd,Ci),[C.Concat]:z(U(2,1/0),J(Ft)),[C.GeometryType]:z(Yd,Ci),[C.LineMetric]:z(Ci),[C.Resolution]:z(Kr,Ci),[C.Zoom]:z(Kr,Ci),[C.Time]:z(Kr,Ci),[C.Any]:z(U(2,1/0),J(Tt)),[C.All]:z(U(2,1/0),J(Tt)),[C.Not]:z(U(1,1),J(Tt)),[C.Equal]:z(U(2,2),J(ds)),[C.NotEqual]:z(U(2,2),J(ds)),[C.GreaterThan]:z(U(2,2),J(Z)),[C.GreaterThanOrEqualTo]:z(U(2,2),J(Z)),[C.LessThan]:z(U(2,2),J(Z)),[C.LessThanOrEqualTo]:z(U(2,2),J(Z)),[C.Multiply]:z(U(2,1/0),xl),[C.Coalesce]:z(U(2,1/0),xl),[C.Divide]:z(U(2,2),J(Z)),[C.Add]:z(U(2,1/0),J(Z)),[C.Subtract]:z(U(2,2),J(Z)),[C.Clamp]:z(U(3,3),J(Z)),[C.Mod]:z(U(2,2),J(Z)),[C.Pow]:z(U(2,2),J(Z)),[C.Abs]:z(U(1,1),J(Z)),[C.Floor]:z(U(1,1),J(Z)),[C.Ceil]:z(U(1,1),J(Z)),[C.Round]:z(U(1,1),J(Z)),[C.Sin]:z(U(1,1),J(Z)),[C.Cos]:z(U(1,1),J(Z)),[C.Atan]:z(U(1,2),J(Z)),[C.Sqrt]:z(U(1,1),J(Z)),[C.Match]:z(U(4,1/0),El,Ud),[C.Between]:z(U(3,3),J(Z)),[C.Interpolate]:z(U(6,1/0),El,Kd),[C.Case]:z(U(3,1/0),Bd,jd),[C.In]:z(U(2,2),Vd),[C.Number]:z(U(1,1/0),J(ds)),[C.String]:z(U(1,1/0),J(ds)),[C.Array]:z(U(1,1/0),J(Z)),[C.Color]:z(U(1,4),J(Z)),[C.Band]:z(U(1,3),J(Z)),[C.Palette]:z(U(2,2),Zd),[C.ToString]:z(U(1,1),J(Tt|Z|Ft|Jt))};function yl(n,t,e){const i=n.length-1,s=new Array(i);for(let r=0;r<i;++r){const o=n[r+1];switch(typeof o){case"number":{s[r]=new _t(Z,o);break}case"string":{s[r]=new _t(Ft,o);break}default:throw new Error(`expected a string key or numeric array index for a get operation, got ${o}`)}r===0&&e.properties.add(String(o))}return s}function Wd(n,t,e){const i=n[1];if(typeof i!="string")throw new Error("expected a string argument for var operation");return e.variables.add(i),[new _t(Ft,i)]}function Xd(n,t,e){e.featureId=!0}function Yd(n,t,e){e.geometryType=!0}function Kr(n,t,e){e.mapState=!0}function Ci(n,t,e){const i=n[0];if(n.length!==1)throw new Error(`expected no arguments for ${i} operation`);return[]}function U(n,t){return function(e,i,s){const r=e[0],o=e.length-1;if(n===t){if(o!==n){const a=n===1?"":"s";throw new Error(`expected ${n} argument${a} for ${r}, got ${o}`)}}else if(o<n||o>t){const a=t===1/0?`${n} or more`:`${n} to ${t}`;throw new Error(`expected ${a} arguments for ${r}, got ${o}`)}}}function xl(n,t,e){const i=n.length-1,s=new Array(i);for(let r=0;r<i;++r){const o=Ct(n[r+1],t,e);s[r]=o}return s}function J(n){return function(t,e,i){const s=t.length-1,r=new Array(s);for(let o=0;o<s;++o){const a=Ct(t[o+1],n,i);r[o]=a}return r}}function Bd(n,t,e){const i=n[0],s=n.length-1;if(s%2===0)throw new Error(`expected an odd number of arguments for ${i}, got ${s} instead`)}function El(n,t,e){const i=n[0],s=n.length-1;if(s%2===1)throw new Error(`expected an even number of arguments for operation ${i}, got ${s} instead`)}function Ud(n,t,e){const i=n.length-1,s=Ft|Z|Tt,r=Ct(n[1],s,e),o=Ct(n[n.length-1],t,e),a=new Array(i-2);for(let l=0;l<i-2;l+=2){try{const h=Ct(n[l+2],r.type,e);a[l]=h}catch(h){throw new Error(`failed to parse argument ${l+1} of match expression: ${h.message}`)}try{const h=Ct(n[l+3],o.type,e);a[l+1]=h}catch(h){throw new Error(`failed to parse argument ${l+2} of match expression: ${h.message}`)}}return[r,...a,o]}function Kd(n,t,e){const i=n[1];let s;switch(i[0]){case"linear":s=1;break;case"exponential":const l=i[1];if(typeof l!="number"||l<=0)throw new Error(`expected a number base for exponential interpolation, got ${JSON.stringify(l)} instead`);s=l;break;default:throw new Error(`invalid interpolation type: ${JSON.stringify(i)}`)}const r=new _t(Z,s);let o;try{o=Ct(n[2],Z,e)}catch(l){throw new Error(`failed to parse argument 1 in interpolate expression: ${l.message}`)}const a=new Array(n.length-3);for(let l=0;l<a.length;l+=2){try{const h=Ct(n[l+3],Z,e);a[l]=h}catch(h){throw new Error(`failed to parse argument ${l+2} for interpolate expression: ${h.message}`)}try{const h=Ct(n[l+4],t,e);a[l+1]=h}catch(h){throw new Error(`failed to parse argument ${l+3} for interpolate expression: ${h.message}`)}}return[r,o,...a]}function jd(n,t,e){const i=Ct(n[n.length-1],t,e),s=new Array(n.length-1);for(let r=0;r<s.length-1;r+=2){try{const o=Ct(n[r+1],Tt,e);s[r]=o}catch(o){throw new Error(`failed to parse argument ${r} of case expression: ${o.message}`)}try{const o=Ct(n[r+2],i.type,e);s[r+1]=o}catch(o){throw new Error(`failed to parse argument ${r+1} of case expression: ${o.message}`)}}return s[s.length-1]=i,s}function Vd(n,t,e){let i=n[2];if(!Array.isArray(i))throw new Error('the second argument for the "in" operator must be an array');let s;if(typeof i[0]=="string"){if(i[0]!=="literal")throw new Error('for the "in" operator, a string array should be wrapped in a "literal" operator to disambiguate from expressions');if(!Array.isArray(i[1]))throw new Error('failed to parse "in" expression: the literal operator must be followed by an array');i=i[1],s=Ft}else s=Z;const r=new Array(i.length);for(let a=0;a<r.length;a++)try{const l=Ct(i[a],s,e);r[a]=l}catch(l){throw new Error(`failed to parse haystack item ${a} for "in" expression: ${l.message}`)}return[Ct(n[1],s,e),...r]}function Zd(n,t,e){let i;try{i=Ct(n[1],Z,e)}catch(o){throw new Error(`failed to parse first argument in palette expression: ${o.message}`)}const s=n[2];if(!Array.isArray(s))throw new Error("the second argument of palette must be an array");const r=new Array(s.length);for(let o=0;o<r.length;o++){let a;try{a=Ct(s[o],Jt,e)}catch(l){throw new Error(`failed to parse color at index ${o} in palette expression: ${l.message}`)}if(!(a instanceof _t))throw new Error(`the palette color at index ${o} must be a literal value`);r[o]=a}return[i,...r]}function z(...n){return function(t,e,i){const s=t[0];let r;for(let o=0;o<n.length;o++){const a=n[o](t,e,i);if(o==n.length-1){if(!a)throw new Error("expected last argument validator to return the parsed args");r=a}}return new zd(e,s,...r)}}function $d(n,t,e){const i=n[0],s=Gd[i];if(!s)throw new Error(`unknown operator: ${i}`);return s(n,t,e)}function wl(n){if(!n)return"";const t=n.getType();switch(t){case"Point":case"LineString":case"Polygon":return t;case"MultiPoint":case"MultiLineString":case"MultiPolygon":return t.substring(5);case"Circle":return"Polygon";case"GeometryCollection":return wl(n.getGeometries()[0]);default:return""}}function vl(){return{variables:{},properties:{},resolution:NaN,featureId:null,geometryType:""}}function ge(n,t,e){const i=Ct(n,t,e);return Qt(i)}function Qt(n,t){if(n instanceof _t){if(n.type===Jt&&typeof n.value=="string"){const i=Yr(n.value);return function(){return i}}return function(){return n.value}}const e=n.operator;switch(e){case C.Number:case C.String:case C.Coalesce:return Hd(n);case C.Get:case C.Var:case C.Has:return qd(n);case C.Id:return i=>i.featureId;case C.GeometryType:return i=>i.geometryType;case C.Concat:{const i=n.args.map(s=>Qt(s));return s=>"".concat(...i.map(r=>r(s).toString()))}case C.Resolution:return i=>i.resolution;case C.Any:case C.All:case C.Between:case C.In:case C.Not:return Qd(n);case C.Equal:case C.NotEqual:case C.LessThan:case C.LessThanOrEqualTo:case C.GreaterThan:case C.GreaterThanOrEqualTo:return Jd(n);case C.Multiply:case C.Divide:case C.Add:case C.Subtract:case C.Clamp:case C.Mod:case C.Pow:case C.Abs:case C.Floor:case C.Ceil:case C.Round:case C.Sin:case C.Cos:case C.Atan:case C.Sqrt:return tf(n);case C.Case:return ef(n);case C.Match:return nf(n);case C.Interpolate:return sf(n);case C.ToString:return rf(n);default:throw new Error(`Unsupported operator ${e}`)}}function Hd(n,t){const e=n.operator,i=n.args.length,s=new Array(i);for(let r=0;r<i;++r)s[r]=Qt(n.args[r]);switch(e){case C.Coalesce:return r=>{for(let o=0;o<i;++o){const a=s[o](r);if(typeof a<"u"&&a!==null)return a}throw new Error("Expected one of the values to be non-null")};case C.Number:case C.String:return r=>{for(let o=0;o<i;++o){const a=s[o](r);if(typeof a===e)return a}throw new Error(`Expected one of the values to be a ${e}`)};default:throw new Error(`Unsupported assertion operator ${e}`)}}function qd(n,t){const i=n.args[0].value;switch(n.operator){case C.Get:return s=>{const r=n.args;let o=s.properties[i];for(let a=1,l=r.length;a<l;++a){const c=r[a].value;o=o[c]}return o};case C.Var:return s=>s.variables[i];case C.Has:return s=>{const r=n.args;if(!(i in s.properties))return!1;let o=s.properties[i];for(let a=1,l=r.length;a<l;++a){const c=r[a].value;if(!o||!Object.hasOwn(o,c))return!1;o=o[c]}return!0};default:throw new Error(`Unsupported accessor operator ${n.operator}`)}}function Jd(n,t){const e=n.operator,i=Qt(n.args[0]),s=Qt(n.args[1]);switch(e){case C.Equal:return r=>i(r)===s(r);case C.NotEqual:return r=>i(r)!==s(r);case C.LessThan:return r=>i(r)<s(r);case C.LessThanOrEqualTo:return r=>i(r)<=s(r);case C.GreaterThan:return r=>i(r)>s(r);case C.GreaterThanOrEqualTo:return r=>i(r)>=s(r);default:throw new Error(`Unsupported comparison operator ${e}`)}}function Qd(n,t){const e=n.operator,i=n.args.length,s=new Array(i);for(let r=0;r<i;++r)s[r]=Qt(n.args[r]);switch(e){case C.Any:return r=>{for(let o=0;o<i;++o)if(s[o](r))return!0;return!1};case C.All:return r=>{for(let o=0;o<i;++o)if(!s[o](r))return!1;return!0};case C.Between:return r=>{const o=s[0](r),a=s[1](r),l=s[2](r);return o>=a&&o<=l};case C.In:return r=>{const o=s[0](r);for(let a=1;a<i;++a)if(o===s[a](r))return!0;return!1};case C.Not:return r=>!s[0](r);default:throw new Error(`Unsupported logical operator ${e}`)}}function tf(n,t){const e=n.operator,i=n.args.length,s=new Array(i);for(let r=0;r<i;++r)s[r]=Qt(n.args[r]);switch(e){case C.Multiply:return r=>{let o=1;for(let a=0;a<i;++a)o*=s[a](r);return o};case C.Divide:return r=>s[0](r)/s[1](r);case C.Add:return r=>{let o=0;for(let a=0;a<i;++a)o+=s[a](r);return o};case C.Subtract:return r=>s[0](r)-s[1](r);case C.Clamp:return r=>{const o=s[0](r),a=s[1](r);if(o<a)return a;const l=s[2](r);return o>l?l:o};case C.Mod:return r=>s[0](r)%s[1](r);case C.Pow:return r=>Math.pow(s[0](r),s[1](r));case C.Abs:return r=>Math.abs(s[0](r));case C.Floor:return r=>Math.floor(s[0](r));case C.Ceil:return r=>Math.ceil(s[0](r));case C.Round:return r=>Math.round(s[0](r));case C.Sin:return r=>Math.sin(s[0](r));case C.Cos:return r=>Math.cos(s[0](r));case C.Atan:return i===2?r=>Math.atan2(s[0](r),s[1](r)):r=>Math.atan(s[0](r));case C.Sqrt:return r=>Math.sqrt(s[0](r));default:throw new Error(`Unsupported numeric operator ${e}`)}}function ef(n,t){const e=n.args.length,i=new Array(e);for(let s=0;s<e;++s)i[s]=Qt(n.args[s]);return s=>{for(let r=0;r<e-1;r+=2)if(i[r](s))return i[r+1](s);return i[e-1](s)}}function nf(n,t){const e=n.args.length,i=new Array(e);for(let s=0;s<e;++s)i[s]=Qt(n.args[s]);return s=>{const r=i[0](s);for(let o=1;o<e-1;o+=2)if(r===i[o](s))return i[o+1](s);return i[e-1](s)}}function sf(n,t){const e=n.args.length,i=new Array(e);for(let s=0;s<e;++s)i[s]=Qt(n.args[s]);return s=>{const r=i[0](s),o=i[1](s);let a,l;for(let h=2;h<e;h+=2){const c=i[h](s);let u=i[h+1](s);const d=Array.isArray(u);if(d&&(u=Pd(u)),c>=o)return h===2?u:d?of(r,o,a,l,c,u):un(r,o,a,l,c,u);a=c,l=u}return l}}function rf(n,t){const e=n.operator,i=n.args.length,s=new Array(i);for(let r=0;r<i;++r)s[r]=Qt(n.args[r]);switch(e){case C.ToString:return r=>{const o=s[0](r);return n.args[0].type===Jt?Br(o):o.toString()};default:throw new Error(`Unsupported convert operator ${e}`)}}function un(n,t,e,i,s,r){const o=s-e;if(o===0)return i;const a=t-e,l=n===1?a/o:(Math.pow(n,a)-1)/(Math.pow(n,o)-1);return i+l*(r-i)}function of(n,t,e,i,s,r){if(s-e===0)return i;const a=_l(i),l=_l(r);let h=l[2]-a[2];h>180?h-=360:h<-180&&(h+=360);const c=[un(n,t,e,a[0],s,l[0]),un(n,t,e,a[1],s,l[1]),a[2]+un(n,t,e,0,s,h),un(n,t,e,i[3],s,r[3])];return Dd(c)}const K={IDLE:0,LOADING:1,LOADED:2,ERROR:3};function af(n,t,e){const i=n;let s=!0,r=!1,o=!1;const a=[Nn(i,B.LOAD,function(){o=!0,r||t()})];return i.src&&na?(r=!0,i.decode().then(function(){s&&t()}).catch(function(l){s&&(o?t():e())})):a.push(Nn(i,B.ERROR,e)),function(){s=!1,a.forEach(at)}}function lf(n,t){return new Promise((e,i)=>{function s(){o(),e(n)}function r(){o(),i(new Error("Image load error"))}function o(){n.removeEventListener("load",s),n.removeEventListener("error",r)}n.addEventListener("load",s),n.addEventListener("error",r)})}function hf(n,t){return t&&(n.src=t),n.src&&na?new Promise((e,i)=>n.decode().then(()=>e(n)).catch(s=>n.complete&&n.width?e(n):i(s))):lf(n)}class cf{constructor(){this.cache_={},this.patternCache_={},this.cacheSize_=0,this.maxCacheSize_=1024}clear(){this.cache_={},this.patternCache_={},this.cacheSize_=0}canExpireCache(){return this.cacheSize_>this.maxCacheSize_}expire(){if(this.canExpireCache()){let t=0;for(const e in this.cache_){const i=this.cache_[e];(t++&3)===0&&!i.hasListener()&&(delete this.cache_[e],delete this.patternCache_[e],--this.cacheSize_)}}}get(t,e,i){const s=jr(t,e,i);return s in this.cache_?this.cache_[s]:null}getPattern(t,e,i){const s=jr(t,e,i);return s in this.patternCache_?this.patternCache_[s]:null}set(t,e,i,s,r){const o=jr(t,e,i),a=o in this.cache_;this.cache_[o]=s,r&&(s.getImageState()===K.IDLE&&s.load(),s.getImageState()===K.LOADING?s.ready().then(()=>{this.patternCache_[o]=os().createPattern(s.getImage(1),"repeat")}):this.patternCache_[o]=os().createPattern(s.getImage(1),"repeat")),a||++this.cacheSize_}setSize(t){this.maxCacheSize_=t,this.expire()}}function jr(n,t,e){const i=e?vi(e):"null";return t+":"+n+":"+i}const Ut=new cf;let dn=null;class Cl extends Fn{constructor(t,e,i,s,r){super(),this.hitDetectionImage_=null,this.image_=t,this.crossOrigin_=i,this.canvas_={},this.color_=r,this.imageState_=s===void 0?K.IDLE:s,this.size_=t&&t.width&&t.height?[t.width,t.height]:null,this.src_=e,this.tainted_,this.ready_=null}initializeImage_(){this.image_=new Image,this.crossOrigin_!==null&&(this.image_.crossOrigin=this.crossOrigin_)}isTainted_(){if(this.tainted_===void 0&&this.imageState_===K.LOADED){dn||(dn=gt(1,1,void 0,{willReadFrequently:!0})),dn.drawImage(this.image_,0,0);try{dn.getImageData(0,0,1,1),this.tainted_=!1}catch{dn=null,this.tainted_=!0}}return this.tainted_===!0}dispatchChangeEvent_(){this.dispatchEvent(B.CHANGE)}handleImageError_(){this.imageState_=K.ERROR,this.dispatchChangeEvent_()}handleImageLoad_(){this.imageState_=K.LOADED,this.size_=[this.image_.width,this.image_.height],this.dispatchChangeEvent_()}getImage(t){return this.image_||this.initializeImage_(),this.replaceColor_(t),this.canvas_[t]?this.canvas_[t]:this.image_}getPixelRatio(t){return this.replaceColor_(t),this.canvas_[t]?t:1}getImageState(){return this.imageState_}getHitDetectionImage(){if(this.image_||this.initializeImage_(),!this.hitDetectionImage_)if(this.isTainted_()){const t=this.size_[0],e=this.size_[1],i=gt(t,e);i.fillRect(0,0,t,e),this.hitDetectionImage_=i.canvas}else this.hitDetectionImage_=this.image_;return this.hitDetectionImage_}getSize(){return this.size_}getSrc(){return this.src_}load(){if(this.imageState_===K.IDLE){this.image_||this.initializeImage_(),this.imageState_=K.LOADING;try{this.src_!==void 0&&(this.image_.src=this.src_)}catch{this.handleImageError_()}this.image_ instanceof HTMLImageElement&&hf(this.image_,this.src_).then(t=>{this.image_=t,this.handleImageLoad_()}).catch(this.handleImageError_.bind(this))}}replaceColor_(t){if(!this.color_||this.canvas_[t]||this.imageState_!==K.LOADED)return;const e=this.image_,i=gt(Math.ceil(e.width*t),Math.ceil(e.height*t)),s=i.canvas;i.scale(t,t),i.drawImage(e,0,0),i.globalCompositeOperation="multiply",i.fillStyle=Ad(this.color_),i.fillRect(0,0,s.width/t,s.height/t),i.globalCompositeOperation="destination-in",i.drawImage(e,0,0),this.canvas_[t]=s}ready(){return this.ready_||(this.ready_=new Promise(t=>{if(this.imageState_===K.LOADED||this.imageState_===K.ERROR)t();else{const e=()=>{(this.imageState_===K.LOADED||this.imageState_===K.ERROR)&&(this.removeEventListener(B.CHANGE,e),t())};this.addEventListener(B.CHANGE,e)}})),this.ready_}}function Vr(n,t,e,i,s,r){let o=t===void 0?void 0:Ut.get(t,e,s);return o||(o=new Cl(n,n&&"src"in n?n.src||void 0:t,e,i,s),Ut.set(t,e,s,o,r)),r&&o&&!Ut.getPattern(t,e,s)&&Ut.set(t,e,s,o,r),o}function oe(n){return n?Array.isArray(n)?Br(n):typeof n=="object"&&"src"in n?uf(n):n:null}function uf(n){if(!n.offset||!n.size)return Ut.getPattern(n.src,"anonymous",n.color);const t=n.src+":"+n.offset,e=Ut.getPattern(t,void 0,n.color);if(e)return e;const i=Ut.get(n.src,"anonymous",null);if(i.getImageState()!==K.LOADED)return null;const s=gt(n.size[0],n.size[1]);return s.drawImage(i.getImage(1),n.offset[0],n.offset[1],n.size[0],n.size[1],0,0,n.size[0],n.size[1]),Vr(s.canvas,t,void 0,K.LOADED,n.color,!0),Ut.getPattern(t,void 0,n.color)}const Rl="10px sans-serif",Nt="#000",Ri="round",_e=[],me=0,Si="round",fn=10,gn="#000",_n="center",fs="middle",Qe=[0,0,0,0],mn=1,Ii=new ne;let pn=null,Sl;const Zr={},df=new Set(["serif","sans-serif","monospace","cursive","fantasy","system-ui","ui-serif","ui-sans-serif","ui-monospace","ui-rounded","emoji","math","fangsong"]);function ff(n,t,e){return`${n} ${t} 16px "${e}"`}const gf=(function(){let t,e;async function i(r){await e.ready;const o=await e.load(r);if(o.length===0)return!1;const a=Rr(r),l=a.families[0].toLowerCase(),h=a.weight;return o.some(c=>{const u=c.family.replace(/^['"]|['"]$/g,"").toLowerCase(),d=Cr[c.weight]||c.weight;return u===l&&c.style===a.style&&d==h})}async function s(){await e.ready;let r=!0;const o=Ii.getProperties(),a=Object.keys(o).filter(l=>o[l]<100);for(let l=a.length-1;l>=0;--l){const h=a[l];let c=o[h];c<100&&(await i(h)?(Ui(Zr),Ii.set(h,100)):(c+=10,Ii.set(h,c,!0),c<100&&(r=!1)))}t=void 0,r||(t=setTimeout(s,100))}return async function(r){e||(e=Ys?self.fonts:document.fonts);const o=Rr(r);if(!o)return;const a=o.families;let l=!1;for(const h of a){if(df.has(h))continue;const c=ff(o.style,o.weight,h);Ii.get(c)===void 0&&(Ii.set(c,0,!0),l=!0)}l&&(clearTimeout(t),t=setTimeout(s,100))}})(),_f=(function(){let n;return function(t){let e=Zr[t];if(e==null){if(Ys){const i=Rr(t),s=Il(t,"Žg");e=(isNaN(Number(i.lineHeight))?1.2:Number(i.lineHeight))*(s.actualBoundingBoxAscent+s.actualBoundingBoxDescent)}else n||(n=document.createElement("div"),n.innerHTML="M",n.style.minHeight="0",n.style.maxHeight="none",n.style.height="auto",n.style.padding="0",n.style.border="none",n.style.position="absolute",n.style.display="block",n.style.left="-99999px"),n.style.font=t,document.body.appendChild(n),e=n.offsetHeight,document.body.removeChild(n);Zr[t]=e}return e}})();function Il(n,t){return pn||(pn=gt(1,1)),n!=Sl&&(pn.font=n,Sl=pn.font),pn.measureText(t)}function Tl(n,t){return Il(n,t).width}function bl(n,t,e){if(t in e)return e[t];const i=t.split(`
|
|
5
6
|
`).reduce((s,r)=>Math.max(s,Tl(n,r)),0);return e[t]=i,i}function mf(n,t){const e=[],i=[],s=[];let r=0,o=0,a=0,l=0;for(let h=0,c=t.length;h<=c;h+=2){const u=t[h];if(u===`
|
|
6
|
-
`||h===c){r=Math.max(r,o),s.push(o),o=0,a+=l,l=0;continue}const d=t[h+1]||n.font,f=Tl(d,u);e.push(f),o+=f;const g=_f(d);i.push(g),l=Math.max(l,g)}return{width:r,height:a,widths:e,heights:i,lineWidths:s}}function pf(n,t,e,i,s,r,o,a,l,h,c){n.save(),e!==1&&(n.globalAlpha===void 0?n.globalAlpha=u=>u.globalAlpha*=e:n.globalAlpha*=e),t&&n.transform.apply(n,t),i.contextInstructions?(n.translate(l,h),n.scale(c[0],c[1]),yf(i,n)):c[0]<0||c[1]<0?(n.translate(l,h),n.scale(c[0],c[1]),n.drawImage(i,s,r,o,a,0,0,o,a)):n.drawImage(i,s,r,o,a,l,h,o*c[0],a*c[1]),n.restore()}function yf(n,t){const e=n.contextInstructions;for(let i=0,s=e.length;i<s;i+=2)Array.isArray(e[i+1])?t[e[i]].apply(t,e[i+1]):t[e[i]]=e[i+1]}class gs{constructor(t){this.opacity_=t.opacity,this.rotateWithView_=t.rotateWithView,this.rotation_=t.rotation,this.scale_=t.scale,this.scaleArray_=kt(t.scale),this.displacement_=t.displacement,this.declutterMode_=t.declutterMode}clone(){const t=this.getScale();return new gs({opacity:this.getOpacity(),scale:Array.isArray(t)?t.slice():t,rotation:this.getRotation(),rotateWithView:this.getRotateWithView(),displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()})}getOpacity(){return this.opacity_}getRotateWithView(){return this.rotateWithView_}getRotation(){return this.rotation_}getScale(){return this.scale_}getScaleArray(){return this.scaleArray_}getDisplacement(){return this.displacement_}getDeclutterMode(){return this.declutterMode_}getAnchor(){return H()}getImage(t){return H()}getHitDetectionImage(){return H()}getPixelRatio(t){return 1}getImageState(){return H()}getImageSize(){return H()}getOrigin(){return H()}getSize(){return H()}setDisplacement(t){this.displacement_=t}setOpacity(t){this.opacity_=t}setRotateWithView(t){this.rotateWithView_=t}setRotation(t){this.rotation_=t}setScale(t){this.scale_=t,this.scaleArray_=kt(t)}listenImageChange(t){H()}load(){H()}unlistenImageChange(t){H()}ready(){return Promise.resolve()}}class _s extends gs{constructor(t){super({opacity:1,rotateWithView:t.rotateWithView!==void 0?t.rotateWithView:!1,rotation:t.rotation!==void 0?t.rotation:0,scale:t.scale!==void 0?t.scale:1,displacement:t.displacement!==void 0?t.displacement:[0,0],declutterMode:t.declutterMode}),this.hitDetectionCanvas_=null,this.fill_=t.fill!==void 0?t.fill:null,this.origin_=[0,0],this.points_=t.points,this.radius=t.radius,this.radius2_=t.radius2,this.angle_=t.angle!==void 0?t.angle:0,this.stroke_=t.stroke!==void 0?t.stroke:null,this.size_,this.renderOptions_,this.imageState_=this.fill_&&this.fill_.loading()?K.LOADING:K.LOADED,this.imageState_===K.LOADING&&this.ready().then(()=>this.imageState_=K.LOADED),this.render()}clone(){const t=this.getScale(),e=new _s({fill:this.getFill()?this.getFill().clone():void 0,points:this.getPoints(),radius:this.getRadius(),radius2:this.getRadius2(),angle:this.getAngle(),stroke:this.getStroke()?this.getStroke().clone():void 0,rotation:this.getRotation(),rotateWithView:this.getRotateWithView(),scale:Array.isArray(t)?t.slice():t,displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()});return e.setOpacity(this.getOpacity()),e}getAnchor(){const t=this.size_,e=this.getDisplacement(),i=this.getScaleArray();return[t[0]/2-e[0]/i[0],t[1]/2+e[1]/i[1]]}getAngle(){return this.angle_}getFill(){return this.fill_}setFill(t){this.fill_=t,this.render()}getHitDetectionImage(){return this.hitDetectionCanvas_||(this.hitDetectionCanvas_=this.createHitDetectionCanvas_(this.renderOptions_)),this.hitDetectionCanvas_}getImage(t){const e=this.fill_?.getKey(),i=`${t},${this.angle_},${this.radius},${this.radius2_},${this.points_},${e}`+Object.values(this.renderOptions_).join(",");let s=Ut.get(i,null,null)?.getImage(1);if(!s){const r=this.renderOptions_,o=Math.ceil(r.size*t),a=gt(o,o);this.draw_(r,a,t),s=a.canvas,Ut.set(i,null,null,new Cl(s,void 0,null,K.LOADED,null))}return s}getPixelRatio(t){return t}getImageSize(){return this.size_}getImageState(){return this.imageState_}getOrigin(){return this.origin_}getPoints(){return this.points_}getRadius(){return this.radius}getRadius2(){return this.radius2_}getSize(){return this.size_}getStroke(){return this.stroke_}setStroke(t){this.stroke_=t,this.render()}listenImageChange(t){}load(){}unlistenImageChange(t){}calculateLineJoinSize_(t,e,i){if(e===0||this.points_===1/0||t!=="bevel"&&t!=="miter")return e;let s=this.radius,r=this.radius2_===void 0?s:this.radius2_;if(s<r){const R=s;s=r,r=R}const o=this.radius2_===void 0?this.points_:this.points_*2,a=2*Math.PI/o,l=r*Math.sin(a),h=Math.sqrt(r*r-l*l),c=s-h,u=Math.sqrt(l*l+c*c),d=u/l;if(t==="miter"&&d<=i)return d*e;const f=e/2/d,g=e/2*(c/u),_=Math.sqrt((s+f)*(s+f)+g*g)-s;if(this.radius2_===void 0||t==="bevel")return _*2;const p=s*Math.sin(a),y=Math.sqrt(s*s-p*p),v=r-y,w=Math.sqrt(p*p+v*v)/p;if(w<=i){const R=w*e/2-r-s;return 2*Math.max(_,R)}return _*2}createRenderOptions(){let t=Ci,e=Ri,i=0,s=null,r=0,o,a=0;this.stroke_&&(o=oe(this.stroke_.getColor()??fn),a=this.stroke_.getWidth()??_n,s=this.stroke_.getLineDash(),r=this.stroke_.getLineDashOffset()??0,e=this.stroke_.getLineJoin()??Ri,t=this.stroke_.getLineCap()??Ci,i=this.stroke_.getMiterLimit()??dn);const l=this.calculateLineJoinSize_(e,a,i),h=Math.max(this.radius,this.radius2_||0),c=Math.ceil(2*h+l);return{strokeStyle:o,strokeWidth:a,size:c,lineCap:t,lineDash:s,lineDashOffset:r,lineJoin:e,miterLimit:i}}render(){this.renderOptions_=this.createRenderOptions();const t=this.renderOptions_.size;this.hitDetectionCanvas_=null,this.size_=[t,t]}draw_(t,e,i){if(e.scale(i,i),e.translate(t.size/2,t.size/2),this.createPath_(e),this.fill_){let s=this.fill_.getColor();s===null&&(s=Nt),e.fillStyle=oe(s),e.fill()}t.strokeStyle&&(e.strokeStyle=t.strokeStyle,e.lineWidth=t.strokeWidth,t.lineDash&&(e.setLineDash(t.lineDash),e.lineDashOffset=t.lineDashOffset),e.lineCap=t.lineCap,e.lineJoin=t.lineJoin,e.miterLimit=t.miterLimit,e.stroke())}createHitDetectionCanvas_(t){let e;if(this.fill_){let i=this.fill_.getColor(),s=0;typeof i=="string"&&(i=wi(i)),i===null?s=1:Array.isArray(i)&&(s=i.length===4?i[3]:1),s===0&&(e=gt(t.size,t.size),this.drawHitDetectionCanvas_(t,e))}return e?e.canvas:this.getImage(1)}createPath_(t){let e=this.points_;const i=this.radius;if(e===1/0)t.arc(0,0,i,0,2*Math.PI);else{const s=this.radius2_===void 0?i:this.radius2_;this.radius2_!==void 0&&(e*=2);const r=this.angle_-Math.PI/2,o=2*Math.PI/e;for(let a=0;a<e;a++){const l=r+a*o,h=a%2===0?i:s;t.lineTo(h*Math.cos(l),h*Math.sin(l))}t.closePath()}}drawHitDetectionCanvas_(t,e){e.translate(t.size/2,t.size/2),this.createPath_(e),e.fillStyle=Nt,e.fill(),t.strokeStyle&&(e.strokeStyle=t.strokeStyle,e.lineWidth=t.strokeWidth,t.lineDash&&(e.setLineDash(t.lineDash),e.lineDashOffset=t.lineDashOffset),e.lineJoin=t.lineJoin,e.miterLimit=t.miterLimit,e.stroke())}ready(){return this.fill_?this.fill_.ready():Promise.resolve()}}class ms extends _s{constructor(t){t=t||{radius:5},super({points:1/0,fill:t.fill,radius:t.radius,stroke:t.stroke,scale:t.scale!==void 0?t.scale:1,rotation:t.rotation!==void 0?t.rotation:0,rotateWithView:t.rotateWithView!==void 0?t.rotateWithView:!1,displacement:t.displacement!==void 0?t.displacement:[0,0],declutterMode:t.declutterMode})}clone(){const t=this.getScale(),e=new ms({fill:this.getFill()?this.getFill().clone():void 0,stroke:this.getStroke()?this.getStroke().clone():void 0,radius:this.getRadius(),scale:Array.isArray(t)?t.slice():t,rotation:this.getRotation(),rotateWithView:this.getRotateWithView(),displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()});return e.setOpacity(this.getOpacity()),e}setRadius(t){this.radius=t,this.render()}}class pn{constructor(t){t=t||{},this.patternImage_=null,this.color_=null,t.color!==void 0&&this.setColor(t.color)}clone(){const t=this.getColor();return new pn({color:Array.isArray(t)?t.slice():t||void 0})}getColor(){return this.color_}setColor(t){if(t!==null&&typeof t=="object"&&"src"in t){const e=Vr(null,t.src,"anonymous",void 0,t.offset?null:t.color?t.color:null,!(t.offset&&t.size));e.ready().then(()=>{this.patternImage_=null}),e.getImageState()===K.IDLE&&e.load(),e.getImageState()===K.LOADING&&(this.patternImage_=e)}this.color_=t}getKey(){const t=this.getColor();return t?t instanceof CanvasPattern||t instanceof CanvasGradient?q(t):typeof t=="object"&&"src"in t?t.src+":"+t.offset:wi(t).toString():""}loading(){return!!this.patternImage_}ready(){return this.patternImage_?this.patternImage_.ready():Promise.resolve()}}function Ml(n,t,e,i){return e!==void 0&&i!==void 0?[e/n,i/t]:e!==void 0?e/n:i!==void 0?i/t:1}class yn extends gs{constructor(t){t=t||{};const e=t.opacity!==void 0?t.opacity:1,i=t.rotation!==void 0?t.rotation:0,s=t.scale!==void 0?t.scale:1,r=t.rotateWithView!==void 0?t.rotateWithView:!1;super({opacity:e,rotation:i,scale:s,displacement:t.displacement!==void 0?t.displacement:[0,0],rotateWithView:r,declutterMode:t.declutterMode}),this.anchor_=t.anchor!==void 0?t.anchor:[.5,.5],this.normalizedAnchor_=null,this.anchorOrigin_=t.anchorOrigin!==void 0?t.anchorOrigin:"top-left",this.anchorXUnits_=t.anchorXUnits!==void 0?t.anchorXUnits:"fraction",this.anchorYUnits_=t.anchorYUnits!==void 0?t.anchorYUnits:"fraction",this.crossOrigin_=t.crossOrigin!==void 0?t.crossOrigin:null;const o=t.img!==void 0?t.img:null;let a=t.src;Q(!(a!==void 0&&o),"`image` and `src` cannot be provided at the same time"),(a===void 0||a.length===0)&&o&&(a=o.src||q(o)),Q(a!==void 0&&a.length>0,"A defined and non-empty `src` or `image` must be provided"),Q(!((t.width!==void 0||t.height!==void 0)&&t.scale!==void 0),"`width` or `height` cannot be provided together with `scale`");let l;if(t.src!==void 0?l=K.IDLE:o!==void 0&&("complete"in o?o.complete?l=o.src?K.LOADED:K.IDLE:l=K.LOADING:l=K.LOADED),this.color_=t.color!==void 0?wi(t.color):null,this.iconImage_=Vr(o,a,this.crossOrigin_,l,this.color_),this.offset_=t.offset!==void 0?t.offset:[0,0],this.offsetOrigin_=t.offsetOrigin!==void 0?t.offsetOrigin:"top-left",this.origin_=null,this.size_=t.size!==void 0?t.size:null,this.initialOptions_,t.width!==void 0||t.height!==void 0){let h,c;if(t.size)[h,c]=t.size;else{const u=this.getImage(1);if(u.width&&u.height)h=u.width,c=u.height;else if(u instanceof HTMLImageElement){this.initialOptions_=t;const d=()=>{if(this.unlistenImageChange(d),!this.initialOptions_)return;const f=this.iconImage_.getSize();this.setScale(Ml(f[0],f[1],t.width,t.height))};this.listenImageChange(d);return}}h!==void 0&&this.setScale(Ml(h,c,t.width,t.height))}}clone(){let t,e,i;return this.initialOptions_?(e=this.initialOptions_.width,i=this.initialOptions_.height):(t=this.getScale(),t=Array.isArray(t)?t.slice():t),new yn({anchor:this.anchor_.slice(),anchorOrigin:this.anchorOrigin_,anchorXUnits:this.anchorXUnits_,anchorYUnits:this.anchorYUnits_,color:this.color_&&this.color_.slice?this.color_.slice():this.color_||void 0,crossOrigin:this.crossOrigin_,offset:this.offset_.slice(),offsetOrigin:this.offsetOrigin_,opacity:this.getOpacity(),rotateWithView:this.getRotateWithView(),rotation:this.getRotation(),scale:t,width:e,height:i,size:this.size_!==null?this.size_.slice():void 0,src:this.getSrc(),displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()})}getAnchor(){let t=this.normalizedAnchor_;if(!t){t=this.anchor_;const s=this.getSize();if(this.anchorXUnits_=="fraction"||this.anchorYUnits_=="fraction"){if(!s)return null;t=this.anchor_.slice(),this.anchorXUnits_=="fraction"&&(t[0]*=s[0]),this.anchorYUnits_=="fraction"&&(t[1]*=s[1])}if(this.anchorOrigin_!="top-left"){if(!s)return null;t===this.anchor_&&(t=this.anchor_.slice()),(this.anchorOrigin_=="top-right"||this.anchorOrigin_=="bottom-right")&&(t[0]=-t[0]+s[0]),(this.anchorOrigin_=="bottom-left"||this.anchorOrigin_=="bottom-right")&&(t[1]=-t[1]+s[1])}this.normalizedAnchor_=t}const e=this.getDisplacement(),i=this.getScaleArray();return[t[0]-e[0]/i[0],t[1]+e[1]/i[1]]}setAnchor(t){this.anchor_=t,this.normalizedAnchor_=null}getColor(){return this.color_}getImage(t){return this.iconImage_.getImage(t)}getPixelRatio(t){return this.iconImage_.getPixelRatio(t)}getImageSize(){return this.iconImage_.getSize()}getImageState(){return this.iconImage_.getImageState()}getHitDetectionImage(){return this.iconImage_.getHitDetectionImage()}getOrigin(){if(this.origin_)return this.origin_;let t=this.offset_;if(this.offsetOrigin_!="top-left"){const e=this.getSize(),i=this.iconImage_.getSize();if(!e||!i)return null;t=t.slice(),(this.offsetOrigin_=="top-right"||this.offsetOrigin_=="bottom-right")&&(t[0]=i[0]-e[0]-t[0]),(this.offsetOrigin_=="bottom-left"||this.offsetOrigin_=="bottom-right")&&(t[1]=i[1]-e[1]-t[1])}return this.origin_=t,this.origin_}getSrc(){return this.iconImage_.getSrc()}getSize(){return this.size_?this.size_:this.iconImage_.getSize()}getWidth(){const t=this.getScaleArray();if(this.size_)return this.size_[0]*t[0];if(this.iconImage_.getImageState()==K.LOADED)return this.iconImage_.getSize()[0]*t[0]}getHeight(){const t=this.getScaleArray();if(this.size_)return this.size_[1]*t[1];if(this.iconImage_.getImageState()==K.LOADED)return this.iconImage_.getSize()[1]*t[1]}setScale(t){delete this.initialOptions_,super.setScale(t)}listenImageChange(t){this.iconImage_.addEventListener(B.CHANGE,t)}load(){this.iconImage_.load()}unlistenImageChange(t){this.iconImage_.removeEventListener(B.CHANGE,t)}ready(){return this.iconImage_.ready()}}class ps{constructor(t){t=t||{},this.color_=t.color!==void 0?t.color:null,this.lineCap_=t.lineCap,this.lineDash_=t.lineDash!==void 0?t.lineDash:null,this.lineDashOffset_=t.lineDashOffset,this.lineJoin_=t.lineJoin,this.miterLimit_=t.miterLimit,this.width_=t.width}clone(){const t=this.getColor();return new ps({color:Array.isArray(t)?t.slice():t||void 0,lineCap:this.getLineCap(),lineDash:this.getLineDash()?this.getLineDash().slice():void 0,lineDashOffset:this.getLineDashOffset(),lineJoin:this.getLineJoin(),miterLimit:this.getMiterLimit(),width:this.getWidth()})}getColor(){return this.color_}getLineCap(){return this.lineCap_}getLineDash(){return this.lineDash_}getLineDashOffset(){return this.lineDashOffset_}getLineJoin(){return this.lineJoin_}getMiterLimit(){return this.miterLimit_}getWidth(){return this.width_}setColor(t){this.color_=t}setLineCap(t){this.lineCap_=t}setLineDash(t){this.lineDash_=t}setLineDashOffset(t){this.lineDashOffset_=t}setLineJoin(t){this.lineJoin_=t}setMiterLimit(t){this.miterLimit_=t}setWidth(t){this.width_=t}}class Oe{constructor(t){t=t||{},this.geometry_=null,this.geometryFunction_=Al,t.geometry!==void 0&&this.setGeometry(t.geometry),this.fill_=t.fill!==void 0?t.fill:null,this.image_=t.image!==void 0?t.image:null,this.renderer_=t.renderer!==void 0?t.renderer:null,this.hitDetectionRenderer_=t.hitDetectionRenderer!==void 0?t.hitDetectionRenderer:null,this.stroke_=t.stroke!==void 0?t.stroke:null,this.text_=t.text!==void 0?t.text:null,this.zIndex_=t.zIndex}clone(){let t=this.getGeometry();return t&&typeof t=="object"&&(t=t.clone()),new Oe({geometry:t??void 0,fill:this.getFill()?this.getFill().clone():void 0,image:this.getImage()?this.getImage().clone():void 0,renderer:this.getRenderer()??void 0,stroke:this.getStroke()?this.getStroke().clone():void 0,text:this.getText()?this.getText().clone():void 0,zIndex:this.getZIndex()})}getRenderer(){return this.renderer_}setRenderer(t){this.renderer_=t}setHitDetectionRenderer(t){this.hitDetectionRenderer_=t}getHitDetectionRenderer(){return this.hitDetectionRenderer_}getGeometry(){return this.geometry_}getGeometryFunction(){return this.geometryFunction_}getFill(){return this.fill_}setFill(t){this.fill_=t}getImage(){return this.image_}setImage(t){this.image_=t}getStroke(){return this.stroke_}setStroke(t){this.stroke_=t}getText(){return this.text_}setText(t){this.text_=t}getZIndex(){return this.zIndex_}setGeometry(t){typeof t=="function"?this.geometryFunction_=t:typeof t=="string"?this.geometryFunction_=function(e){return e.get(t)}:t?t!==void 0&&(this.geometryFunction_=function(){return t}):this.geometryFunction_=Al,this.geometry_=t}setZIndex(t){this.zIndex_=t}}function xf(n){let t;if(typeof n=="function")t=n;else{let e;Array.isArray(n)?e=n:(Q(typeof n.getZIndex=="function","Expected an `Style` or an array of `Style`"),e=[n]),t=function(){return e}}return t}let $r=null;function Ll(n,t){if(!$r){const e=new pn({color:"rgba(255,255,255,0.4)"}),i=new ps({color:"#3399CC",width:1.25});$r=[new Oe({image:new ms({fill:e,stroke:i,radius:5}),fill:e,stroke:i})]}return $r}function Al(n){return n.getGeometry()}const Ef="#333";class Hr{constructor(t){t=t||{},this.font_=t.font,this.rotation_=t.rotation,this.rotateWithView_=t.rotateWithView,this.keepUpright_=t.keepUpright,this.scale_=t.scale,this.scaleArray_=kt(t.scale!==void 0?t.scale:1),this.text_=t.text,this.textAlign_=t.textAlign,this.justify_=t.justify,this.repeat_=t.repeat,this.textBaseline_=t.textBaseline,this.fill_=t.fill!==void 0?t.fill:new pn({color:Ef}),this.maxAngle_=t.maxAngle!==void 0?t.maxAngle:Math.PI/4,this.placement_=t.placement!==void 0?t.placement:"point",this.overflow_=!!t.overflow,this.stroke_=t.stroke!==void 0?t.stroke:null,this.offsetX_=t.offsetX!==void 0?t.offsetX:0,this.offsetY_=t.offsetY!==void 0?t.offsetY:0,this.backgroundFill_=t.backgroundFill?t.backgroundFill:null,this.backgroundStroke_=t.backgroundStroke?t.backgroundStroke:null,this.padding_=t.padding===void 0?null:t.padding,this.declutterMode_=t.declutterMode}clone(){const t=this.getScale();return new Hr({font:this.getFont(),placement:this.getPlacement(),repeat:this.getRepeat(),maxAngle:this.getMaxAngle(),overflow:this.getOverflow(),rotation:this.getRotation(),rotateWithView:this.getRotateWithView(),keepUpright:this.getKeepUpright(),scale:Array.isArray(t)?t.slice():t,text:this.getText(),textAlign:this.getTextAlign(),justify:this.getJustify(),textBaseline:this.getTextBaseline(),fill:this.getFill()?this.getFill().clone():void 0,stroke:this.getStroke()?this.getStroke().clone():void 0,offsetX:this.getOffsetX(),offsetY:this.getOffsetY(),backgroundFill:this.getBackgroundFill()?this.getBackgroundFill().clone():void 0,backgroundStroke:this.getBackgroundStroke()?this.getBackgroundStroke().clone():void 0,padding:this.getPadding()||void 0,declutterMode:this.getDeclutterMode()})}getOverflow(){return this.overflow_}getFont(){return this.font_}getMaxAngle(){return this.maxAngle_}getPlacement(){return this.placement_}getRepeat(){return this.repeat_}getOffsetX(){return this.offsetX_}getOffsetY(){return this.offsetY_}getFill(){return this.fill_}getRotateWithView(){return this.rotateWithView_}getKeepUpright(){return this.keepUpright_}getRotation(){return this.rotation_}getScale(){return this.scale_}getScaleArray(){return this.scaleArray_}getStroke(){return this.stroke_}getText(){return this.text_}getTextAlign(){return this.textAlign_}getJustify(){return this.justify_}getTextBaseline(){return this.textBaseline_}getBackgroundFill(){return this.backgroundFill_}getBackgroundStroke(){return this.backgroundStroke_}getPadding(){return this.padding_}getDeclutterMode(){return this.declutterMode_}setOverflow(t){this.overflow_=t}setFont(t){this.font_=t}setMaxAngle(t){this.maxAngle_=t}setOffsetX(t){this.offsetX_=t}setOffsetY(t){this.offsetY_=t}setPlacement(t){this.placement_=t}setRepeat(t){this.repeat_=t}setRotateWithView(t){this.rotateWithView_=t}setKeepUpright(t){this.keepUpright_=t}setFill(t){this.fill_=t}setRotation(t){this.rotation_=t}setScale(t){this.scale_=t,this.scaleArray_=kt(t!==void 0?t:1)}setStroke(t){this.stroke_=t}setText(t){this.text_=t}setTextAlign(t){this.textAlign_=t}setJustify(t){this.justify_=t}setTextBaseline(t){this.textBaseline_=t}setBackgroundFill(t){this.backgroundFill_=t}setBackgroundStroke(t){this.backgroundStroke_=t}setPadding(t){this.padding_=t}}function wf(n){return!0}function vf(n){const t=pl(),e=Cf(n,t),i=vl();return function(s,r){if(i.properties=s.getPropertiesInternal(),i.resolution=r,t.featureId){const o=s.getId();o!==void 0?i.featureId=o:i.featureId=null}return t.geometryType&&(i.geometryType=wl(s.getGeometry())),e(i)}}function Ol(n){const t=pl(),e=n.length,i=new Array(e);for(let o=0;o<e;++o)i[o]=qr(n[o],t);const s=vl(),r=new Array(e);return function(o,a){if(s.properties=o.getPropertiesInternal(),s.resolution=a,t.featureId){const h=o.getId();h!==void 0?s.featureId=h:s.featureId=null}let l=0;for(let h=0;h<e;++h){const c=i[h](s);c&&(r[l]=c,l+=1)}return r.length=l,r}}function Cf(n,t){const e=n.length,i=new Array(e);for(let s=0;s<e;++s){const r=n[s],o="filter"in r?ge(r.filter,Tt,t):wf;let a;if(Array.isArray(r.style)){const l=r.style.length;a=new Array(l);for(let h=0;h<l;++h)a[h]=qr(r.style[h],t)}else a=[qr(r.style,t)];i[s]={filter:o,styles:a}}return function(s){const r=[];let o=!1;for(let a=0;a<e;++a){const l=i[a].filter;if(l(s)&&!(n[a].else&&o)){o=!0;for(const h of i[a].styles){const c=h(s);c&&r.push(c)}}}return r}}function qr(n,t){const e=xn(n,"",t),i=En(n,"",t),s=Rf(n,t),r=Sf(n,t),o=zt(n,"z-index",t);if(!e&&!i&&!s&&!r&&!oi(n))throw new Error("No fill, stroke, point, or text symbolizer properties in style: "+JSON.stringify(n));const a=new Oe;return function(l){let h=!0;if(e){const c=e(l);c&&(h=!1),a.setFill(c)}if(i){const c=i(l);c&&(h=!1),a.setStroke(c)}if(s){const c=s(l);c&&(h=!1),a.setText(c)}if(r){const c=r(l);c&&(h=!1),a.setImage(c)}return o&&a.setZIndex(o(l)),h?null:a}}function xn(n,t,e){let i;if(t+"fill-pattern-src"in n)i=Mf(n,t+"fill-",e);else{if(n[t+"fill-color"]==="none")return r=>null;i=Jr(n,t+"fill-color",e)}if(!i)return null;const s=new pn;return function(r){const o=i(r);return o===kr?null:(s.setColor(o),s)}}function En(n,t,e){const i=zt(n,t+"stroke-width",e),s=Jr(n,t+"stroke-color",e);if(!i&&!s)return null;const r=pe(n,t+"stroke-line-cap",e),o=pe(n,t+"stroke-line-join",e),a=Pl(n,t+"stroke-line-dash",e),l=zt(n,t+"stroke-line-dash-offset",e),h=zt(n,t+"stroke-miter-limit",e),c=new ps;return function(u){if(s){const d=s(u);if(d===kr)return null;c.setColor(d)}if(i&&c.setWidth(i(u)),r){const d=r(u);if(d!=="butt"&&d!=="round"&&d!=="square")throw new Error("Expected butt, round, or square line cap");c.setLineCap(d)}if(o){const d=o(u);if(d!=="bevel"&&d!=="round"&&d!=="miter")throw new Error("Expected bevel, round, or miter line join");c.setLineJoin(d)}return a&&c.setLineDash(a(u)),l&&c.setLineDashOffset(l(u)),h&&c.setMiterLimit(h(u)),c}}function Rf(n,t){const e="text-",i=pe(n,e+"value",t);if(!i)return null;const s=xn(n,e,t),r=xn(n,e+"background-",t),o=En(n,e,t),a=En(n,e+"background-",t),l=pe(n,e+"font",t),h=zt(n,e+"max-angle",t),c=zt(n,e+"offset-x",t),u=zt(n,e+"offset-y",t),d=Ii(n,e+"overflow",t),f=pe(n,e+"placement",t),g=zt(n,e+"repeat",t),m=xs(n,e+"scale",t),_=Ii(n,e+"rotate-with-view",t),p=zt(n,e+"rotation",t),y=pe(n,e+"align",t),v=pe(n,e+"justify",t),x=pe(n,e+"baseline",t),w=Ii(n,e+"keep-upright",t),R=Pl(n,e+"padding",t),T=ws(n,e+"declutter-mode"),S=new Hr({declutterMode:T});return function(I){if(S.setText(i(I)),s&&S.setFill(s(I)),r&&S.setBackgroundFill(r(I)),o&&S.setStroke(o(I)),a&&S.setBackgroundStroke(a(I)),l&&S.setFont(l(I)),h&&S.setMaxAngle(h(I)),c&&S.setOffsetX(c(I)),u&&S.setOffsetY(u(I)),d&&S.setOverflow(d(I)),f){const M=f(I);if(M!=="point"&&M!=="line")throw new Error("Expected point or line for text-placement");S.setPlacement(M)}if(g&&S.setRepeat(g(I)),m&&S.setScale(m(I)),_&&S.setRotateWithView(_(I)),p&&S.setRotation(p(I)),y){const M=y(I);if(M!=="left"&&M!=="center"&&M!=="right"&&M!=="end"&&M!=="start")throw new Error("Expected left, right, center, start, or end for text-align");S.setTextAlign(M)}if(v){const M=v(I);if(M!=="left"&&M!=="right"&&M!=="center")throw new Error("Expected left, right, or center for text-justify");S.setJustify(M)}if(x){const M=x(I);if(M!=="bottom"&&M!=="top"&&M!=="middle"&&M!=="alphabetic"&&M!=="hanging")throw new Error("Expected bottom, top, middle, alphabetic, or hanging for text-baseline");S.setTextBaseline(M)}return R&&S.setPadding(R(I)),w&&S.setKeepUpright(w(I)),S}}function Sf(n,t){return"icon-src"in n?If(n,t):"shape-points"in n?Tf(n,t):"circle-radius"in n?bf(n,t):null}function If(n,t){const e="icon-",i=e+"src",s=Nl(n[i],i),r=ys(n,e+"anchor",t),o=xs(n,e+"scale",t),a=zt(n,e+"opacity",t),l=ys(n,e+"displacement",t),h=zt(n,e+"rotation",t),c=Ii(n,e+"rotate-with-view",t),u=kl(n,e+"anchor-origin"),d=Fl(n,e+"anchor-x-units"),f=Fl(n,e+"anchor-y-units"),g=Pf(n,e+"color"),m=Af(n,e+"cross-origin"),_=Of(n,e+"offset"),p=kl(n,e+"offset-origin"),y=Es(n,e+"width"),v=Es(n,e+"height"),x=Lf(n,e+"size"),w=ws(n,e+"declutter-mode"),R=new yn({src:s,anchorOrigin:u,anchorXUnits:d,anchorYUnits:f,color:g,crossOrigin:m,offset:_,offsetOrigin:p,height:v,width:y,size:x,declutterMode:w});return function(T){return a&&R.setOpacity(a(T)),l&&R.setDisplacement(l(T)),h&&R.setRotation(h(T)),c&&R.setRotateWithView(c(T)),o&&R.setScale(o(T)),r&&R.setAnchor(r(T)),R}}function Tf(n,t){const e="shape-",i=e+"points",s=e+"radius",r=Qr(n[i],i),o=Qr(n[s],s),a=xn(n,e,t),l=En(n,e,t),h=xs(n,e+"scale",t),c=ys(n,e+"displacement",t),u=zt(n,e+"rotation",t),d=Ii(n,e+"rotate-with-view",t),f=Es(n,e+"radius2"),g=Es(n,e+"angle"),m=ws(n,e+"declutter-mode"),_=new _s({points:r,radius:o,radius2:f,angle:g,declutterMode:m});return function(p){return a&&_.setFill(a(p)),l&&_.setStroke(l(p)),c&&_.setDisplacement(c(p)),u&&_.setRotation(u(p)),d&&_.setRotateWithView(d(p)),h&&_.setScale(h(p)),_}}function bf(n,t){const e="circle-",i=xn(n,e,t),s=En(n,e,t),r=zt(n,e+"radius",t),o=xs(n,e+"scale",t),a=ys(n,e+"displacement",t),l=zt(n,e+"rotation",t),h=Ii(n,e+"rotate-with-view",t),c=ws(n,e+"declutter-mode"),u=new ms({radius:5,declutterMode:c});return function(d){return r&&u.setRadius(r(d)),i&&u.setFill(i(d)),s&&u.setStroke(s(d)),a&&u.setDisplacement(a(d)),l&&u.setRotation(l(d)),h&&u.setRotateWithView(h(d)),o&&u.setScale(o(d)),u}}function zt(n,t,e){if(!(t in n))return;const i=ge(n[t],Z,e);return function(s){return Qr(i(s),t)}}function pe(n,t,e){if(!(t in n))return null;const i=ge(n[t],Ft,e);return function(s){return Nl(i(s),t)}}function Mf(n,t,e){const i=pe(n,t+"pattern-src",e),s=Dl(n,t+"pattern-offset",e),r=Dl(n,t+"pattern-size",e),o=Jr(n,t+"color",e);return function(a){return{src:i(a),offset:s&&s(a),size:r&&r(a),color:o&&o(a)}}}function Ii(n,t,e){if(!(t in n))return null;const i=ge(n[t],Tt,e);return function(s){const r=i(s);if(typeof r!="boolean")throw new Error(`Expected a boolean for ${t}`);return r}}function Jr(n,t,e){if(!(t in n))return null;const i=ge(n[t],Jt,e);return function(s){return zl(i(s),t)}}function Pl(n,t,e){if(!(t in n))return null;const i=ge(n[t],qe,e);return function(s){return wn(i(s),t)}}function ys(n,t,e){if(!(t in n))return null;const i=ge(n[t],qe,e);return function(s){const r=wn(i(s),t);if(r.length!==2)throw new Error(`Expected two numbers for ${t}`);return r}}function Dl(n,t,e){if(!(t in n))return null;const i=ge(n[t],qe,e);return function(s){return Gl(i(s),t)}}function xs(n,t,e){if(!(t in n))return null;const i=ge(n[t],qe|Z,e);return function(s){return Df(i(s),t)}}function Es(n,t){const e=n[t];if(e!==void 0){if(typeof e!="number")throw new Error(`Expected a number for ${t}`);return e}}function Lf(n,t){const e=n[t];if(e!==void 0){if(typeof e=="number")return kt(e);if(!Array.isArray(e))throw new Error(`Expected a number or size array for ${t}`);if(e.length!==2||typeof e[0]!="number"||typeof e[1]!="number")throw new Error(`Expected a number or size array for ${t}`);return e}}function Af(n,t){const e=n[t];if(e!==void 0){if(typeof e!="string")throw new Error(`Expected a string for ${t}`);return e}}function kl(n,t){const e=n[t];if(e!==void 0){if(e!=="bottom-left"&&e!=="bottom-right"&&e!=="top-left"&&e!=="top-right")throw new Error(`Expected bottom-left, bottom-right, top-left, or top-right for ${t}`);return e}}function Fl(n,t){const e=n[t];if(e!==void 0){if(e!=="pixels"&&e!=="fraction")throw new Error(`Expected pixels or fraction for ${t}`);return e}}function Of(n,t){const e=n[t];if(e!==void 0)return wn(e,t)}function ws(n,t){const e=n[t];if(e!==void 0){if(typeof e!="string")throw new Error(`Expected a string for ${t}`);if(e!=="declutter"&&e!=="obstacle"&&e!=="none")throw new Error(`Expected declutter, obstacle, or none for ${t}`);return e}}function Pf(n,t){const e=n[t];if(e!==void 0)return zl(e,t)}function wn(n,t){if(!Array.isArray(n))throw new Error(`Expected an array for ${t}`);const e=n.length;for(let i=0;i<e;++i)if(typeof n[i]!="number")throw new Error(`Expected an array of numbers for ${t}`);return n}function Nl(n,t){if(typeof n!="string")throw new Error(`Expected a string for ${t}`);return n}function Qr(n,t){if(typeof n!="number")throw new Error(`Expected a number for ${t}`);return n}function zl(n,t){if(typeof n=="string")return n;const e=wn(n,t),i=e.length;if(i<3||i>4)throw new Error(`Expected a color with 3 or 4 values for ${t}`);return e}function Gl(n,t){const e=wn(n,t);if(e.length!==2)throw new Error(`Expected an array of two numbers for ${t}`);return e}function Df(n,t){return typeof n=="number"?n:Gl(n,t)}const Wl={RENDER_ORDER:"renderOrder"};class Xl extends ls{constructor(t){t=t||{};const e=Object.assign({},t);delete e.style,delete e.renderBuffer,delete e.updateWhileAnimating,delete e.updateWhileInteracting,super(e),this.declutter_=t.declutter?String(t.declutter):void 0,this.renderBuffer_=t.renderBuffer!==void 0?t.renderBuffer:100,this.style_=null,this.styleFunction_=void 0,this.setStyle(t.style),this.updateWhileAnimating_=t.updateWhileAnimating!==void 0?t.updateWhileAnimating:!1,this.updateWhileInteracting_=t.updateWhileInteracting!==void 0?t.updateWhileInteracting:!1}getDeclutter(){return this.declutter_}getFeatures(t){return super.getFeatures(t)}getRenderBuffer(){return this.renderBuffer_}getRenderOrder(){return this.get(Wl.RENDER_ORDER)}getStyle(){return this.style_}getStyleFunction(){return this.styleFunction_}getUpdateWhileAnimating(){return this.updateWhileAnimating_}getUpdateWhileInteracting(){return this.updateWhileInteracting_}renderDeclutter(t,e){const i=this.getDeclutter();i in t.declutter||(t.declutter[i]=new dl(9)),this.getRenderer().renderDeclutter(t,e)}setRenderOrder(t){this.set(Wl.RENDER_ORDER,t)}setStyle(t){this.style_=t===void 0?Ll:t;const e=kf(t);this.styleFunction_=t===null?void 0:xf(e),this.changed()}setDeclutter(t){this.declutter_=t?String(t):void 0,this.changed()}}function kf(n){if(n===void 0)return Ll;if(!n)return null;if(typeof n=="function"||n instanceof Oe)return n;if(!Array.isArray(n))return Ol([n]);if(n.length===0)return[];const t=n.length,e=n[0];if(e instanceof Oe){const s=new Array(t);for(let r=0;r<t;++r){const o=n[r];if(!(o instanceof Oe))throw new Error("Expected a list of style instances");s[r]=o}return s}if("style"in e){const s=new Array(t);for(let r=0;r<t;++r){const o=n[r];if(!("style"in o))throw new Error("Expected a list of rules with a style property");s[r]=o}return vf(s)}return Ol(n)}class Yl extends ue{constructor(t,e,i,s){super(t),this.inversePixelTransform=e,this.frameState=i,this.context=s}}class Ff extends Dn{constructor(t){super(),this.map_=t}dispatchRenderEvent(t,e){H()}calculateMatrices2D(t){const e=t.viewState,i=t.coordinateToPixelTransform,s=t.pixelToCoordinateTransform;fe(i,t.size[0]/2,t.size[1]/2,1/e.resolution,-1/e.resolution,-e.rotation,-e.center[0],-e.center[1]),Na(s,i)}forEachFeatureAtCoordinate(t,e,i,s,r,o,a,l){let h;const c=e.viewState;function u(x,w,R,T){return r.call(o,w,x?R:null,T)}const d=c.projection,f=pa(t.slice(),d),g=[[0,0]];if(d.canWrapX()&&s){const x=d.getExtent(),w=et(x);g.push([-w,0],[w,0])}const m=e.layerStatesArray,_=m.length,p=[],y=[];for(let x=0;x<g.length;x++)for(let w=_-1;w>=0;--w){const R=m[w],T=R.layer;if(T.hasRenderer()&&Or(R,c)&&a.call(l,T)){const S=T.getRenderer(),I=T.getSource();if(S&&I){const M=I.getWrapX()?f:t,O=u.bind(null,R.managed);y[0]=M[0]+g[x][0],y[1]=M[1]+g[x][1],h=S.forEachFeatureAtCoordinate(y,e,i,O,p)}if(h)return h}}if(p.length===0)return;const v=1/p.length;return p.forEach((x,w)=>x.distanceSq+=w*v),p.sort((x,w)=>x.distanceSq-w.distanceSq),p.some(x=>h=x.callback(x.feature,x.layer,x.geometry)),h}hasFeatureAtCoordinate(t,e,i,s,r,o){return this.forEachFeatureAtCoordinate(t,e,i,s,Xi,this,r,o)!==void 0}getMap(){return this.map_}renderFrame(t){H()}scheduleExpireIconCache(t){Ut.canExpireCache()&&t.postRenderFunctions.push(Nf)}}function Nf(n,t){Ut.expire()}class zf extends Ff{constructor(t){super(t),this.fontChangeListenerKey_=$(Si,ri.PROPERTYCHANGE,t.redrawText,t),this.element_=document.createElement("div");const e=this.element_.style;e.position="absolute",e.width="100%",e.height="100%",e.zIndex="0",this.element_.className=rs+" ol-layers";const i=t.getViewport();i.insertBefore(this.element_,i.firstChild||null),this.children_=[],this.renderedVisible_=!0}dispatchRenderEvent(t,e){const i=this.getMap();if(i.hasListener(t)){const s=new Yl(t,void 0,e);i.dispatchEvent(s)}}disposeInternal(){at(this.fontChangeListenerKey_),this.element_.remove(),super.disposeInternal()}renderFrame(t){if(!t){this.renderedVisible_&&(this.element_.style.display="none",this.renderedVisible_=!1);return}this.calculateMatrices2D(t),this.dispatchRenderEvent(Bt.PRECOMPOSE,t);const e=t.layerStatesArray.sort((a,l)=>a.zIndex-l.zIndex);e.some(a=>a.layer instanceof Xl&&a.layer.getDeclutter())&&(t.declutter={});const s=t.viewState;this.children_.length=0;const r=[];let o=null;for(let a=0,l=e.length;a<l;++a){const h=e[a];t.layerIndex=a;const c=h.layer,u=c.getSourceState();if(!Or(h,s)||u!="ready"&&u!="undefined"){c.unrender();continue}const d=c.render(t,o);d&&(d!==o&&(this.children_.push(d),o=d),r.push(h))}this.declutter(t,r),Vu(this.element_,this.children_),this.dispatchRenderEvent(Bt.POSTCOMPOSE,t),this.renderedVisible_||(this.element_.style.display="",this.renderedVisible_=!0),this.scheduleExpireIconCache(t)}declutter(t,e){if(t.declutter){for(let i=e.length-1;i>=0;--i){const s=e[i],r=s.layer;r.getDeclutter()&&r.renderDeclutter(t,s)}e.forEach(i=>i.layer.renderDeferred(t))}}}function Bl(n){if(n instanceof ls){n.setMapInternal(null);return}n instanceof yi&&n.getLayers().forEach(Bl)}function Ul(n,t){if(n instanceof ls){n.setMapInternal(t);return}if(n instanceof yi){const e=n.getLayers().getArray();for(let i=0,s=e.length;i<s;++i)Ul(e[i],t)}}let Gf=class extends ne{constructor(t){super(),t=t||{},this.on,this.once,this.un;const e=Wf(t);this.renderComplete_=!1,this.loaded_=!0,this.boundHandleBrowserEvent_=this.handleBrowserEvent.bind(this),this.maxTilesLoading_=t.maxTilesLoading!==void 0?t.maxTilesLoading:16,this.pixelRatio_=t.pixelRatio!==void 0?t.pixelRatio:pc,this.postRenderTimeoutHandle_,this.animationDelayKey_,this.animationDelay_=this.animationDelay_.bind(this),this.coordinateToPixelTransform_=qt(),this.pixelToCoordinateTransform_=qt(),this.frameIndex_=0,this.frameState_=null,this.previousExtent_=null,this.viewPropertyListenerKey_=null,this.viewChangeListenerKey_=null,this.layerGroupPropertyListenerKeys_=null,this.viewport_=document.createElement("div"),this.viewport_.className="ol-viewport"+("ontouchstart"in window?" ol-touch":""),this.viewport_.style.position="relative",this.viewport_.style.overflow="hidden",this.viewport_.style.width="100%",this.viewport_.style.height="100%",this.overlayContainer_=document.createElement("div"),this.overlayContainer_.style.position="absolute",this.overlayContainer_.style.zIndex="0",this.overlayContainer_.style.width="100%",this.overlayContainer_.style.height="100%",this.overlayContainer_.style.pointerEvents="none",this.overlayContainer_.className="ol-overlaycontainer",this.viewport_.appendChild(this.overlayContainer_),this.overlayContainerStopEvent_=document.createElement("div"),this.overlayContainerStopEvent_.style.position="absolute",this.overlayContainerStopEvent_.style.zIndex="0",this.overlayContainerStopEvent_.style.width="100%",this.overlayContainerStopEvent_.style.height="100%",this.overlayContainerStopEvent_.style.pointerEvents="none",this.overlayContainerStopEvent_.className="ol-overlaycontainer-stopevent",this.viewport_.appendChild(this.overlayContainerStopEvent_),this.mapBrowserEventHandler_=null,this.moveTolerance_=t.moveTolerance,this.keyboardEventTarget_=e.keyboardEventTarget,this.targetChangeHandlerKeys_=null,this.targetElement_=null,this.resizeObserver_=new ResizeObserver(()=>this.updateSize()),this.controls=e.controls||qu(),this.interactions=e.interactions||xd({onFocusOnly:!0}),this.overlays_=e.overlays,this.overlayIdIndex_={},this.renderer_=null,this.postRenderFunctions_=[],this.tileQueue_=new Ec(this.getTilePriority.bind(this),this.handleTileChange_.bind(this)),this.addChangeListener(Rt.LAYERGROUP,this.handleLayerGroupChanged_),this.addChangeListener(Rt.VIEW,this.handleViewChanged_),this.addChangeListener(Rt.SIZE,this.handleSizeChanged_),this.addChangeListener(Rt.TARGET,this.handleTargetChanged_),this.setProperties(e.values);const i=this;t.view&&!(t.view instanceof re)&&t.view.then(function(s){i.setView(new re(s))}),this.controls.addEventListener(Ot.ADD,s=>{s.element.setMap(this)}),this.controls.addEventListener(Ot.REMOVE,s=>{s.element.setMap(null)}),this.interactions.addEventListener(Ot.ADD,s=>{s.element.setMap(this)}),this.interactions.addEventListener(Ot.REMOVE,s=>{s.element.setMap(null)}),this.overlays_.addEventListener(Ot.ADD,s=>{this.addOverlayInternal_(s.element)}),this.overlays_.addEventListener(Ot.REMOVE,s=>{const r=s.element.getId();r!==void 0&&delete this.overlayIdIndex_[r.toString()],s.element.setMap(null)}),this.controls.forEach(s=>{s.setMap(this)}),this.interactions.forEach(s=>{s.setMap(this)}),this.overlays_.forEach(this.addOverlayInternal_.bind(this))}addControl(t){this.getControls().push(t)}addInteraction(t){this.getInteractions().push(t)}addLayer(t){this.getLayerGroup().getLayers().push(t)}handleLayerAdd_(t){Ul(t.layer,this)}addOverlay(t){this.getOverlays().push(t)}addOverlayInternal_(t){const e=t.getId();e!==void 0&&(this.overlayIdIndex_[e.toString()]=t),t.setMap(this)}disposeInternal(){this.controls.clear(),this.interactions.clear(),this.overlays_.clear(),this.resizeObserver_.disconnect(),this.setTarget(null),super.disposeInternal()}forEachFeatureAtPixel(t,e,i){if(!this.frameState_||!this.renderer_)return;const s=this.getCoordinateFromPixelInternal(t);i=i!==void 0?i:{};const r=i.hitTolerance!==void 0?i.hitTolerance:0,o=i.layerFilter!==void 0?i.layerFilter:Xi,a=i.checkWrapped!==!1;return this.renderer_.forEachFeatureAtCoordinate(s,this.frameState_,r,a,e,null,o,null)}getFeaturesAtPixel(t,e){const i=[];return this.forEachFeatureAtPixel(t,function(s){i.push(s)},e),i}getAllLayers(){const t=[];function e(i){i.forEach(function(s){s instanceof yi?e(s.getLayers()):t.push(s)})}return e(this.getLayers()),t}hasFeatureAtPixel(t,e){if(!this.frameState_||!this.renderer_)return!1;const i=this.getCoordinateFromPixelInternal(t);e=e!==void 0?e:{};const s=e.layerFilter!==void 0?e.layerFilter:Xi,r=e.hitTolerance!==void 0?e.hitTolerance:0,o=e.checkWrapped!==!1;return this.renderer_.hasFeatureAtCoordinate(i,this.frameState_,r,o,s,null)}getEventCoordinate(t){return this.getCoordinateFromPixel(this.getEventPixel(t))}getEventCoordinateInternal(t){return this.getCoordinateFromPixelInternal(this.getEventPixel(t))}getEventPixel(t){const i=this.viewport_.getBoundingClientRect(),s=this.getSize(),r=i.width/s[0],o=i.height/s[1],a="changedTouches"in t?t.changedTouches[0]:t;return[(a.clientX-i.left)/r,(a.clientY-i.top)/o]}getTarget(){return this.get(Rt.TARGET)}getTargetElement(){return this.targetElement_}getCoordinateFromPixel(t){return ur(this.getCoordinateFromPixelInternal(t),this.getView().getProjection())}getCoordinateFromPixelInternal(t){const e=this.frameState_;return e?yt(e.pixelToCoordinateTransform,t.slice()):null}getControls(){return this.controls}getOverlays(){return this.overlays_}getOverlayById(t){const e=this.overlayIdIndex_[t.toString()];return e!==void 0?e:null}getInteractions(){return this.interactions}getLayerGroup(){return this.get(Rt.LAYERGROUP)}setLayers(t){const e=this.getLayerGroup();if(t instanceof se){e.setLayers(t);return}const i=e.getLayers();i.clear(),i.extend(t)}getLayers(){return this.getLayerGroup().getLayers()}getLoadingOrNotReady(){const t=this.getLayerGroup().getLayerStatesArray();for(let e=0,i=t.length;e<i;++e){const s=t[e];if(!s.visible)continue;const r=s.layer.getRenderer();if(r&&!r.ready)return!0;const o=s.layer.getSource();if(o&&o.loading)return!0}return!1}getPixelFromCoordinate(t){const e=de(t,this.getView().getProjection());return this.getPixelFromCoordinateInternal(e)}getPixelFromCoordinateInternal(t){const e=this.frameState_;return e?yt(e.coordinateToPixelTransform,t.slice(0,2)):null}getRenderer(){return this.renderer_}getSize(){return this.get(Rt.SIZE)}getView(){return this.get(Rt.VIEW)}getViewport(){return this.viewport_}getOverlayContainer(){return this.overlayContainer_}getOverlayContainerStopEvent(){return this.overlayContainerStopEvent_}getOwnerDocument(){const t=this.getTargetElement();return t?t.ownerDocument:document}getTilePriority(t,e,i,s){return wc(this.frameState_,t,e,i,s)}handleBrowserEvent(t,e){e=e||t.type;const i=new Re(e,this,t);this.handleMapBrowserEvent(i)}handleMapBrowserEvent(t){if(!this.frameState_)return;const e=t.originalEvent,i=e.type;if(i===Bs.POINTERDOWN||i===B.WHEEL||i===B.KEYDOWN){const s=this.getOwnerDocument(),r=this.viewport_.getRootNode?this.viewport_.getRootNode():s,o=e.target,a=r instanceof ShadowRoot?r.host===o?r.host.ownerDocument:r:r===s?s.documentElement:r;if(this.overlayContainerStopEvent_.contains(o)||!a.contains(o))return}if(t.frameState=this.frameState_,this.dispatchEvent(t)!==!1){const s=this.getInteractions().getArray().slice();for(let r=s.length-1;r>=0;r--){const o=s[r];if(o.getMap()!==this||!o.getActive()||!this.getTargetElement())continue;if(!o.handleEvent(t)||t.propagationStopped)break}}}handlePostRender(){const t=this.frameState_,e=this.tileQueue_;if(!e.isEmpty()){let s=this.maxTilesLoading_,r=s;if(t){const o=t.viewHints;if(o[St.ANIMATING]||o[St.INTERACTING]){const a=Date.now()-t.time>8;s=a?0:8,r=a?0:2}}e.getTilesLoading()<s&&(e.reprioritize(),e.loadMoreTiles(s,r))}t&&this.renderer_&&!t.animate&&(this.renderComplete_?(this.hasListener(Bt.RENDERCOMPLETE)&&this.renderer_.dispatchRenderEvent(Bt.RENDERCOMPLETE,t),this.loaded_===!1&&(this.loaded_=!0,this.dispatchEvent(new ai(Se.LOADEND,this,t)))):this.loaded_===!0&&(this.loaded_=!1,this.dispatchEvent(new ai(Se.LOADSTART,this,t))));const i=this.postRenderFunctions_;if(t)for(let s=0,r=i.length;s<r;++s)i[s](this,t);i.length=0}handleSizeChanged_(){this.getView()&&!this.getView().getAnimating()&&this.getView().resolveConstraints(0),this.render()}handleTargetChanged_(){if(this.mapBrowserEventHandler_){for(let i=0,s=this.targetChangeHandlerKeys_.length;i<s;++i)at(this.targetChangeHandlerKeys_[i]);this.targetChangeHandlerKeys_=null,this.viewport_.removeEventListener(B.CONTEXTMENU,this.boundHandleBrowserEvent_),this.viewport_.removeEventListener(B.WHEEL,this.boundHandleBrowserEvent_),this.mapBrowserEventHandler_.dispose(),this.mapBrowserEventHandler_=null,this.viewport_.remove()}if(this.targetElement_){this.resizeObserver_.unobserve(this.targetElement_);const i=this.targetElement_.getRootNode();i instanceof ShadowRoot&&this.resizeObserver_.unobserve(i.host),this.setSize(void 0)}const t=this.getTarget(),e=typeof t=="string"?document.getElementById(t):t;if(this.targetElement_=e,!e)this.renderer_&&(clearTimeout(this.postRenderTimeoutHandle_),this.postRenderTimeoutHandle_=void 0,this.postRenderFunctions_.length=0,this.renderer_.dispose(),this.renderer_=null),this.animationDelayKey_&&(cancelAnimationFrame(this.animationDelayKey_),this.animationDelayKey_=void 0);else{e.appendChild(this.viewport_),this.renderer_||(this.renderer_=new zf(this)),this.mapBrowserEventHandler_=new yc(this,this.moveTolerance_);for(const r in ct)this.mapBrowserEventHandler_.addEventListener(ct[r],this.handleMapBrowserEvent.bind(this));this.viewport_.addEventListener(B.CONTEXTMENU,this.boundHandleBrowserEvent_,!1),this.viewport_.addEventListener(B.WHEEL,this.boundHandleBrowserEvent_,sa?{passive:!1}:!1);let i;if(this.keyboardEventTarget_)i=this.keyboardEventTarget_;else{const r=e.getRootNode();i=r instanceof ShadowRoot?r.host:e}this.targetChangeHandlerKeys_=[$(i,B.KEYDOWN,this.handleBrowserEvent,this),$(i,B.KEYPRESS,this.handleBrowserEvent,this)];const s=e.getRootNode();s instanceof ShadowRoot&&this.resizeObserver_.observe(s.host),this.resizeObserver_.observe(e)}this.updateSize()}handleTileChange_(){this.render()}handleViewPropertyChanged_(){this.render()}handleViewChanged_(){this.viewPropertyListenerKey_&&(at(this.viewPropertyListenerKey_),this.viewPropertyListenerKey_=null),this.viewChangeListenerKey_&&(at(this.viewChangeListenerKey_),this.viewChangeListenerKey_=null);const t=this.getView();t&&(this.updateViewportSize_(this.getSize()),this.viewPropertyListenerKey_=$(t,ri.PROPERTYCHANGE,this.handleViewPropertyChanged_,this),this.viewChangeListenerKey_=$(t,B.CHANGE,this.handleViewPropertyChanged_,this),t.resolveConstraints(0)),this.render()}handleLayerGroupChanged_(){this.layerGroupPropertyListenerKeys_&&(this.layerGroupPropertyListenerKeys_.forEach(at),this.layerGroupPropertyListenerKeys_=null);const t=this.getLayerGroup();t&&(this.handleLayerAdd_(new Le("addlayer",t)),this.layerGroupPropertyListenerKeys_=[$(t,ri.PROPERTYCHANGE,this.render,this),$(t,B.CHANGE,this.render,this),$(t,"addlayer",this.handleLayerAdd_,this),$(t,"removelayer",this.handleLayerRemove_,this)]),this.render()}isRendered(){return!!this.frameState_}animationDelay_(){this.animationDelayKey_=void 0,this.renderFrame_(Date.now())}renderSync(){this.animationDelayKey_&&cancelAnimationFrame(this.animationDelayKey_),this.animationDelay_()}redrawText(){if(!this.frameState_)return;const t=this.frameState_.layerStatesArray;for(let e=0,i=t.length;e<i;++e){const s=t[e].layer;s.hasRenderer()&&s.getRenderer().handleFontsChanged()}}render(){this.renderer_&&this.animationDelayKey_===void 0&&(this.animationDelayKey_=requestAnimationFrame(this.animationDelay_))}removeControl(t){return this.getControls().remove(t)}removeInteraction(t){return this.getInteractions().remove(t)}removeLayer(t){return this.getLayerGroup().getLayers().remove(t)}handleLayerRemove_(t){Bl(t.layer)}removeOverlay(t){return this.getOverlays().remove(t)}renderFrame_(t){const e=this.getSize(),i=this.getView(),s=this.frameState_;let r=null;if(e!==void 0&&ml(e)&&i&&i.isDef()){const o=i.getHints(this.frameState_?this.frameState_.viewHints:void 0),a=i.getState();if(r={animate:!1,coordinateToPixelTransform:this.coordinateToPixelTransform_,declutter:null,extent:$s(a.center,a.resolution,a.rotation,e),index:this.frameIndex_++,layerIndex:0,layerStatesArray:this.getLayerGroup().getLayerStatesArray(),pixelRatio:this.pixelRatio_,pixelToCoordinateTransform:this.pixelToCoordinateTransform_,postRenderFunctions:[],size:e,tileQueue:this.tileQueue_,time:t,usedTiles:{},viewState:a,viewHints:o,wantedTiles:{},mapId:q(this),renderTargets:{}},a.nextCenter&&a.nextResolution){const l=isNaN(a.nextRotation)?a.rotation:a.nextRotation;r.nextExtent=$s(a.nextCenter,a.nextResolution,l,e)}}this.frameState_=r,this.renderer_.renderFrame(r),r&&(r.animate&&this.render(),Array.prototype.push.apply(this.postRenderFunctions_,r.postRenderFunctions),s&&(!this.previousExtent_||!Vn(this.previousExtent_)&&!ji(r.extent,this.previousExtent_))&&(this.dispatchEvent(new ai(Se.MOVESTART,this,s)),this.previousExtent_=Bn(this.previousExtent_)),this.previousExtent_&&!r.viewHints[St.ANIMATING]&&!r.viewHints[St.INTERACTING]&&!ji(r.extent,this.previousExtent_)&&(this.dispatchEvent(new ai(Se.MOVEEND,this,r)),la(r.extent,this.previousExtent_))),this.dispatchEvent(new ai(Se.POSTRENDER,this,r)),this.renderComplete_=(this.hasListener(Se.LOADSTART)||this.hasListener(Se.LOADEND)||this.hasListener(Bt.RENDERCOMPLETE))&&!this.tileQueue_.getTilesLoading()&&!this.tileQueue_.getCount()&&!this.getLoadingOrNotReady(),this.postRenderTimeoutHandle_||(this.postRenderTimeoutHandle_=setTimeout(()=>{this.postRenderTimeoutHandle_=void 0,this.handlePostRender()},0))}setLayerGroup(t){const e=this.getLayerGroup();e&&this.handleLayerRemove_(new Le("removelayer",e)),this.set(Rt.LAYERGROUP,t)}setSize(t){this.set(Rt.SIZE,t)}setTarget(t){this.set(Rt.TARGET,t)}setView(t){if(!t||t instanceof re){this.set(Rt.VIEW,t);return}this.set(Rt.VIEW,new re);const e=this;t.then(function(i){e.setView(new re(i))})}updateSize(){const t=this.getTargetElement();let e;if(t){const s=getComputedStyle(t),r=t.offsetWidth-parseFloat(s.borderLeftWidth)-parseFloat(s.paddingLeft)-parseFloat(s.paddingRight)-parseFloat(s.borderRightWidth),o=t.offsetHeight-parseFloat(s.borderTopWidth)-parseFloat(s.paddingTop)-parseFloat(s.paddingBottom)-parseFloat(s.borderBottomWidth);!isNaN(r)&&!isNaN(o)&&(e=[Math.max(0,r),Math.max(0,o)],!ml(e)&&(t.offsetWidth||t.offsetHeight||t.getClientRects().length)&&Ea("No map visible because the map container's width or height are 0."))}const i=this.getSize();e&&(!i||!Ce(e,i))&&(this.setSize(e),this.updateViewportSize_(e))}updateViewportSize_(t){const e=this.getView();e&&e.setViewportSize(t)}};function Wf(n){let t=null;n.keyboardEventTarget!==void 0&&(t=typeof n.keyboardEventTarget=="string"?document.getElementById(n.keyboardEventTarget):n.keyboardEventTarget);const e={},i=n.layers&&typeof n.layers.getLayers=="function"?n.layers:new yi({layers:n.layers});e[Rt.LAYERGROUP]=i,e[Rt.TARGET]=n.target,e[Rt.VIEW]=n.view instanceof re?n.view:new re;let s;n.controls!==void 0&&(Array.isArray(n.controls)?s=new se(n.controls.slice()):(Q(typeof n.controls.getArray=="function","Expected `controls` to be an array or an `ol/Collection.js`"),s=n.controls));let r;n.interactions!==void 0&&(Array.isArray(n.interactions)?r=new se(n.interactions.slice()):(Q(typeof n.interactions.getArray=="function","Expected `interactions` to be an array or an `ol/Collection.js`"),r=n.interactions));let o;return n.overlays!==void 0?Array.isArray(n.overlays)?o=new se(n.overlays.slice()):(Q(typeof n.overlays.getArray=="function","Expected `overlays` to be an array or an `ol/Collection.js`"),o=n.overlays):o=new se,{controls:s,interactions:r,keyboardEventTarget:t,overlays:o,values:e}}class to extends Fn{constructor(t,e,i){super(),i=i||{},this.tileCoord=t,this.state=e,this.key="",this.transition_=i.transition===void 0?250:i.transition,this.transitionStarts_={},this.interpolate=!!i.interpolate}changed(){this.dispatchEvent(B.CHANGE)}release(){this.setState(N.EMPTY)}getKey(){return this.key+"/"+this.tileCoord}getTileCoord(){return this.tileCoord}getState(){return this.state}setState(t){if(this.state!==N.EMPTY){if(this.state!==N.ERROR&&this.state>t)throw new Error("Tile load sequence violation");this.state=t,this.changed()}}load(){H()}getAlpha(t,e){if(!this.transition_)return 1;let i=this.transitionStarts_[t];if(!i)i=e,this.transitionStarts_[t]=i;else if(i===-1)return 1;const s=e-i+1e3/60;return s>=this.transition_?1:ya(s/this.transition_)}inTransition(t){return this.transition_?this.transitionStarts_[t]!==-1:!1}endTransition(t){this.transition_&&(this.transitionStarts_[t]=-1)}disposeInternal(){this.release(),super.disposeInternal()}}function eo(n){return n instanceof Image||n instanceof HTMLCanvasElement||n instanceof HTMLVideoElement||n instanceof ImageBitmap?n:null}const Xf=new Error("disposed"),Yf=[256,256];class Kl extends to{constructor(t){const e=N.IDLE;super(t.tileCoord,e,{transition:t.transition,interpolate:t.interpolate}),this.loader_=t.loader,this.data_=null,this.error_=null,this.size_=t.size||null,this.controller_=t.controller||null}getSize(){if(this.size_)return this.size_;const t=eo(this.data_);return t?[t.width,t.height]:Yf}getData(){return this.data_}getError(){return this.error_}load(){if(this.state!==N.IDLE&&this.state!==N.ERROR)return;this.state=N.LOADING,this.changed();const t=this;this.loader_().then(function(e){t.data_=e,t.state=N.LOADED,t.changed()}).catch(function(e){t.error_=e,t.state=N.ERROR,t.changed()})}disposeInternal(){this.controller_&&(this.controller_.abort(Xf),this.controller_=null),super.disposeInternal()}}class jl extends to{constructor(t,e,i,s,r,o){super(t,e,o),this.crossOrigin_=s,this.src_=i,this.key=i,this.image_=new Image,s!==null&&(this.image_.crossOrigin=s),this.unlisten_=null,this.tileLoadFunction_=r}getImage(){return this.image_}setImage(t){this.image_=t,this.state=N.LOADED,this.unlistenImage_(),this.changed()}handleImageError_(){this.state=N.ERROR,this.unlistenImage_(),this.image_=Bf(),this.changed()}handleImageLoad_(){const t=this.image_;t.naturalWidth&&t.naturalHeight?this.state=N.LOADED:this.state=N.EMPTY,this.unlistenImage_(),this.changed()}load(){this.state==N.ERROR&&(this.state=N.IDLE,this.image_=new Image,this.crossOrigin_!==null&&(this.image_.crossOrigin=this.crossOrigin_)),this.state==N.IDLE&&(this.state=N.LOADING,this.changed(),this.tileLoadFunction_(this,this.src_),this.unlisten_=af(this.image_,this.handleImageLoad_.bind(this),this.handleImageError_.bind(this)))}unlistenImage_(){this.unlisten_&&(this.unlisten_(),this.unlisten_=null)}disposeInternal(){this.unlistenImage_(),this.image_=null,super.disposeInternal()}}function Bf(){const n=gt(1,1);return n.fillStyle="rgba(0,0,0,0)",n.fillRect(0,0,1,1),n.canvas}class io{constructor(t,e,i,s){this.minX=t,this.maxX=e,this.minY=i,this.maxY=s}contains(t){return this.containsXY(t[1],t[2])}containsTileRange(t){return this.minX<=t.minX&&t.maxX<=this.maxX&&this.minY<=t.minY&&t.maxY<=this.maxY}containsXY(t,e){return this.minX<=t&&t<=this.maxX&&this.minY<=e&&e<=this.maxY}equals(t){return this.minX==t.minX&&this.minY==t.minY&&this.maxX==t.maxX&&this.maxY==t.maxY}extend(t){t.minX<this.minX&&(this.minX=t.minX),t.maxX>this.maxX&&(this.maxX=t.maxX),t.minY<this.minY&&(this.minY=t.minY),t.maxY>this.maxY&&(this.maxY=t.maxY)}getHeight(){return this.maxY-this.minY+1}getSize(){return[this.getWidth(),this.getHeight()]}getWidth(){return this.maxX-this.minX+1}intersects(t){return this.minX<=t.maxX&&this.maxX>=t.minX&&this.minY<=t.maxY&&this.maxY>=t.minY}}function Ti(n,t,e,i,s){return s!==void 0?(s.minX=n,s.maxX=t,s.minY=e,s.maxY=i,s):new io(n,t,e,i)}let no;const bi=[];function Vl(n,t,e,i,s){n.beginPath(),n.moveTo(0,0),n.lineTo(t,e),n.lineTo(i,s),n.closePath(),n.save(),n.clip(),n.fillRect(0,0,Math.max(t,i)+1,Math.max(e,s)),n.restore()}function so(n,t){return Math.abs(n[t*4]-210)>2||Math.abs(n[t*4+3]-.75*255)>2}function Uf(){if(no===void 0){const n=gt(6,6,bi);n.globalCompositeOperation="lighter",n.fillStyle="rgba(210, 0, 0, 0.75)",Vl(n,4,5,4,0),Vl(n,4,5,0,5);const t=n.getImageData(0,0,3,3).data;no=so(t,0)||so(t,4)||so(t,8),as(n),bi.push(n.canvas)}return no}function Zl(n,t,e,i){const s=cr(e,t,n);let r=Da(t,i,e);const o=t.getMetersPerUnit();o!==void 0&&(r*=o);const a=n.getMetersPerUnit();a!==void 0&&(r/=a);const l=n.getExtent();if(!l||ci(l,s)){const h=Da(n,r,s)/r;isFinite(h)&&h>0&&(r/=h)}return r}function Kf(n,t,e,i){const s=Ye(e);let r=Zl(n,t,s,i);return(!isFinite(r)||r<=0)&&fa(e,function(o){return r=Zl(n,t,o,i),isFinite(r)&&r>0}),r}function jf(n,t,e,i,s,r,o,a,l,h,c,u,d,f){const g=gt(Math.round(e*n),Math.round(e*t),bi);if(u||(g.imageSmoothingEnabled=!1),l.length===0)return g.canvas;g.scale(e,e);function m(w){return Math.round(w*e)/e}g.globalCompositeOperation="lighter";const _=Xt();l.forEach(function(w,R,T){Sc(_,w.extent)});let p;const y=e/i,v=(u?1:1+Math.pow(2,-24))/y;p=gt(Math.round(et(_)*y),Math.round(It(_)*y),bi),u||(p.imageSmoothingEnabled=!1),l.forEach(function(w,R,T){if(w.image.width>0&&w.image.height>0){if(w.clipExtent){p.save();const L=(w.clipExtent[0]-_[0])*y,A=-(w.clipExtent[3]-_[3])*y,P=et(w.clipExtent)*y,X=It(w.clipExtent)*y;p.rect(u?L:Math.round(L),u?A:Math.round(A),u?P:Math.round(L+P)-Math.round(L),u?X:Math.round(A+X)-Math.round(A)),p.clip()}const S=(w.extent[0]-_[0])*y,I=-(w.extent[3]-_[3])*y,M=et(w.extent)*y,O=It(w.extent)*y;p.drawImage(w.image,h,h,w.image.width-2*h,w.image.height-2*h,u?S:Math.round(S),u?I:Math.round(I),u?M:Math.round(S+M)-Math.round(S),u?O:Math.round(I+O)-Math.round(I)),w.clipExtent&&p.restore()}});const x=Ue(o);return a.getTriangles().forEach(function(w,R,T){const S=w.source,I=w.target;let M=S[0][0],O=S[0][1],L=S[1][0],A=S[1][1],P=S[2][0],X=S[2][1];const k=m((I[0][0]-x[0])/r),G=m(-(I[0][1]-x[1])/r),D=m((I[1][0]-x[0])/r),Y=m(-(I[1][1]-x[1])/r),V=m((I[2][0]-x[0])/r),tt=m(-(I[2][1]-x[1])/r),b=M,xt=O;M=0,O=0,L-=b,A-=xt,P-=b,X-=xt;const ft=[[L,A,0,0,D-k],[P,X,0,0,V-k],[0,0,L,A,Y-G],[0,0,P,X,tt-G]],ht=Cc(ft);if(!ht)return;if(g.save(),g.beginPath(),Uf()||!u){g.moveTo(D,Y);const Et=4,jt=k-D,Gt=G-Y;for(let Mt=0;Mt<Et;Mt++)g.lineTo(D+m((Mt+1)*jt/Et),Y+m(Mt*Gt/(Et-1))),Mt!=Et-1&&g.lineTo(D+m((Mt+1)*jt/Et),Y+m((Mt+1)*Gt/(Et-1)));g.lineTo(V,tt)}else g.moveTo(D,Y),g.lineTo(k,G),g.lineTo(V,tt);g.clip(),g.transform(ht[0],ht[2],ht[1],ht[3],k,G),g.translate(_[0]-b,_[3]-xt);let bt;if(p)bt=p.canvas,g.scale(v,-v);else{const Et=l[0],jt=Et.extent;bt=Et.image,g.scale(et(jt)/bt.width,-It(jt)/bt.height)}g.drawImage(bt,0,0),g.restore()}),p&&(as(p),bi.push(p.canvas)),c&&(g.save(),g.globalCompositeOperation="source-over",g.strokeStyle="black",g.lineWidth=1,a.getTriangles().forEach(function(w,R,T){const S=w.target,I=(S[0][0]-x[0])/r,M=-(S[0][1]-x[1])/r,O=(S[1][0]-x[0])/r,L=-(S[1][1]-x[1])/r,A=(S[2][0]-x[0])/r,P=-(S[2][1]-x[1])/r;g.beginPath(),g.moveTo(O,L),g.lineTo(I,M),g.lineTo(A,P),g.closePath(),g.stroke()}),g.restore()),g.canvas}const Vf=10,$l=.25;class Zf{constructor(t,e,i,s,r,o,a){this.sourceProj_=t,this.targetProj_=e;let l={};const h=a?lu(v=>yt(a,cr(v,this.targetProj_,this.sourceProj_))):ts(this.targetProj_,this.sourceProj_);this.transformInv_=function(v){const x=v[0]+"/"+v[1];return l[x]||(l[x]=h(v)),l[x]},this.maxSourceExtent_=s,this.errorThresholdSquared_=r*r,this.triangles_=[],this.wrapsXInSource_=!1,this.canWrapXInSource_=this.sourceProj_.canWrapX()&&!!s&&!!this.sourceProj_.getExtent()&&et(s)>=et(this.sourceProj_.getExtent()),this.sourceWorldWidth_=this.sourceProj_.getExtent()?et(this.sourceProj_.getExtent()):null,this.targetWorldWidth_=this.targetProj_.getExtent()?et(this.targetProj_.getExtent()):null;const c=Ue(i),u=jn(i),d=Kn(i),f=Un(i),g=this.transformInv_(c),m=this.transformInv_(u),_=this.transformInv_(d),p=this.transformInv_(f),y=Vf+(o?Math.max(0,Math.ceil(Math.log2(Zs(i)/(o*o*256*256)))):0);if(this.addQuad_(c,u,d,f,g,m,_,p,y),this.wrapsXInSource_){let v=1/0;this.triangles_.forEach(function(x,w,R){v=Math.min(v,x.source[0][0],x.source[1][0],x.source[2][0])}),this.triangles_.forEach(x=>{if(Math.max(x.source[0][0],x.source[1][0],x.source[2][0])-v>this.sourceWorldWidth_/2){const w=[[x.source[0][0],x.source[0][1]],[x.source[1][0],x.source[1][1]],[x.source[2][0],x.source[2][1]]];w[0][0]-v>this.sourceWorldWidth_/2&&(w[0][0]-=this.sourceWorldWidth_),w[1][0]-v>this.sourceWorldWidth_/2&&(w[1][0]-=this.sourceWorldWidth_),w[2][0]-v>this.sourceWorldWidth_/2&&(w[2][0]-=this.sourceWorldWidth_);const R=Math.min(w[0][0],w[1][0],w[2][0]);Math.max(w[0][0],w[1][0],w[2][0])-R<this.sourceWorldWidth_/2&&(x.source=w)}})}l={}}addTriangle_(t,e,i,s,r,o){this.triangles_.push({source:[s,r,o],target:[t,e,i]})}addQuad_(t,e,i,s,r,o,a,l,h){const c=aa([r,o,a,l]),u=this.sourceWorldWidth_?et(c)/this.sourceWorldWidth_:null,d=this.sourceWorldWidth_,f=this.sourceProj_.canWrapX()&&u>.5&&u<1;let g=!1;if(h>0){if(this.targetProj_.isGlobal()&&this.targetWorldWidth_){const _=aa([t,e,i,s]);g=et(_)/this.targetWorldWidth_>$l||g}!f&&this.sourceProj_.isGlobal()&&u&&(g=u>$l||g)}if(!g&&this.maxSourceExtent_&&isFinite(c[0])&&isFinite(c[1])&&isFinite(c[2])&&isFinite(c[3])&&!Pt(c,this.maxSourceExtent_))return;let m=0;if(!g&&(!isFinite(r[0])||!isFinite(r[1])||!isFinite(o[0])||!isFinite(o[1])||!isFinite(a[0])||!isFinite(a[1])||!isFinite(l[0])||!isFinite(l[1]))){if(h>0)g=!0;else if(m=(!isFinite(r[0])||!isFinite(r[1])?8:0)+(!isFinite(o[0])||!isFinite(o[1])?4:0)+(!isFinite(a[0])||!isFinite(a[1])?2:0)+(!isFinite(l[0])||!isFinite(l[1])?1:0),m!=1&&m!=2&&m!=4&&m!=8)return}if(h>0){if(!g){const _=[(t[0]+i[0])/2,(t[1]+i[1])/2],p=this.transformInv_(_);let y;f?y=(hi(r[0],d)+hi(a[0],d))/2-hi(p[0],d):y=(r[0]+a[0])/2-p[0];const v=(r[1]+a[1])/2-p[1];g=y*y+v*v>this.errorThresholdSquared_}if(g){if(Math.abs(t[0]-i[0])<=Math.abs(t[1]-i[1])){const _=[(e[0]+i[0])/2,(e[1]+i[1])/2],p=this.transformInv_(_),y=[(s[0]+t[0])/2,(s[1]+t[1])/2],v=this.transformInv_(y);this.addQuad_(t,e,_,y,r,o,p,v,h-1),this.addQuad_(y,_,i,s,v,p,a,l,h-1)}else{const _=[(t[0]+e[0])/2,(t[1]+e[1])/2],p=this.transformInv_(_),y=[(i[0]+s[0])/2,(i[1]+s[1])/2],v=this.transformInv_(y);this.addQuad_(t,_,y,s,r,p,v,l,h-1),this.addQuad_(_,e,i,y,p,o,a,v,h-1)}return}}if(f){if(!this.canWrapXInSource_)return;this.wrapsXInSource_=!0}(m&11)==0&&this.addTriangle_(t,i,s,r,a,l),(m&14)==0&&this.addTriangle_(t,i,e,r,a,o),m&&((m&13)==0&&this.addTriangle_(e,s,t,o,l,r),(m&7)==0&&this.addTriangle_(e,s,i,o,l,a))}calculateSourceExtent(){const t=Xt();return this.triangles_.forEach(function(e,i,s){const r=e.source;Vi(t,r[0]),Vi(t,r[1]),Vi(t,r[2])}),t}getTriangles(){return this.triangles_}}const $f=.5;class Hl extends to{constructor(t,e,i,s,r,o,a,l,h,c,u,d){super(r,N.IDLE,d),this.renderEdges_=u!==void 0?u:!1,this.pixelRatio_=a,this.gutter_=l,this.canvas_=null,this.sourceTileGrid_=e,this.targetTileGrid_=s,this.wrappedTileCoord_=o||r,this.sourceTiles_=[],this.sourcesListenerKeys_=null,this.sourceZ_=0,this.clipExtent_=t.canWrapX()?t.getExtent():void 0;const f=s.getTileCoordExtent(this.wrappedTileCoord_),g=this.targetTileGrid_.getExtent();let m=this.sourceTileGrid_.getExtent();const _=g?Be(f,g):f;if(Zs(_)===0){this.state=N.EMPTY;return}const p=t.getExtent();p&&(m?m=Be(m,p):m=p);const y=s.getResolution(this.wrappedTileCoord_[0]),v=Kf(t,i,_,y);if(!isFinite(v)||v<=0){this.state=N.EMPTY;return}const x=c!==void 0?c:$f;if(this.triangulation_=new Zf(t,i,_,m,v*x,y),this.triangulation_.getTriangles().length===0){this.state=N.EMPTY;return}this.sourceZ_=e.getZForResolution(v);let w=this.triangulation_.calculateSourceExtent();if(m&&(t.canWrapX()?(w[1]=lt(w[1],m[1],m[3]),w[3]=lt(w[3],m[1],m[3])):w=Be(w,m)),!Zs(w))this.state=N.EMPTY;else{let R=0,T=0;t.canWrapX()&&(R=et(p),T=Math.floor((w[0]-p[0])/R)),ma(w.slice(),t,!0).forEach(I=>{const M=e.getTileRangeForExtentAndZ(I,this.sourceZ_);for(let O=M.minX;O<=M.maxX;O++)for(let L=M.minY;L<=M.maxY;L++){const A=h(this.sourceZ_,O,L,a);if(A){const P=T*R;this.sourceTiles_.push({tile:A,offset:P})}}++T}),this.sourceTiles_.length===0&&(this.state=N.EMPTY)}}getImage(){return this.canvas_}reproject_(){const t=[];if(this.sourceTiles_.forEach(e=>{const i=e.tile;if(i&&i.getState()==N.LOADED){const s=this.sourceTileGrid_.getTileCoordExtent(i.tileCoord);s[0]+=e.offset,s[2]+=e.offset;const r=this.clipExtent_?.slice();r&&(r[0]+=e.offset,r[2]+=e.offset),t.push({extent:s,clipExtent:r,image:i.getImage()})}}),this.sourceTiles_.length=0,t.length===0)this.state=N.ERROR;else{const e=this.wrappedTileCoord_[0],i=this.targetTileGrid_.getTileSize(e),s=typeof i=="number"?i:i[0],r=typeof i=="number"?i:i[1],o=this.targetTileGrid_.getResolution(e),a=this.sourceTileGrid_.getResolution(this.sourceZ_),l=this.targetTileGrid_.getTileCoordExtent(this.wrappedTileCoord_);this.canvas_=jf(s,r,this.pixelRatio_,a,this.sourceTileGrid_.getExtent(),o,l,this.triangulation_,t,this.gutter_,this.renderEdges_,this.interpolate),this.state=N.LOADED}this.changed()}load(){if(this.state==N.IDLE){this.state=N.LOADING,this.changed();let t=0;this.sourcesListenerKeys_=[],this.sourceTiles_.forEach(({tile:e})=>{const i=e.getState();if(i==N.IDLE||i==N.LOADING){t++;const s=$(e,B.CHANGE,r=>{const o=e.getState();(o==N.LOADED||o==N.ERROR||o==N.EMPTY)&&(at(s),t--,t===0&&(this.unlistenSources_(),this.reproject_()))});this.sourcesListenerKeys_.push(s)}}),t===0?setTimeout(this.reproject_.bind(this),0):this.sourceTiles_.forEach(function({tile:e},i,s){e.getState()==N.IDLE&&e.load()})}}unlistenSources_(){this.sourcesListenerKeys_.forEach(at),this.sourcesListenerKeys_=null}release(){this.canvas_&&(as(this.canvas_.getContext("2d")),bi.push(this.canvas_),this.canvas_=null),super.release()}}class Hf{constructor(t){this.highWaterMark=t!==void 0?t:2048,this.count_=0,this.entries_={},this.oldest_=null,this.newest_=null}deleteOldest(){const t=this.pop();t instanceof Dn&&t.dispose()}canExpireCache(){return this.highWaterMark>0&&this.getCount()>this.highWaterMark}expireCache(t){for(;this.canExpireCache();)this.deleteOldest()}clear(){for(;this.oldest_;)this.deleteOldest()}containsKey(t){return this.entries_.hasOwnProperty(t)}forEach(t){let e=this.oldest_;for(;e;)t(e.value_,e.key_,this),e=e.newer}get(t,e){const i=this.entries_[t];return Q(i!==void 0,"Tried to get a value for a key that does not exist in the cache"),i===this.newest_||(i===this.oldest_?(this.oldest_=this.oldest_.newer,this.oldest_.older=null):(i.newer.older=i.older,i.older.newer=i.newer),i.newer=null,i.older=this.newest_,this.newest_.newer=i,this.newest_=i),i.value_}remove(t){const e=this.entries_[t];return Q(e!==void 0,"Tried to get a value for a key that does not exist in the cache"),e===this.newest_?(this.newest_=e.older,this.newest_&&(this.newest_.newer=null)):e===this.oldest_?(this.oldest_=e.newer,this.oldest_&&(this.oldest_.older=null)):(e.newer.older=e.older,e.older.newer=e.newer),delete this.entries_[t],--this.count_,e.value_}getCount(){return this.count_}getKeys(){const t=new Array(this.count_);let e=0,i;for(i=this.newest_;i;i=i.older)t[e++]=i.key_;return t}getValues(){const t=new Array(this.count_);let e=0,i;for(i=this.newest_;i;i=i.older)t[e++]=i.value_;return t}peekLast(){return this.oldest_.value_}peekLastKey(){return this.oldest_.key_}peekFirstKey(){return this.newest_.key_}peek(t){return this.entries_[t]?.value_}pop(){const t=this.oldest_;return delete this.entries_[t.key_],t.newer&&(t.newer.older=null),this.oldest_=t.newer,this.oldest_||(this.newest_=null),--this.count_,t.value_}replace(t,e){this.get(t),this.entries_[t].value_=e}set(t,e){Q(!(t in this.entries_),"Tried to set a value for a key that is used already");const i={key_:t,newer:null,older:this.newest_,value_:e};this.newest_?this.newest_.newer=i:this.oldest_=i,this.newest_=i,this.entries_[t]=i,++this.count_}setSize(t){this.highWaterMark=t}}function vs(n,t,e,i){return i!==void 0?(i[0]=n,i[1]=t,i[2]=e,i):[n,t,e]}function qf(n,t,e){return n+"/"+t+"/"+e}function Jf(n){return Qf(n[0],n[1],n[2])}function Qf(n,t,e){return(t<<n)+e}function tg(n,t){const e=n[0],i=n[1],s=n[2];if(t.getMinZoom()>e||e>t.getMaxZoom())return!1;const r=t.getFullTileRange(e);return r?r.containsXY(i,s):!0}class ql{constructor(){this.instructions_=[],this.zIndex=0,this.offset_=0,this.context_=new Proxy(os(),{get:(t,e)=>{if(typeof os()[e]=="function")return this.push_(e),this.pushMethodArgs_},set:(t,e,i)=>(this.push_(e,i),!0)})}push_(...t){const e=this.instructions_,i=this.zIndex+this.offset_;e[i]||(e[i]=[]),e[i].push(...t)}pushMethodArgs_=(...t)=>(this.push_(t),this);pushFunction(t){this.push_(t)}getContext(){return this.context_}draw(t){this.instructions_.forEach(e=>{for(let i=0,s=e.length;i<s;++i){const r=e[i];if(typeof r=="function"){r(t);continue}const o=e[++i];if(typeof t[r]=="function")t[r](...o);else{if(typeof o=="function"){t[r]=o(t);continue}t[r]=o}}})}clear(){this.instructions_.length=0,this.zIndex=0,this.offset_=0}offset(){this.offset_=this.instructions_.length,this.zIndex=0}}const eg=5;class ig extends Ui{constructor(t){super(),this.ready=!0,this.boundHandleImageChange_=this.handleImageChange_.bind(this),this.layer_=t,this.staleKeys_=new Array,this.maxStaleKeys=eg}getStaleKeys(){return this.staleKeys_}prependStaleKey(t){this.staleKeys_.unshift(t),this.staleKeys_.length>this.maxStaleKeys&&(this.staleKeys_.length=this.maxStaleKeys)}getFeatures(t){return H()}getData(t){return null}prepareFrame(t){return H()}renderFrame(t,e){return H()}forEachFeatureAtCoordinate(t,e,i,s,r){}getLayer(){return this.layer_}handleFontsChanged(){}handleImageChange_(t){const e=t.target;(e.getState()===K.LOADED||e.getState()===K.ERROR)&&this.renderIfReadyAndVisible()}loadImage(t){let e=t.getState();return e!=K.LOADED&&e!=K.ERROR&&t.addEventListener(B.CHANGE,this.boundHandleImageChange_),e==K.IDLE&&(t.load(),e=t.getState()),e==K.LOADED}renderIfReadyAndVisible(){const t=this.getLayer();t&&t.getVisible()&&t.getSourceState()==="ready"&&t.changed()}renderDeferred(t){}disposeInternal(){delete this.layer_,super.disposeInternal()}}const Jl=[];let Mi=null;function ng(){Mi=gt(1,1,void 0,{willReadFrequently:!0})}class Ql extends ig{constructor(t){super(t),this.container=null,this.renderedResolution,this.tempTransform=qt(),this.pixelTransform=qt(),this.inversePixelTransform=qt(),this.context=null,this.deferredContext_=null,this.containerReused=!1,this.frameState=null}getImageData(t,e,i){Mi||ng(),Mi.clearRect(0,0,1,1);let s;try{Mi.drawImage(t,e,i,1,1,0,0,1,1),s=Mi.getImageData(0,0,1,1).data}catch{return Mi=null,null}return s}getBackground(t){let i=this.getLayer().getBackground();return typeof i=="function"&&(i=i(t.viewState.resolution)),i||void 0}useContainer(t,e,i){const s=this.getLayer().getClassName();let r,o;if(t&&t.className===s&&(!i||t&&t.style.backgroundColor&&Ce(wi(t.style.backgroundColor),wi(i)))){const a=t.firstElementChild;a instanceof HTMLCanvasElement&&(o=a.getContext("2d"))}if(o&&_u(o.canvas.style.transform,e)?(this.container=t,this.context=o,this.containerReused=!0):this.containerReused?(this.container=null,this.context=null,this.containerReused=!1):this.container&&(this.container.style.backgroundColor=null),!this.container){r=document.createElement("div"),r.className=s;let a=r.style;a.position="absolute",a.width="100%",a.height="100%",o=gt();const l=o.canvas;r.appendChild(l),a=l.style,a.position="absolute",a.left="0",a.transformOrigin="top left",this.container=r,this.context=o}!this.containerReused&&i&&!this.container.style.backgroundColor&&(this.container.style.backgroundColor=i)}clipUnrotated(t,e,i){const s=Ue(i),r=jn(i),o=Kn(i),a=Un(i);yt(e.coordinateToPixelTransform,s),yt(e.coordinateToPixelTransform,r),yt(e.coordinateToPixelTransform,o),yt(e.coordinateToPixelTransform,a);const l=this.inversePixelTransform;yt(l,s),yt(l,r),yt(l,o),yt(l,a),t.save(),t.beginPath(),t.moveTo(Math.round(s[0]),Math.round(s[1])),t.lineTo(Math.round(r[0]),Math.round(r[1])),t.lineTo(Math.round(o[0]),Math.round(o[1])),t.lineTo(Math.round(a[0]),Math.round(a[1])),t.clip()}prepareContainer(t,e){const i=t.extent,s=t.viewState.resolution,r=t.viewState.rotation,o=t.pixelRatio,a=Math.round(et(i)/s*o),l=Math.round(It(i)/s*o);fe(this.pixelTransform,t.size[0]/2,t.size[1]/2,1/o,1/o,r,-a/2,-l/2),Na(this.inversePixelTransform,this.pixelTransform);const h=gu(this.pixelTransform);if(this.useContainer(e,h,this.getBackground(t)),!this.containerReused){const c=this.context.canvas;c.width!=a||c.height!=l?(c.width=a,c.height=l):this.context.clearRect(0,0,a,l),h!==c.style.transform&&(c.style.transform=h)}}dispatchRenderEvent_(t,e,i){const s=this.getLayer();if(s.hasListener(t)){const r=new Yl(t,this.inversePixelTransform,i,e);s.dispatchEvent(r)}}preRender(t,e){this.frameState=e,!e.declutter&&this.dispatchRenderEvent_(Bt.PRERENDER,t,e)}postRender(t,e){e.declutter||this.dispatchRenderEvent_(Bt.POSTRENDER,t,e)}renderDeferredInternal(t){}getRenderContext(t){return t.declutter&&!this.deferredContext_&&(this.deferredContext_=new ql),t.declutter?this.deferredContext_.getContext():this.context}renderDeferred(t){t.declutter&&(this.dispatchRenderEvent_(Bt.PRERENDER,this.context,t),t.declutter&&this.deferredContext_&&(this.deferredContext_.draw(this.context),this.deferredContext_.clear()),this.renderDeferredInternal(t),this.dispatchRenderEvent_(Bt.POSTRENDER,this.context,t))}getRenderTransform(t,e,i,s,r,o,a){const l=r/2,h=o/2,c=s/e,u=-c,d=-t[0]+a,f=-t[1];return fe(this.tempTransform,l,h,c,u,-i,d,f)}disposeInternal(){delete this.frameState,super.disposeInternal()}}function ro(n,t,e,i,s){return`${q(n)},${t},${qf(e,i,s)}`}function oo(n,t,e){if(!(e in n))return n[e]=new Set([t]),!0;const i=n[e],s=i.has(t);return s||i.add(t),!s}function sg(n,t,e){const i=n[e];return i?i.delete(t):!1}function th(n,t){const e=n.layerStatesArray[n.layerIndex];e.extent&&(t=Be(t,be(e.extent,n.viewState.projection)));const i=e.layer.getRenderSource();if(!i.getWrapX()){const s=i.getTileGridForProjection(n.viewState.projection).getExtent();s&&(t=Be(t,s))}return t}class rg extends Ql{constructor(t,e){super(t),e=e||{},this.extentChanged=!0,this.renderComplete=!1,this.renderedExtent_=null,this.renderedPixelRatio,this.renderedProjection=null,this.renderedTiles=[],this.renderedSourceKey_,this.renderedSourceRevision_,this.tempExtent=Xt(),this.tempTileRange_=new io(0,0,0,0),this.tempTileCoord_=vs(0,0,0);const i=e.cacheSize!==void 0?e.cacheSize:512;this.tileCache_=new Hf(i),this.maxStaleKeys=i*.5}getTileCache(){return this.tileCache_}getOrCreateTile(t,e,i,s){const r=this.tileCache_,a=this.getLayer().getSource(),l=ro(a,a.getKey(),t,e,i);let h;if(r.containsKey(l))h=r.get(l);else{if(h=a.getTile(t,e,i,s.pixelRatio,s.viewState.projection),!h)return null;r.set(l,h)}return h}getTile(t,e,i,s){const r=this.getOrCreateTile(t,e,i,s);return r||null}getData(t){const e=this.frameState;if(!e)return null;const i=this.getLayer(),s=yt(e.pixelToCoordinateTransform,t.slice()),r=i.getExtent();if(r&&!ci(r,s))return null;const o=e.viewState,a=i.getRenderSource(),l=a.getTileGridForProjection(o.projection),h=a.getTilePixelRatio(e.pixelRatio);for(let c=l.getZForResolution(o.resolution);c>=l.getMinZoom();--c){const u=l.getTileCoordForCoordAndZ(s,c),d=this.getTile(c,u[1],u[2],e);if(!d||d.getState()!==N.LOADED)continue;const f=l.getOrigin(c),g=kt(l.getTileSize(c)),m=l.getResolution(c);let _;if(d instanceof jl||d instanceof Hl)_=d.getImage();else if(d instanceof Kl){if(_=eo(d.getData()),!_)continue}else continue;const p=Math.floor(h*((s[0]-f[0])/m-u[1]*g[0])),y=Math.floor(h*((f[1]-s[1])/m-u[2]*g[1])),v=Math.round(h*a.getGutterForProjection(o.projection));return this.getImageData(_,p+v,y+v)}return null}prepareFrame(t){this.renderedProjection?t.viewState.projection!==this.renderedProjection&&(this.tileCache_.clear(),this.renderedProjection=t.viewState.projection):this.renderedProjection=t.viewState.projection;const e=this.getLayer().getSource();if(!e)return!1;const i=e.getRevision();return this.renderedSourceRevision_?this.renderedSourceRevision_!==i&&(this.renderedSourceRevision_=i,this.renderedSourceKey_===e.getKey()&&this.tileCache_.clear()):this.renderedSourceRevision_=i,!0}enqueueTiles(t,e,i,s,r){const o=t.viewState,a=this.getLayer(),l=a.getRenderSource(),h=l.getTileGridForProjection(o.projection),c=q(l);c in t.wantedTiles||(t.wantedTiles[c]={});const u=t.wantedTiles[c],d=a.getMapInternal(),f=Math.max(i-r,h.getMinZoom(),h.getZForResolution(Math.min(a.getMaxResolution(),d?d.getView().getResolutionForZoom(Math.max(a.getMinZoom(),0)):h.getResolution(0)),l.zDirection)),g=o.rotation,m=g?ga(o.center,o.resolution,g,t.size):void 0;for(let _=i;_>=f;--_){const p=h.getTileRangeForExtentAndZ(e,_,this.tempTileRange_),y=h.getResolution(_);for(let v=p.minX;v<=p.maxX;++v)for(let x=p.minY;x<=p.maxY;++x){if(g&&!h.tileCoordIntersectsViewport([_,v,x],m))continue;const w=this.getTile(_,v,x,t);if(!w||!oo(s,w,_))continue;const T=w.getKey();if(u[T]=!0,w.getState()===N.IDLE&&!t.tileQueue.isKeyQueued(T)){const S=vs(_,v,x,this.tempTileCoord_);t.tileQueue.enqueue([w,c,h.getTileCoordCenter(S),y])}}}}findStaleTile_(t,e){const i=this.tileCache_,s=t[0],r=t[1],o=t[2],a=this.getStaleKeys();for(let l=0;l<a.length;++l){const h=ro(this.getLayer().getSource(),a[l],s,r,o);if(i.containsKey(h)){const c=i.peek(h);if(c.getState()===N.LOADED)return c.endTransition(q(this)),oo(e,c,s),!0}}return!1}findAltTiles_(t,e,i,s){const r=t.getTileRangeForTileCoordAndZ(e,i,this.tempTileRange_);if(!r)return!1;let o=!0;const a=this.tileCache_,l=this.getLayer().getRenderSource(),h=l.getKey();for(let c=r.minX;c<=r.maxX;++c)for(let u=r.minY;u<=r.maxY;++u){const d=ro(l,h,i,c,u);let f=!1;if(a.containsKey(d)){const g=a.peek(d);g.getState()===N.LOADED&&(oo(s,g,i),f=!0)}f||(o=!1)}return o}renderFrame(t,e){this.renderComplete=!0;const i=t.layerStatesArray[t.layerIndex],s=t.viewState,r=s.projection,o=s.resolution,a=s.center,l=t.pixelRatio,h=this.getLayer(),c=h.getSource(),u=c.getTileGridForProjection(r),d=u.getZForResolution(o,c.zDirection),f=u.getResolution(d),g=c.getKey();this.renderedSourceKey_?this.renderedSourceKey_!==g&&(this.prependStaleKey(this.renderedSourceKey_),this.renderedSourceKey_=g):this.renderedSourceKey_=g;let m=t.extent;const _=c.getTilePixelRatio(l);this.prepareContainer(t,e);const p=this.context.canvas.width,y=this.context.canvas.height,v=i.extent&&be(i.extent);v&&(m=Be(m,be(i.extent)));const x=f*p/2/_,w=f*y/2/_,R=[a[0]-x,a[1]-w,a[0]+x,a[1]+w],T={};this.renderedTiles.length=0;const S=h.getPreload();if(t.nextExtent){const D=u.getZForResolution(s.nextResolution,c.zDirection),Y=th(t,t.nextExtent);this.enqueueTiles(t,Y,D,T,S)}const I=th(t,m);if(this.enqueueTiles(t,I,d,T,0),S>0&&setTimeout(()=>{this.enqueueTiles(t,I,d-1,T,S-1)},0),!(d in T))return this.container;const M=q(this),O=t.time;for(const D of T[d]){const Y=D.getState();if(Y===N.EMPTY)continue;const V=D.tileCoord;if(Y===N.LOADED&&D.getAlpha(M,O)===1){D.endTransition(M);continue}if(Y!==N.ERROR&&(this.renderComplete=!1),this.findStaleTile_(V,T)){sg(T,D,d),t.animate=!0;continue}if(this.findAltTiles_(u,V,d+1,T))continue;const xt=u.getMinZoom();for(let ft=d-1;ft>=xt&&!this.findAltTiles_(u,V,ft,T);--ft);}const L=f/o*l/_,A=this.getRenderContext(t);fe(this.tempTransform,p/2,y/2,L,L,0,-p/2,-y/2),i.extent&&this.clipUnrotated(A,t,v),c.getInterpolate()||(A.imageSmoothingEnabled=!1),this.preRender(A,t);const P=Object.keys(T).map(Number);P.sort(ce);let X;const k=[],G=[];for(let D=P.length-1;D>=0;--D){const Y=P[D],V=c.getTilePixelSize(Y,l,r),b=u.getResolution(Y)/f,xt=V[0]*b*L,ft=V[1]*b*L,ht=u.getTileCoordForCoordAndZ(Ue(R),Y),bt=u.getTileCoordExtent(ht),Et=yt(this.tempTransform,[_*(bt[0]-R[0])/f,_*(R[3]-bt[3])/f]),jt=_*c.getGutterForProjection(r);for(const Gt of T[Y]){if(Gt.getState()!==N.LOADED)continue;const Mt=Gt.tileCoord,Oi=ht[1]-Mt[1],W=Math.round(Et[0]-(Oi-1)*xt),rt=ht[2]-Mt[2],j=Math.round(Et[1]-(rt-1)*ft),nt=Math.round(Et[0]-Oi*xt),mt=Math.round(Et[1]-rt*ft),ze=W-nt,Pi=j-mt,Cn=P.length===1;let ei=!1;X=[nt,mt,nt+ze,mt,nt+ze,mt+Pi,nt,mt+Pi];for(let Di=0,ki=k.length;Di<ki;++Di)if(!Cn&&Y<G[Di]){const wt=k[Di];Pt([nt,mt,nt+ze,mt+Pi],[wt[0],wt[3],wt[4],wt[7]])&&(ei||(A.save(),ei=!0),A.beginPath(),A.moveTo(X[0],X[1]),A.lineTo(X[2],X[3]),A.lineTo(X[4],X[5]),A.lineTo(X[6],X[7]),A.moveTo(wt[6],wt[7]),A.lineTo(wt[4],wt[5]),A.lineTo(wt[2],wt[3]),A.lineTo(wt[0],wt[1]),A.clip())}k.push(X),G.push(Y),this.drawTile(Gt,t,nt,mt,ze,Pi,jt,Cn),ei&&A.restore(),this.renderedTiles.unshift(Gt),this.updateUsedTiles(t.usedTiles,c,Gt)}}if(this.renderedResolution=f,this.extentChanged=!this.renderedExtent_||!ji(this.renderedExtent_,R),this.renderedExtent_=R,this.renderedPixelRatio=l,this.postRender(this.context,t),i.extent&&A.restore(),A.imageSmoothingEnabled=!0,this.renderComplete){const D=(Y,V)=>{const tt=q(c),b=V.wantedTiles[tt],xt=b?Object.keys(b).length:0;this.updateCacheSize(xt),this.tileCache_.expireCache()};t.postRenderFunctions.push(D)}return this.container}updateCacheSize(t){this.tileCache_.highWaterMark=Math.max(this.tileCache_.highWaterMark,t*2)}drawTile(t,e,i,s,r,o,a,l){let h;if(t instanceof Kl){if(h=eo(t.getData()),!h)throw new Error("Rendering array data is not yet supported")}else h=this.getTileImage(t);if(!h)return;const c=this.getRenderContext(e),u=q(this),d=e.layerStatesArray[e.layerIndex],f=d.opacity*(l?t.getAlpha(u,e.time):1),g=f!==c.globalAlpha;g&&(c.save(),c.globalAlpha=f),c.drawImage(h,a,a,h.width-2*a,h.height-2*a,i,s,r,o),g&&c.restore(),f!==d.opacity?e.animate=!0:l&&t.endTransition(u)}getImage(){const t=this.context;return t?t.canvas:null}getTileImage(t){return t.getImage()}updateUsedTiles(t,e,i){const s=q(e);s in t||(t[s]={}),t[s][i.getKey()]=!0}}const Cs={PRELOAD:"preload",USE_INTERIM_TILES_ON_ERROR:"useInterimTilesOnError"};class og extends ls{constructor(t){t=t||{};const e=Object.assign({},t),i=t.cacheSize;delete t.cacheSize,delete e.preload,delete e.useInterimTilesOnError,super(e),this.on,this.once,this.un,this.cacheSize_=i,this.setPreload(t.preload!==void 0?t.preload:0),this.setUseInterimTilesOnError(t.useInterimTilesOnError!==void 0?t.useInterimTilesOnError:!0)}getCacheSize(){return this.cacheSize_}getPreload(){return this.get(Cs.PRELOAD)}setPreload(t){this.set(Cs.PRELOAD,t)}getUseInterimTilesOnError(){return this.get(Cs.USE_INTERIM_TILES_ON_ERROR)}setUseInterimTilesOnError(t){this.set(Cs.USE_INTERIM_TILES_ON_ERROR,t)}getData(t){return super.getData(t)}}class ag extends og{constructor(t){super(t)}createRenderer(){return new rg(this,{cacheSize:this.getCacheSize()})}}const Li=[0,0,0],Pe=5;class eh{constructor(t){this.minZoom=t.minZoom!==void 0?t.minZoom:0,this.resolutions_=t.resolutions,Q(dc(this.resolutions_,(s,r)=>r-s),"`resolutions` must be sorted in descending order");let e;if(!t.origins){for(let s=0,r=this.resolutions_.length-1;s<r;++s)if(!e)e=this.resolutions_[s]/this.resolutions_[s+1];else if(this.resolutions_[s]/this.resolutions_[s+1]!==e){e=void 0;break}}this.zoomFactor_=e,this.maxZoom=this.resolutions_.length-1,this.origin_=t.origin!==void 0?t.origin:null,this.origins_=null,t.origins!==void 0&&(this.origins_=t.origins,Q(this.origins_.length==this.resolutions_.length,"Number of `origins` and `resolutions` must be equal"));const i=t.extent;i!==void 0&&!this.origin_&&!this.origins_&&(this.origin_=Ue(i)),Q(!this.origin_&&this.origins_||this.origin_&&!this.origins_,"Either `origin` or `origins` must be configured, never both"),this.tileSizes_=null,t.tileSizes!==void 0&&(this.tileSizes_=t.tileSizes,Q(this.tileSizes_.length==this.resolutions_.length,"Number of `tileSizes` and `resolutions` must be equal")),this.tileSize_=t.tileSize!==void 0?t.tileSize:this.tileSizes_?null:xr,Q(!this.tileSize_&&this.tileSizes_||this.tileSize_&&!this.tileSizes_,"Either `tileSize` or `tileSizes` must be configured, never both"),this.extent_=i!==void 0?i:null,this.fullTileRanges_=null,this.tmpSize_=[0,0],this.tmpExtent_=[0,0,0,0],t.sizes!==void 0?this.fullTileRanges_=t.sizes.map((s,r)=>{const o=new io(Math.min(0,s[0]),Math.max(s[0]-1,-1),Math.min(0,s[1]),Math.max(s[1]-1,-1));if(i){const a=this.getTileRangeForExtentAndZ(i,r);o.minX=Math.max(a.minX,o.minX),o.maxX=Math.min(a.maxX,o.maxX),o.minY=Math.max(a.minY,o.minY),o.maxY=Math.min(a.maxY,o.maxY)}return o}):i&&this.calculateTileRanges_(i)}forEachTileCoord(t,e,i){const s=this.getTileRangeForExtentAndZ(t,e);for(let r=s.minX,o=s.maxX;r<=o;++r)for(let a=s.minY,l=s.maxY;a<=l;++a)i([e,r,a])}forEachTileCoordParentTileRange(t,e,i,s){let r,o,a,l=null,h=t[0]-1;for(this.zoomFactor_===2?(o=t[1],a=t[2]):l=this.getTileCoordExtent(t,s);h>=this.minZoom;){if(o!==void 0&&a!==void 0?(o=Math.floor(o/2),a=Math.floor(a/2),r=Ti(o,o,a,a,i)):r=this.getTileRangeForExtentAndZ(l,h,i),e(h,r))return!0;--h}return!1}getExtent(){return this.extent_}getMaxZoom(){return this.maxZoom}getMinZoom(){return this.minZoom}getOrigin(t){return this.origin_?this.origin_:this.origins_[t]}getResolution(t){return this.resolutions_[t]}getResolutions(){return this.resolutions_}getTileCoordChildTileRange(t,e,i){if(t[0]<this.maxZoom){if(this.zoomFactor_===2){const r=t[1]*2,o=t[2]*2;return Ti(r,r+1,o,o+1,e)}const s=this.getTileCoordExtent(t,i||this.tmpExtent_);return this.getTileRangeForExtentAndZ(s,t[0]+1,e)}return null}getTileRangeForTileCoordAndZ(t,e,i){if(e>this.maxZoom||e<this.minZoom)return null;const s=t[0],r=t[1],o=t[2];if(e===s)return Ti(r,o,r,o,i);if(this.zoomFactor_){const l=Math.pow(this.zoomFactor_,e-s),h=Math.floor(r*l),c=Math.floor(o*l);if(e<s)return Ti(h,h,c,c,i);const u=Math.floor(l*(r+1))-1,d=Math.floor(l*(o+1))-1;return Ti(h,u,c,d,i)}const a=this.getTileCoordExtent(t,this.tmpExtent_);return this.getTileRangeForExtentAndZ(a,e,i)}getTileRangeForExtentAndZ(t,e,i){this.getTileCoordForXYAndZ_(t[0],t[3],e,!1,Li);const s=Li[1],r=Li[2];this.getTileCoordForXYAndZ_(t[2],t[1],e,!0,Li);const o=Li[1],a=Li[2];return Ti(s,o,r,a,i)}getTileCoordCenter(t){const e=this.getOrigin(t[0]),i=this.getResolution(t[0]),s=kt(this.getTileSize(t[0]),this.tmpSize_);return[e[0]+(t[1]+.5)*s[0]*i,e[1]-(t[2]+.5)*s[1]*i]}getTileCoordExtent(t,e){const i=this.getOrigin(t[0]),s=this.getResolution(t[0]),r=kt(this.getTileSize(t[0]),this.tmpSize_),o=i[0]+t[1]*r[0]*s,a=i[1]-(t[2]+1)*r[1]*s,l=o+r[0]*s,h=a+r[1]*s;return Te(o,a,l,h,e)}getTileCoordForCoordAndResolution(t,e,i){return this.getTileCoordForXYAndResolution_(t[0],t[1],e,!1,i)}getTileCoordForXYAndResolution_(t,e,i,s,r){const o=this.getZForResolution(i),a=i/this.getResolution(o),l=this.getOrigin(o),h=kt(this.getTileSize(o),this.tmpSize_);let c=a*(t-l[0])/i/h[0],u=a*(l[1]-e)/i/h[1];return s?(c=Yn(c,Pe)-1,u=Yn(u,Pe)-1):(c=Xn(c,Pe),u=Xn(u,Pe)),vs(o,c,u,r)}getTileCoordForXYAndZ_(t,e,i,s,r){const o=this.getOrigin(i),a=this.getResolution(i),l=kt(this.getTileSize(i),this.tmpSize_);let h=(t-o[0])/a/l[0],c=(o[1]-e)/a/l[1];return s?(h=Yn(h,Pe)-1,c=Yn(c,Pe)-1):(h=Xn(h,Pe),c=Xn(c,Pe)),vs(i,h,c,r)}getTileCoordForCoordAndZ(t,e,i){return this.getTileCoordForXYAndZ_(t[0],t[1],e,!1,i)}getTileCoordResolution(t){return this.resolutions_[t[0]]}getTileSize(t){return this.tileSize_?this.tileSize_:this.tileSizes_[t]}getFullTileRange(t){return this.fullTileRanges_?this.fullTileRanges_[t]:this.extent_?this.getTileRangeForExtentAndZ(this.extent_,t):null}getZForResolution(t,e){const i=Ws(this.resolutions_,t,e||0);return lt(i,this.minZoom,this.maxZoom)}tileCoordIntersectsViewport(t,e){return qa(e,0,e.length,2,this.getTileCoordExtent(t))}calculateTileRanges_(t){const e=this.resolutions_.length,i=new Array(e);for(let s=this.minZoom;s<e;++s)i[s]=this.getTileRangeForExtentAndZ(t,s);this.fullTileRanges_=i}}function ih(n){let t=n.getDefaultTileGrid();return t||(t=ug(n),n.setDefaultTileGrid(t)),t}function lg(n,t,e){const i=t[0],s=n.getTileCoordCenter(t),r=ao(e);if(!ci(r,s)){const o=et(r),a=Math.ceil((r[0]-s[0])/o);return s[0]+=o*a,n.getTileCoordForCoordAndZ(s,i)}return t}function hg(n,t,e,i){i=i!==void 0?i:"top-left";const s=nh(n,t,e);return new eh({extent:n,origin:Tc(n,i),resolutions:s,tileSize:e})}function cg(n){const t=n||{},e=t.extent||Dt("EPSG:3857").getExtent(),i={extent:e,minZoom:t.minZoom,tileSize:t.tileSize,resolutions:nh(e,t.maxZoom,t.tileSize,t.maxResolution)};return new eh(i)}function nh(n,t,e,i){t=t!==void 0?t:Wu,e=kt(e!==void 0?e:xr);const s=It(n),r=et(n);i=i>0?i:Math.max(r/e[0],s/e[1]);const o=t+1,a=new Array(o);for(let l=0;l<o;++l)a[l]=i/Math.pow(2,l);return a}function ug(n,t,e,i){const s=ao(n);return hg(s,t,e,i)}function ao(n){n=Dt(n);let t=n.getExtent();if(!t){const e=180*qs.degrees/n.getMetersPerUnit();t=Te(-e,-e,e,e)}return t}const dg=/\{z\}/g,fg=/\{x\}/g,gg=/\{y\}/g,_g=/\{-y\}/g;function mg(n,t,e,i,s){return n.replace(dg,t.toString()).replace(fg,e.toString()).replace(gg,i.toString()).replace(_g,function(){if(s===void 0)throw new Error("If the URL template has a {-y} placeholder, the grid extent must be known");return(s-i).toString()})}function pg(n){const t=[];let e=/\{([a-z])-([a-z])\}/.exec(n);if(e){const i=e[1].charCodeAt(0),s=e[2].charCodeAt(0);let r;for(r=i;r<=s;++r)t.push(n.replace(e[0],String.fromCharCode(r)));return t}if(e=/\{(\d+)-(\d+)\}/.exec(n),e){const i=parseInt(e[2],10);for(let s=parseInt(e[1],10);s<=i;s++)t.push(n.replace(e[0],s.toString()));return t}return t.push(n),t}function yg(n,t){return(function(e,i,s){if(!e)return;let r;const o=e[0];if(t){const a=t.getFullTileRange(o);a&&(r=a.getHeight()-1)}return mg(n,o,e[1],e[2],r)})}function xg(n,t){const e=n.length,i=new Array(e);for(let s=0;s<e;++s)i[s]=yg(n[s],t);return Eg(i)}function Eg(n){return n.length===1?n[0]:(function(t,e,i){if(!t)return;const s=Jf(t),r=hi(s,n.length);return n[r](t,e,i)})}class sh extends ne{constructor(t){super(),this.projection=Dt(t.projection),this.attributions_=rh(t.attributions),this.attributionsCollapsible_=t.attributionsCollapsible??!0,this.loading=!1,this.state_=t.state!==void 0?t.state:"ready",this.wrapX_=t.wrapX!==void 0?t.wrapX:!1,this.interpolate_=!!t.interpolate,this.viewResolver=null,this.viewRejector=null;const e=this;this.viewPromise_=new Promise(function(i,s){e.viewResolver=i,e.viewRejector=s})}getAttributions(){return this.attributions_}getAttributionsCollapsible(){return this.attributionsCollapsible_}getProjection(){return this.projection}getResolutions(t){return null}getView(){return this.viewPromise_}getState(){return this.state_}getWrapX(){return this.wrapX_}getInterpolate(){return this.interpolate_}refresh(){this.changed()}setAttributions(t){this.attributions_=rh(t),this.changed()}setState(t){this.state_=t,this.changed()}}function rh(n){return n?typeof n=="function"?n:(Array.isArray(n)||(n=[n]),t=>n):null}class wg extends sh{constructor(t){super({attributions:t.attributions,attributionsCollapsible:t.attributionsCollapsible,projection:t.projection,state:t.state,wrapX:t.wrapX,interpolate:t.interpolate}),this.on,this.once,this.un,this.tilePixelRatio_=t.tilePixelRatio!==void 0?t.tilePixelRatio:1,this.tileGrid=t.tileGrid!==void 0?t.tileGrid:null;const e=[256,256];this.tileGrid&&kt(this.tileGrid.getTileSize(this.tileGrid.getMinZoom()),e),this.tmpSize=[0,0],this.key_=t.key||q(this),this.tileOptions={transition:t.transition,interpolate:t.interpolate},this.zDirection=t.zDirection?t.zDirection:0}getGutterForProjection(t){return 0}getKey(){return this.key_}setKey(t){this.key_!==t&&(this.key_=t,this.changed())}getResolutions(t){const e=t?this.getTileGridForProjection(t):this.tileGrid;return e?e.getResolutions():null}getTile(t,e,i,s,r){return H()}getTileGrid(){return this.tileGrid}getTileGridForProjection(t){return this.tileGrid?this.tileGrid:ih(t)}getTilePixelRatio(t){return this.tilePixelRatio_}getTilePixelSize(t,e,i){const s=this.getTileGridForProjection(i),r=this.getTilePixelRatio(e),o=kt(s.getTileSize(t),this.tmpSize);return r==1?o:kd(o,r,this.tmpSize)}getTileCoordForTileUrlFunction(t,e){const i=e!==void 0?e:this.getProjection(),s=e!==void 0?this.getTileGridForProjection(i):this.tileGrid||this.getTileGridForProjection(i);return this.getWrapX()&&i.isGlobal()&&(t=lg(s,t,i)),tg(t,s)?t:null}clear(){}refresh(){this.clear(),super.refresh()}}class vg extends ue{constructor(t,e){super(t),this.tile=e}}const lo={TILELOADSTART:"tileloadstart",TILELOADEND:"tileloadend",TILELOADERROR:"tileloaderror"};class ho extends wg{constructor(t){super({attributions:t.attributions,cacheSize:t.cacheSize,projection:t.projection,state:t.state,tileGrid:t.tileGrid,tilePixelRatio:t.tilePixelRatio,wrapX:t.wrapX,transition:t.transition,interpolate:t.interpolate,key:t.key,attributionsCollapsible:t.attributionsCollapsible,zDirection:t.zDirection}),this.generateTileUrlFunction_=this.tileUrlFunction===ho.prototype.tileUrlFunction,this.tileLoadFunction=t.tileLoadFunction,t.tileUrlFunction&&(this.tileUrlFunction=t.tileUrlFunction),this.urls=null,t.urls?this.setUrls(t.urls):t.url&&this.setUrl(t.url),this.tileLoadingKeys_={}}getTileLoadFunction(){return this.tileLoadFunction}getTileUrlFunction(){return Object.getPrototypeOf(this).tileUrlFunction===this.tileUrlFunction?this.tileUrlFunction.bind(this):this.tileUrlFunction}getUrls(){return this.urls}handleTileChange(t){const e=t.target,i=q(e),s=e.getState();let r;s==N.LOADING?(this.tileLoadingKeys_[i]=!0,r=lo.TILELOADSTART):i in this.tileLoadingKeys_&&(delete this.tileLoadingKeys_[i],r=s==N.ERROR?lo.TILELOADERROR:s==N.LOADED?lo.TILELOADEND:void 0),r!=null&&this.dispatchEvent(new vg(r,e))}setTileLoadFunction(t){this.tileLoadFunction=t,this.changed()}setTileUrlFunction(t,e){this.tileUrlFunction=t,typeof e<"u"?this.setKey(e):this.changed()}setUrl(t){const e=pg(t);this.urls=e,this.setUrls(e)}setUrls(t){this.urls=t;const e=t.join(`
|
|
7
|
-
`);this.generateTileUrlFunction_?this.setTileUrlFunction(xg(t,this.tileGrid),e):this.setKey(e)}tileUrlFunction(t,e,i){}}class Cg extends ho{constructor(t){super({attributions:t.attributions,cacheSize:t.cacheSize,projection:t.projection,state:t.state,tileGrid:t.tileGrid,tileLoadFunction:t.tileLoadFunction?t.tileLoadFunction:Rg,tilePixelRatio:t.tilePixelRatio,tileUrlFunction:t.tileUrlFunction,url:t.url,urls:t.urls,wrapX:t.wrapX,transition:t.transition,interpolate:t.interpolate!==void 0?t.interpolate:!0,key:t.key,attributionsCollapsible:t.attributionsCollapsible,zDirection:t.zDirection}),this.crossOrigin=t.crossOrigin!==void 0?t.crossOrigin:null,this.tileClass=t.tileClass!==void 0?t.tileClass:jl,this.tileGridForProjection={},this.reprojectionErrorThreshold_=t.reprojectionErrorThreshold,this.renderReprojectionEdges_=!1}getGutterForProjection(t){return this.getProjection()&&t&&!ar(this.getProjection(),t)?0:this.getGutter()}getGutter(){return 0}getKey(){let t=super.getKey();return this.getInterpolate()||(t+=":disable-interpolation"),t}getTileGridForProjection(t){const e=this.getProjection();if(this.tileGrid&&(!e||ar(e,t)))return this.tileGrid;const i=q(t);return i in this.tileGridForProjection||(this.tileGridForProjection[i]=ih(t)),this.tileGridForProjection[i]}createTile_(t,e,i,s,r,o){const a=[t,e,i],l=this.getTileCoordForTileUrlFunction(a,r),h=l?this.tileUrlFunction(l,s,r):void 0,c=new this.tileClass(a,h!==void 0?N.IDLE:N.EMPTY,h!==void 0?h:"",this.crossOrigin,this.tileLoadFunction,this.tileOptions);return c.key=o,c.addEventListener(B.CHANGE,this.handleTileChange.bind(this)),c}getTile(t,e,i,s,r){const o=this.getProjection();if(!o||!r||ar(o,r))return this.getTileInternal(t,e,i,s,o||r);const a=[t,e,i],l=this.getKey(),h=this.getTileGridForProjection(o),c=this.getTileGridForProjection(r),u=this.getTileCoordForTileUrlFunction(a,r),d=new Hl(o,h,r,c,a,u,this.getTilePixelRatio(s),this.getGutter(),(f,g,m,_)=>this.getTileInternal(f,g,m,_,o),this.reprojectionErrorThreshold_,this.renderReprojectionEdges_,this.tileOptions);return d.key=l,d}getTileInternal(t,e,i,s,r){const o=this.getKey();return this.createTile_(t,e,i,s,r,o)}setRenderReprojectionEdges(t){this.renderReprojectionEdges_!=t&&(this.renderReprojectionEdges_=t,this.changed())}setTileGridForProjection(t,e){const i=Dt(t);if(i){const s=q(i);s in this.tileGridForProjection||(this.tileGridForProjection[s]=e)}}}function Rg(n,t){n.getImage().src=t}class Sg extends Cg{constructor(t){t=t||{};const e=t.projection!==void 0?t.projection:"EPSG:3857",i=t.tileGrid!==void 0?t.tileGrid:cg({extent:ao(e),maxResolution:t.maxResolution,maxZoom:t.maxZoom,minZoom:t.minZoom,tileSize:t.tileSize});super({attributions:t.attributions,cacheSize:t.cacheSize,crossOrigin:t.crossOrigin,interpolate:t.interpolate,projection:e,reprojectionErrorThreshold:t.reprojectionErrorThreshold,tileGrid:i,tileLoadFunction:t.tileLoadFunction,tilePixelRatio:t.tilePixelRatio,tileUrlFunction:t.tileUrlFunction,url:t.url,urls:t.urls,wrapX:t.wrapX!==void 0?t.wrapX:!0,transition:t.transition,attributionsCollapsible:t.attributionsCollapsible,zDirection:t.zDirection}),this.gutter_=t.gutter!==void 0?t.gutter:0}getGutter(){return this.gutter_}}const Ig='© <a href="https://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap</a> contributors.';class Tg extends Sg{constructor(t){t=t||{};let e;t.attributions!==void 0?e=t.attributions:e=[Ig];const i=t.crossOrigin!==void 0?t.crossOrigin:"anonymous",s=t.url!==void 0?t.url:"https://tile.openstreetmap.org/{z}/{x}/{y}.png";super({attributions:e,attributionsCollapsible:!1,cacheSize:t.cacheSize,crossOrigin:i,interpolate:t.interpolate,maxZoom:t.maxZoom!==void 0?t.maxZoom:19,reprojectionErrorThreshold:t.reprojectionErrorThreshold,tileLoadFunction:t.tileLoadFunction,transition:t.transition,url:s,wrapX:t.wrapX,zDirection:t.zDirection})}}class co extends ne{constructor(t){if(super(),this.on,this.once,this.un,this.id_=void 0,this.geometryName_="geometry",this.style_=null,this.styleFunction_=void 0,this.geometryChangeKey_=null,this.addChangeListener(this.geometryName_,this.handleGeometryChanged_),t)if(typeof t.getSimplifiedGeometry=="function"){const e=t;this.setGeometry(e)}else{const e=t;this.setProperties(e)}}clone(){const t=new co(this.hasProperties()?this.getProperties():null);t.setGeometryName(this.getGeometryName());const e=this.getGeometry();e&&t.setGeometry(e.clone());const i=this.getStyle();return i&&t.setStyle(i),t}getGeometry(){return this.get(this.geometryName_)}getId(){return this.id_}getGeometryName(){return this.geometryName_}getStyle(){return this.style_}getStyleFunction(){return this.styleFunction_}handleGeometryChange_(){this.changed()}handleGeometryChanged_(){this.geometryChangeKey_&&(at(this.geometryChangeKey_),this.geometryChangeKey_=null);const t=this.getGeometry();t&&(this.geometryChangeKey_=$(t,B.CHANGE,this.handleGeometryChange_,this)),this.changed()}setGeometry(t){this.set(this.geometryName_,t)}setStyle(t){this.style_=t,this.styleFunction_=t?bg(t):void 0,this.changed()}setId(t){this.id_=t,this.changed()}setGeometryName(t){this.removeChangeListener(this.geometryName_,this.handleGeometryChanged_),this.geometryName_=t,this.addChangeListener(this.geometryName_,this.handleGeometryChanged_),this.handleGeometryChanged_()}}function bg(n){if(typeof n=="function")return n;let t;return Array.isArray(n)?t=n:(Q(typeof n.getZIndex=="function","Expected an `ol/style/Style` or an array of `ol/style/Style.js`"),t=[n]),function(){return t}}function oh(n,t,e,i,s,r,o){let a,l;const h=(e-t)/i;if(h===1)a=t;else if(h===2)a=t,l=s;else if(h!==0){let c=n[t],u=n[t+1],d=0;const f=[0];for(let _=t+i;_<e;_+=i){const p=n[_],y=n[_+1];d+=Math.sqrt((p-c)*(p-c)+(y-u)*(y-u)),f.push(d),c=p,u=y}const g=s*d,m=hc(f,g);m<0?(l=(g-f[-m-2])/(f[-m-1]-f[-m-2]),a=t+(-m-2)*i):a=t+m*i}o=o>1?o:2,r=r||new Array(o);for(let c=0;c<o;++c)r[c]=a===void 0?NaN:l===void 0?n[a+c]:Wt(n[a+c],n[a+i+c],l);return r}function Mg(n,t,e,i){let s=n[t],r=n[t+1],o=0;for(let a=t+i;a<e;a+=i){const l=n[a],h=n[a+1];o+=Math.sqrt((l-s)*(l-s)+(h-r)*(h-r)),s=l,r=h}return o}class ah{drawCustom(t,e,i,s,r){}drawGeometry(t){}setStyle(t){}drawCircle(t,e,i){}drawFeature(t,e,i){}drawGeometryCollection(t,e,i){}drawLineString(t,e,i){}drawMultiLineString(t,e,i){}drawMultiPoint(t,e,i){}drawMultiPolygon(t,e,i){}drawPoint(t,e,i){}drawPolygon(t,e,i){}drawText(t,e,i){}setFillStrokeStyle(t,e){}setImageStyle(t,e){}setTextStyle(t,e){}}class Lg extends ah{constructor(t,e,i,s,r,o,a){super(),this.context_=t,this.pixelRatio_=e,this.extent_=i,this.transform_=s,this.transformRotation_=s?Wn(Math.atan2(s[1],s[0]),10):0,this.viewRotation_=r,this.squaredTolerance_=o,this.userTransform_=a,this.contextFillState_=null,this.contextStrokeState_=null,this.contextTextState_=null,this.fillState_=null,this.strokeState_=null,this.image_=null,this.imageAnchorX_=0,this.imageAnchorY_=0,this.imageHeight_=0,this.imageOpacity_=0,this.imageOriginX_=0,this.imageOriginY_=0,this.imageRotateWithView_=!1,this.imageRotation_=0,this.imageScale_=[0,0],this.imageWidth_=0,this.text_="",this.textOffsetX_=0,this.textOffsetY_=0,this.textRotateWithView_=!1,this.textRotation_=0,this.textScale_=[0,0],this.textFillState_=null,this.textStrokeState_=null,this.textState_=null,this.pixelCoordinates_=[],this.tmpLocalTransform_=qt()}drawImages_(t,e,i,s){if(!this.image_)return;const r=Me(t,e,i,s,this.transform_,this.pixelCoordinates_),o=this.context_,a=this.tmpLocalTransform_,l=o.globalAlpha;this.imageOpacity_!=1&&(o.globalAlpha=l*this.imageOpacity_);let h=this.imageRotation_;this.transformRotation_===0&&(h-=this.viewRotation_),this.imageRotateWithView_&&(h+=this.viewRotation_);for(let c=0,u=r.length;c<u;c+=2){const d=r[c]-this.imageAnchorX_,f=r[c+1]-this.imageAnchorY_;if(h!==0||this.imageScale_[0]!=1||this.imageScale_[1]!=1){const g=d+this.imageAnchorX_,m=f+this.imageAnchorY_;fe(a,g,m,1,1,h,-g,-m),o.save(),o.transform.apply(o,a),o.translate(g,m),o.scale(this.imageScale_[0],this.imageScale_[1]),o.drawImage(this.image_,this.imageOriginX_,this.imageOriginY_,this.imageWidth_,this.imageHeight_,-this.imageAnchorX_,-this.imageAnchorY_,this.imageWidth_,this.imageHeight_),o.restore()}else o.drawImage(this.image_,this.imageOriginX_,this.imageOriginY_,this.imageWidth_,this.imageHeight_,d,f,this.imageWidth_,this.imageHeight_)}this.imageOpacity_!=1&&(o.globalAlpha=l)}drawText_(t,e,i,s){if(!this.textState_||this.text_==="")return;this.textFillState_&&this.setContextFillState_(this.textFillState_),this.textStrokeState_&&this.setContextStrokeState_(this.textStrokeState_),this.setContextTextState_(this.textState_);const r=Me(t,e,i,s,this.transform_,this.pixelCoordinates_),o=this.context_;let a=this.textRotation_;for(this.transformRotation_===0&&(a-=this.viewRotation_),this.textRotateWithView_&&(a+=this.viewRotation_);e<i;e+=s){const l=r[e]+this.textOffsetX_,h=r[e+1]+this.textOffsetY_;a!==0||this.textScale_[0]!=1||this.textScale_[1]!=1?(o.save(),o.translate(l-this.textOffsetX_,h-this.textOffsetY_),o.rotate(a),o.translate(this.textOffsetX_,this.textOffsetY_),o.scale(this.textScale_[0],this.textScale_[1]),this.textStrokeState_&&o.strokeText(this.text_,0,0),this.textFillState_&&o.fillText(this.text_,0,0),o.restore()):(this.textStrokeState_&&o.strokeText(this.text_,l,h),this.textFillState_&&o.fillText(this.text_,l,h))}}moveToLineTo_(t,e,i,s,r){const o=this.context_,a=Me(t,e,i,s,this.transform_,this.pixelCoordinates_);o.moveTo(a[0],a[1]);let l=a.length;r&&(l-=2);for(let h=2;h<l;h+=2)o.lineTo(a[h],a[h+1]);return r&&o.closePath(),i}drawRings_(t,e,i,s){for(let r=0,o=i.length;r<o;++r)e=this.moveToLineTo_(t,e,i[r],s,!0);return e}drawCircle(t){if(this.squaredTolerance_&&(t=t.simplifyTransformed(this.squaredTolerance_,this.userTransform_)),!!Pt(this.extent_,t.getExtent())){if(this.fillState_||this.strokeState_){this.fillState_&&this.setContextFillState_(this.fillState_),this.strokeState_&&this.setContextStrokeState_(this.strokeState_);const e=wu(t,this.transform_,this.pixelCoordinates_),i=e[2]-e[0],s=e[3]-e[1],r=Math.sqrt(i*i+s*s),o=this.context_;o.beginPath(),o.arc(e[0],e[1],r,0,2*Math.PI),this.fillState_&&o.fill(),this.strokeState_&&o.stroke()}this.text_!==""&&this.drawText_(t.getCenter(),0,2,2)}}setStyle(t){this.setFillStrokeStyle(t.getFill(),t.getStroke()),this.setImageStyle(t.getImage()),this.setTextStyle(t.getText())}setTransform(t){this.transform_=t}drawGeometry(t){switch(t.getType()){case"Point":this.drawPoint(t);break;case"LineString":this.drawLineString(t);break;case"Polygon":this.drawPolygon(t);break;case"MultiPoint":this.drawMultiPoint(t);break;case"MultiLineString":this.drawMultiLineString(t);break;case"MultiPolygon":this.drawMultiPolygon(t);break;case"GeometryCollection":this.drawGeometryCollection(t);break;case"Circle":this.drawCircle(t);break}}drawFeature(t,e){const i=e.getGeometryFunction()(t);i&&(this.setStyle(e),this.drawGeometry(i))}drawGeometryCollection(t){const e=t.getGeometriesArray();for(let i=0,s=e.length;i<s;++i)this.drawGeometry(e[i])}drawPoint(t){this.squaredTolerance_&&(t=t.simplifyTransformed(this.squaredTolerance_,this.userTransform_));const e=t.getFlatCoordinates(),i=t.getStride();this.image_&&this.drawImages_(e,0,e.length,i),this.text_!==""&&this.drawText_(e,0,e.length,i)}drawMultiPoint(t){this.squaredTolerance_&&(t=t.simplifyTransformed(this.squaredTolerance_,this.userTransform_));const e=t.getFlatCoordinates(),i=t.getStride();this.image_&&this.drawImages_(e,0,e.length,i),this.text_!==""&&this.drawText_(e,0,e.length,i)}drawLineString(t){if(this.squaredTolerance_&&(t=t.simplifyTransformed(this.squaredTolerance_,this.userTransform_)),!!Pt(this.extent_,t.getExtent())){if(this.strokeState_){this.setContextStrokeState_(this.strokeState_);const e=this.context_,i=t.getFlatCoordinates();e.beginPath(),this.moveToLineTo_(i,0,i.length,t.getStride(),!1),e.stroke()}if(this.text_!==""){const e=t.getFlatMidpoint();this.drawText_(e,0,2,2)}}}drawMultiLineString(t){this.squaredTolerance_&&(t=t.simplifyTransformed(this.squaredTolerance_,this.userTransform_));const e=t.getExtent();if(Pt(this.extent_,e)){if(this.strokeState_){this.setContextStrokeState_(this.strokeState_);const i=this.context_,s=t.getFlatCoordinates();let r=0;const o=t.getEnds(),a=t.getStride();i.beginPath();for(let l=0,h=o.length;l<h;++l)r=this.moveToLineTo_(s,r,o[l],a,!1);i.stroke()}if(this.text_!==""){const i=t.getFlatMidpoints();this.drawText_(i,0,i.length,2)}}}drawPolygon(t){if(this.squaredTolerance_&&(t=t.simplifyTransformed(this.squaredTolerance_,this.userTransform_)),!!Pt(this.extent_,t.getExtent())){if(this.strokeState_||this.fillState_){this.fillState_&&this.setContextFillState_(this.fillState_),this.strokeState_&&this.setContextStrokeState_(this.strokeState_);const e=this.context_;e.beginPath(),this.drawRings_(t.getOrientedFlatCoordinates(),0,t.getEnds(),t.getStride()),this.fillState_&&e.fill(),this.strokeState_&&e.stroke()}if(this.text_!==""){const e=t.getFlatInteriorPoint();this.drawText_(e,0,2,2)}}}drawMultiPolygon(t){if(this.squaredTolerance_&&(t=t.simplifyTransformed(this.squaredTolerance_,this.userTransform_)),!!Pt(this.extent_,t.getExtent())){if(this.strokeState_||this.fillState_){this.fillState_&&this.setContextFillState_(this.fillState_),this.strokeState_&&this.setContextStrokeState_(this.strokeState_);const e=this.context_,i=t.getOrientedFlatCoordinates();let s=0;const r=t.getEndss(),o=t.getStride();e.beginPath();for(let a=0,l=r.length;a<l;++a){const h=r[a];s=this.drawRings_(i,s,h,o)}this.fillState_&&e.fill(),this.strokeState_&&e.stroke()}if(this.text_!==""){const e=t.getFlatInteriorPoints();this.drawText_(e,0,e.length,2)}}}setContextFillState_(t){const e=this.context_,i=this.contextFillState_;i?i.fillStyle!=t.fillStyle&&(i.fillStyle=t.fillStyle,e.fillStyle=t.fillStyle):(e.fillStyle=t.fillStyle,this.contextFillState_={fillStyle:t.fillStyle})}setContextStrokeState_(t){const e=this.context_,i=this.contextStrokeState_;i?(i.lineCap!=t.lineCap&&(i.lineCap=t.lineCap,e.lineCap=t.lineCap),Ce(i.lineDash,t.lineDash)||e.setLineDash(i.lineDash=t.lineDash),i.lineDashOffset!=t.lineDashOffset&&(i.lineDashOffset=t.lineDashOffset,e.lineDashOffset=t.lineDashOffset),i.lineJoin!=t.lineJoin&&(i.lineJoin=t.lineJoin,e.lineJoin=t.lineJoin),i.lineWidth!=t.lineWidth&&(i.lineWidth=t.lineWidth,e.lineWidth=t.lineWidth),i.miterLimit!=t.miterLimit&&(i.miterLimit=t.miterLimit,e.miterLimit=t.miterLimit),i.strokeStyle!=t.strokeStyle&&(i.strokeStyle=t.strokeStyle,e.strokeStyle=t.strokeStyle)):(e.lineCap=t.lineCap,e.setLineDash(t.lineDash),e.lineDashOffset=t.lineDashOffset,e.lineJoin=t.lineJoin,e.lineWidth=t.lineWidth,e.miterLimit=t.miterLimit,e.strokeStyle=t.strokeStyle,this.contextStrokeState_={lineCap:t.lineCap,lineDash:t.lineDash,lineDashOffset:t.lineDashOffset,lineJoin:t.lineJoin,lineWidth:t.lineWidth,miterLimit:t.miterLimit,strokeStyle:t.strokeStyle})}setContextTextState_(t){const e=this.context_,i=this.contextTextState_,s=t.textAlign?t.textAlign:gn;i?(i.font!=t.font&&(i.font=t.font,e.font=t.font),i.textAlign!=s&&(i.textAlign=s,e.textAlign=s),i.textBaseline!=t.textBaseline&&(i.textBaseline=t.textBaseline,e.textBaseline=t.textBaseline)):(e.font=t.font,e.textAlign=s,e.textBaseline=t.textBaseline,this.contextTextState_={font:t.font,textAlign:s,textBaseline:t.textBaseline})}setFillStrokeStyle(t,e){if(!t)this.fillState_=null;else{const i=t.getColor();this.fillState_={fillStyle:oe(i||Nt)}}if(!e)this.strokeState_=null;else{const i=e.getColor(),s=e.getLineCap(),r=e.getLineDash(),o=e.getLineDashOffset(),a=e.getLineJoin(),l=e.getWidth(),h=e.getMiterLimit(),c=r||_e;this.strokeState_={lineCap:s!==void 0?s:Ci,lineDash:this.pixelRatio_===1?c:c.map(u=>u*this.pixelRatio_),lineDashOffset:(o||me)*this.pixelRatio_,lineJoin:a!==void 0?a:Ri,lineWidth:(l!==void 0?l:_n)*this.pixelRatio_,miterLimit:h!==void 0?h:dn,strokeStyle:oe(i||fn)}}}setImageStyle(t){let e;if(!t||!(e=t.getSize())){this.image_=null;return}const i=t.getPixelRatio(this.pixelRatio_),s=t.getAnchor(),r=t.getOrigin();this.image_=t.getImage(this.pixelRatio_),this.imageAnchorX_=s[0]*i,this.imageAnchorY_=s[1]*i,this.imageHeight_=e[1]*i,this.imageOpacity_=t.getOpacity(),this.imageOriginX_=r[0],this.imageOriginY_=r[1],this.imageRotateWithView_=t.getRotateWithView(),this.imageRotation_=t.getRotation();const o=t.getScaleArray();this.imageScale_=[o[0]*this.pixelRatio_/i,o[1]*this.pixelRatio_/i],this.imageWidth_=e[0]*i}setTextStyle(t){if(!t)this.text_="";else{const e=t.getFill();if(!e)this.textFillState_=null;else{const f=e.getColor();this.textFillState_={fillStyle:oe(f||Nt)}}const i=t.getStroke();if(!i)this.textStrokeState_=null;else{const f=i.getColor(),g=i.getLineCap(),m=i.getLineDash(),_=i.getLineDashOffset(),p=i.getLineJoin(),y=i.getWidth(),v=i.getMiterLimit();this.textStrokeState_={lineCap:g!==void 0?g:Ci,lineDash:m||_e,lineDashOffset:_||me,lineJoin:p!==void 0?p:Ri,lineWidth:y!==void 0?y:_n,miterLimit:v!==void 0?v:dn,strokeStyle:oe(f||fn)}}const s=t.getFont(),r=t.getOffsetX(),o=t.getOffsetY(),a=t.getRotateWithView(),l=t.getRotation(),h=t.getScaleArray(),c=t.getText(),u=t.getTextAlign(),d=t.getTextBaseline();this.textState_={font:s!==void 0?s:Rl,textAlign:u!==void 0?u:gn,textBaseline:d!==void 0?d:fs},this.text_=c!==void 0?Array.isArray(c)?c.reduce((f,g,m)=>f+=m%2?" ":g,""):c:"",this.textOffsetX_=r!==void 0?this.pixelRatio_*r:0,this.textOffsetY_=o!==void 0?this.pixelRatio_*o:0,this.textRotateWithView_=a!==void 0?a:!1,this.textRotation_=l!==void 0?l:0,this.textScale_=[this.pixelRatio_*h[0],this.pixelRatio_*h[1]]}}}const Ag=.5,lh={Point:Gg,LineString:Fg,Polygon:Xg,MultiPoint:Wg,MultiLineString:Ng,MultiPolygon:zg,GeometryCollection:kg,Circle:Pg};function Og(n,t){return parseInt(q(n),10)-parseInt(q(t),10)}function hh(n,t){const e=ch(n,t);return e*e}function ch(n,t){return Ag*n/t}function Pg(n,t,e,i,s){const r=e.getFill(),o=e.getStroke();if(r||o){const l=n.getBuilder(e.getZIndex(),"Circle");l.setFillStrokeStyle(r,o),l.drawCircle(t,i,s)}const a=e.getText();if(a&&a.getText()){const l=n.getBuilder(e.getZIndex(),"Text");l.setTextStyle(a),l.drawText(t,i)}}function uh(n,t,e,i,s,r,o,a){const l=[],h=e.getImage();if(h){let d=!0;const f=h.getImageState();f==K.LOADED||f==K.ERROR?d=!1:f==K.IDLE&&h.load(),d&&l.push(h.ready())}const c=e.getFill();c&&c.loading()&&l.push(c.ready());const u=l.length>0;return u&&Promise.all(l).then(()=>s(null)),Dg(n,t,e,i,r,o,a),u}function Dg(n,t,e,i,s,r,o){const a=e.getGeometryFunction()(t);if(!a)return;const l=a.simplifyTransformed(i,s);if(e.getRenderer())dh(n,l,e,t,o);else{const c=lh[l.getType()];c(n,l,e,t,o,r)}}function dh(n,t,e,i,s){if(t.getType()=="GeometryCollection"){const o=t.getGeometries();for(let a=0,l=o.length;a<l;++a)dh(n,o[a],e,i,s);return}n.getBuilder(e.getZIndex(),"Default").drawCustom(t,i,e.getRenderer(),e.getHitDetectionRenderer(),s)}function kg(n,t,e,i,s,r){const o=t.getGeometriesArray();let a,l;for(a=0,l=o.length;a<l;++a){const h=lh[o[a].getType()];h(n,o[a],e,i,s,r)}}function Fg(n,t,e,i,s){const r=e.getStroke();if(r){const a=n.getBuilder(e.getZIndex(),"LineString");a.setFillStrokeStyle(null,r),a.drawLineString(t,i,s)}const o=e.getText();if(o&&o.getText()){const a=n.getBuilder(e.getZIndex(),"Text");a.setTextStyle(o),a.drawText(t,i,s)}}function Ng(n,t,e,i,s){const r=e.getStroke();if(r){const a=n.getBuilder(e.getZIndex(),"LineString");a.setFillStrokeStyle(null,r),a.drawMultiLineString(t,i,s)}const o=e.getText();if(o&&o.getText()){const a=n.getBuilder(e.getZIndex(),"Text");a.setTextStyle(o),a.drawText(t,i,s)}}function zg(n,t,e,i,s){const r=e.getFill(),o=e.getStroke();if(o||r){const l=n.getBuilder(e.getZIndex(),"Polygon");l.setFillStrokeStyle(r,o),l.drawMultiPolygon(t,i,s)}const a=e.getText();if(a&&a.getText()){const l=n.getBuilder(e.getZIndex(),"Text");l.setTextStyle(a),l.drawText(t,i,s)}}function Gg(n,t,e,i,s,r){const o=e.getImage(),a=e.getText(),l=a&&a.getText(),h=r&&o&&l?{}:void 0;if(o){if(o.getImageState()!=K.LOADED)return;const c=n.getBuilder(e.getZIndex(),"Image");c.setImageStyle(o,h),c.drawPoint(t,i,s)}if(l){const c=n.getBuilder(e.getZIndex(),"Text");c.setTextStyle(a,h),c.drawText(t,i,s)}}function Wg(n,t,e,i,s,r){const o=e.getImage(),a=o&&o.getOpacity()!==0,l=e.getText(),h=l&&l.getText(),c=r&&a&&h?{}:void 0;if(a){if(o.getImageState()!=K.LOADED)return;const u=n.getBuilder(e.getZIndex(),"Image");u.setImageStyle(o,c),u.drawMultiPoint(t,i,s)}if(h){const u=n.getBuilder(e.getZIndex(),"Text");u.setTextStyle(l,c),u.drawText(t,i,s)}}function Xg(n,t,e,i,s){const r=e.getFill(),o=e.getStroke();if(r||o){const l=n.getBuilder(e.getZIndex(),"Polygon");l.setFillStrokeStyle(r,o),l.drawPolygon(t,i,s)}const a=e.getText();if(a&&a.getText()){const l=n.getBuilder(e.getZIndex(),"Text");l.setTextStyle(a),l.drawText(t,i,s)}}let Yg=!1;function Bg(n,t,e,i,s,r,o){const a=new XMLHttpRequest;a.open("GET",typeof n=="function"?n(e,i,s):n,!0),t.getType()=="arraybuffer"&&(a.responseType="arraybuffer"),a.withCredentials=Yg,a.onload=function(l){if(!a.status||a.status>=200&&a.status<300){const h=t.getType();try{let c;h=="text"||h=="json"?c=a.responseText:h=="xml"?c=a.responseXML||a.responseText:h=="arraybuffer"&&(c=a.response),c?r(t.readFeatures(c,{extent:e,featureProjection:s}),t.readProjection(c)):o()}catch{o()}}else o()},a.onerror=o,a.send()}function fh(n,t){return function(e,i,s,r,o){Bg(n,t,e,i,s,(a,l)=>{this.addFeatures(a),r!==void 0&&r(a)},()=>{this.changed(),o!==void 0&&o()})}}function Ug(n,t){return[[-1/0,-1/0,1/0,1/0]]}function Kg(n,t,e,i){const s=[];let r=Xt();for(let o=0,a=e.length;o<a;++o){const l=e[o];r=Vs(n,t,l[0],i),s.push((r[0]+r[2])/2,(r[1]+r[3])/2),t=l[l.length-1]}return s}const gh=qt();class te{constructor(t,e,i,s,r,o){this.styleFunction,this.extent_,this.id_=o,this.type_=t,this.flatCoordinates_=e,this.flatInteriorPoints_=null,this.flatMidpoints_=null,this.ends_=i||null,this.properties_=r,this.squaredTolerance_,this.stride_=s,this.simplifiedGeometry_}get(t){return this.properties_[t]}getExtent(){return this.extent_||(this.extent_=this.type_==="Point"?ua(this.flatCoordinates_):Vs(this.flatCoordinates_,0,this.flatCoordinates_.length,2)),this.extent_}getFlatInteriorPoint(){if(!this.flatInteriorPoints_){const t=Ye(this.getExtent());this.flatInteriorPoints_=gr(this.flatCoordinates_,0,this.ends_,2,t,0)}return this.flatInteriorPoints_}getFlatInteriorPoints(){if(!this.flatInteriorPoints_){const t=ku(this.flatCoordinates_,this.ends_),e=Kg(this.flatCoordinates_,0,t,2);this.flatInteriorPoints_=Lu(this.flatCoordinates_,0,t,2,e)}return this.flatInteriorPoints_}getFlatMidpoint(){return this.flatMidpoints_||(this.flatMidpoints_=oh(this.flatCoordinates_,0,this.flatCoordinates_.length,2,.5)),this.flatMidpoints_}getFlatMidpoints(){if(!this.flatMidpoints_){this.flatMidpoints_=[];const t=this.flatCoordinates_;let e=0;const i=this.ends_;for(let s=0,r=i.length;s<r;++s){const o=i[s],a=oh(t,e,o,2,.5);Xs(this.flatMidpoints_,a),e=o}}return this.flatMidpoints_}getId(){return this.id_}getOrientedFlatCoordinates(){return this.flatCoordinates_}getGeometry(){return this}getSimplifiedGeometry(t){return this}simplifyTransformed(t,e){return this}getProperties(){return this.properties_}getPropertiesInternal(){return this.properties_}getStride(){return this.stride_}getStyleFunction(){return this.styleFunction}getType(){return this.type_}transform(t){t=Dt(t);const e=t.getExtent(),i=t.getWorldExtent();if(e&&i){const s=It(i)/It(e);fe(gh,i[0],i[3],s,-s,0,0,0),Me(this.flatCoordinates_,0,this.flatCoordinates_.length,2,gh,this.flatCoordinates_)}}applyTransform(t){t(this.flatCoordinates_,this.flatCoordinates_,this.stride_)}clone(){return new te(this.type_,this.flatCoordinates_.slice(),this.ends_?.slice(),this.stride_,Object.assign({},this.properties_),this.id_)}getEnds(){return this.ends_}enableSimplifyTransformed(){return this.simplifyTransformed=Qo((t,e)=>{if(t===this.squaredTolerance_)return this.simplifiedGeometry_;this.simplifiedGeometry_=this.clone(),e&&this.simplifiedGeometry_.applyTransform(e);const i=this.simplifiedGeometry_.getFlatCoordinates();let s;switch(this.type_){case"LineString":i.length=fr(i,0,this.simplifiedGeometry_.flatCoordinates_.length,this.simplifiedGeometry_.stride_,t,i,0),s=[i.length];break;case"MultiLineString":s=[],i.length=Tu(i,0,this.simplifiedGeometry_.ends_,this.simplifiedGeometry_.stride_,t,i,0,s);break;case"Polygon":s=[],i.length=Za(i,0,this.simplifiedGeometry_.ends_,this.simplifiedGeometry_.stride_,Math.sqrt(t),i,0,s);break}return s&&(this.simplifiedGeometry_=new te(this.type_,i,s,2,this.properties_,this.id_)),this.squaredTolerance_=t,this.simplifiedGeometry_}),this}}te.prototype.getFlatCoordinates=te.prototype.getOrientedFlatCoordinates;class _h{constructor(t){this.rbush_=new dl(t),this.items_={}}insert(t,e){const i={minX:t[0],minY:t[1],maxX:t[2],maxY:t[3],value:e};this.rbush_.insert(i),this.items_[q(e)]=i}load(t,e){const i=new Array(e.length);for(let s=0,r=e.length;s<r;s++){const o=t[s],a=e[s],l={minX:o[0],minY:o[1],maxX:o[2],maxY:o[3],value:a};i[s]=l,this.items_[q(a)]=l}this.rbush_.load(i)}remove(t){const e=q(t),i=this.items_[e];return delete this.items_[e],this.rbush_.remove(i)!==null}update(t,e){const i=this.items_[q(e)],s=[i.minX,i.minY,i.maxX,i.maxY];ji(s,t)||(this.remove(e),this.insert(t,e))}getAll(){return this.rbush_.all().map(function(e){return e.value})}getInExtent(t){const e={minX:t[0],minY:t[1],maxX:t[2],maxY:t[3]};return this.rbush_.search(e).map(function(s){return s.value})}forEach(t){return this.forEach_(this.getAll(),t)}forEachInExtent(t,e){return this.forEach_(this.getInExtent(t),e)}forEach_(t,e){let i;for(let s=0,r=t.length;s<r;s++)if(i=e(t[s]),i)return i;return i}isEmpty(){return oi(this.items_)}clear(){this.rbush_.clear(),this.items_={}}getExtent(t){const e=this.rbush_.toJSON();return Te(e.minX,e.minY,e.maxX,e.maxY,t)}concat(t){this.rbush_.load(t.rbush_.all());for(const e in t.items_)this.items_[e]=t.items_[e]}}const Kt={ADDFEATURE:"addfeature",CHANGEFEATURE:"changefeature",CLEAR:"clear",REMOVEFEATURE:"removefeature",FEATURESLOADSTART:"featuresloadstart",FEATURESLOADEND:"featuresloadend",FEATURESLOADERROR:"featuresloaderror"};class De extends ue{constructor(t,e,i){super(t),this.feature=e,this.features=i}}class jg extends sh{constructor(t){t=t||{},super({attributions:t.attributions,interpolate:!0,projection:void 0,state:"ready",wrapX:t.wrapX!==void 0?t.wrapX:!0}),this.on,this.once,this.un,this.loader_=Yi,this.format_=t.format||null,this.overlaps_=t.overlaps===void 0?!0:t.overlaps,this.url_=t.url,t.loader!==void 0?this.loader_=t.loader:this.url_!==void 0&&(Q(this.format_,"`format` must be set when `url` is set"),this.loader_=fh(this.url_,this.format_)),this.strategy_=t.strategy!==void 0?t.strategy:Ug;const e=t.useSpatialIndex!==void 0?t.useSpatialIndex:!0;this.featuresRtree_=e?new _h:null,this.loadedExtentsRtree_=new _h,this.loadingExtentsCount_=0,this.nullGeometryFeatures_={},this.idIndex_={},this.uidIndex_={},this.featureChangeKeys_={},this.featuresCollection_=null;let i,s;Array.isArray(t.features)?s=t.features:t.features&&(i=t.features,s=i.getArray()),!e&&i===void 0&&(i=new se(s)),s!==void 0&&this.addFeaturesInternal(s),i!==void 0&&this.bindFeaturesCollection_(i)}addFeature(t){this.addFeatureInternal(t),this.changed()}addFeatureInternal(t){const e=q(t);if(!this.addToIndex_(e,t)){this.featuresCollection_&&this.featuresCollection_.remove(t);return}this.setupChangeEvents_(e,t);const i=t.getGeometry();if(i){const s=i.getExtent();this.featuresRtree_&&this.featuresRtree_.insert(s,t)}else this.nullGeometryFeatures_[e]=t;this.dispatchEvent(new De(Kt.ADDFEATURE,t))}setupChangeEvents_(t,e){e instanceof te||(this.featureChangeKeys_[t]=[$(e,B.CHANGE,this.handleFeatureChange_,this),$(e,ri.PROPERTYCHANGE,this.handleFeatureChange_,this)])}addToIndex_(t,e){let i=!0;if(e.getId()!==void 0){const s=String(e.getId());if(!(s in this.idIndex_))this.idIndex_[s]=e;else if(e instanceof te){const r=this.idIndex_[s];r instanceof te?Array.isArray(r)?r.push(e):this.idIndex_[s]=[r,e]:i=!1}else i=!1}return i&&(Q(!(t in this.uidIndex_),"The passed `feature` was already added to the source"),this.uidIndex_[t]=e),i}addFeatures(t){this.addFeaturesInternal(t),this.changed()}addFeaturesInternal(t){const e=[],i=[],s=[];for(let r=0,o=t.length;r<o;r++){const a=t[r],l=q(a);this.addToIndex_(l,a)&&i.push(a)}for(let r=0,o=i.length;r<o;r++){const a=i[r],l=q(a);this.setupChangeEvents_(l,a);const h=a.getGeometry();if(h){const c=h.getExtent();e.push(c),s.push(a)}else this.nullGeometryFeatures_[l]=a}if(this.featuresRtree_&&this.featuresRtree_.load(e,s),this.hasListener(Kt.ADDFEATURE))for(let r=0,o=i.length;r<o;r++)this.dispatchEvent(new De(Kt.ADDFEATURE,i[r]))}bindFeaturesCollection_(t){let e=!1;this.addEventListener(Kt.ADDFEATURE,function(i){e||(e=!0,t.push(i.feature),e=!1)}),this.addEventListener(Kt.REMOVEFEATURE,function(i){e||(e=!0,t.remove(i.feature),e=!1)}),t.addEventListener(Ot.ADD,i=>{e||(e=!0,this.addFeature(i.element),e=!1)}),t.addEventListener(Ot.REMOVE,i=>{e||(e=!0,this.removeFeature(i.element),e=!1)}),this.featuresCollection_=t}clear(t){if(t){for(const i in this.featureChangeKeys_)this.featureChangeKeys_[i].forEach(at);this.featuresCollection_||(this.featureChangeKeys_={},this.idIndex_={},this.uidIndex_={})}else if(this.featuresRtree_){this.featuresRtree_.forEach(i=>{this.removeFeatureInternal(i)});for(const i in this.nullGeometryFeatures_)this.removeFeatureInternal(this.nullGeometryFeatures_[i])}this.featuresCollection_&&this.featuresCollection_.clear(),this.featuresRtree_&&this.featuresRtree_.clear(),this.nullGeometryFeatures_={};const e=new De(Kt.CLEAR);this.dispatchEvent(e),this.changed()}forEachFeature(t){if(this.featuresRtree_)return this.featuresRtree_.forEach(t);this.featuresCollection_&&this.featuresCollection_.forEach(t)}forEachFeatureAtCoordinateDirect(t,e){const i=[t[0],t[1],t[0],t[1]];return this.forEachFeatureInExtent(i,function(s){const r=s.getGeometry();if(r instanceof te||r.intersectsCoordinate(t))return e(s)})}forEachFeatureInExtent(t,e){if(this.featuresRtree_)return this.featuresRtree_.forEachInExtent(t,e);this.featuresCollection_&&this.featuresCollection_.forEach(e)}forEachFeatureIntersectingExtent(t,e){return this.forEachFeatureInExtent(t,function(i){const s=i.getGeometry();if(s instanceof te||s.intersectsExtent(t)){const r=e(i);if(r)return r}})}getFeaturesCollection(){return this.featuresCollection_}getFeatures(){let t;return this.featuresCollection_?t=this.featuresCollection_.getArray().slice(0):this.featuresRtree_&&(t=this.featuresRtree_.getAll(),oi(this.nullGeometryFeatures_)||Xs(t,Object.values(this.nullGeometryFeatures_))),t}getFeaturesAtCoordinate(t){const e=[];return this.forEachFeatureAtCoordinateDirect(t,function(i){e.push(i)}),e}getFeaturesInExtent(t,e){if(this.featuresRtree_){if(!(e&&e.canWrapX()&&this.getWrapX()))return this.featuresRtree_.getInExtent(t);const s=ma(t,e);return[].concat(...s.map(r=>this.featuresRtree_.getInExtent(r)))}return this.featuresCollection_?this.featuresCollection_.getArray().slice(0):[]}getClosestFeatureToCoordinate(t,e){const i=t[0],s=t[1];let r=null;const o=[NaN,NaN];let a=1/0;const l=[-1/0,-1/0,1/0,1/0];return e=e||Xi,this.featuresRtree_.forEachInExtent(l,function(h){if(e(h)){const c=h.getGeometry(),u=a;if(a=c instanceof te?0:c.closestPointXY(i,s,o,a),a<u){r=h;const d=Math.sqrt(a);l[0]=i-d,l[1]=s-d,l[2]=i+d,l[3]=s+d}}}),r}getExtent(t){return this.featuresRtree_.getExtent(t)}getFeatureById(t){const e=this.idIndex_[t.toString()];return e!==void 0?e:null}getFeatureByUid(t){const e=this.uidIndex_[t];return e!==void 0?e:null}getFormat(){return this.format_}getOverlaps(){return this.overlaps_}getUrl(){return this.url_}handleFeatureChange_(t){const e=t.target,i=q(e),s=e.getGeometry();if(!s)i in this.nullGeometryFeatures_||(this.featuresRtree_&&this.featuresRtree_.remove(e),this.nullGeometryFeatures_[i]=e);else{const o=s.getExtent();i in this.nullGeometryFeatures_?(delete this.nullGeometryFeatures_[i],this.featuresRtree_&&this.featuresRtree_.insert(o,e)):this.featuresRtree_&&this.featuresRtree_.update(o,e)}const r=e.getId();if(r!==void 0){const o=r.toString();this.idIndex_[o]!==e&&(this.removeFromIdIndex_(e),this.idIndex_[o]=e)}else this.removeFromIdIndex_(e),this.uidIndex_[i]=e;this.changed(),this.dispatchEvent(new De(Kt.CHANGEFEATURE,e))}hasFeature(t){const e=t.getId();return e!==void 0?e in this.idIndex_:q(t)in this.uidIndex_}isEmpty(){return this.featuresRtree_?this.featuresRtree_.isEmpty()&&oi(this.nullGeometryFeatures_):this.featuresCollection_?this.featuresCollection_.getLength()===0:!0}loadFeatures(t,e,i){const s=this.loadedExtentsRtree_,r=this.strategy_(t,e,i);for(let o=0,a=r.length;o<a;++o){const l=r[o];s.forEachInExtent(l,function(c){return Ki(c.extent,l)})||(++this.loadingExtentsCount_,this.dispatchEvent(new De(Kt.FEATURESLOADSTART)),this.loader_.call(this,l,e,i,c=>{--this.loadingExtentsCount_,this.dispatchEvent(new De(Kt.FEATURESLOADEND,void 0,c))},()=>{--this.loadingExtentsCount_,this.dispatchEvent(new De(Kt.FEATURESLOADERROR))}),s.insert(l,{extent:l.slice()}))}this.loading=this.loader_.length<4?!1:this.loadingExtentsCount_>0}refresh(){this.clear(!0),this.loadedExtentsRtree_.clear(),super.refresh()}removeLoadedExtent(t){const e=this.loadedExtentsRtree_,i=e.forEachInExtent(t,function(s){if(ji(s.extent,t))return s});i&&e.remove(i)}removeFeatures(t){let e=!1;for(let i=0,s=t.length;i<s;++i)e=this.removeFeatureInternal(t[i])||e;e&&this.changed()}removeFeature(t){if(!t)return;this.removeFeatureInternal(t)&&this.changed()}removeFeatureInternal(t){const e=q(t);if(!(e in this.uidIndex_))return!1;e in this.nullGeometryFeatures_?delete this.nullGeometryFeatures_[e]:this.featuresRtree_&&this.featuresRtree_.remove(t),this.featureChangeKeys_[e]?.forEach(at),delete this.featureChangeKeys_[e];const s=t.getId();if(s!==void 0){const r=s.toString(),o=this.idIndex_[r];o===t?delete this.idIndex_[r]:Array.isArray(o)&&(o.splice(o.indexOf(t),1),o.length===1&&(this.idIndex_[r]=o[0]))}return delete this.uidIndex_[e],this.hasListener(Kt.REMOVEFEATURE)&&this.dispatchEvent(new De(Kt.REMOVEFEATURE,t)),!0}removeFromIdIndex_(t){for(const e in this.idIndex_)if(this.idIndex_[e]===t){delete this.idIndex_[e];break}}setLoader(t){this.loader_=t}setUrl(t){Q(this.format_,"`format` must be set when `url` is set"),this.url_=t,this.setLoader(fh(t,this.format_))}setOverlaps(t){this.overlaps_=t,this.changed()}}const F={BEGIN_GEOMETRY:0,BEGIN_PATH:1,CIRCLE:2,CLOSE_PATH:3,CUSTOM:4,DRAW_CHARS:5,DRAW_IMAGE:6,END_GEOMETRY:7,FILL:8,MOVE_TO_LINE_TO:9,SET_FILL_STYLE:10,SET_STROKE_STYLE:11,STROKE:12},Rs=[F.FILL],ke=[F.STROKE],Qe=[F.BEGIN_PATH],mh=[F.CLOSE_PATH];class vn extends ah{constructor(t,e,i,s){super(),this.tolerance=t,this.maxExtent=e,this.pixelRatio=s,this.maxLineWidth=0,this.resolution=i,this.beginGeometryInstruction1_=null,this.beginGeometryInstruction2_=null,this.bufferedMaxExtent_=null,this.instructions=[],this.coordinates=[],this.tmpCoordinate_=[],this.hitDetectionInstructions=[],this.state={}}applyPixelRatio(t){const e=this.pixelRatio;return e==1?t:t.map(function(i){return i*e})}appendFlatPointCoordinates(t,e){const i=this.getBufferedMaxExtent(),s=this.tmpCoordinate_,r=this.coordinates;let o=r.length;for(let a=0,l=t.length;a<l;a+=e)s[0]=t[a],s[1]=t[a+1],ci(i,s)&&(r[o++]=s[0],r[o++]=s[1]);return o}appendFlatLineCoordinates(t,e,i,s,r,o){const a=this.coordinates;let l=a.length;const h=this.getBufferedMaxExtent();o&&(e+=s);let c=t[e],u=t[e+1];const d=this.tmpCoordinate_;let f=!0,g,m,_;for(g=e+s;g<i;g+=s)d[0]=t[g],d[1]=t[g+1],_=js(h,d),_!==m?(f&&(a[l++]=c,a[l++]=u,f=!1),a[l++]=d[0],a[l++]=d[1]):_===pt.INTERSECTING?(a[l++]=d[0],a[l++]=d[1],f=!1):f=!0,c=d[0],u=d[1],m=_;return(r&&f||g===e+s)&&(a[l++]=c,a[l++]=u),l}drawCustomCoordinates_(t,e,i,s,r){for(let o=0,a=i.length;o<a;++o){const l=i[o],h=this.appendFlatLineCoordinates(t,e,l,s,!1,!1);r.push(h),e=l}return e}drawCustom(t,e,i,s,r){this.beginGeometry(t,e,r);const o=t.getType(),a=t.getStride(),l=this.coordinates.length;let h,c,u,d,f;switch(o){case"MultiPolygon":h=t.getOrientedFlatCoordinates(),d=[];const g=t.getEndss();f=0;for(let m=0,_=g.length;m<_;++m){const p=[];f=this.drawCustomCoordinates_(h,f,g[m],a,p),d.push(p)}this.instructions.push([F.CUSTOM,l,d,t,i,Va,r]),this.hitDetectionInstructions.push([F.CUSTOM,l,d,t,s||i,Va,r]);break;case"Polygon":case"MultiLineString":u=[],h=o=="Polygon"?t.getOrientedFlatCoordinates():t.getFlatCoordinates(),f=this.drawCustomCoordinates_(h,0,t.getEnds(),a,u),this.instructions.push([F.CUSTOM,l,u,t,i,es,r]),this.hitDetectionInstructions.push([F.CUSTOM,l,u,t,s||i,es,r]);break;case"LineString":case"Circle":h=t.getFlatCoordinates(),c=this.appendFlatLineCoordinates(h,0,h.length,a,!1,!1),this.instructions.push([F.CUSTOM,l,c,t,i,mi,r]),this.hitDetectionInstructions.push([F.CUSTOM,l,c,t,s||i,mi,r]);break;case"MultiPoint":h=t.getFlatCoordinates(),c=this.appendFlatPointCoordinates(h,a),c>l&&(this.instructions.push([F.CUSTOM,l,c,t,i,mi,r]),this.hitDetectionInstructions.push([F.CUSTOM,l,c,t,s||i,mi,r]));break;case"Point":h=t.getFlatCoordinates(),this.coordinates.push(h[0],h[1]),c=this.coordinates.length,this.instructions.push([F.CUSTOM,l,c,t,i,void 0,r]),this.hitDetectionInstructions.push([F.CUSTOM,l,c,t,s||i,void 0,r]);break}this.endGeometry(e)}beginGeometry(t,e,i){this.beginGeometryInstruction1_=[F.BEGIN_GEOMETRY,e,0,t,i],this.instructions.push(this.beginGeometryInstruction1_),this.beginGeometryInstruction2_=[F.BEGIN_GEOMETRY,e,0,t,i],this.hitDetectionInstructions.push(this.beginGeometryInstruction2_)}finish(){return{instructions:this.instructions,hitDetectionInstructions:this.hitDetectionInstructions,coordinates:this.coordinates}}reverseHitDetectionInstructions(){const t=this.hitDetectionInstructions;t.reverse();let e;const i=t.length;let s,r,o=-1;for(e=0;e<i;++e)s=t[e],r=s[0],r==F.END_GEOMETRY?o=e:r==F.BEGIN_GEOMETRY&&(s[2]=e,uc(this.hitDetectionInstructions,o,e),o=-1)}fillStyleToState(t,e={}){if(t){const i=t.getColor();e.fillPatternScale=i&&typeof i=="object"&&"src"in i?this.pixelRatio:1,e.fillStyle=oe(i||Nt)}else e.fillStyle=void 0;return e}strokeStyleToState(t,e={}){if(t){const i=t.getColor();e.strokeStyle=oe(i||fn);const s=t.getLineCap();e.lineCap=s!==void 0?s:Ci;const r=t.getLineDash();e.lineDash=r?r.slice():_e;const o=t.getLineDashOffset();e.lineDashOffset=o||me;const a=t.getLineJoin();e.lineJoin=a!==void 0?a:Ri;const l=t.getWidth();e.lineWidth=l!==void 0?l:_n;const h=t.getMiterLimit();e.miterLimit=h!==void 0?h:dn,e.lineWidth>this.maxLineWidth&&(this.maxLineWidth=e.lineWidth,this.bufferedMaxExtent_=null)}else e.strokeStyle=void 0,e.lineCap=void 0,e.lineDash=null,e.lineDashOffset=void 0,e.lineJoin=void 0,e.lineWidth=void 0,e.miterLimit=void 0;return e}setFillStrokeStyle(t,e){const i=this.state;this.fillStyleToState(t,i),this.strokeStyleToState(e,i)}createFill(t){const e=t.fillStyle,i=[F.SET_FILL_STYLE,e];return typeof e!="string"&&i.push(t.fillPatternScale),i}applyStroke(t){this.instructions.push(this.createStroke(t))}createStroke(t){return[F.SET_STROKE_STYLE,t.strokeStyle,t.lineWidth*this.pixelRatio,t.lineCap,t.lineJoin,t.miterLimit,t.lineDash?this.applyPixelRatio(t.lineDash):null,t.lineDashOffset*this.pixelRatio]}updateFillStyle(t,e){const i=t.fillStyle;(typeof i!="string"||t.currentFillStyle!=i)&&(this.instructions.push(e.call(this,t)),t.currentFillStyle=i)}updateStrokeStyle(t,e){const i=t.strokeStyle,s=t.lineCap,r=t.lineDash,o=t.lineDashOffset,a=t.lineJoin,l=t.lineWidth,h=t.miterLimit;(t.currentStrokeStyle!=i||t.currentLineCap!=s||r!=t.currentLineDash&&!Ce(t.currentLineDash,r)||t.currentLineDashOffset!=o||t.currentLineJoin!=a||t.currentLineWidth!=l||t.currentMiterLimit!=h)&&(e.call(this,t),t.currentStrokeStyle=i,t.currentLineCap=s,t.currentLineDash=r,t.currentLineDashOffset=o,t.currentLineJoin=a,t.currentLineWidth=l,t.currentMiterLimit=h)}endGeometry(t){this.beginGeometryInstruction1_[2]=this.instructions.length,this.beginGeometryInstruction1_=null,this.beginGeometryInstruction2_[2]=this.hitDetectionInstructions.length,this.beginGeometryInstruction2_=null;const e=[F.END_GEOMETRY,t];this.instructions.push(e),this.hitDetectionInstructions.push(e)}getBufferedMaxExtent(){if(!this.bufferedMaxExtent_&&(this.bufferedMaxExtent_=la(this.maxExtent),this.maxLineWidth>0)){const t=this.resolution*(this.maxLineWidth+1)/2;Ks(this.bufferedMaxExtent_,t,this.bufferedMaxExtent_)}return this.bufferedMaxExtent_}}class Vg extends vn{constructor(t,e,i,s){super(t,e,i,s),this.hitDetectionImage_=null,this.image_=null,this.imagePixelRatio_=void 0,this.anchorX_=void 0,this.anchorY_=void 0,this.height_=void 0,this.opacity_=void 0,this.originX_=void 0,this.originY_=void 0,this.rotateWithView_=void 0,this.rotation_=void 0,this.scale_=void 0,this.width_=void 0,this.declutterMode_=void 0,this.declutterImageWithText_=void 0}drawPoint(t,e,i){if(!this.image_||this.maxExtent&&!ci(this.maxExtent,t.getFlatCoordinates()))return;this.beginGeometry(t,e,i);const s=t.getFlatCoordinates(),r=t.getStride(),o=this.coordinates.length,a=this.appendFlatPointCoordinates(s,r);this.instructions.push([F.DRAW_IMAGE,o,a,this.image_,this.anchorX_*this.imagePixelRatio_,this.anchorY_*this.imagePixelRatio_,Math.ceil(this.height_*this.imagePixelRatio_),this.opacity_,this.originX_*this.imagePixelRatio_,this.originY_*this.imagePixelRatio_,this.rotateWithView_,this.rotation_,[this.scale_[0]*this.pixelRatio/this.imagePixelRatio_,this.scale_[1]*this.pixelRatio/this.imagePixelRatio_],Math.ceil(this.width_*this.imagePixelRatio_),this.declutterMode_,this.declutterImageWithText_]),this.hitDetectionInstructions.push([F.DRAW_IMAGE,o,a,this.hitDetectionImage_,this.anchorX_,this.anchorY_,this.height_,1,this.originX_,this.originY_,this.rotateWithView_,this.rotation_,this.scale_,this.width_,this.declutterMode_,this.declutterImageWithText_]),this.endGeometry(e)}drawMultiPoint(t,e,i){if(!this.image_)return;this.beginGeometry(t,e,i);const s=t.getFlatCoordinates(),r=[];for(let l=0,h=s.length;l<h;l+=t.getStride())(!this.maxExtent||ci(this.maxExtent,s.slice(l,l+2)))&&r.push(s[l],s[l+1]);const o=this.coordinates.length,a=this.appendFlatPointCoordinates(r,2);this.instructions.push([F.DRAW_IMAGE,o,a,this.image_,this.anchorX_*this.imagePixelRatio_,this.anchorY_*this.imagePixelRatio_,Math.ceil(this.height_*this.imagePixelRatio_),this.opacity_,this.originX_*this.imagePixelRatio_,this.originY_*this.imagePixelRatio_,this.rotateWithView_,this.rotation_,[this.scale_[0]*this.pixelRatio/this.imagePixelRatio_,this.scale_[1]*this.pixelRatio/this.imagePixelRatio_],Math.ceil(this.width_*this.imagePixelRatio_),this.declutterMode_,this.declutterImageWithText_]),this.hitDetectionInstructions.push([F.DRAW_IMAGE,o,a,this.hitDetectionImage_,this.anchorX_,this.anchorY_,this.height_,1,this.originX_,this.originY_,this.rotateWithView_,this.rotation_,this.scale_,this.width_,this.declutterMode_,this.declutterImageWithText_]),this.endGeometry(e)}finish(){return this.reverseHitDetectionInstructions(),this.anchorX_=void 0,this.anchorY_=void 0,this.hitDetectionImage_=null,this.image_=null,this.imagePixelRatio_=void 0,this.height_=void 0,this.scale_=void 0,this.opacity_=void 0,this.originX_=void 0,this.originY_=void 0,this.rotateWithView_=void 0,this.rotation_=void 0,this.width_=void 0,super.finish()}setImageStyle(t,e){const i=t.getAnchor(),s=t.getSize(),r=t.getOrigin();this.imagePixelRatio_=t.getPixelRatio(this.pixelRatio),this.anchorX_=i[0],this.anchorY_=i[1],this.hitDetectionImage_=t.getHitDetectionImage(),this.image_=t.getImage(this.pixelRatio),this.height_=s[1],this.opacity_=t.getOpacity(),this.originX_=r[0],this.originY_=r[1],this.rotateWithView_=t.getRotateWithView(),this.rotation_=t.getRotation(),this.scale_=t.getScaleArray(),this.width_=s[0],this.declutterMode_=t.getDeclutterMode(),this.declutterImageWithText_=e}}class Zg extends vn{constructor(t,e,i,s){super(t,e,i,s)}drawFlatCoordinates_(t,e,i,s){const r=this.coordinates.length,o=this.appendFlatLineCoordinates(t,e,i,s,!1,!1),a=[F.MOVE_TO_LINE_TO,r,o];return this.instructions.push(a),this.hitDetectionInstructions.push(a),i}drawLineString(t,e,i){const s=this.state,r=s.strokeStyle,o=s.lineWidth;if(r===void 0||o===void 0)return;this.updateStrokeStyle(s,this.applyStroke),this.beginGeometry(t,e,i),this.hitDetectionInstructions.push([F.SET_STROKE_STYLE,s.strokeStyle,s.lineWidth,s.lineCap,s.lineJoin,s.miterLimit,_e,me],Qe);const a=t.getFlatCoordinates(),l=t.getStride();this.drawFlatCoordinates_(a,0,a.length,l),this.hitDetectionInstructions.push(ke),this.endGeometry(e)}drawMultiLineString(t,e,i){const s=this.state,r=s.strokeStyle,o=s.lineWidth;if(r===void 0||o===void 0)return;this.updateStrokeStyle(s,this.applyStroke),this.beginGeometry(t,e,i),this.hitDetectionInstructions.push([F.SET_STROKE_STYLE,s.strokeStyle,s.lineWidth,s.lineCap,s.lineJoin,s.miterLimit,_e,me],Qe);const a=t.getEnds(),l=t.getFlatCoordinates(),h=t.getStride();let c=0;for(let u=0,d=a.length;u<d;++u)c=this.drawFlatCoordinates_(l,c,a[u],h);this.hitDetectionInstructions.push(ke),this.endGeometry(e)}finish(){const t=this.state;return t.lastStroke!=null&&t.lastStroke!=this.coordinates.length&&this.instructions.push(ke),this.reverseHitDetectionInstructions(),this.state=null,super.finish()}applyStroke(t){t.lastStroke!=null&&t.lastStroke!=this.coordinates.length&&(this.instructions.push(ke),t.lastStroke=this.coordinates.length),t.lastStroke=0,super.applyStroke(t),this.instructions.push(Qe)}}class ph extends vn{constructor(t,e,i,s){super(t,e,i,s)}drawFlatCoordinatess_(t,e,i,s){const r=this.state,o=r.fillStyle!==void 0,a=r.strokeStyle!==void 0,l=i.length;this.instructions.push(Qe),this.hitDetectionInstructions.push(Qe);for(let h=0;h<l;++h){const c=i[h],u=this.coordinates.length,d=this.appendFlatLineCoordinates(t,e,c,s,!0,!a),f=[F.MOVE_TO_LINE_TO,u,d];this.instructions.push(f),this.hitDetectionInstructions.push(f),a&&(this.instructions.push(mh),this.hitDetectionInstructions.push(mh)),e=c}return o&&(this.instructions.push(Rs),this.hitDetectionInstructions.push(Rs)),a&&(this.instructions.push(ke),this.hitDetectionInstructions.push(ke)),e}drawCircle(t,e,i){const s=this.state,r=s.fillStyle,o=s.strokeStyle;if(r===void 0&&o===void 0)return;this.setFillStrokeStyles_(),this.beginGeometry(t,e,i),s.fillStyle!==void 0&&this.hitDetectionInstructions.push([F.SET_FILL_STYLE,Nt]),s.strokeStyle!==void 0&&this.hitDetectionInstructions.push([F.SET_STROKE_STYLE,s.strokeStyle,s.lineWidth,s.lineCap,s.lineJoin,s.miterLimit,_e,me]);const a=t.getFlatCoordinates(),l=t.getStride(),h=this.coordinates.length;this.appendFlatLineCoordinates(a,0,a.length,l,!1,!1);const c=[F.CIRCLE,h];this.instructions.push(Qe,c),this.hitDetectionInstructions.push(Qe,c),s.fillStyle!==void 0&&(this.instructions.push(Rs),this.hitDetectionInstructions.push(Rs)),s.strokeStyle!==void 0&&(this.instructions.push(ke),this.hitDetectionInstructions.push(ke)),this.endGeometry(e)}drawPolygon(t,e,i){const s=this.state,r=s.fillStyle,o=s.strokeStyle;if(r===void 0&&o===void 0)return;this.setFillStrokeStyles_(),this.beginGeometry(t,e,i),s.fillStyle!==void 0&&this.hitDetectionInstructions.push([F.SET_FILL_STYLE,Nt]),s.strokeStyle!==void 0&&this.hitDetectionInstructions.push([F.SET_STROKE_STYLE,s.strokeStyle,s.lineWidth,s.lineCap,s.lineJoin,s.miterLimit,_e,me]);const a=t.getEnds(),l=t.getOrientedFlatCoordinates(),h=t.getStride();this.drawFlatCoordinatess_(l,0,a,h),this.endGeometry(e)}drawMultiPolygon(t,e,i){const s=this.state,r=s.fillStyle,o=s.strokeStyle;if(r===void 0&&o===void 0)return;this.setFillStrokeStyles_(),this.beginGeometry(t,e,i),s.fillStyle!==void 0&&this.hitDetectionInstructions.push([F.SET_FILL_STYLE,Nt]),s.strokeStyle!==void 0&&this.hitDetectionInstructions.push([F.SET_STROKE_STYLE,s.strokeStyle,s.lineWidth,s.lineCap,s.lineJoin,s.miterLimit,_e,me]);const a=t.getEndss(),l=t.getOrientedFlatCoordinates(),h=t.getStride();let c=0;for(let u=0,d=a.length;u<d;++u)c=this.drawFlatCoordinatess_(l,c,a[u],h);this.endGeometry(e)}finish(){this.reverseHitDetectionInstructions(),this.state=null;const t=this.tolerance;if(t!==0){const e=this.coordinates;for(let i=0,s=e.length;i<s;++i)e[i]=Ve(e[i],t)}return super.finish()}setFillStrokeStyles_(){const t=this.state;this.updateFillStyle(t,this.createFill),this.updateStrokeStyle(t,this.applyStroke)}}function $g(n,t,e,i,s){const r=[];let o=e,a=0,l=t.slice(e,2);for(;a<n&&o+s<i;){const[h,c]=l.slice(-2),u=t[o+s],d=t[o+s+1],f=Math.sqrt((u-h)*(u-h)+(d-c)*(d-c));if(a+=f,a>=n){const g=(n-a+f)/f,m=Wt(h,u,g),_=Wt(c,d,g);l.push(m,_),r.push(l),l=[m,_],a==n&&(o+=s),a=0}else if(a<n)l.push(t[o+s],t[o+s+1]),o+=s;else{const g=f-a,m=Wt(h,u,g/f),_=Wt(c,d,g/f);l.push(m,_),r.push(l),l=[m,_],a=0,o+=s}}return a>0&&r.push(l),r}function Hg(n,t,e,i,s){let r=e,o=e,a=0,l=0,h=e,c,u,d,f,g,m,_,p,y,v;for(u=e;u<i;u+=s){const x=t[u],w=t[u+1];g!==void 0&&(y=x-g,v=w-m,f=Math.sqrt(y*y+v*v),_!==void 0&&(l+=d,c=Math.acos((_*y+p*v)/(d*f)),c>n&&(l>a&&(a=l,r=h,o=u),l=0,h=u-s)),d=f,_=y,p=v),g=x,m=w}return l+=f,l>a?[h,u]:[r,o]}const Ss={left:0,center:.5,right:1,top:0,middle:.5,hanging:.2,alphabetic:.8,ideographic:.8,bottom:1};class qg extends vn{constructor(t,e,i,s){super(t,e,i,s),this.labels_=null,this.text_="",this.textOffsetX_=0,this.textOffsetY_=0,this.textRotateWithView_=void 0,this.textKeepUpright_=void 0,this.textRotation_=0,this.textFillState_=null,this.fillStates={},this.fillStates[Nt]={fillStyle:Nt},this.textStrokeState_=null,this.strokeStates={},this.textState_={},this.textStates={},this.textKey_="",this.fillKey_="",this.strokeKey_="",this.declutterMode_=void 0,this.declutterImageWithText_=void 0}finish(){const t=super.finish();return t.textStates=this.textStates,t.fillStates=this.fillStates,t.strokeStates=this.strokeStates,t}drawText(t,e,i){const s=this.textFillState_,r=this.textStrokeState_,o=this.textState_;if(this.text_===""||!o||!s&&!r)return;const a=this.coordinates;let l=a.length;const h=t.getType();let c=null,u=t.getStride();if(o.placement==="line"&&(h=="LineString"||h=="MultiLineString"||h=="Polygon"||h=="MultiPolygon")){if(!Pt(this.maxExtent,t.getExtent()))return;let d;if(c=t.getFlatCoordinates(),h=="LineString")d=[c.length];else if(h=="MultiLineString")d=t.getEnds();else if(h=="Polygon")d=t.getEnds().slice(0,1);else if(h=="MultiPolygon"){const _=t.getEndss();d=[];for(let p=0,y=_.length;p<y;++p)d.push(_[p][0])}this.beginGeometry(t,e,i);const f=o.repeat,g=f?void 0:o.textAlign;let m=0;for(let _=0,p=d.length;_<p;++_){let y;f?y=$g(f*this.resolution,c,m,d[_],u):y=[c.slice(m,d[_])];for(let v=0,x=y.length;v<x;++v){const w=y[v];let R=0,T=w.length;if(g==null){const I=Hg(o.maxAngle,w,0,w.length,2);R=I[0],T=I[1]}for(let I=R;I<T;I+=u)a.push(w[I],w[I+1]);const S=a.length;m=d[_],this.drawChars_(l,S),l=S}}this.endGeometry(e)}else{let d=o.overflow?null:[];switch(h){case"Point":case"MultiPoint":c=t.getFlatCoordinates();break;case"LineString":c=t.getFlatMidpoint();break;case"Circle":c=t.getCenter();break;case"MultiLineString":c=t.getFlatMidpoints(),u=2;break;case"Polygon":c=t.getFlatInteriorPoint(),o.overflow||d.push(c[2]/this.resolution),u=3;break;case"MultiPolygon":const x=t.getFlatInteriorPoints();c=[];for(let w=0,R=x.length;w<R;w+=3)o.overflow||d.push(x[w+2]/this.resolution),c.push(x[w],x[w+1]);if(c.length===0)return;u=2;break}const f=this.appendFlatPointCoordinates(c,u);if(f===l)return;if(d&&(f-l)/2!==c.length/u){let x=l/2;d=d.filter((w,R)=>{const T=a[(x+R)*2]===c[R*u]&&a[(x+R)*2+1]===c[R*u+1];return T||--x,T})}this.saveTextStates_();const g=o.backgroundFill?this.createFill(this.fillStyleToState(o.backgroundFill)):null,m=o.backgroundStroke?this.createStroke(this.strokeStyleToState(o.backgroundStroke)):null;this.beginGeometry(t,e,i);let _=o.padding;if(_!=Je&&(o.scale[0]<0||o.scale[1]<0)){let x=o.padding[0],w=o.padding[1],R=o.padding[2],T=o.padding[3];o.scale[0]<0&&(w=-w,T=-T),o.scale[1]<0&&(x=-x,R=-R),_=[x,w,R,T]}const p=this.pixelRatio;this.instructions.push([F.DRAW_IMAGE,l,f,null,NaN,NaN,NaN,1,0,0,this.textRotateWithView_,this.textRotation_,[1,1],NaN,this.declutterMode_,this.declutterImageWithText_,_==Je?Je:_.map(function(x){return x*p}),g,m,this.text_,this.textKey_,this.strokeKey_,this.fillKey_,this.textOffsetX_,this.textOffsetY_,d]);const y=1/p,v=g?g.slice(0):null;v&&(v[1]=Nt),this.hitDetectionInstructions.push([F.DRAW_IMAGE,l,f,null,NaN,NaN,NaN,1,0,0,this.textRotateWithView_,this.textRotation_,[y,y],NaN,this.declutterMode_,this.declutterImageWithText_,_,v,m,this.text_,this.textKey_,this.strokeKey_,this.fillKey_?Nt:this.fillKey_,this.textOffsetX_,this.textOffsetY_,d]),this.endGeometry(e)}}saveTextStates_(){const t=this.textStrokeState_,e=this.textState_,i=this.textFillState_,s=this.strokeKey_;t&&(s in this.strokeStates||(this.strokeStates[s]={strokeStyle:t.strokeStyle,lineCap:t.lineCap,lineDashOffset:t.lineDashOffset,lineWidth:t.lineWidth,lineJoin:t.lineJoin,miterLimit:t.miterLimit,lineDash:t.lineDash}));const r=this.textKey_;r in this.textStates||(this.textStates[r]={font:e.font,textAlign:e.textAlign||gn,justify:e.justify,textBaseline:e.textBaseline||fs,scale:e.scale});const o=this.fillKey_;i&&(o in this.fillStates||(this.fillStates[o]={fillStyle:i.fillStyle}))}drawChars_(t,e){const i=this.textStrokeState_,s=this.textState_,r=this.strokeKey_,o=this.textKey_,a=this.fillKey_;this.saveTextStates_();const l=this.pixelRatio,h=Ss[s.textBaseline],c=this.textOffsetY_*l,u=this.text_,d=i?i.lineWidth*Math.abs(s.scale[0])/2:0;this.instructions.push([F.DRAW_CHARS,t,e,h,s.overflow,a,s.maxAngle,l,c,r,d*l,u,o,1,this.declutterMode_,this.textKeepUpright_]),this.hitDetectionInstructions.push([F.DRAW_CHARS,t,e,h,s.overflow,a&&Nt,s.maxAngle,l,c,r,d*l,u,o,1/l,this.declutterMode_,this.textKeepUpright_])}setTextStyle(t,e){let i,s,r;if(!t)this.text_="";else{const o=t.getFill();o?(s=this.textFillState_,s||(s={},this.textFillState_=s),s.fillStyle=oe(o.getColor()||Nt)):(s=null,this.textFillState_=s);const a=t.getStroke();if(!a)r=null,this.textStrokeState_=r;else{r=this.textStrokeState_,r||(r={},this.textStrokeState_=r);const m=a.getLineDash(),_=a.getLineDashOffset(),p=a.getWidth(),y=a.getMiterLimit();r.lineCap=a.getLineCap()||Ci,r.lineDash=m?m.slice():_e,r.lineDashOffset=_===void 0?me:_,r.lineJoin=a.getLineJoin()||Ri,r.lineWidth=p===void 0?_n:p,r.miterLimit=y===void 0?dn:y,r.strokeStyle=oe(a.getColor()||fn)}i=this.textState_;const l=t.getFont()||Rl;gf(l);const h=t.getScaleArray();i.overflow=t.getOverflow(),i.font=l,i.maxAngle=t.getMaxAngle(),i.placement=t.getPlacement(),i.textAlign=t.getTextAlign(),i.repeat=t.getRepeat(),i.justify=t.getJustify(),i.textBaseline=t.getTextBaseline()||fs,i.backgroundFill=t.getBackgroundFill(),i.backgroundStroke=t.getBackgroundStroke(),i.padding=t.getPadding()||Je,i.scale=h===void 0?[1,1]:h;const c=t.getOffsetX(),u=t.getOffsetY(),d=t.getRotateWithView(),f=t.getKeepUpright(),g=t.getRotation();this.text_=t.getText()||"",this.textOffsetX_=c===void 0?0:c,this.textOffsetY_=u===void 0?0:u,this.textRotateWithView_=d===void 0?!1:d,this.textKeepUpright_=f===void 0?!0:f,this.textRotation_=g===void 0?0:g,this.strokeKey_=r?(typeof r.strokeStyle=="string"?r.strokeStyle:q(r.strokeStyle))+r.lineCap+r.lineDashOffset+"|"+r.lineWidth+r.lineJoin+r.miterLimit+"["+r.lineDash.join()+"]":"",this.textKey_=i.font+i.scale+(i.textAlign||"?")+(i.repeat||"?")+(i.justify||"?")+(i.textBaseline||"?"),this.fillKey_=s&&s.fillStyle?typeof s.fillStyle=="string"?s.fillStyle:"|"+q(s.fillStyle):""}this.declutterMode_=t.getDeclutterMode(),this.declutterImageWithText_=e}}const Jg={Circle:ph,Default:vn,Image:Vg,LineString:Zg,Polygon:ph,Text:qg};class Qg{constructor(t,e,i,s){this.tolerance_=t,this.maxExtent_=e,this.pixelRatio_=s,this.resolution_=i,this.buildersByZIndex_={}}finish(){const t={};for(const e in this.buildersByZIndex_){t[e]=t[e]||{};const i=this.buildersByZIndex_[e];for(const s in i){const r=i[s].finish();t[e][s]=r}}return t}getBuilder(t,e){const i=t!==void 0?t.toString():"0";let s=this.buildersByZIndex_[i];s===void 0&&(s={},this.buildersByZIndex_[i]=s);let r=s[e];if(r===void 0){const o=Jg[e];r=new o(this.tolerance_,this.maxExtent_,this.resolution_,this.pixelRatio_),s[e]=r}return r}}function t_(n,t,e,i,s,r,o,a,l,h,c,u,d=!0){let f=n[t],g=n[t+1],m=0,_=0,p=0,y=0;function v(){m=f,_=g,t+=i,f=n[t],g=n[t+1],y+=p,p=Math.sqrt((f-m)*(f-m)+(g-_)*(g-_))}do v();while(t<e-i&&y+p<r);let x=p===0?0:(r-y)/p;const w=Wt(m,f,x),R=Wt(_,g,x),T=t-i,S=y,I=r+a*l(h,s,c);for(;t<e-i&&y+p<I;)v();x=p===0?0:(I-y)/p;const M=Wt(m,f,x),O=Wt(_,g,x);let L=!1;if(d)if(u){const G=[w,R,M,O];Ga(G,0,4,2,u,G,G),L=G[0]>G[2]}else L=w>M;const A=Math.PI,P=[],X=T+i===t;t=T,p=0,y=S,f=n[t],g=n[t+1];let k;if(X){v(),k=Math.atan2(g-_,f-m),L&&(k+=k>0?-A:A);const G=(M+w)/2,D=(O+R)/2;return P[0]=[G,D,(I-r)/2,k,s],P}s=s.replace(/\n/g," ");for(let G=0,D=s.length;G<D;){v();let Y=Math.atan2(g-_,f-m);if(L&&(Y+=Y>0?-A:A),k!==void 0){let ht=Y-k;if(ht+=ht>A?-2*A:ht<-A?2*A:0,Math.abs(ht)>o)return null}k=Y;const V=G;let tt=0;for(;G<D;++G){const ht=L?D-G-1:G,bt=a*l(h,s[ht],c);if(t+i<e&&y+p<r+tt+bt/2)break;tt+=bt}if(G===V)continue;const b=L?s.substring(D-V,D-G):s.substring(V,G);x=p===0?0:(r+tt/2-y)/p;const xt=Wt(m,f,x),ft=Wt(_,g,x);P.push([xt,ft,tt/2,Y,b]),r+=tt}return P}const Ai=Xt(),Fe=[],ye=[],xe=[],Ne=[];function yh(n){return n[3].declutterBox}const xh=new RegExp("[֑-ࣿיִ-﷿ﹰ-ﻼࠀ--]");function uo(n,t){return t==="start"?t=xh.test(n)?"right":"left":t==="end"&&(t=xh.test(n)?"left":"right"),Ss[t]}function e_(n,t,e){return e>0&&n.push(`
|
|
8
|
-
`,""),n.push(t,""),n}function i_(n,t,e){return e%2===0&&(n+=t),n}class n_{constructor(t,e,i,s,r){this.overlaps=i,this.pixelRatio=e,this.resolution=t,this.alignAndScaleFill_,this.instructions=s.instructions,this.coordinates=s.coordinates,this.coordinateCache_={},this.renderedTransform_=qt(),this.hitDetectionInstructions=s.hitDetectionInstructions,this.pixelCoordinates_=null,this.viewRotation_=0,this.fillStates=s.fillStates||{},this.strokeStates=s.strokeStates||{},this.textStates=s.textStates||{},this.widths_={},this.labels_={},this.zIndexContext_=r?new ql:null}getZIndexContext(){return this.zIndexContext_}createLabel(t,e,i,s){const r=t+e+i+s;if(this.labels_[r])return this.labels_[r];const o=s?this.strokeStates[s]:null,a=i?this.fillStates[i]:null,l=this.textStates[e],h=this.pixelRatio,c=[l.scale[0]*h,l.scale[1]*h],u=l.justify?Ss[l.justify]:uo(Array.isArray(t)?t[0]:t,l.textAlign||
|
|
7
|
+
`||h===c){r=Math.max(r,o),s.push(o),o=0,a+=l,l=0;continue}const d=t[h+1]||n.font,f=Tl(d,u);e.push(f),o+=f;const g=_f(d);i.push(g),l=Math.max(l,g)}return{width:r,height:a,widths:e,heights:i,lineWidths:s}}function pf(n,t,e,i,s,r,o,a,l,h,c){n.save(),e!==1&&(n.globalAlpha===void 0?n.globalAlpha=u=>u.globalAlpha*=e:n.globalAlpha*=e),t&&n.transform.apply(n,t),i.contextInstructions?(n.translate(l,h),n.scale(c[0],c[1]),yf(i,n)):c[0]<0||c[1]<0?(n.translate(l,h),n.scale(c[0],c[1]),n.drawImage(i,s,r,o,a,0,0,o,a)):n.drawImage(i,s,r,o,a,l,h,o*c[0],a*c[1]),n.restore()}function yf(n,t){const e=n.contextInstructions;for(let i=0,s=e.length;i<s;i+=2)Array.isArray(e[i+1])?t[e[i]].apply(t,e[i+1]):t[e[i]]=e[i+1]}class gs{constructor(t){this.opacity_=t.opacity,this.rotateWithView_=t.rotateWithView,this.rotation_=t.rotation,this.scale_=t.scale,this.scaleArray_=kt(t.scale),this.displacement_=t.displacement,this.declutterMode_=t.declutterMode}clone(){const t=this.getScale();return new gs({opacity:this.getOpacity(),scale:Array.isArray(t)?t.slice():t,rotation:this.getRotation(),rotateWithView:this.getRotateWithView(),displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()})}getOpacity(){return this.opacity_}getRotateWithView(){return this.rotateWithView_}getRotation(){return this.rotation_}getScale(){return this.scale_}getScaleArray(){return this.scaleArray_}getDisplacement(){return this.displacement_}getDeclutterMode(){return this.declutterMode_}getAnchor(){return H()}getImage(t){return H()}getHitDetectionImage(){return H()}getPixelRatio(t){return 1}getImageState(){return H()}getImageSize(){return H()}getOrigin(){return H()}getSize(){return H()}setDisplacement(t){this.displacement_=t}setOpacity(t){this.opacity_=t}setRotateWithView(t){this.rotateWithView_=t}setRotation(t){this.rotation_=t}setScale(t){this.scale_=t,this.scaleArray_=kt(t)}listenImageChange(t){H()}load(){H()}unlistenImageChange(t){H()}ready(){return Promise.resolve()}}class _s extends gs{constructor(t){super({opacity:1,rotateWithView:t.rotateWithView!==void 0?t.rotateWithView:!1,rotation:t.rotation!==void 0?t.rotation:0,scale:t.scale!==void 0?t.scale:1,displacement:t.displacement!==void 0?t.displacement:[0,0],declutterMode:t.declutterMode}),this.hitDetectionCanvas_=null,this.fill_=t.fill!==void 0?t.fill:null,this.origin_=[0,0],this.points_=t.points,this.radius=t.radius,this.radius2_=t.radius2,this.angle_=t.angle!==void 0?t.angle:0,this.stroke_=t.stroke!==void 0?t.stroke:null,this.size_,this.renderOptions_,this.imageState_=this.fill_&&this.fill_.loading()?K.LOADING:K.LOADED,this.imageState_===K.LOADING&&this.ready().then(()=>this.imageState_=K.LOADED),this.render()}clone(){const t=this.getScale(),e=new _s({fill:this.getFill()?this.getFill().clone():void 0,points:this.getPoints(),radius:this.getRadius(),radius2:this.getRadius2(),angle:this.getAngle(),stroke:this.getStroke()?this.getStroke().clone():void 0,rotation:this.getRotation(),rotateWithView:this.getRotateWithView(),scale:Array.isArray(t)?t.slice():t,displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()});return e.setOpacity(this.getOpacity()),e}getAnchor(){const t=this.size_,e=this.getDisplacement(),i=this.getScaleArray();return[t[0]/2-e[0]/i[0],t[1]/2+e[1]/i[1]]}getAngle(){return this.angle_}getFill(){return this.fill_}setFill(t){this.fill_=t,this.render()}getHitDetectionImage(){return this.hitDetectionCanvas_||(this.hitDetectionCanvas_=this.createHitDetectionCanvas_(this.renderOptions_)),this.hitDetectionCanvas_}getImage(t){const e=this.fill_?.getKey(),i=`${t},${this.angle_},${this.radius},${this.radius2_},${this.points_},${e}`+Object.values(this.renderOptions_).join(",");let s=Ut.get(i,null,null)?.getImage(1);if(!s){const r=this.renderOptions_,o=Math.ceil(r.size*t),a=gt(o,o);this.draw_(r,a,t),s=a.canvas,Ut.set(i,null,null,new Cl(s,void 0,null,K.LOADED,null))}return s}getPixelRatio(t){return t}getImageSize(){return this.size_}getImageState(){return this.imageState_}getOrigin(){return this.origin_}getPoints(){return this.points_}getRadius(){return this.radius}getRadius2(){return this.radius2_}getSize(){return this.size_}getStroke(){return this.stroke_}setStroke(t){this.stroke_=t,this.render()}listenImageChange(t){}load(){}unlistenImageChange(t){}calculateLineJoinSize_(t,e,i){if(e===0||this.points_===1/0||t!=="bevel"&&t!=="miter")return e;let s=this.radius,r=this.radius2_===void 0?s:this.radius2_;if(s<r){const R=s;s=r,r=R}const o=this.radius2_===void 0?this.points_:this.points_*2,a=2*Math.PI/o,l=r*Math.sin(a),h=Math.sqrt(r*r-l*l),c=s-h,u=Math.sqrt(l*l+c*c),d=u/l;if(t==="miter"&&d<=i)return d*e;const f=e/2/d,g=e/2*(c/u),_=Math.sqrt((s+f)*(s+f)+g*g)-s;if(this.radius2_===void 0||t==="bevel")return _*2;const p=s*Math.sin(a),y=Math.sqrt(s*s-p*p),v=r-y,w=Math.sqrt(p*p+v*v)/p;if(w<=i){const R=w*e/2-r-s;return 2*Math.max(_,R)}return _*2}createRenderOptions(){let t=Ri,e=Si,i=0,s=null,r=0,o,a=0;this.stroke_&&(o=oe(this.stroke_.getColor()??gn),a=this.stroke_.getWidth()??mn,s=this.stroke_.getLineDash(),r=this.stroke_.getLineDashOffset()??0,e=this.stroke_.getLineJoin()??Si,t=this.stroke_.getLineCap()??Ri,i=this.stroke_.getMiterLimit()??fn);const l=this.calculateLineJoinSize_(e,a,i),h=Math.max(this.radius,this.radius2_||0),c=Math.ceil(2*h+l);return{strokeStyle:o,strokeWidth:a,size:c,lineCap:t,lineDash:s,lineDashOffset:r,lineJoin:e,miterLimit:i}}render(){this.renderOptions_=this.createRenderOptions();const t=this.renderOptions_.size;this.hitDetectionCanvas_=null,this.size_=[t,t]}draw_(t,e,i){if(e.scale(i,i),e.translate(t.size/2,t.size/2),this.createPath_(e),this.fill_){let s=this.fill_.getColor();s===null&&(s=Nt),e.fillStyle=oe(s),e.fill()}t.strokeStyle&&(e.strokeStyle=t.strokeStyle,e.lineWidth=t.strokeWidth,t.lineDash&&(e.setLineDash(t.lineDash),e.lineDashOffset=t.lineDashOffset),e.lineCap=t.lineCap,e.lineJoin=t.lineJoin,e.miterLimit=t.miterLimit,e.stroke())}createHitDetectionCanvas_(t){let e;if(this.fill_){let i=this.fill_.getColor(),s=0;typeof i=="string"&&(i=vi(i)),i===null?s=1:Array.isArray(i)&&(s=i.length===4?i[3]:1),s===0&&(e=gt(t.size,t.size),this.drawHitDetectionCanvas_(t,e))}return e?e.canvas:this.getImage(1)}createPath_(t){let e=this.points_;const i=this.radius;if(e===1/0)t.arc(0,0,i,0,2*Math.PI);else{const s=this.radius2_===void 0?i:this.radius2_;this.radius2_!==void 0&&(e*=2);const r=this.angle_-Math.PI/2,o=2*Math.PI/e;for(let a=0;a<e;a++){const l=r+a*o,h=a%2===0?i:s;t.lineTo(h*Math.cos(l),h*Math.sin(l))}t.closePath()}}drawHitDetectionCanvas_(t,e){e.translate(t.size/2,t.size/2),this.createPath_(e),e.fillStyle=Nt,e.fill(),t.strokeStyle&&(e.strokeStyle=t.strokeStyle,e.lineWidth=t.strokeWidth,t.lineDash&&(e.setLineDash(t.lineDash),e.lineDashOffset=t.lineDashOffset),e.lineJoin=t.lineJoin,e.miterLimit=t.miterLimit,e.stroke())}ready(){return this.fill_?this.fill_.ready():Promise.resolve()}}class ms extends _s{constructor(t){t=t||{radius:5},super({points:1/0,fill:t.fill,radius:t.radius,stroke:t.stroke,scale:t.scale!==void 0?t.scale:1,rotation:t.rotation!==void 0?t.rotation:0,rotateWithView:t.rotateWithView!==void 0?t.rotateWithView:!1,displacement:t.displacement!==void 0?t.displacement:[0,0],declutterMode:t.declutterMode})}clone(){const t=this.getScale(),e=new ms({fill:this.getFill()?this.getFill().clone():void 0,stroke:this.getStroke()?this.getStroke().clone():void 0,radius:this.getRadius(),scale:Array.isArray(t)?t.slice():t,rotation:this.getRotation(),rotateWithView:this.getRotateWithView(),displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()});return e.setOpacity(this.getOpacity()),e}setRadius(t){this.radius=t,this.render()}}class yn{constructor(t){t=t||{},this.patternImage_=null,this.color_=null,t.color!==void 0&&this.setColor(t.color)}clone(){const t=this.getColor();return new yn({color:Array.isArray(t)?t.slice():t||void 0})}getColor(){return this.color_}setColor(t){if(t!==null&&typeof t=="object"&&"src"in t){const e=Vr(null,t.src,"anonymous",void 0,t.offset?null:t.color?t.color:null,!(t.offset&&t.size));e.ready().then(()=>{this.patternImage_=null}),e.getImageState()===K.IDLE&&e.load(),e.getImageState()===K.LOADING&&(this.patternImage_=e)}this.color_=t}getKey(){const t=this.getColor();return t?t instanceof CanvasPattern||t instanceof CanvasGradient?q(t):typeof t=="object"&&"src"in t?t.src+":"+t.offset:vi(t).toString():""}loading(){return!!this.patternImage_}ready(){return this.patternImage_?this.patternImage_.ready():Promise.resolve()}}function Ml(n,t,e,i){return e!==void 0&&i!==void 0?[e/n,i/t]:e!==void 0?e/n:i!==void 0?i/t:1}class xn extends gs{constructor(t){t=t||{};const e=t.opacity!==void 0?t.opacity:1,i=t.rotation!==void 0?t.rotation:0,s=t.scale!==void 0?t.scale:1,r=t.rotateWithView!==void 0?t.rotateWithView:!1;super({opacity:e,rotation:i,scale:s,displacement:t.displacement!==void 0?t.displacement:[0,0],rotateWithView:r,declutterMode:t.declutterMode}),this.anchor_=t.anchor!==void 0?t.anchor:[.5,.5],this.normalizedAnchor_=null,this.anchorOrigin_=t.anchorOrigin!==void 0?t.anchorOrigin:"top-left",this.anchorXUnits_=t.anchorXUnits!==void 0?t.anchorXUnits:"fraction",this.anchorYUnits_=t.anchorYUnits!==void 0?t.anchorYUnits:"fraction",this.crossOrigin_=t.crossOrigin!==void 0?t.crossOrigin:null;const o=t.img!==void 0?t.img:null;let a=t.src;Q(!(a!==void 0&&o),"`image` and `src` cannot be provided at the same time"),(a===void 0||a.length===0)&&o&&(a=o.src||q(o)),Q(a!==void 0&&a.length>0,"A defined and non-empty `src` or `image` must be provided"),Q(!((t.width!==void 0||t.height!==void 0)&&t.scale!==void 0),"`width` or `height` cannot be provided together with `scale`");let l;if(t.src!==void 0?l=K.IDLE:o!==void 0&&("complete"in o?o.complete?l=o.src?K.LOADED:K.IDLE:l=K.LOADING:l=K.LOADED),this.color_=t.color!==void 0?vi(t.color):null,this.iconImage_=Vr(o,a,this.crossOrigin_,l,this.color_),this.offset_=t.offset!==void 0?t.offset:[0,0],this.offsetOrigin_=t.offsetOrigin!==void 0?t.offsetOrigin:"top-left",this.origin_=null,this.size_=t.size!==void 0?t.size:null,this.initialOptions_,t.width!==void 0||t.height!==void 0){let h,c;if(t.size)[h,c]=t.size;else{const u=this.getImage(1);if(u.width&&u.height)h=u.width,c=u.height;else if(u instanceof HTMLImageElement){this.initialOptions_=t;const d=()=>{if(this.unlistenImageChange(d),!this.initialOptions_)return;const f=this.iconImage_.getSize();this.setScale(Ml(f[0],f[1],t.width,t.height))};this.listenImageChange(d);return}}h!==void 0&&this.setScale(Ml(h,c,t.width,t.height))}}clone(){let t,e,i;return this.initialOptions_?(e=this.initialOptions_.width,i=this.initialOptions_.height):(t=this.getScale(),t=Array.isArray(t)?t.slice():t),new xn({anchor:this.anchor_.slice(),anchorOrigin:this.anchorOrigin_,anchorXUnits:this.anchorXUnits_,anchorYUnits:this.anchorYUnits_,color:this.color_&&this.color_.slice?this.color_.slice():this.color_||void 0,crossOrigin:this.crossOrigin_,offset:this.offset_.slice(),offsetOrigin:this.offsetOrigin_,opacity:this.getOpacity(),rotateWithView:this.getRotateWithView(),rotation:this.getRotation(),scale:t,width:e,height:i,size:this.size_!==null?this.size_.slice():void 0,src:this.getSrc(),displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()})}getAnchor(){let t=this.normalizedAnchor_;if(!t){t=this.anchor_;const s=this.getSize();if(this.anchorXUnits_=="fraction"||this.anchorYUnits_=="fraction"){if(!s)return null;t=this.anchor_.slice(),this.anchorXUnits_=="fraction"&&(t[0]*=s[0]),this.anchorYUnits_=="fraction"&&(t[1]*=s[1])}if(this.anchorOrigin_!="top-left"){if(!s)return null;t===this.anchor_&&(t=this.anchor_.slice()),(this.anchorOrigin_=="top-right"||this.anchorOrigin_=="bottom-right")&&(t[0]=-t[0]+s[0]),(this.anchorOrigin_=="bottom-left"||this.anchorOrigin_=="bottom-right")&&(t[1]=-t[1]+s[1])}this.normalizedAnchor_=t}const e=this.getDisplacement(),i=this.getScaleArray();return[t[0]-e[0]/i[0],t[1]+e[1]/i[1]]}setAnchor(t){this.anchor_=t,this.normalizedAnchor_=null}getColor(){return this.color_}getImage(t){return this.iconImage_.getImage(t)}getPixelRatio(t){return this.iconImage_.getPixelRatio(t)}getImageSize(){return this.iconImage_.getSize()}getImageState(){return this.iconImage_.getImageState()}getHitDetectionImage(){return this.iconImage_.getHitDetectionImage()}getOrigin(){if(this.origin_)return this.origin_;let t=this.offset_;if(this.offsetOrigin_!="top-left"){const e=this.getSize(),i=this.iconImage_.getSize();if(!e||!i)return null;t=t.slice(),(this.offsetOrigin_=="top-right"||this.offsetOrigin_=="bottom-right")&&(t[0]=i[0]-e[0]-t[0]),(this.offsetOrigin_=="bottom-left"||this.offsetOrigin_=="bottom-right")&&(t[1]=i[1]-e[1]-t[1])}return this.origin_=t,this.origin_}getSrc(){return this.iconImage_.getSrc()}getSize(){return this.size_?this.size_:this.iconImage_.getSize()}getWidth(){const t=this.getScaleArray();if(this.size_)return this.size_[0]*t[0];if(this.iconImage_.getImageState()==K.LOADED)return this.iconImage_.getSize()[0]*t[0]}getHeight(){const t=this.getScaleArray();if(this.size_)return this.size_[1]*t[1];if(this.iconImage_.getImageState()==K.LOADED)return this.iconImage_.getSize()[1]*t[1]}setScale(t){delete this.initialOptions_,super.setScale(t)}listenImageChange(t){this.iconImage_.addEventListener(B.CHANGE,t)}load(){this.iconImage_.load()}unlistenImageChange(t){this.iconImage_.removeEventListener(B.CHANGE,t)}ready(){return this.iconImage_.ready()}}class ps{constructor(t){t=t||{},this.color_=t.color!==void 0?t.color:null,this.lineCap_=t.lineCap,this.lineDash_=t.lineDash!==void 0?t.lineDash:null,this.lineDashOffset_=t.lineDashOffset,this.lineJoin_=t.lineJoin,this.miterLimit_=t.miterLimit,this.width_=t.width}clone(){const t=this.getColor();return new ps({color:Array.isArray(t)?t.slice():t||void 0,lineCap:this.getLineCap(),lineDash:this.getLineDash()?this.getLineDash().slice():void 0,lineDashOffset:this.getLineDashOffset(),lineJoin:this.getLineJoin(),miterLimit:this.getMiterLimit(),width:this.getWidth()})}getColor(){return this.color_}getLineCap(){return this.lineCap_}getLineDash(){return this.lineDash_}getLineDashOffset(){return this.lineDashOffset_}getLineJoin(){return this.lineJoin_}getMiterLimit(){return this.miterLimit_}getWidth(){return this.width_}setColor(t){this.color_=t}setLineCap(t){this.lineCap_=t}setLineDash(t){this.lineDash_=t}setLineDashOffset(t){this.lineDashOffset_=t}setLineJoin(t){this.lineJoin_=t}setMiterLimit(t){this.miterLimit_=t}setWidth(t){this.width_=t}}class Oe{constructor(t){t=t||{},this.geometry_=null,this.geometryFunction_=Al,t.geometry!==void 0&&this.setGeometry(t.geometry),this.fill_=t.fill!==void 0?t.fill:null,this.image_=t.image!==void 0?t.image:null,this.renderer_=t.renderer!==void 0?t.renderer:null,this.hitDetectionRenderer_=t.hitDetectionRenderer!==void 0?t.hitDetectionRenderer:null,this.stroke_=t.stroke!==void 0?t.stroke:null,this.text_=t.text!==void 0?t.text:null,this.zIndex_=t.zIndex}clone(){let t=this.getGeometry();return t&&typeof t=="object"&&(t=t.clone()),new Oe({geometry:t??void 0,fill:this.getFill()?this.getFill().clone():void 0,image:this.getImage()?this.getImage().clone():void 0,renderer:this.getRenderer()??void 0,stroke:this.getStroke()?this.getStroke().clone():void 0,text:this.getText()?this.getText().clone():void 0,zIndex:this.getZIndex()})}getRenderer(){return this.renderer_}setRenderer(t){this.renderer_=t}setHitDetectionRenderer(t){this.hitDetectionRenderer_=t}getHitDetectionRenderer(){return this.hitDetectionRenderer_}getGeometry(){return this.geometry_}getGeometryFunction(){return this.geometryFunction_}getFill(){return this.fill_}setFill(t){this.fill_=t}getImage(){return this.image_}setImage(t){this.image_=t}getStroke(){return this.stroke_}setStroke(t){this.stroke_=t}getText(){return this.text_}setText(t){this.text_=t}getZIndex(){return this.zIndex_}setGeometry(t){typeof t=="function"?this.geometryFunction_=t:typeof t=="string"?this.geometryFunction_=function(e){return e.get(t)}:t?t!==void 0&&(this.geometryFunction_=function(){return t}):this.geometryFunction_=Al,this.geometry_=t}setZIndex(t){this.zIndex_=t}}function xf(n){let t;if(typeof n=="function")t=n;else{let e;Array.isArray(n)?e=n:(Q(typeof n.getZIndex=="function","Expected an `Style` or an array of `Style`"),e=[n]),t=function(){return e}}return t}let $r=null;function Ll(n,t){if(!$r){const e=new yn({color:"rgba(255,255,255,0.4)"}),i=new ps({color:"#3399CC",width:1.25});$r=[new Oe({image:new ms({fill:e,stroke:i,radius:5}),fill:e,stroke:i})]}return $r}function Al(n){return n.getGeometry()}const Ef="#333";class Hr{constructor(t){t=t||{},this.font_=t.font,this.rotation_=t.rotation,this.rotateWithView_=t.rotateWithView,this.keepUpright_=t.keepUpright,this.scale_=t.scale,this.scaleArray_=kt(t.scale!==void 0?t.scale:1),this.text_=t.text,this.textAlign_=t.textAlign,this.justify_=t.justify,this.repeat_=t.repeat,this.textBaseline_=t.textBaseline,this.fill_=t.fill!==void 0?t.fill:new yn({color:Ef}),this.maxAngle_=t.maxAngle!==void 0?t.maxAngle:Math.PI/4,this.placement_=t.placement!==void 0?t.placement:"point",this.overflow_=!!t.overflow,this.stroke_=t.stroke!==void 0?t.stroke:null,this.offsetX_=t.offsetX!==void 0?t.offsetX:0,this.offsetY_=t.offsetY!==void 0?t.offsetY:0,this.backgroundFill_=t.backgroundFill?t.backgroundFill:null,this.backgroundStroke_=t.backgroundStroke?t.backgroundStroke:null,this.padding_=t.padding===void 0?null:t.padding,this.declutterMode_=t.declutterMode}clone(){const t=this.getScale();return new Hr({font:this.getFont(),placement:this.getPlacement(),repeat:this.getRepeat(),maxAngle:this.getMaxAngle(),overflow:this.getOverflow(),rotation:this.getRotation(),rotateWithView:this.getRotateWithView(),keepUpright:this.getKeepUpright(),scale:Array.isArray(t)?t.slice():t,text:this.getText(),textAlign:this.getTextAlign(),justify:this.getJustify(),textBaseline:this.getTextBaseline(),fill:this.getFill()?this.getFill().clone():void 0,stroke:this.getStroke()?this.getStroke().clone():void 0,offsetX:this.getOffsetX(),offsetY:this.getOffsetY(),backgroundFill:this.getBackgroundFill()?this.getBackgroundFill().clone():void 0,backgroundStroke:this.getBackgroundStroke()?this.getBackgroundStroke().clone():void 0,padding:this.getPadding()||void 0,declutterMode:this.getDeclutterMode()})}getOverflow(){return this.overflow_}getFont(){return this.font_}getMaxAngle(){return this.maxAngle_}getPlacement(){return this.placement_}getRepeat(){return this.repeat_}getOffsetX(){return this.offsetX_}getOffsetY(){return this.offsetY_}getFill(){return this.fill_}getRotateWithView(){return this.rotateWithView_}getKeepUpright(){return this.keepUpright_}getRotation(){return this.rotation_}getScale(){return this.scale_}getScaleArray(){return this.scaleArray_}getStroke(){return this.stroke_}getText(){return this.text_}getTextAlign(){return this.textAlign_}getJustify(){return this.justify_}getTextBaseline(){return this.textBaseline_}getBackgroundFill(){return this.backgroundFill_}getBackgroundStroke(){return this.backgroundStroke_}getPadding(){return this.padding_}getDeclutterMode(){return this.declutterMode_}setOverflow(t){this.overflow_=t}setFont(t){this.font_=t}setMaxAngle(t){this.maxAngle_=t}setOffsetX(t){this.offsetX_=t}setOffsetY(t){this.offsetY_=t}setPlacement(t){this.placement_=t}setRepeat(t){this.repeat_=t}setRotateWithView(t){this.rotateWithView_=t}setKeepUpright(t){this.keepUpright_=t}setFill(t){this.fill_=t}setRotation(t){this.rotation_=t}setScale(t){this.scale_=t,this.scaleArray_=kt(t!==void 0?t:1)}setStroke(t){this.stroke_=t}setText(t){this.text_=t}setTextAlign(t){this.textAlign_=t}setJustify(t){this.justify_=t}setTextBaseline(t){this.textBaseline_=t}setBackgroundFill(t){this.backgroundFill_=t}setBackgroundStroke(t){this.backgroundStroke_=t}setPadding(t){this.padding_=t}}function wf(n){return!0}function vf(n){const t=pl(),e=Cf(n,t),i=vl();return function(s,r){if(i.properties=s.getPropertiesInternal(),i.resolution=r,t.featureId){const o=s.getId();o!==void 0?i.featureId=o:i.featureId=null}return t.geometryType&&(i.geometryType=wl(s.getGeometry())),e(i)}}function Ol(n){const t=pl(),e=n.length,i=new Array(e);for(let o=0;o<e;++o)i[o]=qr(n[o],t);const s=vl(),r=new Array(e);return function(o,a){if(s.properties=o.getPropertiesInternal(),s.resolution=a,t.featureId){const h=o.getId();h!==void 0?s.featureId=h:s.featureId=null}let l=0;for(let h=0;h<e;++h){const c=i[h](s);c&&(r[l]=c,l+=1)}return r.length=l,r}}function Cf(n,t){const e=n.length,i=new Array(e);for(let s=0;s<e;++s){const r=n[s],o="filter"in r?ge(r.filter,Tt,t):wf;let a;if(Array.isArray(r.style)){const l=r.style.length;a=new Array(l);for(let h=0;h<l;++h)a[h]=qr(r.style[h],t)}else a=[qr(r.style,t)];i[s]={filter:o,styles:a}}return function(s){const r=[];let o=!1;for(let a=0;a<e;++a){const l=i[a].filter;if(l(s)&&!(n[a].else&&o)){o=!0;for(const h of i[a].styles){const c=h(s);c&&r.push(c)}}}return r}}function qr(n,t){const e=En(n,"",t),i=wn(n,"",t),s=Rf(n,t),r=Sf(n,t),o=zt(n,"z-index",t);if(!e&&!i&&!s&&!r&&!ai(n))throw new Error("No fill, stroke, point, or text symbolizer properties in style: "+JSON.stringify(n));const a=new Oe;return function(l){let h=!0;if(e){const c=e(l);c&&(h=!1),a.setFill(c)}if(i){const c=i(l);c&&(h=!1),a.setStroke(c)}if(s){const c=s(l);c&&(h=!1),a.setText(c)}if(r){const c=r(l);c&&(h=!1),a.setImage(c)}return o&&a.setZIndex(o(l)),h?null:a}}function En(n,t,e){let i;if(t+"fill-pattern-src"in n)i=Mf(n,t+"fill-",e);else{if(n[t+"fill-color"]==="none")return r=>null;i=Jr(n,t+"fill-color",e)}if(!i)return null;const s=new yn;return function(r){const o=i(r);return o===kr?null:(s.setColor(o),s)}}function wn(n,t,e){const i=zt(n,t+"stroke-width",e),s=Jr(n,t+"stroke-color",e);if(!i&&!s)return null;const r=pe(n,t+"stroke-line-cap",e),o=pe(n,t+"stroke-line-join",e),a=Pl(n,t+"stroke-line-dash",e),l=zt(n,t+"stroke-line-dash-offset",e),h=zt(n,t+"stroke-miter-limit",e),c=new ps;return function(u){if(s){const d=s(u);if(d===kr)return null;c.setColor(d)}if(i&&c.setWidth(i(u)),r){const d=r(u);if(d!=="butt"&&d!=="round"&&d!=="square")throw new Error("Expected butt, round, or square line cap");c.setLineCap(d)}if(o){const d=o(u);if(d!=="bevel"&&d!=="round"&&d!=="miter")throw new Error("Expected bevel, round, or miter line join");c.setLineJoin(d)}return a&&c.setLineDash(a(u)),l&&c.setLineDashOffset(l(u)),h&&c.setMiterLimit(h(u)),c}}function Rf(n,t){const e="text-",i=pe(n,e+"value",t);if(!i)return null;const s=En(n,e,t),r=En(n,e+"background-",t),o=wn(n,e,t),a=wn(n,e+"background-",t),l=pe(n,e+"font",t),h=zt(n,e+"max-angle",t),c=zt(n,e+"offset-x",t),u=zt(n,e+"offset-y",t),d=Ti(n,e+"overflow",t),f=pe(n,e+"placement",t),g=zt(n,e+"repeat",t),m=xs(n,e+"scale",t),_=Ti(n,e+"rotate-with-view",t),p=zt(n,e+"rotation",t),y=pe(n,e+"align",t),v=pe(n,e+"justify",t),x=pe(n,e+"baseline",t),w=Ti(n,e+"keep-upright",t),R=Pl(n,e+"padding",t),T=ws(n,e+"declutter-mode"),S=new Hr({declutterMode:T});return function(I){if(S.setText(i(I)),s&&S.setFill(s(I)),r&&S.setBackgroundFill(r(I)),o&&S.setStroke(o(I)),a&&S.setBackgroundStroke(a(I)),l&&S.setFont(l(I)),h&&S.setMaxAngle(h(I)),c&&S.setOffsetX(c(I)),u&&S.setOffsetY(u(I)),d&&S.setOverflow(d(I)),f){const M=f(I);if(M!=="point"&&M!=="line")throw new Error("Expected point or line for text-placement");S.setPlacement(M)}if(g&&S.setRepeat(g(I)),m&&S.setScale(m(I)),_&&S.setRotateWithView(_(I)),p&&S.setRotation(p(I)),y){const M=y(I);if(M!=="left"&&M!=="center"&&M!=="right"&&M!=="end"&&M!=="start")throw new Error("Expected left, right, center, start, or end for text-align");S.setTextAlign(M)}if(v){const M=v(I);if(M!=="left"&&M!=="right"&&M!=="center")throw new Error("Expected left, right, or center for text-justify");S.setJustify(M)}if(x){const M=x(I);if(M!=="bottom"&&M!=="top"&&M!=="middle"&&M!=="alphabetic"&&M!=="hanging")throw new Error("Expected bottom, top, middle, alphabetic, or hanging for text-baseline");S.setTextBaseline(M)}return R&&S.setPadding(R(I)),w&&S.setKeepUpright(w(I)),S}}function Sf(n,t){return"icon-src"in n?If(n,t):"shape-points"in n?Tf(n,t):"circle-radius"in n?bf(n,t):null}function If(n,t){const e="icon-",i=e+"src",s=Nl(n[i],i),r=ys(n,e+"anchor",t),o=xs(n,e+"scale",t),a=zt(n,e+"opacity",t),l=ys(n,e+"displacement",t),h=zt(n,e+"rotation",t),c=Ti(n,e+"rotate-with-view",t),u=kl(n,e+"anchor-origin"),d=Fl(n,e+"anchor-x-units"),f=Fl(n,e+"anchor-y-units"),g=Pf(n,e+"color"),m=Af(n,e+"cross-origin"),_=Of(n,e+"offset"),p=kl(n,e+"offset-origin"),y=Es(n,e+"width"),v=Es(n,e+"height"),x=Lf(n,e+"size"),w=ws(n,e+"declutter-mode"),R=new xn({src:s,anchorOrigin:u,anchorXUnits:d,anchorYUnits:f,color:g,crossOrigin:m,offset:_,offsetOrigin:p,height:v,width:y,size:x,declutterMode:w});return function(T){return a&&R.setOpacity(a(T)),l&&R.setDisplacement(l(T)),h&&R.setRotation(h(T)),c&&R.setRotateWithView(c(T)),o&&R.setScale(o(T)),r&&R.setAnchor(r(T)),R}}function Tf(n,t){const e="shape-",i=e+"points",s=e+"radius",r=Qr(n[i],i),o=Qr(n[s],s),a=En(n,e,t),l=wn(n,e,t),h=xs(n,e+"scale",t),c=ys(n,e+"displacement",t),u=zt(n,e+"rotation",t),d=Ti(n,e+"rotate-with-view",t),f=Es(n,e+"radius2"),g=Es(n,e+"angle"),m=ws(n,e+"declutter-mode"),_=new _s({points:r,radius:o,radius2:f,angle:g,declutterMode:m});return function(p){return a&&_.setFill(a(p)),l&&_.setStroke(l(p)),c&&_.setDisplacement(c(p)),u&&_.setRotation(u(p)),d&&_.setRotateWithView(d(p)),h&&_.setScale(h(p)),_}}function bf(n,t){const e="circle-",i=En(n,e,t),s=wn(n,e,t),r=zt(n,e+"radius",t),o=xs(n,e+"scale",t),a=ys(n,e+"displacement",t),l=zt(n,e+"rotation",t),h=Ti(n,e+"rotate-with-view",t),c=ws(n,e+"declutter-mode"),u=new ms({radius:5,declutterMode:c});return function(d){return r&&u.setRadius(r(d)),i&&u.setFill(i(d)),s&&u.setStroke(s(d)),a&&u.setDisplacement(a(d)),l&&u.setRotation(l(d)),h&&u.setRotateWithView(h(d)),o&&u.setScale(o(d)),u}}function zt(n,t,e){if(!(t in n))return;const i=ge(n[t],Z,e);return function(s){return Qr(i(s),t)}}function pe(n,t,e){if(!(t in n))return null;const i=ge(n[t],Ft,e);return function(s){return Nl(i(s),t)}}function Mf(n,t,e){const i=pe(n,t+"pattern-src",e),s=Dl(n,t+"pattern-offset",e),r=Dl(n,t+"pattern-size",e),o=Jr(n,t+"color",e);return function(a){return{src:i(a),offset:s&&s(a),size:r&&r(a),color:o&&o(a)}}}function Ti(n,t,e){if(!(t in n))return null;const i=ge(n[t],Tt,e);return function(s){const r=i(s);if(typeof r!="boolean")throw new Error(`Expected a boolean for ${t}`);return r}}function Jr(n,t,e){if(!(t in n))return null;const i=ge(n[t],Jt,e);return function(s){return zl(i(s),t)}}function Pl(n,t,e){if(!(t in n))return null;const i=ge(n[t],Je,e);return function(s){return vn(i(s),t)}}function ys(n,t,e){if(!(t in n))return null;const i=ge(n[t],Je,e);return function(s){const r=vn(i(s),t);if(r.length!==2)throw new Error(`Expected two numbers for ${t}`);return r}}function Dl(n,t,e){if(!(t in n))return null;const i=ge(n[t],Je,e);return function(s){return Gl(i(s),t)}}function xs(n,t,e){if(!(t in n))return null;const i=ge(n[t],Je|Z,e);return function(s){return Df(i(s),t)}}function Es(n,t){const e=n[t];if(e!==void 0){if(typeof e!="number")throw new Error(`Expected a number for ${t}`);return e}}function Lf(n,t){const e=n[t];if(e!==void 0){if(typeof e=="number")return kt(e);if(!Array.isArray(e))throw new Error(`Expected a number or size array for ${t}`);if(e.length!==2||typeof e[0]!="number"||typeof e[1]!="number")throw new Error(`Expected a number or size array for ${t}`);return e}}function Af(n,t){const e=n[t];if(e!==void 0){if(typeof e!="string")throw new Error(`Expected a string for ${t}`);return e}}function kl(n,t){const e=n[t];if(e!==void 0){if(e!=="bottom-left"&&e!=="bottom-right"&&e!=="top-left"&&e!=="top-right")throw new Error(`Expected bottom-left, bottom-right, top-left, or top-right for ${t}`);return e}}function Fl(n,t){const e=n[t];if(e!==void 0){if(e!=="pixels"&&e!=="fraction")throw new Error(`Expected pixels or fraction for ${t}`);return e}}function Of(n,t){const e=n[t];if(e!==void 0)return vn(e,t)}function ws(n,t){const e=n[t];if(e!==void 0){if(typeof e!="string")throw new Error(`Expected a string for ${t}`);if(e!=="declutter"&&e!=="obstacle"&&e!=="none")throw new Error(`Expected declutter, obstacle, or none for ${t}`);return e}}function Pf(n,t){const e=n[t];if(e!==void 0)return zl(e,t)}function vn(n,t){if(!Array.isArray(n))throw new Error(`Expected an array for ${t}`);const e=n.length;for(let i=0;i<e;++i)if(typeof n[i]!="number")throw new Error(`Expected an array of numbers for ${t}`);return n}function Nl(n,t){if(typeof n!="string")throw new Error(`Expected a string for ${t}`);return n}function Qr(n,t){if(typeof n!="number")throw new Error(`Expected a number for ${t}`);return n}function zl(n,t){if(typeof n=="string")return n;const e=vn(n,t),i=e.length;if(i<3||i>4)throw new Error(`Expected a color with 3 or 4 values for ${t}`);return e}function Gl(n,t){const e=vn(n,t);if(e.length!==2)throw new Error(`Expected an array of two numbers for ${t}`);return e}function Df(n,t){return typeof n=="number"?n:Gl(n,t)}const Wl={RENDER_ORDER:"renderOrder"};class Xl extends ls{constructor(t){t=t||{};const e=Object.assign({},t);delete e.style,delete e.renderBuffer,delete e.updateWhileAnimating,delete e.updateWhileInteracting,super(e),this.declutter_=t.declutter?String(t.declutter):void 0,this.renderBuffer_=t.renderBuffer!==void 0?t.renderBuffer:100,this.style_=null,this.styleFunction_=void 0,this.setStyle(t.style),this.updateWhileAnimating_=t.updateWhileAnimating!==void 0?t.updateWhileAnimating:!1,this.updateWhileInteracting_=t.updateWhileInteracting!==void 0?t.updateWhileInteracting:!1}getDeclutter(){return this.declutter_}getFeatures(t){return super.getFeatures(t)}getRenderBuffer(){return this.renderBuffer_}getRenderOrder(){return this.get(Wl.RENDER_ORDER)}getStyle(){return this.style_}getStyleFunction(){return this.styleFunction_}getUpdateWhileAnimating(){return this.updateWhileAnimating_}getUpdateWhileInteracting(){return this.updateWhileInteracting_}renderDeclutter(t,e){const i=this.getDeclutter();i in t.declutter||(t.declutter[i]=new dl(9)),this.getRenderer().renderDeclutter(t,e)}setRenderOrder(t){this.set(Wl.RENDER_ORDER,t)}setStyle(t){this.style_=t===void 0?Ll:t;const e=kf(t);this.styleFunction_=t===null?void 0:xf(e),this.changed()}setDeclutter(t){this.declutter_=t?String(t):void 0,this.changed()}}function kf(n){if(n===void 0)return Ll;if(!n)return null;if(typeof n=="function"||n instanceof Oe)return n;if(!Array.isArray(n))return Ol([n]);if(n.length===0)return[];const t=n.length,e=n[0];if(e instanceof Oe){const s=new Array(t);for(let r=0;r<t;++r){const o=n[r];if(!(o instanceof Oe))throw new Error("Expected a list of style instances");s[r]=o}return s}if("style"in e){const s=new Array(t);for(let r=0;r<t;++r){const o=n[r];if(!("style"in o))throw new Error("Expected a list of rules with a style property");s[r]=o}return vf(s)}return Ol(n)}class Yl extends ue{constructor(t,e,i,s){super(t),this.inversePixelTransform=e,this.frameState=i,this.context=s}}class Ff extends Dn{constructor(t){super(),this.map_=t}dispatchRenderEvent(t,e){H()}calculateMatrices2D(t){const e=t.viewState,i=t.coordinateToPixelTransform,s=t.pixelToCoordinateTransform;fe(i,t.size[0]/2,t.size[1]/2,1/e.resolution,-1/e.resolution,-e.rotation,-e.center[0],-e.center[1]),Na(s,i)}forEachFeatureAtCoordinate(t,e,i,s,r,o,a,l){let h;const c=e.viewState;function u(x,w,R,T){return r.call(o,w,x?R:null,T)}const d=c.projection,f=pa(t.slice(),d),g=[[0,0]];if(d.canWrapX()&&s){const x=d.getExtent(),w=et(x);g.push([-w,0],[w,0])}const m=e.layerStatesArray,_=m.length,p=[],y=[];for(let x=0;x<g.length;x++)for(let w=_-1;w>=0;--w){const R=m[w],T=R.layer;if(T.hasRenderer()&&Or(R,c)&&a.call(l,T)){const S=T.getRenderer(),I=T.getSource();if(S&&I){const M=I.getWrapX()?f:t,O=u.bind(null,R.managed);y[0]=M[0]+g[x][0],y[1]=M[1]+g[x][1],h=S.forEachFeatureAtCoordinate(y,e,i,O,p)}if(h)return h}}if(p.length===0)return;const v=1/p.length;return p.forEach((x,w)=>x.distanceSq+=w*v),p.sort((x,w)=>x.distanceSq-w.distanceSq),p.some(x=>h=x.callback(x.feature,x.layer,x.geometry)),h}hasFeatureAtCoordinate(t,e,i,s,r,o){return this.forEachFeatureAtCoordinate(t,e,i,s,Yi,this,r,o)!==void 0}getMap(){return this.map_}renderFrame(t){H()}scheduleExpireIconCache(t){Ut.canExpireCache()&&t.postRenderFunctions.push(Nf)}}function Nf(n,t){Ut.expire()}class zf extends Ff{constructor(t){super(t),this.fontChangeListenerKey_=$(Ii,oi.PROPERTYCHANGE,t.redrawText,t),this.element_=document.createElement("div");const e=this.element_.style;e.position="absolute",e.width="100%",e.height="100%",e.zIndex="0",this.element_.className=rs+" ol-layers";const i=t.getViewport();i.insertBefore(this.element_,i.firstChild||null),this.children_=[],this.renderedVisible_=!0}dispatchRenderEvent(t,e){const i=this.getMap();if(i.hasListener(t)){const s=new Yl(t,void 0,e);i.dispatchEvent(s)}}disposeInternal(){at(this.fontChangeListenerKey_),this.element_.remove(),super.disposeInternal()}renderFrame(t){if(!t){this.renderedVisible_&&(this.element_.style.display="none",this.renderedVisible_=!1);return}this.calculateMatrices2D(t),this.dispatchRenderEvent(Bt.PRECOMPOSE,t);const e=t.layerStatesArray.sort((a,l)=>a.zIndex-l.zIndex);e.some(a=>a.layer instanceof Xl&&a.layer.getDeclutter())&&(t.declutter={});const s=t.viewState;this.children_.length=0;const r=[];let o=null;for(let a=0,l=e.length;a<l;++a){const h=e[a];t.layerIndex=a;const c=h.layer,u=c.getSourceState();if(!Or(h,s)||u!="ready"&&u!="undefined"){c.unrender();continue}const d=c.render(t,o);d&&(d!==o&&(this.children_.push(d),o=d),r.push(h))}this.declutter(t,r),Vu(this.element_,this.children_),this.dispatchRenderEvent(Bt.POSTCOMPOSE,t),this.renderedVisible_||(this.element_.style.display="",this.renderedVisible_=!0),this.scheduleExpireIconCache(t)}declutter(t,e){if(t.declutter){for(let i=e.length-1;i>=0;--i){const s=e[i],r=s.layer;r.getDeclutter()&&r.renderDeclutter(t,s)}e.forEach(i=>i.layer.renderDeferred(t))}}}function Bl(n){if(n instanceof ls){n.setMapInternal(null);return}n instanceof xi&&n.getLayers().forEach(Bl)}function Ul(n,t){if(n instanceof ls){n.setMapInternal(t);return}if(n instanceof xi){const e=n.getLayers().getArray();for(let i=0,s=e.length;i<s;++i)Ul(e[i],t)}}let Gf=class extends ne{constructor(t){super(),t=t||{},this.on,this.once,this.un;const e=Wf(t);this.renderComplete_=!1,this.loaded_=!0,this.boundHandleBrowserEvent_=this.handleBrowserEvent.bind(this),this.maxTilesLoading_=t.maxTilesLoading!==void 0?t.maxTilesLoading:16,this.pixelRatio_=t.pixelRatio!==void 0?t.pixelRatio:pc,this.postRenderTimeoutHandle_,this.animationDelayKey_,this.animationDelay_=this.animationDelay_.bind(this),this.coordinateToPixelTransform_=qt(),this.pixelToCoordinateTransform_=qt(),this.frameIndex_=0,this.frameState_=null,this.previousExtent_=null,this.viewPropertyListenerKey_=null,this.viewChangeListenerKey_=null,this.layerGroupPropertyListenerKeys_=null,this.viewport_=document.createElement("div"),this.viewport_.className="ol-viewport"+("ontouchstart"in window?" ol-touch":""),this.viewport_.style.position="relative",this.viewport_.style.overflow="hidden",this.viewport_.style.width="100%",this.viewport_.style.height="100%",this.overlayContainer_=document.createElement("div"),this.overlayContainer_.style.position="absolute",this.overlayContainer_.style.zIndex="0",this.overlayContainer_.style.width="100%",this.overlayContainer_.style.height="100%",this.overlayContainer_.style.pointerEvents="none",this.overlayContainer_.className="ol-overlaycontainer",this.viewport_.appendChild(this.overlayContainer_),this.overlayContainerStopEvent_=document.createElement("div"),this.overlayContainerStopEvent_.style.position="absolute",this.overlayContainerStopEvent_.style.zIndex="0",this.overlayContainerStopEvent_.style.width="100%",this.overlayContainerStopEvent_.style.height="100%",this.overlayContainerStopEvent_.style.pointerEvents="none",this.overlayContainerStopEvent_.className="ol-overlaycontainer-stopevent",this.viewport_.appendChild(this.overlayContainerStopEvent_),this.mapBrowserEventHandler_=null,this.moveTolerance_=t.moveTolerance,this.keyboardEventTarget_=e.keyboardEventTarget,this.targetChangeHandlerKeys_=null,this.targetElement_=null,this.resizeObserver_=new ResizeObserver(()=>this.updateSize()),this.controls=e.controls||qu(),this.interactions=e.interactions||xd({onFocusOnly:!0}),this.overlays_=e.overlays,this.overlayIdIndex_={},this.renderer_=null,this.postRenderFunctions_=[],this.tileQueue_=new Ec(this.getTilePriority.bind(this),this.handleTileChange_.bind(this)),this.addChangeListener(Rt.LAYERGROUP,this.handleLayerGroupChanged_),this.addChangeListener(Rt.VIEW,this.handleViewChanged_),this.addChangeListener(Rt.SIZE,this.handleSizeChanged_),this.addChangeListener(Rt.TARGET,this.handleTargetChanged_),this.setProperties(e.values);const i=this;t.view&&!(t.view instanceof re)&&t.view.then(function(s){i.setView(new re(s))}),this.controls.addEventListener(Ot.ADD,s=>{s.element.setMap(this)}),this.controls.addEventListener(Ot.REMOVE,s=>{s.element.setMap(null)}),this.interactions.addEventListener(Ot.ADD,s=>{s.element.setMap(this)}),this.interactions.addEventListener(Ot.REMOVE,s=>{s.element.setMap(null)}),this.overlays_.addEventListener(Ot.ADD,s=>{this.addOverlayInternal_(s.element)}),this.overlays_.addEventListener(Ot.REMOVE,s=>{const r=s.element.getId();r!==void 0&&delete this.overlayIdIndex_[r.toString()],s.element.setMap(null)}),this.controls.forEach(s=>{s.setMap(this)}),this.interactions.forEach(s=>{s.setMap(this)}),this.overlays_.forEach(this.addOverlayInternal_.bind(this))}addControl(t){this.getControls().push(t)}addInteraction(t){this.getInteractions().push(t)}addLayer(t){this.getLayerGroup().getLayers().push(t)}handleLayerAdd_(t){Ul(t.layer,this)}addOverlay(t){this.getOverlays().push(t)}addOverlayInternal_(t){const e=t.getId();e!==void 0&&(this.overlayIdIndex_[e.toString()]=t),t.setMap(this)}disposeInternal(){this.controls.clear(),this.interactions.clear(),this.overlays_.clear(),this.resizeObserver_.disconnect(),this.setTarget(null),super.disposeInternal()}forEachFeatureAtPixel(t,e,i){if(!this.frameState_||!this.renderer_)return;const s=this.getCoordinateFromPixelInternal(t);i=i!==void 0?i:{};const r=i.hitTolerance!==void 0?i.hitTolerance:0,o=i.layerFilter!==void 0?i.layerFilter:Yi,a=i.checkWrapped!==!1;return this.renderer_.forEachFeatureAtCoordinate(s,this.frameState_,r,a,e,null,o,null)}getFeaturesAtPixel(t,e){const i=[];return this.forEachFeatureAtPixel(t,function(s){i.push(s)},e),i}getAllLayers(){const t=[];function e(i){i.forEach(function(s){s instanceof xi?e(s.getLayers()):t.push(s)})}return e(this.getLayers()),t}hasFeatureAtPixel(t,e){if(!this.frameState_||!this.renderer_)return!1;const i=this.getCoordinateFromPixelInternal(t);e=e!==void 0?e:{};const s=e.layerFilter!==void 0?e.layerFilter:Yi,r=e.hitTolerance!==void 0?e.hitTolerance:0,o=e.checkWrapped!==!1;return this.renderer_.hasFeatureAtCoordinate(i,this.frameState_,r,o,s,null)}getEventCoordinate(t){return this.getCoordinateFromPixel(this.getEventPixel(t))}getEventCoordinateInternal(t){return this.getCoordinateFromPixelInternal(this.getEventPixel(t))}getEventPixel(t){const i=this.viewport_.getBoundingClientRect(),s=this.getSize(),r=i.width/s[0],o=i.height/s[1],a="changedTouches"in t?t.changedTouches[0]:t;return[(a.clientX-i.left)/r,(a.clientY-i.top)/o]}getTarget(){return this.get(Rt.TARGET)}getTargetElement(){return this.targetElement_}getCoordinateFromPixel(t){return ur(this.getCoordinateFromPixelInternal(t),this.getView().getProjection())}getCoordinateFromPixelInternal(t){const e=this.frameState_;return e?yt(e.pixelToCoordinateTransform,t.slice()):null}getControls(){return this.controls}getOverlays(){return this.overlays_}getOverlayById(t){const e=this.overlayIdIndex_[t.toString()];return e!==void 0?e:null}getInteractions(){return this.interactions}getLayerGroup(){return this.get(Rt.LAYERGROUP)}setLayers(t){const e=this.getLayerGroup();if(t instanceof se){e.setLayers(t);return}const i=e.getLayers();i.clear(),i.extend(t)}getLayers(){return this.getLayerGroup().getLayers()}getLoadingOrNotReady(){const t=this.getLayerGroup().getLayerStatesArray();for(let e=0,i=t.length;e<i;++e){const s=t[e];if(!s.visible)continue;const r=s.layer.getRenderer();if(r&&!r.ready)return!0;const o=s.layer.getSource();if(o&&o.loading)return!0}return!1}getPixelFromCoordinate(t){const e=de(t,this.getView().getProjection());return this.getPixelFromCoordinateInternal(e)}getPixelFromCoordinateInternal(t){const e=this.frameState_;return e?yt(e.coordinateToPixelTransform,t.slice(0,2)):null}getRenderer(){return this.renderer_}getSize(){return this.get(Rt.SIZE)}getView(){return this.get(Rt.VIEW)}getViewport(){return this.viewport_}getOverlayContainer(){return this.overlayContainer_}getOverlayContainerStopEvent(){return this.overlayContainerStopEvent_}getOwnerDocument(){const t=this.getTargetElement();return t?t.ownerDocument:document}getTilePriority(t,e,i,s){return wc(this.frameState_,t,e,i,s)}handleBrowserEvent(t,e){e=e||t.type;const i=new Re(e,this,t);this.handleMapBrowserEvent(i)}handleMapBrowserEvent(t){if(!this.frameState_)return;const e=t.originalEvent,i=e.type;if(i===Bs.POINTERDOWN||i===B.WHEEL||i===B.KEYDOWN){const s=this.getOwnerDocument(),r=this.viewport_.getRootNode?this.viewport_.getRootNode():s,o=e.target,a=r instanceof ShadowRoot?r.host===o?r.host.ownerDocument:r:r===s?s.documentElement:r;if(this.overlayContainerStopEvent_.contains(o)||!a.contains(o))return}if(t.frameState=this.frameState_,this.dispatchEvent(t)!==!1){const s=this.getInteractions().getArray().slice();for(let r=s.length-1;r>=0;r--){const o=s[r];if(o.getMap()!==this||!o.getActive()||!this.getTargetElement())continue;if(!o.handleEvent(t)||t.propagationStopped)break}}}handlePostRender(){const t=this.frameState_,e=this.tileQueue_;if(!e.isEmpty()){let s=this.maxTilesLoading_,r=s;if(t){const o=t.viewHints;if(o[St.ANIMATING]||o[St.INTERACTING]){const a=Date.now()-t.time>8;s=a?0:8,r=a?0:2}}e.getTilesLoading()<s&&(e.reprioritize(),e.loadMoreTiles(s,r))}t&&this.renderer_&&!t.animate&&(this.renderComplete_?(this.hasListener(Bt.RENDERCOMPLETE)&&this.renderer_.dispatchRenderEvent(Bt.RENDERCOMPLETE,t),this.loaded_===!1&&(this.loaded_=!0,this.dispatchEvent(new li(Se.LOADEND,this,t)))):this.loaded_===!0&&(this.loaded_=!1,this.dispatchEvent(new li(Se.LOADSTART,this,t))));const i=this.postRenderFunctions_;if(t)for(let s=0,r=i.length;s<r;++s)i[s](this,t);i.length=0}handleSizeChanged_(){this.getView()&&!this.getView().getAnimating()&&this.getView().resolveConstraints(0),this.render()}handleTargetChanged_(){if(this.mapBrowserEventHandler_){for(let i=0,s=this.targetChangeHandlerKeys_.length;i<s;++i)at(this.targetChangeHandlerKeys_[i]);this.targetChangeHandlerKeys_=null,this.viewport_.removeEventListener(B.CONTEXTMENU,this.boundHandleBrowserEvent_),this.viewport_.removeEventListener(B.WHEEL,this.boundHandleBrowserEvent_),this.mapBrowserEventHandler_.dispose(),this.mapBrowserEventHandler_=null,this.viewport_.remove()}if(this.targetElement_){this.resizeObserver_.unobserve(this.targetElement_);const i=this.targetElement_.getRootNode();i instanceof ShadowRoot&&this.resizeObserver_.unobserve(i.host),this.setSize(void 0)}const t=this.getTarget(),e=typeof t=="string"?document.getElementById(t):t;if(this.targetElement_=e,!e)this.renderer_&&(clearTimeout(this.postRenderTimeoutHandle_),this.postRenderTimeoutHandle_=void 0,this.postRenderFunctions_.length=0,this.renderer_.dispose(),this.renderer_=null),this.animationDelayKey_&&(cancelAnimationFrame(this.animationDelayKey_),this.animationDelayKey_=void 0);else{e.appendChild(this.viewport_),this.renderer_||(this.renderer_=new zf(this)),this.mapBrowserEventHandler_=new yc(this,this.moveTolerance_);for(const r in ct)this.mapBrowserEventHandler_.addEventListener(ct[r],this.handleMapBrowserEvent.bind(this));this.viewport_.addEventListener(B.CONTEXTMENU,this.boundHandleBrowserEvent_,!1),this.viewport_.addEventListener(B.WHEEL,this.boundHandleBrowserEvent_,sa?{passive:!1}:!1);let i;if(this.keyboardEventTarget_)i=this.keyboardEventTarget_;else{const r=e.getRootNode();i=r instanceof ShadowRoot?r.host:e}this.targetChangeHandlerKeys_=[$(i,B.KEYDOWN,this.handleBrowserEvent,this),$(i,B.KEYPRESS,this.handleBrowserEvent,this)];const s=e.getRootNode();s instanceof ShadowRoot&&this.resizeObserver_.observe(s.host),this.resizeObserver_.observe(e)}this.updateSize()}handleTileChange_(){this.render()}handleViewPropertyChanged_(){this.render()}handleViewChanged_(){this.viewPropertyListenerKey_&&(at(this.viewPropertyListenerKey_),this.viewPropertyListenerKey_=null),this.viewChangeListenerKey_&&(at(this.viewChangeListenerKey_),this.viewChangeListenerKey_=null);const t=this.getView();t&&(this.updateViewportSize_(this.getSize()),this.viewPropertyListenerKey_=$(t,oi.PROPERTYCHANGE,this.handleViewPropertyChanged_,this),this.viewChangeListenerKey_=$(t,B.CHANGE,this.handleViewPropertyChanged_,this),t.resolveConstraints(0)),this.render()}handleLayerGroupChanged_(){this.layerGroupPropertyListenerKeys_&&(this.layerGroupPropertyListenerKeys_.forEach(at),this.layerGroupPropertyListenerKeys_=null);const t=this.getLayerGroup();t&&(this.handleLayerAdd_(new Le("addlayer",t)),this.layerGroupPropertyListenerKeys_=[$(t,oi.PROPERTYCHANGE,this.render,this),$(t,B.CHANGE,this.render,this),$(t,"addlayer",this.handleLayerAdd_,this),$(t,"removelayer",this.handleLayerRemove_,this)]),this.render()}isRendered(){return!!this.frameState_}animationDelay_(){this.animationDelayKey_=void 0,this.renderFrame_(Date.now())}renderSync(){this.animationDelayKey_&&cancelAnimationFrame(this.animationDelayKey_),this.animationDelay_()}redrawText(){if(!this.frameState_)return;const t=this.frameState_.layerStatesArray;for(let e=0,i=t.length;e<i;++e){const s=t[e].layer;s.hasRenderer()&&s.getRenderer().handleFontsChanged()}}render(){this.renderer_&&this.animationDelayKey_===void 0&&(this.animationDelayKey_=requestAnimationFrame(this.animationDelay_))}removeControl(t){return this.getControls().remove(t)}removeInteraction(t){return this.getInteractions().remove(t)}removeLayer(t){return this.getLayerGroup().getLayers().remove(t)}handleLayerRemove_(t){Bl(t.layer)}removeOverlay(t){return this.getOverlays().remove(t)}renderFrame_(t){const e=this.getSize(),i=this.getView(),s=this.frameState_;let r=null;if(e!==void 0&&ml(e)&&i&&i.isDef()){const o=i.getHints(this.frameState_?this.frameState_.viewHints:void 0),a=i.getState();if(r={animate:!1,coordinateToPixelTransform:this.coordinateToPixelTransform_,declutter:null,extent:$s(a.center,a.resolution,a.rotation,e),index:this.frameIndex_++,layerIndex:0,layerStatesArray:this.getLayerGroup().getLayerStatesArray(),pixelRatio:this.pixelRatio_,pixelToCoordinateTransform:this.pixelToCoordinateTransform_,postRenderFunctions:[],size:e,tileQueue:this.tileQueue_,time:t,usedTiles:{},viewState:a,viewHints:o,wantedTiles:{},mapId:q(this),renderTargets:{}},a.nextCenter&&a.nextResolution){const l=isNaN(a.nextRotation)?a.rotation:a.nextRotation;r.nextExtent=$s(a.nextCenter,a.nextResolution,l,e)}}this.frameState_=r,this.renderer_.renderFrame(r),r&&(r.animate&&this.render(),Array.prototype.push.apply(this.postRenderFunctions_,r.postRenderFunctions),s&&(!this.previousExtent_||!Vn(this.previousExtent_)&&!Vi(r.extent,this.previousExtent_))&&(this.dispatchEvent(new li(Se.MOVESTART,this,s)),this.previousExtent_=Bn(this.previousExtent_)),this.previousExtent_&&!r.viewHints[St.ANIMATING]&&!r.viewHints[St.INTERACTING]&&!Vi(r.extent,this.previousExtent_)&&(this.dispatchEvent(new li(Se.MOVEEND,this,r)),la(r.extent,this.previousExtent_))),this.dispatchEvent(new li(Se.POSTRENDER,this,r)),this.renderComplete_=(this.hasListener(Se.LOADSTART)||this.hasListener(Se.LOADEND)||this.hasListener(Bt.RENDERCOMPLETE))&&!this.tileQueue_.getTilesLoading()&&!this.tileQueue_.getCount()&&!this.getLoadingOrNotReady(),this.postRenderTimeoutHandle_||(this.postRenderTimeoutHandle_=setTimeout(()=>{this.postRenderTimeoutHandle_=void 0,this.handlePostRender()},0))}setLayerGroup(t){const e=this.getLayerGroup();e&&this.handleLayerRemove_(new Le("removelayer",e)),this.set(Rt.LAYERGROUP,t)}setSize(t){this.set(Rt.SIZE,t)}setTarget(t){this.set(Rt.TARGET,t)}setView(t){if(!t||t instanceof re){this.set(Rt.VIEW,t);return}this.set(Rt.VIEW,new re);const e=this;t.then(function(i){e.setView(new re(i))})}updateSize(){const t=this.getTargetElement();let e;if(t){const s=getComputedStyle(t),r=t.offsetWidth-parseFloat(s.borderLeftWidth)-parseFloat(s.paddingLeft)-parseFloat(s.paddingRight)-parseFloat(s.borderRightWidth),o=t.offsetHeight-parseFloat(s.borderTopWidth)-parseFloat(s.paddingTop)-parseFloat(s.paddingBottom)-parseFloat(s.borderBottomWidth);!isNaN(r)&&!isNaN(o)&&(e=[Math.max(0,r),Math.max(0,o)],!ml(e)&&(t.offsetWidth||t.offsetHeight||t.getClientRects().length)&&Ea("No map visible because the map container's width or height are 0."))}const i=this.getSize();e&&(!i||!Ce(e,i))&&(this.setSize(e),this.updateViewportSize_(e))}updateViewportSize_(t){const e=this.getView();e&&e.setViewportSize(t)}};function Wf(n){let t=null;n.keyboardEventTarget!==void 0&&(t=typeof n.keyboardEventTarget=="string"?document.getElementById(n.keyboardEventTarget):n.keyboardEventTarget);const e={},i=n.layers&&typeof n.layers.getLayers=="function"?n.layers:new xi({layers:n.layers});e[Rt.LAYERGROUP]=i,e[Rt.TARGET]=n.target,e[Rt.VIEW]=n.view instanceof re?n.view:new re;let s;n.controls!==void 0&&(Array.isArray(n.controls)?s=new se(n.controls.slice()):(Q(typeof n.controls.getArray=="function","Expected `controls` to be an array or an `ol/Collection.js`"),s=n.controls));let r;n.interactions!==void 0&&(Array.isArray(n.interactions)?r=new se(n.interactions.slice()):(Q(typeof n.interactions.getArray=="function","Expected `interactions` to be an array or an `ol/Collection.js`"),r=n.interactions));let o;return n.overlays!==void 0?Array.isArray(n.overlays)?o=new se(n.overlays.slice()):(Q(typeof n.overlays.getArray=="function","Expected `overlays` to be an array or an `ol/Collection.js`"),o=n.overlays):o=new se,{controls:s,interactions:r,keyboardEventTarget:t,overlays:o,values:e}}class to extends Fn{constructor(t,e,i){super(),i=i||{},this.tileCoord=t,this.state=e,this.key="",this.transition_=i.transition===void 0?250:i.transition,this.transitionStarts_={},this.interpolate=!!i.interpolate}changed(){this.dispatchEvent(B.CHANGE)}release(){this.setState(N.EMPTY)}getKey(){return this.key+"/"+this.tileCoord}getTileCoord(){return this.tileCoord}getState(){return this.state}setState(t){if(this.state!==N.EMPTY){if(this.state!==N.ERROR&&this.state>t)throw new Error("Tile load sequence violation");this.state=t,this.changed()}}load(){H()}getAlpha(t,e){if(!this.transition_)return 1;let i=this.transitionStarts_[t];if(!i)i=e,this.transitionStarts_[t]=i;else if(i===-1)return 1;const s=e-i+1e3/60;return s>=this.transition_?1:ya(s/this.transition_)}inTransition(t){return this.transition_?this.transitionStarts_[t]!==-1:!1}endTransition(t){this.transition_&&(this.transitionStarts_[t]=-1)}disposeInternal(){this.release(),super.disposeInternal()}}function eo(n){return n instanceof Image||n instanceof HTMLCanvasElement||n instanceof HTMLVideoElement||n instanceof ImageBitmap?n:null}const Xf=new Error("disposed"),Yf=[256,256];class Kl extends to{constructor(t){const e=N.IDLE;super(t.tileCoord,e,{transition:t.transition,interpolate:t.interpolate}),this.loader_=t.loader,this.data_=null,this.error_=null,this.size_=t.size||null,this.controller_=t.controller||null}getSize(){if(this.size_)return this.size_;const t=eo(this.data_);return t?[t.width,t.height]:Yf}getData(){return this.data_}getError(){return this.error_}load(){if(this.state!==N.IDLE&&this.state!==N.ERROR)return;this.state=N.LOADING,this.changed();const t=this;this.loader_().then(function(e){t.data_=e,t.state=N.LOADED,t.changed()}).catch(function(e){t.error_=e,t.state=N.ERROR,t.changed()})}disposeInternal(){this.controller_&&(this.controller_.abort(Xf),this.controller_=null),super.disposeInternal()}}class jl extends to{constructor(t,e,i,s,r,o){super(t,e,o),this.crossOrigin_=s,this.src_=i,this.key=i,this.image_=new Image,s!==null&&(this.image_.crossOrigin=s),this.unlisten_=null,this.tileLoadFunction_=r}getImage(){return this.image_}setImage(t){this.image_=t,this.state=N.LOADED,this.unlistenImage_(),this.changed()}handleImageError_(){this.state=N.ERROR,this.unlistenImage_(),this.image_=Bf(),this.changed()}handleImageLoad_(){const t=this.image_;t.naturalWidth&&t.naturalHeight?this.state=N.LOADED:this.state=N.EMPTY,this.unlistenImage_(),this.changed()}load(){this.state==N.ERROR&&(this.state=N.IDLE,this.image_=new Image,this.crossOrigin_!==null&&(this.image_.crossOrigin=this.crossOrigin_)),this.state==N.IDLE&&(this.state=N.LOADING,this.changed(),this.tileLoadFunction_(this,this.src_),this.unlisten_=af(this.image_,this.handleImageLoad_.bind(this),this.handleImageError_.bind(this)))}unlistenImage_(){this.unlisten_&&(this.unlisten_(),this.unlisten_=null)}disposeInternal(){this.unlistenImage_(),this.image_=null,super.disposeInternal()}}function Bf(){const n=gt(1,1);return n.fillStyle="rgba(0,0,0,0)",n.fillRect(0,0,1,1),n.canvas}class io{constructor(t,e,i,s){this.minX=t,this.maxX=e,this.minY=i,this.maxY=s}contains(t){return this.containsXY(t[1],t[2])}containsTileRange(t){return this.minX<=t.minX&&t.maxX<=this.maxX&&this.minY<=t.minY&&t.maxY<=this.maxY}containsXY(t,e){return this.minX<=t&&t<=this.maxX&&this.minY<=e&&e<=this.maxY}equals(t){return this.minX==t.minX&&this.minY==t.minY&&this.maxX==t.maxX&&this.maxY==t.maxY}extend(t){t.minX<this.minX&&(this.minX=t.minX),t.maxX>this.maxX&&(this.maxX=t.maxX),t.minY<this.minY&&(this.minY=t.minY),t.maxY>this.maxY&&(this.maxY=t.maxY)}getHeight(){return this.maxY-this.minY+1}getSize(){return[this.getWidth(),this.getHeight()]}getWidth(){return this.maxX-this.minX+1}intersects(t){return this.minX<=t.maxX&&this.maxX>=t.minX&&this.minY<=t.maxY&&this.maxY>=t.minY}}function bi(n,t,e,i,s){return s!==void 0?(s.minX=n,s.maxX=t,s.minY=e,s.maxY=i,s):new io(n,t,e,i)}let no;const Mi=[];function Vl(n,t,e,i,s){n.beginPath(),n.moveTo(0,0),n.lineTo(t,e),n.lineTo(i,s),n.closePath(),n.save(),n.clip(),n.fillRect(0,0,Math.max(t,i)+1,Math.max(e,s)),n.restore()}function so(n,t){return Math.abs(n[t*4]-210)>2||Math.abs(n[t*4+3]-.75*255)>2}function Uf(){if(no===void 0){const n=gt(6,6,Mi);n.globalCompositeOperation="lighter",n.fillStyle="rgba(210, 0, 0, 0.75)",Vl(n,4,5,4,0),Vl(n,4,5,0,5);const t=n.getImageData(0,0,3,3).data;no=so(t,0)||so(t,4)||so(t,8),as(n),Mi.push(n.canvas)}return no}function Zl(n,t,e,i){const s=cr(e,t,n);let r=Da(t,i,e);const o=t.getMetersPerUnit();o!==void 0&&(r*=o);const a=n.getMetersPerUnit();a!==void 0&&(r/=a);const l=n.getExtent();if(!l||ui(l,s)){const h=Da(n,r,s)/r;isFinite(h)&&h>0&&(r/=h)}return r}function Kf(n,t,e,i){const s=Be(e);let r=Zl(n,t,s,i);return(!isFinite(r)||r<=0)&&fa(e,function(o){return r=Zl(n,t,o,i),isFinite(r)&&r>0}),r}function jf(n,t,e,i,s,r,o,a,l,h,c,u,d,f){const g=gt(Math.round(e*n),Math.round(e*t),Mi);if(u||(g.imageSmoothingEnabled=!1),l.length===0)return g.canvas;g.scale(e,e);function m(w){return Math.round(w*e)/e}g.globalCompositeOperation="lighter";const _=Xt();l.forEach(function(w,R,T){Sc(_,w.extent)});let p;const y=e/i,v=(u?1:1+Math.pow(2,-24))/y;p=gt(Math.round(et(_)*y),Math.round(It(_)*y),Mi),u||(p.imageSmoothingEnabled=!1),l.forEach(function(w,R,T){if(w.image.width>0&&w.image.height>0){if(w.clipExtent){p.save();const L=(w.clipExtent[0]-_[0])*y,A=-(w.clipExtent[3]-_[3])*y,P=et(w.clipExtent)*y,X=It(w.clipExtent)*y;p.rect(u?L:Math.round(L),u?A:Math.round(A),u?P:Math.round(L+P)-Math.round(L),u?X:Math.round(A+X)-Math.round(A)),p.clip()}const S=(w.extent[0]-_[0])*y,I=-(w.extent[3]-_[3])*y,M=et(w.extent)*y,O=It(w.extent)*y;p.drawImage(w.image,h,h,w.image.width-2*h,w.image.height-2*h,u?S:Math.round(S),u?I:Math.round(I),u?M:Math.round(S+M)-Math.round(S),u?O:Math.round(I+O)-Math.round(I)),w.clipExtent&&p.restore()}});const x=Ke(o);return a.getTriangles().forEach(function(w,R,T){const S=w.source,I=w.target;let M=S[0][0],O=S[0][1],L=S[1][0],A=S[1][1],P=S[2][0],X=S[2][1];const k=m((I[0][0]-x[0])/r),G=m(-(I[0][1]-x[1])/r),D=m((I[1][0]-x[0])/r),Y=m(-(I[1][1]-x[1])/r),V=m((I[2][0]-x[0])/r),tt=m(-(I[2][1]-x[1])/r),b=M,xt=O;M=0,O=0,L-=b,A-=xt,P-=b,X-=xt;const ft=[[L,A,0,0,D-k],[P,X,0,0,V-k],[0,0,L,A,Y-G],[0,0,P,X,tt-G]],ht=Cc(ft);if(!ht)return;if(g.save(),g.beginPath(),Uf()||!u){g.moveTo(D,Y);const Et=4,jt=k-D,Gt=G-Y;for(let Mt=0;Mt<Et;Mt++)g.lineTo(D+m((Mt+1)*jt/Et),Y+m(Mt*Gt/(Et-1))),Mt!=Et-1&&g.lineTo(D+m((Mt+1)*jt/Et),Y+m((Mt+1)*Gt/(Et-1)));g.lineTo(V,tt)}else g.moveTo(D,Y),g.lineTo(k,G),g.lineTo(V,tt);g.clip(),g.transform(ht[0],ht[2],ht[1],ht[3],k,G),g.translate(_[0]-b,_[3]-xt);let bt;if(p)bt=p.canvas,g.scale(v,-v);else{const Et=l[0],jt=Et.extent;bt=Et.image,g.scale(et(jt)/bt.width,-It(jt)/bt.height)}g.drawImage(bt,0,0),g.restore()}),p&&(as(p),Mi.push(p.canvas)),c&&(g.save(),g.globalCompositeOperation="source-over",g.strokeStyle="black",g.lineWidth=1,a.getTriangles().forEach(function(w,R,T){const S=w.target,I=(S[0][0]-x[0])/r,M=-(S[0][1]-x[1])/r,O=(S[1][0]-x[0])/r,L=-(S[1][1]-x[1])/r,A=(S[2][0]-x[0])/r,P=-(S[2][1]-x[1])/r;g.beginPath(),g.moveTo(O,L),g.lineTo(I,M),g.lineTo(A,P),g.closePath(),g.stroke()}),g.restore()),g.canvas}const Vf=10,$l=.25;class Zf{constructor(t,e,i,s,r,o,a){this.sourceProj_=t,this.targetProj_=e;let l={};const h=a?lu(v=>yt(a,cr(v,this.targetProj_,this.sourceProj_))):ts(this.targetProj_,this.sourceProj_);this.transformInv_=function(v){const x=v[0]+"/"+v[1];return l[x]||(l[x]=h(v)),l[x]},this.maxSourceExtent_=s,this.errorThresholdSquared_=r*r,this.triangles_=[],this.wrapsXInSource_=!1,this.canWrapXInSource_=this.sourceProj_.canWrapX()&&!!s&&!!this.sourceProj_.getExtent()&&et(s)>=et(this.sourceProj_.getExtent()),this.sourceWorldWidth_=this.sourceProj_.getExtent()?et(this.sourceProj_.getExtent()):null,this.targetWorldWidth_=this.targetProj_.getExtent()?et(this.targetProj_.getExtent()):null;const c=Ke(i),u=jn(i),d=Kn(i),f=Un(i),g=this.transformInv_(c),m=this.transformInv_(u),_=this.transformInv_(d),p=this.transformInv_(f),y=Vf+(o?Math.max(0,Math.ceil(Math.log2(Zs(i)/(o*o*256*256)))):0);if(this.addQuad_(c,u,d,f,g,m,_,p,y),this.wrapsXInSource_){let v=1/0;this.triangles_.forEach(function(x,w,R){v=Math.min(v,x.source[0][0],x.source[1][0],x.source[2][0])}),this.triangles_.forEach(x=>{if(Math.max(x.source[0][0],x.source[1][0],x.source[2][0])-v>this.sourceWorldWidth_/2){const w=[[x.source[0][0],x.source[0][1]],[x.source[1][0],x.source[1][1]],[x.source[2][0],x.source[2][1]]];w[0][0]-v>this.sourceWorldWidth_/2&&(w[0][0]-=this.sourceWorldWidth_),w[1][0]-v>this.sourceWorldWidth_/2&&(w[1][0]-=this.sourceWorldWidth_),w[2][0]-v>this.sourceWorldWidth_/2&&(w[2][0]-=this.sourceWorldWidth_);const R=Math.min(w[0][0],w[1][0],w[2][0]);Math.max(w[0][0],w[1][0],w[2][0])-R<this.sourceWorldWidth_/2&&(x.source=w)}})}l={}}addTriangle_(t,e,i,s,r,o){this.triangles_.push({source:[s,r,o],target:[t,e,i]})}addQuad_(t,e,i,s,r,o,a,l,h){const c=aa([r,o,a,l]),u=this.sourceWorldWidth_?et(c)/this.sourceWorldWidth_:null,d=this.sourceWorldWidth_,f=this.sourceProj_.canWrapX()&&u>.5&&u<1;let g=!1;if(h>0){if(this.targetProj_.isGlobal()&&this.targetWorldWidth_){const _=aa([t,e,i,s]);g=et(_)/this.targetWorldWidth_>$l||g}!f&&this.sourceProj_.isGlobal()&&u&&(g=u>$l||g)}if(!g&&this.maxSourceExtent_&&isFinite(c[0])&&isFinite(c[1])&&isFinite(c[2])&&isFinite(c[3])&&!Pt(c,this.maxSourceExtent_))return;let m=0;if(!g&&(!isFinite(r[0])||!isFinite(r[1])||!isFinite(o[0])||!isFinite(o[1])||!isFinite(a[0])||!isFinite(a[1])||!isFinite(l[0])||!isFinite(l[1]))){if(h>0)g=!0;else if(m=(!isFinite(r[0])||!isFinite(r[1])?8:0)+(!isFinite(o[0])||!isFinite(o[1])?4:0)+(!isFinite(a[0])||!isFinite(a[1])?2:0)+(!isFinite(l[0])||!isFinite(l[1])?1:0),m!=1&&m!=2&&m!=4&&m!=8)return}if(h>0){if(!g){const _=[(t[0]+i[0])/2,(t[1]+i[1])/2],p=this.transformInv_(_);let y;f?y=(ci(r[0],d)+ci(a[0],d))/2-ci(p[0],d):y=(r[0]+a[0])/2-p[0];const v=(r[1]+a[1])/2-p[1];g=y*y+v*v>this.errorThresholdSquared_}if(g){if(Math.abs(t[0]-i[0])<=Math.abs(t[1]-i[1])){const _=[(e[0]+i[0])/2,(e[1]+i[1])/2],p=this.transformInv_(_),y=[(s[0]+t[0])/2,(s[1]+t[1])/2],v=this.transformInv_(y);this.addQuad_(t,e,_,y,r,o,p,v,h-1),this.addQuad_(y,_,i,s,v,p,a,l,h-1)}else{const _=[(t[0]+e[0])/2,(t[1]+e[1])/2],p=this.transformInv_(_),y=[(i[0]+s[0])/2,(i[1]+s[1])/2],v=this.transformInv_(y);this.addQuad_(t,_,y,s,r,p,v,l,h-1),this.addQuad_(_,e,i,y,p,o,a,v,h-1)}return}}if(f){if(!this.canWrapXInSource_)return;this.wrapsXInSource_=!0}(m&11)==0&&this.addTriangle_(t,i,s,r,a,l),(m&14)==0&&this.addTriangle_(t,i,e,r,a,o),m&&((m&13)==0&&this.addTriangle_(e,s,t,o,l,r),(m&7)==0&&this.addTriangle_(e,s,i,o,l,a))}calculateSourceExtent(){const t=Xt();return this.triangles_.forEach(function(e,i,s){const r=e.source;Zi(t,r[0]),Zi(t,r[1]),Zi(t,r[2])}),t}getTriangles(){return this.triangles_}}const $f=.5;class Hl extends to{constructor(t,e,i,s,r,o,a,l,h,c,u,d){super(r,N.IDLE,d),this.renderEdges_=u!==void 0?u:!1,this.pixelRatio_=a,this.gutter_=l,this.canvas_=null,this.sourceTileGrid_=e,this.targetTileGrid_=s,this.wrappedTileCoord_=o||r,this.sourceTiles_=[],this.sourcesListenerKeys_=null,this.sourceZ_=0,this.clipExtent_=t.canWrapX()?t.getExtent():void 0;const f=s.getTileCoordExtent(this.wrappedTileCoord_),g=this.targetTileGrid_.getExtent();let m=this.sourceTileGrid_.getExtent();const _=g?Ue(f,g):f;if(Zs(_)===0){this.state=N.EMPTY;return}const p=t.getExtent();p&&(m?m=Ue(m,p):m=p);const y=s.getResolution(this.wrappedTileCoord_[0]),v=Kf(t,i,_,y);if(!isFinite(v)||v<=0){this.state=N.EMPTY;return}const x=c!==void 0?c:$f;if(this.triangulation_=new Zf(t,i,_,m,v*x,y),this.triangulation_.getTriangles().length===0){this.state=N.EMPTY;return}this.sourceZ_=e.getZForResolution(v);let w=this.triangulation_.calculateSourceExtent();if(m&&(t.canWrapX()?(w[1]=lt(w[1],m[1],m[3]),w[3]=lt(w[3],m[1],m[3])):w=Ue(w,m)),!Zs(w))this.state=N.EMPTY;else{let R=0,T=0;t.canWrapX()&&(R=et(p),T=Math.floor((w[0]-p[0])/R)),ma(w.slice(),t,!0).forEach(I=>{const M=e.getTileRangeForExtentAndZ(I,this.sourceZ_);for(let O=M.minX;O<=M.maxX;O++)for(let L=M.minY;L<=M.maxY;L++){const A=h(this.sourceZ_,O,L,a);if(A){const P=T*R;this.sourceTiles_.push({tile:A,offset:P})}}++T}),this.sourceTiles_.length===0&&(this.state=N.EMPTY)}}getImage(){return this.canvas_}reproject_(){const t=[];if(this.sourceTiles_.forEach(e=>{const i=e.tile;if(i&&i.getState()==N.LOADED){const s=this.sourceTileGrid_.getTileCoordExtent(i.tileCoord);s[0]+=e.offset,s[2]+=e.offset;const r=this.clipExtent_?.slice();r&&(r[0]+=e.offset,r[2]+=e.offset),t.push({extent:s,clipExtent:r,image:i.getImage()})}}),this.sourceTiles_.length=0,t.length===0)this.state=N.ERROR;else{const e=this.wrappedTileCoord_[0],i=this.targetTileGrid_.getTileSize(e),s=typeof i=="number"?i:i[0],r=typeof i=="number"?i:i[1],o=this.targetTileGrid_.getResolution(e),a=this.sourceTileGrid_.getResolution(this.sourceZ_),l=this.targetTileGrid_.getTileCoordExtent(this.wrappedTileCoord_);this.canvas_=jf(s,r,this.pixelRatio_,a,this.sourceTileGrid_.getExtent(),o,l,this.triangulation_,t,this.gutter_,this.renderEdges_,this.interpolate),this.state=N.LOADED}this.changed()}load(){if(this.state==N.IDLE){this.state=N.LOADING,this.changed();let t=0;this.sourcesListenerKeys_=[],this.sourceTiles_.forEach(({tile:e})=>{const i=e.getState();if(i==N.IDLE||i==N.LOADING){t++;const s=$(e,B.CHANGE,r=>{const o=e.getState();(o==N.LOADED||o==N.ERROR||o==N.EMPTY)&&(at(s),t--,t===0&&(this.unlistenSources_(),this.reproject_()))});this.sourcesListenerKeys_.push(s)}}),t===0?setTimeout(this.reproject_.bind(this),0):this.sourceTiles_.forEach(function({tile:e},i,s){e.getState()==N.IDLE&&e.load()})}}unlistenSources_(){this.sourcesListenerKeys_.forEach(at),this.sourcesListenerKeys_=null}release(){this.canvas_&&(as(this.canvas_.getContext("2d")),Mi.push(this.canvas_),this.canvas_=null),super.release()}}class Hf{constructor(t){this.highWaterMark=t!==void 0?t:2048,this.count_=0,this.entries_={},this.oldest_=null,this.newest_=null}deleteOldest(){const t=this.pop();t instanceof Dn&&t.dispose()}canExpireCache(){return this.highWaterMark>0&&this.getCount()>this.highWaterMark}expireCache(t){for(;this.canExpireCache();)this.deleteOldest()}clear(){for(;this.oldest_;)this.deleteOldest()}containsKey(t){return this.entries_.hasOwnProperty(t)}forEach(t){let e=this.oldest_;for(;e;)t(e.value_,e.key_,this),e=e.newer}get(t,e){const i=this.entries_[t];return Q(i!==void 0,"Tried to get a value for a key that does not exist in the cache"),i===this.newest_||(i===this.oldest_?(this.oldest_=this.oldest_.newer,this.oldest_.older=null):(i.newer.older=i.older,i.older.newer=i.newer),i.newer=null,i.older=this.newest_,this.newest_.newer=i,this.newest_=i),i.value_}remove(t){const e=this.entries_[t];return Q(e!==void 0,"Tried to get a value for a key that does not exist in the cache"),e===this.newest_?(this.newest_=e.older,this.newest_&&(this.newest_.newer=null)):e===this.oldest_?(this.oldest_=e.newer,this.oldest_&&(this.oldest_.older=null)):(e.newer.older=e.older,e.older.newer=e.newer),delete this.entries_[t],--this.count_,e.value_}getCount(){return this.count_}getKeys(){const t=new Array(this.count_);let e=0,i;for(i=this.newest_;i;i=i.older)t[e++]=i.key_;return t}getValues(){const t=new Array(this.count_);let e=0,i;for(i=this.newest_;i;i=i.older)t[e++]=i.value_;return t}peekLast(){return this.oldest_.value_}peekLastKey(){return this.oldest_.key_}peekFirstKey(){return this.newest_.key_}peek(t){return this.entries_[t]?.value_}pop(){const t=this.oldest_;return delete this.entries_[t.key_],t.newer&&(t.newer.older=null),this.oldest_=t.newer,this.oldest_||(this.newest_=null),--this.count_,t.value_}replace(t,e){this.get(t),this.entries_[t].value_=e}set(t,e){Q(!(t in this.entries_),"Tried to set a value for a key that is used already");const i={key_:t,newer:null,older:this.newest_,value_:e};this.newest_?this.newest_.newer=i:this.oldest_=i,this.newest_=i,this.entries_[t]=i,++this.count_}setSize(t){this.highWaterMark=t}}function vs(n,t,e,i){return i!==void 0?(i[0]=n,i[1]=t,i[2]=e,i):[n,t,e]}function qf(n,t,e){return n+"/"+t+"/"+e}function Jf(n){return Qf(n[0],n[1],n[2])}function Qf(n,t,e){return(t<<n)+e}function tg(n,t){const e=n[0],i=n[1],s=n[2];if(t.getMinZoom()>e||e>t.getMaxZoom())return!1;const r=t.getFullTileRange(e);return r?r.containsXY(i,s):!0}class ql{constructor(){this.instructions_=[],this.zIndex=0,this.offset_=0,this.context_=new Proxy(os(),{get:(t,e)=>{if(typeof os()[e]=="function")return this.push_(e),this.pushMethodArgs_},set:(t,e,i)=>(this.push_(e,i),!0)})}push_(...t){const e=this.instructions_,i=this.zIndex+this.offset_;e[i]||(e[i]=[]),e[i].push(...t)}pushMethodArgs_=(...t)=>(this.push_(t),this);pushFunction(t){this.push_(t)}getContext(){return this.context_}draw(t){this.instructions_.forEach(e=>{for(let i=0,s=e.length;i<s;++i){const r=e[i];if(typeof r=="function"){r(t);continue}const o=e[++i];if(typeof t[r]=="function")t[r](...o);else{if(typeof o=="function"){t[r]=o(t);continue}t[r]=o}}})}clear(){this.instructions_.length=0,this.zIndex=0,this.offset_=0}offset(){this.offset_=this.instructions_.length,this.zIndex=0}}const eg=5;class ig extends Ki{constructor(t){super(),this.ready=!0,this.boundHandleImageChange_=this.handleImageChange_.bind(this),this.layer_=t,this.staleKeys_=new Array,this.maxStaleKeys=eg}getStaleKeys(){return this.staleKeys_}prependStaleKey(t){this.staleKeys_.unshift(t),this.staleKeys_.length>this.maxStaleKeys&&(this.staleKeys_.length=this.maxStaleKeys)}getFeatures(t){return H()}getData(t){return null}prepareFrame(t){return H()}renderFrame(t,e){return H()}forEachFeatureAtCoordinate(t,e,i,s,r){}getLayer(){return this.layer_}handleFontsChanged(){}handleImageChange_(t){const e=t.target;(e.getState()===K.LOADED||e.getState()===K.ERROR)&&this.renderIfReadyAndVisible()}loadImage(t){let e=t.getState();return e!=K.LOADED&&e!=K.ERROR&&t.addEventListener(B.CHANGE,this.boundHandleImageChange_),e==K.IDLE&&(t.load(),e=t.getState()),e==K.LOADED}renderIfReadyAndVisible(){const t=this.getLayer();t&&t.getVisible()&&t.getSourceState()==="ready"&&t.changed()}renderDeferred(t){}disposeInternal(){delete this.layer_,super.disposeInternal()}}const Jl=[];let Li=null;function ng(){Li=gt(1,1,void 0,{willReadFrequently:!0})}class Ql extends ig{constructor(t){super(t),this.container=null,this.renderedResolution,this.tempTransform=qt(),this.pixelTransform=qt(),this.inversePixelTransform=qt(),this.context=null,this.deferredContext_=null,this.containerReused=!1,this.frameState=null}getImageData(t,e,i){Li||ng(),Li.clearRect(0,0,1,1);let s;try{Li.drawImage(t,e,i,1,1,0,0,1,1),s=Li.getImageData(0,0,1,1).data}catch{return Li=null,null}return s}getBackground(t){let i=this.getLayer().getBackground();return typeof i=="function"&&(i=i(t.viewState.resolution)),i||void 0}useContainer(t,e,i){const s=this.getLayer().getClassName();let r,o;if(t&&t.className===s&&(!i||t&&t.style.backgroundColor&&Ce(vi(t.style.backgroundColor),vi(i)))){const a=t.firstElementChild;a instanceof HTMLCanvasElement&&(o=a.getContext("2d"))}if(o&&_u(o.canvas.style.transform,e)?(this.container=t,this.context=o,this.containerReused=!0):this.containerReused?(this.container=null,this.context=null,this.containerReused=!1):this.container&&(this.container.style.backgroundColor=null),!this.container){r=document.createElement("div"),r.className=s;let a=r.style;a.position="absolute",a.width="100%",a.height="100%",o=gt();const l=o.canvas;r.appendChild(l),a=l.style,a.position="absolute",a.left="0",a.transformOrigin="top left",this.container=r,this.context=o}!this.containerReused&&i&&!this.container.style.backgroundColor&&(this.container.style.backgroundColor=i)}clipUnrotated(t,e,i){const s=Ke(i),r=jn(i),o=Kn(i),a=Un(i);yt(e.coordinateToPixelTransform,s),yt(e.coordinateToPixelTransform,r),yt(e.coordinateToPixelTransform,o),yt(e.coordinateToPixelTransform,a);const l=this.inversePixelTransform;yt(l,s),yt(l,r),yt(l,o),yt(l,a),t.save(),t.beginPath(),t.moveTo(Math.round(s[0]),Math.round(s[1])),t.lineTo(Math.round(r[0]),Math.round(r[1])),t.lineTo(Math.round(o[0]),Math.round(o[1])),t.lineTo(Math.round(a[0]),Math.round(a[1])),t.clip()}prepareContainer(t,e){const i=t.extent,s=t.viewState.resolution,r=t.viewState.rotation,o=t.pixelRatio,a=Math.round(et(i)/s*o),l=Math.round(It(i)/s*o);fe(this.pixelTransform,t.size[0]/2,t.size[1]/2,1/o,1/o,r,-a/2,-l/2),Na(this.inversePixelTransform,this.pixelTransform);const h=gu(this.pixelTransform);if(this.useContainer(e,h,this.getBackground(t)),!this.containerReused){const c=this.context.canvas;c.width!=a||c.height!=l?(c.width=a,c.height=l):this.context.clearRect(0,0,a,l),h!==c.style.transform&&(c.style.transform=h)}}dispatchRenderEvent_(t,e,i){const s=this.getLayer();if(s.hasListener(t)){const r=new Yl(t,this.inversePixelTransform,i,e);s.dispatchEvent(r)}}preRender(t,e){this.frameState=e,!e.declutter&&this.dispatchRenderEvent_(Bt.PRERENDER,t,e)}postRender(t,e){e.declutter||this.dispatchRenderEvent_(Bt.POSTRENDER,t,e)}renderDeferredInternal(t){}getRenderContext(t){return t.declutter&&!this.deferredContext_&&(this.deferredContext_=new ql),t.declutter?this.deferredContext_.getContext():this.context}renderDeferred(t){t.declutter&&(this.dispatchRenderEvent_(Bt.PRERENDER,this.context,t),t.declutter&&this.deferredContext_&&(this.deferredContext_.draw(this.context),this.deferredContext_.clear()),this.renderDeferredInternal(t),this.dispatchRenderEvent_(Bt.POSTRENDER,this.context,t))}getRenderTransform(t,e,i,s,r,o,a){const l=r/2,h=o/2,c=s/e,u=-c,d=-t[0]+a,f=-t[1];return fe(this.tempTransform,l,h,c,u,-i,d,f)}disposeInternal(){delete this.frameState,super.disposeInternal()}}function ro(n,t,e,i,s){return`${q(n)},${t},${qf(e,i,s)}`}function oo(n,t,e){if(!(e in n))return n[e]=new Set([t]),!0;const i=n[e],s=i.has(t);return s||i.add(t),!s}function sg(n,t,e){const i=n[e];return i?i.delete(t):!1}function th(n,t){const e=n.layerStatesArray[n.layerIndex];e.extent&&(t=Ue(t,be(e.extent,n.viewState.projection)));const i=e.layer.getRenderSource();if(!i.getWrapX()){const s=i.getTileGridForProjection(n.viewState.projection).getExtent();s&&(t=Ue(t,s))}return t}class rg extends Ql{constructor(t,e){super(t),e=e||{},this.extentChanged=!0,this.renderComplete=!1,this.renderedExtent_=null,this.renderedPixelRatio,this.renderedProjection=null,this.renderedTiles=[],this.renderedSourceKey_,this.renderedSourceRevision_,this.tempExtent=Xt(),this.tempTileRange_=new io(0,0,0,0),this.tempTileCoord_=vs(0,0,0);const i=e.cacheSize!==void 0?e.cacheSize:512;this.tileCache_=new Hf(i),this.maxStaleKeys=i*.5}getTileCache(){return this.tileCache_}getOrCreateTile(t,e,i,s){const r=this.tileCache_,a=this.getLayer().getSource(),l=ro(a,a.getKey(),t,e,i);let h;if(r.containsKey(l))h=r.get(l);else{if(h=a.getTile(t,e,i,s.pixelRatio,s.viewState.projection),!h)return null;r.set(l,h)}return h}getTile(t,e,i,s){const r=this.getOrCreateTile(t,e,i,s);return r||null}getData(t){const e=this.frameState;if(!e)return null;const i=this.getLayer(),s=yt(e.pixelToCoordinateTransform,t.slice()),r=i.getExtent();if(r&&!ui(r,s))return null;const o=e.viewState,a=i.getRenderSource(),l=a.getTileGridForProjection(o.projection),h=a.getTilePixelRatio(e.pixelRatio);for(let c=l.getZForResolution(o.resolution);c>=l.getMinZoom();--c){const u=l.getTileCoordForCoordAndZ(s,c),d=this.getTile(c,u[1],u[2],e);if(!d||d.getState()!==N.LOADED)continue;const f=l.getOrigin(c),g=kt(l.getTileSize(c)),m=l.getResolution(c);let _;if(d instanceof jl||d instanceof Hl)_=d.getImage();else if(d instanceof Kl){if(_=eo(d.getData()),!_)continue}else continue;const p=Math.floor(h*((s[0]-f[0])/m-u[1]*g[0])),y=Math.floor(h*((f[1]-s[1])/m-u[2]*g[1])),v=Math.round(h*a.getGutterForProjection(o.projection));return this.getImageData(_,p+v,y+v)}return null}prepareFrame(t){this.renderedProjection?t.viewState.projection!==this.renderedProjection&&(this.tileCache_.clear(),this.renderedProjection=t.viewState.projection):this.renderedProjection=t.viewState.projection;const e=this.getLayer().getSource();if(!e)return!1;const i=e.getRevision();return this.renderedSourceRevision_?this.renderedSourceRevision_!==i&&(this.renderedSourceRevision_=i,this.renderedSourceKey_===e.getKey()&&this.tileCache_.clear()):this.renderedSourceRevision_=i,!0}enqueueTiles(t,e,i,s,r){const o=t.viewState,a=this.getLayer(),l=a.getRenderSource(),h=l.getTileGridForProjection(o.projection),c=q(l);c in t.wantedTiles||(t.wantedTiles[c]={});const u=t.wantedTiles[c],d=a.getMapInternal(),f=Math.max(i-r,h.getMinZoom(),h.getZForResolution(Math.min(a.getMaxResolution(),d?d.getView().getResolutionForZoom(Math.max(a.getMinZoom(),0)):h.getResolution(0)),l.zDirection)),g=o.rotation,m=g?ga(o.center,o.resolution,g,t.size):void 0;for(let _=i;_>=f;--_){const p=h.getTileRangeForExtentAndZ(e,_,this.tempTileRange_),y=h.getResolution(_);for(let v=p.minX;v<=p.maxX;++v)for(let x=p.minY;x<=p.maxY;++x){if(g&&!h.tileCoordIntersectsViewport([_,v,x],m))continue;const w=this.getTile(_,v,x,t);if(!w||!oo(s,w,_))continue;const T=w.getKey();if(u[T]=!0,w.getState()===N.IDLE&&!t.tileQueue.isKeyQueued(T)){const S=vs(_,v,x,this.tempTileCoord_);t.tileQueue.enqueue([w,c,h.getTileCoordCenter(S),y])}}}}findStaleTile_(t,e){const i=this.tileCache_,s=t[0],r=t[1],o=t[2],a=this.getStaleKeys();for(let l=0;l<a.length;++l){const h=ro(this.getLayer().getSource(),a[l],s,r,o);if(i.containsKey(h)){const c=i.peek(h);if(c.getState()===N.LOADED)return c.endTransition(q(this)),oo(e,c,s),!0}}return!1}findAltTiles_(t,e,i,s){const r=t.getTileRangeForTileCoordAndZ(e,i,this.tempTileRange_);if(!r)return!1;let o=!0;const a=this.tileCache_,l=this.getLayer().getRenderSource(),h=l.getKey();for(let c=r.minX;c<=r.maxX;++c)for(let u=r.minY;u<=r.maxY;++u){const d=ro(l,h,i,c,u);let f=!1;if(a.containsKey(d)){const g=a.peek(d);g.getState()===N.LOADED&&(oo(s,g,i),f=!0)}f||(o=!1)}return o}renderFrame(t,e){this.renderComplete=!0;const i=t.layerStatesArray[t.layerIndex],s=t.viewState,r=s.projection,o=s.resolution,a=s.center,l=t.pixelRatio,h=this.getLayer(),c=h.getSource(),u=c.getTileGridForProjection(r),d=u.getZForResolution(o,c.zDirection),f=u.getResolution(d),g=c.getKey();this.renderedSourceKey_?this.renderedSourceKey_!==g&&(this.prependStaleKey(this.renderedSourceKey_),this.renderedSourceKey_=g):this.renderedSourceKey_=g;let m=t.extent;const _=c.getTilePixelRatio(l);this.prepareContainer(t,e);const p=this.context.canvas.width,y=this.context.canvas.height,v=i.extent&&be(i.extent);v&&(m=Ue(m,be(i.extent)));const x=f*p/2/_,w=f*y/2/_,R=[a[0]-x,a[1]-w,a[0]+x,a[1]+w],T={};this.renderedTiles.length=0;const S=h.getPreload();if(t.nextExtent){const D=u.getZForResolution(s.nextResolution,c.zDirection),Y=th(t,t.nextExtent);this.enqueueTiles(t,Y,D,T,S)}const I=th(t,m);if(this.enqueueTiles(t,I,d,T,0),S>0&&setTimeout(()=>{this.enqueueTiles(t,I,d-1,T,S-1)},0),!(d in T))return this.container;const M=q(this),O=t.time;for(const D of T[d]){const Y=D.getState();if(Y===N.EMPTY)continue;const V=D.tileCoord;if(Y===N.LOADED&&D.getAlpha(M,O)===1){D.endTransition(M);continue}if(Y!==N.ERROR&&(this.renderComplete=!1),this.findStaleTile_(V,T)){sg(T,D,d),t.animate=!0;continue}if(this.findAltTiles_(u,V,d+1,T))continue;const xt=u.getMinZoom();for(let ft=d-1;ft>=xt&&!this.findAltTiles_(u,V,ft,T);--ft);}const L=f/o*l/_,A=this.getRenderContext(t);fe(this.tempTransform,p/2,y/2,L,L,0,-p/2,-y/2),i.extent&&this.clipUnrotated(A,t,v),c.getInterpolate()||(A.imageSmoothingEnabled=!1),this.preRender(A,t);const P=Object.keys(T).map(Number);P.sort(ce);let X;const k=[],G=[];for(let D=P.length-1;D>=0;--D){const Y=P[D],V=c.getTilePixelSize(Y,l,r),b=u.getResolution(Y)/f,xt=V[0]*b*L,ft=V[1]*b*L,ht=u.getTileCoordForCoordAndZ(Ke(R),Y),bt=u.getTileCoordExtent(ht),Et=yt(this.tempTransform,[_*(bt[0]-R[0])/f,_*(R[3]-bt[3])/f]),jt=_*c.getGutterForProjection(r);for(const Gt of T[Y]){if(Gt.getState()!==N.LOADED)continue;const Mt=Gt.tileCoord,Pi=ht[1]-Mt[1],W=Math.round(Et[0]-(Pi-1)*xt),rt=ht[2]-Mt[2],j=Math.round(Et[1]-(rt-1)*ft),nt=Math.round(Et[0]-Pi*xt),mt=Math.round(Et[1]-rt*ft),ze=W-nt,Di=j-mt,Rn=P.length===1;let ii=!1;X=[nt,mt,nt+ze,mt,nt+ze,mt+Di,nt,mt+Di];for(let ki=0,Fi=k.length;ki<Fi;++ki)if(!Rn&&Y<G[ki]){const wt=k[ki];Pt([nt,mt,nt+ze,mt+Di],[wt[0],wt[3],wt[4],wt[7]])&&(ii||(A.save(),ii=!0),A.beginPath(),A.moveTo(X[0],X[1]),A.lineTo(X[2],X[3]),A.lineTo(X[4],X[5]),A.lineTo(X[6],X[7]),A.moveTo(wt[6],wt[7]),A.lineTo(wt[4],wt[5]),A.lineTo(wt[2],wt[3]),A.lineTo(wt[0],wt[1]),A.clip())}k.push(X),G.push(Y),this.drawTile(Gt,t,nt,mt,ze,Di,jt,Rn),ii&&A.restore(),this.renderedTiles.unshift(Gt),this.updateUsedTiles(t.usedTiles,c,Gt)}}if(this.renderedResolution=f,this.extentChanged=!this.renderedExtent_||!Vi(this.renderedExtent_,R),this.renderedExtent_=R,this.renderedPixelRatio=l,this.postRender(this.context,t),i.extent&&A.restore(),A.imageSmoothingEnabled=!0,this.renderComplete){const D=(Y,V)=>{const tt=q(c),b=V.wantedTiles[tt],xt=b?Object.keys(b).length:0;this.updateCacheSize(xt),this.tileCache_.expireCache()};t.postRenderFunctions.push(D)}return this.container}updateCacheSize(t){this.tileCache_.highWaterMark=Math.max(this.tileCache_.highWaterMark,t*2)}drawTile(t,e,i,s,r,o,a,l){let h;if(t instanceof Kl){if(h=eo(t.getData()),!h)throw new Error("Rendering array data is not yet supported")}else h=this.getTileImage(t);if(!h)return;const c=this.getRenderContext(e),u=q(this),d=e.layerStatesArray[e.layerIndex],f=d.opacity*(l?t.getAlpha(u,e.time):1),g=f!==c.globalAlpha;g&&(c.save(),c.globalAlpha=f),c.drawImage(h,a,a,h.width-2*a,h.height-2*a,i,s,r,o),g&&c.restore(),f!==d.opacity?e.animate=!0:l&&t.endTransition(u)}getImage(){const t=this.context;return t?t.canvas:null}getTileImage(t){return t.getImage()}updateUsedTiles(t,e,i){const s=q(e);s in t||(t[s]={}),t[s][i.getKey()]=!0}}const Cs={PRELOAD:"preload",USE_INTERIM_TILES_ON_ERROR:"useInterimTilesOnError"};class og extends ls{constructor(t){t=t||{};const e=Object.assign({},t),i=t.cacheSize;delete t.cacheSize,delete e.preload,delete e.useInterimTilesOnError,super(e),this.on,this.once,this.un,this.cacheSize_=i,this.setPreload(t.preload!==void 0?t.preload:0),this.setUseInterimTilesOnError(t.useInterimTilesOnError!==void 0?t.useInterimTilesOnError:!0)}getCacheSize(){return this.cacheSize_}getPreload(){return this.get(Cs.PRELOAD)}setPreload(t){this.set(Cs.PRELOAD,t)}getUseInterimTilesOnError(){return this.get(Cs.USE_INTERIM_TILES_ON_ERROR)}setUseInterimTilesOnError(t){this.set(Cs.USE_INTERIM_TILES_ON_ERROR,t)}getData(t){return super.getData(t)}}class ag extends og{constructor(t){super(t)}createRenderer(){return new rg(this,{cacheSize:this.getCacheSize()})}}const Ai=[0,0,0],Pe=5;class eh{constructor(t){this.minZoom=t.minZoom!==void 0?t.minZoom:0,this.resolutions_=t.resolutions,Q(dc(this.resolutions_,(s,r)=>r-s),"`resolutions` must be sorted in descending order");let e;if(!t.origins){for(let s=0,r=this.resolutions_.length-1;s<r;++s)if(!e)e=this.resolutions_[s]/this.resolutions_[s+1];else if(this.resolutions_[s]/this.resolutions_[s+1]!==e){e=void 0;break}}this.zoomFactor_=e,this.maxZoom=this.resolutions_.length-1,this.origin_=t.origin!==void 0?t.origin:null,this.origins_=null,t.origins!==void 0&&(this.origins_=t.origins,Q(this.origins_.length==this.resolutions_.length,"Number of `origins` and `resolutions` must be equal"));const i=t.extent;i!==void 0&&!this.origin_&&!this.origins_&&(this.origin_=Ke(i)),Q(!this.origin_&&this.origins_||this.origin_&&!this.origins_,"Either `origin` or `origins` must be configured, never both"),this.tileSizes_=null,t.tileSizes!==void 0&&(this.tileSizes_=t.tileSizes,Q(this.tileSizes_.length==this.resolutions_.length,"Number of `tileSizes` and `resolutions` must be equal")),this.tileSize_=t.tileSize!==void 0?t.tileSize:this.tileSizes_?null:xr,Q(!this.tileSize_&&this.tileSizes_||this.tileSize_&&!this.tileSizes_,"Either `tileSize` or `tileSizes` must be configured, never both"),this.extent_=i!==void 0?i:null,this.fullTileRanges_=null,this.tmpSize_=[0,0],this.tmpExtent_=[0,0,0,0],t.sizes!==void 0?this.fullTileRanges_=t.sizes.map((s,r)=>{const o=new io(Math.min(0,s[0]),Math.max(s[0]-1,-1),Math.min(0,s[1]),Math.max(s[1]-1,-1));if(i){const a=this.getTileRangeForExtentAndZ(i,r);o.minX=Math.max(a.minX,o.minX),o.maxX=Math.min(a.maxX,o.maxX),o.minY=Math.max(a.minY,o.minY),o.maxY=Math.min(a.maxY,o.maxY)}return o}):i&&this.calculateTileRanges_(i)}forEachTileCoord(t,e,i){const s=this.getTileRangeForExtentAndZ(t,e);for(let r=s.minX,o=s.maxX;r<=o;++r)for(let a=s.minY,l=s.maxY;a<=l;++a)i([e,r,a])}forEachTileCoordParentTileRange(t,e,i,s){let r,o,a,l=null,h=t[0]-1;for(this.zoomFactor_===2?(o=t[1],a=t[2]):l=this.getTileCoordExtent(t,s);h>=this.minZoom;){if(o!==void 0&&a!==void 0?(o=Math.floor(o/2),a=Math.floor(a/2),r=bi(o,o,a,a,i)):r=this.getTileRangeForExtentAndZ(l,h,i),e(h,r))return!0;--h}return!1}getExtent(){return this.extent_}getMaxZoom(){return this.maxZoom}getMinZoom(){return this.minZoom}getOrigin(t){return this.origin_?this.origin_:this.origins_[t]}getResolution(t){return this.resolutions_[t]}getResolutions(){return this.resolutions_}getTileCoordChildTileRange(t,e,i){if(t[0]<this.maxZoom){if(this.zoomFactor_===2){const r=t[1]*2,o=t[2]*2;return bi(r,r+1,o,o+1,e)}const s=this.getTileCoordExtent(t,i||this.tmpExtent_);return this.getTileRangeForExtentAndZ(s,t[0]+1,e)}return null}getTileRangeForTileCoordAndZ(t,e,i){if(e>this.maxZoom||e<this.minZoom)return null;const s=t[0],r=t[1],o=t[2];if(e===s)return bi(r,o,r,o,i);if(this.zoomFactor_){const l=Math.pow(this.zoomFactor_,e-s),h=Math.floor(r*l),c=Math.floor(o*l);if(e<s)return bi(h,h,c,c,i);const u=Math.floor(l*(r+1))-1,d=Math.floor(l*(o+1))-1;return bi(h,u,c,d,i)}const a=this.getTileCoordExtent(t,this.tmpExtent_);return this.getTileRangeForExtentAndZ(a,e,i)}getTileRangeForExtentAndZ(t,e,i){this.getTileCoordForXYAndZ_(t[0],t[3],e,!1,Ai);const s=Ai[1],r=Ai[2];this.getTileCoordForXYAndZ_(t[2],t[1],e,!0,Ai);const o=Ai[1],a=Ai[2];return bi(s,o,r,a,i)}getTileCoordCenter(t){const e=this.getOrigin(t[0]),i=this.getResolution(t[0]),s=kt(this.getTileSize(t[0]),this.tmpSize_);return[e[0]+(t[1]+.5)*s[0]*i,e[1]-(t[2]+.5)*s[1]*i]}getTileCoordExtent(t,e){const i=this.getOrigin(t[0]),s=this.getResolution(t[0]),r=kt(this.getTileSize(t[0]),this.tmpSize_),o=i[0]+t[1]*r[0]*s,a=i[1]-(t[2]+1)*r[1]*s,l=o+r[0]*s,h=a+r[1]*s;return Te(o,a,l,h,e)}getTileCoordForCoordAndResolution(t,e,i){return this.getTileCoordForXYAndResolution_(t[0],t[1],e,!1,i)}getTileCoordForXYAndResolution_(t,e,i,s,r){const o=this.getZForResolution(i),a=i/this.getResolution(o),l=this.getOrigin(o),h=kt(this.getTileSize(o),this.tmpSize_);let c=a*(t-l[0])/i/h[0],u=a*(l[1]-e)/i/h[1];return s?(c=Yn(c,Pe)-1,u=Yn(u,Pe)-1):(c=Xn(c,Pe),u=Xn(u,Pe)),vs(o,c,u,r)}getTileCoordForXYAndZ_(t,e,i,s,r){const o=this.getOrigin(i),a=this.getResolution(i),l=kt(this.getTileSize(i),this.tmpSize_);let h=(t-o[0])/a/l[0],c=(o[1]-e)/a/l[1];return s?(h=Yn(h,Pe)-1,c=Yn(c,Pe)-1):(h=Xn(h,Pe),c=Xn(c,Pe)),vs(i,h,c,r)}getTileCoordForCoordAndZ(t,e,i){return this.getTileCoordForXYAndZ_(t[0],t[1],e,!1,i)}getTileCoordResolution(t){return this.resolutions_[t[0]]}getTileSize(t){return this.tileSize_?this.tileSize_:this.tileSizes_[t]}getFullTileRange(t){return this.fullTileRanges_?this.fullTileRanges_[t]:this.extent_?this.getTileRangeForExtentAndZ(this.extent_,t):null}getZForResolution(t,e){const i=Ws(this.resolutions_,t,e||0);return lt(i,this.minZoom,this.maxZoom)}tileCoordIntersectsViewport(t,e){return qa(e,0,e.length,2,this.getTileCoordExtent(t))}calculateTileRanges_(t){const e=this.resolutions_.length,i=new Array(e);for(let s=this.minZoom;s<e;++s)i[s]=this.getTileRangeForExtentAndZ(t,s);this.fullTileRanges_=i}}function ih(n){let t=n.getDefaultTileGrid();return t||(t=ug(n),n.setDefaultTileGrid(t)),t}function lg(n,t,e){const i=t[0],s=n.getTileCoordCenter(t),r=ao(e);if(!ui(r,s)){const o=et(r),a=Math.ceil((r[0]-s[0])/o);return s[0]+=o*a,n.getTileCoordForCoordAndZ(s,i)}return t}function hg(n,t,e,i){i=i!==void 0?i:"top-left";const s=nh(n,t,e);return new eh({extent:n,origin:Tc(n,i),resolutions:s,tileSize:e})}function cg(n){const t=n||{},e=t.extent||Dt("EPSG:3857").getExtent(),i={extent:e,minZoom:t.minZoom,tileSize:t.tileSize,resolutions:nh(e,t.maxZoom,t.tileSize,t.maxResolution)};return new eh(i)}function nh(n,t,e,i){t=t!==void 0?t:Wu,e=kt(e!==void 0?e:xr);const s=It(n),r=et(n);i=i>0?i:Math.max(r/e[0],s/e[1]);const o=t+1,a=new Array(o);for(let l=0;l<o;++l)a[l]=i/Math.pow(2,l);return a}function ug(n,t,e,i){const s=ao(n);return hg(s,t,e,i)}function ao(n){n=Dt(n);let t=n.getExtent();if(!t){const e=180*qs.degrees/n.getMetersPerUnit();t=Te(-e,-e,e,e)}return t}const dg=/\{z\}/g,fg=/\{x\}/g,gg=/\{y\}/g,_g=/\{-y\}/g;function mg(n,t,e,i,s){return n.replace(dg,t.toString()).replace(fg,e.toString()).replace(gg,i.toString()).replace(_g,function(){if(s===void 0)throw new Error("If the URL template has a {-y} placeholder, the grid extent must be known");return(s-i).toString()})}function pg(n){const t=[];let e=/\{([a-z])-([a-z])\}/.exec(n);if(e){const i=e[1].charCodeAt(0),s=e[2].charCodeAt(0);let r;for(r=i;r<=s;++r)t.push(n.replace(e[0],String.fromCharCode(r)));return t}if(e=/\{(\d+)-(\d+)\}/.exec(n),e){const i=parseInt(e[2],10);for(let s=parseInt(e[1],10);s<=i;s++)t.push(n.replace(e[0],s.toString()));return t}return t.push(n),t}function yg(n,t){return(function(e,i,s){if(!e)return;let r;const o=e[0];if(t){const a=t.getFullTileRange(o);a&&(r=a.getHeight()-1)}return mg(n,o,e[1],e[2],r)})}function xg(n,t){const e=n.length,i=new Array(e);for(let s=0;s<e;++s)i[s]=yg(n[s],t);return Eg(i)}function Eg(n){return n.length===1?n[0]:(function(t,e,i){if(!t)return;const s=Jf(t),r=ci(s,n.length);return n[r](t,e,i)})}class sh extends ne{constructor(t){super(),this.projection=Dt(t.projection),this.attributions_=rh(t.attributions),this.attributionsCollapsible_=t.attributionsCollapsible??!0,this.loading=!1,this.state_=t.state!==void 0?t.state:"ready",this.wrapX_=t.wrapX!==void 0?t.wrapX:!1,this.interpolate_=!!t.interpolate,this.viewResolver=null,this.viewRejector=null;const e=this;this.viewPromise_=new Promise(function(i,s){e.viewResolver=i,e.viewRejector=s})}getAttributions(){return this.attributions_}getAttributionsCollapsible(){return this.attributionsCollapsible_}getProjection(){return this.projection}getResolutions(t){return null}getView(){return this.viewPromise_}getState(){return this.state_}getWrapX(){return this.wrapX_}getInterpolate(){return this.interpolate_}refresh(){this.changed()}setAttributions(t){this.attributions_=rh(t),this.changed()}setState(t){this.state_=t,this.changed()}}function rh(n){return n?typeof n=="function"?n:(Array.isArray(n)||(n=[n]),t=>n):null}class wg extends sh{constructor(t){super({attributions:t.attributions,attributionsCollapsible:t.attributionsCollapsible,projection:t.projection,state:t.state,wrapX:t.wrapX,interpolate:t.interpolate}),this.on,this.once,this.un,this.tilePixelRatio_=t.tilePixelRatio!==void 0?t.tilePixelRatio:1,this.tileGrid=t.tileGrid!==void 0?t.tileGrid:null;const e=[256,256];this.tileGrid&&kt(this.tileGrid.getTileSize(this.tileGrid.getMinZoom()),e),this.tmpSize=[0,0],this.key_=t.key||q(this),this.tileOptions={transition:t.transition,interpolate:t.interpolate},this.zDirection=t.zDirection?t.zDirection:0}getGutterForProjection(t){return 0}getKey(){return this.key_}setKey(t){this.key_!==t&&(this.key_=t,this.changed())}getResolutions(t){const e=t?this.getTileGridForProjection(t):this.tileGrid;return e?e.getResolutions():null}getTile(t,e,i,s,r){return H()}getTileGrid(){return this.tileGrid}getTileGridForProjection(t){return this.tileGrid?this.tileGrid:ih(t)}getTilePixelRatio(t){return this.tilePixelRatio_}getTilePixelSize(t,e,i){const s=this.getTileGridForProjection(i),r=this.getTilePixelRatio(e),o=kt(s.getTileSize(t),this.tmpSize);return r==1?o:kd(o,r,this.tmpSize)}getTileCoordForTileUrlFunction(t,e){const i=e!==void 0?e:this.getProjection(),s=e!==void 0?this.getTileGridForProjection(i):this.tileGrid||this.getTileGridForProjection(i);return this.getWrapX()&&i.isGlobal()&&(t=lg(s,t,i)),tg(t,s)?t:null}clear(){}refresh(){this.clear(),super.refresh()}}class vg extends ue{constructor(t,e){super(t),this.tile=e}}const lo={TILELOADSTART:"tileloadstart",TILELOADEND:"tileloadend",TILELOADERROR:"tileloaderror"};class ho extends wg{constructor(t){super({attributions:t.attributions,cacheSize:t.cacheSize,projection:t.projection,state:t.state,tileGrid:t.tileGrid,tilePixelRatio:t.tilePixelRatio,wrapX:t.wrapX,transition:t.transition,interpolate:t.interpolate,key:t.key,attributionsCollapsible:t.attributionsCollapsible,zDirection:t.zDirection}),this.generateTileUrlFunction_=this.tileUrlFunction===ho.prototype.tileUrlFunction,this.tileLoadFunction=t.tileLoadFunction,t.tileUrlFunction&&(this.tileUrlFunction=t.tileUrlFunction),this.urls=null,t.urls?this.setUrls(t.urls):t.url&&this.setUrl(t.url),this.tileLoadingKeys_={}}getTileLoadFunction(){return this.tileLoadFunction}getTileUrlFunction(){return Object.getPrototypeOf(this).tileUrlFunction===this.tileUrlFunction?this.tileUrlFunction.bind(this):this.tileUrlFunction}getUrls(){return this.urls}handleTileChange(t){const e=t.target,i=q(e),s=e.getState();let r;s==N.LOADING?(this.tileLoadingKeys_[i]=!0,r=lo.TILELOADSTART):i in this.tileLoadingKeys_&&(delete this.tileLoadingKeys_[i],r=s==N.ERROR?lo.TILELOADERROR:s==N.LOADED?lo.TILELOADEND:void 0),r!=null&&this.dispatchEvent(new vg(r,e))}setTileLoadFunction(t){this.tileLoadFunction=t,this.changed()}setTileUrlFunction(t,e){this.tileUrlFunction=t,typeof e<"u"?this.setKey(e):this.changed()}setUrl(t){const e=pg(t);this.urls=e,this.setUrls(e)}setUrls(t){this.urls=t;const e=t.join(`
|
|
8
|
+
`);this.generateTileUrlFunction_?this.setTileUrlFunction(xg(t,this.tileGrid),e):this.setKey(e)}tileUrlFunction(t,e,i){}}class Cg extends ho{constructor(t){super({attributions:t.attributions,cacheSize:t.cacheSize,projection:t.projection,state:t.state,tileGrid:t.tileGrid,tileLoadFunction:t.tileLoadFunction?t.tileLoadFunction:Rg,tilePixelRatio:t.tilePixelRatio,tileUrlFunction:t.tileUrlFunction,url:t.url,urls:t.urls,wrapX:t.wrapX,transition:t.transition,interpolate:t.interpolate!==void 0?t.interpolate:!0,key:t.key,attributionsCollapsible:t.attributionsCollapsible,zDirection:t.zDirection}),this.crossOrigin=t.crossOrigin!==void 0?t.crossOrigin:null,this.tileClass=t.tileClass!==void 0?t.tileClass:jl,this.tileGridForProjection={},this.reprojectionErrorThreshold_=t.reprojectionErrorThreshold,this.renderReprojectionEdges_=!1}getGutterForProjection(t){return this.getProjection()&&t&&!ar(this.getProjection(),t)?0:this.getGutter()}getGutter(){return 0}getKey(){let t=super.getKey();return this.getInterpolate()||(t+=":disable-interpolation"),t}getTileGridForProjection(t){const e=this.getProjection();if(this.tileGrid&&(!e||ar(e,t)))return this.tileGrid;const i=q(t);return i in this.tileGridForProjection||(this.tileGridForProjection[i]=ih(t)),this.tileGridForProjection[i]}createTile_(t,e,i,s,r,o){const a=[t,e,i],l=this.getTileCoordForTileUrlFunction(a,r),h=l?this.tileUrlFunction(l,s,r):void 0,c=new this.tileClass(a,h!==void 0?N.IDLE:N.EMPTY,h!==void 0?h:"",this.crossOrigin,this.tileLoadFunction,this.tileOptions);return c.key=o,c.addEventListener(B.CHANGE,this.handleTileChange.bind(this)),c}getTile(t,e,i,s,r){const o=this.getProjection();if(!o||!r||ar(o,r))return this.getTileInternal(t,e,i,s,o||r);const a=[t,e,i],l=this.getKey(),h=this.getTileGridForProjection(o),c=this.getTileGridForProjection(r),u=this.getTileCoordForTileUrlFunction(a,r),d=new Hl(o,h,r,c,a,u,this.getTilePixelRatio(s),this.getGutter(),(f,g,m,_)=>this.getTileInternal(f,g,m,_,o),this.reprojectionErrorThreshold_,this.renderReprojectionEdges_,this.tileOptions);return d.key=l,d}getTileInternal(t,e,i,s,r){const o=this.getKey();return this.createTile_(t,e,i,s,r,o)}setRenderReprojectionEdges(t){this.renderReprojectionEdges_!=t&&(this.renderReprojectionEdges_=t,this.changed())}setTileGridForProjection(t,e){const i=Dt(t);if(i){const s=q(i);s in this.tileGridForProjection||(this.tileGridForProjection[s]=e)}}}function Rg(n,t){n.getImage().src=t}class Sg extends Cg{constructor(t){t=t||{};const e=t.projection!==void 0?t.projection:"EPSG:3857",i=t.tileGrid!==void 0?t.tileGrid:cg({extent:ao(e),maxResolution:t.maxResolution,maxZoom:t.maxZoom,minZoom:t.minZoom,tileSize:t.tileSize});super({attributions:t.attributions,cacheSize:t.cacheSize,crossOrigin:t.crossOrigin,interpolate:t.interpolate,projection:e,reprojectionErrorThreshold:t.reprojectionErrorThreshold,tileGrid:i,tileLoadFunction:t.tileLoadFunction,tilePixelRatio:t.tilePixelRatio,tileUrlFunction:t.tileUrlFunction,url:t.url,urls:t.urls,wrapX:t.wrapX!==void 0?t.wrapX:!0,transition:t.transition,attributionsCollapsible:t.attributionsCollapsible,zDirection:t.zDirection}),this.gutter_=t.gutter!==void 0?t.gutter:0}getGutter(){return this.gutter_}}const Ig='© <a href="https://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap</a> contributors.';class Tg extends Sg{constructor(t){t=t||{};let e;t.attributions!==void 0?e=t.attributions:e=[Ig];const i=t.crossOrigin!==void 0?t.crossOrigin:"anonymous",s=t.url!==void 0?t.url:"https://tile.openstreetmap.org/{z}/{x}/{y}.png";super({attributions:e,attributionsCollapsible:!1,cacheSize:t.cacheSize,crossOrigin:i,interpolate:t.interpolate,maxZoom:t.maxZoom!==void 0?t.maxZoom:19,reprojectionErrorThreshold:t.reprojectionErrorThreshold,tileLoadFunction:t.tileLoadFunction,transition:t.transition,url:s,wrapX:t.wrapX,zDirection:t.zDirection})}}class co extends ne{constructor(t){if(super(),this.on,this.once,this.un,this.id_=void 0,this.geometryName_="geometry",this.style_=null,this.styleFunction_=void 0,this.geometryChangeKey_=null,this.addChangeListener(this.geometryName_,this.handleGeometryChanged_),t)if(typeof t.getSimplifiedGeometry=="function"){const e=t;this.setGeometry(e)}else{const e=t;this.setProperties(e)}}clone(){const t=new co(this.hasProperties()?this.getProperties():null);t.setGeometryName(this.getGeometryName());const e=this.getGeometry();e&&t.setGeometry(e.clone());const i=this.getStyle();return i&&t.setStyle(i),t}getGeometry(){return this.get(this.geometryName_)}getId(){return this.id_}getGeometryName(){return this.geometryName_}getStyle(){return this.style_}getStyleFunction(){return this.styleFunction_}handleGeometryChange_(){this.changed()}handleGeometryChanged_(){this.geometryChangeKey_&&(at(this.geometryChangeKey_),this.geometryChangeKey_=null);const t=this.getGeometry();t&&(this.geometryChangeKey_=$(t,B.CHANGE,this.handleGeometryChange_,this)),this.changed()}setGeometry(t){this.set(this.geometryName_,t)}setStyle(t){this.style_=t,this.styleFunction_=t?bg(t):void 0,this.changed()}setId(t){this.id_=t,this.changed()}setGeometryName(t){this.removeChangeListener(this.geometryName_,this.handleGeometryChanged_),this.geometryName_=t,this.addChangeListener(this.geometryName_,this.handleGeometryChanged_),this.handleGeometryChanged_()}}function bg(n){if(typeof n=="function")return n;let t;return Array.isArray(n)?t=n:(Q(typeof n.getZIndex=="function","Expected an `ol/style/Style` or an array of `ol/style/Style.js`"),t=[n]),function(){return t}}function oh(n,t,e,i,s,r,o){let a,l;const h=(e-t)/i;if(h===1)a=t;else if(h===2)a=t,l=s;else if(h!==0){let c=n[t],u=n[t+1],d=0;const f=[0];for(let _=t+i;_<e;_+=i){const p=n[_],y=n[_+1];d+=Math.sqrt((p-c)*(p-c)+(y-u)*(y-u)),f.push(d),c=p,u=y}const g=s*d,m=hc(f,g);m<0?(l=(g-f[-m-2])/(f[-m-1]-f[-m-2]),a=t+(-m-2)*i):a=t+m*i}o=o>1?o:2,r=r||new Array(o);for(let c=0;c<o;++c)r[c]=a===void 0?NaN:l===void 0?n[a+c]:Wt(n[a+c],n[a+i+c],l);return r}function Mg(n,t,e,i){let s=n[t],r=n[t+1],o=0;for(let a=t+i;a<e;a+=i){const l=n[a],h=n[a+1];o+=Math.sqrt((l-s)*(l-s)+(h-r)*(h-r)),s=l,r=h}return o}class ah{drawCustom(t,e,i,s,r){}drawGeometry(t){}setStyle(t){}drawCircle(t,e,i){}drawFeature(t,e,i){}drawGeometryCollection(t,e,i){}drawLineString(t,e,i){}drawMultiLineString(t,e,i){}drawMultiPoint(t,e,i){}drawMultiPolygon(t,e,i){}drawPoint(t,e,i){}drawPolygon(t,e,i){}drawText(t,e,i){}setFillStrokeStyle(t,e){}setImageStyle(t,e){}setTextStyle(t,e){}}class Lg extends ah{constructor(t,e,i,s,r,o,a){super(),this.context_=t,this.pixelRatio_=e,this.extent_=i,this.transform_=s,this.transformRotation_=s?Wn(Math.atan2(s[1],s[0]),10):0,this.viewRotation_=r,this.squaredTolerance_=o,this.userTransform_=a,this.contextFillState_=null,this.contextStrokeState_=null,this.contextTextState_=null,this.fillState_=null,this.strokeState_=null,this.image_=null,this.imageAnchorX_=0,this.imageAnchorY_=0,this.imageHeight_=0,this.imageOpacity_=0,this.imageOriginX_=0,this.imageOriginY_=0,this.imageRotateWithView_=!1,this.imageRotation_=0,this.imageScale_=[0,0],this.imageWidth_=0,this.text_="",this.textOffsetX_=0,this.textOffsetY_=0,this.textRotateWithView_=!1,this.textRotation_=0,this.textScale_=[0,0],this.textFillState_=null,this.textStrokeState_=null,this.textState_=null,this.pixelCoordinates_=[],this.tmpLocalTransform_=qt()}drawImages_(t,e,i,s){if(!this.image_)return;const r=Me(t,e,i,s,this.transform_,this.pixelCoordinates_),o=this.context_,a=this.tmpLocalTransform_,l=o.globalAlpha;this.imageOpacity_!=1&&(o.globalAlpha=l*this.imageOpacity_);let h=this.imageRotation_;this.transformRotation_===0&&(h-=this.viewRotation_),this.imageRotateWithView_&&(h+=this.viewRotation_);for(let c=0,u=r.length;c<u;c+=2){const d=r[c]-this.imageAnchorX_,f=r[c+1]-this.imageAnchorY_;if(h!==0||this.imageScale_[0]!=1||this.imageScale_[1]!=1){const g=d+this.imageAnchorX_,m=f+this.imageAnchorY_;fe(a,g,m,1,1,h,-g,-m),o.save(),o.transform.apply(o,a),o.translate(g,m),o.scale(this.imageScale_[0],this.imageScale_[1]),o.drawImage(this.image_,this.imageOriginX_,this.imageOriginY_,this.imageWidth_,this.imageHeight_,-this.imageAnchorX_,-this.imageAnchorY_,this.imageWidth_,this.imageHeight_),o.restore()}else o.drawImage(this.image_,this.imageOriginX_,this.imageOriginY_,this.imageWidth_,this.imageHeight_,d,f,this.imageWidth_,this.imageHeight_)}this.imageOpacity_!=1&&(o.globalAlpha=l)}drawText_(t,e,i,s){if(!this.textState_||this.text_==="")return;this.textFillState_&&this.setContextFillState_(this.textFillState_),this.textStrokeState_&&this.setContextStrokeState_(this.textStrokeState_),this.setContextTextState_(this.textState_);const r=Me(t,e,i,s,this.transform_,this.pixelCoordinates_),o=this.context_;let a=this.textRotation_;for(this.transformRotation_===0&&(a-=this.viewRotation_),this.textRotateWithView_&&(a+=this.viewRotation_);e<i;e+=s){const l=r[e]+this.textOffsetX_,h=r[e+1]+this.textOffsetY_;a!==0||this.textScale_[0]!=1||this.textScale_[1]!=1?(o.save(),o.translate(l-this.textOffsetX_,h-this.textOffsetY_),o.rotate(a),o.translate(this.textOffsetX_,this.textOffsetY_),o.scale(this.textScale_[0],this.textScale_[1]),this.textStrokeState_&&o.strokeText(this.text_,0,0),this.textFillState_&&o.fillText(this.text_,0,0),o.restore()):(this.textStrokeState_&&o.strokeText(this.text_,l,h),this.textFillState_&&o.fillText(this.text_,l,h))}}moveToLineTo_(t,e,i,s,r){const o=this.context_,a=Me(t,e,i,s,this.transform_,this.pixelCoordinates_);o.moveTo(a[0],a[1]);let l=a.length;r&&(l-=2);for(let h=2;h<l;h+=2)o.lineTo(a[h],a[h+1]);return r&&o.closePath(),i}drawRings_(t,e,i,s){for(let r=0,o=i.length;r<o;++r)e=this.moveToLineTo_(t,e,i[r],s,!0);return e}drawCircle(t){if(this.squaredTolerance_&&(t=t.simplifyTransformed(this.squaredTolerance_,this.userTransform_)),!!Pt(this.extent_,t.getExtent())){if(this.fillState_||this.strokeState_){this.fillState_&&this.setContextFillState_(this.fillState_),this.strokeState_&&this.setContextStrokeState_(this.strokeState_);const e=wu(t,this.transform_,this.pixelCoordinates_),i=e[2]-e[0],s=e[3]-e[1],r=Math.sqrt(i*i+s*s),o=this.context_;o.beginPath(),o.arc(e[0],e[1],r,0,2*Math.PI),this.fillState_&&o.fill(),this.strokeState_&&o.stroke()}this.text_!==""&&this.drawText_(t.getCenter(),0,2,2)}}setStyle(t){this.setFillStrokeStyle(t.getFill(),t.getStroke()),this.setImageStyle(t.getImage()),this.setTextStyle(t.getText())}setTransform(t){this.transform_=t}drawGeometry(t){switch(t.getType()){case"Point":this.drawPoint(t);break;case"LineString":this.drawLineString(t);break;case"Polygon":this.drawPolygon(t);break;case"MultiPoint":this.drawMultiPoint(t);break;case"MultiLineString":this.drawMultiLineString(t);break;case"MultiPolygon":this.drawMultiPolygon(t);break;case"GeometryCollection":this.drawGeometryCollection(t);break;case"Circle":this.drawCircle(t);break}}drawFeature(t,e){const i=e.getGeometryFunction()(t);i&&(this.setStyle(e),this.drawGeometry(i))}drawGeometryCollection(t){const e=t.getGeometriesArray();for(let i=0,s=e.length;i<s;++i)this.drawGeometry(e[i])}drawPoint(t){this.squaredTolerance_&&(t=t.simplifyTransformed(this.squaredTolerance_,this.userTransform_));const e=t.getFlatCoordinates(),i=t.getStride();this.image_&&this.drawImages_(e,0,e.length,i),this.text_!==""&&this.drawText_(e,0,e.length,i)}drawMultiPoint(t){this.squaredTolerance_&&(t=t.simplifyTransformed(this.squaredTolerance_,this.userTransform_));const e=t.getFlatCoordinates(),i=t.getStride();this.image_&&this.drawImages_(e,0,e.length,i),this.text_!==""&&this.drawText_(e,0,e.length,i)}drawLineString(t){if(this.squaredTolerance_&&(t=t.simplifyTransformed(this.squaredTolerance_,this.userTransform_)),!!Pt(this.extent_,t.getExtent())){if(this.strokeState_){this.setContextStrokeState_(this.strokeState_);const e=this.context_,i=t.getFlatCoordinates();e.beginPath(),this.moveToLineTo_(i,0,i.length,t.getStride(),!1),e.stroke()}if(this.text_!==""){const e=t.getFlatMidpoint();this.drawText_(e,0,2,2)}}}drawMultiLineString(t){this.squaredTolerance_&&(t=t.simplifyTransformed(this.squaredTolerance_,this.userTransform_));const e=t.getExtent();if(Pt(this.extent_,e)){if(this.strokeState_){this.setContextStrokeState_(this.strokeState_);const i=this.context_,s=t.getFlatCoordinates();let r=0;const o=t.getEnds(),a=t.getStride();i.beginPath();for(let l=0,h=o.length;l<h;++l)r=this.moveToLineTo_(s,r,o[l],a,!1);i.stroke()}if(this.text_!==""){const i=t.getFlatMidpoints();this.drawText_(i,0,i.length,2)}}}drawPolygon(t){if(this.squaredTolerance_&&(t=t.simplifyTransformed(this.squaredTolerance_,this.userTransform_)),!!Pt(this.extent_,t.getExtent())){if(this.strokeState_||this.fillState_){this.fillState_&&this.setContextFillState_(this.fillState_),this.strokeState_&&this.setContextStrokeState_(this.strokeState_);const e=this.context_;e.beginPath(),this.drawRings_(t.getOrientedFlatCoordinates(),0,t.getEnds(),t.getStride()),this.fillState_&&e.fill(),this.strokeState_&&e.stroke()}if(this.text_!==""){const e=t.getFlatInteriorPoint();this.drawText_(e,0,2,2)}}}drawMultiPolygon(t){if(this.squaredTolerance_&&(t=t.simplifyTransformed(this.squaredTolerance_,this.userTransform_)),!!Pt(this.extent_,t.getExtent())){if(this.strokeState_||this.fillState_){this.fillState_&&this.setContextFillState_(this.fillState_),this.strokeState_&&this.setContextStrokeState_(this.strokeState_);const e=this.context_,i=t.getOrientedFlatCoordinates();let s=0;const r=t.getEndss(),o=t.getStride();e.beginPath();for(let a=0,l=r.length;a<l;++a){const h=r[a];s=this.drawRings_(i,s,h,o)}this.fillState_&&e.fill(),this.strokeState_&&e.stroke()}if(this.text_!==""){const e=t.getFlatInteriorPoints();this.drawText_(e,0,e.length,2)}}}setContextFillState_(t){const e=this.context_,i=this.contextFillState_;i?i.fillStyle!=t.fillStyle&&(i.fillStyle=t.fillStyle,e.fillStyle=t.fillStyle):(e.fillStyle=t.fillStyle,this.contextFillState_={fillStyle:t.fillStyle})}setContextStrokeState_(t){const e=this.context_,i=this.contextStrokeState_;i?(i.lineCap!=t.lineCap&&(i.lineCap=t.lineCap,e.lineCap=t.lineCap),Ce(i.lineDash,t.lineDash)||e.setLineDash(i.lineDash=t.lineDash),i.lineDashOffset!=t.lineDashOffset&&(i.lineDashOffset=t.lineDashOffset,e.lineDashOffset=t.lineDashOffset),i.lineJoin!=t.lineJoin&&(i.lineJoin=t.lineJoin,e.lineJoin=t.lineJoin),i.lineWidth!=t.lineWidth&&(i.lineWidth=t.lineWidth,e.lineWidth=t.lineWidth),i.miterLimit!=t.miterLimit&&(i.miterLimit=t.miterLimit,e.miterLimit=t.miterLimit),i.strokeStyle!=t.strokeStyle&&(i.strokeStyle=t.strokeStyle,e.strokeStyle=t.strokeStyle)):(e.lineCap=t.lineCap,e.setLineDash(t.lineDash),e.lineDashOffset=t.lineDashOffset,e.lineJoin=t.lineJoin,e.lineWidth=t.lineWidth,e.miterLimit=t.miterLimit,e.strokeStyle=t.strokeStyle,this.contextStrokeState_={lineCap:t.lineCap,lineDash:t.lineDash,lineDashOffset:t.lineDashOffset,lineJoin:t.lineJoin,lineWidth:t.lineWidth,miterLimit:t.miterLimit,strokeStyle:t.strokeStyle})}setContextTextState_(t){const e=this.context_,i=this.contextTextState_,s=t.textAlign?t.textAlign:_n;i?(i.font!=t.font&&(i.font=t.font,e.font=t.font),i.textAlign!=s&&(i.textAlign=s,e.textAlign=s),i.textBaseline!=t.textBaseline&&(i.textBaseline=t.textBaseline,e.textBaseline=t.textBaseline)):(e.font=t.font,e.textAlign=s,e.textBaseline=t.textBaseline,this.contextTextState_={font:t.font,textAlign:s,textBaseline:t.textBaseline})}setFillStrokeStyle(t,e){if(!t)this.fillState_=null;else{const i=t.getColor();this.fillState_={fillStyle:oe(i||Nt)}}if(!e)this.strokeState_=null;else{const i=e.getColor(),s=e.getLineCap(),r=e.getLineDash(),o=e.getLineDashOffset(),a=e.getLineJoin(),l=e.getWidth(),h=e.getMiterLimit(),c=r||_e;this.strokeState_={lineCap:s!==void 0?s:Ri,lineDash:this.pixelRatio_===1?c:c.map(u=>u*this.pixelRatio_),lineDashOffset:(o||me)*this.pixelRatio_,lineJoin:a!==void 0?a:Si,lineWidth:(l!==void 0?l:mn)*this.pixelRatio_,miterLimit:h!==void 0?h:fn,strokeStyle:oe(i||gn)}}}setImageStyle(t){let e;if(!t||!(e=t.getSize())){this.image_=null;return}const i=t.getPixelRatio(this.pixelRatio_),s=t.getAnchor(),r=t.getOrigin();this.image_=t.getImage(this.pixelRatio_),this.imageAnchorX_=s[0]*i,this.imageAnchorY_=s[1]*i,this.imageHeight_=e[1]*i,this.imageOpacity_=t.getOpacity(),this.imageOriginX_=r[0],this.imageOriginY_=r[1],this.imageRotateWithView_=t.getRotateWithView(),this.imageRotation_=t.getRotation();const o=t.getScaleArray();this.imageScale_=[o[0]*this.pixelRatio_/i,o[1]*this.pixelRatio_/i],this.imageWidth_=e[0]*i}setTextStyle(t){if(!t)this.text_="";else{const e=t.getFill();if(!e)this.textFillState_=null;else{const f=e.getColor();this.textFillState_={fillStyle:oe(f||Nt)}}const i=t.getStroke();if(!i)this.textStrokeState_=null;else{const f=i.getColor(),g=i.getLineCap(),m=i.getLineDash(),_=i.getLineDashOffset(),p=i.getLineJoin(),y=i.getWidth(),v=i.getMiterLimit();this.textStrokeState_={lineCap:g!==void 0?g:Ri,lineDash:m||_e,lineDashOffset:_||me,lineJoin:p!==void 0?p:Si,lineWidth:y!==void 0?y:mn,miterLimit:v!==void 0?v:fn,strokeStyle:oe(f||gn)}}const s=t.getFont(),r=t.getOffsetX(),o=t.getOffsetY(),a=t.getRotateWithView(),l=t.getRotation(),h=t.getScaleArray(),c=t.getText(),u=t.getTextAlign(),d=t.getTextBaseline();this.textState_={font:s!==void 0?s:Rl,textAlign:u!==void 0?u:_n,textBaseline:d!==void 0?d:fs},this.text_=c!==void 0?Array.isArray(c)?c.reduce((f,g,m)=>f+=m%2?" ":g,""):c:"",this.textOffsetX_=r!==void 0?this.pixelRatio_*r:0,this.textOffsetY_=o!==void 0?this.pixelRatio_*o:0,this.textRotateWithView_=a!==void 0?a:!1,this.textRotation_=l!==void 0?l:0,this.textScale_=[this.pixelRatio_*h[0],this.pixelRatio_*h[1]]}}}const Ag=.5,lh={Point:Gg,LineString:Fg,Polygon:Xg,MultiPoint:Wg,MultiLineString:Ng,MultiPolygon:zg,GeometryCollection:kg,Circle:Pg};function Og(n,t){return parseInt(q(n),10)-parseInt(q(t),10)}function hh(n,t){const e=ch(n,t);return e*e}function ch(n,t){return Ag*n/t}function Pg(n,t,e,i,s){const r=e.getFill(),o=e.getStroke();if(r||o){const l=n.getBuilder(e.getZIndex(),"Circle");l.setFillStrokeStyle(r,o),l.drawCircle(t,i,s)}const a=e.getText();if(a&&a.getText()){const l=n.getBuilder(e.getZIndex(),"Text");l.setTextStyle(a),l.drawText(t,i)}}function uh(n,t,e,i,s,r,o,a){const l=[],h=e.getImage();if(h){let d=!0;const f=h.getImageState();f==K.LOADED||f==K.ERROR?d=!1:f==K.IDLE&&h.load(),d&&l.push(h.ready())}const c=e.getFill();c&&c.loading()&&l.push(c.ready());const u=l.length>0;return u&&Promise.all(l).then(()=>s(null)),Dg(n,t,e,i,r,o,a),u}function Dg(n,t,e,i,s,r,o){const a=e.getGeometryFunction()(t);if(!a)return;const l=a.simplifyTransformed(i,s);if(e.getRenderer())dh(n,l,e,t,o);else{const c=lh[l.getType()];c(n,l,e,t,o,r)}}function dh(n,t,e,i,s){if(t.getType()=="GeometryCollection"){const o=t.getGeometries();for(let a=0,l=o.length;a<l;++a)dh(n,o[a],e,i,s);return}n.getBuilder(e.getZIndex(),"Default").drawCustom(t,i,e.getRenderer(),e.getHitDetectionRenderer(),s)}function kg(n,t,e,i,s,r){const o=t.getGeometriesArray();let a,l;for(a=0,l=o.length;a<l;++a){const h=lh[o[a].getType()];h(n,o[a],e,i,s,r)}}function Fg(n,t,e,i,s){const r=e.getStroke();if(r){const a=n.getBuilder(e.getZIndex(),"LineString");a.setFillStrokeStyle(null,r),a.drawLineString(t,i,s)}const o=e.getText();if(o&&o.getText()){const a=n.getBuilder(e.getZIndex(),"Text");a.setTextStyle(o),a.drawText(t,i,s)}}function Ng(n,t,e,i,s){const r=e.getStroke();if(r){const a=n.getBuilder(e.getZIndex(),"LineString");a.setFillStrokeStyle(null,r),a.drawMultiLineString(t,i,s)}const o=e.getText();if(o&&o.getText()){const a=n.getBuilder(e.getZIndex(),"Text");a.setTextStyle(o),a.drawText(t,i,s)}}function zg(n,t,e,i,s){const r=e.getFill(),o=e.getStroke();if(o||r){const l=n.getBuilder(e.getZIndex(),"Polygon");l.setFillStrokeStyle(r,o),l.drawMultiPolygon(t,i,s)}const a=e.getText();if(a&&a.getText()){const l=n.getBuilder(e.getZIndex(),"Text");l.setTextStyle(a),l.drawText(t,i,s)}}function Gg(n,t,e,i,s,r){const o=e.getImage(),a=e.getText(),l=a&&a.getText(),h=r&&o&&l?{}:void 0;if(o){if(o.getImageState()!=K.LOADED)return;const c=n.getBuilder(e.getZIndex(),"Image");c.setImageStyle(o,h),c.drawPoint(t,i,s)}if(l){const c=n.getBuilder(e.getZIndex(),"Text");c.setTextStyle(a,h),c.drawText(t,i,s)}}function Wg(n,t,e,i,s,r){const o=e.getImage(),a=o&&o.getOpacity()!==0,l=e.getText(),h=l&&l.getText(),c=r&&a&&h?{}:void 0;if(a){if(o.getImageState()!=K.LOADED)return;const u=n.getBuilder(e.getZIndex(),"Image");u.setImageStyle(o,c),u.drawMultiPoint(t,i,s)}if(h){const u=n.getBuilder(e.getZIndex(),"Text");u.setTextStyle(l,c),u.drawText(t,i,s)}}function Xg(n,t,e,i,s){const r=e.getFill(),o=e.getStroke();if(r||o){const l=n.getBuilder(e.getZIndex(),"Polygon");l.setFillStrokeStyle(r,o),l.drawPolygon(t,i,s)}const a=e.getText();if(a&&a.getText()){const l=n.getBuilder(e.getZIndex(),"Text");l.setTextStyle(a),l.drawText(t,i,s)}}let Yg=!1;function Bg(n,t,e,i,s,r,o){const a=new XMLHttpRequest;a.open("GET",typeof n=="function"?n(e,i,s):n,!0),t.getType()=="arraybuffer"&&(a.responseType="arraybuffer"),a.withCredentials=Yg,a.onload=function(l){if(!a.status||a.status>=200&&a.status<300){const h=t.getType();try{let c;h=="text"||h=="json"?c=a.responseText:h=="xml"?c=a.responseXML||a.responseText:h=="arraybuffer"&&(c=a.response),c?r(t.readFeatures(c,{extent:e,featureProjection:s}),t.readProjection(c)):o()}catch{o()}}else o()},a.onerror=o,a.send()}function fh(n,t){return function(e,i,s,r,o){Bg(n,t,e,i,s,(a,l)=>{this.addFeatures(a),r!==void 0&&r(a)},()=>{this.changed(),o!==void 0&&o()})}}function Ug(n,t){return[[-1/0,-1/0,1/0,1/0]]}function Kg(n,t,e,i){const s=[];let r=Xt();for(let o=0,a=e.length;o<a;++o){const l=e[o];r=Vs(n,t,l[0],i),s.push((r[0]+r[2])/2,(r[1]+r[3])/2),t=l[l.length-1]}return s}const gh=qt();class te{constructor(t,e,i,s,r,o){this.styleFunction,this.extent_,this.id_=o,this.type_=t,this.flatCoordinates_=e,this.flatInteriorPoints_=null,this.flatMidpoints_=null,this.ends_=i||null,this.properties_=r,this.squaredTolerance_,this.stride_=s,this.simplifiedGeometry_}get(t){return this.properties_[t]}getExtent(){return this.extent_||(this.extent_=this.type_==="Point"?ua(this.flatCoordinates_):Vs(this.flatCoordinates_,0,this.flatCoordinates_.length,2)),this.extent_}getFlatInteriorPoint(){if(!this.flatInteriorPoints_){const t=Be(this.getExtent());this.flatInteriorPoints_=gr(this.flatCoordinates_,0,this.ends_,2,t,0)}return this.flatInteriorPoints_}getFlatInteriorPoints(){if(!this.flatInteriorPoints_){const t=ku(this.flatCoordinates_,this.ends_),e=Kg(this.flatCoordinates_,0,t,2);this.flatInteriorPoints_=Lu(this.flatCoordinates_,0,t,2,e)}return this.flatInteriorPoints_}getFlatMidpoint(){return this.flatMidpoints_||(this.flatMidpoints_=oh(this.flatCoordinates_,0,this.flatCoordinates_.length,2,.5)),this.flatMidpoints_}getFlatMidpoints(){if(!this.flatMidpoints_){this.flatMidpoints_=[];const t=this.flatCoordinates_;let e=0;const i=this.ends_;for(let s=0,r=i.length;s<r;++s){const o=i[s],a=oh(t,e,o,2,.5);Xs(this.flatMidpoints_,a),e=o}}return this.flatMidpoints_}getId(){return this.id_}getOrientedFlatCoordinates(){return this.flatCoordinates_}getGeometry(){return this}getSimplifiedGeometry(t){return this}simplifyTransformed(t,e){return this}getProperties(){return this.properties_}getPropertiesInternal(){return this.properties_}getStride(){return this.stride_}getStyleFunction(){return this.styleFunction}getType(){return this.type_}transform(t){t=Dt(t);const e=t.getExtent(),i=t.getWorldExtent();if(e&&i){const s=It(i)/It(e);fe(gh,i[0],i[3],s,-s,0,0,0),Me(this.flatCoordinates_,0,this.flatCoordinates_.length,2,gh,this.flatCoordinates_)}}applyTransform(t){t(this.flatCoordinates_,this.flatCoordinates_,this.stride_)}clone(){return new te(this.type_,this.flatCoordinates_.slice(),this.ends_?.slice(),this.stride_,Object.assign({},this.properties_),this.id_)}getEnds(){return this.ends_}enableSimplifyTransformed(){return this.simplifyTransformed=Qo((t,e)=>{if(t===this.squaredTolerance_)return this.simplifiedGeometry_;this.simplifiedGeometry_=this.clone(),e&&this.simplifiedGeometry_.applyTransform(e);const i=this.simplifiedGeometry_.getFlatCoordinates();let s;switch(this.type_){case"LineString":i.length=fr(i,0,this.simplifiedGeometry_.flatCoordinates_.length,this.simplifiedGeometry_.stride_,t,i,0),s=[i.length];break;case"MultiLineString":s=[],i.length=Tu(i,0,this.simplifiedGeometry_.ends_,this.simplifiedGeometry_.stride_,t,i,0,s);break;case"Polygon":s=[],i.length=Za(i,0,this.simplifiedGeometry_.ends_,this.simplifiedGeometry_.stride_,Math.sqrt(t),i,0,s);break}return s&&(this.simplifiedGeometry_=new te(this.type_,i,s,2,this.properties_,this.id_)),this.squaredTolerance_=t,this.simplifiedGeometry_}),this}}te.prototype.getFlatCoordinates=te.prototype.getOrientedFlatCoordinates;class _h{constructor(t){this.rbush_=new dl(t),this.items_={}}insert(t,e){const i={minX:t[0],minY:t[1],maxX:t[2],maxY:t[3],value:e};this.rbush_.insert(i),this.items_[q(e)]=i}load(t,e){const i=new Array(e.length);for(let s=0,r=e.length;s<r;s++){const o=t[s],a=e[s],l={minX:o[0],minY:o[1],maxX:o[2],maxY:o[3],value:a};i[s]=l,this.items_[q(a)]=l}this.rbush_.load(i)}remove(t){const e=q(t),i=this.items_[e];return delete this.items_[e],this.rbush_.remove(i)!==null}update(t,e){const i=this.items_[q(e)],s=[i.minX,i.minY,i.maxX,i.maxY];Vi(s,t)||(this.remove(e),this.insert(t,e))}getAll(){return this.rbush_.all().map(function(e){return e.value})}getInExtent(t){const e={minX:t[0],minY:t[1],maxX:t[2],maxY:t[3]};return this.rbush_.search(e).map(function(s){return s.value})}forEach(t){return this.forEach_(this.getAll(),t)}forEachInExtent(t,e){return this.forEach_(this.getInExtent(t),e)}forEach_(t,e){let i;for(let s=0,r=t.length;s<r;s++)if(i=e(t[s]),i)return i;return i}isEmpty(){return ai(this.items_)}clear(){this.rbush_.clear(),this.items_={}}getExtent(t){const e=this.rbush_.toJSON();return Te(e.minX,e.minY,e.maxX,e.maxY,t)}concat(t){this.rbush_.load(t.rbush_.all());for(const e in t.items_)this.items_[e]=t.items_[e]}}const Kt={ADDFEATURE:"addfeature",CHANGEFEATURE:"changefeature",CLEAR:"clear",REMOVEFEATURE:"removefeature",FEATURESLOADSTART:"featuresloadstart",FEATURESLOADEND:"featuresloadend",FEATURESLOADERROR:"featuresloaderror"};class De extends ue{constructor(t,e,i){super(t),this.feature=e,this.features=i}}class jg extends sh{constructor(t){t=t||{},super({attributions:t.attributions,interpolate:!0,projection:void 0,state:"ready",wrapX:t.wrapX!==void 0?t.wrapX:!0}),this.on,this.once,this.un,this.loader_=Bi,this.format_=t.format||null,this.overlaps_=t.overlaps===void 0?!0:t.overlaps,this.url_=t.url,t.loader!==void 0?this.loader_=t.loader:this.url_!==void 0&&(Q(this.format_,"`format` must be set when `url` is set"),this.loader_=fh(this.url_,this.format_)),this.strategy_=t.strategy!==void 0?t.strategy:Ug;const e=t.useSpatialIndex!==void 0?t.useSpatialIndex:!0;this.featuresRtree_=e?new _h:null,this.loadedExtentsRtree_=new _h,this.loadingExtentsCount_=0,this.nullGeometryFeatures_={},this.idIndex_={},this.uidIndex_={},this.featureChangeKeys_={},this.featuresCollection_=null;let i,s;Array.isArray(t.features)?s=t.features:t.features&&(i=t.features,s=i.getArray()),!e&&i===void 0&&(i=new se(s)),s!==void 0&&this.addFeaturesInternal(s),i!==void 0&&this.bindFeaturesCollection_(i)}addFeature(t){this.addFeatureInternal(t),this.changed()}addFeatureInternal(t){const e=q(t);if(!this.addToIndex_(e,t)){this.featuresCollection_&&this.featuresCollection_.remove(t);return}this.setupChangeEvents_(e,t);const i=t.getGeometry();if(i){const s=i.getExtent();this.featuresRtree_&&this.featuresRtree_.insert(s,t)}else this.nullGeometryFeatures_[e]=t;this.dispatchEvent(new De(Kt.ADDFEATURE,t))}setupChangeEvents_(t,e){e instanceof te||(this.featureChangeKeys_[t]=[$(e,B.CHANGE,this.handleFeatureChange_,this),$(e,oi.PROPERTYCHANGE,this.handleFeatureChange_,this)])}addToIndex_(t,e){let i=!0;if(e.getId()!==void 0){const s=String(e.getId());if(!(s in this.idIndex_))this.idIndex_[s]=e;else if(e instanceof te){const r=this.idIndex_[s];r instanceof te?Array.isArray(r)?r.push(e):this.idIndex_[s]=[r,e]:i=!1}else i=!1}return i&&(Q(!(t in this.uidIndex_),"The passed `feature` was already added to the source"),this.uidIndex_[t]=e),i}addFeatures(t){this.addFeaturesInternal(t),this.changed()}addFeaturesInternal(t){const e=[],i=[],s=[];for(let r=0,o=t.length;r<o;r++){const a=t[r],l=q(a);this.addToIndex_(l,a)&&i.push(a)}for(let r=0,o=i.length;r<o;r++){const a=i[r],l=q(a);this.setupChangeEvents_(l,a);const h=a.getGeometry();if(h){const c=h.getExtent();e.push(c),s.push(a)}else this.nullGeometryFeatures_[l]=a}if(this.featuresRtree_&&this.featuresRtree_.load(e,s),this.hasListener(Kt.ADDFEATURE))for(let r=0,o=i.length;r<o;r++)this.dispatchEvent(new De(Kt.ADDFEATURE,i[r]))}bindFeaturesCollection_(t){let e=!1;this.addEventListener(Kt.ADDFEATURE,function(i){e||(e=!0,t.push(i.feature),e=!1)}),this.addEventListener(Kt.REMOVEFEATURE,function(i){e||(e=!0,t.remove(i.feature),e=!1)}),t.addEventListener(Ot.ADD,i=>{e||(e=!0,this.addFeature(i.element),e=!1)}),t.addEventListener(Ot.REMOVE,i=>{e||(e=!0,this.removeFeature(i.element),e=!1)}),this.featuresCollection_=t}clear(t){if(t){for(const i in this.featureChangeKeys_)this.featureChangeKeys_[i].forEach(at);this.featuresCollection_||(this.featureChangeKeys_={},this.idIndex_={},this.uidIndex_={})}else if(this.featuresRtree_){this.featuresRtree_.forEach(i=>{this.removeFeatureInternal(i)});for(const i in this.nullGeometryFeatures_)this.removeFeatureInternal(this.nullGeometryFeatures_[i])}this.featuresCollection_&&this.featuresCollection_.clear(),this.featuresRtree_&&this.featuresRtree_.clear(),this.nullGeometryFeatures_={};const e=new De(Kt.CLEAR);this.dispatchEvent(e),this.changed()}forEachFeature(t){if(this.featuresRtree_)return this.featuresRtree_.forEach(t);this.featuresCollection_&&this.featuresCollection_.forEach(t)}forEachFeatureAtCoordinateDirect(t,e){const i=[t[0],t[1],t[0],t[1]];return this.forEachFeatureInExtent(i,function(s){const r=s.getGeometry();if(r instanceof te||r.intersectsCoordinate(t))return e(s)})}forEachFeatureInExtent(t,e){if(this.featuresRtree_)return this.featuresRtree_.forEachInExtent(t,e);this.featuresCollection_&&this.featuresCollection_.forEach(e)}forEachFeatureIntersectingExtent(t,e){return this.forEachFeatureInExtent(t,function(i){const s=i.getGeometry();if(s instanceof te||s.intersectsExtent(t)){const r=e(i);if(r)return r}})}getFeaturesCollection(){return this.featuresCollection_}getFeatures(){let t;return this.featuresCollection_?t=this.featuresCollection_.getArray().slice(0):this.featuresRtree_&&(t=this.featuresRtree_.getAll(),ai(this.nullGeometryFeatures_)||Xs(t,Object.values(this.nullGeometryFeatures_))),t}getFeaturesAtCoordinate(t){const e=[];return this.forEachFeatureAtCoordinateDirect(t,function(i){e.push(i)}),e}getFeaturesInExtent(t,e){if(this.featuresRtree_){if(!(e&&e.canWrapX()&&this.getWrapX()))return this.featuresRtree_.getInExtent(t);const s=ma(t,e);return[].concat(...s.map(r=>this.featuresRtree_.getInExtent(r)))}return this.featuresCollection_?this.featuresCollection_.getArray().slice(0):[]}getClosestFeatureToCoordinate(t,e){const i=t[0],s=t[1];let r=null;const o=[NaN,NaN];let a=1/0;const l=[-1/0,-1/0,1/0,1/0];return e=e||Yi,this.featuresRtree_.forEachInExtent(l,function(h){if(e(h)){const c=h.getGeometry(),u=a;if(a=c instanceof te?0:c.closestPointXY(i,s,o,a),a<u){r=h;const d=Math.sqrt(a);l[0]=i-d,l[1]=s-d,l[2]=i+d,l[3]=s+d}}}),r}getExtent(t){return this.featuresRtree_.getExtent(t)}getFeatureById(t){const e=this.idIndex_[t.toString()];return e!==void 0?e:null}getFeatureByUid(t){const e=this.uidIndex_[t];return e!==void 0?e:null}getFormat(){return this.format_}getOverlaps(){return this.overlaps_}getUrl(){return this.url_}handleFeatureChange_(t){const e=t.target,i=q(e),s=e.getGeometry();if(!s)i in this.nullGeometryFeatures_||(this.featuresRtree_&&this.featuresRtree_.remove(e),this.nullGeometryFeatures_[i]=e);else{const o=s.getExtent();i in this.nullGeometryFeatures_?(delete this.nullGeometryFeatures_[i],this.featuresRtree_&&this.featuresRtree_.insert(o,e)):this.featuresRtree_&&this.featuresRtree_.update(o,e)}const r=e.getId();if(r!==void 0){const o=r.toString();this.idIndex_[o]!==e&&(this.removeFromIdIndex_(e),this.idIndex_[o]=e)}else this.removeFromIdIndex_(e),this.uidIndex_[i]=e;this.changed(),this.dispatchEvent(new De(Kt.CHANGEFEATURE,e))}hasFeature(t){const e=t.getId();return e!==void 0?e in this.idIndex_:q(t)in this.uidIndex_}isEmpty(){return this.featuresRtree_?this.featuresRtree_.isEmpty()&&ai(this.nullGeometryFeatures_):this.featuresCollection_?this.featuresCollection_.getLength()===0:!0}loadFeatures(t,e,i){const s=this.loadedExtentsRtree_,r=this.strategy_(t,e,i);for(let o=0,a=r.length;o<a;++o){const l=r[o];s.forEachInExtent(l,function(c){return ji(c.extent,l)})||(++this.loadingExtentsCount_,this.dispatchEvent(new De(Kt.FEATURESLOADSTART)),this.loader_.call(this,l,e,i,c=>{--this.loadingExtentsCount_,this.dispatchEvent(new De(Kt.FEATURESLOADEND,void 0,c))},()=>{--this.loadingExtentsCount_,this.dispatchEvent(new De(Kt.FEATURESLOADERROR))}),s.insert(l,{extent:l.slice()}))}this.loading=this.loader_.length<4?!1:this.loadingExtentsCount_>0}refresh(){this.clear(!0),this.loadedExtentsRtree_.clear(),super.refresh()}removeLoadedExtent(t){const e=this.loadedExtentsRtree_,i=e.forEachInExtent(t,function(s){if(Vi(s.extent,t))return s});i&&e.remove(i)}removeFeatures(t){let e=!1;for(let i=0,s=t.length;i<s;++i)e=this.removeFeatureInternal(t[i])||e;e&&this.changed()}removeFeature(t){if(!t)return;this.removeFeatureInternal(t)&&this.changed()}removeFeatureInternal(t){const e=q(t);if(!(e in this.uidIndex_))return!1;e in this.nullGeometryFeatures_?delete this.nullGeometryFeatures_[e]:this.featuresRtree_&&this.featuresRtree_.remove(t),this.featureChangeKeys_[e]?.forEach(at),delete this.featureChangeKeys_[e];const s=t.getId();if(s!==void 0){const r=s.toString(),o=this.idIndex_[r];o===t?delete this.idIndex_[r]:Array.isArray(o)&&(o.splice(o.indexOf(t),1),o.length===1&&(this.idIndex_[r]=o[0]))}return delete this.uidIndex_[e],this.hasListener(Kt.REMOVEFEATURE)&&this.dispatchEvent(new De(Kt.REMOVEFEATURE,t)),!0}removeFromIdIndex_(t){for(const e in this.idIndex_)if(this.idIndex_[e]===t){delete this.idIndex_[e];break}}setLoader(t){this.loader_=t}setUrl(t){Q(this.format_,"`format` must be set when `url` is set"),this.url_=t,this.setLoader(fh(t,this.format_))}setOverlaps(t){this.overlaps_=t,this.changed()}}const F={BEGIN_GEOMETRY:0,BEGIN_PATH:1,CIRCLE:2,CLOSE_PATH:3,CUSTOM:4,DRAW_CHARS:5,DRAW_IMAGE:6,END_GEOMETRY:7,FILL:8,MOVE_TO_LINE_TO:9,SET_FILL_STYLE:10,SET_STROKE_STYLE:11,STROKE:12},Rs=[F.FILL],ke=[F.STROKE],ti=[F.BEGIN_PATH],mh=[F.CLOSE_PATH];class Cn extends ah{constructor(t,e,i,s){super(),this.tolerance=t,this.maxExtent=e,this.pixelRatio=s,this.maxLineWidth=0,this.resolution=i,this.beginGeometryInstruction1_=null,this.beginGeometryInstruction2_=null,this.bufferedMaxExtent_=null,this.instructions=[],this.coordinates=[],this.tmpCoordinate_=[],this.hitDetectionInstructions=[],this.state={}}applyPixelRatio(t){const e=this.pixelRatio;return e==1?t:t.map(function(i){return i*e})}appendFlatPointCoordinates(t,e){const i=this.getBufferedMaxExtent(),s=this.tmpCoordinate_,r=this.coordinates;let o=r.length;for(let a=0,l=t.length;a<l;a+=e)s[0]=t[a],s[1]=t[a+1],ui(i,s)&&(r[o++]=s[0],r[o++]=s[1]);return o}appendFlatLineCoordinates(t,e,i,s,r,o){const a=this.coordinates;let l=a.length;const h=this.getBufferedMaxExtent();o&&(e+=s);let c=t[e],u=t[e+1];const d=this.tmpCoordinate_;let f=!0,g,m,_;for(g=e+s;g<i;g+=s)d[0]=t[g],d[1]=t[g+1],_=js(h,d),_!==m?(f&&(a[l++]=c,a[l++]=u,f=!1),a[l++]=d[0],a[l++]=d[1]):_===pt.INTERSECTING?(a[l++]=d[0],a[l++]=d[1],f=!1):f=!0,c=d[0],u=d[1],m=_;return(r&&f||g===e+s)&&(a[l++]=c,a[l++]=u),l}drawCustomCoordinates_(t,e,i,s,r){for(let o=0,a=i.length;o<a;++o){const l=i[o],h=this.appendFlatLineCoordinates(t,e,l,s,!1,!1);r.push(h),e=l}return e}drawCustom(t,e,i,s,r){this.beginGeometry(t,e,r);const o=t.getType(),a=t.getStride(),l=this.coordinates.length;let h,c,u,d,f;switch(o){case"MultiPolygon":h=t.getOrientedFlatCoordinates(),d=[];const g=t.getEndss();f=0;for(let m=0,_=g.length;m<_;++m){const p=[];f=this.drawCustomCoordinates_(h,f,g[m],a,p),d.push(p)}this.instructions.push([F.CUSTOM,l,d,t,i,Va,r]),this.hitDetectionInstructions.push([F.CUSTOM,l,d,t,s||i,Va,r]);break;case"Polygon":case"MultiLineString":u=[],h=o=="Polygon"?t.getOrientedFlatCoordinates():t.getFlatCoordinates(),f=this.drawCustomCoordinates_(h,0,t.getEnds(),a,u),this.instructions.push([F.CUSTOM,l,u,t,i,es,r]),this.hitDetectionInstructions.push([F.CUSTOM,l,u,t,s||i,es,r]);break;case"LineString":case"Circle":h=t.getFlatCoordinates(),c=this.appendFlatLineCoordinates(h,0,h.length,a,!1,!1),this.instructions.push([F.CUSTOM,l,c,t,i,pi,r]),this.hitDetectionInstructions.push([F.CUSTOM,l,c,t,s||i,pi,r]);break;case"MultiPoint":h=t.getFlatCoordinates(),c=this.appendFlatPointCoordinates(h,a),c>l&&(this.instructions.push([F.CUSTOM,l,c,t,i,pi,r]),this.hitDetectionInstructions.push([F.CUSTOM,l,c,t,s||i,pi,r]));break;case"Point":h=t.getFlatCoordinates(),this.coordinates.push(h[0],h[1]),c=this.coordinates.length,this.instructions.push([F.CUSTOM,l,c,t,i,void 0,r]),this.hitDetectionInstructions.push([F.CUSTOM,l,c,t,s||i,void 0,r]);break}this.endGeometry(e)}beginGeometry(t,e,i){this.beginGeometryInstruction1_=[F.BEGIN_GEOMETRY,e,0,t,i],this.instructions.push(this.beginGeometryInstruction1_),this.beginGeometryInstruction2_=[F.BEGIN_GEOMETRY,e,0,t,i],this.hitDetectionInstructions.push(this.beginGeometryInstruction2_)}finish(){return{instructions:this.instructions,hitDetectionInstructions:this.hitDetectionInstructions,coordinates:this.coordinates}}reverseHitDetectionInstructions(){const t=this.hitDetectionInstructions;t.reverse();let e;const i=t.length;let s,r,o=-1;for(e=0;e<i;++e)s=t[e],r=s[0],r==F.END_GEOMETRY?o=e:r==F.BEGIN_GEOMETRY&&(s[2]=e,uc(this.hitDetectionInstructions,o,e),o=-1)}fillStyleToState(t,e={}){if(t){const i=t.getColor();e.fillPatternScale=i&&typeof i=="object"&&"src"in i?this.pixelRatio:1,e.fillStyle=oe(i||Nt)}else e.fillStyle=void 0;return e}strokeStyleToState(t,e={}){if(t){const i=t.getColor();e.strokeStyle=oe(i||gn);const s=t.getLineCap();e.lineCap=s!==void 0?s:Ri;const r=t.getLineDash();e.lineDash=r?r.slice():_e;const o=t.getLineDashOffset();e.lineDashOffset=o||me;const a=t.getLineJoin();e.lineJoin=a!==void 0?a:Si;const l=t.getWidth();e.lineWidth=l!==void 0?l:mn;const h=t.getMiterLimit();e.miterLimit=h!==void 0?h:fn,e.lineWidth>this.maxLineWidth&&(this.maxLineWidth=e.lineWidth,this.bufferedMaxExtent_=null)}else e.strokeStyle=void 0,e.lineCap=void 0,e.lineDash=null,e.lineDashOffset=void 0,e.lineJoin=void 0,e.lineWidth=void 0,e.miterLimit=void 0;return e}setFillStrokeStyle(t,e){const i=this.state;this.fillStyleToState(t,i),this.strokeStyleToState(e,i)}createFill(t){const e=t.fillStyle,i=[F.SET_FILL_STYLE,e];return typeof e!="string"&&i.push(t.fillPatternScale),i}applyStroke(t){this.instructions.push(this.createStroke(t))}createStroke(t){return[F.SET_STROKE_STYLE,t.strokeStyle,t.lineWidth*this.pixelRatio,t.lineCap,t.lineJoin,t.miterLimit,t.lineDash?this.applyPixelRatio(t.lineDash):null,t.lineDashOffset*this.pixelRatio]}updateFillStyle(t,e){const i=t.fillStyle;(typeof i!="string"||t.currentFillStyle!=i)&&(this.instructions.push(e.call(this,t)),t.currentFillStyle=i)}updateStrokeStyle(t,e){const i=t.strokeStyle,s=t.lineCap,r=t.lineDash,o=t.lineDashOffset,a=t.lineJoin,l=t.lineWidth,h=t.miterLimit;(t.currentStrokeStyle!=i||t.currentLineCap!=s||r!=t.currentLineDash&&!Ce(t.currentLineDash,r)||t.currentLineDashOffset!=o||t.currentLineJoin!=a||t.currentLineWidth!=l||t.currentMiterLimit!=h)&&(e.call(this,t),t.currentStrokeStyle=i,t.currentLineCap=s,t.currentLineDash=r,t.currentLineDashOffset=o,t.currentLineJoin=a,t.currentLineWidth=l,t.currentMiterLimit=h)}endGeometry(t){this.beginGeometryInstruction1_[2]=this.instructions.length,this.beginGeometryInstruction1_=null,this.beginGeometryInstruction2_[2]=this.hitDetectionInstructions.length,this.beginGeometryInstruction2_=null;const e=[F.END_GEOMETRY,t];this.instructions.push(e),this.hitDetectionInstructions.push(e)}getBufferedMaxExtent(){if(!this.bufferedMaxExtent_&&(this.bufferedMaxExtent_=la(this.maxExtent),this.maxLineWidth>0)){const t=this.resolution*(this.maxLineWidth+1)/2;Ks(this.bufferedMaxExtent_,t,this.bufferedMaxExtent_)}return this.bufferedMaxExtent_}}class Vg extends Cn{constructor(t,e,i,s){super(t,e,i,s),this.hitDetectionImage_=null,this.image_=null,this.imagePixelRatio_=void 0,this.anchorX_=void 0,this.anchorY_=void 0,this.height_=void 0,this.opacity_=void 0,this.originX_=void 0,this.originY_=void 0,this.rotateWithView_=void 0,this.rotation_=void 0,this.scale_=void 0,this.width_=void 0,this.declutterMode_=void 0,this.declutterImageWithText_=void 0}drawPoint(t,e,i){if(!this.image_||this.maxExtent&&!ui(this.maxExtent,t.getFlatCoordinates()))return;this.beginGeometry(t,e,i);const s=t.getFlatCoordinates(),r=t.getStride(),o=this.coordinates.length,a=this.appendFlatPointCoordinates(s,r);this.instructions.push([F.DRAW_IMAGE,o,a,this.image_,this.anchorX_*this.imagePixelRatio_,this.anchorY_*this.imagePixelRatio_,Math.ceil(this.height_*this.imagePixelRatio_),this.opacity_,this.originX_*this.imagePixelRatio_,this.originY_*this.imagePixelRatio_,this.rotateWithView_,this.rotation_,[this.scale_[0]*this.pixelRatio/this.imagePixelRatio_,this.scale_[1]*this.pixelRatio/this.imagePixelRatio_],Math.ceil(this.width_*this.imagePixelRatio_),this.declutterMode_,this.declutterImageWithText_]),this.hitDetectionInstructions.push([F.DRAW_IMAGE,o,a,this.hitDetectionImage_,this.anchorX_,this.anchorY_,this.height_,1,this.originX_,this.originY_,this.rotateWithView_,this.rotation_,this.scale_,this.width_,this.declutterMode_,this.declutterImageWithText_]),this.endGeometry(e)}drawMultiPoint(t,e,i){if(!this.image_)return;this.beginGeometry(t,e,i);const s=t.getFlatCoordinates(),r=[];for(let l=0,h=s.length;l<h;l+=t.getStride())(!this.maxExtent||ui(this.maxExtent,s.slice(l,l+2)))&&r.push(s[l],s[l+1]);const o=this.coordinates.length,a=this.appendFlatPointCoordinates(r,2);this.instructions.push([F.DRAW_IMAGE,o,a,this.image_,this.anchorX_*this.imagePixelRatio_,this.anchorY_*this.imagePixelRatio_,Math.ceil(this.height_*this.imagePixelRatio_),this.opacity_,this.originX_*this.imagePixelRatio_,this.originY_*this.imagePixelRatio_,this.rotateWithView_,this.rotation_,[this.scale_[0]*this.pixelRatio/this.imagePixelRatio_,this.scale_[1]*this.pixelRatio/this.imagePixelRatio_],Math.ceil(this.width_*this.imagePixelRatio_),this.declutterMode_,this.declutterImageWithText_]),this.hitDetectionInstructions.push([F.DRAW_IMAGE,o,a,this.hitDetectionImage_,this.anchorX_,this.anchorY_,this.height_,1,this.originX_,this.originY_,this.rotateWithView_,this.rotation_,this.scale_,this.width_,this.declutterMode_,this.declutterImageWithText_]),this.endGeometry(e)}finish(){return this.reverseHitDetectionInstructions(),this.anchorX_=void 0,this.anchorY_=void 0,this.hitDetectionImage_=null,this.image_=null,this.imagePixelRatio_=void 0,this.height_=void 0,this.scale_=void 0,this.opacity_=void 0,this.originX_=void 0,this.originY_=void 0,this.rotateWithView_=void 0,this.rotation_=void 0,this.width_=void 0,super.finish()}setImageStyle(t,e){const i=t.getAnchor(),s=t.getSize(),r=t.getOrigin();this.imagePixelRatio_=t.getPixelRatio(this.pixelRatio),this.anchorX_=i[0],this.anchorY_=i[1],this.hitDetectionImage_=t.getHitDetectionImage(),this.image_=t.getImage(this.pixelRatio),this.height_=s[1],this.opacity_=t.getOpacity(),this.originX_=r[0],this.originY_=r[1],this.rotateWithView_=t.getRotateWithView(),this.rotation_=t.getRotation(),this.scale_=t.getScaleArray(),this.width_=s[0],this.declutterMode_=t.getDeclutterMode(),this.declutterImageWithText_=e}}class Zg extends Cn{constructor(t,e,i,s){super(t,e,i,s)}drawFlatCoordinates_(t,e,i,s){const r=this.coordinates.length,o=this.appendFlatLineCoordinates(t,e,i,s,!1,!1),a=[F.MOVE_TO_LINE_TO,r,o];return this.instructions.push(a),this.hitDetectionInstructions.push(a),i}drawLineString(t,e,i){const s=this.state,r=s.strokeStyle,o=s.lineWidth;if(r===void 0||o===void 0)return;this.updateStrokeStyle(s,this.applyStroke),this.beginGeometry(t,e,i),this.hitDetectionInstructions.push([F.SET_STROKE_STYLE,s.strokeStyle,s.lineWidth,s.lineCap,s.lineJoin,s.miterLimit,_e,me],ti);const a=t.getFlatCoordinates(),l=t.getStride();this.drawFlatCoordinates_(a,0,a.length,l),this.hitDetectionInstructions.push(ke),this.endGeometry(e)}drawMultiLineString(t,e,i){const s=this.state,r=s.strokeStyle,o=s.lineWidth;if(r===void 0||o===void 0)return;this.updateStrokeStyle(s,this.applyStroke),this.beginGeometry(t,e,i),this.hitDetectionInstructions.push([F.SET_STROKE_STYLE,s.strokeStyle,s.lineWidth,s.lineCap,s.lineJoin,s.miterLimit,_e,me],ti);const a=t.getEnds(),l=t.getFlatCoordinates(),h=t.getStride();let c=0;for(let u=0,d=a.length;u<d;++u)c=this.drawFlatCoordinates_(l,c,a[u],h);this.hitDetectionInstructions.push(ke),this.endGeometry(e)}finish(){const t=this.state;return t.lastStroke!=null&&t.lastStroke!=this.coordinates.length&&this.instructions.push(ke),this.reverseHitDetectionInstructions(),this.state=null,super.finish()}applyStroke(t){t.lastStroke!=null&&t.lastStroke!=this.coordinates.length&&(this.instructions.push(ke),t.lastStroke=this.coordinates.length),t.lastStroke=0,super.applyStroke(t),this.instructions.push(ti)}}class ph extends Cn{constructor(t,e,i,s){super(t,e,i,s)}drawFlatCoordinatess_(t,e,i,s){const r=this.state,o=r.fillStyle!==void 0,a=r.strokeStyle!==void 0,l=i.length;this.instructions.push(ti),this.hitDetectionInstructions.push(ti);for(let h=0;h<l;++h){const c=i[h],u=this.coordinates.length,d=this.appendFlatLineCoordinates(t,e,c,s,!0,!a),f=[F.MOVE_TO_LINE_TO,u,d];this.instructions.push(f),this.hitDetectionInstructions.push(f),a&&(this.instructions.push(mh),this.hitDetectionInstructions.push(mh)),e=c}return o&&(this.instructions.push(Rs),this.hitDetectionInstructions.push(Rs)),a&&(this.instructions.push(ke),this.hitDetectionInstructions.push(ke)),e}drawCircle(t,e,i){const s=this.state,r=s.fillStyle,o=s.strokeStyle;if(r===void 0&&o===void 0)return;this.setFillStrokeStyles_(),this.beginGeometry(t,e,i),s.fillStyle!==void 0&&this.hitDetectionInstructions.push([F.SET_FILL_STYLE,Nt]),s.strokeStyle!==void 0&&this.hitDetectionInstructions.push([F.SET_STROKE_STYLE,s.strokeStyle,s.lineWidth,s.lineCap,s.lineJoin,s.miterLimit,_e,me]);const a=t.getFlatCoordinates(),l=t.getStride(),h=this.coordinates.length;this.appendFlatLineCoordinates(a,0,a.length,l,!1,!1);const c=[F.CIRCLE,h];this.instructions.push(ti,c),this.hitDetectionInstructions.push(ti,c),s.fillStyle!==void 0&&(this.instructions.push(Rs),this.hitDetectionInstructions.push(Rs)),s.strokeStyle!==void 0&&(this.instructions.push(ke),this.hitDetectionInstructions.push(ke)),this.endGeometry(e)}drawPolygon(t,e,i){const s=this.state,r=s.fillStyle,o=s.strokeStyle;if(r===void 0&&o===void 0)return;this.setFillStrokeStyles_(),this.beginGeometry(t,e,i),s.fillStyle!==void 0&&this.hitDetectionInstructions.push([F.SET_FILL_STYLE,Nt]),s.strokeStyle!==void 0&&this.hitDetectionInstructions.push([F.SET_STROKE_STYLE,s.strokeStyle,s.lineWidth,s.lineCap,s.lineJoin,s.miterLimit,_e,me]);const a=t.getEnds(),l=t.getOrientedFlatCoordinates(),h=t.getStride();this.drawFlatCoordinatess_(l,0,a,h),this.endGeometry(e)}drawMultiPolygon(t,e,i){const s=this.state,r=s.fillStyle,o=s.strokeStyle;if(r===void 0&&o===void 0)return;this.setFillStrokeStyles_(),this.beginGeometry(t,e,i),s.fillStyle!==void 0&&this.hitDetectionInstructions.push([F.SET_FILL_STYLE,Nt]),s.strokeStyle!==void 0&&this.hitDetectionInstructions.push([F.SET_STROKE_STYLE,s.strokeStyle,s.lineWidth,s.lineCap,s.lineJoin,s.miterLimit,_e,me]);const a=t.getEndss(),l=t.getOrientedFlatCoordinates(),h=t.getStride();let c=0;for(let u=0,d=a.length;u<d;++u)c=this.drawFlatCoordinatess_(l,c,a[u],h);this.endGeometry(e)}finish(){this.reverseHitDetectionInstructions(),this.state=null;const t=this.tolerance;if(t!==0){const e=this.coordinates;for(let i=0,s=e.length;i<s;++i)e[i]=Ze(e[i],t)}return super.finish()}setFillStrokeStyles_(){const t=this.state;this.updateFillStyle(t,this.createFill),this.updateStrokeStyle(t,this.applyStroke)}}function $g(n,t,e,i,s){const r=[];let o=e,a=0,l=t.slice(e,2);for(;a<n&&o+s<i;){const[h,c]=l.slice(-2),u=t[o+s],d=t[o+s+1],f=Math.sqrt((u-h)*(u-h)+(d-c)*(d-c));if(a+=f,a>=n){const g=(n-a+f)/f,m=Wt(h,u,g),_=Wt(c,d,g);l.push(m,_),r.push(l),l=[m,_],a==n&&(o+=s),a=0}else if(a<n)l.push(t[o+s],t[o+s+1]),o+=s;else{const g=f-a,m=Wt(h,u,g/f),_=Wt(c,d,g/f);l.push(m,_),r.push(l),l=[m,_],a=0,o+=s}}return a>0&&r.push(l),r}function Hg(n,t,e,i,s){let r=e,o=e,a=0,l=0,h=e,c,u,d,f,g,m,_,p,y,v;for(u=e;u<i;u+=s){const x=t[u],w=t[u+1];g!==void 0&&(y=x-g,v=w-m,f=Math.sqrt(y*y+v*v),_!==void 0&&(l+=d,c=Math.acos((_*y+p*v)/(d*f)),c>n&&(l>a&&(a=l,r=h,o=u),l=0,h=u-s)),d=f,_=y,p=v),g=x,m=w}return l+=f,l>a?[h,u]:[r,o]}const Ss={left:0,center:.5,right:1,top:0,middle:.5,hanging:.2,alphabetic:.8,ideographic:.8,bottom:1};class qg extends Cn{constructor(t,e,i,s){super(t,e,i,s),this.labels_=null,this.text_="",this.textOffsetX_=0,this.textOffsetY_=0,this.textRotateWithView_=void 0,this.textKeepUpright_=void 0,this.textRotation_=0,this.textFillState_=null,this.fillStates={},this.fillStates[Nt]={fillStyle:Nt},this.textStrokeState_=null,this.strokeStates={},this.textState_={},this.textStates={},this.textKey_="",this.fillKey_="",this.strokeKey_="",this.declutterMode_=void 0,this.declutterImageWithText_=void 0}finish(){const t=super.finish();return t.textStates=this.textStates,t.fillStates=this.fillStates,t.strokeStates=this.strokeStates,t}drawText(t,e,i){const s=this.textFillState_,r=this.textStrokeState_,o=this.textState_;if(this.text_===""||!o||!s&&!r)return;const a=this.coordinates;let l=a.length;const h=t.getType();let c=null,u=t.getStride();if(o.placement==="line"&&(h=="LineString"||h=="MultiLineString"||h=="Polygon"||h=="MultiPolygon")){if(!Pt(this.maxExtent,t.getExtent()))return;let d;if(c=t.getFlatCoordinates(),h=="LineString")d=[c.length];else if(h=="MultiLineString")d=t.getEnds();else if(h=="Polygon")d=t.getEnds().slice(0,1);else if(h=="MultiPolygon"){const _=t.getEndss();d=[];for(let p=0,y=_.length;p<y;++p)d.push(_[p][0])}this.beginGeometry(t,e,i);const f=o.repeat,g=f?void 0:o.textAlign;let m=0;for(let _=0,p=d.length;_<p;++_){let y;f?y=$g(f*this.resolution,c,m,d[_],u):y=[c.slice(m,d[_])];for(let v=0,x=y.length;v<x;++v){const w=y[v];let R=0,T=w.length;if(g==null){const I=Hg(o.maxAngle,w,0,w.length,2);R=I[0],T=I[1]}for(let I=R;I<T;I+=u)a.push(w[I],w[I+1]);const S=a.length;m=d[_],this.drawChars_(l,S),l=S}}this.endGeometry(e)}else{let d=o.overflow?null:[];switch(h){case"Point":case"MultiPoint":c=t.getFlatCoordinates();break;case"LineString":c=t.getFlatMidpoint();break;case"Circle":c=t.getCenter();break;case"MultiLineString":c=t.getFlatMidpoints(),u=2;break;case"Polygon":c=t.getFlatInteriorPoint(),o.overflow||d.push(c[2]/this.resolution),u=3;break;case"MultiPolygon":const x=t.getFlatInteriorPoints();c=[];for(let w=0,R=x.length;w<R;w+=3)o.overflow||d.push(x[w+2]/this.resolution),c.push(x[w],x[w+1]);if(c.length===0)return;u=2;break}const f=this.appendFlatPointCoordinates(c,u);if(f===l)return;if(d&&(f-l)/2!==c.length/u){let x=l/2;d=d.filter((w,R)=>{const T=a[(x+R)*2]===c[R*u]&&a[(x+R)*2+1]===c[R*u+1];return T||--x,T})}this.saveTextStates_();const g=o.backgroundFill?this.createFill(this.fillStyleToState(o.backgroundFill)):null,m=o.backgroundStroke?this.createStroke(this.strokeStyleToState(o.backgroundStroke)):null;this.beginGeometry(t,e,i);let _=o.padding;if(_!=Qe&&(o.scale[0]<0||o.scale[1]<0)){let x=o.padding[0],w=o.padding[1],R=o.padding[2],T=o.padding[3];o.scale[0]<0&&(w=-w,T=-T),o.scale[1]<0&&(x=-x,R=-R),_=[x,w,R,T]}const p=this.pixelRatio;this.instructions.push([F.DRAW_IMAGE,l,f,null,NaN,NaN,NaN,1,0,0,this.textRotateWithView_,this.textRotation_,[1,1],NaN,this.declutterMode_,this.declutterImageWithText_,_==Qe?Qe:_.map(function(x){return x*p}),g,m,this.text_,this.textKey_,this.strokeKey_,this.fillKey_,this.textOffsetX_,this.textOffsetY_,d]);const y=1/p,v=g?g.slice(0):null;v&&(v[1]=Nt),this.hitDetectionInstructions.push([F.DRAW_IMAGE,l,f,null,NaN,NaN,NaN,1,0,0,this.textRotateWithView_,this.textRotation_,[y,y],NaN,this.declutterMode_,this.declutterImageWithText_,_,v,m,this.text_,this.textKey_,this.strokeKey_,this.fillKey_?Nt:this.fillKey_,this.textOffsetX_,this.textOffsetY_,d]),this.endGeometry(e)}}saveTextStates_(){const t=this.textStrokeState_,e=this.textState_,i=this.textFillState_,s=this.strokeKey_;t&&(s in this.strokeStates||(this.strokeStates[s]={strokeStyle:t.strokeStyle,lineCap:t.lineCap,lineDashOffset:t.lineDashOffset,lineWidth:t.lineWidth,lineJoin:t.lineJoin,miterLimit:t.miterLimit,lineDash:t.lineDash}));const r=this.textKey_;r in this.textStates||(this.textStates[r]={font:e.font,textAlign:e.textAlign||_n,justify:e.justify,textBaseline:e.textBaseline||fs,scale:e.scale});const o=this.fillKey_;i&&(o in this.fillStates||(this.fillStates[o]={fillStyle:i.fillStyle}))}drawChars_(t,e){const i=this.textStrokeState_,s=this.textState_,r=this.strokeKey_,o=this.textKey_,a=this.fillKey_;this.saveTextStates_();const l=this.pixelRatio,h=Ss[s.textBaseline],c=this.textOffsetY_*l,u=this.text_,d=i?i.lineWidth*Math.abs(s.scale[0])/2:0;this.instructions.push([F.DRAW_CHARS,t,e,h,s.overflow,a,s.maxAngle,l,c,r,d*l,u,o,1,this.declutterMode_,this.textKeepUpright_]),this.hitDetectionInstructions.push([F.DRAW_CHARS,t,e,h,s.overflow,a&&Nt,s.maxAngle,l,c,r,d*l,u,o,1/l,this.declutterMode_,this.textKeepUpright_])}setTextStyle(t,e){let i,s,r;if(!t)this.text_="";else{const o=t.getFill();o?(s=this.textFillState_,s||(s={},this.textFillState_=s),s.fillStyle=oe(o.getColor()||Nt)):(s=null,this.textFillState_=s);const a=t.getStroke();if(!a)r=null,this.textStrokeState_=r;else{r=this.textStrokeState_,r||(r={},this.textStrokeState_=r);const m=a.getLineDash(),_=a.getLineDashOffset(),p=a.getWidth(),y=a.getMiterLimit();r.lineCap=a.getLineCap()||Ri,r.lineDash=m?m.slice():_e,r.lineDashOffset=_===void 0?me:_,r.lineJoin=a.getLineJoin()||Si,r.lineWidth=p===void 0?mn:p,r.miterLimit=y===void 0?fn:y,r.strokeStyle=oe(a.getColor()||gn)}i=this.textState_;const l=t.getFont()||Rl;gf(l);const h=t.getScaleArray();i.overflow=t.getOverflow(),i.font=l,i.maxAngle=t.getMaxAngle(),i.placement=t.getPlacement(),i.textAlign=t.getTextAlign(),i.repeat=t.getRepeat(),i.justify=t.getJustify(),i.textBaseline=t.getTextBaseline()||fs,i.backgroundFill=t.getBackgroundFill(),i.backgroundStroke=t.getBackgroundStroke(),i.padding=t.getPadding()||Qe,i.scale=h===void 0?[1,1]:h;const c=t.getOffsetX(),u=t.getOffsetY(),d=t.getRotateWithView(),f=t.getKeepUpright(),g=t.getRotation();this.text_=t.getText()||"",this.textOffsetX_=c===void 0?0:c,this.textOffsetY_=u===void 0?0:u,this.textRotateWithView_=d===void 0?!1:d,this.textKeepUpright_=f===void 0?!0:f,this.textRotation_=g===void 0?0:g,this.strokeKey_=r?(typeof r.strokeStyle=="string"?r.strokeStyle:q(r.strokeStyle))+r.lineCap+r.lineDashOffset+"|"+r.lineWidth+r.lineJoin+r.miterLimit+"["+r.lineDash.join()+"]":"",this.textKey_=i.font+i.scale+(i.textAlign||"?")+(i.repeat||"?")+(i.justify||"?")+(i.textBaseline||"?"),this.fillKey_=s&&s.fillStyle?typeof s.fillStyle=="string"?s.fillStyle:"|"+q(s.fillStyle):""}this.declutterMode_=t.getDeclutterMode(),this.declutterImageWithText_=e}}const Jg={Circle:ph,Default:Cn,Image:Vg,LineString:Zg,Polygon:ph,Text:qg};class Qg{constructor(t,e,i,s){this.tolerance_=t,this.maxExtent_=e,this.pixelRatio_=s,this.resolution_=i,this.buildersByZIndex_={}}finish(){const t={};for(const e in this.buildersByZIndex_){t[e]=t[e]||{};const i=this.buildersByZIndex_[e];for(const s in i){const r=i[s].finish();t[e][s]=r}}return t}getBuilder(t,e){const i=t!==void 0?t.toString():"0";let s=this.buildersByZIndex_[i];s===void 0&&(s={},this.buildersByZIndex_[i]=s);let r=s[e];if(r===void 0){const o=Jg[e];r=new o(this.tolerance_,this.maxExtent_,this.resolution_,this.pixelRatio_),s[e]=r}return r}}function t_(n,t,e,i,s,r,o,a,l,h,c,u,d=!0){let f=n[t],g=n[t+1],m=0,_=0,p=0,y=0;function v(){m=f,_=g,t+=i,f=n[t],g=n[t+1],y+=p,p=Math.sqrt((f-m)*(f-m)+(g-_)*(g-_))}do v();while(t<e-i&&y+p<r);let x=p===0?0:(r-y)/p;const w=Wt(m,f,x),R=Wt(_,g,x),T=t-i,S=y,I=r+a*l(h,s,c);for(;t<e-i&&y+p<I;)v();x=p===0?0:(I-y)/p;const M=Wt(m,f,x),O=Wt(_,g,x);let L=!1;if(d)if(u){const G=[w,R,M,O];Ga(G,0,4,2,u,G,G),L=G[0]>G[2]}else L=w>M;const A=Math.PI,P=[],X=T+i===t;t=T,p=0,y=S,f=n[t],g=n[t+1];let k;if(X){v(),k=Math.atan2(g-_,f-m),L&&(k+=k>0?-A:A);const G=(M+w)/2,D=(O+R)/2;return P[0]=[G,D,(I-r)/2,k,s],P}s=s.replace(/\n/g," ");for(let G=0,D=s.length;G<D;){v();let Y=Math.atan2(g-_,f-m);if(L&&(Y+=Y>0?-A:A),k!==void 0){let ht=Y-k;if(ht+=ht>A?-2*A:ht<-A?2*A:0,Math.abs(ht)>o)return null}k=Y;const V=G;let tt=0;for(;G<D;++G){const ht=L?D-G-1:G,bt=a*l(h,s[ht],c);if(t+i<e&&y+p<r+tt+bt/2)break;tt+=bt}if(G===V)continue;const b=L?s.substring(D-V,D-G):s.substring(V,G);x=p===0?0:(r+tt/2-y)/p;const xt=Wt(m,f,x),ft=Wt(_,g,x);P.push([xt,ft,tt/2,Y,b]),r+=tt}return P}const Oi=Xt(),Fe=[],ye=[],xe=[],Ne=[];function yh(n){return n[3].declutterBox}const xh=new RegExp("[֑-ࣿיִ-﷿ﹰ-ﻼࠀ--]");function uo(n,t){return t==="start"?t=xh.test(n)?"right":"left":t==="end"&&(t=xh.test(n)?"left":"right"),Ss[t]}function e_(n,t,e){return e>0&&n.push(`
|
|
9
|
+
`,""),n.push(t,""),n}function i_(n,t,e){return e%2===0&&(n+=t),n}class n_{constructor(t,e,i,s,r){this.overlaps=i,this.pixelRatio=e,this.resolution=t,this.alignAndScaleFill_,this.instructions=s.instructions,this.coordinates=s.coordinates,this.coordinateCache_={},this.renderedTransform_=qt(),this.hitDetectionInstructions=s.hitDetectionInstructions,this.pixelCoordinates_=null,this.viewRotation_=0,this.fillStates=s.fillStates||{},this.strokeStates=s.strokeStates||{},this.textStates=s.textStates||{},this.widths_={},this.labels_={},this.zIndexContext_=r?new ql:null}getZIndexContext(){return this.zIndexContext_}createLabel(t,e,i,s){const r=t+e+i+s;if(this.labels_[r])return this.labels_[r];const o=s?this.strokeStates[s]:null,a=i?this.fillStates[i]:null,l=this.textStates[e],h=this.pixelRatio,c=[l.scale[0]*h,l.scale[1]*h],u=l.justify?Ss[l.justify]:uo(Array.isArray(t)?t[0]:t,l.textAlign||_n),d=s&&o.lineWidth?o.lineWidth:0,f=Array.isArray(t)?t:String(t).split(`
|
|
9
10
|
`).reduce(e_,[]),{width:g,height:m,widths:_,heights:p,lineWidths:y}=mf(l,f),v=g+d,x=[],w=(v+2)*c[0],R=(m+d)*c[1],T={width:w<0?Math.floor(w):Math.ceil(w),height:R<0?Math.floor(R):Math.ceil(R),contextInstructions:x};(c[0]!=1||c[1]!=1)&&x.push("scale",c),s&&(x.push("strokeStyle",o.strokeStyle),x.push("lineWidth",d),x.push("lineCap",o.lineCap),x.push("lineJoin",o.lineJoin),x.push("miterLimit",o.miterLimit),x.push("setLineDash",[o.lineDash]),x.push("lineDashOffset",o.lineDashOffset)),i&&x.push("fillStyle",a.fillStyle),x.push("textBaseline","middle"),x.push("textAlign","center");const S=.5-u;let I=u*v+S*d;const M=[],O=[];let L=0,A=0,P=0,X=0,k;for(let G=0,D=f.length;G<D;G+=2){const Y=f[G];if(Y===`
|
|
10
|
-
`){A+=L,L=0,I=u*v+S*d,++X;continue}const V=f[G+1]||l.font;V!==k&&(s&&M.push("font",V),i&&O.push("font",V),k=V),L=Math.max(L,p[P]);const tt=[Y,I+S*_[P]+u*(_[P]-y[X]),.5*(d+L)+A];I+=_[P],s&&M.push("strokeText",tt),i&&O.push("fillText",tt),++P}return Array.prototype.push.apply(x,M),Array.prototype.push.apply(x,O),this.labels_[r]=T,T}replayTextBackground_(t,e,i,s,r,o,a){t.beginPath(),t.moveTo.apply(t,e),t.lineTo.apply(t,i),t.lineTo.apply(t,s),t.lineTo.apply(t,r),t.lineTo.apply(t,e),o&&(this.alignAndScaleFill_=o[2],t.fillStyle=o[1],this.fill_(t)),a&&(this.setStrokeStyle_(t,a),t.stroke())}calculateImageOrLabelDimensions_(t,e,i,s,r,o,a,l,h,c,u,d,f,g,m,_){a*=d[0],l*=d[1];let p=i-a,y=s-l;const v=r+h>t?t-h:r,x=o+c>e?e-c:o,w=g[3]+v*d[0]+g[1],R=g[0]+x*d[1]+g[2],T=p-g[3],S=y-g[0];(m||u!==0)&&(Fe[0]=T,Ne[0]=T,Fe[1]=S,ye[1]=S,ye[0]=T+w,xe[0]=ye[0],xe[1]=S+R,Ne[1]=xe[1]);let I;return u!==0?(I=fe(qt(),i,s,1,1,u,-i,-s),yt(I,Fe),yt(I,ye),yt(I,xe),yt(I,Ne),Te(Math.min(Fe[0],ye[0],xe[0],Ne[0]),Math.min(Fe[1],ye[1],xe[1],Ne[1]),Math.max(Fe[0],ye[0],xe[0],Ne[0]),Math.max(Fe[1],ye[1],xe[1],Ne[1]),Ai)):Te(Math.min(T,T+w),Math.min(S,S+R),Math.max(T,T+w),Math.max(S,S+R),Ai),f&&(p=Math.round(p),y=Math.round(y)),{drawImageX:p,drawImageY:y,drawImageW:v,drawImageH:x,originX:h,originY:c,declutterBox:{minX:Ai[0],minY:Ai[1],maxX:Ai[2],maxY:Ai[3],value:_},canvasTransform:I,scale:d}}replayImageOrLabel_(t,e,i,s,r,o,a){const l=!!(o||a),h=s.declutterBox,c=a?a[2]*s.scale[0]/2:0;return h.minX-c<=e[0]&&h.maxX+c>=0&&h.minY-c<=e[1]&&h.maxY+c>=0&&(l&&this.replayTextBackground_(t,Fe,ye,xe,Ne,o,a),pf(t,s.canvasTransform,r,i,s.originX,s.originY,s.drawImageW,s.drawImageH,s.drawImageX,s.drawImageY,s.scale)),!0}fill_(t){const e=this.alignAndScaleFill_;if(e){const i=yt(this.renderedTransform_,[0,0]),s=512*this.pixelRatio;t.save(),t.translate(i[0]%s,i[1]%s),e!==1&&t.scale(e,e),t.rotate(this.viewRotation_)}t.fill(),e&&t.restore()}setStrokeStyle_(t,e){t.strokeStyle=e[1],e[1]&&(t.lineWidth=e[2],t.lineCap=e[3],t.lineJoin=e[4],t.miterLimit=e[5],t.lineDashOffset=e[7],t.setLineDash(e[6]))}drawLabelWithPointPlacement_(t,e,i,s){const r=this.textStates[e],o=this.createLabel(t,e,s,i),a=this.strokeStates[i],l=this.pixelRatio,h=uo(Array.isArray(t)?t[0]:t,r.textAlign||gn),c=Ss[r.textBaseline||fs],u=a&&a.lineWidth?a.lineWidth:0,d=o.width/l-2*r.scale[0],f=h*d+2*(.5-h)*u,g=c*o.height/l+2*(.5-c)*u;return{label:o,anchorX:f,anchorY:g}}execute_(t,e,i,s,r,o,a,l){const h=this.zIndexContext_;let c;this.pixelCoordinates_&&Ce(i,this.renderedTransform_)?c=this.pixelCoordinates_:(this.pixelCoordinates_||(this.pixelCoordinates_=[]),c=Me(this.coordinates,0,this.coordinates.length,2,i,this.pixelCoordinates_),uu(this.renderedTransform_,i));let u=0;const d=s.length;let f=0,g,m,_,p,y,v,x,w,R,T,S,I,M,O=0,L=0;const A=this.coordinateCache_,P=this.viewRotation_,X=Math.round(Math.atan2(-i[1],i[0])*1e12)/1e12,k={context:t,pixelRatio:this.pixelRatio,resolution:this.resolution,rotation:P},G=this.instructions!=s||this.overlaps?0:200;let D,Y,V,tt;for(;u<d;){const b=s[u];switch(b[0]){case F.BEGIN_GEOMETRY:D=b[1],tt=b[3],D.getGeometry()?a!==void 0&&!Pt(a,tt.getExtent())?u=b[2]+1:++u:u=b[2],h&&(h.zIndex=b[4]);break;case F.BEGIN_PATH:O>G&&(this.fill_(t),O=0),L>G&&(t.stroke(),L=0),!O&&!L&&(t.beginPath(),y=NaN,v=NaN),++u;break;case F.CIRCLE:f=b[1];const ft=c[f],ht=c[f+1],bt=c[f+2],Et=c[f+3],jt=bt-ft,Gt=Et-ht,Mt=Math.sqrt(jt*jt+Gt*Gt);t.moveTo(ft+Mt,ht),t.arc(ft,ht,Mt,0,2*Math.PI,!0),++u;break;case F.CLOSE_PATH:t.closePath(),++u;break;case F.CUSTOM:f=b[1],g=b[2];const Oi=b[3],W=b[4],rt=b[5];k.geometry=Oi,k.feature=D,u in A||(A[u]=[]);const j=A[u];rt?rt(c,f,g,2,j):(j[0]=c[f],j[1]=c[f+1],j.length=2),h&&(h.zIndex=b[6]),W(j,k),++u;break;case F.DRAW_IMAGE:f=b[1],g=b[2],R=b[3],m=b[4],_=b[5];let nt=b[6];const mt=b[7],ze=b[8],Pi=b[9],Cn=b[10];let ei=b[11];const Di=b[12];let ki=b[13];p=b[14]||"declutter";const wt=b[15];if(!R&&b.length>=20){T=b[19],S=b[20],I=b[21],M=b[22];const Vt=this.drawLabelWithPointPlacement_(T,S,I,M);R=Vt.label,b[3]=R;const ii=b[23];m=(Vt.anchorX-ii)*this.pixelRatio,b[4]=m;const Zt=b[24];_=(Vt.anchorY-Zt)*this.pixelRatio,b[5]=_,nt=R.height,b[6]=nt,ki=R.width,b[13]=ki}let _o;b.length>25&&(_o=b[25]);let mo,Is,Ts;b.length>17?(mo=b[16],Is=b[17],Ts=b[18]):(mo=Je,Is=null,Ts=null),Cn&&X?ei+=P:!Cn&&!X&&(ei-=P);let p_=0;for(;f<g;f+=2){if(_o&&_o[p_++]<ki/this.pixelRatio)continue;const Vt=this.calculateImageOrLabelDimensions_(R.width,R.height,c[f],c[f+1],ki,nt,m,_,ze,Pi,ei,Di,r,mo,!!Is||!!Ts,D),ii=[t,e,R,Vt,mt,Is,Ts];if(l){let Zt,le,$t;if(wt){const ut=g-f;if(!wt[ut]){wt[ut]={args:ii,declutterMode:p};continue}const Lt=wt[ut];Zt=Lt.args,le=Lt.declutterMode,delete wt[ut],$t=yh(Zt)}let Ee,we;if(Zt&&(le!=="declutter"||!l.collides($t))&&(Ee=!0),(p!=="declutter"||!l.collides(Vt.declutterBox))&&(we=!0),le==="declutter"&&p==="declutter"){const ut=Ee&&we;Ee=ut,we=ut}Ee&&(le!=="none"&&l.insert($t),this.replayImageOrLabel_.apply(this,Zt)),we&&(p!=="none"&&l.insert(Vt.declutterBox),this.replayImageOrLabel_.apply(this,ii))}else this.replayImageOrLabel_.apply(this,ii)}++u;break;case F.DRAW_CHARS:const vh=b[1],Ch=b[2],po=b[3],y_=b[4];M=b[5];const x_=b[6],Rh=b[7],Sh=b[8];I=b[9];const yo=b[10];T=b[11],Array.isArray(T)&&(T=T.reduce(i_,"")),S=b[12];const Ih=[b[13],b[13]];p=b[14]||"declutter";const E_=b[15],xo=this.textStates[S],Rn=xo.font,Sn=[xo.scale[0]*Rh,xo.scale[1]*Rh];let In;Rn in this.widths_?In=this.widths_[Rn]:(In={},this.widths_[Rn]=In);const Th=Mg(c,vh,Ch,2),bh=Math.abs(Sn[0])*bl(Rn,T,In);if(y_||bh<=Th){const Vt=this.textStates[S].textAlign,ii=(Th-bh)*uo(T,Vt),Zt=t_(c,vh,Ch,2,T,ii,x_,Math.abs(Sn[0]),bl,Rn,In,X?0:this.viewRotation_,E_);t:if(Zt){const le=[];let $t,Ee,we,ut,Lt;if(I)for($t=0,Ee=Zt.length;$t<Ee;++$t){Lt=Zt[$t],we=Lt[4],ut=this.createLabel(we,S,"",I),m=Lt[2]+(Sn[0]<0?-yo:yo),_=po*ut.height+(.5-po)*2*yo*Sn[1]/Sn[0]-Sh;const ve=this.calculateImageOrLabelDimensions_(ut.width,ut.height,Lt[0],Lt[1],ut.width,ut.height,m,_,0,0,Lt[3],Ih,!1,Je,!1,D);if(l&&p==="declutter"&&l.collides(ve.declutterBox))break t;le.push([t,e,ut,ve,1,null,null])}if(M)for($t=0,Ee=Zt.length;$t<Ee;++$t){Lt=Zt[$t],we=Lt[4],ut=this.createLabel(we,S,M,""),m=Lt[2],_=po*ut.height-Sh;const ve=this.calculateImageOrLabelDimensions_(ut.width,ut.height,Lt[0],Lt[1],ut.width,ut.height,m,_,0,0,Lt[3],Ih,!1,Je,!1,D);if(l&&p==="declutter"&&l.collides(ve.declutterBox))break t;le.push([t,e,ut,ve,1,null,null])}l&&p!=="none"&&l.load(le.map(yh));for(let ve=0,w_=le.length;ve<w_;++ve)this.replayImageOrLabel_.apply(this,le[ve])}}++u;break;case F.END_GEOMETRY:if(o!==void 0){D=b[1];const Vt=o(D,tt,p);if(Vt)return Vt}++u;break;case F.FILL:G?O++:this.fill_(t),++u;break;case F.MOVE_TO_LINE_TO:for(f=b[1],g=b[2],Y=c[f],V=c[f+1],t.moveTo(Y,V),y=Y+.5|0,v=V+.5|0,f+=2;f<g;f+=2)Y=c[f],V=c[f+1],x=Y+.5|0,w=V+.5|0,(f==g-2||x!==y||w!==v)&&(t.lineTo(Y,V),y=x,v=w);++u;break;case F.SET_FILL_STYLE:this.alignAndScaleFill_=b[2],O&&(this.fill_(t),O=0,L&&(t.stroke(),L=0)),t.fillStyle=b[1],++u;break;case F.SET_STROKE_STYLE:L&&(t.stroke(),L=0),this.setStrokeStyle_(t,b),++u;break;case F.STROKE:G?L++:t.stroke(),++u;break;default:++u;break}}O&&this.fill_(t),L&&t.stroke()}execute(t,e,i,s,r,o){this.viewRotation_=s,this.execute_(t,e,i,this.instructions,r,void 0,void 0,o)}executeHitDetection(t,e,i,s,r){return this.viewRotation_=i,this.execute_(t,[t.canvas.width,t.canvas.height],e,this.hitDetectionInstructions,!0,s,r)}}const ti=["Polygon","Circle","LineString","Image","Text","Default"],Eh=["Image","Text"],s_=ti.filter(n=>!Eh.includes(n));class r_{constructor(t,e,i,s,r,o,a){this.maxExtent_=t,this.overlaps_=s,this.pixelRatio_=i,this.resolution_=e,this.renderBuffer_=o,this.executorsByZIndex_={},this.hitDetectionContext_=null,this.hitDetectionTransform_=qt(),this.renderedContext_=null,this.deferredZIndexContexts_={},this.createExecutors_(r,a)}clip(t,e){const i=this.getClipCoords(e);t.beginPath(),t.moveTo(i[0],i[1]),t.lineTo(i[2],i[3]),t.lineTo(i[4],i[5]),t.lineTo(i[6],i[7]),t.clip()}createExecutors_(t,e){for(const i in t){let s=this.executorsByZIndex_[i];s===void 0&&(s={},this.executorsByZIndex_[i]=s);const r=t[i];for(const o in r){const a=r[o];s[o]=new n_(this.resolution_,this.pixelRatio_,this.overlaps_,a,e)}}}hasExecutors(t){for(const e in this.executorsByZIndex_){const i=this.executorsByZIndex_[e];for(let s=0,r=t.length;s<r;++s)if(t[s]in i)return!0}return!1}forEachFeatureAtCoordinate(t,e,i,s,r,o){s=Math.round(s);const a=s*2+1,l=fe(this.hitDetectionTransform_,s+.5,s+.5,1/e,-1/e,-i,-t[0],-t[1]),h=!this.hitDetectionContext_;h&&(this.hitDetectionContext_=gt(a,a));const c=this.hitDetectionContext_;c.canvas.width!==a||c.canvas.height!==a?(c.canvas.width=a,c.canvas.height=a):h||c.clearRect(0,0,a,a);let u;this.renderBuffer_!==void 0&&(u=Xt(),Vi(u,t),Ks(u,e*(this.renderBuffer_+s),u));const d=o_(s);let f;function g(w,R,T){const S=c.getImageData(0,0,a,a).data;for(let I=0,M=d.length;I<M;I++)if(S[d[I]]>0){if(!o||T==="none"||f!=="Image"&&f!=="Text"||o.includes(w)){const O=(d[I]-3)/4,L=s-O%a,A=s-(O/a|0),P=r(w,R,L*L+A*A);if(P)return P}c.clearRect(0,0,a,a);break}}const m=Object.keys(this.executorsByZIndex_).map(Number);m.sort(ce);let _,p,y,v,x;for(_=m.length-1;_>=0;--_){const w=m[_].toString();for(y=this.executorsByZIndex_[w],p=ti.length-1;p>=0;--p)if(f=ti[p],v=y[f],v!==void 0&&(x=v.executeHitDetection(c,l,i,g,u),x))return x}}getClipCoords(t){const e=this.maxExtent_;if(!e)return null;const i=e[0],s=e[1],r=e[2],o=e[3],a=[i,s,i,o,r,o,r,s];return Me(a,0,8,2,t,a),a}isEmpty(){return oi(this.executorsByZIndex_)}execute(t,e,i,s,r,o,a){const l=Object.keys(this.executorsByZIndex_).map(Number);l.sort(a?cc:ce),o=o||ti;const h=ti.length;for(let c=0,u=l.length;c<u;++c){const d=l[c].toString(),f=this.executorsByZIndex_[d];for(let g=0,m=o.length;g<m;++g){const _=o[g],p=f[_];if(p!==void 0){const y=a===null?void 0:p.getZIndexContext(),v=y?y.getContext():t,x=this.maxExtent_&&_!=="Image"&&_!=="Text";if(x&&(v.save(),this.clip(v,i)),!y||_==="Text"||_==="Image"?p.execute(v,e,i,s,r,a):y.pushFunction(w=>p.execute(w,e,i,s,r,a)),x&&v.restore(),y){y.offset();const w=l[c]*h+ti.indexOf(_);this.deferredZIndexContexts_[w]||(this.deferredZIndexContexts_[w]=[]),this.deferredZIndexContexts_[w].push(y)}}}}this.renderedContext_=t}getDeferredZIndexContexts(){return this.deferredZIndexContexts_}getRenderedContext(){return this.renderedContext_}renderDeferred(){const t=this.deferredZIndexContexts_,e=Object.keys(t).map(Number).sort(ce);for(let i=0,s=e.length;i<s;++i)t[e[i]].forEach(r=>{r.draw(this.renderedContext_),r.clear()}),t[e[i]].length=0}}const fo={};function o_(n){if(fo[n]!==void 0)return fo[n];const t=n*2+1,e=n*n,i=new Array(e+1);for(let r=0;r<=n;++r)for(let o=0;o<=n;++o){const a=r*r+o*o;if(a>e)break;let l=i[a];l||(l=[],i[a]=l),l.push(((n+r)*t+(n+o))*4+3),r>0&&l.push(((n-r)*t+(n+o))*4+3),o>0&&(l.push(((n+r)*t+(n-o))*4+3),r>0&&l.push(((n-r)*t+(n-o))*4+3))}const s=[];for(let r=0,o=i.length;r<o;++r)i[r]&&s.push(...i[r]);return fo[n]=s,s}const ae=.5;function a_(n,t,e,i,s,r,o,a,l){const h=s,c=n[0]*ae,u=n[1]*ae,d=gt(c,u);d.imageSmoothingEnabled=!1;const f=d.canvas,g=new Lg(d,ae,s,null,o,a,null),m=e.length,_=Math.floor((256*256*256-1)/m),p={};for(let v=1;v<=m;++v){const x=e[v-1],w=x.getStyleFunction()||i;if(!w)continue;let R=w(x,r);if(!R)continue;Array.isArray(R)||(R=[R]);const S=(v*_).toString(16).padStart(7,"#00000");for(let I=0,M=R.length;I<M;++I){const O=R[I],L=O.getGeometryFunction()(x);if(!L||!Pt(h,L.getExtent()))continue;const A=O.clone(),P=A.getFill();P&&P.setColor(S);const X=A.getStroke();X&&(X.setColor(S),X.setLineDash(null)),A.setText(void 0);const k=O.getImage();if(k){const V=k.getImageSize();if(!V)continue;const tt=gt(V[0],V[1],void 0,{alpha:!1}),b=tt.canvas;tt.fillStyle=S,tt.fillRect(0,0,b.width,b.height),A.setImage(new yn({img:b,anchor:k.getAnchor(),anchorXUnits:"pixels",anchorYUnits:"pixels",offset:k.getOrigin(),opacity:1,size:k.getSize(),scale:k.getScale(),rotation:k.getRotation(),rotateWithView:k.getRotateWithView()}))}const G=A.getZIndex()||0;let D=p[G];D||(D={},p[G]=D,D.Polygon=[],D.Circle=[],D.LineString=[],D.Point=[]);const Y=L.getType();if(Y==="GeometryCollection"){const V=L.getGeometriesArrayRecursive();for(let tt=0,b=V.length;tt<b;++tt){const xt=V[tt];D[xt.getType().replace("Multi","")].push(xt,A)}}else D[Y.replace("Multi","")].push(L,A)}}const y=Object.keys(p).map(Number).sort(ce);for(let v=0,x=y.length;v<x;++v){const w=p[y[v]];for(const R in w){const T=w[R];for(let S=0,I=T.length;S<I;S+=2){g.setStyle(T[S+1]);for(let M=0,O=t.length;M<O;++M)g.setTransform(t[M]),g.drawGeometry(T[S])}}}return d.getImageData(0,0,f.width,f.height)}function l_(n,t,e){const i=[];if(e){const s=Math.floor(Math.round(n[0])*ae),r=Math.floor(Math.round(n[1])*ae),o=(lt(s,0,e.width-1)+lt(r,0,e.height-1)*e.width)*4,a=e.data[o],l=e.data[o+1],c=e.data[o+2]+256*(l+256*a),u=Math.floor((256*256*256-1)/t.length);c&&c%u===0&&i.push(t[c/u-1])}return i}class h_ extends Ql{constructor(t){super(t),this.boundHandleStyleImageChange_=this.handleStyleImageChange_.bind(this),this.animatingOrInteracting_,this.hitDetectionImageData_=null,this.clipped_=!1,this.renderedFeatures_=null,this.renderedRevision_=-1,this.renderedResolution_=NaN,this.renderedExtent_=Xt(),this.wrappedRenderedExtent_=Xt(),this.renderedRotation_,this.renderedCenter_=null,this.renderedProjection_=null,this.renderedPixelRatio_=1,this.renderedRenderOrder_=null,this.renderedFrameDeclutter_,this.replayGroup_=null,this.replayGroupChanged=!0,this.clipping=!0,this.targetContext_=null,this.opacity_=1}renderWorlds(t,e,i){const s=e.extent,r=e.viewState,o=r.center,a=r.resolution,l=r.projection,h=r.rotation,c=l.getExtent(),u=this.getLayer().getSource(),d=this.getLayer().getDeclutter(),f=e.pixelRatio,g=e.viewHints,m=!(g[St.ANIMATING]||g[St.INTERACTING]),_=this.context,p=Math.round(et(s)/a*f),y=Math.round(It(s)/a*f),v=u.getWrapX()&&l.canWrapX(),x=v?et(c):null,w=v?Math.ceil((s[2]-c[2])/x)+1:1;let R=v?Math.floor((s[0]-c[0])/x):0;do{let T=this.getRenderTransform(o,a,0,f,p,y,R*x);e.declutter&&(T=T.slice(0)),t.execute(_,[_.canvas.width,_.canvas.height],T,h,m,i===void 0?ti:i?Eh:s_,i?d&&e.declutter[d]:void 0)}while(++R<w)}setDrawContext_(){this.opacity_!==1&&(this.targetContext_=this.context,this.context=gt(this.context.canvas.width,this.context.canvas.height,Jl))}resetDrawContext_(){if(this.opacity_!==1&&this.targetContext_){const t=this.targetContext_.globalAlpha;this.targetContext_.globalAlpha=this.opacity_,this.targetContext_.drawImage(this.context.canvas,0,0),this.targetContext_.globalAlpha=t,as(this.context),Jl.push(this.context.canvas),this.context=this.targetContext_,this.targetContext_=null}}renderDeclutter(t){!this.replayGroup_||!this.getLayer().getDeclutter()||this.renderWorlds(this.replayGroup_,t,!0)}renderDeferredInternal(t){this.replayGroup_&&(this.replayGroup_.renderDeferred(),this.clipped_&&this.context.restore(),this.resetDrawContext_())}renderFrame(t,e){const i=t.layerStatesArray[t.layerIndex];this.opacity_=i.opacity;const s=t.viewState;this.prepareContainer(t,e);const r=this.context,o=this.replayGroup_;let a=o&&!o.isEmpty();if(!a&&!(this.getLayer().hasListener(Bt.PRERENDER)||this.getLayer().hasListener(Bt.POSTRENDER)))return this.container;if(this.setDrawContext_(),this.preRender(r,t),s.projection,this.clipped_=!1,a&&i.extent&&this.clipping){const l=be(i.extent);a=Pt(l,t.extent),this.clipped_=a&&!Ki(l,t.extent),this.clipped_&&this.clipUnrotated(r,t,l)}return a&&this.renderWorlds(o,t,this.getLayer().getDeclutter()?!1:void 0),!t.declutter&&this.clipped_&&r.restore(),this.postRender(r,t),this.renderedRotation_!==s.rotation&&(this.renderedRotation_=s.rotation,this.hitDetectionImageData_=null),t.declutter||this.resetDrawContext_(),this.container}getFeatures(t){return new Promise(e=>{if(this.frameState&&!this.hitDetectionImageData_&&!this.animatingOrInteracting_){const i=this.frameState.size.slice(),s=this.renderedCenter_,r=this.renderedResolution_,o=this.renderedRotation_,a=this.renderedProjection_,l=this.wrappedRenderedExtent_,h=this.getLayer(),c=[],u=i[0]*ae,d=i[1]*ae;c.push(this.getRenderTransform(s,r,o,ae,u,d,0).slice());const f=h.getSource(),g=a.getExtent();if(f.getWrapX()&&a.canWrapX()&&!Ki(g,l)){let m=l[0];const _=et(g);let p=0,y;for(;m<g[0];)--p,y=_*p,c.push(this.getRenderTransform(s,r,o,ae,u,d,y).slice()),m+=_;for(p=0,m=l[2];m>g[2];)++p,y=_*p,c.push(this.getRenderTransform(s,r,o,ae,u,d,y).slice()),m-=_}this.hitDetectionImageData_=a_(i,c,this.renderedFeatures_,h.getStyleFunction(),l,r,o,hh(r,this.renderedPixelRatio_))}e(l_(t,this.renderedFeatures_,this.hitDetectionImageData_))})}forEachFeatureAtCoordinate(t,e,i,s,r){if(!this.replayGroup_)return;const o=e.viewState.resolution,a=e.viewState.rotation,l=this.getLayer(),h={},c=function(d,f,g){const m=q(d),_=h[m];if(_){if(_!==!0&&g<_.distanceSq){if(g===0)return h[m]=!0,r.splice(r.lastIndexOf(_),1),s(d,l,f);_.geometry=f,_.distanceSq=g}}else{if(g===0)return h[m]=!0,s(d,l,f);r.push(h[m]={feature:d,layer:l,geometry:f,distanceSq:g,callback:s})}},u=this.getLayer().getDeclutter();return this.replayGroup_.forEachFeatureAtCoordinate(t,o,a,i,c,u?e.declutter?.[u]?.all().map(d=>d.value):null)}handleFontsChanged(){const t=this.getLayer();t.getVisible()&&this.replayGroup_&&t.changed()}handleStyleImageChange_(t){this.renderIfReadyAndVisible()}prepareFrame(t){const e=this.getLayer(),i=e.getSource();if(!i)return!1;const s=t.viewHints[St.ANIMATING],r=t.viewHints[St.INTERACTING],o=e.getUpdateWhileAnimating(),a=e.getUpdateWhileInteracting();if(this.ready&&!o&&s||!a&&r)return this.animatingOrInteracting_=!0,!0;this.animatingOrInteracting_=!1;const l=t.extent,h=t.viewState,c=h.projection,u=h.resolution,d=t.pixelRatio,f=e.getRevision(),g=e.getRenderBuffer();let m=e.getRenderOrder();m===void 0&&(m=Og);const _=h.center.slice(),p=Ks(l,g*u),y=p.slice(),v=[p.slice()],x=c.getExtent();if(i.getWrapX()&&c.canWrapX()&&!Ki(x,t.extent)){const P=et(x),X=Math.max(et(p)/2,P);p[0]=x[0]-X,p[2]=x[2]+X,pa(_,c);const k=_a(v[0],c);k[0]<x[0]&&k[2]<x[2]?v.push([k[0]+P,k[1],k[2]+P,k[3]]):k[0]>x[0]&&k[2]>x[2]&&v.push([k[0]-P,k[1],k[2]-P,k[3]])}if(this.ready&&this.renderedResolution_==u&&this.renderedRevision_==f&&this.renderedRenderOrder_==m&&this.renderedFrameDeclutter_===!!t.declutter&&Ki(this.wrappedRenderedExtent_,p))return Ce(this.renderedExtent_,y)||(this.hitDetectionImageData_=null,this.renderedExtent_=y),this.renderedCenter_=_,this.replayGroupChanged=!1,!0;this.replayGroup_=null;const w=new Qg(ch(u,d),p,u,d);let R;for(let P=0,X=v.length;P<X;++P)i.loadFeatures(v[P],u,c);const T=hh(u,d);let S=!0;const I=(P,X)=>{let k;const G=P.getStyleFunction()||e.getStyleFunction();if(G&&(k=G(P,u)),k){const D=this.renderFeature(P,T,k,w,R,this.getLayer().getDeclutter(),X);S=S&&!D}},M=Fa(p),O=i.getFeaturesInExtent(M);m&&O.sort(m);for(let P=0,X=O.length;P<X;++P)I(O[P],P);this.renderedFeatures_=O,this.ready=S;const L=w.finish(),A=new r_(p,u,d,i.getOverlaps(),L,e.getRenderBuffer(),!!t.declutter);return this.renderedResolution_=u,this.renderedRevision_=f,this.renderedRenderOrder_=m,this.renderedFrameDeclutter_=!!t.declutter,this.renderedExtent_=y,this.wrappedRenderedExtent_=p,this.renderedCenter_=_,this.renderedProjection_=c,this.renderedPixelRatio_=d,this.replayGroup_=A,this.hitDetectionImageData_=null,this.replayGroupChanged=!0,!0}renderFeature(t,e,i,s,r,o,a){if(!i)return!1;let l=!1;if(Array.isArray(i))for(let h=0,c=i.length;h<c;++h)l=uh(s,t,i[h],e,this.boundHandleStyleImageChange_,r,o,a)||l;else l=uh(s,t,i,e,this.boundHandleStyleImageChange_,r,o,a);return l}}class c_ extends Xl{constructor(t){super(t)}createRenderer(){return new h_(this)}}function u_({latitude:n,longitude:t,name:e,address:i,url:s,timestamp:r,isFromCustomer:o}){const a=Wi(null),l=Wi(null);ee(()=>{if(!a.current)return;const u=hu([t,n]),d=new co({geometry:new is(u)});d.setStyle(new Oe({image:new yn({anchor:[.5,1],src:"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='%23ef4444' stroke='white' stroke-width='2'%3E%3Cpath d='M21 10c0 7-9 13-9 13s-9-6-9-13a9 9 0 0 1 18 0z'%3E%3C/path%3E%3Ccircle cx='12' cy='10' r='3' fill='white'%3E%3C/circle%3E%3C/svg%3E",scale:1.5})}));const f=new jg({features:[d]}),g=new c_({source:f}),m=new Gf({target:a.current,layers:[new ag({source:new Tg}),g],view:new re({center:u,zoom:15}),controls:[]});return l.current=m,()=>{m.setTarget(void 0),l.current=null}},[n,t]);const h=`https://www.google.com/maps?q=${n},${t}`,c=`https://www.openstreetmap.org/?mlat=${n}&mlon=${t}&zoom=15`;return E("div",{class:`flex ${o?"justify-end":"justify-start"} mb-3`,children:E("div",{class:`max-w-[75%] rounded-lg ${o?"bg-blue-600 text-white":"bg-white border border-zinc-200 text-zinc-900"}`,children:E("div",{class:"p-2",children:[E("div",{ref:a,class:"w-full h-32 rounded border border-zinc-300"}),(e||i)&&E("div",{class:"mt-2",children:[e&&E("p",{class:`text-sm font-medium ${o?"text-white":"text-zinc-900"}`,children:e}),i&&E("p",{class:`text-xs ${o?"text-blue-100":"text-zinc-500"}`,children:i})]}),E("div",{class:"flex items-center gap-1 mt-2",children:[E("svg",{class:`w-3 h-3 ${o?"text-blue-100":"text-zinc-500"}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[E("title",{children:"Pin"}),E("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M17.657 16.657L13.414 20.9a1.998 1.998 0 01-2.827 0l-4.244-4.243a8 8 0 1111.314 0z"}),E("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M15 11a3 3 0 11-6 0 3 3 0 016 0z"})]}),E("span",{class:`text-xs ${o?"text-blue-100":"text-zinc-500"}`,children:[n.toFixed(6),", ",t.toFixed(6)]})]}),s&&E("a",{href:s,target:"_blank",rel:"noopener noreferrer",class:`block mt-2 text-xs px-2 py-1 rounded border text-center transition-colors ${o?"border-blue-400 hover:bg-blue-500":"border-zinc-300 hover:bg-zinc-50"}`,children:"Visit Website"}),E("div",{class:"flex gap-2 mt-2",children:[E("a",{href:h,target:"_blank",rel:"noopener noreferrer",class:`flex-1 text-xs px-2 py-1 rounded border text-center transition-colors ${o?"border-blue-400 hover:bg-blue-500":"border-zinc-300 hover:bg-zinc-50"}`,children:"Google Maps"}),E("a",{href:c,target:"_blank",rel:"noopener noreferrer",class:`flex-1 text-xs px-2 py-1 rounded border text-center transition-colors ${o?"border-blue-400 hover:bg-blue-500":"border-zinc-300 hover:bg-zinc-50"}`,children:"OpenStreetMap"})]}),E("span",{class:`text-xs mt-2 block ${o?"text-blue-100":"text-zinc-500"}`,children:new Date(r).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})})]})})})}function d_({messages:n}){const t=Wi(null),e=sc({count:n.length,getScrollElement:()=>t.current,estimateSize:()=>192,overscan:5});ee(()=>{n.length>0&&e.scrollToIndex(n.length-1,{align:"end"})},[n.length]);const i=r=>{const o={timestamp:r.timestamp,isFromCustomer:!r.isSupport};switch(r.type){case"text":return E(rc,{content:r.content||"",...o});case"photo":return E(oc,{url:r.url||"",filename:r.filename,size:r.size,caption:r.content,...o});case"video":return E(ac,{url:r.url||"",filename:r.filename,size:r.size,caption:r.content,...o});case"file":return E(lc,{url:r.url||"",filename:r.filename||"file",size:r.size,mimeType:r.mimeType,...o});case"location":return E(u_,{latitude:r.latitude||0,longitude:r.longitude||0,name:r.name,address:r.address,...o});default:return null}},s=e.getVirtualItems();return E("div",{ref:t,class:"flex-1 overflow-y-auto p-4",children:E("div",{style:{height:`${e.getTotalSize()}px`,width:"100%",position:"relative"},children:s.map(r=>{const o=n[r.index];return o?E("div",{"data-index":r.index,ref:e.measureElement,style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${r.start}px)`},children:i(o)},r.key):null})})})}function f_(){const{isOpen:n,inputMessage:t,isSending:e,showPlatformChoice:i,showNamePrompt:s,isInitialized:r,availablePlatforms:o,showAttachmentMenu:a,customerName:l,messages:h,isLoadingMessages:c,toggleChat:u,setInputMessage:d,sendMessage:f,selectPlatform:g,goBackToPlatforms:m,initializeWidgetSession:_,toggleAttachmentMenu:p,handleGalleryUpload:y,handleFileUpload:v,handleLocationShare:x}=Uh(),w=R=>{R.preventDefault(),f()};return E("div",{class:"fixed bottom-6 right-6 z-2147483647 font-sans",children:[!n&&E("button",{type:"button",onClick:u,class:"w-14 h-14 bg-blue-600 hover:bg-blue-700 text-white rounded-full shadow-lg flex items-center justify-center transition-all",children:E("svg",{class:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:E("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M8 10h.01M12 10h.01M16 10h.01M9 16H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-5l-5 5v-5z"})})}),n&&E("div",{class:"w-96 h-[600px] bg-white rounded-lg shadow-[0_0_20px_rgba(0,0,0,0.15)] flex flex-col border border-zinc-200",children:[E("div",{class:"p-4 flex items-center gap-3 border-b border-zinc-200",children:[E("button",{type:"button",onClick:m,class:"p-1 hover:bg-zinc-100 rounded transition-colors",children:E("svg",{class:"w-5 h-5 text-zinc-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:E("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M15 19l-7-7 7-7"})})}),E("div",{class:"flex-1 min-w-0",children:E("h2",{class:"font-semibold text-zinc-900 truncate",children:["Support Chat for ",l||"Guest"]})}),E("button",{type:"button",onClick:u,class:"p-1 hover:bg-zinc-100 rounded transition-colors shrink-0",children:E("svg",{class:"w-5 h-5 text-zinc-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:E("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M6 18L18 6M6 6l12 12"})})})]}),i&&E("div",{class:"p-6 flex flex-col gap-4",children:[E("h3",{class:"text-lg font-semibold text-zinc-900",children:"Choose how to contact us"}),E("p",{class:"text-sm text-zinc-600",children:"Select your preferred platform to chat with our support team."}),E("div",{class:"space-y-2",children:o.map(R=>E("button",{type:"button",onClick:()=>g(R),class:"w-full flex items-center gap-3 p-4 border-2 border-zinc-200 hover:border-blue-500 hover:bg-blue-50 rounded-lg transition-all text-left",children:[E("div",{class:"w-10 h-10 flex items-center justify-center rounded-full bg-zinc-100",children:[R.type==="telegram"&&E("svg",{class:"w-6 h-6 text-blue-500",fill:"currentColor",viewBox:"0 0 24 24",children:E("path",{d:"M12 0C5.373 0 0 5.373 0 12s5.373 12 12 12 12-5.373 12-12S18.627 0 12 0zm5.562 8.161c-.18 1.897-.962 6.502-1.359 8.627-.168.9-.5 1.201-.82 1.23-.697.064-1.226-.461-1.901-.903-1.056-.692-1.653-1.123-2.678-1.799-1.185-.781-.417-1.21.258-1.911.177-.184 3.247-2.977 3.307-3.23.007-.032.014-.15-.056-.212s-.174-.041-.249-.024c-.106.024-1.793 1.139-5.062 3.345-.479.329-.913.489-1.302.481-.428-.008-1.252-.241-1.865-.44-.752-.244-1.349-.374-1.297-.789.027-.216.325-.437.893-.663 3.498-1.524 5.831-2.529 6.998-3.014 3.332-1.386 4.025-1.627 4.476-1.635.099-.002.321.023.465.141.121.099.155.232.171.326.016.094.036.308.02.475z"})}),R.type==="discord"&&E("svg",{class:"w-6 h-6 text-indigo-500",fill:"currentColor",viewBox:"0 0 24 24",children:E("path",{d:"M20.317 4.37a19.791 19.791 0 0 0-4.885-1.515a.074.074 0 0 0-.079.037c-.21.375-.444.864-.608 1.25a18.27 18.27 0 0 0-5.487 0a12.64 12.64 0 0 0-.617-1.25a.077.077 0 0 0-.079-.037A19.736 19.736 0 0 0 3.677 4.37a.07.07 0 0 0-.032.027C.533 9.046-.32 13.58.099 18.057a.082.082 0 0 0 .031.057a19.9 19.9 0 0 0 5.993 3.03a.078.078 0 0 0 .084-.028a14.09 14.09 0 0 0 1.226-1.994a.076.076 0 0 0-.041-.106a13.107 13.107 0 0 1-1.872-.892a.077.077 0 0 1-.008-.128a10.2 10.2 0 0 0 .372-.292a.074.074 0 0 1 .077-.01c3.928 1.793 8.18 1.793 12.062 0a.074.074 0 0 1 .078.01c.12.098.246.198.373.292a.077.077 0 0 1-.006.127a12.299 12.299 0 0 1-1.873.892a.077.077 0 0 0-.041.107c.36.698.772 1.362 1.225 1.993a.076.076 0 0 0 .084.028a19.839 19.839 0 0 0 6.002-3.03a.077.077 0 0 0 .032-.054c.5-5.177-.838-9.674-3.549-13.66a.061.061 0 0 0-.031-.03zM8.02 15.33c-1.183 0-2.157-1.085-2.157-2.419c0-1.333.956-2.419 2.157-2.419c1.21 0 2.176 1.096 2.157 2.42c0 1.333-.956 2.418-2.157 2.418zm7.975 0c-1.183 0-2.157-1.085-2.157-2.419c0-1.333.955-2.419 2.157-2.419c1.21 0 2.176 1.096 2.157 2.42c0 1.333-.946 2.418-2.157 2.418z"})}),R.type==="widget"&&E("svg",{class:"w-6 h-6 text-blue-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:E("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M8 10h.01M12 10h.01M16 10h.01M9 16H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-5l-5 5v-5z"})})]}),E("div",{class:"flex-1",children:[E("div",{class:"font-medium text-zinc-900",children:R.name}),E("div",{class:"text-xs text-zinc-500",children:R.type==="widget"?"Chat directly on this website":"Opens in new tab"})]}),E("svg",{class:"w-5 h-5 text-zinc-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:E("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M9 5l7 7-7 7"})})]},R.type))})]}),s&&E("div",{class:"p-6 flex flex-col gap-4",children:[E("h3",{class:"text-lg font-semibold text-zinc-900",children:"Welcome!"}),E("p",{class:"text-sm text-zinc-600",children:"Please enter your details to start chatting."}),E("form",{onSubmit:R=>{R.preventDefault();const T=new FormData(R.currentTarget),S=T.get("name"),I=T.get("email");_(S,I)},class:"space-y-3",children:[E("input",{type:"text",name:"name",placeholder:"Your name",required:!0,class:"w-full px-4 py-2 border border-zinc-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500"}),E("input",{type:"email",name:"email",placeholder:"Email (optional)",class:"w-full px-4 py-2 border border-zinc-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500"}),E("div",{class:"flex gap-2 pt-2",children:[E("button",{type:"button",onClick:m,class:"flex-1 px-4 py-2 border border-zinc-300 rounded-lg hover:bg-zinc-50 transition-colors",children:"Back"}),E("button",{type:"submit",class:"flex-1 px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors",children:"Start Chat"})]})]})]}),r&&E(Ni,{children:[c?E("div",{class:"flex-1 flex items-center justify-center text-zinc-500",children:E("div",{class:"text-center",children:[E("div",{class:"w-8 h-8 border-2 border-blue-600 border-t-transparent rounded-full animate-spin mx-auto mb-2"}),E("p",{class:"text-sm",children:"Loading messages..."})]})}):E(d_,{messages:h}),a&&E("div",{class:"px-4 pb-3 flex gap-2",children:[E("button",{type:"button",onClick:y,disabled:e,class:"flex-1 flex flex-col items-center gap-1 p-3 border border-zinc-200 rounded-lg hover:bg-zinc-50 disabled:opacity-50 transition-colors",children:[E("svg",{class:"w-6 h-6 text-blue-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:E("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"})}),E("span",{class:"text-xs text-zinc-700",children:"Photo/Video"})]}),E("button",{type:"button",onClick:v,disabled:e,class:"flex-1 flex flex-col items-center gap-1 p-3 border border-zinc-200 rounded-lg hover:bg-zinc-50 disabled:opacity-50 transition-colors",children:[E("svg",{class:"w-6 h-6 text-green-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:E("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})}),E("span",{class:"text-xs text-zinc-700",children:"File"})]}),E("button",{type:"button",onClick:x,disabled:e,class:"flex-1 flex flex-col items-center gap-1 p-3 border border-zinc-200 rounded-lg hover:bg-zinc-50 disabled:opacity-50 transition-colors",children:[E("svg",{class:"w-6 h-6 text-red-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[E("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M17.657 16.657L13.414 20.9a1.998 1.998 0 01-2.827 0l-4.244-4.243a8 8 0 1111.314 0z"}),E("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M15 11a3 3 0 11-6 0 3 3 0 016 0z"})]}),E("span",{class:"text-xs text-zinc-700",children:"Location"})]})]}),E("div",{class:"border-t border-zinc-200",children:E("form",{onSubmit:w,class:"flex items-center px-4 py-3",children:[E("button",{type:"button",onClick:p,disabled:e,class:"p-1 hover:bg-zinc-50 disabled:opacity-50 transition-colors",children:E("svg",{class:"w-5 h-5 text-zinc-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:E("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 4v16m8-8H4"})})}),E("input",{type:"text",value:t,onInput:R=>d(R.target.value),placeholder:"Type a message...",disabled:e,class:"flex-1 px-2 py-2 focus:outline-none disabled:opacity-50 placeholder:text-zinc-300"}),E("button",{type:"submit",disabled:e||!t.trim(),class:"p-1 hover:bg-zinc-50 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:E("img",{src:Kh,alt:"Send",class:"w-5 h-5"})})]})})]})]})]})}const wh=document.querySelector("script[data-api-key]"),g_=wh?.getAttribute("data-api-key")||"",__=wh?.getAttribute("data-api-url")||"https://useconverge.app/api/widget",m_={apiKey:g_,apiUrl:__},go=document.createElement("div");go.id="__converge-chat-widget",document.body.appendChild(go),kh(E(Bh,{config:m_,children:E(f_,{})}),go),window.ConvergeChat={}})();
|
|
11
|
+
`){A+=L,L=0,I=u*v+S*d,++X;continue}const V=f[G+1]||l.font;V!==k&&(s&&M.push("font",V),i&&O.push("font",V),k=V),L=Math.max(L,p[P]);const tt=[Y,I+S*_[P]+u*(_[P]-y[X]),.5*(d+L)+A];I+=_[P],s&&M.push("strokeText",tt),i&&O.push("fillText",tt),++P}return Array.prototype.push.apply(x,M),Array.prototype.push.apply(x,O),this.labels_[r]=T,T}replayTextBackground_(t,e,i,s,r,o,a){t.beginPath(),t.moveTo.apply(t,e),t.lineTo.apply(t,i),t.lineTo.apply(t,s),t.lineTo.apply(t,r),t.lineTo.apply(t,e),o&&(this.alignAndScaleFill_=o[2],t.fillStyle=o[1],this.fill_(t)),a&&(this.setStrokeStyle_(t,a),t.stroke())}calculateImageOrLabelDimensions_(t,e,i,s,r,o,a,l,h,c,u,d,f,g,m,_){a*=d[0],l*=d[1];let p=i-a,y=s-l;const v=r+h>t?t-h:r,x=o+c>e?e-c:o,w=g[3]+v*d[0]+g[1],R=g[0]+x*d[1]+g[2],T=p-g[3],S=y-g[0];(m||u!==0)&&(Fe[0]=T,Ne[0]=T,Fe[1]=S,ye[1]=S,ye[0]=T+w,xe[0]=ye[0],xe[1]=S+R,Ne[1]=xe[1]);let I;return u!==0?(I=fe(qt(),i,s,1,1,u,-i,-s),yt(I,Fe),yt(I,ye),yt(I,xe),yt(I,Ne),Te(Math.min(Fe[0],ye[0],xe[0],Ne[0]),Math.min(Fe[1],ye[1],xe[1],Ne[1]),Math.max(Fe[0],ye[0],xe[0],Ne[0]),Math.max(Fe[1],ye[1],xe[1],Ne[1]),Oi)):Te(Math.min(T,T+w),Math.min(S,S+R),Math.max(T,T+w),Math.max(S,S+R),Oi),f&&(p=Math.round(p),y=Math.round(y)),{drawImageX:p,drawImageY:y,drawImageW:v,drawImageH:x,originX:h,originY:c,declutterBox:{minX:Oi[0],minY:Oi[1],maxX:Oi[2],maxY:Oi[3],value:_},canvasTransform:I,scale:d}}replayImageOrLabel_(t,e,i,s,r,o,a){const l=!!(o||a),h=s.declutterBox,c=a?a[2]*s.scale[0]/2:0;return h.minX-c<=e[0]&&h.maxX+c>=0&&h.minY-c<=e[1]&&h.maxY+c>=0&&(l&&this.replayTextBackground_(t,Fe,ye,xe,Ne,o,a),pf(t,s.canvasTransform,r,i,s.originX,s.originY,s.drawImageW,s.drawImageH,s.drawImageX,s.drawImageY,s.scale)),!0}fill_(t){const e=this.alignAndScaleFill_;if(e){const i=yt(this.renderedTransform_,[0,0]),s=512*this.pixelRatio;t.save(),t.translate(i[0]%s,i[1]%s),e!==1&&t.scale(e,e),t.rotate(this.viewRotation_)}t.fill(),e&&t.restore()}setStrokeStyle_(t,e){t.strokeStyle=e[1],e[1]&&(t.lineWidth=e[2],t.lineCap=e[3],t.lineJoin=e[4],t.miterLimit=e[5],t.lineDashOffset=e[7],t.setLineDash(e[6]))}drawLabelWithPointPlacement_(t,e,i,s){const r=this.textStates[e],o=this.createLabel(t,e,s,i),a=this.strokeStates[i],l=this.pixelRatio,h=uo(Array.isArray(t)?t[0]:t,r.textAlign||_n),c=Ss[r.textBaseline||fs],u=a&&a.lineWidth?a.lineWidth:0,d=o.width/l-2*r.scale[0],f=h*d+2*(.5-h)*u,g=c*o.height/l+2*(.5-c)*u;return{label:o,anchorX:f,anchorY:g}}execute_(t,e,i,s,r,o,a,l){const h=this.zIndexContext_;let c;this.pixelCoordinates_&&Ce(i,this.renderedTransform_)?c=this.pixelCoordinates_:(this.pixelCoordinates_||(this.pixelCoordinates_=[]),c=Me(this.coordinates,0,this.coordinates.length,2,i,this.pixelCoordinates_),uu(this.renderedTransform_,i));let u=0;const d=s.length;let f=0,g,m,_,p,y,v,x,w,R,T,S,I,M,O=0,L=0;const A=this.coordinateCache_,P=this.viewRotation_,X=Math.round(Math.atan2(-i[1],i[0])*1e12)/1e12,k={context:t,pixelRatio:this.pixelRatio,resolution:this.resolution,rotation:P},G=this.instructions!=s||this.overlaps?0:200;let D,Y,V,tt;for(;u<d;){const b=s[u];switch(b[0]){case F.BEGIN_GEOMETRY:D=b[1],tt=b[3],D.getGeometry()?a!==void 0&&!Pt(a,tt.getExtent())?u=b[2]+1:++u:u=b[2],h&&(h.zIndex=b[4]);break;case F.BEGIN_PATH:O>G&&(this.fill_(t),O=0),L>G&&(t.stroke(),L=0),!O&&!L&&(t.beginPath(),y=NaN,v=NaN),++u;break;case F.CIRCLE:f=b[1];const ft=c[f],ht=c[f+1],bt=c[f+2],Et=c[f+3],jt=bt-ft,Gt=Et-ht,Mt=Math.sqrt(jt*jt+Gt*Gt);t.moveTo(ft+Mt,ht),t.arc(ft,ht,Mt,0,2*Math.PI,!0),++u;break;case F.CLOSE_PATH:t.closePath(),++u;break;case F.CUSTOM:f=b[1],g=b[2];const Pi=b[3],W=b[4],rt=b[5];k.geometry=Pi,k.feature=D,u in A||(A[u]=[]);const j=A[u];rt?rt(c,f,g,2,j):(j[0]=c[f],j[1]=c[f+1],j.length=2),h&&(h.zIndex=b[6]),W(j,k),++u;break;case F.DRAW_IMAGE:f=b[1],g=b[2],R=b[3],m=b[4],_=b[5];let nt=b[6];const mt=b[7],ze=b[8],Di=b[9],Rn=b[10];let ii=b[11];const ki=b[12];let Fi=b[13];p=b[14]||"declutter";const wt=b[15];if(!R&&b.length>=20){T=b[19],S=b[20],I=b[21],M=b[22];const Vt=this.drawLabelWithPointPlacement_(T,S,I,M);R=Vt.label,b[3]=R;const ni=b[23];m=(Vt.anchorX-ni)*this.pixelRatio,b[4]=m;const Zt=b[24];_=(Vt.anchorY-Zt)*this.pixelRatio,b[5]=_,nt=R.height,b[6]=nt,Fi=R.width,b[13]=Fi}let _o;b.length>25&&(_o=b[25]);let mo,Is,Ts;b.length>17?(mo=b[16],Is=b[17],Ts=b[18]):(mo=Qe,Is=null,Ts=null),Rn&&X?ii+=P:!Rn&&!X&&(ii-=P);let p_=0;for(;f<g;f+=2){if(_o&&_o[p_++]<Fi/this.pixelRatio)continue;const Vt=this.calculateImageOrLabelDimensions_(R.width,R.height,c[f],c[f+1],Fi,nt,m,_,ze,Di,ii,ki,r,mo,!!Is||!!Ts,D),ni=[t,e,R,Vt,mt,Is,Ts];if(l){let Zt,le,$t;if(wt){const ut=g-f;if(!wt[ut]){wt[ut]={args:ni,declutterMode:p};continue}const Lt=wt[ut];Zt=Lt.args,le=Lt.declutterMode,delete wt[ut],$t=yh(Zt)}let Ee,we;if(Zt&&(le!=="declutter"||!l.collides($t))&&(Ee=!0),(p!=="declutter"||!l.collides(Vt.declutterBox))&&(we=!0),le==="declutter"&&p==="declutter"){const ut=Ee&&we;Ee=ut,we=ut}Ee&&(le!=="none"&&l.insert($t),this.replayImageOrLabel_.apply(this,Zt)),we&&(p!=="none"&&l.insert(Vt.declutterBox),this.replayImageOrLabel_.apply(this,ni))}else this.replayImageOrLabel_.apply(this,ni)}++u;break;case F.DRAW_CHARS:const vh=b[1],Ch=b[2],po=b[3],y_=b[4];M=b[5];const x_=b[6],Rh=b[7],Sh=b[8];I=b[9];const yo=b[10];T=b[11],Array.isArray(T)&&(T=T.reduce(i_,"")),S=b[12];const Ih=[b[13],b[13]];p=b[14]||"declutter";const E_=b[15],xo=this.textStates[S],Sn=xo.font,In=[xo.scale[0]*Rh,xo.scale[1]*Rh];let Tn;Sn in this.widths_?Tn=this.widths_[Sn]:(Tn={},this.widths_[Sn]=Tn);const Th=Mg(c,vh,Ch,2),bh=Math.abs(In[0])*bl(Sn,T,Tn);if(y_||bh<=Th){const Vt=this.textStates[S].textAlign,ni=(Th-bh)*uo(T,Vt),Zt=t_(c,vh,Ch,2,T,ni,x_,Math.abs(In[0]),bl,Sn,Tn,X?0:this.viewRotation_,E_);t:if(Zt){const le=[];let $t,Ee,we,ut,Lt;if(I)for($t=0,Ee=Zt.length;$t<Ee;++$t){Lt=Zt[$t],we=Lt[4],ut=this.createLabel(we,S,"",I),m=Lt[2]+(In[0]<0?-yo:yo),_=po*ut.height+(.5-po)*2*yo*In[1]/In[0]-Sh;const ve=this.calculateImageOrLabelDimensions_(ut.width,ut.height,Lt[0],Lt[1],ut.width,ut.height,m,_,0,0,Lt[3],Ih,!1,Qe,!1,D);if(l&&p==="declutter"&&l.collides(ve.declutterBox))break t;le.push([t,e,ut,ve,1,null,null])}if(M)for($t=0,Ee=Zt.length;$t<Ee;++$t){Lt=Zt[$t],we=Lt[4],ut=this.createLabel(we,S,M,""),m=Lt[2],_=po*ut.height-Sh;const ve=this.calculateImageOrLabelDimensions_(ut.width,ut.height,Lt[0],Lt[1],ut.width,ut.height,m,_,0,0,Lt[3],Ih,!1,Qe,!1,D);if(l&&p==="declutter"&&l.collides(ve.declutterBox))break t;le.push([t,e,ut,ve,1,null,null])}l&&p!=="none"&&l.load(le.map(yh));for(let ve=0,w_=le.length;ve<w_;++ve)this.replayImageOrLabel_.apply(this,le[ve])}}++u;break;case F.END_GEOMETRY:if(o!==void 0){D=b[1];const Vt=o(D,tt,p);if(Vt)return Vt}++u;break;case F.FILL:G?O++:this.fill_(t),++u;break;case F.MOVE_TO_LINE_TO:for(f=b[1],g=b[2],Y=c[f],V=c[f+1],t.moveTo(Y,V),y=Y+.5|0,v=V+.5|0,f+=2;f<g;f+=2)Y=c[f],V=c[f+1],x=Y+.5|0,w=V+.5|0,(f==g-2||x!==y||w!==v)&&(t.lineTo(Y,V),y=x,v=w);++u;break;case F.SET_FILL_STYLE:this.alignAndScaleFill_=b[2],O&&(this.fill_(t),O=0,L&&(t.stroke(),L=0)),t.fillStyle=b[1],++u;break;case F.SET_STROKE_STYLE:L&&(t.stroke(),L=0),this.setStrokeStyle_(t,b),++u;break;case F.STROKE:G?L++:t.stroke(),++u;break;default:++u;break}}O&&this.fill_(t),L&&t.stroke()}execute(t,e,i,s,r,o){this.viewRotation_=s,this.execute_(t,e,i,this.instructions,r,void 0,void 0,o)}executeHitDetection(t,e,i,s,r){return this.viewRotation_=i,this.execute_(t,[t.canvas.width,t.canvas.height],e,this.hitDetectionInstructions,!0,s,r)}}const ei=["Polygon","Circle","LineString","Image","Text","Default"],Eh=["Image","Text"],s_=ei.filter(n=>!Eh.includes(n));class r_{constructor(t,e,i,s,r,o,a){this.maxExtent_=t,this.overlaps_=s,this.pixelRatio_=i,this.resolution_=e,this.renderBuffer_=o,this.executorsByZIndex_={},this.hitDetectionContext_=null,this.hitDetectionTransform_=qt(),this.renderedContext_=null,this.deferredZIndexContexts_={},this.createExecutors_(r,a)}clip(t,e){const i=this.getClipCoords(e);t.beginPath(),t.moveTo(i[0],i[1]),t.lineTo(i[2],i[3]),t.lineTo(i[4],i[5]),t.lineTo(i[6],i[7]),t.clip()}createExecutors_(t,e){for(const i in t){let s=this.executorsByZIndex_[i];s===void 0&&(s={},this.executorsByZIndex_[i]=s);const r=t[i];for(const o in r){const a=r[o];s[o]=new n_(this.resolution_,this.pixelRatio_,this.overlaps_,a,e)}}}hasExecutors(t){for(const e in this.executorsByZIndex_){const i=this.executorsByZIndex_[e];for(let s=0,r=t.length;s<r;++s)if(t[s]in i)return!0}return!1}forEachFeatureAtCoordinate(t,e,i,s,r,o){s=Math.round(s);const a=s*2+1,l=fe(this.hitDetectionTransform_,s+.5,s+.5,1/e,-1/e,-i,-t[0],-t[1]),h=!this.hitDetectionContext_;h&&(this.hitDetectionContext_=gt(a,a));const c=this.hitDetectionContext_;c.canvas.width!==a||c.canvas.height!==a?(c.canvas.width=a,c.canvas.height=a):h||c.clearRect(0,0,a,a);let u;this.renderBuffer_!==void 0&&(u=Xt(),Zi(u,t),Ks(u,e*(this.renderBuffer_+s),u));const d=o_(s);let f;function g(w,R,T){const S=c.getImageData(0,0,a,a).data;for(let I=0,M=d.length;I<M;I++)if(S[d[I]]>0){if(!o||T==="none"||f!=="Image"&&f!=="Text"||o.includes(w)){const O=(d[I]-3)/4,L=s-O%a,A=s-(O/a|0),P=r(w,R,L*L+A*A);if(P)return P}c.clearRect(0,0,a,a);break}}const m=Object.keys(this.executorsByZIndex_).map(Number);m.sort(ce);let _,p,y,v,x;for(_=m.length-1;_>=0;--_){const w=m[_].toString();for(y=this.executorsByZIndex_[w],p=ei.length-1;p>=0;--p)if(f=ei[p],v=y[f],v!==void 0&&(x=v.executeHitDetection(c,l,i,g,u),x))return x}}getClipCoords(t){const e=this.maxExtent_;if(!e)return null;const i=e[0],s=e[1],r=e[2],o=e[3],a=[i,s,i,o,r,o,r,s];return Me(a,0,8,2,t,a),a}isEmpty(){return ai(this.executorsByZIndex_)}execute(t,e,i,s,r,o,a){const l=Object.keys(this.executorsByZIndex_).map(Number);l.sort(a?cc:ce),o=o||ei;const h=ei.length;for(let c=0,u=l.length;c<u;++c){const d=l[c].toString(),f=this.executorsByZIndex_[d];for(let g=0,m=o.length;g<m;++g){const _=o[g],p=f[_];if(p!==void 0){const y=a===null?void 0:p.getZIndexContext(),v=y?y.getContext():t,x=this.maxExtent_&&_!=="Image"&&_!=="Text";if(x&&(v.save(),this.clip(v,i)),!y||_==="Text"||_==="Image"?p.execute(v,e,i,s,r,a):y.pushFunction(w=>p.execute(w,e,i,s,r,a)),x&&v.restore(),y){y.offset();const w=l[c]*h+ei.indexOf(_);this.deferredZIndexContexts_[w]||(this.deferredZIndexContexts_[w]=[]),this.deferredZIndexContexts_[w].push(y)}}}}this.renderedContext_=t}getDeferredZIndexContexts(){return this.deferredZIndexContexts_}getRenderedContext(){return this.renderedContext_}renderDeferred(){const t=this.deferredZIndexContexts_,e=Object.keys(t).map(Number).sort(ce);for(let i=0,s=e.length;i<s;++i)t[e[i]].forEach(r=>{r.draw(this.renderedContext_),r.clear()}),t[e[i]].length=0}}const fo={};function o_(n){if(fo[n]!==void 0)return fo[n];const t=n*2+1,e=n*n,i=new Array(e+1);for(let r=0;r<=n;++r)for(let o=0;o<=n;++o){const a=r*r+o*o;if(a>e)break;let l=i[a];l||(l=[],i[a]=l),l.push(((n+r)*t+(n+o))*4+3),r>0&&l.push(((n-r)*t+(n+o))*4+3),o>0&&(l.push(((n+r)*t+(n-o))*4+3),r>0&&l.push(((n-r)*t+(n-o))*4+3))}const s=[];for(let r=0,o=i.length;r<o;++r)i[r]&&s.push(...i[r]);return fo[n]=s,s}const ae=.5;function a_(n,t,e,i,s,r,o,a,l){const h=s,c=n[0]*ae,u=n[1]*ae,d=gt(c,u);d.imageSmoothingEnabled=!1;const f=d.canvas,g=new Lg(d,ae,s,null,o,a,null),m=e.length,_=Math.floor((256*256*256-1)/m),p={};for(let v=1;v<=m;++v){const x=e[v-1],w=x.getStyleFunction()||i;if(!w)continue;let R=w(x,r);if(!R)continue;Array.isArray(R)||(R=[R]);const S=(v*_).toString(16).padStart(7,"#00000");for(let I=0,M=R.length;I<M;++I){const O=R[I],L=O.getGeometryFunction()(x);if(!L||!Pt(h,L.getExtent()))continue;const A=O.clone(),P=A.getFill();P&&P.setColor(S);const X=A.getStroke();X&&(X.setColor(S),X.setLineDash(null)),A.setText(void 0);const k=O.getImage();if(k){const V=k.getImageSize();if(!V)continue;const tt=gt(V[0],V[1],void 0,{alpha:!1}),b=tt.canvas;tt.fillStyle=S,tt.fillRect(0,0,b.width,b.height),A.setImage(new xn({img:b,anchor:k.getAnchor(),anchorXUnits:"pixels",anchorYUnits:"pixels",offset:k.getOrigin(),opacity:1,size:k.getSize(),scale:k.getScale(),rotation:k.getRotation(),rotateWithView:k.getRotateWithView()}))}const G=A.getZIndex()||0;let D=p[G];D||(D={},p[G]=D,D.Polygon=[],D.Circle=[],D.LineString=[],D.Point=[]);const Y=L.getType();if(Y==="GeometryCollection"){const V=L.getGeometriesArrayRecursive();for(let tt=0,b=V.length;tt<b;++tt){const xt=V[tt];D[xt.getType().replace("Multi","")].push(xt,A)}}else D[Y.replace("Multi","")].push(L,A)}}const y=Object.keys(p).map(Number).sort(ce);for(let v=0,x=y.length;v<x;++v){const w=p[y[v]];for(const R in w){const T=w[R];for(let S=0,I=T.length;S<I;S+=2){g.setStyle(T[S+1]);for(let M=0,O=t.length;M<O;++M)g.setTransform(t[M]),g.drawGeometry(T[S])}}}return d.getImageData(0,0,f.width,f.height)}function l_(n,t,e){const i=[];if(e){const s=Math.floor(Math.round(n[0])*ae),r=Math.floor(Math.round(n[1])*ae),o=(lt(s,0,e.width-1)+lt(r,0,e.height-1)*e.width)*4,a=e.data[o],l=e.data[o+1],c=e.data[o+2]+256*(l+256*a),u=Math.floor((256*256*256-1)/t.length);c&&c%u===0&&i.push(t[c/u-1])}return i}class h_ extends Ql{constructor(t){super(t),this.boundHandleStyleImageChange_=this.handleStyleImageChange_.bind(this),this.animatingOrInteracting_,this.hitDetectionImageData_=null,this.clipped_=!1,this.renderedFeatures_=null,this.renderedRevision_=-1,this.renderedResolution_=NaN,this.renderedExtent_=Xt(),this.wrappedRenderedExtent_=Xt(),this.renderedRotation_,this.renderedCenter_=null,this.renderedProjection_=null,this.renderedPixelRatio_=1,this.renderedRenderOrder_=null,this.renderedFrameDeclutter_,this.replayGroup_=null,this.replayGroupChanged=!0,this.clipping=!0,this.targetContext_=null,this.opacity_=1}renderWorlds(t,e,i){const s=e.extent,r=e.viewState,o=r.center,a=r.resolution,l=r.projection,h=r.rotation,c=l.getExtent(),u=this.getLayer().getSource(),d=this.getLayer().getDeclutter(),f=e.pixelRatio,g=e.viewHints,m=!(g[St.ANIMATING]||g[St.INTERACTING]),_=this.context,p=Math.round(et(s)/a*f),y=Math.round(It(s)/a*f),v=u.getWrapX()&&l.canWrapX(),x=v?et(c):null,w=v?Math.ceil((s[2]-c[2])/x)+1:1;let R=v?Math.floor((s[0]-c[0])/x):0;do{let T=this.getRenderTransform(o,a,0,f,p,y,R*x);e.declutter&&(T=T.slice(0)),t.execute(_,[_.canvas.width,_.canvas.height],T,h,m,i===void 0?ei:i?Eh:s_,i?d&&e.declutter[d]:void 0)}while(++R<w)}setDrawContext_(){this.opacity_!==1&&(this.targetContext_=this.context,this.context=gt(this.context.canvas.width,this.context.canvas.height,Jl))}resetDrawContext_(){if(this.opacity_!==1&&this.targetContext_){const t=this.targetContext_.globalAlpha;this.targetContext_.globalAlpha=this.opacity_,this.targetContext_.drawImage(this.context.canvas,0,0),this.targetContext_.globalAlpha=t,as(this.context),Jl.push(this.context.canvas),this.context=this.targetContext_,this.targetContext_=null}}renderDeclutter(t){!this.replayGroup_||!this.getLayer().getDeclutter()||this.renderWorlds(this.replayGroup_,t,!0)}renderDeferredInternal(t){this.replayGroup_&&(this.replayGroup_.renderDeferred(),this.clipped_&&this.context.restore(),this.resetDrawContext_())}renderFrame(t,e){const i=t.layerStatesArray[t.layerIndex];this.opacity_=i.opacity;const s=t.viewState;this.prepareContainer(t,e);const r=this.context,o=this.replayGroup_;let a=o&&!o.isEmpty();if(!a&&!(this.getLayer().hasListener(Bt.PRERENDER)||this.getLayer().hasListener(Bt.POSTRENDER)))return this.container;if(this.setDrawContext_(),this.preRender(r,t),s.projection,this.clipped_=!1,a&&i.extent&&this.clipping){const l=be(i.extent);a=Pt(l,t.extent),this.clipped_=a&&!ji(l,t.extent),this.clipped_&&this.clipUnrotated(r,t,l)}return a&&this.renderWorlds(o,t,this.getLayer().getDeclutter()?!1:void 0),!t.declutter&&this.clipped_&&r.restore(),this.postRender(r,t),this.renderedRotation_!==s.rotation&&(this.renderedRotation_=s.rotation,this.hitDetectionImageData_=null),t.declutter||this.resetDrawContext_(),this.container}getFeatures(t){return new Promise(e=>{if(this.frameState&&!this.hitDetectionImageData_&&!this.animatingOrInteracting_){const i=this.frameState.size.slice(),s=this.renderedCenter_,r=this.renderedResolution_,o=this.renderedRotation_,a=this.renderedProjection_,l=this.wrappedRenderedExtent_,h=this.getLayer(),c=[],u=i[0]*ae,d=i[1]*ae;c.push(this.getRenderTransform(s,r,o,ae,u,d,0).slice());const f=h.getSource(),g=a.getExtent();if(f.getWrapX()&&a.canWrapX()&&!ji(g,l)){let m=l[0];const _=et(g);let p=0,y;for(;m<g[0];)--p,y=_*p,c.push(this.getRenderTransform(s,r,o,ae,u,d,y).slice()),m+=_;for(p=0,m=l[2];m>g[2];)++p,y=_*p,c.push(this.getRenderTransform(s,r,o,ae,u,d,y).slice()),m-=_}this.hitDetectionImageData_=a_(i,c,this.renderedFeatures_,h.getStyleFunction(),l,r,o,hh(r,this.renderedPixelRatio_))}e(l_(t,this.renderedFeatures_,this.hitDetectionImageData_))})}forEachFeatureAtCoordinate(t,e,i,s,r){if(!this.replayGroup_)return;const o=e.viewState.resolution,a=e.viewState.rotation,l=this.getLayer(),h={},c=function(d,f,g){const m=q(d),_=h[m];if(_){if(_!==!0&&g<_.distanceSq){if(g===0)return h[m]=!0,r.splice(r.lastIndexOf(_),1),s(d,l,f);_.geometry=f,_.distanceSq=g}}else{if(g===0)return h[m]=!0,s(d,l,f);r.push(h[m]={feature:d,layer:l,geometry:f,distanceSq:g,callback:s})}},u=this.getLayer().getDeclutter();return this.replayGroup_.forEachFeatureAtCoordinate(t,o,a,i,c,u?e.declutter?.[u]?.all().map(d=>d.value):null)}handleFontsChanged(){const t=this.getLayer();t.getVisible()&&this.replayGroup_&&t.changed()}handleStyleImageChange_(t){this.renderIfReadyAndVisible()}prepareFrame(t){const e=this.getLayer(),i=e.getSource();if(!i)return!1;const s=t.viewHints[St.ANIMATING],r=t.viewHints[St.INTERACTING],o=e.getUpdateWhileAnimating(),a=e.getUpdateWhileInteracting();if(this.ready&&!o&&s||!a&&r)return this.animatingOrInteracting_=!0,!0;this.animatingOrInteracting_=!1;const l=t.extent,h=t.viewState,c=h.projection,u=h.resolution,d=t.pixelRatio,f=e.getRevision(),g=e.getRenderBuffer();let m=e.getRenderOrder();m===void 0&&(m=Og);const _=h.center.slice(),p=Ks(l,g*u),y=p.slice(),v=[p.slice()],x=c.getExtent();if(i.getWrapX()&&c.canWrapX()&&!ji(x,t.extent)){const P=et(x),X=Math.max(et(p)/2,P);p[0]=x[0]-X,p[2]=x[2]+X,pa(_,c);const k=_a(v[0],c);k[0]<x[0]&&k[2]<x[2]?v.push([k[0]+P,k[1],k[2]+P,k[3]]):k[0]>x[0]&&k[2]>x[2]&&v.push([k[0]-P,k[1],k[2]-P,k[3]])}if(this.ready&&this.renderedResolution_==u&&this.renderedRevision_==f&&this.renderedRenderOrder_==m&&this.renderedFrameDeclutter_===!!t.declutter&&ji(this.wrappedRenderedExtent_,p))return Ce(this.renderedExtent_,y)||(this.hitDetectionImageData_=null,this.renderedExtent_=y),this.renderedCenter_=_,this.replayGroupChanged=!1,!0;this.replayGroup_=null;const w=new Qg(ch(u,d),p,u,d);let R;for(let P=0,X=v.length;P<X;++P)i.loadFeatures(v[P],u,c);const T=hh(u,d);let S=!0;const I=(P,X)=>{let k;const G=P.getStyleFunction()||e.getStyleFunction();if(G&&(k=G(P,u)),k){const D=this.renderFeature(P,T,k,w,R,this.getLayer().getDeclutter(),X);S=S&&!D}},M=Fa(p),O=i.getFeaturesInExtent(M);m&&O.sort(m);for(let P=0,X=O.length;P<X;++P)I(O[P],P);this.renderedFeatures_=O,this.ready=S;const L=w.finish(),A=new r_(p,u,d,i.getOverlaps(),L,e.getRenderBuffer(),!!t.declutter);return this.renderedResolution_=u,this.renderedRevision_=f,this.renderedRenderOrder_=m,this.renderedFrameDeclutter_=!!t.declutter,this.renderedExtent_=y,this.wrappedRenderedExtent_=p,this.renderedCenter_=_,this.renderedProjection_=c,this.renderedPixelRatio_=d,this.replayGroup_=A,this.hitDetectionImageData_=null,this.replayGroupChanged=!0,!0}renderFeature(t,e,i,s,r,o,a){if(!i)return!1;let l=!1;if(Array.isArray(i))for(let h=0,c=i.length;h<c;++h)l=uh(s,t,i[h],e,this.boundHandleStyleImageChange_,r,o,a)||l;else l=uh(s,t,i,e,this.boundHandleStyleImageChange_,r,o,a);return l}}class c_ extends Xl{constructor(t){super(t)}createRenderer(){return new h_(this)}}function u_({latitude:n,longitude:t,name:e,address:i,url:s,timestamp:r,isFromCustomer:o}){const a=Xi(null),l=Xi(null);ee(()=>{if(!a.current)return;const u=hu([t,n]),d=new co({geometry:new is(u)});d.setStyle(new Oe({image:new xn({anchor:[.5,1],src:"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='%23ef4444' stroke='white' stroke-width='2'%3E%3Cpath d='M21 10c0 7-9 13-9 13s-9-6-9-13a9 9 0 0 1 18 0z'%3E%3C/path%3E%3Ccircle cx='12' cy='10' r='3' fill='white'%3E%3C/circle%3E%3C/svg%3E",scale:1.5})}));const f=new jg({features:[d]}),g=new c_({source:f}),m=new Gf({target:a.current,layers:[new ag({source:new Tg}),g],view:new re({center:u,zoom:15}),controls:[]});return l.current=m,()=>{m.setTarget(void 0),l.current=null}},[n,t]);const h=`https://www.google.com/maps?q=${n},${t}`,c=`https://www.openstreetmap.org/?mlat=${n}&mlon=${t}&zoom=15`;return E("div",{class:`flex ${o?"justify-end":"justify-start"} mb-3`,children:E("div",{class:`max-w-[75%] rounded-lg ${o?"bg-blue-600 text-white":"bg-white border border-zinc-200 text-zinc-900"}`,children:E("div",{class:"p-2",children:[E("div",{ref:a,class:"w-full h-32 rounded border border-zinc-300"}),(e||i)&&E("div",{class:"mt-2",children:[e&&E("p",{class:`text-sm font-medium ${o?"text-white":"text-zinc-900"}`,children:e}),i&&E("p",{class:`text-xs ${o?"text-blue-100":"text-zinc-500"}`,children:i})]}),E("div",{class:"flex items-center gap-1 mt-2",children:[E("svg",{class:`w-3 h-3 ${o?"text-blue-100":"text-zinc-500"}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[E("title",{children:"Pin"}),E("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M17.657 16.657L13.414 20.9a1.998 1.998 0 01-2.827 0l-4.244-4.243a8 8 0 1111.314 0z"}),E("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M15 11a3 3 0 11-6 0 3 3 0 016 0z"})]}),E("span",{class:`text-xs ${o?"text-blue-100":"text-zinc-500"}`,children:[n.toFixed(6),", ",t.toFixed(6)]})]}),s&&E("a",{href:s,target:"_blank",rel:"noopener noreferrer",class:`block mt-2 text-xs px-2 py-1 rounded border text-center transition-colors ${o?"border-blue-400 hover:bg-blue-500":"border-zinc-300 hover:bg-zinc-50"}`,children:"Visit Website"}),E("div",{class:"flex gap-2 mt-2",children:[E("a",{href:h,target:"_blank",rel:"noopener noreferrer",class:`flex-1 text-xs px-2 py-1 rounded border text-center transition-colors ${o?"border-blue-400 hover:bg-blue-500":"border-zinc-300 hover:bg-zinc-50"}`,children:"Google Maps"}),E("a",{href:c,target:"_blank",rel:"noopener noreferrer",class:`flex-1 text-xs px-2 py-1 rounded border text-center transition-colors ${o?"border-blue-400 hover:bg-blue-500":"border-zinc-300 hover:bg-zinc-50"}`,children:"OpenStreetMap"})]}),E("span",{class:`text-xs mt-2 block ${o?"text-blue-100":"text-zinc-500"}`,children:new Date(r).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})})]})})})}function d_({messages:n}){const t=Xi(null),e=sc({count:n.length,getScrollElement:()=>t.current,estimateSize:()=>192,overscan:5});ee(()=>{n.length>0&&e.scrollToIndex(n.length-1,{align:"end"})},[n.length]);const i=r=>{const o={timestamp:r.timestamp,isFromCustomer:!r.isSupport};switch(r.type){case"text":return E(rc,{content:r.content||"",...o});case"photo":return E(oc,{url:r.url||"",filename:r.filename,size:r.size,caption:r.content,...o});case"video":return E(ac,{url:r.url||"",filename:r.filename,size:r.size,caption:r.content,...o});case"file":return E(lc,{url:r.url||"",filename:r.filename||"file",size:r.size,mimeType:r.mimeType,...o});case"location":return E(u_,{latitude:r.latitude||0,longitude:r.longitude||0,name:r.name,address:r.address,...o});default:return null}},s=e.getVirtualItems();return E("div",{ref:t,class:"flex-1 overflow-y-auto p-4",children:E("div",{style:{height:`${e.getTotalSize()}px`,width:"100%",position:"relative"},children:s.map(r=>{const o=n[r.index];return o?E("div",{"data-index":r.index,ref:e.measureElement,style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${r.start}px)`},children:i(o)},r.key):null})})})}function f_(){const{isOpen:n,inputMessage:t,isSending:e,showPlatformChoice:i,showNamePrompt:s,isInitialized:r,availablePlatforms:o,showAttachmentMenu:a,customerName:l,messages:h,isLoadingMessages:c,toggleChat:u,setInputMessage:d,sendMessage:f,selectPlatform:g,goBackToPlatforms:m,initializeWidgetSession:_,toggleAttachmentMenu:p,handleGalleryUpload:y,handleFileUpload:v,handleLocationShare:x}=Uh(),w=R=>{R.preventDefault(),f()};return E("div",{class:"fixed bottom-6 right-6 z-2147483647 font-sans",children:[!n&&E("button",{type:"button",onClick:u,class:"w-14 h-14 bg-blue-600 hover:bg-blue-700 text-white rounded-full shadow-lg flex items-center justify-center transition-all",children:E("svg",{class:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:E("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M8 10h.01M12 10h.01M16 10h.01M9 16H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-5l-5 5v-5z"})})}),n&&E("div",{class:"w-96 h-[600px] bg-white rounded-lg shadow-[0_0_20px_rgba(0,0,0,0.15)] flex flex-col border border-zinc-200",children:[E("div",{class:"p-4 flex items-center gap-3 border-b border-zinc-200",children:[E("button",{type:"button",onClick:m,class:"p-1 hover:bg-zinc-100 rounded transition-colors",children:E("svg",{class:"w-5 h-5 text-zinc-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:E("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M15 19l-7-7 7-7"})})}),E("div",{class:"flex-1 min-w-0",children:E("h2",{class:"font-semibold text-zinc-900 truncate",children:["Support Chat for ",l||"Guest"]})}),E("button",{type:"button",onClick:u,class:"p-1 hover:bg-zinc-100 rounded transition-colors shrink-0",children:E("svg",{class:"w-5 h-5 text-zinc-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:E("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M6 18L18 6M6 6l12 12"})})})]}),i&&E("div",{class:"p-6 flex flex-col gap-4",children:[E("h3",{class:"text-lg font-semibold text-zinc-900",children:"Choose how to contact us"}),E("p",{class:"text-sm text-zinc-600",children:"Select your preferred platform to chat with our support team."}),E("div",{class:"space-y-2",children:o.map(R=>E("button",{type:"button",onClick:()=>g(R),class:"w-full flex items-center gap-3 p-4 border-2 border-zinc-200 hover:border-blue-500 hover:bg-blue-50 rounded-lg transition-all text-left",children:[E("div",{class:"w-10 h-10 flex items-center justify-center rounded-full bg-zinc-100",children:[R.type==="telegram"&&E("svg",{class:"w-6 h-6 text-blue-500",fill:"currentColor",viewBox:"0 0 24 24",children:E("path",{d:"M12 0C5.373 0 0 5.373 0 12s5.373 12 12 12 12-5.373 12-12S18.627 0 12 0zm5.562 8.161c-.18 1.897-.962 6.502-1.359 8.627-.168.9-.5 1.201-.82 1.23-.697.064-1.226-.461-1.901-.903-1.056-.692-1.653-1.123-2.678-1.799-1.185-.781-.417-1.21.258-1.911.177-.184 3.247-2.977 3.307-3.23.007-.032.014-.15-.056-.212s-.174-.041-.249-.024c-.106.024-1.793 1.139-5.062 3.345-.479.329-.913.489-1.302.481-.428-.008-1.252-.241-1.865-.44-.752-.244-1.349-.374-1.297-.789.027-.216.325-.437.893-.663 3.498-1.524 5.831-2.529 6.998-3.014 3.332-1.386 4.025-1.627 4.476-1.635.099-.002.321.023.465.141.121.099.155.232.171.326.016.094.036.308.02.475z"})}),R.type==="discord"&&E("svg",{class:"w-6 h-6 text-indigo-500",fill:"currentColor",viewBox:"0 0 24 24",children:E("path",{d:"M20.317 4.37a19.791 19.791 0 0 0-4.885-1.515a.074.074 0 0 0-.079.037c-.21.375-.444.864-.608 1.25a18.27 18.27 0 0 0-5.487 0a12.64 12.64 0 0 0-.617-1.25a.077.077 0 0 0-.079-.037A19.736 19.736 0 0 0 3.677 4.37a.07.07 0 0 0-.032.027C.533 9.046-.32 13.58.099 18.057a.082.082 0 0 0 .031.057a19.9 19.9 0 0 0 5.993 3.03a.078.078 0 0 0 .084-.028a14.09 14.09 0 0 0 1.226-1.994a.076.076 0 0 0-.041-.106a13.107 13.107 0 0 1-1.872-.892a.077.077 0 0 1-.008-.128a10.2 10.2 0 0 0 .372-.292a.074.074 0 0 1 .077-.01c3.928 1.793 8.18 1.793 12.062 0a.074.074 0 0 1 .078.01c.12.098.246.198.373.292a.077.077 0 0 1-.006.127a12.299 12.299 0 0 1-1.873.892a.077.077 0 0 0-.041.107c.36.698.772 1.362 1.225 1.993a.076.076 0 0 0 .084.028a19.839 19.839 0 0 0 6.002-3.03a.077.077 0 0 0 .032-.054c.5-5.177-.838-9.674-3.549-13.66a.061.061 0 0 0-.031-.03zM8.02 15.33c-1.183 0-2.157-1.085-2.157-2.419c0-1.333.956-2.419 2.157-2.419c1.21 0 2.176 1.096 2.157 2.42c0 1.333-.956 2.418-2.157 2.418zm7.975 0c-1.183 0-2.157-1.085-2.157-2.419c0-1.333.955-2.419 2.157-2.419c1.21 0 2.176 1.096 2.157 2.42c0 1.333-.946 2.418-2.157 2.418z"})}),R.type==="widget"&&E("svg",{class:"w-6 h-6 text-blue-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:E("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M8 10h.01M12 10h.01M16 10h.01M9 16H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-5l-5 5v-5z"})})]}),E("div",{class:"flex-1",children:[E("div",{class:"font-medium text-zinc-900",children:R.name}),E("div",{class:"text-xs text-zinc-500",children:R.type==="widget"?"Chat directly on this website":"Opens in new tab"})]}),E("svg",{class:"w-5 h-5 text-zinc-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:E("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M9 5l7 7-7 7"})})]},R.type))})]}),s&&E("div",{class:"p-6 flex flex-col gap-4",children:[E("h3",{class:"text-lg font-semibold text-zinc-900",children:"Welcome!"}),E("p",{class:"text-sm text-zinc-600",children:"Please enter your details to start chatting."}),E("form",{onSubmit:R=>{R.preventDefault();const T=new FormData(R.currentTarget),S=T.get("name"),I=T.get("email");_(S,I)},class:"space-y-3",children:[E("input",{type:"text",name:"name",placeholder:"Your name",required:!0,class:"w-full px-4 py-2 border border-zinc-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500"}),E("input",{type:"email",name:"email",placeholder:"Email (optional)",class:"w-full px-4 py-2 border border-zinc-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500"}),E("div",{class:"flex gap-2 pt-2",children:[E("button",{type:"button",onClick:m,class:"flex-1 px-4 py-2 border border-zinc-300 rounded-lg hover:bg-zinc-50 transition-colors",children:"Back"}),E("button",{type:"submit",class:"flex-1 px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors",children:"Start Chat"})]})]})]}),r&&E(zi,{children:[c?E("div",{class:"flex-1 flex items-center justify-center text-zinc-500",children:E("div",{class:"text-center",children:[E("div",{class:"w-8 h-8 border-2 border-blue-600 border-t-transparent rounded-full animate-spin mx-auto mb-2"}),E("p",{class:"text-sm",children:"Loading messages..."})]})}):E(d_,{messages:h}),a&&E("div",{class:"px-4 pb-3 flex gap-2",children:[E("button",{type:"button",onClick:y,disabled:e,class:"flex-1 flex flex-col items-center gap-1 p-3 border border-zinc-200 rounded-lg hover:bg-zinc-50 disabled:opacity-50 transition-colors",children:[E("svg",{class:"w-6 h-6 text-blue-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:E("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"})}),E("span",{class:"text-xs text-zinc-700",children:"Photo/Video"})]}),E("button",{type:"button",onClick:v,disabled:e,class:"flex-1 flex flex-col items-center gap-1 p-3 border border-zinc-200 rounded-lg hover:bg-zinc-50 disabled:opacity-50 transition-colors",children:[E("svg",{class:"w-6 h-6 text-green-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:E("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})}),E("span",{class:"text-xs text-zinc-700",children:"File"})]}),E("button",{type:"button",onClick:x,disabled:e,class:"flex-1 flex flex-col items-center gap-1 p-3 border border-zinc-200 rounded-lg hover:bg-zinc-50 disabled:opacity-50 transition-colors",children:[E("svg",{class:"w-6 h-6 text-red-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[E("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M17.657 16.657L13.414 20.9a1.998 1.998 0 01-2.827 0l-4.244-4.243a8 8 0 1111.314 0z"}),E("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M15 11a3 3 0 11-6 0 3 3 0 016 0z"})]}),E("span",{class:"text-xs text-zinc-700",children:"Location"})]})]}),E("div",{class:"border-t border-zinc-200",children:E("form",{onSubmit:w,class:"flex items-center px-4 py-3",children:[E("button",{type:"button",onClick:p,disabled:e,class:"p-1 hover:bg-zinc-50 disabled:opacity-50 transition-colors",children:E("svg",{class:"w-5 h-5 text-zinc-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:E("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 4v16m8-8H4"})})}),E("input",{type:"text",value:t,onInput:R=>d(R.target.value),placeholder:"Type a message...",disabled:e,class:"flex-1 px-2 py-2 focus:outline-none disabled:opacity-50 placeholder:text-zinc-300"}),E("button",{type:"submit",disabled:e||!t.trim(),class:"p-1 hover:bg-zinc-50 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:E("img",{src:Kh,alt:"Send",class:"w-5 h-5"})})]})})]})]})]})}const wh=document.querySelector("script[data-api-key]"),g_=wh?.getAttribute("data-api-key")||"",__=wh?.getAttribute("data-api-url")||"https://useconverge.app/api/widget",m_={apiKey:g_,apiUrl:__},go=document.createElement("div");go.id="__converge-chat-widget",document.body.appendChild(go),kh(E(Bh,{config:m_,children:E(f_,{})}),go),window.ConvergeChat={}}));
|