import{ag as j,e as h,G as S,ai as D,cq as y,b as N,u as p,j as e,r as F,d as L,J as u,aN as k,aM as E,D as I,z as B,Y as P,t as x,T as r,M as q,a0 as A,a1 as R,a2 as T,a3 as G,au as _,V as M}from"./main-D6SjkSWq.js";import{u as O}from"./use-social-login-CQCryHFt.js";import{u as z}from"./use-all-social-logins-disabled-59RZr6oN.js";import{E as U}from"./envato-DR-vtB4t.js";import{G as W}from"./google-qn0A9fgz.js";import{D as Y}from"./dialog-footer-es-AfbvV.js";function H(a){const s=j(),{getRedirectUri:t}=h();return S({mutationFn:J,onSuccess:o=>{y(o.bootstrapData),s(t(),{replace:!0})},onError:o=>D(o,a)})}function J(a){return N.post("secure/auth/social/connect",a).then(s=>s.data)}const Q=u("Continue with google"),V=u("Continue with facebook"),K=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:m}=h(),{loginWithSocial:i,requestingPassword:w,setIsRequestingPassword:v}=O();if(z({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(m(),{replace:!0})};return e.jsxs(F.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:L("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:Q,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:V,icon:e.jsx(k,{className:"text-facebook"}),onClick:()=>c("facebook")}):null,(b=t==null?void 0:t.twitter)!=null&&b.enable?e.jsx(l,{label:K,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=q(),{formId:s}=A(),t=H(a);return e.jsxs(R,{children:[e.jsx(T,{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(M,{autoFocus:!0,name:"password",type:"password",required:!0,label:e.jsx(r,{message:"Password"})})})]}),e.jsxs(Y,{children:[e.jsx(x,{variant:"text",children:e.jsx(r,{message:"Cancel"})}),e.jsx(x,{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(x,{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};
