vendor: 4,358 bytes, lines 1-7
1import{h as m,o as e,t as b,x as W,y as X,w as _,B as Y}from"./index-D-GBr4OT.js";import{C as T,a as J}from"./ClientLayout-KwFXJIcx.js";import{C as S,b as G,c as I,a as k}from"./card-xgnto5D_.js";import{B as K}from"./badge-u3waVycK.js";import{S as Q,a as Z,b as ee,c as se,d as te}from"./select-c7EgGzNU.js";import{N as ae,R as re,P,M as R,X as $,Y as D,J as A}from"./AreaChart-D31U-eFK.js";import{C as ne}from"./cpu-Cy3W0Nn5.js";import{M as le}from"./memory-stick-DUCbOs-K.js";import{A as q}from"./activity-DvoJRyey.js";import{W as ce}from"./wifi-09jpmHQe.js";import{S as oe}from"./server-BreT6a2k.js";import{S as ie}from"./shopping-cart-sVwxESaO.js";import"./sidebar-DGkNvcst.js";import"./input-D6LAVBj1.js";import"./house-B_xG4xn5.js";import"./ThemeToggle-CpFdVCpJ.js";import"./index-BdQq_4o_.js";import"./index-Ch4cfzOk.js";import"./index-BCaDnGsR.js";import"./chevron-down-Dx4NE3AC.js";import"./check-B7suo32t.js";const de={light:"",dark:".dark"},U=m.createContext(null);function V(){const n=m.useContext(U);if(!n)throw new Error("useChart must be used within a <ChartContainer />");return n}const M=m.forwardRef(({id:n,className:s,children:t,config:a,...r},x)=>{const o=m.useId(),i=`chart-${n||o.replace(/:/g,"")}`;return e.jsx(U.Provider,{value:{config:a},children:e.jsxs("div",{"data-chart":i,ref:x,className:b("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),...r,children:[e.jsx(xe,{id:i,config:a}),e.jsx(re,{children:t})]})})});M.displayName="Chart";const xe=({id:n,config:s})=>{const t=Object.entries(s).filter(([a,r])=>r.theme||r.color);return t.length?e.jsx("style",{dangerouslySetInnerHTML:{__html:Object.entries(de).map(([a,r])=>` 2${r} [data-chart=${n}] { 3${t.map(([x,o])=>{var f;const i=((f=o.theme)==null?void 0:f[a])||o.color;return i?` --color-${x}: ${i};`:null}).join(` 4`)} 5} 6`).join(` 7`)}}):null},B=ae,L=m.forwardRef(({active:n,payload:s,className:t,indicator:a="dot",hideLabel:r=!1,hideIndicator:x=!1,label:o,labelFormatter:i,labelClassName:f,formatter:h,color:C,nameKey:l,labelKey:u},d)=>{const{config:j}=V(),N=m.useMemo(()=>{var y;if(r||!(s!=null&&s.length))return null;const[c]=s,g=`${u||c.dataKey||c.name||"value"}`,w=O(j,c,g),p=!u&&typeof o=="string"?((y=j[o])==null?void 0:y.label)||o:w==null?void 0:w.label;return i?e.jsx("div",{className:b("font-medium",f),children:i(p,s)}):p?e.jsx("div",{className:b("font-medium",f),children:p}):null},[o,i,s,r,f,j,u]);if(!n||!(s!=null&&s.length))return null;const v=s.length===1&&a!=="dot";return e.jsxs("div",{ref:d,className:b("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((c,g)=>{const w=`${l||c.name||c.dataKey||"value"}`,p=O(j,c,w),y=C||c.payload.fill||c.color;return e.jsx("div",{className:b("flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5 [&>svg]:text-muted-foreground",a==="dot"&&"items-center"),children:h&&(c==null?void 0:c.value)!==void 0&&c.name?h(c.value,c.name,c,g,c.payload):e.jsxs(e.Fragment,{children:[p!=null&&p.icon?e.jsx(p.icon,{}):!x&&e.jsx("div",{className:b("shrink-0 rounded-[2px] border-[--color-border] bg-[--color-bg]",{"h-2.5 w-2.5":a==="dot","w-1":a==="line","w-0 border-[1.5px] border-dashed bg-transparent":a==="dashed","my-0.5":v&&a==="dashed"}),style:{"--color-bg":y,"--color-border":y}}),e.jsxs("div",{className:b("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:(p==null?void 0:p.label)||c.name})]}),c.value&&e.jsx("span",{className:"font-mono font-medium tabular-nums text-foreground",children:c.value.toLocaleStr
7ing()})]})]})},c.dataKey)})})]})});L.displayName="ChartTooltip";const me=m.forwardRef(({className:n,hideIcon:s=!1,payload:t,verticalAlign:a="bottom",nameKey:r},x)=>{const{config:o}=V();return t!=null&&t.length?e.jsx("div",{ref:x,className:b("flex items-center justify-center gap-4",a==="top"?"pb-3":"pt-3",n),children:t.map(i=>{const f=`${r||i.dataKey||"value"}`,h=O(o,i,f);return e.jsxs("div",{className:b("flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3 [&>svg]:text-muted-foreground"),children:[h!=null&&h.icon&&!s?e.jsx(h.icon,{}):e.jsx("div",{className:"h-2 w-2 shrink-0 rounded-[2px]",style:{backgroundColor:i.color}}),h==null?void 0:h.label]},i.value)})}):null});me.displayName="ChartLegend";function O(n,s,t){if(typeof s!="object"||s===null)return;const a="payload"in s&&typeof s.payload=="object"&&s.payload!==null?s.payload:void 0;let r=t;return t in s&&typeof s[t]=="string"?r=s[t]:a&&t in a&&typeof a[t]=="string"&&(r=a[t]),r in n?n[r]:n[t]}const z=n=>{const s=[],t=new Date;for(let a=n;a>=0;a--){const x=`${new Date(t.getTime()-a*36e5).getHours().toString().padStart(2,"0")}:00`,o=20+Math.sin(a*.5)*15;s.push({time:x,cpu:Math.min(100,Math.max(5,o+Math.random()*30)),ram:Math.min(100,Math.max(15,40+Math.sin(a*.3)*10+Math.random()*15)),bandwidth:Math.max(0,50+Math.sin(a*.7)*30+Math.random()*40)})}return s},E={cpu:{label:"CPU (%)",color:"hsl(var(--primary))"},ram:{label:"RAM (%)",color:"hsl(var(--accent))"},bandwidth:{label:"Bandwidth (Mbps)",color:"hsl(142 71% 45%)"}},he=({instances:n})=>{var C,l,u,d,j,N,v,c;const s=n.filter(g=>g.status==="active"),[t,a]=m.useState(((C=s[0])==null?void 0:C.id)||""),[r,x]=m.useState(()=>z(23));if(m.useEffect(()=>{if(!t)return;x(z(23));const g=setInterval(()=>{x(w=>{const p=new Date,y=`${p.getHours().toString().padStart(2,"0")}:${p.getMinutes().toString().padStart(2,"0")}`,F=20+Math.random()*30,H={time:y,cpu:Math.min(100,Math.max(5,F+Math.random()*20)),ram:Math.min(100,Math.max(15,40+Math.random()*20)),bandwidth:Math.max(0,50+Math.random()*60)};return[...w.slice(1),H]})},3e4);return()=>clearInterval(g)},[t]),s.length===0)return null;const o=s.find(g=>g.id===t),i=((u=(l=r[r.length-1])==null?void 0:l.cpu)==null?void 0:u.toFixed(1))||"0",f=((j=(d=r[r.length-1])==null?void 0:d.ram)==null?void 0:j.toFixed(1))||"0",h=((v=(N=r[r.length-1])==null?void 0:N.bandwidth)==null?void 0:v.toFixed(0))||"0";return e.jsxs(S,{className:"glass",children:[e.jsxs(G,{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3",children:[e.jsx(I,{className:"text-lg",children:"Monitoramento de Uso"}),s.length>1&&e.jsxs(Q,{value:t,onValueChange:a,children:[e.jsx(Z,{className:"w-[200px]",children:e.jsx(ee,{placeholder:"Selecionar VPS"})}),e.jsx(se,{children:s.map(g=>e.jsx(te,{value:g.id,children:g.hostname},g.id))})]})]}),e.jsxs(k,{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2 p-3 rounded-lg bg-primary/5 border border-primary/10",children:[e.jsx(ne,{className:"w-4 h-4 text-primary"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wide",children:"CPU"}),e.jsxs("p",{className:"text-lg font-bold text-primary",children:[i,"%"]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 p-3 rounded-lg bg-accent/5 border border-accent/10",children:[e.jsx(le,{className:"w-4 h-4 text-accent"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wide",children:"RAM"}),e.jsxs("p",{className:"text-lg font-bold text-accent",children:[f,"%"]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 p-3 rounded-lg bg-emerald-500/5 border border-emerald-500/10",children:[e.jsx(q,{className:"w-4 h-4 text-emerald-500"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wide",children:"Rede"}),e.jsxs("p",{className:"text-lg font-bold text-emerald-500",children:[h," Mbps"]})]})]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-2 font-medium",children:"CPU â Ãltimas 24h"}),e.jsx(M,{config:E,className:"h-[140px] w-full",children:e.jsxs(P,{data:r,children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"cpuGrad",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"hsl(var(--primary))",stopOpacity:.3}),e.jsx("stop",{offset:"100%",stopColor:"hsl(var(--primary))",stopOpacity:0})]})}),e.jsx(R,{strokeDasharray:"3 3",className:"stroke-border/30"}),e.jsx($,{dataKey:"time",tick:{fontSize:10}
7,tickLine:!1,axisLine:!1,interval:"preserveStartEnd"}),e.jsx(D,{domain:[0,100],tick:{fontSize:10},tickLine:!1,axisLine:!1,width:30}),e.jsx(B,{content:e.jsx(L,{})}),e.jsx(A,{type:"monotone",dataKey:"cpu",stroke:"hsl(var(--primary))",fill:"url(#cpuGrad)",strokeWidth:2})]})})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-2 font-medium",children:"RAM â Ãltimas 24h"}),e.jsx(M,{config:E,className:"h-[140px] w-full",children:e.jsxs(P,{data:r,children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"ramGrad",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"hsl(var(--accent))",stopOpacity:.3}),e.jsx("stop",{offset:"100%",stopColor:"hsl(var(--accent))",stopOpacity:0})]})}),e.jsx(R,{strokeDasharray:"3 3",className:"stroke-border/30"}),e.jsx($,{dataKey:"time",tick:{fontSize:10},tickLine:!1,axisLine:!1,interval:"preserveStartEnd"}),e.jsx(D,{domain:[0,100],tick:{fontSize:10},tickLine:!1,axisLine:!1,width:30}),e.jsx(B,{content:e.jsx(L,{})}),e.jsx(A,{type:"monotone",dataKey:"ram",stroke:"hsl(var(--accent))",fill:"url(#ramGrad)",strokeWidth:2})]})})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-2 font-medium",children:"Bandwidth â Ãltimas 24h"}),e.jsx(M,{config:E,className:"h-[140px] w-full",children:e.jsxs(P,{data:r,children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"bwGrad",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"hsl(142 71% 45%)",stopOpacity:.3}),e.jsx("stop",{offset:"100%",stopColor:"hsl(142 71% 45%)",stopOpacity:0})]})}),e.jsx(R,{strokeDasharray:"3 3",className:"stroke-border/30"}),e.jsx($,{dataKey:"time",tick:{fontSize:10},tickLine:!1,axisLine:!1,interval:"preserveStartEnd"}),e.jsx(D,{tick:{fontSize:10},tickLine:!1,axisLine:!1,width:35}),e.jsx(B,{content:e.jsx(L,{})}),e.jsx(A,{type:"monotone",dataKey:"bandwidth",stroke:"hsl(142 71% 45%)",fill:"url(#bwGrad)",strokeWidth:2})]})})]}),e.jsxs("p",{className:"text-[10px] text-muted-foreground text-center",children:[o?`${o.hostname} · ${(c=o.vps_plans)==null?void 0:c.name}`:""," · Dados simulados · Atualiza a cada 30s"]})]})]})},ue={active:{label:"Ativo",variant:"default"},pending:{label:"Pendente",variant:"secondary"},provisioning:{label:"Provisionando",variant:"secondary"},suspended:{label:"Suspenso",variant:"destructive"},error:{label:"Erro",variant:"destructive"},cancelled:{label:"Cancelado",variant:"outline"}},pe={pending:{label:"Pendente",variant:"secondary"},paid:{label:"Pago",variant:"default"},failed:{label:"Falhou",variant:"destructive"},cancelled:{label:"Cancelado",variant:"destructive"},refunded:{label:"Reembolsado",variant:"outline"}},Ge=()=>{const{user:n}=W(),s=X(),[t,a]=m.useState([]),[r,x]=m.useState([]),[o,i]=m.useState(!0),[f,h]=m.useState(!1);m.useEffect(()=>{if(!n)return;(async()=>{const[d,j]=await Promise.all([_.from("vps_instances").select("*, vps_plans(name, vcpu, ram_gb, ssd_gb)").eq("user_id",n.id).order("created_at",{ascending:!1}),_.from("orders").select("*, vps_plans(name)").eq("user_id",n.id).order("created_at",{ascending:!1}).limit(5)]);a(d.data||[]),x(j.data||[]),i(!1)})();const u=_.channel("client-dashboard").on("postgres_changes",{event:"*",schema:"public",table:"vps_instances",filter:`user_id=eq.${n.id}`},async()=>{const{data:d}=await _.from("vps_instances").select("*, vps_plans(name, vcpu, ram_gb, ssd_gb)").eq("user_id",n.id).order("created_at",{ascending:!1});a(d||[])}).on("postgres_changes",{event:"*",schema:"public",table:"orders",filter:`user_id=eq.${n.id}`},async()=>{const{data:d}=await _.from("orders").select("*, vps_plans(name)").eq("user_id",n.id).order("created_at",{ascending:!1}).limit(5);x(d||[])}).subscribe(d=>{h(d==="SUBSCRIBED")});return()=>{_.removeChannel(u)}},[n]);const C=t.filter(l=>l.status==="active").length;return o?e.jsx(T,{children:e.jsx("div",{className:"flex items-center justify-center h-64 text-muted-foreground animate-pulse",children:"Carregando..."})}):e.jsx(T,{children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h1",{className:"font-heading text-2xl font-bold",children:"Meu Painel"}),e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[e.jsx(ce,{className:`w-3.5 h-3.5 ${f?"text-green-500":"text-destructive"}`}),f?"Tempo real":"Reconectando..."]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[e.jsx(S,{className:"glass",children:e.jsxs(k,{className:"flex items-center gap-4 p-5",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-primary/10 flex items-center justify-center",children:e.jsx(oe,{className:"w-5 h-5 text-primary"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Servidores"}),e.jsx("p",{className:"text-xl font-bold",children:t.length})]})]})}),e.jsx(S,{className:"glass",children:e.jsxs(k,{className:"flex items-center gap-4 p-5",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-accent/10 flex items-center justify-center",children:e.jsx(q,{className:"w-5 h-5 text-accent"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Ativos"}),e.jsx("p",{className:"text-xl font-bold",children:C})]})]})}),e.jsx(S,{className:"glass",children:e.jsxs(k,{className:"flex items-center gap-4 p-5",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-secondary flex items-center justify-center",children:e.jsx(ie,{className:"w-5 h-5 text-secondary-foreground"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Pedidos"}),e.jsx("p",{className:"text-xl font-bold",children:r.length})]})]})})]}),e.jsx(he,{instances:t}),e.jsxs(S,{className:"glass",children:[e.jsx(G,{children:e.jsx(I,{className:"text-lg",children:"Meus Servidores"})}),e.jsx(k,{children:t.length===0?e.jsxs("div",{className:"text-center py-6 space-y-3",children:[e.jsx("p",{className:"text-muted-foreground text-sm",children:"Nenhum servidor contratado ainda."}),e.jsxs(Y,{variant:"hero",size:"sm",onClick:()=>s("/cliente/contratar"),children:[e.jsx(J,{className:"w-4 h-4 mr-1"})," Contratar meu primeiro VPS"]})]}):e.jsx("div",{className:"space-y-3",children:t.map(l=>{var d,j,N,v;const u=ue[l.status]||{label:l.status,variant:"outline"};return e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-2 p-4 rounded-lg bg-secondary/30 border border-border/50 transition-all duration-300",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"font-medium",children:l.hostname}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[(d=l.vps_plans)==null?void 0:d.name," · ",(j=l.vps_plans)==null?void 0:j.vcpu," vCPU · ",(N=l.vps_plans)==null?void 0:N.ram_gb," GB RAM · ",(v=l.vps_plans)==null?void 0:v.ssd_gb," GB SSD"]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["IP: ",l.ip_address||"Aguardando"," · Região: ",l.region," · OS: ",l.os]})]}),e.jsx(K,{variant:u.variant,children:u.label})]},l.id)})})})]}),e.jsxs(S,{className:"glass",children:[e.jsx(G,{children:e.jsx(I,{className:"text-lg",children:"Ãltimos Pedidos"})}),e.jsx(k,{children:r.length===0?e.jsx("p",{className:"text-muted-foreground text-sm",children:"Nenhum pedido encontrado."}):e.jsx("div",{className:"space-y-3",children:r.map(l=>{var d;const u=pe[l.status]||{label:l.status,variant:"outline"};return e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-2 p-4 rounded-lg bg-secondary/30 border border-border/50 transition-all duration-300",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"font-medium",children:((d=l.vps_plans)==null?void 0:d.name)||"Plano"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[new Date(l.created_at).toLocaleDateString("pt-BR")," · R$ ",Number(l.amount).toFixed(2)]})]}),e.jsx(K,{variant:u.variant,children:u.label})]},l.id)})})})]})]})})};export{Ge 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.