import{_ as T,j as U,x as q,k as F,l as j,a as d,y as A,E as x,C as L,o as v,c as C,d as l,F as h,g as n,f as i,w as S,n as I,e as w,u as b,I as B,B as P,G as M,h as z,H as D,A as E,p as W,i as $,J as H}from"./index-4e8c1b57.js";import{l as G}from"./load-script-8d839500.js";import{B as V}from"./BaseRadio-a051ce67.js";const k=o=>(W("data-v-82f2ffea"),o=o(),$(),o),J={class:"role-selection"},O=k(()=>l("div",{class:"fwt-700"},"Participant ",-1)),K=k(()=>l("div",{class:"fwt-700"},"Researcher ",-1)),Q=k(()=>l("div",null,[i(" Before a new account can be created for you, please carefully review our "),l("a",{href:"https://help.findingfive.com/tos.html",target:"_blank",class:"fwt-700"},"Terms of Service"),i(" and "),l("a",{href:"https://help.findingfive.com/privacy.html",target:"_blank",class:"fwt-700"},"Privacy Policy"),i('. By clicking the "continue" button below, you are agreeing to these legal documents and permitting us to create an account for you on FindingFive. ')],-1)),X="https://accounts.google.com/gsi/client",Y={__name:"GoogleIdentity",props:{width:{type:Number,default:320}},setup(o){const m=U(),r=q(),a=F(),p=j(),g=o,c=d(!1),_=d(null),s=d(null),e=d((localStorage.getItem("ff_user_part")||"").trim());A(e,u=>{localStorage.setItem("ff_user_part",u.trim())}),x(async()=>{window.google||await G(X),google.accounts.id.initialize({client_id:"537309394364-mqffui8frpu9c5qnq7tg2sdrsr7chvd4.apps.googleusercontent.com",callback:R}),google.accounts.id.renderButton(_.value,{width:g.width})});async function R(u){e.value=localStorage.getItem("ff_user_part")||"",r.disablePage(),s.value=u.credential;try{a.pop("Logging you in via Google...","loading"),await p.signin({token_issuer:"google",token:s.value}),await a.pop("Sign in completed! Redirecting ...","success",1e3),m.push(p.redirectUrl)}catch(t){t.startsWith("No account is associated")?(a.remove(),c.value=!0):await a.pop("We are unable to verify your identity with Google. Please try again later.","error",2e3)}finally{r.disablePage(!0)}}async function N(){if(!e.value){a.pop("Please select a role to continue","error",2500);return}a.pop("Please wait ...","loading"),r.disablePage();const u={token_issuer:"google",token:s.value,role:e.value},t=await E(u);if(t.ok)await a.pop("Sign up completed! Redirecting ...","success",1e3),m.push(p.redirectUrl);else{let f="Unexpected error occurred. Please try again later";t.status>=400&&t.status<500&&(f=(await t.json()).response),await a.pop(f,"error",2e3)}r.disablePage(!0)}return(u,t)=>{const f=L("tippy");return v(),C(D,null,[l("div",{ref_key:"googleLoginButton",ref:_,id:"google-signin-btn"},null,512),c.value?(v(),h(M,{key:0},{title:n(()=>[i("Create a new account")]),body:n(()=>[i(" Please select a role: "),l("div",J,[S((v(),h(V,{modelValue:e.value,"onUpdate:modelValue":t[0]||(t[0]=y=>e.value=y),value:"participant",class:I(["role-option",{selected:e.value==="participant"}])},{default:n(()=>[O,w(b(B),{icon:"fa6-solid:user",inline:"true",width:"12"})]),_:1},8,["modelValue","class"])),[[f,"If you are here to participate in a study"]]),S((v(),h(V,{modelValue:e.value,"onUpdate:modelValue":t[1]||(t[1]=y=>e.value=y),value:"researcher",class:I(["role-option",{selected:e.value==="researcher"}])},{default:n(()=>[K,w(b(B),{icon:"fa6-solid:user-graduate",inline:"true",width:"12"})]),_:1},8,["modelValue","class"])),[[f,"If you are planning to create and run studies"]])]),Q]),footer:n(()=>[w(P,{variant:"confirm",onClick:N},{default:n(()=>[i("Continue")]),_:1}),w(P,{variant:"cancel",onClick:t[2]||(t[2]=y=>c.value=!1)},{default:n(()=>[i("Cancel")]),_:1})]),_:1})):z("",!0)],64)}}},oe=T(Y,[["__scopeId","data-v-82f2ffea"]]),Z="https://challenges.cloudflare.com/turnstile/v0/api.js",se={__name:"Turnstile",props:{sitekey:{type:String,required:!0},modelValue:{type:String,required:!0},action:String},emits:["update:modelValue"],setup(o,{expose:m,emit:r}){const a=o,p=r;let g=d("");const c=d(null);x(async()=>{var s;(window.turnstile===null||!window.turnstile)&&await G(Z),g.value=(s=window.turnstile)==null?void 0:s.render(c.value,{sitekey:a.sitekey,action:a.action,callback:function(e){p("update:modelValue",e)}})}),H(()=>{window.turnstile.remove(g.value)});function _(){window.turnstile.reset(g.value)}return m({reset:_}),(s,e)=>(v(),C("div",{ref_key:"cfTurnstile",ref:c},null,512))}};export{oe as G,se as _};