1import{i as H,j as n,A as v,L as de}from"./index-CGi0bt1A.js";import{r as o,u as ue,a as he}from"./react-D88zDUjx.js";import{P as ge,T as fe,S as pe,E as me}from"./Reader-CRYT02yt.js";import"./epub-iBTXOzSI.js";import"./contentProcessor-BAa_OImN.js";import"./imageLoader-DO0qMxG9.js";import"./pdfjs-DeWlx49F.js";import"./pdf.worker.min-DVp0HCY1.js";const be="/auth?from=demo";function xe({slug:l,dismissed:a,onDismiss:i}){const{language:s}=H(),[g,p]=o.useState(!1),m=`${be}&book=${encodeURIComponent(l||"")}`,h=s==="zh"||s==="zh-TW";return n.jsxs(n.Fragment,{children:[!a&&n.jsxs("div",{style:{position:"fixed",bottom:0,left:0,right:0,zIndex:1e3,background:"linear-gradient(135deg, #2D5A4A 0%, #306F6F 100%)",color:"#fff",padding:"12px 20px calc(12px + env(safe-area-inset-bottom, 0px))",display:"flex",alignItems:"center",justifyContent:"center",gap:"16px",fontFamily:"'Inter', 'Noto Sans SC', sans-serif",fontSize:"14px",boxShadow:"0 -4px 16px rgba(0,0,0,0.15)"},children:[n.jsx("span",{style:{opacity:.95},children:h?"æ³è¦é«äº®ãç¬è®°ã追踪é
读è¿åº¦ï¼":"Want to highlight, take notes, and track your progress?"}),n.jsx("a",{href:m,style:{background:"#fff",color:"#2D5A4A",padding:"6px 16px",borderRadius:8,fontWeight:600,fontSize:"13px",textDecoration:"none",whiteSpace:"nowrap"},children:h?"å
费注å":"Create Free Account"}),n.jsx("a",{href:m+"&action=login",style:{color:"rgba(255,255,255,0.85)",fontSize:"13px",textDecoration:"underline",whiteSpace:"nowrap"},children:h?"ç»å½":"Sign In"}),n.jsx("button",{onClick:()=>i(!0),style:{background:"none",border:"none",color:"rgba(255,255,255,0.7)",cursor:"pointer",fontSize:"18px",padding:"0 4px",lineHeight:1},"aria-label":"Dismiss",children:"Ã"})]}),a&&n.jsx("button",{onClick:()=>i(!1),style:{position:"fixed",bottom:"calc(16px + env(safe-area-inset-bottom, 0px))",right:16,zIndex:1e3,background:"#2D5A4A",color:"#fff",border:"none",borderRadius:"50%",width:48,height:48,display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",boxShadow:"0 4px 12px rgba(0,0,0,0.2)",fontSize:"20px"},"aria-label":"Show sign up banner",children:n.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M16 21v-2a4 4 0 00-4-4H5a4 4 0 00-4 4v2"}),n.jsx("circle",{cx:"8.5",cy:"7",r:"4"}),n.jsx("line",{x1:"20",y1:"8",x2:"20",y2:"14"}),n.jsx("line",{x1:"23",y1:"11",x2:"17",y2:"11"})]})}),g&&n.jsx("div",{onClick:()=>p(!1),style:{position:"fixed",inset:0,zIndex:9999,background:"rgba(0,0,0,0.45)",display:"flex",alignItems:"center",justifyContent:"center"},children:n.jsxs("div",{onClick:k=>k.stopPropagation(),style:{background:"#fff",borderRadius:14,padding:"1.5rem 2rem",maxWidth:400,width:"90%",boxShadow:"0 8px 32px rgba(0,0,0,0.2)",fontFamily:"'Inter', 'Noto Sans SC', sans-serif"},children:[n.jsx("p",{style:{fontSize:"1.1rem",fontWeight:600,margin:"0 0 0.75rem",color:"#1a1a1a"},children:h?"å建账æ·è§£é宿´åè½":"Create an account for the full experience"}),n.jsx("p",{style:{fontSize:"0.9rem",color:"#555",lineHeight:1.6,margin:"0 0 1.25rem"},children:h?"注åå
费账æ·å³å¯ä¿åé«äº®åç¬è®°ï¼é
读è¿åº¦ä¹ä¼èªå¨ä¿åã":"Create a free account to save highlights and notes. Your reading progress will be saved automatically too."}),n.jsxs("div",{style:{display:"flex",gap:"0.75rem",justifyContent:"flex-end"},children:[n.jsx("button",{type:"button",onClick:()=>p(!1),style:{padding:"0.5rem 1.25rem",borderRadius:8,border:"1px solid #ccc",background:"#fff",cursor:"pointer",fontSize:"0.9rem",color:"#555"},children:h?"ç¨åå说":"Maybe Later"}),n.jsx("a",{href:m,style:{padding:"0.5rem 1.25rem",borderRadius:8,border:"none",background:"#2D5A4A",color:"#fff",cursor:"pointer",fontSize:"0.9rem",textDecoration:"none",display:"inline-flex",alignItems:"center"},children:h?"å
费注å":"Create Account"})]})]})})]})}async function ke(l){const a=await fetch(`${v}/reader/demo/books/${encodeURIComponent(l)}`);if(!a.ok)throw a.status===404?new Error("Demo book not found"):a.status===429?new Error("Too many requests â please try again later"):new Error(`Failed to load demo book (${a.status})`);return a.json()}async function ye(l){const a=await fetch(`${v}/reader/demo/books/${encodeURIComponent(l)}/file`);if(!a.ok)throw a.status===429?new Error("Too many requests â please try again later"):new Error(`Failed to download demo book (${a.status})`);return a.arrayBuffer()}async function Ce(l){if(!l.length)return new Map;const a=await fetch(`${v}/reader/demo/chapter-chunks?hashes=${l.join(",")}`);
1if(!a.ok)return new Map;const i=await a.json(),s=new Map;for(const g of i.chunks||[])s.set(g.chapter_content_hash,g);return s}const Se=typeof window<"u"&&window.innerWidth<768,we={theme:"parchment",clickToSelect:!0,ttsAccent:"en-US",ttsGender:"male",progressBarVisibility:"hover",viewMode:"chapter",fontSize:18,fontFamily:"PT Serif",pageWidth:ge,lineHeight:Se?2:1.8,paragraphSpacing:1,letterSpacing:0,autoPlayOnTap:!1};function Fe(){const{slug:l}=ue();he();const{t:a,language:i}=H(),[s,g]=o.useState(null),[p,m]=o.useState([]),[h,k]=o.useState(null),[$,j]=o.useState(!0),[T,E]=o.useState(""),y=o.useRef(null);o.useEffect(()=>{let t=!1;return(async()=>{try{j(!0),E("");const e=await ke(l);if(t)return;g(e.book),m(e.chapter_registry||[]),k(e.book.canonical_book_id);let r=null;y.current=()=>(r||(r=ye(l)),r)}catch(e){t||E(e.message||"Failed to load demo")}finally{t||j(!1)}})(),()=>{t=!0}},[l]);const[P,_]=o.useState(!1),[O,C]=o.useState(!1),D=o.useCallback(()=>C(!0),[]),u=o.useCallback(()=>(D(),Promise.resolve(null)),[D]),[V,G]=o.useState(we),{theme:f,fontSize:A,fontFamily:z,pageWidth:R,lineHeight:F,paragraphSpacing:L,letterSpacing:I,clickToSelect:M,autoPlayOnTap:N,ttsAccent:q,ttsGender:J,progressBarVisibility:Y,viewMode:U}=V,c=t=>e=>G(r=>({...r,[t]:e})),[b,S]=o.useState(!1),[Z,K]=o.useState("toc"),[Q,w]=o.useState(!1),d=o.useRef(null),[x,X]=o.useState({chunkProfile:null,chunkDensity:void 0,chunksEnabled:!0,isProPlan:!1,canUseChunks:!0,toc:[]}),ee=o.useCallback(t=>{X(e=>e.chunkProfile===t.chunkProfile&&e.chunkDensity===t.chunkDensity&&e.chunksEnabled===t.chunksEnabled&&e.toc===t.toc?e:{...t,canUseChunks:!0})},[]),[W,te]=o.useState({percentage:0,currentChapter:null}),ne=o.useCallback(t=>te(t),[]),[ve,oe]=o.useState(!1),re=o.useCallback(()=>oe(!0),[]);o.useLayoutEffect(()=>(document.documentElement.setAttribute("data-easeverse-reader","true"),()=>document.documentElement.removeAttribute("data-easeverse-reader")),[]),o.useLayoutEffect(()=>{document.documentElement.setAttribute("data-theme",f)},[f]),o.useEffect(()=>{if(s!=null&&s.title)return document.title=`Demo | ${s.title} | ${a("meta.siteTitle")}`,()=>{document.title=a("meta.siteTitle")}},[s==null?void 0:s.title,i,a]),o.useEffect(()=>{if(!b)return;const t=e=>{const r=document.querySelector(".sidebar");r&&r.contains(e.target)||e.target.closest('[title="Toggle Sidebar"]')||S(!1)};return document.addEventListener("pointerdown",t),()=>document.removeEventListener("pointerdown",t)},[b]);const ae=o.useCallback(async()=>{try{document.fullscreenElement?(await document.exitFullscreen(),w(!1)):(await document.documentElement.requestFullscreen(),w(!0))}catch{}},[]);o.useEffect(()=>{const t=()=>w(!!document.fullscreenElement);return document.addEventListener("fullscreenchange",t),()=>document.removeEventListener("fullscreenchange",t)},[]);const se=(t,e)=>{var r;(r=d.current)!=null&&r.navigateTo&&d.current.navigateTo(t,e)},ie=o.useCallback(t=>{var e;(e=d.current)!=null&&e.navigateTo&&d.current.navigateTo({percentage:t})},[]),le=o.useMemo(()=>h?{canonicalBookId:h,chapterRegistry:p,fetchChunks:Ce}:null,[h,p]),ce=o.useCallback(()=>y.current?y.current():Promise.reject(new Error("No file provider")),[]);if($)return n.jsx(de,{message:"Loading demo...",title:"EaseVerse"});if(T||!s)return n.jsxs("div",{className:"reader-error",children:[n.jsx("h2",{children:T||"Demo book not found"}),n.jsx("p",{style:{color:"#666",margin:"1rem 0"},children:i==="zh"||i==="zh-TW"?"è¯·æ£æ¥é¾æ¥æ¯å¦æ£ç¡®ï¼æè®¿é®ä¸»é¡µæ¥çæ´å¤ã":"Please check the URL or visit the homepage for more."}),n.jsx("a",{href:"https://easeverse.ink",className:"btn btn-primary",style:{textDecoration:"none"},children:"EaseVerse"})]});const B=`demo-${s.id}`;return n.jsxs("div",{className:`reader-container theme-${f}`,style:{paddingBottom:P?0:48},children:[n.jsx(fe,{book:{...s,file_type:"epub"},onBack:()=>window.location.href="https://easeverse.ink",onToggleSidebar:()=>S(!b),sidebarOpen:b,theme:f,onThemeChange:c("theme"),fontSize:A,onFontSizeChange:c("fontSize"),fontFamily:z,onFontFamilyChange:c("fontFamily"),pageWidth:R,onPageWidthChange:c("pageWidth"),lineHeight:F,onLineHeightChange:c("lineHeight"),paragraphSpacing:L,onParagraphSpacingChange:c("paragraphSpacing"),letterSpacing:I,onLetterSpacingChange:c("letterSpacing"),clickToSelect:M,onClickToSelectChange:c("clickToSelect"),autoPlayOnTap:N,onAutoPlayOnTapChange:c("autoPlayOnTap"),ttsAccent:q,onTtsAccentChange:c("ttsAccent"),ttsGender:J,onTtsGenderChange:c("ttsGender"),progress:W,onProgressJump:ie,onPrevChapter:()=>{var t,e;return(e=(t=d.current)==null?void 0:t.goToPrevChapter)==null?void 0:e.call(t)},onNextChapter:()=>{var t,e;return(e=(t=d.current)==null?void 0:t.goToNextChapter)==null?void 0:e.call(t)}
1,isFullscreen:Q,onToggleFullscreen:ae,viewMode:U,onViewModeChange:c("viewMode"),progressBarVisibility:Y,onProgressBarVisibilityChange:c("progressBarVisibility"),chunkProfile:x.chunkProfile,chunkDensity:x.chunkDensity,onChunkDensityChange:t=>{var e,r;return(r=(e=d.current)==null?void 0:e.setChunkDensity)==null?void 0:r.call(e,t)},onChunkManualOverridesChange:t=>{var e,r;return(r=(e=d.current)==null?void 0:e.setManualOverrides)==null?void 0:r.call(e,t)},onChunkManualLevelChange:t=>{var e,r;return(r=(e=d.current)==null?void 0:e.setManualLevel)==null?void 0:r.call(e,t)},onChunkManualCategoriesChange:t=>{var e,r;return(r=(e=d.current)==null?void 0:e.setManualCategories)==null?void 0:r.call(e,t)},onChunkResetProfile:()=>{var t,e;return(e=(t=d.current)==null?void 0:t.resetChunkProfile)==null?void 0:e.call(t)},chunksEnabled:x.chunksEnabled,onToggleChunks:t=>{var e,r;return(r=(e=d.current)==null?void 0:e.setChunksEnabled)==null?void 0:r.call(e,t)},isProPlan:!1,canUseChunks:!0,bookId:B,bookLanguage:s.language}),n.jsxs("div",{className:"reader-main",children:[n.jsx(pe,{isOpen:b,onClose:()=>S(!1),activeTab:Z,onTabChange:K,highlights:[],notes:[],bookmarks:[],onNavigate:se,onDeleteHighlight:u,onUpdateHighlight:u,onUpdateNote:u,onDeleteNote:u,onUpdateBookmark:u,onDeleteBookmark:u,tableOfContents:x.toc,currentChapter:W.currentChapter,theme:f}),n.jsx("div",{className:"reader-content",children:n.jsx(me,{ref:d,bookId:B,fontSize:A,fontFamily:z,theme:f,pageWidth:R,lineHeight:F,paragraphSpacing:L,letterSpacing:I,bookLanguage:s.language,viewMode:U,clickToSelect:M,autoPlayOnTap:N,getToken:()=>null,userPlan:"demo",highlights:[],notes:[],initialLocation:null,progress:null,onHighlight:u,onUpdateHighlight:u,onDeleteHighlight:u,onAddNote:u,onUpdateNote:u,onDeleteNote:u,onProgressUpdate:()=>{},onRealtimeProgress:ne,onContentReady:re,onReaderStateChange:ee,bookFileProvider:ce,demoConfig:le})})]}),n.jsx(xe,{slug:l,dismissed:P,onDismiss:_}),O&&n.jsx("div",{onClick:()=>C(!1),style:{position:"fixed",inset:0,zIndex:9999,background:"rgba(0,0,0,0.45)",display:"flex",alignItems:"center",justifyContent:"center"},children:n.jsxs("div",{onClick:t=>t.stopPropagation(),style:{background:"#fff",borderRadius:14,padding:"1.5rem 2rem",maxWidth:400,width:"90%",boxShadow:"0 8px 32px rgba(0,0,0,0.2)",fontFamily:"'Inter', 'Noto Sans SC', sans-serif"},children:[n.jsx("p",{style:{fontSize:"1.1rem",fontWeight:600,margin:"0 0 0.75rem",color:"#1a1a1a"},children:i==="zh"||i==="zh-TW"?"å建账æ·è§£é宿´åè½":"Create an account for the full experience"}),n.jsx("p",{style:{fontSize:"0.9rem",color:"#555",lineHeight:1.6,margin:"0 0 1.25rem"},children:i==="zh"||i==="zh-TW"?"注åå 费账æ·å³å¯ä¿åé«äº®åç¬è®°ï¼é 读è¿åº¦ä¹ä¼èªå¨ä¿åã":"Create a free account to save highlights and notes. Your reading progress will be saved automatically too."}),n.jsxs("div",{style:{display:"flex",gap:"0.75rem",justifyContent:"flex-end"},children:[n.jsx("button",{type:"button",onClick:()=>C(!1),style:{padding:"0.5rem 1.25rem",borderRadius:8,border:"1px solid #ccc",background:"#fff",cursor:"pointer",fontSize:"0.9rem",color:"#555"},children:i==="zh"||i==="zh-TW"?"ç¨åå说":"Maybe Later"}),n.jsx("a",{href:`/auth?from=demo&book=${encodeURIComponent(l||"")}`,style:{padding:"0.5rem 1.25rem",borderRadius:8,border:"none",background:"#2D5A4A",color:"#fff",fontSize:"0.9rem",textDecoration:"none",display:"inline-flex",alignItems:"center"},children:i==="zh"||i==="zh-TW"?"å 费注å":"Create Account"})]})]})})]})}export{Fe as default}; 2//# sourceMappingURL=DemoReader-B3euLbt_.js.map
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.