UNPKG

29.4 kBJavaScriptView Raw
1/*! leaflet-xserver - v1.1.2 - 2019-12-19 */
2
3
4!function(a){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=a();else if("function"==typeof define&&define.amd)define([],a);else{var b;b="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,b.leafletXserver=a()}}(function(){return function(){function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);var j=new Error("Cannot find module '"+g+"'");throw j.code="MODULE_NOT_FOUND",j}var k=c[g]={exports:{}};b[g][0].call(k.exports,function(a){return e(b[g][1][a]||a)},k,k.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g<d.length;g++)e(d[g]);return e}return a}()({1:[function(a,b,c){function d(a){if(a)return e(a)}function e(a){for(var b in d.prototype)a[b]=d.prototype[b];return a}void 0!==b&&(b.exports=d),d.prototype.on=d.prototype.addEventListener=function(a,b){return this._callbacks=this._callbacks||{},(this._callbacks["$"+a]=this._callbacks["$"+a]||[]).push(b),this},d.prototype.once=function(a,b){function c(){this.off(a,c),b.apply(this,arguments)}return c.fn=b,this.on(a,c),this},d.prototype.off=d.prototype.removeListener=d.prototype.removeAllListeners=d.prototype.removeEventListener=function(a,b){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var c=this._callbacks["$"+a];if(!c)return this;if(1==arguments.length)return delete this._callbacks["$"+a],this;for(var d,e=0;e<c.length;e++)if((d=c[e])===b||d.fn===b){c.splice(e,1);break}return 0===c.length&&delete this._callbacks["$"+a],this},d.prototype.emit=function(a){this._callbacks=this._callbacks||{};for(var b=new Array(arguments.length-1),c=this._callbacks["$"+a],d=1;d<arguments.length;d++)b[d-1]=arguments[d];if(c){c=c.slice(0);for(var d=0,e=c.length;d<e;++d)c[d].apply(this,b)}return this},d.prototype.listeners=function(a){return this._callbacks=this._callbacks||{},this._callbacks["$"+a]||[]},d.prototype.hasListeners=function(a){return!!this.listeners(a).length}},{}],2:[function(a,b,c){function d(a,b,c){e(a,"",[],void 0);var d;for(d=0===k.length?JSON.stringify(a,b,c):JSON.stringify(a,i(b),c);0!==j.length;){var f=j.pop();4===f.length?Object.defineProperty(f[0],f[1],f[3]):f[0][f[1]]=f[2]}return d}function e(a,b,c,d){var f;if("object"==typeof a&&null!==a){for(f=0;f<c.length;f++)if(c[f]===a){var g=Object.getOwnPropertyDescriptor(d,b);return void(void 0!==g.get?g.configurable?(Object.defineProperty(d,b,{value:"[Circular]"}),j.push([d,b,a,g])):k.push([a,b]):(d[b]="[Circular]",j.push([d,b,a])))}if(c.push(a),Array.isArray(a))for(f=0;f<a.length;f++)e(a[f],f,c,a);else{var h=Object.keys(a);for(f=0;f<h.length;f++){var i=h[f];e(a[i],i,c,a)}}c.pop()}}function f(a,b){return a<b?-1:a>b?1:0}function g(a,b,c){var d,e=h(a,"",[],void 0)||a;for(d=0===k.length?JSON.stringify(e,b,c):JSON.stringify(e,i(b),c);0!==j.length;){var f=j.pop();4===f.length?Object.defineProperty(f[0],f[1],f[3]):f[0][f[1]]=f[2]}return d}function h(a,b,c,d){var e;if("object"==typeof a&&null!==a){for(e=0;e<c.length;e++)if(c[e]===a){var g=Object.getOwnPropertyDescriptor(d,b);return void(void 0!==g.get?g.configurable?(Object.defineProperty(d,b,{value:"[Circular]"}),j.push([d,b,a,g])):k.push([a,b]):(d[b]="[Circular]",j.push([d,b,a])))}if("function"==typeof a.toJSON)return;if(c.push(a),Array.isArray(a))for(e=0;e<a.length;e++)h(a[e],e,c,a);else{var i={},l=Object.keys(a).sort(f);for(e=0;e<l.length;e++){var m=l[e];h(a[m],m,c,a),i[m]=a[m]}if(void 0===d)return i;j.push([d,b,a]),d[b]=i}c.pop()}}function i(a){return a=void 0!==a?a:function(a,b){return b},function(b,c){if(k.length>0)for(var d=0;d<k.length;d++){var e=k[d];if(e[1]===b&&e[0]===c){c="[Circular]",k.splice(d,1);break}}return a.call(this,b,c)}}b.exports=d,d.default=d,d.stable=g,d.stableStringify=g;var j=[],k=[]},{}],3:[function(a,b,c){"use strict";function d(a){return g(a)||f(a)||e()}function e(){throw new TypeError("Invalid attempt to spread non-iterable instance")}function f(a){if(Symbol.iterator in Object(a)||"[object Arguments]"===Object.prototype.toString.call(a))return Array.from(a)}function g(a){if(Array.isArray(a)){for(var b=0,c=new Array(a.length);b<a.length;b++)c[b]=a[b];return c}}function h(){this._defaults=[]}["use","on","once","set","query","type","accept","auth","withCredentials","sortQuery","retry","ok","redirects","timeout","buffer","serialize","parse","ca","key","pfx","cert","disableTLSCerts"].forEach(function(a){h.prototype[a]=function(){for(var b=arguments.length,c=new Array(b),d=0;d<b;d++)c[d]=arguments[d];return this._defaults.push({fn:a,args:c}),this}}),h.prototype._setDefaults=function(a){this._defaults.forEach(function(b){a[b.fn].apply(a,d(b.args))})},b.exports=h},{}],4:[function(a,b,c){"use strict";function d(a){return(d="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a})(a)}function e(){}function f(a){if(!r(a))return a;var b=[];for(var c in a)Object.prototype.hasOwnProperty.call(a,c)&&g(b,c,a[c]);return b.join("&")}function g(a,b,c){if(void 0!==c){if(null===c)return void a.push(encodeURIComponent(b));if(Array.isArray(c))c.forEach(function(c){g(a,b,c)});else if(r(c))for(var d in c)Object.prototype.hasOwnProperty.call(c,d)&&g(a,"".concat(b,"[").concat(d,"]"),c[d]);else a.push(encodeURIComponent(b)+"="+encodeURIComponent(c))}}function h(a){for(var b,c,d={},e=a.split("&"),f=0,g=e.length;f<g;++f)b=e[f],c=b.indexOf("="),-1===c?d[decodeURIComponent(b)]="":d[decodeURIComponent(b.slice(0,c))]=decodeURIComponent(b.slice(c+1));return d}function i(a){for(var b,c,d,e,f=a.split(/\r?\n/),g={},h=0,i=f.length;h<i;++h)c=f[h],-1!==(b=c.indexOf(":"))&&(d=c.slice(0,b).toLowerCase(),e=v(c.slice(b+1)),g[d]=e);return g}function j(a){return/[\/+]json($|[^-\w])/.test(a)}function k(a){this.req=a,this.xhr=this.req.xhr,this.text="HEAD"!==this.req.method&&(""===this.xhr.responseType||"text"===this.xhr.responseType)||void 0===this.xhr.responseType?this.xhr.responseText:null,this.statusText=this.req.xhr.statusText;var b=this.xhr.status;1223===b&&(b=204),this._setStatusProperties(b),this.headers=i(this.xhr.getAllResponseHeaders()),this.header=this.headers,this.header["content-type"]=this.xhr.getResponseHeader("content-type"),this._setHeaderProperties(this.header),null===this.text&&a._responseType?this.body=this.xhr.response:this.body="HEAD"===this.req.method?null:this._parseBody(this.text?this.text:this.xhr.response)}function l(a,b){var c=this;this._query=this._query||[],this.method=a,this.url=b,this.header={},this._header={},this.on("end",function(){var a=null,b=null;try{b=new k(c)}catch(b){return a=new Error("Parser is unable to parse the response"),a.parse=!0,a.original=b,c.xhr?(a.rawResponse=void 0===c.xhr.responseType?c.xhr.responseText:c.xhr.response,a.status=c.xhr.status?c.xhr.status:null,a.statusCode=a.status):(a.rawResponse=null,a.status=null),c.callback(a)}c.emit("response",b);var d;try{c._isResponseOK(b)||(d=new Error(b.statusText||"Unsuccessful HTTP response"))}catch(a){d=a}d?(d.original=a,d.response=b,d.status=b.status,c.callback(d,b)):c.callback(null,b)})}function m(a,b,c){var d=u("DELETE",a);return"function"==typeof b&&(c=b,b=null),b&&d.send(b),c&&d.end(c),d}var n;"undefined"!=typeof window?n=window:"undefined"==typeof self?(console.warn("Using browser-only version of superagent in non-browser environment"),n=void 0):n=self;var o=a("component-emitter"),p=a("fast-safe-stringify"),q=a("./request-base"),r=a("./is-object"),s=a("./response-base"),t=a("./agent-base");b.exports=function(a,b){return"function"==typeof b?new c.Request("GET",a).end(b):1===arguments.length?new c.Request("GET",a):new c.Request(a,b)},c=b.exports;var u=c;c.Request=l,u.getXHR=function(){if(n.XMLHttpRequest&&(!n.location||"file:"!==n.location.protocol||!n.ActiveXObject))return new XMLHttpRequest;try{return new ActiveXObject("Microsoft.XMLHTTP")}catch(a){}try{return new ActiveXObject("Msxml2.XMLHTTP.6.0")}catch(a){}try{return new ActiveXObject("Msxml2.XMLHTTP.3.0")}catch(a){}try{return new ActiveXObject("Msxml2.XMLHTTP")}catch(a){}throw new Error("Browser-only version of superagent could not find XHR")};var v="".trim?function(a){return a.trim()}:function(a){return a.replace(/(^\s*|\s*$)/g,"")};u.serializeObject=f,u.parseString=h,u.types={html:"text/html",json:"application/json",xml:"text/xml",urlencoded:"application/x-www-form-urlencoded",form:"application/x-www-form-urlencoded","form-data":"application/x-www-form-urlencoded"},u.serialize={"application/x-www-form-urlencoded":f,"application/json":p},u.parse={"application/x-www-form-urlencoded":h,"application/json":JSON.parse},s(k.prototype),k.prototype._parseBody=function(a){var b=u.parse[this.type];return this.req._parser?this.req._parser(this,a):(!b&&j(this.type)&&(b=u.parse["application/json"]),b&&a&&(a.length>0||a instanceof Object)?b(a):null)},k.prototype.toError=function(){var a=this.req,b=a.method,c=a.url,d="cannot ".concat(b," ").concat(c," (").concat(this.status,")"),e=new Error(d);return e.status=this.status,e.method=b,e.url=c,e},u.Response=k,o(l.prototype),q(l.prototype),l.prototype.type=function(a){return this.set("Content-Type",u.types[a]||a),this},l.prototype.accept=function(a){return this.set("Accept",u.types[a]||a),this},l.prototype.auth=function(a,b,c){1===arguments.length&&(b=""),"object"===d(b)&&null!==b&&(c=b,b=""),c||(c={type:"function"==typeof btoa?"basic":"auto"});var e=function(a){if("function"==typeof btoa)return btoa(a);throw new Error("Cannot use basic auth, btoa is not a function")};return this._auth(a,b,c,e)},l.prototype.query=function(a){return"string"!=typeof a&&(a=f(a)),a&&this._query.push(a),this},l.prototype.attach=function(a,b,c){if(b){if(this._data)throw new Error("superagent can't mix .send() and .attach()");this._getFormData().append(a,b,c||b.name)}return this},l.prototype._getFormData=function(){return this._formData||(this._formData=new n.FormData),this._formData},l.prototype.callback=function(a,b){if(this._shouldRetry(a,b))return this._retry();var c=this._callback;this.clearTimeout(),a&&(this._maxRetries&&(a.retries=this._retries-1),this.emit("error",a)),c(a,b)},l.prototype.crossDomainError=function(){var a=new Error("Request has been terminated\nPossible causes: the network is offline, Origin is not allowed by Access-Control-Allow-Origin, the page is being unloaded, etc.");a.crossDomain=!0,a.status=this.status,a.method=this.method,a.url=this.url,this.callback(a)},l.prototype.agent=function(){return console.warn("This is not supported in browser version of superagent"),this},l.prototype.buffer=l.prototype.ca,l.prototype.ca=l.prototype.agent,l.prototype.write=function(){throw new Error("Streaming is not supported in browser version of superagent")},l.prototype.pipe=l.prototype.write,l.prototype._isHost=function(a){return a&&"object"===d(a)&&!Array.isArray(a)&&"[object Object]"!==Object.prototype.toString.call(a)},l.prototype.end=function(a){this._endCalled&&console.warn("Warning: .end() was called twice. This is not supported in superagent"),this._endCalled=!0,this._callback=a||e,this._finalizeQueryString(),this._end()},l.prototype._setUploadTimeout=function(){var a=this;this._uploadTimeout&&!this._uploadTimeoutTimer&&(this._uploadTimeoutTimer=setTimeout(function(){a._timeoutError("Upload timeout of ",a._uploadTimeout,"ETIMEDOUT")},this._uploadTimeout))},l.prototype._end=function(){if(this._aborted)return this.callback(new Error("The request has been aborted even before .end() was called"));var a=this;this.xhr=u.getXHR();var b=this.xhr,c=this._formData||this._data;this._setTimeouts(),b.onreadystatechange=function(){var c=b.readyState;if(c>=2&&a._responseTimeoutTimer&&clearTimeout(a._responseTimeoutTimer),4===c){var d;try{d=b.status}catch(a){d=0}if(!d){if(a.timedout||a._aborted)return;return a.crossDomainError()}a.emit("end")}};var d=function(b,c){c.total>0&&(c.percent=c.loaded/c.total*100,100===c.percent&&clearTimeout(a._uploadTimeoutTimer)),c.direction=b,a.emit("progress",c)};if(this.hasListeners("progress"))try{b.addEventListener("progress",d.bind(null,"download")),b.upload&&b.upload.addEventListener("progress",d.bind(null,"upload"))}catch(a){}b.upload&&this._setUploadTimeout();try{this.username&&this.password?b.open(this.method,this.url,!0,this.username,this.password):b.open(this.method,this.url,!0)}catch(a){return this.callback(a)}if(this._withCredentials&&(b.withCredentials=!0),!this._formData&&"GET"!==this.method&&"HEAD"!==this.method&&"string"!=typeof c&&!this._isHost(c)){var e=this._header["content-type"],f=this._serializer||u.serialize[e?e.split(";")[0]:""];!f&&j(e)&&(f=u.serialize["application/json"]),f&&(c=f(c))}for(var g in this.header)null!==this.header[g]&&Object.prototype.hasOwnProperty.call(this.header,g)&&b.setRequestHeader(g,this.header[g]);this._responseType&&(b.responseType=this._responseType),this.emit("request",this),b.send(void 0===c?null:c)},u.agent=function(){return new t},["GET","POST","OPTIONS","PATCH","PUT","DELETE"].forEach(function(a){t.prototype[a.toLowerCase()]=function(b,c){var d=new u.Request(a,b);return this._setDefaults(d),c&&d.end(c),d}}),t.prototype.del=t.prototype.delete,u.get=function(a,b,c){var d=u("GET",a);return"function"==typeof b&&(c=b,b=null),b&&d.query(b),c&&d.end(c),d},u.head=function(a,b,c){var d=u("HEAD",a);return"function"==typeof b&&(c=b,b=null),b&&d.query(b),c&&d.end(c),d},u.options=function(a,b,c){var d=u("OPTIONS",a);return"function"==typeof b&&(c=b,b=null),b&&d.send(b),c&&d.end(c),d},u.del=m,u.delete=m,u.patch=function(a,b,c){var d=u("PATCH",a);return"function"==typeof b&&(c=b,b=null),b&&d.send(b),c&&d.end(c),d},u.post=function(a,b,c){var d=u("POST",a);return"function"==typeof b&&(c=b,b=null),b&&d.send(b),c&&d.end(c),d},u.put=function(a,b,c){var d=u("PUT",a);return"function"==typeof b&&(c=b,b=null),b&&d.send(b),c&&d.end(c),d}},{"./agent-base":3,"./is-object":5,"./request-base":6,"./response-base":7,"component-emitter":1,"fast-safe-stringify":2}],5:[function(a,b,c){"use strict";function d(a){return(d="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a})(a)}function e(a){return null!==a&&"object"===d(a)}b.exports=e},{}],6:[function(a,b,c){"use strict";function d(a){return(d="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a})(a)}function e(a){if(a)return f(a)}function f(a){for(var b in e.prototype)Object.prototype.hasOwnProperty.call(e.prototype,b)&&(a[b]=e.prototype[b]);return a}var g=a("./is-object");b.exports=e,e.prototype.clearTimeout=function(){return clearTimeout(this._timer),clearTimeout(this._responseTimeoutTimer),clearTimeout(this._uploadTimeoutTimer),delete this._timer,delete this._responseTimeoutTimer,delete this._uploadTimeoutTimer,this},e.prototype.parse=function(a){return this._parser=a,this},e.prototype.responseType=function(a){return this._responseType=a,this},e.prototype.serialize=function(a){return this._serializer=a,this},e.prototype.timeout=function(a){if(!a||"object"!==d(a))return this._timeout=a,this._responseTimeout=0,this._uploadTimeout=0,this;for(var b in a)if(Object.prototype.hasOwnProperty.call(a,b))switch(b){case"deadline":this._timeout=a.deadline;break;case"response":this._responseTimeout=a.response;break;case"upload":this._uploadTimeout=a.upload;break;default:console.warn("Unknown timeout option",b)}return this},e.prototype.retry=function(a,b){return 0!==arguments.length&&!0!==a||(a=1),a<=0&&(a=0),this._maxRetries=a,this._retries=0,this._retryCallback=b,this};var h=["ECONNRESET","ETIMEDOUT","EADDRINFO","ESOCKETTIMEDOUT"];e.prototype._shouldRetry=function(a,b){if(!this._maxRetries||this._retries++>=this._maxRetries)return!1;if(this._retryCallback)try{var c=this._retryCallback(a,b);if(!0===c)return!0;if(!1===c)return!1}catch(a){console.error(a)}if(b&&b.status&&b.status>=500&&501!==b.status)return!0;if(a){if(a.code&&h.includes(a.code))return!0;if(a.timeout&&"ECONNABORTED"===a.code)return!0;if(a.crossDomain)return!0}return!1},e.prototype._retry=function(){return this.clearTimeout(),this.req&&(this.req=null,this.req=this.request()),this._aborted=!1,this.timedout=!1,this._end()},e.prototype.then=function(a,b){var c=this;if(!this._fullfilledPromise){var d=this;this._endCalled&&console.warn("Warning: superagent request was sent twice, because both .end() and .then() were called. Never call .end() if you use promises"),this._fullfilledPromise=new Promise(function(a,b){d.on("abort",function(){var a=new Error("Aborted");a.code="ABORTED",a.status=c.status,a.method=c.method,a.url=c.url,b(a)}),d.end(function(c,d){c?b(c):a(d)})})}return this._fullfilledPromise.then(a,b)},e.prototype.catch=function(a){return this.then(void 0,a)},e.prototype.use=function(a){return a(this),this},e.prototype.ok=function(a){if("function"!=typeof a)throw new Error("Callback required");return this._okCallback=a,this},e.prototype._isResponseOK=function(a){return!!a&&(this._okCallback?this._okCallback(a):a.status>=200&&a.status<300)},e.prototype.get=function(a){return this._header[a.toLowerCase()]},e.prototype.getHeader=e.prototype.get,e.prototype.set=function(a,b){if(g(a)){for(var c in a)Object.prototype.hasOwnProperty.call(a,c)&&this.set(c,a[c]);return this}return this._header[a.toLowerCase()]=b,this.header[a]=b,this},e.prototype.unset=function(a){return delete this._header[a.toLowerCase()],delete this.header[a],this},e.prototype.field=function(a,b){if(null===a||void 0===a)throw new Error(".field(name, val) name can not be empty");if(this._data)throw new Error(".field() can't be used if .send() is used. Please use only .send() or only .field() & .attach()");if(g(a)){for(var c in a)Object.prototype.hasOwnProperty.call(a,c)&&this.field(c,a[c]);return this}if(Array.isArray(b)){for(var d in b)Object.prototype.hasOwnProperty.call(b,d)&&this.field(a,b[d]);return this}if(null===b||void 0===b)throw new Error(".field(name, val) val can not be empty");return"boolean"==typeof b&&(b=String(b)),this._getFormData().append(a,b),this},e.prototype.abort=function(){return this._aborted?this:(this._aborted=!0,this.xhr&&this.xhr.abort(),this.req&&this.req.abort(),this.clearTimeout(),this.emit("abort"),this)},e.prototype._auth=function(a,b,c,d){switch(c.type){case"basic":this.set("Authorization","Basic ".concat(d("".concat(a,":").concat(b))));break;case"auto":this.username=a,this.password=b;break;case"bearer":this.set("Authorization","Bearer ".concat(a))}return this},e.prototype.withCredentials=function(a){return void 0===a&&(a=!0),this._withCredentials=a,this},e.prototype.redirects=function(a){return this._maxRedirects=a,this},e.prototype.maxResponseSize=function(a){if("number"!=typeof a)throw new TypeError("Invalid argument");return this._maxResponseSize=a,this},e.prototype.toJSON=function(){return{method:this.method,url:this.url,data:this._data,headers:this._header}},e.prototype.send=function(a){var b=g(a),c=this._header["content-type"];if(this._formData)throw new Error(".send() can't be used if .attach() or .field() is used. Please use only .send() or only .field() & .attach()");if(b&&!this._data)Array.isArray(a)?this._data=[]:this._isHost(a)||(this._data={});else if(a&&this._data&&this._isHost(this._data))throw new Error("Can't merge these send calls");if(b&&g(this._data))for(var d in a)Object.prototype.hasOwnProperty.call(a,d)&&(this._data[d]=a[d]);else"string"==typeof a?(c||this.type("form"),c=this._header["content-type"],this._data="application/x-www-form-urlencoded"===c?this._data?"".concat(this._data,"&").concat(a):a:(this._data||"")+a):this._data=a;return!b||this._isHost(a)?this:(c||this.type("json"),this)},e.prototype.sortQuery=function(a){return this._sort=void 0===a||a,this},e.prototype._finalizeQueryString=function(){var a=this._query.join("&");if(a&&(this.url+=(this.url.includes("?")?"&":"?")+a),this._query.length=0,this._sort){var b=this.url.indexOf("?");if(b>=0){var c=this.url.slice(b+1).split("&");"function"==typeof this._sort?c.sort(this._sort):c.sort(),this.url=this.url.slice(0,b)+"?"+c.join("&")}}},e.prototype._appendQueryString=function(){console.warn("Unsupported")},e.prototype._timeoutError=function(a,b,c){if(!this._aborted){var d=new Error("".concat(a+b,"ms exceeded"));d.timeout=b,d.code="ECONNABORTED",d.errno=c,this.timedout=!0,this.abort(),this.callback(d)}},e.prototype._setTimeouts=function(){var a=this;this._timeout&&!this._timer&&(this._timer=setTimeout(function(){a._timeoutError("Timeout of ",a._timeout,"ETIME")},this._timeout)),this._responseTimeout&&!this._responseTimeoutTimer&&(this._responseTimeoutTimer=setTimeout(function(){a._timeoutError("Response timeout of ",a._responseTimeout,"ETIMEDOUT")},this._responseTimeout))}},{"./is-object":5}],7:[function(a,b,c){"use strict";function d(a){if(a)return e(a)}function e(a){for(var b in d.prototype)Object.prototype.hasOwnProperty.call(d.prototype,b)&&(a[b]=d.prototype[b]);return a}var f=a("./utils");b.exports=d,d.prototype.get=function(a){return this.header[a.toLowerCase()]},d.prototype._setHeaderProperties=function(a){var b=a["content-type"]||"";this.type=f.type(b);var c=f.params(b);for(var d in c)Object.prototype.hasOwnProperty.call(c,d)&&(this[d]=c[d]);this.links={};try{a.link&&(this.links=f.parseLinks(a.link))}catch(a){}},d.prototype._setStatusProperties=function(a){var b=a/100|0;this.statusCode=a,this.status=this.statusCode,this.statusType=b,this.info=1===b,this.ok=2===b,this.redirect=3===b,this.clientError=4===b,this.serverError=5===b,this.error=(4===b||5===b)&&this.toError(),this.created=201===a,this.accepted=202===a,this.noContent=204===a,this.badRequest=400===a,this.unauthorized=401===a,this.notAcceptable=406===a,this.forbidden=403===a,this.notFound=404===a,this.unprocessableEntity=422===a}},{"./utils":8}],8:[function(a,b,c){"use strict";c.type=function(a){return a.split(/ *; */).shift()},c.params=function(a){return a.split(/ *; */).reduce(function(a,b){var c=b.split(/ *= */),d=c.shift(),e=c.shift();return d&&e&&(a[d]=e),a},{})},c.parseLinks=function(a){return a.split(/ *, */).reduce(function(a,b){var c=b.split(/ *; */),d=c[0].slice(1,-1);return a[c[1].split(/ *= */)[1].slice(1,-1)]=d,a},{})},c.cleanHeader=function(a,b){return delete a["content-type"],delete a["content-length"],delete a["transfer-encoding"],delete a.host,b&&(delete a.authorization,delete a.cookie),a}},{}],9:[function(a,b,c){(function(c){"use strict";var d="undefined"!=typeof window?window.L:void 0!==c?c.L:null,e=a("superagent");d.TileLayer.XServer=d.TileLayer.extend({_isrsLayer:!1,options:{disableMouseEvents:!1},initialize:function(a,b){b=d.setOptions(this,b);var c=d.Util.template(a,d.extend({s:0,x:0,y:0,z:0},b));if(this._isrsLayer=-1!==c.indexOf("/renderMap"),!this._isrsLayer&&-1===c.indexOf("contentType=JSON"))throw new Error("L.TileLayer.XServer cannot be intatiated directly without contentType=JSON");d.TileLayer.prototype.initialize.call(this,a,b)},onAdd:function(a){if(d.TileLayer.prototype.onAdd.call(this,a),!this.options.disableMouseEvents){var b=a._container;b.addEventListener("mousemove",d.bind(this._onMouseMove,this),!0),b.addEventListener("mousedown",d.bind(this._onMouseDown,this),!0),a._mapPane.addEventListener("click",d.bind(this._onClick,this),!0),a.addEventListener("click",d.bind(this._onMapClick,this),!1)}},onRemove:function(a){if(!this.options.disableMouseEvents){var b=a._container;b.removeEventListener("mousemove",d.bind(this._onMouseMove,this),!0),b.removeEventListener("mousedown",d.bind(this._onMouseDown,this),!0),a._mapPane.removeEventListener("click",d.bind(this._onClick,this),!0),a.removeEventListener("click",d.bind(this._onMapClick,this),!1)}d.TileLayer.prototype.onRemove.call(this,a)},findElement:function(a,b){if(!b)return null;var c,e,f,g={},h=Array.prototype.slice.call(b.getElementsByTagName("img"));for(c=0,e=h.length;c<e;c++){f=h[c];for(var i=d.DomEvent.getMousePosition(a,f),j=f._layers.length-1;j>=0;j--){var k=f._layers[j],l=Math.abs(k.pixelBoundingBox.right-k.pixelBoundingBox.left),m=Math.abs(k.pixelBoundingBox.top-k.pixelBoundingBox.bottom);k.referencePixelPoint.x-l/2<=i.x&&k.referencePixelPoint.x+l/2>=i.x&&k.referencePixelPoint.y-m/2<=i.y&&k.referencePixelPoint.y+m/2>=i.y&&(g[k.id]||(g[k.id]=k))}}return Object.keys(g).length>0?g:null},_onMouseMove:function(a){!this._map||this._map.dragging._draggable._moving||this._map._animatingZoom||(this.findElement(a,this._container)?(a.preventDefault(),this._map._container.style.cursor="pointer",a.stopPropagation()):this._map._container.style.cursor="")},_onMouseDown:function(a){if(this.findElement(a,this._container))return a.preventDefault(),a.stopPropagation(),!1},_onClick:function(a){var b=this.findElement(a,this._container);if(b){a.preventDefault();var c=this.buildDescriptionText(b),e=b[Object.keys(b)[0]].latLng;return d.popup().setLatLng(e).setContent(c).openOn(this._map),a.stopPropagation(),!1}},_onMapClick:function(a){var b=this.findElement(a.originalEvent,this._container);if(b){var c=this.buildDescriptionText(b),e=b[Object.keys(b)[0]].latLng;return d.popup().setLatLng(e).setContent(c).openOn(this._map),!1}},buildDescriptionText:function(a){var b="",c=!0;for(var d in a){c?c=!1:b+="<br>";for(var e=0;e<a[d].attributes.length;e++){var f=a[d].attributes[e];b=b.concat(f.key.replace(/[A-Z]/g," $&")+": "+f.value.replace("_"," ")+"<br>")}}return b.toLowerCase()},pixToLatLng:function(a,b){var c=Math.PI,e=2*c,f=e/Math.pow(2,a.z),g=-c+(a.x+b.x/256)*f,h=c-(a.y+b.y/256)*f;return d.latLng(360/Math.PI*(Math.atan(Math.exp(h))-Math.PI/4),180/Math.PI*g)},_removeTile:function(a){var b=this._tiles[a];return b&&b.el&&b.el.request&&b.el.request.abort(),d.TileLayer.prototype._removeTile.call(this,a)},createTile:function(a,b){var c=this.getTileUrl(a);if(this._isrsLayer){var f={mapSection:{$type:"MapSectionByTileKey",zoomLevel:a.z,x:a.x,y:a.y},imageOptions:{width:256,height:256},resultFields:{image:!0}};this.options.requestExtension&&(f=d.extend(f,this.options.requestExtension))}var g=document.createElement("img");return g._map=this._map,g._layers=[],g.request=this._isrsLayer?e.post(c).set("Content-Type","application/json").send(f):e.get(c),this.options.username&&this.options.password&&(g.request=g.request.auth(this.options.username,this.options.password)),g.request.responseType("json").end(d.bind(function(c,d){if(g.request=null,d&&d.body&&d.body.image){var e=d.body,f={iVBOR:"data:image/png;base64,",R0lGO:"data:image/gif;base64,","/9j/4":"data:image/jpeg;base64,",Qk02U:"data:image/bmp;base64,"},h=e.image;if(g.src=f[h.substr(0,5)]+h,e.features)for(var i=e.features,j=0;j<i.length;j++){var k=i[j];k.latLng=this.pixToLatLng(a,k.referencePixelPoint),g._layers.push(k)}}b(null,g)},this)),g}}),d.tileLayer.xserver=function(a,b){return-1!==d.Util.template(a,d.extend({s:0,x:0,y:0,z:0},b)).indexOf("/renderMap")||-1!==a.indexOf("contentType=JSON")?new d.TileLayer.XServer(a,b):new d.TileLayer(a,b)},b.exports=d.tileLayer.xserver}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{superagent:4}],10:[function(a,b,c){(function(b){!function(){"use strict";function c(a){var b=a.getTileUrl({x:0,y:0,z:0}),c=i.exec(b);if(c&&!(c.length<2)){var e=c[1],g=j.exec(b),h=g&&g.length>1?g[1]:null,k=f.post(e+"services/rs/XRuntime/getDataInformation").set("Content-Type","application/json").send({});h&&k.auth("xtok",h),k.end(function(c,e){var f=a.options.attribution,g=!c&&e&&e.body&&e.body.mapDescription&&e.body.mapDescription.copyright?d(b,e.body.mapDescription.copyright):"PTV";a.options.attribution=g,a._map&&a._map.attributionControl&&(f&&a._map.attributionControl.removeAttribution(f),a._map.attributionControl.addAttribution(g))})}}function d(a,b){var c=[],d=new RegExp("(&|\\?)(layers=.*(background|labels|transport)|^((?!layers=).)*$)"),e=d.exec(a);(e&&e.length>0||0===c.length)&&(c=c.concat(b.basemap?b.basemap:b));var f=/(PTV_[A-Za-z]*)/g;if(b.featureLayers&&b.featureLayers.length>0){var g=a.match(f);g&&g.length>0&&b.featureLayers.forEach(function(a){-1!==g.indexOf(a.themeId)&&(c=c.concat(a.copyright))})}return c.filter(function(a,b,c){return c.indexOf(a)==b}).join(", ")}var e="undefined"!=typeof window?window.L:void 0!==b?b.L:null,f=a("superagent"),g=e.TileLayer.prototype,h=g.initialize,i=new RegExp("(^https?://.*/)services/(rest|rs)/XMap/"),j=new RegExp("[&?]xtok=(\\w{8}-\\w{4}-\\w{4}-\\w{4}-\\w{12})");g.initialize=function(a,b){h.call(this,a,b),c(this)};var k=g.redraw;g.redraw=function(){c(this),k.call(this)},e.Control.Attribution.prototype._update=function(){if(this._map){var a=[];for(var b in this._map._layers)if(this._map._layers[b].getAttribution){var c=this._map._layers[b].getAttribution();c&&this._attributions[c]&&(a=a.concat(c.split(",")))}var d=a.map(function(a){return a.trim()}).filter(function(a,b,c){return c.indexOf(a)==b}),e=[];this.options.prefix&&e.push(this.options.prefix),d.length&&e.push(d.join(", ")),this._container.innerHTML=e.join(" | ")}}}()}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{superagent:4}]},{},[9,10])(10)});
5//# sourceMappingURL=leaflet-xserver.js.map
\No newline at end of file