text: (window["webpackJsonpgithub-issues-react-example"]=window["webpackJsonpgithub-issues-react-example"]||[]).push([[0],{17:function(e,t,a){e.exports=a(31)},22:function(e,t,a){},30:function(e,t,a){},31:function(e,t,a){"use strict";a.r(t);var n=a(0),r=a.n(n),s=a(14),i=a.n(s),o=(a(22),a(5)),c=a(6),l=a(8),u=a(7),p=a(2),h=a(9),m=a(11),d=a(3),g=a(4),f=new(a(28).Converter)({tables:!0,strikethrough:!0,ghCompatibleHeaderId:!0,literalMidWordUnderscores:!0,ghCodeBlocks:!0,tasklists:!0,ghMentions:!0,ghMentionsLink:"https://github.com/{u}"}),b=function(e){var t=e.data;return r.a.createElement("span",{className:t.comments<1?"is-hidden":"fa-layers  fa-lg comments"},r.a.createElement(g.a,{icon:d.d,transform:"down-2 left-2"},"1"),r.a.createElement("span",{className:"fa-layers-counter fa-2x",transform:"up-5",style:{background:"LightGrey",color:"black"}},t.comments<0?"":t.comments))};function v(e,t){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),a.push.apply(a,n)}return a}var E=function(e){return e.replace(/\w\S*/g,function(e){return e.charAt(0).toUpperCase()+e.substr(1).toLowerCase()})};function y(e){return function(t){return function(e){for(var t=1;t<arguments.length;t++){var a=null!=arguments[t]?arguments[t]:{};t%2?v(a,!0).forEach(function(t){Object(m.a)(e,t,a[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):v(a).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(a,t))})}return e}({},t,{modal:e})}}var w=function(e){var t=e.buttonArray,a=e.filterType,n=e.clickFunction,s=e.listFilter;return r.a.createElement("div",{className:"buttons has-addons",onClick:n},t.map(function(e,t){return r.a.createElement("span",{key:t,"data-choice":e,"data-list-filter":a,className:"button "+(s[a]===e?"is-selected is-active is-info":"")},E(e))}))},k=function(e){function t(e){var a;return Object(o.a)(this,t),(a=Object(l.a)(this,Object(u.a)(t).call(this,e))).state={avatar:"https://github.githubassets.com/images/icons/emoji/octocat.png",modal:""},a.handleFilter=a.handleFilter.bind(Object(p.a)(a)),a.handleRepo=a.handleRepo.bind(Object(p.a)(a)),a.getAvatar=a.getAvatar.bind(Object(p.a)(a)),a.showModal=a.showModal.bind(Object(p.a)(a)),a.renderModal=a.renderModal.bind(Object(p.a)(a)),a}return Object(h.a)(t,e),Object(c.a)(t,[{key:"componentDidMount",value:function(){this.getAvatar()}},{key:"shouldComponentUpdate",value:function(e,t){return e.listFilter!==this.props.listFilter||(e.user!==this.props.user||(t.avatar!==this.state.avatar||t.modal!==this.state.modal))}},{key:"getAvatar",value:function(e,t,a){var n=this,r="https://api.github.com/repos",s=e?"".concat(r,"/").concat(t,"/").concat(a):"".concat(r,"/").concat(this.props.user,"/").concat(this.props.repo);fetch(s,{headers:{Authorization:"token 60e07ff280c786e523a632be9af8f992270a5c5b",Accept:"application/vnd.github.v3+json,application/vnd.github.machine-man-preview+json"}}).then(function(e){if(e.ok)return e.json();throw new Error("Request failed.")}).then(function(e){n.setState({avatar:e.owner.avatar_url,modal:""})})}},{key:"handleFilter",value:function(e){e.preventDefault();var t=e.target.dataset.choice,a={};a[e.target.dataset.listFilter]=t,this.props.onFilterChange(a)}},{key:"handleRepo",value:function(e){e.preventDefault(),console.log(e.target),console.log(this.user.value+" - "+this.repo.value),this.getAvatar(!0,this.user.value,this.repo.value),this.props.onRepoChange(this.user.value,this.repo.value)}},{key:"showModal",value:function(e){e.preventDefault(),console.log(e),!0!==this.state.modal?this.setState(y(!0)):this.setState(y(!1))}},{key:"renderModal",value:function(){var e=this;return r.a.createElement("div",{class:"modal "+(!0===this.state.modal?"is-active":"")},r.a.createElement("div",{class:"modal-background"}),r.a.createElement("div",{class:"modal-content"},r.a.createElement("form",null,r.a.createElement("div",{class:"field"},r.a.createElement("label",{class:"label is-large has-text-white"},"Github User"),r.a.createElement("div",{class:"control"},r.a.createElement("input",{class:"input is-large",type:"text",placeholder:"facebook",ref:function(t){return e.user=t},name:"user"}))),r.a.createElement("div",{class:"field"},r.a.createElement("label",{class:"label is-large has-text-white"},"Repository Name"),r.a.createElement("div",{class:"control"},r.a.createElement("input",{class:"input is-large",type:"text",placeholder:"react",ref:function(t){return e.repo=t},name:"repo"}))),r.a.createElement("button",{class:"button is-link is-large is-fullwidth",onClick:this.handleRepo},"Enter"))),r.a.createElement("button",{class:"modal-close is-large","aria-label":"close",onClick:this.showModal}))}},{key:"render",value:function(){var e=new Date(this.props.since),t=new Date(e.getTime()-6e4*e.getTimezoneOffset()).toISOString().split("T")[0],a=this.props.listFilter,n=a.state,s=a.choice,i="".concat(E(n)," ").concat("all"===s?"issues/PRs":s," since ").concat(t);return r.a.createElement("nav",{className:"navbar is-fixed-top navbar-center panel-heading",role:"navigation"},r.a.createElement("div",{className:"navbar-brand navbar-center "},r.a.createElement("span",{className:"navbar-item"},r.a.createElement("span",{className:"img-label-container is-unselectable",onClick:this.showModal},r.a.createElement("img",{src:this.state.avatar,alt:"".concat(this.props.user,"/").concat(this.props.repo),width:"28px",height:"28px"}),r.a.createElement("p",null,this.props.repo))),r.a.createElement("span",{className:"navbar-item "},r.a.createElement("p",{className:"is-unselectable is-mobile  title-string"},i)),r.a.createElement("span",{role:"button",className:"navbar-burger burger","aria-label":"menu","aria-expanded":"false","data-target":"navbarBasicExample"},r.a.createElement("span",{"aria-hidden":"true"}),r.a.createElement("span",{"aria-hidden":"true"}),r.a.createElement("span",{"aria-hidden":"true"}))),this.renderModal(),r.a.createElement("div",{className:"navbar-center"},r.a.createElement("div",{id:"navbarBasicExample",className:"navbar-menu navbar-center"},r.a.createElement("span",{className:"navbar-item "},r.a.createElement(w,{buttonArray:["issues","pull requests","all"],filterType:"choice",clickFunction:this.handleFilter,listFilter:this.props.listFilter})),r.a.createElement("span",{className:"navbar-item"},r.a.createElement(w,{buttonArray:["open","closed","all"],filterType:"state",clickFunction:this.handleFilter,listFilter:this.props.listFilter})))))}}]),t}(r.a.Component),O=function(e,t){return t=t||2,(new Array(t).join("0")+e).slice(-t)},N=function(e,t){if(0===e.indexOf("#")&&(e=e.slice(1)),3===e.length&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),6!==e.length)throw new Error("Invalid HEX color.");var a=parseInt(e.slice(0,2),16),n=parseInt(e.slice(2,4),16),r=parseInt(e.slice(4,6),16);return t?.299*a+.587*n+.114*r>186?"#000000":"#FFFFFF":(a=(255-a).toString(16),n=(255-n).toString(16),r=(255-r).toString(16),"#"+O(a)+O(n)+O(r))},j=function(e){var t=e.labels,a=t.map(function(e,a){return r.a.createElement("span",{key:a,style:{backgroundColor:"#"+e.color,color:N("#"+e.color,!0)},className:"tag "+(0===t.length?"is-hidden":"")},e.name)});return r.a.createElement(r.a.Fragment,null,a)},C=a(16),F=function(e){var t=e.milestone,a=e._addclass;return r.a.createElement("span",{className:t?"milestone "+(a?Object(C.a)(a):""):"is-hidden"},r.a.createElement(g.a,{icon:d.g,className:"fa-lg"})," ",t?t.title:"")},P=a(15),S=function(e){function t(){return Object(o.a)(this,t),Object(l.a)(this,Object(u.a)(t).apply(this,arguments))}return Object(h.a)(t,e),Object(c.a)(t,[{key:"render",value:function(){return r.a.createElement(P.a,{onSwipedLeft:this.props.onSwipingLeft,onSwipedRight:this.props.onSwipingRight},this.props.children)}}]),t}(r.a.Component),R=function(e){function t(e){var a;return Object(o.a)(this,t),(a=Object(l.a)(this,Object(u.a)(t).call(this,e))).sendPageNumber=a.sendPageNumber.bind(Object(p.a)(a)),a.swipingLeft=a.swipingLeft.bind(Object(p.a)(a)),a.swipingRight=a.swipingRight.bind(Object(p.a)(a)),a}return Object(h.a)(t,e),Object(c.a)(t,[{key:"sendPageNumber",value:function(e){this.props.onPageChange("".concat(e.currentTarget.dataset.url))}},{key:"swipingLeft",value:function(e,t){var a=this.props.pages.last?this.props.pages.last.split("=").pop():this.props.pages.prev?+this.props.pages.prev.split("=").pop()+1:1;this.props.currentPageNumber<a&&this.props.onPageChange("&page=".concat(this.props.currentPageNumber+1))}},{key:"swipingRight",value:function(e,t){this.props.currentPageNumber>1&&this.props.onPageChange("&page=".concat(this.props.currentPageNumber-1))}},{key:"render",value:function(){var e=this,t=this.props.pages,a=this.props.currentPageNumber,n=t.last?t.last.split("=").pop():t.prev?+t.prev.split("=").pop()+1:1,s=Array.apply(null,{length:n}).map(Number.call,Number).map(function(e){return"&page=".concat(e+1)});return r.a.createElement(S,{onSwipingLeft:this.swipingLeft,onSwipingRight:this.swipingRight},r.a.createElement("nav",{className:"pagination is-medium is-centered",role:"navigation","aria-label":"pagination"},r.a.createElement("button",{className:"pagination-previous "+(a>1?"":" is-invisible"),"data-url":"&page=".concat(a-1),onClick:this.sendPageNumber},"\u25c4\u25c4"),r.a.createElement("button",{className:"pagination-link is-hidden-tablet"},"".concat(a,"/").concat(n)),r.a.createElement("button",{className:"pagination-next "+(a<n?"":" is-invisible"),"data-url":"&page=".concat(a+1),onClick:this.sendPageNumber},"\u25ba\u25ba"),r.a.createElement("ul",{className:"pagination-list"},s.map(function(t,n){var s=+t.split("=").pop();return r.a.createElement("li",{key:n,className:"is-hidden-mobile"},r.a.createElement("button",{"data-url":t,onClick:e.sendPageNumber,className:"pagination-link "+(s===a?" is-current":s),"aria-label":"Goto page "+s},s))}))))}}]),t}(r.a.Component),x=function(e){var t=e.state;return r.a.createElement("span",{className:"fa-layers fa-fw fa-2x"},r.a.createElement(g.a,{icon:d.b,color:t}),r.a.createElement(g.a,{className:"fa-inverse",icon:d.e,color:t,transform:"shrink-2"}),"red"===t&&r.a.createElement(g.a,{icon:d.a,color:t,transform:"shrink-10 right-5 up-4"}))},A=function(e){var t=e.state;return r.a.createElement("span",{className:"fa-layers fa-fw fa-2x"},r.a.createElement(g.a,{icon:d.c,color:t,transform:"shrink-4"}),"red"===t?r.a.createElement(g.a,{icon:d.a,color:t,transform:"shrink-8 right-4 down-4"}):"")},D=function(e){var t=e.type,a="closed"===e.state?"red":"green";return t?r.a.createElement(x,{state:a,type:t}):r.a.createElement(A,{state:a,type:t})},I=function(e){var t=Date.now()-e,a=function(e,a){var n=Math.round(t/e);return"".concat(n," ").concat(a).concat(n>1?"s":""," ago")};return t<6e4?a(1e3,"second"):t<36e5?a(6e4,"minute"):t<864e5?a(36e5,"hour"):t<2592e6?a(864e5,"day"):t<31536e6?a(2592e6,"month"):a(31536e6,"year")},L=function(e){var t=e.data,a=I(new Date(t.created_at)),n=I(new Date(t.updated_at)),s=t.user.login,i=a!==n?"#".concat(t.number," created ").concat(a," (updated ").concat(n,")"):"#".concat(t.number," created ").concat(a),o="".concat(i," by ").concat(s),c="".concat(t.assignees.length>0?" ---  Assigned to: ".concat(t.assignees.map(function(e){return" "+e.login})):"");return r.a.createElement(r.a.Fragment,null,o+c)};a(29),a(30);function M(e,t){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),a.push.apply(a,n)}return a}function _(e){for(var t=1;t<arguments.length;t++){var a=null!=arguments[t]?arguments[t]:{};t%2?M(a,!0).forEach(function(t){Object(m.a)(e,t,a[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):M(a).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(a,t))})}return e}var B={headers:{Authorization:"token 60e07ff280c786e523a632be9af8f992270a5c5b",Accept:"application/vnd.github.v3+json,application/vnd.github.machine-man-preview+json"}},T=function(e){function t(e){var a;return Object(o.a)(this,t),(a=Object(l.a)(this,Object(u.a)(t).call(this,e))).state={user:"",repo:"",listFilter:{state:"open",choice:"issues"},since:new Date(Date.now()-6048e5).toISOString(),per_page:40,sort:"created",page:"",currentPageNumber:1,pages:{},issues:[],loading:!0,error:null,showBody:{}},a.getIssues=a.getIssues.bind(Object(p.a)(a)),a.handleRepoChange=a.handleRepoChange.bind(Object(p.a)(a)),a.handlePageChange=a.handlePageChange.bind(Object(p.a)(a)),a.handleFilterChange=a.handleFilterChange.bind(Object(p.a)(a)),a}return Object(h.a)(t,e),Object(c.a)(t,[{key:"componentWillMount",value:function(){this.setState({user:this.props.user,repo:this.props.repo})}},{key:"componentDidMount",value:function(){var e=Array.prototype.slice.call(document.querySelectorAll(".navbar-burger"),0);e.length>0&&e.forEach(function(e){e.addEventListener("click",function(){var t=e.dataset.target,a=document.getElementById(t);e.classList.toggle("is-active"),a.classList.toggle("is-active")})}),this.getIssues()}},{key:"shouldComponentUpdate",value:function(e,t){return e.page!==t.page||e.listFilter!==t.listFilter}},{key:"getIssues",value:function(){var e=this,t=new Date(Date.now()-6048e5).toISOString(),a=function(e){var t=Object.keys(e);return t.length?"?"+t.map(function(t){return encodeURIComponent(t)+"="+encodeURIComponent(e[t])}).join("&"):""}({state:this.state.listFilter.state,since:t,per_page:40,sort:"created"}),n="",r="".concat(this.state.user,"/").concat(this.state.repo,"/issues"),s="".concat("https://api.github.com/repos","/").concat(r).concat(a).concat(this.state.page);fetch(s,B).then(function(e){if(e.headers.get("Link")&&(n=function(e){if(0===e.length)throw new Error("input must not be of zero length");return e.split(/(?!\B"[^"]*),(?![^"]*"\B)/).reduce(function(e,t){var a=t.split(/(?!\B"[^"]*);(?![^"]*"\B)/);if(a.length<2)throw new Error("section could not be split on ';'");var n=a[0].replace(/<(.*)>/,"$1").trim();return e[a[1].replace(/rel="(.*)"/,"$1").trim()]=n,e},{})}(e.headers.get("Link"))),e.ok)return e.json();throw new Error("Request failed.")}).then(function(t){e.setState({pages:n,issues:t,loading:!1,error:null,showBody:{}})}).catch(function(t){e.setState({loading:!1,error:t})})}},{key:"renderLoading",value:function(){return r.a.createElement("progress",{className:"progress is-large is-dark",max:"100"})}},{key:"renderError",value:function(){return r.a.createElement("div",null,"Uh oh: ",this.state.error.message)}},{key:"handlePageChange",value:function(e){var t=this;this.setState(function(e){return function(t){return _({},t,{page:e,currentPageNumber:+e.split("=").pop(),loading:!0})}}(e),function(){t.getIssues()})}},{key:"handleFilterChange",value:function(e){var t,a=this,n=_({},this.state.listFilter,{},e);this.setState((t=n,function(e){var a=e.listFilter.state!==t.state;return _({},e,{listFilter:t,loading:a})}),function(){"state"===Object.keys(e)[0]&&a.getIssues()})}},{key:"handleRepoChange",value:function(e,t){var a=this;this.setState(function(e,t){return function(a){return _({},a,{user:e,repo:t,loading:!0})}}(e,t),function(){a.getIssues()})}},{key:"renderIssues",value:function(){var e=this;if(this.state.error)return this.renderError();var t=function(t){t.preventDefault();var a={},n=t.currentTarget.dataset.id;a["_"+n]=!0!==e.state.showBody["_"+n],e.setState({showBody:a}),a["_"+n]&&e.state.issues.map(function(e){return e.id!==+n||(document.querySelector("._".concat(n)).innerHTML=f.makeHtml(e.body))})},a=function(t){var a=t?"issues":"pull requests";return e.state.listFilter.choice!==(a||"all")?" ":" is-hidden"};return r.a.createElement(r.a.Fragment,null,this.state.issues.map(function(n,s){return r.a.createElement("a",{href:"#",key:s,className:"panel-block"+a(n.pull_request)},r.a.createElement("span",{"data-id":n.id,className:"panel-ovr",onClick:t},r.a.createElement("span",{className:"columns is-mobile is-multiline is-vcentered is-2"},r.a.createElement("span",{className:" column is-1"},r.a.createElement("span",{className:"panel-icon icon is-small"},r.a.createElement(D,{type:!n.pull_request,state:n.state}))),r.a.createElement("span",{className:"column is-11 info-container"},r.a.createElement("span",{className:"_title"},n.title),r.a.createElement("br",{className:"is-hidden-tablet"}),r.a.createElement("span",{className:"time is-hidden-tablet"},r.a.createElement(L,{data:n}),r.a.createElement(F,{milestone:n.milestone,_addclass:["is-hidden-mobile"]})),r.a.createElement("br",{className:"is-hidden-tablet"}),r.a.createElement(j,{labels:n.labels}),r.a.createElement("br",{className:"is-hidden-mobile"}),r.a.createElement("span",{className:"time is-hidden-mobile"},r.a.createElement(L,{data:n}),r.a.createElement(F,{milestone:n.milestone}),r.a.createElement(b,{data:n}))),r.a.createElement("span",{className:"column show-body has-text-right is-pulled-right"},r.a.createElement(g.a,{icon:d.f})))),r.a.createElement("span",{className:"_"+n.id+(i=n.id,e.state.showBody["_"+i]?" container bodyContainer":" is-hidden")}));var i}))}},{key:"render",value:function(){return r.a.createElement("div",{className:"container"},r.a.createElement("nav",{className:"panel"},r.a.createElement(k,{listFilter:this.state.listFilter,onFilterChange:this.handleFilterChange,onRepoChange:this.handleRepoChange,user:this.state.user,repo:this.state.repo,since:this.state.since}),this.state.loading?this.renderLoading():this.renderIssues(),r.a.createElement("nav",{className:"navbar  is-fixed-bottom is-transparent"},r.a.createElement("div",{className:"navbar-start",style:{flexGrow:1,justifyContent:"center"}},r.a.createElement("div",{className:"navbar-item"},r.a.createElement(R,{pages:this.state.pages,currentPageNumber:this.state.currentPageNumber,onPageChange:this.handlePageChange}))))))}}]),t}(r.a.Component);var U=function(){return r.a.createElement(r.a.Fragment,null,r.a.createElement("div",{className:"App"},r.a.createElement(T,{user:"facebook",repo:"react"})))},W=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 q(e,t){navigator.serviceWorker.register(e).then(function(e){e.onupdatefound=function(){var a=e.installing;null!=a&&(a.onstatechange=function(){"installed"===a.state&&(navigator.serviceWorker.controller?(console.log("New content is available and will be used when all tabs for this page are closed. See https://bit.ly/CRA-PWA."),t&&t.onUpdate&&t.onUpdate(e)):(console.log("Content is cached for offline use."),t&&t.onSuccess&&t.onSuccess(e)))})}}).catch(function(e){console.error("Error during service worker registration:",e)})}i.a.render(r.a.createElement(U,null),document.getElementById("root")),function(e){if("serviceWorker"in navigator){if(new URL("/github-issues-react-example",window.location.href).origin!==window.location.origin)return;window.addEventListener("load",function(){var t="".concat("/github-issues-react-example","/service-worker.js");W?(!function(e,t){fetch(e).then(function(a){var n=a.headers.get("content-type");404===a.status||null!=n&&-1===n.indexOf("javascript")?navigator.serviceWorker.ready.then(function(e){e.unregister().then(function(){window.location.reload()})}):q(e,t)}).catch(function(){console.log("No internet connection found. App is running in offline mode.")})}(t,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://bit.ly/CRA-PWA")})):q(t,e)})}}()}},[[17,1,2]]]);
  //# sourceMappingURL=main.d1b87034.chunk.js.map