1import{r as f,j as a}from"./utm-Cy4lOW-Q.js";import{T as s,B as p,X as m}from"./createLucideIcon-dPnAjM8L.js";import{t as x,B as y,v as b,w as h,x as u}from"./App-DvsMbaEo.js";import{aE as N,g as l,aF as w,d as S}from"./authContext-DDS04vem.js";import{ag as _}from"./useCreditBalance-HBJ5NF0b.js";import"./x-CsxYt7Kp.js";import"./index-BN2vGTnN.js";import"./index-BSpP8ib9.js";import"./onboardingFunnelEvents-DqAy5zM4.js";import"./homepageChatDraft-CFZkOD1a.js";import"./analytics-Zu3G7Flx.js";import"./useReferenceImages-CsBgr4xj.js";import"./medium-CNY0dU20.js";import"./rng-BlqX2qel.js";import"./urlUtils-DKzLRyb4.js";import"./v4-CXF1Uesh.js";import"./isArrayLike-web9Nrm3.js";import"./trendPulse-XRdIb8F0.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};t.SENTRY_RELEASE={id:"v20261009-gen9227-idb-noise-61c858d6"};var e=new t.Error().stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="654f242a-35b3-4b3c-ad49-166abc55d0a7",t._sentryDebugIdIdentifier="sentry-dbid-654f242a-35b3-4b3c-ad49-166abc55d0a7")}catch{}})();const I=t=>{if(t==null||t==="")return null;const e=typeof t=="number"?t:Number(t);return Number.isFinite(e)?e:null},v={monthly:"/mo",yearly:"/yr"},j=t=>t?v[t.toLowerCase()]??"":"",E=(t,e=null)=>{const r=I(t);return r===null?typeof t=="string"&&t.trim()!==""?t:"â":`${new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:Number.isInteger(r)?0:2}).format(r)}${j(e)}`},L=({subscriptions:t})=>{const e=x(),[r,i]=f.useState(null),g=async n=>{var d;i(n);try{const o=await e.mutateAsync({return_url:window.location.href,organization_id:n});(d=o.url)!=null&&d.startsWith("https://")&&window.open(o.url,"_blank","noopener,noreferrer")}catch(o){if(o instanceof N&&l(o,void 0,"error_code")===y.NoStripeCustomer){window.open(w,"_blank");return}const c=l(o,b);c&&S.error(c)}finally{i(null)}};return a.jsx("ul",{className:"flex flex-col gap-3","data-testid":"list-subscriptions",children:t.map(n=>a.jsxs("li",{"data-testid":"row-subscription","data-organization-name":n.organizationName,className:"border-g-border bg-g-surface-primary flex flex-col gap-4 roun
1ded-lg border p-4 md:flex-row md:items-center md:justify-between",children:[a.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[a.jsx(s,{variant:"label",className:"truncate","data-testid":"cell-subscription-plan",children:n.planName}),a.jsx(s,{variant:"caption1",className:"text-g-text-secondary truncate","data-testid":"cell-subscription-workspace",children:n.organizationName}),a.jsx(s,{variant:"body2",className:"text-g-text-secondary","data-testid":"cell-subscription-price",children:E(n.price,n.cycle)})]}),a.jsxs(p,{variant:"secondary",size:"sm",className:"shrink-0",loading:r===n.organizationId,onClick:()=>g(n.organizationId),"data-testid":"btn-subscription-manage",children:[a.jsx(_,{className:"size-4"}),"Manage billing"]})]},n.organizationId))})},W=()=>{const{data:t,isLoading:e,error:r}=h();return a.jsxs("div",{className:"mx-auto flex w-full max-w-3xl flex-col gap-6 p-6",children:[a.jsxs("div",{className:"flex flex-col gap-1",children:[a.jsx(s,{variant:"h4","data-testid":"title-billing",children:"Billing"}),a.jsx(s,{variant:"body2",className:"text-g-text-secondary",children:"Subscriptions across all workspaces you own. Manage payment details, invoices, or cancel from the Stripe billing portal."})]}),e&&a.jsxs("div",{className:"flex flex-col gap-3","data-testid":"loading-subscriptions",children:[a.jsx(m,{className:"h-24 w-full rounded-lg"}),a.jsx(m,{className:"h-24 w-full rounded-lg"})]}),!e&&r&&a.jsx(s,{variant:"body2",className:"text-g-text-secondary","data-testid":"msg-subscriptions-error",children:l(r,u)||u}),!e&&!r&&(t==null?void 0:t.length)===0&&a.jsx(s,{variant:"body2",className:"text-g-text-secondary","data-testid":"msg-no-subscriptions",children:"You don't have any active subscriptions. Only workspaces you own with an active plan appear here."}),!e&&!r&&!!(t!=null&&t.length)&&a.jsx(L,{subscriptions:t})]})};export{W 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.