(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[583],{8178:function(e,t,s){(window.__NEXT_P=window.__NEXT_P||[]).push(["/analytics",function(){return s(4241)}])},1398:function(e,t,s){"use strict";s.d(t,{Z:function(){return c}});var a=s(5893),n=s(9008),l=s.n(n),i=s(1664),r=s.n(i);function c(e){let{children:t}=e;return(0,a.jsxs)("div",{children:[(0,a.jsxs)(l(),{children:[(0,a.jsx)("title",{children:"Real-time NBA Analytics"}),(0,a.jsx)("meta",{name:"description",content:"AI-powered NBA analytics and commentary"}),(0,a.jsx)("link",{rel:"icon",href:"/favicon.ico"})]}),(0,a.jsx)("nav",{className:"bg-black text-white p-4",children:(0,a.jsxs)("div",{className:"container mx-auto flex items-center",children:[(0,a.jsx)("div",{className:"flex-1",children:(0,a.jsx)("span",{className:"text-neon-purple text-sm font-roboto",children:"Powered with ❤️ on SingleStore"})}),(0,a.jsx)("div",{className:"flex-1 text-center",children:(0,a.jsx)(r(),{href:"/",className:"text-3xl font-bold text-neon-green font-orbitron",children:"NBA OnTheFlyAI"})}),(0,a.jsx)("div",{className:"flex-1 flex justify-end",children:(0,a.jsxs)("ul",{className:"flex space-x-4",children:[(0,a.jsx)("li",{children:(0,a.jsx)(r(),{href:"/",className:"hover:text-green-400 text-neon-green font-orbitron",children:"Home"})}),(0,a.jsx)("li",{children:(0,a.jsx)(r(),{href:"/analytics",className:"hover:text-green-400 text-neon-green font-orbitron",children:"Analytics"})})]})})]})}),(0,a.jsx)("main",{children:t})]})}},4241:function(e,t,s){"use strict";s.r(t),s.d(t,{default:function(){return v}});var a=s(5893),n=s(7294),l=s(1398),i=s(2305),r=s(82),c=s(9949),o=s(2154),x=s(4283),d=s(7115),h=(0,r.z)({chartName:"BarChart",GraphicalChild:c.$,defaultTooltipEventType:"axis",validateTooltipEventTypes:["axis","item"],axisComponents:[{axisType:"xAxis",AxisComp:o.K},{axisType:"yAxis",AxisComp:x.B}],formatAxisMap:d.t9}),m=s(4206),j=s(6910),p=s(3447),u=s(2332),f=s(8933);let y=e=>{let{total:t}=e;return(0,a.jsx)(i.h,{width:"100%",height:300,children:(0,a.jsxs)(h,{data:[{name:"Total Commentaries",total:t}],children:[(0,a.jsx)(m.q,{strokeDasharray:"3 3"}),(0,a.jsx)(o.K,{dataKey:"name"}),(0,a.jsx)(x.B,{}),(0,a.jsx)(j.u,{}),(0,a.jsx)(p.D,{}),(0,a.jsx)(c.$,{dataKey:"total",fill:"#8884d8"})]})})},N=e=>{let{commentaries:t=[]}=e,s=t.map(e=>({timestamp:new Date(e.timestamp).toLocaleString(),length:e.commentary.length})).reverse();return(0,a.jsx)(i.h,{width:"100%",height:300,children:(0,a.jsxs)(u.w,{data:s,children:[(0,a.jsx)(m.q,{strokeDasharray:"3 3"}),(0,a.jsx)(o.K,{dataKey:"timestamp"}),(0,a.jsx)(x.B,{}),(0,a.jsx)(j.u,{}),(0,a.jsx)(p.D,{}),(0,a.jsx)(f.x,{type:"monotone",dataKey:"length",stroke:"#8884d8"})]})})};function v(){var e;let[t,s]=(0,n.useState)(null),[i,r]=(0,n.useState)("");(0,n.useEffect)(()=>{c()},[]);let c=async()=>{try{let e=await fetch("/api/analytics?userPrompt=".concat(i)),t=await e.json();s(t)}catch(e){console.error("Error fetching analytics data:",e)}};return t?(0,a.jsx)(l.Z,{children:(0,a.jsxs)("div",{className:"container mx-auto px-4 py-8",children:[(0,a.jsx)("h1",{className:"text-3xl font-bold mb-6",children:"Analytics Dashboard"}),(0,a.jsx)("div",{className:"grid grid-cols-1 gap-6 mb-8",children:(0,a.jsxs)("div",{className:"p-6 rounded-lg shadow",children:[(0,a.jsx)("h2",{className:"text-xl font-semibold mb-2",children:"Total Commentaries"}),(0,a.jsx)(y,{total:t.totalCommentaries})]})}),(0,a.jsxs)("div",{className:"p-6 rounded-lg shadow",children:[(0,a.jsx)("h2",{className:"text-2xl font-semibold mb-4",children:"Latest Commentaries"}),(0,a.jsx)(N,{commentaries:t.similaritySearch||[]}),(0,a.jsx)("input",{type:"text",value:i,onChange:e=>{r(e.target.value),c()},placeholder:"Enter your prompt",className:"input-class"}),(0,a.jsxs)("table",{className:"w-full mt-4",children:[(0,a.jsx)("thead",{children:(0,a.jsxs)("tr",{children:[(0,a.jsx)("th",{className:"px-4 py-2 text-left",children:"Timestamp"}),(0,a.jsx)("th",{className:"px-4 py-2 text-left",children:"Commentary"})]})}),(0,a.jsx)("tbody",{children:null==t?void 0:null===(e=t.similaritySearch)||void 0===e?void 0:e.map((e,t)=>(0,a.jsxs)("tr",{className:t%2==0?"bg-gray-800":"",children:[(0,a.jsx)("td",{className:"px-4 py-2",children:new Date(e.timestamp).toLocaleString()}),(0,a.jsx)("td",{className:"px-4 py-2",children:e.commentary})]},t))})]})]})]})}):(0,a.jsx)(l.Z,{children:(0,a.jsxs)("div",{className:"container mx-auto px-4 py-8",children:[(0,a.jsx)("h1",{className:"text-3xl font-bold mb-6",children:"Analytics Dashboard"}),(0,a.jsx)("p",{children:"Loading..."})]})})}}},function(e){e.O(0,[176,888,774,179],function(){return e(e.s=8178)}),_N_E=e.O()}]);