import{aD as j,l as h,an as D,ap as S,bm as y,k as N,g as p,j as e,r as k,c as F,x as u,bo as L,bp as E,D as I,w as B,J as P,B as m,T as r,a2 as R,a7 as A,M as T,Q as q,R as G,am as _,a3 as O}from"./main-TIUJvpaR.js";import{u as M}from"./use-social-login-w6iLlymj.js";import{u as Q}from"./use-all-social-logins-disabled-BoQ09ZS1.js";import{E as U}from"./envato-zsG_WUKe.js";import{G as W}from"./google-Dkq6mbpd.js";import{D as z}from"./dialog-footer-yCpPZGPO.js";function H(a){const s=j(),{getRedirectUri:t}=h();return D({mutationFn:J,onSuccess:o=>{y(o.bootstrapData),s(t(),{replace:!0})},onError:o=>S(o,a)})}function J(a){return N.post("secure/auth/social/connect",a).then(s=>s.data)}const Y=u("Continue with google"),K=u("Continue with facebook"),V=u("Continue with twitter"),X=u("Continue with envato");function ne({dividerMessage:a,isUsingInvite:s}){var d,g,b,f;const{social:t}=p(),o=j(),{getRedirectUri:x}=h(),{loginWithSocial:i,requestingPassword:w,setIsRequestingPassword:v}=M();if(Q({isUsingInvite:s}))return null;const c=async C=>{const n=await i(C);((n==null?void 0:n.status)==="SUCCESS"||(n==null?void 0:n.status)==="ALREADY_LOGGED_IN")&&o(x(),{replace:!0})};return e.jsxs(k.Fragment,{children:[e.jsx("div",{className:"relative my-20 text-center before:absolute before:left-0 before:top-1/2 before:h-1 before:w-full before:-translate-y-1/2 before:bg-divider",children:e.jsx("span",{className:"relative z-10 bg-elevated px-10 text-sm text-muted",children:a})}),e.jsxs("div",{className:F("flex items-center justify-center gap-14",!(t!=null&&t.compact_buttons)&&"flex-col"),children:[(d=t==null?void 0:t.google)!=null&&d.enable?e.jsx(l,{label:Y,icon:e.jsx(W,{viewBox:"0 0 48 48"}),onClick:()=>c("google")}):null,(g=t==null?void 0:t.facebook)!=null&&g.enable?e.jsx(l,{label:K,icon:e.jsx(L,{className:"text-facebook"}),onClick:()=>c("facebook")}):null,(b=t==null?void 0:t.twitter)!=null&&b.enable?e.jsx(l,{label:V,icon:e.jsx(E,{className:"text-twitter"}),onClick:()=>c("twitter")}):null,(f=t==null?void 0:t.envato)!=null&&f.enable&&!s?e.jsx(l,{label:X,icon:e.jsx(U,{viewBox:"0 0 50 50",className:"text-envato"}),onClick:()=>c("envato")}):null]}),e.jsx(I,{type:"modal",isOpen:w,onOpenChange:v,children:e.jsx(Z,{})})]})}function Z(){const a=R(),{formId:s}=A(),t=H(a);return e.jsxs(T,{children:[e.jsx(q,{children:e.jsx(r,{message:"Password required"})}),e.jsxs(G,{children:[e.jsx("div",{className:"mb-30 text-sm text-muted",children:e.jsx(r,{message:"An account with this email address already exists. If you want to connect the two accounts, enter existing account password."})}),e.jsx(_,{form:a,id:s,onSubmit:o=>{t.mutate(o)},children:e.jsx(O,{autoFocus:!0,name:"password",type:"password",required:!0,label:e.jsx(r,{message:"Password"})})})]}),e.jsxs(z,{children:[e.jsx(m,{variant:"text",children:e.jsx(r,{message:"Cancel"})}),e.jsx(m,{type:"submit",form:s,variant:"flat",color:"primary",disabled:t.isPending,children:e.jsx(r,{message:"Connect"})})]})]})}function l({onClick:a,label:s,icon:t}){var i;const{trans:o}=B();return(i=p().social)!=null&&i.compact_buttons?e.jsx(P,{variant:"outline","aria-label":o(s),onClick:a,children:t}):e.jsx(m,{variant:"outline",startIcon:t,onClick:a,className:"min-h-42 w-full",children:e.jsx("span",{className:"min-w-160 text-start",children:e.jsx(r,{...s})})})}export{ne as S};
