Version 0.1.12 0.1.12
authorThierry Florac <thierry.florac@onf.fr>
Tue, 23 Oct 2018 12:23:07 +0200
changeset 63 77c839e343af
parent 62 2c4dc7ef5ccb
child 64 cb064f40c79d
Version 0.1.12
.installed.cfg
bootstrap.py
buildout.cfg
docs/HISTORY.txt
setup.py
src/pyams_gis.egg-info/PKG-INFO
src/pyams_gis/resources/js/leaflet-esri-2.0.8.min.js
--- a/.installed.cfg	Wed Oct 17 16:09:48 2018 +0200
+++ b/.installed.cfg	Tue Oct 23 12:23:07 2018 +0200
@@ -15,14 +15,14 @@
 
 [package]
 __buildout_installed__ = /home/tflorac/Dropbox/src/PyAMS/pyams_gis/bin/pcreate
-	/home/tflorac/Dropbox/src/PyAMS/pyams_gis/bin/prequest
+	/home/tflorac/Dropbox/src/PyAMS/pyams_gis/bin/pviews
+	/home/tflorac/Dropbox/src/PyAMS/pyams_gis/bin/pshell
+	/home/tflorac/Dropbox/src/PyAMS/pyams_gis/bin/proutes
 	/home/tflorac/Dropbox/src/PyAMS/pyams_gis/bin/pdistreport
 	/home/tflorac/Dropbox/src/PyAMS/pyams_gis/bin/pserve
-	/home/tflorac/Dropbox/src/PyAMS/pyams_gis/bin/pviews
-	/home/tflorac/Dropbox/src/PyAMS/pyams_gis/bin/proutes
-	/home/tflorac/Dropbox/src/PyAMS/pyams_gis/bin/pshell
+	/home/tflorac/Dropbox/src/PyAMS/pyams_gis/bin/prequest
 	/home/tflorac/Dropbox/src/PyAMS/pyams_gis/bin/ptweens
-__buildout_signature__ = zc.recipe.egg-8f8815b05e6871a2c4acf8d9c9b6e98f zc.buildout-2.10.0-py3.5.egg setuptools-8f8815b05e6871a2c4acf8d9c9b6e98f
+__buildout_signature__ = zc.recipe.egg-1cfa1feb0fa42aa4d8579505a97c12a0 zc.buildout-1cfa1feb0fa42aa4d8579505a97c12a0 setuptools-1cfa1feb0fa42aa4d8579505a97c12a0
 _b = /home/tflorac/Dropbox/src/PyAMS/pyams_gis/bin
 _d = /home/tflorac/Dropbox/src/PyAMS/pyams_gis/develop-eggs
 _e = /var/local/env/pyams/eggs
@@ -40,7 +40,7 @@
 __buildout_installed__ = /home/tflorac/Dropbox/src/PyAMS/pyams_gis/bin/pybabel
 	/home/tflorac/Dropbox/src/PyAMS/pyams_gis/bin/pot-create
 	/home/tflorac/Dropbox/src/PyAMS/pyams_gis/bin/polint
-__buildout_signature__ = zc.recipe.egg-8f8815b05e6871a2c4acf8d9c9b6e98f zc.buildout-2.10.0-py3.5.egg setuptools-8f8815b05e6871a2c4acf8d9c9b6e98f
+__buildout_signature__ = zc.recipe.egg-1cfa1feb0fa42aa4d8579505a97c12a0 zc.buildout-1cfa1feb0fa42aa4d8579505a97c12a0 setuptools-1cfa1feb0fa42aa4d8579505a97c12a0
 _b = /home/tflorac/Dropbox/src/PyAMS/pyams_gis/bin
 _d = /home/tflorac/Dropbox/src/PyAMS/pyams_gis/develop-eggs
 _e = /var/local/env/pyams/eggs
@@ -55,7 +55,7 @@
 [pyflakes]
 __buildout_installed__ = /home/tflorac/Dropbox/src/PyAMS/pyams_gis/bin/pyflakes
 	/home/tflorac/Dropbox/src/PyAMS/pyams_gis/bin/pyflakes
-__buildout_signature__ = zc.recipe.egg-8f8815b05e6871a2c4acf8d9c9b6e98f zc.buildout-2.10.0-py3.5.egg setuptools-8f8815b05e6871a2c4acf8d9c9b6e98f
+__buildout_signature__ = zc.recipe.egg-1cfa1feb0fa42aa4d8579505a97c12a0 zc.buildout-1cfa1feb0fa42aa4d8579505a97c12a0 setuptools-1cfa1feb0fa42aa4d8579505a97c12a0
 _b = /home/tflorac/Dropbox/src/PyAMS/pyams_gis/bin
 _d = /home/tflorac/Dropbox/src/PyAMS/pyams_gis/develop-eggs
 _e = /var/local/env/pyams/eggs
@@ -72,7 +72,7 @@
 [test]
 __buildout_installed__ = /home/tflorac/Dropbox/src/PyAMS/pyams_gis/parts/test
 	/home/tflorac/Dropbox/src/PyAMS/pyams_gis/bin/test
-__buildout_signature__ = six-8f8815b05e6871a2c4acf8d9c9b6e98f zc.recipe.testrunner-8f8815b05e6871a2c4acf8d9c9b6e98f zc.recipe.egg-8f8815b05e6871a2c4acf8d9c9b6e98f zc.buildout-2.10.0-py3.5.egg zope.exceptions-8f8815b05e6871a2c4acf8d9c9b6e98f zope.interface-8f8815b05e6871a2c4acf8d9c9b6e98f zope.testrunner-8f8815b05e6871a2c4acf8d9c9b6e98f setuptools-8f8815b05e6871a2c4acf8d9c9b6e98f
+__buildout_signature__ = six-1cfa1feb0fa42aa4d8579505a97c12a0 zc.recipe.testrunner-1cfa1feb0fa42aa4d8579505a97c12a0 zc.recipe.egg-1cfa1feb0fa42aa4d8579505a97c12a0 zc.buildout-1cfa1feb0fa42aa4d8579505a97c12a0 zope.exceptions-1cfa1feb0fa42aa4d8579505a97c12a0 zope.interface-1cfa1feb0fa42aa4d8579505a97c12a0 zope.testrunner-1cfa1feb0fa42aa4d8579505a97c12a0 setuptools-1cfa1feb0fa42aa4d8579505a97c12a0
 _b = /home/tflorac/Dropbox/src/PyAMS/pyams_gis/bin
 _d = /home/tflorac/Dropbox/src/PyAMS/pyams_gis/develop-eggs
 _e = /var/local/env/pyams/eggs
--- a/bootstrap.py	Wed Oct 17 16:09:48 2018 +0200
+++ b/bootstrap.py	Tue Oct 23 12:23:07 2018 +0200
@@ -25,7 +25,10 @@
 
 from optparse import OptionParser
 
-tmpeggs = tempfile.mkdtemp()
+__version__ = '2015-07-01'
+# See zc.buildout's changelog if this version is up to date.
+
+tmpeggs = tempfile.mkdtemp(prefix='bootstrap-')
 
 usage = '''\
 [DESIRED PYTHON FOR BUILDOUT] bootstrap.py [options]
@@ -35,18 +38,19 @@
 Simply run this script in a directory containing a buildout.cfg, using the
 Python that you want bin/buildout to use.
 
-Note that by using --find-links to point to local resources, you can keep 
+Note that by using --find-links to point to local resources, you can keep
 this script from going over the network.
 '''
 
 parser = OptionParser(usage=usage)
