js • Lines: 2"use strict";(self.webpackChunknew_site=self.webpackChunknew_site||[]).push([[273],{3273(e,t,s){s.r(t),s.d(t,{default:()=>x});var r=s(9379),l=s(5544),i=s(5043),d=s(3604),n=s(791),o=s(3519),a=s(7417),c=s(1800),h=s(579);function x(){const e=(0,i.useState)([]),t=(0,l.A)(e,2),s=t[0],x=t[1],p=(0,i.useState)(!0),f=(0,l.A)(p,2),b=f[0],u=f[1],y=(0,i.useState)(null),j=(0,l.A)(y,2),m=j[0],v=j[1],w=(0,i.useState)(null),g=(0,l.A)(w,2),S=g[0],z=g[1];if((0,i.useEffect)(()=>{(async()=>{try{const e=(0,d.P)((0,d.rJ)(n.db,(0,c.n)("page_stats")),(0,d.My)("views","desc")),t=(await(0,d.GG)(e)).docs.map(e=>(0,r.A)({id:e.id},e.data())).filter(e=>"/analytics"!==e.path);x(t)}catch(e){console.error("Analytics load error:",e)}finally{u(!1)}})()},[]),b)return(0,h.jsx)(o.A,{className:"text-center py-5",children:(0,h.jsx)(a.A,{animation:"border",variant:"light"})});const k=s.reduce((e,t)=>e+(t.views||0),0),N=s.reduce((e,t)=>e+(t.newUsers||0),0),A=s.reduce((e,t)=>e+(t.returningUsers||0),0),W=Math.max(...s.map(e=>e.views||0),1),T={};s.forEach(e=>{Object.keys(e).filter(e=>e.startsWith("tz.")).forEach(t=>{const s=t.replace("tz.","");T[s]=(T[s]||0)+e[t]})});const O=Math.max(...Object.values(T),1),C=(e,t,s)=>({height:"14px",width:"".concat(e/t*100,"%"),minWidth:e>0?"4px":0,background:s,borderRadius:"0 3px 3px 0",transition:"width 0.4s ease"});return(0,h.jsxs)(o.A,{fluid:!0,className:"p-3",style:{fontSize:"12px",color:"#e2e8f0"},children:[(0,h.jsx)("h5",{className:"mb-3",style:{fontWeight:600},children:"Analytics"}),(0,h.jsxs)("div",{className:"d-flex gap-3 mb-3 flex-wrap",children:[(0,h.jsxs)("div",{className:"p-2 rounded border flex-fill",style:{minWidth:100,background:"#1e293b",borderColor:"#334155"},children:[(0,h.jsx)("div",{style:{color:"#64748b",fontSize:"10px",textTransform:"uppercase"},children:"Total Views"}),(0,h.jsx)("div",{style:{color:"#22d3ee",fontSize:"18px",fontWeight:700},children:k})]}),(0,h.jsxs)("div",{className:"p-2 rounded border flex-fill",style:{minWidth:100,background:"#1e293b",borderColor:"#334155"},children:[(0,h.jsx)("div",{style:{color:"#64748b",fontSize:"10px",textTransform:"uppercase"},children:"New Users"}),(0,h.jsx)("div",{style:{color:"#4ade80",fontSize:"18px",fontWeight:700},children:N})]}),(0,h.jsxs)("div",{className:"p-2 rounded border flex-fill",style:{minWidth:100,background:"#1e293b",borderColor:"#334155"},children:[(0,h.jsx)("div",{style:{color:"#64748b",fontSize:"10px",textTransform:"uppercase"},children:"Returning Users"}),(0,h.jsx)("div",{style:{color:"#fb923c",fontSize:"18px",fontWeight:700},children:A})]}),(0,h.jsxs)("div",{className:"p-2 rounded border flex-fill",style:{minWidth:100,background:"#1e293b",borderColor:"#334155"},children:[(0,h.jsx)("div",{style:{color:"#64748b",fontSize:"10px",textTransform:"uppercase"},children:"Pages Tracked"}),(0,h.jsx)("div",{style:{color:"#a78bfa",fontSize:"18px",fontWeight:700},children:s.length})]})]}),(0,h.jsxs)("div",{className:"d-flex gap-3",style:{flexWrap:"wrap"},children:[(0,h.jsxs)("div",{className:"rounded border p-2 flex-fill",style:{minWidth:280,background:"#1e293b",borderColor:"#334155"},children:[(0,h.jsx)("div",{style:{color:"#64748b",fontSize:"10px",textTransform:"uppercase",marginBottom:"8px"},children:"Views by Page"}),s.map(e=>(0,h.jsxs)("div",{className:"d-flex align-items-center mb-1",style:{gap:"6px",cursor:"pointer"},onMouseEnter:()=>v(e.path),onMouseLeave:()=>v(null),children:[(0,h.jsx)("div",{style:{width:"24px",textAlign:"right",color:"#94a3b8",fontSize:"11px",flexShrink:0},children:e.views}),(0,h.jsx)("div",{style:{flex:1,background:"#0f172a",borderRadius:"3px"},children:(0,h.jsx)("div",{style:(0,r.A)((0,r.A)({},C(e.views,W,"#22d3ee")),{},{opacity:m&&m!==e.path?.4:1})})}),(0,h.jsx)("div",{style:{fontSize:"10px",color:m===e.path?"#22d3ee":"#64748b",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"200px",flexShrink:0},title:e.path,children:e.path})]},e.id))]}),Object.keys(T).length>0&&(0,h.jsxs)("div",{className:"rounded border p-2 flex-fill",style:{minWidth:200,background:"#1e293b",borderColor:"#334155"},children:[(0,h.jsx)("div",{style:{color:"#64748b",fontSize:"10px",textTransform:"uppercase",marginBottom:"8px"},children:"By Timezone"}),Object.entries(T).sort((e,t)=>t[1]-e[1]).map(e=>{let t=(0,l.A)(e,2),s=t[0],i=t[1];return(0,h.jsxs)("div",{className:"d-flex align-items-center mb-1",style:{gap:"6px",cursor:"pointer"},onMouseEnter:()=>z(s),onMouseLeave:()=>z(null),children:[(0,h.jsx)("div",{style:{width:"20px",textAlign:"right",color:"#94a3b8",fontSize:"11px",flexShrink:0},children:i}),(0,h.jsx)("div",{style:{flex:1,background:"#0f172a",borderRadius:"3px"},children:(0,h.jsx)("div",{style:(0,r.A)((0,r.A)({},C(i,O,"#a78bfa")),{},{opacity:S&&S!==s?.4:1})})}),(0,h.jsx)("div",{style:{fontSize:"10px",color:S===s?"#a78bfa":"#64748b",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",width:"100px",flexShrink:0},children:s.split("/").pop()})]},s)})]})]}),(0,h.jsx)("div",{className:"overflow-auto mt-3",style:{maxHeight:"calc(100vh - 350px)"},children:(0,h.jsxs)("table",{className:"table table-dark table-striped table-bordered table-sm",style:{fontSize:"11px"},children:[(0,h.jsx)("thead",{children:(0,h.jsxs)("tr",{children:[(0,h.jsx)("th",{children:"Path"}),(0,h.jsx)("th",{style:{width:50},children:"Views"}),(0,h.jsx)("th",{style:{width:50},children:"New"}),(0,h.jsx)("th",{style:{width:50},children:"Return"}),(0,h.jsx)("th",{style:{width:90},children:"Last Viewed"}),(0,h.jsx)("th",{style:{width:120},children:"Timezones"})]})}),(0,h.jsx)("tbody",{children:s.map(e=>{var t,s,r;return(0,h.jsxs)("tr",{style:{background:m===e.path?"#1e3a5f":void 0},children:[(0,h.jsx)("td",{style:{maxWidth:300,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.path}),(0,h.jsx)("td",{children:e.views}),(0,h.jsx)("td",{children:e.newUsers}),(0,h.jsx)("td",{children:e.returningUsers}),(0,h.jsx)("td",{style:{fontSize:"10px"},children:(null===(t=e.lastViewed)||void 0===t||null===(s=t.toDate)||void 0===s||null===(r=s.call(t))||void 0===r?void 0:r.toLocaleString())||"-"}),(0,h.jsxs)("td",{children:[Object.keys(e).filter(e=>e.startsWith("tz.")).map(t=>(0,h.jsxs)("span",{className:"badge bg-secondary me-1",style:{fontSize:"9px"},children:[t.replace("tz.","").split("/").pop(),":",e[t]]},t)),!Object.keys(e).some(e=>e.startsWith("tz."))&&(0,h.jsx)("span",{style:{color:"#64748b"},children:"-"})]})]},e.id)})})]})})]})}}}]);
//# sourceMappingURL=273.7bfed940.chunk.js.map