PageSourceSearch

https://panaceameetsyourkneads.com/assets/auth-t77qduGd.js

js panaceameetsyourkneads.com collected 2026-10-07 23:18:14 UTC 7,652 bytes, 1 lines download raw bytes

1import{s as E,u as N,r as g,j as e,L as k}from"./index-nv3c_Bci.js";var I={version:"1.1.2"},O="authorization_response",T="/~oauth/initiate",C=["https://oauth.lovable.app","https://lovable.dev"],L="lovable://oauth-callback",R="http://127.0.0.1/iframe-oauth/callback",U=500,D=12e4;function M(t){let r;const n=new Promise(i=>{r=i}),s=i=>{if(!t.some(d=>i.origin===d))return;const c=i.data;!c||typeof c!="object"||c.type===O&&r(c.response)},f=()=>{window.removeEventListener("message",s)};return window.addEventListener("message",s),{cleanup:f,messagePromise:n}}function B(t){const r=window.screenX!==0||window.screenY!==0||!t,n=r?window.outerWidth*.5:window.screen.width*.5,s=r?window.outerHeight*.5:window.screen.height*.5,f=r?window.screenX+(window.outerWidth-n)/2:(window.screen.width-n)/2,i=r?window.screenY+(window.outerHeight-s)/2:(window.screen.height-s)/2;return{width:n,height:s,left:f,top:i}}function A(t,r){return t.state!==r?{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 F(){const t=navigator.userAgent;return!!(/iPhone|iPad|iPod|Android/i.test(t)||/Macintosh/i.test(t)&&navigator.maxTouchPoints>1)}function H(){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 V(t={}){const r=t.oauthBrokerUrl??T,n=t.supportedOAuthOrigins??C;async function s(f,i={}){let u=!1;try{u=window.self!==window.top}catch{u=!0}const c=navigator.userAgent,d=/LovableApp\//.test(c),p=!d&&/lovable/i.test(c),m=H();let x=i.redirect_uri??window.location.origin;d&&u?x=L:p&&u&&(x=R);const v=new URLSearchParams({...i.extraParams,provider:f,redirect_uri:x,state:m});if(!u)return window.location.href=`${r}?${v.toString()}`,{error:null,redirected:!0};!d&&!p&&v.set("response_mode","web_message");const _=`${r}?${v.toString()}`,y=p?[...n,window.location.origin]:n,{messagePromise:o,cleanup:l}=M(y);let h;if(F())h=window.open(_,"_blank");else{const{width:a,height:b,left:w,top:j}=B(u);h=window.open(_,"oauth",`width=${a},height=${b},left=${w},top=${j}`)}if(!h&&(d||p)){let a;const b=new Promise((w,j)=>{a=setTimeout(()=>{j(new Error("OAuth timed out waiting for response"))},D)});try{const w=await Promise.race([o,b]);return A(w,m)}catch(w){return{error:w instanceof Error?w:new Error(String(w))}}finally{a&&clearTimeout(a),l()}}if(!h)return l(),{error:new Error("Popup was blocked")};let P;const S=new Promise((a,b)=>{P=setInterval(()=>{h.closed&&(clearInterval(P),b(new Error("Sign in was cancelled")))},U)});try{const a=await Promise.race([o,S]);return A(a,m)}catch(a){return{error:a instanceof Error?a:new Error(String(a))}}finally{clearInterval(P),l(),h?.close()}}return{signInWithOAuth:s}}typeof window<"u"&&(window.__lovable_cloud_auth_js_version=I.version);function W(t={}){return V(t)}const $=W(),z={auth:{signInWithOAuth:async(t,r)=>{const n=await $.signInWithOAuth(t,{redirect_uri:r?.redirect_uri,extraParams:{...r?.extraParams}});if(n.redirected||n.error)return n;try{await E.auth.setSession(n.tokens)}catch(s){return{error:s instanceof Error?s:new Error(String(s))}}return n}}};function K(){const t=N(),[r,n]=g.useState("signin"),[s,f]=g.useState(""),[i,u]=g.useState(""),[c,d]=g.useState(!1),[p,m]=g.useState(null),[x,v]=g.useState(null);g.useEffect(()=>{E.auth.getSession().then(({data:o})=>{o.session&&t({to:"/admin"})})},[t]);async function _(o){o.preventDefault(),d(!0),m(null),v(null);try{if(r==="signin"){const{error:l}=await E.auth.signInWithPassword({email:s,password:i});if(l)throw l;t({to:"/admin"})}else{const{data:l,error:h}=await E.auth.signUp({email:s,password:i,options:{emailRedirectTo:window.location.origin+"/admin"}});if(h)throw h;l.session?t({to:"/admin"}):v("Check your email to confirm your account.")}}catch(l){m(l?.message??"Sign in failed")}finally{d(!1)}}async function y(){m(null);const o=await z.auth.signInWithOAuth("google",{redirect_uri:window.location.origin+"/auth"});if(o.error){m(o.error.message||"Google sign-in failed");return}o.redirected||t({to:"/admin"})}return e.jsx("main",{className:"min-h-screen bg-[#f7f3ec] flex items-center justify-center px-4 py-12",children:e.jsxs("div",{className:"w-full max-w-md",children:[e.jsx(k,{to:"/",className:"text-sm text-stone-600 hover:text-stone-900",children:"← Back to site"}),e.jsxs("div",{className:"mt-4 rounded-2xl border border-stone-200 bg-white p-8 shadow-sm",children:[e.jsx("h1",{className:"font-serif text-3xl text-stone-900",children:"Staff Sign In"}),e.jsx("p",{className:"mt-2 text-sm text-stone-600",children:"Access the Panacea concierge dashboard."}),e.jsxs("button",{type:"button",onClick:y,className:"mt-6 flex w-full items-center justify-center gap-2 rounded-lg border border-stone-300 bg-white px-4 py-2.5 text-sm font-medium text-stone-800 hover:bg-stone-50",children:[e.jsxs("svg",{className:"h-4 w-4",viewBox:"0 0 24 24","aria-hidden":!0,
1children:[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.75h3.57c2.08-1.92 3.28-4.74 3.28-8.07z"}),e.jsx("path",{fill:"#34A853",d:"M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.75c-.99.66-2.26 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.12A6.98 6.98 0 0 1 5.47 12c0-.74.13-1.45.36-2.12V7.04H2.18A11 11 0 0 0 1 12c0 1.77.42 3.45 1.18 4.96l3.66-2.84z"}),e.jsx("path",{fill:"#EA4335",d:"M12 5.38c1.62 0 3.06.56 4.2 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.04l3.66 2.84C6.71 7.31 9.14 5.38 12 5.38z"})]}),"Continue with Google"]}),e.jsxs("div",{className:"my-6 flex items-center gap-3 text-xs uppercase tracking-wider text-stone-400",children:[e.jsx("div",{className:"h-px flex-1 bg-stone-200"})," or ",e.jsx("div",{className:"h-px flex-1 bg-stone-200"})]}),e.jsxs("form",{onSubmit:_,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-stone-600",children:"Email"}),e.jsx("input",{type:"email",required:!0,value:s,onChange:o=>f(o.target.value),className:"mt-1 w-full rounded-lg border border-stone-300 bg-white px-3 py-2 text-base focus:border-stone-900 focus:outline-none"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-stone-600",children:"Password"}),e.jsx("input",{type:"password",required:!0,minLength:8,value:i,onChange:o=>u(o.target.value),className:"mt-1 w-full rounded-lg border border-stone-300 bg-white px-3 py-2 text-base focus:border-stone-900 focus:outline-none"})]}),p&&e.jsx("p",{className:"text-sm text-red-600",children:p}),x&&e.jsx("p",{className:"text-sm text-emerald-700",children:x}),e.jsx("button",{type:"submit",disabled:c,className:"w-full rounded-lg bg-stone-900 px-4 py-2.5 text-sm font-medium text-white hover:bg-stone-800 disabled:opacity-60",children:c?"Please wait…":r==="signin"?"Sign in":"Create account"})]}),e.jsx("div",{className:"mt-6 text-center text-sm text-stone-600",children:r==="signin"?e.jsxs(e.Fragment,{children:["New team member? ",e.jsx("button",{className:"underline",onClick:()=>n("signup"),children:"Create an account"})]}):e.jsxs(e.Fragment,{children:["Already have an account? ",e.jsx("button",{className:"underline",onClick:()=>n("signin"),children:"Sign in"})]})})]})]})})}export{K 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.