1import{j as e}from"./vendor-ui-CmKBJFmb.js";import{i as H,d as I,r as k}from"./vendor-react-DmLZEbX8.js";import{c as Q,l as T,k as G,g as $,O as q,Q as Y,y as O,R as V,T as W,V as Z,W as J,p as K,B as i,Y as X,Z as ee,M as r,D as se,f as o,_ as ae,U as te,P as ie,H as re,$ as c,h as w,i as y,a0 as ne}from"./index-D1cVJMhq.js";import{B as le}from"./badge-DPfDi_e3.js";import{S as u}from"./star-D6g-fh5F.js";import{C as oe}from"./clock-B-ZZpgIz.js";import{S as ce}from"./shopping-cart-BXUtBYQy.js";import{E as _}from"./external-link-gh4X9kwT.js";import"./vendor-query-X56ZNOSG.js";import"./vendor-supabase-CUHO7gZf.js";/** 2 * @license lucide-react v0.462.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const de=Q("ListPlus",[["path",{d:"M11 12H3",key:"51ecnj"}],["path",{d:"M16 6H3",key:"1wxfjs"}],["path",{d:"M16 18H3",key:"12xzn7"}],["path",{d:"M18 9v6",key:"1twb98"}],["path",{d:"M21 12h-6",key:"bt1uis"}]]);function ke(){const{id:l}=H(),d=I(),{play:C,addToQueue:P,queue:B}=T();G();const{shareBook:F}=ne(),{isPremium:z}=$(),{data:s,isLoading:S}=q(l),{data:m,isLoading:me}=Y(l),{data:x}=O({genre:s==null?void 0:s.genre,language:s==null?void 0:s.language}),{data:h}=V(l),{data:t}=W(l),g=Z(),f=J(),[L,j]=k.useState((t==null?void 0:t.rating)||0);k.useEffect(()=>{t!=null&&t.rating&&j(t.rating)},[t==null?void 0:t.rating]);const p=(x==null?void 0:x.filter(a=>a.id!==l).slice(0,4))||[];if(S)return e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:e.jsx(K,{className:"h-8 w-8 animate-spin text-primary"})});if(!s)return e.jsxs("div",{className:"flex flex-col items-center justify-center min-h-screen p-4",children:[e.jsx("p",{className:"text-muted-foreground",children:"Book not found"}),e.jsx(i,{variant:"link",onClick:()=>d(-1),children:"Go back"})]});const N={id:s.id,title:s.title,author:s.author,narrator:s.narrator||s.author,cover:s.cover_url||"/placeholder.svg",duration:s.duration,language:s.language==="english"?"en":"hi",genre:s.genre,rating:s.rating_average,description:s.description||"",audioUrl:s.audio_url||void 0,audioUrlEnglish:s.audio_url_english||void 0,audioUrlHindi:s.audio_url_hindi||void 0},U=()=>{C(N)},A=()=>{P(N),r.success(`"${s.title}" added to queue`)},v=B.some(a=>a.id===s.id),M=async()=>{try{await g.mutateAsync({bookId:s.id,isFavorite:!!h}),r.success(h?"Removed from favorites":"Added to favorites")}catch{r.error("Failed to update favorites")}},R=async a=>{j(a);try{await f.mutateAsync({bookId:s.id,rating:a}),r.success("Rating submitted")}catch{r.error("Failed to submit rating")}},D=a=>`${Math.floor(a/60)} min`,E=a=>a.replace("_"," ").replace(/\b\w/g,n=>n.toUpperCase());return e.jsxs("div",{className:"min-h-screen bg-background animate-fade-in",children:[e.jsx("div",{className:"sticky top-0 z-10 bg-background/80 backdrop-blur-sm",children:e.jsxs("div",{className:"flex items-center justify-between p-4 max-w-lg mx-auto",children:[e.jsx(i,{variant:"ghost",size:"icon",onClick:()=>d(-1),children:e.jsx(X,{className:"h-5 w-5"})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(i,{variant:"ghost",size:"icon",onClick:()=>F({id:s.id,title:s.title,author:s.author}),children:e.jsx(ee,{className:"h-5 w-5"})}),e.jsx(i,{variant:"ghost",size:"icon",onClick:()=>{z?r.success("Download started"):r.info("Upgrade to Premium for offline downloads")},children:e.jsx(se,{className:"h-5 w-5"})})]})]})}),e.jsxs("div",{className:"px-4 pb-24 max-w-lg mx-auto space-y-6",children:[e.jsxs("div",{className:"flex flex-col items-center text-center",children:[e.jsx("div",{className:"w-48 h-48 rounded-2xl bg-muted overflow-hidden shadow-xl mb-4",children:e.jsx("img",{src:s.cover_url||"/placeholder.svg",alt:s.title,className:"w-full h-full object-cover"})}),e.jsx("h1",{className:"font-heading text-2xl font-bold",children:s.title}),e.jsx("p",{className:"text-muted-foreground",children:s.author}),e.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[e.jsx("div",{className:"flex items-center",children:[1,2,3,4,5].map(a=>e.jsx(u,{className:o("h-4 w-4",a<=Math.floor(s.rating_average||0)?"fill-secondary text-secondary":"text-muted")},a))}),e.jsx("span",{className:"font-medium",children:s.rating_average}),e.jsxs("span",{className:"text-muted-foreground text-sm",children:["(",s.rating_count||0," reviews)"]})]}),e.jsxs("div",{className:"flex items-center gap-4 mt-4 text-sm text-muted-foreground",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(oe,{className:"h-4 w-4"}),e.jsx("span",{children:D(s.duration)})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(ae,{className:"h-4 w-4"}),e.jsx("span",{className:"capitalize",children:s.language})]}),s.narrator&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(te,{className:"h-4 w-4"}),e.jsx("span",{children:s.narrator})]})]}),e.jsx("div",{className:"flex items-center gap-2 mt-3",children:s.genre&&e.jsx(le,{variant:"secondary",children:E(s.genre)})})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsxs(i,{className:"flex-1 h-12 bg-secondary hover:bg-secondary/90",onClick:U,children:[e.jsx(ie,{className:"h-5 w-5 mr-2 fill-current"}),"Play Now"]}),e.jsxs(i,{variant:"outline",className:"h-12 px-4",onClick:A,disabled:v,children:[e.jsx(de,{className:"h-5 w-5 mr-1"}),v?"In Queue":"Queue"]}),e.jsx(i,{variant:"outline",size:"icon",className:"h-12 w-12",onClick:M,disabled:g.isPending,children:e.jsx(re,{className:o("h-5 w-5",h&&"fill-destructive text-destructive")}
6)})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"font-heading font-semibold text-lg mb-2",children:"About this book"}),e.jsx("p",{className:"text-muted-foreground leading-relaxed",children:s.description})]}),(s.amazon_url||s.flipkart_url)&&e.jsxs(e.Fragment,{children:[e.jsx(c,{}),e.jsxs("section",{children:[e.jsxs("h2",{className:"font-heading font-semibold text-lg mb-3 flex items-center gap-2",children:[e.jsx(ce,{className:"h-5 w-5"}),"Buy the Physical Book"]}),e.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:"Loved the summary? Get the full book!"}),e.jsxs("div",{className:"flex gap-3",children:[s.amazon_url&&e.jsx(i,{variant:"outline",className:"flex-1 h-11",asChild:!0,children:e.jsxs("a",{href:s.amazon_url,target:"_blank",rel:"noopener noreferrer",children:[e.jsx("span",{className:"font-semibold",children:"Amazon"}),e.jsx(_,{className:"h-4 w-4 ml-1"})]})}),s.flipkart_url&&e.jsx(i,{variant:"outline",className:"flex-1 h-11",asChild:!0,children:e.jsxs("a",{href:s.flipkart_url,target:"_blank",rel:"noopener noreferrer",children:[e.jsx("span",{className:"font-semibold",children:"Flipkart"}),e.jsx(_,{className:"h-4 w-4 ml-1"})]})})]})]})]}),e.jsx(c,{}),e.jsxs("section",{children:[e.jsx("h2",{className:"font-heading font-semibold text-lg mb-3",children:"Rate this book"}),e.jsx("div",{className:"flex items-center gap-2",children:[1,2,3,4,5].map(a=>e.jsx("button",{onClick:()=>R(a),className:"p-1 hover:scale-110 transition-transform",disabled:f.isPending,children:e.jsx(u,{className:o("h-8 w-8",a<=(L||(t==null?void 0:t.rating)||0)?"fill-secondary text-secondary":"text-muted hover:text-secondary/50")})},a))})]}),m&&m.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(c,{}),e.jsxs("section",{children:[e.jsx("h2",{className:"font-heading font-semibold text-lg mb-3",children:"Reviews"}),e.jsx("div",{className:"space-y-3",children:m.map(a=>{var n;return e.jsx(w,{children:e.jsxs(y,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("span",{className:"font-medium",children:((n=a.profiles)==null?void 0:n.full_name)||"Anonymous"}),e.jsx("div",{className:"flex items-center",children:[1,2,3,4,5].map(b=>e.jsx(u,{className:o("h-3 w-3",b<=a.rating?"fill-secondary text-secondary":"text-muted")},b))})]}),a.review_text&&e.jsx("p",{className:"text-sm text-muted-foreground",children:a.review_text})]})},a.id)})})]})]}),p.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(c,{}),e.jsxs("section",{children:[e.jsx("h2",{className:"font-heading font-semibold text-lg mb-3",children:"You might also like"}),e.jsx("div",{className:"flex gap-3 overflow-x-auto scrollbar-hide -mx-4 px-4 pb-2",children:p.map(a=>e.jsx(w,{className:"flex-shrink-0 w-32 overflow-hidden cursor-pointer",onClick:()=>d(`/book/${a.id}`),children:e.jsxs(y,{className:"p-3",children:[e.jsx("div",{className:"w-full aspect-[3/4] rounded-lg bg-muted mb-2 overflow-hidden",children:e.jsx("img",{src:a.cover_url||"/placeholder.svg",alt:a.title,className:"w-full h-full object-cover"})}),e.jsx("h3",{className:"font-medium text-xs truncate",children:a.title}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:a.author})]})},a.id))})]})]})]})]})}export{ke as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.