import{n as e}from"./rolldown-runtime-BG2f4sTM.js";import{$C as t,A5 as n,Dvt as r,Eut as i,H as a,I5 as o,Mft as s,Mvt as c,N_t as l,O_t as u,P_t as d,QC as f,Rft as p,Tut as m,U as h,Vft as g,Ydt as _,ZC as v,aw as y,cct as b,dft as x,ew as S,f9 as C,gut as w,hut as T,iw as E,jft as D,p9 as O,rw as k,sct as A,tw as j}from"./app-initial-BHB6SClA.js";import{a as M,c as N,d as P,l as F,n as I,o as L,r as R,t as z,u as B}from"./realtime-voice-stage-layout-G6GXAFOl.js";function V(){let e=(0,U.c)(48),n=l(D),r=o(),a=d(E),s=d(O),c=d(h),u=i(),p=a==null||k(`${r.pathname}${r.search}`,a.originPath,S(s,c));if(a==null||!p||a.request.source===`composer_button_existing_thread`&&a.phase!==`failed`)return null;if(a.phase===`failed`){let t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,W.jsx)(`h2`,{className:`text-base font-medium text-token-foreground`,children:(0,W.jsx)(g,{id:`realtimeVoice.launch.failedTitle`,defaultMessage:`Voice chat couldn’t start`,description:`Title shown when an optimistic realtime voice launch fails`})}),e[0]=t):t=e[0];let r;e[1]===a.error?r=e[2]:(r=a.error||(0,W.jsx)(g,{id:`realtimeVoice.launch.failedDescription`,defaultMessage:`Try again, or go back`,description:`Description shown when an optimistic realtime voice launch fails`}),e[1]=a.error,e[2]=r);let i;e[3]===r?i=e[4]:(i=(0,W.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[t,(0,W.jsx)(`p`,{className:`text-sm text-token-text-secondary`,children:r})]}),e[3]=r,e[4]=i);let o;e[5]!==a.originPath||e[6]!==a.request||e[7]!==n?(o=()=>{y(n,a.request,a.originPath).catch(H)},e[5]=a.originPath,e[6]=a.request,e[7]=n,e[8]=o):o=e[8];let s;e[9]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,W.jsx)(g,{id:`realtimeVoice.launch.retry`,defaultMessage:`Try again`,description:`Button that retries a failed realtime voice launch`}),e[9]=s):s=e[9];let c;e[10]===o?c=e[11]:(c=(0,W.jsx)(T,{color:`primary`,onClick:o,size:`medium`,children:s}),e[10]=o,e[11]=c);let l;e[12]===n?l=e[13]:(l=()=>{v(n)},e[12]=n,e[13]=l);let u;e[14]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,W.jsx)(g,{id:`realtimeVoice.launch.back`,defaultMessage:`Back`,description:`Button that dismisses a failed realtime voice launch and returns to the previous surface`}),e[14]=u):u=e[14];let d;e[15]===l?d=e[16]:(d=(0,W.jsx)(T,{color:`secondary`,onClick:l,size:`medium`,children:u}),e[15]=l,e[16]=d);let f;e[17]!==c||e[18]!==d?(f=(0,W.jsxs)(`div`,{className:`flex gap-2`,children:[c,d]}),e[17]=c,e[18]=d,e[19]=f):f=e[19];let p;return e[20]!==i||e[21]!==f?(p=(0,W.jsx)(`div`,{className:`absolute inset-0 z-30 flex items-center justify-center bg-token-main-surface-primary`,children:(0,W.jsxs)(`div`,{className:`flex flex-col items-center gap-4 text-center`,children:[i,f]})}),e[20]=i,e[21]=f,e[22]=p):p=e[22],p}let m=s.phase===`active`&&s.preferredPresentationSurface===`main-thread`,_=a.phase===`connected`&&a.handoffComplete,b=+!_,C;e[23]===b?C=e[24]:(C={opacity:b},e[23]=b,e[24]=C);let w;e[25]!==_||e[26]!==a.request||e[27]!==n?(w=()=>{_&&t(n,a.request)},e[25]=_,e[26]=a.request,e[27]=n,e[28]=w):w=e[28];let j=u?N:L,M;e[29]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,W.jsx)(`span`,{className:`sr-only`,role:`status`,children:(0,W.jsx)(g,{id:`realtimeVoice.launch.starting`,defaultMessage:`Starting voice chat`,description:`Accessible status announced while realtime voice starts`})}),e[29]=M):M=e[29];let P;e[30]===Symbol.for(`react.memo_cache_sentinel`)?(P={transform:R},e[30]=P):P=e[30];let F;e[31]===Symbol.for(`react.memo_cache_sentinel`)?(F={height:112,width:112},e[31]=F):F=e[31];let V=!m,G;e[32]!==a.request||e[33]!==n?(G=()=>f(n,a.request),e[32]=a.request,e[33]=n,e[34]=G):G=e[34];let K=s.phase===`inactive`?`starting`:s.phase,q=s.phase===`inactive`?`idle`:s.activity,J;e[35]!==q||e[36]!==K?(J=(0,W.jsx)(A,{className:`!aspect-square !size-full`,glowEnabled:!1,phase:K,placement:`center`,voiceActivity:q}),e[35]=q,e[36]=K,e[37]=J):J=e[37];let Y;e[38]!==u||e[39]!==J||e[40]!==V||e[41]!==G?(Y=(0,W.jsx)(`div`,{className:I,children:(0,W.jsx)(`div`,{className:z,style:P,children:(0,W.jsx)(`div`,{className:`relative flex`,style:F,children:(0,W.jsx)(B,{isConnecting:V,onHandoffComplete:G,orb:J,orbDiameter:112,reduceMotion:u})})})}),e[38]=u,e[39]=J,e[40]=V,e[41]=G,e[42]=Y):Y=e[42];let X;return e[43]!==C||e[44]!==Y||e[45]!==w||e[46]!==j?(X=(0,W.jsxs)(x.div,{animate:C,className:`absolute inset-0 z-30 bg-token-main-surface-primary`,initial:!1,onAnimationComplete:w,transition:j,children:[M,Y]}),e[43]=C,e[44]=Y,e[45]=w,e[46]=j,e[47]=X):X=e[47],X}function H(){}var U,W;e((()=>{U=c(),_(),u(),p(),n(),w(),m(),b(),s(),P(),C(),j(),F(),a(),M(),W=r()}))();export{V as RealtimeVoiceLaunchSurface};
//# sourceMappingURL=realtime-voice-launch-surface-D0L5DoPz.js.map