1import{bz as A,z as C,aa as _,r as b,j as e,bA as O,bE as R,p as E,s as S,v as y,a1 as P,ag as D,aF as $,B as v}from"./index-BNrdOJig.js";import{R as L,a as F,b as I}from"./onboardingSteps-DCsbHHYK.js";import{A as Q}from"./arrow-right-CRCU77cw.js";import"./circle-question-mark-DwZLL6ii.js";import"./user-BEEPU-TH.js";function G(){const t=A(),l=C(),{preview:p}=_({from:"/_authenticated/onboarding"}),[d,i]=b.useState({}),[j,f]=b.useState(!1),[g,h]=b.useState(!1),x=b.useMemo(()=>{const r=t?.role??"fan";return r==="artist"||r==="label"||r==="producer"||r==="dj"||r==="podcaster"||r==="fan"?r:"fan"},[t?.role]),u=p??x,N=!!p&&p!==x,s=L[u];b.useEffect(()=>{if(!t)return;const r={},o=t.qualifying_answers;o&&Object.keys(o).length>0&&(r.qualify=!0),t.avatar_url&&(r.profile=!0),i(k=>({...k,...r}))},[t?.id]);const n=s.filter(r=>r.required).every(r=>d[r.id]),a=r=>i(o=>({...o,[r]:!0})),c=r=>{if(r.action.kind==="qualify"){f(!0);return}if(r.action.kind==="profile"){a(r.id),l({to:"/channel/settings"});return}a(r.id),r.action.search?l({to:r.action.to,search:r.action.search}):l({to:r.action.to})},m=async()=>{if(!t||!n)return;h(!0);const{error:r}=await S.from("profiles").update({onboarding_completed_at:new Date().toISOString()}).eq("id",t.id);if(h(!1),r){y.error(r.message);return}y.success("You're all set â welcome aboard."),l({to:"/dashboard"})},w=s.filter(r=>d[r.id]).length;
1return e.jsx(O,{profile:t,title:"What's next",subtitle:`A guided checklist for your new ${u} account.`,children:e.jsxs("div",{className:"max-w-3xl mx-auto space-y-6",children:[t?.role==="super_admin"&&e.jsx(B,{active:u,actual:x,onPick:r=>{R(r===x?null:r),l({to:"/onboarding",search:r===x?{}:{preview:r}})}}),N&&e.jsxs("div",{className:"rounded-2xl border border-dashed border-primary/40 bg-primary/5 px-4 py-3 text-xs text-muted-foreground",children:[e.jsx("span",{className:"font-bold uppercase tracking-wider text-primary",children:"Preview mode"})," ","â viewing the ",e.jsx("span",{className:"text-foreground font-semibold",children:u})," guide. Steps below won't update your account. Switch back to"," ",e.jsxs("button",{onClick:()=>l({to:"/onboarding",search:{}}),className:"underline hover:text-primary",children:["your ",x," guide"]}),"."]}),e.jsxs("div",{className:"rounded-3xl border border-border bg-card p-6 sm:p-8",children:[e.jsxs("div",{className:"flex items-center gap-2 text-primary text-xs font-bold tracking-wider uppercase",children:[e.jsx(E,{className:"w-4 h-4"})," Welcome to MO Streams"]}),e.jsx("h2",{className:"font-display text-3xl sm:text-4xl mt-2",children:t?.display_name?`Hey ${t.display_name}, here's your setup.`:"Here's your setup."}),e.jsx("p",{className:"text-sm text-muted-foreground mt-3 leading-relaxed",children:"Knock these out and your dashboard unlocks the rest. You can come back to optional items any time."}),e.jsxs("div",{className:"mt-5 flex items-center gap-3 text-xs font-bold uppercase tracking-wider text-muted-foreground",children:[e.jsx("div",{className:"h-2 w-full rounded-full bg-secondary/40 overflow-hidden",children:e.jsx("div",{className:"h-full bg-primary transition-all",style:{width:`${w/s.length*100}%`}})}),e.jsxs("span",{children:[w," / ",s.length]})]})]}),j?e.jsx(K,{questions:F[u],initial:t?.qualifying_answers??{},onCancel:()=>f(!1),onSaved:async r=>{if(!t)return;const{error:o}=await S.from("profiles").update({qualifying_answers:r}).eq("id",t.id);if(o){y.error(o.message);return}a("qualify"),f(!1),y.success("Thanks â saved.")}}):e.jsx("div",{className:"space-y-3",children:s.map(r=>{const o=!!d[r.id],k=r.icon;return e.jsxs("button",{type:"button",onClick:()=>c(r),className:`w-full text-left rounded-2xl border p-5 flex items-start gap-4 transition-colors ${o?"border-primary/30 bg-primary/5":"border-border bg-card hover:border-primary/60"}`,children:[e.jsx("div",{className:`mt-0.5 w-9 h-9 rounded-full flex items-center justify-center shrink-0 ${o?"bg-primary/20 text-primary":"bg-secondary/60 text-muted-foreground"}`,children:o?e.jsx(P,{className:"w-5 h-5"}):e.jsx(k,{className:"w-5 h-5"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"font-display text-lg",children:r.title}),r.required?e.jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider text-primary bg-primary/10 px-2 py-0.5 rounded-full",children:"Required"}):e.jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider text-muted-foreground bg-secondary/60 px-2 py-0.5 rounded-full",children:"Optional"}),o&&e.jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider text-primary",children:"Done"})]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1 leading-relaxed",children:r.body}),e.jsxs("div",{className:"mt-3 inline-flex items-center gap-1 text-xs font-bold uppercase tracking-wider text-primary",children:[r.cta," ",e.jsx(D,{className:"w-3.5 h-3.5"})]})]}),!o&&e.jsx($,{className:"w-4 h-4 text-muted-foreground shrink-0 mt-1"})]},r.id)})}),e.jsxs("div",{className:"rounded-3xl border border-primary/30 bg-primary/5 p-6 text-sm",children:[e.jsx("div",{className:"font-bold text-primary uppercase tracking-wider text-xs mb-2",children:"When you're done"}),e.jsx("p",{className:"text-foreground leading-relaxed",children:I[u]}),e.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[e.jsxs(v,{className:"btn-gradient rounded-full",disabled:!n||g,onClick:m,children:[g?"Savingâ¦":"Open my dashboard",e.jsx(Q,{className:"w-4 h-4 ml-1.5"})]}),e.jsx(v,{variant:"outline",className:"rounded-full",onClick:()=>l({to:"/dashboard"}),children:"Skip for now"})]}),!n&&e.jsx("p",{className:"text-xs text-muted-foreground mt-3",children:"Finish the required steps above to unlock the full dashboard."})]})]})})}const T=[{key:"fan",label:"Fan"},{key:"artist",label:"Artist"},{key:"label",label:"Label"},{key:"producer",label:"Producer"},{key:"dj",label:"DJ"},{key:"podcaster",label:"Podcaster"}];function B({active:t,actual:l,onPick:p}){return e.jsxs("div",{className:"rounded-2xl border border-border bg-card/60 p-3",children:[e.jsx("div",{className:"text-[10px] font-bold uppercase tracking-wider text-muted-foreground mb-2 px-1",children:"Preview welcome guide"}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:T.map(d=>{const i=d.key===t;return e.jsxs("button",{type:"button",onClick:()=>p(d.key),className:`text-xs font-semibold px-3 py-1.5 rounded-full border transition ${i?"border-primary bg-primary text-primary-foreground":"border-border bg-background hover:border-primary/40"}`,children:[d.label,d.key===l&&e.jsx("span",{className:"ml-1.5 opacity-70 text-[10px] uppercase tracking-wider",children:"you"})]},d.key)})})]})}function K({questions:t,initial:l,onSaved:p,onCancel:d}){const[i,j]=b.useState(l),[f,g]=b.useState(!1),h=(s,n)=>j(a=>({...a,[s]:n})),x=(s,n,a)=>j(c=>{const m=Array.isArray(c[s])?c[s]:[];return m.includes(n)?{...c,[s]:m.filter(w=>w!==n)}:a&&m.length>=a?c:{...c,[s]:[...m,n]}}),u=t.every(s=>{const n=i[s.id];return s.type==="checkbox"?Array.isArray(n)&&n.length>0:typeof n=="string"&&n.trim().length>0}),N=async()=>
1{if(!u){y.error("Answer all questions to continue.");return}g(!0),await p(i),g(!1)};return e.jsxs("div",{className:"rounded-3xl border border-border bg-card p-6 sm:p-8 space-y-6",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-primary text-xs font-bold tracking-wider uppercase",children:"Qualifying questions"}),e.jsx("h3",{className:"font-display text-2xl mt-1",children:"A few quick questions"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"These shape your dashboard, your distribution flow, and what we recommend next."})]}),e.jsx("div",{className:"space-y-5",children:t.map((s,n)=>e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"text-xs font-bold uppercase tracking-wider",children:[n+1,". ",s.label,s.type==="checkbox"&&s.max?e.jsxs("span",{className:"text-muted-foreground",children:[" (pick up to ",s.max,")"]}):null]}),s.type==="radio"&&e.jsx("div",{className:"grid sm:grid-cols-2 gap-2",children:s.options.map(a=>{const c=i[s.id]===a;return e.jsx("button",{type:"button",onClick:()=>h(s.id,a),className:`text-sm text-left px-4 py-2.5 rounded-xl border transition ${c?"border-primary bg-primary/10 text-foreground":"border-border bg-background hover:border-primary/40"}`,children:a},a)})}),s.type==="checkbox"&&e.jsx("div",{className:"flex flex-wrap gap-2",children:s.options.map(a=>{const m=(Array.isArray(i[s.id])?i[s.id]:[]).includes(a);return e.jsx("button",{type:"button",onClick:()=>x(s.id,a,s.max),className:`text-xs px-3 py-1.5 rounded-full border transition ${m?"border-primary bg-primary text-primary-foreground":"border-border bg-background hover:border-primary/40"}`,children:a},a)})}),s.type==="select"&&e.jsxs("select",{value:i[s.id]??"",onChange:a=>h(s.id,a.target.value),className:"w-full rounded-lg bg-background border border-border px-4 py-2.5 text-sm focus:outline-none focus:border-primary",children:[e.jsx("option",{value:"",disabled:!0,children:"Selectâ¦"}),s.options.map(a=>e.jsx("option",{value:a,children:a},a))]}),s.type==="text"&&e.jsx("input",{type:"text",value:i[s.id]??"",onChange:a=>h(s.id,a.target.value),placeholder:s.placeholder,maxLength:200,className:"w-full rounded-lg bg-background border border-border px-4 py-2.5 text-sm focus:outline-none focus:border-primary"})]},s.id))}),e.jsxs("div",{className:"flex flex-wrap gap-2 justify-end pt-2",children:[e.jsx(v,{variant:"outline",className:"rounded-full",onClick:d,children:"Back to checklist"}),e.jsx(v,{className:"btn-gradient rounded-full",disabled:!u||f,onClick:N,children:f?"Savingâ¦":"Save answers"})]})]})}export{G as component};
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.