1import{j as e}from"./jsx-runtime-CuP2xq57.js";import{x as E,r as c,q as C}from"./chunk-JZWAC4HX-DvFdmerS.js";import{u as A}from"./index.esm-BDUO7J7-.js";import{x as P,b as h,G as k,y as F,d as I,g as D,T as M,n as q,u as G,a as L}from"./firebase-YQaWUxJx.js";import{E as z}from"./eye-off-NmLd-LgN.js";import{E as B}from"./eye-yvQ8winu.js";import"./createLucideIcon-C9NiWNpo.js";function R(){const m=E(),[l,o]=c.useState(!1),[u,r]=c.useState(null),[n,y]=c.useState(!1),{register:p,handleSubmit:g,formState:{errors:t}}=A(),f=async a=>{o(!0),r(null);try{await P(h,a.email,a.password),m("/dashboard")}catch(s){console.error("Login error:",s),s.code==="auth/invalid-credential"?r("Invalid email or password"):s.code==="auth/too-many-requests"?r("Too many failed attempts. Please try again later."):r("Failed to sign in. Please try again.")}finally{o(!1)}},b=["getamplifiedmkg.com","codeshock.dev"],w=a=>{const s=a.split("@")[1]?.toLowerCase();return b.includes(s)},j=async(a,s,N)=>{const d=I(L,"users",a),x=await D(d),i=w(s);if(x.exists())i&&x.data()?.role!=="admin"&&await G(d,{role:"admin",plan:"admin",accountStatus:"active"});else{const S=M.now();await q(d,{email:s,displayName:N,companyName:"",createdAt:S,plan:i?"admin":"pending",role:i?"admin":"user",accountStatus:i?"active":"pending_payment"})}},v=async()=>{o(!0),r(null);try{const a=new k,s=await F(h,a);await j(s.user.uid,s.user.email||"",s.user.displayName||"User"),m("/dashboard")}catch(a){console.error("Google sign in error:",a),a.code==="auth/popup-closed-by-user"||r("Failed to sign in with Google. Please try again.")}finally{o(!1)}};return e.jsxs("div",{className:"space-y-6",children:[u&&e.jsx("div",{className:"p-3 bg-red-50 border border-red-200 text-red-700 rounded-lg text-sm",children:u}),e.jsxs("form",{onSubmit:g(f),className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"email",className:"block text-sm font-medium text-gray-700 mb-1",children:"Email"}),e.jsx("input",{id:"email",type:"email",autoComplete:"email",className:`w-full px-4 py-2.5 rounded-xl border ${t.email?"border-red-500 focus:ring-red-200":"border-gray-300 focus:border-cyan-500 focus:ring-cyan-200"} focus:outline-none focus:ring-2 transition-all text-gray-900 placeholder-gray-400`,placeholder:"[email protected]",...p("email",{required:"Email is required",pattern:{value:/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i,message:"Invalid email address"}})}),t.email&&e.jsx("p",{className:"mt-1 text-sm text-red-600",children:t.email.message})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("label",{htmlFor:"password",className:"block text-sm font-medium text-gray-700",children:"Password"}),e.jsx(C,{to:"/forgot-password",className:"text-sm text-cyan-600 hover:underline",children:"Forgot password?"})]}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{id:"password",type:n?"text":"password",autoComplete:"current-password",className:`w-full px-4 py-2.5 pr-10 rounded-xl border ${t.password?"border-red-500 focus:ring-red-200":"border-gray-300 focus:border-cyan-500 focus:ring-cyan-200"} focus:outline-none focus:ring-2 transition-all text-gray-900 placeholder-gray-400`,placeholder:"Enter your password",...p("password",{required:"Password is required"})}),e.jsx("button",{type:"button",onClick:()=>y(!n),className:"absolute right-3 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600",tabIndex:-1,children:n?e.jsx(z,{className:"w-5 h-5"}):e.jsx(B,{className:"w-5 h-5"})})]}),t.password&&e.jsx("p",{className:"mt-1 text-sm text-red-600",children:t.password.message})]}),e.jsx("button",{type:"submit",disabled:l,className:"w-full bg-cyan-500 text-white py-3 rounded-full text-sm font-bold hover:bg-cyan-600 transition-all active:scale-[0.98] shadow-lg shadow-cyan-500/25 disabled:opacity-50 disabled:cursor-not-allowed",children:l?e.jsxs("span",{className:"flex items-center justify-center gap-2",children:[e.jsxs("svg",{className:"animate-spin h-4 w-4",viewBox:"0 0 24 24",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4",fill:"none"}),e.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),"Signing in..."]}):"Sign in"})]}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("div",{className:"w-full border-t border-gray-200"})}),e.jsx("div",{className:"relative flex justify-center text-sm",children:e.jsx("span",{className:"px-2 bg-white text-gray-400",children:"Or continue with"})})]}),e.jsxs("button",{type:"button",onClick:v,disabled:l,className:"w-full inline-flex items-center justify-center gap-2 px-4 py-2.5 rounded-full border-2 border-gray-200 text-gray-700 font-medium hover:border-cyan-500 hover:text-cyan-600 transition-all disabled:opacity-50 disabled:cursor-not-allowed",children:[e.jsxs("svg",{className:"w-5 h-5",viewBox:"0 0 24 24",children:[e.jsx("path",{fill:"#4285F4",d:"M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z"}),e.jsx("path",{fill:"#34A853",d:"M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z"}),e.jsx("path",{fill:"#FBBC05",d:"M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z"}),e.jsx("path",{fill:"#EA4335",d:"M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z"})]}),"Google"]})]})}export{R 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.