PageSourceSearch

https://kometri.com/assets/OnboardingPage-DLZZofVp.js

js kometri.com collected 2026-10-02 01:35:30 UTC 18,078 bytes, 2 lines download raw bytes

1import{j as e}from"./vendor-query-CsYqNbmM.js";import{f as le,r as d}from"./vendor-react-CkrtinOd.js";import{u as G,B as L,r as oe,v as q,w as de,m as ce,t as me}from"./index-BGtza9SP.js";import{u as ue}from"./studyStore-DGaaHfmJ.js";import{b as xe}from"./agent-Cz1qD7uu.js";import{s as J,t as fe}from"./transliterate-lY8u3lJP.js";import{g as ge,c as pe}from"./redditBetaIntent-gSL3GJK0.js";import{u as K}from"./vendor-i18n-l7OMnJqp.js";import{u as he,a as be,b as y}from"./index-B5VnwfK1.js";import{m as ye,o as A,s as je,f as R,V as H,p as we,ak as ve}from"./vendor-ui-Dv3q5jvr.js";import{m as _}from"./proxy-DpZWPpz2.js";import"./en-US-CozxgUTw.js";const $=[{flag:"🇪🇸",code:"es",name:"Spanish"},{flag:"🇫🇷",code:"fr",name:"French"},{flag:"🇩🇪",code:"de",name:"German"},{flag:"🇮🇹",code:"it",name:"Italian"},{flag:"🇵🇹",code:"pt",name:"Portuguese"},{flag:"🇺🇦",code:"uk",name:"Ukrainian"},{flag:"🇯🇵",code:"ja",name:"Japanese"},{flag:"🇰🇷",code:"ko",name:"Korean"},{flag:"🇬🇧",code:"en",name:"English"},{flag:"🇵🇱",code:"pl",name:"Polish"},{flag:"🇹🇷",code:"tr",name:"Turkish"}],Ne=[{id:"beginner",icon:"🌱"},{id:"elementary",icon:"📖"},{id:"intermediate",icon:"💪"},{id:"upper_intermediate",icon:"⚡"},{id:"advanced",icon:"🚀"}];function Ue(){const V=le(),{t:r,i18n:k}=K("onboarding"),{t:j}=K("common"),{user:E}=G(),b=ge()!==null,Q=b?2:3,W=$.filter(a=>a.code!==k.language),[x,F]=d.useState(1),[o,Z]=d.useState(null),[g,ee]=d.useState(null),[M,ke]=d.useState(10),[p,O]=d.useState([]),[C,U]=d.useState(!1),[D,P]=d.useState(null),[Ce,te]=d.useState(new Set),[c,ae]=d.useState(0),[w,se]=d.useState(!1),[z,T]=d.useState(0),v=d.useRef(null),u=he(0),ne=be(u,[-220,220],[-12,12]),B=D===c,Y={en:"English",uk:"Ukrainian",pl:"Polish",es:"Spanish",fr:"French"}[k.language]||"English",N=o?$.find(a=>a.name===o)?.code??"":"",h=o?j(`languages.${N}`,{defaultValue:o}):"",S=o?j(`languages_instr.${N}`,{defaultValue:h}):h,X=d.useCallback(async()=>{if(o){U(!0);try{const a=await xe.onboarding("Generate the starter cards.",{language:o,level:g||"beginner",ui_language:Y}),t=[];try{const s=JSON.parse(a.response),i=Array.isArray(s)?s:s.cards??[];for(const n of i)n.front&&n.back&&t.push({front:n.front,back:n.back,examples:Array.isArray(n.examples)?n.examples:void 0,notes:n.notes||void 0})}catch{for(const s of a.response.split(`
2`)){const i=s.split("|").map(n=>n.trim());if(i.length>=2&&i[0]&&i[1]){const n=i[0].replace(/^\d+[\.\)\-]\s*/,""),f=i[1].replace(/^\d+[\.\)\-]\s*/,"");if(n.toLowerCase()==="front_text"||!n||!f)continue;t.push({front:n,back:f})}}}O(t.slice(0,5))}catch{O([])}finally{U(!1)}}},[o,g,Y]);d.useEffect(()=>{!b&&x===3&&p.length===0&&!C&&X()},[x,b]),d.useEffect(()=>(C?(T(0),v.current=setInterval(()=>{T(a=>a+1)},1800)):v.current&&clearInterval(v.current),()=>{v.current&&clearInterval(v.current)}),[C]),d.useEffect(()=>{const a=p.slice(0,3);if(!B||x!==3||c>=a.length-1)return;let t=!1;const s=setTimeout(async()=>{t||(await y(u,75,{duration:.4,ease:"easeOut"}),!t&&(await y(u,0,{type:"spring",stiffness:220,damping:20}),!t&&(await new Promise(i=>{const n=setTimeout(i,300);t&&clearTimeout(n)}),!t&&(await y(u,-75,{duration:.4,ease:"easeOut"}),!t&&await y(u,0,{type:"spring",stiffness:220,damping:20})))))},700);return()=>{t=!0,clearTimeout(s)}},[B,c]);const re=a=>{P(D===a?null:a),te(t=>new Set(t).add(a))},ie=d.useCallback((a,t)=>{const s=p.slice(0,3),i=t.offset.x<-40||t.velocity.x<-300,n=t.offset.x>40||t.velocity.x>300;(i||n)&&c<s.length-1?y(u,n?520:-520,{duration:.28,ease:"easeIn"}).then(()=>{ae(l=>l+1),P(null),u.set(0)}):y(u,0,{type:"spring",stiffness:300,damping:28})},[c,p,u]),I=async a=>{if(w)return;se(!0);try{const s=await oe.completeOnboarding({learning_language:o?$.find(i=>i.name===o)?.code:void 0,language_level:g||void 0,daily_goal:M,ui_language:k.language});G.getState().setUser(s)}catch{E&&G.getState().setUser({...E,onboarding_completed:!0})}localStorage.setItem(`flshify_onboarding_complete_${E?.id}`,"true"),ue.setState({dailyGoal:M});let t=null;if(o)try{const i=(await q.list(1,50)).collections.find(n=>n.name.toLowerCase()===o.toLowerCase()||n.name.toLowerCase()===h.toLowerCase());if(i)t=i.id;else{const n=$.find(m=>m.name===o)?.code??o.toLowerCase(),f=await q.create({name:h,is_system:!0});if(t=f.id,p.length>0){const m=await de.create({name:r("starter_deck_name",{language:h}),collection_id:f.id,description:r("starter_deck_description",{language:h}),is_system:!0});
2await ce.batchCreate(p.map(l=>({front_text:l.front,back_text:l.back,deck_id:m.id,language:n,source_language:k.language,created_by:"manual",...l.examples&&l.examples.length>0?{examples:l.examples}:{},...l.notes?{notes:l.notes}:{}})),!0)}}}catch{}if(me("onboarding_completed",{learning_language:o,level:g,daily_goal:M,entry:b?"reddit_deck_beta":"standard"}),b){pe();const s=t?`&collection=${encodeURIComponent(t)}`:"";V(`/generate?beta=reddit${s}`,{replace:!0});return}V(a,{replace:!0})};return e.jsxs("div",{className:"fixed inset-0 z-50 bg-background flex flex-col items-center overflow-y-auto",children:[e.jsx("div",{className:"flex items-center gap-2 pt-8 pb-4",children:Array.from({length:Q},(a,t)=>e.jsx("div",{className:`h-2 rounded-full transition-all duration-300 ${t+1===x?"w-8 bg-primary":t+1<x?"w-2 bg-primary":"w-2 bg-muted-foreground/20"}`},t))}),x>1&&e.jsxs("button",{type:"button",onClick:()=>F(x-1),className:"self-start ml-4 sm:ml-8 flex items-center gap-1 text-sm text-muted-foreground hover:text-foreground transition-colors mb-2",children:[e.jsx(ye,{className:"w-4 h-4"}),r("back")]}),e.jsx("div",{className:"flex-1 flex items-center justify-center w-full px-4 pb-12",children:e.jsxs("div",{className:"w-full max-w-[600px]",children:[x===1&&e.jsxs("div",{className:"text-center",children:[e.jsx("h2",{className:"text-2xl sm:text-3xl font-bold text-foreground mb-2 animate-in fade-in slide-in-from-bottom-4 duration-500",style:{animationFillMode:"both"},children:r("language_question")}),e.jsx("p",{className:"text-muted-foreground mb-8 animate-in fade-in slide-in-from-bottom-4 duration-500",style:{animationDelay:"100ms",animationFillMode:"both"},children:r("pick_target")}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-5 gap-3 mb-8",children:W.map((a,t)=>e.jsxs("button",{type:"button",onClick:()=>Z(a.name),className:`cursor-pointer flex flex-col items-center gap-2 p-4 rounded-xl border-2 transition-all duration-200 hover:scale-[1.05] hover:-translate-y-0.5 animate-in fade-in zoom-in-90 duration-300 ${o===a.name?"border-primary bg-primary/10 shadow-md shadow-primary/10":"border-border bg-card hover:border-primary/40 hover:shadow-sm"}`,style:{animationDelay:`${150+t*40}ms`,animationFillMode:"both"},children:[e.jsx("span",{className:"text-3xl transition-transform duration-200 group-hover:scale-110",children:a.flag}),e.jsx("span",{className:`text-sm font-medium ${o===a.name?"text-primary":"text-foreground"}`,children:j(`languages.${a.code}`,{defaultValue:a.name})})]},a.code))}),e.jsx("div",{className:"animate-in fade-in slide-in-from-bottom-4 duration-500",style:{animationDelay:"600ms",animationFillMode:"both"},children:e.jsxs(L,{variant:"brand",size:"lg",onClick:()=>F(2),disabled:!o,className:"px-10",children:[r("continue"),e.jsx(A,{className:"ml-2 h-4 w-4"})]})})]}),x===2&&e.jsxs("div",{className:"text-center",children:[e.jsx("h2",{className:"text-2xl sm:text-3xl font-bold text-foreground mb-2 animate-in fade-in slide-in-from-bottom-4 duration-500",style:{animationFillMode:"both"},children:r("level_question")}),e.jsx("p",{className:"text-muted-foreground mb-8 animate-in fade-in slide-in-from-bottom-4 duration-500",style:{animationDelay:"100ms",animationFillMode:"both"},children:r("level_subtitle")}),e.jsx("div",{className:"space-y-3 mb-8",children:Ne.map((a,t)=>e.jsxs("button",{type:"button",onClick:()=>ee(a.id),className:`cursor-pointer w-full flex items-center gap-4 p-4 rounded-xl border-2 text-left transition-all duration-200 hover:scale-[1.01] hover:-translate-y-px animate-in fade-in slide-in-from-left-4 duration-300 ${g===a.id?"border-primary bg-primary dark:bg-primary/10 shadow-md shadow-primary/10":"border-border bg-card hover:border-primary/40 hover:shadow-sm"}`,style:{animationDelay:`${150+t*60}ms`,animationFillMode:"both"},children:[e.jsx("span",{className:"text-2xl w-8 text-center",children:a.icon}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:`font-semibold ${g===a.id?"text-language dark:text-language":"text-foreground"}`,children:j(`levels.${a.id}`)}),e.jsx("div",{className:"text-sm text-muted-foreground",children:r(`${a.id}_desc`)})]}),e.jsx("div",{className:`ml-auto w-6 h-6 rounded-full border-2 flex items-center justify-center transition-all duration-200 flex-shrink-0 ${g===a.id?"border-primary bg-primary":"border-border"}`,children:g===a.id&&e.jsx(je,{className:"w-3.5 h-3.5 text-primary-foreground"})})]},a.id))}),e.jsx("div",{className:"animate-in fade-in slide-in-from-bottom-4 duration-500",style:{animationDelay:"500ms",animationFillMode:"both"},children:e.jsxs(L,{variant:"brand",size:"lg",onClick:()=>b?I("/generate"):F(3),disabled:!g,className:"px-10",children:[r("continue"),e.jsx(A,{className:"ml-2 h-4 w-4"})]})})]}),x===3&&(()=>{const a="from-[#355126] via-[#263D1D] to-[#111713]";if(C){const t=[r("loading_msg_picking",{defaultValue:"Picking the most useful words…"}),r("ai_generating_vocabulary",{language:S}),r("loading_msg_examples",{defaultValue:"Adding example sentences…"}),r("loading_msg_finishing",{defaultValue:"Almost ready…"})];return e.jsxs("div",{className:"flex flex-col items-center w-full animate-in fade-in duration-500",children:[e.jsx("h2",{className:"text-2xl sm:text-3xl font-bold text-foreground mb-8",children:r("creating_first_cards")}),e.jsxs("div",{className:"relative w-full rounded-3xl border-2 border-dashed border-border bg-muted/30 flex flex-col items-center justify-center gap-6 overflow-hidden",style:{height:"420px"},children:[e.jsx("div",{className:"flex items-end gap-3 h-24",children:[0,1,2].map(s=>e.jsxs(_.div,{className:`relative w-16 h-22 rounded-xl bg-gradient-to-br ${a} shadow-lg shadow-primary/30 overflow-hidden`,style:{height:88},animate:{y:[12,0,0,-8],opacity:[0,1,1,0],scale:[.85,1,1,.95]},transition:{duration:2.4,repeat:1/0,delay:s*.4,times:[0,.25,.75,1],ease:"easeInOut"},children:[e.jsx(_.div,{className:"absolute inset-y-0 w-1/2 bg-gradient-to-r from-transparent via-white/40 to-transparent",animate:{x:["-150%","250%"]},transition:{duration:1.6,repeat:1/0,delay:s*.4+.2,ease:"easeInOut"}}),e.jsxs("div",{className:"absolute bottom-3 left-2 right-2 space-y-1",children:[e.jsx("div",{className:"h-1 rounded-full bg-white/35"}),e.jsx("div",{className:"h-1 w-2/3 rounded-full bg-white/25"})]})]},s))}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute inset-0 rounded-full bg-primary/20 animate-ping"}),e.jsx(R,{className:"relative h-9 w-9 text-primary"})]}),e.jsx("p",{className:"text-sm font-medium text-muted-foreground animate-pulse px-6 text-center animate-in fade-in duration-400",children:t[z%t.length]},z)]})]})}if(p.length>0){const t=p.slice(0,3),s=t[c],i=D===c,n="from-[#355126] via-[#263D1D] to-[#111713]",f=t.length-1-c;return e.jsxs("div",{className:"flex flex-col items-center w-full animate-in fade-in duration-500",children:[e.jsx("h2",{className:"text-2xl sm:text-3xl font-bold text-foreground mb-4",children:r("your_first_words",{language:S})}),e.jsx("div",{className:"flex items-center gap-2 mb-5",children:t.map((m,l)=>e.jsx("div",{className:`rounded-full transition-all duration-300 ${l===c?"w-6 h-1.5 bg-primary":l<c?"w-2 h-1.5 bg-primary":"w-2 h-1.5 bg-muted-foreground
2/20"}`},l))}),e.jsxs("div",{className:"relative w-full mb-6",style:{height:"440px"},children:[[...Array(Math.min(f,2))].map((m,l)=>e.jsx("div",{className:`absolute inset-0 rounded-3xl bg-gradient-to-br ${n} shadow-md`,style:{transform:`translateY(${(l+1)*7}px) scale(${1-(l+1)*.03})`,opacity:.5-l*.15,zIndex:10-l}},`peek-${c}-${l}`)),e.jsx(_.div,{className:"absolute inset-0 cursor-grab active:cursor-grabbing select-none",style:{x:u,rotate:ne,zIndex:20,perspective:"1200px"},drag:"x",dragConstraints:{left:0,right:0},dragElastic:.3,onDragEnd:ie,onClick:()=>{Math.abs(u.get())<5&&re(c)},children:e.jsxs("div",{className:"w-full",style:{transformStyle:"preserve-3d",transform:i?"rotateY(180deg)":"rotateY(0deg)",transition:"transform 0.5s ease",height:"440px"},children:[e.jsxs("div",{className:`absolute inset-0 rounded-3xl overflow-hidden bg-gradient-to-br ${n} flex flex-col items-center justify-center px-8 py-10 shadow-2xl shadow-primary/20`,style:{backfaceVisibility:"hidden"},children:[e.jsx("span",{className:"absolute top-5 left-5 text-xs font-bold uppercase tracking-widest text-white bg-white/20 backdrop-blur-sm px-3 py-1.5 rounded-full",children:h}),e.jsx("button",{type:"button",onClick:m=>{m.stopPropagation(),J(s.front,N??"en")},className:"absolute top-4 right-4 w-9 h-9 rounded-full bg-white/20 hover:bg-white/35 transition-colors flex items-center justify-center backdrop-blur-sm",children:e.jsx(H,{className:"w-4 h-4 text-white"})}),e.jsx("p",{className:"text-5xl sm:text-6xl font-black text-white tracking-tight text-center leading-tight mb-3",children:s.front}),(()=>{const m=fe(s.front,N||void 0);return m?e.jsx("p",{className:"text-base text-white/70 italic mt-1",children:m}):null})(),e.jsxs(_.div,{className:"absolute bottom-6 left-1/2 -translate-x-1/2 flex items-center gap-2 bg-white/25 backdrop-blur-sm border border-white/35 text-white text-sm font-bold px-5 py-2.5 rounded-full shadow-lg pointer-events-none",animate:{y:[0,-4,0]},transition:{duration:1.8,repeat:1/0,ease:"easeInOut"},children:[e.jsx(we,{className:"w-4 h-4"}),r("tap_to_reveal")]}),f>0&&e.jsxs("div",{className:"absolute bottom-6 right-6 text-white/75 text-xs font-bold",children:[c+1,"/",t.length]})]}),e.jsxs("div",{className:"absolute inset-0 rounded-3xl overflow-hidden bg-card border border-border shadow-2xl flex flex-col",style:{backfaceVisibility:"hidden",transform:"rotateY(180deg)"},children:[e.jsx("div",{className:`h-1.5 w-full bg-gradient-to-r ${n} flex-shrink-0`}),e.jsxs("div",{className:"flex-1 p-7 flex flex-col gap-4 justify-center",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground font-semibold uppercase tracking-wider mb-2",children:s.front}),e.jsx("p",{className:"text-4xl sm:text-5xl font-black text-foreground leading-tight",children:s.back})]}),s.examples&&s.examples.length>0&&e.jsx("div",{className:"bg-muted/60 rounded-2xl px-5 py-4",children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-semibold text-foreground leading-snug",children:s.examples[0].text}),e.jsx("p",{className:"text-xs text-muted-foreground italic mt-1",children:s.examples[0].translation})]}),e.jsx("button",{type:"button",onClick:m=>{m.stopPropagation(),J(s.examples[0].text,N??"en")},className:"flex-shrink-0 w-7 h-7 rounded-full bg-muted hover:bg-muted-foreground/20 transition-colors flex items-center justify-center mt-0.5",children:e.jsx(H,{className:"w-3.5 h-3.5 text-muted-foreground"})})]})}),s.notes&&e.jsxs("div",{className:"bg-primary/60 dark:bg-primary/10 border border-primary/50 dark:border-primary/30 rounded-2xl px-5 py-4 flex gap-3",children:[e.jsx("span",{className:"text-lg",children:"💡"}),e.jsx("p",{className:"text-sm text-foreground leading-snug",children:s.notes})]})]}),f>0&&e.jsx("div",{className:"pb-5 flex justify-center",children:e.jsxs(_.span,{className:"flex items-center gap-1.5 text-muted-foreground text-xs font-medium",animate:{x:[-6,6,-6]},transition:{duration:1.6,repeat:1/0,ease:"easeInOut"},children:[e.jsx(ve,{className:"w-3 h-3"}),r("swipe_next")]})})]})]})},`card-${c}`)]}),e.jsx("div",{className:"min-h-[80px] flex flex-col items-center justify-center gap-3",children:i&&c===t.length-1?e.jsxs("div",{className:"animate-in fade-in slide-in-from-bottom-4 duration-300 flex flex-col items-center gap-3",children:[e.jsx("p",{className:"text-sm font-semibold text-language dark:text-language",children:r("words_learned_payoff",{count:t.length,language:S})}),e.jsx(L,{variant:"brand",size:"lg",onClick:()=>I("/dashboard?from=onboarding"),disabled:w,className:"px-10 shadow-lg shadow-primary/20",children:w?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mr-2 h-4 w-4 border-2 border-primary-foreground
2/30 border-t-primary-foreground rounded-full animate-spin"}),j("loading")]}):e.jsxs(e.Fragment,{children:[r("finish_cta"),e.jsx(A,{className:"ml-2 h-4 w-4"})]})})]}):e.jsx("button",{type:"button",onClick:()=>I("/dashboard?from=onboarding"),disabled:w,className:"text-sm text-muted-foreground hover:text-foreground transition-colors underline underline-offset-4 disabled:opacity-50",children:r("skip_for_now")})})]})}return e.jsxs("div",{className:"text-center animate-in fade-in duration-500",children:[e.jsx("div",{className:"flex justify-center mb-6",children:e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute inset-0 rounded-full bg-primary/20 blur-xl scale-150"}),e.jsx("div",{className:"relative w-16 h-16 rounded-full bg-primary flex items-center justify-center shadow-lg shadow-primary/20",children:e.jsx(R,{className:"w-8 h-8 text-primary-foreground"})})]})}),e.jsx("h2",{className:"text-2xl sm:text-3xl font-bold text-foreground mb-2",children:r("ready_to_learn")}),e.jsx("p",{className:"text-muted-foreground mb-8",children:r("lets_create_cards",{language:S})}),e.jsxs(L,{variant:"brand",size:"lg",onClick:X,className:"px-10",children:[e.jsx(R,{className:"mr-2 h-4 w-4"}),r("generate_first_cards")]}),e.jsx("div",{className:"mt-4",children:e.jsxs("button",{type:"button",onClick:()=>I("/dashboard?from=onboarding"),disabled:w,className:"text-sm font-medium text-foreground/70 hover:text-foreground transition-colors disabled:opacity-50 inline-flex items-center gap-1.5",children:[r("skip_for_now")," ",e.jsx(A,{className:"h-3.5 w-3.5"})]})})]})})()]})})]})}export{Ue 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.