1import{a,j as e}from"./vendor-framer-motion-DgxRQIHL.js";import{P as n}from"./PageHeader-BfXJ05vh.js";import{l as i}from"./vendor-firebase-U95O8hiF.js";import{m as c,z as m}from"./index-9GEQNrq5.js";import"./house-BOiQ6NzE.js";import"./vendor-editor-D77TyNkE.js";import"./vendor-pdf-DqDRg8pW.js";import"./vendor-charts-IsSz2KDH.js";async function x(t=30){const r=await i(c,"getFinOpsAiUsageV2")({days:t});if(!r.data)throw new Error("Resposta vazia do servidor FinOps.");return r.data}const v=()=>{const[t,o]=a.useState(null),[r,d]=a.useState(!0),l=a.useCallback(async()=>{d(!0);try{const s=await x(30);o(s)}catch(s){console.error(s),m.error("Não foi possÃvel carregar os dados FinOps."),o(null)}finally{d(!1)}},[]);return a.useEffect(()=>{l()},[l]),e.jsxs("div",{className:"mx-auto max-w-5xl space-y-6 p-4 md:p-8",children:[e.jsx(n,{title:"FinOps â uso de IA",subtitle:"Custos estimados (USD) e alertas por organização. Somente leitura.",backTo:"/dashboard"}),r&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"Carregandoâ¦"}),!r&&t&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-4 rounded-2xl border border-border bg-card p-4 md:grid-cols-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs uppercase text-muted-foreground",children:"PerÃodo"}),e.jsxs("p",{className:"text-sm font-medium",children:[t.startDate," â ",t.endDate]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs uppercase text-muted-foreground",children:"Custo total (est.)"}),e.jsxs("p",{className:"text-lg font-semibold text-[var(--text-emphasis)]",children:["US$ ",t.totalCostUSD.toFixed(4)]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs uppercase text-muted-foreground",children:"Docs diários"}),e.jsx("p",{className:"text-sm font-medium",children:t.dailyDocCount})]})]}),e.jsxs("section",{className:"rounded-2xl border border-border bg-card p-4",children:[e.jsx("h2",{className:"mb-3 text-sm font-semibold text-[var(--text-emphasis)]",children:"Top organizações por custo"}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-left text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-border text-muted-foreground",children:[e.jsx("th",{className:"py-2 pr-4",children:"Organização"}),e.jsx("th",{className:"py-2 pr-4",children:"Custo USD"}),e.jsx("th",{className:"py-2",children:"Chamadas"})]})}),e.jsxs("tbody",{children:[t.topOrgs.map(s=>e.jsxs("tr",{className:"border-b border-border/60",children:[e.jsx("td",{className:"py-2 pr-4 font-mono text-xs",children:s.orgId}),e.jsx("td",{className:"py-2 pr-4",children:s.costUSD.toFixed(4)}),e.jsx("td",{className:"py-2",children:s.callCount})]},s.orgId)),t.topOrgs.length===0&&e.jsx("tr",{children:e.jsx("td",{colSpan:3,className:"py-4 text-muted-foreground",children:"Nenhum dado agregado ainda (coleções finops_ai_*)."})})]})]})})]}),e.jsxs("section",{className:"rounded-2xl border border-border bg-card p-4",children:[e.jsx("h2",{className:"mb-3 text-sm font-semibold text-[var(--text-emphasis)]",children:"Alertas recentes"}),e.jsxs("ul",{className:"space-y-2 text-sm",children:[t.recentAlerts.map(s=>e.jsxs("li",{className:"rounded-lg border border-border/80 bg-muted/30 p-3 font-mono text-xs",children:[e.jsx("span",{className:"font-semibold text-[var(--text-emphasis)]",children:String(s.level??"â")})," â ",String(s.type??""),s.orgId!=null?` â org ${String(s.orgId)}`:""]},String(s.id))),t.recentAlerts.length===0&&e.jsx("li",{className:"text-muted-foreground",children:"Nenhum alerta registrado."})]})]})]})]})};export{v 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.