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]=`45f4c4bb-50af-4768-9d61-c06589e5ee33`,e._sentryDebugIdIdentifier=`sentry-dbid-45f4c4bb-50af-4768-9d61-c06589e5ee33`)}catch{}import{o as e}from"./rolldown-runtime-nx40z1zs.js";import{t}from"./useLocation-gval357w.js";import{$h as n,$m as r,Ag as i,Di as a,Qm as o,Zm as s,_r as c,fp as l,jg as u,ng as d,pi as f}from"./entry.client-mpghtlrl.js";import{ut as p}from"./xds-react-components-ihgca01z.js";import{gt as m}from"./workspace-leaf-files-oergw4h0.js";import{t as h}from"./DialogShell-ga7ic6wy.js";import{n as g,t as _}from"./ChangeGamertagInput-gpneb2o3.js";import{n as v}from"./getChangeGamertagRouterEnvironmentHooks-e3geq7oh.js";import{r as y,t as b}from"./routes-oel6fm83.js";import{t as x}from"./ChangeGamertagLoader-gd80n69h.js";var S=i(),C=e(f(),1),w=e(u(),1),T=d(),E=c(({currentGamertag:e,disableButtons:t,errorReservation:n,handleNext:i,handleRandom:a,handleReserve:o,isLoading:s,randomGamertag:c,reservation:l})=>{let{t:u}=r(`ChangeGamertagDialog`),[d,f]=(0,w.useState)(``),m=v.useComponent(),b={title:{text:u(`Choose your new gamertag`,{shortKey:`choose_new_gamertag_title`}),sizeClassName:`type-section3`},containerClassName:`flex-1 items-center`},S=()=>{o(d)};(0,w.useEffect)(()=>{c&&f(c)},[c]),(0,w.useEffect)(()=>{l&&i()},[l]);let E=(0,T.jsx)(h.NavigationHeader,{showClose:!0,className:`ps-template-overlays-modal-container-padding-2-left-&-right content-between items-baseline self-stretch p-internal-gap-regular`,title:b});return s?(0,T.jsx)(x,{navigationHeader:E}):(0,T.jsxs)(T.Fragment,{children:[E,(0,T.jsxs)(p,{className:(0,C.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,T.jsx)(`p`,{className:`text-action-noninteractive-content-rest type-body`,children:u(`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,T.jsx)(y,{label1:e,label2:u(`Current gamertag`,{shortKey:`gamertag_current_46a3ec`})}),(0,T.jsx)(_,{errorReservation:n,gamertag:d,maxLength:15,setGamertag:f,statusInfo:u(`Up to 15 characters, including spaces. Can't start with a number. If your desired gamertag is more than 12 characters, it must be latin alphanumeric.`,{shortKey:`characters_including_spa_1b5154`})})]}),(0,T.jsxs)(`div`,{className:(0,C.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,T.jsx)(g,{disableButtons:t,disableNext:d.trim().length<1,handleNext:S,handleRandom:a}),(0,T.jsx)(m,{})]})]})},()=>{let e=t(),{authentication:r,gamertag:i}=s(),a=l(),{trackUserAction:c}=o(),[u,d]=(0,w.useState)(!1),[f,p]=(0,w.useState)(``),[{data:h,isLoading:g,refetch:_},{data:v,error:y,isLoading:x},{data:S,isLoading:C,isError:T}]=n({queries:[{...i.queries.generatedGamertags.getActiveUserQuery().getOptions({count:1}),enabled:u},{...i.queries.reserveGamertag.getActiveUserQuery().getOptions({modernGamertag:f}),enabled:!!f},r.queries.userInfo.getActiveUserQuery().getOptions()]}),E=()=>{c(`GenerateRandomGamertag`,{wasClassic:!1},`Press`),u?_():d(!0)},D=async e=>{p(e)},O=()=>{if(c(`NavigateInModal`,{destination:b.confirmNewGamertag,source:e.pathname},`Press`),v){let e={...v,gamertag:v.classicTranslationLevel===m.Impossible?S?.gamertag.legacyGamertag:v.gamertag};a({to:b.confirmNewGamertag,search:e})}};if(T)throw Error(`Failed to get active user`);return{currentGamertag:S?.gamertag.uniqueGamertag,disableButtons:g||x,errorReservation:y,handleNext:O,handleRandom:E,handleReserve:D,isLoading:C,randomGamertag:h?.[0].substring(0,12),reservation:v}}),D=()=>{let e=(0,S.c)(2),t=E.useComponent(),n;return e[0]===t?n=e[1]:(n=(0,T.jsx)(a,{location:`ChooseYourGamertagScreen`,children:(0,T.jsx)(t,{})}),e[0]=t,e[1]=n),n};export{D as ChooseYourGamertag};