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