1import{r as c,j as e}from"./react-BoPr1yjH.js";import{f as h,u as ue,e as fe,g as ge,s as se,B as pe}from"./index-AyuttgAc.js";import{C as D,b as T,c as _,a as R,d as te}from"./card-uH32uaLM.js";import{R as ae,T as je,B as be,X as Ne,Y as we,a as ve}from"./recharts-cDpu-j9e.js";import{a as ye}from"./react-router-8kbBbRMs.js";import{z as De,E as Te,T as E,w as k,u as _e,U as re,G as Re,k as Ve}from"./lucide-react-Dy5dDxJP.js";import"./@supabase-D9VVd71y.js";import"./react-dom-oPhaD6rJ.js";import"./scheduler-CzFDRTuY.js";import"./@radix-ui-uPnaQNgx.js";import"./@floating-ui-B3T_IbQx.js";import"./react-remove-scroll-DUOJNfth.js";import"./tslib-CDuPK5Eb.js";import"./react-remove-scroll-bar-xMAqS-HS.js";import"./react-style-singleton-Bmo2mwzG.js";import"./get-nonce-C-Z93AgS.js";import"./use-sidecar-CmYptSlY.js";import"./use-callback-ref-CDfTGrR-.js";import"./aria-hidden-DQ5UC2Eg.js";import"./class-variance-authority-Dp3B9jqt.js";import"./clsx-B-dksMZM.js";import"./tailwind-merge-Dnoi3Axr.js";import"./next-themes-D2i0MUJ6.js";import"./sonner-Cu3kxFY5.js";import"./@tanstack-Co7gEp7O.js";import"./react-router-dom-CBJBY5ZW.js";import"./@remix-run-Br25Cn4W.js";import"./react-hook-form-CIeLFd_4.js";import"./react-helmet-async-B6H6Ruhg.js";import"./react-fast-compare-DFNOQxth.js";import"./invariant-C1CP3kcu.js";import"./shallowequal-Bda6gaBQ.js";import"./lodash-CHkev9KE.js";import"./react-is-DcfIKM1A.js";import"./react-smooth-fzgCGhs9.js";import"./prop-types-CW7hQHcG.js";import"./fast-equals-C7I1S-bJ.js";import"./tiny-invariant-BaFNuDhB.js";import"./d3-shape-DjFPhhqo.js";import"./d3-path-CimkQT29.js";import"./victory-vendor-6_AdwBXU.js";import"./d3-scale-BYIooUZQ.js";import"./internmap-BkD7Hj8s.js";import"./d3-array-g_qRI3rN.js";import"./d3-time-format-BKO53YJi.js";import"./d3-time-QpEiTrED.js";import"./d3-interpolate-CvRPKVI0.js";import"./d3-color-9lF95FHy.js";import"./d3-format-CzD4bSOQ.js";import"./recharts-scale-DiOBu8nk.js";import"./decimal.js-light-B5-9uEc-.js";import"./eventemitter3-SrZXn4Nc.js";const ie=c.forwardRef(({className:r,...s},t)=>e.jsx("div",{className:"relative w-full overflow-auto",children:e.jsx("table",{ref:t,className:h("w-full caption-bottom text-sm",r),...s})}));
vendor: 4,651 bytes, lines 1-7
1ie.displayName="Table";const ne=c.forwardRef(({className:r,...s},t)=>e.jsx("thead",{ref:t,className:h("[&_tr]:border-b",r),...s}));ne.displayName="TableHeader";const oe=c.forwardRef(({className:r,...s},t)=>e.jsx("tbody",{ref:t,className:h("[&_tr:last-child]:border-0",r),...s}));oe.displayName="TableBody";const qe=c.forwardRef(({className:r,...s},t)=>e.jsx("tfoot",{ref:t,className:h("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",r),...s}));qe.displayName="TableFooter";const U=c.forwardRef(({className:r,...s},t)=>e.jsx("tr",{ref:t,className:h("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",r),...s}));U.displayName="TableRow";const C=c.forwardRef(({className:r,...s},t)=>e.jsx("th",{ref:t,className:h("h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0",r),...s}));C.displayName="TableHead";const F=c.forwardRef(({className:r,...s},t)=>e.jsx("td",{ref:t,className:h("p-4 align-middle [&:has([role=checkbox])]:pr-0",r),...s}));F.displayName="TableCell";const Ce=c.forwardRef(({className:r,...s},t)=>e.jsx("caption",{ref:t,className:h("mt-4 text-sm text-muted-foreground",r),...s}));Ce.displayName="TableCaption";const Fe={light:"",dark:".dark"},le=c.createContext(null);function ce(){const r=c.useContext(le);if(!r)throw new Error("useChart must be used within a <ChartContainer />");return r}const de=c.forwardRef(({id:r,className:s,children:t,config:o,...x},g)=>{const p=c.useId(),m=`chart-${r||p.replace(/:/g,"")}`;return e.jsx(le.Provider,{value:{config:o},children:e.jsxs("div",{"data-chart":m,ref:g,className:h("flex aspect-video justify-center text-xs [&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground [&_.recharts-cartesian-grid_line[stroke='#ccc']]:stroke-border/50 [&_.recharts-curve.recharts-tooltip-cursor]:stroke-border [&_.recharts-dot[stroke='#fff']]:stroke-transparent [&_.recharts-layer]:outline-none [&_.recharts-polar-grid_[stroke='#ccc']]:stroke-border [&_.recharts-radial-bar-background-sector]:fill-muted [&_.recharts-rectangle.recharts-tooltip-cursor]:fill-muted [&_.recharts-reference-line_[stroke='#ccc']]:stroke-border [&_.recharts-sector[stroke='#fff']]:stroke-transparent [&_.recharts-sector]:outline-none [&_.recharts-surface]:outline-none",s),...x,children:[e.jsx(Le,{id:m,config:o}),e.jsx(ae,{children:t})]})})});de.displayName="Chart";const Le=({id:r,config:s})=>{const t=Object.entries(s).filter(([o,x])=>x.theme||x.color);return t.length?e.jsx("style",{dangerouslySetInnerHTML:{__html:Object.entries(Fe).map(([o,x])=>` 2${x} [data-chart=${r}] { 3${t.map(([g,p])=>{var w;const m=((w=p.theme)==null?void 0:w[o])||p.color;return m?` --color-${g}: ${m};`:null}).join(` 4`)} 5} 6`).join(` 7`)}}):null},Ee=je,me=c.forwardRef(({active:r,payload:s,className:t,indicator:o="dot",hideLabel:x=!1,hideIndicator:g=!1,label:p,labelFormatter:m,labelClassName:w,formatter:j,color:W,nameKey:O,labelKey:S},G)=>{const{config:L}=ce(),n=c.useMemo(()=>{var f;if(x||!(s!=null&&s.length))return null;const[l]=s,P=`${S||l.dataKey||l.name||"value"}`,a=z(L,l,P),d=!S&&typeof p=="string"?((f=L[p])==null?void 0:f.label)||p:a==null?void 0:a.label;return m?e.jsx("div",{className:h("font-medium",w),children:m(d,s)}):d?e.jsx("div",{className:h("font-medium",w),children:d}):null},[p,m,s,x,w,L,S]);if(!r||!(s!=null&&s.length))return null;const V=s.length===1&&o!=="dot";return e.jsxs("div",{ref:G,className:h("grid min-w-[8rem] items-start gap-1.5 rounded-lg border border-border/50 bg-background px-2.5 py-1.5 text-xs shadow-xl",t),children:[V?null:n,e.jsx("div",{className:"grid gap-1.5",children:s.map((l,P)=>{const a=`${O||l.name||l.dataKey||"value"}`,d=z(L,l,a),f=W||l.payload.fill||l.color;return e.jsx("div",{className:h("flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5 [&>svg]:text-muted-foreground",o==="dot"&&"items-center"),children:j&&(l==null?void 0:l.value)!==void 0&&l.name?j(l.value,l.name,l,P,l.payload):e.jsxs(e.Fragment,{children:[d!=null&&d.icon?e.jsx(d.icon,{}):!g&&e.jsx("div",{className:h("shrink-0 rounded-[2px] border-[--color-border] bg-[--color-bg]",{"h-2.5 w-2.5":o==="dot","w-1":o==="line","w-0 border-[1.5px] border-dashed bg-transparent":o==="dashed","my-0.5":V&&o==="dashed"}),style:{"--color-bg":f,"--color-border":f}}),e.jsxs("div",{className:h("flex flex-1 justify-between leading-none",V?"items-end":"items-center"),children:[e.jsxs("div",{className:"grid gap-1.5",children:[V?n:null,e.jsx("span",{className:"text-muted-foreground",children:(d==null?void 0:d.label)||l.name})]}),l.value&&e.jsx("span",{className:"font-mono font-medium tabular-nums text-foreground",children:l.value.toLocaleStr
7ing()})]})]})},l.dataKey)})})]})});me.displayName="ChartTooltip";const ke=c.forwardRef(({className:r,hideIcon:s=!1,payload:t,verticalAlign:o="bottom",nameKey:x},g)=>{const{config:p}=ce();return t!=null&&t.length?e.jsx("div",{ref:g,className:h("flex items-center justify-center gap-4",o==="top"?"pb-3":"pt-3",r),children:t.map(m=>{const w=`${x||m.dataKey||"value"}`,j=z(p,m,w);return e.jsxs("div",{className:h("flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3 [&>svg]:text-muted-foreground"),children:[j!=null&&j.icon&&!s?e.jsx(j.icon,{}):e.jsx("div",{className:"h-2 w-2 shrink-0 rounded-[2px]",style:{backgroundColor:m.color}}),j==null?void 0:j.label]},m.value)})}):null});ke.displayName="ChartLegend";function z(r,s,t){if(typeof s!="object"||s===null)return;const o="payload"in s&&typeof s.payload=="object"&&s.payload!==null?s.payload:void 0;let x=t;return t in s&&typeof s[t]=="string"?x=s[t]:o&&t in o&&typeof o[t]=="string"&&(x=o[t]),x in r?r[x]:r[t]}const Es=()=>{const r=ye(),{toast:s}=ue(),{user:t,loading:o,signOut:x}=fe();ge();const[g,p]=c.useState([]),[m,w]=c.useState([]),[j,W]=c.useState(!0),[O,S]=c.useState(null);c.useEffect(()=>{!o&&!t&&(console.log("User not authenticated, redirecting to login"),r("/login"))},[t,o,r]),c.useEffect(()=>{t&&L()},[t]);const G=async()=>{try{await x(),s({title:"Logout realizado",description:"Você foi desconectado com sucesso."}),r("/login")}catch(a){console.error("Logout error:",a),s({title:"Erro no logout",description:"Tente novamente.",variant:"destructive"})}},L=async()=>{try{console.log("Fetching dashboard data...");const{data:a,error:d}=await se.from("demo_requests").select("*").order("created_at",{ascending:!1});if(d)throw console.error("Error fetching demo requests:",d),d;const{data:f,error:b}=await se.from("visits").select("*").order("created_at",{ascending:!1});if(b)throw console.error("Error fetching visits:",b),b;console.log("Demo requests fetched:",(a==null?void 0:a.length)||0),console.log("Visits fetched:",(f==null?void 0:f.length)||0),p(a||[]),w(f||[])}catch(a){console.error("Error fetching data:",a),S(a instanceof Error?a.message:"Erro desconhecido")}finally{W(!1)}},n=c.useMemo(()=>{const a=new Date,d=new Date(a.getTime()-7*24*60*60*1e3),f=new Date(a.getTime()-30*24*60*60*1e3),b=m.filter(i=>new Date(i.created_at)>=d),v=m.filter(i=>new Date(i.created_at)>=f),M=b.filter(i=>i.is_paid),A=b.filter(i=>!i.is_paid),X=Math.round(v.length/30*7),Y=Math.round(v.filter(i=>i.is_paid).length/30*7),J=Math.round(v.filter(i=>!i.is_paid).length/30*7),B=g.filter(i=>new Date(i.created_at)>=d),I=g.filter(i=>new Date(i.created_at)>=f),Q=Math.round(I.length/30*7),H=B.filter(i=>{const u=new Date(i.created_at),q=new Date(u.getTime()-60*60*1e3);return b.filter(N=>{const y=new Date(N.created_at);return y>=q&&y<=u&&N.is_paid}).length>0}),K=B.filter(i=>{const u=new Date(i.created_at),q=new Date(u.getTime()-60*60*1e3);return b.filter(N=>{const y=new Date(N.created_at);return y>=q&&y<=u&&N.is_paid}).length===0}),Z=Math.round(I.filter(i=>{const u=new Date(i.created_at),q=new Date(u.getTime()-60*60*1e3);return v.some($=>{const N=new Date($.created_at);return N>=q&&N<=u&&$.is_paid})}).length/30*7),ee=Math.round(I.filter(i=>{const u=new Date(i.created_at),q=new Date(u.getTime()-60*60*1e3);return!v.some(N=>{const y=new Date(N.created_at);return y>=q&&y<=u&&N.is_paid})}).length/30*7),xe=g.reduce((i,u)=>(i[u.origem]=(i[u.origem]||0)+1,i),{}),he=Object.entries(xe).map(([i,u])=>({origem:i,count:u}));return console.log("Métricas calculadas:",{totalRequests:B.length,paidRequests:H.length,freeRequests:K.length,sum:H.length+K.length}),{totalVisitsLast7Days:b.length,paidVisitsLast7Days:M.length,freeVisitsLast7Days:A.length,averageTotalVisits30Days:X,averagePaidVisits30Days:Y,averageFreeVisits30Days:J,requestsLast7Days:B.length,averageRequests30Days:Q,paidRequestsLast7Days:H.length,freeRequestsLast7Days:K.length,averagePaidRequests30Days:Z,averageFreeRequests30Days:ee,originData:he,totalVisitsTrend:b.length-X,paidVisitsTrend:M.length-Y,freeVisitsTrend:A.length-J,requestsTrend:B.length-Q,paidRequestsTrend:H.length-Z,freeRequestsTrend:K.length-ee}},[g,m]),V=a=>{const d=new Date(a.created_at),f=new Date(d.getTime()-60*60*1e3);return m.filter(v=>{const M=new Date(v.created_at);return M>=f&&M<=d&&v.is_paid}).length>0},l=a=>new Date(a).toLocaleDateString("pt-BR",{day:"2-digit",month:"2-digit",year:"numeric",hour:"2-digit",minute:"2-digit"}),P={count:{label:"Solicitações",color:"#DF5D6F"}};return o?e.jsx("div",{className:"min-h-screen bg-gray-50 flex items-center justify-center",children:e.jsx("div",{className:"text-xl",children:"Verificando autenticação..."})}):t?j?e.jsx("div",{className:"min-h-screen bg-gray-50 flex items-center justify-center",children:e.jsx("div",{className:"text-xl",children:"Carregando dashboard..."})}):O?e.jsx("div",{className:"min-h-screen bg-gray-50 flex items-center justify-center",children:e.jsxs("div",{className:"text-xl text-red-600",children:["Erro: ",O]})}):e.jsxs("div",{className:"min-h-screen bg-gray-50",children:[e.jsx("div",{className:"bg-white border-b border-gray-200",children:e.jsx("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8",children:e.jsxs("div",{className:"flex items-center justify-between h-16",children:[e.jsx("div",{className:"text-2xl font-bold",style:{color:"#DF5D6F"},children:"Vibe Saúde - Dashboard"}),e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsxs("span",{className:"text-sm text-gray-600",children:["Bem-vindo, ",t.email]}),e.jsxs(pe,{onClick:G,variant:"outline",size:"sm",className:"flex items-center space-x-2",children:[e.jsx(De,{className:"h-4 w-4"}),e.jsx("span",{children:"Sair"})]})]})]})})}),e.jsx("div",{className:"px-4 sm:px-6 lg:px-8",children:e.jsxs("div",{className:"max-w-7xl mx-auto py-8",children:[e.jsxs("div",{className:"mb-8",children:[e.jsx("h2",{className:"text-xl font-semibold text-gray-900 mb-4",children:"Visitas (7 dias)"}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:[e.jsxs(D,{children:[e.jsxs(T,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(_,{className:"text-sm font-medium",children:"Visitas Totais"}),e.jsx(Te,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(R,{children:[e.jsx("div",{className:"text-2xl font-bold",style:{color:"#DF5D6F"},children:n.totalVisitsLast7Days}),e.jsxs("div",{className:"flex items-center space-x-1 text-xs text-muted-foreground mt-1",children:[n.totalVisitsTrend>0?e.jsx(E,{className:"h-3 w-3 text-green-500"}):e.jsx(k,{className:"h-3 w-3 text-red-500"}),e.jsxs("span",{children:[n.totalVisitsTrend>0?"+":"",n.totalVisitsTrend," vs média"]})]})]})]}),e.jsxs(D,{children:[e.jsxs(T,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(_,{className:"text-sm font-medium",children:"Visitas Pagas"}),e.jsx(_e,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(R,{children:[e.jsx("div",{className:"text-2xl font-bold",style:{color:"#DF5D6F"},children:n.paidVisitsLast7Days}),e.jsxs("div",{className:"flex items-center space-x-1 text-xs text-muted-foreground mt-1",children:[n.paidVisitsTrend>0?e.jsx(E,{className:"h-3 w-3 text-green-500"}):e.jsx(k,{className:"h-3 w-3 text-red-500"}),e.jsxs("span",{children:[n.paidVisitsTrend>0?"+":"",n.paidVisitsTrend," vs média"]})]})]})]}),e.jsxs(D,{children:[e.jsxs(T,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(_,{className:"text-sm font-medium",children:"Visitas Gratuitas"}),e.jsx(re,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(R,{children:[e.jsx("div",{className:"text-2xl font-bold",style:{color:"#DF5D6F"},children:n.freeVisitsLast7Days}),e.jsxs("div",{className:"flex items-center space-x-1 text-xs text-muted-foreground mt-1",children:[n.freeVisitsTrend>0?e.jsx(E,{className:"h-3 w-3 text-green-500"}):e.jsx(k,{className:"h-3 w-3 text-red-500"}),e.jsxs("span",{children:[n.freeVisitsTrend>0?"+":"",n.freeVisitsTrend," vs média"]})]})]})]})]})]}),e.jsxs("div",{className:"mb-8",children:[e.jsx("h2",{className:"text-xl font-semibold text-gray-900 mb-4",children:"Solicitações (7 dias)"}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:[e.jsxs(D,{children:[e.jsxs(T,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(_,{className:"text-sm font-medium",children:"Solicitações Totais"}),e.jsx(Re,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(R,{children:[e.jsx("div",{className:"text-2xl font-bold",style:{color:"#DF5D6F"},children:n.requestsLast7Days}),e.jsxs("div",{className:"flex items-center space-x-1 text-xs text-muted-foreground mt-1",children:[n.requestsTrend>0?e.jsx(E,{className:"h-3 w-3 text-green-500"}):e.jsx(k,{className:"h-3 w-3 text-red-500"}),e.jsxs("span",{children:[n.requestsTrend>0?"+":"",n.requestsTrend," vs média"]})]})]})]}),e.jsxs(D,{children:[e.jsxs(T,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(_,{className:"text-sm font-medium",children:"Solicitações Pagas"}),e.jsx(Ve,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(R,{children:[e.jsx("div",{className:"text-2xl font-bold",style:{color:"#DF5D6F"},children:n.paidRequestsLast7Days}),e.jsxs("div",{className:"flex items-center space-x-1 text-xs text-muted-foreground mt-1",children:[n.paidRequestsTrend>0?e.jsx(E,{className:"h-3 w-3 text-green-500"}):e.jsx(k,{className:"h-3 w-3 text-red-500"}),e.jsxs("span",{children:[n.paidRequestsTrend>0?"+":"",n.paidRequestsTrend," vs média"]})]})]})]}),e.jsxs(D,{children:[e.jsxs(T,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(_,{className:"text-sm font-medium",children:"Solicitações Gratuitas"}),e.jsx(re,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(R,{children:[e.jsx("div",{className:"text-2xl font-bold",style:{color:"#DF5D6F"},children:n.freeRequestsLast7Days}),e.jsxs("div",{className:"flex items-center space-x-1 text-xs text-muted-foreground mt-1",children:[n.freeRequestsTrend>0?e.jsx(E,{className:"h-3 w-3 text-green-500"}):e.jsx(k,{className:"h-3 w-3 text-red-500"}),e.jsxs("span",{children:[n.freeRequestsTrend>0?"+":"",n.freeRequestsTrend," vs média"]})]})]})]})]})]}),e.jsx("div",{className:"mb-8",children:e.jsxs(D,{children:[e.jsxs(T,{children:[e.jsx(_,{style:{color:"#DF5D6F"},children:"Solicitações por Origem"}),e.jsx(te,{children:"Distribuição das solicitações por página de origem"})]}),e.jsx(R,{children:e.jsx(de,{config:P,className:"h-[300px]",children:e.jsx(ae,{width:"100%",height:"100%",children:e.jsxs(be,{data:n.originData,children:[e.jsx(Ne,{dataKey:"origem"}),e.jsx(we,{}
7),e.jsx(Ee,{content:e.jsx(me,{})}),e.jsx(ve,{dataKey:"count",fill:"#DF5D6F"})]})})})})]})}),e.jsxs(D,{children:[e.jsxs(T,{children:[e.jsx(_,{className:"text-2xl",style:{color:"#DF5D6F"},children:"Solicitações Detalhadas"}),e.jsx(te,{children:"Lista completa de todas as solicitações recebidas"})]}),e.jsx(R,{children:g.length===0?e.jsx("div",{className:"text-center py-8 text-gray-500",children:"Nenhuma solicitação de demo encontrada."}):e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(ie,{children:[e.jsx(ne,{children:e.jsxs(U,{children:[e.jsx(C,{children:"Data"}),e.jsx(C,{children:"Email"}),e.jsx(C,{children:"Empresa"}),e.jsx(C,{children:"Origem"}),e.jsx(C,{children:"Tipo"}),e.jsx(C,{children:"Mensagem"})]})}),e.jsx(oe,{children:g.map(a=>e.jsxs(U,{children:[e.jsx(F,{className:"whitespace-nowrap",children:l(a.created_at)}),e.jsx(F,{className:"font-medium",children:a.email_corporativo}),e.jsx(F,{children:a.nome_empresa}),e.jsx(F,{children:e.jsx("span",{className:"px-2 py-1 bg-gray-100 rounded text-sm",children:a.origem})}),e.jsx(F,{children:e.jsx("span",{className:`px-2 py-1 rounded text-sm ${V(a)?"bg-green-100 text-green-800":"bg-blue-100 text-blue-800"}`,children:V(a)?"Pago":"Gratuito"})}),e.jsx(F,{className:"max-w-xs",children:e.jsx("div",{className:"truncate",title:a.mensagem,children:a.mensagem||"-"})})]},a.id))})]})})})]})]})})]}):null};export{Es 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.