UNPKG

tomtom-react-searchbox

Version:

Customizable searchbox component powered by Tomtom search for your React application.

2 lines (1 loc) 33.5 kB
"use strict";function t(t){return t&&"object"==typeof t&&"default"in t?t.default:t}Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),r=t(e),n=t(require("prop-types"));function o(t,e,r,n,o,i,c){try{var u=t[i](c),a=u.value}catch(t){return void r(t)}u.done?e(a):Promise.resolve(a).then(n,o)}function i(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var c=t.apply(e,r);function u(t){o(c,n,i,u,a,"next",t)}function a(t){o(c,n,i,u,a,"throw",t)}u(void 0)}))}}function c(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function u(){return(u=Object.assign||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}).apply(this,arguments)}function a(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function s(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?a(Object(r),!0).forEach((function(e){c(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):a(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function f(t,e){if(null==t)return{};var r,n,o=function(t,e){if(null==t)return{};var r,n,o={},i=Object.keys(t);for(n=0;n<i.length;n++)r=i[n],e.indexOf(r)>=0||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n<i.length;n++)r=i[n],e.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}function l(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(t)))return;var r=[],n=!0,o=!1,i=void 0;try{for(var c,u=t[Symbol.iterator]();!(n=(c=u.next()).done)&&(r.push(c.value),!e||r.length!==e);n=!0);}catch(t){o=!0,i=t}finally{try{n||null==u.return||u.return()}finally{if(o)throw i}}return r}(t,e)||function(t,e){if(!t)return;if("string"==typeof t)return p(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return p(t,e)}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function p(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}var h="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function d(t,e){return t(e={exports:{}},e.exports),e.exports}var v=function(t){return t&&t.Math==Math&&t},y=v("object"==typeof globalThis&&globalThis)||v("object"==typeof window&&window)||v("object"==typeof self&&self)||v("object"==typeof h&&h)||Function("return this")(),m=function(t){try{return!!t()}catch(t){return!0}},g=!m((function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a})),b={}.propertyIsEnumerable,w=Object.getOwnPropertyDescriptor,j={f:w&&!b.call({1:2},1)?function(t){var e=w(this,t);return!!e&&e.enumerable}:b},O=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}},x={}.toString,E=function(t){return x.call(t).slice(8,-1)},S="".split,R=m((function(){return!Object("z").propertyIsEnumerable(0)}))?function(t){return"String"==E(t)?S.call(t,""):Object(t)}:Object,C=function(t){if(null==t)throw TypeError("Can't call method on "+t);return t},k=function(t){return R(C(t))},P=function(t){return"object"==typeof t?null!==t:"function"==typeof t},_=function(t,e){if(!P(t))return t;var r,n;if(e&&"function"==typeof(r=t.toString)&&!P(n=r.call(t)))return n;if("function"==typeof(r=t.valueOf)&&!P(n=r.call(t)))return n;if(!e&&"function"==typeof(r=t.toString)&&!P(n=r.call(t)))return n;throw TypeError("Can't convert object to primitive value")},T={}.hasOwnProperty,L=function(t,e){return T.call(t,e)},N=y.document,I=P(N)&&P(N.createElement),F=function(t){return I?N.createElement(t):{}},q=!g&&!m((function(){return 7!=Object.defineProperty(F("div"),"a",{get:function(){return 7}}).a})),A=Object.getOwnPropertyDescriptor,M={f:g?A:function(t,e){if(t=k(t),e=_(e,!0),q)try{return A(t,e)}catch(t){}if(L(t,e))return O(!j.f.call(t,e),t[e])}},D=function(t){if(!P(t))throw TypeError(String(t)+" is not an object");return t},G=Object.defineProperty,z={f:g?G:function(t,e,r){if(D(t),e=_(e,!0),D(r),q)try{return G(t,e,r)}catch(t){}if("get"in r||"set"in r)throw TypeError("Accessors not supported");return"value"in r&&(t[e]=r.value),t}},W=g?function(t,e,r){return z.f(t,e,O(1,r))}:function(t,e,r){return t[e]=r,t},B=function(t,e){try{W(y,t,e)}catch(r){y[t]=e}return e},U=y["__core-js_shared__"]||B("__core-js_shared__",{}),K=Function.toString;"function"!=typeof U.inspectSource&&(U.inspectSource=function(t){return K.call(t)});var Y,H,V,$,J=U.inspectSource,Q=y.WeakMap,X="function"==typeof Q&&/native code/.test(J(Q)),Z=d((function(t){(t.exports=function(t,e){return U[t]||(U[t]=void 0!==e?e:{})})("versions",[]).push({version:"3.6.0",mode:"global",copyright:"© 2019 Denis Pushkarev (zloirock.ru)"})})),tt=0,et=Math.random(),rt=function(t){return"Symbol("+String(void 0===t?"":t)+")_"+(++tt+et).toString(36)},nt=Z("keys"),ot={},it=y.WeakMap;if(X){var ct=new it,ut=ct.get,at=ct.has,st=ct.set;Y=function(t,e){return st.call(ct,t,e),e},H=function(t){return ut.call(ct,t)||{}},V=function(t){return at.call(ct,t)}}else{var ft=nt[$="state"]||(nt[$]=rt($));ot[ft]=!0,Y=function(t,e){return W(t,ft,e),e},H=function(t){return L(t,ft)?t[ft]:{}},V=function(t){return L(t,ft)}}var lt,pt,ht={set:Y,get:H,has:V,enforce:function(t){return V(t)?H(t):Y(t,{})},getterFor:function(t){return function(e){var r;if(!P(e)||(r=H(e)).type!==t)throw TypeError("Incompatible receiver, "+t+" required");return r}}},dt=d((function(t){var e=ht.get,r=ht.enforce,n=String(String).split("String");(t.exports=function(t,e,o,i){var c=!!i&&!!i.unsafe,u=!!i&&!!i.enumerable,a=!!i&&!!i.noTargetGet;"function"==typeof o&&("string"!=typeof e||L(o,"name")||W(o,"name",e),r(o).source=n.join("string"==typeof e?e:"")),t!==y?(c?!a&&t[e]&&(u=!0):delete t[e],u?t[e]=o:W(t,e,o)):u?t[e]=o:B(e,o)})(Function.prototype,"toString",(function(){return"function"==typeof this&&e(this).source||J(this)}))})),vt=y,yt=function(t){return"function"==typeof t?t:void 0},mt=function(t,e){return arguments.length<2?yt(vt[t])||yt(y[t]):vt[t]&&vt[t][e]||y[t]&&y[t][e]},gt=Math.ceil,bt=Math.floor,wt=function(t){return isNaN(t=+t)?0:(t>0?bt:gt)(t)},jt=Math.min,Ot=function(t){return t>0?jt(wt(t),9007199254740991):0},xt=Math.max,Et=Math.min,St=function(t){return function(e,r,n){var o,i=k(e),c=Ot(i.length),u=function(t,e){var r=wt(t);return r<0?xt(r+e,0):Et(r,e)}(n,c);if(t&&r!=r){for(;c>u;)if((o=i[u++])!=o)return!0}else for(;c>u;u++)if((t||u in i)&&i[u]===r)return t||u||0;return!t&&-1}},Rt={includes:St(!0),indexOf:St(!1)}.indexOf,Ct=function(t,e){var r,n=k(t),o=0,i=[];for(r in n)!L(ot,r)&&L(n,r)&&i.push(r);for(;e.length>o;)L(n,r=e[o++])&&(~Rt(i,r)||i.push(r));return i},kt=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],Pt=kt.concat("length","prototype"),_t={f:Object.getOwnPropertyNames||function(t){return Ct(t,Pt)}},Tt={f:Object.getOwnPropertySymbols},Lt=mt("Reflect","ownKeys")||function(t){var e=_t.f(D(t)),r=Tt.f;return r?e.concat(r(t)):e},Nt=function(t,e){for(var r=Lt(e),n=z.f,o=M.f,i=0;i<r.length;i++){var c=r[i];L(t,c)||n(t,c,o(e,c))}},It=/#|\.prototype\./,Ft=function(t,e){var r=At[qt(t)];return r==Dt||r!=Mt&&("function"==typeof e?m(e):!!e)},qt=Ft.normalize=function(t){return String(t).replace(It,".").toLowerCase()},At=Ft.data={},Mt=Ft.NATIVE="N",Dt=Ft.POLYFILL="P",Gt=Ft,zt=M.f,Wt=function(t,e){var r,n,o,i,c,u=t.target,a=t.global,s=t.stat;if(r=a?y:s?y[u]||B(u,{}):(y[u]||{}).prototype)for(n in e){if(i=e[n],o=t.noTargetGet?(c=zt(r,n))&&c.value:r[n],!Gt(a?n:u+(s?".":"#")+n,t.forced)&&void 0!==o){if(typeof i==typeof o)continue;Nt(i,o)}(t.sham||o&&o.sham)&&W(i,"sham",!0),dt(r,n,i,t)}},Bt=Array.isArray||function(t){return"Array"==E(t)},Ut=function(t){return Object(C(t))},Kt=function(t,e,r){var n=_(e);n in t?z.f(t,n,O(0,r)):t[n]=r},Yt=!!Object.getOwnPropertySymbols&&!m((function(){return!String(Symbol())})),Ht=Yt&&!Symbol.sham&&"symbol"==typeof Symbol(),Vt=Z("wks"),$t=y.Symbol,Jt=Ht?$t:rt,Qt=function(t){return L(Vt,t)||(Yt&&L($t,t)?Vt[t]=$t[t]:Vt[t]=Jt("Symbol."+t)),Vt[t]},Xt=Qt("species"),Zt=function(t,e){var r;return Bt(t)&&("function"!=typeof(r=t.constructor)||r!==Array&&!Bt(r.prototype)?P(r)&&null===(r=r[Xt])&&(r=void 0):r=void 0),new(void 0===r?Array:r)(0===e?0:e)},te=mt("navigator","userAgent")||"",ee=y.process,re=ee&&ee.versions,ne=re&&re.v8;ne?pt=(lt=ne.split("."))[0]+lt[1]:te&&(!(lt=te.match(/Edge\/(\d+)/))||lt[1]>=74)&&(lt=te.match(/Chrome\/(\d+)/))&&(pt=lt[1]);var oe=pt&&+pt,ie=Qt("species"),ce=function(t){return oe>=51||!m((function(){var e=[];return(e.constructor={})[ie]=function(){return{foo:1}},1!==e[t](Boolean).foo}))},ue=Qt("isConcatSpreadable"),ae=oe>=51||!m((function(){var t=[];return t[ue]=!1,t.concat()[0]!==t})),se=ce("concat"),fe=function(t){if(!P(t))return!1;var e=t[ue];return void 0!==e?!!e:Bt(t)};Wt({target:"Array",proto:!0,forced:!ae||!se},{concat:function(t){var e,r,n,o,i,c=Ut(this),u=Zt(c,0),a=0;for(e=-1,n=arguments.length;e<n;e++)if(fe(i=-1===e?c:arguments[e])){if(a+(o=Ot(i.length))>9007199254740991)throw TypeError("Maximum allowed index exceeded");for(r=0;r<o;r++,a++)r in i&&Kt(u,a,i[r])}else{if(a>=9007199254740991)throw TypeError("Maximum allowed index exceeded");Kt(u,a++,i)}return u.length=a,u}});var le,pe,he=[].join,de=R!=Object,ve=(le=",",!(pe=[]["join"])||!m((function(){pe.call(null,le||function(){throw 1},1)})));Wt({target:"Array",proto:!0,forced:de||ve},{join:function(t){return he.call(k(this),void 0===t?",":t)}});var ye=function(t){if("function"!=typeof t)throw TypeError(String(t)+" is not a function");return t},me=function(t,e,r){if(ye(t),void 0===e)return t;switch(r){case 0:return function(){return t.call(e)};case 1:return function(r){return t.call(e,r)};case 2:return function(r,n){return t.call(e,r,n)};case 3:return function(r,n,o){return t.call(e,r,n,o)}}return function(){return t.apply(e,arguments)}},ge=[].push,be=function(t){var e=1==t,r=2==t,n=3==t,o=4==t,i=6==t,c=5==t||i;return function(u,a,s,f){for(var l,p,h=Ut(u),d=R(h),v=me(a,s,3),y=Ot(d.length),m=0,g=f||Zt,b=e?g(u,y):r?g(u,0):void 0;y>m;m++)if((c||m in d)&&(p=v(l=d[m],m,h),t))if(e)b[m]=p;else if(p)switch(t){case 3:return!0;case 5:return l;case 6:return m;case 2:ge.call(b,l)}else if(o)return!1;return i?-1:n||o?o:b}},we={forEach:be(0),map:be(1),filter:be(2),some:be(3),every:be(4),find:be(5),findIndex:be(6)},je=we.map,Oe=ce("map"),xe=Oe&&!m((function(){[].map.call({length:-1,0:1},(function(t){throw t}))}));Wt({target:"Array",proto:!0,forced:!Oe||!xe},{map:function(t){return je(this,t,arguments.length>1?arguments[1]:void 0)}});var Ee=Object.keys||function(t){return Ct(t,kt)},Se=j.f,Re=function(t){return function(e){for(var r,n=k(e),o=Ee(n),i=o.length,c=0,u=[];i>c;)r=o[c++],g&&!Se.call(n,r)||u.push(t?[r,n[r]]:n[r]);return u}},Ce={entries:Re(!0),values:Re(!1)}.entries;Wt({target:"Object",stat:!0},{entries:function(t){return Ce(t)}});var ke={};ke[Qt("toStringTag")]="z";var Pe="[object z]"===String(ke),_e=Qt("toStringTag"),Te="Arguments"==E(function(){return arguments}()),Le=Pe?E:function(t){var e,r,n;return void 0===t?"Undefined":null===t?"Null":"string"==typeof(r=function(t,e){try{return t[e]}catch(t){}}(e=Object(t),_e))?r:Te?E(e):"Object"==(n=E(e))&&"function"==typeof e.callee?"Arguments":n},Ne=Pe?{}.toString:function(){return"[object "+Le(this)+"]"};Pe||dt(Object.prototype,"toString",Ne,{unsafe:!0});var Ie=y.Promise,Fe=z.f,qe=Qt("toStringTag"),Ae=Qt("species"),Me={},De=Qt("iterator"),Ge=Array.prototype,ze=Qt("iterator"),We=function(t,e,r,n){try{return n?e(D(r)[0],r[1]):e(r)}catch(e){var o=t.return;throw void 0!==o&&D(o.call(t)),e}},Be=d((function(t){var e=function(t,e){this.stopped=t,this.result=e};(t.exports=function(t,r,n,o,i){var c,u,a,s,f,l,p,h,d=me(r,n,o?2:1);if(i)c=t;else{if("function"!=typeof(u=function(t){if(null!=t)return t[ze]||t["@@iterator"]||Me[Le(t)]}(t)))throw TypeError("Target is not iterable");if(void 0!==(h=u)&&(Me.Array===h||Ge[De]===h)){for(a=0,s=Ot(t.length);s>a;a++)if((f=o?d(D(p=t[a])[0],p[1]):d(t[a]))&&f instanceof e)return f;return new e(!1)}c=u.call(t)}for(l=c.next;!(p=l.call(c)).done;)if("object"==typeof(f=We(c,d,p.value,o))&&f&&f instanceof e)return f;return new e(!1)}).stop=function(t){return new e(!0,t)}})),Ue=Qt("iterator"),Ke=!1;try{var Ye=0,He={next:function(){return{done:!!Ye++}},return:function(){Ke=!0}};He[Ue]=function(){return this},Array.from(He,(function(){throw 2}))}catch(t){}var Ve,$e,Je,Qe=Qt("species"),Xe=mt("document","documentElement"),Ze=/(iphone|ipod|ipad).*applewebkit/i.test(te),tr=y.location,er=y.setImmediate,rr=y.clearImmediate,nr=y.process,or=y.MessageChannel,ir=y.Dispatch,cr=0,ur={},ar=function(t){if(ur.hasOwnProperty(t)){var e=ur[t];delete ur[t],e()}},sr=function(t){return function(){ar(t)}},fr=function(t){ar(t.data)},lr=function(t){y.postMessage(t+"",tr.protocol+"//"+tr.host)};er&&rr||(er=function(t){for(var e=[],r=1;arguments.length>r;)e.push(arguments[r++]);return ur[++cr]=function(){("function"==typeof t?t:Function(t)).apply(void 0,e)},Ve(cr),cr},rr=function(t){delete ur[t]},"process"==E(nr)?Ve=function(t){nr.nextTick(sr(t))}:ir&&ir.now?Ve=function(t){ir.now(sr(t))}:or&&!Ze?(Je=($e=new or).port2,$e.port1.onmessage=fr,Ve=me(Je.postMessage,Je,1)):!y.addEventListener||"function"!=typeof postMessage||y.importScripts||m(lr)?Ve="onreadystatechange"in F("script")?function(t){Xe.appendChild(F("script")).onreadystatechange=function(){Xe.removeChild(this),ar(t)}}:function(t){setTimeout(sr(t),0)}:(Ve=lr,y.addEventListener("message",fr,!1)));var pr,hr,dr,vr,yr,mr,gr,br,wr={set:er,clear:rr},jr=M.f,Or=wr.set,xr=y.MutationObserver||y.WebKitMutationObserver,Er=y.process,Sr=y.Promise,Rr="process"==E(Er),Cr=jr(y,"queueMicrotask"),kr=Cr&&Cr.value;kr||(pr=function(){var t,e;for(Rr&&(t=Er.domain)&&t.exit();hr;){e=hr.fn,hr=hr.next;try{e()}catch(t){throw hr?vr():dr=void 0,t}}dr=void 0,t&&t.enter()},Rr?vr=function(){Er.nextTick(pr)}:xr&&!Ze?(yr=!0,mr=document.createTextNode(""),new xr(pr).observe(mr,{characterData:!0}),vr=function(){mr.data=yr=!yr}):Sr&&Sr.resolve?(gr=Sr.resolve(void 0),br=gr.then,vr=function(){br.call(gr,pr)}):vr=function(){Or.call(y,pr)});var Pr,_r,Tr,Lr,Nr,Ir,Fr,qr=kr||function(t){var e={fn:t,next:void 0};dr&&(dr.next=e),hr||(hr=e,vr()),dr=e},Ar=function(t){var e,r;this.promise=new t((function(t,n){if(void 0!==e||void 0!==r)throw TypeError("Bad Promise constructor");e=t,r=n})),this.resolve=ye(e),this.reject=ye(r)},Mr={f:function(t){return new Ar(t)}},Dr=function(t,e){if(D(t),P(e)&&e.constructor===t)return e;var r=Mr.f(t);return(0,r.resolve)(e),r.promise},Gr=function(t){try{return{error:!1,value:t()}}catch(t){return{error:!0,value:t}}},zr=wr.set,Wr=Qt("species"),Br="Promise",Ur=ht.get,Kr=ht.set,Yr=ht.getterFor(Br),Hr=Ie,Vr=y.TypeError,$r=y.document,Jr=y.process,Qr=mt("fetch"),Xr=Mr.f,Zr=Xr,tn="process"==E(Jr),en=!!($r&&$r.createEvent&&y.dispatchEvent),rn=Gt(Br,(function(){if(!(J(Hr)!==String(Hr))){if(66===oe)return!0;if(!tn&&"function"!=typeof PromiseRejectionEvent)return!0}if(oe>=51&&/native code/.test(Hr))return!1;var t=Hr.resolve(1),e=function(t){t((function(){}),(function(){}))};return(t.constructor={})[Wr]=e,!(t.then((function(){}))instanceof e)})),nn=rn||!function(t,e){if(!e&&!Ke)return!1;var r=!1;try{var n={};n[Ue]=function(){return{next:function(){return{done:r=!0}}}},t(n)}catch(t){}return r}((function(t){Hr.all(t).catch((function(){}))})),on=function(t){var e;return!(!P(t)||"function"!=typeof(e=t.then))&&e},cn=function(t,e,r){if(!e.notified){e.notified=!0;var n=e.reactions;qr((function(){for(var o=e.value,i=1==e.state,c=0;n.length>c;){var u,a,s,f=n[c++],l=i?f.ok:f.fail,p=f.resolve,h=f.reject,d=f.domain;try{l?(i||(2===e.rejection&&fn(t,e),e.rejection=1),!0===l?u=o:(d&&d.enter(),u=l(o),d&&(d.exit(),s=!0)),u===f.promise?h(Vr("Promise-chain cycle")):(a=on(u))?a.call(u,p,h):p(u)):h(o)}catch(t){d&&!s&&d.exit(),h(t)}}e.reactions=[],e.notified=!1,r&&!e.rejection&&an(t,e)}))}},un=function(t,e,r){var n,o;en?((n=$r.createEvent("Event")).promise=e,n.reason=r,n.initEvent(t,!1,!0),y.dispatchEvent(n)):n={promise:e,reason:r},(o=y["on"+t])?o(n):"unhandledrejection"===t&&function(t,e){var r=y.console;r&&r.error&&(1===arguments.length?r.error(t):r.error(t,e))}("Unhandled promise rejection",r)},an=function(t,e){zr.call(y,(function(){var r,n=e.value;if(sn(e)&&(r=Gr((function(){tn?Jr.emit("unhandledRejection",n,t):un("unhandledrejection",t,n)})),e.rejection=tn||sn(e)?2:1,r.error))throw r.value}))},sn=function(t){return 1!==t.rejection&&!t.parent},fn=function(t,e){zr.call(y,(function(){tn?Jr.emit("rejectionHandled",t):un("rejectionhandled",t,e.value)}))},ln=function(t,e,r,n){return function(o){t(e,r,o,n)}},pn=function(t,e,r,n){e.done||(e.done=!0,n&&(e=n),e.value=r,e.state=2,cn(t,e,!0))},hn=function(t,e,r,n){if(!e.done){e.done=!0,n&&(e=n);try{if(t===r)throw Vr("Promise can't be resolved itself");var o=on(r);o?qr((function(){var n={done:!1};try{o.call(r,ln(hn,t,n,e),ln(pn,t,n,e))}catch(r){pn(t,n,r,e)}})):(e.value=r,e.state=1,cn(t,e,!1))}catch(r){pn(t,{done:!1},r,e)}}};rn&&(Hr=function(t){!function(t,e,r){if(!(t instanceof e))throw TypeError("Incorrect "+(r?r+" ":"")+"invocation")}(this,Hr,Br),ye(t),Pr.call(this);var e=Ur(this);try{t(ln(hn,this,e),ln(pn,this,e))}catch(t){pn(this,e,t)}},(Pr=function(t){Kr(this,{type:Br,done:!1,notified:!1,parent:!1,reactions:[],rejection:!1,state:0,value:void 0})}).prototype=function(t,e,r){for(var n in e)dt(t,n,e[n],r);return t}(Hr.prototype,{then:function(t,e){var r,n,o,i=Yr(this),c=Xr((r=Hr,void 0===(o=D(this).constructor)||null==(n=D(o)[Qe])?r:ye(n)));return c.ok="function"!=typeof t||t,c.fail="function"==typeof e&&e,c.domain=tn?Jr.domain:void 0,i.parent=!0,i.reactions.push(c),0!=i.state&&cn(this,i,!1),c.promise},catch:function(t){return this.then(void 0,t)}}),_r=function(){var t=new Pr,e=Ur(t);this.promise=t,this.resolve=ln(hn,t,e),this.reject=ln(pn,t,e)},Mr.f=Xr=function(t){return t===Hr||t===Tr?new _r(t):Zr(t)},"function"==typeof Ie&&(Lr=Ie.prototype.then,dt(Ie.prototype,"then",(function(t,e){var r=this;return new Hr((function(t,e){Lr.call(r,t,e)})).then(t,e)}),{unsafe:!0}),"function"==typeof Qr&&Wt({global:!0,enumerable:!0,forced:!0},{fetch:function(t){return Dr(Hr,Qr.apply(y,arguments))}}))),Wt({global:!0,wrap:!0,forced:rn},{Promise:Hr}),Ir=Br,Fr=!1,(Nr=Hr)&&!L(Nr=Fr?Nr:Nr.prototype,qe)&&Fe(Nr,qe,{configurable:!0,value:Ir}),function(t){var e=mt(t),r=z.f;g&&e&&!e[Ae]&&r(e,Ae,{configurable:!0,get:function(){return this}})}(Br),Tr=mt(Br),Wt({target:Br,stat:!0,forced:rn},{reject:function(t){var e=Xr(this);return e.reject.call(void 0,t),e.promise}}),Wt({target:Br,stat:!0,forced:rn},{resolve:function(t){return Dr(this,t)}}),Wt({target:Br,stat:!0,forced:nn},{all:function(t){var e=this,r=Xr(e),n=r.resolve,o=r.reject,i=Gr((function(){var r=ye(e.resolve),i=[],c=0,u=1;Be(t,(function(t){var a=c++,s=!1;i.push(void 0),u++,r.call(e,t).then((function(t){s||(s=!0,i[a]=t,--u||n(i))}),o)})),--u||n(i)}));return i.error&&o(i.value),r.promise},race:function(t){var e=this,r=Xr(e),n=r.reject,o=Gr((function(){var o=ye(e.resolve);Be(t,(function(t){o.call(e,t).then(r.resolve,n)}))}));return o.error&&n(o.value),r.promise}});d((function(t){var e=function(t){var e,r=Object.prototype,n=r.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",c=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function a(t,e,r,n){var o=e&&e.prototype instanceof v?e:v,i=Object.create(o.prototype),c=new C(n||[]);return i._invoke=function(t,e,r){var n=f;return function(o,i){if(n===p)throw new Error("Generator is already running");if(n===h){if("throw"===o)throw i;return P()}for(r.method=o,r.arg=i;;){var c=r.delegate;if(c){var u=E(c,r);if(u){if(u===d)continue;return u}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(n===f)throw n=h,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n=p;var a=s(t,e,r);if("normal"===a.type){if(n=r.done?h:l,a.arg===d)continue;return{value:a.arg,done:r.done}}"throw"===a.type&&(n=h,r.method="throw",r.arg=a.arg)}}}(t,r,c),i}function s(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=a;var f="suspendedStart",l="suspendedYield",p="executing",h="completed",d={};function v(){}function y(){}function m(){}var g={};g[i]=function(){return this};var b=Object.getPrototypeOf,w=b&&b(b(k([])));w&&w!==r&&n.call(w,i)&&(g=w);var j=m.prototype=v.prototype=Object.create(g);function O(t){["next","throw","return"].forEach((function(e){t[e]=function(t){return this._invoke(e,t)}}))}function x(t){var e;this._invoke=function(r,o){function i(){return new Promise((function(e,i){!function e(r,o,i,c){var u=s(t[r],t,o);if("throw"!==u.type){var a=u.arg,f=a.value;return f&&"object"==typeof f&&n.call(f,"__await")?Promise.resolve(f.__await).then((function(t){e("next",t,i,c)}),(function(t){e("throw",t,i,c)})):Promise.resolve(f).then((function(t){a.value=t,i(a)}),(function(t){return e("throw",t,i,c)}))}c(u.arg)}(r,o,e,i)}))}return e=e?e.then(i,i):i()}}function E(t,r){var n=t.iterator[r.method];if(n===e){if(r.delegate=null,"throw"===r.method){if(t.iterator.return&&(r.method="return",r.arg=e,E(t,r),"throw"===r.method))return d;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return d}var o=s(n,t.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,d;var i=o.arg;return i?i.done?(r[t.resultName]=i.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,d):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,d)}function S(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function R(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function C(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(S,this),this.reset(!0)}function k(t){if(t){var r=t[i];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,c=function r(){for(;++o<t.length;)if(n.call(t,o))return r.value=t[o],r.done=!1,r;return r.value=e,r.done=!0,r};return c.next=c}}return{next:P}}function P(){return{value:e,done:!0}}return y.prototype=j.constructor=m,m.constructor=y,m[u]=y.displayName="GeneratorFunction",t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===y||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,m):(t.__proto__=m,u in t||(t[u]="GeneratorFunction")),t.prototype=Object.create(j),t},t.awrap=function(t){return{__await:t}},O(x.prototype),x.prototype[c]=function(){return this},t.AsyncIterator=x,t.async=function(e,r,n,o){var i=new x(a(e,r,n,o));return t.isGeneratorFunction(r)?i:i.next().then((function(t){return t.done?t.value:i.next()}))},O(j),j[u]="Generator",j[i]=function(){return this},j.toString=function(){return"[object Generator]"},t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=k,C.prototype={constructor:C,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(R),!t)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=e)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function o(n,o){return u.type="throw",u.arg=t,r.next=n,o&&(r.method="next",r.arg=e),!!o}for(var i=this.tryEntries.length-1;i>=0;--i){var c=this.tryEntries[i],u=c.completion;if("root"===c.tryLoc)return o("end");if(c.tryLoc<=this.prev){var a=n.call(c,"catchLoc"),s=n.call(c,"finallyLoc");if(a&&s){if(this.prev<c.catchLoc)return o(c.catchLoc,!0);if(this.prev<c.finallyLoc)return o(c.finallyLoc)}else if(a){if(this.prev<c.catchLoc)return o(c.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<c.finallyLoc)return o(c.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var c=i?i.completion:{};return c.type=t,c.arg=e,i?(this.method="next",this.next=i.finallyLoc,d):this.complete(c)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),d},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),R(r),d}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;R(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:k(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),d}},t}(t.exports);try{regeneratorRuntime=e}catch(t){Function("r","regeneratorRuntime = r")(e)}}));var dn=function(){var t=i(regeneratorRuntime.mark((function t(e){var r,n;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,fetch(e);case 2:if((r=t.sent).ok){t.next=5;break}throw r;case 5:return t.next=7,r.json();case 7:return n=t.sent,t.abrupt("return",n.results);case 9:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),vn=function(t){var e,r=(e=t,Object.entries(e).map((function(t){var e=l(t,2),r=e[0],n=e[1];return"".concat(r,"=").concat(encodeURIComponent(n))})).join("&")),n="https://api.tomtom.com/search/2/search/".concat(encodeURIComponent(t.query),".json?").concat(r);return dn(n)},yn=we.filter,mn=ce("filter"),gn=mn&&!m((function(){[].filter.call({length:-1,0:1},(function(t){throw t}))}));Wt({target:"Array",proto:!0,forced:!mn||!gn},{filter:function(t){return yn(this,t,arguments.length>1?arguments[1]:void 0)}});var bn=z.f,wn=Function.prototype,jn=wn.toString,On=/^\s*function ([^ (]*)/;g&&!("name"in wn)&&bn(wn,"name",{configurable:!0,get:function(){try{return jn.call(this).match(On)[1]}catch(t){return""}}});var xn=function(t){return t.id},En=function(t){return void 0!==t.poi&&void 0!==t.poi.name?t.poi.name:""},Sn=function(t){var e=[];return void 0!==t.address.freeformAddress&&e.push(t.address.freeformAddress),void 0!==t.address.countryCodeISO3&&e.push(t.address.countryCodeISO3),e.join(", ")},Rn=function(t){return[En(t),Sn(t)].filter((function(t){return t.length})).join(", ")};function Cn(t){var r=t.result,n=t.isSelected,o=t.onResultClick,i=En(r),c=Sn(r),u=null;return u=i&&c?e.createElement(e.Fragment,null,e.createElement("div",{className:"react-searchbox__result-item -primary"},"".concat(i," ")),e.createElement("br",null),e.createElement("div",{className:"react-searchbox__result-item -secondary"},c)):e.createElement("div",{className:"react-searchbox__result-item -primary"},c),e.createElement("div",{"data-testid":"result-item",className:"react-searchbox__result ".concat(n?"-selected":""),onMouseDown:function(t){return t.preventDefault()},onClick:o,key:xn(r)},u)}Cn.propTypes={result:n.objectOf(n.any).isRequired,isSelected:n.bool.isRequired,onResultClick:n.func.isRequired};var kn=n.shape({Clear:n.elementType,Result:n.elementType}),Pn=38,_n=40,Tn=13,Ln=27,Nn=function(t){t.keyCode===Pn&&t.preventDefault()};function In(t){var r=t.value,n=t.placeholder,o=t.autofocus,i=t.onFocus,c=t.onBlur,u=t.onChange,a=t.onClear,s=t.inputWidthCallback,f=t.components,l=e.useRef(null);return e.useEffect((function(){var t=l.current.offsetWidth;s(t)}),[]),e.createElement("div",{className:"react-searchbox__input-wrapper",ref:l},e.createElement("input",{placeholder:n,autoFocus:o,type:"text",className:"react-searchbox__input",onFocus:i,onKeyDown:Nn,onBlur:c,value:r,onChange:u}),r&&f.Clear&&e.createElement(f.Clear,{onClear:a}))}function Fn(t){var r=t.results,n=t.selectedItemIndex,o=t.width,i=t.onResultChoose,c=t.components;return 0===r.length?null:e.createElement("div",{className:"react-searchbox__results",style:{width:o},"data-testid":"results-list"},r.map((function(t,r){return c.Result?e.createElement(c.Result,{key:t.id,result:t,isSelected:r===n,onResultClick:function(){return i(t)}}):null})))}function qn(){return(qn=Object.assign||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}).apply(this,arguments)}In.propTypes={onChange:n.func.isRequired,value:n.string.isRequired,onFocus:n.func.isRequired,onClear:n.func.isRequired,onBlur:n.func.isRequired,inputWidthCallback:n.func.isRequired,placeholder:n.string.isRequired,autofocus:n.bool.isRequired,components:kn.isRequired},Fn.propTypes={results:n.arrayOf(n.object).isRequired,width:n.number.isRequired,onResultChoose:n.func.isRequired,selectedItemIndex:n.number,components:kn.isRequired},Fn.defaultProps={selectedItemIndex:null};var An=e.createElement("path",{d:"M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"}),Mn=e.createElement("path",{d:"M0 0h24v24H0z",fill:"none"});function Dn(t){return e.createElement("svg",qn({height:24,width:24},t),An,Mn)}function Gn(t){var r=t.onClear;return e.createElement("div",{className:"react-searchbox__clear",onClick:r,"data-testid":"clear"},e.createElement(Dn,null))}Gn.propTypes={onClear:n.func.isRequired};var zn={Clear:Gn},Wn=Object.freeze({__proto__:null,default:zn});function Bn(t){var r=l(e.useState(""),2),n=r[0],o=r[1],c=l(e.useState(null),2),u=c[0],a=c[1],f=l(e.useState(!1),2),p=f[0],h=f[1],d=l(e.useState(null),2),v=d[0],y=d[1],m=l(e.useState(null),2),g=m[0],b=m[1],w=e.useRef();function j(){return(j=i(regeneratorRuntime.mark((function e(r){var n,i;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t.onChange&&t.onChange(r),n=r.target.value,o(n),!(n.length>=t.minNumbOfChars)){e.next=11;break}return e.next=6,t.service(s({query:n},t.searchOptions)).catch();case 6:i=e.sent,a(i),h(!0),e.next=13;break;case 11:h(!1),a(null);case 13:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function O(e){o(t.getFormattedResult(e)),h(!1),t.onResultChoose&&t.onResultChoose(e)}var x=l(e.useState(-1),2),E=x[0],S=x[1];e.useEffect((function(){g&&function(){var e=i(regeneratorRuntime.mark((function e(r){var i,c;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:e.t0=r.keyCode,e.next=e.t0===_n?3:e.t0===Pn?6:e.t0===Tn?9:e.t0===Ln?20:22;break;case 3:return i=E<u.length-1?E+1:E,S(i),e.abrupt("break",22);case 6:return S(E>=0?E-1:E),e.abrupt("break",22);case 9:if(-1!==E){e.next=16;break}return e.next=12,t.service(s(s({query:n},t.searchOptions),{},{typeahead:!1})).catch();case 12:return(c=e.sent).length>0&&(o(t.getFormattedResult(c[0])),a(c),t.onResultChoose&&t.onResultChoose(c[0])),h(!1),e.abrupt("return");case 16:return O(u[E]),h(!1),e.abrupt("break",22);case 20:return h(!1),e.abrupt("break",22);case 22:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()(g)}),[g]),e.useEffect((function(){t.onResultSelect&&-1!==E&&p&&t.onResultSelect(u[E])}),[E]),e.useEffect((function(){S(-1),null!==u&&t.onResultsFetch&&t.onResultsFetch(u)}),[u]);var R=t.placeholder,C=t.autofocus,k=t.wrapperClassName,P=t.components,_=s(s({},zn),P);return e.createElement("div",{className:["react-searchbox",k].join(" "),ref:w,onKeyDown:function(t){t.persist(),b(t)}},e.createElement(In,{components:_,autofocus:C,value:n,placeholder:R,onBlur:function(){return h(!1)},inputWidthCallback:function(t){return y(t)},onFocus:function(){return h(!0)},onClear:function(){o(""),a(null)},onChange:function(t){return j.apply(this,arguments)}}),u&&p&&e.createElement(Fn,{components:_,selectedItemIndex:E,onResultChoose:O,results:u,width:v}))}Bn.defaultProps={components:zn,minNumbOfChars:3,placeholder:"",autofocus:!1,wrapperClassName:null,onResultSelect:null,onResultChoose:null,onResultsFetch:null,onChange:null},Bn.propTypes={searchOptions:n.objectOf(n.any).isRequired,minNumbOfChars:n.number,getFormattedResult:n.func.isRequired,service:n.func.isRequired,placeholder:n.string,autofocus:n.bool,wrapperClassName:n.string,onResultSelect:n.func,onResultChoose:n.func,onResultsFetch:n.func,onChange:n.func,components:kn};var Un=s({Result:Cn},Wn),Kn=function(t){var e=t.components,n=f(t,["components"]);return r.createElement(Bn,u({getFormattedResult:Rn,service:vn,components:s(s({Result:Cn},Un),e)},n))};Kn.propTypes={components:kn},exports.components=Un,exports.default=Kn;