UNPKG

@clerk/clerk-js

Version:
1 lines 22.1 kB
"use strict";(globalThis.webpackChunk_clerk_clerk_js=globalThis.webpackChunk_clerk_clerk_js||[]).push([["294"],{12264:function(e,t,o){o.r(t),o.d(t,{PaymentAttemptPage:()=>Z,PaymentAttemptsList:()=>d});var a=o(79109),r=o(16600),i=o(39082),n=o(55913),l=o(11576),c=o(64204),s=o(24676);let d=()=>{let{data:e,isLoading:t,count:o}=(0,l.usePaymentAttempts)(),i=(0,l.useSubscriberTypeLocalizationRoot)();return(0,a.tZ)(r.wQ,{page:1,onPageChange:e=>{},itemCount:o,pageCount:1,itemsPerPage:10,isLoading:t,emptyStateLocalizationKey:(0,c.localizationKeys)("".concat(i,".billingPage.paymentHistorySection.empty")),headers:[(0,c.localizationKeys)("".concat(i,".billingPage.paymentHistorySection.tableHeader__date")),(0,c.localizationKeys)("".concat(i,".billingPage.paymentHistorySection.tableHeader__amount")),(0,c.localizationKeys)("".concat(i,".billingPage.paymentHistorySection.tableHeader__status"))],rows:e.map(e=>(0,a.tZ)(u,{paymentAttempt:e},e.id))})},u=e=>{let{paymentAttempt:t}=e,{id:o,amount:l,failedAt:d,paidAt:u,updatedAt:p,status:m}=t,{navigate:h}=(0,s.useRouter)();return(0,a.BX)(r.Uk,{onClick:()=>{h("payment-attempt/".concat(o))},children:[(0,a.BX)(c.Td,{sx:{cursor:"pointer"},children:[(0,a.tZ)(c.Text,{variant:"subtitle",children:(0,i.p)(u||d||p,"long")}),(0,a.tZ)(c.Text,{colorScheme:"secondary",variant:"caption",truncate:!0,sx:e=>({marginTop:e.space.$0x5}),children:(0,n.L)(o)})]}),(0,a.tZ)(c.Td,{sx:{cursor:"pointer"},children:(0,a.BX)(c.Text,{children:[l.currencySymbol,l.amountFormatted]})}),(0,a.tZ)(c.Td,{children:(0,a.tZ)(c.Badge,{colorScheme:"paid"===m?"success":"failed"===m?"danger":"primary",sx:{textTransform:"capitalize"},children:m})})]})};o(45261),o(70957),o(24551),o(22349),o(65223);var p=o(83799),m=o(7901),h=o(9117),y=o(92654),g=o(28e3),b=o(18018),S=o(12464),x=o(96519);let Z=()=>{var e,t;let{params:o,navigate:r}=(0,s.useRouter)(),l=(0,b.sC)(),{organization:d}=(0,p.o8)(),u=(0,b.xr)(),{t:S,translateError:x}=(0,c.useLocalizations)(),Z=(0,p.cL)(),{data:v,isLoading:$,error:f}=(0,m.default)(o.paymentAttemptId?{type:"payment-attempt",id:o.paymentAttemptId,orgId:"organization"===l?null==d?void 0:d.id:void 0}:null,()=>Z.billing.getPaymentAttempt({id:o.paymentAttemptId,orgId:"organization"===l?null==d?void 0:d.id:void 0})),B=null==v?void 0:v.subscriptionItem;return $?(0,a.tZ)(c.Box,{sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%"},children:(0,a.tZ)(c.Spinner,{colorScheme:"primary",sx:{margin:"auto",display:"block"},elementDescriptor:c.descriptors.spinner})}):(0,a.BX)(a.HY,{children:[(0,a.tZ)(y.h.Root,{sx:e=>({borderBlockEndWidth:e.borderWidths.$normal,borderBlockEndStyle:e.borderStyles.$solid,borderBlockEndColor:e.colors.$borderAlpha100,marginBlockEnd:e.space.$4,paddingBlockEnd:e.space.$4}),children:(0,a.tZ)(y.h.BackLink,{onClick:()=>void r("../../",{searchParams:new URLSearchParams("tab=payments")}),children:(0,a.tZ)(y.h.Title,{localizationKey:(0,c.localizationKeys)("".concat(u,".billingPage.start.headerTitle__payments")),textVariant:"h2"})})}),v?(0,a.BX)(c.Box,{elementDescriptor:c.descriptors.paymentAttemptRoot,as:"article",sx:e=>({borderWidth:e.borderWidths.$normal,borderStyle:e.borderStyles.$solid,borderColor:e.colors.$borderAlpha100,borderRadius:e.radii.$lg,overflow:"clip"}),children:[(0,a.BX)(c.Box,{elementDescriptor:c.descriptors.paymentAttemptHeader,as:"header",sx:e=>({padding:e.space.$4,background:e.colors.$neutralAlpha25,display:"flex",justifyContent:"space-between",alignItems:"flex-start"}),children:[(0,a.BX)(c.Span,{elementDescriptor:c.descriptors.paymentAttemptHeaderTitleContainer,children:[(0,a.tZ)(c.Heading,{elementDescriptor:c.descriptors.paymentAttemptHeaderTitle,textVariant:"h2",localizationKey:(0,i.p)(v.paidAt||v.failedAt||v.updatedAt,"long")}),(0,a.BX)(c.Span,{sx:e=>({display:"flex",alignItems:"center",gap:e.space.$0x25,color:e.colors.$colorMutedForeground}),children:[(0,a.tZ)(z,{copyLabel:"Copy payment attempt ID",text:v.id}),(0,a.tZ)(c.Text,{colorScheme:"secondary",variant:"subtitle",children:(0,n.L)(v.id)})]})]}),(0,a.tZ)(c.Badge,{elementDescriptor:c.descriptors.paymentAttemptHeaderBadge,colorScheme:"paid"===v.status?"success":"failed"===v.status?"danger":"primary",sx:{textTransform:"capitalize"},children:v.status})]}),(0,a.tZ)(c.Box,{elementDescriptor:c.descriptors.paymentAttemptBody,sx:e=>({padding:e.space.$4}),children:B&&(0,a.BX)(g.a.Root,{children:[(0,a.BX)(g.a.Group,{children:[(0,a.tZ)(g.a.Title,{title:B.plan.name}),(0,a.tZ)(g.a.Description,{prefix:"annual"===B.planPeriod?"x12":void 0,text:"".concat(B.plan.currencySymbol).concat("month"===B.planPeriod?B.plan.amountFormatted:B.plan.annualMonthlyAmountFormatted)})]}),(0,a.BX)(g.a.Group,{borderTop:!0,variant:"tertiary",children:[(0,a.tZ)(g.a.Title,{title:(0,c.localizationKeys)("commerce.subtotal")}),(0,a.tZ)(g.a.Description,{text:"".concat(null==(e=B.amount)?void 0:e.currencySymbol).concat(null==(t=B.amount)?void 0:t.amountFormatted)})]}),B.credit&&B.credit.amount.amount>0&&(0,a.BX)(g.a.Group,{variant:"tertiary",children:[(0,a.tZ)(g.a.Title,{title:(0,c.localizationKeys)("commerce.credit")}),(0,a.tZ)(g.a.Description,{text:"- ".concat(B.credit.amount.currencySymbol).concat(B.credit.amount.amountFormatted)})]})]})}),(0,a.BX)(c.Box,{elementDescriptor:c.descriptors.paymentAttemptFooter,as:"footer",sx:e=>({paddingInline:e.space.$4,paddingBlock:e.space.$3,background:e.colors.$neutralAlpha25,borderBlockStartWidth:e.borderWidths.$normal,borderBlockStartStyle:e.borderStyles.$solid,borderBlockStartColor:e.colors.$borderAlpha100,display:"flex",justifyContent:"space-between"}),children:[(0,a.tZ)(c.Text,{variant:"h3",localizationKey:(0,c.localizationKeys)("commerce.totalDue"),elementDescriptor:c.descriptors.paymentAttemptFooterLabel}),(0,a.BX)(c.Span,{elementDescriptor:c.descriptors.paymentAttemptFooterValueContainer,sx:e=>({display:"flex",alignItems:"center",gap:e.space.$2x5}),children:[(0,a.tZ)(c.Text,{variant:"caption",colorScheme:"secondary",elementDescriptor:c.descriptors.paymentAttemptFooterCurrency,sx:{textTransform:"uppercase"},children:v.amount.currency}),(0,a.BX)(c.Text,{variant:"h3",elementDescriptor:c.descriptors.paymentAttemptFooterValue,children:[v.amount.currencySymbol,v.amount.amountFormatted]})]})]})]}):(0,a.tZ)(c.Box,{sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%"},children:(0,a.tZ)(h.b,{variant:"danger",colorScheme:"danger",children:f?x(f.errors[0]):S((0,c.localizationKeys)("".concat(u,".billingPage.paymentHistorySection.notFound")))})})]})};function z(e){let{text:t,copyLabel:o="Copy"}=e,{onCopy:r,hasCopied:i}=(0,S.VP)(t);return(0,a.tZ)(c.Button,{elementDescriptor:c.descriptors.paymentAttemptCopyButton,variant:"unstyled",onClick:r,sx:e=>({color:"inherit",width:e.sizes.$4,height:e.sizes.$4,padding:0,borderRadius:e.radii.$sm,"&:focus-visible":{outline:"2px solid",outlineColor:e.colors.$colorRing}}),focusRing:!1,"aria-label":i?"Copied":o,children:(0,a.tZ)(c.Icon,{size:"sm",icon:i?x.Jr:x.CK,"aria-hidden":!0})})}},75058:function(e,t,o){o.d(t,{hG:()=>A,ph:()=>T,fC:()=>f,OL:()=>P}),o(65223);var a=o(79109),r=o(83799),i=o(69144),n=o(92418),l=o(2672),c=o(70431),s=o(19460),d=o(68487),u=o(68849),p=o(88870),m=o(11576),h=o(64204);let y=e=>(0,a.tZ)(h.Box,{sx:[e=>({height:e.space.$2,width:"100%",borderRadius:e.radii.$md,background:e.colors.$neutralAlpha100}),e.sx]}),g=()=>(0,a.tZ)(y,{sx:e=>({height:e.space.$10,width:"100%"})}),b=e=>(0,a.tZ)(h.Flex,{direction:"col",gap:2,children:e.children}),S=()=>(0,a.tZ)(h.Box,{"aria-label":"Loading...",sx:{position:"relative",minHeight:0,flex:1,overflowY:"auto"},children:(0,a.BX)(h.Flex,{direction:"col",gap:5,children:[(0,a.BX)(b,{children:[(0,a.tZ)(y,{sx:e=>({height:e.space.$3,width:e.sizes.$24})}),(0,a.tZ)(g,{})]}),(0,a.BX)(h.Grid,{columns:2,gap:4,children:[(0,a.BX)(b,{children:[(0,a.tZ)(y,{sx:e=>({height:e.space.$3,width:e.sizes.$20})}),(0,a.tZ)(g,{})]}),(0,a.BX)(b,{children:[(0,a.tZ)(y,{sx:e=>({height:e.space.$3,width:e.sizes.$24})}),(0,a.tZ)(g,{})]})]}),(0,a.BX)(b,{children:[(0,a.tZ)(y,{sx:e=>({height:e.space.$3,width:e.sizes.$16})}),(0,a.tZ)(g,{})]}),(0,a.BX)(b,{children:[(0,a.tZ)(y,{}),(0,a.tZ)(y,{}),(0,a.tZ)(y,{sx:{width:"66.666667%"}})]})]})}),[x,Z]=(0,r.uH)("AddPaymentSourceRoot"),z=e=>{let{children:t,checkout:o,...n}=e,l=(0,m.useSubscriberTypeContext)(),c=(0,i.useRef)(null),{t:s}=(0,h.useLocalizations)(),[d,p]=(0,i.useState)(void 0),[y,g]=(0,i.useState)(void 0),[b,S]=(0,i.useState)(void 0),Z=(e=>{let t=(0,h.useAppearance)().parsedInternalTheme;return(0,i.useMemo)(()=>{if(!e)return;let{colors:o,fontWeights:a,fontSizes:r,radii:i,space:n}=t;return{colorPrimary:(0,u.Aj)(e,o.$primary500,o.$colorBackground),colorBackground:(0,u.Aj)(e,o.$colorInput,o.$colorBackground),colorText:(0,u.Aj)(e,o.$colorForeground,o.$colorBackground),colorTextSecondary:(0,u.Aj)(e,o.$colorMutedForeground,o.$colorBackground),colorSuccess:(0,u.Aj)(e,o.$success500,o.$colorBackground),colorDanger:(0,u.Aj)(e,o.$danger500,o.$colorBackground),colorWarning:(0,u.Aj)(e,o.$warning500,o.$colorBackground),fontWeightNormal:(0,u.uj)(e,"font-weight",a.$normal.toString()),fontWeightMedium:(0,u.uj)(e,"font-weight",a.$medium.toString()),fontWeightBold:(0,u.uj)(e,"font-weight",a.$bold.toString()),fontSizeXl:(0,u.uj)(e,"font-size",r.$xl),fontSizeLg:(0,u.uj)(e,"font-size",r.$lg),fontSizeSm:(0,u.uj)(e,"font-size",r.$md),fontSizeXs:(0,u.uj)(e,"font-size",r.$sm),borderRadius:(0,u.uj)(e,"border-radius",i.$lg),spacingUnit:(0,u.uj)(e,"padding",n.$1)}},[t,e])})(c.current);return(0,a.BX)(x.Provider,{value:{value:{headerTitle:d,headerSubtitle:y,submitLabel:b,setHeaderTitle:p,setHeaderSubtitle:g,setSubmitLabel:S,checkout:o,...n}},children:[(0,a.tZ)("div",{ref:c,style:{display:"none"}}),(0,a.tZ)(r.pe,{checkout:o,for:l,stripeAppearance:Z,paymentDescription:s((0,h.localizationKeys)((null==o?void 0:o.planPeriod)==="month"?"commerce.paymentSource.applePayDescription.monthly":"commerce.paymentSource.applePayDescription.annual")),children:t})]})},v=e=>{let{isProviderReady:t}=(0,r.Wh)();return t?null:e.children},$=e=>{let{isProviderReady:t}=(0,r.Wh)();return t?(0,a.tZ)(a.HY,{children:e.children}):null},f=e=>{let{children:t,...o}=e;return(0,a.BX)(z,{...o,children:[(0,a.tZ)(v,{children:(0,a.tZ)(h.Flex,{direction:"row",align:"center",justify:"center",sx:e=>({width:"100%",minHeight:e.sizes.$60}),children:(0,a.tZ)(h.Spinner,{size:"lg",colorScheme:"primary",elementDescriptor:h.descriptors.spinner})})}),(0,a.tZ)($,{children:(0,a.tZ)(w,{children:t})})]})},B=(e,t)=>{(0,i.useRef)(()=>{t(e)}),(0,i.useEffect)(()=>{t(e)},[e,t])},T=e=>{let{text:t}=e,{setHeaderTitle:o}=Z();return B(t,o),null},A=e=>{let{text:t}=e,{setHeaderSubtitle:o}=Z();return B(t,o),null},P=e=>{let{text:t}=e,{setSubmitLabel:o}=Z();return B(t,o),null},w=e=>{let{children:t}=e,{headerTitle:o,headerSubtitle:i,submitLabel:u,checkout:y,onSuccess:g,cancelAction:b}=Z(),x=(0,l.useCardState)(),z=(0,m.useSubscriberTypeLocalizationRoot)(),{isFormReady:v,submit:$,reset:f}=(0,r.Wh)(),B=async e=>{e.preventDefault(),x.setLoading(),x.setError(void 0);let{data:t,error:o}=await $();if(!o)try{await g(t)}catch(e){(0,p.S3)(e,[],x.setError)}finally{x.setIdle(),f()}};return(0,a.tZ)(d.Y,{headerTitle:o,headerSubtitle:i,children:(0,a.BX)(c.l.Root,{onSubmit:B,sx:e=>({display:"flex",flexDirection:"column",rowGap:e.space.$3}),children:[t,(0,a.tZ)(r.Y7,{fallback:(0,a.tZ)(S,{})}),(0,a.tZ)(n.Z.Alert,{children:x.error}),(0,a.tZ)(s.A,{isDisabled:!v,submitLabel:null!=u?u:(0,h.localizationKeys)("".concat(z,".billingPage.paymentSourcesSection.formButtonPrimary__add")),onReset:b,hideReset:!b,sx:{flex:y?1:void 0}})]})})}},57106:function(e,t,o){o.d(t,{j:()=>n});var a=o(79109),r=o(64204),i=o(96519);let n=e=>{let{paymentSource:t}=e;return(0,a.BX)(r.Flex,{sx:{overflow:"hidden"},gap:2,align:"baseline",elementDescriptor:r.descriptors.paymentSourceRow,children:[(0,a.tZ)(r.Icon,{icon:"card"===t.paymentMethod?i.aB:i.Nn,sx:{alignSelf:"center"},elementDescriptor:r.descriptors.paymentSourceRowIcon}),(0,a.tZ)(r.Text,{sx:e=>({color:e.colors.$colorForeground,textTransform:"capitalize"}),truncate:!0,elementDescriptor:r.descriptors.paymentSourceRowType,children:"card"===t.paymentMethod?t.cardType:t.paymentMethod}),(0,a.tZ)(r.Text,{sx:e=>({color:e.colors.$colorMutedForeground}),variant:"caption",truncate:!0,elementDescriptor:r.descriptors.paymentSourceRowValue,children:"card"===t.paymentMethod?"⋯ ".concat(t.last4):null}),t.isDefault&&(0,a.tZ)(r.Badge,{elementDescriptor:r.descriptors.paymentSourceRowBadge,elementId:r.descriptors.paymentSourceRowBadge.setId("default"),localizationKey:(0,r.localizationKeys)("badge__default")}),"expired"===t.status&&(0,a.tZ)(r.Badge,{elementDescriptor:r.descriptors.paymentSourceRowBadge,elementId:r.descriptors.paymentSourceRowBadge.setId("expired"),colorScheme:"danger",localizationKey:(0,r.localizationKeys)("badge__expired")})]})}},86054:function(e,t,o){o.d(t,{Hw:()=>$});var a=o(75058);o(50725),o(838);var r=o(79109),i=o(83799),n=o(69144),l=o(2672),c=o(58104),s=o(19655),d=o(33009),u=o(88870),p=o(8969),m=o(22189),h=o(11576),y=o(64204),g=o(99805),b=o(44709),S=o(57106),x=o(28e3);let Z=()=>{let{t:e}=(0,y.useLocalizations)();return(0,r.BX)(y.Box,{sx:e=>({background:e.colors.$neutralAlpha50,padding:e.space.$2x5,borderRadius:e.radii.$md,borderWidth:e.borderWidths.$normal,borderStyle:e.borderStyles.$solid,borderColor:e.colors.$borderAlpha100,display:"flex",flexDirection:"column",rowGap:e.space.$2,position:"relative"}),children:[(0,r.tZ)(y.Box,{sx:e=>({position:"absolute",inset:0,background:"repeating-linear-gradient(-45deg,".concat(e.colors.$warningAlpha100,",").concat(e.colors.$warningAlpha100," 6px,").concat(e.colors.$warningAlpha150," 6px,").concat(e.colors.$warningAlpha150," 12px)"),maskImage:"linear-gradient(transparent 20%, black)",pointerEvents:"none"})}),(0,r.BX)(y.Box,{sx:{display:"flex",alignItems:"baseline",justifyContent:"space-between"},children:[(0,r.tZ)(y.Text,{variant:"caption",colorScheme:"body",localizationKey:(0,y.localizationKeys)("commerce.paymentSource.dev.testCardInfo")}),(0,r.tZ)(y.Text,{variant:"caption",sx:e=>({color:e.colors.$warning500,fontWeight:e.fontWeights.$semibold}),localizationKey:(0,y.localizationKeys)("commerce.paymentSource.dev.developmentMode")})]}),(0,r.BX)(x.a.Root,{children:[(0,r.BX)(x.a.Group,{variant:"tertiary",children:[(0,r.tZ)(x.a.Title,{title:(0,y.localizationKeys)("commerce.paymentSource.dev.cardNumber")}),(0,r.tZ)(x.a.Description,{text:"4242 4242 4242 4242"})]}),(0,r.BX)(x.a.Group,{variant:"tertiary",children:[(0,r.tZ)(x.a.Title,{title:(0,y.localizationKeys)("commerce.paymentSource.dev.expirationDate")}),(0,r.tZ)(x.a.Description,{text:"11/44"})]}),(0,r.BX)(x.a.Group,{variant:"tertiary",children:[(0,r.tZ)(x.a.Title,{title:(0,y.localizationKeys)("commerce.paymentSource.dev.cvcZip")}),(0,r.tZ)(x.a.Description,{text:e((0,y.localizationKeys)("commerce.paymentSource.dev.anyNumbers"))})]})]})]})},z=(0,l.withCardStateProvider)(e=>{let{onSuccess:t}=e,{close:o}=(0,b.XC)(),n=(0,i.cL)(),l=(0,h.useSubscriberTypeContext)(),c=(0,h.useSubscriberTypeLocalizationRoot)(),s=async e=>{let a="organization"===l?null==n?void 0:n.organization:n.user;return await (null==a?void 0:a.addPaymentSource(e)),t(),o(),Promise.resolve()};return(0,r.BX)(a.fC,{onSuccess:s,cancelAction:o,children:[(0,r.tZ)(a.ph,{text:(0,y.localizationKeys)("".concat(c,".billingPage.paymentSourcesSection.add"))}),(0,r.tZ)(a.hG,{text:(0,y.localizationKeys)("".concat(c,".billingPage.paymentSourcesSection.addSubtitle"))}),(0,r.tZ)(m.P,{children:(0,r.tZ)(Z,{})})]})}),v=e=>{let{paymentSource:t,revalidate:o}=e,{close:a}=(0,b.XC)(),c=(0,l.useCardState)(),s=(0,h.useSubscriberTypeContext)(),{organization:d}=(0,i.o8)(),m=(0,h.useSubscriberTypeLocalizationRoot)(),g=(0,n.useRef)("".concat("card"===t.paymentMethod?t.cardType:t.paymentMethod," ").concat("card"===t.paymentMethod?"⋯ ".concat(t.last4):"-"));if(!g.current)return null;let S=async()=>{await t.remove({orgId:"organization"===s?null==d?void 0:d.id:void 0}).then(o).catch(e=>{(0,u.S3)(e,[],c.setError)})};return(0,r.tZ)(p.LE,{title:(0,y.localizationKeys)("".concat(m,".billingPage.paymentSourcesSection.removeResource.title")),messageLine1:(0,y.localizationKeys)("".concat(m,".billingPage.paymentSourcesSection.removeResource.messageLine1"),{identifier:g.current}),messageLine2:(0,y.localizationKeys)("".concat(m,".billingPage.paymentSourcesSection.removeResource.messageLine2")),successMessage:(0,y.localizationKeys)("".concat(m,".billingPage.paymentSourcesSection.removeResource.successMessage"),{paymentSource:g.current}),deleteResource:S,onSuccess:a,onReset:a})},$=(0,l.withCardStateProvider)(()=>{let e=(0,i.cL)(),t=(0,h.useSubscriberTypeContext)(),o=(0,h.useSubscriberTypeLocalizationRoot)(),a="organization"===t?null==e?void 0:e.organization:e.user,{data:l,isLoading:d,revalidate:u}=(0,h.usePaymentMethods)(),p=(0,n.useMemo)(()=>l.sort((e,t)=>e.isDefault&&!t.isDefault?-1:1),[l]);return a?(0,r.tZ)(s.zd.Root,{title:(0,y.localizationKeys)("".concat(o,".billingPage.paymentSourcesSection.title")),centered:!1,id:"paymentSources",sx:e=>({flex:1,borderTopWidth:e.borderWidths.$normal,borderTopStyle:e.borderStyles.$solid,borderTopColor:e.colors.$borderAlpha100}),children:(0,r.tZ)(g.a.Root,{children:(0,r.tZ)(s.zd.ItemList,{id:"paymentSources",disableAnimation:!0,children:d?(0,r.tZ)(c.m,{}):(0,r.BX)(r.HY,{children:[p.map(e=>(0,r.BX)(n.Fragment,{children:[(0,r.BX)(s.zd.Item,{id:"paymentSources",children:[(0,r.tZ)(S.j,{paymentSource:e}),(0,r.tZ)(f,{paymentSource:e,revalidate:u})]}),(0,r.tZ)(g.a.Open,{value:"remove-".concat(e.id),children:(0,r.tZ)(g.a.Card,{variant:"destructive",children:(0,r.tZ)(v,{paymentSource:e,revalidate:u})})})]},e.id)),(0,r.tZ)(g.a.Trigger,{value:"add",children:(0,r.tZ)(s.zd.ArrowButton,{id:"paymentSources",localizationKey:(0,y.localizationKeys)("".concat(o,".billingPage.paymentSourcesSection.add"))})}),(0,r.tZ)(g.a.Open,{value:"add",children:(0,r.tZ)(g.a.Card,{children:(0,r.tZ)(z,{onSuccess:u})})})]})})})}):null}),f=e=>{let{paymentSource:t,revalidate:o}=e,{open:a}=(0,b.XC)(),n=(0,l.useCardState)(),{organization:c}=(0,i.o8)(),s=(0,h.useSubscriberTypeContext)(),p=(0,h.useSubscriberTypeLocalizationRoot)(),m=[{label:(0,y.localizationKeys)("".concat(p,".billingPage.paymentSourcesSection.actionLabel__remove")),isDestructive:!0,onClick:()=>a("remove-".concat(t.id)),isDisabled:!t.isRemovable}];return t.isDefault||m.unshift({label:(0,y.localizationKeys)("".concat(p,".billingPage.paymentSourcesSection.actionLabel__default")),isDestructive:!1,onClick:()=>{t.makeDefault({orgId:"organization"===s?null==c?void 0:c.id:void 0}).then(o).catch(e=>{(0,u.S3)(e,[],n.setError)})},isDisabled:!1}),(0,r.tZ)(d.a,{actions:m})}},95746:function(e,t,o){o.d(t,{u:()=>l});var a=o(79109),r=o(64204);let i={active:"badge__activePlan",upcoming:"badge__upcomingPlan",past_due:"badge__pastDuePlan"},n={active:"secondary",upcoming:"primary",past_due:"warning"},l=e=>{let{subscription:t,elementDescriptor:o}=e;return(0,a.tZ)(r.Badge,{elementDescriptor:o,colorScheme:n[t.status],localizationKey:(0,r.localizationKeys)(i[t.status])})}},91800:function(e,t,o){o.d(t,{b:()=>p});var a=o(79109),r=o(69144),i=o(19655),n=o(8969),l=o(11576),c=o(64204),s=o(96519),d=o(24676),u=o(95746);function p(e){let{title:t,arrowButtonText:o,arrowButtonEmptyText:p}=e,{captionForSubscription:m,openSubscriptionDetails:h}=(0,l.usePlansContext)(),y=(0,l.useSubscriberTypeLocalizationRoot)(),g=(0,l.useSubscriberTypeContext)(),{subscriptionItems:b}=(0,l.useSubscription)(),S=(0,n.N2)(e=>e({permission:"org:sys_billing:manage"})||"user"===g),{navigate:x}=(0,d.useRouter)(),{commerceSettings:Z}=(0,l.useEnvironment)(),z=(0,r.useMemo)(()=>b.sort((e,t)=>"active"===e.status&&"active"!==t.status?-1:("active"===t.status&&e.status,1)),[b]);return(0,a.BX)(i.zd.Root,{id:"subscriptionsList",title:t,centered:!1,sx:e=>({borderTop:"none",paddingTop:e.space.$1}),children:[b.length>0&&(0,a.BX)(c.Table,{tableHeadVisuallyHidden:!0,children:[(0,a.tZ)(c.Thead,{children:(0,a.BX)(c.Tr,{children:[(0,a.tZ)(c.Th,{localizationKey:(0,c.localizationKeys)("".concat(y,".billingPage.subscriptionsListSection.tableHeader__plan"))}),(0,a.tZ)(c.Th,{localizationKey:(0,c.localizationKeys)("".concat(y,".billingPage.subscriptionsListSection.tableHeader__startDate"))}),(0,a.tZ)(c.Th,{localizationKey:(0,c.localizationKeys)("".concat(y,".billingPage.subscriptionsListSection.tableHeader__edit"))})]})}),(0,a.tZ)(c.Tbody,{children:z.map(e=>(0,a.BX)(c.Tr,{children:[(0,a.tZ)(c.Td,{children:(0,a.BX)(c.Col,{gap:1,children:[(0,a.BX)(c.Flex,{align:"center",gap:1,children:[(0,a.tZ)(c.Icon,{icon:s.ou,sx:e=>({width:e.sizes.$4,height:e.sizes.$4,opacity:e.opacity.$inactive})}),(0,a.tZ)(c.Text,{variant:"subtitle",sx:e=>({marginRight:e.sizes.$1}),children:e.plan.name}),z.length>1||e.canceledAtDate?(0,a.tZ)(u.u,{subscription:e}):null]}),(!e.plan.isDefault||"upcoming"===e.status)&&(0,a.tZ)(c.Text,{variant:"caption",colorScheme:"secondary",localizationKey:m(e)})]})}),(0,a.tZ)(c.Td,{sx:e=>({textAlign:"right"}),children:(0,a.BX)(c.Text,{variant:"subtitle",children:[e.plan.currencySymbol,"annual"===e.planPeriod?e.plan.annualAmountFormatted:e.plan.amountFormatted,(e.plan.amount>0||e.plan.annualAmount>0)&&(0,a.tZ)(c.Span,{sx:e=>({color:e.colors.$colorMutedForeground,textTransform:"lowercase",":before":{content:'"/"',marginInline:e.space.$1}}),localizationKey:"annual"===e.planPeriod?(0,c.localizationKeys)("commerce.year"):(0,c.localizationKeys)("commerce.month")})]})}),(0,a.tZ)(c.Td,{sx:e=>({textAlign:"right"}),children:(0,a.tZ)(c.Button,{"aria-label":"Manage subscription",onClick:e=>h(e),variant:"bordered",colorScheme:"secondary",isDisabled:!S,sx:e=>({width:e.sizes.$6,height:e.sizes.$6}),children:(0,a.tZ)(c.Icon,{icon:s.tc,sx:e=>({width:e.sizes.$4,height:e.sizes.$4,opacity:e.opacity.$inactive})})})})]},e.id))})]}),Z.billing.user.hasPaidPlans&&"user"===g||Z.billing.organization.hasPaidPlans&&"organization"===g?(0,a.tZ)(i.zd.ArrowButton,{id:"subscriptionsList",textLocalizationKey:b.length>0?o:p,sx:[e=>({justifyContent:"start",height:e.sizes.$8})],leftIcon:b.length>0?s.Ic:s.v3,leftIconSx:e=>({width:e.sizes.$4,height:e.sizes.$4}),onClick:()=>void x("plans")}):null]})}}}]);