import{u as s,j as r}from"./query-Bw69rE6b.js";import{C as n,a as c,b as u}from"./Card-nuKO-lKR.js";import{P as p}from"./PageHeader-qtVByY5c.js";import{S as h}from"./StatusPill-DBEWzsQ3.js";import{o as m,a as f}from"./index-CoUu6FiM.js";import"./react-CQKYBN-P.js";import"./Badge-DwoQNRW3.js";const _=["pricing","models"];function i(e){return e===0?"$0.0000":`$${e.toFixed(4)}`}function d(e){if(e==null)return"—";const t=Math.max(0,Date.now()/1e3-e);return t<60?`${Math.floor(t)}s ago`:t<3600?`${Math.floor(t/60)}m ago`:t<86400?`${(t/3600).toFixed(1)}h ago`:`${(t/86400).toFixed(1)}d ago`}const x=[{id:"model_id",header:"Model",cell:e=>e.model_id,sortValue:e=>e.model_id,mono:!0},{id:"provider_hint",header:"Provider",cell:e=>e.provider_hint||"—",sortValue:e=>e.provider_hint,width:"w-32"},{id:"input_per_mtok",header:"Input $/Mtok",cell:e=>i(e.input_per_mtok),sortValue:e=>e.input_per_mtok,align:"right",width:"w-32"},{id:"output_per_mtok",header:"Output $/Mtok",cell:e=>i(e.output_per_mtok),sortValue:e=>e.output_per_mtok,align:"right",width:"w-32"},{id:"source",header:"Source",cell:e=>e.source,sortValue:e=>e.source,width:"w-28"},{id:"fetched_at",header:"Fetched",cell:e=>d(e.fetched_at),sortValue:e=>e.fetched_at??0,width:"w-24"}],g=[{id:"litellm",label:"LiteLLM",predicate:e=>e.source==="litellm"},{id:"openrouter",label:"OpenRouter",predicate:e=>e.source==="openrouter"},{id:"fallback",label:"Bundled",predicate:e=>e.source==="fallback"}];function S(){const e=s({queryKey:_,queryFn:()=>f.listModelPrices(),refetchOnWindowFocus:!1}),t=e.data?.models??[],a=e.data?.is_stale??!1,l=e.data?.fetched_at??null;return r.jsxs("div",{className:"flex flex-col gap-4 px-6 py-6",children:[r.jsx(p,{title:"LLM model prices",description:"Every model AMX has price data for, refreshed from LiteLLM and OpenRouter."}),r.jsxs(n,{children:[r.jsx(c,{title:`${t.length} models loaded`,description:`Cache snapshot: ${d(l)}`,actions:a?r.jsx(h,{tone:"warning",children:"Stale"}):void 0}),r.jsxs(u,{children:[a&&r.jsx("div",{className:"mb-3 rounded-md border border-warning/40 bg-warning-soft/40 px-3 py-2 text-[12px] text-warning",children:"These prices are more than 24h old. Click the refresh icon in the topbar to pull fresh data."}),r.jsx(m,{columns:x,rows:t,rowKey:o=>o.model_id,searchable:!0,searchPlaceholder:"Search by model id…",searchAccessor:o=>`${o.model_id} ${o.provider_hint} ${o.source}`,filters:g,isLoading:e.isLoading,error:e.error?e.error.message:null,emptyState:r.jsx("div",{className:"px-4 py-6 text-center text-[13px] text-ink-dim",children:"No price data loaded yet. Click the refresh icon in the topbar to populate the catalog from LiteLLM and OpenRouter."}),initialSort:{id:"model_id",direction:"asc"},pageSize:50})]})]})]})}export{S as default};
