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]=`61844483-dbfc-44fe-81c8-8143c1b4c274`,e._sentryDebugIdIdentifier=`sentry-dbid-61844483-dbfc-44fe-81c8-8143c1b4c274`)}catch{}import{o as e}from"./rolldown-runtime-nx40z1zs.js";import{t}from"./useLocation-gval357w.js";import{$m as n,Ag as r,Di as i,Qh as a,Qm as o,Zm as s,_r as c,fp as l,jg as u,ng as d,pi as f,pp as p}from"./entry.client-mpghtlrl.js";import{ut as m}from"./xds-react-components-ihgca01z.js";import{t as h}from"./DialogShell-ga7ic6wy.js";import{n as g,t as _}from"./ChangeGamertagInput-gpneb2o3.js";import{n as v,t as y}from"./getChangeGamertagRouterEnvironmentHooks-e3geq7oh.js";import{n as b,r as x,t as S}from"./routes-oel6fm83.js";var C=r(),w=e(f(),1),T=e(u(),1),E=d(),D=c(({currentGamertag:e,disableButtons:t,errorReservation:r,handleNext:i,handleRandom:a,handleReserve:o,navigateBack:s,randomGamertag:c,reservation:l})=>{let{t:u}=n(`ChangeGamertagDialog`),[d,f]=(0,T.useState)(``),p=v.useComponent(),y={title:{text:u(`Customize your classic gamertag`,{shortKey:`change_classic_gamertag_title`}),sizeClassName:`type-section3`},containerClassName:`flex-1 items-center`};return(0,T.useEffect)(()=>{c&&f(c)},[c]),(0,T.useEffect)(()=>{l&&i()},[l]),(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(h.NavigationHeader,{showClose:!0,onBack:s,className:`ps-template-overlays-modal-container-padding-2-left-&-right content-between items-baseline self-stretch p-internal-gap-regular`,title:y}),(0,E.jsxs)(m,{className:(0,w.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,E.jsx)(`p`,{className:`text-action-noninteractive-content-rest type-body`,children:u(`Your classic gamertag will continue to be used in existing games. The recommended classic gamertag below aligns with your new gamertag and helps people recognize you across games and other experiences.`,{shortKey:`change_classic_gamertag_description`})}),(0,E.jsx)(x,{label1:e,label2:u(`Suggested classic gamertag`,{shortKey:`suggested_classic_gamertag`})}),(0,E.jsx)(_,{errorReservation:r,gamertag:d,maxLength:15,setGamertag:f,statusInfo:u(`Up to 15 characters, including spaces. Must both start with a letter and only use latin alphanumeric characters`,{shortKey:`customize_rules_classic_gamertag`})})]}),(0,E.jsxs)(`div`,{className:(0,w.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,E.jsx)(g,{disableButtons:t,disableNext:d.trim().length<1,handleNext:()=>{o(d)},handleRandom:a,nextButtonText:u(`Save changes`,{shortKey:`save_changes`})}),(0,E.jsx)(p,{})]})]})},()=>{let e=t(),{gamertag:n}=s(),r=l(),{trackUserAction:i}=o(),c=y(),u=()=>{i(`BackButton`,{},`Press`),c()},d=p({from:b.changeClassicGamertag}),[f,m]=(0,T.useState)(!0),[h,g]=(0,T.useState)(``),{data:_,isLoading:v,refetch:x}=a({...n.queries.generatedGamertags.getActiveUserQuery().getOptions({count:1}),enabled:!f}),{data:C,error:w,isLoading:E}=a({...n.queries.reserveGamertag.getActiveUserQuery().getOptions({classicGamertag:h}),enabled:!!h});return{currentGamertag:d.gamertag??``,disableButtons:v||E,errorReservation:w,handleNext:()=>{if(C){let t={gamertag:C.gamertag,modernGamertag:d.modernGamertag,modernGamertagSuffix:d.modernGamertagSuffix,uniqueModernGamertag:d.uniqueModernGamertag,classicTranslationLevel:d.classicTranslationLevel??C.classicTranslationLevel,promptForClassicGamertag:C.promptForClassicGamertag};i(`NavigateInModal`,{destination:S.confirmNewGamertag,source:e.pathname},`Press`),r({to:S.confirmNewGamertag,search:t})}},handleRandom:()=>{i(`GenerateRandomGamertag`,{wasClassic:!0},`Press`),f?m(!1):x()},handleReserve:async e=>{g(e)},navigateBack:u,randomGamertag:_?.[0],reservation:C}}),O=()=>{let e=(0,C.c)(2),t=D.useComponent(),n;return e[0]===t?n=e[1]:(n=(0,E.jsx)(i,{location:`ChangeClassicGamertagScreen`,children:(0,E.jsx)(t,{})}),e[0]=t,e[1]=n),n};export{O as ChangeClassicGamertag};