1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8035],{36990:function(e,s,t){(window.__NEXT_P=window.__NEXT_P||[]).push(["/admin/rag-analytics",function(){return t(95071)}])},39200:function(e,s,t){"use strict";t.d(s,{Z:function(){return a}});let a=(0,t(63759).Z)("AlertTriangle",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3Z",key:"c3ski4"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]])},89354:function(e,s,t){"use strict";t.d(s,{Z:function(){return a}});let a=(0,t(63759).Z)("Database",[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]])},46111:function(e,s,t){"use strict";t.d(s,{Z:function(){return a}});let a=(0,t(63759).Z)("DollarSign",[["line",{x1:"12",x2:"12",y1:"2",y2:"22",key:"7eqyqh"}],["path",{d:"M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6",key:"1b0p4s"}]])},7656:function(e,s,t){"use strict";t.d(s,{Z:function(){return a}});let a=(0,t(63759).Z)("MessageCircle",[["path",{d:"m3 21 1.9-5.7a8.5 8.5 0 1 1 3.8 3.8z",key:"v2veuj"}]])},44976:function(e,s,t){"use strict";t.d(s,{Z:function(){return a}});let a=(0,t(63759).Z)("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]])},46611:function(e,s,t){"use strict";t.d(s,{Z:function(){return a}});let a=(0,t(63759).Z)("Zap",[["polygon",{points:"13 2 3 14 12 14 11 22 21 10 12 10 13 2",key:"45s27k"}]])},95071:function(e,s,t){"use strict";t.r(s),t.d(s,{default:function(){return y}});var a=t(85893),n=t(67294),l=t(9008),c=t.n(l),i=t(11163),r=t(85412),d=t(67694),o=t(92761),m=t(7656),x=t(44976),h=t(39200),u=t(46111),p=t(46611),j=t(89354);function g(e){return e?"$".concat(e.toFixed(4)):"$0.00"}function y(){let{theme:e}=(0,d.F)(),s=(0,i.useRouter)(),[t,l]=(0,n.useState)(null),[y,N]=(0,n.useState)(!0),[f,b]=(0,n.useState)(""),[v,w]=(0,n.useState)(30),k="dark"===e,Z=k?"glass glass-dark":"glass",A=k?"text-[#818384]":"text-gray-600",C=k?"text-white":"text-gray-900",M=async()=>{let e=localStorage.getItem("admin_key");if(!e){b("Admin key required â open /admin and authenticate first."),N(!1);return}N(!0),b("");try{let s=await fetch("/api/admin/rag-analytics?days=".concat(v),{headers:{"x-admin-key":e}}),t=await s.json();if(!s.ok)throw Error((null==t?void 0:t.error)||"Failed to load");l(t)}catch(e){b((null==e?void 0:e.message)||"Failed to load")}finally{N(!1)}};(0,n.useEffect)(()=>{M()},[v]);let S=Math.max(...(null==t?void 0:t.daily.map(e=>e.messages))||[1],1);return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(c(),{children:(0,a.jsx)("title",{children:"Career AI RAG Analytics â Admin"})}),(0,a.jsx)(r.Z,{}),(0,a.jsxs)("main",{className:"max-w-6xl mx-auto px-4 py-8",children:[(0,a.jsxs)("button",{type:"button",onClick:()=>s.push("/admin"),className:"inline-flex items-center gap-2 text-sm mb-6 ".concat(A),children:[(0,a.jsx)(o.Z,{className:"w-4 h-4"})," Back to admin"]}),(0,a.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-4 mb-8",children:[(0,a.jsxs)("div",{children:[(0,a.jsxs)("h1",{className:"text-2xl font-bold flex items-center gap-2 ".concat(C),children:[(0,a.jsx)(m.Z,{className:"w-7 h-7 text-indigo-500"}),"Career AI / RAG Analytics"]}),(0,a.jsx)("p",{className:"text-sm mt-1 ".concat(A),children:"Usage, OpenAI cost, streaming rate, and job embedding index"})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("select",{value:v,onChange:e=>w(Number(e.target.value)),className:"text-sm rounded-lg border px-3 py-2",children:[7,14,30,60,90].map(e=>(0,a.jsxs)("option",{value:e,children:["Last ",e," days"]},e))}),(0,a.jsxs)("button",{type:"button",onClick:M,className:"inline-flex items-center gap-1 px-3 py-2 rounded-lg bg-indigo-600 text-white text-sm font-semibold",children:[(0,a.jsx)(x.Z,{className:"w-4 h-4"})," Refresh"]})]})]}),f&&(0,a.jsxs)("div",{className:"mb-6 p-4 rounded-xl bg-red-500/10 text-red-600 flex items-center gap-2",children:[(0,a.jsx)(h.Z,{className:"w-5 h-5"})," ",f]}),y&&(0,a.jsx)("p",{className:A,children:"Loadingâ¦"}),t&&!y&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 mb-8",children:[{icon:m.Z,label:"Messages",value:t.summary.totalMessages},{icon:u.Z,label:"Est. OpenAI cost",value:g(t.summary.totalEstimatedUsd)},{icon:p.Z,label:"Streamed",value:"".concat(t.summary.streamRatePct,"%")},{icon:j.Z,label:"Avg latency",value:"".concat(t.summary.avgDurationMs,"ms")}].map(e=>(0,a.jsxs)("div",{className:"".concat(Z," rounded-2xl p-5 shadow-premium"),children:[(0,a.jsx)(e.icon,{className:"w-8 h-8 text-indigo-500 mb-2"}),(0,a.jsx)("div",{className:"text-2xl font-bold ".concat(C),children:e.value}),(0,a.jsx)("div",{className:"text-xs ".concat(A),children:e.label})]},e.label))}),(0,a.jsxs)("div",{className:"grid md:grid-cols-2 gap-6 mb-8",children:[(0,a.jsxs)("div",{className:"".concat(Z," rounded-2xl p-5"),children:[(0,a.jsx)("h2",{className:"font-bold mb-4 ".concat(C),children:"Cost breakdown"}),(0,a.jsxs)("ul",{className:"text-sm space-y-2 ".concat(A),children:[(0,a.jsxs)("li",{children:["Avg cost / message: ",(0,a.jsx)("strong",{className:C,children:g(t.summary.avgCostPerMessage)})]}),(0,a.jsxs)("li",{children:["Prompt tokens: ",(0,a.jsx)("strong",{className:C,children:t.summary.totalPromptTokens.toLocaleStr
1ing()})]}),(0,a.jsxs)("li",{children:["Completion tokens: ",(0,a.jsx)("strong",{className:C,children:t.summary.totalCompletionTokens.toLocaleString()})]}),(0,a.jsxs)("li",{children:["Success / fail: ",(0,a.jsxs)("strong",{className:C,children:[t.summary.successCount," / ",t.summary.failCount]})]}),(0,a.jsxs)("li",{children:["Avg jobs retrieved: ",(0,a.jsx)("strong",{className:C,children:t.summary.avgJobsRetrieved})]})]})]}),(0,a.jsxs)("div",{className:"".concat(Z," rounded-2xl p-5"),children:[(0,a.jsx)("h2",{className:"font-bold mb-4 ".concat(C),children:"Job embedding index"}),0===t.embeddingIndex.length?(0,a.jsxs)("p",{className:"text-sm ".concat(A),children:["No embeddings indexed yet. Run nightly cron or"," ",(0,a.jsx)("code",{className:"text-xs",children:"node scripts/index-job-embeddings.js"})]}):(0,a.jsx)("ul",{className:"text-sm space-y-2 ".concat(A),children:t.embeddingIndex.map(e=>(0,a.jsxs)("li",{children:[e.country,": ",(0,a.jsx)("strong",{className:C,children:e.count.toLocaleString()})," jobs"]},e.country))})]})]}),(0,a.jsxs)("div",{className:"".concat(Z," rounded-2xl p-5 mb-8"),children:[(0,a.jsx)("h2",{className:"font-bold mb-4 ".concat(C),children:"Daily volume"}),(0,a.jsx)("div",{className:"flex items-end gap-1 h-40 overflow-x-auto",children:t.daily.map(e=>(0,a.jsxs)("div",{className:"flex flex-col items-center flex-1 min-w-[24px]",children:[(0,a.jsx)("div",{className:"w-full max-w-[20px] rounded-t bg-indigo-500",style:{height:"".concat(e.messages/S*100,"%"),minHeight:e.messages?4:0},title:"".concat(e.date,": ").concat(e.messages," msgs, ").concat(g(e.estimatedUsd))}),(0,a.jsx)("span",{className:"text-[9px] mt-1 ".concat(A),children:e.date.slice(5)})]},e.date))})]}),(0,a.jsxs)("div",{className:"".concat(Z," rounded-2xl p-5 mb-8"),children:[(0,a.jsx)("h2",{className:"font-bold mb-4 ".concat(C),children:"By intent"}),(0,a.jsx)("div",{className:"overflow-x-auto",children:(0,a.jsxs)("table",{className:"w-full text-sm",children:[(0,a.jsx)("thead",{children:(0,a.jsxs)("tr",{className:A,children:[(0,a.jsx)("th",{className:"text-left py-2",children:"Intent"}),(0,a.jsx)("th",{className:"text-right py-2",children:"Count"}),(0,a.jsx)("th",{className:"text-right py-2",children:"USD"})]})}),(0,a.jsx)("tbody",{children:t.byIntent.map(e=>(0,a.jsxs)("tr",{className:"border-t border-gray-200/20",children:[(0,a.jsx)("td",{className:"py-2 ".concat(C),children:e.intent}),(0,a.jsx)("td",{className:"text-right py-2",children:e.count}),(0,a.jsx)("td",{className:"text-right py-2",children:g(e.estimatedUsd)})]},e.intent))})]})})]}),(0,a.jsxs)("div",{className:"".concat(Z," rounded-2xl p-5"),children:[(0,a.jsx)("h2",{className:"font-bold mb-4 ".concat(C),children:"Recent messages"}),(0,a.jsx)("div",{className:"overflow-x-auto max-h-96 overflow-y-auto",children:(0,a.jsxs)("table",{className:"w-full text-xs",children:[(0,a.jsx)("thead",{children:(0,a.jsxs)("tr",{className:A,children:[(0,a.jsx)("th",{className:"text-left py-2",children:"Time"}),(0,a.jsx)("th",{className:"text-left py-2",children:"Intent"}),(0,a.jsx)("th",{className:"text-left py-2",children:"Preview"}),(0,a.jsx)("th",{className:"text-right py-2",children:"USD"}),(0,a.jsx)("th",{className:"text-right py-2",children:"ms"}),(0,a.jsx)("th",{className:"text-right py-2",children:"Jobs"})]})}),(0,a.jsx)("tbody",{children:t.recent.map((e,s)=>(0,a.jsxs)("tr",{className:"border-t border-gray-200/20",children:[(0,a.jsx)("td",{className:"py-2 whitespace-nowrap",children:new Date(e.at).toLocaleString()}),(0,a.jsx)("td",{className:"py-2",children:e.intent}),(0,a.jsx)("td",{className:"py-2 max-w-[200px] truncate",title:e.preview,children:e.preview}),(0,a.jsx)("td",{className:"text-right py-2",children:g(e.estimatedUsd)}),(0,a.jsx)("td",{className:"text-right py-2",children:e.durationMs}),(0,a.jsx)("td",{className:"text-right py-2",children:e.jobsRetrieved})]},s))})]})})]})]})]})]})}}},function(e){e.O(0,[4968,1296,5412,2888,9774,179],function(){return e(e.s=36990)}),_N_E=e.O()}]);
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.