1import{u as M,i as Y,r as l,t as S,j as e,k as g,g as v,S as C,f as K,e as n,K as U,C as b,M as V,s as h,x as m}from"./index-xlBnq6Ca.js";import{B as k}from"./badge-DNCmvFff.js";import{A as H,a as J}from"./alert-CIwtZni8.js";import{P as Q}from"./promptPackCategories-CNNH0AU4.js";import{S as X}from"./save-Dvi772wr.js";import{C as _}from"./chevron-left-SsFZdXif.js";const Z=[{value:"founder",label:"Founder / Entrepreneur",icon:"ð"},{value:"agency",label:"Agency / Freelancer",icon:"ð¼"},{value:"creator",label:"Creator / Influencer",icon:"â¨"},{value:"marketing",label:"Marketing / Growth",icon:"ð"},{value:"sales",label:"Sales / Outbound",icon:"ð°"},{value:"developer",label:"Developer / Engineer",icon:"ð¨âð»"},{value:"student",label:"Student / Learning",icon:"ð"},{value:"other",label:"Other",icon:"ð¤"}],ee=[{value:"b2b-saas",label:"B2B SaaS"},{value:"ecommerce",label:"E-commerce / DTC"},{value:"coaching",label:"Coaching / Courses"},{value:"content",label:"Content & Audience Growth"},{value:"local",label:"Local / Service Business"},{value:"agency-services",label:"Agency Services"},{value:"tech-product",label:"Tech / Product Development"},{value:"other",label:"Other"}],se=Q.filter(i=>i!=="Other");function oe(){const i=M(),{user:a}=Y(),[o,p]=l.useState(1),[f,u]=l.useState(!1),[O,P]=l.useState(!0),[E,R]=l.useState(!1),[c,z]=l.useState(""),[d,A]=l.useState(""),[t,B]=l.useState([]),[j,F]=l.useState([]),[L,y]=l.useState(!1),N=3;l.useEffect(()=>{if(!a){i("/login");return}S("onboarding_view",{userId:a.id,metadata:{variant:"packs"}}),P(!1)},[a,i]);const T=async()=>{if(a){u(!0);try{const{error:s}=await h.from("profiles").update({onboarding_completed:!0}).eq("id",a.id);if(s)throw s;i("/app/learn")}catch(s){console.error("Skip error:",s),m({title:"Error",description:"Failed to skip onboarding",variant:"destructive"})}finally{u(!1)}}},I=async()=>{if(a){y(!0);try{let s=h.from("prompt_packs").select("*");t.length>0?s=s.or(`is_featured.eq.true,category.in.(${t.join(",")})`):s=s.eq("is_featured",!0);const{data:r,error:x}=await s.order("is_featured",{ascending:!1}).order("views_count",{ascending:!1}).limit(5);if(x)throw x;F(r||[])}catch(s){console.error("Error fetching recommendations:",s)}finally{y(!1)}}},$=async()=>{if(a){u(!0);try{const{error:s}=await h.from("profiles").update({role_preference:c,primary_focus:d,preferred_categories:t,onboarding_completed:!0}).eq("id",a.id);if(s)throw s;S("onboarding_complete",{userId:a.id,metadata:{variant:"packs",role_preference:c}}),await I(),R(!0)}catch(s){console.error("Onboarding error:",s),m({title:"Error",description:"Something went wrong. Please try again.",variant:"destructive"})}finally{u(!1)}}},w=()=>{o>1&&p(o-1)},q=s=>{B(r=>r.includes(s)?r.filter(x=>x!==s):r.length>=5?(m({title:"Maximum reached",description:"You can select up to 5 categories"}),r):[...r,s])},W=()=>{switch(o){case 1:return c!=="";case 2:return d!=="";case 3:return t.length>=1;default:return!1}},D=async s=>{if(a)try{const{error:r}=await h.from("prompt_pack_saves").insert({pack_id:s,user_id:a.id});if(r)if(r.code==="23505")m({title:"Already saved",description:"This pack is already in your collection"});else throw r;else m({title:"Saved!",description:"Pack added to your collection"})}catch(r){console.error("Error saving pack:",r),m({title:"Error",description:"Failed to save pack",variant:"destructive"})}},G=()=>{t.join(","),i("/app/learn")};return O?e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-primary/5 via-accent/5 to-secondary/5 flex items-center justify-center",children:e.jsx(g,{className:"h-8 w-8 animate-spin text-primary"})}):E?e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-primary/5 via-accent/5 to-secondary/5 flex items-center justify-center p-4",children:e.jsx("div",{className:"max-w-4xl w-full",children:e.jsx(v,{className:"p-8 md:p-12 shadow-2xl border-2",children:e.jsxs("div",{className:"space-y-8",children:[e.jsxs("div",{className:"text-center space-y-4",children:[e.jsx("div",{className:"flex justify-center mb-4",children:e.jsx("div",{className:"h-16 w-16 rounded-full bg-primary/10 flex items-center justify-center",children:e.jsx(C,{className:"h-8 w-8 text-primary"})})}),e.jsx("h2",{className:"text-3xl md:text-4xl font-bold text-foreground",children:"You're all set! ð"}),e.jsx("p",{className:"text-lg text-muted-foreground",children:"Based on your interests, here are some prompt packs to start with:"})]}),L?e.jsx("div",{className:"flex justify-center py-12",children:e.jsx(g,{className:"h-8 w-8 animate-spin text-primary"})}):j.length>0?e.jsx("div",{className:"space-y-4",children:j.map(s=>e.jsx(v,{className:"p-6 hover:bg-accent/5 transition-colors border-2 hover:border-primary/30",children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("h3",{className:"text-lg font-semibold text-foreground",children:s.title}),s.is_featured&&e.jsx(k,{variant:"secondary",className:"text-xs",children:"Featured"})]}),s.subtitle&&e.jsx("p",{className:"text-sm text-muted-foreground",children:s.subtitle}),e.jsxs("div",{className:"flex items-center gap-3 text-xs text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(K,{className:"h-3 w-3"}),s.category]}),s.estimated_prompt_count&&e.jsxs("span",{children:[s.estimated_prompt_count," prompts"]}),s.difficulty_level&&e.jsx(k,{variant:"outline",className:"text-xs",children:s.difficulty_level})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(n,{variant:"outline",size:"sm",onClick:()=>i(`/app/pack/${s.slug}`),children:"View"}),e.jsx(n,{variant:"default",size:"sm",onClick:()=>D(s.id),children:e.jsx(X,{className:"h-4 w-4"})})]})]})},s.id))}):e.jsx("div",{className:"text-center py-8",children:e.jsx("p",{className:"text-muted-foreground",children:"We couldn't load recommendations right now, but you can still explore all prompt packs."})}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 pt-4",children:[e.jsx(n,{variant:"outline",onClick:()=>i("/app/learn"),size:"lg",className:"flex-1",children:"Skip for now"}),e.jsxs(n,{onClick:G,size:"lg",className:"flex-1",children:["Explore All Packs",e.jsx(U,{className:"ml-2 h-4 w-4"})]})]})]})})})}):e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-primary/5 via-accent/5 to-secondary/5 flex items-center justify-center p-3 sm:p-4",children:e.jsxs(v,{className:"w-full max-w-2xl p-4 sm:p-8 shadow-2xl border-2",children:[e.jsxs("div",{className:"mb-8",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("span",{className:"text-sm font-medium text-muted-foreground",children:["Step ",o," of ",N]}),e.jsx("button",{onClick:T,disabled:f,className:"text-sm text-muted-foreground hover:text-foreground transition-colors underline-offset-4 hover:underline",children:"Skip for now"})]}),e.jsx("div",{className:"h-2 bg-muted rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-gradient-to-r from-primary to-accent transition-all duration-500 ease-out rounded-full",style:{width:`${o/N*100}%`}})})]}),o===1&&e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"inline-flex items-center justify-center w-14 h-14 bg-primary/10 rounded-full mb-4",children:e.jsx(C,{className:"h-7 w-7 text-primary"})}),e.jsx("h2",{className:"text-2xl sm:text-3xl font-bold text-foreground mb-2",children:"Welcome to SpeedChat! ð"}),e.jsx("p",{className:"text-base sm:text-lg text-muted-foreground",children:"Let's personalize your experience. What best describes you?"})]}),e.jsx("div",{className:"space-y-2",children:Z.map(s=>e.jsxs("label",{className:`flex items-center gap-3 sm:gap-4 p-3 sm:p-4 border-2 rounded-xl cursor-pointer transition-all hover:border-primary/40 hover:bg-primary/5 ${c===s.value?"border-primary bg-primary/10 shadow-sm":"border-border"}`,children:[e.jsx("input",{type:"radio",name:"role",value:s.value,checked:c===s.value,onChange:r=>z(r.target.value),className:"sr-only"}),e.jsx("span",{className:"text-xl sm:text-2xl",children:s.icon}),e.jsx("span",{className:"font-medium text-base sm:text-lg text-foreground",children:s.label}),c===s.value&&e.jsx(b,{className:"ml-auto h-5 w-5 text-primary"})]},s.value))}),e.jsx(n,{onClick:()=>p(2),disabled:!c,size:"lg",className:"w-full h-12 text-lg",children:"Continue â"})]}),o===2&&e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("h2",{className:"text-2xl sm:text-3xl font-bold text-foreground mb-2",children:"What do you mostly work on?"}),e.jsx("p",{className:"text-base sm:text-lg text-muted-foreground",children:"This helps us recommend the right prompts and courses"})]}),e.jsx("div",{className:"space-y-2",children:ee.map(s=>e.jsxs("label",{className:`flex items-center gap-3 sm:gap-4 p-3 sm:p-4 border-2 rounded-xl cursor-pointer transition-all hover:border-primary/40 hover:bg-primary/5 ${d===s.value?"border-primary bg-primary/10 shadow-sm":"border-border"}`,children:[e.jsx("input",{type:"radio",name:"focus",value:s.value,checked:d===s.value,onChange:r=>A(r.target.value),className:"sr-only"}),e.jsx("span",{className:"font-medium text-base sm:text-lg text-foreground",children:s.label}),d===s.value&&e.jsx(b,{className:"ml-auto h-5 w-5 text-primary"})]},s.value))}),e.jsxs("div",{className:"flex gap-3",children:[e.jsxs(n,{variant:"outline",onClick:w,size:"lg",className:"flex-1 h-12",children:[e.jsx(_,{className:"mr-2 h-4 w-4"})," Back"]}),e.jsx(n,{onClick:()=>p(3),disabled:!d,size:"lg",className:"flex-1 h-12 text-lg",children:"Continue â"})]})]}),o===3&&e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("h2",{className:"text-2xl sm:text-3xl font-bold text-foreground mb-2",children:"What interests you most? â¨"}),e.jsx("p",{className:"text-base sm:text-lg text-muted-foreground",children:"Select up to 5 â we'll personalize your library"})]}),e.jsx("div",{className:"max-h-80 overflow-y-auto pr-2 space-y-2 rounded-xl border-2 border-border p-4",children:se.map(s=>e.jsxs("label",{className:`flex items-center gap-3 p-3 border-2 rounded-lg cursor-pointer transition-all hover:border-primary/40 hover:bg-primary/5 ${t.includes(s)?"border-primary bg-primary/10":"border-border"}`,children:[e.jsx("input",{type:"checkbox",checked:t.includes(s),onChange:()=>q(s),className:"sr-only"}),e.jsx("div",{className:`w-5 h-5 rounded border-2 flex items-center justify-center shrink-0 transition-colors ${t.includes(s)?"bg-primary border-primary":"border-muted-foreground
1/40"}`,children:t.includes(s)&&e.jsx(b,{className:"h-3.5 w-3.5 text-primary-foreground"})}),e.jsx("span",{className:"font-medium text-foreground",children:s})]},s))}),e.jsxs(H,{className:"bg-primary/5 border-primary/20",children:[e.jsx(V,{className:"h-4 w-4 text-primary"}),e.jsxs(J,{className:"text-foreground",children:["Selected ",t.length," of 5 categories. You can change these anytime in settings."]})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsxs(n,{variant:"outline",onClick:w,size:"lg",className:"flex-1 h-12",children:[e.jsx(_,{className:"mr-2 h-4 w-4"})," Back"]}),e.jsx(n,{onClick:$,disabled:!W()||f,size:"lg",className:"flex-1 h-12 text-lg",children:f?e.jsxs(e.Fragment,{children:[e.jsx(g,{className:"mr-2 h-5 w-5 animate-spin"})," Personalizing..."]}):e.jsx(e.Fragment,{children:"Complete Setup â"})})]})]})]})})}export{oe 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.