try{let e=typeof window<`u`?window:typeof global<`u`?global:typeof globalThis<`u`?globalThis:typeof self<`u`?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]=`b7adf40f-a5a2-4333-a738-5fa4a8b32b72`,e._sentryDebugIdIdentifier=`sentry-dbid-b7adf40f-a5a2-4333-a738-5fa4a8b32b72`)}catch{}import{o as e}from"./rolldown-runtime-eb2nym32.js";import{t}from"./useLocation-fu2554ly.js";import{st as n}from"./xds-react-components-lks62tbl.js";import{Ag as r,Fg as i,Gp as a,Ig as o,Og as s,ch as c,dn as l,lh as u,or as d,pr as f,sh as p}from"./entry.client-dr7r6s9a.js";import{t as m}from"./DialogShell-k2jpaw9r.js";import{n as h,t as g}from"./ChangeGamertagInput-nruk26ee.js";import{n as _}from"./getChangeGamertagRouterEnvironmentHooks-e2ysxgj6.js";import{r as v,t as y}from"./routes-bxal063z.js";import{t as b}from"./ChangeGamertagLoader-g0frxxf0.js";var x=i(),S=e(d(),1),C=e(o(),1),w=r(),T=l(({currentGamertag:e,disableButtons:t,errorReservation:r,handleNext:i,handleRandom:a,handleReserve:o,isLoading:s,randomGamertag:c,reservation:l})=>{let{t:d}=u(`ChangeGamertagDialog`),[f,p]=(0,C.useState)(``),y=_.useComponent(),x={title:{text:d(`Choose your new gamertag`,{shortKey:`choose_new_gamertag_title`}),sizeClassName:`type-section3`},containerClassName:`flex-1 items-center`},T=()=>{o(f)};(0,C.useEffect)(()=>{c&&p(c)},[c]),(0,C.useEffect)(()=>{l&&i()},[l]);let E=(0,w.jsx)(m.NavigationHeader,{showClose:!0,className:`ps-template-overlays-modal-container-padding-2-left-&-right content-between items-baseline self-stretch p-internal-gap-regular`,title:x});return s?(0,w.jsx)(b,{navigationHeader:E}):(0,w.jsxs)(w.Fragment,{children:[E,(0,w.jsxs)(n,{className:(0,S.default)(`overflow-y-auto sbar`,`[--scrollbar-track-margin-top:var(--modal-spacing)]`,`flex flex-1 flex-col self-stretch`,`px-template-overlays-modal-container-padding-2-left-&-right`,`items-start gap-internal-gap-static-regular`),children:[(0,w.jsx)(`p`,{className:`text-action-noninteractive-content-rest type-body`,children:d(`Xbox has expanded the range of possibilities and languages. Now you can choose just about any name you want.`,{shortKey:`choose_new_gamertag_description`})}),(0,w.jsx)(v,{label1:e,label2:d(`Current gamertag`,{shortKey:`gamertag_current_46a3ec`})}),(0,w.jsx)(g,{errorReservation:r,gamertag:f,maxLength:12,setGamertag:p,statusInfo:d(`Up to 12 characters, including spaces. Can't start with a number`,{shortKey:`characters_including_spa_1b5154`})})]}),(0,w.jsxs)(`div`,{className:(0,S.default)(`flex flex-col gap-internal-gap-regular`,`px-template-overlays-modal-container-padding-2-left-&-right pb-template-overlays-modal-container-padding-2-top-&-bottom`),children:[(0,w.jsx)(h,{disableButtons:t,disableNext:f.trim().length<1,handleNext:T,handleRandom:a}),(0,w.jsx)(y,{})]})]})},()=>{let e=t(),{authentication:n,gamertag:r}=p(),i=a(),{trackUserAction:o}=c(),[l,u]=(0,C.useState)(!1),[d,f]=(0,C.useState)(``),[{data:m,isLoading:h,refetch:g},{data:_,error:v,isLoading:b},{data:x,isLoading:S,isError:w}]=s({queries:[{...r.queries.generatedGamertags.getActiveUserQuery().getOptions({count:1}),enabled:l},{...r.queries.reserveGamertag.getActiveUserQuery().getOptions({modernGamertag:d}),enabled:!!d},n.queries.userInfo.getActiveUserQuery().getOptions()]}),T=()=>{o(`GenerateRandomGamertag`,{wasClassic:!1},`Press`),l?g():u(!0)},E=async e=>{f(e)},D=()=>{o(`NavigateInModal`,{destination:y.confirmNewGamertag,source:e.pathname},`Press`),_&&i({to:y.confirmNewGamertag,search:_})};if(w)throw Error(`Failed to get active user`);return{currentGamertag:x?.gamertag.uniqueGamertag,disableButtons:h||b,errorReservation:v,handleNext:D,handleRandom:T,handleReserve:E,isLoading:S,randomGamertag:m?.[0].substring(0,12),reservation:_}}),E=()=>{let e=(0,x.c)(2),t=T.useComponent(),n;return e[0]===t?n=e[1]:(n=(0,w.jsx)(f,{location:`ChooseYourGamertagScreen`,children:(0,w.jsx)(t,{})}),e[0]=t,e[1]=n),n};export{E as ChooseYourGamertag};