PageSourceSearch

https://plant4growthuk-production-a1cd.up.railway.app/static/js/596.ebc09489.chunk.js

js plant4growthuk-production-a1cd.up.railway.app collected 2026-10-03 12:14:12 UTC 57,115 bytes, 2 lines download raw bytes

1"use strict";(self.webpackChunkfrontend=self.webpackChunkfrontend||[]).push([[596],{596(e,s,t){t.r(s),t.d(s,{AdminPaymentsPage:()=>H,default:()=>X});var a=t(9379),l=t(5043),n=t(9970),i=t(4980),r=t(1140),c=t(3390),d=t(2264),o=t(9938),x=t(5949),m=t(1654),h=t(4943),u=t(7819),p=t(2054),j=t(2024),N=t(8646),b=t(9463),v=t(8326),f=t(5088),g=t(6376),y=t(3062),w=t(7104),_=t(764),A=t(4651),k=t(5087),D=t(1680),R=t(3773),S=t(7147),F=t(6898),C=t(516),B=t(8693),E=t(9292),T=t(9855),P=t(4919),Z=t(614),W=t(6328),z=t(1094),O=t(7879),L=t(7734),I=t(74),V=t(9808),$=t(2185),U=t(6026),M=t(2291),G=t(877),K=t(579);const J=e=>"paid"===e?(0,K.jsxs)(x.E,{className:"bg-emerald-100 text-emerald-700",children:[(0,K.jsx)(p.A,{className:"w-3 h-3 mr-1"}),"Paid"]}):"pending"===e?(0,K.jsxs)(x.E,{className:"bg-yellow-100 text-yellow-700",children:[(0,K.jsx)(f.A,{className:"w-3 h-3 mr-1"}),"Pending"]}):"refunded"===e?(0,K.jsxs)(x.E,{className:"bg-red-100 text-red-700",children:[(0,K.jsx)(u.A,{className:"w-3 h-3 mr-1"}),"Refunded"]}):"partially_refunded"===e?(0,K.jsxs)(x.E,{className:"bg-orange-100 text-orange-700",children:[(0,K.jsx)(u.A,{className:"w-3 h-3 mr-1"}),"Part. Refunded"]}):(0,K.jsx)(x.E,{className:"bg-slate-100 text-slate-700",children:e}),q=e=>{let{course:s,onClose:t,onSave:n}=e;const[r,x]=(0,l.useState)({price:s.price||0,vat_rate:s.vat_rate||20,subscription_enabled:s.subscription_enabled||!1,subscription_price_monthly:s.subscription_price_monthly||0,subscription_price_yearly:s.subscription_price_yearly||0}),[h,u]=(0,l.useState)(!1),p=e=>(e+e*(r.vat_rate/100)).toFixed(2);return(0,K.jsx)("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:(0,K.jsxs)("div",{className:"bg-white rounded-2xl max-w-lg w-full shadow-xl max-h-[90vh] overflow-y-auto",children:[(0,K.jsxs)("div",{className:"p-6 border-b border-slate-100 sticky top-0 bg-white",children:[(0,K.jsxs)("div",{className:"flex items-center justify-between",children:[(0,K.jsx)("h2",{className:"text-xl font-bold text-[#0D1B2A]",children:"Edit Course Pricing"}),(0,K.jsx)("button",{onClick:t,className:"text-slate-400 hover:text-slate-600",children:(0,K.jsx)(Z.A,{className:"w-5 h-5"})})]}),(0,K.jsx)("p",{className:"text-slate-500 mt-1",children:s.title})]}),(0,K.jsxs)("div",{className:"p-6 space-y-6",children:[(0,K.jsxs)("div",{className:"space-y-2",children:[(0,K.jsxs)(o.J,{className:"flex items-center gap-2",children:[(0,K.jsx)(S.A,{className:"w-4 h-4 text-slate-500"}),"VAT Rate (%)"]}),(0,K.jsx)(d.p,{type:"number",step:"0.1",value:r.vat_rate,onChange:e=>x((0,a.A)((0,a.A)({},r),{},{vat_rate:parseFloat(e.target.value)||0})),className:"w-full"}),(0,K.jsx)("p",{className:"text-xs text-slate-500",children:"UK standard rate is 20%"})]}),(0,K.jsxs)("div",{className:"space-y-2",children:[(0,K.jsxs)(o.J,{className:"flex items-center gap-2",children:[(0,K.jsx)(y.A,{className:"w-4 h-4 text-slate-500"}),"One-Time Price (\xa3)"]}),(0,K.jsx)(d.p,{type:"number",step:"0.01",value:r.price,onChange:e=>x((0,a.A)((0,a.A)({},r),{},{price:parseFloat(e.target.value)||0})),className:"w-full"}),r.price>0&&(0,K.jsxs)("p",{className:"text-xs text-slate-500",children:["With VAT: ",(0,K.jsxs)("span",{className:"font-medium",children:["\xa3",p(r.price)]})]})]}),(0,K.jsxs)("div",{className:"flex items-center justify-between p-4 bg-slate-50 rounded-xl",children:[(0,K.jsxs)("div",{children:[(0,K.jsx)("p",{className:"font-medium text-[#0D1B2A]",children:"Enable Subscriptions"}),(0,K.jsx)("p",{className:"text-xs text-slate-500",children:"Allow monthly/yearly payment options"})]}),(0,K.jsx)(m.d,{checked:r.subscription_enabled,onCheckedChange:e=>x((0,a.A)((0,a.A)({},r),{},{subscription_enabled:e}))})]}),r.subscription_enabled&&(0,K.jsxs)("div",{className:"space-y-4 p-4 border border-slate-200 rounded-xl",children:[(0,K.jsx)("p",{className:"font-medium text-[#0D1B2A]",children:"Subscription Pricing"}),(0,K.jsxs)("div",{className:"space-y-2",children:[(0,K.jsx)(o.J,{children:"Monthly Price (\xa3)"}),(0,K.jsx)(d.p,{type:"number",step:"0.01",value:r.subscription_price_monthly,onChange:e=>x((0,a.A)((0,a.A)({},r),{},{subscription_price_monthly:parseFloat(e.target.value)||0}))}),r.subscription_price_monthly>0&&(0,K.jsxs)("p",{className:"text-xs text-slate-500",children:["With VAT: ",(0,K.jsxs)("span",{className:"font-medium",children:["\xa3",p(r.subscription_price_monthly),"/mo"]})]})]}),(0,K.jsxs)("div",{className:"space-y-2",children:[(0,K.jsx)(o.J,{children:"Yearly Price (\xa3)"}),(0,K.jsx)(d.p,{type:"number",step:"0.01",value:r.subscription_price_yearly,onChange:e=>x((0,a.A)((0,a.A)({},r),{},{subscription_price_yearly:parseFloat(e.target.value)||0}))}),r.subscription_price_yearly>0&&(0,K.jsxs)("p",{className:"text-xs text-slate-500",children:["With VAT: ",(0,K.jsxs)("span",{className:"font-medium",children:["\xa3",p(r.subscription_price_yearly),"/yr"]})]})]})]}),(0,K.jsxs)(c.$,{onClick:async()=>{u(!0);try{await i.a5.updateCoursePricing(s.course_id,r),W.oR.success("Pricing updated successfully"),n(),t()}catch(e){W.oR.error("Failed to update pricing")}finally{u(!1)}},disabled:h,className:"w-full bg-[#0D1B2A] hover:bg-[#1B3A4B]",children:[h?(0,K.jsx)(j.A,{className:"w-4 h-4 mr-2 animate-spin"}):(0,K.jsx)(B.A,{className:"w-4 h-4 mr-2"}),"Save Pricing"]})]})]})})},Y=e=>{var s,t,a,n,r,o,m,h,p,N,b,v,f,g,y,w,A,k,D,S,F,C;let{id:B,onClose:E,onRefunded:T,onChanged:P}=e;const[z,O]=(0,l.useState)(null),[L,I]=(0,l.useState)(!0),[V,$]=(0,l.useState)(""),[U,M]=(0,l.useState)("requested_by_customer"),[G,q]=(0,l.useState)(!1),[Y,Q]=(0,l.useState)(!1),[H,X]=(0,l.useState)(""),ee=()=>(I(!0),i.a5.getPaymentDetail(B).then(e=>O(e.data)).catch(()=>W.oR.error("Failed to load transaction details")).finally(()=>I(!1)));(0,l.useEffect)(()=>{ee()},[B]);const se=async(e,s,t)=>{if(s){X(e);try{t?await i.a5.unmarkFake(e,s):await i.a5.markFake(e,s),await ee(),null===P||void 0===P||P()}catch(a){W.oR.error("Failed to update test flag")}finally{X("")}}};return(0,K.jsx)("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:(0,K.jsxs)("div",{className:"bg-white rounded-2xl max-w-2xl w-full shadow-xl max-h-[90vh] overflow-y-auto",children:[(0,K.jsxs)("div",{className:"p-6 border-b border-slate-100 sticky top-0 bg-white",children:[(0,K.jsxs)("div",{className:"flex items-center justify-between",children:[(0,K.jsx)("h2",{className:"text-xl font-bold text-[#0D1B2A]",children:"Transaction Detail"}),(0,K.jsx)("button",{onClick:E,className:"text-slate-400 hover:text-slate-600",children:(0,K.jsx)(Z.A,{className:"w-5 h-5"})})]}),z&&(0,K.jsx)("p",{className:"text-slate-500 mt-1 text-sm font-mono truncate",children:z.id})]}),(0,K.jsx)("div",{className:"p-6 space-y-6",children:L?(0,K.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,K.jsx)(j.A,{className:"w-8 h-8 text-[#41EAD4] animate-spin"})}):z?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)("div",{children:[(0,K.jsx)("h3",{className:"text-sm font-semibold text-slate-400 uppercase tracking-wide mb-2",children:"Customer"}),(0,K.jsxs)("div",{className:"bg-slate-50 rounded-xl p-4 space-y-1",children:[(0,K.jsx)("p",{className:"font-medium text-[#0D1B2A]",children:null===(s=z.customer)||void 0===s?void 0:s.name}),(0,K.jsx)("p",{className:"text-sm text-slate-500",children:null===(t=z.customer)||void 0===t?void 0:t.email}),(null===(a=z.customer)||void 0===a?void 0:a.stripe_customer_id)&&(0,K.jsx)("p",{className:"text-xs text-slate-400 font-mono",children:z.customer.stripe_customer_id})]})]}),(0,K.jsxs)("div",{children:[(0,K.jsx)("h3",{className:"text-sm font-semibold text-slate-400 uppercase tracking-wide mb-2",children:"Item"}),(0,K.jsxs)("div",{className:"bg-slate-50 rounded-xl p-4 space-y-2",children:[(0,K.jsx)("p",{className:"font-medium text-[#0D1B2A]",children:null===(n=z.item)||void 0===n?void 0:n.title}),(0,K.jsxs)("div",{className:"flex gap-2 items-center flex-wrap",children:[(null===(r=z.item)||void 0===r?void 0:r.type)&&(0,K.jsx)(x.E,{variant:"outline",className:"capitalize",children:z.item.type}),z.domain&&(0,K.jsx)(x.E,{variant:"outline",className:"capitalize",children:z.domain}),(0,K.jsx)("span",{className:"text-xs text-slate-400 font-mono",children:J(z.payment_status)})]})]})]}),(0,K.jsxs)("div",{children:[(0,K.jsx)("h3",{className:"text-sm font-semibold text-slate-400 uppercase tracking-wide mb-2",children:"Breakdown"}),(0,K.jsxs)("div",{className:"bg-slate-50 rounded-xl p-4 space-y-2 text-sm",children:[(0,K.jsxs)("div",{className:"flex justify-between",children:[(0,K.jsx)("span",{className:"text-slate-500",children:"Base"}),(0,K.jsxs)("span",{className:"font-medium",children:["\xa3",(null!==(o=null===(m=z.breakdown)||void 0===m?void 0:m.base)&&void 0!==o?o:0).toFixed(2)]})]}),(0,K.jsxs)("div",{className:"flex justify-between",children:[(0,K.jsx)("span",{className:"text-slate-500",children:"VAT"}),(0,K.jsxs)("span",{className:"font-medium",children:["\xa3",(null!==(h=null===(p=z.breakdown)||void 0===p?void 0:p.vat)&&void 0!==h?h:0).toFixed(2)]})]}),(0,K.jsxs)("div",{className:"flex justify-between border-t border-slate-200 pt-2 font-semibold",children:[(0,K.jsx)("span",{className:"text-[#0D1B2A]",children:"Total"}),(0,K.jsxs)("span",{className:"text-[#0D1B2A]",children:["\xa3",(null!==(N=null===(b=z.breakdown)||void 0===b?void 0:b.total)&&void 0!==N?N:0).toFixed(2)]})]})]})]}),((null===(v=z.stripe)||void 0===v?void 0:v.payment_url)||(null===(f=z.stripe)||void 0===f?void 0:f.customer_url)||(null===(g=z.stripe)||void 0===g?void 0:g.subscription_url))&&(0,K.jsxs)("div",{children:[(0,K.jsx)("h3",{className:"text-sm font-semibold text-slate-400 uppercase tracking-wide mb-2",children:"Stripe Links"}),(0,K.jsxs)("div",{className:"flex flex-wrap gap-2",children:[z.stripe.payment_url&&(0,K.jsxs)("a",{href:z.stripe.payment_url,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-sm px-3 py-1.5 rounded-lg bg-slate-100 hover:bg-slate-200 text-[#0D1B2A] transition-colors",children:[(0,K.jsx)(_.A,{className:"w-3 h-3"})," Payment Intent"]}),z.stripe.customer_url&&(0,K.jsxs)("a",{href:z.stripe.customer_url,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-sm px-3 py-1.5 rounded-lg bg-slate-100 hover:bg-slate-200 text-[#0D1B2A] transition-colors",children:[(0,K.jsx)(_.A,{className:"w-3 h-3"})," Customer"]}),z.stripe.subscription_url&&(0,K.jsxs)("a",{href:z.stripe.subscription_url,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-sm px-3 py-1.5 rounded-lg bg-slate-100 hover:bg-slate-200 text-[#0D1B2A] transition-colors",children:[(0,K.jsx)(_.A,{className:"w-3 h-3"})," Subscription"]})]})]}),z.timeline&&z.timeline.length>0&&(0,K.jsxs)("div",{children:[(0,K.jsx)("h3",{className:"text-sm font-semibold text-slate-400 uppercase tracking-wide mb-2",children:"Status Timeline"}),(0,K.jsx)("div",{className:"space-y-2",children:z.timeline.map((e,s)=>(0,K.jsxs)("div",{className:"flex items-start gap-3 text-sm",children:[(0,K.jsx)("div",{className:"w-2 h-2 rounded-full bg-[#41EAD4] mt-1.5 shrink-0"}),(0,K.jsxs)("div",{children:[(0,K.jsx)("span",{className:"font-medium text-[#0D1B2A] capitalize",children:e.state}),null!=e.amount&&(0,K.jsxs)("span",{className:"text-slate-500 ml-2",children:["\xa3",Number(e.amount).toFixed(2)]}),(0,K.jsx)("p",{className:"text-xs text-slate-400",children:new Date(e.at).toLocaleStr
1ing("en-GB")})]})]},s))})]}),z.refunds&&z.refunds.length>0&&(0,K.jsxs)("div",{children:[(0,K.jsx)("h3",{className:"text-sm font-semibold text-slate-400 uppercase tracking-wide mb-2",children:"Refunds"}),(0,K.jsx)("div",{className:"space-y-2",children:z.refunds.map((e,s)=>{var t;return(0,K.jsxs)("div",{className:"flex justify-between items-center text-sm bg-red-50 rounded-lg p-3",children:[(0,K.jsxs)("div",{children:[(0,K.jsxs)("p",{className:"font-medium text-red-700",children:["\xa3",Number(e.amount).toFixed(2)]}),(0,K.jsx)("p",{className:"text-xs text-slate-500",children:new Date(e.created_at).toLocaleString("en-GB")})]}),(0,K.jsx)(x.E,{className:"bg-red-100 text-red-700",children:"Refunded"})]},null!==(t=e.id)&&void 0!==t?t:s)})})]}),z.webhook_events&&z.webhook_events.length>0&&(0,K.jsxs)("div",{children:[(0,K.jsx)("h3",{className:"text-sm font-semibold text-slate-400 uppercase tracking-wide mb-2",children:"Webhook Events"}),(0,K.jsx)("div",{className:"space-y-1",children:z.webhook_events.map((e,s)=>{var t;return(0,K.jsxs)("div",{className:"flex items-center justify-between text-xs bg-slate-50 rounded-lg p-2 gap-2",children:[(0,K.jsx)("span",{className:"font-mono text-slate-600 truncate",children:e.type}),(0,K.jsx)("span",{className:"text-slate-400 font-mono truncate",children:e.event_id})]},null!==(t=e.event_id)&&void 0!==t?t:s)})})]}),(0,K.jsxs)("div",{className:"border border-slate-200 rounded-xl p-4 space-y-3",children:[(0,K.jsxs)("div",{className:"flex items-center justify-between",children:[(0,K.jsxs)("h3",{className:"text-sm font-semibold text-[#0D1B2A] flex items-center gap-1.5",children:[(0,K.jsx)(R.A,{className:"w-4 h-4 text-amber-600"})," Test / Fake"]}),z.is_fake&&(0,K.jsx)(x.E,{className:"bg-amber-100 text-amber-700",children:"Excluded from totals"})]}),(0,K.jsx)("p",{className:"text-xs text-slate-500",children:"Flagged items are hidden from the list and left out of revenue totals."}),(0,K.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,K.jsxs)(c.$,{variant:"outline",size:"sm",disabled:"transaction"===H,onClick:()=>{var e;return se("transaction",z.id,null===(e=z.fake)||void 0===e?void 0:e.transaction)},className:null!==(y=z.fake)&&void 0!==y&&y.transaction?"border-amber-400 text-amber-700 bg-amber-50":"",children:["transaction"===H&&(0,K.jsx)(j.A,{className:"w-3 h-3 mr-1 animate-spin"}),null!==(w=z.fake)&&void 0!==w&&w.transaction?"Unmark this transaction":"Mark this transaction"]}),(null===(A=z.customer)||void 0===A?void 0:A.email)&&"Unknown"!==z.customer.email&&(0,K.jsxs)(c.$,{variant:"outline",size:"sm",disabled:"email"===H,onClick:()=>{var e;return se("email",z.customer.email,null===(e=z.fake)||void 0===e?void 0:e.email)},className:null!==(k=z.fake)&&void 0!==k&&k.email?"border-amber-400 text-amber-700 bg-amber-50":"",children:["email"===H&&(0,K.jsx)(j.A,{className:"w-3 h-3 mr-1 animate-spin"}),null!==(D=z.fake)&&void 0!==D&&D.email?"Unflag email":"Flag all from this email"]}),(null===(S=z.customer)||void 0===S?void 0:S.user_id)&&(0,K.jsxs)(c.$,{variant:"outline",size:"sm",disabled:"user"===H,onClick:()=>{var e;return se("user",z.customer.user_id,null===(e=z.fake)||void 0===e?void 0:e.user)},className:null!==(F=z.fake)&&void 0!==F&&F.user?"border-amber-400 text-amber-700 bg-amber-50":"",children:["user"===H&&(0,K.jsx)(j.A,{className:"w-3 h-3 mr-1 animate-spin"}),null!==(C=z.fake)&&void 0!==C&&C.user?"Unflag user account":"Flag user account"]})]})]}),(0,K.jsxs)("div",{className:"border border-slate-200 rounded-xl p-4 space-y-4",children:[(0,K.jsx)("h3",{className:"text-sm font-semibold text-[#0D1B2A]",children:"Issue Refund"}),(0,K.jsxs)("div",{className:"flex gap-3 flex-wrap",children:[(0,K.jsxs)("div",{className:"flex-1 min-w-[140px]",children:[(0,K.jsx)("label",{className:"text-xs text-slate-500 mb-1 block",children:"Amount (\xa3) \u2014 blank for full refund"}),(0,K.jsx)(d.p,{type:"number",step:"0.01",min:"0",placeholder:"Leave blank for full",value:V,onChange:e=>$(e.target.value)})]}),(0,K.jsxs)("div",{className:"flex-1 min-w-[160px]",children:[(0,K.jsx)("label",{className:"text-xs text-slate-500 mb-1 block",children:"Reason"}),(0,K.jsxs)("select",{value:U,onChange:e=>M(e.target.value),className:"w-full border border-slate-200 rounded-lg px-3 py-2 text-sm text-[#0D1B2A] focus:outline-none focus:ring-2 focus:ring-[#41EAD4]",children:[(0,K.jsx)("option",{value:"requested_by_customer",children:"Requested by customer"}),(0,K.jsx)("option",{value:"duplicate",children:"Duplicate"}),(0,K.jsx)("option",{value:"fraudulent",children:"Fraudulent"})]})]})]}),Y&&(0,K.jsx)("p",{className:"text-xs text-blue-600",children:"Refund initiated \u2014 access updates after Stripe confirms (webhook-reconciled)."}),(0,K.jsxs)(c.$,{onClick:async()=>{const e=V.trim(),s=""===e?void 0:parseFloat(e);
1if(void 0!==s&&(isNaN(s)||s<=0))return void W.oR.error("Enter a valid positive amount, or leave blank for a full refund");if(window.confirm(void 0!==s?"Issue a partial refund of \xa3".concat(s.toFixed(2),"? This cannot be undone."):"Issue a FULL refund? This cannot be undone.")){q(!0);try{const e={reason:U};void 0!==s&&(e.amount=s),await i.a5.refundPayment(B,e),W.oR.success("Refund initiated \u2014 access updates after Stripe confirms"),Q(!0),T()}catch(t){W.oR.error("Failed to issue refund")}finally{q(!1)}}},disabled:G,className:"bg-red-600 hover:bg-red-700 text-white",children:[G?(0,K.jsx)(j.A,{className:"w-4 h-4 mr-2 animate-spin"}):(0,K.jsx)(u.A,{className:"w-4 h-4 mr-2"}),"Issue Refund"]})]})]}):(0,K.jsx)("p",{className:"text-center text-slate-500 py-8",children:"Failed to load details."})})]})})},Q=[{key:"transactions",label:"Transactions"},{key:"subscriptions",label:"Subscriptions"},{key:"reconciliation",label:"Reconciliation"},{key:"pricing",label:"Course Pricing"},{key:"vat",label:"VAT Report"},{key:"analytics",label:"Analytics"}],H=()=>{var e,s,t,o,m,y,_,S,B,Z,H,X,ee,se,te,ae,le,ne,ie,re,ce,de,oe,xe,me,he,ue,pe,je,Ne,be,ve,fe,ge,ye,we,_e,Ae,ke,De;const[Re,Se]=(0,l.useState)(!0),[Fe,Ce]=(0,l.useState)("transactions"),[Be,Ee]=(0,l.useState)([]),[Te,Pe]=(0,l.useState)(null),[Ze,We]=(0,l.useState)(null),[ze,Oe]=(0,l.useState)({status:"",domain:"",search:"",date_from:"",date_to:""}),[Le,Ie]=(0,l.useState)(1),[Ve,$e]=(0,l.useState)(!1),[Ue,Me]=(0,l.useState)({items:[],total:0,summary:{}}),[Ge,Ke]=(0,l.useState)(0),[Je,qe]=(0,l.useState)(!1),[Ye,Qe]=(0,l.useState)(null),[He,Xe]=(0,l.useState)({items:[],total:0}),[es,ss]=(0,l.useState)({status:"",domain:""}),[ts,as]=(0,l.useState)([]),[ls,ns]=(0,l.useState)(!1),[is,rs]=(0,l.useState)(null),[cs,ds]=(0,l.useState)(null),[os,xs]=(0,l.useState)(!1),[ms,hs]=(0,l.useState)(null),[us,ps]=(0,l.useState)(!1),[js,Ns]=(0,l.useState)({date_from:"",date_to:""}),bs=async()=>{try{const[e,s]=await Promise.all([i.BP.getAll(),i.a5.getVATReport()]);Ee(e.data),Pe(s.data)}catch(e){W.oR.error("Failed to load payment data")}finally{Se(!1)}};(0,l.useEffect)(()=>{bs()},[]),(0,l.useEffect)(()=>{if("transactions"!==Fe)return;qe(!0);const e=Object.fromEntries(Object.entries((0,a.A)((0,a.A)({},ze),{},{page:Le,page_size:25})).filter(e=>{let[,s]=e;return""!==s}));Ve&&(e.include_fake=!0),i.a5.listPayments(e).then(e=>Me(e.data)).catch(()=>W.oR.error("Failed to load transactions")).finally(()=>qe(!1))},[Fe,ze,Le,Ve,Ge]),(0,l.useEffect)(()=>{"transactions"===Fe&&i.a5.getArrears().then(e=>Xe(e.data)).catch(()=>{})},[Fe,Ge]);const vs=()=>{ns(!0);const e=Object.fromEntries(Object.entries(es).filter(e=>{let[,s]=e;return""!==s}));i.a5.listSubscriptions(e).then(e=>{var s,t;return as(null!==(s=null===(t=e.data)||void 0===t?void 0:t.items)&&void 0!==s?s:[])}).catch(()=>W.oR.error("Failed to load subscriptions")).finally(()=>ns(!1))};(0,l.useEffect)(()=>{"subscriptions"===Fe&&vs()},[Fe,es]),(0,l.useEffect)(()=>{"reconciliation"===Fe&&(xs(!0),i.a5.getReconciliation().then(e=>ds(e.data)).catch(()=>W.oR.error("Failed to load reconciliation data")).finally(()=>xs(!1)))},[Fe]),(0,l.useEffect)(()=>{if("analytics"!==Fe)return;ps(!0);const e=Object.fromEntries(Object.entries(js).filter(e=>{let[,s]=e;return""!==s}));i.a5.getAnalytics(e).then(e=>hs(e.data)).catch(()=>W.oR.error("Failed to load analytics data")).finally(()=>ps(!1))},[Fe,js]);const fs=(e,s)=>{Oe(t=>(0,a.A)((0,a.A)({},t),{},{[e]:s})),Ie(1)};return Re?(0,K.jsx)(n.NI,{children:(0,K.jsx)("div",{className:"flex items-center justify-center h-64",children:(0,K.jsx)(j.A,{className:"w-8 h-8 text-[#41EAD4] animate-spin"})})}):(0,K.jsx)(n.NI,{children:(0,K.jsxs)("div",{className:"space-y-6","data-testid":"admin-payments-page",children:[(0,K.jsxs)("div",{children:[(0,K.jsx)("h1",{className:"text-2xl font-bold text-[#0D1B2A] mb-2",children:"Payment Management"}),(0,K.jsx)("p",{className:"text-slate-500",children:"Manage course pricing, VAT, and view transactions"})]}),(0,K.jsx)("div",{className:"flex gap-2 border-b border-slate-200 overflow-x-auto",children:Q.map(e=>{let{key:s,label:t}=e;return(0,K.jsx)("button",{onClick:()=>Ce(s),className:"px-4 py-2 font-medium transition-colors whitespace-nowrap ".concat(Fe===s?"text-[#0D1B2A] border-b-2 border-[#41EAD4]":"text-slate-500 hover:text-slate-700"),
1children:t},s)})}),"transactions"===Fe&&(0,K.jsxs)("div",{className:"space-y-4",children:[Ue.summary&&Object.keys(Ue.summary).length>0&&(0,K.jsxs)("div",{className:"grid sm:grid-cols-2 lg:grid-cols-4 gap-4",children:[(0,K.jsx)(r.Zp,{className:"border-slate-100",children:(0,K.jsx)(r.Wu,{className:"p-4",children:(0,K.jsxs)("div",{className:"flex items-center gap-3",children:[(0,K.jsx)("div",{className:"w-10 h-10 bg-emerald-100 rounded-xl flex items-center justify-center",children:(0,K.jsx)(P.A,{className:"w-5 h-5 text-emerald-600"})}),(0,K.jsxs)("div",{children:[(0,K.jsx)("p",{className:"text-xs text-slate-500",children:"Total Revenue"}),(0,K.jsxs)("p",{className:"text-xl font-bold text-[#0D1B2A]",children:["\xa3",(null!==(e=Ue.summary.total_revenue)&&void 0!==e?e:0).toFixed(2)]})]})]})})}),(0,K.jsx)(r.Zp,{className:"border-slate-100",children:(0,K.jsx)(r.Wu,{className:"p-4",children:(0,K.jsxs)("div",{className:"flex items-center gap-3",children:[(0,K.jsx)("div",{className:"w-10 h-10 bg-blue-100 rounded-xl flex items-center justify-center",children:(0,K.jsx)(F.A,{className:"w-5 h-5 text-blue-600"})}),(0,K.jsxs)("div",{children:[(0,K.jsx)("p",{className:"text-xs text-slate-500",children:"VAT Collected"}),(0,K.jsxs)("p",{className:"text-xl font-bold text-[#0D1B2A]",children:["\xa3",(null!==(s=Ue.summary.total_vat_collected)&&void 0!==s?s:0).toFixed(2)]})]})]})})}),(0,K.jsx)(r.Zp,{className:"border-slate-100",children:(0,K.jsx)(r.Wu,{className:"p-4",children:(0,K.jsxs)("div",{className:"flex items-center gap-3",children:[(0,K.jsx)("div",{className:"w-10 h-10 bg-purple-100 rounded-xl flex items-center justify-center",children:(0,K.jsx)(p.A,{className:"w-5 h-5 text-purple-600"})}),(0,K.jsxs)("div",{children:[(0,K.jsx)("p",{className:"text-xs text-slate-500",children:"Paid"}),(0,K.jsx)("p",{className:"text-xl font-bold text-[#0D1B2A]",children:null!==(t=Ue.summary.paid_transactions)&&void 0!==t?t:0})]})]})})}),(0,K.jsx)(r.Zp,{className:"border-slate-100",children:(0,K.jsx)(r.Wu,{className:"p-4",children:(0,K.jsxs)("div",{className:"flex items-center gap-3",children:[(0,K.jsx)("div",{className:"w-10 h-10 bg-yellow-100 rounded-xl flex items-center justify-center",children:(0,K.jsx)(f.A,{className:"w-5 h-5 text-yellow-600"})}),(0,K.jsxs)("div",{children:[(0,K.jsx)("p",{className:"text-xs text-slate-500",children:"Pending"}),(0,K.jsx)("p",{className:"text-xl font-bold text-[#0D1B2A]",children:null!==(o=Ue.summary.pending_transactions)&&void 0!==o?o:0})]})]})})})]}),He.total>0&&(0,K.jsxs)(r.Zp,{className:"border-red-200",children:[(0,K.jsx)(r.aR,{className:"pb-0",children:(0,K.jsxs)(r.ZB,{className:"text-lg flex items-center gap-2 text-red-700",children:[(0,K.jsx)(u.A,{className:"w-5 h-5"}),"Arrears",(0,K.jsxs)("span",{className:"text-sm font-normal text-slate-500",children:["(",He.total," booking",1===He.total?"":"s"," overdue)"]})]})}),(0,K.jsx)(r.Wu,{className:"pt-4",children:(0,K.jsx)("div",{className:"overflow-x-auto",children:(0,K.jsxs)("table",{className:"w-full",children:[(0,K.jsx)("thead",{children:(0,K.jsxs)("tr",{className:"text-left text-xs text-slate-500 border-b",children:[(0,K.jsx)("th",{className:"pb-3 font-medium",children:"Customer"}),(0,K.jsx)("th",{className:"pb-3 font-medium",children:"Programme"}),(0,K.jsx)("th",{className:"pb-3 font-medium text-right",children:"Overdue rows"}),(0,K.jsx)("th",{className:"pb-3 font-medium text-right",children:"Overdue amount"}),(0,K.jsx)("th",{className:"pb-3 font-medium",children:"Oldest due"})]})}),(0,K.jsx)("tbody",{className:"text-sm",children:He.items.map(e=>(0,K.jsxs)("tr",{className:"border-b border-slate-50",children:[(0,K.jsxs)("td",{className:"py-3",children:[(0,K.jsx)("p",{className:"font-medium text-[#0D1B2A]",children:e.customer_name||"Unknown"}),(0,K.jsx)("p",{className:"text-xs text-slate-500",children:e.customer_email})]}),(0,K.jsx)("td",{className:"py-3 text-slate-600",children:e.programme_title||e.programme_slug}),(0,K.jsx)("td",{className:"py-3 text-right font-medium text-red-600",children:e.overdue_count}),(0,K.jsxs)("td",{className:"py-3 text-right font-medium text-red-600",children:["\xa3",(e.overdue_amount||0).toFixed(2)]}),(0,K.jsx)("td",{className:"py-3 text-slate-600",children:new Date(e.olde
1st_due_date).toLocaleDateString("en-GB")})]},e.booking_id))})]})})})]}),(0,K.jsx)(r.Zp,{className:"border-slate-100",children:(0,K.jsx)(r.Wu,{className:"p-4",children:(0,K.jsxs)("div",{className:"flex flex-wrap gap-3 items-end",children:[(0,K.jsxs)("div",{className:"flex-1 min-w-[160px]",children:[(0,K.jsx)("label",{className:"text-xs text-slate-500 mb-1 block",children:"Status"}),(0,K.jsxs)("select",{value:ze.status,onChange:e=>fs("status",e.target.value),className:"w-full border border-slate-200 rounded-lg px-3 py-2 text-sm text-[#0D1B2A] focus:outline-none focus:ring-2 focus:ring-[#41EAD4]",children:[(0,K.jsx)("option",{value:"",children:"All Statuses"}),(0,K.jsx)("option",{value:"paid",children:"Paid"}),(0,K.jsx)("option",{value:"pending",children:"Pending"}),(0,K.jsx)("option",{value:"refunded",children:"Refunded"}),(0,K.jsx)("option",{value:"partially_refunded",children:"Partially Refunded"})]})]}),(0,K.jsxs)("div",{className:"flex-1 min-w-[140px]",children:[(0,K.jsx)("label",{className:"text-xs text-slate-500 mb-1 block",children:"Type"}),(0,K.jsxs)("select",{value:ze.domain,onChange:e=>fs("domain",e.target.value),className:"w-full border border-slate-200 rounded-lg px-3 py-2 text-sm text-[#0D1B2A] focus:outline-none focus:ring-2 focus:ring-[#41EAD4]",children:[(0,K.jsx)("option",{value:"",children:"All Types"}),(0,K.jsx)("option",{value:"course",children:"Course"}),(0,K.jsx)("option",{value:"programme",children:"Programme"})]})]}),(0,K.jsxs)("div",{className:"flex-1 min-w-[180px]",children:[(0,K.jsx)("label",{className:"text-xs text-slate-500 mb-1 block",children:"Search"}),(0,K.jsxs)("div",{className:"relative",children:[(0,K.jsx)(E.A,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-slate-400"}),(0,K.jsx)(d.p,{placeholder:"Name or email\u2026",value:ze.search,onChange:e=>fs("search",e.target.value),className:"pl-9"})]})]}),(0,K.jsxs)("div",{className:"flex-1 min-w-[140px]",children:[(0,K.jsx)("label",{className:"text-xs text-slate-500 mb-1 block",children:"From"}),(0,K.jsx)(d.p,{type:"date",value:ze.date_from,onChange:e=>fs("date_from",e.target.value)})]}),(0,K.jsxs)("div",{className:"flex-1 min-w-[140px]",children:[(0,K.jsx)("label",{className:"text-xs text-slate-500 mb-1 block",children:"To"}),(0,K.jsx)(d.p,{type:"date",value:ze.date_to,onChange:e=>fs("date_to",e.target.value)})]}),(0,K.jsxs)(c.$,{variant:"outline",onClick:()=>{$e(e=>!e),Ie(1)},className:"shrink-0 ".concat(Ve?"border-[#41EAD4] text-[#0D1B2A] bg-[#41EAD4]/10":""),title:"Test transactions are hidden and excluded from totals by default",children:[Ve?(0,K.jsx)(k.A,{className:"w-4 h-4 mr-1"}):(0,K.jsx)(A.A,{className:"w-4 h-4 mr-1"}),Ve?"Showing test":"Show test"]}),(0,K.jsxs)(c.$,{variant:"outline",onClick:()=>{Oe({status:"",domain:"",search:"",date_from:"",date_to:""}),$e(!1),Ie(1)},className:"shrink-0",children:[(0,K.jsx)(C.A,{className:"w-4 h-4 mr-1"})," Reset"]}),(0,K.jsxs)(c.$,{variant:"outline",onClick:async()=>{try{const e=Object.fromEntries(Object.entries(ze).filter(e=>{let[,s]=e;return""!==s}));Ve&&(e.include_fake=!0);const s=await i.a5.exportTransactionsCsv(e),t=URL.createObjectURL(new Blob([s.data],{type:"text/csv"})),a=document.createElement("a");a.href=t,a.download="transactions.csv",a.click(),URL.revokeObjectURL(t)}catch(e){W.oR.error("Failed to export CSV")}},className:"shrink-0",children:[(0,K.jsx)(w.A,{className:"w-4 h-4 mr-1"})," Export CSV"]})]})})}),(0,K.jsxs)(r.Zp,{className:"border-slate-100",children:[(0,K.jsx)(r.aR,{className:"pb-0",children:(0,K.jsxs)(r.ZB,{className:"text-lg",children:["Transactions",Ue.total>0&&(0,K.jsxs)("span",{className:"text-sm font-normal text-slate-500 ml-2",children:["(",Ue.total," total)"]})]})}),(0,K.jsxs)(r.Wu,{className:"pt-4",children:[Je?(0,K.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,K.jsx)(j.A,{className:"w-8 h-8 text-[#41EAD4] animate-spin"})}):0===Ue.items.length?(0,K.jsxs)("div",{className:"text-center py-10 text-slate-500",children:[(0,K.jsx)(g.A,{className:"w-12 h-12 mx-auto mb-2 text-slate-300"}
1),(0,K.jsx)("p",{children:"No transactions found"})]}):(0,K.jsx)("div",{className:"overflow-x-auto",children:(0,K.jsxs)("table",{className:"w-full",children:[(0,K.jsx)("thead",{children:(0,K.jsxs)("tr",{className:"text-left text-xs text-slate-500 border-b",children:[(0,K.jsx)("th",{className:"pb-3 font-medium",children:"Date"}),(0,K.jsx)("th",{className:"pb-3 font-medium",children:"Customer"}),(0,K.jsx)("th",{className:"pb-3 font-medium",children:"Item"}),(0,K.jsx)("th",{className:"pb-3 font-medium",children:"Type"}),(0,K.jsx)("th",{className:"pb-3 font-medium text-right",children:"Amount"}),(0,K.jsx)("th",{className:"pb-3 font-medium",children:"Status"}),(0,K.jsx)("th",{className:"pb-3 font-medium text-right",children:"Actions"})]})}),(0,K.jsx)("tbody",{className:"text-sm",children:Ue.items.map(e=>(0,K.jsxs)("tr",{className:"border-b border-slate-50 hover:bg-slate-50 cursor-pointer transition-colors",onClick:()=>Qe(e.id),children:[(0,K.jsx)("td",{className:"py-3 text-slate-600",children:new Date(e.created_at).toLocaleDateString("en-GB")}),(0,K.jsxs)("td",{className:"py-3",children:[(0,K.jsxs)("p",{className:"font-medium text-[#0D1B2A] flex items-center gap-1.5",children:[e.user_name,e.is_fake&&(0,K.jsxs)(x.E,{className:"bg-amber-100 text-amber-700 text-[10px] px-1.5 py-0",children:[(0,K.jsx)(R.A,{className:"w-3 h-3 mr-0.5"}),"Test"]})]}),(0,K.jsx)("p",{className:"text-xs text-slate-500",children:e.user_email})]}),(0,K.jsx)("td",{className:"py-3 text-slate-600",children:e.item_title}),(0,K.jsx)("td",{className:"py-3",children:(0,K.jsx)(x.E,{variant:"outline",className:"capitalize",children:e.domain})}),(0,K.jsxs)("td",{className:"py-3 text-right font-medium text-[#0D1B2A]",children:["\xa3",(e.amount_total||0).toFixed(2)]}),(0,K.jsx)("td",{className:"py-3",children:J(e.payment_status)}),(0,K.jsx)("td",{className:"py-3 text-right",children:(0,K.jsx)(c.$,{variant:"ghost",size:"sm",onClick:s=>((e,s)=>{e.stopPropagation();const t=s.user_email||s.user_name||"unknown customer";window.confirm("Delete this ".concat(s.domain," transaction for ").concat(t,"?\n\nThis permanently removes the record from the database."))&&i.a5.deletePayment(s.id).then(()=>{W.oR.success("Transaction deleted"),Ke(e=>e+1)}).catch(e=>{var s,t;return W.oR.error((null===(s=e.response)||void 0===s||null===(t=s.data)||void 0===t?void 0:t.detail)||"Failed to delete transaction")})})(s,e),className:"text-slate-400 hover:text-red-600 hover:bg-red-50",title:"Delete this transaction record","data-testid":"delete-tx-".concat(e.id),children:(0,K.jsx)(T.A,{className:"w-4 h-4"})})})]},e.id))})]})}),Ue.total>0&&(0,K.jsxs)("div",{className:"flex items-center justify-between mt-4 pt-4 border-t border-slate-100",children:[(0,K.jsxs)("span",{className:"text-sm text-slate-500",children:["Page ",Le," \xb7 ",Ue.total," total"]}),(0,K.jsxs)("div",{className:"flex gap-2",children:[(0,K.jsxs)(c.$,{variant:"outline",size:"sm",disabled:1===Le,onClick:()=>Ie(e=>e-1),children:[(0,K.jsx)(b.A,{className:"w-4 h-4 mr-1"})," Prev"]}),(0,K.jsxs)(c.$,{variant:"outline",size:"sm",disabled:25*Le>=Ue.total,onClick:()=>Ie(e=>e+1),children:["Next ",(0,K.jsx)(v.A,{className:"w-4 h-4 ml-1"})]})]})]})]})]})]}),"subscriptions"===Fe&&(0,K.jsxs)("div",{className:"space-y-4",children:[(0,K.jsx)(r.Zp,{className:"border-slate-100",children:(0,K.jsx)(r.Wu,{className:"p-4",children:(0,K.jsxs)("div",{className:"flex flex-wrap gap-3 items-end",children:[(0,K.jsxs)("div",{className:"flex-1 min-w-[160px]",children:[(0,K.jsx)("label",{className:"text-xs text-slate-500 mb-1 block",children:"Status"}),(0,K.jsxs)("select",{value:es.status,onChange:e=>ss(s=>(0,a.A)((0,a.A)({},s),{},{status:e.target.value})),className:"w-full border border-slate-200 rounded-lg px-3 py-2 text-sm text-[#0D1B2A] focus:outline-none focus:ring-2 focus:ring-[#41EAD4]",children:[(0,K.jsx)("option",{value:"",children:"All Statuses"}),(0,K.jsx)("option",{value:"active",children:"Active"}),(0,K.jsx)("option",{value:"past_due",children:"Past Due"}),(0,K.jsx)("option",{value:"canceled",children:"Cancelled"}),(0,K.jsx)("option",{value:"trialing",children:"Trialing"})]})]}),(0,K.jsxs)("div",{className:"flex-1 min-w-[140px]",children:[(0,K.jsx)("label",{className:"text-xs text-slate-500 mb-1 block",children:"Type"}),(0,K.jsxs)("select",{value:es.domain,onChange:e=>ss(s=>(0,a.A)((0,a.A)({},s),{},{domain:e.target.value})),className:"w-full border border-slate-200 rounded-lg px-3 py-2 text-sm text-[#0D1B2A] focus:outline-none focus:ring-2 focus:ring-[#41EAD4]",children:[(0,K.jsx)("option",{value:"",children:"All Types"}),(0,K.jsx)("option",{value:"course",children:"Course"}),(0,K.jsx)("option",{value:"programme",children:"Programme"})]})]}),(0,K.jsxs)(c.$,{variant:"outline",onClick:()=>ss({status:"",domain:""}),className:"shrink-0",children:[(0,K.jsx)(C.A,{className:"w-4 h-4 mr-1"})," Reset"]})]})})}),(0,K.jsxs)(r.Zp,{className:"border-slate-100",children:[(0,K.jsx)(r.aR,{className:"pb-0",children:(0,K.jsx)(r.ZB,{className:"text-lg",children:"Subscriptions & Installments"})}),(0,K.jsx)(r.Wu,{className:"pt-4",children:ls?(0,K.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,K.jsx)(j.A,{className:"w-8 h-8 text-[#41EAD4] animate-spin"})}):0===ts.length?(0,K.jsxs)("div",{className:"text-center py-10 text-slate-500",children:[(0,K.jsx)(g.A,{className:"w-12 h-12 mx-auto mb-2 text-slate-300"}),(0,K.jsx)("p",{children:"No subscriptions"})]}):(0,K.jsx)("div",{className:"overflow-x-auto",children:(0,K.jsxs)("table",{className:"w-full",children:[(0,K.jsx)("thead",{children:(0,K.jsxs)("tr",{className:"text-left text-xs text-slate-500 border-b",children:[(0,K.jsx)("th",{className:"pb-3 font-medium",children:"Customer"}),(0,K.jsx)("th",{className:"pb-3 font-medium",children:"Item"}),(0,K.jsx)("th",{className:"pb-3 font-medium",children:"Type"}),(0,K.jsx)("th",{className:"pb-3 font-medium",children:"Kind"}),(0,K.jsx)("th",{className:"pb-3 font-medium",children:"Status"}),(0,K.jsx)("th",{className:"pb-3 font-medium",children:"Next Billing"}),(0,K.jsx)("th",{className:"pb-3 font-medium",children:"Progress"}),(0,K.jsx)("th",{className:"pb-3 font-medium",children:"Actions"})]})}),(0,K.jsx)("tbody",{className:"text-sm",children:ts.map(e=>{var s,t;const a=null!=e.payments_made?"".concat(e.payments_made," / ").concat(e.payments_made+(null!==(s=e.payments_remaining)&&void 0!==s?s:0)):"\u2014",l=e.current_period_end?new Date(e.current_period_end).toLocaleDateString("en-GB"):"\u2014",n=is===e.stripe_subscription_id;return(0,K.jsxs)("tr",{className:"border-b border-slate-50 hover:bg-slate-50 transition-colors",children:[(0,K.jsxs)("td",{className:"py-3",children:[(0,K.jsx)("p",{className:"font-medium text-[#0D1B2A]",children:e.user_name}),(0,K.jsx)("p",{className:"text-xs text-slate-500",children:e.user_email})]}),(0,K.jsx)("td",{className:"py-3 text-slate-600",children:e.item_title}),(0,K.jsx)("td",{className:"py-3",children:(0,K.jsx)(x.E,{variant:"outline",className:"capitalize",children:e.domain})}),(0,K.jsx)("td",{className:"py-3 text-slate-600 capitalize",children:e.kind}),(0,K.jsx)("td",{className:"py-3",children:(r=e.status,"active"===r?(0,K.jsxs)(x.E,{className:"bg-emerald-100 text-emerald-700",children:[(0,K.jsx)(p.A,{className:"w-3 h-3 mr-1"}),"Active"]}):"past_due"===r?(0,K.jsxs)(x.E,{className:"bg-yellow-100 text-yellow-700",children:[(0,K.jsx)(f.A,{className:"w-3 h-3 mr-1"}),"Past Due"]}):"canceled"===r||"cancelled"===r?(0,K.jsxs)(x.E,{className:"bg-red-100 text-red-700",children:[(0,K.jsx)(u.A,{className:"w-3 h-3 mr-1"}),"Cancelled"]}):"trialing"===r?(0,K.jsxs)(x.E,{className:"bg-blue-100 text-blue-700",children:[(0,K.jsx)(f.A,{className:"w-3 h-3 mr-1"}),"Trialing"]}):(0,K.jsx)(x.E,{className:"bg-slate-100 text-slate-700",children:r}))}),(0,K.jsx)("td",{className:"py-3 text-slate-600",children:(0,K.jsxs)("span",{className:"flex items-center gap-1",children:[(0,K.jsx)(N.A,{className:"w-3 h-3 text-slate-400"}),l]})}),(0,K.jsx)("td",{className:"py-3 text-slate-600",children:a}),(0,K.jsx)("td",{className:"py-3",children:(0,K.jsx)(c.$,{size:"sm",variant:"outline",disabled:n||"canceled"===e.status||"cancelled"===e.status,onClick:()=>(async e=>{if(window.confirm("Cancel subscription for ".concat(e.user_name," 
1(").concat(e.item_title,")? This cannot be undone."))){rs(e.stripe_subscription_id);try{await i.a5.cancelSubscription(e.stripe_subscription_id),W.oR.success("Cancellation initiated \u2014 reconciled by Stripe"),vs()}catch(s){W.oR.error("Failed to cancel subscription")}finally{rs(null)}}})(e),className:"text-red-600 border-red-200 hover:bg-red-50 hover:border-red-300",children:n?(0,K.jsx)(j.A,{className:"w-3 h-3 animate-spin"}):"Cancel"})})]},null!==(t=e.id)&&void 0!==t?t:e.stripe_subscription_id);var r})})]})})})]})]}),"reconciliation"===Fe&&(0,K.jsx)("div",{className:"space-y-6",children:os?(0,K.jsx)("div",{className:"flex items-center justify-center py-24",children:(0,K.jsx)(j.A,{className:"w-8 h-8 text-[#41EAD4] animate-spin"})}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(r.Zp,{className:"border-slate-100",children:[(0,K.jsx)(r.aR,{className:"pb-0",children:(0,K.jsxs)(r.ZB,{className:"text-lg flex items-center gap-2",children:[(0,K.jsx)(u.A,{className:"w-5 h-5 text-orange-500"}),"Paid but Unenrolled",(0,K.jsxs)("span",{className:"text-sm font-normal text-slate-500 ml-1",children:["(",(null!==(m=null===cs||void 0===cs?void 0:cs.paid_but_unenrolled)&&void 0!==m?m:[]).length,")"]})]})}),(0,K.jsx)(r.Wu,{className:"pt-4",children:0===(null!==(y=null===cs||void 0===cs?void 0:cs.paid_but_unenrolled)&&void 0!==y?y:[]).length?(0,K.jsxs)("div",{className:"text-center py-6 text-slate-400",children:[(0,K.jsx)(p.A,{className:"w-8 h-8 mx-auto mb-2 text-emerald-400"}),(0,K.jsx)("p",{className:"font-medium",children:"All clear \u2713"}),(0,K.jsx)("p",{className:"text-sm",children:"No paid-but-unenrolled records found"})]}):(0,K.jsx)("div",{className:"overflow-x-auto",children:(0,K.jsxs)("table",{className:"w-full",children:[(0,K.jsx)("thead",{children:(0,K.jsxs)("tr",{className:"text-left text-xs text-slate-500 border-b",children:[(0,K.jsx)("th",{className:"pb-3 font-medium",children:"ID"}),(0,K.jsx)("th",{className:"pb-3 font-medium",children:"Domain"}),(0,K.jsx)("th",{className:"pb-3 font-medium",children:"User ID"}),(0,K.jsx)("th",{className:"pb-3 font-medium",children:"Course / Programme"})]})}),(0,K.jsx)("tbody",{className:"text-sm",children:(null!==(_=null===cs||void 0===cs?void 0:cs.paid_but_unenrolled)&&void 0!==_?_:[]).map(e=>{var s,t;return(0,K.jsxs)("tr",{className:"border-b border-slate-50 hover:bg-slate-50 cursor-pointer transition-colors",onClick:()=>Qe(e.id),children:[(0,K.jsx)("td",{className:"py-3 font-mono text-xs text-slate-600 truncate max-w-[180px]",children:e.id}),(0,K.jsx)("td",{className:"py-3",children:(0,K.jsx)(x.E,{variant:"outline",className:"capitalize",children:e.domain})}),(0,K.jsx)("td",{className:"py-3 font-mono text-xs text-slate-500 truncate max-w-[140px]",children:e.user_id}),(0,K.jsx)("td",{className:"py-3 text-slate-600",children:null!==(s=null!==(t=e.course_id)&&void 0!==t?t:e.programme_slug)&&void 0!==s?s:"\u2014"})]},e.id)})})]})})})]}),(0,K.jsxs)(r.Zp,{className:"border-slate-100",children:[(0,K.jsx)(r.aR,{className:"pb-0",children:(0,K.jsxs)(r.ZB,{className:"text-lg flex items-center gap-2",children:[(0,K.jsx)(u.A,{className:"w-5 h-5 text-red-500"}),"Failed Webhook Events",(0,K.jsxs)("span",{className:"text-sm font-normal text-slate-500 ml-1",children:["(",(null!==(S=null===cs||void 0===cs?void 0:cs.webhook_failed)&&void 0!==S?S:[]).length,")"]})]})}),(0,K.jsx)(r.Wu,{className:"pt-4",children:0===(null!==(B=null===cs||void 0===cs?void 0:cs.webhook_failed)&&void 0!==B?B:[]).length?(0,K.jsxs)("div",{className:"text-center py-6 text-slate-400",children:[(0,K.jsx)(p.A,{className:"w-8 h-8 mx-auto mb-2 text-emerald-400"}),(0,K.jsx)("p",{className:"font-medium",children:"All clear \u2713"}),(0,K.jsx)("p",{className:"text-sm",children:"No failed webhook events"})]}):(0,K.jsx)("div",{className:"overflow-x-auto",children:(0,K.jsxs)("table",{className:"w-full",children:[(0,K.jsx)("thead",{children:(0,K.jsxs)("tr",{className:"text-left text-xs text-slate-500 border-b",children:[(0,K.jsx)("th",{className:"pb-3 font-medium",children:"Event ID"}),(0,K.jsx)("th",{className:"pb-3 font-medium",children:"Type"}),(0,K.jsx)("th",{className:"pb-3 font-medium",children:"Error"}),(0,K.jsx)("th",{className:"pb-3 font-medium",children:"Received At"})]})}),(0,K.jsx)("tbody",{className:"text-sm",children:(null!==(Z=null===cs||void 0===cs?void 0:cs.webhook_failed)&&void 0!==Z?Z:[]).map(e=>(0,K.jsxs)("tr",{className:"border-b border-slate-50 hover:bg-slate-50 transition-colors",children:[(0,K.jsx)("td",{className:"py-3 font-mono text-xs text-slate-600 truncate max-w-[180px]",children:e.event_id}),(0,K.jsx)("td",{className:"py-3 text-slate-600",children:e.type}),(0,K.jsx)("td",{className:"py-3 text-red-600 text-xs max-w-[260px] truncate",children:e.error}),(0,K.jsx)("td",{className:"py-3 text-slate-500 text-xs whitespace-nowrap",children:e.received_at?new Date(e.received_at).toLocaleStr
1ing("en-GB"):"\u2014"})]},e.event_id))})]})})})]}),(0,K.jsxs)(r.Zp,{className:"border-slate-100",children:[(0,K.jsx)(r.aR,{className:"pb-0",children:(0,K.jsxs)(r.ZB,{className:"text-lg flex items-center gap-2",children:[(0,K.jsx)(u.A,{className:"w-5 h-5 text-yellow-500"}),"Amount Mismatches",(0,K.jsxs)("span",{className:"text-sm font-normal text-slate-500 ml-1",children:["(",(null!==(H=null===cs||void 0===cs?void 0:cs.amount_mismatch)&&void 0!==H?H:[]).length,")"]})]})}),(0,K.jsx)(r.Wu,{className:"pt-4",children:0===(null!==(X=null===cs||void 0===cs?void 0:cs.amount_mismatch)&&void 0!==X?X:[]).length?(0,K.jsxs)("div",{className:"text-center py-6 text-slate-400",children:[(0,K.jsx)(p.A,{className:"w-8 h-8 mx-auto mb-2 text-emerald-400"}),(0,K.jsx)("p",{className:"font-medium",children:"No mismatches detected"}),(0,K.jsx)("p",{className:"text-sm",children:"Stored amounts match Stripe"})]}):(0,K.jsx)("div",{className:"overflow-x-auto",children:(0,K.jsxs)("table",{className:"w-full",children:[(0,K.jsx)("thead",{children:(0,K.jsxs)("tr",{className:"text-left text-xs text-slate-500 border-b",children:[(0,K.jsx)("th",{className:"pb-3 font-medium",children:"ID"}),(0,K.jsx)("th",{className:"pb-3 font-medium text-right",children:"Stored (\xa3)"}),(0,K.jsx)("th",{className:"pb-3 font-medium text-right",children:"Stripe (\xa3)"}),(0,K.jsx)("th",{className:"pb-3 font-medium text-right",children:"Difference"})]})}),(0,K.jsx)("tbody",{className:"text-sm",children:(null!==(ee=null===cs||void 0===cs?void 0:cs.amount_mismatch)&&void 0!==ee?ee:[]).map(e=>{const s=(Number(e.stripe)-Number(e.stored)).toFixed(2);return(0,K.jsxs)("tr",{className:"border-b border-slate-50 hover:bg-slate-50 transition-colors",children:[(0,K.jsx)("td",{className:"py-3 font-mono text-xs text-slate-600 truncate max-w-[180px]",children:e.id}),(0,K.jsxs)("td",{className:"py-3 text-right text-slate-600",children:["\xa3",Number(e.stored).toFixed(2)]}),(0,K.jsxs)("td",{className:"py-3 text-right text-slate-600",children:["\xa3",Number(e.stripe).toFixed(2)]}),(0,K.jsxs)("td",{className:"py-3 text-right font-medium ".concat(0!==Number(s)?"text-red-600":"text-emerald-600"),children:[Number(s)>=0?"+":"","\xa3",s]})]},e.id)})})]})})})]})]})}),"pricing"===Fe&&(0,K.jsx)("div",{className:"grid md:grid-cols-2 lg:grid-cols-3 gap-4",children:Be.map(e=>(0,K.jsx)(r.Zp,{className:"border-slate-100",children:(0,K.jsxs)(r.Wu,{className:"p-4",children:[(0,K.jsx)("h3",{className:"font-medium text-[#0D1B2A] mb-2",children:e.title}),(0,K.jsxs)("div",{className:"space-y-2 text-sm mb-4",children:[(0,K.jsxs)("div",{className:"flex justify-between",children:[(0,K.jsx)("span",{className:"text-slate-500",children:"One-Time Price"}),(0,K.jsxs)("span",{className:"font-medium",children:["\xa3",(e.price||0).toFixed(2)]})]}),(0,K.jsxs)("div",{className:"flex justify-between",children:[(0,K.jsx)("span",{className:"text-slate-500",children:"VAT Rate"}),(0,K.jsxs)("span",{className:"font-medium",children:[e.vat_rate||20,"%"]})]}),e.subscription_enabled&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)("div",{className:"flex justify-between",children:[(0,K.jsx)("span",{className:"text-slate-500",children:"Monthly"}),(0,K.jsxs)("span",{className:"font-medium",children:["\xa3",(e.subscription_price_monthly||0).toFixed(2)]})]}),(0,K.jsxs)("div",{className:"flex justify-between",children:[(0,K.jsx)("span",{className:"text-slate-500",children:"Yearly"}),(0,K.jsxs)("span",{className:"font-medium",children:["\xa3",(e.subscription_price_yearly||0).toFixed(2)]})]})]})]}),(0,K.jsx)(c.$,{variant:"outline",className:"w-full",onClick:()=>We(e),children:"Edit Pricing"})]})},e.course_id))}),"vat"===Fe&&Te&&(0,K.jsxs)(r.Zp,{className:"border-slate-100",children:[(0,K.jsx)(r.aR,{children:(0,K.jsxs)(r.ZB,{className:"text-lg flex items-center gap-2",children:[(0,K.jsx)(D.A,{className:"w-5 h-5 text-[#41EAD4]"}),"VAT Report by Month"]})}),(0,K.jsx)(r.Wu,{children:0===Object.keys(Te.monthly_breakdown||{}).length?(0,K.jsxs)("div",{className:"text-center py-8 text-slate-500",children:[(0,K.jsx)(F.A,{className:"w-12 h-12 mx-auto mb-2 text-slate-300"}),(0,K.jsx)("p",{children:"No VAT data available yet"})]}):(0,K.jsx)("div",{className:"overflow-x-auto",children:(0,K.jsxs)("table",{className:"w-full",children:[(0,K.jsx)("thead",{children:(0,K.jsxs)("tr",{className:"text-left text-xs text-slate-500 border-b",children:[(0,K.jsx)("th",{className:"pb-3 font-medium",children:"Month"}),(0,K.jsx)("th",{className:"pb-3 font-medium text-right",children:"Transactions"}),(0,K.jsx)("th",{className:"pb-3 font-medium text-right",children:"Net Sales"}),(0,K.jsx)("th",{className:"pb-3 font-medium text-right",children:"VAT Collected"}),(0,K.jsx)("th",{className:"pb-3 font-medium text-right",children:"Total Sales"})]})}),(0,K.jsx)("tbody",{className:"text-sm",children:Object.entries(Te.monthly_breakdown).sort((e,s)=>s[0].localeCompare(e[0])).map(e=>{let[s,t]=e;return(0,K.jsxs)("tr",{className:"border-b border-slate-50",children:[(0,K.jsx)("td",{className:"py-3 font-medium text-[#0D1B2A]",children:new Date(s+"-01").toLocaleDateString("en-GB",{month:"long",year:"numeric"})}),(0,K.jsx)("td",{className:"py-3 text-right text-slate-600",children:t.transaction_count}),(0,K.jsxs)("td",{className:"py-3 text-right text-slate-600",children:["\xa3",t.net_sales.toFixed(2)]}),(0,K.jsxs)("td",{className:"py-3 text-right text-blue-600 font-medium",children:["\xa3",t.vat_collected.toFixed(2)]}),(0,K.jsxs)("td",{className:"py-3 text-right font-medium text-[#0D1B2A]",children:["\xa3",t.total_sales.toFixed(2)]})]},s)})})]})})})]}),"analytics"===Fe&&(0,K.jsxs)("div",{className:"space-y-6",children:[(0,K.jsx)(r.Zp,{className:"border-slate-100",children:(0,K.jsx)(r.Wu,{className:"p-4",children:(0,K.jsxs)("div",{className:"flex flex-wrap gap-3 items-end",children:[(0,K.jsxs)("div",{className:"flex-1 min-w-[140px]",children:[(0,K.jsx)("label",{className:"text-xs text-slate-500 mb-1 block",children:"From"}),(0,K.jsx)(d.p,{type:"date",value:js.date_from,onChange:e=>Ns(s=>(0,a.A)((0,a.A)({},s),{},{date_from:e.target.value}))})]}),(0,K.jsxs)("div",{className:"flex-1 min-w-[140px]",children:[(0,K.jsx)("label",{className:"text-xs text-slate-500 mb-1 block",children:"To"}),(0,K.jsx)(d.p,{type:"date",value:js.date_to,onChange:e=>Ns(s=>(0,a.A)((0,a.A)({},s),{},{date_to:e.target.value}))})]}),(0,K.jsxs)(c.$,{variant:"outline",onClick:()=>Ns({date_from:"",date_to:""}),className:"shrink-0",children:[(0,K.jsx)(C.A,{className:"w-4 h-4 mr-1"})," Reset"]})]})})}),us?(0,K.jsx)("div",{className:"flex items-center justify-center py-24",children:(0,K.jsx)(j.A,{className:"w-8 h-8 text-[#41EAD4] animate-spin"})}
1):ms?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)("div",{className:"grid sm:grid-cols-2 lg:grid-cols-4 gap-4",children:[(0,K.jsx)(r.Zp,{className:"border-slate-100",children:(0,K.jsxs)(r.Wu,{className:"p-4",children:[(0,K.jsx)("p",{className:"text-xs text-slate-500 mb-1",children:"MRR"}),(0,K.jsxs)("p",{className:"text-2xl font-bold text-[#0D1B2A]",children:["\xa3",Number(null!==(se=ms.mrr)&&void 0!==se?se:0).toFixed(2)]}),(0,K.jsx)("p",{className:"text-xs text-slate-400 mt-1",children:"Monthly Recurring Revenue"})]})}),(0,K.jsx)(r.Zp,{className:"border-slate-100",children:(0,K.jsxs)(r.Wu,{className:"p-4",children:[(0,K.jsx)("p",{className:"text-xs text-slate-500 mb-1",children:"ARR"}),(0,K.jsxs)("p",{className:"text-2xl font-bold text-[#0D1B2A]",children:["\xa3",Number(null!==(te=ms.arr)&&void 0!==te?te:0).toFixed(2)]}),(0,K.jsx)("p",{className:"text-xs text-slate-400 mt-1",children:"Annual Recurring Revenue"})]})}),(0,K.jsx)(r.Zp,{className:"border-slate-100",children:(0,K.jsxs)(r.Wu,{className:"p-4",children:[(0,K.jsx)("p",{className:"text-xs text-slate-500 mb-1",children:"Refund Rate"}),(0,K.jsxs)("p",{className:"text-2xl font-bold text-red-600",children:[(100*(null!==(ae=null===(le=ms.refund_rate)||void 0===le?void 0:le.rate)&&void 0!==ae?ae:0)).toFixed(1),"%"]}),(0,K.jsxs)("p",{className:"text-xs text-slate-400 mt-1",children:[null!==(ne=null===(ie=ms.refund_rate)||void 0===ie?void 0:ie.refunded_count)&&void 0!==ne?ne:0," of"," ",null!==(re=null===(ce=ms.refund_rate)||void 0===ce?void 0:ce.paid_count)&&void 0!==re?re:0," transactions"]})]})}),(0,K.jsx)(r.Zp,{className:"border-slate-100",children:(0,K.jsxs)(r.Wu,{className:"p-4",children:[(0,K.jsx)("p",{className:"text-xs text-slate-500 mb-1",children:"Failed Payments"}),(0,K.jsx)("p",{className:"text-2xl font-bold text-orange-600",children:null!==(de=ms.failed_payment_count)&&void 0!==de?de:0}),(0,K.jsx)("p",{className:"text-xs text-slate-400 mt-1",children:"Requires attention"})]})}),(0,K.jsx)(r.Zp,{className:"border-slate-100",children:(0,K.jsxs)(r.Wu,{className:"p-4",children:[(0,K.jsx)("p",{className:"text-xs text-slate-500 mb-1",children:"Total Revenue"}),(0,K.jsxs)("p",{className:"text-2xl font-bold text-[#0D1B2A]",children:["\xa3",Number(null!==(oe=null===(xe=ms.totals)||void 0===xe?void 0:xe.total_revenue)&&void 0!==oe?oe:0).toFixed(2)]}),(0,K.jsxs)("p",{className:"text-xs text-slate-400 mt-1",children:["VAT: \xa3",Number(null!==(me=null===(he=ms.totals)||void 0===he?void 0:he.total_vat)&&void 0!==me?me:0).toFixed(2)]})]})}),(0,K.jsx)(r.Zp,{className:"border-slate-100",children:(0,K.jsxs)(r.Wu,{className:"p-4",children:[(0,K.jsx)("p",{className:"text-xs text-slate-500 mb-1",children:"Net Revenue"}),(0,K.jsxs)("p",{className:"text-2xl font-bold text-emerald-600",children:["\xa3",Number(null!==(ue=null===(pe=ms.totals)||void 0===pe?void 0:pe.net_revenue)&&void 0!==ue?ue:0).toFixed(2)]}),(0,K.jsxs)("p",{className:"text-xs text-slate-400 mt-1",children:[null!==(je=null===(Ne=ms.totals)||void 0===Ne?void 0:Ne.transaction_count)&&void 0!==je?je:0," transactions"]})]})}),(0,K.jsx)(r.Zp,{className:"border-slate-100 sm:col-span-2",children:(0,K.jsxs)(r.Wu,{className:"p-4",children:[(0,K.jsx)("p",{className:"text-xs text-slate-500 mb-1",children:"New vs Renewal Revenue"}),(0,K.jsxs)("div",{className:"flex gap-6 mt-2",children:[(0,K.jsxs)("div",{children:[(0,K.jsxs)("p",{className:"text-xl font-bold text-[#41EAD4]",children:["\xa3",Number(null!==(be=null===(ve=ms.new_vs_renewal)||void 0===ve?void 0:ve.new_revenue)&&void 0!==be?be:0).toFixed(2)]}),(0,K.jsx)("p",{className:"text-xs text-slate-400",children:"New"})]}),(0,K.jsxs)("div",{children:[(0,K.jsxs)("p",{className:"text-xl font-bold text-[#0D1B2A]",children:["\xa3",Number(null!==(fe=null===(ge=ms.new_vs_renewal)||void 0===ge?void 0:ge.renewal_revenue)&&void 0!==fe?fe:0).toFixed(2)]}),(0,K.jsx)("p",{className:"text-xs text-slate-400",children:"Renewal"})]})]})]})})]}),(null!==(ye=ms.revenue_over_time)&&void 0!==ye?ye:[]).length>0&&(0,K.jsxs)(r.Zp,{className:"border-slate-100",children:[(0,K.jsx)(r.aR,{className:"pb-2",children:(0,K.jsx)(r.ZB,{className:"text-lg",children:"Revenue Over Time"})}),(0,K.jsx)(r.Wu,{children:(0,K.jsx)(O.u,{width:"100%",height:280,children:(0,K.jsxs)(G.Q,{data:ms.revenue_over_time,children:[(0,K.jsx)(L.d,{strokeDasharray:"3 3",stroke:"#e2e8f0"}),(0,K.jsx)($.W,{dataKey:"month",tick:{fontSize:12,fill:"#64748b"}}),(0,K.jsx)(U.h,{tick:{fontSize:12,fill:"#64748b"},tickFormatter:e=>"\xa3".concat(Number(e).toFixed(0))}),(0,K.jsx)(z.m,{formatter:e=>["\xa3".concat(Number(e).toFixed(2)),"Revenue"]}),(0,K.jsx)(I.Gk,{type:"monotone",dataKey:"revenue",stroke:"#41EAD4",fill:"#41EAD4",fillOpacity:.15,strokeWidth:2})]})})})]}),(null!==(we=ms.revenue_by_payment_type)&&void 0!==we?we:[]).length>0&&(0,K.jsxs)(r.Zp,{className:"border-slate-100",children:[(0,K.jsx)(r.aR,{className:"pb-2",children:(0,K.jsx)(r.ZB,{className:"text-lg",children:"Revenue by Payment Type"})}),(0,K.jsx)(r.Wu,{children:(0,K.jsx)(O.u,{width:"100%",height:240,children:(0,K.jsxs)(M.E,{data:ms.revenue_by_payment_type,children:[(0,K.jsx)(L.d,{strokeDasharray:"3 3",stroke:"#e2e8f0"}),(0,K.jsx)($.W,{dataKey:"payment_type",tick:{fontSize:12,fill:"#64748b"}}),(0,K.jsx)(U.h,{tick:{fontSize:12,fill:"#64748b"},tickFormatter:e=>"\xa3".concat(Number(e).toFixed(0))}),(0,K.jsx)(z.m,{formatter:e=>["\xa3".concat(Number(e).toFixed(2)),"Revenue"]}),(0,K.jsx)(V.yP,{dataKey:"revenue",fill:"#0D1B2A",radius:[4,4,0,0]})]})})})]}),(null!==(_e=ms.revenue_by_item)&&void 0!==_e?_e:[]).length>0&&(0,K.jsxs)(r.Zp,{className:"border-slate-100",children:[(0,K.jsx)(r.aR,{className:"pb-2",children:(0,K.jsx)(r.ZB,{className:"text-lg",children:"Revenue by Item"})}),(0,K.jsx)(r.Wu,{children:(0,K.jsx)(O.u,{width:"100%",height:260,children:(0,K.jsxs)(M.E,{data:ms.revenue_by_item,layout:"vertical",children:[(0,K.jsx)(L.d,{strokeDasharray:"3 3",stroke:"#e2e8f0"}),(0,K.jsx)($.W,{type:"number",tick:{fontSize:11,fill:"#64748b"},tickFormatter:e=>"\xa3".concat(Number(e).toFixed(0))}),(0,K.jsx)(U.h,{type:"category",dataKey:"title",width:140,tick:{fontSize:11,fill:"#64748b"}}),(0,K.jsx)(z.m,{formatter:e=>["\xa3".concat(Number(e).toFixed(2)),"Revenue"]}),(0,K.jsx)(V.yP,{dataKey:"revenue",fill:"#41EAD4",radius:[0,4,4,0]})]})})})]}),0===(null!==(Ae=ms.revenue_over_time)&&void 0!==Ae?Ae:[]).length&&0===(null!==(ke=ms.revenue_by_payment_type)&&void 0!==ke?ke:[]).length&&0===(null!==(De=ms.revenue_by_item)&&void 0!==De?De:[]).length&&(0,K.jsxs)("div",{className:"text-center py-10 text-slate-400",children:[(0,K.jsx)(h.A,{className:"w-10 h-10 mx-auto mb-2 text-slate-300"}),(0,K.jsx)("p",{children:"No chart data for this period"})]})]}):(0,K.jsxs)("div",{className:"text-center py-16 text-slate-400",children:[(0,K.jsx)(h.A,{className:"w-12 h-12 mx-auto mb-3 text-slate-300"}
1),(0,K.jsx)("p",{className:"font-medium",children:"No analytics data available"}),(0,K.jsx)("p",{className:"text-sm",children:"Try adjusting your date range"})]})]}),Ze&&(0,K.jsx)(q,{course:Ze,onClose:()=>We(null),onSave:bs}),Ye&&(0,K.jsx)(Y,{id:Ye,onClose:()=>Qe(null),onRefunded:()=>{Qe(null),Oe(e=>(0,a.A)({},e))},onChanged:()=>Oe(e=>(0,a.A)({},e))})]})})},X=H},1654(e,s,t){t.d(s,{d:()=>o});var a=t(9379),l=t(3986),n=t(5043),i=t(7943),r=t(9766),c=t(579);const d=["className"],o=n.forwardRef((e,s)=>{let{className:t}=e,n=(0,l.A)(e,d);return(0,c.jsx)(i.bL,(0,a.A)((0,a.A)({className:(0,r.cn)("peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",t)},n),{},{ref:s,children:(0,c.jsx)(i.zi,{className:(0,r.cn)("pointer-events-none block h-4 w-4 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0")})}))});o.displayName=i.bL.displayName},9938(e,s,t){t.d(s,{J:()=>m});var a=t(9379),l=t(3986),n=t(5043),i=t(5131),r=t(917),c=t(9766),d=t(579);const o=["className"],x=(0,r.F)("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),m=n.forwardRef((e,s)=>{let{className:t}=e,n=(0,l.A)(e,o);return(0,d.jsx)(i.b,(0,a.A)({ref:s,className:(0,c.cn)(x(),t)},n))});m.displayName=i.b.displayName}}]);
2//# sourceMappingURL=596.ebc09489.chunk.js.map

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.