import{j as e,a7 as g,al as x}from"./vendor-mui-core-CDEc-eG6.js";import{i as v,r as T,b as m}from"./vendor-hooks-Ca2cSNuD.js";import{I as k}from"./invitation-CcqRXA0x.js";import{K as I}from"./landing-page-BvgQ3gcP.js";import{aa as P,ao as j}from"./vendor-ux-PO0jFgJf.js";import{u as R,b as S,d as E,W,H as N}from"./index-CgSpL7jz.js";import{g as b}from"./get-safe-url-uxJSMQTF.js";import{c as C}from"./passport-2AVRJTQK.js";import{u as F}from"./vendor-react-DX7tU9aY.js";import"./vendor-utils-_C9URqjS.js";import"./index-BvUXcJcd.js";import"./purify.es-HRjpPm7y.js";import"./use-passport-id-B-b-_oYF.js";import"./session-BEf_KK-i.js";import"./sdk-CuoW9qgj.js";import"./wrap-locale-AxlzuLIu.js";import"./index-C2_MQP4T.js";import"./use-blocklet-logo-nVOJALp0.js";import"./vendor-arcblock-BVQTtbN-.js";import"./create-passport-svg-DNOT-xbE.js";function $(c){const{searchParams:r}=new URL(window.location.href),{api:a,session:f}=R(),d=F(),{t:u}=P(),n=r.get("id"),p=r.get("redirect"),h=v({state:""}),o=T(async()=>{if(!n)return null;const{data:t}=await a.get("/api/invitation",{params:{inviteId:n,mode:"issue-passport"}});return t}),l=m(()=>{if(o.error)throw o.error;return o?.data}),w=m(async(t,i=s=>s)=>{t&&(t.sessionToken&&S(i(t.sessionToken)),t.refreshToken&&E(i(t.refreshToken)),t.visitorId&&j(i(t.visitorId)),await f.refresh()),setTimeout(()=>{if(p){const s=decodeURIComponent(p);s.startsWith(W)?d(s,{replace:!0}):window.location.href=b(s)}else window.location.href=window.env.pathPrefix||"/"},50)});return o.loading?e.jsx(g,{}):e.jsxs(I,{did:window.blocklet?.appPid,children:[e.jsx(N,{children:e.jsxs("title",{children:[u("pageTitle.issuePassport")," | ",window.blocklet?.appName]})}),e.jsx(x,{className:"page-invite",sx:{width:"560px",maxWidth:"100%",height:"100%"},children:e.jsx(k,{...c,action:"issue-passport",getDataFn:l,checkFn:a.get,createPassportSvg:C,onLoginSuccess:w,inService:!0,status:h.state})})]})}export{$ as default};
