text: (window.webpackJsonp=window.webpackJsonp||[]).push([[0],[,,,,,,,,,,,,function(e,t,n){e.exports=n(33)},,,,,,function(e,t,n){},function(e,t,n){},function(e,t,n){},function(e,t,n){},function(e,t,n){},function(e,t,n){},function(e,t,n){},function(e,t,n){},function(e,t,n){},function(e,t,n){},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),i=n(11),o=n.n(i),c=n(5),s=n.n(c),u=n(6),l=n(9),h=n(1),f=n(2),p=n(7),d=n(4),m=n(3),y=n(8),v=n(35),b=function(e){Object(d.a)(n,e);var t=Object(m.a)(n);function n(){return Object(h.a)(this,n),t.apply(this,arguments)}return Object(f.a)(n,[{key:"render",value:function(){return r.a.createElement("p",{className:"forecast__temperature"},this.props.temperature,r.a.createElement("span",{className:"temperature__unit-dot"}))}}]),n}(a.PureComponent),w=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=(new Date).getTime(),a={};function r(){(new Date).getTime()-n>=t?e.call():a.value=requestAnimationFrame(r)}return a.value=requestAnimationFrame(r),a},g=(n(18),{"wi-cloudy":n.p+"static/media/wi-cloudy.3036dcf4.svg","wi-day-cloudy":n.p+"static/media/wi-day-cloudy.2d14b4eb.svg","wi-day-sunny":n.p+"static/media/wi-day-sunny.a12c7b3b.svg","wi-fog":n.p+"static/media/wi-fog.dcbb9c97.svg","wi-night-alt-cloudy":n.p+"static/media/wi-night-alt-cloudy.5856194e.svg","wi-night-clear":n.p+"static/media/wi-night-clear.22c8b82f.svg","wi-rain":n.p+"static/media/wi-rain.58931f0f.svg","wi-sleet":n.p+"static/media/wi-sleet.040e9866.svg","wi-snow":n.p+"static/media/wi-snow.f6b34506.svg","wi-windy":n.p+"static/media/wi-windy.d5931498.svg"}),k=function(e){var t={"clear-day":{id:"wi-day-sunny"},"clear-night":{id:"wi-night-clear"},"partly-cloudy-day":{id:"wi-day-cloudy"},"partly-cloudy-night":{id:"wi-night-alt-cloudy"},cloudy:{id:"wi-cloudy"},rain:{id:"wi-rain"},sleet:{id:"wi-sleet"},snow:{id:"wi-snow"},wind:{id:"wi-windy"},fog:{id:"wi-fog"}}[e];if(t)return t;throw new Error("No icon registered with the key: ".concat(e))},C=function(e){Object(d.a)(n,e);var t=Object(m.a)(n);function n(){var e;return Object(h.a)(this,n),(e=t.call(this)).forecast=r.a.createRef(),e}return Object(f.a)(n,[{key:"animate",value:function(){var e=this;w((function(){return e.forecast.current.classList.add("animate-in")}),100),w((function(){return e.title.classList.add("animate-in")}),200),w((function(){return e.icon.classList.add("animate-in")}),250),w((function(){e.temperature.map((function(e){return e.classList.add("animate-in")}))}),350),w((function(){return e.rain.classList.add("animate-in")}),400)}},{key:"componentDidMount",value:function(){var e=this;this.title=this.forecast.current.querySelector(".forecast__title"),this.icon=this.forecast.current.querySelector(".forecast__icon"),this.temperature=Object(y.a)(this.forecast.current.querySelectorAll(".forecast__temperature")),this.rain=this.forecast.current.querySelector(".rain"),w((function(){return e.animate()}),100*this.props.animationDelay)}},{key:"render",value:function(){return r.a.createElement("div",{ref:this.forecast,className:"forecast","data-id":this.props.id},r.a.createElement("span",{className:"forecast__title"},this.props.title),r.a.createElement("img",{className:"forecast__icon",alt:"icon",src:g[this.props.icon]}),this.props.children)}}]),n}(a.PureComponent),j=n.p+"static/media/rain-probality.b7a9b35c.svg",O=(n(19),function(e){Object(d.a)(n,e);var t=Object(m.a)(n);function n(){return Object(h.a)(this,n),t.apply(this,arguments)}return Object(f.a)(n,[{key:"render",value:function(){return r.a.createElement("div",{className:"rain"},r.a.createElement("img",{width:"24",height:"24",className:"rain__icon",src:j,alt:"rain probability ".concat(this.props.probability)}),r.a.createElement("span",{className:"rain__probability"},"".concat(this.props.probability,"%")))}}]),n}(a.PureComponent)),E=function(e){Object(d.a)(n,e);var t=Object(m.a)(n);function n(){return Object(h.a)(this,n),t.apply(this,arguments)}return Object(f.a)(n,[{key:"render",value:function(){return r.a.createElement("section",{className:"forecasts__period swiper-slide"},this.props.foreCastHourly.map((function(e,t){return r.a.createElement(C,{key:"hourly-".concat(t),id:"hourly-".concat(t),title:"".concat(e.time,":00"),icon:e.icon,animationDelay:t},r.a.createElement(b,{temperature:e.temperature}),r.a.createElement(O,{probability:e.rainProbability}))})))}}]),n}(a.PureComponent),L=function(e){Object(d.a)(n,e);var t=Object(m.a)(n);function n(){return Object(h.a)(this,n),t.apply(this,arguments)}return Object(f.a)(n,[{key:"render",value:function(){return r.a.createElement("section",{className:"forecasts__period forecasts--daily swiper-slide"},this.props.foreCastDaily.map((function(e,t){return r.a.createElement(C,{key:"daily-".concat(t),id:"daily-".concat(t),title:e.weekDay,icon:e.icon,animationDelay:t},r.a.createElement("div",null,r.a.createElement(b,{temperature:e.temperature.max}),r.a.createElement(b,{temperature:e.temperature.min})),r.a.createElement(O,{probability:e.rainProbability}))})))}}]),n}(a.PureComponent),x=(n(20),function(e){Object(d.a)(n,e);var t=Object(m.a)(n);function n(){var e;return Object(h.a)(this,n),(e=t.call(this)).icon=r.a.createRef(),e.text=r.a.createRef(),e}return Object(f.a)(n,[{key:"animate",value:function(){var e=this;w((function(){return e.icon.current.classList.add("animate-in")}),250),w((function(){return e.text.current.classList.add("animate-in")}),350)}},{key:"componentDidMount",value:function(){var e=this;w((function(){return e.animate()}),350)}},{key:"render",value:function(){return r.a.createElement("section",{className:"location"},r.a.createElement("span",{ref:this.icon,className:"location__icon"},r.a.createElement("svg",{enableBackground:"new 0 0 24 24",height:"24px",id:"location",version:"1.1",viewBox:"0 0 24 24",width:"24px"},r.a.createElement("path",{d:"M11.513,12.38c-2.117,0-3.835-1.729-3.835-3.862c0-2.135,1.718-3.863,3.835-3.863s3.835,1.729,3.835,3.863  C15.348,10.65,13.63,12.38,11.513,12.38 M11.513,0C6.825,0,3.025,3.827,3.025,8.549c0,4.46,3.844,10.213,6.411,13.014  c0.959,1.045,2.076,2.454,2.076,2.454s1.2-1.417,2.229-2.493C16.306,18.84,20,13.451,20,8.549C20,3.827,16.2,0,11.513,0"}))),r.a.createElement("span",{ref:this.text,className:"location__text"},this.props.location))}}]),n}(a.PureComponent)),_=(n(21),function(e){Object(d.a)(n,e);var t=Object(m.a)(n);function n(){var e;return Object(h.a)(this,n),(e=t.call(this)).status=r.a.createRef(),e.value=r.a.createRef(),e.unit=r.a.createRef(),e}return Object(f.a)(n,[{key:"animate",value:function(){var e=this;w((function(){return e.status.current.classList.add("animate-in")}),150),w((function(){return e.value.current.classList.add("animate-in")}),250),w((function(){return e.unit.current.classList.add("animate-in")}),300)}},{key:"componentDidMount",value:function(){var e=this;w((function(){return e.animate()}),400)}},{key:"render",value:function(){return r.a.createElement("section",{className:"current-condition"},r.a.createElement("div",{className:"wrapper-temperature"},r.a.createElement("span",{ref:this.status,className:"temperature__status"},this.props.weather),r.a.createElement("div",{className:"temperature"},r.a.createElement("span",{ref:this.value,className:"temperature__value"},this.props.temperature),r.a.createElement("div",{ref:this.unit,className:"temperature__unit"},r.a.createElement("span",{className:"temperature__unit-dot"}),r.a.createElement("span",{className:"temperature__unit-letter"},"c")))))}}]),n}(a.PureComponent)),P=(n(22),function(e){Object(d.a)(n,e);var t=Object(m.a)(n);function n(){var e;return Object(h.a)(this,n),(e=t.call(this)).navigation=r.a.createRef(),e}return Object(f.a)(n,[{key:"animate",value:function(){var e=this;w((function(){e.dots.map((function(e,t){return w((function(){return e.classList.add("animate-in")}),150*t),e}))}),350)}},{key:"componentDidMount",value:function(){var e=this;this.dots=Object(y.a)(this.navigation.current.querySelectorAll(".navigation__dot")),w((function(){return e.animate()}),350)}},{key:"render",value:function(){return r.a.createElement("section",{ref:this.navigation,className:"navigation ".concat(this.props.currentForecast)},r.a.createElement("div",{className:"navigation__dot"}),r.a.createElement("div",{className:"navigation__dot"}))}}]),n}(a.PureComponent)),S=(n(23),function(e){Object(d.a)(n,e);var t=Object(m.a)(n);function n(){var e;return Object(h.a)(this,n),(e=t.call(this)).button=r.a.createRef(),e.onMouseDown=e.onMouseDown.bind(Object(p.a)(e)),e.onMouseUp=e.onMouseUp.bind(Object(p.a)(e)),e}return Object(f.a)(n,[{key:"animate",value:function(){var e=this;w((function(){return e.button.current.classList.add("animate-in")}),430)}},{key:"onMouseDown",value:function(){var e=this;w((function(){return e.button.current.classList.add("press")}),1)}},{key:"onMouseUp",value:function(){var e=this;w((function(){return e.button.current.classList.remove("press")}),1)}},{key:"componentDidMount",value:function(){var e=this;w((function(){return e.animate()}),350)}},{key:"render",value:function(){return r.a.createElement("button",{ref:this.button,type:"button",className:"gps-location","aria-label":"Get current location",onTouchStart:this.onMouseDown,onTouchEnd:this.onMouseUp,onMouseDown:this.onMouseDown,onMouseUp:this.onMouseUp,onClick:this.props.onGPSLocationClick},r.a.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",id:"gpslocation",viewBox:"0 0 96 96"},r.a.createElement("g",{id:"XMLID_1_"},r.a.createElement("circle",{id:"XMLID_3_",cx:"48",cy:"48",r:"9.8"}),r.a.createElement("path",{id:"XMLID_6_",d:"M80.5 44.8h-6.7C72.3 33 63 23.7 51.3 22.2v-6.7h-6.5v6.7C33 23.7 23.7 33 22.2 44.8h-6.7v6.5h6.7C23.7 63 33 72.3 44.8 73.8v6.7h6.5v-6.7C63 72.3 72.3 63 73.8 51.3h6.7v-6.5zM48 67.5c-10.8 0-19.5-8.7-19.5-19.5S37.2 28.5 48 28.5 67.5 37.2 67.5 48 58.8 67.5 48 67.5z"}))))}}]),n}(a.PureComponent)),I=(n(24),function(e){Object(d.a)(n,e);var t=Object(m.a)(n);function n(){var e;return Object(h.a)(this,n),(e=t.call(this)).button=r.a.createRef(),e}return Object(f.a)(n,[{key:"animate",value:function(){var e=this;w((function(){return e.button.current.classList.add("animate-in")}),500)}},{key:"componentDidMount",value:function(){var e=this;w((function(){return e.animate()}),350)}},{key:"render",value:function(){return r.a.createElement("button",{ref:this.button,type:"button",className:"button-info","aria-label":"Information",onClick:this.props.onInfoClick},r.a.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},r.a.createElement("path",{d:"M12 0C5.371 0 0 5.371 0 12s5.371 12 12 12 12-5.371 12-12S18.629 0 12 0zm0 2c5.523 0 10 4.477 10 10s-4.477 10-10 10S2 17.523 2 12 6.477 2 12 2zm0 3.813c-.184 0-.336-.004-.5.03a1.127 1.127 0 0 0-.438.22.98.98 0 0 0-.28.375c-.071.152-.095.332-.095.562 0 .227.024.406.094.563.07.156.16.28.281.375.122.093.274.148.438.187.164.04.316.063.5.063.18 0 .371-.024.531-.063.16-.04.285-.094.406-.188a.951.951 0 0 0 .282-.375c.07-.152.125-.335.125-.562 0-.23-.055-.41-.125-.563a.98.98 0 0 0-.281-.375c-.122-.093-.247-.183-.407-.218-.16-.035-.351-.032-.531-.032zm-1.219 3.343v8.969h2.438V9.156z"})))}}]),n}(a.PureComponent)),D=(n(25),function(e){Object(d.a)(n,e);var t=Object(m.a)(n);function n(){var e;return Object(h.a)(this,n),(e=t.call(this)).text=r.a.createRef(),e}return Object(f.a)(n,[{key:"animate",value:function(){var e=this;w((function(){return e.text.current.classList.add("animate-in")}),400)}},{key:"componentDidMount",value:function(){var e=this;w((function(){return e.animate()}),350)}},{key:"render",value:function(){return r.a.createElement("section",{className:"date-current"},r.a.createElement("span",{ref:this.text,className:"date-current__text"},this.props.date))}}]),n}(a.PureComponent)),N=(n(26),function(e){Object(d.a)(n,e);var t=Object(m.a)(n);function n(){var e;return Object(h.a)(this,n),(e=t.call(this)).view=r.a.createRef(),e.button=r.a.createRef(),e.getClass=e.getClass.bind(Object(p.a)(e)),e.onMouseDown=e.onMouseDown.bind(Object(p.a)(e)),e.onMouseUp=e.onMouseUp.bind(Object(p.a)(e)),e}return Object(f.a)(n,[{key:"animate",value:function(){var e=this;w((function(){return e.view.current.classList.add("animate-in")}),350)}},{key:"onMouseDown",value:function(){var e=this;w((function(){return e.button.current.classList.add("press")}),1)}},{key:"onMouseUp",value:function(){var e=this;w((function(){return e.button.current.classList.remove("press")}),1)}},{key:"componentDidMount",value:function(){var e=this;w((function(){return e.animate()}),350)}},{key:"getClass",value:function(e){var t=e.updating,n="";return this.view.current&&(n="animate-in"),"refresh ".concat(n," ").concat(t?"fetching":"")}},{key:"render",value:function(){return r.a.createElement("section",{ref:this.view,className:"".concat(this.getClass(this.props))},r.a.createElement("span",{className:"refresh__time"},this.props.time),r.a.createElement("button",{ref:this.button,type:"button",className:"button-refresh","aria-label":"Refresh content",onTouchStart:this.onMouseDown,onTouchEnd:this.onMouseUp,onMouseDown:this.onMouseDown,onMouseUp:this.onMouseUp,onClick:this.props.onClick},r.a.createElement("svg",{viewBox:"0 0 96 96"},r.a.createElement("path",{d:"M48 15.5c-8.8 0-17 3.5-23 9.5l-6.3-6.3v19.5h19.5l-8.6-8.6C34.4 24.8 40.9 22 48 22c14.3 0 26 11.7 26 26S62.3 74 48 74 22 62.3 22 48h-6.5c0 17.9 14.6 32.5 32.5 32.5S80.5 65.9 80.5 48 65.9 15.5 48 15.5z"}))))}}]),n}(a.PureComponent)),M=function(e){Object(d.a)(n,e);var t=Object(m.a)(n);function n(){var e;return Object(h.a)(this,n),(e=t.call(this)).state={currentForecast:"hourly",forecastIndex:["hourly","daily"]},e}return Object(f.a)(n,[{key:"componentDidMount",value:function(){var e=this;this.forecasts=Object(y.a)(document.querySelectorAll(".forecasts__period")),this.swiper=new v.a(".swiper-container",{direction:"horizontal",loop:!1}),this.swiper.on("slideChangeTransitionEnd",(function(){e.setState({currentForecast:e.state.forecastIndex[e.swiper.activeIndex]})}))}},{key:"render",value:function(){return r.a.createElement(a.Fragment,null,r.a.createElement(S,{onGPSLocationClick:this.props.onGPSLocationClick}),r.a.createElement(I,{onInfoClick:this.props.onInfoClick,onInfoClose:this.props.onInfoClose}),r.a.createElement(x,{location:this.props.currentCondition.location}),r.a.createElement(D,{date:this.props.currentCondition.date}),r.a.createElement(_,{weather:this.props.currentCondition.weather,temperature:this.props.currentCondition.temperature}),r.a.createElement(N,{onClick:this.props.onRefreshClick,updating:this.props.updating,time:this.props.lastUpdate}),r.a.createElement("section",{className:"forecasts"},r.a.createElement("div",{className:"forecasts__scroll-panel swiper-container"},r.a.createElement("div",{className:"swiper-wrapper"},r.a.createElement(E,{foreCastHourly:this.props.foreCastHourly}),r.a.createElement(L,{foreCastDaily:this.props.foreCastDaily}))),r.a.createElement(P,{currentForecast:this.state.currentForecast})))}}]),n}(a.PureComponent),R=(n(27),function(e){Object(d.a)(n,e);var t=Object(m.a)(n);function n(){var e;return Object(h.a)(this,n),(e=t.call(this)).button=r.a.createRef(),e}return Object(f.a)(n,[{key:"animate",value:function(){var e=this;w((function(){return e.button.current.classList.add("animate-in")}),1)}},{key:"hide",value:function(){var e=this;w((function(){return e.button.current.classList.remove("animate-in")}),1)}},{key:"render",value:function(){return r.a.createElement("button",{ref:this.button,type:"button",className:"button-close","aria-label":"Close view",onClick:this.props.onCloseClick},r.a.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",fill:"#fff",stroke:"#000",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2"},r.a.createElement("path",{d:"M18 6L6 18M6 6l12 12"})))}}]),n}(a.PureComponent)),G=n.p+"static/media/github.5cb865b1.svg",A=(n(28),n(29),function(e){Object(d.a)(n,e);var t=Object(m.a)(n);function n(){var e;return Object(h.a)(this,n),(e=t.call(this)).transition=r.a.createRef(),e.view=r.a.createRef(),e.close=r.a.createRef(),e.onInfoClose=e.onInfoClose.bind(Object(p.a)(e)),e}return Object(f.a)(n,[{key:"onInfoClose",value:function(){var e=this;w((function(){return e.view.current.classList.remove("animate-in")}),1),w((function(){return e.close.current.hide()}),20),w((function(){return e.transition.current.classList.remove("animate-in")}),100),w((function(){e.props.onInfoClose(),e.view.current.setAttribute("aria-hidden",!0)}),110)}},{key:"getStyle",value:function(e){var t=this;return e?(w((function(){return t.transition.current.classList.add("animate-in")}),1),w((function(){return t.close.current.animate()}),50),w((function(){t.view.current.classList.remove("hide"),t.view.current.classList.add("animate-in"),t.view.current.setAttribute("aria-hidden",!1)}),150),""):""}},{key:"render",value:function(){return r.a.createElement(a.Fragment,null,r.a.createElement("div",{ref:this.transition,className:"transition"}),r.a.createElement("section",{ref:this.view,className:"info ".concat(this.getStyle(this.props.show)),"aria-hidden":!0},r.a.createElement(R,{ref:this.close,onCloseClick:this.onInfoClose}),r.a.createElement("h1",null,"About"),r.a.createElement("p",null,"PWA Weather Application made with React/Scss/ES6"),r.a.createElement("p",null,"This is a personal project built in my spare time for learning purposes."),r.a.createElement("h2",null,"APIs"),r.a.createElement("ul",null,r.a.createElement("li",null,r.a.createElement("a",{className:"link",href:"https://www.ipify.org",target:"_blank",rel:"noopener noreferrer"},"Ipify (ip address)")),r.a.createElement("li",null,r.a.createElement("a",{className:"link",href:"https://ipstack.com",target:"_blank",rel:"noopener noreferrer"},"IpStack (ip based geolocation)")),r.a.createElement("li",null,r.a.createElement("a",{className:"link",href:"https://darksky.net",target:"_blank",rel:"noopener noreferrer"},"DarkSky (weather forecasting)")),r.a.createElement("li",null,r.a.createElement("a",{className:"link",href:"https://opencagedata.com/",target:"_blank",rel:"noopener noreferrer"},"OpenCage (reverse geolocation)"))),r.a.createElement("a",{target:"_blank",rel:"noopener noreferrer",href:"https://github.com/iondrimba/react-weather-app",className:"github",title:"Github"},r.a.createElement("img",{src:G,alt:"Github icon",width:"32",height:"32"}))))}}]),n}(a.PureComponent)),U=(n(30),function(e){Object(d.a)(n,e);var t=Object(m.a)(n);function n(){var e;return Object(h.a)(this,n),(e=t.call(this)).loader=r.a.createRef(),e.circle=r.a.createRef(),e.rays=[],e}return Object(f.a)(n,[{key:"_getCircle",value:function(){return this.circle.current?this.circle.current:document.querySelector(".loader__circle")}},{key:"animateIn",value:function(){var e=this;this.animateCircle(),w((function(){return e.animateRays()}),300),w((function(){return e.startRotation()}),500)}},{key:"animateRays",value:function(){this.rays.map((function(e,t){return w((function(){return e.classList.add("animate-in")}),80*t),e}))}},{key:"startRotation",value:function(){var e=this;w((function(){return e._getCircle().classList.add("start-rotation")}),300)}},{key:"animateCircle",value:function(){var e=this;w((function(){return e._getCircle().classList.add("animate-in")}),150)}},{key:"animateOut",value:function(){var e=this;w((function(){return e._getCircle().classList.add("animate-out")}),550),this.rays.map((function(e,t){return w((function(){return e.classList.add("animate-out")}),50*t),e}))}},{key:"componentDidMount",value:function(){this.rays=Object(y.a)(this._getCircle().querySelectorAll(".ray"))}},{key:"render",value:function(){return r.a.createElement("div",{ref:this.loader,className:"loader"},r.a.createElement("div",{ref:this.circle,className:"loader__circle"},[0,1].map((function(e){return r.a.createElement("div",{key:"ray_".concat(e),className:"rays"},r.a.createElement("div",{className:"ray ray--north"}),r.a.createElement("div",{className:"ray ray--west"}),r.a.createElement("div",{className:"ray ray--south"}),r.a.createElement("div",{className:"ray ray--east"}))}))))}}]),n}(a.PureComponent)),F=(n(31),function(e){Object(d.a)(n,e);var t=Object(m.a)(n);function n(){return Object(h.a)(this,n),t.apply(this,arguments)}return Object(f.a)(n,[{key:"render",value:function(){return r.a.createElement("div",{className:"error"},r.a.createElement("h1",null,":("),"This application uses a free service from ",r.a.createElement("a",{target:"blank",rel:"noopener",href:"https://ipstack.com/"},"https://ipstack.com/")," and the current usage exceded the reach limit.",r.a.createElement("br",null),r.a.createElement("br",null),"Please come back later.")}}]),n}(a.PureComponent)),T=function(){function e(t){Object(h.a)(this,e),this.endpoint=function(e){return"https://weather-api-nodejs.herokuapp.com/api/ip?ip=".concat(e)},this.data=null,this.secret=t}return Object(f.a)(e,[{key:"fetch",value:function(e){function t(t){return e.apply(this,arguments)}return t.toString=function(){return e.toString()},t}(function(){var e=Object(u.a)(s.a.mark((function e(t){var n,a;return s.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,fetch(this.endpoint(t));case 3:return n=e.sent,e.next=6,n.json();case 6:a=e.sent,this.data=a,e.next=13;break;case 10:throw e.prev=10,e.t0=e.catch(0),new Error("IpGeoLocation unable to fetch: ".concat(e.t0.message));case 13:case"end":return e.stop()}}),e,this,[[0,10]])})));return function(t){return e.apply(this,arguments)}}())}]),e}(),H=function(){function e(t){Object(h.a)(this,e),this.secret=t,this.endpoint=function(e,t){return"https://weather-api-nodejs.herokuapp.com/api?latitude=".concat(e,"&longitude=").concat(t)},this.data=null}return Object(f.a)(e,[{key:"fetch",value:function(e){function t(t,n){return e.apply(this,arguments)}return t.toString=function(){return e.toString()},t}(function(){var e=Object(u.a)(s.a.mark((function e(t,n){var a;return s.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,fetch(this.endpoint(t,n));case 3:return a=e.sent,e.next=6,a.json();case 6:this.data=e.sent,e.next=12;break;case 9:throw e.prev=9,e.t0=e.catch(0),new Error("ForeCastAPI unable to fetch: ".concat(e.t0.message));case 12:case"end":return e.stop()}}),e,this,[[0,9]])})));return function(t,n){return e.apply(this,arguments)}}())}]),e}(),q=function(){function e(){Object(h.a)(this,e),this.endpoint=function(e,t){return"https://weather-api-nodejs.herokuapp.com/api/geolocation?latitude=".concat(e,"&longitude=").concat(t)},this.data=null}return Object(f.a)(e,[{key:"fetch",value:function(e){function t(t,n){return e.apply(this,arguments)}return t.toString=function(){return e.toString()},t}(function(){var e=Object(u.a)(s.a.mark((function e(t,n){var a,r;return s.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,fetch(this.endpoint(t,n));case 3:return a=e.sent,e.next=6,a.json();case 6:r=e.sent,this.data=r,e.next=13;break;case 10:throw e.prev=10,e.t0=e.catch(0),new Error("ReverseGeoLocation unable to fetch: ".concat(e.t0.message));case 13:case"end":return e.stop()}}),e,this,[[0,10]])})));return function(t,n){return e.apply(this,arguments)}}())}]),e}(),z=function(){function e(){Object(h.a)(this,e),this.ip="",this.endpoint="https://api.ipify.org/?format=json"}return Object(f.a)(e,[{key:"fetch",value:function(e){function t(){return e.apply(this,arguments)}return t.toString=function(){return e.toString()},t}(Object(u.a)(s.a.mark((function e(){var t,n;return s.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,fetch(this.endpoint);case 3:return t=e.sent,e.next=6,t.json();case 6:n=e.sent,this.ip=n.ip,e.next=13;break;case 10:throw e.prev=10,e.t0=e.catch(0),new Error("IpFetcher unable to fetch: ".concat(e.t0.message));case 13:case"end":return e.stop()}}),e,this,[[0,10]])}))))}]),e}(),W=function(e){return e<10?"0".concat(e):e},B=function(e){var t=new Date(1e3*e),n=t.getTime();return new Date(function(e,t){var n=t;return/GMT\+\d+/.test(e.toString())&&(n=t+6e4*e.getTimezoneOffset()),n}(t,n))},J=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"en-US",n=B(e),a=n.getFullYear(),r=n.getDay(),i=n.getMonth()+1,o=n.getDate(),c=n.getHours(),s=n.getMinutes();i=W(i),o=W(o),c=W(c),s=W(s);var u=n.toLocaleDateString(t,{weekday:"long",year:"numeric",month:"long",day:"numeric"});return{localeDateString:u,weekDay:r,day:o,month:i,year:a,hours:c,minutes:s}},X=function(e){var t=["sun","mon","tue","wed","thu","fri","sat"][e];if(t)return t;throw new Error("No weekday found for index: ".concat(e))},Q={showInfo:!1,dataLoaded:!1,latitude:0,longitude:0,updating:!1,lastUpdate:"00:00",currentCondition:{currentCondition:{location:"--",temperature:0,date:"--",weather:"Clear",dayTime:!1,humidity:0,dataLoaded:!1},foreCastDaily:[{weekDay:"mon",rainProbability:0,icon:"wi-day-sunny",temperature:{max:0,min:0}},{weekDay:"tue",rainProbability:0,icon:"wi-day-sunny",temperature:{max:0,min:0}},{weekDay:"wed",rainProbability:0,icon:"wi-day-sunny",temperature:{max:0,min:0}},{weekDay:"Thu",rainProbability:0,icon:"wi-day-sunny",temperature:{max:0,min:0}},{weekDay:"Fri",rainProbability:0,icon:"wi-fog",temperature:{max:0,min:0}}],foreCastHourly:[{time:0,rainProbability:0,temperature:23,icon:"wi-fog"},{time:0,rainProbability:0,temperature:25,icon:"wi-day-sunny"},{time:0,rainProbability:0,temperature:15,icon:"wi-day-sunny"},{time:0,rainProbability:0,temperature:16,icon:"wi-day-sunny"},{time:0,rainProbability:0,temperature:24,icon:"wi-day-sunny"}],location:"S\xe3o Paulo",date:"Sunday, August 12, 2018",temperature:17,weather:"Mostly Cloudy"},foreCastHourly:[{time:0,rainProbability:0,temperature:0,icon:"wi-day-cloudy"},{time:0,rainProbability:0,temperature:0,icon:"wi-day-cloudy"},{time:0,rainProbability:0,temperature:0,icon:"wi-day-cloudy"},{time:0,rainProbability:0,temperature:0,icon:"wi-night-clear"},{time:0,rainProbability:0,temperature:14,icon:"wi-night-clear"}],foreCastDaily:[{weekDay:"mon",rainProbability:0,icon:"wi-day-sunny",temperature:{max:0,min:0}},{weekDay:"tue",rainProbability:0,icon:"wi-day-sunny",temperature:{max:0,min:0}},{weekDay:"wed",rainProbability:0,icon:"wi-night-alt-cloudy",temperature:{max:0,min:0}},{weekDay:"thu",rainProbability:0,icon:"wi-cloudy",temperature:{max:0,min:0}},{weekDay:"fri",rainProbability:0,icon:"wi-cloudy",temperature:{max:0,min:0}}]},V=function(){function e(){Object(h.a)(this,e),this.ipFetcher=new z,this.ipGeoLocation=new T,this.foreCastAPI=new H("#####"),this.reverseGeoLocation=new q,this.data=Object(l.a)({},Q),this.currentDate=new Date}return Object(f.a)(e,[{key:"update",value:function(){this.ipGeoLocation.data.error||(this.data={latitude:this.foreCastAPI.data.latitude,longitude:this.foreCastAPI.data.longitude,lastUpdate:this.getLastUpdate(this.currentDate),currentCondition:Object(l.a)(Object(l.a)({},Q),{},{location:this.ipGeoLocation.data.city,date:J(this.foreCastAPI.data.currently.time).localeDateString,temperature:Math.round(this.foreCastAPI.data.currently.temperature),weather:this.foreCastAPI.data.currently.summary}),foreCastHourly:this.foreCastAPI.data.hourly.data.slice(0,5).map((function(e){return{time:J(e.time).hours,rainProbability:Math.round(100*e.precipProbability),temperature:Math.round(e.temperature),icon:k(e.icon).id}})),foreCastDaily:this.foreCastAPI.data.daily.data.slice(1,6).map((function(e){return{weekDay:X(J(e.time).weekDay),rainProbability:Math.round(100*e.precipProbability),icon:k(e.icon).id,temperature:{max:Math.round(e.temperatureMax),min:Math.round(e.temperatureMin)}}}))})}},{key:"getLastUpdate",value:function(e){return"".concat(W(e.getHours()),":").concat(W(e.getMinutes()))}},{key:"_updateIP",value:function(){var e=Object(u.a)(s.a.mark((function e(){return s.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!localStorage.getItem("ip")){e.next=4;break}this.ipFetcher.ip=localStorage.getItem("ip"),e.next=7;break;case 4:return e.next=6,this.ipFetcher.fetch();case 6:localStorage.setItem("ip",this.ipFetcher.ip);case 7:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}()},{key:"_updateGeoLocation",value:function(){var e=Object(u.a)(s.a.mark((function e(){return s.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!localStorage.getItem("geoLocation")){e.next=4;break}this.ipGeoLocation.data=JSON.parse(localStorage.getItem("geoLocation")),e.next=7;break;case 4:return e.next=6,this.ipGeoLocation.fetch(this.ipFetcher.ip);case 6:localStorage.setItem("geoLocation",JSON.stringify(this.ipGeoLocation.data));case 7:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}()},{key:"_updateForecast",value:function(){var e=Object(u.a)(s.a.mark((function e(){return s.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!localStorage.getItem("forecast")){e.next=4;break}this.foreCastAPI.data=JSON.parse(localStorage.getItem("forecast")),e.next=8;break;case 4:return e.next=6,this.foreCastAPI.fetch(this.ipGeoLocation.data.latitude,this.ipGeoLocation.data.longitude);case 6:localStorage.setItem("lastupdate",(new Date).getTime()),localStorage.setItem("forecast",JSON.stringify(this.foreCastAPI.data));case 8:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}()},{key:"fetch",value:function(){var e=Object(u.a)(s.a.mark((function e(){return s.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._updateIP();case 2:return e.next=4,this._updateGeoLocation();case 4:return e.next=6,this._updateForecast();case 6:this.update();case 7:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}()},{key:"getLocation",value:function(){var e=Object(u.a)(s.a.mark((function e(t,n){var a,r;return s.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.currentDate=new Date,a=Number(localStorage.getItem("lastupdate")),r=Math.abs(this.currentDate.getTime()-a)/36e5,this.foreCastAPI.data.latitude=t,this.foreCastAPI.data.longitude=n,this.data.lastUpdate=this.getLastUpdate(this.currentDate),e.next=8,this.reverseGeoLocation.fetch(t,n);case 8:if(!(r>1.05)){e.next=13;break}return e.next=11,this.foreCastAPI.fetch(t,n);case 11:localStorage.setItem("lastupdate",this.currentDate.getTime()),localStorage.setItem("forecast",JSON.stringify(this.foreCastAPI.data));case 13:this.ipGeoLocation.data.city=this.reverseGeoLocation.data[0].city||this.reverseGeoLocation.data[0].state,this.update();case 15:case"end":return e.stop()}}),e,this)})));return function(t,n){return e.apply(this,arguments)}}()}]),e}(),Y=(n(32),function(e){Object(d.a)(n,e);var t=Object(m.a)(n);function n(){var e;return Object(h.a)(this,n),(e=t.call(this)).loader=r.a.createRef(),e.onInfoClick=e.onInfoClick.bind(Object(p.a)(e)),e.onInfoClose=e.onInfoClose.bind(Object(p.a)(e)),e.onRefreshClick=e.onRefreshClick.bind(Object(p.a)(e)),e.onGPSLocationClick=e.onGPSLocationClick.bind(Object(p.a)(e)),e.storage=new V("#####"),e.state=Object(l.a)({},e.storage.data),e}return Object(f.a)(n,[{key:"init",value:function(){var e=Object(u.a)(s.a.mark((function e(){var t=this;return s.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return w((function(){return t.loader.current.animateIn()}),100),e.next=3,this.storage.fetch();case 3:w((function(){t.loader.current.animateOut(),w((function(){return t.updatedState(t.storage)}),600)}),1e3);case 4:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}()},{key:"updatedState",value:function(e){var t=e.ipGeoLocation,n=e.data;t.data&&t.data.error?this.setState({error:t.data.error,dataLoaded:!0}):this.setState(Object(l.a)(Object(l.a)({},n),{},{showInfo:!1,dataLoaded:!0,updating:!1}))}},{key:"onGetCurrentLocation",value:function(){var e=Object(u.a)(s.a.mark((function e(t){var n,a,r=this;return s.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.latitude,a=t.longitude,e.next=3,this.storage.getLocation(n,a);case 3:w((function(){return r.updatedState(r.storage)}),600);case 4:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}()},{key:"onGPSLocationClick",value:function(){var e=this;this.state.updating||(this.setState({updating:!0}),navigator.geolocation&&navigator.geolocation.getCurrentPosition((function(t){e.onGetCurrentLocation(t.coords)})))}},{key:"onRefreshClick",value:function(){var e=this.storage.data,t=e.latitude,n=e.longitude;this.state.updating||(this.setState({updating:!0}),this.onGetCurrentLocation({latitude:t,longitude:n}))}},{key:"onInfoClick",value:function(){this.setState({showInfo:!0})}},{key:"onInfoClose",value:function(){this.setState({showInfo:!1})}},{key:"componentDidMount",value:function(){this.init()}},{key:"errorReachLimit",value:function(){return r.a.createElement(F,null)}},{key:"display",value:function(){return this.state.error?this.errorReachLimit():this.displayHome()}},{key:"displayHome",value:function(){return r.a.createElement(a.Fragment,null,r.a.createElement(M,{currentCondition:this.state.currentCondition,foreCastDaily:this.state.foreCastDaily,foreCastHourly:this.state.foreCastHourly,onInfoClick:this.onInfoClick,onGPSLocationClick:this.onGPSLocationClick,updating:this.state.updating,lastUpdate:this.state.lastUpdate,onRefreshClick:this.onRefreshClick}),r.a.createElement(A,{onInfoClose:this.onInfoClose,show:this.state.showInfo}))}},{key:"render",value:function(){return r.a.createElement("div",{className:"App"},this.state.dataLoaded?this.display():r.a.createElement(U,{ref:this.loader}))}}]),n}(a.Component)),$=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}$/));function K(e){navigator.serviceWorker.register(e).then((function(e){e.onupdatefound=function(){var t=e.installing;t.onstatechange=function(){"installed"===t.state&&(navigator.serviceWorker.controller?console.log("New content is available; please refresh."):console.log("Content is cached for offline use."))}}})).catch((function(e){console.error("Error during service worker registration:",e)}))}o.a.render(r.a.createElement(Y,null),document.getElementById("root")),function(){if("serviceWorker"in navigator){if(new URL("",window.location).origin!==window.location.origin)return;window.addEventListener("load",(function(){var e="".concat("","/service-worker.js");$?(!function(e){fetch(e).then((function(t){404===t.status||-1===t.headers.get("content-type").indexOf("javascript")?navigator.serviceWorker.ready.then((function(e){e.unregister().then((function(){window.location.reload()}))})):K(e)})).catch((function(){console.log("No internet connection found. App is running in offline mode.")}))}(e),navigator.serviceWorker.ready.then((function(){console.log("This web app is being served cache-first by a service worker. To learn more, visit https://goo.gl/SC7cgQ")}))):K(e)}))}}()}],[[12,1,2]]]);
  //# sourceMappingURL=main.0c25600b.chunk.js.map