1!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._posthogChunkIds=e._posthogChunkIds||{},e._posthogChunkIds[n]="01a10c27-9737-7a52-b2fb-bfa6da2cdde6")}catch(e){}}();import{x as J,u as q,a as i,I as X,t as _,a5 as R,q as U,j as e,L as H,B as I,ax as $,b as G,ay as Z,Y as ee,at as te}from"./index-KsBbuwn3.js";import{A as ne}from"./AgentProgressPanel-MxGY-x69.js";import{O as ae}from"./OnboardingAhaView-rxyorXCJ.js";import{b as re}from"./agentProgress-C7ggqU9i.js";import{O as w,c as se,d as oe}from"./onboardingFlow-B84chOMb.js";import"./AiCoachResultView-Bvs9PA4B.js";import"./studioCoachUi-DlghZg0n.js";import"./thumbs-up-C2NPMwzs.js";import"./pencil-L5GtmgYk.js";import"./maximize-2-C8Jluxqz.js";import"./send-D6MnqzdE.js";import"./scriptFilm-B4NfAAfV.js";import"./video-BplmvS4_.js";const ie=["save_profile","find_viral","audience_research","hook_angle","write_script","production_notes"];function W(n,o,a){return re(ie,n,o,a,ce)}function ce(n){switch(n){case"save_profile":return"Saving your niche and audience";case"find_viral":return"Finding what's going viral in your niche";case"audience_research":return"Researching your audience on Reddit and Quora";case"hook_angle":return"Picking a scroll-stopping hook angle";case"write_script":return"Writing your viral script";case"production_notes":return"Adding film-ready production notes";default:return"Working on your script"}}function de(n){const o=n.niche.trim().slice(0,48)||"your niche",a=n.audience.trim().slice(0,48)||"your audience";return{save_profile:`Saving ${o} and ${a}`,find_viral:`Finding what's going viral in ${o}`,audience_research:`Researching ${a} on Reddit and Quora`,hook_angle:"Picking a scroll-stopping hook angle",write_script:"Writing your viral script",production_notes:"Adding film-ready production notes (Instagram audio, B-roll, how to film)"}}const le="You won't need to do this research manually again.",ue=new Date(Z);function ge(n){if(!n)return null;if(n instanceof Date)return n;const o=new Date(String(n));return Number.isNaN(o.getTime())?null:o}function O({children:n,onSkip:o,showSkip:a,step:g,variant:u="standalone"}){const p=g!=null?e.jsx("div",{"data-loc":"client/src/pages/onboarding.tsx:54",className:"flex gap-2",children:[1,2].map(l=>e.jsx("div",{"data-loc":"client/src/pages/onboarding.tsx:56",className:`h-1 flex-1 rounded-full transition-colors ${l<=g?"bg-primary":"bg-muted"}`},l))}):null;return u==="dashboard"?e.jsxs("div",{"data-loc":"client/src/pages/onboarding.tsx:68",className:"flex min-h-0 flex-1 flex-col",children:[(p||a&&o)&&e.jsx("div",{"data-loc":"client/src/pages/onboarding.tsx:70",className:"border-b border-border/50 px-4 py-4 sm:px-6",children:e.jsxs("div",{"data-loc":"client/src/pages/onboarding.tsx:71",className:"mx-auto flex w-full max-w-2xl items-center gap-4",children:[p?e.jsx("div",{"data-loc":"client/src/pages/onboarding.tsx:72",className:"min-w-0 flex-1",children:p}):e.jsx("div",{"data-loc":"client/src/pages/onboarding.tsx:72",className:"flex-1"}),a&&o?e.jsx("button",{"data-loc":"client/src/pages/onboarding.tsx:74",type:"button",onClick:o,className:"shrink-0 rounded-md px-2 py-1.5 text-xs text-muted-foreground transition hover:text-foreground",children:"Skip setup"}):null]})}),n]}):e.jsxs("div",{"data-loc":"client/src/pages/onboarding.tsx:91",className:"min-h-screen bg-background text-foreground",children:[e.jsx("header",{"data-loc":"client/src/pages/onboarding.tsx:92",className:"border-b border-border/50",children:e.jsxs("div",{"data-loc":"client/src/pages/onboarding.tsx:93",className:"mx-auto flex h-14 w-full max-w-2xl items-center justify-between px-4 sm:px-6",children:[e.jsx(ee,{"data-loc":"client/src/pages/onboarding.tsx:94",href:"/",className:"inline-flex min-w-0",children:e.jsx(te,{"data-loc":"client/src/pages/onboarding.tsx:95",size:"header"})}),a&&o?e.jsx("button",{"data-loc":"client/src/pages/onboarding.tsx:98",type:"button",onClick:o,className:"rounded-md px-2 py-1.5 text-xs text-muted-foreground transition hover:text-foreground",children:"Skip setup"}):null]})}),g!=null?e.jsx("div",{"data-loc":"client/src/pages/onboarding.tsx:110",className:"mx-auto flex max-w-2xl gap-2 px-4 pt-5 sm:px-6",children:p}):null,n]})}function ke(){const n=J(),[,o]=q(),[a,g]=i.useState("step1"),[u,p]=i.useState(""),[l,N]=i.useState(""),[h,L]=i.useState(null),[M,B]=i.useState([]),[D,y]=i.useState(null),[Y,j]=i.useState(()=>W("save_profile")),f=i.useRef(null),S=i.useRef(!1),k=i.useRef(!1),A=i.useRef(!1),{user:c,loading:C}=X({redirectOnUnauthenticated:!0});i.useEffect(()=>
1{c&&n?.identify(String(c.id),{email:c.email,name:c.name})},[n,c?.id,c?.email,c?.name]);const m=_.useUtils(),x=_.onboarding.getState.useQuery(void 0,{enabled:!!c,staleTime:6e4,refetchOnWindowFocus:!1}),E=_.onboarding.startCreating.useMutation(),Q=_.onboarding.skip.useMutation(),b=i.useMemo(()=>{if(!c)return!1;const t=ge(c.createdAt);if(!t||t.getTime()<=ue.getTime())return!0;const r=x.data;return r?!!(r.onboardingCompletedAt||r.onboardingSkippedAt):!1},[c,x.data]);i.useEffect(()=>{C||x.isLoading||!c||b&&a==="step1"||(a==="step1"?n?.capture("onboarding_step1_viewed"):a==="step2"?n?.capture("onboarding_step2_viewed"):a==="loading"?n?.capture("onboarding_loading_started"):a==="aha"&&n?.capture("onboarding_aha_viewed"))},[a,n,C,x.isLoading,c,b]),i.useEffect(()=>{if(a!=="loading"){A.current=!1;return}const t=()=>{A.current||(A.current=!0,n?.capture("onboarding_loading_abandoned"))},s=()=>{t()},r=()=>{document.visibilityState==="hidden"&&t()},d=()=>{t()};return window.addEventListener("beforeunload",s),window.addEventListener("pagehide",d),document.addEventListener("visibilitychange",r),()=>{window.removeEventListener("beforeunload",s),window.removeEventListener("pagehide",d),document.removeEventListener("visibilitychange",r)}},[a,n]),i.useEffect(()=>{!b||a==="aha"||a==="loading"||a==="step2"||sessionStorage.getItem(w)||R(o,"/dashboard")},[o,b,a]),i.useEffect(()=>()=>{f.current!=null&&window.clearInterval(f.current)},[]),i.useEffect(()=>{const t=x.data;if(!t?.onboardingCompletedAt||a!=="step1"||h)return;const s=sessionStorage.getItem(w);if(!s)return;const r=Number(s);!Number.isFinite(r)||r<=0||m.studio.get.fetch({id:r}).then(d=>{L(d),p(t.businessDescription?.trim()||u),N(t.targetAudience?.trim()||l),B(t.selectedNicheSlugs??[]),g("aha")}).catch(()=>{sessionStorage.removeItem(w),R(o,"/dashboard")})},[h,l,u,x.data,a,o,m.studio.get]);const z=async()=>{const t=a==="step2"?"step2":"step1";n?.capture("onboarding_skip_clicked",{step:t});try{const s=await Q.mutateAsync();s.alreadyDone||(n?.capture("onboarding_skipped"),n?.capture("onboarding_completed",{niches_selected:0,creators_selected:0,demo_creator_handle:$(s.demoCreatorHandle??""),demo_seeded:!!s.demoJobId})),await m.onboarding.getState.invalidate();const r=U()?"/plan":"/research";R(o,r)}catch(s){G.error(s instanceof Error?s.message:"Could not skip setup")}},T=()=>{const t=u.trim();t.length<3||(n?.capture("onboarding_step1_completed",{char_count:t.length,chip_used:S.current}),g("step2"))},P=()=>{f.current!=null&&(window.clearInterval(f.current),f.current=null)},K=(t,s)=>{P();const r=de({niche:t,audience:s});j(W("save_profile",void 0,r)),m.onboarding.getGenerationProgress.fetch(void 0,{staleTime:0}).then(d=>{d?.steps?.length&&j(d.steps)}).catch(()=>{}),f.current=window.setInterval(()=>{m.onboarding.getGenerationProgress.fetch(void 0,{staleTime:0}).then(d=>{d?.steps?.length&&j(d.steps)}).catch(()=>{})},800)},F=async()=>{const t=u.trim(),s=l.trim();if(!(t.length<3||s.length<3)){n?.capture("onboarding_step2_completed",{char_count:s.length,chip_used:k.current}),y(null),g("loading"),K(t,s);try{const r=await E.mutateAsync({businessDescription:t,targetAudience:s});if(P(),!r.script)throw new Error("Script generation failed. Please try again.");L(r.script),B(r.selectedNicheSlugs),sessionStorage.setItem(w,String(r.script.id)),g("aha"),r.alreadyComplete||(n?.capture("onboarding_completed",{niches_selected:r.selectedNicheSlugs.length,creators_selected:0,demo_creator_handle:$(r.demoCreatorHandle??""),demo_seeded:!!r.demoJobId,first_script_id:r.script.id}),n?.capture("onboarding_first_script_ready",{script_id:r.script.id})),await m.onboarding.getState.invalidate(),m.studio.list.invalidate()}catch(r){P(),console.error("Onboarding start creating failed",r);const d=r instanceof Error?r.message:"Something went wrong. Please try again.";y(d),G.error("Could not create your first script",{description:d}),g("step2")}}},v=U()?"standalone":"dashboard";if(C||x.isLoading)return v==="dashboard"?e.jsx("div",{"data-loc":"client/src/pages/onboarding.tsx:395",className:"flex flex-1 items-center justify-center py-24",children:e.jsx(H,{"data-loc":"client/src/pages/onboarding.tsx:396",className:"h-7 w-7 animate-spin text-primary"})}):e.jsx("div",{"data-loc":"client/src/pages/onboarding.tsx:401",className:"flex min-h-screen items-center justify-center bg-background",children:e.jsx(H,{"data-loc":"client/src/pages/onboarding.tsx:402",className:"h-7 w-7 animate-spin text-primary"})});if(!c||b&&a!=="aha"&&a!=="loading"&&a!=="step2")return null;if(a==="loading"||E.isPending)return e.jsx(O,{"data-loc":"client/src/pages/onboarding.tsx:412",showSkip:!1,step:null,variant:v,children:e.jsx(ne,{"data-loc":"client/src/pages/onboarding.tsx:413",steps:Y,subheadline:`Tailored for ${l.trim().slice(0,48)||"your audience"}
1. Usually 1-2 minutes.`,footer:le,badgeLabel:"Creating"})});if(a==="aha"&&h)return e.jsx(O,{"data-loc":"client/src/pages/onboarding.tsx:425",showSkip:!1,step:null,variant:v,children:e.jsx(ae,{"data-loc":"client/src/pages/onboarding.tsx:426",script:h,niche:u.trim()||"Your niche",audience:l.trim()||"Your audience",selectedNicheSlugs:M,onCtaClick:t=>{n?.capture("onboarding_aha_cta_clicked",{cta:t})}})});const V=a==="step2"?2:1;return e.jsx(O,{"data-loc":"client/src/pages/onboarding.tsx:442",onSkip:z,showSkip:!0,step:V,variant:v,children:e.jsx("main",{"data-loc":"client/src/pages/onboarding.tsx:443",className:"mx-auto w-full max-w-2xl px-4 pb-10 pt-6 sm:px-6",children:a==="step1"?e.jsxs(e.Fragment,{children:[e.jsx("h1",{"data-loc":"client/src/pages/onboarding.tsx:446",className:"text-2xl font-extrabold tracking-tight sm:text-3xl",children:"What do you create content about?"}),e.jsx("p",{"data-loc":"client/src/pages/onboarding.tsx:449",className:"mt-2 text-sm text-muted-foreground",children:"Your niche shapes every script the AI writes for you."}),e.jsx("input",{"data-loc":"client/src/pages/onboarding.tsx:452",type:"text",value:u,onChange:t=>{S.current=!1,p(t.target.value),y(null)},onKeyDown:t=>{t.key==="Enter"&&u.trim().length>=3&&T()},placeholder:"e.g. Fitness, Personal Finance, AI Tools...",maxLength:200,autoFocus:!0,autoComplete:"off",className:"mt-5 w-full rounded-xl border border-border bg-card px-4 py-3 text-sm outline-none transition focus:border-primary"}),e.jsx("p",{"data-loc":"client/src/pages/onboarding.tsx:469",className:"mt-4 text-[11px] font-bold uppercase tracking-wide text-muted-foreground",children:"Popular niches"}),e.jsx("div",{"data-loc":"client/src/pages/onboarding.tsx:472",className:"mt-2 flex flex-wrap gap-2",children:se.map(t=>e.jsx("button",{"data-loc":"client/src/pages/onboarding.tsx:474",type:"button",onClick:()=>{S.current=!0,p(t)},className:`rounded-full border px-3 py-1.5 text-xs font-medium transition ${u===t?"border-primary bg-primary/10 text-primary":"border-border bg-card text-muted-foreground hover:border-primary/40"}`,children:t},t))}),e.jsx("div",{"data-loc":"client/src/pages/onboarding.tsx:491",className:"mt-8 flex justify-end",children:e.jsx(I,{"data-loc":"client/src/pages/onboarding.tsx:492",type:"button",disabled:u.trim().length<3,onClick:T,children:"Continue"})})]}):e.jsxs(e.Fragment,{children:[e.jsx("h1",{"data-loc":"client/src/pages/onboarding.tsx:503",className:"text-2xl font-extrabold tracking-tight sm:text-3xl",children:"Who are you talking to?"}),e.jsx("p",{"data-loc":"client/src/pages/onboarding.tsx:504",className:"mt-2 text-sm text-muted-foreground",children:'Be specific. "Busy moms who want to lose weight" beats "women."'}),e.jsx("input",{"data-loc":"client/src/pages/onboarding.tsx:507",type:"text",value:l,onChange:t=>{k.current=!1,N(t.target.value),y(null)},onKeyDown:t=>{t.key==="Enter"&&l.trim().length>=3&&F()},placeholder:"e.g. Busy moms who want to lose 20 lbs...",maxLength:200,autoFocus:!0,autoComplete:"off",className:"mt-5 w-full rounded-xl border border-border bg-card px-4 py-3 text-sm outline-none transition focus:border-primary"}),e.jsx("p",{"data-loc":"client/src/pages/onboarding.tsx:524",className:"mt-4 text-[11px] font-bold uppercase tracking-wide text-muted-foreground",children:"Common audiences"}),e.jsx("div",{"data-loc":"client/src/pages/onboarding.tsx:527",className:"mt-2 flex flex-wrap gap-2",children:oe.map(t=>e.jsx("button",{"data-loc":"client/src/pages/onboarding.tsx:529",type:"button",onClick:()=>{k.current=!0,N(t)},className:`rounded-full border px-3 py-1.5 text-xs font-medium transition ${l===t?"border-primary bg-primary/10 text-primary":"border-border bg-card text-muted-foreground hover:border-primary/40"}`,children:t},t))}),D?e.jsx("p",{"data-loc":"client/src/pages/onboarding.tsx:546",className:"mt-4 text-sm text-destructive",children:D}):null,e.jsxs("div",{"data-loc":"client/src/pages/onboarding.tsx:547",className:"mt-8 flex flex-wrap justify-between gap-3",children:[e.jsx(I,{"data-loc":"client/src/pages/onboarding.tsx:548",type:"button",variant:"outline",onClick:()=>g("step1"),children:"Back"}),e.jsx(I,{"data-loc":"client/src/pages/onboarding.tsx:551",type:"button",disabled:l.trim().length<3||E.isPending,onClick:()=>void F(),children:"Start creating"})]})]})})})}export{ke as default}; 2 3//# chunkId=01a10c27-9737-7a52-b2fb-bfa6da2cdde6
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.