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]=`7d8adf35-bee5-499b-ae48-c14923be0ffe`,e._sentryDebugIdIdentifier=`sentry-dbid-7d8adf35-bee5-499b-ae48-c14923be0ffe`)}catch{}import{o as e}from"./rolldown-runtime-eb2nym32.js";import{st as t}from"./xds-react-components-lks62tbl.js";import{Ag as n,Dg as r,Fg as i,Ig as a,Qn as o,Yn as s,eh as c,lh as l,or as u,pn as d,sh as f,wg as p}from"./entry.client-dr7r6s9a.js";import{r as m}from"./ControllerPairingContext-lndsofbd.js";import{n as h,r as g}from"./routes-cum86uu1.js";import{r as _}from"./Styles-pe7l89m3.js";import{t as v}from"./getControllerPairingRouterEnvironment-cyamx6ev.js";import{t as y}from"./ControllerPairingHeader-o5r7pkm4.js";var b=e(a(),1),x=e(u(),1),S=i();function C(){let e=(0,S.c)(2),{t}=l(`ControllerPairingCaccsPairing`),n;return e[0]===t?n=e[1]:(n={locAuthCodeLabel:()=>t(`caccs label`,{shortKey:`caccs_pairing_auth_code_label`}),locQrCodeAlt:()=>t(`caccs alt`,{shortKey:`caccs_pairing_qr_alt`}),locStep1Description:()=>t(`caccs step 1 description`,{shortKey:`caccs_pairing_step1_desc`}),locStep1Title:()=>t(`caccs step 1`,{shortKey:`caccs_pairing_step1_title`}),locStep2Description:()=>t(`caccs step 2 description`,{shortKey:`caccs_pairing_step2_desc`}),locStep2Title:()=>t(`caccs step 2`,{shortKey:`caccs_pairing_step2_title`}),locSubtitle:()=>t(`caccs subtitle`,{shortKey:`caccs_pairing_subtitle`}),locTitle:()=>t(`caccs`,{shortKey:`caccs_pairing_title`})},e[0]=t,e[1]=n),n}var w=n(),T=()=>{let{locTitle:e,locAuthCodeLabel:n}=C(),{locSomethingWentWrong:i,locGenericErrorSubheading:a,locTryAgain:l}=c(),{fullscreen:u}=m(),S=v(),{accs:T}=f(),{data:E,isLoading:D,isError:O,refetch:k}=r(T.queries.authorizationCode.getOptions()),A=E?.AuthorizationCode,{data:j}=r(T.queries.accessoryState.getOptions()),{mutate:M}=p(T.mutations.startAuthorizationCodeRefresh.getOptions()),N=(0,b.useRef)(!!E);return(0,b.useEffect)(()=>{N.current||M()},[M]),(0,b.useEffect)(()=>{!j?.accessoryId||j.deviceType!==`VIRTUAL`||(j.requiresConfirmation?S(h.path,{replace:!0}):S(g.path,{replace:!0,state:{autoDismiss:!0}}))},[j,S]),(0,w.jsxs)(`div`,{className:(0,x.default)(_(u),`!flex !flex-col !items-center`,O&&`!gap-0`),children:[(0,w.jsx)(y,{title:e()}),(0,w.jsx)(t,{className:`flex flex-1 flex-col items-center justify-center gap-layout-vertical-related-content-in-a-section-tight overflow-y-auto pe-4 sbar`,capturesFocus:!1,children:O?(0,w.jsx)(d,{illustration:`error`,title:i(),subtitle:a(),primaryButton:{text:l(),onPress:()=>k()},size:`small`}):D||!A?(0,w.jsx)(o,{children:(0,w.jsxs)(`div`,{className:`relative w-[12ch] type-display2`,children:[(0,w.jsx)(`span`,{className:`invisible`,"aria-hidden":`true`,children:`\xA0`}),(0,w.jsx)(s,{className:`absolute inset-0 rounded-regular`})]})}):(0,w.jsx)(`p`,{className:`text-noninteractive-content-primary-content type-display2`,role:`status`,"aria-label":`${n()}: ${A.split(``).join(` `)}`,children:A.split(``).join(` `)})})]})};export{T as CaccsPairing};