react-map-gl-geocoder
Version:
React wrapper for mapbox-gl-geocoder for use with react-map-gl
1 lines • 73.7 kB
JavaScript
import{PureComponent as t}from"react";import e from"events";import{FlyToInterpolator as n}from"react-map-gl";var r="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function i(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function o(t,e){return t(e={exports:{}},e.exports),e.exports}var a=o(function(t,e){Object.defineProperty(e,"__esModule",{value:!0});var n="function"==typeof Symbol&&Symbol.for,r=n?Symbol.for("react.element"):60103,i=n?Symbol.for("react.portal"):60106,o=n?Symbol.for("react.fragment"):60107,a=n?Symbol.for("react.strict_mode"):60108,s=n?Symbol.for("react.profiler"):60114,u=n?Symbol.for("react.provider"):60109,c=n?Symbol.for("react.context"):60110,l=n?Symbol.for("react.async_mode"):60111,h=n?Symbol.for("react.concurrent_mode"):60111,p=n?Symbol.for("react.forward_ref"):60112,f=n?Symbol.for("react.suspense"):60113,d=n?Symbol.for("react.memo"):60115,y=n?Symbol.for("react.lazy"):60116;function g(t){if("object"==typeof t&&null!==t){var e=t.$$typeof;switch(e){case r:switch(t=t.type){case l:case h:case o:case s:case a:case f:return t;default:switch(t=t&&t.$$typeof){case c:case p:case u:return t;default:return e}}case y:case d:case i:return e}}}function m(t){return g(t)===h}e.typeOf=g,e.AsyncMode=l,e.ConcurrentMode=h,e.ContextConsumer=c,e.ContextProvider=u,e.Element=r,e.ForwardRef=p,e.Fragment=o,e.Lazy=y,e.Memo=d,e.Portal=i,e.Profiler=s,e.StrictMode=a,e.Suspense=f,e.isValidElementType=function(t){return"string"==typeof t||"function"==typeof t||t===o||t===h||t===s||t===a||t===f||"object"==typeof t&&null!==t&&(t.$$typeof===y||t.$$typeof===d||t.$$typeof===u||t.$$typeof===c||t.$$typeof===p)},e.isAsyncMode=function(t){return m(t)||g(t)===l},e.isConcurrentMode=m,e.isContextConsumer=function(t){return g(t)===c},e.isContextProvider=function(t){return g(t)===u},e.isElement=function(t){return"object"==typeof t&&null!==t&&t.$$typeof===r},e.isForwardRef=function(t){return g(t)===p},e.isFragment=function(t){return g(t)===o},e.isLazy=function(t){return g(t)===y},e.isMemo=function(t){return g(t)===d},e.isPortal=function(t){return g(t)===i},e.isProfiler=function(t){return g(t)===s},e.isStrictMode=function(t){return g(t)===a},e.isSuspense=function(t){return g(t)===f}});i(a);var s=o(function(t,e){"production"!==process.env.NODE_ENV&&function(){Object.defineProperty(e,"__esModule",{value:!0});var t="function"==typeof Symbol&&Symbol.for,n=t?Symbol.for("react.element"):60103,r=t?Symbol.for("react.portal"):60106,i=t?Symbol.for("react.fragment"):60107,o=t?Symbol.for("react.strict_mode"):60108,a=t?Symbol.for("react.profiler"):60114,s=t?Symbol.for("react.provider"):60109,u=t?Symbol.for("react.context"):60110,c=t?Symbol.for("react.async_mode"):60111,l=t?Symbol.for("react.concurrent_mode"):60111,h=t?Symbol.for("react.forward_ref"):60112,p=t?Symbol.for("react.suspense"):60113,f=t?Symbol.for("react.memo"):60115,d=t?Symbol.for("react.lazy"):60116,y=function(t){for(var e=arguments.length,n=Array(e>1?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];var i=0,o="Warning: "+t.replace(/%s/g,function(){return n[i++]});"undefined"!=typeof console&&console.warn(o);try{throw new Error(o)}catch(t){}};function g(t){if("object"==typeof t&&null!==t){var e=t.$$typeof;switch(e){case n:var y=t.type;switch(y){case c:case l:case i:case a:case o:case p:return y;default:var g=y&&y.$$typeof;switch(g){case u:case h:case s:return g;default:return e}}case d:case f:case r:return e}}}var m=c,v=l,b=u,_=s,x=n,w=h,E=i,M=d,O=f,j=r,P=a,S=o,k=p,R=!1;function C(t){return g(t)===l}e.typeOf=g,e.AsyncMode=m,e.ConcurrentMode=v,e.ContextConsumer=b,e.ContextProvider=_,e.Element=x,e.ForwardRef=w,e.Fragment=E,e.Lazy=M,e.Memo=O,e.Portal=j,e.Profiler=P,e.StrictMode=S,e.Suspense=k,e.isValidElementType=function(t){return"string"==typeof t||"function"==typeof t||t===i||t===l||t===a||t===o||t===p||"object"==typeof t&&null!==t&&(t.$$typeof===d||t.$$typeof===f||t.$$typeof===s||t.$$typeof===u||t.$$typeof===h)},e.isAsyncMode=function(t){return R||(R=!0,function(t,e){if(void 0===e)throw new Error("`lowPriorityWarning(condition, format, ...args)` requires a warning message argument");if(!t){for(var n=arguments.length,r=Array(n>2?n-2:0),i=2;i<n;i++)r[i-2]=arguments[i];y.apply(void 0,[e].concat(r))}}(!1,"The ReactIs.isAsyncMode() alias has been deprecated, and will be removed in React 17+. Update your code to use ReactIs.isConcurrentMode() instead. It has the exact same API.")),C(t)||g(t)===c},e.isConcurrentMode=C,e.isContextConsumer=function(t){return g(t)===u},e.isContextProvider=function(t){return g(t)===s},e.isElement=function(t){return"object"==typeof t&&null!==t&&t.$$typeof===n},e.isForwardRef=function(t){return g(t)===h},e.isFragment=function(t){return g(t)===i},e.isLazy=function(t){return g(t)===d},e.isMemo=function(t){return g(t)===f},e.isPortal=function(t){return g(t)===r},e.isProfiler=function(t){return g(t)===a},e.isStrictMode=function(t){return g(t)===o},e.isSuspense=function(t){return g(t)===p}}()});i(s);var u=o(function(t){t.exports="production"===process.env.NODE_ENV?a:s}),c=Object.getOwnPropertySymbols,l=Object.prototype.hasOwnProperty,h=Object.prototype.propertyIsEnumerable;function p(t){if(null==t)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(t)}var f=function(){try{if(!Object.assign)return!1;var t=new String("abc");if(t[5]="de","5"===Object.getOwnPropertyNames(t)[0])return!1;for(var e={},n=0;n<10;n++)e["_"+String.fromCharCode(n)]=n;if("0123456789"!==Object.getOwnPropertyNames(e).map(function(t){return e[t]}).join(""))return!1;var r={};return"abcdefghijklmnopqrst".split("").forEach(function(t){r[t]=t}),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},r)).join("")}catch(t){return!1}}()?Object.assign:function(t,e){for(var n,r,i=p(t),o=1;o<arguments.length;o++){for(var a in n=Object(arguments[o]))l.call(n,a)&&(i[a]=n[a]);if(c){r=c(n);for(var s=0;s<r.length;s++)h.call(n,r[s])&&(i[r[s]]=n[r[s]])}}return i},d="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED",y=function(){};if("production"!==process.env.NODE_ENV){var g=d,m={},v=Function.call.bind(Object.prototype.hasOwnProperty);y=function(t){var e="Warning: "+t;"undefined"!=typeof console&&console.error(e);try{throw new Error(e)}catch(t){}}}function b(t,e,n,r,i){if("production"!==process.env.NODE_ENV)for(var o in t)if(v(t,o)){var a;try{if("function"!=typeof t[o]){var s=Error((r||"React class")+": "+n+" type `"+o+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof t[o]+"`.");throw s.name="Invariant Violation",s}a=t[o](e,o,r,n,null,g)}catch(t){a=t}if(!a||a instanceof Error||y((r||"React class")+": type specification of "+n+" `"+o+"` is invalid; the type checker function must return `null` or an `Error` but returned a "+typeof a+". You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument)."),a instanceof Error&&!(a.message in m)){m[a.message]=!0;var u=i?i():"";y("Failed "+n+" type: "+a.message+(null!=u?u:""))}}}b.resetWarningCache=function(){"production"!==process.env.NODE_ENV&&(m={})};var _=b,x=Function.call.bind(Object.prototype.hasOwnProperty),w=function(){};function E(){return null}function M(){}function O(){}"production"!==process.env.NODE_ENV&&(w=function(t){var e="Warning: "+t;"undefined"!=typeof console&&console.error(e);try{throw new Error(e)}catch(t){}}),O.resetWarningCache=M;var j=o(function(t){t.exports="production"!==process.env.NODE_ENV?function(t,e){var n="function"==typeof Symbol&&Symbol.iterator,r="@@iterator",i="<<anonymous>>",o={array:l("array"),bool:l("boolean"),func:l("function"),number:l("number"),object:l("object"),string:l("string"),symbol:l("symbol"),any:c(E),arrayOf:function(t){return c(function(e,n,r,i,o){if("function"!=typeof t)return new s("Property `"+o+"` of component `"+r+"` has invalid PropType notation inside arrayOf.");var a=e[n];if(!Array.isArray(a))return new s("Invalid "+i+" `"+o+"` of type `"+p(a)+"` supplied to `"+r+"`, expected an array.");for(var u=0;u<a.length;u++){var c=t(a,u,r,i,o+"["+u+"]",d);if(c instanceof Error)return c}return null})},element:c(function(e,n,r,i,o){var a=e[n];return t(a)?null:new s("Invalid "+i+" `"+o+"` of type `"+p(a)+"` supplied to `"+r+"`, expected a single ReactElement.")}),elementType:c(function(t,e,n,r,i){var o=t[e];return u.isValidElementType(o)?null:new s("Invalid "+r+" `"+i+"` of type `"+p(o)+"` supplied to `"+n+"`, expected a single ReactElement type.")}),instanceOf:function(t){return c(function(e,n,r,o,a){var u;return e[n]instanceof t?null:new s("Invalid "+o+" `"+a+"` of type `"+((u=e[n]).constructor&&u.constructor.name?u.constructor.name:i)+"` supplied to `"+r+"`, expected instance of `"+(t.name||i)+"`.")})},node:c(function(t,e,n,r,i){return h(t[e])?null:new s("Invalid "+r+" `"+i+"` supplied to `"+n+"`, expected a ReactNode.")}),objectOf:function(t){return c(function(e,n,r,i,o){if("function"!=typeof t)return new s("Property `"+o+"` of component `"+r+"` has invalid PropType notation inside objectOf.");var a=e[n],u=p(a);if("object"!==u)return new s("Invalid "+i+" `"+o+"` of type `"+u+"` supplied to `"+r+"`, expected an object.");for(var c in a)if(x(a,c)){var l=t(a,c,r,i,o+"."+c,d);if(l instanceof Error)return l}return null})},oneOf:function(t){return Array.isArray(t)?c(function(e,n,r,i,o){for(var u=e[n],c=0;c<t.length;c++)if(a(u,t[c]))return null;var l=JSON.stringify(t,function(t,e){return"symbol"===y(e)?String(e):e});return new s("Invalid "+i+" `"+o+"` of value `"+String(u)+"` supplied to `"+r+"`, expected one of "+l+".")}):("production"!==process.env.NODE_ENV&&w(arguments.length>1?"Invalid arguments supplied to oneOf, expected an array, got "+arguments.length+" arguments. A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z]).":"Invalid argument supplied to oneOf, expected an array."),E)},oneOfType:function(t){if(!Array.isArray(t))return"production"!==process.env.NODE_ENV&&w("Invalid argument supplied to oneOfType, expected an instance of array."),E;for(var e=0;e<t.length;e++){var n=t[e];if("function"!=typeof n)return w("Invalid argument supplied to oneOfType. Expected an array of check functions, but received "+g(n)+" at index "+e+"."),E}return c(function(e,n,r,i,o){for(var a=0;a<t.length;a++)if(null==(0,t[a])(e,n,r,i,o,d))return null;return new s("Invalid "+i+" `"+o+"` supplied to `"+r+"`.")})},shape:function(t){return c(function(e,n,r,i,o){var a=e[n],u=p(a);if("object"!==u)return new s("Invalid "+i+" `"+o+"` of type `"+u+"` supplied to `"+r+"`, expected `object`.");for(var c in t){var l=t[c];if(l){var h=l(a,c,r,i,o+"."+c,d);if(h)return h}}return null})},exact:function(t){return c(function(e,n,r,i,o){var a=e[n],u=p(a);if("object"!==u)return new s("Invalid "+i+" `"+o+"` of type `"+u+"` supplied to `"+r+"`, expected `object`.");var c=f({},e[n],t);for(var l in c){var h=t[l];if(!h)return new s("Invalid "+i+" `"+o+"` key `"+l+"` supplied to `"+r+"`.\nBad object: "+JSON.stringify(e[n],null," ")+"\nValid keys: "+JSON.stringify(Object.keys(t),null," "));var y=h(a,l,r,i,o+"."+l,d);if(y)return y}return null})}};function a(t,e){return t===e?0!==t||1/t==1/e:t!=t&&e!=e}function s(t){this.message=t,this.stack=""}function c(t){if("production"!==process.env.NODE_ENV)var n={},r=0;function o(o,a,u,c,l,h,p){if(c=c||i,h=h||u,p!==d){if(e){var f=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use `PropTypes.checkPropTypes()` to call them. Read more at http://fb.me/use-check-prop-types");throw f.name="Invariant Violation",f}if("production"!==process.env.NODE_ENV&&"undefined"!=typeof console){var y=c+":"+u;!n[y]&&r<3&&(w("You are manually calling a React.PropTypes validation function for the `"+h+"` prop on `"+c+"`. This is deprecated and will throw in the standalone `prop-types` package. You may be seeing this warning due to a third-party PropTypes library. See https://fb.me/react-warning-dont-call-proptypes for details."),n[y]=!0,r++)}}return null==a[u]?o?new s(null===a[u]?"The "+l+" `"+h+"` is marked as required in `"+c+"`, but its value is `null`.":"The "+l+" `"+h+"` is marked as required in `"+c+"`, but its value is `undefined`."):null:t(a,u,c,l,h)}var a=o.bind(null,!1);return a.isRequired=o.bind(null,!0),a}function l(t){return c(function(e,n,r,i,o,a){var u=e[n];return p(u)!==t?new s("Invalid "+i+" `"+o+"` of type `"+y(u)+"` supplied to `"+r+"`, expected `"+t+"`."):null})}function h(e){switch(typeof e){case"number":case"string":case"undefined":return!0;case"boolean":return!e;case"object":if(Array.isArray(e))return e.every(h);if(null===e||t(e))return!0;var i=function(t){var i=e&&(n&&e[n]||e[r]);if("function"==typeof i)return i}();if(!i)return!1;var o,a=i.call(e);if(i!==e.entries){for(;!(o=a.next()).done;)if(!h(o.value))return!1}else for(;!(o=a.next()).done;){var s=o.value;if(s&&!h(s[1]))return!1}return!0;default:return!1}}function p(t){var e=typeof t;return Array.isArray(t)?"array":t instanceof RegExp?"object":function(t,e){return"symbol"===t||!!e&&("Symbol"===e["@@toStringTag"]||"function"==typeof Symbol&&e instanceof Symbol)}(e,t)?"symbol":e}function y(t){if(null==t)return""+t;var e=p(t);if("object"===e){if(t instanceof Date)return"date";if(t instanceof RegExp)return"regexp"}return e}function g(t){var e=y(t);switch(e){case"array":case"object":return"an "+e;case"boolean":case"date":case"regexp":return"a "+e;default:return e}}return s.prototype=Error.prototype,o.checkPropTypes=_,o.resetWarningCache=_.resetWarningCache,o.PropTypes=o,o}(u.isElement,!0):function(){function t(t,e,n,r,i,o){if(o!==d){var a=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw a.name="Invariant Violation",a}}function e(){return t}t.isRequired=t;var n={array:t,bool:t,func:t,number:t,object:t,string:t,symbol:t,any:t,arrayOf:e,element:t,elementType:t,instanceOf:e,node:t,objectOf:e,oneOf:e,oneOfType:e,shape:e,exact:e,checkPropTypes:O,resetWarningCache:M};return n.PropTypes=n,n}()}),P=function(){for(var t={},e=0;e<arguments.length;e++){var n=arguments[e];for(var r in n)S.call(n,r)&&(t[r]=n[r])}return t},S=Object.prototype.hasOwnProperty,k=o(function(t,e){!function(){var e={};t.exports=e,e.simpleFilter=function(t,n){return n.filter(function(n){return e.test(t,n)})},e.test=function(t,n){return null!==e.match(t,n)},e.match=function(t,e,n){var r,i=0,o=[],a=e.length,s=0,u=0,c=(n=n||{}).pre||"",l=n.post||"",h=n.caseSensitive&&e||e.toLowerCase();t=n.caseSensitive&&t||t.toLowerCase();for(var p=0;p<a;p++)r=e[p],h[p]===t[i]?(r=c+r+l,i+=1,u+=1+u):u=0,s+=u,o[o.length]=r;return i===t.length?(s=h===t?Infinity:s,{rendered:o.join(""),score:s}):null},e.filter=function(t,n,r){return n&&0!==n.length?"string"!=typeof t?n:(r=r||{},n.reduce(function(n,i,o,a){var s=i;r.extract&&(s=r.extract(i));var u=e.match(t,s,r);return null!=u&&(n[n.length]={string:u.rendered,score:u.score,index:o,original:i}),n},[]).sort(function(t,e){return e.score-t.score||t.index-e.index})):[]}}()}),R=function(t){return this.component=t,this.items=[],this.active=0,this.wrapper=document.createElement("div"),this.wrapper.className="suggestions-wrapper",this.element=document.createElement("ul"),this.element.className="suggestions",this.wrapper.appendChild(this.element),this.selectingListItem=!1,t.el.parentNode.insertBefore(this.wrapper,t.el.nextSibling),this};R.prototype.show=function(){this.element.style.display="block"},R.prototype.hide=function(){this.element.style.display="none"},R.prototype.add=function(t){this.items.push(t)},R.prototype.clear=function(){this.items=[],this.active=0},R.prototype.isEmpty=function(){return!this.items.length},R.prototype.isVisible=function(){return"block"===this.element.style.display},R.prototype.draw=function(){if(this.element.innerHTML="",0!==this.items.length){for(var t=0;t<this.items.length;t++)this.drawItem(this.items[t],this.active===t);this.show()}else this.hide()},R.prototype.drawItem=function(t,e){var n=document.createElement("li"),r=document.createElement("a");e&&(n.className+=" active"),r.innerHTML=t.string,n.appendChild(r),this.element.appendChild(n),n.addEventListener("mousedown",function(){this.selectingListItem=!0}.bind(this)),n.addEventListener("mouseup",function(){this.handleMouseUp.call(this,t)}.bind(this))},R.prototype.handleMouseUp=function(t){this.selectingListItem=!1,this.component.value(t.original),this.clear(),this.draw()},R.prototype.move=function(t){this.active=t,this.draw()},R.prototype.previous=function(){this.move(0===this.active?this.items.length-1:this.active-1)},R.prototype.next=function(){this.move(this.active===this.items.length-1?0:this.active+1)},R.prototype.drawError=function(t){var e=document.createElement("li");e.innerHTML=t,this.element.appendChild(e),this.show()};var C=R,A=function(t,e,n){return this.options=P({minLength:2,limit:5,filter:!0},n=n||{}),this.el=t,this.data=e||[],this.list=new C(this),this.query="",this.selected=null,this.list.draw(),this.el.addEventListener("keyup",function(t){this.handleKeyUp(t.keyCode)}.bind(this),!1),this.el.addEventListener("keydown",function(t){this.handleKeyDown(t)}.bind(this)),this.el.addEventListener("focus",function(){this.handleFocus()}.bind(this)),this.el.addEventListener("blur",function(){this.handleBlur()}.bind(this)),this.el.addEventListener("paste",function(t){this.handlePaste(t)}.bind(this)),this.render=this.options.render?this.options.render.bind(this):this.render.bind(this),this.getItemValue=this.options.getItemValue?this.options.getItemValue.bind(this):this.getItemValue.bind(this),this};A.prototype.handleKeyUp=function(t){40!==t&&38!==t&&27!==t&&13!==t&&9!==t&&this.handleInputChange(this.el.value)},A.prototype.handleKeyDown=function(t){switch(t.keyCode){case 13:case 9:this.list.isEmpty()||(this.list.isVisible()&&t.preventDefault(),this.value(this.list.items[this.list.active].original),this.list.hide());break;case 27:this.list.isEmpty()||this.list.hide();break;case 38:this.list.previous();break;case 40:this.list.next()}},A.prototype.handleBlur=function(){this.list.selectingListItem||this.list.hide()},A.prototype.handlePaste=function(t){if(t.clipboardData)this.handleInputChange(t.clipboardData.getData("Text"));else{var e=this;setTimeout(function(){e.handleInputChange(t.target.value)},100)}},A.prototype.handleInputChange=function(t){this.query=this.normalize(t),this.list.clear(),this.query.length<this.options.minLength?this.list.draw():this.getCandidates(function(t){for(var e=0;e<t.length&&(this.list.add(t[e]),e!==this.options.limit-1);e++);this.list.draw()}.bind(this))},A.prototype.handleFocus=function(){this.list.isEmpty()||this.list.show(),this.list.selectingListItem=!1},A.prototype.update=function(t){this.data=t,this.handleKeyUp()},A.prototype.clear=function(){this.data=[],this.list.clear()},A.prototype.normalize=function(t){return t.toLowerCase()},A.prototype.match=function(t,e){return t.indexOf(e)>-1},A.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")},A.prototype.getCandidates=function(t){var e={pre:"<strong>",post:"</strong>",extract:function(t){return this.getItemValue(t)}.bind(this)};t(this.options.filter?k.filter(this.query,this.data,e).map(function(t){return{original:t.original,string:this.render(t.original,t.string)}}.bind(this)):this.data.map(function(t){return{original:t,string:this.render(t)}}.bind(this)))},A.prototype.getItemValue=function(t){return t},A.prototype.render=function(t,e){if(e)return e;for(var n=this.getItemValue(t.original?t.original:t),r=this.normalize(n),i=r.lastIndexOf(this.query);i>-1;){var o=i+this.query.length;n=n.slice(0,i)+"<strong>"+n.slice(i,o)+"</strong>"+n.slice(o),i=r.slice(0,i).lastIndexOf(this.query)}return n},A.prototype.renderError=function(t){this.list.drawError(t)};var T=A,I=o(function(t){window.Suggestions=t.exports=T}),L=NaN,N="[object Symbol]",q=/^\s+|\s+$/g,F=/^[-+]0x[0-9a-f]+$/i,z=/^0b[01]+$/i,B=/^0o[0-7]+$/i,V=parseInt,D="object"==typeof r&&r&&r.Object===Object&&r,$="object"==typeof self&&self&&self.Object===Object&&self,G=D||$||Function("return this")(),U=Object.prototype.toString,Z=Math.max,Q=Math.min,H=function(){return G.Date.now()};function W(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function K(t){if("number"==typeof t)return t;if(function(t){return"symbol"==typeof t||function(t){return!!t&&"object"==typeof t}(t)&&U.call(t)==N}(t))return L;if(W(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=W(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=t.replace(q,"");var n=z.test(t);return n||B.test(t)?V(t.slice(2),n?2:8):F.test(t)?L:+t}var J={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]]}},Y=function(t){return t?t.split(/,\s*</).reduce(function(t,e){var n=function(t){var e=t.match(/<?([^>]*)>(.*)/);if(!e)return null;var n=e[1],r=e[2].split(";"),i=null,o=r.reduce(function(t,e){var n=function(t){var e=t.match(/\s*(.+)\s*=\s*"?([^"]+)"?/);return e?{key:e[1],value:e[2]}:null}(e);return n?"rel"===n.key?(i||(i=n.value),t):(t[n.key]=n.value,t):t},{});return i?{url:n,rel:i,params:o}:null}(e);return n?(n.rel.split(/\s+/).forEach(function(e){t[e]||(t[e]={url:n.url,params:n.params})}),t):t},{}):{}};function X(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=Y(this.headers.link)}X.prototype.hasNextPage=function(){return!!this.links.next},X.prototype.nextPage=function(){return this.hasNextPage()?this.request._extend({path:this.links.next.url}):null};var tt=X,et={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"},nt=function(t){var e,n=t.type||et.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===et.ERROR_REQUEST_ABORTED&&(r="Request aborted")),this.message=r,this.type=n,this.statusCode=t.statusCode||null,this.request=t.request,this.body=e},rt={};function it(t){var e=t.total,n=t.loaded;return{total:e,transferred:n,percent:100*n/e}}var ot=o(function(t,e){!function(n){var i=e,o=t&&t.exports==i&&t,a="object"==typeof r&&r;a.global!==a&&a.window!==a||(n=a);var s=function(t){this.message=t};(s.prototype=new Error).name="InvalidCharacterError";var u=function(t){throw new s(t)},c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",l=/[\t\n\f\r ]/g,h={encode:function(t){t=String(t),/[^\0-\xFF]/.test(t)&&u("The string to be encoded contains characters outside of the Latin1 range.");for(var e,n,r,i,o=t.length%3,a="",s=-1,l=t.length-o;++s<l;)e=t.charCodeAt(s)<<16,n=t.charCodeAt(++s)<<8,r=t.charCodeAt(++s),a+=c.charAt((i=e+n+r)>>18&63)+c.charAt(i>>12&63)+c.charAt(i>>6&63)+c.charAt(63&i);return 2==o?(e=t.charCodeAt(s)<<8,n=t.charCodeAt(++s),a+=c.charAt((i=e+n)>>10)+c.charAt(i>>4&63)+c.charAt(i<<2&63)+"="):1==o&&(i=t.charCodeAt(s),a+=c.charAt(i>>2)+c.charAt(i<<4&63)+"=="),a},decode:function(t){var e=(t=String(t).replace(l,"")).length;e%4==0&&(e=(t=t.replace(/==?$/,"")).length),(e%4==1||/[^+a-zA-Z0-9\/]/.test(t))&&u("Invalid character: the string to be decoded is not correctly encoded.");for(var n,r,i=0,o="",a=-1;++a<e;)r=c.indexOf(t.charAt(a)),n=i%4?64*n+r:r,i++%4&&(o+=String.fromCharCode(255&n>>(-2*i&6)));return o},version:"0.1.0"};if(i&&!i.nodeType)if(o)o.exports=h;else for(var p in h)h.hasOwnProperty(p)&&(i[p]=h[p]);else n.base64=h}(r)}),at={};function st(t,e){return Object.prototype.hasOwnProperty.call(t,e)}var ut=function(t){if(at[t])return at[t];var e=t.split("."),n=e[0],r=e[1];if(!r)throw new Error("Invalid token");var i=function(t){try{return JSON.parse(ot.decode(t))}catch(t){throw new Error("Invalid token")}}(r),o={usage:n,user:i.u};return st(i,"a")&&(o.authorization=i.a),st(i,"exp")&&(o.expires=1e3*i.exp),st(i,"iat")&&(o.created=1e3*i.iat),st(i,"scopes")&&(o.scopes=i.scopes),st(i,"client")&&(o.client=i.client),st(i,"ll")&&(o.lastLogin=i.ll),st(i,"iu")&&(o.impersonator=i.iu),at[t]=o,o},ct=o(function(t){var e=Object.prototype.hasOwnProperty,n="~";function r(){}function i(t,e,n){this.fn=t,this.context=e,this.once=n||!1}function o(t,e,r,o,a){if("function"!=typeof r)throw new TypeError("The listener must be a function");var s=new i(r,o||t,a),u=n?n+e:e;return t._events[u]?t._events[u].fn?t._events[u]=[t._events[u],s]:t._events[u].push(s):(t._events[u]=s,t._eventsCount++),t}function a(t,e){0==--t._eventsCount?t._events=new r:delete t._events[e]}function s(){this._events=new r,this._eventsCount=0}Object.create&&(r.prototype=Object.create(null),(new r).__proto__||(n=!1)),s.prototype.eventNames=function(){var t,r,i=[];if(0===this._eventsCount)return i;for(r in t=this._events)e.call(t,r)&&i.push(n?r.slice(1):r);return Object.getOwnPropertySymbols?i.concat(Object.getOwnPropertySymbols(t)):i},s.prototype.listeners=function(t){var e=this._events[n?n+t:t];if(!e)return[];if(e.fn)return[e.fn];for(var r=0,i=e.length,o=new Array(i);r<i;r++)o[r]=e[r].fn;return o},s.prototype.listenerCount=function(t){var e=this._events[n?n+t:t];return e?e.fn?1:e.length:0},s.prototype.emit=function(t,e,r,i,o,a){var s=n?n+t:t;if(!this._events[s])return!1;var u,c,l=this._events[s],h=arguments.length;if(l.fn){switch(l.once&&this.removeListener(t,l.fn,void 0,!0),h){case 1:return l.fn.call(l.context),!0;case 2:return l.fn.call(l.context,e),!0;case 3:return l.fn.call(l.context,e,r),!0;case 4:return l.fn.call(l.context,e,r,i),!0;case 5:return l.fn.call(l.context,e,r,i,o),!0;case 6:return l.fn.call(l.context,e,r,i,o,a),!0}for(c=1,u=new Array(h-1);c<h;c++)u[c-1]=arguments[c];l.fn.apply(l.context,u)}else{var p,f=l.length;for(c=0;c<f;c++)switch(l[c].once&&this.removeListener(t,l[c].fn,void 0,!0),h){case 1:l[c].fn.call(l[c].context);break;case 2:l[c].fn.call(l[c].context,e);break;case 3:l[c].fn.call(l[c].context,e,r);break;case 4:l[c].fn.call(l[c].context,e,r,i);break;default:if(!u)for(p=1,u=new Array(h-1);p<h;p++)u[p-1]=arguments[p];l[c].fn.apply(l[c].context,u)}}return!0},s.prototype.on=function(t,e,n){return o(this,t,e,n,!1)},s.prototype.once=function(t,e,n){return o(this,t,e,n,!0)},s.prototype.removeListener=function(t,e,r,i){var o=n?n+t:t;if(!this._events[o])return this;if(!e)return a(this,o),this;var s=this._events[o];if(s.fn)s.fn!==e||i&&!s.once||r&&s.context!==r||a(this,o);else{for(var u=0,c=[],l=s.length;u<l;u++)(s[u].fn!==e||i&&!s[u].once||r&&s[u].context!==r)&&c.push(s[u]);c.length?this._events[o]=1===c.length?c[0]:c:a(this,o)}return this},s.prototype.removeAllListeners=function(t){var e;return t?this._events[e=n?n+t:t]&&a(this,e):(this._events=new r,this._eventsCount=0),this},s.prototype.off=s.prototype.removeListener,s.prototype.addListener=s.prototype.on,s.prefixed=n,s.EventEmitter=s,t.exports=s});function lt(t){return Array.isArray(t)?t.map(encodeURIComponent).join(","):encodeURIComponent(String(t))}function ht(t,e,n){if(!1===n||null===n)return t;var r=/\?/.test(t)?"&":"?",i=encodeURIComponent(e);return void 0!==n&&""!==n&&!0!==n&&(i+="="+lt(n)),""+t+r+i}var pt={appendQueryObject:function(t,e){if(!e)return t;var n=t;return Object.keys(e).forEach(function(t){var r=e[t];void 0!==r&&(Array.isArray(r)&&(r=r.filter(function(t){return!!t}).join(",")),n=ht(n,t,r))}),n},appendQueryParam:ht,prependOrigin:function(t,e){if(!e)return t;if("http"===t.slice(0,4))return t;var n="/"===t[0]?"":"/";return""+e.replace(/\/$/,"")+n+t},interpolateRouteParams:function(t,e){return e?t.replace(/\/:([a-zA-Z0-9]+)/g,function(t,n){var r=e[n];if(void 0===r)throw new Error("Unspecified route parameter "+n);return"/"+lt(r)}):t}},ft=1;function dt(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=P(n,e.headers),i=Object.keys(r).reduce(function(t,e){return t[e.toLowerCase()]=r[e],t},{});this.id=ft++,this._options=e,this.emitter=new ct,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}dt.prototype.url=function(t){var e=pt.prependOrigin(this.path,this.origin);e=pt.appendQueryObject(e,this.query);var n=this.params;if(t){e=pt.appendQueryParam(e,"access_token",t);var r=ut(t).user;n=P({ownerId:r},n)}return pt.interpolateRouteParams(e,n)},dt.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(et.EVENT_RESPONSE,e),e},function(e){throw t.error=e,t.emitter.emit(et.EVENT_ERROR,e),e})},dt.prototype.abort=function(){this._nextPageRequest&&(this._nextPageRequest.abort(),delete this._nextPageRequest),this.response||this.error||this.aborted||(this.aborted=!0,this.client.abortRequest(this))},dt.prototype.eachPage=function(t){var e=this;function n(n){t(null,n,function(){delete e._nextPageRequest;var t=n.nextPage();t&&(e._nextPageRequest=t,i(t))})}function r(e){t(e,null,function(){})}function i(t){t.send().then(n,r)}i(this)},dt.prototype.clone=function(){return this._extend()},dt.prototype._extend=function(t){var e=P(this._options,t);return new dt(this.client,e)};var yt=dt;function gt(t){if(!t||!t.accessToken)throw new Error("Cannot create a client without an access token");ut(t.accessToken),this.accessToken=t.accessToken,this.origin=t.origin||et.API_ORIGIN}gt.prototype.createRequest=function(t){return new yt(this,t)};var mt=gt;function vt(t){mt.call(this,t)}(vt.prototype=Object.create(mt.prototype)).constructor=vt,vt.prototype.sendRequest=function(t){return Promise.resolve().then(function(){var e=function(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}(t,t.client.accessToken);return function(t,e){return new Promise(function(n,r){e.onprogress=function(e){t.emitter.emit(et.EVENT_PROGRESS_DOWNLOAD,it(e))};var i=t.file;i&&(e.upload.onprogress=function(e){t.emitter.emit(et.EVENT_PROGRESS_UPLOAD,it(e))}),e.onerror=function(t){r(t)},e.onabort=function(){var e=new nt({request:t,type:et.ERROR_REQUEST_ABORTED});r(e)},e.onload=function(){if(delete rt[t.id],e.status<200||e.status>=400){var i=new nt({request:t,body:e.response,statusCode:e.status});r(i)}else n(e)};var o=t.body;"string"==typeof o?e.send(o):o?e.send(JSON.stringify(o)):i?e.send(i):e.send(),rt[t.id]=e}).then(function(e){return function(t,e){return new tt(t,{body:e.response,headers:(n=e.getAllResponseHeaders(),r={},n?(n.trim().split(/[\r|\n]+/).forEach(function(t){var e=function(t){var e=t.indexOf(":");return{name:t.substring(0,e).trim().toLowerCase(),value:t.substring(e+1).trim()}}(t);r[e.name]=e.value}),r):r),statusCode:e.status});var n,r}(t,e)})}(t,e)})},vt.prototype.abortRequest=function(t){var e=rt[t.id];e&&(e.abort(),delete rt[t.id])};var bt=function(t){return new vt(t)},_t=bt,xt=Object.prototype.toString,wt="value",Et={};function Mt(t){var e=Array.isArray(t);return function(n){var r=Ot(Et.plainArray,n);if(r)return r;if(e&&n.length!==t.length)return"an array with "+t.length+" items";for(var i=0;i<n.length;i++)if(r=Ot(e?t[i]:t,n[i]))return[i].concat(r)}}function Ot(t,e){if(null!=e||t.hasOwnProperty("__required")){var n=t(e);return n?Array.isArray(n)?n:[n]:void 0}}function jt(t,e){var n=t.length,r=t[n-1],i=t.slice(0,n-1);return 0===i.length&&(i=[wt]),e=P(e,{path:i}),"function"==typeof r?r(e):St(e,function(t){return"must be "+(/^an? /.test(e=t)?e:/^[aeiou]/i.test(e)?"an "+e:/^[a-z]/i.test(e)?"a "+e:e)+".";var e}(r))}function Pt(t){return t.length<2?t[0]:2===t.length?t.join(" or "):t.slice(0,-1).join(", ")+", or "+t.slice(-1)}function St(t,e){return(kt(t.path)?"Item at position ":"")+t.path.join(".")+" "+e}function kt(t){return"number"==typeof t[t.length-1]||"number"==typeof t[0]}Et.assert=function(t,e){return e=e||{},function(n){var r=Ot(t,n);if(r){var i=jt(r,e);throw e.apiName&&(i=e.apiName+": "+i),new Error(i)}}},Et.shape=function(t){var e,n=(e=t,Object.keys(e||{}).map(function(t){return{key:t,value:e[t]}}));return function(t){var e,r=Ot(Et.plainObject,t);if(r)return r;for(var i=[],o=0;o<n.length;o++)(r=Ot(n[o].value,t[e=n[o].key]))&&i.push([e].concat(r));return i.length<2?i[0]:function(t){i=i.map(function(e){return"- "+e[0]+": "+jt(e,t).split("\n").join("\n ")});var e=t.path.join(".");return"The following properties"+(e===wt?"":" of "+e)+" have invalid values:\n "+i.join("\n ")}}},Et.strictShape=function(t){var e=Et.shape(t);return function(n){var r=e(n);if(r)return r;var i=Object.keys(n).reduce(function(e,n){return void 0===t[n]&&e.push(n),e},[]);return 0!==i.length?function(){return"The following keys are invalid: "+i.join(", ")}:void 0}},Et.arrayOf=function(t){return Mt(t)},Et.tuple=function(){var t=Array.isArray(arguments[0])?arguments[0]:Array.prototype.slice.call(arguments);return Mt(t)},Et.required=function(t){function e(e){return null==e?function(t){return St(t,kt(t.path)?"cannot be undefined/null.":"is required.")}:t.apply(this,arguments)}return e.__required=!0,e},Et.oneOfType=function(){var t=Array.isArray(arguments[0])?arguments[0]:Array.prototype.slice.call(arguments);return function(e){var n=t.map(function(t){return Ot(t,e)}).filter(Boolean);if(n.length===t.length)return n.every(function(t){return 1===t.length&&"string"==typeof t[0]})?Pt(n.map(function(t){return t[0]})):n.reduce(function(t,e){return e.length>t.length?e:t})}},Et.equal=function(t){return function(e){if(e!==t)return JSON.stringify(t)}},Et.oneOf=function(){var t=Array.isArray(arguments[0])?arguments[0]:Array.prototype.slice.call(arguments),e=t.map(function(t){return Et.equal(t)});return Et.oneOfType.apply(this,e)},Et.range=function(t){var e=t[0],n=t[1];return function(t){if(Ot(Et.number,t)||t<e||t>n)return"number between "+e+" & "+n+" (inclusive)"}},Et.any=function(){},Et.boolean=function(t){if("boolean"!=typeof t)return"boolean"},Et.number=function(t){if("number"!=typeof t)return"number"},Et.plainArray=function(t){if(!Array.isArray(t))return"array"},Et.plainObject=function(t){if("[object Object]"!==xt.call(e=t)||null!==(n=Object.getPrototypeOf(e))&&n!==Object.getPrototypeOf({}))return"object";var e,n},Et.string=function(t){if("string"!=typeof t)return"string"},Et.func=function(t){if("function"!=typeof t)return"function"},Et.validate=Ot,Et.processMessage=jt;var Rt=Et,Ct=P(Rt,{file:function(t){if("undefined"!=typeof window){if(t instanceof r.Blob||t instanceof r.ArrayBuffer)return;return"Blob or ArrayBuffer"}if("string"!=typeof t&&void 0===t.pipe)return"Filename or Readable stream"},date:function(t){if("boolean"==typeof t)return"date";try{var e=new Date(t);if(e.getTime&&isNaN(e.getTime()))return"date"}catch(t){return"date"}},coordinates:function(t){return Rt.tuple(Rt.number,Rt.number)(t)},assertShape:function(t,e){return Rt.assert(Rt.strictShape(t),e)}}),At=function(t,e){var n=function(t,n){return-1!==e.indexOf(t)&&void 0!==n};return"function"==typeof e&&(n=e),Object.keys(t).filter(function(e){return n(e,t[e])}).reduce(function(e,n){return e[n]=t[n],e},{})},Tt=function(t){return function(t,e){return Object.keys(t).reduce(function(e,n){return e[n]="boolean"==typeof(r=t[n])?JSON.stringify(r):r,e;var r},{})}(t)},It={},Lt=["country","region","postcode","district","place","locality","neighborhood","address","poi","poi.landmark"];It.forwardGeocode=function(t){Ct.assertShape({query:Ct.required(Ct.string),mode:Ct.oneOf("mapbox.places","mapbox.places-permanent"),countries:Ct.arrayOf(Ct.string),proximity:Ct.coordinates,types:Ct.arrayOf(Ct.oneOf(Lt)),autocomplete:Ct.boolean,bbox:Ct.arrayOf(Ct.number),limit:Ct.number,language:Ct.arrayOf(Ct.string)})(t),t.mode=t.mode||"mapbox.places";var e=Tt(P({country:t.countries},At(t,["proximity","types","autocomplete","bbox","limit","language"])));return this.client.createRequest({method:"GET",path:"/geocoding/v5/:mode/:query.json",params:At(t,["mode","query"]),query:e})},It.reverseGeocode=function(t){Ct.assertShape({query:Ct.required(Ct.coordinates),mode:Ct.oneOf("mapbox.places","mapbox.places-permanent"),countries:Ct.arrayOf(Ct.string),types:Ct.arrayOf(Ct.oneOf(Lt)),bbox:Ct.arrayOf(Ct.number),limit:Ct.number,language:Ct.arrayOf(Ct.string),reverseMode:Ct.oneOf("distance","score")})(t),t.mode=t.mode||"mapbox.places";var e=Tt(P({country:t.countries},At(t,["country","types","bbox","limit","language","reverseMode"])));return this.client.createRequest({method:"GET",path:"/geocoding/v5/:mode/:query.json",params:At(t,["mode","query"]),query:e})};var Nt,qt=(Nt=It,function(t){var e;e=mt.prototype.isPrototypeOf(t)?t:bt(t);var n=Object.create(Nt);return n.client=e,n});if("production"!==process.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 Ft=self.crypto||self.msCrypto;function zt(t){this.origin=t.origin||"https://api.mapbox.com",this.endpoint="events/v2",this.access_token=t.accessToken,this.version="0.2.0",this.sessionID=this.generateSessionID(),this.userAgent=this.getUserAgent(),this.options=t,this.send=this.send.bind(this),this.countries=t.countries?t.countries.split(","):null,this.types=t.types?t.types.split(","):null,this.bbox=t.bbox?t.bbox:null,this.language=t.language?t.language.split(","):null,this.limit=t.limit?+t.limit:null,this.locale=navigator.language||null,this.enableEventLogging=this.shouldEnableLogging(t),this.eventQueue=new Array,this.flushInterval=t.flushInterval||1e3,this.maxQueueSize=t.maxQueueSize||100,this.timer=this.flushInterval?setTimeout(this.flush.bind(this),this.flushInterval):null,this.lastSentInput="",this.lastSentIndex=0}zt.prototype={select:function(t,e){var n=this.getSelectedIndex(t,e),r=this.getEventPayload("search.select",e);if(r.resultIndex=n,r.resultPlaceName=t.place_name,r.resultId=t.id,(n!==this.lastSentIndex||r.queryString!==this.lastSentInput)&&-1!=n&&(this.lastSentIndex=n,this.lastSentInput=r.queryString,r.queryString))return this.push(r)},start:function(t){var e=this.getEventPayload("search.start",t);if(e.queryString)return this.push(e)},keyevent:function(t,e){if(t.key&&!t.metaKey&&-1===[9,27,37,39,13,38,40].indexOf(t.keyCode)){var n=this.getEventPayload("search.keystroke",e);if(n.lastAction=t.key,n.queryString)return this.push(n)}},send:function(t,e){if(!this.enableEventLogging)return e?e():void 0;var n=this.getRequestOptions(t);this.request(n,function(t){return t?this.handleError(t,e):e?e():void 0}.bind(this))},getRequestOptions:function(t){return Array.isArray(t)||(t=[t]),{method:"POST",host:this.origin,path:this.endpoint+"?access_token="+this.access_token,headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}},getEventPayload:function(t,e){var n;n=e.options.proximity?[e.options.proximity.longitude,e.options.proximity.latitude]:null;var r=e._map?e._map.getZoom():null,i={event:t,created:+new Date,sessionIdentifier:this.sessionID,country:this.countries,userAgent:this.userAgent,language:this.language,bbox:this.bbox,types:this.types,endpoint:"mapbox.places",proximity:n,limit:e.options.limit,mapZoom:r,keyboardLocale:this.locale};return i.queryString="search.select"===t?e.inputString:"search.select"!=t&&e._inputEl?e._inputEl.value:e.inputString,i},request:function(t,e){var n=new XMLHttpRequest;for(var r in n.onreadystatechange=function(){if(4==this.readyState)return e(204==this.status?null:this.statusText)},n.open(t.method,t.host+"/"+t.path,!0),t.headers)n.setRequestHeader(r,t.headers[r]);n.send(t.body)},handleError:function(t,e){if(e)return e(t)},generateSessionID:function(){return function(t){t=t||21;for(var e="",n=Ft.getRandomValues(new Uint8Array(t));0<t--;)e+="Uint8ArdomValuesObj012345679BCDEFGHIJKLMNPQRSTWXYZ_cfghkpqvwxyz-"[63&n[t]];return e}()},getUserAgent:function(){return"mapbox-gl-geocoder."+this.version+"."+navigator.userAgent},getSelectedIndex:function(t,e){if(e._typeahead){var n=t.id;return e._typeahead.data.map(function(t){return t.id}).indexOf(n)}},shouldEnableLogging:function(t){return!(!1===t.enableEventLogging||t.origin&&-1==t.origin.indexOf("api.mapbox.com")||t.localGeocoder||t.filter)},flush:function(){this.eventQueue.length>0&&(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()}};var Bt=zt,Vt={placeholder:{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"}},Dt=o(function(t){!function(e,n,r){t.exports?t.exports=r():e.subtag=r()}(r,0,function(){var t="",e=/^([a-zA-Z]{2,3})(?:[_-]+([a-zA-Z]{3})(?=$|[_-]+))?(?:[_-]+([a-zA-Z]{4})(?=$|[_-]+))?(?:[_-]+([a-zA-Z]{2}|[0-9]{3})(?=$|[_-]+))?/;function n(t){return t.match(e)||[]}function r(e){return{language:(e=n(e))[1]||t,extlang:e[2]||t,script:e[3]||t,region:e[4]||t}}function i(t,e,n){Object.defineProperty(t,e,{value:n,enumerable:!0})}function o(e,o,a){function s(r){return n(r)[e]||t}i(s,"pattern",o),i(r,a,s)}return o(1,/^[a-zA-Z]{2,3}$/,"language"),o(2,/^[a-zA-Z]{3}$/,"extlang"),o(3,/^[a-zA-Z]{4}$/,"script"),o(4,/^[a-zA-Z]{2}$|^[0-9]{3}$/,"region"),i(r,"split",function(t){return n(t).filter(function(t,e){return t&&e})}),r})}),$t=e.EventEmitter;function Gt(t){this._eventEmitter=new $t,this.options=P({},this.options,t),this.inputString="",this.fresh=!0,this.lastSelected=null}Gt.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,clearAndBlurOnEsc:!1,clearOnBlur:!1,getItemValue:function(t){return t.place_name},render:function(t){var e=t.place_name.split(",");return'<div class="mapboxgl-ctrl-geocoder--suggestion"><div class="mapboxgl-ctrl-geocoder--suggestion-title">'+e[0]+'</div><div class="mapboxgl-ctrl-geocoder--suggestion-address">'+e.splice(1,e.length).join(",")+"</div></div>"}},onAdd:function(t){this._map=t,this.setLanguage(),this.geocoderService=qt(_t({accessToken:this.options.accessToken,origin:this.options.origin})),this.eventManager=new Bt(this.options),this._onChange=this._onChange.bind(this),this._onKeyDown=this._onKeyDown.bind(this),this._onBlur=this._onBlur.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),this._clear=this._clear.bind(this),this._clearOnBlur=this._clearOnBlur.bind(this);var e=this.container=document.createElement("div");e.className="mapboxgl-ctrl-geocoder mapboxgl-ctrl";var n=this.createIcon("search",'<path d="M7.4 2.5c-2.7 0-4.9 2.2-4.9 4.9s2.2 4.9 4.9 4.9c1 0 1.8-.2 2.5-.8l3.7 3.7c.2.2.4.3.8.3.7 0 1.1-.4 1.1-1.1 0-.3-.1-.5-.3-.8L11.4 10c.4-.8.8-1.6.8-2.5.1-2.8-2.1-5-4.8-5zm0 1.6c1.8 0 3.2 1.4 3.2 3.2s-1.4 3.2-3.2 3.2-3.3-1.3-3.3-3.1 1.4-3.3 3.3-3.3z"/>');this._inputEl=document.createElement("input"),this._inputEl.type="text",this._inputEl.className="mapboxgl-ctrl-geocoder--input",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.options.collapsed||this.options.clearOnBlur)&&this._inputEl.addEventListener("blur",this._onBlur),this._inputEl.addEventListener("keydown",function(t,e,n){var r,i,o,a,s,u,c=0,l=!1,h=!1,p=!0;if("function"!=typeof t)throw new TypeError("Expected a function");function f(e){var n=r,o=i;return r=i=void 0,c=e,a=t.apply(o,n)}function d(t){var n=t-u;return void 0===u||n>=e||n<0||h&&t-c>=o}function y(){var t=H();if(d(t))return g(t);s=setTimeout(y,function(t){var n=e-(t-u);return h?Q(n,o-(t-c)):n}(t))}function g(t){return s=void 0,p&&r?f(t):(r=i=void 0,a)}function m(){var t=H(),n=d(t);if(r=arguments,i=this,u=t,n){if(void 0===s)return function(t){return c=t,s=setTimeout(y,e),l?f(t):a}(u);if(h)return s=setTimeout(y,e),f(u)}return void 0===s&&(s=setTimeout(y,e)),a}return e=K(e)||0,W(void 0)&&(l=!!(void 0).leading,o=(h="maxWait"in void 0)?Z(K((void 0).maxWait)||0,e):o,p="trailing"in void 0?!!(void 0).trailing:p),m.cancel=function(){void 0!==s&&clearTimeout(s),c=0,r=u=i=s=void 0},m.flush=function(){return void 0===s?a:g(H())},m}(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("mapboxgl-ctrl-geocoder--pin-right"),this._clearEl=document.createElement("button"),this._clearEl.setAttribute("aria-label","Clear"),this._clearEl.addEventListener("click",this.clear),this._clearEl.className="mapboxgl-ctrl-geocoder--button";var i=this.createIcon("close",'<path d="M3.8 2.5c-.6 0-1.3.7-1.3 1.3 0 .3.2.7.5.8L7.2 9 3 13.2c-.3.3-.5.7-.5 1 0 .6.7 1.3 1.3 1.3.3 0 .7-.2 1-.5L9 10.8l4.2 4.2c.2.3.7.3 1 .3.6 0 1.3-.7 1.3-1.3 0-.3-.2-.7-.3-1l-4.4-4L15 4.6c.3-.2.5-.5.5-.8 0-.7-.7-1.3-1.3-1.3-.3 0-.7.2-1 .3L9 7.1 4.8 2.8c-.3-.1-.7-.3-1-.3z"/>');return this._clearEl.appendChild(i),this._loadingEl=this.createIcon("loading",'<path fill="#333" d="M4.4 4.4l.8.8c2.1-2.1 5.5-2.1 7.6 0l.8-.8c-2.5-2.5-6.7-2.5-9.2 0z"/><path opacity=".1" d="M12.8 12.9c-2.1 2.1-5.5 2.1-7.6 0-2.1-2.1-2.1-5.5 0-7.7l-.8-.8c-2.5 2.5-2.5 6.7 0 9.2s6.6 2.5 9.2 0 2.5-6.6 0-9.2l-.8.8c2.2 2.1 2.2 5.6 0 7.7z"/>'),r.appendChild(this._clearEl),r.appendChild(this._loadingEl),e.appendChild(n),e.appendChild(this._inputEl),e.appendChild(r),this._typeahead=new I(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","mapboxgl-ctrl-geocoder--icon mapboxgl-ctrl-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=27,n=9;if(t.keyCode===e&&this.options.clearAndBlurOnEsc)return this._clear(t),this._inputEl.blur();var r=t.target&&t.target.shadowRoot?t.target.shadowRoot.activeElement:t.target;if(!r||!r.value)return this.fresh=!0,t.keyCode!==n&&this.clear(t),this._clearEl.style.display="none";t.metaKey||-1!==[n,e,37,39,13,38,40].indexOf(t.keyCode)||r.value.length>=this.options.minLength&&this._geocode(r.value)},_showButton:function(){this._typeahead.selected&&(this._clearEl.style.display="block")},_hideButton:function(){this._typeahead.selected&&(this._clearEl.style.display="none")},_onBlur:function(t){this.options.clearOnBlur&&this._clearOnBlur(t),this.options.collapsed&&this._collapse()},_onChange:function(){var t=this._typeahead.selected;if(t&&t.id!==this.lastSelected){var e;if(this._clearEl.style.display="none",this.options.flyTo)if(t.properties&&!J[t.properties.short_code]&&t.bbox){var n=t.bbox;e=P({},this.options.flyTo),this._map.fitBounds([[n[0],n[1]],[n[2],n[3]]],e)}else t.properties&&J[t.properties.short_code]?(e=P({},this.options.flyTo),this._map.fitBounds(J[t.properties.short_code].bbox,e)):((e=P({},{zoom:this.options.zoom},this.options.flyTo)).center=t.center,this._map.flyTo(e));this.options.marker&&this._mapboxgl&&this._handleMarker(t),this._inputEl.focus(),this._inputEl.scrollLeft=0,this._inputEl.setSelectionRange(0,0),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=this,r=["bbox","limit","proximity","countries","types","language","reverseMode"].reduce(function(t,e){return n.options[e]&&(t[e]=["countries","types","language"].indexOf(e)>-1?n.options[e].split(/[\s,]+/):n.options[e],"proximity"===e&&n.options[e]&&n.options[e].longitude&&n.options[e].latitude&&(t[e]=[n.options[e].longitude,n.options[e