1import{j as e}from"./index-Co_COyci.js";import{u as x}from"./useQuery-DqEksgYJ.js";import{u as m}from"./useServerFn-BKNxTzPx.js";import{C as i}from"./card-cZcrpr2o.js";import{B as h}from"./badge-gTQnF4Q_.js";import{a as p}from"./admin-phase2.functions-aPQPAMBe.js";import{M as u}from"./message-square-CNmKUjqu.js";import{k as j,X as n,Y as o,B as c,l as g,m as N,R as f,n as b,T as v}from"./generateCategoricalChart-DF4Lz6x2.js";import{c as _}from"./createLucideIcon-D9X7GujO.js";import{S as y}from"./sparkles-Du7MObM_.js";import"./utils-BQHNewu7.js";import"./index-LHNt3CwB.js";import"./auth-middleware-Bw-vsZYX.js";const T=[["path",{d:"M16 7h6v6",key:"box55l"}],["path",{d:"m22 7-8.5 8.5-5-5L2 17",key:"1t1m79"}]],C=_("trending-up",T);var M=j({chartName:"BarChart",GraphicalChild:c,defaultTooltipEventType:"axis",validateTooltipEventTypes:["axis","item"],axisComponents:[{axisType:"xAxis",AxisComp:n},{axisType:"yAxis",AxisComp:o}],formatAxisMap:g});function d(a){return`$${a.toFixed(2)}`}function $(){const a=m(p),{data:t,isLoading:r}=x({queryKey:["admin-credits"],queryFn:()=>a()});return e.jsxs("div",{className:"p-6 space-y-6 max-w-7xl mx-auto",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"AI Credits & Kosten"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Geschätzte Lovable-AI-Kosten basierend auf Message-Volumen (~",350," Tokens/Msg, modell-spezifischer Preis)."]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[e.jsx(l,{icon:u,label:"Messages 30d",value:t?.total_messages_30d??"â¦",sub:t?`${t.total_messages_7d} in 7d`:""}),e.jsx(l,{icon:N,label:"Geschätzte Kosten 30d",value:t?d(t.est_cost_30d_usd):"â¦"}),e.jsx(l,{icon:C,label:"à Kosten pro Message",value:t?`$${t.est_cost_per_msg.toFixed(4)}`:"â¦"}),e.jsx(l,{icon:y,label:"Aktive GPTs",value:t?.per_gpt.length??"â¦"})]}),e.jsxs(i,{className:"p-4",children:[e.jsx("h2",{className:"font-semibold mb-3",children:"Messages pro Tag (30 Tage)"}),e.jsx("div",{className:"h-56",children:e.jsx(f,{width:"100%",height:"100%",children:e.jsxs(M,{data:t?.per_day??[],children:[e.jsx(b,{strokeDasharray:"3 3",className:"opacity-20"}),e.jsx(n,{dataKey:"date",tick:{fontSize:10},tickFormatter:s=>s.slice(5)}),e.jsx(o,{tick:{fontSize:10}}),e.jsx(v,{contentStyle:{background:"hsl(var(--background))",border:"1px solid hsl(var(--border))",fontSize:12}}),e.jsx(c,{dataKey:"messages",fill:"hsl(var(--primary))",radius:[4,4,0,0]})]})})})]}),e.jsxs(i,{className:"overflow-hidden",children:[e.jsx("div",{className:"p-3 border-b",children:e.jsx("h2",{className:"font-semibold",children:"Verbrauch pro GPT"})}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:"bg-muted/40 text-xs uppercase text-muted-foreground",children:e.jsxs("tr",{children:[e.jsx("th",{className:"text-left p-3",children:"GPT"}),e.jsx("th",{className:"text-left p-3",children:"Model"}),e.jsx("th",{className:"text-right p-3",children:"Messages"}),e.jsx("th",{className:"text-right p-3",children:"Unique User"}),e.jsx("th",{className:"text-right p-3",children:"Geschätzte Kosten"})]})}),e.jsxs("tbody",{children:[r&&e.jsx("tr",{children:e.jsx("td",{colSpan:5,className:"p-6 text-center text-muted-foreground",children:"Lädtâ¦"})}),!r&&(t?.per_gpt.length??0)===0&&e.jsx("tr",{children:e.jsx("td",{colSpan:5,className:"p-6 text-center text-muted-foreground",children:"Noch keine Nutzung."})}),t?.per_gpt.map(s=>e.jsxs("tr",{className:"border-t hover:bg-muted/30",children:[e.jsxs("td",{className:"p-3",children:[e.jsx("span",{className:"mr-2",children:s.gpt_icon}),s.gpt_name]}),e.jsx("td",{className:"p-3",children:e.jsx(h,{variant:"outline",className:"text-[10px] font-mono",children:s.model})}),e.jsx("td",{className:"p-3 text-right tabular-nums",children:s.messages}),e.jsx("td",{className:"p-3 text-right tabular-nums",children:s.unique_users}),e.jsx("td",{className:"p-3 text-right tabular-nums",children:d(s.est_cost_usd)})]},s.gpt_id))]})]})})]}),e.jsxs(i,{className:"overflow-hidden",children:[e.jsx("div",{className:"p-3 border-b",children:e.jsx("h2",{className:"font-semibold",children:"Top 20 User (Messages 30d)"})}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:"bg-muted/40 text-xs uppercase text-muted-foreground",children:e.jsxs("tr",{children:[e.jsx("th",{className:"text-left p-3",children:"User"}),e.jsx("th",{className:"text-right p-3",children:"Messages"})]})}),e.jsx("tbody",{children:t?.top_users.map(s=>e.jsxs("tr",{className:"border-t hover:bg-muted/30",children:[e.jsx("td",{className:"p-3",children:s.name??e.jsxs("span",{className:"text-muted-foreground text-xs",children:[s.user_id.slice(0,8),"â¦"]})}),e.jsx("td",{className:"p-3 text-right tabular-nums",children:s.messages})]}
1,s.user_id))})]})})]})]})}function l({icon:a,label:t,value:r,sub:s}){return e.jsxs(i,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:t}),e.jsx(a,{className:"w-4 h-4 text-muted-foreground"})]}),e.jsx("p",{className:"text-2xl font-bold mt-1",children:r}),s&&e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:s})]})}export{$ as component};
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.