1import{u as v,r as k,j as e}from"./react-vendor-BorBU4Bs.js";import{a as j}from"./query-vendor-dlntIC_S.js";import{u as w,s as g,m as x,p as m,B as C,A as R,K as l,an as S,ao as M,dC as T,M as d,N as _,O as B,Q as f,U as r,V as H,W as o,b8 as L,aX as h}from"./index-DkhxOMdR.js";import{R as K,L as A,C as F,X as W,Y as q,T as z,b as n}from"./charts-vendor-BxJanGhU.js";import"./radix-vendor-CazrR58L.js";import"./supabase-vendor-BxTHC7hl.js";import"./xlsx-vendor-DOnNs5_d.js";import"./qr-vendor-Ca1-Dxvv.js";function V(){const N=v(),{isAutoRefreshEnabled:p}=w(),{data:i=[]}=j({queryKey:["sync-gdrive-stats"],queryFn:async()=>{const{data:s,error:a}=await g.from("gdrive_sync_stats").select("*").order("run_at",{ascending:!1}).limit(30);if(a)throw a;return s},refetchOnWindowFocus:p("dashboard")}),{data:u=0}=j({queryKey:["sync-gdrive-processed-count"],queryFn:async()=>{const{count:s,error:a}=await g.from("gdrive_processed_files").select("*",{count:"exact",head:!0});if(a)throw a;return s||0},refetchOnWindowFocus:p("dashboard")}),t=k.useMemo(()=>{const s=i[0];if(!s)return null;const a=Math.max(0,s.total-s.remaining),b=s.total>0?Math.round(a/s.total*100):0,y=[...i].slice(0,20).reverse().map(c=>({execucao:x(m(c.run_at),"dd/MM HH:mm",{locale:h}),processados:c.processed_count,importados:c.imported,ignorados:c.skipped,erros:c.errors}));return{latest:s,processed:a,pct:b,chart:y}},[i]);return e.jsxs("div",{className:"animate-fade-in",children:[e.jsx("div",{className:"flex items-center gap-2 mb-4",children:e.jsxs(C,{variant:"ghost",size:"sm",onClick:()=>N("/configuracoes"),children:[e.jsx(R,{className:"h-4 w-4 mr-1"})," Voltar"]})}),e.jsxs(l,{children:[e.jsx(S,{children:e.jsxs(M,{className:"text-base flex items-center gap-2",children:[e.jsx(T,{className:"h-4 w-4 text-primary"}),"Sincronização Google Drive XML"]})}),e.jsx(d,{className:"space-y-6",children:t?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[e.jsx(l,{className:"border-l-4 border-l-blue-500",children:e.jsxs(d,{className:"pt-4 pb-3",children:[e.jsx("p",{className:"text-xs text-muted-foreground uppercase tracking-wide",children:"Total no Drive"}),e.jsx("p",{className:"text-2xl font-bold mt-1",children:t.latest.total.toLocaleString("pt-BR")})]})}),e.jsx(l,{className:"border-l-4 border-l-emerald-500",children:e.jsxs(d,{className:"pt-4 pb-3",children:[e.jsx("p",{className:"text-xs text-muted-foreground uppercase tracking-wide",children:"Processados"}),e.jsx("p",{className:"text-2xl font-bold mt-1",children:t.processed.toLocaleString("pt-BR")}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[t.pct,"% do total"]})]})}),e.jsx(l,{className:"border-l-4 border-l-rose-500",children:e.jsxs(d,{className:"pt-4 pb-3",children:[e.jsx("p",{className:"text-xs text-muted-foreground uppercase tracking-wide",children:"Faltam"}),e.jsx("p",{className:"text-2xl font-bold mt-1",children:t.latest.remaining.toLocaleString("pt-BR")})]})}),e.jsx(l,{className:"border-l-4 border-l-amber-500",children:e.jsxs(d,{className:"pt-4 pb-3",children:[e.jsx("p",{className:"text-xs text-muted-foreground uppercase tracking-wide",children:"Ãltima execução"}),e.jsx("p",{className:"text-lg font-bold mt-1",children:x(m(t.latest.run_at),"dd/MM/yyyy HH:mm",{locale:h})})]})})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium mb-2",children:"Arquivos processados por execução"}),t.chart.length>0?e.jsx(K,{width:"100%",height:220,children:e.jsxs(A,{data:t.chart,children:[e.jsx(F,{strokeDasharray:"3 3",className:"stroke-muted"}),e.jsx(W,{dataKey:"execucao",className:"text-xs",tick:{fontSize:11}}),e.jsx(q,{allowDecimals:!1,tick:{fontSize:11}}),e.jsx(z,{contentStyle:{borderRadius:"8px",fontSize:"12px"},labelFormatter:s=>`Execução: ${s}`}),e.jsx(n,{type:"monotone",dataKey:"processados",stroke:"hsl(var(--primary))",strokeWidth:2,dot:!1}),e.jsx(n,{type:"monotone",dataKey:"importados",stroke:"hsl(142, 60%, 40%)",strokeWidth:2,dot:!1}),e.jsx(n,{type:"monotone",dataKey:"ignorados",stroke:"hsl(40, 90%, 50%)",strokeWidth:2,dot:!1}),e.jsx(n,{type:"monotone",dataKey:"erros",stroke:"hsl(0, 72%, 51%)",strokeWidth:2,dot:!1})]})}):e.jsx("p",{className:"text-center text-muted-foreground py-8",children:"Nenhuma execução registrada"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium mb-2",children:"Ãltimas execuções"}),e.jsxs(_,{children:[e.jsx(B,{children:e.jsxs(f,{className:"table-header",children:[e.jsx(r,{children:"Execução"}),e.jsx(r,{className:"text-right",children:"Processados"}),e.jsx(r,{className:"text-right",children:"Importados"}),e.jsx(r,{className:"text-right",children:"Backfilled"}),e.jsx(r,{className:"text-right",children:"Ignorados"}),e.jsx(r,{className:"text-right",children:"Erros"}),e.jsx(r,{className:"text-right",children:"Restam"})]})}),e.jsx(H,{children:i.slice(0,10).map(s=>e.jsxs(f,{children:[e.jsx(o,{className:"text-xs",children:x(m(s.run_at),"dd/MM/yyyy HH:mm",{locale:h})}),e.jsx(o,{className:"text-right font-medium",children:s.processed_count}),e.jsx(o,{className:"text-right text-emerald-600",children:s.imported}),e.jsx(o,{className:"text-right text-blue-600",children:s.backfilled}),e.jsx(o,{className:"text-right text-amber-600",children:s.skipped}),e.jsx(o,{className:"text-right text-rose-600",children:s.errors}),e.jsx(o,{className:"text-right",children:s.remaining})]},s.id))})]})]})]}):e.jsxs("div",{className:"flex flex-col items-center justify-center py-10 text-center gap-3",children:[e.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-full bg-muted",children:e.jsx(L,{className:"h-5 w-5 text-muted-foreground"})}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Nenhuma execução de sincronização registrada ainda."}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"O painel será preenchido automaticamente na próxima execução (a cada hora)."}),u>0&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:[u.toLocaleStr
1ing("pt-BR")," arquivos já constam como processados no banco de dados."]})]})})]})]})}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.