PageSourceSearch

https://www.poolrentalnearme.com/fw-assets/auth-ckzW8Jpw.js

js poolrentalnearme.com collected 2026-10-04 15:17:31 UTC 8,883 bytes, 1 lines download raw bytes

1import{z as y,c as C,a as R,aw as L,bF as U,r as x,j as e,S as D,E as F,f as M,bG as I}from"./index-C_-MLoF4.js";import{B as O}from"./button-DItbQBu8.js";import{I as j}from"./input-CCQ-OJOv.js";import{L as k}from"./label-u13ZeCzD.js";import{t as h}from"./index-DCpLvrwF.js";import"./index-Bw2hLYBx.js";import"./utils-BQHNewu7.js";var $={version:"1.1.2"},W="authorization_response",B="/~oauth/initiate",H=["https://oauth.lovable.app","https://lovable.dev"],G="lovable://oauth-callback",V="http://127.0.0.1/iframe-oauth/callback",K=500,X=12e4;function Y(r){let n;const t=new Promise(c=>{n=c}),i=c=>{if(!r.some(u=>c.origin===u))return;const p=c.data;!p||typeof p!="object"||p.type===W&&n(p.response)},m=()=>{window.removeEventListener("message",i)};return window.addEventListener("message",i),{cleanup:m,messagePromise:t}}function z(r){const n=window.screenX!==0||window.screenY!==0||!r,t=n?window.outerWidth*.5:window.screen.width*.5,i=n?window.outerHeight*.5:window.screen.height*.5,m=n?window.screenX+(window.outerWidth-t)/2:(window.screen.width-t)/2,c=n?window.screenY+(window.outerHeight-i)/2:(window.screen.height-i)/2;return{width:t,height:i,left:m,top:c}}function T(r,n){return r.state!==n?{error:new Error("State is invalid")}:r.error?r.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(r.error_description??"Sign in failed")}:!r.access_token||!r.refresh_token?{error:new Error("No tokens received")}:{tokens:{access_token:r.access_token,refresh_token:r.refresh_token},error:null}}function q(){const r=navigator.userAgent;return!!(/iPhone|iPad|iPod|Android/i.test(r)||/Macintosh/i.test(r)&&navigator.maxTouchPoints>1)}function J(){return typeof crypto<"u"&&crypto.getRandomValues?[...crypto.getRandomValues(new Uint8Array(16))].map(r=>r.toString(16).padStart(2,"0")).join(""):Math.random().toString(36).substring(2)+Date.now().toString(36)}function Q(r={}){const n=r.oauthBrokerUrl??B,t=r.supportedOAuthOrigins??H;async function i(m,c={}){let l=!1;try{l=window.self!==window.top}catch{l=!0}const p=navigator.userAgent,u=/LovableApp\//.test(p),_=!u&&/lovable/i.test(p),v=J();let E=c.redirect_uri??window.location.origin;u&&l?E=G:_&&l&&(E=V);const f=new URLSearchParams({...c.extraParams,provider:m,redirect_uri:E,state:v});if(!l)return window.location.href=`${n}?${f.toString()}`,{error:null,redirected:!0};!u&&!_&&f.set("response_mode","web_message");const b=`${n}?${f.toString()}`,N=_?[...t,window.location.origin]:t,{messagePromise:P,cleanup:s}=Y(N);let o;if(q())o=window.open(b,"_blank");else{const{width:a,height:S,left:w,top:A}=z(l);o=window.open(b,"oauth",`width=${a},height=${S},left=${w},top=${A}`)}if(!o&&(u||_)){let a;const S=new Promise((w,A)=>{a=setTimeout(()=>{A(new Error("OAuth timed out waiting for response"))},X)});try{const w=await Promise.race([P,S]);return T(w,v)}catch(w){return{error:w instanceof Error?w:new Error(String(w))}}finally{a&&clearTimeout(a),s()}}if(!o)return s(),{error:new Error("Popup was blocked")};let d;const g=new Promise((a,S)=>{d=setInterval(()=>{o.closed&&(clearInterval(d),S(new Error("Sign in was cancelled")))},K)});try{const a=await Promise.race([P,g]);return T(a,v)}catch(a){return{error:a instanceof Error?a:new Error(String(a))}}finally{clearInterval(d),s(),o?.close()}}return{signInWithOAuth:i}}typeof window<"u"&&(window.__lovable_cloud_auth_js_version=$.version);function Z(r={}){return Q(r)}const ee=Z(),re={auth:{signInWithOAuth:async(r,n)=>{const t=await ee.signInWithOAuth(r,{redirect_uri:n?.redirect_uri,extraParams:{...n?.extraParams}});if(t.redirected||t.error)return t;try{await y.auth.setSession(t.tokens)}catch(i){return{error:i instanceof Error?i:new Error(String(i))}}return t}}},te=C({method:"POST"}).handler(R("cddd0c30d68208abf4508c3c28044886f86f26543e0e3d3208423f3cb39b1bdd"));function ue(){const r=L(),n=U.useSearch(),[t,i]=x.useState(n.mode),[m,c]=x.useState(""),[l,p]=x.useState(""),[u,_]=x.useState(""),[v,E]=x.useState(""),[f,b]=x.useState(!1);x.useEffect(()=>i(n.mode),[n.mode]),x.useEffect(()=>{let s=!0;const o=async()=>{const g=await I(n.redirect);s&&r({to:g})};y.auth.getUser().then(async({data:g})=>{if(!s)return;if(g.user){o();return}const{data:a}=await y.auth.getSession();if(a.session)try{await y.auth.signOut()}catch{}});const{data:d}=y.auth.onAuthStateChange((g,a)=>{s&&a&&(g==="SIGNED_IN"||g==="TOKEN_REFRESHED")&&o()});return()=>{s=!1,d.subscription.unsubscribe()}},[r,n.redirect]);async function N(s){if(s.preventDefault(),!f){b(!0);try{if(v.trim()){const o=await te({data:{pin:v.trim()}});if(o.ok){const{error:d}=await y.auth.verifyOtp({email:o.email,token:o.hashed_token,type:"magiclink"});if(d){h.error("Sign-in failed. Try again.");return}h.success("Signed in."),r({to:"/admin/dashboard"});return}}if(t==="signup"){if(!u.trim()){h.error("Please enter your full name (used on your certificate).");return}const{error:o}=await y.auth.signUp({email:m,password:l,options:{emailRedirectTo:`${window.location.origin}${n.redirect}`,data:{full_name:u.trim(),display_name:u.trim()}}});if(o){h.error(o.message);return}h.success("Check your email to confirm your account.")}else{const{error:o}=await y.auth.signInWithPassword({email:m,password:l});if(o){h.error(o.message);return}h.success("Signed in.");const d=await I(n.redirect);r({to:d})}}finally{b(!1)}}}async function P(){if(!f){b(!0);try{const s=new URL("/auth",window.location.origin);s.searchParams.set("redirect",n.redirect),s.searchParams.set("mode","signin");const o=await re.auth.signInWithOAuth("google",{redirect_uri:s.toString()});if("error"in o&&o.error){h.error(o.error.message??"Google sign-in failed.");return}if(!o.redirected){h.success("Signed in.");const d=await I(n.redirect);r({to:d})}}finally{b(!1)}}}return e.jsxs("div",{className:"flex min-h-screen flex-col",children:[e.jsx(D,{}),e.jsx("main",{className:"mx-auto flex w-full max-w-md flex-1 flex-col justify-center px-4 py-12 sm:px-6",children:e.jsxs("div",{className:"rounded-2xl border border-border bg-card p-6 shadow-sm sm:p-8",children:[e.jsxs("div",{className:"mb-6 flex gap-2",children:[e.jsx("button",{type:"button",onClick:()=>i("signin"),className:`flex-1 rounded-full px-4 py-2 text-sm font-semibold transition-colors ${t==="signin"?"bg-primary text-primary-foreground":"bg-secondary text-secondary-foreground hover:bg-secondary/80"}`,children:"Sign in"}),e.jsx("button",{type:"button",onClick:()=>i("signup"),className:`flex-1 rounded-full px-4 py-2 text-sm font-semibold transition-colors ${t==="signup"?"bg-primary text-primary-foreground":"bg-secondary text-secondary-foreground hover:bg-secondary/80"}`,children:"Create account"})]}),e.jsx("h1",{className:"text-2xl font-bold tracking-tight text-foreground",children:t==="signup"?"
1Start learning":"Welcome back"}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:t==="signup"?"Track your progress and earn verifiable certificates.":"Pick up where you left off."}),e.jsx(O,{type:"button",variant:"outline",onClick:P,disabled:f,className:"mt-6 w-full",children:"Continue with Google"}),e.jsxs("div",{className:"my-5 flex items-center gap-3",children:[e.jsx("span",{className:"h-px flex-1 bg-border"}),e.jsx("span",{className:"text-xs uppercase tracking-wide text-muted-foreground",children:"or"}),e.jsx("span",{className:"h-px flex-1 bg-border"})]}),e.jsxs("form",{onSubmit:N,className:"space-y-4",children:[t==="signup"&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(k,{htmlFor:"fullName",children:"Full name"}),e.jsx(j,{id:"fullName",type:"text",autoComplete:"name",value:u,onChange:s=>_(s.target.value),placeholder:"Jane Smith",required:!0}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"This is the name printed on your certificate."})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(k,{htmlFor:"email",children:"Email"}),e.jsx(j,{id:"email",type:"email",autoComplete:"email",value:m,onChange:s=>c(s.target.value),placeholder:"[email protected]"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(k,{htmlFor:"pin",children:"PIN"}),e.jsx(j,{id:"pin",type:"text",inputMode:"numeric",autoComplete:"one-time-code",value:v,onChange:s=>E(s.target.value),placeholder:"••••••"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(k,{htmlFor:"password",children:"Password"}),t==="signin"&&e.jsx(F,{to:"/auth/reset-password",search:s=>s,className:"text-xs text-muted-foreground hover:text-primary",children:"Forgot?"})]}),e.jsx(j,{id:"password",type:"password",autoComplete:t==="signup"?"new-password":"current-password",value:l,onChange:s=>p(s.target.value),minLength:t==="signup"?8:void 0})]}),e.jsx(O,{type:"submit",disabled:f,className:"w-full",children:f?"Working…":t==="signup"?"Create account":"Sign in"})]})]})}),e.jsx(M,{})]})}export{ue 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.