import{u,j as s,C as d,A as x,ay as v,cw as C,aT as f,af as j,aH as I,K as P,bC as S}from"./index-CCv_8omK.js";import{I as T}from"./invitation-B5QYli1h.js";import{g as E}from"./get-safe-url-B_yWzv49.js";import"./index-yORTeDE5.js";import"./index-g_RqxcM4.js";import"./emotion-cache.browser.esm-CdT-VIlA.js";import"./sdk-BJ8ul4G_.js";import"./wrap-locale-B1uKF2jP.js";import"./index-gqKcev8E.js";function R(n){const{searchParams:a}=new URL(window.location.href),g=x(),{api:i,session:r}=v(),{info:l}=u(),c=a.get("redirect"),p=a.get("id"),o=C(async()=>{if(!p)return null;const{data:t}=await i.get("/api/invitation",{params:{inviteId:p,mode:"issue-passport"}});return t}),m=f(()=>{if(o.error)throw o.error;return o?.data}),h=f(async(t,w=e=>e)=>{t&&(t.sessionToken&&j(w(t.sessionToken)),await r.refresh()),setTimeout(()=>{if(c){const e=decodeURIComponent(c);e.startsWith(I.WELLKNOWN_SERVICE_PATH_PREFIX)?g(e,{replace:!0}):window.location.href=E(e)}else window.location.href=window.env.pathPrefix||"/"},50)});return o.loading?s.jsx(d,{}):s.jsx(P,{className:"page-invite",sx:{width:"100vw",height:"100%",minHeight:"100vh",display:"flex",justifyContent:"center",alignItems:"center",backgroundColor:"#f6f8fa",overflow:"auto",padding:"20px"},children:s.jsx(T,{...n,action:"issue-passport",getDataFn:m,createPassportSvg:t=>S(t,l),checkFn:i.get,onLoginSuccess:h,passportColor:"default",onLogin:r.login})})}function b(){return u().loading?s.jsx(d,{}):s.jsx(R,{})}export{b as default};
