import{a as R}from"/build/_shared/chunk-3HCBGCGM.js";import{a as v,b as h}from"/build/_shared/chunk-QTXW5A25.js";import{a as g}from"/build/_shared/chunk-JWVFBRIV.js";import{a as V}from"/build/_shared/chunk-32YOKIWQ.js";import"/build/_shared/chunk-HTTIUZX4.js";import{x as t}from"/build/_shared/chunk-J57633IL.js";import{a as O}from"/build/_shared/chunk-YCZ72ESF.js";import"/build/_shared/chunk-FCFTNN44.js";import"/build/_shared/chunk-N2QZPEPI.js";import{A as C,a as w,d as u,g as m,w as p}from"/build/_shared/chunk-IYEHZB2Y.js";import{b as N,d as o}from"/build/_shared/chunk-4AMCPB2Y.js";var c=N((G,y)=>{y.exports={}});var S=o(O(),1);var n=o(w(),1);var r={USER_CODE_RECEIVED:"USER_CODE_RECEIVED",AUTH_RESOLVED:"AUTH_RESOLVED",AUTH_REJECTED:"AUTH_REJECTED"};var I=o(c(),1),J=o(V(),1);var b=o(c(),1);var k=t.object({type:t.literal(r.USER_CODE_RECEIVED),code:t.string(),url:t.string()}),F=t.object({type:t.literal(r.AUTH_RESOLVED)}),H=t.object({type:t.literal(r.AUTH_REJECTED),error:t.string().optional().default("Unknown error")}),x=t.union([k,F,H]);var e=o(C(),1);function D(){let a=p(),[_,T]=(0,n.useState)(!1),[E,U]=(0,n.useState)(null),[s,A]=(0,n.useState)(null),d=u(),f=m(),l=R("/login-sse");return(0,n.useEffect)(()=>{if(!l)return;let L=JSON.parse(l),i=x.safeParse(L);if(!i.success){console.error(i.error.flatten());return}switch(i.data.type){case r.USER_CODE_RECEIVED:{A(i.data);break}case r.AUTH_RESOLVED:{f.revalidate(),d("/");break}case r.AUTH_REJECTED:{U(i.data.error);break}}},[l,d,f]),(0,e.jsx)("main",{className:"flex h-full w-full flex-grow flex-col items-center justify-center p-10 text-center",children:(0,e.jsxs)("div",{className:"flex flex-col items-center",children:[(0,e.jsx)(j,{className:"h-16 w-16"}),(0,e.jsx)("h1",{className:"pt-5 text-2xl font-semibold md:text-3xl",children:"Authenticate with EpicWeb.dev"}),(0,e.jsx)("h2",{className:"max-w-sm pt-3 text-base text-gray-700 dark:text-gray-300",children:"If you have purchased Epic Web, you'll be able to watch videos, track progress, and more!"}),(0,e.jsxs)("div",{className:"flex w-full flex-col items-center pt-5",children:[s?(0,e.jsxs)("div",{className:"flex w-full flex-col items-center gap-3",children:[(0,e.jsxs)("div",{className:"my-2 flex w-full flex-col items-center gap-2",children:[(0,e.jsx)("p",{className:"text-lg",children:"Your verification code is: "}),(0,e.jsx)("div",{className:"mb-3 w-full bg-gray-100 px-5 py-3 text-lg font-bold dark:bg-black/40",children:(0,e.jsx)("code",{children:s.code})})]}),(0,e.jsx)(h,{varient:"primary",to:s.url,target:"_blank",rel:"noreferrer",onClick:()=>T(!0),children:"Continue"}),_?(0,e.jsx)("div",{className:"pt-5 opacity-60",children:(0,e.jsx)(g,{children:"Waiting for confirmation"})}):null]}):(0,e.jsx)(a.Form,{method:"POST",children:(0,e.jsx)(v,{varient:"primary",type:"submit",children:a.state==="idle"&&a.data?.status!=="pending"?"Retrieve Code":"Retrieving Code..."})}),E?(0,e.jsxs)("div",{className:"mt-4 text-red-500",children:["There was an error: ",(0,e.jsx)("pre",{children:E})]}):null]})]})})}var j=({className:a=""})=>(0,e.jsxs)("svg",{className:a,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[(0,e.jsx)("path",{d:"M12.438 11.5677C12.0131 11.8026 11.5249 12.0534 10.9784 12.3047C8.80704 13.3031 5.70429 14.314 1.986 14.3555L1.55773 14.3603L1.48003 13.9391C1.36509 13.316 1.29793 12.6714 1.29793 12.006C1.29793 6.10441 6.09863 1.30372 12.0002 1.30372C13.6287 1.30372 15.1745 1.66961 16.5585 2.32369L17.9801 1.59897C16.2189 0.582162 14.1769 0 12.0002 0C5.38709 0 0 5.38709 0 12.0002C0 14.6402 0.858474 17.0847 2.31072 19.0692C4.79741 18.6457 6.35749 17.6495 6.35749 17.6495C6.35749 17.6495 5.36137 19.2075 4.93785 21.6946C6.92114 23.1439 9.36321 24.0005 12.0002 24.0005C18.6134 24.0005 24.0005 18.6134 24.0005 12.0002C24.0005 9.82732 23.4199 7.78762 22.4053 6.02738L21.6818 7.44613C22.3364 8.83057 22.7025 10.3769 22.7025 12.006C22.7025 17.9076 17.9018 22.7083 12.0002 22.7083C11.3345 22.7083 10.6959 22.6411 10.0681 22.5264L9.646 22.4493L9.65079 22.0203C9.6923 18.2991 10.7031 15.1964 11.7016 13.0257C11.9527 12.4797 12.2033 11.9921 12.438 11.5677Z",fill:"url(#epicGradient)"}),(0,e.jsx)("path",{d:"M18.2525 9.31052L15.4992 8.50683L14.6953 5.74778L23.8291 0.171387L18.2525 9.31052Z",fill:"currentColor"}),(0,e.jsx)("defs",{children:(0,e.jsxs)("linearGradient",{id:"epicGradient",x1:"16.9703",y1:"7.03022",x2:"7.05798",y2:"16.948",gradientUnits:"userSpaceOnUse",children:[(0,e.jsx)("stop",{stopColor:"#4F75FF"}),(0,e.jsx)("stop",{offset:"1",stopColor:"#30AFFF"})]})})]});export{D as default};
//# sourceMappingURL=/build/routes/_app+/login-UY5BEOCD.js.map
