1import{d as oe,r as u,c as v,X as se,o as ne,w as ie,z as f,B as t,G as r,u as i,E as K,L as O,M as L,Y as N,Z as re,C as m}from"./vendor-vue-BVJWaRIf.js";import{u as le}from"./useClipboard-CMfQ2Hei.js";import{a as ue,u as de,o as ce,q as pe,s as he,f as ve}from"./index-DajaXR7V.js";import{c as fe,o as me,l as _e}from"./oauthAffiliate-CrlUwkd1.js";import{u as be}from"./vendor-i18n-pgwztqC8.js";import"./vendor-misc-WKm5Kdig.js";const ge={class:"min-h-screen bg-gray-50 px-4 py-10 dark:bg-dark-900"},ye={class:"mx-auto max-w-2xl"},we={key:0,class:"card p-6 text-center"},ke={class:"mt-4 text-lg font-semibold text-gray-900 dark:text-white"},xe={class:"mt-2 text-sm text-gray-600 dark:text-gray-400"},Ce={key:1,class:"card p-6"},Pe={class:"text-lg font-semibold text-gray-900 dark:text-white"},Re={class:"mt-2 text-sm text-gray-600 dark:text-gray-400"},Se={class:"mt-6 space-y-4"},Ae={class:"input-label"},Ee=["value"],Te={class:"input-label"},qe=["placeholder","disabled"],Oe={class:"input-label"},Le=["placeholder","disabled"],Ne={key:0},Ue={class:"input-label"},Ie=["placeholder","disabled"],$e={key:1,class:"text-sm text-red-600 dark:text-red-400"},Ve=["disabled"],De={key:2,class:"card p-6 text-center"},Fe={class:"text-lg font-semibold text-gray-900 dark:text-white"},He={class:"mt-2 text-sm text-gray-600 dark:text-gray-400"},Me={key:3,class:"card p-6"},Be={class:"text-lg font-semibold text-gray-900 dark:text-white"},Ke={class:"mt-2 text-sm text-gray-600 dark:text-gray-400"},Ge={class:"mt-6 space-y-4"},ze={class:"input-label"},We={class:"flex gap-2"},Ye=["value"],je=["disabled"],Xe={class:"input-label"},Ze={class:"flex gap-2"},Je=["value"],Qe=["disabled"],et={class:"input-label"},tt={class:"flex gap-2"},at=["value"],ot=["disabled"],G="email_oauth_pending_provider",ct=oe({__name:"OAuthCallbackView",setup(st){const _=se(),U=re(),{t:s}=be(),{copyToClipboard:z}=le(),b=ue(),W=de(),g=u(!1),d=u(!1),S=u(!1),y=u(!1),w=u(""),c=u(""),k=u(""),x=u(""),p=u(""),A=u("github"),I=u("/dashboard"),$=u(!1),C=v(()=>_.query.code||""),P=v(()=>_.query.state||""),Y=v(()=>_.query.error||_.query.error_description||""),E=v(()=>typeof window>"u"?"":window.location.href),V=v(()=>A.value==="google"?"Google":"GitHub"),j=v(()=>y.value?s("auth.oidc.invitationRequired",{providerName:V.value}):s("auth.oidc.completeRegistration")),X=v(()=>!(!w.value.trim()||c.value.length<6||c.value!==k.value||y.value&&!x.value.trim()));function Z(){const e=typeof window<"u"?window.location.hash:"",a=e.startsWith("#")?e.slice(1):e;return new URLSearchParams(a)}function J(e){var F,H,M,B;const a=((F=e.get("access_token"))==null?void 0:F.trim())||"";if(!a)return null;const o={access_token:a},l=((H=e.get("refresh_token"))==null?void 0:H.trim())||"";l&&(o.refresh_token=l);const n=Number.parseInt(((M=e.get("expires_in"))==null?void 0:M.trim())||"",10);Number.isFinite(n)&&n>0&&(o.expires_in=n);const h=((B=e.get("token_type"))==null?void 0:B.trim())||"";return h&&(o.token_type=h),o}function D(e){return!e||!e.startsWith("/")||e.startsWith("//")||e.includes("://")||e.includes(` 2`)||e.includes("\r")?"/dashboard":e}function Q(){if(typeof window>"u")return null;const e=window.sessionStorage.getItem(G);return e==="github"||e==="google"?e:null}function ee(e){if(typeof window>"u")return;const a=new URLSearchParams;for(const[l,n]of Object.entries(_.query))Array.isArray(n)?n.forEach(h=>{h!=null&&a.append(l,String(h))}):n!=null&&a.set(l,String(n));const o=a.toString()?`?${a.toString()}`:"";window.location.href=ce(`/auth/oauth/${e}/callback${o}`)}async function T(e,a){pe(e),await W.setToken(e.access_token),typeof window<"u"&&window.sessionStorage.removeItem(G),fe(),b.showSuccess(s("auth.loginSuccess")),await U.replace(D(a))}function te(e){return typeof e.access_token=="string"&&e.access_token.trim()!==""}async function ae(){var e,a;g.value=!0;try{const o=await he(),l=o.redirect||"/dashboard";if(te(o)){await T(o,l);return}const n=String(o.provider||"").toLowerCase();if((n==="github"||n==="google")&&(A.value=n),I.value=D(l),o.error==="invitation_required"||o.error==="registration_completion_required"){y.value=o.error==="invitation_required"||o.invitation_required===!0,w.value=String(o.resolved_email||o.email||"").trim(),S.value=!0,g.value=!1;return}b.showError(o.error||s("auth.loginFailed"))}catch(o){const l=o,n=((a=(e=l.response)==null?void 0:e.data)==null?void 0:a.message)||l.message||s("auth.loginFailed");b.showError(n),$.value=!0}finally{S.value||(g.value=!1)}}async function R(){var a,o;if(p.value="",!w.value.trim()){p.value=s("auth.emailRequired");return}if(c.value.length<6){p.value=s("auth.passwordMinLength");return}if(c.value!==k.value){p.value=s("auth.passwordsDoNotMatch");return}const e=x.value.trim();if(!(y.value&&!e)){d.value=!0;try{const l={password:c.value,...me(_e())};y.value&&(l.invitation_code=e);const{data:n}=await ve.post(`/auth/oauth/${A.value}/complete-registration`,l);await T(n,I.value)}catch(l){const n=l;p.value=((o=(a=n.response)==null?void 0:a.data)==null?void 0:o.message)||n.message||s("auth.oidc.completeRegistrationFailed")}finally{d.value=!1}}}ne(async()=>{const e=Z(),a=J(e),o=e.get("error")||"",l=e.get("error_description")||e.get("error_message")||"";if(o){b.showError(l||o);return}if(!a){if(_.path==="/auth/oauth/callback"){const n=Q();if(n&&C.value&&P.value){ee(n);return}await ae()}return}g.value=!0;try{await T(a,e.get("redirect")||"/dashboard")}catch(n){const h=(n==null?void 0:n.message)||s("auth.loginFailed");b.showError(h),g.value=!1}}),ie(Y,e=>{e&&b.showError(e)},{immediate:!0});const q=e=>{e&&z(e)};return(e,a)=>(m(),f("div",ge,[t("div",ye,[g.value?(m(),f("div",we,[a[7]||(a[7]=t("div",{class:"mx-auto h-8 w-8 animate-spin rounded-full border-2 border-primary-500 border-t-transparent"},null,-1)),t("h1",ke,r(i(s)("auth.oauth.callbackTitle")),1),t("p",xe,r(i(s)("auth.oauth.callbackHint")),1)])):S.value?(m(),f("div",Ce,[t("h1",Pe,r(i(s)("auth.oidc.callbackTitle",{providerName:V.value})),1),t("p",Re,r(j.value),1),t("div",Se,[t("div",null,[t("label",Ae,r(i(s)("auth.emailLabel")),1),t("input",{class:"input w-full",type:"email",value:w.value,readonly:"",disabled:""},null,8,Ee)]),t("div",null,[t("label",Te,r(i(s)("auth.passwordLabel")),1),O(t("input",{"onUpdate:modelValue":a[0]||(a[0]=o=>c.value=o),type:"password",class:"input w-full",placeholder:i(s)("auth.createPasswordPlaceholder"),disabled:d.value,autocomplete:"new-password",onKeyup:N(R,["enter"])},null,40,qe),[[L,c.value]])]),t("div",null,[t("label",Oe,r(i(s)("auth.confirmPassword")),1),O(t("input",{"onUpdate:modelValue":a[1]||(a[1]=o=>k.value=o),type:"password",class:"input w-full",placeholder:i(s)("auth.confirmPasswordPlaceholder"),disabled:d.value,autocomplete:"new-password",onKeyup:N(R,["enter"])},null,40,Le),[[L,k.value]])]),y.value?(m(),f("div",Ne,[t("label",Ue,r(i(s)("auth.invitationCodeLabel")),1),O(t("input",{"onUpdate:modelValue":a[2]||(a[2]=o=>x.value=o),type:"text",class:"input w-full",placeholder:i(s)("auth.invitationCodePlaceholder"),disabled:d.value,onKeyup:N(R,["enter"])},null,40,Ie),[[L,x.value]])])):K("",!0),p.value?(m(),f("p",$e,r(p.value),1)):K("",!0),t("button",{class:"btn btn-primary w-full",type:"button",disabled:d.value||!X.value,onClick:R},r(d.value?i(s)("common.processing"):i(s)("auth.oidc.completeRegistration")),9,Ve)])])):$.value?(m(),f("div",De,[t("h1",Fe,r(i(s)("auth.oauth.invalidCallbackTitle")),1),t("p",He,r(i(s)("auth.oauth.invalidCallbackHint")),1),t("button",{class:"btn btn-primary mt-6",type:"button",onClick:a[3]||(a[3]=o=>i(U).replace("/login"))},r(i(s)("auth.backToLogin")),1)])):(m(),f("div",Me,[t("h1",Be,r(i(s)("auth.oauth.callbackTitle")),1),t("p",Ke,r(i(s)("auth.oauth.callbackHint")),1),t("div",Ge,[t("div",null,[t("label",ze,r(i(s)("auth.oauth.code")),1),t("div",We,[t("input",{class:"input flex-1 font-mono text-sm",value:C.value,readonly:""},null,8,Ye),t("button",{class:"btn btn-secondary",type:"button",disabled:!C.value,onClick:a[4]||(a[4]=o=>q(C.value))},r(i(s)("common.copy")),9,je)])]),t("div",null,[t("label",Xe,r(i(s)("auth.oauth.state")),1),t("div",Ze,[t("input",{class:"input flex-1 font-mono text-sm",value:P.value,readonly:""},null,8,Je),t("button",{class:"btn btn-secondary",type:"button",disabled:!P.value,onClick:a[5]||(a[5]=o=>q(P.value))},r(i(s)("common.copy")),9,Qe)])]),t("div",null,[t("label",et,r(i(s)("auth.oauth.fullUrl")),1),t("div",tt,[t("input",{class:"input flex-1 font-mono text-xs",value:E.value,readonly:""},null,8,at),t("button",{class:"btn btn-secondary",type:"button",disabled:!E.value,onClick:a[6]||(a[6]=o=>q(E.value))},r(i(s)("common.copy")),9,ot)])])])]))])]))}});
2export{ct 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.