%PDF- %PDF-
| Direktori : /home2/rezakur1/ai.rezakurnia.com/assets/ |
| Current File : /home2/rezakur1/ai.rezakurnia.com/assets/UsagePage-MnExUa6R.js |
import{r as x,a as te,j as e,L as he}from"./index-CYXd_ywS.js";import{C as y,a as L,b as $}from"./Card-DxTZG1_W.js";import{B as T}from"./Badge-Bs3KAUoA.js";import{B as pe}from"./Button-BtCTiucz.js";import{u as be}from"./useBilling-pxBKddZJ.js";import{a as g,c as p,g as j,e as ge,f as je}from"./format-CjhWL3Ta.js";import{R as fe,C as Ne,X as ke,Y as ve,T as ye}from"./CartesianChart-DrWDYIYJ.js";import{A as we,a as _e}from"./AreaChart-V8oZPMY_.js";import"./index-CyoKYIp9.js";import"./with-selector-DIjl9Exq.js";function qe(a=30){const[r,i]=x.useState(null),[o,l]=x.useState(!0),[b,m]=x.useState(null),h=x.useRef(0),s=x.useCallback(async()=>{const u=++h.current;l(!0),m(null);try{const d=await te(`/me/usage?days=${a}`);if(h.current!==u)return;i(d)}catch(d){if(h.current!==u)return;m(d instanceof Error?d.message:"Gagal memuat penggunaan")}finally{h.current===u&&l(!1)}},[a]);return x.useEffect(()=>{s()},[s]),{data:r,loading:o,error:b,refresh:s}}function Le(a=30,r=50){const[i,o]=x.useState([]),[l,b]=x.useState(!0),[m,h]=x.useState(null),s=x.useCallback(async()=>{let u=!1;return b(!0),te(`/me/usage/requests?days=${a}&limit=${r}`).then(d=>{u||(o(d.requests),h(null))}).catch(d=>{u||h(d.message)}).finally(()=>{u||b(!1)}),()=>{u=!0}},[a,r]);return x.useEffect(()=>{s()},[s]),{requests:i,loading:l,error:m,refresh:s}}const $e=[{value:7,label:"7 hari"},{value:30,label:"30 hari"},{value:90,label:"90 hari"},{value:0,label:"Semua"}],k={requests:{label:"Requests",key:"requests",color:"#3b82f6"},tokens:{label:"Token",key:"total_tokens",color:"#93c5fd"}},Te=[{value:"all",label:"Semua"},{value:"wallet",label:"Dipotong Wallet"},{value:"package",label:"Ditanggung Paket"}],Ce=[{key:"billed_wallet",label:"Dipotong Wallet",bar:"bg-blue-400",tone:"text-blue-300",hint:"Langsung mengurangi saldo"},{key:"covered_package",label:"Ditanggung Paket",bar:"bg-emerald-400",tone:"text-emerald-300",hint:"Memakai kuota paket aktif"},{key:"untracked",label:"Sebelum Harga",bar:"bg-slate-500",tone:"text-slate-400",hint:"Harga 0 / belum diset"}],w={clock:"M12 6v6h4.5m4.5 0a9 9 0 11-18 0 9 9 0 0118 0z",refresh:"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",bolt:"M3.75 13.5l10.5-11.25L12 10.5h8.25L9.75 21.75 12 13.5H3.75z",list:"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",wallet:"M2.25 8.25h19.5m-16.5.75h12a2.25 2.25 0 012.25 2.25v3a2.25 2.25 0 01-2.25 2.25h-12A2.25 2.25 0 012.25 14.25v-3a2.25 2.25 0 012.25-2.25z",key:"M15.75 5.25a3 3 0 013 3m3 0a6 6 0 01-7.029 5.912c-.563-.097-1.159.026-1.563.43L10.5 17.25H8.25v2.25H6v2.25H2.25v-2.818c0-.597.237-1.17.659-1.591l6.499-6.499c.404-.404.527-1 .43-1.563A6 6 0 1121.75 8.25z"};function ee(a){const r=new Date(`${a}T00:00:00`);return Number.isNaN(r.getTime())?a:new Intl.DateTimeFormat("id-ID",{day:"2-digit",month:"short"}).format(r)}function Re({code:a}){return a>=200&&a<300?e.jsx(T,{tone:"success",children:a}):a>=400&&a<500?e.jsx(T,{tone:"warning",children:a}):a>=500?e.jsx(T,{tone:"danger",children:a}):e.jsx(T,{tone:"default",children:a})}function Be({data:a}){const r=a.map(d=>Number(d.requests));if(r.length===0)return null;const i=140,o=44,l=3,b=Math.max(1,...r),m=r.length>1?(i-l*2)/(r.length-1):0,s=r.map((d,S)=>{const f=r.length>1?l+S*m:i/2,C=o-l-d/b*(o-l*2);return`${f.toFixed(1)},${C.toFixed(1)}`}).join(" "),u=`${l},${o-l} ${s} ${i-l},${o-l}`;return e.jsxs("svg",{viewBox:`0 0 ${i} ${o}`,className:"h-11 w-36 shrink-0",children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"sparkFill",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"#3b82f6",stopOpacity:.35}),e.jsx("stop",{offset:"100%",stopColor:"#3b82f6",stopOpacity:0})]})}),e.jsx("polygon",{points:u,fill:"url(#sparkFill)"}),e.jsx("polyline",{points:s,fill:"none",stroke:"#3b82f6",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})]})}function De({active:a,payload:r,metric:i}){if(!a||!(r!=null&&r.length))return null;const o=r[0].payload,l=k[i],b=Number(o[l.key]??0),m=new Date(`${o.date}T00:00:00`),h=Number.isNaN(m.getTime())?o.date:new Intl.DateTimeFormat("id-ID",{day:"2-digit",month:"short",year:"numeric"}).format(m);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 font-semibold text-white",children:h}),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:l.color}}),l.label]}),e.jsx("span",{className:"font-semibold tabular-nums text-white",children:i==="requests"?g(b):p(b)})]})]})}function _({label:a,value:r,hint:i,icon:o,accent:l="text-white"}){return e.jsxs("div",{className:"rounded-xl border border-white/[0.06] bg-white/[0.02] px-3 py-2.5",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] font-semibold uppercase tracking-wider text-slate-500",children:[e.jsx("svg",{className:"h-3.5 w-3.5 shrink-0",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.7,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:o})}),e.jsx("span",{className:"truncate",children:a})]}),e.jsx("p",{className:`mt-1 text-base font-bold tabular-nums ${l}`,children:r}),i&&e.jsx("p",{className:"mt-0.5 text-[10px] leading-snug text-slate-500",children:i})]})}function M({label:a,value:r,hint:i}){return e.jsxs("div",{className:"rounded-lg border border-white/[0.06] bg-white/[0.02] px-3 py-2",children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-slate-500",children:a}),e.jsx("p",{className:"mt-0.5 text-sm font-semibold tabular-nums text-white",children:r}),i&&e.jsx("p",{className:"text-[10px] text-slate-500",children:i})]})}const E=a=>a&&typeof a=="object"?a:{requests:0,nominal_cost:0};function We(){const[a,r]=x.useState(30),[i,o]=x.useState(50),[l,b]=x.useState("requests"),[m,h]=x.useState("all"),{data:s,loading:u,error:d,refresh:S}=qe(a),{requests:f,loading:C,error:H,refresh:se}=Le(a,i),{data:c,loading:ae,error:I,refresh:le}=be(a,{autoRefresh:!1}),R=a===0?"semua waktu":`${a} hari terakhir`,re=u||C||ae,ne=()=>{S(),se(),le()},O=Number((s==null?void 0:s.usage.input_tokens)??0)+Number((s==null?void 0:s.usage.cached_tokens)??0)+Number((s==null?void 0:s.usage.output_tokens)??0),v=Number((s==null?void 0:s.usage.requests)??0),W=Number((s==null?void 0:s.usage.avg_latency_ms)??0),G=v>0,z=(s==null?void 0:s.daily.length)??0,F=z>0?v/z:0,B=((s==null?void 0:s.daily)??[]).reduce((t,n)=>!t||Number(n.requests)>Number(t.requests)?n:t,null),N=c==null?void 0:c.summary,K=Number((N==null?void 0:N.total_usage_gross)??(s==null?void 0:s.usage.cost)??0),U=Number((N==null?void 0:N.total_usage)??0),P=Number((N==null?void 0:N.covered_by_package)??0),ie=E(c==null?void 0:c.breakdown.billed_wallet),ce=E(c==null?void 0:c.breakdown.covered_package),oe=E(c==null?void 0:c.breakdown.untracked),D=Ce.map(t=>({...t,...t.key==="billed_wallet"?ie:t.key==="covered_package"?ce:oe})),V=D.reduce((t,n)=>t+Number(n.nominal_cost),0),X=D.reduce((t,n)=>t+Number(n.requests),0),de=V>0,Y=t=>de?Number(t.nominal_cost)/V*100:X>0?Number(t.requests)/X*100:0,J=((s==null?void 0:s.detail)??[]).reduce((t,n)=>t+Number(n.requests),0),Q=f.filter(t=>Number(t.covered_by_package)!==1).length,xe=f.length-Q,A=f.filter(t=>m==="all"?!0:m==="package"?Number(t.covered_by_package)===1:Number(t.covered_by_package)!==1),me={all:f.length,wallet:Q,package:xe},Z={className:"h-5 w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.7};return e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-end sm:justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-bold tracking-tight text-white sm:text-2xl",children:"Penggunaan"}),e.jsx("p",{className:"mt-1 text-sm text-slate-500",children:"Pemakaian request, token, biaya & latency pada akun Anda."})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("div",{className:"flex items-center gap-1 rounded-xl border border-white/[0.06] bg-white/[0.03] p-1",children:$e.map(t=>e.jsx("button",{onClick:()=>r(t.value),className:`rounded-lg px-3.5 py-1.5 text-xs font-medium transition-colors ${a===t.value?"bg-white/[0.08] text-white":"text-slate-500 hover:text-slate-300"}`,children:t.label},t.value))}),e.jsx(pe,{variant:"ghost",size:"sm",onClick:ne,isLoading:re,children:"Refresh"})]})]}),u&&!s&&e.jsxs("div",{className:"space-y-5",children:[e.jsx("div",{className:"h-56 animate-pulse rounded-2xl border border-white/[0.04] bg-white/[0.02]"}),e.jsx("div",{className:"h-40 animate-pulse rounded-2xl border border-white/[0.04] bg-white/[0.02]"}),e.jsx("div",{className:"h-80 animate-pulse rounded-2xl border border-white/[0.04] bg-white/[0.02]"})]}),d&&e.jsxs(y,{className:"p-8 text-center text-sm text-red-300",children:["Gagal memuat data penggunaan: ",d]}),s&&e.jsxs(e.Fragment,{children:[e.jsxs(y,{className:"relative overflow-hidden",children:[e.jsx("div",{className:"pointer-events-none absolute inset-0 bg-[radial-gradient(ellipse_55%_65%_at_85%_-10%,rgba(59,130,246,0.12),transparent)]"}),e.jsxs("div",{className:"relative p-5 sm:p-6",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-6",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("p",{className:"flex items-center gap-2 text-[11px] font-semibold uppercase tracking-widest text-brand-300",children:[e.jsx("svg",{...Z,className:"h-4 w-4",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"})}),"Total Token"]}),e.jsx("p",{className:"mt-2 text-4xl font-extrabold tracking-tight tabular-nums text-white sm:text-5xl",children:O.toLocaleString("id-ID")}),e.jsxs("p",{className:"mt-1.5 text-xs text-slate-500",children:["token terpakai · ",R]}),e.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-x-4 gap-y-1.5 text-[11px] text-slate-400",children:[e.jsxs("span",{children:[e.jsx("span",{className:"font-semibold text-white",children:g(v)})," ","request"]}),e.jsx("span",{className:"text-slate-700",children:"·"}),e.jsxs("span",{children:[e.jsx("span",{className:"font-semibold text-white",children:p(F)})," ","req/hari"]}),e.jsx("span",{className:"text-slate-700",children:"·"}),e.jsxs("span",{children:["latency"," ",e.jsx("span",{className:"font-semibold text-white",children:G?`${p(W)} ms`:"—"})]})]})]}),e.jsx(Be,{data:s.daily})]}),e.jsxs("div",{className:"mt-5 grid grid-cols-2 gap-2.5 sm:grid-cols-3 xl:grid-cols-6",children:[e.jsx(_,{label:"Input",value:p(Number(s.usage.input_tokens)),hint:"token prompt",icon:w.clock}),e.jsx(_,{label:"Cached",value:p(Number(s.usage.cached_tokens)),hint:"token cache",icon:w.refresh,accent:"text-sky-300"}),e.jsx(_,{label:"Output",value:p(Number(s.usage.output_tokens)),hint:"token completion",icon:w.bolt}),e.jsx(_,{label:"Requests",value:g(v),hint:`${p(F)} / hari`,icon:w.list}),e.jsx(_,{label:"Total Biaya",value:j(K),hint:c?`${j(U)} wallet · ${j(P)} paket`:"memuat rincian…",icon:w.wallet,accent:"text-emerald-300"}),e.jsx(_,{label:"Latency",value:G?`${p(W)} ms`:"—",hint:"rata-rata per request",icon:w.clock})]})]})]}),e.jsxs(y,{children:[e.jsx(L,{title:"Rincian Biaya",subtitle:`Nilai semua request & asal penagihannya · ${R}`,action:e.jsxs(he,{to:"/billing",className:"inline-flex items-center gap-1.5 rounded-lg border border-white/[0.08] bg-white/[0.03] px-2.5 py-1.5 text-[11px] font-medium text-slate-300 transition hover:bg-white/[0.06] hover:text-white",children:["Detail Billing",e.jsx("svg",{className:"h-3 w-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M13.5 4.5L21 12l-7.5 7.5M21 12H3"})})]})}),e.jsx($,{children:I?e.jsxs("p",{className:"text-xs text-red-300",children:["Gagal memuat rincian billing: ",I]}):c?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex h-3 overflow-hidden rounded-full bg-white/[0.04]",children:D.map(t=>{const n=Y(t);return n>0?e.jsx("div",{className:t.bar,style:{width:`${n}%`},title:`${t.label}: ${n.toFixed(1)}%`},t.key):null})}),e.jsx("div",{className:"mt-4 grid gap-2.5 sm:grid-cols-3",children:D.map(t=>e.jsxs("div",{className:"rounded-xl border border-white/[0.06] bg-white/[0.02] p-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("p",{className:"flex items-center gap-1.5 text-[11px] font-medium text-slate-300",children:[e.jsx("span",{className:`h-2 w-2 rounded-full ${t.bar}`}),t.label]}),e.jsxs("span",{className:"text-[10px] font-semibold tabular-nums text-slate-500",children:[Y(t).toFixed(0),"%"]})]}),e.jsx("p",{className:`mt-1.5 text-base font-bold tabular-nums ${t.tone}`,children:j(Number(t.nominal_cost))}),e.jsxs("p",{className:"text-[10px] text-slate-500",children:[g(t.requests)," request"]}),e.jsx("p",{className:"mt-0.5 text-[10px] text-slate-600",children:t.hint})]},t.key))}),e.jsxs("div",{className:"mt-4 rounded-xl border border-white/[0.06] bg-white/[0.02] px-3.5 py-3",children:[e.jsxs("p",{className:"text-[11px] leading-relaxed text-slate-400",children:["Nilai semua request"," ",e.jsx("span",{className:"font-semibold text-white",children:j(K)}),"."," ",e.jsx("span",{className:"font-semibold text-blue-300",children:j(U)})," ","dipotong dari wallet",P>0&&e.jsxs(e.Fragment,{children:[" ","dan"," ",e.jsx("span",{className:"font-semibold text-emerald-300",children:j(P)})," ","ditanggung paket aktif"]}),"."]}),c.active_package?e.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2 text-[10px] text-slate-500",children:[e.jsx(T,{tone:"info",children:c.active_package.package_name}),e.jsxs("span",{children:["aktif s/d ",ge(c.active_package.expires_at)]}),e.jsx("span",{className:"text-slate-700",children:"·"}),e.jsxs("span",{children:["sisa"," ",c.active_package.request_remaining??"∞"," ","request /"," ",c.active_package.token_remaining??"∞"," token"]})]}):e.jsx("p",{className:"mt-1.5 text-[10px] text-slate-600",children:"Tidak ada paket aktif pada periode ini — semua pemakaian yang berharga dipotong dari wallet."})]})]}):e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"h-3 animate-pulse rounded-full bg-white/[0.04]"}),e.jsx("div",{className:"grid gap-2.5 sm:grid-cols-3",children:[...Array(3)].map((t,n)=>e.jsx("div",{className:"h-24 animate-pulse rounded-xl border border-white/[0.04] bg-white/[0.02]"},n))})]})})]}),e.jsxs(y,{children:[e.jsx(L,{title:"Tren Pemakaian",subtitle:`Per hari · ${R}`,action:e.jsx("div",{className:"flex rounded-lg border border-white/[0.06] bg-white/[0.02] p-0.5",children:Object.keys(k).map(t=>e.jsx("button",{type:"button",onClick:()=>b(t),className:`rounded-md px-2.5 py-1 text-[11px] font-medium transition-colors ${l===t?"bg-white/[0.08] text-white":"text-slate-500 hover:text-slate-300"}`,children:k[t].label},t))})}),e.jsxs($,{children:[e.jsxs("div",{className:"mb-4 grid grid-cols-2 gap-2 sm:grid-cols-4",children:[e.jsx(M,{label:"Total Request",value:g(v)}),e.jsx(M,{label:"Rata-rata/hari",value:p(F),hint:`${z} hari aktif`}),e.jsx(M,{label:"Hari Tersibuk",value:B?ee(B.date):"—",hint:B?`${g(B.requests)} request`:void 0}),e.jsx(M,{label:"Total Token",value:p(O)})]}),s.daily.length===0?e.jsx("div",{className:"flex h-60 items-center justify-center text-sm text-slate-500",children:"Belum ada data penggunaan pada rentang ini."}):e.jsx("div",{className:"h-60 w-full",children:e.jsx(fe,{width:"100%",height:"100%",children:e.jsxs(we,{data:s.daily,margin:{top:4,right:4,left:0,bottom:0},children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"usageTrend",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:k[l].color,stopOpacity:.35}),e.jsx("stop",{offset:"100%",stopColor:k[l].color,stopOpacity:0})]})}),e.jsx(Ne,{strokeDasharray:"3 3",stroke:"rgba(255,255,255,0.05)",vertical:!1}),e.jsx(ke,{dataKey:"date",tickFormatter:ee,tick:{fill:"#475569",fontSize:10},axisLine:!1,tickLine:!1,minTickGap:24}),e.jsx(ve,{tick:{fill:"#475569",fontSize:11},tickFormatter:p,axisLine:!1,tickLine:!1,allowDecimals:!1}),e.jsx(ye,{content:e.jsx(De,{metric:l}),cursor:{stroke:"rgba(255,255,255,0.15)"}}),e.jsx(_e,{type:"monotone",dataKey:k[l].key,name:k[l].label,stroke:k[l].color,strokeWidth:2,fill:"url(#usageTrend)"})]})})})]})]}),e.jsxs("div",{className:"grid grid-cols-1 gap-5 xl:grid-cols-2",children:[e.jsxs(y,{children:[e.jsx(L,{title:"Model Terpopuler",subtitle:"Share request & biaya per model"}),e.jsx($,{className:"space-y-2",children:s.models.length===0?e.jsx("p",{className:"py-8 text-center text-sm text-slate-500",children:"Belum ada data model."}):s.models.slice(0,6).map(t=>{const n=Number(t.requests),q=v>0?n/v*100:0;return e.jsxs("div",{className:"rounded-lg border border-white/[0.04] bg-white/[0.02] px-3 py-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 text-xs",children:[e.jsx("span",{className:"truncate font-mono text-slate-200",children:t.model}),e.jsxs("span",{className:"shrink-0 tabular-nums text-slate-400",children:[e.jsx("span",{className:"font-semibold text-white",children:g(n)})," ","req · ",q.toFixed(1),"%"]})]}),e.jsxs("div",{className:"mt-1.5 flex items-center gap-2",children:[e.jsx("div",{className:"h-1.5 flex-1 overflow-hidden rounded-full bg-white/[0.04]",children:e.jsx("div",{className:"h-full rounded-full bg-gradient-to-r from-blue-500 to-blue-400",style:{width:`${q}%`}})}),e.jsx("span",{className:"w-20 shrink-0 text-right text-[10px] tabular-nums text-slate-500",children:j(Number(t.cost))})]})]},t.model)})})]}),e.jsxs(y,{children:[e.jsx(L,{title:"Per API Key",subtitle:`Pemakaian ${R}`}),e.jsx($,{className:"space-y-2",children:s.detail.length===0?e.jsx("p",{className:"py-8 text-center text-sm text-slate-500",children:"Belum ada pemakaian."}):s.detail.map(t=>{const n=Number(t.requests),q=J>0?n/J*100:0,ue=Number(t.input_tokens)+Number(t.cached_tokens)+Number(t.output_tokens);return e.jsxs("div",{className:"rounded-lg border border-white/[0.04] bg-white/[0.02] px-3 py-2",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("div",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-lg border border-white/[0.06] bg-white/[0.03] text-brand-300",children:e.jsx("svg",{...Z,className:"h-3.5 w-3.5",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:w.key})})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"truncate text-xs font-medium text-white",children:t.name}),e.jsx("p",{className:"truncate font-mono text-[10px] text-slate-600",children:t.key_prefix})]}),e.jsxs("div",{className:"hidden text-right sm:block",children:[e.jsxs("p",{className:"text-xs font-semibold tabular-nums text-white",children:[g(n)," req"]}),e.jsxs("p",{className:"text-[10px] tabular-nums text-slate-500",children:[p(ue)," token"]})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("p",{className:"text-xs font-semibold tabular-nums text-white",children:j(Number(t.cost))}),e.jsxs("p",{className:"text-[10px] text-slate-500 sm:hidden",children:[g(n)," req"]})]})]}),e.jsxs("div",{className:"mt-1.5 flex items-center gap-2",children:[e.jsx("div",{className:"h-1 flex-1 overflow-hidden rounded-full bg-white/[0.04]",children:e.jsx("div",{className:"h-full rounded-full bg-brand-400",style:{width:`${q}%`}})}),e.jsxs("span",{className:"w-9 shrink-0 text-right text-[10px] tabular-nums text-slate-500",children:[q.toFixed(0),"%"]})]})]},t.api_key_id)})})]})]})]}),e.jsxs(y,{children:[e.jsx(L,{title:"Log Permintaan",subtitle:`Rincian request ${a===0?"semua waktu":`${a} hari terakhir`}`,action:e.jsxs("select",{value:i,onChange:t=>o(Number(t.target.value)),className:"input-solid w-auto px-3 py-1.5 text-xs",children:[e.jsx("option",{value:50,children:"50 baris"}),e.jsx("option",{value:100,children:"100 baris"}),e.jsx("option",{value:200,children:"200 baris"})]})}),e.jsxs($,{className:"p-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 border-b border-white/[0.06] px-4 py-2.5",children:[Te.map(t=>e.jsxs("button",{type:"button",onClick:()=>h(t.value),className:`rounded-md px-2.5 py-1 text-[11px] font-medium transition-colors ${m===t.value?"bg-white/[0.08] text-white":"text-slate-500 hover:text-slate-300"}`,children:[t.label,e.jsx("span",{className:"ml-1 tabular-nums text-slate-500",children:me[t.value]})]},t.value)),e.jsxs("span",{className:"ml-auto text-[10px] tabular-nums text-slate-500",children:[A.length," dari ",f.length," baris"]})]}),H&&e.jsxs("div",{className:"p-5 text-sm text-red-300",children:["Gagal memuat log: ",H]}),C&&f.length===0?e.jsx("div",{className:"space-y-3 p-5",children:[...Array(5)].map((t,n)=>e.jsx("div",{className:"h-12 animate-pulse rounded-xl bg-white/[0.02]"},n))}):A.length===0?e.jsx("div",{className:"px-5 py-10 text-center text-sm text-slate-500",children:f.length===0?"Belum ada permintaan pada rentang ini.":"Tidak ada permintaan pada filter ini."}):e.jsx("div",{className:"max-h-[560px] overflow-auto",children:e.jsxs("table",{className:"w-full min-w-[900px] text-left text-sm",children:[e.jsx("thead",{className:"sticky top-0 z-10",children:e.jsxs("tr",{className:"border-b border-white/[0.06] bg-ink-800 text-[11px] uppercase tracking-wider text-slate-500",children:[e.jsx("th",{className:"px-5 py-2.5 font-semibold",children:"Waktu"}),e.jsx("th",{className:"px-4 py-2.5 font-semibold",children:"Model"}),e.jsx("th",{className:"px-4 py-2.5 font-semibold",children:"API Key"}),e.jsx("th",{className:"px-4 py-2.5 text-right font-semibold",children:"Total Token"}),e.jsx("th",{className:"px-4 py-2.5 text-right font-semibold",children:"Biaya"}),e.jsx("th",{className:"px-4 py-2.5 text-right font-semibold",children:"Latency"}),e.jsx("th",{className:"px-5 py-2.5 text-right font-semibold",children:"Status"})]})}),e.jsx("tbody",{children:A.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-2.5 text-xs tabular-nums text-slate-400",children:je(t.created_at)}),e.jsx("td",{className:"px-4 py-2.5",children:t.model?e.jsx("span",{className:"font-mono text-xs text-slate-200",children:t.model}):e.jsx("span",{className:"text-xs text-slate-600",children:"—"})}),e.jsxs("td",{className:"px-4 py-2.5",children:[e.jsx("p",{className:"text-xs font-medium text-slate-200",children:t.key_name}),e.jsx("p",{className:"font-mono text-[11px] text-slate-600",children:t.key_prefix})]}),e.jsx("td",{className:"px-4 py-2.5 text-right font-medium tabular-nums text-slate-300",children:g(t.total_tokens)}),e.jsx("td",{className:"px-4 py-2.5 text-right font-medium tabular-nums text-slate-300",children:Number(t.covered_by_package)===1?e.jsxs("span",{title:"Request ditanggung paket aktif — tidak ada biaya wallet",className:"inline-flex items-center gap-1 rounded-full border border-emerald-400/25 bg-emerald-500/10 px-2 py-0.5 text-[10px] font-medium text-emerald-300",children:[e.jsx("svg",{className:"h-3 w-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 12.75L11.25 15 15 9.75M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),"Paket"]}):t.cost!=null?j(Number(t.cost)):e.jsx("span",{className:"text-slate-600",children:"—"})}),e.jsx("td",{className:"px-4 py-2.5 text-right tabular-nums text-slate-400",children:t.latency_ms!=null?e.jsxs("span",{className:"text-xs",children:[g(t.latency_ms)," ms"]}):e.jsx("span",{className:"text-xs text-slate-600",children:"—"})}),e.jsx("td",{className:"px-5 py-2.5 text-right",children:e.jsx(Re,{code:t.http_status})})]},t.id))})]})})]})]})]})}export{We as default};