1/*! For license information please see 151.108a9e2d.chunk.js.LICENSE.txt */ 2"use strict";(globalThis.webpackChunkfrontend=globalThis.webpackChunkfrontend||[]).push([[151],{9151(e,t,s){s.r(t),s.d(t,{default:()=>Y});var a=s(5043),i=s(6752),r=s(5271),n=s(1180),l=s(877),o=s(7734),c=s(2185),d=s(6026),x=s(3670),m=s(2770),p=s(6992),h=s(6102),u=s(7869),w=s(7856),b=s(7010),j=s(7899),g=s(5692),f=s(6099),N=s(516);const v=(0,s(7784).A)("chart-no-axes-column",[["line",{x1:"18",x2:"18",y1:"20",y2:"10",key:"1xfpm4"}],["line",{x1:"12",x2:"12",y1:"20",y2:"4",key:"be30l9"}],["line",{x1:"6",x2:"6",y1:"20",y2:"14",key:"1r4le6"}]]);var _=s(3165),y=s(7118),E=s(4919),A=s(3172),C=s(6963),R=s(7108),P=s(5087),T=s(929),I=s(2626),F=s(3639),S=s(5327),k=s(4669),O=s(5731),L=s(2787),V=s(9748),$=s(579);const D={NODE_ENV:"production",PUBLIC_URL:"",WDS_SOCKET_HOST:void 0,WDS_SOCKET_PATH:void 0,WDS_SOCKET_PORT:void 0,FAST_REFRESH:!0,REACT_APP_VERCEL_GIT_COMMIT_AUTHOR_NAME:"",REACT_APP_VERCEL_GIT_PROVIDER:"",REACT_APP_VERCEL_PROJECT_ID:"prj_zhpn4GXuyIWVvlr6ohV1quFNCWJ3",REACT_APP_VERCEL_OBSERVABILITY_CLIENT_CONFIG:'{"analytics":{"scriptSrc":"2bdc0186909e7611/script.js","viewEndpoint":"2bdc0186909e7611/view","eventEndpoint":"2bdc0186909e7611/event","sessionEndpoint":"2bdc0186909e7611/session"},"speedInsights":{"scriptSrc":"a3d17884bf1bf680/script.js","endpoint":"a3d17884bf1bf680/vitals"}}',REACT_APP_VERCEL_GIT_PULL_REQUEST_ID:"",REACT_APP_VERCEL_GIT_COMMIT_MESSAGE:"",REACT_APP_SUPABASE_URL:"https://uuvsbgxrndwcnudctjlw.supabase.co",REACT_APP_VERCEL_DEPLOYMENT_ID:"dpl_7zcTmUPjFH7rmbTyz6ffMUdJNQ9k",REACT_APP_VERCEL_GIT_REPO_SLUG:"",REACT_APP_VERCEL_TARGET_ENV:"production",REACT_APP_VERCEL_GIT_COMMIT_SHA:"",REACT_APP_ADMIN_EMAILS:"[email protected]\n",REACT_APP_VERCEL_ENV:"production",REACT_APP_VERCEL_GIT_COMMIT_REF:"",REACT_APP_VERCEL_URL:"frontend-pumjwaa02-steevens-9009s-projects.vercel.app",REACT_APP_VERCEL_PROJECT_PRODUCTION_URL:"institutobrcultural.org",REACT_APP_SUPABASE_ANON_KEY:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InV1dnNiZ3hybmR3Y251ZGN0amx3Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NzQ3MDE5NzQsImV4cCI6MjA5MDI3Nzk3NH0.aEDfwNOnaTuv7KYKbMkMZ36bpiIIXXASQFM4AbzEAu4",REACT_APP_VERCEL_GIT_PREVIOUS_SHA:"",REACT_APP_VERCEL_GIT_REPO_ID:"",REACT_APP_VERCEL_GIT_COMMIT_AUTHOR_LOGIN:"",REACT_APP_VERCEL_GIT_REPO_OWNER:"",REACT_APP_BACKEND_URL:"http://localhost:8000",REACT_APP_NVIDIA_API_KEY:"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"}.REACT_APP_OLLAMA_URL||"http://localhost:11434",M="#FFC107",z=[M,"#3B82F6","#10B981","#F97316","#8B5CF6","#EC4899"],G=e=>{let{text:t}=e;return(0,$.jsxs)("div",{className:"relative group inline-flex ml-1.5",children:[(0,$.jsx)(w.A,{size:13,className:"text-white/15 group-hover:text-white/40 transition-colors cursor-help"}),(0,$.jsxs)("div",{className:"absolute bottom-full left-1/2 -translate-x-1/2 mb-2 px-3 py-2 bg-[#1a1a1a] border border-white/10 text-[11px] font-manrope text-white/60 leading-relaxed w-[220px] opacity-0 group-hover:opacity-100 transition-opacity pointer-events-none z-50 shadow-xl",children:[t,(0,$.jsx)("div",{className:"absolute top-full left-1/2 -translate-x-1/2 border-4 border-transparent border-t-[#1a1a1a]"})]})]})},B=e=>{let{icon:t,label:s,value:a,color:n,to:l,trend:o}=e;return(0,$.jsx)(i.N_,{to:l,children:(0,$.jsxs)(r.P.div,{className:"bg-[#141414] border border-white/5 p-5 hover:border-[#FFC107]/20 transition-all group cursor-pointer",whileHover:{y:-2},children:[(0,$.jsxs)("div",{className:"flex items-start justify-between mb-4",children:[(0,$.jsx)(t,{size:20,className:n||"text-white/30"}),(0,$.jsxs)("div",{className:"flex items-center gap-1",children:[void 0!==o&&null!==o&&(0,$.jsxs)("span",{className:"flex items-center gap-0.5 text-[10px] font-manrope "+(o>=0?"text-green-400":"text-red-400"),children:[o>=0?(0,$.jsx)(b.A,{size:10}):(0,$.jsx)(j.A,{size:10}),Math.abs(o),"%"]}),(0,$.jsx)(g.A,{size:14,className:"text-white/10 group-hover:text-[#FFC107] transition-colors"})]})]}),(0,$.jsx)("p",{className:"font-oswald text-3xl text-white mb-1",children:"number"===typeof a?a.toLocaleStr
2ing("pt-BR"):a}),(0,$.jsx)("p",{className:"font-manrope text-xs text-white/30 uppercase tracking-wider",children:s})]})})},U=e=>{let{type:t,title:s,subtitle:a,time:i}=e;return(0,$.jsxs)("div",{className:"flex items-start gap-3 py-3 border-b border-white/5 last:border-0",children:[(0,$.jsx)("div",{className:"w-1.5 h-1.5 mt-2 flex-shrink-0 "+("lead"===t?"bg-[#FFC107]":"contact"===t?"bg-blue-400":"event"===t?"bg-purple-400":"bg-green-400")}),(0,$.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,$.jsx)("p",{className:"font-manrope text-sm text-white/70 truncate",children:s}),(0,$.jsx)("p",{className:"font-manrope text-xs text-white/25",children:a})]}),(0,$.jsx)("span",{className:"font-manrope text-[10px] text-white/15 flex-shrink-0",children:i})]})},q=e=>{let{active:t,payload:s,label:a}=e;return t&&null!==s&&void 0!==s&&s.length?(0,$.jsxs)("div",{className:"bg-[#1a1a1a] border border-white/10 px-3 py-2 text-xs font-manrope",children:[(0,$.jsx)("p",{className:"text-white/50 mb-1",children:a}),s.map((e,t)=>{var s;return(0,$.jsxs)("p",{style:{color:e.color},className:"font-medium",children:[e.name,": ",null===(s=e.value)||void 0===s?void 0:s.toLocaleString("pt-BR")]},t)})]}):null},J=()=>(0,$.jsx)("span",{className:"inline-flex items-center gap-1",children:[0,1,2].map(e=>(0,$.jsx)(r.P.span,{className:"w-1.5 h-1.5 bg-[#FFC107]/60 rounded-full inline-block",animate:{opacity:[.2,1,.2]},transition:{duration:1.2,repeat:1/0,delay:.2*e}},e))}),K="qwen2.5-coder:7b",H=e=>{let{totalViews:t,stats:s,recentLeads:i,topPages:r,deviceData:n,leadsByType:l}=e;const[o,c]=(0,a.useState)(null),[d,x]=(0,a.useState)(!1),[m,p]=(0,a.useState)(null),h=(0,a.useCallback)(()=>{const e=r.length>0?r.map(e=>{let[t,s]=e;return` ${t}: ${s} views`}).join("\n"):" (sem dados)",a=n.length>0?n.map(e=>` ${e.name}: ${e.value}`).join("\n"):" (sem dados)",o=l.length>0?l.map(e=>` ${e.name}: ${e.value}`).join("\n"):" (sem dados)",c=i.length>0?i.slice(0,3).map(e=>` ${e.name} \u2014 ${e.type||"geral"} (${e.program||""})`).join("\n"):" (sem leads recentes)";return`Pageviews \xfaltimos 30 dias: ${t}\nLeads totais: ${s.leads}\nAssinantes newsletter: ${s.newsletter}\nContatos recebidos: ${s.contacts}\nNot\xedcias publicadas: ${s.news}\nArtigos publicados: ${s.articles}\nParceiros: ${s.partners}\n\nTop p\xe1ginas:\n${e}\n\nDispositivos dos visitantes:\n${a}\n\nLeads por tipo:\n${o}\n\nLeads recentes:\n${c}`},[t,s,i,r,n,l]),u=(0,a.useCallback)(async()=>{x(!0),p(null),c(null);const e=h();try{var t;const s=await fetch(`${D}/api/chat`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:K,messages:[{role:"system",content:"Voc\xea \xe9 o analista de dados do IBRC. Gere 3-5 insights acion\xe1veis e concisos baseados nos dados do dashboard. Responda em portugu\xeas. Use bullet points. Sugira a\xe7\xf5es concretas."},{role:"user",content:`Dados do dashboard IBRC:\n${e}`}],stream:!1})});if(!s.ok)throw new Error(`Ollama retornou status ${s.status}`);const a=null===(t=(await s.json()).message)||void 0===t?void 0:t.content;if(!a)throw new Error("Resposta vazia do modelo.");c(a)}catch(s){p(s.message||`Erro ao conectar com Ollama. Verifique se est\xe1 rodando em ${D}.`)}finally{x(!1)}},[h]);return(0,a.useEffect)(()=>{u()},[]),(0,$.jsxs)("div",{className:"bg-[#141414] border border-white/5 p-5",children:[(0,$.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,$.jsxs)("div",{className:"flex items-center gap-2",children:[(0,$.jsx)(f.A,{size:15,className:"text-[#FFC107]"}),(0,$.jsxs)("h3",{className:"font-oswald text-sm uppercase text-white/50",children:["AI Insights",(0,$.jsx)(G,{text:"An\xe1lise autom\xe1tica dos dados do dashboard via IA local (Ollama)."})]})]}),(0,$.jsxs)("div",{className:"flex items-center gap-3",children:[(0,$.jsx)("span",{className:"font-manrope text-[10px] text-white/20 bg-white/5 px-2 py-0.5 border border-white/5",children:K}),(0,$.jsxs)("button",{onClick:u,disabled:d,className:"flex items-center gap-1.5 text-[10px] font-manrope uppercase tracking-wider text-[#FFC107] hover:text-white transition-colors disabled:opacity-40 disabled:cursor-not-allowed",children:[(0,$.jsx)(N.A,{size:11,className:d?"animate-spin":""}),"Regenerar"]})]})]}),(0,$.jsxs)("div",{className:"min-h-[80px]",children:[d&&(0,$.jsxs)("div",{className:"flex items-center gap-3 py-4",children:[(0,$.jsx)(J,{}),(0,$.jsx)("span",{className:"font-manrope text-xs text-white/25",children:"Analisando dados do dashboard..."})]}),m&&!d&&(0,$.jsxs)("div",{className:"py-3",children:[(0,$.jsx)("p",{className:"font-manrope text-xs text-red-400/70 leading-relaxed",children:m}),(0,$.jsxs)("p",{className:"font-manrope text-[11px] text-white/20 mt-1",children:["Certifique-se que o Ollama est\xe1 ativo: ",(0,$.jsx)("code",{className:"text-white/30",children:"ollama serve"})]})]}),o&&!d&&(0,$.jsx)("pre",{className:"font-manrope text-[12.5px] text-white/55 leading-relaxed whitespace-pre-wrap break-words",children:o})]}),(0,$.jsxs)("div",{className:"mt-4 pt-3 border-t border-white/5 flex items-center gap-1.5",children:[(0,$.jsx)("div",{className:"w-1.5 h-1.5 bg-[#FFC107]/40 rounded-full"}),(0,$.jsx)("span",{className:"font-manrope text-[10px] text-white/15",children:"Gerado com Ollama \xb7 IA local \xb7
2nenhum dado enviado para servidores externos"})]})]})},W=()=>{const[e,t]=(0,a.useState)([]),[s,i]=(0,a.useState)({total:0,uniqueVisitors:0,best:null}),[n,l]=(0,a.useState)(!0);(0,a.useEffect)(()=>{(async()=>{try{const{data:e}=await L.N.from("page_views").select("page_path, visitor_id, created_at").like("page_path","/artigos/%"),{data:s}=await L.N.from("collaborations").select("type, program, created_at").eq("type","newsletter_artigo"),{data:a}=await L.N.from("articles").select("slug, title_pt, title_en").eq("status","published"),r={},n={},l={};(e||[]).forEach(e=>{const t=e.page_path.split("/")[2];t&&(r[t]=(r[t]||0)+1,(!n[t]||e.created_at>n[t])&&(n[t]=e.created_at),l[t]||(l[t]=new Set),e.visitor_id&&l[t].add(e.visitor_id))});const o={};(s||[]).forEach(e=>{const t=e.program;t&&(o[t]=(o[t]||0)+1)});const c={};(a||[]).forEach(e=>{c[e.slug]=e});const d=new Set([...Object.keys(r),...Object.keys(o)]),x=Array.from(d).map(e=>{var t;const s=r[e]||0,a=o[e]||0,i=(null===(t=l[e])||void 0===t?void 0:t.size)||s,d=i>0?(a/i*100).toFixed(1):"0.0",x=c[e];return{slug:e,title:(null===x||void 0===x?void 0:x.title_pt)||(null===x||void 0===x?void 0:x.title_en)||e,views:s,leads:a,uniqueVisitors:i,convRate:parseFloat(d),lastVisit:n[e]||null}}).sort((e,t)=>t.views-e.views);t(x);const m=(s||[]).length,p=Object.values(l).reduce((e,t)=>e+t.size,0),h=x.length>0?x.reduce((e,t)=>t.convRate>e.convRate?t:e,x[0]):null;i({total:m,uniqueVisitors:p,best:h})}catch{}finally{l(!1)}})()},[]);const o=e.slice(0,5).map(e=>({name:e.title.length>28?e.title.slice(0,28)+"\u2026":e.title,views:e.views})),c=e=>{if(!e)return"\u2014";const t=new Date-new Date(e),s=Math.floor(t/6e4);if(s<1)return"agora";if(s<60)return`${s}m`;const a=Math.floor(s/60);return a<24?`${a}h`:`${Math.floor(a/24)}d`},d=s.uniqueVisitors>0?(s.total/s.uniqueVisitors*100).toFixed(1):"0.0";return(0,$.jsxs)("div",{className:"mb-6",children:[(0,$.jsxs)("div",{className:"flex items-center gap-2 mb-4",children:[(0,$.jsx)(v,{size:15,className:"text-[#FFC107]"}),(0,$.jsxs)("h2",{className:"font-oswald text-sm uppercase text-white/50 tracking-wider",children:["Artigos & Leads",(0,$.jsx)(G,{text:"Performance dos artigos: pageviews, leads capturados e taxa de convers\xe3o por slug."})]})]}),n?(0,$.jsxs)("div",{className:"bg-[#141414] border border-white/5 p-8 flex items-center gap-3",children:[(0,$.jsx)(J,{}),(0,$.jsx)("span",{className:"font-manrope text-xs text-white/25",children:"Carregando analytics de artigos\u2026"})]}):(0,$.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[(0,$.jsxs)("div",{className:"space-y-4",children:[(0,$.jsxs)("div",{className:"grid grid-cols-3 gap-3",children:[(0,$.jsxs)("div",{className:"bg-[#141414] border border-white/5 p-4",children:[(0,$.jsx)(_.A,{size:14,className:"text-[#FFC107] mb-2"}),(0,$.jsx)("p",{className:"font-oswald text-2xl text-white",children:s.total}),(0,$.jsx)("p",{className:"font-manrope text-[10px] text-white/25 uppercase tracking-wider mt-0.5",children:"Leads"})]}),(0,$.jsxs)("div",{className:"bg-[#141414] border border-white/5 p-4",children:[(0,$.jsx)(y.A,{size:14,className:"text-cyan-400 mb-2"}),(0,$.jsx)("p",{className:"font-oswald text-2xl text-white",children:s.uniqueVisitors}),(0,$.jsx)("p",{className:"font-manrope text-[10px] text-white/25 uppercase tracking-wider mt-0.5",children:"Visitantes"})]}),(0,$.jsxs)("div",{className:"bg-[#141414] border border-white/5 p-4",children:[(0,$.jsx)(E.A,{size:14,className:"text-green-400 mb-2"}),(0,$.jsxs)("p",{className:"font-oswald text-2xl text-white",children:[d,"%"]}),(0,$.jsx)("p",{className:"font-manrope text-[10px] text-white/25 uppercase tracking-wider mt-0.5",children:"Convers\xe3o"})]})]}),s.best&&s.best.convRate>0&&(0,$.jsxs)("div",{className:"bg-[#141414] border border-[#FFC107]/15 p-4",children:[(0,$.jsxs)("div",{className:"flex items-center gap-1.5 mb-2",children:[(0,$.jsx)("div",{className:"w-1.5 h-1.5 bg-[#FFC107]"}),(0,$.jsx)("span",{className:"font-manrope text-[10px] uppercase tracking-wider text-[#FFC107]/70",children:"Melhor convers\xe3o"})]}),(0,$.jsx)("p",{className:"font-manrope text-sm text-white/70 leading-snug truncate",children:s.best.title}),(0,$.jsxs)("p",{className:"font-oswald text-lg text-[#FFC107] mt-1",children:[s.best.convRate,"%"]}),(0,$.jsxs)("p",{className:"font-manrope text-[10px] text-white/20",children:[s.best.leads," lead",1!==s.best.leads?"s":""," \xb7 ",s.best.views," views"]})]}),(0,$.jsxs)("div",{className:"bg-[#141414] border border-white/5 p-4",children:[(0,$.jsx)("h3",{className:"font-oswald text-xs uppercase text-white/40 mb-3",children:"Top 5 por Views"}),o.length>0?(0,$.jsx)("div",{className:"space-y-2.5",children:o.map((e,t)=>{var s;const a=(null===(s=o[0])||void 0===s?void 0:s.views)||1,i=Math.round(e.views/a*100);return(0,$.jsxs)("div",{children:[(0,$.jsxs)("div",{className:"flex justify-between items-baseline mb-0.5",children:[(0,$.jsx)("span",{className:"font-manrope text-[11px] text-white/50 truncate max-w-[75%]",children:e.name}),(0,$.jsx)("span",{className:"font-oswald text-xs text-white/30 flex-shrink-0 ml-1",children:e.views})]}),(0,$.jsx)("div",{className:"h-1 bg-white/5 overflow-hidden",children:(0,$.jsx)(r.P.div,{className:"h-full bg-[#FFC107]",initial:{width:0},animate:{width:`${i}%`},transition:{duration:.7,delay:.08*t}})})]},t)})}):(0,$.jsx)("p",{className:"font-manrope text-xs text-white/15 py-2",children:"Sem dados de artigos ainda."})]})]}),(0,$.jsxs)("div",{className:"lg:col-span-2 bg-[#141414] border border-white/5 p-5",children:[(0,$.jsxs)("h3",{className:"font-oswald text-sm uppercase text-white/50 mb-4 flex items-center",children:["Performance por Artigo",(0,$.jsx)(G,{text:"Views e leads por artigo. Convers\xe3o = leads \xf7 visitantes \xfanicos."})]}),e.length>0?(0,$.jsx)("div",{className:"overflow-x-auto",children:(0,$.jsxs)("table",{className:"w-full text-left border-collapse",children:[(0,$.jsx)("thead",{children:(0,$.jsxs)("tr",{className:"border-b border-white/5",children:[(0,$.jsx)("th",{className:"font-manrope text-[10px] uppercase tracking-wider text-white/20 pb-2 pr-4 font-normal",children:"T\xedtulo"}),(0,$.jsx)("th",{className:"font-manrope text-[10px] uppercase tracking-wider text-white/20 pb-2 pr-4 font-normal text-right",children:"Views"}),(0,$.jsx)("th",{className:"font-manrope text-[10px] uppercase tracking-wider text-white/20 pb-2 pr-4 font-normal text-right",children:"Leads"}),(0,$.jsx)("th",{className:"font-manrope text-[10px] uppercase tracking-wider text-white/20 pb-2 pr-4 font-normal text-right",children:"Conv."}),(0,$.jsx)("th",{className:"font-manrope text-[10px] uppercase tracking-wider text-white/20 pb-2 font-normal text-right",children:"\xdaltima visita"})]})}),(0,$.jsx)("tbody",{children:e.map((e,t)=>(0,$.jsxs)("tr",{className:"border-b border-white/[0.03] hover:bg-white/[0.025] transition-colors "+(t%2===0?"":"bg-white/[0.015]"),children:[(0,$.jsxs)("td",{className:"py-2.5 pr-4",children:[(0,$.jsx)("p",{className:"font-manrope text-[12px] text-white/60 truncate max-w-[200px]",title:e.title,children:e.title}),(0,$.jsxs)("p",{className:"font-manrope text-[10px] text-white/20 truncate max-w-[200px]",children:["/",e.slug]})]}),(0,$.jsx)("td",{className:"py-2.5 pr-4 text-right",children:(0,$.jsx)("span",{className:"font-oswald text-sm text-white/50",children:e.views.toLocaleStr
2ing("pt-BR")})}),(0,$.jsx)("td",{className:"py-2.5 pr-4 text-right",children:(0,$.jsx)("span",{className:"font-oswald text-sm "+(e.leads>0?"text-[#FFC107]":"text-white/20"),children:e.leads})}),(0,$.jsx)("td",{className:"py-2.5 pr-4 text-right",children:(0,$.jsxs)("span",{className:"font-manrope text-xs font-medium "+(e.convRate>=5?"text-green-400":e.convRate>=2?"text-yellow-400":e.convRate>0?"text-white/40":"text-white/15"),children:[e.convRate,"%"]})}),(0,$.jsx)("td",{className:"py-2.5 text-right",children:(0,$.jsx)("span",{className:"font-manrope text-[11px] text-white/20",children:c(e.lastVisit)})})]},e.slug))})]})}):(0,$.jsxs)("div",{className:"py-8 text-center",children:[(0,$.jsx)("p",{className:"font-manrope text-sm text-white/15",children:"Nenhum dado de artigos encontrado."}),(0,$.jsx)("p",{className:"font-manrope text-xs text-white/10 mt-1",children:"Os dados aparecer\xe3o assim que os artigos receberem visitas."})]})]})]})]})},Y=()=>{const[e,t]=(0,a.useState)({news:0,leads:0,partners:0,publications:0,newsletter:0,contacts:0,articles:0}),[s,w]=(0,a.useState)([]),[b,j]=(0,a.useState)([]),[g,f]=(0,a.useState)([]),[N,v]=(0,a.useState)([]),[_,E]=(0,a.useState)(0),[D,J]=(0,a.useState)([]),[K,Y]=(0,a.useState)([]);(0,a.useEffect)(()=>{const e=new Date,s=new Date(e);s.setDate(s.getDate()-30);const a=new Date(e);a.setDate(a.getDate()-60);(async()=>{const[e,s,a,i,r,n,l]=await Promise.all([L.N.from("news").select("id",{count:"exact",head:!0}),L.N.from("collaborations").select("id",{count:"exact",head:!0}),L.N.from("partners").select("id",{count:"exact",head:!0}),L.N.from("publications").select("id",{count:"exact",head:!0}),L.N.from("newsletter_subscribers").select("id",{count:"exact",head:!0}),L.N.from("contacts").select("id",{count:"exact",head:!0}),L.N.from("articles").select("id",{count:"exact",head:!0})]);t({news:e.count||0,leads:s.count||0,partners:a.count||0,publications:i.count||0,newsletter:r.count||0,contacts:n.count||0,articles:l.count||0})})(),(async()=>{const[{data:e},{data:t}]=await Promise.all([L.N.from("collaborations").select("*").order("created_at",{ascending:!1}).limit(5),L.N.from("contacts").select("*").order("created_at",{ascending:!1}).limit(5)]);e&&w(e),t&&j(t)})(),(async()=>{try{const[e,t,i]=await Promise.all([L.N.from("page_views").select("page_path, device_type, created_at").gte("created_at",s.toISOString()),L.N.from("page_views").select("id",{count:"exact",head:!0}).gte("created_at",a.toISOString()).lt("created_at",s.toISOString()),L.N.from("site_events").select("event_name, event_category, page_path, created_at").gte("created_at",s.toISOString()).order("created_at",{ascending:!1}).limit(10)]);if(e.data){v(e.data),E(t.count||0);const s={};e.data.forEach(e=>{s[e.page_path]=(s[e.page_path]||0)+1}),Y(Object.entries(s).sort((e,t)=>t[1]-e[1]).slice(0,5))}i.data&&f(i.data)}catch{}})(),(async()=>{const{data:e}=await L.N.from("collaborations").select("type");if(e){const t={};e.forEach(e=>{t[e.type]=(t[e.type]||0)+1}),J(Object.entries(t).map(e=>{let[t,s]=e;return{name:t,value:s}}))}})()},[]);const Q=N.length,X=_>0?Math.round((Q-_)/_*100):null,Z=(0,a.useMemo)(()=>{const e={};return N.forEach(t=>{const s=t.created_at.slice(0,10);e[s]||(e[s]=0),e[s]++}),Object.entries(e).sort((e,t)=>e[0].localeCompare(t[0])).slice(-14).map(e=>{let[t,s]=e;return{day:`${t.slice(8,10)}/${t.slice(5,7)}`,views:s}})},[N]),ee=(0,a.useMemo)(()=>{const e={desktop:0,mobile:0,tablet:0};return N.forEach(t=>{e[t.device_type||"desktop"]++}),Object.entries(e).filter(e=>{let[,t]=e;return t>0}).map(e=>{let[t,s]=e;return{name:t,value:s}})},[N]),te={desktop:A.A,mobile:C.A,tablet:R.A},se=e=>{const t=new Date-new Date(e),s=Math.floor(t/6e4);if(s<1)return"agora";if(s<60)return`${s}m`;const a=Math.floor(s/60);return a<24?`${a}h`:`${Math.floor(a/24)}d`};return(0,$.jsxs)(V.A,{children:[(0,$.jsxs)("div",{className:"mb-8",children:[(0,$.jsx)("h1",{className:"font-oswald text-2xl md:text-3xl uppercase text-white mb-1",children:"Dashboard"}),(0,$.jsx)("p",{className:"font-manrope text-sm text-white/25",children:"Vis\xe3o geral do site IBRC \u2014 \xfaltimos 30 dias"})]}),(0,$.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-4 lg:grid-cols-7 gap-3 mb-8",children:[(0,$.jsx)(B,{icon:P.A,label:"Pageviews",value:Q,color:"text-[#FFC107]",to:"/admin/analytics",trend:X}),(0,$.jsx)(B,{icon:y.A,label:"Leads",value:e.leads,color:"text-orange-400",to:"/admin/leads"}),(0,$.jsx)(B,{icon:T.A,label:"Not\xedcias",value:e.news,color:"text-green-400",to:"/admin/noticias-cms"}),(0,$.jsx)(B,{icon:I.A,label:"Artigos",value:e.articles,color:"text-cyan-400",to:"/admin/artigos"}),(0,$.jsx)(B,{icon:F.A,label:"Parceiros",value:e.partners,color:"text-blue-400",to:"/admin/parceiros"}),(0,$.jsx)(B,{icon:S.A,label:"Newsletter",value:e.newsletter,color:"text-purple-400",to:"/admin/newsletter"}),(0,$.jsx)(B,{icon:k.A,label:"Contatos",value:e.contacts,color:"text-pink-400",to:"/admin/contatos"})]}),(0,$.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6 mb-6",children:[(0,$.jsxs)("div",{className:"lg:col-span-2 bg-[#141414] border border-white/5 p-5",children:[(0,$.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,$.jsxs)("h3",{className:"font-oswald text-sm uppercase text-white/50 flex items-center",children:["Tr\xe1fego (14 dias)",(0,$.jsx)(G,{text:"Evolu\xe7\xe3o di\xe1ria de pageviews nas \xfaltimas 2 semanas."})]}),(0,$.jsx)(i.N_,{to:"/admin/analytics",className:"text-[10px] font-manrope uppercase tracking-wider text-[#FFC107] hover:text-white transition-colors",children:"Ver completo \u2192"})]}),(0,$.jsx)("div",{className:"h-[200px]",children:Z.length>0?(0,$.jsx)(n.u,{children:(0,$.jsxs)(l.Q,{data:Z,children:[(0,$.jsx)("defs",{children:(0,$.jsxs)("linearGradient",{id:"gd",x1:"0",y1:"0",x2:"0",y2:"1",children:[(0,$.jsx)("stop",{offset:"0%",stopColor:M,stopOpacity:.3}),(0,$.jsx)("stop",{offset:"100%",stopColor:M,stopOpacity:0})]})}),(0,$.jsx)(o.d,{strokeDasharray:"3 3",stroke:"rgba(255,255,255,0.03)"}),(0,$.jsx)(c.W,{dataKey:"day",tick:{fill:"rgba(255,255,255,0.2)",fontSize:10}
2,axisLine:!1,tickLine:!1}),(0,$.jsx)(d.h,{tick:{fill:"rgba(255,255,255,0.2)",fontSize:10},axisLine:!1,tickLine:!1,width:30}),(0,$.jsx)(x.m,{content:(0,$.jsx)(q,{})}),(0,$.jsx)(m.Gk,{type:"monotone",dataKey:"views",name:"Views",stroke:M,fill:"url(#gd)",strokeWidth:2})]})}):(0,$.jsx)("div",{className:"h-full flex items-center justify-center text-white/15 font-manrope text-sm",children:"Navegue pelo site para gerar dados de analytics"})})]}),(0,$.jsxs)("div",{className:"space-y-6",children:[(0,$.jsxs)("div",{className:"bg-[#141414] border border-white/5 p-5",children:[(0,$.jsxs)("h3",{className:"font-oswald text-sm uppercase text-white/50 mb-3 flex items-center",children:["Dispositivos",(0,$.jsx)(G,{text:"Tipo de aparelho usado pelos visitantes."})]}),ee.length>0?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)("div",{className:"h-[100px]",children:(0,$.jsx)(n.u,{children:(0,$.jsx)(p.r,{children:(0,$.jsx)(h.Fq,{data:ee,dataKey:"value",nameKey:"name",cx:"50%",cy:"50%",innerRadius:28,outerRadius:45,paddingAngle:3,children:ee.map((e,t)=>(0,$.jsx)(u.f,{fill:z[t]},t))})})})}),(0,$.jsx)("div",{className:"flex flex-wrap gap-2 justify-center",children:ee.map((e,t)=>{const s=te[e.name]||A.A;return(0,$.jsxs)("span",{className:"flex items-center gap-1 text-[10px] font-manrope text-white/40",children:[(0,$.jsx)(s,{size:10,style:{color:z[t]}})," ",e.name," (",e.value,")"]},t)})})]}):(0,$.jsx)("p",{className:"font-manrope text-xs text-white/15 py-2",children:"Sem dados"})]}),D.length>0&&(0,$.jsxs)("div",{className:"bg-[#141414] border border-white/5 p-5",children:[(0,$.jsxs)("h3",{className:"font-oswald text-sm uppercase text-white/50 mb-3 flex items-center",children:["Leads por tipo",(0,$.jsx)(G,{text:"Distribui\xe7\xe3o dos leads por categoria de interesse."})]}),(0,$.jsx)("div",{className:"space-y-1.5",children:D.map((e,t)=>{const s=D.reduce((e,t)=>e+t.value,0),a=Math.round(e.value/s*100);return(0,$.jsxs)("div",{children:[(0,$.jsxs)("div",{className:"flex justify-between mb-0.5",children:[(0,$.jsx)("span",{className:"font-manrope text-[11px] text-white/50",children:e.name}),(0,$.jsxs)("span",{className:"font-manrope text-[11px] text-white/30",children:[e.value," (",a,"%)"]})]}),(0,$.jsx)("div",{className:"h-1 bg-white/5 overflow-hidden",children:(0,$.jsx)(r.P.div,{className:"h-full",style:{background:z[t%z.length]},initial:{width:0},animate:{width:`${a}%`},transition:{duration:.8,delay:.1*t}})})]},t)})})]})]})]}),(0,$.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6 mb-6",children:[(0,$.jsxs)("div",{className:"bg-[#141414] border border-white/5 p-5",children:[(0,$.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,$.jsxs)("h3",{className:"font-oswald text-sm uppercase text-white/50 flex items-center",children:["Top P\xe1ginas",(0,$.jsx)(G,{text:"P\xe1ginas mais visitadas nos \xfaltimos 30 dias."})]}),(0,$.jsx)(i.N_,{to:"/admin/analytics",className:"text-[10px] font-manrope uppercase tracking-wider text-[#FFC107] hover:text-white transition-colors",children:"Mais \u2192"})]}),K.length>0?K.map((e,t)=>{let[s,a]=e;return(0,$.jsxs)("div",{className:"flex items-center justify-between py-2 border-b border-white/5 last:border-0",children:[(0,$.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,$.jsx)(O.A,{size:11,className:"text-white/15 flex-shrink-0"}),(0,$.jsx)("span",{className:"font-manrope text-sm text-white/50 truncate",children:s})]}),(0,$.jsx)("span",{className:"font-oswald text-sm text-white/30 flex-shrink-0 ml-2",children:a})]},t)}):(0,$.jsx)("p",{className:"font-manrope text-sm text-white/15 py-4",children:"Nenhum dado"})]}),(0,$.jsxs)("div",{className:"bg-[#141414] border border-white/5 p-5",children:[(0,$.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,$.jsxs)("h3",{className:"font-oswald text-sm uppercase text-white/50 flex items-center",children:["Leads Recentes",(0,$.jsx)(G,{text:"\xdaltimos 5 leads recebidos pelo site."})]}),(0,$.jsx)(i.N_,{to:"/admin/leads",className:"text-[10px] font-manrope uppercase tracking-wider text-[#FFC107] hover:text-white transition-colors",children:"Ver todos \u2192"})]}),s.length>0?s.map((e,t)=>(0,$.jsx)(U,{type:"lead",title:`${e.name} \u2014 ${e.program||"geral"}`,subtitle:`${e.type} \xb7 ${e.email}`,time:se(e.created_at)},t)):(0,$.jsx)("p",{className:"font-manrope text-sm text-white/15 py-4",children:"Nenhum lead ainda."})]}),(0,$.jsxs)("div",{className:"bg-[#141414] border border-white/5 p-5",children:[(0,$.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,$.jsxs)("h3",{className:"font-oswald text-sm uppercase text-white/50 flex items-center",children:["Contatos Recentes",(0,$.jsx)(G,{text:"\xdaltimos 5 contatos via formul\xe1rio."})]}),(0,$.jsx)(i.N_,{to:"/admin/contatos",className:"text-[10px] font-manrope uppercase tracking-wider text-[#FFC107] hover:text-white transition-colors",children:"Ver todos \u2192"})]}),b.length>0?b.map((e,t)=>(0,$.jsx)(U,{type:"contact",title:e.subject||"Sem assunto",subtitle:`${e.name} \xb7 ${e.email}`,time:se(e.created_at)},t)):(0,$.jsx)("p",{className:"font-manrope text-sm text-white/15 py-4",children:"Nenhum contato ainda."})]})]}),g.length>0&&(0,$.jsxs)("div",{className:"bg-[#141414] border border-white/5 p-5 mb-6",children:[(0,$.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,$.jsxs)("h3",{className:"font-oswald text-sm uppercase text-white/50 flex items-center",children:["Eventos Recentes",(0,$.jsx)(G,{text:"\xdaltimas intera\xe7\xf5es rastreadas pelo analytics."})]}),(0,$.jsx)(i.N_,{to:"/admin/analytics",className:"text-[10px] font-manrope uppercase tracking-wider text-[#FFC107] hover:text-white transition-colors",children:"Analytics \u2192"})]}),(0,$.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-5 ga
2p-2",children:g.slice(0,10).map((e,t)=>(0,$.jsxs)("div",{className:`px-3 py-2.5 border ${{conversion:"border-[#FFC107]/30",engagement:"border-blue-400/30",navigation:"border-green-400/30"}[e.event_category]||"border-white/5"} bg-white/[0.02]`,children:[(0,$.jsx)("p",{className:"font-manrope text-[11px] text-white/60 font-medium",children:e.event_name}),(0,$.jsx)("p",{className:"font-manrope text-[10px] text-white/20 truncate",children:e.page_path})]},t))})]}),(0,$.jsx)(W,{}),(0,$.jsx)(H,{totalViews:Q,stats:e,recentLeads:s,topPages:K,deviceData:ee,leadsByType:D})]})}}}]); 3//# sourceMappingURL=151.108a9e2d.chunk.js.map
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.