1import{d as F,b as H,a as O,u as G,D as J,o as K,c as x,l as s,e,h as o,v as Q,t as h,p as N,g as W,f as T,q as y,k as i,B as l,a6 as U,i as f,n as X,j as c}from"./CiKtckVa.js";import{_ as Y}from"./B1_FshQ4.js";import{V as D}from"./DjYJYkEl.js";import{_ as A}from"./5DDz-OcZ.js";import{o as ee,s as R}from"./DTVzw1wU.js";const se={class:"p-4 md:p-8 flex-1 flex flex-col justify-center"},ae={class:"max-w-md w-full mx-auto space-y-6"},te={key:0,class:"space-y-4"},oe={key:1,class:"space-y-6 text-center"},ne={class:"flex justify-center"},re={class:"w-16 h-16 rounded-full bg-orange-100 dark:bg-orange-900/40 flex items-center justify-center"},le={class:"space-y-2"},ie={class:"text-gray-600 dark:text-gray-400"},ce={key:2,class:"space-y-6"},de={class:"space-y-2"},ue={class:"text-3xl font-bold text-gray-900 dark:text-white"},me={class:"text-gray-600 dark:text-gray-400"},pe={class:"font-medium"},ve={key:0,class:"bg-red-50 dark:bg-red-900/50 text-red-500 dark:text-red-400 px-4 py-3 rounded-md"},xe={class:"flex flex-col space-y-2 my-4"},he={class:"grid grid-cols-2 gap-4"},ge={class:"flex items-center space-x-2"},ye={class:"flex items-center space-x-2"},fe={class:"flex items-center space-x-2"},we={class:"flex items-center space-x-2"},je=F({__name:"invitation",setup(_e){H({title:"Invitation"});const q=O(),I=G(),{setAuthToken:M}=J(),w=i(()=>q.query.token||""),_=l(!0),d=l(!1),p=l(!1),g=l(""),v=l("invalid"),B=l(""),$=l(null),b=l(!1),n=l({password:"",confirmPassword:""}),k=i(()=>n.value.password.length>=6),C=i(()=>/\d/.test(n.value.password)),V=i(()=>/[A-Z]/.test(n.value.password)),P=i(()=>/[a-z]/.test(n.value.password)),S=i(()=>k.value&&C.value&&V.value&&P.value&&n.value.password===n.value.confirmPassword),E=i(()=>v.value==="expired"?"Cette invitation a expiré. Demandez au club de vous en envoyer une nouvelle.":v.value==="known"?"Vous êtes déjà membre de ce club : connectez-vous avec vos identifiants.":"Ce lien d'invitation n'est pas valide."),Z=ee
1({password:R().min(6,"Le mot de passe doit contenir au moins 6 caractères").regex(/[0-9]/,"Le mot de passe doit contenir au moins un chiffre").regex(/[A-Z]/,"Le mot de passe doit contenir au moins une majuscule").regex(/[a-z]/,"Le mot de passe doit contenir au moins une minuscule"),confirmPassword:R()}).refine(t=>t.password===t.confirmPassword,{message:"Les mots de passe ne correspondent pas",path:["confirmPassword"]}),L=t=>`${window.location.protocol}//${window.location.hostname}${t}`;K(async()=>{if(!w.value){_.value=!1;return}try{const t=await $fetch(L(`/api/invitation/${w.value}`));v.value=t?.status??"invalid",B.value=t?.email??"",$.value=t?.club_name??null,b.value=t?.known_account===!0}catch{v.value="invalid"}finally{_.value=!1}});const z=async()=>{g.value="",d.value=!0;try{const t=await $fetch(L(`/api/invitation/${w.value}`),{method:"POST",body:{password:n.value.password,password_confirmation:n.value.confirmPassword}});if(!t?.token)throw new Error("L'activation du compte a échoué");M(t.token),await X("/app")}catch(t){g.value=t?.data?.error||t?.message||"L'activation du compte a échoué"}finally{d.value=!1}};return(t,a)=>{const u=Q;return c(),x("div",se,[s("div",ae,[e(_)?(c(),x("div",te,[...a[2]||(a[2]=[s("div",{class:"h-8 bg-gray-200 dark:bg-gray-700 rounded w-2/3 animate-pulse"},null,-1),s("div",{class:"h-4 bg-gray-100 dark:bg-gray-800 rounded w-full animate-pulse"},null,-1),s("div",{class:"h-10 bg-gray-100 dark:bg-gray-800 rounded animate-pulse"},null,-1)])])):e(v)!=="valid"?(c(),x("div",oe,[s("div",ne,[s("div",re,[o(u,{name:"heroicons:exclamation-triangle",class:"w-10 h-10 text-orange-500"})])]),s("div",le,[a[3]||(a[3]=s("h1",{class:"text-3xl font-bold text-gray-900 dark:text-white"},"Invitation indisponible",-1)),s("p",ie,h(e(E)),1)]),o(A,{text:"Aller à la connexion",color:"primary",onClick:a[0]||(a[0]=r=>e(I).push("/auth/login"))})])):(c(),x("div",ce,[s("div",de,[s("h1",ue,"Rejoindre "+h(e($)||"le club"),1),s("p",me,[a[4]||(a[4]=N(" Vous avez été invité avec l'adresse ",-1)),s("span",pe,h(e(B)),1),N(". "+h(e(b)?"Vous avez déjà un compte VPDive : votre mot de passe habituel reste valable.":"Choisissez votre mot de passe pour activer votre compte."),1)])]),e(g)?(c(),x("div",ve,h(e(g)),1)):W("",!0),e(b)?(c(),T(A,{key:1,text:"Rejoindre le club",color:"primary",loading:e(d),disabled:e(d),icon:"heroicons:arrow-right","icon-position":"right",onClick:z},null,8,["loading","disabled"])):(c(),T(Y,{key:2,schema:e(Z),onSubmit:z},{default:y(()=>[o(e(U),{name:"password"},{default:y(({field:r,errorMessage:j})=>[o(D,{type:e(p)?"text":"password",label:"Mot de passe",placeholder:"********",name:r.name,"model-value":r.value,"onUpdate:modelValue":m=>{r.onChange(m),e(n).password=m},onBlur:r.onBlur,error:j,required:""},{append:y(()=>[s("button",{type:"button",onClick:a[1]||(a[1]=m=>p.value=!e(p)),class:"absolute right-3 top-1/2 -translate-y-1/2 text-emerald-500 dark:text-emerald-400 hover:text-emerald-600 dark:hover:text-emerald-300"},[o(u,{name:e(p)?"material-symbols-visibility-off":"material-symbols-visibility",class:"inline-block w-5 h-5 ml-1"},null,8,["name"])])]),_:1},8,["type","name","model-value","onUpdate:modelValue","onBlur","error"])]),_:1}),o(e(U),{name:"confirmPassword"},{default:y(({field:r,errorMessage:j})=>[o(D,{type:e(p)?"text":"password",label:"Confirmation",placeholder:"Confirmer le mot de passe",name:r.name,"model-value":r.value,"onUpdate:modelValue":m=>{r.onChange(m),e(n).confirmPassword=m},onBlur:r.onBlur,error:j,required:"",class:"mt-4"},null,8,["type","name","model-value","onUpdate:modelValue","onBlur","error"])]),_:1}),s("div",xe,[s("div",he,[s("div",ge,[o(u,{name:e(k)?"heroicons:check-circle":"heroicons:x-circle",class:f(["w-5 h-5",e(k)?"text-green-500":"text-gray-300"])},null,8,["name","class"]),a[5]||(a[5]=s("span",{class:"text-sm text-gray-600 dark:text-gray-400"},"Au moins 6 caractères",-1))]),s("div",ye,[o(u,{name:e(V)?"heroicons:check-circle":"heroicons:x-circle",class:f(["w-5 h-5",e(V)?"text-green-500":"text-gray-300"])},null,8,["name","class"]),a[6]||(a[6]=s("span",{class:"text-sm text-gray-600 dark:text-gray-400"},"Au moins une majuscule",-1))]),s("div",fe,[o(u,{name:e(C)?"heroicons:check-circle":"heroicons:x-circle",class:f(["w-5 h-5",e(C)?"text-green-500":"text-gray-300"])},null,8,["name","class"]),a[7]||(a[7]=s("span",{class:"text-sm text-gray-600 dark:text-gray-400"},"Au moins un chiffre",-1))]),s("div",we,[o(u,{name:e(P)?"heroicons:check-circle":"heroicons:x-circle",class:f(["w-5 h-5",e(P)?"text-green-500":"text-gray-300"])},null,8,["name","class"]),a[8]||(a[8]=s("span",{class:"text-sm text-gray-600 dark:text-gray-400"},"Au moins une minuscule",-1))])])]),o(A,{type:"submit",text:"Rejoindre le club",color:"primary",loading:e(d),disabled:e(d)||!e(S),icon:"heroicons:arrow-right","icon-position":"right"},null,8,["loading","disabled"])]),_:1},8,["schema"]))]))])])}}});
1export{je 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.