PageSourceSearch

https://kanvo.ai/assets/Auth-8A_SqQWV.js

js kanvo.ai collected 2026-10-05 12:16:24 UTC 32,303 bytes, 6 lines download raw bytes

1import{c as se,f as D,o as J,a9 as re,r as i,s as P,a1 as E,x as $,an as ne,j as e,B as S,p as C,W as ae,aH as oe,b as M,h as ie,a5 as Y,b2 as le,e as B,aW as ce,w as de,a as ue}from"./index-CyV9aJqm.js";import{K as me}from"./KanvoLogo-BZGpIwui.js";import{w as he,i as fe}from"./invoke-Dk5jjtyg.js";import{r as V,e as F,i as q,R as Q,a as pe,b as ge}from"./inviteOnly-DfkrnVJj.js";import{I as L}from"./input-CWgB7KLx.js";import{L as R}from"./label-BPmy7-1x.js";import{C as xe}from"./contactEmail-CLY1sg0F.js";import{Q as we}from"./qr-code-DAJyszko.js";import{C as ve}from"./chevron-down-oEEberIu.js";import{L as be}from"./lock-BPlhYtD9.js";import{E as ye}from"./eye-off-uEIE9Jr7.js";import{E as je}from"./eye-ChUe1Agf.js";import{P as Ne,v as Se,s as Ee,a as ke,b as Ce}from"./authValidation-DcuEta8k.js";import{M as Z}from"./mail-CVvil2_Q.js";import{I as Ie,a as Ae,b as T}from"./input-otp-BAQ6iNXL.js";import{M as Pe}from"./message-square-BwfDFems.js";import{S as Oe}from"./scan-eye-C2iiIoA_.js";import{P as _e}from"./pen-line-EmKNn9zU.js";import{L as Te}from"./lightbulb-CwFgihu2.js";import{r as H,s as Me}from"./authRedirect-KChsFTLa.js";import{S as Le}from"./SEO-CgzsEJIw.js";import{a as Re}from"./ThemeToggle-CnYh-pZy.js";import{K as Ue}from"./key-round-DyGNkKv5.js";import"./types-4og3oiYD.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 Fe=se("MailCheck",[["path",{d:"M22 13V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v12c0 1.1.9 2 2 2h8",key:"12jkf8"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}],["path",{d:"m16 19 2 2 4-4",key:"1b14m6"}]]),z=t=>fe("wallet-auth",t);function De({className:t}){const r=D(),[s]=J(),{connect:n,sign:a,account:o,error:c}=re(),[m,l]=i.useState(!1),h=i.useRef(!1),f=i.useRef(!1),b=s.get("redirect")||"/dashboard",x=i.useCallback(async u=>{if(!u.supported)throw new Error("Switch your wallet to a network Kanvo supports, then try again.");const v=await z({action:"challenge",namespace:u.namespace,chainId:String(u.chainId),address:u.address}),y=await a(v.message),N=V(),p=await z({action:"verify",nonce:v.nonce,signature:y,...N?{invite_code:N}:{}}),{error:w}=await P.auth.verifyOtp({token_hash:p.token_hash,type:"magiclink"});if(w)throw w;E.success(p.status==="signed-up"?"New account created":"Signed in",{description:p.status==="signed-up"?"That wallet was new to Kanvo, so this account is empty and your wallet is the only way into it. Already have an account? Sign out, sign in as usual, and add this wallet under Settings → Wallets.":"Welcome back."}),r(b,{replace:!0})},[r,b,a]),g=i.useCallback(async u=>{if(!f.current){f.current=!0,l(!0);try{await x(u)}catch(v){const y=$(v,"Signing in with a wallet failed."),N=F(y,v==null?void 0:v.code);he(v)?E("Cancelled",{description:"The signature request was dismissed."}):E.error("Could not sign in",{description:N})}finally{f.current=!1,l(!1)}}},[x]);i.useEffect(()=>{!o||!h.current||(h.current=!1,g(o))},[o,g]);const d=async()=>{if(o){await g(o);return}h.current=!0,l(!0);const u=await n()??c;if(u){h.current=!1,l(!1),E.error("Could not connect",{description:u});return}window.setTimeout(()=>{h.current&&(h.current=!1,l(!1))},12e4)};return ne()?e.jsxs(S,{type:"button",variant:"outline",className:t,onClick:d,disabled:m,children:[m?e.jsx(C,{className:"mr-2 h-4 w-4 animate-spin"}):e.jsx(ae,{className:"mr-2 h-5 w-5"}),o?"Sign in with your wallet":"Continue with a wallet"]}):null}function We(t){const r=t.trim().toLowerCase().lastIndexOf("@");return r<1||r===t.trim().length-1?null:t.trim().toLowerCase().slice(r+1)}function $e(t){const r=t==null?void 0:t.status,s=String((t==null?void 0:t.message)??"").toLowerCase();return r===404||r===422||r===501?!0:s.includes("sso")&&(s.includes("not found")||s.includes("not enabled")||s.includes("disabled"))}async function Be(t,r){const s=We(t);if(!s)throw new Error("Enter your work email address.");const{data:n,error:a}=await P.auth.signInWithSSO({domain:s,...r?{options:{redirectTo:r}}:{}});if(a){if($e(a))return!1;throw a}return n!=null&&n.url?(window.location.assign(n.url),!0):!1}const Ve=t=>typeof(t==null?void 0:t.saml_enabled)=="boolean"?t.saml_enabled:null,He="https://cxlzunwzvrrtdrtlblcd.supabase.co",ze="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImN4bHp1bnd6dnJydGRydGxibGNkIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjcxNzYzODcsImV4cCI6MjA4Mjc1MjM4N30.G-1qGjgpDQOaWN_55f5mKEsOtbhIGFgA-7vPXCh-xSU";let K=null;function Ke(){return K??(K=(async()=>{try{const t=await fetch(`${He}/auth/v1/settings`,{headers:{apikey:ze}});return t.ok?Ve(await t.json()):null}catch{return null}})()),K}function Ge({initiallyOpen:t=!1,redirectTo:r}={}){const[s,n]=i.useState(t),[a,o]=i.useState(""),[c,m]=i.useState(!1),[l,h]=i.useState(null),[f,b]=i.useState(null);if(i.useEffect(()=>{let g=!0;return Ke().then(d=>{g&&b(d)}),()=>{g=!1}},[]),f===!1)return null;if(!s)return e.jsxs(S,{type:"button",variant:"ghost",className:"w-full mb-2 text-muted-foreground hover:text-foreground",onClick:()=>n(!0),children:[e.jsx(oe,{className:"mr-2 h-4 w-4","aria-hidden":"true"}),"Sign in with your company account"]});const x=async g=>{g.preventDefault(),m(!0),h(null);try{await Be(a,r)||h(`We don't have single sign-on set up for that domain yet. Use one of the other options above, or ask us at ${xe} to connect your identity provider.`)}catch(d){h($(d,"That did not work. Try another way in."))}finally{m(!1)}};return e.jsxs("form",{onSubmit:x,className:"mb-2 space-y-2 rounded-lg border border-border/60 p-3",children:[e.jsx(R,{htmlFor:"sso-email",className:"text-sm",children:"Work email"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(L,{id:"sso-email",type:"email",required:!0,autoComplete:"email",value:a,onChange:g=>o(g.target.value),placeholder:"[email protected]"}
6),e.jsx(S,{type:"submit",variant:"outline",disabled:c,children:c?e.jsx(C,{className:"h-4 w-4 animate-spin","aria-hidden":"true"}):"Continue"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"SAML 2.0, against your own identity provider. We'll send you to it and back."}),l&&e.jsx("p",{className:"text-xs text-muted-foreground",children:l})]})}const Xe="/assets/1profile-icon-DD5KZ67p.png",Je=()=>e.jsxs("svg",{className:"mr-2 h-5 w-5",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"})]}),Ye=()=>e.jsxs("svg",{className:"mr-2 h-5 w-5",viewBox:"0 0 23 23","aria-hidden":"true",children:[e.jsx("path",{fill:"#f35325",d:"M1 1h10v10H1z"}),e.jsx("path",{fill:"#81bc06",d:"M12 1h10v10H12z"}),e.jsx("path",{fill:"#05a6f0",d:"M1 12h10v10H1z"}),e.jsx("path",{fill:"#ffba08",d:"M12 12h10v10H12z"})]}),qe=()=>e.jsx("svg",{className:"mr-2 h-5 w-5",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:e.jsx("path",{d:"M16.365 1.43c0 1.14-.417 2.2-1.25 3.03-.99 1-2.13 1.58-3.36 1.48-.02-.11-.03-.23-.03-.36 0-1.1.47-2.19 1.28-3 .82-.83 2.06-1.45 3.2-1.5.09.11.16.24.16.35zM20.7 17.02c-.33.76-.72 1.46-1.18 2.1-.63.87-1.14 1.47-1.54 1.8-.62.54-1.28.82-1.99.84-.51 0-1.13-.15-1.85-.44-.72-.29-1.38-.44-1.99-.44-.63 0-1.31.15-2.04.44-.73.29-1.32.45-1.77.47-.68.03-1.36-.26-2.03-.87-.43-.36-.96-.98-1.6-1.87a12.9 12.9 0 01-1.69-3.28c-.46-1.32-.69-2.6-.69-3.84 0-1.42.31-2.64.92-3.67a5.4 5.4 0 011.93-1.95 5.2 5.2 0 012.6-.74c.54 0 1.25.17 2.14.5.88.33 1.45.5 1.7.5.19 0 .82-.2 1.89-.59 1.01-.36 1.86-.51 2.56-.45 1.89.15 3.31.9 4.25 2.25-1.69 1.03-2.53 2.46-2.51 4.3.02 1.43.54 2.62 1.56 3.57.46.44.98.78 1.55 1.02-.12.36-.25.7-.4 1.03z"})});function Qe({isGoogleLoading:t,isAppleLoading:r,isOneProfileLoading:s,isMicrosoftLoading:n,handleGoogleSignIn:a,handleAppleSignIn:o,handleOneProfileSignIn:c,handleMicrosoftSignIn:m,ssoOpen:l=!1,ssoRedirect:h}){const[f,b]=i.useState(l);return e.jsxs(e.Fragment,{children:[e.jsxs(S,{type:"button",variant:"outline",className:"w-full mb-2 hover:border-foreground
6/20 hover:bg-foreground/[0.06] hover:text-foreground",onClick:a,disabled:t,children:[t?e.jsx(C,{className:"mr-2 h-4 w-4 animate-spin"}):e.jsx(Je,{}),"Continue with Google"]}),e.jsxs(S,{type:"button",variant:"outline",className:"w-full mb-2 hover:border-foreground/20 hover:bg-foreground/[0.06] hover:text-foreground",onClick:o,disabled:r,children:[r?e.jsx(C,{className:"mr-2 h-4 w-4 animate-spin"}):e.jsx(qe,{}),"Continue with Apple"]}),f?e.jsxs(e.Fragment,{children:[e.jsxs(S,{type:"button",variant:"outline",className:"w-full mb-2 hover:border-foreground/20 hover:bg-foreground/[0.06] hover:text-foreground",onClick:m,disabled:n,children:[n?e.jsx(C,{className:"mr-2 h-4 w-4 animate-spin"}):e.jsx(Ye,{}),"Continue with Microsoft"]}),e.jsxs(S,{type:"button",variant:"outline",className:"w-full mb-2 hover:border-foreground/20 hover:bg-foreground/[0.06] hover:text-foreground",onClick:c,disabled:s,children:[s?e.jsx(C,{className:"mr-2 h-4 w-4 animate-spin"}):e.jsx("img",{src:Xe,alt:"","aria-hidden":"true",className:"mr-2 h-5 w-5"}),"Continue with 1Profile"]}
6),e.jsx(De,{className:"w-full mb-2 hover:border-foreground/20 hover:bg-foreground/[0.06] hover:text-foreground"}),e.jsx(Ge,{initiallyOpen:l,redirectTo:h}),e.jsx(S,{asChild:!0,variant:"ghost",className:"w-full mb-2 text-muted-foreground hover:text-foreground",children:e.jsxs(M,{to:"/pair",children:[e.jsx(we,{className:"me-2 h-4 w-4","aria-hidden":"true"}),"Use a code from another device"]})})]}):e.jsxs(S,{type:"button",variant:"ghost",className:"w-full h-9 mb-0 text-muted-foreground hover:text-foreground",onClick:()=>b(!0),children:["More ways to sign in",e.jsx(ve,{className:"ml-1 h-4 w-4","aria-hidden":"true"})]}),e.jsxs("div",{className:"my-4 flex items-center gap-3",children:[e.jsx("div",{className:"h-px flex-1 bg-border"}),e.jsx("span",{className:"text-xs uppercase tracking-wide text-muted-foreground",children:"Or"}),e.jsx("div",{className:"h-px flex-1 bg-border"})]})]})}function Ze({id:t="password",label:r="Password",value:s,onChange:n,error:a,hint:o,autoComplete:c}){const[m,l]=i.useState(!1),h=a?`${t}-error`:o?`${t}-hint`:void 0;return e.jsxs("div",{className:"space-y-2",children:[e.jsx(R,{htmlFor:t,className:"text-foreground",children:r}),e.jsxs("div",{className:"relative",children:[e.jsx(be,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground","aria-hidden":"true"}),e.jsx(L,{id:t,type:m?"text":"password",value:s,autoComplete:c,"aria-invalid":a?!0:void 0,"aria-describedby":h,onChange:f=>n(f.target.value),className:`pl-10 pr-10 bg-background border-input ${a?"border-destructive":""}`}),e.jsx("button",{type:"button",onClick:()=>l(f=>!f),"aria-label":m?"Hide password":"Show password","aria-pressed":m,className:"absolute right-3 top-1/2 -translate-y-1/2 rounded-sm p-0.5 text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:m?e.jsx(ye,{className:"h-4 w-4"}):e.jsx(je,{className:"h-4 w-4"})})]}),a?e.jsx("p",{id:`${t}-error`,className:"text-sm text-destructive",children:a}):o?e.jsx("p",{id:`${t}-hint`,className:"text-xs text-muted-foreground",children:o}):null]})}function et({isLogin:t,auth:r}){const{email:s,setEmail:n,password:a,setPassword:o,displayName:c,setDisplayName:m,errors:l,authError:h,isSubmitting:f,resendCooldown:b,clearFieldError:x,handleSubmit:g,handleResendVerification:d}=r;return e.jsxs("form",{onSubmit:g,className:"space-y-4",children:[!t&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(R,{htmlFor:"displayName",className:"text-foreground",children:"Display Name"}),e.jsxs("div",{className:"relative",children:[e.jsx(ie,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(L,{id:"displayName",type:"text",placeholder:"John Doe",value:c,onChange:u=>m(u.target.value),className:"pl-10 bg-background border-input"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(R,{htmlFor:"email",className:"text-foreground",children:"Email"}),e.jsxs("div",{className:"relative",children:[e.jsx(Z,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(L,{id:"email",type:"email",placeholder:"[email protected]",value:s,onChange:u=>{n(u.target.value),x("email")},className:`pl-10 bg-background border-input ${l.email?"border-destructive":""}`})]}),l.email&&e.jsx("p",{className:"text-sm text-destructive",children:l.email})]}),e.jsx(Ze,{value:a,onChange:u=>{o(u),x("password")},error:l.password,hint:t?void 0:Ne,autoComplete:t?"current-password":"new-password"}),h&&e.jsxs("div",{className:"bg-destructive/10 border border-destructive/30 text-destructive px-4 py-3 rounded-lg text-sm",children:[e.jsx("p",{children:h}),h.includes("verify your email")&&e.jsx("button",{type:"button",onClick:d,disabled:b>0,className:"mt-2 text-primary hover:underline font-medium disabled:opacity-50",children:b>0?`Resend verification email (${b}s)`:"Resend verification email"})]}),e.jsx(S,{type:"submit",className:"w-full",variant:"hero",disabled:f,children:f?e.jsxs(e.Fragment,{children:[e.jsx(C,{className:"mr-2 h-4 w-4 animate-spin"}),t?"Signing in...":"Creating account..."]}):t?"Sign in":"Create account"})]})}function tt({auth:t}){const{phone:r,setPhone:s,errors:n,isSubmitting:a,clearFieldError:o,handleSubmit:c}=t;return e.jsxs("form",{onSubmit:c,className:"space-y-5",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(R,{htmlFor:"phone",className:"text-foreground",children:"Phone number"}),e.jsxs("div",{className:"relative",children:[e.jsx(Y,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(L,{id:"phone",type:"tel",placeholder:"+44 7700 900123",autoComplete:"tel",inputMode:"tel",value:r,onChange:m=>{s(m.target.value),o()},className:`pl-10 bg-background border-input ${n.phone?"border-destructive":""}`})]}),n.phone&&e.jsx("p",{className:"text-sm text-destructive",children:n.phone}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Start with your country code — +44 for the UK, +1 for the US."})]}),e.jsx(S,{type:"submit",className:"w-full",variant:"hero",disabled:a,children:a?e.jsxs(e.Fragment,{children:[e.jsx(C,{className:"mr-2 h-4 w-4 animate-spin"}),"Sending code..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Pe,{className:"mr-2 h-4 w-4"}),"Send verification code"]})})]})}function st({auth:t}){const{phone:r,otp:s,setOtp:n,isSubmitting:a,handleVerify:o,reset:c}=t;return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-muted-foreground mb-2",children:"Enter the 6-digit code sent to"}),e.jsx("p",{className:"font-medium text-foreground",children:r})]}),e.jsx("div",{className:"flex justify-center",children:e.jsx(Ie,{value:s,onChange:n,maxLength:6,children:e.jsxs(Ae,{children:[e.jsx(T,{index:0}),e.jsx(T,{index:1}),e.jsx(T,{index:2}),e.jsx(T,{index:3}),e.jsx(T,{index:4}),e.jsx(T,{index:5})]})})}),e.jsx(S,{type:"button",onClick:o,className:"w-full",variant:"hero",disabled:a||s.length!==6,children:a?e.jsxs(e.Fragment,{children:[e.jsx(C,{className:"mr-2 h-4 w-4 animate-spin"}),"Verifying..."]}):"Verify & Sign In"}),e.jsx("div",{className:"text-center",children:e.jsx("button",{type:"button",onClick:c,className:"text-sm text-primary hover:underline",children:"Use a different number"})})]})}function rt({auth:t}){return e.jsx("div",{className:"space-y-5",children:t.showOtpInput?e.jsx(st,{auth:t}):e.jsx(tt,{auth:t})})}const nt=[{icon:Oe,title:"Reads it for you",detail:"Two lines on the thread you have not opened since Thursday, and what the person is actually asking for."}
6,{icon:_e,title:"Writes the reply",detail:"A draft in your voice, already in the box. Send it, change a word, or throw it away."},{icon:Te,title:"Says what it would change",detail:"The detail you left out, the price you forgot to mention, the tone that reads sharper than you meant."},{icon:le,title:"Listens and speaks",detail:"Voice notes arrive as text you can skim. Long threads play back while your hands are busy."}];function at(){return e.jsxs("div",{className:"hidden lg:flex lg:flex-1 relative overflow-hidden",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-primary/20 via-accent/10 to-kanvo-lavender/30"}),e.jsx("div",{className:"absolute inset-0 gradient-mesh opacity-50"}),e.jsx("div",{className:"absolute top-1/4 left-1/4 w-64 h-64 rounded-full bg-primary/20 blur-3xl animate-float"}),e.jsx("div",{className:"absolute bottom-1/4 right-1/4 w-48 h-48 rounded-full bg-accent/20 blur-3xl animate-float-slow"}),e.jsx("div",{className:"relative z-10 flex flex-col justify-center p-12",children:e.jsxs("div",{className:"glass-card max-w-md p-8",children:[e.jsx("h2",{className:"font-heading text-2xl font-medium text-foreground",children:"The messenger you run with AI"}),e.jsx("ul",{className:"mt-6 space-y-5",children:nt.map(t=>e.jsxs("li",{className:"flex gap-3",children:[e.jsx("span",{className:"mt-0.5 flex h-8 w-8 shrink-0 items-center justify-center rounded-sm bg-primary/10",children:e.jsx(t.icon,{className:"h-4 w-4 text-primary","aria-hidden":"true"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-foreground",children:t.title}),e.jsx("p",{className:"text-sm text-muted-foreground",children:t.detail})]})]},t.title))})]})})]})}function ot({auth:t}){return e.jsxs("div",{className:"rounded-lg border border-border bg-card p-6 text-center",children:[e.jsx("div",{className:"mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-primary/10",children:e.jsx(Fe,{className:"h-6 w-6 text-primary","aria-hidden":"true"})}),e.jsx("h2",{className:"font-heading text-xl font-medium text-foreground",children:"Check your inbox"}),e.jsxs("p",{className:"mt-2 text-sm text-muted-foreground",children:["We sent a confirmation link to"," ",e.jsx("span",{className:"font-medium text-foreground",children:t.email}),". Open it and you will be signed in."]}),e.jsxs("div",{className:"mt-6 flex flex-col gap-2",children:[e.jsx(S,{type:"button",variant:"outline",onClick:t.handleResendVerification,disabled:t.resendCooldown>0,children:t.resendCooldown>0?`Send it again in ${t.resendCooldown}s`:"Send it again"}),e.jsx(S,{type:"button",variant:"ghost",onClick:t.dismissVerification,children:"Use a different address"})]}),e.jsx("p",{className:"mt-4 text-xs text-muted-foreground",children:"Nothing arrived? Check the spam folder — the message comes from kanvo.ai."})]})}const it="authorization_response",lt="/~oauth/initiate",ct=["https://oauth.lovable.app","https://lovable.dev"],dt="lovable://oauth-callback",ut="http://127.0.0.1/iframe-oauth/callback",mt=500,ht=12e4,ft=/LovableAppScheme\/([a-z0-9.+-]+)/i;function pt(t){var s;const r=(s=ft.exec(t))==null?void 0:s[1];return r?`${r}://oauth-callback`:dt}function gt(t){let r;const s=new Promise(o=>{r=o}),n=o=>{if(!t.some(m=>o.origin===m))return;const c=o.data;!c||typeof c!="object"||c.type===it&&r(c.response)},a=()=>{window.removeEventListener("message",n)};return window.addEventListener("message",n),{cleanup:a,messagePromise:s}}function xt(t){const r=window.screenX!==0||window.screenY!==0||!t,s=r?window.outerWidth*.5:window.screen.width*.5,n=r?window.outerHeight*.5:window.screen.height*.5;return{width:s,height:n,left:r?window.screenX+(window.outerWidth-s)/2:(window.screen.width-s)/2,top:r?window.screenY+(window.outerHeight-n)/2:(window.screen.height-n)/2}}function G(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 wt(){const t=navigator.userAgent;return!!(/iPhone|iPad|iPod|Android/i.test(t)||/Macintosh/i.test(t)&&navigator.maxTouchPoints>1)}function vt(){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 bt(t={}){const r=t.oauthBrokerUrl??lt,s=t.supportedOAuthOrigins??ct;async function n(a,o={}){let c=!1;try{c=window.self!==window.top}catch{c=!0}const m=navigator.userAgent,l=/LovableApp\//.test(m),h=!l&&/lovable/i.test(m),f=vt();let b=o.redirect_uri??window.location.origin;
6l&&c?b=pt(m):h&&c&&(b=ut);const x=new URLSearchParams({...o.extraParams,provider:a,redirect_uri:b,state:f});if(!c)return window.location.href=`${r}?${x.toString()}`,{error:null,redirected:!0};!l&&!h&&x.set("response_mode","web_message");const g=`${r}?${x.toString()}`,{messagePromise:d,cleanup:u}=gt(h?[...s,window.location.origin]:s);let v;if(wt())v=window.open(g,"_blank");else{const{width:p,height:w,left:j,top:k}=xt(c);v=window.open(g,"oauth",`width=${p},height=${w},left=${j},top=${k}`)}if(!v&&(l||h)){let p;const w=new Promise((j,k)=>{p=setTimeout(()=>{k(new Error("OAuth timed out waiting for response"))},ht)});try{return G(await Promise.race([d,w]),f)}catch(j){return{error:j instanceof Error?j:new Error(String(j))}}finally{p&&clearTimeout(p),u()}}if(!v)return u(),{error:new Error("Popup was blocked")};let y;const N=new Promise((p,w)=>{y=setInterval(()=>{v.closed&&(clearInterval(y),w(new Error("Sign in was cancelled")))},mt)});try{return G(await Promise.race([d,N]),f)}catch(p){return{error:p instanceof Error?p:new Error(String(p))}}finally{clearInterval(y),u(),v==null||v.close()}}return{signInWithOAuth:n}}function yt(t={}){return bt(t)}const jt=yt(),Nt={auth:{signInWithOAuth:async(t,r)=>{const s=await jt.signInWithOAuth(t,{...r,extraParams:{...r==null?void 0:r.extraParams}});if(s.redirected||s.error)return s;try{await P.auth.setSession(s.tokens)}catch(n){return{error:n instanceof Error?n:new Error(String(n))}}return s}}},St={google:"Google",apple:"Apple",microsoft:"Microsoft"};function Et(t,r){const[s,n]=i.useState(!1),[a,o]=i.useState(!1),[c,m]=i.useState(!1),[l,h]=i.useState(!1),f=(g,d)=>E.error(g,{description:d}),b=async()=>{n(!0);try{r&&H(r);const g=`${window.location.origin}/auth/callback`,{data:d,error:u}=await P.functions.invoke("oneprofile-sso/authorize",{body:{redirect_uri:g}});if(u){console.error("1Profile auth error:",u),f("Authentication failed","Failed to initiate 1Profile sign-in."),n(!1);return}d.authUrl&&(window.location.href=d.authUrl)}catch(g){console.error("1Profile SSO error:",g),f("Authentication failed","An error occurred during sign-in."),n(!1)}},x=(g,d)=>async()=>{var v,y;const u=St[g];d(!0),t==null||t(),r&&H(r);try{const N=V();let p;if(N){const j=(v=window.prompt(`Using invite code ${N}. Which email address is your ${u} account? (Leave blank if you already have a Kanvo account.)`))==null?void 0:v.trim();if(j===void 0){d(!1);return}if(j){const{data:k,error:O}=await P.functions.invoke("redeem-invite",{body:{code:N,email:j}});if(O||(k==null?void 0:k.ok)!==!0){const U=(y=O==null?void 0:O.context)==null?void 0:y.status;f("Invite code not accepted",O?U===400?"That email address doesn't look right.":U===429?"Too many tries from here. Try again in a little while.":"That code could not be checked. Try again.":"That code is used up, expired or revoked."),d(!1);return}p=j}}const w=await Nt.auth.signInWithOAuth(g,{redirect_uri:`${window.location.origin}/auth/callback`,...p&&g!=="apple"?{extraParams:{login_hint:p}}:{}});if(w.error){const j=w.error.message||"";if(q(j,w.error.code??null)){E.error("Invite needed",{description:"Kanvo is invite-only right now. Taking you to request access…"}),setTimeout(()=>{window.location.href=Q},2500),d(!1);return}f(`${u} sign-in failed`,F(w.error.message||`An error occurred during ${u} sign-in.`)),d(!1)}}catch(N){console.error(`${u} SSO error:`,N),f("Authentication failed",`An error occurred during ${u} sign-in.`),d(!1)}};return{isOneProfileLoading:s,isGoogleLoading:a,isAppleLoading:c,isMicrosoftLoading:l,handleOneProfileSignIn:b,handleGoogleSignIn:x("google",o),handleAppleSignIn:x("apple",m),handleMicrosoftSignIn:x("microsoft",h)}}const kt=5,Ct=60*1e3;function It(){const t=i.useRef(0),r=i.useRef(0);return{lockoutRemaining:()=>{const o=Date.now();return o<r.current?Math.ceil((r.current-o)/1e3):0},recordFailure:()=>(t.current++,t.current>=kt?(r.current=Date.now()+Ct,t.current=0,!0):!1),recordSuccess:()=>{t.current=0}}}const At=60;function Pt(){const[t,r]=i.useState(0),s=i.useRef(null);i.useEffect(()=>()=>{s.current&&clearInterval(s.current)},[]);const n=i.useCallback(()=>{r(At),s.current&&clearInterval(s.current),s.current=setInterval(()=>{r(a=>a<=1?(s.current&&clearInterval(s.current),0):a-1)},1e3)},[]);return{seconds:t,start:n}}
6function Ot({isLogin:t,redirect:r,inviteCode:s=""}){const n=D(),{signIn:a,signUp:o}=B(),c=It(),m=Pt(),[l,h]=i.useState(""),[f,b]=i.useState(""),[x,g]=i.useState(""),[d,u]=i.useState({}),[v,y]=i.useState(""),[N,p]=i.useState(!1),[w,j]=i.useState(!1),k=A=>u(_=>({..._,[A]:void 0})),O=async A=>{A.preventDefault(),y("");const _=Se(l,f);if(u(_),!(Object.keys(_).length>0)){if(t){const I=c.lockoutRemaining();if(I>0){y(`Too many login attempts. Please wait ${I} seconds.`);return}}p(!0);try{if(t){const{error:I}=await a(l,f);if(I){if(c.recordFailure()){y("Too many failed attempts. Please wait 60 seconds before trying again.");return}y(Ee(I.message))}else c.recordSuccess(),E.success("Welcome back!",{description:"You have successfully logged in."}),n(r)}else{const{error:I}=await o(l,f,x,s);I?q(I.message)?(P.functions.invoke("request-access",{body:{email:l,name:x||void 0,source:"signup"}}).catch(W=>console.error("Access request failed:",W)),y(pe)):y(ke(I.message)):(P.functions.invoke("welcome-email",{body:{email:l,displayName:x||void 0}}).catch(W=>console.error("Welcome email failed:",W)),j(!0))}}finally{p(!1)}}},U=async()=>{if(!(m.seconds>0))try{const{error:A}=await P.auth.resend({type:"signup",email:l});if(A)throw A;m.start(),E("Verification email sent",{description:"Please check your inbox for the verification link."})}catch(A){const _=$(A,"Failed to resend verification email.");E.error("Error",{description:_})}},ee=()=>{u({}),y("")},te=()=>y("");return{email:l,setEmail:h,password:f,setPassword:b,displayName:x,setDisplayName:g,errors:d,authError:v,isSubmitting:N,awaitingVerification:w,dismissVerification:()=>j(!1),resendCooldown:m.seconds,clearFieldError:k,clearErrors:ee,clearAuthError:te,handleSubmit:O,handleResendVerification:U}}const X=6;function _t({redirect:t,inviteCode:r=""}){const s=D(),{signInWithPhone:n,verifyPhoneOtp:a}=B(),[o,c]=i.useState(""),[m,l]=i.useState(""),[h,f]=i.useState(!1),[b,x]=i.useState({}),[g,d]=i.useState(!1);return{phone:o,setPhone:c,otp:m,setOtp:l,showOtpInput:h,errors:b,isSubmitting:g,clearFieldError:()=>x(w=>({...w,phone:void 0})),clearErrors:()=>{x({}),f(!1)},handleSubmit:async w=>{w.preventDefault();const j=Ce(o);if(x(j),!(Object.keys(j).length>0)){d(!0);try{const{error:k}=await n(o,r);k?E.error("Failed to send OTP",{description:F(k.message)}):(f(!0),E.success("OTP sent!",{description:"Please check your phone for the verification code."}))}finally{d(!1)}}},handleVerify:async()=>{if(m.length!==X){E.error("Invalid OTP",{description:`Please enter the ${X}-digit code.`});return}d(!0);try{const{error:w}=await a(o,m);w?E.error("Verification failed",{description:F(w.message)}):(E.success("Success!"),s(t))}finally{d(!1)}},reset:()=>{f(!1),l("")}}}const Tt=[{id:"email",label:"Email",Icon:Z},{id:"phone",label:"Phone",Icon:Y}],as=()=>{const[t,r]=J(),[s,n]=i.useState(t.get("mode")!=="signup"),[a,o]=i.useState("email"),{user:c,loading:m}=B(),l=D(),h=Me(t.get("redirect"),window.location.origin),f=t.get("sso")==="1",b=t.get("native")==="1"?`${window.location.origin}/auth/native`:void 0,[x,g]=i.useState(()=>ce(t)||V());i.useEffect(()=>ge(x),[x]);const d=Ot({isLogin:s,redirect:h,inviteCode:x}),u=_t({redirect:h,inviteCode:x}),v=Et(d.clearAuthError,h);i.useEffect(()=>{!m&&c&&l(h)},[c,m,l,h]);const y=p=>{n(p);const w=new URLSearchParams(t);p?w.delete("mode"):w.set("mode","signup"),r(w,{replace:!0}),d.clearErrors(),u.clearErrors()},N=p=>{o(p),d.clearErrors(),u.clearErrors()};return m?e.jsx("div",{className:"min-h-screen flex items-center justify-center",children:e.jsx(C,{className:"h-8 w-8 animate-spin text-primary"})}):e.jsxs("div",{className:"auth-page min-h-screen flex",children:[e.jsx(Le,{title:"Sign in",description:"Sign in or create a Kanvo account to reach your unified inbox across WhatsApp, Instagram, Messenger, Telegram, Slack, Discord and SMS.",url:"https://kanvo.ai/auth",noindex:!0}),e.jsx("main",{className:"flex-1 flex flex-col justify-center px-4 sm:px-6 lg:px-20 xl:px-24 py-8",children:e.jsxs("div",{className:"mx-auto w-full max-w-sm lg:max-w-md",children:[e.jsxs("div",{className:"mb-6",children:[e.jsxs("div",{className:"mb-6 flex items-center justify-between",children:[e.jsx(M,{to:"/","aria-label":"Back to home",className:"rounded-sm",children:e.jsx(me,{className:"h-8"})}),e.jsx(Re,{})]}),e.jsx("h1",{className:"font-heading text-2xl lg:text-3xl font-medium text-foreground",children:s?"Welcome back":"Create your account"}),e.jsx("p",{className:"mt-1.5 text-sm text-muted-foreground",children:s?"Sign in to get back to your conversations.":"Kanvo is invite-only for now. Use the address or number your invite went to, or your co
6de."})]}),d.awaitingVerification?e.jsx(ot,{auth:d}):e.jsxs(e.Fragment,{children:[!s&&e.jsxs("div",{className:"mb-4 space-y-1.5",children:[e.jsxs(R,{htmlFor:"inviteCode",className:"text-foreground",children:["Invite code ",e.jsx("span",{className:"font-normal text-muted-foreground",children:"(if you have one)"})]}),e.jsxs("div",{className:"relative",children:[e.jsx(Ue,{className:"absolute start-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground","aria-hidden":"true"}),e.jsx(L,{id:"inviteCode",value:x,onChange:p=>g(de(p.target.value)),placeholder:"KOL-XXXX",autoComplete:"off",autoCapitalize:"characters",spellCheck:!1,className:"ps-10 bg-background border-input"})]})]}),e.jsx(Qe,{...v,ssoOpen:f,ssoRedirect:b}),e.jsx("div",{className:"mb-4 grid grid-cols-2 gap-1 rounded-md bg-muted p-1",role:"group","aria-label":"Sign in with email or phone",children:Tt.map(({id:p,label:w,Icon:j})=>e.jsxs("button",{type:"button","aria-pressed":a===p,onClick:()=>N(p),className:ue("inline-flex h-8 items-center justify-center gap-2 rounded-sm text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",a===p?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:[e.jsx(j,{className:"h-4 w-4","aria-hidden":"true"}),w]},p))}),a==="email"?e.jsx(et,{isLogin:s,auth:d}):e.jsx(rt,{auth:u}),s&&a==="email"&&e.jsx("div",{className:"mt-3 text-center",children:e.jsx(M,{to:"/auth/reset-password",className:"text-sm text-primary hover:underline",children:"Forgot your password?"})}),!s&&e.jsxs("p",{className:"mt-3 text-xs text-muted-foreground",children:["By creating an account you agree to our"," ",e.jsx(M,{to:"/terms",className:"underline hover:text-foreground",children:"terms of service"})," ","and"," ",e.jsx(M,{to:"/privacy",className:"underline hover:text-foreground",children:"privacy policy"}),"."]}),e.jsxs("div",{className:"mt-4 text-center",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:[s?"Don't have an account?":"Already have an account?",e.jsx("button",{type:"button",onClick:()=>y(!s),className:"ml-1 text-primary hover:underline font-medium",children:s?"Sign up with an invite":"Sign in"})]}),e.jsxs("p",{className:"mt-1 text-sm text-muted-foreground",children:["No invite?",e.jsx(M,{to:Q,className:"ms-1 text-primary hover:underline font-medium",children:"Request access"})]})]})]})]})}),e.jsx(at,{})]})};export{as 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.