PageSourceSearch

https://cbnamazonia.com/assets/SearchAnalyticsDashboard-Cg5sFOLc.js

js cbnamazonia.com collected 2026-09-25 15:03:05 UTC 13,422 bytes, 1 lines download raw bytes

1import{j as e}from"./vendor-editor-BX0sR0z-.js";import{r as o}from"./vendor-react-BPk9u-w4.js";import{h as T}from"./index-FZUSOwo2.js";import{F as z}from"./FiltroDeDatas-D4yJ45DU.js";import{u as A}from"./usePeriodoNaUrl-zkbWwT2s.js";import{l as L}from"./periodo-C4wsnXcM.js";import{bo as q,u as j,ab as F,ap as V,aG as Q,d5 as E,du as S,a2 as H,bm as O,b6 as P,cZ as U}from"./vendor-icons-D7M_7Je-.js";import"./vendor-charts-Cf-ruFca.js";import"./vendor-ui-utils-Bbg69IUi.js";import"./vendor-graph-Df3mHyA7.js";import"./vendor-supabase-UBwEW4nm.js";import"./vendor-sonner-DPZ7yCFm.js";import"./vendor-helmet-C74EPpLp.js";import"./useMediaQuery-DmKoq-cZ.js";import"./createReactComponent-LJ3Rzzl2.js";import"./IconCalendar-B44dlgS6.js";import"./IconChevronDown-BcsKoyPw.js";import"./IconCheck-2awuSAfX.js";import"./IconChevronLeft-CWWwj-5H.js";import"./IconChevronRight-_i4BDM-V.js";const me=()=>{const[r,g]=o.useState([]),[m,b]=o.useState(!0),[c,R,k]=A({padrao:"7"}),[M,D]=o.useState(new Date),f=o.useCallback(async()=>{b(!0);const{desde:t,antesDe:s}=L({de:c.de,ate:c.ate});let a=T.from("search_queries").select("query, results_count, searched_at, zero_results, clicked, source");t&&(a=a.gte("searched_at",t)),s&&(a=a.lt("searched_at",s));const{data:l,error:u}=await a.order("searched_at",{ascending:!1}).limit(1e4);!u&&l&&g(l),b(!1),D(new Date)},[c.de,c.ate]);o.useEffect(()=>{f()},[f]);const N=!!c.de&&c.de===c.ate,_=o.useMemo(()=>{const t=new Map;for(const s of r){const a=s.query.toLowerCase().trim(),l=t.get(a)||{count:0,totalResults:0,lastSearched:s.searched_at,clicks:0};l.count++,l.totalResults+=s.results_count,s.clicked&&l.clicks++,s.searched_at>l.lastSearched&&(l.lastSearched=s.searched_at),t.set(a,l)}return Array.from(t.entries()).map(([s,a])=>({query:s,count:a.count,avgResults:Math.round(a.totalResults/a.count),lastSearched:a.lastSearched,ctr:a.count>0?Math.round(a.clicks/a.count*100):0})).sort((s,a)=>a.count-s.count).slice(0,25)},[r]),v=o.useMemo(()=>{const t=new Map;for(const s of r)if(s.results_count===0||s.zero_results){const a=s.query.toLowerCase().trim(),l=t.get(a)||{count:0,lastSearched:s.searched_at};l.count++,s.searched_at>l.lastSearched&&(l.lastSearched=s.searched_at),t.set(a,l)}return Array.from(t.entries()).map(([s,a])=>({query:s,count:a.count,avgResults:0,lastSearched:a.lastSearched})).sort((s,a)=>a.count-s.count).slice(0,20)},[r]),h=o.useMemo(()=>{const t=new Map;for(const s of r){const a=new Date(s.searched_at);let l;N?l=`${a.getHours().toString().padStart(2,"0")}:00`:l=a.toLocaleDateString("pt-BR",{day:"2-digit",month:"2-digit"}),t.set(l,(t.get(l)||0)+1)}return Array.from(t.entries()).map(([s,a])=>({hour:s,count:a}))},[r,N]),p=o.useMemo(()=>{const t={search:0,autocomplete:0,voice:0,unknown:0};for(const a of r){const l=a.source||"search";t[l]=(t[l]||0)+1}const s=r.length||1;return{search:{count:t.search||0,pct:((t.search||0)/s*100).toFixed(1)},autocomplete:{count:t.autocomplete||0,pct:((t.autocomplete||0)/s*100).toFixed(1)},voice:{count:t.voice||0,pct:((t.voice||0)/s*100).toFixed(1)}}},[r]),y=o.useMemo(()=>{const t=Array.from({length:7},()=>Array(24).fill(0));for(const a of r){const l=new Date(a.searched_at);t[l.getDay()][l.getHours()]++}const s=Math.max(...t.flat(),1);return{grid:t,maxVal:s}},[r]),i=o.useMemo(()=>{const t=r.length,s=new Set(r.map(n=>n.query.toLowerCase().trim())).size,a=r.filter(n=>n.results_count===0||n.zero_results).length,l=r.filter(n=>n.clicked).length,u=t>0?Math.round(r.reduce((n,B)=>n+B.results_count,0)/t):0,$=t>0?(l/t*100).toFixed(1):"0";return{total:t,unique:s,failed:a,failedRate:t>0?(a/t*100).toFixed(1):"0",avgResults:u,clicked:l,ctr:$}},[r]),d=o.useMemo(()=>{if(c.preset!=="7")return null;const t=Date.now(),s=r.filter(a=>new Date(a.searched_at).getTime()>t-7*864e5).length;return{thisWeek:s,trend:s>100?"up":s>50?"stable":"down"}},[r,c.preset]),C=Math.max(...h.map(t=>t.count),1),w=["Dom","Seg","Ter","Qua","Qui","Sex","Sáb"];return e.jsxs("div",{className:"space-y-5 console-page-enter px-4 pb-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-[20px] font-semibold text-slate-900 tracking-tight",children:"Analytics de Busca"}),e.jsxs("p",{className:"text-[13px] text-slate-500 mt-1",children:["Dados de buscas realizadas no portal público.",e.jsxs("span",{className:"text-[11px] text-slate-400 ml-2",children:["Atualizado: ",M.toLocaleTimeString("pt-BR")]})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(z,{value:c,onChange:R,hoje:k,variante:"kit",alinhamento:"direita",presets:["hoje","ontem","7","14","30"],permiteComparar:!1}),e.jsx("button",{onClick:f,disabled:m,className:"p-2 text-slate-400 hover:text-slate-600 border border-slate-200 rounded-lg transition-colors",children:e.jsx(q,{size:16,className:m?"animate-spin":""})})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-3",children:[e.jsx(x,{label:"Total de Buscas",value:i.total.toLocaleStr
1ing(),icon:j,color:"blue"}),e.jsx(x,{label:"Termos Únicos",value:i.unique.toLocaleString(),icon:F,color:"indigo"}),e.jsx(x,{label:"Sem Resultado",value:`${i.failedRate}%`,subValue:`${i.failed} buscas`,icon:V,color:"amber"}),e.jsx(x,{label:"Média Resultados",value:i.avgResults.toString(),icon:Q,color:"emerald"}),e.jsx(x,{label:"CTR (Cliques)",value:`${i.ctr}%`,subValue:`${i.clicked} cliques`,icon:E,color:"purple"}),e.jsx(x,{label:"Busca por Voz",value:p.voice.count.toLocaleString(),subValue:`${p.voice.pct}%`,icon:S,color:"rose"})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[e.jsxs("div",{className:"border border-slate-200 rounded-xl p-5",children:[e.jsx("h3",{className:"text-[13px] font-semibold text-slate-900 mb-4",children:"Origem das Buscas"}),e.jsx("div",{className:"space-y-3",children:[{label:"Digitação",value:p.search,color:"bg-slate-500",icon:j},{label:"Autocomplete",value:p.autocomplete,color:"bg-slate-400",icon:H},{label:"Voz",value:p.voice,color:"bg-slate-300",icon:S}].map(t=>e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:`w-8 h-8 rounded-lg ${t.color} bg-opacity-10 flex items-center justify-center`,children:e.jsx(t.icon,{size:14,className:t.color.replace("bg-","text-")})}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("span",{className:"text-sm font-medium text-slate-700",children:t.label}),e.jsxs("span",{className:"text-xs font-bold text-slate-500",children:[t.value.pct,"%"]})]}),e.jsx("div",{className:"w-full bg-slate-100 rounded-full h-1.5",children:e.jsx("div",{className:`${t.color} rounded-full h-1.5 transition-all`,style:{width:`${Math.max(parseFloat(t.value.pct),1)}%`}})})]}),e.jsx("span",{className:"text-xs text-slate-400 font-mono w-12 text-right",children:t.value.count})]},t.label))})]}),e.jsxs("div",{className:"lg:col-span-2 border border-slate-200 rounded-xl p-5",children:[e.jsxs("h3",{className:"text-[13px] font-semibold text-slate-900 mb-4 flex items-center gap-2",children:["Volume de Buscas",d&&e.jsxs("span",{className:`text-xs font-bold ml-auto flex items-center gap-1 ${d.trend==="up"?"text-emerald-600":d.trend==="down"?"text-red-500":"text-slate-400"}`,children:[d.trend==="up"?e.jsx(O,{size:14}):d.trend==="down"?e.jsx(P,{size:14}):e.jsx(U,{size:14}),d.thisWeek," esta semana"]})]}),h.length>0?e.jsx("div",{className:"flex items-end gap-1 h-40",children:h.map((t,s)=>e.jsxs("div",{className:"flex-1 flex flex-col items-center gap-1 group",title:`${t.hour}: ${t.count} buscas`,children:[e.jsx("span",{className:"text-[9px] text-slate-400 font-mono opacity-0 group-hover:opacity-100 transition-opacity",children:t.count}),e.jsx("div",{className:"w-full bg-slate-300 rounded-t-sm hover:bg-slate-500 transition-colors min-h-[2px]",style:{height:`${t.count/C*100}%`}}),s%Math.max(1,Math.floor(h.length/10))===0&&e.jsx("span",{className:"text-[8px] text-slate-400 font-mono mt-1 whitespace-nowrap",children:t.hour})]},s))}):e.jsx("div",{className:"h-40 flex items-center justify-center text-sm text-slate-400",children:"Sem dados no período"})]})]}),e.jsxs("div",{className:"border border-slate-200 rounded-xl p-5",children:[e.jsx("h3",{className:"text-[13px] font-semibold text-slate-900 mb-4",children:"Heatmap - Quando seus leitores buscam"}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("div",{className:"min-w-[600px]",children:[e.jsx("div",{className:"flex ml-10 mb-1",children:Array.from({length:24},(t,s)=>e.jsx("div",{className:"flex-1 text-center text-[9px] text-slate-400 font-mono",children:s%3===0?`${s.toString().padStart(2,"0")}h`:""},s))}),y.grid.map((t,s)=>e.jsxs("div",{className:"flex items-center gap-1 mb-0.5",children:[e.jsx("span",{className:"text-[10px] font-bold text-slate-500 w-8 text-right",children:w[s]}),e.jsx("div",{className:"flex-1 flex gap-0.5",children:t.map((a,l)=>{const u=a/y.maxVal;return e.jsx("div",{className:"flex-1 h-5 rounded-sm transition-all hover:ring-1 hover:ring-slate-400 cursor-default",style:{backgroundColor:a===0?"rgb(241 245 249)":`rgba(100, 116, 139, ${Math.max(u,.15)})`},title:`${w[s]} ${l}h: ${a} buscas`},l)})})]},s)),e.jsxs("div",{className:"flex items-center justify-end gap-2 mt-2",children:[e.jsx("span",{className:"text-[9px] text-slate-400",children:"Menos"}),[.1,.3,.5,.7,1].map(t=>e.jsx("div",{className:"w-4 h-3 rounded-sm",style:{backgroundColor:`rgba(100, 116, 139, ${t})`}},t)),e.jsx("span",{className:"text-[9px] text-slate-400",children:"Mais"})]})]})})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[e.jsxs("div",{className:"border border-slate-200 rounded-xl overflow-hidden",children:[e.jsxs("div",{className:"px-5 py-3 border-b border-slate-100",children:[e.jsx("h3",{className:"text-[13px] font-semibold text-slate-900",children:"Top Buscas"}),e.jsx("p",{className:"text-[11px] text-slate-400 mt-0.5",children:"Ordenado por frequência • CTR = taxa de cliques"})]}),e.jsx("div",{className:"max-h-[400px] overflow-y-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:"bg-slate-50/50 sticky top-0",children:e.jsxs("tr",{className:"text-[11px] font-bold text-slate-400 uppercase tracking-wider",children:[e.jsx("th",{className:"px-5 py-3 text-left",children:"#"}),e.jsx("th",{className:"px-5 py-3 text-left",children:"Termo"}),e.jsx("th",{className:"px-5 py-3 text-right",children:"Buscas"}),e.jsx("th",{className:"px-5 py-3 text-right",children:"Res."}),e.jsx("th",{className:"px-5 py-3 text-right",children:"CTR"})]})}),e.jsx("tbody",{className:"divide-y divide-slate-100",children:_.map((t,s)=>e.jsxs("tr",{className:"hover:bg-slate-50/50 transition-colors",children:[e.jsx("td",{className:"px-5 py-2.5 text-[12px] font-medium text-slate-400",children:s+1}),e.jsx("td",{className:"px-5 py-2.5 text-[13px] font-medium text-slate-900",children:t.query}),e.jsx("td",{className:"px-5 py-2.5 text-right text-[13px] font-medium text-slate-700",children:t.count}),e.jsxs("td",{className:"px-5 py-2.5 text-right text-[12px] text-slate-400",children:["~",t.avgResults]}),e.jsx("td",{className:"px-5 py-2.5 text-right",children:e.jsxs("span",{className:"text-[11px] font-medium px-1.5 py-0.5 rounded bg-slate-100 text-slate-600",children:[t.ctr||0,"%"]})})]},t.query))})]})})]}),e.jsxs("div",{className:"border border-slate-200 rounded-xl overflow-hidden",children:[e.jsxs("div",{className:"px-5 py-3 border-b border-slate-100",children:[e.jsx("h3",{className:"text-[13px] font-semibold text-slate-900",children:"Content Gap - Buscas Sem Resultado"}),e.jsx("p",{className:"text-[11px] text-slate-400 mt-0.5",children:"Oportunidades de conteúdo que seu público procura"})]}),v.length>0?e.jsx("div",{className:"max-h-[400px] overflow-y-auto",children:e.jsxs("table",{className:"w-full text-left border-collapse",children:[e.jsx("thead",{className:"bg-slate-50/50 sticky top-0",children:e.jsxs("tr",{className:"text-[11px] font-bold text-slate-400 uppercase tracking-wider",children:[e.jsx("th",{className:"px-5 py-3",children:"Termo"}),e.jsx("th",{className:"px-5 py-3 text-right",children:"Tentativas"}),e.jsx("th",{className:"px-5 py-3 text-right",children:"Última Busca"})]})}),e.jsx("tbody",{className:"divide-y divide-slate-100",children:v.map(t=>e.jsxs("tr",{className:"hover:bg-slate-50/50 transition-colors",children:[e.jsx("td",{className:"px-5 py-2.5 text-[13px] font-medium text-slate-900",children:t.query}),e.jsxs("td",{className:"px-5 py-2.5 text-right text-[13px] font-medium text-slate-700",children:[t.count,"×"]}),e.jsx("td",{className:"px-5 py-2.5 text-right text-[11px] text-slate-400",children:new Date(t.lastSearched).toLocaleDateString("pt-BR")})]},t.query))})]})}):e.jsxs("div",{className:"p-8 text-center text-slate-400",children:[e.jsx(j,{className:"w-8 h-8 mx-auto mb-2 opacity-20"}),e.jsx("p",{className:"text-sm",children:"Nenhuma busca sem resultado no período"})]})]})]})]})},x=({label:r,value:g,subValue:m})=>e.jsxs("div",{className:"border border-slate-200 rounded-xl p-4",children:[e.jsx("div",{className:"text-[20px] font-semibold text-slate-900 tracking-tight",children:g}),e.jsx("div",{className:"text-[10px] font-bold text-slate-400 uppercase tracking-wider mt-0.5",children:r}),m&&e.jsx("span",{className:"text-[10px] text-slate-400 mt-0.5 block",children:m})]});
1export{me as SearchAnalyticsDashboard};

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.