1import{E as D,J as F,r,cV as j,d1 as S,j as e,aV as E,br as L,d2 as y,L as m,B as P,aD as V,d3 as A}from"./index-C4ajyBlC.js";import{L as T}from"./layers-uzEKLCFI.js";import{U as M}from"./upload-CR_4zTZl.js";import{C as R}from"./chevron-right-CxkxpcgE.js";function W(){if(typeof window>"u")return!1;const t=window.location.hostname||"";return!!(t.includes("staging")||t==="new.chinesetrack.com")}function I(t){return typeof t.wordCount=="number"&&t.wordCount>0?t.wordCount:typeof t.itemCount=="number"?t.itemCount:t.totalItems??0}function O(){const{status:t,user:d}=D(),N=F(),[l,o]=r.useState(null),[x,p]=r.useState(null),[k,i]=r.useState(!1),[u,h]=r.useState(""),[b,c]=r.useState(null),[n,g]=r.useState(!1),v=r.useCallback(async()=>{const s=await j();o(s)},[]);r.useEffect(()=>{if(t!=="authenticated"||!d){o(null);return}let s=!1;return o(null),p(null),(async()=>{try{const a=await j();s||o(a)}catch(a){if(!s){const f=a instanceof Error?a.message:"Could not load decks.";p(f)}}})(),()=>{s=!0}},[t,d]);const w=async()=>{const s=u.trim();if(!s){c("Enter a deck name.");return}g(!0),c(null);try{const a=await A(s);i(!1),h(""),await v(),N(`/study/decks/${a.id}`)}catch(a){const f=a instanceof Error?a.message:"Could not create deck.";c(f)}finally{g(!1)}},C=t==="authenticated"&&!!d&&l===null&&!x;return S()?t==="loading"?e.jsx("div",{className:"mx-auto max-w-3xl px-4 py-10",children:e.jsx("div",{className:"flex min-h-[280px] items-center justify-center",children:e.jsx("div",{className:"h-12 w-12 animate-spin rounded-full border-b-2 border-[#F37021]"})})}):d?e.jsxs("div",{className:"mx-auto max-w-3xl px-4 pb-12 pt-8",children:[e.jsx("div",{className:"mb-8 rounded-2xl border border-orange-100 bg-orange-50/80 p-5 shadow-sm",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"mt-0.5 flex h-10 w-10 shrink-0 items-center justify-center rounded-xl bg-[#F37021] text-white shadow",children:e.jsx(T,{className:"h-5 w-5","aria-hidden":!0})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold uppercase tracking-wide text-orange-900/80",children:"Preview"}),e.jsx("h1",{className:"mt-1 text-2xl font-bold tracking-tight text-slate-900",children:"Decks"}),e.jsx("p",{className:"mt-2 text-sm leading-relaxed text-slate-700 sm:text-base",children:"Decks are lists of saved words from My Words. Review them with spaced repetition when cards are due. Open a deck below to run a review session when you have due or new cards."}),e.jsx("p",{className:"mt-2 text-xs text-slate-600",children:"Reviews use server-side schedulingâcards only appear when they are due or new, not every visit."})]})]})}),d&&e.jsx("div",{className:"mb-6 flex flex-col gap-3 sm:flex-row sm:flex-wrap sm:items-center sm:justify-between",children:e.jsxs("button",{type:"button",onClick:()=>{c(null),h(""),i(!0)},className:"inline-flex items-center justify-center gap-2 rounded-xl border-2 border-[#F37021] bg-white px-4 py-2.5 text-sm font-semibold text-[#F37021] shadow-sm transition hover:bg-orange-50",children:[e.jsx(L,{className:"h-4 w-4","aria-hidden":!0}),"Create deck"]})}),e.jsx("div",{className:"mb-8 rounded-2xl border border-dashed border-orange-200 bg-orange-50/60 p-5",children:e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-xl border border-orange-200 bg-white text-[#F37021]",children:e.jsx(M,{className:"h-5 w-5","aria-hidden":!0})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold text-slate-900",children:"Import CSV / Pleco word list"}),e.jsx("p",{className:"mt-1 text-sm leading-relaxed text-slate-700",children:y()?e.jsx(e.Fragment,{children:"Paste or upload CSV, TSV, or Pleco-style text, match to the dictionary, then import into a deck. Anki .apkg import is coming later."}):e.jsx(e.Fragment,{children:"Coming soon: bulk import from CSV, TSV, or Pleco-style lists. You can still add words from the Dictionary and Sentence Analyzer, and organize decks from your saved words."})})]})]}),e.jsxs("div",{className:"flex shrink-0 flex-col items-stretch gap-2 sm:items-end",children:[y()?e.jsx(m,{to:"/study/decks/import",className:"inline-flex shrink-0 items-center justify-center rounded-xl border-2 border-[#F37021] bg-white px-4 py-2.5 text-sm font-semibold text-[#F37021] shadow-sm transition hover:bg-orange-50",children:"Import word list"}):e.jsx("span",{className:"inline-flex shrink-0 items-center justify-center rounded-xl border-2 border-dashed border-slate-300 bg-white/80 px-4 py-2.5 text-sm font-semibold text-slate-500",children:"Coming soon"}),W()?e.jsx(m,{to:"/study/decks/apkg-prototype",className:"inline-flex items-center justify-center rounded-lg border border-amber-300 bg-amber-50/80 px-3 py-1.5 text-xs font-semibold text-amber-900 hover:bg-amber-100",children:".apkg inspect (staging)"}):null]})]})}),x&&e.jsx("div",{className:"mb-6 rounded-xl border border-red-200 bg-red-50 px-4 py-3 text-sm text-red-800",children:x}),C&&e.jsxs("div",{className:"flex min-h-[200px] flex-col items-center justify-center gap-2 text-slate-500",children:[e.jsx("div",{className:"h-10 w-10 animate-spin rounded-full border-b-2 border-[#F37021]","aria-hidden":!0}),e.jsx("p",{className:"text-sm",children:"Loading your decksâ¦"})]}),l&&l.length===0&&e.jsxs("div",{className:"rounded-2xl border border-slate-200 bg-white p-8 text-center shadow-sm",children:[e.jsx(P,{className:"mx-auto h-12 w-12 text-slate-300","aria-hidden":!0}),e.jsx("p",{className:"mt-4 font-medium text-slate-800",children:"No word lists yet"}),e.jsxs("p",{className:"mt-2 text-sm text-slate-600",children:["Save words from the"," ",e.jsx(m,{to:"/dictionary?tab=browse",className:"font-medium text-[#F37021] underline",children:"Dictionary"})," ","(My Words). Your lists will show up here as decks."]})]}),l&&l.length>0&&e.jsx("ul",{className:"grid gap-4 sm:grid-cols-2",children:l.map(s=>{const a=I(s);return e.jsx("li",{children:e.jsxs("article",{className:"flex h-full flex-col rounded-2xl border border-slate-200/80 bg-white p-5 shadow-sm transition hover:border-orange-200 hover:shadow-md",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("h2",{className:"text-lg font-semibold text-slate-900",children:s.name}),e.jsxs("p",{className:"mt-2 text-sm text-slate-700",children:[e.jsx("span",{className:"font-medium text-slate-800",children:"Total words:"})," ",e.jsx("span",{className:"tabular-nums",children:a})]}),(s.listType==="default"||s.assigned||s.listType==="session")&&e.jsx("p",{className:"mt-1 text-xs text-slate-500",children:[s.listType==="default"?"Default list":null,s.assigned?"Assigned":null,s.listType==="session"?"Session list":null].filter(
1Boolean).join(" · ")})]}),e.jsxs(m,{to:`/study/decks/${s.id}`,className:"mt-5 inline-flex items-center justify-center gap-2 rounded-xl bg-[#F37021] px-4 py-3 text-sm font-semibold text-white shadow transition hover:bg-[#E55A0F] active:scale-[0.98]",children:["View deck",e.jsx(R,{className:"h-4 w-4","aria-hidden":!0})]})]})},s.id)})}),k&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4",role:"dialog","aria-modal":"true","aria-labelledby":"study-decks-create-title",children:e.jsxs("div",{className:"w-full max-w-md rounded-2xl border border-slate-200 bg-white p-6 shadow-xl",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsx("h2",{id:"study-decks-create-title",className:"text-lg font-semibold text-slate-900",children:"Create deck"}),e.jsx("button",{type:"button",onClick:()=>!n&&i(!1),className:"rounded-lg p-1 text-slate-500 hover:bg-slate-100 hover:text-slate-800","aria-label":"Close",children:e.jsx(V,{className:"h-5 w-5"})})]}),e.jsx("p",{className:"mt-2 text-sm text-slate-600",children:"Creates a new list in My Words you can use as a deck here and when saving from the Dictionary."}),e.jsx("label",{className:"mt-4 block text-sm font-medium text-slate-700",htmlFor:"new-deck-name",children:"Deck name"}),e.jsx("input",{id:"new-deck-name",type:"text",value:u,onChange:s=>h(s.target.value),onKeyDown:s=>{s.key==="Enter"&&w(),s.key==="Escape"&&!n&&i(!1)},disabled:n,placeholder:"e.g. HSK 3 travel",className:"mt-1 w-full rounded-xl border border-slate-300 px-3 py-2.5 text-slate-900 shadow-sm focus:border-[#F37021] focus:outline-none focus:ring-2 focus:ring-orange-200 disabled:bg-slate-50",autoFocus:!0}),b&&e.jsx("p",{className:"mt-2 text-sm text-red-700",children:b}),e.jsxs("div",{className:"mt-6 flex justify-end gap-2",children:[e.jsx("button",{type:"button",disabled:n,onClick:()=>i(!1),className:"rounded-xl px-4 py-2 text-sm font-medium text-slate-700 hover:bg-slate-100 disabled:opacity-50",children:"Cancel"}),e.jsx("button",{type:"button",disabled:n||!u.trim(),onClick:()=>void w(),className:"rounded-xl bg-[#F37021] px-4 py-2 text-sm font-semibold text-white shadow hover:bg-[#E55A0F] disabled:cursor-not-allowed disabled:opacity-50",children:n?"Creatingâ¦":"Create deck"})]})]})})]}):e.jsxs("div",{className:"mx-auto max-w-lg px-4 py-16 text-center",children:[e.jsx("p",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500",children:"Preview"}),e.jsx("h1",{className:"mt-2 text-2xl font-semibold text-slate-900",children:"Decks"}),e.jsx("p",{className:"mt-4 text-slate-600 leading-relaxed",children:"Decks are lists of saved words from My Words. Review them with spaced repetition when cards are due."}),e.jsxs("p",{className:"mt-3 text-sm text-slate-500",children:[e.jsx(E,{className:"font-semibold text-[#F37021] underline",children:"Log in"})," to see your decks."]})]}):null}export{O as default}; 2//# sourceMappingURL=StudyDecksPage-C7OFZDfL.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.