1import{j as e}from"./ui-vendor-CealJQWJ.js";import{d as B,r as t}from"./react-vendor-BkH0-HFx.js";import{supabase as o}from"./client-CwGsWvMq.js";import{B as v,l}from"./index-DiSVxwlL.js";import{L as P,I as S}from"./label-DqCDDQ_r.js";import{c as T}from"./one-business-club-logo-DdMcL7FK.js";import{C as U}from"./circle-check-big-BVNeLu8O.js";import{L}from"./lock-D-PmaP62.js";import{E as z}from"./eye-off-DyFJu5jV.js";import{E as Z}from"./eye-eDnYgciW.js";import"./query-vendor-i3MONKX8.js";const $=()=>{const u=B(),[d,R]=t.useState(""),[f,C]=t.useState(""),[h,E]=t.useState(!1),[p,x]=t.useState(!1),[q,i]=t.useState(!1),[D,w]=t.useState(!1),[b,c]=t.useState(null),[y,_]=t.useState(null);t.useEffect(()=>{const{data:{subscription:a}}=o.auth.onAuthStateChange(s=>{(s==="PASSWORD_RECOVERY"||s==="SIGNED_IN")&&i(!0)});return(async()=>{try{const s=new URL(window.location.href),r=new URLSearchParams(window.location.hash.replace(/^#/,"")),m=s.searchParams.get("rt");if(m){_(m),i(!0);return}const N=s.searchParams.get("error_description")||r.get("error_description");if(N){c(decodeURIComponent(N));return}const k=s.searchParams.get("code");if(k){const{error:n}=await o.auth.exchangeCodeForSession(k);n?c(n.message):(i(!0),window.history.replaceState({},"",s.pathname));return}const j=s.searchParams.get("token_hash")||r.get("token_hash"),I=s.searchParams.get("type")||r.get("type");if(j&&I==="recovery"){const{error:n}=await o.auth.verifyOtp({type:"recovery",token_hash:j});n?c(n.message):(i(!0),window.history.replaceState({},"",s.pathname));return}if(r.get("access_token")){setTimeout(async()=>{const{data:n}=await o.auth.getSession();n.session?i(!0):c("Recovery-Link ist abgelaufen oder ungueltig.")},500);return}const{data:O}=await o.auth.getSession();O.session?i(!0):c("Kein gueltiger Recovery-Link gefunden. Bitte fordere einen neuen Link an.")}catch(s){c((s==null?void 0:s.message)||"Recovery-Link konnte nicht verarbeitet werden.")}})(),()=>a.unsubscribe()},[]);const F=async a=>{if(a.preventDefault(),d.length<6){l.error("Das Passwort muss mindestens 6 Zeichen lang sein.");return}if(d!==f){l.error("Die Passwörter stimmen nicht überein.");return}if(x(!0),y){const{data:s,error:r}=await o.functions.invoke("password-reset",{body:{action:"complete",token:y,password:d}}),m=(r==null?void 0:r.message)||(s==null?void 0:s.error);m?l.error("Fehler beim Zurücksetzen",{description:(s==null?void 0:s.error)??m}):(w(!0),l.success("Passwort erfolgreich geändert!"),setTimeout(()=>u("/login"),2e3)),x(!1);return}const{error:g}=await o.auth.updateUser({password:d});g?l.error("Fehler beim Zurücksetzen",{description:g.message}):(w(!0),l.success("Passwort erfolgreich geändert!"),setTimeout(()=>u("/member"),2e3)),x(!1)};return e.jsx("div",{className:"min-h-screen bg-white flex items-center justify-center px-4",children:e.jsxs("div",{className:"w-full max-w-md",children:[e.jsx("div",{className:"text-center mb-8",children:e.jsx("img",{src:T,alt:"ONE Business Club",className:"h-10 w-auto mx-auto"})}),e.jsx("div",{className:"bg-white rounded-2xl border border-gray-200 shadow-lg p-8",children:D?e.jsxs("div",{className:"text-center py-8",children:[e.jsx(U,{className:"h-12 w-12 text-[hsl(104,46%,48%)] mx-auto mb-4"}),e.jsxs("h2",{className:"text-xl font-heading uppercase text-black mb-2",children:["Passwort ge","ä","ndert"]}),e.jsx("p",{className:"text-sm text-gray-500 font-body",children:"Du wirst gleich weitergeleitetâ¦"})]}):b?e.jsxs("div",{className:"text-center py-6",children:[e.jsxs("h2",{className:"text-xl font-heading uppercase text-black mb-3",children:["Link ung","ü","ltig"]}),e.jsx("p",{className:"text-sm text-gray-600 font-body mb-5",children:b}),e.jsx("p",{className:"text-xs text-gray-500 font-body mb-5",children:"Recovery-Links sind nur 24 Stunden gültig und können nur einmal verwendet werden. Manche E-Mail-Programme (iCloud, Outlook) öffnen den Link automatisch zum Prüfen â dadurch wird er verbraucht, bevor du draufklickst."}),e.jsx(v,{onClick:()=>u("/login"),className:"w-full bg-[hsl(104,46%,48%)] text-white hover:bg-[hsl(104,46%,38%)] font-body font-bold",children:"Neuen Link anfordern"})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"text-center mb-6",children:[e.jsx("h2",{className:"text-2xl font-heading uppercase text-black",children:"Neues Passwort"}),e.jsx("p",{className:"text-gray-500 font-body text-sm mt-1",children:"Gib dein neues Passwort ein."})]}),e.jsxs("form",{onSubmit:F,className:"space-y-5",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{htmlFor:"new-password",className:"text-black font-body text-sm",children:"Neues Passwort"}),e.jsxs("div",{className:"relative",children:[e.jsx(L,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-gray-400"}),e.jsx(S,{id:"new-password",type:h?"text":"password",placeholder:"â¢â¢â¢â¢â¢â¢â¢â¢",value:d,onChange:a=>R(a.target.value),className:"pl-10 pr-10 bg-white border-gray-300 text-black font-body",required:!0,minLength:6}),e.jsx("button",{type:"button",onClick:()=>E(!h),className:"absolute right-3 top-1/2 -translate-y-1/2 text-gray-400 hover:text-black",children:h?e.jsx(z,{className:"h-4 w-4"}):e.jsx(Z,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{htmlFor:"confirm-password",className:"text-black font-body text-sm",children:"Passwort bestätigen"}),e.jsxs("div",{className:"relative",children:[e.jsx(L,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-gray-400"}),e.jsx(S,{id:"confirm-password",type:h?"text":"password",placeholder:"â¢â¢â¢â¢â¢â¢â¢â¢",value:f,onChange:a=>C(a.target.value),className:"pl-10 bg-white border-gray-300 text-black font-body",required:!0})]})]}),e.jsx(v,{type:"submit",disabled:p,className:"w-full bg-[hsl(104,46%,48%)] text-white hover:bg-[hsl(104,46%,38%)] font-body font-bold text-base py-5",children:p?"Wird gespeichert...":"Passwort speichern"})]})]})})]})})};export{$ 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.