PageSourceSearch

https://reader.easeverse.ink/assets/Library-CVMKUhhy.js

js easeverse.ink collected 2026-10-02 01:57:22 UTC 164,175 bytes, 5 lines download raw bytes

1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/guideBook-XcUfAKKk.js","assets/index-CGi0bt1A.js","assets/react-D88zDUjx.js","assets/epub-iBTXOzSI.js","assets/index-BPp4UNtk.css"])))=>i.map(i=>d[i]);
2import{i as ve,j as e,w as ne,_ as Fe,K as Ct,m as Oe,x as Re,M as on,N as ln,O as cn,e as dn,Q as un,b as hn,I as gn,y as fn,A as pn,F as mn,R as yn,S as pt,T as xn,g as bn,U as vn,V as wn}from"./index-CGi0bt1A.js";import{r as l,R as oe,a as et,d as St}from"./react-D88zDUjx.js";import"./epub-iBTXOzSI.js";function _n({message:t,onReLogin:n}){const{t:s}=ve();return e.jsx("div",{className:"sim-overlay",children:e.jsxs("div",{className:"sim-modal",children:[e.jsx("div",{className:"sim-icon",children:"⚠️"}),e.jsx("h2",{className:"sim-title",children:s("session.invalidTitle")||"登录已失效"}),e.jsx("p",{className:"sim-message",children:t}),e.jsx("p",{className:"sim-hint",children:s("session.invalidHint")||"当前设备已登出。"}),e.jsx("button",{type:"button",className:"sim-btn",onClick:n,children:s("session.reLogin")||"重新登录"})]})})}const Lt="easeverse_dismissed_notifications",jn=6e4;function kn(){try{const t=sessionStorage.getItem(Lt);if(!t)return new Set;const n=JSON.parse(t);return new Set(Array.isArray(n)?n:[])}catch{return new Set}}function Nn(t){try{sessionStorage.setItem(Lt,JSON.stringify(Array.from(t)))}catch{}}function Cn(t){return t?t==="zh-TW"?"zh_tw":t:"en"}function Sn(t,n){const s=[Cn(n),"zh","en"];for(const c of s){const g=t[`title_${c}`],f=t[`body_${c}`];if(g&&f)return{title:g,body:f}}return null}function Ln(){const{t,language:n}=ve(),[s,c]=l.useState([]),[g,f]=l.useState(()=>kn()),y=l.useCallback(async()=>{const b=await ne.getActiveNotifications();c(Array.isArray(b==null?void 0:b.notifications)?b.notifications:[])},[]);l.useEffect(()=>{let b=!1,i=null;const M=async()=>{b||typeof document<"u"&&document.hidden||await y()};M(),i=setInterval(M,jn);const o=()=>{document.hidden||M()};return document.addEventListener("visibilitychange",o),()=>{b=!0,i&&clearInterval(i),document.removeEventListener("visibilitychange",o)}},[y]);const a=b=>{const i=new Set(g);i.add(b),f(i),Nn(i)},v=s.filter(b=>!g.has(b.id));return v.length===0?null:e.jsx(e.Fragment,{children:v.map(b=>{const i=Sn(b,n);return i?e.jsxs("div",{className:"app-notification-banner",role:"status",children:[e.jsxs("div",{className:"app-notification-text",children:[e.jsx("span",{className:"app-notification-title",children:i.title}),e.jsx("span",{className:"app-notification-body",children:i.body})]}),e.jsx("button",{type:"button",className:"app-notification-dismiss",onClick:()=>a(b.id),"aria-label":t("notification.dismiss")||"Dismiss",title:t("notification.dismiss")||"Dismiss",children:"×"})]},b.id):null})})}function zn({kind:t,pages:n,quota:s,fileName:c,onConfirm:g,onCancel:f,onUpgrade:y}){const{t:a}=ve(),v=(s==null?void 0:s.monthlyLimit)??0,b=(s==null?void 0:s.dailyLimit)??0,i=(s==null?void 0:s.monthlyUsed)??0,M=(s==null?void 0:s.dailyUsed)??0,o=Math.max(0,v-i),d=Math.max(0,b-M),u=Math.max(0,o-n),_=Math.max(0,d-n),D=(s==null?void 0:s.perBookCap)??0,x=v>0&&u<v*.2,S=b>0&&_<b*.2,j=L=>a("library.pdf.unit.pages",{n:L}),m=t==="upgrade"?"library.pdf.upgrade.title":t==="per_book_cap"?"library.pdf.error.perBookCapTitle":t==="quota_exceeded"?"library.pdf.error.quotaExceededTitle":t==="unreadable"?"library.pdf.error.unreadableTitle":"library.pdf.confirm.title",C=t==="confirm"?g:y,$=t==="confirm"?"library.pdf.confirm.confirm":"library.pdf.upgrade.cta",A=t!=="unreadable";return e.jsx("div",{className:"pcd-overlay",onClick:f,children:e.jsxs("div",{className:"pcd-modal",onClick:L=>L.stopPropagation(),role:"dialog","aria-modal":"true",children:[e.jsxs("header",{className:"pcd-head",children:[e.jsx("h2",{className:"pcd-title",children:a(m)}),e.jsxs("div",{className:"pcd-fileline",children:[e.jsx("span",{className:"pcd-filename",title:c,children:c}),n>0&&e.jsx("span",{className:"pcd-pagebadge",children:j(n)})]})]}),t==="confirm"&&e.jsxs("section",{className:"pcd-body",children:[e.jsx("p",{className:"pcd-summary",children:a("library.pdf.confirm.summary",{pages:n})}),e.jsxs("div",{className:"pcd-quota-table",children:[e.jsxs("div",{className:"pcd-quota-header",children:[e.jsx("span",{}),e.jsx("span",{children:a("library.pdf.confirm.colCurrent")}
2),e.jsx("span",{"aria-hidden":!0,children:"→"}),e.jsx("span",{children:a("library.pdf.confirm.colAfter")})]}),e.jsxs("div",{className:"pcd-quota-row",children:[e.jsxs("span",{className:"pcd-quota-label",children:[a("library.pdf.confirm.rowDaily"),e.jsxs("span",{className:"pcd-quota-cap",children:["/ ",j(b)]})]}),e.jsx("span",{className:"pcd-quota-num",children:d}),e.jsx("span",{className:"pcd-quota-arrow","aria-hidden":!0,children:"→"}),e.jsx("span",{className:`pcd-quota-num pcd-quota-after ${S?"pcd-warn":""}`,children:_})]}),e.jsxs("div",{className:"pcd-quota-row",children:[e.jsxs("span",{className:"pcd-quota-label",children:[a("library.pdf.confirm.rowMonthly"),e.jsxs("span",{className:"pcd-quota-cap",children:["/ ",j(v)]})]}),e.jsx("span",{className:"pcd-quota-num",children:o}),e.jsx("span",{className:"pcd-quota-arrow","aria-hidden":!0,children:"→"}),e.jsx("span",{className:`pcd-quota-num pcd-quota-after ${x?"pcd-warn":""}`,children:u})]})]})]}),t==="per_book_cap"&&e.jsxs("section",{className:"pcd-body",children:[e.jsx("p",{className:"pcd-error-line",children:a("library.pdf.error.perBookCapBody",{pages:n,cap:D})}),e.jsxs("div",{className:"pcd-bar",children:[e.jsx("div",{className:"pcd-bar-fill pcd-bar-over",style:{width:`${Math.min(100,n/Math.max(D,1)*100)}%`}}),e.jsx("div",{className:"pcd-bar-cap-marker",style:{left:"100%"},"aria-label":`cap ${D}`})]}),e.jsx("p",{className:"pcd-bar-legend",children:e.jsx("span",{children:a("library.pdf.error.perBookCapLegend",{pages:n,cap:D})})})]}),t==="quota_exceeded"&&e.jsxs("section",{className:"pcd-body",children:[e.jsx("p",{className:"pcd-error-line",children:a("library.pdf.error.quotaExceededBody",{pages:n})}),e.jsxs("div",{className:"pcd-quota-table",children:[e.jsxs("div",{className:"pcd-quota-row",children:[e.jsx("span",{className:"pcd-quota-label",children:a("library.pdf.confirm.rowDaily")}),e.jsx("span",{className:"pcd-quota-num",children:d}),e.jsx("span",{className:"pcd-quota-arrow","aria-hidden":!0,children:"·"}),e.jsx("span",{className:"pcd-quota-need",children:a("library.pdf.error.needs",{pages:n})})]}),e.jsxs("div",{className:"pcd-quota-row",children:[e.jsx("span",{className:"pcd-quota-label",children:a("library.pdf.confirm.rowMonthly")}),e.jsx("span",{className:"pcd-quota-num",children:o}),e.jsx("span",{className:"pcd-quota-arrow","aria-hidden":!0,children:"·"}),e.jsx("span",{className:"pcd-quota-need",children:a("library.pdf.error.needs",{pages:n})})]})]})]}),t==="upgrade"&&e.jsxs("section",{className:"pcd-body",children:[e.jsx("p",{className:"pcd-summary",children:a("library.pdf.upgrade.body")}),e.jsxs("ul",{className:"pcd-benefits",children:[e.jsx("li",{children:a("library.pdf.upgrade.benefit1")}),e.jsx("li",{children:a("library.pdf.upgrade.benefit2")}),e.jsx("li",{children:a("library.pdf.upgrade.benefit3")})]})]}),t==="unreadable"&&e.jsxs("section",{className:"pcd-body",children:[e.jsx("p",{className:"pcd-error-line",children:a("library.pdf.error.unreadableBody")}),e.jsxs("ul",{className:"pcd-causes",children:[e.jsx("li",{children:a("library.pdf.error.unreadableCause1")}),e.jsx("li",{children:a("library.pdf.error.unreadableCause2")}),e.jsx("li",{children:a("library.pdf.error.unreadableCause3")})]})]}),e.jsxs("footer",{className:"pcd-actions",children:[e.jsx("button",{type:"button",className:"pcd-btn pcd-btn-secondary",onClick:f,children:a(A?"library.pdf.confirm.cancel":"library.pdf.error.dismiss")}),A&&e.jsx("button",{type:"button",className:"pcd-btn pcd-btn-primary",onClick:C,children:a($)})]})]})})}function Bn({fileName:t,chapters:n=[],totalPages:s=0,outlineQuality:c="good",quota:g=null,alreadyConvertedIndices:f=[],cachedPages:y=[],isScanOnly:a=!1,charsPerPage:v=0,tocHarvested:b=!1,onSubmit:i,onClose:M,busy:o=!1,error:d=null}){const{t:u}=ve(),[_,D]=l.useState(!1),x=l.useMemo(()=>new Set(f),[f]),[S,j]=l.useState(()=>new Set(n.map((R,ee)=>ee)));l.useEffect(()=>{j(new Set(n.map((R,ee)=>ee)))},[n.length]);const m=l.useMemo(()=>{let R=0;for(const ee of S){const H=n[ee];H&&(R+=H.pageCount)}return R},[S,n]),C=l.useMemo(()=>{let R=0;for(const ee of S){const H=n[ee];H&&(x.has(H.chapterIndex)||(R+=H.pageCount))}return R},[S,n,x]),$=m-C,A=l.useMemo(()=>new Set(y),[y]),L=l.useMemo(()=>
2{if(A.size===0)return 0;let R=0;for(const ee of S){const H=n[ee];if(H&&!x.has(H.chapterIndex))for(let he=H.startPage;he<=H.endPage;he++)A.has(he)&&R++}return Math.min(R,C)},[S,n,x,A,C]),W=C-L,q=_&&W>0,G=Math.ceil(L/2)+(q?Math.ceil(W/2):W),k=(g==null?void 0:g.perBookCap)??0,z=(g==null?void 0:g.monthlyLimit)??0,Y=(g==null?void 0:g.monthlyUsed)??0,K=(g==null?void 0:g.dailyLimit)??0,ie=(g==null?void 0:g.dailyUsed)??0,E=Math.max(0,z-Y),T=Math.max(0,K-ie),p=Math.max(0,E-G),I=Math.max(0,T-G),Z=k>0&&C>k,Q=z>0&&G>E,te=K>0&&G>T,ae=!(S.size===0)&&!Z&&!Q&&!te&&!o,me=z>0&&p<z*.2,fe=K>0&&I<K*.2,de=R=>{const ee=n[R];return ee!=null&&x.has(ee.chapterIndex)},pe=R=>{de(R)||j(ee=>{const H=new Set(ee);return H.has(R)?H.delete(R):H.add(R),H})},w=()=>j(new Set(n.map((R,ee)=>ee))),U=()=>{j(R=>{const ee=new Set;for(let H=0;H<n.length;H++){if(de(H)){ee.add(H);continue}R.has(H)||ee.add(H)}return ee})},O=()=>{if(!ae)return;const R=Array.from(S).sort((ee,H)=>ee-H);i(R,{batch:q})},P=n.filter(R=>R.displayTitle).length,se=!b||P===0?"none":P===n.length?"full":"partial",ce=se==="full"?"chapterSelection.tocHarvested":se==="partial"?"chapterSelection.tocHarvestedPartial":c==="sparse"?"chapterSelection.outlineSparse":c==="heuristic"?"chapterSelection.outlineHeuristic":c==="fallback_single"?"chapterSelection.fallbackSingle":c==="fallback_chunks"?"chapterSelection.fallbackChunks":null,_e=R=>c==="fallback_chunks"?R.displayTitle||u("chapterSelection.pageRangeTitle",{start:R.startPage,end:R.endPage})||`${R.startPage}–${R.endPage}`:R.displayTitle||R.title;return e.jsx("div",{className:"pcd-overlay",onClick:o?void 0:M,children:e.jsxs("div",{className:"pcd-modal csm-modal",onClick:R=>R.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"csm-title",children:[e.jsxs("header",{className:"pcd-head",children:[e.jsx("h2",{className:"pcd-title",id:"csm-title",children:u("chapterSelection.title")||"选择要转换的章节"}),e.jsxs("div",{className:"pcd-fileline",children:[e.jsx("span",{className:"pcd-filename",title:t,children:t}),s>0&&e.jsx("span",{className:"pcd-pagebadge",children:u("library.pdf.unit.pages",{n:s})})]})]}),e.jsxs("div",{className:"csm-body",children:[ce&&e.jsx("div",{className:"csm-quality-hint",role:"status",children:u(ce)}),o&&n.length===0?e.jsxs("div",{className:"csm-loading-outline",role:"status","aria-live":"polite",children:[e.jsx("div",{className:"csm-spinner","aria-hidden":!0}),e.jsx("p",{children:u("chapterSelection.loadingOutline")||"正在解析章节…"})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"csm-toolbar",children:[e.jsx("button",{type:"button",className:"csm-tool-btn",onClick:w,disabled:o,children:u("chapterSelection.selectAll")||"全选"}),e.jsx("button",{type:"button",className:"csm-tool-btn",onClick:U,disabled:o,children:u("chapterSelection.invertSelection")||"反选"}),e.jsx("span",{className:"csm-tool-spacer"}),e.jsxs("span",{className:"csm-tool-counter",children:[u("chapterSelection.selectedCount",{n:S.size,pages:m})||`已选 ${S.size} 章 / ${m} 页`,$>0&&e.jsx("span",{className:"csm-tool-counter-free",children:u("chapterSelection.includesFreePages",{pages:$})||`(其中 ${$} 页免费)`})]})]}),e.jsx("ul",{className:"csm-chapter-list",children:n.map((R,ee)=>{const H=S.has(ee),he=x.has(R.chapterIndex);return e.jsx("li",{className:`csm-row ${H?"csm-row-checked":""} ${he?"csm-row-paid":""}`,children:e.jsxs("label",{className:"csm-row-label",children:[e.jsx("input",{type:"checkbox",checked:H,onChange:()=>pe(ee),disabled:o||he}),e.jsx("span",{className:"csm-row-title",title:_e(R),children:_e(R)}),e.jsx("span",{className:"csm-row-pages",children:u("library.pdf.unit.pages",{n:R.pageCount})}),he&&e.jsx("span",{className:"csm-row-paid-badge",children:u("chapterSelection.alreadyConverted")||"✓ 已转换"})]})},R.chapterIndex??ee)})}),e.jsxs("div",{className:"csm-footer-summary",children:[W>0&&e.jsxs("label",{className:`csm-batch-option ${_?"csm-batch-on":""}`,children:[e.jsx("input",{type:"checkbox",checked:_,onChange:R=>D(R.target.checked),disabled:o}),e.jsxs("span",{className:"csm-batch-copy",children:[e.jsx("span",{className:"csm-batch-title",children:u("chapterSelection.batchTitle")||"慢速转换,配额减半"}),e.jsx("span",{className:"csm-batch-hint",children:u("chapterSelection.batchHint")||"通常数小时内完成,最迟次日;完成后书架上即可阅读"})]})]}),C>0&&G!==C&&e.jsxs("div",{className:"csm-charge-summary",role:"status",children:[u("chapterSelection.chargeSummary",{pages:G})||`本次将扣 ${G} 页配额`,L>0&&e.jsx("span",{className:"csm-charge-cached",children:u("chapterSelection.cachedDiscount",{pages:L})||`(${L} 页命中共享缓存,半价)`})]}),(z>0||K>0)&&e.jsxs("div",{className:"pcd-quota-table csm-quota-table",children:[e.jsxs("div",{className:"pcd-quota-header",children:[e.jsx("span",{}),e.jsx("span",{children:u("library.pdf.confirm.colCurrent")}
2),e.jsx("span",{"aria-hidden":!0,children:"→"}),e.jsx("span",{children:u("library.pdf.confirm.colAfter")})]}),K>0&&e.jsxs("div",{className:"pcd-quota-row",children:[e.jsxs("span",{className:"pcd-quota-label",children:[u("library.pdf.confirm.rowDaily"),e.jsxs("span",{className:"pcd-quota-cap",children:["/ ",u("library.pdf.unit.pages",{n:K})]})]}),e.jsx("span",{className:"pcd-quota-num",children:T}),e.jsx("span",{className:"pcd-quota-arrow","aria-hidden":!0,children:"→"}),e.jsx("span",{className:`pcd-quota-num pcd-quota-after ${fe?"pcd-warn":""} ${te?"csm-warn-num":""}`,children:te?`−${G-T}`:I})]}),z>0&&e.jsxs("div",{className:"pcd-quota-row",children:[e.jsxs("span",{className:"pcd-quota-label",children:[u("library.pdf.confirm.rowMonthly"),e.jsxs("span",{className:"pcd-quota-cap",children:["/ ",u("library.pdf.unit.pages",{n:z})]})]}),e.jsx("span",{className:"pcd-quota-num",children:E}),e.jsx("span",{className:"pcd-quota-arrow","aria-hidden":!0,children:"→"}),e.jsx("span",{className:`pcd-quota-num pcd-quota-after ${me?"pcd-warn":""} ${Q?"csm-warn-num":""}`,children:Q?`−${G-E}`:p})]})]}),Z&&e.jsx("div",{className:"csm-quota-line csm-warn",children:u("chapterSelection.exceedsCap",{cap:k})||`超出单本上限 ${k} 页`}),(Q||te)&&!Z&&e.jsx("div",{className:"csm-quota-line csm-warn",children:u("chapterSelection.exceedsQuota",{pages:G})||"选中页数超出剩余配额,请减少选择"}),d&&e.jsx("div",{className:"csm-quota-line csm-warn",role:"alert",children:d})]})]})]}),e.jsxs("footer",{className:"pcd-actions",children:[e.jsx("button",{type:"button",className:"pcd-btn pcd-btn-secondary",onClick:M,disabled:o,children:u("library.pdf.confirm.cancel")||"取消"}),e.jsx("button",{type:"button",className:"pcd-btn pcd-btn-primary",onClick:O,disabled:!ae,children:o&&n.length>0?u("chapterSelection.submitting")||"提交中…":u("chapterSelection.startConversion")||"开始转换"})]})]})})}async function Mn(t){try{const n=await t.arrayBuffer(),s=await Fe(()=>import("./pdfjs-DeWlx49F.js"),[]);if(!s.GlobalWorkerOptions.workerSrc){const g=(await Fe(async()=>{const{default:f}=await import("./pdf.worker.min-DVp0HCY1.js");return{default:f}},[])).default;s.GlobalWorkerOptions.workerSrc=g}const c=await s.getDocument({data:n,useSystemFonts:!1,disableFontFace:!0,verbosity:0}).promise;try{return c.numPages}finally{await c.destroy()}}catch{return null}}function Tn(t){const n=t==null?void 0:t.pdfPagesLimitMonthly;return n===void 0?(t==null?void 0:t.plan)!=="free"&&!!(t!=null&&t.plan):n!==0}function Pn(t){var n;return((n=t==null?void 0:t.detail)==null?void 0:n.error)==="pdf_not_available"}function An({exts:t,pdfEnabled:n,readerPaid:s,currentCount:c,limit:g}){return!n&&t.includes(".pdf")?"pdf_upgrade":!s&&c+t.length>g?"book_limit":null}function Qe(t){return typeof(t==null?void 0:t.file_url)=="string"&&(t.file_url.startsWith("curated-books/")||t.file_url.includes("/curated-books/"))}function Dn(t){if(!t)return"";const n=new Date(t),c=new Date-n,g=Math.floor(c/6e4),f=Math.floor(c/36e5),y=Math.floor(c/864e5);return g<1?"Just now":g<60?`${g} min ago`:f<24?`${f} hour${f>1?"s":""} ago`:y<7?`${y} day${y>1?"s":""} ago`:n.toLocaleDateString()}function mt(t){if(!t)return null;try{const n=new Date(t),s=n.getFullYear(),c=String(n.getMonth()+1).padStart(2,"0"),g=String(n.getDate()).padStart(2,"0");return`${s}年${c}月${g}日`}catch{return null}}function Xe(t){const n=[...t].sort((i,M)=>new Date(M.created_at)-new Date(i.created_at)),s=new Date,c=new Date(s.getTime()-7*24*60*60*1e3),g=s.getFullYear(),f=[],y=[],a={};for(const i of n){const M=new Date(i.created_at);if(M>=c)f.push(i);else if(M.getFullYear()===g)y.push(i);else{const o=M.getFullYear();a[o]||(a[o]=[]),a[o].push(i)}}const v=[];f.length&&v.push({labelKey:"library.last7Days",labelParam:void 0,books:f}),y.length&&v.push({labelKey:"library.thisYear",labelParam:void 0,books:y});const b=Object.keys(a).map(Number).sort((i,M)=>M-i);for(const i of b)v.push({labelKey:"library.yearUploaded",labelParam:{year:i},books:a[i]});return v}function En(t,n){const s=t.map(a=>{var v;return{book:a,finished_at:((v=n[a.id])==null?void 0:v.finished_at)||null}}).sort((a,v)=>a.finished_at?v.finished_at?new Date(v.finished_at)-new Date(a.finished_at):-1:1),c={};for(const{book:a,finished_at:v}of s){const b=v?new Date(v):null,i=b?b.getFullYear():0,M=b?b.getMonth():-1;c[i]||(c[i]={}),c[i][M]||(c[i][M]=[]),c[i][M].push(a)}const g=Object.keys(c).map(Number).filter(a=>a>0).sort((a,v)=>v-a),f=c[0]&&c[0][-1]?c[0][-1]:[],y=[];for(const a of g){const v=c[a],i=Object.keys(v).map(Number).sort((o,d)=>d-o).map(o=>({month:o,books:v[o]}
2)),M=i.reduce((o,d)=>o+d.books.length,0);y.push({labelKey:"library.yearFinishedCount",labelParam:{year:a,count:M},year:a,rows:i})}if(f.length){const a=new Date().getFullYear();y.push({labelKey:"library.yearFinishedCount",labelParam:{year:a,count:f.length},year:a,rows:[{month:null,books:f}]})}return y}function In({book:t}){const{t:n}=ve(),s=t==null?void 0:t.conversion_status;if(!s||s==="ready"||s==="failed")return null;if(s==="uploading"){const a=n("library.uploadingBadge")||"上传中…";return e.jsx("span",{className:`book-conversion-badge book-conversion-badge-${s}`,title:a,children:a})}if(s==="batch_pending"){const a=n("library.batchPendingBadge")||"排队中·慢速";return e.jsx("span",{className:`book-conversion-badge book-conversion-badge-${s}`,title:n("reader.pdfBatch.hint")||a,children:a})}if(s==="pending_preview"){const a=n("library.pendingPreviewBadge")||"待选章节";return e.jsx("span",{className:`book-conversion-badge book-conversion-badge-${s}`,title:a,children:a})}const c=Number(t.chapters_total)||0,g=Number(t.chapters_completed)||0;let f,y;return c===0?(f=n("library.badgeExtracting")||"解析中",y=n("reader.pdfPreparing.stage1")||"解析 PDF 文本"):g<c?(f=`${n("library.badgeConverting")||"整理"} ${g}/${c}`,y=`${n("reader.pdfPreparing.stage2")||"正在整理为可读格式"} (${g}/${c})`):(f=n("library.badgeFinishing")||"即将完成",y=n("reader.pdfPreparing.stage4")||"保存到云端"),e.jsx("span",{className:`book-conversion-badge book-conversion-badge-${s}`,title:y,children:f})}const We=oe.memo(In);function qe(t){if(!t)return!1;if(typeof t.outline_chapter_total!="number"||t.outline_chapter_total<=0)return!0;const n=t.selected_chapter_indices;let s=0;if(Array.isArray(n))s=n.length;else if(typeof n=="string")try{const c=JSON.parse(n);Array.isArray(c)&&(s=c.length)}catch{}return s<t.outline_chapter_total}function $n({book:t,index:n,showTime:s=!0,showFinishedDate:c=!1,showProgress:g=!1,selectionOpts:f=null,ctx:y}){var Q,te,re;const{cloudDownloading:a,bookCovers:v,coverLoading:b,localFileIds:i,cloudUploading:M,isPaid:o,justDidBoxSelectRef:d,bookProgress:u,t:_,getLastReadTime:D,isCloudOnly:x,isBookFinished:S,handleOpenBook:j,handleDelete:m,handleCloudUpload:C,openChapterPickerForBook:$,isAccessible:A}=y,L=A?!A(t.id):!1,W=Qe(t)?_("library.returnBook"):_("library.deleteBook"),q=v[t.id],[G,k]=l.useState(!1),[z,Y]=l.useState(q);z!==q&&(Y(q),k(!1));const K=a[t.id]!=null,ie=a[t.id]||0,E=S(t.id),T=f==null?void 0:f.selectionMode,p=(f==null?void 0:f.selected)??!1,I=f==null?void 0:f.onToggleSelect,Z=f==null?void 0:f.finishedAt;return e.jsxs("article",{"data-book-id":t.id,className:`book-card ${K?"downloading":""} ${T?"selection-mode":""} ${p?"selected":""} ${L?"phantom":""}`,style:{animationDelay:`${n*30}ms`},onClick:()=>{if(!d.current){if(T&&I){I(t.id);return}K||j(t)}},children:[!T&&!L&&s&&e.jsx("span",{className:"book-time",children:Dn(D(t)||t.created_at)}),!T&&e.jsx("button",{className:"book-delete",onClick:ae=>m(ae,t.id),title:W,"aria-label":W,children:e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{d:"M6 18L18 6M6 6l12 12",strokeLinecap:"round",strokeLinejoin:"round"})})}),e.jsxs("div",{className:"book-cover",children:[T&&e.jsx("span",{className:`book-selection-check ${p?"checked":""}`,"aria-hidden":"true",children:p&&e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("polyline",{points:"20 6 9 17 4 12"})})}),q&&!G?e.jsx("img",{src:q,alt:t.title,className:"book-cover-image",loading:"lazy",decoding:"async",onError:()=>k(!0)}):e.jsx("div",{className:`book-cover-placeholder ${b[t.id]?"loading":"no-cover"}`,children:b[t.id]?e.jsx("div",{className:"cover-spinner"}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"book-cover-initial",children:(t.title||"?").charAt(0).toUpperCase()}),e.jsx("span",{className:"book-cover-title",children:t.title})]})}),E&&!K&&e.jsx("span",{className:"book-finished-badge",title:_("library.finishedReading"),children:_("library.finishedShort")}),!Ct(t.file_type)&&!K&&e.jsx("span",{className:"format-disabled-badge",title:_("reader.formatTemporarilyUnavailable",{format:String(t.file_type||"").toUpperCase()}),children:String(t.file_type||"").toUpperCase()}),!K&&e.jsx(We,{book:t}),L&&!K&&e.jsx("span",{className:"phantom-badge",title:_("library.notAvailable"),children:e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("path",{d:"M20 16.58A5 5 0 0018 7h-1.26A8 8 0 104 15.25",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M8 17l8-8",strokeLinecap:"round"})]})}),!L&&x(t)&&!K&&e.jsx("span",{className:"cloud-badge",title:_("library.cloudOnly"),children:e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{d:"M20 16.58A5 5 0 0018 7h-1.26A8 8 0 104 15.25",strokeLinecap:"round",strokeLinejoin:"round"})})}),K&&e.jsxs("div",{className:"cloud-download-overlay",children:[e.jsxs("svg",{className:"cloud-download-icon",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("path",{d:"M12 4v12m0 0l-3-3m3 3l3-3",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M20 16.58A5 5 0 0018 7h-1.26A8 8 0 104 15.25",strokeLinecap:"round",strokeLinejoin:"round"})]}),e.jsxs("span",{className:"cloud-download-pct",children:[ie,"%"]}),e.jsx("div",{className:"cloud-download-bar",children:e.jsx("div",{className:"cloud-download-fill",style:{width:`${ie}%`}})})]}),!T&&!L&&o&&i.has(t.id)&&!t.file_url&&e.jsx("button",{type:"button",className:`book-cloud-btn ${M[t.id]?"uploading":""}`,onClick:ae=>C(ae,t),title:"Upload to cloud",children:e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("path",{d:"M12 16V8m0 0l-3 3m3-3l3 3",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M20 16.58A5 5 0 0018 7h-1.26A8 8 0 104 15.25",strokeLinecap:"round",strokeLinejoin:"round"})]})}),!T&&!L&&t.file_type==="epub_from_pdf"&&t.conversion_status==="ready"&&$&&qe(t)&&e.jsx("button",{type:"button",className:"book-add-chapters-btn",onClick:ae=>{ae.stopPropagation(),$(t)}
2,title:_("library.addChapters")||"增加章节",children:e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",children:e.jsx("path",{d:"M12 5v14M5 12h14"})})})]}),e.jsx("h3",{className:"book-title",title:t.title,children:t.title}),g?e.jsxs("div",{className:"book-progress-row",children:[e.jsx("div",{className:"book-progress-bar",children:e.jsx("div",{className:"book-progress-fill",style:{width:`${Math.round(((Q=u[t.id])==null?void 0:Q.percentage)||0)}%`}})}),e.jsxs("span",{className:"book-progress-pct",children:[Math.round(((te=u[t.id])==null?void 0:te.percentage)||0),"%"]})]}):c?e.jsx("span",{className:"book-finished-date-label",children:mt((re=u[t.id])==null?void 0:re.finished_at)||"—"}):null,f&&"finishedAt"in f&&e.jsx("div",{className:"book-finished-date-wrap",children:e.jsx("span",{className:"book-finished-date",children:mt(Z)||"—"})})]},t.id)}const tt=oe.memo($n),Fn={en:"en",zh:"zh-CN","zh-TW":"zh-TW",fr:"fr",ja:"ja"},Ke={};function Rn(t,n){const s=Fn[n]||"en";return Ke[s]||(Ke[s]=new Intl.DateTimeFormat(s,{month:"long"})),Ke[s].format(new Date(2e3,t,1))}function Wn({books:t,ctx:n}){const{t:s,language:c}=ve(),g=n.bookProgress,f=l.useMemo(()=>En(t,g),[t,g]),y=new Date().getFullYear(),[a,v]=l.useState(()=>new Set([y])),b=l.useCallback(i=>{v(M=>{const o=new Set(M);return o.has(i)?o.delete(i):o.add(i),o})},[]);return f.length?e.jsx("ol",{className:"finished-timeline",children:f.map(i=>{const M=a.has(i.year);return e.jsxs("li",{className:"finished-timeline-year","data-expanded":M?"true":"false",children:[e.jsxs("button",{type:"button",className:"finished-timeline-year-head",onClick:()=>b(i.year),"aria-expanded":M,children:[e.jsx("span",{className:"finished-timeline-year-dot","aria-hidden":"true"}),e.jsx("span",{className:"finished-timeline-year-label",children:s(i.labelKey,i.labelParam)}),e.jsx("svg",{className:"finished-timeline-year-caret",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e.jsx("polyline",{points:"6 9 12 15 18 9"})})]}),M&&e.jsx("div",{className:"finished-timeline-year-body",children:i.rows.map(o=>e.jsxs("section",{className:"finished-timeline-month",children:[e.jsxs("h4",{className:"finished-timeline-month-title",children:[e.jsx("span",{className:"finished-timeline-month-dot","aria-hidden":"true"}),e.jsx("span",{className:"finished-timeline-month-name",children:o.month===null?s("library.otherFinishedCount",{count:o.books.length}):Rn(o.month,c)}),o.month!==null&&e.jsxs("span",{className:"finished-timeline-month-count",children:["· ",s("library.bookCount",{count:o.books.length})]})]}),e.jsx("div",{className:"books-grid-full",children:o.books.map((d,u)=>e.jsx(tt,{book:d,index:u,showTime:!1,showProgress:!1,showFinishedDate:!0,selectionOpts:null,ctx:n},d.id))})]},o.month??"no-date"))})]},i.year)})}):null}const qn=oe.memo(Wn),On=[{value:"cloud",labelKey:"library.filterCloud"},{value:"local",labelKey:"library.filterLocal"},{value:"curated",labelKey:"library.filterCurated"}],yt=()=>e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("polyline",{points:"20 6 9 17 4 12"})});function Hn({gridBookFilter:t,setGridBookFilter:n,bookList:s,t:c}){const[g,f]=l.useState(!1),y=l.useRef(null),{storage:a,language:v}=t,b=(a!=="all"?1:0)+(v!=="all"?1:0);l.useEffect(()=>{if(!g)return;const d=u=>{y.current&&!y.current.contains(u.target)&&f(!1)};return document.addEventListener("pointerdown",d),()=>document.removeEventListener("pointerdown",d)},[g]);const i=oe.useMemo(()=>{const d={};for(const u of s){const _=(u.language||"").toLowerCase();_&&_!=="und"&&(d[_]=(d[_]||0)+1)}return Object.entries(d).sort((u,_)=>_[1]-u[1])},[s]),M=d=>n(u=>({...u,storage:u.storage===d?"all":d})),o=d=>n(u=>({...u,language:u.language===d?"all":d}));return e.jsxs("div",{className:"grid-filter-wrap",ref:y,children:[e.jsxs("button",{type:"button",className:`btn-icon-action ${b>0?"btn-icon-action-active":""}`,onClick:()=>f(d=>!d),title:c("library.filter"),children:[e.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M3 4h18l-7 8.5V18l-4 2v-7.5L3 4z"})}),b>0&&e.jsx("span",{className:"filter-badge",children:b})]}),g&&e.jsxs("div",{className:"grid-filter-dropdown",children:[e.jsx("div",{className:"grid-filter-section-label",children:c("library.filterStorageSection")}),On.map(d=>e.jsxs("button",{type:"button",className:a===d.value?"active":"",onClick:()=>
2M(d.value),children:[c(d.labelKey),a===d.value&&e.jsx(yt,{})]},d.value)),i.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"grid-filter-divider"}),e.jsx("div",{className:"grid-filter-section-label",children:c("library.filterLanguageSection")}),i.map(([d,u])=>e.jsxs("button",{type:"button",className:v===d?"active":"",onClick:()=>o(d),children:[c(`dashboard.langName.${d}`)||d.toUpperCase(),e.jsx("span",{className:"grid-filter-count",children:u}),v===d&&e.jsx(yt,{})]},d))]})]})]})}function Un({title:t,bookList:n,filterBaseList:s,gridViewType:c=null,ctx:g}){const{user:f,autoBackupEnabled:y,setAutoBackup:a}=Oe(),v=c==="all-books"&&!!(f!=null&&f.readerPaid),{bookProgress:b,localPinnedIds:i,gridSelectionMode:M,gridSelectedIds:o,gridBookFilter:d,boxSelectStart:u,boxSelectCurrent:_,gridScrollRef:D,isPaid:x,localFileIds:S,cloudUploading:j,t:m,goBackHome:C,setGridSelectionMode:$,setGridSelectedIds:A,setGridBookFilter:L,setLocalPinnedIds:W,setCloudUploading:q,setBooks:G,setLocalFileIds:k,setError:z,persistLocalPinned:Y,api:K,books:ie}=g,E=w=>{A(U=>{const O=new Set(U);return O.has(w)?O.delete(w):O.add(w),O})},T=()=>{W(w=>{const U=new Set(w);return o.forEach(O=>U.add(O)),Y(U),U}),A(new Set),$(!1)},p=()=>{W(w=>{const U=new Set(w);return o.forEach(O=>U.delete(O)),Y(U),U}),A(new Set),$(!1)},I=async()=>{if(!x){z(m("library.cloudProOnly"));return}const w=[...o].filter(O=>S.has(O));if(w.length===0)return;z("");const U=4;for(let O=0;O<w.length;O+=U){const P=w.slice(O,O+U);q(se=>({...se,...Object.fromEntries(P.map(ce=>[ce,!0]))})),await Promise.all(P.map(async se=>{try{const{file_url:ce}=await K.uploadBookToCloud(se);G(_e=>_e.map(R=>R.id===se?{...R,file_url:ce}:R))}catch(ce){z(ce.message||m("library.uploadFailed")),console.error(ce),Re(ce.message||"Bulk cloud upload failed",{level:"error",stack:ce.stack,metadata:{source:"GridView.handleBulkUploadToCloud",bookId:se}})}finally{q(ce=>({...ce,[se]:!1}))}}))}A(new Set),$(!1)},Z=async()=>{if(o.size===0||!confirm(m("library.confirmRemoveFromLocal",{count:o.size})))return;z("");const w=new Set(o);try{const U=[];for(const O of w){const P=ie.find(se=>se.id===O);P!=null&&P.file_url?await K.freeLocalSpace(O):(await K.deleteBook(O),U.push(O))}k(O=>{const P=new Set(O);return w.forEach(se=>P.delete(se)),P}),U.length>0&&G(O=>O.filter(P=>!U.includes(P.id))),A(new Set),$(!1)}catch(U){z(m("library.deleteFailed")),Re(U.message||"Bulk remove from local failed",{level:"error",stack:U.stack,metadata:{source:"GridView.handleBulkRemoveFromLocal"}})}},Q=n.length,te=c==="finished",re=c==="reading",ae=te||re,me=d.storage!=="all"||d.language!=="all";let fe;if(ae||me){const w=me?[...n].sort((U,O)=>new Date(O.created_at)-new Date(U.created_at)):n;fe=w.length?[{labelKey:null,labelParam:void 0,books:w}]:[]}else if(c==="local-library"){const w=n.filter(P=>i.has(P.id)),U=n.filter(P=>!i.has(P.id));fe=[...w.length?[{labelKey:"library.pinToTop",labelParam:void 0,books:[...w].sort((P,se)=>new Date(se.created_at)-new Date(P.created_at))}]:[],...Xe(U)]}else fe=Xe(n);const de=!!c&&!ae,pe=de&&M?{selectionMode:!0,selected:w=>o.has(w),onToggleSelect:E}:null;return e.jsxs("section",{className:`grid-view ${de?"grid-view-cloud":""}`,children:[e.jsxs("div",{className:"grid-view-header",children:[e.jsx("button",{className:"btn-back",onClick:C,"aria-label":m("library.back"),children:e.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M15 18l-6-6 6-6"})})}),e.jsxs("div",{className:"grid-view-header-left",children:[e.jsx("h2",{children:t}),e.jsx("span",{className:"grid-view-count",children:m("library.bookCount",{count:Q})})]}),e.jsxs("div",{className:"grid-view-header-right",children:[v&&e.jsxs("label",{className:"cloud-backup-toggle",title:m("library.cloudBackupDesc"),children:[e.jsx("input",{className:"cbt-input",type:"checkbox",checked:!!y,onChange:w=>a(w.target.checked)}),e.jsx("span",{className:"cbt-track","aria-hidden":"true",children:e.jsx("span",{className:"cbt-thumb"})}),e.jsx("span",{className:"cbt-label",children:m("library.cloudBackupToggle")})]}),c&&e.jsx(Hn,{gridBookFilter:d,setGridBookFilter:L,bookList:s||n,t:m}),de?M?e.jsxs("button",{type:"button",className:"btn-icon-action btn-icon-action-active",onClick:()=>{$(!1),A(new Set)},title:m("library.cancel"),children:[o.size>0&&e.jsx("span",{className:"select-count-badge",children:o.size}),e.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M18 6L6 18M6 6l12 12"})})]}):e.jsx("button",{type:"button",className:"btn-icon-action",onClick:()=>$(!0),title:m("library.select"),children:e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"3",y:"3",width:"7",height:"7",rx:"1"}),e.jsx("rect",{x:"14",y:"3",width:"7",height:"7",rx:"1"}),e.jsx("rect",{x:"3",y:"14",width:"7",height:"7",rx:"1"}),e.jsx("rect",{x:"14",y:"14",width:"7",height:"7",rx:"1"})]})}):null]})]}),n.length===0?e.jsxs("div",{className:"books-empty",children:[e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1",children:e.jsx("path",{d:"M12 6.042A8.967 8.967 0 006 3.75c-1.052 0-2.062.18-3 .512v14.25A8.987 8.987 0 016 18c2.305 0 4.408.867 6 2.292m0-14.25a8.966 8.966 0 016-2.292c1.052 0 2.062.18 3 .512v14.25A8.987 8.987 0 0018 18a8.967 8.967 0 00-6 2.292m0-14.25v14.25",strokeLinecap:"round",strokeLinejoin:"round"})}),e.jsx("p",{children:m("library.emptyTitle")})]}):te?e.jsx("div",{className:"grid-view-scroll",ref:D,children:e.jsx(qn,{books:n,ctx:g})}):e.jsx("div",{className:"grid-view-scroll",ref:D,children:fe.map((w,U)=>{var O;return e.jsxs("div",{className:"grid-view-section",children:[w.labelKey?e.jsx("h3",{className:"grid-view-section-title",children:w.labelParam?m(w.labelKey,w.labelParam):m(w.labelKey)}):e.jsx("h3",{className:"grid-view-section-title","aria-hidden":"true",style:{visibility:"hidden"},children:" "}),e.jsx("div",{className:"books-grid-full",children:w.books.map((P,se)=>e.jsx(tt,{book:P,index:se,showTime:!1,showProgress:re,showFinishedDate:te,selectionOpts:pe?{...pe,selected:pe.selected(P.id),pinned:c==="local-library"?i.has(P.id):!1}:null,ctx:g},P.id))})]},(w.labelKey||"flat")+(((O=w.labelParam)==null?void 0:O.year)??"")+U)})}),de&&u&&_&&(()=>{const w=D.current;if(!w)return null;const U=w.getBoundingClientRect(),O=U.left-w.scrollLeft+Math.min(u.x,_.x),P=U.top-w.scrollTop+Math.min(u.y,_.y);return e.jsx("div",{className:"box-select-overlay",style:{left:O,top:P,width:Math.abs(_.x-u.x),height:Math.abs(_.y-u.y)},"aria-hidden":!0})})(),de&&M&&e.jsxs("div",{className:"cloud-selection-bar",children:[e.jsxs("button",{type:"button",className:"cloud-selection-btn",onClick:()=>{const w=n.map(O=>O.id),U=w.length>0&&w.every(O=>o.has(O));A(U?new Set:new Set(w))},title:m("library.selectAll"),children:[e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("path",{d:"M9 11l3 3L22 4",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M21 12v7a2 2 0 01-2 2H5a2 2 0 01-2-2V5a2 2 0 012-2h11",strokeLinecap:"round",strokeLinejoin:"round"})]}),e.jsx("span",{children:m("library.selectAll")})]}),c==="local-library"&&(()=>{const w=o.size>0&&[...o].every(U=>i.has(U));return e.jsxs("button",{type:"button",className:"cloud-selection-btn",onClick:w?p:T,title:m(w?"library.unpinFromTop":"library.pinToTop"),children:[e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{d:"M18 15l-6-6-6 6",strokeLinecap:"round",strokeLinejoin:"round"})}),e.jsx("span",{children:m(w?"library.unpinFromTop":"library.pinToTop")})]})})(),x&&(()=>{const w=[...o].filter(O=>{var P;return S.has(O)&&!((P=ie.find(se=>se.id===O))!=null&&P.file_url)});if(w.length===0)return null;const U=w.some(O=>j[O]);return e.jsxs("button",{type:"button",className:`cloud-selection-btn ${U?"cloud-selection-btn-uploading":""}`,onClick:I,title:m("library.addToCloudShort"),disabled:U,children:[e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("path",{d:"M12 16V8m0 0l-3 3m3-3l3 3",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M20 16.58A5 5 0 0018 7h-1.26A8 8 0 104 15.25",strokeLinecap:"round",strokeLinejoin:"round"})]}),e.jsx("span",{children:m(U?"library.uploading":"library.addToCloudShort")})]})})(),e.jsxs("button",{type:"button",className:"cloud-selection-btn cloud-selection-btn-remove",onClick:Z,title:m("library.deleteShort"),children:[e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16",strokeLinecap:"round",strokeLinejoin:"round"})}),e.jsx("span",{children:m("library.deleteShort")})]}),e.jsxs("button",{type:"button",className:"cloud-selection-btn",onClick:()=>{A(new Set),$(!1)},title:m("library.cancel"),children:[e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{d:"M18 6L6 18M6 6l12 12",strokeLinecap:"round",strokeLinejoin:"round"})}),e.jsx("span",{children:m("library.cancel")})]})]})]})}const Ce=oe.memo(Un),xt=80,Jn=14;
2function Gn({viewMode:t,gridScrollRef:n,justDidBoxSelectRef:s,setCloudSelectedIds:c,setCloudSelectionMode:g,setGridSelectedIds:f,setGridSelectionMode:y}){const a=l.useRef(!1),v=l.useRef({x:0,y:0}),b=l.useRef(0),[i,M]=l.useState(null),[o,d]=l.useState(null),[,u]=l.useState(0),_=l.useCallback((x,S)=>{const j=n.current;if(!j)return{x,y:S};const m=j.getBoundingClientRect();return{x:x-m.left+j.scrollLeft,y:S-m.top+j.scrollTop}},[n]),D=t==="cloud-library"||t==="all-books"||t==="local-library";return l.useEffect(()=>{if(!D)return;const x=S=>{if(S.button!==0||S.target.closest('button, a, input, textarea, select, [contenteditable="true"]'))return;a.current=!0;const j=_(S.clientX,S.clientY);M(j),d(j)};return document.addEventListener("mousedown",x),()=>document.removeEventListener("mousedown",x)},[D,_]),l.useEffect(()=>{if(i==null)return;const x=n.current,S=5,j=A=>{v.current={x:A.clientX,y:A.clientY},d(_(A.clientX,A.clientY));const L=A.clientY;L>=window.innerHeight-xt?b.current=1:L<=xt?b.current=-1:b.current=0},m=A=>{b.current=0;const L=_(A.clientX,A.clientY),W=Math.min(i.x,L.x),q=Math.min(i.y,L.y),G=Math.abs(L.x-i.x),k=Math.abs(L.y-i.y);if(M(null),d(null),a.current=!1,G>=S&&k>=S&&x){const z=x.getBoundingClientRect(),Y={left:z.left-x.scrollLeft+W,top:z.top-x.scrollTop+q,right:z.left-x.scrollLeft+W+G,bottom:z.top-x.scrollTop+q+k},K=x.querySelectorAll(".book-card[data-book-id]"),ie=[];K.forEach(E=>{const T=E.getAttribute("data-book-id");if(!T)return;const p=E.getBoundingClientRect();!(Y.right<p.left||Y.left>p.right||Y.bottom<p.top||Y.top>p.bottom)&&ie.push(T)}),ie.length>0&&(s.current=!0,setTimeout(()=>{s.current=!1},120),t==="cloud-library"?(c(E=>{const T=new Set(E);return ie.forEach(p=>{T.has(p)?T.delete(p):T.add(p)}),T}),g(!0)):(f(E=>{const T=new Set(E);return ie.forEach(p=>{T.has(p)?T.delete(p):T.add(p)}),T}),y(!0)))}},C=()=>u(A=>A+1),$=setInterval(()=>{const A=b.current;if(A===0)return;window.scrollBy(0,A*Jn);const{x:L,y:W}=v.current;d(_(L,W))},50);return document.addEventListener("mousemove",j),document.addEventListener("mouseup",m),x&&x.addEventListener("scroll",C,{passive:!0}),()=>{b.current=0,clearInterval($),document.removeEventListener("mousemove",j),document.removeEventListener("mouseup",m),x&&x.removeEventListener("scroll",C)}},[i,_,t,n,s,c,g,f,y]),{boxSelectStart:i,boxSelectCurrent:o,boxSelectActiveRef:a}}function Vn({books:t,localFileIds:n,api:s}){const[c,g]=l.useState({}),[f,y]=l.useState({}),a=l.useRef({}),v=l.useRef(c);l.useEffect(()=>{v.current=c},[c]);const b=l.useRef(f);l.useEffect(()=>{b.current=f},[f]),l.useEffect(()=>{try{localStorage.removeItem("easeverse_cover_cache")}catch{}},[]),l.useEffect(()=>()=>{Object.values(a.current).forEach(o=>{o!=null&&o.startsWith("blob:")&&URL.revokeObjectURL(o)})},[]);const i=l.useCallback(async o=>{var d;if(a.current[o.id])return a.current[o.id];y(u=>({...u,[o.id]:!0}));try{if(o.cover_url){const _=await s.fetchBookCoverFromCloud(o.id);if(_)return a.current[o.id]=_,g(D=>({...D,[o.id]:_})),y(D=>({...D,[o.id]:!1})),_}const u=await on(o.id);if(u!=null&&u.data){const _=URL.createObjectURL(u.data);return a.current[o.id]=_,g(D=>({...D,[o.id]:_})),y(D=>({...D,[o.id]:!1})),_}if((d=ln(o.file_type))!=null&&d.coverExtractor&&n.has(o.id)){const _=await cn(o.id);if(_){const D=await dn(_,o.file_type);if(D){const x=un(D);hn(o.id,x).catch(()=>{});const S=URL.createObjectURL(x);return a.current[o.id]=S,g(j=>({...j,[o.id]:S})),y(j=>({...j,[o.id]:!1})),S}}}return y(_=>({..._,[o.id]:!1})),null}catch(u){return console.warn("Failed to load cover for",o.title,u),y(_=>({..._,[o.id]:!1})),null}},[n,s]),M=l.useRef(n);return l.useEffect(()=>{const o=M.current,d=[];for(const u of n)o.has(u)||d.push(u);M.current=n,d.length!==0&&y(u=>{const _={...u};for(const D of d)v.current[D]||delete _[D];return _})},[n]),l.useEffect(()=>{t.length>0&&t.forEach(o=>{!v.current[o.id]&&b.current[o.id]===void 0&&i(o)})},[t,n,i]),{bookCovers:c,coverLoading:f}}function Yn({ctx:t}){const{books:n,cloudBooks:s,localFileIds:c,cloudPinnedIds:g,cloudSelectionMode:f,cloudSelectedIds:y,boxSelectStart:a,boxSelectCurrent:v,gridScrollRef:b,t:i,goBackHome:M,setCloudSelectionMode:o,setCloudSelectedIds:d,setCloudDownloading:u,setLocalFileIds:_,setError:D,setCloudPinnedIds:x,persist
2CloudPinned:S,api:j}=t,m=E=>{d(T=>{const p=new Set(T);return p.has(E)?p.delete(E):p.add(E),p})},C=async()=>{const E=[...y];D("");for(const T of E){const p=n.find(I=>I.id===T);if(!(!p||!p.file_url||c.has(T))){u(I=>({...I,[T]:0}));try{await j.fetchBookFileFromCloud(T,Z=>{u(Q=>({...Q,[T]:Z}))})&&_(Z=>new Set([...Z,T]))}catch(I){D(i("library.downloadFailed")),Re((I==null?void 0:I.message)||"Bulk download from cloud failed",{level:"error",stack:I==null?void 0:I.stack,metadata:{source:"CloudLibraryView.handleBulkDownload",bookId:T}})}finally{u(I=>{const Z={...I};return delete Z[T],Z})}}}d(new Set),o(!1)},$=async()=>{const E=[...y].filter(T=>c.has(T));if(E.length!==0&&confirm(i("library.confirmBulkFreeLocalSpace",{count:E.length}))){D("");for(const T of E)try{await j.freeLocalSpace(T)}catch(p){D(p.message||"Failed to free local space"),console.error(p),Re(p.message||"Failed to free local space",{level:"error",stack:p.stack,metadata:{source:"CloudLibraryView.handleBulkFreeLocalSpace",bookId:T}})}_(T=>{const p=new Set(T);return E.forEach(I=>p.delete(I)),p}),d(new Set),o(!1)}},A=()=>{x(E=>{const T=new Set(E);return y.forEach(p=>T.add(p)),S(T),T}),d(new Set),o(!1)},L=()=>{x(E=>{const T=new Set(E);return y.forEach(p=>T.delete(p)),S(T),T}),d(new Set),o(!1)},W=s.length,q=s.filter(E=>g.has(E.id)),G=s.filter(E=>!g.has(E.id)),k=q.length?[{labelKey:"library.pinToTop",labelParam:void 0,books:[...q].sort((E,T)=>new Date(T.created_at)-new Date(E.created_at))}]:[],z=Xe(G),Y=[...k,...z],K=f?{selectionMode:!0,selected:E=>y.has(E),onToggleSelect:m}:null,ie=y.size>0&&[...y].every(E=>g.has(E));return e.jsxs("section",{className:"grid-view grid-view-cloud",children:[e.jsxs("div",{className:"grid-view-header grid-view-header-cloud",children:[e.jsx("button",{className:"btn-back",onClick:M,"aria-label":i("library.back"),children:e.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M15 18l-6-6 6-6"})})}),e.jsx("h2",{children:i("library.cloudLibrary")}),e.jsx("div",{className:"grid-view-header-right",children:f?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"grid-view-selected-count",children:i("library.selectedCount",{count:y.size})}),e.jsx("button",{type:"button",className:"btn-cancel-select",onClick:()=>{o(!1),d(new Set)},children:i("library.cancel")})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"grid-view-count",children:i("library.bookCount",{count:W})}),e.jsx("button",{type:"button",className:"btn-select",onClick:()=>o(!0),children:i("library.select")})]})})]}),W===0?e.jsxs("div",{className:"books-empty",children:[e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1",children:e.jsx("path",{d:"M12 6.042A8.967 8.967 0 006 3.75c-1.052 0-2.062.18-3 .512v14.25A8.987 8.987 0 016 18c2.305 0 4.408.867 6 2.292m0-14.25a8.966 8.966 0 016-2.292c1.052 0 2.062.18 3 .512v14.25A8.987 8.987 0 0018 18a8.967 8.967 0 00-6 2.292m0-14.25v14.25",strokeLinecap:"round",strokeLinejoin:"round"})}),e.jsx("p",{children:i("library.emptyTitle")})]}):e.jsx("div",{className:"grid-view-scroll",ref:b,children:Y.map(E=>{var T;return e.jsxs("div",{className:"grid-view-section",children:[e.jsx("h3",{className:"grid-view-section-title",children:E.labelParam?i(E.labelKey,E.labelParam):i(E.labelKey)}),e.jsx("div",{className:"books-grid-full",children:E.books.map((p,I)=>e.jsx(tt,{book:p,index:I,showTime:!1,selectionOpts:K?{...K,selected:K.selected(p.id),pinned:g.has(p.id)}:{pinned:g.has(p.id)},ctx:t},p.id))})]},E.labelKey+(((T=E.labelParam)==null?void 0:T.year)??""))})}),a&&v&&(()=>{const E=b.current;if(!E)return null;const T=E.getBoundingClientRect(),p=T.left-E.scrollLeft+Math.min(a.x,v.x),I=T.top-E.scrollTop+Math.min(a.y,v.y);return e.jsx("div",{className:"box-select-overlay",style:{left:p,top:I,width:Math.abs(v.x-a.x),height:Math.abs(v.y-a.y)},"aria-hidden":!0})})(),f&&e.jsxs("div",{className:"cloud-selection-bar",children:[e.jsxs("button",{type:"button",className:"cloud-selection-btn",onClick:()=>{const E=Y.flatMap(p=>p.books.map(I=>I.id)),T=E.length>0&&E.every(p=>y.has(p));d(T?new Set:new Set(E))},title:i("library.selectAll"),children:[e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("path",{d:"M9 11l3 3L22 4",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M21 12v7a2 2 0 01-2 2H5a2 2 0 01-2-2V5a2 2 0 012-2h11",strokeLinecap:"round",strokeLinejoin:"round"})]}),e.jsx("span",{children:i("library.selectAll")})]}),e.jsxs("button",{type:"button",className:"cloud-selection-btn",onClick:ie?L:A,title:i(ie?"library.unpinFromTop":"library.pinToTop"),children:[e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{d:"M18 15l-6-6-6 6",strokeLinecap:"round",strokeLinejoin:"round"})}),e.jsx("span",{children:i(ie?"library.unpinFromTop":"library.pinToTop")})]}),e.jsxs("button",{type:"button",className:"cloud-selection-btn",onClick:C,title:i("library.downloadToLocal"),children:[e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{d:"M21 15v4a2 2 0 01-2 2H5a2 2 0 01-2-2v-4M7 10l5 5 5-5M12 15V3"})}),e.jsx("span",{children:i("library.downloadToLocal")})]}),e.jsxs("button",{type:"button",className:"cloud-selection-btn",onClick:$,title:i("library.freeLocalSpaceShort"),children:[e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{d:"M3 6h18M8 6V4h8v2M19 6v14a2 2 0 01-2 2H7a2 2 0 01-2-2V6",strokeLinecap:"round",strokeLinejoin:"round"})}),e.jsx("span",{children:i("library.freeLocalSpaceShort")})]}),e.jsxs("button",{type:"button",className:"cloud-selection-btn",onClick:()=>{d(new Set),o(!1)},title:i("library.cancel"),children:[e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{d:"M18 6L6 18M6 6l12 12",strokeLinecap:"round",strokeLinejoin:"round"})}),e.jsx("span",{children:i("library.cancel")})]})]})]})}const Kn=oe.memo(Yn),bt="ev_backup_consent_seen";function Zn(){const{user:t,autoBackupEnabled:n}=Oe(),{t:s}=ve(),c=!!(t!=null&&t.readerPaid),[g,f]=l.useState(()=>{try{return localStorage.getItem(bt)==="1"}catch{return!0}});if(!c||g||!n)return null;const y=()=>{try{localStorage.setItem(bt,"1")}
2catch{}f(!0)};return e.jsxs("div",{className:"cloud-backup-consent",role:"status",children:[e.jsx("span",{className:"cbc-icon","aria-hidden":"true",children:e.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M18 10h-1.26A8 8 0 1 0 9 20h9a5 5 0 0 0 0-10z"})})}),e.jsxs("div",{className:"cbc-text",children:[e.jsx("strong",{className:"cbc-title",children:s("library.cloudBackupTitle")}),e.jsx("span",{className:"cbc-desc",children:s("library.cloudBackupDesc")})]}),e.jsx("div",{className:"cbc-actions",children:e.jsx("button",{type:"button",className:"cbc-btn cbc-ok",onClick:y,children:s("library.cloudBackupGotIt")})})]})}const Qn=60*60*1e3;function Xn(t,n=Date.now()){return Array.isArray(t)?t.filter(s=>{if(!s||s.file_type!=="pdf"||s.source_pdf_url||s.deleted_at)return!1;if(s.updated_at){const c=n-new Date(s.updated_at).getTime();if(Number.isFinite(c)&&c<Qn)return!1}return!0}):[]}function er({books:t,onDeleteBook:n}){const{t:s}=ve(),[c,g]=l.useState(()=>new Set),f=l.useMemo(()=>Xn(t),[t]),y=l.useMemo(()=>f.filter(v=>!c.has(v.id)),[f,c]);if(y.length===0)return null;function a(v){n&&(n(v),g(b=>{const i=new Set(b);return i.add(v.id),i}))}return e.jsxs("div",{className:"stuck-pdf-banner",role:"status",children:[e.jsx("strong",{className:"stuck-pdf-banner-title",children:s("stuckPdf.title",{count:y.length})}),e.jsx("p",{className:"stuck-pdf-banner-explanation",children:s("stuckPdf.explanation")}),e.jsx("ul",{className:"stuck-pdf-banner-list",children:y.map(v=>e.jsxs("li",{className:"stuck-pdf-banner-item",children:[e.jsx("span",{className:"stuck-pdf-banner-item-title",title:v.title,children:v.title||v.file_name||"(untitled PDF)"}),e.jsx("button",{type:"button",className:"stuck-pdf-banner-item-delete",onClick:()=>a(v),children:s("stuckPdf.deleteBook")})]},v.id))})]})}function tr({book:t,index:n,ctx:s}){const{bookProgress:c,cloudDownloading:g,bookCovers:f,coverLoading:y,t:a,isCloudOnly:v,handleOpenBook:b,openChapterPickerForBook:i}=s,M=c[t.id],o=Math.round((M==null?void 0:M.percentage)||0),d=g[t.id]!=null,u=g[t.id]||0;return e.jsxs("article",{className:`continue-card ${d?"downloading":""}`,style:{animationDelay:`${n*30}ms`},onClick:()=>!d&&b(t),children:[e.jsxs("div",{className:"continue-cover",children:[f[t.id]?e.jsx("img",{src:f[t.id],alt:t.title,className:"book-cover-image"}):e.jsx("div",{className:`book-cover-placeholder ${y[t.id]?"loading":"no-cover"}`,children:y[t.id]?e.jsx("div",{className:"cover-spinner"}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"book-cover-initial",children:(t.title||"?").charAt(0).toUpperCase()}),e.jsx("span",{className:"book-cover-title",children:t.title})]})}),v(t)&&!d&&e.jsx("span",{className:"cloud-badge",title:a("library.cloudOnly"),children:e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{d:"M20 16.58A5 5 0 0018 7h-1.26A8 8 0 104 15.25",strokeLinecap:"round",strokeLinejoin:"round"})})}),!d&&e.jsx(We,{book:t}),!d&&t.file_type==="epub_from_pdf"&&t.conversion_status==="ready"&&i&&qe(t)&&e.jsx("button",{type:"button",className:"book-add-chapters-btn",onClick:_=>{_.stopPropagation(),i(t)},title:a("library.addChapters")||"增加章节",children:e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",children:e.jsx("path",{d:"M12 5v14M5 12h14"})})}),d&&e.jsxs("div",{className:"cloud-download-overlay",children:[e.jsxs("svg",{className:"cloud-download-icon",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("path",{d:"M12 4v12m0 0l-3-3m3 3l3-3",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M20 16.58A5 5 0 0018 7h-1.26A8 8 0 104 15.25",strokeLinecap:"round",strokeLinejoin:"round"})]}),e.jsxs("span",{className:"cloud-download-pct",children:[u,"%"]}),e.jsx("div",{className:"cloud-download-bar",children:e.jsx("div",{className:"cloud-download-fill",style:{width:`${u}%`}})})]})]}),e.jsxs("div",{className:"continue-info",children:[e.jsx("h3",{className:"continue-title",title:t.title,children:t.title}),e.jsxs("div",{className:"continue-progress-row",children:[e.jsx("div",{className:"continue-progress-bar",children:e.jsx("div",{className:"continue-progress-fill",style:{width:`${o}%`}})}),e.jsxs("span",{className:"continue-progress-pct",children:[o,"%"]})]})]})]},t.id)}const nr=oe.memo(tr),vt={zh:"开始阅读后,这里会记录每天的阅读时长","zh-TW":"開始閱讀後,這裡會記錄每天的閱讀時長",en:"Your daily reading time will appear here",fr:"Votre temps de lecture quotidien apparaîtra ici"},wt=30,_t=14;function rr(){const[t,n]=l.useState(()=>typeof window<"u"&&window.innerWidth<480?_t:wt);return l.useEffect(()=>{const s=window.matchMedia("(max-width: 480px)"),c=g=>n(g.matches?_t:wt);return s.addEventListener("change",c),()=>s.removeEventListener("change",c)},[]),t}function ar({bookId:t,language:n}){const[s,c]=l.useState([]),[g,f]=l.useState(!1),[y,a]=l.useState(null),v=l.useRef(null),b=rr(),i=l.useMemo(()=>gn()||!matchMedia("(hover: hover)").matches,[]);l.useEffect(()=>{if(!t)return;let j=!1;return ne.getBookDailyStats(t).then(m=>{var C;j||((C=m==null?void 0:m.days)!=null&&C.length&&c(m.days),f(!0))}),()=>{j=!0}},[t]);const M=l.useMemo(()=>s.slice(-b),[s,b]),o=l.useCallback((j,m)=>{const C=new Date(j+"T12:00:00"),$=Math.max(1,Math.round(m/6e4));return n==="zh"||n==="zh-TW"?`${C.getFullYear()}年${C.getMonth()+1}月${C.getDate()}日,${$}分钟`:n==="fr"?`${C.getDate()}/${C.getMonth()+1}/${C.getFullYear()}, ${$} min`:`${["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][C.getMonth()]} ${C.getDate()}, ${C.getFullYear()}, ${$} min`},[n]),d=l.useCallback((j,m)=>{var L;
2const C=j.currentTarget;if(!C)return;const $=C.getBoundingClientRect(),A=(L=v.current)==null?void 0:L.getBoundingClientRect();A&&a({date:m.date,text:o(m.date,m.total_ms),x:$.left+$.width/2-A.left,y:$.top-A.top-6})},[o]),u=i?void 0:(j,m)=>d(j,m),_=i?void 0:()=>a(null),D=l.useCallback((j,m)=>{var A;if(j.stopPropagation(),!i)return;const C=j.currentTarget.getBoundingClientRect(),$=(A=v.current)==null?void 0:A.getBoundingClientRect();a(L=>(L==null?void 0:L.date)===m.date||!$?null:{date:m.date,text:o(m.date,m.total_ms),x:C.left+C.width/2-$.left,y:C.top-$.top-6})},[i,o]),x=l.useCallback(j=>{j.stopPropagation()},[]);if(!M.length)return g?e.jsx("div",{className:"book-daily-chart book-daily-chart-empty",onClick:x,children:e.jsx("p",{className:"book-daily-chart-empty-text",children:vt[n]||vt.en})}):null;const S=Math.max(...M.map(j=>j.total_ms),1);return e.jsxs("div",{className:"book-daily-chart",ref:v,onClick:x,children:[y&&e.jsx("div",{className:"book-daily-chart-tooltip",style:{left:y.x,top:y.y},children:y.text}),e.jsx("div",{className:"book-daily-chart-bars",children:M.map(j=>{const m=Math.max(8,j.total_ms/S*100);return e.jsx("div",{className:`book-daily-chart-bar${(y==null?void 0:y.date)===j.date?" active":""}`,style:{height:`${m}%`},onMouseEnter:u?C=>u(C,j):void 0,onMouseLeave:_,onClick:C=>D(C,j)},j.date)})})]})}const sr=oe.memo(ar);function or(){const[t,n]=l.useState(null),[s,c]=l.useState(null),[g,f]=l.useState(!0),[y,a]=l.useState(null),v=l.useRef(!1),b=l.useCallback(async()=>{try{f(!0),a(null);const[u,_]=await Promise.allSettled([ne.getDashboard(),ne.getHeatmap()]);if(u.status==="fulfilled"&&u.value)n(u.value);else if(u.status==="rejected")throw u.reason;_.status==="fulfilled"&&_.value&&c(_.value.days||[])}catch(u){a(u.message)}finally{f(!1)}},[]);l.useEffect(()=>{v.current||(v.current=!0,b())},[b]);const i=l.useCallback(()=>{b()},[b]),M=l.useCallback(u=>{ne.ackMilestone(u),n(_=>_&&{..._,new_milestones:(_.new_milestones||[]).filter(D=>D.key!==u)})},[]),o=l.useCallback(async u=>{const _=await ne.setYearlyGoal(u);return n(D=>{var x;return D&&{...D,yearly_goal:{...D.yearly_goal,..._.goal,current_words:((x=D.yearly_goal)==null?void 0:x.current_words)||0}}}),_},[]),d=l.useCallback(async({days:u,minutes:_,yearlyTarget:D})=>{const x={reading_goal_days:u,reading_goal_minutes:_};D&&(x.yearly_target=D);const S=await ne.updateSettings(x);if(S.error_code==="GOAL_EDIT_EXHAUSTED"){const j=new Error("GOAL_EDIT_EXHAUSTED");throw j.code="GOAL_EDIT_EXHAUSTED",j}n(j=>{var C;if(!j)return j;const m={...j,week:{...j.week,goal_days:u,goal_minutes:_},goal_edit_remaining:S.remaining??j.goal_edit_remaining};return S.goal&&(m.yearly_goal={...j.yearly_goal,...S.goal,current_words:((C=j.yearly_goal)==null?void 0:C.current_words)||0}),m})},[]);return{data:t,heatmap:s,loading:g,error:y,refresh:i,ackMilestone:M,setYearlyGoal:o,saveGoal:d}}const Se=[{id:"en_001",lang:"en",text:"To be, or not to be, that is the question: Whether 'tis nobler in the mind to suffer the slings and arrows of outrageous fortune, or to take arms against a sea of troubles, and by opposing end them.",author:"William Shakespeare",source:"Hamlet",genre:"drama"},{id:"en_002",lang:"en",text:"All the world's a stage, and all the men and women merely players. They have their exits and their entrances; and one man in his time plays many parts.",author:"William Shakespeare",source:"As You Like It",genre:"drama"},{id:"en_005",lang:"en",text:"We are such stuff as dreams are made on, and our little life is rounded with a sleep.",author:"William Shakespeare",source:"The Tempest",genre:"drama"},{id:"en_007",lang:"en",text:"There is nothing either good or bad, but thinking makes it so.",author:"William Shakespeare",source:"Hamlet",genre:"drama"},{id:"en_009",lang:"en",text:"I declare after all there is no enjoyment like reading! How much sooner one tires of anything than of a book!",author:"Jane Austen",source:"Pride and Prejudice",genre:"fiction"},{id:"en_012",lang:"en",text:"Seldom, very seldom, does complete truth belong to any human disclosure; seldom can it happen that something is not a little disguised or a little mistaken.",author:"Jane Austen",source:"Emma",genre:"fiction"},{id:"en_013",lang:"en",text:"Know your own happiness. You want nothing but patience — or give it a more fascinating name, call it hope.",author:"Jane Austen",source:"Sense and Sensibility",genre:"fiction"},{id:"en_014",lang:"en",text:"It was the best of times, it was the worst of times, it was the age of wisdom, it was the age of foolishness.",author:"Charles Dickens",source:"A Tale of Two Cities",genre:"fiction"},{id:"en_015",lang:"en",text:"It is a far, far better thing that I do, than I have ever done; it is a far, far better rest that I go to than I have ever known.",author:"Charles Dickens",source:"A Tale of Two Cities",genre:"fiction"},{id:"en_016",lang:"en",text:"Suffering has been stronger than all other teaching, and has taught me to understand what your heart used to be. I have been bent and broken, but — I hope — into a better shape.",author:"Charles Dickens",source:"Great Expectations",genre:"fiction"},{id:"en_017",lang:"en",text:"There are books of which the backs and covers are by far the best parts.",author:"Charles Dickens",source:"Oliver Twist",genre:"fiction"},{id:"en_018",lang:"en",text:"Whether I shall turn out to be the hero of my own life, or whether that station will be held by anybody else, these pages must show.",author:"Charles Dickens",source:"David Copperfield",genre:"fiction"},{id:"en_019",lang:"en",text:"Have a heart that never hardens, and a temper that never tires, and a touch that never hurts.",author:"Charles Dickens",source:"Our Mutual Friend",genre:"fiction"},{id:"en_020",lang:"en",text:"The world breaks everyone and afterward many are strong at the broken places.",author:"Ernest Hemingway",source:"A Farewell to Arms",genre:"fiction"},{id:"en_021",lang:"en",text:"But man is not made for defeat. A man can be destroyed but not defeated.",author:"Ernest Hemingway",source:"The Old Man and the Sea",genre:"fiction"},{id:"en_022",lang:"en",text:"There is nothing noble in being superior to your fellow man; true nobility is being superior to your former self.",author:"Ernest Hemingway",source:"The Sun Also Rises",genre:"fiction"},{id:"en_023",lang:"en",text:"Every day is a new day. It is better to be lucky. But I would rather be exact. Then when luck comes you are ready.",author:"Ernest Hemingway",source:"The Old Man and the Sea",genre:"fiction"},{id:"en_025",lang:"en",text:"So we beat on, boats against the current, borne back ceaselessly into the past.",author:"F. Scott Fitzgerald",source:"The Great Gatsby",genre:"fiction"},{id:"en_026",lang:"en",text:`In my younger and more vulnerable years my father gave me some advice that I've been turning over in my mind ever since. "Whenever you feel like criticizing anyone," he told me, "just remember that all the people in this world haven't had the advantages that you've had."`,author:"F. Scott Fitzgerald",source:"The Great Gatsby",genre:"fiction"},{id:"en_029",lang:"en",text:"The test of a first-rate intelligence is the ability to hold two opposed ideas in mind at the same time and still retain the ability to function.",author:"F. Scott Fitzgerald",source:"The Crack-Up",genre:"essay"},{id:"en_030",lang:"en",text:"Who controls the past controls the future. Who controls the present controls the past.",author:"George Orwell",source:"1984",genre:"fiction"},{id:"en_031",lang:"en",text:"All animals are equal, but some animals are more equal than others.",author:"George Orwell",source:"Animal Farm",genre:"fiction"},{id:"en_032",lang:"en",text:"In a time of deceit telling the truth is a revolutionary act.",author:"George Orwell",source:"1984",genre:"fiction"},{id:"en_033",lang:"en",text:"Perhaps one did not want to be loved so much as to be understood.",author:"George Orwell",source:"1984",genre:"fiction"},{id:"en_036",lang:"en",text:"You cannot find peace by avoiding life.",author:"Virginia Woolf",source:"The Hours",genre:"fiction"},{id:"en_037",lang:"en",text:"For now she need not think of anybody. She could be herself, by herself. And that was what now she often felt the need of — to think; well, not even to think. To be silent; to be alone.",author:"Virginia Woolf",source:"To the Lighthouse",genre:"fiction"},{id:"en_038",lang:"en",text:"A woman must have money and a room of her own if she is to write fiction.",author:"Virginia Woolf",source:"A Room of One's Own",genre:"essay"},{id:"en_040",lang:"en",text:"I have dreamt in my life, dreams that have stayed with me ever after, and changed my ideas; they have gone through and through me, like wine through water, and altered the colour of my mind.",author:"Emily Brontë",source:"Wuthering Heights",genre:"fiction"},{id:"en_041",lang:"en",text:"I am no bird; and no net ensnares me: I am a free human being with an independent will.",author:"Charlotte Brontë",source:"Jane Eyre",genre:"fiction"},{id:"en_042",lang:"en",text:"I would always rather be happy than dignified.",author:"Charlotte Brontë",source:"Jane Eyre",genre:"fiction"},{id:"en_043",lang:"en",text:"Not all those who wander are lost.",author:"J.R.R. Tolkien",source:"The Fellowship of the Ring",genre:"fiction"},{id:"en_045",lang:"en",text:"Even the smallest person can change the course of the future.",author:"J.R.R. Tolkien",source:"The Fellowship of the Ring",genre:"fiction"},{id:"en_046",lang:"en",text:"Whenever you find yourself on the side of the majority, it is time to pause and reflect.",author:"Mark Twain",source:"Notebook",genre:"essay"},{id:"en_047",lang:"en",text:"The two most important days in your life are the day you are born and the day you find out why.",author:"Mark Twain",source:"Attributed",genre:"essay"},{id:"en_048",lang:"en",text:"Travel is fatal to prejudice, bigotry, and narrow-mindedness, and many of our people need it sorely on these accounts.",author:"Mark Twain",source:"The Innocents Abroad",genre:"essay"},{id:"en_049",lang:"en",text:"All you need in this life is ignorance and confidence, and then success is sure.",author:"Mark Twain",source:"Letter to Mrs. Foote",genre:"essay"},{id:"en_050",lang:"en",text:"To live is the rarest thing in the world. Most people exist, that is all.",author:"Oscar Wilde",source:"The Soul of Man under Socialism",genre:"essay"},{id:"en_051",lang:"en",text:"Be yourself; everyone else is already taken.",author:"Oscar Wilde",source:"Attributed",genre:"essay"},{id:"en_053",lang:"en",text:"We are all in the gutter, but some of us are looking at the stars.",author:"Oscar Wilde",source:"Lady Windermere's Fan",genre:"drama"},{id:"en_054",lang:"en",text:"Experience is simply the name we give our mistakes.",author:"Oscar Wilde",source:"The Picture of Dorian Gray",genre:"fiction"},{id:"en_059",lang:"en",text:"Hope is the thing with feathers that perches in the soul, and sings the tune without the words, and never stops at all.",author:"Emily Dickinson",source:"Hope is the thing with feathers",genre:"poetry"},{id:"en_060",lang:"en",text:"I dwell in Possibility — a fairer House than Prose — more numerous of Windows — superior — for Doors.",author:"Emily Dickinson",source:"I dwell in Possibility",genre:"poetry"},{id:"en_062",lang:"en",text:"Tell all the truth but tell it slant — Success in Circuit lies.",author:"Emily Dickinson",source:"Tell all the truth but tell it slant",genre:"poetry"},{id:"en_063",lang:"en",text:"I am large, I contain multitudes.",author:"Walt Whitman",source:"Song of Myself",genre:"poetry"},{id:"en_065",lang:"en",text:"Keep your face always toward the sunshine — and shadows will fall behind you.",author:"Walt Whitman",source:"Leaves of Grass",genre:"poetry"},{id:"en_067",lang:"en",text:"It is not down on any map; true places never are.",author:"Herman Melville",source:"Moby-Dick",genre:"fiction"},{id:"en_068",lang:"en",text:"As for me, I am tormented with an everlasting itch for things remote. I love to sail forbidden seas, and land on barbarous coasts.",author:"Herman Melville",source:"Moby-Dick",genre:"fiction"},{id:"en_069",lang:"en",text:"If you surrendered to the air, you could ride it.",author:"Toni Morrison",source:"Song of Solomon",genre:"fiction"},{id:"en_070",lang:"en",text:"You wanna fly, you got to give up the shit that weighs you down.",author:"Toni Morrison",source:"Song of Solomon",genre:"fiction"},{id:"en_071",lang:"en",text:"Freeing yourself was one thing, claiming ownership of that freed self was another.",author:"Toni Morrison",source:"Beloved",genre:"fiction"},{id:"en_072",lang:"en",text:"You never really understand a person until you consider things from his point of view — until you climb into his skin and walk around in it.",author:"Harper Lee",source:"To Kill a Mockingbird",genre:"fiction"},{id:"en_073",lang:"en",text:"People generally see what they look for, and hear what they listen for.",author:"Harper Lee",source:"To Kill a Mockingbird",genre:"fiction"},{id:"en_074",lang:"en",text:"The one thing that doesn't abide by majority rule is a person's conscience.",author:"Harper Lee",source:"To Kill a Mockingbird",genre:"fiction"},{id:"en_075",lang:"en",text:"You don't have to burn books to destroy a culture. You just have to get people to stop reading them.",author:"Ray Bradbury",source:"Fahrenheit 451",genre:"fiction"},{id:"en_076",lang:"en",text:"Stuff your eyes with wonder. Live as if you'd drop dead in ten seconds. See the world. It's more fantastic than any dream made or paid for in factories.",author:"Ray Bradbury",source:"Fahrenheit 451",genre:"fiction"},{id:"en_077",lang:"en",text:"There must be something in books, something we can't imagine, to make a woman stay in a burning house.",author:"Ray Bradbury",source:"Fahrenheit 451",genre:"fiction"},{id:"en_079",lang:"en",text:"We are what we pretend to be, so we must be careful about what we pretend to be.",author:"Kurt Vonnegut",source:"Mother Night",genre:"fiction"},{id:"en_081",lang:"en",text:"I took a deep breath and listened to the old brag of my heart. I am, I am, I am.",author:"Sylvia Plath",source:"The Bell Jar",genre:"fiction"},{id:"en_083",lang:"en",text:"Perhaps when we find ourselves wanting everything, it is because we are dangerously close to wanting nothing.",author:"Sylvia Plath",source:"The Bell Jar",genre:"fiction"},{id:"en_084",lang:"en",text:"I went to the woods because I wished to live deliberately, to front only the essential facts of life, and see if I could not learn what it had to teach, and not, when I came to die, discover that I had not lived.",author:"Henry David Thoreau",source:"Walden",genre:"philosophy"},{id:"en_085",lang:"en",text:"How vain it is to sit down to write when you have not stood up to live.",author:"Henry David Thoreau",source:"Journal",genre:"essay"},{id:"en_086",lang:"en",text:"To be yourself in a world that is constantly trying to make you something else is the greatest accomplishment.",author:"Ralph Waldo Emerson",
2source:"Self-Reliance",genre:"philosophy"},{id:"en_087",lang:"en",text:"What lies behind us and what lies before us are tiny matters compared to what lies within us.",author:"Ralph Waldo Emerson",source:"Self-Reliance",genre:"philosophy"},{id:"en_088",lang:"en",text:"And now that you don't have to be perfect, you can be good.",author:"John Steinbeck",source:"East of Eden",genre:"fiction"},{id:"en_089",lang:"en",text:"I wonder how many people I've looked at all my life and never seen.",author:"John Steinbeck",source:"The Winter of Our Discontent",genre:"fiction"},{id:"en_090",lang:"en",text:"The past is never dead. It's not even past.",author:"William Faulkner",source:"Requiem for a Nun",genre:"fiction"},{id:"en_092",lang:"en",text:"Nothing is so painful to the human mind as a great and sudden change.",author:"Mary Shelley",source:"Frankenstein",genre:"fiction"},{id:"en_093",lang:"en",text:"Beware; for I am fearless, and therefore powerful.",author:"Mary Shelley",source:"Frankenstein",genre:"fiction"},{id:"en_094",lang:"en",text:"It's no use going back to yesterday, because I was a different person then.",author:"Lewis Carroll",source:"Alice's Adventures in Wonderland",genre:"fiction"},{id:"en_095",lang:"en",text:"Two roads diverged in a wood, and I — I took the one less traveled by, and that has made all the difference.",author:"Robert Frost",source:"The Road Not Taken",genre:"poetry"},{id:"en_096",lang:"en",text:"In three words I can sum up everything I've learned about life: it goes on.",author:"Robert Frost",source:"Attributed",genre:"poetry"},{id:"en_097",lang:"en",text:"Hold fast to dreams, for if dreams die, life is a broken-winged bird that cannot fly.",author:"Langston Hughes",source:"Dreams",genre:"poetry"},{id:"en_098",lang:"en",text:"We shall not cease from exploration, and the end of all our exploring will be to arrive where we started and know the place for the first time.",author:"T.S. Eliot",source:"Four Quartets",genre:"poetry"},{id:"en_099",lang:"en",text:"There is no greater agony than bearing an untold story inside you.",author:"Maya Angelou",source:"I Know Why the Caged Bird Sings",genre:"fiction"},{id:"en_100",lang:"en",text:"Not everything that is faced can be changed, but nothing can be changed until it is faced.",author:"James Baldwin",source:"The Cross of Redemption",genre:"essay"},{id:"en_101",lang:"en",text:"Missing one workout happens, but I'm not going to miss two in a row. I can't be perfect, but I can avoid a second lapse.",author:"James Clear",source:"Atomic Habits",genre:"essay"},{id:"en_102",lang:"en",text:"Good habits make time your ally. Bad habits make time your enemy.",author:"James Clear",source:"Atomic Habits",genre:"essay"},{id:"en_103",lang:"en",text:"The most powerful outcomes of any compounding process are delayed. You need to be patient.",author:"James Clear",source:"Atomic Habits",genre:"essay"},{id:"en_104",lang:"en",text:"A slight change in your daily habits can guide your life to a very different destination.",author:"James Clear",source:"Atomic Habits",genre:"essay"},{id:"en_105",lang:"en",text:"Every action you take is a vote for the type of person you wish to become.",author:"James Clear",source:"Atomic Habits",genre:"essay"},{id:"en_106",lang:"en",text:"The goal is not to read a book, the goal is to become a reader.",author:"James Clear",source:"Atomic Habits",genre:"essay"},{id:"en_107",lang:"en",text:"It's hard to change your habits if you never change the underlying beliefs that led to your past behavior.",author:"James Clear",source:"Atomic Habits",genre:"essay"},{id:"en_108",lang:"en",text:"You have to learn to fall in love with boredom.",author:"James Clear",source:"Atomic Habits",genre:"essay"},{id:"en_109",lang:"en",text:"The only way to become excellent is to be endlessly fascinated by doing the same thing over and over.",author:"James Clear",source:"Atomic Habits",genre:"essay"},{id:"en_110",lang:"en",text:"The most effective way to change your habits is to join a culture where your desired behavior is the normal behavior.",author:"James Clear",source:"Atomic Habits",genre:"essay"},{id:"en_111",lang:"en",text:"Read what you love until you love to read.",author:"Naval Ravikant",source:"The Almanack of Naval Ravikant",genre:"essay"},{id:"en_112",lang:"en",text:"All the real benefits in life come from compound interest.",author:"Naval Ravikant",source:"The Almanack of Naval Ravikant",genre:"essay"},{id:"en_113",lang:"en",text:"Intentions don't matter. Actions do.",author:"Naval Ravikant",source:"The Almanack of Naval Ravikant",genre:"essay"},{id:"en_114",lang:"en",text:"We are what we repeatedly do. Excellence, then, is not an act, but a habit.",author:"Will Durant",source:"The Story of Philosophy",genre:"philosophy"},{id:"en_115",lang:"en",text:"Motivation is what gets you started. Habit is what keeps you going.",author:"Jim Ryun",source:"Attributed",genre:"essay"},{id:"en_116",lang:"en",text:"Don't let the noise of others' opinions drown out your own inner voice.",author:"Steve Jobs",source:"Stanford Commencement Speech",genre:"essay"},{id:"en_117",lang:"en",text:"Your time is limited, don't waste it living someone else's life.",author:"Steve Jobs",source:"Stanford Commencement Speech",genre:"essay"},{id:"en_118",lang:"en",text:"Success is the sum of small efforts, repeated day in and day out.",author:"Robert C
2ollier",source:"Attributed",genre:"essay"},{id:"en_119",lang:"en",text:"You are never too old to set another goal or to dream a new dream.",author:"C.S. Lewis",source:"Attributed",genre:"essay"},{id:"en_120",lang:"en",text:"Turn your wounds into wisdom.",author:"Oprah Winfrey",source:"Attributed",genre:"essay"},{id:"en_121",lang:"en",text:"Opportunities don't happen. You create them.",author:"Chris Grosser",source:"Attributed",genre:"essay"},{id:"en_122",lang:"en",text:"The secret of getting ahead is getting started.",author:"Mark Twain",source:"Attributed",genre:"essay"},{id:"en_123",lang:"en",text:"Believe you can and you're halfway there.",author:"Theodore Roosevelt",source:"Attributed",genre:"essay"},{id:"en_124",lang:"en",text:"Do one thing every day that scares you.",author:"Eleanor Roosevelt",source:"Attributed",genre:"essay"},{id:"en_125",lang:"en",text:"Better to light a candle than curse the darkness.",author:"Eleanor Roosevelt",source:"Attributed",genre:"essay"},{id:"en_126",lang:"en",text:`Nothing is impossible; the word itself says "I'm possible"!`,author:"Audrey Hepburn",source:"Attributed",genre:"essay"},{id:"en_127",lang:"en",text:"The reading of all good books is like a conversation with the finest minds of past centuries.",author:"René Descartes",source:"Discourse on the Method",genre:"philosophy"},{id:"en_128",lang:"en",text:"The biggest risk is not taking any risk.",author:"Mark Zuckerberg",source:"Attributed",genre:"essay"},{id:"en_129",lang:"en",text:"You don't have to be great to start, but you have to start to be great.",author:"Zig Ziglar",source:"Attributed",genre:"essay"},{id:"en_130",lang:"en",text:"Be the change that you wish to see in the world.",author:"Mahatma Gandhi",source:"Attributed",genre:"philosophy"},{id:"en_131",lang:"en",text:"She was still too young to know that life never gives anything for nothing, and that a price is always paid for what fate bestows.",author:"Stefan Zweig",source:"Marie Antoinette",genre:"fiction"},{id:"en_132",lang:"en",text:"What is once well done is done forever.",author:"Henry David Thoreau",source:"Journal",genre:"essay"},{id:"en_133",lang:"en",text:"He who has a why to live can bear almost any how.",author:"Friedrich Nietzsche",source:"Twilight of the Idols",genre:"philosophy"},{id:"en_134",lang:"en",text:"The struggle itself toward the heights is enough to fill a man's heart.",author:"Albert Camus",source:"The Myth of Sisyphus",genre:"philosophy"},{id:"en_135",lang:"en",text:"I am not what happened to me, I am what I choose to become.",author:"Carl Jung",source:"Attributed",genre:"philosophy"},{id:"zh_001",lang:"zh",text:"满纸荒唐言,一把辛酸泪。都云作者痴,谁解其中味。",author:"曹雪芹",source:"红楼梦",genre:"fiction"},{id:"zh_002",lang:"zh",text:"世事洞明皆学问,人情练达即文章。",author:"曹雪芹",source:"红楼梦",genre:"fiction"},{id:"zh_003",lang:"zh",text:"假作真时真亦假,无为有处有还无。",author:"曹雪芹",source:"红楼梦",genre:"fiction"},{id:"zh_005",lang:"zh",text:"质本洁来还洁去,强于污淖陷渠沟。",author:"曹雪芹",source:"红楼梦",genre:"fiction"},{id:"zh_006",lang:"zh",text:"黄金万两容易得,知心一个也难求。",author:"曹雪芹",source:"红楼梦",genre:"fiction"},{id:"zh_007",lang:"zh",text:"横眉冷对千夫指,俯首甘为孺子牛。",author:"鲁迅",source:"自嘲",genre:"poetry"},{id:"zh_008",lang:"zh",text:"不在沉默中爆发,就在沉默中灭亡。",author:"鲁迅",source:"记念刘和珍君",genre:"essay"},{id:"zh_009",lang:"zh",text:"其实地上本没有路,走的人多了,也便成了路。",author:"鲁迅",source:"故乡",genre:"fiction"},{id:"zh_010",lang:"zh",text:"真的猛士,敢于直面惨淡的人生,敢于正视淋漓的鲜血。",author:"鲁迅",source:"记念刘和珍君",genre:"essay"},{id:"zh_013",lang:"zh",text:"雨下给富人,也下给穷人;下给义人,也下给不义的人。其实,雨并不公道,因为下落在一个没有公道的世界上。",author:"è€
2èˆ",source:"骆驼祥子",genre:"fiction"},{id:"zh_014",lang:"zh",text:"生活是种律动,须有光有影,有左有右,有晴有雨,趣味就在这变而不猛的曲折里。",author:"老舍",source:"小病",genre:"essay"},{id:"zh_015",lang:"zh",text:"才华是刀刃,辛苦是磨刀石,再锋利的刀刃,若日久不磨,也会生锈。",author:"老舍",source:"老舍散文",genre:"essay"},{id:"zh_021",lang:"zh",text:"日头没有辜负我们,我们也切莫辜负日头。",author:"沈从文",source:"边城",genre:"fiction"},{id:"zh_022",lang:"zh",text:"因为懂得,所以慈悲。",author:"张爱玲",source:"倾城之恋",genre:"fiction"},{id:"zh_028",lang:"zh",text:"天下只有两种人。比如一串葡萄到手,一种人挑最好的先吃,另一种人把最好的留到最后吃。照例第一种人应该乐观,因为他每吃一颗都是吃剩的葡萄里最好的;第二种人应该悲观。不过事实却适得其反。",author:"钱钟书",source:"围城",genre:"fiction"},{id:"zh_031",lang:"zh",text:"我们曾如此渴望命运的波澜,到最后才发现,人生最曼妙的风景,竟是内心的淡定与从容。",author:"杨绛",source:"一百岁感言",genre:"essay"},{id:"zh_032",lang:"zh",text:"你的问题主要在于读书不多而想得太多。",author:"杨绛",source:"杨绛文集",genre:"essay"},{id:"zh_034",lang:"zh",text:"我和谁都不争,和谁争我都不屑。",author:"杨绛",source:"杨绛散文",genre:"essay"},{id:"zh_035",lang:"zh",text:"人是为活着本身而活着的,而不是为了活着之外的任何事物所活着。",author:"余华",source:"活着",genre:"fiction"},{id:"zh_036",lang:"zh",text:"以笑的方式哭,在死亡的伴随下活着。",author:"余华",source:"活着",genre:"fiction"},{id:"zh_037",lang:"zh",text:"没有什么比时间更具有说服力了,因为时间无需通知我们就可以改变一切。",author:"余华",source:"活着",genre:"fiction"},{id:"zh_039",lang:"zh",text:"世界上的事情,最忌讳的就是个十全十美,你看那天上的月亮,一旦圆满了,马上就要亏厌。",author:"莫言",source:"檀香刑",genre:"fiction"},{id:"zh_040",lang:"zh",text:"文学和科学相比较,的确没什么用处,但文学最大的用处,也许就是它没有用处。",author:"莫言",source:"诺贝尔文学奖演讲",genre:"essay"},{id:"zh_042",lang:"zh",text:"人生不过如此,且行且珍惜。自己永远是自己的主角,不要总在别人的戏剧里充当着配角。",author:"林语堂",source:"人生不过如此",genre:"essay"},{id:"zh_043",lang:"zh",text:"孤独这两个字拆开来看,有孩童,有瓜果,有小犬,有蝴蝶。足以撑起一个盛夏傍晚的巷口,人情味十足。",author:"林语堂",source:"林语堂散文",genre:"essay"},{id:"zh_044",lang:"zh",text:"读书使人得到一种优雅和风味,这就是读书的整个目的,而只有抱着这种目的的读书才可以叫做艺术。",author:"林语堂",source:"生活的艺术",genre:"essay"},{id:"zh_045",lang:"zh",text:"那一天我二十一岁,在我一生的黄金时代,我有好多奢望。我想爱,想吃,还想在一瞬间变成天上半明半暗的云。",author:"王小波",source:"黄金时代",genre:"fiction"},{id:"zh_047",lang:"zh",text:"一个人只拥有此生此世是不够的,他还应该拥有诗意的世界。",author:"王小波",source:"万寿寺",genre:"fiction"},{id:"zh_048",lang:"zh",text:"大江东去,浪淘尽,千古风流人物。",author:"苏轼",source:"念奴娇·赤壁怀古",genre:"poetry"},{id:"zh_050",lang:"zh",text:"人生如逆旅,我亦是行人。",author:"苏轼",source:"临江仙·送钱穆父",genre:"poetry"},{id:"zh_051",lang:"zh",text:"竹杖芒鞋轻胜马,谁怕?一蓑烟雨任平生。",author:"苏轼",source:"定风波",genre:"poetry"},{id:"zh_052",lang:"zh",text:"回首向来萧瑟处,归去,也无风雨也无晴。",author:"苏轼",source:"定风波",genre:"poetry"},{id:"zh_053",lang:"zh",text:"长风破浪会有时,直挂云帆济沧海。",author:"李白",source:"行路难",genre:"poetry"},{id:"zh_055",lang:"zh",text:"天生我材必有用,千金散尽还复来。",author:"李白",source:"将进酒",genre:"poetry"},{id:"zh_057",lang:"zh",text:"两岸猿声啼不住,轻舟已过万重山。",author:"李白",source:"早发白帝城",genre:"poetry"},{id:"zh_058",lang:"zh",text:"会当凌绝顶,一览众山小。",author:"杜甫",source:"望岳",genre:"poetry"},{id:"zh_059",lang:"zh",text:"安得广厦千万间,大庇天下寒士俱欢颜。",author:"杜甫",source:"茅屋为秋风所破歌",genre:"poetry"},{id:"zh_060",lang:"zh",text:"读书破万卷,下笔如有神。",author:"杜甫",source:"奉赠韦左丞丈二十二韵",genre:"poetry"},{id:"zh_062",lang:"zh",text:"生当作人杰,死亦为鬼雄。",author:"李清照",source:"夏日绝句",genre:"poetry"},{id:"zh_065",lang:"zh",text:"采菊东篱下,悠然见南山。",author:"陶渊明",source:"饮酒·其五",genre:"poetry"},{id:"zh_066",lang:"zh",text:"盛年不重来,一日难再晨。及时当勉励,岁月不待人。",author:"陶渊明",source:"杂诗",genre:"poetry"},{id:"zh_067",lang:"zh",text:"纵浪大化中,不喜亦不惧。应尽便须尽,无复独多虑。",author:"陶渊明",source:"形影神三首",genre:"poetry"},{id:"zh_070",lang:"zh",text:"山一程,水一程,身向榆关那畔行,夜深千帐灯。",author:"纳兰性德",source:"长相思",genre:"poetry"},{id:"zh_071",lang:"zh",text:"我不配做一盏灯,那么就让我做一块木柴吧,我愿意把我从太阳那里受到的热放散出来。",author:"巴金",source:"å®¶",genre:"fiction"},{id:"zh_072",lang:"zh",text:"光辉的理想像明净的水一样洗去我心灵上的尘垢。",author:"巴金",source:"å®¶",genre:"fiction"},{id:"zh_073",lang:"zh",text:"燕子去了,有再来的时候;杨柳枯了,有再青的时候;桃花谢了,有再开的时候。但是,聪明的,你告诉我ï¼
2Œæˆ‘们的日子为什么一去不复返呢?",author:"朱自清",source:"匆匆",genre:"essay"},{id:"zh_074",lang:"zh",text:"从此我不再仰脸看青天,不再低头看白水,只谨慎着我双双的脚步,我要一步一步踏在泥土上,打上深深的脚印!",author:"朱自清",source:"毁灭",genre:"poetry"},{id:"zh_075",lang:"zh",text:"墙角的花!你孤芳自赏时,天地便小了。",author:"冰心",source:"繁星·春水",genre:"poetry"},{id:"zh_076",lang:"zh",text:"爱在左,同情在右,走在生命路的两旁,随时撒种,随时开花。",author:"冰心",source:"寄小读者",genre:"essay"},{id:"zh_079",lang:"zh",text:"生活不能等待别人来安排,要自己去争取和奋斗;而不论其结果是喜是悲,但可以慰藉的是,你总不枉在这世界上活了一场。",author:"路遥",source:"平凡的世界",genre:"fiction"},{id:"zh_080",lang:"zh",text:"人们宁愿去关心一个蹩脚电影演员的吃喝拉撒和鸡毛蒜皮,而不愿了解一个普通人波涛汹涌的内心世界。",author:"路遥",source:"平凡的世界",genre:"fiction"},{id:"zh_081",lang:"zh",text:"死是一件不必急于求成的事,死是一个必然会降临的节日。",author:"史铁生",source:"我与地坛",genre:"essay"},{id:"zh_084",lang:"zh",text:"岁月不饶人,我亦未曾饶过岁月。",author:"木心",source:"云雀叫了一整天",genre:"poetry"},{id:"zh_085",lang:"zh",text:"自然是伟大的,人类是伟大的,然而充满了崇高精神的人类的活动,乃是伟大中之尤其伟大者。",author:"茅盾",source:"白杨礼赞",genre:"essay"},{id:"zh_086",lang:"zh",text:"众里寻他千百度,蓦然回首,那人却在,灯火阑珊处。",author:"辛弃疾",source:"青玉案·元夕",genre:"poetry"},{id:"zh_087",lang:"zh",text:"少年不识愁滋味,爱上层楼。爱上层楼,为赋新词强说愁。",author:"辛弃疾",source:"丑奴儿·书博山道中壁",genre:"poetry"},{id:"zh_088",lang:"zh",text:"行到水穷处,坐看云起时。",author:"王维",source:"终南别业",genre:"poetry"},{id:"zh_090",lang:"zh",text:"衣带渐宽终不悔,为伊消得人憔悴。",author:"柳永",source:"蝶恋花",genre:"poetry"},{id:"zh_091",lang:"zh",text:"人的一生,苦也罢,乐也罢;得也罢,失也罢。要紧的是心间的一泓清泉里不能没有月辉。",author:"贾平凹",source:"自在独行",genre:"essay"},{id:"zh_092",lang:"zh",text:"不乱于心,不困于情。不畏将来,不念过往。如此,安好。",author:"丰子恺",source:"不宠无惊过一生",genre:"essay"},{id:"zh_094",lang:"zh",text:"如果有来生,要做一棵树,站成永恒,没有悲欢的姿势。一半在尘土里安详,一半在风里飞扬。",author:"三毛",source:"说给自己听",genre:"essay"},{id:"zh_095",lang:"zh",text:"每个人都争取一个完满的人生。然而,自古及今,海内海外,一个百分之百完满的人生是没有的。",author:"季羡林",source:"不完满才是人生",genre:"essay"},{id:"zh_097",lang:"zh",text:"同是天涯沦落人,相逢何必曾相识。",author:"白居易",source:"琵琶行",genre:"poetry"},{id:"zh_098",lang:"zh",text:"沉舟侧畔千帆过,病树前头万木春。",author:"刘禹锡",source:"酬乐天扬州初逢席上见赠",genre:"poetry"},{id:"zh_099",lang:"zh",text:"落红不是无情物,化作春泥更护花。",author:"龚自珍",source:"己亥杂诗",genre:"poetry"},{id:"zh_100",lang:"zh",text:"山重水复疑无路,柳暗花明又一村。",author:"陆游",source:"游山西村",genre:"poetry"},{id:"zh_101",lang:"zh",text:"我要有能做我自己的自由,和敢做我自己的胆量。",author:"林语堂",source:"林语堂散文",genre:"essay"},{id:"zh_102",lang:"zh",text:"靡不有初,鲜克有终。",author:"诗经",source:"大雅·荡",genre:"poetry"},{id:"zh_103",lang:"zh",text:"腹有诗书气自华。",author:"苏轼",source:"和董传留别",genre:"poetry"},{id:"zh_104",lang:"zh",text:"日拱一卒,功不唐捐。",author:"俗语",source:"民间谚语",genre:"philosophy"},{id:"zh_105",lang:"zh",text:"不自见,故明;不自是,故彰;不自伐,故有功;不自矜,故长。",author:"è€
2å­",source:"道德经·第二十二章",genre:"philosophy"},{id:"zh_106",lang:"zh",text:"学而不思则罔,思而不学则殆。",author:"孔子",source:"论语·为政",genre:"philosophy"},{id:"zh_107",lang:"zh",text:"知之者不如好之者,好之者不如乐之者。",author:"孔子",source:"论语·雍也",genre:"philosophy"},{id:"zh_108",lang:"zh",text:"三人行,必有我师焉。择其善者而从之,其不善者而改之。",author:"孔子",source:"论语·述而",genre:"philosophy"},{id:"zh_109",lang:"zh",text:"天行健,君子以自强不息。",author:"周易",source:"乾卦·象传",genre:"philosophy"},{id:"zh_110",lang:"zh",text:"不积跬步,无以至千里;不积小流,无以成江海。",author:"荀子",source:"劝学",genre:"philosophy"},{id:"zh_111",lang:"zh",text:"锲而舍之,朽木不折;锲而不舍,金石可镂。",author:"荀子",source:"劝学",genre:"philosophy"},{id:"zh_112",lang:"zh",text:"天将降大任于是人也,必先苦其心志,劳其筋骨,饿其体肤,空乏其身。",author:"孟子",source:"告子下",genre:"philosophy"},{id:"zh_113",lang:"zh",text:"尽信书,则不如无书。",author:"孟子",source:"尽心下",genre:"philosophy"},{id:"zh_114",lang:"zh",text:"博学之,审问之,慎思之,明辨之,笃行之。",author:"子思",source:"中庸",genre:"philosophy"},{id:"zh_115",lang:"zh",text:"非淡泊无以明志,非宁静无以致远。",author:"诸葛亮",source:"诫子书",genre:"essay"},{id:"zh_116",lang:"zh",text:"先天下之忧而忧,后天下之乐而乐。",author:"范仲淹",source:"岳阳楼记",genre:"essay"},{id:"zh_117",lang:"zh",text:"人生自古谁无死?留取丹心照汗青。",author:"文天祥",source:"过零丁洋",genre:"poetry"},{id:"zh_118",lang:"zh",text:"穷且益坚,不坠青云之志。",author:"王勃",source:"滕王阁序",genre:"essay"},{id:"zh_119",lang:"zh",text:"书山有路勤为径,学海无涯苦作舟。",author:"韩愈",source:"Attributed",genre:"poetry"},{id:"zh_120",lang:"zh",text:"问渠那得清如许?为有源头活水来。",author:"朱熹",source:"观书有感",genre:"poetry"},{id:"zh_121",lang:"zh",text:"知是行之始,行是知之成。",author:"王阳明",source:"传习录",genre:"philosophy"},{id:"zh_122",lang:"zh",text:"太上有立德,其次有立功,其次有立言,虽久不废,此之谓不朽。",author:"叔孙豹",source:"左传·襄公二十四年",genre:"philosophy"},{id:"zh_123",lang:"zh",text:"黑发不知勤学早,白首方悔读书迟。",author:"颜真卿",source:"劝学诗",genre:"poetry"},{id:"zh_124",lang:"zh",text:"纸上得来终觉浅,绝知此事要躬行。",author:"陆游",source:"冬夜读书示子聿",genre:"poetry"},{id:"zh_125",lang:"zh",text:"书犹药也,善读之可以医愚。",author:"刘向",source:"说苑",genre:"philosophy"},{id:"zh_126",lang:"zh",text:"今日之责任,不在他人,而全在我少年。",author:"梁启超",source:"少年中国说",genre:"essay"},{id:"zh_127",lang:"zh",text:"怕什么真理无穷,进一寸有一寸的欢喜。",author:"胡适",source:"胡适日记",genre:"essay"},{id:"zh_128",lang:"zh",text:"天下古今之庸人,皆以一惰字致败;天下古今之人才,皆以一傲字致败。",author:"曾国藩",source:"曾国藩家书",genre:"essay"},{id:"zh_129",lang:"zh",text:"路漫漫其修远兮,吾将上下而求索。",author:"屈原",source:"离骚",genre:"poetry"},{id:"zh_130",lang:"zh",text:"为天地立心,为生民立命,为往圣继绝学,为万世开太平。",author:"å¼ è½½",source:"横渠四句",genre:"philosophy"},{id:"zh_131",lang:"zh",text:"学然后知不足,教然后知困。",author:"礼记",source:"学记",genre:"philosophy"},{id:"zh_132",lang:"zh",text:"吾生也有涯,而知也无涯。",author:"庄子",source:"养生主",genre:"philosophy"},{id:"tw_006",lang:"zh-TW",text:"所謂父女母子一場,只不過意味著,你和他的緣分就是今生今世不斷地在目送他的背影漸行漸遠。",author:"龍應台",source:"目送",genre:"essay"},{id:"tw_007",lang:"zh-TW",text:"有些路啊,只能一個人走。",author:"龍應台",source:"目送",genre:"essay"},{id:"tw_009",lang:"zh-TW",text:"一個社會特立獨行的人越多,天分、才氣、道德、勇氣就越多。",author:"龍應台",source:"野火集",genre:"essay"},{id:"tw_010",lang:"zh-TW",text:"不是漸行漸遠,而是有一天終要重逢。",author:"龍應台",source:"目送",genre:"essay"},{id:"tw_012",lang:"zh-TW",text:"一個人至少擁有一個夢想,有一個理由去堅強。心若沒有棲息的地方,到哪裡都是在流浪。",author:"三毛",source:"撒哈拉的故事",genre:"essay"},{id:"tw_013",lang:"zh-TW",text:"生命的滋味,無論是陽春白雪,青菜豆腐,都要自己去嘗一嘗啊。",author:"三毛",source:"撒哈拉的故事",genre:"essay"},{id:"tw_014",lang:"zh-TW",text:"我笑,便面如春花,定是能感動人的,任他是誰。",author:"三毛",source:"傾城",genre:"essay"},{id:"tw_015",lang:"zh-TW",text:"歲月極美,在於它必然的流逝。春花、秋月、夏日、冬雪。",author:"三毛",source:"歲月",genre:"essay"},{id:"tw_020",lang:"zh-TW",text:"爸爸的花兒落了,我也不再是小孩子。",author:"林海音",source:"城南舊事",genre:"fiction"},{id:"tw_025",lang:"zh-TW",text:"酒入豪腸,七分釀成了月光,餘下的三分嘯成劍氣,繡口一吐就半個盛唐。",author:"余光中",source:"尋李白",genre:"poetry"},{id:"tw_026",lang:"zh-TW",text:"掉頭一去是風吹黑髮,回首再來已雪滿白頭。",author:"余光中",source:"浪子回頭",genre:"poetry"}
2,{id:"tw_028",lang:"zh-TW",text:"旅行之意義並不是告訴別人「這裡我來過」,而是一種改變。",author:"余光中",source:"余光中散文",genre:"essay"},{id:"tw_037",lang:"zh-TW",text:"小鎮的人們像一棵棵老樹,根扎在土地裡,任風雨搖晃也不倒。",author:"黃春明",source:"兒子的大玩偶",genre:"fiction"},{id:"tw_038",lang:"zh-TW",text:"人活著就要有尊嚴,尊嚴比什麼都重要。",author:"黃春明",source:"看海的日子",genre:"fiction"},{id:"tw_039",lang:"zh-TW",text:"生命中最珍貴的東西,往往是最不起眼的。",author:"黃春明",source:"莎喲娜啦,再見",genre:"fiction"},{id:"tw_042",lang:"zh-TW",text:"所有的美麗都是短暫的,正因為短暫,才如此動人。",author:"朱天文",source:"炎夏之都",genre:"fiction"},{id:"tw_046",lang:"zh-TW",text:"人生的況味,就在於那些不經意的瞬間。",author:"張曼娟",source:"人間好時節",genre:"essay"},{id:"tw_049",lang:"zh-TW",text:"讓懂的人懂,讓不懂的人不懂。讓世界是世界,我甘心是我的繭。",author:"簡媜",source:"水問",genre:"essay"},{id:"tw_050",lang:"zh-TW",text:"我想學會用一種冷冽而清明的心情,去看待生命中所有的流轉與變遷。",author:"簡媜",source:"微暈的樹林",genre:"essay"},{id:"tw_051",lang:"zh-TW",text:"月光照在大地上,世界忽然安靜得像一首詩。",author:"簡媜",source:"夢遊書",genre:"essay"},{id:"tw_053",lang:"zh-TW",text:"有些事物消失了,但它們曾經存在過,這就夠了。",author:"吳明益",source:"單車失竊記",genre:"fiction"},{id:"tw_054",lang:"zh-TW",text:"每一棵樹都有自己的故事,只是我們很少停下來傾聽。",author:"吳明益",source:"苦雨之地",genre:"fiction"},{id:"tw_055",lang:"zh-TW",text:"美,其實是一種拯救。在最絕望的時刻,美讓人有了活下去的勇氣。",author:"蔣勳",source:"美的沉思",genre:"essay"},{id:"tw_056",lang:"zh-TW",text:"孤獨和寂寞不一樣。寂寞會發慌,孤獨則是飽滿的。",author:"蔣勳",source:"孤獨六講",genre:"essay"},{id:"tw_057",lang:"zh-TW",text:"孤獨是一種沉澱,而沉澱之後的思維是清明。",author:"蔣勳",source:"孤獨六講",genre:"essay"},{id:"tw_058",lang:"zh-TW",text:"生命裡第一個愛戀的對象應該是自己,寫詩給自己,與自己對話,在一個空間裡安靜下來,聆聽自己的心跳與呼吸。",author:"蔣勳",source:"生活十講",genre:"essay"},{id:"tw_059",lang:"zh-TW",text:"以清淨心看世界,以歡喜心過生活,以平常心生情味,以柔軟心除掛礙。",author:"林清玄",source:"清淨之蓮",genre:"essay"},{id:"tw_060",lang:"zh-TW",text:"人生需要準備的,不是昂貴的茶,而是喝茶的心情。",author:"林清玄",source:"人間有味是清歡",genre:"essay"},{id:"tw_061",lang:"zh-TW",text:"今天比昨天慈悲,今天比昨天智慧,今天比昨天快樂,這就是成功。",author:"林清玄",source:"林清玄散文",genre:"essay"},{id:"tw_062",lang:"zh-TW",text:"在穿過林間的時候,我覺得麻雀的死亡給我一些啟示,我們雖然在塵網中生活,但永遠不要失去想飛的心,不要忘記飛翔的姿勢。",author:"林清玄",source:"心的菩提",genre:"essay"},{id:"tw_063",lang:"zh-TW",text:"每次轉變,總會在生命中留下了青春的印痕。",author:"林清玄",source:"菩提十書",genre:"essay"},{id:"tw_064",lang:"zh-TW",text:"你不能決定生命的長度,但你可以控制它的寬度。",author:"劉墉",source:"螢窗小語",genre:"essay"},{id:"tw_065",lang:"zh-TW",text:"年輕的時候以為不讀書不足以了解人生,直到後來才發現如果不了解人生,是讀不懂書的。",author:"劉墉",source:"螢窗小語",genre:"essay"},{id:"tw_066",lang:"zh-TW",text:"每一個成功者都有一個開始。勇於開始,才能找到成功的路。",author:"劉墉",source:"我不是教你詐",genre:"essay"},{id:"tw_070",lang:"zh-TW",text:"人的命運不是由自己決定的,但人可以決定面對命運的態度。",author:"陳映真",source:"山路",genre:"fiction"},{id:"tw_074",lang:"zh-TW",text:"今天的陽光很好,好得讓人想一輩子都不閉眼。",author:"洛夫",source:"漂木",genre:"poetry"},{id:"tw_075",lang:"zh-TW",text:"溫柔之必要。肯定之必要。一點點酒和木樨花之必要。",author:"瘂弦",source:"如歌的行板",genre:"poetry"},{id:"tw_076",lang:"zh-TW",text:"給我一個解釋我就可以再相信一次人世,給我一張犁我就可以再翻一遍土地。",author:"瘂弦",source:"深淵",genre:"poetry"}
2,{id:"tw_078",lang:"zh-TW",text:"他強由他強,清風拂山岡;他橫任他橫,明月照大江。",author:"金庸",source:"倚天屠龍記",genre:"fiction"},{id:"tw_079",lang:"zh-TW",text:"人生在世,去若朝露。魑魅搏人,可盡信邪?",author:"金庸",source:"倚天屠龍記",genre:"fiction"},{id:"tw_080",lang:"zh-TW",text:"當高鐵列車加速到時速三百公里,再好的牛車也追不上。一個人的眼界決定了他的高度。",author:"李敖",source:"李敖語錄",genre:"essay"},{id:"tw_081",lang:"zh-TW",text:"小說家不過是個說故事的人,可是好的故事足以改變一個人看待世界的方式。",author:"張大春",source:"小說稗類",genre:"essay"},{id:"tw_082",lang:"zh-TW",text:"人生如戲,但不能彩排。每一天都是現場直播。",author:"王鼎鈞",source:"開放的人生",genre:"essay"},{id:"tw_083",lang:"zh-TW",text:"一枝草,一點露。天無絕人之路。",author:"王鼎鈞",source:"碎琉璃",genre:"essay"},{id:"tw_084",lang:"zh-TW",text:"樹在。山在。大地在。歲月在。我在。你還要怎樣更好的世界?",author:"張曉風",source:"我在",genre:"essay"},{id:"tw_087",lang:"zh-TW",text:"做人凡事要靜:靜靜地來,靜靜地去,靜靜努力,靜靜收穫。",author:"亦舒",source:"直至海枯石爛",genre:"fiction"},{id:"tw_088",lang:"zh-TW",text:"肥土鎮的居民,每個人的腦袋裡都住著一座花園。",author:"西西",source:"我城",genre:"fiction"},{id:"tw_090",lang:"zh-TW",text:"在城市的叢林裡,每一盞燈火都是一個人的故事。",author:"也斯",source:"城市筆記",genre:"poetry"},{id:"tw_091",lang:"zh-TW",text:"走路是一種緩慢的旅行,讓你看見平常視而不見的風景。",author:"劉克襄",source:"十一月的白芒花",genre:"essay"},{id:"tw_093",lang:"zh-TW",text:"大河奔流,帶走了多少歲月,卻帶不走那些刻骨銘心的記憶。",author:"齊邦媛",source:"巨流河",genre:"essay"},{id:"tw_094",lang:"zh-TW",text:"一生的故事,從哪裡開始說起呢?從那條大河,從那個年代。",author:"齊邦媛",source:"巨流河",genre:"essay"},{id:"tw_095",lang:"zh-TW",text:"十方是我沉默的發言,而萬籟都是我的知音。",author:"周夢蝶",source:"還魂草",genre:"poetry"},{id:"tw_096",lang:"zh-TW",text:"沒有悲劇就沒有悲壯,沒有悲壯就沒有崇高。",author:"余秋雨",source:"文化苦旅",genre:"essay"},{id:"tw_098",lang:"zh-TW",text:"海燕是大海上的精靈,牠們在暴風雨中歡叫,那是對生命最熱烈的禮讚。",author:"鄭振鐸",source:"海燕",genre:"essay"},{id:"tw_100",lang:"zh-TW",text:"文學是一面鏡子,映照出一個時代的靈魂。而島嶼的文學,映照的是漂流者永恆的鄉愁。",author:"陳芳明",source:"台灣新文學史",genre:"history"},{id:"fr_001",lang:"fr",text:"La suprême sagesse et la suprême raison est de bien remplir le moment présent.",author:"Victor Hugo",source:"Les Misérables",genre:"fiction"},{id:"fr_002",lang:"fr",text:"Même la nuit la plus sombre prendra fin et le soleil se lèvera.",author:"Victor Hugo",source:"Les Misérables",genre:"fiction"},{id:"fr_003",lang:"fr",text:"La liberté commence où l'ignorance finit.",author:"Victor Hugo",source:"Les Misérables",genre:"fiction"},{id:"fr_004",lang:"fr",text:"Il y a des pensées qui sont des prières. Il y a des moments où, quelle que soit l'attitude du corps, l'âme est à genoux.",author:"Victor Hugo",source:"Les Misérables",genre:"fiction"},{id:"fr_006",lang:"fr",text:"Les mots sont les passants mystérieux de l'âme.",author:"Victor Hugo",source:"Les Contemplations",genre:"poetry"},{id:"fr_007",lang:"fr",text:"Le véritable voyage de découverte ne consiste pas à chercher de nouveaux paysages, mais à avoir de nouveaux yeux.",author:"Marcel Proust",source:"À la recherche du temps perdu",genre:"fiction"},{id:"fr_008",lang:"fr",text:"On ne reçoit pas la sagesse, il faut la découvrir soi-même après un trajet que personne ne peut faire pour nous, ne peut nous épargner.",author:"Marcel Proust",source:"À l'ombre des jeunes filles en fleurs",genre:"fiction"}
2,{id:"fr_009",lang:"fr",text:"Le bonheur est salutaire pour le corps, mais c'est le chagrin qui développe les forces de l'esprit.",author:"Marcel Proust",source:"Le Temps retrouvé",genre:"fiction"},{id:"fr_012",lang:"fr",text:"Au milieu de l'hiver, j'ai découvert en moi un invincible été.",author:"Albert Camus",source:"Retour à Tipasa",genre:"essay"},{id:"fr_013",lang:"fr",text:"Il faut imaginer Sisyphe heureux.",author:"Albert Camus",source:"Le Mythe de Sisyphe",genre:"philosophy"},{id:"fr_014",lang:"fr",text:"La lutte elle-même vers les sommets suffit à remplir un cœur d'homme.",author:"Albert Camus",source:"Le Mythe de Sisyphe",genre:"philosophy"},{id:"fr_016",lang:"fr",text:"Je n'ai pas appris la liberté dans Marx. Il est vrai : je l'ai apprise dans la misère.",author:"Albert Camus",source:"Carnets",genre:"essay"},{id:"fr_018",lang:"fr",text:"On ne voit bien qu'avec le cœur. L'essentiel est invisible pour les yeux.",author:"Antoine de Saint-Exupéry",source:"Le Petit Prince",genre:"fiction"},{id:"fr_019",lang:"fr",text:"Tu deviens responsable pour toujours de ce que tu as apprivoisé.",author:"Antoine de Saint-Exupéry",source:"Le Petit Prince",genre:"fiction"},{id:"fr_020",lang:"fr",text:"C'est le temps que tu as perdu pour ta rose qui fait ta rose si importante.",author:"Antoine de Saint-Exupéry",source:"Le Petit Prince",genre:"fiction"},{id:"fr_021",lang:"fr",text:"Toutes les grandes personnes ont d'abord été des enfants. Mais peu d'entre elles s'en souviennent.",author:"Antoine de Saint-Exupéry",source:"Le Petit Prince",genre:"fiction"},{id:"fr_022",lang:"fr",text:"La terre nous en apprend plus long sur nous que tous les livres. Parce qu'elle nous résiste.",author:"Antoine de Saint-Exupéry",source:"Terre des hommes",genre:"essay"},{id:"fr_023",lang:"fr",text:"Aimer, ce n'est pas se regarder l'un l'autre, c'est regarder ensemble dans la même direction.",author:"Antoine de Saint-Exupéry",source:"Terre des hommes",genre:"essay"},{id:"fr_024",lang:"fr",text:"La parole humaine est comme un chaudron fêlé où nous battons des mélodies à faire danser les ours, quand on voudrait attendrir les étoiles.",author:"Gustave Flaubert",source:"Madame Bovary",genre:"fiction"},{id:"fr_026",lang:"fr",text:"On ne doit écrire que quand on laisse un morceau de sa chair dans l'encrier, chaque fois qu'on trempe sa plume.",author:"Gustave Flaubert",source:"Correspondance",genre:"essay"},{id:"fr_027",lang:"fr",text:"Lisez pour vivre.",author:"Gustave Flaubert",source:"Correspondance",genre:"essay"},{id:"fr_028",lang:"fr",text:"Le hasard est le plus grand romancier du monde ; pour être fécond, il n'y a qu'à l'étudier.",author:"Honoré de Balzac",source:"La Comédie humaine",genre:"fiction"},{id:"fr_030",lang:"fr",text:"La résignation est un suicide quotidien.",author:"Honoré de Balzac",source:"Illusions perdues",genre:"fiction"},{id:"fr_031",lang:"fr",text:"Toute la sagesse humaine sera dans ces deux mots : Attendre et Espérer.",author:"Alexandre Dumas",source:"Le Comte de Monte-Cristo",genre:"fiction"},{id:"fr_032",lang:"fr",text:"La vie est un orage. Un jour tu te prends au soleil, le lendemain la foudre t'éclate sur un rocher.",author:"Alexandre Dumas",source:"Le Comte de Monte-Cristo",genre:"fiction"},{id:"fr_033",lang:"fr",text:"Un pour tous, tous pour un.",author:"Alexandre Dumas",source:"Les Trois Mousquetaires",genre:"fiction"},{id:"fr_035",lang:"fr",text:"Enivrez-vous. Il faut être toujours ivre. Tout est là : c'est l'unique question.",author:"Charles Baudelaire",source:"Le Spleen de Paris",genre:"poetry"},{id:"fr_037",lang:"fr",text:"Le génie n'est que l'enfance retrouvée à volonté.",author:"Charles Baudelaire",source:"Le Peintre de la vie moderne",genre:"essay"},{id:"fr_038",lang:"fr",text:"Homme libre, toujours tu chériras la mer !",author:"Charles Baudelaire",source:"Les Fleurs du mal",genre:"poetry"},{id:"fr_039",lang:"fr",text:"Il faut cultiver notre jardin.",author:"Voltaire",source:"Candide",genre:"fiction"},{id:"fr_040",lang:"fr",text:"Le doute n'est pas un état bien agréable, mais l'assurance est un état ridicule.",author:"Voltaire",source:"C
2orrespondance",genre:"philosophy"},{id:"fr_041",lang:"fr",text:"J'ai décidé d'être heureux parce que c'est bon pour la santé.",author:"Voltaire",source:"Correspondance",genre:"philosophy"},{id:"fr_042",lang:"fr",text:"Le secret d'ennuyer est celui de tout dire.",author:"Voltaire",source:"Discours en vers sur l'homme",genre:"poetry"},{id:"fr_043",lang:"fr",text:"Je ne suis pas d'accord avec ce que vous dites, mais je me battrai jusqu'à la mort pour que vous ayez le droit de le dire.",author:"Voltaire",source:"Attributed",genre:"philosophy"},{id:"fr_044",lang:"fr",text:"Il faut manger pour vivre et non pas vivre pour manger.",author:"Molière",source:"L'Avare",genre:"drama"},{id:"fr_046",lang:"fr",text:"Plus grand est l'obstacle, et plus grande est la gloire de le surmonter.",author:"Molière",source:"Les Fourberies de Scapin",genre:"drama"},{id:"fr_047",lang:"fr",text:"L'existence précède l'essence.",author:"Jean-Paul Sartre",source:"L'Existentialisme est un humanisme",genre:"philosophy"},{id:"fr_049",lang:"fr",text:"L'homme est condamné à être libre.",author:"Jean-Paul Sartre",source:"L'Existentialisme est un humanisme",genre:"philosophy"},{id:"fr_050",lang:"fr",text:"Nous sommes nos choix.",author:"Jean-Paul Sartre",source:"L'Être et le Néant",genre:"philosophy"},{id:"fr_051",lang:"fr",text:"On ne naît pas femme : on le devient.",author:"Simone de Beauvoir",source:"Le Deuxième Sexe",genre:"philosophy"},{id:"fr_052",lang:"fr",text:"C'est dans la connaissance des conditions véritables de notre vie qu'il nous faut puiser la force de vivre et des raisons d'agir.",author:"Simone de Beauvoir",source:"Pour une morale de l'ambiguïté",genre:"philosophy"},{id:"fr_053",lang:"fr",text:"Je suis trop intelligente, trop exigeante et trop ingénieuse pour que quiconque puisse prendre en charge ma liberté.",author:"Simone de Beauvoir",source:"Les Mandarins",genre:"fiction"},{id:"fr_054",lang:"fr",text:"Écrire, c'est aussi ne pas parler. C'est se taire. C'est hurler sans bruit.",author:"Marguerite Duras",source:"Écrire",genre:"essay"},{id:"fr_056",lang:"fr",text:"L'alcool n'a pas consolé, la musique non plus, ni la littérature. Mais la littérature, c'est quand même autre chose.",author:"Marguerite Duras",source:"Outside",genre:"essay"},{id:"fr_057",lang:"fr",text:"Un roman est un miroir qui se promène sur une grande route.",author:"Stendhal",source:"Le Rouge et le Noir",genre:"fiction"},{id:"fr_060",lang:"fr",text:"La vérité est en marche et rien ne l'arrêtera.",author:"Émile Zola",source:"J'accuse…!",genre:"essay"},{id:"fr_061",lang:"fr",text:"Si vous me demandez ce que je suis venu faire en ce monde, moi, artiste, je vous répondrai : je suis venu vivre à voix haute.",author:"Émile Zola",source:"Mes Haines",genre:"essay"},{id:"fr_062",lang:"fr",text:"La vie, voyez-vous, ça n'est jamais si bon ni si mauvais qu'on croit.",author:"Guy de Maupassant",source:"Une vie",genre:"fiction"},{id:"fr_064",lang:"fr",text:"On a vraiment du mérite que dans ce qu'on ne possède pas de naissance.",author:"Guy de Maupassant",source:"Fort comme la mort",genre:"fiction"},{id:"fr_068",lang:"fr",text:"Patience et longueur de temps font plus que force ni que rage.",author:"Jean de La Fontaine",source:"Fables",genre:"poetry"},{id:"fr_069",lang:"fr",text:"On a souvent besoin d'un plus petit que soi.",author:"Jean de La Fontaine",source:"Fables",genre:"poetry"},{id:"fr_070",lang:"fr",text:"Rien ne sert de courir ; il faut partir à point.",author:"Jean de La Fontaine",source:"Fables",genre:"poetry"},{id:"fr_073",lang:"fr",text:"Philosopher, c'est apprendre à mourir.",author:"Michel de Montaigne",source:"Essais",genre:"philosophy"},{id:"fr_074",lang:"fr",text:"Le monde n'est qu'une branloire pérenne. Toutes choses y branlent sans cesse.",author:"Michel de Montaigne",source:"Essais",genre:"philosophy"},{id:"fr_075",lang:"fr",text:"Chaque homme porte la forme entière de l'humaine condition.",author:"Michel de Montaigne",source:"Essais",genre:"philosophy"},{id:"fr_076",lang:"fr",text:"L'homme est né libre, et partout il est dans les fers.",author:"Jean-Jacques Rousseau",source:"Du contrat social",genre:"philosophy"}
2,{id:"fr_077",lang:"fr",text:"Vivre n'est pas respirer, c'est agir.",author:"Jean-Jacques Rousseau",source:"Émile, ou De l'éducation",genre:"philosophy"},{id:"fr_078",lang:"fr",text:"Il faut avec les mots de tout le monde écrire comme personne.",author:"Colette",source:"Journal à rebours",genre:"essay"},{id:"fr_079",lang:"fr",text:"Le difficile, ce n'est pas de donner, c'est de ne pas tout donner.",author:"Colette",source:"La Naissance du jour",genre:"fiction"},{id:"fr_080",lang:"fr",text:"Il faudrait essayer d'être heureux, ne serait-ce que pour donner l'exemple.",author:"Jacques Prévert",source:"Spectacle",genre:"poetry"},{id:"fr_082",lang:"fr",text:"Il n'y a pas de hasard, il n'y a que des rendez-vous.",author:"Paul Éluard",source:"Capitale de la douleur",genre:"poetry"},{id:"fr_084",lang:"fr",text:"Le cœur a ses raisons que la raison ne connaît point.",author:"Blaise Pascal",source:"Pensées",genre:"philosophy"},{id:"fr_085",lang:"fr",text:"Tout le malheur des hommes vient d'une seule chose, qui est de ne savoir pas demeurer en repos dans une chambre.",author:"Blaise Pascal",source:"Pensées",genre:"philosophy"},{id:"fr_086",lang:"fr",text:"L'homme n'est qu'un roseau, le plus faible de la nature ; mais c'est un roseau pensant.",author:"Blaise Pascal",source:"Pensées",genre:"philosophy"},{id:"fr_087",lang:"fr",text:"Je pense, donc je suis.",author:"René Descartes",source:"Discours de la méthode",genre:"philosophy"},{id:"fr_088",lang:"fr",text:"Il est bon de suivre sa pente, pourvu que ce soit en montant.",author:"André Gide",source:"Les Faux-Monnayeurs",genre:"fiction"},{id:"fr_089",lang:"fr",text:"On ne découvre pas de terre nouvelle sans consentir à perdre de vue, d'abord et longtemps, tout rivage.",author:"André Gide",source:"Les Faux-Monnayeurs",genre:"fiction"},{id:"fr_090",lang:"fr",text:"Les yeux ouverts, je me suis exercé à contempler le monde en homme qui va le quitter.",author:"Marguerite Yourcenar",source:"Mémoires d'Hadrien",genre:"fiction"},{id:"fr_091",lang:"fr",text:"Tout bonheur est un chef-d'œuvre : la moindre erreur le fausse, la moindre hésitation l'altère.",author:"Marguerite Yourcenar",source:"Mémoires d'Hadrien",genre:"fiction"},{id:"fr_092",lang:"fr",text:"Le style est une manière absolue de voir les choses.",author:"Gustave Flaubert",source:"Correspondance",genre:"essay"},{id:"fr_093",lang:"fr",text:"Nous avons tous assez de force pour supporter les maux d'autrui.",author:"François de La Rochefoucauld",source:"Maximes",genre:"philosophy"},{id:"fr_095",lang:"fr",text:"On risque autant à croire trop qu'à croire trop peu.",author:"Denis Diderot",source:"Pensées philosophiques",genre:"philosophy"},{id:"fr_096",lang:"fr",text:"Ô temps ! suspends ton vol, et vous, heures propices ! Suspendez votre cours.",author:"Alphonse de Lamartine",source:"Le Lac",genre:"poetry"},{id:"fr_098",lang:"fr",text:"C'est la nuit qu'il est beau de croire à la lumière.",author:"Edmond Rostand",source:"Chantecler",genre:"drama"},{id:"fr_099",lang:"fr",text:"Mal nommer un objet, c'est ajouter au malheur de ce monde.",author:"Albert Camus",source:"Sur une philosophie de l'expression",genre:"essay"},{id:"fr_101",lang:"fr",text:"Vivre, c'est ce qu'il y a de plus rare au monde. La plupart des gens existent, c'est tout.",author:"Oscar Wilde",source:"L'Âme humaine (trad.)",genre:"essay"},{id:"fr_102",lang:"fr",text:"La lecture de tous les bons livres est comme une conversation avec les plus honnêtes gens des siècles passés.",author:"René Descartes",source:"Discours de la méthode",genre:"philosophy"},{id:"fr_103",lang:"fr",text:"Il faut beaucoup étudier pour savoir un peu.",author:"Montesquieu",source:"Pensées",genre:"philosophy"},{id:"fr_104",lang:"fr",text:"L'attention est la forme la plus rare et la plus pure de la générosité.",author:"Simone Weil",source:"Lettre à Joë Bousquet",genre:"philosophy"}];function ir({className:t,children:n}){const s=oe.useRef(null),[c,g]=l.useState(!1),[f,y]=l.useState(!1),a=l.useCallback(()=>{const b=s.current;b&&(g(b.scrollLeft>4),y(b.scrollLeft+b.clientWidth<b.scrollWidth-4))},[]);l.useEffect(()=>{const b=s.current;if(!b)return;a(),b.addEventListener("scroll",a,{passive:!0});const i=new ResizeObserver(a);return i.observe(b),()=>{b.removeEventListener("scroll",a),i.disconnect()}},[a]);const v=b=>{const i=s.current;i&&i.scrollBy({left:b*i.clientWidth*.7,behavior:fn()})};return e.jsxs("div",{className:"scroll-row-wrap",children:[e.jsx("div",{ref:s,className:`${t} scroll-row-hidden-bar`,children:n}),c&&e.jsx("button",{type:"button",className:"scroll-arrow scroll-arrow-left",onClick:()=>v(-1),children:e.jsx("svg",{viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("polyline",{points:"15 18 9 12 15 6"})})}),f&&e.jsx("button",{type:"button",className:"scroll-arrow scroll-arrow-right",onClick:()=>v(1),children:e.jsx("svg",{viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("polyline",{points:"9 6 15 12 9 18"})})})]})}function lr(t,n,s,c){let g=n||"";if(g){const z=g.match(/^([^:\(\u2014\u2013]{4,})[:\(\u2014\u2013]/);z&&(g=z[1].trim()),g.length>30&&(g=g.slice(0,28)+"…")}const f=new Date().getHours(),y=new Date().getDay(),a=y===0||y===6,b=t==="zh"||t==="zh-TW"?",":", ",i=g,{weekMs:M,streak:o,todayMs:d,daysMetCount:u}=s,_=z=>z>0?c(z):"",D=_(M),x=[],S=[],j=[],m=[];d>=3e5&&(x.push(`You've read ${_(d)} today — keep going whenever you're ready.`),S.push(`今天读了 ${_(d)},想继续的时候随时翻开。`),j.push(`今天讀了 ${_(d)},想繼續的時候隨時翻開。`),m.push(`${_(d)} aujourd'hui — reprenez quand vous voulez.`)),o>=7?(x.push(`${o}-day streak — keep the rhythm going!`),S.push(`连续阅读 ${o} 天了,保持这个节奏!`),j.push(`連續閱讀 ${o} 天了,保持這個節奏!`),m.push(`${o} jours d'affilée — gardez le rythme !`)):o>=3&&(x.push(`${o} days in a row — today makes it even better!`),S.push(`连续 ${o} 天了,今天继续!`),j.push(`連續 ${o} 天了,今天繼續!`),m.push(`${o} jours consécutifs — encore un aujourd'hui ?`)),u>=5&&(x.push(`${u}/7 days this week — almost a perfect week!`),S.push(`本周 ${u}/7 天达标,快满勤了!`),j.push(`本週 ${u}/7 天達標,快滿勤了!`),m.push(`${u}/7 jours cette semaine — presque parfait !`)),M>=18e5&&(x.push(`${D} this week — shall we add a few more pages?`),S.push(`本周已读 ${D},要不要再翻几页?`),j.push(`本週已讀 ${D},要不要再翻幾頁?`),m.push(`${D} cette semaine — on continue ?`));const C=z=>z.length>0?z[Math.floor(Math.random()*z.length)]:null,$={en:x,zh:S,"zh-TW":j,fr:m},A=C($[t]||$.en),L={en:{morning:"Good morning",afternoon:"Hey",evening:"Good evening",lateNight:"Still up",weekend:"Happy weekend"},zh:{morning:"早上好",afternoon:"下午好",evening:"晚上好",lateNight:"夜深了",weekend:"周末愉快"},"zh-TW":{morning:"早安",afternoon:"午安",evening:"晚上好",lateNight:"夜深了",weekend:"週末愉快"},fr:{morning:"Bonjour",afternoon:"Salut",evening:"Bonsoir",lateNight:"Encore debout",weekend:"Bon week-end"}},W=L[t]||L.en;let q;a?q=W.weekend:f<6?q=W.lateNight:f<12?q=W.morning:f<18?q=W.afternoon:f<23?q=W.evening:q=W.lateNight;const G={en:i?[`Pick up "${i}" where you left off?`,`"${i}" is waiting for you.`,`Ready for the next chapter of "${i}"?`]:["A good book makes any moment better.","Your next great read is one click away.","Every page counts — start reading!"],zh:i?[`继续《${i}》的旅程?`,`《${i}》的故事还在等你。`,`翻开《${i}》,回到上次的精彩。`]:["好书让每一刻都更有意义。","翻开一本书,开启今天的阅读。","每一页都算数,开始读吧!"],"zh-TW":i?[`繼續《${i}》的旅程?`,`《${i}》的故事還在等你。`,`翻開《${i}》,回到上次的精彩。`]:["好書讓每一刻都更有意義。","翻開一本書,開啟今天的閱讀。","每一頁都算數,開始讀吧!"],fr:i?[`On reprend "${i}" ?`,`"${i}" vous attend.`,`Prêt(e) pour le prochain chapitre de "${i}" ?`]:["Un bon livre rend chaque instant meilleur.","Votre prochaine lecture est à portée de clic.","Chaque page compte — commencez à lire !"]},k=A||C(G[t]||G.en)||"";return{prefix:q+b,body:k}}function cr({ctx:t,recentBooks:n,fileInputRef:s}){var ie,E,T;const{t:c,language:g}=t,{user:f}=Oe(),y=et(),{data:a,loading:v}=or(),[b,i]=l.useState(new Set),[M,o]=l.useState({}),[d,u]=l.useState(()=>Se[Math.floor(Math.random()*Se.length)]);l.useEffect(()=>{ne.getQuoteLikes().then(p=>{p!=null&&p.likes&&i(new Set(p.likes))}).catch(()=>{})},[]),l.useEffect(()=>{if(!d)return;const p=d.id;if(p in M)return;let I=!1;
2return ne.getQuoteLikeCount(p).then(Z=>{if(I)return;const Q=Number((Z==null?void 0:Z.count)??0);o(te=>({...te,[p]:Q}))}).catch(()=>{}),()=>{I=!0}},[d,M]);const _=d&&b.has(d.id),D=d?M[d.id]??null:null,x=l.useCallback(async()=>{if(!d)return;const p=d.id,I=b.has(p),Z=M[p]??0;i(Q=>{const te=new Set(Q);return I?te.delete(p):te.add(p),te}),o(Q=>({...Q,[p]:Math.max(0,Z+(I?-1:1))}));try{const Q=I?await ne.unlikeQuote(p):await ne.likeQuote({quote_id:p,genre:d.genre,author_name:d.author,language:d.lang});Q&&typeof Q.count=="number"&&o(te=>({...te,[p]:Q.count}))}catch{i(Q=>{const te=new Set(Q);return I?te.add(p):te.delete(p),te}),o(Q=>({...Q,[p]:Z}))}},[d,b,M]),S=l.useCallback(()=>{if(Se.length<=1)return;let p;do p=Se[Math.floor(Math.random()*Se.length)];while(p.id===(d==null?void 0:d.id)&&Se.length>1);u(p)},[d]),j=p=>{if(!p)return"0m";const I=Math.floor(p/6e4);if(I<1)return"<1m";const Z=Math.floor(I/60),Q=I%60;return Z>0&&Q>0?`${Z}h ${Q}m`:Z>0?`${Z}h`:`${Q}m`},m=a==null?void 0:a.week,C=a==null?void 0:a.month,$=c(`stats.month${new Date().getMonth()+1}`),A=[c("stats.mon"),c("stats.tue"),c("stats.wed"),c("stats.thu"),c("stats.fri"),c("stats.sat"),c("stats.sun")],L=n[0],W=L?t.bookProgress[L.id]:null,q=Math.round((W==null?void 0:W.percentage)||0),G=(W==null?void 0:W.chapter)||"",k=L?t.bookCovers[L.id]:null,z=(f==null?void 0:f.display_name)||((E=(ie=f==null?void 0:f.email)==null?void 0:ie.split("@"))==null?void 0:E[0])||"",Y=m!=null&&m.days_met?m.days_met.filter(Boolean).length:0,K=l.useMemo(()=>{var p;return lr(g,(L==null?void 0:L.title)||"",{monthMs:(C==null?void 0:C.total_ms)||0,weekMs:(m==null?void 0:m.total_ms)||0,streak:(a==null?void 0:a.streak)||0,todayMs:((p=a==null?void 0:a.today)==null?void 0:p.ms)||0,booksFinished:(a==null?void 0:a.books_finished)||0,totalDays:(a==null?void 0:a.total_reading_days)||0,daysMetCount:Y},j)},[g,L==null?void 0:L.title,C==null?void 0:C.total_ms,m==null?void 0:m.total_ms,a==null?void 0:a.streak,(T=a==null?void 0:a.today)==null?void 0:T.ms,Y]);return e.jsxs("div",{className:"landing-view",children:[d&&e.jsxs("div",{className:"landing-quote-card",children:[e.jsx("div",{className:"landing-quote-card-bg"}),e.jsxs("div",{className:"landing-quote-card-inner",children:[e.jsx("p",{className:"landing-quote-text",children:d.text}),e.jsxs("div",{className:"landing-quote-row",children:[e.jsxs("span",{className:"landing-quote-meta",children:[d.author,d.source&&e.jsxs("span",{className:"landing-quote-source",children:[", ",d.source]})]}),e.jsxs("button",{className:`landing-like-btn ${_?"liked":""}`,onClick:x,title:c(_?"landing.liked":"landing.like"),children:[_?e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"currentColor",stroke:"none",children:e.jsx("path",{d:"M12 21.35l-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54L12 21.35z"})}):e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M20.84 4.61a5.5 5.5 0 0 0-7.78 0L12 5.67l-1.06-1.06a5.5 5.5 0 0 0-7.78 7.78l1.06 1.06L12 21.23l7.78-7.78 1.06-1.06a5.5 5.5 0 0 0 0-7.78z"})}),D!==null&&D>0&&e.jsx("span",{className:"landing-like-count",children:D})]}),e.jsx("button",{className:"landing-refresh-btn",onClick:S,title:c("landing.nextQuote"),children:e.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("polyline",{points:"23 4 23 10 17 10"}),e.jsx("path",{d:"M20.49 15a9 9 0 1 1-2.12-9.36L23 10"})]})})]})]})]}),e.jsxs("div",{className:"landing-mid-row",children:[L&&e.jsxs("div",{className:"landing-hero",onClick:()=>t.handleOpenBook(L),children:[e.jsxs("div",{className:"landing-hero-cover-col",children:[e.jsxs("div",{className:"landing-hero-cover",children:[k?e.jsx("img",{src:k,alt:L.title,className:"landing-hero-cover-img"}):e.jsx("div",{className:"landing-hero-cover-placeholder",children:e.jsx("span",{children:(L.title||"?").charAt(0).toUpperCase()})}),e.jsx(We,{book:L}),L.file_type==="epub_from_pdf"&&L.conversion_status==="ready"&&t.openChapterPickerForBook&&qe(L)&&e.jsx("button",{type:"button",className:"book-add-chapters-btn",onClick:p=>{p.stopPropagation(),t.openChapterPickerForBook(L)}
2,title:c("library.addChapters")||"增加章节",children:e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",children:e.jsx("path",{d:"M12 5v14M5 12h14"})})})]}),e.jsxs("div",{className:"continue-info",children:[e.jsx("h3",{className:"continue-title",title:L.title,children:L.title}),e.jsxs("div",{className:"continue-progress-row",children:[e.jsx("div",{className:"continue-progress-bar",children:e.jsx("div",{className:"continue-progress-fill",style:{width:`${q}%`}})}),e.jsxs("span",{className:"continue-progress-pct",children:[q,"%"]})]})]})]}),e.jsxs("div",{className:"landing-hero-info",children:[e.jsxs("h2",{className:"landing-hero-hello",children:[K.prefix,e.jsx("strong",{className:"landing-hero-hello-name",children:z})]}),K.body&&e.jsx("p",{className:"landing-hero-subtitle",children:K.body}),G&&e.jsxs("p",{className:"landing-hero-chapter",children:[c("landing.lastRead"),": ",G]}),e.jsx(sr,{bookId:L==null?void 0:L.id,language:g})]})]}),a&&!v&&e.jsxs("aside",{className:"landing-aside",children:[e.jsxs("div",{className:"landing-aside-stat-row",children:[e.jsxs("button",{className:"landing-stat-box",onClick:()=>y("/dashboard"),children:[e.jsx("span",{className:"landing-stat-label",children:c("landing.weekReading")}),e.jsx("strong",{className:"landing-stat-value",children:j(m==null?void 0:m.total_ms)})]}),e.jsxs("button",{className:"landing-stat-box",onClick:()=>y("/dashboard"),children:[e.jsxs("span",{className:"landing-stat-label",children:[$,c("stats.reading")]}),e.jsx("strong",{className:"landing-stat-value",children:j(C==null?void 0:C.total_ms)})]})]}),e.jsx("div",{className:"landing-aside-card landing-aside-card-clickable",onClick:()=>y("/dashboard"),children:e.jsx("div",{className:"landing-week-days",children:A.map((p,I)=>{var me,fe;const Z=(new Date().getDay()+6)%7,Q=((me=m==null?void 0:m.days_met)==null?void 0:me[I])||!1,te=I>Z,re=((fe=m==null?void 0:m.days_ms)==null?void 0:fe[I])||0,ae=I===Z&&!Q&&re>0?Math.min(1,re/(5*60*1e3)):0;return e.jsxs("div",{className:"landing-day-col",title:(()=>{if(te)return"";const de=new Date;return de.setDate(de.getDate()+(I-Z)),`${de.getMonth()+1}月${de.getDate()}日 ${j(re)}`})(),children:[e.jsxs("div",{className:`landing-day-circle ${Q?"met":""} ${te?"future":""} ${ae>0?"partial":""}`,children:[Q&&e.jsx("svg",{width:"9",height:"9",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3.5",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("polyline",{points:"20 6 9 17 4 12"})}),ae>0&&e.jsxs("svg",{className:"landing-day-ring",width:"18",height:"18",viewBox:"0 0 18 18",children:[e.jsx("circle",{cx:"9",cy:"9",r:"7.5",fill:"none",stroke:"currentColor",strokeWidth:"1.5",opacity:"0.15"}),e.jsx("circle",{cx:"9",cy:"9",r:"7.5",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:`${ae*47.1} 47.1`,strokeLinecap:"round",transform:"rotate(-90 9 9)"})]})]}),e.jsx("span",{className:"landing-day-label",children:p})]},I)})})}),e.jsxs("div",{className:"landing-aside-card landing-shelf",children:[e.jsxs("button",{className:"landing-shelf-header",onClick:()=>y("/?view=home"),children:[e.jsx("span",{children:c("sidebar.myBookshelf")}),e.jsx("svg",{className:"landing-books-arrow",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("polyline",{points:"9 6 15 12 9 18"})})]}),e.jsxs("div",{className:"landing-shelf-grid",children:[e.jsx("button",{className:"landing-shelf-add",onClick:p=>{var I;p.stopPropagation(),(I=s==null?void 0:s.current)==null||I.click()},children:e.jsx("svg",{viewBox:"0 0 24 24",width:"20",height:"20",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:e.jsx("path",{d:"M12 5v14M5 12h14",strokeLinecap:"round",strokeLinejoin:"round"})})}),(t.books||[]).filter(p=>!p.deleted_at).sort((p,I)=>new Date(I.created_at)-new Date(p.created_at)).slice(0,3).map(p=>e.jsxs("div",{className:"landing-shelf-book",onClick:()=>t.handleOpenBook(p),children:[t.bookCovers[p.id]?e.jsx("img",{src:t.bookCovers[p.id],alt:p.title,className:"landing-shelf-cover"}):e.jsx("div",{className:"landing-shelf-placeholder",children:e.jsx("span",{children:(p.title||"?").charAt(0).toUpperCase()})}
2),e.jsx(We,{book:p}),p.file_type==="epub_from_pdf"&&p.conversion_status==="ready"&&t.openChapterPickerForBook&&qe(p)&&e.jsx("button",{type:"button",className:"book-add-chapters-btn",onClick:I=>{I.stopPropagation(),t.openChapterPickerForBook(p)},title:c("library.addChapters")||"增加章节",children:e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",children:e.jsx("path",{d:"M12 5v14M5 12h14"})})})]},p.id))]})]})]})]}),n.length>1&&e.jsxs("div",{className:"landing-books-full",children:[e.jsxs("button",{className:"landing-books-title",onClick:()=>y("/?view=continue-reading"),children:[c("landing.continueReading")," ",e.jsx("svg",{className:"landing-books-arrow",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("polyline",{points:"9 6 15 12 9 18"})})]}),e.jsx(ir,{className:"books-row continue-row",children:n.slice(1).map((p,I)=>e.jsx(nr,{book:p,index:I,ctx:t},p.id))})]})]})}const dr=oe.memo(cr),Ze=()=>e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("polyline",{points:"20 6 9 17 4 12"})});function ur({filters:t,setFilters:n,books:s,t:c,uiLang:g}){const[f,y]=l.useState(!1),a=l.useRef(null),v=(t.difficulty!=="all"?1:0)+(t.length!=="all"?1:0)+(t.list!=="all"?1:0);l.useEffect(()=>{if(!f)return;const x=S=>{a.current&&!a.current.contains(S.target)&&y(!1)};return document.addEventListener("pointerdown",x),()=>document.removeEventListener("pointerdown",x)},[f]);const b=oe.useMemo(()=>{const x={};for(const S of s||[])S.difficulty_level&&(x[S.difficulty_level]=(x[S.difficulty_level]||0)+1);return Object.entries(x).sort((S,j)=>{const m=jt.indexOf(S[0]),C=jt.indexOf(j[0]);return m===-1&&C===-1?S[0].localeCompare(j[0]):m===-1?1:C===-1?-1:m-C})},[s]),i=oe.useMemo(()=>{const x={};for(const S of s||[])for(const j of nt(S.reading_lists))x[j]=(x[j]||0)+1;return Mt.filter(S=>x[S]).map(S=>[S,x[S]])},[s]),M=(x,S)=>n(j=>({...j,[x]:j[x]===S?"all":S})),o=Le(g),d=o?"难度":"Level",u=o?"篇幅":"Length",_=o?"书单":"Reading list",D=o?{short:"< 5万字",medium:"5–15万字",long:"> 15万字"}:{short:"< 50k",medium:"50–150k",long:"> 150k"};return e.jsxs("div",{className:"grid-filter-wrap",ref:a,children:[e.jsxs("button",{type:"button",className:`btn-icon-action ${v>0?"btn-icon-action-active":""}`,onClick:()=>y(x=>!x),title:c("library.filter")||"Filter",children:[e.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M3 4h18l-7 8.5V18l-4 2v-7.5L3 4z"})}),v>0&&e.jsx("span",{className:"filter-badge",children:v})]}),f&&e.jsxs("div",{className:"grid-filter-dropdown",children:[b.length>1&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"grid-filter-section-label",children:d}),b.map(([x,S])=>e.jsxs("button",{type:"button",className:t.difficulty===x?"active":"",onClick:()=>M("difficulty",x),children:[x,e.jsx("span",{className:"grid-filter-count",children:S}),t.difficulty===x&&e.jsx(Ze,{})]},x)),e.jsx("div",{className:"grid-filter-divider"})]}),i.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"grid-filter-section-label",children:_}),i.map(([x,S])=>e.jsxs("button",{type:"button",title:Pt(x,g),className:t.list===x?"active":"",onClick:()=>M("list",x),children:[Tt(x,g),e.jsx("span",{className:"grid-filter-count",children:S}),t.list===x&&e.jsx(Ze,{})]},x)),e.jsx("div",{className:"grid-filter-divider"})]}),e.jsx("div",{className:"grid-filter-section-label",children:u}),zt.map(x=>e.jsxs("button",{type:"button",className:t.length===x.id?"active":"",onClick:()=>M("length",x.id),children:[e.jsx(Et,{bucket:x.id}),D[x.id],t.length===x.id&&e.jsx(Ze,{})]},x.id))]})]})}function Le(t){return t==="zh"||t==="zh-TW"}const jt=["A1","A2","A2-B1","B1","B1-B2","B2","B2-C1","C1","C1-C2","C2"],zt=[{id:"short",maxWords:5e4},{id:"medium",maxWords:15e4},{id:"long",maxWords:1/0}],Bt={harvard_classics:{en:"Harvard Classics",zh:"哈佛经典",descEn:"Harvard classics list",descZh:"哈佛大学经典书单"},columbia_lithum:{en:"Columbia Lit Hum",zh:"哥大文学核心",descEn:"Columbia must-read",descZh:"哥大本科必读书"},stjohns_greatbooks:{en:"Great Books",zh:"经典名著课程",descEn:`St. John's "Great Books" program`,descZh:"圣约翰学院“Great Books”课程书单"},ap_literature:{en:"AP Literature",zh:"AP 文学",descEn:"US AP-level lit",descZh:"美国大学先修课"},commoncore_hs:{en:"Common Core",zh:"美国K12必读",descEn:"US K-12 must-read",descZh:"美国中小学必读"},harvard_reading:{en:"Harvard Reading",zh:"哈佛推荐",descEn:"Harvard recommended",descZh:"哈佛大学推荐书"},yale_princeton:{en:"Yale / Princeton",zh:"耶鲁/普林斯顿",descEn:"Yale/Princeton picks",de
2scZh:"耶鲁普林斯顿推荐"},canada_university:{en:"Canadian Univ.",zh:"加拿大大学",descEn:"Top Canadian unis",descZh:"加拿大名校推荐"},canada_highschool:{en:"Canadian HS",zh:"加拿大高中",descEn:"Canadian HS must-read",descZh:"加拿大高中必读"}},Mt=["harvard_classics","columbia_lithum","stjohns_greatbooks","ap_literature","commoncore_hs","harvard_reading","yale_princeton","canada_university","canada_highschool"];function nt(t){if(!t)return[];if(Array.isArray(t))return t;try{const n=JSON.parse(t);return Array.isArray(n)?n:[]}catch{return[]}}function Tt(t,n){const s=Bt[t];return s?Le(n)?s.zh:s.en:t}function Pt(t,n){const s=Bt[t];return s?Le(n)?s.descZh||"":s.descEn||"":""}const At="easeverse-curated-filters";function hr(){try{const t=localStorage.getItem(At);if(!t)return null;const n=JSON.parse(t);return!n||typeof n!="object"?null:n}catch{return null}}function gr(t){try{localStorage.setItem(At,JSON.stringify(t))}catch{}}function Dt(t){if(!t||t<=0)return null;for(const n of zt)if(t<=n.maxWords)return n.id;return"long"}function fr({ctx:t}){const{t:n,language:s,api:c,isPaid:g,goBackHome:f,setError:y,setBooks:a,setLocalFileIds:v,books:b}=t,i=et(),[M]=St(),o=(M.get("clang")||"en").toLowerCase(),[d,u]=l.useState(null),[_,D]=l.useState(!0),[x,S]=l.useState({}),[j,m]=l.useState({}),[C,$]=l.useState(()=>{const k=hr();return{difficulty:(k==null?void 0:k.difficulty)||"all",length:(k==null?void 0:k.length)||"all",list:(k==null?void 0:k.list)||"all",free:(k==null?void 0:k.free)||"all"}});l.useEffect(()=>{gr(C)},[C]);const A=oe.useMemo(()=>{const k=new Set;for(const z of b||[])z.canonical_book_id&&k.add(z.canonical_book_id);return k},[b]),L=l.useCallback(k=>{if(!k||!b)return null;const z=b.find(Y=>Y.canonical_book_id===k);return z?z.id:null},[b]);l.useEffect(()=>{let k=!1;return(async()=>{try{const{books:z}=await c.getCuratedBooks();k||u(z||[])}catch(z){k||y(z.message||"Failed to load curated books")}finally{k||D(!1)}})(),()=>{k=!0}},[c,y]);const W=l.useCallback(async k=>{if(!x[k.id]){if(!g&&!k.free_access){y(n("library.cloudUpgrade"));return}S(z=>({...z,[k.id]:!0})),m(z=>({...z,[k.id]:0}));try{const z=await c.addCuratedBookFull(k,Y=>{m(K=>({...K,[k.id]:Y}))});a(Y=>Y.some(K=>K.id===z.book_id)?Y:[{id:z.book_id,title:k.title,author:k.author,language:k.language,file_url:k.file_url??!0,canonical_book_id:z.canonical_book_id,created_at:new Date().toISOString(),updated_at:new Date().toISOString()},...Y]),v(Y=>new Set([...Y,z.book_id])),i(`/read/${z.book_id}`)}catch(z){z.code==="PLAN_REQUIRED"?y(n("library.cloudUpgrade")):z.code==="BOOK_LIMIT"?y(n("library.bookLimitExceeded")):y(z.message||"Failed to add book")}finally{S(z=>({...z,[k.id]:!1})),m(z=>{const Y={...z};return delete Y[k.id],Y})}}},[x,g,c,n,y,a,v,i]),q=oe.useMemo(()=>d?d.filter(k=>(k.language||"").toLowerCase()===o):null,[d,o]),G=oe.useMemo(()=>q?q.filter(k=>{if(C.free==="free"&&!k.free_access||C.difficulty!=="all"&&k.difficulty_level!==C.difficulty||C.list!=="all"&&!nt(k.reading_lists).includes(C.list))return!1;if(C.length!=="all"){const z=Dt(k.total_words);if(z&&z!==C.length)return!1}return!0}):null,[q,C]);return e.jsxs("section",{className:"curated-library-view",children:[e.jsxs("div",{className:"grid-view-header",children:[e.jsx("button",{className:"btn-back",onClick:f,"aria-label":n("library.back"),children:e.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M15 18l-6-6 6-6"})})}),e.jsx("div",{className:"grid-view-header-left",children:e.jsx("h2",{children:n(o==="fr"?"library.curatedFrench":"library.curatedEnglish")})}),e.jsxs("div",{className:"grid-view-header-right",children:[!g&&q&&q.some(k=>k.free_access)&&e.jsxs("button",{type:"button",className:`curated-free-chip ${C.free==="free"?"active":""}`,onClick:()=>$(k=>({...k,free:k.free==="free"?"all":"free"})),"aria-pressed":C.free==="free",children:[n("library.freeBadge"),e.jsx("span",{className:"grid-filter-count",children:q.filter(k=>k.free_access).length})]}),q&&q.length>0&&e.jsx(ur,{filters:C,setFilters:$,books:q,t:n,uiLang:s})]})]}),_?e.jsxs("div",{className:"books-loading",children:[e.jsx("div",{className:"loading-spinner"}),e.jsx("p",{children:n("library.loading")})]}):!q||q.length===0?e.jsxs("div",{className:"books-empty",children:[e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 -960 960 960",fill:"currentColor",width:"48",height:"48",children:e.jsx("path",{d:"M80-160v-80h800v80H80Zm80-160v-320h80v320h-80Zm160 0v-480h80v480h-80Zm160 0v-480h80v480h-80Zm280 0L600-600l70-40 160 280-70 40Z"})}),e.jsx("p",{children:n("library.curatedComingSoon")})]}):G&&G.length===0?e.jsx("div",{className:"books-empty",children:e.jsx("p",{children:Le(s)?"没有符合筛选条件的书":"No books match the current filters"})}):e.jsx("div",{className:"curated-grid",children:G.map(k=>{const z=A.has(k.canonical_book_id),Y=z?L(k.canonical_book_id):null;return e.jsx(yr,{book:k,token:c.token,adding:!!x[k.id],progress:j[k.id],owned:z,onAdd:()=>W(k),onOpen:()=>Y&&i(`/read/${Y}`),t:n,uiLang:s,isPaid:g},k.id)})})]})}const kt={en:{A1:"Starter",A2:"Elementary",B1:"Intermediate",B2:"Upper-Inter.",C1:"Advanced",C2:"Mastery"},zh:{A1:"入门",A2:"基础",B1:"中级",B2:"中高级",C1:"高级",C2:"精通"},"zh-TW":{A1:"入門",A2:"基礎",B1:"中級",B2:"中高級",C1:"高級",C2:"精通"},fr:{A1:"Débutant",A2:"Élémentaire",B1:"Intermédiaire",B2:"Interméd. sup.",C1:"Avancé",C2:"Maîtrise"}};function pr(t){if(!t)return{quote:"",hasMore:!1};const n=t.match(/^[^。!?.!?\n]+[。!?.!?]/);if(n){const s=n[0].trim();return{quote:s,hasMore:t.length>s.length+2}}if(t.length>60){const s=t.lastIndexOf(",",60);return{quote:t.slice(0,s>20?s+1:60)+"……",hasMore:!0}}return{quote:t,hasMore:!1}}function Et({bucket:t}){const s={short:.3333333333333333,medium:.6666666666666666,long:1}[t];
2if(!s)return null;const c=7,g=7,f=5.5,y={viewBox:"0 0 14 14",width:14,height:14,"aria-hidden":!0,style:{verticalAlign:"-2px",marginRight:4}};if(s>=1)return e.jsx("svg",{...y,children:e.jsx("circle",{cx:c,cy:g,r:f,fill:"currentColor"})});const a=s*2*Math.PI,v=c+f*Math.sin(a),b=g-f*Math.cos(a),i=s>.5?1:0;return e.jsxs("svg",{...y,children:[e.jsx("circle",{cx:c,cy:g,r:f,fill:"none",stroke:"currentColor",strokeWidth:"1"}),e.jsx("path",{d:`M ${c} ${g} L ${c} ${g-f} A ${f} ${f} 0 ${i} 1 ${v} ${b} Z`,fill:"currentColor"})]})}function mr(t,n){if(!t||t<=0)return null;const c=["zh","ja","ko"].includes((n||"").toLowerCase())?350:150;return t/(c*60)}function Nt(t,n,s){return(s==="zh"||s==="zh-TW"?t[`${n}_zh`]:t[`${n}_en`])||t[`${n}_en`]||t[`${n}_zh`]||""}function yr({book:t,token:n,adding:s,progress:c,owned:g,onAdd:f,onOpen:y,t:a,uiLang:v,isPaid:b}){var C;const[i,M]=l.useState(null),o=l.useRef(null);l.useEffect(()=>{if(!n)return;let $=!1;return(async()=>{try{const A=await fetch(`${pn}/reader/curated-books/${t.id}/cover`,{headers:{Authorization:`Bearer ${n}`}});if(!A.ok||$)return;const L=await A.blob();if($)return;const W=URL.createObjectURL(L);o.current=W,M(W)}catch{}})(),()=>{$=!0,o.current&&URL.revokeObjectURL(o.current)}},[n,t.id]);const d=Nt(t,"description",v),u=Nt(t,"title",v),_=(t.language||"").toLowerCase(),D=v==="zh"||v==="zh-TW",x=u&&u!==t.title&&(_==="en"&&D||_!=="en"&&v==="en"||_==="en"&&v==="fr"),S=kt[v]||kt.en,j=t.difficulty_level||"",m=S[j]||j;return e.jsxs("article",{className:"curated-book-card",children:[e.jsxs("div",{className:"curated-book-cover",children:[!b&&!!t.free_access&&e.jsx("span",{className:`curated-free-badge ${t.free_access_source==="rotation"?"rotation":""}`,children:t.free_access_source==="rotation"?a("library.freeThisMonth"):a("library.freeBadge")}),i?e.jsx("img",{src:i,alt:t.title}):e.jsx("div",{className:"curated-book-cover-placeholder",children:e.jsx("span",{children:((C=t.title)==null?void 0:C[0])||"?"})})]}),e.jsxs("div",{className:"curated-book-info",children:[e.jsx("h3",{className:"curated-book-title",title:t.title,children:t.title}),x&&e.jsx("p",{className:"curated-book-subtitle",children:u}),t.author&&e.jsx("p",{className:"curated-book-author",children:t.author}),d&&(()=>{const{quote:$,hasMore:A}=pr(d);return e.jsxs("div",{className:"curated-book-quote-wrap",children:[e.jsx("p",{className:"curated-book-quote",children:$}),A&&e.jsx("div",{className:"curated-book-quote-full",children:d})]})})(),e.jsxs("div",{className:"curated-book-meta",children:[t.language&&e.jsx("span",{className:"curated-meta-tag",children:t.language.toUpperCase()}),j&&e.jsx("span",{className:"curated-meta-tag curated-meta-level",title:m,children:j}),(()=>{const $=Dt(t.total_words);if($){const A=Le(v),L=["zh","ja","ko"].includes((t.language||"").toLowerCase()),W=mr(t.total_words,t.language),q=W?W<10?W.toFixed(1).replace(/\.0$/,""):Math.round(W).toString():null;let G;if(A){const k=parseFloat((t.total_words/1e4).toFixed(1)),z=L?"字":"词";G=q?`约 ${q} 小时(${k}万${z})`:`约 ${k}万${z}`}else{const k=L?"characters":"words",z=(t.total_words/1e3).toFixed(0);G=q?`~${q}h read (${z}k ${k})`:`~${z}k ${k}`}return e.jsx("span",{className:"curated-meta-tag curated-meta-length",title:G,children:e.jsx(Et,{bucket:$})})}return t.total_chapters?e.jsxs("span",{className:"curated-meta-tag",children:[t.total_chapters," ",a("library.chapterUnit")||"ch."]}):null})(),(()=>{const $=Mt.filter(k=>nt(t.reading_lists).includes(k));if(!$.length)return null;const A=$.length,L=Le(v),W=L?`${A} 个书单`:A===1?"1 list":`${A} lists`,G=(L?`在这 ${A} 个书单中:`:`On ${A} reading list${A>1?"s":""}:`)+`
3`+$.map(k=>`${Tt(k,v)} — ${Pt(k,v)}`).join(`
4`);return e.jsx("span",{className:"curated-meta-tag curated-meta-list",title:G,children:W})})()]}),g?e.jsx("button",{className:"curated-add-btn curated-owned-btn",onClick:y,children:a("library.continueReading")}):e.jsx("button",{className:`curated-add-btn ${s?"curated-add-btn-loading":""}`,onClick:f,disabled:s,children:s?c!=null&&c<100?`${c}%`:a("library.adding"):a("library.addToMyLibrary")})]})]})}const xr=oe.memo(fr);function br({book:t,onChoice:n,t:s}){return t?e.jsx("div",{className:"delete-dialog-overlay",onClick:()=>n("cancel"),children:e.jsxs("div",{className:"delete-dialog",onClick:c=>c.stopPropagation(),children:[e.jsx("p",{className:"delete-dialog-title",children:t.title}),e.jsx("p",{className:"delete-dialog-desc",children:s("library.deleteDialogDesc")}),e.jsxs("div",{className:"delete-dialog-actions",children:[e.jsx("button",{type:"button",className:"delete-dialog-btn delete-dialog-btn-local",onClick:()=>n("local"),children:s("library.deleteLocalOnly")}),e.jsx("button",{type:"button",className:"delete-dialog-btn delete-dialog-btn-full",onClick:()=>n("full"),children:s("library.deleteCompletely")}),e.jsx("button",{type:"button",className:"delete-dialog-btn delete-dialog-btn-cancel",onClick:()=>n("cancel"),children:s("library.cancel")})]})]})}):null}const vr=oe.memo(br);function wr({book:t,onChoice:n,t:s}){return t?e.jsx("div",{className:"delete-dialog-overlay",onClick:()=>n("cancel"),children:e.jsxs("div",{className:"delete-dialog phantom-dialog",onClick:c=>c.stopPropagation(),children:[e.jsx("p",{className:"delete-dialog-title",children:t.title}),e.jsx("p",{className:"delete-dialog-desc",children:s("library.phantomDialogDesc")}),e.jsxs("div",{className:"delete-dialog-actions",children:[e.jsx("button",{type:"button",className:"delete-dialog-btn delete-dialog-btn-local",onClick:()=>n("upload"),children:s("library.phantomUploadNew")}),e.jsx("button",{type:"button",className:"delete-dialog-btn delete-dialog-btn-full",onClick:()=>n("remove"),children:s("library.phantomRemove")}),e.jsx("button",{type:"button",className:"delete-dialog-btn delete-dialog-btn-cancel",onClick:()=>n("cancel"),children:s("library.cancel")})]})]})}):null}const _r=oe.memo(wr);function zr(){var ft;const[t,n]=l.useState([]),[s,c]=l.useState(!0),[g,f]=l.useState(!1),[y,a]=l.useState(""),[v,b]=l.useState(!1),[i,M]=l.useState({}),[o,d]=l.useState(new Set),[u,_]=l.useState({}),[D,x]=l.useState({}),[S,j]=l.useState(!1),[m,C]=l.useState(new Set),[$,A]=l.useState(new Set),[L,W]=l.useState(!1),[q,G]=l.useState(new Set),k={storage:"all",language:"all"},[z,Y]=l.useState(k),[K,ie]=l.useState(new Set),[E,T]=l.useState(null),[p,I]=l.useState(null),[Z,Q]=l.useState(null),te=l.useRef(null),[re,ae]=l.useState(null),me=l.useRef(null),fe=l.useRef(null),de=l.useRef(!1),pe=l.useRef(0),{user:w,getToken:U,sessionInvalidMessage:O}=Oe(),{t:P,language:se}=ve(),ce=!!(w!=null&&w.readerPaid),_e=(w==null?void 0:w.readerBookLimit)??3,R=Tn(w),ee=et(),[H,he]=St(
4),ge=H.get("view")||"landing",ze=(H.get("q")||"").trim().toLowerCase(),rt=l.useCallback(r=>ze?r.filter(h=>(h.title||"").toLowerCase().includes(ze)||(h.author||"").toLowerCase().includes(ze)):r,[ze]),{boxSelectStart:at,boxSelectCurrent:It,boxSelectActiveRef:$t}=Gn({viewMode:ge,gridScrollRef:fe,justDidBoxSelectRef:de,setCloudSelectedIds:C,setCloudSelectionMode:j,setGridSelectedIds:G,setGridSelectionMode:W}),{bookCovers:Ft,coverLoading:Rt}=Vn({books:t,localFileIds:o,api:ne});l.useEffect(()=>{const r="#fafafa",h=[document.documentElement,document.body,document.getElementById("root")].filter(Boolean),N=h.map(B=>B.style.backgroundColor);return h.forEach(B=>{B.style.backgroundColor=r}),()=>{h.forEach((B,F)=>{B.style.backgroundColor=N[F]})}},[]);const st=oe.useRef(H.toString());l.useEffect(()=>{const r=H.toString(),h=r!==st.current;st.current=r,ge!=="cloud-library"&&(j(!1),C(new Set)),ge!=="all-books"&&ge!=="local-library"?(W(!1),G(new Set),Y(k)):h&&Y(k)},[ge,H]);const He=oe.useRef(null);l.useEffect(()=>{const r=H.get("openPicker");if(!r||He.current===r)return;const h=t.find(N=>N.id===r);if(h){if(h.conversion_status!=="pending_preview"){He.current=r,he(N=>{const B=new URLSearchParams(N);return B.delete("openPicker"),B},{replace:!0});return}He.current=r,Ae(h),he(N=>{const B=new URLSearchParams(N);return B.delete("openPicker"),B},{replace:!0})}},[t,H,he]);const ot="easeverse-reader-cloud-pinned";l.useEffect(()=>{if(w!=null&&w.id)try{const r=localStorage.getItem(`${ot}-${w.id}`);if(r){const h=JSON.parse(r);Array.isArray(h)&&A(new Set(h))}}catch{}},[w==null?void 0:w.id]);const it="easeverse-reader-local-pinned";l.useEffect(()=>{if(w!=null&&w.id)try{const r=localStorage.getItem(`${it}-${w.id}`);if(r){const h=JSON.parse(r);Array.isArray(h)&&ie(new Set(h))}}catch{}},[w==null?void 0:w.id]);const Wt=l.useCallback(r=>{if(w!=null&&w.id)try{localStorage.setItem(`${it}-${w.id}`,JSON.stringify([...r]))}catch{}},[w==null?void 0:w.id]),qt=l.useCallback(r=>{if(w!=null&&w.id)try{localStorage.setItem(`${ot}-${w.id}`,JSON.stringify([...r]))}catch{}},[w==null?void 0:w.id]),lt=l.useCallback(async()=>{try{c(!0);const[{books:r},h]=await Promise.all([ne.getBooks(),ne.getLocalFileBookIds()]);n(r||[]),d(h);try{const{progress:N}=await ne.getAllProgress(),B={};(N||[]).forEach(F=>{B[F.book_id]=F}),_(B)}catch(N){console.warn("Failed to load progress:",N)}try{ne.backfillBookLanguages((r||[]).filter(N=>!N.deleted_at)).catch(()=>{})}catch{}try{const{isGuideBook:N,upgradeGuideBookIfNeeded:B}=await Fe(async()=>{const{isGuideBook:X,upgradeGuideBookIfNeeded:V}=await import("./guideBook-XcUfAKKk.js");return{isGuideBook:X,upgradeGuideBookIfNeeded:V}},__vite__mapDeps([0,1,2,3,4])),F=(r||[]).find(N);F&&B(F).catch(()=>{})}catch{}}catch(r){a(P("library.loadFailed")),console.error(r)}finally{c(!1)}},[P]);l.useEffect(()=>{const r=U();if(!r){n([]);return}ne.setToken(r);let h=!1;return(async()=>{ce&&await xn(r).catch(()=>{}),!h&&await lt()})(),()=>{h=!0}},[U,ce,lt]),l.useEffect(()=>{const r=t.filter(B=>B.conversion_status&&B.conversion_status!=="ready"&&B.conversion_status!=="failed"&&B.conversion_status!=="uploading"&&B.conversion_status!=="batch_pending").map(B=>B.id);if(r.length===0)return;let h=!1;const N=setInterval(async()=>{try{const B=await Promise.all(r.map(X=>ne.getBookRemote(X).catch(()=>null)));if(h)return;const F=new Map(B.filter(Boolean).map(X=>[X.id,X]));if(F.size===0)return;n(X=>X.map(V=>F.get(V.id)?{...V,...F.get(V.id)}:V))}catch{}},5e3);return()=>{h=!0,clearInterval(N)}},[t]);const Ot=async()=>{try{const{progress:r}=await ne.getAllProgress(),h={};(r||[]).forEach(N=>{h[N.book_id]=N}),_(h)}catch(r){console.warn("Failed to reload progress:",r)}};l.useEffect(()=>{const r=mn(async()=>{try{const h=await bn(w==null?void 0:w.id),N=await ne.getLocalFileBookIds();n(h||[]),d(N)}catch(h){console.warn("[SyncCallback] Failed to refresh books:",h)}Ot()});return()=>{typeof r=="function"&&r()}},[w==null?void 0:w.id]);const Be=oe.useMemo(()=>{const r=new Set;for(const h of t)(o.has(h.id)||h.file_url)&&r.add(h.id);return r},[t,o]),Ht=r=>Be.has(r),je=oe.useMemo(()=>{const r=new Set;for(const[h,N]of Object.entries(u))(N.finished_at||Number(N.percentage||0)>=100)&&r.add(h);return r},[u]),Pe=r=>new Promise(h=>{te.current=h,Q(r)}),Ue=r=>{Q(null),te.current&&(te.current(r),te.current=null)},Ut=async r=>{if(!R)return await Pe({kind:"upgrade",file:r,pages:0,quota:null});let h;try{h=await Mn(r)}catch{h=null}return h===null?(await Pe({kind:"unreadable",file:r,pages:0,quota:null}),!1):!0},Ae=async r=>{var h,N;ae({bookId:r.id,fileName:r.file_name||r.title||"PDF",chapters:[],totalPages:0,outlineQuality:"good",quota:null,alreadyConvertedIndices:[],cachedPages:[],isScanOnly:!1,charsPerPage:0,tocHarvested:!1,busy:!0,error:null});try{const B=await ne.previewPdfChapters(r.id);if(ae(F=>F&&F.bookId===r.id?{...F,chapters:B.chapters||[],totalPages:B.total_pages||0,outlineQuality:B.outline_quality||"good",quota:B.quota||null,alreadyConvertedIndices:B.already_converted_indices||[],cachedPages:B.cached_pages||[],isScanOnly:!!B.is_scan_only,charsPerPage:B.chars_per_page||0,tocHarvested:!!B.toc_harvested,busy:!1}
4:F),B.is_scan_only){n(F=>F.map(X=>X.id===r.id?{...X,is_scan_only:1}:X));try{await yn(r.id,{is_scan_only:1})}catch(F){console.warn("[Library] patchBookFromServer scan-only failed",F)}}}catch(B){const F=((h=B==null?void 0:B.detail)==null?void 0:h.error_code)==="pdf_outline_unreadable"?P("chapterSelection.unreadablePdf"):((N=B==null?void 0:B.detail)==null?void 0:N.error)||(B==null?void 0:B.message)||"preview failed";ae(X=>X&&X.bookId===r.id?{...X,busy:!1,error:F}:X)}},Jt=async(r,h={})=>{var B;if(!re)return;const N=re.bookId;ae(F=>F&&{...F,busy:!0,error:null});try{await ne.startPdfConversion(N,r,h),n(F=>F.map(X=>X.id===N?{...X,conversion_status:"pending",selected_chapter_indices:JSON.stringify(r)}:X)),ae(null)}catch(F){if(Pn(F)){const V=re==null?void 0:re.fileName;ae(null),await Pe({kind:"upgrade",file:V?{name:V}:null,pages:0,quota:null});return}const X=((B=F==null?void 0:F.detail)==null?void 0:B.error)||(F==null?void 0:F.message)||"start conversion failed";ae(V=>V&&{...V,busy:!1,error:X})}},ct=async r=>{if(!r||r.length===0)return;const h=pt().map(J=>"."+J),N=Array.from(r),B=J=>"."+J.name.split(".").pop().toLowerCase();if(N.some(J=>B(J)===".pdf"&&!Ct("pdf"))){a(P("library.pdfTemporarilyDisabled"));return}const X=N.filter(J=>h.includes(B(J)));if(X.length===0){a(P("library.invalidFormat"));return}const V=An({exts:X.map(B),pdfEnabled:R,readerPaid:ce,currentCount:t.filter(J=>!J.deleted_at).length,limit:_e});if(V==="pdf_upgrade"){await Pe({kind:"upgrade",file:X.find(J=>B(J)===".pdf"),pages:0,quota:null});return}if(V==="book_limit"){a(P("library.freeLimitReached",{limit:_e}));return}f(!0),a("");try{for(const J of X){if(B(J)===".pdf"&&!await Ut(J))continue;const le=await ne.findDuplicateBook(J);if(le){if(le.isPhantom){const{book:be}=await ne.uploadBook(J,le.book.id);n(Te=>Te.some($e=>$e.id===be.id)?Te.map($e=>$e.id===be.id?be:$e):[be,...Te]),d(Te=>new Set([...Te,be.id]));continue}const ye=le.book.author?P("library.bookExistsByAuthor",{author:le.book.author}):"";if(!window.confirm(P("library.bookExists",{title:le.book.title,author:ye})))continue}const{book:ue}=await ne.uploadBook(J);n(ye=>ye.some(be=>be.id===ue.id)?ye.map(be=>be.id===ue.id?ue:be):[ue,...ye]),d(ye=>new Set([...ye,ue.id])),ue.conversion_status==="pending_preview"&&Ae(ue)}}catch(J){const le=J==null?void 0:J.code;le==="DRM_PROTECTED"?a(P("library.drmProtected")):le==="HUFF_NOT_SUPPORTED"?a(P("library.huffNotSupported")):le==="BOOK_LIMIT"?a(P("library.bookLimitExceeded")):le&&/_PARSE_FAILED$/.test(le)?a(P("library.parseFailed")):a(P("library.uploadFailed")),console.error(J)}finally{f(!1)}},Gt=r=>{var N;const h=(N=r.dataTransfer)==null?void 0:N.types;return h?Array.from(h).includes("Files"):!1},Je=r=>{if(r.preventDefault(),r.stopPropagation(),r.type==="dragenter"){if(!Gt(r)||$t.current)return;pe.current+=1,pe.current===1&&b(!0)}else if(r.type==="dragleave"){if(pe.current===0)return;pe.current-=1,pe.current===0&&b(!1)}},Vt=r=>{r.preventDefault(),r.stopPropagation(),pe.current=0,b(!1),r.dataTransfer.files.length>0&&ct(r.dataTransfer.files)},Yt=async(r,h)=>{if(r.stopPropagation(),!i[h.id]){if(!ce){a(P("library.cloudProOnly"));return}M(N=>({...N,[h.id]:!0})),a("");try{const{file_url:N}=await ne.uploadBookToCloud(h.id);n(B=>B.map(F=>F.id===h.id?{...F,file_url:N}:F))}catch(N){(N==null?void 0:N.code)==="BOOK_LIMIT"?a(P("library.bookLimitExceeded")):a(N.message||"Upload to cloud failed"),console.error(N)}finally{M(N=>({...N,[h.id]:!1}))}}},Kt=(r,h)=>{r.stopPropagation();const N=t.find(B=>B.id===h);if(N){if(Qe(N)){if(!confirm(P("library.confirmRemoveCurated")))return;Me(h);return}if(N.file_url&&o.has(h))T(N);else{if(!confirm(P("library.confirmDelete")))return;Me(h)}}},Me=async r=>{try{await ne.deleteBook(r),n(h=>h.filter(N=>N.id!==r))}catch{a(P("library.deleteFailed"))}},Zt=async r=>{const h=E;if(T(null),!(!h||r==="cancel"))if(r==="local")try{await ne.freeLocalSpace(h.id),d(N=>{const B=new Set(N);return B.delete(h.id),B})}catch(N){a(N.message||"Failed to free local space")}else r==="full"&&await Me(h.id)},Qt=r=>{var N;const h=p;I(null),!(!h||r==="cancel")&&(r==="upload"?(N=me.current)==null||N.click():r==="remove"&&Me(h.id))},Xt=l.useCallback(r=>je.has(r),[je]),ke=l.useMemo(()=>t.filter(r=>Be.has(r.id)),[t,Be]),Ne=[...ke].sort((r,h)=>new Date(h.created_at)-new Date(r.created_at)),De=r=>{if(r.last_read_at)return r.last_read_at;const h=u[r.id];
4return(h==null?void 0:h.updated_at)||null},Ee=[...ke].filter(r=>De(r)).sort((r,h)=>new Date(De(h))-new Date(De(r))).slice(0,20),dt=l.useRef(!1);l.useEffect(()=>{dt.current||s||!(w!=null&&w.id)||H.get("onboarding")!=="day2"||(dt.current=!0,(async()=>{try{const{findGuideBook:h,seedGuideBook:N,upgradeGuideBookIfNeeded:B}=await Fe(async()=>{const{findGuideBook:V,seedGuideBook:J,upgradeGuideBookIfNeeded:le}=await import("./guideBook-XcUfAKKk.js");return{findGuideBook:V,seedGuideBook:J,upgradeGuideBookIfNeeded:le}},__vite__mapDeps([0,1,2,3,4])),F=w==null?void 0:w.id,X=F?await h(F):null;if(X){B(X).catch(()=>{}),ee(`/read/${X.id}?onboarding=day2`);return}if(F){const V=await N(F,se);n(J=>J.some(ue=>ue.id===V.id)?J.map(ue=>ue.id===V.id?V:ue):[V,...J]),d(J=>new Set([...J,V.id])),ee(`/read/${V.id}?onboarding=day2`)}}catch{const N=[...Ee,...ke].filter(B=>Be.has(B.id))[0];N?ee(`/read/${N.id}?onboarding=day2`):a(P("library.downloadFailed"))}})())},[s,H,Ee,ke,Be,ee,P,se,w]);const Ge=ke.filter(r=>o.has(r.id)),en=ke.filter(r=>!!r.file_url),ut=oe.useMemo(()=>{var h;const r=new Set;for(const N of t)(N.last_read_at||((h=u[N.id])==null?void 0:h.updated_at)||null)&&!je.has(N.id)&&r.add(N.id);return r},[t,u,je]),ht=l.useCallback(r=>Qe(r),[]),we=l.useCallback(r=>{let h=r;const{storage:N,language:B}=z;return N==="cloud"?h=h.filter(F=>!!F.file_url):N==="local"?h=h.filter(F=>o.has(F.id)):N==="curated"&&(h=h.filter(ht)),B!=="all"&&(h=h.filter(F=>(F.language||"").toLowerCase()===B.toLowerCase())),h},[z,o,ht]),tn=l.useMemo(()=>we(Ge),[Ge,we]),Ie=l.useMemo(()=>[...t].sort((r,h)=>new Date(h.created_at)-new Date(r.created_at)),[t]),gt=l.useMemo(()=>we(Ie),[Ie,we]),Ve=l.useMemo(()=>Ne.filter(r=>ut.has(r.id)),[Ne,ut]),Ye=l.useMemo(()=>[...Ne.filter(r=>je.has(r.id)),...t.filter(r=>!Ne.some(h=>h.id===r.id)&&je.has(r.id))],[Ne,t,je]),nn=l.useMemo(()=>{const r=h=>{var N;return h.last_read_at||((N=u[h.id])==null?void 0:N.updated_at)||null};return we(Ve).sort((h,N)=>new Date(r(N)||0)-new Date(r(h)||0))},[Ve,u,we]),rn=l.useMemo(()=>we(Ye).sort((r,h)=>{var N,B;return new Date(((N=u[h.id])==null?void 0:N.finished_at)||0)-new Date(((B=u[r.id])==null?void 0:B.finished_at)||0)}),[Ye,u,we]),an=l.useCallback(()=>{he({})},[he]),xe={books:t,accessibleBooks:ke,bookCovers:Ft,coverLoading:Rt,bookProgress:u,localFileIds:o,cloudDownloading:D,cloudUploading:i,cloudBooks:en,cloudPinnedIds:$,cloudSelectionMode:S,cloudSelectedIds:m,gridSelectionMode:L,gridSelectedIds:q,gridBookFilter:z,localPinnedIds:K,boxSelectStart:at,boxSelectCurrent:It,isPaid:ce,language:se,gridScrollRef:fe,justDidBoxSelectRef:de,setGridSelectionMode:W,setGridSelectedIds:G,setGridBookFilter:Y,setCloudSelectionMode:j,setCloudSelectedIds:C,setLocalPinnedIds:ie,setCloudUploading:M,setBooks:n,setLocalFileIds:d,setError:a,setCloudDownloading:x,setCloudPinnedIds:A,persistLocalPinned:Wt,persistCloudPinned:qt,api:ne,t:P,getLastReadTime:De,isCloudOnly:r=>!o.has(r.id)&&!!r.file_url,isAccessible:Ht,isBookFinished:Xt,handleOpenBook:async r=>{if(r.file_type==="pdf"&&r.conversion_status==="uploading")return;if(r.file_type==="pdf"&&r.conversion_status==="pending_preview"){Ae(r);return}let h=o.has(r.id);const N=!!r.file_url,B=r.file_type==="pdf"&&r.conversion_status&&r.conversion_status!=="ready";if(h&&r.file_type==="epub_from_pdf"&&r.conversion_status==="ready")try{const V=await ne.getBookRemote(r.id),J=await vn(r.id),le=(V==null?void 0:V.epub_version)??0;J!=null&&le>J&&(await wn(r.id),d(ue=>{const ye=new Set(ue);return ye.delete(r.id),ye}),h=!1,console.log(`[Library §F17] Evicted stale EPUB for ${r.id} (cached v${J}, server v${le})`))}catch(V){console.warn("[Library §F17] freshness check failed (using cache):",(V==null?void 0:V.message)||V)}if(!h&&!N&&!B){I(r);return}const F=H.get("onboarding"),X=F?`?onboarding=${F}`:"";if(h||B){ee(`/read/${r.id}${X}`);return}x(V=>({...V,[r.id]:0}));try{if(!await ne.fetchBookFileFromCloud(r.id,J=>{x(le=>({...le,[r.id]:J}))})){a(P("library.downloadFailed"));return}d(J=>new Set([...J,r.id])),ee(`/read/${r.id}${X}`)}catch{a(P("library.downloadFailed"))}finally{x(V=>{const J={...V};return delete J[r.id],J})}},handleDelete:Kt,handleCloudUpload:Yt,openChapterPickerForBook:Ae,goBackHome:an};return e.jsxs("div",{className:`library-container ${v?"drag-active":""} ${at!=null?"box-selecting":""}`,onDragEnter:Je,onDragLeave:Je,onDragOver:Je,onDrop:Vt,children:[e.jsxs("main",{className:"library-main",children:[e.jsx("input",{ref:me,type:"file",accept:pt().map(r=>"."+r).join(","),multiple:!0,onChange:r=>ct(r.target.files),hidden:!0}),e.jsx(Ln,{}),e.jsx(Zn,{}),O&&e.jsx(_n,{message:O,onReLogin:()=>{window.location.href="/auth"}}),y&&e.jsxs("div",{className:"library-error",children:[y,e.jsx("button",{type:"button",onClick:()=>a(""),"aria-label":"Dismiss",children:"×"})]}),e.jsx(er,{books:t,onDeleteBook:r=>{confirm(P("library.confirmDelete"))&&Me(r.id)}}),v&&e.jsx("div",{className:"drop-overlay",children:e.jsxs("div",{className:"drop-content",children:[e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:e.jsx("path",{d:"M12 16v-8m0 0l-4 4m4-4l4 4M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z",strokeLinecap:"round",strokeLinejoin:"round"})}),e.jsx("p",{children:P("library.dropHere")}
4),e.jsx("span",{children:P("library.dropFormats")})]})}),s?e.jsxs("div",{className:"books-loading",children:[e.jsx("div",{className:"loading-spinner"}),e.jsx("p",{children:P("library.loading")})]}):ze?e.jsx(Ce,{title:`"${H.get("q")}" — ${rt(Ne).length} ${P("library.searchResults")}`,bookList:rt(Ne),gridViewType:null,ctx:xe}):ge==="all-books"&&H.get("filter")==="reading"?e.jsx(Ce,{title:P("sidebar.reading"),bookList:nn,filterBaseList:Ve,gridViewType:"reading",ctx:xe}):ge==="all-books"&&H.get("filter")==="finished"?e.jsx(Ce,{title:P("sidebar.finished"),bookList:rn,filterBaseList:Ye,gridViewType:"finished",ctx:xe}):ge==="all-books"?e.jsx(Ce,{title:P("library.allBooks"),bookList:gt,filterBaseList:Ie,gridViewType:"all-books",ctx:xe}):ge==="local-library"?e.jsx(Ce,{title:P("library.localLibrary"),bookList:tn,filterBaseList:Ge,gridViewType:"local-library",ctx:xe}):ge==="cloud-library"?e.jsx(Kn,{ctx:xe}):ge==="continue-reading"?e.jsx(Ce,{title:P("library.continueReading"),bookList:Ee,gridViewType:null,ctx:xe}):ge==="curated-library"?e.jsx(xr,{ctx:xe}):ge==="home"?e.jsx(Ce,{title:P("library.allBooks"),bookList:gt,filterBaseList:Ie,gridViewType:"all-books",ctx:xe}):e.jsx(dr,{ctx:xe,recentBooks:Ee,fileInputRef:me})]}),e.jsx(vr,{book:E,onChoice:Zt,t:P}),e.jsx(_r,{book:p,onChoice:Qt,t:P}),Z&&e.jsx(zn,{kind:Z.kind,pages:Z.pages,quota:Z.quota,fileName:((ft=Z.file)==null?void 0:ft.name)||"",onConfirm:()=>Ue(!0),onCancel:()=>Ue(!1),onUpgrade:()=>{Ue(!1),window.open("https://easeverse.ink/pricing","_blank","noopener")}}),re&&e.jsx(Bn,{fileName:re.fileName,chapters:re.chapters,totalPages:re.totalPages,outlineQuality:re.outlineQuality,quota:re.quota,alreadyConvertedIndices:re.alreadyConvertedIndices||[],isScanOnly:!!re.isScanOnly,charsPerPage:re.charsPerPage||0,tocHarvested:!!re.tocHarvested,cachedPages:re.cachedPages||[],busy:re.busy,error:re.error,onClose:()=>ae(null),onSubmit:(r,h)=>Jt(r,h)})]})}export{zr as default};
5//# sourceMappingURL=Library-CVMKUhhy.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.