1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[88],{10088:function(e,t,n){"use strict";n.d(t,{Y:function(){return h},a:function(){return v}});var a=n(85893);n(67294);var l=n(93967),s=n.n(l),r=n(48718),i=n(62244),o=n(72300);n(62450);var d=n(53870),u=n(55346);let c=e=>{let{brand:t}=e,n=null==t?void 0:t.toLowerCase();return"visa"===n?(0,a.jsx)(d.yT$,{size:"22px"}):"mastercard"===n?(0,a.jsx)(d.jcQ,{}):"amex"===n?(0,a.jsx)(u.ePy,{}):(0,a.jsx)(a.Fragment,{})};var m=n(26885),x=n.n(m);let h=e=>{let{limitToDefaultCard:t}=e,{data:n}=r.S.user.paymentMethods.list.useQuery(),l=t?null==n?void 0:n.filter(e=>e.is_default_method):n;return(0,a.jsx)("div",{children:null==l?void 0:l.map(e=>{var t,n,l,r;return(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsx)("div",{className:s()("grid grid-cols-1 gap-4",!(null==e?void 0:e.is_default_method)&&"opacity-50"),children:(0,a.jsx)(v,{isDefaultMethod:null==e?void 0:e.is_default_method,brand:null==e?void 0:null===(t=e.card)||void 0===t?void 0:t.brand,last4:null==e?void 0:null===(n=e.card)||void 0===n?void 0:n.last4})}),(0,a.jsx)("ul",{className:s()("flex gap-2",x().ul),children:(null==e?void 0:e.is_default_method)?null:(0,a.jsx)("li",{className:"flex items-center",children:(0,a.jsx)(p,{brand:null==e?void 0:null===(l=e.card)||void 0===l?void 0:l.brand,last4:null==e?void 0:null===(r=e.card)||void 0===r?void 0:r.last4,paymentMethodId:e.id})})})]},e.id)})})},v=e=>{let{brand:t,last4:n,isDefaultMethod:l}=e;return(0,a.jsx)(a.Fragment,{children:(0,a.jsxs)("p",{className:"flex gap-1 items-center my-0",children:[(0,a.jsx)("span",{className:x().fauxCreditCard,children:(0,a.jsx)(c,{brand:t})})," ","⢠⢠⢠⢠",n]})})},p=e=>{let{paymentMethodId:t,last4:n,brand:l}=e,{dialogId:s,openDialog:d,closeDialog:u}=(0,i.W)(),c=r.S.useUtils(),{mutate:m,isLoading:h}=r.S.user.paymentMethods.delete.useMutation({onSuccess:()=>{c.user.paymentMethods.list.refetch(),u()}}),v="remove-".concat(t);return(0,a.jsxs)("div",{children:[(0,a.jsx)("button",{type:"button",onClick:()=>d(v),className:x().aa,children:"Remove"}),s===v&&(0,a.jsxs)(i.Z.Root,{children:[(0,a.jsx)(i.Z.Header,{children:"Remove card"}),(0,a.jsx)(i.Z.Description,{children:"Are you sure you want to remove this card?"}),(0,a.jsx)("button",{type:"button",className:"btn-primary btn-warning w-full mt-6",onClick:()=>m({paymentMethodId:t}),disabled:h,children:h?(0,a.jsx)(o.Z,{}):"Remove ".concat(l," **** ").concat(n)})]})]})}},62244:function(e,t,n){"use strict";n.d(t,{W:function(){return x}});var a=n(85893),l=n(89121),s=n(84169),r=n(15103),i=n(48583),o=n(67294),d=n(86250),u=n(73731),c=n.n(u);let m=(0,r.cn)(null),x=()=>{let[e,t]=(0,i.KO)(m);return{dialogId:e,openDialog:e=>t(e),closeDialog:()=>t(null)}};t.Z={Root:e=>{let{children:t}=e,{dialogId:n,closeDialog:r}=x();return(0,a.jsx)(l.u,{show:null!==n,as:o.Fragment,children:(0,a.jsxs)(s.V,{as:"div",onClose:r,className:"fixed inset-0 z-50",children:[(0,a.jsx)(l.u.Child,{as:o.Fragment,enter:"ease-out duration-200",enterFrom:"opacity-0",enterTo:"opacity-100",leave:"ease-in duration-100",leaveFrom:"opacity-100",leaveTo:"opacity-0",children:(0,a.jsx)("div",{"aria-hidden":"true",className:c().overlay,style:{zIndex:50}})}),(0,a.jsx)(l.u.Child,{as:o.Fragment,enter:"ease-out duration-200",enterFrom:"opacity-0",enterTo:"opacity-100",leave:"ease-in duration-100",leaveFrom:"opacity-100",leaveTo:"opacity-0",children:(0,a.jsx)(s.V.Panel,{style:{position:"fixed",top:"50%",left:"50%",transform:"translate(-50%, -50%)",background:"white",borderRadius:"0.5rem",padding:"1.5rem",minWidth:"400px",zIndex:51,boxShadow:"0 10px 25px rgba(0, 0, 0, 0.2)"},children:t})})]})})},Header:e=>{let{children:t}=e,{closeDialog:n}=x();return(0,a.jsxs)("header",{className:"flex items-center justify-between mb-2",children:[(0,a.jsx)(s.V.Title,{as:"h1",children:t}),(0,a.jsx)("div",{children:(0,a.jsx)("button",{className:c().btnClose,onClick:n,"aria-label":"Close",children:(0,a.jsx)(d.bjh,{className:c().btnCloseIcon,size:24})})})]})},Description:e=>{let{children:t}=e;return(0,a.jsx)(s.V.Description,{as:"div",children:t})},Content:e=>{let{children:t}=e;return(0,a.jsx)("div",{children:t})}}},62450:function(e,t,n){"use strict";n.d(t,{pu:function(){return b}});var a=n(85893),l=n(67294),s=n(31439),r=n(86664),i=n(1604),o=n(93967),d=n.n(o),u=n(48718),c=n(38748),m=n.n(c),x=n(62244),h=n(72300),v=n(91434),p=n(37994);let b=e=>{let{paymentMethodId:t}
1=e,{data:n,submitPaymentMethod:o,stripeError:d,createBilling:c,updateBilling:p}=function(e){let t=!!e,n=(0,r.useStripe)(),a=(0,r.useElements)(),{closeDialog:s}=(0,x.W)(),[i,o]=(0,l.useState)(""),{data:d}=u.S.user.paymentMethods.byId.useQuery({paymentMethodId:e},{enabled:t}),c=u.S.useUtils(),m=u.S.user.paymentMethods.update.useMutation({onSuccess:()=>{c.user.paymentMethods.list.refetch(),s()}}),h=u.S.user.paymentMethods.create.useMutation({onSuccess:()=>{c.user.paymentMethods.list.refetch(),s()}}),v=l.useCallback(async t=>{e&&await m.mutateAsync({paymentMethodId:e,name:t.name})},[t]),p=l.useCallback(async e=>{if(!n||!a)return!1;let t=a.getElement(r.CardElement);if(!t)return!1;let{error:l,paymentMethod:s}=await n.createPaymentMethod({type:"card",card:t,billing_details:{name:e.name}});if(l||!s)return console.error("submitPaymentMethodCreate:",l),o((null==l?void 0:l.message)||""),!1;let i=await h.mutateAsync({paymentMethodId:s.id,name:e.name});return(null==i?void 0:i.success)!==!1},[n,a]);return{data:d,submitPaymentMethod:async function(e){o(""),t?await v(e):await p(e)},stripeError:i,createBilling:h,updateBilling:m,submitPaymentMethodUpdate:v,submitPaymentMethodCreate:p}}(t),b=l.useContext(v.Ec),j=!!t;return(0,a.jsx)("div",{className:m().container,children:(0,a.jsx)(s.l0,{onSubmit:e=>o(e),children:e=>{var t;return(0,a.jsxs)("form",{className:"flex flex-col gap-4",onSubmit:async t=>{t.preventDefault(),e.submit()},children:[(0,a.jsx)(y,{name:"name",label:"Name on card",initialValue:null==n?void 0:null===(t=n.billing_details)||void 0===t?void 0:t.name,validator:i.z.string().optional(),externalError:d}),!j&&(0,a.jsx)(f,{}),(0,a.jsx)("button",{type:"submit",className:"btn-primary mt-4",disabled:!e.isValid||c.isLoading||p.isLoading||(null==b?void 0:b.subscriptionName)==="Anonymous",children:c.isLoading||p.isLoading?(0,a.jsx)(h.Z,{}):"Save card"})]})}})})},j=e=>{let{errors:t}=e;return(0,a.jsx)("span",{className:"error-text",children:t.map(e=>e).join(" ")})},y=e=>{let{name:t,label:n,initialValue:l,isRequired:r,validator:o,externalError:u}=e;return(0,a.jsx)(s.gN,{name:t,initialValue:null!=l?l:"",onBlurValidate:o||i.z.string().min(2).max(50),children:e=>{let s=[...e.errors,u];return(0,a.jsxs)("div",{children:[(0,a.jsxs)("label",{className:"text-label",htmlFor:t,children:[n,r&&(0,a.jsx)("span",{className:"text-error",children:"*"})]}),(0,a.jsx)("input",{name:t,type:"text",className:d()("text-input mb-1",e.errors.length&&"text-input-error"),value:e.value,onBlur:e.onBlur,onChange:t=>e.setValue(t.target.value),placeholder:l||n}),(null==s?void 0:s.length)>1&&(0,a.jsx)(j,{errors:s.filter(e=>void 0!==e)})]})}})},f=()=>(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"text-label",htmlFor:"cardNumber",children:"Credit Card"}),(0,a.jsx)(r.CardElement,{onChange:e=>{console.log(e)},className:"text-input",options:p.k})]})},26885:function(e){e.exports={fauxCreditCard:"BillingCard_fauxCreditCard__E2xFQ",bold:"Billing
1Card_bold__WLQFw",ul:"BillingCard_ul__XvuLT",aa:"BillingCard_aa__jGjvb"}},73731:function(e){e.exports={overlay:"Dialog_overlay__XFvb2",bg:"Dialog_bg__zvXBC",btnClose:"Dialog_btnClose__YOtBa",btnCloseIcon:"Dialog_btnCloseIcon__lZG5t"}},38748:function(e){e.exports={title:"PaymentMethodForm_title__4oZsu",container:"PaymentMethodForm_container__kI2yf",miniLabel:"PaymentMethodForm_miniLabel__AC9nM"}}}]);
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.