PageSourceSearch

https://ronaldstolk.nl/assets/GebruikAdmin-Bo9Fq_wK.js

js ronaldstolk.nl collected 2026-10-04 07:32:22 UTC 37,445 bytes, 1 lines download raw bytes

1import{r as p,j as e,L as Se}from"./vendor-B5DssOfd.js";import{D as $e}from"./DashboardLayout-DYuT_LER.js";import{R as j,X as v,Y as y,T as g}from"./CartesianChart-Eon_FRs7.js";import{B as D,a as k,C as Ce}from"./BarChart-CPyDoWd9.js";import{C as _}from"./getRadiusAndStrokeWidthFromDot-BJUOd2nR.js";import{P as Ae,a as Te}from"./PieChart-67MQv9fy.js";import{L as O}from"./Legend-BsyHuKjn.js";import{A as de,a as U}from"./AreaChart-D07M7oUq.js";import"./index-DkvNy9W1.js";import"./i18n-uURfBduE.js";import"./PolarChart-COQMklrE.js";const P="https://api.rstcc.net";function z(){const o=localStorage.getItem("token")??sessionStorage.getItem("token")??"";return o?{Authorization:`Token ${o}`}:{}}function l(o){return`€${o.toFixed(2)}`}function r(o){return o.toLocaleString("nl-NL")}const Ie=[{label:"7d",days:7},{label:"30d",days:30},{label:"90d",days:90},{label:"365d",days:365}],xe=["#6366f1","#22d3ee","#a78bfa","#34d399","#fb923c","#f472b6","#facc15","#38bdf8"];function b({label:o,value:h,icon:n,sub:u,highlight:i}){return e.jsxs("div",{className:`rounded-2xl border p-4 space-y-1 ${i?"bg-primary/8 border-primary/20":"bg-surface-container border-outline-variant/10"}`,children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:`material-symbols-outlined text-sm ${i?"text-primary":"text-on-surface-variant/50"}`,children:n}),e.jsx("span",{className:"text-[9px] font-black uppercase tracking-widest text-on-surface-variant/40",children:o})]}),e.jsx("p",{className:`text-xl font-black ${i?"text-primary":"text-on-surface"}`,children:h}),u&&e.jsx("p",{className:"text-[10px] text-on-surface-variant/40",children:u})]})}function N({title:o,children:h,span:n=1}){return e.jsxs("div",{className:`bg-surface-container rounded-2xl border border-outline-variant/10 p-5 ${n===2?"col-span-2":""}`,children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-widest text-on-surface-variant/40 mb-4",children:o}),h]})}const w=({active:o,payload:h,label:n})=>!o||!(h!=null&&h.length)?null:e.jsxs("div",{className:"bg-surface-container-high border border-outline-variant/20 rounded-xl px-3 py-2 text-xs shadow-lg",children:[n&&e.jsx("p",{className:"font-bold text-on-surface mb-1",children:n}),h.map(u=>e.jsxs("p",{style:{color:u.color},children:[u.name,": ",e.jsx("span",{className:"font-bold",children:typeof u.value=="number"&&u.value<1e3?u.value.toFixed(2):r(u.value)})]},u.name))]});function Be(){var ne,ie,oe,ce;const[o,h]=p.useState(30),[n,u]=p.useState([]),[i,pe]=p.useState(null),[V,q]=p.useState(!0),[$,ue]=p.useState("data"),[C,fe]=p.useState("ai_cost_eur"),[H,X]=p.useState(!1),[F,me]=p.useState(""),[K,L]=p.useState(!1),[f,A]=p.useState(null),[M,Y]=p.useState(null),[s,W]=p.useState(null),[J,Z]=p.useState(!1),[R,Q]=p.useState(""),[ee,te]=p.useState(!1),[B,T]=p.useState("");function ae(){q(!0),fetch(`${P}/api/admin/gebruik/?days=${o}`,{headers:z()}).then(t=>t.json()).then(t=>{u(t.users??[]),pe(t.totals??null)}).catch(()=>{}).finally(()=>q(!1))}p.useEffect(()=>{ae()},[o]);function he(t){C===t?X(a=>!a):(fe(t),X(!1))}async function be(t){Z(!0),W(null),T(""),Q("");try{const a=await fetch(`${P}/api/admin/gebruik/user/${t}/?days=${o}`,{headers:z()});W(await a.json())}catch{}finally{Z(!1)}}async function je(){if(!s)return;const t=parseFloat(R);if(!isNaN(t)){te(!0),T("");try{const a=await fetch(`${P}/api/admin/gebruik/user/${s.user.id}/wallet-adjust/`,{method:"POST",headers:{...z(),"Content-Type":"application/json"},body:JSON.stringify({set_to:t.toFixed(2)})}),c=await a.json();if(!a.ok){T(c.error||"Fout.");return}const d=c.token_equivalent!==null?` (≈ ${c.token_equivalent.toLocaleString("nl-NL")} tokens)`:"";T(`✓ Nieuw saldo: €${c.balance_eur.toFixed(2)}${d}`),W(m=>m&&{...m,user:{...m.user,wallet_balance:c.balance_eur}})}catch(a){T(String(a))}finally{te(!1)}}}async function ge(){L(!0),A(null);try{const t=await fetch(`${P}/api/admin/gebruik/import-log/?days=${o}&dry_run=1`,{method:"POST",headers:z()});A(await t.json())}catch{}finally{L(!1)}}async function ke(){L(!0);try{const a=await(await fetch(`${P}/api/admin/gebruik/import-log/?days=${o}`,{method:"POST",headers:z()})).json();Y(a),A(null),ae()}catch{}finally{L(!1)}}const I=[...n.filter(t=>!F||t.name.toLowerCase().includes(F.toLowerCase())||t.email.toLowerCase().includes(F.toLowerCase()))].sort((t,a)=>{const c=t[C],d=a[C];return H?c-d:d-c}),se=[...n].sort((t,a)=>a.ai_tokens-t.ai_tokens).slice(0,10).map(t=>({name:t.name.split(" ")[0],tokens:t.ai_tokens,app:t.calls_app,portal:t.calls_portal})),ve=[...n].sort((t,a)=>a.ai_margin_eur-t.ai_margin_eur).slice(0,10).map(t=>({name:t.name.split(" ")[0],inkoop:parseFloat(t.ai_cost_eur.toFixed(2)),marge:parseFloat(t.ai_margin_eur.toFixed(2))})),re=[...n].filter(t=>t.workouts>0).sort((t,a)=>
1a.workouts-t.workouts).slice(0,10).map(t=>({name:t.name.split(" ")[0],workouts:t.workouts})),E=(()=>{const t=n.reduce((c,d)=>c+d.calls_app,0),a=n.reduce((c,d)=>c+d.calls_portal,0);return[{name:"App",value:t,color:"#6366f1"},{name:"Portal",value:a,color:"#a78bfa"}]})(),le=[...n].filter(t=>t.wallet_balance>0).sort((t,a)=>a.wallet_balance-t.wallet_balance).slice(0,10).map(t=>({name:t.name.split(" ")[0],saldo:parseFloat(t.wallet_balance.toFixed(2)),gekocht:parseFloat(t.purchased_eur.toFixed(2))}));(()=>{const t=n.reduce((d,m)=>d+m.calls_app,0),a=n.reduce((d,m)=>d+m.calls_portal,0),c=n.reduce((d,m)=>d+m.workouts,0);return n.reduce((d,m)=>d+m.ai_calls,0)-c,[{name:"App calls",value:t,color:"#6366f1"},{name:"Portal calls",value:a,color:"#a78bfa"},{name:"Workouts",value:c,color:"#34d399"}]})();const ye=[...n].filter(t=>t.ai_cost_eur>0||t.ai_sell_eur>0).sort((t,a)=>a.ai_sell_eur-t.ai_sell_eur).slice(0,10).map(t=>({name:t.name.split(" ")[0],inkoop:parseFloat(t.ai_cost_eur.toFixed(4)),verkoop:parseFloat(t.ai_sell_eur.toFixed(4))})),_e=n.filter(t=>t.ai_calls>0).length,Ne=n.filter(t=>t.wallet_balance>0).length,we=n.length?Math.round(n.reduce((t,a)=>t+a.ai_calls,0)/n.length):0,S=n.reduce((t,a)=>t+a.calls_app,0),G=n.reduce((t,a)=>t+a.calls_portal,0),x=({k:t,label:a,right:c=!0})=>e.jsxs("th",{onClick:()=>he(t),className:`px-3 py-3 text-[9px] font-black uppercase tracking-widest cursor-pointer select-none whitespace-nowrap ${c?"text-right":"text-left"} ${C===t?"text-primary":"text-on-surface-variant/50"}`,children:[a,C===t?H?" ↑":" ↓":""]});return e.jsxs($e,{children:[e.jsxs("div",{className:"p-6 max-w-[1600px] mx-auto space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between flex-wrap gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(Se,{to:"/admin/dashboard?tab=tools",className:"flex items-center gap-1.5 px-3 py-2 rounded-xl bg-surface-container border border-outline-variant/20 hover:border-primary/30 hover:bg-primary/5 transition-all text-on-surface-variant hover:text-primary",children:[e.jsx("span",{className:"material-symbols-outlined text-sm",children:"arrow_back"}),e.jsx("span",{className:"text-[11px] font-black uppercase tracking-widest",children:"Dashboard"})]}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-black text-on-surface tracking-tight",children:"Gebruik"}),e.jsx("p",{className:"text-sm text-on-surface-variant/60 mt-0.5",children:"AI-gebruik, kosten, marge en saldo per gebruiker"})]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[$==="data"&&e.jsx("input",{value:F,onChange:t=>me(t.target.value),placeholder:"Zoek gebruiker…",className:"bg-surface-container border border-outline-variant/20 rounded-xl px-4 py-2 text-sm focus:outline-none focus:border-primary/50 w-48"}),e.jsxs("button",{onClick:ge,disabled:K,className:"flex items-center gap-1.5 px-4 py-2 rounded-xl bg-amber-500/10 border border-amber-500/30 hover:bg-amber-500/20 transition-all text-amber-400 disabled:opacity-50",children:[e.jsx("span",{className:"material-symbols-outlined text-sm",children:"download"}),e.jsx("span",{className:"text-[11px] font-black uppercase tracking-widest",children:K?"Bezig…":"Importeer log"})]}),e.jsx("div",{className:"flex items-center gap-1 bg-surface-container border border-outline-variant/20 rounded-xl p-1",children:Ie.map(t=>e.jsx("button",{onClick:()=>h(t.days),className:`px-3 py-1.5 rounded-lg text-[11px] font-black uppercase tracking-widest transition-all ${o===t.days?"bg-primary text-white shadow":"text-on-surface-variant/60 hover:text-on-surface"}`,children:t.label},t.days))})]})]}),M&&e.jsxs("div",{className:"flex items-center gap-3 px-5 py-4 rounded-2xl bg-green-500/10 border border-green-500/20",children:[e.jsx("span",{className:"material-symbols-outlined text-green-400",children:"check_circle"}),e.jsxs("div",{children:[e.jsxs("p",{className:"text-sm font-bold text-green-400",children:[M.imported," entries geïmporteerd"]}),e.jsxs("p",{className:"text-xs text-on-surface-variant/50",children:["Verkoop: ",l(M.total_sell_eur)," · Inkoop: ",l(M.total_cost_eur)]})]}),e.jsx("button",{onClick:()=>Y(null),className:"ml-auto text-on-surface-variant/30 hover:text-on-surface-variant",children:e.jsx("span",{className:"material-symbols-outlined text-sm",children:"close"})})]}),i&&e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 lg:grid-cols-8 gap-3",children:[e.jsx(b,{label:"AI calls",value:r(i.ai_calls),icon:"bolt",sub:`App ${r(S)} / Portal ${r(G)}`}),e.jsx(b,{label:"Tokens",value:r(i.ai_tokens),icon:"token"}),e.jsx(b,{label:"Inkoop",value:l(i.ai_cost_eur),icon:"shopping_cart"}),e.jsx(b,{label:"Verkoop",value:l(i.ai_sell_eur),icon:"sell"}),e.jsx(b,{label:"Marge",value:l(i.ai_margin_eur),icon:"trending_up",highlight:!0}),e.jsx(b,{label:"Workouts",value:r(i.workouts),icon:"fitness_center"}),e.jsx(b,{label:"DB-koppelingen",value:r(i.db_workouts_linked),icon:"link",sub:l(i.db_workouts_spend_eur)}),e.jsx(b,{label:"Aankopen",value:l(i.purchased_eur),icon:"payments"}),e.jsx(b,{label:"Orders",value:r(i.orders_count),icon:"receipt_long"})]}),e.jsx("div",{className:"flex gap-1 bg-surface-container border border-outline-variant/10 rounded-2xl p-1 w-fit",children:["data","charts"].map(t=>e.jsxs("button",{onClick:()=>ue(t),className:`flex items-center gap-2 px-5 py-2 rounded-xl text-[11px] font-black uppercase tracking-widest transition-all ${$===t?"bg-primary text-white shadow":"text-on-surface-variant/60 hover:text-on-surface"}`,children:[e.jsx("span",{className:"material-symbols-outlined text-sm",children:t==="data"?"table_rows":"bar_chart"}),t==="data"?"Data":"Statistieken"]},t))}),$==="data"&&e.jsx("div",{className:"bg-surface-container rounded-2xl border border-outline-variant/10 overflow-auto",children:V?e.jsx("div",{className:"flex items-center justify-center h-40",children:e.jsx("div",{className:"w-8 h-8 border-2 border-primary/30 border-t-primary rounded-full animate-spin"})}):I.length===0?e.jsx("p",{className:"text-center py-12 text-on-surface-variant/30 text-sm",children:"Geen gebruikers gevonden"}):e.jsxs("table",{className:"w-full text-sm border-collapse",children:[e.jsx("thead",{className:"border-b border-outline-variant/10 sticky top-0 bg-surface-container z-10",children:e.jsxs("tr",{children:[e.jsx(x,{k:"name",label:"Gebruiker",right:!1}),e.jsx(x,{k:"ai_calls",label:"Calls"}),e.jsx(x,{k:"calls_app",label:"App"}),e.jsx(x,{k:"calls_portal",label:"Portal"}),e.jsx(x,{k:"ai_tokens",label:"Tokens"}),e.jsx(x,{k:"ai_cost_eur",label:"Inkoop"}),e.jsx(x,{k:"margin_pct",label:"Marge %"}),e.jsx(x,{k:"ai_sell_eur",label:"Verkoop"}),e.jsx(x,{k:"ai_margin_eur",label:"Marge €"}),e.jsx(x,{k:"workouts",label:"Workouts"}),e.jsx(x,{k:"price_per_schema",label:"€/workout"}),e.jsx(x,{k:"db_workouts_linked",label:"DB-koppelingen"}),e.jsx(x,{k:"db_workouts_spend_eur",label:"DB-uitgaven"}),e.jsx(x,{k:"wallet_balance",label:"Saldo"}),e.jsx(x,{k:"purchased_eur",label:"Gekocht"}),e.jsx(x,{k:"topup_count",label:"Topups"}),e.jsx(x,{k:"orders_count",label:"Orders"})]})}),e.jsx("tbody",{children:I.map((t,a)=>e.jsxs("tr",{onClick:()=>be(t.user_id),className:`border-b border-outline-variant/5 hover:bg-primary/5 curs
1or-pointer transition-colors ${a%2?"bg-white/[0.015]":""}`,children:[e.jsxs("td",{className:"px-3 py-2.5",children:[e.jsx("p",{className:"text-xs font-bold text-on-surface group-hover:text-primary",children:t.name}),e.jsx("p",{className:"text-[10px] text-on-surface-variant/40",children:t.email})]}),e.jsx("td",{className:"px-3 py-2.5 text-right text-xs text-on-surface-variant/70",children:r(t.ai_calls)}),e.jsx("td",{className:"px-3 py-2.5 text-right text-xs",children:t.calls_app>0?e.jsx("span",{className:"text-blue-400 font-bold",children:r(t.calls_app)}):e.jsx("span",{className:"text-on-surface-variant/20",children:"–"})}),e.jsx("td",{className:"px-3 py-2.5 text-right text-xs",children:t.calls_portal>0?e.jsx("span",{className:"text-violet-400 font-bold",children:r(t.calls_portal)}):e.jsx("span",{className:"text-on-surface-variant/20",children:"–"})}),e.jsx("td",{className:"px-3 py-2.5 text-right text-xs text-on-surface-variant/70",children:r(t.ai_tokens)}),e.jsx("td",{className:"px-3 py-2.5 text-right text-xs text-on-surface-variant/70",children:l(t.ai_cost_eur)}),e.jsx("td",{className:"px-3 py-2.5 text-right text-xs text-on-surface-variant/70",children:t.margin_pct>0?`${t.margin_pct}%`:"–"}),e.jsx("td",{className:"px-3 py-2.5 text-right text-xs font-bold text-on-surface",children:l(t.ai_sell_eur)}),e.jsx("td",{className:`px-3 py-2.5 text-right text-xs font-bold ${t.ai_margin_eur>0?"text-green-400":"text-on-surface-variant/40"}`,children:t.ai_margin_eur>0?`+${l(t.ai_margin_eur)}`:"–"}),e.jsx("td",{className:"px-3 py-2.5 text-right text-xs text-on-surface-variant/70",children:t.workouts>0?r(t.workouts):"–"}),e.jsx("td",{className:"px-3 py-2.5 text-right text-xs text-on-surface-variant/70",children:t.price_per_schema>0?l(t.price_per_schema):"–"}),e.jsx("td",{className:"px-3 py-2.5 text-right text-xs text-on-surface-variant/70",children:t.db_workouts_linked>0?r(t.db_workouts_linked):"–"}),e.jsx("td",{className:"px-3 py-2.5 text-right text-xs text-on-surface-variant/70",children:t.db_workouts_spend_eur>0?l(t.db_workouts_spend_eur):"–"}),e.jsx("td",{className:`px-3 py-2.5 text-right text-xs font-bold ${t.wallet_balance>0?"text-primary":"text-on-surface-variant/40"}`,children:l(t.wallet_balance)}),e.jsx("td",{className:"px-3 py-2.5 text-right text-xs text-on-surface-variant/70",children:t.purchased_eur>0?l(t.purchased_eur):"–"}),e.jsx("td",{className:"px-3 py-2.5 text-right text-xs text-on-surface-variant/70",children:t.topup_count>0?r(t.topup_count):"–"}),e.jsx("td",{className:"px-3 py-2.5 text-right text-xs text-on-surface-variant/70",children:t.orders_count>0?r(t.orders_count):"–"})]},t.user_id))}),i&&e.jsx("tfoot",{className:"border-t border-outline-variant/20 bg-surface-container-high/50",children:e.jsxs("tr",{children:[e.jsxs("td",{className:"px-3 py-2.5 text-[10px] font-black uppercase tracking-widest text-on-surface-variant/50",children:["Totaal (",I.length,")"]}),e.jsx("td",{className:"px-3 py-2.5 text-right text-xs font-bold",children:r(i.ai_calls)}),e.jsx("td",{className:"px-3 py-2.5 text-right text-xs font-bold text-blue-400",children:r(I.reduce((t,a)=>t+a.calls_app,0))}),e.jsx("td",{className:"px-3 py-2.5 text-right text-xs font-bold text-violet-400",children:r(I.reduce((t,a)=>t+a.calls_portal,0))}),e.jsx("td",{className:"px-3 py-2.5 text-right text-xs font-bold",children:r(i.ai_tokens)}),e.jsx("td",{className:"px-3 py-2.5 text-right text-xs font-bold",children:l(i.ai_cost_eur)}),e.jsx("td",{className:"px-3 py-2.5"}),e.jsx("td",{className:"px-3 py-2.5 text-right text-xs font-bold",children:l(i.ai_sell_eur)}),e.jsxs("td",{className:"px-3 py-2.5 text-right text-xs font-bold text-green-400",children:["+",l(i.ai_margin_eur)]}),e.jsx("td",{className:"px-3 py-2.5 text-right text-xs font-bold",children:r(i.workouts)}),e.jsx("td",{className:"px-3 py-2.5"}),e.jsx("td",{className:"px-3 py-2.5 text-right text-xs font-bold",children:r(i.db_workouts_linked)}),e.jsx("td",{className:"px-3 py-2.5 text-right text-xs font-bold",children:l(i.db_workouts_spend_eur)}),e.jsx("td",{className:"px-3 py-2.5"}),e.jsx("td",{className:"px-3 py-2.5 text-right text-xs font-bold",children:l(i.purchased_eur)}),e.jsx("td",{className:"px-3 py-2.5"}),e.jsx("td",{className:"px-3 py-2.5 text-right text-xs font-bold",children:r(i.orders_count)})]})})]})}),$==="charts"&&!V&&e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3",children:[{label:"Actieve gebruikers",value:r(_e),icon:"person",color:"text-primary"},{label:"Gem. calls/gebruiker",value:r(we),icon:"bolt",color:"text-amber-400"},{label:"Gebruikers met saldo",value:r(Ne),icon:"account_balance_wallet",color:"text-green-400"},{label:"App vs Portal",value:`${S>0?Math.round(S/(S+G)*100):0}% app`,icon:"smartphone",color:"text-blue-400"}
1].map(t=>e.jsxs("div",{className:"bg-surface-container rounded-2xl border border-outline-variant/10 p-4 flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-surface-container-high flex items-center justify-center",children:e.jsx("span",{className:`material-symbols-outlined text-lg ${t.color}`,children:t.icon})}),e.jsxs("div",{children:[e.jsx("p",{className:`text-lg font-black ${t.color}`,children:t.value}),e.jsx("p",{className:"text-[10px] text-on-surface-variant/40 font-bold uppercase tracking-widest",children:t.label})]})]},t.label))}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[e.jsx(N,{title:"Top 10 tokengebruikers",children:e.jsx(j,{width:"100%",height:220,children:e.jsxs(D,{data:se,margin:{left:-10},children:[e.jsx(_,{strokeDasharray:"3 3",stroke:"#ffffff08"}),e.jsx(v,{dataKey:"name",tick:{fontSize:10,fill:"#ffffff40"}}),e.jsx(y,{tick:{fontSize:10,fill:"#ffffff40"},tickFormatter:t=>r(t)}),e.jsx(g,{content:e.jsx(w,{})}),e.jsx(k,{dataKey:"tokens",name:"Tokens",fill:"#6366f1",radius:[4,4,0,0]})]})})}),e.jsx(N,{title:"App vs Portal verdeling",children:e.jsxs("div",{className:"flex items-center gap-6",children:[e.jsx(j,{width:"55%",height:220,children:e.jsxs(Ae,{children:[e.jsx(Te,{data:E,cx:"50%",cy:"50%",innerRadius:55,outerRadius:85,dataKey:"value",nameKey:"name",paddingAngle:4,children:E.map((t,a)=>e.jsx(Ce,{fill:t.color},a))}),e.jsx(g,{content:e.jsx(w,{})})]})}),e.jsxs("div",{className:"space-y-3 flex-1",children:[E.map(t=>e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex justify-between text-xs",children:[e.jsx("span",{className:"font-bold",style:{color:t.color},children:t.name}),e.jsxs("span",{className:"text-on-surface-variant/60",children:[r(t.value)," calls"]})]}),e.jsx("div",{className:"h-1.5 bg-surface-container-high rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full rounded-full",style:{width:`${t.value/(S+G||1)*100}%`,background:t.color}})})]},t.name)),e.jsxs("p",{className:"text-[10px] text-on-surface-variant/30 pt-1",children:["Totaal ",r(S+G)," calls"]})]})]})}),e.jsx(N,{title:"Inkoop vs Verkoop per gebruiker (top 10)",children:e.jsx(j,{width:"100%",height:220,children:e.jsxs(D,{data:ye,margin:{left:-10},children:[e.jsx(_,{strokeDasharray:"3 3",stroke:"#ffffff08"}),e.jsx(v,{dataKey:"name",tick:{fontSize:10,fill:"#ffffff40"}}),e.jsx(y,{tick:{fontSize:10,fill:"#ffffff40"},tickFormatter:t=>`€${t.toFixed(2)}`}),e.jsx(g,{content:e.jsx(w,{})}),e.jsx(k,{dataKey:"inkoop",name:"Inkoop",fill:"#6366f1",radius:[4,4,0,0]}),e.jsx(k,{dataKey:"verkoop",name:"Verkoop",fill:"#34d399",radius:[4,4,0,0]}),e.jsx(O,{wrapperStyle:{fontSize:10,color:"#ffffff60"}})]})})}),e.jsx(N,{title:"App vs Portal per gebruiker (top 10)",children:e.jsx(j,{width:"100%",height:220,children:e.jsxs(D,{data:se,margin:{left:-10},layout:"vertical",children:[e.jsx(_,{strokeDasharray:"3 3",stroke:"#ffffff08"}),e.jsx(v,{type:"number",tick:{fontSize:10,fill:"#ffffff40"}}),e.jsx(y,{type:"category",dataKey:"name",tick:{fontSize:10,fill:"#ffffff40"},width:60}),e.jsx(g,{content:e.jsx(w,{})}),e.jsx(k,{dataKey:"app",name:"App",fill:"#6366f1",stackId:"a",radius:[0,0,0,0]}),e.jsx(k,{dataKey:"portal",name:"Portal",fill:"#a78bfa",stackId:"a",radius:[0,4,4,0]}),e.jsx(O,{wrapperStyle:{fontSize:10,color:"#ffffff60"}})]})})}),re.length>0&&e.jsx(N,{title:"Trainingen gegenereerd per gebruiker (top 10)",children:e.jsx(j,{width:"100%",height:220,children:e.jsxs(D,{data:re,margin:{left:-10},children:[e.jsx(_,{strokeDasharray:"3 3",stroke:"#ffffff08"}),e.jsx(v,{dataKey:"name",tick:{fontSize:10,fill:"#ffffff40"}}),e.jsx(y,{tick:{fontSize:10,fill:"#ffffff40"},allowDecimals:!1}),e.jsx(g,{content:e.jsx(w,{})}),e.jsx(k,{dataKey:"workouts",name:"Workouts",fill:"#34d399",radius:[4,4,0,0]})]})})}),le.length>0&&e.jsx(N,{title:"Saldo & aankopen per gebruiker (top 10)",children:e.jsx(j,{width:"100%",height:220,children:e.jsxs(D,{data:le,margin:{left:-10},children:[e.jsx(_,{strokeDasharray:"3 3",stroke:"#ffffff08"}),e.jsx(v,{dataKey:"name",tick:{fontSize:10,fill:"#ffffff40"}}),e.jsx(y,{tick:{fontSize:10,fill:"#ffffff40"},tickFormatter:t=>`€${t}`}),e.jsx(g,{content:e.jsx(w,{})}),e.jsx(k,{dataKey:"gekocht",name:"Gekocht",fill:"#6366f1",radius:[4,4,0,0]}),e.jsx(k,{dataKey:"saldo",name:"Saldo",fill:"#22d3ee",radius:[4,4,0,0]}
1),e.jsx(O,{wrapperStyle:{fontSize:10,color:"#ffffff60"}})]})})}),e.jsx(N,{title:"Marge per gebruiker (top 10)",span:2,children:e.jsx(j,{width:"100%",height:200,children:e.jsxs(de,{data:ve,margin:{left:0},children:[e.jsxs("defs",{children:[e.jsxs("linearGradient",{id:"gInkoop",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"5%",stopColor:"#6366f1",stopOpacity:.3}),e.jsx("stop",{offset:"95%",stopColor:"#6366f1",stopOpacity:0})]}),e.jsxs("linearGradient",{id:"gMarge",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"5%",stopColor:"#34d399",stopOpacity:.3}),e.jsx("stop",{offset:"95%",stopColor:"#34d399",stopOpacity:0})]})]}),e.jsx(_,{strokeDasharray:"3 3",stroke:"#ffffff08"}),e.jsx(v,{dataKey:"name",tick:{fontSize:10,fill:"#ffffff40"}}),e.jsx(y,{tick:{fontSize:10,fill:"#ffffff40"},tickFormatter:t=>`€${t}`}),e.jsx(g,{content:e.jsx(w,{})}),e.jsx(U,{type:"monotone",dataKey:"inkoop",name:"Inkoop",stroke:"#6366f1",fill:"url(#gInkoop)",strokeWidth:2}),e.jsx(U,{type:"monotone",dataKey:"marge",name:"Marge",stroke:"#34d399",fill:"url(#gMarge)",strokeWidth:2}),e.jsx(O,{wrapperStyle:{fontSize:10,color:"#ffffff60"}})]})})})]})]}),$==="charts"&&V&&e.jsx("div",{className:"flex items-center justify-center h-64",children:e.jsx("div",{className:"w-8 h-8 border-2 border-primary/30 border-t-primary rounded-full animate-spin"})})]}),(s||J)&&e.jsxs("div",{className:"fixed inset-0 z-50 bg-surface overflow-auto",children:[e.jsxs("div",{className:"sticky top-0 z-10 bg-surface/95 backdrop-blur border-b border-outline-variant/10 px-6 py-4 flex items-center gap-4",children:[e.jsxs("button",{onClick:()=>W(null),className:"flex items-center gap-2 text-on-surface-variant/60 hover:text-on-surface transition-colors text-sm font-bold",children:[e.jsx("span",{className:"material-symbols-outlined text-base",children:"arrow_back"}),"Terug"]}),J?e.jsxs("div",{className:"flex items-center gap-2 ml-2",children:[e.jsx("div",{className:"w-4 h-4 border-2 border-primary/30 border-t-primary rounded-full animate-spin"}),e.jsx("span",{className:"text-sm text-on-surface-variant/50",children:"Laden…"})]}):s?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"h-6 w-px bg-outline-variant/20"}),e.jsxs("div",{children:[e.jsx("span",{className:"text-base font-black text-on-surface",children:s.user.name}),e.jsxs("span",{className:"text-xs text-on-surface-variant/40 ml-3",children:[s.user.email," · ",s.user.site_profile??"geen profiel"]})]})]}):null]}),s&&e.jsxs("div",{className:"max-w-7xl mx-auto px-6 py-6 space-y-6",children:[e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-4 lg:grid-cols-8 gap-3",children:[{label:`Calls (${o}d)`,val:r(s.period.ai_calls),icon:"bolt",sub:`All-time: ${r(s.all_time.ai_calls)}`},{label:`Tokens (${o}d)`,val:r(s.period.ai_tokens),icon:"token",sub:`All-time: ${r(s.all_time.ai_tokens)}`},{label:`Workouts (${o}d)`,val:r(s.period.workouts),icon:"fitness_center",sub:`All-time: ${r(s.all_time.workouts)}`},{label:"Saldo",val:l(s.user.wallet_balance),icon:"account_balance_wallet",hl:s.user.wallet_balance>0},{label:"Totaal gekocht",val:l(s.credits.total_topup),icon:"payments",sub:`${s.credits.topup_count}× topup`},{label:"Totaal verbruikt",val:l(Math.abs(s.credits.total_spent)),icon:"receipt",sub:`${s.credits.spend_count}× afschrijving`},{label:`App (${o}d)`,val:r(s.period.calls_app),icon:"smartphone",sub:`All-time: ${r(s.all_time.calls_app)}`},{label:`Portal (${o}d)`,val:r(s.period.calls_portal),icon:"computer",sub:`All-time: ${r(s.all_time.calls_portal)}`}].map(t=>e.jsxs("div",{className:`rounded-2xl border p-4 ${t.hl?"bg-primary/8 border-primary/20":"bg-surface-container border-outline-variant/10"}`,children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-2",children:[e.jsx("span",{className:`material-symbols-outlined text-sm ${t.hl?"text-primary":"text-on-surface-variant/40"}`,children:t.icon}),e.jsx("span",{className:"text-[9px] font-black uppercase tracking-widest text-on-surface-variant/40 leading-tight",children:t.label})]}),e.jsx("p",{className:`text-xl font-black ${t.hl?"text-primary":"text-on-surface"}`,children:t.val}),t.sub&&e.jsx("p",{className:"text-[10px] text-on-surface-variant/30 mt-1",children:t.sub})]},t.label))}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[e.jsxs("div",{className:"lg:col-span-2 space-y-6",children:[s.daily.length>0&&e.jsxs("div",{className:"bg-surface-container rounded-2xl border border-outline-variant/10 p-5",children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-widest text-on-surface-variant/40 mb-4",children:"Dagelijks gebruik (90 dagen)"}),e.jsx(j,{width:"100%",height:220,children:e.jsxs(de,{data:s.daily,children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"gCalls",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"5%",
1stopColor:"#6366f1",stopOpacity:.3}),e.jsx("stop",{offset:"95%",stopColor:"#6366f1",stopOpacity:0})]})}),e.jsx(_,{strokeDasharray:"3 3",stroke:"#ffffff08"}),e.jsx(v,{dataKey:"date",tick:{fontSize:9,fill:"#ffffff30"},tickFormatter:t=>t==null?void 0:t.slice(5)}),e.jsx(y,{tick:{fontSize:9,fill:"#ffffff30"},allowDecimals:!1}),e.jsx(g,{contentStyle:{background:"#1e1e2e",border:"1px solid #ffffff15",borderRadius:8,fontSize:11}}),e.jsx(U,{type:"monotone",dataKey:"calls",name:"Calls",stroke:"#6366f1",fill:"url(#gCalls)",strokeWidth:2})]})})]}),s.by_module.length>0&&e.jsxs("div",{className:"bg-surface-container rounded-2xl border border-outline-variant/10 p-5",children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-widest text-on-surface-variant/40 mb-4",children:"Gebruik per module (all-time)"}),e.jsx("div",{className:"space-y-3",children:s.by_module.map((t,a)=>{var d;const c=((d=s.by_module[0])==null?void 0:d.calls)||1;return e.jsxs("div",{children:[e.jsxs("div",{className:"flex justify-between text-xs mb-1",children:[e.jsx("span",{className:"font-bold text-on-surface",children:t.module||"–"}),e.jsxs("span",{className:"text-on-surface-variant/50",children:[r(t.calls)," calls · ",r(t.tokens||0)," tokens"]})]}),e.jsx("div",{className:"h-2 bg-surface-container-high rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${t.calls/c*100}%`,background:xe[a%xe.length]}})})]},t.module||a)})})]}),s.credits.history.length>0&&e.jsxs("div",{className:"bg-surface-container rounded-2xl border border-outline-variant/10 p-5",children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-widest text-on-surface-variant/40 mb-4",children:"Credittransacties (laatste 50)"}),e.jsx("div",{className:"space-y-1",children:s.credits.history.map((t,a)=>{var c;return e.jsxs("div",{className:"flex justify-between items-center text-xs py-1.5 border-b border-outline-variant/5",children:[e.jsxs("div",{children:[e.jsx("span",{className:`font-black ${t.kind==="topup"?"text-green-400":t.kind==="spend"?"text-red-400":"text-amber-400"}`,children:t.kind}),e.jsx("span",{className:"text-on-surface-variant/40 ml-2",children:t.note||"–"})]}),e.jsxs("div",{className:"text-right shrink-0 ml-4",children:[e.jsxs("p",{className:`font-bold ${t.amount_eur>=0?"text-green-400":"text-red-400"}`,children:[t.amount_eur>=0?"+":"",l(t.amount_eur)]}),e.jsx("p",{className:"text-[10px] text-on-surface-variant/30",children:(c=t.created_at)==null?void 0:c.slice(0,10)})]})]},a)})})]})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"bg-surface-container rounded-2xl border border-outline-variant/10 p-5",children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-widest text-on-surface-variant/40 mb-4",children:"Financieel"}),e.jsx("div",{className:"space-y-2.5",children:[["Inkoop (all-time)",l(s.all_time.ai_cost_eur)],["Verkoop (all-time)",l(s.all_time.ai_cost_eur*(1+s.user.margin_pct/100))],["Marge %",`${s.user.margin_pct}%`],["Prijs/training",s.user.price_per_schema>0?l(s.user.price_per_schema):"–"],["Totaal aankoopbedrag",l(s.credits.total_topup)],["Aanpassingen (adjust)",l(Math.abs(s.credits.total_adjust))]].map(([t,a])=>e.jsxs("div",{className:"flex justify-between text-sm border-b border-outline-variant/5 pb-2",children:[e.jsx("span",{className:"text-on-surface-variant/50",children:t}),e.jsx("span",{className:"font-black text-on-surface",children:a})]},t))})]}),s.orders.length>0&&e.jsxs("div",{className:"bg-surface-container rounded-2xl border border-outline-variant/10 p-5",children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-widest text-on-surface-variant/40 mb-4",children:"Orders"}),e.jsx("div",{className:"space-y-2",children:s.orders.map(t=>e.jsxs("div",{className:"flex justify-between text-xs py-1.5 border-b border-outline-variant/5",children:[e.jsxs("span",{className:"text-on-surface-variant/50",children:["#",t.id," · ",t.date]}),e.jsxs("span",{className:`font-bold ${t.status==="paid"?"text-green-400":"text-on-surface-variant/50"}`,children:[l(t.amount)," · ",t.status]})]},t.id))})]}),e.jsxs("div",{className:"bg-surface-container rounded-2xl border border-outline-variant/10 p-5",children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-widest text-on-surface-variant/40 mb-4",children:"Accountinfo"}),e.jsx("div",{className:"space-y-2.5",children:[["Eerste gebruik",((ne=s.all_time.first_call)==null?void 0:ne.slice(0,10))??"–"],["Laatste gebruik",((ie=s.all_time.last_call)==null?void 0:ie.slice(0,10))??"–"],["Aangemeld",((oe=s.user.date_joined)==null?void 0:oe.slice(0,10))??"–"],["Laatste login",((ce=s.user.last_login)==null?void 0:ce.slice(0,10))??"–"]].map(([t,a])=>e.jsxs("div",{className:"flex justify-between text-sm border-b border-outline-variant/5 pb-2",children:[e.jsx("span",{className:"text-on-surface-variant/40",children:t}),e.jsx("span",{className:"font-black text-on-surface",children:a})]},t))})]}),e.jsxs("div",{className:"bg-surface-container rounded-2xl border border-outline-variant/10 p-5",children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-widest text-on-surface-variant/40 mb-1",children:"Saldo aanpassen"}),e.jsxs("p",{className:"text-[11px] text-on-surface-variant/40 mb-4",children:["Huidig: ",e.jsx("span",{className:"font-black text-on-surface",children:l(s.user.wallet_balance)})]}),e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-on-surface-variant/40 text-sm",children:"€"}),e.jsx("input",{type:"number",step:"0.01",placeholder:"0.00",value:R,onChange:t=>Q(t.target.value),className:"w-full pl-7 pr-3 py-2.5 bg-surface-container-high border border-outline-variant/20 rounded-xl text-sm text-on-surface focus:outline-none focus:border-primary/50"})]}),e.jsx("button",{onClick:je,disabled:ee||R==="",className:"px-4 py-2.5 rounded-xl bg-primary text-white text-xs font-black uppercase tracking-widest hover:bg-primary/80 disabled:opacity-40 transition-all whitespace-nowrap",children:ee?"…":"Instellen"})]}),B&&e.jsx("p",{className:`text-xs mt-2 ${B.startsWith("✓")?"text-green-400":"text-red-400"}`,children:B}),e.jsx("p",{className:"text-[10px] text-on-surface-variant/30 mt-2",children:"Voer het gewenste eindsaldo in (kan negatief). Wijziging wordt gelogd als aanpassing."})]})]})]})]})]}),f&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm p-4",children:e.jsxs("div",{className:"bg-surface-container rounded-3xl border border-outline-variant/20 w-full max-w-2xl max-h-[80vh] flex flex-col shadow-2xl",children:[e.jsxs("div",{className:"flex items-center justify-between px-6 py-5 border-b border-outline-variant/10",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-black text-on-surface",children:"Importeer uit log"}),e.jsxs("p",{className:"text-xs text-on-surface-variant/50 mt-0.5",children:[f.imported," ongefactureerde entries gevonden voor de afgelopen ",o," dagen"]})]}),e.jsx("button",{onClick:()=>A(null),className:"text-on-surface-variant/40 hover:text-on-surface-variant",children:e.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3 px-6 py-4 border-b border-outline-variant/10",children:[e.jsxs("div",{className:"bg-surface-container-high rounded-2xl p-4",children:[e.jsx("p",{className:"text-[9px] font-black uppercase tracking-widest text-on-surface-variant/40",children:"Inkoop totaal"}),e.jsx("p",{className:"text-xl font-black text-on-surface mt-1",children:l(f.total_cost_eur)})]}),e.jsxs("div",{className:"bg-primary/8 border border-primary/20 rounded-2xl p-4",children:[e.jsx("p",{className:"text-[9px] font-black uppercase tracking-widest text-on-surface-variant/40",children:"Verkoop totaal"}),e.jsx("p",{className:"text-xl font-black text-primary mt-1",children:l(f.total_sell_eur)})]}),e.jsxs("div",{className:"bg-surface-container-high rounded-2xl p-4",children:[e.jsx("p",{className:"text-[9px] font-black uppercase tracking-widest text-on-surface-variant/40",children:"Trainingen"}),e.jsx("p",{className:"text-xl font-black text-on-surface mt-1",children:r(f.workout_count)})]}),e.jsxs("div",{className:"bg-surface-container-high rounded-2xl p-4",children:[e.jsx("p",{className:"text-[9px] font-black uppercase tracking-widest text-on-surface-variant/40",children:"Prijs/training"}),e.jsx("p",{className:"text-xl font-black text-on-surface mt-1",children:f.price_per_schema>0?l(f.price_per_schema):"–"})]})]}),f.entries.length>0?e.jsxs("div",{className:"overflow-auto flex-1 px-6 py-3",children:[e.jsxs("table",{className:"w-full text-xs border-collapse",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-outline-variant/10",children:[e.jsx("th",{className:"py-2 text-left text-[9px] font-black uppercase tracking-widest text-on-surface-variant/40",children:"Gebruiker"}),e.jsx("th",{className:"py-2 text-left text-[9px] font-black uppercase tracking-widest text-on-surface-variant/40",children:"Module"}),e.jsx("th",{className:"py-2 text-right text-[9px] font-black uppercase tracking-widest text-on-surface-variant/40",children:"Inkoop"}),e.jsx("th",{className:"py-2 text-right text-[9px] font-black uppercase tracking-widest text-on-surface-variant/40",children:"Marge/prijs"}),e.jsx("th",{className:"py-2 text-right text-[9px] font-black uppercase tracking-widest text-on-surface-variant/40",children:"Verkoop"})]})}),e.jsx("tbody",{children:f.entries.map(t=>e.jsxs("tr",{className:"border-b border-outline-variant/5",children:[e.jsx("td",{className:"py-1.5 text-on-surface-variant/70",children:t.user_name}),e.jsxs("td",{className:"py-1.5 text-on-surface-variant/50 flex items-center gap-1",children:[t.is_workout&&e.jsx("span",{className:"material-symbols-outlined text-[10px] text-primary",children:"fitness_center"}),t.module]}),e.jsx("td",{className:"py-1.5 text-right text-on-surface-variant/50",children:l(t.cost_eur)}),e.jsx("td",{className:"py-1.5 text-right text-on-surface-variant/50",children:t.is_workout&&t.price_per_schema?e.jsxs("span",{className:"text-primary font-bold",children:[l(t.price_per_schema),"/training"]}):t.margin_pct>0?`${t.margin_pct}%`:"–"}),e.jsx("td",{className:"py-1.5 text-right font-bold text-on-surface",children:l(t.sell_eur)})]},t.log_id))})]}),f.entries.length===100&&e.jsx("p",{className:"text-center text-[10px] text-on-surface-variant/30 mt-2",children:"Eerste 100 entries weergegeven"})]}):e.jsx("div",{className:"flex-1 flex items-center justify-center py-10",children:e.jsx("p",{className:"text-sm text-on-surface-variant/30",children:"Geen ongefactureerde entries gevonden"})}),e.jsxs("div",{className:"flex items-center justify-end gap-3 px-6 py-4 border-t border-outline-variant/10",children:[e.jsx("button",{onClick:()=>A(null),className:"px-5 py-2.5 rounded-xl border border-outline-variant/20 text-sm font-bold text-on-surface-variant hover:bg-surface-container-high transition-all",children:"Annuleren"}),f.imported>0&&e.jsx("button",{onClick:ke,disabled:K,className:"px-5 py-2.5 rounded-xl bg-primary text-white text-sm font-black disabled:opacity-50 hover:bg-primary/90 transition-all",children:K?"Importeren…":`${f.imported} entries importeren`})]})]})})]})}export{Be as default};

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.