text: (this.webpackJsonptodos=this.webpackJsonptodos||[]).push([[0],{20:function(e,t,n){},22:function(e,t,n){},27:function(e,t,n){"use strict";n.r(t);var o=n(0),a=n.n(o),i=n(14),c=n.n(i),s=(n(20),n(15)),r=n(10),l=n(8),d=n.n(l),f=(n(22),n(29)),h=n(30),u=n.p+"static/media/task.18a72958.png",g=n(5);var j=function(){var e=Object(o.useState)(""),t=Object(r.a)(e,2),n=t[0],a=t[1],i=Object(o.useState)([]),c=Object(r.a)(i,2),l=c[0],j=c[1],m=Object(o.useState)(!1),b=Object(r.a)(m,2),v=b[0],w=b[1];Object(o.useEffect)((function(){x()}),[]);var x=function(){var e=localStorage.getItem("todo"),t=JSON.parse(e),n=t&&0!==t.length?t.reverse():[];j(n)};return Object(g.jsx)("div",{className:"app",children:Object(g.jsxs)("div",{className:"web",children:[Object(g.jsx)("div",{className:"p-4 fixed-top bg",children:Object(g.jsxs)(f.a,{className:"d-flex w-100",children:[Object(g.jsx)(f.a.Control,{className:"search w-75",placeholder:"Add your tasks here...",onChange:function(e){a(e.target.value),w(!1)},maxLength:"30"}),Object(g.jsx)(h.a,{variant:"light",size:"sm",onClick:function(){if(0!==n.length){var e=JSON.parse(localStorage.getItem("todo"))||[],t={text:n.trim(),key:d()().unix()},o=[].concat(Object(s.a)(e),[t]);localStorage.setItem("todo",JSON.stringify(o)),window.location.reload(!1)}else w(!0)},className:"w-25",children:"Submit"})]})}),Object(g.jsxs)("div",{className:"container list",children:[v?Object(g.jsx)("div",{class:"text-center font-weight-bold text-danger my-2",children:"Please add a task first."}):null,0!==l.length?l.map((function(e,t){return Object(g.jsxs)("div",{className:"d-flex justify-content-between align-items-center flex-wrap bg-white my-2 p-3",children:[Object(g.jsx)("h5",{className:"font-weight-bold",children:e.text}),Object(g.jsxs)("div",{className:"d-flex justify-content-end",children:[Object(g.jsx)("span",{children:d.a.unix(e.key).format("DD MMM, YYYY")}),Object(g.jsx)("span",{className:"mx-3",children:d.a.unix(e.key).format("hh:mm A")}),Object(g.jsx)("span",{onClick:function(){return function(e){var t=(JSON.parse(localStorage.getItem("todo"))||[]).filter((function(t){return t.key!==e}));localStorage.setItem("todo",JSON.stringify(t)),window.location.reload(!1)}(e.key)},className:"mr-4",children:"Delete"})]})]},e.key)})):Object(g.jsx)("div",{className:"d-flex flex-column justify-content-center align-items-center",children:Object(g.jsx)("img",{src:u,className:"w-50 h-50 mt-5",alt:"No tasks found."})}),0!==l.length?Object(g.jsxs)("h5",{className:"fixed-bottom p-5",children:["#",l.length," task(s) pending"]}):null]}),Object(g.jsx)("div",{className:"d-flex list justify-content-center align-items-center",children:Object(g.jsx)("p",{className:"font-weight-bold mob",children:"This site is available for desktop view only."})})]})})},m=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 b(e,t){navigator.serviceWorker.register(e).then((function(e){e.onupdatefound=function(){var n=e.installing;null!=n&&(n.onstatechange=function(){"installed"===n.state&&(navigator.serviceWorker.controller?(console.log("New content is available and will be used when all tabs for this page are closed. See https://cra.link/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)}))}var v=function(e){e&&e instanceof Function&&n.e(3).then(n.bind(null,31)).then((function(t){var n=t.getCLS,o=t.getFID,a=t.getFCP,i=t.getLCP,c=t.getTTFB;n(e),o(e),a(e),i(e),c(e)}))};c.a.render(Object(g.jsx)(a.a.StrictMode,{children:Object(g.jsx)(j,{})}),document.getElementById("root")),function(e){if("serviceWorker"in navigator){if(new URL("/todos",window.location.href).origin!==window.location.origin)return;window.addEventListener("load",(function(){var t="".concat("/todos","/service-worker.js");m?(!function(e,t){fetch(e,{headers:{"Service-Worker":"script"}}).then((function(n){var o=n.headers.get("content-type");404===n.status||null!=o&&-1===o.indexOf("javascript")?navigator.serviceWorker.ready.then((function(e){e.unregister().then((function(){window.location.reload()}))})):b(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://cra.link/PWA")}))):b(t,e)}))}}(),v()}},[[27,1,2]]]);
  //# sourceMappingURL=main.dbb40f9e.chunk.js.map