PageSourceSearch

https://qpu-1.lovable.app/assets/Auth-CbKqRdaF.js

js qpu-1.lovable.app collected 2026-10-03 03:40:57 UTC 12,928 bytes, 6 lines download raw bytes

1import{c as Y,s as D,r as x,u as X,a as J,b as Z,j as e,P as ee,L as $,C as te,B as L,d as O,S as z,I as U,e as se,f as A,g as re}from"./index-DGdCDVGV.js";import{C as ae,a as ne,b as ie,c as oe,d as ce}from"./card-DzEUzuEG.js";import{S as le}from"./SEO-DW7PUNO7.js";import{s as h,o as P,a as de,l as ue}from"./schemas-c7xS3HeG.js";/**
2 * @license lucide-react v0.462.0 - ISC
3 *
4 * This source code is licensed under the ISC license.
5 * See the LICENSE file in the root directory of this source tree.
6 */const me=Y("UserRound",[["circle",{cx:"12",cy:"8",r:"5",key:"1hypcn"}],["path",{d:"M20 21a8 8 0 0 0-16 0",key:"rfgkzh"}]]);var he="authorization_response",pe="/~oauth/initiate",ge=["https://oauth.lovable.app","https://lovable.dev"],xe="lovable://oauth-callback",we="http://127.0.0.1/iframe-oauth/callback",fe=500,ve=12e4;function be(t){let s;const r=new Promise(l=>{s=l}),i=l=>{if(!t.some(g=>l.origin===g))return;const p=l.data;!p||typeof p!="object"||p.type===he&&s(p.response)},u=()=>{window.removeEventListener("message",i)};return window.addEventListener("message",i),{cleanup:u,messagePromise:r}}function je(t){const s=window.screenX!==0||window.screenY!==0||!t,r=s?window.outerWidth*.5:window.screen.width*.5,i=s?window.outerHeight*.5:window.screen.height*.5,u=s?window.screenX+(window.outerWidth-r)/2:(window.screen.width-r)/2,l=s?window.screenY+(window.outerHeight-i)/2:(window.screen.height-i)/2;return{width:r,height:i,left:u,top:l}}function V(t,s){return t.state!==s?{error:new Error("State is invalid")}:t.error?t.error==="legacy_flow"?{error:new Error("This flow is not supported in Preview mode. Please open the app in a new tab to sign in.")}:{error:new Error(t.error_description??"Sign in failed")}:!t.access_token||!t.refresh_token?{error:new Error("No tokens received")}:{tokens:{access_token:t.access_token,refresh_token:t.refresh_token},error:null}}function ye(){const t=navigator.userAgent;return!!(/iPhone|iPad|iPod|Android/i.test(t)||/Macintosh/i.test(t)&&navigator.maxTouchPoints>1)}function Ne(){return typeof crypto<"u"&&crypto.getRandomValues?[...crypto.getRandomValues(new Uint8Array(16))].map(t=>t.toString(16).padStart(2,"0")).join(""):Math.random().toString(36).substring(2)+Date.now().toString(36)}function Se(t={}){const s=t.oauthBrokerUrl??pe,r=t.supportedOAuthOrigins??ge;async function i(u,l={}){let d=!1;try{d=window.self!==window.top}catch{d=!0}const p=navigator.userAgent,g=/LovableApp\//.test(p),f=!g&&/lovable/i.test(p),w=Ne();let j=l.redirect_uri??window.location.origin;g&&d?j=xe:f&&d&&(j=we);const y=new URLSearchParams({...l.extraParams,provider:u,redirect_uri:j,state:w});if(!d)return window.location.href=`${s}?${y.toString()}`,{error:null,redirected:!0};!g&&!f&&y.set("response_mode","web_message");const S=`${s}?${y.toString()}`,_=f?[...r,window.location.origin]:r,{messagePromise:I,cleanup:E}=be(_);let m;if(ye())m=window.open(S,"_blank");else{const{width:a,height:v,left:o,top:N}=je(d);m=window.open(S,"oauth",`width=${a},height=${v},left=${o},top=${N}`)}if(!m&&(g||f)){let a;const v=new Promise((o,N)=>{a=setTimeout(()=>{N(new Error("OAuth timed out waiting for response"))},ve)});try{const o=await Promise.race([I,v]);return V(o,w)}catch(o){return{error:o instanceof Error?o:new Error(String(o))}}finally{a&&clearTimeout(a),E()}}if(!m)return E(),{error:new Error("Popup was blocked")};let C;const R=new Promise((a,v)=>{C=setInterval(()=>{m.closed&&(clearInterval(C),v(new Error("Sign in was cancelled")))},fe)});try{const a=await Promise.race([I,R]);return V(a,w)}catch(a){return{error:a instanceof Error?a:new Error(String(a))}}finally{clearInterval(C),E(),m==null||m.close()}}return{signInWithOAuth:i}}var _e={name:"@lovable.dev/cloud-auth-js",version:"1.1.1",description:"Lovable Cloud Auth JS",main:"./dist/index.cjs",module:"./dist/index.js",types:"./dist/index.d.ts",type:"module",files:["dist"],scripts:{build:"tsup src/index.ts --format cjs,esm --dts --outDir dist",dev:"tsup src/index.ts --format cjs,esm --dts --watch",test:"vitest run",typecheck:"tsgo --noEmit",prepublishOnly:"npm run clean && npm run build",clean:"rimraf dist"},keywords:["lovable","oauth","authentication"],license:"MIT",devDependencies:{"@types/node":"^22",jsdom:"^26",rimraf:"^5.0.0",tsup:"^7.2.0",typescript:"^5",vitest:"^4.1.0"}};typeof window<"u"&&(window.__lovable_cloud_auth_js_version=_e.version);function Ee(t={}){return Se(t)}const Ce=Ee(),ke={auth:{signInWithOAuth:async(t,s)=>{const r=await Ce.signInWithOAuth(t,{redirect_uri:s==null?void 0:s.redirect_uri,extraParams:{...s==null?void 0:s.extraParams}});if(r.redirected||r.error)return r;try{await D.auth.setSession(r.tokens)}catch(i){return{error:i instanceof Error?i:new Error(String(i))}}return r}}},M=h().trim().email("Invalid email").max(255),q=h().min(6,"At least 6 characters").max(128),G=h().trim().min(1,"Required").max(50),Ae=P({email:M,password:q}),Pe=P({email:M,password:q,displayName:G}),Ie=P({email:M});h().trim().min(1,"Title required").max(120);
6P({title:h().trim().min(5,"Title must be ≥5 chars").max(200),content:h().trim().min(10,"Content must be ≥10 chars").max(2e4),category:h().min(1),tags:de(h().trim().max(30)).max(8).optional()});P({display_name:G.optional(),bio:h().max(500).optional().nullable(),website:h().url("Invalid URL").max(200).optional().nullable().or(ue(""))});function Ue(){const[t,s]=x.useState("login"),[r,i]=x.useState(""),[u,l]=x.useState(""),[d,p]=x.useState(""),[g,f]=x.useState(!1),[w,j]=x.useState(null),[y,S]=x.useState(!1),[_,I]=x.useState(!1),{signIn:E,signUp:m,resetPassword:C,signInAsGuest:R}=X(),a=J(),[v]=Z(),o=v.get("next")??"",N=o.startsWith("/")&&!o.startsWith("//")?o:"",B=N||"/dashboard",Q=`${window.location.origin}${N||"/dashboard"}`,[c,T]=x.useState({}),K=async n=>{if(n.preventDefault(),T({}),t==="signup"&&!_){T({terms:"You must agree to the Terms of Service to create an account."});return}const H=(t==="login"?Ae:t==="signup"?Pe:Ie).safeParse({email:r,password:u,displayName:d});if(!H.success){const b={};H.error.issues.forEach(W=>{b[W.path[0]]=W.message}),T(b);return}f(!0);try{if(t==="login")await E(r,u),a(B);else if(t==="signup"){await m(r,u,d);try{const{data:{user:b}}=await D.auth.getUser();b&&await D.from("profiles").update({terms_accepted_at:new Date().toISOString(),terms_version:re}).eq("id",b.id)}catch{}A.success("Check your email to confirm your account!")}else await C(r),A.success("Password reset email sent!")}catch(b){A.error(b.message)}finally{f(!1)}},F=async n=>{j(n);try{const{error:k}=await ke.auth.signInWithOAuth(n,{redirect_uri:Q});if(k)throw k}catch(k){A.error(k.message||`Failed to sign in with ${n}`)}finally{j(null)}};return e.jsxs("main",{className:"flex min-h-screen items-center justify-center bg-background p-4 relative overflow-hidden",children:[e.jsx(le,{title:t==="login"?"Sign in":t==="signup"?"Create account":"Reset password",description:"Sign in to QuantumLab to run quantum circuits across multiple QPU backends."}),e.jsx("h1",{className:"sr-only",children:t==="login"?"Sign in to QuantumLab":t==="signup"?"Create your QuantumLab account":"Reset your QuantumLab password"}),e.jsx("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:e.jsx(ee,{variant:"auth"})}
6),e.jsxs("div",{className:"w-full max-w-md space-y-6 relative z-10 animate-fade-in",children:[e.jsx($,{to:"/",className:"flex items-center gap-2 text-muted-foreground hover:text-foreground transition-colors text-sm",children:"← Back to home"}),e.jsxs(ae,{className:"border border-border backdrop-blur-sm",children:[e.jsxs(ne,{className:"text-center pb-2",children:[e.jsx("div",{className:"mx-auto mb-3 h-14 w-14 rounded-xl bg-primary flex items-center justify-center",children:e.jsx(te,{className:"h-7 w-7 text-primary-foreground"})}),e.jsx(ie,{className:"text-2xl tracking-tight",children:t==="login"?"Welcome back":t==="signup"?"Create account":"Reset password"}),e.jsx(oe,{className:"text-xs",children:t==="login"?"Sign in to QuantumLab":t==="signup"?"Start running quantum circuits":"We'll send you a reset link"})]}),e.jsxs(ce,{className:"space-y-4",children:[t!=="reset"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs(L,{variant:"outline",className:"h-11",onClick:()=>F("google"),disabled:!!w,children:[w==="google"?e.jsx(O,{className:"h-4 w-4 animate-spin"}):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 0 1-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"})]}),"Google"]}),e.jsxs(L,{variant:"outline",className:"h-11",onClick:()=>F("apple"),disabled:!!w,children:[w==="apple"?e.jsx(O,{className:"h-4 w-4 animate-spin"}):e.jsx("svg",{className:"h-4 w-4 mr-2",viewBox:"0 0 24 24",fill:"currentColor",children:e.jsx("path",{d:"M17.05 20.28c-.98.95-2.05.88-3.08.4-1.09-.5-2.08-.48-3.24 0-1.44.62-2.2.44-3.06-.4C2.79 15.25 3.51 7.59 9.05 7.31c1.35.07 2.29.74 3.08.8 1.18-.24 2.31-.93 3.57-.84 1.51.12 2.65.72 3.4 1.8-3.12 1.87-2.38 5.98.48 7.13-.57 1.5-1.31 2.99-2.54 4.09zM12.03 7.25c-.15-2.23 1.66-4.07 3.74-4.25.29 2.58-2.34 4.5-3.74 4.25z"})}),"Apple"]})]}),e.jsxs("div",{className:"relative",children:[e.jsx(z,{}),e.jsx("span",{className:"absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 bg-card px-3 text-xs text-muted-foreground",children:"or"})]})]}),e.jsxs("form",{onSubmit:K,className:"space-y-3",children:[t==="signup"&&e.jsxs("div",{children:[e.jsx(U,{placeholder:"Display name",value:d,onChange:n=>p(n.target.value),className:"h-11","aria-invalid":!!c.displayName}),c.displayName&&e.jsx("p",{className:"text-[11px] text-destructive mt-1",children:c.displayName})]}),e.jsxs("div",{children:[e.jsx(U,{type:"email",placeholder:"Email",required:!0,value:r,onChange:n=>i(n.target.value),className:"h-11","aria-invalid":!!c.email}),c.email&&e.jsx("p",{className:"text-[11px] text-destructive mt-1",children:c.email})]}),t!=="reset"&&e.jsxs("div",{children:[e.jsx(U,{type:"password",placeholder:"Password",required:!0,minLength:6,value:u,onChange:n=>l(n.target.value),className:"h-11","aria-invalid":!!c.password}),c.password&&e.jsx("p",{className:"text-[11px] text-destructive mt-1",children:c.password})]}),t==="signup"&&e.jsxs("div",{children:[e.jsxs("label",{className:"flex items-start gap-2 text-xs text-muted-foreground leading-relaxed",children:[e.jsx(se,{checked:_,onCheckedChange:n=>I(n===!0),className:"mt-0.5","aria-invalid":!!c.terms}),e.jsxs("span",{children:["I agree to the"," ",e.jsx($,{to:"/terms",target:"_blank",className:"text-primary hover:underline",children:"Terms of Service"}),". Credits are non-refundable except for genuine platform errors."]})]}),c.terms&&e.jsx("p",{className:"text-[11px] text-destructive mt-1",children:c.terms})]}),e.jsx(L,{type:"submit",className:"w-full h-11 glow-sm",disabled:g||t==="signup"&&!_,children:g?e.jsx(O,{className:"h-4 w-4 animate-spin"}):t==="login"?"Sign In":t==="signup"?"Create Account":"Send Reset Link"})]}),t==="login"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"relative",children:[e.jsx(z,{}),e.jsx("span",{className:"absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 bg-card px-3 text-xs text-muted-foreground",children:"or"})]}),e.jsxs(L,{variant:"outline",className:"w-full h-11",onClick:async()=>{S(!0);try{await R(),a(B)}catch(n){A.error(n.message)}finally{S(!1)}},disabled:y,children:[y?e.jsx(O,{className:"h-4 w-4 animate-spin mr-2"}):e.jsx(me,{className:"h-4 w-4 mr-2"}),"Continue as Guest"]}),e.jsx("p",{className:"text-[10px] text-center text-muted-foreground",children:"Guest accounts have limited access (500 qubits/job, 10 jobs/day)"})]}),e.jsxs("div",{className:"text-center text-sm text-muted-foreground space-y-1 pt-2",children:[t==="login"&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>s("reset"),className:"text-primary hover:underline block mx-auto text-xs",children:"Forgot password?"}),e.jsxs("p",{className:"text-xs",children:["Don't have an account? ",e.jsx("button",{onClick:()=>s("signup"),className:"text-primary hover:underline",children:"Sign up"})]})]}),t==="signup"&&e.jsxs("p",{className:"text-xs",children:["Already have an account? ",e.jsx("button",{onClick:()=>s("login"),className:"text-primary hover:underline",children:"Sign in"})]}),t==="reset"&&e.jsx("button",{onClick:()=>s("login"),className:"text-primary hover:underline text-xs",children:"Back to sign in"})]})]})]})]})]})}export{Ue 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.