import{E as x,F as h,b as l,j as e,T as p,J as o}from"./index-afzoW-A2.js";import{A as b}from"./AdsBanner-WB7ZkDyI.js";import{H as v}from"./HilltopAd-BEZbJaB-.js";import{O as N}from"./OverlaySlot-CUm4Fu71.js";import{V as g}from"./viewport-BONrjlXp.js";import"./runtime-omRR9KF1.js";const y=x({method:"POST"}).handler(h("fe0dfd3aa3754070bfb3540a3aa0e26f9c5627ce11bb14d82e90642b146e5f81")),P=x({method:"POST"}).handler(h("7485599f06252e3dc168dc3a7c6550c7b021a2eff6a2aa14d2a5d770603b54f5"));function O({bookId:s,chapterId:a,userId:t,ind:r,sourceIP:i}){const n=l.useRef(!1);return l.useEffect(()=>{const d=setTimeout(()=>{n.current||(t&&y({data:{bookId:s,userId:t,chapterId:a,ind:r}}),P({data:{bookId:s,ind:r.toString(),sourceIP:i}}),n.current=!0)},6e3);return()=>clearTimeout(d)},[s,a,t,r,i]),null}function m({book_id:s,current:a,total:t}){return e.jsxs("nav",{className:"site-reader-nav","aria-label":"章節導覽",children:[a>0?e.jsx("a",{className:"site-button",href:`/books/${s}/${a-1}`,children:"← 上一話"}):e.jsx("button",{type:"button",className:"site-button",disabled:!0,children:"← 上一話"}),e.jsxs("div",{className:"site-reader-center",children:[e.jsx("a",{className:"site-button",href:`/books/${s}`,children:"目錄"}),e.jsx(p,{})]}),a<t-1?e.jsx("a",{className:"site-button site-button-primary",href:`/books/${s}/${a+1}`,children:"下一話 →"}):e.jsx("button",{type:"button",className:"site-button",disabled:!0,children:"已到最新"})]})}function A(){const{bookId:s}=o.useParams(),{ads:a,book:t,chapter:r,current:i,total:n,imagePaths:d,userId:j,cfClientIP:u}=o.useLoaderData();return e.jsxs("div",{children:[e.jsx(O,{bookId:t.id,chapterId:r.id,userId:j,ind:r.ind,sourceIP:u}),e.jsxs("div",{className:"px-1",children:[e.jsxs("header",{className:"site-reader-heading",children:[e.jsx("p",{className:"site-eyebrow",children:"READING ROOM"}),e.jsx("h1",{children:t.name}),e.jsxs("p",{children:[r.name," · ",i+1," / ",n]})]}),e.jsx("div",{className:"my-2",children:e.jsx(m,{book_id:s,current:i,total:n})})]}),e.jsx("div",{className:"grid grid-cols-2 gap-4 md:gap-8 my-2",children:e.jsx(b,{bundle:a,name:"chapterBanner",className:"mx-auto",eager:!0})}),e.jsx("div",{className:"site-reader-canvas",children:d?.map((f,c)=>e.jsx("div",{className:"flex justify-center",children:e.jsx(g,{imageUrl:f,ind:c})},c))}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4 md:gap-8 my-2 sm:my-6",children:[e.jsxs("div",{className:"flex flex-col items-center space-y-2",children:[e.jsx("ins",{className:"eas6a97888e","data-zoneid":"4454466"}),e.jsx("div",{"data-cl-spot":"1854687"})]}),e.jsx("div",{className:"flex justify-center",children:e.jsx(v,{zone:"hilltop"})})]}),e.jsx("div",{className:"px-1",children:e.jsx("div",{className:"my-2",children:e.jsx(m,{book_id:s,current:i,total:n})})}),e.jsx(N,{bundle:a,name:"bookOverlay"})]})}export{A as component};
