1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7411],{88162:function(e,r,a){(window.__NEXT_P=window.__NEXT_P||[]).push(["/onboarding",function(){return a(96315)}])},96315:function(e,r,a){"use strict";a.r(r);var i=a(85893),t=a(94720),o=a(45161),l=a(57747),s=a(22338),n=a(48783),c=a(22757),d=a(71293),u=a(65040),p=a(13990),h=a(40607),m=a(18020),f=a(66529),g=a(33090),y=a(51001),x=a(93717),j=a(36948),b=a(14225),v=a(39828),w=a(67294),C=a(11163),F=a(52330),N=a(88935),z=a(27680),_=a(27307),k=a(91259),S=a(25675),R=a.n(S),U=a(34273);r.default=()=>{let e=(0,C.useRouter)(),{user:r,firestoreUser:a}=(0,U.Z)(),[S,A]=(0,w.useState)({displayName:"",username:"",avatarType:"generated",avatarColor:(0,_.m)(),photoURL:""}),[E,L]=(0,w.useState)(!1),[D,P]=(0,w.useState)(""),[T,I]=(0,w.useState)(1),[W,Z]=(0,w.useState)(null),[J,O]=(0,w.useState)(!1),q=(0,w.useRef)(null),B=(0,t.p)(),X=(0,o.ff)("#F5F7FA","#050508"),G=(0,o.ff)("#FFFFFF","#1A202C"),H=(0,o.ff)("#1A202C","white"),M=(0,o.ff)("#FFFFFF","rgba(31, 41, 55, 0.5)"),Q=(0,o.ff)("#D1D5DB","rgba(75, 85, 99, 0.7)"),$=(0,o.ff)("#1F2937","gray.200"),K=(0,o.ff)("#374151","gray.200"),V=(0,o.ff)("#9CA3AF","gray.400");(0,w.useEffect)(()=>{var i;if(!r||(null==a?void 0:null===(i=a.metadata)||void 0===i?void 0:i.hasCompletedOnboarding)){e.push("/");return}r.displayName&&!S.displayName&&A(e=>({...e,displayName:r.displayName||""}))},[r,a,e,S.displayName]),(0,w.useEffect)(()=>{if(!J&&!S.username&&r){if(S.displayName){let e=S.displayName.toLowerCase().replace(/[^a-z0-9]/g,"");A(r=>({...r,username:e}))}else if(r.email){let e=r.email.split("@")[0].toLowerCase().replace(/[^a-z0-9]/g,"");A(r=>({...r,username:e}))}}},[S.displayName,S.username,r,J]);let Y=async e=>{if(!e)return"Username is required";if(e.length<3)return"Username must be at least 3 characters";if(e.length>25)return"Username must be less than 25 characters";if(!/^[a-z0-9_]+$/.test(e))return"Username can only contain lowercase letters, numbers, and underscores";try{if((await (0,v.QT)((0,v.JU)(F.RZ,"usernames",e))).exists())return"Username is already taken"}catch(e){return console.error("Error checking username:",e),"Error checking username availability"}return null},ee=e=>{let{name:r,value:a}=e.target;if("username"===r){O(!0);let e=a.toLowerCase().replace(/[^a-z0-9_]/g,"");A(a=>({...a,[r]:e}))}else A(e=>({...e,[r]:a}));D&&P("")},er=async()=>{if(P(""),1===T){if(!S.displayName.trim()){P("Display name is required");return}I(2)}else if(2===T){let e=await Y(S.username);if(e){P(e);return}I(3)}else 3===T&&await ea()},ea=async()=>{if(r){L(!0),P("");try{let a="";if(W)try{a=await (0,N.ow)(W,r.uid)}catch(e){console.error("Upload error:",e),P("Failed to upload profile picture. Please try again."),L(!1);return}let i=W?"custom":"generated",t="generated"===i?S.avatarColor:null,o=(0,v.JU)(F.RZ,"users",r.uid),l=(0,v.JU)(F.RZ,"usernames",S.username);if((await (0,v.QT)(l)).exists()){P("Username is already taken"),L(!1);return}if(await (0,v.pl)(l,{uid:r.uid,createdAt:Date.now()}),await (0,v.pl)(o,{profile:{displayName:S.displayName,username:S.username,avatar:{type:i,color:"generated"===i?t:null,photoURL:a}},metadata:{hasCompletedOnboarding:!0},email:r.email,uid:r.uid,createdAt:Date.now(),followerCount:0},{merge:!0}),a)try{await (0,k.ck)(r,{displayName:S.displayName,photoURL:a})}catch(e){console.error("Error updating Firebase Auth profile:",e)}else try{await (0,k.ck)(r,{displayName:S.displayName})}catch(e){console.error("Error updating Firebase Auth display name:",e)}let s=(0,v.IO)((0,v.hJ)(F.RZ,"posts"),(0,v.ar)("creator.id","==",r.uid)),n=await (0,v.PL)(s);if(!n.empty){let e=(0,v.qs)(F.RZ);n.docs.forEach(r=>{e.update(r.ref,{"creator.displayName":S.displayName,"creator.avatarType":i,"creator.avatarColor":t,"creator.imageURL":a||null})}),await e.commit()}B({title:"Profile created successfully!",status:"success",duration:3e3,isClosable:!0}),e.push("/")}catch(e){console.error("Error creating profile:",e),P("Failed to create profile. Please try again.")}finally{L(!1)}}};return r?(0,i.jsx)(l.xu,{minH:"100vh",bg:X,py:8,children:(0,i.jsx)(s.W,{maxW:"md",centerContent:!0,children:(0,i.jsxs)(n.g,{spacing:8,w:"100%",children:[(0,i.jsxs)(n.g,{spacing:4,textAlign:"center",children:[(0,i.jsx)(c.X,{color:H,size:"xl",children:"Welcome to Starc!"}),(0,i.jsx)(d.x,{color:H,fontSize:"lg",children:"Let's set up your profile"}),(0,i.jsx)(u.E,{value:T/3*100,size:"lg",w:"100%",colorScheme:"blue",borderRadius:"full"}),(0,i.jsxs)(d.x,{color:H,fontSize:"sm",children:["Step ",T," of 3"]})]}),(0,i.jsx)(p.Z,{w:"100%",bg:G,shadow:"lg",children:(0,i.jsx)(h.e,{p:8,children:(0,i.jsxs)(n.g,{spacing:6,children:[1===T&&(0,i.jsxs)(m.NI,{isRequired:!0,isInvalid:!!D,children:[(0,i.jsx)(f.l,{color:K,fontSize:"lg",fontWeight:"semibold",children:"What should we call you?"}),(0,i.jsx)(g.I,{name:"displayName",value:S.displayName,onChange:ee,placeholder:"Display Name",size:"lg",bg:M,border:"1px solid",borderColor:Q,color:$,_placeholder:{color:V},_focus:{outline:"none",borderColor:"#4149FF"}}),(0,i.jsx)(y.J1,{children:D})]}),2===T&&(0,i.jsxs)(m.NI,{isRequired:!0,isInvalid:!!D,children:[(0,i.jsx)(f.l,{color:K,fontSize:"lg",fontWeight:"semibold",children:"Choose a username"}),(0,i.jsx)(g.I,{name:"username",value:S.username,onChange:ee,placeholder:"username",size:"lg",bg:M,border:"1px solid",borderColor:Q,color:$,_placeholder:{color:V},_focus:{outline:"none",borderColor:"#4149FF"},mb:2}),(0,i.jsx)(d.x,{fontSize:"sm",color:"gray.400",mb:3,children:"Usernames are stored in lowercase and can only contain letters, numbers, and underscores."}),D&&(0,i.jsx)(y.J1,{children:D})]}),3===T&&(0,i.jsxs)(m.NI,{isInvalid:!!D,children:[(0,i.jsx)(f.l,{color:K,fontSize:"lg",fontWeight:"semibold",textAlign:"center",children:"Profile Picture"}),(0,i.jsx)("input",{type:"file",ref:q,onChange:e=>{var r;let a=null===(r=e.target.files)||void 0===r?void 0:r[0];if(a){if(a.size>5242880){P("File size must be less than 5MB");return}if(!a.type.startsWith("image/")){P("Please select an image file");return}Z(a),A(e=>({...e,avatarType:"custom"})),P("")}},accept:"image/*",style:{display:"none"}}),(0,i.jsxs)(x.k,{direction:"column",align:"center",gap:6,children:[(0,i.jsxs)(l.xu,{onClick:()=>{var e;null===(e=q.current)||void 0===e||e.click()},cursor:"pointer",position:"relative",_hover:{opacity:.8},children:[W?(0,i.jsx)(l.xu,{w:"150px",h:"150px",borderRadius:"full",overflow:"hidden",position:"relative",children:(0,i.jsx)(R(),{src:URL.createObjectURL(W),alt:"Selected profile",width:150,height:150,style:{objectFit:"cover",width:"100%",height:"100%"}})}):(0,i.jsx)(_.Z,{name:S.displayName,color:S.avatarColor,size:"150px"}),(0,i.jsx)(x.k,{position:"absolute",top:"0",left:"0",right:"0",bottom:"0",align:"center",justify:"center",bg:"blackAlpha.600",borderRadius:"full",opacity:"0",transition:"opacity 0.2s",_hover:{opacity:1},children:(0,i.jsx)(j.J,{as:z.lnH,color:"white",boxSize:10})})]}),(0,i.jsxs)(d.x,{fontSize:"md",color:"gray.500",textAlign:"center",children:["Click to ",W?"change":"upload"," profile picture"]}),W&&(0,i.jsx)(b.z,{size:"sm",variant:"outline",colorScheme:"red",onClick:()=>{Z(null),A(e=>({...e,avatarType:"generated",photoURL:""})),q.current&&(q.current.value="")},children:"Remove Photo"}),D&&(0,i.jsx)(d.x,{color:"red.500",fontSize:"sm",children:D})]})]}),(0,i.jsxs)(x.k,{w:"100%",justify:"space-between",pt:4,children:[T>1?(0,i.jsx)(b.z,{variant:"ghost",onClick:()=>{P(""),I(e=>Math.max(1,e-1))},isDisabled:E,size:"lg",children:"Back"}):(0,i.jsx)(l.xu,{}),(0,i.jsx)(b.z,{bgGradient:"linear(to-r, blue.400, #4149FF)",color:"white",onClick:er,isLoading:E,size:"lg",px:8,_hover:{bgGradient:"linear(to-r, blue.500, #5158FF)"},children:3===T?"Complete":"Next"})]})]})})}),(0,i.jsxs)(n.g,{spacing:3,opacity:.7,fontSize:"xs",textAlign:"center",children:[(0,i.jsxs)(x.k,{wrap:"wrap",justify:"center",gap:4,color:H,children:[(0,i.jsx)(d.x,{as:"a",href:"/more/terms",_hover:{textDecoration:"underline",opacity:1},cursor:"pointer",children:"Terms of Service"}),(0,i.jsx)(d.x,{color:"gray.400",children:"â¢"}),(0,i.jsx)(d.x,{as:"a",href:"/more/privacy",_hover:{textDecoration:"underline",opacity:1},cursor:"pointer",children:"Privacy Policy"}),(0,i.jsx)(d.x,{color:"gray.400",children:"â¢"}),(0,i.jsx)(d.x,{color:"red.400",_hover:{textDecoration:"underline",opacity:1},cursor:"pointer",onClick:()=>{window.confirm("Are you sure you want to delete your account? This action cannot be undone.")&&e.push("/user/"+(null==r?void 0:r.uid)+"/settings/delete-account")},children:"Delete Account"})]}),(0,i.jsx)(d.x,{color:"gray.500",fontSize:"xs",children:"By continuing, you agree to our terms and privacy policy"})]})]})})}):null}}},function(e){e.O(0,[7395,1254,7281,6245,5871,543,1976,5851,3801,9379,6592,3142,9074,1425,3544,4748,50,6537,9353,1030,1680,4709,5880,3602,7844,8057,8053,2939,2468,5007,1234,5340,7011,4002,4006,1588,2778,4073,7474,2385,9680,8497,3492,1089,4963,5860,7680,1967,7214,1011,379,3843,6958,6864,4091,7314,6343,5774,6122,963,8554,2150,7249,2888,2870,1754,7144,5971,5050,143,6010,179],function(){return e(e.s=88162)}),_N_E=e.O()}]);
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.