1import{q as T,s as i,j as e,B as y}from"./index-D_Axm8F4.js";import{r as t}from"./vendor-recharts-PDzeV0Q9.js";import{I as b}from"./input-D4Q-4fL_.js";import{L as v}from"./label-DEqjoNPz.js";import{S as N}from"./SEO-aMTZ9ECZ.js";import{C as M}from"./circle-check-big-DC02wcCP.js";import{C as A}from"./circle-alert-Bc8pwbSd.js";import{E as B}from"./eye-off-8nvNGYFq.js";import{E as I}from"./eye-CRC60SE3.js";import{L as E}from"./loader-circle-tRkch_ee.js";const K=()=>{const[x,S]=t.useState(""),[u,C]=t.useState(""),[l,k]=t.useState(!1),[h,p]=t.useState(!1),[f,g]=t.useState(null),[r,c]=t.useState("form"),[w,o]=t.useState(""),[d,L]=t.useState(5);T(),t.useEffect(()=>{if(r!=="success")return;if(d<=0){window.close();return}const s=setTimeout(()=>L(a=>a-1),1e3);return()=>clearTimeout(s)},[r,d]),t.useEffect(()=>{(async()=>{const{data:{session:n}}=await i.auth.getSession();n&&j(n.access_token,n.refresh_token)})();const{data:{subscription:a}}=i.auth.onAuthStateChange((n,m)=>{m&&j(m.access_token,m.refresh_token)});return()=>a.unsubscribe()},[]);const j=(s,a)=>{window.postMessage({type:"POPIFY_AUTH_TOKEN",payload:{access_token:s,refresh_token:a}},window.location.origin),c("success")},P=async s=>{s.preventDefault(),p(!0),o("");try{const{error:a}=await i.auth.signInWithPassword({email:x,password:u});a&&(o(a.message),c("error"))}catch{o("An unexpected error occurred. Please try again."),c("error")}finally{p(!1)}},_=async()=>{g("google");try{const{error:s}=await i.auth.signInWithOAuth({provider:"google",options:{redirectTo:window.location.href}});if(s)throw s}catch(s){o(s.message||"Google sign-in failed. Please try again."),g(null)}};return r==="success"?e.jsxs("div",{className:"min-h-screen flex items-center justify-center bg-gray-50",children:[e.jsx(N,{title:"Logged In - Popify Extension",canonical:"/auth/extension-login",noindex:!0}),e.jsxs("div",{className:"max-w-sm w-full p-8 text-center",children:[e.jsx(M,{className:"h-16 w-16 text-green-500 mx-auto mb-4"}),e.jsx("h1",{className:"text-2xl font-bold mb-2",children:"Logged in!"}),e.jsxs("p",{className:"text-gray-600 mb-4",children:["This window will close in ",d,"s"]}),e.jsxs("div",{className:"bg-purple-50 border border-purple-200 rounded-lg p-4 text-sm text-purple-800",children:[e.jsx("p",{className:"font-semibold mb-1",children:"Next step:"}),e.jsx("p",{children:"Refresh any open application forms for Popify auto-fill to appear."})]})]})]}):e.jsxs("div",{className:"min-h-screen flex items-center justify-center bg-gray-50",children:[e.jsx(N,{title:"Log in to Popify Extension",description:"Sign in to your Popify account to use the Chrome extension for auto-filling market applications.",canonical:"/auth/extension-login",noindex:!0}),e.jsxs("div",{className:"max-w-sm w-full bg-white rounded-xl shadow-lg p-8",children:[e.jsxs("div",{className:"text-center mb-6",children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-900",children:"Popify"}),e.jsx("p",{className:"text-gray-500 mt-1",children:"Log in to Popify Extension"})]}),r==="error"&&w&&e.jsxs("div",{className:"flex items-center gap-2 p-3 mb-4 bg-red-50 text-red-700 rounded-lg text-sm",children:[e.jsx(A,{className:"h-4 w-4 flex-shrink-0"}),e.jsx("span",{children:w})]}),e.jsxs("form",{onSubmit:P,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(v,{htmlFor:"email",children:"Email"}),e.jsx(b,{id:"email",type:"email",value:x,onChange:s=>S(s.target.value),placeholder:"[email protected]",required:!0})]}),e.jsxs("div",{children:[e.jsx(v,{htmlFor:"password",children:"Password"}),e.jsxs("div",{className:"relative",children:[e.jsx(b,{id:"password",type:l?"text":"password",value:u,onChange:s=>C(s.target.value),placeholder:"Your password",required:!0}),e.jsx("button",{type:"button",onClick:()=>k(!l),onMouseDown:s=>s.preventDefault(),className:"absolute right-3 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600",children:l?e.jsx(B,{className:"h-4 w-4"}):e.jsx(I,{className:"h-4 w-4"})})]})]}),e.jsxs(y,{type:"submit",className:"w-full bg-purple-600 hover:bg-purple-700 text-white",disabled:h,children:[h?e.jsx(E,{className:"h-4 w-4 animate-spin mr-2"}):null,"Log in"]})]}),e.jsxs("div",{className:"relative my-4",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:"bg-white px-2 text-gray-500",children:"or"})})]}),e.jsxs(y,{variant:"outline",className:"w-full",onClick:_,disabled:!!f,children:[f==="google"?e.jsx(E,{className:"h-4 w-4 animate-spin mr-2"}):e.jsxs("svg",{className:"h-4 w-4 mr-2",viewBox:"0 0 24 24",children:[e.jsx("path",{d:"M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92a5.06 5.06 0 01-2.2 3.32v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.1z",fill:"#4285F4"}),e.jsx("path",{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",fill:"#34A853"}),e.jsx("path",{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",fill:"#FBBC05"}),e.jsx("path",{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",fill:"#EA4335"})]}),"Continue with Google"]}),e.jsxs("p",{className:"text-center text-sm text-gray-500 mt-6",children:["Don't have an account?"," ",e.jsx("a",{href:"https://popify.world",className:"text-purple-600 hover:underline",target:"_blank",rel:"noopener noreferrer",children:"Sign up at popify.world"})]})]})]})};export{K 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.