1import{c0 as O,c1 as q,j as t}from"./vendor-data-eBPZki-Z.js";import{f as F,r as s}from"./vendor-react-BgtJhS2O.js";import"./vendor-zod-Bei2Z9MS.js";import{u}from"./index-DTQGL8n8.js";const R=3,C=3,I=/^[a-zA-Z0-9_\-.]+$/,L=/^[_\-.]+/,$=400;function B(e){const c=e&&typeof e=="object"&&"message"in e&&typeof e.message=="string"?e.message:"",m=e&&typeof e=="object"&&"response"in e&&e.response&&typeof e.response=="object"&&"data"in e.response&&e.response.data&&typeof e.response.data=="object"&&"message"in e.response.data&&typeof e.response.data.message=="string"?e.response.data.message:"";return m||(c==="Network Error"||e&&typeof e=="object"&&"code"in e&&e.code==="ERR_NETWORK"?"Could not reach the server. Please check your connection and try again.":c||"Failed to save profile. Please try again.")}function Y(){const e=F(),c=u(r=>r.user),m=u(r=>r.setUser),_=u(r=>r.restoreSession),P=O(),[o,M]=s.useState(c?.displayName||""),[a,T]=s.useState(c?.username||""),[k,h]=s.useState(""),[N,l]=s.useState(""),[g,i]=s.useState(!1),[y,E]=s.useState(!1),[j,f]=s.useState(""),[v,S]=s.useState(!1),d=s.useRef(null),x=s.useRef(a),U=s.useCallback(r=>r.trim()?r.trim().length<R?`Name must be at least ${R} characters`:"":"Name is required",[]),b=s.useCallback(r=>r.trim()?r.length<C?`Username must be at least ${C} characters`:I.test(r)?L.test(r)?"Username can't start with _, -, or .":"":"Only letters, numbers, underscores, hyphens, and dots allowed":"Username is required",[]);s.useEffect(()=>{if(x.current=a,!a){i(!1);return}if(b(a)){i(!1);return}return d.current&&clearTimeout(d.current),d.current=setTimeout(async()=>{E(!0);try{const n=await q(a);if(x.current!==a)return;i(!n.available),!n.available&&n.error?l(n.error):l("")}catch{if(x.current!==a)return;i(!1)}finally{x.current===a&&E(!1)}},$),()=>{d.current&&clearTimeout(d.current)}},[a,b]);const A=async r=>{r.preventDefault(),f("");const n=U(o),w=b(a);if(h(n),l(w),!(n||w)&&!g){S(!0);try{await P.mutateAsync({name:o.trim(),username:a.trim(),accountSetup:!0});const p=u.getState().user;p&&m({...p,displayName:o.trim(),username:a.trim(),accountSetup:!0}),await _();const G=u.getState().user?.acceptTermsOfService?"/account-setup":"/accept-terms?onboarding=1";e(G,{replace:!0})}catch(p){f(B(p))}finally{S(!1)}}},D=v||y||g||!o.trim()||!a.trim();return t.jsx("div",{className:"min-h-dvh flex items-center justify-center bg-bg dark:bg-bg-dark px-4 py-8",children:t.jsxs("div",{className:"w-full max-w-[400px]",children:[t.jsxs("div",{className:"text-center mb-8",children:[t.jsx("h1",{className:"text-2xl font-bold text-text dark:text-text-dark",children:"Create your profile"}),t.jsx("p",{className:"text-sm text-text-secondary dark:text-text-secondary-dark mt-2",children:"Pick a name and username that others will see."})]}),t.jsxs("form",{onSubmit:A,className:"border border-border-light dark:border-border-dark rounded-lg p-8 bg-bg-elevated dark:bg-bg-elevated-dark space-y-6",children:[t.jsxs("div",{children:[t.jsx("label",{htmlFor:"name",className:"block text-sm font-medium text-text dark:text-text-dark mb-1.5",children:"Display name"}),t.jsx("input",{id:"name",type:"text",value:o,onChange:r=>{M(r.target.value),h(""),f("")},onBlur:()=>h(U(o)),placeholder:"Your name",required:!0,className:"w-full px-4 py-3 rounded-lg border border-border-light dark:border-border-dark bg-transparent text-text dark:text-text-dark focus:outline-none focus:border-brand focus:ring-1 focus:ring-brand text-base"}),k&&t.jsx("p",{className:"text-error text-sm mt-1",children:k})]}),t.jsxs("div",{children:[t.jsx("label",{htmlFor:"username",className:"block text-sm font-medium text-text dark:text-text-dark mb-1.5",children:"Username"}),t.jsxs("div",{className:"relative",children:[t.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-text-secondary dark:text-text-secondary-dark text-base pointer-events-none",children:"@"}),t.jsx("input",{id:"username",type:"text",value:a,onChange:r=>{T(r.target.value.replace(/^@/,"")),l(""),f(""),i(!1)},onBlur:()=>l(b(a)),placeholder:"username",required:!0,autoCapitalize:"none",autoCorrect:"off",className:`w-full pl-8 ${y?"pr-10":"pr-4"} py-3 rounded-lg border border-border-light dark:border-border-dark bg-transparent text-text dark:text-text-dark focus:outline-none focus:border-brand focus:ring-1 focus:ring-brand text-base`}),y&&t.jsx("div",{className:"absolute right-3 top-1/2 -translate-y-1/2",children:t.jsx("div",{className:"w-4 h-4 border-2 border-text-secondary/30 dark:border-text-secondary-dark/30 border-t-text-secondary dark:border-t-text-secondary-dark rounded-full animate-spin"})})]}),N?t.jsx("p",{className:"text-error text-sm mt-1",children:N}):g?t.jsx("p",{className:"text-error text-sm mt-1",children:"That username is taken."}):null]}),j&&t.jsx("p",{className:"text-error text-sm",children:j}),t.jsx("button",{type:"submit",disabled:D,className:"w-full bg-brand hover:bg-brand/90 text-white font-medium py-2.5 px-4 roun
1ded-full text-sm transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:v?"Creating profileâ¦":"Continue"})]})]})})}export{Y 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.