UNPKG

28.3 kBJavaScriptView Raw
1import*as t from"leaflet";function e(){return e=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},e.apply(this,arguments)}function r(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,n(t,e)}function n(t,e){return n=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},n(t,e)}function o(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(t){return!1}}function i(t,e,r){return i=o()?Reflect.construct.bind():function(t,e,r){var o=[null];o.push.apply(o,e);var i=new(Function.bind.apply(t,o));return r&&n(i,r.prototype),i},i.apply(null,arguments)}function s(t,e,r,n){void 0===e&&(e=""),void 0===n&&(n={});var o=document.createElement(t);return e&&(o.className=e),Object.keys(n).forEach(function(t){if("function"==typeof n[t]){var e=0===t.indexOf("on")?t.substr(2).toLowerCase():t;o.addEventListener(e,n[t])}else"html"===t?o.innerHTML=n[t]:"text"===t?o.innerText=n[t]:o.setAttribute(t,n[t])}),r&&r.appendChild(o),o}function a(t){t.preventDefault(),t.stopPropagation()}var l=function(){return[].slice.call(arguments).filter(Boolean).join(" ").trim()};function c(t,e){t&&t.classList&&(Array.isArray(e)?e:[e]).forEach(function(e){t.classList.contains(e)||t.classList.add(e)})}function u(t,e){t&&t.classList&&(Array.isArray(e)?e:[e]).forEach(function(e){t.classList.contains(e)&&t.classList.remove(e)})}var h,p=13,d=40,f=38,v=[p,27,d,f,37,39],m=/*#__PURE__*/function(){function t(t){var e=this,r=t.handleSubmit,n=t.searchLabel,o=t.classNames,i=void 0===o?{}:o;this.container=void 0,this.form=void 0,this.input=void 0,this.handleSubmit=void 0,this.hasError=!1,this.container=s("div",l("geosearch",i.container)),this.form=s("form",["",i.form].join(" "),this.container,{autocomplete:"none",onClick:a,onDblClick:a,touchStart:a,touchEnd:a}),this.input=s("input",["glass",i.input].join(" "),this.form,{type:"text",placeholder:n||"search",onInput:this.onInput,onKeyUp:function(t){return e.onKeyUp(t)},onKeyPress:function(t){return e.onKeyPress(t)},onFocus:this.onFocus,onBlur:this.onBlur,onClick:function(){e.input.focus(),e.input.dispatchEvent(new Event("focus"))}}),this.handleSubmit=r}var e=t.prototype;return e.onFocus=function(){c(this.form,"active")},e.onBlur=function(){u(this.form,"active")},e.onSubmit=function(t){try{var e=this;return a(t),u(r=e.container,"error"),c(r,"pending"),Promise.resolve(e.handleSubmit({query:e.input.value})).then(function(){u(e.container,"pending")})}catch(t){return Promise.reject(t)}var r},e.onInput=function(){this.hasError&&(u(this.container,"error"),this.hasError=!1)},e.onKeyUp=function(t){27===t.keyCode&&(u(this.container,["pending","active"]),this.input.value="",document.body.focus(),document.body.blur())},e.onKeyPress=function(t){t.keyCode===p&&this.onSubmit(t)},e.setQuery=function(t){this.input.value=t},t}(),g=/*#__PURE__*/function(){function t(t){var e=this,r=t.handleClick,n=t.classNames,o=void 0===n?{}:n,i=t.notFoundMessage;this.handleClick=void 0,this.selected=-1,this.results=[],this.container=void 0,this.resultItem=void 0,this.notFoundMessage=void 0,this.onClick=function(t){if("function"==typeof e.handleClick){var r=t.target;if(r&&e.container.contains(r)&&r.hasAttribute("data-key")){var n=Number(r.getAttribute("data-key"));e.handleClick({result:e.results[n]})}}},this.handleClick=r,this.notFoundMessage=i?s("div",l(o.notfound),void 0,{html:i}):void 0,this.container=s("div",l("results",o.resultlist)),this.container.addEventListener("click",this.onClick,!0),this.resultItem=s("div",l(o.item))}var e=t.prototype;return e.render=function(t,e){var r=this;void 0===t&&(t=[]),this.clear(),t.forEach(function(t,n){var o=r.resultItem.cloneNode(!0);o.setAttribute("data-key",""+n),o.innerHTML=e({result:t}),r.container.appendChild(o)}),t.length>0?(c(this.container.parentElement,"open"),c(this.container,"active")):this.notFoundMessage&&(this.container.appendChild(this.notFoundMessage),c(this.container.parentElement,"open")),this.results=t},e.select=function(t){return Array.from(this.container.children).forEach(function(e,r){return r===t?c(e,"active"):u(e,"active")}),this.selected=t,this.results[t]},e.count=function(){return this.results?this.results.length:0},e.clear=function(){for(this.selected=-1;this.container.lastChild;)this.container.removeChild(this.container.lastChild);u(this.container.parentElement,"open"),u(this.container,"active")},t}(),y={position:"topleft",style:"button",showMarker:!0,showPopup:!1,popupFormat:function(t){return""+t.result.label},resultFormat:function(t){return""+t.result.label},marker:{icon:t&&t.Icon?new t.Icon.Default:void 0,draggable:!1},maxMarkers:1,maxSuggestions:5,retainZoomLevel:!1,animateZoom:!0,searchLabel:"Enter address",clearSearchLabel:"Clear search",notFoundMessage:"",messageHideDelay:3e3,zoomLevel:18,classNames:{container:"leaflet-bar leaflet-control leaflet-control-geosearch",button:"leaflet-bar-part leaflet-bar-part-single",resetButton:"reset",msgbox:"leaflet-bar message",form:"",input:"",resultlist:"",item:"",notfound:"leaflet-bar-notfound"},autoComplete:!0,autoCompleteDelay:250,autoClose:!1,keepResult:!1,updateMap:!0},b="Leaflet must be loaded before instantiating the GeoSearch control",E={options:e({},y),classNames:e({},y.classNames),initialize:function(r){var n,o,i,a,l=this;if(!t)throw new Error(b);if(!r.provider)throw new Error("Provider is missing from options");this.options=e({},y,r),this.classNames=e({},this.classNames,r.classNames),this.markers=new t.FeatureGroup,this.classNames.container+=" leaflet-geosearch-"+this.options.style,this.searchElement=new m({searchLabel:this.options.searchLabel,classNames:{container:this.classNames.container,form:this.classNames.form,input:this.classNames.input},handleSubmit:function(t){return l.onSubmit(t)}}),this.button=s("a",this.classNames.button,this.searchElement.container,{title:this.options.searchLabel,href:"#",onClick:function(t){return l.onClick(t)}}),t.DomEvent.disableClickPropagation(this.button),this.resetButton=s("button",this.classNames.resetButton,this.searchElement.form,{text:"×","aria-label":this.options.clearSearchLabel,onClick:function(){""===l.searchElement.input.value?l.close():l.clearResults(null,!0)}}),t.DomEvent.disableClickPropagation(this.resetButton),this.options.autoComplete&&(this.resultList=new g({handleClick:function(t){var e=t.result;l.searchElement.input.value=e.label,l.onSubmit({query:e.label,data:e})},classNames:{resultlist:this.classNames.resultlist,item:this.classNames.item,notfound:this.classNames.notfound},notFoundMessage:this.options.notFoundMessage}),this.searchElement.form.appendChild(this.resultList.container),this.searchElement.input.addEventListener("keyup",(n=function(t){return l.autoSearch(t)},void 0===(o=this.options.autoCompleteDelay)&&(o=250),void 0===i&&(i=!1),function(){var t=[].slice.call(arguments);a&&clearTimeout(a),a=setTimeout(function(){a=null,i||n.apply(void 0,t)},o),i&&!a&&n.apply(void 0,t)}),!0),this.searchElement.input.addEventListener("keydown",function(t){return l.selectResult(t)},!0),this.searchElement.input.addEventListener("keydown",function(t){return l.clearResults(t,!0)},!0)),this.searchElement.form.addEventListener("click",function(t){t.preventDefault()},!1)},onAdd:function(e){var r=this.options,n=r.showMarker,o=r.style;if(this.map=e,n&&this.markers.addTo(e),"bar"===o){var i=e.getContainer().querySelector(".leaflet-control-container");this.container=s("div","leaflet-control-geosearch leaflet-geosearch-bar"),this.container.appendChild(this.searchElement.form),i.appendChild(this.container)}return t.DomEvent.disableClickPropagation(this.searchElement.form),this.searchElement.container},onRemove:function(){var t;return null==(t=this.container)||t.remove(),this},open:function(){var t=this.searchElement,e=t.input;c(t.container,"active"),e.focus()},close:function(){u(this.searchElement.container,"active"),this.clearResults()},onClick:function(t){t.preventDefault(),t.stopPropagation(),this.searchElement.container.classList.contains("active")?this.close():this.open()},selectResult:function(t){if(-1!==[p,d,f].indexOf(t.keyCode))if(t.preventDefault(),t.keyCode!==p){var e=this.resultList.count()-1;if(!(e<0)){var r=this.resultList.selected,n=t.keyCode===d?r+1:r-1,o=this.resultList.select(n<0?e:n>e?0:n);this.searchElement.input.value=o.label}}else{var i=this.resultList.select(this.resultList.selected);this.onSubmit({query:this.searchElement.input.value,data:i})}},clearResults:function(t,e){if(void 0===e&&(e=!1),!t||27===t.keyCode){var r=this.options,n=r.autoComplete;!e&&r.keepResult||(this.searchElement.input.value="",this.markers.clearLayers()),n&&this.resultList.clear()}},autoSearch:function(t){try{var e=this;if(v.indexOf(t.keyCode)>-1)return Promise.resolve();var r=t.target.value,n=e.options.provider,o=function(){if(r.length)return Promise.resolve(n.search({query:r})).then(function(t){t=t.slice(0,e.options.maxSuggestions),e.resultList.render(t,e.options.resultFormat)});e.resultList.clear()}();return Promise.resolve(o&&o.then?o.then(function(){}):void 0)}catch(t){return Promise.reject(t)}},onSubmit:function(t){try{var e=this;return e.resultList.clear(),Promise.resolve(e.options.provider.search(t)).then(function(r){r&&r.length>0&&e.showResult(r[0],t)})}catch(t){return Promise.reject(t)}},showResult:function(t,e){var r=this.options,n=r.autoClose,o=r.updateMap,i=this.markers.getLayers();i.length>=this.options.maxMarkers&&this.markers.removeLayer(i[0]);var s=this.addMarker(t,e);o&&this.centerMap(t),this.map.fireEvent("geosearch/showlocation",{location:t,marker:s}),n&&this.closeResults()},closeResults:function(){var t=this.searchElement.container;t.classList.contains("active")&&u(t,"active"),this.clearResults()},addMarker:function(e,r){var n=this,o=this.options,i=o.marker,s=o.showPopup,a=o.popupFormat,l=new t.Marker([e.y,e.x],i),c=e.label;return"function"==typeof a&&(c=a({query:r,result:e})),l.bindPopup(c),this.markers.addLayer(l),s&&l.openPopup(),i.draggable&&l.on("dragend",function(t){n.map.fireEvent("geosearch/marker/dragend",{location:l.getLatLng(),event:t})}),l},centerMap:function(e){var r=this.options,n=r.retainZoomLevel,o=r.animateZoom,i=e.bounds?new t.LatLngBounds(e.bounds):new t.LatLng(e.y,e.x).toBounds(10),s=i.isValid()?i:this.markers.getBounds();!n&&i.isValid()&&!e.bounds||n||!i.isValid()?this.map.setView(s.getCenter(),this.getZoom(),{animate:o}):this.map.fitBounds(s,{animate:o})},getZoom:function(){var t=this.options,e=t.zoomLevel;return t.retainZoomLevel?this.map.getZoom():e}};function w(){if(!t)throw new Error(b);var e=t.Control.extend(E);return i(e,[].slice.call(arguments))}!function(t){t[t.SEARCH=0]="SEARCH",t[t.REVERSE=1]="REVERSE"}(h||(h={}));var x=/*#__PURE__*/function(){function t(t){void 0===t&&(t={}),this.options=void 0,this.options=t}var r=t.prototype;return r.getParamString=function(t){void 0===t&&(t={});var r=e({},this.options.params,t);return Object.keys(r).map(function(t){return encodeURIComponent(t)+"="+encodeURIComponent(r[t])}).join("&")},r.getUrl=function(t,e){return t+"?"+this.getParamString(e)},r.search=function(t){try{var e=this,r=e.endpoint({query:t.query,type:h.SEARCH});return Promise.resolve(fetch(r)).then(function(t){return Promise.resolve(t.json()).then(function(t){return e.parse({data:t})})})}catch(t){return Promise.reject(t)}},t}(),L=/*#__PURE__*/function(t){function n(){return t.apply(this,arguments)||this}r(n,t);var o=n.prototype;return o.endpoint=function(){return"https://places-dsn.algolia.net/1/places/query"},o.findBestMatchLevelIndex=function(t){var e=t.find(function(t){return"full"===t.matchLevel})||t.find(function(t){return"partial"===t.matchLevel});return e?t.indexOf(e):0},o.getLabel=function(t){var e,r,n,o;return[null==(e=t.locale_names)?void 0:e.default[this.findBestMatchLevelIndex(t._highlightResult.locale_names.default)],null==(r=t.city)?void 0:r.default[this.findBestMatchLevelIndex(t._highlightResult.city.default)],t.administrative[this.findBestMatchLevelIndex(t._highlightResult.administrative)],null==(n=t.postcode)?void 0:n[this.findBestMatchLevelIndex(t._highlightResult.postcode)],null==(o=t.country)?void 0:o.default].filter(Boolean).join(", ")},o.parse=function(t){var e=this;return t.data.hits.map(function(t){return{x:t._geoloc.lng,y:t._geoloc.lat,label:e.getLabel(t),bounds:null,raw:t}})},o.search=function(t){var r=t.query;try{var n=this,o="string"==typeof r?{query:r}:r;return Promise.resolve(fetch(n.endpoint(),{method:"POST",body:JSON.stringify(e({},n.options.params,o))})).then(function(t){return Promise.resolve(t.json()).then(function(t){return n.parse({data:t})})})}catch(t){return Promise.reject(t)}},n}(x),k=/*#__PURE__*/function(t){function e(){for(var e,r=arguments.length,n=new Array(r),o=0;o<r;o++)n[o]=arguments[o];return(e=t.call.apply(t,[this].concat(n))||this).searchUrl="https://dev.virtualearth.net/REST/v1/Locations",e}r(e,t);var n=e.prototype;return n.endpoint=function(t){var e=t.query,r="string"==typeof e?{q:e}:e;return r.jsonp=t.jsonp,this.getUrl(this.searchUrl,r)},n.parse=function(t){return 0===t.data.resourceSets.length?[]:t.data.resourceSets[0].resources.map(function(t){return{x:t.point.coordinates[1],y:t.point.coordinates[0],label:t.address.formattedAddress,bounds:[[t.bbox[0],t.bbox[1]],[t.bbox[2],t.bbox[3]]],raw:t}})},n.search=function(t){var e,r,n,o=t.query;try{var i=this,a="BING_JSONP_CB_"+Date.now();return Promise.resolve((e=i.endpoint({query:o,jsonp:a}),r=a,n=s("script",null,document.body),n.setAttribute("type","text/javascript"),new Promise(function(t){window[r]=function(e){n.remove(),delete window[r],t(e)},n.setAttribute("src",e)}))).then(function(t){return i.parse({data:t})})}catch(t){return Promise.reject(t)}},e}(x),U=/*#__PURE__*/function(t){function e(){for(var e,r=arguments.length,n=new Array(r),o=0;o<r;o++)n[o]=arguments[o];return(e=t.call.apply(t,[this].concat(n))||this).searchUrl="https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/find",e}r(e,t);var n=e.prototype;return n.endpoint=function(t){var e=t.query,r="string"==typeof e?{text:e}:e;return r.f="json",this.getUrl(this.searchUrl,r)},n.parse=function(t){return t.data.locations.map(function(t){return{x:t.feature.geometry.x,y:t.feature.geometry.y,label:t.name,bounds:[[t.extent.ymin,t.extent.xmin],[t.extent.ymax,t.extent.xmax]],raw:t}})},e}(x),S=/*#__PURE__*/function(t){function e(e){var r;return void 0===e&&(e={}),(r=t.call(this,e)||this).host=void 0,r.host=e.host||"http://localhost:4000",r}r(e,t);var n=e.prototype;return n.endpoint=function(t){var e=t.query;return t.type===h.REVERSE?this.getUrl(this.host+"/v1/reverse","string"==typeof e?{}:e):this.getUrl(this.host+"/v1/autocomplete","string"==typeof e?{text:e}:e)},n.parse=function(t){return t.data.features.map(function(t){var e={x:t.geometry.coordinates[0],y:t.geometry.coordinates[1],label:t.properties.label,bounds:null,raw:t};return Array.isArray(t.bbox)&&4===t.bbox.length&&(e.bounds=[[t.bbox[1],t.bbox[0]],[t.bbox[3],t.bbox[2]]]),e})},e}(x),C=/*#__PURE__*/function(t){function e(e){return void 0===e&&(e={}),e.host="https://api.geocode.earth",t.call(this,e)||this}return r(e,t),e}(S);function P(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}"function"==typeof SuppressedError&&SuppressedError;var R,I=/*@__PURE__*/P(function t(e,r){if(e===r)return!0;if(e&&r&&"object"==typeof e&&"object"==typeof r){if(e.constructor!==r.constructor)return!1;var n,o,i;if(Array.isArray(e)){if((n=e.length)!=r.length)return!1;for(o=n;0!=o--;)if(!t(e[o],r[o]))return!1;return!0}if(e.constructor===RegExp)return e.source===r.source&&e.flags===r.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===r.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===r.toString();if((n=(i=Object.keys(e)).length)!==Object.keys(r).length)return!1;for(o=n;0!=o--;)if(!Object.prototype.hasOwnProperty.call(r,i[o]))return!1;for(o=n;0!=o--;){var s=i[o];if(!t(e[s],r[s]))return!1}return!0}return e!=e&&r!=r});!function(t){t[t.INITIALIZED=0]="INITIALIZED",t[t.LOADING=1]="LOADING",t[t.SUCCESS=2]="SUCCESS",t[t.FAILURE=3]="FAILURE"}(R||(R={}));class j{constructor({apiKey:t,authReferrerPolicy:e,channel:r,client:n,id:o="__googleMapsScriptId",language:i,libraries:s=[],mapIds:a,nonce:l,region:c,retries:u=3,url:h="https://maps.googleapis.com/maps/api/js",version:p}){if(this.callbacks=[],this.done=!1,this.loading=!1,this.errors=[],this.apiKey=t,this.authReferrerPolicy=e,this.channel=r,this.client=n,this.id=o||"__googleMapsScriptId",this.language=i,this.libraries=s,this.mapIds=a,this.nonce=l,this.region=c,this.retries=u,this.url=h,this.version=p,j.instance){if(!I(this.options,j.instance.options))throw new Error(`Loader must not be called again with different options. ${JSON.stringify(this.options)} !== ${JSON.stringify(j.instance.options)}`);return j.instance}j.instance=this}get options(){return{version:this.version,apiKey:this.apiKey,channel:this.channel,client:this.client,id:this.id,libraries:this.libraries,language:this.language,region:this.region,mapIds:this.mapIds,nonce:this.nonce,url:this.url,authReferrerPolicy:this.authReferrerPolicy}}get status(){return this.errors.length?R.FAILURE:this.done?R.SUCCESS:this.loading?R.LOADING:R.INITIALIZED}get failed(){return this.done&&!this.loading&&this.errors.length>=this.retries+1}createUrl(){let t=this.url;return t+="?callback=__googleMapsCallback&loading=async",this.apiKey&&(t+=`&key=${this.apiKey}`),this.channel&&(t+=`&channel=${this.channel}`),this.client&&(t+=`&client=${this.client}`),this.libraries.length>0&&(t+=`&libraries=${this.libraries.join(",")}`),this.language&&(t+=`&language=${this.language}`),this.region&&(t+=`&region=${this.region}`),this.version&&(t+=`&v=${this.version}`),this.mapIds&&(t+=`&map_ids=${this.mapIds.join(",")}`),this.authReferrerPolicy&&(t+=`&auth_referrer_policy=${this.authReferrerPolicy}`),t}deleteScript(){const t=document.getElementById(this.id);t&&t.remove()}load(){return this.loadPromise()}loadPromise(){return new Promise((t,e)=>{this.loadCallback(r=>{r?e(r.error):t(window.google)})})}importLibrary(t){return this.execute(),google.maps.importLibrary(t)}loadCallback(t){this.callbacks.push(t),this.execute()}setScript(){var t,e;if(document.getElementById(this.id))return void this.callback();const r={key:this.apiKey,channel:this.channel,client:this.client,libraries:this.libraries.length&&this.libraries,v:this.version,mapIds:this.mapIds,language:this.language,region:this.region,authReferrerPolicy:this.authReferrerPolicy};Object.keys(r).forEach(t=>!r[t]&&delete r[t]),(null===(e=null===(t=null===window||void 0===window?void 0:window.google)||void 0===t?void 0:t.maps)||void 0===e?void 0:e.importLibrary)||(t=>{let e,r,n,o="The Google Maps JavaScript API",i="google",s="importLibrary",a="__ib__",l=document,c=window;c=c[i]||(c[i]={});const u=c.maps||(c.maps={}),h=new Set,p=new URLSearchParams,d=()=>e||(e=new Promise((s,c)=>{return d=this,v=function*(){var d;for(n in yield r=l.createElement("script"),r.id=this.id,p.set("libraries",[...h]+""),t)p.set(n.replace(/[A-Z]/g,t=>"_"+t[0].toLowerCase()),t[n]);p.set("callback",i+".maps."+a),r.src=this.url+"?"+p,u[a]=s,r.onerror=()=>e=c(Error(o+" could not load.")),r.nonce=this.nonce||(null===(d=l.querySelector("script[nonce]"))||void 0===d?void 0:d.nonce)||"",l.head.append(r)},new((f=void 0)||(f=Promise))(function(t,e){function r(t){try{o(v.next(t))}catch(t){e(t)}}function n(t){try{o(v.throw(t))}catch(t){e(t)}}function o(e){var o;e.done?t(e.value):(o=e.value,o instanceof f?o:new f(function(t){t(o)})).then(r,n)}o((v=v.apply(d,[])).next())});var d,f,v}));u[s]?console.warn(o+" only loads once. Ignoring:",t):u[s]=(t,...e)=>h.add(t)&&d().then(()=>u[s](t,...e))})(r);const n=this.libraries.map(t=>this.importLibrary(t));n.length||n.push(this.importLibrary("core")),Promise.all(n).then(()=>this.callback(),t=>{const e=new ErrorEvent("error",{error:t});this.loadErrorCallback(e)})}reset(){this.deleteScript(),this.done=!1,this.loading=!1,this.errors=[],this.onerrorEvent=null}resetIfRetryingFailed(){this.failed&&this.reset()}loadErrorCallback(t){if(this.errors.push(t),this.errors.length<=this.retries){const t=this.errors.length*Math.pow(2,this.errors.length);console.error(`Failed to load Google Maps script, retrying in ${t} ms.`),setTimeout(()=>{this.deleteScript(),this.setScript()},t)}else this.onerrorEvent=t,this.callback()}callback(){this.done=!0,this.loading=!1,this.callbacks.forEach(t=>{t(this.onerrorEvent)}),this.callbacks=[]}execute(){if(this.resetIfRetryingFailed(),this.done)this.callback();else{if(window.google&&window.google.maps&&window.google.maps.version)return console.warn("Google Maps already loaded outside @googlemaps/js-api-loader.This may result in undesirable behavior as options and script parameters may not match."),void this.callback();this.loading||(this.loading=!0,this.setScript())}}}var A=/*#__PURE__*/function(t){function e(e){var r;return(r=t.call(this,e)||this).loader=null,r.geocoder=null,"undefined"!=typeof window&&(r.loader=new j(e).load().then(function(t){var e=new t.maps.Geocoder;return r.geocoder=e,e})),r}r(e,t);var n=e.prototype;return n.endpoint=function(t){throw new Error("Method not implemented.")},n.parse=function(t){return t.data.results.map(function(t){var e=t.geometry.location.toJSON(),r=e.lat,n=e.lng,o=t.geometry.viewport.toJSON();return{x:n,y:r,label:t.formatted_address,bounds:[[o.south,o.west],[o.north,o.east]],raw:t}})},n.search=function(t){try{var e=function(e){if(!e)throw new Error("GoogleMaps GeoCoder is not loaded. Are you trying to run this server side?");return Promise.resolve(e.geocode({address:t.query},function(t){return{results:t}}).catch(function(t){return"ZERO_RESULTS"!==t.code&&console.error(t.code+": "+t.message),{results:[]}})).then(function(t){return r.parse({data:t})})},r=this,n=r.geocoder;return Promise.resolve(n?e(n):Promise.resolve(r.loader).then(e))}catch(t){return Promise.reject(t)}},e}(x),N=/*#__PURE__*/function(t){function e(){for(var e,r=arguments.length,n=new Array(r),o=0;o<r;o++)n[o]=arguments[o];return(e=t.call.apply(t,[this].concat(n))||this).searchUrl="https://maps.googleapis.com/maps/api/geocode/json",e}r(e,t);var n=e.prototype;return n.endpoint=function(t){var e=t.query;return this.getUrl(this.searchUrl,"string"==typeof e?{address:e}:e)},n.parse=function(t){return t.data.results.map(function(t){return{x:t.geometry.location.lng,y:t.geometry.location.lat,label:t.formatted_address,bounds:[[t.geometry.viewport.southwest.lat,t.geometry.viewport.southwest.lng],[t.geometry.viewport.northeast.lat,t.geometry.viewport.northeast.lng]],raw:t}})},e}(x),O=/*#__PURE__*/function(t){function e(){for(var e,r=arguments.length,n=new Array(r),o=0;o<r;o++)n[o]=arguments[o];return(e=t.call.apply(t,[this].concat(n))||this).searchUrl="https://geocode.search.hereapi.com/v1/autosuggest",e}r(e,t);var n=e.prototype;return n.endpoint=function(t){var e=t.query;return this.getUrl(this.searchUrl,"string"==typeof e?{q:e}:e)},n.parse=function(t){return t.data.items.filter(function(t){return void 0!==t.position}).map(function(t){return{x:t.position.lng,y:t.position.lat,label:t.address.label,bounds:null,raw:t}})},e}(x),F=/*#__PURE__*/function(t){function e(e){var r;void 0===e&&(e={}),(r=t.call(this,e)||this).searchUrl=void 0,r.reverseUrl=void 0;var n="https://nominatim.openstreetmap.org";return r.searchUrl=e.searchUrl||n+"/search",r.reverseUrl=e.reverseUrl||n+"/reverse",r}r(e,t);var n=e.prototype;return n.endpoint=function(t){var e=t.query,r=t.type,n="string"==typeof e?{q:e}:e;return n.format="json",this.getUrl(r===h.REVERSE?this.reverseUrl:this.searchUrl,n)},n.parse=function(t){return(Array.isArray(t.data)?t.data:[t.data]).map(function(t){return{x:Number(t.lon),y:Number(t.lat),label:t.display_name,bounds:[[parseFloat(t.boundingbox[0]),parseFloat(t.boundingbox[2])],[parseFloat(t.boundingbox[1]),parseFloat(t.boundingbox[3])]],raw:t}})},e}(x),_=/*#__PURE__*/function(t){function n(r){return t.call(this,e({},r,{searchUrl:"https://locationiq.org/v1/search.php",reverseUrl:"https://locationiq.org/v1/reverse.php"}))||this}return r(n,t),n.prototype.parse=function(e){return e.data.error?[]:t.prototype.parse.call(this,e)},n}(F),M=/*#__PURE__*/function(t){function e(){for(var e,r=arguments.length,n=new Array(r),o=0;o<r;o++)n[o]=arguments[o];return(e=t.call.apply(t,[this].concat(n))||this).searchUrl="https://api.opencagedata.com/geocode/v1/json",e}r(e,t);var n=e.prototype;return n.endpoint=function(t){var e=t.query,r="string"==typeof e?{q:e}:e;return r.format="json",this.getUrl(this.searchUrl,r)},n.parse=function(t){return t.data.results.map(function(t){return{x:t.geometry.lng,y:t.geometry.lat,label:t.formatted,bounds:[[t.bounds.southwest.lat,t.bounds.southwest.lng],[t.bounds.northeast.lat,t.bounds.northeast.lng]],raw:t}})},n.search=function(e){try{return Promise.resolve(e.query.length<2?[]:t.prototype.search.call(this,e))}catch(t){return Promise.reject(t)}},e}(x),q=/*#__PURE__*/function(t){function e(e){var r;void 0===e&&(e={}),(r=t.call(this,e)||this).searchUrl=void 0,r.reverseUrl=void 0;var n="https://civildefense.fit.vutbr.cz";return r.searchUrl=e.searchUrl||n+"/search",r.reverseUrl=e.reverseUrl||n+"/reverse",r}r(e,t);var n=e.prototype;return n.endpoint=function(t){var e=t.query,r=t.type,n="string"==typeof e?{q:e}:e;return n.format="json",this.getUrl(r===h.REVERSE?this.reverseUrl:this.searchUrl,n)},n.parse=function(t){return(Array.isArray(t.data)?t.data:[t.data]).map(function(t){return{x:Number(t.lon),y:Number(t.lat),label:t.display_name,bounds:[[parseFloat(t.boundingbox[0]),parseFloat(t.boundingbox[2])],[parseFloat(t.boundingbox[1]),parseFloat(t.boundingbox[3])]],raw:t}})},e}(x),B=/*#__PURE__*/function(t){function e(e){var r;return void 0===e&&(e={}),(r=t.call(this,e)||this).searchUrl=void 0,r.searchUrl=e.searchUrl||"https://a.tiles.mapbox.com/v4/geocode/mapbox.places/",r}r(e,t);var n=e.prototype;return n.endpoint=function(t){return this.getUrl(""+this.searchUrl+t.query+".json")},n.parse=function(t){return(Array.isArray(t.data.features)?t.data.features:[]).map(function(t){var e=null;return t.bbox&&(e=[[parseFloat(t.bbox[1]),parseFloat(t.bbox[0])],[parseFloat(t.bbox[3]),parseFloat(t.bbox[2])]]),{x:Number(t.center[0]),y:Number(t.center[1]),label:t.place_name?t.place_name:t.text,bounds:e,raw:t}})},e}(x),D=/*#__PURE__*/function(t){function e(e){var r;void 0===e&&(e={}),(r=t.call(this,e)||this).searchUrl=void 0,r.reverseUrl=void 0;var n="https://api-adresse.data.gouv.fr";return r.searchUrl=e.searchUrl||n+"/search",r.reverseUrl=e.reverseUrl||n+"/reverse",r}r(e,t);var n=e.prototype;return n.endpoint=function(t){var e=t.query;return this.getUrl(t.type===h.REVERSE?this.reverseUrl:this.searchUrl,"string"==typeof e?{q:e}:e)},n.parse=function(t){return t.data.features.map(function(t){return{x:t.geometry.coordinates[0],y:t.geometry.coordinates[1],label:t.properties.label,bounds:null,raw:t}})},e}(x),T=/*#__PURE__*/function(t){function e(e){var r;void 0===e&&(e={}),(r=t.call(this,e)||this).searchUrl=void 0,r.reverseUrl=void 0;var n="https://api.geoapify.com/v1/geocode";return r.searchUrl=e.searchUrl||n+"/search",r.reverseUrl=e.reverseUrl||n+"/reverse",r}r(e,t);var n=e.prototype;return n.endpoint=function(t){var e=t.query,r=t.type,n="string"==typeof e?{text:e}:e;return n.format="json",this.getUrl(r===h.REVERSE?this.reverseUrl:this.searchUrl,n)},n.parse=function(t){return(Array.isArray(t.data.results)?t.data.results:[t.data.results]).map(function(t){return{x:Number(t.lon),y:Number(t.lat),label:t.formatted,bounds:[[parseFloat(t.bbox.lat1),parseFloat(t.bbox.lon1)],[parseFloat(t.bbox.lat2),parseFloat(t.bbox.lon2)]],raw:t}})},e}(x);export{L as AlgoliaProvider,k as BingProvider,q as CivilDefenseMapProvider,U as EsriProvider,D as GeoApiFrProvider,w as GeoSearchControl,T as GeoapifyProvider,C as GeocodeEarthProvider,A as GoogleProvider,O as HereProvider,x as JsonProvider,N as LegacyGoogleProvider,_ as LocationIQProvider,B as MapBoxProvider,M as OpenCageProvider,F as OpenStreetMapProvider,S as PeliasProvider,w as SearchControl,m as SearchElement};
2//# sourceMappingURL=geosearch.module.js.map