import{v as e,f as s,d as t,e as o,a as r,u as a,j as i,w as n,n as l}from"./index.c5fb8bc8.js";import{m as c,w as u,s as d,p as f,q as p,e as m,I as v,B as g,J as h,N as b,H as k,t as y,c as w,r as x,o as C,a4 as E,L as _,M as j,D as B,z as D,A as I}from"./vendor.0fb6acf8.js";import{_ as T}from"./error-card.571cbd99.js";import{u as H,_ as M,a as R}from"./xstate.e56ef8a6.js";import{p as V}from"./mainCheckoutMachine.e7b5ddf2.js";import{u as $}from"./index.dadb3e58.js";import{g as U}from"./mainAuthMachine.cc1f2d0a.js";import{getErrorCardInfo as X}from"./getErrorCardInfo.b825947f.js";import A from"./continuar.70d30cc3.js";import q from"./inscreva-se.a2af2d97.js";import N from"./insira-o-pin.6bd82fab.js";import S from"./insira-seus-dados.0656708e.js";import z from"./escolher-autenticacao.0485f0ca.js";import"./errorHandling.de8b7b83.js";import"./interpreterHelpers.75178808.js";import"./base-link.03118c9b.js";import"./base-input.209e88ce.js";import"./tel-input.63e6bfb3.js";var P=c({components:{XIcon:e},props:{durationInMS:{type:Number,default:0},visible:Boolean},emits:["update:visible"],setup(e,{emit:s}){function t(){s("update:visible",!1)}return u((()=>e.visible),(s=>{s&&e.durationInMS&&setTimeout(t,e.durationInMS)})),{emitClose:t}}});const J={key:0,class:"max-w-sm w-full bg-white shadow-lg rounded-lg pointer-events-auto ring-1 ring-black ring-opacity-5 overflow-hidden"},L={class:"p-4"},O={class:"flex items-start"},F={class:"flex-shrink-0"},G={class:"ml-3 w-0 flex-1 pt-0.5"},K={class:"ml-4 flex-shrink-0 flex"},Q=m("span",{class:"sr-only"},"Close",-1);P.render=function(e,s,t,o,r,a){const i=d("XIcon");return f(),p(k,{to:"#notifications"},[m(b,{"enter-active-class":"transform ease-out duration-300 transition","enter-from-class":"opacity-0","enter-to-class":"opacity-100","leave-active-class":"transition ease-in duration-100","leave-from-class":"opacity-100","leave-to-class":"opacity-0"},{default:v((()=>[e.visible?(f(),p("div",J,[m("div",L,[m("div",O,[m("div",F,[g(e.$slots,"icon")]),m("div",G,[g(e.$slots,"default")]),m("div",K,[m("button",{type:"button",class:"bg-white rounded-md inline-flex text-gray-400 hover:text-gray-500 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500",onClick:s[1]||(s[1]=(...s)=>e.emitClose&&e.emitClose(...s))},[Q,m(i,{class:"h-5 w-5","aria-hidden":"true"})])])])])])):h("",!0)])),_:1})])};var W=c({components:{EscolherAutenticacao:z,Continuar:A,InscrevaSe:q,InsiraOPin:N,InsiraSeusDados:S,BaseNotification:P,XCircleIcon:function(e,s){return f(),p("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[m("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M10 14l2-2m0 0l2-2m-2 2l-2-2m2 2l2 2m7-2a9 9 0 11-18 0 9 9 0 0118 0z"})])}},setup(){const e=s(),c=t(),d=o(),f=r(),p=$(),{locale:m,t:v}=a(),{token:g}=i(),h=n(["locale","sessionToken"]),b=y(z);d.query.auth_token&&"string"==typeof d.query.auth_token&&(g.value=d.query.auth_token),c.setRootState({sessionToken:g.value});const k=U({$accessor:c,$axios:e,$mixpanel:p,$sentry:E,sessionToken:g,router:f}),_=H(k);V(_),u(_.state,(({value:e})=>function(e){switch(e){case"chooseAuthMethod":b.value=z;break;case"identify":b.value=q;break;case"signup":b.value=S;break;case"signin":b.value=N}}(e)));const j=w((()=>c.checkoutXstate.hasError)),B=w((()=>{var e,s,t;if(j.value){const o=c.checkoutXstate.getPasswordlessError.currentError,r=null==(s=null==(e=c.checkoutXstate.getContentEndpointResponse)?void 0:e.result.classroom.enrollment)?void 0:s.begin,a=null==(t=c.checkoutXstate.getContentEndpointResponse)?void 0:t.result.account.checkout_fallback_url;return X(o,v,r,a)}})),D=w((()=>{var e;return null==(e=B.value)?void 0:e.text})),I=w((()=>{var e;return null==(e=B.value)?void 0:e.buttonText})),T=w((()=>{var e;return(null==(e=B.value)?void 0:e.onButtonClick)||(()=>{})})),M=w((()=>{var e;return(null==(e=c.checkoutXstate.getContentEndpointResponse)?void 0:e.result.course.name)||""})),R=w({get:()=>c.passwordlessErrorHandling.isTryAgainDialogVisible,set(e){l.done(),e?c.passwordlessErrorHandling.showTryAgainDialog():c.passwordlessErrorHandling.hideTryAgainDialog()}}),A=w({get:()=>c.passwordlessErrorHandling.isConflictedUserDialogVisible,set(e){l.done(),e?c.passwordlessErrorHandling.showConflictedUserDialog():c.passwordlessErrorHandling.hideConflictedUserDialog()}}),P=w({get:()=>c.passwordlessErrorHandling.isBlockedUserDialogVisible,set(e){l.done(),e?c.passwordlessErrorHandling.showBlockedUserDialog():c.passwordlessErrorHandling.hideBlockedUserDialog()}}),J=w((()=>c.checkoutRedirecting.isRedirectingCardVisible));const L=x(!1);return C((async()=>{const s=d.query.auth_error_message;s&&"string"==typeof s&&(L.value=!0);!!h.get("locale")||await e.get("https://ip2c.org/s").then((({data:e})=>{e.includes(";BR;")&&(m.value="pt-BR")})).catch((()=>{}))})),{isConflictedUserDialogVisible:A,isBlockedUserDialogVisible:P,isTryAgainDialogVisible:R,hasError:j,isRedirecting:J,title:M,errorText:D,errorButtonText:I,onErrorButtonClick:T,currentComponent:b,isErrorNotificationVisible:L}}});const Y=I("data-v-2643cf34");_("data-v-2643cf34");const Z={key:"content",class:"content-wrapper"},ee={class:"text-sm font-medium text-gray-900"},se={class:"mt-1 text-sm text-gray-500"},te={key:"error"},oe={key:1,class:"flex flex-col items-center w-full"},re={class:"outside-title"},ae=m("div",{class:"mobile-color-overlay","aria-hidden":"true"},null,-1),ie={key:2,class:"flex flex-col items-center w-full"},ne={class:"outside-title"},le=m("div",{class:"mobile-color-overlay","aria-hidden":"true"},null,-1),ce={class:"outside-powered-by"};j();const ue=Y(((e,s,t,o,r,a)=>{const i=d("XCircleIcon"),n=P,l=T,c=M,u=R;return f(),p("div",Z,[m(n,{visible:e.isErrorNotificationVisible,"onUpdate:visible":s[1]||(s[1]=s=>e.isErrorNotificationVisible=s)},{icon:Y((()=>[m(i,{class:"h-6 w-6 text-red-600"})])),default:Y((()=>[m("p",ee,B(e.$t("checkout.error_messages.auth_error")),1),m("p",se,B(e.$route.query.auth_error_message),1)])),_:1},8,["visible"]),e.hasError?(f(),p("div",te,[m(l,{text:e.errorText,"main-button-text":e.errorButtonText,onMainButtonClick:e.onErrorButtonClick},null,8,["text","main-button-text","onMainButtonClick"])])):e.isRedirecting?(f(),p("div",oe,[m("div",re,[m("h1",null,B(e.$t("checkout.general.access_your_account")),1),ae]),m(c)])):(f(),p("div",ie,[m("div",ne,[m("h1",null,B(e.$t("checkout.general.access_your_account")),1),le]),(f(),p(D(e.currentComponent),{mode:"auth"}))])),m("div",ce,[m(u)])])}));W.render=ue,W.__scopeId="data-v-2643cf34";var de=c({}),fe={};"function"==typeof fe&&fe(de),de.render=function(e,s,t,o,r,a){const i=W,n=d("client-only");return f(),p(n,null,{default:v((()=>[m(i)])),_:1})};export default de;
//# sourceMappingURL=auth.8b86c206.js.map
