UNPKG

esri-leaflet

Version:

Leaflet plugins for consuming ArcGIS Online and ArcGIS Server services.

11 lines 67.5 kB
/* esri-leaflet - v3.0.18 - Thu Aug 14 2025 15:02:37 GMT-0500 (Central Daylight Time) * Copyright (c) 2025 Environmental Systems Research Institute, Inc. * Apache-2.0 */ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("leaflet")):"function"==typeof define&&define.amd?define(["exports","leaflet"],e):e(((t="undefined"!=typeof globalThis?globalThis:t||self).L=t.L||{},t.L.esri={}),t.L)}(this,(function(t,e){"use strict";var i="3.0.18";const s=window.XMLHttpRequest&&"withCredentials"in new window.XMLHttpRequest,r=""===document.documentElement.style.pointerEvents,o={cors:s,pointerEvents:r},n={attributionWidthOffset:55};let a=0;function l(t){let e="";t.f=t.f||"json";for(const i in t)if(Object.hasOwn(t,i)){const s=t[i],r=Object.prototype.toString.call(s);let o;e.length&&(e+="&"),o="[object Array]"===r?"[object Object]"===Object.prototype.toString.call(s[0])?JSON.stringify(s):s.join(","):"[object Object]"===r?JSON.stringify(s):"[object Date]"===r?s.valueOf():s,e+=`${encodeURIComponent(i)}=${encodeURIComponent(o)}`}return e.replaceAll("'","%27")}function h(t,i){const s=new window.XMLHttpRequest;return s.onerror=function(){s.onreadystatechange=e.Util.falseFn,t.call(i,{error:{code:500,message:"XMLHttpRequest error"}},null)},s.onreadystatechange=function(){let r,o;if(4===s.readyState){try{r=JSON.parse(s.responseText)}catch(t){r=null,o={code:500,message:"Could not parse response as JSON. This could also be caused by a CORS or XMLHttpRequest error."}}!o&&r.error&&(o=r.error,r=null),s.onerror=e.Util.falseFn,t.call(i,o,r)}},s.ontimeout=function(){this.onerror()},s}function u(t,e,i,s){const r=h(i,s);return r.open("POST",t),null!=s&&void 0!==s.options&&(r.timeout=s.options.timeout),r.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8"),r.send(l(e)),r}function p(t,e,i,s){const r=h(i,s);return r.open("GET",`${t}?${l(e)}`,!0),null!=s&&void 0!==s.options&&(r.timeout=s.options.timeout,s.options.withCredentials&&(r.withCredentials=!0)),r.send(null),r}function c(t,e,i,s){const r=l(e),n=h(i,s),a=`${t}?${r}`.length;if(a<=2e3&&o.cors?n.open("GET",`${t}?${r}`):a>2e3&&o.cors&&(n.open("POST",t),n.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8")),null!=s&&void 0!==s.options&&(n.timeout=s.options.timeout,s.options.withCredentials&&(n.withCredentials=!0)),a<=2e3&&o.cors)n.send(null);else{if(!(a>2e3&&o.cors))return a<=2e3&&!o.cors?d(t,e,i,s):void y(`a request to ${t} was longer then 2000 characters and this browser cannot make a cross-domain post request. Please use a proxy https://developers.arcgis.com/esri-leaflet/api-reference/request/`);n.send(r)}return n}function d(t,i,s,r){window._EsriLeafletCallbacks=window._EsriLeafletCallbacks||{};const o=`c${a}`;i.callback=`window._EsriLeafletCallbacks.${o}`,window._EsriLeafletCallbacks[o]=function(t){if(!0!==window._EsriLeafletCallbacks[o]){let e;const i=Object.prototype.toString.call(t);"[object Object]"!==i&&"[object Array]"!==i&&(e={error:{code:500,message:"Expected array or object as JSONP response"}},t=null),!e&&t.error&&(e=t,t=null),s.call(r,e,t),window._EsriLeafletCallbacks[o]=!0}};const n=e.DomUtil.create("script",null,document.body);return n.type="text/javascript",n.src=`${t}?${l(i)}`,n.id=o,n.onerror=function(t){if(t&&!0!==window._EsriLeafletCallbacks[o]){const t={error:{code:500,message:"An unknown error occurred"}};s.call(r,t),window._EsriLeafletCallbacks[o]=!0}},e.DomUtil.addClass(n,"esri-leaflet-jsonp"),a++,{id:o,url:n.src,abort(){window._EsriLeafletCallbacks._callback[o]({code:0,message:"Request aborted."})}}}const m=o.cors?p:d;function y(...t){console&&console.warn&&console.warn.apply(console,t)}m.CORS=p,m.JSONP=d;const f={request:c,get:m,post:u}; /* @preserve * @terraformer/arcgis - v2.0.7 - MIT * Copyright (c) 2012-2021 Environmental Systems Research Institute, Inc. * Thu Jul 22 2021 13:58:30 GMT-0700 (Pacific Daylight Time) */ /* Copyright (c) 2012-2019 Environmental Systems Research Institute, Inc. * Apache-2.0 */var g=function(t,e,i,s){var r=(s[0]-i[0])*(t[1]-i[1])-(s[1]-i[1])*(t[0]-i[0]),o=(e[0]-t[0])*(t[1]-i[1])-(e[1]-t[1])*(t[0]-i[0]),n=(s[1]-i[1])*(e[0]-t[0])-(s[0]-i[0])*(e[1]-t[1]);if(0!==n){var a=r/n,l=o/n;if(a>=0&&a<=1&&l>=0&&l<=1)return!0}return!1},_=function(t,e){for(var i=0;i<t.length-1;i++)for(var s=0;s<e.length-1;s++)if(g(t[i],t[i+1],e[s],e[s+1]))return!0;return!1},b=function(t){return function(t,e){for(var i=0;i<t.length;i++)if(t[i]!==e[i])return!1;return!0}(t[0],t[t.length-1])||t.push(t[0]),t},v=function(t){for(var e,i=0,s=0,r=t.length,o=t[s];s<r-1;s++)i+=((e=t[s+1])[0]-o[0])*(e[1]+o[1]),o=e;return i>=0},x=function(t){var e={};for(var i in t)t.hasOwnProperty(i)&&(e[i]=t[i]);return e},S=function(t,e){var i=_(t,e),s=function(t,e){for(var i=!1,s=-1,r=t.length,o=r-1;++s<r;o=s)(t[s][1]<=e[1]&&e[1]<t[o][1]||t[o][1]<=e[1]&&e[1]<t[s][1])&&e[0]<(t[o][0]-t[s][0])*(e[1]-t[s][1])/(t[o][1]-t[s][1])+t[s][0]&&(i=!i);return i}(t,e[0]);return!(i||!s)},L=function t(e,i){var s={};if(e.features){s.type="FeatureCollection",s.features=[];for(var r=0;r<e.features.length;r++)s.features.push(t(e.features[r],i))}if("number"==typeof e.x&&"number"==typeof e.y&&(s.type="Point",s.coordinates=[e.x,e.y],"number"==typeof e.z&&s.coordinates.push(e.z)),e.points&&(s.type="MultiPoint",s.coordinates=e.points.slice(0)),e.paths&&(1===e.paths.length?(s.type="LineString",s.coordinates=e.paths[0].slice(0)):(s.type="MultiLineString",s.coordinates=e.paths.slice(0))),e.rings&&(s=function(t){for(var e,i,s,r=[],o=[],n=0;n<t.length;n++){var a=b(t[n].slice(0));if(!(a.length<4))if(v(a)){var l=[a.slice().reverse()];r.push(l)}else o.push(a.slice().reverse())}for(var h=[];o.length;){s=o.pop();var u=!1;for(e=r.length-1;e>=0;e--)if(i=r[e][0],S(i,s)){r[e].push(s),u=!0;break}u||h.push(s)}for(;h.length;){s=h.pop();var p=!1;for(e=r.length-1;e>=0;e--)if(i=r[e][0],_(i,s)){r[e].push(s),p=!0;break}p||r.push([s.reverse()])}return 1===r.length?{type:"Polygon",coordinates:r[0]}:{type:"MultiPolygon",coordinates:r}}(e.rings.slice(0))),"number"==typeof e.xmin&&"number"==typeof e.ymin&&"number"==typeof e.xmax&&"number"==typeof e.ymax&&(s.type="Polygon",s.coordinates=[[[e.xmax,e.ymax],[e.xmin,e.ymax],[e.xmin,e.ymin],[e.xmax,e.ymin],[e.xmax,e.ymax]]]),(e.geometry||e.attributes)&&(s.type="Feature",s.geometry=e.geometry?t(e.geometry):null,s.properties=e.attributes?x(e.attributes):null,e.attributes))try{s.id=function(t,e){for(var i=e?[e,"OBJECTID","FID"]:["OBJECTID","FID"],s=0;s<i.length;s++){var r=i[s];if(r in t&&("string"==typeof t[r]||"number"==typeof t[r]))return t[r]}throw Error("No valid id attribute found")}(e.attributes,i)}catch(t){}return JSON.stringify(s.geometry)===JSON.stringify({})&&(s.geometry=null),e.spatialReference&&e.spatialReference.wkid&&4326!==e.spatialReference.wkid&&console.warn("Object converted in non-standard crs - "+JSON.stringify(e.spatialReference)),s},A=function(t){var e=[],i=t.slice(0),s=b(i.shift().slice(0));if(s.length>=4){v(s)||s.reverse(),e.push(s);for(var r=0;r<i.length;r++){var o=b(i[r].slice(0));o.length>=4&&(v(o)&&o.reverse(),e.push(o))}}return e},I=function t(e,i){i=i||"OBJECTID";var s,r={wkid:4326},o={};switch(e.type){case"Point":o.x=e.coordinates[0],o.y=e.coordinates[1],e.coordinates[2]&&(o.z=e.coordinates[2]),o.spatialReference=r;break;case"MultiPoint":o.points=e.coordinates.slice(0),e.coordinates[0][2]&&(o.hasZ=!0),o.spatialReference=r;break;case"LineString":o.paths=[e.coordinates.slice(0)],e.coordinates[0][2]&&(o.hasZ=!0),o.spatialReference=r;break;case"MultiLineString":o.paths=e.coordinates.slice(0),e.coordinates[0][0][2]&&(o.hasZ=!0),o.spatialReference=r;break;case"Polygon":o.rings=A(e.coordinates.slice(0)),e.coordinates[0][0][2]&&(o.hasZ=!0),o.spatialReference=r;break;case"MultiPolygon":o.rings=function(t){for(var e=[],i=0;i<t.length;i++)for(var s=A(t[i]),r=s.length-1;r>=0;r--){var o=s[r].slice(0);e.push(o)}return e}(e.coordinates.slice(0)),e.coordinates[0][0][0][2]&&(o.hasZ=!0),o.spatialReference=r;break;case"Feature":e.geometry&&(o.geometry=t(e.geometry,i)),o.attributes=e.properties?x(e.properties):{},e.id&&(o.attributes[i]=e.id);break;case"FeatureCollection":for(o=[],s=0;s<e.features.length;s++)o.push(t(e.features[s],i));break;case"GeometryCollection":for(o=[],s=0;s<e.geometries.length;s++)o.push(t(e.geometries[s],i))}return o};function T(t,e){return I(t,e)}function C(t,e){return L(t,e)}function w(t){if("NaN"!==t.xmin&&"NaN"!==t.ymin&&"NaN"!==t.xmax&&"NaN"!==t.ymax){const i=e.latLng(t.ymin,t.xmin),s=e.latLng(t.ymax,t.xmax);return e.latLngBounds(i,s)}return null}function R(t){return{xmin:(t=e.latLngBounds(t)).getSouthWest().lng,ymin:t.getSouthWest().lat,xmax:t.getNorthEast().lng,ymax:t.getNorthEast().lat,spatialReference:{wkid:4326}}}const P=/^(OBJECTID|FID|OID|ID)$/i;function O(t){let e;if(t.objectIdFieldName)e=t.objectIdFieldName;else if(t.fields){for(let i=0;i<=t.fields.length-1;i++)if("esriFieldTypeOID"===t.fields[i].type){e=t.fields[i].name;break}if(!e)for(let i=0;i<=t.fields.length-1;i++)if(t.fields[i].name.match(P)){e=t.fields[i].name;break}}return e}function F(t){for(const e in t.attributes)if(e.match(P))return e}function k(t,e){let i;const s=t.features||t.results,r=s&&s.length;i=e||O(t);const o={type:"FeatureCollection",features:[]};if(r)for(let t=s.length-1;t>=0;t--){const e=C(s[t],i||F(s[t]));o.features.push(e)}return o}function M(t){return"/"!==(t=e.Util.trim(t))[t.length-1]&&(t+="/"),t}function U(t){if(-1!==t.url.indexOf("?")){t.requestParams=t.requestParams||{};const e=t.url.substring(t.url.indexOf("?")+1);t.url=t.url.split("?")[0],t.requestParams=JSON.parse(`{"${decodeURI(e).replace(/"/g,'\\"').replace(/&/g,'","').replace(/=/g,'":"')}"}`)}return t.url=M(t.url.split("?")[0]),t}function G(t){return/^(?!.*utility\.arcgis\.com).*\.arcgis\.com.*FeatureServer/i.test(t)}function D(t){let e;switch(t){case"Point":e="esriGeometryPoint";break;case"MultiPoint":e="esriGeometryMultipoint";break;case"LineString":case"MultiLineString":e="esriGeometryPolyline";break;case"Polygon":case"MultiPolygon":e="esriGeometryPolygon"}return e}function E(t){return t.getSize().x-n.attributionWidthOffset+"px"}function q(t){if(t.attributionControl){if(t.attributionControl._esriAttributionLayerCount||(t.attributionControl._esriAttributionLayerCount=0),0===t.attributionControl._esriAttributionLayerCount){if(!t.attributionControl._esriAttributionAddedOnce){const e=document.createElement("style");e.type="text/css",e.innerHTML=".esri-truncated-attribution:hover {white-space: normal;}",document.getElementsByTagName("head")[0].appendChild(e);const i=document.createElement("style");i.type="text/css",i.innerHTML=`.esri-truncated-attribution {vertical-align: -3px;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;display: inline-block;transition: 0s white-space;transition-delay: 1s;max-width: ${E(t)};}`,document.getElementsByTagName("head")[0].appendChild(i),t.on("resize",(e=>{t.attributionControl&&(t.attributionControl._container.style.maxWidth=E(e.target))})),t.attributionControl._esriAttributionAddedOnce=!0}e.DomUtil.addClass(t.attributionControl._container,"esri-truncated-attribution:hover"),e.DomUtil.addClass(t.attributionControl._container,"esri-truncated-attribution")}t.attributionControl._esriAttributionLayerCount=t.attributionControl._esriAttributionLayerCount+1}}function B(){return'Powered by <a href="https://www.esri.com">Esri</a>'}function z(t){t.attributionControl&&(t.attributionControl._esriAttributionLayerCount&&1===t.attributionControl._esriAttributionLayerCount&&(e.DomUtil.removeClass(t.attributionControl._container,"esri-truncated-attribution:hover"),e.DomUtil.removeClass(t.attributionControl._container,"esri-truncated-attribution")),t.attributionControl._esriAttributionLayerCount=t.attributionControl._esriAttributionLayerCount-1)}function Z(t){const i={geometry:null,geometryType:null};return t instanceof e.LatLngBounds?(i.geometry=R(t),i.geometryType="esriGeometryEnvelope",i):(t.getLatLng&&(t=t.getLatLng()),t instanceof e.LatLng&&(t={type:"Point",coordinates:[t.lng,t.lat]}),t instanceof e.GeoJSON&&(t=t.getLayers()[0].feature.geometry,i.geometry=T(t),i.geometryType=D(t.type)),t.toGeoJSON&&(t=t.toGeoJSON()),"Feature"===t.type&&(t=t.geometry),"Point"===t.type||"LineString"===t.type||"Polygon"===t.type||"MultiPolygon"===t.type?(i.geometry=T(t),i.geometryType=D(t.type),i):void y("invalid geometry passed to spatial query. Should be L.LatLng, L.LatLngBounds, L.Marker or a GeoJSON Point, Line, Polygon or MultiPolygon object"))}function $(t,i){o.cors&&c(t,{},e.Util.bind(((t,s)=>{if(t)return;i._esriAttributions=[];for(let t=0;t<s.contributors.length;t++){const r=s.contributors[t];for(let t=0;t<r.coverageAreas.length;t++){const s=r.coverageAreas[t],o=e.latLng(s.bbox[0],s.bbox[1]),n=e.latLng(s.bbox[2],s.bbox[3]);i._esriAttributions.push({attribution:r.attribution,score:s.score,bounds:e.latLngBounds(o,n),minZoom:s.zoomMin,maxZoom:s.zoomMax})}}i._esriAttributions.sort(((t,e)=>e.score-t.score));N({target:i})}),this))}function N(t){const i=t.target,s=i._esriAttributions;if(!i||!i.attributionControl)return;const r=i.attributionControl._container.querySelector(".esri-dynamic-attribution");if(r&&s){let t="";const o=i.getBounds(),n=e.latLngBounds(o.getSouthWest().wrap(),o.getNorthEast().wrap()),a=i.getZoom();for(let e=0;e<s.length;e++){const i=s[e],r=i.attribution;!t.match(r)&&i.bounds.intersects(n)&&a>=i.minZoom&&a<=i.maxZoom&&(t+=`, ${r}`)}t=`Powered by <a href="https://www.esri.com">Esri</a> | ${t.substr(2)}`,r.innerHTML=t,r.style.maxWidth=E(i),i.fire("attributionupdated",{attribution:t})}}const j={warn:y,cleanUrl:M,getUrlParams:U,isArcgisOnline:G,geojsonTypeToArcGIS:D,responseToFeatureCollection:k,geojsonToArcGIS:T,arcgisToGeoJSON:C,boundsToExtent:R,extentToBounds:w,calcAttributionWidth:E,setEsriAttribution:q,getEsriAttributionHtmlString:B,removeEsriAttribution:z,_setGeometry:Z,_getAttributionData:$,_updateMapAttribution:N,_findIdAttributeFromFeature:F,_findIdAttributeFromResponse:O},W=e.Class.extend({options:{proxy:!1,useCors:s},generateSetter:(t,i)=>e.Util.bind((function(e){return this.params[t]=e,this}),i),initialize(t){if(t.request&&t.options?(this._service=t,e.Util.setOptions(this,t.options)):(e.Util.setOptions(this,t),this.options.url=M(t.url)),this.params=e.Util.extend({},this.params||{}),this.setters)for(const t in this.setters){const e=this.setters[t];this[t]=this.generateSetter(e,this)}},token(t){return this._service?this._service.authenticate(t):this.params.token=t,this},apikey(t){return this.token(t)},format(t){return this.params.returnUnformattedValues=!t,this},request(t,i){return this.options.requestParams&&e.Util.extend(this.params,this.options.requestParams),this._service?this._service.request(this.path,this.params,t,i):this._request("request",this.path,this.params,t,i)},_request(t,e,i,s,r){const o=this.options.proxy?`${this.options.proxy}?${this.options.url}${e}`:this.options.url+e;return"get"!==t&&"request"!==t||this.options.useCors?f[t](o,i,s,r):f.get.JSONP(o,i,s,r)}});const J=W.extend({setters:{offset:"resultOffset",limit:"resultRecordCount",fields:"outFields",precision:"geometryPrecision",featureIds:"objectIds",returnGeometry:"returnGeometry",returnM:"returnM",transform:"datumTransformation",token:"token"},path:"query",params:{returnGeometry:!0,where:"1=1",outSR:4326,outFields:"*"},within(t){return this._setGeometryParams(t),this.params.spatialRel="esriSpatialRelContains",this},intersects(t){return this._setGeometryParams(t),this.params.spatialRel="esriSpatialRelIntersects",this},contains(t){return this._setGeometryParams(t),this.params.spatialRel="esriSpatialRelWithin",this},crosses(t){return this._setGeometryParams(t),this.params.spatialRel="esriSpatialRelCrosses",this},touches(t){return this._setGeometryParams(t),this.params.spatialRel="esriSpatialRelTouches",this},overlaps(t){return this._setGeometryParams(t),this.params.spatialRel="esriSpatialRelOverlaps",this},bboxIntersects(t){return this._setGeometryParams(t),this.params.spatialRel="esriSpatialRelEnvelopeIntersects",this},indexIntersects(t){return this._setGeometryParams(t),this.params.spatialRel="esriSpatialRelIndexIntersects",this},nearby(t,i){return t=e.latLng(t),this.params.geometry=[t.lng,t.lat],this.params.geometryType="esriGeometryPoint",this.params.spatialRel="esriSpatialRelIntersects",this.params.units="esriSRUnit_Meter",this.params.distance=i,this.params.inSR=4326,this},where(t){return this.params.where=t,this},between(t,e){return this.params.time=[t.valueOf(),e.valueOf()],this},simplify(t,e){const i=Math.abs(t.getBounds().getWest()-t.getBounds().getEast());return this.params.maxAllowableOffset=i/t.getSize().y*e,this},orderBy(t,e){return e=e||"ASC",this.params.orderByFields=this.params.orderByFields?`${this.params.orderByFields},`:"",this.params.orderByFields+=[t,e].join(" "),this},run(t,e){return this._cleanParams(),this.options.isModern||G(this.options.url)&&void 0===this.options.isModern?(this.params.f="geojson",this.request((function(i,s){this._trapSQLerrors(i),t.call(e,i,s,s)}),this)):this.request((function(i,s){this._trapSQLerrors(i),t.call(e,i,s&&k(s),s)}),this)},count(t,e){return this._cleanParams(),this.params.returnCountOnly=!0,this.request((function(e,i){t.call(this,e,i&&i.count,i)}),e)},ids(t,e){return this._cleanParams(),this.params.returnIdsOnly=!0,this.request((function(e,i){t.call(this,e,i&&i.objectIds,i)}),e)},bounds(t,e){return this._cleanParams(),this.params.returnExtentOnly=!0,this.request(((i,s)=>{s&&s.extent&&w(s.extent)?t.call(e,i,w(s.extent),s):(i={message:"Invalid Bounds"},t.call(e,i,null,s))}),e)},distinct(){return this.params.returnGeometry=!1,this.params.returnDistinctValues=!0,this},pixelSize(t){const i=e.point(t);return this.params.pixelSize=[i.x,i.y],this},layer(t){return this.path=`${t}/query`,this},_trapSQLerrors(t){t&&"400"===t.code&&y("one common syntax error in query requests is encasing string values in double quotes instead of single quotes")},_cleanParams(){delete this.params.returnIdsOnly,delete this.params.returnExtentOnly,delete this.params.returnCountOnly},_setGeometryParams(t){this.params.inSR=4326;const e=Z(t);this.params.geometry=e.geometry,this.params.geometryType=e.geometryType}});function V(t){return new J(t)}const Q=W.extend({setters:{contains:"contains",text:"searchText",fields:"searchFields",spatialReference:"sr",sr:"sr",layers:"layers",returnGeometry:"returnGeometry",maxAllowableOffset:"maxAllowableOffset",precision:"geometryPrecision",dynamicLayers:"dynamicLayers",returnZ:"returnZ",returnM:"returnM",gdbVersion:"gdbVersion",token:"token"},path:"find",params:{sr:4326,contains:!0,returnGeometry:!0,returnZ:!0,returnM:!1},layerDefs(t,e){return this.params.layerDefs=this.params.layerDefs?`${this.params.layerDefs};`:"",this.params.layerDefs+=[t,e].join(":"),this},simplify(t,e){const i=Math.abs(t.getBounds().getWest()-t.getBounds().getEast());return this.params.maxAllowableOffset=i/t.getSize().y*e,this},run(t,e){return this.request(((i,s)=>{t.call(e,i,s&&k(s),s)}),e)}});function H(t){return new Q(t)}const K=W.extend({path:"identify",between(t,e){return this.params.time=[t.valueOf(),e.valueOf()],this}});const X=K.extend({setters:{layers:"layers",precision:"geometryPrecision",tolerance:"tolerance",returnGeometry:"returnGeometry"},params:{sr:4326,layers:"all",tolerance:3,returnGeometry:!0},on(t){const e=R(t.getBounds()),i=t.getSize();return this.params.imageDisplay=[i.x,i.y,96],this.params.mapExtent=[e.xmin,e.ymin,e.xmax,e.ymax],this},at(t){return 2===t.length&&(t=e.latLng(t)),this._setGeometryParams(t),this},layerDef(t,e){return this.params.layerDefs=this.params.layerDefs?`${this.params.layerDefs};`:"",this.params.layerDefs+=[t,e].join(":"),this},simplify(t,e){const i=Math.abs(t.getBounds().getWest()-t.getBounds().getEast());return this.params.maxAllowableOffset=i/t.getSize().y*e,this},run(t,e){return this.request(((i,s)=>{if(i)t.call(e,i,void 0,s);else{const i=k(s);s.results=s.results.reverse();for(let t=0;t<i.features.length;t++){i.features[t].layerId=s.results[t].layerId}t.call(e,void 0,i,s)}}))},_setGeometryParams(t){const e=Z(t);this.params.geometry=e.geometry,this.params.geometryType=e.geometryType}});function Y(t){return new X(t)}const tt=K.extend({setters:{setMosaicRule:"mosaicRule",setRenderingRule:"renderingRule",setPixelSize:"pixelSize",returnCatalogItems:"returnCatalogItems",returnGeometry:"returnGeometry"},params:{returnGeometry:!1},at(t){return t=e.latLng(t),this.params.geometry=JSON.stringify({x:t.lng,y:t.lat,spatialReference:{wkid:4326}}),this.params.geometryType="esriGeometryPoint",this},getMosaicRule(){return this.params.mosaicRule},getRenderingRule(){return this.params.renderingRule},getPixelSize(){return this.params.pixelSize},run(t,e){return this.request((function(i,s){t.call(e,i,s&&this._responseToGeoJSON(s),s)}),this)},_responseToGeoJSON(t){const e=t.location,i=t.catalogItems,s=t.catalogItemVisibilities,r={pixel:{type:"Feature",geometry:{type:"Point",coordinates:[e.x,e.y]},crs:{type:"EPSG",properties:{code:e.spatialReference.wkid}},properties:{OBJECTID:t.objectId,name:t.name,value:t.value},id:t.objectId}};if(t.properties&&t.properties.Values&&(r.pixel.properties.values=t.properties.Values),i&&i.features&&(r.catalogItems=k(i),s&&s.length===r.catalogItems.features.length))for(let t=s.length-1;t>=0;t--)r.catalogItems.features[t].properties.catalogItemVisibility=s[t];return r}});function et(t){return new tt(t)}const it=e.Evented.extend({options:{proxy:!1,useCors:s,timeout:0},initialize(t){t=t||{},this._requestQueue=[],this._authenticating=!1,e.Util.setOptions(this,t),this.options.url=M(this.options.url)},get(t,e,i,s){return this._request("get",t,e,i,s)},post(t,e,i,s){return this._request("post",t,e,i,s)},request(t,e,i,s){return this._request("request",t,e,i,s)},metadata(t,e){return this._request("get","",{},t,e)},authenticate(t){return this._authenticating=!1,this.options.token=t,this._runQueue(),this},getTimeout(){return this.options.timeout},setTimeout(t){this.options.timeout=t},_request(t,i,s,r,o){this.fire("requeststart",{url:this.options.url+i,params:s,method:t},!0);const n=this._createServiceCallback(t,i,s,r,o);if(this.options.token&&(s.token=this.options.token),this.options.requestParams&&e.Util.extend(s,this.options.requestParams),!this._authenticating){const e=this.options.proxy?`${this.options.proxy}?${this.options.url}${i}`:this.options.url+i;return"get"!==t&&"request"!==t||this.options.useCors?f[t](e,s,n,o):f.get.JSONP(e,s,n,o)}this._requestQueue.push([t,i,s,r,o])},_createServiceCallback(t,i,s,r,o){return e.Util.bind((function(n,a){!n||499!==n.code&&498!==n.code||(this._authenticating=!0,this._requestQueue.push([t,i,s,r,o]),this.fire("authenticationrequired",{authenticate:e.Util.bind(this.authenticate,this)},!0),n.authenticate=e.Util.bind(this.authenticate,this)),r.call(o,n,a),n?this.fire("requesterror",{url:this.options.url+i,params:s,message:n.message,code:n.code,method:t},!0):this.fire("requestsuccess",{url:this.options.url+i,params:s,response:a,method:t},!0),this.fire("requestend",{url:this.options.url+i,params:s,method:t},!0)}),this)},_runQueue(){for(let t=this._requestQueue.length-1;t>=0;t--){const e=this._requestQueue[t];this[e.shift()].apply(this,e)}this._requestQueue=[]}});const st=it.extend({identify(){return Y(this)},find(){return H(this)},query(){return V(this)}});function rt(t){return new st(t)}const ot=it.extend({query(){return V(this)},identify(){return et(this)}});function nt(t){return new ot(t)}const at=it.extend({options:{idAttribute:"OBJECTID"},query(){return V(this)},addFeature(t,e,i){this.addFeatures(t,e,i)},addFeatures(t,e,i){const s=t.features?t.features:[t];for(let t=s.length-1;t>=0;t--)delete s[t].id;return t=T(t),t=s.length>1?t:[t],this.post("addFeatures",{features:t},((t,s)=>{const r=s&&s.addResults?s.addResults.length>1?s.addResults:s.addResults[0]:void 0;e&&e.call(i,t||s.addResults[0].error,r)}),i)},updateFeature(t,e,i){this.updateFeatures(t,e,i)},updateFeatures(t,e,i){const s=t.features?t.features:[t];return t=T(t,this.options.idAttribute),t=s.length>1?t:[t],this.post("updateFeatures",{features:t},((t,s)=>{const r=s&&s.updateResults?s.updateResults.length>1?s.updateResults:s.updateResults[0]:void 0;e&&e.call(i,t||s.updateResults[0].error,r)}),i)},deleteFeature(t,e,i){this.deleteFeatures(t,e,i)},deleteFeatures(t,e,i){return this.post("deleteFeatures",{objectIds:t},((t,s)=>{const r=s&&s.deleteResults?s.deleteResults.length>1?s.deleteResults:s.deleteResults[0]:void 0;e&&e.call(i,t||s.deleteResults[0].error,r)}),i)}});function lt(t){return new at(t)}const ht="https:"!==window.location.protocol?"http:":"https:",ut=e.TileLayer.extend({statics:{TILES:{Streets:{urlTemplate:`${ht}//{s}.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer/tile/{z}/{y}/{x}`,options:{minZoom:1,maxZoom:19,subdomains:["server","services"],attribution:"USGS, NOAA",attributionUrl:"https://static.arcgis.com/attribution/World_Street_Map"}},Topographic:{urlTemplate:`${ht}//{s}.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{z}/{y}/{x}`,options:{minZoom:1,maxZoom:19,subdomains:["server","services"],attribution:"USGS, NOAA",attributionUrl:"https://static.arcgis.com/attribution/World_Topo_Map"}},Oceans:{urlTemplate:`${ht}//{s}.arcgisonline.com/arcgis/rest/services/Ocean/World_Ocean_Base/MapServer/tile/{z}/{y}/{x}`,options:{minZoom:1,maxZoom:16,subdomains:["server","services"],attribution:"USGS, NOAA",attributionUrl:"https://static.arcgis.com/attribution/Ocean_Basemap"}},OceansLabels:{urlTemplate:`${ht}//{s}.arcgisonline.com/arcgis/rest/services/Ocean/World_Ocean_Reference/MapServer/tile/{z}/{y}/{x}`,options:{minZoom:1,maxZoom:16,subdomains:["server","services"],pane:r?"esri-labels":"tilePane",attribution:""}},NationalGeographic:{urlTemplate:`${ht}//{s}.arcgisonline.com/ArcGIS/rest/services/NatGeo_World_Map/MapServer/tile/{z}/{y}/{x}`,options:{minZoom:1,maxZoom:16,subdomains:["server","services"],attribution:"National Geographic, DeLorme, HERE, UNEP-WCMC, USGS, NASA, ESA, METI, NRCAN, GEBCO, NOAA, increment P Corp."}},DarkGray:{urlTemplate:`${ht}//{s}.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Dark_Gray_Base/MapServer/tile/{z}/{y}/{x}`,options:{minZoom:1,maxZoom:16,subdomains:["server","services"],attribution:"HERE, DeLorme, MapmyIndia, &copy; OpenStreetMap contributors"}},DarkGrayLabels:{urlTemplate:`${ht}//{s}.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Dark_Gray_Reference/MapServer/tile/{z}/{y}/{x}`,options:{minZoom:1,maxZoom:16,subdomains:["server","services"],pane:r?"esri-labels":"tilePane",attribution:""}},Gray:{urlTemplate:`${ht}//{s}.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer/tile/{z}/{y}/{x}`,options:{minZoom:1,maxZoom:16,subdomains:["server","services"],attribution:"HERE, DeLorme, MapmyIndia, &copy; OpenStreetMap contributors"}},GrayLabels:{urlTemplate:`${ht}//{s}.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Reference/MapServer/tile/{z}/{y}/{x}`,options:{minZoom:1,maxZoom:16,subdomains:["server","services"],pane:r?"esri-labels":"tilePane",attribution:""}},Imagery:{urlTemplate:`${ht}//{s}.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}`,options:{minZoom:1,maxZoom:19,subdomains:["server","services"],attribution:"DigitalGlobe, GeoEye, i-cubed, USDA, USGS, AEX, Getmapping, Aerogrid, IGN, IGP, swisstopo, and the GIS User Community",attributionUrl:"https://static.arcgis.com/attribution/World_Imagery"}},ImageryLabels:{urlTemplate:`${ht}//{s}.arcgisonline.com/ArcGIS/rest/services/Reference/World_Boundaries_and_Places/MapServer/tile/{z}/{y}/{x}`,options:{minZoom:1,maxZoom:19,subdomains:["server","services"],pane:r?"esri-labels":"tilePane",attribution:""}},ImageryTransportation:{urlTemplate:`${ht}//{s}.arcgisonline.com/ArcGIS/rest/services/Reference/World_Transportation/MapServer/tile/{z}/{y}/{x}`,options:{minZoom:1,maxZoom:19,subdomains:["server","services"],pane:r?"esri-labels":"tilePane",attribution:""}},ShadedRelief:{urlTemplate:`${ht}//{s}.arcgisonline.com/ArcGIS/rest/services/World_Shaded_Relief/MapServer/tile/{z}/{y}/{x}`,options:{minZoom:1,maxZoom:13,subdomains:["server","services"],attribution:"USGS"}},ShadedReliefLabels:{urlTemplate:`${ht}//{s}.arcgisonline.com/ArcGIS/rest/services/Reference/World_Boundaries_and_Places_Alternate/MapServer/tile/{z}/{y}/{x}`,options:{minZoom:1,maxZoom:12,subdomains:["server","services"],pane:r?"esri-labels":"tilePane",attribution:""}},Terrain:{urlTemplate:`${ht}//{s}.arcgisonline.com/ArcGIS/rest/services/World_Terrain_Base/MapServer/tile/{z}/{y}/{x}`,options:{minZoom:1,maxZoom:13,subdomains:["server","services"],attribution:"USGS, NOAA"}},TerrainLabels:{urlTemplate:`${ht}//{s}.arcgisonline.com/ArcGIS/rest/services/Reference/World_Reference_Overlay/MapServer/tile/{z}/{y}/{x}`,options:{minZoom:1,maxZoom:13,subdomains:["server","services"],pane:r?"esri-labels":"tilePane",attribution:""}},USATopo:{urlTemplate:`${ht}//{s}.arcgisonline.com/ArcGIS/rest/services/USA_Topo_Maps/MapServer/tile/{z}/{y}/{x}`,options:{minZoom:1,maxZoom:15,subdomains:["server","services"],attribution:"USGS, National Geographic Society, i-cubed"}},ImageryClarity:{urlTemplate:`${ht}//clarity.maptiles.arcgis.com/arcgis/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}`,options:{minZoom:1,maxZoom:19,attribution:"Esri, DigitalGlobe, GeoEye, Earthstar Geographics, CNES/Airbus DS, USDA, USGS, AeroGRID, IGN, and the GIS User Community"}},Physical:{urlTemplate:`${ht}//{s}.arcgisonline.com/arcgis/rest/services/World_Physical_Map/MapServer/tile/{z}/{y}/{x}`,options:{minZoom:1,maxZoom:8,subdomains:["server","services"],attribution:"U.S. National Park Service"}},ImageryFirefly:{urlTemplate:`${ht}//fly.maptiles.arcgis.com/arcgis/rest/services/World_Imagery_Firefly/MapServer/tile/{z}/{y}/{x}`,options:{minZoom:1,maxZoom:19,attribution:"Esri, DigitalGlobe, GeoEye, Earthstar Geographics, CNES/Airbus DS, USDA, USGS, AeroGRID, IGN, and the GIS User Community",attributionUrl:"https://static.arcgis.com/attribution/World_Imagery"}}}},initialize(t,i){let s;if("object"==typeof t&&t.urlTemplate&&t.options)s=t;else{if("string"!=typeof t||!ut.TILES[t])throw new Error('L.esri.BasemapLayer: Invalid parameter. Use one of "Streets", "Topographic", "Oceans", "OceansLabels", "NationalGeographic", "Physical", "Gray", "GrayLabels", "DarkGray", "DarkGrayLabels", "Imagery", "ImageryLabels", "ImageryTransportation", "ImageryClarity", "ImageryFirefly", ShadedRelief", "ShadedReliefLabels", "Terrain", "TerrainLabels" or "USATopo"');s=ut.TILES[t]}const r=e.Util.extend(s.options,i);e.Util.setOptions(this,r),this.options.ignoreDeprecationWarning||console.warn("WARNING: L.esri.BasemapLayer uses data services that are in mature support and are not being updated. Please use L.esri.Vector.vectorBasemapLayer instead. More info: https://esriurl.com/esri-leaflet-basemap"),this.options.token&&-1===s.urlTemplate.indexOf("token=")&&(s.urlTemplate+=`?token=${this.options.token}`),this.options.proxy&&(s.urlTemplate=`${this.options.proxy}?${s.urlTemplate}`),e.TileLayer.prototype.initialize.call(this,s.urlTemplate,r)},onAdd(t){q(t),"esri-labels"===this.options.pane&&this._initPane(),this.options.attributionUrl&&$((this.options.proxy?`${this.options.proxy}?`:"")+this.options.attributionUrl,t),t.on("moveend",N),e.TileLayer.prototype.onAdd.call(this,t)},onRemove(t){z(t),t.off("moveend",N),e.TileLayer.prototype.onRemove.call(this,t)},_initPane(){if(!this._map.getPane(this.options.pane)){const t=this._map.createPane(this.options.pane);t.style.pointerEvents="none",t.style.zIndex=500}},getAttribution(){let t;return this.options.attribution&&(t=`<span class="esri-dynamic-attribution">${this.options.attribution}</span>`),t}});const pt=e.TileLayer.extend({options:{zoomOffsetAllowance:.1,errorTileUrl:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAAEABAMAAACuXLVVAAAAA1BMVEUzNDVszlHHAAAAAXRSTlMAQObYZgAAAAlwSFlzAAAAAAAAAAAB6mUWpAAAADZJREFUeJztwQEBAAAAgiD/r25IQAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA7waBAAABw08RwAAAAABJRU5ErkJggg=="},statics:{MercatorZoomLevels:{0:156543.033928,1:78271.5169639999,2:39135.7584820001,3:19567.8792409999,4:9783.93962049996,5:4891.96981024998,6:2445.98490512499,7:1222.99245256249,8:611.49622628138,9:305.748113140558,10:152.874056570411,11:76.4370282850732,12:38.2185141425366,13:19.1092570712683,14:9.55462853563415,15:4.77731426794937,16:2.38865713397468,17:1.19432856685505,18:.597164283559817,19:.298582141647617,20:.14929107082381,21:.07464553541191,22:.0373227677059525,23:.0186613838529763}},initialize(t){(t=e.Util.setOptions(this,t)).apikey&&(t.token=t.apikey),t=U(t),this.tileUrl=`${(t.proxy?`${t.proxy}?`:"")+t.url}tile/{z}/{y}/{x}${t.requestParams&&Object.keys(t.requestParams).length>0?e.Util.getParamString(t.requestParams):""}`,-1!==t.url.indexOf("{s}")&&t.subdomains&&(t.url=t.url.replace("{s}",t.subdomains[0])),this.service=rt(t),this.service.addEventParent(this);new RegExp(/tiles.arcgis(online)?\.com/g).test(t.url)&&(this.tileUrl=this.tileUrl.replace("://tiles","://tiles{s}"),t.subdomains=["1","2","3","4"]),this.options.token&&(this.tileUrl+=`?token=${this.options.token}`),e.TileLayer.prototype.initialize.call(this,this.tileUrl,t)},getTileUrl(t){const i=this._getZoomForUrl();return e.Util.template(this.tileUrl,e.Util.extend({s:this._getSubdomain(t),x:t.x,y:t.y,z:this._lodMap&&void 0!==this._lodMap[i]?this._lodMap[i]:i},this.options))},createTile(t,i){const s=document.createElement("img");return e.DomEvent.on(s,"load",e.Util.bind(this._tileOnLoad,this,i,s)),e.DomEvent.on(s,"error",e.Util.bind(this._tileOnError,this,i,s)),this.options.crossOrigin&&(s.crossOrigin=""),s.alt="",!this._lodMap||this._lodMap&&void 0!==this._lodMap[this._getZoomForUrl()]?s.src=this.getTileUrl(t):this.once("lodmap",(function(){s.src=this.getTileUrl(t)}),this),s},onAdd(t){q(t),this._lodMap||this.metadata((function(i,s){if(!i&&s.spatialReference){const i=s.spatialReference.latestWkid||s.spatialReference.wkid;if(!this.options.attribution&&t.attributionControl&&s.copyrightText&&(this.options.attribution=s.copyrightText,t.attributionControl.addAttribution(this.getAttribution())),t.options.crs!==e.CRS.EPSG3857||102100!==i&&3857!==i)t.options.crs&&t.options.crs.code&&t.options.crs.code.indexOf(i)>-1||y("L.esri.TiledMapLayer is using a non-mercator spatial reference. Support may be available through Proj4Leaflet https://developers.arcgis.com/esri-leaflet/samples/non-mercator-projection/");else{this._lodMap={};const t=s.tileInfo.lods,e=pt.MercatorZoomLevels;for(let i=0;i<t.length;i++){const s=t[i];for(const t in e){const i=e[t];if(this._withinPercentage(s.resolution,i,this.options.zoomOffsetAllowance)){this._lodMap[t]=s.level;break}}}this.fire("lodmap")}}}),this),e.TileLayer.prototype.onAdd.call(this,t)},onRemove(t){z(t),e.TileLayer.prototype.onRemove.call(this,t)},metadata(t,e){return this.service.metadata(t,e),this},identify(){return this.service.identify()},find(){return this.service.find()},query(){return this.service.query()},authenticate(t){const e=`?token=${t}`;return this.tileUrl=this.options.token?this.tileUrl.replace(/\?token=(.+)/g,e):this.tileUrl+e,this.options.token=t,this.service.authenticate(t),this},_withinPercentage:(t,e,i)=>Math.abs(t/e-1)<i});const ct=e.ImageOverlay.extend({onAdd(t){this._topLeft=t.getPixelBounds().min,e.ImageOverlay.prototype.onAdd.call(this,t)},_reset(){this._map.options.crs===e.CRS.EPSG3857?e.ImageOverlay.prototype._reset.call(this):e.DomUtil.setPosition(this._image,this._topLeft.subtract(this._map.getPixelOrigin()))}}),dt=e.Layer.extend({options:{opacity:1,position:"front",f:"image",useCors:s,attribution:null,interactive:!1,alt:""},onAdd(t){q(t),this.options.zIndex&&(this.options.position=null),this._update=e.Util.throttle(this._update,this.options.updateInterval,this),t.on("moveend",this._update,this),this._currentImage&&this._currentImage._bounds.equals(this._map.getBounds())?t.addLayer(this._currentImage):this._currentImage&&(this._map.removeLayer(this._currentImage),this._currentImage=null),this._update(),this._popup&&(this._map.on("click",this._getPopupData,this),this._map.on("dblclick",this._resetPopupState,this)),this.metadata((function(e,i){!e&&!this.options.attribution&&t.attributionControl&&i.copyrightText&&(this.options.attribution=i.copyrightText,t.attributionControl.addAttribution(this.getAttribution()))}),this)},onRemove(t){z(t),this._currentImage&&this._map.removeLayer(this._currentImage),this._popup&&(this._map.off("click",this._getPopupData,this),this._map.off("dblclick",this._resetPopupState,this)),this._map.off("moveend",this._update,this)},bindPopup(t,i){return this._shouldRenderPopup=!1,this._lastClick=!1,this._popup=e.popup(i),this._popupFunction=t,this._map&&(this._map.on("click",this._getPopupData,this),this._map.on("dblclick",this._resetPopupState,this)),this},unbindPopup(){return this._map&&(this._map.closePopup(this._popup),this._map.off("click",this._getPopupData,this),this._map.off("dblclick",this._resetPopupState,this)),this._popup=!1,this},bringToFront(){return this.options.position="front",this._currentImage&&(this._currentImage.bringToFront(),this._setAutoZIndex(Math.max)),this},bringToBack(){return this.options.position="back",this._currentImage&&(this._currentImage.bringToBack(),this._setAutoZIndex(Math.min)),this},setZIndex(t){return this.options.zIndex=t,this._currentImage&&this._currentImage.setZIndex(t),this},_setAutoZIndex(t){if(!this._currentImage)return;const e=this._currentImage.getPane().children;let i=-t(-1/0,1/0);for(let s,r=0,o=e.length;r<o;r++)s=e[r].style.zIndex,e[r]!==this._currentImage._image&&s&&(i=t(i,+s));isFinite(i)&&(this.options.zIndex=i+t(-1,1),this.setZIndex(this.options.zIndex))},getAttribution(){return this.options.attribution},getOpacity(){return this.options.opacity},setOpacity(t){return this.options.opacity=t,this._currentImage&&this._currentImage.setOpacity(t),this},getTimeRange(){return[this.options.from,this.options.to]},setTimeRange(t,e){return this.options.from=t,this.options.to=e,this._update(),this},metadata(t,e){return this.service.metadata(t,e),this},authenticate(t){return this.service.authenticate(t),this},redraw(){this._update()},_renderImage(t,e,i){if(this._map){if(i&&(t=`data:${i};base64,${t}`),!t)return;const s=new ct(t,e,{opacity:0,crossOrigin:this.options.withCredentials?"use-credentials":this.options.useCors,alt:this.options.alt,pane:this.options.pane||this.getPane(),interactive:this.options.interactive}).addTo(this._map);let r;const o=function(){this._map.removeLayer(s),this.fire("error"),s.off("load",r,this)};r=function(t){if(s.off("error",o,this),this._map){const i=t.target,s=this._currentImage;i._bounds.equals(e)&&i._bounds.equals(this._map.getBounds())?(this._currentImage=i,"front"===this.options.position?this.bringToFront():"back"===this.options.position&&this.bringToBack(),this.options.zIndex&&this.setZIndex(this.options.zIndex),this._map&&this._currentImage._map?this._currentImage.setOpacity(this.options.opacity):this._currentImage._map.removeLayer(this._currentImage),s&&this._map&&this._map.removeLayer(s),s&&s._map&&s._map.removeLayer(s)):this._map.removeLayer(i)}this.fire("load",{bounds:e})},s.once("error",o,this),s.once("load",r,this)}},_update(){if(!this._map)return;const t=this._map.getZoom(),i=this._map.getBounds();if(this._animatingZoom)return;if(this._map._panTransition&&this._map._panTransition._inProgress)return;if(t>this.options.maxZoom||t<this.options.minZoom)return void(this._currentImage&&(this._currentImage._map.removeLayer(this._currentImage),this._currentImage=null));const s=this._buildExportParams();e.Util.extend(s,this.options.requestParams),s?(this._requestExport(s,i),this.fire("loading",{bounds:i})):this._currentImage&&(this._currentImage._map.removeLayer(this._currentImage),this._currentImage=null)},_renderPopup(t,i,s,r){if(t=e.latLng(t),this._shouldRenderPopup&&this._lastClick.equals(t)){const e=this._popupFunction(i,s,r);e&&this._popup.setLatLng(t).setContent(e).openOn(this._map)}},_resetPopupState(t){this._shouldRenderPopup=!1,this._lastClick=t.latlng},_calculateBbox(){const t=this._map.getPixelBounds(),i=this._map.unproject(t.getBottomLeft()),s=this._map.unproject(t.getTopRight()),r=this._map.options.crs.project(s),o=this._map.options.crs.project(i),n=e.bounds(r,o);return[n.getBottomLeft().x,n.getBottomLeft().y,n.getTopRight().x,n.getTopRight().y].join(",")},_calculateImageSize(){const t=this._map.getPixelBounds(),e=this._map.getSize(),i=this._map.unproject(t.getBottomLeft()),s=this._map.unproject(t.getTopRight()),r=this._map.latLngToLayerPoint(s).y,o=this._map.latLngToLayerPoint(i).y;return(r>0||o<e.y)&&(e.y=o-r),`${e.x},${e.y}`}}),mt=dt.extend({options:{updateInterval:150,format:"jpgpng",transparent:!0,f:"image"},query(){return this.service.query()},identify(){return this.service.identify()},initialize(t){t=U(t),this.service=nt(t),this.service.addEventParent(this),e.Util.setOptions(this,t)},setPixelType(t){return this.options.pixelType=t,this._update(),this},getPixelType(){return this.options.pixelType},setBandIds(t){return e.Util.isArray(t)?this.options.bandIds=t.join(","):this.options.bandIds=t.toString(),this._update(),this},getBandIds(){return this.options.bandIds},setNoData(t,i){return e.Util.isArray(t)?this.options.noData=t.join(","):this.options.noData=t.toString(),i&&(this.options.noDataInterpretation=i),this._update(),this},getNoData(){return this.options.noData},getNoDataInterpretation(){return this.options.noDataInterpretation},setRenderingRule(t){this.options.renderingRule=t,this._update()},getRenderingRule(){return this.options.renderingRule},setMosaicRule(t){this.options.mosaicRule=t,this._update()},getMosaicRule(){return this.options.mosaicRule},_getPopupData(t){const i=e.Util.bind((function(i,s,r){i||setTimeout(e.Util.bind((function(){this._renderPopup(t.latlng,i,s,r)}),this),300)}),this),s=this.identify().at(t.latlng);this.options.mosaicRule&&s.setMosaicRule(this.options.mosaicRule),s.run(i),this._shouldRenderPopup=!0,this._lastClick=t.latlng},_buildExportParams(){const t=parseInt(this._map.options.crs.code.split(":")[1],10),e={bbox:this._calculateBbox(),size:this._calculateImageSize(),format:this.options.format,transparent:this.options.transparent,bboxSR:t,imageSR:t};return this.options.from&&this.options.to&&(e.time=`${this.options.from.valueOf()},${this.options.to.valueOf()}`),this.options.pixelType&&(e.pixelType=this.options.pixelType),this.options.interpolation&&(e.interpolation=this.options.interpolation),this.options.compressionQuality&&(e.compressionQuality=this.options.compressionQuality),this.options.bandIds&&(e.bandIds=this.options.bandIds),(0===this.options.noData||this.options.noData)&&(e.noData=this.options.noData),this.options.noDataInterpretation&&(e.noDataInterpretation=this.options.noDataInterpretation),this.service.options.token&&(e.token=this.service.options.token),this.options.renderingRule&&(e.renderingRule=JSON.stringify(this.options.renderingRule)),this.options.mosaicRule&&(e.mosaicRule=JSON.stringify(this.options.mosaicRule)),e},_requestExport(t,i){if("json"===this.options.f)this.service.request("exportImage",t,(function(t,e){t||(this.options.token&&(e.href+=`?token=${this.options.token}`),this.options.proxy&&(e.href=`${this.options.proxy}?${e.href}`),this._renderImage(e.href,i))}),this);else{t.f="image";let s=`${this.options.url}exportImage${e.Util.getParamString(t)}`;this.options.proxy&&(s=`${this.options.proxy}?${s}`),this._renderImage(s,i)}}});const yt=dt.extend({options:{updateInterval:150,layers:!1,layerDefs:!1,timeOptions:!1,format:"png32",transparent:!0,f:"json"},initialize(t){t=U(t),this.service=rt(t),this.service.addEventParent(this),e.Util.setOptions(this,t)},getDynamicLayers(){return this.options.dynamicLayers},setDynamicLayers(t){return this.options.dynamicLayers=t,this._update(),this},getLayers(){return this.options.layers},setLayers(t){return this.options.layers=t,this._update(),this},getLayerDefs(){return this.options.layerDefs},setLayerDefs(t){return this.options.layerDefs=t,this._update(),this},getTimeOptions(){return this.options.timeOptions},setTimeOptions(t){return this.options.timeOptions=t,this._update(),this},query(){return this.service.query()},identify(){return this.service.identify()},find(){return this.service.find()},_getPopupData(t){const i=e.Util.bind((function(i,s,r){i||setTimeout(e.Util.bind((function(){this._renderPopup(t.latlng,i,s,r)}),this),300)}),this);let s;if(s=this.options.popup?this.options.popup.on(this._map).at(t.latlng):this.identify().on(this._map).at(t.latlng),s.params.maxAllowableOffset||s.simplify(this._map,.5),this.options.popup&&this.options.popup.params&&this.options.popup.params.layers||(this.options.layers?s.layers(`visible:${this.options.layers.join(",")}`):s.layers("visible")),this.options.layerDefs&&"string"!=typeof this.options.layerDefs&&!s.params.layerDefs)for(const t in this.options.layerDefs)Object.hasOwn(this.options.layerDefs,t)&&s.layerDef(t,this.options.layerDefs[t]);s.run(i),this._shouldRenderPopup=!0,this._lastClick=t.latlng},_buildExportParams(){const t=parseInt(this._map.options.crs.code.split(":")[1],10),e={bbox:this._calculateBbox(),size:this._calculateImageSize(),dpi:96,format:this.options.format,transparent:this.options.transparent,bboxSR:t,imageSR:t};if(this.options.dynamicLayers&&(e.dynamicLayers=this.options.dynamicLayers),this.options.layers){if(0===this.options.layers.length)return;e.layers=`show:${this.options.layers.join(",")}`}return this.options.layerDefs&&(e.layerDefs="string"==typeof this.options.layerDefs?this.options.layerDefs:JSON.stringify(this.options.layerDefs)),this.options.timeOptions&&(e.timeOptions=JSON.stringify(this.options.timeOptions)),this.options.from&&this.options.to&&(e.time=`${this.options.from.valueOf()},${this.options.to.valueOf()}`),this.service.options.token&&(e.token=this.service.options.token),this.options.proxy&&(e.proxy=this.options.proxy),this.options.disableCache&&(e._ts=Date.now()),e},_requestExport(t,i){if("json"===this.options.f)this.service.request("export",t,(function(t,e){t||(this.options.token&&e.href&&(e.href+=`?token=${this.options.token}`),this.options.proxy&&e.href&&(e.href=`${this.options.proxy}?${e.href}`),e.href?this._renderImage(e.href,i):this._renderImage(e.imageData,i,e.contentType))}),this);else{t.f="image";let s=`${this.options.url}export${e.Util.getParamString(t)}`;this.options.proxy&&(s=`${this.options.proxy}?${s}`),this._renderImage(s,i)}}});const ft=e.Layer.extend({options:{cellSize:512,updateWhenIdle:e.Browser.mobile,updateInterval:150,noWrap:!1,keepBuffer:1.5},initialize(t){e.Util.setOptions(this,t)},onAdd(){this._cells={},this._activeCells={},this._resetView(),this._update()},onRemove(){this._removeAllCells(),this._cellZoom=void 0},isLoading(){return this._loading},redraw(){return this._map&&(this._removeAllCells(),this._update()),this},getEvents(){const t={viewprereset:this._invalidateAll,viewreset:this._resetView,zoom:this._resetView,moveend:this._onMoveEnd};return this.options.updateWhenIdle||(this._onMove||(this._onMove=e.Util.throttle(this._onMoveEnd,this.options.updateInterval,this)),t.move=this._onMove),t},createCell:()=>document.createElement("div"),removeCell(){},reuseCell(){},cellLeave(){},cellEnter(){},getCellSize(){const t=this.options.cellSize;return t instanceof e.Point?t:new e.Point(t,t)},_pruneCells(){if(!this._map)return;let t,e;for(t in this._cells)e=this._cells[t],e.retain=e.current;for(t in this._cells)if(e=this._cells[t],e.current&&!e.active){const t=e.coords;this._retainParent(t.x,t.y,t.z,t.z-5)||this._retainChildren(t.x,t.y,t.z,t.z+2)}for(t in this._cells)this._cells[t].retain||this._removeCell(t)},_removeAllCells(){for(const t in this._cells)this._removeCell(t)},_invalidateAll(){this._removeAllCells(),this._cellZoom=void 0},_retainParent(t,i,s,r){const o=Math.floor(t/2),n=Math.floor(i/2),a=s-1,l=new e.Point(+o,+n);l.z=+a;const h=this._cellCoordsToKey(l),u=this._cells[h];return u&&u.active?(u.retain=!0,!0):(u&&u.loaded&&(u.retain=!0),a>r&&this._retainParent(o,n,a,r))},_retainChildren(t,i,s,r){for(let o=2*t;o<2*t+2;o++)for(let t=2*i;t<2*i+2;t++){const i=new e.Point(o,t);i.z=s+1;const n=this._cellCoordsToKey(i),a=this._cells[n];a&&a.active?a.retain=!0:(a&&a.loaded&&(a.retain=!0),s+1<r&&this._retainChildren(o,t,s+1,r))}},_resetView(t){const e=t&&(t.pinch||t.flyTo);e||this._setView(this._map.getCenter(),this._map.getZoom(),e,e)},_setView(t,e,i,s){const r=Math.round(e);s||(this._cellZoom=r,this._abortLoading&&this._abortLoading(),this._resetGrid(),void 0!==r&&this._update(t),i||this._pruneCells(),this._noPrune=!!i)},_resetGrid(){const t=this._map,e=t.options.crs,i=this._cellSize=this.getCellSize(),s=this._cellZoom,r=this._map.getPixelWorldBounds(this._cellZoom);r&&(this._globalCellRange=this._pxBoundsToCellRange(r)),this._wrapX=e.wrapLng&&!this.options.noWrap&&[Math.floor(t.project([0,e.wrapLng[0]],s).x/i.x),Math.ceil(t.project([0,e.wrapLng[1]],s).x/i.y)],this._wrapY=e.wrapLat&&!this.options.noWrap&&[Math.floor(t.project([e.wrapLat[0],0],s).y/i.x),Math.ceil(t.project([e.wrapLat[1],0],s).y/i.y)]},_onMoveEnd(t){t&&(t.pinch||t.flyTo)||!this._map||this._map._animatingZoom||this._update()},_getCelldPixelBounds(t){const i=this._map,s=i._animatingZoom?Math.max(i._animateToZoom,i.getZoom()):i.getZoom(),r=i.getZoomScale(s,this._cellZoom),o=i.project(t,this._cellZoom).floor(),n=i.getSize().divideBy(2*r);return new e.Bounds(o.subtract(n),o.add(n))},_update(t){const i=this._map;if(!i)return;const s=Math.round(i.getZoom());void 0===t&&(t=i.getCenter());const r=this._getCelldPixelBounds(t),o=this._pxBoundsToCellRange(r),n=o.getCenter(),a=[],l=this.options.keepBuffer,h=new e.Bounds(o.getBottomLeft().subtract([l,-l]),o.getTopRight().add([l,-l]));if(!(isFinite(o.min.x)&&isFinite(o.min.y)&&isFinite(o.max.x)&&isFinite(o.max.y)))throw new Error("Attempted to load an infinite number of cells");for(const t in this._cells){const i=this._cells[t].coords;i.z===this._cellZoom&&h.contains(new e.Point(i.x,i.y))||(this._cells[t].current=!1)}if(Math.abs(s-thi