1import{a as e,r as t,t as n}from"./jsx-runtime-BTOWmXi1.js";import{n as r}from"./utils-CdHtdOf4.js";import{n as i,t as a}from"./lovable-Dx3VJtIX.js";import{t as o}from"./loader-circle-CBzliNxp.js";import{F as s,I as c,M as l,f as u,h as d,o as f}from"./index-Ro9uu-if.js";import{n as p,t as m}from"./label-D_UKoBQH.js";import{t as h}from"./dist-C-yXR5pp.js";import{a as g,c as _,i as v,n as y,o as b,r as x,s as S,t as C}from"./dist-C1yhIUuD.js";var w=e(t(),1),T=Object.defineProperty,E=(e,t)=>T(e,`name`,{value:t,configurable:!0});function D(e){let t=w.useRef(e);return w.useEffect(()=>{t.current=e}),w.useMemo(()=>((...e)=>t.current?.(...e)),[])}E(D,`useCallbackRef`);var O=Object.defineProperty,k=(e,t)=>O(e,`name`,{value:t,configurable:!0}),A=!1;function j(){let[e,t]=w.useState(A);return w.useEffect(()=>{A||(A=!0,t(!0))},[]),e}k(j,`useIsHydrated`);var M=w.useSyncExternalStore;function N(){return()=>{}}k(N,`subscribe`);function P(){return M(N,()=>!0,()=>!1)}k(P,`useIsHydratedModern`);var ee=typeof M==`function`?P:j,F=n(),te=Object.defineProperty,I=(e,t)=>te(e,`name`,{value:t,configurable:!0}),L=`rovingFocusGroup.onEntryFocus`,ne={bubbles:!1,cancelable:!0},R=`RovingFocusGroup`,[z,B,re]=b(R),[ie,ae]=S(R,[re]),[oe,se]=ie(R),ce=w.forwardRef(I(function(e,t){return(0,F.jsx)(z.Provider,{scope:e.__scopeRovingFocusGroup,children:(0,F.jsx)(z.Slot,{scope:e.__scopeRovingFocusGroup,children:(0,F.jsx)(le,{...e,ref:t})})})},`RovingFocusGroup`)),le=w.forwardRef(I(function(e,t){let{__scopeRovingFocusGroup:n,orientation:r,loop:i=!1,dir:a,currentTabStopId:o,defaultCurrentTabStopId:s,onCurrentTabStopIdChange:c,onEntryFocus:l,preventScrollOnEntryFocus:u=!1,...f}=e,p=w.useRef(null),m=d(t,p),g=y(a),[v,b]=x({prop:o,defaultProp:s??null,onChange:c,caller:R}),[S,C]=w.useState(!1),T=D(l),E=B(n),O=w.useRef(!1),[k,A]=w.useState(0);return w.useEffect(()=>{let e=p.current;if(e)return e.addEventListener(L,T),()=>e.removeEventListener(L,T)},[T]),(0,F.jsx)(oe,{scope:n,orientation:r,dir:g,loop:i,currentTabStopId:v,onItemFocus:w.useCallback(e=>b(e),[b]),onItemShiftTab:w.useCallback(()=>C(!0),[]),onFocusableItemAdd:w.useCallback(()=>A(e=>e+1),[]),onFocusableItemRemove:w.useCallback(()=>A(e=>e-1),[]),children:(0,F.jsx)(h.div,{tabIndex:S||k===0?-1:0,"data-orientation":r,...f,ref:m,style:{outline:`none`,...e.style},onMouseDown:_(e.onMouseDown,()=>{O.current=!0}),onFocus:_(e.onFocus,e=>{let t=!O.current;if(e.target===e.currentTarget&&t&&!S){let t=new CustomEvent(L,ne);if(e.currentTarget.dispatchEvent(t),!t.defaultPrevented){let e=E().filter(e=>e.focusable);H([e.find(e=>e.active),e.find(e=>e.id===v),...e].filter(Boolean).map(e=>e.ref.current),u)}}O.current=!1}),onBlur:_(e.onBlur,()=>C(!1))})})},`RovingFocusGroupImpl`)),ue=`RovingFocusGroupItem`,de=w.forwardRef(I(function(e,t){let{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:a,children:o,...s}=e,c=v(),l=a||c,u=se(ue,n),d=u.currentTabStopId===l,f=B(n),{onFocusableItemAdd:p,onFocusableItemRemove:m,currentTabStopId:y}=u,b=ee();return g(()=>{if(!(!b||!r))return p(),()=>m()},[b,r,p,m]),w.useEffect(()=>{if(!(b||!r))return p(),()=>m()},[b,r,p,m]),(0,F.jsx)(z.ItemSlot,{scope:n,id:l,focusable:r,active:i,children:(0,F.jsx)(h.span,{tabIndex:d?0:-1,"data-orientation":u.orientation,...s,ref:t,onMouseDown:_(e.onMouseDown,e=>{r?u.onItemFocus(l):e.preventDefault()}),onFocus:_(e.onFocus,()=>u.onItemFocus(l)),onKeyDown:_(e.onKeyDown,e=>{if(e.key===`Tab`&&e.shiftKey){u.onItemShiftTab();return}if(e.target!==e.currentTarget)return;let t=V(e,u.orientation,u.dir);if(t!==void 0){if(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault();let n=f().filter(e=>e.focusable).map(e=>e.ref.current);if(t===`last`)n.reverse();else if(t===`prev`||t===`next`){t===`prev`&&n.reverse();let r=n.indexOf(e.currentTarget);n=u.loop?U(n,r+1):n.slice(r+1)}setTimeout(()=>H(n))}}),children:typeof o==`function`?o({isCurrentTabStop:d,hasTabStop:y!=null}):o})})},`RovingFocusGroupItem`)),fe={ArrowLeft:`prev`,ArrowUp:`prev`,ArrowRight:`next`,ArrowDown:`next`,PageUp:`first`,Home:`first`,PageDown:`last`,End:`last`};function pe(e,t){return t===`rtl`?e===`ArrowLeft`?`ArrowRight`:e===`ArrowRight`?`ArrowLeft`:e:e}I(pe,`getDirectionAwareKey`);
1function V(e,t,n){let r=pe(e.key,n);if(!(t===`vertical`&&[`ArrowLeft`,`ArrowRight`].includes(r))&&!(t===`horizontal`&&[`ArrowUp`,`ArrowDown`].includes(r)))return fe[r]}I(V,`getFocusIntent`);function H(e,t=!1){let n=document.activeElement;for(let r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}I(H,`focusFirst`);function U(e,t){return e.map((n,r)=>e[(t+r)%e.length])}I(U,`wrapArray`);var me=ce,he=de,ge=Object.defineProperty,W=(e,t)=>ge(e,`name`,{value:t,configurable:!0}),G=`Tabs`,[_e,ve]=S(G,[ae]),K=ae(),[ye,q]=_e(G),be=w.forwardRef(W(function(e,t){let{__scopeTabs:n,value:r,onValueChange:i,defaultValue:a,orientation:o=`horizontal`,dir:s,activationMode:c=`automatic`,...l}=e,u=y(s),[d,f]=x({prop:r,onChange:i,defaultProp:a??``,caller:G});return(0,F.jsx)(ye,{scope:n,baseId:v(),value:d,onValueChange:f,orientation:o,dir:u,activationMode:c,children:(0,F.jsx)(h.div,{dir:u,"data-orientation":o,...l,ref:t})})},`Tabs`)),xe=`TabsList`,Se=w.forwardRef(W(function(e,t){let{__scopeTabs:n,loop:r=!0,...i}=e,a=q(xe,n),o=K(n);return(0,F.jsx)(me,{asChild:!0,...o,orientation:a.orientation,dir:a.dir,loop:r,children:(0,F.jsx)(h.div,{role:`tablist`,"aria-orientation":a.orientation,...i,ref:t})})},`TabsList`)),Ce=`TabsTrigger`,we=w.forwardRef(W(function(e,t){let{__scopeTabs:n,value:r,disabled:i=!1,...a}=e,o=q(Ce,n),s=K(n),c=J(o.baseId,r),l=Y(o.baseId,r),u=r===o.value;return(0,F.jsx)(he,{asChild:!0,...s,focusable:!i,active:u,children:(0,F.jsx)(h.button,{type:`button`,role:`tab`,"aria-selected":u,"aria-controls":l,"data-state":u?`active`:`inactive`,"data-disabled":i?``:void 0,disabled:i,id:c,...a,ref:t,onMouseDown:_(e.onMouseDown,e=>{!i&&e.button===0&&e.ctrlKey===!1?o.onValueChange(r):e.preventDefault()}),onKeyDown:_(e.onKeyDown,e=>{i||e.target!==e.currentTarget||[` `,`Enter`].includes(e.key)&&o.onValueChange(r)}),onFocus:_(e.onFocus,()=>{let e=o.activationMode!==`manual`;!u&&!i&&e&&o.onValueChange(r)})})})},`TabsTrigger`)),Te=`TabsContent`,Ee=w.forwardRef(W(function(e,t){let{__scopeTabs:n,value:r,forceMount:i,children:a,...o}=e,s=q(Te,n),c=J(s.baseId,r),l=Y(s.baseId,r),u=r===s.value,d=w.useRef(u);return w.useEffect(()=>{let e=requestAnimationFrame(()=>d.current=!1);return()=>cancelAnimationFrame(e)},[]),(0,F.jsx)(C,{present:i||u,children:({present:n})=>(0,F.jsx)(h.div,{"data-state":u?`active`:`inactive`,"data-orientation":s.orientation,role:`tabpanel`,"aria-labelledby":c,hidden:!n,id:l,tabIndex:0,...o,ref:t,style:{...e.style,animationDuration:d.current?`0s`:void 0},children:n&&a})})},`TabsContent`));function J(e,t){return`${e}-trigger-${t}`}W(J,`makeTriggerId`);function Y(e,t){return`${e}-content-${t}`}W(Y,`makeContentId`);var De=be,X=Se,Z=we,Oe=Ee,ke=De,Ae=w.forwardRef(({className:e,...t},n)=>(0,F.jsx)(X,{ref:n,className:r(`inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground`,e),...t}));Ae.displayName=X.displayName;var Q=w.forwardRef(({className:e,...t},n)=>(0,F.jsx)(Z,{ref:n,className:r(`inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium ring-offset-background cursor-pointer transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 disabled:cursor-not-allowed data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow`,e),...t}));Q.displayName=Z.displayName;var $=w.forwardRef(({className:e,...t},n)=>(0,F.jsx)(Oe,{ref:n,className:r(`mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2`,e),...t}));$.displayName=Oe.displayName;function je(){let e=c(),[t,n]=(0,w.useState)(`signup`),[r,d]=(0,w.useState)(``),[p,m]=(0,w.useState)(``),[h,g]=(0,w.useState)(!1),[_,v]=(0,w.useState)(!0);(0,w.useEffect)(()=>{l.auth.getUser().then(({data:t,error:n})=>{!n&&t.user?e({to:`/account`}):v(!1)})},[e]);let y=async i=>{i.preventDefault(),g(!0);try{if(t===`signup`){let e={};typeof window<`u`&&(e.emailRedirectTo=window.location.origin);let{error:t}=await l.auth.signUp({email:r,password:p,options:e});if(t)throw t;f.success(`Check your email to confirm your account, then sign in.`),n(`signin`)}else{let{error:t}=await l.auth.signInWithPassword({email:r,password:p});if(t)throw t;f.success(`Signed in successfully.`),e({to:`/account`})}}catch(e){f.error(e instanceof Error?e.message:`Something went wrong.`)}finally{g(!1)}};return _?(0,F.jsx)(`div`,{className:`flex flex-1 items-center justify-center px-4 py-12 sm:px-6 lg:px-8`,children:(0,F.jsx)(o,{className:`h-8 w-8 animate-spin text-muted-foreground`})}):(0,F.jsx)(`div`,{className:`flex flex-1 items-center justify-center px-4 py-12 sm:px-6 lg:px-8`,children:(0,F.jsxs)(`div`,{className:`w-full max-w-md
1space-y-8`,children:[(0,F.jsxs)(`div`,{className:`text-center`,children:[(0,F.jsx)(`h1`,{className:`text-3xl font-bold tracking-tight text-foreground`,children:t===`signup`?`Create your free account`:`Welcome back`}),(0,F.jsx)(`p`,{className:`mt-2 text-sm text-muted-foreground`,children:`Free for up to 25 contacts. Upgrade to Pro anytime.`})]}),(0,F.jsxs)(ke,{value:t,onValueChange:e=>n(e),className:`w-full`,children:[(0,F.jsxs)(Ae,{className:`grid w-full grid-cols-2`,children:[(0,F.jsx)(Q,{value:`signup`,children:`Sign up`}),(0,F.jsx)(Q,{value:`signin`,children:`Sign in`})]}),(0,F.jsx)($,{value:`signup`,children:(0,F.jsx)(Me,{email:r,setEmail:d,password:p,setPassword:m,loading:h,onSubmit:y,submitLabel:`Create free account`})}),(0,F.jsx)($,{value:`signin`,children:(0,F.jsx)(Me,{email:r,setEmail:d,password:p,setPassword:m,loading:h,onSubmit:y,submitLabel:`Sign in`})})]}),(0,F.jsxs)(`div`,{className:`relative`,children:[(0,F.jsx)(`div`,{className:`absolute inset-0 flex items-center`,children:(0,F.jsx)(`span`,{className:`w-full border-t`})}),(0,F.jsx)(`div`,{className:`relative flex justify-center text-xs uppercase`,children:(0,F.jsx)(`span`,{className:`bg-background px-2 text-muted-foreground`,children:`Or continue with`})})]}),(0,F.jsxs)(u,{variant:`outline`,type:`button`,className:`w-full`,onClick:async()=>{g(!0);let e={};typeof window<`u`&&(e.redirect_uri=window.location.origin);let t=await a.auth.signInWithOAuth(`google`,e);t.error&&(f.error(t.error instanceof Error?t.error.message:`Google sign-in failed.`),g(!1))},disabled:h,children:[h?(0,F.jsx)(o,{className:`mr-2 h-4 w-4 animate-spin`}):(0,F.jsx)(i,{className:`mr-2 h-4 w-4`}),`Google`]}),(0,F.jsxs)(`p`,{className:`text-center text-xs text-muted-foreground`,children:[`By signing up, you agree to our`,` `,(0,F.jsx)(s,{to:`/terms`,className:`underline hover:text-foreground`,children:`Terms of Service`}),` `,`and`,` `,(0,F.jsx)(s,{to:`/privacy`,className:`underline hover:text-foreground`,children:`Privacy Policy`}),`.`]})]})})}function Me({email:e,setEmail:t,password:n,setPassword:r,loading:i,onSubmit:a,submitLabel:s}){return(0,F.jsxs)(`form`,{onSubmit:a,className:`mt-6 space-y-4`,children:[(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(m,{htmlFor:`email`,children:`Email`}),(0,F.jsx)(p,{id:`email`,type:`email`,placeholder:`[email protected]`,value:e,onChange:e=>t(e.target.value),required:!0,autoComplete:`email`})]}),(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(m,{htmlFor:`password`,children:`Password`}),(0,F.jsx)(p,{id:`password`,type:`password`,placeholder:`â¢â¢â¢â¢â¢â¢â¢â¢`,value:n,onChange:e=>r(e.target.value),required:!0,autoComplete:s===`Create free account`?`new-password`:`current-password`,minLength:6})]}),(0,F.jsxs)(u,{type:`submit`,className:`w-full`,disabled:i,children:[i&&(0,F.jsx)(o,{className:`mr-2 h-4 w-4 animate-spin`}),s]})]})}export{je 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.