1import{_ as j,aa as e,B as d,m,K as h,a2 as S,ap as y,aq as C,aA as k,ac as P,aD as M,i as A,ag as T}from"./index-CAXCr2dA.js";import{f as N}from"./react-vendor-Clvj-Tss.js";import{P as L}from"./pricing-Cs2--rZK.js";import{C as _}from"./check-Dc4DkCYO.js";import{S as c,E as b}from"./error-state-C8YtfWas.js";import{C as v,P as E}from"./card-C3jtoumP.js";import{T as U,d as I,e as g,c as n,a as q,b as i}from"./table-BmF3gmF6.js";import{f as x}from"./format-Cy1cCpwh.js";import{p as u}from"./parseISO-DLrPfdCa.js";import{P as R,a as B,S as D,f as z}from"./plan-display-Umz9Uolx.js";import{S as F}from"./sparkles-CS41x1q_.js";import{C as H}from"./circle-x-DDCBGl-0.js";import"./supabase-vendor-c_8iEK2M.js";import"./chart-vendor-CRVLmFP-.js";import"./en-US-BMcnMstS.js";/** 2 * @license lucide-react v0.468.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const K=j("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]]);/** 7 * @license lucide-react v0.468.0 - ISC 8 * 9 * This source code is licensed under the ISC license. 10 * See the LICENSE file in the root directory of this source tree. 11 */const V=j("ExternalLink",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);function Y(){const[s,r]=N.useState(null);async function l(a){if(a!=="lifetime"){r(a);try{window.location.href=await S(a)}catch(t){y.error(t instanceof Error?t.message:"Something went wrong."),r(null)}}}return e.jsx("div",{className:"grid gap-6 sm:grid-cols-2",children:L.map(a=>e.jsxs("div",{className:h("relative flex flex-col rounded-xl border bg-card p-6",a.highlighted&&"border-primary ring-1 ring-primary"),children:[a.badge&&e.jsx("span",{className:"absolute -top-3 left-6 rounded-full bg-primary px-3 py-0.5 text-xs font-semibold text-primary-foreground",children:a.badge}),e.jsx("h3",{className:"text-lg font-bold text-card-foreground",children:a.name}),e.jsxs("div",{className:"mt-2 flex items-baseline gap-1",children:[e.jsx("span",{className:"text-3xl font-extrabold text-card-foreground",children:a.price}),e.jsx("span",{className:"text-sm text-muted-foreground",children:a.cadence})]}),a.priceNote&&e.jsx("p",{className:"mt-1 text-xs font-semibold text-success",children:a.priceNote}),e.jsx("ul",{className:"mt-4 grow space-y-2",children:a.features.map(t=>e.jsxs("li",{className:"flex items-start gap-2 text-sm text-card-foreground",children:[e.jsx(_,{className:"mt-0.5 size-4 shrink-0 text-primary"}),e.jsx("span",{children:t})]},t))}),e.jsxs(d,{className:"mt-6 w-full",variant:a.highlighted?"default":"outline",onClick:()=>void l(a.id),disabled:s!==null,children:[s===a.id&&e.jsx(m,{className:"animate-spin"}),"Choose ",a.name]})]},a.id))})}function G(){const{user:s}=C();return k({queryKey:["invoices",s==null?void 0:s.id],enabled:!!s,queryFn:P,staleTime:5*6e4})}function O(s,r){return new Intl.NumberFormat("en-US",{style:"currency",currency:r.toUpperCase()}).format(s/100)}const Q={paid:"bg-success text-success-foreground",open:"bg-warning text-warning-foreground",void:"bg-muted text-muted-foreground",uncollectible:"bg-destructive text-destructive-foreground",draft:"bg-muted text-muted-foreground"};function X(){const{data:s,isPending:r,isError:l,refetch:a}=G();return e.jsxs(v,{className:"max-w-3xl gap-4 p-6",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-semibold text-card-foreground",children:"Billing history"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Invoices and receipts from Stripe."})]}),r?e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{className:"h-9 w-full"}),e.jsx(c,{className:"h-9 w-full"}),e.jsx(c,{className:"h-9 w-full"})]}):l?e.jsx(b,{title:"Couldn't load billing history",onRetry:()=>a()}):s.length===0?e.jsx("p",{className:"py-8 text-center text-sm text-muted-foreground",children:"No invoices yet â they'll appear here after your first payment."}):e.jsxs(U,{children:[e.jsx(I,{children:e.jsxs(g,{children:[e.jsx(n,{children:"Invoice"}),e.jsx(n,{children:"Date"}),e.jsx(n,{children:"Amount"}),e.jsx(n,{children:"Status"}),e.jsx(n,{className:"text-right",children:"Receipt"})]})}),e.jsx(q,{children:s.map(t=>e.jsxs(g,{children:[e.jsx(i,{className:"font-medium text-card-foreground",children:t.number??"â"}),e.jsx(i,{children:x(u(t.created),"MMM d, yyyy")}),e.jsx(i,{children:O(t.amount,t.currency)}),e.jsx(i,{children:e.jsx("span",{className:h("inline-block rounded-full px-2.5 py-0.5 text-xs font-semibold capitalize",(t.status&&Q[t.status])??"bg-muted text-muted-foreground"),children:t.status??"unknown"})}),e.jsx(i,{className:"text-right",children:t.pdfUrl||t.hostedUrl?e.jsxs("a",{href:t.pdfUrl??t.hostedUrl,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-sm font-medium text-primary hover:underline",children:[t.pdfUrl?e.jsx(K,{className:"size-3.5"}):e.jsx(V,{className:"size-3.5"}),t.pdfUrl?"PDF":"View"]}):e.jsx("span",{className:"text-sm text-muted-foreground",children:"â"})})]},t.id))})]})]})}function o({label:s,value:r}){return e.jsxs("div",{children:[e.jsx("dt",{className:"text-xs text-muted-foreground",children:s}),e.jsx("dd",{className:"mt-0.5 text-sm font-medium text-card-foreground",children:r})]})}function $({subscription:s,portalAction:r,onPortal:l}){const a=s.plan_type==="lifetime";return e.jsxs(v,{className:"max-w-3xl gap-0 p-6",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Current plan"}),e.jsx("p",{className:"text-2xl font-bold text-card-foreground",children:R[s.plan_type]})]}),e.jsx("span",{className:h("rounded-full px-2.5 py-1 text-xs font-semibold",D[s.status]),children:B[s.status]})]}),e.jsxs("dl",{className:"mt-6 grid gap-4 sm:grid-cols-2",children:[e.jsx(o,{label:"Amount paid",value:z(s.amount_paid)}),e.jsx(o,{label:"Purchased",value:x(u(s.created_at),"MMMM d, yyyy")}),a?e.jsx(o,{label:"Access",value:"Never expires"}):s.expires_at?e.jsx(o,{label:s.status==="active"?"Renews on":"Access until",value:x(u(s.expires_at),"MMMM d, yyyy")}):null]}),a?e.jsxs("div",{className:"mt-6 flex items-center gap-2 rounded-lg bg-primary/10 p-3 text-sm text-foreground",children:[e.jsx(F,{className:"size-4 shrink-0 text-primary"}),"You have lifetime access â every future update included."]}):e.jsxs("div",{className:"mt-6 flex flex-wrap gap-2",children:[e.jsxs(d,{onClick:()=>l("manage"),disabled:r!==null,children:[r==="manage"?e.jsx(m,{className:"animate-spin"}):e.jsx(A,{}),"Manage billing"]}),e.jsxs(d,{variant:"outline",onClick:()=>l("cancel"),disabled:r!==null,children:[r==="cancel"?e.jsx(m,{className:"animate-spin"}):e.jsx(H,{}),"Cancel subscription"]})]})]})}function xe(){const{state:s,subscription:r,refetch:l}=M(),[a,t]=N.useState(null);async function w(f){t(f);try{window.location.href=await T(f==="cancel"?"cancel":void 0)}catch(p){y.error(p instanceof Error?p.message:"Something went wrong."),t(null)}}return e.jsxs("div",{className:"space-y-6",children:[e.jsx(E,{title:"Subscription",description:"Manage your Social Flow plan and billing."}),s==="loading"?e.jsx(c,{className:"h-64 max-w-3xl rounded-xl"}):s==="error"?e.jsx(b,{title:"Couldn't load your subscription",onRetry:()=>l(),className:"max-w-3xl"}):r&&s==="active"?e.jsx($,{subscription:r,portalAction:a,onPortal:w}):e.jsxs("div",{className:"max-w-3xl space-y-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-semibold text-foreground",children:"Choose a plan"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"You don't have an active subscription. Pick a plan to activate the Social Flow extension â your dashboard and warm-up history stay available either way."})]}),e.jsx(Y,{})]}),s!=="loading"&&e.jsx(X,{})]})}
11export{xe as SubscriptionPage};
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.