diff --git a/assets/index-Cxl7xtx2.js b/assets/index-CBWwzU-c.js similarity index 99% rename from assets/index-Cxl7xtx2.js rename to assets/index-CBWwzU-c.js index f8af708..4f0f57b 100644 --- a/assets/index-Cxl7xtx2.js +++ b/assets/index-CBWwzU-c.js @@ -832,7 +832,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho * LICENSE.md file in the root directory of this source tree. * * @license MIT - */function ei(){return ei=Object.assign?Object.assign.bind():function(e){for(var t=1;t=0)&&(n[i]=e[i]);return n}function TE(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function AE(e,t){return e.button===0&&(!t||t==="_self")&&!TE(e)}const LE=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset","unstable_viewTransition"],DE=["aria-current","caseSensitive","className","end","style","to","unstable_viewTransition","children"],jE="6";try{window.__reactRouterVersion=jE}catch{}function ME(e,t){return qx({basename:t==null?void 0:t.basename,future:ei({},t==null?void 0:t.future,{v7_prependBasename:!0}),history:kx({window:t==null?void 0:t.window}),hydrationData:(t==null?void 0:t.hydrationData)||IE(),routes:e,mapRouteProperties:OE,window:t==null?void 0:t.window}).initialize()}function IE(){var e;let t=(e=window)==null?void 0:e.__staticRouterHydrationData;return t&&t.errors&&(t=ei({},t,{errors:zE(t.errors)})),t}function zE(e){if(!e)return null;let t=Object.entries(e),n={};for(let[r,i]of t)if(i&&i.__type==="RouteErrorResponse")n[r]=new Pf(i.status,i.statusText,i.data,i.internal===!0);else if(i&&i.__type==="Error"){if(i.__subType){let a=window[i.__subType];if(typeof a=="function")try{let o=new a(i.message);o.stack="",n[r]=o}catch{}}if(n[r]==null){let a=new Error(i.message);a.stack="",n[r]=a}}else n[r]=i;return n}const Ky=R.createContext({isTransitioning:!1}),FE=R.createContext(new Map),UE="startTransition",th=Is[UE],$E="flushSync",nh=lw[$E];function BE(e){th?th(e):e()}function Pi(e){nh?nh(e):e()}class HE{constructor(){this.status="pending",this.promise=new Promise((t,n)=>{this.resolve=r=>{this.status==="pending"&&(this.status="resolved",t(r))},this.reject=r=>{this.status==="pending"&&(this.status="rejected",n(r))}})}}function WE(e){let{fallbackElement:t,router:n,future:r}=e,[i,a]=R.useState(n.state),[o,l]=R.useState(),[s,u]=R.useState({isTransitioning:!1}),[c,f]=R.useState(),[d,g]=R.useState(),[v,y]=R.useState(),S=R.useRef(new Map),{v7_startTransition:h}=r||{},p=R.useCallback(C=>{h?BE(C):C()},[h]),m=R.useCallback((C,N)=>{let{deletedFetchers:L,unstable_flushSync:F,unstable_viewTransitionOpts:G}=N;L.forEach(Ee=>S.current.delete(Ee)),C.fetchers.forEach((Ee,ft)=>{Ee.data!==void 0&&S.current.set(ft,Ee.data)});let Ce=n.window==null||typeof n.window.document.startViewTransition!="function";if(!G||Ce){F?Pi(()=>a(C)):p(()=>a(C));return}if(F){Pi(()=>{d&&(c&&c.resolve(),d.skipTransition()),u({isTransitioning:!0,flushSync:!0,currentLocation:G.currentLocation,nextLocation:G.nextLocation})});let Ee=n.window.document.startViewTransition(()=>{Pi(()=>a(C))});Ee.finished.finally(()=>{Pi(()=>{f(void 0),g(void 0),l(void 0),u({isTransitioning:!1})})}),Pi(()=>g(Ee));return}d?(c&&c.resolve(),d.skipTransition(),y({state:C,currentLocation:G.currentLocation,nextLocation:G.nextLocation})):(l(C),u({isTransitioning:!0,flushSync:!1,currentLocation:G.currentLocation,nextLocation:G.nextLocation}))},[n.window,d,c,S,p]);R.useLayoutEffect(()=>n.subscribe(m),[n,m]),R.useEffect(()=>{s.isTransitioning&&!s.flushSync&&f(new HE)},[s]),R.useEffect(()=>{if(c&&o&&n.window){let C=o,N=c.promise,L=n.window.document.startViewTransition(async()=>{p(()=>a(C)),await N});L.finished.finally(()=>{f(void 0),g(void 0),l(void 0),u({isTransitioning:!1})}),g(L)}},[p,o,c,n.window]),R.useEffect(()=>{c&&o&&i.location.key===o.location.key&&c.resolve()},[c,d,i.location,o]),R.useEffect(()=>{!s.isTransitioning&&v&&(l(v.state),u({isTransitioning:!0,flushSync:!1,currentLocation:v.currentLocation,nextLocation:v.nextLocation}),y(void 0))},[s.isTransitioning,v]),R.useEffect(()=>{},[]);let k=R.useMemo(()=>({createHref:n.createHref,encodeLocation:n.encodeLocation,go:C=>n.navigate(C),push:(C,N,L)=>n.navigate(C,{state:N,preventScrollReset:L==null?void 0:L.preventScrollReset}),replace:(C,N,L)=>n.navigate(C,{replace:!0,state:N,preventScrollReset:L==null?void 0:L.preventScrollReset})}),[n]),b=n.basename||"/",w=R.useMemo(()=>({router:n,navigator:k,static:!1,basename:b}),[n,k,b]);return R.createElement(R.Fragment,null,R.createElement(Ta.Provider,{value:w},R.createElement(Nf.Provider,{value:i},R.createElement(FE.Provider,{value:S.current},R.createElement(Ky.Provider,{value:s},R.createElement(NE,{basename:b,location:i.location,navigationType:i.historyAction,navigator:k,future:{v7_relativeSplatPath:n.future.v7_relativeSplatPath}},i.initialized||n.future.v7_partialHydration?R.createElement(VE,{routes:n.routes,future:n.future,state:i}):t))))),null)}function VE(e){let{routes:t,future:n,state:r}=e;return vE(t,void 0,r,n)}const YE=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",KE=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Of=R.forwardRef(function(t,n){let{onClick:r,relative:i,reloadDocument:a,replace:o,state:l,target:s,to:u,preventScrollReset:c,unstable_viewTransition:f}=t,d=Yy(t,LE),{basename:g}=R.useContext(Hn),v,y=!1;if(typeof u=="string"&&KE.test(u)&&(v=u,YE))try{let m=new URL(window.location.href),k=u.startsWith("//")?new URL(m.protocol+u):new URL(u),b=nn(k.pathname,g);k.origin===m.origin&&b!=null?u=b+k.search+k.hash:y=!0}catch{}let S=cE(u,{relative:i}),h=XE(u,{replace:o,state:l,target:s,preventScrollReset:c,relative:i,unstable_viewTransition:f});function p(m){r&&r(m),m.defaultPrevented||h(m)}return R.createElement("a",ei({},d,{href:v||S,onClick:y||a?r:p,ref:n,target:s}))}),QE=R.forwardRef(function(t,n){let{"aria-current":r="page",caseSensitive:i=!1,className:a="",end:o=!1,style:l,to:s,unstable_viewTransition:u,children:c}=t,f=Yy(t,DE),d=Il(s,{relative:f.relative}),g=La(),v=R.useContext(Nf),{navigator:y,basename:S}=R.useContext(Hn),h=v!=null&&qE(d)&&u===!0,p=y.encodeLocation?y.encodeLocation(d).pathname:d.pathname,m=g.pathname,k=v&&v.navigation&&v.navigation.location?v.navigation.location.pathname:null;i||(m=m.toLowerCase(),k=k?k.toLowerCase():null,p=p.toLowerCase()),k&&S&&(k=nn(k,S)||k);const b=p!=="/"&&p.endsWith("/")?p.length-1:p.length;let w=m===p||!o&&m.startsWith(p)&&m.charAt(b)==="/",C=k!=null&&(k===p||!o&&k.startsWith(p)&&k.charAt(p.length)==="/"),N={isActive:w,isPending:C,isTransitioning:h},L=w?r:void 0,F;typeof a=="function"?F=a(N):F=[a,w?"active":null,C?"pending":null,h?"transitioning":null].filter(Boolean).join(" ");let G=typeof l=="function"?l(N):l;return R.createElement(Of,ei({},f,{"aria-current":L,className:F,ref:n,style:G,to:s,unstable_viewTransition:u}),typeof c=="function"?c(N):c)});var tc;(function(e){e.UseScrollRestoration="useScrollRestoration",e.UseSubmit="useSubmit",e.UseSubmitFetcher="useSubmitFetcher",e.UseFetcher="useFetcher",e.useViewTransitionState="useViewTransitionState"})(tc||(tc={}));var rh;(function(e){e.UseFetcher="useFetcher",e.UseFetchers="useFetchers",e.UseScrollRestoration="useScrollRestoration"})(rh||(rh={}));function GE(e){let t=R.useContext(Ta);return t||Y(!1),t}function XE(e,t){let{target:n,replace:r,state:i,preventScrollReset:a,relative:o,unstable_viewTransition:l}=t===void 0?{}:t,s=fE(),u=La(),c=Il(e,{relative:o});return R.useCallback(f=>{if(AE(f,n)){f.preventDefault();let d=r!==void 0?r:fr(u)===fr(c);s(e,{replace:d,state:i,preventScrollReset:a,relative:o,unstable_viewTransition:l})}},[u,s,c,r,i,n,e,a,o,l])}function qE(e,t){t===void 0&&(t={});let n=R.useContext(Ky);n==null&&Y(!1);let{basename:r}=GE(tc.useViewTransitionState),i=Il(e,{relative:t.relative});if(!n.isTransitioning)return!1;let a=nn(n.currentLocation.pathname,r)||n.currentLocation.pathname,o=nn(n.nextLocation.pathname,r)||n.nextLocation.pathname;return qu(i.pathname,o)!=null||qu(i.pathname,a)!=null}const JE=({path:e,faIcon:t,name:n})=>T.jsxs(QE,{className:({isActive:r})=>r?"nav-link active-link":"nav-link",to:e,children:[T.jsx("div",{className:"icon-wrapper",children:T.jsx(si,{className:"icon",icon:t})}),n]}),ui=({children:e})=>T.jsx("div",{className:"route-page-layout",children:e}),ZE=40,e2=100,t2="Ex: War and Peace by Leo Tolstoy",n2=(e,t)=>{if(!e||e.length<=t)return e;const n=e.lastIndexOf(" ",t);return n===-1?e.slice(0,t).concat("..."):e.slice(0,n).concat("...")},ih=(e,t)=>e===void 0?`No ${t}.`:Array.isArray(e)?e.length>0?e.join(", "):`No ${t}.`:e,zl=({id:e,title:t,authors:n,publishedDate:r,description:i,averageRating:a,smallThumbnail:o})=>{const l=ih(t,"title"),s=ih(n,"authors"),u=r?new Date(r).getFullYear():"No published date.";let c=n2(i,e2);c=c===void 0?"No description.":c;const f=a?`${a} / 5.0`:"No ratings";return T.jsxs(Of,{id:`id-${e}`,className:"sb-card",to:`/books-wishlist-app/${e}`,children:[T.jsx("div",{className:"sb-thumbnail-wrapper",children:o?T.jsx("img",{src:o,className:"sb-thumbnail"}):"No image preview available."}),T.jsxs("div",{className:"sb-content",children:[T.jsx("h3",{className:"sb-title",children:l}),T.jsx("p",{className:"sb-author",children:s}),T.jsx("p",{className:"sb-description",children:c}),T.jsxs("div",{className:"sb-details",children:[T.jsx("p",{className:"sb-rating",children:f}),T.jsx("p",{className:"sb-published-date",children:u})]})]})]})},Fl=e=>{const t=e.volumeInfo,n=t!=null&&t.imageLinks?t.imageLinks.smallThumbnail:"";return{id:e.id,title:t==null?void 0:t.title,authors:t==null?void 0:t.authors,publishedDate:t==null?void 0:t.publishedDate,description:t==null?void 0:t.description,averageRating:t==null?void 0:t.averageRating,smallThumbnail:n}},r2=()=>{const[e,t]=R.useState([]);return R.useEffect(()=>{const n=localStorage.getItem("favourites"),r=n!==null?JSON.parse(n):[];(async()=>{const a=[];for(const o of r){const l=`https://www.googleapis.com/books/v1/volumes/${o}`,s=await ce.get(l);a.push(s.data)}t(a)})()},[]),T.jsxs(ui,{children:[T.jsx("h1",{className:"grand-title",children:"Your favourites"}),T.jsx("div",{className:"searched-books-grid",children:e.map(n=>{const r=Fl(n);return T.jsx(zl,{id:r.id,title:r.title,authors:r.authors,publishedDate:r.publishedDate,description:r.description,averageRating:r.averageRating,smallThumbnail:r.smallThumbnail},r.id)})})]})};var i2={prefix:"fas",iconName:"bookmark",icon:[384,512,[128278,61591],"f02e","M0 48V487.7C0 501.1 10.9 512 24.3 512c5 0 9.9-1.5 14-4.4L192 400 345.7 507.6c4.1 2.9 9 4.4 14 4.4c13.4 0 24.3-10.9 24.3-24.3V48c0-26.5-21.5-48-48-48H48C21.5 0 0 21.5 0 48z"]},a2={prefix:"fas",iconName:"star",icon:[576,512,[11088,61446],"f005","M316.9 18C311.6 7 300.4 0 288.1 0s-23.4 7-28.8 18L195 150.3 51.4 171.5c-12 1.8-22 10.2-25.7 21.7s-.7 24.2 7.9 32.7L137.8 329 113.2 474.7c-2 12 3 24.2 12.9 31.3s23 8 33.8 2.3l128.3-68.5 128.3 68.5c10.8 5.7 23.9 4.9 33.8-2.3s14.9-19.3 12.9-31.3L438.5 329 542.7 225.9c8.6-8.5 11.7-21.2 7.9-32.7s-13.7-19.9-25.7-21.7L381.2 150.3 316.9 18z"]},o2={prefix:"fas",iconName:"basket-shopping",icon:[576,512,["shopping-basket"],"f291","M253.3 35.1c6.1-11.8 1.5-26.3-10.2-32.4s-26.3-1.5-32.4 10.2L117.6 192H32c-17.7 0-32 14.3-32 32s14.3 32 32 32L83.9 463.5C91 492 116.6 512 146 512H430c29.4 0 55-20 62.1-48.5L544 256c17.7 0 32-14.3 32-32s-14.3-32-32-32H458.4L365.3 12.9C359.2 1.2 344.7-3.4 332.9 2.7s-16.3 20.6-10.2 32.4L404.3 192H171.7L253.3 35.1zM192 304v96c0 8.8-7.2 16-16 16s-16-7.2-16-16V304c0-8.8 7.2-16 16-16s16 7.2 16 16zm96-16c8.8 0 16 7.2 16 16v96c0 8.8-7.2 16-16 16s-16-7.2-16-16V304c0-8.8 7.2-16 16-16zm128 16v96c0 8.8-7.2 16-16 16s-16-7.2-16-16V304c0-8.8 7.2-16 16-16s16 7.2 16 16z"]},Qy={prefix:"fas",iconName:"magnifying-glass",icon:[512,512,[128269,"search"],"f002","M416 208c0 45.9-14.9 88.3-40 122.7L502.6 457.4c12.5 12.5 12.5 32.8 0 45.3s-32.8 12.5-45.3 0L330.7 376c-34.4 25.2-76.8 40-122.7 40C93.1 416 0 322.9 0 208S93.1 0 208 0S416 93.1 416 208zM208 352a144 144 0 1 0 0-288 144 144 0 1 0 0 288z"]};const l2=[{path:"/books-wishlist-app/search",faIcon:Qy,name:"Search books"},{path:"/books-wishlist-app/favourites",faIcon:a2,name:"Favourites"},{path:"/books-wishlist-app/toread",faIcon:o2,name:"To read"},{path:"/books-wishlist-app/read",faIcon:i2,name:"Read"}],s2=()=>T.jsxs("div",{className:"layout",children:[T.jsx("nav",{className:"navbar",children:l2.map(({path:e,faIcon:t,name:n},r)=>T.jsx(JE,{path:e,faIcon:t,name:n},r))}),T.jsx(RE,{})]}),u2=()=>{const[e,t]=R.useState([]);return R.useEffect(()=>{const n=localStorage.getItem("read"),r=n!==null?JSON.parse(n):[];(async()=>{const a=[];for(const o of r){const l=`https://www.googleapis.com/books/v1/volumes/${o}`,s=await ce.get(l);a.push(s.data)}t(a)})()},[]),T.jsxs(ui,{children:[T.jsx("h1",{className:"grand-title",children:"Your Read Books"}),T.jsx("div",{className:"searched-books-grid",children:e.map(n=>{const r=Fl(n);return T.jsx(zl,{id:r.id,title:r.title,authors:r.authors,publishedDate:r.publishedDate,description:r.description,averageRating:r.averageRating,smallThumbnail:r.smallThumbnail},r.id)})})]})};var Gy={exports:{}},Xy={};/** + */function ei(){return ei=Object.assign?Object.assign.bind():function(e){for(var t=1;t=0)&&(n[i]=e[i]);return n}function TE(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function AE(e,t){return e.button===0&&(!t||t==="_self")&&!TE(e)}const LE=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset","unstable_viewTransition"],DE=["aria-current","caseSensitive","className","end","style","to","unstable_viewTransition","children"],jE="6";try{window.__reactRouterVersion=jE}catch{}function ME(e,t){return qx({basename:t==null?void 0:t.basename,future:ei({},t==null?void 0:t.future,{v7_prependBasename:!0}),history:kx({window:t==null?void 0:t.window}),hydrationData:(t==null?void 0:t.hydrationData)||IE(),routes:e,mapRouteProperties:OE,window:t==null?void 0:t.window}).initialize()}function IE(){var e;let t=(e=window)==null?void 0:e.__staticRouterHydrationData;return t&&t.errors&&(t=ei({},t,{errors:zE(t.errors)})),t}function zE(e){if(!e)return null;let t=Object.entries(e),n={};for(let[r,i]of t)if(i&&i.__type==="RouteErrorResponse")n[r]=new Pf(i.status,i.statusText,i.data,i.internal===!0);else if(i&&i.__type==="Error"){if(i.__subType){let a=window[i.__subType];if(typeof a=="function")try{let o=new a(i.message);o.stack="",n[r]=o}catch{}}if(n[r]==null){let a=new Error(i.message);a.stack="",n[r]=a}}else n[r]=i;return n}const Ky=R.createContext({isTransitioning:!1}),FE=R.createContext(new Map),UE="startTransition",th=Is[UE],$E="flushSync",nh=lw[$E];function BE(e){th?th(e):e()}function Pi(e){nh?nh(e):e()}class HE{constructor(){this.status="pending",this.promise=new Promise((t,n)=>{this.resolve=r=>{this.status==="pending"&&(this.status="resolved",t(r))},this.reject=r=>{this.status==="pending"&&(this.status="rejected",n(r))}})}}function WE(e){let{fallbackElement:t,router:n,future:r}=e,[i,a]=R.useState(n.state),[o,l]=R.useState(),[s,u]=R.useState({isTransitioning:!1}),[c,f]=R.useState(),[d,g]=R.useState(),[v,y]=R.useState(),S=R.useRef(new Map),{v7_startTransition:h}=r||{},p=R.useCallback(C=>{h?BE(C):C()},[h]),m=R.useCallback((C,N)=>{let{deletedFetchers:L,unstable_flushSync:F,unstable_viewTransitionOpts:G}=N;L.forEach(Ee=>S.current.delete(Ee)),C.fetchers.forEach((Ee,ft)=>{Ee.data!==void 0&&S.current.set(ft,Ee.data)});let Ce=n.window==null||typeof n.window.document.startViewTransition!="function";if(!G||Ce){F?Pi(()=>a(C)):p(()=>a(C));return}if(F){Pi(()=>{d&&(c&&c.resolve(),d.skipTransition()),u({isTransitioning:!0,flushSync:!0,currentLocation:G.currentLocation,nextLocation:G.nextLocation})});let Ee=n.window.document.startViewTransition(()=>{Pi(()=>a(C))});Ee.finished.finally(()=>{Pi(()=>{f(void 0),g(void 0),l(void 0),u({isTransitioning:!1})})}),Pi(()=>g(Ee));return}d?(c&&c.resolve(),d.skipTransition(),y({state:C,currentLocation:G.currentLocation,nextLocation:G.nextLocation})):(l(C),u({isTransitioning:!0,flushSync:!1,currentLocation:G.currentLocation,nextLocation:G.nextLocation}))},[n.window,d,c,S,p]);R.useLayoutEffect(()=>n.subscribe(m),[n,m]),R.useEffect(()=>{s.isTransitioning&&!s.flushSync&&f(new HE)},[s]),R.useEffect(()=>{if(c&&o&&n.window){let C=o,N=c.promise,L=n.window.document.startViewTransition(async()=>{p(()=>a(C)),await N});L.finished.finally(()=>{f(void 0),g(void 0),l(void 0),u({isTransitioning:!1})}),g(L)}},[p,o,c,n.window]),R.useEffect(()=>{c&&o&&i.location.key===o.location.key&&c.resolve()},[c,d,i.location,o]),R.useEffect(()=>{!s.isTransitioning&&v&&(l(v.state),u({isTransitioning:!0,flushSync:!1,currentLocation:v.currentLocation,nextLocation:v.nextLocation}),y(void 0))},[s.isTransitioning,v]),R.useEffect(()=>{},[]);let k=R.useMemo(()=>({createHref:n.createHref,encodeLocation:n.encodeLocation,go:C=>n.navigate(C),push:(C,N,L)=>n.navigate(C,{state:N,preventScrollReset:L==null?void 0:L.preventScrollReset}),replace:(C,N,L)=>n.navigate(C,{replace:!0,state:N,preventScrollReset:L==null?void 0:L.preventScrollReset})}),[n]),b=n.basename||"/",w=R.useMemo(()=>({router:n,navigator:k,static:!1,basename:b}),[n,k,b]);return R.createElement(R.Fragment,null,R.createElement(Ta.Provider,{value:w},R.createElement(Nf.Provider,{value:i},R.createElement(FE.Provider,{value:S.current},R.createElement(Ky.Provider,{value:s},R.createElement(NE,{basename:b,location:i.location,navigationType:i.historyAction,navigator:k,future:{v7_relativeSplatPath:n.future.v7_relativeSplatPath}},i.initialized||n.future.v7_partialHydration?R.createElement(VE,{routes:n.routes,future:n.future,state:i}):t))))),null)}function VE(e){let{routes:t,future:n,state:r}=e;return vE(t,void 0,r,n)}const YE=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",KE=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Of=R.forwardRef(function(t,n){let{onClick:r,relative:i,reloadDocument:a,replace:o,state:l,target:s,to:u,preventScrollReset:c,unstable_viewTransition:f}=t,d=Yy(t,LE),{basename:g}=R.useContext(Hn),v,y=!1;if(typeof u=="string"&&KE.test(u)&&(v=u,YE))try{let m=new URL(window.location.href),k=u.startsWith("//")?new URL(m.protocol+u):new URL(u),b=nn(k.pathname,g);k.origin===m.origin&&b!=null?u=b+k.search+k.hash:y=!0}catch{}let S=cE(u,{relative:i}),h=XE(u,{replace:o,state:l,target:s,preventScrollReset:c,relative:i,unstable_viewTransition:f});function p(m){r&&r(m),m.defaultPrevented||h(m)}return R.createElement("a",ei({},d,{href:v||S,onClick:y||a?r:p,ref:n,target:s}))}),QE=R.forwardRef(function(t,n){let{"aria-current":r="page",caseSensitive:i=!1,className:a="",end:o=!1,style:l,to:s,unstable_viewTransition:u,children:c}=t,f=Yy(t,DE),d=Il(s,{relative:f.relative}),g=La(),v=R.useContext(Nf),{navigator:y,basename:S}=R.useContext(Hn),h=v!=null&&qE(d)&&u===!0,p=y.encodeLocation?y.encodeLocation(d).pathname:d.pathname,m=g.pathname,k=v&&v.navigation&&v.navigation.location?v.navigation.location.pathname:null;i||(m=m.toLowerCase(),k=k?k.toLowerCase():null,p=p.toLowerCase()),k&&S&&(k=nn(k,S)||k);const b=p!=="/"&&p.endsWith("/")?p.length-1:p.length;let w=m===p||!o&&m.startsWith(p)&&m.charAt(b)==="/",C=k!=null&&(k===p||!o&&k.startsWith(p)&&k.charAt(p.length)==="/"),N={isActive:w,isPending:C,isTransitioning:h},L=w?r:void 0,F;typeof a=="function"?F=a(N):F=[a,w?"active":null,C?"pending":null,h?"transitioning":null].filter(Boolean).join(" ");let G=typeof l=="function"?l(N):l;return R.createElement(Of,ei({},f,{"aria-current":L,className:F,ref:n,style:G,to:s,unstable_viewTransition:u}),typeof c=="function"?c(N):c)});var tc;(function(e){e.UseScrollRestoration="useScrollRestoration",e.UseSubmit="useSubmit",e.UseSubmitFetcher="useSubmitFetcher",e.UseFetcher="useFetcher",e.useViewTransitionState="useViewTransitionState"})(tc||(tc={}));var rh;(function(e){e.UseFetcher="useFetcher",e.UseFetchers="useFetchers",e.UseScrollRestoration="useScrollRestoration"})(rh||(rh={}));function GE(e){let t=R.useContext(Ta);return t||Y(!1),t}function XE(e,t){let{target:n,replace:r,state:i,preventScrollReset:a,relative:o,unstable_viewTransition:l}=t===void 0?{}:t,s=fE(),u=La(),c=Il(e,{relative:o});return R.useCallback(f=>{if(AE(f,n)){f.preventDefault();let d=r!==void 0?r:fr(u)===fr(c);s(e,{replace:d,state:i,preventScrollReset:a,relative:o,unstable_viewTransition:l})}},[u,s,c,r,i,n,e,a,o,l])}function qE(e,t){t===void 0&&(t={});let n=R.useContext(Ky);n==null&&Y(!1);let{basename:r}=GE(tc.useViewTransitionState),i=Il(e,{relative:t.relative});if(!n.isTransitioning)return!1;let a=nn(n.currentLocation.pathname,r)||n.currentLocation.pathname,o=nn(n.nextLocation.pathname,r)||n.nextLocation.pathname;return qu(i.pathname,o)!=null||qu(i.pathname,a)!=null}const JE=({path:e,faIcon:t,name:n})=>T.jsxs(QE,{className:({isActive:r})=>r?"nav-link active-link":"nav-link",to:e,children:[T.jsx("div",{className:"icon-wrapper",children:T.jsx(si,{className:"icon",icon:t})}),n]}),ui=({children:e})=>T.jsx("div",{className:"route-page-layout",children:e}),ZE=40,e2=100,t2="Ex: War and Peace by Leo Tolstoy",n2=(e,t)=>{if(!e||e.length<=t)return e;const n=e.lastIndexOf(" ",t);return n===-1?e.slice(0,t).concat("..."):e.slice(0,n).concat("...")},ih=(e,t)=>e===void 0?`No ${t}.`:Array.isArray(e)?e.length>0?e.join(", "):`No ${t}.`:e,zl=({id:e,title:t,authors:n,publishedDate:r,description:i,averageRating:a,smallThumbnail:o})=>{const l=ih(t,"title"),s=ih(n,"authors"),u=r?new Date(r).getFullYear():"No published date.";let c=n2(i,e2);c=c===void 0?"No description.":c;const f=a?`${a} / 5.0`:"No ratings";return T.jsxs(Of,{id:`id-${e}`,className:"sb-card",to:`/books-wishlist-app/${e}`,children:[T.jsx("div",{className:"sb-thumbnail-wrapper",children:o?T.jsx("img",{src:o,className:"sb-thumbnail"}):"No image preview available."}),T.jsxs("div",{className:"sb-content",children:[T.jsx("h3",{className:"sb-title",children:l}),T.jsx("p",{className:"sb-author",children:s}),T.jsx("p",{className:"sb-description",children:c}),T.jsxs("div",{className:"sb-details",children:[T.jsx("p",{className:"sb-rating",children:f}),T.jsx("p",{className:"sb-published-date",children:u})]})]})]})},Fl=e=>{const t=e.volumeInfo,n=t!=null&&t.imageLinks?t.imageLinks.smallThumbnail:"";return{id:e.id,title:t==null?void 0:t.title,authors:t==null?void 0:t.authors,publishedDate:t==null?void 0:t.publishedDate,description:t==null?void 0:t.description,averageRating:t==null?void 0:t.averageRating,smallThumbnail:n}},r2=()=>{const[e,t]=R.useState([]);return R.useEffect(()=>{const n=localStorage.getItem("favourites"),r=n!==null?JSON.parse(n):[];(async()=>{const a=[];for(const o of r){const l=`https://www.googleapis.com/books/v1/volumes/${o}`,s=await ce.get(l);a.push(s.data)}t(a)})()},[]),T.jsxs(ui,{children:[T.jsx("h1",{className:"grand-title",children:"Your favourites"}),T.jsx("div",{className:"searched-books-grid",children:e.map(n=>{const r=Fl(n);return T.jsx(zl,{id:r.id,title:r.title,authors:r.authors,publishedDate:r.publishedDate,description:r.description,averageRating:r.averageRating,smallThumbnail:r.smallThumbnail},r.id)})})]})};var i2={prefix:"fas",iconName:"bookmark",icon:[384,512,[128278,61591],"f02e","M0 48V487.7C0 501.1 10.9 512 24.3 512c5 0 9.9-1.5 14-4.4L192 400 345.7 507.6c4.1 2.9 9 4.4 14 4.4c13.4 0 24.3-10.9 24.3-24.3V48c0-26.5-21.5-48-48-48H48C21.5 0 0 21.5 0 48z"]},a2={prefix:"fas",iconName:"star",icon:[576,512,[11088,61446],"f005","M316.9 18C311.6 7 300.4 0 288.1 0s-23.4 7-28.8 18L195 150.3 51.4 171.5c-12 1.8-22 10.2-25.7 21.7s-.7 24.2 7.9 32.7L137.8 329 113.2 474.7c-2 12 3 24.2 12.9 31.3s23 8 33.8 2.3l128.3-68.5 128.3 68.5c10.8 5.7 23.9 4.9 33.8-2.3s14.9-19.3 12.9-31.3L438.5 329 542.7 225.9c8.6-8.5 11.7-21.2 7.9-32.7s-13.7-19.9-25.7-21.7L381.2 150.3 316.9 18z"]},o2={prefix:"fas",iconName:"basket-shopping",icon:[576,512,["shopping-basket"],"f291","M253.3 35.1c6.1-11.8 1.5-26.3-10.2-32.4s-26.3-1.5-32.4 10.2L117.6 192H32c-17.7 0-32 14.3-32 32s14.3 32 32 32L83.9 463.5C91 492 116.6 512 146 512H430c29.4 0 55-20 62.1-48.5L544 256c17.7 0 32-14.3 32-32s-14.3-32-32-32H458.4L365.3 12.9C359.2 1.2 344.7-3.4 332.9 2.7s-16.3 20.6-10.2 32.4L404.3 192H171.7L253.3 35.1zM192 304v96c0 8.8-7.2 16-16 16s-16-7.2-16-16V304c0-8.8 7.2-16 16-16s16 7.2 16 16zm96-16c8.8 0 16 7.2 16 16v96c0 8.8-7.2 16-16 16s-16-7.2-16-16V304c0-8.8 7.2-16 16-16zm128 16v96c0 8.8-7.2 16-16 16s-16-7.2-16-16V304c0-8.8 7.2-16 16-16s16 7.2 16 16z"]},Qy={prefix:"fas",iconName:"magnifying-glass",icon:[512,512,[128269,"search"],"f002","M416 208c0 45.9-14.9 88.3-40 122.7L502.6 457.4c12.5 12.5 12.5 32.8 0 45.3s-32.8 12.5-45.3 0L330.7 376c-34.4 25.2-76.8 40-122.7 40C93.1 416 0 322.9 0 208S93.1 0 208 0S416 93.1 416 208zM208 352a144 144 0 1 0 0-288 144 144 0 1 0 0 288z"]};const l2=[{path:"books-wishlist-app/search",faIcon:Qy,name:"Search books"},{path:"books-wishlist-app/favourites",faIcon:a2,name:"Favourites"},{path:"books-wishlist-app/toread",faIcon:o2,name:"To read"},{path:"books-wishlist-app/read",faIcon:i2,name:"Read"}],s2=()=>T.jsxs("div",{className:"layout",children:[T.jsx("nav",{className:"navbar",children:l2.map(({path:e,faIcon:t,name:n},r)=>T.jsx(JE,{path:e,faIcon:t,name:n},r))}),T.jsx(RE,{})]}),u2=()=>{const[e,t]=R.useState([]);return R.useEffect(()=>{const n=localStorage.getItem("read"),r=n!==null?JSON.parse(n):[];(async()=>{const a=[];for(const o of r){const l=`https://www.googleapis.com/books/v1/volumes/${o}`,s=await ce.get(l);a.push(s.data)}t(a)})()},[]),T.jsxs(ui,{children:[T.jsx("h1",{className:"grand-title",children:"Your Read Books"}),T.jsx("div",{className:"searched-books-grid",children:e.map(n=>{const r=Fl(n);return T.jsx(zl,{id:r.id,title:r.title,authors:r.authors,publishedDate:r.publishedDate,description:r.description,averageRating:r.averageRating,smallThumbnail:r.smallThumbnail},r.id)})})]})};var Gy={exports:{}},Xy={};/** * @license React * use-sync-external-store-with-selector.production.min.js * diff --git a/index.html b/index.html index 2bc25bf..bfce94f 100644 --- a/index.html +++ b/index.html @@ -5,7 +5,7 @@ Books Wishlist - +