1import{f as e,r as t,u as o,j as n}from"./vendor-react-DejgYtBM.js";import{u as s,U as a,s as r,L as i,A as c,B as l,w as p,D as u,E as d,F as m}from"./index-BeIIFw6E.js";import"./vendor-semi-D8d7bTtM.js";import"./vendor-icons-EJvJ5X-w.js";import"./vendor-motion-Chfy_MiU.js";const g={github:"GitHub",google:"Google",oidc:"OIDC",linuxdo:"Linux DO",hongming:"鸿æº"},f=f=>{const{t:y}=s(),[w]=e(),[,h]=t.useContext(a),v=o(),j=async(e,t,o=0)=>{try{const o="hongming"===f.type?`/api/oauth/hongming?auth_code=${encodeURIComponent(e)}`:`/api/oauth/${f.type}?code=${e}&state=${t}`,{data:n}=await c.get(o),{success:s,message:a,data:r}=n;if(!s)throw new Error(a||"OAuth2 callback error");if("already_bound"===r){const e=g[f.type]||f.type||y("该账å·");l(y("æ¨å·²ç»å®è¯¥ {{provider}} è´¦å·ï¼æ ééå¤ç»å®",{provider:e})),v("/console/personal")}else if("bind"===r)p(y("ç»å®æåï¼")),v("/console/personal");else{const e=r.is_new_user,t={...r};delete t.is_new_user,u(),h({type:"login",payload:t}),d(t),m(),p(y(e?"注åæåï¼":"ç»å½æåï¼")),((e=5e3,t=200)=>new Promise(o=>{if("function"==typeof window.trackAnalyticsEvent)return o(!0);const n=Date.now(),s=setInterval(()=>{"function"==typeof window.trackAnalyticsEvent?(clearInterval(s),o(!0)):Date.now()-n>=e&&(clearInterval(s),o(!1))},t)}))().then(t=>{if(t){const t=e?"registration":"login";window.trackAnalyticsEvent(t,{method:f.type||"oauth"})}}),v("/console")}}catch(n){if(o<3)return"function"==typeof setPrompt&&setPrompt(y("åºç°é误ï¼ç¬¬ ${num} 次éè¯ä¸...",{num:o+1})),await new Promise(e=>setTimeout(e,2e3*(o+1))),j(e,t,o+1);const s=n.message||message||y("ææå¤±è´¥");r(s),"function"==typeof setPrompt&&setPrompt(y("æä½å¤±è´¥ï¼éå®åè³ç»å½çé¢ä¸...")),v("/console/personal")}};return t.useEffect(()=>{if("hongming"===f.type){const e=w.get("auth_code");return e?void j(e,""):(r(y("æªè·åå°ææç ")),void v("/login"))}const e=w.get("code"),t=w.get("state");if(!e)return r(y("æªè·åå°ææç ")),void v("/console/personal");j(e,t)},[]),n.jsx(i,{})};export{f as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.