text: (this["webpackJsonpfoursquare-api-demo-client"]=this["webpackJsonpfoursquare-api-demo-client"]||[]).push([[0],[,,,,,,,,,function(e,t,n){e.exports=n(20)},,,,,,function(e,t,n){},function(e,t,n){},function(e,t,n){},function(e,t,n){},function(e,t,n){},function(e,t,n){"use strict";n.r(t);var a=n(0),r=n.n(a),c=n(4),o=n.n(c),s=n(3),u=n(1),i=n.n(u),l=n(2),m=n(6),p=n.n(m),d=n(7);var f="Geolocation not supported or disabled",h=function(){var e=Object(l.a)(i.a.mark((function e(t){return i.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t.geolocation){e.next=2;break}throw new Error(f);case 2:return e.abrupt("return",new Promise((function(e){t.geolocation.getCurrentPosition((function(t){var n=t.coords,a=Math.round(100*n.latitude)/100,r=Math.round(100*n.longitude)/100;e("".concat(a,",").concat(r))}),(function(){throw new Error(f)}))})));case 3:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}();n(15);function v(e){var t=e.onSearchComplete,n=Object(a.useState)(""),c=Object(s.a)(n,2),o=c[0],u=c[1],m=Object(a.useState)(!1),f=Object(s.a)(m,2),v=f[0],b=f[1],E=function(){var e=Object(l.a)(i.a.mark((function e(n,a){return i.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return b(!0),e.abrupt("return",Object(d.a)(n).then((function(e){return e.json()})).then((function(e){var t,n=e.response;return n&&n.venues?(t=n.venues)&&t.map((function(e){var t=e.id,n=e.name,a=e.location,r=e.categories,c=r.length&&r.filter((function(e){return e.primary}))[0];return{id:t,name:n,address:a.formattedAddress.join(", "),category:{name:c?c.name:"Venue",icon:c?"".concat(c.icon.prefix,"bg_32").concat(c.icon.suffix):"https://ss3.4sqi.net/img/categories_v2/building/default_bg_32.png"}}})):[]})).then((function(e){return t(a,e)})).then((function(){b(!1),u("")})));case 2:case"end":return e.stop()}}),e)})));return function(t,n){return e.apply(this,arguments)}}(),g=function(){var e=Object(l.a)(i.a.mark((function e(){var t;return i.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,h(navigator).catch((function(){}));case 2:return t=e.sent,e.abrupt("return",E("".concat("/api/venues/search","?ll=").concat(t),"your location"));case 4:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),y=function(){var e=Object(l.a)(i.a.mark((function e(){return i.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o){e.next=2;break}return e.abrupt("return");case 2:return e.abrupt("return",E("".concat("/api/venues/search","?near=").concat(encodeURIComponent(o)),o));case 3:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}();return r.a.createElement("div",{className:"search-input"},r.a.createElement("div",{className:"search-input__form pure-form"},r.a.createElement("div",{className:"search-input__textbox"},r.a.createElement("input",{type:"text",className:"pure-input-1",placeholder:"Enter a city, address, etc...",value:o,onChange:function(e){var t=e.target;return u(t.value)},onKeyPress:function(e){"Enter"===e.key&&y()}})),r.a.createElement("div",{className:"search-input__buttons"},r.a.createElement("button",{className:"pure-button pure-button-primary",type:"button",disabled:v,onClick:y},"Search"),r.a.createElement("button",{className:"pure-button",type:"button",disabled:v,onClick:g},"Use my location"))),r.a.createElement("div",{style:v?{opacity:1,zIndex:10}:{opacity:0,zIndex:-1},className:"search-input__loading","data-testid":"loadingAnimation"},r.a.createElement("div",{className:"search-input__loading-bars"},r.a.createElement(p.a,{type:"bars",color:"#eee",height:"100px",width:"200px"}))))}var b=n(8);n(16);function E(e){var t=e.name,n=e.address,a=e.category;return r.a.createElement("div",{className:"venue"},r.a.createElement("div",{className:"venue__icon"},r.a.createElement(b.LazyLoadImage,{alt:a.name,height:32,src:a.icon,width:32})),r.a.createElement("div",{className:"venue__details"},r.a.createElement("div",{className:"venue__name"},t),r.a.createElement("div",{className:"venue__address"},n)))}n(17);function g(e){var t=e.searchTerm,n=e.venues;return r.a.createElement("div",{className:"search-results"},n.length>0?r.a.createElement(r.a.Fragment,null,r.a.createElement("h2",null,"Venues near ",t,":"),r.a.createElement("div",{className:"search-results__venues"},n.map((function(e){return r.a.createElement(E,Object.assign({key:e.id},e))})))):r.a.createElement("div",{className:"search-results__empty"},"Looks like we couldn't find anything for that location..."))}g.defaultProps={venues:[]};n(18);function y(){var e=Object(a.useState)(""),t=Object(s.a)(e,2),n=t[0],c=t[1],o=Object(a.useState)([]),u=Object(s.a)(o,2),i=u[0],l=u[1];return r.a.createElement("div",{className:"app"},r.a.createElement("h1",null,"Search for Venues"),r.a.createElement(v,{onSearchComplete:function(e,t){c(e),l(t)}}),n&&r.a.createElement(g,{searchTerm:n,venues:i}))}Boolean("localhost"===window.location.hostname||"[::1]"===window.location.hostname||window.location.hostname.match(/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/));n(19);o.a.render(r.a.createElement(r.a.StrictMode,null,r.a.createElement(y,null)),document.getElementById("root")),"serviceWorker"in navigator&&navigator.serviceWorker.ready.then((function(e){e.unregister()})).catch((function(e){console.error(e.message)}))}],[[9,1,2]]]);
  //# sourceMappingURL=main.5dc8b941.chunk.js.map