!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,e.MapboxGeocoder=t()}}(function(){var t;return function(){function t(e,n,r){function i(o,a){if(!n[o]){if(!e[o]){var u="function"==typeof require&&require;if(!a&&u)return u(o,!0);if(s)return s(o,!0);var l=new Error("Cannot find module '"+o+"'");throw l.code="MODULE_NOT_FOUND",l}var c=n[o]={exports:{}};e[o][0].call(c.exports,function(t){return i(e[o][1][t]||t)},c,c.exports,t,e,n,r)}return n[o].exports}for(var s="function"==typeof require&&require,o=0;o0&&(this.send(this.eventQueue),this.eventQueue=new Array),this.timer&&clearTimeout(this.timer),this.flushInterval&&(this.timer=setTimeout(this.flush.bind(this),this.flushInterval))},push:function(t,e){this.eventQueue.push(t),(this.eventQueue.length>=this.maxQueueSize||e)&&this.flush()},remove:function(){this.flush()}},e.exports=r},{nanoid:30}],2:[function(t,e,n){e.exports={fr:{name:"France",bbox:[[-4.59235,41.380007],[9.560016,51.148506]]},us:{name:"United States",bbox:[[-171.791111,18.91619],[-66.96466,71.357764]]},ru:{name:"Russia",bbox:[[19.66064,41.151416],[190.10042,81.2504]]},ca:{name:"Canada",bbox:[[-140.99778,41.675105],[-52.648099,83.23324]]}}},{}],3:[function(t,e,n){"use strict";function r(t){this._eventEmitter=new u,this.options=a({},this.options,t),this.inputString="",this.fresh=!0,this.lastSelected=null}var i,s=t("suggestions"),o=t("lodash.debounce"),a=t("xtend"),u=t("events").EventEmitter,l=t("./exceptions"),c=t("@mapbox/mapbox-sdk"),h=t("@mapbox/mapbox-sdk/services/geocoding"),p=t("./events"),f=t("./localization"),d=t("subtag");r.prototype={options:{zoom:16,flyTo:!0,trackProximity:!0,minLength:2,reverseGeocode:!1,limit:5,origin:"https://api.mapbox.com",enableEventLogging:!0,marker:!0,mapboxgl:null,collapsed:!1,getItemValue:function(t){return t.place_name},render:function(t){var e=t.place_name.split(",");return'
'+e[0]+'
'+e.splice(1,e.length).join(",")+"
"}},onAdd:function(t){this._map=t,this.setLanguage(),i=h(c({accessToken:this.options.accessToken,origin:this.options.origin})),this.eventManager=new p(this.options),this._onChange=this._onChange.bind(this),this._onKeyDown=this._onKeyDown.bind(this),this._showButton=this._showButton.bind(this),this._hideButton=this._hideButton.bind(this),this._onQueryResult=this._onQueryResult.bind(this),this.clear=this.clear.bind(this),this._updateProximity=this._updateProximity.bind(this),this._collapse=this._collapse.bind(this),this._unCollapse=this._unCollapse.bind(this);var e=this.container=document.createElement("div");e.className="mapboxgl-ctrl-geocoder mapboxgl-ctrl";var n=this.createIcon("search",'');this._inputEl=document.createElement("input"),this._inputEl.type="text",this.setPlaceholder(),this.options.collapsed&&(this._collapse(),this.container.addEventListener("mouseenter",this._unCollapse),this.container.addEventListener("mouseleave",this._collapse),this._inputEl.addEventListener("focus",this._unCollapse),this._inputEl.addEventListener("blur",this._collapse)),this._inputEl.addEventListener("keydown",o(this._onKeyDown,200)),this._inputEl.addEventListener("change",this._onChange),this.container.addEventListener("mouseenter",this._showButton),this.container.addEventListener("mouseleave",this._hideButton),this._inputEl.addEventListener("keyup",function(t){this.eventManager.keyevent(t,this)}.bind(this));var r=document.createElement("div");r.classList.add("geocoder-pin-right"),this._clearEl=document.createElement("button"),this._clearEl.setAttribute("aria-label","Clear"),this._clearEl.addEventListener("click",this.clear);var a=this.createIcon("close",'');return this._clearEl.appendChild(a),this._loadingEl=this.createIcon("loading",''),r.appendChild(this._clearEl),r.appendChild(this._loadingEl),e.appendChild(n),e.appendChild(this._inputEl),e.appendChild(r),this._typeahead=new s(this._inputEl,[],{filter:!1,minLength:this.options.minLength,limit:this.options.limit}),this.setRenderFunction(this.options.render),this._typeahead.getItemValue=this.options.getItemValue,this.options.trackProximity&&(this._updateProximity(),this._map.on("moveend",this._updateProximity)),this.mapMarker=null,this._handleMarker=this._handleMarker.bind(this),this._mapboxgl=this.options.mapboxgl,!this._mapboxgl&&this.options.marker&&(console.error("No mapboxgl detected in options. Map markers are disabled. Please set options.mapboxgl."),this.options.marker=!1),e},createIcon:function(t,e){var n=document.createElementNS("http://www.w3.org/2000/svg","svg");return n.setAttribute("class","geocoder-icon geocoder-icon-"+t),n.setAttribute("viewBox","0 0 18 18"),n.setAttribute("xml:space","preserve"),n.setAttribute("width",18),n.setAttribute("height",18),n.innerHTML=e,n},onRemove:function(){return this.container.parentNode.removeChild(this.container),this.options.trackProximity&&this._map.off("moveend",this._updateProximity),this._removeMarker(),this._map=null,this},_onKeyDown:function(t){var e=t.target&&t.target.shadowRoot?t.target.shadowRoot.activeElement:t.target;if(!(e?e.value:""))return this.fresh=!0,9!==t.keyCode&&this.clear(t),this._clearEl.style.display="none";t.metaKey||-1!==[9,27,37,39,13,38,40].indexOf(t.keyCode)||e.value.length>=this.options.minLength&&this._geocode(e.value)},_showButton:function(){this._typeahead.selected&&(this._clearEl.style.display="block")},_hideButton:function(){this._typeahead.selected&&(this._clearEl.style.display="none")},_onChange:function(){var t=this._typeahead.selected;if(t&&t.id!==this.lastSelected){if(this._clearEl.style.display="none",this.options.flyTo){var e;if(t.properties&&!l[t.properties.short_code]&&t.bbox){var n=t.bbox;e=a({},this.options.flyTo),this._map.fitBounds([[n[0],n[1]],[n[2],n[3]]],e)}else if(t.properties&&l[t.properties.short_code])e=a({},this.options.flyTo),this._map.fitBounds(l[t.properties.short_code].bbox,e);else{var r={zoom:this.options.zoom};e=a({},r,this.options.flyTo),e.center=t.center,this._map.flyTo(e)}}this.options.marker&&this._mapboxgl&&this._handleMarker(t),this._eventEmitter.emit("result",{result:t}),this.eventManager.select(t,this),this.lastSelected=t.id}},_geocode:function(t){this._loadingEl.style.display="block",this._eventEmitter.emit("loading",{query:t}),this.inputString=t;var e,n=["bbox","limit","proximity","countries","types","language","reverseMode"],r=this,s=n.reduce(function(t,e){return r.options[e]&&(["countries","types","language"].indexOf(e)>-1?t[e]=r.options[e].split(/[\s,]+/):t[e]=r.options[e],"proximity"===e&&r.options[e]&&r.options[e].longitude&&r.options[e].latitude&&(t[e]=[r.options[e].longitude,r.options[e].latitude])),t},{});if(this.options.reverseGeocode&&/(-?\d+\.?\d*)[, ]+(-?\d+\.?\d*)[ ]*$/.test(t)){var o=t.split(/[\s(,)?]+/).map(function(t){return parseFloat(t,10)}).reverse();s.types&&s.types[0],s=a(s,{query:o,limit:1}),e=i.reverseGeocode(s).send()}else s=a(s,{query:t}),e=i.forwardGeocode(s).send();var u=[];return this.options.localGeocoder&&((u=this.options.localGeocoder(t))||(u=[])),e.then(function(t){this._loadingEl.style.display="none";var e={};"200"==t.statusCode&&(e=t.body),e.features=e.features?u.concat(e.features):u,this.options.filter&&e.features.length&&(e.features=e.features.filter(this.options.filter)),e.features.length?this._clearEl.style.display="block":(this._clearEl.style.display="none",this._typeahead.selected=null),e.config=s,this.fresh&&(this.eventManager.start(this),this.fresh=!1),this._eventEmitter.emit("results",e),this._typeahead.update(e.features)}.bind(this)),e.catch(function(t){this._loadingEl.style.display="none",u.length?this._clearEl.style.display="block":(this._clearEl.style.display="none",this._typeahead.selected=null),this._eventEmitter.emit("results",{features:u}),this._typeahead.update(u),this._eventEmitter.emit("error",{error:t})}.bind(this)),e},clear:function(t){t&&t.preventDefault(),this._inputEl.value="",this._typeahead.selected=null,this._typeahead.clear(),this._onChange(),this._inputEl.focus(),this._clearEl.style.display="none",this._removeMarker(),this.lastSelected=null,this._eventEmitter.emit("clear"),this.fresh=!0},_onQueryResult:function(t){var e=t.body;if(e.features.length){var n=e.features[0];this._typeahead.selected=n,this._inputEl.value=n.place_name,this._onChange()}},_updateProximity:function(){if(this._map.getZoom()>9){var t=this._map.getCenter().wrap();this.setProximity({longitude:t.lng,latitude:t.lat})}else this.setProximity(null)},_collapse:function(){this._inputEl.value||this._inputEl===document.activeElement||this.container.classList.add("geocoder-collapsed")},_unCollapse:function(){this.container.classList.remove("geocoder-collapsed")},query:function(t){return this._geocode(t).then(this._onQueryResult),this},_getPlaceholderText:function(){if(this.options.placeholder)return this.options.placeholder;if(this.options.language){var t=this.options.language.split(",")[0],e=d.language(t),n=f.placeholder[e];if(n)return n}return"Search"},setInput:function(t){return this._inputEl.value=t,this._typeahead.selected=null,this._typeahead.clear(),this._onChange(),this},setProximity:function(t){return this.options.proximity=t,this},getProximity:function(){return this.options.proximity},setRenderFunction:function(t){return t&&"function"==typeof t&&(this._typeahead.render=t),this},getRenderFunction:function(){return this._typeahead.render},setLanguage:function(t){var e=navigator.language||navigator.userLanguage||navigator.browserLanguage;return this.options.language=t||this.options.language||e,this},getLanguage:function(){return this.options.language},getZoom:function(){return this.options.zoom},setZoom:function(t){return this.options.zoom=t,this},getFlyTo:function(){return this.options.flyTo},setFlyTo:function(t){return this.options.flyTo=t,this},getPlaceholder:function(){return this.options.placeholder},setPlaceholder:function(t){return this.placeholder=t||this._getPlaceholderText(),this._inputEl.placeholder=this.placeholder,this},getBbox:function(){return this.options.bbox},setBbox:function(t){return this.options.bbox=t,this},getCountries:function(){return this.options.countries},setCountries:function(t){return this.options.countries=t,this},getTypes:function(){return this.options.types},setTypes:function(t){return this.options.types=t,this},getMinLength:function(){return this.options.minLength},setMinLength:function(t){return this.options.minLength=t,this._typeahead&&(this._typeahead.minLength=t),this},getLimit:function(){return this.options.limit},setLimit:function(t){return this.options.limit=t,this._typeahead&&(this._typeahead.options.limit=t),this},getFilter:function(){return this.options.filter},setFilter:function(t){return this.options.filter=t,this},_handleMarker:function(t){this._removeMarker();var e={color:"#4668F2"},n=a({},e,this.options.marker);return this.mapMarker=new this._mapboxgl.Marker(n),this.mapMarker.setLngLat(t.center).addTo(this._map),this},_removeMarker:function(){this.mapMarker&&(this.mapMarker.remove(),this.mapMarker=null)},on:function(t,e){return this._eventEmitter.on(t,e),this},off:function(t,e){return this._eventEmitter.removeListener(t,e),this.eventManager.remove(),this}},e.exports=r},{"./events":1,"./exceptions":2,"./localization":4,"@mapbox/mapbox-sdk":6,"@mapbox/mapbox-sdk/services/geocoding":17,events:25,"lodash.debounce":29,subtag:32,suggestions:33,xtend:36}],4:[function(t,e,n){"use strict";var r={de:"Suche",it:"Ricerca",en:"Search",nl:"Zoeken",fr:"Chercher",ca:"Cerca",he:"לחפש",ja:"サーチ",lv:"Meklēt",pt:"Procurar",sr:"Претрага",zh:"搜索",cs:"Vyhledávání",hu:"Keresés",ka:"ძიება",nb:"Søke",sk:"Vyhľadávanie",th:"ค้นหา",fi:"Hae",is:"Leita",ko:"수색",pl:"Szukaj",sl:"Iskanje"};e.exports={placeholder:r}},{}],5:[function(t,e,n){"use strict";function r(t){var e=Array.isArray(t),n=function(n){return e?t[n]:t};return function(r){var s=i(v.plainArray,r);if(s)return s;if(e&&r.length!==t.length)return"an array with "+t.length+" items";for(var o=0;ot.length?e:t})}},v.equal=function(t){return function(e){if(e!==t)return JSON.stringify(t)}},v.oneOf=function(){var t=Array.isArray(arguments[0])?arguments[0]:Array.prototype.slice.call(arguments),e=t.map(function(t){return v.equal(t)});return v.oneOfType.apply(this,e)},v.range=function(t){var e=t[0],n=t[1];return function(t){if(i(v.number,t)||tn)return"number between "+e+" & "+n+" (inclusive)"}},v.any=function(){},v.boolean=function(t){if("boolean"!=typeof t)return"boolean"},v.number=function(t){if("number"!=typeof t)return"number"},v.plainArray=function(t){if(!Array.isArray(t))return"array"},v.plainObject=function(t){if(!p(t))return"object"},v.string=function(t){if("string"!=typeof t)return"string"},v.func=function(t){if("function"!=typeof t)return"function"},v.validate=i,v.processMessage=s,e.exports=v},{"is-plain-obj":28,xtend:36}],6:[function(t,e,n){"use strict";var r=t("./lib/client");e.exports=r},{"./lib/client":7}],7:[function(t,e,n){"use strict";function r(t){o.call(this,t)}function i(t){return new r(t)}var s=t("./browser-layer"),o=t("../classes/mapi-client");r.prototype=Object.create(o.prototype),r.prototype.constructor=r,r.prototype.sendRequest=s.browserSend,r.prototype.abortRequest=s.browserAbort,e.exports=i},{"../classes/mapi-client":9,"./browser-layer":8}],8:[function(t,e,n){"use strict";function r(t){var e=f[t.id];e&&(e.abort(),delete f[t.id])}function i(t,e){return new l(t,{body:e.response,headers:p(e.getAllResponseHeaders()),statusCode:e.status})}function s(t){var e=t.total,n=t.loaded;return{total:e,transferred:n,percent:100*n/e}}function o(t,e){return new Promise(function(n,r){e.onprogress=function(e){t.emitter.emit(h.EVENT_PROGRESS_DOWNLOAD,s(e))};var i=t.file;i&&(e.upload.onprogress=function(e){t.emitter.emit(h.EVENT_PROGRESS_UPLOAD,s(e))}),e.onerror=function(t){r(t)},e.onabort=function(){var e=new c({request:t,type:h.ERROR_REQUEST_ABORTED});r(e)},e.onload=function(){if(delete f[t.id],e.status<200||e.status>=400){var i=new c({request:t,body:e.response,statusCode:e.status});return void r(i)}n(e)};var o=t.body;"string"==typeof o?e.send(o):o?e.send(JSON.stringify(o)):i?e.send(i):e.send(),f[t.id]=e}).then(function(e){return i(t,e)})}function a(t,e){var n=t.url(e),r=new window.XMLHttpRequest;return r.open(t.method,n),Object.keys(t.headers).forEach(function(e){r.setRequestHeader(e,t.headers[e])}),r}function u(t){return Promise.resolve().then(function(){var e=a(t,t.client.accessToken);return o(t,e)})}var l=t("../classes/mapi-response"),c=t("../classes/mapi-error"),h=t("../constants"),p=t("../helpers/parse-headers"),f={};e.exports={browserAbort:r,sendRequestXhr:o,browserSend:u,createRequestXhr:a}},{"../classes/mapi-error":10,"../classes/mapi-response":12,"../constants":13,"../helpers/parse-headers":14}],9:[function(t,e,n){"use strict";function r(t){if(!t||!t.accessToken)throw new Error("Cannot create a client without an access token");i(t.accessToken),this.accessToken=t.accessToken,this.origin=t.origin||o.API_ORIGIN}var i=t("@mapbox/parse-mapbox-token"),s=t("./mapi-request"),o=t("../constants");r.prototype.createRequest=function(t){return new s(this,t)},e.exports=r},{"../constants":13,"./mapi-request":11,"@mapbox/parse-mapbox-token":23}],10:[function(t,e,n){"use strict";function r(t){var e,n=t.type||i.ERROR_HTTP;if(t.body)try{e=JSON.parse(t.body)}catch(n){e=t.body}else e=null;var r=t.message||null;r||("string"==typeof e?r=e:e&&"string"==typeof e.message?r=e.message:n===i.ERROR_REQUEST_ABORTED&&(r="Request aborted")),this.message=r,this.type=n,this.statusCode=t.statusCode||null,this.request=t.request,this.body=e}var i=t("../constants");e.exports=r},{"../constants":13}],11:[function(t,e,n){"use strict";function r(t,e){if(!t)throw new Error("MapiRequest requires a client");if(!e||!e.path||!e.method)throw new Error("MapiRequest requires an options object with path and method properties");var n={};e.body&&(n["content-type"]="application/json");var r=s(n,e.headers),i=Object.keys(r).reduce(function(t,e){return t[e.toLowerCase()]=r[e],t},{});this.id=l++,this._options=e,this.emitter=new o,this.client=t,this.response=null,this.error=null,this.sent=!1,this.aborted=!1,this.path=e.path,this.method=e.method,this.origin=e.origin||t.origin,this.query=e.query||{},this.params=e.params||{},this.body=e.body||null,this.file=e.file||null,this.headers=i}var i=t("@mapbox/parse-mapbox-token"),s=t("xtend"),o=t("eventemitter3"),a=t("../helpers/url-utils"),u=t("../constants"),l=1;r.prototype.url=function(t){var e=a.prependOrigin(this.path,this.origin);e=a.appendQueryObject(e,this.query);var n=this.params;if(t){e=a.appendQueryParam(e,"access_token",t);var r=i(t).user;n=s({ownerId:r},n)}return e=a.interpolateRouteParams(e,n),e},r.prototype.send=function(){var t=this;if(t.sent)throw new Error("This request has already been sent. Check the response and error properties. Create a new request with clone().");return t.sent=!0,t.client.sendRequest(t).then(function(e){return t.response=e,t.emitter.emit(u.EVENT_RESPONSE,e),e},function(e){throw t.error=e,t.emitter.emit(u.EVENT_ERROR,e),e})},r.prototype.abort=function(){this._nextPageRequest&&(this._nextPageRequest.abort(),delete this._nextPageRequest),this.response||this.error||this.aborted||(this.aborted=!0,this.client.abortRequest(this))},r.prototype.eachPage=function(t){function e(e){function n(){delete i._nextPageRequest;var t=e.nextPage();t&&(i._nextPageRequest=t,r(t))}t(null,e,n)}function n(e){t(e,null,function(){})}function r(t){t.send().then(e,n)}var i=this;r(this)},r.prototype.clone=function(){return this._extend()},r.prototype._extend=function(t){var e=s(this._options,t);return new r(this.client,e)},e.exports=r},{"../constants":13,"../helpers/url-utils":16,"@mapbox/parse-mapbox-token":23,eventemitter3:26,xtend:36}],12:[function(t,e,n){"use strict";function r(t,e){this.request=t,this.headers=e.headers,this.rawBody=e.body,this.statusCode=e.statusCode;try{this.body=JSON.parse(e.body||"{}")}catch(t){this.body=e.body}this.links=i(this.headers.link)}var i=t("../helpers/parse-link-header");r.prototype.hasNextPage=function(){return!!this.links.next},r.prototype.nextPage=function(){return this.hasNextPage()?this.request._extend({path:this.links.next.url}):null},e.exports=r},{"../helpers/parse-link-header":15}],13:[function(t,e,n){"use strict";e.exports={API_ORIGIN:"https://api.mapbox.com",EVENT_PROGRESS_DOWNLOAD:"downloadProgress",EVENT_PROGRESS_UPLOAD:"uploadProgress",EVENT_ERROR:"error",EVENT_RESPONSE:"response",ERROR_HTTP:"HttpError",ERROR_REQUEST_ABORTED:"RequestAbortedError"}},{}],14:[function(t,e,n){"use strict";function r(t){var e=t.indexOf(":");return{name:t.substring(0,e).trim().toLowerCase(),value:t.substring(e+1).trim()}}function i(t){var e={};return t?(t.trim().split(/[\r|\n]+/).forEach(function(t){var n=r(t);e[n.name]=n.value}),e):e}e.exports=i},{}],15:[function(t,e,n){"use strict";function r(t){var e=t.match(/\s*(.+)\s*=\s*"?([^"]+)"?/);return e?{key:e[1],value:e[2]}:null}function i(t){var e=t.match(/]*)>(.*)/);if(!e)return null;var n=e[1],i=e[2].split(";"),s=null,o=i.reduce(function(t,e){var n=r(e);return n?"rel"===n.key?(s||(s=n.value),t):(t[n.key]=n.value,t):t},{});return s?{url:n,rel:s,params:o}:null}function s(t){return t?t.split(/,\s*>(-2*i&6)));return s},f=function(t){t=String(t),/[^\0-\xFF]/.test(t)&&l("The string to be encoded contains characters outside of the Latin1 range.");for(var e,n,r,i,s=t.length%3,o="",a=-1,u=t.length-s;++a>18&63)+c.charAt(i>>12&63)+c.charAt(i>>6&63)+c.charAt(63&i);return 2==s?(e=t.charCodeAt(a)<<8,n=t.charCodeAt(++a),i=e+n,o+=c.charAt(i>>10)+c.charAt(i>>4&63)+c.charAt(i<<2&63)+"="):1==s&&(i=t.charCodeAt(a),o+=c.charAt(i>>2)+c.charAt(i<<4&63)+"=="),o},d={encode:f,decode:p,version:"0.1.0"};if("function"==typeof t&&"object"==typeof t.amd&&t.amd)t(function(){return d });else if(s&&!s.nodeType)if(o)o.exports=d;else for(var v in d)d.hasOwnProperty(v)&&(s[v]=d[v]);else i.base64=d}(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],25:[function(t,e,n){function r(){this._events&&Object.prototype.hasOwnProperty.call(this,"_events")||(this._events=x(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0}function i(t){return void 0===t._maxListeners?r.defaultMaxListeners:t._maxListeners}function s(t,e,n){if(e)t.call(n);else for(var r=t.length,i=y(t,r),s=0;s0&&a.length>s){a.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+a.length+' "'+String(e)+'" listeners added. Use emitter.setMaxListeners() to increase limit.');u.name="MaxListenersExceededWarning",u.emitter=t,u.type=e,u.count=a.length,"object"==typeof console&&console.warn&&console.warn("%s: %s",u.name,u.message)}}else a=o[e]=n,++t._eventsCount;return t}function h(){if(!this.fired)switch(this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length){case 0:return this.listener.call(this.target);case 1:return this.listener.call(this.target,arguments[0]);case 2:return this.listener.call(this.target,arguments[0],arguments[1]);case 3:return this.listener.call(this.target,arguments[0],arguments[1],arguments[2]);default:for(var t=new Array(arguments.length),e=0;e1&&(e=arguments[1]),e instanceof Error)throw e;var f=new Error('Unhandled "error" event. ('+e+")");throw f.context=e,f}if(!(n=h[t]))return!1;var d="function"==typeof n;switch(r=arguments.length){case 1:s(n,d,this);break;case 2:o(n,d,this,arguments[1]);break;case 3:a(n,d,this,arguments[1],arguments[2]);break;case 4:u(n,d,this,arguments[1],arguments[2],arguments[3]);break;default:for(i=new Array(r-1),c=1;c=0;s--)if(n[s]===e||n[s].listener===e){o=n[s].listener,i=s;break}if(i<0)return this;0===i?n.shift():v(n,i),1===n.length&&(r[t]=n[0]),r.removeListener&&this.emit("removeListener",t,o||e)}return this},r.prototype.removeAllListeners=function(t){var e,n,r;if(!(n=this._events))return this;if(!n.removeListener)return 0===arguments.length?(this._events=x(null),this._eventsCount=0):n[t]&&(0==--this._eventsCount?this._events=x(null):delete n[t]),this;if(0===arguments.length){var i,s=w(n);for(r=0;r=0;r--)this.removeListener(t,e[r]);return this},r.prototype.listeners=function(t){return f(this,t,!0)},r.prototype.rawListeners=function(t){return f(this,t,!1)},r.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):d.call(t,e)},r.prototype.listenerCount=d,r.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]}},{}],26:[function(t,e,n){"use strict";function r(){}function i(t,e,n){this.fn=t,this.context=e,this.once=n||!1}function s(t,e,n,r,s){if("function"!=typeof n)throw new TypeError("The listener must be a function");var o=new i(n,r||t,s),a=l?l+e:e;return t._events[a]?t._events[a].fn?t._events[a]=[t._events[a],o]:t._events[a].push(o):(t._events[a]=o,t._eventsCount++),t}function o(t,e){0==--t._eventsCount?t._events=new r:delete t._events[e]}function a(){this._events=new r,this._eventsCount=0}var u=Object.prototype.hasOwnProperty,l="~";Object.create&&(r.prototype=Object.create(null),(new r).__proto__||(l=!1)),a.prototype.eventNames=function(){var t,e,n=[];if(0===this._eventsCount)return n;for(e in t=this._events)u.call(t,e)&&n.push(l?e.slice(1):e);return Object.getOwnPropertySymbols?n.concat(Object.getOwnPropertySymbols(t)):n},a.prototype.listeners=function(t){var e=l?l+t:t,n=this._events[e];if(!n)return[];if(n.fn)return[n.fn];for(var r=0,i=n.length,s=new Array(i);r=e||n<0||k&&r>=m}function c(){var t=w();if(l(t))return h(t);b=setTimeout(c,u(t))}function h(t){return b=void 0,T&&v?i(t):(v=y=void 0,g)}function p(){void 0!==b&&clearTimeout(b),L=0,v=E=y=b=void 0}function f(){return void 0===b?g:h(w())}function d(){var t=w(),n=l(t);if(v=arguments,y=this,E=t,n){if(void 0===b)return s(E);if(k)return b=setTimeout(c,e),i(E)}return void 0===b&&(b=setTimeout(c,e)),g}var v,y,m,g,b,E,L=0,O=!1,k=!1,T=!0;if("function"!=typeof t)throw new TypeError(a);return e=o(e)||0,r(n)&&(O=!!n.leading,k="maxWait"in n,m=k?_(o(n.maxWait)||0,e):m,T="trailing"in n?!!n.trailing:T),d.cancel=p,d.flush=f,d}function r(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function i(t){return!!t&&"object"==typeof t}function s(t){return"symbol"==typeof t||i(t)&&b.call(t)==l}function o(t){if("number"==typeof t)return t;if(s(t))return u;if(r(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=r(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=t.replace(c,"");var n=p.test(t);return n||f.test(t)?d(t.slice(2),n?2:8):h.test(t)?u:+t}var a="Expected a function",u=NaN,l="[object Symbol]",c=/^\s+|\s+$/g,h=/^[-+]0x[0-9a-f]+$/i,p=/^0b[01]+$/i,f=/^0o[0-7]+$/i,d=parseInt,v="object"==typeof t&&t&&t.Object===Object&&t,y="object"==typeof self&&self&&self.Object===Object&&self,m=v||y||Function("return this")(),g=Object.prototype,b=g.toString,_=Math.max,x=Math.min,w=function(){return m.Date.now()};e.exports=n}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],30:[function(t,e,n){(function(t){if("production"!==t.env.NODE_ENV&&("undefined"==typeof self||!self.crypto&&!self.msCrypto))throw new Error("Your browser does not have secure random generator. If you don’t need unpredictable IDs, you can use nanoid/non-secure.");var n=self.crypto||self.msCrypto;e.exports=function(t){t=t||21;for(var e="",r=n.getRandomValues(new Uint8Array(t));01)for(var n=1;n-1},o.prototype.value=function(t){if(this.selected=t,this.el.value=this.getItemValue(t),document.createEvent){var e=document.createEvent("HTMLEvents");e.initEvent("change",!0,!1),this.el.dispatchEvent(e)}else this.el.fireEvent("onchange")},o.prototype.getCandidates=function(t){var e,n={pre:"",post:"",extract:function(t){return this.getItemValue(t)}.bind(this)};this.options.filter?(e=i.filter(this.query,this.data,n),e=e.map(function(t){return{original:t.original,string:this.render(t.original,t.string)}}.bind(this))):e=this.data.map(function(t){return{original:t,string:this.render(t)}}.bind(this)),t(e)},o.prototype.getItemValue=function(t){return t},o.prototype.render=function(t,e){if(e)return e;for(var n=t.original?this.getItemValue(t.original):this.getItemValue(t),r=this.normalize(n),i=r.lastIndexOf(this.query);i>-1;){var s=i+this.query.length;n=n.slice(0,i)+""+n.slice(i,s)+""+n.slice(s),i=r.slice(0,i).lastIndexOf(this.query)}return n},e.exports=o},{"./list":34,fuzzy:27,xtend:36}],36:[function(t,e,n){function r(){for(var t={},e=0;e