import{j as e,b4 as b,B as j,u as v,r as a,p as P,h as S,b as k,D as w,ab as E,b6 as K,b7 as W,k as i,b8 as _,A as U,b3 as B,C as D,b9 as N,ba as R}from"./index-DR3HTfO6.js";import{p as c}from"./index-6zqs-c3t.js";function o({children:r,...s}){return e.jsx(b,{...s,did:window?.blocklet?.appPid||window?.env?.appPid,children:e.jsx(j,{sx:{maxWidth:"100%",height:"100%"},children:r})})}function L(){const r=v(),{t:s,locale:d}=a.useContext(P),{api:l}=S(),{info:u}=k(),p=w(u),h=E(),n=K({ready:!1,success:!1,error:null,invalidSession:!1}),f=W(),m=()=>{try{const t=new URL(window.location.href);if(t.hash.includes("invalid")){n.invalidSession=!0;return}const g=t.searchParams.get("__connect_url__"),y=N(g);if(!R(y))throw new Error;n.ready=!0}catch{n.invalidSession=!0,r("#invalid",{replace:!0})}};a.useLayoutEffect(()=>m(),[]);const x=i(t=>{n.error=t.message,r("#invalid",{replace:!0})}),C=i(()=>{n.success=!0});if(n.invalidSession)return e.jsx(o,{children:e.jsx(c,{style:{backgroundColor:"transparent"},status:"error",title:s("didConnect.common.invalidSession"),description:s("didConnect.common.invalidSessionDesc")})});if(n.error){const t=n.error;return e.jsx(o,{children:e.jsx(c,{style:{backgroundColor:"transparent"},status:"error",title:s("didConnect.common.connectionError"),description:t})})}return n.success?e.jsx(o,{children:e.jsx(c,{style:{backgroundColor:"transparent"},status:"info",icon:e.jsx(_,{style:{color:h.palette.success.main,fontSize:72}}),title:s("didConnect.genKeyPair.success"),description:s("didConnect.genKeyPair.successDesc")})}):n.ready?e.jsx(o,{children:e.jsx(U,{className:"connect",action:"gen-key-pair",checkFn:l.get,checkTimeout:600*1e3,extraParams:{sourceAppPid:f?.appPid,forceSwitch:!0},saveConnect:!1,forceConnected:!1,webWalletUrl:p,onSuccess:C,onError:x,locale:d,messages:{title:s("didConnect.genKeyPair.title"),scan:s("didConnect.genKeyPair.scan"),confirm:s("auth.confirm"),success:s("didConnect.genKeyPair.success")},popup:!0,open:!0,hideCloseButton:!0})},"ready"):e.jsx(B,{children:e.jsx(D,{})})}export{L as default};
