import{j as e,a7 as P,al as E}from"./vendor-mui-core-CDEc-eG6.js";import{r as k,u as T}from"./vendor-react-DX7tU9aY.js";import{o as W}from"./vendor-arcblock-DY2miJjh.js";import{W as j,O as x,b3 as C}from"./vendor-ux-bFYdDLNG.js";import{w as I,W as R,k as S,b,d as v}from"./index-DGZk149v.js";import{K as U}from"./landing-page-C9IV5jp5.js";import{w as L}from"./wrap-locale-DSF06-Vj.js";import{g as N}from"./get-safe-url-B1bR9jl-.js";import"./vendor-hooks-BrgYeCrj.js";import"./vendor-utils-_C9URqjS.js";import"./use-blocklet-logo-BSClbuwz.js";import"./index-91KnTNni.js";function _({SessionContext:n,webWalletUrl:a,onSuccess:o}){const{api:t,session:i}=k.useContext(n),{t:s,locale:h}=j(),f=T(),{searchParams:p}=new URL(window.location.href),l=p.get("redirect"),g=async(r,w)=>{o(r,w),await i.refresh(),x.success(s("exchangePassport.success")),setTimeout(()=>{if(l){const c=decodeURIComponent(l);c.startsWith(R)?f(c,{replace:!0}):window.location.href=N(c)}else window.location.href=window.env.pathPrefix||window.env.apiPrefix||"/"},3e3)},u=r=>{x.error(r.message)},m={},d=p.get("componentId");return d&&(m.componentId=d),i.loading?e.jsx(W,{children:e.jsx(P,{})}):e.jsx(U,{did:window?.blocklet?.appPid||window?.env?.appPid,children:e.jsx(E,{sx:{maxWidth:"100%",height:"100%"},children:e.jsx(I,{popup:!0,open:!0,className:"connect",action:"exchange-passport",checkFn:t.get,checkTimeout:600*1e3,webWalletUrl:a,onSuccess:g,onError:u,locale:h,messages:{title:s("exchangePassport.dialog.title"),scan:s("exchangePassport.dialog.scan"),confirm:s("exchangePassport.dialog.confirm"),success:s("exchangePassport.dialog.success")},extraParams:m,extraContent:null,hideCloseButton:!0})})})}const B=L(_);function G(){const n=C(),a=(o,t)=>{o.sessionToken&&(b(t(o.sessionToken)),v(t(o.refreshToken)))};return e.jsx(B,{SessionContext:S,webWalletUrl:n,onSuccess:a})}export{G as default};
