1import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{n as t,t as n}from"./jsx-runtime-Ciaf_P-h.js";import{i as r,n as i,o as a}from"./router-compat-BkIud-hE.js";import{t as o}from"./client-BpMbrqHm.js";import{n as s}from"./use-toast-Bfgt-5y-.js";import{t as c}from"./button-D-uxO5jV.js";import{t as l}from"./arrow-right-kSfuZE07.js";import{t as u}from"./eye-off-BFuyjLit.js";import{t as d}from"./eye-D1n45Jgr.js";import{t as f}from"./lock-BeHWt5JO.js";import{t as p}from"./shield-CaQygCl1.js";import{t as m}from"./proxy-Cegqxc_K.js";import{Ft as h,ot as g,xt as _}from"./index-B4i4a1Ae.js";import{t as v}from"./input-2HlNgKx_.js";import{t as y}from"./label-EAzSFKYu.js";var b=e(t(),1),x=n();function S(){let[e]=a(),t=e.get(`redirect`)||`/admin`,n=e.get(`mode`)===`login`,S=!!e.get(`checkout_session_id`),C=e.get(`invite_email`)||``,w=e.get(`invite_org`)||``,T=!!C,[E,D]=(0,b.useState)(C),[O,k]=(0,b.useState)(``),[A,j]=(0,b.useState)(!1),[M,N]=(0,b.useState)(!1),[P,F]=(0,b.useState)(!n&&(e.get(`signup`)===`1`||T)),{signIn:I,signUp:L,user:R,isLoading:z}=g(),{toast:B}=s(),V=r();return!z&&R&&!n?(0,x.jsx)(i,{to:`/admin`,replace:!0}):(0,x.jsxs)(`div`,{className:`min-h-screen bg-gradient-to-br from-primary via-primary/95 to-primary/90 flex items-center justify-center p-4`,children:[(0,x.jsx)(`title`,{children:`Accedi â Area riservata | Innovonline`}),(0,x.jsx)(`meta`,{name:`robots`,content:`noindex, nofollow`}),(0,x.jsx)(`div`,{className:`absolute inset-0 bg-[url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNjAiIGhlaWdodD0iNjAiIHZpZXdCb3g9IjAgMCA2MCA2MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxnIGZpbGw9IiNmZmYiIGZpbGwtb3BhY2l0eT0iMC4wMyI+PGNpcmNsZSBjeD0iMzAiIGN5PSIzMCIgcj0iMiIvPjwvZz48L2c+PC9zdmc+')] opacity-50`}),(0,x.jsx)(m.div,{initial:{opacity:0,y:20,scale:.95},animate:{opacity:1,y:0,scale:1},transition:{duration:.5},className:`relative w-full max-w-md`,children:(0,x.jsxs)(`div`,{className:`bg-card rounded-2xl shadow-2xl border border-border/50 overflow-hidden`,children:[(0,x.jsxs)(`div`,{className:`bg-gradient-to-r from-secondary to-secondary/80 p-6 text-center`,children:[(0,x.jsx)(m.div,{initial:{scale:0},animate:{scale:1},transition:{delay:.2,type:`spring`},className:`w-16 h-16 rounded-full bg-white/20 backdrop-blur-sm flex items-center justify-center mx-auto mb-4`,children:P?(0,x.jsx)(_,{className:`w-8 h-8 text-white`}):(0,x.jsx)(p,{className:`w-8 h-8 text-white`})}),(0,x.jsx)(`h1`,{className:`text-2xl font-bold text-white`,children:P?`Crea Account`:`Accedi`}),(0,x.jsx)(`p`,{className:`text-white/80 text-sm mt-1`,children:T?`Crea un account per unirti a ${w}`:P?`Registrati per accedere al CRM`:`Accedi al tuo pannello di controllo`})]}),T&&(0,x.jsxs)(`div`,{className:`mx-6 mt-4 p-3 bg-secondary/10 border border-secondary/20 rounded-lg text-center`,children:[(0,x.jsxs)(`p`,{className:`text-sm text-foreground`,children:[`ð© Sei stato invitato a `,(0,x.jsx)(`strong`,{children:w})]}),(0,x.jsxs)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:[`Crea un account con l'email `,(0,x.jsx)(`strong`,{children:C}),` per accettare l'invito`]})]}),(0,x.jsxs)(`form`,{onSubmit:async e=>{if(e.preventDefault(),N(!0),P){let e=T?`${window.location.origin}${t}`:window.location.origin,{error:n}=await L(E,O,e);if(n){B({title:`Errore di registrazione`,description:n.message,variant:`destructive`}),N(!1);return}if(E.split(`@`)[1]?.toLowerCase()===`innovonline.it`&&!S&&!T){let{data:e,error:n}=await o.functions.invoke(`bootstrap-admin`);if(!n&&e?.becameAdmin){await o.auth.refreshSession(),B({title:`Account admin creato!`,description:`Sei stato registrato come primo amministratore.`}),V(t);return}}if(T){B({title:`Account creato â
`,description:`Conferma la tua email e poi completa l'accettazione dell'invito.`}),V(t);return}B({title:`Registrazione completata! ð`,description:`Benvenuto! Ora configura la tua azienda.`}),V(`/admin/organization/setup`);return}{let{error:e}=await I(E,O);if(e){B({title:`Errore di accesso`,description:e.message,variant:`destructive`}),N(!1);return}B({title:`Accesso effettuato`,description:`Benvenuto!`}),V(t)}},className:`p-6 space-y-5`,children:[(0,x.jsxs)(`div`,{className:`space-y-2`,children:[(0,x.jsx)(y,{htmlFor:`email`,className:`text-foreground`,children:`Email`}),(0,x.jsxs)(`div`,{className:`relative`,children:[(0,x.jsx)(h,{className:`absolute left-3 top-1/2 -translate-y-1/2 w-5 h-5 text-muted-foreground`}),(0,x.jsx)(v,{id:`email`,type:`email`,placeholder:`[email protected]`,value:E,onChange:e=>D(e.target.value),className:`pl-10`,required:!0,readOnly:T,tabIndex:T?-1:void 0})]})]}),(0,x.jsxs)(`div`,{className:`space-y-2`,children:[(0,x.jsx)(y,{htmlFor:`password`,className:`text-foreground`,children:`Password`}),(0,x.jsxs)(`div`,{className:`relative`,children:[(0,x.jsx)(f,{className:`absolute left-3 top-1/2 -translate-y-1/2 w-5 h-5 text-muted-foreground`}),(0,x.jsx)(v,{id:`password`,type:A?`text`:`password`,placeholder:`â¢â¢â¢â¢â¢â¢â¢â¢`,value:O,onChange:e=>k(e.target.value),className:`pl-10 pr-10`,required:!0,minLength:6}),(0,x.jsx)(`button`,{type:`button`,onClick:()=>j(!A),className:`absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground transition-colors`,children:A?(0,x.jsx)(u,{className:`w-5 h-5`}):(0,x.jsx)(d,{className:`w-5 h-5`})})]})]}),(0,x.jsx)(c,{type:`submit`,disabled:M,className:`w-full bg-secondary hover:bg-secondary/90 text-white font-semibold py-6 group`,children:M?(0,x.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,x.jsx)(`div`,{className:`w-5 h-5 border-2 border-white/30 border-t-white rounded-full animate-spin`}),P?`Registrazione...`:`Accesso...`]}):(0,x.jsxs)(`div`,{className:`flex items-center gap-2`,children:[P?`Registrati`:`Accedi`,(0,x.jsx)(l,{className:`w-5 h-5 group-hover:translate-x-1 transition-transform`})]})}),!n&&!T&&(0,x.jsx)(`div`,{className:`text-center pt-2`,children:(0,x.jsx)(`button`,{type:`button`,onClick:()=>F(!P),className:`text-sm text-muted-foreground hover:text-secondary transition-colors`,children:P?(0,x.jsxs)(x.Fragment,{children:[`Hai già un account? `,(0,x.jsx)(`span`,{className:`font-semibold`,children:`Accedi`})]}):(0,x.jsxs)(x.Fragment,{children:[`Primo accesso? `,(0,x.jsx)(`span`,{className:`font-semibold`,children:`Registrati`})]})})})]}),(0,x.jsx)(`div`,{className:`px-6 pb-6 text-center`,children:(0,x.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:P?`Dopo la registrazione potrai configurare la tua azienda`:`Accedi con le tue credenziali per gestire il CRM`})})]})})]})}var C=()=>(0,x.jsx)(S,{});export{C as component};
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.