From 42f899531f4467c8a7e5642732fab9f1360523c6 Mon Sep 17 00:00:00 2001 From: eisserer Date: Tue, 17 Sep 2024 14:42:51 +0200 Subject: [PATCH] PWA improvements --- docs/assets/index-BK-nidoD.js | 68 ++++ docs/assets/index-BK-nidoD.js.map | 1 + docs/assets/index-BTt4wF4e.js | 40 --- docs/assets/index-BTt4wF4e.js.map | 1 - docs/hofapp-192.png | Bin 59449 -> 45972 bytes docs/index.html | 15 +- docs/sw.js | 2 +- docs/sw.js.map | 2 +- index.html | 13 +- main.js | 506 ++++++++++++++++++++++++------ package.json | 4 +- public/hofapp-192.png | Bin 59449 -> 45972 bytes sw.js | 86 +++++ vite.config.js | 4 +- yarn.lock | 7 +- 15 files changed, 587 insertions(+), 162 deletions(-) create mode 100644 docs/assets/index-BK-nidoD.js create mode 100644 docs/assets/index-BK-nidoD.js.map delete mode 100644 docs/assets/index-BTt4wF4e.js delete mode 100644 docs/assets/index-BTt4wF4e.js.map create mode 100644 sw.js diff --git a/docs/assets/index-BK-nidoD.js b/docs/assets/index-BK-nidoD.js new file mode 100644 index 0000000..0c078f3 --- /dev/null +++ b/docs/assets/index-BK-nidoD.js @@ -0,0 +1,68 @@ +(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))n(o);new MutationObserver(o=>{for(const l of o)if(l.type==="childList")for(const u of l.addedNodes)u.tagName==="LINK"&&u.rel==="modulepreload"&&n(u)}).observe(document,{childList:!0,subtree:!0});function e(o){const l={};return o.integrity&&(l.integrity=o.integrity),o.referrerPolicy&&(l.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?l.credentials="include":o.crossOrigin==="anonymous"?l.credentials="omit":l.credentials="same-origin",l}function n(o){if(o.ep)return;o.ep=!0;const l=e(o);fetch(o.href,l)}})();class hs{constructor(t){this.propagationStopped,this.defaultPrevented,this.type=t,this.target=null}preventDefault(){this.defaultPrevented=!0}stopPropagation(){this.propagationStopped=!0}}const Nr={PROPERTYCHANGE:"propertychange"};class Nh{constructor(){this.disposed=!1}dispose(){this.disposed||(this.disposed=!0,this.disposeInternal())}disposeInternal(){}}function j1(r,t,e){let n,o;e=e||ss;let l=0,u=r.length,g=!1;for(;l>1),o=+e(r[n],t),o<0?l=n+1:(u=n,g=!o);return g?l:~l}function ss(r,t){return r>t?1:r0?o-1:o}return n-1}if(e>0){for(let o=1;o0||e&&u===0)})}function go(){return!0}function ka(){return!1}function Pr(){}function Hu(r){let t=!1,e,n,o;return function(){const l=Array.prototype.slice.call(arguments);return(!t||this!==o||!Ls(l,n))&&(t=!0,o=this,n=l,e=r.apply(this,arguments)),e}}function q1(r){function t(){let e;try{e=r()}catch(n){return Promise.reject(n)}return e instanceof Promise?e:Promise.resolve(e)}return t()}function No(r){for(const t in r)delete r[t]}function er(r){let t;for(t in r)return!1;return!t}class Ga extends Nh{constructor(t){super(),this.eventTarget_=t,this.pendingRemovals_=null,this.dispatching_=null,this.listeners_=null}addEventListener(t,e){if(!t||!e)return;const n=this.listeners_||(this.listeners_={}),o=n[t]||(n[t]=[]);o.includes(e)||o.push(e)}dispatchEvent(t){const e=typeof t=="string",n=e?t:t.type,o=this.listeners_&&this.listeners_[n];if(!o)return;const l=e?new hs(t):t;l.target||(l.target=this.eventTarget_||this);const u=this.dispatching_||(this.dispatching_={}),g=this.pendingRemovals_||(this.pendingRemovals_={});n in u||(u[n]=0,g[n]=0),++u[n];let x;for(let E=0,w=o.length;E0:!1}removeEventListener(t,e){if(!this.listeners_)return;const n=this.listeners_[t];if(!n)return;const o=n.indexOf(e);o!==-1&&(this.pendingRemovals_&&t in this.pendingRemovals_?(n[o]=Pr,++this.pendingRemovals_[t]):(n.splice(o,1),n.length===0&&delete this.listeners_[t]))}}const jt={CHANGE:"change",ERROR:"error",BLUR:"blur",CLEAR:"clear",CONTEXTMENU:"contextmenu",CLICK:"click",DBLCLICK:"dblclick",DRAGENTER:"dragenter",DRAGOVER:"dragover",DROP:"drop",FOCUS:"focus",KEYDOWN:"keydown",KEYPRESS:"keypress",LOAD:"load",RESIZE:"resize",TOUCHMOVE:"touchmove",WHEEL:"wheel"};function ge(r,t,e,n,o){if(n&&n!==r&&(e=e.bind(n)),o){const u=e;e=function(){r.removeEventListener(t,e),u.apply(this,arguments)}}const l={target:r,type:t,listener:e};return r.addEventListener(t,e),l}function wa(r,t,e,n){return ge(r,t,e,n,!0)}function Fe(r){r&&r.target&&(r.target.removeEventListener(r.type,r.listener),No(r))}class Po extends Ga{constructor(){super(),this.on=this.onInternal,this.once=this.onceInternal,this.un=this.unInternal,this.revision_=0}changed(){++this.revision_,this.dispatchEvent(jt.CHANGE)}getRevision(){return this.revision_}onInternal(t,e){if(Array.isArray(t)){const n=t.length,o=new Array(n);for(let l=0;l0;)this.pop()}extend(t){for(let e=0,n=t.length;ethis.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 na(Hi.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 n=0,o=e.length;n=this.getLength())return;const e=this.array_[t];return this.array_.splice(t,1),this.updateLength_(),this.dispatchEvent(new na(Hi.REMOVE,e,t)),e}setAt(t,e){const n=this.getLength();if(t>=n){this.insertAt(t,e);return}if(t<0)throw new Error("Index out of bounds: "+t);this.unique_&&this.assertUnique_(e,t);const o=this.array_[t];this.array_[t]=e,this.dispatchEvent(new na(Hi.REMOVE,o,t)),this.dispatchEvent(new na(Hi.ADD,e,t))}updateLength_(){this.set(Dc.LENGTH,this.array_.length)}assertUnique_(t,e){for(let n=0,o=this.array_.length;nMath.round(e*Lc[n])/Lc[n]).join(", ")+")"}const yi={UNKNOWN:0,INTERSECTING:1,ABOVE:2,RIGHT:4,BELOW:8,LEFT:16};function Fc(r){const t=mn();for(let e=0,n=r.length;eo&&(x=x|yi.RIGHT),gl&&(x=x|yi.ABOVE),x===yi.UNKNOWN&&(x=yi.INTERSECTING),x}function mn(){return[1/0,1/0,-1/0,-1/0]}function Os(r,t,e,n,o){return o?(o[0]=r,o[1]=t,o[2]=e,o[3]=n,o):[r,t,e,n]}function Do(r){return Os(1/0,1/0,-1/0,-1/0,r)}function Ku(r,t){const e=r[0],n=r[1];return Os(e,n,e,n,t)}function Fh(r,t,e,n,o){const l=Do(o);return Ju(l,r,t,e,n)}function mo(r,t){return r[0]==t[0]&&r[2]==t[2]&&r[1]==t[1]&&r[3]==t[3]}function qu(r,t){return t[0]r[2]&&(r[2]=t[2]),t[1]r[3]&&(r[3]=t[3]),r}function ho(r,t){t[0]r[2]&&(r[2]=t[0]),t[1]r[3]&&(r[3]=t[1])}function Ju(r,t,e,n,o){for(;et[0]?n[0]=r[0]:n[0]=t[0],r[1]>t[1]?n[1]=r[1]:n[1]=t[1],r[2]=t[0]&&r[1]<=t[3]&&r[3]>=t[1]}function Xa(r){return r[2]=u&&F<=x),!n&&l&yi.RIGHT&&!(o&yi.RIGHT)&&(V=P-(S-x)*L,n=V>=g&&V<=E),!n&&l&yi.BELOW&&!(o&yi.BELOW)&&(F=S-(P-g)/L,n=F>=u&&F<=x),!n&&l&yi.LEFT&&!(o&yi.LEFT)&&(V=P-(S-u)*L,n=V>=g&&V<=E)}return n}function $u(r,t){const e=t.getExtent(),n=Ns(r);if(t.canWrapX()&&(n[0]=e[2])){const o=Ce(e),u=Math.floor((n[0]-e[0])/o)*o;r[0]-=u,r[2]-=u}return r}function t0(r,t,e){if(t.canWrapX()){const n=t.getExtent();if(!isFinite(r[0])||!isFinite(r[2]))return[[n[0],r[1],n[2],r[3]]];$u(r,t);const o=Ce(n);if(Ce(r)>o&&!e)return[[n[0],r[1],n[2],r[3]]];if(r[0]n[2])return[[r[0],r[1],n[2],r[3]],[n[0],r[1],r[2]-o,r[3]]]}return[r]}const xo={radians:6370997/(2*Math.PI),degrees:2*Math.PI*6370997/360,ft:.3048,m:1,"us-ft":1200/3937};class lf{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_||xo[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 Bh=lf,Lo=6378137,Tr=Math.PI*Lo,hf=[-Tr,-Tr,Tr,Tr],cf=[-180,-85,180,85],sa=Lo*Math.log(Math.tan(Math.PI/2));class pr extends Bh{constructor(t){super({code:t,units:"m",extent:hf,global:!0,worldExtent:cf,getPointResolution:function(e,n){return e/Math.cosh(n[1]/Lo)}})}}const Bc=[new pr("EPSG:3857"),new pr("EPSG:102100"),new pr("EPSG:102113"),new pr("EPSG:900913"),new pr("http://www.opengis.net/def/crs/EPSG/0/3857"),new pr("http://www.opengis.net/gml/srs/epsg.xml#3857")];function uf(r,t,e){const n=r.length;e=e>1?e:2,t===void 0&&(e>2?t=r.slice():t=new Array(n));for(let o=0;osa?l=sa:l<-sa&&(l=-sa),t[o+1]=l}return t}function ff(r,t,e){const n=r.length;e=e>1?e:2,t===void 0&&(e>2?t=r.slice():t=new Array(n));for(let o=0;o1?(e=o,n=l):x>0&&(e+=u*x,n+=g*x)}return $s(r,t,e,n)}function $s(r,t,e,n){const o=e-r,l=n-t;return o*o+l*l}function pf(r){const t=r.length;for(let n=0;nl&&(l=x,o=g)}if(l===0)return null;const u=r[o];r[o]=r[n],r[n]=u;for(let g=n+1;g=0;n--){e[n]=r[n][t]/r[n][n];for(let o=n-1;o>=0;o--)r[o][t]-=r[o][n]*e[n]}return e}function pa(r){return r*Math.PI/180}function vr(r,t){const e=r%t;return e*t<0?e+t:e}function en(r,t,e){return r+e*(t-r)}function kh(r,t){const e=Math.pow(10,t);return Math.round(r*e)/e}function ra(r,t){return Math.floor(kh(r,t))}function oa(r,t){return Math.ceil(kh(r,t))}function Qr(r,t,e){const n=e!==void 0?r.toFixed(e):""+r;let o=n.indexOf(".");return o=o===-1?n.length:o,o>t?n:new Array(1+t-o).join("0")+n}function yf(r,t){return r[0]+=+t[0],r[1]+=+t[1],r}function Ea(r,t){let e=!0;for(let n=r.length-1;n>=0;--n)if(r[n]!=t[n]){e=!1;break}return e}function Gh(r,t){const e=Math.cos(t),n=Math.sin(t),o=r[0]*e-r[1]*n,l=r[1]*e+r[0]*n;return r[0]=o,r[1]=l,r}function wf(r,t){return r[0]*=t,r[1]*=t,r}function i0(r,t){if(t.canWrapX()){const e=Ce(t.getExtent()),n=n0(r,t,e);n&&(r[0]-=n*e)}return r}function n0(r,t,e){const n=t.getExtent();let o=0;return t.canWrapX()&&(r[0]n[2])&&(e=e||Ce(n),o=Math.floor((r[0]-n[0])/e)),o}const Ef=63710088e-1;function Uc(r,t,e){e=e||Ef;const n=pa(r[1]),o=pa(t[1]),l=(o-n)/2,u=pa(t[0]-r[0])/2,g=Math.sin(l)*Math.sin(l)+Math.sin(u)*Math.sin(u)*Math.cos(n)*Math.cos(o);return 2*e*Math.atan2(Math.sqrt(g),Math.sqrt(1-g))}function s0(...r){console.warn(...r)}let hh=!0;function Cf(r){hh=!(r===void 0?!0:r)}function Uh(r,t){if(t!==void 0){for(let e=0,n=r.length;e=g?t[l+x]:u[x]}return e}}function Mf(r,t,e,n){const o=Be(r),l=Be(t);Lr(o,l,Wc(e)),Lr(l,o,Wc(n))}function js(r,t){if(r===t)return!0;const e=r.getUnits()===t.getUnits();return(r.getCode()===t.getCode()||Va(r,t)===Uh)&&e}function Va(r,t){const e=r.getCode(),n=t.getCode();let o=e0(e,n);return o||(o=r0),o}function _o(r,t){const e=Be(r),n=Be(t);return Va(e,n)}function bf(r,t,e){return _o(t,e)(r,void 0,r.length)}let Tf=null;function Sf(){return Tf}function uh(r,t){return r}function $n(r,t){return hh&&!Ea(r,[0,0])&&r[0]>=-180&&r[0]<=180&&r[1]>=-90&&r[1]<=90&&(hh=!1,s0("Call useGeographic() from ol/proj once to work with [longitude, latitude] coordinates.")),r}function Wh(r,t){return r}function Ks(r,t){return r}function Xc(r,t,e){return function(n){let o,l;if(r.canWrapX()){const u=r.getExtent(),g=Ce(u);n=n.slice(0),l=n0(n,r,g),l&&(n[0]=n[0]-l*g),n[0]=ei(n[0],u[0],u[2]),n[1]=ei(n[1],u[1],u[3]),o=e(n)}else o=e(n);return l&&t.canWrapX()&&(o[0]+=l*Ce(t.getExtent())),o}}function Rf(){ch(Bc),ch(Gc),If(Gc,Bc,uf,ff)}Rf();function vs(r,t,e,n,o,l){l=l||[];let u=0;for(let g=t;g{if(!n)return this.getSimplifiedGeometry(e);const o=this.clone();return o.applyTransform(n),o.getSimplifiedGeometry(e)})}simplifyTransformed(t,e){return this.simplifyTransformedInternal(this.getRevision(),t,e)}clone(){return Xt()}closestPointXY(t,e,n,o){return Xt()}containsXY(t,e){const n=this.getClosestPoint([t,e]);return n[0]===t&&n[1]===e}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 Xt()}getExtent(t){if(this.extentRevision_!=this.getRevision()){const e=this.computeExtent(this.extent_);(isNaN(e[0])||isNaN(e[1]))&&Do(e),this.extentRevision_=this.getRevision()}return of(this.extent_,t)}rotate(t,e){Xt()}scale(t,e,n){Xt()}simplify(t){return this.getSimplifiedGeometry(t*t)}getSimplifiedGeometry(t){return Xt()}getType(){return Xt()}applyTransform(t){Xt()}intersectsExtent(t){return Xt()}translate(t,e){Xt()}transform(t,e){const n=Be(t),o=n.getUnits()=="tile-pixels"?function(l,u,g){const x=n.getExtent(),E=n.getWorldExtent(),w=Bi(E)/Bi(x);return as(Vc,E[0],E[3],w,-w,0,0,0),vs(l,0,l.length,g,Vc,u),_o(n,e)(l,u,g)}:_o(n,e);return this.applyTransform(o),this}}class ar extends l0{constructor(){super(),this.layout="XY",this.stride=2,this.flatCoordinates}computeExtent(t){return Fh(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t)}getCoordinates(){return Xt()}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().length1)A=e;else if(S>0){for(let P=0;Po&&(o=E),l=g,u=x}return o}function Vh(r,t,e,n,o){for(let l=0,u=e.length;l0;){const A=E.pop(),S=E.pop();let P=0;const L=r[S],F=r[S+1],V=r[A],z=r[A+1];for(let U=S+n;UP&&(w=U,P=$)}P>o&&(x[(w-t)/n]=1,S+n0&&F>P)&&(L<0&&V0&&V>L)){E=A,w=S;continue}l[u++]=E,l[u++]=w,g=E,x=w,E=A,w=S}return l[u++]=E,l[u++]=w,u}function jh(r,t,e,n,o,l,u,g){for(let x=0,E=e.length;xl&&(E-g)*(l-x)-(o-g)*(w-x)>0&&u++:w<=l&&(E-g)*(l-x)-(o-g)*(w-x)<0&&u--,g=E,x=w}return u!==0}function Zh(r,t,e,n,o,l){if(e.length===0||!qs(r,t,e[0],n,o,l))return!1;for(let u=1,g=e.length;uz&&(E=(w+A)/2,Zh(r,t,e,n,E,L)&&(V=E,z=U)),w=A}return isNaN(V)&&(V=o[l]),u?(u.push(V,L,z),u):[V,L,z]}function d0(r,t,e,n,o){let l=[];for(let u=0,g=e.length;u=o[0]&&l[2]<=o[2]||l[1]>=o[1]&&l[3]<=o[3]?!0:g0(r,t,e,n,function(u,g){return af(o,u,g)}):!1}function zf(r,t,e,n,o){for(let l=0,u=e.length;l0}function Jh(r,t,e,n,o){o=o!==void 0?o:!1;for(let l=0,u=e.length;l.0031308?1.055*Math.pow(l,1/2.4)-.055:l=l*12.92,u=u>.0031308?1.055*Math.pow(u,1/2.4)-.055:u=u*12.92,g=g>.0031308?1.055*Math.pow(g,1/2.4)-.055:g=g*12.92,l=Math.min(Math.max(0,l),1),u=Math.min(Math.max(0,u),1),g=Math.min(Math.max(0,g),1),[l*255,u*255,g*255]};wo.xyz=function(r,t){var e=r[0]/255,n=r[1]/255,o=r[2]/255;e=e>.04045?Math.pow((e+.055)/1.055,2.4):e/12.92,n=n>.04045?Math.pow((n+.055)/1.055,2.4):n/12.92,o=o>.04045?Math.pow((o+.055)/1.055,2.4):o/12.92;var l=e*.41239079926595+n*.35758433938387+o*.18048078840183,u=e*.21263900587151+n*.71516867876775+o*.072192315360733,g=e*.019330818715591+n*.11919477979462+o*.95053215224966;return t=t||Ti.whitepoint[2].E,[l*t[0],u*t[1],g*t[2]]};const Qh={name:"luv",min:[0,-134,-140],max:[100,224,122],channel:["lightness","u","v"],alias:["LUV","cieluv","cie1976"],xyz:function(r,t,e){var n,o,l,u,g,x,E,w,A,S,P,L,F;if(l=r[0],u=r[1],g=r[2],l===0)return[0,0,0];var V=.0011070564598794539;return t=t||"D65",e=e||2,A=Ti.whitepoint[e][t][0],S=Ti.whitepoint[e][t][1],P=Ti.whitepoint[e][t][2],L=4*A/(A+15*S+3*P),F=9*S/(A+15*S+3*P),n=u/(13*l)+L||0,o=g/(13*l)+F||0,E=l>8?S*Math.pow((l+16)/116,3):S*l*V,x=E*9*n/(4*o)||0,w=E*(12-3*n-20*o)/(4*o)||0,[x,E,w]}};Ti.luv=function(r,t,e){var n,o,l,u,g,x,E,w,A,S,P,L,F,V=.008856451679035631,z=903.2962962962961;t=t||"D65",e=e||2,A=Ti.whitepoint[e][t][0],S=Ti.whitepoint[e][t][1],P=Ti.whitepoint[e][t][2],L=4*A/(A+15*S+3*P),F=9*S/(A+15*S+3*P),x=r[0],E=r[1],w=r[2],n=4*x/(x+15*E+3*w)||0,o=9*E/(x+15*E+3*w)||0;var U=E/S;return l=U<=V?z*U:116*Math.pow(U,1/3)-16,u=13*l*(n-L),g=13*l*(o-F),[l,u,g]};var p0={name:"lchuv",channel:["lightness","chroma","hue"],alias:["LCHuv","cielchuv"],min:[0,0,0],max:[100,100,360],luv:function(r){var t=r[0],e=r[1],n=r[2],o,l,u;return u=n/360*2*Math.PI,o=e*Math.cos(u),l=e*Math.sin(u),[t,o,l]},xyz:function(r){return Qh.xyz(p0.luv(r))}};Qh.lchuv=function(r){var t=r[0],e=r[1],n=r[2],o=Math.sqrt(e*e+n*n),l=Math.atan2(n,e),u=l*360/2/Math.PI;return u<0&&(u+=360),[t,o,u]};Ti.lchuv=function(r){return Qh.lchuv(Ti.luv(r))};const Zc={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]};var Kc={red:0,orange:60,yellow:120,green:180,blue:240,purple:300};function Yf(r){var t,e=[],n=1,o;if(typeof r=="number")return{space:"rgb",values:[r>>>16,(r&65280)>>>8,r&255],alpha:1};if(typeof r=="number")return{space:"rgb",values:[r>>>16,(r&65280)>>>8,r&255],alpha:1};if(r=String(r).toLowerCase(),Zc[r])e=Zc[r].slice(),o="rgb";else if(r==="transparent")n=0,o="rgb",e=[0,0,0];else if(r[0]==="#"){var l=r.slice(1),u=l.length,g=u<=4;n=1,g?(e=[parseInt(l[0]+l[0],16),parseInt(l[1]+l[1],16),parseInt(l[2]+l[2],16)],u===4&&(n=parseInt(l[3]+l[3],16)/255)):(e=[parseInt(l[0]+l[1],16),parseInt(l[2]+l[3],16),parseInt(l[4]+l[5],16)],u===8&&(n=parseInt(l[6]+l[7],16)/255)),e[0]||(e[0]=0),e[1]||(e[1]=0),e[2]||(e[2]=0),o="rgb"}else if(t=/^((?:rgba?|hs[lvb]a?|hwba?|cmyk?|xy[zy]|gray|lab|lchu?v?|[ly]uv|lms|oklch|oklab|color))\s*\(([^\)]*)\)/.exec(r)){var x=t[1];o=x.replace(/a$/,"");var E=o==="cmyk"?4:o==="gray"?1:3;e=t[2].trim().split(/\s*[,\/]\s*|\s+/),o==="color"&&(o=e.shift()),e=e.map(function(w,A){if(w[w.length-1]==="%")return w=parseFloat(w)/100,A===3?w:o==="rgb"?w*255:o[0]==="h"||o[0]==="l"&&!A?w*100:o==="lab"?w*125:o==="lch"?A<2?w*150:w*360:o[0]==="o"&&!A?w:o==="oklab"?w*.4:o==="oklch"?A<2?w*.4:w*360:w;if(o[A]==="h"||A===2&&o[o.length-1]==="h"){if(Kc[w]!==void 0)return Kc[w];if(w.endsWith("deg"))return parseFloat(w);if(w.endsWith("turn"))return parseFloat(w)*360;if(w.endsWith("grad"))return parseFloat(w)*360/400;if(w.endsWith("rad"))return parseFloat(w)*180/Math.PI}return w==="none"?0:parseFloat(w)}),n=e.length>E?e.pop():1}else/[0-9](?:\s|\/|,)/.test(r)&&(e=r.match(/([0-9]+)/g).map(function(w){return parseFloat(w)}),o=r.match(/([a-z])/ig)?.join("")?.toLowerCase()||"rgb");return{space:o,values:e,alpha:n}}const Ol={name:"hsl",min:[0,0,0],max:[360,100,100],channel:["hue","saturation","lightness"],alias:["HSL"],rgb:function(r){var t=r[0]/360,e=r[1]/100,n=r[2]/100,o,l,u,g,x,E=0;if(e===0)return x=n*255,[x,x,x];for(l=n<.5?n*(1+e):n+e-n*e,o=2*n-l,g=[0,0,0];E<3;)u=t+1/3*-(E-1),u<0?u++:u>1&&u--,x=6*u<1?o+(l-o)*6*u:2*u<1?l:3*u<2?o+(l-o)*(2/3-u)*6:o,g[E++]=x*255;return g}};wo.hsl=function(r){var t=r[0]/255,e=r[1]/255,n=r[2]/255,o=Math.min(t,e,n),l=Math.max(t,e,n),u=l-o,g,x,E;return l===o?g=0:t===l?g=(e-n)/u:e===l?g=2+(n-t)/u:n===l&&(g=4+(t-e)/u),g=Math.min(g*60,360),g<0&&(g+=360),E=(o+l)/2,l===o?x=0:E<=.5?x=u/(l+o):x=u/(2-l-o),[g,x*100,E*100]};function Hf(r){Array.isArray(r)&&r.raw&&(r=String.raw(...arguments)),r instanceof Number&&(r=+r);var t,e=Yf(r);if(!e.space)return[];const n=e.space[0]==="h"?Ol.min:wo.min,o=e.space[0]==="h"?Ol.max:wo.max;return t=Array(3),t[0]=Math.min(Math.max(e.values[0],n[0]),o[0]),t[1]=Math.min(Math.max(e.values[1],n[1]),o[1]),t[2]=Math.min(Math.max(e.values[2],n[2]),o[2]),e.space[0]==="h"&&(t=Ol.rgb(t)),t.push(Math.min(Math.max(e.alpha,0),1)),t}function jf(r){return typeof r=="string"?r:tc(r)}const Zf=1024,$r={};let Nl=0;function Kf(r){if(r.length===4)return r;const t=r.slice();return t[3]=1,t}function qc(r){const t=Ti.lchuv(wo.xyz(r));return t[3]=r[3],t}function qf(r){const t=Ti.rgb(p0.xyz(r));return t[3]=r[3],t}function $h(r){if($r.hasOwnProperty(r))return $r[r];if(Nl>=Zf){let e=0;for(const n in $r)e++&3||(delete $r[n],--Nl)}const t=Hf(r);if(t.length!==4)throw new Error('Failed to parse "'+r+'" as color');for(const e of t)if(isNaN(e))throw new Error('Failed to parse "'+r+'" as color');return y0(t),$r[r]=t,++Nl,t}function Eo(r){return Array.isArray(r)?r:$h(r)}function y0(r){return r[0]=ei(r[0]+.5|0,0,255),r[1]=ei(r[1]+.5|0,0,255),r[2]=ei(r[2]+.5|0,0,255),r[3]=ei(r[3],0,1),r}function tc(r){let t=r[0];t!=(t|0)&&(t=t+.5|0);let e=r[1];e!=(e|0)&&(e=e+.5|0);let n=r[2];n!=(n|0)&&(n=n+.5|0);const o=r[3]===void 0?1:Math.round(r[3]*1e3)/1e3;return"rgba("+t+","+e+","+n+","+o+")"}function Jf(r){try{return $h(r),!0}catch{return!1}}const Ds=typeof navigator<"u"&&typeof navigator.userAgent<"u"?navigator.userAgent.toLowerCase():"",Qf=Ds.includes("firefox"),$f=Ds.includes("safari")&&!Ds.includes("chrom");$f&&(Ds.includes("version/15.4")||/cpu (os|iphone os) 15_4 like mac os x/.test(Ds));const td=Ds.includes("webkit")&&!Ds.includes("edge"),w0=Ds.includes("macintosh"),E0=typeof devicePixelRatio<"u"?devicePixelRatio:1,C0=typeof WorkerGlobalScope<"u"&&typeof OffscreenCanvas<"u"&&self instanceof WorkerGlobalScope,A0=typeof Image<"u"&&Image.prototype.decode,I0=function(){let r=!1;try{const t=Object.defineProperty({},"passive",{get:function(){r=!0}});window.addEventListener("_",null,t),window.removeEventListener("_",null,t)}catch{}return r}();function Si(r,t,e,n){let o;return e&&e.length?o=e.shift():C0?o=new OffscreenCanvas(r||300,t||300):o=document.createElement("canvas"),r&&(o.width=r),t&&(o.height=t),o.getContext("2d",n)}let Pl;function Aa(){return Pl||(Pl=Si(1,1)),Pl}function Za(r){const t=r.canvas;t.width=1,t.height=1,r.clearRect(0,0,1,1)}function ed(r){let t=r.offsetWidth;const e=getComputedStyle(r);return t+=parseInt(e.marginLeft,10)+parseInt(e.marginRight,10),t}function id(r){let t=r.offsetHeight;const e=getComputedStyle(r);return t+=parseInt(e.marginTop,10)+parseInt(e.marginBottom,10),t}function Jc(r,t){const e=t.parentNode;e&&e.replaceChild(r,t)}function Ia(r){return r&&r.parentNode?r.parentNode.removeChild(r):null}function M0(r){for(;r.lastChild;)r.removeChild(r.lastChild)}function nd(r,t){const e=r.childNodes;for(let n=0;;++n){const o=e[n],l=t[n];if(!o&&!l)break;if(o!==l){if(!o){r.appendChild(l);continue}if(!l){r.removeChild(o),--n;continue}r.insertBefore(l,o)}}}function sd(r,t,e){const n=r;let o=!0,l=!1,u=!1;const g=[wa(n,jt.LOAD,function(){u=!0,l||t()})];return n.src&&A0?(l=!0,n.decode().then(function(){o&&t()}).catch(function(x){o&&(u?t():e())})):g.push(wa(n,jt.ERROR,e)),function(){o=!1,g.forEach(Fe)}}function rd(r,t){return new Promise((e,n)=>{function o(){u(),e(r)}function l(){u(),n(new Error("Image load error"))}function u(){r.removeEventListener("load",o),r.removeEventListener("error",l)}r.addEventListener("load",o),r.addEventListener("error",l),t&&(r.src=t)})}function od(r,t){return t&&(r.src=t),r.src&&A0?new Promise((e,n)=>r.decode().then(()=>e(r)).catch(o=>r.complete&&r.width?e(r):n(o))):rd(r)}class ad{constructor(){this.cache_={},this.patternCache_={},this.cacheSize_=0,this.maxCacheSize_=32}clear(){this.cache_={},this.patternCache_={},this.cacheSize_=0}canExpireCache(){return this.cacheSize_>this.maxCacheSize_}expire(){if(this.canExpireCache()){let t=0;for(const e in this.cache_){const n=this.cache_[e];!(t++&3)&&!n.hasListener()&&(delete this.cache_[e],delete this.patternCache_[e],--this.cacheSize_)}}}get(t,e,n){const o=Dl(t,e,n);return o in this.cache_?this.cache_[o]:null}getPattern(t,e,n){const o=Dl(t,e,n);return o in this.patternCache_?this.patternCache_[o]:null}set(t,e,n,o,l){const u=Dl(t,e,n),g=u in this.cache_;this.cache_[u]=o,l&&(o.getImageState()===ie.IDLE&&o.load(),o.getImageState()===ie.LOADING?o.ready().then(()=>{this.patternCache_[u]=Aa().createPattern(o.getImage(1),"repeat")}):this.patternCache_[u]=Aa().createPattern(o.getImage(1),"repeat")),g||++this.cacheSize_}setSize(t){this.maxCacheSize_=t,this.expire()}}function Dl(r,t,e){const n=e?Eo(e):"null";return t+":"+r+":"+n}const kn=new ad;let to=null;class ld extends Ga{constructor(t,e,n,o,l){super(),this.hitDetectionImage_=null,this.image_=t,this.crossOrigin_=n,this.canvas_={},this.color_=l,this.imageState_=o===void 0?ie.IDLE:o,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_===ie.LOADED){to||(to=Si(1,1,void 0,{willReadFrequently:!0})),to.drawImage(this.image_,0,0);try{to.getImageData(0,0,1,1),this.tainted_=!1}catch{to=null,this.tainted_=!0}}return this.tainted_===!0}dispatchChangeEvent_(){this.dispatchEvent(jt.CHANGE)}handleImageError_(){this.imageState_=ie.ERROR,this.dispatchChangeEvent_()}handleImageLoad_(){this.imageState_=ie.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],n=Si(t,e);n.fillRect(0,0,t,e),this.hitDetectionImage_=n.canvas}else this.hitDetectionImage_=this.image_;return this.hitDetectionImage_}getSize(){return this.size_}getSrc(){return this.src_}load(){if(this.imageState_===ie.IDLE){this.image_||this.initializeImage_(),this.imageState_=ie.LOADING;try{this.src_!==void 0&&(this.image_.src=this.src_)}catch{this.handleImageError_()}this.image_ instanceof HTMLImageElement&&od(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_!==ie.LOADED)return;const e=this.image_,n=document.createElement("canvas");n.width=Math.ceil(e.width*t),n.height=Math.ceil(e.height*t);const o=n.getContext("2d");o.scale(t,t),o.drawImage(e,0,0),o.globalCompositeOperation="multiply",o.fillStyle=jf(this.color_),o.fillRect(0,0,n.width/t,n.height/t),o.globalCompositeOperation="destination-in",o.drawImage(e,0,0),this.canvas_[t]=n}ready(){return this.ready_||(this.ready_=new Promise(t=>{this.imageState_===ie.LOADED||this.imageState_===ie.ERROR?t():this.addEventListener(jt.CHANGE,function e(){(this.imageState_===ie.LOADED||this.imageState_===ie.ERROR)&&(this.removeEventListener(jt.CHANGE,e),t())})})),this.ready_}}function ec(r,t,e,n,o,l){let u=t===void 0?void 0:kn.get(t,e,o);return u||(u=new ld(r,r&&"src"in r?r.src||void 0:t,e,n,o),kn.set(t,e,o,u,l)),l&&u&&!kn.getPattern(t,e,o)&&kn.set(t,e,o,u,l),u}class Bo{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 Bo({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=ec(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()===ie.IDLE&&e.load(),e.getImageState()===ie.LOADING&&(this.patternImage_=e)}this.color_=t}loading(){return!!this.patternImage_}ready(){return this.patternImage_?this.patternImage_.ready():Promise.resolve()}}function Ma(r,t,e,n,o,l,u){let g,x;const E=(e-t)/n;if(E===1)g=t;else if(E===2)g=t,x=o;else if(E!==0){let w=r[t],A=r[t+1],S=0;const P=[0];for(let V=t+n;V1?u:2,l=l||new Array(u);for(let w=0;w>1;o0&&r[1]>0}function cd(r,t,e){return e===void 0&&(e=[0,0]),e[0]=r[0]*t+.5|0,e[1]=r[1]*t+.5|0,e}function sn(r,t){return Array.isArray(r)?r:(t===void 0?t=[r,r]:(t[0]=r,t[1]=r),t)}class qa{constructor(t){this.opacity_=t.opacity,this.rotateWithView_=t.rotateWithView,this.rotation_=t.rotation,this.scale_=t.scale,this.scaleArray_=sn(t.scale),this.displacement_=t.displacement,this.declutterMode_=t.declutterMode}clone(){const t=this.getScale();return new qa({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 Xt()}getImage(t){return Xt()}getHitDetectionImage(){return Xt()}getPixelRatio(t){return 1}getImageState(){return Xt()}getImageSize(){return Xt()}getOrigin(){return Xt()}getSize(){return Xt()}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_=sn(t)}listenImageChange(t){Xt()}load(){Xt()}unlistenImageChange(t){Xt()}ready(){return Promise.resolve()}}function Gn(r){return r?Array.isArray(r)?tc(r):typeof r=="object"&&"src"in r?ud(r):r:null}function ud(r){if(!r.offset||!r.size)return kn.getPattern(r.src,"anonymous",r.color);const t=r.src+":"+r.offset,e=kn.getPattern(t,void 0,r.color);if(e)return e;const n=kn.get(r.src,"anonymous",null);if(n.getImageState()!==ie.LOADED)return null;const o=Si(r.size[0],r.size[1]);return o.drawImage(n.getImage(1),r.offset[0],r.offset[1],r.size[0],r.size[1],0,0,r.size[0],r.size[1]),ec(o.canvas,t,void 0,ie.LOADED,r.color,!0),kn.getPattern(t,void 0,r.color)}const aa="ol-hidden",fd="ol-selectable",Ja="ol-unselectable",ic="ol-control",$c="ol-collapsed",dd=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-z]+?)\\s*$`].join(""),"i"),tu=["style","variant","weight","size","lineHeight","family"],T0=function(r){const t=r.match(dd);if(!t)return null;const e={lineHeight:"normal",size:"1.2em",style:"normal",weight:"normal",variant:"normal"};for(let n=0,o=tu.length;nMath.max(o,Ta(r,l)),0);return e[t]=n,n}function xd(r,t){const e=[],n=[],o=[];let l=0,u=0,g=0,x=0;for(let E=0,w=t.length;E<=w;E+=2){const A=t[E];if(A===` +`||E===w){l=Math.max(l,u),o.push(u),u=0,g+=x,x=0;continue}const S=t[E+1]||r.font,P=Ta(S,A);e.push(P),u+=P;const L=md(S);n.push(L),x=Math.max(x,L)}return{width:l,height:g,widths:e,heights:n,lineWidths:o}}function _d(r,t,e,n,o,l,u,g,x,E,w){r.save(),e!==1&&(r.globalAlpha===void 0?r.globalAlpha=A=>A.globalAlpha*=e:r.globalAlpha*=e),t&&r.transform.apply(r,t),n.contextInstructions?(r.translate(x,E),r.scale(w[0],w[1]),pd(n,r)):w[0]<0||w[1]<0?(r.translate(x,E),r.scale(w[0],w[1]),r.drawImage(n,o,l,u,g,0,0,u,g)):r.drawImage(n,o,l,u,g,x,E,u*w[0],g*w[1]),r.restore()}function pd(r,t){const e=r.contextInstructions;for(let n=0,o=e.length;nthis.imageState_=ie.LOADED),this.render()}clone(){const t=this.getScale(),e=new Qa({fill:this.getFill()?this.getFill().clone():void 0,points:this.getPoints(),radius:this.getRadius(),radius2:this.getRadius2(),angle:this.getAngle(),stroke:this.getStroke()?this.getStroke().clone():void 0,rotation:this.getRotation(),rotateWithView:this.getRotateWithView(),scale:Array.isArray(t)?t.slice():t,displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()});return e.setOpacity(this.getOpacity()),e}getAnchor(){const t=this.size_,e=this.getDisplacement(),n=this.getScaleArray();return[t[0]/2-e[0]/n[0],t[1]/2+e[1]/n[1]]}getAngle(){return this.angle_}getFill(){return this.fill_}setFill(t){this.fill_=t,this.render()}getHitDetectionImage(){return this.hitDetectionCanvas_||(this.hitDetectionCanvas_=this.createHitDetectionCanvas_(this.renderOptions_)),this.hitDetectionCanvas_}getImage(t){let e=this.canvases_[t];if(!e){const n=this.renderOptions_,o=Si(n.size*t,n.size*t);this.draw_(n,o,t),e=o.canvas,this.canvases_[t]=e}return e}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,n){if(e===0||this.points_===1/0||t!=="bevel"&&t!=="miter")return e;let o=this.radius_,l=this.radius2_===void 0?o:this.radius2_;if(oP&&(S=(P+S)/2,P=S),L>F&&(L=(F+L)/2,F=L);let V=ei(n[0],S,P),z=ei(n[1],L,F);if(u&&e&&o){const U=30*o;V+=-U*Math.log(1+Math.max(0,S-n[0])/U)+U*Math.log(1+Math.max(0,n[0]-P)/U),z+=-U*Math.log(1+Math.max(0,L-n[1])/U)+U*Math.log(1+Math.max(0,n[1]-F)/U)}return[V,z]}}function Cd(r){return r}function rc(r,t,e,n){const o=Ce(t)/e[0],l=Bi(t)/e[1];return n?Math.min(r,Math.max(o,l)):Math.min(r,Math.min(o,l))}function oc(r,t,e){let n=Math.min(r,t);const o=50;return n*=Math.log(1+o*Math.max(0,r/t-1))/o+1,e&&(n=Math.max(n,e),n/=Math.log(1+o*Math.max(0,e/r-1))/o+1),ei(n,e/2,t*2)}function Ad(r,t,e,n){return t=t!==void 0?t:!0,function(o,l,u,g){if(o!==void 0){const x=r[0],E=r[r.length-1],w=e?rc(x,e,u,n):x;if(g)return t?oc(o,w,E):ei(o,E,w);const A=Math.min(w,o),S=Math.floor(Ph(r,A,l));return r[S]>w&&S1&&typeof arguments[e-1]=="function"&&(n=arguments[e-1],--e);let o=0;for(;o0}getInteracting(){return this.hints_[Fi.INTERACTING]>0}cancelAnimations(){this.setHint(Fi.ANIMATING,-this.hints_[Fi.ANIMATING]);let t;for(let e=0,n=this.animations_.length;e=0;--n){const o=this.animations_[n];let l=!0;for(let u=0,g=o.length;u0?E/x.duration:1;w>=1?(x.complete=!0,w=1):l=!1;const A=x.easing(w);if(x.sourceCenter){const S=x.sourceCenter[0],P=x.sourceCenter[1],L=x.targetCenter[0],F=x.targetCenter[1];this.nextCenter_=x.targetCenter;const V=S+A*(L-S),z=P+A*(F-P);this.targetCenter_=[V,z]}if(x.sourceResolution&&x.targetResolution){const S=A===1?x.targetResolution:x.sourceResolution+A*(x.targetResolution-x.sourceResolution);if(x.anchor){const P=this.getViewportSize_(this.getRotation()),L=this.constraints_.resolution(S,0,P,!0);this.targetCenter_=this.calculateCenterZoom(L,x.anchor)}this.nextResolution_=x.targetResolution,this.targetResolution_=S,this.applyTargetState_(!0)}if(x.sourceRotation!==void 0&&x.targetRotation!==void 0){const S=A===1?vr(x.targetRotation+Math.PI,2*Math.PI)-Math.PI:x.sourceRotation+A*(x.targetRotation-x.sourceRotation);if(x.anchor){const P=this.constraints_.rotation(S,!0);this.targetCenter_=this.calculateCenterRotate(P,x.anchor)}this.nextRotation_=x.targetRotation,this.targetRotation_=S}if(this.applyTargetState_(!0),e=!0,!x.complete)break}if(l){this.animations_[n]=null,this.setHint(Fi.ANIMATING,-1),this.nextCenter_=null,this.nextResolution_=NaN,this.nextRotation_=NaN;const u=o[0].callback;u&&la(u,!0)}}this.animations_=this.animations_.filter(Boolean),e&&this.updateAnimationKey_===void 0&&(this.updateAnimationKey_=requestAnimationFrame(this.updateAnimations_.bind(this)))}calculateCenterRotate(t,e){let n;const o=this.getCenterInternal();return o!==void 0&&(n=[o[0]-e[0],o[1]-e[1]],Gh(n,t-this.getRotation()),yf(n,e)),n}calculateCenterZoom(t,e){let n;const o=this.getCenterInternal(),l=this.getResolution();if(o!==void 0&&l!==void 0){const u=e[0]-t*(e[0]-o[0])/l,g=e[1]-t*(e[1]-o[1])/l;n=[u,g]}return n}getViewportSize_(t){const e=this.viewportSize_;if(t){const n=e[0],o=e[1];return[Math.abs(n*Math.cos(t))+Math.abs(o*Math.sin(t)),Math.abs(n*Math.sin(t))+Math.abs(o*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&&uh(t,this.getProjection())}getCenterInternal(){return this.get(An.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 Wh(e,this.getProjection())}calculateExtentInternal(t){t=t||this.getViewportSizeMinusPadding_();const e=this.getCenterInternal();pe(e,"The view center is not defined");const n=this.getResolution();pe(n!==void 0,"The view resolution is not defined");const o=this.getRotation();return pe(o!==void 0,"The view rotation is not defined"),oh(e,n,o,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(An.RESOLUTION)}getResolutions(){return this.resolutions_}getResolutionForExtent(t,e){return this.getResolutionForExtentInternal(Ks(t,this.getProjection()),e)}getResolutionForExtentInternal(t,e){e=e||this.getViewportSizeMinusPadding_();const n=Ce(t)/e[0],o=Bi(t)/e[1];return Math.max(n,o)}getResolutionForValueFunction(t){t=t||2;const e=this.getConstrainedResolution(this.maxResolution_),n=this.minResolution_,o=Math.log(e/n)/Math.log(t);return function(l){return e/Math.pow(t,l*o)}}getRotation(){return this.get(An.ROTATION)}getValueForResolutionFunction(t){const e=Math.log(t||2),n=this.getConstrainedResolution(this.maxResolution_),o=this.minResolution_,l=Math.log(n/o)/e;return function(u){return Math.log(n/u)/e/l}}getViewportSizeMinusPadding_(t){let e=this.getViewportSize_(t);const n=this.padding_;return n&&(e=[e[0]-n[1]-n[3],e[1]-n[0]-n[2]]),e}getState(){const t=this.getProjection(),e=this.getResolution(),n=this.getRotation();let o=this.getCenterInternal();const l=this.padding_;if(l){const u=this.getViewportSizeMinusPadding_();o=Bl(o,this.getViewportSize_(),[u[0]/2+l[3],u[1]/2+l[0]],e,n)}return{center:o.slice(0),projection:t!==void 0?t:null,resolution:e,nextCenter:this.nextCenter_,nextResolution:this.nextResolution_,nextRotation:this.nextRotation_,rotation:n,zoom:this.getZoom()}}getViewStateAndExtent(){return{viewState:this.getState(),extent:this.calculateExtent()}}getZoom(){let t;const e=this.getResolution();return e!==void 0&&(t=this.getZoomForResolution(e)),t}getZoomForResolution(t){let e=this.minZoom_||0,n,o;if(this.resolutions_){const l=Ph(this.resolutions_,t,1);e=l,n=this.resolutions_[l],l==this.resolutions_.length-1?o=2:o=n/this.resolutions_[l+1]}else n=this.maxResolution_,o=this.zoomFactor_;return e+Math.log(n/t)/Math.log(o)}getResolutionForZoom(t){if(this.resolutions_){if(this.resolutions_.length<=1)return 0;const e=ei(Math.floor(t),0,this.resolutions_.length-2),n=this.resolutions_[e]/this.resolutions_[e+1];return this.resolutions_[e]/Math.pow(n,ei(t-e,0,1))}return this.maxResolution_/Math.pow(this.zoomFactor_,t-this.minZoom_)}fit(t,e){let n;if(pe(Array.isArray(t)||typeof t.getSimplifiedGeometry=="function","Invalid extent or geometry provided as `geometry`"),Array.isArray(t)){pe(!Xa(t),"Cannot fit empty extent provided as `geometry`");const o=Ks(t,this.getProjection());n=jc(o)}else if(t.getType()==="Circle"){const o=Ks(t.getExtent(),this.getProjection());n=jc(o),n.rotate(this.getRotation(),Ns(o))}else n=t;this.fitInternal(n,e)}rotatedExtentForGeometry(t){const e=this.getRotation(),n=Math.cos(e),o=Math.sin(-e),l=t.getFlatCoordinates(),u=t.getStride();let g=1/0,x=1/0,E=-1/0,w=-1/0;for(let A=0,S=l.length;A{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 n=this.getMapInternal();!t&&n&&(t=n.getView()),t instanceof Ln?e={viewState:t.getState(),extent:t.calculateExtent()}:e=t,!e.layerStatesArray&&n&&(e.layerStatesArray=n.getLayerGroup().getLayerStatesArray());let o;e.layerStatesArray?o=e.layerStatesArray.find(u=>u.layer===this):o=this.getLayerState();const l=this.getExtent();return lc(o,e.viewState)&&(!l||Zi(l,e.extent))}getAttributions(t){if(!this.isVisible(t))return[];let e;const n=this.getSource();if(n&&(e=n.getAttributions()),!e)return[];const o=t instanceof Ln?t.getViewStateAndExtent():t;let l=e(o);return Array.isArray(l)||(l=[l]),l}render(t,e){const n=this.getRenderer();return n.prepareFrame(t)?(this.rendered=!0,n.renderFrame(t,e)):null}unrender(){this.rendered=!1}getDeclutter(){}renderDeclutter(t,e){}renderDeferred(t){const e=this.getRenderer();e&&e.renderDeferred(t)}setMapInternal(t){t||this.unrender(),this.set(ve.MAP,t)}getMapInternal(){return this.get(ve.MAP)}setMap(t){this.mapPrecomposeKey_&&(Fe(this.mapPrecomposeKey_),this.mapPrecomposeKey_=null),t||this.changed(),this.mapRenderKey_&&(Fe(this.mapRenderKey_),this.mapRenderKey_=null),t&&(this.mapPrecomposeKey_=ge(t,gn.PRECOMPOSE,function(e){const o=e.frameState.layerStatesArray,l=this.getLayerState(!1);pe(!o.some(function(u){return u.layer===l.layer}),"A layer can only be added to the map once. Use either `layer.setMap()` or `map.addLayer()`, not both."),o.push(l)},this),this.mapRenderKey_=ge(this,jt.CHANGE,t.render,t),this.changed())}setSource(t){this.set(ve.SOURCE,t)}getRenderer(){return this.renderer_||(this.renderer_=this.createRenderer()),this.renderer_}hasRenderer(){return!!this.renderer_}createRenderer(){return null}disposeInternal(){this.renderer_&&(this.renderer_.dispose(),delete this.renderer_),this.setSource(null),super.disposeInternal()}}function lc(r,t){if(!r.visible)return!1;const e=t.resolution;if(e=r.maxResolution)return!1;const n=t.zoom;return n>r.minZoom&&n<=r.maxZoom}function Dd(r,t,e,n,o){P0(r,t,e||0,n||r.length-1,o||Ld)}function P0(r,t,e,n,o){for(;n>e;){if(n-e>600){var l=n-e+1,u=t-e+1,g=Math.log(l),x=.5*Math.exp(2*g/3),E=.5*Math.sqrt(g*x*(l-x)/l)*(u-l/2<0?-1:1),w=Math.max(e,Math.floor(t-u*x/l+E)),A=Math.min(n,Math.floor(t+(l-u)*x/l+E));P0(r,t,w,A,o)}var S=r[t],P=e,L=n;for(eo(r,e,t),o(r[n],S)>0&&eo(r,e,n);P0;)L--}o(r[e],S)===0?eo(r,e,L):(L++,eo(r,L,n)),L<=t&&(e=L+1),t<=L&&(n=L-1)}}function eo(r,t,e){var n=r[t];r[t]=r[e],r[e]=n}function Ld(r,t){return rt?1:0}let D0=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 n=[];if(!ca(t,e))return n;const o=this.toBBox,l=[];for(;e;){for(let u=0;u=0&&l[e].children.length>this._maxEntries;)this._split(l,e),e--;this._adjustParentBBoxes(o,l,e)}_split(t,e){const n=t[e],o=n.children.length,l=this._minEntries;this._chooseSplitAxis(n,l,o);const u=this._chooseSplitIndex(n,l,o),g=Ir(n.children.splice(u,n.children.length-u));g.height=n.height,g.leaf=n.leaf,yr(n,this.toBBox),yr(g,this.toBBox),e?t[e-1].children.push(g):this._splitRoot(n,g)}_splitRoot(t,e){this.data=Ir([t,e]),this.data.height=t.height+1,this.data.leaf=!1,yr(this.data,this.toBBox)}_chooseSplitIndex(t,e,n){let o,l=1/0,u=1/0;for(let g=e;g<=n-e;g++){const x=so(t,0,g,this.toBBox),E=so(t,g,n,this.toBBox),w=Ud(x,E),A=kl(x)+kl(E);w=e;E--){const w=t.children[E];ro(g,t.leaf?l(w):w),x+=ha(g)}return x}_adjustParentBBoxes(t,e,n){for(let o=n;o>=0;o--)ro(e[o],t)}_condense(t){for(let e=t.length-1,n;e>=0;e--)t[e].children.length===0?e>0?(n=t[e-1].children,n.splice(n.indexOf(t[e]),1)):this.clear():yr(t[e],this.toBBox)}};function Fd(r,t,e){if(!e)return t.indexOf(r);for(let n=0;n=r.minX&&t.maxY>=r.minY}function Ir(r){return{children:r,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function ou(r,t,e,n,o){const l=[t,e];for(;l.length;){if(e=l.pop(),t=l.pop(),e-t<=n)continue;const u=t+Math.ceil((e-t)/n/2)*n;Dd(r,u,t,e,o),l.push(t,u,u,e)}}function au(r,t,e,n){return e!==void 0&&n!==void 0?[e/r,n/t]:e!==void 0?e/r:n!==void 0?n/t:1}class il extends qa{constructor(t){t=t||{};const e=t.opacity!==void 0?t.opacity:1,n=t.rotation!==void 0?t.rotation:0,o=t.scale!==void 0?t.scale:1,l=t.rotateWithView!==void 0?t.rotateWithView:!1;super({opacity:e,rotation:n,scale:o,displacement:t.displacement!==void 0?t.displacement:[0,0],rotateWithView:l,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 u=t.img!==void 0?t.img:null;let g=t.src;pe(!(g!==void 0&&u),"`image` and `src` cannot be provided at the same time"),(g===void 0||g.length===0)&&u&&(g=u.src||be(u)),pe(g!==void 0&&g.length>0,"A defined and non-empty `src` or `image` must be provided"),pe(!((t.width!==void 0||t.height!==void 0)&&t.scale!==void 0),"`width` or `height` cannot be provided together with `scale`");let x;if(t.src!==void 0?x=ie.IDLE:u!==void 0&&("complete"in u?u.complete?x=u.src?ie.LOADED:ie.IDLE:x=ie.LOADING:x=ie.LOADED),this.color_=t.color!==void 0?Eo(t.color):null,this.iconImage_=ec(u,g,this.crossOrigin_,x,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,t.width!==void 0||t.height!==void 0){let E,w;if(t.size)[E,w]=t.size;else{const A=this.getImage(1);if(A.width&&A.height)E=A.width,w=A.height;else if(A instanceof HTMLImageElement){this.initialOptions_=t;const S=()=>{if(this.unlistenImageChange(S),!this.initialOptions_)return;const P=this.iconImage_.getSize();this.setScale(au(P[0],P[1],t.width,t.height))};this.listenImageChange(S);return}}E!==void 0&&this.setScale(au(E,w,t.width,t.height))}}clone(){let t,e,n;return this.initialOptions_?(e=this.initialOptions_.width,n=this.initialOptions_.height):(t=this.getScale(),t=Array.isArray(t)?t.slice():t),new il({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:n,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 o=this.getSize();if(this.anchorXUnits_=="fraction"||this.anchorYUnits_=="fraction"){if(!o)return null;t=this.anchor_.slice(),this.anchorXUnits_=="fraction"&&(t[0]*=o[0]),this.anchorYUnits_=="fraction"&&(t[1]*=o[1])}if(this.anchorOrigin_!="top-left"){if(!o)return null;t===this.anchor_&&(t=this.anchor_.slice()),(this.anchorOrigin_=="top-right"||this.anchorOrigin_=="bottom-right")&&(t[0]=-t[0]+o[0]),(this.anchorOrigin_=="bottom-left"||this.anchorOrigin_=="bottom-right")&&(t[1]=-t[1]+o[1])}this.normalizedAnchor_=t}const e=this.getDisplacement(),n=this.getScaleArray();return[t[0]-e[0]/n[0],t[1]+e[1]/n[1]]}setAnchor(t){this.anchor_=t,this.normalizedAnchor_=null}getColor(){return this.color_}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(),n=this.iconImage_.getSize();if(!e||!n)return null;t=t.slice(),(this.offsetOrigin_=="top-right"||this.offsetOrigin_=="bottom-right")&&(t[0]=n[0]-e[0]-t[0]),(this.offsetOrigin_=="bottom-left"||this.offsetOrigin_=="bottom-right")&&(t[1]=n[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()==ie.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()==ie.LOADED)return this.iconImage_.getSize()[1]*t[1]}setScale(t){delete this.initialOptions_,super.setScale(t)}listenImageChange(t){this.iconImage_.addEventListener(jt.CHANGE,t)}load(){this.iconImage_.load()}unlistenImageChange(t){this.iconImage_.removeEventListener(jt.CHANGE,t)}ready(){return this.iconImage_.ready()}}let hr=0;const Xr=0,$e=1<",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"},Yd={[ft.Get]:Yt(([r,t])=>t!==void 0?Vd(t.value):Di,Jt(1,2),Hd),[ft.Var]:Yt(([r])=>r.type,Jt(1,1),jd),[ft.Id]:Yt(Pt|nn,io,Zd),[ft.Concat]:Yt(nn,Jt(2,1/0),_e(Di)),[ft.GeometryType]:Yt(nn,io,Kd),[ft.Resolution]:Yt(Pt,io),[ft.Zoom]:Yt(Pt,io),[ft.Time]:Yt(Pt,io),[ft.Any]:Yt($e,Jt(2,1/0),_e($e)),[ft.All]:Yt($e,Jt(2,1/0),_e($e)),[ft.Not]:Yt($e,Jt(1,1),_e($e)),[ft.Equal]:Yt($e,Jt(2,2),_e(Di),ys),[ft.NotEqual]:Yt($e,Jt(2,2),_e(Di),ys),[ft.GreaterThan]:Yt($e,Jt(2,2),_e(Di),ys),[ft.GreaterThanOrEqualTo]:Yt($e,Jt(2,2),_e(Di),ys),[ft.LessThan]:Yt($e,Jt(2,2),_e(Di),ys),[ft.LessThanOrEqualTo]:Yt($e,Jt(2,2),_e(Di),ys),[ft.Multiply]:Yt(r=>{let t=Pt|wi;for(let e=0;e{let t=Di;for(let e=1;e{let t=Di;for(let e=2;e{let t=wi|Pt;for(let e=3;e{let t=Di;for(let e=1;er.length===2?Un|uo:r.length===3||r.length===4?Un|wi:Un,Jt(1,1/0),_e(Pt)),[ft.Color]:Yt(wi,Jt(1,4),_e(Pt)),[ft.Band]:Yt(Pt,Jt(1,3),_e(Pt)),[ft.Palette]:Yt(wi,Jt(2,2),eg),[ft.ToString]:Yt(nn,Jt(1,1),_e($e|Pt|nn|wi))};function Hd(r,t){const e=Me(r[1],t);if(!(e instanceof Ts))throw new Error("Expected a literal argument for get operation");if(typeof e.value!="string")throw new Error("Expected a string argument for get operation");if(t.properties.add(e.value),r.length===3){const n=Me(r[2],t);return[e,n]}return[e]}function jd(r,t,e,n){const o=r[1];if(typeof o!="string")throw new Error("Expected a string argument for var operation");if(t.variables.add(o),!("variables"in t.style)||t.style.variables[o]===void 0)return[new Ts(Di,o)];const l=t.style.variables[o],u=Me(l,t);if(u.value=o,n&&!zn(n,u.type))throw new Error(`The variable ${o} has type ${ki(u.type)} but the following type was expected: ${ki(n)}`);return[u]}function Zd(r,t){t.featureId=!0}function Kd(r,t){t.geometryType=!0}function io(r,t){const e=r[0];if(r.length!==1)throw new Error(`Expected no arguments for ${e} operation`);return[]}function Jt(r,t){return function(e,n){const o=e[0],l=e.length-1;if(r===t){if(l!==r){const u=r===1?"":"s";throw new Error(`Expected ${r} argument${u} for ${o}, got ${l}`)}}else if(lt){const u=t===1/0?`${r} or more`:`${r} to ${t}`;throw new Error(`Expected ${u} arguments for ${o}, got ${l}`)}}}function _e(r){return function(t,e){const n=t[0],o=t.length-1,l=new Array(o);for(let u=0;un.featureId;case ft.GeometryType:return n=>n.geometryType;case ft.Concat:{const n=r.args.map(o=>Sn(o));return o=>"".concat(...n.map(l=>l(o).toString()))}case ft.Resolution:return n=>n.resolution;case ft.Any:case ft.All:case ft.Between:case ft.In:case ft.Not:return og(r);case ft.Equal:case ft.NotEqual:case ft.LessThan:case ft.LessThanOrEqualTo:case ft.GreaterThan:case ft.GreaterThanOrEqualTo:return rg(r);case ft.Multiply:case ft.Divide:case ft.Add:case ft.Subtract:case ft.Clamp:case ft.Mod:case ft.Pow:case ft.Abs:case ft.Floor:case ft.Ceil:case ft.Round:case ft.Sin:case ft.Cos:case ft.Atan:case ft.Sqrt:return ag(r);case ft.Case:return lg(r);case ft.Match:return hg(r);case ft.Interpolate:return cg(r);case ft.ToString:return ug(r);default:throw new Error(`Unsupported operator ${e}`)}}function ng(r,t){const e=r.operator,n=r.args.length,o=new Array(n);for(let l=0;l{for(let u=0;u{for(let u=0;uo.properties[n];case ft.Var:return o=>o.variables[n];default:throw new Error(`Unsupported accessor operator ${r.operator}`)}}function rg(r,t){const e=r.operator,n=Sn(r.args[0]),o=Sn(r.args[1]);switch(e){case ft.Equal:return l=>n(l)===o(l);case ft.NotEqual:return l=>n(l)!==o(l);case ft.LessThan:return l=>n(l)n(l)<=o(l);case ft.GreaterThan:return l=>n(l)>o(l);case ft.GreaterThanOrEqualTo:return l=>n(l)>=o(l);default:throw new Error(`Unsupported comparison operator ${e}`)}}function og(r,t){const e=r.operator,n=r.args.length,o=new Array(n);for(let l=0;l{for(let u=0;u{for(let u=0;u{const u=o[0](l),g=o[1](l),x=o[2](l);return u>=g&&u<=x};case ft.In:return l=>{const u=o[0](l);for(let g=1;g!o[0](l);default:throw new Error(`Unsupported logical operator ${e}`)}}function ag(r,t){const e=r.operator,n=r.args.length,o=new Array(n);for(let l=0;l{let u=1;for(let g=0;go[0](l)/o[1](l);case ft.Add:return l=>{let u=0;for(let g=0;go[0](l)-o[1](l);case ft.Clamp:return l=>{const u=o[0](l),g=o[1](l);if(ux?x:u};case ft.Mod:return l=>o[0](l)%o[1](l);case ft.Pow:return l=>Math.pow(o[0](l),o[1](l));case ft.Abs:return l=>Math.abs(o[0](l));case ft.Floor:return l=>Math.floor(o[0](l));case ft.Ceil:return l=>Math.ceil(o[0](l));case ft.Round:return l=>Math.round(o[0](l));case ft.Sin:return l=>Math.sin(o[0](l));case ft.Cos:return l=>Math.cos(o[0](l));case ft.Atan:return n===2?l=>Math.atan2(o[0](l),o[1](l)):l=>Math.atan(o[0](l));case ft.Sqrt:return l=>Math.sqrt(o[0](l));default:throw new Error(`Unsupported numeric operator ${e}`)}}function lg(r,t){const e=r.args.length,n=new Array(e);for(let o=0;o{for(let l=0;l{const l=n[0](o);for(let u=1;u{const l=n[0](o),u=n[1](o);let g,x;for(let E=2;E=u)return E===2?A:S?fg(l,u,g,x,w,A):oo(l,u,g,x,w,A);g=w,x=A}return x}}function ug(r,t){const e=r.operator,n=r.args.length,o=new Array(n);for(let l=0;l{const u=o[0](l);return r.args[0].type===wi?tc(u):u.toString()};default:throw new Error(`Unsupported convert operator ${e}`)}}function oo(r,t,e,n,o,l){const u=o-e;if(u===0)return n;const g=t-e,x=r===1?g/u:(Math.pow(r,g)-1)/(Math.pow(r,u)-1);return n+x*(l-n)}function fg(r,t,e,n,o,l){if(o-e===0)return n;const g=qc(n),x=qc(l);let E=x[2]-g[2];E>180?E-=360:E<-180&&(E+=360);const w=[oo(r,t,e,g[0],o,x[0]),oo(r,t,e,g[1],o,x[1]),g[2]+oo(r,t,e,0,o,E),oo(r,t,e,n[3],o,l[3])];return y0(qf(w))}function dg(r){return!0}function gg(r){const t=F0(),e=mg(r,t),n=k0();return function(o,l){if(n.properties=o.getPropertiesInternal(),n.resolution=l,t.featureId){const u=o.getId();u!==void 0?n.featureId=u:n.featureId=null}return t.geometryType&&(n.geometryType=B0(o.getGeometry())),e(n)}}function hu(r){const t=F0(),e=r.length,n=new Array(e);for(let u=0;u4)throw new Error(`Expected a color with 3 or 4 values for ${t}`);return e}function W0(r,t){const e=ko(r,t);if(e.length!==2)throw new Error(`Expected an array of two numbers for ${t}`);return e}function bg(r,t){return typeof r=="number"?r:W0(r,t)}const du={RENDER_ORDER:"renderOrder"};class X0 extends el{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(du.RENDER_ORDER)}getStyle(){return this.style_}getStyleFunction(){return this.styleFunction_}getUpdateWhileAnimating(){return this.updateWhileAnimating_}getUpdateWhileInteracting(){return this.updateWhileInteracting_}renderDeclutter(t,e){const n=this.getDeclutter();n in t.declutter||(t.declutter[n]=new D0(9)),this.getRenderer().renderDeclutter(t,e)}setRenderOrder(t){this.set(du.RENDER_ORDER,t)}setStyle(t){this.style_=t===void 0?v0:t;const e=Tg(t);this.styleFunction_=t===null?void 0:yd(e),this.changed()}}function Tg(r){if(r===void 0)return v0;if(!r)return null;if(typeof r=="function"||r instanceof ya)return r;if(!Array.isArray(r))return hu([r]);if(r.length===0)return[];const t=r.length,e=r[0];if(e instanceof ya){const o=new Array(t);for(let l=0;lx&&(this.instructions.push([Bt.CUSTOM,x,w,t,n,bs,l]),this.hitDetectionInstructions.push([Bt.CUSTOM,x,w,t,o||n,bs,l]));break;case"Point":E=t.getFlatCoordinates(),this.coordinates.push(E[0],E[1]),w=this.coordinates.length,this.instructions.push([Bt.CUSTOM,x,w,t,n,void 0,l]),this.hitDetectionInstructions.push([Bt.CUSTOM,x,w,t,o||n,void 0,l]);break}this.endGeometry(e)}beginGeometry(t,e,n){this.beginGeometryInstruction1_=[Bt.BEGIN_GEOMETRY,e,0,t,n],this.instructions.push(this.beginGeometryInstruction1_),this.beginGeometryInstruction2_=[Bt.BEGIN_GEOMETRY,e,0,t,n],this.hitDetectionInstructions.push(this.beginGeometryInstruction2_)}finish(){return{instructions:this.instructions,hitDetectionInstructions:this.hitDetectionInstructions,coordinates:this.coordinates}}reverseHitDetectionInstructions(){const t=this.hitDetectionInstructions;t.reverse();let e;const n=t.length;let o,l,u=-1;for(e=0;ethis.maxLineWidth&&(this.maxLineWidth=n.lineWidth,this.bufferedMaxExtent_=null)}else n.strokeStyle=void 0,n.lineCap=void 0,n.lineDash=null,n.lineDashOffset=void 0,n.lineJoin=void 0,n.lineWidth=void 0,n.miterLimit=void 0}createFill(t){const e=t.fillStyle,n=[Bt.SET_FILL_STYLE,e];return typeof e!="string"&&n.push(t.fillPatternScale),n}applyStroke(t){this.instructions.push(this.createStroke(t))}createStroke(t){return[Bt.SET_STROKE_STYLE,t.strokeStyle,t.lineWidth*this.pixelRatio,t.lineCap,t.lineJoin,t.miterLimit,this.applyPixelRatio(t.lineDash),t.lineDashOffset*this.pixelRatio]}updateFillStyle(t,e){const n=t.fillStyle;(typeof n!="string"||t.currentFillStyle!=n)&&(n!==void 0&&this.instructions.push(e.call(this,t)),t.currentFillStyle=n)}updateStrokeStyle(t,e){const n=t.strokeStyle,o=t.lineCap,l=t.lineDash,u=t.lineDashOffset,g=t.lineJoin,x=t.lineWidth,E=t.miterLimit;(t.currentStrokeStyle!=n||t.currentLineCap!=o||l!=t.currentLineDash&&!Ls(t.currentLineDash,l)||t.currentLineDashOffset!=u||t.currentLineJoin!=g||t.currentLineWidth!=x||t.currentMiterLimit!=E)&&(n!==void 0&&e.call(this,t),t.currentStrokeStyle=n,t.currentLineCap=o,t.currentLineDash=l,t.currentLineDashOffset=u,t.currentLineJoin=g,t.currentLineWidth=x,t.currentMiterLimit=E)}endGeometry(t){this.beginGeometryInstruction1_[2]=this.instructions.length,this.beginGeometryInstruction1_=null,this.beginGeometryInstruction2_[2]=this.hitDetectionInstructions.length,this.beginGeometryInstruction2_=null;const e=[Bt.END_GEOMETRY,t];this.instructions.push(e),this.hitDetectionInstructions.push(e)}getBufferedMaxExtent(){if(!this.bufferedMaxExtent_&&(this.bufferedMaxExtent_=Zu(this.maxExtent),this.maxLineWidth>0)){const t=this.resolution*(this.maxLineWidth+1)/2;Dh(this.bufferedMaxExtent_,t,this.bufferedMaxExtent_)}return this.bufferedMaxExtent_}}class Sg extends Go{constructor(t,e,n,o){super(t,e,n,o),this.hitDetectionImage_=null,this.image_=null,this.imagePixelRatio_=void 0,this.anchorX_=void 0,this.anchorY_=void 0,this.height_=void 0,this.opacity_=void 0,this.originX_=void 0,this.originY_=void 0,this.rotateWithView_=void 0,this.rotation_=void 0,this.scale_=void 0,this.width_=void 0,this.declutterMode_=void 0,this.declutterImageWithText_=void 0}drawPoint(t,e,n){if(!this.image_||this.maxExtent&&!Dr(this.maxExtent,t.getFlatCoordinates()))return;this.beginGeometry(t,e,n);const o=t.getFlatCoordinates(),l=t.getStride(),u=this.coordinates.length,g=this.appendFlatPointCoordinates(o,l);this.instructions.push([Bt.DRAW_IMAGE,u,g,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([Bt.DRAW_IMAGE,u,g,this.hitDetectionImage_,this.anchorX_,this.anchorY_,this.height_,1,this.originX_,this.originY_,this.rotateWithView_,this.rotation_,this.scale_,this.width_,this.declutterMode_,this.declutterImageWithText_]),this.endGeometry(e)}drawMultiPoint(t,e,n){if(!this.image_)return;this.beginGeometry(t,e,n);const o=t.getFlatCoordinates(),l=[];for(let x=0,E=o.length;x=r){const L=(r-g+P)/P,F=en(E,A,L),V=en(w,S,L);x.push(F,V),l.push(x),x=[F,V],g==r&&(u+=o),g=0}else if(g0&&l.push(x),l}function Dg(r,t,e,n,o){let l=e,u=e,g=0,x=0,E=e,w,A,S,P,L,F,V,z,U,Y;for(A=e;Ar&&(x>g&&(g=x,l=E,u=A),x=0,E=A-o)),S=P,V=U,z=Y),L=Z,F=$}return x+=P,x>g?[E,A]:[l,u]}const va={left:0,center:.5,right:1,top:0,middle:.5,hanging:.2,alphabetic:.8,ideographic:.8,bottom:1};class Lg extends Go{constructor(t,e,n,o){super(t,e,n,o),this.labels_=null,this.text_="",this.textOffsetX_=0,this.textOffsetY_=0,this.textRotateWithView_=void 0,this.textRotation_=0,this.textFillState_=null,this.fillStates={},this.fillStates[ji]={fillStyle:ji},this.textStrokeState_=null,this.strokeStates={},this.textState_={},this.textStates={},this.textKey_="",this.fillKey_="",this.strokeKey_="",this.declutterMode_=void 0,this.declutterImageWithText_=void 0}finish(){const t=super.finish();return t.textStates=this.textStates,t.fillStates=this.fillStates,t.strokeStates=this.strokeStates,t}drawText(t,e,n){const o=this.textFillState_,l=this.textStrokeState_,u=this.textState_;if(this.text_===""||!u||!o&&!l)return;const g=this.coordinates;let x=g.length;const E=t.getType();let w=null,A=t.getStride();if(u.placement==="line"&&(E=="LineString"||E=="MultiLineString"||E=="Polygon"||E=="MultiPolygon")){if(!Zi(this.maxExtent,t.getExtent()))return;let S;if(w=t.getFlatCoordinates(),E=="LineString")S=[w.length];else if(E=="MultiLineString")S=t.getEnds();else if(E=="Polygon")S=t.getEnds().slice(0,1);else if(E=="MultiPolygon"){const V=t.getEndss();S=[];for(let z=0,U=V.length;z{const $=g[(U+Z)*2]===w[Z*A]&&g[(U+Z)*2+1]===w[Z*A+1];return $||--U,$})}this.saveTextStates_(),(u.backgroundFill||u.backgroundStroke)&&(this.setFillStrokeStyle(u.backgroundFill,u.backgroundStroke),u.backgroundFill&&this.updateFillStyle(this.state,this.createFill),u.backgroundStroke&&(this.updateStrokeStyle(this.state,this.applyStroke),this.hitDetectionInstructions.push(this.createStroke(this.state)))),this.beginGeometry(t,e,n);let L=u.padding;if(L!=Js&&(u.scale[0]<0||u.scale[1]<0)){let U=u.padding[0],Y=u.padding[1],Z=u.padding[2],$=u.padding[3];u.scale[0]<0&&(Y=-Y,$=-$),u.scale[1]<0&&(U=-U,Z=-Z),L=[U,Y,Z,$]}const F=this.pixelRatio;this.instructions.push([Bt.DRAW_IMAGE,x,P,null,NaN,NaN,NaN,1,0,0,this.textRotateWithView_,this.textRotation_,[1,1],NaN,this.declutterMode_,this.declutterImageWithText_,L==Js?Js:L.map(function(U){return U*F}),!!u.backgroundFill,!!u.backgroundStroke,this.text_,this.textKey_,this.strokeKey_,this.fillKey_,this.textOffsetX_,this.textOffsetY_,S]);const V=1/F,z=this.state.fillStyle;u.backgroundFill&&(this.state.fillStyle=ji,this.hitDetectionInstructions.push(this.createFill(this.state))),this.hitDetectionInstructions.push([Bt.DRAW_IMAGE,x,P,null,NaN,NaN,NaN,1,0,0,this.textRotateWithView_,this.textRotation_,[V,V],NaN,this.declutterMode_,this.declutterImageWithText_,L,!!u.backgroundFill,!!u.backgroundStroke,this.text_,this.textKey_,this.strokeKey_,this.fillKey_?ji:this.fillKey_,this.textOffsetX_,this.textOffsetY_,S]),u.backgroundFill&&(this.state.fillStyle=z,this.hitDetectionInstructions.push(this.createFill(this.state))),this.endGeometry(e)}}saveTextStates_(){const t=this.textStrokeState_,e=this.textState_,n=this.textFillState_,o=this.strokeKey_;t&&(o in this.strokeStates||(this.strokeStates[o]={strokeStyle:t.strokeStyle,lineCap:t.lineCap,lineDashOffset:t.lineDashOffset,lineWidth:t.lineWidth,lineJoin:t.lineJoin,miterLimit:t.miterLimit,lineDash:t.lineDash}));const l=this.textKey_;l in this.textStates||(this.textStates[l]={font:e.font,textAlign:e.textAlign||Io,justify:e.justify,textBaseline:e.textBaseline||ba,scale:e.scale});const u=this.fillKey_;n&&(u in this.fillStates||(this.fillStates[u]={fillStyle:n.fillStyle}))}drawChars_(t,e){const n=this.textStrokeState_,o=this.textState_,l=this.strokeKey_,u=this.textKey_,g=this.fillKey_;this.saveTextStates_();const x=this.pixelRatio,E=va[o.textBaseline],w=this.textOffsetY_*x,A=this.text_,S=n?n.lineWidth*Math.abs(o.scale[0])/2:0;this.instructions.push([Bt.DRAW_CHARS,t,e,E,o.overflow,g,o.maxAngle,x,w,l,S*x,A,u,1,this.declutterMode_]),this.hitDetectionInstructions.push([Bt.DRAW_CHARS,t,e,E,o.overflow,g&&ji,o.maxAngle,x,w,l,S*x,A,u,1/x,this.declutterMode_])}setTextStyle(t,e){let n,o,l;if(!t)this.text_="";else{const u=t.getFill();u?(o=this.textFillState_,o||(o={},this.textFillState_=o),o.fillStyle=Gn(u.getColor()||ji)):(o=null,this.textFillState_=o);const g=t.getStroke();if(!g)l=null,this.textStrokeState_=l;else{l=this.textStrokeState_,l||(l={},this.textStrokeState_=l);const L=g.getLineDash(),F=g.getLineDashOffset(),V=g.getWidth(),z=g.getMiterLimit();l.lineCap=g.getLineCap()||Fr,l.lineDash=L?L.slice():rs,l.lineDashOffset=F===void 0?os:F,l.lineJoin=g.getLineJoin()||Br,l.lineWidth=V===void 0?Mo:V,l.miterLimit=z===void 0?Co:z,l.strokeStyle=Gn(g.getColor()||Ao)}n=this.textState_;const x=t.getFont()||S0;gd(x);const E=t.getScaleArray();n.overflow=t.getOverflow(),n.font=x,n.maxAngle=t.getMaxAngle(),n.placement=t.getPlacement(),n.textAlign=t.getTextAlign(),n.repeat=t.getRepeat(),n.justify=t.getJustify(),n.textBaseline=t.getTextBaseline()||ba,n.backgroundFill=t.getBackgroundFill(),n.backgroundStroke=t.getBackgroundStroke(),n.padding=t.getPadding()||Js,n.scale=E===void 0?[1,1]:E;const w=t.getOffsetX(),A=t.getOffsetY(),S=t.getRotateWithView(),P=t.getRotation();this.text_=t.getText()||"",this.textOffsetX_=w===void 0?0:w,this.textOffsetY_=A===void 0?0:A,this.textRotateWithView_=S===void 0?!1:S,this.textRotation_=P===void 0?0:P,this.strokeKey_=l?(typeof l.strokeStyle=="string"?l.strokeStyle:be(l.strokeStyle))+l.lineCap+l.lineDashOffset+"|"+l.lineWidth+l.lineJoin+l.miterLimit+"["+l.lineDash.join()+"]":"",this.textKey_=n.font+n.scale+(n.textAlign||"?")+(n.repeat||"?")+(n.justify||"?")+(n.textBaseline||"?"),this.fillKey_=o&&o.fillStyle?typeof o.fillStyle=="string"?o.fillStyle:"|"+be(o.fillStyle):""}this.declutterMode_=t.getDeclutterMode(),this.declutterImageWithText_=e}}const Fg={Circle:mu,Default:Go,Image:Rg,LineString:Og,Polygon:mu,Text:Lg};class Bg{constructor(t,e,n,o){this.tolerance_=t,this.maxExtent_=e,this.pixelRatio_=o,this.resolution_=n,this.buildersByZIndex_={}}finish(){const t={};for(const e in this.buildersByZIndex_){t[e]=t[e]||{};const n=this.buildersByZIndex_[e];for(const o in n){const l=n[o].finish();t[e][o]=l}}return t}getBuilder(t,e){const n=t!==void 0?t.toString():"0";let o=this.buildersByZIndex_[n];o===void 0&&(o={},this.buildersByZIndex_[n]=o);let l=o[e];if(l===void 0){const u=Fg[e];l=new u(this.tolerance_,this.maxExtent_,this.resolution_,this.pixelRatio_),o[e]=l}return l}}class kg extends Po{constructor(t){super(),this.ready=!0,this.boundHandleImageChange_=this.handleImageChange_.bind(this),this.layer_=t}getFeatures(t){return Xt()}getData(t){return null}prepareFrame(t){return Xt()}renderFrame(t,e){return Xt()}loadedTileCallback(t,e,n){t[e]||(t[e]={}),t[e][n.tileCoord.toString()]=n}createLoadedTileFinder(t,e,n){return(o,l)=>{const u=this.loadedTileCallback.bind(this,n,o);return t.forEachLoadedTile(e,o,l,u)}}forEachFeatureAtCoordinate(t,e,n,o,l){}getLayer(){return this.layer_}handleFontsChanged(){}handleImageChange_(t){const e=t.target;(e.getState()===ie.LOADED||e.getState()===ie.ERROR)&&this.renderIfReadyAndVisible()}loadImage(t){let e=t.getState();return e!=ie.LOADED&&e!=ie.ERROR&&t.addEventListener(jt.CHANGE,this.boundHandleImageChange_),e==ie.IDLE&&(t.load(),e=t.getState()),e==ie.LOADED}renderIfReadyAndVisible(){const t=this.getLayer();t&&t.getVisible()&&t.getSourceState()==="ready"&&t.changed()}renderDeferred(t){}disposeInternal(){delete this.layer_,super.disposeInternal()}}class Y0 extends hs{constructor(t,e,n,o){super(t),this.inversePixelTransform=e,this.frameState=n,this.context=o}}class H0{constructor(){this.instructions_=[],this.zIndex=0,this.offset_=0,this.context_=new Proxy(Aa(),{get:(t,e)=>{if(typeof Aa()[e]=="function")return this.instructions_[this.zIndex+this.offset_]||(this.instructions_[this.zIndex+this.offset_]=[]),this.instructions_[this.zIndex+this.offset_].push(e),this.pushMethodArgs_},set:(t,e,n)=>(this.instructions_[this.zIndex+this.offset_]||(this.instructions_[this.zIndex+this.offset_]=[]),this.instructions_[this.zIndex+this.offset_].push(e,n),!0)})}pushMethodArgs_=(...t)=>(this.instructions_[this.zIndex+this.offset_].push(t),this);pushFunction(t){this.instructions_[this.zIndex+this.offset_].push(t)}getContext(){return this.context_}draw(t){this.instructions_.forEach(e=>{for(let n=0,o=e.length;nlt[2]}else xt=Z>H;const at=Math.PI,ut=[],pt=ot+n===t;t=ot,V=0,z=X,S=r[t],P=r[t+1];let q;if(pt){U(),q=Math.atan2(P-F,S-L),xt&&(q+=q>0?-at:at);const lt=(H+Z)/2,yt=(_t+$)/2;return ut[0]=[lt,yt,(J-l)/2,q,o],ut}o=o.replace(/\n/g," ");for(let lt=0,yt=o.length;lt0?-at:at),q!==void 0){let gt=Lt-q;if(gt+=gt>at?-2*at:gt<-at?2*at:0,Math.abs(gt)>u)return null}q=Lt;const oe=lt;let Gt=0;for(;lt0&&r.push(` +`,""),r.push(t,""),r}class Wg{constructor(t,e,n,o,l){this.overlaps=n,this.pixelRatio=e,this.resolution=t,this.alignAndScaleFill_,this.instructions=o.instructions,this.coordinates=o.coordinates,this.coordinateCache_={},this.renderedTransform_=Tn(),this.hitDetectionInstructions=o.hitDetectionInstructions,this.pixelCoordinates_=null,this.viewRotation_=0,this.fillStates=o.fillStates||{},this.strokeStates=o.strokeStates||{},this.textStates=o.textStates||{},this.widths_={},this.labels_={},this.zIndexContext_=l?new H0:null}getZIndexContext(){return this.zIndexContext_}createLabel(t,e,n,o){const l=t+e+n+o;if(this.labels_[l])return this.labels_[l];const u=o?this.strokeStates[o]:null,g=n?this.fillStates[n]:null,x=this.textStates[e],E=this.pixelRatio,w=[x.scale[0]*E,x.scale[1]*E],A=Array.isArray(t),S=x.justify?va[x.justify]:Ul(Array.isArray(t)?t[0]:t,x.textAlign||Io),P=o&&u.lineWidth?u.lineWidth:0,L=A?t:t.split(` +`).reduce(zg,[]),{width:F,height:V,widths:z,heights:U,lineWidths:Y}=xd(x,L),Z=F+P,$=[],ot=(Z+2)*w[0],X=(V+P)*w[1],J={width:ot<0?Math.floor(ot):Math.ceil(ot),height:X<0?Math.floor(X):Math.ceil(X),contextInstructions:$};(w[0]!=1||w[1]!=1)&&$.push("scale",w),o&&($.push("strokeStyle",u.strokeStyle),$.push("lineWidth",P),$.push("lineCap",u.lineCap),$.push("lineJoin",u.lineJoin),$.push("miterLimit",u.miterLimit),$.push("setLineDash",[u.lineDash]),$.push("lineDashOffset",u.lineDashOffset)),n&&$.push("fillStyle",g.fillStyle),$.push("textBaseline","middle"),$.push("textAlign","center");const H=.5-S;let _t=S*Z+H*P;const xt=[],at=[];let ut=0,pt=0,q=0,lt=0,yt;for(let Lt=0,oe=L.length;Ltt?t-E:l,Z=u+w>e?e-w:u,$=L[3]+Y*S[0]+L[1],ot=L[0]+Z*S[1]+L[2],X=z-L[3],J=U-L[0];(F||A!==0)&&(ws[0]=X,Es[0]=X,ws[1]=J,Jn[1]=J,Jn[0]=X+$,Qn[0]=Jn[0],Qn[1]=J+ot,Es[1]=Qn[1]);let H;return A!==0?(H=as(Tn(),n,o,1,1,A,-n,-o),bi(H,ws),bi(H,Jn),bi(H,Qn),bi(H,Es),Os(Math.min(ws[0],Jn[0],Qn[0],Es[0]),Math.min(ws[1],Jn[1],Qn[1],Es[1]),Math.max(ws[0],Jn[0],Qn[0],Es[0]),Math.max(ws[1],Jn[1],Qn[1],Es[1]),wr)):Os(Math.min(X,X+$),Math.min(J,J+ot),Math.max(X,X+$),Math.max(J,J+ot),wr),P&&(z=Math.round(z),U=Math.round(U)),{drawImageX:z,drawImageY:U,drawImageW:Y,drawImageH:Z,originX:E,originY:w,declutterBox:{minX:wr[0],minY:wr[1],maxX:wr[2],maxY:wr[3],value:V},canvasTransform:H,scale:S}}replayImageOrLabel_(t,e,n,o,l,u,g){const x=!!(u||g),E=o.declutterBox,w=g?g[2]*o.scale[0]/2:0;return E.minX-w<=e[0]&&E.maxX+w>=0&&E.minY-w<=e[1]&&E.maxY+w>=0&&(x&&this.replayTextBackground_(t,ws,Jn,Qn,Es,u,g),_d(t,o.canvasTransform,l,n,o.originX,o.originY,o.drawImageW,o.drawImageH,o.drawImageX,o.drawImageY,o.scale)),!0}fill_(t){const e=this.alignAndScaleFill_;if(e){const n=bi(this.renderedTransform_,[0,0]),o=512*this.pixelRatio;t.save(),t.translate(n[0]%o,n[1]%o),e!==1&&t.scale(e,e),t.rotate(this.viewRotation_)}t.fill(),e&&t.restore()}setStrokeStyle_(t,e){t.strokeStyle=e[1],t.lineWidth=e[2],t.lineCap=e[3],t.lineJoin=e[4],t.miterLimit=e[5],t.lineDashOffset=e[7],t.setLineDash(e[6])}drawLabelWithPointPlacement_(t,e,n,o){const l=this.textStates[e],u=this.createLabel(t,e,o,n),g=this.strokeStates[n],x=this.pixelRatio,E=Ul(Array.isArray(t)?t[0]:t,l.textAlign||Io),w=va[l.textBaseline||ba],A=g&&g.lineWidth?g.lineWidth:0,S=u.width/x-2*l.scale[0],P=E*S+2*(.5-E)*A,L=w*u.height/x+2*(.5-w)*A;return{label:u,anchorX:P,anchorY:L}}execute_(t,e,n,o,l,u,g,x){const E=this.zIndexContext_;let w;this.pixelCoordinates_&&Ls(n,this.renderedTransform_)?w=this.pixelCoordinates_:(this.pixelCoordinates_||(this.pixelCoordinates_=[]),w=vs(this.coordinates,0,this.coordinates.length,2,n,this.pixelCoordinates_),tf(this.renderedTransform_,n));let A=0;const S=o.length;let P=0,L,F,V,z,U,Y,Z,$,ot,X,J,H,_t,xt=0,at=0,ut=null,pt=null;const q=this.coordinateCache_,lt=this.viewRotation_,yt=Math.round(Math.atan2(-n[1],n[0])*1e12)/1e12,Lt={context:t,pixelRatio:this.pixelRatio,resolution:this.resolution,rotation:lt},oe=this.instructions!=o||this.overlaps?0:200;let Gt,$t,Ft,te;for(;Aoe&&(this.fill_(t),xt=0),at>oe&&(t.stroke(),at=0),!xt&&!at&&(t.beginPath(),U=NaN,Y=NaN),++A;break;case Bt.CIRCLE:P=gt[1];const Rt=w[P],Ne=w[P+1],ye=w[P+2],mi=w[P+3],ke=ye-Rt,Ke=mi-Ne,ze=Math.sqrt(ke*ke+Ke*Ke);t.moveTo(Rt+ze,Ne),t.arc(Rt,Ne,ze,0,2*Math.PI,!0),++A;break;case Bt.CLOSE_PATH:t.closePath(),++A;break;case Bt.CUSTOM:P=gt[1],L=gt[2];const ne=gt[3],xi=gt[4],hi=gt[5];Lt.geometry=ne,Lt.feature=Gt,A in q||(q[A]=[]);const Ei=q[A];hi?hi(w,P,L,2,Ei):(Ei[0]=w[P],Ei[1]=w[P+1],Ei.length=2),E&&(E.zIndex=gt[6]),xi(Ei,Lt),++A;break;case Bt.DRAW_IMAGE:P=gt[1],L=gt[2],ot=gt[3],F=gt[4],V=gt[5];let Ge=gt[6];const he=gt[7],ee=gt[8],_i=gt[9],St=gt[10];let Ci=gt[11];const on=gt[12];let ci=gt[13];z=gt[14]||"declutter";const Ui=gt[15];if(!ot&>.length>=20){X=gt[19],J=gt[20],H=gt[21],_t=gt[22];const fe=this.drawLabelWithPointPlacement_(X,J,H,_t);ot=fe.label,gt[3]=ot;const ue=gt[23];F=(fe.anchorX-ue)*this.pixelRatio,gt[4]=F;const Wt=gt[24];V=(fe.anchorY-Wt)*this.pixelRatio,gt[5]=V,Ge=ot.height,gt[6]=Ge,ci=ot.width,gt[13]=ci}let ni;gt.length>25&&(ni=gt[25]);let qi,qe,ce;gt.length>17?(qi=gt[16],qe=gt[17],ce=gt[18]):(qi=Js,qe=!1,ce=!1),St&&yt?Ci+=lt:!St&&!yt&&(Ci-=lt);let cr=0;for(;P!Z0.includes(r));class Vg{constructor(t,e,n,o,l,u,g){this.maxExtent_=t,this.overlaps_=o,this.pixelRatio_=n,this.resolution_=e,this.renderBuffer_=u,this.executorsByZIndex_={},this.hitDetectionContext_=null,this.hitDetectionTransform_=Tn(),this.renderedContext_=null,this.deferredZIndexContexts_={},this.createExecutors_(l,g)}clip(t,e){const n=this.getClipCoords(e);t.beginPath(),t.moveTo(n[0],n[1]),t.lineTo(n[2],n[3]),t.lineTo(n[4],n[5]),t.lineTo(n[6],n[7]),t.clip()}createExecutors_(t,e){for(const n in t){let o=this.executorsByZIndex_[n];o===void 0&&(o={},this.executorsByZIndex_[n]=o);const l=t[n];for(const u in l){const g=l[u];o[u]=new Wg(this.resolution_,this.pixelRatio_,this.overlaps_,g,e)}}}hasExecutors(t){for(const e in this.executorsByZIndex_){const n=this.executorsByZIndex_[e];for(let o=0,l=t.length;o0){if(!u||X==="none"||P!=="Image"&&P!=="Text"||u.includes($)){const xt=(S[H]-3)/4,at=o-xt%g,ut=o-(xt/g|0),pt=l($,ot,at*at+ut*ut);if(pt)return pt}w.clearRect(0,0,g,g);break}}const F=Object.keys(this.executorsByZIndex_).map(Number);F.sort(ss);let V,z,U,Y,Z;for(V=F.length-1;V>=0;--V){const $=F[V].toString();for(U=this.executorsByZIndex_[$],z=Sr.length-1;z>=0;--z)if(P=Sr[z],Y=U[P],Y!==void 0&&(Z=Y.executeHitDetection(w,x,n,L,A),Z))return Z}}getClipCoords(t){const e=this.maxExtent_;if(!e)return null;const n=e[0],o=e[1],l=e[2],u=e[3],g=[n,o,n,u,l,u,l,o];return vs(g,0,8,2,t,g),g}isEmpty(){return er(this.executorsByZIndex_)}execute(t,e,n,o,l,u,g){const x=Object.keys(this.executorsByZIndex_).map(Number);x.sort(ss),u=u||Sr;const E=Sr.length;let w,A,S,P,L;for(g&&x.reverse(),w=0,A=x.length;wz.execute($,e,n,o,l,g)),Z&&Y.restore(),U){U.offset();const $=x[w]*E+S;this.deferredZIndexContexts_[$]||(this.deferredZIndexContexts_[$]=[]),this.deferredZIndexContexts_[$].push(U)}}}}this.renderedContext_=t}getDeferredZIndexContexts(){return this.deferredZIndexContexts_}getRenderedContext(){return this.renderedContext_}renderDeferred(){const t=this.deferredZIndexContexts_,e=Object.keys(t).map(Number).sort(ss);for(let n=0,o=e.length;n{l.draw(this.renderedContext_),l.clear()}),t[e[n]].length=0}}const zl={};function Yg(r){if(zl[r]!==void 0)return zl[r];const t=r*2+1,e=r*r,n=new Array(e+1);for(let l=0;l<=r;++l)for(let u=0;u<=r;++u){const g=l*l+u*u;if(g>e)break;let x=n[g];x||(x=[],n[g]=x),x.push(((r+l)*t+(r+u))*4+3),l>0&&x.push(((r-l)*t+(r+u))*4+3),u>0&&(x.push(((r+l)*t+(r-u))*4+3),l>0&&x.push(((r-l)*t+(r-u))*4+3))}const o=[];for(let l=0,u=n.length;lA*this.pixelRatio_),lineDashOffset:(u||os)*this.pixelRatio_,lineJoin:g!==void 0?g:Br,lineWidth:(x!==void 0?x:Mo)*this.pixelRatio_,miterLimit:E!==void 0?E:Co,strokeStyle:Gn(n||Ao)}}}setImageStyle(t){let e;if(!t||!(e=t.getSize())){this.image_=null;return}const n=t.getPixelRatio(this.pixelRatio_),o=t.getAnchor(),l=t.getOrigin();this.image_=t.getImage(this.pixelRatio_),this.imageAnchorX_=o[0]*n,this.imageAnchorY_=o[1]*n,this.imageHeight_=e[1]*n,this.imageOpacity_=t.getOpacity(),this.imageOriginX_=l[0],this.imageOriginY_=l[1],this.imageRotateWithView_=t.getRotateWithView(),this.imageRotation_=t.getRotation();const u=t.getScaleArray();this.imageScale_=[u[0]*this.pixelRatio_/n,u[1]*this.pixelRatio_/n],this.imageWidth_=e[0]*n}setTextStyle(t){if(!t)this.text_="";else{const e=t.getFill();if(!e)this.textFillState_=null;else{const P=e.getColor();this.textFillState_={fillStyle:Gn(P||ji)}}const n=t.getStroke();if(!n)this.textStrokeState_=null;else{const P=n.getColor(),L=n.getLineCap(),F=n.getLineDash(),V=n.getLineDashOffset(),z=n.getLineJoin(),U=n.getWidth(),Y=n.getMiterLimit();this.textStrokeState_={lineCap:L!==void 0?L:Fr,lineDash:F||rs,lineDashOffset:V||os,lineJoin:z!==void 0?z:Br,lineWidth:U!==void 0?U:Mo,miterLimit:Y!==void 0?Y:Co,strokeStyle:Gn(P||Ao)}}const o=t.getFont(),l=t.getOffsetX(),u=t.getOffsetY(),g=t.getRotateWithView(),x=t.getRotation(),E=t.getScaleArray(),w=t.getText(),A=t.getTextAlign(),S=t.getTextBaseline();this.textState_={font:o!==void 0?o:S0,textAlign:A!==void 0?A:Io,textBaseline:S!==void 0?S:ba},this.text_=w!==void 0?Array.isArray(w)?w.reduce((P,L,F)=>P+=F%2?" ":L,""):w:"",this.textOffsetX_=l!==void 0?this.pixelRatio_*l:0,this.textOffsetY_=u!==void 0?this.pixelRatio_*u:0,this.textRotateWithView_=g!==void 0?g:!1,this.textRotation_=x!==void 0?x:0,this.textScale_=[this.pixelRatio_*E[0],this.pixelRatio_*E[1]]}}}const jg=Hg,Fn=.5;function Zg(r,t,e,n,o,l,u,g,x){const E=x?Wh(o):o,w=r[0]*Fn,A=r[1]*Fn,S=Si(w,A);S.imageSmoothingEnabled=!1;const P=S.canvas,L=new jg(S,Fn,o,null,u,g,x?Va(Sf(),x):null),F=e.length,V=Math.floor((256*256*256-1)/F),z={};for(let Y=1;Y<=F;++Y){const Z=e[Y-1],$=Z.getStyleFunction()||n;if(!$)continue;let ot=$(Z,l);if(!ot)continue;Array.isArray(ot)||(ot=[ot]);const J=(Y*V).toString(16).padStart(7,"#00000");for(let H=0,_t=ot.length;H<_t;++H){const xt=ot[H],at=xt.getGeometryFunction()(Z);if(!at||!Zi(E,at.getExtent()))continue;const ut=xt.clone(),pt=ut.getFill();pt&&pt.setColor(J);const q=ut.getStroke();q&&(q.setColor(J),q.setLineDash(null)),ut.setText(void 0);const lt=xt.getImage();if(lt){const Gt=lt.getImageSize();if(!Gt)continue;const $t=Si(Gt[0],Gt[1],void 0,{alpha:!1}),Ft=$t.canvas;$t.fillStyle=J,$t.fillRect(0,0,Ft.width,Ft.height),ut.setImage(new il({img:Ft,anchor:lt.getAnchor(),anchorXUnits:"pixels",anchorYUnits:"pixels",offset:lt.getOrigin(),opacity:1,size:lt.getSize(),scale:lt.getScale(),rotation:lt.getRotation(),rotateWithView:lt.getRotateWithView()}))}const yt=ut.getZIndex()||0;let Lt=z[yt];Lt||(Lt={},z[yt]=Lt,Lt.Polygon=[],Lt.Circle=[],Lt.LineString=[],Lt.Point=[]);const oe=at.getType();if(oe==="GeometryCollection"){const Gt=at.getGeometriesArrayRecursive();for(let $t=0,Ft=Gt.length;$t0;return A&&Promise.all(x).then(()=>o(null)),$g(r,t,e,n,l,u,g),A}function $g(r,t,e,n,o,l,u){const g=e.getGeometryFunction()(t);if(!g)return;const x=g.simplifyTransformed(n,o);if(e.getRenderer())J0(r,x,e,t,u);else{const w=K0[x.getType()];w(r,x,e,t,u,l)}}function J0(r,t,e,n,o){if(t.getType()=="GeometryCollection"){const u=t.getGeometries();for(let g=0,x=u.length;g{if(this.frameState&&!this.hitDetectionImageData_&&!this.animatingOrInteracting_){const n=this.frameState.size.slice(),o=this.renderedCenter_,l=this.renderedResolution_,u=this.renderedRotation_,g=this.renderedProjection_,x=this.wrappedRenderedExtent_,E=this.getLayer(),w=[],A=n[0]*Fn,S=n[1]*Fn;w.push(this.getRenderTransform(o,l,u,Fn,A,S,0).slice());const P=E.getSource(),L=g.getExtent();if(P.getWrapX()&&g.canWrapX()&&!Zs(L,x)){let F=x[0];const V=Ce(L);let z=0,U;for(;FL[2];)++z,U=V*z,w.push(this.getRenderTransform(o,l,u,Fn,A,S,U).slice()),F-=V}this.hitDetectionImageData_=Zg(n,w,this.renderedFeatures_,E.getStyleFunction(),x,l,u,yu(l,this.renderedPixelRatio_),null)}e(Kg(t,this.renderedFeatures_,this.hitDetectionImageData_))})}forEachFeatureAtCoordinate(t,e,n,o,l){if(!this.replayGroup_)return;const u=e.viewState.resolution,g=e.viewState.rotation,x=this.getLayer(),E={},w=function(L,F,V){const z=be(L),U=E[z];if(U){if(U!==!0&&VA=L.forEachFeatureAtCoordinate(t,u,g,n,w,P&&e.declutter[P]?e.declutter[P].all().map(F=>F.value):null)),A}handleFontsChanged(){const t=this.getLayer();t.getVisible()&&this.replayGroup_&&t.changed()}handleStyleImageChange_(t){this.renderIfReadyAndVisible()}prepareFrame(t){const e=this.getLayer(),n=e.getSource();if(!n)return!1;const o=t.viewHints[Fi.ANIMATING],l=t.viewHints[Fi.INTERACTING],u=e.getUpdateWhileAnimating(),g=e.getUpdateWhileInteracting();if(this.ready&&!u&&o||!g&&l)return this.animatingOrInteracting_=!0,!0;this.animatingOrInteracting_=!1;const x=t.extent,E=t.viewState,w=E.projection,A=E.resolution,S=t.pixelRatio,P=e.getRevision(),L=e.getRenderBuffer();let F=e.getRenderOrder();F===void 0&&(F=Jg);const V=E.center.slice(),z=Dh(x,L*A),U=z.slice(),Y=[z.slice()],Z=w.getExtent();if(n.getWrapX()&&w.canWrapX()&&!Zs(Z,t.extent)){const pt=Ce(Z),q=Math.max(Ce(z)/2,pt);z[0]=Z[0]-q,z[2]=Z[2]+q,i0(V,w);const lt=$u(Y[0],w);lt[0]Z[0]&<[2]>Z[2]&&Y.push([lt[0]-pt,lt[1],lt[2]-pt,lt[3]])}if(this.ready&&this.renderedResolution_==A&&this.renderedRevision_==P&&this.renderedRenderOrder_==F&&this.renderedFrameDeclutter_===!!t.declutter&&Zs(this.wrappedRenderedExtent_,z))return Ls(this.renderedExtent_,U)||(this.hitDetectionImageData_=null,this.renderedExtent_=U),this.renderedCenter_=V,this.replayGroupChanged=!1,!0;this.replayGroup_=null;const $=new Bg(q0(A,S),z,A,S);let ot;for(let pt=0,q=Y.length;pt{let lt;const yt=pt.getStyleFunction()||e.getStyleFunction();if(yt&&(lt=yt(pt,A)),lt){const Lt=this.renderFeature(pt,X,lt,$,ot,this.getLayer().getDeclutter(),q);J=J&&!Lt}},_t=Wh(z),xt=n.getFeaturesInExtent(_t);F&&xt.sort(F);for(let pt=0,q=xt.length;ptt.clone())}const h2=Oa;class Ro extends ar{constructor(t,e,n){if(super(),this.ends_=[],this.maxDelta_=-1,this.maxDeltaRevision_=-1,Array.isArray(t[0]))this.setCoordinates(t,e);else if(e!==void 0&&n)this.setFlatCoordinates(e,t),this.ends_=n;else{const o=t,l=[],u=[];for(let x=0,E=o.length;x{if(t===this.squaredTolerance_)return this.simplifiedGeometry_;this.simplifiedGeometry_=this.clone(),e&&this.simplifiedGeometry_.applyTransform(e);const n=this.simplifiedGeometry_.getFlatCoordinates();let o;switch(this.type_){case"LineString":n.length=Ha(n,0,this.simplifiedGeometry_.flatCoordinates_.length,this.simplifiedGeometry_.stride_,t,n,0),o=[n.length];break;case"MultiLineString":o=[],n.length=c0(n,0,this.simplifiedGeometry_.ends_,this.simplifiedGeometry_.stride_,t,n,0,o);break;case"Polygon":o=[],n.length=jh(n,0,this.simplifiedGeometry_.ends_,this.simplifiedGeometry_.stride_,Math.sqrt(t),n,0,o);break}return o&&(this.simplifiedGeometry_=new Yi(this.type_,n,o,2,this.properties_,this.id_)),this.squaredTolerance_=t,this.simplifiedGeometry_}),this}}Yi.prototype.getFlatCoordinates=Yi.prototype.getOrientedFlatCoordinates;class t1 extends Rn{constructor(t){super(),this.projection=Be(t.projection),this.attributions_=Iu(t.attributions),this.attributionsCollapsible_=t.attributionsCollapsible!==void 0?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(n,o){e.viewResolver=n,e.viewRejector=o})}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_=Iu(t),this.changed()}setState(t){this.state_=t,this.changed()}}function Iu(r){return r?Array.isArray(r)?function(t){return r}:typeof r=="function"?r:function(t){return[r]}:null}const dn={ADDFEATURE:"addfeature",CHANGEFEATURE:"changefeature",CLEAR:"clear",REMOVEFEATURE:"removefeature",FEATURESLOADSTART:"featuresloadstart",FEATURESLOADEND:"featuresloadend",FEATURESLOADERROR:"featuresloaderror"};function u2(r,t){return[[-1/0,-1/0,1/0,1/0]]}let f2=!1;function d2(r,t,e,n,o,l,u){const g=new XMLHttpRequest;g.open("GET",typeof r=="function"?r(e,n,o):r,!0),t.getType()=="arraybuffer"&&(g.responseType="arraybuffer"),g.withCredentials=f2,g.onload=function(x){if(!g.status||g.status>=200&&g.status<300){const E=t.getType();try{let w;E=="text"||E=="json"?w=g.responseText:E=="xml"?w=g.responseXML||g.responseText:E=="arraybuffer"&&(w=g.response),w?l(t.readFeatures(w,{extent:e,featureProjection:o}),t.readProjection(w)):u()}catch{u()}}else u()},g.onerror=u,g.send()}function Mu(r,t){return function(e,n,o,l,u){const g=this;d2(r,t,e,n,o,function(x,E){g.addFeatures(x),l!==void 0&&l(x)},u||Pr)}}class Cs extends hs{constructor(t,e,n){super(t),this.feature=e,this.features=n}}class g2 extends t1{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_=Pr,this.format_=t.format,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&&(pe(this.format_,"`format` must be set when `url` is set"),this.loader_=Mu(this.url_,this.format_)),this.strategy_=t.strategy!==void 0?t.strategy:u2;const e=t.useSpatialIndex!==void 0?t.useSpatialIndex:!0;this.featuresRtree_=e?new Cu:null,this.loadedExtentsRtree_=new Cu,this.loadingExtentsCount_=0,this.nullGeometryFeatures_={},this.idIndex_={},this.uidIndex_={},this.featureChangeKeys_={},this.featuresCollection_=null;let n,o;Array.isArray(t.features)?o=t.features:t.features&&(n=t.features,o=n.getArray()),!e&&n===void 0&&(n=new Bn(o)),o!==void 0&&this.addFeaturesInternal(o),n!==void 0&&this.bindFeaturesCollection_(n)}addFeature(t){this.addFeatureInternal(t),this.changed()}addFeatureInternal(t){const e=be(t);if(!this.addToIndex_(e,t)){this.featuresCollection_&&this.featuresCollection_.remove(t);return}this.setupChangeEvents_(e,t);const n=t.getGeometry();if(n){const o=n.getExtent();this.featuresRtree_&&this.featuresRtree_.insert(o,t)}else this.nullGeometryFeatures_[e]=t;this.dispatchEvent(new Cs(dn.ADDFEATURE,t))}setupChangeEvents_(t,e){e instanceof Yi||(this.featureChangeKeys_[t]=[ge(e,jt.CHANGE,this.handleFeatureChange_,this),ge(e,Nr.PROPERTYCHANGE,this.handleFeatureChange_,this)])}addToIndex_(t,e){let n=!0;if(e.getId()!==void 0){const o=String(e.getId());if(!(o in this.idIndex_))this.idIndex_[o]=e;else if(e instanceof Yi){const l=this.idIndex_[o];l instanceof Yi?Array.isArray(l)?l.push(e):this.idIndex_[o]=[l,e]:n=!1}else n=!1}return n&&(pe(!(t in this.uidIndex_),"The passed `feature` was already added to the source"),this.uidIndex_[t]=e),n}addFeatures(t){this.addFeaturesInternal(t),this.changed()}addFeaturesInternal(t){const e=[],n=[],o=[];for(let l=0,u=t.length;l{e||(e=!0,this.addFeature(n.element),e=!1)}),t.addEventListener(Hi.REMOVE,n=>{e||(e=!0,this.removeFeature(n.element),e=!1)}),this.featuresCollection_=t}clear(t){if(t){for(const n in this.featureChangeKeys_)this.featureChangeKeys_[n].forEach(Fe);this.featuresCollection_||(this.featureChangeKeys_={},this.idIndex_={},this.uidIndex_={})}else if(this.featuresRtree_){const n=o=>{this.removeFeatureInternal(o)};this.featuresRtree_.forEach(n);for(const o in this.nullGeometryFeatures_)this.removeFeatureInternal(this.nullGeometryFeatures_[o])}this.featuresCollection_&&this.featuresCollection_.clear(),this.featuresRtree_&&this.featuresRtree_.clear(),this.nullGeometryFeatures_={};const e=new Cs(dn.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 n=[t[0],t[1],t[0],t[1]];return this.forEachFeatureInExtent(n,function(o){const l=o.getGeometry();if(l instanceof Yi||l.intersectsCoordinate(t))return e(o)})}forEachFeatureInExtent(t,e){if(this.featuresRtree_)return this.featuresRtree_.forEachInExtent(t,e);this.featuresCollection_&&this.featuresCollection_.forEach(e)}forEachFeatureIntersectingExtent(t,e){return this.forEachFeatureInExtent(t,function(n){const o=n.getGeometry();if(o instanceof Yi||o.intersectsExtent(t)){const l=e(n);if(l)return l}})}getFeaturesCollection(){return this.featuresCollection_}getFeatures(){let t;return this.featuresCollection_?t=this.featuresCollection_.getArray().slice(0):this.featuresRtree_&&(t=this.featuresRtree_.getAll(),er(this.nullGeometryFeatures_)||bn(t,Object.values(this.nullGeometryFeatures_))),t}getFeaturesAtCoordinate(t){const e=[];return this.forEachFeatureAtCoordinateDirect(t,function(n){e.push(n)}),e}getFeaturesInExtent(t,e){if(this.featuresRtree_){if(!(e&&e.canWrapX()&&this.getWrapX()))return this.featuresRtree_.getInExtent(t);const o=t0(t,e);return[].concat(...o.map(l=>this.featuresRtree_.getInExtent(l)))}return this.featuresCollection_?this.featuresCollection_.getArray().slice(0):[]}getClosestFeatureToCoordinate(t,e){const n=t[0],o=t[1];let l=null;const u=[NaN,NaN];let g=1/0;const x=[-1/0,-1/0,1/0,1/0];return e=e||go,this.featuresRtree_.forEachInExtent(x,function(E){if(e(E)){const w=E.getGeometry(),A=g;if(g=w instanceof Yi?0:w.closestPointXY(n,o,u,g),g{--this.loadingExtentsCount_,this.dispatchEvent(new Cs(dn.FEATURESLOADEND,void 0,w))},()=>{--this.loadingExtentsCount_,this.dispatchEvent(new Cs(dn.FEATURESLOADERROR))}),o.insert(x,{extent:x.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_;let n;e.forEachInExtent(t,function(o){if(mo(o.extent,t))return n=o,!0}),n&&e.remove(n)}removeFeatures(t){const e=[];for(let n=0,o=t.length;n0&&this.changed()}removeFeature(t){if(!t)return;this.removeFeatureInternal(t)&&this.changed()}removeFeatureInternal(t){const e=be(t);if(!(e in this.uidIndex_))return;e in this.nullGeometryFeatures_?delete this.nullGeometryFeatures_[e]:this.featuresRtree_&&this.featuresRtree_.remove(t),this.featureChangeKeys_[e]?.forEach(Fe),delete this.featureChangeKeys_[e];const o=t.getId();if(o!==void 0){const l=o.toString(),u=this.idIndex_[l];u===t?delete this.idIndex_[l]:Array.isArray(u)&&(u.splice(u.indexOf(t),1),u.length===1&&(this.idIndex_[l]=u[0]))}return delete this.uidIndex_[e],this.hasListener(dn.REMOVEFEATURE)&&this.dispatchEvent(new Cs(dn.REMOVEFEATURE,t)),t}removeFromIdIndex_(t){let e=!1;for(const n in this.idIndex_){const o=this.idIndex_[n];if(t instanceof Yi&&Array.isArray(o)&&o.includes(t))o.splice(o.indexOf(t),1);else if(this.idIndex_[n]===t){delete this.idIndex_[n],e=!0;break}}return e}setLoader(t){this.loader_=t}setUrl(t){pe(this.format_,"`format` must be set when `url` is set"),this.url_=t,this.setLoader(Mu(t,this.format_))}}const bu=g2,kt={IDLE:0,LOADING:1,LOADED:2,ERROR:3,EMPTY:4};class e1 extends Ga{constructor(t,e,n){super(),n=n||{},this.tileCoord=t,this.state=e,this.interimTile=null,this.key="",this.transition_=n.transition===void 0?250:n.transition,this.transitionStarts_={},this.interpolate=!!n.interpolate}changed(){this.dispatchEvent(jt.CHANGE)}release(){this.state===kt.ERROR&&this.setState(kt.EMPTY)}getKey(){return this.key+"/"+this.tileCoord}getInterimTile(){let t=this.interimTile;if(!t)return this;do{if(t.getState()==kt.LOADED)return this.transition_=0,t;t=t.interimTile}while(t);return this}refreshInterimChain(){let t=this.interimTile;if(!t)return;let e=this;do{if(t.getState()==kt.LOADED){t.interimTile=null;break}t.getState()==kt.LOADING?e=t:t.getState()==kt.IDLE?e.interimTile=t.interimTile:e=t,t=e.interimTile}while(t)}getTileCoord(){return this.tileCoord}getState(){return this.state}setState(t){if(this.state!==kt.ERROR&&this.state>t)throw new Error("Tile load sequence violation");this.state=t,this.changed()}load(){Xt()}getAlpha(t,e){if(!this.transition_)return 1;let n=this.transitionStarts_[t];if(!n)n=e,this.transitionStarts_[t]=n;else if(n===-1)return 1;const o=e-n+1e3/60;return o>=this.transition_?1:N0(o/this.transition_)}inTransition(t){return this.transition_?this.transitionStarts_[t]!==-1:!1}endTransition(t){this.transition_&&(this.transitionStarts_[t]=-1)}}class i1 extends e1{constructor(t,e,n,o,l,u){super(t,e,u),this.crossOrigin_=o,this.src_=n,this.key=n,this.image_=new Image,o!==null&&(this.image_.crossOrigin=o),this.unlisten_=null,this.tileLoadFunction_=l}getImage(){return this.image_}setImage(t){this.image_=t,this.state=kt.LOADED,this.unlistenImage_(),this.changed()}handleImageError_(){this.state=kt.ERROR,this.unlistenImage_(),this.image_=m2(),this.changed()}handleImageLoad_(){const t=this.image_;t.naturalWidth&&t.naturalHeight?this.state=kt.LOADED:this.state=kt.EMPTY,this.unlistenImage_(),this.changed()}load(){this.state==kt.ERROR&&(this.state=kt.IDLE,this.image_=new Image,this.crossOrigin_!==null&&(this.image_.crossOrigin=this.crossOrigin_)),this.state==kt.IDLE&&(this.state=kt.LOADING,this.changed(),this.tileLoadFunction_(this,this.src_),this.unlisten_=sd(this.image_,this.handleImageLoad_.bind(this),this.handleImageError_.bind(this)))}unlistenImage_(){this.unlisten_&&(this.unlisten_(),this.unlisten_=null)}}function m2(){const r=Si(1,1);return r.fillStyle="rgba(0,0,0,0)",r.fillRect(0,0,1,1),r.canvas}class x2{constructor(t,e,n){this.decay_=t,this.minVelocity_=e,this.delay_=n,this.points_=[],this.angle_=0,this.initialVelocity_=0}begin(){this.points_.length=0,this.angle_=0,this.initialVelocity_=0}update(t,e){this.points_.push(t,e,Date.now())}end(){if(this.points_.length<6)return!1;const t=Date.now()-this.delay_,e=this.points_.length-3;if(this.points_[e+2]0&&this.points_[n+2]>t;)n-=3;const o=this.points_[e+2]-this.points_[n+2];if(o<1e3/60)return!1;const l=this.points_[e]-this.points_[n],u=this.points_[e+1]-this.points_[n+1];return this.angle_=Math.atan2(u,l),this.initialVelocity_=Math.sqrt(l*l+u*u)/o,this.initialVelocity_>this.minVelocity_}getDistance(){return(this.minVelocity_-this.initialVelocity_)/this.decay_}getAngle(){return this.angle_}}class _2 extends Nh{constructor(t){super(),this.map_=t}dispatchRenderEvent(t,e){Xt()}calculateMatrices2D(t){const e=t.viewState,n=t.coordinateToPixelTransform,o=t.pixelToCoordinateTransform;as(n,t.size[0]/2,t.size[1]/2,1/e.resolution,-1/e.resolution,-e.rotation,-e.center[0],-e.center[1]),ju(o,n)}forEachFeatureAtCoordinate(t,e,n,o,l,u,g,x){let E;const w=e.viewState;function A(Z,$,ot,X){return l.call(u,$,Z?ot:null,X)}const S=w.projection,P=i0(t.slice(),S),L=[[0,0]];if(S.canWrapX()&&o){const Z=S.getExtent(),$=Ce(Z);L.push([-$,0],[$,0])}const F=e.layerStatesArray,V=F.length,z=[],U=[];for(let Z=0;Z=0;--$){const ot=F[$],X=ot.layer;if(X.hasRenderer()&&lc(ot,w)&&g.call(x,X)){const J=X.getRenderer(),H=X.getSource();if(J&&H){const _t=H.getWrapX()?P:t,xt=A.bind(null,ot.managed);U[0]=_t[0]+L[Z][0],U[1]=_t[1]+L[Z][1],E=J.forEachFeatureAtCoordinate(U,e,n,xt,z)}if(E)return E}}if(z.length===0)return;const Y=1/z.length;return z.forEach((Z,$)=>Z.distanceSq+=$*Y),z.sort((Z,$)=>Z.distanceSq-$.distanceSq),z.some(Z=>E=Z.callback(Z.feature,Z.layer,Z.geometry)),E}hasFeatureAtCoordinate(t,e,n,o,l,u){return this.forEachFeatureAtCoordinate(t,e,n,o,go,this,l,u)!==void 0}getMap(){return this.map_}renderFrame(t){Xt()}scheduleExpireIconCache(t){kn.canExpireCache()&&t.postRenderFunctions.push(p2)}}function p2(r,t){kn.expire()}class y2 extends _2{constructor(t){super(t),this.fontChangeListenerKey_=ge(ts,Nr.PROPERTYCHANGE,t.redrawText.bind(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=Ja+" ol-layers";const n=t.getViewport();n.insertBefore(this.element_,n.firstChild||null),this.children_=[],this.renderedVisible_=!0}dispatchRenderEvent(t,e){const n=this.getMap();if(n.hasListener(t)){const o=new Y0(t,void 0,e);n.dispatchEvent(o)}}disposeInternal(){Fe(this.fontChangeListenerKey_),this.element_.parentNode.removeChild(this.element_),super.disposeInternal()}renderFrame(t){if(!t){this.renderedVisible_&&(this.element_.style.display="none",this.renderedVisible_=!1);return}this.calculateMatrices2D(t),this.dispatchRenderEvent(gn.PRECOMPOSE,t);const e=t.layerStatesArray.sort(function(g,x){return g.zIndex-x.zIndex});e.some(g=>g.layer instanceof X0&&g.layer.getDeclutter())&&(t.declutter={});const o=t.viewState;this.children_.length=0;const l=[];let u=null;for(let g=0,x=e.length;g=0;--n){const o=e[n],l=o.layer;l.getDeclutter()&&l.renderDeclutter(t,o)}e.forEach(n=>n.layer.renderDeferred(t))}}}class Ms extends hs{constructor(t,e){super(t),this.layer=e}}const Xl={LAYERS:"layers"};class Vr extends O0{constructor(t){t=t||{};const e=Object.assign({},t);delete e.layers;let n=t.layers;super(e),this.on,this.once,this.un,this.layersListenerKeys_=[],this.listenerKeys_={},this.addChangeListener(Xl.LAYERS,this.handleLayersChanged_),n?Array.isArray(n)?n=new Bn(n.slice(),{unique:!0}):pe(typeof n.getArray=="function","Expected `layers` to be an array or a `Collection`"):n=new Bn(void 0,{unique:!0}),this.setLayers(n)}handleLayerChange_(){this.changed()}handleLayersChanged_(){this.layersListenerKeys_.forEach(Fe),this.layersListenerKeys_.length=0;const t=this.getLayers();this.layersListenerKeys_.push(ge(t,Hi.ADD,this.handleLayersAdd_,this),ge(t,Hi.REMOVE,this.handleLayersRemove_,this));for(const n in this.listenerKeys_)this.listenerKeys_[n].forEach(Fe);No(this.listenerKeys_);const e=t.getArray();for(let n=0,o=e.length;n{this.clickTimeoutId_=void 0;const n=new Is(ti.SINGLECLICK,this.map_,t);this.dispatchEvent(n)},250)}updateActivePointers_(t){const e=t,n=e.pointerId;if(e.type==ti.POINTERUP||e.type==ti.POINTERCANCEL){delete this.trackedTouches_[n];for(const o in this.trackedTouches_)if(this.trackedTouches_[o].target!==e.target){delete this.trackedTouches_[o];break}}else(e.type==ti.POINTERDOWN||e.type==ti.POINTERMOVE)&&(this.trackedTouches_[n]=e);this.activePointers_=Object.values(this.trackedTouches_)}handlePointerUp_(t){this.updateActivePointers_(t);const e=new Is(ti.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(Fe),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 Is(ti.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 n=this.map_.getOwnerDocument();this.dragListenerKeys_.push(ge(n,ti.POINTERMOVE,this.handlePointerMove_,this),ge(n,ti.POINTERUP,this.handlePointerUp_,this),ge(this.element_,ti.POINTERCANCEL,this.handlePointerUp_,this)),this.element_.getRootNode&&this.element_.getRootNode()!==n&&this.dragListenerKeys_.push(ge(this.element_.getRootNode(),ti.POINTERUP,this.handlePointerUp_,this))}}handlePointerMove_(t){if(this.isMoving_(t)){this.updateActivePointers_(t),this.dragging_=!0;const e=new Is(ti.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 Is(ti.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_&&(Fe(this.relayedListenerKey_),this.relayedListenerKey_=null),this.element_.removeEventListener(jt.TOUCHMOVE,this.boundHandleTouchMove_),this.pointerdownListenerKey_&&(Fe(this.pointerdownListenerKey_),this.pointerdownListenerKey_=null),this.dragListenerKeys_.forEach(Fe),this.dragListenerKeys_.length=0,this.element_=null,super.disposeInternal()}}const es={POSTRENDER:"postrender",MOVESTART:"movestart",MOVEEND:"moveend",LOADSTART:"loadstart",LOADEND:"loadend"},Li={LAYERGROUP:"layergroup",SIZE:"size",TARGET:"target",VIEW:"view"},Pa=1/0;class E2{constructor(t,e){this.priorityFunction_=t,this.keyFunction_=e,this.elements_=[],this.priorities_=[],this.queuedElements_={}}clear(){this.elements_.length=0,this.priorities_.length=0,No(this.queuedElements_)}dequeue(){const t=this.elements_,e=this.priorities_,n=t[0];t.length==1?(t.length=0,e.length=0):(t[0]=t.pop(),e[0]=e.pop(),this.siftUp_(0));const o=this.keyFunction_(n);return delete this.queuedElements_[o],n}enqueue(t){pe(!(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!=Pa?(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_,n=this.priorities_,o=e.length,l=e[t],u=n[t],g=t;for(;t>1;){const x=this.getLeftChildIndex_(t),E=this.getRightChildIndex_(t),w=Et;){const g=this.getParentIndex_(e);if(o[g]>u)n[e]=n[g],o[e]=o[g],e=g;else break}n[e]=l,o[e]=u}reprioritize(){const t=this.priorityFunction_,e=this.elements_,n=this.priorities_;let o=0;const l=e.length;let u,g,x;for(g=0;g0;)l=this.dequeue()[0],u=l.getKey(),o=l.getState(),o===kt.IDLE&&!(u in this.tilesLoadingKeys_)&&(this.tilesLoadingKeys_[u]=!0,++this.tilesLoading_,++n,l.load())}}function A2(r,t,e,n,o){if(!r||!(e in r.wantedTiles)||!r.wantedTiles[e][t.getKey()])return Pa;const l=r.viewState.center,u=n[0]-l[0],g=n[1]-l[1];return 65536*Math.log(o)+Math.sqrt(u*u+g*g)/o}class uc extends Rn{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(){Ia(this.element),super.disposeInternal()}getMap(){return this.map_}setMap(t){this.map_&&Ia(this.element);for(let e=0,n=this.listenerKeys.length;eo.getAttributions(t)))),n=!this.getMap().getAllLayers().some(o=>o.getSource()&&o.getSource().getAttributionsCollapsible()===!1);return this.overrideCollapsible_||this.setCollapsible(n),e}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(o=>q1(()=>o))),n=e.length>0;if(this.renderedVisible_!=n&&(this.element.style.display=n?"":"none",this.renderedVisible_=n),!Ls(e,this.renderedAttributions_)){M0(this.ulElement_);for(let o=0,l=e.length;o0&&n%(2*Math.PI)!==0?e.animate({rotation:0,duration:this.duration_,easing:Wr}):e.setRotation(0))}render(t){const e=t.frameState;if(!e)return;const n=e.viewState.rotation;if(n!=this.rotation_){const o="rotate("+n+"rad)";if(this.autoHide_){const l=this.element.classList.contains(aa);!l&&n===0?this.element.classList.add(aa):l&&n!==0&&this.element.classList.remove(aa)}this.label_.style.transform=o}this.rotation_=n}}const T2=b2;class S2 extends uc{constructor(t){t=t||{},super({element:document.createElement("div"),target:t.target});const e=t.className!==void 0?t.className:"ol-zoom",n=t.delta!==void 0?t.delta:1,o=t.zoomInClassName!==void 0?t.zoomInClassName:e+"-in",l=t.zoomOutClassName!==void 0?t.zoomOutClassName:e+"-out",u=t.zoomInLabel!==void 0?t.zoomInLabel:"+",g=t.zoomOutLabel!==void 0?t.zoomOutLabel:"–",x=t.zoomInTipLabel!==void 0?t.zoomInTipLabel:"Zoom in",E=t.zoomOutTipLabel!==void 0?t.zoomOutTipLabel:"Zoom out",w=document.createElement("button");w.className=o,w.setAttribute("type","button"),w.title=x,w.appendChild(typeof u=="string"?document.createTextNode(u):u),w.addEventListener(jt.CLICK,this.handleClick_.bind(this,n),!1);const A=document.createElement("button");A.className=l,A.setAttribute("type","button"),A.title=E,A.appendChild(typeof g=="string"?document.createTextNode(g):g),A.addEventListener(jt.CLICK,this.handleClick_.bind(this,-n),!1);const S=e+" "+Ja+" "+ic,P=this.element;P.className=S,P.appendChild(w),P.appendChild(A),this.duration_=t.duration!==void 0?t.duration:250}handleClick_(t,e){e.preventDefault(),this.zoomByDelta_(t)}zoomByDelta_(t){const n=this.getMap().getView();if(!n)return;const o=n.getZoom();if(o!==void 0){const l=n.getConstrainedZoom(o+t);this.duration_>0?(n.getAnimating()&&n.cancelAnimations(),n.animate({zoom:l,duration:this.duration_,easing:Wr})):n.setZoom(l)}}}const R2=S2;function v2(r){r=r||{};const t=new Bn;return(r.zoom!==void 0?r.zoom:!0)&&t.push(new R2(r.zoomOptions)),(r.rotate!==void 0?r.rotate:!0)&&t.push(new T2(r.rotateOptions)),(r.attribution!==void 0?r.attribution:!0)&&t.push(new M2(r.attributionOptions)),t}const Tu={ACTIVE:"active"};class Uo extends Rn{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(Tu.ACTIVE)}getMap(){return this.map_}handleEvent(t){return!0}setActive(t){this.set(Tu.ACTIVE,t)}setMap(t){this.map_=t}}function O2(r,t,e){const n=r.getCenterInternal();if(n){const o=[n[0]+t[0],n[1]+t[1]];r.animateInternal({duration:e!==void 0?e:250,easing:Sd,center:r.getConstrainedCenter(o)})}}function fc(r,t,e,n){const o=r.getZoom();if(o===void 0)return;const l=r.getConstrainedZoom(o+t),u=r.getResolutionForZoom(l);r.getAnimating()&&r.cancelAnimations(),r.animate({resolution:u,anchor:e,duration:n!==void 0?n:250,easing:Wr})}class N2 extends Uo{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==ti.DBLCLICK){const n=t.originalEvent,o=t.map,l=t.coordinate,u=n.shiftKey?-this.delta_:this.delta_,g=o.getView();fc(g,u,l,this.duration_),n.preventDefault(),e=!0}return!e}}const P2=N2;class zo extends Uo{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==ti.POINTERDRAG)this.handleDragEvent(t),t.originalEvent.preventDefault();else if(t.type==ti.POINTERUP){const n=this.handleUpEvent(t);this.handlingDownUpSequence=n&&this.targetPointers.length>0}}else if(t.type==ti.POINTERDOWN){const n=this.handleDownEvent(t);this.handlingDownUpSequence=n,e=this.stopDown(n)}else t.type==ti.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 dc(r){const t=r.length;let e=0,n=0;for(let o=0;o0&&this.condition_(t)){const n=t.map.getView();return this.lastCentroid=null,n.getAnimating()&&n.cancelAnimations(),this.kinetic_&&this.kinetic_.begin(),this.noKinetic_=this.targetPointers.length>1,!0}return!1}}const z2=U2;class W2 extends zo{constructor(t){t=t||{},super({stopDown:ka}),this.condition_=t.condition?t.condition:D2,this.lastAngle_=void 0,this.duration_=t.duration!==void 0?t.duration:250}handleDragEvent(t){if(!Vl(t))return;const e=t.map,n=e.getView();if(n.getConstraints().rotation===ac)return;const o=e.getSize(),l=t.pixel,u=Math.atan2(o[1]/2-l[1],l[0]-o[0]/2);if(this.lastAngle_!==void 0){const g=u-this.lastAngle_;n.adjustRotationInternal(-g)}this.lastAngle_=u}handleUpEvent(t){return Vl(t)?(t.map.getView().endInteraction(this.duration_),!1):!0}handleDownEvent(t){return Vl(t)&&s1(t)&&this.condition_(t)?(t.map.getView().beginInteraction(),this.lastAngle_=void 0,!0):!1}}class X2 extends Nh{constructor(t){super(),this.geometry_=null,this.element_=document.createElement("div"),this.element_.style.position="absolute",this.element_.style.pointerEvents="auto",this.element_.className="ol-box "+t,this.map_=null,this.startPixel_=null,this.endPixel_=null}disposeInternal(){this.setMap(null)}render_(){const t=this.startPixel_,e=this.endPixel_,n="px",o=this.element_.style;o.left=Math.min(t[0],e[0])+n,o.top=Math.min(t[1],e[1])+n,o.width=Math.abs(e[0]-t[0])+n,o.height=Math.abs(e[1]-t[1])+n}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_,o=[t,[t[0],e[1]],e,[e[0],t[1]]].map(this.map_.getCoordinateFromPixelInternal,this.map_);o[4]=o[0].slice(),this.geometry_?this.geometry_.setCoordinates([o]):this.geometry_=new Ps([o])}getGeometry(){return this.geometry_}}const no={BOXSTART:"boxstart",BOXDRAG:"boxdrag",BOXEND:"boxend",BOXCANCEL:"boxcancel"};class fa extends hs{constructor(t,e,n){super(t),this.coordinate=e,this.mapBrowserEvent=n}}class V2 extends zo{constructor(t){super(),this.on,this.once,this.un,t=t||{},this.box_=new X2(t.className||"ol-dragbox"),this.minArea_=t.minArea!==void 0?t.minArea:64,t.onBoxEnd&&(this.onBoxEnd=t.onBoxEnd),this.startPixel_=null,this.condition_=t.condition?t.condition:s1,this.boxEndCondition_=t.boxEndCondition?t.boxEndCondition:this.defaultBoxEndCondition}defaultBoxEndCondition(t,e,n){const o=n[0]-e[0],l=n[1]-e[1];return o*o+l*l>=this.minArea_}getGeometry(){return this.box_.getGeometry()}handleDragEvent(t){this.startPixel_&&(this.box_.setPixels(this.startPixel_,t.pixel),this.dispatchEvent(new fa(no.BOXDRAG,t.coordinate,t)))}handleUpEvent(t){if(!this.startPixel_)return!1;this.box_.setMap(null);const e=this.boxEndCondition_(t,this.startPixel_,t.pixel);return e&&this.onBoxEnd(t),this.dispatchEvent(new fa(e?no.BOXEND:no.BOXCANCEL,t.coordinate,t)),!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 fa(no.BOXSTART,t.coordinate,t)),!0):!1}onBoxEnd(t){}setActive(t){t||(this.box_.setMap(null),this.startPixel_&&(this.dispatchEvent(new fa(no.BOXCANCEL,this.startPixel_,null)),this.startPixel_=null)),super.setActive(t)}}class Y2 extends V2{constructor(t){t=t||{};const e=t.condition?t.condition:k2;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 n=this.getMap().getView();let o=this.getGeometry();if(this.out_){const l=n.rotatedExtentForGeometry(o),u=n.getResolutionForExtentInternal(l),g=n.getResolution()/u;o=o.clone(),o.scale(g*g)}n.fitInternal(o,{duration:this.duration_,easing:Wr})}}const H2=Y2,Vs={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",DOWN:"ArrowDown"};class j2 extends Uo{constructor(t){super(),t=t||{},this.defaultCondition_=function(e){return r1(e)&&o1(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==jt.KEYDOWN){const n=t.originalEvent,o=n.key;if(this.condition_(t)&&(o==Vs.DOWN||o==Vs.LEFT||o==Vs.RIGHT||o==Vs.UP)){const u=t.map.getView(),g=u.getResolution()*this.pixelDelta_;let x=0,E=0;o==Vs.DOWN?E=-g:o==Vs.LEFT?x=-g:o==Vs.RIGHT?x=g:E=g;const w=[x,E];Gh(w,u.getRotation()),O2(u,w,this.duration_),n.preventDefault(),e=!0}}return!e}}class Z2 extends Uo{constructor(t){super(),t=t||{},this.condition_=t.condition?t.condition:function(e){return!B2(e)&&o1(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==jt.KEYDOWN||t.type==jt.KEYPRESS){const n=t.originalEvent,o=n.key;if(this.condition_(t)&&(o==="+"||o==="-")){const l=t.map,u=o==="+"?this.delta_:-this.delta_,g=l.getView();fc(g,u,void 0,this.duration_),n.preventDefault(),e=!0}}return!e}}const K2=Z2;class q2 extends Uo{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:F2;this.condition_=t.onFocusOnly?wh(n1,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_)}handleEvent(t){if(!this.condition_(t)||t.type!==jt.WHEEL)return!0;const n=t.map,o=t.originalEvent;o.preventDefault(),this.useAnchor_&&(this.lastAnchor_=t.coordinate);let l;if(t.type==jt.WHEEL&&(l=o.deltaY,Qf&&o.deltaMode===WheelEvent.DOM_DELTA_PIXEL&&(l/=E0),o.deltaMode===WheelEvent.DOM_DELTA_LINE&&(l*=40)),l===0)return!1;this.lastDelta_=l;const u=Date.now();this.startTime_===void 0&&(this.startTime_=u),(!this.mode_||u-this.startTime_>this.trackpadEventGap_)&&(this.mode_=Math.abs(l)<4?"trackpad":"wheel");const g=n.getView();if(this.mode_==="trackpad"&&!(g.getConstrainResolution()||this.constrainResolution_))return this.trackpadTimeoutId_?clearTimeout(this.trackpadTimeoutId_):(g.getAnimating()&&g.cancelAnimations(),g.beginInteraction()),this.trackpadTimeoutId_=setTimeout(this.endInteraction_.bind(this),this.timeout_),g.adjustZoom(-l/this.deltaPerZoom_,this.lastAnchor_),this.startTime_=u,!1;this.totalDelta_+=l;const x=Math.max(this.timeout_-(u-this.startTime_),0);return clearTimeout(this.timeoutId_),this.timeoutId_=setTimeout(this.handleWheelZoom_.bind(this,n),x),!1}handleWheelZoom_(t){const e=t.getView();e.getAnimating()&&e.cancelAnimations();let n=-ei(this.totalDelta_,-this.maxDelta_*this.deltaPerZoom_,this.maxDelta_*this.deltaPerZoom_)/this.deltaPerZoom_;(e.getConstrainResolution()||this.constrainResolution_)&&(n=n?n>0?1:-1:0),fc(e,n,this.lastAnchor_,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)}}const J2=q2;class Q2 extends zo{constructor(t){t=t||{};const e=t;e.stopDown||(e.stopDown=ka),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 n=this.targetPointers[0],o=this.targetPointers[1],l=Math.atan2(o.clientY-n.clientY,o.clientX-n.clientX);if(this.lastAngle_!==void 0){const x=l-this.lastAngle_;this.rotationDelta_+=x,!this.rotating_&&Math.abs(this.rotationDelta_)>this.threshold_&&(this.rotating_=!0),e=x}this.lastAngle_=l;const u=t.map,g=u.getView();g.getConstraints().rotation!==ac&&(this.anchor_=u.getCoordinateFromPixelInternal(u.getEventPixel(dc(this.targetPointers))),this.rotating_&&(u.render(),g.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 $2 extends zo{constructor(t){t=t||{};const e=t;e.stopDown||(e.stopDown=ka),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 n=this.targetPointers[0],o=this.targetPointers[1],l=n.clientX-o.clientX,u=n.clientY-o.clientY,g=Math.sqrt(l*l+u*u);this.lastDistance_!==void 0&&(e=this.lastDistance_/g),this.lastDistance_=g;const x=t.map,E=x.getView();e!=1&&(this.lastScaleDelta_=e),this.anchor_=x.getCoordinateFromPixelInternal(x.getEventPixel(dc(this.targetPointers))),x.render(),E.adjustResolutionInternal(e,this.anchor_)}handleUpEvent(t){if(this.targetPointers.length<2){const n=t.map.getView(),o=this.lastScaleDelta_>1?1:-1;return n.endInteraction(this.duration_,o),!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}}const tm=$2;function em(r){r=r||{};const t=new Bn,e=new x2(-.005,.05,100);return(r.altShiftDragRotate!==void 0?r.altShiftDragRotate:!0)&&t.push(new W2),(r.doubleClickZoom!==void 0?r.doubleClickZoom:!0)&&t.push(new P2({delta:r.zoomDelta,duration:r.zoomDuration})),(r.dragPan!==void 0?r.dragPan:!0)&&t.push(new z2({onFocusOnly:r.onFocusOnly,kinetic:e})),(r.pinchRotate!==void 0?r.pinchRotate:!0)&&t.push(new Q2),(r.pinchZoom!==void 0?r.pinchZoom:!0)&&t.push(new tm({duration:r.zoomDuration})),(r.keyboard!==void 0?r.keyboard:!0)&&(t.push(new j2),t.push(new K2({delta:r.zoomDelta,duration:r.zoomDuration}))),(r.mouseWheelZoom!==void 0?r.mouseWheelZoom:!0)&&t.push(new J2({onFocusOnly:r.onFocusOnly,duration:r.zoomDuration})),(r.shiftDragZoom!==void 0?r.shiftDragZoom:!0)&&t.push(new H2({duration:r.zoomDuration})),t}function a1(r){if(r instanceof el){r.setMapInternal(null);return}r instanceof Vr&&r.getLayers().forEach(a1)}function l1(r,t){if(r instanceof el){r.setMapInternal(t);return}if(r instanceof Vr){const e=r.getLayers().getArray();for(let n=0,o=e.length;nthis.updateSize()),this.controls=e.controls||v2(),this.interactions=e.interactions||em({onFocusOnly:!0}),this.overlays_=e.overlays,this.overlayIdIndex_={},this.renderer_=null,this.postRenderFunctions_=[],this.tileQueue_=new C2(this.getTilePriority.bind(this),this.handleTileChange_.bind(this)),this.addChangeListener(Li.LAYERGROUP,this.handleLayerGroupChanged_),this.addChangeListener(Li.VIEW,this.handleViewChanged_),this.addChangeListener(Li.SIZE,this.handleSizeChanged_),this.addChangeListener(Li.TARGET,this.handleTargetChanged_),this.setProperties(e.values);const n=this;t.view&&!(t.view instanceof Ln)&&t.view.then(function(o){n.setView(new Ln(o))}),this.controls.addEventListener(Hi.ADD,o=>{o.element.setMap(this)}),this.controls.addEventListener(Hi.REMOVE,o=>{o.element.setMap(null)}),this.interactions.addEventListener(Hi.ADD,o=>{o.element.setMap(this)}),this.interactions.addEventListener(Hi.REMOVE,o=>{o.element.setMap(null)}),this.overlays_.addEventListener(Hi.ADD,o=>{this.addOverlayInternal_(o.element)}),this.overlays_.addEventListener(Hi.REMOVE,o=>{const l=o.element.getId();l!==void 0&&delete this.overlayIdIndex_[l.toString()],o.element.setMap(null)}),this.controls.forEach(o=>{o.setMap(this)}),this.interactions.forEach(o=>{o.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){l1(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,n){if(!this.frameState_||!this.renderer_)return;const o=this.getCoordinateFromPixelInternal(t);n=n!==void 0?n:{};const l=n.hitTolerance!==void 0?n.hitTolerance:0,u=n.layerFilter!==void 0?n.layerFilter:go,g=n.checkWrapped!==!1;return this.renderer_.forEachFeatureAtCoordinate(o,this.frameState_,l,g,e,null,u,null)}getFeaturesAtPixel(t,e){const n=[];return this.forEachFeatureAtPixel(t,function(o){n.push(o)},e),n}getAllLayers(){const t=[];function e(n){n.forEach(function(o){o instanceof Vr?e(o.getLayers()):t.push(o)})}return e(this.getLayers()),t}hasFeatureAtPixel(t,e){if(!this.frameState_||!this.renderer_)return!1;const n=this.getCoordinateFromPixelInternal(t);e=e!==void 0?e:{};const o=e.layerFilter!==void 0?e.layerFilter:go,l=e.hitTolerance!==void 0?e.hitTolerance:0,u=e.checkWrapped!==!1;return this.renderer_.hasFeatureAtCoordinate(n,this.frameState_,l,u,o,null)}getEventCoordinate(t){return this.getCoordinateFromPixel(this.getEventPixel(t))}getEventCoordinateInternal(t){return this.getCoordinateFromPixelInternal(this.getEventPixel(t))}getEventPixel(t){const n=this.viewport_.getBoundingClientRect(),o=this.getSize(),l=n.width/o[0],u=n.height/o[1],g="changedTouches"in t?t.changedTouches[0]:t;return[(g.clientX-n.left)/l,(g.clientY-n.top)/u]}getTarget(){return this.get(Li.TARGET)}getTargetElement(){return this.targetElement_}getCoordinateFromPixel(t){return uh(this.getCoordinateFromPixelInternal(t),this.getView().getProjection())}getCoordinateFromPixelInternal(t){const e=this.frameState_;return e?bi(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(Li.LAYERGROUP)}setLayers(t){const e=this.getLayerGroup();if(t instanceof Bn){e.setLayers(t);return}const n=e.getLayers();n.clear(),n.extend(t)}getLayers(){return this.getLayerGroup().getLayers()}getLoadingOrNotReady(){const t=this.getLayerGroup().getLayerStatesArray();for(let e=0,n=t.length;e=0;l--){const u=o[l];if(u.getMap()!==this||!u.getActive()||!this.getTargetElement())continue;if(!u.handleEvent(t)||t.propagationStopped)break}}}handlePostRender(){const t=this.frameState_,e=this.tileQueue_;if(!e.isEmpty()){let o=this.maxTilesLoading_,l=o;if(t){const u=t.viewHints;if(u[Fi.ANIMATING]||u[Fi.INTERACTING]){const g=Date.now()-t.time>8;o=g?0:8,l=g?0:2}}e.getTilesLoading(){this.postRenderTimeoutHandle_=void 0,this.handlePostRender()},0))}setLayerGroup(t){const e=this.getLayerGroup();e&&this.handleLayerRemove_(new Ms("removelayer",e)),this.set(Li.LAYERGROUP,t)}setSize(t){this.set(Li.SIZE,t)}setTarget(t){this.set(Li.TARGET,t)}setView(t){if(!t||t instanceof Ln){this.set(Li.VIEW,t);return}this.set(Li.VIEW,new Ln);const e=this;t.then(function(n){e.setView(new Ln(n))})}updateSize(){const t=this.getTargetElement();let e;if(t){const o=getComputedStyle(t),l=t.offsetWidth-parseFloat(o.borderLeftWidth)-parseFloat(o.paddingLeft)-parseFloat(o.paddingRight)-parseFloat(o.borderRightWidth),u=t.offsetHeight-parseFloat(o.borderTopWidth)-parseFloat(o.paddingTop)-parseFloat(o.paddingBottom)-parseFloat(o.borderBottomWidth);!isNaN(l)&&!isNaN(u)&&(e=[l,u],!Qc(e)&&(t.offsetWidth||t.offsetHeight||t.getClientRects().length)&&s0("No map visible because the map container's width or height are 0."))}const n=this.getSize();e&&(!n||!Ls(e,n))&&(this.setSize(e),this.updateViewportSize_(e))}updateViewportSize_(t){const e=this.getView();e&&e.setViewportSize(t)}};function nm(r){let t=null;r.keyboardEventTarget!==void 0&&(t=typeof r.keyboardEventTarget=="string"?document.getElementById(r.keyboardEventTarget):r.keyboardEventTarget);const e={},n=r.layers&&typeof r.layers.getLayers=="function"?r.layers:new Vr({layers:r.layers});e[Li.LAYERGROUP]=n,e[Li.TARGET]=r.target,e[Li.VIEW]=r.view instanceof Ln?r.view:new Ln;let o;r.controls!==void 0&&(Array.isArray(r.controls)?o=new Bn(r.controls.slice()):(pe(typeof r.controls.getArray=="function","Expected `controls` to be an array or an `ol/Collection.js`"),o=r.controls));let l;r.interactions!==void 0&&(Array.isArray(r.interactions)?l=new Bn(r.interactions.slice()):(pe(typeof r.interactions.getArray=="function","Expected `interactions` to be an array or an `ol/Collection.js`"),l=r.interactions));let u;return r.overlays!==void 0?Array.isArray(r.overlays)?u=new Bn(r.overlays.slice()):(pe(typeof r.overlays.getArray=="function","Expected `overlays` to be an array or an `ol/Collection.js`"),u=r.overlays):u=new Bn,{controls:o,interactions:l,keyboardEventTarget:t,overlays:u,values:e}}const sm=im,Pi={ELEMENT:"element",MAP:"map",OFFSET:"offset",POSITION:"position",POSITIONING:"positioning"};class rm extends Rn{constructor(t){super(),this.on,this.once,this.un,this.options=t,this.id=t.id,this.insertFirst=t.insertFirst!==void 0?t.insertFirst:!0,this.stopEvent=t.stopEvent!==void 0?t.stopEvent:!0,this.element=document.createElement("div"),this.element.className=t.className!==void 0?t.className:"ol-overlay-container "+fd,this.element.style.position="absolute",this.element.style.pointerEvents="auto",this.autoPan=t.autoPan===!0?{}:t.autoPan||void 0,this.rendered={transform_:"",visible:!0},this.mapPostrenderListenerKey=null,this.addChangeListener(Pi.ELEMENT,this.handleElementChanged),this.addChangeListener(Pi.MAP,this.handleMapChanged),this.addChangeListener(Pi.OFFSET,this.handleOffsetChanged),this.addChangeListener(Pi.POSITION,this.handlePositionChanged),this.addChangeListener(Pi.POSITIONING,this.handlePositioningChanged),t.element!==void 0&&this.setElement(t.element),this.setOffset(t.offset!==void 0?t.offset:[0,0]),this.setPositioning(t.positioning||"top-left"),t.position!==void 0&&this.setPosition(t.position)}getElement(){return this.get(Pi.ELEMENT)}getId(){return this.id}getMap(){return this.get(Pi.MAP)||null}getOffset(){return this.get(Pi.OFFSET)}getPosition(){return this.get(Pi.POSITION)}getPositioning(){return this.get(Pi.POSITIONING)}handleElementChanged(){M0(this.element);const t=this.getElement();t&&this.element.appendChild(t)}handleMapChanged(){this.mapPostrenderListenerKey&&(Ia(this.element),Fe(this.mapPostrenderListenerKey),this.mapPostrenderListenerKey=null);const t=this.getMap();if(t){this.mapPostrenderListenerKey=ge(t,es.POSTRENDER,this.render,this),this.updatePixelPosition();const e=this.stopEvent?t.getOverlayContainerStopEvent():t.getOverlayContainer();this.insertFirst?e.insertBefore(this.element,e.childNodes[0]||null):e.appendChild(this.element),this.performAutoPan()}}render(){this.updatePixelPosition()}handleOffsetChanged(){this.updatePixelPosition()}handlePositionChanged(){this.updatePixelPosition(),this.performAutoPan()}handlePositioningChanged(){this.updatePixelPosition()}setElement(t){this.set(Pi.ELEMENT,t)}setMap(t){this.set(Pi.MAP,t)}setOffset(t){this.set(Pi.OFFSET,t)}setPosition(t){this.set(Pi.POSITION,t)}performAutoPan(){this.autoPan&&this.panIntoView(this.autoPan)}panIntoView(t){const e=this.getMap();if(!e||!e.getTargetElement()||!this.get(Pi.POSITION))return;const n=this.getRect(e.getTargetElement(),e.getSize()),o=this.getElement(),l=this.getRect(o,[ed(o),id(o)]);t=t||{};const u=t.margin===void 0?20:t.margin;if(!Zs(n,l)){const g=l[0]-n[0],x=n[2]-l[2],E=l[1]-n[1],w=n[3]-l[3],A=[0,0];if(g<0?A[0]=g-u:x<0&&(A[0]=Math.abs(x)+u),E<0?A[1]=E-u:w<0&&(A[1]=Math.abs(w)+u),A[0]!==0||A[1]!==0){const S=e.getView().getCenterInternal(),P=e.getPixelFromCoordinateInternal(S);if(!P)return;const L=[P[0]+A[0],P[1]+A[1]],F=t.animation||{};e.getView().animateInternal({center:e.getCoordinateFromPixelInternal(L),duration:F.duration,easing:F.easing})}}}getRect(t,e){const n=t.getBoundingClientRect(),o=n.left+window.pageXOffset,l=n.top+window.pageYOffset;return[o,l,o+e[0],l+e[1]]}setPositioning(t){this.set(Pi.POSITIONING,t)}setVisible(t){this.rendered.visible!==t&&(this.element.style.display=t?"":"none",this.rendered.visible=t)}updatePixelPosition(){const t=this.getMap(),e=this.getPosition();if(!t||!t.isRendered()||!e){this.setVisible(!1);return}const n=t.getPixelFromCoordinate(e),o=t.getSize();this.updateRenderedPosition(n,o)}updateRenderedPosition(t,e){const n=this.element.style,o=this.getOffset(),l=this.getPositioning();this.setVisible(!0);const u=Math.round(t[0]+o[0])+"px",g=Math.round(t[1]+o[1])+"px";let x="0%",E="0%";l=="bottom-right"||l=="center-right"||l=="top-right"?x="-100%":(l=="bottom-center"||l=="center-center"||l=="top-center")&&(x="-50%"),l=="bottom-left"||l=="bottom-center"||l=="bottom-right"?E="-100%":(l=="center-left"||l=="center-center"||l=="center-right")&&(E="-50%");const w=`translate(${x}, ${E}) translate(${u}, ${g})`;this.rendered.transform_!=w&&(this.rendered.transform_=w,n.transform=w)}getOptions(){return this.options}}class om{constructor(t){this.highWaterMark=t!==void 0?t:2048,this.count_=0,this.entries_={},this.oldest_=null,this.newest_=null}canExpireCache(){return this.highWaterMark>0&&this.getCount()>this.highWaterMark}expireCache(t){for(;this.canExpireCache();)this.pop()}clear(){this.count_=0,this.entries_={},this.oldest_=null,this.newest_=null}containsKey(t){return this.entries_.hasOwnProperty(t)}forEach(t){let e=this.oldest_;for(;e;)t(e.value_,e.key_,this),e=e.newer}get(t,e){const n=this.entries_[t];return pe(n!==void 0,"Tried to get a value for a key that does not exist in the cache"),n===this.newest_||(n===this.oldest_?(this.oldest_=this.oldest_.newer,this.oldest_.older=null):(n.newer.older=n.older,n.older.newer=n.newer),n.newer=null,n.older=this.newest_,this.newest_.newer=n,this.newest_=n),n.value_}remove(t){const e=this.entries_[t];return pe(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,n;for(n=this.newest_;n;n=n.older)t[e++]=n.key_;return t}getValues(){const t=new Array(this.count_);let e=0,n;for(n=this.newest_;n;n=n.older)t[e++]=n.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){pe(!(t in this.entries_),"Tried to set a value for a key that is used already");const n={key_:t,newer:null,older:this.newest_,value_:e};this.newest_?this.newest_.newer=n:this.oldest_=n,this.newest_=n,this.entries_[t]=n,++this.count_}setSize(t){this.highWaterMark=t}}function Su(r,t,e,n){return n!==void 0?(n[0]=r,n[1]=t,n[2]=e,n):[r,t,e]}function ol(r,t,e){return r+"/"+t+"/"+e}function h1(r){return ol(r[0],r[1],r[2])}function am(r){return r.split("/").map(Number)}function lm(r){return(r[1]<e||e>t.getMaxZoom())return!1;const l=t.getFullTileRange(e);return l?l.containsXY(n,o):!0}class c1 extends om{clear(){for(;this.getCount()>0;)this.pop().release();super.clear()}expireCache(t){for(;this.canExpireCache()&&!(this.peekLast().getKey()in t);)this.pop().release()}pruneExceptNewestZ(){if(this.getCount()===0)return;const t=this.peekFirstKey(),n=am(t)[0];this.forEach(o=>{o.tileCoord[0]!==n&&(this.remove(h1(o.tileCoord)),o.release())})}}class gc{constructor(t,e,n,o){this.minX=t,this.maxX=e,this.minY=n,this.maxY=o}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.minXthis.maxX&&(this.maxX=t.maxX),t.minYthis.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 Er(r,t,e,n,o){return o!==void 0?(o.minX=r,o.maxX=t,o.minY=e,o.maxY=n,o):new gc(r,t,e,n)}const da={PRELOAD:"preload",USE_INTERIM_TILES_ON_ERROR:"useInterimTilesOnError"};class cm extends el{constructor(t){t=t||{};const e=Object.assign({},t);delete e.preload,delete e.useInterimTilesOnError,super(e),this.on,this.once,this.un,this.setPreload(t.preload!==void 0?t.preload:0),this.setUseInterimTilesOnError(t.useInterimTilesOnError!==void 0?t.useInterimTilesOnError:!0)}getPreload(){return this.get(da.PRELOAD)}setPreload(t){this.set(da.PRELOAD,t)}getUseInterimTilesOnError(){return this.get(da.USE_INTERIM_TILES_ON_ERROR)}setUseInterimTilesOnError(t){this.set(da.USE_INTERIM_TILES_ON_ERROR,t)}getData(t){return super.getData(t)}}const um=.5,fm=10,Ru=.25;class dm{constructor(t,e,n,o,l,u){this.sourceProj_=t,this.targetProj_=e;let g={};const x=_o(this.targetProj_,this.sourceProj_);this.transformInv_=function(U){const Y=U[0]+"/"+U[1];return g[Y]||(g[Y]=x(U)),g[Y]},this.maxSourceExtent_=o,this.errorThresholdSquared_=l*l,this.triangles_=[],this.wrapsXInSource_=!1,this.canWrapXInSource_=this.sourceProj_.canWrapX()&&!!o&&!!this.sourceProj_.getExtent()&&Ce(o)>=Ce(this.sourceProj_.getExtent()),this.sourceWorldWidth_=this.sourceProj_.getExtent()?Ce(this.sourceProj_.getExtent()):null,this.targetWorldWidth_=this.targetProj_.getExtent()?Ce(this.targetProj_.getExtent()):null;const E=or(n),w=Wa(n),A=za(n),S=Ua(n),P=this.transformInv_(E),L=this.transformInv_(w),F=this.transformInv_(A),V=this.transformInv_(S),z=fm+(u?Math.max(0,Math.ceil(Math.log2(rh(n)/(u*u*256*256)))):0);if(this.addQuad_(E,w,A,S,P,L,F,V,z),this.wrapsXInSource_){let U=1/0;this.triangles_.forEach(function(Y,Z,$){U=Math.min(U,Y.source[0][0],Y.source[1][0],Y.source[2][0])}),this.triangles_.forEach(Y=>{if(Math.max(Y.source[0][0],Y.source[1][0],Y.source[2][0])-U>this.sourceWorldWidth_/2){const Z=[[Y.source[0][0],Y.source[0][1]],[Y.source[1][0],Y.source[1][1]],[Y.source[2][0],Y.source[2][1]]];Z[0][0]-U>this.sourceWorldWidth_/2&&(Z[0][0]-=this.sourceWorldWidth_),Z[1][0]-U>this.sourceWorldWidth_/2&&(Z[1][0]-=this.sourceWorldWidth_),Z[2][0]-U>this.sourceWorldWidth_/2&&(Z[2][0]-=this.sourceWorldWidth_);const $=Math.min(Z[0][0],Z[1][0],Z[2][0]);Math.max(Z[0][0],Z[1][0],Z[2][0])-$.5&&A<1;let L=!1;if(E>0){if(this.targetProj_.isGlobal()&&this.targetWorldWidth_){const V=Fc([t,e,n,o]);L=Ce(V)/this.targetWorldWidth_>Ru||L}!P&&this.sourceProj_.isGlobal()&&A&&(L=A>Ru||L)}if(!L&&this.maxSourceExtent_&&isFinite(w[0])&&isFinite(w[1])&&isFinite(w[2])&&isFinite(w[3])&&!Zi(w,this.maxSourceExtent_))return;let F=0;if(!L&&(!isFinite(l[0])||!isFinite(l[1])||!isFinite(u[0])||!isFinite(u[1])||!isFinite(g[0])||!isFinite(g[1])||!isFinite(x[0])||!isFinite(x[1]))){if(E>0)L=!0;else if(F=(!isFinite(l[0])||!isFinite(l[1])?8:0)+(!isFinite(u[0])||!isFinite(u[1])?4:0)+(!isFinite(g[0])||!isFinite(g[1])?2:0)+(!isFinite(x[0])||!isFinite(x[1])?1:0),F!=1&&F!=2&&F!=4&&F!=8)return}if(E>0){if(!L){const V=[(t[0]+n[0])/2,(t[1]+n[1])/2],z=this.transformInv_(V);let U;P?U=(vr(l[0],S)+vr(g[0],S))/2-vr(z[0],S):U=(l[0]+g[0])/2-z[0];const Y=(l[1]+g[1])/2-z[1];L=U*U+Y*Y>this.errorThresholdSquared_}if(L){if(Math.abs(t[0]-n[0])<=Math.abs(t[1]-n[1])){const V=[(e[0]+n[0])/2,(e[1]+n[1])/2],z=this.transformInv_(V),U=[(o[0]+t[0])/2,(o[1]+t[1])/2],Y=this.transformInv_(U);this.addQuad_(t,e,V,U,l,u,z,Y,E-1),this.addQuad_(U,V,n,o,Y,z,g,x,E-1)}else{const V=[(t[0]+e[0])/2,(t[1]+e[1])/2],z=this.transformInv_(V),U=[(n[0]+o[0])/2,(n[1]+o[1])/2],Y=this.transformInv_(U);this.addQuad_(t,V,U,o,l,z,Y,x,E-1),this.addQuad_(V,e,n,U,z,u,g,Y,E-1)}return}}if(P){if(!this.canWrapXInSource_)return;this.wrapsXInSource_=!0}F&11||this.addTriangle_(t,n,o,l,g,x),F&14||this.addTriangle_(t,n,e,l,g,u),F&&(F&13||this.addTriangle_(e,o,t,u,x,l),F&7||this.addTriangle_(e,o,n,u,x,g))}calculateSourceExtent(){const t=mn();return this.triangles_.forEach(function(e,n,o){const l=e.source;ho(t,l[0]),ho(t,l[1]),ho(t,l[2])}),t}getTriangles(){return this.triangles_}}let Yl;const Or=[];function vu(r,t,e,n,o){r.beginPath(),r.moveTo(0,0),r.lineTo(t,e),r.lineTo(n,o),r.closePath(),r.save(),r.clip(),r.fillRect(0,0,Math.max(t,n)+1,Math.max(e,o)),r.restore()}function Hl(r,t){return Math.abs(r[t*4]-210)>2||Math.abs(r[t*4+3]-.75*255)>2}function gm(){if(Yl===void 0){const r=Si(6,6,Or);r.globalCompositeOperation="lighter",r.fillStyle="rgba(210, 0, 0, 0.75)",vu(r,4,5,4,0),vu(r,4,5,0,5);const t=r.getImageData(0,0,3,3).data;Yl=Hl(t,0)||Hl(t,4)||Hl(t,8),Za(r),Or.push(r.canvas)}return Yl}function Ou(r,t,e,n){const o=bf(e,t,r);let l=zc(t,n,e);const u=t.getMetersPerUnit();u!==void 0&&(l*=u);const g=r.getMetersPerUnit();g!==void 0&&(l/=g);const x=r.getExtent();if(!x||Dr(x,o)){const E=zc(r,l,o)/l;isFinite(E)&&E>0&&(l/=E)}return l}function mm(r,t,e,n){const o=Ns(e);let l=Ou(r,t,o,n);return(!isFinite(l)||l<=0)&&Qu(e,function(u){return l=Ou(r,t,u,n),isFinite(l)&&l>0}),l}function xm(r,t,e,n,o,l,u,g,x,E,w,A,S,P){const L=Si(Math.round(e*r),Math.round(e*t),Or);if(A||(L.imageSmoothingEnabled=!1),x.length===0)return L.canvas;L.scale(e,e);function F($){return Math.round($*e)/e}L.globalCompositeOperation="lighter";const V=mn();x.forEach(function($,ot,X){qu(V,$.extent)});let z;const U=e/n,Y=(A?1:1+Math.pow(2,-24))/U;if(!S||x.length!==1||E!==0){if(z=Si(Math.round(Ce(V)*U),Math.round(Bi(V)*U),Or),A||(z.imageSmoothingEnabled=!1),o&&P){const $=(o[0]-V[0])*U,ot=-(o[3]-V[3])*U,X=Ce(o)*U,J=Bi(o)*U;z.rect($,ot,X,J),z.clip()}x.forEach(function($,ot,X){if($.image.width>0&&$.image.height>0){if($.clipExtent){z.save();const at=($.clipExtent[0]-V[0])*U,ut=-($.clipExtent[3]-V[3])*U,pt=Ce($.clipExtent)*U,q=Bi($.clipExtent)*U;z.rect(A?at:Math.round(at),A?ut:Math.round(ut),A?pt:Math.round(at+pt)-Math.round(at),A?q:Math.round(ut+q)-Math.round(ut)),z.clip()}const J=($.extent[0]-V[0])*U,H=-($.extent[3]-V[3])*U,_t=Ce($.extent)*U,xt=Bi($.extent)*U;z.drawImage($.image,E,E,$.image.width-2*E,$.image.height-2*E,A?J:Math.round(J),A?H:Math.round(H),A?_t:Math.round(J+_t)-Math.round(J),A?xt:Math.round(H+xt)-Math.round(H)),$.clipExtent&&z.restore()}})}const Z=or(u);return g.getTriangles().forEach(function($,ot,X){const J=$.source,H=$.target;let _t=J[0][0],xt=J[0][1],at=J[1][0],ut=J[1][1],pt=J[2][0],q=J[2][1];const lt=F((H[0][0]-Z[0])/l),yt=F(-(H[0][1]-Z[1])/l),Lt=F((H[1][0]-Z[0])/l),oe=F(-(H[1][1]-Z[1])/l),Gt=F((H[2][0]-Z[0])/l),$t=F(-(H[2][1]-Z[1])/l),Ft=_t,te=xt;_t=0,xt=0,at-=Ft,ut-=te,pt-=Ft,q-=te;const gt=[[at,ut,0,0,Lt-lt],[pt,q,0,0,Gt-lt],[0,0,at,ut,oe-yt],[0,0,pt,q,$t-yt]],ii=pf(gt);if(!ii)return;if(L.save(),L.beginPath(),gm()||!A){L.moveTo(Lt,oe);const Ne=4,ye=lt-Lt,mi=yt-oe;for(let ke=0;ke{const _t=e.getTileRangeForExtentAndZ(H,this.sourceZ_);for(let xt=_t.minX;xt<=_t.maxX;xt++)for(let at=_t.minY;at<=_t.maxY;at++){const ut=E(this.sourceZ_,xt,at,g);if(ut){const pt=X*ot;this.sourceTiles_.push({tile:ut,offset:pt})}}++X}),this.sourceTiles_.length===0&&(this.state=kt.EMPTY)}}getImage(){return this.canvas_}reproject_(){const t=[];if(this.sourceTiles_.forEach(e=>{const n=e.tile;if(n&&n.getState()==kt.LOADED){const o=this.sourceTileGrid_.getTileCoordExtent(n.tileCoord);o[0]+=e.offset,o[2]+=e.offset;const l=this.clipExtent_?.slice();l&&(l[0]+=e.offset,l[2]+=e.offset),t.push({extent:o,clipExtent:l,image:n.getImage()})}}),this.sourceTiles_.length=0,t.length===0)this.state=kt.ERROR;else{const e=this.wrappedTileCoord_[0],n=this.targetTileGrid_.getTileSize(e),o=typeof n=="number"?n:n[0],l=typeof n=="number"?n:n[1],u=this.targetTileGrid_.getResolution(e),g=this.sourceTileGrid_.getResolution(this.sourceZ_),x=this.targetTileGrid_.getTileCoordExtent(this.wrappedTileCoord_);this.canvas_=xm(o,l,this.pixelRatio_,g,this.sourceTileGrid_.getExtent(),u,x,this.triangulation_,t,this.gutter_,this.renderEdges_,this.interpolate),this.state=kt.LOADED}this.changed()}load(){if(this.state==kt.IDLE){this.state=kt.LOADING,this.changed();let t=0;this.sourcesListenerKeys_=[],this.sourceTiles_.forEach(({tile:e})=>{const n=e.getState();if(n==kt.IDLE||n==kt.LOADING){t++;const o=ge(e,jt.CHANGE,function(l){const u=e.getState();(u==kt.LOADED||u==kt.ERROR||u==kt.EMPTY)&&(Fe(o),t--,t===0&&(this.unlistenSources_(),this.reproject_()))},this);this.sourcesListenerKeys_.push(o)}}),t===0?setTimeout(this.reproject_.bind(this),0):this.sourceTiles_.forEach(function({tile:e},n,o){e.getState()==kt.IDLE&&e.load()})}}unlistenSources_(){this.sourcesListenerKeys_.forEach(Fe),this.sourcesListenerKeys_=null}release(){this.canvas_&&(Za(this.canvas_.getContext("2d")),Or.push(this.canvas_),this.canvas_=null),super.release()}}class _m extends j0{constructor(t){super(t),this.extentChanged=!0,this.renderedExtent_=null,this.renderedPixelRatio,this.renderedProjection=null,this.renderedRevision,this.renderedTiles=[],this.newTiles_=!1,this.tmpExtent=mn(),this.tmpTileRange_=new gc(0,0,0,0)}isDrawableTile(t){const e=this.getLayer(),n=t.getState(),o=e.getUseInterimTilesOnError();return n==kt.LOADED||n==kt.EMPTY||n==kt.ERROR&&!o}getTile(t,e,n,o){const l=o.pixelRatio,u=o.viewState.projection,g=this.getLayer();let E=g.getSource().getTile(t,e,n,l,u);return E.getState()==kt.ERROR&&g.getUseInterimTilesOnError()&&g.getPreload()>0&&(this.newTiles_=!0),this.isDrawableTile(E)||(E=E.getInterimTile()),E}getData(t){const e=this.frameState;if(!e)return null;const n=this.getLayer(),o=bi(e.pixelToCoordinateTransform,t.slice()),l=n.getExtent();if(l&&!Dr(l,o))return null;const u=e.pixelRatio,g=e.viewState.projection,x=e.viewState,E=n.getRenderSource(),w=E.getTileGridForProjection(x.projection),A=E.getTilePixelRatio(e.pixelRatio);for(let S=w.getZForResolution(x.resolution);S>=w.getMinZoom();--S){const P=w.getTileCoordForCoordAndZ(o,S),L=E.getTile(S,P[1],P[2],u,g);if(!(L instanceof i1||L instanceof Eh)||L instanceof Eh&&L.getState()===kt.EMPTY)return null;if(L.getState()!==kt.LOADED)continue;const F=w.getOrigin(S),V=sn(w.getTileSize(S)),z=w.getResolution(S),U=Math.floor(A*((o[0]-F[0])/z-P[1]*V[0])),Y=Math.floor(A*((F[1]-o[1])/z-P[2]*V[1])),Z=Math.round(A*E.getGutterForProjection(x.projection));return this.getImageData(L.getImage(),U+Z,Y+Z)}return null}loadedTileCallback(t,e,n){return this.isDrawableTile(n)?super.loadedTileCallback(t,e,n):!1}prepareFrame(t){return!!this.getLayer().getSource()}renderFrame(t,e){const n=t.layerStatesArray[t.layerIndex],o=t.viewState,l=o.projection,u=o.resolution,g=o.center,x=o.rotation,E=t.pixelRatio,w=this.getLayer(),A=w.getSource(),S=A.getRevision(),P=A.getTileGridForProjection(l),L=P.getZForResolution(u,A.zDirection),F=P.getResolution(L);let V=t.extent;const z=t.viewState.resolution,U=A.getTilePixelRatio(E);this.prepareContainer(t,e);const Y=this.context.canvas.width,Z=this.context.canvas.height,$=n.extent&&Ks(n.extent);$&&(V=co(V,Ks(n.extent)));const ot=F*Y/2/U,X=F*Z/2/U,J=[g[0]-ot,g[1]-X,g[0]+ot,g[1]+X],H=P.getTileRangeForExtentAndZ(V,L),_t={};_t[L]={};const xt=this.createLoadedTileFinder(A,l,_t),at=this.tmpExtent,ut=this.tmpTileRange_;this.newTiles_=!1;const pt=x?ah(o.center,z,x,t.size):void 0;for(let $t=H.minX;$t<=H.maxX;++$t)for(let Ft=H.minY;Ft<=H.maxY;++Ft){if(x&&!P.tileCoordIntersectsViewport([L,$t,Ft],pt))continue;const te=this.getTile(L,$t,Ft,t);if(this.isDrawableTile(te)){const Rt=be(this);if(te.getState()==kt.LOADED){_t[L][te.tileCoord.toString()]=te;let Ne=te.inTransition(Rt);Ne&&n.opacity!==1&&(te.endTransition(Rt),Ne=!1),!this.newTiles_&&(Ne||!this.renderedTiles.includes(te))&&(this.newTiles_=!0)}if(te.getAlpha(Rt,t.time)===1)continue}const gt=P.getTileCoordChildTileRange(te.tileCoord,ut,at);let ii=!1;gt&&(ii=xt(L+1,gt)),ii||P.forEachTileCoordParentTileRange(te.tileCoord,xt,ut,at)}const q=F/u*E/U,lt=this.getRenderContext(t);as(this.tempTransform,Y/2,Z/2,q,q,0,-Y/2,-Z/2),$&&this.clipUnrotated(lt,t,$),A.getInterpolate()||(lt.imageSmoothingEnabled=!1),this.preRender(lt,t),this.renderedTiles.length=0;let yt=Object.keys(_t).map(Number);yt.sort(ss);let Lt,oe,Gt;n.opacity===1&&(!this.containerReused||A.getOpaque(t.viewState.projection))?yt=yt.reverse():(Lt=[],oe=[]);for(let $t=yt.length-1;$t>=0;--$t){const Ft=yt[$t],te=A.getTilePixelSize(Ft,E,l),ii=P.getResolution(Ft)/F,Rt=te[0]*ii*q,Ne=te[1]*ii*q,ye=P.getTileCoordForCoordAndZ(or(J),Ft),mi=P.getTileCoordExtent(ye),ke=bi(this.tempTransform,[U*(mi[0]-J[0])/F,U*(J[3]-mi[3])/F]),Ke=U*A.getGutterForProjection(l),ze=_t[Ft];for(const ne in ze){const xi=ze[ne],hi=xi.tileCoord,Ei=ye[1]-hi[1],Ge=Math.round(ke[0]-(Ei-1)*Rt),he=ye[2]-hi[2],ee=Math.round(ke[1]-(he-1)*Ne),_i=Math.round(ke[0]-Ei*Rt),St=Math.round(ke[1]-he*Ne),Ci=Ge-_i,on=ee-St,ci=L===Ft,Ui=ci&&xi.getAlpha(be(this),t.time)!==1;let ni=!1;if(!Ui)if(Lt){Gt=[_i,St,_i+Ci,St,_i+Ci,St+on,_i,St+on];for(let qi=0,qe=Lt.length;qil-o,!0),"`resolutions` must be sorted in descending order");let e;if(!t.origins){for(let o=0,l=this.resolutions_.length-1;o{const u=new gc(Math.min(0,o[0]),Math.max(o[0]-1,-1),Math.min(0,o[1]),Math.max(o[1]-1,-1));if(n){const g=this.getTileRangeForExtentAndZ(n,l);u.minX=Math.max(g.minX,u.minX),u.maxX=Math.min(g.maxX,u.maxX),u.minY=Math.max(g.minY,u.minY),u.maxY=Math.min(g.maxY,u.maxY)}return u}):n&&this.calculateTileRanges_(n)}forEachTileCoord(t,e,n){const o=this.getTileRangeForExtentAndZ(t,e);for(let l=o.minX,u=o.maxX;l<=u;++l)for(let g=o.minY,x=o.maxY;g<=x;++g)n([e,l,g])}forEachTileCoordParentTileRange(t,e,n,o){let l,u,g,x=null,E=t[0]-1;for(this.zoomFactor_===2?(u=t[1],g=t[2]):x=this.getTileCoordExtent(t,o);E>=this.minZoom;){if(u!==void 0&&g!==void 0?(u=Math.floor(u/2),g=Math.floor(g/2),l=Er(u,u,g,g,n)):l=this.getTileRangeForExtentAndZ(x,E,n),e(E,l))return!0;--E}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,n){if(t[0]this.maxZoom||e0?n:Math.max(l/e[0],o/e[1]);const u=t+1,g=new Array(u);for(let x=0;xn.highWaterMark&&(n.highWaterMark=t)}useTile(t,e,n,o){}}class bm extends hs{constructor(t,e){super(t),this.tile=e}}function Tm(r,t){const e=/\{z\}/g,n=/\{x\}/g,o=/\{y\}/g,l=/\{-y\}/g;return function(u,g,x){if(u)return r.replace(e,u[0].toString()).replace(n,u[1].toString()).replace(o,u[2].toString()).replace(l,function(){const E=u[0],w=t.getFullTileRange(E);if(!w)throw new Error("The {-y} placeholder requires a tile grid with extent");return(w.getHeight()-u[2]-1).toString()})}}function Sm(r,t){const e=r.length,n=new Array(e);for(let o=0;othis.getTileInternal(V,z,U,Y,u),this.reprojectionErrorThreshold_,this.renderReprojectionEdges_,this.tileOptions);return F.key=A,E?(F.interimTile=E,F.refreshInterimChain(),g.replace(w,F)):g.set(w,F),F}getTileInternal(t,e,n,o,l){let u=null;const g=ol(t,e,n),x=this.getKey();if(!this.tileCache.containsKey(g))u=this.createTile_(t,e,n,o,l,x),this.tileCache.set(g,u);else if(u=this.tileCache.get(g),u.key!=x){const E=u;u=this.createTile_(t,e,n,o,l,x),E.getState()==kt.IDLE?u.interimTile=E.interimTile:u.interimTile=E,u.refreshInterimChain(),this.tileCache.replace(g,u)}return u}setRenderReprojectionEdges(t){if(this.renderReprojectionEdges_!=t){this.renderReprojectionEdges_=t;for(const e in this.tileCacheForProjection)this.tileCacheForProjection[e].clear();this.changed()}}setTileGridForProjection(t,e){const n=Be(t);if(n){const o=be(n);o in this.tileGridForProjection||(this.tileGridForProjection[o]=e)}}clear(){super.clear();for(const t in this.tileCacheForProjection)this.tileCacheForProjection[t].clear()}}function Nm(r,t){r.getImage().src=t}class Pm extends Om{constructor(t){t=t||{};const e=t.projection!==void 0?t.projection:"EPSG:3857",n=t.tileGrid!==void 0?t.tileGrid:Am({extent:mc(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,opaque:t.opaque,projection:e,reprojectionErrorThreshold:t.reprojectionErrorThreshold,tileGrid:n,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_}}class g1{constructor(){this.dataProjection=void 0,this.defaultFeatureProjection=void 0,this.featureClass=sr,this.supportedMediaTypes=null}getReadOptions(t,e){if(e){let n=e.dataProjection?Be(e.dataProjection):this.readProjection(t);e.extent&&n&&n.getUnits()==="tile-pixels"&&(n=Be(n),n.setWorldExtent(e.extent)),e={dataProjection:n,featureProjection:e.featureProjection}}return this.adaptOptions(e)}adaptOptions(t){return Object.assign({dataProjection:this.dataProjection,featureProjection:this.defaultFeatureProjection,featureClass:this.featureClass},t)}getType(){return Xt()}readFeature(t,e){return Xt()}readFeatures(t,e){return Xt()}readGeometry(t,e){return Xt()}readProjection(t){return Xt()}writeFeature(t,e){return Xt()}writeFeatures(t,e){return Xt()}writeGeometry(t,e){return Xt()}}function us(r,t,e){const n=e?Be(e.featureProjection):null,o=e?Be(e.dataProjection):null;let l=r;if(n&&o&&!js(n,o)){t&&(l=r.clone());const u=t?n:o,g=t?o:n;u.getUnits()==="tile-pixels"?l.transform(u,g):l.applyTransform(_o(u,g))}if(t&&e&&e.decimals!==void 0){const u=Math.pow(10,e.decimals),g=function(x){for(let E=0,w=x.length;Em1({...r,geometry:l})).flat();const n=e.type==="MultiPolygon"?"Polygon":e.type;if(n==="GeometryCollection"||n==="Circle")throw new Error("Unsupported geometry type: "+n);const o=e.layout.length;return us(new Yi(n,n==="Polygon"?Lm(e.flatCoordinates,e.ends,o):e.flatCoordinates,e.ends?.flat(),o,r.properties||{},r.id).enableSimplifyTransformed(),!1,t)}function _c(r,t){if(!r)return null;if(Array.isArray(r)){const n=r.map(o=>_c(o,t));return new h2(n)}const e=Dm[r.type];return us(new e(r.flatCoordinates,r.layout,r.ends),!1,t)}const Nu="http://www.w3.org/2001/XMLSchema-instance";function pc(r,t){return Wo().createElementNS(r,t)}function al(r,t){return x1(r,t,[]).join("")}function x1(r,t,e){if(r.nodeType==Node.CDATA_SECTION_NODE||r.nodeType==Node.TEXT_NODE)t?e.push(String(r.nodeValue).replace(/(\r\n|\r|\n)/g,"")):e.push(r.nodeValue);else{let n;for(n=r.firstChild;n;n=n.nextSibling)x1(n,t,e)}return e}function ao(r){return"documentElement"in r}function lo(r){return new DOMParser().parseFromString(r,"application/xml")}function Zl(r,t){return function(e,n){const o=r.call(t!==void 0?t:this,e,n);o!==void 0&&n[n.length-1].push(o)}}function Ht(r,t,e){return function(n,o){const l=r.call(e!==void 0?e:this,n,o);if(l!==void 0){const u=o[o.length-1],g=t!==void 0?t:n.localName;u[g]=l}}}function Qt(r,t){return function(e,n,o){r.call(t!==void 0?t:this,e,n,o),o[o.length-1].node.appendChild(e)}}function _1(r,t){let e,n;return function(o,l,u){if(e===void 0){e={};const g={};g[o.localName]=r,e[o.namespaceURI]=g,n=yc(o.localName)}p1(e,n,l,u)}}function yc(r,t){return function(e,n,o){const u=n[n.length-1].node;let g=r;g===void 0&&(g=o);const x=t!==void 0?t:u.namespaceURI;return pc(x,g)}}const ll=yc();function wc(r,t){const e=t.length,n=new Array(e);for(let o=0;o0?n[0]:null}readFeatureFromNode(t,e){return null}readFeatures(t,e){if(!t)return[];if(typeof t=="string"){const n=lo(t);return this.readFeaturesFromDocument(n,e)}return ao(t)?this.readFeaturesFromDocument(t,e):this.readFeaturesFromNode(t,e)}readFeaturesFromDocument(t,e){const n=[];for(let o=t.firstChild;o;o=o.nextSibling)o.nodeType==Node.ELEMENT_NODE&&bn(n,this.readFeaturesFromNode(o,e));return n}readFeaturesFromNode(t,e){return Xt()}readGeometry(t,e){if(!t)return null;if(typeof t=="string"){const n=lo(t);return this.readGeometryFromDocument(n,e)}return ao(t)?this.readGeometryFromDocument(t,e):this.readGeometryFromNode(t,e)}readGeometryFromDocument(t,e){return null}readGeometryFromNode(t,e){return null}readProjection(t){if(!t)return null;if(typeof t=="string"){const e=lo(t);return this.readProjectionFromDocument(e)}return ao(t)?this.readProjectionFromDocument(t):this.readProjectionFromNode(t)}readProjectionFromDocument(t){return this.dataProjection}readProjectionFromNode(t){return this.dataProjection}writeFeature(t,e){const n=this.writeFeatureNode(t,e);return this.xmlSerializer_.serializeToString(n)}writeFeatureNode(t,e){return null}writeFeatures(t,e){const n=this.writeFeaturesNode(t,e);return this.xmlSerializer_.serializeToString(n)}writeFeaturesNode(t,e){return null}writeGeometry(t,e){const n=this.writeGeometryNode(t,e);return this.xmlSerializer_.serializeToString(n)}writeGeometryNode(t,e){return null}}function hl(r){const t=al(r,!1),e=Date.parse(t);return isNaN(e)?void 0:e/1e3}function is(r){const t=al(r,!1);return km(t)}function km(r){const t=/^\s*([+\-]?\d*\.?\d+(?:e[+\-]?\d+)?)\s*$/i.exec(r);if(t)return parseFloat(t[1])}function vo(r){const t=al(r,!1);return Gm(t)}function Gm(r){const t=/^\s*(\d+)\s*$/.exec(r);if(t)return parseInt(t[1],10)}function Ve(r){return al(r,!1).trim()}function Um(r,t){const e=new Date(t*1e3),n=e.getUTCFullYear()+"-"+Qr(e.getUTCMonth()+1,2)+"-"+Qr(e.getUTCDate(),2)+"T"+Qr(e.getUTCHours(),2)+":"+Qr(e.getUTCMinutes(),2)+":"+Qr(e.getUTCSeconds(),2)+"Z";r.appendChild(Wo().createTextNode(n))}function Ys(r,t){const e=t.toPrecision();r.appendChild(Wo().createTextNode(e))}function Da(r,t){const e=t.toString();r.appendChild(Wo().createTextNode(e))}function gi(r,t){r.appendChild(Wo().createTextNode(t))}const Ue=[null,"http://www.topografix.com/GPX/1/0","http://www.topografix.com/GPX/1/1"],zm="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd",Wm={rte:y1,trk:w1,wpt:E1},Xm=li(Ue,{rte:Zl(y1),trk:Zl(w1),wpt:Zl(E1)}),Vm=li(Ue,{text:Ht(Ve,"linkText"),type:Ht(Ve,"linkType")}),Ym=li(Ue,{name:Ht(Ve),email:px,link:Xo}),Hm=li(Ue,{name:Ht(Ve),desc:Ht(Ve),author:Ht(mx),copyright:Ht(xx),link:Xo,time:Ht(hl),keywords:Ht(Ve),bounds:_x,extensions:cl}),jm=li(Ue,{year:Ht(vo),license:Ht(Ve)}),Zm=li(Ue,{rte:Qt(Cx),trk:Qt(Ax),wpt:Qt(Mx)});class Km extends Bm{constructor(t){super(),t=t||{},this.dataProjection=Be("EPSG:4326"),this.readExtensions_=t.readExtensions}handleReadExtensions_(t){t||(t=[]);for(let e=0,n=t.length;e0?90:-90)):(f.lat0=x(f.lat1>0?90:-90),f.lat_ts=f.lat1)}function w(f){var p=this;if(arguments.length===2){var y=arguments[1];typeof y=="string"?y.charAt(0)==="+"?w[f]=de(arguments[1]):w[f]=ks(arguments[1]):w[f]=y}else if(arguments.length===1){if(Array.isArray(f))return f.map(function(b){Array.isArray(b)?w.apply(p,b):w(b)});if(typeof f=="string"){if(f in w)return w[f]}else"EPSG"in f?w["EPSG:"+f.EPSG]=f:"ESRI"in f?w["ESRI:"+f.ESRI]=f:"IAU2000"in f?w["IAU2000:"+f.IAU2000]=f:console.log(f);return}}function A(f){return typeof f=="string"}function S(f){return f in w}function P(f){return ur.some(function(p){return f.indexOf(p)>-1})}function L(f){var p=e(f,"authority");if(p){var y=e(p,"epsg");return y&&ln.indexOf(y)>-1}}function F(f){var p=e(f,"extension");if(p)return e(p,"proj4")}function V(f){return f[0]==="+"}function z(f){if(!A(f))return f;if(S(f))return w[f];if(P(f)){var p=ks(f);if(L(p))return w["EPSG:3857"];var y=F(p);return y?de(y):p}return V(f)?de(f):void 0}function U(f){return f}function Y(f,p){var y=dt.length;return f.names?(dt[y]=f,f.names.forEach(function(b){xs[b.toLowerCase()]=y}),this):(console.log(p),!0)}function Z(f,p,y,b){var I=f*f,v=p*p,N=(I-v)/I,O=0;return b?(I=(f*=1-N*(Gi+N*(On+N*Bs)))*f,N=0):O=Math.sqrt(N),{es:N,e:O,ep2:(I-v)/v}}function $(f,p,y,b,I){if(!f){var v=e(Ot,b);v||(v=_s),f=v.a,p=v.b,y=v.rf}return y&&!p&&(p=(1-1/y)*f),(y===0||Math.abs(f-p)3&&(O.datum_params[3]===0&&O.datum_params[4]===0&&O.datum_params[5]===0&&O.datum_params[6]===0||(O.datum_type=se,O.datum_params[3]*=an,O.datum_params[4]*=an,O.datum_params[5]*=an,O.datum_params[6]=O.datum_params[6]/1e6+1))),N&&(O.datum_type=we,O.grids=N),O.a=y,O.b=b,O.es=I,O.ep2=v,O}function X(f){return f===void 0?null:f.split(",").map(J)}function J(f){if(f.length===0)return null;var p=f[0]==="@";return p&&(f=f.slice(1)),f==="null"?{name:"null",mandatory:!p,grid:null,isNull:!0}:{name:f,mandatory:!p,grid:me[f]||null,isNull:!1}}function H(f){return f/3600*Math.PI/180}function _t(f){var p=f.getInt32(8,!1);return p!==11&&((p=f.getInt32(8,!0))!==11&&console.warn("Failed to detect nadgrid endian-ness, defaulting to little-endian"),!0)}function xt(f,p){return{nFields:f.getInt32(8,p),nSubgridFields:f.getInt32(24,p),nSubgrids:f.getInt32(40,p),shiftType:at(f,56,64).trim(),fromSemiMajorAxis:f.getFloat64(120,p),fromSemiMinorAxis:f.getFloat64(136,p),toSemiMajorAxis:f.getFloat64(152,p),toSemiMinorAxis:f.getFloat64(168,p)}}function at(f,p,y){return String.fromCharCode.apply(null,new Uint8Array(f.buffer.slice(p,y)))}function ut(f,p,y){for(var b=176,I=[],v=0;v5e-11)&&(f.datum_type===Te?f.datum_params[0]===p.datum_params[0]&&f.datum_params[1]===p.datum_params[1]&&f.datum_params[2]===p.datum_params[2]:f.datum_type!==se||f.datum_params[0]===p.datum_params[0]&&f.datum_params[1]===p.datum_params[1]&&f.datum_params[2]===p.datum_params[2]&&f.datum_params[3]===p.datum_params[3]&&f.datum_params[4]===p.datum_params[4]&&f.datum_params[5]===p.datum_params[5]&&f.datum_params[6]===p.datum_params[6])}function oe(f,p,y){var b,I,v,N,O=f.x,G=f.y,W=f.z?f.z:0;if(G<-ht&&G>-1.001*ht)G=-ht;else if(G>ht&&G<1.001*ht)G=ht;else{if(G<-ht)return{x:-1/0,y:-1/0,z:f.z};if(G>ht)return{x:1/0,y:1/0,z:f.z}}return O>Math.PI&&(O-=2*Math.PI),I=Math.sin(G),N=Math.cos(G),v=I*I,b=y/Math.sqrt(1-p*v),{x:(b+W)*N*Math.cos(O),y:(b+W)*N*Math.sin(O),z:(b*(1-p)+W)*I}}function Gt(f,p,y,b){var I,v,N,O,G,W,Q,it,ct,wt,rt,Mt,T,i,s,a,h=f.x,c=f.y,d=f.z?f.z:0;if(I=Math.sqrt(h*h+c*c),v=Math.sqrt(h*h+c*c+d*d),I/y<1e-12){if(i=0,v/y<1e-12)return s=ht,a=-b,{x:f.x,y:f.y,z:f.z}}else i=Math.atan2(c,h);N=d/v,it=(O=I/v)*(1-p)*(G=1/Math.sqrt(1-p*(2-p)*O*O)),ct=N*G,T=0;do T++,W=p*(Q=y/Math.sqrt(1-p*ct*ct))/(Q+(a=I*it+d*ct-Q*(1-p*ct*ct))),Mt=(rt=N*(G=1/Math.sqrt(1-W*(2-W)*O*O)))*it-(wt=O*(1-W)*G)*ct,it=wt,ct=rt;while(Mt*Mt>1e-24&&T<30);return s=Math.atan(rt/Math.abs(wt)),{x:i,y:s,z:a}}function $t(f,p,y){if(p===Te)return{x:f.x+y[0],y:f.y+y[1],z:f.z+y[2]};if(p===se){var b=y[0],I=y[1],v=y[2],N=y[3],O=y[4],G=y[5],W=y[6];return{x:W*(f.x-G*f.y+O*f.z)+b,y:W*(G*f.x+f.y-N*f.z)+I,z:W*(-O*f.x+N*f.y+f.z)+v}}}function Ft(f,p,y){if(p===Te)return{x:f.x-y[0],y:f.y-y[1],z:f.z-y[2]};if(p===se){var b=y[0],I=y[1],v=y[2],N=y[3],O=y[4],G=y[5],W=y[6],Q=(f.x-b)/W,it=(f.y-I)/W,ct=(f.z-v)/W;return{x:Q+G*it-O*ct,y:-G*Q+it+N*ct,z:O*Q-N*it+ct}}}function te(f){return f===Te||f===se}function gt(f,p,y){if(f.grids===null||f.grids.length===0)return console.log("Grid shift grids not found"),-1;var b={x:-y.x,y:y.y},I={x:Number.NaN,y:Number.NaN},v=[];t:for(var N=0;Nb.y||wt>b.x||T1e-12&&Math.abs(N.y)>1e-12);if(G<0)return console.log("Inverse grid shift iterator failed to converge."),b;b.x=Tt(v.x+y.ll[0]),b.y=v.y+y.ll[1]}else isNaN(v.x)||(b.x=f.x+v.x,b.y=f.y+v.y);return b}function Rt(f,p){var y,b={x:f.x/p.del[0],y:f.y/p.del[1]},I={x:Math.floor(b.x),y:Math.floor(b.y)},v={x:b.x-1*I.x,y:b.y-1*I.y},N={x:Number.NaN,y:Number.NaN};if(I.x<0||I.x>=p.lim[0]||I.y<0||I.y>=p.lim[1])return N;y=I.y*p.lim[0]+I.x;var O={x:p.cvs[y][0],y:p.cvs[y][1]};y++;var G={x:p.cvs[y][0],y:p.cvs[y][1]};y+=p.lim[0];var W={x:p.cvs[y][0],y:p.cvs[y][1]};y--;var Q={x:p.cvs[y][0],y:p.cvs[y][1]},it=v.x*v.y,ct=v.x*(1-v.y),wt=(1-v.x)*(1-v.y),rt=(1-v.x)*v.y;return N.x=wt*O.x+ct*G.x+rt*Q.x+it*W.x,N.y=wt*O.y+ct*G.y+rt*Q.y+it*W.y,N}function Ne(f){if(typeof Number.isFinite=="function"){if(Number.isFinite(f))return;throw new TypeError("coordinates must be finite numbers")}if(typeof f!="number"||f!==f||!isFinite(f))throw new TypeError("coordinates must be finite numbers")}function ye(f,p){return(f.datum.datum_type===Te||f.datum.datum_type===se||f.datum.datum_type===we)&&p.datumCode!=="WGS84"||(p.datum.datum_type===Te||p.datum.datum_type===se||p.datum.datum_type===we)&&f.datumCode!=="WGS84"}function mi(f,p,y,b){var I,v=(y=Array.isArray(y)?fr(y):{x:y.x,y:y.y,z:y.z,m:y.m}).z!==void 0;if(Hr(y),f.datum&&p.datum&&ye(f,p)&&(y=mi(f,I=new yt("WGS84"),y,b),f=I),b&&f.axis!=="enu"&&(y=re(f,!1,y)),f.projName==="longlat")y={x:y.x*fe,y:y.y*fe,z:y.z||0};else if(f.to_meter&&(y={x:y.x*f.to_meter,y:y.y*f.to_meter,z:y.z||0}),!(y=f.inverse(y)))return;if(f.from_greenwich&&(y.x+=f.from_greenwich),y=xe(f.datum,p.datum,y))return p.from_greenwich&&(y={x:y.x-p.from_greenwich,y:y.y,z:y.z||0}),p.projName==="longlat"?y={x:y.x*ue,y:y.y*ue,z:y.z||0}:(y=p.forward(y),p.to_meter&&(y={x:y.x/p.to_meter,y:y.y/p.to_meter,z:y.z||0})),b&&p.axis!=="enu"?re(p,!0,y):(y&&!v&&delete y.z,y)}function ke(f,p,y,b){var I,v,N;return Array.isArray(y)?(I=mi(f,p,y,b)||{x:NaN,y:NaN},y.length>2?f.name!==void 0&&f.name==="geocent"||p.name!==void 0&&p.name==="geocent"?typeof I.z=="number"?[I.x,I.y,I.z].concat(y.splice(3)):[I.x,I.y,y[2]].concat(y.splice(3)):[I.x,I.y].concat(y.splice(2)):[I.x,I.y]):(v=mi(f,p,y,b),(N=Object.keys(y)).length===2||N.forEach(function(O){if(f.name!==void 0&&f.name==="geocent"||p.name!==void 0&&p.name==="geocent"){if(O==="x"||O==="y"||O==="z")return}else if(O==="x"||O==="y")return;v[O]=y[O]}),v)}function Ke(f){return f instanceof yt?f:f.oProj?f.oProj:yt(f)}function ze(f,p,y){f=Ke(f);var b,I=!1;return p===void 0?(p=f,f=dr,I=!0):(p.x!==void 0||Array.isArray(p))&&(y=p,p=f,f=dr,I=!0),p=Ke(p),y?ke(f,p,y):(b={forward:function(v,N){return ke(f,p,v,N)},inverse:function(v,N){return ke(p,f,v,N)}},I&&(b.oProj=p),b)}function ne(f,p){return p=p||5,_i(Ge({lat:f[1],lon:f[0]}),p)}function xi(f){var p=he(ci(f.toUpperCase()));return p.lat&&p.lon?[p.lon,p.lat]:[(p.left+p.right)/2,(p.top+p.bottom)/2]}function hi(f){return f*(Math.PI/180)}function Ei(f){return f/Math.PI*180}function Ge(f){var p,y,b,I,v,N,O=f.lat,G=f.lon,W=6378137,Q=hi(O),it=hi(G);N=Math.floor((G+180)/6)+1,G===180&&(N=60),O>=56&&O<64&&G>=3&&G<12&&(N=32),O>=72&&O<84&&(G>=0&&G<9?N=31:G>=9&&G<21?N=33:G>=21&&G<33?N=35:G>=33&&G<42&&(N=37)),v=hi(6*(N-1)-180+3),p=W/Math.sqrt(1-.00669438*Math.sin(Q)*Math.sin(Q)),y=Math.tan(Q)*Math.tan(Q),b=.006739496752268451*Math.cos(Q)*Math.cos(Q);var ct=.9996*p*((I=Math.cos(Q)*(it-v))+(1-y+b)*I*I*I/6+(5-18*y+y*y+72*b-.39089081163157013)*I*I*I*I*I/120)+5e5,wt=.9996*(W*(.9983242984503243*Q-.002514607064228144*Math.sin(2*Q)+2639046602129982e-21*Math.sin(4*Q)-3418046101696858e-24*Math.sin(6*Q))+p*Math.tan(Q)*(I*I/2+(5-y+9*b+4*b*b)*I*I*I*I/24+(61-58*y+y*y+600*b-2.2240339282485886)*I*I*I*I*I*I/720));return O<0&&(wt+=1e7),{northing:Math.round(wt),easting:Math.round(ct),zoneNumber:N,zoneLetter:ee(O)}}function he(f){var p=f.northing,y=f.easting,b=f.zoneLetter,I=f.zoneNumber;if(I<0||I>60)return null;var v,N,O,G,W,Q,it,ct,wt=6378137,rt=(1-Math.sqrt(.99330562))/(1+Math.sqrt(.99330562)),Mt=y-5e5,T=p;b<"N"&&(T-=1e7),Q=6*(I-1)-180+3,ct=(it=T/.9996/6367449145945056e-9)+(3*rt/2-27*rt*rt*rt/32)*Math.sin(2*it)+(21*rt*rt/16-55*rt*rt*rt*rt/32)*Math.sin(4*it)+151*rt*rt*rt/96*Math.sin(6*it),v=wt/Math.sqrt(1-.00669438*Math.sin(ct)*Math.sin(ct)),N=Math.tan(ct)*Math.tan(ct),O=.006739496752268451*Math.cos(ct)*Math.cos(ct),G=.99330562*wt/Math.pow(1-.00669438*Math.sin(ct)*Math.sin(ct),1.5),W=Mt/(.9996*v);var i=ct-v*Math.tan(ct)/G*(W*W/2-(5+3*N+10*O-4*O*O-.06065547077041606)*W*W*W*W/24+(61+90*N+298*O+45*N*N-1.6983531815716497-3*O*O)*W*W*W*W*W*W/720);i=Ei(i);var s=(W-(1+2*N+O)*W*W*W/6+(5-2*O+28*N-3*O*O+.05391597401814761+24*N*N)*W*W*W*W*W/120)/Math.cos(ct);s=Q+Ei(s);var a;if(f.accuracy){var h=he({northing:f.northing+f.accuracy,easting:f.easting+f.accuracy,zoneLetter:f.zoneLetter,zoneNumber:f.zoneNumber});a={top:h.lat,right:h.lon,bottom:i,left:s}}else a={lat:i,lon:s};return a}function ee(f){var p="Z";return 84>=f&&f>=72?p="X":72>f&&f>=64?p="W":64>f&&f>=56?p="V":56>f&&f>=48?p="U":48>f&&f>=40?p="T":40>f&&f>=32?p="S":32>f&&f>=24?p="R":24>f&&f>=16?p="Q":16>f&&f>=8?p="P":8>f&&f>=0?p="N":0>f&&f>=-8?p="M":-8>f&&f>=-16?p="L":-16>f&&f>=-24?p="K":-24>f&&f>=-32?p="J":-32>f&&f>=-40?p="H":-40>f&&f>=-48?p="G":-48>f&&f>=-56?p="F":-56>f&&f>=-64?p="E":-64>f&&f>=-72?p="D":-72>f&&f>=-80&&(p="C"),p}function _i(f,p){var y="00000"+f.easting,b="00000"+f.northing;return f.zoneNumber+f.zoneLetter+St(f.easting,f.northing,f.zoneNumber)+y.substr(y.length-5,p)+b.substr(b.length-5,p)}function St(f,p,y){var b=Ci(y);return on(Math.floor(f/1e5),Math.floor(p/1e5)%20,b)}function Ci(f){var p=f%Je;return p===0&&(p=Je),p}function on(f,p,y){var b=y-1,I=_n.charCodeAt(b),v=Ho.charCodeAt(b),N=I+f-1,O=v+p,G=!1;return N>Ee&&(N=N-Ee+Oe-1,G=!0),(N===He||IHe||(N>He||Izi||(N>zi||IEe&&(N=N-Ee+Oe-1),O>cn?(O=O-cn+Oe-1,G=!0):G=!1,(O===He||vHe||(O>He||vzi||(O>zi||vcn&&(O=O-cn+Oe-1),String.fromCharCode(N)+String.fromCharCode(O)}function ci(f){if(f&&f.length===0)throw"MGRSPoint coverting from nothing";for(var p,y=f.length,b=null,I="",v=0;!/[A-Z]/.test(p=f.charAt(v));){if(v>=2)throw"MGRSPoint bad conversion from: "+f;I+=p,v++}var N=parseInt(I,10);if(v===0||v+3>y)throw"MGRSPoint bad conversion from: "+f;var O=f.charAt(v++);if(O<="A"||O==="B"||O==="Y"||O>="Z"||O==="I"||O==="O")throw"MGRSPoint zone letter "+O+" not handled: "+f;b=f.substring(v,v+=2);for(var G=Ci(N),W=Ui(b.charAt(0),G),Q=ni(b.charAt(1),G);Q0&&(ct=1e5/Math.pow(10,i),wt=f.substring(v,v+i),s=parseFloat(wt)*ct,rt=f.substring(v+i),a=parseFloat(rt)*ct),Mt=s+W,T=a+Q,{easting:Mt,northing:T,zoneLetter:O,zoneNumber:N,accuracy:ct}}function Ui(f,p){for(var y=_n.charCodeAt(p-1),b=1e5,I=!1;y!==f.charCodeAt(0);){if(++y===He&&y++,y===zi&&y++,y>Ee){if(I)throw"Bad character: "+f;y=Oe,I=!0}b+=1e5}return b}function ni(f,p){if(f>"V")throw"MGRSPoint given invalid Northing "+f;for(var y=Ho.charCodeAt(p-1),b=0,I=!1;y!==f.charCodeAt(0);){if(++y===He&&y++,y===zi&&y++,y>cn){if(I)throw"Bad character: "+f;y=Oe,I=!0}b+=1e5}return b}function qi(f){var p;switch(f){case"C":p=11e5;break;case"D":p=2e6;break;case"E":p=28e5;break;case"F":p=37e5;break;case"G":p=46e5;break;case"H":p=55e5;break;case"J":p=64e5;break;case"K":p=73e5;break;case"L":p=82e5;break;case"M":p=91e5;break;case"N":p=0;break;case"P":p=8e5;break;case"Q":p=17e5;break;case"R":p=26e5;break;case"S":p=35e5;break;case"T":p=44e5;break;case"U":p=53e5;break;case"V":p=62e5;break;case"W":p=7e6;break;case"X":p=79e5;break;default:p=-1}if(p>=0)return p;throw"Invalid zone letter: "+f}function qe(f,p,y){if(!(this instanceof qe))return new qe(f,p,y);if(Array.isArray(f))this.x=f[0],this.y=f[1],this.z=f[2]||0;else if(typeof f=="object")this.x=f.x,this.y=f.y,this.z=f.z||0;else if(typeof f=="string"&&p===void 0){var b=f.split(",");this.x=parseFloat(b[0],10),this.y=parseFloat(b[1],10),this.z=parseFloat(b[2],10)||0}else this.x=f,this.y=p,this.z=y||0;console.warn("proj4.Point will be removed in version 3, use proj4.toPoint")}function ce(f){var p=["Hotine_Oblique_Mercator","Hotine_Oblique_Mercator_Azimuth_Natural_Origin"],y=typeof f.PROJECTION=="object"?Object.keys(f.PROJECTION)[0]:f.PROJECTION;return"no_uoff"in f||"no_off"in f||p.indexOf(y)!==-1}function cr(f){var p,y=[];return y[0]=f*qo,p=f*f,y[0]+=p*Jo,y[1]=p*Cl,p*=f,y[0]+=p*El,y[1]+=p*Al,y[2]=p*Ie,y}function Xn(f,p){var y=f+f;return f+p[0]*Math.sin(y)+p[1]*Math.sin(y+y)+p[2]*Math.sin(y+y+y)}function Vn(f,p,y,b){var I;return fWt&&I<=ht+Wt?(b.value=bt.AREA_1,I-=ht):I>ht+Wt||I<=-(ht+Wt)?(b.value=bt.AREA_2,I=I>=0?I-Vt:I+Vt):(b.value=bt.AREA_3,I+=ht)),I}function Ae(f,p){var y=f+p;return y<-Vt?y+=si:y>+Vt&&(y-=si),y}function It(f,p,y,b){for(var I=p;b;--b){var v=f(I);if(I-=v,Math.abs(v)=this.text.length)return;f=this.text[this.place++]}switch(this.state){case Ye:return this.neutral(f);case 2:return this.keyword(f);case 4:return this.quoted(f);case 5:return this.afterquote(f);case 3:return this.number(f);case-1:return}},n.prototype.afterquote=function(f){if(f==='"')return this.word+='"',void(this.state=4);if(ds.test(f))return this.word=this.word.trim(),void this.afterItem(f);throw new Error(`havn't handled "`+f+'" in afterquote yet, index '+this.place)},n.prototype.afterItem=function(f){return f===","?(this.word!==null&&this.currentObject.push(this.word),this.word=null,void(this.state=Ye)):f==="]"?(this.level--,this.word!==null&&(this.currentObject.push(this.word),this.word=null),this.state=Ye,this.currentObject=this.stack.pop(),void(this.currentObject||(this.state=-1))):void 0},n.prototype.number=function(f){if(!Ai.test(f)){if(ds.test(f))return this.word=parseFloat(this.word),void this.afterItem(f);throw new Error(`havn't handled "`+f+'" in number yet, index '+this.place)}this.word+=f},n.prototype.quoted=function(f){f!=='"'?this.word+=f:this.state=5},n.prototype.keyword=function(f){if(fs.test(f))this.word+=f;else{if(f==="["){var p=[];return p.push(this.word),this.level++,this.root===null?this.root=p:this.currentObject.push(p),this.stack.push(this.currentObject),this.currentObject=p,void(this.state=Ye)}if(!ds.test(f))throw new Error(`havn't handled "`+f+'" in keyword yet, index '+this.place);this.afterItem(f)}},n.prototype.neutral=function(f){if(vt.test(f))return this.word=f,void(this.state=2);if(f==='"')return this.word="",void(this.state=4);if(Ai.test(f))return this.word=f,void(this.state=3);{if(!ds.test(f))throw new Error(`havn't handled "`+f+'" in neutral yet, index '+this.place);this.afterItem(f)}},n.prototype.output=function(){for(;this.place90&&y*ue<-90&&p*ue>180&&p*ue<-180)return null;var b,I;if(Math.abs(Math.abs(y)-ht)<=Ct)return null;if(this.sphere)b=this.x0+this.a*this.k0*Tt(p-this.long0),I=this.y0+this.a*this.k0*Math.log(Math.tan(Wt+.5*y));else{var v=Math.sin(y),N=ae(this.e,y,v);b=this.x0+this.a*this.k0*Tt(p-this.long0),I=this.y0-this.a*this.k0*Math.log(N)}return f.x=b,f.y=I,f},inverse:function(f){var p,y,b=f.x-this.x0,I=f.y-this.y0;if(this.sphere)y=ht-2*Math.atan(Math.exp(-I/(this.a*this.k0)));else{var v=Math.exp(-I/(this.a*this.k0));if((y=ms(this.e,v))===-9999)return null}return p=Tt(this.long0+b/(this.a*this.k0)),f.x=p,f.y=y,f},names:["Mercator","Popular Visualisation Pseudo Mercator","Mercator_1SP","Mercator_Auxiliary_Sphere","merc"]},{init:function(){},forward:U,inverse:U,names:["longlat","identity"]}],xs={},dt=[],xl={start:function(){Nn.forEach(Y)},add:Y,get:function(f){if(!f)return!1;var p=f.toLowerCase();return xs[p]!==void 0&&dt[xs[p]]?dt[xs[p]]:void 0}},Ot={};Ot.MERIT={a:6378137,rf:298.257,ellipseName:"MERIT 1983"},Ot.SGS85={a:6378136,rf:298.257,ellipseName:"Soviet Geodetic System 85"},Ot.GRS80={a:6378137,rf:298.257222101,ellipseName:"GRS 1980(IUGG, 1980)"},Ot.IAU76={a:6378140,rf:298.257,ellipseName:"IAU 1976"},Ot.airy={a:6377563396e-3,b:635625691e-2,ellipseName:"Airy 1830"},Ot.APL4={a:6378137,rf:298.25,ellipseName:"Appl. Physics. 1965"},Ot.NWL9D={a:6378145,rf:298.25,ellipseName:"Naval Weapons Lab., 1965"},Ot.mod_airy={a:6377340189e-3,b:6356034446e-3,ellipseName:"Modified Airy"},Ot.andrae={a:637710443e-2,rf:300,ellipseName:"Andrae 1876 (Den., Iclnd.)"},Ot.aust_SA={a:6378160,rf:298.25,ellipseName:"Australian Natl & S. Amer. 1969"},Ot.GRS67={a:6378160,rf:298.247167427,ellipseName:"GRS 67(IUGG 1967)"},Ot.bessel={a:6377397155e-3,rf:299.1528128,ellipseName:"Bessel 1841"},Ot.bess_nam={a:6377483865e-3,rf:299.1528128,ellipseName:"Bessel 1841 (Namibia)"},Ot.clrk66={a:63782064e-1,b:63565838e-1,ellipseName:"Clarke 1866"},Ot.clrk80={a:6378249145e-3,rf:293.4663,ellipseName:"Clarke 1880 mod."},Ot.clrk80ign={a:63782492e-1,b:6356515,rf:293.4660213,ellipseName:"Clarke 1880 (IGN)"},Ot.clrk58={a:6378293645208759e-9,rf:294.2606763692654,ellipseName:"Clarke 1858"},Ot.CPM={a:63757387e-1,rf:334.29,ellipseName:"Comm. des Poids et Mesures 1799"},Ot.delmbr={a:6376428,rf:311.5,ellipseName:"Delambre 1810 (Belgium)"},Ot.engelis={a:637813605e-2,rf:298.2566,ellipseName:"Engelis 1985"},Ot.evrst30={a:6377276345e-3,rf:300.8017,ellipseName:"Everest 1830"},Ot.evrst48={a:6377304063e-3,rf:300.8017,ellipseName:"Everest 1948"},Ot.evrst56={a:6377301243e-3,rf:300.8017,ellipseName:"Everest 1956"},Ot.evrst69={a:6377295664e-3,rf:300.8017,ellipseName:"Everest 1969"},Ot.evrstSS={a:6377298556e-3,rf:300.8017,ellipseName:"Everest (Sabah & Sarawak)"},Ot.fschr60={a:6378166,rf:298.3,ellipseName:"Fischer (Mercury Datum) 1960"},Ot.fschr60m={a:6378155,rf:298.3,ellipseName:"Fischer 1960"},Ot.fschr68={a:6378150,rf:298.3,ellipseName:"Fischer 1968"},Ot.helmert={a:6378200,rf:298.3,ellipseName:"Helmert 1906"},Ot.hough={a:6378270,rf:297,ellipseName:"Hough"},Ot.intl={a:6378388,rf:297,ellipseName:"International 1909 (Hayford)"},Ot.kaula={a:6378163,rf:298.24,ellipseName:"Kaula 1961"},Ot.lerch={a:6378139,rf:298.257,ellipseName:"Lerch 1979"},Ot.mprts={a:6397300,rf:191,ellipseName:"Maupertius 1738"},Ot.new_intl={a:63781575e-1,b:63567722e-1,ellipseName:"New International 1967"},Ot.plessis={a:6376523,rf:6355863,ellipseName:"Plessis 1817 (France)"},Ot.krass={a:6378245,rf:298.3,ellipseName:"Krassovsky, 1942"},Ot.SEasia={a:6378155,b:63567733205e-4,ellipseName:"Southeast Asia"},Ot.walbeck={a:6376896,b:63558348467e-4,ellipseName:"Walbeck"},Ot.WGS60={a:6378165,rf:298.3,ellipseName:"WGS 60"},Ot.WGS66={a:6378145,rf:298.25,ellipseName:"WGS 66"},Ot.WGS7={a:6378135,rf:298.26,ellipseName:"WGS 72"};var _s=Ot.WGS84={a:6378137,rf:298.257223563,ellipseName:"WGS 84"};Ot.sphere={a:6370997,b:6370997,ellipseName:"Normal Sphere (r=6370997)"};var ri={};ri.wgs84={towgs84:"0,0,0",ellipse:"WGS84",datumName:"WGS84"},ri.ch1903={towgs84:"674.374,15.056,405.346",ellipse:"bessel",datumName:"swiss"},ri.ggrs87={towgs84:"-199.87,74.79,246.62",ellipse:"GRS80",datumName:"Greek_Geodetic_Reference_System_1987"},ri.nad83={towgs84:"0,0,0",ellipse:"GRS80",datumName:"North_American_Datum_1983"},ri.nad27={nadgrids:"@conus,@alaska,@ntv2_0.gsb,@ntv1_can.dat",ellipse:"clrk66",datumName:"North_American_Datum_1927"},ri.potsdam={towgs84:"598.1,73.7,418.2,0.202,0.045,-2.455,6.7",ellipse:"bessel",datumName:"Potsdam Rauenberg 1950 DHDN"},ri.carthage={towgs84:"-263.0,6.0,431.0",ellipse:"clark80",datumName:"Carthage 1934 Tunisia"},ri.hermannskogel={towgs84:"577.326,90.129,463.919,5.137,1.474,5.297,2.4232",ellipse:"bessel",datumName:"Hermannskogel"},ri.militargeographische_institut={towgs84:"577.326,90.129,463.919,5.137,1.474,5.297,2.4232",ellipse:"bessel",datumName:"Militar-Geographische Institut"},ri.osni52={towgs84:"482.530,-130.596,564.557,-1.042,-0.214,-0.631,8.15",ellipse:"airy",datumName:"Irish National"},ri.ire65={towgs84:"482.530,-130.596,564.557,-1.042,-0.214,-0.631,8.15",ellipse:"mod_airy",datumName:"Ireland 1965"},ri.rassadiran={towgs84:"-133.63,-157.5,-158.62",ellipse:"intl",datumName:"Rassadiran"},ri.nzgd49={towgs84:"59.47,-5.04,187.44,0.47,-0.1,1.024,-4.5993",ellipse:"intl",datumName:"New Zealand Geodetic Datum 1949"},ri.osgb36={towgs84:"446.448,-125.157,542.060,0.1502,0.2470,0.8421,-20.4894",ellipse:"airy",datumName:"Airy 1830"},ri.s_jtsk={towgs84:"589,76,480",ellipse:"bessel",datumName:"S-JTSK (Ferro)"},ri.beduaram={towgs84:"-106,-87,188",ellipse:"clrk80",datumName:"Beduaram"},ri.gunung_segara={towgs84:"-403,684,41",ellipse:"bessel",datumName:"Gunung Segara Jakarta"},ri.rnb72={towgs84:"106.869,-52.2978,103.724,-0.33657,0.456955,-1.84218,1",ellipse:"intl",datumName:"Reseau National Belge 1972"};var me={};yt.projections=xl,yt.projections.start();var xe=function(f,p,y){if(Lt(f,p)||f.datum_type===vn||p.datum_type===vn)return y;var b=f.a,I=f.es;if(f.datum_type===we){if(gt(f,!1,y)!==0)return;b=6378137,I=.0066943799901413165}var v=p.a,N=p.b,O=p.es;return p.datum_type===we&&(v=6378137,N=6356752314e-3,O=.0066943799901413165),I!==O||b!==v||te(f.datum_type)||te(p.datum_type)?(y=oe(y,I,b),te(f.datum_type)&&(y=$t(y,f.datum_type,f.datum_params)),te(p.datum_type)&&(y=Ft(y,p.datum_type,p.datum_params)),y=Gt(y,O,v,N),p.datum_type!==we||gt(p,!0,y)===0?y:void 0):y},re=function(f,p,y){var b,I,v,N=y.x,O=y.y,G=y.z||0,W={};for(v=0;v<3;v++)if(!p||v!==2||y.z!==void 0)switch(v===0?(b=N,I="ew".indexOf(f.axis[v])!==-1?"x":"y"):v===1?(b=O,I="ns".indexOf(f.axis[v])!==-1?"y":"x"):(b=G,I="z"),f.axis[v]){case"e":W[I]=b;break;case"w":W[I]=-b;break;case"n":W[I]=b;break;case"s":W[I]=-b;break;case"u":y[I]!==void 0&&(W.z=b);break;case"d":y[I]!==void 0&&(W.z=-b);break;default:return null}return W},fr=function(f){var p={x:f[0],y:f[1]};return f.length>2&&(p.z=f[2]),f.length>3&&(p.m=f[3]),p},Hr=function(f){Ne(f.x),Ne(f.y)},dr=yt("WGS84"),Je=6,_n="AJSAJS",Ho="AFAFAF",Oe=65,He=73,zi=79,cn=86,Ee=90,pi={forward:ne,inverse:function(f){var p=he(ci(f.toUpperCase()));return p.lat&&p.lon?[p.lon,p.lat,p.lon,p.lat]:[p.left,p.bottom,p.right,p.top]},toPoint:xi};qe.fromMGRS=function(f){return new qe(xi(f))},qe.prototype.toMGRS=function(f){return ne([this.x,this.y],f)};var et=.01068115234375,B=function(f){var p=[];p[0]=1-f*(.25+f*(.046875+f*(.01953125+f*et))),p[1]=f*(.75-f*(.046875+f*(.01953125+f*et)));var y=f*f;return p[2]=y*(.46875-f*(.013020833333333334+.007120768229166667*f)),y*=f,p[3]=y*(.3645833333333333-.005696614583333333*f),p[4]=y*f*.3076171875,p},Nt=function(f,p,y,b){return y*=p,p*=p,b[0]*f-y*(b[1]+p*(b[2]+p*(b[3]+p*b[4])))},oi=function(f,p,y){for(var b=1/(1-p),I=f,v=20;v;--v){var N=Math.sin(I),O=1-p*N*N;if(O=(Nt(I,N,Math.cos(I),y)-f)*(O*Math.sqrt(O))*b,I-=O,Math.abs(O)Ct?Math.tan(v):0,rt=Math.pow(wt,2),Mt=Math.pow(rt,2);p=1-this.es*Math.pow(O,2),W/=Math.sqrt(p);var T=Nt(v,O,G,this.en);y=this.a*(this.k0*W*(1+Q/6*(1-rt+it+Q/20*(5-18*rt+Mt+14*it-58*rt*it+Q/42*(61+179*Mt-Mt*rt-479*rt)))))+this.x0,b=this.a*(this.k0*(T-this.ml0+O*N*W/2*(1+Q/12*(5-rt+9*it+4*ct+Q/30*(61+Mt-58*rt+270*it-330*rt*it+Q/56*(1385+543*Mt-Mt*rt-3111*rt))))))+this.y0}else{var i=G*Math.sin(N);if(Math.abs(Math.abs(i)-1)=1){if(i-1>Ct)return 93;b=0}else b=Math.acos(b);v<0&&(b=-b),b=this.a*this.k0*(b-this.lat0)+this.y0}return f.x=y,f.y=b,f},inverse:function(f){var p,y,b,I,v=(f.x-this.x0)*(1/this.a),N=(f.y-this.y0)*(1/this.a);if(this.es)if(p=this.ml0+N/this.k0,y=oi(p,this.es,this.en),Math.abs(y)Ct?Math.tan(y):0,Q=this.ep2*Math.pow(G,2),it=Math.pow(Q,2),ct=Math.pow(W,2),wt=Math.pow(ct,2);p=1-this.es*Math.pow(O,2);var rt=v*Math.sqrt(p)/this.k0,Mt=Math.pow(rt,2);b=y-(p*=W)*Mt/(1-this.es)*.5*(1-Mt/12*(5+3*ct-9*Q*ct+Q-4*it-Mt/30*(61+90*ct-252*Q*ct+45*wt+46*Q-Mt/56*(1385+3633*ct+4095*wt+1574*wt*ct)))),I=Tt(this.long0+rt*(1-Mt/6*(1+2*ct+Q-Mt/20*(5+28*ct+24*wt+8*Q*ct+6*Q-Mt/42*(61+662*ct+1320*wt+720*wt*ct))))/G)}else b=ht*vi(N),I=0;else{var T=Math.exp(v/this.k0),i=.5*(T-1/T),s=this.lat0+N/this.k0,a=Math.cos(s);p=Math.sqrt((1-Math.pow(a,2))/(1+Math.pow(i,2))),b=Math.asin(p),N<0&&(b=-b),I=i===0&&a===0?0:Tt(Math.atan2(i,a)+this.long0)}return f.x=I,f.y=b,f},names:["Fast_Transverse_Mercator","Fast Transverse Mercator"]},jo=function(f){var p=Math.exp(f);return p=(p-1/p)/2},Oi=function(f,p){f=Math.abs(f),p=Math.abs(p);var y=Math.max(f,p),b=Math.min(f,p)/(y||1);return y*Math.sqrt(1+Math.pow(b,2))},Wi=function(f){var p=1+f,y=p-1;return y===0?f:f*Math.log(p)/y},Dt=function(f){var p=Math.abs(f);return p=Wi(p*(1+p/(Oi(1,p)+1))),f<0?-p:p},Pe=function(f,p){for(var y,b=2*Math.cos(2*p),I=f.length-1,v=f[I],N=0;--I>=0;)y=b*v-N+f[I],N=v,v=y;return p+y*Math.sin(2*p)},Zo=function(f,p){for(var y,b=2*Math.cos(p),I=f.length-1,v=f[I],N=0;--I>=0;)y=b*v-N+f[I],N=v,v=y;return Math.sin(p)*y},_l=function(f){var p=Math.exp(f);return p=(p+1/p)/2},gr=function(f,p,y){for(var b,I,v=Math.sin(p),N=Math.cos(p),O=jo(y),G=_l(y),W=2*N*G,Q=-2*v*O,it=f.length-1,ct=f[it],wt=0,rt=0,Mt=0;--it>=0;)b=rt,I=wt,ct=W*(rt=ct)-b-Q*(wt=Mt)+f[it],Mt=Q*rt-I+W*wt;return W=v*G,Q=N*O,[W*ct-Q*Mt,W*Mt+Q*ct]},Yn={init:function(){if(!this.approx&&(isNaN(this.es)||this.es<=0))throw new Error('Incorrect elliptical usage. Try using the +approx option in the proj string, or PROJECTION["Fast_Transverse_Mercator"] in the WKT.');this.approx&&(Ii.init.apply(this),this.forward=Ii.forward,this.inverse=Ii.inverse),this.x0=this.x0!==void 0?this.x0:0,this.y0=this.y0!==void 0?this.y0:0,this.long0=this.long0!==void 0?this.long0:0,this.lat0=this.lat0!==void 0?this.lat0:0,this.cgb=[],this.cbg=[],this.utg=[],this.gtu=[];var f=this.es/(1+Math.sqrt(1-this.es)),p=f/(2-f),y=p;this.cgb[0]=p*(2+p*(-2/3+p*(p*(116/45+p*(26/45+p*(-2854/675)))-2))),this.cbg[0]=p*(p*(2/3+p*(4/3+p*(-82/45+p*(32/45+p*(4642/4725)))))-2),y*=p,this.cgb[1]=y*(7/3+p*(p*(-227/45+p*(2704/315+p*(2323/945)))-1.6)),this.cbg[1]=y*(5/3+p*(-16/15+p*(-13/9+p*(904/315+p*(-1522/945))))),y*=p,this.cgb[2]=y*(56/15+p*(-136/35+p*(-1262/105+p*(73814/2835)))),this.cbg[2]=y*(-26/15+p*(34/21+p*(1.6+p*(-12686/2835)))),y*=p,this.cgb[3]=y*(4279/630+p*(-332/35+p*(-399572/14175))),this.cbg[3]=y*(1237/630+p*(p*(-24832/14175)-2.4)),y*=p,this.cgb[4]=y*(4174/315+p*(-144838/6237)),this.cbg[4]=y*(-734/315+p*(109598/31185)),y*=p,this.cgb[5]=y*(601676/22275),this.cbg[5]=y*(444337/155925),y=Math.pow(p,2),this.Qn=this.k0/(1+p)*(1+y*(.25+y*(1/64+y/256))),this.utg[0]=p*(p*(2/3+p*(-37/96+p*(1/360+p*(81/512+p*(-96199/604800)))))-.5),this.gtu[0]=p*(.5+p*(-2/3+p*(5/16+p*(41/180+p*(-127/288+p*(7891/37800)))))),this.utg[1]=y*(-1/48+p*(-1/15+p*(437/1440+p*(-46/105+p*(1118711/3870720))))),this.gtu[1]=y*(13/48+p*(p*(557/1440+p*(281/630+p*(-1983433/1935360)))-.6)),y*=p,this.utg[2]=y*(-17/480+p*(37/840+p*(209/4480+p*(-5569/90720)))),this.gtu[2]=y*(61/240+p*(-103/140+p*(15061/26880+p*(167603/181440)))),y*=p,this.utg[3]=y*(-4397/161280+p*(11/504+p*(830251/7257600))),this.gtu[3]=y*(49561/161280+p*(-179/168+p*(6601661/7257600))),y*=p,this.utg[4]=y*(-4583/161280+p*(108847/3991680)),this.gtu[4]=y*(34729/80640+p*(-3418889/1995840)),y*=p,this.utg[5]=-.03233083094085698*y,this.gtu[5]=.6650675310896665*y;var b=Pe(this.cbg,this.lat0);this.Zb=-this.Qn*(b+Zo(this.gtu,2*b))},forward:function(f){var p=Tt(f.x-this.long0),y=f.y;y=Pe(this.cbg,y);var b=Math.sin(y),I=Math.cos(y),v=Math.sin(p),N=Math.cos(p);y=Math.atan2(b,N*I),p=Math.atan2(v*I,Oi(b,I*N)),p=Dt(Math.tan(p));var O=gr(this.gtu,2*y,2*p);y+=O[0],p+=O[1];var G,W;return Math.abs(p)<=2.623395162778?(G=this.a*(this.Qn*p)+this.x0,W=this.a*(this.Qn*y+this.Zb)+this.y0):(G=1/0,W=1/0),f.x=G,f.y=W,f},inverse:function(f){var p=(f.x-this.x0)*(1/this.a),y=(f.y-this.y0)*(1/this.a);y=(y-this.Zb)/this.Qn,p/=this.Qn;var b,I;if(Math.abs(p)<=2.623395162778){var v=gr(this.utg,2*y,2*p);y+=v[0],p+=v[1],p=Math.atan(jo(p));var N=Math.sin(y),O=Math.cos(y),G=Math.sin(p),W=Math.cos(p);y=Math.atan2(N*W,Oi(G,W*O)),p=Math.atan2(G,W*O),b=Tt(p+this.long0),I=Pe(this.cgb,y)}else b=1/0,I=1/0;return f.x=b,f.y=I,f},names:["Extended_Transverse_Mercator","Extended Transverse Mercator","etmerc","Transverse_Mercator","Transverse Mercator","Gauss Kruger","Gauss_Kruger","tmerc"]},jr=function(f,p){if(f===void 0){if((f=Math.floor(30*(Tt(p)+Math.PI)/Math.PI)+1)<0)return 0;if(f>60)return 60}return f},pl={init:function(){var f=jr(this.zone,this.long0);if(f===void 0)throw new Error("unknown utm zone");this.lat0=0,this.long0=(6*Math.abs(f)-183)*fe,this.x0=5e5,this.y0=this.utmSouth?1e7:0,this.k0=.9996,Yn.init.apply(this),this.forward=Yn.forward,this.inverse=Yn.inverse},names:["Universal Transverse Mercator System","utm"],dependsOn:"etmerc"},Qe=function(f,p){return Math.pow((1-f)/(1+f),p)},Gs=20,un={init:function(){var f=Math.sin(this.lat0),p=Math.cos(this.lat0);p*=p,this.rc=Math.sqrt(1-this.es)/(1-this.es*f*f),this.C=Math.sqrt(1+this.es*p*p/(1-this.es)),this.phic0=Math.asin(f/this.C),this.ratexp=.5*this.C*this.e,this.K=Math.tan(.5*this.phic0+Wt)/(Math.pow(Math.tan(.5*this.lat0+Wt),this.C)*Qe(this.e*f,this.ratexp))},forward:function(f){var p=f.x,y=f.y;return f.y=2*Math.atan(this.K*Math.pow(Math.tan(.5*y+Wt),this.C)*Qe(this.e*Math.sin(y),this.ratexp))-ht,f.x=this.C*p,f},inverse:function(f){for(var p=f.x/this.C,y=f.y,b=Math.pow(Math.tan(.5*y+Wt)/this.K,1/this.C),I=Gs;I>0&&(y=2*Math.atan(b*Qe(this.e*Math.sin(f.y),-.5*this.e))-ht,!(Math.abs(y-f.y)<1e-14));--I)f.y=y;return I?(f.x=p,f.y=y,f):null},names:["gauss"]},Ut={init:function(){un.init.apply(this),this.rc&&(this.sinc0=Math.sin(this.phic0),this.cosc0=Math.cos(this.phic0),this.R2=2*this.rc,this.title||(this.title="Oblique Stereographic Alternative"))},forward:function(f){var p,y,b,I;return f.x=Tt(f.x-this.long0),un.forward.apply(this,[f]),p=Math.sin(f.y),y=Math.cos(f.y),b=Math.cos(f.x),I=this.k0*this.R2/(1+this.sinc0*p+this.cosc0*y*b),f.x=I*y*Math.sin(f.x),f.y=I*(this.cosc0*p-this.sinc0*y*b),f.x=this.a*f.x+this.x0,f.y=this.a*f.y+this.y0,f},inverse:function(f){var p,y,b,I,v;if(f.x=(f.x-this.x0)/this.a,f.y=(f.y-this.y0)/this.a,f.x/=this.k0,f.y/=this.k0,v=Oi(f.x,f.y)){var N=2*Math.atan2(v,this.R2);p=Math.sin(N),y=Math.cos(N),I=Math.asin(y*this.sinc0+f.y*p*this.cosc0/v),b=Math.atan2(f.x*p,v*this.cosc0*y-f.y*this.sinc0*p)}else I=this.phic0,b=0;return f.x=b,f.y=I,un.inverse.apply(this,[f]),f.x=Tt(f.x+this.long0),f},names:["Stereographic_North_Pole","Oblique_Stereographic","sterea","Oblique Stereographic Alternative","Double_Stereographic"]},yl={init:function(){this.x0=this.x0||0,this.y0=this.y0||0,this.lat0=this.lat0||0,this.long0=this.long0||0,this.coslat0=Math.cos(this.lat0),this.sinlat0=Math.sin(this.lat0),this.sphere?this.k0===1&&!isNaN(this.lat_ts)&&Math.abs(this.coslat0)<=Ct&&(this.k0=.5*(1+vi(this.lat0)*Math.sin(this.lat_ts))):(Math.abs(this.coslat0)<=Ct&&(this.lat0>0?this.con=1:this.con=-1),this.cons=Math.sqrt(Math.pow(1+this.e,1+this.e)*Math.pow(1-this.e,1-this.e)),this.k0===1&&!isNaN(this.lat_ts)&&Math.abs(this.coslat0)<=Ct&&Math.abs(Math.cos(this.lat_ts))>Ct&&(this.k0=.5*this.cons*hn(this.e,Math.sin(this.lat_ts),Math.cos(this.lat_ts))/ae(this.e,this.con*this.lat_ts,this.con*Math.sin(this.lat_ts))),this.ms1=hn(this.e,this.sinlat0,this.coslat0),this.X0=2*Math.atan(this.ssfn_(this.lat0,this.sinlat0,this.e))-ht,this.cosX0=Math.cos(this.X0),this.sinX0=Math.sin(this.X0))},forward:function(f){var p,y,b,I,v,N,O=f.x,G=f.y,W=Math.sin(G),Q=Math.cos(G),it=Tt(O-this.long0);return Math.abs(Math.abs(O-this.long0)-Math.PI)<=Ct&&Math.abs(G+this.lat0)<=Ct?(f.x=NaN,f.y=NaN,f):this.sphere?(p=2*this.k0/(1+this.sinlat0*W+this.coslat0*Q*Math.cos(it)),f.x=this.a*p*Q*Math.sin(it)+this.x0,f.y=this.a*p*(this.coslat0*W-this.sinlat0*Q*Math.cos(it))+this.y0,f):(y=2*Math.atan(this.ssfn_(G,W,this.e))-ht,I=Math.cos(y),b=Math.sin(y),Math.abs(this.coslat0)<=Ct?(v=ae(this.e,G*this.con,this.con*W),N=2*this.a*this.k0*v/this.cons,f.x=this.x0+N*Math.sin(O-this.long0),f.y=this.y0-this.con*N*Math.cos(O-this.long0),f):(Math.abs(this.sinlat0)0?this.long0+Math.atan2(f.x,-1*f.y):this.long0+Math.atan2(f.x,f.y):this.long0+Math.atan2(f.x*Math.sin(O),N*this.coslat0*Math.cos(O)-f.y*this.sinlat0*Math.sin(O))),f.x=p,f.y=y,f)}if(Math.abs(this.coslat0)<=Ct){if(N<=Ct)return y=this.lat0,p=this.long0,f.x=p,f.y=y,f;f.x*=this.con,f.y*=this.con,b=N*this.cons/(2*this.a*this.k0),y=this.con*ms(this.e,b),p=this.con*Tt(this.con*this.long0+Math.atan2(f.x,-1*f.y))}else I=2*Math.atan(N*this.cosX0/(2*this.a*this.k0*this.ms1)),p=this.long0,N<=Ct?v=this.X0:(v=Math.asin(Math.cos(I)*this.sinX0+f.y*Math.sin(I)*this.cosX0/N),p=Tt(this.long0+Math.atan2(f.x*Math.sin(I),N*this.cosX0*Math.cos(I)-f.y*this.sinX0*Math.sin(I)))),y=-1*ms(this.e,Math.tan(.5*(ht+v)));return f.x=p,f.y=y,f},names:["stere","Stereographic_South_Pole","Polar Stereographic (variant B)","Polar_Stereographic"],ssfn_:function(f,p,y){return p*=y,Math.tan(.5*(ht+f))*Math.pow((1-p)/(1+p),.5*y)}},Zt={init:function(){var f=this.lat0;this.lambda0=this.long0;var p=Math.sin(f),y=this.a,b=1/this.rf,I=2*b-Math.pow(b,2),v=this.e=Math.sqrt(I);this.R=this.k0*y*Math.sqrt(1-I)/(1-I*Math.pow(p,2)),this.alpha=Math.sqrt(1+I/(1-I)*Math.pow(Math.cos(f),4)),this.b0=Math.asin(p/this.alpha);var N=Math.log(Math.tan(Math.PI/4+this.b0/2)),O=Math.log(Math.tan(Math.PI/4+f/2)),G=Math.log((1+v*p)/(1-v*p));this.K=N-this.alpha*O+this.alpha*v/2*G},forward:function(f){var p=Math.log(Math.tan(Math.PI/4-f.y/2)),y=this.e/2*Math.log((1+this.e*Math.sin(f.y))/(1-this.e*Math.sin(f.y))),b=-this.alpha*(p+y)+this.K,I=2*(Math.atan(Math.exp(b))-Math.PI/4),v=this.alpha*(f.x-this.lambda0),N=Math.atan(Math.sin(v)/(Math.sin(this.b0)*Math.tan(I)+Math.cos(this.b0)*Math.cos(v))),O=Math.asin(Math.cos(this.b0)*Math.sin(I)-Math.sin(this.b0)*Math.cos(I)*Math.cos(v));return f.y=this.R/2*Math.log((1+Math.sin(O))/(1-Math.sin(O)))+this.y0,f.x=this.R*N+this.x0,f},inverse:function(f){for(var p=f.x-this.x0,y=f.y-this.y0,b=p/this.R,I=2*(Math.atan(Math.exp(y/this.R))-Math.PI/4),v=Math.asin(Math.cos(this.b0)*Math.sin(I)+Math.sin(this.b0)*Math.cos(I)*Math.cos(b)),N=Math.atan(Math.sin(b)/(Math.cos(this.b0)*Math.cos(b)-Math.sin(this.b0)*Math.tan(I))),O=this.lambda0+N/this.alpha,G=0,W=v,Q=-1e3,it=0;Math.abs(W-Q)>1e-7;){if(++it>20)return;G=1/this.alpha*(Math.log(Math.tan(Math.PI/4+v/2))-this.K)+this.e*Math.log(Math.tan(Math.PI/4+Math.asin(this.e*Math.sin(W))/2)),Q=W,W=2*Math.atan(Math.exp(G))-Math.PI/2}return f.x=O,f.y=W,f},names:["somerc"]},We=1e-7,wl={init:function(){var f,p,y,b,I,v,N,O,G,W,Q,it=0,ct=0,wt=0,rt=0,Mt=0,T=0,i=0;this.no_off=ce(this),this.no_rot="no_rot"in this;var s=!1;"alpha"in this&&(s=!0);var a=!1;if("rectified_grid_angle"in this&&(a=!0),s&&(i=this.alpha),a&&(it=this.rectified_grid_angle*fe),s||a)ct=this.longc;else if(wt=this.long1,Mt=this.lat1,rt=this.long2,T=this.lat2,Math.abs(Mt-T)<=We||(f=Math.abs(Mt))<=We||Math.abs(f-ht)<=We||Math.abs(Math.abs(this.lat0)-ht)<=We||Math.abs(Math.abs(T)-ht)<=We)throw new Error;var h=1-this.es;p=Math.sqrt(h),Math.abs(this.lat0)>Ct?(O=Math.sin(this.lat0),y=Math.cos(this.lat0),f=1-this.es*O*O,this.B=y*y,this.B=Math.sqrt(1+this.es*this.B*this.B/h),this.A=this.B*this.k0*p/f,(I=(b=this.B*p/(y*Math.sqrt(f)))*b-1)<=0?I=0:(I=Math.sqrt(I),this.lat0<0&&(I=-I)),this.E=I+=b,this.E*=Math.pow(ae(this.e,this.lat0,O),this.B)):(this.B=1/p,this.A=this.k0,this.E=b=I=1),s||a?(s?(Q=Math.asin(Math.sin(i)/b),a||(it=i)):(Q=it,i=Math.asin(b*Math.sin(Q))),this.lam0=ct-Math.asin(.5*(I-1/I)*Math.tan(Q))/this.B):(v=Math.pow(ae(this.e,Mt,Math.sin(Mt)),this.B),N=Math.pow(ae(this.e,T,Math.sin(T)),this.B),I=this.E/v,G=(N-v)/(N+v),W=((W=this.E*this.E)-N*v)/(W+N*v),(f=wt-rt)<-Math.pi?rt-=si:f>Math.pi&&(rt+=si),this.lam0=Tt(.5*(wt+rt)-Math.atan(W*Math.tan(.5*this.B*(wt-rt))/G)/this.B),Q=Math.atan(2*Math.sin(this.B*Tt(wt-this.lam0))/(I-1/I)),it=i=Math.asin(b*Math.sin(Q))),this.singam=Math.sin(Q),this.cosgam=Math.cos(Q),this.sinrot=Math.sin(it),this.cosrot=Math.cos(it),this.rB=1/this.B,this.ArB=this.A*this.rB,this.BrA=1/this.ArB,this.no_off?this.u_0=0:(this.u_0=Math.abs(this.ArB*Math.atan(Math.sqrt(b*b-1)/Math.cos(i))),this.lat0<0&&(this.u_0=-this.u_0)),I=.5*Q,this.v_pole_n=this.ArB*Math.log(Math.tan(Wt-I)),this.v_pole_s=this.ArB*Math.log(Math.tan(Wt+I))},forward:function(f){var p,y,b,I,v,N,O,G,W={};if(f.x=f.x-this.lam0,Math.abs(Math.abs(f.y)-ht)>Ct){if(v=this.E/Math.pow(ae(this.e,f.y,Math.sin(f.y)),this.B),N=1/v,p=.5*(v-N),y=.5*(v+N),I=Math.sin(this.B*f.x),b=(p*this.singam-I*this.cosgam)/y,Math.abs(Math.abs(b)-1)0?this.v_pole_n:this.v_pole_s,O=this.ArB*f.y;return this.no_rot?(W.x=O,W.y=G):(O-=this.u_0,W.x=G*this.cosrot+O*this.sinrot,W.y=O*this.cosrot-G*this.sinrot),W.x=this.a*W.x+this.x0,W.y=this.a*W.y+this.y0,W},inverse:function(f){var p,y,b,I,v,N,O,G={};if(f.x=(f.x-this.x0)*(1/this.a),f.y=(f.y-this.y0)*(1/this.a),this.no_rot?(y=f.y,p=f.x):(y=f.x*this.cosrot-f.y*this.sinrot,p=f.y*this.cosrot+f.x*this.sinrot+this.u_0),b=Math.exp(-this.BrA*y),I=.5*(b-1/b),v=.5*(b+1/b),N=Math.sin(this.BrA*p),O=(N*this.cosgam+I*this.singam)/v,Math.abs(Math.abs(O)-1)Ct?this.ns=Math.log(b/O)/Math.log(I/G):this.ns=p,isNaN(this.ns)&&(this.ns=p),this.f0=b/(this.ns*Math.pow(I,this.ns)),this.rh=this.a*this.f0*Math.pow(W,this.ns),this.title||(this.title="Lambert Conformal Conic")}},forward:function(f){var p=f.x,y=f.y;Math.abs(2*Math.abs(y)-Math.PI)<=Ct&&(y=vi(y)*(ht-2*Ct));var b,I,v=Math.abs(Math.abs(y)-ht);if(v>Ct)b=ae(this.e,y,Math.sin(y)),I=this.a*this.f0*Math.pow(b,this.ns);else{if((v=y*this.ns)<=0)return null;I=0}var N=this.ns*Tt(p-this.long0);return f.x=this.k0*(I*Math.sin(N))+this.x0,f.y=this.k0*(this.rh-I*Math.cos(N))+this.y0,f},inverse:function(f){var p,y,b,I,v,N=(f.x-this.x0)/this.k0,O=this.rh-(f.y-this.y0)/this.k0;this.ns>0?(p=Math.sqrt(N*N+O*O),y=1):(p=-Math.sqrt(N*N+O*O),y=-1);var G=0;if(p!==0&&(G=Math.atan2(y*N,y*O)),p!==0||this.ns>0){if(y=1/this.ns,b=Math.pow(p/(this.a*this.f0),y),(I=ms(this.e,b))===-9999)return null}else I=-ht;return v=Tt(G/this.ns+this.long0),f.x=v,f.y=I,f},names:["Lambert Tangential Conformal Conic Projection","Lambert_Conformal_Conic","Lambert_Conformal_Conic_1SP","Lambert_Conformal_Conic_2SP","lcc","Lambert Conic Conformal (1SP)","Lambert Conic Conformal (2SP)"]},Ko={init:function(){this.a=6377397155e-3,this.es=.006674372230614,this.e=Math.sqrt(this.es),this.lat0||(this.lat0=.863937979737193),this.long0||(this.long0=.4334234309119251),this.k0||(this.k0=.9999),this.s45=.785398163397448,this.s90=2*this.s45,this.fi0=this.lat0,this.e2=this.es,this.e=Math.sqrt(this.e2),this.alfa=Math.sqrt(1+this.e2*Math.pow(Math.cos(this.fi0),4)/(1-this.e2)),this.uq=1.04216856380474,this.u0=Math.asin(Math.sin(this.fi0)/this.alfa),this.g=Math.pow((1+this.e*Math.sin(this.fi0))/(1-this.e*Math.sin(this.fi0)),this.alfa*this.e/2),this.k=Math.tan(this.u0/2+this.s45)/Math.pow(Math.tan(this.fi0/2+this.s45),this.alfa)*this.g,this.k1=this.k0,this.n0=this.a*Math.sqrt(1-this.e2)/(1-this.e2*Math.pow(Math.sin(this.fi0),2)),this.s0=1.37008346281555,this.n=Math.sin(this.s0),this.ro0=this.k1*this.n0/Math.tan(this.s0),this.ad=this.s90-this.uq},forward:function(f){var p,y,b,I,v,N,O,G=f.x,W=f.y,Q=Tt(G-this.long0);return p=Math.pow((1+this.e*Math.sin(W))/(1-this.e*Math.sin(W)),this.alfa*this.e/2),y=2*(Math.atan(this.k*Math.pow(Math.tan(W/2+this.s45),this.alfa)/p)-this.s45),b=-Q*this.alfa,I=Math.asin(Math.cos(this.ad)*Math.sin(y)+Math.sin(this.ad)*Math.cos(y)*Math.cos(b)),v=Math.asin(Math.cos(y)*Math.sin(b)/Math.cos(I)),N=this.n*v,O=this.ro0*Math.pow(Math.tan(this.s0/2+this.s45),this.n)/Math.pow(Math.tan(I/2+this.s45),this.n),f.y=O*Math.cos(N)/1,f.x=O*Math.sin(N)/1,this.czech||(f.y*=-1,f.x*=-1),f},inverse:function(f){var p,y,b,I,v,N,O,G=f.x;f.x=f.y,f.y=G,this.czech||(f.y*=-1,f.x*=-1),v=Math.sqrt(f.x*f.x+f.y*f.y),I=Math.atan2(f.y,f.x)/Math.sin(this.s0),b=2*(Math.atan(Math.pow(this.ro0/v,1/this.n)*Math.tan(this.s0/2+this.s45))-this.s45),p=Math.asin(Math.cos(this.ad)*Math.sin(b)-Math.sin(this.ad)*Math.cos(b)*Math.cos(I)),y=Math.asin(Math.cos(b)*Math.sin(I)/Math.cos(p)),f.x=this.long0-y/this.alfa,N=p,O=0;var W=0;do f.y=2*(Math.atan(Math.pow(this.k,-1/this.alfa)*Math.pow(Math.tan(p/2+this.s45),1/this.alfa)*Math.pow((1+this.e*Math.sin(N))/(1-this.e*Math.sin(N)),this.e/2))-this.s45),Math.abs(N-f.y)<1e-10&&(O=1),N=f.y,W+=1;while(O===0&&W<15);return W>=15?null:f},names:["Krovak","krovak"]},je=function(f,p,y,b,I){return f*I-p*Math.sin(2*I)+y*Math.sin(4*I)-b*Math.sin(6*I)},Us=function(f){return 1-.25*f*(1+f/16*(3+1.25*f))},pn=function(f){return .375*f*(1+.25*f*(1+.46875*f))},yn=function(f){return .05859375*f*f*(1+.75*f)},wn=function(f){return f*f*f*(35/3072)},Hn=function(f,p,y){var b=p*y;return f/Math.sqrt(1-b*b)},fn=function(f){return Math.abs(f)1e-7?(y=f*p,(1-f*f)*(p/(1-y*y)-.5/f*Math.log((1-y)/(1+y)))):2*p},qo=.3333333333333333,Jo=.17222222222222222,El=.10257936507936508,Cl=.06388888888888888,Al=.0664021164021164,Ie=.016415012942191543,Qo={init:function(){var f=Math.abs(this.lat0);if(Math.abs(f-ht)0){var p;switch(this.qp=En(this.e,1),this.mmf=.5/(1-this.es),this.apa=cr(this.es),this.mode){case this.N_POLE:case this.S_POLE:this.dd=1;break;case this.EQUIT:this.rq=Math.sqrt(.5*this.qp),this.dd=1/this.rq,this.xmf=1,this.ymf=.5*this.qp;break;case this.OBLIQ:this.rq=Math.sqrt(.5*this.qp),p=Math.sin(this.lat0),this.sinb1=En(this.e,p)/this.qp,this.cosb1=Math.sqrt(1-this.sinb1*this.sinb1),this.dd=Math.cos(this.lat0)/(Math.sqrt(1-this.es*p*p)*this.rq*this.cosb1),this.ymf=(this.xmf=this.rq)/this.dd,this.xmf*=this.dd}}else this.mode===this.OBLIQ&&(this.sinph0=Math.sin(this.lat0),this.cosph0=Math.cos(this.lat0))},forward:function(f){var p,y,b,I,v,N,O,G,W,Q,it=f.x,ct=f.y;if(it=Tt(it-this.long0),this.sphere){if(v=Math.sin(ct),Q=Math.cos(ct),b=Math.cos(it),this.mode===this.OBLIQ||this.mode===this.EQUIT){if((y=this.mode===this.EQUIT?1+Q*b:1+this.sinph0*v+this.cosph0*Q*b)<=Ct)return null;p=(y=Math.sqrt(2/y))*Q*Math.sin(it),y*=this.mode===this.EQUIT?v:this.cosph0*v-this.sinph0*Q*b}else if(this.mode===this.N_POLE||this.mode===this.S_POLE){if(this.mode===this.N_POLE&&(b=-b),Math.abs(ct+this.lat0)=0?(p=(W=Math.sqrt(N))*I,y=b*(this.mode===this.S_POLE?W:-W)):p=y=0}}return f.x=this.a*p+this.x0,f.y=this.a*y+this.y0,f},inverse:function(f){f.x-=this.x0,f.y-=this.y0;var p,y,b,I,v,N,O,G=f.x/this.a,W=f.y/this.a;if(this.sphere){var Q,it=0,ct=0;if(Q=Math.sqrt(G*G+W*W),(y=.5*Q)>1)return null;switch(y=2*Math.asin(y),this.mode!==this.OBLIQ&&this.mode!==this.EQUIT||(ct=Math.sin(y),it=Math.cos(y)),this.mode){case this.EQUIT:y=Math.abs(Q)<=Ct?0:Math.asin(W*ct/Q),G*=ct,W=it*Q;break;case this.OBLIQ:y=Math.abs(Q)<=Ct?this.lat0:Math.asin(it*this.sinph0+W*ct*this.cosph0/Q),G*=ct*this.cosph0,W=(it-Math.sin(y)*this.sinph0)*Q;break;case this.N_POLE:W=-W,y=ht-y;break;case this.S_POLE:y-=ht}p=W!==0||this.mode!==this.EQUIT&&this.mode!==this.OBLIQ?Math.atan2(G,W):0}else{if(O=0,this.mode===this.OBLIQ||this.mode===this.EQUIT){if(G/=this.dd,W*=this.dd,(N=Math.sqrt(G*G+W*W))1&&(f=f>1?1:-1),Math.asin(f)},Dn={init:function(){Math.abs(this.lat1+this.lat2)Ct?this.ns0=(this.ms1*this.ms1-this.ms2*this.ms2)/(this.qs2-this.qs1):this.ns0=this.con,this.c=this.ms1*this.ms1+this.ns0*this.qs1,this.rh=this.a*Math.sqrt(this.c-this.ns0*this.qs0)/this.ns0)},forward:function(f){var p=f.x,y=f.y;this.sin_phi=Math.sin(y),this.cos_phi=Math.cos(y);var b=En(this.e3,this.sin_phi),I=this.a*Math.sqrt(this.c-this.ns0*b)/this.ns0,v=this.ns0*Tt(p-this.long0),N=I*Math.sin(v)+this.x0,O=this.rh-I*Math.cos(v)+this.y0;return f.x=N,f.y=O,f},inverse:function(f){var p,y,b,I,v,N;return f.x-=this.x0,f.y=this.rh-f.y+this.y0,this.ns0>=0?(p=Math.sqrt(f.x*f.x+f.y*f.y),b=1):(p=-Math.sqrt(f.x*f.x+f.y*f.y),b=-1),I=0,p!==0&&(I=Math.atan2(b*f.x,b*f.y)),b=p*this.ns0/this.a,this.sphere?N=Math.asin((this.c-b*b)/(2*this.ns0)):(y=(this.c-b*b)/this.ns0,N=this.phi1z(this.e3,y)),v=Tt(I/this.ns0+this.long0),f.x=v,f.y=N,f},names:["Albers_Conic_Equal_Area","Albers","aea"],phi1z:function(f,p){var y,b,I,v,N,O=Ji(.5*p);if(f0||Math.abs(v)<=Ct?(N=this.x0+1*this.a*y*Math.sin(b)/v,O=this.y0+1*this.a*(this.cos_p14*p-this.sin_p14*y*I)/v):(N=this.x0+this.infinity_dist*y*Math.sin(b),O=this.y0+this.infinity_dist*(this.cos_p14*p-this.sin_p14*y*I)),f.x=N,f.y=O,f},inverse:function(f){var p,y,b,I,v,N;return f.x=(f.x-this.x0)/this.a,f.y=(f.y-this.y0)/this.a,f.x/=this.k0,f.y/=this.k0,(p=Math.sqrt(f.x*f.x+f.y*f.y))?(I=Math.atan2(p,this.rc),y=Math.sin(I),b=Math.cos(I),N=Ji(b*this.sin_p14+f.y*y*this.cos_p14/p),v=Math.atan2(f.x*y,p*this.cos_p14*b-f.y*this.sin_p14*y),v=Tt(this.long0+v)):(N=this.phic0,v=0),f.x=v,f.y=N,f},names:["gnom"]},nt=function(f,p){var y=1-(1-f*f)/(2*f)*Math.log((1-f)/(1+f));if(Math.abs(Math.abs(p)-y)<1e-6)return p<0?-1*ht:ht;for(var b,I,v,N,O=Math.asin(.5*p),G=0;G<30;G++)if(I=Math.sin(O),v=Math.cos(O),N=f*I,b=Math.pow(1-N*N,2)/(2*v)*(p/(1-f*f)-I/(1-N*N)+.5/f*Math.log((1-N)/(1+N))),O+=b,Math.abs(b)<=1e-10)return O;return NaN},qt={init:function(){this.sphere||(this.k0=hn(this.e,Math.sin(this.lat_ts),Math.cos(this.lat_ts)))},forward:function(f){var p,y,b=f.x,I=f.y,v=Tt(b-this.long0);if(this.sphere)p=this.x0+this.a*v*Math.cos(this.lat_ts),y=this.y0+this.a*Math.sin(I)/Math.cos(this.lat_ts);else{var N=En(this.e,Math.sin(I));p=this.x0+this.a*this.k0*v,y=this.y0+this.a*N*.5/this.k0}return f.x=p,f.y=y,f},inverse:function(f){f.x-=this.x0,f.y-=this.y0;var p,y;return this.sphere?(p=Tt(this.long0+f.x/this.a/Math.cos(this.lat_ts)),y=Math.asin(f.y/this.a*Math.cos(this.lat_ts))):(y=nt(this.e,2*f.y*this.k0/this.a),p=Tt(this.long0+f.x/(this.a*this.k0))),f.x=p,f.y=y,f},names:["cea"]},fi={init:function(){this.x0=this.x0||0,this.y0=this.y0||0,this.lat0=this.lat0||0,this.long0=this.long0||0,this.lat_ts=this.lat_ts||0,this.title=this.title||"Equidistant Cylindrical (Plate Carre)",this.rc=Math.cos(this.lat_ts)},forward:function(f){var p=f.x,y=f.y,b=Tt(p-this.long0),I=fn(y-this.lat0);return f.x=this.x0+this.a*b*this.rc,f.y=this.y0+this.a*I,f},inverse:function(f){var p=f.x,y=f.y;return f.x=Tt(this.long0+(p-this.x0)/(this.a*this.rc)),f.y=fn(this.lat0+(y-this.y0)/this.a),f},names:["Equirectangular","Equidistant_Cylindrical","eqc"]},zs=20,$o={init:function(){this.temp=this.b/this.a,this.es=1-Math.pow(this.temp,2),this.e=Math.sqrt(this.es),this.e0=Us(this.es),this.e1=pn(this.es),this.e2=yn(this.es),this.e3=wn(this.es),this.ml0=this.a*je(this.e0,this.e1,this.e2,this.e3,this.lat0)},forward:function(f){var p,y,b,I=f.x,v=f.y,N=Tt(I-this.long0);if(b=N*Math.sin(v),this.sphere)Math.abs(v)<=Ct?(p=this.a*N,y=-1*this.a*this.lat0):(p=this.a*Math.sin(b)/Math.tan(v),y=this.a*(fn(v-this.lat0)+(1-Math.cos(b))/Math.tan(v)));else if(Math.abs(v)<=Ct)p=this.a*N,y=-1*this.ml0;else{var O=Hn(this.a,this.e,Math.sin(v))/Math.tan(v);p=O*Math.sin(b),y=this.a*je(this.e0,this.e1,this.e2,this.e3,v)-this.ml0+O*(1-Math.cos(b))}return f.x=p+this.x0,f.y=y+this.y0,f},inverse:function(f){var p,y,b,I,v,N,O,G,W;if(b=f.x-this.x0,I=f.y-this.y0,this.sphere)if(Math.abs(I+this.a*this.lat0)<=Ct)p=Tt(b/this.a+this.long0),y=0;else{N=this.lat0+I/this.a,O=b*b/this.a/this.a+N*N,G=N;var Q;for(v=zs;v;--v)if(Q=Math.tan(G),W=-1*(N*(G*Q+1)-G-.5*(G*G+O)*Q)/((G-N)/Q-1),G+=W,Math.abs(W)<=Ct){y=G;break}p=Tt(this.long0+Math.asin(b*Math.tan(G)/this.a)/Math.sin(y))}else if(Math.abs(I+this.ml0)<=Ct)y=0,p=Tt(this.long0+b/this.a);else{N=(this.ml0+I)/this.a,O=b*b/this.a/this.a+N*N,G=N;var it,ct,wt,rt,Mt;for(v=zs;v;--v)if(Mt=this.e*Math.sin(G),it=Math.sqrt(1-Mt*Mt)*Math.tan(G),ct=this.a*je(this.e0,this.e1,this.e2,this.e3,G),wt=this.e0-2*this.e1*Math.cos(2*G)+4*this.e2*Math.cos(4*G)-6*this.e3*Math.cos(6*G),rt=ct/this.a,W=(N*(it*rt+1)-rt-.5*it*(rt*rt+O))/(this.es*Math.sin(2*G)*(rt*rt+O-2*N*rt)/(4*it)+(N-rt)*(it*wt-2/Math.sin(2*G))-wt),G-=W,Math.abs(W)<=Ct){y=G;break}it=Math.sqrt(1-this.es*Math.pow(Math.sin(y),2))*Math.tan(y),p=Tt(this.long0+Math.asin(b*it/this.a)/Math.sin(y))}return f.x=p,f.y=y,f},names:["Polyconic","poly"]},Ml={init:function(){this.A=[],this.A[1]=.6399175073,this.A[2]=-.1358797613,this.A[3]=.063294409,this.A[4]=-.02526853,this.A[5]=.0117879,this.A[6]=-.0055161,this.A[7]=.0026906,this.A[8]=-.001333,this.A[9]=67e-5,this.A[10]=-34e-5,this.B_re=[],this.B_im=[],this.B_re[1]=.7557853228,this.B_im[1]=0,this.B_re[2]=.249204646,this.B_im[2]=.003371507,this.B_re[3]=-.001541739,this.B_im[3]=.04105856,this.B_re[4]=-.10162907,this.B_im[4]=.01727609,this.B_re[5]=-.26623489,this.B_im[5]=-.36249218,this.B_re[6]=-.6870983,this.B_im[6]=-1.1651967,this.C_re=[],this.C_im=[],this.C_re[1]=1.3231270439,this.C_im[1]=0,this.C_re[2]=-.577245789,this.C_im[2]=-.007809598,this.C_re[3]=.508307513,this.C_im[3]=-.112208952,this.C_re[4]=-.15094762,this.C_im[4]=.18200602,this.C_re[5]=1.01418179,this.C_im[5]=1.64497696,this.C_re[6]=1.9660549,this.C_im[6]=2.5127645,this.D=[],this.D[1]=1.5627014243,this.D[2]=.5185406398,this.D[3]=-.03333098,this.D[4]=-.1052906,this.D[5]=-.0368594,this.D[6]=.007317,this.D[7]=.0122,this.D[8]=.00394,this.D[9]=-.0013},forward:function(f){var p,y=f.x,b=f.y-this.lat0,I=y-this.long0,v=b/an*1e-5,N=I,O=1,G=0;for(p=1;p<=10;p++)O*=v,G+=this.A[p]*O;var W,Q=G,it=N,ct=1,wt=0,rt=0,Mt=0;for(p=1;p<=6;p++)W=wt*Q+ct*it,ct=ct*Q-wt*it,wt=W,rt=rt+this.B_re[p]*ct-this.B_im[p]*wt,Mt=Mt+this.B_im[p]*ct+this.B_re[p]*wt;return f.x=Mt*this.a+this.x0,f.y=rt*this.a+this.y0,f},inverse:function(f){var p,y,b=f.x,I=f.y,v=b-this.x0,N=(I-this.y0)/this.a,O=v/this.a,G=1,W=0,Q=0,it=0;for(p=1;p<=6;p++)y=W*N+G*O,G=G*N-W*O,W=y,Q=Q+this.C_re[p]*G-this.C_im[p]*W,it=it+this.C_im[p]*G+this.C_re[p]*W;for(var ct=0;ct.999999999999&&(y=.999999999999),p=Math.asin(y);var b=Tt(this.long0+f.x/(.900316316158*this.a*Math.cos(p)));b<-Math.PI&&(b=-Math.PI),b>Math.PI&&(b=Math.PI),y=(2*p+Math.sin(2*p))/Math.PI,Math.abs(y)>1&&(y=1);var I=Math.asin(y);return f.x=b,f.y=I,f},names:["Mollweide","moll"]},qr={init:function(){Math.abs(this.lat1+this.lat2)=0?(y=Math.sqrt(f.x*f.x+f.y*f.y),p=1):(y=-Math.sqrt(f.x*f.x+f.y*f.y),p=-1);var v=0;if(y!==0&&(v=Math.atan2(p*f.x,p*f.y)),this.sphere)return I=Tt(this.long0+v/this.ns),b=fn(this.g-y/this.a),f.x=I,f.y=b,f;var N=this.g-y/this.a;return b=Pn(N,this.e0,this.e1,this.e2,this.e3),I=Tt(this.long0+v/this.ns),f.x=I,f.y=b,f},names:["Equidistant_Conic","eqdc"]},Xe={init:function(){this.R=this.a},forward:function(f){var p,y,b=f.x,I=f.y,v=Tt(b-this.long0);Math.abs(I)<=Ct&&(p=this.x0+this.R*v,y=this.y0);var N=Ji(2*Math.abs(I/Math.PI));(Math.abs(v)<=Ct||Math.abs(Math.abs(I)-ht)<=Ct)&&(p=this.x0,y=I>=0?this.y0+Math.PI*this.R*Math.tan(.5*N):this.y0+Math.PI*this.R*-Math.tan(.5*N));var O=.5*Math.abs(Math.PI/v-v/Math.PI),G=O*O,W=Math.sin(N),Q=Math.cos(N),it=Q/(W+Q-1),ct=it*it,wt=it*(2/W-1),rt=wt*wt,Mt=Math.PI*this.R*(O*(it-rt)+Math.sqrt(G*(it-rt)*(it-rt)-(rt+G)*(ct-rt)))/(rt+G);v<0&&(Mt=-Mt),p=this.x0+Mt;var T=G+it;return Mt=Math.PI*this.R*(wt*T-O*Math.sqrt((rt+G)*(G+1)-T*T))/(rt+G),y=I>=0?this.y0+Mt:this.y0-Mt,f.x=p,f.y=y,f},inverse:function(f){var p,y,b,I,v,N,O,G,W,Q,it,ct,wt;return f.x-=this.x0,f.y-=this.y0,it=Math.PI*this.R,b=f.x/it,I=f.y/it,v=b*b+I*I,N=-Math.abs(I)*(1+v),O=N-2*I*I+b*b,G=-2*N+1+2*I*I+v*v,wt=I*I/G+(2*O*O*O/G/G/G-9*N*O/G/G)/27,W=(N-O*O/3/G)/G,Q=2*Math.sqrt(-W/3),it=3*wt/W/Q,Math.abs(it)>1&&(it=it>=0?1:-1),ct=Math.acos(it)/3,y=f.y>=0?(-Q*Math.cos(ct+Math.PI/3)-O/3/G)*Math.PI:-(-Q*Math.cos(ct+Math.PI/3)-O/3/G)*Math.PI,p=Math.abs(b)2*ht*this.a?void 0:(y=p/this.a,b=Math.sin(y),I=Math.cos(y),v=this.long0,Math.abs(p)<=Ct?N=this.lat0:(N=Ji(I*this.sin_p12+f.y*b*this.cos_p12/p),O=Math.abs(this.lat0)-ht,v=Tt(Math.abs(O)<=Ct?this.lat0>=0?this.long0+Math.atan2(f.x,-f.y):this.long0-Math.atan2(-f.x,f.y):this.long0+Math.atan2(f.x*b,p*this.cos_p12*I-f.y*this.sin_p12*b))),f.x=v,f.y=N,f):(G=Us(this.es),W=pn(this.es),Q=yn(this.es),it=wn(this.es),Math.abs(this.sin_p12-1)<=Ct?(ct=this.a*je(G,W,Q,it,ht),p=Math.sqrt(f.x*f.x+f.y*f.y),wt=ct-p,N=Pn(wt/this.a,G,W,Q,it),v=Tt(this.long0+Math.atan2(f.x,-1*f.y)),f.x=v,f.y=N,f):Math.abs(this.sin_p12+1)<=Ct?(ct=this.a*je(G,W,Q,it,ht),p=Math.sqrt(f.x*f.x+f.y*f.y),wt=p-ct,N=Pn(wt/this.a,G,W,Q,it),v=Tt(this.long0+Math.atan2(f.x,f.y)),f.x=v,f.y=N,f):(p=Math.sqrt(f.x*f.x+f.y*f.y),T=Math.atan2(f.x,f.y),rt=Hn(this.a,this.e,this.sin_p12),i=Math.cos(T),s=this.e*this.cos_p12*i,a=-s*s/(1-this.es),h=3*this.es*(1-a)*this.sin_p12*this.cos_p12*i/(1-this.es),c=p/rt,d=c-a*(1+a)*Math.pow(c,3)/6-h*(1+3*a)*Math.pow(c,4)/24,m=1-a*d*d/2-c*d*d*d/6,Mt=Math.asin(this.sin_p12*Math.cos(d)+this.cos_p12*Math.sin(d)*i),v=Tt(this.long0+Math.asin(Math.sin(T)*Math.sin(d)/Math.cos(Mt))),_=Math.sin(Mt),N=Math.atan2((_-this.es*m*this.sin_p12)*Math.tan(Mt),_*(1-this.es)),f.x=v,f.y=N,f))},names:["Azimuthal_Equidistant","aeqd"]},jn={init:function(){this.sin_p14=Math.sin(this.lat0),this.cos_p14=Math.cos(this.lat0)},forward:function(f){var p,y,b,I,v,N,O,G=f.x,W=f.y;return b=Tt(G-this.long0),p=Math.sin(W),y=Math.cos(W),I=Math.cos(b),((v=this.sin_p14*p+this.cos_p14*y*I)>0||Math.abs(v)<=Ct)&&(N=1*this.a*y*Math.sin(b),O=this.y0+1*this.a*(this.cos_p14*p-this.sin_p14*y*I)),f.x=N,f.y=O,f},inverse:function(f){var p,y,b,I,v,N,O;return f.x-=this.x0,f.y-=this.y0,p=Math.sqrt(f.x*f.x+f.y*f.y),y=Ji(p/this.a),b=Math.sin(y),I=Math.cos(y),N=this.long0,Math.abs(p)<=Ct?(O=this.lat0,f.x=N,f.y=O,f):(O=Ji(I*this.sin_p14+f.y*b*this.cos_p14/p),v=Math.abs(this.lat0)-ht,Math.abs(v)<=Ct?(N=Tt(this.lat0>=0?this.long0+Math.atan2(f.x,-f.y):this.long0-Math.atan2(-f.x,f.y)),f.x=N,f.y=O,f):(N=Tt(this.long0+Math.atan2(f.x*b,p*this.cos_p14*I-f.y*this.sin_p14*b)),f.x=N,f.y=O,f))},names:["ortho"]},zt={FRONT:1,RIGHT:2,BACK:3,LEFT:4,TOP:5,BOTTOM:6},bt={AREA_0:1,AREA_1:2,AREA_2:3,AREA_3:4},Sl={init:function(){this.x0=this.x0||0,this.y0=this.y0||0,this.lat0=this.lat0||0,this.long0=this.long0||0,this.lat_ts=this.lat_ts||0,this.title=this.title||"Quadrilateralized Spherical Cube",this.lat0>=ht-Wt/2?this.face=zt.TOP:this.lat0<=-(ht-Wt/2)?this.face=zt.BOTTOM:Math.abs(this.long0)<=Wt?this.face=zt.FRONT:Math.abs(this.long0)<=ht+Wt?this.face=this.long0>0?zt.RIGHT:zt.LEFT:this.face=zt.BACK,this.es!==0&&(this.one_minus_f=1-(this.a-this.b)/this.a,this.one_minus_f_squared=this.one_minus_f*this.one_minus_f)},forward:function(f){var p,y,b,I,v,N,O={x:0,y:0},G={value:0};if(f.x-=this.long0,p=this.es!==0?Math.atan(this.one_minus_f_squared*Math.tan(f.y)):f.y,y=f.x,this.face===zt.TOP)I=ht-p,y>=Wt&&y<=ht+Wt?(G.value=bt.AREA_0,b=y-ht):y>ht+Wt||y<=-(ht+Wt)?(G.value=bt.AREA_1,b=y>0?y-Vt:y+Vt):y>-(ht+Wt)&&y<=-Wt?(G.value=bt.AREA_2,b=y+ht):(G.value=bt.AREA_3,b=y);else if(this.face===zt.BOTTOM)I=ht+p,y>=Wt&&y<=ht+Wt?(G.value=bt.AREA_0,b=-y+ht):y=-Wt?(G.value=bt.AREA_1,b=-y):y<-Wt&&y>=-(ht+Wt)?(G.value=bt.AREA_2,b=-y-ht):(G.value=bt.AREA_3,b=y>0?-y+Vt:-y-Vt);else{var W,Q,it,ct,wt,rt;this.face===zt.RIGHT?y=Ae(y,+ht):this.face===zt.BACK?y=Ae(y,+Vt):this.face===zt.LEFT&&(y=Ae(y,-ht)),ct=Math.sin(p),wt=Math.cos(p),rt=Math.sin(y),W=wt*Math.cos(y),Q=wt*rt,it=ct,this.face===zt.FRONT?b=Vn(I=Math.acos(W),it,Q,G):this.face===zt.RIGHT?b=Vn(I=Math.acos(Q),it,-W,G):this.face===zt.BACK?b=Vn(I=Math.acos(-W),it,-Q,G):this.face===zt.LEFT?b=Vn(I=Math.acos(-Q),it,W,G):(I=b=0,G.value=bt.AREA_0)}return N=Math.atan(12/Vt*(b+Math.acos(Math.sin(b)*Math.cos(Wt))-ht)),v=Math.sqrt((1-Math.cos(I))/(Math.cos(N)*Math.cos(N))/(1-Math.cos(Math.atan(1/Math.cos(b))))),G.value===bt.AREA_1?N+=ht:G.value===bt.AREA_2?N+=Vt:G.value===bt.AREA_3&&(N+=1.5*Vt),O.x=v*Math.cos(N),O.y=v*Math.sin(N),O.x=O.x*this.a+this.x0,O.y=O.y*this.a+this.y0,f.x=O.x,f.y=O.y,f},inverse:function(f){var p,y,b,I,v,N,O,G,W,Q={lam:0,phi:0},it={value:0};if(f.x=(f.x-this.x0)/this.a,f.y=(f.y-this.y0)/this.a,y=Math.atan(Math.sqrt(f.x*f.x+f.y*f.y)),p=Math.atan2(f.y,f.x),f.x>=0&&f.x>=Math.abs(f.y)?it.value=bt.AREA_0:f.y>=0&&f.y>=Math.abs(f.x)?(it.value=bt.AREA_1,p-=ht):f.x<0&&-f.x>=Math.abs(f.y)?(it.value=bt.AREA_2,p=p<0?p+Vt:p-Vt):(it.value=bt.AREA_3,p+=ht),W=Vt/12*Math.tan(p),v=Math.sin(W)/(Math.cos(W)-1/Math.sqrt(2)),N=Math.atan(v),b=Math.cos(p),I=Math.tan(y),(O=1-b*b*I*I*(1-Math.cos(Math.atan(1/Math.cos(N)))))<-1?O=-1:O>1&&(O=1),this.face===zt.TOP)G=Math.acos(O),Q.phi=ht-G,it.value===bt.AREA_0?Q.lam=N+ht:it.value===bt.AREA_1?Q.lam=N<0?N+Vt:N-Vt:it.value===bt.AREA_2?Q.lam=N-ht:Q.lam=N;else if(this.face===zt.BOTTOM)G=Math.acos(O),Q.phi=G-ht,it.value===bt.AREA_0?Q.lam=-N+ht:it.value===bt.AREA_1?Q.lam=-N:it.value===bt.AREA_2?Q.lam=-N-ht:Q.lam=N<0?-N-Vt:-N+Vt;else{var ct,wt,rt;W=(ct=O)*ct,wt=(W+=(rt=W>=1?0:Math.sqrt(1-W)*Math.sin(N))*rt)>=1?0:Math.sqrt(1-W),it.value===bt.AREA_1?(W=wt,wt=-rt,rt=W):it.value===bt.AREA_2?(wt=-wt,rt=-rt):it.value===bt.AREA_3&&(W=wt,wt=rt,rt=-W),this.face===zt.RIGHT?(W=ct,ct=-wt,wt=W):this.face===zt.BACK?(ct=-ct,wt=-wt):this.face===zt.LEFT&&(W=ct,ct=wt,wt=-W),Q.phi=Math.acos(-rt)-ht,Q.lam=Math.atan2(wt,ct),this.face===zt.RIGHT?Q.lam=Ae(Q.lam,-ht):this.face===zt.BACK?Q.lam=Ae(Q.lam,-Vt):this.face===zt.LEFT&&(Q.lam=Ae(Q.lam,+ht))}if(this.es!==0){var Mt,T,i;Mt=Q.phi<0?1:0,T=Math.tan(Q.phi),i=this.b/Math.sqrt(T*T+this.one_minus_f_squared),Q.phi=Math.atan(Math.sqrt(this.a*this.a-i*i)/(this.one_minus_f*i)),Mt&&(Q.phi=-Q.phi)}return Q.lam+=this.long0,f.x=Q.lam,f.y=Q.phi,f},names:["Quadrilateralized Spherical Cube","Quadrilateralized_Spherical_Cube","qsc"]},Re=[[1,22199e-21,-715515e-10,31103e-10],[.9986,-482243e-9,-24897e-9,-13309e-10],[.9954,-83103e-8,-448605e-10,-986701e-12],[.99,-.00135364,-59661e-9,36777e-10],[.9822,-.00167442,-449547e-11,-572411e-11],[.973,-.00214868,-903571e-10,18736e-12],[.96,-.00305085,-900761e-10,164917e-11],[.9427,-.00382792,-653386e-10,-26154e-10],[.9216,-.00467746,-10457e-8,481243e-11],[.8962,-.00536223,-323831e-10,-543432e-11],[.8679,-.00609363,-113898e-9,332484e-11],[.835,-.00698325,-640253e-10,934959e-12],[.7986,-.00755338,-500009e-10,935324e-12],[.7597,-.00798324,-35971e-9,-227626e-11],[.7186,-.00851367,-701149e-10,-86303e-10],[.6732,-.00986209,-199569e-9,191974e-10],[.6213,-.010418,883923e-10,624051e-11],[.5722,-.00906601,182e-6,624051e-11],[.5322,-.00677797,275608e-9,624051e-11]],Qi=[[-520417e-23,.0124,121431e-23,-845284e-16],[.062,.0124,-126793e-14,422642e-15],[.124,.0124,507171e-14,-160604e-14],[.186,.0123999,-190189e-13,600152e-14],[.248,.0124002,710039e-13,-224e-10],[.31,.0123992,-264997e-12,835986e-13],[.372,.0124029,988983e-12,-311994e-12],[.434,.0123893,-369093e-11,-435621e-12],[.4958,.0123198,-102252e-10,-345523e-12],[.5571,.0121916,-154081e-10,-582288e-12],[.6176,.0119938,-241424e-10,-525327e-12],[.6769,.011713,-320223e-10,-516405e-12],[.7346,.0113541,-397684e-10,-609052e-12],[.7903,.0109107,-489042e-10,-104739e-11],[.8435,.0103431,-64615e-9,-140374e-14],[.8936,.00969686,-64636e-9,-8547e-9],[.9394,.00840947,-192841e-9,-42106e-10],[.9761,.00616527,-256e-6,-42106e-10],[1,.00328947,-319159e-9,-42106e-10]],Zn=.8487,ta=1.3523,$i=ue/5,Jr=1/$i,Kn=18,ps=function(f,p){return f[0]+p*(f[1]+p*(f[2]+p*f[3]))},ea=function(f,p){return f[1]+p*(2*f[2]+3*p*f[3])},ia={init:function(){this.x0=this.x0||0,this.y0=this.y0||0,this.long0=this.long0||0,this.es=0,this.title=this.title||"Robinson"},forward:function(f){var p=Tt(f.x-this.long0),y=Math.abs(f.y),b=Math.floor(y*$i);b<0?b=0:b>=Kn&&(b=Kn-1),y=ue*(y-Jr*b);var I={x:ps(Re[b],y)*p,y:ps(Qi[b],y)};return f.y<0&&(I.y=-I.y),I.x=I.x*this.a*Zn+this.x0,I.y=I.y*this.a*ta+this.y0,I},inverse:function(f){var p={x:(f.x-this.x0)/(this.a*Zn),y:Math.abs(f.y-this.y0)/(this.a*ta)};if(p.y>=1)p.x/=Re[Kn][0],p.y=f.y<0?-ht:ht;else{var y=Math.floor(p.y*Kn);for(y<0?y=0:y>=Kn&&(y=Kn-1);;)if(Qi[y][0]>p.y)--y;else{if(!(Qi[y+1][0]<=p.y))break;++y}var b=Qi[y],I=5*(p.y-b[0])/(Qi[y+1][0]-b[0]);I=It(function(v){return(ps(b,v)-p.y)/ea(b,v)},I,Ct,100),p.x/=ps(Re[y],I),p.y=(5*y+I)*fe,f.y<0&&(p.y=-p.y)}return p.x=Tt(p.x+this.long0),p},names:["Robinson","robin"]},Rl={init:function(){this.name="geocent"},forward:function(f){return oe(f,this.es,this.a)},inverse:function(f){return Gt(f,this.es,this.a,this.b)},names:["Geocentric","geocentric","geocent","Geocent"]},Ze={N_POLE:0,S_POLE:1,EQUIT:2,OBLIQ:3},qn={h:{def:1e5,num:!0},azi:{def:0,num:!0,degrees:!0},tilt:{def:0,num:!0,degrees:!0},long0:{def:0,num:!0},lat0:{def:0,num:!0}},vl={init:function(){if(Object.keys(qn).forEach(function(y){if(this[y]===void 0)this[y]=qn[y].def;else{if(qn[y].num&&isNaN(this[y]))throw new Error("Invalid parameter value, must be numeric "+y+" = "+this[y]);qn[y].num&&(this[y]=parseFloat(this[y]))}qn[y].degrees&&(this[y]=this[y]*fe)}.bind(this)),Math.abs(Math.abs(this.lat0)-ht)1e10)throw new Error("Invalid height");this.p=1+this.pn1,this.rp=1/this.p,this.h1=1/this.pn1,this.pfact=(this.p+1)*this.h1,this.es=0;var f=this.tilt,p=this.azi;this.cg=Math.cos(p),this.sg=Math.sin(p),this.cw=Math.cos(f),this.sw=Math.sin(f)},forward:function(f){f.x-=this.long0;var p,y,b=Math.sin(f.y),I=Math.cos(f.y),v=Math.cos(f.x);switch(this.mode){case Ze.OBLIQ:y=this.sinph0*b+this.cosph0*I*v;break;case Ze.EQUIT:y=I*v;break;case Ze.S_POLE:y=-b;break;case Ze.N_POLE:y=b}switch(y=this.pn1/(this.p-y),p=y*I*Math.sin(f.x),this.mode){case Ze.OBLIQ:y*=this.cosph0*b-this.sinph0*I*v;break;case Ze.EQUIT:y*=b;break;case Ze.N_POLE:y*=-I*v;break;case Ze.S_POLE:y*=I*v}var N,O;return N=y*this.cg+p*this.sg,O=1/(N*this.sw*this.h1+this.cw),p=(p*this.cg-y*this.sg)*this.cw*O,y=N*O,f.x=p*this.a,f.y=y*this.a,f},inverse:function(f){f.x/=this.a,f.y/=this.a;var p,y,b,I={x:f.x,y:f.y};b=1/(this.pn1-f.y*this.sw),p=this.pn1*f.x*b,y=this.pn1*f.y*this.cw*b,f.x=p*this.cg+y*this.sg,f.y=y*this.cg-p*this.sg;var v=Oi(f.x,f.y);if(Math.abs(v)1e10)throw new Error;if(this.radius_g=1+this.radius_g_1,this.C=this.radius_g*this.radius_g-1,this.es!==0){var f=1-this.es,p=1/f;this.radius_p=Math.sqrt(f),this.radius_p2=f,this.radius_p_inv2=p,this.shape="ellipse"}else this.radius_p=1,this.radius_p2=1,this.radius_p_inv2=1,this.shape="sphere";this.title||(this.title="Geostationary Satellite View")},forward:function(f){var p,y,b,I,v=f.x,N=f.y;if(v-=this.long0,this.shape==="ellipse"){N=Math.atan(this.radius_p2*Math.tan(N));var O=this.radius_p/Oi(this.radius_p*Math.cos(N),Math.sin(N));if(y=O*Math.cos(v)*Math.cos(N),b=O*Math.sin(v)*Math.cos(N),I=O*Math.sin(N),(this.radius_g-y)*y-b*b-I*I*this.radius_p_inv2<0)return f.x=Number.NaN,f.y=Number.NaN,f;p=this.radius_g-y,this.flip_axis?(f.x=this.radius_g_1*Math.atan(b/Oi(I,p)),f.y=this.radius_g_1*Math.atan(I/p)):(f.x=this.radius_g_1*Math.atan(b/p),f.y=this.radius_g_1*Math.atan(I/Oi(b,p)))}else this.shape==="sphere"&&(p=Math.cos(N),y=Math.cos(v)*p,b=Math.sin(v)*p,I=Math.sin(N),p=this.radius_g-y,this.flip_axis?(f.x=this.radius_g_1*Math.atan(b/Oi(I,p)),f.y=this.radius_g_1*Math.atan(I/p)):(f.x=this.radius_g_1*Math.atan(b/p),f.y=this.radius_g_1*Math.atan(I/Oi(b,p))));return f.x=f.x*this.a,f.y=f.y*this.a,f},inverse:function(f){var p,y,b,I,v=-1,N=0,O=0;if(f.x=f.x/this.a,f.y=f.y/this.a,this.shape==="ellipse"){this.flip_axis?(O=Math.tan(f.y/this.radius_g_1),N=Math.tan(f.x/this.radius_g_1)*Oi(1,O)):(N=Math.tan(f.x/this.radius_g_1),O=Math.tan(f.y/this.radius_g_1)*Oi(1,N));var G=O/this.radius_p;if(p=N*N+G*G+v*v,y=2*this.radius_g*v,(b=y*y-4*p*this.C)<0)return f.x=Number.NaN,f.y=Number.NaN,f;I=(-y-Math.sqrt(b))/(2*p),v=this.radius_g+I*v,N*=I,O*=I,f.x=Math.atan2(N,v),f.y=Math.atan(O*Math.cos(f.x)/v),f.y=Math.atan(this.radius_p_inv2*Math.tan(f.y))}else if(this.shape==="sphere"){if(this.flip_axis?(O=Math.tan(f.y/this.radius_g_1),N=Math.tan(f.x/this.radius_g_1)*Math.sqrt(1+O*O)):(N=Math.tan(f.x/this.radius_g_1),O=Math.tan(f.y/this.radius_g_1)*Math.sqrt(1+N*N)),p=N*N+O*O+v*v,y=2*this.radius_g*v,(b=y*y-4*p*this.C)<0)return f.x=Number.NaN,f.y=Number.NaN,f;I=(-y-Math.sqrt(b))/(2*p),v=this.radius_g+I*v,N*=I,O*=I,f.x=Math.atan2(N,v),f.y=Math.atan(O*Math.cos(f.x)/v)}return f.x=f.x+this.long0,f},names:["Geostationary Satellite View","Geostationary_Satellite","geos"]};return ze.defaultDatum="WGS84",ze.Proj=yt,ze.WGS84=new ze.Proj("WGS84"),ze.Point=qe,ze.toPoint=fr,ze.defs=w,ze.nadgrid=function(f,p){var y=new DataView(p),b=_t(y),I=xt(y,b),v={header:I,subgrids:ut(y,I,b)};return me[f]=v,v},ze.transform=mi,ze.mgrs=pi,ze.version="2.10.0",function(f){f.Proj.projections.add(Ii),f.Proj.projections.add(Yn),f.Proj.projections.add(pl),f.Proj.projections.add(Ut),f.Proj.projections.add(yl),f.Proj.projections.add(Zt),f.Proj.projections.add(wl),f.Proj.projections.add(Zr),f.Proj.projections.add(Ko),f.Proj.projections.add(Ni),f.Proj.projections.add(Qo),f.Proj.projections.add(Dn),f.Proj.projections.add(Il),f.Proj.projections.add(qt),f.Proj.projections.add(fi),f.Proj.projections.add($o),f.Proj.projections.add(Ml),f.Proj.projections.add(bl),f.Proj.projections.add(Kr),f.Proj.projections.add(ai),f.Proj.projections.add(qr),f.Proj.projections.add(Xe),f.Proj.projections.add(mr),f.Proj.projections.add(jn),f.Proj.projections.add(Sl),f.Proj.projections.add(ia),f.Proj.projections.add(Rl),f.Proj.projections.add(vl),f.Proj.projections.add(Ws)}(ze),ze})})(A1);var Xx=A1.exports;const ma=C1(Xx);function Vx(r){const t=Object.keys(r.defs),e=t.length;let n,o;for(n=0;n40)throw new Error('"version" should be in range from 1 to 40');return t*4+17};rn.getSymbolTotalCodewords=function(t){return Hx[t]};rn.getBCHDigit=function(r){let t=0;for(;r!==0;)t++,r>>>=1;return t};rn.setToSJISFunction=function(t){if(typeof t!="function")throw new Error('"toSJISFunc" is not a valid function.');Tc=t};rn.isKanjiModeEnabled=function(){return typeof Tc<"u"};rn.toSJIS=function(t){return Tc(t)};var ul={};(function(r){r.L={bit:1},r.M={bit:0},r.Q={bit:3},r.H={bit:2};function t(e){if(typeof e!="string")throw new Error("Param is not a string");switch(e.toLowerCase()){case"l":case"low":return r.L;case"m":case"medium":return r.M;case"q":case"quartile":return r.Q;case"h":case"high":return r.H;default:throw new Error("Unknown EC Level: "+e)}}r.isValid=function(n){return n&&typeof n.bit<"u"&&n.bit>=0&&n.bit<4},r.from=function(n,o){if(r.isValid(n))return n;try{return t(n)}catch{return o}}})(ul);function M1(){this.buffer=[],this.length=0}M1.prototype={get:function(r){const t=Math.floor(r/8);return(this.buffer[t]>>>7-r%8&1)===1},put:function(r,t){for(let e=0;e>>t-e-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(r){const t=Math.floor(this.length/8);this.buffer.length<=t&&this.buffer.push(0),r&&(this.buffer[t]|=128>>>this.length%8),this.length++}};var jx=M1;function Vo(r){if(!r||r<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=r,this.data=new Uint8Array(r*r),this.reservedBit=new Uint8Array(r*r)}Vo.prototype.set=function(r,t,e,n){const o=r*this.size+t;this.data[o]=e,n&&(this.reservedBit[o]=!0)};Vo.prototype.get=function(r,t){return this.data[r*this.size+t]};Vo.prototype.xor=function(r,t,e){this.data[r*this.size+t]^=e};Vo.prototype.isReserved=function(r,t){return this.reservedBit[r*this.size+t]};var Zx=Vo,b1={};(function(r){const t=rn.getSymbolSize;r.getRowColCoords=function(n){if(n===1)return[];const o=Math.floor(n/7)+2,l=t(n),u=l===145?26:Math.ceil((l-13)/(2*o-2))*2,g=[l-7];for(let x=1;x=0&&o<=7},r.from=function(o){return r.isValid(o)?parseInt(o,10):void 0},r.getPenaltyN1=function(o){const l=o.size;let u=0,g=0,x=0,E=null,w=null;for(let A=0;A=5&&(u+=t.N1+(g-5)),E=P,g=1),P=o.get(S,A),P===w?x++:(x>=5&&(u+=t.N1+(x-5)),w=P,x=1)}g>=5&&(u+=t.N1+(g-5)),x>=5&&(u+=t.N1+(x-5))}return u},r.getPenaltyN2=function(o){const l=o.size;let u=0;for(let g=0;g=10&&(g===1488||g===93)&&u++,x=x<<1&2047|o.get(w,E),w>=10&&(x===1488||x===93)&&u++}return u*t.N3},r.getPenaltyN4=function(o){let l=0;const u=o.data.length;for(let x=0;x=0;){const u=l[0];for(let x=0;x0){const l=new Uint8Array(this.degree);return l.set(n,o),l}return n};var qx=Sc,O1={},Fs={},Rc={};Rc.isValid=function(t){return!isNaN(t)&&t>=1&&t<=40};var Wn={};const N1="[0-9]+",Jx="[A-Z $%*+\\-./:]+";let Oo="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";Oo=Oo.replace(/u/g,"\\u");const Qx="(?:(?![A-Z0-9 $%*+\\-./:]|"+Oo+`)(?:.|[\r +]))+`;Wn.KANJI=new RegExp(Oo,"g");Wn.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g");Wn.BYTE=new RegExp(Qx,"g");Wn.NUMERIC=new RegExp(N1,"g");Wn.ALPHANUMERIC=new RegExp(Jx,"g");const $x=new RegExp("^"+Oo+"$"),t_=new RegExp("^"+N1+"$"),e_=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");Wn.testKanji=function(t){return $x.test(t)};Wn.testNumeric=function(t){return t_.test(t)};Wn.testAlphanumeric=function(t){return e_.test(t)};(function(r){const t=Rc,e=Wn;r.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]},r.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},r.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]},r.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]},r.MIXED={bit:-1},r.getCharCountIndicator=function(l,u){if(!l.ccBits)throw new Error("Invalid mode: "+l);if(!t.isValid(u))throw new Error("Invalid version: "+u);return u>=1&&u<10?l.ccBits[0]:u<27?l.ccBits[1]:l.ccBits[2]},r.getBestModeForData=function(l){return e.testNumeric(l)?r.NUMERIC:e.testAlphanumeric(l)?r.ALPHANUMERIC:e.testKanji(l)?r.KANJI:r.BYTE},r.toString=function(l){if(l&&l.id)return l.id;throw new Error("Invalid mode")},r.isValid=function(l){return l&&l.bit&&l.ccBits};function n(o){if(typeof o!="string")throw new Error("Param is not a string");switch(o.toLowerCase()){case"numeric":return r.NUMERIC;case"alphanumeric":return r.ALPHANUMERIC;case"kanji":return r.KANJI;case"byte":return r.BYTE;default:throw new Error("Unknown mode: "+o)}}r.from=function(l,u){if(r.isValid(l))return l;try{return n(l)}catch{return u}}})(Fs);(function(r){const t=rn,e=fl,n=ul,o=Fs,l=Rc,u=7973,g=t.getBCHDigit(u);function x(S,P,L){for(let F=1;F<=40;F++)if(P<=r.getCapacity(F,L,S))return F}function E(S,P){return o.getCharCountIndicator(S,P)+4}function w(S,P){let L=0;return S.forEach(function(F){const V=E(F.mode,P);L+=V+F.getBitsLength()}),L}function A(S,P){for(let L=1;L<=40;L++)if(w(S,L)<=r.getCapacity(L,P,o.MIXED))return L}r.from=function(P,L){return l.isValid(P)?parseInt(P,10):L},r.getCapacity=function(P,L,F){if(!l.isValid(P))throw new Error("Invalid QR Code version");typeof F>"u"&&(F=o.BYTE);const V=t.getSymbolTotalCodewords(P),z=e.getTotalCodewordsCount(P,L),U=(V-z)*8;if(F===o.MIXED)return U;const Y=U-E(F,P);switch(F){case o.NUMERIC:return Math.floor(Y/10*3);case o.ALPHANUMERIC:return Math.floor(Y/11*2);case o.KANJI:return Math.floor(Y/13);case o.BYTE:default:return Math.floor(Y/8)}},r.getBestVersionForData=function(P,L){let F;const V=n.from(L,n.M);if(Array.isArray(P)){if(P.length>1)return A(P,V);if(P.length===0)return 1;F=P[0]}else F=P;return x(F.mode,F.getLength(),V)},r.getEncodedBits=function(P){if(!l.isValid(P)||P<7)throw new Error("Invalid QR Code version");let L=P<<12;for(;t.getBCHDigit(L)-g>=0;)L^=u<=0;)o^=D1<0&&(n=this.data.substr(e),o=parseInt(n,10),t.put(o,l*3+1))};var s_=kr;const r_=Fs,Jl=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function Gr(r){this.mode=r_.ALPHANUMERIC,this.data=r}Gr.getBitsLength=function(t){return 11*Math.floor(t/2)+6*(t%2)};Gr.prototype.getLength=function(){return this.data.length};Gr.prototype.getBitsLength=function(){return Gr.getBitsLength(this.data.length)};Gr.prototype.write=function(t){let e;for(e=0;e+2<=this.data.length;e+=2){let n=Jl.indexOf(this.data[e])*45;n+=Jl.indexOf(this.data[e+1]),t.put(n,11)}this.data.length%2&&t.put(Jl.indexOf(this.data[e]),6)};var o_=Gr,a_=function(t){for(var e=[],n=t.length,o=0;o=55296&&l<=56319&&n>o+1){var u=t.charCodeAt(o+1);u>=56320&&u<=57343&&(l=(l-55296)*1024+u-56320+65536,o+=1)}if(l<128){e.push(l);continue}if(l<2048){e.push(l>>6|192),e.push(l&63|128);continue}if(l<55296||l>=57344&&l<65536){e.push(l>>12|224),e.push(l>>6&63|128),e.push(l&63|128);continue}if(l>=65536&&l<=1114111){e.push(l>>18|240),e.push(l>>12&63|128),e.push(l>>6&63|128),e.push(l&63|128);continue}e.push(239,191,189)}return new Uint8Array(e).buffer};const l_=a_,h_=Fs;function Ur(r){this.mode=h_.BYTE,typeof r=="string"&&(r=l_(r)),this.data=new Uint8Array(r)}Ur.getBitsLength=function(t){return t*8};Ur.prototype.getLength=function(){return this.data.length};Ur.prototype.getBitsLength=function(){return Ur.getBitsLength(this.data.length)};Ur.prototype.write=function(r){for(let t=0,e=this.data.length;t=33088&&e<=40956)e-=33088;else if(e>=57408&&e<=60351)e-=49472;else throw new Error("Invalid SJIS character: "+this.data[t]+` +Make sure your charset is UTF-8`);e=(e>>>8&255)*192+(e&255),r.put(e,13)}};var d_=zr,F1={exports:{}};(function(r){var t={single_source_shortest_paths:function(e,n,o){var l={},u={};u[n]=0;var g=t.PriorityQueue.make();g.push(n,0);for(var x,E,w,A,S,P,L,F,V;!g.empty();){x=g.pop(),E=x.value,A=x.cost,S=e[E]||{};for(w in S)S.hasOwnProperty(w)&&(P=S[w],L=A+P,F=u[w],V=typeof u[w]>"u",(V||F>L)&&(u[w]=L,g.push(w,L),l[w]=E))}if(typeof o<"u"&&typeof u[o]>"u"){var z=["Could not find a path from ",n," to ",o,"."].join("");throw new Error(z)}return l},extract_shortest_path_from_predecessor_list:function(e,n){for(var o=[],l=n;l;)o.push(l),e[l],l=e[l];return o.reverse(),o},find_path:function(e,n,o){var l=t.single_source_shortest_paths(e,n,o);return t.extract_shortest_path_from_predecessor_list(l,o)},PriorityQueue:{make:function(e){var n=t.PriorityQueue,o={},l;e=e||{};for(l in n)n.hasOwnProperty(l)&&(o[l]=n[l]);return o.queue=[],o.sorter=e.sorter||n.default_sorter,o},default_sorter:function(e,n){return e.cost-n.cost},push:function(e,n){var o={value:e,cost:n};this.queue.push(o),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};r.exports=t})(F1);var g_=F1.exports;(function(r){const t=Fs,e=s_,n=o_,o=c_,l=d_,u=Wn,g=rn,x=g_;function E(z){return unescape(encodeURIComponent(z)).length}function w(z,U,Y){const Z=[];let $;for(;($=z.exec(Y))!==null;)Z.push({data:$[0],index:$.index,mode:U,length:$[0].length});return Z}function A(z){const U=w(u.NUMERIC,t.NUMERIC,z),Y=w(u.ALPHANUMERIC,t.ALPHANUMERIC,z);let Z,$;return g.isKanjiModeEnabled()?(Z=w(u.BYTE,t.BYTE,z),$=w(u.KANJI,t.KANJI,z)):(Z=w(u.BYTE_KANJI,t.BYTE,z),$=[]),U.concat(Y,Z,$).sort(function(X,J){return X.index-J.index}).map(function(X){return{data:X.data,mode:X.mode,length:X.length}})}function S(z,U){switch(U){case t.NUMERIC:return e.getBitsLength(z);case t.ALPHANUMERIC:return n.getBitsLength(z);case t.KANJI:return l.getBitsLength(z);case t.BYTE:return o.getBitsLength(z)}}function P(z){return z.reduce(function(U,Y){const Z=U.length-1>=0?U[U.length-1]:null;return Z&&Z.mode===Y.mode?(U[U.length-1].data+=Y.data,U):(U.push(Y),U)},[])}function L(z){const U=[];for(let Y=0;Y=0&&g<=6&&(x===0||x===6)||x>=0&&x<=6&&(g===0||g===6)||g>=2&&g<=4&&x>=2&&x<=4?r.set(l+g,u+x,!0,!0):r.set(l+g,u+x,!1,!0))}}function A_(r){const t=r.size;for(let e=8;e>g&1)===1,r.set(o,l,u,!0),r.set(l,o,u,!0)}function th(r,t,e){const n=r.size,o=w_.getEncodedBits(t,e);let l,u;for(l=0;l<15;l++)u=(o>>l&1)===1,l<6?r.set(l,8,u,!0):l<8?r.set(l+1,8,u,!0):r.set(n-15+l,8,u,!0),l<8?r.set(8,n-l-1,u,!0):l<9?r.set(8,15-l-1+1,u,!0):r.set(8,15-l-1,u,!0);r.set(n-8,8,1,!0)}function b_(r,t){const e=r.size;let n=-1,o=e-1,l=7,u=0;for(let g=e-1;g>0;g-=2)for(g===6&&g--;;){for(let x=0;x<2;x++)if(!r.isReserved(o,g-x)){let E=!1;u>>l&1)===1),r.set(o,g-x,E),l--,l===-1&&(u++,l=7)}if(o+=n,o<0||e<=o){o-=n,n=-n;break}}}function T_(r,t,e){const n=new m_;e.forEach(function(x){n.put(x.mode.bit,4),n.put(x.getLength(),E_.getCharCountIndicator(x.mode,r)),x.write(n)});const o=gl.getSymbolTotalCodewords(r),l=Mh.getTotalCodewordsCount(r,t),u=(o-l)*8;for(n.getLengthInBits()+4<=u&&n.put(0,4);n.getLengthInBits()%8!==0;)n.putBit(0);const g=(u-n.getLengthInBits())/8;for(let x=0;x=7&&M_(x,t),b_(x,u),isNaN(n)&&(n=Ih.getBestMask(x,th.bind(null,x,e))),Ih.applyMask(n,x),th(x,e,n),{modules:x,version:t,errorCorrectionLevel:e,maskPattern:n,segments:o}}I1.create=function(t,e){if(typeof t>"u"||t==="")throw new Error("No input text");let n=Ql.M,o,l;return typeof e<"u"&&(n=Ql.from(e.errorCorrectionLevel,Ql.M),o=Fa.from(e.version),l=Ih.from(e.maskPattern),e.toSJISFunc&&gl.setToSJISFunction(e.toSJISFunc)),R_(t,o,n,l)};var B1={},vc={};(function(r){function t(e){if(typeof e=="number"&&(e=e.toString()),typeof e!="string")throw new Error("Color should be defined as hex string");let n=e.slice().replace("#","").split("");if(n.length<3||n.length===5||n.length>8)throw new Error("Invalid hex color: "+e);(n.length===3||n.length===4)&&(n=Array.prototype.concat.apply([],n.map(function(l){return[l,l]}))),n.length===6&&n.push("F","F");const o=parseInt(n.join(""),16);return{r:o>>24&255,g:o>>16&255,b:o>>8&255,a:o&255,hex:"#"+n.slice(0,6).join("")}}r.getOptions=function(n){n||(n={}),n.color||(n.color={});const o=typeof n.margin>"u"||n.margin===null||n.margin<0?4:n.margin,l=n.width&&n.width>=21?n.width:void 0,u=n.scale||4;return{width:l,scale:l?4:u,margin:o,color:{dark:t(n.color.dark||"#000000ff"),light:t(n.color.light||"#ffffffff")},type:n.type,rendererOpts:n.rendererOpts||{}}},r.getScale=function(n,o){return o.width&&o.width>=n+o.margin*2?o.width/(n+o.margin*2):o.scale},r.getImageWidth=function(n,o){const l=r.getScale(n,o);return Math.floor((n+o.margin*2)*l)},r.qrToImageData=function(n,o,l){const u=o.modules.size,g=o.modules.data,x=r.getScale(u,l),E=Math.floor((u+l.margin*2)*x),w=l.margin*x,A=[l.color.light,l.color.dark];for(let S=0;S=w&&P>=w&&S"u"&&(!u||!u.getContext)&&(x=u,u=void 0),u||(E=n()),x=t.getOptions(x);const w=t.getImageWidth(l.modules.size,x),A=E.getContext("2d"),S=A.createImageData(w,w);return t.qrToImageData(S.data,l,x),e(A,E,w),A.putImageData(S,0,0),E},r.renderToDataURL=function(l,u,g){let x=g;typeof x>"u"&&(!u||!u.getContext)&&(x=u,u=void 0),x||(x={});const E=r.render(l,u,x),w=x.type||"image/png",A=x.rendererOpts||{};return E.toDataURL(w,A.quality)}})(B1);var k1={};const v_=vc;function Lu(r,t){const e=r.a/255,n=t+'="'+r.hex+'"';return e<1?n+" "+t+'-opacity="'+e.toFixed(2).slice(1)+'"':n}function eh(r,t,e){let n=r+t;return typeof e<"u"&&(n+=" "+e),n}function O_(r,t,e){let n="",o=0,l=!1,u=0;for(let g=0;g0&&x>0&&r[g-1]||(n+=l?eh("M",x+e,.5+E+e):eh("m",o,0),o=0,l=!1),x+1':"",E="',w='viewBox="0 0 '+g+" "+g+'"',S=''+x+E+` +`;return typeof n=="function"&&n(null,S),S};const N_=Yx,bh=I1,G1=B1,P_=k1;function Oc(r,t,e,n,o){const l=[].slice.call(arguments,1),u=l.length,g=typeof l[u-1]=="function";if(!g&&!N_())throw new Error("Callback required as last argument");if(g){if(u<2)throw new Error("Too few arguments provided");u===2?(o=e,e=t,t=n=void 0):u===3&&(t.getContext&&typeof o>"u"?(o=n,n=void 0):(o=n,n=e,e=t,t=void 0))}else{if(u<1)throw new Error("Too few arguments provided");return u===1?(e=t,t=n=void 0):u===2&&!t.getContext&&(n=e,e=t,t=void 0),new Promise(function(x,E){try{const w=bh.create(e,n);x(r(w,t,n))}catch(w){E(w)}})}try{const x=bh.create(e,n);o(null,r(x,t,n))}catch(x){o(x)}}bh.create;Oc.bind(null,G1.render);Oc.bind(null,G1.renderToDataURL);Oc.bind(null,function(r,t,e){return P_.render(r,e)});var di;(function(r){r[r.QR_CODE=0]="QR_CODE",r[r.AZTEC=1]="AZTEC",r[r.CODABAR=2]="CODABAR",r[r.CODE_39=3]="CODE_39",r[r.CODE_93=4]="CODE_93",r[r.CODE_128=5]="CODE_128",r[r.DATA_MATRIX=6]="DATA_MATRIX",r[r.MAXICODE=7]="MAXICODE",r[r.ITF=8]="ITF",r[r.EAN_13=9]="EAN_13",r[r.EAN_8=10]="EAN_8",r[r.PDF_417=11]="PDF_417",r[r.RSS_14=12]="RSS_14",r[r.RSS_EXPANDED=13]="RSS_EXPANDED",r[r.UPC_A=14]="UPC_A",r[r.UPC_E=15]="UPC_E",r[r.UPC_EAN_EXTENSION=16]="UPC_EAN_EXTENSION"})(di||(di={}));di.QR_CODE,di.AZTEC,di.CODABAR,di.CODE_39,di.CODE_93,di.CODE_128,di.DATA_MATRIX,di.MAXICODE,di.ITF,di.EAN_13,di.EAN_8,di.PDF_417,di.RSS_14,di.RSS_EXPANDED,di.UPC_A,di.UPC_E,di.UPC_EAN_EXTENSION;var Fu;(function(r){r[r.UNKNOWN=0]="UNKNOWN",r[r.URL=1]="URL"})(Fu||(Fu={}));var Ba;(function(r){r[r.SCAN_TYPE_CAMERA=0]="SCAN_TYPE_CAMERA",r[r.SCAN_TYPE_FILE=1]="SCAN_TYPE_FILE"})(Ba||(Ba={}));var D_=function(){function r(){}return r.GITHUB_PROJECT_URL="https://github.com/mebjas/html5-qrcode",r.SCAN_DEFAULT_FPS=2,r.DEFAULT_DISABLE_FLIP=!1,r.DEFAULT_REMEMBER_LAST_CAMERA_USED=!0,r.DEFAULT_SUPPORTED_SCAN_TYPE=[Ba.SCAN_TYPE_CAMERA,Ba.SCAN_TYPE_FILE],r}(),Bu;(function(r){r[r.UNKWOWN_ERROR=0]="UNKWOWN_ERROR",r[r.IMPLEMENTATION_ERROR=1]="IMPLEMENTATION_ERROR",r[r.NO_CODE_FOUND_ERROR=2]="NO_CODE_FOUND_ERROR"})(Bu||(Bu={}));var ku={exports:{}};(function(r,t){(function(e,n){n(t)})(Mn,function(e){function n(T){return T==null}var o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(T,i){T.__proto__=i}||function(T,i){for(var s in i)i.hasOwnProperty(s)&&(T[s]=i[s])};function l(T,i){o(T,i);function s(){this.constructor=T}T.prototype=i===null?Object.create(i):(s.prototype=i.prototype,new s)}function u(T,i){var s=Object.setPrototypeOf;s?s(T,i):T.__proto__=i}function g(T,i){i===void 0&&(i=T.constructor);var s=Error.captureStackTrace;s&&s(T,i)}var x=function(T){l(i,T);function i(s){var a=this.constructor,h=T.call(this,s)||this;return Object.defineProperty(h,"name",{value:a.name,enumerable:!1}),u(h,a.prototype),g(h),h}return i}(Error);class E extends x{constructor(i=void 0){super(i),this.message=i}getKind(){return this.constructor.kind}}E.kind="Exception";class w extends E{}w.kind="ArgumentException";class A extends E{}A.kind="IllegalArgumentException";class S{constructor(i){if(this.binarizer=i,i===null)throw new A("Binarizer must be non-null.")}getWidth(){return this.binarizer.getWidth()}getHeight(){return this.binarizer.getHeight()}getBlackRow(i,s){return this.binarizer.getBlackRow(i,s)}getBlackMatrix(){return(this.matrix===null||this.matrix===void 0)&&(this.matrix=this.binarizer.getBlackMatrix()),this.matrix}isCropSupported(){return this.binarizer.getLuminanceSource().isCropSupported()}crop(i,s,a,h){const c=this.binarizer.getLuminanceSource().crop(i,s,a,h);return new S(this.binarizer.createBinarizer(c))}isRotateSupported(){return this.binarizer.getLuminanceSource().isRotateSupported()}rotateCounterClockwise(){const i=this.binarizer.getLuminanceSource().rotateCounterClockwise();return new S(this.binarizer.createBinarizer(i))}rotateCounterClockwise45(){const i=this.binarizer.getLuminanceSource().rotateCounterClockwise45();return new S(this.binarizer.createBinarizer(i))}toString(){try{return this.getBlackMatrix().toString()}catch{return""}}}class P extends E{static getChecksumInstance(){return new P}}P.kind="ChecksumException";class L{constructor(i){this.source=i}getLuminanceSource(){return this.source}getWidth(){return this.source.getWidth()}getHeight(){return this.source.getHeight()}}class F{static arraycopy(i,s,a,h,c){for(;c--;)a[h++]=i[s++]}static currentTimeMillis(){return Date.now()}}class V extends E{}V.kind="IndexOutOfBoundsException";class z extends V{constructor(i=void 0,s=void 0){super(s),this.index=i,this.message=s}}z.kind="ArrayIndexOutOfBoundsException";class U{static fill(i,s){for(let a=0,h=i.length;aa)throw new A("fromIndex("+s+") > toIndex("+a+")");if(s<0)throw new z(s);if(a>i)throw new z(a)}static asList(...i){return i}static create(i,s,a){return Array.from({length:i}).map(c=>Array.from({length:s}).fill(a))}static createInt32Array(i,s,a){return Array.from({length:i}).map(c=>Int32Array.from({length:s}).fill(a))}static equals(i,s){if(!i||!s||!i.length||!s.length||i.length!==s.length)return!1;for(let a=0,h=i.length;a>1,m=a(s,i[d]);if(m>0)h=d+1;else if(m<0)c=d-1;else return d}return-h-1}static numberComparator(i,s){return i-s}}class Y{static numberOfTrailingZeros(i){let s;if(i===0)return 32;let a=31;return s=i<<16,s!==0&&(a-=16,i=s),s=i<<8,s!==0&&(a-=8,i=s),s=i<<4,s!==0&&(a-=4,i=s),s=i<<2,s!==0&&(a-=2,i=s),a-(i<<1>>>31)}static numberOfLeadingZeros(i){if(i===0)return 32;let s=1;return i>>>16||(s+=16,i<<=16),i>>>24||(s+=8,i<<=8),i>>>28||(s+=4,i<<=4),i>>>30||(s+=2,i<<=2),s-=i>>>31,s}static toHexString(i){return i.toString(16)}static toBinaryString(i){return String(parseInt(String(i),2))}static bitCount(i){return i=i-(i>>>1&1431655765),i=(i&858993459)+(i>>>2&858993459),i=i+(i>>>4)&252645135,i=i+(i>>>8),i=i+(i>>>16),i&63}static truncDivision(i,s){return Math.trunc(i/s)}static parseInt(i,s=void 0){return parseInt(i,s)}}Y.MIN_VALUE_32_BITS=-2147483648,Y.MAX_VALUE=Number.MAX_SAFE_INTEGER;class Z{constructor(i,s){i===void 0?(this.size=0,this.bits=new Int32Array(1)):(this.size=i,s==null?this.bits=Z.makeArray(i):this.bits=s)}getSize(){return this.size}getSizeInBytes(){return Math.floor((this.size+7)/8)}ensureCapacity(i){if(i>this.bits.length*32){const s=Z.makeArray(i);F.arraycopy(this.bits,0,s,0,this.bits.length),this.bits=s}}get(i){return(this.bits[Math.floor(i/32)]&1<<(i&31))!==0}set(i){this.bits[Math.floor(i/32)]|=1<<(i&31)}flip(i){this.bits[Math.floor(i/32)]^=1<<(i&31)}getNextSet(i){const s=this.size;if(i>=s)return s;const a=this.bits;let h=Math.floor(i/32),c=a[h];c&=~((1<<(i&31))-1);const d=a.length;for(;c===0;){if(++h===d)return s;c=a[h]}const m=h*32+Y.numberOfTrailingZeros(c);return m>s?s:m}getNextUnset(i){const s=this.size;if(i>=s)return s;const a=this.bits;let h=Math.floor(i/32),c=~a[h];c&=~((1<<(i&31))-1);const d=a.length;for(;c===0;){if(++h===d)return s;c=~a[h]}const m=h*32+Y.numberOfTrailingZeros(c);return m>s?s:m}setBulk(i,s){this.bits[Math.floor(i/32)]=s}setRange(i,s){if(sthis.size)throw new A;if(s===i)return;s--;const a=Math.floor(i/32),h=Math.floor(s/32),c=this.bits;for(let d=a;d<=h;d++){const m=d>a?0:i&31,C=(2<<(dthis.size)throw new A;if(s===i)return!0;s--;const h=Math.floor(i/32),c=Math.floor(s/32),d=this.bits;for(let m=h;m<=c;m++){const _=m>h?0:i&31,M=(2<<(m32)throw new A("Num bits must be between 0 and 32");this.ensureCapacity(this.size+s);for(let a=s;a>0;a--)this.appendBit((i>>a-1&1)===1)}appendBitArray(i){const s=i.size;this.ensureCapacity(this.size+s);for(let a=0;a>1&1431655765|(d&1431655765)<<1,d=d>>2&858993459|(d&858993459)<<2,d=d>>4&252645135|(d&252645135)<<4,d=d>>8&16711935|(d&16711935)<<8,d=d>>16&65535|(d&65535)<<16,i[s-c]=d}if(this.size!==a*32){const c=a*32-this.size;let d=i[0]>>>c;for(let m=1;m>>c}i[a-1]=d}this.bits=i}static makeArray(i){return new Int32Array(Math.floor((i+31)/32))}equals(i){if(!(i instanceof Z))return!1;const s=i;return this.size===s.size&&U.equals(this.bits,s.bits)}hashCode(){return 31*this.size+U.hashCode(this.bits)}toString(){let i="";for(let s=0,a=this.size;s=900)throw new X("incorect value");const s=H.VALUES_TO_ECI.get(i);if(s===void 0)throw new X("incorect value");return s}static getCharacterSetECIByName(i){const s=H.NAME_TO_ECI.get(i);if(s===void 0)throw new X("incorect value");return s}equals(i){if(!(i instanceof H))return!1;const s=i;return this.getName()===s.getName()}}H.VALUE_IDENTIFIER_TO_ECI=new Map,H.VALUES_TO_ECI=new Map,H.NAME_TO_ECI=new Map,H.Cp437=new H(J.Cp437,Int32Array.from([0,2]),"Cp437"),H.ISO8859_1=new H(J.ISO8859_1,Int32Array.from([1,3]),"ISO-8859-1","ISO88591","ISO8859_1"),H.ISO8859_2=new H(J.ISO8859_2,4,"ISO-8859-2","ISO88592","ISO8859_2"),H.ISO8859_3=new H(J.ISO8859_3,5,"ISO-8859-3","ISO88593","ISO8859_3"),H.ISO8859_4=new H(J.ISO8859_4,6,"ISO-8859-4","ISO88594","ISO8859_4"),H.ISO8859_5=new H(J.ISO8859_5,7,"ISO-8859-5","ISO88595","ISO8859_5"),H.ISO8859_6=new H(J.ISO8859_6,8,"ISO-8859-6","ISO88596","ISO8859_6"),H.ISO8859_7=new H(J.ISO8859_7,9,"ISO-8859-7","ISO88597","ISO8859_7"),H.ISO8859_8=new H(J.ISO8859_8,10,"ISO-8859-8","ISO88598","ISO8859_8"),H.ISO8859_9=new H(J.ISO8859_9,11,"ISO-8859-9","ISO88599","ISO8859_9"),H.ISO8859_10=new H(J.ISO8859_10,12,"ISO-8859-10","ISO885910","ISO8859_10"),H.ISO8859_11=new H(J.ISO8859_11,13,"ISO-8859-11","ISO885911","ISO8859_11"),H.ISO8859_13=new H(J.ISO8859_13,15,"ISO-8859-13","ISO885913","ISO8859_13"),H.ISO8859_14=new H(J.ISO8859_14,16,"ISO-8859-14","ISO885914","ISO8859_14"),H.ISO8859_15=new H(J.ISO8859_15,17,"ISO-8859-15","ISO885915","ISO8859_15"),H.ISO8859_16=new H(J.ISO8859_16,18,"ISO-8859-16","ISO885916","ISO8859_16"),H.SJIS=new H(J.SJIS,20,"SJIS","Shift_JIS"),H.Cp1250=new H(J.Cp1250,21,"Cp1250","windows-1250"),H.Cp1251=new H(J.Cp1251,22,"Cp1251","windows-1251"),H.Cp1252=new H(J.Cp1252,23,"Cp1252","windows-1252"),H.Cp1256=new H(J.Cp1256,24,"Cp1256","windows-1256"),H.UnicodeBigUnmarked=new H(J.UnicodeBigUnmarked,25,"UnicodeBigUnmarked","UTF-16BE","UnicodeBig"),H.UTF8=new H(J.UTF8,26,"UTF8","UTF-8"),H.ASCII=new H(J.ASCII,Int32Array.from([27,170]),"ASCII","US-ASCII"),H.Big5=new H(J.Big5,28,"Big5"),H.GB18030=new H(J.GB18030,29,"GB18030","GB2312","EUC_CN","GBK"),H.EUC_KR=new H(J.EUC_KR,30,"EUC_KR","EUC-KR");class _t extends E{}_t.kind="UnsupportedOperationException";class xt{static decode(i,s){const a=this.encodingName(s);return this.customDecoder?this.customDecoder(i,a):typeof TextDecoder>"u"||this.shouldDecodeOnFallback(a)?this.decodeFallback(i,a):new TextDecoder(a).decode(i)}static shouldDecodeOnFallback(i){return!xt.isBrowser()&&i==="ISO-8859-1"}static encode(i,s){const a=this.encodingName(s);return this.customEncoder?this.customEncoder(i,a):typeof TextEncoder>"u"?this.encodeFallback(i):new TextEncoder().encode(i)}static isBrowser(){return typeof window<"u"&&{}.toString.call(window)==="[object Window]"}static encodingName(i){return typeof i=="string"?i:i.getName()}static encodingCharacterSet(i){return i instanceof H?i:H.getCharacterSetECIByName(i)}static decodeFallback(i,s){const a=this.encodingCharacterSet(s);if(xt.isDecodeFallbackSupported(a)){let h="";for(let c=0,d=i.length;c3&&i[0]===239&&i[1]===187&&i[2]===191;for(let At=0;At0?mt&128?m--:d=!1:mt&128&&(mt&64?(m++,mt&32?(m++,mt&16?(m++,mt&8?d=!1:M++):C++):_++):d=!1)),h&&(mt>127&&mt<160?h=!1:mt>159&&(mt<192||mt===215||mt===247)&&st++),c&&(R>0?mt<64||mt===127||mt>252?c=!1:R--:mt===128||mt===160||mt>239?c=!1:mt>160&&mt<224?(D++,j=0,k++,k>K&&(K=k)):mt>127?(R++,k=0,j++,j>tt&&(tt=j)):(k=0,j=0))}return d&&m>0&&(d=!1),c&&R>0&&(c=!1),d&&(Et||_+C+M>0)?at.UTF8:c&&(at.ASSUME_SHIFT_JIS||K>=3||tt>=3)?at.SHIFT_JIS:h&&c?K===2&&D===2||st*10>=a?at.SHIFT_JIS:at.ISO88591:h?at.ISO88591:c?at.SHIFT_JIS:d?at.UTF8:at.PLATFORM_DEFAULT_ENCODING}static format(i,...s){let a=-1;function h(d,m,_,C,M,R){if(d==="%%")return"%";if(s[++a]===void 0)return;d=C?parseInt(C.substr(1)):void 0;let D=M?parseInt(M.substr(1)):void 0,k;switch(R){case"s":k=s[a];break;case"c":k=s[a][0];break;case"f":k=parseFloat(s[a]).toFixed(d);break;case"p":k=parseFloat(s[a]).toPrecision(d);break;case"e":k=parseFloat(s[a]).toExponential(d);break;case"x":k=parseInt(s[a]).toString(D||16);break;case"d":k=parseFloat(parseInt(s[a],D||10).toPrecision(d)).toFixed(0);break}k=typeof k=="object"?JSON.stringify(k):(+k).toString(D);let j=parseInt(_),K=_&&_[0]+""=="0"?"0":" ";for(;k.lengthd){if(m===-1)m=c-d;else if(c-d!==m)throw new A("row lengths do not match");d=c,_++}C++}else if(i.substring(C,C+s.length)===s)C+=s.length,h[c]=!0,c++;else if(i.substring(C,C+a.length)===a)C+=a.length,h[c]=!1,c++;else throw new A("illegal character encountered: "+i.substring(C));if(c>d){if(m===-1)m=c-d;else if(c-d!==m)throw new A("row lengths do not match");_++}const M=new pt(m,_);for(let R=0;R>>(i&31)&1)!==0}set(i,s){const a=s*this.rowSize+Math.floor(i/32);this.bits[a]|=1<<(i&31)&4294967295}unset(i,s){const a=s*this.rowSize+Math.floor(i/32);this.bits[a]&=~(1<<(i&31)&4294967295)}flip(i,s){const a=s*this.rowSize+Math.floor(i/32);this.bits[a]^=1<<(i&31)&4294967295}xor(i){if(this.width!==i.getWidth()||this.height!==i.getHeight()||this.rowSize!==i.getRowSize())throw new A("input matrix dimensions do not match");const s=new Z(Math.floor(this.width/32)+1),a=this.rowSize,h=this.bits;for(let c=0,d=this.height;cthis.height||c>this.width)throw new A("The region must fit inside the matrix");const m=this.rowSize,_=this.bits;for(let C=s;C_&&(_=C),M*32m){let D=31;for(;!(R>>>D);)D--;M*32+D>m&&(m=M*32+D)}}}return m=0&&s[a]===0;)a--;if(a<0)return null;const h=Math.floor(a/i);let c=Math.floor(a%i)*32;const d=s[a];let m=31;for(;!(d>>>m);)m--;return c+=m,Int32Array.from([c,h])}getWidth(){return this.width}getHeight(){return this.height}getRowSize(){return this.rowSize}equals(i){if(!(i instanceof pt))return!1;const s=i;return this.width===s.width&&this.height===s.height&&this.rowSize===s.rowSize&&U.equals(this.bits,s.bits)}hashCode(){let i=this.width;return i=31*i+this.width,i=31*i+this.height,i=31*i+this.rowSize,i=31*i+U.hashCode(this.bits),i}toString(i="X ",s=" ",a=` +`){return this.buildToString(i,s,a)}buildToString(i,s,a){let h=new ut;for(let c=0,d=this.height;c>lt.LUMINANCE_SHIFT]++;const m=lt.estimateBlackPoint(d);if(h<3)for(let _=0;_>lt.LUMINANCE_SHIFT]++}}const d=lt.estimateBlackPoint(c),m=i.getMatrix();for(let _=0;_c&&(h=M,c=i[M]),i[M]>a&&(a=i[M]);let d=0,m=0;for(let M=0;Mm&&(d=M,m=D)}if(h>d){const M=h;h=d,d=M}if(d-h<=s/16)throw new q;let _=d-1,C=-1;for(let M=d-1;M>h;M--){const R=M-h,D=R*R*(d-M)*(a-i[M]);D>C&&(_=M,C=D)}return _<=yt.MINIMUM_DIMENSION&&a>=yt.MINIMUM_DIMENSION){const h=i.getMatrix();let c=s>>yt.BLOCK_SIZE_POWER;s&yt.BLOCK_SIZE_MASK&&c++;let d=a>>yt.BLOCK_SIZE_POWER;a&yt.BLOCK_SIZE_MASK&&d++;const m=yt.calculateBlackPoints(h,c,d,s,a),_=new pt(s,a);yt.calculateThresholdForBlock(h,c,d,s,a,m,_),this.matrix=_}else this.matrix=super.getBlackMatrix();return this.matrix}createBinarizer(i){return new yt(i)}static calculateThresholdForBlock(i,s,a,h,c,d,m){const _=c-yt.BLOCK_SIZE,C=h-yt.BLOCK_SIZE;for(let M=0;M_&&(R=_);const D=yt.cap(M,2,a-3);for(let k=0;kC&&(j=C);const K=yt.cap(k,2,s-3);let tt=0;for(let Et=-2;Et<=2;Et++){const At=d[D+Et];tt+=At[K-2]+At[K-1]+At[K]+At[K+1]+At[K+2]}const st=tt/25;yt.thresholdBlock(i,j,R,st,h,m)}}}static cap(i,s,a){return ia?a:i}static thresholdBlock(i,s,a,h,c,d){for(let m=0,_=a*c+s;md&&(M=d);for(let R=0;Rm&&(D=m);let k=0,j=255,K=0;for(let st=0,Et=M*h+D;stK&&(K=mt)}if(K-j>yt.MIN_DYNAMIC_RANGE)for(st++,Et+=h;st>yt.BLOCK_SIZE_POWER*2;if(K-j<=yt.MIN_DYNAMIC_RANGE&&(tt=j/2,C>0&&R>0)){const st=(_[C-1][R]+2*_[C][R-1]+_[C-1][R-1])/4;j>10}h[d]=_}return h}getRow(i,s){if(i<0||i>=this.getHeight())throw new A("Requested row is outside the image: "+i);const a=this.getWidth(),h=i*a;return s===null?s=this.buffer.slice(h,h+a):(s.lengthnew $t(s.deviceId,s.label))})}findDeviceById(i){return Ft(this,void 0,void 0,function*(){const s=yield this.listVideoInputDevices();return s?s.find(a=>a.deviceId===i):null})}decodeFromInputVideoDevice(i,s){return Ft(this,void 0,void 0,function*(){return yield this.decodeOnceFromVideoDevice(i,s)})}decodeOnceFromVideoDevice(i,s){return Ft(this,void 0,void 0,function*(){this.reset();let a;i?a={deviceId:{exact:i}}:a={facingMode:"environment"};const h={video:a};return yield this.decodeOnceFromConstraints(h,s)})}decodeOnceFromConstraints(i,s){return Ft(this,void 0,void 0,function*(){const a=yield navigator.mediaDevices.getUserMedia(i);return yield this.decodeOnceFromStream(a,s)})}decodeOnceFromStream(i,s){return Ft(this,void 0,void 0,function*(){this.reset();const a=yield this.attachStreamToVideo(i,s);return yield this.decodeOnce(a)})}decodeFromInputVideoDeviceContinuously(i,s,a){return Ft(this,void 0,void 0,function*(){return yield this.decodeFromVideoDevice(i,s,a)})}decodeFromVideoDevice(i,s,a){return Ft(this,void 0,void 0,function*(){let h;i?h={deviceId:{exact:i}}:h={facingMode:"environment"};const c={video:h};return yield this.decodeFromConstraints(c,s,a)})}decodeFromConstraints(i,s,a){return Ft(this,void 0,void 0,function*(){const h=yield navigator.mediaDevices.getUserMedia(i);return yield this.decodeFromStream(h,s,a)})}decodeFromStream(i,s,a){return Ft(this,void 0,void 0,function*(){this.reset();const h=yield this.attachStreamToVideo(i,s);return yield this.decodeContinuously(h,a)})}stopAsyncDecode(){this._stopAsyncDecode=!0}stopContinuousDecode(){this._stopContinuousDecode=!0}attachStreamToVideo(i,s){return Ft(this,void 0,void 0,function*(){const a=this.prepareVideoElement(s);return this.addVideoSource(a,i),this.videoElement=a,this.stream=i,yield this.playVideoOnLoadAsync(a),a})}playVideoOnLoadAsync(i){return new Promise((s,a)=>this.playVideoOnLoad(i,()=>s()))}playVideoOnLoad(i,s){this.videoEndedListener=()=>this.stopStreams(),this.videoCanPlayListener=()=>this.tryPlayVideo(i),i.addEventListener("ended",this.videoEndedListener),i.addEventListener("canplay",this.videoCanPlayListener),i.addEventListener("playing",s),this.tryPlayVideo(i)}isVideoPlaying(i){return i.currentTime>0&&!i.paused&&!i.ended&&i.readyState>2}tryPlayVideo(i){return Ft(this,void 0,void 0,function*(){if(this.isVideoPlaying(i)){console.warn("Trying to play video that is already playing.");return}try{yield i.play()}catch{console.warn("It was not possible to play the video.")}})}getMediaElement(i,s){const a=document.getElementById(i);if(!a)throw new w(`element with id '${i}' not found`);if(a.nodeName.toLowerCase()!==s.toLowerCase())throw new w(`element with id '${i}' must be an ${s} element`);return a}decodeFromImage(i,s){if(!i&&!s)throw new w("either imageElement with a src set or an url must be provided");return s&&!i?this.decodeFromImageUrl(s):this.decodeFromImageElement(i)}decodeFromVideo(i,s){if(!i&&!s)throw new w("Either an element with a src set or an URL must be provided");return s&&!i?this.decodeFromVideoUrl(s):this.decodeFromVideoElement(i)}decodeFromVideoContinuously(i,s,a){if(i===void 0&&s===void 0)throw new w("Either an element with a src set or an URL must be provided");return s&&!i?this.decodeFromVideoUrlContinuously(s,a):this.decodeFromVideoElementContinuously(i,a)}decodeFromImageElement(i){if(!i)throw new w("An image element must be provided.");this.reset();const s=this.prepareImageElement(i);this.imageElement=s;let a;return this.isImageLoaded(s)?a=this.decodeOnce(s,!1,!0):a=this._decodeOnLoadImage(s),a}decodeFromVideoElement(i){const s=this._decodeFromVideoElementSetup(i);return this._decodeOnLoadVideo(s)}decodeFromVideoElementContinuously(i,s){const a=this._decodeFromVideoElementSetup(i);return this._decodeOnLoadVideoContinuously(a,s)}_decodeFromVideoElementSetup(i){if(!i)throw new w("A video element must be provided.");this.reset();const s=this.prepareVideoElement(i);return this.videoElement=s,s}decodeFromImageUrl(i){if(!i)throw new w("An URL must be provided.");this.reset();const s=this.prepareImageElement();this.imageElement=s;const a=this._decodeOnLoadImage(s);return s.src=i,a}decodeFromVideoUrl(i){if(!i)throw new w("An URL must be provided.");this.reset();const s=this.prepareVideoElement(),a=this.decodeFromVideoElement(s);return s.src=i,a}decodeFromVideoUrlContinuously(i,s){if(!i)throw new w("An URL must be provided.");this.reset();const a=this.prepareVideoElement(),h=this.decodeFromVideoElementContinuously(a,s);return a.src=i,h}_decodeOnLoadImage(i){return new Promise((s,a)=>{this.imageLoadedListener=()=>this.decodeOnce(i,!1,!0).then(s,a),i.addEventListener("load",this.imageLoadedListener)})}_decodeOnLoadVideo(i){return Ft(this,void 0,void 0,function*(){return yield this.playVideoOnLoadAsync(i),yield this.decodeOnce(i)})}_decodeOnLoadVideoContinuously(i,s){return Ft(this,void 0,void 0,function*(){yield this.playVideoOnLoadAsync(i),this.decodeContinuously(i,s)})}isImageLoaded(i){return!(!i.complete||i.naturalWidth===0)}prepareImageElement(i){let s;return typeof i>"u"&&(s=document.createElement("img"),s.width=200,s.height=200),typeof i=="string"&&(s=this.getMediaElement(i,"img")),i instanceof HTMLImageElement&&(s=i),s}prepareVideoElement(i){let s;return!i&&typeof document<"u"&&(s=document.createElement("video"),s.width=200,s.height=200),typeof i=="string"&&(s=this.getMediaElement(i,"video")),i instanceof HTMLVideoElement&&(s=i),s.setAttribute("autoplay","true"),s.setAttribute("muted","true"),s.setAttribute("playsinline","true"),s}decodeOnce(i,s=!0,a=!0){this._stopAsyncDecode=!1;const h=(c,d)=>{if(this._stopAsyncDecode){d(new q("Video stream has ended before any code could be detected.")),this._stopAsyncDecode=void 0;return}try{const m=this.decode(i);c(m)}catch(m){const _=s&&m instanceof q,M=(m instanceof P||m instanceof X)&&a;if(_||M)return setTimeout(h,this._timeBetweenDecodingAttempts,c,d);d(m)}};return new Promise((c,d)=>h(c,d))}decodeContinuously(i,s){this._stopContinuousDecode=!1;const a=()=>{if(this._stopContinuousDecode){this._stopContinuousDecode=void 0;return}try{const h=this.decode(i);s(h,null),setTimeout(a,this.timeBetweenScansMillis)}catch(h){s(null,h);const c=h instanceof P||h instanceof X,d=h instanceof q;(c||d)&&setTimeout(a,this._timeBetweenDecodingAttempts)}};a()}decode(i){const s=this.createBinaryBitmap(i);return this.decodeBitmap(s)}_isHTMLVideoElement(i){return i.videoWidth!==0}drawFrameOnCanvas(i,s,a){s||(s={sx:0,sy:0,sWidth:i.videoWidth,sHeight:i.videoHeight,dx:0,dy:0,dWidth:i.videoWidth,dHeight:i.videoHeight}),a||(a=this.captureCanvasContext),a.drawImage(i,s.sx,s.sy,s.sWidth,s.sHeight,s.dx,s.dy,s.dWidth,s.dHeight)}drawImageOnCanvas(i,s,a=this.captureCanvasContext){s||(s={sx:0,sy:0,sWidth:i.naturalWidth,sHeight:i.naturalHeight,dx:0,dy:0,dWidth:i.naturalWidth,dHeight:i.naturalHeight}),a||(a=this.captureCanvasContext),a.drawImage(i,s.sx,s.sy,s.sWidth,s.sHeight,s.dx,s.dy,s.dWidth,s.dHeight)}createBinaryBitmap(i){this.getCaptureCanvasContext(i),this._isHTMLVideoElement(i)?this.drawFrameOnCanvas(i):this.drawImageOnCanvas(i);const s=this.getCaptureCanvas(i),a=new Gt(s),h=new yt(a);return new S(h)}getCaptureCanvasContext(i){if(!this.captureCanvasContext){const a=this.getCaptureCanvas(i).getContext("2d");this.captureCanvasContext=a}return this.captureCanvasContext}getCaptureCanvas(i){if(!this.captureCanvas){const s=this.createCaptureCanvas(i);this.captureCanvas=s}return this.captureCanvas}decodeBitmap(i){return this.reader.decode(i,this._hints)}createCaptureCanvas(i){if(typeof document>"u")return this._destroyCaptureCanvas(),null;const s=document.createElement("canvas");let a,h;return typeof i<"u"&&(i instanceof HTMLVideoElement?(a=i.videoWidth,h=i.videoHeight):i instanceof HTMLImageElement&&(a=i.naturalWidth||i.width,h=i.naturalHeight||i.height)),s.style.width=a+"px",s.style.height=h+"px",s.width=a,s.height=h,s}stopStreams(){this.stream&&(this.stream.getVideoTracks().forEach(i=>i.stop()),this.stream=void 0),this._stopAsyncDecode===!1&&this.stopAsyncDecode(),this._stopContinuousDecode===!1&&this.stopContinuousDecode()}reset(){this.stopStreams(),this._destroyVideoElement(),this._destroyImageElement(),this._destroyCaptureCanvas()}_destroyVideoElement(){this.videoElement&&(typeof this.videoEndedListener<"u"&&this.videoElement.removeEventListener("ended",this.videoEndedListener),typeof this.videoPlayingEventListener<"u"&&this.videoElement.removeEventListener("playing",this.videoPlayingEventListener),typeof this.videoCanPlayListener<"u"&&this.videoElement.removeEventListener("loadedmetadata",this.videoCanPlayListener),this.cleanVideoSource(this.videoElement),this.videoElement=void 0)}_destroyImageElement(){this.imageElement&&(this.imageLoadedListener!==void 0&&this.imageElement.removeEventListener("load",this.imageLoadedListener),this.imageElement.src=void 0,this.imageElement.removeAttribute("src"),this.imageElement=void 0)}_destroyCaptureCanvas(){this.captureCanvasContext=void 0,this.captureCanvas=void 0}addVideoSource(i,s){try{i.srcObject=s}catch{i.src=URL.createObjectURL(s)}}cleanVideoSource(i){try{i.srcObject=null}catch{i.src=""}this.videoElement.removeAttribute("src")}}class gt{constructor(i,s,a=s==null?0:8*s.length,h,c,d=F.currentTimeMillis()){this.text=i,this.rawBytes=s,this.numBits=a,this.resultPoints=h,this.format=c,this.timestamp=d,this.text=i,this.rawBytes=s,a==null?this.numBits=s==null?0:8*s.length:this.numBits=a,this.resultPoints=h,this.format=c,this.resultMetadata=null,d==null?this.timestamp=F.currentTimeMillis():this.timestamp=d}getText(){return this.text}getRawBytes(){return this.rawBytes}getNumBits(){return this.numBits}getResultPoints(){return this.resultPoints}getBarcodeFormat(){return this.format}getResultMetadata(){return this.resultMetadata}putMetadata(i,s){this.resultMetadata===null&&(this.resultMetadata=new Map),this.resultMetadata.set(i,s)}putAllMetadata(i){i!==null&&(this.resultMetadata===null?this.resultMetadata=i:this.resultMetadata=new Map(i))}addResultPoints(i){const s=this.resultPoints;if(s===null)this.resultPoints=i;else if(i!==null&&i.length>0){const a=new Array(s.length+i.length);F.arraycopy(s,0,a,0,s.length),F.arraycopy(i,0,a,s.length,i.length),this.resultPoints=a}}getTimestamp(){return this.timestamp}toString(){return this.text}}var ii;(function(T){T[T.AZTEC=0]="AZTEC",T[T.CODABAR=1]="CODABAR",T[T.CODE_39=2]="CODE_39",T[T.CODE_93=3]="CODE_93",T[T.CODE_128=4]="CODE_128",T[T.DATA_MATRIX=5]="DATA_MATRIX",T[T.EAN_8=6]="EAN_8",T[T.EAN_13=7]="EAN_13",T[T.ITF=8]="ITF",T[T.MAXICODE=9]="MAXICODE",T[T.PDF_417=10]="PDF_417",T[T.QR_CODE=11]="QR_CODE",T[T.RSS_14=12]="RSS_14",T[T.RSS_EXPANDED=13]="RSS_EXPANDED",T[T.UPC_A=14]="UPC_A",T[T.UPC_E=15]="UPC_E",T[T.UPC_EAN_EXTENSION=16]="UPC_EAN_EXTENSION"})(ii||(ii={}));var Rt=ii,Ne;(function(T){T[T.OTHER=0]="OTHER",T[T.ORIENTATION=1]="ORIENTATION",T[T.BYTE_SEGMENTS=2]="BYTE_SEGMENTS",T[T.ERROR_CORRECTION_LEVEL=3]="ERROR_CORRECTION_LEVEL",T[T.ISSUE_NUMBER=4]="ISSUE_NUMBER",T[T.SUGGESTED_PRICE=5]="SUGGESTED_PRICE",T[T.POSSIBLE_COUNTRY=6]="POSSIBLE_COUNTRY",T[T.UPC_EAN_EXTENSION=7]="UPC_EAN_EXTENSION",T[T.PDF417_EXTRA_METADATA=8]="PDF417_EXTRA_METADATA",T[T.STRUCTURED_APPEND_SEQUENCE=9]="STRUCTURED_APPEND_SEQUENCE",T[T.STRUCTURED_APPEND_PARITY=10]="STRUCTURED_APPEND_PARITY"})(Ne||(Ne={}));var ye=Ne;class mi{constructor(i,s,a,h,c=-1,d=-1){this.rawBytes=i,this.text=s,this.byteSegments=a,this.ecLevel=h,this.structuredAppendSequenceNumber=c,this.structuredAppendParity=d,this.numBits=i==null?0:8*i.length}getRawBytes(){return this.rawBytes}getNumBits(){return this.numBits}setNumBits(i){this.numBits=i}getText(){return this.text}getByteSegments(){return this.byteSegments}getECLevel(){return this.ecLevel}getErrorsCorrected(){return this.errorsCorrected}setErrorsCorrected(i){this.errorsCorrected=i}getErasures(){return this.erasures}setErasures(i){this.erasures=i}getOther(){return this.other}setOther(i){this.other=i}hasStructuredAppend(){return this.structuredAppendParity>=0&&this.structuredAppendSequenceNumber>=0}getStructuredAppendParity(){return this.structuredAppendParity}getStructuredAppendSequenceNumber(){return this.structuredAppendSequenceNumber}}class ke{exp(i){return this.expTable[i]}log(i){if(i===0)throw new A;return this.logTable[i]}static addOrSubtract(i,s){return i^s}}class Ke{constructor(i,s){if(s.length===0)throw new A;this.field=i;const a=s.length;if(a>1&&s[0]===0){let h=1;for(;ha.length){const d=s;s=a,a=d}let h=new Int32Array(a.length);const c=a.length-s.length;F.arraycopy(a,0,h,0,c);for(let d=c;d=i.getDegree()&&!h.isZero();){const m=h.getDegree()-i.getDegree(),_=s.multiply(h.getCoefficient(h.getDegree()),d),C=i.multiplyByMonomial(m,_),M=s.buildMonomial(m,_);a=a.addOrSubtract(M),h=h.addOrSubtract(C)}return[a,h]}toString(){let i="";for(let s=this.getDegree();s>=0;s--){let a=this.getCoefficient(s);if(a!==0){if(a<0?(i+=" - ",a=-a):i.length>0&&(i+=" + "),s===0||a!==1){const h=this.field.log(a);h===0?i+="1":h===1?i+="a":(i+="a^",i+=h)}s!==0&&(s===1?i+="x":(i+="x^",i+=s))}}return i}}class ze extends E{}ze.kind="ArithmeticException";class ne extends ke{constructor(i,s,a){super(),this.primitive=i,this.size=s,this.generatorBase=a;const h=new Int32Array(s);let c=1;for(let m=0;m=s&&(c^=i,c&=s-1);this.expTable=h;const d=new Int32Array(s);for(let m=0;m=(a/2|0);){let k=c,j=m;if(c=d,m=_,c.isZero())throw new xi("r_{i-1} was zero");d=k;let K=h.getZero();const tt=c.getCoefficient(c.getDegree()),st=h.inverse(tt);for(;d.getDegree()>=c.getDegree()&&!d.isZero();){const Et=d.getDegree()-c.getDegree(),At=h.multiply(d.getCoefficient(d.getDegree()),st);K=K.addOrSubtract(h.buildMonomial(Et,At)),d=d.addOrSubtract(c.multiplyByMonomial(Et,At))}if(_=K.multiply(m).addOrSubtract(j),d.getDegree()>=c.getDegree())throw new hi("Division algorithm failed to reduce polynomial?")}const C=_.getCoefficient(0);if(C===0)throw new xi("sigmaTilde(0) was zero");const M=h.inverse(C),R=_.multiplyScalar(M),D=d.multiplyScalar(M);return[R,D]}findErrorLocations(i){const s=i.getDegree();if(s===1)return Int32Array.from([i.getCoefficient(1)]);const a=new Int32Array(s);let h=0;const c=this.field;for(let d=1;d1,R,R+a-1),R+=a-1;else for(let j=a-1;j>=0;--j)M[R++]=(k&1<=8?he.readCode(i,s,8):he.readCode(i,s,a)<<8-a}static convertBoolArrayToByteArray(i){let s=new Uint8Array((i.length+7)/8);for(let a=0;a","?","[","]","{","}","CTRL_UL"],he.DIGIT_TABLE=["CTRL_PS"," ","0","1","2","3","4","5","6","7","8","9",",",".","CTRL_UL","CTRL_US"];class ee{constructor(){}static round(i){return i===NaN?0:i<=Number.MIN_SAFE_INTEGER?Number.MIN_SAFE_INTEGER:i>=Number.MAX_SAFE_INTEGER?Number.MAX_SAFE_INTEGER:i+(i<0?-.5:.5)|0}static distance(i,s,a,h){const c=i-a,d=s-h;return Math.sqrt(c*c+d*d)}static sum(i){let s=0;for(let a=0,h=i.length;a!==h;a++){const c=i[a];s+=c}return s}}class _i{static floatToIntBits(i){return i}}_i.MAX_VALUE=Number.MAX_SAFE_INTEGER;class St{constructor(i,s){this.x=i,this.y=s}getX(){return this.x}getY(){return this.y}equals(i){if(i instanceof St){const s=i;return this.x===s.x&&this.y===s.y}return!1}hashCode(){return 31*_i.floatToIntBits(this.x)+_i.floatToIntBits(this.y)}toString(){return"("+this.x+","+this.y+")"}static orderBestPatterns(i){const s=this.distance(i[0],i[1]),a=this.distance(i[1],i[2]),h=this.distance(i[0],i[2]);let c,d,m;if(a>=s&&a>=h?(d=i[0],c=i[1],m=i[2]):h>=a&&h>=s?(d=i[1],c=i[0],m=i[2]):(d=i[2],c=i[0],m=i[1]),this.crossProductZ(c,d,m)<0){const _=c;c=m,m=_}i[0]=c,i[1]=d,i[2]=m}static distance(i,s){return ee.distance(i.x,i.y,s.x,s.y)}static crossProductZ(i,s,a){const h=s.x,c=s.y;return(a.x-h)*(i.y-c)-(a.y-c)*(i.x-h)}}class Ci{constructor(i,s){this.bits=i,this.points=s}getBits(){return this.bits}getPoints(){return this.points}}class on extends Ci{constructor(i,s,a,h,c){super(i,s),this.compact=a,this.nbDatablocks=h,this.nbLayers=c}getNbLayers(){return this.nbLayers}getNbDatablocks(){return this.nbDatablocks}isCompact(){return this.compact}}class ci{constructor(i,s,a,h){this.image=i,this.height=i.getHeight(),this.width=i.getWidth(),s==null&&(s=ci.INIT_SIZE),a==null&&(a=i.getWidth()/2|0),h==null&&(h=i.getHeight()/2|0);const c=s/2|0;if(this.leftInit=a-c,this.rightInit=a+c,this.upInit=h-c,this.downInit=h+c,this.upInit<0||this.leftInit<0||this.downInit>=this.height||this.rightInit>=this.width)throw new q}detect(){let i=this.leftInit,s=this.rightInit,a=this.upInit,h=this.downInit,c=!1,d=!0,m=!1,_=!1,C=!1,M=!1,R=!1;const D=this.width,k=this.height;for(;d;){d=!1;let j=!0;for(;(j||!_)&&s=D){c=!0;break}let K=!0;for(;(K||!C)&&h=k){c=!0;break}let tt=!0;for(;(tt||!M)&&i>=0;)tt=this.containsBlackPoint(a,h,i,!1),tt?(i--,d=!0,M=!0):M||i--;if(i<0){c=!0;break}let st=!0;for(;(st||!R)&&a>=0;)st=this.containsBlackPoint(i,s,a,!0),st?(a--,d=!0,R=!0):R||a--;if(a<0){c=!0;break}d&&(m=!0)}if(!c&&m){const j=s-i;let K=null;for(let At=1;K===null&&Ata||_<-1||_>h)throw new q;c=!1,m===-1?(s[d]=0,c=!0):m===a&&(s[d]=a-1,c=!0),_===-1?(s[d+1]=0,c=!0):_===h&&(s[d+1]=h-1,c=!0)}c=!0;for(let d=s.length-2;d>=0&&c;d-=2){const m=Math.floor(s[d]),_=Math.floor(s[d+1]);if(m<-1||m>a||_<-1||_>h)throw new q;c=!1,m===-1?(s[d]=0,c=!0):m===a&&(s[d]=a-1,c=!0),_===-1?(s[d+1]=0,c=!0):_===h&&(s[d+1]=h-1,c=!0)}}}class ni{constructor(i,s,a,h,c,d,m,_,C){this.a11=i,this.a21=s,this.a31=a,this.a12=h,this.a22=c,this.a32=d,this.a13=m,this.a23=_,this.a33=C}static quadrilateralToQuadrilateral(i,s,a,h,c,d,m,_,C,M,R,D,k,j,K,tt){const st=ni.quadrilateralToSquare(i,s,a,h,c,d,m,_);return ni.squareToQuadrilateral(C,M,R,D,k,j,K,tt).times(st)}transformPoints(i){const s=i.length,a=this.a11,h=this.a12,c=this.a13,d=this.a21,m=this.a22,_=this.a23,C=this.a31,M=this.a32,R=this.a33;for(let D=0;D>1&127):(h<<=10,h+=(m>>2&992)+(m>>1&31))}let c=this.getCorrectedParameterData(h,this.compact);this.compact?(this.nbLayers=(c>>6)+1,this.nbDataBlocks=(c&63)+1):(this.nbLayers=(c>>11)+1,this.nbDataBlocks=(c&2047)+1)}getRotation(i,s){let a=0;i.forEach((h,c,d)=>{let m=(h>>s-2<<1)+(h&1);a=(a<<3)+m}),a=((a&1)<<11)+(a>>1);for(let h=0;h<4;h++)if(Y.bitCount(a^this.EXPECTED_CORNER_BITS[h])<=2)return h;throw new q}getCorrectedParameterData(i,s){let a,h;s?(a=7,h=2):(a=10,h=4);let c=a-h,d=new Int32Array(a);for(let _=a-1;_>=0;--_)d[_]=i&15,i>>=4;try{new Ei(ne.AZTEC_PARAM).decode(d,c)}catch{throw new q}let m=0;for(let _=0;_2){let K=this.distancePoint(j,R)*this.nbCenterLayers/(this.distancePoint(c,s)*(this.nbCenterLayers+2));if(K<.75||K>1.25||!this.isWhiteOrBlackRectangle(R,D,k,j))break}s=R,a=D,h=k,c=j,d=!d}if(this.nbCenterLayers!==5&&this.nbCenterLayers!==7)throw new q;this.compact=this.nbCenterLayers===5;let m=new St(s.getX()+.5,s.getY()-.5),_=new St(a.getX()+.5,a.getY()+.5),C=new St(h.getX()-.5,h.getY()+.5),M=new St(c.getX()-.5,c.getY()-.5);return this.expandSquare([m,_,C,M],2*this.nbCenterLayers-3,2*this.nbCenterLayers)}getMatrixCenter(){let i,s,a,h;try{let m=new ci(this.image).detect();i=m[0],s=m[1],a=m[2],h=m[3]}catch{let _=this.image.getWidth()/2,C=this.image.getHeight()/2;i=this.getFirstDifferent(new ce(_+7,C-7),!1,1,-1).toResultPoint(),s=this.getFirstDifferent(new ce(_+7,C+7),!1,1,1).toResultPoint(),a=this.getFirstDifferent(new ce(_-7,C+7),!1,-1,1).toResultPoint(),h=this.getFirstDifferent(new ce(_-7,C-7),!1,-1,-1).toResultPoint()}let c=ee.round((i.getX()+h.getX()+s.getX()+a.getX())/4),d=ee.round((i.getY()+h.getY()+s.getY()+a.getY())/4);try{let m=new ci(this.image,15,c,d).detect();i=m[0],s=m[1],a=m[2],h=m[3]}catch{i=this.getFirstDifferent(new ce(c+7,d-7),!1,1,-1).toResultPoint(),s=this.getFirstDifferent(new ce(c+7,d+7),!1,1,1).toResultPoint(),a=this.getFirstDifferent(new ce(c-7,d+7),!1,-1,1).toResultPoint(),h=this.getFirstDifferent(new ce(c-7,d-7),!1,-1,-1).toResultPoint()}return c=ee.round((i.getX()+h.getX()+s.getX()+a.getX())/4),d=ee.round((i.getY()+h.getY()+s.getY()+a.getY())/4),new ce(c,d)}getMatrixCornerPoints(i){return this.expandSquare(i,2*this.nbCenterLayers,this.getDimension())}sampleGrid(i,s,a,h,c){let d=qe.getInstance(),m=this.getDimension(),_=m/2-this.nbCenterLayers,C=m/2+this.nbCenterLayers;return d.sampleGrid(i,m,m,_,_,C,_,C,C,_,C,s.getX(),s.getY(),a.getX(),a.getY(),h.getX(),h.getY(),c.getX(),c.getY())}sampleLine(i,s,a){let h=0,c=this.distanceResultPoint(i,s),d=c/a,m=i.getX(),_=i.getY(),C=d*(s.getX()-i.getX())/c,M=d*(s.getY()-i.getY())/c;for(let R=0;R.1&&R<.9?0:R<=.1===C?1:-1}getFirstDifferent(i,s,a,h){let c=i.getX()+a,d=i.getY()+h;for(;this.isValid(c,d)&&this.image.get(c,d)===s;)c+=a,d+=h;for(c-=a,d-=h;this.isValid(c,d)&&this.image.get(c,d)===s;)c+=a;for(c-=a;this.isValid(c,d)&&this.image.get(c,d)===s;)d+=h;return d-=h,new ce(c,d)}expandSquare(i,s,a){let h=a/(2*s),c=i[0].getX()-i[2].getX(),d=i[0].getY()-i[2].getY(),m=(i[0].getX()+i[2].getX())/2,_=(i[0].getY()+i[2].getY())/2,C=new St(m+h*c,_+h*d),M=new St(m-h*c,_-h*d);c=i[1].getX()-i[3].getX(),d=i[1].getY()-i[3].getY(),m=(i[1].getX()+i[3].getX())/2,_=(i[1].getY()+i[3].getY())/2;let R=new St(m+h*c,_+h*d),D=new St(m-h*c,_-h*d);return[C,R,M,D]}isValid(i,s){return i>=0&&i0&&s{a.foundPossibleResultPoint(h)})}}reset(){}}class Vn extends te{constructor(i=500){super(new Xn,i)}}class Ae{decode(i,s){try{return this.doDecode(i,s)}catch{if(s&&s.get(ot.TRY_HARDER)===!0&&i.isRotateSupported()){const c=i.rotateCounterClockwise(),d=this.doDecode(c,s),m=d.getResultMetadata();let _=270;m!==null&&m.get(ye.ORIENTATION)===!0&&(_=_+m.get(ye.ORIENTATION)%360),d.putMetadata(ye.ORIENTATION,_);const C=d.getResultPoints();if(C!==null){const M=c.getHeight();for(let R=0;R>(d?8:5));let _;d?_=h:_=15;const C=Math.trunc(h/2);for(let M=0;M<_;M++){const R=Math.trunc((M+1)/2),D=(M&1)===0,k=C+m*(D?R:-R);if(k<0||k>=h)break;try{c=i.getBlackRow(k,c)}catch{continue}for(let j=0;j<2;j++){if(j===1&&(c.reverse(),s&&s.get(ot.NEED_RESULT_POINT_CALLBACK)===!0)){const K=new Map;s.forEach((tt,st)=>K.set(st,tt)),K.delete(ot.NEED_RESULT_POINT_CALLBACK),s=K}try{const K=this.decodeRow(k,c,s);if(j===1){K.putMetadata(ye.ORIENTATION,180);const tt=K.getResultPoints();tt!==null&&(tt[0]=new St(a-tt[0].getX()-1,tt[0].getY()),tt[1]=new St(a-tt[1].getX()-1,tt[1].getY()))}return K}catch{}}}throw new q}static recordPattern(i,s,a){const h=a.length;for(let C=0;C=c)throw new q;let d=!i.get(s),m=0,_=s;for(;_0&&h>=0;)i.get(--s)!==c&&(h--,c=!c);if(h>=0)throw new q;Ae.recordPattern(i,s+1,a)}static patternMatchVariance(i,s,a){const h=i.length;let c=0,d=0;for(let C=0;CR?M-R:R-M;if(D>a)return Number.POSITIVE_INFINITY;_+=D}return _/c}}class It extends Ae{static findStartPattern(i){const s=i.getSize(),a=i.getNextSet(0);let h=0,c=Int32Array.from([0,0,0,0,0,0]),d=a,m=!1;const _=6;for(let C=a;C=0&&i.isRange(Math.max(0,d-(C-d)/2),d,!1))return Int32Array.from([d,C,R]);d+=c[0]+c[1],c=c.slice(2,c.length-1),c[h-1]=0,c[h]=0,h--}else h++;c[h]=1,m=!m}throw new q}static decodeCode(i,s,a){Ae.recordPattern(i,a,s);let h=It.MAX_AVG_VARIANCE,c=-1;for(let d=0;d=0)return c;throw new q}decodeRow(i,s,a){const h=a&&a.get(ot.ASSUME_GS1)===!0,c=It.findStartPattern(s),d=c[2];let m=0;const _=new Uint8Array(20);_[m++]=d;let C;switch(d){case It.CODE_START_A:C=It.CODE_CODE_A;break;case It.CODE_START_B:C=It.CODE_CODE_B;break;case It.CODE_START_C:C=It.CODE_CODE_C;break;default:throw new X}let M=!1,R=!1,D="",k=c[0],j=c[1];const K=Int32Array.from([0,0,0,0,0,0]);let tt=0,st=0,Et=d,At=0,mt=!0,le=!1,Kt=!1;for(;!M;){const _r=R;switch(R=!1,tt=st,st=It.decodeCode(s,K,j),_[m++]=st,st!==It.CODE_STOP&&(mt=!0),st!==It.CODE_STOP&&(At++,Et+=At*st),k=j,j+=K.reduce((Y1,H1)=>Y1+H1,0),st){case It.CODE_START_A:case It.CODE_START_B:case It.CODE_START_C:throw new X}switch(C){case It.CODE_CODE_A:if(st<64)Kt===le?D+=String.fromCharCode(32+st):D+=String.fromCharCode(32+st+128),Kt=!1;else if(st<96)Kt===le?D+=String.fromCharCode(st-64):D+=String.fromCharCode(st+64),Kt=!1;else switch(st!==It.CODE_STOP&&(mt=!1),st){case It.CODE_FNC_1:h&&(D.length===0?D+="]C1":D+="");break;case It.CODE_FNC_2:case It.CODE_FNC_3:break;case It.CODE_FNC_4_A:!le&&Kt?(le=!0,Kt=!1):le&&Kt?(le=!1,Kt=!1):Kt=!0;break;case It.CODE_SHIFT:R=!0,C=It.CODE_CODE_B;break;case It.CODE_CODE_B:C=It.CODE_CODE_B;break;case It.CODE_CODE_C:C=It.CODE_CODE_C;break;case It.CODE_STOP:M=!0;break}break;case It.CODE_CODE_B:if(st<96)Kt===le?D+=String.fromCharCode(32+st):D+=String.fromCharCode(32+st+128),Kt=!1;else switch(st!==It.CODE_STOP&&(mt=!1),st){case It.CODE_FNC_1:h&&(D.length===0?D+="]C1":D+="");break;case It.CODE_FNC_2:case It.CODE_FNC_3:break;case It.CODE_FNC_4_B:!le&&Kt?(le=!0,Kt=!1):le&&Kt?(le=!1,Kt=!1):Kt=!0;break;case It.CODE_SHIFT:R=!0,C=It.CODE_CODE_A;break;case It.CODE_CODE_A:C=It.CODE_CODE_A;break;case It.CODE_CODE_C:C=It.CODE_CODE_C;break;case It.CODE_STOP:M=!0;break}break;case It.CODE_CODE_C:if(st<100)st<10&&(D+="0"),D+=st;else switch(st!==It.CODE_STOP&&(mt=!1),st){case It.CODE_FNC_1:h&&(D.length===0?D+="]C1":D+="");break;case It.CODE_CODE_A:C=It.CODE_CODE_A;break;case It.CODE_CODE_B:C=It.CODE_CODE_B;break;case It.CODE_STOP:M=!0;break}break}_r&&(C=C===It.CODE_CODE_A?It.CODE_CODE_B:It.CODE_CODE_A)}const Xi=j-k;if(j=s.getNextUnset(j),!s.isRange(j,Math.min(s.getSize(),j+(j-k)/2),!1))throw new q;if(Et-=At*tt,Et%103!==tt)throw new P;const Cn=D.length;if(Cn===0)throw new q;Cn>0&&mt&&(C===It.CODE_CODE_C?D=D.substring(0,Cn-2):D=D.substring(0,Cn-1));const Vi=(c[1]+c[0])/2,De=k+Xi/2,Mi=_.length,tn=new Uint8Array(Mi);for(let _r=0;_ra&&(c=_);a=c,h=0;let d=0,m=0;for(let _=0;_a&&(m|=1<0;_++){let C=i[_];if(C>a&&(h--,C*2>=d))return-1}return m}}while(h>3);return-1}static patternToChar(i){for(let s=0;s="A"&&d<="Z")m=String.fromCharCode(d.charCodeAt(0)+32);else throw new X;break;case"$":if(d>="A"&&d<="Z")m=String.fromCharCode(d.charCodeAt(0)-64);else throw new X;break;case"%":if(d>="A"&&d<="E")m=String.fromCharCode(d.charCodeAt(0)-38);else if(d>="F"&&d<="J")m=String.fromCharCode(d.charCodeAt(0)-11);else if(d>="K"&&d<="O")m=String.fromCharCode(d.charCodeAt(0)+16);else if(d>="P"&&d<="T")m=String.fromCharCode(d.charCodeAt(0)+43);else if(d==="U")m="\0";else if(d==="V")m="@";else if(d==="W")m="`";else if(d==="X"||d==="Y"||d==="Z")m="";else throw new X;break;case"/":if(d>="A"&&d<="O")m=String.fromCharCode(d.charCodeAt(0)-32);else if(d==="Z")m=":";else throw new X;break}a+=m,h++}else a+=c}return a}}Te.ALPHABET_STRING="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%",Te.CHARACTER_ENCODINGS=[52,289,97,352,49,304,112,37,292,100,265,73,328,25,280,88,13,268,76,28,259,67,322,19,274,82,7,262,70,22,385,193,448,145,400,208,133,388,196,168,162,138,42],Te.ASTERISK_ENCODING=148;class se extends Ae{constructor(){super(...arguments),this.narrowLineWidth=-1}decodeRow(i,s,a){let h=this.decodeStart(s),c=this.decodeEnd(s),d=new ut;se.decodeMiddle(s,h[1],c[0],d);let m=d.toString(),_=null;a!=null&&(_=a.get(ot.ALLOWED_LENGTHS)),_==null&&(_=se.DEFAULT_ALLOWED_LENGTHS);let C=m.length,M=!1,R=0;for(let j of _){if(C===j){M=!0;break}j>R&&(R=j)}if(!M&&C>R&&(M=!0),!M)throw new X;const D=[new St(h[1],i),new St(c[0],i)];return new gt(m,null,0,D,Rt.ITF,new Date().getTime())}static decodeMiddle(i,s,a,h){let c=new Int32Array(10),d=new Int32Array(5),m=new Int32Array(5);for(c.fill(0),d.fill(0),m.fill(0);s0&&h>=0&&!i.get(h);h--)a--;if(a!==0)throw new q}static skipWhiteSpace(i){const s=i.getSize(),a=i.getNextSet(0);if(a===s)throw new q;return a}decodeEnd(i){i.reverse();try{let s=se.skipWhiteSpace(i),a;try{a=se.findGuardPattern(i,s,se.END_PATTERN_REVERSED[0])}catch(c){c instanceof q&&(a=se.findGuardPattern(i,s,se.END_PATTERN_REVERSED[1]))}this.validateQuietZone(i,a[0]);let h=a[0];return a[0]=i.getSize()-a[1],a[1]=i.getSize()-h,a}finally{i.reverse()}}static findGuardPattern(i,s,a){let h=a.length,c=new Int32Array(h),d=i.getSize(),m=!1,_=0,C=s;c.fill(0);for(let M=s;M=0)return a%10;throw new q}}se.PATTERNS=[Int32Array.from([1,1,2,2,1]),Int32Array.from([2,1,1,1,2]),Int32Array.from([1,2,1,1,2]),Int32Array.from([2,2,1,1,1]),Int32Array.from([1,1,2,1,2]),Int32Array.from([2,1,2,1,1]),Int32Array.from([1,2,2,1,1]),Int32Array.from([1,1,1,2,2]),Int32Array.from([2,1,1,2,1]),Int32Array.from([1,2,1,2,1]),Int32Array.from([1,1,3,3,1]),Int32Array.from([3,1,1,1,3]),Int32Array.from([1,3,1,1,3]),Int32Array.from([3,3,1,1,1]),Int32Array.from([1,1,3,1,3]),Int32Array.from([3,1,3,1,1]),Int32Array.from([1,3,3,1,1]),Int32Array.from([1,1,1,3,3]),Int32Array.from([3,1,1,3,1]),Int32Array.from([1,3,1,3,1])],se.MAX_AVG_VARIANCE=.38,se.MAX_INDIVIDUAL_VARIANCE=.5,se.DEFAULT_ALLOWED_LENGTHS=[6,8,10,12,14],se.START_PATTERN=Int32Array.from([1,1,1,1]),se.END_PATTERN_REVERSED=[Int32Array.from([1,1,2]),Int32Array.from([1,1,3])];class we extends Ae{constructor(){super(...arguments),this.decodeRowStringBuffer=""}static findStartGuardPattern(i){let s=!1,a,h=0,c=Int32Array.from([0,0,0]);for(;!s;){c=Int32Array.from([0,0,0]),a=we.findGuardPattern(i,h,!1,this.START_END_PATTERN,c);let d=a[0];h=a[1];let m=d-(h-d);m>=0&&(s=i.isRange(m,d,!1))}return a}static checkChecksum(i){return we.checkStandardUPCEANChecksum(i)}static checkStandardUPCEANChecksum(i){let s=i.length;if(s===0)return!1;let a=parseInt(i.charAt(s-1),10);return we.getStandardUPCEANChecksum(i.substring(0,s-1))===a}static getStandardUPCEANChecksum(i){let s=i.length,a=0;for(let h=s-1;h>=0;h-=2){let c=i.charAt(h).charCodeAt(0)-48;if(c<0||c>9)throw new X;a+=c}a*=3;for(let h=s-2;h>=0;h-=2){let c=i.charAt(h).charCodeAt(0)-48;if(c<0||c>9)throw new X;a+=c}return(1e3-a)%10}static decodeEnd(i,s){return we.findGuardPattern(i,s,!1,we.START_END_PATTERN,new Int32Array(we.START_END_PATTERN.length).fill(0))}static findGuardPatternWithoutCounters(i,s,a,h){return this.findGuardPattern(i,s,a,h,new Int32Array(h.length))}static findGuardPattern(i,s,a,h,c){let d=i.getSize();s=a?i.getNextUnset(s):i.getNextSet(s);let m=0,_=s,C=h.length,M=a;for(let R=s;R=0)return d;throw new q}}we.MAX_AVG_VARIANCE=.48,we.MAX_INDIVIDUAL_VARIANCE=.7,we.START_END_PATTERN=Int32Array.from([1,1,1]),we.MIDDLE_PATTERN=Int32Array.from([1,1,1,1,1]),we.END_PATTERN=Int32Array.from([1,1,1,1,1,1]),we.L_PATTERNS=[Int32Array.from([3,2,1,1]),Int32Array.from([2,2,2,1]),Int32Array.from([2,1,2,2]),Int32Array.from([1,4,1,1]),Int32Array.from([1,1,3,2]),Int32Array.from([1,2,3,1]),Int32Array.from([1,1,1,4]),Int32Array.from([1,3,1,2]),Int32Array.from([1,2,1,3]),Int32Array.from([3,1,1,2])];class xn{constructor(){this.CHECK_DIGIT_ENCODINGS=[24,20,18,17,12,6,3,10,9,5],this.decodeMiddleCounters=Int32Array.from([0,0,0,0]),this.decodeRowStringBuffer=""}decodeRow(i,s,a){let h=this.decodeRowStringBuffer,c=this.decodeMiddle(s,a,h),d=h.toString(),m=xn.parseExtensionString(d),_=[new St((a[0]+a[1])/2,i),new St(c,i)],C=new gt(d,null,0,_,Rt.UPC_EAN_EXTENSION,new Date().getTime());return m!=null&&C.putAllMetadata(m),C}decodeMiddle(i,s,a){let h=this.decodeMiddleCounters;h[0]=0,h[1]=0,h[2]=0,h[3]=0;let c=i.getSize(),d=s[1],m=0;for(let C=0;C<5&&d=10&&(m|=1<<4-C),C!==4&&(d=i.getNextSet(d),d=i.getNextUnset(d))}if(a.length!==5)throw new q;let _=this.determineCheckDigit(m);if(xn.extensionChecksum(a.toString())!==_)throw new q;return d}static extensionChecksum(i){let s=i.length,a=0;for(let h=s-2;h>=0;h-=2)a+=i.charAt(h).charCodeAt(0)-48;a*=3;for(let h=s-1;h>=0;h-=2)a+=i.charAt(h).charCodeAt(0)-48;return a*=3,a%10}determineCheckDigit(i){for(let s=0;s<10;s++)if(i===this.CHECK_DIGIT_ENCODINGS[s])return s;throw new q}static parseExtensionString(i){if(i.length!==5)return null;let s=xn.parseExtension5String(i);return s==null?null:new Map([[ye.SUGGESTED_PRICE,s]])}static parseExtension5String(i){let s;switch(i.charAt(0)){case"0":s="£";break;case"5":s="$";break;case"9":switch(i){case"90000":return null;case"99991":return"0.00";case"99990":return"Used"}s="";break;default:s="";break}let a=parseInt(i.substring(1)),h=(a/100).toString(),c=a%100,d=c<10?"0"+c:c.toString();return s+h+"."+d}}class vn{constructor(){this.decodeMiddleCounters=Int32Array.from([0,0,0,0]),this.decodeRowStringBuffer=""}decodeRow(i,s,a){let h=this.decodeRowStringBuffer,c=this.decodeMiddle(s,a,h),d=h.toString(),m=vn.parseExtensionString(d),_=[new St((a[0]+a[1])/2,i),new St(c,i)],C=new gt(d,null,0,_,Rt.UPC_EAN_EXTENSION,new Date().getTime());return m!=null&&C.putAllMetadata(m),C}decodeMiddle(i,s,a){let h=this.decodeMiddleCounters;h[0]=0,h[1]=0,h[2]=0,h[3]=0;let c=i.getSize(),d=s[1],m=0;for(let _=0;_<2&&d=10&&(m|=1<<1-_),_!==1&&(d=i.getNextSet(d),d=i.getNextUnset(d))}if(a.length!==2)throw new q;if(parseInt(a.toString())%4!==m)throw new q;return d}static parseExtensionString(i){return i.length!==2?null:new Map([[ye.ISSUE_NUMBER,parseInt(i)]])}}class an{static decodeRow(i,s,a){let h=we.findGuardPattern(s,a,!1,this.EXTENSION_START_PATTERN,new Int32Array(this.EXTENSION_START_PATTERN.length).fill(0));try{return new xn().decodeRow(i,s,h)}catch{return new vn().decodeRow(i,s,h)}}}an.EXTENSION_START_PATTERN=Int32Array.from([1,1,2]);class ht extends we{constructor(){super(),this.decodeRowStringBuffer="",ht.L_AND_G_PATTERNS=ht.L_PATTERNS.map(i=>Int32Array.from(i));for(let i=10;i<20;i++){let s=ht.L_PATTERNS[i-10],a=new Int32Array(s.length);for(let h=0;h=s.getSize()||!s.isRange(M,R,!1))throw new q;let D=_.toString();if(D.length<8)throw new X;if(!ht.checkChecksum(D))throw new P;let k=(h[1]+h[0])/2,j=(C[1]+C[0])/2,K=this.getBarcodeFormat(),tt=[new St(k,i),new St(j,i)],st=new gt(D,null,0,tt,K,new Date().getTime()),Et=0;try{let mt=an.decodeRow(i,s,C[1]);st.putMetadata(ye.UPC_EAN_EXTENSION,mt.getText()),st.putAllMetadata(mt.getResultMetadata()),st.addResultPoints(mt.getResultPoints()),Et=mt.getText().length}catch{}let At=a==null?null:a.get(ot.ALLOWED_EAN_EXTENSIONS);if(At!=null){let mt=!1;for(let le in At)if(Et.toString()===le){mt=!0;break}if(!mt)throw new q}return st}decodeEnd(i,s){return ht.findGuardPattern(i,s,!1,ht.START_END_PATTERN,new Int32Array(ht.START_END_PATTERN.length).fill(0))}static checkChecksum(i){return ht.checkStandardUPCEANChecksum(i)}static checkStandardUPCEANChecksum(i){let s=i.length;if(s===0)return!1;let a=parseInt(i.charAt(s-1),10);return ht.getStandardUPCEANChecksum(i.substring(0,s-1))===a}static getStandardUPCEANChecksum(i){let s=i.length,a=0;for(let h=s-1;h>=0;h-=2){let c=i.charAt(h).charCodeAt(0)-48;if(c<0||c>9)throw new X;a+=c}a*=3;for(let h=s-2;h>=0;h-=2){let c=i.charAt(h).charCodeAt(0)-48;if(c<0||c>9)throw new X;a+=c}return(1e3-a)%10}}class Gi extends ht{constructor(){super(),this.decodeMiddleCounters=Int32Array.from([0,0,0,0])}decodeMiddle(i,s,a){let h=this.decodeMiddleCounters;h[0]=0,h[1]=0,h[2]=0,h[3]=0;let c=i.getSize(),d=s[1],m=0;for(let C=0;C<6&&d=10&&(m|=1<<5-C)}a=Gi.determineFirstDigit(a,m),d=ht.findGuardPattern(i,d,!0,ht.MIDDLE_PATTERN,new Int32Array(ht.MIDDLE_PATTERN.length).fill(0))[1];for(let C=0;C<6&&dC);h[0]=0,h[1]=0,h[2]=0,h[3]=0;const c=i.getSize();let d=s[1],m=0;for(let C=0;C<6&&d=10&&(m|=1<<5-C)}let _=Ct.determineNumSysAndCheckDigit(a,m);return{rowOffset:d,resultString:_}}decodeEnd(i,s){return Ct.findGuardPatternWithoutCounters(i,s,!0,Ct.MIDDLE_END_PATTERN)}checkChecksum(i){return ht.checkChecksum(Ct.convertUPCEtoUPCA(i))}static determineNumSysAndCheckDigit(i,s){for(let a=0;a<=1;a++)for(let h=0;h<10;h++)if(s===this.NUMSYS_AND_CHECK_DIGIT_PATTERNS[a][h]){let c=String.fromCharCode(48+a),d=String.fromCharCode(48+h);return c+i+d}throw q.getNotFoundInstance()}getBarcodeFormat(){return Rt.UPC_E}static convertUPCEtoUPCA(i){const s=i.slice(1,7).split("").map(c=>c.charCodeAt(0)),a=new ut;a.append(i.charAt(0));let h=s[5];switch(h){case 0:case 1:case 2:a.appendChars(s,0,2),a.append(h),a.append("0000"),a.appendChars(s,2,3);break;case 3:a.appendChars(s,0,3),a.append("00000"),a.appendChars(s,3,2);break;case 4:a.appendChars(s,0,4),a.append("00000"),a.append(s[4]);break;default:a.appendChars(s,0,5),a.append("0000"),a.append(h);break}return i.length>=8&&a.append(i.charAt(7)),a.toString()}}Ct.MIDDLE_END_PATTERN=Int32Array.from([1,1,1,1,1,1]),Ct.NUMSYS_AND_CHECK_DIGIT_PATTERNS=[Int32Array.from([56,52,50,49,44,38,35,42,41,37]),Int32Array.from([7,11,13,14,19,25,28,21,22,26])];class fe extends Ae{constructor(i){super();let s=i==null?null:i.get(ot.POSSIBLE_FORMATS),a=[];n(s)?(a.push(new Gi),a.push(new Bs),a.push(new On),a.push(new Ct)):(s.indexOf(Rt.EAN_13)>-1&&a.push(new Gi),s.indexOf(Rt.UPC_A)>-1&&a.push(new Bs),s.indexOf(Rt.EAN_8)>-1&&a.push(new On),s.indexOf(Rt.UPC_E)>-1&&a.push(new Ct)),this.readers=a}decodeRow(i,s,a){for(let h of this.readers)try{const c=h.decodeRow(i,s,a),d=c.getBarcodeFormat()===Rt.EAN_13&&c.getText().charAt(0)==="0",m=a==null?null:a.get(ot.POSSIBLE_FORMATS),_=m==null||m.includes(Rt.UPC_A);if(d&&_){const C=c.getRawBytes(),M=new gt(c.getText().substring(1),C,C?C.length:null,c.getResultPoints(),Rt.UPC_A);return M.putAllMetadata(c.getResultMetadata()),M}return c}catch{}throw new q}reset(){for(let i of this.readers)i.reset()}}class ue extends Ae{constructor(){super(),this.decodeFinderCounters=new Int32Array(4),this.dataCharacterCounters=new Int32Array(8),this.oddRoundingErrors=new Array(4),this.evenRoundingErrors=new Array(4),this.oddCounts=new Array(this.dataCharacterCounters.length/2),this.evenCounts=new Array(this.dataCharacterCounters.length/2)}getDecodeFinderCounters(){return this.decodeFinderCounters}getDataCharacterCounters(){return this.dataCharacterCounters}getOddRoundingErrors(){return this.oddRoundingErrors}getEvenRoundingErrors(){return this.evenRoundingErrors}getOddCounts(){return this.oddCounts}getEvenCounts(){return this.evenCounts}parseFinderValue(i,s){for(let a=0;ah&&(h=s[c],a=c);i[a]++}static decrement(i,s){let a=0,h=s[0];for(let c=1;c=ue.MIN_FINDER_PATTERN_RATIO&&h<=ue.MAX_FINDER_PATTERN_RATIO){let c=Number.MAX_SAFE_INTEGER,d=Number.MIN_SAFE_INTEGER;for(let m of i)m>d&&(d=m),m=m-_-1&&(M-=Vt.combins(h-C-(m-_),m-_-2)),m-_-1>1){let R=0;for(let D=h-C-(m-_-2);D>s;D--)R+=Vt.combins(h-C-D-1,m-_-3);M-=R*(m-1-_)}else h-C>s&&M--;c+=M}h-=C}return c}static combins(i,s){let a,h;i-s>s?(h=s,a=i-s):(h=i-s,a=s);let c=1,d=1;for(let m=i;m>a;m--)c*=m,d<=h&&(c/=d,d++);for(;d<=h;)c/=d,d++;return c}}class Le{static buildBitArray(i){let s=i.length*2-1;i[i.length-1].getRightChar()==null&&(s-=1);let a=12*s,h=new Z(a),c=0,m=i[0].getRightChar().getValue();for(let _=11;_>=0;--_)m&1<<_&&h.set(c),c++;for(let _=1;_=0;--R)M&1<=0;--D)R&1<10||a<0||a>10)throw new X;this.firstDigit=s,this.secondDigit=a}getFirstDigit(){return this.firstDigit}getSecondDigit(){return this.secondDigit}getValue(){return this.firstDigit*10+this.secondDigit}isFirstDigitFNC1(){return this.firstDigit===Ri.FNC1}isSecondDigitFNC1(){return this.secondDigit===Ri.FNC1}isAnyFNC1(){return this.firstDigit===Ri.FNC1||this.secondDigit===Ri.FNC1}}Ri.FNC1=10;class vt{constructor(){}static parseFieldsInGeneralPurpose(i){if(!i)return null;if(i.length<2)throw new q;let s=i.substring(0,2);for(let c of vt.TWO_DIGIT_DATA_LENGTH)if(c[0]===s)return c[1]===vt.VARIABLE_LENGTH?vt.processVariableAI(2,c[2],i):vt.processFixedAI(2,c[1],i);if(i.length<3)throw new q;let a=i.substring(0,3);for(let c of vt.THREE_DIGIT_DATA_LENGTH)if(c[0]===a)return c[1]===vt.VARIABLE_LENGTH?vt.processVariableAI(3,c[2],i):vt.processFixedAI(3,c[1],i);for(let c of vt.THREE_DIGIT_PLUS_DIGIT_DATA_LENGTH)if(c[0]===a)return c[1]===vt.VARIABLE_LENGTH?vt.processVariableAI(4,c[2],i):vt.processFixedAI(4,c[1],i);if(i.length<4)throw new q;let h=i.substring(0,4);for(let c of vt.FOUR_DIGIT_DATA_LENGTH)if(c[0]===h)return c[1]===vt.VARIABLE_LENGTH?vt.processVariableAI(4,c[2],i):vt.processFixedAI(4,c[1],i);throw new q}static processFixedAI(i,s,a){if(a.lengththis.information.getSize())return i+4<=this.information.getSize();for(let s=i;sthis.information.getSize()){let c=this.extractNumericValueFromBitArray(i,4);return c===0?new Ri(this.information.getSize(),Ri.FNC1,Ri.FNC1):new Ri(this.information.getSize(),c-1,Ri.FNC1)}let s=this.extractNumericValueFromBitArray(i,7),a=(s-8)/11,h=(s-8)%11;return new Ri(i+7,a,h)}extractNumericValueFromBitArray(i,s){return fs.extractNumericValueFromBitArray(this.information,i,s)}static extractNumericValueFromBitArray(i,s,a){let h=0;for(let c=0;cthis.information.getSize())return!1;let s=this.extractNumericValueFromBitArray(i,5);if(s>=5&&s<16)return!0;if(i+7>this.information.getSize())return!1;let a=this.extractNumericValueFromBitArray(i,7);if(a>=64&&a<116)return!0;if(i+8>this.information.getSize())return!1;let h=this.extractNumericValueFromBitArray(i,8);return h>=232&&h<253}decodeIsoIec646(i){let s=this.extractNumericValueFromBitArray(i,5);if(s===15)return new de(i+5,de.FNC1);if(s>=5&&s<15)return new de(i+5,"0"+(s-5));let a=this.extractNumericValueFromBitArray(i,7);if(a>=64&&a<90)return new de(i+7,""+(a+1));if(a>=90&&a<116)return new de(i+7,""+(a+7));let h=this.extractNumericValueFromBitArray(i,8),c;switch(h){case 232:c="!";break;case 233:c='"';break;case 234:c="%";break;case 235:c="&";break;case 236:c="'";break;case 237:c="(";break;case 238:c=")";break;case 239:c="*";break;case 240:c="+";break;case 241:c=",";break;case 242:c="-";break;case 243:c=".";break;case 244:c="/";break;case 245:c=":";break;case 246:c=";";break;case 247:c="<";break;case 248:c="=";break;case 249:c=">";break;case 250:c="?";break;case 251:c="_";break;case 252:c=" ";break;default:throw new X}return new de(i+8,c)}isStillAlpha(i){if(i+5>this.information.getSize())return!1;let s=this.extractNumericValueFromBitArray(i,5);if(s>=5&&s<16)return!0;if(i+6>this.information.getSize())return!1;let a=this.extractNumericValueFromBitArray(i,6);return a>=16&&a<63}decodeAlphanumeric(i){let s=this.extractNumericValueFromBitArray(i,5);if(s===15)return new de(i+5,de.FNC1);if(s>=5&&s<15)return new de(i+5,"0"+(s-5));let a=this.extractNumericValueFromBitArray(i,6);if(a>=32&&a<58)return new de(i+6,""+(a+33));let h;switch(a){case 58:h="*";break;case 59:h=",";break;case 60:h="-";break;case 61:h=".";break;case 62:h="/";break;default:throw new hi("Decoding invalid alphanumeric value: "+a)}return new de(i+6,h)}isAlphaTo646ToAlphaLatch(i){if(i+1>this.information.getSize())return!1;for(let s=0;s<5&&s+ithis.information.getSize())return!1;for(let s=i;sthis.information.getSize())return!1;for(let s=0;s<4&&s+i{s.forEach(d=>{h.getLeftChar().getValue()===d.getLeftChar().getValue()&&h.getRightChar().getValue()===d.getRightChar().getValue()&&h.getFinderPatter().getValue()===d.getFinderPatter().getValue()&&(a=!0)})}),a}}class dt extends ue{constructor(i){super(...arguments),this.pairs=new Array(dt.MAX_PAIRS),this.rows=new Array,this.startEnd=[2],this.verbose=i===!0}decodeRow(i,s,a){this.pairs.length=0,this.startFromEven=!1;try{return dt.constructResult(this.decodeRow2pairs(i,s))}catch(h){this.verbose&&console.log(h)}return this.pairs.length=0,this.startFromEven=!0,dt.constructResult(this.decodeRow2pairs(i,s))}reset(){this.pairs.length=0,this.rows.length=0}decodeRow2pairs(i,s){let a=!1;for(;!a;)try{this.pairs.push(this.retrieveNextPair(s,this.pairs,i))}catch(c){if(c instanceof q){if(!this.pairs.length)throw new q;a=!0}}if(this.checkChecksum())return this.pairs;let h;if(this.rows.length?h=!0:h=!1,this.storeRow(i,!1),h){let c=this.checkRowsBoolean(!1);if(c!=null||(c=this.checkRowsBoolean(!0),c!=null))return c}throw new q}checkRowsBoolean(i){if(this.rows.length>25)return this.rows.length=0,null;this.pairs.length=0,i&&(this.rows=this.rows.reverse());let s=null;try{s=this.checkRows(new Array,0)}catch(a){this.verbose&&console.log(a)}return i&&(this.rows=this.rows.reverse()),s}checkRows(i,s){for(let a=s;as.length)continue;let a=!0;for(let h=0;hi){c=d.isEquivalent(this.pairs);break}h=d.isEquivalent(this.pairs),a++}c||h||dt.isPartialRow(this.pairs,this.rows)||(this.rows.push(a,new xs(this.pairs,i,s)),this.removePartialRows(this.pairs,this.rows))}removePartialRows(i,s){for(let a of s)if(a.getPairs().length!==i.length){for(let h of a.getPairs())for(let c of i)if(Nn.equals(h,c))break}}static isPartialRow(i,s){for(let a of s){let h=!0;for(let c of i){let d=!1;for(let m of a.getPairs())if(c.equals(m)){d=!0;break}if(!d){h=!1;break}}if(h)return!0}return!1}getRows(){return this.rows}static constructResult(i){let s=Le.buildBitArray(i),h=ms(s).parseInformation(),c=i[0].getFinderPattern().getResultPoints(),d=i[i.length-1].getFinderPattern().getResultPoints(),m=[c[0],c[1],d[0],d[1]];return new gt(h,null,null,m,Rt.RSS_EXPANDED,null)}checkChecksum(){let i=this.pairs.get(0),s=i.getLeftChar(),a=i.getRightChar();if(a==null)return!1;let h=a.getChecksumPortion(),c=2;for(let m=1;m=0?d=a:this.isEmptyPair(s)?d=0:d=s[s.length-1].getFinderPattern().getStartEnd()[1];let m=s.length%2!=0;this.startFromEven&&(m=!m);let _=!1;for(;d=0&&!i.get(C);)C--;C++,h=this.startEnd[0]-C,c=C,d=this.startEnd[1]}else c=this.startEnd[0],d=i.getNextUnset(this.startEnd[1]+1),h=d-this.startEnd[1];let m=this.getDecodeFinderCounters();F.arraycopy(m,0,m,1,m.length-1),m[0]=h;let _;try{_=this.parseFinderValue(m,dt.FINDER_PATTERNS)}catch{return null}return new si(_,[c,d],c,d,s)}decodeDataCharacter(i,s,a,h){let c=this.getDataCharacterCounters();for(let De=0;De.3)throw new q;let C=this.getOddCounts(),M=this.getEvenCounts(),R=this.getOddRoundingErrors(),D=this.getEvenRoundingErrors();for(let De=0;De8){if(Mi>8.7)throw new q;tn=8}let xr=De/2;De&1?(M[xr]=tn,D[xr]=Mi-tn):(C[xr]=tn,R[xr]=Mi-tn)}this.adjustOddEvenCounts(d);let k=4*s.getValue()+(a?0:2)+(h?0:1)-1,j=0,K=0;for(let De=C.length-1;De>=0;De--){if(dt.isNotA1left(s,a,h)){let Mi=dt.WEIGHTS[k][2*De];K+=C[De]*Mi}j+=C[De]}let tt=0;for(let De=M.length-1;De>=0;De--)if(dt.isNotA1left(s,a,h)){let Mi=dt.WEIGHTS[k][2*De+1];tt+=M[De]*Mi}let st=K+tt;if(j&1||j>13||j<4)throw new q;let Et=(13-j)/2,At=dt.SYMBOL_WIDEST[Et],mt=9-At,le=Vt.getRSSvalue(C,At,!0),Kt=Vt.getRSSvalue(M,mt,!1),Xi=dt.EVEN_TOTAL_SUBSET[Et],Cn=dt.GSUM[Et],Vi=le*Xi+Kt+Cn;return new Wt(Vi,st)}static isNotA1left(i,s,a){return!(i.getValue()==0&&s&&a)}adjustOddEvenCounts(i){let s=ee.sum(new Int32Array(this.getOddCounts())),a=ee.sum(new Int32Array(this.getEvenCounts())),h=!1,c=!1;s>13?c=!0:s<4&&(h=!0);let d=!1,m=!1;a>13?m=!0:a<4&&(d=!0);let _=s+a-i,C=(s&1)==1,M=(a&1)==0;if(_==1)if(C){if(M)throw new q;c=!0}else{if(!M)throw new q;m=!0}else if(_==-1)if(C){if(M)throw new q;h=!0}else{if(!M)throw new q;d=!0}else if(_==0){if(C){if(!M)throw new q;s1){for(let m of this.possibleRightPairs)if(m.getCount()>1&&Ot.checkChecksum(d,m))return Ot.constructResult(d,m)}throw new q}static addOrTally(i,s){if(s==null)return;let a=!1;for(let h of i)if(h.getValue()===s.getValue()){h.incrementCount(),a=!0;break}a||i.push(s)}reset(){this.possibleLeftPairs.length=0,this.possibleRightPairs.length=0}static constructResult(i,s){let a=4537077*i.getValue()+s.getValue(),h=new String(a).toString(),c=new ut;for(let C=13-h.length;C>0;C--)c.append("0");c.append(h);let d=0;for(let C=0;C<13;C++){let M=c.charAt(C).charCodeAt(0)-48;d+=C&1?M:3*M}d=10-d%10,d===10&&(d=0),c.append(d.toString());let m=i.getFinderPattern().getResultPoints(),_=s.getFinderPattern().getResultPoints();return new gt(c.toString(),null,0,[m[0],m[1],_[0],_[1]],Rt.RSS_14,new Date().getTime())}static checkChecksum(i,s){let a=(i.getChecksumPortion()+16*s.getChecksumPortion())%79,h=9*i.getFinderPattern().getValue()+s.getFinderPattern().getValue();return h>72&&h--,h>8&&h--,a===h}decodePair(i,s,a,h){try{let c=this.findFinderPattern(i,s),d=this.parseFoundFinderPattern(i,a,s,c),m=h==null?null:h.get(ot.NEED_RESULT_POINT_CALLBACK);if(m!=null){let M=(c[0]+c[1])/2;s&&(M=i.getSize()-1-M),m.foundPossibleResultPoint(new St(M,a))}let _=this.decodeDataCharacter(i,d,!0),C=this.decodeDataCharacter(i,d,!1);return new xl(1597*_.getValue()+C.getValue(),_.getChecksumPortion()+4*C.getChecksumPortion(),d)}catch{return null}}decodeDataCharacter(i,s,a){let h=this.getDataCharacterCounters();for(let tt=0;tt8&&(Et=8);let At=Math.floor(tt/2);tt&1?(_[At]=Et,M[At]=st-Et):(m[At]=Et,C[At]=st-Et)}this.adjustOddEvenCounts(a,c);let R=0,D=0;for(let tt=m.length-1;tt>=0;tt--)D*=9,D+=m[tt],R+=m[tt];let k=0,j=0;for(let tt=_.length-1;tt>=0;tt--)k*=9,k+=_[tt],j+=_[tt];let K=D+3*k;if(a){if(R&1||R>12||R<4)throw new q;let tt=(12-R)/2,st=Ot.OUTSIDE_ODD_WIDEST[tt],Et=9-st,At=Vt.getRSSvalue(m,st,!1),mt=Vt.getRSSvalue(_,Et,!0),le=Ot.OUTSIDE_EVEN_TOTAL_SUBSET[tt],Kt=Ot.OUTSIDE_GSUM[tt];return new Wt(At*le+mt+Kt,K)}else{if(j&1||j>10||j<4)throw new q;let tt=(10-j)/2,st=Ot.INSIDE_ODD_WIDEST[tt],Et=9-st,At=Vt.getRSSvalue(m,st,!0),mt=Vt.getRSSvalue(_,Et,!1),le=Ot.INSIDE_ODD_TOTAL_SUBSET[tt],Kt=Ot.INSIDE_GSUM[tt];return new Wt(mt*le+At+Kt,K)}}findFinderPattern(i,s){let a=this.getDecodeFinderCounters();a[0]=0,a[1]=0,a[2]=0,a[3]=0;let h=i.getSize(),c=!1,d=0;for(;d=0&&c!==i.get(d);)d--;d++;const m=h[0]-d,_=this.getDecodeFinderCounters(),C=new Int32Array(_.length);F.arraycopy(_,0,C,1,_.length-1),C[0]=m;const M=this.parseFinderValue(C,Ot.FINDER_PATTERNS);let R=d,D=h[1];return a&&(R=i.getSize()-1-R,D=i.getSize()-1-D),new si(M,[d,h[1]],R,D,s)}adjustOddEvenCounts(i,s){let a=ee.sum(new Int32Array(this.getOddCounts())),h=ee.sum(new Int32Array(this.getEvenCounts())),c=!1,d=!1,m=!1,_=!1;i?(a>12?d=!0:a<4&&(c=!0),h>12?_=!0:h<4&&(m=!0)):(a>11?d=!0:a<5&&(c=!0),h>10?_=!0:h<4&&(m=!0));let C=a+h-s,M=(a&1)===(i?1:0),R=(h&1)===1;if(C===1)if(M){if(R)throw new q;d=!0}else{if(!R)throw new q;_=!0}else if(C===-1)if(M){if(R)throw new q;c=!0}else{if(!R)throw new q;m=!0}else if(C===0){if(M){if(!R)throw new q;ai.reset())}}class ri extends te{constructor(i=500,s){super(new _s(s),i,s)}}class me{constructor(i,s,a){this.ecCodewords=i,this.ecBlocks=[s],a&&this.ecBlocks.push(a)}getECCodewords(){return this.ecCodewords}getECBlocks(){return this.ecBlocks}}class xe{constructor(i,s){this.count=i,this.dataCodewords=s}getCount(){return this.count}getDataCodewords(){return this.dataCodewords}}class re{constructor(i,s,a,h,c,d){this.versionNumber=i,this.symbolSizeRows=s,this.symbolSizeColumns=a,this.dataRegionSizeRows=h,this.dataRegionSizeColumns=c,this.ecBlocks=d;let m=0;const _=d.getECCodewords(),C=d.getECBlocks();for(let M of C)m+=M.getCount()*(M.getDataCodewords()+_);this.totalCodewords=m}getVersionNumber(){return this.versionNumber}getSymbolSizeRows(){return this.symbolSizeRows}getSymbolSizeColumns(){return this.symbolSizeColumns}getDataRegionSizeRows(){return this.dataRegionSizeRows}getDataRegionSizeColumns(){return this.dataRegionSizeColumns}getTotalCodewords(){return this.totalCodewords}getECBlocks(){return this.ecBlocks}static getVersionForDimensions(i,s){if(i&1||s&1)throw new X;for(let a of re.VERSIONS)if(a.symbolSizeRows===i&&a.symbolSizeColumns===s)return a;throw new X}toString(){return""+this.versionNumber}static buildVersions(){return[new re(1,10,10,8,8,new me(5,new xe(1,3))),new re(2,12,12,10,10,new me(7,new xe(1,5))),new re(3,14,14,12,12,new me(10,new xe(1,8))),new re(4,16,16,14,14,new me(12,new xe(1,12))),new re(5,18,18,16,16,new me(14,new xe(1,18))),new re(6,20,20,18,18,new me(18,new xe(1,22))),new re(7,22,22,20,20,new me(20,new xe(1,30))),new re(8,24,24,22,22,new me(24,new xe(1,36))),new re(9,26,26,24,24,new me(28,new xe(1,44))),new re(10,32,32,14,14,new me(36,new xe(1,62))),new re(11,36,36,16,16,new me(42,new xe(1,86))),new re(12,40,40,18,18,new me(48,new xe(1,114))),new re(13,44,44,20,20,new me(56,new xe(1,144))),new re(14,48,48,22,22,new me(68,new xe(1,174))),new re(15,52,52,24,24,new me(42,new xe(2,102))),new re(16,64,64,14,14,new me(56,new xe(2,140))),new re(17,72,72,16,16,new me(36,new xe(4,92))),new re(18,80,80,18,18,new me(48,new xe(4,114))),new re(19,88,88,20,20,new me(56,new xe(4,144))),new re(20,96,96,22,22,new me(68,new xe(4,174))),new re(21,104,104,24,24,new me(56,new xe(6,136))),new re(22,120,120,18,18,new me(68,new xe(6,175))),new re(23,132,132,20,20,new me(62,new xe(8,163))),new re(24,144,144,22,22,new me(62,new xe(8,156),new xe(2,155))),new re(25,8,18,6,16,new me(7,new xe(1,5))),new re(26,8,32,6,14,new me(11,new xe(1,10))),new re(27,12,26,10,24,new me(14,new xe(1,16))),new re(28,12,36,10,16,new me(18,new xe(1,22))),new re(29,16,36,14,16,new me(24,new xe(1,32))),new re(30,16,48,14,22,new me(28,new xe(1,49)))]}}re.VERSIONS=re.buildVersions();class fr{constructor(i){const s=i.getHeight();if(s<8||s>144||s&1)throw new X;this.version=fr.readVersion(i),this.mappingBitMatrix=this.extractDataRegion(i),this.readMappingMatrix=new pt(this.mappingBitMatrix.getWidth(),this.mappingBitMatrix.getHeight())}getVersion(){return this.version}static readVersion(i){const s=i.getHeight(),a=i.getWidth();return re.getVersionForDimensions(s,a)}readCodewords(){const i=new Int8Array(this.version.getTotalCodewords());let s=0,a=4,h=0;const c=this.mappingBitMatrix.getHeight(),d=this.mappingBitMatrix.getWidth();let m=!1,_=!1,C=!1,M=!1;do if(a===c&&h===0&&!m)i[s++]=this.readCorner1(c,d)&255,a-=2,h+=2,m=!0;else if(a===c-2&&h===0&&d&3&&!_)i[s++]=this.readCorner2(c,d)&255,a-=2,h+=2,_=!0;else if(a===c+4&&h===2&&!(d&7)&&!C)i[s++]=this.readCorner3(c,d)&255,a-=2,h+=2,C=!0;else if(a===c-2&&h===0&&(d&7)===4&&!M)i[s++]=this.readCorner4(c,d)&255,a-=2,h+=2,M=!0;else{do a=0&&!this.readMappingMatrix.get(h,a)&&(i[s++]=this.readUtah(a,h,c,d)&255),a-=2,h+=2;while(a>=0&&h=0&&h=0);a+=3,h+=1}while(a7?K-1:K;d[st].codewords[Et]=i[R++]}if(R!==i.length)throw new A;return d}getNumDataCodewords(){return this.numDataCodewords}getCodewords(){return this.codewords}}class dr{constructor(i){this.bytes=i,this.byteOffset=0,this.bitOffset=0}getBitOffset(){return this.bitOffset}getByteOffset(){return this.byteOffset}readBits(i){if(i<1||i>32||i>this.available())throw new A(""+i);let s=0,a=this.bitOffset,h=this.byteOffset;const c=this.bytes;if(a>0){const d=8-a,m=i>8-m<<_;s=(c[h]&C)>>_,i-=m,a+=m,a===8&&(a=0,h++)}if(i>0){for(;i>=8;)s=s<<8|c[h]&255,h++,i-=8;if(i>0){const d=8-i,m=255>>d<>d,a+=i}}return this.bitOffset=a,this.byteOffset=h,s}available(){return 8*(this.bytes.length-this.byteOffset)-this.bitOffset}}var Je;(function(T){T[T.PAD_ENCODE=0]="PAD_ENCODE",T[T.ASCII_ENCODE=1]="ASCII_ENCODE",T[T.C40_ENCODE=2]="C40_ENCODE",T[T.TEXT_ENCODE=3]="TEXT_ENCODE",T[T.ANSIX12_ENCODE=4]="ANSIX12_ENCODE",T[T.EDIFACT_ENCODE=5]="EDIFACT_ENCODE",T[T.BASE256_ENCODE=6]="BASE256_ENCODE"})(Je||(Je={}));class _n{static decode(i){const s=new dr(i),a=new ut,h=new ut,c=new Array;let d=Je.ASCII_ENCODE;do if(d===Je.ASCII_ENCODE)d=this.decodeAsciiSegment(s,a,h);else{switch(d){case Je.C40_ENCODE:this.decodeC40Segment(s,a);break;case Je.TEXT_ENCODE:this.decodeTextSegment(s,a);break;case Je.ANSIX12_ENCODE:this.decodeAnsiX12Segment(s,a);break;case Je.EDIFACT_ENCODE:this.decodeEdifactSegment(s,a);break;case Je.BASE256_ENCODE:this.decodeBase256Segment(s,a,c);break;default:throw new X}d=Je.ASCII_ENCODE}while(d!==Je.PAD_ENCODE&&s.available()>0);return h.length()>0&&a.append(h.toString()),new mi(i,a.toString(),c.length===0?null:c,null)}static decodeAsciiSegment(i,s,a){let h=!1;do{let c=i.readBits(8);if(c===0)throw new X;if(c<=128)return h&&(c+=128),s.append(String.fromCharCode(c-1)),Je.ASCII_ENCODE;if(c===129)return Je.PAD_ENCODE;if(c<=229){const d=c-130;d<10&&s.append("0"),s.append(""+d)}else switch(c){case 230:return Je.C40_ENCODE;case 231:return Je.BASE256_ENCODE;case 232:s.append("");break;case 233:case 234:break;case 235:h=!0;break;case 236:s.append("[)>05"),a.insert(0,"");break;case 237:s.append("[)>06"),a.insert(0,"");break;case 238:return Je.ANSIX12_ENCODE;case 239:return Je.TEXT_ENCODE;case 240:return Je.EDIFACT_ENCODE;case 241:break;default:if(c!==254||i.available()!==0)throw new X;break}}while(i.available()>0);return Je.ASCII_ENCODE}static decodeC40Segment(i,s){let a=!1;const h=[];let c=0;do{if(i.available()===8)return;const d=i.readBits(8);if(d===254)return;this.parseTwoBytes(d,i.readBits(8),h);for(let m=0;m<3;m++){const _=h[m];switch(c){case 0:if(_<3)c=_+1;else if(_0)}static decodeTextSegment(i,s){let a=!1,h=[],c=0;do{if(i.available()===8)return;const d=i.readBits(8);if(d===254)return;this.parseTwoBytes(d,i.readBits(8),h);for(let m=0;m<3;m++){const _=h[m];switch(c){case 0:if(_<3)c=_+1;else if(_0)}static decodeAnsiX12Segment(i,s){const a=[];do{if(i.available()===8)return;const h=i.readBits(8);if(h===254)return;this.parseTwoBytes(h,i.readBits(8),a);for(let c=0;c<3;c++){const d=a[c];switch(d){case 0:s.append("\r");break;case 1:s.append("*");break;case 2:s.append(">");break;case 3:s.append(" ");break;default:if(d<14)s.append(String.fromCharCode(d+44));else if(d<40)s.append(String.fromCharCode(d+51));else throw new X;break}}}while(i.available()>0)}static parseTwoBytes(i,s,a){let h=(i<<8)+s-1,c=Math.floor(h/1600);a[0]=c,h-=c*1600,c=Math.floor(h/40),a[1]=c,a[2]=h-c*40}static decodeEdifactSegment(i,s){do{if(i.available()<=16)return;for(let a=0;a<4;a++){let h=i.readBits(6);if(h===31){const c=8-i.getBitOffset();c!==8&&i.readBits(c);return}h&32||(h|=64),s.append(String.fromCharCode(h))}}while(i.available()>0)}static decodeBase256Segment(i,s,a){let h=1+i.getByteOffset();const c=this.unrandomize255State(i.readBits(8),h++);let d;if(c===0?d=i.available()/8|0:c<250?d=c:d=250*(c-249)+this.unrandomize255State(i.readBits(8),h++),d<0)throw new X;const m=new Uint8Array(d);for(let _=0;_=0?h:h+256}}_n.C40_BASIC_SET_CHARS=["*","*","*"," ","0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"],_n.C40_SHIFT2_SET_CHARS=["!",'"',"#","$","%","&","'","(",")","*","+",",","-",".","/",":",";","<","=",">","?","@","[","\\","]","^","_"],_n.TEXT_BASIC_SET_CHARS=["*","*","*"," ","0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"],_n.TEXT_SHIFT2_SET_CHARS=_n.C40_SHIFT2_SET_CHARS,_n.TEXT_SHIFT3_SET_CHARS=["`","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","{","|","}","~",""];class Ho{constructor(){this.rsDecoder=new Ei(ne.DATA_MATRIX_FIELD_256)}decode(i){const s=new fr(i),a=s.getVersion(),h=s.readCodewords(),c=Hr.getDataBlocks(h,a);let d=0;for(let C of c)d+=C.getNumDataCodewords();const m=new Uint8Array(d),_=c.length;for(let C=0;C<_;C++){const M=c[C],R=M.getCodewords(),D=M.getNumDataCodewords();this.correctErrors(R,D);for(let k=0;km&&(M=m,R[0]=s,R[1]=a,R[2]=h,R[3]=c),M>_&&(M=_,R[0]=a,R[1]=h,R[2]=c,R[3]=s),M>C&&(R[0]=h,R[1]=c,R[2]=s,R[3]=a),R}detectSolid2(i){let s=i[0],a=i[1],h=i[2],c=i[3],d=this.transitionsBetween(s,c),m=Oe.shiftPoint(a,h,(d+1)*4),_=Oe.shiftPoint(h,a,(d+1)*4),C=this.transitionsBetween(m,s),M=this.transitionsBetween(_,c);return Ck?M:R}shiftToModuleCenter(i){let s=i[0],a=i[1],h=i[2],c=i[3],d=this.transitionsBetween(s,c)+1,m=this.transitionsBetween(h,c)+1,_=Oe.shiftPoint(s,a,m*4),C=Oe.shiftPoint(h,a,d*4);d=this.transitionsBetween(_,c)+1,m=this.transitionsBetween(C,c)+1,(d&1)===1&&(d+=1),(m&1)===1&&(m+=1);let M=(s.getX()+a.getX()+h.getX()+c.getX())/4,R=(s.getY()+a.getY()+h.getY()+c.getY())/4;s=Oe.moveAway(s,M,R),a=Oe.moveAway(a,M,R),h=Oe.moveAway(h,M,R),c=Oe.moveAway(c,M,R);let D,k;return _=Oe.shiftPoint(s,a,m*4),_=Oe.shiftPoint(_,c,d*4),D=Oe.shiftPoint(a,s,m*4),D=Oe.shiftPoint(D,h,d*4),C=Oe.shiftPoint(h,c,m*4),C=Oe.shiftPoint(C,a,d*4),k=Oe.shiftPoint(c,h,m*4),k=Oe.shiftPoint(k,s,d*4),[_,D,C,k]}isValid(i){return i.getX()>=0&&i.getX()0&&i.getY()Math.abs(c-a);if(m){let K=a;a=h,h=K,K=c,c=d,d=K}let _=Math.abs(c-a),C=Math.abs(d-h),M=-_/2,R=h0){if(tt===d)break;tt+=R,M-=_}}return k}}class He{constructor(){this.decoder=new Ho}decode(i,s=null){let a,h;if(s!=null&&s.has(ot.PURE_BARCODE)){const C=He.extractPureBits(i.getBlackMatrix());a=this.decoder.decode(C),h=He.NO_POINTS}else{const C=new Oe(i.getBlackMatrix()).detect();a=this.decoder.decode(C.getBits()),h=C.getPoints()}const c=a.getRawBytes(),d=new gt(a.getText(),c,8*c.length,h,Rt.DATA_MATRIX,F.currentTimeMillis()),m=a.getByteSegments();m!=null&&d.putMetadata(ye.BYTE_SEGMENTS,m);const _=a.getECLevel();return _!=null&&d.putMetadata(ye.ERROR_CORRECTION_LEVEL,_),d}reset(){}static extractPureBits(i){const s=i.getTopLeftOnBit(),a=i.getBottomRightOnBit();if(s==null||a==null)throw new q;const h=this.moduleSize(s,i);let c=s[1];const d=a[1];let m=s[0];const C=(a[0]-m+1)/h,M=(d-c+1)/h;if(C<=0||M<=0)throw new q;const R=h/2;c+=R,m+=R;const D=new pt(C,M);for(let k=0;k=Ee.FOR_BITS.size)throw new A;return Ee.FOR_BITS.get(i)}}Ee.FOR_BITS=new Map,Ee.FOR_VALUE=new Map,Ee.L=new Ee(cn.L,"L",1),Ee.M=new Ee(cn.M,"M",0),Ee.Q=new Ee(cn.Q,"Q",3),Ee.H=new Ee(cn.H,"H",2);class pi{constructor(i){this.errorCorrectionLevel=Ee.forBits(i>>3&3),this.dataMask=i&7}static numBitsDiffering(i,s){return Y.bitCount(i^s)}static decodeFormatInformation(i,s){const a=pi.doDecodeFormatInformation(i,s);return a!==null?a:pi.doDecodeFormatInformation(i^pi.FORMAT_INFO_MASK_QR,s^pi.FORMAT_INFO_MASK_QR)}static doDecodeFormatInformation(i,s){let a=Number.MAX_SAFE_INTEGER,h=0;for(const c of pi.FORMAT_INFO_DECODE_LOOKUP){const d=c[0];if(d===i||d===s)return new pi(c[1]);let m=pi.numBitsDiffering(i,d);m40)throw new A;return Nt.VERSIONS[i-1]}static decodeVersionInformation(i){let s=Number.MAX_SAFE_INTEGER,a=0;for(let h=0;h6&&(s.setRegion(i-11,0,3,6),s.setRegion(0,i-11,6,3)),s}toString(){return""+this.versionNumber}}Nt.VERSION_DECODE_INFO=Int32Array.from([31892,34236,39577,42195,48118,51042,55367,58893,63784,68472,70749,76311,79154,84390,87683,92361,96236,102084,102881,110507,110734,117786,119615,126325,127568,133589,136944,141498,145311,150283,152622,158308,161089,167017]),Nt.VERSIONS=[new Nt(1,new Int32Array(0),new et(7,new B(1,19)),new et(10,new B(1,16)),new et(13,new B(1,13)),new et(17,new B(1,9))),new Nt(2,Int32Array.from([6,18]),new et(10,new B(1,34)),new et(16,new B(1,28)),new et(22,new B(1,22)),new et(28,new B(1,16))),new Nt(3,Int32Array.from([6,22]),new et(15,new B(1,55)),new et(26,new B(1,44)),new et(18,new B(2,17)),new et(22,new B(2,13))),new Nt(4,Int32Array.from([6,26]),new et(20,new B(1,80)),new et(18,new B(2,32)),new et(26,new B(2,24)),new et(16,new B(4,9))),new Nt(5,Int32Array.from([6,30]),new et(26,new B(1,108)),new et(24,new B(2,43)),new et(18,new B(2,15),new B(2,16)),new et(22,new B(2,11),new B(2,12))),new Nt(6,Int32Array.from([6,34]),new et(18,new B(2,68)),new et(16,new B(4,27)),new et(24,new B(4,19)),new et(28,new B(4,15))),new Nt(7,Int32Array.from([6,22,38]),new et(20,new B(2,78)),new et(18,new B(4,31)),new et(18,new B(2,14),new B(4,15)),new et(26,new B(4,13),new B(1,14))),new Nt(8,Int32Array.from([6,24,42]),new et(24,new B(2,97)),new et(22,new B(2,38),new B(2,39)),new et(22,new B(4,18),new B(2,19)),new et(26,new B(4,14),new B(2,15))),new Nt(9,Int32Array.from([6,26,46]),new et(30,new B(2,116)),new et(22,new B(3,36),new B(2,37)),new et(20,new B(4,16),new B(4,17)),new et(24,new B(4,12),new B(4,13))),new Nt(10,Int32Array.from([6,28,50]),new et(18,new B(2,68),new B(2,69)),new et(26,new B(4,43),new B(1,44)),new et(24,new B(6,19),new B(2,20)),new et(28,new B(6,15),new B(2,16))),new Nt(11,Int32Array.from([6,30,54]),new et(20,new B(4,81)),new et(30,new B(1,50),new B(4,51)),new et(28,new B(4,22),new B(4,23)),new et(24,new B(3,12),new B(8,13))),new Nt(12,Int32Array.from([6,32,58]),new et(24,new B(2,92),new B(2,93)),new et(22,new B(6,36),new B(2,37)),new et(26,new B(4,20),new B(6,21)),new et(28,new B(7,14),new B(4,15))),new Nt(13,Int32Array.from([6,34,62]),new et(26,new B(4,107)),new et(22,new B(8,37),new B(1,38)),new et(24,new B(8,20),new B(4,21)),new et(22,new B(12,11),new B(4,12))),new Nt(14,Int32Array.from([6,26,46,66]),new et(30,new B(3,115),new B(1,116)),new et(24,new B(4,40),new B(5,41)),new et(20,new B(11,16),new B(5,17)),new et(24,new B(11,12),new B(5,13))),new Nt(15,Int32Array.from([6,26,48,70]),new et(22,new B(5,87),new B(1,88)),new et(24,new B(5,41),new B(5,42)),new et(30,new B(5,24),new B(7,25)),new et(24,new B(11,12),new B(7,13))),new Nt(16,Int32Array.from([6,26,50,74]),new et(24,new B(5,98),new B(1,99)),new et(28,new B(7,45),new B(3,46)),new et(24,new B(15,19),new B(2,20)),new et(30,new B(3,15),new B(13,16))),new Nt(17,Int32Array.from([6,30,54,78]),new et(28,new B(1,107),new B(5,108)),new et(28,new B(10,46),new B(1,47)),new et(28,new B(1,22),new B(15,23)),new et(28,new B(2,14),new B(17,15))),new Nt(18,Int32Array.from([6,30,56,82]),new et(30,new B(5,120),new B(1,121)),new et(26,new B(9,43),new B(4,44)),new et(28,new B(17,22),new B(1,23)),new et(28,new B(2,14),new B(19,15))),new Nt(19,Int32Array.from([6,30,58,86]),new et(28,new B(3,113),new B(4,114)),new et(26,new B(3,44),new B(11,45)),new et(26,new B(17,21),new B(4,22)),new et(26,new B(9,13),new B(16,14))),new Nt(20,Int32Array.from([6,34,62,90]),new et(28,new B(3,107),new B(5,108)),new et(26,new B(3,41),new B(13,42)),new et(30,new B(15,24),new B(5,25)),new et(28,new B(15,15),new B(10,16))),new Nt(21,Int32Array.from([6,28,50,72,94]),new et(28,new B(4,116),new B(4,117)),new et(26,new B(17,42)),new et(28,new B(17,22),new B(6,23)),new et(30,new B(19,16),new B(6,17))),new Nt(22,Int32Array.from([6,26,50,74,98]),new et(28,new B(2,111),new B(7,112)),new et(28,new B(17,46)),new et(30,new B(7,24),new B(16,25)),new et(24,new B(34,13))),new Nt(23,Int32Array.from([6,30,54,78,102]),new et(30,new B(4,121),new B(5,122)),new et(28,new B(4,47),new B(14,48)),new et(30,new B(11,24),new B(14,25)),new et(30,new B(16,15),new B(14,16))),new Nt(24,Int32Array.from([6,28,54,80,106]),new et(30,new B(6,117),new B(4,118)),new et(28,new B(6,45),new B(14,46)),new et(30,new B(11,24),new B(16,25)),new et(30,new B(30,16),new B(2,17))),new Nt(25,Int32Array.from([6,32,58,84,110]),new et(26,new B(8,106),new B(4,107)),new et(28,new B(8,47),new B(13,48)),new et(30,new B(7,24),new B(22,25)),new et(30,new B(22,15),new B(13,16))),new Nt(26,Int32Array.from([6,30,58,86,114]),new et(28,new B(10,114),new B(2,115)),new et(28,new B(19,46),new B(4,47)),new et(28,new B(28,22),new B(6,23)),new et(30,new B(33,16),new B(4,17))),new Nt(27,Int32Array.from([6,34,62,90,118]),new et(30,new B(8,122),new B(4,123)),new et(28,new B(22,45),new B(3,46)),new et(30,new B(8,23),new B(26,24)),new et(30,new B(12,15),new B(28,16))),new Nt(28,Int32Array.from([6,26,50,74,98,122]),new et(30,new B(3,117),new B(10,118)),new et(28,new B(3,45),new B(23,46)),new et(30,new B(4,24),new B(31,25)),new et(30,new B(11,15),new B(31,16))),new Nt(29,Int32Array.from([6,30,54,78,102,126]),new et(30,new B(7,116),new B(7,117)),new et(28,new B(21,45),new B(7,46)),new et(30,new B(1,23),new B(37,24)),new et(30,new B(19,15),new B(26,16))),new Nt(30,Int32Array.from([6,26,52,78,104,130]),new et(30,new B(5,115),new B(10,116)),new et(28,new B(19,47),new B(10,48)),new et(30,new B(15,24),new B(25,25)),new et(30,new B(23,15),new B(25,16))),new Nt(31,Int32Array.from([6,30,56,82,108,134]),new et(30,new B(13,115),new B(3,116)),new et(28,new B(2,46),new B(29,47)),new et(30,new B(42,24),new B(1,25)),new et(30,new B(23,15),new B(28,16))),new Nt(32,Int32Array.from([6,34,60,86,112,138]),new et(30,new B(17,115)),new et(28,new B(10,46),new B(23,47)),new et(30,new B(10,24),new B(35,25)),new et(30,new B(19,15),new B(35,16))),new Nt(33,Int32Array.from([6,30,58,86,114,142]),new et(30,new B(17,115),new B(1,116)),new et(28,new B(14,46),new B(21,47)),new et(30,new B(29,24),new B(19,25)),new et(30,new B(11,15),new B(46,16))),new Nt(34,Int32Array.from([6,34,62,90,118,146]),new et(30,new B(13,115),new B(6,116)),new et(28,new B(14,46),new B(23,47)),new et(30,new B(44,24),new B(7,25)),new et(30,new B(59,16),new B(1,17))),new Nt(35,Int32Array.from([6,30,54,78,102,126,150]),new et(30,new B(12,121),new B(7,122)),new et(28,new B(12,47),new B(26,48)),new et(30,new B(39,24),new B(14,25)),new et(30,new B(22,15),new B(41,16))),new Nt(36,Int32Array.from([6,24,50,76,102,128,154]),new et(30,new B(6,121),new B(14,122)),new et(28,new B(6,47),new B(34,48)),new et(30,new B(46,24),new B(10,25)),new et(30,new B(2,15),new B(64,16))),new Nt(37,Int32Array.from([6,28,54,80,106,132,158]),new et(30,new B(17,122),new B(4,123)),new et(28,new B(29,46),new B(14,47)),new et(30,new B(49,24),new B(10,25)),new et(30,new B(24,15),new B(46,16))),new Nt(38,Int32Array.from([6,32,58,84,110,136,162]),new et(30,new B(4,122),new B(18,123)),new et(28,new B(13,46),new B(32,47)),new et(30,new B(48,24),new B(14,25)),new et(30,new B(42,15),new B(32,16))),new Nt(39,Int32Array.from([6,26,54,82,110,138,166]),new et(30,new B(20,117),new B(4,118)),new et(28,new B(40,47),new B(7,48)),new et(30,new B(43,24),new B(22,25)),new et(30,new B(10,15),new B(67,16))),new Nt(40,Int32Array.from([6,30,58,86,114,142,170]),new et(30,new B(19,118),new B(6,119)),new et(28,new B(18,47),new B(31,48)),new et(30,new B(34,24),new B(34,25)),new et(30,new B(20,15),new B(61,16)))];var oi;(function(T){T[T.DATA_MASK_000=0]="DATA_MASK_000",T[T.DATA_MASK_001=1]="DATA_MASK_001",T[T.DATA_MASK_010=2]="DATA_MASK_010",T[T.DATA_MASK_011=3]="DATA_MASK_011",T[T.DATA_MASK_100=4]="DATA_MASK_100",T[T.DATA_MASK_101=5]="DATA_MASK_101",T[T.DATA_MASK_110=6]="DATA_MASK_110",T[T.DATA_MASK_111=7]="DATA_MASK_111"})(oi||(oi={}));class Ii{constructor(i,s){this.value=i,this.isMasked=s}unmaskBitMatrix(i,s){for(let a=0;a(T+i&1)===0)],[oi.DATA_MASK_001,new Ii(oi.DATA_MASK_001,(T,i)=>(T&1)===0)],[oi.DATA_MASK_010,new Ii(oi.DATA_MASK_010,(T,i)=>i%3===0)],[oi.DATA_MASK_011,new Ii(oi.DATA_MASK_011,(T,i)=>(T+i)%3===0)],[oi.DATA_MASK_100,new Ii(oi.DATA_MASK_100,(T,i)=>(Math.floor(T/2)+Math.floor(i/3)&1)===0)],[oi.DATA_MASK_101,new Ii(oi.DATA_MASK_101,(T,i)=>T*i%6===0)],[oi.DATA_MASK_110,new Ii(oi.DATA_MASK_110,(T,i)=>T*i%6<3)],[oi.DATA_MASK_111,new Ii(oi.DATA_MASK_111,(T,i)=>(T+i+T*i%3&1)===0)]]);class jo{constructor(i){const s=i.getHeight();if(s<21||(s&3)!==1)throw new X;this.bitMatrix=i}readFormatInformation(){if(this.parsedFormatInfo!==null&&this.parsedFormatInfo!==void 0)return this.parsedFormatInfo;let i=0;for(let c=0;c<6;c++)i=this.copyBit(c,8,i);i=this.copyBit(7,8,i),i=this.copyBit(8,8,i),i=this.copyBit(8,7,i);for(let c=5;c>=0;c--)i=this.copyBit(8,c,i);const s=this.bitMatrix.getHeight();let a=0;const h=s-7;for(let c=s-1;c>=h;c--)a=this.copyBit(8,c,a);for(let c=s-8;c=0;d--)for(let m=i-9;m>=h;m--)a=this.copyBit(m,d,a);let c=Nt.decodeVersionInformation(a);if(c!==null&&c.getDimensionForVersion()===i)return this.parsedVersion=c,c;a=0;for(let d=5;d>=0;d--)for(let m=i-9;m>=h;m--)a=this.copyBit(d,m,a);if(c=Nt.decodeVersionInformation(a),c!==null&&c.getDimensionForVersion()===i)return this.parsedVersion=c,c;throw new X}copyBit(i,s,a){return(this.isMirror?this.bitMatrix.get(s,i):this.bitMatrix.get(i,s))?a<<1|1:a<<1}readCodewords(){const i=this.readFormatInformation(),s=this.readVersion(),a=Ii.values.get(i.getDataMask()),h=this.bitMatrix.getHeight();a.unmaskBitMatrix(this.bitMatrix,h);const c=s.buildFunctionPattern();let d=!0;const m=new Uint8Array(s.getTotalCodewords());let _=0,C=0,M=0;for(let R=h-1;R>0;R-=2){R===6&&R--;for(let D=0;D=0&&m[M].codewords.length!==C;)M--;M++;const R=C-h.getECCodewordsPerBlock();let D=0;for(let j=0;ji.available())throw new X;const h=new Uint8Array(2*a);let c=0;for(;a>0;){const d=i.readBits(13);let m=d/96<<8&4294967295|d%96;m<959?m+=41377:m+=42657,h[c]=m>>8&255,h[c+1]=m&255,c+=2,a--}try{s.append(xt.decode(h,at.GB2312))}catch(d){throw new X(d)}}static decodeKanjiSegment(i,s,a){if(a*13>i.available())throw new X;const h=new Uint8Array(2*a);let c=0;for(;a>0;){const d=i.readBits(13);let m=d/192<<8&4294967295|d%192;m<7936?m+=33088:m+=49472,h[c]=m>>8,h[c+1]=m,c+=2,a--}try{s.append(xt.decode(h,at.SHIFT_JIS))}catch(d){throw new X(d)}}static decodeByteSegment(i,s,a,h,c,d){if(8*a>i.available())throw new X;const m=new Uint8Array(a);for(let C=0;C=Pe.ALPHANUMERIC_CHARS.length)throw new X;return Pe.ALPHANUMERIC_CHARS[i]}static decodeAlphanumericSegment(i,s,a,h){const c=s.length();for(;a>1;){if(i.available()<11)throw new X;const d=i.readBits(11);s.append(Pe.toAlphaNumericChar(Math.floor(d/45))),s.append(Pe.toAlphaNumericChar(d%45)),a-=2}if(a===1){if(i.available()<6)throw new X;s.append(Pe.toAlphaNumericChar(i.readBits(6)))}if(h)for(let d=c;d=3;){if(i.available()<10)throw new X;const h=i.readBits(10);if(h>=1e3)throw new X;s.append(Pe.toAlphaNumericChar(Math.floor(h/100))),s.append(Pe.toAlphaNumericChar(Math.floor(h/10)%10)),s.append(Pe.toAlphaNumericChar(h%10)),a-=3}if(a===2){if(i.available()<7)throw new X;const h=i.readBits(7);if(h>=100)throw new X;s.append(Pe.toAlphaNumericChar(Math.floor(h/10))),s.append(Pe.toAlphaNumericChar(h%10))}else if(a===1){if(i.available()<4)throw new X;const h=i.readBits(4);if(h>=10)throw new X;s.append(Pe.toAlphaNumericChar(h))}}static parseECIValue(i){const s=i.readBits(8);if(!(s&128))return s&127;if((s&192)===128){const a=i.readBits(8);return(s&63)<<8&4294967295|a}if((s&224)===192){const a=i.readBits(16);return(s&31)<<16&4294967295|a}throw new X}}Pe.ALPHANUMERIC_CHARS="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:",Pe.GB2312_SUBSET=1;class Zo{constructor(i){this.mirrored=i}isMirrored(){return this.mirrored}applyMirroredCorrection(i){if(!this.mirrored||i===null||i.length<3)return;const s=i[0];i[0]=i[2],i[2]=s}}class _l{constructor(){this.rsDecoder=new Ei(ne.QR_CODE_FIELD_256)}decodeBooleanArray(i,s){return this.decodeBitMatrix(pt.parseFromBooleanArray(i),s)}decodeBitMatrix(i,s){const a=new jo(i);let h=null;try{return this.decodeBitMatrixParser(a,s)}catch(c){h=c}try{a.remask(),a.setMirror(!0),a.readVersion(),a.readFormatInformation(),a.mirror();const c=this.decodeBitMatrixParser(a,s);return c.setOther(new Zo(!0)),c}catch(c){throw h!==null?h:c}}decodeBitMatrixParser(i,s){const a=i.readVersion(),h=i.readFormatInformation().getErrorCorrectionLevel(),c=i.readCodewords(),d=Oi.getDataBlocks(c,a,h);let m=0;for(const M of d)m+=M.getNumDataCodewords();const _=new Uint8Array(m);let C=0;for(const M of d){const R=M.getCodewords(),D=M.getNumDataCodewords();this.correctErrors(R,D);for(let k=0;k=a)return!1;return!0}crossCheckVertical(i,s,a,h){const c=this.image,d=c.getHeight(),m=this.crossCheckStateCount;m[0]=0,m[1]=0,m[2]=0;let _=i;for(;_>=0&&c.get(s,_)&&m[1]<=a;)m[1]++,_--;if(_<0||m[1]>a)return NaN;for(;_>=0&&!c.get(s,_)&&m[0]<=a;)m[0]++,_--;if(m[0]>a)return NaN;for(_=i+1;_a)return NaN;for(;_a)return NaN;const C=m[0]+m[1]+m[2];return 5*Math.abs(C-h)>=2*h?NaN:this.foundPatternCross(m)?Yn.centerFromEnd(m,_):NaN}handlePossibleCenter(i,s,a){const h=i[0]+i[1]+i[2],c=Yn.centerFromEnd(i,a),d=this.crossCheckVertical(s,c,2*i[1],h);if(!isNaN(d)){const m=(i[0]+i[1]+i[2])/3;for(const C of this.possibleCenters)if(C.aboutEquals(m,d,c))return C.combineEstimate(d,c,m);const _=new gr(c,d,m);this.possibleCenters.push(_),this.resultPointCallback!==null&&this.resultPointCallback!==void 0&&this.resultPointCallback.foundPossibleResultPoint(_)}return null}}class jr extends St{constructor(i,s,a,h){super(i,s),this.estimatedModuleSize=a,this.count=h,h===void 0&&(this.count=1)}getEstimatedModuleSize(){return this.estimatedModuleSize}getCount(){return this.count}aboutEquals(i,s,a){if(Math.abs(s-this.getY())<=i&&Math.abs(a-this.getX())<=i){const h=Math.abs(i-this.estimatedModuleSize);return h<=1||h<=this.estimatedModuleSize}return!1}combineEstimate(i,s,a){const h=this.count+1,c=(this.count*this.getX()+s)/h,d=(this.count*this.getY()+i)/h,m=(this.count*this.estimatedModuleSize+a)/h;return new jr(c,d,m,h)}}class pl{constructor(i){this.bottomLeft=i[0],this.topLeft=i[1],this.topRight=i[2]}getBottomLeft(){return this.bottomLeft}getTopLeft(){return this.topLeft}getTopRight(){return this.topRight}}class Qe{constructor(i,s){this.image=i,this.resultPointCallback=s,this.possibleCenters=[],this.crossCheckStateCount=new Int32Array(5),this.resultPointCallback=s}getImage(){return this.image}getPossibleCenters(){return this.possibleCenters}find(i){const s=i!=null&&i.get(ot.TRY_HARDER)!==void 0,a=i!=null&&i.get(ot.PURE_BARCODE)!==void 0,h=this.image,c=h.getHeight(),d=h.getWidth();let m=Math.floor(3*c/(4*Qe.MAX_MODULES));(mC[2]&&(R+=K-C[2]-m,k=d-1)}else{C[0]=C[2],C[1]=C[3],C[2]=C[4],C[3]=1,C[4]=0,D=3;continue}D=0,C[0]=0,C[1]=0,C[2]=0,C[3]=0,C[4]=0}else C[0]=C[2],C[1]=C[3],C[2]=C[4],C[3]=1,C[4]=0,D=3;else C[++D]++;Qe.foundPatternCross(C)&&this.handlePossibleCenter(C,R,d,a)===!0&&(m=C[0],this.hasSkipped&&(_=this.haveMultiplyConfirmedCenters()))}const M=this.selectBestPatterns();return St.orderBestPatterns(M),new pl(M)}static centerFromEnd(i,s){return s-i[4]-i[3]-i[2]/2}static foundPatternCross(i){let s=0;for(let c=0;c<5;c++){const d=i[c];if(d===0)return!1;s+=d}if(s<7)return!1;const a=s/7,h=a/2;return Math.abs(a-i[0])=d&&s>=d&&m.get(s-d,i-d);)c[2]++,d++;if(i=d&&s>=d&&!m.get(s-d,i-d)&&c[1]<=a;)c[1]++,d++;if(ia)return!1;for(;i>=d&&s>=d&&m.get(s-d,i-d)&&c[0]<=a;)c[0]++,d++;if(c[0]>a)return!1;const _=m.getHeight(),C=m.getWidth();for(d=1;i+d<_&&s+d=_||s+d>=C)return!1;for(;i+d<_&&s+d=_||s+d>=C||c[3]>=a)return!1;for(;i+d<_&&s+d=a)return!1;const M=c[0]+c[1]+c[2]+c[3]+c[4];return Math.abs(M-h)<2*h&&Qe.foundPatternCross(c)}crossCheckVertical(i,s,a,h){const c=this.image,d=c.getHeight(),m=this.getCrossCheckStateCount();let _=i;for(;_>=0&&c.get(s,_);)m[2]++,_--;if(_<0)return NaN;for(;_>=0&&!c.get(s,_)&&m[1]<=a;)m[1]++,_--;if(_<0||m[1]>a)return NaN;for(;_>=0&&c.get(s,_)&&m[0]<=a;)m[0]++,_--;if(m[0]>a)return NaN;for(_=i+1;_=a)return NaN;for(;_=a)return NaN;const C=m[0]+m[1]+m[2]+m[3]+m[4];return 5*Math.abs(C-h)>=2*h?NaN:Qe.foundPatternCross(m)?Qe.centerFromEnd(m,_):NaN}crossCheckHorizontal(i,s,a,h){const c=this.image,d=c.getWidth(),m=this.getCrossCheckStateCount();let _=i;for(;_>=0&&c.get(_,s);)m[2]++,_--;if(_<0)return NaN;for(;_>=0&&!c.get(_,s)&&m[1]<=a;)m[1]++,_--;if(_<0||m[1]>a)return NaN;for(;_>=0&&c.get(_,s)&&m[0]<=a;)m[0]++,_--;if(m[0]>a)return NaN;for(_=i+1;_=a)return NaN;for(;_=a)return NaN;const C=m[0]+m[1]+m[2]+m[3]+m[4];return 5*Math.abs(C-h)>=h?NaN:Qe.foundPatternCross(m)?Qe.centerFromEnd(m,_):NaN}handlePossibleCenter(i,s,a,h){const c=i[0]+i[1]+i[2]+i[3]+i[4];let d=Qe.centerFromEnd(i,a),m=this.crossCheckVertical(s,Math.floor(d),i[2],c);if(!isNaN(m)&&(d=this.crossCheckHorizontal(Math.floor(d),Math.floor(m),i[2],c),!isNaN(d)&&(!h||this.crossCheckDiagonal(Math.floor(m),Math.floor(d),i[2],c)))){const _=c/7;let C=!1;const M=this.possibleCenters;for(let R=0,D=M.length;R=Qe.CENTER_QUORUM)if(s==null)s=a;else return this.hasSkipped=!0,Math.floor((Math.abs(s.getX()-a.getX())-Math.abs(s.getY()-a.getY()))/2);return 0}haveMultiplyConfirmedCenters(){let i=0,s=0;const a=this.possibleCenters.length;for(const d of this.possibleCenters)d.getCount()>=Qe.CENTER_QUORUM&&(i++,s+=d.getEstimatedModuleSize());if(i<3)return!1;const h=s/a;let c=0;for(const d of this.possibleCenters)c+=Math.abs(d.getEstimatedModuleSize()-h);return c<=.05*s}selectBestPatterns(){const i=this.possibleCenters.length;if(i<3)throw new q;const s=this.possibleCenters;let a;if(i>3){let h=0,c=0;for(const _ of this.possibleCenters){const C=_.getEstimatedModuleSize();h+=C,c+=C*C}a=h/i;let d=Math.sqrt(c/i-a*a);s.sort((_,C)=>{const M=Math.abs(C.getEstimatedModuleSize()-a),R=Math.abs(_.getEstimatedModuleSize()-a);return MR?1:0});const m=Math.max(.2*a,d);for(let _=0;_3;_++){const C=s[_];Math.abs(C.getEstimatedModuleSize()-a)>m&&(s.splice(_,1),_--)}}if(s.length>3){let h=0;for(const c of s)h+=c.getEstimatedModuleSize();a=h/s.length,s.sort((c,d)=>{if(d.getCount()===c.getCount()){const m=Math.abs(d.getEstimatedModuleSize()-a),_=Math.abs(c.getEstimatedModuleSize()-a);return m<_?1:m>_?-1:0}else return d.getCount()-c.getCount()}),s.splice(3)}return[s[0],s[1],s[2]]}}Qe.CENTER_QUORUM=2,Qe.MIN_SKIP=3,Qe.MAX_MODULES=57;class Gs{constructor(i){this.image=i}getImage(){return this.image}getResultPointCallback(){return this.resultPointCallback}detect(i){this.resultPointCallback=i==null?null:i.get(ot.NEED_RESULT_POINT_CALLBACK);const a=new Qe(this.image,this.resultPointCallback).find(i);return this.processFinderPatternInfo(a)}processFinderPatternInfo(i){const s=i.getTopLeft(),a=i.getTopRight(),h=i.getBottomLeft(),c=this.calculateModuleSize(s,a,h);if(c<1)throw new q("No pattern found in proccess finder.");const d=Gs.computeDimension(s,a,h,c),m=Nt.getProvisionalVersionForDimension(d),_=m.getDimensionForVersion()-7;let C=null;if(m.getAlignmentPatternCenters().length>0){const k=a.getX()-s.getX()+h.getX(),j=a.getY()-s.getY()+h.getY(),K=1-3/_,tt=Math.floor(s.getX()+K*(k-s.getX())),st=Math.floor(s.getY()+K*(j-s.getY()));for(let Et=4;Et<=16;Et<<=1)try{C=this.findAlignmentInRegion(c,tt,st,Et);break}catch(At){if(!(At instanceof q))throw At}}const M=Gs.createTransform(s,a,h,C,d),R=Gs.sampleGrid(this.image,M,d);let D;return C===null?D=[h,s,a]:D=[h,s,a,C],new Ci(R,D)}static createTransform(i,s,a,h,c){const d=c-3.5;let m,_,C,M;return h!==null?(m=h.getX(),_=h.getY(),C=d-3,M=C):(m=s.getX()-i.getX()+a.getX(),_=s.getY()-i.getY()+a.getY(),C=d,M=d),ni.quadrilateralToQuadrilateral(3.5,3.5,d,3.5,C,M,3.5,d,i.getX(),i.getY(),s.getX(),s.getY(),m,_,a.getX(),a.getY())}static sampleGrid(i,s,a){return qe.getInstance().sampleGridWithTransform(i,a,a,s)}static computeDimension(i,s,a,h){const c=ee.round(St.distance(i,s)/h),d=ee.round(St.distance(i,a)/h);let m=Math.floor((c+d)/2)+7;switch(m&3){case 0:m++;break;case 2:m--;break;case 3:throw new q("Dimensions could be not found.")}return m}calculateModuleSize(i,s,a){return(this.calculateModuleSizeOneWay(i,s)+this.calculateModuleSizeOneWay(i,a))/2}calculateModuleSizeOneWay(i,s){const a=this.sizeOfBlackWhiteBlackRunBothWays(Math.floor(i.getX()),Math.floor(i.getY()),Math.floor(s.getX()),Math.floor(s.getY())),h=this.sizeOfBlackWhiteBlackRunBothWays(Math.floor(s.getX()),Math.floor(s.getY()),Math.floor(i.getX()),Math.floor(i.getY()));return isNaN(a)?h/7:isNaN(h)?a/7:(a+h)/14}sizeOfBlackWhiteBlackRunBothWays(i,s,a,h){let c=this.sizeOfBlackWhiteBlackRun(i,s,a,h),d=1,m=i-(a-i);m<0?(d=i/(i-m),m=0):m>=this.image.getWidth()&&(d=(this.image.getWidth()-1-i)/(m-i),m=this.image.getWidth()-1);let _=Math.floor(s-(h-s)*d);return d=1,_<0?(d=s/(s-_),_=0):_>=this.image.getHeight()&&(d=(this.image.getHeight()-1-s)/(_-s),_=this.image.getHeight()-1),m=Math.floor(i+(m-i)*d),c+=this.sizeOfBlackWhiteBlackRun(i,s,m,_),c-1}sizeOfBlackWhiteBlackRun(i,s,a,h){const c=Math.abs(h-s)>Math.abs(a-i);if(c){let k=i;i=s,s=k,k=a,a=h,h=k}const d=Math.abs(a-i),m=Math.abs(h-s);let _=-d/2;const C=i0){if(j===h)break;j+=M,_-=d}}return R===2?ee.distance(a+C,h,i,s):NaN}findAlignmentInRegion(i,s,a,h){const c=Math.floor(h*i),d=Math.max(0,s-c),m=Math.min(this.image.getWidth()-1,s+c);if(m-d=_||c>=d)throw new q;if(d-c!==_-m&&(_=m+(d-c),_>=i.getWidth()))throw new q;const C=Math.round((_-m+1)/h),M=Math.round((d-c+1)/h);if(C<=0||M<=0)throw new q;if(M!==C)throw new q;const R=Math.floor(h/2);c+=R,m+=R;const D=m+Math.floor((C-1)*h)-_;if(D>0){if(D>R)throw new q;m-=D}const k=c+Math.floor((M-1)*h)-d;if(k>0){if(k>R)throw new q;c-=k}const j=new pt(C,M);for(let K=0;K0;){const D=Zt.findGuardPattern(i,c,--h,a,!1,d,C);if(D!=null)R=D;else{h++;break}}m[0]=new St(R[0],h),m[1]=new St(R[1],h),_=!0;break}}let M=h+1;if(_){let R=0,D=Int32Array.from([Math.trunc(m[0].getX()),Math.trunc(m[1].getX())]);for(;MZt.SKIPPED_ROW_COUNT_MAX)break;R++}}M-=R+1,m[2]=new St(D[0],M),m[3]=new St(D[1],M)}return M-h0&&C++R?M-R:R-M;if(D>a)return 1/0;_+=D}return _/c}}Zt.INDEXES_START_PATTERN=Int32Array.from([0,4,1,5]),Zt.INDEXES_STOP_PATTERN=Int32Array.from([6,2,7,3]),Zt.MAX_AVG_VARIANCE=.42,Zt.MAX_INDIVIDUAL_VARIANCE=.8,Zt.START_PATTERN=Int32Array.from([8,1,1,1,1,1,1,3]),Zt.STOP_PATTERN=Int32Array.from([7,1,1,3,1,1,1,2,1]),Zt.MAX_PIXEL_DRIFT=3,Zt.MAX_PATTERN_DRIFT=5,Zt.SKIPPED_ROW_COUNT_MAX=25,Zt.ROW_STEP=5,Zt.BARCODE_MIN_HEIGHT=10;class We{constructor(i,s){if(s.length===0)throw new A;this.field=i;let a=s.length;if(a>1&&s[0]===0){let h=1;for(;ha.length){let d=s;s=a,a=d}let h=new Int32Array(a.length),c=a.length-s.length;F.arraycopy(a,0,h,0,c);for(let d=c;d=0;s--){let a=this.getCoefficient(s);a!==0&&(a<0?(i.append(" - "),a=-a):i.length()>0&&i.append(" + "),(s===0||a!==1)&&i.append(a),s!==0&&(s===1?i.append("x"):(i.append("x^"),i.append(s))))}return i.toString()}}class wl{add(i,s){return(i+s)%this.modulus}subtract(i,s){return(this.modulus+i-s)%this.modulus}exp(i){return this.expTable[i]}log(i){if(i===0)throw new A;return this.logTable[i]}inverse(i){if(i===0)throw new ze;return this.expTable[this.modulus-this.logTable[i]-1]}multiply(i,s){return i===0||s===0?0:this.expTable[(this.logTable[i]+this.logTable[s])%(this.modulus-1)]}getSize(){return this.modulus}equals(i){return i===this}}class Zr extends wl{constructor(i,s){super(),this.modulus=i,this.expTable=new Int32Array(i),this.logTable=new Int32Array(i);let a=1;for(let h=0;h0;j--){let K=h.evaluateAt(this.field.exp(j));c[s-j]=K,K!==0&&(d=!0)}if(!d)return 0;let m=this.field.getOne();if(a!=null)for(const j of a){let K=this.field.exp(i.length-1-j),tt=new We(this.field,new Int32Array([this.field.subtract(0,K),1]));m=m.multiply(tt)}let _=new We(this.field,c),C=this.runEuclideanAlgorithm(this.field.buildMonomial(s,1),_,s),M=C[0],R=C[1],D=this.findErrorLocations(M),k=this.findErrorMagnitudes(R,M,D);for(let j=0;j=Math.round(a/2);){let D=h,k=d;if(h=c,d=m,h.isZero())throw P.getChecksumInstance();c=D;let j=this.field.getZero(),K=h.getCoefficient(h.getDegree()),tt=this.field.inverse(K);for(;c.getDegree()>=h.getDegree()&&!c.isZero();){let st=c.getDegree()-h.getDegree(),Et=this.field.multiply(c.getCoefficient(c.getDegree()),tt);j=j.add(this.field.buildMonomial(st,Et)),c=c.subtract(h.multiplyByMonomial(st,Et))}m=j.multiply(d).subtract(k).negative()}let _=m.getCoefficient(0);if(_===0)throw P.getChecksumInstance();let C=this.field.inverse(_),M=m.multiply(C),R=c.multiply(C);return[M,R]}findErrorLocations(i){let s=i.getDegree(),a=new Int32Array(s),h=0;for(let c=1;c0){let _=a?this.topLeft:this.topRight,C=Math.trunc(_.getY()-i);C<0&&(C=0);let M=new St(_.getX(),C);a?h=M:d=M}if(s>0){let _=a?this.bottomLeft:this.bottomRight,C=Math.trunc(_.getY()+s);C>=this.image.getHeight()&&(C=this.image.getHeight()-1);let M=new St(_.getX(),C);a?c=M:m=M}return new je(this.image,h,c,d,m)}getMinX(){return this.minX}getMaxX(){return this.maxX}getMinY(){return this.minY}getMaxY(){return this.maxY}getTopLeft(){return this.topLeft}getTopRight(){return this.topRight}getBottomLeft(){return this.bottomLeft}getBottomRight(){return this.bottomRight}}class Us{constructor(i,s,a,h){this.columnCount=i,this.errorCorrectionLevel=h,this.rowCountUpperPart=s,this.rowCountLowerPart=a,this.rowCount=s+a}getColumnCount(){return this.columnCount}getErrorCorrectionLevel(){return this.errorCorrectionLevel}getRowCount(){return this.rowCount}getRowCountUpperPart(){return this.rowCountUpperPart}getRowCountLowerPart(){return this.rowCountLowerPart}}class pn{constructor(){this.buffer=""}static form(i,s){let a=-1;function h(d,m,_,C,M,R){if(d==="%%")return"%";if(s[++a]===void 0)return;d=C?parseInt(C.substr(1)):void 0;let D=M?parseInt(M.substr(1)):void 0,k;switch(R){case"s":k=s[a];break;case"c":k=s[a][0];break;case"f":k=parseFloat(s[a]).toFixed(d);break;case"p":k=parseFloat(s[a]).toPrecision(d);break;case"e":k=parseFloat(s[a]).toExponential(d);break;case"x":k=parseInt(s[a]).toString(D||16);break;case"d":k=parseFloat(parseInt(s[a],D||10).toPrecision(d)).toFixed(0);break}k=typeof k=="object"?JSON.stringify(k):(+k).toString(D);let j=parseInt(_),K=_&&_[0]+""=="0"?"0":" ";for(;k.length=0&&(s=this.codewords[h],s!=null)||(h=this.imageRowToCodewordIndex(i)+a,ha,getValue:()=>h};c.getValue()>i?(i=c.getValue(),s=[],s.push(c.getKey())):c.getValue()===i&&s.push(c.getKey())}return Ut.toIntArray(s)}getConfidence(i){return this.values.get(i)}}class Hn extends yn{constructor(i,s){super(i),this._isLeft=s}setRowNumbers(){for(let i of this.getCodewords())i?.setRowNumberAsRowIndicatorColumn()}adjustCompleteIndicatorColumnRowNumbers(i){let s=this.getCodewords();this.setRowNumbers(),this.removeIncorrectCodewords(s,i);let a=this.getBoundingBox(),h=this._isLeft?a.getTopLeft():a.getTopRight(),c=this._isLeft?a.getBottomLeft():a.getBottomRight(),d=this.imageRowToCodewordIndex(Math.trunc(h.getY())),m=this.imageRowToCodewordIndex(Math.trunc(c.getY())),_=-1,C=1,M=0;for(let R=d;R=i.getRowCount()||k>R)s[R]=null;else{let j;C>2?j=(C-2)*k:j=k;let K=j>=R;for(let tt=1;tt<=j&&!K;tt++)K=s[R-tt]!=null;K?s[R]=null:(_=D.getRowNumber(),M=1)}}}getRowHeights(){let i=this.getBarcodeMetadata();if(i==null)return null;this.adjustIncompleteIndicatorColumnRowNumbers(i);let s=new Int32Array(i.getRowCount());for(let a of this.getCodewords())if(a!=null){let h=a.getRowNumber();if(h>=s.length)continue;s[h]++}return s}adjustIncompleteIndicatorColumnRowNumbers(i){let s=this.getBoundingBox(),a=this._isLeft?s.getTopLeft():s.getTopRight(),h=this._isLeft?s.getBottomLeft():s.getBottomRight(),c=this.imageRowToCodewordIndex(Math.trunc(a.getY())),d=this.imageRowToCodewordIndex(Math.trunc(h.getY())),m=this.getCodewords(),_=-1;for(let C=c;C=i.getRowCount()?m[C]=null:_=M.getRowNumber())}}getBarcodeMetadata(){let i=this.getCodewords(),s=new wn,a=new wn,h=new wn,c=new wn;for(let m of i){if(m==null)continue;m.setRowNumberAsRowIndicatorColumn();let _=m.getValue()%30,C=m.getRowNumber();switch(this._isLeft||(C+=2),C%3){case 0:a.setValue(_*3+1);break;case 1:c.setValue(_/3),h.setValue(_%3);break;case 2:s.setValue(_+1);break}}if(s.getValue().length===0||a.getValue().length===0||h.getValue().length===0||c.getValue().length===0||s.getValue()[0]<1||a.getValue()[0]+h.getValue()[0]Ut.MAX_ROWS_IN_BARCODE)return null;let d=new Us(s.getValue()[0],a.getValue()[0],h.getValue()[0],c.getValue()[0]);return this.removeIncorrectCodewords(i,d),d}removeIncorrectCodewords(i,s){for(let a=0;as.getRowCount()){i[a]=null;continue}switch(this._isLeft||(d+=2),d%3){case 0:c*3+1!==s.getRowCountUpperPart()&&(i[a]=null);break;case 1:(Math.trunc(c/3)!==s.getErrorCorrectionLevel()||c%3!==s.getRowCountLowerPart())&&(i[a]=null);break;case 2:c+1!==s.getColumnCount()&&(i[a]=null);break}}}isLeft(){return this._isLeft}toString(){return"IsLeft: "+this._isLeft+` +`+super.toString()}}class fn{constructor(i,s){this.ADJUST_ROW_NUMBER_SKIP=2,this.barcodeMetadata=i,this.barcodeColumnCount=i.getColumnCount(),this.boundingBox=s,this.detectionResultColumns=new Array(this.barcodeColumnCount+2)}getDetectionResultColumns(){this.adjustIndicatorColumnRowNumbers(this.detectionResultColumns[0]),this.adjustIndicatorColumnRowNumbers(this.detectionResultColumns[this.barcodeColumnCount+1]);let i=Ut.MAX_CODEWORDS_IN_BARCODE,s;do s=i,i=this.adjustRowNumbersAndGetCount();while(i>0&&i0&&c0&&(m[0]=a[s-1],m[4]=c[s-1],m[5]=d[s-1]),s>1&&(m[8]=a[s-2],m[10]=c[s-2],m[11]=d[s-2]),s>=1;a=s&1,Ni.RATIOS_TABLE[i]||(Ni.RATIOS_TABLE[i]=new Array(Ut.BARS_IN_MODULE)),Ni.RATIOS_TABLE[i][Ut.BARS_IN_MODULE-h-1]=Math.fround(c/Ut.MODULES_IN_CODEWORD)}}this.bSymbolTableReady=!0}static getDecodedValue(i){let s=Ni.getDecodedCodewordValue(Ni.sampleBitCounts(i));return s!==-1?s:Ni.getClosestDecodedValue(i)}static sampleBitCounts(i){let s=ee.sum(i),a=new Int32Array(Ut.BARS_IN_MODULE),h=0,c=0;for(let d=0;d1)for(let d=0;d=h)break}mnew Array(Ut.BARS_IN_MODULE));class En{constructor(){this.segmentCount=-1,this.fileSize=-1,this.timestamp=-1,this.checksum=-1}getSegmentIndex(){return this.segmentIndex}setSegmentIndex(i){this.segmentIndex=i}getFileId(){return this.fileId}setFileId(i){this.fileId=i}getOptionalData(){return this.optionalData}setOptionalData(i){this.optionalData=i}isLastSegment(){return this.lastSegment}setLastSegment(i){this.lastSegment=i}getSegmentCount(){return this.segmentCount}setSegmentCount(i){this.segmentCount=i}getSender(){return this.sender||null}setSender(i){this.sender=i}getAddressee(){return this.addressee||null}setAddressee(i){this.addressee=i}getFileName(){return this.fileName}setFileName(i){this.fileName=i}getFileSize(){return this.fileSize}setFileSize(i){this.fileSize=i}getChecksum(){return this.checksum}setChecksum(i){this.checksum=i}getTimestamp(){return this.timestamp}setTimestamp(i){this.timestamp=i}}class qo{static parseLong(i,s=void 0){return parseInt(i,s)}}class Jo extends E{}Jo.kind="NullPointerException";class El{writeBytes(i){this.writeBytesOffset(i,0,i.length)}writeBytesOffset(i,s,a){if(i==null)throw new Jo;if(s<0||s>i.length||a<0||s+a>i.length||s+a<0)throw new V;if(a===0)return;for(let h=0;h0&&this.grow(i)}grow(i){let a=this.buf.length<<1;if(a-i<0&&(a=i),a<0){if(i<0)throw new Cl;a=Y.MAX_VALUE}this.buf=U.copyOfUint8Array(this.buf,a)}write(i){this.ensureCapacity(this.count+1),this.buf[this.count]=i,this.count+=1}writeBytesOffset(i,s,a){if(s<0||s>i.length||a<0||s+a-i.length>0)throw new V;this.ensureCapacity(this.count+a),F.arraycopy(i,s,this.buf,this.count,a),this.count+=a}writeTo(i){i.writeBytesOffset(this.buf,0,this.count)}reset(){this.count=0}toByteArray(){return U.copyOfUint8Array(this.buf,this.count)}size(){return this.count}toString(i){return i?typeof i=="string"?this.toString_string(i):this.toString_number(i):this.toString_void()}toString_void(){return new String(this.buf).toString()}toString_string(i){return new String(this.buf).toString()}toString_number(i){return new String(this.buf).toString()}close(){}}var Ie;(function(T){T[T.ALPHA=0]="ALPHA",T[T.LOWER=1]="LOWER",T[T.MIXED=2]="MIXED",T[T.PUNCT=3]="PUNCT",T[T.ALPHA_SHIFT=4]="ALPHA_SHIFT",T[T.PUNCT_SHIFT=5]="PUNCT_SHIFT"})(Ie||(Ie={}));function Qo(){if(typeof window<"u")return window.BigInt||null;if(typeof Mn<"u")return Mn.BigInt||null;if(typeof self<"u")return self.BigInt||null;throw new Error("Can't search globals for BigInt!")}let Ji;function Dn(T){if(typeof Ji>"u"&&(Ji=Qo()),Ji===null)throw new Error("BigInt is not supported!");return Ji(T)}function Il(){let T=[];T[0]=Dn(1);let i=Dn(900);T[1]=i;for(let s=2;s<16;s++)T[s]=T[s-1]*i;return T}class nt{static decode(i,s){let a=new ut(""),h=H.ISO8859_1;a.enableDecoding(h);let c=1,d=i[c++],m=new En;for(;ci[0])throw X.getFormatInstance();let h=new Int32Array(nt.NUMBER_OF_SEQUENCE_CODEWORDS);for(let m=0;m0){for(let D=0;D<6;++D)d.write(Number(Dn(_)>>Dn(8*(5-D))));_=0,m=0}break}h===s[0]&&R0){for(let k=0;k<6;++k)d.write(Number(Dn(_)>>Dn(8*(5-k))));_=0,m=0}}break}return c.append(xt.decode(d.toByteArray(),a)),h}static numericCompaction(i,s,a){let h=0,c=!1,d=new Int32Array(nt.MAX_NUMERIC_CODEWORDS);for(;s0&&(a.append(nt.decodeBase900toBase10(d,h)),h=0)}return s}static decodeBase900toBase10(i,s){let a=Dn(0);for(let c=0;c@[\\]_\`~!\r ,: +-.$/"|*()?{}'`,nt.MIXED_CHARS="0123456789&\r ,:#-.$/+%*=^",nt.EXP900=Qo()?Il():[],nt.NUMBER_OF_SEQUENCE_CODEWORDS=2;class qt{constructor(){}static decode(i,s,a,h,c,d,m){let _=new je(i,s,a,h,c),C=null,M=null,R;for(let j=!0;;j=!1){if(s!=null&&(C=qt.getRowIndicatorColumn(i,_,s,!0,d,m)),h!=null&&(M=qt.getRowIndicatorColumn(i,_,h,!1,d,m)),R=qt.merge(C,M),R==null)throw q.getNotFoundInstance();let K=R.getBoundingBox();if(j&&K!=null&&(K.getMinY()<_.getMinY()||K.getMaxY()>_.getMaxY()))_=K;else break}R.setBoundingBox(_);let D=R.getBarcodeColumnCount()+1;R.setDetectionResultColumn(0,C),R.setDetectionResultColumn(D,M);let k=C!=null;for(let j=1;j<=D;j++){let K=k?j:D-j;if(R.getDetectionResultColumn(K)!==void 0)continue;let tt;K===0||K===D?tt=new Hn(_,K===0):tt=new yn(_),R.setDetectionResultColumn(K,tt);let st=-1,Et=st;for(let At=_.getMinY();At<=_.getMaxY();At++){if(st=qt.getStartColumn(R,K,At,k),st<0||st>_.getMaxX()){if(Et===-1)continue;st=Et}let mt=qt.detectCodeword(i,_.getMinX(),_.getMaxX(),k,st,At,d,m);mt!=null&&(tt.setCodeword(At,mt),Et=st,d=Math.min(d,mt.getWidth()),m=Math.max(m,mt.getWidth()))}}return qt.createDecoderResult(R)}static merge(i,s){if(i==null&&s==null)return null;let a=qt.getBarcodeMetadata(i,s);if(a==null)return null;let h=je.merge(qt.adjustBoundingBox(i),qt.adjustBoundingBox(s));return new fn(a,h)}static adjustBoundingBox(i){if(i==null)return null;let s=i.getRowHeights();if(s==null)return null;let a=qt.getMax(s),h=0;for(let m of s)if(h+=a-m,m>0)break;let c=i.getCodewords();for(let m=0;h>0&&c[m]==null;m++)h--;let d=0;for(let m=s.length-1;m>=0&&(d+=a-s[m],!(s[m]>0));m--);for(let m=c.length-1;d>0&&c[m]==null;m--)d--;return i.getBoundingBox().addMissingRows(h,d,i.isLeft())}static getMax(i){let s=-1;for(let a of i)s=Math.max(s,a);return s}static getBarcodeMetadata(i,s){let a;if(i==null||(a=i.getBarcodeMetadata())==null)return s==null?null:s.getBarcodeMetadata();let h;return s==null||(h=s.getBarcodeMetadata())==null?a:a.getColumnCount()!==h.getColumnCount()&&a.getErrorCorrectionLevel()!==h.getErrorCorrectionLevel()&&a.getRowCount()!==h.getRowCount()?null:a}static getRowIndicatorColumn(i,s,a,h,c,d){let m=new Hn(s,h);for(let _=0;_<2;_++){let C=_===0?1:-1,M=Math.trunc(Math.trunc(a.getX()));for(let R=Math.trunc(Math.trunc(a.getY()));R<=s.getMaxY()&&R>=s.getMinY();R+=C){let D=qt.detectCodeword(i,0,i.getWidth(),h,M,R,c,d);D!=null&&(m.setCodeword(R,D),h?M=D.getStartX():M=D.getEndX())}}return m}static adjustCodewordCount(i,s){let a=s[0][1],h=a.getValue(),c=i.getBarcodeColumnCount()*i.getBarcodeRowCount()-qt.getNumberOfECCodeWords(i.getBarcodeECLevel());if(h.length===0){if(c<1||c>Ut.MAX_CODEWORDS_IN_BARCODE)throw q.getNotFoundInstance();a.setValue(c)}else h[0]!==c&&a.setValue(c)}static createDecoderResult(i){let s=qt.createBarcodeMatrix(i);qt.adjustCodewordCount(i,s);let a=new Array,h=new Int32Array(i.getBarcodeRowCount()*i.getBarcodeColumnCount()),c=[],d=new Array;for(let _=0;_0;){for(let _=0;_new Array(i.getBarcodeColumnCount()+2));for(let h=0;h=0){if(d>=s.length)continue;s[d][a].setValue(c.getValue())}}}a++}return s}static isValidBarcodeColumn(i,s){return s>=0&&s<=i.getBarcodeColumnCount()+1}static getStartColumn(i,s,a,h){let c=h?1:-1,d=null;if(qt.isValidBarcodeColumn(i,s-c)&&(d=i.getDetectionResultColumn(s-c).getCodeword(a)),d!=null)return h?d.getEndX():d.getStartX();if(d=i.getDetectionResultColumn(s).getCodewordNearby(a),d!=null)return h?d.getStartX():d.getEndX();if(qt.isValidBarcodeColumn(i,s-c)&&(d=i.getDetectionResultColumn(s-c).getCodewordNearby(a)),d!=null)return h?d.getEndX():d.getStartX();let m=0;for(;qt.isValidBarcodeColumn(i,s-c);){s-=c;for(let _ of i.getDetectionResultColumn(s).getCodewords())if(_!=null)return(h?_.getEndX():_.getStartX())+c*m*(_.getEndX()-_.getStartX());m++}return h?i.getBoundingBox().getMinX():i.getBoundingBox().getMaxX()}static detectCodeword(i,s,a,h,c,d,m,_){c=qt.adjustCodewordStartColumn(i,s,a,h,c,d);let C=qt.getModuleBitCount(i,s,a,h,c,d);if(C==null)return null;let M,R=ee.sum(C);if(h)M=c+R;else{for(let j=0;j=s)&&C<_.length;)i.get(m,d)===R?(_[C]++,m+=M):(C++,R=!R);return C===_.length||m===(h?a:s)&&C===_.length-1?_:null}static getNumberOfECCodeWords(i){return 2<=s:mqt.CODEWORD_SKEW_SIZE)return c;m+=_}_=-_,h=!h}return m}static checkCodewordSkew(i,s,a){return s-qt.CODEWORD_SKEW_SIZE<=i&&i<=a+qt.CODEWORD_SKEW_SIZE}static decodeCodewords(i,s,a){if(i.length===0)throw X.getFormatInstance();let h=1<a/2+qt.MAX_ERRORS||a<0||a>qt.MAX_EC_CODEWORDS)throw P.getChecksumInstance();return qt.errorCorrection.decode(i,a,s)}static verifyCodewordCount(i,s){if(i.length<4)throw X.getFormatInstance();let a=i[0];if(a>i.length)throw X.getFormatInstance();if(a===0)if(s>=1;return s}static getCodewordBucketNumber(i){return i instanceof Int32Array?this.getCodewordBucketNumber_Int32Array(i):this.getCodewordBucketNumber_number(i)}static getCodewordBucketNumber_number(i){return qt.getCodewordBucketNumber(qt.getBitCountForCodeword(i))}static getCodewordBucketNumber_Int32Array(i){return(i[0]-i[2]+i[4]-i[6]+9)%9}static toString(i){let s=new pn;for(let a=0;ad)}static getMaxWidth(i,s){return i==null||s==null?0:Math.trunc(Math.abs(i.getX()-s.getX()))}static getMinWidth(i,s){return i==null||s==null?Y.MAX_VALUE:Math.trunc(Math.abs(i.getX()-s.getX()))}static getMaxCodewordWidth(i){return Math.floor(Math.max(Math.max(fi.getMaxWidth(i[0],i[4]),fi.getMaxWidth(i[6],i[2])*Ut.MODULES_IN_CODEWORD/Ut.MODULES_IN_STOP_PATTERN),Math.max(fi.getMaxWidth(i[1],i[5]),fi.getMaxWidth(i[7],i[3])*Ut.MODULES_IN_CODEWORD/Ut.MODULES_IN_STOP_PATTERN)))}static getMinCodewordWidth(i){return Math.floor(Math.min(Math.min(fi.getMinWidth(i[0],i[4]),fi.getMinWidth(i[6],i[2])*Ut.MODULES_IN_CODEWORD/Ut.MODULES_IN_STOP_PATTERN),Math.min(fi.getMinWidth(i[1],i[5]),fi.getMinWidth(i[7],i[3])*Ut.MODULES_IN_CODEWORD/Ut.MODULES_IN_STOP_PATTERN)))}reset(){}}class zs extends E{}zs.kind="ReaderException";class $o{constructor(i,s){this.verbose=i===!0,s&&this.setHints(s)}decode(i,s){return s&&this.setHints(s),this.decodeInternal(i)}decodeWithState(i){return(this.readers===null||this.readers===void 0)&&this.setHints(null),this.decodeInternal(i)}setHints(i){this.hints=i;const s=!n(i)&&i.get(ot.TRY_HARDER)===!0,a=n(i)?null:i.get(ot.POSSIBLE_FORMATS),h=new Array;if(!n(a)){const c=a.some(d=>d===Rt.UPC_A||d===Rt.UPC_E||d===Rt.EAN_13||d===Rt.EAN_8||d===Rt.CODABAR||d===Rt.CODE_39||d===Rt.CODE_93||d===Rt.CODE_128||d===Rt.ITF||d===Rt.RSS_14||d===Rt.RSS_EXPANDED);c&&!s&&h.push(new _s(i,this.verbose)),a.includes(Rt.QR_CODE)&&h.push(new un),a.includes(Rt.DATA_MATRIX)&&h.push(new He),a.includes(Rt.AZTEC)&&h.push(new Xn),a.includes(Rt.PDF_417)&&h.push(new fi),c&&s&&h.push(new _s(i,this.verbose))}h.length===0&&(s||h.push(new _s(i,this.verbose)),h.push(new un),h.push(new He),h.push(new Xn),h.push(new fi),s&&h.push(new _s(i,this.verbose))),this.readers=h}reset(){if(this.readers!==null)for(const i of this.readers)i.reset()}decodeInternal(i){if(this.readers===null)throw new zs("No readers where selected, nothing can be read.");for(const s of this.readers)try{return s.decode(i,this.hints)}catch(a){if(a instanceof zs)continue}throw new q("No MultiFormat Readers were able to detect the code.")}}class Ml extends te{constructor(i=null,s=500){const a=new $o;a.setHints(i),super(a,s)}decodeBitmap(i){return this.reader.decodeWithState(i)}}class bl extends te{constructor(i=500){super(new fi,i)}}class Tl extends te{constructor(i=500){super(new un,i)}}var Kr;(function(T){T[T.ERROR_CORRECTION=0]="ERROR_CORRECTION",T[T.CHARACTER_SET=1]="CHARACTER_SET",T[T.DATA_MATRIX_SHAPE=2]="DATA_MATRIX_SHAPE",T[T.MIN_SIZE=3]="MIN_SIZE",T[T.MAX_SIZE=4]="MAX_SIZE",T[T.MARGIN=5]="MARGIN",T[T.PDF417_COMPACT=6]="PDF417_COMPACT",T[T.PDF417_COMPACTION=7]="PDF417_COMPACTION",T[T.PDF417_DIMENSIONS=8]="PDF417_DIMENSIONS",T[T.AZTEC_LAYERS=9]="AZTEC_LAYERS",T[T.QR_VERSION=10]="QR_VERSION"})(Kr||(Kr={}));var ai=Kr;class qr{constructor(i){this.field=i,this.cachedGenerators=[],this.cachedGenerators.push(new Ke(i,Int32Array.from([1])))}buildGenerator(i){const s=this.cachedGenerators;if(i>=s.length){let a=s[s.length-1];const h=this.field;for(let c=s.length;c<=i;c++){const d=a.multiply(new Ke(h,Int32Array.from([1,h.exp(c-1+h.getGeneratorBase())])));s.push(d),a=d}}return s[i]}encode(i,s){if(s===0)throw new A("No error correction bytes");const a=i.length-s;if(a<=0)throw new A("No data bytes provided");const h=this.buildGenerator(s),c=new Int32Array(a);F.arraycopy(i,0,c,0,a);let d=new Ke(this.field,c);d=d.multiplyByMonomial(s,1);const _=d.divide(h)[1].getCoefficients(),C=s-_.length;for(let M=0;M=5&&(a+=Xe.N1+(_-5)),_=1,C=R)}_>=5&&(a+=Xe.N1+(_-5))}return a}}Xe.N1=3,Xe.N2=3,Xe.N3=40,Xe.N4=10;class mr{constructor(i,s){this.width=i,this.height=s;const a=new Array(s);for(let h=0;h!==s;h++)a[h]=new Uint8Array(i);this.bytes=a}getHeight(){return this.height}getWidth(){return this.width}get(i,s){return this.bytes[s][i]}getArray(){return this.bytes}setNumber(i,s,a){this.bytes[s][i]=a}setBoolean(i,s,a){this.bytes[s][i]=a?1:0}clear(i){for(const s of this.bytes)U.fill(s,i)}equals(i){if(!(i instanceof mr))return!1;const s=i;if(this.width!==s.width||this.height!==s.height)return!1;for(let a=0,h=this.height;a> +`),i.toString()}setMode(i){this.mode=i}setECLevel(i){this.ecLevel=i}setVersion(i){this.version=i}setMaskPattern(i){this.maskPattern=i}setMatrix(i){this.matrix=i}static isValidMaskPattern(i){return i>=0&&i0;){for(d===6&&(d-=1);m>=0&&m=a;)i^=s<=0)for(let _=0;_!==d;_++){const C=h[_];C>=0&&bt.isEmpty(s.get(C,m))&&bt.embedPositionAdjustmentPattern(C-2,m-2,s)}}}}bt.POSITION_DETECTION_PATTERN=Array.from([Int32Array.from([1,1,1,1,1,1,1]),Int32Array.from([1,0,0,0,0,0,1]),Int32Array.from([1,0,1,1,1,0,1]),Int32Array.from([1,0,1,1,1,0,1]),Int32Array.from([1,0,1,1,1,0,1]),Int32Array.from([1,0,0,0,0,0,1]),Int32Array.from([1,1,1,1,1,1,1])]),bt.POSITION_ADJUSTMENT_PATTERN=Array.from([Int32Array.from([1,1,1,1,1]),Int32Array.from([1,0,0,0,1]),Int32Array.from([1,0,1,0,1]),Int32Array.from([1,0,0,0,1]),Int32Array.from([1,1,1,1,1])]),bt.POSITION_ADJUSTMENT_PATTERN_COORDINATE_TABLE=Array.from([Int32Array.from([-1,-1,-1,-1,-1,-1,-1]),Int32Array.from([6,18,-1,-1,-1,-1,-1]),Int32Array.from([6,22,-1,-1,-1,-1,-1]),Int32Array.from([6,26,-1,-1,-1,-1,-1]),Int32Array.from([6,30,-1,-1,-1,-1,-1]),Int32Array.from([6,34,-1,-1,-1,-1,-1]),Int32Array.from([6,22,38,-1,-1,-1,-1]),Int32Array.from([6,24,42,-1,-1,-1,-1]),Int32Array.from([6,26,46,-1,-1,-1,-1]),Int32Array.from([6,28,50,-1,-1,-1,-1]),Int32Array.from([6,30,54,-1,-1,-1,-1]),Int32Array.from([6,32,58,-1,-1,-1,-1]),Int32Array.from([6,34,62,-1,-1,-1,-1]),Int32Array.from([6,26,46,66,-1,-1,-1]),Int32Array.from([6,26,48,70,-1,-1,-1]),Int32Array.from([6,26,50,74,-1,-1,-1]),Int32Array.from([6,30,54,78,-1,-1,-1]),Int32Array.from([6,30,56,82,-1,-1,-1]),Int32Array.from([6,30,58,86,-1,-1,-1]),Int32Array.from([6,34,62,90,-1,-1,-1]),Int32Array.from([6,28,50,72,94,-1,-1]),Int32Array.from([6,26,50,74,98,-1,-1]),Int32Array.from([6,30,54,78,102,-1,-1]),Int32Array.from([6,28,54,80,106,-1,-1]),Int32Array.from([6,32,58,84,110,-1,-1]),Int32Array.from([6,30,58,86,114,-1,-1]),Int32Array.from([6,34,62,90,118,-1,-1]),Int32Array.from([6,26,50,74,98,122,-1]),Int32Array.from([6,30,54,78,102,126,-1]),Int32Array.from([6,26,52,78,104,130,-1]),Int32Array.from([6,30,56,82,108,134,-1]),Int32Array.from([6,34,60,86,112,138,-1]),Int32Array.from([6,30,58,86,114,142,-1]),Int32Array.from([6,34,62,90,118,146,-1]),Int32Array.from([6,30,54,78,102,126,150]),Int32Array.from([6,24,50,76,102,128,154]),Int32Array.from([6,28,54,80,106,132,158]),Int32Array.from([6,32,58,84,110,136,162]),Int32Array.from([6,26,54,82,110,138,166]),Int32Array.from([6,30,58,86,114,142,170])]),bt.TYPE_INFO_COORDINATES=Array.from([Int32Array.from([8,0]),Int32Array.from([8,1]),Int32Array.from([8,2]),Int32Array.from([8,3]),Int32Array.from([8,4]),Int32Array.from([8,5]),Int32Array.from([8,7]),Int32Array.from([8,8]),Int32Array.from([7,8]),Int32Array.from([5,8]),Int32Array.from([4,8]),Int32Array.from([3,8]),Int32Array.from([2,8]),Int32Array.from([1,8]),Int32Array.from([0,8])]),bt.VERSION_INFO_POLY=7973,bt.TYPE_INFO_POLY=1335,bt.TYPE_INFO_MASK_PATTERN=21522;class Sl{constructor(i,s){this.dataBytes=i,this.errorCorrectionBytes=s}getDataBytes(){return this.dataBytes}getErrorCorrectionBytes(){return this.errorCorrectionBytes}}class Re{constructor(){}static calculateMaskPenalty(i){return Xe.applyMaskPenaltyRule1(i)+Xe.applyMaskPenaltyRule2(i)+Xe.applyMaskPenaltyRule3(i)+Xe.applyMaskPenaltyRule4(i)}static encode(i,s,a=null){let h=Re.DEFAULT_BYTE_MODE_ENCODING;const c=a!==null&&a.get(ai.CHARACTER_SET)!==void 0;c&&(h=a.get(ai.CHARACTER_SET).toString());const d=this.chooseMode(i,h),m=new Z;if(d===Dt.BYTE&&(c||Re.DEFAULT_BYTE_MODE_ENCODING!==h)){const At=H.getCharacterSetECIByName(h);At!==void 0&&this.appendECI(At,m)}this.appendModeInfo(d,m);const _=new Z;this.appendBytes(i,d,_,h);let C;if(a!==null&&a.get(ai.QR_VERSION)!==void 0){const At=Number.parseInt(a.get(ai.QR_VERSION).toString(),10);C=Nt.getVersionForNumber(At);const mt=this.calculateBitsNeeded(d,m,_,C);if(!this.willFit(mt,C,s))throw new zt("Data too big for requested version")}else C=this.recommendVersion(s,d,m,_);const M=new Z;M.appendBitArray(m);const R=d===Dt.BYTE?_.getSizeInBytes():i.length;this.appendLengthInfo(R,C,d,M),M.appendBitArray(_);const D=C.getECBlocksForLevel(s),k=C.getTotalCodewords()-D.getTotalECCodewords();this.terminateBits(k,M);const j=this.interleaveWithECBytes(M,C.getTotalCodewords(),k,D.getNumBlocks()),K=new jn;K.setECLevel(s),K.setMode(d),K.setVersion(C);const tt=C.getDimensionForVersion(),st=new mr(tt,tt),Et=this.chooseMaskPattern(j,s,C,st);return K.setMaskPattern(Et),bt.buildMatrix(j,s,C,Et,st),K.setMatrix(st),K}static recommendVersion(i,s,a,h){const c=this.calculateBitsNeeded(s,a,h,Nt.getVersionForNumber(1)),d=this.chooseVersion(c,i),m=this.calculateBitsNeeded(s,a,h,d);return this.chooseVersion(m,i)}static calculateBitsNeeded(i,s,a,h){return s.getSize()+i.getCharacterCountBits(h)+a.getSize()}static getAlphanumericCode(i){return i159)&&(c<224||c>235))return!1}return!0}static chooseMaskPattern(i,s,a,h){let c=Number.MAX_SAFE_INTEGER,d=-1;for(let m=0;m=_}static terminateBits(i,s){const a=i*8;if(s.getSize()>a)throw new zt("data bits cannot fit in the QR Code"+s.getSize()+" > "+a);for(let d=0;d<4&&s.getSize()0)for(let d=h;d<8;d++)s.appendBit(!1);const c=i-s.getSizeInBytes();for(let d=0;d=a)throw new zt("Block ID too large");const m=i%a,_=a-m,C=Math.floor(i/a),M=C+1,R=Math.floor(s/a),D=R+1,k=C-R,j=M-D;if(k!==j)throw new zt("EC bytes mismatch");if(a!==_+m)throw new zt("RS blocks mismatch");if(i!==(R+k)*_+(D+j)*m)throw new zt("Total bytes mismatch");h<_?(c[0]=R,d[0]=k):(c[0]=D,d[0]=j)}static interleaveWithECBytes(i,s,a,h){if(i.getSizeInBytes()!==a)throw new zt("Number of bits and data bytes does not match");let c=0,d=0,m=0;const _=new Array;for(let M=0;M=1<=0&&s<=9}static appendNumericBytes(i,s){const a=i.length;let h=0;for(;h=33088&&_<=40956?C=_-33088:_>=57408&&_<=60351&&(C=_-49472),C===-1)throw new zt("Invalid byte sequence");const M=(C>>8)*192+(C&255);s.appendBits(M,13)}}static appendECI(i,s){s.appendBits(Dt.ECI.getBits(),4),s.appendBits(i.getValue(),8)}}Re.ALPHANUMERIC_TABLE=Int32Array.from([-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,36,-1,-1,-1,37,38,-1,-1,-1,-1,39,40,-1,41,42,43,0,1,2,3,4,5,6,7,8,9,44,-1,-1,-1,-1,-1,-1,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,-1,-1,-1,-1,-1]),Re.DEFAULT_BYTE_MODE_ENCODING=H.UTF8.getName();class Qi{write(i,s,a,h=null){if(i.length===0)throw new A("Found empty contents");if(s<0||a<0)throw new A("Requested dimensions are too small: "+s+"x"+a);let c=Ee.L,d=Qi.QUIET_ZONE_SIZE;h!==null&&(h.get(ai.ERROR_CORRECTION)!==void 0&&(c=Ee.fromString(h.get(ai.ERROR_CORRECTION).toString())),h.get(ai.MARGIN)!==void 0&&(d=Number.parseInt(h.get(ai.MARGIN).toString(),10)));const m=Re.encode(i,c,h);return this.renderResult(m,s,a,d)}writeToDom(i,s,a,h,c=null){typeof i=="string"&&(i=document.querySelector(i));const d=this.write(s,a,h,c);i&&i.appendChild(d)}renderResult(i,s,a,h){const c=i.getMatrix();if(c===null)throw new hi;const d=c.getWidth(),m=c.getHeight(),_=d+h*2,C=m+h*2,M=Math.max(s,_),R=Math.max(a,C),D=Math.min(Math.floor(M/_),Math.floor(R/C)),k=Math.floor((M-d*D)/2),j=Math.floor((R-m*D)/2),K=this.createSVGElement(M,R);for(let tt=0,st=j;tts||c+m>a)throw new A("Crop rectangle does not fit within image data.");_&&this.reverseHorizontal(d,m)}getRow(i,s){if(i<0||i>=this.getHeight())throw new A("Requested row is outside the image: "+i);const a=this.getWidth();(s==null||s.length>16&255,k=R>>7&510,j=R&255;C[M]=(D+k+j)/4&255}this.luminances=C}else this.luminances=i;if(h===void 0&&(this.dataWidth=s),c===void 0&&(this.dataHeight=a),d===void 0&&(this.left=0),m===void 0&&(this.top=0),this.left+s>this.dataWidth||this.top+a>this.dataHeight)throw new A("Crop rectangle does not fit within image data.")}getRow(i,s){if(i<0||i>=this.getHeight())throw new A("Requested row is outside the image: "+i);const a=this.getWidth();(s==null||s.length"}}class qn extends Ze{constructor(i,s,a){super(i,0,0),this.binaryShiftStart=s,this.binaryShiftByteCount=a}appendTo(i,s){for(let a=0;a62?i.appendBits(this.binaryShiftByteCount-31,16):a===0?i.appendBits(Math.min(this.binaryShiftByteCount,31),5):i.appendBits(this.binaryShiftByteCount-31,5)),i.appendBits(s[this.binaryShiftStart+a],8)}addBinaryShift(i,s){return new qn(this,i,s)}toString(){return"<"+this.binaryShiftStart+"::"+(this.binaryShiftStart+this.binaryShiftByteCount-1)+">"}}function vl(T,i,s){return new qn(T,i,s)}function Ws(T,i,s){return new Ze(T,i,s)}const f=["UPPER","LOWER","DIGIT","MIXED","PUNCT"],p=0,y=1,b=2,I=3,v=4,N=new Ze(null,0,0),O=[Int32Array.from([0,(5<<16)+28,(5<<16)+30,(5<<16)+29,656318]),Int32Array.from([(9<<16)+480+14,0,(5<<16)+30,(5<<16)+29,656318]),Int32Array.from([(4<<16)+14,(9<<16)+448+28,0,(9<<16)+448+29,932798]),Int32Array.from([(5<<16)+29,(5<<16)+28,656318,0,(5<<16)+30]),Int32Array.from([(5<<16)+31,656380,656382,656381,0])];function G(T){for(let i of T)U.fill(i,-1);return T[p][v]=0,T[y][v]=0,T[y][p]=28,T[I][v]=0,T[b][v]=0,T[b][p]=15,T}const W=G(U.createInt32Array(6,6));class Q{constructor(i,s,a,h){this.token=i,this.mode=s,this.binaryShiftByteCount=a,this.bitCount=h}getMode(){return this.mode}getToken(){return this.token}getBinaryShiftByteCount(){return this.binaryShiftByteCount}getBitCount(){return this.bitCount}latchAndAppend(i,s){let a=this.bitCount,h=this.token;if(i!==this.mode){let d=O[this.mode][i];h=Ws(h,d&65535,d>>16),a+=d>>16}let c=i===b?4:5;return h=Ws(h,s,c),new Q(h,i,0,a+c)}shiftAndAppend(i,s){let a=this.token,h=this.mode===b?4:5;return a=Ws(a,W[this.mode][i],h),a=Ws(a,s,5),new Q(a,this.mode,0,this.bitCount+h+5)}addBinaryShiftChar(i){let s=this.token,a=this.mode,h=this.bitCount;if(this.mode===v||this.mode===b){let m=O[a][p];s=Ws(s,m&65535,m>>16),h+=m>>16,a=p}let c=this.binaryShiftByteCount===0||this.binaryShiftByteCount===31?18:this.binaryShiftByteCount===62?9:8,d=new Q(s,a,this.binaryShiftByteCount+1,h+c);return d.binaryShiftByteCount===2078&&(d=d.endBinaryShift(i+1)),d}endBinaryShift(i){if(this.binaryShiftByteCount===0)return this;let s=this.token;return s=vl(s,i-this.binaryShiftByteCount,this.binaryShiftByteCount),new Q(s,this.mode,0,this.bitCount)}isBetterThanOrEqualTo(i){let s=this.bitCount+(O[this.mode][i.mode]>>16);return this.binaryShiftByteCounti.binaryShiftByteCount&&i.binaryShiftByteCount>0&&(s+=10),s<=i.bitCount}toBitArray(i){let s=[];for(let h=this.endBinaryShift(i.length).token;h!==null;h=h.getPrevious())s.unshift(h);let a=new Z;for(const h of s)h.appendTo(a,i);return a}toString(){return at.format("%s bits=%d bytes=%d",f[this.mode],this.bitCount,this.binaryShiftByteCount)}static calculateBinaryShiftCost(i){return i.binaryShiftByteCount>62?21:i.binaryShiftByteCount>31?20:i.binaryShiftByteCount>0?10:0}}Q.INITIAL_STATE=new Q(N,p,0,0);function it(T){const i=at.getCharCode(" "),s=at.getCharCode("."),a=at.getCharCode(",");T[p][i]=1;const h=at.getCharCode("Z"),c=at.getCharCode("A");for(let D=c;D<=h;D++)T[p][D]=D-c+2;T[y][i]=1;const d=at.getCharCode("z"),m=at.getCharCode("a");for(let D=m;D<=d;D++)T[y][D]=D-m+2;T[b][i]=1;const _=at.getCharCode("9"),C=at.getCharCode("0");for(let D=C;D<=_;D++)T[b][D]=D-C+2;T[b][a]=12,T[b][s]=13;const M=["\0"," ","","","","","","","\x07","\b"," ",` +`,"\v","\f","\r","\x1B","","","","","@","\\","^","_","`","|","~",""];for(let D=0;D","?","[","]","{","}"];for(let D=0;D0&&(T[v][at.getCharCode(R[D])]=D);return T}const ct=it(U.createInt32Array(5,256));class wt{constructor(i){this.text=i}encode(){const i=at.getCharCode(" "),s=at.getCharCode(` +`);let a=ia.singletonList(Q.INITIAL_STATE);for(let c=0;c0?(a=wt.updateStateListForPair(a,c,d),c++):a=this.updateStateListForChar(a,c)}return ia.min(a,(c,d)=>c.getBitCount()-d.getBitCount()).toBitArray(this.text)}updateStateListForChar(i,s){const a=[];for(let h of i)this.updateStateForChar(h,s,a);return wt.simplifyStates(a)}updateStateForChar(i,s,a){let h=this.text[s]&255,c=ct[i.getMode()][h]>0,d=null;for(let m=0;m<=v;m++){let _=ct[m][h];if(_>0){if(d==null&&(d=i.endBinaryShift(s)),!c||m===i.getMode()||m===b){const C=d.latchAndAppend(m,_);a.push(C)}if(!c&&W[i.getMode()][m]>=0){const C=d.shiftAndAppend(m,_);a.push(C)}}}if(i.getBinaryShiftByteCount()>0||ct[i.getMode()][h]===0){let m=i.addBinaryShiftChar(s);a.push(m)}}static updateStateListForPair(i,s,a){const h=[];for(let c of i)this.updateStateForPair(c,s,a,h);return this.simplifyStates(h)}static updateStateForPair(i,s,a,h){let c=i.endBinaryShift(s);if(h.push(c.latchAndAppend(v,a)),i.getMode()!==v&&h.push(c.shiftAndAppend(v,a)),a===3||a===4){let d=c.latchAndAppend(b,16-a).latchAndAppend(b,1);h.push(d)}if(i.getBinaryShiftByteCount()>0){let d=i.addBinaryShiftChar(s).addBinaryShiftChar(s+1);h.push(d)}}static simplifyStates(i){let s=[];for(const a of i){let h=!0;for(const c of s){if(c.isBetterThanOrEqualTo(a)){h=!1;break}a.isBetterThanOrEqualTo(c)&&(s=s.filter(d=>d!==c))}h&&s.push(a)}return s}}class rt{constructor(){}static encodeBytes(i){return rt.encode(i,rt.DEFAULT_EC_PERCENT,rt.DEFAULT_AZTEC_LAYERS)}static encode(i,s,a){let h=new wt(i).encode(),c=Y.truncDivision(h.getSize()*s,100)+11,d=h.getSize()+c,m,_,C,M,R;if(a!==rt.DEFAULT_AZTEC_LAYERS){if(m=a<0,_=Math.abs(a),_>(m?rt.MAX_NB_BITS_COMPACT:rt.MAX_NB_BITS))throw new A(at.format("Illegal value %s for layers",a));C=rt.totalBitsInLayer(_,m),M=rt.WORD_SIZE[_];let mt=C-C%M;if(R=rt.stuffBits(h,M),R.getSize()+c>mt)throw new A("Data to large for user specified layer");if(m&&R.getSize()>M*64)throw new A("Data to large for user specified layer")}else{M=0,R=null;for(let mt=0;;mt++){if(mt>rt.MAX_NB_BITS)throw new A("Data too large for an Aztec code");if(m=mt<=3,_=m?mt+1:mt,C=rt.totalBitsInLayer(_,m),d>C)continue;(R==null||M!==rt.WORD_SIZE[_])&&(M=rt.WORD_SIZE[_],R=rt.stuffBits(h,M));let le=C-C%M;if(!(m&&R.getSize()>M*64)&&R.getSize()+c<=le)break}}let D=rt.generateCheckWords(R,C,M),k=R.getSize()/M,j=rt.generateModeMessage(m,_,k),K=(m?11:14)+_*4,tt=new Int32Array(K),st;if(m){st=K;for(let mt=0;mt=h||i.get(d+_))&&(m|=1<t.some(e=>r instanceof e);let zu,Wu;function B_(){return zu||(zu=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function k_(){return Wu||(Wu=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}const Sh=new WeakMap,ih=new WeakMap,ml=new WeakMap;function G_(r){const t=new Promise((e,n)=>{const o=()=>{r.removeEventListener("success",l),r.removeEventListener("error",u)},l=()=>{e(tr(r.result)),o()},u=()=>{n(r.error),o()};r.addEventListener("success",l),r.addEventListener("error",u)});return ml.set(t,r),t}function U_(r){if(Sh.has(r))return;const t=new Promise((e,n)=>{const o=()=>{r.removeEventListener("complete",l),r.removeEventListener("error",u),r.removeEventListener("abort",u)},l=()=>{e(),o()},u=()=>{n(r.error||new DOMException("AbortError","AbortError")),o()};r.addEventListener("complete",l),r.addEventListener("error",u),r.addEventListener("abort",u)});Sh.set(r,t)}let Rh={get(r,t,e){if(r instanceof IDBTransaction){if(t==="done")return Sh.get(r);if(t==="store")return e.objectStoreNames[1]?void 0:e.objectStore(e.objectStoreNames[0])}return tr(r[t])},set(r,t,e){return r[t]=e,!0},has(r,t){return r instanceof IDBTransaction&&(t==="done"||t==="store")?!0:t in r}};function z1(r){Rh=r(Rh)}function z_(r){return k_().includes(r)?function(...t){return r.apply(vh(this),t),tr(this.request)}:function(...t){return tr(r.apply(vh(this),t))}}function W_(r){return typeof r=="function"?z_(r):(r instanceof IDBTransaction&&U_(r),Th(r,B_())?new Proxy(r,Rh):r)}function tr(r){if(r instanceof IDBRequest)return G_(r);if(ih.has(r))return ih.get(r);const t=W_(r);return t!==r&&(ih.set(r,t),ml.set(t,r)),t}const vh=r=>ml.get(r);function X_(r,t,{blocked:e,upgrade:n,blocking:o,terminated:l}={}){const u=indexedDB.open(r,t),g=tr(u);return n&&u.addEventListener("upgradeneeded",x=>{n(tr(u.result),x.oldVersion,x.newVersion,tr(u.transaction),x)}),e&&u.addEventListener("blocked",x=>e(x.oldVersion,x.newVersion,x)),g.then(x=>{l&&x.addEventListener("close",()=>l()),o&&x.addEventListener("versionchange",E=>o(E.oldVersion,E.newVersion,E))}).catch(()=>{}),g}const V_=["get","getKey","getAll","getAllKeys","count"],Y_=["put","add","delete","clear"],nh=new Map;function Xu(r,t){if(!(r instanceof IDBDatabase&&!(t in r)&&typeof t=="string"))return;if(nh.get(t))return nh.get(t);const e=t.replace(/FromIndex$/,""),n=t!==e,o=Y_.includes(e);if(!(e in(n?IDBIndex:IDBObjectStore).prototype)||!(o||V_.includes(e)))return;const l=async function(u,...g){const x=this.transaction(u,o?"readwrite":"readonly");let E=x.store;return n&&(E=E.index(g.shift())),(await Promise.all([E[e](...g),o&&x.done]))[0]};return nh.set(t,l),l}z1(r=>({...r,get:(t,e,n)=>Xu(t,e)||r.get(t,e,n),has:(t,e)=>!!Xu(t,e)||r.has(t,e)}));const H_=["continue","continuePrimaryKey","advance"],Vu={},Oh=new WeakMap,W1=new WeakMap,j_={get(r,t){if(!H_.includes(t))return r[t];let e=Vu[t];return e||(e=Vu[t]=function(...n){Oh.set(this,W1.get(this)[t](...n))}),e}};async function*Z_(...r){let t=this;if(t instanceof IDBCursor||(t=await t.openCursor(...r)),!t)return;t=t;const e=new Proxy(t,j_);for(W1.set(e,t),ml.set(e,vh(t));t;)yield e,t=await(Oh.get(e)||t.continue()),Oh.delete(e)}function Yu(r,t){return t===Symbol.asyncIterator&&Th(r,[IDBIndex,IDBObjectStore,IDBCursor])||t==="iterate"&&Th(r,[IDBIndex,IDBObjectStore])}z1(r=>({...r,get(t,e,n){return Yu(t,e)?Z_:r.get(t,e,n)},has(t,e){return Yu(t,e)||r.has(t,e)}}));var X1={exports:{}};(function(r,t){(function(e,n){n()})(Mn,function(){function e(E,w){return typeof w>"u"?w={autoBom:!1}:typeof w!="object"&&(console.warn("Deprecated: Expected third argument to be a object"),w={autoBom:!w}),w.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(E.type)?new Blob(["\uFEFF",E],{type:E.type}):E}function n(E,w,A){var S=new XMLHttpRequest;S.open("GET",E),S.responseType="blob",S.onload=function(){x(S.response,w,A)},S.onerror=function(){console.error("could not download file")},S.send()}function o(E){var w=new XMLHttpRequest;w.open("HEAD",E,!1);try{w.send()}catch{}return 200<=w.status&&299>=w.status}function l(E){try{E.dispatchEvent(new MouseEvent("click"))}catch{var w=document.createEvent("MouseEvents");w.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),E.dispatchEvent(w)}}var u=typeof window=="object"&&window.window===window?window:typeof self=="object"&&self.self===self?self:typeof Mn=="object"&&Mn.global===Mn?Mn:void 0,g=u.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),x=u.saveAs||(typeof window!="object"||window!==u?function(){}:"download"in HTMLAnchorElement.prototype&&!g?function(E,w,A){var S=u.URL||u.webkitURL,P=document.createElement("a");w=w||E.name||"download",P.download=w,P.rel="noopener",typeof E=="string"?(P.href=E,P.origin===location.origin?l(P):o(P.href)?n(E,w,A):l(P,P.target="_blank")):(P.href=S.createObjectURL(E),setTimeout(function(){S.revokeObjectURL(P.href)},4e4),setTimeout(function(){l(P)},0))}:"msSaveOrOpenBlob"in navigator?function(E,w,A){if(w=w||E.name||"download",typeof E!="string")navigator.msSaveOrOpenBlob(e(E,A),w);else if(o(E))n(E,w,A);else{var S=document.createElement("a");S.href=E,S.target="_blank",setTimeout(function(){l(S)})}}:function(E,w,A,S){if(S=S||open("","_blank"),S&&(S.document.title=S.document.body.innerText="downloading..."),typeof E=="string")return n(E,w,A);var P=E.type==="application/octet-stream",L=/constructor/i.test(u.HTMLElement)||u.safari,F=/CriOS\/[\d]+/.test(navigator.userAgent);if((F||P&&L||g)&&typeof FileReader<"u"){var V=new FileReader;V.onloadend=function(){var Y=V.result;Y=F?Y:Y.replace(/^data:[^;]*;/,"data:attachment/file;"),S?S.location.href=Y:location=Y,S=null},V.readAsDataURL(E)}else{var z=u.URL||u.webkitURL,U=z.createObjectURL(E);S?S.location=U:location.href=U,S=null,setTimeout(function(){z.revokeObjectURL(U)},4e4)}});u.saveAs=x.saveAs=x,r.exports=x})})(X1);var K_=X1.exports;const q_=C1(K_);let In=!1;document.getElementById("loginBtn").onclick=r=>{const t=document.getElementById("user").value,e=document.getElementById("pwd").value;localStorage.setItem("lastUser",t),V1(t,e)};try{const r=new AbortController,t=setTimeout(()=>r.abort(),1e3),e=await fetch("http://192.168.56.101:8081/geoserver/wfs?service=WFS&version=1.1.0&request=GetFeature&typename=wfsttest:wfsuser_view&outputFormat=application/json",{signal:r.signal});clearTimeout(t);const n=await e.json();In=!0}catch{In=!1}if(!In){const r=localStorage.getItem("lastUser");V1(r)}function J_(r){return new Promise((t,e)=>{let n=new FileReader;n.onload=function(){return t({data:n.result,name:r.name,size:r.size,type:r.type})},n.readAsDataURL(r)})}function Q_(r){return new Promise((t,e)=>{const n=new FileReader;n.onloadend=()=>t(n.result),n.readAsDataURL(r)})}async function V1(r,t){document.getElementById("loginDiv").innerHTML="";const e=await X_("hofapp",20,{upgrade(X,J,H,_t,xt){X.objectStoreNames.contains("imgs")&&X.deleteObjectStore("imgs"),X.objectStoreNames.contains("txt")&&X.deleteObjectStore("txt"),X.objectStoreNames.contains("file")&&X.deleteObjectStore("file"),X.createObjectStore("imgs",{keyPath:"url"}).createIndex("url","url"),X.createObjectStore("txt",{keyPath:"url"}).createIndex("url","url");const pt=X.createObjectStore("file",{keyPath:"filename"});pt.createIndex("filename","filename"),pt.createIndex("gid","gid",{unique:!1}),pt.createIndex("uploadpending","uploadpending",{unique:!1}),pt.createIndex("removalpending","removalpending",{unique:!1})}});function n(X,J={}){return J.headers=J.headers??{},J.headers.Authorization=`Basic ${window.btoa(r+":"+t)}`,fetch(X,J)}async function o(X,J,H){if(In){const _t=await(await X(J,H)).text();return e.transaction("txt","readwrite").objectStore("txt").put({url:J,data:_t}),_t}else return(await e.transaction("txt","readonly").objectStore("txt").get(J)).data}async function l(X,J){const H=[];if(In){const _t=await o(n,"http://192.168.56.101:8081/geoserver/wfs/?service=WFS&version=2.0.0&request=GetFeature&typeNames=wfsttest:protectedsite_files_view&cql_filter=mimetype=%27application%2Fgpx%2Bxml%27&outputformat=json"),xt=JSON.parse(_t);for(const at of xt.features)H.push(at.properties.fdata)}else{const xt=(await e.transaction("file","readonly").objectStore("file").index("removalpending").getAll(IDBKeyRange.only(0))).filter(at=>at.filename.indexOf(".gpx")>-1);for(const at of xt){let ut=await Q_(at.blob);ut=ut.substring(ut.indexOf(",")+1),H.push(ut)}}J.getSource().clear();for(const _t of H){const xt=window.atob(_t),at=J.getSource().getFormat().readFeatures(xt,{featureProjection:X.getView().getProjection()});J.getSource().addFeatures(at)}}const u=new Eu({source:new bu({format:new Km})});ma.defs("EPSG:31287","+proj=lcc +lat_0=47.5 +lon_0=13.3333333333333 +lat_1=49 +lat_2=46 +x_0=400000 +y_0=400000 +ellps=bessel +towgs84=577.326,90.129,463.919,5.137,1.474,5.297,2.4232 +units=m +no_defs +type=crs"),ma.defs("EPSG:4326","+proj=longlat +datum=WGS84 +no_defs +type=crs"),ma.defs("EPSG:3035","+proj=laea +lat_0=52 +lon_0=10 +x_0=4321000 +y_0=3210000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs +type=crs"),Vx(ma);const g=await o(n,"http://192.168.56.101:8081/geoserver/wfs?service=WFS&version=1.1.0&request=GetFeature&typename=wfsttest:protectedsite_view&outputFormat=application/json&srsname=EPSG:31287"),x=new bu({features:new Tx().readFeatures(g)}),E=new Eu({source:x,style:{"stroke-width":.75,"stroke-color":"white","fill-color":"rgba(255,0,0,0.5)"}}),w=new sm({target:"map",layers:[new ym({source:new Pm({url:"https://mapproxy.rest-gdi.geo-data.space/tiles/osm/webmercator/{z}/{x}/{y}.png",maxZoom:19,tileLoadFunction:async function(X,J){const H=X.getImage(),_t=(await e.transaction("imgs","readonly").objectStore("imgs").get(J))?.data;if(_t)H.src=_t;else{H.src=J;const at=await(await fetch(J)).blob(),ut=new FileReader;ut.onload=pt=>{e.transaction("imgs","readwrite").objectStore("imgs").put({url:J,data:ut.result})},ut.readAsDataURL(at)}}})}),E,u],view:new Ln({center:[401306,423398],zoom:8,projection:"EPSG:31287"})});w.getView().fit(x.getExtent());const A=localStorage.getItem("zoom");A&&w.getView().setZoom(JSON.parse(A)),w.getView().on("change",X=>{const J=w.getView().getCenter(),H=w.getView().getZoom();localStorage.setItem("center",JSON.stringify(J)),localStorage.setItem("zoom",JSON.stringify(H))});const S=document.getElementById("popup"),P=document.getElementById("popup-content"),L=document.getElementById("popup-closer"),F=new rm({element:S,autoPan:{animation:{duration:250}}});w.addOverlay(F);function V(X,J,H){for(var _t=512,xt=atob(X),at=[],ut=0;ut_t.properties)}async function U(){let X=e.transaction("file","readonly").objectStore("file");const J=await X.index("uploadpending").getAll(IDBKeyRange.only(1));for(const lt of J){const yt=new File([lt.blob],lt.filename);await Y(lt.gid,lt.filename,lt.filesize,lt.mimetype,yt),lt.uploadpending=0,e.transaction("file","readwrite").objectStore("file").put(lt)}X=e.transaction("file","readonly").objectStore("file");const H=await X.index("removalpending").getAll(IDBKeyRange.only(1));for(const lt of H)ot(lt.filename);const _t=await z(),xt=new Map(_t.map(lt=>[lt.filename,lt])),at=await e.transaction("file","readonly").objectStore("file").getAll(),ut=new Map(at.map(lt=>[lt.filename,lt])),pt=new Map(xt);ut.forEach(lt=>pt.delete(lt.filename));for(const[lt,yt]of pt){const Lt=await $(lt);e.transaction("file","readwrite").objectStore("file").put({...yt,uploadPending:0,gid:yt.psiteid,blob:Lt})}const q=new Map(ut);xt.forEach(lt=>q.delete(lt.filename));for(const lt of q.keys())e.transaction("file","readwrite").objectStore("file").delete(lt)}In&&await U(),l(w,u);async function Y(X,J,H,_t,xt,at){const ut=await J_(at),pt=ut.data.substring(ut.data.indexOf(",")+1),q=` + + + + ${X} + ${J} + ${H} + ${_t} + ${xt} + ${pt} + + + `;await n("http://192.168.56.101:8081/geoserver/wfs",{method:"POST",body:q})}async function Z(X,J,H){let _t=[];if(In)_t=await z(X);else{const ut=e.transaction("file","readonly").objectStore("file").index("gid"),pt=IDBKeyRange.only(X);for await(const q of ut.iterate(pt)){const lt=q.value;lt.removalpending||_t.push(lt)}}J.innerHTML="";for(let at of _t){const ut=document.createElement("a");if(ut.innerText=`${at.filename} (${at.filesize})`,ut.setAttribute("href","#"),ut.onclick=async pt=>{const q=await $(at.filename);q_.saveAs(q,at.filename,"application/octet_stream"),pt.preventDefault()},J.appendChild(ut),at.userids.split(",").includes("bauer1")){const pt=document.createElement("a");pt.innerText=" X",pt.setAttribute("href","#"),pt.onclick=q=>{q.preventDefault(),ot(at.filename),setTimeout(()=>Z(X,J,H),100)},J.appendChild(pt),J.appendChild(document.createElement("br"))}}l(w,u);const xt=document.createElement("input",{id:"fileInput"});xt.setAttribute("type","file"),J.appendChild(xt),F.setPosition(H),xt.addEventListener("change",async at=>{var ut=at.target.files[0];const pt=ut.name.toLowerCase().endsWith(".gpx")?"application/gpx+xml":"application/octet-stream",q=window.prompt("Beistrich-getrennte Liste von zusätzlich leseberechtigten Benutzern:"),lt=await ut.arrayBuffer();In&&await Y(X,ut.name,lt.byteLength,pt,q,ut);const yt=new Blob([lt],{type:pt});e.transaction("file","readwrite").objectStore("file").put({uploadpending:In?0:1,removalpending:0,gid:X,mimetype:pt,filesize:lt.byteLength,filename:ut.name,userids:q,blob:yt}),Z(X,J,H)})}async function $(X){if(In){const J=await(await n(`http://192.168.56.101:8081/geoserver/wfs/?service=WFS&version=2.0.0&request=GetFeature&typeNames=wfsttest:protectedsite_files_view&cql_filter=filename='${X}'&outputformat=json`)).text(),xt=JSON.parse(J).features[0].properties.fdata;return V(xt)}else{const H=await e.transaction("file","readonly").objectStore("file").index("filename").openCursor(IDBKeyRange.only(X));if(H){const _t=H?.value;return new File([_t.blob],X)}}}async function ot(X){if(In){const J=` + + + + + filename + ${X} + + + + `;await(await n("http://192.168.56.101:8081/geoserver/wfs",{method:"POST",body:J})).text(),e.transaction("file","readwrite").objectStore("file").delete(X)}else{const J=await e.transaction("file","readonly").objectStore("file").get(X);J.removalpending=1,e.transaction("file","readwrite").objectStore("file").put(J)}}w.on("click",async function(X){w.forEachFeatureAtPixel(X.pixel,async function(J,H){if(H===E){const xt=J.getProperties().gid;Z(xt,P,X.coordinate)}})}),L.onclick=function(){return F.setPosition(void 0),L.blur(),!1}} +//# sourceMappingURL=index-BK-nidoD.js.map diff --git a/docs/assets/index-BK-nidoD.js.map b/docs/assets/index-BK-nidoD.js.map new file mode 100644 index 0000000..bf82b1b --- /dev/null +++ b/docs/assets/index-BK-nidoD.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index-BK-nidoD.js","sources":["../../node_modules/ol/events/Event.js","../../node_modules/ol/ObjectEventType.js","../../node_modules/ol/Disposable.js","../../node_modules/ol/array.js","../../node_modules/ol/functions.js","../../node_modules/ol/obj.js","../../node_modules/ol/events/Target.js","../../node_modules/ol/events/EventType.js","../../node_modules/ol/events.js","../../node_modules/ol/Observable.js","../../node_modules/ol/util.js","../../node_modules/ol/Object.js","../../node_modules/ol/CollectionEventType.js","../../node_modules/ol/Collection.js","../../node_modules/ol/asserts.js","../../node_modules/ol/Feature.js","../../node_modules/ol/transform.js","../../node_modules/ol/extent/Relationship.js","../../node_modules/ol/extent.js","../../node_modules/ol/proj/Units.js","../../node_modules/ol/proj/Projection.js","../../node_modules/ol/proj/epsg3857.js","../../node_modules/ol/proj/epsg4326.js","../../node_modules/ol/proj/projections.js","../../node_modules/ol/proj/transforms.js","../../node_modules/ol/math.js","../../node_modules/ol/string.js","../../node_modules/ol/coordinate.js","../../node_modules/ol/sphere.js","../../node_modules/ol/console.js","../../node_modules/ol/proj.js","../../node_modules/ol/geom/flat/transform.js","../../node_modules/ol/geom/Geometry.js","../../node_modules/ol/geom/SimpleGeometry.js","../../node_modules/ol/geom/flat/closest.js","../../node_modules/ol/geom/flat/deflate.js","../../node_modules/ol/geom/flat/simplify.js","../../node_modules/ol/geom/flat/inflate.js","../../node_modules/ol/geom/flat/area.js","../../node_modules/ol/geom/LinearRing.js","../../node_modules/ol/geom/Point.js","../../node_modules/ol/geom/flat/contains.js","../../node_modules/ol/geom/flat/interiorpoint.js","../../node_modules/ol/geom/flat/segments.js","../../node_modules/ol/geom/flat/intersectsextent.js","../../node_modules/ol/geom/flat/reverse.js","../../node_modules/ol/geom/flat/orient.js","../../node_modules/ol/geom/Polygon.js","../../node_modules/ol/render/EventType.js","../../node_modules/ol/ImageState.js","../../node_modules/color-space/rgb.js","../../node_modules/color-space/xyz.js","../../node_modules/color-space/luv.js","../../node_modules/color-space/lchuv.js","../../node_modules/color-parse/node_modules/color-name/index.js","../../node_modules/color-parse/index.js","../../node_modules/color-space/hsl.js","../../node_modules/color-rgba/index.js","../../node_modules/ol/color.js","../../node_modules/ol/has.js","../../node_modules/ol/dom.js","../../node_modules/ol/Image.js","../../node_modules/ol/style/IconImageCache.js","../../node_modules/ol/style/IconImage.js","../../node_modules/ol/style/Fill.js","../../node_modules/ol/geom/flat/interpolate.js","../../node_modules/ol/geom/flat/length.js","../../node_modules/ol/geom/LineString.js","../../node_modules/ol/style/Stroke.js","../../node_modules/ol/size.js","../../node_modules/ol/style/Image.js","../../node_modules/ol/colorlike.js","../../node_modules/ol/css.js","../../node_modules/ol/render/canvas.js","../../node_modules/ol/style/RegularShape.js","../../node_modules/ol/style/Circle.js","../../node_modules/ol/style/Style.js","../../node_modules/ol/style/Text.js","../../node_modules/ol/layer/Property.js","../../node_modules/ol/layer/Base.js","../../node_modules/ol/ViewHint.js","../../node_modules/ol/ViewProperty.js","../../node_modules/ol/tilegrid/common.js","../../node_modules/ol/centerconstraint.js","../../node_modules/ol/resolutionconstraint.js","../../node_modules/ol/rotationconstraint.js","../../node_modules/ol/easing.js","../../node_modules/ol/View.js","../../node_modules/ol/layer/Layer.js","../../node_modules/quickselect/index.js","../../node_modules/rbush/index.js","../../node_modules/ol/style/Icon.js","../../node_modules/ol/expr/expression.js","../../node_modules/ol/expr/cpu.js","../../node_modules/ol/render/canvas/style.js","../../node_modules/ol/layer/BaseVector.js","../../node_modules/ol/render/canvas/Instruction.js","../../node_modules/ol/render/VectorContext.js","../../node_modules/ol/render/canvas/Builder.js","../../node_modules/ol/render/canvas/ImageBuilder.js","../../node_modules/ol/render/canvas/LineStringBuilder.js","../../node_modules/ol/render/canvas/PolygonBuilder.js","../../node_modules/ol/geom/flat/linechunk.js","../../node_modules/ol/geom/flat/straightchunk.js","../../node_modules/ol/render/canvas/TextBuilder.js","../../node_modules/ol/render/canvas/BuilderGroup.js","../../node_modules/ol/renderer/Layer.js","../../node_modules/ol/render/Event.js","../../node_modules/ol/render/canvas/ZIndexContext.js","../../node_modules/ol/renderer/canvas/Layer.js","../../node_modules/ol/geom/flat/textpath.js","../../node_modules/ol/render/canvas/Executor.js","../../node_modules/ol/render/canvas/ExecutorGroup.js","../../node_modules/ol/render/canvas/Immediate.js","../../node_modules/ol/render/canvas/hitdetect.js","../../node_modules/ol/renderer/vector.js","../../node_modules/ol/renderer/canvas/VectorLayer.js","../../node_modules/ol/layer/Vector.js","../../node_modules/ol/structs/RBush.js","../../node_modules/ol/geom/GeometryCollection.js","../../node_modules/ol/geom/MultiLineString.js","../../node_modules/ol/geom/MultiPoint.js","../../node_modules/ol/geom/flat/center.js","../../node_modules/ol/geom/MultiPolygon.js","../../node_modules/ol/render/Feature.js","../../node_modules/ol/source/Source.js","../../node_modules/ol/source/VectorEventType.js","../../node_modules/ol/loadingstrategy.js","../../node_modules/ol/featureloader.js","../../node_modules/ol/source/Vector.js","../../node_modules/ol/TileState.js","../../node_modules/ol/Tile.js","../../node_modules/ol/ImageTile.js","../../node_modules/ol/Kinetic.js","../../node_modules/ol/renderer/Map.js","../../node_modules/ol/renderer/Composite.js","../../node_modules/ol/layer/Group.js","../../node_modules/ol/MapEvent.js","../../node_modules/ol/MapBrowserEvent.js","../../node_modules/ol/MapBrowserEventType.js","../../node_modules/ol/pointer/EventType.js","../../node_modules/ol/MapBrowserEventHandler.js","../../node_modules/ol/MapEventType.js","../../node_modules/ol/MapProperty.js","../../node_modules/ol/structs/PriorityQueue.js","../../node_modules/ol/TileQueue.js","../../node_modules/ol/control/Control.js","../../node_modules/ol/control/Attribution.js","../../node_modules/ol/control/Rotate.js","../../node_modules/ol/control/Zoom.js","../../node_modules/ol/control/defaults.js","../../node_modules/ol/interaction/Property.js","../../node_modules/ol/interaction/Interaction.js","../../node_modules/ol/interaction/DoubleClickZoom.js","../../node_modules/ol/interaction/Pointer.js","../../node_modules/ol/events/condition.js","../../node_modules/ol/interaction/DragPan.js","../../node_modules/ol/interaction/DragRotate.js","../../node_modules/ol/render/Box.js","../../node_modules/ol/interaction/DragBox.js","../../node_modules/ol/interaction/DragZoom.js","../../node_modules/ol/events/Key.js","../../node_modules/ol/interaction/KeyboardPan.js","../../node_modules/ol/interaction/KeyboardZoom.js","../../node_modules/ol/interaction/MouseWheelZoom.js","../../node_modules/ol/interaction/PinchRotate.js","../../node_modules/ol/interaction/PinchZoom.js","../../node_modules/ol/interaction/defaults.js","../../node_modules/ol/Map.js","../../node_modules/ol/Overlay.js","../../node_modules/ol/structs/LRUCache.js","../../node_modules/ol/tilecoord.js","../../node_modules/ol/TileCache.js","../../node_modules/ol/TileRange.js","../../node_modules/ol/layer/TileProperty.js","../../node_modules/ol/layer/BaseTile.js","../../node_modules/ol/reproj/common.js","../../node_modules/ol/reproj/Triangulation.js","../../node_modules/ol/reproj.js","../../node_modules/ol/reproj/Tile.js","../../node_modules/ol/renderer/canvas/TileLayer.js","../../node_modules/ol/layer/Tile.js","../../node_modules/ol/source/TileEventType.js","../../node_modules/ol/tilegrid/TileGrid.js","../../node_modules/ol/tilegrid.js","../../node_modules/ol/source/Tile.js","../../node_modules/ol/tileurlfunction.js","../../node_modules/ol/source/UrlTile.js","../../node_modules/ol/source/TileImage.js","../../node_modules/ol/source/XYZ.js","../../node_modules/ol/format/Feature.js","../../node_modules/ol/xml.js","../../node_modules/ol/format/XMLFeature.js","../../node_modules/ol/format/xsd.js","../../node_modules/ol/format/GPX.js","../../node_modules/ol/format/JSONFeature.js","../../node_modules/ol/format/GeoJSON.js","../../node_modules/proj4/dist/proj4.js","../../node_modules/ol/proj/proj4.js","../../node_modules/qrcode/lib/can-promise.js","../../node_modules/qrcode/lib/core/utils.js","../../node_modules/qrcode/lib/core/error-correction-level.js","../../node_modules/qrcode/lib/core/bit-buffer.js","../../node_modules/qrcode/lib/core/bit-matrix.js","../../node_modules/qrcode/lib/core/alignment-pattern.js","../../node_modules/qrcode/lib/core/finder-pattern.js","../../node_modules/qrcode/lib/core/mask-pattern.js","../../node_modules/qrcode/lib/core/error-correction-code.js","../../node_modules/qrcode/lib/core/galois-field.js","../../node_modules/qrcode/lib/core/polynomial.js","../../node_modules/qrcode/lib/core/reed-solomon-encoder.js","../../node_modules/qrcode/lib/core/version-check.js","../../node_modules/qrcode/lib/core/regex.js","../../node_modules/qrcode/lib/core/mode.js","../../node_modules/qrcode/lib/core/version.js","../../node_modules/qrcode/lib/core/format-info.js","../../node_modules/qrcode/lib/core/numeric-data.js","../../node_modules/qrcode/lib/core/alphanumeric-data.js","../../node_modules/encode-utf8/index.js","../../node_modules/qrcode/lib/core/byte-data.js","../../node_modules/qrcode/lib/core/kanji-data.js","../../node_modules/dijkstrajs/dijkstra.js","../../node_modules/qrcode/lib/core/segments.js","../../node_modules/qrcode/lib/core/qrcode.js","../../node_modules/qrcode/lib/renderer/utils.js","../../node_modules/qrcode/lib/renderer/canvas.js","../../node_modules/qrcode/lib/renderer/svg-tag.js","../../node_modules/qrcode/lib/browser.js","../../node_modules/html5-qrcode/esm/core.js","../../node_modules/html5-qrcode/third_party/zxing-js.umd.js","../../node_modules/html5-qrcode/esm/camera/core-impl.js","../../node_modules/html5-qrcode/esm/state-manager.js","../../node_modules/html5-qrcode/esm/html5-qrcode.js","../../node_modules/html5-qrcode/esm/html5-qrcode-scanner.js","../../node_modules/idb/build/index.js","../../node_modules/file-saver/dist/FileSaver.min.js","../../main.js"],"sourcesContent":["/**\n * @module ol/events/Event\n */\n\n/**\n * @classdesc\n * Stripped down implementation of the W3C DOM Level 2 Event interface.\n * See https://www.w3.org/TR/DOM-Level-2-Events/events.html#Events-interface.\n *\n * This implementation only provides `type` and `target` properties, and\n * `stopPropagation` and `preventDefault` methods. It is meant as base class\n * for higher level events defined in the library, and works with\n * {@link module:ol/events/Target~Target}.\n */\nclass BaseEvent {\n /**\n * @param {string} type Type.\n */\n constructor(type) {\n /**\n * @type {boolean}\n */\n this.propagationStopped;\n\n /**\n * @type {boolean}\n */\n this.defaultPrevented;\n\n /**\n * The event type.\n * @type {string}\n * @api\n */\n this.type = type;\n\n /**\n * The event target.\n * @type {Object}\n * @api\n */\n this.target = null;\n }\n\n /**\n * Prevent default. This means that no emulated `click`, `singleclick` or `doubleclick` events\n * will be fired.\n * @api\n */\n preventDefault() {\n this.defaultPrevented = true;\n }\n\n /**\n * Stop event propagation.\n * @api\n */\n stopPropagation() {\n this.propagationStopped = true;\n }\n}\n\n/**\n * @param {Event|import(\"./Event.js\").default} evt Event\n */\nexport function stopPropagation(evt) {\n evt.stopPropagation();\n}\n\n/**\n * @param {Event|import(\"./Event.js\").default} evt Event\n */\nexport function preventDefault(evt) {\n evt.preventDefault();\n}\n\nexport default BaseEvent;\n","/**\n * @module ol/ObjectEventType\n */\n\n/**\n * @enum {string}\n */\nexport default {\n /**\n * Triggered when a property is changed.\n * @event module:ol/Object.ObjectEvent#propertychange\n * @api\n */\n PROPERTYCHANGE: 'propertychange',\n};\n\n/**\n * @typedef {'propertychange'} Types\n */\n","/**\n * @module ol/Disposable\n */\n\n/**\n * @classdesc\n * Objects that need to clean up after themselves.\n */\nclass Disposable {\n constructor() {\n /**\n * The object has already been disposed.\n * @type {boolean}\n * @protected\n */\n this.disposed = false;\n }\n\n /**\n * Clean up.\n */\n dispose() {\n if (!this.disposed) {\n this.disposed = true;\n this.disposeInternal();\n }\n }\n\n /**\n * Extension point for disposable objects.\n * @protected\n */\n disposeInternal() {}\n}\n\nexport default Disposable;\n","/**\n * @module ol/array\n */\n\n/**\n * Performs a binary search on the provided sorted list and returns the index of the item if found. If it can't be found it'll return -1.\n * https://github.com/darkskyapp/binary-search\n *\n * @param {Array<*>} haystack Items to search through.\n * @param {*} needle The item to look for.\n * @param {Function} [comparator] Comparator function.\n * @return {number} The index of the item if found, -1 if not.\n */\nexport function binarySearch(haystack, needle, comparator) {\n let mid, cmp;\n comparator = comparator || ascending;\n let low = 0;\n let high = haystack.length;\n let found = false;\n\n while (low < high) {\n /* Note that \"(low + high) >>> 1\" may overflow, and results in a typecast\n * to double (which gives the wrong results). */\n mid = low + ((high - low) >> 1);\n cmp = +comparator(haystack[mid], needle);\n\n if (cmp < 0.0) {\n /* Too low. */\n low = mid + 1;\n } else {\n /* Key found or too high */\n high = mid;\n found = !cmp;\n }\n }\n\n /* Key not found. */\n return found ? low : ~low;\n}\n\n/**\n * Compare function sorting arrays in ascending order. Safe to use for numeric values.\n * @param {*} a The first object to be compared.\n * @param {*} b The second object to be compared.\n * @return {number} A negative number, zero, or a positive number as the first\n * argument is less than, equal to, or greater than the second.\n */\nexport function ascending(a, b) {\n return a > b ? 1 : a < b ? -1 : 0;\n}\n\n/**\n * Compare function sorting arrays in descending order. Safe to use for numeric values.\n * @param {*} a The first object to be compared.\n * @param {*} b The second object to be compared.\n * @return {number} A negative number, zero, or a positive number as the first\n * argument is greater than, equal to, or less than the second.\n */\nexport function descending(a, b) {\n return a < b ? 1 : a > b ? -1 : 0;\n}\n\n/**\n * {@link module:ol/tilegrid/TileGrid~TileGrid#getZForResolution} can use a function\n * of this type to determine which nearest resolution to use.\n *\n * This function takes a `{number}` representing a value between two array entries,\n * a `{number}` representing the value of the nearest higher entry and\n * a `{number}` representing the value of the nearest lower entry\n * as arguments and returns a `{number}`. If a negative number or zero is returned\n * the lower value will be used, if a positive number is returned the higher value\n * will be used.\n * @typedef {function(number, number, number): number} NearestDirectionFunction\n * @api\n */\n\n/**\n * @param {Array} arr Array in descending order.\n * @param {number} target Target.\n * @param {number|NearestDirectionFunction} direction\n * 0 means return the nearest,\n * > 0 means return the largest nearest,\n * < 0 means return the smallest nearest.\n * @return {number} Index.\n */\nexport function linearFindNearest(arr, target, direction) {\n if (arr[0] <= target) {\n return 0;\n }\n\n const n = arr.length;\n if (target <= arr[n - 1]) {\n return n - 1;\n }\n\n if (typeof direction === 'function') {\n for (let i = 1; i < n; ++i) {\n const candidate = arr[i];\n if (candidate === target) {\n return i;\n }\n if (candidate < target) {\n if (direction(target, arr[i - 1], candidate) > 0) {\n return i - 1;\n }\n return i;\n }\n }\n return n - 1;\n }\n\n if (direction > 0) {\n for (let i = 1; i < n; ++i) {\n if (arr[i] < target) {\n return i - 1;\n }\n }\n return n - 1;\n }\n\n if (direction < 0) {\n for (let i = 1; i < n; ++i) {\n if (arr[i] <= target) {\n return i;\n }\n }\n return n - 1;\n }\n\n for (let i = 1; i < n; ++i) {\n if (arr[i] == target) {\n return i;\n }\n if (arr[i] < target) {\n if (arr[i - 1] - target < target - arr[i]) {\n return i - 1;\n }\n return i;\n }\n }\n return n - 1;\n}\n\n/**\n * @param {Array<*>} arr Array.\n * @param {number} begin Begin index.\n * @param {number} end End index.\n */\nexport function reverseSubArray(arr, begin, end) {\n while (begin < end) {\n const tmp = arr[begin];\n arr[begin] = arr[end];\n arr[end] = tmp;\n ++begin;\n --end;\n }\n}\n\n/**\n * @param {Array} arr The array to modify.\n * @param {!Array|VALUE} data The elements or arrays of elements to add to arr.\n * @template VALUE\n */\nexport function extend(arr, data) {\n const extension = Array.isArray(data) ? data : [data];\n const length = extension.length;\n for (let i = 0; i < length; i++) {\n arr[arr.length] = extension[i];\n }\n}\n\n/**\n * @param {Array} arr The array to modify.\n * @param {VALUE} obj The element to remove.\n * @template VALUE\n * @return {boolean} If the element was removed.\n */\nexport function remove(arr, obj) {\n const i = arr.indexOf(obj);\n const found = i > -1;\n if (found) {\n arr.splice(i, 1);\n }\n return found;\n}\n\n/**\n * @param {Array|Uint8ClampedArray} arr1 The first array to compare.\n * @param {Array|Uint8ClampedArray} arr2 The second array to compare.\n * @return {boolean} Whether the two arrays are equal.\n */\nexport function equals(arr1, arr2) {\n const len1 = arr1.length;\n if (len1 !== arr2.length) {\n return false;\n }\n for (let i = 0; i < len1; i++) {\n if (arr1[i] !== arr2[i]) {\n return false;\n }\n }\n return true;\n}\n\n/**\n * Sort the passed array such that the relative order of equal elements is preserved.\n * See https://en.wikipedia.org/wiki/Sorting_algorithm#Stability for details.\n * @param {Array<*>} arr The array to sort (modifies original).\n * @param {!function(*, *): number} compareFnc Comparison function.\n * @api\n */\nexport function stableSort(arr, compareFnc) {\n const length = arr.length;\n const tmp = Array(arr.length);\n let i;\n for (i = 0; i < length; i++) {\n tmp[i] = {index: i, value: arr[i]};\n }\n tmp.sort(function (a, b) {\n return compareFnc(a.value, b.value) || a.index - b.index;\n });\n for (i = 0; i < arr.length; i++) {\n arr[i] = tmp[i].value;\n }\n}\n\n/**\n * @param {Array<*>} arr The array to test.\n * @param {Function} [func] Comparison function.\n * @param {boolean} [strict] Strictly sorted (default false).\n * @return {boolean} Return index.\n */\nexport function isSorted(arr, func, strict) {\n const compare = func || ascending;\n return arr.every(function (currentVal, index) {\n if (index === 0) {\n return true;\n }\n const res = compare(arr[index - 1], currentVal);\n return !(res > 0 || (strict && res === 0));\n });\n}\n","/**\n * @module ol/functions\n */\n\nimport {equals as arrayEquals} from './array.js';\n\n/**\n * Always returns true.\n * @return {boolean} true.\n */\nexport function TRUE() {\n return true;\n}\n\n/**\n * Always returns false.\n * @return {boolean} false.\n */\nexport function FALSE() {\n return false;\n}\n\n/**\n * A reusable function, used e.g. as a default for callbacks.\n *\n * @return {void} Nothing.\n */\nexport function VOID() {}\n\n/**\n * Wrap a function in another function that remembers the last return. If the\n * returned function is called twice in a row with the same arguments and the same\n * this object, it will return the value from the first call in the second call.\n *\n * @param {function(...any): ReturnType} fn The function to memoize.\n * @return {function(...any): ReturnType} The memoized function.\n * @template ReturnType\n */\nexport function memoizeOne(fn) {\n let called = false;\n\n /** @type {ReturnType} */\n let lastResult;\n\n /** @type {Array} */\n let lastArgs;\n\n let lastThis;\n\n return function () {\n const nextArgs = Array.prototype.slice.call(arguments);\n if (!called || this !== lastThis || !arrayEquals(nextArgs, lastArgs)) {\n called = true;\n lastThis = this;\n lastArgs = nextArgs;\n lastResult = fn.apply(this, arguments);\n }\n return lastResult;\n };\n}\n\n/**\n * @template T\n * @param {function(): (T | Promise)} getter A function that returns a value or a promise for a value.\n * @return {Promise} A promise for the value.\n */\nexport function toPromise(getter) {\n function promiseGetter() {\n let value;\n try {\n value = getter();\n } catch (err) {\n return Promise.reject(err);\n }\n if (value instanceof Promise) {\n return value;\n }\n return Promise.resolve(value);\n }\n return promiseGetter();\n}\n","/**\n * @module ol/obj\n */\n\n/**\n * Removes all properties from an object.\n * @param {Object} object The object to clear.\n */\nexport function clear(object) {\n for (const property in object) {\n delete object[property];\n }\n}\n\n/**\n * Determine if an object has any properties.\n * @param {Object} object The object to check.\n * @return {boolean} The object is empty.\n */\nexport function isEmpty(object) {\n let property;\n for (property in object) {\n return false;\n }\n return !property;\n}\n","/**\n * @module ol/events/Target\n */\nimport Disposable from '../Disposable.js';\nimport Event from './Event.js';\nimport {VOID} from '../functions.js';\nimport {clear} from '../obj.js';\n\n/**\n * @typedef {EventTarget|Target} EventTargetLike\n */\n\n/**\n * @classdesc\n * A simplified implementation of the W3C DOM Level 2 EventTarget interface.\n * See https://www.w3.org/TR/2000/REC-DOM-Level-2-Events-20001113/events.html#Events-EventTarget.\n *\n * There are two important simplifications compared to the specification:\n *\n * 1. The handling of `useCapture` in `addEventListener` and\n * `removeEventListener`. There is no real capture model.\n * 2. The handling of `stopPropagation` and `preventDefault` on `dispatchEvent`.\n * There is no event target hierarchy. When a listener calls\n * `stopPropagation` or `preventDefault` on an event object, it means that no\n * more listeners after this one will be called. Same as when the listener\n * returns false.\n */\nclass Target extends Disposable {\n /**\n * @param {*} [target] Default event target for dispatched events.\n */\n constructor(target) {\n super();\n\n /**\n * @private\n * @type {*}\n */\n this.eventTarget_ = target;\n\n /**\n * @private\n * @type {Object|null}\n */\n this.pendingRemovals_ = null;\n\n /**\n * @private\n * @type {Object|null}\n */\n this.dispatching_ = null;\n\n /**\n * @private\n * @type {Object>|null}\n */\n this.listeners_ = null;\n }\n\n /**\n * @param {string} type Type.\n * @param {import(\"../events.js\").Listener} listener Listener.\n */\n addEventListener(type, listener) {\n if (!type || !listener) {\n return;\n }\n const listeners = this.listeners_ || (this.listeners_ = {});\n const listenersForType = listeners[type] || (listeners[type] = []);\n if (!listenersForType.includes(listener)) {\n listenersForType.push(listener);\n }\n }\n\n /**\n * Dispatches an event and calls all listeners listening for events\n * of this type. The event parameter can either be a string or an\n * Object with a `type` property.\n *\n * @param {import(\"./Event.js\").default|string} event Event object.\n * @return {boolean|undefined} `false` if anyone called preventDefault on the\n * event object or if any of the listeners returned false.\n * @api\n */\n dispatchEvent(event) {\n const isString = typeof event === 'string';\n const type = isString ? event : event.type;\n const listeners = this.listeners_ && this.listeners_[type];\n if (!listeners) {\n return;\n }\n\n const evt = isString ? new Event(event) : /** @type {Event} */ (event);\n if (!evt.target) {\n evt.target = this.eventTarget_ || this;\n }\n const dispatching = this.dispatching_ || (this.dispatching_ = {});\n const pendingRemovals =\n this.pendingRemovals_ || (this.pendingRemovals_ = {});\n if (!(type in dispatching)) {\n dispatching[type] = 0;\n pendingRemovals[type] = 0;\n }\n ++dispatching[type];\n let propagate;\n for (let i = 0, ii = listeners.length; i < ii; ++i) {\n if ('handleEvent' in listeners[i]) {\n propagate = /** @type {import(\"../events.js\").ListenerObject} */ (\n listeners[i]\n ).handleEvent(evt);\n } else {\n propagate = /** @type {import(\"../events.js\").ListenerFunction} */ (\n listeners[i]\n ).call(this, evt);\n }\n if (propagate === false || evt.propagationStopped) {\n propagate = false;\n break;\n }\n }\n if (--dispatching[type] === 0) {\n let pr = pendingRemovals[type];\n delete pendingRemovals[type];\n while (pr--) {\n this.removeEventListener(type, VOID);\n }\n delete dispatching[type];\n }\n return propagate;\n }\n\n /**\n * Clean up.\n */\n disposeInternal() {\n this.listeners_ && clear(this.listeners_);\n }\n\n /**\n * Get the listeners for a specified event type. Listeners are returned in the\n * order that they will be called in.\n *\n * @param {string} type Type.\n * @return {Array|undefined} Listeners.\n */\n getListeners(type) {\n return (this.listeners_ && this.listeners_[type]) || undefined;\n }\n\n /**\n * @param {string} [type] Type. If not provided,\n * `true` will be returned if this event target has any listeners.\n * @return {boolean} Has listeners.\n */\n hasListener(type) {\n if (!this.listeners_) {\n return false;\n }\n return type\n ? type in this.listeners_\n : Object.keys(this.listeners_).length > 0;\n }\n\n /**\n * @param {string} type Type.\n * @param {import(\"../events.js\").Listener} listener Listener.\n */\n removeEventListener(type, listener) {\n if (!this.listeners_) {\n return;\n }\n const listeners = this.listeners_[type];\n if (!listeners) {\n return;\n }\n const index = listeners.indexOf(listener);\n if (index !== -1) {\n if (this.pendingRemovals_ && type in this.pendingRemovals_) {\n // make listener a no-op, and remove later in #dispatchEvent()\n listeners[index] = VOID;\n ++this.pendingRemovals_[type];\n } else {\n listeners.splice(index, 1);\n if (listeners.length === 0) {\n delete this.listeners_[type];\n }\n }\n }\n }\n}\n\nexport default Target;\n","/**\n * @module ol/events/EventType\n */\n\n/**\n * @enum {string}\n * @const\n */\nexport default {\n /**\n * Generic change event. Triggered when the revision counter is increased.\n * @event module:ol/events/Event~BaseEvent#change\n * @api\n */\n CHANGE: 'change',\n\n /**\n * Generic error event. Triggered when an error occurs.\n * @event module:ol/events/Event~BaseEvent#error\n * @api\n */\n ERROR: 'error',\n\n BLUR: 'blur',\n CLEAR: 'clear',\n CONTEXTMENU: 'contextmenu',\n CLICK: 'click',\n DBLCLICK: 'dblclick',\n DRAGENTER: 'dragenter',\n DRAGOVER: 'dragover',\n DROP: 'drop',\n FOCUS: 'focus',\n KEYDOWN: 'keydown',\n KEYPRESS: 'keypress',\n LOAD: 'load',\n RESIZE: 'resize',\n TOUCHMOVE: 'touchmove',\n WHEEL: 'wheel',\n};\n","/**\n * @module ol/events\n */\nimport {clear} from './obj.js';\n\n/**\n * Key to use with {@link module:ol/Observable.unByKey}.\n * @typedef {Object} EventsKey\n * @property {ListenerFunction} listener Listener.\n * @property {import(\"./events/Target.js\").EventTargetLike} target Target.\n * @property {string} type Type.\n * @api\n */\n\n/**\n * Listener function. This function is called with an event object as argument.\n * When the function returns `false`, event propagation will stop.\n *\n * @typedef {function((Event|import(\"./events/Event.js\").default)): (void|boolean)} ListenerFunction\n * @api\n */\n\n/**\n * @typedef {Object} ListenerObject\n * @property {ListenerFunction} handleEvent HandleEvent listener function.\n */\n\n/**\n * @typedef {ListenerFunction|ListenerObject} Listener\n */\n\n/**\n * Registers an event listener on an event target. Inspired by\n * https://google.github.io/closure-library/api/source/closure/goog/events/events.js.src.html\n *\n * This function efficiently binds a `listener` to a `this` object, and returns\n * a key for use with {@link module:ol/events.unlistenByKey}.\n *\n * @param {import(\"./events/Target.js\").EventTargetLike} target Event target.\n * @param {string} type Event type.\n * @param {ListenerFunction} listener Listener.\n * @param {Object} [thisArg] Object referenced by the `this` keyword in the\n * listener. Default is the `target`.\n * @param {boolean} [once] If true, add the listener as one-off listener.\n * @return {EventsKey} Unique key for the listener.\n */\nexport function listen(target, type, listener, thisArg, once) {\n if (thisArg && thisArg !== target) {\n listener = listener.bind(thisArg);\n }\n if (once) {\n const originalListener = listener;\n listener = function () {\n target.removeEventListener(type, listener);\n originalListener.apply(this, arguments);\n };\n }\n const eventsKey = {\n target: target,\n type: type,\n listener: listener,\n };\n target.addEventListener(type, listener);\n return eventsKey;\n}\n\n/**\n * Registers a one-off event listener on an event target. Inspired by\n * https://google.github.io/closure-library/api/source/closure/goog/events/events.js.src.html\n *\n * This function efficiently binds a `listener` as self-unregistering listener\n * to a `this` object, and returns a key for use with\n * {@link module:ol/events.unlistenByKey} in case the listener needs to be\n * unregistered before it is called.\n *\n * When {@link module:ol/events.listen} is called with the same arguments after this\n * function, the self-unregistering listener will be turned into a permanent\n * listener.\n *\n * @param {import(\"./events/Target.js\").EventTargetLike} target Event target.\n * @param {string} type Event type.\n * @param {ListenerFunction} listener Listener.\n * @param {Object} [thisArg] Object referenced by the `this` keyword in the\n * listener. Default is the `target`.\n * @return {EventsKey} Key for unlistenByKey.\n */\nexport function listenOnce(target, type, listener, thisArg) {\n return listen(target, type, listener, thisArg, true);\n}\n\n/**\n * Unregisters event listeners on an event target. Inspired by\n * https://google.github.io/closure-library/api/source/closure/goog/events/events.js.src.html\n *\n * The argument passed to this function is the key returned from\n * {@link module:ol/events.listen} or {@link module:ol/events.listenOnce}.\n *\n * @param {EventsKey} key The key.\n */\nexport function unlistenByKey(key) {\n if (key && key.target) {\n key.target.removeEventListener(key.type, key.listener);\n clear(key);\n }\n}\n","/**\n * @module ol/Observable\n */\nimport EventTarget from './events/Target.js';\nimport EventType from './events/EventType.js';\nimport {listen, listenOnce, unlistenByKey} from './events.js';\n\n/***\n * @template {string} Type\n * @template {Event|import(\"./events/Event.js\").default} EventClass\n * @template Return\n * @typedef {(type: Type, listener: (event: EventClass) => ?) => Return} OnSignature\n */\n\n/***\n * @template {string} Type\n * @template Return\n * @typedef {(type: Type[], listener: (event: Event|import(\"./events/Event\").default) => ?) => Return extends void ? void : Return[]} CombinedOnSignature\n */\n\n/**\n * @typedef {'change'|'error'} EventTypes\n */\n\n/***\n * @template Return\n * @typedef {OnSignature & CombinedOnSignature} ObservableOnSignature\n */\n\n/**\n * @classdesc\n * Abstract base class; normally only used for creating subclasses and not\n * instantiated in apps.\n * An event target providing convenient methods for listener registration\n * and unregistration. A generic `change` event is always available through\n * {@link module:ol/Observable~Observable#changed}.\n *\n * @fires import(\"./events/Event.js\").default\n * @api\n */\nclass Observable extends EventTarget {\n constructor() {\n super();\n\n this.on =\n /** @type {ObservableOnSignature} */ (\n this.onInternal\n );\n\n this.once =\n /** @type {ObservableOnSignature} */ (\n this.onceInternal\n );\n\n this.un = /** @type {ObservableOnSignature} */ (this.unInternal);\n\n /**\n * @private\n * @type {number}\n */\n this.revision_ = 0;\n }\n\n /**\n * Increases the revision counter and dispatches a 'change' event.\n * @api\n */\n changed() {\n ++this.revision_;\n this.dispatchEvent(EventType.CHANGE);\n }\n\n /**\n * Get the version number for this object. Each time the object is modified,\n * its version number will be incremented.\n * @return {number} Revision.\n * @api\n */\n getRevision() {\n return this.revision_;\n }\n\n /**\n * @param {string|Array} type Type.\n * @param {function((Event|import(\"./events/Event\").default)): ?} listener Listener.\n * @return {import(\"./events.js\").EventsKey|Array} Event key.\n * @protected\n */\n onInternal(type, listener) {\n if (Array.isArray(type)) {\n const len = type.length;\n const keys = new Array(len);\n for (let i = 0; i < len; ++i) {\n keys[i] = listen(this, type[i], listener);\n }\n return keys;\n }\n return listen(this, /** @type {string} */ (type), listener);\n }\n\n /**\n * @param {string|Array} type Type.\n * @param {function((Event|import(\"./events/Event\").default)): ?} listener Listener.\n * @return {import(\"./events.js\").EventsKey|Array} Event key.\n * @protected\n */\n onceInternal(type, listener) {\n let key;\n if (Array.isArray(type)) {\n const len = type.length;\n key = new Array(len);\n for (let i = 0; i < len; ++i) {\n key[i] = listenOnce(this, type[i], listener);\n }\n } else {\n key = listenOnce(this, /** @type {string} */ (type), listener);\n }\n /** @type {Object} */ (listener).ol_key = key;\n return key;\n }\n\n /**\n * Unlisten for a certain type of event.\n * @param {string|Array} type Type.\n * @param {function((Event|import(\"./events/Event\").default)): ?} listener Listener.\n * @protected\n */\n unInternal(type, listener) {\n const key = /** @type {Object} */ (listener).ol_key;\n if (key) {\n unByKey(key);\n } else if (Array.isArray(type)) {\n for (let i = 0, ii = type.length; i < ii; ++i) {\n this.removeEventListener(type[i], listener);\n }\n } else {\n this.removeEventListener(type, listener);\n }\n }\n}\n\n/**\n * Listen for a certain type of event.\n * @function\n * @param {string|Array} type The event type or array of event types.\n * @param {function((Event|import(\"./events/Event\").default)): ?} listener The listener function.\n * @return {import(\"./events.js\").EventsKey|Array} Unique key for the listener. If\n * called with an array of event types as the first argument, the return\n * will be an array of keys.\n * @api\n */\nObservable.prototype.on;\n\n/**\n * Listen once for a certain type of event.\n * @function\n * @param {string|Array} type The event type or array of event types.\n * @param {function((Event|import(\"./events/Event\").default)): ?} listener The listener function.\n * @return {import(\"./events.js\").EventsKey|Array} Unique key for the listener. If\n * called with an array of event types as the first argument, the return\n * will be an array of keys.\n * @api\n */\nObservable.prototype.once;\n\n/**\n * Unlisten for a certain type of event.\n * @function\n * @param {string|Array} type The event type or array of event types.\n * @param {function((Event|import(\"./events/Event\").default)): ?} listener The listener function.\n * @api\n */\nObservable.prototype.un;\n\n/**\n * Removes an event listener using the key returned by `on()` or `once()`.\n * @param {import(\"./events.js\").EventsKey|Array} key The key returned by `on()`\n * or `once()` (or an array of keys).\n * @api\n */\nexport function unByKey(key) {\n if (Array.isArray(key)) {\n for (let i = 0, ii = key.length; i < ii; ++i) {\n unlistenByKey(key[i]);\n }\n } else {\n unlistenByKey(/** @type {import(\"./events.js\").EventsKey} */ (key));\n }\n}\n\nexport default Observable;\n","/**\n * @module ol/util\n */\n\n/**\n * @return {never} Any return.\n */\nexport function abstract() {\n throw new Error('Unimplemented abstract method.');\n}\n\n/**\n * Counter for getUid.\n * @type {number}\n * @private\n */\nlet uidCounter_ = 0;\n\n/**\n * Gets a unique ID for an object. This mutates the object so that further calls\n * with the same object as a parameter returns the same value. Unique IDs are generated\n * as a strictly increasing sequence. Adapted from goog.getUid.\n *\n * @param {Object} obj The object to get the unique ID for.\n * @return {string} The unique ID for the object.\n * @api\n */\nexport function getUid(obj) {\n return obj.ol_uid || (obj.ol_uid = String(++uidCounter_));\n}\n\n/**\n * OpenLayers version.\n * @type {string}\n */\nexport const VERSION = '9.2.4';\n","/**\n * @module ol/Object\n */\nimport Event from './events/Event.js';\nimport ObjectEventType from './ObjectEventType.js';\nimport Observable from './Observable.js';\nimport {getUid} from './util.js';\nimport {isEmpty} from './obj.js';\n\n/**\n * @classdesc\n * Events emitted by {@link module:ol/Object~BaseObject} instances are instances of this type.\n */\nexport class ObjectEvent extends Event {\n /**\n * @param {string} type The event type.\n * @param {string} key The property name.\n * @param {*} oldValue The old value for `key`.\n */\n constructor(type, key, oldValue) {\n super(type);\n\n /**\n * The name of the property whose value is changing.\n * @type {string}\n * @api\n */\n this.key = key;\n\n /**\n * The old value. To get the new value use `e.target.get(e.key)` where\n * `e` is the event object.\n * @type {*}\n * @api\n */\n this.oldValue = oldValue;\n }\n}\n\n/***\n * @template Return\n * @typedef {import(\"./Observable\").OnSignature &\n * import(\"./Observable\").OnSignature &\n * import(\"./Observable\").CombinedOnSignature} ObjectOnSignature\n */\n\n/**\n * @classdesc\n * Abstract base class; normally only used for creating subclasses and not\n * instantiated in apps.\n * Most non-trivial classes inherit from this.\n *\n * This extends {@link module:ol/Observable~Observable} with observable\n * properties, where each property is observable as well as the object as a\n * whole.\n *\n * Classes that inherit from this have pre-defined properties, to which you can\n * add your owns. The pre-defined properties are listed in this documentation as\n * 'Observable Properties', and have their own accessors; for example,\n * {@link module:ol/Map~Map} has a `target` property, accessed with\n * `getTarget()` and changed with `setTarget()`. Not all properties are however\n * settable. There are also general-purpose accessors `get()` and `set()`. For\n * example, `get('target')` is equivalent to `getTarget()`.\n *\n * The `set` accessors trigger a change event, and you can monitor this by\n * registering a listener. For example, {@link module:ol/View~View} has a\n * `center` property, so `view.on('change:center', function(evt) {...});` would\n * call the function whenever the value of the center property changes. Within\n * the function, `evt.target` would be the view, so `evt.target.getCenter()`\n * would return the new center.\n *\n * You can add your own observable properties with\n * `object.set('prop', 'value')`, and retrieve that with `object.get('prop')`.\n * You can listen for changes on that property value with\n * `object.on('change:prop', listener)`. You can get a list of all\n * properties with {@link module:ol/Object~BaseObject#getProperties}.\n *\n * Note that the observable properties are separate from standard JS properties.\n * You can, for example, give your map object a title with\n * `map.title='New title'` and with `map.set('title', 'Another title')`. The\n * first will be a `hasOwnProperty`; the second will appear in\n * `getProperties()`. Only the second is observable.\n *\n * Properties can be deleted by using the unset method. E.g.\n * object.unset('foo').\n *\n * @fires ObjectEvent\n * @api\n */\nclass BaseObject extends Observable {\n /**\n * @param {Object} [values] An object with key-value pairs.\n */\n constructor(values) {\n super();\n\n /***\n * @type {ObjectOnSignature}\n */\n this.on;\n\n /***\n * @type {ObjectOnSignature}\n */\n this.once;\n\n /***\n * @type {ObjectOnSignature}\n */\n this.un;\n\n // Call {@link module:ol/util.getUid} to ensure that the order of objects' ids is\n // the same as the order in which they were created. This also helps to\n // ensure that object properties are always added in the same order, which\n // helps many JavaScript engines generate faster code.\n getUid(this);\n\n /**\n * @private\n * @type {Object|null}\n */\n this.values_ = null;\n\n if (values !== undefined) {\n this.setProperties(values);\n }\n }\n\n /**\n * Gets a value.\n * @param {string} key Key name.\n * @return {*} Value.\n * @api\n */\n get(key) {\n let value;\n if (this.values_ && this.values_.hasOwnProperty(key)) {\n value = this.values_[key];\n }\n return value;\n }\n\n /**\n * Get a list of object property names.\n * @return {Array} List of property names.\n * @api\n */\n getKeys() {\n return (this.values_ && Object.keys(this.values_)) || [];\n }\n\n /**\n * Get an object of all property names and values.\n * @return {Object} Object.\n * @api\n */\n getProperties() {\n return (this.values_ && Object.assign({}, this.values_)) || {};\n }\n\n /**\n * Get an object of all property names and values.\n * @return {Object?} Object.\n */\n getPropertiesInternal() {\n return this.values_;\n }\n\n /**\n * @return {boolean} The object has properties.\n */\n hasProperties() {\n return !!this.values_;\n }\n\n /**\n * @param {string} key Key name.\n * @param {*} oldValue Old value.\n */\n notify(key, oldValue) {\n let eventType;\n eventType = `change:${key}`;\n if (this.hasListener(eventType)) {\n this.dispatchEvent(new ObjectEvent(eventType, key, oldValue));\n }\n eventType = ObjectEventType.PROPERTYCHANGE;\n if (this.hasListener(eventType)) {\n this.dispatchEvent(new ObjectEvent(eventType, key, oldValue));\n }\n }\n\n /**\n * @param {string} key Key name.\n * @param {import(\"./events.js\").Listener} listener Listener.\n */\n addChangeListener(key, listener) {\n this.addEventListener(`change:${key}`, listener);\n }\n\n /**\n * @param {string} key Key name.\n * @param {import(\"./events.js\").Listener} listener Listener.\n */\n removeChangeListener(key, listener) {\n this.removeEventListener(`change:${key}`, listener);\n }\n\n /**\n * Sets a value.\n * @param {string} key Key name.\n * @param {*} value Value.\n * @param {boolean} [silent] Update without triggering an event.\n * @api\n */\n set(key, value, silent) {\n const values = this.values_ || (this.values_ = {});\n if (silent) {\n values[key] = value;\n } else {\n const oldValue = values[key];\n values[key] = value;\n if (oldValue !== value) {\n this.notify(key, oldValue);\n }\n }\n }\n\n /**\n * Sets a collection of key-value pairs. Note that this changes any existing\n * properties and adds new ones (it does not remove any existing properties).\n * @param {Object} values Values.\n * @param {boolean} [silent] Update without triggering an event.\n * @api\n */\n setProperties(values, silent) {\n for (const key in values) {\n this.set(key, values[key], silent);\n }\n }\n\n /**\n * Apply any properties from another object without triggering events.\n * @param {BaseObject} source The source object.\n * @protected\n */\n applyProperties(source) {\n if (!source.values_) {\n return;\n }\n Object.assign(this.values_ || (this.values_ = {}), source.values_);\n }\n\n /**\n * Unsets a property.\n * @param {string} key Key name.\n * @param {boolean} [silent] Unset without triggering an event.\n * @api\n */\n unset(key, silent) {\n if (this.values_ && key in this.values_) {\n const oldValue = this.values_[key];\n delete this.values_[key];\n if (isEmpty(this.values_)) {\n this.values_ = null;\n }\n if (!silent) {\n this.notify(key, oldValue);\n }\n }\n }\n}\n\nexport default BaseObject;\n","/**\n * @module ol/CollectionEventType\n */\n\n/**\n * @enum {string}\n */\nexport default {\n /**\n * Triggered when an item is added to the collection.\n * @event module:ol/Collection.CollectionEvent#add\n * @api\n */\n ADD: 'add',\n /**\n * Triggered when an item is removed from the collection.\n * @event module:ol/Collection.CollectionEvent#remove\n * @api\n */\n REMOVE: 'remove',\n};\n","/**\n * @module ol/Collection\n */\nimport BaseObject from './Object.js';\nimport CollectionEventType from './CollectionEventType.js';\nimport Event from './events/Event.js';\n\n/**\n * @enum {string}\n * @private\n */\nconst Property = {\n LENGTH: 'length',\n};\n\n/**\n * @classdesc\n * Events emitted by {@link module:ol/Collection~Collection} instances are instances of this\n * type.\n * @template T\n */\nexport class CollectionEvent extends Event {\n /**\n * @param {import(\"./CollectionEventType.js\").default} type Type.\n * @param {T} element Element.\n * @param {number} index The index of the added or removed element.\n */\n constructor(type, element, index) {\n super(type);\n\n /**\n * The element that is added to or removed from the collection.\n * @type {T}\n * @api\n */\n this.element = element;\n\n /**\n * The index of the added or removed element.\n * @type {number}\n * @api\n */\n this.index = index;\n }\n}\n\n/***\n * @template T\n * @template Return\n * @typedef {import(\"./Observable\").OnSignature &\n * import(\"./Observable\").OnSignature &\n * import(\"./Observable\").OnSignature<'add'|'remove', CollectionEvent, Return> &\n * import(\"./Observable\").CombinedOnSignature} CollectionOnSignature\n */\n\n/**\n * @typedef {Object} Options\n * @property {boolean} [unique=false] Disallow the same item from being added to\n * the collection twice.\n */\n\n/**\n * @classdesc\n * An expanded version of standard JS Array, adding convenience methods for\n * manipulation. Add and remove changes to the Collection trigger a Collection\n * event. Note that this does not cover changes to the objects _within_ the\n * Collection; they trigger events on the appropriate object, not on the\n * Collection as a whole.\n *\n * @fires CollectionEvent\n *\n * @template T\n * @api\n */\nclass Collection extends BaseObject {\n /**\n * @param {Array} [array] Array.\n * @param {Options} [options] Collection options.\n */\n constructor(array, options) {\n super();\n\n /***\n * @type {CollectionOnSignature}\n */\n this.on;\n\n /***\n * @type {CollectionOnSignature}\n */\n this.once;\n\n /***\n * @type {CollectionOnSignature}\n */\n this.un;\n\n options = options || {};\n\n /**\n * @private\n * @type {boolean}\n */\n this.unique_ = !!options.unique;\n\n /**\n * @private\n * @type {!Array}\n */\n this.array_ = array ? array : [];\n\n if (this.unique_) {\n for (let i = 0, ii = this.array_.length; i < ii; ++i) {\n this.assertUnique_(this.array_[i], i);\n }\n }\n\n this.updateLength_();\n }\n\n /**\n * Remove all elements from the collection.\n * @api\n */\n clear() {\n while (this.getLength() > 0) {\n this.pop();\n }\n }\n\n /**\n * Add elements to the collection. This pushes each item in the provided array\n * to the end of the collection.\n * @param {!Array} arr Array.\n * @return {Collection} This collection.\n * @api\n */\n extend(arr) {\n for (let i = 0, ii = arr.length; i < ii; ++i) {\n this.push(arr[i]);\n }\n return this;\n }\n\n /**\n * Iterate over each element, calling the provided callback.\n * @param {function(T, number, Array): *} f The function to call\n * for every element. This function takes 3 arguments (the element, the\n * index and the array). The return value is ignored.\n * @api\n */\n forEach(f) {\n const array = this.array_;\n for (let i = 0, ii = array.length; i < ii; ++i) {\n f(array[i], i, array);\n }\n }\n\n /**\n * Get a reference to the underlying Array object. Warning: if the array\n * is mutated, no events will be dispatched by the collection, and the\n * collection's \"length\" property won't be in sync with the actual length\n * of the array.\n * @return {!Array} Array.\n * @api\n */\n getArray() {\n return this.array_;\n }\n\n /**\n * Get the element at the provided index.\n * @param {number} index Index.\n * @return {T} Element.\n * @api\n */\n item(index) {\n return this.array_[index];\n }\n\n /**\n * Get the length of this collection.\n * @return {number} The length of the array.\n * @observable\n * @api\n */\n getLength() {\n return this.get(Property.LENGTH);\n }\n\n /**\n * Insert an element at the provided index.\n * @param {number} index Index.\n * @param {T} elem Element.\n * @api\n */\n insertAt(index, elem) {\n if (index < 0 || index > this.getLength()) {\n throw new Error('Index out of bounds: ' + index);\n }\n if (this.unique_) {\n this.assertUnique_(elem);\n }\n this.array_.splice(index, 0, elem);\n this.updateLength_();\n this.dispatchEvent(\n new CollectionEvent(CollectionEventType.ADD, elem, index),\n );\n }\n\n /**\n * Remove the last element of the collection and return it.\n * Return `undefined` if the collection is empty.\n * @return {T|undefined} Element.\n * @api\n */\n pop() {\n return this.removeAt(this.getLength() - 1);\n }\n\n /**\n * Insert the provided element at the end of the collection.\n * @param {T} elem Element.\n * @return {number} New length of the collection.\n * @api\n */\n push(elem) {\n if (this.unique_) {\n this.assertUnique_(elem);\n }\n const n = this.getLength();\n this.insertAt(n, elem);\n return this.getLength();\n }\n\n /**\n * Remove the first occurrence of an element from the collection.\n * @param {T} elem Element.\n * @return {T|undefined} The removed element or undefined if none found.\n * @api\n */\n remove(elem) {\n const arr = this.array_;\n for (let i = 0, ii = arr.length; i < ii; ++i) {\n if (arr[i] === elem) {\n return this.removeAt(i);\n }\n }\n return undefined;\n }\n\n /**\n * Remove the element at the provided index and return it.\n * Return `undefined` if the collection does not contain this index.\n * @param {number} index Index.\n * @return {T|undefined} Value.\n * @api\n */\n removeAt(index) {\n if (index < 0 || index >= this.getLength()) {\n return undefined;\n }\n const prev = this.array_[index];\n this.array_.splice(index, 1);\n this.updateLength_();\n this.dispatchEvent(\n /** @type {CollectionEvent} */ (\n new CollectionEvent(CollectionEventType.REMOVE, prev, index)\n ),\n );\n return prev;\n }\n\n /**\n * Set the element at the provided index.\n * @param {number} index Index.\n * @param {T} elem Element.\n * @api\n */\n setAt(index, elem) {\n const n = this.getLength();\n if (index >= n) {\n this.insertAt(index, elem);\n return;\n }\n if (index < 0) {\n throw new Error('Index out of bounds: ' + index);\n }\n if (this.unique_) {\n this.assertUnique_(elem, index);\n }\n const prev = this.array_[index];\n this.array_[index] = elem;\n this.dispatchEvent(\n /** @type {CollectionEvent} */ (\n new CollectionEvent(CollectionEventType.REMOVE, prev, index)\n ),\n );\n this.dispatchEvent(\n /** @type {CollectionEvent} */ (\n new CollectionEvent(CollectionEventType.ADD, elem, index)\n ),\n );\n }\n\n /**\n * @private\n */\n updateLength_() {\n this.set(Property.LENGTH, this.array_.length);\n }\n\n /**\n * @private\n * @param {T} elem Element.\n * @param {number} [except] Optional index to ignore.\n */\n assertUnique_(elem, except) {\n for (let i = 0, ii = this.array_.length; i < ii; ++i) {\n if (this.array_[i] === elem && i !== except) {\n throw new Error('Duplicate item added to a unique collection');\n }\n }\n }\n}\n\nexport default Collection;\n","/**\n * @module ol/asserts\n */\n\n/**\n * @param {*} assertion Assertion we expected to be truthy.\n * @param {string} errorMessage Error message.\n */\nexport function assert(assertion, errorMessage) {\n if (!assertion) {\n throw new Error(errorMessage);\n }\n}\n","/**\n * @module ol/Feature\n */\nimport BaseObject from './Object.js';\nimport EventType from './events/EventType.js';\nimport {assert} from './asserts.js';\nimport {listen, unlistenByKey} from './events.js';\n\n/**\n * @typedef {typeof Feature|typeof import(\"./render/Feature.js\").default} FeatureClass\n */\n\n/**\n * @typedef {Feature|import(\"./render/Feature.js\").default} FeatureLike\n */\n\n/***\n * @template Return\n * @typedef {import(\"./Observable\").OnSignature &\n * import(\"./Observable\").OnSignature &\n * import(\"./Observable\").CombinedOnSignature} FeatureOnSignature\n */\n\n/***\n * @template {import(\"./geom/Geometry.js\").default} [Geometry=import(\"./geom/Geometry.js\").default]\n * @typedef {Object & { geometry?: Geometry }} ObjectWithGeometry\n */\n\n/**\n * @classdesc\n * A vector object for geographic features with a geometry and other\n * attribute properties, similar to the features in vector file formats like\n * GeoJSON.\n *\n * Features can be styled individually with `setStyle`; otherwise they use the\n * style of their vector layer.\n *\n * Note that attribute properties are set as {@link module:ol/Object~BaseObject} properties on\n * the feature object, so they are observable, and have get/set accessors.\n *\n * Typically, a feature has a single geometry property. You can set the\n * geometry using the `setGeometry` method and get it with `getGeometry`.\n * It is possible to store more than one geometry on a feature using attribute\n * properties. By default, the geometry used for rendering is identified by\n * the property name `geometry`. If you want to use another geometry property\n * for rendering, use the `setGeometryName` method to change the attribute\n * property associated with the geometry for the feature. For example:\n *\n * ```js\n *\n * import Feature from 'ol/Feature.js';\n * import Polygon from 'ol/geom/Polygon.js';\n * import Point from 'ol/geom/Point.js';\n *\n * const feature = new Feature({\n * geometry: new Polygon(polyCoords),\n * labelPoint: new Point(labelCoords),\n * name: 'My Polygon',\n * });\n *\n * // get the polygon geometry\n * const poly = feature.getGeometry();\n *\n * // Render the feature as a point using the coordinates from labelPoint\n * feature.setGeometryName('labelPoint');\n *\n * // get the point geometry\n * const point = feature.getGeometry();\n * ```\n *\n * @api\n * @template {import(\"./geom/Geometry.js\").default} [Geometry=import(\"./geom/Geometry.js\").default]\n */\nclass Feature extends BaseObject {\n /**\n * @param {Geometry|ObjectWithGeometry} [geometryOrProperties]\n * You may pass a Geometry object directly, or an object literal containing\n * properties. If you pass an object literal, you may include a Geometry\n * associated with a `geometry` key.\n */\n constructor(geometryOrProperties) {\n super();\n\n /***\n * @type {FeatureOnSignature}\n */\n this.on;\n\n /***\n * @type {FeatureOnSignature}\n */\n this.once;\n\n /***\n * @type {FeatureOnSignature}\n */\n this.un;\n\n /**\n * @private\n * @type {number|string|undefined}\n */\n this.id_ = undefined;\n\n /**\n * @type {string}\n * @private\n */\n this.geometryName_ = 'geometry';\n\n /**\n * User provided style.\n * @private\n * @type {import(\"./style/Style.js\").StyleLike}\n */\n this.style_ = null;\n\n /**\n * @private\n * @type {import(\"./style/Style.js\").StyleFunction|undefined}\n */\n this.styleFunction_ = undefined;\n\n /**\n * @private\n * @type {?import(\"./events.js\").EventsKey}\n */\n this.geometryChangeKey_ = null;\n\n this.addChangeListener(this.geometryName_, this.handleGeometryChanged_);\n\n if (geometryOrProperties) {\n if (\n typeof (\n /** @type {?} */ (geometryOrProperties).getSimplifiedGeometry\n ) === 'function'\n ) {\n const geometry = /** @type {Geometry} */ (geometryOrProperties);\n this.setGeometry(geometry);\n } else {\n /** @type {Object} */\n const properties = geometryOrProperties;\n this.setProperties(properties);\n }\n }\n }\n\n /**\n * Clone this feature. If the original feature has a geometry it\n * is also cloned. The feature id is not set in the clone.\n * @return {Feature} The clone.\n * @api\n */\n clone() {\n const clone = /** @type {Feature} */ (\n new Feature(this.hasProperties() ? this.getProperties() : null)\n );\n clone.setGeometryName(this.getGeometryName());\n const geometry = this.getGeometry();\n if (geometry) {\n clone.setGeometry(/** @type {Geometry} */ (geometry.clone()));\n }\n const style = this.getStyle();\n if (style) {\n clone.setStyle(style);\n }\n return clone;\n }\n\n /**\n * Get the feature's default geometry. A feature may have any number of named\n * geometries. The \"default\" geometry (the one that is rendered by default) is\n * set when calling {@link module:ol/Feature~Feature#setGeometry}.\n * @return {Geometry|undefined} The default geometry for the feature.\n * @api\n * @observable\n */\n getGeometry() {\n return /** @type {Geometry|undefined} */ (this.get(this.geometryName_));\n }\n\n /**\n * Get the feature identifier. This is a stable identifier for the feature and\n * is either set when reading data from a remote source or set explicitly by\n * calling {@link module:ol/Feature~Feature#setId}.\n * @return {number|string|undefined} Id.\n * @api\n */\n getId() {\n return this.id_;\n }\n\n /**\n * Get the name of the feature's default geometry. By default, the default\n * geometry is named `geometry`.\n * @return {string} Get the property name associated with the default geometry\n * for this feature.\n * @api\n */\n getGeometryName() {\n return this.geometryName_;\n }\n\n /**\n * Get the feature's style. Will return what was provided to the\n * {@link module:ol/Feature~Feature#setStyle} method.\n * @return {import(\"./style/Style.js\").StyleLike|undefined} The feature style.\n * @api\n */\n getStyle() {\n return this.style_;\n }\n\n /**\n * Get the feature's style function.\n * @return {import(\"./style/Style.js\").StyleFunction|undefined} Return a function\n * representing the current style of this feature.\n * @api\n */\n getStyleFunction() {\n return this.styleFunction_;\n }\n\n /**\n * @private\n */\n handleGeometryChange_() {\n this.changed();\n }\n\n /**\n * @private\n */\n handleGeometryChanged_() {\n if (this.geometryChangeKey_) {\n unlistenByKey(this.geometryChangeKey_);\n this.geometryChangeKey_ = null;\n }\n const geometry = this.getGeometry();\n if (geometry) {\n this.geometryChangeKey_ = listen(\n geometry,\n EventType.CHANGE,\n this.handleGeometryChange_,\n this,\n );\n }\n this.changed();\n }\n\n /**\n * Set the default geometry for the feature. This will update the property\n * with the name returned by {@link module:ol/Feature~Feature#getGeometryName}.\n * @param {Geometry|undefined} geometry The new geometry.\n * @api\n * @observable\n */\n setGeometry(geometry) {\n this.set(this.geometryName_, geometry);\n }\n\n /**\n * Set the style for the feature to override the layer style. This can be a\n * single style object, an array of styles, or a function that takes a\n * resolution and returns an array of styles. To unset the feature style, call\n * `setStyle()` without arguments or a falsey value.\n * @param {import(\"./style/Style.js\").StyleLike} [style] Style for this feature.\n * @api\n * @fires module:ol/events/Event~BaseEvent#event:change\n */\n setStyle(style) {\n this.style_ = style;\n this.styleFunction_ = !style ? undefined : createStyleFunction(style);\n this.changed();\n }\n\n /**\n * Set the feature id. The feature id is considered stable and may be used when\n * requesting features or comparing identifiers returned from a remote source.\n * The feature id can be used with the\n * {@link module:ol/source/Vector~VectorSource#getFeatureById} method.\n * @param {number|string|undefined} id The feature id.\n * @api\n * @fires module:ol/events/Event~BaseEvent#event:change\n */\n setId(id) {\n this.id_ = id;\n this.changed();\n }\n\n /**\n * Set the property name to be used when getting the feature's default geometry.\n * When calling {@link module:ol/Feature~Feature#getGeometry}, the value of the property with\n * this name will be returned.\n * @param {string} name The property name of the default geometry.\n * @api\n */\n setGeometryName(name) {\n this.removeChangeListener(this.geometryName_, this.handleGeometryChanged_);\n this.geometryName_ = name;\n this.addChangeListener(this.geometryName_, this.handleGeometryChanged_);\n this.handleGeometryChanged_();\n }\n}\n\n/**\n * Convert the provided object into a feature style function. Functions passed\n * through unchanged. Arrays of Style or single style objects wrapped\n * in a new feature style function.\n * @param {!import(\"./style/Style.js\").StyleFunction|!Array|!import(\"./style/Style.js\").default} obj\n * A feature style function, a single style, or an array of styles.\n * @return {import(\"./style/Style.js\").StyleFunction} A style function.\n */\nexport function createStyleFunction(obj) {\n if (typeof obj === 'function') {\n return obj;\n }\n /**\n * @type {Array}\n */\n let styles;\n if (Array.isArray(obj)) {\n styles = obj;\n } else {\n assert(\n typeof (/** @type {?} */ (obj).getZIndex) === 'function',\n 'Expected an `ol/style/Style` or an array of `ol/style/Style.js`',\n );\n const style = /** @type {import(\"./style/Style.js\").default} */ (obj);\n styles = [style];\n }\n return function () {\n return styles;\n };\n}\nexport default Feature;\n","/**\n * @module ol/transform\n */\nimport {assert} from './asserts.js';\n\n/**\n * An array representing an affine 2d transformation for use with\n * {@link module:ol/transform} functions. The array has 6 elements.\n * @typedef {!Array} Transform\n * @api\n */\n\n/**\n * Collection of affine 2d transformation functions. The functions work on an\n * array of 6 elements. The element order is compatible with the [SVGMatrix\n * interface](https://developer.mozilla.org/en-US/docs/Web/API/SVGMatrix) and is\n * a subset (elements a to f) of a 3×3 matrix:\n * ```\n * [ a c e ]\n * [ b d f ]\n * [ 0 0 1 ]\n * ```\n */\n\n/**\n * @private\n * @type {Transform}\n */\nconst tmp_ = new Array(6);\n\n/**\n * Create an identity transform.\n * @return {!Transform} Identity transform.\n */\nexport function create() {\n return [1, 0, 0, 1, 0, 0];\n}\n\n/**\n * Resets the given transform to an identity transform.\n * @param {!Transform} transform Transform.\n * @return {!Transform} Transform.\n */\nexport function reset(transform) {\n return set(transform, 1, 0, 0, 1, 0, 0);\n}\n\n/**\n * Multiply the underlying matrices of two transforms and return the result in\n * the first transform.\n * @param {!Transform} transform1 Transform parameters of matrix 1.\n * @param {!Transform} transform2 Transform parameters of matrix 2.\n * @return {!Transform} transform1 multiplied with transform2.\n */\nexport function multiply(transform1, transform2) {\n const a1 = transform1[0];\n const b1 = transform1[1];\n const c1 = transform1[2];\n const d1 = transform1[3];\n const e1 = transform1[4];\n const f1 = transform1[5];\n const a2 = transform2[0];\n const b2 = transform2[1];\n const c2 = transform2[2];\n const d2 = transform2[3];\n const e2 = transform2[4];\n const f2 = transform2[5];\n\n transform1[0] = a1 * a2 + c1 * b2;\n transform1[1] = b1 * a2 + d1 * b2;\n transform1[2] = a1 * c2 + c1 * d2;\n transform1[3] = b1 * c2 + d1 * d2;\n transform1[4] = a1 * e2 + c1 * f2 + e1;\n transform1[5] = b1 * e2 + d1 * f2 + f1;\n\n return transform1;\n}\n\n/**\n * Set the transform components a-f on a given transform.\n * @param {!Transform} transform Transform.\n * @param {number} a The a component of the transform.\n * @param {number} b The b component of the transform.\n * @param {number} c The c component of the transform.\n * @param {number} d The d component of the transform.\n * @param {number} e The e component of the transform.\n * @param {number} f The f component of the transform.\n * @return {!Transform} Matrix with transform applied.\n */\nexport function set(transform, a, b, c, d, e, f) {\n transform[0] = a;\n transform[1] = b;\n transform[2] = c;\n transform[3] = d;\n transform[4] = e;\n transform[5] = f;\n return transform;\n}\n\n/**\n * Set transform on one matrix from another matrix.\n * @param {!Transform} transform1 Matrix to set transform to.\n * @param {!Transform} transform2 Matrix to set transform from.\n * @return {!Transform} transform1 with transform from transform2 applied.\n */\nexport function setFromArray(transform1, transform2) {\n transform1[0] = transform2[0];\n transform1[1] = transform2[1];\n transform1[2] = transform2[2];\n transform1[3] = transform2[3];\n transform1[4] = transform2[4];\n transform1[5] = transform2[5];\n return transform1;\n}\n\n/**\n * Transforms the given coordinate with the given transform returning the\n * resulting, transformed coordinate. The coordinate will be modified in-place.\n *\n * @param {Transform} transform The transformation.\n * @param {import(\"./coordinate.js\").Coordinate|import(\"./pixel.js\").Pixel} coordinate The coordinate to transform.\n * @return {import(\"./coordinate.js\").Coordinate|import(\"./pixel.js\").Pixel} return coordinate so that operations can be\n * chained together.\n */\nexport function apply(transform, coordinate) {\n const x = coordinate[0];\n const y = coordinate[1];\n coordinate[0] = transform[0] * x + transform[2] * y + transform[4];\n coordinate[1] = transform[1] * x + transform[3] * y + transform[5];\n return coordinate;\n}\n\n/**\n * Applies rotation to the given transform.\n * @param {!Transform} transform Transform.\n * @param {number} angle Angle in radians.\n * @return {!Transform} The rotated transform.\n */\nexport function rotate(transform, angle) {\n const cos = Math.cos(angle);\n const sin = Math.sin(angle);\n return multiply(transform, set(tmp_, cos, sin, -sin, cos, 0, 0));\n}\n\n/**\n * Applies scale to a given transform.\n * @param {!Transform} transform Transform.\n * @param {number} x Scale factor x.\n * @param {number} y Scale factor y.\n * @return {!Transform} The scaled transform.\n */\nexport function scale(transform, x, y) {\n return multiply(transform, set(tmp_, x, 0, 0, y, 0, 0));\n}\n\n/**\n * Creates a scale transform.\n * @param {!Transform} target Transform to overwrite.\n * @param {number} x Scale factor x.\n * @param {number} y Scale factor y.\n * @return {!Transform} The scale transform.\n */\nexport function makeScale(target, x, y) {\n return set(target, x, 0, 0, y, 0, 0);\n}\n\n/**\n * Applies translation to the given transform.\n * @param {!Transform} transform Transform.\n * @param {number} dx Translation x.\n * @param {number} dy Translation y.\n * @return {!Transform} The translated transform.\n */\nexport function translate(transform, dx, dy) {\n return multiply(transform, set(tmp_, 1, 0, 0, 1, dx, dy));\n}\n\n/**\n * Creates a composite transform given an initial translation, scale, rotation, and\n * final translation (in that order only, not commutative).\n * @param {!Transform} transform The transform (will be modified in place).\n * @param {number} dx1 Initial translation x.\n * @param {number} dy1 Initial translation y.\n * @param {number} sx Scale factor x.\n * @param {number} sy Scale factor y.\n * @param {number} angle Rotation (in counter-clockwise radians).\n * @param {number} dx2 Final translation x.\n * @param {number} dy2 Final translation y.\n * @return {!Transform} The composite transform.\n */\nexport function compose(transform, dx1, dy1, sx, sy, angle, dx2, dy2) {\n const sin = Math.sin(angle);\n const cos = Math.cos(angle);\n transform[0] = sx * cos;\n transform[1] = sy * sin;\n transform[2] = -sx * sin;\n transform[3] = sy * cos;\n transform[4] = dx2 * sx * cos - dy2 * sx * sin + dx1;\n transform[5] = dx2 * sy * sin + dy2 * sy * cos + dy1;\n return transform;\n}\n\n/**\n * Creates a composite transform given an initial translation, scale, rotation, and\n * final translation (in that order only, not commutative). The resulting transform\n * string can be applied as `transform` property of an HTMLElement's style.\n * @param {number} dx1 Initial translation x.\n * @param {number} dy1 Initial translation y.\n * @param {number} sx Scale factor x.\n * @param {number} sy Scale factor y.\n * @param {number} angle Rotation (in counter-clockwise radians).\n * @param {number} dx2 Final translation x.\n * @param {number} dy2 Final translation y.\n * @return {string} The composite css transform.\n * @api\n */\nexport function composeCssTransform(dx1, dy1, sx, sy, angle, dx2, dy2) {\n return toString(compose(create(), dx1, dy1, sx, sy, angle, dx2, dy2));\n}\n\n/**\n * Invert the given transform.\n * @param {!Transform} source The source transform to invert.\n * @return {!Transform} The inverted (source) transform.\n */\nexport function invert(source) {\n return makeInverse(source, source);\n}\n\n/**\n * Invert the given transform.\n * @param {!Transform} target Transform to be set as the inverse of\n * the source transform.\n * @param {!Transform} source The source transform to invert.\n * @return {!Transform} The inverted (target) transform.\n */\nexport function makeInverse(target, source) {\n const det = determinant(source);\n assert(det !== 0, 'Transformation matrix cannot be inverted');\n\n const a = source[0];\n const b = source[1];\n const c = source[2];\n const d = source[3];\n const e = source[4];\n const f = source[5];\n\n target[0] = d / det;\n target[1] = -b / det;\n target[2] = -c / det;\n target[3] = a / det;\n target[4] = (c * f - d * e) / det;\n target[5] = -(a * f - b * e) / det;\n\n return target;\n}\n\n/**\n * Returns the determinant of the given matrix.\n * @param {!Transform} mat Matrix.\n * @return {number} Determinant.\n */\nexport function determinant(mat) {\n return mat[0] * mat[3] - mat[1] * mat[2];\n}\n\n/**\n * @type {Array}\n */\nconst matrixPrecision = [1e6, 1e6, 1e6, 1e6, 2, 2];\n\n/**\n * A rounded string version of the transform. This can be used\n * for CSS transforms.\n * @param {!Transform} mat Matrix.\n * @return {string} The transform as a string.\n */\nexport function toString(mat) {\n const transformString =\n 'matrix(' +\n mat\n .map(\n (value, i) =>\n Math.round(value * matrixPrecision[i]) / matrixPrecision[i],\n )\n .join(', ') +\n ')';\n return transformString;\n}\n","/**\n * @module ol/extent/Relationship\n */\n\n/**\n * Relationship to an extent.\n * @enum {number}\n */\nexport default {\n UNKNOWN: 0,\n INTERSECTING: 1,\n ABOVE: 2,\n RIGHT: 4,\n BELOW: 8,\n LEFT: 16,\n};\n","/**\n * @module ol/extent\n */\nimport Relationship from './extent/Relationship.js';\n\n/**\n * An array of numbers representing an extent: `[minx, miny, maxx, maxy]`.\n * @typedef {Array} Extent\n * @api\n */\n\n/**\n * Extent corner.\n * @typedef {'bottom-left' | 'bottom-right' | 'top-left' | 'top-right'} Corner\n */\n\n/**\n * Build an extent that includes all given coordinates.\n *\n * @param {Array} coordinates Coordinates.\n * @return {Extent} Bounding extent.\n * @api\n */\nexport function boundingExtent(coordinates) {\n const extent = createEmpty();\n for (let i = 0, ii = coordinates.length; i < ii; ++i) {\n extendCoordinate(extent, coordinates[i]);\n }\n return extent;\n}\n\n/**\n * @param {Array} xs Xs.\n * @param {Array} ys Ys.\n * @param {Extent} [dest] Destination extent.\n * @private\n * @return {Extent} Extent.\n */\nfunction _boundingExtentXYs(xs, ys, dest) {\n const minX = Math.min.apply(null, xs);\n const minY = Math.min.apply(null, ys);\n const maxX = Math.max.apply(null, xs);\n const maxY = Math.max.apply(null, ys);\n return createOrUpdate(minX, minY, maxX, maxY, dest);\n}\n\n/**\n * Return extent increased by the provided value.\n * @param {Extent} extent Extent.\n * @param {number} value The amount by which the extent should be buffered.\n * @param {Extent} [dest] Extent.\n * @return {Extent} Extent.\n * @api\n */\nexport function buffer(extent, value, dest) {\n if (dest) {\n dest[0] = extent[0] - value;\n dest[1] = extent[1] - value;\n dest[2] = extent[2] + value;\n dest[3] = extent[3] + value;\n return dest;\n }\n return [\n extent[0] - value,\n extent[1] - value,\n extent[2] + value,\n extent[3] + value,\n ];\n}\n\n/**\n * Creates a clone of an extent.\n *\n * @param {Extent} extent Extent to clone.\n * @param {Extent} [dest] Extent.\n * @return {Extent} The clone.\n */\nexport function clone(extent, dest) {\n if (dest) {\n dest[0] = extent[0];\n dest[1] = extent[1];\n dest[2] = extent[2];\n dest[3] = extent[3];\n return dest;\n }\n return extent.slice();\n}\n\n/**\n * @param {Extent} extent Extent.\n * @param {number} x X.\n * @param {number} y Y.\n * @return {number} Closest squared distance.\n */\nexport function closestSquaredDistanceXY(extent, x, y) {\n let dx, dy;\n if (x < extent[0]) {\n dx = extent[0] - x;\n } else if (extent[2] < x) {\n dx = x - extent[2];\n } else {\n dx = 0;\n }\n if (y < extent[1]) {\n dy = extent[1] - y;\n } else if (extent[3] < y) {\n dy = y - extent[3];\n } else {\n dy = 0;\n }\n return dx * dx + dy * dy;\n}\n\n/**\n * Check if the passed coordinate is contained or on the edge of the extent.\n *\n * @param {Extent} extent Extent.\n * @param {import(\"./coordinate.js\").Coordinate} coordinate Coordinate.\n * @return {boolean} The coordinate is contained in the extent.\n * @api\n */\nexport function containsCoordinate(extent, coordinate) {\n return containsXY(extent, coordinate[0], coordinate[1]);\n}\n\n/**\n * Check if one extent contains another.\n *\n * An extent is deemed contained if it lies completely within the other extent,\n * including if they share one or more edges.\n *\n * @param {Extent} extent1 Extent 1.\n * @param {Extent} extent2 Extent 2.\n * @return {boolean} The second extent is contained by or on the edge of the\n * first.\n * @api\n */\nexport function containsExtent(extent1, extent2) {\n return (\n extent1[0] <= extent2[0] &&\n extent2[2] <= extent1[2] &&\n extent1[1] <= extent2[1] &&\n extent2[3] <= extent1[3]\n );\n}\n\n/**\n * Check if the passed coordinate is contained or on the edge of the extent.\n *\n * @param {Extent} extent Extent.\n * @param {number} x X coordinate.\n * @param {number} y Y coordinate.\n * @return {boolean} The x, y values are contained in the extent.\n * @api\n */\nexport function containsXY(extent, x, y) {\n return extent[0] <= x && x <= extent[2] && extent[1] <= y && y <= extent[3];\n}\n\n/**\n * Get the relationship between a coordinate and extent.\n * @param {Extent} extent The extent.\n * @param {import(\"./coordinate.js\").Coordinate} coordinate The coordinate.\n * @return {import(\"./extent/Relationship.js\").default} The relationship (bitwise compare with\n * import(\"./extent/Relationship.js\").Relationship).\n */\nexport function coordinateRelationship(extent, coordinate) {\n const minX = extent[0];\n const minY = extent[1];\n const maxX = extent[2];\n const maxY = extent[3];\n const x = coordinate[0];\n const y = coordinate[1];\n let relationship = Relationship.UNKNOWN;\n if (x < minX) {\n relationship = relationship | Relationship.LEFT;\n } else if (x > maxX) {\n relationship = relationship | Relationship.RIGHT;\n }\n if (y < minY) {\n relationship = relationship | Relationship.BELOW;\n } else if (y > maxY) {\n relationship = relationship | Relationship.ABOVE;\n }\n if (relationship === Relationship.UNKNOWN) {\n relationship = Relationship.INTERSECTING;\n }\n return relationship;\n}\n\n/**\n * Create an empty extent.\n * @return {Extent} Empty extent.\n * @api\n */\nexport function createEmpty() {\n return [Infinity, Infinity, -Infinity, -Infinity];\n}\n\n/**\n * Create a new extent or update the provided extent.\n * @param {number} minX Minimum X.\n * @param {number} minY Minimum Y.\n * @param {number} maxX Maximum X.\n * @param {number} maxY Maximum Y.\n * @param {Extent} [dest] Destination extent.\n * @return {Extent} Extent.\n */\nexport function createOrUpdate(minX, minY, maxX, maxY, dest) {\n if (dest) {\n dest[0] = minX;\n dest[1] = minY;\n dest[2] = maxX;\n dest[3] = maxY;\n return dest;\n }\n return [minX, minY, maxX, maxY];\n}\n\n/**\n * Create a new empty extent or make the provided one empty.\n * @param {Extent} [dest] Extent.\n * @return {Extent} Extent.\n */\nexport function createOrUpdateEmpty(dest) {\n return createOrUpdate(Infinity, Infinity, -Infinity, -Infinity, dest);\n}\n\n/**\n * @param {import(\"./coordinate.js\").Coordinate} coordinate Coordinate.\n * @param {Extent} [dest] Extent.\n * @return {Extent} Extent.\n */\nexport function createOrUpdateFromCoordinate(coordinate, dest) {\n const x = coordinate[0];\n const y = coordinate[1];\n return createOrUpdate(x, y, x, y, dest);\n}\n\n/**\n * @param {Array} coordinates Coordinates.\n * @param {Extent} [dest] Extent.\n * @return {Extent} Extent.\n */\nexport function createOrUpdateFromCoordinates(coordinates, dest) {\n const extent = createOrUpdateEmpty(dest);\n return extendCoordinates(extent, coordinates);\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {number} end End.\n * @param {number} stride Stride.\n * @param {Extent} [dest] Extent.\n * @return {Extent} Extent.\n */\nexport function createOrUpdateFromFlatCoordinates(\n flatCoordinates,\n offset,\n end,\n stride,\n dest,\n) {\n const extent = createOrUpdateEmpty(dest);\n return extendFlatCoordinates(extent, flatCoordinates, offset, end, stride);\n}\n\n/**\n * @param {Array>} rings Rings.\n * @param {Extent} [dest] Extent.\n * @return {Extent} Extent.\n */\nexport function createOrUpdateFromRings(rings, dest) {\n const extent = createOrUpdateEmpty(dest);\n return extendRings(extent, rings);\n}\n\n/**\n * Determine if two extents are equivalent.\n * @param {Extent} extent1 Extent 1.\n * @param {Extent} extent2 Extent 2.\n * @return {boolean} The two extents are equivalent.\n * @api\n */\nexport function equals(extent1, extent2) {\n return (\n extent1[0] == extent2[0] &&\n extent1[2] == extent2[2] &&\n extent1[1] == extent2[1] &&\n extent1[3] == extent2[3]\n );\n}\n\n/**\n * Determine if two extents are approximately equivalent.\n * @param {Extent} extent1 Extent 1.\n * @param {Extent} extent2 Extent 2.\n * @param {number} tolerance Tolerance in extent coordinate units.\n * @return {boolean} The two extents differ by less than the tolerance.\n */\nexport function approximatelyEquals(extent1, extent2, tolerance) {\n return (\n Math.abs(extent1[0] - extent2[0]) < tolerance &&\n Math.abs(extent1[2] - extent2[2]) < tolerance &&\n Math.abs(extent1[1] - extent2[1]) < tolerance &&\n Math.abs(extent1[3] - extent2[3]) < tolerance\n );\n}\n\n/**\n * Modify an extent to include another extent.\n * @param {Extent} extent1 The extent to be modified.\n * @param {Extent} extent2 The extent that will be included in the first.\n * @return {Extent} A reference to the first (extended) extent.\n * @api\n */\nexport function extend(extent1, extent2) {\n if (extent2[0] < extent1[0]) {\n extent1[0] = extent2[0];\n }\n if (extent2[2] > extent1[2]) {\n extent1[2] = extent2[2];\n }\n if (extent2[1] < extent1[1]) {\n extent1[1] = extent2[1];\n }\n if (extent2[3] > extent1[3]) {\n extent1[3] = extent2[3];\n }\n return extent1;\n}\n\n/**\n * @param {Extent} extent Extent.\n * @param {import(\"./coordinate.js\").Coordinate} coordinate Coordinate.\n */\nexport function extendCoordinate(extent, coordinate) {\n if (coordinate[0] < extent[0]) {\n extent[0] = coordinate[0];\n }\n if (coordinate[0] > extent[2]) {\n extent[2] = coordinate[0];\n }\n if (coordinate[1] < extent[1]) {\n extent[1] = coordinate[1];\n }\n if (coordinate[1] > extent[3]) {\n extent[3] = coordinate[1];\n }\n}\n\n/**\n * @param {Extent} extent Extent.\n * @param {Array} coordinates Coordinates.\n * @return {Extent} Extent.\n */\nexport function extendCoordinates(extent, coordinates) {\n for (let i = 0, ii = coordinates.length; i < ii; ++i) {\n extendCoordinate(extent, coordinates[i]);\n }\n return extent;\n}\n\n/**\n * @param {Extent} extent Extent.\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {number} end End.\n * @param {number} stride Stride.\n * @return {Extent} Extent.\n */\nexport function extendFlatCoordinates(\n extent,\n flatCoordinates,\n offset,\n end,\n stride,\n) {\n for (; offset < end; offset += stride) {\n extendXY(extent, flatCoordinates[offset], flatCoordinates[offset + 1]);\n }\n return extent;\n}\n\n/**\n * @param {Extent} extent Extent.\n * @param {Array>} rings Rings.\n * @return {Extent} Extent.\n */\nexport function extendRings(extent, rings) {\n for (let i = 0, ii = rings.length; i < ii; ++i) {\n extendCoordinates(extent, rings[i]);\n }\n return extent;\n}\n\n/**\n * @param {Extent} extent Extent.\n * @param {number} x X.\n * @param {number} y Y.\n */\nexport function extendXY(extent, x, y) {\n extent[0] = Math.min(extent[0], x);\n extent[1] = Math.min(extent[1], y);\n extent[2] = Math.max(extent[2], x);\n extent[3] = Math.max(extent[3], y);\n}\n\n/**\n * This function calls `callback` for each corner of the extent. If the\n * callback returns a truthy value the function returns that value\n * immediately. Otherwise the function returns `false`.\n * @param {Extent} extent Extent.\n * @param {function(import(\"./coordinate.js\").Coordinate): S} callback Callback.\n * @return {S|boolean} Value.\n * @template S\n */\nexport function forEachCorner(extent, callback) {\n let val;\n val = callback(getBottomLeft(extent));\n if (val) {\n return val;\n }\n val = callback(getBottomRight(extent));\n if (val) {\n return val;\n }\n val = callback(getTopRight(extent));\n if (val) {\n return val;\n }\n val = callback(getTopLeft(extent));\n if (val) {\n return val;\n }\n return false;\n}\n\n/**\n * Get the size of an extent.\n * @param {Extent} extent Extent.\n * @return {number} Area.\n * @api\n */\nexport function getArea(extent) {\n let area = 0;\n if (!isEmpty(extent)) {\n area = getWidth(extent) * getHeight(extent);\n }\n return area;\n}\n\n/**\n * Get the bottom left coordinate of an extent.\n * @param {Extent} extent Extent.\n * @return {import(\"./coordinate.js\").Coordinate} Bottom left coordinate.\n * @api\n */\nexport function getBottomLeft(extent) {\n return [extent[0], extent[1]];\n}\n\n/**\n * Get the bottom right coordinate of an extent.\n * @param {Extent} extent Extent.\n * @return {import(\"./coordinate.js\").Coordinate} Bottom right coordinate.\n * @api\n */\nexport function getBottomRight(extent) {\n return [extent[2], extent[1]];\n}\n\n/**\n * Get the center coordinate of an extent.\n * @param {Extent} extent Extent.\n * @return {import(\"./coordinate.js\").Coordinate} Center.\n * @api\n */\nexport function getCenter(extent) {\n return [(extent[0] + extent[2]) / 2, (extent[1] + extent[3]) / 2];\n}\n\n/**\n * Get a corner coordinate of an extent.\n * @param {Extent} extent Extent.\n * @param {Corner} corner Corner.\n * @return {import(\"./coordinate.js\").Coordinate} Corner coordinate.\n */\nexport function getCorner(extent, corner) {\n let coordinate;\n if (corner === 'bottom-left') {\n coordinate = getBottomLeft(extent);\n } else if (corner === 'bottom-right') {\n coordinate = getBottomRight(extent);\n } else if (corner === 'top-left') {\n coordinate = getTopLeft(extent);\n } else if (corner === 'top-right') {\n coordinate = getTopRight(extent);\n } else {\n throw new Error('Invalid corner');\n }\n return coordinate;\n}\n\n/**\n * @param {Extent} extent1 Extent 1.\n * @param {Extent} extent2 Extent 2.\n * @return {number} Enlarged area.\n */\nexport function getEnlargedArea(extent1, extent2) {\n const minX = Math.min(extent1[0], extent2[0]);\n const minY = Math.min(extent1[1], extent2[1]);\n const maxX = Math.max(extent1[2], extent2[2]);\n const maxY = Math.max(extent1[3], extent2[3]);\n return (maxX - minX) * (maxY - minY);\n}\n\n/**\n * @param {import(\"./coordinate.js\").Coordinate} center Center.\n * @param {number} resolution Resolution.\n * @param {number} rotation Rotation.\n * @param {import(\"./size.js\").Size} size Size.\n * @param {Extent} [dest] Destination extent.\n * @return {Extent} Extent.\n */\nexport function getForViewAndSize(center, resolution, rotation, size, dest) {\n const [x0, y0, x1, y1, x2, y2, x3, y3] = getRotatedViewport(\n center,\n resolution,\n rotation,\n size,\n );\n return createOrUpdate(\n Math.min(x0, x1, x2, x3),\n Math.min(y0, y1, y2, y3),\n Math.max(x0, x1, x2, x3),\n Math.max(y0, y1, y2, y3),\n dest,\n );\n}\n\n/**\n * @param {import(\"./coordinate.js\").Coordinate} center Center.\n * @param {number} resolution Resolution.\n * @param {number} rotation Rotation.\n * @param {import(\"./size.js\").Size} size Size.\n * @return {Array} Linear ring representing the viewport.\n */\nexport function getRotatedViewport(center, resolution, rotation, size) {\n const dx = (resolution * size[0]) / 2;\n const dy = (resolution * size[1]) / 2;\n const cosRotation = Math.cos(rotation);\n const sinRotation = Math.sin(rotation);\n const xCos = dx * cosRotation;\n const xSin = dx * sinRotation;\n const yCos = dy * cosRotation;\n const ySin = dy * sinRotation;\n const x = center[0];\n const y = center[1];\n return [\n x - xCos + ySin,\n y - xSin - yCos,\n x - xCos - ySin,\n y - xSin + yCos,\n x + xCos - ySin,\n y + xSin + yCos,\n x + xCos + ySin,\n y + xSin - yCos,\n x - xCos + ySin,\n y - xSin - yCos,\n ];\n}\n\n/**\n * Get the height of an extent.\n * @param {Extent} extent Extent.\n * @return {number} Height.\n * @api\n */\nexport function getHeight(extent) {\n return extent[3] - extent[1];\n}\n\n/**\n * @param {Extent} extent1 Extent 1.\n * @param {Extent} extent2 Extent 2.\n * @return {number} Intersection area.\n */\nexport function getIntersectionArea(extent1, extent2) {\n const intersection = getIntersection(extent1, extent2);\n return getArea(intersection);\n}\n\n/**\n * Get the intersection of two extents.\n * @param {Extent} extent1 Extent 1.\n * @param {Extent} extent2 Extent 2.\n * @param {Extent} [dest] Optional extent to populate with intersection.\n * @return {Extent} Intersecting extent.\n * @api\n */\nexport function getIntersection(extent1, extent2, dest) {\n const intersection = dest ? dest : createEmpty();\n if (intersects(extent1, extent2)) {\n if (extent1[0] > extent2[0]) {\n intersection[0] = extent1[0];\n } else {\n intersection[0] = extent2[0];\n }\n if (extent1[1] > extent2[1]) {\n intersection[1] = extent1[1];\n } else {\n intersection[1] = extent2[1];\n }\n if (extent1[2] < extent2[2]) {\n intersection[2] = extent1[2];\n } else {\n intersection[2] = extent2[2];\n }\n if (extent1[3] < extent2[3]) {\n intersection[3] = extent1[3];\n } else {\n intersection[3] = extent2[3];\n }\n } else {\n createOrUpdateEmpty(intersection);\n }\n return intersection;\n}\n\n/**\n * @param {Extent} extent Extent.\n * @return {number} Margin.\n */\nexport function getMargin(extent) {\n return getWidth(extent) + getHeight(extent);\n}\n\n/**\n * Get the size (width, height) of an extent.\n * @param {Extent} extent The extent.\n * @return {import(\"./size.js\").Size} The extent size.\n * @api\n */\nexport function getSize(extent) {\n return [extent[2] - extent[0], extent[3] - extent[1]];\n}\n\n/**\n * Get the top left coordinate of an extent.\n * @param {Extent} extent Extent.\n * @return {import(\"./coordinate.js\").Coordinate} Top left coordinate.\n * @api\n */\nexport function getTopLeft(extent) {\n return [extent[0], extent[3]];\n}\n\n/**\n * Get the top right coordinate of an extent.\n * @param {Extent} extent Extent.\n * @return {import(\"./coordinate.js\").Coordinate} Top right coordinate.\n * @api\n */\nexport function getTopRight(extent) {\n return [extent[2], extent[3]];\n}\n\n/**\n * Get the width of an extent.\n * @param {Extent} extent Extent.\n * @return {number} Width.\n * @api\n */\nexport function getWidth(extent) {\n return extent[2] - extent[0];\n}\n\n/**\n * Determine if one extent intersects another.\n * @param {Extent} extent1 Extent 1.\n * @param {Extent} extent2 Extent.\n * @return {boolean} The two extents intersect.\n * @api\n */\nexport function intersects(extent1, extent2) {\n return (\n extent1[0] <= extent2[2] &&\n extent1[2] >= extent2[0] &&\n extent1[1] <= extent2[3] &&\n extent1[3] >= extent2[1]\n );\n}\n\n/**\n * Determine if an extent is empty.\n * @param {Extent} extent Extent.\n * @return {boolean} Is empty.\n * @api\n */\nexport function isEmpty(extent) {\n return extent[2] < extent[0] || extent[3] < extent[1];\n}\n\n/**\n * @param {Extent} extent Extent.\n * @param {Extent} [dest] Extent.\n * @return {Extent} Extent.\n */\nexport function returnOrUpdate(extent, dest) {\n if (dest) {\n dest[0] = extent[0];\n dest[1] = extent[1];\n dest[2] = extent[2];\n dest[3] = extent[3];\n return dest;\n }\n return extent;\n}\n\n/**\n * @param {Extent} extent Extent.\n * @param {number} value Value.\n */\nexport function scaleFromCenter(extent, value) {\n const deltaX = ((extent[2] - extent[0]) / 2) * (value - 1);\n const deltaY = ((extent[3] - extent[1]) / 2) * (value - 1);\n extent[0] -= deltaX;\n extent[2] += deltaX;\n extent[1] -= deltaY;\n extent[3] += deltaY;\n}\n\n/**\n * Determine if the segment between two coordinates intersects (crosses,\n * touches, or is contained by) the provided extent.\n * @param {Extent} extent The extent.\n * @param {import(\"./coordinate.js\").Coordinate} start Segment start coordinate.\n * @param {import(\"./coordinate.js\").Coordinate} end Segment end coordinate.\n * @return {boolean} The segment intersects the extent.\n */\nexport function intersectsSegment(extent, start, end) {\n let intersects = false;\n const startRel = coordinateRelationship(extent, start);\n const endRel = coordinateRelationship(extent, end);\n if (\n startRel === Relationship.INTERSECTING ||\n endRel === Relationship.INTERSECTING\n ) {\n intersects = true;\n } else {\n const minX = extent[0];\n const minY = extent[1];\n const maxX = extent[2];\n const maxY = extent[3];\n const startX = start[0];\n const startY = start[1];\n const endX = end[0];\n const endY = end[1];\n const slope = (endY - startY) / (endX - startX);\n let x, y;\n if (!!(endRel & Relationship.ABOVE) && !(startRel & Relationship.ABOVE)) {\n // potentially intersects top\n x = endX - (endY - maxY) / slope;\n intersects = x >= minX && x <= maxX;\n }\n if (\n !intersects &&\n !!(endRel & Relationship.RIGHT) &&\n !(startRel & Relationship.RIGHT)\n ) {\n // potentially intersects right\n y = endY - (endX - maxX) * slope;\n intersects = y >= minY && y <= maxY;\n }\n if (\n !intersects &&\n !!(endRel & Relationship.BELOW) &&\n !(startRel & Relationship.BELOW)\n ) {\n // potentially intersects bottom\n x = endX - (endY - minY) / slope;\n intersects = x >= minX && x <= maxX;\n }\n if (\n !intersects &&\n !!(endRel & Relationship.LEFT) &&\n !(startRel & Relationship.LEFT)\n ) {\n // potentially intersects left\n y = endY - (endX - minX) * slope;\n intersects = y >= minY && y <= maxY;\n }\n }\n return intersects;\n}\n\n/**\n * Apply a transform function to the extent.\n * @param {Extent} extent Extent.\n * @param {import(\"./proj.js\").TransformFunction} transformFn Transform function.\n * Called with `[minX, minY, maxX, maxY]` extent coordinates.\n * @param {Extent} [dest] Destination extent.\n * @param {number} [stops] Number of stops per side used for the transform.\n * By default only the corners are used.\n * @return {Extent} Extent.\n * @api\n */\nexport function applyTransform(extent, transformFn, dest, stops) {\n if (isEmpty(extent)) {\n return createOrUpdateEmpty(dest);\n }\n let coordinates = [];\n if (stops > 1) {\n const width = extent[2] - extent[0];\n const height = extent[3] - extent[1];\n for (let i = 0; i < stops; ++i) {\n coordinates.push(\n extent[0] + (width * i) / stops,\n extent[1],\n extent[2],\n extent[1] + (height * i) / stops,\n extent[2] - (width * i) / stops,\n extent[3],\n extent[0],\n extent[3] - (height * i) / stops,\n );\n }\n } else {\n coordinates = [\n extent[0],\n extent[1],\n extent[2],\n extent[1],\n extent[2],\n extent[3],\n extent[0],\n extent[3],\n ];\n }\n transformFn(coordinates, coordinates, 2);\n const xs = [];\n const ys = [];\n for (let i = 0, l = coordinates.length; i < l; i += 2) {\n xs.push(coordinates[i]);\n ys.push(coordinates[i + 1]);\n }\n return _boundingExtentXYs(xs, ys, dest);\n}\n\n/**\n * Modifies the provided extent in-place to be within the real world\n * extent.\n *\n * @param {Extent} extent Extent.\n * @param {import(\"./proj/Projection.js\").default} projection Projection\n * @return {Extent} The extent within the real world extent.\n */\nexport function wrapX(extent, projection) {\n const projectionExtent = projection.getExtent();\n const center = getCenter(extent);\n if (\n projection.canWrapX() &&\n (center[0] < projectionExtent[0] || center[0] >= projectionExtent[2])\n ) {\n const worldWidth = getWidth(projectionExtent);\n const worldsAway = Math.floor(\n (center[0] - projectionExtent[0]) / worldWidth,\n );\n const offset = worldsAway * worldWidth;\n extent[0] -= offset;\n extent[2] -= offset;\n }\n return extent;\n}\n\n/**\n * Fits the extent to the real world\n *\n * If the extent does not cross the anti meridian, this will return the extent in an array\n * If the extent crosses the anti meridian, the extent will be sliced, so each part fits within the\n * real world\n *\n *\n * @param {Extent} extent Extent.\n * @param {import(\"./proj/Projection.js\").default} projection Projection\n * @param {boolean} [multiWorld] Return all worlds\n * @return {Array} The extent within the real world extent.\n */\nexport function wrapAndSliceX(extent, projection, multiWorld) {\n if (projection.canWrapX()) {\n const projectionExtent = projection.getExtent();\n\n if (!isFinite(extent[0]) || !isFinite(extent[2])) {\n return [[projectionExtent[0], extent[1], projectionExtent[2], extent[3]]];\n }\n\n wrapX(extent, projection);\n const worldWidth = getWidth(projectionExtent);\n\n if (getWidth(extent) > worldWidth && !multiWorld) {\n // the extent wraps around on itself\n return [[projectionExtent[0], extent[1], projectionExtent[2], extent[3]]];\n }\n if (extent[0] < projectionExtent[0]) {\n // the extent crosses the anti meridian, so it needs to be sliced\n return [\n [extent[0] + worldWidth, extent[1], projectionExtent[2], extent[3]],\n [projectionExtent[0], extent[1], extent[2], extent[3]],\n ];\n }\n if (extent[2] > projectionExtent[2]) {\n // the extent crosses the anti meridian, so it needs to be sliced\n return [\n [extent[0], extent[1], projectionExtent[2], extent[3]],\n [projectionExtent[0], extent[1], extent[2] - worldWidth, extent[3]],\n ];\n }\n }\n\n return [extent];\n}\n","/**\n * @module ol/proj/Units\n */\n\n/**\n * @typedef {'radians' | 'degrees' | 'ft' | 'm' | 'pixels' | 'tile-pixels' | 'us-ft'} Units\n * Projection units.\n */\n\n/**\n * See http://duff.ess.washington.edu/data/raster/drg/docs/geotiff.txt\n * @type {Object}\n */\nconst unitByCode = {\n '9001': 'm',\n '9002': 'ft',\n '9003': 'us-ft',\n '9101': 'radians',\n '9102': 'degrees',\n};\n\n/**\n * @param {number} code Unit code.\n * @return {Units} Units.\n */\nexport function fromCode(code) {\n return unitByCode[code];\n}\n\n/**\n * @typedef {Object} MetersPerUnitLookup\n * @property {number} radians Radians\n * @property {number} degrees Degrees\n * @property {number} ft Feet\n * @property {number} m Meters\n * @property {number} us-ft US feet\n */\n\n/**\n * Meters per unit lookup table.\n * @const\n * @type {MetersPerUnitLookup}\n * @api\n */\nexport const METERS_PER_UNIT = {\n // use the radius of the Normal sphere\n 'radians': 6370997 / (2 * Math.PI),\n 'degrees': (2 * Math.PI * 6370997) / 360,\n 'ft': 0.3048,\n 'm': 1,\n 'us-ft': 1200 / 3937,\n};\n","/**\n * @module ol/proj/Projection\n */\nimport {METERS_PER_UNIT} from './Units.js';\n\n/**\n * @typedef {Object} Options\n * @property {string} code The SRS identifier code, e.g. `EPSG:4326`.\n * @property {import(\"./Units.js\").Units} [units] Units. Required unless a\n * proj4 projection is defined for `code`.\n * @property {import(\"../extent.js\").Extent} [extent] The validity extent for the SRS.\n * @property {string} [axisOrientation='enu'] The axis orientation as specified in Proj4.\n * @property {boolean} [global=false] Whether the projection is valid for the whole globe.\n * @property {number} [metersPerUnit] The meters per unit for the SRS.\n * If not provided, the `units` are used to get the meters per unit from the {@link METERS_PER_UNIT}\n * lookup table.\n * @property {import(\"../extent.js\").Extent} [worldExtent] The world extent for the SRS.\n * @property {function(number, import(\"../coordinate.js\").Coordinate):number} [getPointResolution]\n * Function to determine resolution at a point. The function is called with a\n * `number` view resolution and a {@link module:ol/coordinate~Coordinate} as arguments, and returns\n * the `number` resolution in projection units at the passed coordinate. If this is `undefined`,\n * the default {@link module:ol/proj.getPointResolution} function will be used.\n */\n\n/**\n * @classdesc\n * Projection definition class. One of these is created for each projection\n * supported in the application and stored in the {@link module:ol/proj} namespace.\n * You can use these in applications, but this is not required, as API params\n * and options use {@link module:ol/proj~ProjectionLike} which means the simple string\n * code will suffice.\n *\n * You can use {@link module:ol/proj.get} to retrieve the object for a particular\n * projection.\n *\n * The library includes definitions for `EPSG:4326` and `EPSG:3857`, together\n * with the following aliases:\n * * `EPSG:4326`: CRS:84, urn:ogc:def:crs:EPSG:6.6:4326,\n * urn:ogc:def:crs:OGC:1.3:CRS84, urn:ogc:def:crs:OGC:2:84,\n * http://www.opengis.net/gml/srs/epsg.xml#4326,\n * urn:x-ogc:def:crs:EPSG:4326\n * * `EPSG:3857`: EPSG:102100, EPSG:102113, EPSG:900913,\n * urn:ogc:def:crs:EPSG:6.18:3:3857,\n * http://www.opengis.net/gml/srs/epsg.xml#3857\n *\n * If you use [proj4js](https://github.com/proj4js/proj4js), aliases can\n * be added using `proj4.defs()`. After all required projection definitions are\n * added, call the {@link module:ol/proj/proj4.register} function.\n *\n * @api\n */\nclass Projection {\n /**\n * @param {Options} options Projection options.\n */\n constructor(options) {\n /**\n * @private\n * @type {string}\n */\n this.code_ = options.code;\n\n /**\n * Units of projected coordinates. When set to `TILE_PIXELS`, a\n * `this.extent_` and `this.worldExtent_` must be configured properly for each\n * tile.\n * @private\n * @type {import(\"./Units.js\").Units}\n */\n this.units_ = /** @type {import(\"./Units.js\").Units} */ (options.units);\n\n /**\n * Validity extent of the projection in projected coordinates. For projections\n * with `TILE_PIXELS` units, this is the extent of the tile in\n * tile pixel space.\n * @private\n * @type {import(\"../extent.js\").Extent}\n */\n this.extent_ = options.extent !== undefined ? options.extent : null;\n\n /**\n * Extent of the world in EPSG:4326. For projections with\n * `TILE_PIXELS` units, this is the extent of the tile in\n * projected coordinate space.\n * @private\n * @type {import(\"../extent.js\").Extent}\n */\n this.worldExtent_ =\n options.worldExtent !== undefined ? options.worldExtent : null;\n\n /**\n * @private\n * @type {string}\n */\n this.axisOrientation_ =\n options.axisOrientation !== undefined ? options.axisOrientation : 'enu';\n\n /**\n * @private\n * @type {boolean}\n */\n this.global_ = options.global !== undefined ? options.global : false;\n\n /**\n * @private\n * @type {boolean}\n */\n this.canWrapX_ = !!(this.global_ && this.extent_);\n\n /**\n * @private\n * @type {function(number, import(\"../coordinate.js\").Coordinate):number|undefined}\n */\n this.getPointResolutionFunc_ = options.getPointResolution;\n\n /**\n * @private\n * @type {import(\"../tilegrid/TileGrid.js\").default}\n */\n this.defaultTileGrid_ = null;\n\n /**\n * @private\n * @type {number|undefined}\n */\n this.metersPerUnit_ = options.metersPerUnit;\n }\n\n /**\n * @return {boolean} The projection is suitable for wrapping the x-axis\n */\n canWrapX() {\n return this.canWrapX_;\n }\n\n /**\n * Get the code for this projection, e.g. 'EPSG:4326'.\n * @return {string} Code.\n * @api\n */\n getCode() {\n return this.code_;\n }\n\n /**\n * Get the validity extent for this projection.\n * @return {import(\"../extent.js\").Extent} Extent.\n * @api\n */\n getExtent() {\n return this.extent_;\n }\n\n /**\n * Get the units of this projection.\n * @return {import(\"./Units.js\").Units} Units.\n * @api\n */\n getUnits() {\n return this.units_;\n }\n\n /**\n * Get the amount of meters per unit of this projection. If the projection is\n * not configured with `metersPerUnit` or a units identifier, the return is\n * `undefined`.\n * @return {number|undefined} Meters.\n * @api\n */\n getMetersPerUnit() {\n return this.metersPerUnit_ || METERS_PER_UNIT[this.units_];\n }\n\n /**\n * Get the world extent for this projection.\n * @return {import(\"../extent.js\").Extent} Extent.\n * @api\n */\n getWorldExtent() {\n return this.worldExtent_;\n }\n\n /**\n * Get the axis orientation of this projection.\n * Example values are:\n * enu - the default easting, northing, elevation.\n * neu - northing, easting, up - useful for \"lat/long\" geographic coordinates,\n * or south orientated transverse mercator.\n * wnu - westing, northing, up - some planetary coordinate systems have\n * \"west positive\" coordinate systems\n * @return {string} Axis orientation.\n * @api\n */\n getAxisOrientation() {\n return this.axisOrientation_;\n }\n\n /**\n * Is this projection a global projection which spans the whole world?\n * @return {boolean} Whether the projection is global.\n * @api\n */\n isGlobal() {\n return this.global_;\n }\n\n /**\n * Set if the projection is a global projection which spans the whole world\n * @param {boolean} global Whether the projection is global.\n * @api\n */\n setGlobal(global) {\n this.global_ = global;\n this.canWrapX_ = !!(global && this.extent_);\n }\n\n /**\n * @return {import(\"../tilegrid/TileGrid.js\").default} The default tile grid.\n */\n getDefaultTileGrid() {\n return this.defaultTileGrid_;\n }\n\n /**\n * @param {import(\"../tilegrid/TileGrid.js\").default} tileGrid The default tile grid.\n */\n setDefaultTileGrid(tileGrid) {\n this.defaultTileGrid_ = tileGrid;\n }\n\n /**\n * Set the validity extent for this projection.\n * @param {import(\"../extent.js\").Extent} extent Extent.\n * @api\n */\n setExtent(extent) {\n this.extent_ = extent;\n this.canWrapX_ = !!(this.global_ && extent);\n }\n\n /**\n * Set the world extent for this projection.\n * @param {import(\"../extent.js\").Extent} worldExtent World extent\n * [minlon, minlat, maxlon, maxlat].\n * @api\n */\n setWorldExtent(worldExtent) {\n this.worldExtent_ = worldExtent;\n }\n\n /**\n * Set the getPointResolution function (see {@link module:ol/proj.getPointResolution}\n * for this projection.\n * @param {function(number, import(\"../coordinate.js\").Coordinate):number} func Function\n * @api\n */\n setGetPointResolution(func) {\n this.getPointResolutionFunc_ = func;\n }\n\n /**\n * Get the custom point resolution function for this projection (if set).\n * @return {function(number, import(\"../coordinate.js\").Coordinate):number|undefined} The custom point\n * resolution function (if set).\n */\n getPointResolutionFunc() {\n return this.getPointResolutionFunc_;\n }\n}\n\nexport default Projection;\n","/**\n * @module ol/proj/epsg3857\n */\nimport Projection from './Projection.js';\n\n/**\n * Radius of WGS84 sphere\n *\n * @const\n * @type {number}\n */\nexport const RADIUS = 6378137;\n\n/**\n * @const\n * @type {number}\n */\nexport const HALF_SIZE = Math.PI * RADIUS;\n\n/**\n * @const\n * @type {import(\"../extent.js\").Extent}\n */\nexport const EXTENT = [-HALF_SIZE, -HALF_SIZE, HALF_SIZE, HALF_SIZE];\n\n/**\n * @const\n * @type {import(\"../extent.js\").Extent}\n */\nexport const WORLD_EXTENT = [-180, -85, 180, 85];\n\n/**\n * Maximum safe value in y direction\n * @const\n * @type {number}\n */\nexport const MAX_SAFE_Y = RADIUS * Math.log(Math.tan(Math.PI / 2));\n\n/**\n * @classdesc\n * Projection object for web/spherical Mercator (EPSG:3857).\n */\nclass EPSG3857Projection extends Projection {\n /**\n * @param {string} code Code.\n */\n constructor(code) {\n super({\n code: code,\n units: 'm',\n extent: EXTENT,\n global: true,\n worldExtent: WORLD_EXTENT,\n getPointResolution: function (resolution, point) {\n return resolution / Math.cosh(point[1] / RADIUS);\n },\n });\n }\n}\n\n/**\n * Projections equal to EPSG:3857.\n *\n * @const\n * @type {Array}\n */\nexport const PROJECTIONS = [\n new EPSG3857Projection('EPSG:3857'),\n new EPSG3857Projection('EPSG:102100'),\n new EPSG3857Projection('EPSG:102113'),\n new EPSG3857Projection('EPSG:900913'),\n new EPSG3857Projection('http://www.opengis.net/def/crs/EPSG/0/3857'),\n new EPSG3857Projection('http://www.opengis.net/gml/srs/epsg.xml#3857'),\n];\n\n/**\n * Transformation from EPSG:4326 to EPSG:3857.\n *\n * @param {Array} input Input array of coordinate values.\n * @param {Array} [output] Output array of coordinate values.\n * @param {number} [dimension] Dimension (default is `2`).\n * @return {Array} Output array of coordinate values.\n */\nexport function fromEPSG4326(input, output, dimension) {\n const length = input.length;\n dimension = dimension > 1 ? dimension : 2;\n if (output === undefined) {\n if (dimension > 2) {\n // preserve values beyond second dimension\n output = input.slice();\n } else {\n output = new Array(length);\n }\n }\n for (let i = 0; i < length; i += dimension) {\n output[i] = (HALF_SIZE * input[i]) / 180;\n let y = RADIUS * Math.log(Math.tan((Math.PI * (+input[i + 1] + 90)) / 360));\n if (y > MAX_SAFE_Y) {\n y = MAX_SAFE_Y;\n } else if (y < -MAX_SAFE_Y) {\n y = -MAX_SAFE_Y;\n }\n output[i + 1] = y;\n }\n return output;\n}\n\n/**\n * Transformation from EPSG:3857 to EPSG:4326.\n *\n * @param {Array} input Input array of coordinate values.\n * @param {Array} [output] Output array of coordinate values.\n * @param {number} [dimension] Dimension (default is `2`).\n * @return {Array} Output array of coordinate values.\n */\nexport function toEPSG4326(input, output, dimension) {\n const length = input.length;\n dimension = dimension > 1 ? dimension : 2;\n if (output === undefined) {\n if (dimension > 2) {\n // preserve values beyond second dimension\n output = input.slice();\n } else {\n output = new Array(length);\n }\n }\n for (let i = 0; i < length; i += dimension) {\n output[i] = (180 * input[i]) / HALF_SIZE;\n output[i + 1] =\n (360 * Math.atan(Math.exp(input[i + 1] / RADIUS))) / Math.PI - 90;\n }\n return output;\n}\n","/**\n * @module ol/proj/epsg4326\n */\nimport Projection from './Projection.js';\n\n/**\n * Semi-major radius of the WGS84 ellipsoid.\n *\n * @const\n * @type {number}\n */\nexport const RADIUS = 6378137;\n\n/**\n * Extent of the EPSG:4326 projection which is the whole world.\n *\n * @const\n * @type {import(\"../extent.js\").Extent}\n */\nexport const EXTENT = [-180, -90, 180, 90];\n\n/**\n * @const\n * @type {number}\n */\nexport const METERS_PER_UNIT = (Math.PI * RADIUS) / 180;\n\n/**\n * @classdesc\n * Projection object for WGS84 geographic coordinates (EPSG:4326).\n *\n * Note that OpenLayers does not strictly comply with the EPSG definition.\n * The EPSG registry defines 4326 as a CRS for Latitude,Longitude (y,x).\n * OpenLayers treats EPSG:4326 as a pseudo-projection, with x,y coordinates.\n */\nclass EPSG4326Projection extends Projection {\n /**\n * @param {string} code Code.\n * @param {string} [axisOrientation] Axis orientation.\n */\n constructor(code, axisOrientation) {\n super({\n code: code,\n units: 'degrees',\n extent: EXTENT,\n axisOrientation: axisOrientation,\n global: true,\n metersPerUnit: METERS_PER_UNIT,\n worldExtent: EXTENT,\n });\n }\n}\n\n/**\n * Projections equal to EPSG:4326.\n *\n * @const\n * @type {Array}\n */\nexport const PROJECTIONS = [\n new EPSG4326Projection('CRS:84'),\n new EPSG4326Projection('EPSG:4326', 'neu'),\n new EPSG4326Projection('urn:ogc:def:crs:OGC:1.3:CRS84'),\n new EPSG4326Projection('urn:ogc:def:crs:OGC:2:84'),\n new EPSG4326Projection('http://www.opengis.net/def/crs/OGC/1.3/CRS84'),\n new EPSG4326Projection('http://www.opengis.net/gml/srs/epsg.xml#4326', 'neu'),\n new EPSG4326Projection('http://www.opengis.net/def/crs/EPSG/0/4326', 'neu'),\n];\n","/**\n * @module ol/proj/projections\n */\n\n/**\n * @type {Object}\n */\nlet cache = {};\n\n/**\n * Clear the projections cache.\n */\nexport function clear() {\n cache = {};\n}\n\n/**\n * Get a cached projection by code.\n * @param {string} code The code for the projection.\n * @return {import(\"./Projection.js\").default} The projection (if cached).\n */\nexport function get(code) {\n return (\n cache[code] ||\n cache[code.replace(/urn:(x-)?ogc:def:crs:EPSG:(.*:)?(\\w+)$/, 'EPSG:$3')] ||\n null\n );\n}\n\n/**\n * Add a projection to the cache.\n * @param {string} code The projection code.\n * @param {import(\"./Projection.js\").default} projection The projection to cache.\n */\nexport function add(code, projection) {\n cache[code] = projection;\n}\n","/**\n * @module ol/proj/transforms\n */\nimport {isEmpty} from '../obj.js';\n\n/**\n * @private\n * @type {!Object>}\n */\nlet transforms = {};\n\n/**\n * Clear the transform cache.\n */\nexport function clear() {\n transforms = {};\n}\n\n/**\n * Registers a conversion function to convert coordinates from the source\n * projection to the destination projection.\n *\n * @param {import(\"./Projection.js\").default} source Source.\n * @param {import(\"./Projection.js\").default} destination Destination.\n * @param {import(\"../proj.js\").TransformFunction} transformFn Transform.\n */\nexport function add(source, destination, transformFn) {\n const sourceCode = source.getCode();\n const destinationCode = destination.getCode();\n if (!(sourceCode in transforms)) {\n transforms[sourceCode] = {};\n }\n transforms[sourceCode][destinationCode] = transformFn;\n}\n\n/**\n * Unregisters the conversion function to convert coordinates from the source\n * projection to the destination projection. This method is used to clean up\n * cached transforms during testing.\n *\n * @param {import(\"./Projection.js\").default} source Source projection.\n * @param {import(\"./Projection.js\").default} destination Destination projection.\n * @return {import(\"../proj.js\").TransformFunction} transformFn The unregistered transform.\n */\nexport function remove(source, destination) {\n const sourceCode = source.getCode();\n const destinationCode = destination.getCode();\n const transform = transforms[sourceCode][destinationCode];\n delete transforms[sourceCode][destinationCode];\n if (isEmpty(transforms[sourceCode])) {\n delete transforms[sourceCode];\n }\n return transform;\n}\n\n/**\n * Get a transform given a source code and a destination code.\n * @param {string} sourceCode The code for the source projection.\n * @param {string} destinationCode The code for the destination projection.\n * @return {import(\"../proj.js\").TransformFunction|undefined} The transform function (if found).\n */\nexport function get(sourceCode, destinationCode) {\n let transform;\n if (sourceCode in transforms && destinationCode in transforms[sourceCode]) {\n transform = transforms[sourceCode][destinationCode];\n }\n return transform;\n}\n","/**\n * @module ol/math\n */\n\n/**\n * Takes a number and clamps it to within the provided bounds.\n * @param {number} value The input number.\n * @param {number} min The minimum value to return.\n * @param {number} max The maximum value to return.\n * @return {number} The input number if it is within bounds, or the nearest\n * number within the bounds.\n */\nexport function clamp(value, min, max) {\n return Math.min(Math.max(value, min), max);\n}\n\n/**\n * Returns the square of the closest distance between the point (x, y) and the\n * line segment (x1, y1) to (x2, y2).\n * @param {number} x X.\n * @param {number} y Y.\n * @param {number} x1 X1.\n * @param {number} y1 Y1.\n * @param {number} x2 X2.\n * @param {number} y2 Y2.\n * @return {number} Squared distance.\n */\nexport function squaredSegmentDistance(x, y, x1, y1, x2, y2) {\n const dx = x2 - x1;\n const dy = y2 - y1;\n if (dx !== 0 || dy !== 0) {\n const t = ((x - x1) * dx + (y - y1) * dy) / (dx * dx + dy * dy);\n if (t > 1) {\n x1 = x2;\n y1 = y2;\n } else if (t > 0) {\n x1 += dx * t;\n y1 += dy * t;\n }\n }\n return squaredDistance(x, y, x1, y1);\n}\n\n/**\n * Returns the square of the distance between the points (x1, y1) and (x2, y2).\n * @param {number} x1 X1.\n * @param {number} y1 Y1.\n * @param {number} x2 X2.\n * @param {number} y2 Y2.\n * @return {number} Squared distance.\n */\nexport function squaredDistance(x1, y1, x2, y2) {\n const dx = x2 - x1;\n const dy = y2 - y1;\n return dx * dx + dy * dy;\n}\n\n/**\n * Solves system of linear equations using Gaussian elimination method.\n *\n * @param {Array>} mat Augmented matrix (n x n + 1 column)\n * in row-major order.\n * @return {Array|null} The resulting vector.\n */\nexport function solveLinearSystem(mat) {\n const n = mat.length;\n\n for (let i = 0; i < n; i++) {\n // Find max in the i-th column (ignoring i - 1 first rows)\n let maxRow = i;\n let maxEl = Math.abs(mat[i][i]);\n for (let r = i + 1; r < n; r++) {\n const absValue = Math.abs(mat[r][i]);\n if (absValue > maxEl) {\n maxEl = absValue;\n maxRow = r;\n }\n }\n\n if (maxEl === 0) {\n return null; // matrix is singular\n }\n\n // Swap max row with i-th (current) row\n const tmp = mat[maxRow];\n mat[maxRow] = mat[i];\n mat[i] = tmp;\n\n // Subtract the i-th row to make all the remaining rows 0 in the i-th column\n for (let j = i + 1; j < n; j++) {\n const coef = -mat[j][i] / mat[i][i];\n for (let k = i; k < n + 1; k++) {\n if (i == k) {\n mat[j][k] = 0;\n } else {\n mat[j][k] += coef * mat[i][k];\n }\n }\n }\n }\n\n // Solve Ax=b for upper triangular matrix A (mat)\n const x = new Array(n);\n for (let l = n - 1; l >= 0; l--) {\n x[l] = mat[l][n] / mat[l][l];\n for (let m = l - 1; m >= 0; m--) {\n mat[m][n] -= mat[m][l] * x[l];\n }\n }\n return x;\n}\n\n/**\n * Converts radians to to degrees.\n *\n * @param {number} angleInRadians Angle in radians.\n * @return {number} Angle in degrees.\n */\nexport function toDegrees(angleInRadians) {\n return (angleInRadians * 180) / Math.PI;\n}\n\n/**\n * Converts degrees to radians.\n *\n * @param {number} angleInDegrees Angle in degrees.\n * @return {number} Angle in radians.\n */\nexport function toRadians(angleInDegrees) {\n return (angleInDegrees * Math.PI) / 180;\n}\n\n/**\n * Returns the modulo of a / b, depending on the sign of b.\n *\n * @param {number} a Dividend.\n * @param {number} b Divisor.\n * @return {number} Modulo.\n */\nexport function modulo(a, b) {\n const r = a % b;\n return r * b < 0 ? r + b : r;\n}\n\n/**\n * Calculates the linearly interpolated value of x between a and b.\n *\n * @param {number} a Number\n * @param {number} b Number\n * @param {number} x Value to be interpolated.\n * @return {number} Interpolated value.\n */\nexport function lerp(a, b, x) {\n return a + x * (b - a);\n}\n\n/**\n * Returns a number with a limited number of decimal digits.\n * @param {number} n The input number.\n * @param {number} decimals The maximum number of decimal digits.\n * @return {number} The input number with a limited number of decimal digits.\n */\nexport function toFixed(n, decimals) {\n const factor = Math.pow(10, decimals);\n return Math.round(n * factor) / factor;\n}\n\n/**\n * Rounds a number to the nearest integer value considering only the given number\n * of decimal digits (with rounding on the final digit).\n * @param {number} n The input number.\n * @param {number} decimals The maximum number of decimal digits.\n * @return {number} The nearest integer.\n */\nexport function round(n, decimals) {\n return Math.round(toFixed(n, decimals));\n}\n\n/**\n * Rounds a number to the next smaller integer considering only the given number\n * of decimal digits (with rounding on the final digit).\n * @param {number} n The input number.\n * @param {number} decimals The maximum number of decimal digits.\n * @return {number} The next smaller integer.\n */\nexport function floor(n, decimals) {\n return Math.floor(toFixed(n, decimals));\n}\n\n/**\n * Rounds a number to the next bigger integer considering only the given number\n * of decimal digits (with rounding on the final digit).\n * @param {number} n The input number.\n * @param {number} decimals The maximum number of decimal digits.\n * @return {number} The next bigger integer.\n */\nexport function ceil(n, decimals) {\n return Math.ceil(toFixed(n, decimals));\n}\n","/**\n * @module ol/string\n */\n\n/**\n * @param {number} number Number to be formatted\n * @param {number} width The desired width\n * @param {number} [precision] Precision of the output string (i.e. number of decimal places)\n * @return {string} Formatted string\n */\nexport function padNumber(number, width, precision) {\n const numberString =\n precision !== undefined ? number.toFixed(precision) : '' + number;\n let decimal = numberString.indexOf('.');\n decimal = decimal === -1 ? numberString.length : decimal;\n return decimal > width\n ? numberString\n : new Array(1 + width - decimal).join('0') + numberString;\n}\n\n/**\n * Adapted from https://github.com/omichelsen/compare-versions/blob/master/index.js\n * @param {string|number} v1 First version\n * @param {string|number} v2 Second version\n * @return {number} Value\n */\nexport function compareVersions(v1, v2) {\n const s1 = ('' + v1).split('.');\n const s2 = ('' + v2).split('.');\n\n for (let i = 0; i < Math.max(s1.length, s2.length); i++) {\n const n1 = parseInt(s1[i] || '0', 10);\n const n2 = parseInt(s2[i] || '0', 10);\n\n if (n1 > n2) {\n return 1;\n }\n if (n2 > n1) {\n return -1;\n }\n }\n\n return 0;\n}\n","/**\n * @module ol/coordinate\n */\nimport {getWidth} from './extent.js';\nimport {modulo, toFixed} from './math.js';\nimport {padNumber} from './string.js';\n\n/**\n * An array of numbers representing an `xy`, `xyz` or `xyzm` coordinate.\n * Example: `[16, 48]`.\n * @typedef {Array} Coordinate\n * @api\n */\n\n/**\n * A function that takes a {@link module:ol/coordinate~Coordinate} and\n * transforms it into a `{string}`.\n *\n * @typedef {function((Coordinate|undefined)): string} CoordinateFormat\n * @api\n */\n\n/**\n * Add `delta` to `coordinate`. `coordinate` is modified in place and returned\n * by the function.\n *\n * Example:\n *\n * import {add} from 'ol/coordinate.js';\n *\n * const coord = [7.85, 47.983333];\n * add(coord, [-2, 4]);\n * // coord is now [5.85, 51.983333]\n *\n * @param {Coordinate} coordinate Coordinate.\n * @param {Coordinate} delta Delta.\n * @return {Coordinate} The input coordinate adjusted by\n * the given delta.\n * @api\n */\nexport function add(coordinate, delta) {\n coordinate[0] += +delta[0];\n coordinate[1] += +delta[1];\n return coordinate;\n}\n\n/**\n * Calculates the point closest to the passed coordinate on the passed circle.\n *\n * @param {Coordinate} coordinate The coordinate.\n * @param {import(\"./geom/Circle.js\").default} circle The circle.\n * @return {Coordinate} Closest point on the circumference.\n */\nexport function closestOnCircle(coordinate, circle) {\n const r = circle.getRadius();\n const center = circle.getCenter();\n const x0 = center[0];\n const y0 = center[1];\n const x1 = coordinate[0];\n const y1 = coordinate[1];\n\n let dx = x1 - x0;\n const dy = y1 - y0;\n if (dx === 0 && dy === 0) {\n dx = 1;\n }\n const d = Math.sqrt(dx * dx + dy * dy);\n\n const x = x0 + (r * dx) / d;\n const y = y0 + (r * dy) / d;\n\n return [x, y];\n}\n\n/**\n * Calculates the point closest to the passed coordinate on the passed segment.\n * This is the foot of the perpendicular of the coordinate to the segment when\n * the foot is on the segment, or the closest segment coordinate when the foot\n * is outside the segment.\n *\n * @param {Coordinate} coordinate The coordinate.\n * @param {Array} segment The two coordinates\n * of the segment.\n * @return {Coordinate} The foot of the perpendicular of\n * the coordinate to the segment.\n */\nexport function closestOnSegment(coordinate, segment) {\n const x0 = coordinate[0];\n const y0 = coordinate[1];\n const start = segment[0];\n const end = segment[1];\n const x1 = start[0];\n const y1 = start[1];\n const x2 = end[0];\n const y2 = end[1];\n const dx = x2 - x1;\n const dy = y2 - y1;\n const along =\n dx === 0 && dy === 0\n ? 0\n : (dx * (x0 - x1) + dy * (y0 - y1)) / (dx * dx + dy * dy || 0);\n let x, y;\n if (along <= 0) {\n x = x1;\n y = y1;\n } else if (along >= 1) {\n x = x2;\n y = y2;\n } else {\n x = x1 + along * dx;\n y = y1 + along * dy;\n }\n return [x, y];\n}\n\n/**\n * Returns a {@link module:ol/coordinate~CoordinateFormat} function that can be\n * used to format\n * a {Coordinate} to a string.\n *\n * Example without specifying the fractional digits:\n *\n * import {createStringXY} from 'ol/coordinate.js';\n *\n * const coord = [7.85, 47.983333];\n * const stringifyFunc = createStringXY();\n * const out = stringifyFunc(coord);\n * // out is now '8, 48'\n *\n * Example with explicitly specifying 2 fractional digits:\n *\n * import {createStringXY} from 'ol/coordinate.js';\n *\n * const coord = [7.85, 47.983333];\n * const stringifyFunc = createStringXY(2);\n * const out = stringifyFunc(coord);\n * // out is now '7.85, 47.98'\n *\n * @param {number} [fractionDigits] The number of digits to include\n * after the decimal point. Default is `0`.\n * @return {CoordinateFormat} Coordinate format.\n * @api\n */\nexport function createStringXY(fractionDigits) {\n return (\n /**\n * @param {Coordinate} coordinate Coordinate.\n * @return {string} String XY.\n */\n function (coordinate) {\n return toStringXY(coordinate, fractionDigits);\n }\n );\n}\n\n/**\n * @param {string} hemispheres Hemispheres.\n * @param {number} degrees Degrees.\n * @param {number} [fractionDigits] The number of digits to include\n * after the decimal point. Default is `0`.\n * @return {string} String.\n */\nexport function degreesToStringHDMS(hemispheres, degrees, fractionDigits) {\n const normalizedDegrees = modulo(degrees + 180, 360) - 180;\n const x = Math.abs(3600 * normalizedDegrees);\n const decimals = fractionDigits || 0;\n\n let deg = Math.floor(x / 3600);\n let min = Math.floor((x - deg * 3600) / 60);\n let sec = toFixed(x - deg * 3600 - min * 60, decimals);\n\n if (sec >= 60) {\n sec = 0;\n min += 1;\n }\n\n if (min >= 60) {\n min = 0;\n deg += 1;\n }\n\n let hdms = deg + '\\u00b0';\n if (min !== 0 || sec !== 0) {\n hdms += ' ' + padNumber(min, 2) + '\\u2032';\n }\n if (sec !== 0) {\n hdms += ' ' + padNumber(sec, 2, decimals) + '\\u2033';\n }\n if (normalizedDegrees !== 0) {\n hdms += ' ' + hemispheres.charAt(normalizedDegrees < 0 ? 1 : 0);\n }\n\n return hdms;\n}\n\n/**\n * Transforms the given {@link module:ol/coordinate~Coordinate} to a string\n * using the given string template. The strings `{x}` and `{y}` in the template\n * will be replaced with the first and second coordinate values respectively.\n *\n * Example without specifying the fractional digits:\n *\n * import {format} from 'ol/coordinate.js';\n *\n * const coord = [7.85, 47.983333];\n * const template = 'Coordinate is ({x}|{y}).';\n * const out = format(coord, template);\n * // out is now 'Coordinate is (8|48).'\n *\n * Example explicitly specifying the fractional digits:\n *\n * import {format} from 'ol/coordinate.js';\n *\n * const coord = [7.85, 47.983333];\n * const template = 'Coordinate is ({x}|{y}).';\n * const out = format(coord, template, 2);\n * // out is now 'Coordinate is (7.85|47.98).'\n *\n * @param {Coordinate} coordinate Coordinate.\n * @param {string} template A template string with `{x}` and `{y}` placeholders\n * that will be replaced by first and second coordinate values.\n * @param {number} [fractionDigits] The number of digits to include\n * after the decimal point. Default is `0`.\n * @return {string} Formatted coordinate.\n * @api\n */\nexport function format(coordinate, template, fractionDigits) {\n if (coordinate) {\n return template\n .replace('{x}', coordinate[0].toFixed(fractionDigits))\n .replace('{y}', coordinate[1].toFixed(fractionDigits));\n }\n return '';\n}\n\n/**\n * @param {Coordinate} coordinate1 First coordinate.\n * @param {Coordinate} coordinate2 Second coordinate.\n * @return {boolean} The two coordinates are equal.\n */\nexport function equals(coordinate1, coordinate2) {\n let equals = true;\n for (let i = coordinate1.length - 1; i >= 0; --i) {\n if (coordinate1[i] != coordinate2[i]) {\n equals = false;\n break;\n }\n }\n return equals;\n}\n\n/**\n * Rotate `coordinate` by `angle`. `coordinate` is modified in place and\n * returned by the function.\n *\n * Example:\n *\n * import {rotate} from 'ol/coordinate.js';\n *\n * const coord = [7.85, 47.983333];\n * const rotateRadians = Math.PI / 2; // 90 degrees\n * rotate(coord, rotateRadians);\n * // coord is now [-47.983333, 7.85]\n *\n * @param {Coordinate} coordinate Coordinate.\n * @param {number} angle Angle in radian.\n * @return {Coordinate} Coordinate.\n * @api\n */\nexport function rotate(coordinate, angle) {\n const cosAngle = Math.cos(angle);\n const sinAngle = Math.sin(angle);\n const x = coordinate[0] * cosAngle - coordinate[1] * sinAngle;\n const y = coordinate[1] * cosAngle + coordinate[0] * sinAngle;\n coordinate[0] = x;\n coordinate[1] = y;\n return coordinate;\n}\n\n/**\n * Scale `coordinate` by `scale`. `coordinate` is modified in place and returned\n * by the function.\n *\n * Example:\n *\n * import {scale as scaleCoordinate} from 'ol/coordinate.js';\n *\n * const coord = [7.85, 47.983333];\n * const scale = 1.2;\n * scaleCoordinate(coord, scale);\n * // coord is now [9.42, 57.5799996]\n *\n * @param {Coordinate} coordinate Coordinate.\n * @param {number} scale Scale factor.\n * @return {Coordinate} Coordinate.\n */\nexport function scale(coordinate, scale) {\n coordinate[0] *= scale;\n coordinate[1] *= scale;\n return coordinate;\n}\n\n/**\n * @param {Coordinate} coord1 First coordinate.\n * @param {Coordinate} coord2 Second coordinate.\n * @return {number} Squared distance between coord1 and coord2.\n */\nexport function squaredDistance(coord1, coord2) {\n const dx = coord1[0] - coord2[0];\n const dy = coord1[1] - coord2[1];\n return dx * dx + dy * dy;\n}\n\n/**\n * @param {Coordinate} coord1 First coordinate.\n * @param {Coordinate} coord2 Second coordinate.\n * @return {number} Distance between coord1 and coord2.\n */\nexport function distance(coord1, coord2) {\n return Math.sqrt(squaredDistance(coord1, coord2));\n}\n\n/**\n * Calculate the squared distance from a coordinate to a line segment.\n *\n * @param {Coordinate} coordinate Coordinate of the point.\n * @param {Array} segment Line segment (2\n * coordinates).\n * @return {number} Squared distance from the point to the line segment.\n */\nexport function squaredDistanceToSegment(coordinate, segment) {\n return squaredDistance(coordinate, closestOnSegment(coordinate, segment));\n}\n\n/**\n * Format a geographic coordinate with the hemisphere, degrees, minutes, and\n * seconds.\n *\n * Example without specifying fractional digits:\n *\n * import {toStringHDMS} from 'ol/coordinate.js';\n *\n * const coord = [7.85, 47.983333];\n * const out = toStringHDMS(coord);\n * // out is now '47° 58′ 60″ N 7° 50′ 60″ E'\n *\n * Example explicitly specifying 1 fractional digit:\n *\n * import {toStringHDMS} from 'ol/coordinate.js';\n *\n * const coord = [7.85, 47.983333];\n * const out = toStringHDMS(coord, 1);\n * // out is now '47° 58′ 60.0″ N 7° 50′ 60.0″ E'\n *\n * @param {Coordinate} coordinate Coordinate.\n * @param {number} [fractionDigits] The number of digits to include\n * after the decimal point. Default is `0`.\n * @return {string} Hemisphere, degrees, minutes and seconds.\n * @api\n */\nexport function toStringHDMS(coordinate, fractionDigits) {\n if (coordinate) {\n return (\n degreesToStringHDMS('NS', coordinate[1], fractionDigits) +\n ' ' +\n degreesToStringHDMS('EW', coordinate[0], fractionDigits)\n );\n }\n return '';\n}\n\n/**\n * Format a coordinate as a comma delimited string.\n *\n * Example without specifying fractional digits:\n *\n * import {toStringXY} from 'ol/coordinate.js';\n *\n * const coord = [7.85, 47.983333];\n * const out = toStringXY(coord);\n * // out is now '8, 48'\n *\n * Example explicitly specifying 1 fractional digit:\n *\n * import {toStringXY} from 'ol/coordinate.js';\n *\n * const coord = [7.85, 47.983333];\n * const out = toStringXY(coord, 1);\n * // out is now '7.8, 48.0'\n *\n * @param {Coordinate} coordinate Coordinate.\n * @param {number} [fractionDigits] The number of digits to include\n * after the decimal point. Default is `0`.\n * @return {string} XY.\n * @api\n */\nexport function toStringXY(coordinate, fractionDigits) {\n return format(coordinate, '{x}, {y}', fractionDigits);\n}\n\n/**\n * Modifies the provided coordinate in-place to be within the real world\n * extent. The lower projection extent boundary is inclusive, the upper one\n * exclusive.\n *\n * @param {Coordinate} coordinate Coordinate.\n * @param {import(\"./proj/Projection.js\").default} projection Projection.\n * @return {Coordinate} The coordinate within the real world extent.\n */\nexport function wrapX(coordinate, projection) {\n if (projection.canWrapX()) {\n const worldWidth = getWidth(projection.getExtent());\n const worldsAway = getWorldsAway(coordinate, projection, worldWidth);\n if (worldsAway) {\n coordinate[0] -= worldsAway * worldWidth;\n }\n }\n return coordinate;\n}\n/**\n * @param {Coordinate} coordinate Coordinate.\n * @param {import(\"./proj/Projection.js\").default} projection Projection.\n * @param {number} [sourceExtentWidth] Width of the source extent.\n * @return {number} Offset in world widths.\n */\nexport function getWorldsAway(coordinate, projection, sourceExtentWidth) {\n const projectionExtent = projection.getExtent();\n let worldsAway = 0;\n if (\n projection.canWrapX() &&\n (coordinate[0] < projectionExtent[0] || coordinate[0] > projectionExtent[2])\n ) {\n sourceExtentWidth = sourceExtentWidth || getWidth(projectionExtent);\n worldsAway = Math.floor(\n (coordinate[0] - projectionExtent[0]) / sourceExtentWidth,\n );\n }\n return worldsAway;\n}\n","/**\n * @module ol/sphere\n */\nimport {toDegrees, toRadians} from './math.js';\n\n/**\n * Object literal with options for the {@link getLength} or {@link getArea}\n * functions.\n * @typedef {Object} SphereMetricOptions\n * @property {import(\"./proj.js\").ProjectionLike} [projection='EPSG:3857']\n * Projection of the geometry. By default, the geometry is assumed to be in\n * Web Mercator.\n * @property {number} [radius=6371008.8] Sphere radius. By default, the\n * [mean Earth radius](https://en.wikipedia.org/wiki/Earth_radius#Mean_radius)\n * for the WGS84 ellipsoid is used.\n */\n\n/**\n * The mean Earth radius (1/3 * (2a + b)) for the WGS84 ellipsoid.\n * https://en.wikipedia.org/wiki/Earth_radius#Mean_radius\n * @type {number}\n */\nexport const DEFAULT_RADIUS = 6371008.8;\n\n/**\n * Get the great circle distance (in meters) between two geographic coordinates.\n * @param {Array} c1 Starting coordinate.\n * @param {Array} c2 Ending coordinate.\n * @param {number} [radius] The sphere radius to use. Defaults to the Earth's\n * mean radius using the WGS84 ellipsoid.\n * @return {number} The great circle distance between the points (in meters).\n * @api\n */\nexport function getDistance(c1, c2, radius) {\n radius = radius || DEFAULT_RADIUS;\n const lat1 = toRadians(c1[1]);\n const lat2 = toRadians(c2[1]);\n const deltaLatBy2 = (lat2 - lat1) / 2;\n const deltaLonBy2 = toRadians(c2[0] - c1[0]) / 2;\n const a =\n Math.sin(deltaLatBy2) * Math.sin(deltaLatBy2) +\n Math.sin(deltaLonBy2) *\n Math.sin(deltaLonBy2) *\n Math.cos(lat1) *\n Math.cos(lat2);\n return 2 * radius * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));\n}\n\n/**\n * Get the cumulative great circle length of linestring coordinates (geographic).\n * @param {Array} coordinates Linestring coordinates.\n * @param {number} radius The sphere radius to use.\n * @return {number} The length (in meters).\n */\nfunction getLengthInternal(coordinates, radius) {\n let length = 0;\n for (let i = 0, ii = coordinates.length; i < ii - 1; ++i) {\n length += getDistance(coordinates[i], coordinates[i + 1], radius);\n }\n return length;\n}\n\n/**\n * Get the spherical length of a geometry. This length is the sum of the\n * great circle distances between coordinates. For polygons, the length is\n * the sum of all rings. For points, the length is zero. For multi-part\n * geometries, the length is the sum of the length of each part.\n * @param {import(\"./geom/Geometry.js\").default} geometry A geometry.\n * @param {SphereMetricOptions} [options] Options for the\n * length calculation. By default, geometries are assumed to be in 'EPSG:3857'.\n * You can change this by providing a `projection` option.\n * @return {number} The spherical length (in meters).\n * @api\n */\nexport function getLength(geometry, options) {\n options = options || {};\n const radius = options.radius || DEFAULT_RADIUS;\n const projection = options.projection || 'EPSG:3857';\n const type = geometry.getType();\n if (type !== 'GeometryCollection') {\n geometry = geometry.clone().transform(projection, 'EPSG:4326');\n }\n let length = 0;\n let coordinates, coords, i, ii, j, jj;\n switch (type) {\n case 'Point':\n case 'MultiPoint': {\n break;\n }\n case 'LineString':\n case 'LinearRing': {\n coordinates = /** @type {import(\"./geom/SimpleGeometry.js\").default} */ (\n geometry\n ).getCoordinates();\n length = getLengthInternal(coordinates, radius);\n break;\n }\n case 'MultiLineString':\n case 'Polygon': {\n coordinates = /** @type {import(\"./geom/SimpleGeometry.js\").default} */ (\n geometry\n ).getCoordinates();\n for (i = 0, ii = coordinates.length; i < ii; ++i) {\n length += getLengthInternal(coordinates[i], radius);\n }\n break;\n }\n case 'MultiPolygon': {\n coordinates = /** @type {import(\"./geom/SimpleGeometry.js\").default} */ (\n geometry\n ).getCoordinates();\n for (i = 0, ii = coordinates.length; i < ii; ++i) {\n coords = coordinates[i];\n for (j = 0, jj = coords.length; j < jj; ++j) {\n length += getLengthInternal(coords[j], radius);\n }\n }\n break;\n }\n case 'GeometryCollection': {\n const geometries =\n /** @type {import(\"./geom/GeometryCollection.js\").default} */ (\n geometry\n ).getGeometries();\n for (i = 0, ii = geometries.length; i < ii; ++i) {\n length += getLength(geometries[i], options);\n }\n break;\n }\n default: {\n throw new Error('Unsupported geometry type: ' + type);\n }\n }\n return length;\n}\n\n/**\n * Returns the spherical area for a list of coordinates.\n *\n * [Reference](https://trs.jpl.nasa.gov/handle/2014/40409)\n * Robert. G. Chamberlain and William H. Duquette, \"Some Algorithms for\n * Polygons on a Sphere\", JPL Publication 07-03, Jet Propulsion\n * Laboratory, Pasadena, CA, June 2007\n *\n * @param {Array} coordinates List of coordinates of a linear\n * ring. If the ring is oriented clockwise, the area will be positive,\n * otherwise it will be negative.\n * @param {number} radius The sphere radius.\n * @return {number} Area (in square meters).\n */\nfunction getAreaInternal(coordinates, radius) {\n let area = 0;\n const len = coordinates.length;\n let x1 = coordinates[len - 1][0];\n let y1 = coordinates[len - 1][1];\n for (let i = 0; i < len; i++) {\n const x2 = coordinates[i][0];\n const y2 = coordinates[i][1];\n area +=\n toRadians(x2 - x1) *\n (2 + Math.sin(toRadians(y1)) + Math.sin(toRadians(y2)));\n x1 = x2;\n y1 = y2;\n }\n return (area * radius * radius) / 2.0;\n}\n\n/**\n * Get the spherical area of a geometry. This is the area (in meters) assuming\n * that polygon edges are segments of great circles on a sphere.\n * @param {import(\"./geom/Geometry.js\").default} geometry A geometry.\n * @param {SphereMetricOptions} [options] Options for the area\n * calculation. By default, geometries are assumed to be in 'EPSG:3857'.\n * You can change this by providing a `projection` option.\n * @return {number} The spherical area (in square meters).\n * @api\n */\nexport function getArea(geometry, options) {\n options = options || {};\n const radius = options.radius || DEFAULT_RADIUS;\n const projection = options.projection || 'EPSG:3857';\n const type = geometry.getType();\n if (type !== 'GeometryCollection') {\n geometry = geometry.clone().transform(projection, 'EPSG:4326');\n }\n let area = 0;\n let coordinates, coords, i, ii, j, jj;\n switch (type) {\n case 'Point':\n case 'MultiPoint':\n case 'LineString':\n case 'MultiLineString':\n case 'LinearRing': {\n break;\n }\n case 'Polygon': {\n coordinates = /** @type {import(\"./geom/Polygon.js\").default} */ (\n geometry\n ).getCoordinates();\n area = Math.abs(getAreaInternal(coordinates[0], radius));\n for (i = 1, ii = coordinates.length; i < ii; ++i) {\n area -= Math.abs(getAreaInternal(coordinates[i], radius));\n }\n break;\n }\n case 'MultiPolygon': {\n coordinates = /** @type {import(\"./geom/SimpleGeometry.js\").default} */ (\n geometry\n ).getCoordinates();\n for (i = 0, ii = coordinates.length; i < ii; ++i) {\n coords = coordinates[i];\n area += Math.abs(getAreaInternal(coords[0], radius));\n for (j = 1, jj = coords.length; j < jj; ++j) {\n area -= Math.abs(getAreaInternal(coords[j], radius));\n }\n }\n break;\n }\n case 'GeometryCollection': {\n const geometries =\n /** @type {import(\"./geom/GeometryCollection.js\").default} */ (\n geometry\n ).getGeometries();\n for (i = 0, ii = geometries.length; i < ii; ++i) {\n area += getArea(geometries[i], options);\n }\n break;\n }\n default: {\n throw new Error('Unsupported geometry type: ' + type);\n }\n }\n return area;\n}\n\n/**\n * Returns the coordinate at the given distance and bearing from `c1`.\n *\n * @param {import(\"./coordinate.js\").Coordinate} c1 The origin point (`[lon, lat]` in degrees).\n * @param {number} distance The great-circle distance between the origin\n * point and the target point.\n * @param {number} bearing The bearing (in radians).\n * @param {number} [radius] The sphere radius to use. Defaults to the Earth's\n * mean radius using the WGS84 ellipsoid.\n * @return {import(\"./coordinate.js\").Coordinate} The target point.\n */\nexport function offset(c1, distance, bearing, radius) {\n radius = radius || DEFAULT_RADIUS;\n const lat1 = toRadians(c1[1]);\n const lon1 = toRadians(c1[0]);\n const dByR = distance / radius;\n const lat = Math.asin(\n Math.sin(lat1) * Math.cos(dByR) +\n Math.cos(lat1) * Math.sin(dByR) * Math.cos(bearing),\n );\n const lon =\n lon1 +\n Math.atan2(\n Math.sin(bearing) * Math.sin(dByR) * Math.cos(lat1),\n Math.cos(dByR) - Math.sin(lat1) * Math.sin(lat),\n );\n return [toDegrees(lon), toDegrees(lat)];\n}\n","/**\n * @module ol/console\n */\n\n/**\n * @typedef {'info'|'warn'|'error'|'none'} Level\n */\n\n/**\n * @type {Object}\n */\nconst levels = {\n info: 1,\n warn: 2,\n error: 3,\n none: 4,\n};\n\n/**\n * @type {number}\n */\nlet level = levels.info;\n\n/**\n * Set the logging level. By default, the level is set to 'info' and all\n * messages will be logged. Set to 'warn' to only display warnings and errors.\n * Set to 'error' to only display errors. Set to 'none' to silence all messages.\n *\n * @param {Level} l The new level.\n */\nexport function setLevel(l) {\n level = levels[l];\n}\n\n/**\n * @param {...any} args Arguments to log\n */\nexport function log(...args) {\n if (level > levels.info) {\n return;\n }\n console.log(...args); // eslint-disable-line no-console\n}\n\n/**\n * @param {...any} args Arguments to log\n */\nexport function warn(...args) {\n if (level > levels.warn) {\n return;\n }\n console.warn(...args); // eslint-disable-line no-console\n}\n\n/**\n * @param {...any} args Arguments to log\n */\nexport function error(...args) {\n if (level > levels.error) {\n return;\n }\n console.error(...args); // eslint-disable-line no-console\n}\n","/**\n * @module ol/proj\n */\n\n/**\n * The ol/proj module stores:\n * * a list of {@link module:ol/proj/Projection~Projection}\n * objects, one for each projection supported by the application\n * * a list of transform functions needed to convert coordinates in one projection\n * into another.\n *\n * The static functions are the methods used to maintain these.\n * Each transform function can handle not only simple coordinate pairs, but also\n * large arrays of coordinates such as vector geometries.\n *\n * When loaded, the library adds projection objects for EPSG:4326 (WGS84\n * geographic coordinates) and EPSG:3857 (Web or Spherical Mercator, as used\n * for example by Bing Maps or OpenStreetMap), together with the relevant\n * transform functions.\n *\n * Additional transforms may be added by using the http://proj4js.org/\n * library (version 2.2 or later). You can use the full build supplied by\n * Proj4js, or create a custom build to support those projections you need; see\n * the Proj4js website for how to do this. You also need the Proj4js definitions\n * for the required projections. These definitions can be obtained from\n * https://epsg.io/, and are a JS function, so can be loaded in a script\n * tag (as in the examples) or pasted into your application.\n *\n * After all required projection definitions are added to proj4's registry (by\n * using `proj4.defs()`), simply call `register(proj4)` from the `ol/proj/proj4`\n * package. Existing transforms are not changed by this function. See\n * examples/wms-image-custom-proj for an example of this.\n *\n * Additional projection definitions can be registered with `proj4.defs()` any\n * time. Just make sure to call `register(proj4)` again; for example, with user-supplied data where you don't\n * know in advance what projections are needed, you can initially load minimal\n * support and then load whichever are requested.\n *\n * Note that Proj4js does not support projection extents. If you want to add\n * one for creating default tile grids, you can add it after the Projection\n * object has been created with `setExtent`, for example,\n * `get('EPSG:1234').setExtent(extent)`.\n *\n * In addition to Proj4js support, any transform functions can be added with\n * {@link module:ol/proj.addCoordinateTransforms}. To use this, you must first create\n * a {@link module:ol/proj/Projection~Projection} object for the new projection and add it with\n * {@link module:ol/proj.addProjection}. You can then add the forward and inverse\n * functions with {@link module:ol/proj.addCoordinateTransforms}. See\n * examples/wms-custom-proj for an example of this.\n *\n * Note that if no transforms are needed and you only need to define the\n * projection, just add a {@link module:ol/proj/Projection~Projection} with\n * {@link module:ol/proj.addProjection}. See examples/wms-no-proj for an example of\n * this.\n */\nimport Projection from './proj/Projection.js';\nimport {\n PROJECTIONS as EPSG3857_PROJECTIONS,\n fromEPSG4326,\n toEPSG4326,\n} from './proj/epsg3857.js';\nimport {PROJECTIONS as EPSG4326_PROJECTIONS} from './proj/epsg4326.js';\nimport {METERS_PER_UNIT} from './proj/Units.js';\nimport {\n add as addProj,\n clear as clearProj,\n get as getProj,\n} from './proj/projections.js';\nimport {\n add as addTransformFunc,\n clear as clearTransformFuncs,\n get as getTransformFunc,\n} from './proj/transforms.js';\nimport {applyTransform, getWidth} from './extent.js';\nimport {clamp, modulo} from './math.js';\nimport {equals, getWorldsAway} from './coordinate.js';\nimport {getDistance} from './sphere.js';\nimport {warn} from './console.js';\n\n/**\n * A projection as {@link module:ol/proj/Projection~Projection}, SRS identifier\n * string or undefined.\n * @typedef {Projection|string|undefined} ProjectionLike\n * @api\n */\n\n/**\n * A transform function accepts an array of input coordinate values, an optional\n * output array, and an optional dimension (default should be 2). The function\n * transforms the input coordinate values, populates the output array, and\n * returns the output array.\n *\n * @typedef {function(Array, Array=, number=): Array} TransformFunction\n * @api\n */\n\nexport {METERS_PER_UNIT};\n\nexport {Projection};\n\nlet showCoordinateWarning = true;\n\n/**\n * @param {boolean} [disable = true] Disable console info about `useGeographic()`\n */\nexport function disableCoordinateWarning(disable) {\n const hide = disable === undefined ? true : disable;\n showCoordinateWarning = !hide;\n}\n\n/**\n * @param {Array} input Input coordinate array.\n * @param {Array} [output] Output array of coordinate values.\n * @return {Array} Output coordinate array (new array, same coordinate\n * values).\n */\nexport function cloneTransform(input, output) {\n if (output !== undefined) {\n for (let i = 0, ii = input.length; i < ii; ++i) {\n output[i] = input[i];\n }\n output = output;\n } else {\n output = input.slice();\n }\n return output;\n}\n\n/**\n * @param {Array} input Input coordinate array.\n * @param {Array} [output] Output array of coordinate values.\n * @return {Array} Input coordinate array (same array as input).\n */\nexport function identityTransform(input, output) {\n if (output !== undefined && input !== output) {\n for (let i = 0, ii = input.length; i < ii; ++i) {\n output[i] = input[i];\n }\n input = output;\n }\n return input;\n}\n\n/**\n * Add a Projection object to the list of supported projections that can be\n * looked up by their code.\n *\n * @param {Projection} projection Projection instance.\n * @api\n */\nexport function addProjection(projection) {\n addProj(projection.getCode(), projection);\n addTransformFunc(projection, projection, cloneTransform);\n}\n\n/**\n * @param {Array} projections Projections.\n */\nexport function addProjections(projections) {\n projections.forEach(addProjection);\n}\n\n/**\n * Fetches a Projection object for the code specified.\n *\n * @param {ProjectionLike} projectionLike Either a code string which is\n * a combination of authority and identifier such as \"EPSG:4326\", or an\n * existing projection object, or undefined.\n * @return {Projection|null} Projection object, or null if not in list.\n * @api\n */\nexport function get(projectionLike) {\n return typeof projectionLike === 'string'\n ? getProj(/** @type {string} */ (projectionLike))\n : /** @type {Projection} */ (projectionLike) || null;\n}\n\n/**\n * Get the resolution of the point in degrees or distance units.\n * For projections with degrees as the unit this will simply return the\n * provided resolution. For other projections the point resolution is\n * by default estimated by transforming the `point` pixel to EPSG:4326,\n * measuring its width and height on the normal sphere,\n * and taking the average of the width and height.\n * A custom function can be provided for a specific projection, either\n * by setting the `getPointResolution` option in the\n * {@link module:ol/proj/Projection~Projection} constructor or by using\n * {@link module:ol/proj/Projection~Projection#setGetPointResolution} to change an existing\n * projection object.\n * @param {ProjectionLike} projection The projection.\n * @param {number} resolution Nominal resolution in projection units.\n * @param {import(\"./coordinate.js\").Coordinate} point Point to find adjusted resolution at.\n * @param {import(\"./proj/Units.js\").Units} [units] Units to get the point resolution in.\n * Default is the projection's units.\n * @return {number} Point resolution.\n * @api\n */\nexport function getPointResolution(projection, resolution, point, units) {\n projection = get(projection);\n let pointResolution;\n const getter = projection.getPointResolutionFunc();\n if (getter) {\n pointResolution = getter(resolution, point);\n if (units && units !== projection.getUnits()) {\n const metersPerUnit = projection.getMetersPerUnit();\n if (metersPerUnit) {\n pointResolution =\n (pointResolution * metersPerUnit) / METERS_PER_UNIT[units];\n }\n }\n } else {\n const projUnits = projection.getUnits();\n if ((projUnits == 'degrees' && !units) || units == 'degrees') {\n pointResolution = resolution;\n } else {\n // Estimate point resolution by transforming the center pixel to EPSG:4326,\n // measuring its width and height on the normal sphere, and taking the\n // average of the width and height.\n const toEPSG4326 = getTransformFromProjections(\n projection,\n get('EPSG:4326'),\n );\n if (toEPSG4326 === identityTransform && projUnits !== 'degrees') {\n // no transform is available\n pointResolution = resolution * projection.getMetersPerUnit();\n } else {\n let vertices = [\n point[0] - resolution / 2,\n point[1],\n point[0] + resolution / 2,\n point[1],\n point[0],\n point[1] - resolution / 2,\n point[0],\n point[1] + resolution / 2,\n ];\n vertices = toEPSG4326(vertices, vertices, 2);\n const width = getDistance(vertices.slice(0, 2), vertices.slice(2, 4));\n const height = getDistance(vertices.slice(4, 6), vertices.slice(6, 8));\n pointResolution = (width + height) / 2;\n }\n const metersPerUnit = units\n ? METERS_PER_UNIT[units]\n : projection.getMetersPerUnit();\n if (metersPerUnit !== undefined) {\n pointResolution /= metersPerUnit;\n }\n }\n }\n return pointResolution;\n}\n\n/**\n * Registers transformation functions that don't alter coordinates. Those allow\n * to transform between projections with equal meaning.\n *\n * @param {Array} projections Projections.\n * @api\n */\nexport function addEquivalentProjections(projections) {\n addProjections(projections);\n projections.forEach(function (source) {\n projections.forEach(function (destination) {\n if (source !== destination) {\n addTransformFunc(source, destination, cloneTransform);\n }\n });\n });\n}\n\n/**\n * Registers transformation functions to convert coordinates in any projection\n * in projection1 to any projection in projection2.\n *\n * @param {Array} projections1 Projections with equal\n * meaning.\n * @param {Array} projections2 Projections with equal\n * meaning.\n * @param {TransformFunction} forwardTransform Transformation from any\n * projection in projection1 to any projection in projection2.\n * @param {TransformFunction} inverseTransform Transform from any projection\n * in projection2 to any projection in projection1..\n */\nexport function addEquivalentTransforms(\n projections1,\n projections2,\n forwardTransform,\n inverseTransform,\n) {\n projections1.forEach(function (projection1) {\n projections2.forEach(function (projection2) {\n addTransformFunc(projection1, projection2, forwardTransform);\n addTransformFunc(projection2, projection1, inverseTransform);\n });\n });\n}\n\n/**\n * Clear all cached projections and transforms.\n */\nexport function clearAllProjections() {\n clearProj();\n clearTransformFuncs();\n}\n\n/**\n * @param {Projection|string|undefined} projection Projection.\n * @param {string} defaultCode Default code.\n * @return {Projection} Projection.\n */\nexport function createProjection(projection, defaultCode) {\n if (!projection) {\n return get(defaultCode);\n }\n if (typeof projection === 'string') {\n return get(projection);\n }\n return /** @type {Projection} */ (projection);\n}\n\n/**\n * Creates a {@link module:ol/proj~TransformFunction} from a simple 2D coordinate transform\n * function.\n * @param {function(import(\"./coordinate.js\").Coordinate): import(\"./coordinate.js\").Coordinate} coordTransform Coordinate\n * transform.\n * @return {TransformFunction} Transform function.\n */\nexport function createTransformFromCoordinateTransform(coordTransform) {\n return (\n /**\n * @param {Array} input Input.\n * @param {Array} [output] Output.\n * @param {number} [dimension] Dimension.\n * @return {Array} Output.\n */\n function (input, output, dimension) {\n const length = input.length;\n dimension = dimension !== undefined ? dimension : 2;\n output = output !== undefined ? output : new Array(length);\n for (let i = 0; i < length; i += dimension) {\n const point = coordTransform(input.slice(i, i + dimension));\n const pointLength = point.length;\n for (let j = 0, jj = dimension; j < jj; ++j) {\n output[i + j] = j >= pointLength ? input[i + j] : point[j];\n }\n }\n return output;\n }\n );\n}\n\n/**\n * Registers coordinate transform functions to convert coordinates between the\n * source projection and the destination projection.\n * The forward and inverse functions convert coordinate pairs; this function\n * converts these into the functions used internally which also handle\n * extents and coordinate arrays.\n *\n * @param {ProjectionLike} source Source projection.\n * @param {ProjectionLike} destination Destination projection.\n * @param {function(import(\"./coordinate.js\").Coordinate): import(\"./coordinate.js\").Coordinate} forward The forward transform\n * function (that is, from the source projection to the destination\n * projection) that takes a {@link module:ol/coordinate~Coordinate} as argument and returns\n * the transformed {@link module:ol/coordinate~Coordinate}.\n * @param {function(import(\"./coordinate.js\").Coordinate): import(\"./coordinate.js\").Coordinate} inverse The inverse transform\n * function (that is, from the destination projection to the source\n * projection) that takes a {@link module:ol/coordinate~Coordinate} as argument and returns\n * the transformed {@link module:ol/coordinate~Coordinate}. If the transform function can only\n * transform less dimensions than the input coordinate, it is supposeed to return a coordinate\n * with only the length it can transform. The other dimensions will be taken unchanged from the\n * source.\n * @api\n */\nexport function addCoordinateTransforms(source, destination, forward, inverse) {\n const sourceProj = get(source);\n const destProj = get(destination);\n addTransformFunc(\n sourceProj,\n destProj,\n createTransformFromCoordinateTransform(forward),\n );\n addTransformFunc(\n destProj,\n sourceProj,\n createTransformFromCoordinateTransform(inverse),\n );\n}\n\n/**\n * Transforms a coordinate from longitude/latitude to a different projection.\n * @param {import(\"./coordinate.js\").Coordinate} coordinate Coordinate as longitude and latitude, i.e.\n * an array with longitude as 1st and latitude as 2nd element.\n * @param {ProjectionLike} [projection] Target projection. The\n * default is Web Mercator, i.e. 'EPSG:3857'.\n * @return {import(\"./coordinate.js\").Coordinate} Coordinate projected to the target projection.\n * @api\n */\nexport function fromLonLat(coordinate, projection) {\n disableCoordinateWarning();\n return transform(\n coordinate,\n 'EPSG:4326',\n projection !== undefined ? projection : 'EPSG:3857',\n );\n}\n\n/**\n * Transforms a coordinate to longitude/latitude.\n * @param {import(\"./coordinate.js\").Coordinate} coordinate Projected coordinate.\n * @param {ProjectionLike} [projection] Projection of the coordinate.\n * The default is Web Mercator, i.e. 'EPSG:3857'.\n * @return {import(\"./coordinate.js\").Coordinate} Coordinate as longitude and latitude, i.e. an array\n * with longitude as 1st and latitude as 2nd element.\n * @api\n */\nexport function toLonLat(coordinate, projection) {\n const lonLat = transform(\n coordinate,\n projection !== undefined ? projection : 'EPSG:3857',\n 'EPSG:4326',\n );\n const lon = lonLat[0];\n if (lon < -180 || lon > 180) {\n lonLat[0] = modulo(lon + 180, 360) - 180;\n }\n return lonLat;\n}\n\n/**\n * Checks if two projections are the same, that is every coordinate in one\n * projection does represent the same geographic point as the same coordinate in\n * the other projection.\n *\n * @param {Projection} projection1 Projection 1.\n * @param {Projection} projection2 Projection 2.\n * @return {boolean} Equivalent.\n * @api\n */\nexport function equivalent(projection1, projection2) {\n if (projection1 === projection2) {\n return true;\n }\n const equalUnits = projection1.getUnits() === projection2.getUnits();\n if (projection1.getCode() === projection2.getCode()) {\n return equalUnits;\n }\n const transformFunc = getTransformFromProjections(projection1, projection2);\n return transformFunc === cloneTransform && equalUnits;\n}\n\n/**\n * Searches in the list of transform functions for the function for converting\n * coordinates from the source projection to the destination projection.\n *\n * @param {Projection} sourceProjection Source Projection object.\n * @param {Projection} destinationProjection Destination Projection\n * object.\n * @return {TransformFunction} Transform function.\n */\nexport function getTransformFromProjections(\n sourceProjection,\n destinationProjection,\n) {\n const sourceCode = sourceProjection.getCode();\n const destinationCode = destinationProjection.getCode();\n let transformFunc = getTransformFunc(sourceCode, destinationCode);\n if (!transformFunc) {\n transformFunc = identityTransform;\n }\n return transformFunc;\n}\n\n/**\n * Given the projection-like objects, searches for a transformation\n * function to convert a coordinates array from the source projection to the\n * destination projection.\n *\n * @param {ProjectionLike} source Source.\n * @param {ProjectionLike} destination Destination.\n * @return {TransformFunction} Transform function.\n * @api\n */\nexport function getTransform(source, destination) {\n const sourceProjection = get(source);\n const destinationProjection = get(destination);\n return getTransformFromProjections(sourceProjection, destinationProjection);\n}\n\n/**\n * Transforms a coordinate from source projection to destination projection.\n * This returns a new coordinate (and does not modify the original).\n *\n * See {@link module:ol/proj.transformExtent} for extent transformation.\n * See the transform method of {@link module:ol/geom/Geometry~Geometry} and its\n * subclasses for geometry transforms.\n *\n * @param {import(\"./coordinate.js\").Coordinate} coordinate Coordinate.\n * @param {ProjectionLike} source Source projection-like.\n * @param {ProjectionLike} destination Destination projection-like.\n * @return {import(\"./coordinate.js\").Coordinate} Coordinate.\n * @api\n */\nexport function transform(coordinate, source, destination) {\n const transformFunc = getTransform(source, destination);\n return transformFunc(coordinate, undefined, coordinate.length);\n}\n\n/**\n * Transforms an extent from source projection to destination projection. This\n * returns a new extent (and does not modify the original).\n *\n * @param {import(\"./extent.js\").Extent} extent The extent to transform.\n * @param {ProjectionLike} source Source projection-like.\n * @param {ProjectionLike} destination Destination projection-like.\n * @param {number} [stops] Number of stops per side used for the transform.\n * By default only the corners are used.\n * @return {import(\"./extent.js\").Extent} The transformed extent.\n * @api\n */\nexport function transformExtent(extent, source, destination, stops) {\n const transformFunc = getTransform(source, destination);\n return applyTransform(extent, transformFunc, undefined, stops);\n}\n\n/**\n * Transforms the given point to the destination projection.\n *\n * @param {import(\"./coordinate.js\").Coordinate} point Point.\n * @param {Projection} sourceProjection Source projection.\n * @param {Projection} destinationProjection Destination projection.\n * @return {import(\"./coordinate.js\").Coordinate} Point.\n */\nexport function transformWithProjections(\n point,\n sourceProjection,\n destinationProjection,\n) {\n const transformFunc = getTransformFromProjections(\n sourceProjection,\n destinationProjection,\n );\n return transformFunc(point);\n}\n\n/**\n * @type {Projection|null}\n */\nlet userProjection = null;\n\n/**\n * Set the projection for coordinates supplied from and returned by API methods.\n * This includes all API methods except for those interacting with tile grids,\n * plus {@link import(\"./Map.js\").FrameState} and {@link import(\"./View.js\").State}.\n * @param {ProjectionLike} projection The user projection.\n * @api\n */\nexport function setUserProjection(projection) {\n userProjection = get(projection);\n}\n\n/**\n * Clear the user projection if set.\n * @api\n */\nexport function clearUserProjection() {\n userProjection = null;\n}\n\n/**\n * Get the projection for coordinates supplied from and returned by API methods.\n * @return {Projection|null} The user projection (or null if not set).\n * @api\n */\nexport function getUserProjection() {\n return userProjection;\n}\n\n/**\n * Use geographic coordinates (WGS-84 datum) in API methods.\n * This includes all API methods except for those interacting with tile grids,\n * plus {@link import(\"./Map.js\").FrameState} and {@link import(\"./View.js\").State}.\n * @api\n */\nexport function useGeographic() {\n setUserProjection('EPSG:4326');\n}\n\n/**\n * Return a coordinate transformed into the user projection. If no user projection\n * is set, the original coordinate is returned.\n * @param {Array} coordinate Input coordinate.\n * @param {ProjectionLike} sourceProjection The input coordinate projection.\n * @return {Array} The input coordinate in the user projection.\n */\nexport function toUserCoordinate(coordinate, sourceProjection) {\n if (!userProjection) {\n return coordinate;\n }\n return transform(coordinate, sourceProjection, userProjection);\n}\n\n/**\n * Return a coordinate transformed from the user projection. If no user projection\n * is set, the original coordinate is returned.\n * @param {Array} coordinate Input coordinate.\n * @param {ProjectionLike} destProjection The destination projection.\n * @return {Array} The input coordinate transformed.\n */\nexport function fromUserCoordinate(coordinate, destProjection) {\n if (!userProjection) {\n if (\n showCoordinateWarning &&\n !equals(coordinate, [0, 0]) &&\n coordinate[0] >= -180 &&\n coordinate[0] <= 180 &&\n coordinate[1] >= -90 &&\n coordinate[1] <= 90\n ) {\n showCoordinateWarning = false;\n warn(\n 'Call useGeographic() from ol/proj once to work with [longitude, latitude] coordinates.',\n );\n }\n return coordinate;\n }\n return transform(coordinate, userProjection, destProjection);\n}\n\n/**\n * Return an extent transformed into the user projection. If no user projection\n * is set, the original extent is returned.\n * @param {import(\"./extent.js\").Extent} extent Input extent.\n * @param {ProjectionLike} sourceProjection The input extent projection.\n * @return {import(\"./extent.js\").Extent} The input extent in the user projection.\n */\nexport function toUserExtent(extent, sourceProjection) {\n if (!userProjection) {\n return extent;\n }\n return transformExtent(extent, sourceProjection, userProjection);\n}\n\n/**\n * Return an extent transformed from the user projection. If no user projection\n * is set, the original extent is returned.\n * @param {import(\"./extent.js\").Extent} extent Input extent.\n * @param {ProjectionLike} destProjection The destination projection.\n * @return {import(\"./extent.js\").Extent} The input extent transformed.\n */\nexport function fromUserExtent(extent, destProjection) {\n if (!userProjection) {\n return extent;\n }\n return transformExtent(extent, userProjection, destProjection);\n}\n\n/**\n * Return the resolution in user projection units per pixel. If no user projection\n * is set, or source or user projection are missing units, the original resolution\n * is returned.\n * @param {number} resolution Resolution in input projection units per pixel.\n * @param {ProjectionLike} sourceProjection The input projection.\n * @return {number} Resolution in user projection units per pixel.\n */\nexport function toUserResolution(resolution, sourceProjection) {\n if (!userProjection) {\n return resolution;\n }\n const sourceMetersPerUnit = get(sourceProjection).getMetersPerUnit();\n const userMetersPerUnit = userProjection.getMetersPerUnit();\n return sourceMetersPerUnit && userMetersPerUnit\n ? (resolution * sourceMetersPerUnit) / userMetersPerUnit\n : resolution;\n}\n\n/**\n * Return the resolution in user projection units per pixel. If no user projection\n * is set, or source or user projection are missing units, the original resolution\n * is returned.\n * @param {number} resolution Resolution in user projection units per pixel.\n * @param {ProjectionLike} destProjection The destination projection.\n * @return {number} Resolution in destination projection units per pixel.\n */\nexport function fromUserResolution(resolution, destProjection) {\n if (!userProjection) {\n return resolution;\n }\n const destMetersPerUnit = get(destProjection).getMetersPerUnit();\n const userMetersPerUnit = userProjection.getMetersPerUnit();\n return destMetersPerUnit && userMetersPerUnit\n ? (resolution * userMetersPerUnit) / destMetersPerUnit\n : resolution;\n}\n\n/**\n * Creates a safe coordinate transform function from a coordinate transform function.\n * \"Safe\" means that it can handle wrapping of x-coordinates for global projections,\n * and that coordinates exceeding the source projection validity extent's range will be\n * clamped to the validity range.\n * @param {Projection} sourceProj Source projection.\n * @param {Projection} destProj Destination projection.\n * @param {function(import(\"./coordinate.js\").Coordinate): import(\"./coordinate.js\").Coordinate} transform Transform function (source to destination).\n * @return {function(import(\"./coordinate.js\").Coordinate): import(\"./coordinate.js\").Coordinate} Safe transform function (source to destination).\n */\nexport function createSafeCoordinateTransform(sourceProj, destProj, transform) {\n return function (coord) {\n let transformed, worldsAway;\n if (sourceProj.canWrapX()) {\n const sourceExtent = sourceProj.getExtent();\n const sourceExtentWidth = getWidth(sourceExtent);\n coord = coord.slice(0);\n worldsAway = getWorldsAway(coord, sourceProj, sourceExtentWidth);\n if (worldsAway) {\n // Move x to the real world\n coord[0] = coord[0] - worldsAway * sourceExtentWidth;\n }\n coord[0] = clamp(coord[0], sourceExtent[0], sourceExtent[2]);\n coord[1] = clamp(coord[1], sourceExtent[1], sourceExtent[3]);\n transformed = transform(coord);\n } else {\n transformed = transform(coord);\n }\n if (worldsAway && destProj.canWrapX()) {\n // Move transformed coordinate back to the offset world\n transformed[0] += worldsAway * getWidth(destProj.getExtent());\n }\n return transformed;\n };\n}\n\n/**\n * Add transforms to and from EPSG:4326 and EPSG:3857. This function is called\n * by when this module is executed and should only need to be called again after\n * `clearAllProjections()` is called (e.g. in tests).\n */\nexport function addCommon() {\n // Add transformations that don't alter coordinates to convert within set of\n // projections with equal meaning.\n addEquivalentProjections(EPSG3857_PROJECTIONS);\n addEquivalentProjections(EPSG4326_PROJECTIONS);\n // Add transformations to convert EPSG:4326 like coordinates to EPSG:3857 like\n // coordinates and back.\n addEquivalentTransforms(\n EPSG4326_PROJECTIONS,\n EPSG3857_PROJECTIONS,\n fromEPSG4326,\n toEPSG4326,\n );\n}\n\naddCommon();\n","/**\n * @module ol/geom/flat/transform\n */\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {number} end End.\n * @param {number} stride Stride.\n * @param {import(\"../../transform.js\").Transform} transform Transform.\n * @param {Array} [dest] Destination.\n * @return {Array} Transformed coordinates.\n */\nexport function transform2D(\n flatCoordinates,\n offset,\n end,\n stride,\n transform,\n dest,\n) {\n dest = dest ? dest : [];\n let i = 0;\n for (let j = offset; j < end; j += stride) {\n const x = flatCoordinates[j];\n const y = flatCoordinates[j + 1];\n dest[i++] = transform[0] * x + transform[2] * y + transform[4];\n dest[i++] = transform[1] * x + transform[3] * y + transform[5];\n }\n if (dest && dest.length != i) {\n dest.length = i;\n }\n return dest;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {number} end End.\n * @param {number} stride Stride.\n * @param {number} angle Angle.\n * @param {Array} anchor Rotation anchor point.\n * @param {Array} [dest] Destination.\n * @return {Array} Transformed coordinates.\n */\nexport function rotate(\n flatCoordinates,\n offset,\n end,\n stride,\n angle,\n anchor,\n dest,\n) {\n dest = dest ? dest : [];\n const cos = Math.cos(angle);\n const sin = Math.sin(angle);\n const anchorX = anchor[0];\n const anchorY = anchor[1];\n let i = 0;\n for (let j = offset; j < end; j += stride) {\n const deltaX = flatCoordinates[j] - anchorX;\n const deltaY = flatCoordinates[j + 1] - anchorY;\n dest[i++] = anchorX + deltaX * cos - deltaY * sin;\n dest[i++] = anchorY + deltaX * sin + deltaY * cos;\n for (let k = j + 2; k < j + stride; ++k) {\n dest[i++] = flatCoordinates[k];\n }\n }\n if (dest && dest.length != i) {\n dest.length = i;\n }\n return dest;\n}\n\n/**\n * Scale the coordinates.\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {number} end End.\n * @param {number} stride Stride.\n * @param {number} sx Scale factor in the x-direction.\n * @param {number} sy Scale factor in the y-direction.\n * @param {Array} anchor Scale anchor point.\n * @param {Array} [dest] Destination.\n * @return {Array} Transformed coordinates.\n */\nexport function scale(\n flatCoordinates,\n offset,\n end,\n stride,\n sx,\n sy,\n anchor,\n dest,\n) {\n dest = dest ? dest : [];\n const anchorX = anchor[0];\n const anchorY = anchor[1];\n let i = 0;\n for (let j = offset; j < end; j += stride) {\n const deltaX = flatCoordinates[j] - anchorX;\n const deltaY = flatCoordinates[j + 1] - anchorY;\n dest[i++] = anchorX + sx * deltaX;\n dest[i++] = anchorY + sy * deltaY;\n for (let k = j + 2; k < j + stride; ++k) {\n dest[i++] = flatCoordinates[k];\n }\n }\n if (dest && dest.length != i) {\n dest.length = i;\n }\n return dest;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {number} end End.\n * @param {number} stride Stride.\n * @param {number} deltaX Delta X.\n * @param {number} deltaY Delta Y.\n * @param {Array} [dest] Destination.\n * @return {Array} Transformed coordinates.\n */\nexport function translate(\n flatCoordinates,\n offset,\n end,\n stride,\n deltaX,\n deltaY,\n dest,\n) {\n dest = dest ? dest : [];\n let i = 0;\n for (let j = offset; j < end; j += stride) {\n dest[i++] = flatCoordinates[j] + deltaX;\n dest[i++] = flatCoordinates[j + 1] + deltaY;\n for (let k = j + 2; k < j + stride; ++k) {\n dest[i++] = flatCoordinates[k];\n }\n }\n if (dest && dest.length != i) {\n dest.length = i;\n }\n return dest;\n}\n","/**\n * @module ol/geom/Geometry\n */\nimport BaseObject from '../Object.js';\nimport {abstract} from '../util.js';\nimport {\n compose as composeTransform,\n create as createTransform,\n} from '../transform.js';\nimport {\n createEmpty,\n createOrUpdateEmpty,\n getHeight,\n returnOrUpdate,\n} from '../extent.js';\nimport {get as getProjection, getTransform} from '../proj.js';\nimport {memoizeOne} from '../functions.js';\nimport {transform2D} from './flat/transform.js';\n\n/**\n * @typedef {'XY' | 'XYZ' | 'XYM' | 'XYZM'} GeometryLayout\n * The coordinate layout for geometries, indicating whether a 3rd or 4th z ('Z')\n * or measure ('M') coordinate is available.\n */\n\n/**\n * @typedef {'Point' | 'LineString' | 'LinearRing' | 'Polygon' | 'MultiPoint' | 'MultiLineString' | 'MultiPolygon' | 'GeometryCollection' | 'Circle'} Type\n * The geometry type. One of `'Point'`, `'LineString'`, `'LinearRing'`,\n * `'Polygon'`, `'MultiPoint'`, `'MultiLineString'`, `'MultiPolygon'`,\n * `'GeometryCollection'`, or `'Circle'`.\n */\n\n/**\n * @type {import(\"../transform.js\").Transform}\n */\nconst tmpTransform = createTransform();\n\n/**\n * @classdesc\n * Abstract base class; normally only used for creating subclasses and not\n * instantiated in apps.\n * Base class for vector geometries.\n *\n * To get notified of changes to the geometry, register a listener for the\n * generic `change` event on your geometry instance.\n *\n * @abstract\n * @api\n */\nclass Geometry extends BaseObject {\n constructor() {\n super();\n\n /**\n * @private\n * @type {import(\"../extent.js\").Extent}\n */\n this.extent_ = createEmpty();\n\n /**\n * @private\n * @type {number}\n */\n this.extentRevision_ = -1;\n\n /**\n * @protected\n * @type {number}\n */\n this.simplifiedGeometryMaxMinSquaredTolerance = 0;\n\n /**\n * @protected\n * @type {number}\n */\n this.simplifiedGeometryRevision = 0;\n\n /**\n * Get a transformed and simplified version of the geometry.\n * @abstract\n * @param {number} revision The geometry revision.\n * @param {number} squaredTolerance Squared tolerance.\n * @param {import(\"../proj.js\").TransformFunction} [transform] Optional transform function.\n * @return {Geometry} Simplified geometry.\n */\n this.simplifyTransformedInternal = memoizeOne(\n (revision, squaredTolerance, transform) => {\n if (!transform) {\n return this.getSimplifiedGeometry(squaredTolerance);\n }\n const clone = this.clone();\n clone.applyTransform(transform);\n return clone.getSimplifiedGeometry(squaredTolerance);\n },\n );\n }\n\n /**\n * Get a transformed and simplified version of the geometry.\n * @abstract\n * @param {number} squaredTolerance Squared tolerance.\n * @param {import(\"../proj.js\").TransformFunction} [transform] Optional transform function.\n * @return {Geometry} Simplified geometry.\n */\n simplifyTransformed(squaredTolerance, transform) {\n return this.simplifyTransformedInternal(\n this.getRevision(),\n squaredTolerance,\n transform,\n );\n }\n\n /**\n * Make a complete copy of the geometry.\n * @abstract\n * @return {!Geometry} Clone.\n */\n clone() {\n return abstract();\n }\n\n /**\n * @abstract\n * @param {number} x X.\n * @param {number} y Y.\n * @param {import(\"../coordinate.js\").Coordinate} closestPoint Closest point.\n * @param {number} minSquaredDistance Minimum squared distance.\n * @return {number} Minimum squared distance.\n */\n closestPointXY(x, y, closestPoint, minSquaredDistance) {\n return abstract();\n }\n\n /**\n * @param {number} x X.\n * @param {number} y Y.\n * @return {boolean} Contains (x, y).\n */\n containsXY(x, y) {\n const coord = this.getClosestPoint([x, y]);\n return coord[0] === x && coord[1] === y;\n }\n\n /**\n * Return the closest point of the geometry to the passed point as\n * {@link module:ol/coordinate~Coordinate coordinate}.\n * @param {import(\"../coordinate.js\").Coordinate} point Point.\n * @param {import(\"../coordinate.js\").Coordinate} [closestPoint] Closest point.\n * @return {import(\"../coordinate.js\").Coordinate} Closest point.\n * @api\n */\n getClosestPoint(point, closestPoint) {\n closestPoint = closestPoint ? closestPoint : [NaN, NaN];\n this.closestPointXY(point[0], point[1], closestPoint, Infinity);\n return closestPoint;\n }\n\n /**\n * Returns true if this geometry includes the specified coordinate. If the\n * coordinate is on the boundary of the geometry, returns false.\n * @param {import(\"../coordinate.js\").Coordinate} coordinate Coordinate.\n * @return {boolean} Contains coordinate.\n * @api\n */\n intersectsCoordinate(coordinate) {\n return this.containsXY(coordinate[0], coordinate[1]);\n }\n\n /**\n * @abstract\n * @param {import(\"../extent.js\").Extent} extent Extent.\n * @protected\n * @return {import(\"../extent.js\").Extent} extent Extent.\n */\n computeExtent(extent) {\n return abstract();\n }\n\n /**\n * Get the extent of the geometry.\n * @param {import(\"../extent.js\").Extent} [extent] Extent.\n * @return {import(\"../extent.js\").Extent} extent Extent.\n * @api\n */\n getExtent(extent) {\n if (this.extentRevision_ != this.getRevision()) {\n const extent = this.computeExtent(this.extent_);\n if (isNaN(extent[0]) || isNaN(extent[1])) {\n createOrUpdateEmpty(extent);\n }\n this.extentRevision_ = this.getRevision();\n }\n return returnOrUpdate(this.extent_, extent);\n }\n\n /**\n * Rotate the geometry around a given coordinate. This modifies the geometry\n * coordinates in place.\n * @abstract\n * @param {number} angle Rotation angle in radians.\n * @param {import(\"../coordinate.js\").Coordinate} anchor The rotation center.\n * @api\n */\n rotate(angle, anchor) {\n abstract();\n }\n\n /**\n * Scale the geometry (with an optional origin). This modifies the geometry\n * coordinates in place.\n * @abstract\n * @param {number} sx The scaling factor in the x-direction.\n * @param {number} [sy] The scaling factor in the y-direction (defaults to sx).\n * @param {import(\"../coordinate.js\").Coordinate} [anchor] The scale origin (defaults to the center\n * of the geometry extent).\n * @api\n */\n scale(sx, sy, anchor) {\n abstract();\n }\n\n /**\n * Create a simplified version of this geometry. For linestrings, this uses\n * the [Douglas Peucker](https://en.wikipedia.org/wiki/Ramer-Douglas-Peucker_algorithm)\n * algorithm. For polygons, a quantization-based\n * simplification is used to preserve topology.\n * @param {number} tolerance The tolerance distance for simplification.\n * @return {Geometry} A new, simplified version of the original geometry.\n * @api\n */\n simplify(tolerance) {\n return this.getSimplifiedGeometry(tolerance * tolerance);\n }\n\n /**\n * Create a simplified version of this geometry using the Douglas Peucker\n * algorithm.\n * See https://en.wikipedia.org/wiki/Ramer-Douglas-Peucker_algorithm.\n * @abstract\n * @param {number} squaredTolerance Squared tolerance.\n * @return {Geometry} Simplified geometry.\n */\n getSimplifiedGeometry(squaredTolerance) {\n return abstract();\n }\n\n /**\n * Get the type of this geometry.\n * @abstract\n * @return {Type} Geometry type.\n */\n getType() {\n return abstract();\n }\n\n /**\n * Apply a transform function to the coordinates of the geometry.\n * The geometry is modified in place.\n * If you do not want the geometry modified in place, first `clone()` it and\n * then use this function on the clone.\n * @abstract\n * @param {import(\"../proj.js\").TransformFunction} transformFn Transform function.\n * Called with a flat array of geometry coordinates.\n */\n applyTransform(transformFn) {\n abstract();\n }\n\n /**\n * Test if the geometry and the passed extent intersect.\n * @abstract\n * @param {import(\"../extent.js\").Extent} extent Extent.\n * @return {boolean} `true` if the geometry and the extent intersect.\n */\n intersectsExtent(extent) {\n return abstract();\n }\n\n /**\n * Translate the geometry. This modifies the geometry coordinates in place. If\n * instead you want a new geometry, first `clone()` this geometry.\n * @abstract\n * @param {number} deltaX Delta X.\n * @param {number} deltaY Delta Y.\n * @api\n */\n translate(deltaX, deltaY) {\n abstract();\n }\n\n /**\n * Transform each coordinate of the geometry from one coordinate reference\n * system to another. The geometry is modified in place.\n * For example, a line will be transformed to a line and a circle to a circle.\n * If you do not want the geometry modified in place, first `clone()` it and\n * then use this function on the clone.\n *\n * @param {import(\"../proj.js\").ProjectionLike} source The current projection. Can be a\n * string identifier or a {@link module:ol/proj/Projection~Projection} object.\n * @param {import(\"../proj.js\").ProjectionLike} destination The desired projection. Can be a\n * string identifier or a {@link module:ol/proj/Projection~Projection} object.\n * @return {this} This geometry. Note that original geometry is\n * modified in place.\n * @api\n */\n transform(source, destination) {\n /** @type {import(\"../proj/Projection.js\").default} */\n const sourceProj = getProjection(source);\n const transformFn =\n sourceProj.getUnits() == 'tile-pixels'\n ? function (inCoordinates, outCoordinates, stride) {\n const pixelExtent = sourceProj.getExtent();\n const projectedExtent = sourceProj.getWorldExtent();\n const scale = getHeight(projectedExtent) / getHeight(pixelExtent);\n composeTransform(\n tmpTransform,\n projectedExtent[0],\n projectedExtent[3],\n scale,\n -scale,\n 0,\n 0,\n 0,\n );\n transform2D(\n inCoordinates,\n 0,\n inCoordinates.length,\n stride,\n tmpTransform,\n outCoordinates,\n );\n return getTransform(sourceProj, destination)(\n inCoordinates,\n outCoordinates,\n stride,\n );\n }\n : getTransform(sourceProj, destination);\n this.applyTransform(transformFn);\n return this;\n }\n}\n\nexport default Geometry;\n","/**\n * @module ol/geom/SimpleGeometry\n */\nimport Geometry from './Geometry.js';\nimport {abstract} from '../util.js';\nimport {createOrUpdateFromFlatCoordinates, getCenter} from '../extent.js';\nimport {rotate, scale, transform2D, translate} from './flat/transform.js';\n\n/**\n * @classdesc\n * Abstract base class; only used for creating subclasses; do not instantiate\n * in apps, as cannot be rendered.\n *\n * @abstract\n * @api\n */\nclass SimpleGeometry extends Geometry {\n constructor() {\n super();\n\n /**\n * @protected\n * @type {import(\"./Geometry.js\").GeometryLayout}\n */\n this.layout = 'XY';\n\n /**\n * @protected\n * @type {number}\n */\n this.stride = 2;\n\n /**\n * @protected\n * @type {Array}\n */\n this.flatCoordinates;\n }\n\n /**\n * @param {import(\"../extent.js\").Extent} extent Extent.\n * @protected\n * @return {import(\"../extent.js\").Extent} extent Extent.\n */\n computeExtent(extent) {\n return createOrUpdateFromFlatCoordinates(\n this.flatCoordinates,\n 0,\n this.flatCoordinates.length,\n this.stride,\n extent,\n );\n }\n\n /**\n * @abstract\n * @return {Array<*> | null} Coordinates.\n */\n getCoordinates() {\n return abstract();\n }\n\n /**\n * Return the first coordinate of the geometry.\n * @return {import(\"../coordinate.js\").Coordinate} First coordinate.\n * @api\n */\n getFirstCoordinate() {\n return this.flatCoordinates.slice(0, this.stride);\n }\n\n /**\n * @return {Array} Flat coordinates.\n */\n getFlatCoordinates() {\n return this.flatCoordinates;\n }\n\n /**\n * Return the last coordinate of the geometry.\n * @return {import(\"../coordinate.js\").Coordinate} Last point.\n * @api\n */\n getLastCoordinate() {\n return this.flatCoordinates.slice(\n this.flatCoordinates.length - this.stride,\n );\n }\n\n /**\n * Return the {@link import(\"./Geometry.js\").GeometryLayout layout} of the geometry.\n * @return {import(\"./Geometry.js\").GeometryLayout} Layout.\n * @api\n */\n getLayout() {\n return this.layout;\n }\n\n /**\n * Create a simplified version of this geometry using the Douglas Peucker algorithm.\n * @param {number} squaredTolerance Squared tolerance.\n * @return {SimpleGeometry} Simplified geometry.\n */\n getSimplifiedGeometry(squaredTolerance) {\n if (this.simplifiedGeometryRevision !== this.getRevision()) {\n this.simplifiedGeometryMaxMinSquaredTolerance = 0;\n this.simplifiedGeometryRevision = this.getRevision();\n }\n // If squaredTolerance is negative or if we know that simplification will not\n // have any effect then just return this.\n if (\n squaredTolerance < 0 ||\n (this.simplifiedGeometryMaxMinSquaredTolerance !== 0 &&\n squaredTolerance <= this.simplifiedGeometryMaxMinSquaredTolerance)\n ) {\n return this;\n }\n\n const simplifiedGeometry =\n this.getSimplifiedGeometryInternal(squaredTolerance);\n const simplifiedFlatCoordinates = simplifiedGeometry.getFlatCoordinates();\n if (simplifiedFlatCoordinates.length < this.flatCoordinates.length) {\n return simplifiedGeometry;\n }\n // Simplification did not actually remove any coordinates. We now know\n // that any calls to getSimplifiedGeometry with a squaredTolerance less\n // than or equal to the current squaredTolerance will also not have any\n // effect. This allows us to short circuit simplification (saving CPU\n // cycles) and prevents the cache of simplified geometries from filling\n // up with useless identical copies of this geometry (saving memory).\n this.simplifiedGeometryMaxMinSquaredTolerance = squaredTolerance;\n return this;\n }\n\n /**\n * @param {number} squaredTolerance Squared tolerance.\n * @return {SimpleGeometry} Simplified geometry.\n * @protected\n */\n getSimplifiedGeometryInternal(squaredTolerance) {\n return this;\n }\n\n /**\n * @return {number} Stride.\n */\n getStride() {\n return this.stride;\n }\n\n /**\n * @param {import(\"./Geometry.js\").GeometryLayout} layout Layout.\n * @param {Array} flatCoordinates Flat coordinates.\n */\n setFlatCoordinates(layout, flatCoordinates) {\n this.stride = getStrideForLayout(layout);\n this.layout = layout;\n this.flatCoordinates = flatCoordinates;\n }\n\n /**\n * @abstract\n * @param {!Array<*>} coordinates Coordinates.\n * @param {import(\"./Geometry.js\").GeometryLayout} [layout] Layout.\n */\n setCoordinates(coordinates, layout) {\n abstract();\n }\n\n /**\n * @param {import(\"./Geometry.js\").GeometryLayout|undefined} layout Layout.\n * @param {Array<*>} coordinates Coordinates.\n * @param {number} nesting Nesting.\n * @protected\n */\n setLayout(layout, coordinates, nesting) {\n let stride;\n if (layout) {\n stride = getStrideForLayout(layout);\n } else {\n for (let i = 0; i < nesting; ++i) {\n if (coordinates.length === 0) {\n this.layout = 'XY';\n this.stride = 2;\n return;\n }\n coordinates = /** @type {Array} */ (coordinates[0]);\n }\n stride = coordinates.length;\n layout = getLayoutForStride(stride);\n }\n this.layout = layout;\n this.stride = stride;\n }\n\n /**\n * Apply a transform function to the coordinates of the geometry.\n * The geometry is modified in place.\n * If you do not want the geometry modified in place, first `clone()` it and\n * then use this function on the clone.\n * @param {import(\"../proj.js\").TransformFunction} transformFn Transform function.\n * Called with a flat array of geometry coordinates.\n * @api\n */\n applyTransform(transformFn) {\n if (this.flatCoordinates) {\n transformFn(this.flatCoordinates, this.flatCoordinates, this.stride);\n this.changed();\n }\n }\n\n /**\n * Rotate the geometry around a given coordinate. This modifies the geometry\n * coordinates in place.\n * @param {number} angle Rotation angle in counter-clockwise radians.\n * @param {import(\"../coordinate.js\").Coordinate} anchor The rotation center.\n * @api\n */\n rotate(angle, anchor) {\n const flatCoordinates = this.getFlatCoordinates();\n if (flatCoordinates) {\n const stride = this.getStride();\n rotate(\n flatCoordinates,\n 0,\n flatCoordinates.length,\n stride,\n angle,\n anchor,\n flatCoordinates,\n );\n this.changed();\n }\n }\n\n /**\n * Scale the geometry (with an optional origin). This modifies the geometry\n * coordinates in place.\n * @param {number} sx The scaling factor in the x-direction.\n * @param {number} [sy] The scaling factor in the y-direction (defaults to sx).\n * @param {import(\"../coordinate.js\").Coordinate} [anchor] The scale origin (defaults to the center\n * of the geometry extent).\n * @api\n */\n scale(sx, sy, anchor) {\n if (sy === undefined) {\n sy = sx;\n }\n if (!anchor) {\n anchor = getCenter(this.getExtent());\n }\n const flatCoordinates = this.getFlatCoordinates();\n if (flatCoordinates) {\n const stride = this.getStride();\n scale(\n flatCoordinates,\n 0,\n flatCoordinates.length,\n stride,\n sx,\n sy,\n anchor,\n flatCoordinates,\n );\n this.changed();\n }\n }\n\n /**\n * Translate the geometry. This modifies the geometry coordinates in place. If\n * instead you want a new geometry, first `clone()` this geometry.\n * @param {number} deltaX Delta X.\n * @param {number} deltaY Delta Y.\n * @api\n */\n translate(deltaX, deltaY) {\n const flatCoordinates = this.getFlatCoordinates();\n if (flatCoordinates) {\n const stride = this.getStride();\n translate(\n flatCoordinates,\n 0,\n flatCoordinates.length,\n stride,\n deltaX,\n deltaY,\n flatCoordinates,\n );\n this.changed();\n }\n }\n}\n\n/**\n * @param {number} stride Stride.\n * @return {import(\"./Geometry.js\").GeometryLayout} layout Layout.\n */\nexport function getLayoutForStride(stride) {\n let layout;\n if (stride == 2) {\n layout = 'XY';\n } else if (stride == 3) {\n layout = 'XYZ';\n } else if (stride == 4) {\n layout = 'XYZM';\n }\n return /** @type {import(\"./Geometry.js\").GeometryLayout} */ (layout);\n}\n\n/**\n * @param {import(\"./Geometry.js\").GeometryLayout} layout Layout.\n * @return {number} Stride.\n */\nexport function getStrideForLayout(layout) {\n let stride;\n if (layout == 'XY') {\n stride = 2;\n } else if (layout == 'XYZ' || layout == 'XYM') {\n stride = 3;\n } else if (layout == 'XYZM') {\n stride = 4;\n }\n return /** @type {number} */ (stride);\n}\n\n/**\n * @param {SimpleGeometry} simpleGeometry Simple geometry.\n * @param {import(\"../transform.js\").Transform} transform Transform.\n * @param {Array} [dest] Destination.\n * @return {Array} Transformed flat coordinates.\n */\nexport function transformGeom2D(simpleGeometry, transform, dest) {\n const flatCoordinates = simpleGeometry.getFlatCoordinates();\n if (!flatCoordinates) {\n return null;\n }\n const stride = simpleGeometry.getStride();\n return transform2D(\n flatCoordinates,\n 0,\n flatCoordinates.length,\n stride,\n transform,\n dest,\n );\n}\n\nexport default SimpleGeometry;\n","/**\n * @module ol/geom/flat/closest\n */\nimport {lerp, squaredDistance as squaredDx} from '../../math.js';\n\n/**\n * Returns the point on the 2D line segment flatCoordinates[offset1] to\n * flatCoordinates[offset2] that is closest to the point (x, y). Extra\n * dimensions are linearly interpolated.\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset1 Offset 1.\n * @param {number} offset2 Offset 2.\n * @param {number} stride Stride.\n * @param {number} x X.\n * @param {number} y Y.\n * @param {Array} closestPoint Closest point.\n */\nfunction assignClosest(\n flatCoordinates,\n offset1,\n offset2,\n stride,\n x,\n y,\n closestPoint,\n) {\n const x1 = flatCoordinates[offset1];\n const y1 = flatCoordinates[offset1 + 1];\n const dx = flatCoordinates[offset2] - x1;\n const dy = flatCoordinates[offset2 + 1] - y1;\n let offset;\n if (dx === 0 && dy === 0) {\n offset = offset1;\n } else {\n const t = ((x - x1) * dx + (y - y1) * dy) / (dx * dx + dy * dy);\n if (t > 1) {\n offset = offset2;\n } else if (t > 0) {\n for (let i = 0; i < stride; ++i) {\n closestPoint[i] = lerp(\n flatCoordinates[offset1 + i],\n flatCoordinates[offset2 + i],\n t,\n );\n }\n closestPoint.length = stride;\n return;\n } else {\n offset = offset1;\n }\n }\n for (let i = 0; i < stride; ++i) {\n closestPoint[i] = flatCoordinates[offset + i];\n }\n closestPoint.length = stride;\n}\n\n/**\n * Return the squared of the largest distance between any pair of consecutive\n * coordinates.\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {number} end End.\n * @param {number} stride Stride.\n * @param {number} max Max squared delta.\n * @return {number} Max squared delta.\n */\nexport function maxSquaredDelta(flatCoordinates, offset, end, stride, max) {\n let x1 = flatCoordinates[offset];\n let y1 = flatCoordinates[offset + 1];\n for (offset += stride; offset < end; offset += stride) {\n const x2 = flatCoordinates[offset];\n const y2 = flatCoordinates[offset + 1];\n const squaredDelta = squaredDx(x1, y1, x2, y2);\n if (squaredDelta > max) {\n max = squaredDelta;\n }\n x1 = x2;\n y1 = y2;\n }\n return max;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {Array} ends Ends.\n * @param {number} stride Stride.\n * @param {number} max Max squared delta.\n * @return {number} Max squared delta.\n */\nexport function arrayMaxSquaredDelta(\n flatCoordinates,\n offset,\n ends,\n stride,\n max,\n) {\n for (let i = 0, ii = ends.length; i < ii; ++i) {\n const end = ends[i];\n max = maxSquaredDelta(flatCoordinates, offset, end, stride, max);\n offset = end;\n }\n return max;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {Array>} endss Endss.\n * @param {number} stride Stride.\n * @param {number} max Max squared delta.\n * @return {number} Max squared delta.\n */\nexport function multiArrayMaxSquaredDelta(\n flatCoordinates,\n offset,\n endss,\n stride,\n max,\n) {\n for (let i = 0, ii = endss.length; i < ii; ++i) {\n const ends = endss[i];\n max = arrayMaxSquaredDelta(flatCoordinates, offset, ends, stride, max);\n offset = ends[ends.length - 1];\n }\n return max;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {number} end End.\n * @param {number} stride Stride.\n * @param {number} maxDelta Max delta.\n * @param {boolean} isRing Is ring.\n * @param {number} x X.\n * @param {number} y Y.\n * @param {Array} closestPoint Closest point.\n * @param {number} minSquaredDistance Minimum squared distance.\n * @param {Array} [tmpPoint] Temporary point object.\n * @return {number} Minimum squared distance.\n */\nexport function assignClosestPoint(\n flatCoordinates,\n offset,\n end,\n stride,\n maxDelta,\n isRing,\n x,\n y,\n closestPoint,\n minSquaredDistance,\n tmpPoint,\n) {\n if (offset == end) {\n return minSquaredDistance;\n }\n let i, squaredDistance;\n if (maxDelta === 0) {\n // All points are identical, so just test the first point.\n squaredDistance = squaredDx(\n x,\n y,\n flatCoordinates[offset],\n flatCoordinates[offset + 1],\n );\n if (squaredDistance < minSquaredDistance) {\n for (i = 0; i < stride; ++i) {\n closestPoint[i] = flatCoordinates[offset + i];\n }\n closestPoint.length = stride;\n return squaredDistance;\n }\n return minSquaredDistance;\n }\n tmpPoint = tmpPoint ? tmpPoint : [NaN, NaN];\n let index = offset + stride;\n while (index < end) {\n assignClosest(\n flatCoordinates,\n index - stride,\n index,\n stride,\n x,\n y,\n tmpPoint,\n );\n squaredDistance = squaredDx(x, y, tmpPoint[0], tmpPoint[1]);\n if (squaredDistance < minSquaredDistance) {\n minSquaredDistance = squaredDistance;\n for (i = 0; i < stride; ++i) {\n closestPoint[i] = tmpPoint[i];\n }\n closestPoint.length = stride;\n index += stride;\n } else {\n // Skip ahead multiple points, because we know that all the skipped\n // points cannot be any closer than the closest point we have found so\n // far. We know this because we know how close the current point is, how\n // close the closest point we have found so far is, and the maximum\n // distance between consecutive points. For example, if we're currently\n // at distance 10, the best we've found so far is 3, and that the maximum\n // distance between consecutive points is 2, then we'll need to skip at\n // least (10 - 3) / 2 == 3 (rounded down) points to have any chance of\n // finding a closer point. We use Math.max(..., 1) to ensure that we\n // always advance at least one point, to avoid an infinite loop.\n index +=\n stride *\n Math.max(\n ((Math.sqrt(squaredDistance) - Math.sqrt(minSquaredDistance)) /\n maxDelta) |\n 0,\n 1,\n );\n }\n }\n if (isRing) {\n // Check the closing segment.\n assignClosest(\n flatCoordinates,\n end - stride,\n offset,\n stride,\n x,\n y,\n tmpPoint,\n );\n squaredDistance = squaredDx(x, y, tmpPoint[0], tmpPoint[1]);\n if (squaredDistance < minSquaredDistance) {\n minSquaredDistance = squaredDistance;\n for (i = 0; i < stride; ++i) {\n closestPoint[i] = tmpPoint[i];\n }\n closestPoint.length = stride;\n }\n }\n return minSquaredDistance;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {Array} ends Ends.\n * @param {number} stride Stride.\n * @param {number} maxDelta Max delta.\n * @param {boolean} isRing Is ring.\n * @param {number} x X.\n * @param {number} y Y.\n * @param {Array} closestPoint Closest point.\n * @param {number} minSquaredDistance Minimum squared distance.\n * @param {Array} [tmpPoint] Temporary point object.\n * @return {number} Minimum squared distance.\n */\nexport function assignClosestArrayPoint(\n flatCoordinates,\n offset,\n ends,\n stride,\n maxDelta,\n isRing,\n x,\n y,\n closestPoint,\n minSquaredDistance,\n tmpPoint,\n) {\n tmpPoint = tmpPoint ? tmpPoint : [NaN, NaN];\n for (let i = 0, ii = ends.length; i < ii; ++i) {\n const end = ends[i];\n minSquaredDistance = assignClosestPoint(\n flatCoordinates,\n offset,\n end,\n stride,\n maxDelta,\n isRing,\n x,\n y,\n closestPoint,\n minSquaredDistance,\n tmpPoint,\n );\n offset = end;\n }\n return minSquaredDistance;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {Array>} endss Endss.\n * @param {number} stride Stride.\n * @param {number} maxDelta Max delta.\n * @param {boolean} isRing Is ring.\n * @param {number} x X.\n * @param {number} y Y.\n * @param {Array} closestPoint Closest point.\n * @param {number} minSquaredDistance Minimum squared distance.\n * @param {Array} [tmpPoint] Temporary point object.\n * @return {number} Minimum squared distance.\n */\nexport function assignClosestMultiArrayPoint(\n flatCoordinates,\n offset,\n endss,\n stride,\n maxDelta,\n isRing,\n x,\n y,\n closestPoint,\n minSquaredDistance,\n tmpPoint,\n) {\n tmpPoint = tmpPoint ? tmpPoint : [NaN, NaN];\n for (let i = 0, ii = endss.length; i < ii; ++i) {\n const ends = endss[i];\n minSquaredDistance = assignClosestArrayPoint(\n flatCoordinates,\n offset,\n ends,\n stride,\n maxDelta,\n isRing,\n x,\n y,\n closestPoint,\n minSquaredDistance,\n tmpPoint,\n );\n offset = ends[ends.length - 1];\n }\n return minSquaredDistance;\n}\n","/**\n * @module ol/geom/flat/deflate\n */\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {import(\"../../coordinate.js\").Coordinate} coordinate Coordinate.\n * @param {number} stride Stride.\n * @return {number} offset Offset.\n */\nexport function deflateCoordinate(flatCoordinates, offset, coordinate, stride) {\n for (let i = 0, ii = coordinate.length; i < ii; ++i) {\n flatCoordinates[offset++] = coordinate[i];\n }\n return offset;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {Array} coordinates Coordinates.\n * @param {number} stride Stride.\n * @return {number} offset Offset.\n */\nexport function deflateCoordinates(\n flatCoordinates,\n offset,\n coordinates,\n stride,\n) {\n for (let i = 0, ii = coordinates.length; i < ii; ++i) {\n const coordinate = coordinates[i];\n for (let j = 0; j < stride; ++j) {\n flatCoordinates[offset++] = coordinate[j];\n }\n }\n return offset;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {Array>} coordinatess Coordinatess.\n * @param {number} stride Stride.\n * @param {Array} [ends] Ends.\n * @return {Array} Ends.\n */\nexport function deflateCoordinatesArray(\n flatCoordinates,\n offset,\n coordinatess,\n stride,\n ends,\n) {\n ends = ends ? ends : [];\n let i = 0;\n for (let j = 0, jj = coordinatess.length; j < jj; ++j) {\n const end = deflateCoordinates(\n flatCoordinates,\n offset,\n coordinatess[j],\n stride,\n );\n ends[i++] = end;\n offset = end;\n }\n ends.length = i;\n return ends;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {Array>>} coordinatesss Coordinatesss.\n * @param {number} stride Stride.\n * @param {Array>} [endss] Endss.\n * @return {Array>} Endss.\n */\nexport function deflateMultiCoordinatesArray(\n flatCoordinates,\n offset,\n coordinatesss,\n stride,\n endss,\n) {\n endss = endss ? endss : [];\n let i = 0;\n for (let j = 0, jj = coordinatesss.length; j < jj; ++j) {\n const ends = deflateCoordinatesArray(\n flatCoordinates,\n offset,\n coordinatesss[j],\n stride,\n endss[i],\n );\n if (ends.length === 0) {\n ends[0] = offset;\n }\n endss[i++] = ends;\n offset = ends[ends.length - 1];\n }\n endss.length = i;\n return endss;\n}\n","/**\n * @module ol/geom/flat/simplify\n */\n// Based on simplify-js https://github.com/mourner/simplify-js\n// Copyright (c) 2012, Vladimir Agafonkin\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are met:\n//\n// 1. Redistributions of source code must retain the above copyright notice,\n// this list of conditions and the following disclaimer.\n//\n// 2. Redistributions in binary form must reproduce the above copyright\n// notice, this list of conditions and the following disclaimer in the\n// documentation and/or other materials provided with the distribution.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE\n// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\n// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\n// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\n// POSSIBILITY OF SUCH DAMAGE.\n\nimport {squaredDistance, squaredSegmentDistance} from '../../math.js';\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {number} end End.\n * @param {number} stride Stride.\n * @param {number} squaredTolerance Squared tolerance.\n * @param {boolean} highQuality Highest quality.\n * @param {Array} [simplifiedFlatCoordinates] Simplified flat\n * coordinates.\n * @return {Array} Simplified line string.\n */\nexport function simplifyLineString(\n flatCoordinates,\n offset,\n end,\n stride,\n squaredTolerance,\n highQuality,\n simplifiedFlatCoordinates,\n) {\n simplifiedFlatCoordinates =\n simplifiedFlatCoordinates !== undefined ? simplifiedFlatCoordinates : [];\n if (!highQuality) {\n end = radialDistance(\n flatCoordinates,\n offset,\n end,\n stride,\n squaredTolerance,\n simplifiedFlatCoordinates,\n 0,\n );\n flatCoordinates = simplifiedFlatCoordinates;\n offset = 0;\n stride = 2;\n }\n simplifiedFlatCoordinates.length = douglasPeucker(\n flatCoordinates,\n offset,\n end,\n stride,\n squaredTolerance,\n simplifiedFlatCoordinates,\n 0,\n );\n return simplifiedFlatCoordinates;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {number} end End.\n * @param {number} stride Stride.\n * @param {number} squaredTolerance Squared tolerance.\n * @param {Array} simplifiedFlatCoordinates Simplified flat\n * coordinates.\n * @param {number} simplifiedOffset Simplified offset.\n * @return {number} Simplified offset.\n */\nexport function douglasPeucker(\n flatCoordinates,\n offset,\n end,\n stride,\n squaredTolerance,\n simplifiedFlatCoordinates,\n simplifiedOffset,\n) {\n const n = (end - offset) / stride;\n if (n < 3) {\n for (; offset < end; offset += stride) {\n simplifiedFlatCoordinates[simplifiedOffset++] = flatCoordinates[offset];\n simplifiedFlatCoordinates[simplifiedOffset++] =\n flatCoordinates[offset + 1];\n }\n return simplifiedOffset;\n }\n /** @type {Array} */\n const markers = new Array(n);\n markers[0] = 1;\n markers[n - 1] = 1;\n /** @type {Array} */\n const stack = [offset, end - stride];\n let index = 0;\n while (stack.length > 0) {\n const last = stack.pop();\n const first = stack.pop();\n let maxSquaredDistance = 0;\n const x1 = flatCoordinates[first];\n const y1 = flatCoordinates[first + 1];\n const x2 = flatCoordinates[last];\n const y2 = flatCoordinates[last + 1];\n for (let i = first + stride; i < last; i += stride) {\n const x = flatCoordinates[i];\n const y = flatCoordinates[i + 1];\n const squaredDistance = squaredSegmentDistance(x, y, x1, y1, x2, y2);\n if (squaredDistance > maxSquaredDistance) {\n index = i;\n maxSquaredDistance = squaredDistance;\n }\n }\n if (maxSquaredDistance > squaredTolerance) {\n markers[(index - offset) / stride] = 1;\n if (first + stride < index) {\n stack.push(first, index);\n }\n if (index + stride < last) {\n stack.push(index, last);\n }\n }\n }\n for (let i = 0; i < n; ++i) {\n if (markers[i]) {\n simplifiedFlatCoordinates[simplifiedOffset++] =\n flatCoordinates[offset + i * stride];\n simplifiedFlatCoordinates[simplifiedOffset++] =\n flatCoordinates[offset + i * stride + 1];\n }\n }\n return simplifiedOffset;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {Array} ends Ends.\n * @param {number} stride Stride.\n * @param {number} squaredTolerance Squared tolerance.\n * @param {Array} simplifiedFlatCoordinates Simplified flat\n * coordinates.\n * @param {number} simplifiedOffset Simplified offset.\n * @param {Array} simplifiedEnds Simplified ends.\n * @return {number} Simplified offset.\n */\nexport function douglasPeuckerArray(\n flatCoordinates,\n offset,\n ends,\n stride,\n squaredTolerance,\n simplifiedFlatCoordinates,\n simplifiedOffset,\n simplifiedEnds,\n) {\n for (let i = 0, ii = ends.length; i < ii; ++i) {\n const end = ends[i];\n simplifiedOffset = douglasPeucker(\n flatCoordinates,\n offset,\n end,\n stride,\n squaredTolerance,\n simplifiedFlatCoordinates,\n simplifiedOffset,\n );\n simplifiedEnds.push(simplifiedOffset);\n offset = end;\n }\n return simplifiedOffset;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {Array>} endss Endss.\n * @param {number} stride Stride.\n * @param {number} squaredTolerance Squared tolerance.\n * @param {Array} simplifiedFlatCoordinates Simplified flat\n * coordinates.\n * @param {number} simplifiedOffset Simplified offset.\n * @param {Array>} simplifiedEndss Simplified endss.\n * @return {number} Simplified offset.\n */\nexport function douglasPeuckerMultiArray(\n flatCoordinates,\n offset,\n endss,\n stride,\n squaredTolerance,\n simplifiedFlatCoordinates,\n simplifiedOffset,\n simplifiedEndss,\n) {\n for (let i = 0, ii = endss.length; i < ii; ++i) {\n const ends = endss[i];\n /** @type {Array} */\n const simplifiedEnds = [];\n simplifiedOffset = douglasPeuckerArray(\n flatCoordinates,\n offset,\n ends,\n stride,\n squaredTolerance,\n simplifiedFlatCoordinates,\n simplifiedOffset,\n simplifiedEnds,\n );\n simplifiedEndss.push(simplifiedEnds);\n offset = ends[ends.length - 1];\n }\n return simplifiedOffset;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {number} end End.\n * @param {number} stride Stride.\n * @param {number} squaredTolerance Squared tolerance.\n * @param {Array} simplifiedFlatCoordinates Simplified flat\n * coordinates.\n * @param {number} simplifiedOffset Simplified offset.\n * @return {number} Simplified offset.\n */\nexport function radialDistance(\n flatCoordinates,\n offset,\n end,\n stride,\n squaredTolerance,\n simplifiedFlatCoordinates,\n simplifiedOffset,\n) {\n if (end <= offset + stride) {\n // zero or one point, no simplification possible, so copy and return\n for (; offset < end; offset += stride) {\n simplifiedFlatCoordinates[simplifiedOffset++] = flatCoordinates[offset];\n simplifiedFlatCoordinates[simplifiedOffset++] =\n flatCoordinates[offset + 1];\n }\n return simplifiedOffset;\n }\n let x1 = flatCoordinates[offset];\n let y1 = flatCoordinates[offset + 1];\n // copy first point\n simplifiedFlatCoordinates[simplifiedOffset++] = x1;\n simplifiedFlatCoordinates[simplifiedOffset++] = y1;\n let x2 = x1;\n let y2 = y1;\n for (offset += stride; offset < end; offset += stride) {\n x2 = flatCoordinates[offset];\n y2 = flatCoordinates[offset + 1];\n if (squaredDistance(x1, y1, x2, y2) > squaredTolerance) {\n // copy point at offset\n simplifiedFlatCoordinates[simplifiedOffset++] = x2;\n simplifiedFlatCoordinates[simplifiedOffset++] = y2;\n x1 = x2;\n y1 = y2;\n }\n }\n if (x2 != x1 || y2 != y1) {\n // copy last point\n simplifiedFlatCoordinates[simplifiedOffset++] = x2;\n simplifiedFlatCoordinates[simplifiedOffset++] = y2;\n }\n return simplifiedOffset;\n}\n\n/**\n * @param {number} value Value.\n * @param {number} tolerance Tolerance.\n * @return {number} Rounded value.\n */\nexport function snap(value, tolerance) {\n return tolerance * Math.round(value / tolerance);\n}\n\n/**\n * Simplifies a line string using an algorithm designed by Tim Schaub.\n * Coordinates are snapped to the nearest value in a virtual grid and\n * consecutive duplicate coordinates are discarded. This effectively preserves\n * topology as the simplification of any subsection of a line string is\n * independent of the rest of the line string. This means that, for examples,\n * the common edge between two polygons will be simplified to the same line\n * string independently in both polygons. This implementation uses a single\n * pass over the coordinates and eliminates intermediate collinear points.\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {number} end End.\n * @param {number} stride Stride.\n * @param {number} tolerance Tolerance.\n * @param {Array} simplifiedFlatCoordinates Simplified flat\n * coordinates.\n * @param {number} simplifiedOffset Simplified offset.\n * @return {number} Simplified offset.\n */\nexport function quantize(\n flatCoordinates,\n offset,\n end,\n stride,\n tolerance,\n simplifiedFlatCoordinates,\n simplifiedOffset,\n) {\n // do nothing if the line is empty\n if (offset == end) {\n return simplifiedOffset;\n }\n // snap the first coordinate (P1)\n let x1 = snap(flatCoordinates[offset], tolerance);\n let y1 = snap(flatCoordinates[offset + 1], tolerance);\n offset += stride;\n // add the first coordinate to the output\n simplifiedFlatCoordinates[simplifiedOffset++] = x1;\n simplifiedFlatCoordinates[simplifiedOffset++] = y1;\n // find the next coordinate that does not snap to the same value as the first\n // coordinate (P2)\n let x2, y2;\n do {\n x2 = snap(flatCoordinates[offset], tolerance);\n y2 = snap(flatCoordinates[offset + 1], tolerance);\n offset += stride;\n if (offset == end) {\n // all coordinates snap to the same value, the line collapses to a point\n // push the last snapped value anyway to ensure that the output contains\n // at least two points\n // FIXME should we really return at least two points anyway?\n simplifiedFlatCoordinates[simplifiedOffset++] = x2;\n simplifiedFlatCoordinates[simplifiedOffset++] = y2;\n return simplifiedOffset;\n }\n } while (x2 == x1 && y2 == y1);\n while (offset < end) {\n // snap the next coordinate (P3)\n const x3 = snap(flatCoordinates[offset], tolerance);\n const y3 = snap(flatCoordinates[offset + 1], tolerance);\n offset += stride;\n // skip P3 if it is equal to P2\n if (x3 == x2 && y3 == y2) {\n continue;\n }\n // calculate the delta between P1 and P2\n const dx1 = x2 - x1;\n const dy1 = y2 - y1;\n // calculate the delta between P3 and P1\n const dx2 = x3 - x1;\n const dy2 = y3 - y1;\n // if P1, P2, and P3 are colinear and P3 is further from P1 than P2 is from\n // P1 in the same direction then P2 is on the straight line between P1 and\n // P3\n if (\n dx1 * dy2 == dy1 * dx2 &&\n ((dx1 < 0 && dx2 < dx1) || dx1 == dx2 || (dx1 > 0 && dx2 > dx1)) &&\n ((dy1 < 0 && dy2 < dy1) || dy1 == dy2 || (dy1 > 0 && dy2 > dy1))\n ) {\n // discard P2 and set P2 = P3\n x2 = x3;\n y2 = y3;\n continue;\n }\n // either P1, P2, and P3 are not colinear, or they are colinear but P3 is\n // between P3 and P1 or on the opposite half of the line to P2. add P2,\n // and continue with P1 = P2 and P2 = P3\n simplifiedFlatCoordinates[simplifiedOffset++] = x2;\n simplifiedFlatCoordinates[simplifiedOffset++] = y2;\n x1 = x2;\n y1 = y2;\n x2 = x3;\n y2 = y3;\n }\n // add the last point (P2)\n simplifiedFlatCoordinates[simplifiedOffset++] = x2;\n simplifiedFlatCoordinates[simplifiedOffset++] = y2;\n return simplifiedOffset;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {Array} ends Ends.\n * @param {number} stride Stride.\n * @param {number} tolerance Tolerance.\n * @param {Array} simplifiedFlatCoordinates Simplified flat\n * coordinates.\n * @param {number} simplifiedOffset Simplified offset.\n * @param {Array} simplifiedEnds Simplified ends.\n * @return {number} Simplified offset.\n */\nexport function quantizeArray(\n flatCoordinates,\n offset,\n ends,\n stride,\n tolerance,\n simplifiedFlatCoordinates,\n simplifiedOffset,\n simplifiedEnds,\n) {\n for (let i = 0, ii = ends.length; i < ii; ++i) {\n const end = ends[i];\n simplifiedOffset = quantize(\n flatCoordinates,\n offset,\n end,\n stride,\n tolerance,\n simplifiedFlatCoordinates,\n simplifiedOffset,\n );\n simplifiedEnds.push(simplifiedOffset);\n offset = end;\n }\n return simplifiedOffset;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {Array>} endss Endss.\n * @param {number} stride Stride.\n * @param {number} tolerance Tolerance.\n * @param {Array} simplifiedFlatCoordinates Simplified flat\n * coordinates.\n * @param {number} simplifiedOffset Simplified offset.\n * @param {Array>} simplifiedEndss Simplified endss.\n * @return {number} Simplified offset.\n */\nexport function quantizeMultiArray(\n flatCoordinates,\n offset,\n endss,\n stride,\n tolerance,\n simplifiedFlatCoordinates,\n simplifiedOffset,\n simplifiedEndss,\n) {\n for (let i = 0, ii = endss.length; i < ii; ++i) {\n const ends = endss[i];\n /** @type {Array} */\n const simplifiedEnds = [];\n simplifiedOffset = quantizeArray(\n flatCoordinates,\n offset,\n ends,\n stride,\n tolerance,\n simplifiedFlatCoordinates,\n simplifiedOffset,\n simplifiedEnds,\n );\n simplifiedEndss.push(simplifiedEnds);\n offset = ends[ends.length - 1];\n }\n return simplifiedOffset;\n}\n","/**\n * @module ol/geom/flat/inflate\n */\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {number} end End.\n * @param {number} stride Stride.\n * @param {Array} [coordinates] Coordinates.\n * @return {Array} Coordinates.\n */\nexport function inflateCoordinates(\n flatCoordinates,\n offset,\n end,\n stride,\n coordinates,\n) {\n coordinates = coordinates !== undefined ? coordinates : [];\n let i = 0;\n for (let j = offset; j < end; j += stride) {\n coordinates[i++] = flatCoordinates.slice(j, j + stride);\n }\n coordinates.length = i;\n return coordinates;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {Array} ends Ends.\n * @param {number} stride Stride.\n * @param {Array>} [coordinatess] Coordinatess.\n * @return {Array>} Coordinatess.\n */\nexport function inflateCoordinatesArray(\n flatCoordinates,\n offset,\n ends,\n stride,\n coordinatess,\n) {\n coordinatess = coordinatess !== undefined ? coordinatess : [];\n let i = 0;\n for (let j = 0, jj = ends.length; j < jj; ++j) {\n const end = ends[j];\n coordinatess[i++] = inflateCoordinates(\n flatCoordinates,\n offset,\n end,\n stride,\n coordinatess[i],\n );\n offset = end;\n }\n coordinatess.length = i;\n return coordinatess;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {Array>} endss Endss.\n * @param {number} stride Stride.\n * @param {Array>>} [coordinatesss]\n * Coordinatesss.\n * @return {Array>>} Coordinatesss.\n */\nexport function inflateMultiCoordinatesArray(\n flatCoordinates,\n offset,\n endss,\n stride,\n coordinatesss,\n) {\n coordinatesss = coordinatesss !== undefined ? coordinatesss : [];\n let i = 0;\n for (let j = 0, jj = endss.length; j < jj; ++j) {\n const ends = endss[j];\n coordinatesss[i++] =\n ends.length === 1 && ends[0] === offset\n ? []\n : inflateCoordinatesArray(\n flatCoordinates,\n offset,\n ends,\n stride,\n coordinatesss[i],\n );\n offset = ends[ends.length - 1];\n }\n coordinatesss.length = i;\n return coordinatesss;\n}\n","/**\n * @module ol/geom/flat/area\n */\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {number} end End.\n * @param {number} stride Stride.\n * @return {number} Area.\n */\nexport function linearRing(flatCoordinates, offset, end, stride) {\n let twiceArea = 0;\n let x1 = flatCoordinates[end - stride];\n let y1 = flatCoordinates[end - stride + 1];\n for (; offset < end; offset += stride) {\n const x2 = flatCoordinates[offset];\n const y2 = flatCoordinates[offset + 1];\n twiceArea += y1 * x2 - x1 * y2;\n x1 = x2;\n y1 = y2;\n }\n return twiceArea / 2;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {Array} ends Ends.\n * @param {number} stride Stride.\n * @return {number} Area.\n */\nexport function linearRings(flatCoordinates, offset, ends, stride) {\n let area = 0;\n for (let i = 0, ii = ends.length; i < ii; ++i) {\n const end = ends[i];\n area += linearRing(flatCoordinates, offset, end, stride);\n offset = end;\n }\n return area;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {Array>} endss Endss.\n * @param {number} stride Stride.\n * @return {number} Area.\n */\nexport function linearRingss(flatCoordinates, offset, endss, stride) {\n let area = 0;\n for (let i = 0, ii = endss.length; i < ii; ++i) {\n const ends = endss[i];\n area += linearRings(flatCoordinates, offset, ends, stride);\n offset = ends[ends.length - 1];\n }\n return area;\n}\n","/**\n * @module ol/geom/LinearRing\n */\nimport SimpleGeometry from './SimpleGeometry.js';\nimport {assignClosestPoint, maxSquaredDelta} from './flat/closest.js';\nimport {closestSquaredDistanceXY} from '../extent.js';\nimport {deflateCoordinates} from './flat/deflate.js';\nimport {douglasPeucker} from './flat/simplify.js';\nimport {inflateCoordinates} from './flat/inflate.js';\nimport {linearRing as linearRingArea} from './flat/area.js';\n\n/**\n * @classdesc\n * Linear ring geometry. Only used as part of polygon; cannot be rendered\n * on its own.\n *\n * @api\n */\nclass LinearRing extends SimpleGeometry {\n /**\n * @param {Array|Array} coordinates Coordinates.\n * For internal use, flat coordinates in combination with `layout` are also accepted.\n * @param {import(\"./Geometry.js\").GeometryLayout} [layout] Layout.\n */\n constructor(coordinates, layout) {\n super();\n\n /**\n * @private\n * @type {number}\n */\n this.maxDelta_ = -1;\n\n /**\n * @private\n * @type {number}\n */\n this.maxDeltaRevision_ = -1;\n\n if (layout !== undefined && !Array.isArray(coordinates[0])) {\n this.setFlatCoordinates(\n layout,\n /** @type {Array} */ (coordinates),\n );\n } else {\n this.setCoordinates(\n /** @type {Array} */ (\n coordinates\n ),\n layout,\n );\n }\n }\n\n /**\n * Make a complete copy of the geometry.\n * @return {!LinearRing} Clone.\n * @api\n */\n clone() {\n return new LinearRing(this.flatCoordinates.slice(), this.layout);\n }\n\n /**\n * @param {number} x X.\n * @param {number} y Y.\n * @param {import(\"../coordinate.js\").Coordinate} closestPoint Closest point.\n * @param {number} minSquaredDistance Minimum squared distance.\n * @return {number} Minimum squared distance.\n */\n closestPointXY(x, y, closestPoint, minSquaredDistance) {\n if (minSquaredDistance < closestSquaredDistanceXY(this.getExtent(), x, y)) {\n return minSquaredDistance;\n }\n if (this.maxDeltaRevision_ != this.getRevision()) {\n this.maxDelta_ = Math.sqrt(\n maxSquaredDelta(\n this.flatCoordinates,\n 0,\n this.flatCoordinates.length,\n this.stride,\n 0,\n ),\n );\n this.maxDeltaRevision_ = this.getRevision();\n }\n return assignClosestPoint(\n this.flatCoordinates,\n 0,\n this.flatCoordinates.length,\n this.stride,\n this.maxDelta_,\n true,\n x,\n y,\n closestPoint,\n minSquaredDistance,\n );\n }\n\n /**\n * Return the area of the linear ring on projected plane.\n * @return {number} Area (on projected plane).\n * @api\n */\n getArea() {\n return linearRingArea(\n this.flatCoordinates,\n 0,\n this.flatCoordinates.length,\n this.stride,\n );\n }\n\n /**\n * Return the coordinates of the linear ring.\n * @return {Array} Coordinates.\n * @api\n */\n getCoordinates() {\n return inflateCoordinates(\n this.flatCoordinates,\n 0,\n this.flatCoordinates.length,\n this.stride,\n );\n }\n\n /**\n * @param {number} squaredTolerance Squared tolerance.\n * @return {LinearRing} Simplified LinearRing.\n * @protected\n */\n getSimplifiedGeometryInternal(squaredTolerance) {\n /** @type {Array} */\n const simplifiedFlatCoordinates = [];\n simplifiedFlatCoordinates.length = douglasPeucker(\n this.flatCoordinates,\n 0,\n this.flatCoordinates.length,\n this.stride,\n squaredTolerance,\n simplifiedFlatCoordinates,\n 0,\n );\n return new LinearRing(simplifiedFlatCoordinates, 'XY');\n }\n\n /**\n * Get the type of this geometry.\n * @return {import(\"./Geometry.js\").Type} Geometry type.\n * @api\n */\n getType() {\n return 'LinearRing';\n }\n\n /**\n * Test if the geometry and the passed extent intersect.\n * @param {import(\"../extent.js\").Extent} extent Extent.\n * @return {boolean} `true` if the geometry and the extent intersect.\n * @api\n */\n intersectsExtent(extent) {\n return false;\n }\n\n /**\n * Set the coordinates of the linear ring.\n * @param {!Array} coordinates Coordinates.\n * @param {import(\"./Geometry.js\").GeometryLayout} [layout] Layout.\n * @api\n */\n setCoordinates(coordinates, layout) {\n this.setLayout(layout, coordinates, 1);\n if (!this.flatCoordinates) {\n this.flatCoordinates = [];\n }\n this.flatCoordinates.length = deflateCoordinates(\n this.flatCoordinates,\n 0,\n coordinates,\n this.stride,\n );\n this.changed();\n }\n}\n\nexport default LinearRing;\n","/**\n * @module ol/geom/Point\n */\nimport SimpleGeometry from './SimpleGeometry.js';\nimport {containsXY, createOrUpdateFromCoordinate} from '../extent.js';\nimport {deflateCoordinate} from './flat/deflate.js';\nimport {squaredDistance as squaredDx} from '../math.js';\n\n/**\n * @classdesc\n * Point geometry.\n *\n * @api\n */\nclass Point extends SimpleGeometry {\n /**\n * @param {import(\"../coordinate.js\").Coordinate} coordinates Coordinates.\n * @param {import(\"./Geometry.js\").GeometryLayout} [layout] Layout.\n */\n constructor(coordinates, layout) {\n super();\n this.setCoordinates(coordinates, layout);\n }\n\n /**\n * Make a complete copy of the geometry.\n * @return {!Point} Clone.\n * @api\n */\n clone() {\n const point = new Point(this.flatCoordinates.slice(), this.layout);\n point.applyProperties(this);\n return point;\n }\n\n /**\n * @param {number} x X.\n * @param {number} y Y.\n * @param {import(\"../coordinate.js\").Coordinate} closestPoint Closest point.\n * @param {number} minSquaredDistance Minimum squared distance.\n * @return {number} Minimum squared distance.\n */\n closestPointXY(x, y, closestPoint, minSquaredDistance) {\n const flatCoordinates = this.flatCoordinates;\n const squaredDistance = squaredDx(\n x,\n y,\n flatCoordinates[0],\n flatCoordinates[1],\n );\n if (squaredDistance < minSquaredDistance) {\n const stride = this.stride;\n for (let i = 0; i < stride; ++i) {\n closestPoint[i] = flatCoordinates[i];\n }\n closestPoint.length = stride;\n return squaredDistance;\n }\n return minSquaredDistance;\n }\n\n /**\n * Return the coordinate of the point.\n * @return {import(\"../coordinate.js\").Coordinate} Coordinates.\n * @api\n */\n getCoordinates() {\n return this.flatCoordinates.slice();\n }\n\n /**\n * @param {import(\"../extent.js\").Extent} extent Extent.\n * @protected\n * @return {import(\"../extent.js\").Extent} extent Extent.\n */\n computeExtent(extent) {\n return createOrUpdateFromCoordinate(this.flatCoordinates, extent);\n }\n\n /**\n * Get the type of this geometry.\n * @return {import(\"./Geometry.js\").Type} Geometry type.\n * @api\n */\n getType() {\n return 'Point';\n }\n\n /**\n * Test if the geometry and the passed extent intersect.\n * @param {import(\"../extent.js\").Extent} extent Extent.\n * @return {boolean} `true` if the geometry and the extent intersect.\n * @api\n */\n intersectsExtent(extent) {\n return containsXY(extent, this.flatCoordinates[0], this.flatCoordinates[1]);\n }\n\n /**\n * @param {!Array<*>} coordinates Coordinates.\n * @param {import(\"./Geometry.js\").GeometryLayout} [layout] Layout.\n * @api\n */\n setCoordinates(coordinates, layout) {\n this.setLayout(layout, coordinates, 0);\n if (!this.flatCoordinates) {\n this.flatCoordinates = [];\n }\n this.flatCoordinates.length = deflateCoordinate(\n this.flatCoordinates,\n 0,\n coordinates,\n this.stride,\n );\n this.changed();\n }\n}\n\nexport default Point;\n","/**\n * @module ol/geom/flat/contains\n */\nimport {forEachCorner} from '../../extent.js';\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {number} end End.\n * @param {number} stride Stride.\n * @param {import(\"../../extent.js\").Extent} extent Extent.\n * @return {boolean} Contains extent.\n */\nexport function linearRingContainsExtent(\n flatCoordinates,\n offset,\n end,\n stride,\n extent,\n) {\n const outside = forEachCorner(\n extent,\n /**\n * @param {import(\"../../coordinate.js\").Coordinate} coordinate Coordinate.\n * @return {boolean} Contains (x, y).\n */\n function (coordinate) {\n return !linearRingContainsXY(\n flatCoordinates,\n offset,\n end,\n stride,\n coordinate[0],\n coordinate[1],\n );\n },\n );\n return !outside;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {number} end End.\n * @param {number} stride Stride.\n * @param {number} x X.\n * @param {number} y Y.\n * @return {boolean} Contains (x, y).\n */\nexport function linearRingContainsXY(\n flatCoordinates,\n offset,\n end,\n stride,\n x,\n y,\n) {\n // https://geomalgorithms.com/a03-_inclusion.html\n // Copyright 2000 softSurfer, 2012 Dan Sunday\n // This code may be freely used and modified for any purpose\n // providing that this copyright notice is included with it.\n // SoftSurfer makes no warranty for this code, and cannot be held\n // liable for any real or imagined damage resulting from its use.\n // Users of this code must verify correctness for their application.\n let wn = 0;\n let x1 = flatCoordinates[end - stride];\n let y1 = flatCoordinates[end - stride + 1];\n for (; offset < end; offset += stride) {\n const x2 = flatCoordinates[offset];\n const y2 = flatCoordinates[offset + 1];\n if (y1 <= y) {\n if (y2 > y && (x2 - x1) * (y - y1) - (x - x1) * (y2 - y1) > 0) {\n wn++;\n }\n } else if (y2 <= y && (x2 - x1) * (y - y1) - (x - x1) * (y2 - y1) < 0) {\n wn--;\n }\n x1 = x2;\n y1 = y2;\n }\n return wn !== 0;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {Array} ends Ends.\n * @param {number} stride Stride.\n * @param {number} x X.\n * @param {number} y Y.\n * @return {boolean} Contains (x, y).\n */\nexport function linearRingsContainsXY(\n flatCoordinates,\n offset,\n ends,\n stride,\n x,\n y,\n) {\n if (ends.length === 0) {\n return false;\n }\n if (!linearRingContainsXY(flatCoordinates, offset, ends[0], stride, x, y)) {\n return false;\n }\n for (let i = 1, ii = ends.length; i < ii; ++i) {\n if (\n linearRingContainsXY(flatCoordinates, ends[i - 1], ends[i], stride, x, y)\n ) {\n return false;\n }\n }\n return true;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {Array>} endss Endss.\n * @param {number} stride Stride.\n * @param {number} x X.\n * @param {number} y Y.\n * @return {boolean} Contains (x, y).\n */\nexport function linearRingssContainsXY(\n flatCoordinates,\n offset,\n endss,\n stride,\n x,\n y,\n) {\n if (endss.length === 0) {\n return false;\n }\n for (let i = 0, ii = endss.length; i < ii; ++i) {\n const ends = endss[i];\n if (linearRingsContainsXY(flatCoordinates, offset, ends, stride, x, y)) {\n return true;\n }\n offset = ends[ends.length - 1];\n }\n return false;\n}\n","/**\n * @module ol/geom/flat/interiorpoint\n */\nimport {ascending} from '../../array.js';\nimport {linearRingsContainsXY} from './contains.js';\n\n/**\n * Calculates a point that is likely to lie in the interior of the linear rings.\n * Inspired by JTS's com.vividsolutions.jts.geom.Geometry#getInteriorPoint.\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {Array} ends Ends.\n * @param {number} stride Stride.\n * @param {Array} flatCenters Flat centers.\n * @param {number} flatCentersOffset Flat center offset.\n * @param {Array} [dest] Destination.\n * @return {Array} Destination point as XYM coordinate, where M is the\n * length of the horizontal intersection that the point belongs to.\n */\nexport function getInteriorPointOfArray(\n flatCoordinates,\n offset,\n ends,\n stride,\n flatCenters,\n flatCentersOffset,\n dest,\n) {\n let i, ii, x, x1, x2, y1, y2;\n const y = flatCenters[flatCentersOffset + 1];\n /** @type {Array} */\n const intersections = [];\n // Calculate intersections with the horizontal line\n for (let r = 0, rr = ends.length; r < rr; ++r) {\n const end = ends[r];\n x1 = flatCoordinates[end - stride];\n y1 = flatCoordinates[end - stride + 1];\n for (i = offset; i < end; i += stride) {\n x2 = flatCoordinates[i];\n y2 = flatCoordinates[i + 1];\n if ((y <= y1 && y2 <= y) || (y1 <= y && y <= y2)) {\n x = ((y - y1) / (y2 - y1)) * (x2 - x1) + x1;\n intersections.push(x);\n }\n x1 = x2;\n y1 = y2;\n }\n }\n // Find the longest segment of the horizontal line that has its center point\n // inside the linear ring.\n let pointX = NaN;\n let maxSegmentLength = -Infinity;\n intersections.sort(ascending);\n x1 = intersections[0];\n for (i = 1, ii = intersections.length; i < ii; ++i) {\n x2 = intersections[i];\n const segmentLength = Math.abs(x2 - x1);\n if (segmentLength > maxSegmentLength) {\n x = (x1 + x2) / 2;\n if (linearRingsContainsXY(flatCoordinates, offset, ends, stride, x, y)) {\n pointX = x;\n maxSegmentLength = segmentLength;\n }\n }\n x1 = x2;\n }\n if (isNaN(pointX)) {\n // There is no horizontal line that has its center point inside the linear\n // ring. Use the center of the the linear ring's extent.\n pointX = flatCenters[flatCentersOffset];\n }\n if (dest) {\n dest.push(pointX, y, maxSegmentLength);\n return dest;\n }\n return [pointX, y, maxSegmentLength];\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {Array>} endss Endss.\n * @param {number} stride Stride.\n * @param {Array} flatCenters Flat centers.\n * @return {Array} Interior points as XYM coordinates, where M is the\n * length of the horizontal intersection that the point belongs to.\n */\nexport function getInteriorPointsOfMultiArray(\n flatCoordinates,\n offset,\n endss,\n stride,\n flatCenters,\n) {\n /** @type {Array} */\n let interiorPoints = [];\n for (let i = 0, ii = endss.length; i < ii; ++i) {\n const ends = endss[i];\n interiorPoints = getInteriorPointOfArray(\n flatCoordinates,\n offset,\n ends,\n stride,\n flatCenters,\n 2 * i,\n interiorPoints,\n );\n offset = ends[ends.length - 1];\n }\n return interiorPoints;\n}\n","/**\n * @module ol/geom/flat/segments\n */\n\n/**\n * This function calls `callback` for each segment of the flat coordinates\n * array. If the callback returns a truthy value the function returns that\n * value immediately. Otherwise the function returns `false`.\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {number} end End.\n * @param {number} stride Stride.\n * @param {function(import(\"../../coordinate.js\").Coordinate, import(\"../../coordinate.js\").Coordinate): T} callback Function\n * called for each segment.\n * @return {T|boolean} Value.\n * @template T\n */\nexport function forEach(flatCoordinates, offset, end, stride, callback) {\n let ret;\n offset += stride;\n for (; offset < end; offset += stride) {\n ret = callback(\n flatCoordinates.slice(offset - stride, offset),\n flatCoordinates.slice(offset, offset + stride),\n );\n if (ret) {\n return ret;\n }\n }\n return false;\n}\n","/**\n * @module ol/geom/flat/intersectsextent\n */\nimport {\n containsExtent,\n createEmpty,\n extendFlatCoordinates,\n intersects,\n intersectsSegment,\n} from '../../extent.js';\nimport {forEach as forEachSegment} from './segments.js';\nimport {linearRingContainsExtent, linearRingContainsXY} from './contains.js';\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {number} end End.\n * @param {number} stride Stride.\n * @param {import(\"../../extent.js\").Extent} extent Extent.\n * @return {boolean} True if the geometry and the extent intersect.\n */\nexport function intersectsLineString(\n flatCoordinates,\n offset,\n end,\n stride,\n extent,\n) {\n const coordinatesExtent = extendFlatCoordinates(\n createEmpty(),\n flatCoordinates,\n offset,\n end,\n stride,\n );\n if (!intersects(extent, coordinatesExtent)) {\n return false;\n }\n if (containsExtent(extent, coordinatesExtent)) {\n return true;\n }\n if (coordinatesExtent[0] >= extent[0] && coordinatesExtent[2] <= extent[2]) {\n return true;\n }\n if (coordinatesExtent[1] >= extent[1] && coordinatesExtent[3] <= extent[3]) {\n return true;\n }\n return forEachSegment(\n flatCoordinates,\n offset,\n end,\n stride,\n /**\n * @param {import(\"../../coordinate.js\").Coordinate} point1 Start point.\n * @param {import(\"../../coordinate.js\").Coordinate} point2 End point.\n * @return {boolean} `true` if the segment and the extent intersect,\n * `false` otherwise.\n */\n function (point1, point2) {\n return intersectsSegment(extent, point1, point2);\n },\n );\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {Array} ends Ends.\n * @param {number} stride Stride.\n * @param {import(\"../../extent.js\").Extent} extent Extent.\n * @return {boolean} True if the geometry and the extent intersect.\n */\nexport function intersectsLineStringArray(\n flatCoordinates,\n offset,\n ends,\n stride,\n extent,\n) {\n for (let i = 0, ii = ends.length; i < ii; ++i) {\n if (\n intersectsLineString(flatCoordinates, offset, ends[i], stride, extent)\n ) {\n return true;\n }\n offset = ends[i];\n }\n return false;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {number} end End.\n * @param {number} stride Stride.\n * @param {import(\"../../extent.js\").Extent} extent Extent.\n * @return {boolean} True if the geometry and the extent intersect.\n */\nexport function intersectsLinearRing(\n flatCoordinates,\n offset,\n end,\n stride,\n extent,\n) {\n if (intersectsLineString(flatCoordinates, offset, end, stride, extent)) {\n return true;\n }\n if (\n linearRingContainsXY(\n flatCoordinates,\n offset,\n end,\n stride,\n extent[0],\n extent[1],\n )\n ) {\n return true;\n }\n if (\n linearRingContainsXY(\n flatCoordinates,\n offset,\n end,\n stride,\n extent[0],\n extent[3],\n )\n ) {\n return true;\n }\n if (\n linearRingContainsXY(\n flatCoordinates,\n offset,\n end,\n stride,\n extent[2],\n extent[1],\n )\n ) {\n return true;\n }\n if (\n linearRingContainsXY(\n flatCoordinates,\n offset,\n end,\n stride,\n extent[2],\n extent[3],\n )\n ) {\n return true;\n }\n return false;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {Array} ends Ends.\n * @param {number} stride Stride.\n * @param {import(\"../../extent.js\").Extent} extent Extent.\n * @return {boolean} True if the geometry and the extent intersect.\n */\nexport function intersectsLinearRingArray(\n flatCoordinates,\n offset,\n ends,\n stride,\n extent,\n) {\n if (!intersectsLinearRing(flatCoordinates, offset, ends[0], stride, extent)) {\n return false;\n }\n if (ends.length === 1) {\n return true;\n }\n for (let i = 1, ii = ends.length; i < ii; ++i) {\n if (\n linearRingContainsExtent(\n flatCoordinates,\n ends[i - 1],\n ends[i],\n stride,\n extent,\n )\n ) {\n if (\n !intersectsLineString(\n flatCoordinates,\n ends[i - 1],\n ends[i],\n stride,\n extent,\n )\n ) {\n return false;\n }\n }\n }\n return true;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {Array>} endss Endss.\n * @param {number} stride Stride.\n * @param {import(\"../../extent.js\").Extent} extent Extent.\n * @return {boolean} True if the geometry and the extent intersect.\n */\nexport function intersectsLinearRingMultiArray(\n flatCoordinates,\n offset,\n endss,\n stride,\n extent,\n) {\n for (let i = 0, ii = endss.length; i < ii; ++i) {\n const ends = endss[i];\n if (\n intersectsLinearRingArray(flatCoordinates, offset, ends, stride, extent)\n ) {\n return true;\n }\n offset = ends[ends.length - 1];\n }\n return false;\n}\n","/**\n * @module ol/geom/flat/reverse\n */\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {number} end End.\n * @param {number} stride Stride.\n */\nexport function coordinates(flatCoordinates, offset, end, stride) {\n while (offset < end - stride) {\n for (let i = 0; i < stride; ++i) {\n const tmp = flatCoordinates[offset + i];\n flatCoordinates[offset + i] = flatCoordinates[end - stride + i];\n flatCoordinates[end - stride + i] = tmp;\n }\n offset += stride;\n end -= stride;\n }\n}\n","/**\n * @module ol/geom/flat/orient\n */\nimport {coordinates as reverseCoordinates} from './reverse.js';\n\n/**\n * Is the linear ring oriented clockwise in a coordinate system with a bottom-left\n * coordinate origin? For a coordinate system with a top-left coordinate origin,\n * the ring's orientation is clockwise when this function returns false.\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {number} end End.\n * @param {number} stride Stride.\n * @return {boolean|undefined} Is clockwise.\n */\nexport function linearRingIsClockwise(flatCoordinates, offset, end, stride) {\n // https://stackoverflow.com/q/1165647/clockwise-method#1165943\n // https://github.com/OSGeo/gdal/blob/master/gdal/ogr/ogrlinearring.cpp\n let edge = 0;\n let x1 = flatCoordinates[end - stride];\n let y1 = flatCoordinates[end - stride + 1];\n for (; offset < end; offset += stride) {\n const x2 = flatCoordinates[offset];\n const y2 = flatCoordinates[offset + 1];\n edge += (x2 - x1) * (y2 + y1);\n x1 = x2;\n y1 = y2;\n }\n return edge === 0 ? undefined : edge > 0;\n}\n\n/**\n * Determines if linear rings are oriented. By default, left-hand orientation\n * is tested (first ring must be clockwise, remaining rings counter-clockwise).\n * To test for right-hand orientation, use the `right` argument.\n *\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {Array} ends Array of end indexes.\n * @param {number} stride Stride.\n * @param {boolean} [right] Test for right-hand orientation\n * (counter-clockwise exterior ring and clockwise interior rings).\n * @return {boolean} Rings are correctly oriented.\n */\nexport function linearRingsAreOriented(\n flatCoordinates,\n offset,\n ends,\n stride,\n right,\n) {\n right = right !== undefined ? right : false;\n for (let i = 0, ii = ends.length; i < ii; ++i) {\n const end = ends[i];\n const isClockwise = linearRingIsClockwise(\n flatCoordinates,\n offset,\n end,\n stride,\n );\n if (i === 0) {\n if ((right && isClockwise) || (!right && !isClockwise)) {\n return false;\n }\n } else {\n if ((right && !isClockwise) || (!right && isClockwise)) {\n return false;\n }\n }\n offset = end;\n }\n return true;\n}\n\n/**\n * Determines if linear rings are oriented. By default, left-hand orientation\n * is tested (first ring must be clockwise, remaining rings counter-clockwise).\n * To test for right-hand orientation, use the `right` argument.\n *\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {Array>} endss Array of array of end indexes.\n * @param {number} stride Stride.\n * @param {boolean} [right] Test for right-hand orientation\n * (counter-clockwise exterior ring and clockwise interior rings).\n * @return {boolean} Rings are correctly oriented.\n */\nexport function linearRingssAreOriented(\n flatCoordinates,\n offset,\n endss,\n stride,\n right,\n) {\n for (let i = 0, ii = endss.length; i < ii; ++i) {\n const ends = endss[i];\n if (!linearRingsAreOriented(flatCoordinates, offset, ends, stride, right)) {\n return false;\n }\n if (ends.length) {\n offset = ends[ends.length - 1];\n }\n }\n return true;\n}\n\n/**\n * Orient coordinates in a flat array of linear rings. By default, rings\n * are oriented following the left-hand rule (clockwise for exterior and\n * counter-clockwise for interior rings). To orient according to the\n * right-hand rule, use the `right` argument.\n *\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {Array} ends Ends.\n * @param {number} stride Stride.\n * @param {boolean} [right] Follow the right-hand rule for orientation.\n * @return {number} End.\n */\nexport function orientLinearRings(\n flatCoordinates,\n offset,\n ends,\n stride,\n right,\n) {\n right = right !== undefined ? right : false;\n for (let i = 0, ii = ends.length; i < ii; ++i) {\n const end = ends[i];\n const isClockwise = linearRingIsClockwise(\n flatCoordinates,\n offset,\n end,\n stride,\n );\n const reverse =\n i === 0\n ? (right && isClockwise) || (!right && !isClockwise)\n : (right && !isClockwise) || (!right && isClockwise);\n if (reverse) {\n reverseCoordinates(flatCoordinates, offset, end, stride);\n }\n offset = end;\n }\n return offset;\n}\n\n/**\n * Orient coordinates in a flat array of linear rings. By default, rings\n * are oriented following the left-hand rule (clockwise for exterior and\n * counter-clockwise for interior rings). To orient according to the\n * right-hand rule, use the `right` argument.\n *\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {Array>} endss Array of array of end indexes.\n * @param {number} stride Stride.\n * @param {boolean} [right] Follow the right-hand rule for orientation.\n * @return {number} End.\n */\nexport function orientLinearRingsArray(\n flatCoordinates,\n offset,\n endss,\n stride,\n right,\n) {\n for (let i = 0, ii = endss.length; i < ii; ++i) {\n offset = orientLinearRings(\n flatCoordinates,\n offset,\n endss[i],\n stride,\n right,\n );\n }\n return offset;\n}\n\n/**\n * Return a two-dimensional endss\n * @param {Array} flatCoordinates Flat coordinates\n * @param {Array} ends Linear ring end indexes\n * @return {Array>} Two dimensional endss array that can\n * be used to construct a MultiPolygon\n */\nexport function inflateEnds(flatCoordinates, ends) {\n const endss = [];\n let offset = 0;\n let prevEndIndex = 0;\n let startOrientation;\n for (let i = 0, ii = ends.length; i < ii; ++i) {\n const end = ends[i];\n // classifies an array of rings into polygons with outer rings and holes\n const orientation = linearRingIsClockwise(flatCoordinates, offset, end, 2);\n if (startOrientation === undefined) {\n startOrientation = orientation;\n }\n if (orientation === startOrientation) {\n endss.push(ends.slice(prevEndIndex, i + 1));\n } else {\n if (endss.length === 0) {\n continue;\n }\n endss[endss.length - 1].push(ends[prevEndIndex]);\n }\n prevEndIndex = i + 1;\n offset = end;\n }\n return endss;\n}\n","/**\n * @module ol/geom/Polygon\n */\nimport LinearRing from './LinearRing.js';\nimport Point from './Point.js';\nimport SimpleGeometry from './SimpleGeometry.js';\nimport {arrayMaxSquaredDelta, assignClosestArrayPoint} from './flat/closest.js';\nimport {closestSquaredDistanceXY, getCenter, isEmpty} from '../extent.js';\nimport {deflateCoordinatesArray} from './flat/deflate.js';\nimport {extend} from '../array.js';\nimport {getInteriorPointOfArray} from './flat/interiorpoint.js';\nimport {inflateCoordinatesArray} from './flat/inflate.js';\nimport {intersectsLinearRingArray} from './flat/intersectsextent.js';\nimport {linearRingsAreOriented, orientLinearRings} from './flat/orient.js';\nimport {linearRings as linearRingsArea} from './flat/area.js';\nimport {linearRingsContainsXY} from './flat/contains.js';\nimport {modulo} from '../math.js';\nimport {quantizeArray} from './flat/simplify.js';\nimport {offset as sphereOffset} from '../sphere.js';\n\n/**\n * @classdesc\n * Polygon geometry.\n *\n * @api\n */\nclass Polygon extends SimpleGeometry {\n /**\n * @param {!Array>|!Array} coordinates\n * Array of linear rings that define the polygon. The first linear ring of the\n * array defines the outer-boundary or surface of the polygon. Each subsequent\n * linear ring defines a hole in the surface of the polygon. A linear ring is\n * an array of vertices' coordinates where the first coordinate and the last are\n * equivalent. (For internal use, flat coordinates in combination with\n * `layout` and `ends` are also accepted.)\n * @param {import(\"./Geometry.js\").GeometryLayout} [layout] Layout.\n * @param {Array} [ends] Ends (for internal use with flat coordinates).\n */\n constructor(coordinates, layout, ends) {\n super();\n\n /**\n * @type {Array}\n * @private\n */\n this.ends_ = [];\n\n /**\n * @private\n * @type {number}\n */\n this.flatInteriorPointRevision_ = -1;\n\n /**\n * @private\n * @type {import(\"../coordinate.js\").Coordinate|null}\n */\n this.flatInteriorPoint_ = null;\n\n /**\n * @private\n * @type {number}\n */\n this.maxDelta_ = -1;\n\n /**\n * @private\n * @type {number}\n */\n this.maxDeltaRevision_ = -1;\n\n /**\n * @private\n * @type {number}\n */\n this.orientedRevision_ = -1;\n\n /**\n * @private\n * @type {Array|null}\n */\n this.orientedFlatCoordinates_ = null;\n\n if (layout !== undefined && ends) {\n this.setFlatCoordinates(\n layout,\n /** @type {Array} */ (coordinates),\n );\n this.ends_ = ends;\n } else {\n this.setCoordinates(\n /** @type {Array>} */ (\n coordinates\n ),\n layout,\n );\n }\n }\n\n /**\n * Append the passed linear ring to this polygon.\n * @param {LinearRing} linearRing Linear ring.\n * @api\n */\n appendLinearRing(linearRing) {\n if (!this.flatCoordinates) {\n this.flatCoordinates = linearRing.getFlatCoordinates().slice();\n } else {\n extend(this.flatCoordinates, linearRing.getFlatCoordinates());\n }\n this.ends_.push(this.flatCoordinates.length);\n this.changed();\n }\n\n /**\n * Make a complete copy of the geometry.\n * @return {!Polygon} Clone.\n * @api\n */\n clone() {\n const polygon = new Polygon(\n this.flatCoordinates.slice(),\n this.layout,\n this.ends_.slice(),\n );\n polygon.applyProperties(this);\n return polygon;\n }\n\n /**\n * @param {number} x X.\n * @param {number} y Y.\n * @param {import(\"../coordinate.js\").Coordinate} closestPoint Closest point.\n * @param {number} minSquaredDistance Minimum squared distance.\n * @return {number} Minimum squared distance.\n */\n closestPointXY(x, y, closestPoint, minSquaredDistance) {\n if (minSquaredDistance < closestSquaredDistanceXY(this.getExtent(), x, y)) {\n return minSquaredDistance;\n }\n if (this.maxDeltaRevision_ != this.getRevision()) {\n this.maxDelta_ = Math.sqrt(\n arrayMaxSquaredDelta(\n this.flatCoordinates,\n 0,\n this.ends_,\n this.stride,\n 0,\n ),\n );\n this.maxDeltaRevision_ = this.getRevision();\n }\n return assignClosestArrayPoint(\n this.flatCoordinates,\n 0,\n this.ends_,\n this.stride,\n this.maxDelta_,\n true,\n x,\n y,\n closestPoint,\n minSquaredDistance,\n );\n }\n\n /**\n * @param {number} x X.\n * @param {number} y Y.\n * @return {boolean} Contains (x, y).\n */\n containsXY(x, y) {\n return linearRingsContainsXY(\n this.getOrientedFlatCoordinates(),\n 0,\n this.ends_,\n this.stride,\n x,\n y,\n );\n }\n\n /**\n * Return the area of the polygon on projected plane.\n * @return {number} Area (on projected plane).\n * @api\n */\n getArea() {\n return linearRingsArea(\n this.getOrientedFlatCoordinates(),\n 0,\n this.ends_,\n this.stride,\n );\n }\n\n /**\n * Get the coordinate array for this geometry. This array has the structure\n * of a GeoJSON coordinate array for polygons.\n *\n * @param {boolean} [right] Orient coordinates according to the right-hand\n * rule (counter-clockwise for exterior and clockwise for interior rings).\n * If `false`, coordinates will be oriented according to the left-hand rule\n * (clockwise for exterior and counter-clockwise for interior rings).\n * By default, coordinate orientation will depend on how the geometry was\n * constructed.\n * @return {Array>} Coordinates.\n * @api\n */\n getCoordinates(right) {\n let flatCoordinates;\n if (right !== undefined) {\n flatCoordinates = this.getOrientedFlatCoordinates().slice();\n orientLinearRings(flatCoordinates, 0, this.ends_, this.stride, right);\n } else {\n flatCoordinates = this.flatCoordinates;\n }\n\n return inflateCoordinatesArray(flatCoordinates, 0, this.ends_, this.stride);\n }\n\n /**\n * @return {Array} Ends.\n */\n getEnds() {\n return this.ends_;\n }\n\n /**\n * @return {Array} Interior point.\n */\n getFlatInteriorPoint() {\n if (this.flatInteriorPointRevision_ != this.getRevision()) {\n const flatCenter = getCenter(this.getExtent());\n this.flatInteriorPoint_ = getInteriorPointOfArray(\n this.getOrientedFlatCoordinates(),\n 0,\n this.ends_,\n this.stride,\n flatCenter,\n 0,\n );\n this.flatInteriorPointRevision_ = this.getRevision();\n }\n return /** @type {import(\"../coordinate.js\").Coordinate} */ (\n this.flatInteriorPoint_\n );\n }\n\n /**\n * Return an interior point of the polygon.\n * @return {Point} Interior point as XYM coordinate, where M is the\n * length of the horizontal intersection that the point belongs to.\n * @api\n */\n getInteriorPoint() {\n return new Point(this.getFlatInteriorPoint(), 'XYM');\n }\n\n /**\n * Return the number of rings of the polygon, this includes the exterior\n * ring and any interior rings.\n *\n * @return {number} Number of rings.\n * @api\n */\n getLinearRingCount() {\n return this.ends_.length;\n }\n\n /**\n * Return the Nth linear ring of the polygon geometry. Return `null` if the\n * given index is out of range.\n * The exterior linear ring is available at index `0` and the interior rings\n * at index `1` and beyond.\n *\n * @param {number} index Index.\n * @return {LinearRing|null} Linear ring.\n * @api\n */\n getLinearRing(index) {\n if (index < 0 || this.ends_.length <= index) {\n return null;\n }\n return new LinearRing(\n this.flatCoordinates.slice(\n index === 0 ? 0 : this.ends_[index - 1],\n this.ends_[index],\n ),\n this.layout,\n );\n }\n\n /**\n * Return the linear rings of the polygon.\n * @return {Array} Linear rings.\n * @api\n */\n getLinearRings() {\n const layout = this.layout;\n const flatCoordinates = this.flatCoordinates;\n const ends = this.ends_;\n const linearRings = [];\n let offset = 0;\n for (let i = 0, ii = ends.length; i < ii; ++i) {\n const end = ends[i];\n const linearRing = new LinearRing(\n flatCoordinates.slice(offset, end),\n layout,\n );\n linearRings.push(linearRing);\n offset = end;\n }\n return linearRings;\n }\n\n /**\n * @return {Array} Oriented flat coordinates.\n */\n getOrientedFlatCoordinates() {\n if (this.orientedRevision_ != this.getRevision()) {\n const flatCoordinates = this.flatCoordinates;\n if (linearRingsAreOriented(flatCoordinates, 0, this.ends_, this.stride)) {\n this.orientedFlatCoordinates_ = flatCoordinates;\n } else {\n this.orientedFlatCoordinates_ = flatCoordinates.slice();\n this.orientedFlatCoordinates_.length = orientLinearRings(\n this.orientedFlatCoordinates_,\n 0,\n this.ends_,\n this.stride,\n );\n }\n this.orientedRevision_ = this.getRevision();\n }\n return /** @type {Array} */ (this.orientedFlatCoordinates_);\n }\n\n /**\n * @param {number} squaredTolerance Squared tolerance.\n * @return {Polygon} Simplified Polygon.\n * @protected\n */\n getSimplifiedGeometryInternal(squaredTolerance) {\n /** @type {Array} */\n const simplifiedFlatCoordinates = [];\n /** @type {Array} */\n const simplifiedEnds = [];\n simplifiedFlatCoordinates.length = quantizeArray(\n this.flatCoordinates,\n 0,\n this.ends_,\n this.stride,\n Math.sqrt(squaredTolerance),\n simplifiedFlatCoordinates,\n 0,\n simplifiedEnds,\n );\n return new Polygon(simplifiedFlatCoordinates, 'XY', simplifiedEnds);\n }\n\n /**\n * Get the type of this geometry.\n * @return {import(\"./Geometry.js\").Type} Geometry type.\n * @api\n */\n getType() {\n return 'Polygon';\n }\n\n /**\n * Test if the geometry and the passed extent intersect.\n * @param {import(\"../extent.js\").Extent} extent Extent.\n * @return {boolean} `true` if the geometry and the extent intersect.\n * @api\n */\n intersectsExtent(extent) {\n return intersectsLinearRingArray(\n this.getOrientedFlatCoordinates(),\n 0,\n this.ends_,\n this.stride,\n extent,\n );\n }\n\n /**\n * Set the coordinates of the polygon.\n * @param {!Array>} coordinates Coordinates.\n * @param {import(\"./Geometry.js\").GeometryLayout} [layout] Layout.\n * @api\n */\n setCoordinates(coordinates, layout) {\n this.setLayout(layout, coordinates, 2);\n if (!this.flatCoordinates) {\n this.flatCoordinates = [];\n }\n const ends = deflateCoordinatesArray(\n this.flatCoordinates,\n 0,\n coordinates,\n this.stride,\n this.ends_,\n );\n this.flatCoordinates.length = ends.length === 0 ? 0 : ends[ends.length - 1];\n this.changed();\n }\n}\n\nexport default Polygon;\n\n/**\n * Create an approximation of a circle on the surface of a sphere.\n * @param {import(\"../coordinate.js\").Coordinate} center Center (`[lon, lat]` in degrees).\n * @param {number} radius The great-circle distance from the center to\n * the polygon vertices in meters.\n * @param {number} [n] Optional number of vertices for the resulting\n * polygon. Default is `32`.\n * @param {number} [sphereRadius] Optional radius for the sphere (defaults to\n * the Earth's mean radius using the WGS84 ellipsoid).\n * @return {Polygon} The \"circular\" polygon.\n * @api\n */\nexport function circular(center, radius, n, sphereRadius) {\n n = n ? n : 32;\n /** @type {Array} */\n const flatCoordinates = [];\n for (let i = 0; i < n; ++i) {\n extend(\n flatCoordinates,\n sphereOffset(center, radius, (2 * Math.PI * i) / n, sphereRadius),\n );\n }\n flatCoordinates.push(flatCoordinates[0], flatCoordinates[1]);\n return new Polygon(flatCoordinates, 'XY', [flatCoordinates.length]);\n}\n\n/**\n * Create a polygon from an extent. The layout used is `XY`.\n * @param {import(\"../extent.js\").Extent} extent The extent.\n * @return {Polygon} The polygon.\n * @api\n */\nexport function fromExtent(extent) {\n if (isEmpty(extent)) {\n throw new Error('Cannot create polygon from empty extent');\n }\n const minX = extent[0];\n const minY = extent[1];\n const maxX = extent[2];\n const maxY = extent[3];\n const flatCoordinates = [\n minX,\n minY,\n minX,\n maxY,\n maxX,\n maxY,\n maxX,\n minY,\n minX,\n minY,\n ];\n return new Polygon(flatCoordinates, 'XY', [flatCoordinates.length]);\n}\n\n/**\n * Create a regular polygon from a circle.\n * @param {import(\"./Circle.js\").default} circle Circle geometry.\n * @param {number} [sides] Number of sides of the polygon. Default is 32.\n * @param {number} [angle] Start angle for the first vertex of the polygon in\n * counter-clockwise radians. 0 means East. Default is 0.\n * @return {Polygon} Polygon geometry.\n * @api\n */\nexport function fromCircle(circle, sides, angle) {\n sides = sides ? sides : 32;\n const stride = circle.getStride();\n const layout = circle.getLayout();\n const center = circle.getCenter();\n const arrayLength = stride * (sides + 1);\n const flatCoordinates = new Array(arrayLength);\n for (let i = 0; i < arrayLength; i += stride) {\n flatCoordinates[i] = 0;\n flatCoordinates[i + 1] = 0;\n for (let j = 2; j < stride; j++) {\n flatCoordinates[i + j] = center[j];\n }\n }\n const ends = [flatCoordinates.length];\n const polygon = new Polygon(flatCoordinates, layout, ends);\n makeRegular(polygon, center, circle.getRadius(), angle);\n return polygon;\n}\n\n/**\n * Modify the coordinates of a polygon to make it a regular polygon.\n * @param {Polygon} polygon Polygon geometry.\n * @param {import(\"../coordinate.js\").Coordinate} center Center of the regular polygon.\n * @param {number} radius Radius of the regular polygon.\n * @param {number} [angle] Start angle for the first vertex of the polygon in\n * counter-clockwise radians. 0 means East. Default is 0.\n */\nexport function makeRegular(polygon, center, radius, angle) {\n const flatCoordinates = polygon.getFlatCoordinates();\n const stride = polygon.getStride();\n const sides = flatCoordinates.length / stride - 1;\n const startAngle = angle ? angle : 0;\n for (let i = 0; i <= sides; ++i) {\n const offset = i * stride;\n const angle = startAngle + (modulo(i, sides) * 2 * Math.PI) / sides;\n flatCoordinates[offset] = center[0] + radius * Math.cos(angle);\n flatCoordinates[offset + 1] = center[1] + radius * Math.sin(angle);\n }\n polygon.changed();\n}\n","/**\n * @module ol/render/EventType\n */\n\n/**\n * @enum {string}\n */\nexport default {\n /**\n * Triggered before a layer is rendered.\n * @event module:ol/render/Event~RenderEvent#prerender\n * @api\n */\n PRERENDER: 'prerender',\n\n /**\n * Triggered after a layer is rendered.\n * @event module:ol/render/Event~RenderEvent#postrender\n * @api\n */\n POSTRENDER: 'postrender',\n\n /**\n * Triggered before layers are composed. When dispatched by the map, the event object will not have\n * a `context` set. When dispatched by a layer, the event object will have a `context` set. Only\n * WebGL layers currently dispatch this event.\n * @event module:ol/render/Event~RenderEvent#precompose\n * @api\n */\n PRECOMPOSE: 'precompose',\n\n /**\n * Triggered after layers are composed. When dispatched by the map, the event object will not have\n * a `context` set. When dispatched by a layer, the event object will have a `context` set. Only\n * WebGL layers currently dispatch this event.\n * @event module:ol/render/Event~RenderEvent#postcompose\n * @api\n */\n POSTCOMPOSE: 'postcompose',\n\n /**\n * Triggered when rendering is complete, i.e. all sources and tiles have\n * finished loading for the current viewport, and all tiles are faded in.\n * The event object will not have a `context` set.\n * @event module:ol/render/Event~RenderEvent#rendercomplete\n * @api\n */\n RENDERCOMPLETE: 'rendercomplete',\n};\n\n/**\n * @typedef {'postrender'|'precompose'|'postcompose'|'rendercomplete'} MapRenderEventTypes\n */\n\n/**\n * @typedef {'postrender'|'prerender'} LayerRenderEventTypes\n */\n","/**\n * @module ol/ImageState\n */\n\n/**\n * @enum {number}\n */\nexport default {\n IDLE: 0,\n LOADING: 1,\n LOADED: 2,\n ERROR: 3,\n EMPTY: 4,\n};\n","/**\n * RGB space.\n *\n * @module color-space/rgb\n */\n\nexport default {\n\tname: 'rgb',\n\tmin: [0,0,0],\n\tmax: [255,255,255],\n\tchannel: ['red', 'green', 'blue'],\n\talias: ['RGB']\n};\n","/**\n * CIE XYZ\n *\n * @module color-space/xyz\n */\nimport rgb from './rgb.js';\n\nvar xyz = {\n\tname: 'xyz',\n\tmin: [0,0,0],\n\tchannel: ['X','Y','Z'],\n\talias: ['XYZ', 'ciexyz', 'cie1931']\n};\n\n\n/**\n * Whitepoint reference values with observer/illuminant\n *\n * http://en.wikipedia.org/wiki/Standard_illuminant\n */\nxyz.whitepoint = {\n\t//1931 2°\n\t2: {\n\t\t//incadescent\n\t\tA:[109.85, 100, 35.585],\n\t\t// B:[],\n\t\tC: [98.074, 100, 118.232],\n\t\tD50: [96.422, 100, 82.521],\n\t\tD55: [95.682, 100, 92.149],\n\t\t//daylight\n\t\tD65: [95.045592705167, 100, 108.9057750759878],\n\t\tD75: [94.972, 100, 122.638],\n\t\t//flourescent\n\t\t// F1: [],\n\t\tF2: [99.187, 100, 67.395],\n\t\t// F3: [],\n\t\t// F4: [],\n\t\t// F5: [],\n\t\t// F6:[],\n\t\tF7: [95.044, 100, 108.755],\n\t\t// F8: [],\n\t\t// F9: [],\n\t\t// F10: [],\n\t\tF11: [100.966, 100, 64.370],\n\t\t// F12: [],\n\t\tE: [100,100,100]\n\t},\n\n\t//1964 10°\n\t10: {\n\t\t//incadescent\n\t\tA:[111.144, 100, 35.200],\n\t\tC: [97.285, 100, 116.145],\n\t\tD50: [96.720, 100, 81.427],\n\t\tD55: [95.799, 100, 90.926],\n\t\t//daylight\n\t\tD65: [94.811, 100, 107.304],\n\t\tD75: [94.416, 100, 120.641],\n\t\t//flourescent\n\t\tF2: [103.280, 100, 69.026],\n\t\tF7: [95.792, 100, 107.687],\n\t\tF11: [103.866, 100, 65.627],\n\t\tE: [100,100,100]\n\t}\n};\n\n\n/**\n * Top values are the whitepoint’s top values, default are D65\n */\nxyz.max = xyz.whitepoint[2].D65;\n\n\n/**\n * Transform xyz to rgb\n *\n * @param {Array} xyz Array of xyz values\n *\n * @return {Array} RGB values\n */\nxyz.rgb = function (_xyz, white) {\n\t//FIXME: make sure we have to divide like this. Probably we have to replace matrix as well then\n\twhite = white || xyz.whitepoint[2].E;\n\n\tvar x = _xyz[0] / white[0],\n\t\ty = _xyz[1] / white[1],\n\t\tz = _xyz[2] / white[2],\n\t\tr, g, b;\n\n\t// assume sRGB\n\t// http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html\n\tr = (x * 3.240969941904521) + (y * -1.537383177570093) + (z * -0.498610760293);\n\tg = (x * -0.96924363628087) + (y * 1.87596750150772) + (z * 0.041555057407175);\n\tb = (x * 0.055630079696993) + (y * -0.20397695888897) + (z * 1.056971514242878);\n\n\tr = r > 0.0031308 ? ((1.055 * Math.pow(r, 1.0 / 2.4)) - 0.055)\n\t\t: r = (r * 12.92);\n\n\tg = g > 0.0031308 ? ((1.055 * Math.pow(g, 1.0 / 2.4)) - 0.055)\n\t\t: g = (g * 12.92);\n\n\tb = b > 0.0031308 ? ((1.055 * Math.pow(b, 1.0 / 2.4)) - 0.055)\n\t\t: b = (b * 12.92);\n\n\tr = Math.min(Math.max(0, r), 1);\n\tg = Math.min(Math.max(0, g), 1);\n\tb = Math.min(Math.max(0, b), 1);\n\n\treturn [r * 255, g * 255, b * 255];\n}\n\n\n\n/**\n * RGB to XYZ\n *\n * @param {Array} rgb RGB channels\n *\n * @return {Array} XYZ channels\n */\nrgb.xyz = function(rgb, white) {\n\tvar r = rgb[0] / 255,\n\t\t\tg = rgb[1] / 255,\n\t\t\tb = rgb[2] / 255;\n\n\t// assume sRGB\n\tr = r > 0.04045 ? Math.pow(((r + 0.055) / 1.055), 2.4) : (r / 12.92);\n\tg = g > 0.04045 ? Math.pow(((g + 0.055) / 1.055), 2.4) : (g / 12.92);\n\tb = b > 0.04045 ? Math.pow(((b + 0.055) / 1.055), 2.4) : (b / 12.92);\n\n\tvar x = (r * 0.41239079926595) + (g * 0.35758433938387) + (b * 0.18048078840183);\n\tvar y = (r * 0.21263900587151) + (g * 0.71516867876775) + (b * 0.072192315360733);\n\tvar z = (r * 0.019330818715591) + (g * 0.11919477979462) + (b * 0.95053215224966);\n\n\twhite = white || xyz.whitepoint[2].E;\n\n\treturn [x * white[0], y * white[1], z * white[2]];\n};\n\n\n\nexport default xyz;\n","/**\n * CIE LUV (C'est la vie)\n *\n * @module color-space/luv\n */\n import xyz from './xyz.js';\n\nexport default {\n\tname: 'luv',\n\t//NOTE: luv has no rigidly defined limits\n\t//easyrgb fails to get proper coords\n\t//boronine states no rigid limits\n\t//colorMine refers this ones:\n\tmin: [0,-134,-140],\n\tmax: [100,224,122],\n\tchannel: ['lightness', 'u', 'v'],\n\talias: ['LUV', 'cieluv', 'cie1976'],\n\n\txyz: function(arg, i, o){\n\t\tvar _u, _v, l, u, v, x, y, z, xn, yn, zn, un, vn;\n\t\tl = arg[0], u = arg[1], v = arg[2];\n\n\t\tif (l === 0) return [0,0,0];\n\n\t\t//get constants\n\t\t//var e = 0.008856451679035631; //(6/29)^3\n\t\tvar k = 0.0011070564598794539; //(3/29)^3\n\n\t\t//get illuminant/observer\n\t\ti = i || 'D65';\n\t\to = o || 2;\n\n\t\txn = xyz.whitepoint[o][i][0];\n\t\tyn = xyz.whitepoint[o][i][1];\n\t\tzn = xyz.whitepoint[o][i][2];\n\n\t\tun = (4 * xn) / (xn + (15 * yn) + (3 * zn));\n\t\tvn = (9 * yn) / (xn + (15 * yn) + (3 * zn));\n\t\t// un = 0.19783000664283;\n\t\t// vn = 0.46831999493879;\n\n\n\t\t_u = u / (13 * l) + un || 0;\n\t\t_v = v / (13 * l) + vn || 0;\n\n\t\ty = l > 8 ? yn * Math.pow( (l + 16) / 116 , 3) : yn * l * k;\n\n\t\t//wikipedia method\n\t\tx = y * 9 * _u / (4 * _v) || 0;\n\t\tz = y * (12 - 3 * _u - 20 * _v) / (4 * _v) || 0;\n\n\t\t//boronine method\n\t\t//https://github.com/boronine/husl/blob/master/husl.coffee#L201\n\t\t// x = 0 - (9 * y * _u) / ((_u - 4) * _v - _u * _v);\n\t\t// z = (9 * y - (15 * _v * y) - (_v * x)) / (3 * _v);\n\n\t\treturn [x, y, z];\n\t}\n};\n\n// http://www.brucelindbloom.com/index.html?Equations.html\n// https://github.com/boronine/husl/blob/master/husl.coffee\n//i - illuminant\n//o - observer\nxyz.luv = function(arg, i, o) {\n\tvar _u, _v, l, u, v, x, y, z, xn, yn, zn, un, vn;\n\n\t//get constants\n\tvar e = 0.008856451679035631; //(6/29)^3\n\tvar k = 903.2962962962961; //(29/3)^3\n\n\t//get illuminant/observer coords\n\ti = i || 'D65';\n\to = o || 2;\n\n\txn = xyz.whitepoint[o][i][0];\n\tyn = xyz.whitepoint[o][i][1];\n\tzn = xyz.whitepoint[o][i][2];\n\n\tun = (4 * xn) / (xn + (15 * yn) + (3 * zn));\n\tvn = (9 * yn) / (xn + (15 * yn) + (3 * zn));\n\n\n\tx = arg[0], y = arg[1], z = arg[2];\n\n\n\t_u = (4 * x) / (x + (15 * y) + (3 * z)) || 0;\n\t_v = (9 * y) / (x + (15 * y) + (3 * z)) || 0;\n\n\tvar yr = y/yn;\n\n\tl = yr <= e ? k * yr : 116 * Math.pow(yr, 1/3) - 16;\n\n\tu = 13 * l * (_u - un);\n\tv = 13 * l * (_v - vn);\n\n\treturn [l, u, v];\n};\n","/**\n * Cylindrical CIE LUV\n *\n * @module color-space/lchuv\n */\nimport luv from './luv.js';\nimport xyz from './xyz.js';\n\n//cylindrical luv\nvar lchuv = {\n\tname: 'lchuv',\n\tchannel: ['lightness', 'chroma', 'hue'],\n\talias: ['LCHuv', 'cielchuv'],\n\tmin: [0,0,0],\n\tmax: [100,100,360],\n\n\tluv: function(luv){\n\t\tvar l = luv[0],\n\t\tc = luv[1],\n\t\th = luv[2],\n\t\tu, v, hr;\n\n\t\thr = h / 360 * 2 * Math.PI;\n\t\tu = c * Math.cos(hr);\n\t\tv = c * Math.sin(hr);\n\t\treturn [l, u, v];\n\t},\n\n\txyz: function(arg) {\n\t\treturn luv.xyz(lchuv.luv(arg));\n\t}\n};\n\nexport default lchuv;\n\nluv.lchuv = function(luv){\n\tvar l = luv[0], u = luv[1], v = luv[2];\n\n\tvar c = Math.sqrt(u*u + v*v);\n\tvar hr = Math.atan2(v,u);\n\tvar h = hr * 360 / 2 / Math.PI;\n\tif (h < 0) {\n\t\th += 360;\n\t}\n\n\treturn [l,c,h]\n};\n\nxyz.lchuv = function(arg){\n return luv.lchuv(xyz.luv(arg));\n};\n","export default {\n\taliceblue: [240, 248, 255],\n\tantiquewhite: [250, 235, 215],\n\taqua: [0, 255, 255],\n\taquamarine: [127, 255, 212],\n\tazure: [240, 255, 255],\n\tbeige: [245, 245, 220],\n\tbisque: [255, 228, 196],\n\tblack: [0, 0, 0],\n\tblanchedalmond: [255, 235, 205],\n\tblue: [0, 0, 255],\n\tblueviolet: [138, 43, 226],\n\tbrown: [165, 42, 42],\n\tburlywood: [222, 184, 135],\n\tcadetblue: [95, 158, 160],\n\tchartreuse: [127, 255, 0],\n\tchocolate: [210, 105, 30],\n\tcoral: [255, 127, 80],\n\tcornflowerblue: [100, 149, 237],\n\tcornsilk: [255, 248, 220],\n\tcrimson: [220, 20, 60],\n\tcyan: [0, 255, 255],\n\tdarkblue: [0, 0, 139],\n\tdarkcyan: [0, 139, 139],\n\tdarkgoldenrod: [184, 134, 11],\n\tdarkgray: [169, 169, 169],\n\tdarkgreen: [0, 100, 0],\n\tdarkgrey: [169, 169, 169],\n\tdarkkhaki: [189, 183, 107],\n\tdarkmagenta: [139, 0, 139],\n\tdarkolivegreen: [85, 107, 47],\n\tdarkorange: [255, 140, 0],\n\tdarkorchid: [153, 50, 204],\n\tdarkred: [139, 0, 0],\n\tdarksalmon: [233, 150, 122],\n\tdarkseagreen: [143, 188, 143],\n\tdarkslateblue: [72, 61, 139],\n\tdarkslategray: [47, 79, 79],\n\tdarkslategrey: [47, 79, 79],\n\tdarkturquoise: [0, 206, 209],\n\tdarkviolet: [148, 0, 211],\n\tdeeppink: [255, 20, 147],\n\tdeepskyblue: [0, 191, 255],\n\tdimgray: [105, 105, 105],\n\tdimgrey: [105, 105, 105],\n\tdodgerblue: [30, 144, 255],\n\tfirebrick: [178, 34, 34],\n\tfloralwhite: [255, 250, 240],\n\tforestgreen: [34, 139, 34],\n\tfuchsia: [255, 0, 255],\n\tgainsboro: [220, 220, 220],\n\tghostwhite: [248, 248, 255],\n\tgold: [255, 215, 0],\n\tgoldenrod: [218, 165, 32],\n\tgray: [128, 128, 128],\n\tgreen: [0, 128, 0],\n\tgreenyellow: [173, 255, 47],\n\tgrey: [128, 128, 128],\n\thoneydew: [240, 255, 240],\n\thotpink: [255, 105, 180],\n\tindianred: [205, 92, 92],\n\tindigo: [75, 0, 130],\n\tivory: [255, 255, 240],\n\tkhaki: [240, 230, 140],\n\tlavender: [230, 230, 250],\n\tlavenderblush: [255, 240, 245],\n\tlawngreen: [124, 252, 0],\n\tlemonchiffon: [255, 250, 205],\n\tlightblue: [173, 216, 230],\n\tlightcoral: [240, 128, 128],\n\tlightcyan: [224, 255, 255],\n\tlightgoldenrodyellow: [250, 250, 210],\n\tlightgray: [211, 211, 211],\n\tlightgreen: [144, 238, 144],\n\tlightgrey: [211, 211, 211],\n\tlightpink: [255, 182, 193],\n\tlightsalmon: [255, 160, 122],\n\tlightseagreen: [32, 178, 170],\n\tlightskyblue: [135, 206, 250],\n\tlightslategray: [119, 136, 153],\n\tlightslategrey: [119, 136, 153],\n\tlightsteelblue: [176, 196, 222],\n\tlightyellow: [255, 255, 224],\n\tlime: [0, 255, 0],\n\tlimegreen: [50, 205, 50],\n\tlinen: [250, 240, 230],\n\tmagenta: [255, 0, 255],\n\tmaroon: [128, 0, 0],\n\tmediumaquamarine: [102, 205, 170],\n\tmediumblue: [0, 0, 205],\n\tmediumorchid: [186, 85, 211],\n\tmediumpurple: [147, 112, 219],\n\tmediumseagreen: [60, 179, 113],\n\tmediumslateblue: [123, 104, 238],\n\tmediumspringgreen: [0, 250, 154],\n\tmediumturquoise: [72, 209, 204],\n\tmediumvioletred: [199, 21, 133],\n\tmidnightblue: [25, 25, 112],\n\tmintcream: [245, 255, 250],\n\tmistyrose: [255, 228, 225],\n\tmoccasin: [255, 228, 181],\n\tnavajowhite: [255, 222, 173],\n\tnavy: [0, 0, 128],\n\toldlace: [253, 245, 230],\n\tolive: [128, 128, 0],\n\tolivedrab: [107, 142, 35],\n\torange: [255, 165, 0],\n\torangered: [255, 69, 0],\n\torchid: [218, 112, 214],\n\tpalegoldenrod: [238, 232, 170],\n\tpalegreen: [152, 251, 152],\n\tpaleturquoise: [175, 238, 238],\n\tpalevioletred: [219, 112, 147],\n\tpapayawhip: [255, 239, 213],\n\tpeachpuff: [255, 218, 185],\n\tperu: [205, 133, 63],\n\tpink: [255, 192, 203],\n\tplum: [221, 160, 221],\n\tpowderblue: [176, 224, 230],\n\tpurple: [128, 0, 128],\n\trebeccapurple: [102, 51, 153],\n\tred: [255, 0, 0],\n\trosybrown: [188, 143, 143],\n\troyalblue: [65, 105, 225],\n\tsaddlebrown: [139, 69, 19],\n\tsalmon: [250, 128, 114],\n\tsandybrown: [244, 164, 96],\n\tseagreen: [46, 139, 87],\n\tseashell: [255, 245, 238],\n\tsienna: [160, 82, 45],\n\tsilver: [192, 192, 192],\n\tskyblue: [135, 206, 235],\n\tslateblue: [106, 90, 205],\n\tslategray: [112, 128, 144],\n\tslategrey: [112, 128, 144],\n\tsnow: [255, 250, 250],\n\tspringgreen: [0, 255, 127],\n\tsteelblue: [70, 130, 180],\n\ttan: [210, 180, 140],\n\tteal: [0, 128, 128],\n\tthistle: [216, 191, 216],\n\ttomato: [255, 99, 71],\n\tturquoise: [64, 224, 208],\n\tviolet: [238, 130, 238],\n\twheat: [245, 222, 179],\n\twhite: [255, 255, 255],\n\twhitesmoke: [245, 245, 245],\n\tyellow: [255, 255, 0],\n\tyellowgreen: [154, 205, 50]\n}\n","/**\n * @module color-parse\n */\nimport names from 'color-name'\n\nexport default parse\n\n/**\n * Base hues\n * http://dev.w3.org/csswg/css-color/#typedef-named-hue\n */\n//FIXME: use external hue detector\nvar baseHues = {\n\tred: 0,\n\torange: 60,\n\tyellow: 120,\n\tgreen: 180,\n\tblue: 240,\n\tpurple: 300\n}\n\n/**\n * Parse color from the string passed\n *\n * @return {Object} A space indicator `space`, an array `values` and `alpha`\n */\nfunction parse(cstr) {\n\tvar m, parts = [], alpha = 1, space\n\n\t//numeric case\n\tif (typeof cstr === 'number') {\n\t\treturn { space: 'rgb', values: [cstr >>> 16, (cstr & 0x00ff00) >>> 8, cstr & 0x0000ff], alpha: 1 }\n\t}\n\tif (typeof cstr === 'number') return { space: 'rgb', values: [cstr >>> 16, (cstr & 0x00ff00) >>> 8, cstr & 0x0000ff], alpha: 1 }\n\n\tcstr = String(cstr).toLowerCase();\n\n\t//keyword\n\tif (names[cstr]) {\n\t\tparts = names[cstr].slice()\n\t\tspace = 'rgb'\n\t}\n\n\t//reserved words\n\telse if (cstr === 'transparent') {\n\t\talpha = 0\n\t\tspace = 'rgb'\n\t\tparts = [0, 0, 0]\n\t}\n\n\t//hex\n\telse if (cstr[0] === '#') {\n\t\tvar base = cstr.slice(1)\n\t\tvar size = base.length\n\t\tvar isShort = size <= 4\n\t\talpha = 1\n\n\t\tif (isShort) {\n\t\t\tparts = [\n\t\t\t\tparseInt(base[0] + base[0], 16),\n\t\t\t\tparseInt(base[1] + base[1], 16),\n\t\t\t\tparseInt(base[2] + base[2], 16)\n\t\t\t]\n\t\t\tif (size === 4) {\n\t\t\t\talpha = parseInt(base[3] + base[3], 16) / 255\n\t\t\t}\n\t\t}\n\t\telse {\n\t\t\tparts = [\n\t\t\t\tparseInt(base[0] + base[1], 16),\n\t\t\t\tparseInt(base[2] + base[3], 16),\n\t\t\t\tparseInt(base[4] + base[5], 16)\n\t\t\t]\n\t\t\tif (size === 8) {\n\t\t\t\talpha = parseInt(base[6] + base[7], 16) / 255\n\t\t\t}\n\t\t}\n\n\t\tif (!parts[0]) parts[0] = 0\n\t\tif (!parts[1]) parts[1] = 0\n\t\tif (!parts[2]) parts[2] = 0\n\n\t\tspace = 'rgb'\n\t}\n\n\t// color space\n\telse if (m = /^((?:rgba?|hs[lvb]a?|hwba?|cmyk?|xy[zy]|gray|lab|lchu?v?|[ly]uv|lms|oklch|oklab|color))\\s*\\(([^\\)]*)\\)/.exec(cstr)) {\n\t\tvar name = m[1]\n\t\tspace = name.replace(/a$/, '')\n\t\tvar dims = space === 'cmyk' ? 4 : space === 'gray' ? 1 : 3\n\t\tparts = m[2].trim().split(/\\s*[,\\/]\\s*|\\s+/)\n\n\t\t// color(srgb-linear x x x) -> srgb-linear(x x x)\n\t\tif (space === 'color') space = parts.shift()\n\n\t\tparts = parts.map(function (x, i) {\n\t\t\t//\n\t\t\tif (x[x.length - 1] === '%') {\n\t\t\t\tx = parseFloat(x) / 100\n\t\t\t\t// alpha -> 0..1\n\t\t\t\tif (i === 3) return x\n\t\t\t\t// rgb -> 0..255\n\t\t\t\tif (space === 'rgb') return x * 255\n\t\t\t\t// hsl, hwb H -> 0..100\n\t\t\t\tif (space[0] === 'h') return x * 100\n\t\t\t\t// lch, lab L -> 0..100\n\t\t\t\tif (space[0] === 'l' && !i) return x * 100\n\t\t\t\t// lab A B -> -125..125\n\t\t\t\tif (space === 'lab') return x * 125\n\t\t\t\t// lch C -> 0..150, H -> 0..360\n\t\t\t\tif (space === 'lch') return i < 2 ? x * 150 : x * 360\n\t\t\t\t// oklch/oklab L -> 0..1\n\t\t\t\tif (space[0] === 'o' && !i) return x\n\t\t\t\t// oklab A B -> -0.4..0.4\n\t\t\t\tif (space === 'oklab') return x * 0.4\n\t\t\t\t// oklch C -> 0..0.4, H -> 0..360\n\t\t\t\tif (space === 'oklch') return i < 2 ? x * 0.4 : x * 360\n\t\t\t\t// color(xxx) -> 0..1\n\t\t\t\treturn x\n\t\t\t}\n\n\t\t\t//hue\n\t\t\tif (space[i] === 'h' || (i === 2 && space[space.length - 1] === 'h')) {\n\t\t\t\t//\n\t\t\t\tif (baseHues[x] !== undefined) return baseHues[x]\n\t\t\t\t//\n\t\t\t\tif (x.endsWith('deg')) return parseFloat(x)\n\t\t\t\t//\n\t\t\t\tif (x.endsWith('turn')) return parseFloat(x) * 360\n\t\t\t\tif (x.endsWith('grad')) return parseFloat(x) * 360 / 400\n\t\t\t\tif (x.endsWith('rad')) return parseFloat(x) * 180 / Math.PI\n\t\t\t}\n\t\t\tif (x === 'none') return 0\n\t\t\treturn parseFloat(x)\n\t\t});\n\n\t\talpha = parts.length > dims ? parts.pop() : 1\n\t}\n\n\t//named channels case\n\telse if (/[0-9](?:\\s|\\/|,)/.test(cstr)) {\n\t\tparts = cstr.match(/([0-9]+)/g).map(function (value) {\n\t\t\treturn parseFloat(value)\n\t\t})\n\n\t\tspace = cstr.match(/([a-z])/ig)?.join('')?.toLowerCase() || 'rgb'\n\t}\n\n\treturn {\n\t\tspace,\n\t\tvalues: parts,\n\t\talpha\n\t}\n}\n","/**\n * @module color-space/hsl\n */\nimport rgb from './rgb.js';\n\nexport default {\n\tname: 'hsl',\n\tmin: [0,0,0],\n\tmax: [360,100,100],\n\tchannel: ['hue', 'saturation', 'lightness'],\n\talias: ['HSL'],\n\n\trgb: function(hsl) {\n\t\tvar h = hsl[0]/360, s = hsl[1]/100, l = hsl[2]/100, t1, t2, t3, rgb, val, i=0;\n\n\t\tif (s === 0) return val = l * 255, [val, val, val];\n\n\t\tt2 = l < 0.5 ? l * (1 + s) : l + s - l * s;\n\t\tt1 = 2 * l - t2;\n\n\t\trgb = [0, 0, 0];\n\t\tfor (;i<3;) {\n\t\t\tt3 = h + 1 / 3 * - (i - 1);\n\t\t\tt3 < 0 ? t3++ : t3 > 1 && t3--;\n\t\t\tval = 6 * t3 < 1 ? t1 + (t2 - t1) * 6 * t3 :\n\t\t\t2 * t3 < 1 ? t2 :\n\t\t\t3 * t3 < 2 ? t1 + (t2 - t1) * (2 / 3 - t3) * 6 :\n\t\t\tt1;\n\t\t\trgb[i++] = val * 255;\n\t\t}\n\n\t\treturn rgb;\n\t}\n};\n\n\n//extend rgb\nrgb.hsl = function(rgb) {\n\tvar r = rgb[0]/255,\n\t\t\tg = rgb[1]/255,\n\t\t\tb = rgb[2]/255,\n\t\t\tmin = Math.min(r, g, b),\n\t\t\tmax = Math.max(r, g, b),\n\t\t\tdelta = max - min,\n\t\t\th, s, l;\n\n\tif (max === min) {\n\t\th = 0;\n\t}\n\telse if (r === max) {\n\t\th = (g - b) / delta;\n\t}\n\telse if (g === max) {\n\t\th = 2 + (b - r) / delta;\n\t}\n\telse if (b === max) {\n\t\th = 4 + (r - g)/ delta;\n\t}\n\n\th = Math.min(h * 60, 360);\n\n\tif (h < 0) {\n\t\th += 360;\n\t}\n\n\tl = (min + max) / 2;\n\n\tif (max === min) {\n\t\ts = 0;\n\t}\n\telse if (l <= 0.5) {\n\t\ts = delta / (max + min);\n\t}\n\telse {\n\t\ts = delta / (2 - max - min);\n\t}\n\n\treturn [h, s * 100, l * 100];\n};\n","/** @module color-rgba */\nimport parse from 'color-parse'\nimport rgb from 'color-space/rgb.js'\nimport hsl from 'color-space/hsl.js'\n\nexport default function rgba(color) {\n\t// template literals\n\tif (Array.isArray(color) && color.raw) color = String.raw(...arguments)\n\tif (color instanceof Number) color = +color\n\n\tvar values, i, l\n\n\t//attempt to parse non-array arguments\n\tvar parsed = parse(color)\n\n\tif (!parsed.space) return []\n\n\tconst min = parsed.space[0] === 'h' ? hsl.min : rgb.min\n\tconst max = parsed.space[0] === 'h' ? hsl.max : rgb.max\n\n\tvalues = Array(3)\n\tvalues[0] = Math.min(Math.max(parsed.values[0], min[0]), max[0])\n\tvalues[1] = Math.min(Math.max(parsed.values[1], min[1]), max[1])\n\tvalues[2] = Math.min(Math.max(parsed.values[2], min[2]), max[2])\n\n\tif (parsed.space[0] === 'h') {\n\t\tvalues = hsl.rgb(values)\n\t}\n\n\tvalues.push(Math.min(Math.max(parsed.alpha, 0), 1))\n\n\treturn values\n}\n","/**\n * @module ol/color\n */\nimport lchuv from 'color-space/lchuv.js';\nimport parseRgba from 'color-rgba';\nimport rgb from 'color-space/rgb.js';\nimport xyz from 'color-space/xyz.js';\nimport {clamp} from './math.js';\n\n/**\n * A color represented as a short array [red, green, blue, alpha].\n * red, green, and blue should be integers in the range 0..255 inclusive.\n * alpha should be a float in the range 0..1 inclusive. If no alpha value is\n * given then `1` will be used.\n * @typedef {Array} Color\n * @api\n */\n\n/**\n * Return the color as an rgba string.\n * @param {Color|string} color Color.\n * @return {string} Rgba string.\n * @api\n */\nexport function asString(color) {\n if (typeof color === 'string') {\n return color;\n }\n return toString(color);\n}\n\n/**\n * @type {number}\n */\nconst MAX_CACHE_SIZE = 1024;\n\n/**\n * We maintain a small cache of parsed strings. Whenever the cache grows too large,\n * we delete an arbitrary set of the entries.\n *\n * @type {Object}\n */\nconst cache = {};\n\n/**\n * @type {number}\n */\nlet cacheSize = 0;\n\n/**\n * @param {Color} color A color that may or may not have an alpha channel.\n * @return {Color} The input color with an alpha channel. If the input color has\n * an alpha channel, the input color will be returned unchanged. Otherwise, a new\n * array will be returned with the input color and an alpha channel of 1.\n */\nexport function withAlpha(color) {\n if (color.length === 4) {\n return color;\n }\n const output = color.slice();\n output[3] = 1;\n return output;\n}\n\n/**\n * @param {Color} color RGBA color.\n * @return {Color} LCHuv color with alpha.\n */\nexport function rgbaToLcha(color) {\n const output = xyz.lchuv(rgb.xyz(color));\n output[3] = color[3];\n return output;\n}\n\n/**\n * @param {Color} color LCHuv color with alpha.\n * @return {Color} RGBA color.\n */\nexport function lchaToRgba(color) {\n const output = xyz.rgb(lchuv.xyz(color));\n output[3] = color[3];\n return output;\n}\n\n/**\n * @param {string} s String.\n * @return {Color} Color.\n */\nexport function fromString(s) {\n if (cache.hasOwnProperty(s)) {\n return cache[s];\n }\n if (cacheSize >= MAX_CACHE_SIZE) {\n let i = 0;\n for (const key in cache) {\n if ((i++ & 3) === 0) {\n delete cache[key];\n --cacheSize;\n }\n }\n }\n\n const color = parseRgba(s);\n if (color.length !== 4) {\n throw new Error('Failed to parse \"' + s + '\" as color');\n }\n for (const c of color) {\n if (isNaN(c)) {\n throw new Error('Failed to parse \"' + s + '\" as color');\n }\n }\n normalize(color);\n cache[s] = color;\n ++cacheSize;\n return color;\n}\n\n/**\n * Return the color as an array. This function maintains a cache of calculated\n * arrays which means the result should not be modified.\n * @param {Color|string} color Color.\n * @return {Color} Color.\n * @api\n */\nexport function asArray(color) {\n if (Array.isArray(color)) {\n return color;\n }\n return fromString(color);\n}\n\n/**\n * Exported for the tests.\n * @param {Color} color Color.\n * @return {Color} Clamped color.\n */\nexport function normalize(color) {\n color[0] = clamp((color[0] + 0.5) | 0, 0, 255);\n color[1] = clamp((color[1] + 0.5) | 0, 0, 255);\n color[2] = clamp((color[2] + 0.5) | 0, 0, 255);\n color[3] = clamp(color[3], 0, 1);\n return color;\n}\n\n/**\n * @param {Color} color Color.\n * @return {string} String.\n */\nexport function toString(color) {\n let r = color[0];\n if (r != (r | 0)) {\n r = (r + 0.5) | 0;\n }\n let g = color[1];\n if (g != (g | 0)) {\n g = (g + 0.5) | 0;\n }\n let b = color[2];\n if (b != (b | 0)) {\n b = (b + 0.5) | 0;\n }\n const a = color[3] === undefined ? 1 : Math.round(color[3] * 1000) / 1000;\n return 'rgba(' + r + ',' + g + ',' + b + ',' + a + ')';\n}\n\n/**\n * @param {string} s String.\n * @return {boolean} Whether the string is actually a valid color\n */\nexport function isStringColor(s) {\n try {\n fromString(s);\n return true;\n } catch (_) {\n return false;\n }\n}\n","/**\n * @module ol/has\n */\n\nconst ua =\n typeof navigator !== 'undefined' && typeof navigator.userAgent !== 'undefined'\n ? navigator.userAgent.toLowerCase()\n : '';\n\n/**\n * User agent string says we are dealing with Firefox as browser.\n * @type {boolean}\n */\nexport const FIREFOX = ua.includes('firefox');\n\n/**\n * User agent string says we are dealing with Safari as browser.\n * @type {boolean}\n */\nexport const SAFARI = ua.includes('safari') && !ua.includes('chrom');\n\n/**\n * https://bugs.webkit.org/show_bug.cgi?id=237906\n * @type {boolean}\n */\nexport const SAFARI_BUG_237906 =\n SAFARI &&\n (ua.includes('version/15.4') ||\n /cpu (os|iphone os) 15_4 like mac os x/.test(ua));\n\n/**\n * User agent string says we are dealing with a WebKit engine.\n * @type {boolean}\n */\nexport const WEBKIT = ua.includes('webkit') && !ua.includes('edge');\n\n/**\n * User agent string says we are dealing with a Mac as platform.\n * @type {boolean}\n */\nexport const MAC = ua.includes('macintosh');\n\n/**\n * The ratio between physical pixels and device-independent pixels\n * (dips) on the device (`window.devicePixelRatio`).\n * @const\n * @type {number}\n * @api\n */\nexport const DEVICE_PIXEL_RATIO =\n typeof devicePixelRatio !== 'undefined' ? devicePixelRatio : 1;\n\n/**\n * The execution context is a worker with OffscreenCanvas available.\n * @const\n * @type {boolean}\n */\nexport const WORKER_OFFSCREEN_CANVAS =\n typeof WorkerGlobalScope !== 'undefined' &&\n typeof OffscreenCanvas !== 'undefined' &&\n self instanceof WorkerGlobalScope; //eslint-disable-line\n\n/**\n * Image.prototype.decode() is supported.\n * @type {boolean}\n */\nexport const IMAGE_DECODE =\n typeof Image !== 'undefined' && Image.prototype.decode;\n\n/**\n * createImageBitmap() is supported.\n * @type {boolean}\n */\nexport const CREATE_IMAGE_BITMAP = typeof createImageBitmap === 'function';\n\n/**\n * @type {boolean}\n */\nexport const PASSIVE_EVENT_LISTENERS = (function () {\n let passive = false;\n try {\n const options = Object.defineProperty({}, 'passive', {\n get: function () {\n passive = true;\n },\n });\n\n // @ts-ignore Ignore invalid event type '_'\n window.addEventListener('_', null, options);\n // @ts-ignore Ignore invalid event type '_'\n window.removeEventListener('_', null, options);\n } catch (error) {\n // passive not supported\n }\n return passive;\n})();\n","import {WORKER_OFFSCREEN_CANVAS} from './has.js';\n\n/**\n * @module ol/dom\n */\n\n//FIXME Move this function to the canvas module\n/**\n * Create an html canvas element and returns its 2d context.\n * @param {number} [width] Canvas width.\n * @param {number} [height] Canvas height.\n * @param {Array} [canvasPool] Canvas pool to take existing canvas from.\n * @param {CanvasRenderingContext2DSettings} [settings] CanvasRenderingContext2DSettings\n * @return {CanvasRenderingContext2D} The context.\n */\nexport function createCanvasContext2D(width, height, canvasPool, settings) {\n /** @type {HTMLCanvasElement|OffscreenCanvas} */\n let canvas;\n if (canvasPool && canvasPool.length) {\n canvas = /** @type {HTMLCanvasElement} */ (canvasPool.shift());\n } else if (WORKER_OFFSCREEN_CANVAS) {\n canvas = new OffscreenCanvas(width || 300, height || 300);\n } else {\n canvas = document.createElement('canvas');\n }\n if (width) {\n canvas.width = width;\n }\n if (height) {\n canvas.height = height;\n }\n //FIXME Allow OffscreenCanvasRenderingContext2D as return type\n return /** @type {CanvasRenderingContext2D} */ (\n canvas.getContext('2d', settings)\n );\n}\n\n/** @type {CanvasRenderingContext2D} */\nlet sharedCanvasContext;\n\n/**\n * @return {CanvasRenderingContext2D} Shared canvas context.\n */\nexport function getSharedCanvasContext2D() {\n if (!sharedCanvasContext) {\n sharedCanvasContext = createCanvasContext2D(1, 1);\n }\n return sharedCanvasContext;\n}\n\n/**\n * Releases canvas memory to avoid exceeding memory limits in Safari.\n * See https://pqina.nl/blog/total-canvas-memory-use-exceeds-the-maximum-limit/\n * @param {CanvasRenderingContext2D} context Context.\n */\nexport function releaseCanvas(context) {\n const canvas = context.canvas;\n canvas.width = 1;\n canvas.height = 1;\n context.clearRect(0, 0, 1, 1);\n}\n\n/**\n * Get the current computed width for the given element including margin,\n * padding and border.\n * Equivalent to jQuery's `$(el).outerWidth(true)`.\n * @param {!HTMLElement} element Element.\n * @return {number} The width.\n */\nexport function outerWidth(element) {\n let width = element.offsetWidth;\n const style = getComputedStyle(element);\n width += parseInt(style.marginLeft, 10) + parseInt(style.marginRight, 10);\n\n return width;\n}\n\n/**\n * Get the current computed height for the given element including margin,\n * padding and border.\n * Equivalent to jQuery's `$(el).outerHeight(true)`.\n * @param {!HTMLElement} element Element.\n * @return {number} The height.\n */\nexport function outerHeight(element) {\n let height = element.offsetHeight;\n const style = getComputedStyle(element);\n height += parseInt(style.marginTop, 10) + parseInt(style.marginBottom, 10);\n\n return height;\n}\n\n/**\n * @param {Node} newNode Node to replace old node\n * @param {Node} oldNode The node to be replaced\n */\nexport function replaceNode(newNode, oldNode) {\n const parent = oldNode.parentNode;\n if (parent) {\n parent.replaceChild(newNode, oldNode);\n }\n}\n\n/**\n * @param {Node} node The node to remove.\n * @return {Node|null} The node that was removed or null.\n */\nexport function removeNode(node) {\n return node && node.parentNode ? node.parentNode.removeChild(node) : null;\n}\n\n/**\n * @param {Node} node The node to remove the children from.\n */\nexport function removeChildren(node) {\n while (node.lastChild) {\n node.removeChild(node.lastChild);\n }\n}\n\n/**\n * Transform the children of a parent node so they match the\n * provided list of children. This function aims to efficiently\n * remove, add, and reorder child nodes while maintaining a simple\n * implementation (it is not guaranteed to minimize DOM operations).\n * @param {Node} node The parent node whose children need reworking.\n * @param {Array} children The desired children.\n */\nexport function replaceChildren(node, children) {\n const oldChildren = node.childNodes;\n\n for (let i = 0; true; ++i) {\n const oldChild = oldChildren[i];\n const newChild = children[i];\n\n // check if our work is done\n if (!oldChild && !newChild) {\n break;\n }\n\n // check if children match\n if (oldChild === newChild) {\n continue;\n }\n\n // check if a new child needs to be added\n if (!oldChild) {\n node.appendChild(newChild);\n continue;\n }\n\n // check if an old child needs to be removed\n if (!newChild) {\n node.removeChild(oldChild);\n --i;\n continue;\n }\n\n // reorder\n node.insertBefore(newChild, oldChild);\n }\n}\n","/**\n * @module ol/Image\n */\nimport EventTarget from './events/Target.js';\nimport EventType from './events/EventType.js';\nimport ImageState from './ImageState.js';\nimport {CREATE_IMAGE_BITMAP, IMAGE_DECODE} from './has.js';\nimport {listenOnce, unlistenByKey} from './events.js';\nimport {toPromise} from './functions.js';\n\n/**\n * A function that takes an {@link module:ol/Image~ImageWrapper} for the image and a\n * `{string}` for the src as arguments. It is supposed to make it so the\n * underlying image {@link module:ol/Image~ImageWrapper#getImage} is assigned the\n * content specified by the src. If not specified, the default is\n *\n * function(image, src) {\n * image.getImage().src = src;\n * }\n *\n * Providing a custom `imageLoadFunction` can be useful to load images with\n * post requests or - in general - through XHR requests, where the src of the\n * image element would be set to a data URI when the content is loaded.\n *\n * @typedef {function(import(\"./Image.js\").default, string): void} LoadFunction\n * @api\n */\n\n/**\n * @typedef {Object} ImageObject\n * @property {import(\"./extent.js\").Extent} [extent] Extent, if different from the requested one.\n * @property {import(\"./resolution.js\").ResolutionLike} [resolution] Resolution, if different from the requested one.\n * When x and y resolution are different, use the array type (`[xResolution, yResolution]`).\n * @property {number} [pixelRatio] Pixel ratio, if different from the requested one.\n * @property {import('./DataTile.js').ImageLike} image Image.\n */\n\n/**\n * Loader function used for image sources. Receives extent, resolution and pixel ratio as arguments.\n * For images that cover any extent and resolution (static images), the loader function should not accept\n * any arguments. The function returns an {@link import(\"./DataTile.js\").ImageLike image}, an\n * {@link import(\"./Image.js\").ImageObject image object}, or a promise for the same.\n * For loaders that generate images, the promise should not resolve until the image is loaded.\n * If the returned image does not match the extent, resolution or pixel ratio passed to the loader,\n * it has to return an {@link import(\"./Image.js\").ImageObject image object} with the `image` and the\n * correct `extent`, `resolution` and `pixelRatio`.\n *\n * @typedef {function(import(\"./extent.js\").Extent, number, number, (function(HTMLImageElement, string): void)=): import(\"./DataTile.js\").ImageLike|ImageObject|Promise} Loader\n * @api\n */\n\n/**\n * Loader function used for image sources. Receives extent, resolution and pixel ratio as arguments.\n * The function returns a promise for an {@link import(\"./Image.js\").ImageObject image object}.\n *\n * @typedef {function(import(\"./extent.js\").Extent, number, number, (function(HTMLImageElement, string): void)=): import(\"./DataTile.js\").ImageLike|ImageObject|Promise} ImageObjectPromiseLoader\n */\n\nclass ImageWrapper extends EventTarget {\n /**\n * @param {import(\"./extent.js\").Extent} extent Extent.\n * @param {number|Array|undefined} resolution Resolution. If provided as array, x and y\n * resolution will be assumed.\n * @param {number} pixelRatio Pixel ratio.\n * @param {import(\"./ImageState.js\").default|import(\"./Image.js\").Loader} stateOrLoader State.\n */\n constructor(extent, resolution, pixelRatio, stateOrLoader) {\n super();\n\n /**\n * @protected\n * @type {import(\"./extent.js\").Extent}\n */\n this.extent = extent;\n\n /**\n * @private\n * @type {number}\n */\n this.pixelRatio_ = pixelRatio;\n\n /**\n * @protected\n * @type {number|Array|undefined}\n */\n this.resolution = resolution;\n\n /**\n * @protected\n * @type {import(\"./ImageState.js\").default}\n */\n this.state =\n typeof stateOrLoader === 'function' ? ImageState.IDLE : stateOrLoader;\n\n /**\n * @private\n * @type {import('./DataTile.js').ImageLike|null}\n */\n this.image_ = null;\n\n /**\n * @protected\n * @type {import(\"./Image.js\").Loader}\n */\n this.loader = typeof stateOrLoader === 'function' ? stateOrLoader : null;\n }\n\n /**\n * @protected\n */\n changed() {\n this.dispatchEvent(EventType.CHANGE);\n }\n\n /**\n * @return {import(\"./extent.js\").Extent} Extent.\n */\n getExtent() {\n return this.extent;\n }\n\n /**\n * @return {import('./DataTile.js').ImageLike} Image.\n */\n getImage() {\n return this.image_;\n }\n\n /**\n * @return {number} PixelRatio.\n */\n getPixelRatio() {\n return this.pixelRatio_;\n }\n\n /**\n * @return {number|Array} Resolution.\n */\n getResolution() {\n return /** @type {number} */ (this.resolution);\n }\n\n /**\n * @return {import(\"./ImageState.js\").default} State.\n */\n getState() {\n return this.state;\n }\n\n /**\n * Load not yet loaded URI.\n */\n load() {\n if (this.state == ImageState.IDLE) {\n if (this.loader) {\n this.state = ImageState.LOADING;\n this.changed();\n const resolution = this.getResolution();\n const requestResolution = Array.isArray(resolution)\n ? resolution[0]\n : resolution;\n toPromise(() =>\n this.loader(\n this.getExtent(),\n requestResolution,\n this.getPixelRatio(),\n ),\n )\n .then((image) => {\n if ('image' in image) {\n this.image_ = image.image;\n }\n if ('extent' in image) {\n this.extent = image.extent;\n }\n if ('resolution' in image) {\n this.resolution = image.resolution;\n }\n if ('pixelRatio' in image) {\n this.pixelRatio_ = image.pixelRatio;\n }\n if (\n image instanceof HTMLImageElement ||\n image instanceof ImageBitmap ||\n image instanceof HTMLCanvasElement ||\n image instanceof HTMLVideoElement\n ) {\n this.image_ = image;\n }\n this.state = ImageState.LOADED;\n })\n .catch((error) => {\n this.state = ImageState.ERROR;\n console.error(error); // eslint-disable-line no-console\n })\n .finally(() => this.changed());\n }\n }\n }\n\n /**\n * @param {import('./DataTile.js').ImageLike} image The image.\n */\n setImage(image) {\n this.image_ = image;\n }\n\n /**\n * @param {number|Array} resolution Resolution.\n */\n setResolution(resolution) {\n this.resolution = resolution;\n }\n}\n\n/**\n * @param {import('./DataTile.js').ImageLike} image Image element.\n * @param {function():any} loadHandler Load callback function.\n * @param {function():any} errorHandler Error callback function.\n * @return {function():void} Callback to stop listening.\n */\nexport function listenImage(image, loadHandler, errorHandler) {\n const img = /** @type {HTMLImageElement} */ (image);\n let listening = true;\n let decoding = false;\n let loaded = false;\n\n const listenerKeys = [\n listenOnce(img, EventType.LOAD, function () {\n loaded = true;\n if (!decoding) {\n loadHandler();\n }\n }),\n ];\n\n if (img.src && IMAGE_DECODE) {\n decoding = true;\n img\n .decode()\n .then(function () {\n if (listening) {\n loadHandler();\n }\n })\n .catch(function (error) {\n if (listening) {\n if (loaded) {\n loadHandler();\n } else {\n errorHandler();\n }\n }\n });\n } else {\n listenerKeys.push(listenOnce(img, EventType.ERROR, errorHandler));\n }\n\n return function unlisten() {\n listening = false;\n listenerKeys.forEach(unlistenByKey);\n };\n}\n\n/**\n * Loads an image.\n * @param {HTMLImageElement} image Image, not yet loaded.\n * @param {string} [src] `src` attribute of the image. Optional, not required if already present.\n * @return {Promise} Promise resolving to an `HTMLImageElement`.\n * @api\n */\nexport function load(image, src) {\n return new Promise((resolve, reject) => {\n function handleLoad() {\n unlisten();\n resolve(image);\n }\n function handleError() {\n unlisten();\n reject(new Error('Image load error'));\n }\n function unlisten() {\n image.removeEventListener('load', handleLoad);\n image.removeEventListener('error', handleError);\n }\n image.addEventListener('load', handleLoad);\n image.addEventListener('error', handleError);\n if (src) {\n image.src = src;\n }\n });\n}\n\n/**\n * @param {HTMLImageElement} image Image, not yet loaded.\n * @param {string} [src] `src` attribute of the image. Optional, not required if already present.\n * @return {Promise} Promise resolving to an `HTMLImageElement`.\n */\nexport function decodeFallback(image, src) {\n if (src) {\n image.src = src;\n }\n return image.src && IMAGE_DECODE\n ? new Promise((resolve, reject) =>\n image\n .decode()\n .then(() => resolve(image))\n .catch((e) =>\n image.complete && image.width ? resolve(image) : reject(e),\n ),\n )\n : load(image);\n}\n\n/**\n * Loads an image and decodes it to an `ImageBitmap` if `createImageBitmap()` is supported. Returns\n * the loaded image otherwise.\n * @param {HTMLImageElement} image Image, not yet loaded.\n * @param {string} [src] `src` attribute of the image. Optional, not required if already present.\n * @return {Promise} Promise resolving to an `ImageBitmap` or an\n * `HTMLImageElement` if `createImageBitmap()` is not supported.\n * @api\n */\nexport function decode(image, src) {\n if (src) {\n image.src = src;\n }\n return image.src && IMAGE_DECODE && CREATE_IMAGE_BITMAP\n ? image\n .decode()\n .then(() => createImageBitmap(image))\n .catch((e) => {\n if (image.complete && image.width) {\n return image;\n }\n throw e;\n })\n : decodeFallback(image);\n}\n\nexport default ImageWrapper;\n","/**\n * @module ol/style/IconImageCache\n */\nimport ImageState from '../ImageState.js';\nimport {asArray} from '../color.js';\nimport {getSharedCanvasContext2D} from '../dom.js';\n\n/**\n * @classdesc\n * Singleton class. Available through {@link module:ol/style/IconImageCache.shared}.\n */\nclass IconImageCache {\n constructor() {\n /**\n * @type {!Object}\n * @private\n */\n this.cache_ = {};\n\n /**\n * @type {!Object}\n * @private\n */\n this.patternCache_ = {};\n\n /**\n * @type {number}\n * @private\n */\n this.cacheSize_ = 0;\n\n /**\n * @type {number}\n * @private\n */\n this.maxCacheSize_ = 32;\n }\n\n /**\n * FIXME empty description for jsdoc\n */\n clear() {\n this.cache_ = {};\n this.patternCache_ = {};\n this.cacheSize_ = 0;\n }\n\n /**\n * @return {boolean} Can expire cache.\n */\n canExpireCache() {\n return this.cacheSize_ > this.maxCacheSize_;\n }\n\n /**\n * FIXME empty description for jsdoc\n */\n expire() {\n if (this.canExpireCache()) {\n let i = 0;\n for (const key in this.cache_) {\n const iconImage = this.cache_[key];\n if ((i++ & 3) === 0 && !iconImage.hasListener()) {\n delete this.cache_[key];\n delete this.patternCache_[key];\n --this.cacheSize_;\n }\n }\n }\n }\n\n /**\n * @param {string} src Src.\n * @param {?string} crossOrigin Cross origin.\n * @param {import(\"../color.js\").Color|string|null} color Color.\n * @return {import(\"./IconImage.js\").default} Icon image.\n */\n get(src, crossOrigin, color) {\n const key = getCacheKey(src, crossOrigin, color);\n return key in this.cache_ ? this.cache_[key] : null;\n }\n\n /**\n * @param {string} src Src.\n * @param {?string} crossOrigin Cross origin.\n * @param {import(\"../color.js\").Color|string|null} color Color.\n * @return {CanvasPattern} Icon image.\n */\n getPattern(src, crossOrigin, color) {\n const key = getCacheKey(src, crossOrigin, color);\n return key in this.patternCache_ ? this.patternCache_[key] : null;\n }\n\n /**\n * @param {string} src Src.\n * @param {?string} crossOrigin Cross origin.\n * @param {import(\"../color.js\").Color|string|null} color Color.\n * @param {import(\"./IconImage.js\").default|null} iconImage Icon image.\n * @param {boolean} [pattern] Also cache a `'repeat'` pattern with this `iconImage`.\n */\n set(src, crossOrigin, color, iconImage, pattern) {\n const key = getCacheKey(src, crossOrigin, color);\n const update = key in this.cache_;\n this.cache_[key] = iconImage;\n if (pattern) {\n if (iconImage.getImageState() === ImageState.IDLE) {\n iconImage.load();\n }\n if (iconImage.getImageState() === ImageState.LOADING) {\n iconImage.ready().then(() => {\n this.patternCache_[key] = getSharedCanvasContext2D().createPattern(\n iconImage.getImage(1),\n 'repeat',\n );\n });\n } else {\n this.patternCache_[key] = getSharedCanvasContext2D().createPattern(\n iconImage.getImage(1),\n 'repeat',\n );\n }\n }\n if (!update) {\n ++this.cacheSize_;\n }\n }\n\n /**\n * Set the cache size of the icon cache. Default is `32`. Change this value when\n * your map uses more than 32 different icon images and you are not caching icon\n * styles on the application level.\n * @param {number} maxCacheSize Cache max size.\n * @api\n */\n setSize(maxCacheSize) {\n this.maxCacheSize_ = maxCacheSize;\n this.expire();\n }\n}\n\n/**\n * @param {string} src Src.\n * @param {?string} crossOrigin Cross origin.\n * @param {import(\"../color.js\").Color|string|null} color Color.\n * @return {string} Cache key.\n */\nexport function getCacheKey(src, crossOrigin, color) {\n const colorString = color ? asArray(color) : 'null';\n return crossOrigin + ':' + src + ':' + colorString;\n}\n\nexport default IconImageCache;\n\n/**\n * The {@link module:ol/style/IconImageCache~IconImageCache} for\n * {@link module:ol/style/Icon~Icon} images.\n * @api\n */\nexport const shared = new IconImageCache();\n","/**\n * @module ol/style/IconImage\n */\n\nimport EventTarget from '../events/Target.js';\nimport EventType from '../events/EventType.js';\nimport ImageState from '../ImageState.js';\nimport {asString} from '../color.js';\nimport {createCanvasContext2D} from '../dom.js';\nimport {decodeFallback} from '../Image.js';\nimport {shared as iconImageCache} from './IconImageCache.js';\n\n/**\n * @type {CanvasRenderingContext2D}\n */\nlet taintedTestContext = null;\n\nclass IconImage extends EventTarget {\n /**\n * @param {HTMLImageElement|HTMLCanvasElement|ImageBitmap|null} image Image.\n * @param {string|undefined} src Src.\n * @param {?string} crossOrigin Cross origin.\n * @param {import(\"../ImageState.js\").default|undefined} imageState Image state.\n * @param {import(\"../color.js\").Color|string|null} color Color.\n */\n constructor(image, src, crossOrigin, imageState, color) {\n super();\n\n /**\n * @private\n * @type {HTMLImageElement|HTMLCanvasElement|ImageBitmap}\n */\n this.hitDetectionImage_ = null;\n\n /**\n * @private\n * @type {HTMLImageElement|HTMLCanvasElement|ImageBitmap|null}\n */\n this.image_ = image;\n\n /**\n * @private\n * @type {string|null}\n */\n this.crossOrigin_ = crossOrigin;\n\n /**\n * @private\n * @type {Object}\n */\n this.canvas_ = {};\n\n /**\n * @private\n * @type {import(\"../color.js\").Color|string|null}\n */\n this.color_ = color;\n\n /**\n * @private\n * @type {import(\"../ImageState.js\").default}\n */\n this.imageState_ = imageState === undefined ? ImageState.IDLE : imageState;\n\n /**\n * @private\n * @type {import(\"../size.js\").Size|null}\n */\n this.size_ =\n image && image.width && image.height ? [image.width, image.height] : null;\n\n /**\n * @private\n * @type {string|undefined}\n */\n this.src_ = src;\n\n /**\n * @private\n */\n this.tainted_;\n\n /**\n * @private\n * @type {Promise|null}\n */\n this.ready_ = null;\n }\n\n /**\n * @private\n */\n initializeImage_() {\n this.image_ = new Image();\n if (this.crossOrigin_ !== null) {\n this.image_.crossOrigin = this.crossOrigin_;\n }\n }\n\n /**\n * @private\n * @return {boolean} The image canvas is tainted.\n */\n isTainted_() {\n if (this.tainted_ === undefined && this.imageState_ === ImageState.LOADED) {\n if (!taintedTestContext) {\n taintedTestContext = createCanvasContext2D(1, 1, undefined, {\n willReadFrequently: true,\n });\n }\n taintedTestContext.drawImage(this.image_, 0, 0);\n try {\n taintedTestContext.getImageData(0, 0, 1, 1);\n this.tainted_ = false;\n } catch (e) {\n taintedTestContext = null;\n this.tainted_ = true;\n }\n }\n return this.tainted_ === true;\n }\n\n /**\n * @private\n */\n dispatchChangeEvent_() {\n this.dispatchEvent(EventType.CHANGE);\n }\n\n /**\n * @private\n */\n handleImageError_() {\n this.imageState_ = ImageState.ERROR;\n this.dispatchChangeEvent_();\n }\n\n /**\n * @private\n */\n handleImageLoad_() {\n this.imageState_ = ImageState.LOADED;\n this.size_ = [this.image_.width, this.image_.height];\n this.dispatchChangeEvent_();\n }\n\n /**\n * @param {number} pixelRatio Pixel ratio.\n * @return {HTMLImageElement|HTMLCanvasElement|ImageBitmap} Image or Canvas element or image bitmap.\n */\n getImage(pixelRatio) {\n if (!this.image_) {\n this.initializeImage_();\n }\n this.replaceColor_(pixelRatio);\n return this.canvas_[pixelRatio] ? this.canvas_[pixelRatio] : this.image_;\n }\n\n /**\n * @param {number} pixelRatio Pixel ratio.\n * @return {number} Image or Canvas element.\n */\n getPixelRatio(pixelRatio) {\n this.replaceColor_(pixelRatio);\n return this.canvas_[pixelRatio] ? pixelRatio : 1;\n }\n\n /**\n * @return {import(\"../ImageState.js\").default} Image state.\n */\n getImageState() {\n return this.imageState_;\n }\n\n /**\n * @return {HTMLImageElement|HTMLCanvasElement|ImageBitmap} Image element.\n */\n getHitDetectionImage() {\n if (!this.image_) {\n this.initializeImage_();\n }\n if (!this.hitDetectionImage_) {\n if (this.isTainted_()) {\n const width = this.size_[0];\n const height = this.size_[1];\n const context = createCanvasContext2D(width, height);\n context.fillRect(0, 0, width, height);\n this.hitDetectionImage_ = context.canvas;\n } else {\n this.hitDetectionImage_ = this.image_;\n }\n }\n return this.hitDetectionImage_;\n }\n\n /**\n * Get the size of the icon (in pixels).\n * @return {import(\"../size.js\").Size} Image size.\n */\n getSize() {\n return this.size_;\n }\n\n /**\n * @return {string|undefined} Image src.\n */\n getSrc() {\n return this.src_;\n }\n\n /**\n * Load not yet loaded URI.\n */\n load() {\n if (this.imageState_ !== ImageState.IDLE) {\n return;\n }\n if (!this.image_) {\n this.initializeImage_();\n }\n\n this.imageState_ = ImageState.LOADING;\n try {\n if (this.src_ !== undefined) {\n /** @type {HTMLImageElement} */ (this.image_).src = this.src_;\n }\n } catch (e) {\n this.handleImageError_();\n }\n if (this.image_ instanceof HTMLImageElement) {\n decodeFallback(this.image_, this.src_)\n .then((image) => {\n this.image_ = image;\n this.handleImageLoad_();\n })\n .catch(this.handleImageError_.bind(this));\n }\n }\n\n /**\n * @param {number} pixelRatio Pixel ratio.\n * @private\n */\n replaceColor_(pixelRatio) {\n if (\n !this.color_ ||\n this.canvas_[pixelRatio] ||\n this.imageState_ !== ImageState.LOADED\n ) {\n return;\n }\n\n const image = this.image_;\n const canvas = document.createElement('canvas');\n canvas.width = Math.ceil(image.width * pixelRatio);\n canvas.height = Math.ceil(image.height * pixelRatio);\n\n const ctx = canvas.getContext('2d');\n ctx.scale(pixelRatio, pixelRatio);\n ctx.drawImage(image, 0, 0);\n\n ctx.globalCompositeOperation = 'multiply';\n ctx.fillStyle = asString(this.color_);\n ctx.fillRect(0, 0, canvas.width / pixelRatio, canvas.height / pixelRatio);\n\n ctx.globalCompositeOperation = 'destination-in';\n ctx.drawImage(image, 0, 0);\n\n this.canvas_[pixelRatio] = canvas;\n }\n\n /**\n * @return {Promise} Promise that resolves when the image is loaded.\n */\n ready() {\n if (!this.ready_) {\n this.ready_ = new Promise((resolve) => {\n if (\n this.imageState_ === ImageState.LOADED ||\n this.imageState_ === ImageState.ERROR\n ) {\n resolve();\n } else {\n this.addEventListener(EventType.CHANGE, function onChange() {\n if (\n this.imageState_ === ImageState.LOADED ||\n this.imageState_ === ImageState.ERROR\n ) {\n this.removeEventListener(EventType.CHANGE, onChange);\n resolve();\n }\n });\n }\n });\n }\n return this.ready_;\n }\n}\n\n/**\n * @param {HTMLImageElement|HTMLCanvasElement|ImageBitmap|null} image Image.\n * @param {string|undefined} cacheKey Src.\n * @param {?string} crossOrigin Cross origin.\n * @param {import(\"../ImageState.js\").default|undefined} imageState Image state.\n * @param {import(\"../color.js\").Color|string|null} color Color.\n * @param {boolean} [pattern] Also cache a `repeat` pattern with the icon image.\n * @return {IconImage} Icon image.\n */\nexport function get(image, cacheKey, crossOrigin, imageState, color, pattern) {\n let iconImage =\n cacheKey === undefined\n ? undefined\n : iconImageCache.get(cacheKey, crossOrigin, color);\n if (!iconImage) {\n iconImage = new IconImage(\n image,\n image && 'src' in image ? image.src || undefined : cacheKey,\n crossOrigin,\n imageState,\n color,\n );\n iconImageCache.set(cacheKey, crossOrigin, color, iconImage, pattern);\n }\n if (\n pattern &&\n iconImage &&\n !iconImageCache.getPattern(cacheKey, crossOrigin, color)\n ) {\n iconImageCache.set(cacheKey, crossOrigin, color, iconImage, pattern);\n }\n return iconImage;\n}\n\nexport default IconImage;\n","/**\n * @module ol/style/Fill\n */\n\nimport ImageState from '../ImageState.js';\nimport {get as getIconImage} from './IconImage.js';\n\n/**\n * @typedef {Object} Options\n * @property {import(\"../color.js\").Color|import(\"../colorlike.js\").ColorLike|import('../colorlike.js').PatternDescriptor|null} [color=null] A color,\n * gradient or pattern.\n * See {@link module:ol/color~Color} and {@link module:ol/colorlike~ColorLike} for possible formats. For polygon fills (not for {@link import(\"./RegularShape.js\").default} fills),\n * a pattern can also be provided as {@link module:ol/colorlike~PatternDescriptor}.\n * Default null; if null, the Canvas/renderer default black will be used.\n */\n\n/**\n * @classdesc\n * Set fill style for vector features.\n * @api\n */\nclass Fill {\n /**\n * @param {Options} [options] Options.\n */\n constructor(options) {\n options = options || {};\n\n /**\n * @private\n * @type {import(\"./IconImage.js\").default|null}\n */\n this.patternImage_ = null;\n\n /**\n * @private\n * @type {import(\"../color.js\").Color|import(\"../colorlike.js\").ColorLike|import('../colorlike.js').PatternDescriptor|null}\n */\n this.color_ = null;\n if (options.color !== undefined) {\n this.setColor(options.color);\n }\n }\n\n /**\n * Clones the style. The color is not cloned if it is an {@link module:ol/colorlike~ColorLike}.\n * @return {Fill} The cloned style.\n * @api\n */\n clone() {\n const color = this.getColor();\n return new Fill({\n color: Array.isArray(color) ? color.slice() : color || undefined,\n });\n }\n\n /**\n * Get the fill color.\n * @return {import(\"../color.js\").Color|import(\"../colorlike.js\").ColorLike|import('../colorlike.js').PatternDescriptor|null} Color.\n * @api\n */\n getColor() {\n return this.color_;\n }\n\n /**\n * Set the color.\n *\n * @param {import(\"../color.js\").Color|import(\"../colorlike.js\").ColorLike|import('../colorlike.js').PatternDescriptor|null} color Color.\n * @api\n */\n setColor(color) {\n if (color !== null && typeof color === 'object' && 'src' in color) {\n const patternImage = getIconImage(\n null,\n color.src,\n 'anonymous',\n undefined,\n color.offset ? null : color.color ? color.color : null,\n !(color.offset && color.size),\n );\n patternImage.ready().then(() => {\n this.patternImage_ = null;\n });\n if (patternImage.getImageState() === ImageState.IDLE) {\n patternImage.load();\n }\n if (patternImage.getImageState() === ImageState.LOADING) {\n this.patternImage_ = patternImage;\n }\n }\n this.color_ = color;\n }\n\n /**\n * @return {boolean} The fill style is loading an image pattern.\n */\n loading() {\n return !!this.patternImage_;\n }\n\n /**\n * @return {Promise} `false` or a promise that resolves when the style is ready to use.\n */\n ready() {\n return this.patternImage_ ? this.patternImage_.ready() : Promise.resolve();\n }\n}\n\nexport default Fill;\n","/**\n * @module ol/geom/flat/interpolate\n */\nimport {binarySearch} from '../../array.js';\nimport {lerp} from '../../math.js';\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {number} end End.\n * @param {number} stride Stride.\n * @param {number} fraction Fraction.\n * @param {Array} [dest] Destination.\n * @param {number} [dimension] Destination dimension (default is `2`)\n * @return {Array} Destination.\n */\nexport function interpolatePoint(\n flatCoordinates,\n offset,\n end,\n stride,\n fraction,\n dest,\n dimension,\n) {\n let o, t;\n const n = (end - offset) / stride;\n if (n === 1) {\n o = offset;\n } else if (n === 2) {\n o = offset;\n t = fraction;\n } else if (n !== 0) {\n let x1 = flatCoordinates[offset];\n let y1 = flatCoordinates[offset + 1];\n let length = 0;\n const cumulativeLengths = [0];\n for (let i = offset + stride; i < end; i += stride) {\n const x2 = flatCoordinates[i];\n const y2 = flatCoordinates[i + 1];\n length += Math.sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));\n cumulativeLengths.push(length);\n x1 = x2;\n y1 = y2;\n }\n const target = fraction * length;\n const index = binarySearch(cumulativeLengths, target);\n if (index < 0) {\n t =\n (target - cumulativeLengths[-index - 2]) /\n (cumulativeLengths[-index - 1] - cumulativeLengths[-index - 2]);\n o = offset + (-index - 2) * stride;\n } else {\n o = offset + index * stride;\n }\n }\n dimension = dimension > 1 ? dimension : 2;\n dest = dest ? dest : new Array(dimension);\n for (let i = 0; i < dimension; ++i) {\n dest[i] =\n o === undefined\n ? NaN\n : t === undefined\n ? flatCoordinates[o + i]\n : lerp(flatCoordinates[o + i], flatCoordinates[o + stride + i], t);\n }\n return dest;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {number} end End.\n * @param {number} stride Stride.\n * @param {number} m M.\n * @param {boolean} extrapolate Extrapolate.\n * @return {import(\"../../coordinate.js\").Coordinate|null} Coordinate.\n */\nexport function lineStringCoordinateAtM(\n flatCoordinates,\n offset,\n end,\n stride,\n m,\n extrapolate,\n) {\n if (end == offset) {\n return null;\n }\n let coordinate;\n if (m < flatCoordinates[offset + stride - 1]) {\n if (extrapolate) {\n coordinate = flatCoordinates.slice(offset, offset + stride);\n coordinate[stride - 1] = m;\n return coordinate;\n }\n return null;\n }\n if (flatCoordinates[end - 1] < m) {\n if (extrapolate) {\n coordinate = flatCoordinates.slice(end - stride, end);\n coordinate[stride - 1] = m;\n return coordinate;\n }\n return null;\n }\n // FIXME use O(1) search\n if (m == flatCoordinates[offset + stride - 1]) {\n return flatCoordinates.slice(offset, offset + stride);\n }\n let lo = offset / stride;\n let hi = end / stride;\n while (lo < hi) {\n const mid = (lo + hi) >> 1;\n if (m < flatCoordinates[(mid + 1) * stride - 1]) {\n hi = mid;\n } else {\n lo = mid + 1;\n }\n }\n const m0 = flatCoordinates[lo * stride - 1];\n if (m == m0) {\n return flatCoordinates.slice((lo - 1) * stride, (lo - 1) * stride + stride);\n }\n const m1 = flatCoordinates[(lo + 1) * stride - 1];\n const t = (m - m0) / (m1 - m0);\n coordinate = [];\n for (let i = 0; i < stride - 1; ++i) {\n coordinate.push(\n lerp(\n flatCoordinates[(lo - 1) * stride + i],\n flatCoordinates[lo * stride + i],\n t,\n ),\n );\n }\n coordinate.push(m);\n return coordinate;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {Array} ends Ends.\n * @param {number} stride Stride.\n * @param {number} m M.\n * @param {boolean} extrapolate Extrapolate.\n * @param {boolean} interpolate Interpolate.\n * @return {import(\"../../coordinate.js\").Coordinate|null} Coordinate.\n */\nexport function lineStringsCoordinateAtM(\n flatCoordinates,\n offset,\n ends,\n stride,\n m,\n extrapolate,\n interpolate,\n) {\n if (interpolate) {\n return lineStringCoordinateAtM(\n flatCoordinates,\n offset,\n ends[ends.length - 1],\n stride,\n m,\n extrapolate,\n );\n }\n let coordinate;\n if (m < flatCoordinates[stride - 1]) {\n if (extrapolate) {\n coordinate = flatCoordinates.slice(0, stride);\n coordinate[stride - 1] = m;\n return coordinate;\n }\n return null;\n }\n if (flatCoordinates[flatCoordinates.length - 1] < m) {\n if (extrapolate) {\n coordinate = flatCoordinates.slice(flatCoordinates.length - stride);\n coordinate[stride - 1] = m;\n return coordinate;\n }\n return null;\n }\n for (let i = 0, ii = ends.length; i < ii; ++i) {\n const end = ends[i];\n if (offset == end) {\n continue;\n }\n if (m < flatCoordinates[offset + stride - 1]) {\n return null;\n }\n if (m <= flatCoordinates[end - 1]) {\n return lineStringCoordinateAtM(\n flatCoordinates,\n offset,\n end,\n stride,\n m,\n false,\n );\n }\n offset = end;\n }\n return null;\n}\n","/**\n * @module ol/geom/flat/length\n */\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {number} end End.\n * @param {number} stride Stride.\n * @return {number} Length.\n */\nexport function lineStringLength(flatCoordinates, offset, end, stride) {\n let x1 = flatCoordinates[offset];\n let y1 = flatCoordinates[offset + 1];\n let length = 0;\n for (let i = offset + stride; i < end; i += stride) {\n const x2 = flatCoordinates[i];\n const y2 = flatCoordinates[i + 1];\n length += Math.sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));\n x1 = x2;\n y1 = y2;\n }\n return length;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {number} end End.\n * @param {number} stride Stride.\n * @return {number} Perimeter.\n */\nexport function linearRingLength(flatCoordinates, offset, end, stride) {\n let perimeter = lineStringLength(flatCoordinates, offset, end, stride);\n const dx = flatCoordinates[end - stride] - flatCoordinates[offset];\n const dy = flatCoordinates[end - stride + 1] - flatCoordinates[offset + 1];\n perimeter += Math.sqrt(dx * dx + dy * dy);\n return perimeter;\n}\n","/**\n * @module ol/geom/LineString\n */\nimport SimpleGeometry from './SimpleGeometry.js';\nimport {assignClosestPoint, maxSquaredDelta} from './flat/closest.js';\nimport {closestSquaredDistanceXY} from '../extent.js';\nimport {deflateCoordinates} from './flat/deflate.js';\nimport {douglasPeucker} from './flat/simplify.js';\nimport {extend} from '../array.js';\nimport {forEach as forEachSegment} from './flat/segments.js';\nimport {inflateCoordinates} from './flat/inflate.js';\nimport {interpolatePoint, lineStringCoordinateAtM} from './flat/interpolate.js';\nimport {intersectsLineString} from './flat/intersectsextent.js';\nimport {lineStringLength} from './flat/length.js';\n\n/**\n * @classdesc\n * Linestring geometry.\n *\n * @api\n */\nclass LineString extends SimpleGeometry {\n /**\n * @param {Array|Array} coordinates Coordinates.\n * For internal use, flat coordinates in combination with `layout` are also accepted.\n * @param {import(\"./Geometry.js\").GeometryLayout} [layout] Layout.\n */\n constructor(coordinates, layout) {\n super();\n\n /**\n * @private\n * @type {import(\"../coordinate.js\").Coordinate|null}\n */\n this.flatMidpoint_ = null;\n\n /**\n * @private\n * @type {number}\n */\n this.flatMidpointRevision_ = -1;\n\n /**\n * @private\n * @type {number}\n */\n this.maxDelta_ = -1;\n\n /**\n * @private\n * @type {number}\n */\n this.maxDeltaRevision_ = -1;\n\n if (layout !== undefined && !Array.isArray(coordinates[0])) {\n this.setFlatCoordinates(\n layout,\n /** @type {Array} */ (coordinates),\n );\n } else {\n this.setCoordinates(\n /** @type {Array} */ (\n coordinates\n ),\n layout,\n );\n }\n }\n\n /**\n * Append the passed coordinate to the coordinates of the linestring.\n * @param {import(\"../coordinate.js\").Coordinate} coordinate Coordinate.\n * @api\n */\n appendCoordinate(coordinate) {\n extend(this.flatCoordinates, coordinate);\n this.changed();\n }\n\n /**\n * Make a complete copy of the geometry.\n * @return {!LineString} Clone.\n * @api\n */\n clone() {\n const lineString = new LineString(\n this.flatCoordinates.slice(),\n this.layout,\n );\n lineString.applyProperties(this);\n return lineString;\n }\n\n /**\n * @param {number} x X.\n * @param {number} y Y.\n * @param {import(\"../coordinate.js\").Coordinate} closestPoint Closest point.\n * @param {number} minSquaredDistance Minimum squared distance.\n * @return {number} Minimum squared distance.\n */\n closestPointXY(x, y, closestPoint, minSquaredDistance) {\n if (minSquaredDistance < closestSquaredDistanceXY(this.getExtent(), x, y)) {\n return minSquaredDistance;\n }\n if (this.maxDeltaRevision_ != this.getRevision()) {\n this.maxDelta_ = Math.sqrt(\n maxSquaredDelta(\n this.flatCoordinates,\n 0,\n this.flatCoordinates.length,\n this.stride,\n 0,\n ),\n );\n this.maxDeltaRevision_ = this.getRevision();\n }\n return assignClosestPoint(\n this.flatCoordinates,\n 0,\n this.flatCoordinates.length,\n this.stride,\n this.maxDelta_,\n false,\n x,\n y,\n closestPoint,\n minSquaredDistance,\n );\n }\n\n /**\n * Iterate over each segment, calling the provided callback.\n * If the callback returns a truthy value the function returns that\n * value immediately. Otherwise the function returns `false`.\n *\n * @param {function(this: S, import(\"../coordinate.js\").Coordinate, import(\"../coordinate.js\").Coordinate): T} callback Function\n * called for each segment. The function will receive two arguments, the start and end coordinates of the segment.\n * @return {T|boolean} Value.\n * @template T,S\n * @api\n */\n forEachSegment(callback) {\n return forEachSegment(\n this.flatCoordinates,\n 0,\n this.flatCoordinates.length,\n this.stride,\n callback,\n );\n }\n\n /**\n * Returns the coordinate at `m` using linear interpolation, or `null` if no\n * such coordinate exists.\n *\n * `extrapolate` controls extrapolation beyond the range of Ms in the\n * MultiLineString. If `extrapolate` is `true` then Ms less than the first\n * M will return the first coordinate and Ms greater than the last M will\n * return the last coordinate.\n *\n * @param {number} m M.\n * @param {boolean} [extrapolate] Extrapolate. Default is `false`.\n * @return {import(\"../coordinate.js\").Coordinate|null} Coordinate.\n * @api\n */\n getCoordinateAtM(m, extrapolate) {\n if (this.layout != 'XYM' && this.layout != 'XYZM') {\n return null;\n }\n extrapolate = extrapolate !== undefined ? extrapolate : false;\n return lineStringCoordinateAtM(\n this.flatCoordinates,\n 0,\n this.flatCoordinates.length,\n this.stride,\n m,\n extrapolate,\n );\n }\n\n /**\n * Return the coordinates of the linestring.\n * @return {Array} Coordinates.\n * @api\n */\n getCoordinates() {\n return inflateCoordinates(\n this.flatCoordinates,\n 0,\n this.flatCoordinates.length,\n this.stride,\n );\n }\n\n /**\n * Return the coordinate at the provided fraction along the linestring.\n * The `fraction` is a number between 0 and 1, where 0 is the start of the\n * linestring and 1 is the end.\n * @param {number} fraction Fraction.\n * @param {import(\"../coordinate.js\").Coordinate} [dest] Optional coordinate whose values will\n * be modified. If not provided, a new coordinate will be returned.\n * @return {import(\"../coordinate.js\").Coordinate} Coordinate of the interpolated point.\n * @api\n */\n getCoordinateAt(fraction, dest) {\n return interpolatePoint(\n this.flatCoordinates,\n 0,\n this.flatCoordinates.length,\n this.stride,\n fraction,\n dest,\n this.stride,\n );\n }\n\n /**\n * Return the length of the linestring on projected plane.\n * @return {number} Length (on projected plane).\n * @api\n */\n getLength() {\n return lineStringLength(\n this.flatCoordinates,\n 0,\n this.flatCoordinates.length,\n this.stride,\n );\n }\n\n /**\n * @return {Array} Flat midpoint.\n */\n getFlatMidpoint() {\n if (this.flatMidpointRevision_ != this.getRevision()) {\n this.flatMidpoint_ = this.getCoordinateAt(\n 0.5,\n this.flatMidpoint_ ?? undefined,\n );\n this.flatMidpointRevision_ = this.getRevision();\n }\n return /** @type {Array} */ (this.flatMidpoint_);\n }\n\n /**\n * @param {number} squaredTolerance Squared tolerance.\n * @return {LineString} Simplified LineString.\n * @protected\n */\n getSimplifiedGeometryInternal(squaredTolerance) {\n /** @type {Array} */\n const simplifiedFlatCoordinates = [];\n simplifiedFlatCoordinates.length = douglasPeucker(\n this.flatCoordinates,\n 0,\n this.flatCoordinates.length,\n this.stride,\n squaredTolerance,\n simplifiedFlatCoordinates,\n 0,\n );\n return new LineString(simplifiedFlatCoordinates, 'XY');\n }\n\n /**\n * Get the type of this geometry.\n * @return {import(\"./Geometry.js\").Type} Geometry type.\n * @api\n */\n getType() {\n return 'LineString';\n }\n\n /**\n * Test if the geometry and the passed extent intersect.\n * @param {import(\"../extent.js\").Extent} extent Extent.\n * @return {boolean} `true` if the geometry and the extent intersect.\n * @api\n */\n intersectsExtent(extent) {\n return intersectsLineString(\n this.flatCoordinates,\n 0,\n this.flatCoordinates.length,\n this.stride,\n extent,\n );\n }\n\n /**\n * Set the coordinates of the linestring.\n * @param {!Array} coordinates Coordinates.\n * @param {import(\"./Geometry.js\").GeometryLayout} [layout] Layout.\n * @api\n */\n setCoordinates(coordinates, layout) {\n this.setLayout(layout, coordinates, 1);\n if (!this.flatCoordinates) {\n this.flatCoordinates = [];\n }\n this.flatCoordinates.length = deflateCoordinates(\n this.flatCoordinates,\n 0,\n coordinates,\n this.stride,\n );\n this.changed();\n }\n}\n\nexport default LineString;\n","/**\n * @module ol/style/Stroke\n */\n\n/**\n * @typedef {Object} Options\n * @property {import(\"../color.js\").Color|import(\"../colorlike.js\").ColorLike} [color] A color, gradient or pattern.\n * See {@link module:ol/color~Color} and {@link module:ol/colorlike~ColorLike} for possible formats.\n * Default null; if null, the Canvas/renderer default black will be used.\n * @property {CanvasLineCap} [lineCap='round'] Line cap style: `butt`, `round`, or `square`.\n * @property {CanvasLineJoin} [lineJoin='round'] Line join style: `bevel`, `round`, or `miter`.\n * @property {Array} [lineDash] Line dash pattern. Default is `null` (no dash).\n * @property {number} [lineDashOffset=0] Line dash offset.\n * @property {number} [miterLimit=10] Miter limit.\n * @property {number} [width] Width.\n */\n\n/**\n * @classdesc\n * Set stroke style for vector features.\n * Note that the defaults given are the Canvas defaults, which will be used if\n * option is not defined. The `get` functions return whatever was entered in\n * the options; they will not return the default.\n * @api\n */\nclass Stroke {\n /**\n * @param {Options} [options] Options.\n */\n constructor(options) {\n options = options || {};\n\n /**\n * @private\n * @type {import(\"../color.js\").Color|import(\"../colorlike.js\").ColorLike}\n */\n this.color_ = options.color !== undefined ? options.color : null;\n\n /**\n * @private\n * @type {CanvasLineCap|undefined}\n */\n this.lineCap_ = options.lineCap;\n\n /**\n * @private\n * @type {Array|null}\n */\n this.lineDash_ = options.lineDash !== undefined ? options.lineDash : null;\n\n /**\n * @private\n * @type {number|undefined}\n */\n this.lineDashOffset_ = options.lineDashOffset;\n\n /**\n * @private\n * @type {CanvasLineJoin|undefined}\n */\n this.lineJoin_ = options.lineJoin;\n\n /**\n * @private\n * @type {number|undefined}\n */\n this.miterLimit_ = options.miterLimit;\n\n /**\n * @private\n * @type {number|undefined}\n */\n this.width_ = options.width;\n }\n\n /**\n * Clones the style.\n * @return {Stroke} The cloned style.\n * @api\n */\n clone() {\n const color = this.getColor();\n return new Stroke({\n color: Array.isArray(color) ? color.slice() : color || undefined,\n lineCap: this.getLineCap(),\n lineDash: this.getLineDash() ? this.getLineDash().slice() : undefined,\n lineDashOffset: this.getLineDashOffset(),\n lineJoin: this.getLineJoin(),\n miterLimit: this.getMiterLimit(),\n width: this.getWidth(),\n });\n }\n\n /**\n * Get the stroke color.\n * @return {import(\"../color.js\").Color|import(\"../colorlike.js\").ColorLike} Color.\n * @api\n */\n getColor() {\n return this.color_;\n }\n\n /**\n * Get the line cap type for the stroke.\n * @return {CanvasLineCap|undefined} Line cap.\n * @api\n */\n getLineCap() {\n return this.lineCap_;\n }\n\n /**\n * Get the line dash style for the stroke.\n * @return {Array|null} Line dash.\n * @api\n */\n getLineDash() {\n return this.lineDash_;\n }\n\n /**\n * Get the line dash offset for the stroke.\n * @return {number|undefined} Line dash offset.\n * @api\n */\n getLineDashOffset() {\n return this.lineDashOffset_;\n }\n\n /**\n * Get the line join type for the stroke.\n * @return {CanvasLineJoin|undefined} Line join.\n * @api\n */\n getLineJoin() {\n return this.lineJoin_;\n }\n\n /**\n * Get the miter limit for the stroke.\n * @return {number|undefined} Miter limit.\n * @api\n */\n getMiterLimit() {\n return this.miterLimit_;\n }\n\n /**\n * Get the stroke width.\n * @return {number|undefined} Width.\n * @api\n */\n getWidth() {\n return this.width_;\n }\n\n /**\n * Set the color.\n *\n * @param {import(\"../color.js\").Color|import(\"../colorlike.js\").ColorLike} color Color.\n * @api\n */\n setColor(color) {\n this.color_ = color;\n }\n\n /**\n * Set the line cap.\n *\n * @param {CanvasLineCap|undefined} lineCap Line cap.\n * @api\n */\n setLineCap(lineCap) {\n this.lineCap_ = lineCap;\n }\n\n /**\n * Set the line dash.\n *\n * @param {Array|null} lineDash Line dash.\n * @api\n */\n setLineDash(lineDash) {\n this.lineDash_ = lineDash;\n }\n\n /**\n * Set the line dash offset.\n *\n * @param {number|undefined} lineDashOffset Line dash offset.\n * @api\n */\n setLineDashOffset(lineDashOffset) {\n this.lineDashOffset_ = lineDashOffset;\n }\n\n /**\n * Set the line join.\n *\n * @param {CanvasLineJoin|undefined} lineJoin Line join.\n * @api\n */\n setLineJoin(lineJoin) {\n this.lineJoin_ = lineJoin;\n }\n\n /**\n * Set the miter limit.\n *\n * @param {number|undefined} miterLimit Miter limit.\n * @api\n */\n setMiterLimit(miterLimit) {\n this.miterLimit_ = miterLimit;\n }\n\n /**\n * Set the width.\n *\n * @param {number|undefined} width Width.\n * @api\n */\n setWidth(width) {\n this.width_ = width;\n }\n}\n\nexport default Stroke;\n","/**\n * @module ol/size\n */\n\n/**\n * An array of numbers representing a size: `[width, height]`.\n * @typedef {Array} Size\n * @api\n */\n\n/**\n * Returns a buffered size.\n * @param {Size} size Size.\n * @param {number} num The amount by which to buffer.\n * @param {Size} [dest] Optional reusable size array.\n * @return {Size} The buffered size.\n */\nexport function buffer(size, num, dest) {\n if (dest === undefined) {\n dest = [0, 0];\n }\n dest[0] = size[0] + 2 * num;\n dest[1] = size[1] + 2 * num;\n return dest;\n}\n\n/**\n * Determines if a size has a positive area.\n * @param {Size} size The size to test.\n * @return {boolean} The size has a positive area.\n */\nexport function hasArea(size) {\n return size[0] > 0 && size[1] > 0;\n}\n\n/**\n * Returns a size scaled by a ratio. The result will be an array of integers.\n * @param {Size} size Size.\n * @param {number} ratio Ratio.\n * @param {Size} [dest] Optional reusable size array.\n * @return {Size} The scaled size.\n */\nexport function scale(size, ratio, dest) {\n if (dest === undefined) {\n dest = [0, 0];\n }\n dest[0] = (size[0] * ratio + 0.5) | 0;\n dest[1] = (size[1] * ratio + 0.5) | 0;\n return dest;\n}\n\n/**\n * Returns an `Size` array for the passed in number (meaning: square) or\n * `Size` array.\n * (meaning: non-square),\n * @param {number|Size} size Width and height.\n * @param {Size} [dest] Optional reusable size array.\n * @return {Size} Size.\n * @api\n */\nexport function toSize(size, dest) {\n if (Array.isArray(size)) {\n return size;\n }\n if (dest === undefined) {\n dest = [size, size];\n } else {\n dest[0] = size;\n dest[1] = size;\n }\n return dest;\n}\n","/**\n * @module ol/style/Image\n */\nimport {abstract} from '../util.js';\nimport {toSize} from '../size.js';\n\n/**\n * @typedef {Object} Options\n * @property {number} opacity Opacity.\n * @property {boolean} rotateWithView If the image should get rotated with the view.\n * @property {number} rotation Rotation.\n * @property {number|import(\"../size.js\").Size} scale Scale.\n * @property {Array} displacement Displacement.\n * @property {import('../style/Style.js').DeclutterMode} declutterMode Declutter mode: `declutter`, `obstacle`, `none`.\n */\n\n/**\n * @classdesc\n * A base class used for creating subclasses and not instantiated in\n * apps. Base class for {@link module:ol/style/Icon~Icon}, {@link module:ol/style/Circle~CircleStyle} and\n * {@link module:ol/style/RegularShape~RegularShape}.\n * @abstract\n * @api\n */\nclass ImageStyle {\n /**\n * @param {Options} options Options.\n */\n constructor(options) {\n /**\n * @private\n * @type {number}\n */\n this.opacity_ = options.opacity;\n\n /**\n * @private\n * @type {boolean}\n */\n this.rotateWithView_ = options.rotateWithView;\n\n /**\n * @private\n * @type {number}\n */\n this.rotation_ = options.rotation;\n\n /**\n * @private\n * @type {number|import(\"../size.js\").Size}\n */\n this.scale_ = options.scale;\n\n /**\n * @private\n * @type {import(\"../size.js\").Size}\n */\n this.scaleArray_ = toSize(options.scale);\n\n /**\n * @private\n * @type {Array}\n */\n this.displacement_ = options.displacement;\n\n /**\n * @private\n * @type {import('../style/Style.js').DeclutterMode}\n */\n this.declutterMode_ = options.declutterMode;\n }\n\n /**\n * Clones the style.\n * @return {ImageStyle} The cloned style.\n * @api\n */\n clone() {\n const scale = this.getScale();\n return new ImageStyle({\n opacity: this.getOpacity(),\n scale: Array.isArray(scale) ? scale.slice() : scale,\n rotation: this.getRotation(),\n rotateWithView: this.getRotateWithView(),\n displacement: this.getDisplacement().slice(),\n declutterMode: this.getDeclutterMode(),\n });\n }\n\n /**\n * Get the symbolizer opacity.\n * @return {number} Opacity.\n * @api\n */\n getOpacity() {\n return this.opacity_;\n }\n\n /**\n * Determine whether the symbolizer rotates with the map.\n * @return {boolean} Rotate with map.\n * @api\n */\n getRotateWithView() {\n return this.rotateWithView_;\n }\n\n /**\n * Get the symoblizer rotation.\n * @return {number} Rotation.\n * @api\n */\n getRotation() {\n return this.rotation_;\n }\n\n /**\n * Get the symbolizer scale.\n * @return {number|import(\"../size.js\").Size} Scale.\n * @api\n */\n getScale() {\n return this.scale_;\n }\n\n /**\n * Get the symbolizer scale array.\n * @return {import(\"../size.js\").Size} Scale array.\n */\n getScaleArray() {\n return this.scaleArray_;\n }\n\n /**\n * Get the displacement of the shape\n * @return {Array} Shape's center displacement\n * @api\n */\n getDisplacement() {\n return this.displacement_;\n }\n\n /**\n * Get the declutter mode of the shape\n * @return {import(\"./Style.js\").DeclutterMode} Shape's declutter mode\n * @api\n */\n getDeclutterMode() {\n return this.declutterMode_;\n }\n\n /**\n * Get the anchor point in pixels. The anchor determines the center point for the\n * symbolizer.\n * @abstract\n * @return {Array} Anchor.\n */\n getAnchor() {\n return abstract();\n }\n\n /**\n * Get the image element for the symbolizer.\n * @abstract\n * @param {number} pixelRatio Pixel ratio.\n * @return {import('../DataTile.js').ImageLike} Image element.\n */\n getImage(pixelRatio) {\n return abstract();\n }\n\n /**\n * @abstract\n * @return {import('../DataTile.js').ImageLike} Image element.\n */\n getHitDetectionImage() {\n return abstract();\n }\n\n /**\n * Get the image pixel ratio.\n * @param {number} pixelRatio Pixel ratio.\n * @return {number} Pixel ratio.\n */\n getPixelRatio(pixelRatio) {\n return 1;\n }\n\n /**\n * @abstract\n * @return {import(\"../ImageState.js\").default} Image state.\n */\n getImageState() {\n return abstract();\n }\n\n /**\n * @abstract\n * @return {import(\"../size.js\").Size} Image size.\n */\n getImageSize() {\n return abstract();\n }\n\n /**\n * Get the origin of the symbolizer.\n * @abstract\n * @return {Array} Origin.\n */\n getOrigin() {\n return abstract();\n }\n\n /**\n * Get the size of the symbolizer (in pixels).\n * @abstract\n * @return {import(\"../size.js\").Size} Size.\n */\n getSize() {\n return abstract();\n }\n\n /**\n * Set the displacement.\n *\n * @param {Array} displacement Displacement.\n * @api\n */\n setDisplacement(displacement) {\n this.displacement_ = displacement;\n }\n\n /**\n * Set the opacity.\n *\n * @param {number} opacity Opacity.\n * @api\n */\n setOpacity(opacity) {\n this.opacity_ = opacity;\n }\n\n /**\n * Set whether to rotate the style with the view.\n *\n * @param {boolean} rotateWithView Rotate with map.\n * @api\n */\n setRotateWithView(rotateWithView) {\n this.rotateWithView_ = rotateWithView;\n }\n\n /**\n * Set the rotation.\n *\n * @param {number} rotation Rotation.\n * @api\n */\n setRotation(rotation) {\n this.rotation_ = rotation;\n }\n\n /**\n * Set the scale.\n *\n * @param {number|import(\"../size.js\").Size} scale Scale.\n * @api\n */\n setScale(scale) {\n this.scale_ = scale;\n this.scaleArray_ = toSize(scale);\n }\n\n /**\n * @abstract\n * @param {function(import(\"../events/Event.js\").default): void} listener Listener function.\n */\n listenImageChange(listener) {\n abstract();\n }\n\n /**\n * Load not yet loaded URI.\n * @abstract\n */\n load() {\n abstract();\n }\n\n /**\n * @abstract\n * @param {function(import(\"../events/Event.js\").default): void} listener Listener function.\n */\n unlistenImageChange(listener) {\n abstract();\n }\n\n /**\n * @return {Promise} `false` or Promise that resolves when the style is ready to use.\n */\n ready() {\n return Promise.resolve();\n }\n}\n\nexport default ImageStyle;\n","/**\n * @module ol/colorlike\n */\nimport ImageState from './ImageState.js';\nimport {createCanvasContext2D} from './dom.js';\nimport {get as getIconImage} from './style/IconImage.js';\nimport {shared as iconCache} from './style/IconImageCache.js';\nimport {toString} from './color.js';\n\n/**\n * @typedef {Object} PatternDescriptor\n * @property {string} src Pattern image URL\n * @property {import(\"./color.js\").Color|string} [color] Color to tint the pattern with.\n * @property {import(\"./size.js\").Size} [size] Size of the desired slice from the pattern image.\n * Use this together with `offset` when the pattern image is a sprite sheet.\n * @property {import(\"./size.js\").Size} [offset] Offset of the desired slice from the pattern image.\n * Use this together with `size` when the pattern image is a sprite sheet.\n */\n\n/**\n * A type accepted by CanvasRenderingContext2D.fillStyle\n * or CanvasRenderingContext2D.strokeStyle.\n * Represents a color, [CanvasPattern](https://developer.mozilla.org/en-US/docs/Web/API/CanvasPattern),\n * or [CanvasGradient](https://developer.mozilla.org/en-US/docs/Web/API/CanvasGradient). The origin for\n * patterns and gradients as fill style is an increment of 512 css pixels from map coordinate\n * `[0, 0]`. For seamless repeat patterns, width and height of the pattern image\n * must be a factor of two (2, 4, 8, ..., 512).\n *\n * @typedef {string|CanvasPattern|CanvasGradient} ColorLike\n * @api\n */\n\n/**\n * @param {import(\"./color.js\").Color|ColorLike|PatternDescriptor|null} color Color.\n * @return {ColorLike|null} The color as an {@link ol/colorlike~ColorLike}.\n * @api\n */\nexport function asColorLike(color) {\n if (!color) {\n return null;\n }\n if (Array.isArray(color)) {\n return toString(color);\n }\n if (typeof color === 'object' && 'src' in color) {\n return asCanvasPattern(color);\n }\n return color;\n}\n\n/**\n * @param {PatternDescriptor} pattern Pattern descriptor.\n * @return {CanvasPattern|null} Canvas pattern or null if the pattern referenced in the\n * PatternDescriptor was not found in the icon image cache.\n */\nfunction asCanvasPattern(pattern) {\n if (!pattern.offset || !pattern.size) {\n return iconCache.getPattern(pattern.src, 'anonymous', pattern.color);\n }\n\n const cacheKey = pattern.src + ':' + pattern.offset;\n\n const canvasPattern = iconCache.getPattern(\n cacheKey,\n undefined,\n pattern.color,\n );\n if (canvasPattern) {\n return canvasPattern;\n }\n\n const iconImage = iconCache.get(pattern.src, 'anonymous', null);\n if (iconImage.getImageState() !== ImageState.LOADED) {\n return null;\n }\n const patternCanvasContext = createCanvasContext2D(\n pattern.size[0],\n pattern.size[1],\n );\n patternCanvasContext.drawImage(\n iconImage.getImage(1),\n pattern.offset[0],\n pattern.offset[1],\n pattern.size[0],\n pattern.size[1],\n 0,\n 0,\n pattern.size[0],\n pattern.size[1],\n );\n getIconImage(\n patternCanvasContext.canvas,\n cacheKey,\n undefined,\n ImageState.LOADED,\n pattern.color,\n true,\n );\n return iconCache.getPattern(cacheKey, undefined, pattern.color);\n}\n","/**\n * @module ol/css\n */\n\n/**\n * @typedef {Object} FontParameters\n * @property {string} style Style.\n * @property {string} variant Variant.\n * @property {string} weight Weight.\n * @property {string} size Size.\n * @property {string} lineHeight LineHeight.\n * @property {string} family Family.\n * @property {Array} families Families.\n */\n\n/**\n * The CSS class for hidden feature.\n *\n * @const\n * @type {string}\n */\nexport const CLASS_HIDDEN = 'ol-hidden';\n\n/**\n * The CSS class that we'll give the DOM elements to have them selectable.\n *\n * @const\n * @type {string}\n */\nexport const CLASS_SELECTABLE = 'ol-selectable';\n\n/**\n * The CSS class that we'll give the DOM elements to have them unselectable.\n *\n * @const\n * @type {string}\n */\nexport const CLASS_UNSELECTABLE = 'ol-unselectable';\n\n/**\n * The CSS class for unsupported feature.\n *\n * @const\n * @type {string}\n */\nexport const CLASS_UNSUPPORTED = 'ol-unsupported';\n\n/**\n * The CSS class for controls.\n *\n * @const\n * @type {string}\n */\nexport const CLASS_CONTROL = 'ol-control';\n\n/**\n * The CSS class that we'll give the DOM elements that are collapsed, i.e.\n * to those elements which usually can be expanded.\n *\n * @const\n * @type {string}\n */\nexport const CLASS_COLLAPSED = 'ol-collapsed';\n\n/**\n * From https://stackoverflow.com/questions/10135697/regex-to-parse-any-css-font\n * @type {RegExp}\n */\nconst fontRegEx = new RegExp(\n [\n '^\\\\s*(?=(?:(?:[-a-z]+\\\\s*){0,2}(italic|oblique))?)',\n '(?=(?:(?:[-a-z]+\\\\s*){0,2}(small-caps))?)',\n '(?=(?:(?:[-a-z]+\\\\s*){0,2}(bold(?:er)?|lighter|[1-9]00 ))?)',\n '(?:(?:normal|\\\\1|\\\\2|\\\\3)\\\\s*){0,3}((?:xx?-)?',\n '(?:small|large)|medium|smaller|larger|[\\\\.\\\\d]+(?:\\\\%|in|[cem]m|ex|p[ctx]))',\n '(?:\\\\s*\\\\/\\\\s*(normal|[\\\\.\\\\d]+(?:\\\\%|in|[cem]m|ex|p[ctx])?))',\n '?\\\\s*([-,\\\\\"\\\\\\'\\\\sa-z]+?)\\\\s*$',\n ].join(''),\n 'i',\n);\n/** @type {Array<'style'|'variant'|'weight'|'size'|'lineHeight'|'family'>} */\nconst fontRegExMatchIndex = [\n 'style',\n 'variant',\n 'weight',\n 'size',\n 'lineHeight',\n 'family',\n];\n\n/**\n * Get the list of font families from a font spec. Note that this doesn't work\n * for font families that have commas in them.\n * @param {string} fontSpec The CSS font property.\n * @return {FontParameters|null} The font parameters (or null if the input spec is invalid).\n */\nexport const getFontParameters = function (fontSpec) {\n const match = fontSpec.match(fontRegEx);\n if (!match) {\n return null;\n }\n const style = /** @type {FontParameters} */ ({\n lineHeight: 'normal',\n size: '1.2em',\n style: 'normal',\n weight: 'normal',\n variant: 'normal',\n });\n for (let i = 0, ii = fontRegExMatchIndex.length; i < ii; ++i) {\n const value = match[i + 1];\n if (value !== undefined) {\n style[fontRegExMatchIndex[i]] = value;\n }\n }\n style.families = style.family.split(/,\\s?/);\n return style;\n};\n","/**\n * @module ol/render/canvas\n */\nimport BaseObject from '../Object.js';\nimport {WORKER_OFFSCREEN_CANVAS} from '../has.js';\nimport {clear} from '../obj.js';\nimport {createCanvasContext2D} from '../dom.js';\nimport {getFontParameters} from '../css.js';\n\n/**\n * @typedef {'Circle' | 'Image' | 'LineString' | 'Polygon' | 'Text' | 'Default'} BuilderType\n */\n\n/**\n * @typedef {Object} FillState\n * @property {import(\"../colorlike.js\").ColorLike} fillStyle FillStyle.\n */\n\n/**\n * @typedef Label\n * @property {number} width Width.\n * @property {number} height Height.\n * @property {Array} contextInstructions ContextInstructions.\n */\n\n/**\n * @typedef {Object} FillStrokeState\n * @property {import(\"../colorlike.js\").ColorLike} [currentFillStyle] Current FillStyle.\n * @property {import(\"../colorlike.js\").ColorLike} [currentStrokeStyle] Current StrokeStyle.\n * @property {CanvasLineCap} [currentLineCap] Current LineCap.\n * @property {Array} currentLineDash Current LineDash.\n * @property {number} [currentLineDashOffset] Current LineDashOffset.\n * @property {CanvasLineJoin} [currentLineJoin] Current LineJoin.\n * @property {number} [currentLineWidth] Current LineWidth.\n * @property {number} [currentMiterLimit] Current MiterLimit.\n * @property {number} [lastStroke] Last stroke.\n * @property {import(\"../colorlike.js\").ColorLike} [fillStyle] FillStyle.\n * @property {import(\"../colorlike.js\").ColorLike} [strokeStyle] StrokeStyle.\n * @property {CanvasLineCap} [lineCap] LineCap.\n * @property {Array} lineDash LineDash.\n * @property {number} [lineDashOffset] LineDashOffset.\n * @property {CanvasLineJoin} [lineJoin] LineJoin.\n * @property {number} [lineWidth] LineWidth.\n * @property {number} [miterLimit] MiterLimit.\n * @property {number} [fillPatternScale] Fill pattern scale.\n */\n\n/**\n * @typedef {Object} StrokeState\n * @property {CanvasLineCap} lineCap LineCap.\n * @property {Array} lineDash LineDash.\n * @property {number} lineDashOffset LineDashOffset.\n * @property {CanvasLineJoin} lineJoin LineJoin.\n * @property {number} lineWidth LineWidth.\n * @property {number} miterLimit MiterLimit.\n * @property {import(\"../colorlike.js\").ColorLike} strokeStyle StrokeStyle.\n */\n\n/**\n * @typedef {Object} TextState\n * @property {string} font Font.\n * @property {CanvasTextAlign} [textAlign] TextAlign.\n * @property {number} [repeat] Repeat.\n * @property {import(\"../style/Text.js\").TextJustify} [justify] Justify.\n * @property {CanvasTextBaseline} textBaseline TextBaseline.\n * @property {import(\"../style/Text.js\").TextPlacement} [placement] Placement.\n * @property {number} [maxAngle] MaxAngle.\n * @property {boolean} [overflow] Overflow.\n * @property {import(\"../style/Fill.js\").default} [backgroundFill] BackgroundFill.\n * @property {import(\"../style/Stroke.js\").default} [backgroundStroke] BackgroundStroke.\n * @property {import(\"../size.js\").Size} [scale] Scale.\n * @property {Array} [padding] Padding.\n */\n\n/**\n * @typedef {Object} SerializableInstructions\n * @property {Array<*>} instructions The rendering instructions.\n * @property {Array<*>} hitDetectionInstructions The rendering hit detection instructions.\n * @property {Array} coordinates The array of all coordinates.\n * @property {!Object} [textStates] The text states (decluttering).\n * @property {!Object} [fillStates] The fill states (decluttering).\n * @property {!Object} [strokeStates] The stroke states (decluttering).\n */\n\n/**\n * @typedef {Object} DeclutterImageWithText\n */\n\n/**\n * @const\n * @type {string}\n */\nexport const defaultFont = '10px sans-serif';\n\n/**\n * @const\n * @type {string}\n */\nexport const defaultFillStyle = '#000';\n\n/**\n * @const\n * @type {CanvasLineCap}\n */\nexport const defaultLineCap = 'round';\n\n/**\n * @const\n * @type {Array}\n */\nexport const defaultLineDash = [];\n\n/**\n * @const\n * @type {number}\n */\nexport const defaultLineDashOffset = 0;\n\n/**\n * @const\n * @type {CanvasLineJoin}\n */\nexport const defaultLineJoin = 'round';\n\n/**\n * @const\n * @type {number}\n */\nexport const defaultMiterLimit = 10;\n\n/**\n * @const\n * @type {import(\"../colorlike.js\").ColorLike}\n */\nexport const defaultStrokeStyle = '#000';\n\n/**\n * @const\n * @type {CanvasTextAlign}\n */\nexport const defaultTextAlign = 'center';\n\n/**\n * @const\n * @type {CanvasTextBaseline}\n */\nexport const defaultTextBaseline = 'middle';\n\n/**\n * @const\n * @type {Array}\n */\nexport const defaultPadding = [0, 0, 0, 0];\n\n/**\n * @const\n * @type {number}\n */\nexport const defaultLineWidth = 1;\n\n/**\n * @type {BaseObject}\n */\nexport const checkedFonts = new BaseObject();\n\n/**\n * @type {CanvasRenderingContext2D}\n */\nlet measureContext = null;\n\n/**\n * @type {string}\n */\nlet measureFont;\n\n/**\n * @type {!Object}\n */\nexport const textHeights = {};\n\n/**\n * Clears the label cache when a font becomes available.\n * @param {string} fontSpec CSS font spec.\n */\nexport const registerFont = (function () {\n const retries = 100;\n const size = '32px ';\n const referenceFonts = ['monospace', 'serif'];\n const len = referenceFonts.length;\n const text = 'wmytzilWMYTZIL@#/&?$%10\\uF013';\n let interval, referenceWidth;\n\n /**\n * @param {string} fontStyle Css font-style\n * @param {string} fontWeight Css font-weight\n * @param {*} fontFamily Css font-family\n * @return {boolean} Font with style and weight is available\n */\n function isAvailable(fontStyle, fontWeight, fontFamily) {\n let available = true;\n for (let i = 0; i < len; ++i) {\n const referenceFont = referenceFonts[i];\n referenceWidth = measureTextWidth(\n fontStyle + ' ' + fontWeight + ' ' + size + referenceFont,\n text,\n );\n if (fontFamily != referenceFont) {\n const width = measureTextWidth(\n fontStyle +\n ' ' +\n fontWeight +\n ' ' +\n size +\n fontFamily +\n ',' +\n referenceFont,\n text,\n );\n // If width and referenceWidth are the same, then the fallback was used\n // instead of the font we wanted, so the font is not available.\n available = available && width != referenceWidth;\n }\n }\n if (available) {\n return true;\n }\n return false;\n }\n\n function check() {\n let done = true;\n const fonts = checkedFonts.getKeys();\n for (let i = 0, ii = fonts.length; i < ii; ++i) {\n const font = fonts[i];\n if (checkedFonts.get(font) < retries) {\n if (isAvailable.apply(this, font.split('\\n'))) {\n clear(textHeights);\n // Make sure that loaded fonts are picked up by Safari\n measureContext = null;\n measureFont = undefined;\n checkedFonts.set(font, retries);\n } else {\n checkedFonts.set(font, checkedFonts.get(font) + 1, true);\n done = false;\n }\n }\n }\n if (done) {\n clearInterval(interval);\n interval = undefined;\n }\n }\n\n return function (fontSpec) {\n const font = getFontParameters(fontSpec);\n if (!font) {\n return;\n }\n const families = font.families;\n for (let i = 0, ii = families.length; i < ii; ++i) {\n const family = families[i];\n const key = font.style + '\\n' + font.weight + '\\n' + family;\n if (checkedFonts.get(key) === undefined) {\n checkedFonts.set(key, retries, true);\n if (!isAvailable(font.style, font.weight, family)) {\n checkedFonts.set(key, 0, true);\n if (interval === undefined) {\n interval = setInterval(check, 32);\n }\n }\n }\n }\n };\n})();\n\n/**\n * @param {string} font Font to use for measuring.\n * @return {import(\"../size.js\").Size} Measurement.\n */\nexport const measureTextHeight = (function () {\n /**\n * @type {HTMLDivElement}\n */\n let measureElement;\n return function (fontSpec) {\n let height = textHeights[fontSpec];\n if (height == undefined) {\n if (WORKER_OFFSCREEN_CANVAS) {\n const font = getFontParameters(fontSpec);\n const metrics = measureText(fontSpec, 'Žg');\n const lineHeight = isNaN(Number(font.lineHeight))\n ? 1.2\n : Number(font.lineHeight);\n height =\n lineHeight *\n (metrics.actualBoundingBoxAscent + metrics.actualBoundingBoxDescent);\n } else {\n if (!measureElement) {\n measureElement = document.createElement('div');\n measureElement.innerHTML = 'M';\n measureElement.style.minHeight = '0';\n measureElement.style.maxHeight = 'none';\n measureElement.style.height = 'auto';\n measureElement.style.padding = '0';\n measureElement.style.border = 'none';\n measureElement.style.position = 'absolute';\n measureElement.style.display = 'block';\n measureElement.style.left = '-99999px';\n }\n measureElement.style.font = fontSpec;\n document.body.appendChild(measureElement);\n height = measureElement.offsetHeight;\n document.body.removeChild(measureElement);\n }\n textHeights[fontSpec] = height;\n }\n return height;\n };\n})();\n\n/**\n * @param {string} font Font.\n * @param {string} text Text.\n * @return {TextMetrics} Text metrics.\n */\nfunction measureText(font, text) {\n if (!measureContext) {\n measureContext = createCanvasContext2D(1, 1);\n }\n if (font != measureFont) {\n measureContext.font = font;\n measureFont = measureContext.font;\n }\n return measureContext.measureText(text);\n}\n\n/**\n * @param {string} font Font.\n * @param {string} text Text.\n * @return {number} Width.\n */\nexport function measureTextWidth(font, text) {\n return measureText(font, text).width;\n}\n\n/**\n * Measure text width using a cache.\n * @param {string} font The font.\n * @param {string} text The text to measure.\n * @param {Object} cache A lookup of cached widths by text.\n * @return {number} The text width.\n */\nexport function measureAndCacheTextWidth(font, text, cache) {\n if (text in cache) {\n return cache[text];\n }\n const width = text\n .split('\\n')\n .reduce((prev, curr) => Math.max(prev, measureTextWidth(font, curr)), 0);\n cache[text] = width;\n return width;\n}\n\n/**\n * @param {TextState} baseStyle Base style.\n * @param {Array} chunks Text chunks to measure.\n * @return {{width: number, height: number, widths: Array, heights: Array, lineWidths: Array}}} Text metrics.\n */\nexport function getTextDimensions(baseStyle, chunks) {\n const widths = [];\n const heights = [];\n const lineWidths = [];\n let width = 0;\n let lineWidth = 0;\n let height = 0;\n let lineHeight = 0;\n for (let i = 0, ii = chunks.length; i <= ii; i += 2) {\n const text = chunks[i];\n if (text === '\\n' || i === ii) {\n width = Math.max(width, lineWidth);\n lineWidths.push(lineWidth);\n lineWidth = 0;\n height += lineHeight;\n lineHeight = 0;\n continue;\n }\n const font = chunks[i + 1] || baseStyle.font;\n const currentWidth = measureTextWidth(font, text);\n widths.push(currentWidth);\n lineWidth += currentWidth;\n const currentHeight = measureTextHeight(font);\n heights.push(currentHeight);\n lineHeight = Math.max(lineHeight, currentHeight);\n }\n return {width, height, widths, heights, lineWidths};\n}\n\n/**\n * @param {CanvasRenderingContext2D} context Context.\n * @param {number} rotation Rotation.\n * @param {number} offsetX X offset.\n * @param {number} offsetY Y offset.\n */\nexport function rotateAtOffset(context, rotation, offsetX, offsetY) {\n if (rotation !== 0) {\n context.translate(offsetX, offsetY);\n context.rotate(rotation);\n context.translate(-offsetX, -offsetY);\n }\n}\n\n/**\n * @param {CanvasRenderingContext2D|import(\"../render/canvas/ZIndexContext.js\").ZIndexContextProxy} context Context.\n * @param {import(\"../transform.js\").Transform|null} transform Transform.\n * @param {number} opacity Opacity.\n * @param {Label|HTMLCanvasElement|HTMLImageElement|HTMLVideoElement} labelOrImage Label.\n * @param {number} originX Origin X.\n * @param {number} originY Origin Y.\n * @param {number} w Width.\n * @param {number} h Height.\n * @param {number} x X.\n * @param {number} y Y.\n * @param {import(\"../size.js\").Size} scale Scale.\n */\nexport function drawImageOrLabel(\n context,\n transform,\n opacity,\n labelOrImage,\n originX,\n originY,\n w,\n h,\n x,\n y,\n scale,\n) {\n context.save();\n\n if (opacity !== 1) {\n if (context.globalAlpha === undefined) {\n context.globalAlpha = (context) => (context.globalAlpha *= opacity);\n } else {\n context.globalAlpha *= opacity;\n }\n }\n if (transform) {\n context.transform.apply(context, transform);\n }\n\n if (/** @type {*} */ (labelOrImage).contextInstructions) {\n // label\n context.translate(x, y);\n context.scale(scale[0], scale[1]);\n executeLabelInstructions(/** @type {Label} */ (labelOrImage), context);\n } else if (scale[0] < 0 || scale[1] < 0) {\n // flipped image\n context.translate(x, y);\n context.scale(scale[0], scale[1]);\n context.drawImage(\n /** @type {HTMLCanvasElement|HTMLImageElement|HTMLVideoElement} */ (\n labelOrImage\n ),\n originX,\n originY,\n w,\n h,\n 0,\n 0,\n w,\n h,\n );\n } else {\n // if image not flipped translate and scale can be avoided\n context.drawImage(\n /** @type {HTMLCanvasElement|HTMLImageElement|HTMLVideoElement} */ (\n labelOrImage\n ),\n originX,\n originY,\n w,\n h,\n x,\n y,\n w * scale[0],\n h * scale[1],\n );\n }\n\n context.restore();\n}\n\n/**\n * @param {Label} label Label.\n * @param {CanvasRenderingContext2D} context Context.\n */\nfunction executeLabelInstructions(label, context) {\n const contextInstructions = label.contextInstructions;\n for (let i = 0, ii = contextInstructions.length; i < ii; i += 2) {\n if (Array.isArray(contextInstructions[i + 1])) {\n context[contextInstructions[i]].apply(\n context,\n contextInstructions[i + 1],\n );\n } else {\n context[contextInstructions[i]] = contextInstructions[i + 1];\n }\n }\n}\n","/**\n * @module ol/style/RegularShape\n */\n\nimport ImageState from '../ImageState.js';\nimport ImageStyle from './Image.js';\nimport {asArray} from '../color.js';\nimport {asColorLike} from '../colorlike.js';\nimport {createCanvasContext2D} from '../dom.js';\nimport {\n defaultFillStyle,\n defaultLineCap,\n defaultLineJoin,\n defaultLineWidth,\n defaultMiterLimit,\n defaultStrokeStyle,\n} from '../render/canvas.js';\n\n/**\n * Specify radius for regular polygons, or both radius and radius2 for stars.\n * @typedef {Object} Options\n * @property {import(\"./Fill.js\").default} [fill] Fill style.\n * @property {number} points Number of points for stars and regular polygons. In case of a polygon, the number of points\n * is the number of sides.\n * @property {number} radius Radius of a regular polygon.\n * @property {number} [radius2] Second radius to make a star instead of a regular polygon.\n * @property {number} [angle=0] Shape's angle in radians. A value of 0 will have one of the shape's points facing up.\n * @property {Array} [displacement=[0, 0]] Displacement of the shape in pixels.\n * Positive values will shift the shape right and up.\n * @property {import(\"./Stroke.js\").default} [stroke] Stroke style.\n * @property {number} [rotation=0] Rotation in radians (positive rotation clockwise).\n * @property {boolean} [rotateWithView=false] Whether to rotate the shape with the view.\n * @property {number|import(\"../size.js\").Size} [scale=1] Scale. Unless two dimensional scaling is required a better\n * result may be obtained with appropriate settings for `radius` and `radius2`.\n * @property {import('./Style.js').DeclutterMode} [declutterMode] Declutter mode.\n */\n\n/**\n * @typedef {Object} RenderOptions\n * @property {import(\"../colorlike.js\").ColorLike|undefined} strokeStyle StrokeStyle.\n * @property {number} strokeWidth StrokeWidth.\n * @property {number} size Size.\n * @property {CanvasLineCap} lineCap LineCap.\n * @property {Array|null} lineDash LineDash.\n * @property {number} lineDashOffset LineDashOffset.\n * @property {CanvasLineJoin} lineJoin LineJoin.\n * @property {number} miterLimit MiterLimit.\n */\n\n/**\n * @classdesc\n * Set regular shape style for vector features. The resulting shape will be\n * a regular polygon when `radius` is provided, or a star when both `radius` and\n * `radius2` are provided.\n * @api\n */\nclass RegularShape extends ImageStyle {\n /**\n * @param {Options} options Options.\n */\n constructor(options) {\n super({\n opacity: 1,\n rotateWithView:\n options.rotateWithView !== undefined ? options.rotateWithView : false,\n rotation: options.rotation !== undefined ? options.rotation : 0,\n scale: options.scale !== undefined ? options.scale : 1,\n displacement:\n options.displacement !== undefined ? options.displacement : [0, 0],\n declutterMode: options.declutterMode,\n });\n\n /**\n * @private\n * @type {Object}\n */\n this.canvases_;\n\n /**\n * @private\n * @type {HTMLCanvasElement|null}\n */\n this.hitDetectionCanvas_ = null;\n\n /**\n * @private\n * @type {import(\"./Fill.js\").default|null}\n */\n this.fill_ = options.fill !== undefined ? options.fill : null;\n\n /**\n * @private\n * @type {Array}\n */\n this.origin_ = [0, 0];\n\n /**\n * @private\n * @type {number}\n */\n this.points_ = options.points;\n\n /**\n * @protected\n * @type {number}\n */\n this.radius_ = options.radius;\n\n /**\n * @private\n * @type {number|undefined}\n */\n this.radius2_ = options.radius2;\n\n /**\n * @private\n * @type {number}\n */\n this.angle_ = options.angle !== undefined ? options.angle : 0;\n\n /**\n * @private\n * @type {import(\"./Stroke.js\").default|null}\n */\n this.stroke_ = options.stroke !== undefined ? options.stroke : null;\n\n /**\n * @private\n * @type {import(\"../size.js\").Size}\n */\n this.size_;\n\n /**\n * @private\n * @type {RenderOptions}\n */\n this.renderOptions_;\n\n this.imageState_ =\n this.fill_ && this.fill_.loading()\n ? ImageState.LOADING\n : ImageState.LOADED;\n if (this.imageState_ === ImageState.LOADING) {\n this.ready().then(() => (this.imageState_ = ImageState.LOADED));\n }\n this.render();\n }\n\n /**\n * Clones the style.\n * @return {RegularShape} The cloned style.\n * @api\n */\n clone() {\n const scale = this.getScale();\n const style = new RegularShape({\n fill: this.getFill() ? this.getFill().clone() : undefined,\n points: this.getPoints(),\n radius: this.getRadius(),\n radius2: this.getRadius2(),\n angle: this.getAngle(),\n stroke: this.getStroke() ? this.getStroke().clone() : undefined,\n rotation: this.getRotation(),\n rotateWithView: this.getRotateWithView(),\n scale: Array.isArray(scale) ? scale.slice() : scale,\n displacement: this.getDisplacement().slice(),\n declutterMode: this.getDeclutterMode(),\n });\n style.setOpacity(this.getOpacity());\n return style;\n }\n\n /**\n * Get the anchor point in pixels. The anchor determines the center point for the\n * symbolizer.\n * @return {Array} Anchor.\n * @api\n */\n getAnchor() {\n const size = this.size_;\n const displacement = this.getDisplacement();\n const scale = this.getScaleArray();\n // anchor is scaled by renderer but displacement should not be scaled\n // so divide by scale here\n return [\n size[0] / 2 - displacement[0] / scale[0],\n size[1] / 2 + displacement[1] / scale[1],\n ];\n }\n\n /**\n * Get the angle used in generating the shape.\n * @return {number} Shape's rotation in radians.\n * @api\n */\n getAngle() {\n return this.angle_;\n }\n\n /**\n * Get the fill style for the shape.\n * @return {import(\"./Fill.js\").default|null} Fill style.\n * @api\n */\n getFill() {\n return this.fill_;\n }\n\n /**\n * Set the fill style.\n * @param {import(\"./Fill.js\").default|null} fill Fill style.\n * @api\n */\n setFill(fill) {\n this.fill_ = fill;\n this.render();\n }\n\n /**\n * @return {HTMLCanvasElement} Image element.\n */\n getHitDetectionImage() {\n if (!this.hitDetectionCanvas_) {\n this.hitDetectionCanvas_ = this.createHitDetectionCanvas_(\n this.renderOptions_,\n );\n }\n return this.hitDetectionCanvas_;\n }\n\n /**\n * Get the image icon.\n * @param {number} pixelRatio Pixel ratio.\n * @return {HTMLCanvasElement} Image or Canvas element.\n * @api\n */\n getImage(pixelRatio) {\n let image = this.canvases_[pixelRatio];\n if (!image) {\n const renderOptions = this.renderOptions_;\n const context = createCanvasContext2D(\n renderOptions.size * pixelRatio,\n renderOptions.size * pixelRatio,\n );\n this.draw_(renderOptions, context, pixelRatio);\n\n image = context.canvas;\n this.canvases_[pixelRatio] = image;\n }\n return image;\n }\n\n /**\n * Get the image pixel ratio.\n * @param {number} pixelRatio Pixel ratio.\n * @return {number} Pixel ratio.\n */\n getPixelRatio(pixelRatio) {\n return pixelRatio;\n }\n\n /**\n * @return {import(\"../size.js\").Size} Image size.\n */\n getImageSize() {\n return this.size_;\n }\n\n /**\n * @return {import(\"../ImageState.js\").default} Image state.\n */\n getImageState() {\n return this.imageState_;\n }\n\n /**\n * Get the origin of the symbolizer.\n * @return {Array} Origin.\n * @api\n */\n getOrigin() {\n return this.origin_;\n }\n\n /**\n * Get the number of points for generating the shape.\n * @return {number} Number of points for stars and regular polygons.\n * @api\n */\n getPoints() {\n return this.points_;\n }\n\n /**\n * Get the (primary) radius for the shape.\n * @return {number} Radius.\n * @api\n */\n getRadius() {\n return this.radius_;\n }\n\n /**\n * Get the secondary radius for the shape.\n * @return {number|undefined} Radius2.\n * @api\n */\n getRadius2() {\n return this.radius2_;\n }\n\n /**\n * Get the size of the symbolizer (in pixels).\n * @return {import(\"../size.js\").Size} Size.\n * @api\n */\n getSize() {\n return this.size_;\n }\n\n /**\n * Get the stroke style for the shape.\n * @return {import(\"./Stroke.js\").default|null} Stroke style.\n * @api\n */\n getStroke() {\n return this.stroke_;\n }\n\n /**\n * Set the stroke style.\n * @param {import(\"./Stroke.js\").default|null} stroke Stroke style.\n * @api\n */\n setStroke(stroke) {\n this.stroke_ = stroke;\n this.render();\n }\n\n /**\n * @param {function(import(\"../events/Event.js\").default): void} listener Listener function.\n */\n listenImageChange(listener) {}\n\n /**\n * Load not yet loaded URI.\n */\n load() {}\n\n /**\n * @param {function(import(\"../events/Event.js\").default): void} listener Listener function.\n */\n unlistenImageChange(listener) {}\n\n /**\n * Calculate additional canvas size needed for the miter.\n * @param {string} lineJoin Line join\n * @param {number} strokeWidth Stroke width\n * @param {number} miterLimit Miter limit\n * @return {number} Additional canvas size needed\n * @private\n */\n calculateLineJoinSize_(lineJoin, strokeWidth, miterLimit) {\n if (\n strokeWidth === 0 ||\n this.points_ === Infinity ||\n (lineJoin !== 'bevel' && lineJoin !== 'miter')\n ) {\n return strokeWidth;\n }\n // m | ^\n // i | |\\ .\n // t >| #\\\n // e | |\\ \\ .\n // r \\s\\\n // | \\t\\ . .\n // \\r\\ . .\n // | \\o\\ . . . . .\n // e \\k\\ . . . .\n // | \\e\\ . . . . .\n // d \\ \\ . . . .\n // | _ _a_ _\\# . . .\n // r1 / ` . .\n // | . .\n // b / . .\n // | . .\n // / r2 . .\n // | . .\n // / . .\n // |α . .\n // / . .\n // ° center\n let r1 = this.radius_;\n let r2 = this.radius2_ === undefined ? r1 : this.radius2_;\n if (r1 < r2) {\n const tmp = r1;\n r1 = r2;\n r2 = tmp;\n }\n const points =\n this.radius2_ === undefined ? this.points_ : this.points_ * 2;\n const alpha = (2 * Math.PI) / points;\n const a = r2 * Math.sin(alpha);\n const b = Math.sqrt(r2 * r2 - a * a);\n const d = r1 - b;\n const e = Math.sqrt(a * a + d * d);\n const miterRatio = e / a;\n if (lineJoin === 'miter' && miterRatio <= miterLimit) {\n return miterRatio * strokeWidth;\n }\n // Calculate the distance from center to the stroke corner where\n // it was cut short because of the miter limit.\n // l\n // ----+---- <= distance from center to here is maxr\n // /####|k ##\\\n // /#####^#####\\\n // /#### /+\\# s #\\\n // /### h/+++\\# t #\\\n // /### t/+++++\\# r #\\\n // /### a/+++++++\\# o #\\\n // /### p/++ fill +\\# k #\\\n ///#### /+++++^+++++\\# e #\\\n //#####/+++++/+\\+++++\\#####\\\n const k = strokeWidth / 2 / miterRatio;\n const l = (strokeWidth / 2) * (d / e);\n const maxr = Math.sqrt((r1 + k) * (r1 + k) + l * l);\n const bevelAdd = maxr - r1;\n if (this.radius2_ === undefined || lineJoin === 'bevel') {\n return bevelAdd * 2;\n }\n // If outer miter is over the miter limit the inner miter may reach through the\n // center and be longer than the bevel, same calculation as above but swap r1 / r2.\n const aa = r1 * Math.sin(alpha);\n const bb = Math.sqrt(r1 * r1 - aa * aa);\n const dd = r2 - bb;\n const ee = Math.sqrt(aa * aa + dd * dd);\n const innerMiterRatio = ee / aa;\n if (innerMiterRatio <= miterLimit) {\n const innerLength = (innerMiterRatio * strokeWidth) / 2 - r2 - r1;\n return 2 * Math.max(bevelAdd, innerLength);\n }\n return bevelAdd * 2;\n }\n\n /**\n * @return {RenderOptions} The render options\n * @protected\n */\n createRenderOptions() {\n let lineCap = defaultLineCap;\n let lineJoin = defaultLineJoin;\n let miterLimit = 0;\n let lineDash = null;\n let lineDashOffset = 0;\n let strokeStyle;\n let strokeWidth = 0;\n\n if (this.stroke_) {\n strokeStyle = asColorLike(this.stroke_.getColor() ?? defaultStrokeStyle);\n strokeWidth = this.stroke_.getWidth() ?? defaultLineWidth;\n lineDash = this.stroke_.getLineDash();\n lineDashOffset = this.stroke_.getLineDashOffset() ?? 0;\n lineJoin = this.stroke_.getLineJoin() ?? defaultLineJoin;\n lineCap = this.stroke_.getLineCap() ?? defaultLineCap;\n miterLimit = this.stroke_.getMiterLimit() ?? defaultMiterLimit;\n }\n\n const add = this.calculateLineJoinSize_(lineJoin, strokeWidth, miterLimit);\n const maxRadius = Math.max(this.radius_, this.radius2_ || 0);\n const size = Math.ceil(2 * maxRadius + add);\n\n return {\n strokeStyle: strokeStyle,\n strokeWidth: strokeWidth,\n size: size,\n lineCap: lineCap,\n lineDash: lineDash,\n lineDashOffset: lineDashOffset,\n lineJoin: lineJoin,\n miterLimit: miterLimit,\n };\n }\n\n /**\n * @protected\n */\n render() {\n this.renderOptions_ = this.createRenderOptions();\n const size = this.renderOptions_.size;\n this.canvases_ = {};\n this.hitDetectionCanvas_ = null;\n this.size_ = [size, size];\n }\n\n /**\n * @private\n * @param {RenderOptions} renderOptions Render options.\n * @param {CanvasRenderingContext2D} context The rendering context.\n * @param {number} pixelRatio The pixel ratio.\n */\n draw_(renderOptions, context, pixelRatio) {\n context.scale(pixelRatio, pixelRatio);\n // set origin to canvas center\n context.translate(renderOptions.size / 2, renderOptions.size / 2);\n\n this.createPath_(context);\n\n if (this.fill_) {\n let color = this.fill_.getColor();\n if (color === null) {\n color = defaultFillStyle;\n }\n context.fillStyle = asColorLike(color);\n context.fill();\n }\n if (renderOptions.strokeStyle) {\n context.strokeStyle = renderOptions.strokeStyle;\n context.lineWidth = renderOptions.strokeWidth;\n if (renderOptions.lineDash) {\n context.setLineDash(renderOptions.lineDash);\n context.lineDashOffset = renderOptions.lineDashOffset;\n }\n context.lineCap = renderOptions.lineCap;\n context.lineJoin = renderOptions.lineJoin;\n context.miterLimit = renderOptions.miterLimit;\n context.stroke();\n }\n }\n\n /**\n * @private\n * @param {RenderOptions} renderOptions Render options.\n * @return {HTMLCanvasElement} Canvas containing the icon\n */\n createHitDetectionCanvas_(renderOptions) {\n let context;\n if (this.fill_) {\n let color = this.fill_.getColor();\n\n // determine if fill is transparent (or pattern or gradient)\n let opacity = 0;\n if (typeof color === 'string') {\n color = asArray(color);\n }\n if (color === null) {\n opacity = 1;\n } else if (Array.isArray(color)) {\n opacity = color.length === 4 ? color[3] : 1;\n }\n if (opacity === 0) {\n // if a transparent fill style is set, create an extra hit-detection image\n // with a default fill style\n context = createCanvasContext2D(renderOptions.size, renderOptions.size);\n this.drawHitDetectionCanvas_(renderOptions, context);\n }\n }\n return context ? context.canvas : this.getImage(1);\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} context The context to draw in.\n */\n createPath_(context) {\n let points = this.points_;\n const radius = this.radius_;\n if (points === Infinity) {\n context.arc(0, 0, radius, 0, 2 * Math.PI);\n } else {\n const radius2 = this.radius2_ === undefined ? radius : this.radius2_;\n if (this.radius2_ !== undefined) {\n points *= 2;\n }\n const startAngle = this.angle_ - Math.PI / 2;\n const step = (2 * Math.PI) / points;\n for (let i = 0; i < points; i++) {\n const angle0 = startAngle + i * step;\n const radiusC = i % 2 === 0 ? radius : radius2;\n context.lineTo(radiusC * Math.cos(angle0), radiusC * Math.sin(angle0));\n }\n context.closePath();\n }\n }\n\n /**\n * @private\n * @param {RenderOptions} renderOptions Render options.\n * @param {CanvasRenderingContext2D} context The context.\n */\n drawHitDetectionCanvas_(renderOptions, context) {\n // set origin to canvas center\n context.translate(renderOptions.size / 2, renderOptions.size / 2);\n\n this.createPath_(context);\n\n context.fillStyle = defaultFillStyle;\n context.fill();\n if (renderOptions.strokeStyle) {\n context.strokeStyle = renderOptions.strokeStyle;\n context.lineWidth = renderOptions.strokeWidth;\n if (renderOptions.lineDash) {\n context.setLineDash(renderOptions.lineDash);\n context.lineDashOffset = renderOptions.lineDashOffset;\n }\n context.lineJoin = renderOptions.lineJoin;\n context.miterLimit = renderOptions.miterLimit;\n context.stroke();\n }\n }\n\n ready() {\n return this.fill_ ? this.fill_.ready() : Promise.resolve();\n }\n}\n\nexport default RegularShape;\n","/**\n * @module ol/style/Circle\n */\n\nimport RegularShape from './RegularShape.js';\n\n/**\n * @typedef {Object} Options\n * @property {import(\"./Fill.js\").default} [fill] Fill style.\n * @property {number} radius Circle radius.\n * @property {import(\"./Stroke.js\").default} [stroke] Stroke style.\n * @property {Array} [displacement=[0,0]] displacement\n * @property {number|import(\"../size.js\").Size} [scale=1] Scale. A two dimensional scale will produce an ellipse.\n * Unless two dimensional scaling is required a better result may be obtained with an appropriate setting for `radius`.\n * @property {number} [rotation=0] Rotation in radians\n * (positive rotation clockwise, meaningful only when used in conjunction with a two dimensional scale).\n * @property {boolean} [rotateWithView=false] Whether to rotate the shape with the view\n * (meaningful only when used in conjunction with a two dimensional scale).\n * @property {import('./Style.js').DeclutterMode} [declutterMode] Declutter mode\n */\n\n/**\n * @classdesc\n * Set circle style for vector features.\n * @api\n */\nclass CircleStyle extends RegularShape {\n /**\n * @param {Options} [options] Options.\n */\n constructor(options) {\n options = options ? options : {radius: 5};\n\n super({\n points: Infinity,\n fill: options.fill,\n radius: options.radius,\n stroke: options.stroke,\n scale: options.scale !== undefined ? options.scale : 1,\n rotation: options.rotation !== undefined ? options.rotation : 0,\n rotateWithView:\n options.rotateWithView !== undefined ? options.rotateWithView : false,\n displacement:\n options.displacement !== undefined ? options.displacement : [0, 0],\n declutterMode: options.declutterMode,\n });\n }\n\n /**\n * Clones the style.\n * @return {CircleStyle} The cloned style.\n * @api\n */\n clone() {\n const scale = this.getScale();\n const style = new CircleStyle({\n fill: this.getFill() ? this.getFill().clone() : undefined,\n stroke: this.getStroke() ? this.getStroke().clone() : undefined,\n radius: this.getRadius(),\n scale: Array.isArray(scale) ? scale.slice() : scale,\n rotation: this.getRotation(),\n rotateWithView: this.getRotateWithView(),\n displacement: this.getDisplacement().slice(),\n declutterMode: this.getDeclutterMode(),\n });\n style.setOpacity(this.getOpacity());\n return style;\n }\n\n /**\n * Set the circle radius.\n *\n * @param {number} radius Circle radius.\n * @api\n */\n setRadius(radius) {\n this.radius_ = radius;\n this.render();\n }\n}\n\nexport default CircleStyle;\n","/**\n * @module ol/style/Style\n */\n\nimport CircleStyle from './Circle.js';\nimport Fill from './Fill.js';\nimport Stroke from './Stroke.js';\nimport {assert} from '../asserts.js';\n\n/**\n * Defines how symbols and text are decluttered on layers ith `declutter` set to `true`\n * * **declutter**: Overlapping symbols and text are decluttered.\n * * **obstacle**: Symbols and text are rendered, but serve as obstacle for subsequent attempts\n * to place a symbol or text at the same location.\n * * **none**: No decluttering is done.\n *\n * @typedef {\"declutter\"|\"obstacle\"|\"none\"} DeclutterMode\n */\n\n/**\n * A function that takes an {@link module:ol/Feature~Feature} and a `{number}`\n * representing the view's resolution. The function should return a\n * {@link module:ol/style/Style~Style} or an array of them. This way e.g. a\n * vector layer can be styled. If the function returns `undefined`, the\n * feature will not be rendered.\n *\n * @typedef {function(import(\"../Feature.js\").FeatureLike, number):(Style|Array