-parser.add_option("-v", "--version", help="use a specific zc.buildout version")
-
+parser.add_option("--version",
+                  action="store_true", default=False,
+                  help=("Return bootstrap.py version."))
 parser.add_option("-t", "--accept-buildout-test-releases",
                   dest='accept_buildout_test_releases',
                   action="store_true", default=False,
-                  help=("Normally, if you do not specify a --version, the "
-                        "bootstrap script and buildout gets the newest "
+                  help=("Normally, if you do not specify a --buildout-version, "
+                        "the bootstrap script and buildout gets the newest "
                         "*final* versions of zc.buildout and its recipes and "
                         "extensions for you.  If you use this flag, "
                         "bootstrap and buildout will get the newest releases "
@@ -59,36 +63,57 @@
 parser.add_option("--allow-site-packages",
                   action="store_true", default=False,
                   help=("Let bootstrap.py use existing site packages"))
-
+parser.add_option("--buildout-version",
+                  help="Use a specific zc.buildout version")
+parser.add_option("--setuptools-version",
+                  help="Use a specific setuptools version")
+parser.add_option("--setuptools-to-dir",
+                  help=("Allow for re-use of existing directory of "
+                        "setuptools versions"))
 
 options, args = parser.parse_args()
+if options.version:
+    print("bootstrap.py version %s" % __version__)
+    sys.exit(0)
+
 
 ######################################################################
 # load/install setuptools
 
 try:
-    if options.allow_site_packages:
-        import setuptools
-        import pkg_resources
     from urllib.request import urlopen
 except ImportError:
     from urllib2 import urlopen
 
 ez = {}
-exec(urlopen('https://bootstrap.pypa.io/ez_setup.py').read(), ez)
+if os.path.exists('ez_setup.py'):
+    exec(open('ez_setup.py').read(), ez)
+else:
+    exec(urlopen('https://bootstrap.pypa.io/ez_setup.py').read(), ez)
 
 if not options.allow_site_packages:
     # ez_setup imports site, which adds site packages
-    # this will remove them from the path to ensure that incompatible versions 
+    # this will remove them from the path to ensure that incompatible versions
     # of setuptools are not in the path
     import site
-    # inside a virtualenv, there is no 'getsitepackages'. 
+    # inside a virtualenv, there is no 'getsitepackages'.
     # We can't remove these reliably
     if hasattr(site, 'getsitepackages'):
         for sitepackage_path in site.getsitepackages():
-            sys.path[:] = [x for x in sys.path if sitepackage_path not in x]
+            # Strip all site-packages directories from sys.path that
+            # are not sys.prefix; this is because on Windows
+            # sys.prefix is a site-package directory.
+            if sitepackage_path != sys.prefix:
+                sys.path[:] = [x for x in sys.path
+                               if sitepackage_path not in x]
 
 setup_args = dict(to_dir=tmpeggs, download_delay=0)
+
+if options.setuptools_version is not None:
+    setup_args['version'] = options.setuptools_version
+if options.setuptools_to_dir is not None:
+    setup_args['to_dir'] = options.setuptools_to_dir
+
 ez['use_setuptools'](**setup_args)
 import setuptools
 import pkg_resources
@@ -104,7 +129,12 @@
 
 ws = pkg_resources.working_set
 
+setuptools_path = ws.find(
+    pkg_resources.Requirement.parse('setuptools')).location
+
+# Fix sys.path here as easy_install.pth added before PYTHONPATH
 cmd = [sys.executable, '-c',
+       'import sys; sys.path[0:0] = [%r]; ' % setuptools_path +
        'from setuptools.command.easy_install import main; main()',
        '-mZqNxd', tmpeggs]
 
@@ -117,21 +147,23 @@
 if find_links:
     cmd.extend(['-f', find_links])
 
-setuptools_path = ws.find(
-    pkg_resources.Requirement.parse('setuptools')).location
-
 requirement = 'zc.buildout'
-version = options.version
+version = options.buildout_version
 if version is None and not options.accept_buildout_test_releases:
     # Figure out the most recent final version of zc.buildout.
     import setuptools.package_index
     _final_parts = '*final-', '*final'
 
     def _final_version(parsed_version):
-        for part in parsed_version:
-            if (part[:1] == '*') and (part not in _final_parts):
-                return False
-        return True
+        try:
+            return not parsed_version.is_prerelease
+        except AttributeError:
+            # Older setuptools
+            for part in parsed_version:
+                if (part[:1] == '*') and (part not in _final_parts):
+                    return False
+            return True
+
     index = setuptools.package_index.PackageIndex(
         search_path=[setuptools_path])
     if find_links:
@@ -156,7 +188,7 @@
 cmd.append(requirement)
 
 import subprocess
-if subprocess.call(cmd, env=dict(os.environ, PYTHONPATH=setuptools_path)) != 0:
+if subprocess.call(cmd) != 0:
     raise Exception(
         "Failed to execute command:\n%s" % repr(cmd)[1:-1])
 
--- a/buildout.cfg	Wed Oct 17 16:09:48 2018 +0200
+++ b/buildout.cfg	Tue Oct 23 12:23:07 2018 +0200
@@ -70,5 +70,5 @@
 eggs = pyams_gis [test]
 
 [versions]
-pyams_gis = 0.1.11
+pyams_gis = 0.1.12
 GDAL = 2.1.0
--- a/docs/HISTORY.txt	Wed Oct 17 16:09:48 2018 +0200
+++ b/docs/HISTORY.txt	Tue Oct 23 12:23:07 2018 +0200
@@ -1,6 +1,10 @@
 History
 =======
 
+0.1.12
+------
+ - updated internal objects forms templates
+
 0.1.11
 ------
  - updated widgets templates
--- a/setup.py	Wed Oct 17 16:09:48 2018 +0200
+++ b/setup.py	Tue Oct 23 12:23:07 2018 +0200
@@ -22,7 +22,7 @@
 README = os.path.join(DOCS, 'README.txt')
 HISTORY = os.path.join(DOCS, 'HISTORY.txt')
 
-version = '0.1.11'
+version = '0.1.12'
 long_description = open(README).read() + '\n\n' + open(HISTORY).read()
 
 tests_require = []
--- a/src/pyams_gis.egg-info/PKG-INFO	Wed Oct 17 16:09:48 2018 +0200
+++ b/src/pyams_gis.egg-info/PKG-INFO	Tue Oct 23 12:23:07 2018 +0200
@@ -1,12 +1,11 @@
-Metadata-Version: 1.1
+Metadata-Version: 2.1
 Name: pyams-gis
-Version: 0.1.11
+Version: 0.1.12
 Summary: PyAMS GIS helpers interfaces and classes
 Home-page: http://hg.ztfy.org/pyams/pyams_gis
 Author: Thierry Florac
 Author-email: tflorac@ulthar.net
 License: ZPL
-Description-Content-Type: UNKNOWN
 Description: 
         sudo apt-get install libgdal-dev
         
@@ -18,6 +17,10 @@
         History
         =======
         
+        0.1.12
+        ------
+         - updated internal objects forms templates
+        
         0.1.11
         ------
          - updated widgets templates
@@ -83,3 +86,4 @@
 Classifier: Programming Language :: Python
 Classifier: Framework :: Pyramid
 Classifier: Topic :: Software Development :: Libraries :: Python Modules
+Provides-Extra: test
--- a/src/pyams_gis/resources/js/leaflet-esri-2.0.8.min.js	Wed Oct 17 16:09:48 2018 +0200
+++ b/src/pyams_gis/resources/js/leaflet-esri-2.0.8.min.js	Tue Oct 23 12:23:07 2018 +0200
@@ -1,1 +1,1 @@
-(function(b,a){typeof exports==="object"&&typeof module!=="undefined"?a(exports,require("leaflet")):typeof define==="function"&&define.amd?define(["exports","leaflet"],a):(a((b.L=b.L||{},b.L.esri=b.L.esri||{}),b.L))}(this,function(O,S){var Y="default" in S?S["default"]:S;var s="2.0.8";var aJ=((window.XMLHttpRequest&&"withCredentials" in new window.XMLHttpRequest()));var a=document.documentElement.style.pointerEvents==="";var ag={cors:aJ,pointerEvents:a};var W={attributionWidthOffset:55};var o=0;function c(aP){var aN="";aP.f=aP.f||"json";for(var aK in aP){if(aP.hasOwnProperty(aK)){var aO=aP[aK];var aL=Object.prototype.toString.call(aO);var aM;if(aN.length){aN+="&"}if(aL==="[object Array]"){aM=(Object.prototype.toString.call(aO[0])==="[object Object]")?JSON.stringify(aO):aO.join(",")}else{if(aL==="[object Object]"){aM=JSON.stringify(aO)}else{if(aL==="[object Date]"){aM=aO.valueOf()}else{aM=aO}}}aN+=encodeURIComponent(aK)+"="+encodeURIComponent(aM)}}return aN}function y(aM,aL){var aK=new window.XMLHttpRequest();aK.onerror=function(aN){aK.onreadystatechange=S.Util.falseFn;aM.call(aL,{error:{code:500,message:"XMLHttpRequest error"}},null)};aK.onreadystatechange=function(){var aN;var aO;if(aK.readyState===4){try{aN=JSON.parse(aK.responseText)}catch(aP){aN=null;aO={code:500,message:"Could not parse response as JSON. This could also be caused by a CORS or XMLHttpRequest error."}}if(!aO&&aN.error){aO=aN.error;aN=null}aK.onerror=S.Util.falseFn;aM.call(aL,aO,aN)}};aK.ontimeout=function(){this.onerror()};return aK}function aA(aL,aN,aO,aM){var aK=y(aO,aM);aK.open("POST",aL);if(typeof aM!=="undefined"&&aM!==null){if(typeof aM.options!=="undefined"){aK.timeout=aM.options.timeout}}aK.setRequestHeader("Content-Type","application/x-www-form-urlencoded");aK.send(c(aN));return aK}function b(aL,aN,aO,aM){var aK=y(aO,aM);aK.open("GET",aL+"?"+c(aN),true);if(typeof aM!=="undefined"&&aM!==null){if(typeof aM.options!=="undefined"){aK.timeout=aM.options.timeout}}aK.send(null);return aK}function ah(aL,aP,aQ,aN){var aO=c(aP);var aK=y(aQ,aN);var aM=(aL+"?"+aO).length;if(aM<=2000&&ag.cors){aK.open("GET",aL+"?"+aO)}else{if(aM>2000&&ag.cors){aK.open("POST",aL);aK.setRequestHeader("Content-Type","application/x-www-form-urlencoded")}}if(typeof aN!=="undefined"&&aN!==null){if(typeof aN.options!=="undefined"){aK.timeout=aN.options.timeout}}if(aM<=2000&&ag.cors){aK.send(null)}else{if(aM>2000&&ag.cors){aK.send(aO)}else{if(aM<=2000&&!ag.cors){return g(aL,aP,aQ,aN)}else{aF("a request to "+aL+" was longer then 2000 characters and this browser cannot make a cross-domain post request. Please use a proxy http://esri.github.io/esri-leaflet/api-reference/request.html");return}}}return aK}function g(aL,aO,aP,aM){window._EsriLeafletCallbacks=window._EsriLeafletCallbacks||{};var aN="c"+o;aO.callback="window._EsriLeafletCallbacks."+aN;window._EsriLeafletCallbacks[aN]=function(aQ){if(window._EsriLeafletCallbacks[aN]!==true){var aS;var aR=Object.prototype.toString.call(aQ);if(!(aR==="[object Object]"||aR==="[object Array]")){aS={error:{code:500,message:"Expected array or object as JSONP response"}};aQ=null}if(!aS&&aQ.error){aS=aQ;aQ=null}aP.call(aM,aS,aQ);window._EsriLeafletCallbacks[aN]=true}};var aK=S.DomUtil.create("script",null,document.body);aK.type="text/javascript";aK.src=aL+"?"+c(aO);aK.id=aN;o++;return{id:aN,url:aK.src,abort:function(){window._EsriLeafletCallbacks._callback[aN]({code:0,message:"Request aborted."})}}}var al=((ag.cors)?b:g);al.CORS=b;al.JSONP=g;var G={request:ah,get:al,post:aA};function af(aL,aK){for(var aM=0;aM<aL.length;aM++){if(aL[aM]!==aK[aM]){return false}}return true}function D(aK){if(!af(aK[0],aK[aK.length-1])){aK.push(aK[0])}return aK}function t(aL){var aM=0;var aK=0;var aO=aL.length;var aP=aL[aK];var aN;for(aK;aK<aO-1;aK++){aN=aL[aK+1];aM+=(aN[0]-aP[0])*(aN[1]+aP[1]);aP=aN}return(aM>=0)}function u(aO,aN,aS,aR){var aL=(aR[0]-aS[0])*(aO[1]-aS[1])-(aR[1]-aS[1])*(aO[0]-aS[0]);var aQ=(aN[0]-aO[0])*(aO[1]-aS[1])-(aN[1]-aO[1])*(aO[0]-aS[0]);var aP=(aR[1]-aS[1])*(aN[0]-aO[0])-(aR[0]-aS[0])*(aN[1]-aO[1]);if(aP!==0){var aM=aL/aP;var aK=aQ/aP;if(aM>=0&&aM<=1&&aK>=0&&aK<=1){return true}}return false}function h(aL,aK){for(var aN=0;aN<aL.length-1;aN++){for(var aM=0;aM<aK.length-1;aM++){if(u(aL[aN],aL[aN+1],aK[aM],aK[aM+1])){return true}}}return false}function aE(aP,aK){var aO=false;for(var aN=-1,aL=aP.length,aM=aL-1;++aN<aL;aM=aN){if(((aP[aN][1]<=aK[1]&&aK[1]<aP[aM][1])||(aP[aM][1]<=aK[1]&&aK[1]<aP[aN][1]))&&(aK[0]<(aP[aM][0]-aP[aN][0])*(aK[1]-aP[aN][1])/(aP[aM][1]-aP[aN][1])+aP[aN][0])){aO=!aO}}return aO}function an(aM,aK){var aN=h(aM,aK);var aL=aE(aM,aK[0]);if(!aN&&aL){return true}return false}function k(aT){var aQ=[];var aN=[];var aU;var aP;var aK;for(var aL=0;aL<aT.length;aL++){var aM=D(aT[aL].slice(0));if(aM.length<4){continue}if(t(aM)){var aS=[aM];aQ.push(aS)}else{aN.push(aM)}}var aV=[];while(aN.length){aK=aN.pop();var aR=false;for(aU=aQ.length-1;aU>=0;aU--){aP=aQ[aU][0];if(an(aP,aK)){aQ[aU].push(aK);aR=true;break}}if(!aR){aV.push(aK)}}while(aV.length){aK=aV.pop();var aO=false;for(aU=aQ.length-1;aU>=0;aU--){aP=aQ[aU][0];if(h(aP,aK)){aQ[aU].push(aK);aO=true;break}}if(!aO){aQ.push([aK.reverse()])}}if(aQ.length===1){return{type:"Polygon",coordinates:aQ[0]}}else{return{type:"MultiPolygon",coordinates:aQ}}}function I(aP){var aL=[];var aN=aP.slice(0);var aK=D(aN.shift().slice(0));if(aK.length>=4){if(!t(aK)){aK.reverse()}aL.push(aK);for(var aM=0;aM<aN.length;aM++){var aO=D(aN[aM].slice(0));if(aO.length>=4){if(t(aO)){aO.reverse()}aL.push(aO)}}}return aL}function p(aP){var aL=[];for(var aO=0;aO<aP.length;aO++){var aN=I(aP[aO]);for(var aK=aN.length-1;aK>=0;aK--){var aM=aN[aK].slice(0);aL.push(aM)}}return aL}function ak(aM){var aL={};for(var aK in aM){if(aM.hasOwnProperty(aK)){aL[aK]=aM[aK]}}return aL}function e(aM,aL){var aK={};if(typeof aM.x==="number"&&typeof aM.y==="number"){aK.type="Point";aK.coordinates=[aM.x,aM.y]}if(aM.points){aK.type="MultiPoint";aK.coordinates=aM.points.slice(0)}if(aM.paths){if(aM.paths.length===1){aK.type="LineString";aK.coordinates=aM.paths[0].slice(0)}else{aK.type="MultiLineString";aK.coordinates=aM.paths.slice(0)}}if(aM.rings){aK=k(aM.rings.slice(0))}if(aM.geometry||aM.attributes){aK.type="Feature";aK.geometry=(aM.geometry)?e(aM.geometry):null;aK.properties=(aM.attributes)?ak(aM.attributes):null;if(aM.attributes){aK.id=aM.attributes[aL]||aM.attributes.OBJECTID||aM.attributes.FID}}return aK}function v(aL,aO){aO=aO||"OBJECTID";var aN={wkid:4326};var aK={};var aM;switch(aL.type){case"Point":aK.x=aL.coordinates[0];aK.y=aL.coordinates[1];aK.spatialReference=aN;break;case"MultiPoint":aK.points=aL.coordinates.slice(0);aK.spatialReference=aN;break;case"LineString":aK.paths=[aL.coordinates.slice(0)];aK.spatialReference=aN;break;case"MultiLineString":aK.paths=aL.coordinates.slice(0);aK.spatialReference=aN;break;case"Polygon":aK.rings=I(aL.coordinates.slice(0));aK.spatialReference=aN;break;case"MultiPolygon":aK.rings=p(aL.coordinates.slice(0));aK.spatialReference=aN;break;case"Feature":if(aL.geometry){aK.geometry=v(aL.geometry,aO)}aK.attributes=(aL.properties)?ak(aL.properties):{};if(aL.id){aK.attributes[aO]=aL.id}break;case"FeatureCollection":aK=[];for(aM=0;aM<aL.features.length;aM++){aK.push(v(aL.features[aM],aO))}break;case"GeometryCollection":aK=[];for(aM=0;aM<aL.geometries.length;aM++){aK.push(v(aL.geometries[aM],aO))}break}return aK}function ap(aK,aL){return v(aK,aL)}function ac(aK,aL){return e(aK,aL)}function aD(aM){var aL={};for(var aK in aM){if(aM.hasOwnProperty(aK)){aL[aK]=aM[aK]}}return aL}function Q(aL){if(aL.xmin!=="NaN"&&aL.ymin!=="NaN"&&aL.xmax!=="NaN"&&aL.ymax!=="NaN"){var aK=S.latLng(aL.ymin,aL.xmin);var aM=S.latLng(aL.ymax,aL.xmax);return S.latLngBounds(aK,aM)}else{return null}}function aj(aK){aK=S.latLngBounds(aK);return{xmin:aK.getSouthWest().lng,ymin:aK.getSouthWest().lat,xmax:aK.getNorthEast().lng,ymax:aK.getNorthEast().lat,spatialReference:{wkid:4326}}}function r(aM,aR){var aQ;var aL=aM.features||aM.results;var aP=aL.length;if(aR){aQ=aR}else{if(aM.objectIdFieldName){aQ=aM.objectIdFieldName}else{if(aM.fields){for(var aN=0;aN<=aM.fields.length-1;aN++){if(aM.fields[aN].type==="esriFieldTypeOID"){aQ=aM.fields[aN].name;break}}}else{if(aP){for(var aS in aL[0].attributes){if(aS.match(/^(OBJECTID|FID|OID|ID)$/i)){aQ=aS;break}}}}}}var aK={type:"FeatureCollection",features:[]};if(aP){for(var aO=aL.length-1;aO>=0;aO--){var aT=ac(aL[aO],aQ);aK.features.push(aT)}}return aK}function T(aK){aK=S.Util.trim(aK);if(aK[aK.length-1]!=="/"){aK+="/"}return aK}function z(aK){return(/^(?!.*utility\.arcgis\.com).*\.arcgis\.com.*FeatureServer/i).test(aK)}function aI(aK){var aL;switch(aK){case"Point":aL="esriGeometryPoint";break;case"MultiPoint":aL="esriGeometryMultipoint";break;case"LineString":aL="esriGeometryPolyline";break;case"MultiLineString":aL="esriGeometryPolyline";break;case"Polygon":aL="esriGeometryPolygon";break;case"MultiPolygon":aL="esriGeometryPolygon";break}return aL}function aF(){if(console&&console.warn){console.warn.apply(console,arguments)}}function C(aK){return(aK.getSize().x-W.attributionWidthOffset)+"px"}function ay(aM){if(aM.attributionControl&&!aM.attributionControl._esriAttributionAdded){aM.attributionControl.setPrefix('<a href="http://leafletjs.com" title="A JS library for interactive maps">Leaflet</a> | Powered by <a href="https://www.esri.com">Esri</a>');var aL=document.createElement("style");aL.type="text/css";aL.innerHTML=".esri-truncated-attribution:hover {white-space: normal;}";document.getElementsByTagName("head")[0].appendChild(aL);S.DomUtil.addClass(aM.attributionControl._container,"esri-truncated-attribution:hover");var aK=document.createElement("style");aK.type="text/css";aK.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: "+C(aM)+";}";document.getElementsByTagName("head")[0].appendChild(aK);S.DomUtil.addClass(aM.attributionControl._container,"esri-truncated-attribution");aM.on("resize",function(aN){aM.attributionControl._container.style.maxWidth=C(aN.target)});aM.attributionControl._esriAttributionAdded=true}}function V(aK,aL){g(aK,{},S.Util.bind(function(aU,aM){if(aU){return}aL._esriAttributions=[];for(var aT=0;aT<aM.contributors.length;aT++){var aP=aM.contributors[aT];for(var aS=0;aS<aP.coverageAreas.length;aS++){var aQ=aP.coverageAreas[aS];var aN=S.latLng(aQ.bbox[0],aQ.bbox[1]);var aO=S.latLng(aQ.bbox[2],aQ.bbox[3]);aL._esriAttributions.push({attribution:aP.attribution,score:aQ.score,bounds:S.latLngBounds(aN,aO),minZoom:aQ.zoomMin,maxZoom:aQ.zoomMax})}}aL._esriAttributions.sort(function(aW,aV){return aV.score-aW.score});var aR={target:aL};aB(aR)},this))}function aB(aQ){var aM=aQ.target;var aP=aM._esriAttributions;if(aM&&aM.attributionControl&&aP){var aO="";var aL=aM.getBounds();var aK=S.latLngBounds(aL.getSouthWest().wrap(),aL.getNorthEast().wrap());var aU=aM.getZoom();for(var aN=0;aN<aP.length;aN++){var aS=aP[aN];var aR=aS.attribution;if(!aO.match(aR)&&aS.bounds.intersects(aK)&&aU>=aS.minZoom&&aU<=aS.maxZoom){aO+=(", "+aR)}}aO=aO.substr(2);var aT=aM.attributionControl._container.querySelector(".esri-dynamic-attribution");aT.innerHTML=aO;aT.style.maxWidth=C(aM);aM.fire("attributionupdated",{attribution:aO})}}var X={shallowClone:aD,warn:aF,cleanUrl:T,isArcgisOnline:z,geojsonTypeToArcGIS:aI,responseToFeatureCollection:r,geojsonToArcGIS:ap,arcgisToGeoJSON:ac,boundsToExtent:aj,extentToBounds:Q,calcAttributionWidth:C,setEsriAttribution:ay,_getAttributionData:V,_updateMapAttribution:aB};var aC=S.Class.extend({options:{proxy:false,useCors:aJ},generateSetter:function(aL,aK){return S.Util.bind(function(aM){this.params[aL]=aM;return this},aK)},initialize:function(aL){if(aL.request&&aL.options){this._service=aL;S.Util.setOptions(this,aL.options)}else{S.Util.setOptions(this,aL);this.options.url=T(aL.url)}this.params=S.Util.extend({},this.params||{});if(this.setters){for(var aM in this.setters){var aK=this.setters[aM];this[aM]=this.generateSetter(aK,this)}}},token:function(aK){if(this._service){this._service.authenticate(aK)}else{this.params.token=aK}return this},request:function(aL,aK){if(this._service){return this._service.request(this.path,this.params,aL,aK)}return this._request("request",this.path,this.params,aL,aK)},_request:function(aP,aM,aN,aO,aL){var aK=(this.options.proxy)?this.options.proxy+"?"+this.options.url+aM:this.options.url+aM;if((aP==="get"||aP==="request")&&!this.options.useCors){return G.get.JSONP(aK,aN,aO,aL)}return G[aP](aK,aN,aO,aL)}});function am(aK){return new aC(aK)}var R=aC.extend({setters:{offset:"resultOffset",limit:"resultRecordCount",fields:"outFields",precision:"geometryPrecision",featureIds:"objectIds",returnGeometry:"returnGeometry",token:"token"},path:"query",params:{returnGeometry:true,where:"1=1",outSr:4326,outFields:"*"},within:function(aK){this._setGeometry(aK);this.params.spatialRel="esriSpatialRelContains";return this},intersects:function(aK){this._setGeometry(aK);this.params.spatialRel="esriSpatialRelIntersects";return this},contains:function(aK){this._setGeometry(aK);this.params.spatialRel="esriSpatialRelWithin";return this},crosses:function(aK){this._setGeometry(aK);this.params.spatialRel="esriSpatialRelCrosses";return this},touches:function(aK){this._setGeometry(aK);this.params.spatialRel="esriSpatialRelTouches";return this},overlaps:function(aK){this._setGeometry(aK);this.params.spatialRel="esriSpatialRelOverlaps";return this},bboxIntersects:function(aK){this._setGeometry(aK);this.params.spatialRel="esriSpatialRelEnvelopeIntersects";return this},indexIntersects:function(aK){this._setGeometry(aK);this.params.spatialRel="esriSpatialRelIndexIntersects";return this},nearby:function(aL,aK){aL=S.latLng(aL);this.params.geometry=[aL.lng,aL.lat];this.params.geometryType="esriGeometryPoint";this.params.spatialRel="esriSpatialRelIntersects";this.params.units="esriSRUnit_Meter";this.params.distance=aK;this.params.inSr=4326;return this},where:function(aK){this.params.where=aK;return this},between:function(aL,aK){this.params.time=[aL.valueOf(),aK.valueOf()];return this},simplify:function(aM,aL){var aK=Math.abs(aM.getBounds().getWest()-aM.getBounds().getEast());this.params.maxAllowableOffset=(aK/aM.getSize().y)*aL;return this},orderBy:function(aL,aK){aK=aK||"ASC";this.params.orderByFields=(this.params.orderByFields)?this.params.orderByFields+",":"";this.params.orderByFields+=([aL,aK]).join(" ");return this},run:function(aL,aK){this._cleanParams();if(this.options.isModern||z(this.options.url)){this.params.f="geojson";return this.request(function(aN,aM){this._trapSQLerrors(aN);aL.call(aK,aN,aM,aM)},this)}else{return this.request(function(aN,aM){this._trapSQLerrors(aN);aL.call(aK,aN,(aM&&r(aM)),aM)},this)}},count:function(aL,aK){this._cleanParams();this.params.returnCountOnly=true;return this.request(function(aN,aM){aL.call(this,aN,(aM&&aM.count),aM)},aK)},ids:function(aL,aK){this._cleanParams();this.params.returnIdsOnly=true;return this.request(function(aN,aM){aL.call(this,aN,(aM&&aM.objectIds),aM)},aK)},bounds:function(aL,aK){this._cleanParams();this.params.returnExtentOnly=true;return this.request(function(aN,aM){if(aM&&aM.extent&&Q(aM.extent)){aL.call(aK,aN,Q(aM.extent),aM)}else{aN={message:"Invalid Bounds"};aL.call(aK,aN,null,aM)}},aK)},pixelSize:function(aK){var aL=S.point(aK);this.params.pixelSize=[aL.x,aL.y];return this},layer:function(aK){this.path=aK+"/query";return this},_trapSQLerrors:function(aK){if(aK){if(aK.code==="400"){aF("one common syntax error in query requests is encasing string values in double quotes instead of single quotes")}}},_cleanParams:function(){delete this.params.returnIdsOnly;delete this.params.returnExtentOnly;delete this.params.returnCountOnly},_setGeometry:function(aK){this.params.inSr=4326;if(aK instanceof S.LatLngBounds){this.params.geometry=aj(aK);this.params.geometryType="esriGeometryEnvelope";return}if(aK.getLatLng){aK=aK.getLatLng()}if(aK instanceof S.LatLng){aK={type:"Point",coordinates:[aK.lng,aK.lat]}}if(aK instanceof S.GeoJSON){aK=aK.getLayers()[0].feature.geometry;this.params.geometry=ap(aK);this.params.geometryType=aI(aK.type)}if(aK.toGeoJSON){aK=aK.toGeoJSON()}if(aK.type==="Feature"){aK=aK.geometry}if(aK.type==="Point"||aK.type==="LineString"||aK.type==="Polygon"||aK.type==="MultiPolygon"){this.params.geometry=ap(aK);this.params.geometryType=aI(aK.type);return}aF("invalid geometry passed to spatial query. Should be L.LatLng, L.LatLngBounds, L.Marker or a GeoJSON Point, Line, Polygon or MultiPolygon object");return}});function K(aK){return new R(aK)}var l=aC.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:true,returnGeometry:true,returnZ:true,returnM:false},layerDefs:function(aL,aK){this.params.layerDefs=(this.params.layerDefs)?this.params.layerDefs+";":"";this.params.layerDefs+=([aL,aK]).join(":");return this},simplify:function(aM,aL){var aK=Math.abs(aM.getBounds().getWest()-aM.getBounds().getEast());this.params.maxAllowableOffset=(aK/aM.getSize().y)*aL;return this},run:function(aL,aK){return this.request(function(aN,aM){aL.call(aK,aN,(aM&&r(aM)),aM)},aK)}});function aH(aK){return new l(aK)}var ax=aC.extend({path:"identify",between:function(aL,aK){this.params.time=[aL.valueOf(),aK.valueOf()];return this}});function ao(aK){return new ax(aK)}var au=ax.extend({setters:{layers:"layers",precision:"geometryPrecision",tolerance:"tolerance",returnGeometry:"returnGeometry"},params:{sr:4326,layers:"all",tolerance:3,returnGeometry:true},on:function(aM){var aL=aj(aM.getBounds());var aK=aM.getSize();this.params.imageDisplay=[aK.x,aK.y,96];this.params.mapExtent=[aL.xmin,aL.ymin,aL.xmax,aL.ymax];return this},at:function(aK){aK=S.latLng(aK);this.params.geometry=[aK.lng,aK.lat];this.params.geometryType="esriGeometryPoint";return this},layerDef:function(aL,aK){this.params.layerDefs=(this.params.layerDefs)?this.params.layerDefs+";":"";this.params.layerDefs+=([aL,aK]).join(":");return this},simplify:function(aM,aL){var aK=Math.abs(aM.getBounds().getWest()-aM.getBounds().getEast());this.params.maxAllowableOffset=(aK/aM.getSize().y)*aL;return this},run:function(aL,aK){return this.request(function(aN,aM){if(aN){aL.call(aK,aN,undefined,aM);return}else{var aQ=r(aM);aM.results=aM.results.reverse();for(var aP=0;aP<aQ.features.length;aP++){var aO=aQ.features[aP];aO.layerId=aM.results[aP].layerId}aL.call(aK,undefined,aQ,aM)}})}});function N(aK){return new au(aK)}var d=ax.extend({setters:{setMosaicRule:"mosaicRule",setRenderingRule:"renderingRule",setPixelSize:"pixelSize",returnCatalogItems:"returnCatalogItems",returnGeometry:"returnGeometry"},params:{returnGeometry:false},at:function(aK){aK=S.latLng(aK);this.params.geometry=JSON.stringify({x:aK.lng,y:aK.lat,spatialReference:{wkid:4326}});this.params.geometryType="esriGeometryPoint";return this},getMosaicRule:function(){return this.params.mosaicRule},getRenderingRule:function(){return this.params.renderingRule},getPixelSize:function(){return this.params.pixelSize},run:function(aL,aK){return this.request(function(aN,aM){aL.call(aK,aN,(aM&&this._responseToGeoJSON(aM)),aM)},this)},_responseToGeoJSON:function(aL){var aK=aL.location;var aN=aL.catalogItems;var aO=aL.catalogItemVisibilities;var aP={pixel:{type:"Feature",geometry:{type:"Point",coordinates:[aK.x,aK.y]},crs:{type:"EPSG",properties:{code:aK.spatialReference.wkid}},properties:{OBJECTID:aL.objectId,name:aL.name,value:aL.value},id:aL.objectId}};if(aL.properties&&aL.properties.Values){aP.pixel.properties.values=aL.properties.Values}if(aN&&aN.features){aP.catalogItems=r(aN);if(aO&&aO.length===aP.catalogItems.features.length){for(var aM=aO.length-1;aM>=0;aM--){aP.catalogItems.features[aM].properties.catalogItemVisibility=aO[aM]}}}return aP}});function n(aK){return new d(aK)}var ae=S.Evented.extend({options:{proxy:false,useCors:aJ,timeout:0},initialize:function(aK){aK=aK||{};this._requestQueue=[];this._authenticating=false;S.Util.setOptions(this,aK);this.options.url=T(this.options.url)},get:function(aL,aM,aN,aK){return this._request("get",aL,aM,aN,aK)},post:function(aL,aM,aN,aK){return this._request("post",aL,aM,aN,aK)},request:function(aL,aM,aN,aK){return this._request("request",aL,aM,aN,aK)},metadata:function(aL,aK){return this._request("get","",{},aL,aK)},authenticate:function(aK){this._authenticating=false;this.options.token=aK;this._runQueue();return this},getTimeout:function(){return this.options.timeout},setTimeout:function(aK){this.options.timeout=aK},_request:function(aQ,aM,aO,aP,aL){this.fire("requeststart",{url:this.options.url+aM,params:aO,method:aQ},true);var aN=this._createServiceCallback(aQ,aM,aO,aP,aL);if(this.options.token){aO.token=this.options.token}if(this._authenticating){this._requestQueue.push([aQ,aM,aO,aP,aL]);return}else{var aK=(this.options.proxy)?this.options.proxy+"?"+this.options.url+aM:this.options.url+aM;if((aQ==="get"||aQ==="request")&&!this.options.useCors){return G.get.JSONP(aK,aO,aN,aL)}else{return G[aQ](aK,aO,aN,aL)}}},_createServiceCallback:function(aO,aL,aM,aN,aK){return S.Util.bind(function(aQ,aP){if(aQ&&(aQ.code===499||aQ.code===498)){this._authenticating=true;this._requestQueue.push([aO,aL,aM,aN,aK]);this.fire("authenticationrequired",{authenticate:S.Util.bind(this.authenticate,this)},true);aQ.authenticate=S.Util.bind(this.authenticate,this)}aN.call(aK,aQ,aP);if(aQ){this.fire("requesterror",{url:this.options.url+aL,params:aM,message:aQ.message,code:aQ.code,method:aO},true)}else{this.fire("requestsuccess",{url:this.options.url+aL,params:aM,response:aP,method:aO},true)}this.fire("requestend",{url:this.options.url+aL,params:aM,method:aO},true)},this)},_runQueue:function(){for(var aK=this._requestQueue.length-1;aK>=0;aK--){var aL=this._requestQueue[aK];var aM=aL.shift();this[aM].apply(this,aL)}this._requestQueue=[]}});function aG(aK){return new ae(aK)}var m=ae.extend({identify:function(){return N(this)},find:function(){return aH(this)},query:function(){return K(this)}});function f(aK){return new m(aK)}var ar=ae.extend({query:function(){return K(this)},identify:function(){return n(this)}});function P(aK){return new ar(aK)}var az=ae.extend({options:{idAttribute:"OBJECTID"},query:function(){return K(this)},addFeature:function(aL,aM,aK){delete aL.id;aL=ap(aL);return this.post("addFeatures",{features:[aL]},function(aP,aO){var aN=(aO&&aO.addResults)?aO.addResults[0]:undefined;if(aM){aM.call(aK,aP||aO.addResults[0].error,aN)}},aK)},updateFeature:function(aL,aM,aK){aL=ap(aL,this.options.idAttribute);return this.post("updateFeatures",{features:[aL]},function(aP,aO){var aN=(aO&&aO.updateResults)?aO.updateResults[0]:undefined;if(aM){aM.call(aK,aP||aO.updateResults[0].error,aN)}},aK)},deleteFeature:function(aM,aL,aK){return this.post("deleteFeatures",{objectIds:aM},function(aP,aO){var aN=(aO&&aO.deleteResults)?aO.deleteResults[0]:undefined;if(aL){aL.call(aK,aP||aO.deleteResults[0].error,aN)}},aK)},deleteFeatures:function(aL,aM,aK){return this.post("deleteFeatures",{objectIds:aL},function(aP,aO){var aN=(aO&&aO.deleteResults)?aO.deleteResults:undefined;if(aM){aM.call(aK,aP||aO.deleteResults[0].error,aN)}},aK)}});function ab(aK){return new az(aK)}var x=(window.location.protocol!=="https:")?"http:":"https:";var ad=S.TileLayer.extend({statics:{TILES:{Streets:{urlTemplate:x+"//{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:x+"//{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:x+"//{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:x+"//{s}.arcgisonline.com/arcgis/rest/services/Ocean/World_Ocean_Reference/MapServer/tile/{z}/{y}/{x}",options:{minZoom:1,maxZoom:16,subdomains:["server","services"],pane:(a)?"esri-labels":"tilePane"}},NationalGeographic:{urlTemplate:x+"//{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:x+"//{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:x+"//{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:(a)?"esri-labels":"tilePane",attribution:""}},Gray:{urlTemplate:x+"//{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:x+"//{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:(a)?"esri-labels":"tilePane",attribution:""}},Imagery:{urlTemplate:x+"//{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"}},ImageryLabels:{urlTemplate:x+"//{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:(a)?"esri-labels":"tilePane",attribution:""}},ImageryTransportation:{urlTemplate:x+"//{s}.arcgisonline.com/ArcGIS/rest/services/Reference/World_Transportation/MapServer/tile/{z}/{y}/{x}",options:{minZoom:1,maxZoom:19,subdomains:["server","services"],pane:(a)?"esri-labels":"tilePane"}},ShadedRelief:{urlTemplate:x+"//{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:x+"//{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:(a)?"esri-labels":"tilePane",attribution:""}},Terrain:{urlTemplate:x+"//{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:x+"//{s}.arcgisonline.com/ArcGIS/rest/services/Reference/World_Reference_Overlay/MapServer/tile/{z}/{y}/{x}",options:{minZoom:1,maxZoom:13,subdomains:["server","services"],pane:(a)?"esri-labels":"tilePane",attribution:""}},USATopo:{urlTemplate:x+"//{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"}}}},initialize:function(aM,aL){var aK;if(typeof aM==="object"&&aM.urlTemplate&&aM.options){aK=aM}else{if(typeof aM==="string"&&ad.TILES[aM]){aK=ad.TILES[aM]}else{throw new Error('L.esri.BasemapLayer: Invalid parameter. Use one of "Streets", "Topographic", "Oceans", "OceansLabels", "NationalGeographic", "Gray", "GrayLabels", "DarkGray", "DarkGrayLabels", "Imagery", "ImageryLabels", "ImageryTransportation", "ShadedRelief", "ShadedReliefLabels", "Terrain", "TerrainLabels" or "USATopo"')}}var aN=S.Util.extend(aK.options,aL);S.Util.setOptions(this,aN);if(this.options.token){aK.urlTemplate+=("?token="+this.options.token)}S.TileLayer.prototype.initialize.call(this,aK.urlTemplate,aN)},onAdd:function(aK){ay(aK);if(this.options.pane==="esri-labels"){this._initPane()}if(this.options.attributionUrl){V(this.options.attributionUrl,aK)}aK.on("moveend",aB);S.TileLayer.prototype.onAdd.call(this,aK)},onRemove:function(aK){aK.off("moveend",aB);S.TileLayer.prototype.onRemove.call(this,aK)},_initPane:function(){if(!this._map.getPane(this.options.pane)){var aK=this._map.createPane(this.options.pane);aK.style.pointerEvents="none";aK.style.zIndex=500}},getAttribution:function(){if(this.options.attribution){var aK='<span class="esri-dynamic-attribution">'+this.options.attribution+"</span>"}return aK}});function w(aL,aK){return new ad(aL,aK)}var q=S.TileLayer.extend({options:{zoomOffsetAllowance:0.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":0.597164283559817,"19":0.298582141647617,"20":0.14929107082381,"21":0.07464553541191,"22":0.0373227677059525,"23":0.0186613838529763}},initialize:function(aK){aK.url=T(aK.url);aK=S.Util.setOptions(this,aK);this.tileUrl=aK.url+"tile/{z}/{y}/{x}";this.service=f(aK);this.service.addEventParent(this);var aL=new RegExp(/tiles.arcgis(online)?\.com/g);if(aL.test(aK.url)){this.tileUrl=this.tileUrl.replace("://tiles","://tiles{s}");aK.subdomains=["1","2","3","4"]}if(this.options.token){this.tileUrl+=("?token="+this.options.token)}S.TileLayer.prototype.initialize.call(this,this.tileUrl,aK)},getTileUrl:function(aK){var aL=this._getZoomForUrl();return S.Util.template(this.tileUrl,S.Util.extend({s:this._getSubdomain(aK),x:aK.x,y:aK.y,z:(this._lodMap&&this._lodMap[aL])?this._lodMap[aL]:aL},this.options))},createTile:function(aM,aK){var aL=document.createElement("img");L.DomEvent.on(aL,"load",L.bind(this._tileOnLoad,this,aK,aL));L.DomEvent.on(aL,"error",L.bind(this._tileOnError,this,aK,aL));if(this.options.crossOrigin){aL.crossOrigin=""}aL.alt="";if(!this._lodMap||(this._lodMap&&this._lodMap[this._getZoomForUrl()])){aL.src=this.getTileUrl(aM)}else{this.once("lodmap",function(){aL.src=this.getTileUrl(aM)},this)}return aL},onAdd:function(aK){ay(aK);if(!this._lodMap){this.metadata(function(aP,aQ){if(!aP&&aQ.spatialReference){var aL=aQ.spatialReference.latestWkid||aQ.spatialReference.wkid;if(!this.options.attribution&&aK.attributionControl&&aQ.copyrightText){this.options.attribution=aQ.copyrightText;aK.attributionControl.addAttribution(this.getAttribution())}if(aK.options.crs===L.CRS.EPSG3857&&aL===102100||aL===3857){this._lodMap={};var aM=aQ.tileInfo.lods;var aN=q.MercatorZoomLevels;for(var aO=0;aO<aM.length;aO++){var aR=aM[aO];for(var aT in aN){var aS=aN[aT];if(this._withinPercentage(aR.resolution,aS,this.options.zoomOffsetAllowance)){this._lodMap[aT]=aR.level;break}}}this.fire("lodmap")}else{if(!proj4){aF("L.esri.TiledMapLayer is using a non-mercator spatial reference. Support may be available through Proj4Leaflet http://esri.github.io/esri-leaflet/examples/non-mercator-projection.html")}}}},this)}S.TileLayer.prototype.onAdd.call(this,aK)},metadata:function(aL,aK){this.service.metadata(aL,aK);return this},identify:function(){return this.service.identify()},find:function(){return this.service.find()},query:function(){return this.service.query()},authenticate:function(aK){var aL="?token="+aK;this.tileUrl=(this.options.token)?this.tileUrl.replace(/\?token=(.+)/g,aL):this.tileUrl+aL;this.options.token=aK;this.service.authenticate(aK);return this},_withinPercentage:function(aM,aK,aL){var aN=Math.abs((aM/aK)-1);return aN<aL}});function U(aL,aK){return new q(aL,aK)}var M=S.ImageOverlay.extend({onAdd:function(aK){this._topLeft=aK.getPixelBounds().min;S.ImageOverlay.prototype.onAdd.call(this,aK)},_reset:function(){if(this._map.options.crs===S.CRS.EPSG3857){S.ImageOverlay.prototype._reset.call(this)}else{S.DomUtil.setPosition(this._image,this._topLeft.subtract(this._map.getPixelOrigin()))}}});var aw=S.Layer.extend({options:{opacity:1,position:"front",f:"image",useCors:aJ,attribution:null,interactive:false,alt:""},onAdd:function(aK){ay(aK);this._update=S.Util.throttle(this._update,this.options.updateInterval,this);aK.on("moveend",this._update,this);if(this._currentImage&&this._currentImage._bounds.equals(this._map.getBounds())){aK.addLayer(this._currentImage)}else{if(this._currentImage){this._map.removeLayer(this._currentImage);this._currentImage=null}}this._update();if(this._popup){this._map.on("click",this._getPopupData,this);this._map.on("dblclick",this._resetPopupState,this)}this.metadata(function(aM,aL){if(!aM&&!this.options.attribution&&aK.attributionControl&&aL.copyrightText){this.options.attribution=aL.copyrightText;aK.attributionControl.addAttribution(this.getAttribution())}},this)},onRemove:function(aK){if(this._currentImage){this._map.removeLayer(this._currentImage)}if(this._popup){this._map.off("click",this._getPopupData,this);this._map.off("dblclick",this._resetPopupState,this)}this._map.off("moveend",this._update,this)},bindPopup:function(aK,aL){this._shouldRenderPopup=false;this._lastClick=false;this._popup=S.popup(aL);this._popupFunction=aK;if(this._map){this._map.on("click",this._getPopupData,this);this._map.on("dblclick",this._resetPopupState,this)}return this},unbindPopup:function(){if(this._map){this._map.closePopup(this._popup);this._map.off("click",this._getPopupData,this);this._map.off("dblclick",this._resetPopupState,this)}this._popup=false;return this},bringToFront:function(){this.options.position="front";if(this._currentImage){this._currentImage.bringToFront()}return this},bringToBack:function(){this.options.position="back";if(this._currentImage){this._currentImage.bringToBack()}return this},getAttribution:function(){return this.options.attribution},getOpacity:function(){return this.options.opacity},setOpacity:function(aK){this.options.opacity=aK;if(this._currentImage){this._currentImage.setOpacity(aK)}return this},getTimeRange:function(){return[this.options.from,this.options.to]},setTimeRange:function(aL,aK){this.options.from=aL;this.options.to=aK;this._update();return this},metadata:function(aL,aK){this.service.metadata(aL,aK);return this},authenticate:function(aK){this.service.authenticate(aK);return this},redraw:function(){this._update()},_renderImage:function(aK,aL,aN){if(this._map){if(aN){aK="data:"+aN+";base64,"+aK}var aM=new M(aK,aL,{opacity:0,crossOrigin:this.options.useCors,alt:this.options.alt,pane:this.options.pane||this.getPane(),interactive:this.options.interactive}).addTo(this._map);aM.once("load",function(aP){if(this._map){var aQ=aP.target;var aO=this._currentImage;if(aQ._bounds.equals(aL)&&aQ._bounds.equals(this._map.getBounds())){this._currentImage=aQ;if(this.options.position==="front"){this.bringToFront()}else{this.bringToBack()}if(this._map&&this._currentImage._map){this._currentImage.setOpacity(this.options.opacity)}else{this._currentImage._map.removeLayer(this._currentImage)}if(aO&&this._map){this._map.removeLayer(aO)}if(aO&&aO._map){aO._map.removeLayer(aO)}}else{this._map.removeLayer(aQ)}}this.fire("load",{bounds:aL})},this);this.fire("loading",{bounds:aL})}},_update:function(){if(!this._map){return}var aL=this._map.getZoom();var aK=this._map.getBounds();if(this._animatingZoom){return}if(this._map._panTransition&&this._map._panTransition._inProgress){return}if(aL>this.options.maxZoom||aL<this.options.minZoom){if(this._currentImage){this._currentImage._map.removeLayer(this._currentImage);this._currentImage=null}return}var aM=this._buildExportParams();this._requestExport(aM,aK)},_renderPopup:function(aO,aL,aM,aK){aO=S.latLng(aO);if(this._shouldRenderPopup&&this._lastClick.equals(aO)){var aN=this._popupFunction(aL,aM,aK);if(aN){this._popup.setLatLng(aO).setContent(aN).openOn(this._map)}}},_resetPopupState:function(aK){this._shouldRenderPopup=false;this._lastClick=aK.latlng}});var at=aw.extend({options:{updateInterval:150,format:"jpgpng",transparent:true,f:"json"},query:function(){return this.service.query()},identify:function(){return this.service.identify()},initialize:function(aK){aK.url=T(aK.url);this.service=P(aK);this.service.addEventParent(this);S.Util.setOptions(this,aK)},setPixelType:function(aK){this.options.pixelType=aK;this._update();return this},getPixelType:function(){return this.options.pixelType},setBandIds:function(aK){if(S.Util.isArray(aK)){this.options.bandIds=aK.join(",")}else{this.options.bandIds=aK.toString()}this._update();return this},getBandIds:function(){return this.options.bandIds},setNoData:function(aK,aL){if(S.Util.isArray(aK)){this.options.noData=aK.join(",")}else{this.options.noData=aK.toString()}if(aL){this.options.noDataInterpretation=aL}this._update();return this},getNoData:function(){return this.options.noData},getNoDataInterpretation:function(){return this.options.noDataInterpretation},setRenderingRule:function(aK){this.options.renderingRule=aK;this._update()},getRenderingRule:function(){return this.options.renderingRule},setMosaicRule:function(aK){this.options.mosaicRule=aK;this._update()},getMosaicRule:function(){return this.options.mosaicRule},_getPopupData:function(aL){var aM=S.Util.bind(function(aO,aP,aN){if(aO){return}setTimeout(S.Util.bind(function(){this._renderPopup(aL.latlng,aO,aP,aN)},this),300)},this);var aK=this.identify().at(aL.latlng);if(this.options.mosaicRule){aK.setMosaicRule(this.options.mosaicRule)}aK.run(aM);this._shouldRenderPopup=true;this._lastClick=aL.latlng},_buildExportParams:function(){var aO=this._map.getBounds();var aM=this._map.getSize();var aQ=this._map.options.crs.project(aO._northEast);var aK=this._map.options.crs.project(aO._southWest);var aP=this._map.latLngToLayerPoint(aO._northEast);var aL=this._map.latLngToLayerPoint(aO._southWest);if(aP.y>0||aL.y<aM.y){aM.y=aL.y-aP.y}var aN=parseInt(this._map.options.crs.code.split(":")[1],10);var aR={bbox:[aK.x,aK.y,aQ.x,aQ.y].join(","),size:aM.x+","+aM.y,format:this.options.format,transparent:this.options.transparent,bboxSR:aN,imageSR:aN};if(this.options.from&&this.options.to){aR.time=this.options.from.valueOf()+","+this.options.to.valueOf()}if(this.options.pixelType){aR.pixelType=this.options.pixelType}if(this.options.interpolation){aR.interpolation=this.options.interpolation}if(this.options.compressionQuality){aR.compressionQuality=this.options.compressionQuality}if(this.options.bandIds){aR.bandIds=this.options.bandIds}if(this.options.noData){aR.noData=this.options.noData}if(this.options.noDataInterpretation){aR.noDataInterpretation=this.options.noDataInterpretation}if(this.service.options.token){aR.token=this.service.options.token}if(this.options.renderingRule){aR.renderingRule=JSON.stringify(this.options.renderingRule)}if(this.options.mosaicRule){aR.mosaicRule=JSON.stringify(this.options.mosaicRule)}return aR},_requestExport:function(aL,aK){if(this.options.f==="json"){this.service.request("exportImage",aL,function(aN,aM){if(aN){return}if(this.options.token){aM.href+=("?token="+this.options.token)}this._renderImage(aM.href,aK)},this)}else{aL.f="image";this._renderImage(this.options.url+"exportImage"+S.Util.getParamString(aL),aK)}}});function j(aL,aK){return new at(aL,aK)}var J=aw.extend({options:{updateInterval:150,layers:false,layerDefs:false,timeOptions:false,format:"png24",transparent:true,f:"json"},initialize:function(aK){aK.url=T(aK.url);this.service=f(aK);this.service.addEventParent(this);if((aK.proxy||aK.token)&&aK.f!=="json"){aK.f="json"}S.Util.setOptions(this,aK)},getDynamicLayers:function(){return this.options.dynamicLayers},setDynamicLayers:function(aK){this.options.dynamicLayers=aK;this._update();return this},getLayers:function(){return this.options.layers},setLayers:function(aK){this.options.layers=aK;this._update();return this},getLayerDefs:function(){return this.options.layerDefs},setLayerDefs:function(aK){this.options.layerDefs=aK;this._update();return this},getTimeOptions:function(){return this.options.timeOptions},setTimeOptions:function(aK){this.options.timeOptions=aK;this._update();return this},query:function(){return this.service.query()},identify:function(){return this.service.identify()},find:function(){return this.service.find()},_getPopupData:function(aL){var aM=S.Util.bind(function(aO,aP,aN){if(aO){return}setTimeout(S.Util.bind(function(){this._renderPopup(aL.latlng,aO,aP,aN)},this),300)},this);var aK=this.identify().on(this._map).at(aL.latlng);aK.simplify(this._map,0.5);if(this.options.layers){aK.layers("visible:"+this.options.layers.join(","))}else{aK.layers("visible")}aK.run(aM);this._shouldRenderPopup=true;this._lastClick=aL.latlng},_buildExportParams:function(){var aO=this._map.getBounds();var aM=this._map.getSize();var aQ=this._map.options.crs.project(aO.getNorthEast());var aK=this._map.options.crs.project(aO.getSouthWest());var aN=parseInt(this._map.options.crs.code.split(":")[1],10);var aP=this._map.latLngToLayerPoint(aO._northEast);var aL=this._map.latLngToLayerPoint(aO._southWest);if(aP.y>0||aL.y<aM.y){aM.y=aL.y-aP.y}var aR={bbox:[aK.x,aK.y,aQ.x,aQ.y].join(","),size:aM.x+","+aM.y,dpi:96,format:this.options.format,transparent:this.options.transparent,bboxSR:aN,imageSR:aN};if(this.options.dynamicLayers){aR.dynamicLayers=this.options.dynamicLayers}if(this.options.layers){aR.layers="show:"+this.options.layers.join(",")}if(this.options.layerDefs){aR.layerDefs=typeof this.options.layerDefs==="string"?this.options.layerDefs:JSON.stringify(this.options.layerDefs)}if(this.options.timeOptions){aR.timeOptions=JSON.stringify(this.options.timeOptions)}if(this.options.from&&this.options.to){aR.time=this.options.from.valueOf()+","+this.options.to.valueOf()}if(this.service.options.token){aR.token=this.service.options.token}if(this.options.proxy){aR.proxy=this.options.proxy}return aR},_requestExport:function(aL,aK){if(this.options.f==="json"){this.service.request("export",aL,function(aN,aM){if(aN){return}if(this.options.token){aM.href+=("?token="+this.options.token)}if(this.options.proxy){aM.href=this.options.proxy+"?"+aM.href}if(aM.href){this._renderImage(aM.href,aK)}else{this._renderImage(aM.imageData,aK,aM.contentType)}},this)}else{aL.f="image";this._renderImage(this.options.url+"export"+S.Util.getParamString(aL),aK)}}});function aq(aL,aK){return new J(aL,aK)}var Z=Y.Layer.extend({options:{cellSize:512,updateInterval:150},initialize:function(aK){aK=Y.setOptions(this,aK);this._zooming=false},onAdd:function(aK){this._map=aK;this._update=Y.Util.throttle(this._update,this.options.updateInterval,this);this._reset();this._update()},onRemove:function(){this._map.removeEventListener(this.getEvents(),this);this._removeCells()},getEvents:function(){var aK={moveend:this._update,zoomstart:this._zoomstart,zoomend:this._reset};return aK},addTo:function(aK){aK.addLayer(this);return this},removeFrom:function(aK){aK.removeLayer(this);return this},_zoomstart:function(){this._zooming=true},_reset:function(){this._removeCells();this._cells={};this._activeCells={};this._cellsToLoad=0;this._cellsTotal=0;this._cellNumBounds=this._getCellNumBounds();this._resetWrap();this._zooming=false},_resetWrap:function(){var aL=this._map;var aK=aL.options.crs;if(aK.infinite){return}var aM=this._getCellSize();if(aK.wrapLng){this._wrapLng=[Math.floor(aL.project([0,aK.wrapLng[0]]).x/aM),Math.ceil(aL.project([0,aK.wrapLng[1]]).x/aM)]}if(aK.wrapLat){this._wrapLat=[Math.floor(aL.project([aK.wrapLat[0],0]).y/aM),Math.ceil(aL.project([aK.wrapLat[1],0]).y/aM)]}},_getCellSize:function(){return this.options.cellSize},_update:function(){if(!this._map){return}var aL=this._map.getPixelBounds();var aM=this._getCellSize();var aK=Y.bounds(aL.min.divideBy(aM).floor(),aL.max.divideBy(aM).floor());this._removeOtherCells(aK);this._addCells(aK);this.fire("cellsupdated")},_addCells:function(aQ){var aM=[];var aL=aQ.getCenter();var aP=this._map.getZoom();var aN,aO,aR;for(aN=aQ.min.y;aN<=aQ.max.y;aN++){for(aO=aQ.min.x;aO<=aQ.max.x;aO++){aR=Y.point(aO,aN);aR.z=aP;if(this._isValidCell(aR)){aM.push(aR)}}}var aK=aM.length;if(aK===0){return}this._cellsToLoad+=aK;this._cellsTotal+=aK;aM.sort(function(aT,aS){return aT.distanceTo(aL)-aS.distanceTo(aL)});for(aO=0;aO<aK;aO++){this._addCell(aM[aO])}},_isValidCell:function(aN){var aK=this._map.options.crs;if(!aK.infinite){var aM=this._cellNumBounds;if((!aK.wrapLng&&(aN.x<aM.min.x||aN.x>aM.max.x))||(!aK.wrapLat&&(aN.y<aM.min.y||aN.y>aM.max.y))){return false}}if(!this.options.bounds){return true}var aL=this._cellCoordsToBounds(aN);return Y.latLngBounds(this.options.bounds).intersects(aL)},_cellCoordsToBounds:function(aO){var aP=this._map;var aQ=this.options.cellSize;var aM=aO.multiplyBy(aQ);var aK=aM.add([aQ,aQ]);var aL=aP.wrapLatLng(aP.unproject(aM,aO.z));var aN=aP.wrapLatLng(aP.unproject(aK,aO.z));return Y.latLngBounds(aL,aN)},_cellCoordsToKey:function(aK){return aK.x+":"+aK.y},_keyToCellCoords:function(aL){var aM=aL.split(":");var aK=parseInt(aM[0],10);var aN=parseInt(aM[1],10);return Y.point(aK,aN)},_removeOtherCells:function(aL){for(var aK in this._cells){if(!aL.contains(this._keyToCellCoords(aK))){this._removeCell(aK)}}},_removeCell:function(aL){var aK=this._activeCells[aL];if(aK){delete this._activeCells[aL];if(this.cellLeave){this.cellLeave(aK.bounds,aK.coords)}this.fire("cellleave",{bounds:aK.bounds,coords:aK.coords})}},_removeCells:function(){for(var aK in this._cells){var aL=this._cells[aK].bounds;var aM=this._cells[aK].coords;if(this.cellLeave){this.cellLeave(aL,aM)}this.fire("cellleave",{bounds:aL,coords:aM})}},_addCell:function(aM){this._wrapCoords(aM);var aL=this._cellCoordsToKey(aM);var aK=this._cells[aL];if(aK&&!this._activeCells[aL]){if(this.cellEnter){this.cellEnter(aK.bounds,aM)}this.fire("cellenter",{bounds:aK.bounds,coords:aM});this._activeCells[aL]=aK}if(!aK){aK={coords:aM,bounds:this._cellCoordsToBounds(aM)};this._cells[aL]=aK;this._activeCells[aL]=aK;if(this.createCell){this.createCell(aK.bounds,aM)}this.fire("cellcreate",{bounds:aK.bounds,coords:aM})}},_wrapCoords:function(aK){aK.x=this._wrapLng?Y.Util.wrapNum(aK.x,this._wrapLng):aK.x;aK.y=this._wrapLat?Y.Util.wrapNum(aK.y,this._wrapLat):aK.y},_getCellNumBounds:function(){var aL=this._map.getPixelWorldBounds();var aK=this._getCellSize();return aL?Y.bounds(aL.min.divideBy(aK).floor(),aL.max.divideBy(aK).ceil().subtract([1,1])):null}});function aa(aK){this.values=[].concat(aK||[])}aa.prototype.query=function(aL){var aK=this.getIndex(aL);return this.values[aK]};aa.prototype.getIndex=function i(aO){if(this.dirty){this.sort()}var aM=0;var aN=this.values.length-1;var aK;var aL;while(aM<=aN){aK=(aM+aN)/2|0;aL=this.values[Math.round(aK)];if(+aL.value<+aO){aM=aK+1}else{if(+aL.value>+aO){aN=aK-1}else{return aK}}}return Math.abs(~aN)};aa.prototype.between=function H(aN,aK){var aM=this.getIndex(aN);var aL=this.getIndex(aK);if(aM===0&&aL===0){return[]}while(this.values[aM-1]&&this.values[aM-1].value===aN){aM--}while(this.values[aL+1]&&this.values[aL+1].value===aK){aL++}if(this.values[aL]&&this.values[aL].value===aK&&this.values[aL+1]){aL++}return this.values.slice(aM,aL)};aa.prototype.insert=function B(aK){this.values.splice(this.getIndex(aK.value),0,aK);return this};aa.prototype.bulkAdd=function A(aK,aL){this.values=this.values.concat([].concat(aK||[]));if(aL){this.sort()}else{this.dirty=true}return this};aa.prototype.sort=function F(){this.values.sort(function(aL,aK){return +aK.value-+aL.value}).reverse();this.dirty=false;return this};var av=Z.extend({options:{attribution:null,where:"1=1",fields:["*"],from:false,to:false,timeField:false,timeFilterMode:"server",simplifyFactor:0,precision:6},initialize:function(aK){Z.prototype.initialize.call(this,aK);aK.url=T(aK.url);aK=S.setOptions(this,aK);this.service=ab(aK);this.service.addEventParent(this);if(this.options.fields[0]!=="*"){var aM=false;for(var aL=0;aL<this.options.fields.length;aL++){if(this.options.fields[aL].match(/^(OBJECTID|FID|OID|ID)$/i)){aM=true}}if(aM===false){aF("no known esriFieldTypeOID field detected in fields Array.  Please add an attribute field containing unique IDs to ensure the layer can be drawn correctly.")}}if(this.options.timeField.start&&this.options.timeField.end){this._startTimeIndex=new aa();this._endTimeIndex=new aa()}else{if(this.options.timeField){this._timeIndex=new aa()}}this._cache={};this._currentSnapshot=[];this._activeRequests=0},onAdd:function(aK){ay(aK);this.service.metadata(function(aM,aL){if(!aM){var aO=aL.supportedQueryFormats;var aN=false;if(this.service.options.isModern===false){aN=true}if(!aN&&aO&&aO.indexOf("geoJSON")!==-1){this.service.options.isModern=true}if(!this.options.attribution&&aK.attributionControl&&aL.copyrightText){this.options.attribution=aL.copyrightText;aK.attributionControl.addAttribution(this.getAttribution())}}},this);aK.on("zoomend",this._handleZoomChange,this);return Z.prototype.onAdd.call(this,aK)},onRemove:function(aK){aK.off("zoomend",this._handleZoomChange,this);return Z.prototype.onRemove.call(this,aK)},getAttribution:function(){return this.options.attribution},createCell:function(aK,aL){if(this._visibleZoom()){this._requestFeatures(aK,aL)}},_requestFeatures:function(aK,aL,aM){this._activeRequests++;if(this._activeRequests===1){this.fire("loading",{bounds:aK},true)}return this._buildQuery(aK).run(function(aO,aP,aN){if(aN&&aN.exceededTransferLimit){this.fire("drawlimitexceeded")}if(!aO&&aP&&aP.features.length){S.Util.requestAnimFrame(S.Util.bind(function(){this._addFeatures(aP.features,aL);this._postProcessFeatures(aK)},this))}if(!aO&&aP&&!aP.features.length){this._postProcessFeatures(aK)}if(aO){this._postProcessFeatures(aK)}if(aM){aM.call(this,aO,aP)}},this)},_postProcessFeatures:function(aK){this._activeRequests--;if(this._activeRequests<=0){this.fire("load",{bounds:aK})}},_cacheKey:function(aK){return aK.z+":"+aK.x+":"+aK.y},_addFeatures:function(aM,aN){var aL=this._cacheKey(aN);this._cache[aL]=this._cache[aL]||[];for(var aK=aM.length-1;aK>=0;aK--){var aO=aM[aK].id;if(this._currentSnapshot.indexOf(aO)===-1){this._currentSnapshot.push(aO)}if(this._cache[aL].indexOf(aO)===-1){this._cache[aL].push(aO)}}if(this.options.timeField){this._buildTimeIndexes(aM)}this.createLayers(aM)},_buildQuery:function(aK){var aL=this.service.query().intersects(aK).where(this.options.where).fields(this.options.fields).precision(this.options.precision);if(this.options.simplifyFactor){aL.simplify(this._map,this.options.simplifyFactor)}if(this.options.timeFilterMode==="server"&&this.options.from&&this.options.to){aL.between(this.options.from,this.options.to)}return aL},setWhere:function(aP,aU,aL){this.options.where=(aP&&aP.length)?aP:"1=1";var aN=[];var aT=[];var aM=0;var aR=null;var aV=S.Util.bind(function(aW,aY){if(aW){aR=aW}if(aY){for(var aX=aY.features.length-1;aX>=0;aX--){aT.push(aY.features[aX].id)}}aM--;if(aM<=0){this._currentSnapshot=aT;S.Util.requestAnimFrame(S.Util.bind(function(){this.removeLayers(aN);this.addLayers(aT);if(aU){aU.call(aL,aR)}},this))}},this);for(var aO=this._currentSnapshot.length-1;aO>=0;aO--){aN.push(this._currentSnapshot[aO])}for(var aS in this._activeCells){aM++;var aQ=this._keyToCellCoords(aS);var aK=this._cellCoordsToBounds(aQ);this._requestFeatures(aK,aS,aV)}return this},getWhere:function(){return this.options.where},getTimeRange:function(){return[this.options.from,this.options.to]},setTimeRange:function(aO,aP,aU,aL){var aT=this.options.from;var aS=this.options.to;var aM=0;var aQ=null;var aV=S.Util.bind(function(aW){if(aW){aQ=aW}this._filterExistingFeatures(aT,aS,aO,aP);aM--;if(aU&&aM<=0){aU.call(aL,aQ)}},this);this.options.from=aO;this.options.to=aP;this._filterExistingFeatures(aT,aS,aO,aP);if(this.options.timeFilterMode==="server"){for(var aR in this._activeCells){aM++;var aN=this._keyToCellCoords(aR);var aK=this._cellCoordsToBounds(aN);this._requestFeatures(aK,aR,aV)}}return this},refresh:function(){for(var aK in this._activeCells){var aM=this._keyToCellCoords(aK);var aL=this._cellCoordsToBounds(aM);this._requestFeatures(aL,aK)}if(this.redraw){this.once("load",function(){this.eachFeature(function(aN){this._redraw(aN.feature.id)},this)},this)}},_filterExistingFeatures:function(aL,aR,aP,aM){var aO=(aL&&aR)?this._getFeaturesInTimeRange(aL,aR):this._currentSnapshot;var aQ=this._getFeaturesInTimeRange(aP,aM);if(aQ.indexOf){for(var aN=0;aN<aQ.length;aN++){var aK=aO.indexOf(aQ[aN]);if(aK>=0){aO.splice(aK,1)}}}S.Util.requestAnimFrame(S.Util.bind(function(){this.removeLayers(aO);this.addLayers(aQ)},this))},_getFeaturesInTimeRange:function(aQ,aK){var aP=[];var aO;if(this.options.timeField.start&&this.options.timeField.end){var aN=this._startTimeIndex.between(aQ,aK);var aL=this._endTimeIndex.between(aQ,aK);aO=aN.concat(aL)}else{aO=this._timeIndex.between(aQ,aK)}for(var aM=aO.length-1;aM>=0;aM--){aP.push(aO[aM].id)}return aP},_buildTimeIndexes:function(aL){var aO;var aN;if(this.options.timeField.start&&this.options.timeField.end){var aP=[];var aK=[];for(aO=aL.length-1;aO>=0;aO--){aN=aL[aO];aP.push({id:aN.id,value:new Date(aN.properties[this.options.timeField.start])});aK.push({id:aN.id,value:new Date(aN.properties[this.options.timeField.end])})}this._startTimeIndex.bulkAdd(aP);this._endTimeIndex.bulkAdd(aK)}else{var aM=[];for(aO=aL.length-1;aO>=0;aO--){aN=aL[aO];aM.push({id:aN.id,value:new Date(aN.properties[this.options.timeField])})}this._timeIndex.bulkAdd(aM)}},_featureWithinTimeRange:function(aM){if(!this.options.from||!this.options.to){return true}var aP=+this.options.from.valueOf();var aO=+this.options.to.valueOf();if(typeof this.options.timeField==="string"){var aL=+aM.properties[this.options.timeField];return(aL>=aP)&&(aL<=aO)}if(this.options.timeField.start&&this.options.timeField.end){var aK=+aM.properties[this.options.timeField.start];var aN=+aM.properties[this.options.timeField.end];return((aK>=aP)&&(aK<=aO))||((aN>=aP)&&(aN<=aO))}},_visibleZoom:function(){if(!this._map){return false}var aK=this._map.getZoom();if(aK>this.options.maxZoom||aK<this.options.minZoom){return false}else{return true}},_handleZoomChange:function(){if(!this._visibleZoom()){this.removeLayers(this._currentSnapshot);this._currentSnapshot=[]}else{for(var aL in this._activeCells){var aM=this._activeCells[aL].coords;var aK=this._cacheKey(aM);if(this._cache[aK]){this.addLayers(this._cache[aK])}}}},authenticate:function(aK){this.service.authenticate(aK);return this},metadata:function(aL,aK){this.service.metadata(aL,aK);return this},query:function(){return this.service.query()},_getMetadata:function(aL){if(this._metadata){var aK;aL(aK,this._metadata)}else{this.metadata(S.Util.bind(function(aN,aM){this._metadata=aM;aL(aN,this._metadata)},this))}},addFeature:function(aL,aM,aK){this._getMetadata(S.Util.bind(function(aN,aO){if(aN){if(aM){aM.call(this,aN,null)}return}this.service.addFeature(aL,S.Util.bind(function(aQ,aP){if(!aQ){aL.properties[aO.objectIdField]=aP.objectId;aL.id=aP.objectId;this.createLayers([aL])}if(aM){aM.call(aK,aQ,aP)}},this))},this))},updateFeature:function(aL,aM,aK){this.service.updateFeature(aL,function(aO,aN){if(!aO){this.removeLayers([aL.id],true);this.createLayers([aL])}if(aM){aM.call(aK,aO,aN)}},this)},deleteFeature:function(aM,aL,aK){this.service.deleteFeature(aM,function(aO,aN){if(!aO&&aN.objectId){this.removeLayers([aN.objectId],true)}if(aL){aL.call(aK,aO,aN)}},this)},deleteFeatures:function(aL,aM,aK){return this.service.deleteFeatures(aL,function(aO,aN){if(!aO&&aN.length>0){for(var aP=0;aP<aN.length;aP++){this.removeLayers([aN[aP].objectId],true)}}if(aM){aM.call(aK,aO,aN)}},this)}});var ai=av.extend({options:{cacheLayers:true},initialize:function(aK){av.prototype.initialize.call(this,aK);this._originalStyle=this.options.style;this._layers={}},onRemove:function(aL){for(var aK in this._layers){aL.removeLayer(this._layers[aK]);this.fire("removefeature",{feature:this._layers[aK].feature,permanent:false},true)}return av.prototype.onRemove.call(this,aL)},createNewLayer:function(aK){var aL=S.GeoJSON.geometryToLayer(aK,this.options);aL.defaultOptions=aL.options;return aL},_updateLayer:function(aM,aL){var aK=[];var aN=this.options.coordsToLatLng||S.GeoJSON.coordsToLatLng;if(aL.properties){aM.feature.properties=aL.properties}switch(aL.geometry.type){case"Point":aK=S.GeoJSON.coordsToLatLng(aL.geometry.coordinates);aM.setLatLng(aK);break;case"LineString":aK=S.GeoJSON.coordsToLatLngs(aL.geometry.coordinates,0,aN);aM.setLatLngs(aK);break;case"MultiLineString":aK=S.GeoJSON.coordsToLatLngs(aL.geometry.coordinates,1,aN);aM.setLatLngs(aK);break;case"Polygon":aK=S.GeoJSON.coordsToLatLngs(aL.geometry.coordinates,1,aN);aM.setLatLngs(aK);break;case"MultiPolygon":aK=S.GeoJSON.coordsToLatLngs(aL.geometry.coordinates,2,aN);aM.setLatLngs(aK);break}},createLayers:function(aO){for(var aM=aO.length-1;aM>=0;aM--){var aK=aO[aM];var aL=this._layers[aK.id];var aN;if(this._visibleZoom()&&aL&&!this._map.hasLayer(aL)){this._map.addLayer(aL);this.fire("addfeature",{feature:aL.feature},true)}if(aL&&this.options.simplifyFactor>0&&(aL.setLatLngs||aL.setLatLng)){this._updateLayer(aL,aK)}if(!aL){aN=this.createNewLayer(aK);aN.feature=aK;aN.addEventParent(this);if(this.options.onEachFeature){this.options.onEachFeature(aN.feature,aN)}this._layers[aN.feature.id]=aN;this.setFeatureStyle(aN.feature.id,this.options.style);this.fire("createfeature",{feature:aN.feature},true);if(this._visibleZoom()&&(!this.options.timeField||(this.options.timeField&&this._featureWithinTimeRange(aK)))){this._map.addLayer(aN)}}}},addLayers:function(aM){for(var aL=aM.length-1;aL>=0;aL--){var aK=this._layers[aM[aL]];if(aK){this._map.addLayer(aK)}}},removeLayers:function(aM,aN){for(var aL=aM.length-1;aL>=0;aL--){var aO=aM[aL];var aK=this._layers[aO];if(aK){this.fire("removefeature",{feature:aK.feature,permanent:aN},true);this._map.removeLayer(aK)}if(aK&&aN){delete this._layers[aO]}}},cellEnter:function(aK,aL){if(this._visibleZoom()&&!this._zooming&&this._map){S.Util.requestAnimFrame(S.Util.bind(function(){var aN=this._cacheKey(aL);var aO=this._cellCoordsToKey(aL);var aM=this._cache[aN];if(this._activeCells[aO]&&aM){this.addLayers(aM)}},this))}},cellLeave:function(aK,aL){if(!this._zooming){S.Util.requestAnimFrame(S.Util.bind(function(){if(this._map){var aR=this._cacheKey(aL);var aS=this._cellCoordsToKey(aL);var aQ=this._cache[aR];var aM=this._map.getBounds();if(!this._activeCells[aS]&&aQ){var aN=true;for(var aP=0;aP<aQ.length;aP++){var aO=this._layers[aQ[aP]];if(aO&&aO.getBounds&&aM.intersects(aO.getBounds())){aN=false}}if(aN){this.removeLayers(aQ,!this.options.cacheLayers)}if(!this.options.cacheLayers&&aN){delete this._cache[aR];delete this._cells[aS];delete this._activeCells[aS]}}}},this))}},resetStyle:function(){this.options.style=this._originalStyle;this.eachFeature(function(aK){this.resetFeatureStyle(aK.feature.id)},this);return this},setStyle:function(aK){this.options.style=aK;this.eachFeature(function(aL){this.setFeatureStyle(aL.feature.id,aK)},this);return this},resetFeatureStyle:function(aM){var aK=this._layers[aM];var aL=this._originalStyle||L.Path.prototype.options;if(aK){S.Util.extend(aK.options,aK.defaultOptions);this.setFeatureStyle(aM,aL)}return this},setFeatureStyle:function(aM,aL){var aK=this._layers[aM];if(typeof aL==="function"){aL=aL(aK.feature)}if(aK.setStyle){aK.setStyle(aL)}return this},eachActiveFeature:function(aM,aL){if(this._map){var aN=this._map.getBounds();for(var aK in this._layers){if(aN.intersects(this._layers[aK].getBounds())&&this._currentSnapshot.indexOf(this._layers[aK].feature.id)!==-1){aM.call(aL,this._layers[aK])}}}return this},eachFeature:function(aM,aL){for(var aK in this._layers){aM.call(aL,this._layers[aK])}return this},getFeature:function(aK){return this._layers[aK]},bringToBack:function(){this.eachFeature(function(aK){if(aK.bringToBack){aK.bringToBack()}})},bringToFront:function(){this.eachFeature(function(aK){if(aK.bringToFront){aK.bringToFront()}})},redraw:function(aK){if(aK){this._redraw(aK)}return this},_redraw:function(aQ){var aN=this._layers[aQ];var aM=aN.feature;if(aN&&aN.setIcon&&this.options.pointToLayer){if(this.options.pointToLayer){var aP=this.options.pointToLayer(aM,S.latLng(aM.geometry.coordinates[1],aM.geometry.coordinates[0]));var aO=aP.options.icon;aN.setIcon(aO)}}if(aN&&aN.setStyle&&this.options.pointToLayer){var aK=this.options.pointToLayer(aM,S.latLng(aM.geometry.coordinates[1],aM.geometry.coordinates[0]));var aL=aK.options;this.setFeatureStyle(aM.id,aL)}if(aN&&aN.setStyle&&this.options.style){this.resetStyle(aM.id)}}});function E(aK){return new ai(aK)}O.VERSION=s;O.Support=ag;O.options=W;O.Util=X;O.get=al;O.post=aA;O.request=ah;O.Task=aC;O.task=am;O.Query=R;O.query=K;O.Find=l;O.find=aH;O.Identify=ax;O.identify=ao;O.IdentifyFeatures=au;O.identifyFeatures=N;O.IdentifyImage=d;O.identifyImage=n;O.Service=ae;O.service=aG;O.MapService=m;O.mapService=f;O.ImageService=ar;O.imageService=P;O.FeatureLayerService=az;O.featureLayerService=ab;O.BasemapLayer=ad;O.basemapLayer=w;O.TiledMapLayer=q;O.tiledMapLayer=U;O.RasterLayer=aw;O.ImageMapLayer=at;O.imageMapLayer=j;O.DynamicMapLayer=J;O.dynamicMapLayer=aq;O.FeatureManager=av;O.FeatureLayer=ai;O.featureLayer=E}));
\ No newline at end of file
+!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("leaflet")):"function"==typeof define&&define.amd?define(["exports","leaflet"],e):e((t.L=t.L||{},t.L.esri=t.L.esri||{}),t.L)}(this,function(t,e){"use strict";function i(t){var e="";t.f=t.f||"json";for(var i in t)if(t.hasOwnProperty(i)){var s,r=t[i],n=Object.prototype.toString.call(r);e.length&&(e+="&"),s="[object Array]"===n?"[object Object]"===Object.prototype.toString.call(r[0])?JSON.stringify(r):r.join(","):"[object Object]"===n?JSON.stringify(r):"[object Date]"===n?r.valueOf():r,e+=encodeURIComponent(i)+"="+encodeURIComponent(s)}return e}function s(t,i){var s=new window.XMLHttpRequest;return s.onerror=function(r){s.onreadystatechange=e.Util.falseFn,t.call(i,{error:{code:500,message:"XMLHttpRequest error"}},null)},s.onreadystatechange=function(){var r,n;if(4===s.readyState){try{r=JSON.parse(s.responseText)}catch(t){r=null,n={code:500,message:"Could not parse response as JSON. This could also be caused by a CORS or XMLHttpRequest error."}}!n&&r.error&&(n=r.error,r=null),s.onerror=e.Util.falseFn,t.call(i,n,r)}},s.ontimeout=function(){this.onerror()},s}function r(t,e,r,n){var o=s(r,n);return o.open("POST",t),void 0!==n&&null!==n&&void 0!==n.options&&(o.timeout=n.options.timeout),o.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),o.send(i(e)),o}function n(t,e,r,n){var o=s(r,n);return o.open("GET",t+"?"+i(e),!0),void 0!==n&&null!==n&&void 0!==n.options&&(o.timeout=n.options.timeout),o.send(null),o}function o(t,e,r,n){var o=i(e),u=s(r,n),l=(t+"?"+o).length;if(l<=2e3&&J.cors?u.open("GET",t+"?"+o):l>2e3&&J.cors&&(u.open("POST",t),u.setRequestHeader("Content-Type","application/x-www-form-urlencoded")),void 0!==n&&null!==n&&void 0!==n.options&&(u.timeout=n.options.timeout),l<=2e3&&J.cors)u.send(null);else{if(!(l>2e3&&J.cors))return l<=2e3&&!J.cors?a(t,e,r,n):void O("a request to "+t+" was longer then 2000 characters and this browser cannot make a cross-domain post request. Please use a proxy http://esri.github.io/esri-leaflet/api-reference/request.html");u.send(o)}return u}function a(t,s,r,n){window._EsriLeafletCallbacks=window._EsriLeafletCallbacks||{};var o="c"+H;s.callback="window._EsriLeafletCallbacks."+o,window._EsriLeafletCallbacks[o]=function(t){if(!0!==window._EsriLeafletCallbacks[o]){var e,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),r.call(n,e,t),window._EsriLeafletCallbacks[o]=!0}};var a=e.DomUtil.create("script",null,document.body);return a.type="text/javascript",a.src=t+"?"+i(s),a.id=o,H++,{id:o,url:a.src,abort:function(){window._EsriLeafletCallbacks._callback[o]({code:0,message:"Request aborted."})}}}function u(t,e){for(var i=0;i<t.length;i++)if(t[i]!==e[i])return!1;return!0}function l(t){return u(t[0],t[t.length-1])||t.push(t[0]),t}function h(t){var e,i=0,s=0,r=t.length,n=t[s];for(s;s<r-1;s++)i+=((e=t[s+1])[0]-n[0])*(e[1]+n[1]),n=e;return i>=0}function c(t,e,i,s){var r=(s[0]-i[0])*(t[1]-i[1])-(s[1]-i[1])*(t[0]-i[0]),n=(e[0]-t[0])*(t[1]-i[1])-(e[1]-t[1])*(t[0]-i[0]),o=(s[1]-i[1])*(e[0]-t[0])-(s[0]-i[0])*(e[1]-t[1]);if(0!==o){var a=r/o,u=n/o;if(a>=0&&a<=1&&u>=0&&u<=1)return!0}return!1}function p(t,e){for(var i=0;i<t.length-1;i++)for(var s=0;s<e.length-1;s++)if(c(t[i],t[i+1],e[s],e[s+1]))return!0;return!1}function d(t,e){for(var i=!1,s=-1,r=t.length,n=r-1;++s<r;n=s)(t[s][1]<=e[1]&&e[1]<t[n][1]||t[n][1]<=e[1]&&e[1]<t[s][1])&&e[0]<(t[n][0]-t[s][0])*(e[1]-t[s][1])/(t[n][1]-t[s][1])+t[s][0]&&(i=!i);return i}function m(t,e){var i=p(t,e),s=d(t,e[0]);return!(i||!s)}function f(t){for(var e,i,s,r=[],n=[],o=0;o<t.length;o++){var a=l(t[o].slice(0));if(!(a.length<4))if(h(a)){var u=[a];r.push(u)}else n.push(a)}for(var c=[];n.length;){s=n.pop();var d=!1;for(e=r.length-1;e>=0;e--)if(i=r[e][0],m(i,s)){r[e].push(s),d=!0;break}d||c.push(s)}for(;c.length;){s=c.pop();var f=!1;for(e=r.length-1;e>=0;e--)if(i=r[e][0],p(i,s)){r[e].push(s),f=!0;break}f||r.push([s.reverse()])}return 1===r.length?{type:"Polygon",coordinates:r[0]}:{type:"MultiPolygon",coordinates:r}}function y(t){var e=[],i=t.slice(0),s=l(i.shift().slice(0));if(s.length>=4){h(s)||s.reverse(),e.push(s);for(var r=0;r<i.length;r++){var n=l(i[r].slice(0));n.length>=4&&(h(n)&&n.reverse(),e.push(n))}}return e}function g(t){for(var e=[],i=0;i<t.length;i++)for(var s=y(t[i]),r=s.length-1;r>=0;r--){var n=s[r].slice(0);e.push(n)}return e}function _(t){var e={};for(var i in t)t.hasOwnProperty(i)&&(e[i]=t[i]);return e}function v(t,e){var i={};return"number"==typeof t.x&&"number"==typeof t.y&&(i.type="Point",i.coordinates=[t.x,t.y]),t.points&&(i.type="MultiPoint",i.coordinates=t.points.slice(0)),t.paths&&(1===t.paths.length?(i.type="LineString",i.coordinates=t.paths[0].slice(0)):(i.type="MultiLineString",i.coordinates=t.paths.slice(0))),t.rings&&(i=f(t.rings.slice(0))),(t.geometry||t.attributes)&&(i.type="Feature",i.geometry=t.geometry?v(t.geometry):null,i.properties=t.attributes?_(t.attributes):null,t.attributes&&(i.id=t.attributes[e]||t.attributes.OBJECTID||t.attributes.FID)),i}function b(t,e){e=e||"OBJECTID";var i,s={wkid:4326},r={};switch(t.type){case"Point":r.x=t.coordinates[0],r.y=t.coordinates[1],r.spatialReference=s;break;case"MultiPoint":r.points=t.coordinates.slice(0),r.spatialReference=s;break;case"LineString":r.paths=[t.coordinates.slice(0)],r.spatialReference=s;break;case"MultiLineString":r.paths=t.coordinates.slice(0),r.spatialReference=s;break;case"Polygon":r.rings=y(t.coordinates.slice(0)),r.spatialReference=s;break;case"MultiPolygon":r.rings=g(t.coordinates.slice(0)),r.spatialReference=s;break;case"Feature":t.geometry&&(r.geometry=b(t.geometry,e)),r.attributes=t.properties?_(t.properties):{},t.id&&(r.attributes[e]=t.id);break;case"FeatureCollection":for(r=[],i=0;i<t.features.length;i++)r.push(b(t.features[i],e));break;case"GeometryCollection":for(r=[],i=0;i<t.geometries.length;i++)r.push(b(t.geometries[i],e))}return r}function x(t,e){return b(t,e)}function S(t,e){return v(t,e)}function A(t){if("NaN"!==t.xmin&&"NaN"!==t.ymin&&"NaN"!==t.xmax&&"NaN"!==t.ymax){var i=e.latLng(t.ymin,t.xmin),s=e.latLng(t.ymax,t.xmax);return e.latLngBounds(i,s)}return null}function T(t){return t=e.latLngBounds(t),{xmin:t.getSouthWest().lng,ymin:t.getSouthWest().lat,xmax:t.getNorthEast().lng,ymax:t.getNorthEast().lat,spatialReference:{wkid:4326}}}function I(t,e){var i,s=t.features||t.results,r=s.length;if(e)i=e;else if(t.objectIdFieldName)i=t.objectIdFieldName;else if(t.fields){for(var n=0;n<=t.fields.length-1;n++)if("esriFieldTypeOID"===t.fields[n].type){i=t.fields[n].name;break}}else if(r)for(var o in s[0].attributes)if(o.match(/^(OBJECTID|FID|OID|ID)$/i)){i=o;break}var a={type:"FeatureCollection",features:[]};if(r)for(var u=s.length-1;u>=0;u--){var l=S(s[u],i);a.features.push(l)}return a}function w(t){return"/"!==(t=e.Util.trim(t))[t.length-1]&&(t+="/"),t}function R(t){return/^(?!.*utility\.arcgis\.com).*\.arcgis\.com.*FeatureServer/i.test(t)}function C(t){var 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 O(){console&&console.warn&&console.warn.apply(console,arguments)}function F(t){return t.getSize().x-Q.attributionWidthOffset+"px"}function P(t){if(t.attributionControl&&!t.attributionControl._esriAttributionAdded){t.attributionControl.setPrefix('<a href="http://leafletjs.com" title="A JS library for interactive maps">Leaflet</a> | Powered by <a href="https://www.esri.com">Esri</a>');var i=document.createElement("style");i.type="text/css",i.innerHTML=".esri-truncated-attribution:hover {white-space: normal;}",document.getElementsByTagName("head")[0].appendChild(i),e.DomUtil.addClass(t.attributionControl._container,"esri-truncated-attribution:hover");var s=document.createElement("style");s.type="text/css",s.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: "+F(t)+";}",document.getElementsByTagName("head")[0].appendChild(s),e.DomUtil.addClass(t.attributionControl._container,"esri-truncated-attribution"),t.on("resize",function(e){t.attributionControl._container.style.maxWidth=F(e.target)}),t.attributionControl._esriAttributionAdded=!0}}function k(t,i){a(t,{},e.Util.bind(function(t,s){if(!t){i._esriAttributions=[];for(var r=0;r<s.contributors.length;r++)for(var n=s.contributors[r],o=0;o<n.coverageAreas.length;o++){var a=n.coverageAreas[o],u=e.latLng(a.bbox[0],a.bbox[1]),l=e.latLng(a.bbox[2],a.bbox[3]);i._esriAttributions.push({attribution:n.attribution,score:a.score,bounds:e.latLngBounds(u,l),minZoom:a.zoomMin,maxZoom:a.zoomMax})}i._esriAttributions.sort(function(t,e){return e.score-t.score}),M({target:i})}},this))}function M(t){var i=t.target,s=i._esriAttributions;if(i&&i.attributionControl&&s){for(var r="",n=i.getBounds(),o=e.latLngBounds(n.getSouthWest().wrap(),n.getNorthEast().wrap()),a=i.getZoom(),u=0;u<s.length;u++){var l=s[u],h=l.attribution;!r.match(h)&&l.bounds.intersects(o)&&a>=l.minZoom&&a<=l.maxZoom&&(r+=", "+h)}r=r.substr(2);var c=i.attributionControl._container.querySelector(".esri-dynamic-attribution");c.innerHTML=r,c.style.maxWidth=F(i),i.fire("attributionupdated",{attribution:r})}}function G(t){return new Y(t)}function E(t){return new tt(t)}function U(t){return new it(t)}function q(t){return new st(t)}function D(t){return new nt(t)}function B(t){return new ot(t)}function z(t){return new at(t)}function N(t){this.values=[].concat(t||[])}var j="default"in e?e.default:e,Z=window.XMLHttpRequest&&"withCredentials"in new window.XMLHttpRequest,W=""===document.documentElement.style.pointerEvents,J={cors:Z,pointerEvents:W},Q={attributionWidthOffset:55},H=0,V=J.cors?n:a;V.CORS=n,V.JSONP=a;var K={request:o,get:V,post:r},X={shallowClone:function(t){var e={};for(var i in t)t.hasOwnProperty(i)&&(e[i]=t[i]);return e},warn:O,cleanUrl:w,isArcgisOnline:R,geojsonTypeToArcGIS:C,responseToFeatureCollection:I,geojsonToArcGIS:x,arcgisToGeoJSON:S,boundsToExtent:T,extentToBounds:A,calcAttributionWidth:F,setEsriAttribution:P,_getAttributionData:k,_updateMapAttribution:M},$=e.Class.extend({options:{proxy:!1,useCors:Z},generateSetter:function(t,i){return e.Util.bind(function(e){return this.params[t]=e,this},i)},initialize:function(t){if(t.request&&t.options?(this._service=t,e.Util.setOptions(this,t.options)):(e.Util.setOptions(this,t),this.options.url=w(t.url)),this.params=e.Util.extend({},this.params||{}),this.setters)for(var i in this.setters){var s=this.setters[i];this[i]=this.generateSetter(s,this)}},token:function(t){return this._service?this._service.authenticate(t):this.params.token=t,this},request:function(t,e){return this._service?this._service.request(this.path,this.params,t,e):this._request("request",this.path,this.params,t,e)},_request:function(t,e,i,s,r){var n=this.options.proxy?this.options.proxy+"?"+this.options.url+e:this.options.url+e;return"get"!==t&&"request"!==t||this.options.useCors?K[t](n,i,s,r):K.get.JSONP(n,i,s,r)}}),Y=$.extend({setters:{offset:"resultOffset",limit:"resultRecordCount",fields:"outFields",precision:"geometryPrecision",featureIds:"objectIds",returnGeometry:"returnGeometry",token:"token"},path:"query",params:{returnGeometry:!0,where:"1=1",outSr:4326,outFields:"*"},within:function(t){return this._setGeometry(t),this.params.spatialRel="esriSpatialRelContains",this},intersects:function(t){return this._setGeometry(t),this.params.spatialRel="esriSpatialRelIntersects",this},contains:function(t){return this._setGeometry(t),this.params.spatialRel="esriSpatialRelWithin",this},crosses:function(t){return this._setGeometry(t),this.params.spatialRel="esriSpatialRelCrosses",this},touches:function(t){return this._setGeometry(t),this.params.spatialRel="esriSpatialRelTouches",this},overlaps:function(t){return this._setGeometry(t),this.params.spatialRel="esriSpatialRelOverlaps",this},bboxIntersects:function(t){return this._setGeometry(t),this.params.spatialRel="esriSpatialRelEnvelopeIntersects",this},indexIntersects:function(t){return this._setGeometry(t),this.params.spatialRel="esriSpatialRelIndexIntersects",this},nearby:function(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:function(t){return this.params.where=t,this},between:function(t,e){return this.params.time=[t.valueOf(),e.valueOf()],this},simplify:function(t,e){var i=Math.abs(t.getBounds().getWest()-t.getBounds().getEast());return this.params.maxAllowableOffset=i/t.getSize().y*e,this},orderBy:function(t,e){return e=e||"ASC",this.params.orderByFields=this.params.orderByFields?this.params.orderByFields+",":"",this.params.orderByFields+=[t,e].join(" "),this},run:function(t,e){return this._cleanParams(),this.options.isModern||R(this.options.url)?(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&&I(s),s)},this)},count:function(t,e){return this._cleanParams(),this.params.returnCountOnly=!0,this.request(function(e,i){t.call(this,e,i&&i.count,i)},e)},ids:function(t,e){return this._cleanParams(),this.params.returnIdsOnly=!0,this.request(function(e,i){t.call(this,e,i&&i.objectIds,i)},e)},bounds:function(t,e){return this._cleanParams(),this.params.returnExtentOnly=!0,this.request(function(i,s){s&&s.extent&&A(s.extent)?t.call(e,i,A(s.extent),s):(i={message:"Invalid Bounds"},t.call(e,i,null,s))},e)},pixelSize:function(t){var i=e.point(t);return this.params.pixelSize=[i.x,i.y],this},layer:function(t){return this.path=t+"/query",this},_trapSQLerrors:function(t){t&&"400"===t.code&&O("one common syntax error in query requests is encasing string values in double quotes instead of single quotes")},_cleanParams:function(){delete this.params.returnIdsOnly,delete this.params.returnExtentOnly,delete this.params.returnCountOnly},_setGeometry:function(t){return this.params.inSr=4326,t instanceof e.LatLngBounds?(this.params.geometry=T(t),void(this.params.geometryType="esriGeometryEnvelope")):(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,this.params.geometry=x(t),this.params.geometryType=C(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?(this.params.geometry=x(t),void(this.params.geometryType=C(t.type))):void O("invalid geometry passed to spatial query. Should be L.LatLng, L.LatLngBounds, L.Marker or a GeoJSON Point, Line, Polygon or MultiPolygon object"))}}),tt=$.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:function(t,e){return this.params.layerDefs=this.params.layerDefs?this.params.layerDefs+";":"",this.params.layerDefs+=[t,e].join(":"),this},simplify:function(t,e){var i=Math.abs(t.getBounds().getWest()-t.getBounds().getEast());return this.params.maxAllowableOffset=i/t.getSize().y*e,this},run:function(t,e){return this.request(function(i,s){t.call(e,i,s&&I(s),s)},e)}}),et=$.extend({path:"identify",between:function(t,e){return this.params.time=[t.valueOf(),e.valueOf()],this}}),it=et.extend({setters:{layers:"layers",precision:"geometryPrecision",tolerance:"tolerance",returnGeometry:"returnGeometry"},params:{sr:4326,layers:"all",tolerance:3,returnGeometry:!0},on:function(t){var e=T(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:function(t){return t=e.latLng(t),this.params.geometry=[t.lng,t.lat],this.params.geometryType="esriGeometryPoint",this},layerDef:function(t,e){return this.params.layerDefs=this.params.layerDefs?this.params.layerDefs+";":"",this.params.layerDefs+=[t,e].join(":"),this},simplify:function(t,e){var i=Math.abs(t.getBounds().getWest()-t.getBounds().getEast());return this.params.maxAllowableOffset=i/t.getSize().y*e,this},run:function(t,e){return this.request(function(i,s){if(i)t.call(e,i,void 0,s);else{var r=I(s);s.results=s.results.reverse();for(var n=0;n<r.features.length;n++)r.features[n].layerId=s.results[n].layerId;t.call(e,void 0,r,s)}})}}),st=et.extend({setters:{setMosaicRule:"mosaicRule",setRenderingRule:"renderingRule",setPixelSize:"pixelSize",returnCatalogItems:"returnCatalogItems",returnGeometry:"returnGeometry"},params:{returnGeometry:!1},at:function(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:function(){return this.params.mosaicRule},getRenderingRule:function(){return this.params.renderingRule},getPixelSize:function(){return this.params.pixelSize},run:function(t,e){return this.request(function(i,s){t.call(e,i,s&&this._responseToGeoJSON(s),s)},this)},_responseToGeoJSON:function(t){var 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=I(i),s&&s.length===r.catalogItems.features.length))for(var n=s.length-1;n>=0;n--)r.catalogItems.features[n].properties.catalogItemVisibility=s[n];return r}}),rt=e.Evented.extend({options:{proxy:!1,useCors:Z,timeout:0},initialize:function(t){t=t||{},this._requestQueue=[],this._authenticating=!1,e.Util.setOptions(this,t),this.options.url=w(this.options.url)},get:function(t,e,i,s){return this._request("get",t,e,i,s)},post:function(t,e,i,s){return this._request("post",t,e,i,s)},request:function(t,e,i,s){return this._request("request",t,e,i,s)},metadata:function(t,e){return this._request("get","",{},t,e)},authenticate:function(t){return this._authenticating=!1,this.options.token=t,this._runQueue(),this},getTimeout:function(){return this.options.timeout},setTimeout:function(t){this.options.timeout=t},_request:function(t,e,i,s,r){this.fire("requeststart",{url:this.options.url+e,params:i,method:t},!0);var n=this._createServiceCallback(t,e,i,s,r);this.options.token&&(i.token=this.options.token);{if(!this._authenticating){var o=this.options.proxy?this.options.proxy+"?"+this.options.url+e:this.options.url+e;return"get"!==t&&"request"!==t||this.options.useCors?K[t](o,i,n,r):K.get.JSONP(o,i,n,r)}this._requestQueue.push([t,e,i,s,r])}},_createServiceCallback:function(t,i,s,r,n){return e.Util.bind(function(o,a){!o||499!==o.code&&498!==o.code||(this._authenticating=!0,this._requestQueue.push([t,i,s,r,n]),this.fire("authenticationrequired",{authenticate:e.Util.bind(this.authenticate,this)},!0),o.authenticate=e.Util.bind(this.authenticate,this)),r.call(n,o,a),o?this.fire("requesterror",{url:this.options.url+i,params:s,message:o.message,code:o.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:function(){for(var t=this._requestQueue.length-1;t>=0;t--){var e=this._requestQueue[t];this[e.shift()].apply(this,e)}this._requestQueue=[]}}),nt=rt.extend({identify:function(){return U(this)},find:function(){return E(this)},query:function(){return G(this)}}),ot=rt.extend({query:function(){return G(this)},identify:function(){return q(this)}}),at=rt.extend({options:{idAttribute:"OBJECTID"},query:function(){return G(this)},addFeature:function(t,e,i){return delete t.id,t=x(t),this.post("addFeatures",{features:[t]},function(t,s){var r=s&&s.addResults?s.addResults[0]:void 0;e&&e.call(i,t||s.addResults[0].error,r)},i)},updateFeature:function(t,e,i){return t=x(t,this.options.idAttribute),this.post("updateFeatures",{features:[t]},function(t,s){var r=s&&s.updateResults?s.updateResults[0]:void 0;e&&e.call(i,t||s.updateResults[0].error,r)},i)},deleteFeature:function(t,e,i){return this.post("deleteFeatures",{objectIds:t},function(t,s){var r=s&&s.deleteResults?s.deleteResults[0]:void 0;e&&e.call(i,t||s.deleteResults[0].error,r)},i)},deleteFeatures:function(t,e,i){return this.post("deleteFeatures",{objectIds:t},function(t,s){var r=s&&s.deleteResults?s.deleteResults:void 0;e&&e.call(i,t||s.deleteResults[0].error,r)},i)}}),ut="https:"!==window.location.protocol?"http:":"https:",lt=e.TileLayer.extend({statics:{TILES:{Streets:{urlTemplate:ut+"//{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:ut+"//{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:ut+"//{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:ut+"//{s}.arcgisonline.com/arcgis/rest/services/Ocean/World_Ocean_Reference/MapServer/tile/{z}/{y}/{x}",options:{minZoom:1,maxZoom:16,subdomains:["server","services"],pane:W?"esri-labels":"tilePane"}},NationalGeographic:{urlTemplate:ut+"//{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:ut+"//{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:ut+"//{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:W?"esri-labels":"tilePane",attribution:""}},Gray:{urlTemplate:ut+"//{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:ut+"//{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:W?"esri-labels":"tilePane",attribution:""}},Imagery:{urlTemplate:ut+"//{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"}},ImageryLabels:{urlTemplate:ut+"//{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:W?"esri-labels":"tilePane",attribution:""}},ImageryTransportation:{urlTemplate:ut+"//{s}.arcgisonline.com/ArcGIS/rest/services/Reference/World_Transportation/MapServer/tile/{z}/{y}/{x}",options:{minZoom:1,maxZoom:19,subdomains:["server","services"],pane:W?"esri-labels":"tilePane"}},ShadedRelief:{urlTemplate:ut+"//{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:ut+"//{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:W?"esri-labels":"tilePane",attribution:""}},Terrain:{urlTemplate:ut+"//{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:ut+"//{s}.arcgisonline.com/ArcGIS/rest/services/Reference/World_Reference_Overlay/MapServer/tile/{z}/{y}/{x}",options:{minZoom:1,maxZoom:13,subdomains:["server","services"],pane:W?"esri-labels":"tilePane",attribution:""}},USATopo:{urlTemplate:ut+"//{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"}}}},initialize:function(t,i){var s;if("object"==typeof t&&t.urlTemplate&&t.options)s=t;else{if("string"!=typeof t||!lt.TILES[t])throw new Error('L.esri.BasemapLayer: Invalid parameter. Use one of "Streets", "Topographic", "Oceans", "OceansLabels", "NationalGeographic", "Gray", "GrayLabels", "DarkGray", "DarkGrayLabels", "Imagery", "ImageryLabels", "ImageryTransportation", "ShadedRelief", "ShadedReliefLabels", "Terrain", "TerrainLabels" or "USATopo"');s=lt.TILES[t]}var r=e.Util.extend(s.options,i);e.Util.setOptions(this,r),this.options.token&&(s.urlTemplate+="?token="+this.options.token),e.TileLayer.prototype.initialize.call(this,s.urlTemplate,r)},onAdd:function(t){P(t),"esri-labels"===this.options.pane&&this._initPane(),this.options.attributionUrl&&k(this.options.attributionUrl,t),t.on("moveend",M),e.TileLayer.prototype.onAdd.call(this,t)},onRemove:function(t){t.off("moveend",M),e.TileLayer.prototype.onRemove.call(this,t)},_initPane:function(){if(!this._map.getPane(this.options.pane)){var t=this._map.createPane(this.options.pane);t.style.pointerEvents="none",t.style.zIndex=500}},getAttribution:function(){if(this.options.attribution)var t='<span class="esri-dynamic-attribution">'+this.options.attribution+"</span>";return t}}),ht=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:function(t){t.url=w(t.url),t=e.Util.setOptions(this,t),this.tileUrl=t.url+"tile/{z}/{y}/{x}",this.service=D(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:function(t){var 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&&this._lodMap[i]?this._lodMap[i]:i},this.options))},createTile:function(t,e){var i=document.createElement("img");return L.DomEvent.on(i,"load",L.bind(this._tileOnLoad,this,e,i)),L.DomEvent.on(i,"error",L.bind(this._tileOnError,this,e,i)),this.options.crossOrigin&&(i.crossOrigin=""),i.alt="",!this._lodMap||this._lodMap&&this._lodMap[this._getZoomForUrl()]?i.src=this.getTileUrl(t):this.once("lodmap",function(){i.src=this.getTileUrl(t)},this),i},onAdd:function(t){P(t),this._lodMap||this.metadata(function(e,i){if(!e&&i.spatialReference){var s=i.spatialReference.latestWkid||i.spatialReference.wkid;if(!this.options.attribution&&t.attributionControl&&i.copyrightText&&(this.options.attribution=i.copyrightText,t.attributionControl.addAttribution(this.getAttribution())),t.options.crs===L.CRS.EPSG3857&&102100===s||3857===s){this._lodMap={};for(var r=i.tileInfo.lods,n=ht.MercatorZoomLevels,o=0;o<r.length;o++){var a=r[o];for(var u in n){var l=n[u];if(this._withinPercentage(a.resolution,l,this.options.zoomOffsetAllowance)){this._lodMap[u]=a.level;break}}}this.fire("lodmap")}else proj4||O("L.esri.TiledMapLayer is using a non-mercator spatial reference. Support may be available through Proj4Leaflet http://esri.github.io/esri-leaflet/examples/non-mercator-projection.html")}},this),e.TileLayer.prototype.onAdd.call(this,t)},metadata:function(t,e){return this.service.metadata(t,e),this},identify:function(){return this.service.identify()},find:function(){return this.service.find()},query:function(){return this.service.query()},authenticate:function(t){var 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:function(t,e,i){return Math.abs(t/e-1)<i}}),ct=e.ImageOverlay.extend({onAdd:function(t){this._topLeft=t.getPixelBounds().min,e.ImageOverlay.prototype.onAdd.call(this,t)},_reset:function(){this._map.options.crs===e.CRS.EPSG3857?e.ImageOverlay.prototype._reset.call(this):e.DomUtil.setPosition(this._image,this._topLeft.subtract(this._map.getPixelOrigin()))}}),pt=e.Layer.extend({options:{opacity:1,position:"front",f:"image",useCors:Z,attribution:null,interactive:!1,alt:""},onAdd:function(t){P(t),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:function(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:function(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:function(){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:function(){return this.options.position="front",this._currentImage&&this._currentImage.bringToFront(),this},bringToBack:function(){return this.options.position="back",this._currentImage&&this._currentImage.bringToBack(),this},getAttribution:function(){return this.options.attribution},getOpacity:function(){return this.options.opacity},setOpacity:function(t){return this.options.opacity=t,this._currentImage&&this._currentImage.setOpacity(t),this},getTimeRange:function(){return[this.options.from,this.options.to]},setTimeRange:function(t,e){return this.options.from=t,this.options.to=e,this._update(),this},metadata:function(t,e){return this.service.metadata(t,e),this},authenticate:function(t){return this.service.authenticate(t),this},redraw:function(){this._update()},_renderImage:function(t,e,i){this._map&&(i&&(t="data:"+i+";base64,"+t),new ct(t,e,{opacity:0,crossOrigin:this.options.useCors,alt:this.options.alt,pane:this.options.pane||this.getPane(),interactive:this.options.interactive}).addTo(this._map).once("load",function(t){if(this._map){var 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():this.bringToBack(),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})},this),this.fire("loading",{bounds:e}))},_update:function(){if(this._map){var t=this._map.getZoom(),e=this._map.getBounds();if(!(this._animatingZoom||this._map._panTransition&&this._map._panTransition._inProgress))if(t>this.options.maxZoom||t<this.options.minZoom)this._currentImage&&(this._currentImage._map.removeLayer(this._currentImage),this._currentImage=null);else{var i=this._buildExportParams();this._requestExport(i,e)}}},_renderPopup:function(t,i,s,r){if(t=e.latLng(t),this._shouldRenderPopup&&this._lastClick.equals(t)){var n=this._popupFunction(i,s,r);n&&this._popup.setLatLng(t).setContent(n).openOn(this._map)}},_resetPopupState:function(t){this._shouldRenderPopup=!1,this._lastClick=t.latlng}}),dt=pt.extend({options:{updateInterval:150,format:"jpgpng",transparent:!0,f:"json"},query:function(){return this.service.query()},identify:function(){return this.service.identify()},initialize:function(t){t.url=w(t.url),this.service=B(t),this.service.addEventParent(this),e.Util.setOptions(this,t)},setPixelType:function(t){return this.options.pixelType=t,this._update(),this},getPixelType:function(){return this.options.pixelType},setBandIds:function(t){return e.Util.isArray(t)?this.options.bandIds=t.join(","):this.options.bandIds=t.toString(),this._update(),this},getBandIds:function(){return this.options.bandIds},setNoData:function(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:function(){return this.options.noData},getNoDataInterpretation:function(){return this.options.noDataInterpretation},setRenderingRule:function(t){this.options.renderingRule=t,this._update()},getRenderingRule:function(){return this.options.renderingRule},setMosaicRule:function(t){this.options.mosaicRule=t,this._update()},getMosaicRule:function(){return this.options.mosaicRule},_getPopupData:function(t){var 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:function(){var t=this._map.getBounds(),e=this._map.getSize(),i=this._map.options.crs.project(t._northEast),s=this._map.options.crs.project(t._southWest),r=this._map.latLngToLayerPoint(t._northEast),n=this._map.latLngToLayerPoint(t._southWest);(r.y>0||n.y<e.y)&&(e.y=n.y-r.y);var o=parseInt(this._map.options.crs.code.split(":")[1],10),a={bbox:[s.x,s.y,i.x,i.y].join(","),size:e.x+","+e.y,format:this.options.format,transparent:this.options.transparent,bboxSR:o,imageSR:o};return this.options.from&&this.options.to&&(a.time=this.options.from.valueOf()+","+this.options.to.valueOf()),this.options.pixelType&&(a.pixelType=this.options.pixelType),this.options.interpolation&&(a.interpolation=this.options.interpolation),this.options.compressionQuality&&(a.compressionQuality=this.options.compressionQuality),this.options.bandIds&&(a.bandIds=this.options.bandIds),this.options.noData&&(a.noData=this.options.noData),this.options.noDataInterpretation&&(a.noDataInterpretation=this.options.noDataInterpretation),this.service.options.token&&(a.token=this.service.options.token),this.options.renderingRule&&(a.renderingRule=JSON.stringify(this.options.renderingRule)),this.options.mosaicRule&&(a.mosaicRule=JSON.stringify(this.options.mosaicRule)),a},_requestExport:function(t,i){"json"===this.options.f?this.service.request("exportImage",t,function(t,e){t||(this.options.token&&(e.href+="?token="+this.options.token),this._renderImage(e.href,i))},this):(t.f="image",this._renderImage(this.options.url+"exportImage"+e.Util.getParamString(t),i))}}),mt=pt.extend({options:{updateInterval:150,layers:!1,layerDefs:!1,timeOptions:!1,format:"png24",transparent:!0,f:"json"},initialize:function(t){t.url=w(t.url),this.service=D(t),this.service.addEventParent(this),(t.proxy||t.token)&&"json"!==t.f&&(t.f="json"),e.Util.setOptions(this,t)},getDynamicLayers:function(){return this.options.dynamicLayers},setDynamicLayers:function(t){return this.options.dynamicLayers=t,this._update(),this},getLayers:function(){return this.options.layers},setLayers:function(t){return this.options.layers=t,this._update(),this},getLayerDefs:function(){return this.options.layerDefs},setLayerDefs:function(t){return this.options.layerDefs=t,this._update(),this},getTimeOptions:function(){return this.options.timeOptions},setTimeOptions:function(t){return this.options.timeOptions=t,this._update(),this},query:function(){return this.service.query()},identify:function(){return this.service.identify()},find:function(){return this.service.find()},_getPopupData:function(t){var 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().on(this._map).at(t.latlng);s.simplify(this._map,.5),this.options.layers?s.layers("visible:"+this.options.layers.join(",")):s.layers("visible"),s.run(i),this._shouldRenderPopup=!0,this._lastClick=t.latlng},_buildExportParams:function(){var t=this._map.getBounds(),e=this._map.getSize(),i=this._map.options.crs.project(t.getNorthEast()),s=this._map.options.crs.project(t.getSouthWest()),r=parseInt(this._map.options.crs.code.split(":")[1],10),n=this._map.latLngToLayerPoint(t._northEast),o=this._map.latLngToLayerPoint(t._southWest);(n.y>0||o.y<e.y)&&(e.y=o.y-n.y);var a={bbox:[s.x,s.y,i.x,i.y].join(","),size:e.x+","+e.y,dpi:96,format:this.options.format,transparent:this.options.transparent,bboxSR:r,imageSR:r};return this.options.dynamicLayers&&(a.dynamicLayers=this.options.dynamicLayers),this.options.layers&&(a.layers="show:"+this.options.layers.join(",")),this.options.layerDefs&&(a.layerDefs="string"==typeof this.options.layerDefs?this.options.layerDefs:JSON.stringify(this.options.layerDefs)),this.options.timeOptions&&(a.timeOptions=JSON.stringify(this.options.timeOptions)),this.options.from&&this.options.to&&(a.time=this.options.from.valueOf()+","+this.options.to.valueOf()),this.service.options.token&&(a.token=this.service.options.token),this.options.proxy&&(a.proxy=this.options.proxy),a},_requestExport:function(t,i){"json"===this.options.f?this.service.request("export",t,function(t,e){t||(this.options.token&&(e.href+="?token="+this.options.token),this.options.proxy&&(e.href=this.options.proxy+"?"+e.href),e.href?this._renderImage(e.href,i):this._renderImage(e.imageData,i,e.contentType))},this):(t.f="image",this._renderImage(this.options.url+"export"+e.Util.getParamString(t),i))}}),ft=j.Layer.extend({options:{cellSize:512,updateInterval:150},initialize:function(t){t=j.setOptions(this,t),this._zooming=!1},onAdd:function(t){this._map=t,this._update=j.Util.throttle(this._update,this.options.updateInterval,this),this._reset(),this._update()},onRemove:function(){this._map.removeEventListener(this.getEvents(),this),this._removeCells()},getEvents:function(){return{moveend:this._update,zoomstart:this._zoomstart,zoomend:this._reset}},addTo:function(t){return t.addLayer(this),this},removeFrom:function(t){return t.removeLayer(this),this},_zoomstart:function(){this._zooming=!0},_reset:function(){this._removeCells(),this._cells={},this._activeCells={},this._cellsToLoad=0,this._cellsTotal=0,this._cellNumBounds=this._getCellNumBounds(),this._resetWrap(),this._zooming=!1},_resetWrap:function(){var t=this._map,e=t.options.crs;if(!e.infinite){var i=this._getCellSize();e.wrapLng&&(this._wrapLng=[Math.floor(t.project([0,e.wrapLng[0]]).x/i),Math.ceil(t.project([0,e.wrapLng[1]]).x/i)]),e.wrapLat&&(this._wrapLat=[Math.floor(t.project([e.wrapLat[0],0]).y/i),Math.ceil(t.project([e.wrapLat[1],0]).y/i)])}},_getCellSize:function(){return this.options.cellSize},_update:function(){if(this._map){var t=this._map.getPixelBounds(),e=this._getCellSize(),i=j.bounds(t.min.divideBy(e).floor(),t.max.divideBy(e).floor());this._removeOtherCells(i),this._addCells(i),this.fire("cellsupdated")}},_addCells:function(t){var e,i,s,r=[],n=t.getCenter(),o=this._map.getZoom();for(e=t.min.y;e<=t.max.y;e++)for(i=t.min.x;i<=t.max.x;i++)(s=j.point(i,e)).z=o,this._isValidCell(s)&&r.push(s);var a=r.length;if(0!==a)for(this._cellsToLoad+=a,this._cellsTotal+=a,r.sort(function(t,e){return t.distanceTo(n)-e.distanceTo(n)}),i=0;i<a;i++)this._addCell(r[i])},_isValidCell:function(t){var e=this._map.options.crs;if(!e.infinite){var i=this._cellNumBounds;if(!e.wrapLng&&(t.x<i.min.x||t.x>i.max.x)||!e.wrapLat&&(t.y<i.min.y||t.y>i.max.y))return!1}if(!this.options.bounds)return!0;var s=this._cellCoordsToBounds(t);return j.latLngBounds(this.options.bounds).intersects(s)},_cellCoordsToBounds:function(t){var e=this._map,i=this.options.cellSize,s=t.multiplyBy(i),r=s.add([i,i]),n=e.wrapLatLng(e.unproject(s,t.z)),o=e.wrapLatLng(e.unproject(r,t.z));return j.latLngBounds(n,o)},_cellCoordsToKey:function(t){return t.x+":"+t.y},_keyToCellCoords:function(t){var e=t.split(":"),i=parseInt(e[0],10),s=parseInt(e[1],10);return j.point(i,s)},_removeOtherCells:function(t){for(var e in this._cells)t.contains(this._keyToCellCoords(e))||this._removeCell(e)},_removeCell:function(t){var e=this._activeCells[t];e&&(delete this._activeCells[t],this.cellLeave&&this.cellLeave(e.bounds,e.coords),this.fire("cellleave",{bounds:e.bounds,coords:e.coords}))},_removeCells:function(){for(var t in this._cells){var e=this._cells[t].bounds,i=this._cells[t].coords;this.cellLeave&&this.cellLeave(e,i),this.fire("cellleave",{bounds:e,coords:i})}},_addCell:function(t){this._wrapCoords(t);var e=this._cellCoordsToKey(t),i=this._cells[e];i&&!this._activeCells[e]&&(this.cellEnter&&this.cellEnter(i.bounds,t),this.fire("cellenter",{bounds:i.bounds,coords:t}),this._activeCells[e]=i),i||(i={coords:t,bounds:this._cellCoordsToBounds(t)},this._cells[e]=i,this._activeCells[e]=i,this.createCell&&this.createCell(i.bounds,t),this.fire("cellcreate",{bounds:i.bounds,coords:t}))},_wrapCoords:function(t){t.x=this._wrapLng?j.Util.wrapNum(t.x,this._wrapLng):t.x,t.y=this._wrapLat?j.Util.wrapNum(t.y,this._wrapLat):t.y},_getCellNumBounds:function(){var t=this._map.getPixelWorldBounds(),e=this._getCellSize();return t?j.bounds(t.min.divideBy(e).floor(),t.max.divideBy(e).ceil().subtract([1,1])):null}});N.prototype.query=function(t){var e=this.getIndex(t);return this.values[e]},N.prototype.getIndex=function(t){this.dirty&&this.sort();for(var e,i,s=0,r=this.values.length-1;s<=r;)if(e=(s+r)/2|0,+(i=this.values[Math.round(e)]).value<+t)s=e+1;else{if(!(+i.value>+t))return e;r=e-1}return Math.abs(~r)},N.prototype.between=function(t,e){var i=this.getIndex(t),s=this.getIndex(e);if(0===i&&0===s)return[];for(;this.values[i-1]&&this.values[i-1].value===t;)i--;for(;this.values[s+1]&&this.values[s+1].value===e;)s++;return this.values[s]&&this.values[s].value===e&&this.values[s+1]&&s++,this.values.slice(i,s)},N.prototype.insert=function(t){return this.values.splice(this.getIndex(t.value),0,t),this},N.prototype.bulkAdd=function(t,e){return this.values=this.values.concat([].concat(t||[])),e?this.sort():this.dirty=!0,this},N.prototype.sort=function(){return this.values.sort(function(t,e){return+e.value-+t.value}).reverse(),this.dirty=!1,this};var yt=ft.extend({options:{attribution:null,where:"1=1",fields:["*"],from:!1,to:!1,timeField:!1,timeFilterMode:"server",simplifyFactor:0,precision:6},initialize:function(t){if(ft.prototype.initialize.call(this,t),t.url=w(t.url),t=e.setOptions(this,t),this.service=z(t),this.service.addEventParent(this),"*"!==this.options.fields[0]){for(var i=!1,s=0;s<this.options.fields.length;s++)this.options.fields[s].match(/^(OBJECTID|FID|OID|ID)$/i)&&(i=!0);!1===i&&O("no known esriFieldTypeOID field detected in fields Array.  Please add an attribute field containing unique IDs to ensure the layer can be drawn correctly.")}this.options.timeField.start&&this.options.timeField.end?(this._startTimeIndex=new N,this._endTimeIndex=new N):this.options.timeField&&(this._timeIndex=new N),this._cache={},this._currentSnapshot=[],this._activeRequests=0},onAdd:function(t){return P(t),this.service.metadata(function(e,i){if(!e){var s=i.supportedQueryFormats,r=!1;!1===this.service.options.isModern&&(r=!0),!r&&s&&-1!==s.indexOf("geoJSON")&&(this.service.options.isModern=!0),!this.options.attribution&&t.attributionControl&&i.copyrightText&&(this.options.attribution=i.copyrightText,t.attributionControl.addAttribution(this.getAttribution()))}},this),t.on("zoomend",this._handleZoomChange,this),ft.prototype.onAdd.call(this,t)},onRemove:function(t){return t.off("zoomend",this._handleZoomChange,this),ft.prototype.onRemove.call(this,t)},getAttribution:function(){return this.options.attribution},createCell:function(t,e){this._visibleZoom()&&this._requestFeatures(t,e)},_requestFeatures:function(t,i,s){return this._activeRequests++,1===this._activeRequests&&this.fire("loading",{bounds:t},!0),this._buildQuery(t).run(function(r,n,o){o&&o.exceededTransferLimit&&this.fire("drawlimitexceeded"),!r&&n&&n.features.length&&e.Util.requestAnimFrame(e.Util.bind(function(){this._addFeatures(n.features,i),this._postProcessFeatures(t)},this)),r||!n||n.features.length||this._postProcessFeatures(t),r&&this._postProcessFeatures(t),s&&s.call(this,r,n)},this)},_postProcessFeatures:function(t){this._activeRequests--,this._activeRequests<=0&&this.fire("load",{bounds:t})},_cacheKey:function(t){return t.z+":"+t.x+":"+t.y},_addFeatures:function(t,e){var i=this._cacheKey(e);this._cache[i]=this._cache[i]||[];for(var s=t.length-1;s>=0;s--){var r=t[s].id;-1===this._currentSnapshot.indexOf(r)&&this._currentSnapshot.push(r),-1===this._cache[i].indexOf(r)&&this._cache[i].push(r)}this.options.timeField&&this._buildTimeIndexes(t),this.createLayers(t)},_buildQuery:function(t){var e=this.service.query().intersects(t).where(this.options.where).fields(this.options.fields).precision(this.options.precision);return this.options.simplifyFactor&&e.simplify(this._map,this.options.simplifyFactor),"server"===this.options.timeFilterMode&&this.options.from&&this.options.to&&e.between(this.options.from,this.options.to),e},setWhere:function(t,i,s){this.options.where=t&&t.length?t:"1=1";for(var r=[],n=[],o=0,a=null,u=e.Util.bind(function(t,u){if(t&&(a=t),u)for(var l=u.features.length-1;l>=0;l--)n.push(u.features[l].id);--o<=0&&(this._currentSnapshot=n,e.Util.requestAnimFrame(e.Util.bind(function(){this.removeLayers(r),this.addLayers(n),i&&i.call(s,a)},this)))},this),l=this._currentSnapshot.length-1;l>=0;l--)r.push(this._currentSnapshot[l]);for(var h in this._activeCells){o++;var c=this._keyToCellCoords(h),p=this._cellCoordsToBounds(c);this._requestFeatures(p,h,u)}return this},getWhere:function(){return this.options.where},getTimeRange:function(){return[this.options.from,this.options.to]},setTimeRange:function(t,i,s,r){var n=this.options.from,o=this.options.to,a=0,u=null,l=e.Util.bind(function(e){e&&(u=e),this._filterExistingFeatures(n,o,t,i),a--,s&&a<=0&&s.call(r,u)},this);if(this.options.from=t,this.options.to=i,this._filterExistingFeatures(n,o,t,i),"server"===this.options.timeFilterMode)for(var h in this._activeCells){a++;var c=this._keyToCellCoords(h),p=this._cellCoordsToBounds(c);this._requestFeatures(p,h,l)}return this},refresh:function(){for(var t in this._activeCells){var e=this._keyToCellCoords(t),i=this._cellCoordsToBounds(e);this._requestFeatures(i,t)}this.redraw&&this.once("load",function(){this.eachFeature(function(t){this._redraw(t.feature.id)},this)},this)},_filterExistingFeatures:function(t,i,s,r){var n=t&&i?this._getFeaturesInTimeRange(t,i):this._currentSnapshot,o=this._getFeaturesInTimeRange(s,r);if(o.indexOf)for(var a=0;a<o.length;a++){var u=n.indexOf(o[a]);u>=0&&n.splice(u,1)}e.Util.requestAnimFrame(e.Util.bind(function(){this.removeLayers(n),this.addLayers(o)},this))},_getFeaturesInTimeRange:function(t,e){var i,s=[];if(this.options.timeField.start&&this.options.timeField.end){var r=this._startTimeIndex.between(t,e),n=this._endTimeIndex.between(t,e);i=r.concat(n)}else i=this._timeIndex.between(t,e);for(var o=i.length-1;o>=0;o--)s.push(i[o].id);return s},_buildTimeIndexes:function(t){var e,i;if(this.options.timeField.start&&this.options.timeField.end){var s=[],r=[];for(e=t.length-1;e>=0;e--)i=t[e],s.push({id:i.id,value:new Date(i.properties[this.options.timeField.start])}),r.push({id:i.id,value:new Date(i.properties[this.options.timeField.end])});this._startTimeIndex.bulkAdd(s),this._endTimeIndex.bulkAdd(r)}else{var n=[];for(e=t.length-1;e>=0;e--)i=t[e],n.push({id:i.id,value:new Date(i.properties[this.options.timeField])});this._timeIndex.bulkAdd(n)}},_featureWithinTimeRange:function(t){if(!this.options.from||!this.options.to)return!0;var e=+this.options.from.valueOf(),i=+this.options.to.valueOf();if("string"==typeof this.options.timeField){var s=+t.properties[this.options.timeField];return s>=e&&s<=i}if(this.options.timeField.start&&this.options.timeField.end){var r=+t.properties[this.options.timeField.start],n=+t.properties[this.options.timeField.end];return r>=e&&r<=i||n>=e&&n<=i}},_visibleZoom:function(){if(!this._map)return!1;var t=this._map.getZoom();return!(t>this.options.maxZoom||t<this.options.minZoom)},_handleZoomChange:function(){if(this._visibleZoom())for(var t in this._activeCells){var e=this._activeCells[t].coords,i=this._cacheKey(e);this._cache[i]&&this.addLayers(this._cache[i])}else this.removeLayers(this._currentSnapshot),this._currentSnapshot=[]},authenticate:function(t){return this.service.authenticate(t),this},metadata:function(t,e){return this.service.metadata(t,e),this},query:function(){return this.service.query()},_getMetadata:function(t){if(this._metadata){t(void 0,this._metadata)}else this.metadata(e.Util.bind(function(e,i){this._metadata=i,t(e,this._metadata)},this))},addFeature:function(t,i,s){this._getMetadata(e.Util.bind(function(r,n){r?i&&i.call(this,r,null):this.service.addFeature(t,e.Util.bind(function(e,r){e||(t.properties[n.objectIdField]=r.objectId,t.id=r.objectId,this.createLayers([t])),i&&i.call(s,e,r)},this))},this))},updateFeature:function(t,e,i){this.service.updateFeature(t,function(s,r){s||(this.removeLayers([t.id],!0),this.createLayers([t])),e&&e.call(i,s,r)},this)},deleteFeature:function(t,e,i){this.service.deleteFeature(t,function(t,s){!t&&s.objectId&&this.removeLayers([s.objectId],!0),e&&e.call(i,t,s)},this)},deleteFeatures:function(t,e,i){return this.service.deleteFeatures(t,function(t,s){if(!t&&s.length>0)for(var r=0;r<s.length;r++)this.removeLayers([s[r].objectId],!0);e&&e.call(i,t,s)},this)}}),gt=yt.extend({options:{cacheLayers:!0},initialize:function(t){yt.prototype.initialize.call(this,t),this._originalStyle=this.options.style,this._layers={}},onRemove:function(t){for(var e in this._layers)t.removeLayer(this._layers[e]),this.fire("removefeature",{feature:this._layers[e].feature,permanent:!1},!0);return yt.prototype.onRemove.call(this,t)},createNewLayer:function(t){var i=e.GeoJSON.geometryToLayer(t,this.options);return i.defaultOptions=i.options,i},_updateLayer:function(t,i){var s=[],r=this.options.coordsToLatLng||e.GeoJSON.coordsToLatLng;switch(i.properties&&(t.feature.properties=i.properties),i.geometry.type){case"Point":s=e.GeoJSON.coordsToLatLng(i.geometry.coordinates),t.setLatLng(s);break;case"LineString":s=e.GeoJSON.coordsToLatLngs(i.geometry.coordinates,0,r),t.setLatLngs(s);break;case"MultiLineString":case"Polygon":s=e.GeoJSON.coordsToLatLngs(i.geometry.coordinates,1,r),t.setLatLngs(s);break;case"MultiPolygon":s=e.GeoJSON.coordsToLatLngs(i.geometry.coordinates,2,r),t.setLatLngs(s)}},createLayers:function(t){for(var e=t.length-1;e>=0;e--){var i,s=t[e],r=this._layers[s.id];this._visibleZoom()&&r&&!this._map.hasLayer(r)&&(this._map.addLayer(r),this.fire("addfeature",{feature:r.feature},!0)),r&&this.options.simplifyFactor>0&&(r.setLatLngs||r.setLatLng)&&this._updateLayer(r,s),r||((i=this.createNewLayer(s)).feature=s,i.addEventParent(this),this.options.onEachFeature&&this.options.onEachFeature(i.feature,i),this._layers[i.feature.id]=i,this.setFeatureStyle(i.feature.id,this.options.style),this.fire("createfeature",{feature:i.feature},!0),this._visibleZoom()&&(!this.options.timeField||this.options.timeField&&this._featureWithinTimeRange(s))&&this._map.addLayer(i))}},addLayers:function(t){for(var e=t.length-1;e>=0;e--){var i=this._layers[t[e]];i&&this._map.addLayer(i)}},removeLayers:function(t,e){for(var i=t.length-1;i>=0;i--){var s=t[i],r=this._layers[s];r&&(this.fire("removefeature",{feature:r.feature,permanent:e},!0),this._map.removeLayer(r)),r&&e&&delete this._layers[s]}},cellEnter:function(t,i){this._visibleZoom()&&!this._zooming&&this._map&&e.Util.requestAnimFrame(e.Util.bind(function(){var t=this._cacheKey(i),e=this._cellCoordsToKey(i),s=this._cache[t];this._activeCells[e]&&s&&this.addLayers(s)},this))},cellLeave:function(t,i){this._zooming||e.Util.requestAnimFrame(e.Util.bind(function(){if(this._map){var t=this._cacheKey(i),e=this._cellCoordsToKey(i),s=this._cache[t],r=this._map.getBounds();if(!this._activeCells[e]&&s){for(var n=!0,o=0;o<s.length;o++){var a=this._layers[s[o]];a&&a.getBounds&&r.intersects(a.getBounds())&&(n=!1)}n&&this.removeLayers(s,!this.options.cacheLayers),!this.options.cacheLayers&&n&&(delete this._cache[t],delete this._cells[e],delete this._activeCells[e])}}},this))},resetStyle:function(){return this.options.style=this._originalStyle,this.eachFeature(function(t){this.resetFeatureStyle(t.feature.id)},this),this},setStyle:function(t){return this.options.style=t,this.eachFeature(function(e){this.setFeatureStyle(e.feature.id,t)},this),this},resetFeatureStyle:function(t){var i=this._layers[t],s=this._originalStyle||L.Path.prototype.options;return i&&(e.Util.extend(i.options,i.defaultOptions),this.setFeatureStyle(t,s)),this},setFeatureStyle:function(t,e){var i=this._layers[t];return"function"==typeof e&&(e=e(i.feature)),i.setStyle&&i.setStyle(e),this},eachActiveFeature:function(t,e){if(this._map){var i=this._map.getBounds();for(var s in this._layers)i.intersects(this._layers[s].getBounds())&&-1!==this._currentSnapshot.indexOf(this._layers[s].feature.id)&&t.call(e,this._layers[s])}return this},eachFeature:function(t,e){for(var i in this._layers)t.call(e,this._layers[i]);return this},getFeature:function(t){return this._layers[t]},bringToBack:function(){this.eachFeature(function(t){t.bringToBack&&t.bringToBack()})},bringToFront:function(){this.eachFeature(function(t){t.bringToFront&&t.bringToFront()})},redraw:function(t){return t&&this._redraw(t),this},_redraw:function(t){var i=this._layers[t],s=i.feature;if(i&&i.setIcon&&this.options.pointToLayer&&this.options.pointToLayer){var r=this.options.pointToLayer(s,e.latLng(s.geometry.coordinates[1],s.geometry.coordinates[0])).options.icon;i.setIcon(r)}if(i&&i.setStyle&&this.options.pointToLayer){var n=this.options.pointToLayer(s,e.latLng(s.geometry.coordinates[1],s.geometry.coordinates[0])).options;this.setFeatureStyle(s.id,n)}i&&i.setStyle&&this.options.style&&this.resetStyle(s.id)}});t.VERSION="2.0.8",t.Support=J,t.options=Q,t.Util=X,t.get=V,t.post=r,t.request=o,t.Task=$,t.task=function(t){return new $(t)},t.Query=Y,t.query=G,t.Find=tt,t.find=E,t.Identify=et,t.identify=function(t){return new et(t)},t.IdentifyFeatures=it,t.identifyFeatures=U,t.IdentifyImage=st,t.identifyImage=q,t.Service=rt,t.service=function(t){return new rt(t)},t.MapService=nt,t.mapService=D,t.ImageService=ot,t.imageService=B,t.FeatureLayerService=at,t.featureLayerService=z,t.BasemapLayer=lt,t.basemapLayer=function(t,e){return new lt(t,e)},t.TiledMapLayer=ht,t.tiledMapLayer=function(t,e){return new ht(t,e)},t.RasterLayer=pt,t.ImageMapLayer=dt,t.imageMapLayer=function(t,e){return new dt(t,e)},t.DynamicMapLayer=mt,t.dynamicMapLayer=function(t,e){return new mt(t,e)},t.FeatureManager=yt,t.FeatureLayer=gt,t.featureLayer=function(t){return new gt(t)}});