text: (window.webpackJsonp=window.webpackJsonp||[]).push([[0],{22:function(e,t,a){e.exports=a.p+"static/media/logo.700ea584.png"},39:function(e,t,a){e.exports=a(56)},45:function(e,t,a){},56:function(e,t,a){"use strict";a.r(t);var n=a(2),r=a.n(n),c=a(26),l=a.n(c),i=a(16),s=a(10),m=a(15),o=(a(44),a(45),a(17)),d=a(21),u=a.n(d),p=a(27),g=a(28),h=a(29),b=a(37),f=a(30),E=a(38),v=a(31);function y(){var e=Object(v.a)(["\n  query($_id: ID) {\n    character(_id: $_id) {\n      _id\n      name\n      status\n      species\n      gender\n      origin {\n        name\n      }\n      location {\n        name\n      }\n      image\n    }\n  }\n"]);return y=function(){return e},e}var N=Object(i.b)(y()),x=a(36),w=function(e){var t=e.seen,a=e.onClick,n=Object(x.a)(t.values());return r.a.createElement("ul",{className:"list-group",style:{maxHeight:"500px",overflowY:"scroll"}},n.map(function(e){return r.a.createElement("li",{key:e._id+Math.random(),className:"list-group-item d-flex justify-content-between align-items-center",style:{maxHeight:"40px",cursor:"pointer"},onClick:function(){return a(e._id)}},r.a.createElement("img",{src:e.image,alt:"img",style:{maxHeight:"40px"}}),e.name,r.a.createElement("span",{className:"badge badge-info badge-pill"},e._id.slice(e._id.length-3)))}))},k=function(e){var t=Object(o.a)({},e.character);return r.a.createElement("div",{className:"card mb-3"},r.a.createElement("div",{className:"row no-gutters"},r.a.createElement("div",{className:"col-md-5"},r.a.createElement("img",{style:{maxHeight:"300px",maxWidth:"300px"},src:t&&t.image,className:"card-img",alt:"loading..."})),r.a.createElement("div",{className:"col-md-7 p-3"},r.a.createElement("h5",{className:"card-title d-flex justify-content-between mb-0"},r.a.createElement("u",null,t&&t.name),r.a.createElement("span",{className:"badge badge-pill badge-info"},t._id.slice(t._id.length-3))),delete t.image&&delete t.name&&delete t._id,r.a.createElement("div",{className:"card-body",style:{maxHeight:"200px",overflowY:"scroll"}},r.a.createElement("div",{className:"card-text"},r.a.createElement("ul",{className:"list-group list-group-flush"},t&&Object.keys(t).map(function(e,a){return r.a.createElement("li",{key:a,className:"list-group-item"},e,":"," ",t[e]&&t[e].name||t[e])})))))))},j=a(22),C=a.n(j),O=function(){return r.a.createElement("div",{className:"card mb-3"},r.a.createElement("div",{className:"row no-gutters"},r.a.createElement("div",{className:"col-md-5"},r.a.createElement("img",{style:{maxHeight:"300px",maxWidth:"300px"},src:C.a&&C.a,className:"card-img p-4 my-5",alt:"loading..."})),r.a.createElement("div",{className:"col-md-7 p-3"},r.a.createElement("h5",{className:"card-title d-flex justify-content-between mb-0"},r.a.createElement("u",null,"The Rick and Morty Encyclop\xe6dia")),r.a.createElement("div",{className:"card-body",style:{maxHeight:"200px",overflowY:"scroll"}},r.a.createElement("div",{className:"card-text"},"Have fun trying to find the 493 characters available from the R&M verse in this amazing and informative web app powered by the Rick and Morty API. Click on the button to get started.")))))},_=function(e){var t=e.onClick,a=e.client;return r.a.createElement("button",{onClick:function(){return t(a)},type:"button",className:"btn btn-info"},"NEW CHARACTER")},H=function(e){function t(){var e,a;Object(g.a)(this,t);for(var n=arguments.length,c=new Array(n),l=0;l<n;l++)c[l]=arguments[l];return(a=Object(b.a)(this,(e=Object(f.a)(t)).call.apply(e,[this].concat(c)))).state={seen:new Map,current:{}},a.handleCardUpdate=function(){var e=Object(p.a)(u.a.mark(function e(t){var n,r,c,l,i;return u.a.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return n=new Map(a.state.seen),e.next=3,t.query({query:N,variables:{_id:""},fetchPolicy:"network-only"});case 3:if(r=e.sent,c=r.data.character,l=c._id,!n.has(l)){e.next=9;break}return i=n.get(l),e.abrupt("return",a.setState({current:i}));case 9:return n.set(c._id.toString(),c),e.abrupt("return",a.setState({seen:n,current:c}));case 11:case"end":return e.stop()}},e)}));return function(t){return e.apply(this,arguments)}}(),a.handleCardSelect=function(e){var t=a.state.seen,n=Object(o.a)({},t.get(e.toString()));return a.setState({current:n})},a.handleSeenCardsRender=function(e){return r.a.createElement(r.a.Fragment,null,r.a.createElement("h6",null,"Have you seen them all?"," ",r.a.createElement("span",{role:"img","aria-label":"eyes"},"\ud83d\udc40")),r.a.createElement(w,{seen:e,onClick:a.handleCardSelect}))},a}return Object(E.a)(t,e),Object(h.a)(t,[{key:"render",value:function(){var e=this,t=this.state,a=t.current,n=t.seen;return r.a.createElement(m.a,null,function(t){return r.a.createElement("div",{className:"App"},r.a.createElement("div",{className:"container"},r.a.createElement("div",{className:"row"},r.a.createElement("div",{className:"col-5"},e.handleSeenCardsRender(n)),r.a.createElement("div",{className:"col-7"},0===Object.keys(a).length&&r.a.createElement(O,null),Object.keys(a).length>0&&r.a.createElement(k,{character:a||{}}),r.a.createElement(_,{onClick:e.handleCardUpdate,client:t})))))})}}]),t}(n.Component),S=new i.a({uri:"https://cors-anywhere.herokuapp.com/http://174.138.41.192:4000/graphql",cache:new s.a({addTypename:!1})});l.a.render(r.a.createElement(m.b,{client:S},r.a.createElement(H,null)),document.getElementById("root"))}},[[39,1,2]]]);
  //# sourceMappingURL=main.388b6b7a.chunk.js.map