%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /home2/rezakur1/ai.rezakurnia.com/assets/
Upload File :
Create Path :
Current File : /home2/rezakur1/ai.rezakurnia.com/assets/AdminAnalyticsPage-CwAEhzHf.js

import{r,c as Q,a as te,d as se,j as e}from"./index-_MR6QBUm.js";import{B as H}from"./Button-BRUb7BtQ.js";import{C as d,d as f,e as p,g as $,c as V,h,a as x}from"./format-DuRu6B7q.js";import{B as N}from"./Badge-MEsxA8Zk.js";import{S as ae}from"./StatCard-gMeqQ8wy.js";import{R as A,C as M,X as O,Y as K,T as E}from"./CartesianChart-Bopnyt2O.js";import{A as le,a as ie}from"./AreaChart-Bky5y1Cu.js";import{B as F,a as I,C as ne}from"./BarChart-drAdbAdE.js";import"./index-B2yPAbM9.js";import"./with-selector-MR6Hz0w7.js";const re=20;function ce(a=30){const[l,b]=r.useState([]),[i,j]=r.useState(0),[c,k]=r.useState(0),[g,D]=r.useState(""),[_,u]=r.useState(!1),[z,m]=r.useState(null),v=r.useRef(0),s=r.useCallback(async(C,T,L)=>{const w=++v.current;L&&(u(!0),m(null));try{const y=await Q(`/admin/users?days=${a}&q=${encodeURIComponent(C)}&page=${T}&limit=${re}`);if(v.current!==w)return;j(y.total),k(T),b(S=>L?y.users:[...S,...y.users])}catch(y){if(v.current!==w)return;m(y instanceof Error?y.message:"Gagal memuat daftar user")}finally{v.current===w&&u(!1)}},[a]);r.useEffect(()=>{const C=setTimeout(()=>void s(g,1,!0),300);return()=>clearTimeout(C)},[g,s]);const q=r.useCallback(()=>{_||l.length>=i||s(g,c+1,!1)},[_,l.length,i,g,c,s]);return{users:l,total:i,loading:_,error:z,q:g,setQ:D,loadMore:q}}const de=[7,30,90],R={className:"h-5 w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.7},oe=[{key:"billed_wallet",label:"Dipotong Wallet",tone:"text-blue-300",bar:"bg-blue-400",hint:"Request yang benar-benar memotong saldo"},{key:"covered_package",label:"Ditanggung Paket",tone:"text-emerald-300",bar:"bg-emerald-400",hint:"Ditanggung kuota paket aktif"},{key:"untracked",label:"Sebelum Harga",tone:"text-slate-400",bar:"bg-slate-500",hint:"Harga 0 / sebelum harga model diset"}],W=["#3b82f6","#38bdf8","#93c5fd","#818cf8","#34d399","#f472b6","#fbbf24","#a78bfa"],J=a=>{const l=new Date(`${a}T00:00:00`);return Number.isNaN(l.getTime())?a:new Intl.DateTimeFormat("id-ID",{day:"2-digit",month:"short"}).format(l)};function Y({active:a,payload:l}){if(!a||!(l!=null&&l.length))return null;const b=l[0].payload,i=new Date(`${b.date}T00:00:00`),j=Number.isNaN(i.getTime())?String(b.date):new Intl.DateTimeFormat("id-ID",{day:"2-digit",month:"short",year:"numeric"}).format(i);return e.jsxs("div",{className:"rounded-xl border border-white/[0.08] bg-ink-900 px-3.5 py-2.5 text-xs shadow-modal",children:[e.jsx("p",{className:"mb-1.5 font-semibold text-white",children:j}),e.jsx("div",{className:"space-y-1",children:l.map(c=>{const k=typeof c.value=="number"?c.value:Number(c.value),g=c.dataKey==="cost"?h(k):c.dataKey==="requests"?k.toLocaleString("id-ID"):x(k);return e.jsxs("p",{className:"flex items-center justify-between gap-6 text-slate-400",children:[e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"h-2 w-2 rounded-full",style:{background:c.color||c.fill}}),c.name]}),e.jsx("span",{className:"font-semibold tabular-nums text-white",children:g})]},c.dataKey)})})]})}function xe({active:a,payload:l}){if(!a||!(l!=null&&l.length))return null;const b=l[0].payload;return e.jsxs("div",{className:"rounded-xl border border-white/[0.08] bg-ink-900 px-3.5 py-2.5 text-xs shadow-modal",children:[e.jsx("p",{className:"mb-1.5 font-semibold text-white",children:b.model}),e.jsx("div",{className:"space-y-1",children:l.map(i=>{const j=typeof i.value=="number"?i.value:Number(i.value);return e.jsxs("p",{className:"flex items-center justify-between gap-6 text-slate-400",children:[e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"h-2 w-2 rounded-full",style:{background:i.color||i.fill}}),i.name]}),e.jsx("span",{className:"font-semibold tabular-nums text-white",children:i.dataKey==="cost"?h(j):x(j)})]},i.dataKey)})})]})}function me({u:a,selected:l,onClick:b}){return e.jsxs("button",{type:"button",onClick:b,className:`w-full rounded-xl border px-3 py-2.5 text-left transition-colors ${l?"border-brand-400/30 bg-brand-500/10":"border-transparent hover:bg-white/[0.03]"}`,children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-ink-700 text-xs font-semibold text-white",children:a.name.charAt(0).toUpperCase()}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("p",{className:"flex items-center gap-1.5 font-medium text-white",children:[e.jsx("span",{className:"truncate",children:a.name}),Number(a.is_admin)===1&&e.jsx(N,{tone:"info",children:"Admin"}),Number(a.is_active)!==1&&e.jsx(N,{tone:"danger",children:"Suspend"})]}),e.jsx("p",{className:"truncate text-xs text-slate-500",children:a.email})]})]}),e.jsxs("div",{className:"mt-2 flex items-center justify-between text-[11px]",children:[e.jsx("span",{className:"font-medium tabular-nums text-emerald-300",children:V(a.balance)}),e.jsxs("span",{className:"tabular-nums text-slate-500",children:[a.requests," req ·"," ",x(Number(a.input_tokens)+Number(a.cached_tokens)+Number(a.output_tokens))," ","tok"]})]})]})}function ve(){const a=te(),[l]=se(),b=Number(l.get("user"))||0,{users:i,total:j,loading:c,error:k,q:g,setQ:D,loadMore:_}=ce(30),[u,z]=r.useState(b),[m,v]=r.useState(30),[s,q]=r.useState(null),[C,T]=r.useState(!1),[L,w]=r.useState(null),y=t=>{z(t),a(`/admin/analytics?user=${t}`,{replace:!0})},S=r.useCallback(async t=>{if(t){T(!0),w(null);try{const n=await Q(`/admin/users/${t}/analytics?days=${m}`);q(n)}catch(n){w(n instanceof Error?n.message:"Gagal memuat analisa"),q(null)}finally{T(!1)}}},[m]);r.useEffect(()=>{u&&S(u)},[u,S]);const o=s==null?void 0:s.billing.summary,B=s==null?void 0:s.billing.breakdown,P=Number((o==null?void 0:o.total_usage_gross)??0),G=B&&typeof B=="object"?oe.map(t=>{const n=B[t.key],Z=n&&typeof n=="object"?n.requests:0,U=n&&typeof n=="object"?n.nominal_cost:0,ee=P>0?Math.round(U/P*100):0;return{...t,req:Z,cost:U,pct:ee}}):[],X=s!=null&&s.usage?[{label:"Total Requests",value:Number(s.usage.requests),accent:"pink",icon:e.jsx("svg",{...R,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8.25 6.75h12M8.25 12h12m-12 5.25h12M3.75 6.75h.007v.008H3.75V6.75zm.375 0a.375.375 0 11-.75 0 .375.375 0 01.75 0zM3.75 12h.007v.008H3.75V12zm.375 0a.375.375 0 11-.75 0 .375.375 0 01.75 0zm-.375 5.25h.007v.008H3.75v-.008zm.375 0a.375.375 0 11-.75 0 .375.375 0 01.75 0z"})})},{label:"Input Tokens",value:Number(s.usage.input_tokens),accent:"fuchsia",icon:e.jsx("svg",{...R,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9.813 15.904L9 18.75l-.813-2.846a4.5 4.5 0 00-3.09-3.09L2.25 12l2.846-.813a4.5 4.5 0 003.09-3.09L9 5.25l.813 2.846a4.5 4.5 0 003.09 3.09L15.75 12l-2.846.813a4.5 4.5 0 00-3.09 3.09zM18.259 8.715L18 9.75l-.259-1.035a3.375 3.375 0 00-2.455-2.456L14.25 6l1.036-.259a3.375 3.375 0 002.455-2.456L18 2.25l.259 1.035a3.375 3.375 0 002.456 2.456L21.75 6l-1.035.259a3.375 3.375 0 00-2.456 2.456z"})})},{label:"Cached Tokens",value:Number(s.usage.cached_tokens),accent:"rose",icon:e.jsx("svg",{...R,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M16.023 9.348h4.992v-.001M2.985 19.644v-4.992m0 0h4.992m-4.993 0l3.181 3.183a8.25 8.25 0 0013.803-3.7l4.029-1.523a.75.75 0 01.93.539v.011a.75.75 0 01-.539.93l-4.029 1.523a8.25 8.25 0 01-13.803 3.7l-3.182-3.182v-.001z"})})},{label:"Output Tokens",value:Number(s.usage.output_tokens),accent:"hot",icon:e.jsx("svg",{...R,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3.75 13.5l10.5-11.25L12 10.5h8.25L9.75 21.75 12 13.5H3.75z"})})}]:[];return e.jsx("div",{className:"mx-auto max-w-7xl",children:e.jsxs("div",{className:"grid grid-cols-1 items-start gap-6 lg:grid-cols-[320px_1fr]",children:[e.jsxs(d,{className:"lg:sticky lg:top-6",children:[e.jsx(f,{title:"Pengguna",subtitle:`${j} akun`,action:e.jsx("input",{type:"search",placeholder:"Cari nama / email…",value:g,onChange:t=>D(t.target.value),className:"input-solid w-full"})}),e.jsxs(p,{className:"p-3",children:[k&&e.jsx("p",{className:"px-2 pb-2 text-xs text-red-400",children:k}),e.jsxs("div",{className:"max-h-[62vh] space-y-1 overflow-y-auto pr-1",children:[i.length===0&&!c?e.jsx("p",{className:"px-2 py-8 text-center text-sm text-slate-500",children:"Tidak ada pengguna yang cocok."}):i.map(t=>e.jsx(me,{u:t,selected:u===t.id,onClick:()=>y(t.id)},t.id)),c&&e.jsx("div",{className:"space-y-2 px-1",children:[...Array(3)].map((t,n)=>e.jsx("div",{className:"h-16 animate-pulse rounded-xl bg-white/[0.02]"},n))})]}),i.length<j&&!c&&e.jsx("div",{className:"pt-3",children:e.jsxs(H,{variant:"ghost",size:"sm",className:"w-full",onClick:_,children:["Muat lebih banyak (",i.length,"/",j,")"]})})]})]}),e.jsxs("div",{className:"min-w-0 space-y-6",children:[e.jsx(d,{children:e.jsx(f,{title:"Analisa User",subtitle:u?"Token, request, biaya & billing per pengguna":"Pilih pengguna dari daftar di samping kiri",action:e.jsx("div",{className:"flex rounded-lg border border-white/[0.06] bg-white/[0.02] p-0.5",children:de.map(t=>e.jsxs("button",{onClick:()=>v(t),className:`rounded-md px-3 py-1.5 text-xs font-medium transition-colors ${m===t?"bg-brand-500/20 text-brand-200":"text-slate-400 hover:text-slate-200"}`,children:[t,"H"]},t))})})}),u?L?e.jsx(d,{children:e.jsxs(p,{children:[e.jsx("p",{className:"text-sm text-red-400",children:L}),e.jsx(H,{variant:"ghost",size:"sm",className:"mt-3",onClick:()=>u&&void S(u),children:"Coba lagi"})]})}):C&&!s?e.jsx("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2 xl:grid-cols-4",children:[...Array(4)].map((t,n)=>e.jsx("div",{className:"h-28 animate-pulse rounded-2xl border border-white/[0.04] bg-white/[0.02]"},n))}):s?e.jsxs(e.Fragment,{children:[e.jsx(d,{children:e.jsx(p,{children:e.jsxs("div",{className:"flex flex-wrap items-center gap-4",children:[e.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-full bg-ink-700 text-sm font-semibold text-white",children:s.user.name.charAt(0).toUpperCase()}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("p",{className:"flex flex-wrap items-center gap-2 font-semibold text-white",children:[s.user.name,Number(s.user.is_admin)===1&&e.jsx(N,{tone:"info",children:"Admin"}),Number(s.user.is_active)===1?e.jsx(N,{tone:"success",children:"Aktif"}):e.jsx(N,{tone:"danger",children:"Suspend"})]}),e.jsxs("p",{className:"truncate text-xs text-slate-500",children:[s.user.email," · terdaftar"," ",$(s.user.created_at)]})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("p",{className:"text-[11px] font-medium uppercase tracking-wider text-slate-500",children:"Saldo Wallet"}),e.jsx("p",{className:"text-xl font-bold tabular-nums text-emerald-300",children:V(s.user.balance)})]})]})})}),e.jsx("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2 xl:grid-cols-4",children:X.map(t=>e.jsx(ae,{...t},t.label))}),e.jsxs("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2 xl:grid-cols-4",children:[e.jsxs(d,{className:"p-5",children:[e.jsx("p",{className:"text-xs font-medium text-slate-400",children:"Total Top Up"}),e.jsx("p",{className:"mt-2 text-2xl font-bold tabular-nums text-white",children:h(Number((o==null?void 0:o.total_topup)??0))})]}),e.jsxs(d,{className:"p-5",children:[e.jsx("p",{className:"text-xs font-medium text-slate-400",children:"Total Pemakaian"}),e.jsx("p",{className:"mt-2 text-2xl font-bold tabular-nums text-white",children:h(Number((o==null?void 0:o.total_usage)??0))})]}),e.jsxs(d,{className:"p-5",children:[e.jsx("p",{className:"text-xs font-medium text-slate-400",children:"Total Paket"}),e.jsx("p",{className:"mt-2 text-2xl font-bold tabular-nums text-white",children:h(Number((o==null?void 0:o.total_package_orders)??0))})]}),e.jsxs(d,{className:"p-5",children:[e.jsx("p",{className:"text-xs font-medium text-slate-400",children:"Biaya Usage"}),e.jsx("p",{className:"mt-2 text-2xl font-bold tabular-nums text-white",children:h(Number(s.usage.cost))}),e.jsxs("p",{className:"mt-1 text-[11px] text-slate-500",children:["Latensi rata-rata"," ",x(s.usage.avg_latency_ms)," ms"]})]})]}),e.jsxs(d,{children:[e.jsx(f,{title:"Tren Request Harian",subtitle:`${m} hari terakhir`}),e.jsx(p,{children:s.daily.length===0?e.jsx("div",{className:"flex h-56 items-center justify-center text-sm text-slate-500",children:"Belum ada data pada rentang ini."}):e.jsx("div",{className:"h-56 w-full",children:e.jsx(A,{width:"100%",height:"100%",children:e.jsxs(le,{data:s.daily,margin:{top:4,right:4,left:0,bottom:0},children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"anReq",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"#3b82f6",stopOpacity:.4}),e.jsx("stop",{offset:"100%",stopColor:"#3b82f6",stopOpacity:0})]})}),e.jsx(M,{strokeDasharray:"3 3",stroke:"rgba(255,255,255,0.05)",vertical:!1}),e.jsx(O,{dataKey:"date",tickFormatter:J,tick:{fill:"#475569",fontSize:10},axisLine:!1,tickLine:!1,minTickGap:24}),e.jsx(K,{tick:{fill:"#475569",fontSize:11},tickFormatter:x,axisLine:!1,tickLine:!1,allowDecimals:!1}),e.jsx(E,{content:e.jsx(Y,{}),cursor:{stroke:"rgba(255,255,255,0.15)"}}),e.jsx(ie,{type:"monotone",dataKey:"requests",name:"Requests",stroke:"#3b82f6",strokeWidth:2,fill:"url(#anReq)"})]})})})})]}),e.jsxs(d,{children:[e.jsx(f,{title:"Token Harian",subtitle:`Input, cached & output per hari (${m} hari terakhir)`}),e.jsx(p,{children:s.daily.length===0?e.jsx("div",{className:"flex h-56 items-center justify-center text-sm text-slate-500",children:"Belum ada data pada rentang ini."}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-4 flex items-center gap-5 text-xs text-slate-400",children:[e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"inline-block h-2 w-2 rounded-full bg-blue-500"}),"Input"]}),e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"inline-block h-2 w-2 rounded-full bg-sky-400"}),"Cached"]}),e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"inline-block h-2 w-2 rounded-full bg-blue-300"}),"Output"]})]}),e.jsx("div",{className:"h-56 w-full",children:e.jsx(A,{width:"100%",height:"100%",children:e.jsxs(F,{data:s.daily,margin:{top:4,right:4,left:0,bottom:0},barCategoryGap:0,children:[e.jsxs("defs",{children:[e.jsxs("linearGradient",{id:"anTokIn",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"#3b82f6"}),e.jsx("stop",{offset:"100%",stopColor:"#1d4ed8"})]}),e.jsxs("linearGradient",{id:"anTokCached",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"#38bdf8"}),e.jsx("stop",{offset:"100%",stopColor:"#0284c7"})]}),e.jsxs("linearGradient",{id:"anTokOut",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"#93c5fd"}),e.jsx("stop",{offset:"100%",stopColor:"#60a5fa"})]})]}),e.jsx(M,{strokeDasharray:"3 3",stroke:"rgba(255,255,255,0.05)",vertical:!1}),e.jsx(O,{dataKey:"date",tickFormatter:J,tick:{fill:"#475569",fontSize:10},axisLine:!1,tickLine:!1,minTickGap:24}),e.jsx(K,{tick:{fill:"#475569",fontSize:11},tickFormatter:x,axisLine:!1,tickLine:!1}),e.jsx(E,{content:e.jsx(Y,{}),cursor:{fill:"rgba(255,255,255,0.04)",radius:6}}),e.jsx(I,{dataKey:"input_tokens",name:"Input",stackId:"tok",fill:"url(#anTokIn)",maxBarSize:22}),e.jsx(I,{dataKey:"cached_tokens",name:"Cached",stackId:"tok",fill:"url(#anTokCached)",maxBarSize:22}),e.jsx(I,{dataKey:"output_tokens",name:"Output",stackId:"tok",fill:"url(#anTokOut)",radius:[5,5,0,0],maxBarSize:22})]})})})]})})]}),e.jsxs(d,{children:[e.jsx(f,{title:"Peringkat Model",subtitle:`Jumlah request per model (${m} hari terakhir)`}),e.jsx(p,{children:s.models.length===0?e.jsx("div",{className:"flex h-56 items-center justify-center text-sm text-slate-500",children:"Belum ada data pada rentang ini."}):e.jsx("div",{className:"h-64 w-full",children:e.jsx(A,{width:"100%",height:"100%",children:e.jsxs(F,{data:s.models,layout:"vertical",margin:{top:4,right:12,left:8,bottom:4},children:[e.jsx(M,{strokeDasharray:"3 3",stroke:"rgba(255,255,255,0.05)",horizontal:!1}),e.jsx(O,{type:"number",tick:{fill:"#475569",fontSize:11},tickFormatter:x,axisLine:!1,tickLine:!1,allowDecimals:!1}),e.jsx(K,{type:"category",dataKey:"model",width:120,tick:{fill:"#94a3b8",fontSize:10},axisLine:!1,tickLine:!1}),e.jsx(E,{content:e.jsx(xe,{}),cursor:{fill:"rgba(255,255,255,0.04)",radius:6}}),e.jsx(I,{dataKey:"requests",name:"Requests",radius:[0,6,6,0],maxBarSize:16,children:s.models.map((t,n)=>e.jsx(ne,{fill:W[n%W.length]},t.model))})]})})})})]}),G.length>0&&e.jsxs(d,{children:[e.jsx(f,{title:"Darimana Angka Pemakaian?",subtitle:`Nilai semua request vs yang benar-benar memotong wallet (${m} hari)`}),e.jsxs(p,{children:[e.jsx("div",{className:"flex items-end gap-1 rounded-xl border border-white/[0.06] bg-white/[0.02] px-3 pt-3",children:G.map(t=>e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:`h-2.5 rounded-t-md ${t.bar}`,style:{opacity:t.pct>0?.9:.25}}),e.jsx("p",{className:`mt-2 text-[11px] font-medium ${t.tone}`,children:t.label}),e.jsx("p",{className:"text-sm font-semibold tabular-nums text-white",children:h(t.cost)}),e.jsxs("p",{className:"text-[11px] text-slate-500",children:[t.req," request · ",t.pct,"%"]}),e.jsx("p",{className:"mb-3 mt-0.5 text-[10px] text-slate-600",children:t.hint})]},t.key))}),e.jsxs("p",{className:"mt-4 text-xs leading-relaxed text-slate-400",children:["Total Pemakaian (Rp"," ",h(Number((o==null?void 0:o.total_usage)??0)).replace("Rp ",""),") hanya menghitung request yang benar-benar memotong wallet. Nilai semua request (Rp"," ",h(P).replace("Rp ",""),") sebagian ditanggung paket aktif, sebagian terjadi sebelum harga model diset (biaya 0), sehingga tidak tercatat sebagai potongan."]}),s.billing.active_package&&e.jsxs("div",{className:"mt-4 flex flex-wrap items-center gap-3 rounded-xl border border-brand-400/25 bg-brand-500/10 px-4 py-3",children:[e.jsxs(N,{tone:"info",children:["Paket ",s.billing.active_package.package_name," aktif"]}),e.jsxs("span",{className:"text-xs text-slate-300",children:["Sisa"," ",s.billing.active_package.request_remaining??"∞"," ","request ·"," ",s.billing.active_package.token_remaining??"∞"," ","token"]}),e.jsxs("span",{className:"text-xs text-slate-500",children:["berlaku s/d"," ",$(s.billing.active_package.expires_at)]})]})]})]}),e.jsxs(d,{children:[e.jsx(f,{title:"Pemakaian per Model",subtitle:`${m} hari terakhir`}),e.jsx(p,{className:"p-0",children:s.models.length===0?e.jsx("div",{className:"px-5 py-10 text-center text-sm text-slate-500",children:"Belum ada pemakaian pada rentang ini."}):e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full min-w-[620px] text-left text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-white/[0.06] bg-white/[0.02] text-[11px] uppercase tracking-wider text-slate-500",children:[e.jsx("th",{className:"px-5 py-3 font-semibold",children:"Model"}),e.jsx("th",{className:"px-4 py-3 text-right font-semibold",children:"Requests"}),e.jsx("th",{className:"px-4 py-3 text-right font-semibold",children:"Input"}),e.jsx("th",{className:"px-4 py-3 text-right font-semibold",children:"Cached"}),e.jsx("th",{className:"px-4 py-3 text-right font-semibold",children:"Output"}),e.jsx("th",{className:"px-5 py-3 text-right font-semibold",children:"Biaya"})]})}),e.jsx("tbody",{children:s.models.map(t=>e.jsxs("tr",{className:"border-b border-white/[0.04] transition-colors last:border-0 hover:bg-white/[0.02]",children:[e.jsx("td",{className:"px-5 py-3.5 font-medium text-white",children:t.model}),e.jsx("td",{className:"px-4 py-3.5 text-right font-medium tabular-nums text-slate-300",children:t.requests}),e.jsx("td",{className:"px-4 py-3.5 text-right tabular-nums text-slate-400",children:x(t.input_tokens)}),e.jsx("td",{className:"px-4 py-3.5 text-right tabular-nums text-slate-500",children:x(t.cached_tokens)}),e.jsx("td",{className:"px-4 py-3.5 text-right tabular-nums text-slate-400",children:x(t.output_tokens)}),e.jsx("td",{className:"px-5 py-3.5 text-right font-medium tabular-nums text-slate-300",children:h(Number(t.cost))})]},t.model))})]})})})]}),e.jsxs(d,{children:[e.jsx(f,{title:"Pemakaian Harian",subtitle:`${m} hari terakhir`}),e.jsx(p,{className:"p-0",children:s.daily.length===0?e.jsx("div",{className:"px-5 py-10 text-center text-sm text-slate-500",children:"Belum ada pemakaian pada rentang ini."}):e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full min-w-[760px] text-left text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-white/[0.06] bg-white/[0.02] text-[11px] uppercase tracking-wider text-slate-500",children:[e.jsx("th",{className:"px-5 py-3 font-semibold",children:"Tanggal"}),e.jsx("th",{className:"px-4 py-3 text-right font-semibold",children:"Requests"}),e.jsx("th",{className:"px-4 py-3 text-right font-semibold",children:"Total Token"}),e.jsx("th",{className:"px-4 py-3 text-right font-semibold",children:"Input"}),e.jsx("th",{className:"px-4 py-3 text-right font-semibold",children:"Cached"}),e.jsx("th",{className:"px-4 py-3 text-right font-semibold",children:"Output"}),e.jsx("th",{className:"px-5 py-3 text-right font-semibold",children:"Biaya"})]})}),e.jsx("tbody",{children:s.daily.map(t=>e.jsxs("tr",{className:"border-b border-white/[0.04] transition-colors last:border-0 hover:bg-white/[0.02]",children:[e.jsx("td",{className:"px-5 py-3.5 text-xs tabular-nums text-slate-400",children:t.date}),e.jsx("td",{className:"px-4 py-3.5 text-right font-medium tabular-nums text-slate-300",children:t.requests}),e.jsx("td",{className:"px-4 py-3.5 text-right font-medium tabular-nums text-slate-300",children:x(t.total_tokens)}),e.jsx("td",{className:"px-4 py-3.5 text-right tabular-nums text-slate-400",children:x(t.input_tokens)}),e.jsx("td",{className:"px-4 py-3.5 text-right tabular-nums text-slate-500",children:x(t.cached_tokens)}),e.jsx("td",{className:"px-4 py-3.5 text-right tabular-nums text-slate-400",children:x(t.output_tokens)}),e.jsx("td",{className:"px-5 py-3.5 text-right font-medium tabular-nums text-slate-300",children:h(Number(t.cost))})]},t.date))})]})})})]}),e.jsxs(d,{children:[e.jsx(f,{title:"Log Transaksi",subtitle:"Riwayat finansial: top-up, pemakaian, paket"}),e.jsx(p,{className:"p-0",children:s.billing.transactions.length===0?e.jsx("div",{className:"px-5 py-10 text-center text-sm text-slate-500",children:"Belum ada transaksi pada rentang ini."}):e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full min-w-[760px] text-left text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-white/[0.06] bg-white/[0.02] text-[11px] uppercase tracking-wider text-slate-500",children:[e.jsx("th",{className:"px-5 py-3 font-semibold",children:"Waktu"}),e.jsx("th",{className:"px-4 py-3 font-semibold",children:"Jenis"}),e.jsx("th",{className:"px-4 py-3 font-semibold",children:"Keterangan"}),e.jsx("th",{className:"px-5 py-3 text-right font-semibold",children:"Jumlah"})]})}),e.jsx("tbody",{children:s.billing.transactions.map(t=>e.jsxs("tr",{className:"border-b border-white/[0.04] transition-colors last:border-0 hover:bg-white/[0.02]",children:[e.jsx("td",{className:"px-5 py-3.5 text-xs tabular-nums text-slate-400",children:$(t.created_at)}),e.jsx("td",{className:"px-4 py-3.5",children:t.type==="topup"?e.jsx(N,{tone:"success",children:"Top Up"}):t.type==="usage"?e.jsx(N,{tone:"danger",children:"Pemakaian"}):e.jsx(N,{tone:"info",children:"Paket"})}),e.jsx("td",{className:"max-w-[260px] truncate px-4 py-3.5 text-xs text-slate-400",children:t.description??"—"}),e.jsxs("td",{className:`px-5 py-3.5 text-right font-medium tabular-nums ${Number(t.amount)<0?"text-red-300":"text-emerald-300"}`,children:[Number(t.amount)<0?"−":"+",h(Math.abs(Number(t.amount)))]})]},t.id))})]})})})]})]}):null:e.jsx(d,{children:e.jsx(p,{children:e.jsx("p",{className:"py-10 text-center text-sm text-slate-500",children:"Pilih pengguna dari daftar di samping kiri."})})})]})]})})}export{ve as default};

Zerion Mini Shell 1.0