PageSourceSearch

https://app.nottana.com/assets/BrwDz4gP.js

js nottana.com collected 2026-09-24 14:49:33 UTC 24,346 bytes, 1 lines download raw bytes

1import{u as e,d as s,j as r,B as t,de as l,T as n,I as i,bl as a,aC as o,d6 as c,d7 as d,Y as x,A as u,b as h,ai as p,dO as j,dP as m,da as g,dQ as b,dR as y,df as v,af as f,ag as S,aq as w,ak as k,a6 as C,al as I,am as z,an as P,ao as D,ap as W,aJ as R,aX as A,aY as $,aQ as T,a3 as L,ac as E,aW as M,G as F,dS as N,N as K,O,a7 as Y,Q as B,p as Q,dT as q,l as X,dU as U,v as G,dV as V,P as J}from"./DZTmPh6V.js";import{a as Z}from"./UqzzAnT4.js";import{b as H}from"./De8K10pL.js";import{a0 as _,a5 as ee,a3 as se,a4 as re,a6 as te,a1 as le,a2 as ne,a7 as ie}from"./d6i-3HOE.js";import{P as ae,a as oe,C as ce}from"./DK5dNNaf.js";import{L as de,a as xe}from"./Bvi2baVk.js";import"./DXvvCRrN.js";import"./Cp3sm0TP.js";const ue={apple:{label:"Apple IAP",color:"#111111",icon:r.jsx(G,{sx:{fontSize:40}})},google:{label:"Google Play",color:"#3ddc84",icon:r.jsx(U,{sx:{fontSize:40}})},stripe:{label:"Stripe",color:"#635bff",icon:r.jsx(X,{sx:{fontSize:40}})},comped:{label:"Comped",color:"#f57c00",icon:r.jsx(j,{sx:{fontSize:40}})},member:{label:"Member",color:"#0288d1",icon:r.jsx(q,{sx:{fontSize:40}})}},he={source:"Source",email:"Email",plan:"Plan",status:"Status",expires:"Expires"},pe=({columnKey:e,sortKey:s,sortDir:t,onSort:l})=>r.jsx(D,{sortDirection:s===e&&t,children:r.jsx(V,{active:s===e,direction:s===e?t:"desc",onClick:()=>l(e),children:he[e]})});pe.propTypes={columnKey:J.string.isRequired,sortKey:J.string.isRequired,sortDir:J.string.isRequired,onSort:J.func.isRequired};const je=[{value:"stripe",label:"Stripe"},{value:"apple",label:"Apple IAP"},{value:"google",label:"Google Play"},{value:"comped",label:"Comped"},{value:"member",label:"Member (on someone's plan)"},{value:"other",label:"Unresolved"}],me=["#1976d2","#388e3c","#7b1fa2","#0097a7","#c2185b","#455a64"],ge=e=>{const s=new Date(e);return`${s.getMonth()+1}/${s.getDate()}`},be=(e,s)=>{if(null==e)return"—";try{return new Intl.NumberFormat(void 0,{style:"currency",currency:(s||"usd").toUpperCase()}).format(e/100)}catch{return`${(e/100).toFixed(2)} ${s||""}`.trim()}},ye=e=>e?new Date(e).toLocaleDateString():"—",ve=e=>null==e?"—":new Intl.NumberFormat(void 0,{style:"currency",currency:"USD",maximumFractionDigits:e%1==0?0:2}).format(e),fe={personal:"Personal",family:"Family",team:"Team"},Se={monthly:"Monthly",yearly:"Yearly"},we=[{key:"1",label:"24h"},{key:"7",label:"7d"},{key:"30",label:"30d"},{key:"90",label:"90d"},{key:"thisQuarter",label:"This Q"},{key:"lastQuarter",label:"Last Q"},{key:"180",label:"6M"},{key:"365",label:"1Y"},{key:"all",label:"All"},{key:"custom",label:"Custom"}],ke=(e,s)=>new Date(e,3*s,1),Ce=({title:e,value:s,subtitle:l,icon:i,color:a})=>r.jsx(f,{sx:{height:"100%"},children:r.jsx(S,{children:r.jsxs(t,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:1},children:[r.jsxs(t,{sx:{minWidth:0},children:[r.jsx(n,{variant:"body2",color:"text.secondary",children:e}),r.jsx(n,{variant:"h4",sx:{fontWeight:600,mt:.5},children:s?.toLocaleString()??"-"}),l&&r.jsx(n,{variant:"caption",color:"text.secondary",children:l})]}),r.jsx(t,{sx:{color:a,opacity:.85},children:i})]})})});Ce.propTypes={title:J.string.isRequired,value:J.number,subtitle:J.string,icon:J.node,color:J.string};const Ie=({title:e,amount:s,subtitle:l,icon:i,color:a})=>r.jsx(f,{sx:{height:"100%"},children:r.jsx(S,{children:r.jsxs(t,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:1},children:[r.jsxs(t,{sx:{minWidth:0},children:[r.jsx(n,{variant:"body2",color:"text.secondary",children:e}),r.jsx(n,{variant:"h4",sx:{fontWeight:600,mt:.5},children:ve(s)}),l&&r.jsx(n,{variant:"caption",color:"text.secondary",children:l})]}),r.jsx(t,{sx:{color:a,opacity:.85},children:i})]})})});Ie.propTypes={title:J.string.isRequired,amount:J.number,subtitle:J.string,icon:J.node,color:J.string};const ze=({source:e})=>{const s=ue[e];return r.jsx(w,{label:s?.label||e||"none",size:"small",sx:{bgcolor:s?`${s.color}22`:"grey.200",color:s?s.color:"text.secondary",fontWeight:600,border:s?`1px solid ${s.color}55`:void 0}})};ze.propTypes={source:J.string};const Pe=({result:e})=>{if(!e)return null;if(!1===e.available)return r.jsx(u,{severity:"info",children:e.reason||"Live lookup is unavailable for this provider."});if(!1===e.found)return r.jsxs(u,{severity:"warning",children:["The provider had no matching record (or it could not be verified).",e.error?` Details: ${e.error}`:""]});const s=e.data||{},l=[];return"apple"===e.provider?(l.push(["Product",s.productId||"—"]),l.push(["Active",s.active?"Yes":"No"]),l.push(["Revoked",s.revoked?"Yes":"No"]),l.push(["Expires",ye(s.expiresAt)]),l.push(["Original transaction",s.originalTransactionId||"—"])):"google"===e.provider?(l.push(["Product",s.productId||"—"]),l.push(["State",s.state||"—"]),l.push(["Active",s.active?"Yes":"No"]),l.push(["Acknowledged",s.acknowledged?"Yes":"No"]),l.push(["Expires",ye(s.expiresAt)])):"stripe"===e.provider&&(l.push(["Subscription",s.subscriptionId||"—"]),l.push(["Status",s.status||"—"]),l.push(["Cancel at period end",s.cancelAtPeriodEnd?"Yes":"No"]),l.push(["Renews / ends",ye(s.currentPeriodEnd)]),s.price&&l.push(["Price",`${be(s.price.unitAmou
1nt,s.price.currency)}${s.price.interval?` / ${s.price.interval}`:""}`])),r.jsxs(t,{children:[r.jsxs(t,{sx:{display:"flex",alignItems:"center",gap:1,mb:1.5},children:[r.jsx(ze,{source:e.provider}),r.jsx(w,{label:"Live from provider",size:"small",color:"success",variant:"outlined"})]}),r.jsx(k,{component:C,variant:"outlined",sx:{overflowX:"auto"},children:r.jsx(I,{size:"small",children:r.jsx(W,{children:l.map(([e,s])=>r.jsxs(P,{children:[r.jsx(D,{sx:{fontWeight:600,width:"45%"},children:e}),r.jsx(D,{sx:{wordBreak:"break-word"},children:s})]},e))})})}),"stripe"===e.provider&&Array.isArray(s.recentInvoices)&&s.recentInvoices.length>0&&r.jsxs(t,{sx:{mt:2},children:[r.jsx(n,{variant:"subtitle2",sx:{mb:1},children:"Recent invoices"}),r.jsx(k,{component:C,variant:"outlined",sx:{overflowX:"auto"},children:r.jsxs(I,{size:"small",children:[r.jsx(z,{children:r.jsxs(P,{sx:{"& th":{fontWeight:600}},children:[r.jsx(D,{children:"Date"}),r.jsx(D,{children:"Number"}),r.jsx(D,{children:"Status"}),r.jsx(D,{align:"right",children:"Paid"})]})}),r.jsx(W,{children:s.recentInvoices.map((e,s)=>r.jsxs(P,{children:[r.jsx(D,{sx:{whiteSpace:"nowrap"},children:ye(e.created)}),r.jsx(D,{children:e.number||e.id||"—"}),r.jsx(D,{children:e.status||"—"}),r.jsx(D,{align:"right",children:be(e.amountPaid,e.currency)})]},s))})]})})]})]})};Pe.propTypes={result:J.object};const De=({period:q})=>{const X=e(),U=s(X.breakpoints.down("sm")),[G,V]=Z.useState(null),[J,he]=Z.useState(!0),[be,De]=Z.useState(null),[We,Re]=Z.useState(q||"30"),[Ae,$e]=Z.useState(""),[Te,Le]=Z.useState(""),[Ee,Me]=Z.useState([]),[Fe,Ne]=Z.useState({page:1,total:0,totalPages:0}),[Ke,Oe]=Z.useState({open:!1,row:null,loading:!1,error:null,subscribers:[],page:1,total:0,totalPages:0}),Ye=Z.useCallback(async(e,s)=>{Oe(e=>({...e,loading:!0,error:null}));try{const r=await H.get("/payments/admin/billing/breakdown-subscribers",{params:{source:e.source,plan:e.plan,cycle:e.cycle,page:s,limit:25}}),t=r?.data||{};Oe(e=>({...e,loading:!1,subscribers:t.subscribers||[],page:t.pagination?.page||s,total:t.pagination?.total??0,totalPages:t.pagination?.totalPages??0}))}catch(r){Oe(e=>({...e,loading:!1,subscribers:[],error:r?.response?.data?.message||r?.message||"Failed to load subscribers"}))}},[]),Be=Z.useCallback(e=>{Oe({open:!0,row:e,loading:!0,error:null,subscribers:[],page:1,total:0,totalPages:0}),Ye(e,1)},[Ye]),Qe=Z.useCallback(()=>{Oe(e=>({...e,open:!1}))},[]),[qe,Xe]=Z.useState(!1),[Ue,Ge]=Z.useState([]),[Ve,Je]=Z.useState("source"),[Ze,He]=Z.useState("desc"),[_e,es]=Z.useState(""),[ss,rs]=Z.useState(""),[ts,ls]=Z.useState(1),[ns,is]=Z.useState({open:!1,email:"",loading:!1,result:null}),as=Z.useCallback(async()=>{try{he(!0),De(null);const e=((e,s,r)=>{if(/^\d+$/.test(e))return{days:e};const t=new Date,l=Math.floor(t.getMonth()/3);if("thisQuarter"===e)return{startDate:ke(t.getFullYear(),l).toISOString()};if("lastQuarter"===e){const e=new Date(t.getFullYear(),3*(l-1),1),s=new Date(ke(t.getFullYear(),l).getTime()-1);return{startDate:e.toISOString(),endDate:s.toISOString()}}if("all"===e)return{startDate:new Date("2020-01-01T00:00:00.000Z").toISOString()};if("custom"===e){const e={};return s&&(e.startDate=new Date(`${s}T00:00:00`).toISOString()),r&&(e.endDate=new Date(`${r}T23:59:59`).toISOString()),Object.keys(e).length?e:{days:"30"}}return{days:"30"}})(We,Ae,Te),s=await H.get("/payments/admin/billing/overview",{params:e});s.data?.success&&V(s.data)}catch{De("Failed to load billing overview.")}finally{he(!1)}},[We,Ae,Te]),os=Z.useCallback(async()=>{try{Xe(!0);const e=await H.get("/payments/admin/billing/subscribers",{params:{source:Ue.join(","),search:ss,sort:Ve,dir:Ze,page:ts,limit:25}});e.data?.success&&(Me(e.data.subscribers||[]),Ne(e.data.pagination||{page:1,total:0,totalPages:0}))}catch{Me([])}finally{Xe(!1)}},[Ue,ss,ts,Ve,Ze]),cs=Z.useCallback(e=>{ls(1),Je(s=>(He(r=>s===e?"asc"===r?"desc":"asc":"desc"),e))},[]);Z.useEffect(()=>{as()},[as]),Z.useEffect(()=>{os()},[os]);const ds=()=>{ls(1),rs(_e.trim())},xs=Z.useCallback(async(e,s)=>{is({open:!0,email:s,loading:!0,result:null});try{const s=await H.get("/payments/admin/billing/lookup",{params:{userId:e}});is(e=>({...e,loading:!1,result:s.data}))}catch(r){is(e=>({...e,loading:!1,result:{available:!0,found:!1,error:r?.response?.data?.message||"Lookup failed"}}))}},[]),us=()=>is({open:!1,email:"",loading:!1,result:null}),hs=G?.providersConfigured||{},ps=Object.entries(hs).filter(([,e])=>!e).map(([e])=>ue[e]?.label||e),js=e=>G?.bySource?.find(s=>
1s.source===e)?.count??0,ms=e=>`${(e=>G?.bySource?.find(s=>s.source===e)?.active??0)(e).toLocaleString()} active`,gs=(G?.bySource||[]).filter(e=>e.count>0).map(e=>({name:ue[e.source]?.label||e.source,value:e.count,source:e.source})),bs=(G?.byPlan||[]).map(e=>({plan:e.plan,count:e.count})),ys=(()=>{if("custom"===We)return Ae||Te?`${Ae||"…"} → ${Te||"now"}`:"custom range";const e=we.find(e=>e.key===We);return e?e.label:We})(),vs=G?.breakdown||[],fs=vs.reduce((e,s)=>e+(s.mrr||0),0),Ss=G?.cycleCounts||{monthly:0,yearly:0};return r.jsxs(t,{sx:{mt:5},children:[r.jsxs(t,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:2,gap:1,flexWrap:"wrap"},children:[r.jsxs(t,{sx:{display:"flex",alignItems:"center",gap:1},children:[r.jsx(l,{color:"primary"}),r.jsx(n,{variant:"h5",sx:{fontWeight:600},children:"Billing & Subscriptions"})]}),r.jsx(i,{onClick:as,disabled:J,size:"small",children:r.jsx(a,{})})]}),r.jsxs(o,{direction:"row",spacing:1,alignItems:"center",flexWrap:"wrap",useFlexGap:!0,sx:{mb:2},children:[r.jsx(c,{value:We,exclusive:!0,size:"small",onChange:(e,s)=>s&&Re(s),sx:{flexWrap:"wrap"},children:we.map(e=>r.jsx(d,{value:e.key,sx:{px:1.25},children:e.label},e.key))}),"custom"===We&&r.jsxs(o,{direction:"row",spacing:1,alignItems:"center",children:[r.jsx(x,{type:"date",size:"small",label:"From",InputLabelProps:{shrink:!0},value:Ae,onChange:e=>$e(e.target.value)}),r.jsx(x,{type:"date",size:"small",label:"To",InputLabelProps:{shrink:!0},value:Te,onChange:e=>Le(e.target.value)})]})]}),be&&r.jsx(u,{severity:"error",sx:{mb:2},children:be}),ps.length>0&&r.jsxs(u,{severity:"warning",sx:{mb:2},children:["Live transaction lookup is unavailable for: ",ps.join(", ")," (provider not configured on this environment). Stored subscription data is still shown."]}),J&&!G?r.jsx(t,{sx:{display:"flex",justifyContent:"center",p:4},children:r.jsx(h,{})}):r.jsxs(r.Fragment,{children:[r.jsxs(p,{container:!0,spacing:2,sx:{mb:3},children:[r.jsx(p,{item:!0,xs:6,sm:4,md:!0,children:r.jsx(Ce,{title:"Total Paying",value:G?.totals?.paying,icon:r.jsx(l,{sx:{fontSize:40}}),color:"primary.main"})}),r.jsx(p,{item:!0,xs:6,sm:4,md:!0,children:r.jsx(Ce,{title:"Apple IAP",value:js("apple"),subtitle:ms("apple"),icon:ue.apple.icon,color:ue.apple.color})}),r.jsx(p,{item:!0,xs:6,sm:4,md:!0,children:r.jsx(Ce,{title:"Google Play",value:js("google"),subtitle:ms("google"),icon:ue.google.icon,color:ue.google.color})}),r.jsx(p,{item:!0,xs:6,sm:4,md:!0,children:r.jsx(Ce,{title:"Stripe",value:js("stripe"),subtitle:ms("stripe"),icon:ue.stripe.icon,color:ue.stripe.color})}),r.jsx(p,{item:!0,xs:6,sm:4,md:!0,children:r.jsx(Ce,{title:"Comped",value:G?.totals?.comped,icon:r.jsx(j,{sx:{fontSize:40}}),color:"#f57c00"})}),r.jsx(p,{item:!0,xs:6,sm:4,md:!0,children:r.jsx(Ce,{title:"Trials",value:G?.totals?.trials,icon:r.jsx(m,{sx:{fontSize:40}}),color:"#0097a7"})}),r.jsx(p,{item:!0,xs:6,sm:4,md:!0,children:r.jsx(Ce,{title:"Expiring (7d)",value:G?.totals?.expiringSoon,icon:r.jsx(g,{sx:{fontSize:40}}),color:"#d32f2f"})})]}),r.jsx(n,{variant:"subtitle2",color:"text.secondary",sx:{mb:1},children:"Estimated recurring revenue — active paying subscribers, as of now"}),G?.revenue?.excludedFromMrr>0&&r.jsxs(n,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:1},children:[G.revenue.excludedFromMrr.toLocaleString()," active-plan account",1===G.revenue.excludedFromMrr?"":"s"," excluded from MRR (no verified payment provider — grant or test account, not comped)"]}),r.jsxs(p,{container:!0,spacing:2,sx:{mb:3},children:[r.jsx(p,{item:!0,xs:12,sm:4,children:r.jsx(Ie,{title:"MRR",amount:G?.revenue?.mrr,subtitle:"Monthly recurring revenue",icon:r.jsx(b,{sx:{fontSize:40}}),color:"success.main"})}),r.jsx(p,{item:!0,xs:12,sm:4,children:r.jsx(Ie,{title:"ARR",amount:G?.revenue?.arr,subtitle:"Annual run-rate (MRR × 12)",icon:r.jsx(y,{sx:{fontSize:40}}),color:"primary.main"})}),r.jsx(p,{item:!0,xs:12,sm:4,children:r.jsx(Ie,{title:"New MRR",amount:G?.revenue?.newMrrInPeriod,subtitle:`Added in ${ys}`,icon:r.jsx(v,{sx:{fontSize:40}}),color:"#7b1fa2"})})]}),r.jsxs(p,{container:!0,spacing:3,sx:{mb:2},children:[r.jsx(p,{item:!0,xs:12,md:4,children:r.jsx(f,{sx:{height:"100%"},children:r.jsxs(S,{children:[r.jsx(n,{variant:"h6",gutterBottom:!0,children:"Subscribers by Source"}),gs.length>0?r.jsx(_,{width:"100%",height:280,children:r.jsxs(ae,{children:[r.jsx(oe,{data:gs,dataKey:"value",nameKey:"name",cx:"50%",cy:"50%",outerRadius:90,label:!0,children:gs.map(e=>r.jsx(ee,{fill:ue[e.source]?.color||"#888"},e.source))}),r.jsx(se,{}),r.jsx(re,{})]})}):r.jsx(n,{color:"text.secondary",sx:{py:6,textAlign:"center"},children:"No paying subscribers yet"})]})})}),r.jsx(p,{item:!0,xs:12,md:4,children:r.jsx(f,{sx:{height:"100%"},children:r.jsxs(S,{children:[r.jsx(n,{variant:"h6",gutterBottom:!0,children:"Users by Plan"}),bs.length>0?r.jsx(_,{width:"100%",height:280,children:r.jsxs(te,{data:bs,children:[r.jsx(ce,{strokeDasharray:"3 3"}),r.jsx(le,{dataKey:"plan",tick:{fontSize:11}}),r.jsx(ne,{allowDecimals:!1}),r.jsx(se,{}),r.jsx(ie,{dataKey:"count",children:bs.map((e,s)=>r.jsx(ee,{fill:me[s%me.length]},e.plan))})]})}):r.jsx(n,{color:"text.secondary",sx:{py:6,textAlign:"center"},children:"No data"})]})})}),r.jsx(p,{item:!0,xs:12,md:4,children:r.jsx(f,{sx:{height:"100%"},children:r.jsxs(S,{children:[r.jsxs(n,{variant:"h6",gutterBottom:!0,children:["New Paid (",ys,")"]}),r.jsx(_,{width:"100%",height:280,children:r.jsxs(de,{data:G?.newPaidOverTime||[],children:[r.jsx(ce,{strokeDasharray:"3 3"}),r.jsx(le,{dataKey:"date",tickFormatter:ge,tick:{fontSize:11}}),r.jsx(ne,{allowDecimals:!1}),r.jsx(se,{labelFormatter:ge}),r.jsx(xe,{type:"monotone",dataKey:"count",stroke:"#388e3c",strokeWidth:2,dot:!1})]})})]})})})]}),r.jsx(f,{sx:{mb:3},children:r.jsxs(S,{children:[r.jsxs(t,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",flexWrap:"wrap",gap:1,mb:1},children:[r.jsxs(t,{children:[r.jsx(n,{variant:"h6",children:"Revenue Breakdown"}),r.jsx(n,{variant:"caption",color:"text.secondary",children:"Select a row to list the subscribers behind it"})]}),r.jsxs(o,{direction:"row",spacing:1,children:[r.jsx(w,{label:`Monthly: ${Ss.monthly.toLocaleStr
1ing()} subs · ${ve(G?.revenue?.byCycle?.monthly)}`,size:"small",variant:"outlined"}),r.jsx(w,{label:`Yearly: ${Ss.yearly.toLocaleString()} subs · ${ve(G?.revenue?.byCycle?.yearly)}`,size:"small",variant:"outlined"})]})]}),r.jsx(k,{component:C,variant:"outlined",sx:{overflowX:"auto"},children:r.jsxs(I,{size:"small",children:[r.jsx(z,{children:r.jsxs(P,{sx:{"& th":{fontWeight:600}},children:[r.jsx(D,{children:"Source"}),r.jsx(D,{children:"Plan"}),r.jsx(D,{children:"Cycle"}),r.jsx(D,{align:"right",children:"Subscribers"}),r.jsx(D,{align:"right",children:"MRR"})]})}),r.jsxs(W,{children:[vs.map((e,s)=>r.jsxs(P,{hover:!0,onClick:()=>Be(e),role:"button",tabIndex:0,onKeyDown:s=>{"Enter"!==s.key&&" "!==s.key||(s.preventDefault(),Be(e))},sx:{cursor:"pointer","&:hover":{backgroundColor:"action.hover"}},children:[r.jsx(D,{children:r.jsx(ze,{source:e.source})}),r.jsx(D,{children:fe[e.plan]||e.plan}),r.jsx(D,{children:Se[e.cycle]||e.cycle}),r.jsx(D,{align:"right",children:e.count.toLocaleString()}),r.jsx(D,{align:"right",children:ve(e.mrr)})]},s)),0===vs.length?r.jsx(P,{children:r.jsx(D,{colSpan:5,align:"center",sx:{color:"text.secondary"},children:"No active paying subscribers"})}):r.jsxs(P,{sx:{"& td":{fontWeight:700,borderTop:"2px solid",borderColor:"divider"}},children:[r.jsx(D,{colSpan:3,children:"Total MRR"}),r.jsx(D,{align:"right",children:vs.reduce((e,s)=>e+s.count,0).toLocaleString()}),r.jsx(D,{align:"right",children:ve(fs)})]})]})]})})]})}),r.jsx(f,{sx:{mb:3},children:r.jsxs(S,{children:[r.jsx(n,{variant:"h6",gutterBottom:!0,children:"Recent Billing Events"}),r.jsx(k,{component:C,variant:"outlined",sx:{overflowX:"auto"},children:r.jsxs(I,{size:"small",children:[r.jsx(z,{children:r.jsxs(P,{sx:{"& th":{fontWeight:600}},children:[r.jsx(D,{children:"When"}),r.jsx(D,{children:"User"}),r.jsx(D,{children:"Change"}),r.jsx(D,{children:"Product"})]})}),r.jsxs(W,{children:[(G?.recentEvents||[]).map((e,s)=>r.jsxs(P,{children:[r.jsx(D,{sx:{whiteSpace:"nowrap"},children:new Date(e.timestamp).toLocaleString()}),r.jsx(D,{sx:{whiteSpace:"nowrap"},children:e.email||e.userId}),r.jsx(D,{children:r.jsxs(t,{sx:{display:"flex",alignItems:"center",gap:.5},children:[r.jsx(ze,{source:e.fromSource}),r.jsx("span",{children:"→"}),r.jsx(ze,{source:e.toSource})]})}),r.jsx(D,{children:e.productId||"—"})]},s)),(!G?.recentEvents||0===G.recentEvents.length)&&r.jsx(P,{children:r.jsx(D,{colSpan:4,align:"center",sx:{color:"text.secondary"},children:"No billing-source changes in this period"})})]})]})})]})}),r.jsx(f,{children:r.jsxs(S,{children:[r.jsxs(t,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:2,gap:1,flexWrap:"wrap"},children:[r.jsx(n,{variant:"h6",children:"Subscribers"}),r.jsxs(t,{sx:{display:"flex",gap:1,flexWrap:"wrap"},children:[r.jsxs(R,{size:"small",sx:{minWidth:200},children:[r.jsx(A,{children:"Source"}),r.jsx($,{multiple:!0,label:"Source",value:Ue,onChange:e=>{ls(1);const s=e.target.value;Ge("string"==typeof s?s.split(","):s)},renderValue:e=>0===e.length?"All":e.map(e=>ue[e]?.label||e).join(", "),displayEmpty:!0,children:je.map(e=>r.jsxs(T,{value:e.value,children:[r.jsx(L,{size:"small",checked:Ue.includes(e.value)}),r.jsx(E,{primary:e.label})]},e.value))})]}),r.jsx(x,{size:"small",placeholder:"Search name / email",value:_e,onChange:e=>es(e.target.value),onKeyDown:e=>{"Enter"===e.key&&ds()},InputProps:{endAdornment:r.jsx(i,{size:"small",onClick:ds,children:r.jsx(M,{fontSize:"small"})})}})]})]}),r.jsx(k,{component:C,variant:"outlined",sx:{overflowX:"auto"},children:r.jsxs(I,{size:"small",sx:{minWidth:720},children:[r.jsx(z,{children:r.jsxs(P,{sx:{"& th":{fontWeight:600}},children:[["email","source","plan","status"].map(e=>r.jsx(pe,{columnKey:e,sortKey:Ve,sortDir:Ze,onSort:cs},e)),r.jsx(D,{children:"Product"}),r.jsx(pe,{columnKey:"expires",sortKey:Ve,sortDir:Ze,onSort:cs}),r.jsx(D,{align:"right",children:"Lookup"})]})}),r.jsx(W,{children:qe?r.jsx(P,{children:r.jsx(D,{colSpan:7,align:"center",sx:{py:3},children:r.jsx(h,{size:24})})}):0===Ee.length?r.jsx(P,{children:r.jsx(D,{colSpan:7,align:"center",sx:{color:"text.secondary"},children:"No subscribers match this filter"})}):Ee.map(e=>
1r.jsxs(P,{sx:{"&:hover":{backgroundColor:"action.hover"}},children:[r.jsx(D,{sx:{whiteSpace:"nowrap"},children:e.email||e.userId}),r.jsxs(D,{children:[r.jsx(ze,{source:e.source}),e.isMember&&e.ownerEmail?r.jsxs(n,{variant:"caption",sx:{display:"block",opacity:.7,mt:.25},children:["on ",e.ownerEmail]}):null]}),r.jsx(D,{children:e.planId||"—"}),r.jsx(D,{children:e.planStatus||"—"}),r.jsx(D,{sx:{maxWidth:200,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.productId||"—"}),r.jsx(D,{sx:{whiteSpace:"nowrap"},children:ye(e.expiresAt)}),r.jsx(D,{align:"right",children:r.jsx(F,{size:"small",variant:"outlined",onClick:()=>xs(e.userId,e.email),children:"Look up"})})]},e.userId))})]})}),Fe.totalPages>1&&r.jsx(t,{sx:{display:"flex",justifyContent:"center",mt:2},children:r.jsx(N,{count:Fe.totalPages,page:ts,onChange:(e,s)=>ls(s),size:"small"})}),r.jsxs(n,{variant:"caption",color:"text.secondary",sx:{mt:1,display:"block"},children:[Fe.total.toLocaleString()," subscriber",1===Fe.total?"":"s"," total. Transaction ids are never exposed here — “Look up” verifies against the provider server-side."]})]})})]}),r.jsxs(K,{open:Ke.open,onClose:Qe,maxWidth:"md",fullWidth:!0,fullScreen:U,children:[r.jsxs(O,{sx:{pr:6},children:[r.jsx(n,{component:"div",variant:"h6",children:Ke.row?`${fe[Ke.row.plan]||Ke.row.plan} · ${Se[Ke.row.cycle]||Ke.row.cycle}`:"Subscribers"}),Ke.row?r.jsxs(t,{sx:{display:"flex",alignItems:"center",gap:1,mt:.5,flexWrap:"wrap"},children:[r.jsx(ze,{source:Ke.row.source}),r.jsxs(n,{variant:"body2",color:"text.secondary",children:[Ke.row.count.toLocaleString()," in this row",Ke.loading||Ke.error?"":` · ${Ke.total.toLocaleString()} listed`]})]}):null,r.jsx(i,{onClick:Qe,size:"small",sx:{position:"absolute",right:8,top:8},"aria-label":"Close",children:r.jsx(Y,{fontSize:"small"})})]}),r.jsx(B,{dividers:!0,children:Ke.loading?r.jsx(t,{sx:{display:"flex",justifyContent:"center",py:4},children:r.jsx(h,{size:28})}):Ke.error?r.jsx(u,{severity:"error",children:Ke.error}):0===Ke.subscribers.length?r.jsx(n,{variant:"body2",color:"text.secondary",sx:{py:2},children:"No subscribers matched this row."}):r.jsxs(r.Fragment,{children:[r.jsx(k,{component:C,variant:"outlined",sx:{overflowX:"auto"},children:r.jsxs(I,{size:"small",children:[r.jsx(z,{children:r.jsxs(P,{sx:{"& th":{fontWeight:600}},children:[r.jsx(D,{children:"Name"}),r.jsx(D,{children:"Email"}),r.jsx(D,{children:"Status"}),r.jsx(D,{children:"Cycle"})]})}),r.jsx(W,{children:Ke.subscribers.map((e,s)=>r.jsxs(P,{children:[r.jsx(D,{sx:{whiteSpace:"nowrap"},children:e.name||"—"}),r.jsx(D,{sx:{wordBreak:"break-all"},children:e.email||"—"}),r.jsx(D,{children:e.planStatus||"—"}),r.jsx(D,{children:Se[e.billingCycle]||e.billingCycle||"—"})]},e.userId||e.email||s))})]})}),Ke.totalPages>1?r.jsx(t,{sx:{display:"flex",justifyContent:"center",mt:2},children:r.jsx(N,{count:Ke.totalPages,page:Ke.page,onChange:(e,s)=>Ye(Ke.row,s),size:"small",siblingCount:U?0:1})}):null]})})]}),r.jsxs(K,{open:ns.open,onClose:us,maxWidth:"sm",fullWidth:!0,fullScreen:U,children:[r.jsxs(O,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",py:1.5},children:[r.jsxs(n,{variant:"h6",noWrap:!0,children:["Transaction lookup",ns.email?` — ${ns.email}`:""]}),r.jsx(i,{onClick:us,size:"small",children:r.jsx(Y,{})})]}),r.jsx(Q,{}),r.jsx(B,{sx:{p:{xs:1.5,sm:2}},children:ns.loading?r.jsx(t,{sx:{display:"flex",justifyContent:"center",p:4},children:r.jsx(h,{})}):r.jsx(Pe,{result:ns.result})})]})]})};De.propTypes={period:J.string.isRequired};const We=()=>{const[l,i]=Z.useState("30"),a=e(),o=s(a.breakpoints.down("sm"));return r.jsxs(t,{sx:{p:{xs:1.5,sm:3}},children:[r.jsxs(t,{sx:{display:"flex",flexDirection:{xs:"column",sm:"row"},alignItems:{xs:"flex-start",sm:"center"},justifyContent:"space-between",gap:1.5,mb:2},children:[r.jsxs(t,{children:[r.jsx(n,{variant:"h5",sx:{fontWeight:600},children:"Billing & Subscriptions"}),r.jsx(n,{variant:"body2",color:"text.secondary",children:"Revenue, active subscribers and recent billing events"})]}),r.jsxs(c,{value:l,exclusive:!0,onChange:(e,s)=>s&&i(s),size:"small",fullWidth:o,children:[r.jsx(d,{value:"1",children:"24h"}),r.jsx(d,{value:"7",children:"7d"}),r.jsx(d,{value:"30",children:"30d"}),r.jsx(d,{value:"90",children:"90d"})]})]}),r.jsx(De,{period:l})]})};export{We 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.