PageSourceSearch

https://mayulearn.com/assets/SelectStudySetPage-C9UqEuM2.js

js mayulearn.com collected 2026-09-24 14:47:51 UTC 9,752 bytes, 1 lines download raw bytes

1import{c as G,r as d,j as s,b as Q,u as W,L as X}from"./react-vendor-CuXqCZZG.js";import{g as q,a6 as Z,a7 as B,_ as J,a8 as V,a9 as _,aa as O,ab as ee,q as te,ac as se,ad as H,I as ae,S as z,C as A,B as K,ae as re}from"./index-C_flNTgt.js";import{u as ne}from"./useIntersectionLoadMore-Dr_n-n20.js";import{L as oe,m as le}from"./LearningStateMoon-CF-2tigP.js";import{u as ie}from"./filterStudySetsByLanguage-B-pzSLql.js";import{R as ce,i as de}from"./studySetProgressUtils-jtMm7Bqu.js";import{b as ue}from"./importTypes-wyLMLFJs.js";import"./supabase-BoK9SHHt.js";function me(t){const e=G.c(10),{children:r,hint:n,className:o}=t,g=d.useId();let u;e[0]!==o?(u=q("group/hint relative cursor-help rounded-sm font-medium text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-2",o),e[0]=o,e[1]=u):u=e[1];let l;e[2]!==n||e[3]!==g?(l=s.jsx("span",{id:g,role:"tooltip",className:"pointer-events-none absolute left-0 top-full z-30 mt-1 hidden w-52 rounded-md border border-border bg-muted px-3 py-2 text-xs font-normal leading-snug text-foreground shadow-sm group-hover/hint:block group-focus-within/hint:block",children:n}),e[2]=n,e[3]=g,e[4]=l):l=e[4];let f;return e[5]!==r||e[6]!==g||e[7]!==u||e[8]!==l?(f=s.jsxs("span",{tabIndex:0,"aria-describedby":g,className:u,children:[r,l]}),e[5]=r,e[6]=g,e[7]=u,e[8]=l,e[9]=f):f=e[9],f}function $(t){return(t??"").trim().toLowerCase()}function ge(){const t=G.c(33),e=Q(),r=W(),{activeStudySet:n,activeStudySetId:o,isReady:g,setActiveStudySet:u}=Z(),{selectedLanguage:l,setSelectedLanguage:f,languageOptions:j}=B(),{showToast:m}=J();let b;
1t[0]!==r.search?(b=new URLSearchParams(r.search),t[0]=r.search,t[1]=b):b=t[1];const i=b;let S;t[2]!==i?(S=i.get("mode"),t[2]=i,t[3]=S):S=t[3];const x=S==="change";let p;t[4]!==i?(p=V(i.get("redirect")),t[4]=i,t[5]=p):p=t[5];const c=p;let R;t[6]!==i?(R=_(i.get("redirect")),t[6]=i,t[7]=R):R=t[7];const y=R;let I;e:{if(!c||!n){I=!1;break e}let h;t[8]!==n.studyLanguage||t[9]!==c?(h=O({gameKey:c,studyLanguage:n.studyLanguage,totalCards:null}),t[8]=n.studyLanguage,t[9]=c,t[10]=h):h=t[10],I=h===null}const v=I;let C,P;t[11]!==o||t[12]!==v||t[13]!==x||t[14]!==g||t[15]!==e||t[16]!==y?(C=()=>{g&&(x||o&&y!=="/"&&v&&e(y,{replace:!0}))},P=[g,x,o,y,e,v],t[11]=o,t[12]=v,t[13]=x,t[14]=g,t[15]=e,t[16]=y,t[17]=C,t[18]=P):(C=t[17],P=t[18]),d.useEffect(C,P);let w;t[19]!==j||t[20]!==e||t[21]!==c||t[22]!==y||t[23]!==l||t[24]!==u||t[25]!==f||t[26]!==m?(w=h=>{if(c&&O({gameKey:c,studyLanguage:h.studyLanguage,totalCards:ee(h)})==="unsupported-language"){const T=te(c).title;m({content:`${T} isn't available for this study language yet.`});return}u({id:h.id,name:h.title,studyLanguage:h.studyLanguage});const N=$(h.studyLanguage),F=$(l==="all"?void 0:l);if(N&&l!=="all"&&N!==F){f(N);const E=j.find(T=>$(T.code)===N)?.label??N.toUpperCase();m({content:`We changed your language to ${E}`})}else N&&l==="all"&&f(N);e(y,{replace:!0})},t[19]=j,t[20]=e,t[21]=c,t[22]=y,t[23]=l,t[24]=u,t[25]=f,t[26]=m,t[27]=w):w=t[27];const k=w;let L;return t[28]!==k||t[29]!==x||t[30]!==c||t[31]!==y?(L={redirectGameKey:c,redirectTarget:y,isChangeMode:x,handleSelectStudySet:k},t[28]=k,t[29]=x,t[30]=c,t[31]=y,t[32]=L):L=t[32],L}function fe(t){const e=G.c(21),{progress:r,className:n,showRetentionHint:o}=t,g=o===void 0?!1:o;let u;e[0]!==r.masteryPercentage?(u=Math.round(r.masteryPercentage*100),e[0]=r.masteryPercentage,e[1]=u):u=e[1];const l=u;let f;e[2]!==r.retentionPercentage?(f=Math.round(r.retentionPercentage*100),e[2]=r.retentionPercentage,e[3]=f):f=e[3];const j=f;let m;e[4]!==n?(m=q("grid grid-cols-1 gap-2 text-sm text-muted-foreground sm:grid-cols-3",n),e[4]=n,e[5]=m):m=e[5];let b;e[6]===Symbol.for("react.memo_cache_sentinel")?(b=s.jsx("span",{className:"font-medium text-foreground",children:"Mastery"}),e[6]=b):b=e[6];let i;e[7]!==l?(i=s.jsxs("p",{children:[b,": ",l,"%"]}),e[7]=l,e[8]=i):i=e[8];let S;e[9]!==j||e[10]!==g?(S=s.jsx("p",{children:g?s.jsxs(s.Fragment,{children:[s.jsx(me,{hint:ce,children:"Retention"}),": ",j,"%"]}):s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"font-medium text-foreground",children:"Retention"}),": ",j,"%"]})}),e[9]=j,e[10]=g,e[11]=S):S=e[11];let x;e[12]===Symbol.for("react.memo_cache_sentinel")?(x=s.jsx("span",{className:"font-medium text-foreground",children:"Cards"}),e[12]=x):x=e[12];let p;e[13]!==r.masteredCards||e[14]!==r.totalCards?(p=s.jsxs("p",{children:[x,": ",r.masteredCards,"/",r.totalCards," ","mastered"]}),e[13]=r.masteredCards,e[14]=r.totalCards,e[15]=p):p=e[15];let c;return e[16]!==m||e[17]!==i||e[18]!==S||e[19]!==p?(c=s.jsxs("div",{className:m,children:[i,S,p]}),e[16]=m,e[17]=i,e[18]=S,e[19]=p,e[20]=c):c=e[20],c}const U=15;function xe(t,e){const r=new Map(t.map(n=>[n.id,n]));for(const n of e)r.set(n.id,n);return[...r.values()]}function Ce(){const t=Q(),{selectedLanguage:e}=B(),{handleSelectStudySet:r}=ge(),n=e==="all"?void 0:e,[o,g]=d.useState(!0),[u,l]=d.useState([]),[f,j]=d.useState(0),[m,b]=d.useState(!1),[i,S]=d.useState(!1),[x,p]=d.useState(null),[c,R]=d.useState(null),[y,I]=d.useState(""),[v,C]=d.useState(null),P=d.useRef(null),w=d.useRef(!1);se(d.useCallback(()=>C(null),[]));const k=ie(u,e),L=d.useMemo(()=>{const a=y.trim().toLowerCase();return a?k.filter(M=>{const D=M.title?.toLowerCase()??"",Y=M.description?.toLowerCase()??"";return D.includes(a)||Y.includes(a)}):k},[k,y]),h=y.trim().length>0,N=h&&m&&!o&&x==null,F=d.useCallback(async()=>{g(!0),R(null),p(null);try{const a=await H({limit:U,offset:0,...n?{studyLanguage:n}:{}});l(a.items),j(a.pagination.nextOffset),b(a.pagination.hasMore)}catch(a){R(a instanceof Error?a.message:"Failed to load study sets"),l([]),j(null),b(!1)}finally{g(!1)}},[n]),E=d.useCallback(async()=>
1{if(!(!m||w.current||o||f==null)){w.current=!0,S(!0),p(null);try{const a=await H({limit:U,offset:f,...n?{studyLanguage:n}:{}});l(M=>xe(M,a.items)),j(a.pagination.nextOffset),b(a.pagination.hasMore)}catch(a){p(a instanceof Error?a.message:"Failed to load more study sets")}finally{w.current=!1,S(!1)}}},[m,o,f,n]);d.useEffect(()=>{F()},[F]),ne(P,{enabled:m&&!o&&!i&&!h,onLoadMore:()=>{E()}}),d.useEffect(()=>{!h||!m||o||i||x||E()},[h,m,o,i,x,E,L.length]);const T=d.useCallback(a=>{C(null),r(a)},[r]);return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"mx-auto w-full max-w-2xl",children:[s.jsxs("div",{className:"mb-6 text-center",children:[s.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Study Sets"}),s.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"Choose the study set you want to learn from."})]}),s.jsx("div",{className:"mb-4",children:s.jsx(ae,{id:"select-study-set-search",label:"Search study sets",labelSrOnly:!0,value:y,onChange:a=>I(a.target.value),placeholder:"Search study sets"})}),o?s.jsx("div",{className:"flex justify-center py-4",children:s.jsx(z,{className:"size-5","aria-label":"Loading study sets"})}):null,c?s.jsx("p",{className:"mb-4 text-center text-sm text-destructive",children:c}):null,N?s.jsxs("div",{className:"mb-4 flex items-center justify-center gap-2 text-sm text-muted-foreground",children:[s.jsx(z,{className:"size-4 border-2","aria-label":"Loading matching study sets"}),s.jsx("span",{children:"Loading more study sets for search..."})]}):null,!o&&u.length===0?s.jsxs(A,{className:"flex flex-col items-center text-center",children:[s.jsx("h2",{className:"text-lg font-semibold",children:"No study sets yet"}),s.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"Create a study set first to start learning."}),s.jsx("div",{className:"mt-4",children:s.jsx(X,{to:"/library/new",onClick:ue,children:s.jsx(K,{type:"button",children:"Create Study Set"})})})]}):null,!o&&!N&&u.length>0&&L.length===0?s.jsxs(A,{className:"text-center",children:[s.jsx("h2",{className:"text-lg font-semibold",children:"No matching study sets"}),s.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"Try another search term."})]}):null,!o&&L.length>0?s.jsxs("div",{className:"space-y-3",children:[L.map(a=>s.jsxs("button",{type:"button",onClick:()=>T(a),onContextMenu:M=>{M.preventDefault(),C({studySet:a,x:M.clientX,y:M.clientY})},className:"w-full rounded-xl border border-border bg-card p-4 text-left transition-colors hover:border-primary/40 hover:bg-primary/5",children:[s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsx("p",{className:"min-w-0 flex-1 text-base font-semibold text-foreground",children:a.title||"Study Set"}),s.jsx(oe,{state:le(a.progress)})]}),a.description?s.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:a.description}):null,de(a.progress)&&a.progress?s.jsx(fe,{progress:a.progress,className:"mt-2"}):s.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:typeof a.termCount=="number"?`${a.termCount} ${a.termCount===1?"term":"terms"}`:"Study Set"})]},a.id)),!h&&m?s.jsx("div",{ref:P,className:"h-1 w-full","aria-hidden":!0}):null,i&&!h?s.jsx("p",{className:"text-center text-sm text-muted-foreground",children:"Loading more study sets..."}):null,x?s.jsxs("div",{className:"flex flex-col items-center gap-2 py-2",children:[s.jsx("p",{className:"text-sm text-destructive",children:x}),s.jsx(K,{type:"button",variant:"secondary",size:"sm",onClick:()=>{E()},children:"Retry"})]}):null]}):null]}),v?s.jsx(re,{x:v.x,y:v.y,className:"min-w-[13.75rem] rounded-md border border-border bg-card p-1 shadow-md",onClick:a=>a.stopPropagation(),children:s.jsx("button",{type:"button",className:"flex w-full items-center rounded-sm px-3 py-2 text-left text-sm font-medium text-foreground transition-colors hover:bg-secondary/60",onClick:()=>{t(`/library/${encodeURIComponent(v.studySet.id)}`),C(null)},children:"Go to Study Set"})}):null]})}export{Ce as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.