PageSourceSearch

https://rolebotz.ai/assets/Expense-cIkDioh7.js

js rolebotz.ai collected 2026-10-05 14:43:04 UTC 29,114 bytes, 1 lines download raw bytes

1import{e as re,r as m,j as e,B as V,as as le,C as o,G as ie,W as ne,au as de,aw as oe,R as X,T as v,m as I,ac as ce,O as xe,w as me,aK as he,aL as pe,y as j}from"./index-WWECtYvd.js";import{S as _}from"./index-BCPQLdpu.js";import{A as Z}from"./AreaChart-HQNk4sxK.js";import{B as ue}from"./BarChart-iNny7h97.js";import{i as ye,S as O,A as ge,g as f,d,M as g,f as be,b as t,p as je,a as fe}from"./_shared-C0aQwtyd.js";import"./useControllableState-CYtZNIYI.js";import"./useCallbackRef-CVNXAPIG.js";import"./index-Dcv3uDI5.js";const Ne=[{value:"30",label:"30d"},{value:"90",label:"90d"},{value:"180",label:"180d"}],R=[{key:"main",label:"main",color:"#008CBA",grad:"exp-ct-main"},{key:"router",label:"router",color:"#8C62FF",grad:"exp-ct-router"},{key:"memory_gate",label:"memory gate",color:"#00c27f",grad:"exp-ct-mem"},{key:"autonomous",label:"autonomous",color:"#FE964A",grad:"exp-ct-auto"},{key:"other",label:"other",color:"#a3a3a3",grad:"exp-ct-other"}],w="#FE964A",y="#008CBA",k="#ff6a55",q=({share:c,color:h})=>e.jsx("div",{className:"h-1.5 w-20 rounded bg-gray-100 dark:bg-gray-700 overflow-hidden",children:e.jsx("div",{className:"h-1.5 rounded",style:{width:`${Math.max(0,Math.min(100,(typeof c=="number"&&!isNaN(c)?c:0)*100))}%`,backgroundColor:h}})}),C=({v:c,className:h=""})=>e.jsx("span",{className:`tabular-nums whitespace-nowrap ${c?"heading-text":"text-gray-500"} ${h}`,children:t(c)}),S=({eyebrow:c,title:h,sub:E,icon:a})=>e.jsxs("div",{className:"flex items-start justify-between gap-4 mb-4",children:[e.jsxs("div",{children:[c&&e.jsx("div",{className:"text-xs text-primary mb-1",children:c}),e.jsx("div",{className:"font-medium heading-text",children:h}),E&&e.jsx("div",{className:"text-xs text-gray-500 mt-1 max-w-2xl",children:E})]}),a&&e.jsx("span",{className:"text-gray-400 text-xl flex-shrink-0",children:a})]}),A=({color:c,children:h})=>e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"w-2.5 h-2.5 rounded-sm flex-shrink-0",style:{backgroundColor:c}}),h]}),$=({cols:c,children:h})=>e.jsx("tr",{children:e.jsx("td",{colSpan:c,className:"px-5 py-12 text-center text-sm text-gray-500",children:h})}),Le=()=>{const c=re(),[h,E]=m.useState("90"),[a,J]=m.useState(null),[W,B]=m.useState(!0),[L,D]=m.useState(!1),[G,M]=m.useState(null),[Q,z]=m.useState(0),[T,Y]=m.useState("call_type"),[F,ee]=m.useState(!1);m.useEffect(()=>{document.title="Internal · Net Expense"},[]),m.useEffect(()=>{let s=!1;return D(!0),(async()=>{try{const l=await ye(`/api/internal/expenses?days=${h||"90"}`);if(s)return;J(l),M(null)}catch(l){if(s)return;M(l)}finally{s||(B(!1),D(!1))}})(),()=>{s=!0}},[h,Q]);const b=a?.series||[],K=m.useMemo(()=>b.map(s=>({date:(s.date||"").slice(5),full:s.date||"",lane_total_usd:s.lane_total_usd??0,total_usd:s.total_usd??0,known:s.lane_known?1:0})),[b]),P=m.useMemo(()=>b.map(s=>({date:(s.date||"").slice(5),main:s.main??0,router:s.router??0,memory_gate:s.memory_gate??0,autonomous:s.autonomous??0,other:s.other??0,customer_usd:s.customer_usd??0,ops_usd:s.ops_usd??0})),[b]),se=m.useMemo(()=>{const s={};for(const l of a?.by_call_type||[])s[l.call_type]=l.usd;return s},[a]),H=m.useMemo(()=>b.filter(s=>!s.lane_known).length,[b]),te=e.jsxs("div",{children:[e.jsx(o,{className:"mb-6",children:e.jsx(j,{height:48})}),e.jsx("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-4 mb-6",children:[0,1,2,3].map(s=>e.jsx(o,{children:e.jsx(j,{height:92})},s))}),e.jsx("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-4 mb-8",children:[0,1,2,3].map(s=>e.jsx(o,{children:e.jsx(j,{height:72})},s))}),e.jsx(o,{className:"mb-6",children:e.jsx(j,{height:280})}),e.jsx(o,{className:"mb-6",children:e.jsx(j,{height:260})}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[e.jsx(o,{children:e.jsx(j,{height:220})}),e.jsx(o,{children:e.jsx(j,{height:220})})]})]}),n=a?.totals,x=a?.live||null,r=a?.net||null,N=a?.capture||null,u=a?.revenue,p=a?.coverage,i=a?.recon;return e.jsxs("div",{className:"container mx-auto py-6",children:[e.jsx(O,{eyebrow:"INTERNAL",title:"Net Expense",subtitle:"What we spend, where it goes, who is expensive.",action:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(_,{value:h,onChange:s=>E(s||"90"),children:Ne.map(s=>e.jsx(_.Item,{value:s.value,children:s.label},s.value))}),e.jsx(V,{size:"sm",variant:"default",icon:e.jsx(le,{}),loading:L,onClick:()=>z(s=>s+1),children:"Refresh"})]})}),e.jsx(ge,{loading:W,error:G,skeleton:te,onRetry:()=>{B(!0),M(null),z(s=>s+1)},empty:!W&&!G&&!a,emptyText:"The expense endpoint returned no payload.",children:a&&n&&u&&p&&i&&e.jsxs(e.Fragment,{children:[e.jsxs(o,{className:"mb-6 border-amber-300 dark:border-amber-500/40 bg-amber-50/60 dark:bg-amber-500/5",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(ie,{className:"text-amber-500 text-lg mt-0.5 flex-shrink-0"}),e.jsxs("div",{className:"text-sm text-gray-700 dark:text-gray-300 space-y-1",children:[e.jsxs("p",{children:["Per-call attribution covers"," ",e.jsx("span",{className:"font-medium heading-text tabular-nums",children:f(n.attributed_share_of_lane)})," ","of the metered bill — the rest is unattributed fleet backstop."]}),e.jsx("p",{children:u.note}),e.jsxs("p",{className:"text-xs text-gray-500",children:["Revenue basis ",e.jsx("span",{className:"font-mono",children:u.basis})," ·"," ",d(u.manual_accounts??0)," manually set ·"," ",d(u.stripe_linked_accounts)," with a Stripe link ·"," ",d(u.accounts_priced)," on a priced tier (not counted as revenue)",u.enterprise_accounts>0&&e.jsxs(e.Fragment,{children:[" · ",d(u.enterprise_accounts)," enterprise"]})]})]})]}),(p.errors.length>0||p.truncated)&&e.jsxs("div",{className:"mt-3 rounded-lg border border-rose-300 dark:border-rose-500/40 bg-rose-50 dark:bg-rose-500/10 px-3 py-2 text-xs text-rose-700 dark:text-rose-300 space-y-0.5",children:[p.truncated&&e.jsx("div",{children:"Sweep truncated — at least one day was not fully paged. Figures below are a floor, not a total."}),p.errors.map((s,l)=>e.jsx("div",{className:"break-words font-mono",children:s},l))]})]}),e.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-4 mb-4",children:[e.jsx(g,{size:"lg",icon:e.jsx(ne,{}),tone:"primary",label:"Spend today",value:t(x?x.today_usd:null),sub:x?`FLOWMETER · as of ${be(x.as_of)}`:"FLOWMETER has not reported yet"}),e.jsx(g,{size:"lg",icon:e.jsx(de,{}),label:"Burn per hour",value:t(x?x.burn_usd_per_hr:null),sub:x?"current hourly rate":"FLOWMETER has not reported yet"}),e.jsx(g,{size:"lg",icon:e.jsx(oe,{}),label:"Projected end of day",value:t(x?x.eod_projection_usd:null),sub:x?.coverage||(x?"projection from today’s burn":"FLOWMETER has not reported yet")}),e.jsx(g,{size:"lg",icon:e.jsx(X,{}),label:"Average per day",value:t(n.invoice_avg_usd_per_day??n.lane_avg_usd_per_day),sub:n.invoice_avg_usd_per_day!=null?`provider invoices · ${d(n.invoice_days)} days`:`${d(n.lane_days)} metered days · meter only`})]}),x&&x.top_sources.length>0&&e.jsxs("div",{className:"flex items-center gap-3 flex-wrap text-xs text-gray-500 mb-8",children:[e.jsx("span",{children:"Live top sources:"}),x.top_sources.map((s,l)=>e.jsxs(v,{className:"border-0 bg-gray-100 text-gray-600 dark:bg-gray-700 dark:text-gray-300 text-xs px-2 py-0",children:[s.name," ",e.jsx("span",{className:"ml-1 tabular-nums",children:t(s.usd)})]},l))]}),e.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-4",children:[e.jsx(g,{tone:"danger",label:r?.cost_basis==="provider_invoice"?"Actual cost, invoiced":"Metered cost",value:t(r?r.cost_usd:null),sub:r?r.cost_basis==="provider_invoice"?`${t(r.cost_per_day_usd)}/day over ${d(r.basis_days)} days · Anthropic + AWS`:`over ${d(r.basis_days)} metered days · meter only, a floor`:"No cost data in this window"}),e.jsx(g,{label:"Revenue (billed)",value:t(r?r.revenue_usd:null),sub:r?`${t(u.mrr_usd)}/mo run-rate · earned in ${r.basis_days}d · manual + Stripe`:"No metered days in this window"}),e.jsx(g,{size:"lg",tone:r?r.net_usd>=0?"success":"danger":"default",label:"Net",value:t(r?r.net_usd:null),sub:r?`billed revenue − ${r.cost_basis==="provider_invoice"?"invoiced cost":"metered cost"}${r.monthly_run_rate_usd!=null?` · ${t(r.monthly_run_rate_usd)}/mo burn`:""}`:"No cost data in this window"}),e.jsx(g,{label:"Margin",value:r?f(r.margin_pct):"—",sub:r?`confidence: ${r.confidence}`:"No metered days in this window"})]}),r&&r.cost_components.length>0&&e.jsxs("div",{className:"flex items-center gap-3 flex-wrap text-xs text-gray-500 mt-3",children:[e.jsx("span",{children:"Cost is:"}),r.cost_components.map((s,l)=>e.jsxs(v,{className:"border-0 bg-gray-100 text-gray-600 dark:bg-gray-700 dark:text-gray-300 text-xs px-2 py-0",children:[s.label," ",e.jsx("span",{className:"ml-1 tabular-nums heading-text",children:t(s.usd)}),e.jsxs("span",{className:"ml-1 opacity-70",children:["(",t(s.per_day_usd),"/day)"]})]},l))]}),N&&e.jsxs("div",{className:"mt-3 rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-900 dark:border-amber-500/30 dark:bg-amber-500/10 dark:text-amber-200",children:[e.jsx("span",{className:"heading-text",children:"Meter blind spot — "}),"our token meter accounts for"," ",e.jsxs("span",{className:"tabular-nums heading-text",children:[N.meter_capture_pct,"%"]})," ","of the Anthropic invoice over ",d(N.basis_days)," days (",t(N.anthropic_metered_usd)," metered vs ",t(N.anthropic_invoice_usd)," invoiced,"," ",e.jsx("span",{className:"tabular-nums heading-text",children:t(N.unmetered_usd)})," unattributed). Metered and attributed figures on this page are floors, not the bill."]}),r&&r.caveats.length>0&&e.jsx("ul",{className:"text-xs text-gray-500 mt-3 mb-8 space-y-0.5 list-disc pl-5",children:r.caveats.map((s,l)=>e.jsx("li",{children:s},l))}),(!r||r.caveats.length===0)&&e.jsx("div",{className:"mb-8"}),e.jsxs(o,{className:"mb-6",children:[e.jsx(S,{eyebrow:"THE BILL",title:`Total metered spend by day · ${a.window.days} days`,sub:"The metered lane rollup is the whole bill. Attributed model calls are the slice we can trace to a caller — the gap between the two lines is unattributed fleet backstop.",icon:e.jsx(X,{})}),K.length===0?e.jsx("div",{className:"p-12 text-center text-sm text-gray-500",children:"No days in this window."}):e.jsxs(e.Fragment,{children:[e.jsx(Z,{data:K,height:280,areaConfig:[{type:"monotone",dataKey:"lane_total_usd",stroke:k,fill:"url(#exp-lane)"},{type:"monotone",dataKey:"total_usd",stroke:y,fill:"url(#exp-attr)"}],xAxisConfig:{dataKey:"date",interval:"preserveStartEnd",minTickGap:24},yAxisConfig:{hide:!1,domain:[0,"auto"],width:60,tickLine:!1,axisLine
1:!1},cartesianGridConfig:{strokeDasharray:"3 3"},tooltipContentConfig:{nameFormatter:s=>s==="lane_total_usd"?"Metered total":"Attributed calls",valueFormatter:(s,l)=>{const ae=l?.payload?.known,U=t(Number(s??0));return ae===0?`${U} · no rollup yet`:U}},children:e.jsxs("defs",{children:[e.jsxs("linearGradient",{id:"exp-lane",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"5%",stopColor:k,stopOpacity:.45}),e.jsx("stop",{offset:"95%",stopColor:k,stopOpacity:.04})]}),e.jsxs("linearGradient",{id:"exp-attr",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"5%",stopColor:y,stopOpacity:.5}),e.jsx("stop",{offset:"95%",stopColor:y,stopOpacity:.04})]})]})}),e.jsxs("div",{className:"flex items-center gap-4 text-xs text-gray-500 mt-3 flex-wrap",children:[e.jsxs(A,{color:k,children:["Metered total ",e.jsx("span",{className:"tabular-nums heading-text ml-1",children:t(n.lane_total_usd)})]}),e.jsxs(A,{color:y,children:["Attributed calls ",e.jsx("span",{className:"tabular-nums heading-text ml-1",children:t(n.attributed_total_usd)})]}),e.jsxs("span",{children:[f(n.attributed_share_of_lane)," of the bill is attributed"]}),H>0&&e.jsxs("span",{className:"text-amber-600 dark:text-amber-400",children:[d(H)," of ",d(b.length)," days have no rollup yet — a zero there means no data, not no spend"]})]})]})]}),e.jsxs(o,{className:"mb-6",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4 mb-4 flex-wrap",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-primary mb-1",children:"ATTRIBUTED"}),e.jsx("div",{className:"font-medium heading-text",children:"Attributed model calls by day"}),e.jsxs("div",{className:"text-xs text-gray-500 mt-1 max-w-2xl",children:["Attributed spend only (",f(n.attributed_share_of_lane)," of the bill), split by normalised call type or by who it was for. Our-ops is amber and is never a customer figure."]})]}),e.jsxs(_,{value:T,onChange:s=>Y(s||"call_type"),children:[e.jsx(_.Item,{value:"call_type",children:"By call type"}),e.jsx(_.Item,{value:"ours",children:"Ours vs customer"})]})]}),P.length===0?e.jsx("div",{className:"p-12 text-center text-sm text-gray-500",children:"No attributed calls in this window."}):e.jsxs(e.Fragment,{children:[e.jsx(Z,{data:P,height:260,areaConfig:T==="ours"?[{type:"monotone",dataKey:"customer_usd",stackId:"oc",stroke:y,fill:"url(#exp-cust)"},{type:"monotone",dataKey:"ops_usd",stackId:"oc",stroke:w,fill:"url(#exp-ops)"}]:R.map(s=>({type:"monotone",dataKey:s.key,stackId:"ct",stroke:s.color,fill:`url(#${s.grad})`})),xAxisConfig:{dataKey:"date",interval:"preserveStartEnd",minTickGap:24},yAxisConfig:{hide:!1,domain:[0,"auto"],width:56,tickLine:!1,axisLine:!1},cartesianGridConfig:{strokeDasharray:"3 3"},tooltipContentConfig:{nameFormatter:s=>s==="customer_usd"?"Customer":s==="ops_usd"?"Our ops":R.find(l=>l.key===s)?.label||s,valueFormatter:s=>t(Number(s??0))},children:e.jsxs("defs",{children:[e.jsxs("linearGradient",{id:"exp-cust",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"5%",stopColor:y,stopOpacity:.55}),e.jsx("stop",{offset:"95%",stopColor:y,stopOpacity:.08})]}),e.jsxs("linearGradient",{id:"exp-ops",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"5%",stopColor:w,stopOpacity:.55}),e.jsx("stop",{offset:"95%",stopColor:w,stopOpacity:.08})]}),R.map(s=>e.jsxs("linearGradient",{id:s.grad,x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"5%",stopColor:s.color,stopOpacity:.55}),e.jsx("stop",{offset:"95%",stopColor:s.color,stopOpacity:.08})]},s.grad))]})}),e.jsx("div",{className:"flex items-center gap-4 text-xs text-gray-500 mt-3 flex-wrap",children:T==="ours"?e.jsxs(e.Fragment,{children:[e.jsxs(A,{color:y,children:["Customer ",e.jsx("span",{className:"tabular-nums heading-text ml-1",children:t(n.attributed_customer_usd)})]}),e.jsxs(A,{color:w,children:["Our ops ",e.jsx("span",{className:"tabular-nums heading-text ml-1",children:t(n.attributed_ops_usd)})]}),e.jsxs("span",{children:[d(n.attributed_calls)," attributed calls"]})]}):R.map(s=>e.jsxs(A,{color:s.color,children:[s.label," ",e.jsx("span",{className:"tabular-nums heading-text ml-1",children:t(se[s.key]??0)})]},s.key))})]})]}),e.jsx(O,{eyebrow:"WHERE IT GOES",title:"Lanes and models",subtitle:"Lane totals come from the metered rollup. A lane marked “no attribution” cannot be split per customer — that is why per-customer spend never reconciles to the bill."}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4 mb-10",children:[e.jsxs(o,{className:"overflow-hidden !p-0",children:[e.jsxs("div",{className:"px-5 py-3 border-b border-gray-200 dark:border-gray-700",children:[e.jsx("div",{className:"font-medium heading-text text-sm",children:"By lane"}),e.jsxs("div",{className:"text-xs text-gray-500",children:["Metered basis · ",t(n.lane_total_usd)," total"]})]}),e.jsx("div",{className:`overflow-x-auto transition-opacity ${L?"opacity-60":""}`,children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"text-xsr text-gray-500 border-b border-gray-200 dark:border-gray-700",children:[e.jsx("th",{className:"text-left px-5 py-3 font-medium",children:"Lane"}),e.jsx("th",{className:"text-right px-5 py-3 font-medium",children:"Spend"}),e.jsx("th",{className:"text-right px-5 py-3 font-medium",children:"Days"}),e.jsx("th",{className:"text-right px-5 py-3 font-medium",children:"Share"}),e.jsx("th",{className:"px-5 py-3"})]})}),e.jsx("tbody",{children:a.by_lane.length===0?e.jsx($,{cols:5,children:"No lane rollups in this window."}):a.by_lane.map((s,l)=>e.jsxs(I.tr,{initial:{opacity:0}
1,animate:{opacity:1},transition:{duration:.2,delay:Math.min(l*.01,.3)},className:"border-b border-gray-100 dark:border-gray-700/60",children:[e.jsx("td",{className:"px-5 py-3",children:e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"heading-text font-mono text-xs break-all",children:s.lane}),!s.attributable&&e.jsx(v,{className:"border-0 bg-gray-100 text-gray-600 dark:bg-gray-700 dark:text-gray-300 text-xs px-2 py-0",children:"no attribution"})]})}),e.jsx("td",{className:"px-5 py-3 text-right",children:e.jsx(C,{v:s.usd})}),e.jsx("td",{className:"px-5 py-3 text-right tabular-nums text-gray-500",children:d(s.days)}),e.jsx("td",{className:"px-5 py-3 text-right tabular-nums text-gray-500",children:f(s.share)}),e.jsx("td",{className:"px-5 py-3",children:e.jsx(q,{share:s.share,color:k})})]},s.lane))})]})})]}),e.jsxs(o,{className:"overflow-hidden !p-0",children:[e.jsxs("div",{className:"px-5 py-3 border-b border-gray-200 dark:border-gray-700",children:[e.jsx("div",{className:"font-medium heading-text text-sm",children:"By model"}),e.jsxs("div",{className:"text-xs text-gray-500",children:["Attributed basis · ",t(n.attributed_total_usd)," over ",d(n.attributed_calls)," calls"]})]}),e.jsx("div",{className:`overflow-x-auto transition-opacity ${L?"opacity-60":""}`,children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"text-xsr text-gray-500 border-b border-gray-200 dark:border-gray-700",children:[e.jsx("th",{className:"text-left px-5 py-3 font-medium",children:"Model"}),e.jsx("th",{className:"text-right px-5 py-3 font-medium",children:"Spend"}),e.jsx("th",{className:"text-right px-5 py-3 font-medium",children:"Calls"}),e.jsx("th",{className:"text-right px-5 py-3 font-medium",children:"Share"}),e.jsx("th",{className:"px-5 py-3"})]})}),e.jsx("tbody",{children:a.by_model.length===0?e.jsx($,{cols:5,children:"No attributed model calls in this window."}):a.by_model.map((s,l)=>e.jsxs(I.tr,{initial:{opacity:0}
1,animate:{opacity:1},transition:{duration:.2,delay:Math.min(l*.01,.3)},className:"border-b border-gray-100 dark:border-gray-700/60",children:[e.jsx("td",{className:"px-5 py-3 heading-text font-mono text-xs break-all",children:s.model||"(unknown)"}),e.jsx("td",{className:"px-5 py-3 text-right",children:e.jsx(C,{v:s.usd})}),e.jsx("td",{className:"px-5 py-3 text-right tabular-nums text-gray-500",children:d(s.calls)}),e.jsx("td",{className:"px-5 py-3 text-right tabular-nums text-gray-500",children:f(s.share)}),e.jsx("td",{className:"px-5 py-3",children:e.jsx(q,{share:s.share,color:y})})]},s.model||l))})]})})]})]}),e.jsxs(o,{className:"mb-10",children:[e.jsx(S,{eyebrow:"OUR OPS",title:"PITCREW spend by crew",sub:`Our own autonomous operations. Excluded from every customer figure, included in the total. Bucketed from ${p.excluded_ids.join(", ")||"the excluded ids"}.`,icon:e.jsx(ce,{})}),a.by_ops_crew.length===0?e.jsx("div",{className:"p-12 text-center text-sm text-gray-500",children:"No our-ops spend attributed in this window."}):e.jsxs(e.Fragment,{children:[e.jsx(ue,{data:a.by_ops_crew.map(s=>({crew:s.crew,usd:s.usd,calls:s.calls})),height:Math.max(160,a.by_ops_crew.length*30+50),layout:"vertical",barConfig:[{dataKey:"usd",fill:w,radius:[0,6,6,0]}],xAxisConfig:{type:"number",hide:!1,tickLine:!1,axisLine:!1},yAxisConfig:{type:"category",dataKey:"crew",hide:!1,width:120,tickLine:!1,axisLine:!1},cartesianGridConfig:{strokeDasharray:"3 3"},chartHorizontalSpace:8,tooltipContentConfig:{nameFormatter:()=>"Spend",valueFormatter:s=>t(Number(s??0))}}),e.jsxs("div",{className:"text-xs text-gray-500 mt-3",children:["These crews sum to"," ",e.jsx("span",{className:"tabular-nums heading-text",children:t(n.attributed_ops_usd)})," ","of attributed our-ops spend in this window."]})]})]}),e.jsx(O,{eyebrow:"WHO IS EXPENSIVE",title:"Attributed customer spend",subtitle:"Attributed model calls booked to a customer id, highest first. Our-ops never appears here."}),e.jsx("div",{className:"text-xs text-gray-500 mb-3",children:p.attributed_note}),e.jsx(o,{className:"overflow-hidden !p-0 mb-3",children:e.jsx("div",{className:`overflow-x-auto transition-opacity ${L?"opacity-60":""}`,children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"text-xsr text-gray-500 border-b border-gray-200 dark:border-gray-700",children:[e.jsx("th",{className:"text-left px-5 py-3 font-medium",children:"Account"}),e.jsx("th",{className:"text-left px-5 py-3 font-medium",children:"Plan"}),e.jsxs("th",{className:"text-right px-5 py-3 font-medium",children:["Spend ",a.window.days,"d"]}),e.jsx("th",{className:"text-right px-5 py-3 font-medium",children:"Spend 30d"}),e.jsx("th",{className:"text-right px-5 py-3 font-medium",children:"Calls"}),e.jsx("th",{className:"px-5 py-3"})]})}),e.jsx("tbody",{children:a.top_spenders.length===0?e.jsx($,{cols:6,children:"No attributed customer spend in this window."}):a.top_spenders.map((s,l)=>e.jsxs(I.tr,{initial:{opacity:0}
1,animate:{opacity:1},transition:{duration:.2,delay:Math.min(l*.01,.3)},className:"border-b border-gray-100 dark:border-gray-700/60 hover:bg-gray-50 dark:hover:bg-gray-800/40 transition-colors cursor-pointer",onClick:()=>c(`/internal/customers/${encodeURIComponent(s.customer_id)}`),children:[e.jsxs("td",{className:"px-5 py-3",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.is_staff&&e.jsx("span",{title:"Rolebotz staff or internal account",className:"inline-flex",children:e.jsx(xe,{className:"text-amber-500 text-sm"})}),e.jsx("span",{className:"heading-text font-medium",children:s.label||s.customer_id}),s.is_staff&&e.jsx(v,{className:"border-0 bg-amber-100 text-amber-700 dark:bg-amber-500/15 dark:text-amber-300 text-xs px-2 py-0",children:"staff"})]}),e.jsx("div",{className:"text-xs text-gray-500 break-all",children:s.email||s.customer_id})]}),e.jsx("td",{className:"px-5 py-3 text-gray-600 dark:text-gray-400",children:je(s.plan)}),e.jsx("td",{className:"px-5 py-3 text-right",children:e.jsx(C,{v:s.usd_window})}),e.jsx("td",{className:"px-5 py-3 text-right",children:e.jsx(C,{v:s.usd_30d})}),e.jsx("td",{className:"px-5 py-3 text-right tabular-nums text-gray-500",children:d(s.calls)}),e.jsx("td",{className:"px-5 py-3",children:e.jsx(me,{className:"text-gray-400"})})]},s.customer_id))})]})})}),e.jsxs("div",{className:"text-xs text-gray-500 mb-10",children:["Customer bucket ",t(n.attributed_customer_usd)," · of which staff/internal"," ",t(n.attributed_staff_usd)," (a subset, not an addition) · our-ops"," ",t(n.attributed_ops_usd)," shown separately above."]}),e.jsx(O,{eyebrow:"RECONCILIATION",title:"Provider bills",subtitle:`${d(i.days_available)} days of provider reconciliation available in this window.`}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4 mb-10",children:[e.jsxs(o,{children:[e.jsx(S,{title:"AWS",sub:i.aws?`billing date ${i.aws.date}`:void 0}),i.aws?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-3xl font-bold tabular-nums heading-text leading-none mb-3",children:t(i.aws.total_usd)}),e.jsx("div",{className:"space-y-1",children:i.aws.by_service.length===0?e.jsx("div",{className:"text-xs text-gray-500",children:"No per-service breakdown recorded."}):i.aws.by_service.map((s,l)=>e.jsxs("div",{className:"flex items-center justify-between gap-3 text-xs",children:[e.jsx("span",{className:"text-gray-600 dark:text-gray-400 break-all",children:s.service}),e.jsx("span",{className:"tabular-nums heading-text whitespace-nowrap",children:t(s.usd)})]},l))})]}):e.jsx("div",{className:"text-sm text-gray-500",children:"No reconciliation for this window."})]}),e.jsxs(o,{children:[e.jsx(S,{title:"Anthropic",sub:i.anthropic?`billing date ${i.anthropic.date}`:void 0}),i.anthropic?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx("div",{className:"text-3xl font-bold tabular-nums heading-text leading-none",children:t(i.anthropic.console_usd)}),i.anthropic.status&&e.jsx(v,{className:"border-0 bg-amber-100 text-amber-700 dark:bg-amber-500/15 dark:text-amber-300 text-xs px-2 py-0",children:i.anthropic.status})]}),e.jsxs("div",{className:"space-y-1 text-xs",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:"console"}),e.jsx("span",{className:"tabular-nums heading-text",children:t(i.anthropic.console_usd)})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:"metered"}),e.jsx("span",{className:"tabular-nums heading-text",children:t(i.anthropic.metered_usd)})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:"residual"}),e.jsx("span",{className:"tabular-nums heading-text",children:t(i.anthropic.residual_usd)})]})]}),i.anthropic.coverage&&e.jsx("div",{className:"text-xs text-gray-500 mt-3 break-words",children:i.anthropic.coverage})]}):e.jsx("div",{className:"text-sm text-gray-500",children:"No reconciliation for this window."})]}),e.jsxs(o,{children:[e.jsx(S,{title:"Cache ROI",sub:i.cache_roi?`billing date ${i.cache_roi.date}`:void 0}),i.cache_roi?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-3xl font-bold tabular-nums text-success leading-none mb-3",children:t(i.cache_roi.net_usd)}),e.jsxs("div",{className:"space-y-1 text-xs",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:"saved"}),e.jsx("span",{className:"tabular-nums heading-text",children:t(i.cache_roi.saved_usd)})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:"write premium"}),e.jsx("span",{className:"tabular-nums heading-text",children:t(i.cache_roi.premium_usd)})]})]}),e.jsx("div",{className:"text-xs text-gray-500 mt-3",children:"Net saved by prompt c
1aching."})]}):e.jsx("div",{className:"text-sm text-gray-500",children:"No reconciliation for this window."})]})]}),e.jsxs(o,{className:"mb-8",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium heading-text",children:"Raw call types"}),e.jsxs("div",{className:"text-xs text-gray-500 mt-1 max-w-2xl",children:["Every raw ",e.jsx("span",{className:"font-mono",children:"call_type"})," value as stored, and the bucket it collapsed into. Normalisation is visible here so it can never be a silent data loss."]})]}),e.jsx(V,{size:"sm",variant:"link",icon:F?e.jsx(he,{}):e.jsx(pe,{}),onClick:()=>ee(s=>!s),children:F?"Hide raw values":`Show raw values (${d(a.call_type_raw.length)})`})]}),F&&e.jsx("div",{className:"overflow-x-auto -mx-5 -mb-5 mt-4",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"text-xsr text-gray-500 border-b border-gray-200 dark:border-gray-700",children:[e.jsx("th",{className:"text-left px-5 py-2 font-medium",children:"Raw"}),e.jsx("th",{className:"text-left px-5 py-2 font-medium",children:"Normalised to"}),e.jsx("th",{className:"text-right px-5 py-2 font-medium",children:"Spend"}),e.jsx("th",{className:"text-right px-5 py-2 font-medium",children:"Calls"})]})}),e.jsx("tbody",{children:a.call_type_raw.length===0?e.jsx($,{cols:4,children:"No call types recorded in this window."}):a.call_type_raw.map((s,l)=>e.jsxs("tr",{className:"border-b border-gray-100 dark:border-gray-700/60",children:[e.jsx("td",{className:"px-5 py-2.5 font-mono text-xs break-all text-gray-600 dark:text-gray-400",children:s.raw||"(empty)"}),e.jsx("td",{className:"px-5 py-2.5",children:e.jsx(v,{className:"border-0 bg-gray-100 text-gray-600 dark:bg-gray-700 dark:text-gray-300 text-xs px-2 py-0",children:s.normalised})}),e.jsx("td",{className:"px-5 py-2.5 text-right",children:e.jsx(C,{v:s.usd})}),e.jsx("td",{className:"px-5 py-2.5 text-right tabular-nums text-gray-500",children:d(s.calls)})]},`${s.raw}-${l}`))})]})})]}),e.jsxs("div",{className:"text-xs text-gray-500 space-y-1 pb-4",children:[e.jsx("div",{children:p.attributed_note}),e.jsx("div",{children:p.lane_note}),e.jsx("div",{children:p.forge_note}),e.jsxs("div",{children:["Per-path cost logging started ",p.cost_logging_started_at," — earlier customer spend was computed and discarded, not zero."]}),e.jsxs("div",{children:["user_id present on ",f(p.user_attribution_pct)," of swept rows — per
1-seat spend is not yet a grain that exists."]}),e.jsxs("div",{children:["Window ",a.window.from," → ",a.window.to," · sweep ",d(p.sweep_days),"d · generated"," ",fe(a.window.generated_at)," · cache ",d(a.window.cache_age_s),"s"]})]})]})})]})};export{Le 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.