1import{r,j as l}from"./react-vendor-CU6Sz31W.js";import{as as B,f2 as ut,cf as ye,ci as dt,u as pt,al as ft,b as mt,aD as bt,ii as ht,be as Se,j0 as gt,t as De,E as yt,eq as St,dP as Ct}from"./index-DEXJEDAi.js";import{w as N,q as W,l as ve,o as ce,e as z,f as Ie,z as xt,c as Me}from"./firebase-w6DYUbFN.js";import{u as vt}from"./useClientStaffSubscriptionsGate-BCro_DuA.js";import{u as Et}from"./useOpenPatientProfile-CASNKG5E.js";import"./calendar-RV2oTCrW.js";import{a as wt}from"./DataTableCard-BluwWKn_.js";import"./ExportCsvAction-BJr9eiP6.js";import{a as At}from"./localTableUtils-D6jRZlmf.js";import{a as se,b as Tt}from"./filterDescriptorUtils-NUS9ISaN.js";import"./patient-name-link-BAfQKbEs.js";import"./text-highlight-BFqqfcjs.js";import{d as It,s as Mt}from"./emptyStateReason-DJABlLfy.js";import{K as Ce}from"./KpiTile-C9Lf8Uia.js";import{statusMetaFor as oe,planTypeMeta as X,ENROLLMENT_STATUS as j,enrollmentNextRunAt as Ne,cadenceLabel as le,staffBillingModeLabel as Ee,hasClinicalPolicy as Ke,staffNextEventLabel as xe,availableActionsFor as Nt}from"./subscriptionEnrollmentDisplay-f8nekOZX.js";import{M as Rt,A as Pt,D as kt}from"./cells-Db2ZEFlu.js";import{b as Lt}from"./patientSubscriptionsApi-KUGSVQNU.js";import"./payment-icons-Daq1K3F1.js";import"./useClientStaffPermissions-lm-TFENw.js";import"./addWeeks-1hrFjz19.js";import"./index-BSuGcRaZ.js";import"./table-CxPdvV_9.js";import"./arrow-up-D6DFVL4j.js";import"./arrow-down-BjUlbB4f.js";import"./pill-filter-CtZSNPVl.js";import"./date-picker-filter-Qp1kqu9t.js";import"./clear-filters-button-DmPemFGr.js";import"./modal-option-cards-Dksohkou.js";import"./Sparkline-CRGbuase.js";import"./chartTheme-By-OHNNJ.js";import"./LineChart-CR9Oqe-_.js";import"./editor-D8UbQKN1.js";import"./value-BGBiTkF3.js";import"./BarChart-oNqFvUUt.js";import"./graphicalItemSelectors-NjnoOTSd.js";import"./AreaChart-uR5Wnr3N.js";import"./formatters-C_0Kn-_3.js";import"./arrow-up-right-DG_mPx_g.js";import"./arrow-down-right-DcZLkz9z.js";import"./minus-Du80G9MU.js";import"./ellipsis-vertical-C-dQ6Kzj.js";const Be=6e3;function We(e){var t;return!!(e!=null&&e.empty&&((t=e==null?void 0:e.metadata)!=null&&t.fromCache))}class ze extends Error{constructor(t="Could not reach the server to load this data."){super(t),this.name="SnapshotUnreachableError",this.code="unavailable"}}const ie=100,jt=30;function we(e){return{id:e.id,...e.data()}}function Ot(e,t){const s=new Set(e.map(a=>a.id));return[...e,...t.filter(a=>!s.has(a.id))]}function ue(e,t=[]){const s=String(e||"").trim();if(!s)return[];const a=(Array.isArray(t)?t:[]).map(n=>String(n||"").trim()).filter(n=>n&&n!==s);return[...new Set([s,...a])].slice(0,jt)}async function Vt({clientId:e,childClientIds:t=[],enabled:s=!0}){const a=ue(e,t);return!s||!a.length?[]:(await Me(W(z(B,"SubscriptionEnrollments"),a.length===1?N("clientId","==",a[0]):N("clientId","in",a),ce("createdAt","desc")))).docs.map(we)}function _t({clientId:e,childClientIds:t=[],enabled:s=!0}){const a=ue(e,t).join("|"),n=r.useMemo(()=>a?a.split("|"):[],[a]),u=s&&n.length>0,[y,f]=r.useState([]),[i,d]=r.useState(!0),[R,S]=r.useState(!!u),[_,h]=r.useState(!1),[H,E]=r.useState(null),[O,U]=r.useState(0),m=r.useRef(null),w=r.useRef(!1),p=r.useRef(!0),C=r.useRef(!1),A=r.useRef(y),I=r.useRef(null);r.useEffect(()=>{A.current=y},[y]);const T=r.useCallback(()=>n.length===1?N("clientId","==",n[0]):N("clientId","in",n),[n]);r.useEffect(()=>{if(!u){f([]),d(!1),S(!1),E(null),m.current=null,w.current=!1,p.current=!1;return}S(!0),E(null),m.current=null,w.current=!1,p.current=!0,d(!0);const g=W(z(B,"SubscriptionEnrollments"),T(),ce("createdAt","desc"),ve(ie)),v=()=>{I.current&&(clearTimeout(I.current),I.current=null)},V=Ie(g,M=>{if(We(M)){I.current||(I.current=setTimeout(()=>{I.current=null,E(new ze("Could not reach the server to load recurring items.")),S(!1)},Be));return}v();const D=M.docs.map(we);if(f(P=>w.current?Ot(D,P):D),!w.current){m.current=M.docs.at(-1)||null;const P=M.docs.length===ie;p.current=P,d(P)}S(!1),E(null)},M=>{console.error("Error listening to client subscription enrollments:",M),v(),E(M),S(!1)});return()=>
1{v(),V()}},[u,T,O]);const b=r.useCallback(async()=>{if(!(!u||!p.current||C.current)&&m.current){C.current=!0,h(!0);try{const g=W(z(B,"SubscriptionEnrollments"),T(),ce("createdAt","desc"),xt(m.current),ve(ie)),v=await Me(g),V=v.docs.map(we),M=new Set(A.current.map(F=>F.id)),D=V.filter(F=>!M.has(F.id));w.current=!0,m.current=v.docs.at(-1)||m.current;const P=v.docs.length===ie;p.current=P,d(P),f(F=>[...F,...D])}catch(g){console.error("Error loading more client subscription enrollments:",g),E(g)}finally{C.current=!1,h(!1)}}},[u,T]),x=r.useCallback(()=>U(g=>g+1),[]);return{enrollments:y,loading:R,loadingMore:_,hasMore:i,loadMore:b,error:H,retry:x,fetchAllRows:()=>Vt({clientId:e,childClientIds:t,enabled:s})}}const Ut="unknown";function He(e){return String((e==null?void 0:e.status)||"").trim()||Ut}function Ye(e){return X(e).id}function qe(e){return(e==null?void 0:e.billingMode)==="invoice"?"invoice":"vault_charge"}const Dt={invoice:"Invoiced",vault_charge:"Saved card"};function Ge(e){return le(e)}function ae(e,t,s){const a=String(t??"").trim();if(!a)return;const n=e.get(a);e.set(a,{id:a,label:String(s??a),count:((n==null?void 0:n.count)||0)+1})}function re(e){return[...e.values()].sort((t,s)=>t.label.localeCompare(s.label))}const ne=["past_due","awaiting_payment","pending_setup","active","paused","cancelled"];function Ft(e){return[...e].sort((t,s)=>{const a=ne.indexOf(t.id),n=ne.indexOf(s.id);return(a===-1?ne.length:a)-(n===-1?ne.length:n)})}function $t(e=[]){const t=new Map,s=new Map,a=new Map,n=new Map;
1return(Array.isArray(e)?e:[]).forEach(u=>{const y=He(u);ae(t,y,oe(u).label),ae(s,Ye(u),X(u).label);const f=qe(u);ae(a,f,Dt[f]);const i=Ge(u);ae(n,i,i.charAt(0).toUpperCase()+i.slice(1))}),{statuses:Ft(re(t)),planTypes:re(s),billingModes:re(a),cadences:re(n)}}function Fe(){return{statuses:[],planTypes:[],billingModes:[],cadences:[]}}function Kt(e={}){return[{id:"status",getValue:He,activeValues:e.statuses||[]},{id:"planType",getValue:Ye,activeValues:e.planTypes||[]},{id:"billingMode",getValue:qe,activeValues:e.billingModes||[]},{id:"cadence",getValue:Ge,activeValues:e.cadences||[]}]}const Bt=[j.PAUSED,j.CANCELLED];function Wt({nextEventRange:e}={}){return[{id:"nextEvent",getValue:t=>Bt.includes(t==null?void 0:t.status)?null:Ne(t),dateRange:e}]}function zt({patientNameFor:e,patientEmailFor:t}={}){return[s=>(s==null?void 0:s.subscriptionTitle)||"",s=>(s==null?void 0:s.id)||"",s=>typeof e=="function"?e(s):"",s=>typeof t=="function"?t(s):""]}function Ht({searchTerm:e="",selection:t={},nextEventRange:s=null}={}){const a=Object.values(t).some(n=>Array.isArray(n)&&n.length>0);return!!(String(e).trim()||a||s!=null&&s.from)}function Yt(e){const t=(Array.isArray(e==null?void 0:e.productRefs)?e.productRefs:[]).map(s=>s==null?void 0:s.parentOrderId).find(Boolean);return(e==null?void 0:e.lastOrderId)||t||null}function Qe({patientNameFor:e,patientEmailFor:t,searchTerm:s="",onOpenPatient:a,patientHrefFor:n,onOpenOrder:u,canManageEnrollments:y=!1,onManageEnrollment:f}){return[{id:"item",header:"Item",sortKey:"item",minWidth:260,csvValue:i=>i.subscriptionTitle||"Subscription",renderCell:i=>l.jsxs("div",{className:"flex min-w-0 items-start gap-1.5",children:[l.jsx(Rt,{primary:i.subscriptionTitle||"Subscription",secondary:i.id,highlight:s}),Ke(i)?l.jsxs("span",{className:ye("teal","mt-0.5 shrink-0"),children:[l.jsx(ut,{className:"size-3","aria-hidden":"true"}),"Clinical review"]}):null]}),skeletonClassName:"w-40"},{id:"patient",header:"Patient",sortKey:"patient",minWidth:200,csvValue:i=>e(i),renderCell:i=>l.jsx(Pt,{label:e(i),sublabel:t(i),highlight:s,patientId:i.patientId||null,onOpenPatient:a,href:n==null?void 0:n(i.patientId)}),skeletonClassName:"w-36"},{id:"planType",header:"Type",sortKey:"planType",minWidth:130,csvValue:i=>X(i).label,hideOnMobile:!0,renderCell:i=>{const d=X(i);return l.jsx("span",{className:ye(d.tone),children:d.label})},skeletonClassName:"w-20 rounded-full"},{id:"cadence",header:"Cadence",sortKey:"cadence",minWidth:170,csvValue:i=>`${le(i)}, ${Ee(i)}`,hideOnTablet:!0,renderCell:i=>l.jsxs("div",{className:"min-w-0",children:[l.jsx("p",{className:"truncate text-sm text-content-secondary max-lg:text-2xs",children:le(i)}),l.jsx("p",{className:"truncate text-xs text-content-tertiary max-lg:text-3xs",children:Ee(i)})]}),skeletonClassName:"w-24"},{id:"amount",header:"Amount",sortKey:"amount",align:"right",minWidth:130,csvValue:i=>Number(i==null?void 0:i.priceCents)||0,hideOnMobile:!0,renderCell:i=>l.jsxs("div",{className:"min-w-0 text-right",children:[l.jsx("p",{className:"truncate text-sm font-medium tabular-nums text-content-primary max-lg:text-2xs",children:dt(i.priceCents,{cents:!0})}),l.jsx("p",{className:"truncate text-xs text-content-tertiary max-lg:text-3xs",children:"per cycle"})]}),skeletonClassName:"ml-auto w-16"},{id:"status",header:"Status",sortKey:"status",minWidth:140,csvValue:i=>oe(i).label,renderCell:i=>{const d=oe(i);return l.jsx("span",{className:ye(d.tone),children:d.label})},skeletonClassName:"w-20 rounded-full"},{id:"nextEvent",header:"Next event",sortKey:"nextEvent",minWidth:230,csvValue:i=>xe(i),hideOnTablet:!0,renderCell:i=>l.jsx("p",{className:"line-clamp-2 text-sm text-content-secondary max-lg:text-2xs",title:xe(i),children:xe(i)}),skeletonClassName:"w-28"},{id:"actions",header:l.jsx("span",{className:"sr-only",children:"Actions"}),align:"right",minWidth:72,fixedWidth:!0,renderCell:i=>{const d=Yt(i),R=y&&f?new Set(Nt(i)):new Set;return l.jsx("div",{className:"flex justify-end",children:l.jsx(kt,{actions:[i.patientId&&a?{id:"patient",label:"View patient",onSelect:()=>a(i.patientId)}:null,d&&u?{id:"order",label:"View originating order",onSelect:()=>u(d)}:null,R.has("pause")?{id:"pause",label:"Pause subscription",onSelect:()=>f(i,"pause")}:null,R.has("resume")?{id:"resume",label:"Resume subscription",onSelect:()=>f(i,"resume")}:null,R.has("cancel")?{id:"cancel",label:"Cancel subscription",onSelect:()=>f(i,"cancel"),danger:!0}:null],label:`Open actions for ${i.subscriptionTitle||"this recurring item"}`,borderless:!0})})},skeletonClassName:"ml-auto w-7 rounded-md"}]}function qt({patientNameFor:e}){return{item:t=>(t==null?void 0:t.subscriptionTitle)||"",patient:t=>e(t),planType:t=>X(t).label,cadence:t=>`${le(t)} ${Ee(t)}`,amount:t=>Number(t==null?void 0:t.priceCents)||0,status:t=>oe(t).label,nextEvent:t=>Gt(t)}}function Gt(e){const t=e==null?void 0:e.status;return t==="paused"||t==="cancelled"?null:Ne(e)}function Qt({patientNameFor:e,patientEmailFor:t}){return[...Qe({patientNameFor:e,patientEmailFor:t}),{id:"enrollmentId",exportHeader:"Enrollment ID",csvValue:s=>s.id},{id:"patientEmail",exportHeader:"Patient email",csvValue:s=>t(s)},{id:"clinicalReview",exportHeader:"Clinical review required",csvValue:s=>Ke(s)?"Yes":"No"}]}const Ze=7,$e={months:30,weeks:7,days:1,minutes:1/1440},Z=[j.ACTIVE,j.PAST_DUE,j.AWAITING_PAYMENT];function Zt(e){if((e==null?void 0:e.status)!==j.ACTIVE)return 0;const t=Number(e==null?void 0:e.priceCents)||0,s=Math.max(1,Math.floor(Number(e==null?void 0:e.periodCount)||1)),a=($e[e==null?void 0:e.periodUnit]??$e.months)*s;return a?t/a*30:0}function Ae(){return{activeCount:0,runRateCents:0,renewingSoon:0,pastDue:0,awaitingPayment:0}}function Xt(e=[],{now:t=Date.now()}={}){const s=t+Ze*24*60*60*1e3,a=Ae();
1return(Array.isArray(e)?e:[]).forEach(n=>{if((n==null?void 0:n.status)===j.ACTIVE){a.activeCount+=1,a.runRateCents+=Zt(n);const u=Ne(n);u&&u.getTime()<=s&&(a.renewingSoon+=1)}(n==null?void 0:n.status)===j.PAST_DUE&&(a.pastDue+=1),(n==null?void 0:n.status)===j.AWAITING_PAYMENT&&(a.awaitingPayment+=1)}),a}const Te=500;function Jt(e){return{id:e.id,...e.data()}}function es({clientId:e,childClientIds:t=[],enabled:s=!0}){const a=ue(e,t).join("|"),n=r.useMemo(()=>a?a.split("|"):[],[a]),u=s&&n.length>0,[y,f]=r.useState(Ae),[i,d]=r.useState(!!u),[R,S]=r.useState(null),[_,h]=r.useState(!1),[H,E]=r.useState(0);r.useEffect(()=>{if(!u){f(Ae()),d(!1),S(null),h(!1);return}d(!0),S(null),h(!1);const U=n.length===1?N("clientId","==",n[0]):N("clientId","in",n),m=new Map(Z.map(b=>[b,[]])),w=new Set,p=new Set;let C=null;const A=()=>{C&&(clearTimeout(C),C=null)},I=()=>{const b=new Map;m.forEach(x=>x.forEach(g=>b.set(g.id,g))),f(Xt([...b.values()])),h(w.size>0),p.size===Z.length&&d(!1)},T=Z.map(b=>Ie(W(z(B,"SubscriptionEnrollments"),U,N("status","==",b),ce("createdAt","desc"),ve(Te)),x=>{if(We(x)){C||(C=setTimeout(()=>{C=null,p.size!==Z.length&&(S(new ze("Could not reach the server to load recurring totals.")),d(!1))},Be));return}p.add(b),m.set(b,x.docs.map(Jt)),x.docs.length>=Te?w.add(b):w.delete(b),p.size===Z.length&&(A(),S(null)),I()},x=>{console.error(`Error listening to ${b} subscription enrollment totals:`,x),A(),S(x),d(!1)}));return()=>{A(),T.forEach(b=>b())}},[u,n,H]);const O=r.useCallback(()=>E(U=>U+1),[]);return{summary:y,loading:i,error:R,retry:O,truncated:_}}function Ks(){const{userDoc:e,clientData:t,loading:s}=pt(),{branding:a}=ft(),n=(a==null?void 0:a.accentColor)||mt,[u,y]=bt(),{openPatientProfile:f,buildPatientProfileHref:i}=Et(),{confirmAction:d,confirmDialog:R}=ht({accentColor:n}),{manageAllowed:S}=vt(e==null?void 0:e.clientId),_=Se(e==null?void 0:e.userType,"Client Admin")||Se(e==null?void 0:e.userType,"Provider Network Admin")||Se(e==null?void 0:e.userType,"Client Staff")&&S,h=(e==null?void 0:e.clientId)||"",[H,E]=r.useState([]),[O,U]=r.useState({}),[m,w]=r.useState(""),[p,C]=r.useState(Fe),[A,I]=r.useState(void 0),[T,b]=r.useState({key:null,direction:"asc"}),x=gt(t);r.useEffect(()=>{if(!x||!h){E([]);return}return Ie(W(z(B,"Clients"),N("parentClientId","==",h)),c=>E(c.docs.map(o=>o.id)),c=>{console.error("Error loading child clients for subscriptions:",c),E([])})},[x,h]);const g=H.join("|"),v=r.useMemo(()=>g?g.split("|"):[],[g]),{enrollments:V,loading:M,loadingMore:D,hasMore:P,loadMore:F,error:Re,retry:Xe,fetchAllRows:Je}=_t({clientId:h,childClientIds:v,enabled:!s&&!!h}),{summary:k,loading:de,error:et,retry:pe,truncated:tt}=es({clientId:h,childClientIds:v,enabled:!s&&!!h}),fe=ue(h,v).join("|"),Y=r.useMemo(()=>fe?fe.split("|"):[],[fe]),J=Math.max(0,1+v.length-Y.length);r.useEffect(()=>{if(s||Y.length===0)return;let c=!1;return Promise.all(Y.map(o=>Me(W(z(B,"Users"),N("clientId","==",o),N("userType","in",["Patient","Standard User"]))))).then(o=>{if(c)return;const $={};o.forEach(ee=>{ee.docs.forEach(Ue=>{const te=Ue.data();$[Ue.id]={name:`${te.firstName||""} ${te.lastName||""}`.trim()||te.displayName||"Unknown patient",email:te.email||""}})}),U($)}).catch(o=>{console.error("Error loading patients for subscriptions:",o)}),()=>{c=!0}},[s,Y]);const L=r.useCallback(c=>{var o;return((o=O[c==null?void 0:c.patientId])==null?void 0:o.name)||"Unknown patient"},[O]),K=r.useCallback(c=>{var o;return((o=O[c==null?void 0:c.patientId])==null?void 0:o.email)||""},[O]),Pe=r.useCallback(c=>{const o=new URLSearchParams(u);o.set("order",c),y(o)},[u,y]),ke=r.useCallback(async(c,o)=>{const $={pause:{title:"Pause this subscription?",description:"Billing stops until it is resumed.",confirmLabel:"Pause"},resume:{title:"Resume this subscription?",description:"Billing restarts on a fresh cycle starting today.",confirmLabel:"Resume"},cancel:{title:"Cancel this subscription?",description:"This ends the subscription and stops billing. It cannot be resumed afterward.",confirmLabel:"Cancel subscription",tone:"destructive"}}[o];if(!$||!await d($))return;const ee=await Lt({enrollmentId:c.id,action:o});if(!ee.ok){De.error(ee.error||`Unable to ${o}
1 this subscription.`);return}De.success(o==="cancel"?"Subscription cancelled.":`Subscription ${o}d.`)},[d]),q=r.useMemo(()=>$t(V),[V]),Le=r.useMemo(()=>zt({patientNameFor:L,patientEmailFor:K}),[L,K]),je=r.useMemo(()=>qt({patientNameFor:L}),[L]),me=r.useCallback(c=>At(c,{searchTerm:m,searchFields:Le,filters:Kt(p),dateFilters:Wt({nextEventRange:A}),sortKey:T.key,sortDirection:T.direction,sortAccessors:je}),[A,Le,m,p,je,T]),{sortedRows:Oe,filteredCount:st,totalCount:it}=r.useMemo(()=>me(V),[V,me]),G=r.useCallback((c,o)=>{C($=>({...$,[c]:o}))},[]),Ve=r.useCallback(()=>{w(""),C(Fe()),I(void 0)},[]),at=r.useCallback(c=>{b(o=>o.key!==c?{key:c,direction:"asc"}:o.direction==="asc"?{key:c,direction:"desc"}:{key:null,direction:"asc"})},[]),be=r.useMemo(()=>[se({id:"status",filters:q.statuses,activeFilters:p.statuses,onFilterChange:c=>G("statuses",c),defaultLabel:"All statuses"}),se({id:"planType",filters:q.planTypes,activeFilters:p.planTypes,onFilterChange:c=>G("planTypes",c),defaultLabel:"All types"}),se({id:"billingMode",filters:q.billingModes,activeFilters:p.billingModes,onFilterChange:c=>G("billingModes",c),defaultLabel:"All billing"}),se({id:"cadence",filters:q.cadences,activeFilters:p.cadences,onFilterChange:c=>G("cadences",c),defaultLabel:"All cadences"}),Tt({id:"nextEvent",label:"Next event",date:A,setDate:I})],[q,A,p,G]),he=r.useMemo(()=>({value:m,onChange:w,placeholder:"Search by patient, item, or enrollment IDâ¦",testId:"input-client-subscriptions-search"}),[m]),_e=Ht({searchTerm:m,selection:p,nextEventRange:A}),rt=r.useMemo(()=>Qe({patientNameFor:L,patientEmailFor:K,searchTerm:m,onOpenPatient:f,patientHrefFor:i,onOpenOrder:Pe,canManageEnrollments:_,onManageEnrollment:_?ke:void 0}),[L,K,m,f,i,Pe,_,ke]),nt=r.useMemo(()=>Qt({patientNameFor:L,patientEmailFor:K}),[L,K]),Q=It({error:Re,filters:be,search:he,hasActiveFilters:_e}),ct=Re&&Oe.length>0?"Recurring items could not be refreshed. What you see may be out of date.":"",ge=et?"Recurring totals could not be loaded.":"",ot=`Across ${k.activeCount} active plan${k.activeCount===1?"":"s"}, normalised monthly`+(tt?`. Counting the newest ${Te} per status, so this understates.`:""),lt=l.jsx(yt,{reason:Q,title:Q==="empty"?"No recurring items yet":void 0,description:Q==="empty"?"Subscriptions and programs appear here once a patient enrolls at checkout.":void 0,filterSummary:Mt({filters:be,search:he}),action:Q==="filtered"?{onClick:Ve}:Q==="error"?{onClick:Xe}:null,testId:"empty-client-subscriptions"});return l.jsxs("div",{className:"app-page-shell space-y-6 max-lg:space-y-3",children:[R,l.jsx(St,{headerId:"subscriptions-client",testId:"section-client-subscriptions-header"}),l.jsxs("div",{className:"grid grid-cols-3 gap-4 max-lg:grid-cols-1 max-lg:gap-2",children:[l.jsx(Ce,{label:"Recurring revenue",unit:"currency",card:{value:k.runRateCents},sublabel:ot,tooltip:"Every active plan's price converted to a 30-day equivalent and summed, across the whole client rather than the rows loaded below. It is a run rate, not billed revenue.",loading:de,error:ge,onRetry:pe}),l.jsx(Ce,{label:`Renewing in ${Ze} days`,card:{value:k.renewingSoon},sublabel:"Active plans whose next run date falls inside the window",loading:de,error:ge,onRetry:pe}),l.jsx(Ce,{label:"Needs attention",card:{value:k.pastDue+k.awaitingPayment},polarity:"inverse",sublabel:`${k.pastDue} payment${k.pastDue===1?"":"s"} failed · ${k.awaitingPayment} awaiting payment`,loading:de,error:ge,onRetry:pe})]}),l.jsx(wt,{id:"client-subscriptions",title:"Recurring items",icon:Ct,accentColor:n,className:"min-w-0",loading:M,error:ct,filteredCount:st,totalCount:it,search:he,filters:be,hasActiveFilters:_e,onClearFilters:Ve,headerExtra:J>0?l.jsx("p",{className:"text-xs text-amber-600 dark:text-amber-300",children:`Showing ${Y.length} of ${1+v.length} clients. Firestore limits this query to 30, so ${J} affiliated client${J===1?"":"s"} ${J===1?"is":"are"} not included.`}):null,columns:rt,rows:Oe,rowKey:"id",rowClick:c=>{c!=null&&c.patientId&&f(c.patientId)},rowKeyboardAccessible:!0,rowAriaLabel:c=>`Open ${L(c)} for ${(c==null?void 0:c.subscriptionTitle)||"this recurring item"}`,rowTestId:c=>`row-client-subscription-${c==null?void 0:c.id}`,sortKey:T.key,sortDirection:T.direction,onSort:at,csvExport:{feature:"client-subscriptions",tenantSlug:a==null?void 0:a.businessName,columns:nt,view:{getRows:async()=>me(await Je()).sortedRows}},compactDensity:!0,virtualized:!0,stretchToMaxHeight:!0,loadingMore:D,loadingMoreLabel:"Loading more recurring itemsâ¦",onEndReached:()=>{P&&!D&&F()},tableTestId:"table-client-subscriptions",tableLabel:"Recurring items table",emptyMessage:lt})]})}
1export{Ks 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.