!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("leaflet"),require("esri-leaflet"),require("esri-leaflet-geocoder")):"function"==typeof define&&define.amd?define(["exports","leaflet","esri-leaflet","esri-leaflet-geocoder"],t):t(((e=e||self).L=e.L||{},e.L.esri=e.L.esri||{},e.L.esri.BootstrapGeocoder={}),e.L,e.L.esri,e.L.esri.Geocoding)}(this,function(e,h,i,t){"use strict";var s=h.Layer.extend({options:{allowMultipleResults:!0,placeholder:"Search for places or addresses",title:"Location Search",wrapperStyle:"input-group",suggestionGroupStyle:"dropdown-menu",selectedStyle:"geocoder-control-selected"},initialize:function(e){e.providers||(e.providers=[t.arcgisOnlineProvider()]),h.Util.setOptions(this,e),this._geosearchCore=t.geosearchCore(this,e),this._geosearchCore.addEventParent(this),this._geosearchCore._pendingSuggestions=[],this._geosearchCore._providers[0].addEventParent(this)},_renderSuggestions:function(e){var t,i=[];this._suggestions.style.display="block";for(var s=0;s<e.length;s++){var o=e[s];t||((t=h.DomUtil.create("ul",null,o.provider._contentsElement)).style.display="block");var r=h.DomUtil.create("li","geocoder-control-suggestion",t);r.innerHTML=o.text,r.provider=o.provider,r["data-magic-key"]=o.magicKey}return i.push(t),i},clear:function(){this._clearAllSuggestions()},_clearAllSuggestions:function(){this._suggestions.style.display="none";for(var e=0;e<this.options.providers.length;e++)this._clearProviderSuggestions(this.options.providers[e])},_clearProviderSuggestions:function(e){e._contentsElement.innerHTML=""},_finalizeSuggestions:function(e,t){e||(h.DomUtil.removeClass(this._input,"geocoder-control-loading"),t||this._clearAllSuggestions())},onAdd:function(e){this._map=e,i.Util.setEsriAttribution(e),this._input=document.getElementById(this.options.inputTag),this._wrapper=document.createElement("div"),h.DomUtil.addClass(this._wrapper,this.options.wrapperStyle),this._input.parentNode.insertBefore(this._wrapper,this._input),this._wrapper.appendChild(this._input),this._input.title=this.options.title,this._suggestions=document.createElement("div"),h.DomUtil.addClass(this._suggestions,this.options.suggestionGroupStyle);for(var t=0;t<this.options.providers.length;t++)this.options.providers[t]._contentsElement=h.DomUtil.create("div",null,this._suggestions);this._input.parentNode.insertBefore(this._suggestions,null),h.DomEvent.addListener(this._input,"focus",function(e){this._input.placeholder=this.options.placeholder},this),h.DomEvent.addListener(this._suggestions,"mousedown",function(e){var t=e.target||e.srcElement;this._geosearchCore._geocode(t.innerHTML,t["data-magic-key"],t.provider),this.clear()},this),h.DomEvent.addListener(this._input,"blur",function(e){this._input.placeholder="",this.clear()},this),h.DomEvent.addListener(this._input,"keydown",function(e){for(var t,i=this.options.selectedStyle,s=this._suggestions.querySelectorAll(".geocoder-control-suggestion"),o=this._suggestions.querySelectorAll("."+i)[0],r=0;r<s.length;r++)if(s[r]===o){t=r;break}switch(e.keyCode){case 13:o?(this._geosearchCore._geocode(o.innerText,o["data-magic-key"],o.provider),this.clear()):this.options.allowMultipleResults?(this._geosearchCore._geocode(this._input.value,void 0),this.clear()):h.DomUtil.addClass(s[0],i),h.DomEvent.preventDefault(e);break;case 38:o&&L.DomUtil.removeClass(o,i);var n=s[t-1];o&&n?h.DomUtil.addClass(n,i):h.DomUtil.addClass(s[s.length-1],i),h.DomEvent.preventDefault(e);break;case 40:o&&h.DomUtil.removeClass(o,i);var l=s[t+1];o&&l?h.DomUtil.addClass(l,i):h.DomUtil.addClass(s[0],i),h.DomEvent.preventDefault(e);break;default:for(var a=0;a<this._geosearchCore._pendingSuggestions.length;a++){var d=this._geosearchCore._pendingSuggestions[a];d&&d.abort&&!d.id&&d.abort()}}},this),h.DomEvent.addListener(this._input,"keyup",h.Util.throttle(function(e){var t=e.which||e.keyCode,i=(e.target||e.srcElement).value;if(i.length<2)return this._lastValue=this._input.value,void this._clearAllSuggestions();27!==t?13!==t&&38!==t&&40!==t&&this._input.value!==this._lastValue&&(this._lastValue=this._input.value,this._geosearchCore._suggest(i)):this._clearAllSuggestions()},50,this),this)}});e.Search=s,e.search=function(e){return new s(e)},Object.defineProperty(e,"__esModule",{value:!0})});
//# sourceMappingURL=bootstrap-geocoder.js.map
