import{d as _,u as y,b as p,n as k,w as b,v,e as x,o as T,c as E,r as B,g as C,f as I,l as q,s as R,E as d}from"./index-XuO881sr.js";const S={class:"social-callback"},M=_({__name:"index",setup(J){const a=y(),s=B(!0),u=a.query.code,c=a.query.state,f=a.query.source,n=JSON.parse(atob(c)),w=n.tenantId?n.tenantId:"000000",i=n.domain,r=async e=>{if(e.code!==200)throw new Error(e.msg);e.data!==null&&R(e.data.access_token),d.success(e.msg),setTimeout(()=>{location.href="/index"},2e3)},l=e=>{d.error(e.message),setTimeout(()=>{location.href="/index"},2e3)},h=async e=>{try{const t=await I(e);await r(t),s.value=!1}catch(t){l(t)}},g=async e=>{try{const t=await q(e);await r(t),s.value=!1}catch(t){l(t)}},m=async()=>{const e=window.location.host;if(i!==e){const o=new URL(window.location.href);o.host=i,window.location.href=o.toString();return}const t={socialCode:u,socialState:c,tenantId:w,source:f,clientId:"e5cd7e4891bf95d1d19206ce24a7b32e",grantType:"social"};C()?await h(t):await g(t)};return p(()=>{k(()=>{m()})}),(e,t)=>{const o=v;return b((T(),E("div",S,null,512)),[[o,x(s)]])}}});export{M as default};
