1import{A as B}from"./AsyncState-C1wY1NSf.js";import{M}from"./MasterDataTable-PTWiW2Qq.js";import"./creatorFieldHelp-BrZsjpkG.js";import"./FieldLabel-DcFbp3Rs.js";import"./ChromeButton-DmiFifbd.js";import"./DataTable-DiOue6-9.js";import{M as T}from"./MetricGrid-DMaQt6lc.js";import{S as V}from"./SectionHeader-60mU8zeF.js";import{C}from"./ChromeCard-DkvfllPh.js";import{k as N,c as w,y as g,C as P,D as R,z as k,H as D,J as U,K as E,r as i,_ as F,Q as c,u as e}from"./vendor-misc-5pJBpqhN.js";import{_ as $,k as I}from"./index-BNPflmqD.js";import{A as O}from"./AdminTabToolbar-DQnD-zBS.js";import{N as j,O as H}from"./adminApi-CoQuaOSc.js";import"./useBreakpoint-DOQrj9xp.js";import"./breakpoints-Cr7fi6TV.js";import"./arrow-up-8FIemuBW.js";import"./vendor-utils-CxkvrZ9U.js";import"./format-W5H20hG1.js";import"./vendor-vue-BIDZeepx.js";import"./vendor-tanstack-B6ELLr_Q.js";import"./vendor-sentry-84cD2ryj.js";import"./PageToolbar-C0IR3MXo.js";const z={key:0,class:"sparkline-title"},G=["viewBox","aria-label"],J=["points","stroke"],K={key:2,class:"sparkline-empty"},L=N({__name:"SparklineChart",props:{title:{},values:{},width:{default:240},height:{default:48},accentVar:{default:"--accent-sapphire"}},setup(t){const r=t,u=w(()=>(r.values??[]).filter(a=>Number.isFinite(a))),m=w(()=>{const a=u.value;if(!a.length)return"";const s=Math.max(...a,1),d=Math.min(...a,0),p=s-d||1;return a.map((n,o)=>{const f=o/Math.max(a.length-1,1)*r.width,h=r.height-(n-d)/p*(r.height-4)-2;return`${f},${h}`}).join(" ")});return(a,s)=>(g(),P(C,{class:"sparkline-card"},{default:R(()=>[t.title?(g(),k("h3",z,D(t.title),1)):U("",!0),u.value.length?(g(),k("svg",{key:1,class:"sparkline",viewBox:`0 0 ${t.width} ${t.height}`,preserveAspectRatio:"none",role:"img","aria-label":t.title||"Trend chart"},[E("polyline",{points:m.value,fill:"none",stroke:`var(${t.accentVar})`,"stroke-width":"2"},null,8,J)],8,G)):(g(),k("p",K,"No trend data."))]),_:1}))}}),Q=$(L,[["__scopeId","data-v-94e4436c"]]);function A(t){const r=Number(t??0);return new Intl.NumberFormat(void 0,{style:"currency",currency:"USD"}).format(r)}function q(){const t=i(!0),r=i(null),u=i(null),m=i([]),a=i([]),s=i([]),d=i([]),p=i(null);async function n(){t.value=!0,r.value=null;try{const[o,f]=await Promise.all([j(),H(12).catch(()=>null)]),h=o,_=h.data??h,l=_.revenue??{},y=_.subscriptions??{};m.value=[{id:"mrr",label:"MRR",value:A(l.mrr)},{id:"arr",label:"ARR",value:A(l.arr)},{id:"active",label:"Active subscriptions",value:String(y.total_active??0)},{id:"creators",label:"Total creators",value:String(y.total_creators??0)},{id:"churn",label:"Churn (30d)",value:`${Number(y.churn_rate_percent??0)}%`}];const x=y.by_plan??{};a.value=Object.entries(x).map(([v,S])=>({id:v,plan:v.charAt(0).toUpperCase()+v.slice(1),count:Number(S)}));const b=f;s.value=(b==null?void 0:b.trend)??[],d.value=s.value.map(v=>v.mrr),p.value=(b==null?void 0:b.growth_pct)??null,u.value=new Date}catch(o){r.value=I(o,"Failed to load business metrics")}finally{t.value=!1}}return F(n),{loading:t,error:r,lastUpdated:u,metrics:m,planRows:a,trend:s,trendValues:d,growthPct:p,refresh:n}}const W={class:"admin-tab"},X=N({__name:"AdminBusinessTab",setup(t){const{loading:r,error:u,lastUpdated:m,metrics:a,planRows:s,trend:d,trendValues:p,growthPct:n,refresh:o}=q(),f=[{key:"month",label:"Month"},{key:"mrr",label:"MRR",align:"right",format:"currency"},{key:"subscriber_count",label:"Orgs / seats",align:"right",format:"number"}],h=w(()=>d.value.map(l=>({id:l.month,month:l.month,mrr:l.mrr,subscriber_count:l.subscriber_count}))),_=[{key:"plan",label:"Plan"},{key:"count",label:"Subscribers",align:"right",format:"number"}];return(l,y)=>(g(),k("div",W,[c(O,{loading:e(r),"last-updated":e(m),onRefresh:e(o)},null,8,["loading","last-updated","onRefresh"]),c(B,{loading:e(r),error:e(u),onRetry:e(o)},{default:R(()=>[c(T,{items:e(a)},null,8,["items"]),c(C,{class:"admin-business__card"},{default:R(()=>[c(V,{title:"Agency MRR trend (12 months)",description:e(n)!=null?`${e(n)>0?"+":""}${e(n)}% over the period`:"Monthly recurring revenue from agency desk subscriptions"},null,8,["description"]),c(Q,{values:e(p),width:480,height:64},null,8,["values"])]),_:1}),c(M,{class:"admin-business__card admin-business__trend",title:"Agency MRR trend (12 months)",description:e(n)!=null?`${e(n)>0?"+":""}${e(n)}
1% over the period`:"Monthly recurring revenue from agency desk subscriptions","count-label":"months",columns:f,rows:h.value,"default-sort-key":"month","default-sort-direction":"desc",layout:"table","empty-label":"No trend data","priority-columns":["month","mrr"]},null,8,["description","rows"]),c(M,{class:"admin-business__card",title:"Tier distribution",description:"Agency orgs by Launch / Scale / Empire (and legacy plans if any).","count-label":"plans",columns:_,rows:e(s),"default-sort-key":"count","default-sort-direction":"desc",layout:"table","empty-label":"No subscription data"},null,8,["rows"])]),_:1},8,["loading","error","onRetry"])]))}}),_e=$(X,[["__scopeId","data-v-563a32b9"]]);export{_e 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.