@bunnyapp/components 1.0.14 → 1.0.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/dist/cjs/index.js +344 -561
  2. package/dist/cjs/src/components/PaymentForm/CheckoutFooter.d.ts +3 -4
  3. package/dist/cjs/src/components/PaymentForm/DemoPay/hooks/usePay.d.ts +4 -6
  4. package/dist/cjs/src/components/PaymentForm/PaymentForm.d.ts +1 -2
  5. package/dist/cjs/src/components/PaymentForm/PaymentFormTypes.d.ts +3 -28
  6. package/dist/cjs/src/components/PaymentForm/PaymentMethodDetails.d.ts +1 -2
  7. package/dist/cjs/src/components/PaymentForm/PaymentMethodSelector.d.ts +3 -3
  8. package/dist/cjs/src/components/PaymentForm/Stripe/StripeForm.d.ts +1 -1
  9. package/dist/cjs/src/components/PaymentForm/Stripe/hooks/usePay.d.ts +4 -5
  10. package/dist/cjs/src/components/Signup/PaymentForms.d.ts +1 -2
  11. package/dist/cjs/src/contexts/PaymentContext.d.ts +2 -0
  12. package/dist/esm/index.js +347 -564
  13. package/dist/esm/src/components/PaymentForm/CheckoutFooter.d.ts +3 -4
  14. package/dist/esm/src/components/PaymentForm/DemoPay/hooks/usePay.d.ts +4 -6
  15. package/dist/esm/src/components/PaymentForm/PaymentForm.d.ts +1 -2
  16. package/dist/esm/src/components/PaymentForm/PaymentFormTypes.d.ts +3 -28
  17. package/dist/esm/src/components/PaymentForm/PaymentMethodDetails.d.ts +1 -2
  18. package/dist/esm/src/components/PaymentForm/PaymentMethodSelector.d.ts +3 -3
  19. package/dist/esm/src/components/PaymentForm/Stripe/StripeForm.d.ts +1 -1
  20. package/dist/esm/src/components/PaymentForm/Stripe/hooks/usePay.d.ts +4 -5
  21. package/dist/esm/src/components/Signup/PaymentForms.d.ts +1 -2
  22. package/dist/esm/src/contexts/PaymentContext.d.ts +2 -0
  23. package/dist/index.d.ts +1 -3
  24. package/package.json +4 -3
  25. package/dist/cjs/src/components/Checkout/InvoiceCheckout.d.ts +0 -8
  26. package/dist/cjs/src/components/Transactions/DocumentNameEnum.d.ts +0 -4
  27. package/dist/cjs/src/components/icons/BunnyFooterIcon.d.ts +0 -4
  28. package/dist/cjs/src/consts/paymentConsts.d.ts +0 -16
  29. package/dist/cjs/src/graphql/mutations/quoteCreate.d.ts +0 -9
  30. package/dist/cjs/src/graphql/queries/getInvoice.d.ts +0 -7
  31. package/dist/cjs/src/graphql/queries/getSubscription.d.ts +0 -12
  32. package/dist/esm/src/components/Checkout/InvoiceCheckout.d.ts +0 -8
  33. package/dist/esm/src/components/Transactions/DocumentNameEnum.d.ts +0 -4
  34. package/dist/esm/src/components/icons/BunnyFooterIcon.d.ts +0 -4
  35. package/dist/esm/src/consts/paymentConsts.d.ts +0 -16
  36. package/dist/esm/src/graphql/mutations/quoteCreate.d.ts +0 -9
  37. package/dist/esm/src/graphql/queries/getInvoice.d.ts +0 -7
  38. package/dist/esm/src/graphql/queries/getSubscription.d.ts +0 -12
package/dist/esm/index.js CHANGED
@@ -4,13 +4,13 @@ import React__default, { createContext as createContext$1, useContext as useCont
4
4
  import { Markup } from 'interweave';
5
5
  import { ConfigProvider, Button as Button$1, Typography, Tag, Divider, Popconfirm, Input, Checkbox, Collapse, Modal, Form, Drawer, Card as Card$1, Select, Image, Dropdown, Skeleton } from 'antd';
6
6
  import styled from 'styled-components';
7
- import { DEFAULT_ACCENT_COLOR, DEFAULT_BRAND_COLOR, DEFAULT_SECONDARY_COLOR, DEFAULT_TOP_NAV_IMAGE_URL, gqlRequest as gqlRequest$1, QueryKeyFactory, useIsMobile, isColorTooDark, MARK_PRO, INPUT_BORDER_COLOR, SLATE_50, SLATE_400, SLATE_200, getPlugins, invokePlugin, useErrorNotification, formatCurrency, GRAY_500, GRAY_200, useSuccessNotification, useAllErrorFormats, getFormattedInvoice, PAYABLE_INVOICE_STATES, DOCUMENT_NAME as DOCUMENT_NAME$1, useGraphQLmutation, formatDate, FrontendTransaction, SLATE_600, WHITE, TransactionKind, Lists, getAccount as getAccount$1, DEFAULT_CONFIG, SubscriptionState as SubscriptionState$2, MODAL_MAX_HEIGHT, SLATE_500, StringUtils, DataInterval, TAG_COLORS, ChargeType } from '@bunnyapp/common';
8
- import { QueryClient, QueryClientProvider, useQuery, useQueryClient, useMutation, keepPreviousData, onlineManager } from '@tanstack/react-query';
7
+ import { DEFAULT_ACCENT_COLOR, DEFAULT_BRAND_COLOR, DEFAULT_SECONDARY_COLOR, DEFAULT_TOP_NAV_IMAGE_URL, gqlRequest as gqlRequest$1, QueryKeyFactory, useIsMobile, isColorTooDark, MARK_PRO, INPUT_BORDER_COLOR, SLATE_50, SLATE_400, SLATE_200, getPlugins, useErrorNotification, formatCurrency, invokePlugin, GRAY_500, GRAY_200, useSuccessNotification, BreakpointNumbers, useAllErrorFormats, getFormattedInvoice, PAYABLE_INVOICE_STATES, DOCUMENT_NAME as DOCUMENT_NAME$1, useGraphQLmutation, formatDate, FrontendTransaction, SLATE_600, WHITE, TransactionKind, Lists, getAccount as getAccount$1, DEFAULT_CONFIG, SubscriptionState as SubscriptionState$2, MODAL_MAX_HEIGHT, SLATE_500, StringUtils, DataInterval, TAG_COLORS, ChargeType } from '@bunnyapp/common';
8
+ import { QueryClient, QueryClientProvider, useQuery, useQueryClient, keepPreviousData, useMutation, onlineManager } from '@tanstack/react-query';
9
9
  import theme from 'antd/lib/theme';
10
10
  import { RecoilRoot } from 'recoil';
11
11
  import request, { GraphQLClient } from 'graphql-request';
12
12
  import { HelmetProvider, Helmet } from 'react-helmet-async';
13
- import { useElements, useStripe, Elements, PaymentElement } from '@stripe/react-stripe-js';
13
+ import { useElements, useStripe, PaymentElement, Elements } from '@stripe/react-stripe-js';
14
14
  import { loadStripe } from '@stripe/stripe-js/pure';
15
15
  import { capitalize, startCase, cloneDeep, omit } from 'lodash';
16
16
  import { BarChart, ResponsiveContainer, XAxis, Tooltip, Bar, Rectangle } from 'recharts';
@@ -42,7 +42,7 @@ function styleInject(css, ref) {
42
42
  }
43
43
  }
44
44
 
45
- var css_248z = ".ant-collapse-header {\n cursor: default !important;\n padding: 0 !important;\n}\n.ant-tag {\n border: none;\n border-radius: 14px;\n font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica Neue, Arial, Noto Sans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol, Noto Color Emoji;\n font-weight: 500;\n white-space: nowrap;\n margin: 0;\n}\n.ant-tag-blue {\n color: #3b82f6 !important;\n background: #bfdbfe !important;\n}\n.ant-tag-green {\n color: #059669 !important;\n background: #a7f3d0 !important;\n}\n.ant-tag-red {\n color: #ef4444 !important;\n background: #fecaca !important;\n}\n.ant-tag-orange {\n color: #f97316 !important;\n background: #fed7aa !important;\n}\n.ant-tag-yellow {\n color: #f59e0b !important;\n background: #fde68a !important;\n}\n.ant-tag-purple {\n color: #8b5cf6 !important;\n background: #ddd6fe !important;\n}\n.ant-tag-black {\n color: white !important;\n background: black !important;\n}\n.ant-popover {\n z-index: 1050;\n}\n.ant-popover-inner-content {\n display: flex;\n flex-direction: column;\n gap: 0.5rem;\n max-width: 300px;\n}\n.ant-popover-message-title {\n padding: 0;\n text-align: center;\n font-size: 1rem;\n}\n.ant-popover-buttons {\n display: flex;\n align-items: center;\n justify-content: center;\n}\n.ant-btn-link:disabled {\n color: #717d94 !important;\n}\n.ant-btn-link:disabled:hover {\n background-color: transparent !important;\n}\n.ant-input-affix-wrapper .ant-input-prefix {\n transition: color 0.3s;\n}\n.ant-form-item-label {\n text-transform: none !important;\n font-size: 0.75rem;\n padding-bottom: 2px !important;\n}\n.ant-form-item-label > label {\n width: 100%;\n color: #4b5563 !important;\n}\n.ant-form-item-explain-error {\n font-size: 11px;\n min-height: 11px;\n line-height: 11px;\n padding-top: 2px;\n}\n.ant-form-item {\n margin-bottom: 0;\n}\n.ant-notification {\n width: min-content;\n}\n.ant-notification-topRight {\n right: 0 !important;\n left: 0 !important;\n margin-left: auto !important;\n margin-right: auto !important;\n}\n.ant-notification-notice-wrapper {\n width: 350px !important;\n overflow: hidden !important;\n}\n.ant-notification-notice {\n padding: 16px !important;\n width: 350px !important;\n display: flex !important;\n box-shadow: 0px 6px 10px rgba(0, 0, 0, 0.08), 0px 1px 18px rgba(0, 0, 0, 0.08), 0px 3px 5px rgba(0, 0, 0, 0.16) !important;\n}\n.ant-notification-notice-description {\n padding: 0 14px 0 0 !important;\n color: #232323 !important;\n font-size: 14px !important;\n word-break: break-all !important;\n overflow-wrap: break-word !important;\n}\n.ant-notification-notice-success {\n background-color: #edfffa !important;\n}\n.ant-notification-notice-error {\n background-color: #fff8f4 !important;\n}\n.ant-notification-notice-error .ant-notification-notice-message {\n color: #ff6e1c !important;\n font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica Neue, Arial, Noto Sans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol, Noto Color Emoji !important;\n font-weight: 500;\n}\n.ant-notification-notice-error .ant-notification-notice-icon {\n color: #ff6e1c;\n}\n.ant-notification-notice-success .ant-notification-notice-message {\n color: #00b76a !important;\n font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica Neue, Arial, Noto Sans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol, Noto Color Emoji !important;\n font-weight: 500;\n}\n.ant-notification-notice-success .ant-notification-notice-icon {\n color: #00b76a !important;\n}\n.ant-notification-notice-message {\n margin-bottom: 0 !important;\n}\n.ant-notification-notice-close {\n top: 16px !important;\n right: 16px !important;\n}\n.ant-menu-submenu-popup > .ant-menu .ant-menu-item {\n display: flex !important;\n align-items: center !important;\n}\n.ant-menu-submenu::after {\n display: none !important;\n}\n.ant-drawer-title {\n font-weight: 400 !important;\n}\n.ant-drawer-header-title {\n flex-direction: row-reverse !important;\n align-items: start !important ;\n}\n.ant-drawer-close {\n margin-inline-end: 0 !important;\n}\n@media (min-width: 768px) {\n .ant-input,\n .ant-picker,\n .ant-select,\n .ant-input-affix-wrapper {\n font-size: 1rem !important;\n }\n .ant-drawer-header {\n padding-right: 1.5rem !important;\n padding-left: 1.5rem !important;\n }\n}\n:root {\n --row-background: #ffffff;\n --row-background-alternate: rgba(100, 116, 139, 0.04);\n --row-background-dark: #121212;\n --row-background-alternate-dark: #1e1e1e;\n}\n.plan-step-line {\n height: 1px;\n min-width: 128px;\n background: #717d94;\n}\n.plan-step-number {\n display: flex;\n align-items: center;\n justify-content: center;\n border-radius: 9999px;\n border: 1px solid #717d94;\n background: white;\n width: 24px;\n height: 24px;\n color: #717d94;\n}\n.plan-step-number.active {\n border: none;\n color: white;\n background: #ff6e1c;\n}\n.hidden {\n display: none;\n}\n.cardElement {\n padding: 8px 11px;\n border: 1px solid #e5e7eb;\n background-color: white;\n font-family: Inter !important;\n}\n.tooltip {\n visibility: hidden;\n position: absolute !important;\n}\n.has-tooltip:hover .tooltip {\n visibility: visible;\n z-index: 100;\n}\n.show-on-hover {\n opacity: 0;\n}\n.show-on-hover-container:hover .show-on-hover {\n opacity: 1;\n}\n.pdf-only {\n display: none !important;\n}\n.notes p {\n margin: 0;\n padding: 0;\n padding-bottom: 0.25rem;\n}\n#form-element #finix-form-container .field-holder label {\n color: #717d94 !important;\n font-size: 12px !important;\n}\n#form-element #finix-form-container > *:first-child,\n#form-element #finix-form-container > *:last-child {\n margin-top: 0 !important;\n}\n#form-element #finix-form-container > *:not(:first-child):not(:last-child) {\n margin-top: 12px !important;\n}\n#form-element #finix-form-container .field-array > * {\n margin-top: 0 !important;\n}\n#form-element #finix-form-container .field-holder .field,\n#form-element #finix-form-container iframe {\n height: 34px !important;\n}\n#form-element #finix-form-container .field {\n margin-top: 0 !important;\n padding-top: 2px !important;\n}\n#form-element #finix-form-container .field-holder .validation {\n font-size: 11px !important;\n color: #ff4d4f !important;\n}\n.icon-path {\n transition: fill 0.3s;\n}\n.shadow-padding-x {\n padding-right: 1rem;\n padding-left: 1rem;\n}\n.shadow-padding-xb {\n padding-right: 1rem;\n padding-left: 1rem;\n padding-bottom: 0.5rem;\n}\n.content-container {\n width: 100%;\n margin: 0 auto;\n}\n@media (min-width: 1220px) {\n .content-container {\n width: 1220px !important;\n margin: 0 auto;\n }\n}\n@media (min-width: 768px) {\n .shadow-padding-x {\n padding-right: 2rem;\n padding-left: 2rem;\n }\n .shadow-padding-xb {\n padding-right: 2rem;\n padding-left: 2rem;\n padding-bottom: 0.5rem;\n }\n .sm\\:flex {\n display: flex !important;\n }\n .sm\\:hidden {\n display: none !important;\n }\n}\n.rotate-45,\n.transform {\n --tw-translate-x: 0;\n --tw-translate-y: 0;\n --tw-rotate: 0;\n --tw-skew-x: 0;\n --tw-skew-y: 0;\n --tw-scale-x: 1;\n --tw-scale-y: 1;\n}\n.shadow,\n.shadow-lg,\n.shadow-md,\n.shadow-none,\n.shadow-sm,\n.shadow-xl {\n --tw-ring-offset-shadow: 0 0 #0000;\n --tw-ring-shadow: 0 0 #0000;\n --tw-shadow: 0 0 #0000;\n --tw-shadow-colored: 0 0 #0000;\n}\n.container {\n width: 100%;\n}\n@media (min-width: 768px) {\n .container {\n max-width: 768px;\n }\n}\n@media (min-width: 1024px) {\n .container {\n max-width: 1024px;\n }\n}\n@media (min-width: 1280px) {\n .container {\n max-width: 1280px;\n }\n}\n@media (min-width: 1536px) {\n .container {\n max-width: 1536px;\n }\n}\n.visible {\n visibility: visible;\n}\n.fixed {\n position: fixed;\n}\n.absolute {\n position: absolute;\n}\n.relative {\n position: relative;\n}\n.bottom-0 {\n bottom: 0px;\n}\n.left-0 {\n left: 0px;\n}\n.right-0 {\n right: 0px;\n}\n.top-0 {\n top: 0px;\n}\n.z-50 {\n z-index: 50;\n}\n.col-span-2 {\n grid-column: span 2 / span 2;\n}\n.col-span-3 {\n grid-column: span 3 / span 3;\n}\n.m-0 {\n margin: 0px;\n}\n.mx-4 {\n margin-left: 1rem;\n margin-right: 1rem;\n}\n.my-12 {\n margin-top: 3rem;\n margin-bottom: 3rem;\n}\n.my-2 {\n margin-top: 0.5rem;\n margin-bottom: 0.5rem;\n}\n.my-4 {\n margin-top: 1rem;\n margin-bottom: 1rem;\n}\n.mb-4 {\n margin-bottom: 1rem;\n}\n.ml-2 {\n margin-left: 0.5rem;\n}\n.mr-8 {\n margin-right: 2rem;\n}\n.mt-1 {\n margin-top: 0.25rem;\n}\n.mt-2 {\n margin-top: 0.5rem;\n}\n.mt-4 {\n margin-top: 1rem;\n}\n.mt-6 {\n margin-top: 1.5rem;\n}\n.mt-8 {\n margin-top: 2rem;\n}\n.block {\n display: block;\n}\n.flex {\n display: flex;\n}\n.table {\n display: table;\n}\n.grid {\n display: grid;\n}\n.contents {\n display: contents;\n}\n.hidden {\n display: none;\n}\n.h-4 {\n height: 1rem;\n}\n.h-5 {\n height: 1.25rem;\n}\n.h-8 {\n height: 2rem;\n}\n.h-full {\n height: 100%;\n}\n.w-1\\/2 {\n width: 50%;\n}\n.w-1\\/3 {\n width: 33.333333%;\n}\n.w-2\\/3 {\n width: 66.666667%;\n}\n.w-4 {\n width: 1rem;\n}\n.w-full {\n width: 100%;\n}\n.max-w-32 {\n max-width: 8rem;\n}\n.flex-1 {\n flex: 1 1 0%;\n}\n.shrink-0 {\n flex-shrink: 0;\n}\n.grow {\n flex-grow: 1;\n}\n.border-collapse {\n border-collapse: collapse;\n}\n.rotate-45 {\n --tw-rotate: 45deg;\n transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));\n}\n.transform {\n transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));\n}\n.cursor-pointer {\n cursor: pointer;\n}\n.grid-cols-2 {\n grid-template-columns: repeat(2, minmax(0, 1fr));\n}\n.grid-cols-3 {\n grid-template-columns: repeat(3, minmax(0, 1fr));\n}\n.flex-row {\n flex-direction: row;\n}\n.flex-col {\n flex-direction: column;\n}\n.items-end {\n align-items: flex-end;\n}\n.items-center {\n align-items: center;\n}\n.justify-start {\n justify-content: flex-start;\n}\n.justify-end {\n justify-content: flex-end;\n}\n.justify-center {\n justify-content: center;\n}\n.justify-between {\n justify-content: space-between;\n}\n.gap-0 {\n gap: 0px;\n}\n.gap-1 {\n gap: 0.25rem;\n}\n.gap-2 {\n gap: 0.5rem;\n}\n.gap-4 {\n gap: 1rem;\n}\n.gap-6 {\n gap: 1.5rem;\n}\n.space-y-2 > :not([hidden]) ~ :not([hidden]) {\n --tw-space-y-reverse: 0;\n margin-top: calc(0.5rem * calc(1 - var(--tw-space-y-reverse)));\n margin-bottom: calc(0.5rem * var(--tw-space-y-reverse));\n}\n.space-y-4 > :not([hidden]) ~ :not([hidden]) {\n --tw-space-y-reverse: 0;\n margin-top: calc(1rem * calc(1 - var(--tw-space-y-reverse)));\n margin-bottom: calc(1rem * var(--tw-space-y-reverse));\n}\n.space-y-8 > :not([hidden]) ~ :not([hidden]) {\n --tw-space-y-reverse: 0;\n margin-top: calc(2rem * calc(1 - var(--tw-space-y-reverse)));\n margin-bottom: calc(2rem * var(--tw-space-y-reverse));\n}\n.overflow-auto {\n overflow: auto;\n}\n.overflow-hidden {\n overflow: hidden;\n}\n.overflow-visible {\n overflow: visible;\n}\n.whitespace-nowrap {\n white-space: nowrap;\n}\n.text-nowrap {\n text-wrap: nowrap;\n}\n.rounded {\n border-radius: 0.25rem;\n}\n.rounded-full {\n border-radius: 9999px;\n}\n.rounded-md {\n border-radius: 0.375rem;\n}\n.border {\n border-width: 1px;\n}\n.border-solid {\n border-style: solid;\n}\n.border-gray-400 {\n --tw-border-opacity: 1;\n border-color: rgb(156 163 175 / var(--tw-border-opacity, 1));\n}\n.border-gray-500 {\n --tw-border-opacity: 1;\n border-color: rgb(107 114 128 / var(--tw-border-opacity, 1));\n}\n.border-slate-200 {\n --tw-border-opacity: 1;\n border-color: rgb(226 232 240 / var(--tw-border-opacity, 1));\n}\n.border-slate-300 {\n --tw-border-opacity: 1;\n border-color: rgb(203 213 225 / var(--tw-border-opacity, 1));\n}\n.border-slate-700 {\n --tw-border-opacity: 1;\n border-color: rgb(51 65 85 / var(--tw-border-opacity, 1));\n}\n.bg-black {\n --tw-bg-opacity: 1;\n background-color: rgb(0 0 0 / var(--tw-bg-opacity, 1));\n}\n.bg-emerald-200 {\n --tw-bg-opacity: 1;\n background-color: rgb(167 243 208 / var(--tw-bg-opacity, 1));\n}\n.bg-green-200 {\n --tw-bg-opacity: 1;\n background-color: rgb(187 247 208 / var(--tw-bg-opacity, 1));\n}\n.bg-orange-200 {\n --tw-bg-opacity: 1;\n background-color: rgb(254 215 170 / var(--tw-bg-opacity, 1));\n}\n.bg-red-200 {\n --tw-bg-opacity: 1;\n background-color: rgb(254 202 202 / var(--tw-bg-opacity, 1));\n}\n.bg-red-500 {\n --tw-bg-opacity: 1;\n background-color: rgb(239 68 68 / var(--tw-bg-opacity, 1));\n}\n.bg-slate-50 {\n --tw-bg-opacity: 1;\n background-color: rgb(248 250 252 / var(--tw-bg-opacity, 1));\n}\n.bg-white {\n --tw-bg-opacity: 1;\n background-color: rgb(255 255 255 / var(--tw-bg-opacity, 1));\n}\n.bg-yellow-200 {\n --tw-bg-opacity: 1;\n background-color: rgb(254 240 138 / var(--tw-bg-opacity, 1));\n}\n.p-0 {\n padding: 0px;\n}\n.p-1 {\n padding: 0.25rem;\n}\n.p-2 {\n padding: 0.5rem;\n}\n.p-4 {\n padding: 1rem;\n}\n.p-8 {\n padding: 2rem;\n}\n.px-0 {\n padding-left: 0px;\n padding-right: 0px;\n}\n.px-2 {\n padding-left: 0.5rem;\n padding-right: 0.5rem;\n}\n.px-4 {\n padding-left: 1rem;\n padding-right: 1rem;\n}\n.px-6 {\n padding-left: 1.5rem;\n padding-right: 1.5rem;\n}\n.py-1 {\n padding-top: 0.25rem;\n padding-bottom: 0.25rem;\n}\n.py-2 {\n padding-top: 0.5rem;\n padding-bottom: 0.5rem;\n}\n.py-4 {\n padding-top: 1rem;\n padding-bottom: 1rem;\n}\n.py-6 {\n padding-top: 1.5rem;\n padding-bottom: 1.5rem;\n}\n.px-3 {\n padding-left: 0.75rem;\n padding-right: 0.75rem;\n}\n.pb-2 {\n padding-bottom: 0.5rem;\n}\n.pb-4 {\n padding-bottom: 1rem;\n}\n.pb-6 {\n padding-bottom: 1.5rem;\n}\n.pb-8 {\n padding-bottom: 2rem;\n}\n.pl-0 {\n padding-left: 0px;\n}\n.pl-2 {\n padding-left: 0.5rem;\n}\n.pl-4 {\n padding-left: 1rem;\n}\n.pt-1 {\n padding-top: 0.25rem;\n}\n.pt-12 {\n padding-top: 3rem;\n}\n.pt-2 {\n padding-top: 0.5rem;\n}\n.pt-4 {\n padding-top: 1rem;\n}\n.pt-5 {\n padding-top: 1.25rem;\n}\n.pt-6 {\n padding-top: 1.5rem;\n}\n.pt-8 {\n padding-top: 2rem;\n}\n.text-left {\n text-align: left;\n}\n.text-center {\n text-align: center;\n}\n.text-right {\n text-align: right;\n}\n.align-middle {\n vertical-align: middle;\n}\n.text-2xl {\n font-size: 1.5rem;\n line-height: 2rem;\n}\n.text-base {\n font-size: 1rem;\n line-height: 1.5rem;\n}\n.text-lg {\n font-size: 1.125rem;\n line-height: 1.75rem;\n}\n.text-sm {\n font-size: 0.875rem;\n line-height: 1.25rem;\n}\n.text-xl {\n font-size: 1.25rem;\n line-height: 1.75rem;\n}\n.text-xs {\n font-size: 0.75rem;\n line-height: 1rem;\n}\n.font-bold {\n font-weight: 700;\n}\n.font-medium {\n font-weight: 500;\n}\n.font-normal {\n font-weight: 400;\n}\n.capitalize {\n text-transform: capitalize;\n}\n.text-emerald-600 {\n --tw-text-opacity: 1;\n color: rgb(5 150 105 / var(--tw-text-opacity, 1));\n}\n.text-emerald-700 {\n --tw-text-opacity: 1;\n color: rgb(4 120 87 / var(--tw-text-opacity, 1));\n}\n.text-gray-600 {\n --tw-text-opacity: 1;\n color: rgb(75 85 99 / var(--tw-text-opacity, 1));\n}\n.text-gray-900 {\n --tw-text-opacity: 1;\n color: rgb(17 24 39 / var(--tw-text-opacity, 1));\n}\n.text-green-600 {\n --tw-text-opacity: 1;\n color: rgb(22 163 74 / var(--tw-text-opacity, 1));\n}\n.text-orange-500 {\n --tw-text-opacity: 1;\n color: rgb(249 115 22 / var(--tw-text-opacity, 1));\n}\n.text-red-500 {\n --tw-text-opacity: 1;\n color: rgb(239 68 68 / var(--tw-text-opacity, 1));\n}\n.text-slate-400 {\n --tw-text-opacity: 1;\n color: rgb(148 163 184 / var(--tw-text-opacity, 1));\n}\n.text-slate-500 {\n --tw-text-opacity: 1;\n color: rgb(100 116 139 / var(--tw-text-opacity, 1));\n}\n.text-white {\n --tw-text-opacity: 1;\n color: rgb(255 255 255 / var(--tw-text-opacity, 1));\n}\n.text-yellow-500 {\n --tw-text-opacity: 1;\n color: rgb(234 179 8 / var(--tw-text-opacity, 1));\n}\n.underline {\n text-decoration-line: underline;\n}\n.shadow {\n --tw-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);\n --tw-shadow-colored: 0 1px 3px 0 var(--tw-shadow-color), 0 1px 2px -1px var(--tw-shadow-color);\n box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);\n}\n.shadow-lg {\n --tw-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);\n --tw-shadow-colored: 0 10px 15px -3px var(--tw-shadow-color), 0 4px 6px -4px var(--tw-shadow-color);\n box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);\n}\n.shadow-md {\n --tw-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);\n --tw-shadow-colored: 0 4px 6px -1px var(--tw-shadow-color), 0 2px 4px -2px var(--tw-shadow-color);\n box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);\n}\n.shadow-none {\n --tw-shadow: 0 0 #0000;\n --tw-shadow-colored: 0 0 #0000;\n box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);\n}\n.shadow-sm {\n --tw-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);\n --tw-shadow-colored: 0 1px 2px 0 var(--tw-shadow-color);\n box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);\n}\n.shadow-xl {\n --tw-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);\n --tw-shadow-colored: 0 20px 25px -5px var(--tw-shadow-color), 0 8px 10px -6px var(--tw-shadow-color);\n box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);\n}\n.transition {\n transition-property: color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, -webkit-backdrop-filter;\n transition-property: color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, backdrop-filter;\n transition-property: color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, backdrop-filter, -webkit-backdrop-filter;\n transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);\n transition-duration: 150ms;\n}\n.font-light {\n font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica Neue, Arial, Noto Sans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol, Noto Color Emoji;\n}\n.font-medium {\n font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica Neue, Arial, Noto Sans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol, Noto Color Emoji;\n}\n.font-bold {\n font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica Neue, Arial, Noto Sans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol, Noto Color Emoji;\n}\n@media (min-width: 768px) {\n .sm\\:flex {\n display: flex;\n }\n .sm\\:hidden {\n display: none;\n }\n}\n* {\n margin: 0;\n padding: 0;\n box-sizing: border-box !important;\n font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica Neue, Arial, Noto Sans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol, Noto Color Emoji;\n line-height: 1.15;\n}\nbody {\n color: #232323;\n background-color: #f8fafc;\n}\nth {\n font-weight: normal;\n}\ncode {\n font-family: source-code-pro, Menlo, Monaco, Consolas, \"Courier New\", monospace;\n}\n@media only screen and (max-width: 768px) {\n select,\n textarea,\n input[type=\"text\"],\n input[type=\"password\"],\n input[type=\"datetime\"],\n input[type=\"datetime-local\"],\n input[type=\"date\"],\n input[type=\"month\"],\n input[type=\"time\"],\n input[type=\"week\"],\n input[type=\"number\"],\n input[type=\"email\"],\n input[type=\"url\"],\n input[type=\"search\"],\n input[type=\"tel\"],\n input[type=\"color\"] {\n font-size: 16px !important;\n }\n}\n@keyframes App-logo-spin {\n from {\n transform: rotate(0deg);\n }\n to {\n transform: rotate(360deg);\n }\n}\n";
45
+ var css_248z = ".ant-collapse-header {\n cursor: default !important;\n padding: 0 !important;\n}\n.ant-tag {\n border: none;\n border-radius: 14px;\n font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica Neue, Arial, Noto Sans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol, Noto Color Emoji;\n font-weight: 500;\n white-space: nowrap;\n margin: 0;\n}\n.ant-tag-blue {\n color: #3b82f6 !important;\n background: #bfdbfe !important;\n}\n.ant-tag-green {\n color: #059669 !important;\n background: #a7f3d0 !important;\n}\n.ant-tag-red {\n color: #ef4444 !important;\n background: #fecaca !important;\n}\n.ant-tag-orange {\n color: #f97316 !important;\n background: #fed7aa !important;\n}\n.ant-tag-yellow {\n color: #f59e0b !important;\n background: #fde68a !important;\n}\n.ant-tag-purple {\n color: #8b5cf6 !important;\n background: #ddd6fe !important;\n}\n.ant-tag-black {\n color: white !important;\n background: black !important;\n}\n.ant-popover {\n z-index: 1050;\n}\n.ant-popover-inner-content {\n display: flex;\n flex-direction: column;\n gap: 0.5rem;\n max-width: 300px;\n}\n.ant-popover-message-title {\n padding: 0;\n text-align: center;\n font-size: 1rem;\n}\n.ant-popover-buttons {\n display: flex;\n align-items: center;\n justify-content: center;\n}\n.ant-btn-link:disabled {\n color: #717d94 !important;\n}\n.ant-btn-link:disabled:hover {\n background-color: transparent !important;\n}\n.ant-input-affix-wrapper .ant-input-prefix {\n transition: color 0.3s;\n}\n.ant-form-item-label {\n text-transform: none !important;\n font-size: 0.75rem;\n padding-bottom: 2px !important;\n}\n.ant-form-item-label > label {\n width: 100%;\n color: #4b5563 !important;\n}\n.ant-form-item-explain-error {\n font-size: 11px;\n min-height: 11px;\n line-height: 11px;\n padding-top: 2px;\n}\n.ant-form-item {\n margin-bottom: 0;\n}\n.ant-notification {\n width: min-content;\n}\n.ant-notification-topRight {\n right: 0 !important;\n left: 0 !important;\n margin-left: auto !important;\n margin-right: auto !important;\n}\n.ant-notification-notice-wrapper {\n width: 350px !important;\n overflow: hidden !important;\n}\n.ant-notification-notice {\n padding: 16px !important;\n width: 350px !important;\n display: flex !important;\n box-shadow: 0px 6px 10px rgba(0, 0, 0, 0.08), 0px 1px 18px rgba(0, 0, 0, 0.08), 0px 3px 5px rgba(0, 0, 0, 0.16) !important;\n}\n.ant-notification-notice-description {\n padding: 0 14px 0 0 !important;\n color: #232323 !important;\n font-size: 14px !important;\n word-break: break-all !important;\n overflow-wrap: break-word !important;\n}\n.ant-notification-notice-success {\n background-color: #edfffa !important;\n}\n.ant-notification-notice-error {\n background-color: #fff8f4 !important;\n}\n.ant-notification-notice-error .ant-notification-notice-message {\n color: #ff6e1c !important;\n font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica Neue, Arial, Noto Sans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol, Noto Color Emoji !important;\n font-weight: 500;\n}\n.ant-notification-notice-error .ant-notification-notice-icon {\n color: #ff6e1c;\n}\n.ant-notification-notice-success .ant-notification-notice-message {\n color: #00b76a !important;\n font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica Neue, Arial, Noto Sans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol, Noto Color Emoji !important;\n font-weight: 500;\n}\n.ant-notification-notice-success .ant-notification-notice-icon {\n color: #00b76a !important;\n}\n.ant-notification-notice-message {\n margin-bottom: 0 !important;\n}\n.ant-notification-notice-close {\n top: 16px !important;\n right: 16px !important;\n}\n.ant-menu-submenu-popup > .ant-menu .ant-menu-item {\n display: flex !important;\n align-items: center !important;\n}\n.ant-menu-submenu::after {\n display: none !important;\n}\n.ant-drawer-title {\n font-weight: 400 !important;\n}\n.ant-drawer-header-title {\n flex-direction: row-reverse !important;\n align-items: start !important ;\n}\n.ant-drawer-close {\n margin-inline-end: 0 !important;\n}\n@media (min-width: 768px) {\n .ant-input,\n .ant-picker,\n .ant-select,\n .ant-input-affix-wrapper {\n font-size: 1rem !important;\n }\n .ant-drawer-header {\n padding-right: 1.5rem !important;\n padding-left: 1.5rem !important;\n }\n}\n:root {\n --row-background: #ffffff;\n --row-background-alternate: rgba(100, 116, 139, 0.04);\n --row-background-dark: #121212;\n --row-background-alternate-dark: #1e1e1e;\n}\n.plan-step-line {\n height: 1px;\n min-width: 128px;\n background: #717d94;\n}\n.plan-step-number {\n display: flex;\n align-items: center;\n justify-content: center;\n border-radius: 9999px;\n border: 1px solid #717d94;\n background: white;\n width: 24px;\n height: 24px;\n color: #717d94;\n}\n.plan-step-number.active {\n border: none;\n color: white;\n background: #ff6e1c;\n}\n.hidden {\n display: none;\n}\n.cardElement {\n padding: 8px 11px;\n border: 1px solid #e5e7eb;\n background-color: white;\n font-family: Inter !important;\n}\n.tooltip {\n visibility: hidden;\n position: absolute !important;\n}\n.has-tooltip:hover .tooltip {\n visibility: visible;\n z-index: 100;\n}\n.show-on-hover {\n opacity: 0;\n}\n.show-on-hover-container:hover .show-on-hover {\n opacity: 1;\n}\n.pdf-only {\n display: none !important;\n}\n.notes p {\n margin: 0;\n padding: 0;\n padding-bottom: 0.25rem;\n}\n#form-element #finix-form-container .field-holder label {\n color: #717d94 !important;\n font-size: 12px !important;\n}\n#form-element #finix-form-container > *:first-child,\n#form-element #finix-form-container > *:last-child {\n margin-top: 0 !important;\n}\n#form-element #finix-form-container > *:not(:first-child):not(:last-child) {\n margin-top: 12px !important;\n}\n#form-element #finix-form-container .field-array > * {\n margin-top: 0 !important;\n}\n#form-element #finix-form-container .field-holder .field,\n#form-element #finix-form-container iframe {\n height: 34px !important;\n}\n#form-element #finix-form-container .field {\n margin-top: 0 !important;\n padding-top: 2px !important;\n}\n#form-element #finix-form-container .field-holder .validation {\n font-size: 11px !important;\n color: #ff4d4f !important;\n}\n.icon-path {\n transition: fill 0.3s;\n}\n.shadow-padding-x {\n padding-right: 1rem;\n padding-left: 1rem;\n}\n.shadow-padding-xb {\n padding-right: 1rem;\n padding-left: 1rem;\n padding-bottom: 0.5rem;\n}\n.content-container {\n width: 100%;\n margin: 0 auto;\n}\n@media (min-width: 1220px) {\n .content-container {\n width: 1220px !important;\n margin: 0 auto;\n }\n}\n@media (min-width: 768px) {\n .shadow-padding-x {\n padding-right: 2rem;\n padding-left: 2rem;\n }\n .shadow-padding-xb {\n padding-right: 2rem;\n padding-left: 2rem;\n padding-bottom: 0.5rem;\n }\n .sm\\:flex {\n display: flex !important;\n }\n .sm\\:hidden {\n display: none !important;\n }\n}\n.rotate-45,\n.transform {\n --tw-translate-x: 0;\n --tw-translate-y: 0;\n --tw-rotate: 0;\n --tw-skew-x: 0;\n --tw-skew-y: 0;\n --tw-scale-x: 1;\n --tw-scale-y: 1;\n}\n.shadow,\n.shadow-lg,\n.shadow-md,\n.shadow-none,\n.shadow-sm,\n.shadow-xl {\n --tw-ring-offset-shadow: 0 0 #0000;\n --tw-ring-shadow: 0 0 #0000;\n --tw-shadow: 0 0 #0000;\n --tw-shadow-colored: 0 0 #0000;\n}\n.container {\n width: 100%;\n}\n@media (min-width: 768px) {\n .container {\n max-width: 768px;\n }\n}\n@media (min-width: 1024px) {\n .container {\n max-width: 1024px;\n }\n}\n@media (min-width: 1280px) {\n .container {\n max-width: 1280px;\n }\n}\n@media (min-width: 1536px) {\n .container {\n max-width: 1536px;\n }\n}\n.visible {\n visibility: visible;\n}\n.fixed {\n position: fixed;\n}\n.absolute {\n position: absolute;\n}\n.relative {\n position: relative;\n}\n.bottom-0 {\n bottom: 0px;\n}\n.left-0 {\n left: 0px;\n}\n.right-0 {\n right: 0px;\n}\n.top-0 {\n top: 0px;\n}\n.z-50 {\n z-index: 50;\n}\n.col-span-2 {\n grid-column: span 2 / span 2;\n}\n.col-span-3 {\n grid-column: span 3 / span 3;\n}\n.m-0 {\n margin: 0px;\n}\n.mx-4 {\n margin-left: 1rem;\n margin-right: 1rem;\n}\n.my-12 {\n margin-top: 3rem;\n margin-bottom: 3rem;\n}\n.my-2 {\n margin-top: 0.5rem;\n margin-bottom: 0.5rem;\n}\n.my-4 {\n margin-top: 1rem;\n margin-bottom: 1rem;\n}\n.mb-4 {\n margin-bottom: 1rem;\n}\n.ml-2 {\n margin-left: 0.5rem;\n}\n.mr-8 {\n margin-right: 2rem;\n}\n.mt-1 {\n margin-top: 0.25rem;\n}\n.mt-2 {\n margin-top: 0.5rem;\n}\n.mt-4 {\n margin-top: 1rem;\n}\n.mt-6 {\n margin-top: 1.5rem;\n}\n.mt-8 {\n margin-top: 2rem;\n}\n.block {\n display: block;\n}\n.flex {\n display: flex;\n}\n.table {\n display: table;\n}\n.grid {\n display: grid;\n}\n.contents {\n display: contents;\n}\n.hidden {\n display: none;\n}\n.h-4 {\n height: 1rem;\n}\n.h-5 {\n height: 1.25rem;\n}\n.h-8 {\n height: 2rem;\n}\n.h-full {\n height: 100%;\n}\n.w-1\\/2 {\n width: 50%;\n}\n.w-1\\/3 {\n width: 33.333333%;\n}\n.w-2\\/3 {\n width: 66.666667%;\n}\n.w-4 {\n width: 1rem;\n}\n.w-full {\n width: 100%;\n}\n.max-w-32 {\n max-width: 8rem;\n}\n.flex-1 {\n flex: 1 1 0%;\n}\n.shrink-0 {\n flex-shrink: 0;\n}\n.grow {\n flex-grow: 1;\n}\n.border-collapse {\n border-collapse: collapse;\n}\n.rotate-45 {\n --tw-rotate: 45deg;\n transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));\n}\n.transform {\n transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));\n}\n.cursor-pointer {\n cursor: pointer;\n}\n.grid-cols-2 {\n grid-template-columns: repeat(2, minmax(0, 1fr));\n}\n.grid-cols-3 {\n grid-template-columns: repeat(3, minmax(0, 1fr));\n}\n.flex-row {\n flex-direction: row;\n}\n.flex-col {\n flex-direction: column;\n}\n.items-end {\n align-items: flex-end;\n}\n.items-center {\n align-items: center;\n}\n.justify-start {\n justify-content: flex-start;\n}\n.justify-end {\n justify-content: flex-end;\n}\n.justify-center {\n justify-content: center;\n}\n.justify-between {\n justify-content: space-between;\n}\n.gap-0 {\n gap: 0px;\n}\n.gap-1 {\n gap: 0.25rem;\n}\n.gap-2 {\n gap: 0.5rem;\n}\n.gap-4 {\n gap: 1rem;\n}\n.gap-6 {\n gap: 1.5rem;\n}\n.space-y-2 > :not([hidden]) ~ :not([hidden]) {\n --tw-space-y-reverse: 0;\n margin-top: calc(0.5rem * calc(1 - var(--tw-space-y-reverse)));\n margin-bottom: calc(0.5rem * var(--tw-space-y-reverse));\n}\n.space-y-4 > :not([hidden]) ~ :not([hidden]) {\n --tw-space-y-reverse: 0;\n margin-top: calc(1rem * calc(1 - var(--tw-space-y-reverse)));\n margin-bottom: calc(1rem * var(--tw-space-y-reverse));\n}\n.space-y-8 > :not([hidden]) ~ :not([hidden]) {\n --tw-space-y-reverse: 0;\n margin-top: calc(2rem * calc(1 - var(--tw-space-y-reverse)));\n margin-bottom: calc(2rem * var(--tw-space-y-reverse));\n}\n.overflow-auto {\n overflow: auto;\n}\n.overflow-hidden {\n overflow: hidden;\n}\n.overflow-visible {\n overflow: visible;\n}\n.whitespace-nowrap {\n white-space: nowrap;\n}\n.text-nowrap {\n text-wrap: nowrap;\n}\n.rounded {\n border-radius: 0.25rem;\n}\n.rounded-full {\n border-radius: 9999px;\n}\n.rounded-md {\n border-radius: 0.375rem;\n}\n.border {\n border-width: 1px;\n}\n.border-solid {\n border-style: solid;\n}\n.border-gray-400 {\n --tw-border-opacity: 1;\n border-color: rgb(156 163 175 / var(--tw-border-opacity, 1));\n}\n.border-gray-500 {\n --tw-border-opacity: 1;\n border-color: rgb(107 114 128 / var(--tw-border-opacity, 1));\n}\n.border-slate-200 {\n --tw-border-opacity: 1;\n border-color: rgb(226 232 240 / var(--tw-border-opacity, 1));\n}\n.border-slate-300 {\n --tw-border-opacity: 1;\n border-color: rgb(203 213 225 / var(--tw-border-opacity, 1));\n}\n.border-slate-700 {\n --tw-border-opacity: 1;\n border-color: rgb(51 65 85 / var(--tw-border-opacity, 1));\n}\n.bg-black {\n --tw-bg-opacity: 1;\n background-color: rgb(0 0 0 / var(--tw-bg-opacity, 1));\n}\n.bg-emerald-200 {\n --tw-bg-opacity: 1;\n background-color: rgb(167 243 208 / var(--tw-bg-opacity, 1));\n}\n.bg-green-200 {\n --tw-bg-opacity: 1;\n background-color: rgb(187 247 208 / var(--tw-bg-opacity, 1));\n}\n.bg-orange-200 {\n --tw-bg-opacity: 1;\n background-color: rgb(254 215 170 / var(--tw-bg-opacity, 1));\n}\n.bg-red-200 {\n --tw-bg-opacity: 1;\n background-color: rgb(254 202 202 / var(--tw-bg-opacity, 1));\n}\n.bg-red-500 {\n --tw-bg-opacity: 1;\n background-color: rgb(239 68 68 / var(--tw-bg-opacity, 1));\n}\n.bg-slate-50 {\n --tw-bg-opacity: 1;\n background-color: rgb(248 250 252 / var(--tw-bg-opacity, 1));\n}\n.bg-white {\n --tw-bg-opacity: 1;\n background-color: rgb(255 255 255 / var(--tw-bg-opacity, 1));\n}\n.bg-yellow-200 {\n --tw-bg-opacity: 1;\n background-color: rgb(254 240 138 / var(--tw-bg-opacity, 1));\n}\n.p-0 {\n padding: 0px;\n}\n.p-1 {\n padding: 0.25rem;\n}\n.p-2 {\n padding: 0.5rem;\n}\n.p-4 {\n padding: 1rem;\n}\n.p-8 {\n padding: 2rem;\n}\n.px-2 {\n padding-left: 0.5rem;\n padding-right: 0.5rem;\n}\n.px-3 {\n padding-left: 0.75rem;\n padding-right: 0.75rem;\n}\n.px-4 {\n padding-left: 1rem;\n padding-right: 1rem;\n}\n.px-6 {\n padding-left: 1.5rem;\n padding-right: 1.5rem;\n}\n.py-1 {\n padding-top: 0.25rem;\n padding-bottom: 0.25rem;\n}\n.py-2 {\n padding-top: 0.5rem;\n padding-bottom: 0.5rem;\n}\n.py-4 {\n padding-top: 1rem;\n padding-bottom: 1rem;\n}\n.py-6 {\n padding-top: 1.5rem;\n padding-bottom: 1.5rem;\n}\n.pb-2 {\n padding-bottom: 0.5rem;\n}\n.pb-4 {\n padding-bottom: 1rem;\n}\n.pb-6 {\n padding-bottom: 1.5rem;\n}\n.pb-8 {\n padding-bottom: 2rem;\n}\n.pl-0 {\n padding-left: 0px;\n}\n.pl-2 {\n padding-left: 0.5rem;\n}\n.pl-4 {\n padding-left: 1rem;\n}\n.pt-1 {\n padding-top: 0.25rem;\n}\n.pt-12 {\n padding-top: 3rem;\n}\n.pt-2 {\n padding-top: 0.5rem;\n}\n.pt-4 {\n padding-top: 1rem;\n}\n.pt-5 {\n padding-top: 1.25rem;\n}\n.pt-6 {\n padding-top: 1.5rem;\n}\n.pt-8 {\n padding-top: 2rem;\n}\n.text-left {\n text-align: left;\n}\n.text-center {\n text-align: center;\n}\n.text-right {\n text-align: right;\n}\n.align-middle {\n vertical-align: middle;\n}\n.text-2xl {\n font-size: 1.5rem;\n line-height: 2rem;\n}\n.text-base {\n font-size: 1rem;\n line-height: 1.5rem;\n}\n.text-lg {\n font-size: 1.125rem;\n line-height: 1.75rem;\n}\n.text-sm {\n font-size: 0.875rem;\n line-height: 1.25rem;\n}\n.text-xl {\n font-size: 1.25rem;\n line-height: 1.75rem;\n}\n.text-xs {\n font-size: 0.75rem;\n line-height: 1rem;\n}\n.font-bold {\n font-weight: 700;\n}\n.font-medium {\n font-weight: 500;\n}\n.font-normal {\n font-weight: 400;\n}\n.capitalize {\n text-transform: capitalize;\n}\n.text-emerald-600 {\n --tw-text-opacity: 1;\n color: rgb(5 150 105 / var(--tw-text-opacity, 1));\n}\n.text-emerald-700 {\n --tw-text-opacity: 1;\n color: rgb(4 120 87 / var(--tw-text-opacity, 1));\n}\n.text-gray-600 {\n --tw-text-opacity: 1;\n color: rgb(75 85 99 / var(--tw-text-opacity, 1));\n}\n.text-gray-900 {\n --tw-text-opacity: 1;\n color: rgb(17 24 39 / var(--tw-text-opacity, 1));\n}\n.text-green-600 {\n --tw-text-opacity: 1;\n color: rgb(22 163 74 / var(--tw-text-opacity, 1));\n}\n.text-orange-500 {\n --tw-text-opacity: 1;\n color: rgb(249 115 22 / var(--tw-text-opacity, 1));\n}\n.text-red-500 {\n --tw-text-opacity: 1;\n color: rgb(239 68 68 / var(--tw-text-opacity, 1));\n}\n.text-slate-400 {\n --tw-text-opacity: 1;\n color: rgb(148 163 184 / var(--tw-text-opacity, 1));\n}\n.text-slate-500 {\n --tw-text-opacity: 1;\n color: rgb(100 116 139 / var(--tw-text-opacity, 1));\n}\n.text-white {\n --tw-text-opacity: 1;\n color: rgb(255 255 255 / var(--tw-text-opacity, 1));\n}\n.text-yellow-500 {\n --tw-text-opacity: 1;\n color: rgb(234 179 8 / var(--tw-text-opacity, 1));\n}\n.underline {\n text-decoration-line: underline;\n}\n.shadow {\n --tw-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);\n --tw-shadow-colored: 0 1px 3px 0 var(--tw-shadow-color), 0 1px 2px -1px var(--tw-shadow-color);\n box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);\n}\n.shadow-lg {\n --tw-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);\n --tw-shadow-colored: 0 10px 15px -3px var(--tw-shadow-color), 0 4px 6px -4px var(--tw-shadow-color);\n box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);\n}\n.shadow-md {\n --tw-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);\n --tw-shadow-colored: 0 4px 6px -1px var(--tw-shadow-color), 0 2px 4px -2px var(--tw-shadow-color);\n box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);\n}\n.shadow-none {\n --tw-shadow: 0 0 #0000;\n --tw-shadow-colored: 0 0 #0000;\n box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);\n}\n.shadow-sm {\n --tw-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);\n --tw-shadow-colored: 0 1px 2px 0 var(--tw-shadow-color);\n box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);\n}\n.shadow-xl {\n --tw-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);\n --tw-shadow-colored: 0 20px 25px -5px var(--tw-shadow-color), 0 8px 10px -6px var(--tw-shadow-color);\n box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);\n}\n.transition {\n transition-property: color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, -webkit-backdrop-filter;\n transition-property: color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, backdrop-filter;\n transition-property: color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, backdrop-filter, -webkit-backdrop-filter;\n transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);\n transition-duration: 150ms;\n}\n.font-light {\n font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica Neue, Arial, Noto Sans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol, Noto Color Emoji;\n}\n.font-medium {\n font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica Neue, Arial, Noto Sans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol, Noto Color Emoji;\n}\n.font-bold {\n font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica Neue, Arial, Noto Sans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol, Noto Color Emoji;\n}\n@media (min-width: 768px) {\n .sm\\:flex {\n display: flex;\n }\n .sm\\:hidden {\n display: none;\n }\n}\n* {\n margin: 0;\n padding: 0;\n box-sizing: border-box !important;\n font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica Neue, Arial, Noto Sans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol, Noto Color Emoji;\n line-height: 1.15;\n}\nbody {\n color: #232323;\n background-color: #f8fafc;\n}\nth {\n font-weight: normal;\n}\ncode {\n font-family: source-code-pro, Menlo, Monaco, Consolas, \"Courier New\", monospace;\n}\n@media only screen and (max-width: 768px) {\n select,\n textarea,\n input[type=\"text\"],\n input[type=\"password\"],\n input[type=\"datetime\"],\n input[type=\"datetime-local\"],\n input[type=\"date\"],\n input[type=\"month\"],\n input[type=\"time\"],\n input[type=\"week\"],\n input[type=\"number\"],\n input[type=\"email\"],\n input[type=\"url\"],\n input[type=\"search\"],\n input[type=\"tel\"],\n input[type=\"color\"] {\n font-size: 16px !important;\n }\n}\n@keyframes App-logo-spin {\n from {\n transform: rotate(0deg);\n }\n to {\n transform: rotate(360deg);\n }\n}\n";
46
46
  styleInject(css_248z);
47
47
 
48
48
  /******************************************************************************
@@ -1775,6 +1775,48 @@ var quoteMetaTitle = function (_a) {
1775
1775
  return vendorName + " " + documentName;
1776
1776
  };
1777
1777
 
1778
+ var fetchPDF = function (apiEndpoint, invoiceUuid) { return __awaiter(void 0, void 0, void 0, function () {
1779
+ var response;
1780
+ return __generator(this, function (_a) {
1781
+ switch (_a.label) {
1782
+ case 0:
1783
+ if (!invoiceUuid) {
1784
+ throw new Error("Invoice ID is required to fetch PDF");
1785
+ }
1786
+ return [4 /*yield*/, fetch("".concat(apiEndpoint, "/api/legacy_invoices/").concat(invoiceUuid))];
1787
+ case 1:
1788
+ response = _a.sent();
1789
+ if (!response.ok)
1790
+ throw new Error("Failed to fetch PDF");
1791
+ return [2 /*return*/, response.blob()]; // Return the PDF as a blob
1792
+ }
1793
+ });
1794
+ }); };
1795
+ function InvoicePDF(_a) {
1796
+ var invoiceUuid = _a.invoiceUuid, apiHost = _a.apiHost;
1797
+ var _b = useState(undefined), pdfUrl = _b[0], setPdfUrl = _b[1];
1798
+ var _c = useQuery({
1799
+ queryKey: ["invoicePDF", invoiceUuid],
1800
+ queryFn: function () { return fetchPDF(apiHost || "", invoiceUuid); },
1801
+ enabled: Boolean(invoiceUuid),
1802
+ }), pdfBlob = _c.data, isLoading = _c.isLoading;
1803
+ useEffect(function () {
1804
+ if (pdfBlob) {
1805
+ var url_1 = URL.createObjectURL(pdfBlob);
1806
+ setPdfUrl(url_1);
1807
+ return function () { return URL.revokeObjectURL(url_1); };
1808
+ }
1809
+ }, [pdfBlob]);
1810
+ if (isLoading || !pdfUrl)
1811
+ return jsx(Fragment, {});
1812
+ return (jsx("iframe", { src: pdfUrl, style: {
1813
+ border: "none",
1814
+ gridColumn: "1/-1",
1815
+ minHeight: "1000px",
1816
+ minWidth: "780px",
1817
+ }, title: "Invoice PDF", width: "100%" }));
1818
+ }
1819
+
1778
1820
  var PaymentContext = createContext$1({});
1779
1821
 
1780
1822
  var paymentMethodsQuery = "query paymentMethods ($filter: String, $first: Int, $sort: String) {\n paymentMethods (filter: $filter, first: $first, sort: $sort) {\n nodes {\n id\n disabled\n pluginId\n accountId\n expirationDate\n plugin {\n guid\n id\n }\n state\n metadata {\n issuer\n identifier\n kind\n description\n icon\n }\n }\n }\n}";
@@ -1846,289 +1888,110 @@ var getQuoteAmountDue = function (quote) {
1846
1888
  return quote.amountDue;
1847
1889
  };
1848
1890
 
1849
- // Simulated payment creation and confirmation
1850
- var confirmPayment = function (_a) {
1851
- var amount = _a.amount, currency = _a.currency;
1852
- return { token: "DemoPayTestToken", amount: amount, currency: currency };
1853
- };
1854
- var DIGIT_REGEX = /\d/;
1855
- var isDigit = function (char) { return DIGIT_REGEX.test(char); };
1856
- var isDeletion = function (char) { return [8, 46].includes(char); }; // Backspace or Delete
1857
- var isNavigation = function (char) { return [9, 37, 38, 39, 40].includes(char); }; // Tab, Arrows
1858
- var isModifier = function (char) { return [16, 17, 18].includes(char); }; // Shift, Ctrl, Alt
1859
- var isValidKey = function (code) {
1860
- return isDeletion(code) || isNavigation(code) || isModifier(code);
1861
- };
1862
- var isValidExpiry = function (expiry) {
1863
- var month = parseInt(expiry.substring(0, 2), 10);
1864
- var year = parseInt(expiry.substring(2, 4), 10) + 2000;
1865
- if (isNaN(month) || isNaN(year))
1866
- return false;
1867
- if (month < 1 || month > 12)
1868
- return false;
1869
- return true;
1870
- };
1871
- var isCardExpired = function (expiry) {
1872
- var month = parseInt(expiry.substring(0, 2), 10);
1873
- var year = parseInt(expiry.substring(2, 4), 10) + 2000;
1874
- var expiryDate = new Date(year, month, 1);
1875
- return expiryDate < new Date();
1876
- };
1877
- var formatCardExpiry = function (cardExpiry) {
1878
- if (cardExpiry.length <= 2)
1879
- return cardExpiry;
1880
- return cardExpiry.substring(0, 2) + "/" + cardExpiry.substring(2);
1881
- };
1882
- // removes spaces from a credit card number
1883
- var unformatCardNumber = function (cardNumber) {
1884
- var cardNumberArray = cardNumber.split("");
1885
- var unformattedCardNumberArray = cardNumberArray.filter(function (character) { return character !== " "; });
1886
- return unformattedCardNumberArray.join("");
1887
- };
1888
- var storePayment = function (options, plugin, apiHost, accountId) { return __awaiter(void 0, void 0, void 0, function () {
1889
- var testCreditCardNumber, testCreditCardCvc, testCreditCardExpirationDate, token, response;
1890
- return __generator(this, function (_a) {
1891
- switch (_a.label) {
1892
- case 0:
1893
- testCreditCardNumber = options.testCreditCardNumber, testCreditCardCvc = options.testCreditCardCvc, testCreditCardExpirationDate = options.testCreditCardExpirationDate, token = options.token;
1894
- return [4 /*yield*/, invokePlugin({
1895
- method: "store_payment_method",
1896
- plugin: plugin,
1897
- payload: {
1898
- test_credit_card_number: testCreditCardNumber,
1899
- test_credit_card_cvc: testCreditCardCvc,
1900
- test_credit_card_expiration_date: testCreditCardExpirationDate,
1901
- account_id: accountId,
1902
- },
1903
- token: token,
1904
- apiHost: apiHost,
1905
- })];
1906
- case 1:
1907
- response = _a.sent();
1908
- if ((response === null || response === void 0 ? void 0 : response.status) !== "success")
1909
- throw new Error(response === null || response === void 0 ? void 0 : response.message);
1910
- return [2 /*return*/, response];
1911
- }
1912
- });
1913
- }); };
1914
-
1915
- function usePay$1(_a) {
1916
- var _this = this;
1917
- var onPaymentSuccess = _a.onPaymentSuccess, onPaymentError = _a.onPaymentError, quote = _a.quote, invoice = _a.invoice;
1918
- var pay = function (_a) {
1919
- var plugin = _a.plugin, savePaymentMethod = _a.savePaymentMethod;
1920
- return __awaiter(_this, void 0, void 0, function () {
1921
- var amountDue, currencyId, response;
1922
- return __generator(this, function (_b) {
1923
- amountDue = quote ? getQuoteAmountDue(quote) : invoice === null || invoice === void 0 ? void 0 : invoice.amountDue;
1924
- currencyId = (quote === null || quote === void 0 ? void 0 : quote.currencyId) || (invoice === null || invoice === void 0 ? void 0 : invoice.currency);
1925
- if (!amountDue || !currencyId) {
1926
- throw new Error("No amount or currencyId");
1927
- }
1928
- try {
1929
- response = confirmPayment({
1930
- amount: amountDue,
1931
- currency: currencyId,
1932
- });
1933
- onPaymentSuccess({
1934
- pluginPaymentResponse: {
1935
- plugin: plugin,
1936
- token: response.token,
1937
- savePaymentMethod: savePaymentMethod,
1938
- },
1939
- });
1940
- }
1941
- catch (error) {
1942
- onPaymentError === null || onPaymentError === void 0 ? void 0 : onPaymentError(error);
1943
- }
1944
- return [2 /*return*/];
1945
- });
1946
- });
1947
- };
1948
- return { pay: pay };
1949
- }
1950
-
1951
- var createPaymentMethod = function (_a) {
1952
- var paymentMethodId = _a.paymentMethodId, plugin = _a.plugin, token = _a.token, apiHost = _a.apiHost, accountId = _a.accountId;
1953
- return __awaiter(void 0, void 0, void 0, function () {
1954
- var response;
1955
- return __generator(this, function (_b) {
1956
- switch (_b.label) {
1957
- case 0: return [4 /*yield*/, invokePlugin({
1958
- plugin: plugin,
1959
- method: "store_payment_method",
1960
- payload: {
1961
- payment_method_id: paymentMethodId,
1962
- account_id: accountId,
1963
- },
1964
- token: token,
1965
- apiHost: apiHost,
1966
- })];
1967
- case 1:
1968
- response = _b.sent();
1969
- if (response.status !== "success")
1970
- throw new Error(response.message || "Unknown error");
1971
- return [2 /*return*/, response];
1972
- }
1973
- });
1974
- });
1975
- };
1976
- var createSetupIntent = function (plugin, token, apiHost, accountId) {
1977
- return invokePlugin({
1978
- plugin: plugin,
1979
- method: "create_setup_intent",
1980
- token: token,
1981
- apiHost: apiHost,
1982
- payload: {
1983
- account_id: accountId,
1984
- },
1985
- });
1986
- };
1987
- var createPaymentIntent = function (_a) {
1988
- var payable = _a.payable, savePaymentMethod = _a.savePaymentMethod, memo = _a.memo, plugin = _a.plugin, token = _a.token, apiHost = _a.apiHost;
1891
+ var MUTATION$8 = "\n mutation checkout(\n $invoiceId: ID,\n $quoteId: ID,\n $paymentMethodId: ID,\n $paymentMethodData: CheckoutPaymentMethodAttributes\n ) {\n checkout(\n invoiceId: $invoiceId,\n quoteId: $quoteId,\n paymentMethodId: $paymentMethodId,\n paymentMethodData: $paymentMethodData\n ) {\n invoice {\n id\n state\n amount\n amountDue\n }\n payment {\n id\n state\n amount\n }\n paymentApplication {\n id\n invoiceId\n paymentId\n }\n transaction {\n id\n amount\n }\n }\n }\n";
1892
+ var checkout = function (_a) {
1893
+ var quoteId = _a.quoteId, invoiceId = _a.invoiceId, paymentMethodId = _a.paymentMethodId, paymentMethodData = _a.paymentMethodData, token = _a.token, apiHost = _a.apiHost;
1989
1894
  return __awaiter(void 0, void 0, void 0, function () {
1990
- var payload, response;
1895
+ var mutationVars, response, errors;
1991
1896
  return __generator(this, function (_b) {
1992
1897
  switch (_b.label) {
1993
1898
  case 0:
1994
- payload = {
1995
- payable_id: payable.payableId,
1996
- save_payment_method: savePaymentMethod,
1997
- memo: memo,
1899
+ mutationVars = {
1900
+ quoteId: quoteId,
1901
+ invoiceId: invoiceId,
1902
+ paymentMethodId: paymentMethodId,
1998
1903
  };
1999
- return [4 /*yield*/, invokePlugin({
2000
- plugin: plugin,
2001
- method: "create_payment_intent",
2002
- payload: payload,
1904
+ if (paymentMethodData) {
1905
+ mutationVars.paymentMethodData = __assign(__assign({}, paymentMethodData), { metadata: paymentMethodData.metadata });
1906
+ }
1907
+ return [4 /*yield*/, gqlRequest$1({
1908
+ query: MUTATION$8,
2003
1909
  token: token,
1910
+ vars: mutationVars,
2004
1911
  apiHost: apiHost,
2005
1912
  })];
2006
1913
  case 1:
2007
1914
  response = _b.sent();
2008
- if (response.status !== "success")
2009
- throw new Error(response.message || "Unknown error");
2010
- return [2 /*return*/, response.payload];
1915
+ errors = (response === null || response === void 0 ? void 0 : response.checkout).errors;
1916
+ if (errors)
1917
+ throw errors;
1918
+ return [2 /*return*/, {
1919
+ savePaymentMethod: paymentMethodData === null || paymentMethodData === void 0 ? void 0 : paymentMethodData.savePaymentMethod,
1920
+ }];
2011
1921
  }
2012
1922
  });
2013
1923
  });
2014
1924
  };
2015
- var fetchStripeKey = function (plugin, token, apiHost, accountId) { return __awaiter(void 0, void 0, void 0, function () {
2016
- var response;
2017
- return __generator(this, function (_a) {
2018
- switch (_a.label) {
2019
- case 0: return [4 /*yield*/, invokePlugin({
2020
- plugin: plugin,
2021
- method: "retrieve_config",
2022
- token: token,
2023
- apiHost: apiHost,
2024
- payload: {
2025
- account_id: accountId,
2026
- },
2027
- })];
2028
- case 1:
2029
- response = _a.sent();
2030
- return [2 /*return*/, response];
2031
- }
2032
- });
2033
- }); };
2034
- loadStripe.setLoadParameters({ advancedFraudSignals: false });
2035
- var useStripePlugin = function (plugin, token, apiHost, accountId) {
2036
- var _a = useState(null), stripe = _a[0], setStripe = _a[1];
2037
- var showErrorNotification = useErrorNotification();
2038
- var options = {
2039
- mode: "setup",
2040
- // TODO: Fetch currency from the entity/account
2041
- currency: "usd",
2042
- setupFutureUsage: "off_session",
2043
- };
2044
- if (!plugin)
2045
- return { stripe: null, options: options };
2046
- useEffect(function () {
2047
- fetchStripeKey(plugin, token, apiHost || "", accountId)
2048
- .then(function (_a) {
2049
- var payload = _a.payload;
2050
- return loadStripe(payload.publishable_key).then(setStripe);
2051
- })
2052
- .catch(function (error) {
2053
- console.error("Caught Error in fetching stripe key: ", error);
2054
- showErrorNotification(error.message, "Unexpected Error fetching key");
1925
+
1926
+ function usePay$1(_a) {
1927
+ var _this = this;
1928
+ var onPaymentSuccess = _a.onPaymentSuccess, onPaymentError = _a.onPaymentError, quote = _a.quote, invoice = _a.invoice, storedPaymentMethod = _a.storedPaymentMethod;
1929
+ var _b = useContext$1(BunnyContext), token = _b.token, apiHost = _b.apiHost;
1930
+ var pay = function () { return __awaiter(_this, void 0, void 0, function () {
1931
+ var amountDue, currencyId, response, error_1;
1932
+ return __generator(this, function (_a) {
1933
+ switch (_a.label) {
1934
+ case 0:
1935
+ amountDue = quote ? getQuoteAmountDue(quote) : invoice === null || invoice === void 0 ? void 0 : invoice.amountDue;
1936
+ currencyId = (quote === null || quote === void 0 ? void 0 : quote.currencyId) || (invoice === null || invoice === void 0 ? void 0 : invoice.currency);
1937
+ if (!amountDue || !currencyId) {
1938
+ throw new Error("No amount or currencyId");
1939
+ }
1940
+ _a.label = 1;
1941
+ case 1:
1942
+ _a.trys.push([1, 3, , 4]);
1943
+ return [4 /*yield*/, checkout({
1944
+ invoiceId: invoice === null || invoice === void 0 ? void 0 : invoice.id,
1945
+ quoteId: quote === null || quote === void 0 ? void 0 : quote.id,
1946
+ paymentMethodId: storedPaymentMethod === null || storedPaymentMethod === void 0 ? void 0 : storedPaymentMethod.id,
1947
+ token: token,
1948
+ apiHost: apiHost,
1949
+ })];
1950
+ case 2:
1951
+ response = _a.sent();
1952
+ onPaymentSuccess === null || onPaymentSuccess === void 0 ? void 0 : onPaymentSuccess(response);
1953
+ return [3 /*break*/, 4];
1954
+ case 3:
1955
+ error_1 = _a.sent();
1956
+ onPaymentError === null || onPaymentError === void 0 ? void 0 : onPaymentError(error_1);
1957
+ return [3 /*break*/, 4];
1958
+ case 4: return [2 /*return*/];
1959
+ }
2055
1960
  });
2056
- // eslint-disable-next-line
2057
- }, [plugin, token]);
2058
- return { stripe: stripe, options: options };
2059
- };
1961
+ }); };
1962
+ return { pay: pay };
1963
+ }
2060
1964
 
2061
1965
  function usePay(_a) {
2062
1966
  var _this = this;
2063
- var onPaymentSuccess = _a.onPaymentSuccess, onPaymentError = _a.onPaymentError, quote = _a.quote, invoice = _a.invoice;
1967
+ var onPaymentSuccess = _a.onPaymentSuccess, onPaymentError = _a.onPaymentError, quote = _a.quote, invoice = _a.invoice, storedPaymentMethod = _a.storedPaymentMethod;
2064
1968
  // Hooks
2065
- var elements = useElements();
2066
- var stripe = useStripe();
2067
1969
  var _b = useContext$1(BunnyContext), token = _b.token, apiHost = _b.apiHost;
2068
- var pay = function (_a) {
2069
- var plugin = _a.plugin;
2070
- return __awaiter(_this, void 0, void 0, function () {
2071
- var payable, submitError, paymentIntent, clientSecret, response, paymentIntentId, error_1;
2072
- var _b;
2073
- return __generator(this, function (_c) {
2074
- switch (_c.label) {
2075
- case 0:
2076
- payable = (quote || invoice);
2077
- _c.label = 1;
2078
- case 1:
2079
- _c.trys.push([1, 5, , 6]);
2080
- if (!stripe)
2081
- throw new Error("Form is not ready");
2082
- if (!elements)
2083
- throw new Error("Elements couldn't be retrieved");
2084
- return [4 /*yield*/, elements.submit()];
2085
- case 2:
2086
- submitError = (_c.sent()).error;
2087
- if (submitError)
2088
- throw new Error(submitError.message);
2089
- return [4 /*yield*/, createPaymentIntent({
2090
- payable: payable,
2091
- savePaymentMethod: true,
2092
- plugin: plugin,
2093
- token: token,
2094
- apiHost: apiHost || "",
2095
- })];
2096
- case 3:
2097
- paymentIntent = _c.sent();
2098
- clientSecret = paymentIntent === null || paymentIntent === void 0 ? void 0 : paymentIntent.client_secret;
2099
- return [4 /*yield*/, stripe.confirmPayment({
2100
- elements: elements,
2101
- clientSecret: clientSecret,
2102
- redirect: "if_required",
2103
- confirmParams: {
2104
- return_url: window.location.href,
2105
- },
2106
- })];
2107
- case 4:
2108
- response = _c.sent();
2109
- // See https://stripe.com/docs/payments/save-during-payment?platform=web#web-submit-payment
2110
- if (response.error)
2111
- throw new Error(response.error.message);
2112
- paymentIntentId = (_b = response.paymentIntent) === null || _b === void 0 ? void 0 : _b.id;
2113
- if (!paymentIntentId)
2114
- throw new Error("Payment intent couldn't be retrieved");
2115
- onPaymentSuccess === null || onPaymentSuccess === void 0 ? void 0 : onPaymentSuccess({
2116
- pluginPaymentResponse: {
2117
- plugin: plugin,
2118
- token: paymentIntentId,
2119
- savePaymentMethod: true,
2120
- },
2121
- });
2122
- return [3 /*break*/, 6];
2123
- case 5:
2124
- error_1 = _c.sent();
2125
- onPaymentError === null || onPaymentError === void 0 ? void 0 : onPaymentError(error_1);
2126
- return [3 /*break*/, 6];
2127
- case 6: return [2 /*return*/];
2128
- }
2129
- });
1970
+ var pay = function () { return __awaiter(_this, void 0, void 0, function () {
1971
+ var response, error_1;
1972
+ return __generator(this, function (_a) {
1973
+ switch (_a.label) {
1974
+ case 0:
1975
+ _a.trys.push([0, 2, , 3]);
1976
+ return [4 /*yield*/, checkout({
1977
+ invoiceId: invoice === null || invoice === void 0 ? void 0 : invoice.id,
1978
+ quoteId: quote === null || quote === void 0 ? void 0 : quote.id,
1979
+ paymentMethodId: storedPaymentMethod === null || storedPaymentMethod === void 0 ? void 0 : storedPaymentMethod.id,
1980
+ token: token,
1981
+ apiHost: apiHost,
1982
+ })];
1983
+ case 1:
1984
+ response = _a.sent();
1985
+ onPaymentSuccess === null || onPaymentSuccess === void 0 ? void 0 : onPaymentSuccess(response);
1986
+ return [3 /*break*/, 3];
1987
+ case 2:
1988
+ error_1 = _a.sent();
1989
+ onPaymentError === null || onPaymentError === void 0 ? void 0 : onPaymentError(error_1);
1990
+ return [3 /*break*/, 3];
1991
+ case 3: return [2 /*return*/];
1992
+ }
2130
1993
  });
2131
- };
1994
+ }); };
2132
1995
  return { pay: pay };
2133
1996
  }
2134
1997
 
@@ -2137,30 +2000,29 @@ var ActualCheckoutFooter = function (_a) {
2137
2000
  var quote = _a.quote, invoice = _a.invoice, onPaymentSuccess = _a.onPaymentSuccess, noPadding = _a.noPadding, plugin = _a.plugin;
2138
2001
  var isMobile = useIsMobile();
2139
2002
  var _b = useState(false), isPaying = _b[0], setIsPaying = _b[1];
2003
+ var storedPaymentMethod = useContext$1(PaymentContext).storedPaymentMethod;
2140
2004
  var amountDue = quote ? getQuoteAmountDue(quote) : invoice === null || invoice === void 0 ? void 0 : invoice.amountDue;
2141
2005
  var currencyId = (quote === null || quote === void 0 ? void 0 : quote.currencyId) || (invoice === null || invoice === void 0 ? void 0 : invoice.currency);
2142
2006
  // Payment hooks
2143
2007
  var payDemoPay = usePay$1({
2144
- onPaymentSuccess: function (response) {
2145
- onPaymentSuccess(response);
2146
- },
2008
+ onPaymentSuccess: onPaymentSuccess,
2147
2009
  onPaymentError: function (error) {
2148
2010
  setIsPaying(false);
2149
- showErrorNotification$1(error);
2011
+ showErrorNotification$1(JSON.stringify(error));
2150
2012
  },
2151
2013
  quote: quote,
2152
2014
  invoice: invoice,
2015
+ storedPaymentMethod: storedPaymentMethod,
2153
2016
  }).pay;
2154
2017
  var payStripe = usePay({
2155
- onPaymentSuccess: function (response) {
2156
- onPaymentSuccess(response);
2157
- },
2018
+ onPaymentSuccess: onPaymentSuccess,
2158
2019
  onPaymentError: function (error) {
2159
2020
  setIsPaying(false);
2160
- showErrorNotification$1(error);
2021
+ showErrorNotification$1(JSON.stringify(error));
2161
2022
  },
2162
2023
  quote: quote,
2163
2024
  invoice: invoice,
2025
+ storedPaymentMethod: storedPaymentMethod,
2164
2026
  }).pay;
2165
2027
  var handlePaymentSubmit = function () { return __awaiter(void 0, void 0, void 0, function () {
2166
2028
  var _a;
@@ -2170,22 +2032,17 @@ var ActualCheckoutFooter = function (_a) {
2170
2032
  case 0:
2171
2033
  if (!plugin)
2172
2034
  return [2 /*return*/];
2173
- _a = (_c = (_b = plugin === null || plugin === void 0 ? void 0 : plugin.components) === null || _b === void 0 ? void 0 : _b.frontend) === null || _c === void 0 ? void 0 : _c[0].name;
2035
+ _a = (_c = (_b = plugin.components) === null || _b === void 0 ? void 0 : _b.frontend) === null || _c === void 0 ? void 0 : _c[0].name;
2174
2036
  switch (_a) {
2175
2037
  case "StripePayment": return [3 /*break*/, 1];
2176
2038
  case "DemoPayPayment": return [3 /*break*/, 3];
2177
2039
  }
2178
2040
  return [3 /*break*/, 5];
2179
- case 1: return [4 /*yield*/, payStripe({
2180
- plugin: plugin,
2181
- })];
2041
+ case 1: return [4 /*yield*/, payStripe()];
2182
2042
  case 2:
2183
2043
  _d.sent();
2184
2044
  return [3 /*break*/, 6];
2185
- case 3: return [4 /*yield*/, payDemoPay({
2186
- plugin: plugin,
2187
- savePaymentMethod: false,
2188
- })];
2045
+ case 3: return [4 /*yield*/, payDemoPay()];
2189
2046
  case 4:
2190
2047
  _d.sent();
2191
2048
  return [3 /*break*/, 6];
@@ -2200,18 +2057,10 @@ var ActualCheckoutFooter = function (_a) {
2200
2057
  }, size: isMobile ? "large" : "middle", type: "primary" }, { children: "".concat(isPaying ? "Paying" : "Pay", " ").concat(amountDue && currencyId ? formatCurrency(amountDue, currencyId) : "") })) })));
2201
2058
  };
2202
2059
  var CheckoutFooter = function (_a) {
2203
- var _b, _c;
2204
2060
  var quote = _a.quote, invoice = _a.invoice, onPaymentSuccess = _a.onPaymentSuccess, noPadding = _a.noPadding, plugin = _a.plugin;
2205
2061
  if (!plugin)
2206
2062
  return null;
2207
- var _d = useContext$1(BunnyContext), token = _d.token, apiHost = _d.apiHost;
2208
- var accountId = useContext$1(PaymentContext).accountId;
2209
- // If plugin is not stripe, pass undefined to prevent errors
2210
- var stripePlugin = ((_c = (_b = plugin === null || plugin === void 0 ? void 0 : plugin.components) === null || _b === void 0 ? void 0 : _b.frontend) === null || _c === void 0 ? void 0 : _c[0].name) === "StripePayment"
2211
- ? plugin
2212
- : undefined;
2213
- var _e = useStripePlugin(stripePlugin, token, apiHost, accountId), stripe = _e.stripe, options = _e.options;
2214
- return (jsx(Elements, __assign({ options: options, stripe: stripe }, { children: jsx(ActualCheckoutFooter, { plugin: plugin, invoice: invoice, quote: quote, onPaymentSuccess: onPaymentSuccess, noPadding: noPadding }) })));
2063
+ return (jsx(ActualCheckoutFooter, { plugin: plugin, invoice: invoice, quote: quote, onPaymentSuccess: onPaymentSuccess, noPadding: noPadding }));
2215
2064
  };
2216
2065
 
2217
2066
  var dayjs_min = {exports: {}};
@@ -2245,7 +2094,7 @@ var CreditCard = function (_a) {
2245
2094
  var onClickRemove = _a.onClickRemove, onClickUpdate = _a.onClickUpdate, paymentMethodData = _a.paymentMethodData, _c = _a.shadow, shadow = _c === void 0 ? "shadow-md" : _c, _d = _a.cardEnabled, cardEnabled = _d === void 0 ? true : _d;
2246
2095
  var isMobile = useIsMobile();
2247
2096
  var Wrapper = cardEnabled ? Card : "div";
2248
- return (jsxs(Wrapper, __assign({ className: "".concat(cardEnabled ? shadow : "", " m-0") }, { children: [jsxs("div", __assign({ className: "flex items-center justify-between gap-4 p-4" }, { children: [jsxs("div", __assign({ className: "flex items-center gap-4" }, { children: [jsxs("div", __assign({ className: "flex items-center gap-2" }, { children: [jsx(CardImage, { paymentMethodData: paymentMethodData }), jsx(Text$f, { children: (_b = paymentMethodData === null || paymentMethodData === void 0 ? void 0 : paymentMethodData.metadata) === null || _b === void 0 ? void 0 : _b.description })] })), jsx(Tag, __assign({ color: isExpired(paymentMethodData) ? "red" : "green" }, { children: isExpired(paymentMethodData) ? "Expired" : "Valid" }))] })), !isMobile && (jsx(CardActions, { onClickRemove: onClickRemove, onClickUpdate: onClickUpdate }))] })), dayjs(paymentMethodData === null || paymentMethodData === void 0 ? void 0 : paymentMethodData.expirationDate).isValid() && (jsxs(Fragment, { children: [jsx(Divider, {}), jsxs("div", __assign({ className: "flex flex-col p-4" }, { children: [jsx(CardAttribute, { title: "EXPIRATION", value: expirationDate(paymentMethodData) }), isMobile && (jsx(CardActions, { onClickRemove: onClickRemove, onClickUpdate: onClickUpdate }))] }))] }))] })));
2097
+ return (jsxs(Wrapper, __assign({ className: "".concat(cardEnabled ? shadow : "", " m-0") }, { children: [jsxs("div", __assign({ className: "flex items-center justify-between gap-4 p-4" }, { children: [jsxs("div", __assign({ className: "flex items-center gap-4" }, { children: [jsxs("div", __assign({ className: "flex items-center gap-2" }, { children: [jsx(CardImage, { paymentMethodData: paymentMethodData }), jsx(Text$f, { children: (_b = paymentMethodData === null || paymentMethodData === void 0 ? void 0 : paymentMethodData.metadata) === null || _b === void 0 ? void 0 : _b.identifier })] })), jsx(Tag, __assign({ color: isExpired(paymentMethodData) ? "red" : "green" }, { children: isExpired(paymentMethodData) ? "Expired" : "Valid" }))] })), !isMobile && (jsx(CardActions, { onClickRemove: onClickRemove, onClickUpdate: onClickUpdate }))] })), dayjs(paymentMethodData === null || paymentMethodData === void 0 ? void 0 : paymentMethodData.expirationDate).isValid() && (jsxs(Fragment, { children: [jsx(Divider, {}), jsxs("div", __assign({ className: "flex flex-col p-4" }, { children: [jsx(CardAttribute, { title: "EXPIRATION", value: expirationDate(paymentMethodData) }), isMobile && (jsx(CardActions, { onClickRemove: onClickRemove, onClickUpdate: onClickUpdate }))] }))] }))] })));
2249
2098
  };
2250
2099
  var MiniCreditCard = function (_a) {
2251
2100
  var _b;
@@ -2257,7 +2106,7 @@ var MiniCreditCard = function (_a) {
2257
2106
  var backgroundColor = useMemo(function () {
2258
2107
  return darkMode ? "var(--row-background-alternate)" : "bg-slate-50";
2259
2108
  }, [darkMode]);
2260
- return (jsx("div", __assign({ className: "flex flex-row justify-between items-center p-1 px-3 border-solid ".concat(backgroundColor, " ").concat(borderColor, " rounded-md border") }, { children: paymentMethodData ? (jsxs(Fragment, { children: [jsxs("div", __assign({ className: "flex flex-row gap-4" }, { children: [jsxs("div", __assign({ className: "flex items-center gap-4" }, { children: [jsxs("div", __assign({ className: "flex items-center gap-2" }, { children: [jsx(CardImage, { paymentMethodData: paymentMethodData }), jsx(Text$f, { children: (_b = paymentMethodData === null || paymentMethodData === void 0 ? void 0 : paymentMethodData.metadata) === null || _b === void 0 ? void 0 : _b.description })] })), jsx(Tag, __assign({ color: isExpired(paymentMethodData) ? "red" : "green" }, { children: isExpired(paymentMethodData) ? "Expired" : "Valid" }))] })), jsx("div", __assign({ className: "flex flex-row gap-1 items-center" }, { children: dayjs(paymentMethodData === null || paymentMethodData === void 0 ? void 0 : paymentMethodData.expirationDate).isValid() && (jsxs(Fragment, { children: [jsx(Text$f, __assign({ className: "text-slate-400", style: { fontSize: "11px" } }, { children: "EXP" })), jsx(Text$f, { children: expirationDate(paymentMethodData) })] })) }))] })), !hideRemoveButton && (jsx(Popconfirm, __assign({ title: "Remove card?", onConfirm: onClickRemove }, { children: jsx(Button$1, __assign({ className: "font-normal p-0", type: "link" }, { children: "Remove" })) })))] })) : (jsxs("div", __assign({ className: "flex flex-row gap-2 items-center" }, { children: [jsx(CreditCardOutlined$1, {}), jsx(Text$f, __assign({ className: "text-slate-400", style: { fontSize: "11px" } }, { children: "No payment method selected" })), jsx(Button$1, { disabled: true, type: "link" })] }))) })));
2109
+ return (jsx("div", __assign({ className: "flex flex-row justify-between items-center p-1 px-3 border-solid ".concat(backgroundColor, " ").concat(borderColor, " rounded-md border") }, { children: paymentMethodData ? (jsxs(Fragment, { children: [jsx("div", __assign({ className: "flex flex-row gap-4" }, { children: jsxs("div", __assign({ className: "flex items-center gap-4 space-between w-full" }, { children: [jsx(CardImage, { paymentMethodData: paymentMethodData }), jsx(Text$f, { children: (_b = paymentMethodData === null || paymentMethodData === void 0 ? void 0 : paymentMethodData.metadata) === null || _b === void 0 ? void 0 : _b.identifier }), jsx(Tag, __assign({ color: isExpired(paymentMethodData) ? "red" : "green" }, { children: isExpired(paymentMethodData) ? "Expired" : "Valid" }))] })) })), !hideRemoveButton && (jsx(Popconfirm, __assign({ title: "Remove card?", onConfirm: onClickRemove }, { children: jsx(Button$1, __assign({ className: "font-normal p-0", type: "link" }, { children: "Remove" })) })))] })) : (jsxs("div", __assign({ className: "flex flex-row gap-2 items-center" }, { children: [jsx(CreditCardOutlined$1, {}), jsx(Text$f, __assign({ className: "text-slate-400", style: { fontSize: "11px" } }, { children: "No payment method selected" })), jsx(Button$1, { disabled: true, type: "link" })] }))) })));
2261
2110
  };
2262
2111
  var CardImage = function (_a) {
2263
2112
  var _b, _c;
@@ -2303,6 +2152,67 @@ var SavePaymentMethodFooter = function (_a) {
2303
2152
  return (jsxs("div", __assign({ className: "flex justify-end gap-2 ".concat(noPadding ? "" : "pt-6") }, { children: [onClickCancel && (jsx(Button$1, __assign({ className: "w-full", size: isMobile ? "large" : "middle", onClick: function () { return onClickCancel(); } }, { children: "Cancel" }))), jsx(Button$1, __assign({ className: "w-full", disabled: isSaving, onClick: onSave, size: isMobile ? "large" : "middle", type: "primary" }, { children: isSaving ? "Saving" : "Save" }))] })));
2304
2153
  };
2305
2154
 
2155
+ var DIGIT_REGEX = /\d/;
2156
+ var isDigit = function (char) { return DIGIT_REGEX.test(char); };
2157
+ var isDeletion = function (char) { return [8, 46].includes(char); }; // Backspace or Delete
2158
+ var isNavigation = function (char) { return [9, 37, 38, 39, 40].includes(char); }; // Tab, Arrows
2159
+ var isModifier = function (char) { return [16, 17, 18].includes(char); }; // Shift, Ctrl, Alt
2160
+ var isValidKey = function (code) {
2161
+ return isDeletion(code) || isNavigation(code) || isModifier(code);
2162
+ };
2163
+ var isValidExpiry = function (expiry) {
2164
+ var month = parseInt(expiry.substring(0, 2), 10);
2165
+ var year = parseInt(expiry.substring(2, 4), 10) + 2000;
2166
+ if (isNaN(month) || isNaN(year))
2167
+ return false;
2168
+ if (month < 1 || month > 12)
2169
+ return false;
2170
+ return true;
2171
+ };
2172
+ var isCardExpired = function (expiry) {
2173
+ var month = parseInt(expiry.substring(0, 2), 10);
2174
+ var year = parseInt(expiry.substring(2, 4), 10) + 2000;
2175
+ var expiryDate = new Date(year, month, 1);
2176
+ return expiryDate < new Date();
2177
+ };
2178
+ var formatCardExpiry = function (cardExpiry) {
2179
+ if (cardExpiry.length <= 2)
2180
+ return cardExpiry;
2181
+ return cardExpiry.substring(0, 2) + "/" + cardExpiry.substring(2);
2182
+ };
2183
+ // removes spaces from a credit card number
2184
+ var unformatCardNumber = function (cardNumber) {
2185
+ var cardNumberArray = cardNumber.split("");
2186
+ var unformattedCardNumberArray = cardNumberArray.filter(function (character) { return character !== " "; });
2187
+ return unformattedCardNumberArray.join("");
2188
+ };
2189
+ var storePayment = function (options, plugin, apiHost, accountId) { return __awaiter(void 0, void 0, void 0, function () {
2190
+ var testCreditCardNumber, testCreditCardCvc, testCreditCardExpirationDate, token, response;
2191
+ return __generator(this, function (_a) {
2192
+ switch (_a.label) {
2193
+ case 0:
2194
+ testCreditCardNumber = options.testCreditCardNumber, testCreditCardCvc = options.testCreditCardCvc, testCreditCardExpirationDate = options.testCreditCardExpirationDate, token = options.token;
2195
+ return [4 /*yield*/, invokePlugin({
2196
+ method: "store_payment_method",
2197
+ plugin: plugin,
2198
+ payload: {
2199
+ test_credit_card_number: testCreditCardNumber,
2200
+ test_credit_card_cvc: testCreditCardCvc,
2201
+ test_credit_card_expiration_date: testCreditCardExpirationDate,
2202
+ account_id: accountId,
2203
+ },
2204
+ token: token,
2205
+ apiHost: apiHost,
2206
+ })];
2207
+ case 1:
2208
+ response = _a.sent();
2209
+ if ((response === null || response === void 0 ? void 0 : response.status) !== "success")
2210
+ throw new Error(response === null || response === void 0 ? void 0 : response.message);
2211
+ return [2 /*return*/, response];
2212
+ }
2213
+ });
2214
+ }); };
2215
+
2306
2216
  var DemoPayCardCvc = function (_a) {
2307
2217
  var autoFocus = _a.autoFocus, onChange = _a.onChange, placeholder = _a.placeholder, value = _a.value;
2308
2218
  var onKeyPress = function (event) {
@@ -2468,6 +2378,91 @@ var StyledInputs = styled.div(templateObject_1$7 || (templateObject_1$7 = __make
2468
2378
  });
2469
2379
  var templateObject_1$7;
2470
2380
 
2381
+ var createPaymentMethod = function (_a) {
2382
+ var paymentMethodId = _a.paymentMethodId, plugin = _a.plugin, token = _a.token, apiHost = _a.apiHost, accountId = _a.accountId;
2383
+ return __awaiter(void 0, void 0, void 0, function () {
2384
+ var response;
2385
+ return __generator(this, function (_b) {
2386
+ switch (_b.label) {
2387
+ case 0: return [4 /*yield*/, invokePlugin({
2388
+ plugin: plugin,
2389
+ method: "store_payment_method",
2390
+ payload: {
2391
+ payment_method_id: paymentMethodId,
2392
+ account_id: accountId,
2393
+ },
2394
+ token: token,
2395
+ apiHost: apiHost,
2396
+ })];
2397
+ case 1:
2398
+ response = _b.sent();
2399
+ if (response.status !== "success")
2400
+ throw new Error(response.message || "Unknown error");
2401
+ return [2 /*return*/, response];
2402
+ }
2403
+ });
2404
+ });
2405
+ };
2406
+ var createSetupIntent = function (plugin, token, apiHost, accountId) {
2407
+ return invokePlugin({
2408
+ plugin: plugin,
2409
+ method: "create_setup_intent",
2410
+ token: token,
2411
+ apiHost: apiHost,
2412
+ payload: {
2413
+ account_id: accountId,
2414
+ },
2415
+ });
2416
+ };
2417
+ var fetchStripeKey = function (plugin, token, apiHost, accountId) { return __awaiter(void 0, void 0, void 0, function () {
2418
+ var response;
2419
+ return __generator(this, function (_a) {
2420
+ switch (_a.label) {
2421
+ case 0: return [4 /*yield*/, invokePlugin({
2422
+ plugin: plugin,
2423
+ method: "retrieve_config",
2424
+ token: token,
2425
+ apiHost: apiHost,
2426
+ payload: {
2427
+ account_id: accountId,
2428
+ },
2429
+ })];
2430
+ case 1:
2431
+ response = _a.sent();
2432
+ return [2 /*return*/, response];
2433
+ }
2434
+ });
2435
+ }); };
2436
+ loadStripe.setLoadParameters({ advancedFraudSignals: false });
2437
+ var useStripePlugin = function (plugin, token, apiHost, accountId) {
2438
+ var _a = useState(null), stripe = _a[0], setStripe = _a[1];
2439
+ var showErrorNotification = useErrorNotification();
2440
+ var options = {
2441
+ mode: "setup",
2442
+ // TODO: Fetch currency from the entity/account
2443
+ currency: "usd",
2444
+ setupFutureUsage: "off_session",
2445
+ };
2446
+ useEffect(function () {
2447
+ var _a, _b;
2448
+ if (!plugin)
2449
+ return;
2450
+ if (((_b = (_a = plugin.components) === null || _a === void 0 ? void 0 : _a.frontend) === null || _b === void 0 ? void 0 : _b[0].name) !== "StripePayment")
2451
+ return;
2452
+ fetchStripeKey(plugin, token, apiHost || "", accountId)
2453
+ .then(function (_a) {
2454
+ var payload = _a.payload;
2455
+ return loadStripe(payload.publishable_key).then(setStripe);
2456
+ })
2457
+ .catch(function (error) {
2458
+ console.error("Caught Error in fetching stripe key: ", error);
2459
+ showErrorNotification(error.message, "Unexpected Error fetching key");
2460
+ });
2461
+ // eslint-disable-next-line
2462
+ }, [plugin, token]);
2463
+ return { stripe: stripe, options: options };
2464
+ };
2465
+
2471
2466
  function useSave(_a) {
2472
2467
  var _this = this;
2473
2468
  var onSaveSuccess = _a.onSaveSuccess;
@@ -2586,12 +2581,7 @@ var PaymentMethodForm = function (_a) {
2586
2581
  // This is just a wrapper to fetch the stripe object and pass it to the form
2587
2582
  var StripeForm = function (_a) {
2588
2583
  var plugin = _a.plugin, onFail = _a.onFail, onSavePaymentMethod = _a.onSavePaymentMethod;
2589
- var _b = useContext$1(BunnyContext), token = _b.token, apiHost = _b.apiHost;
2590
- var accountId = useContext$1(PaymentContext).accountId;
2591
- var _c = useStripePlugin(plugin, token, apiHost, accountId), stripe = _c.stripe, options = _c.options;
2592
- if (!stripe)
2593
- return null;
2594
- return (jsx(Elements, __assign({ options: options, stripe: stripe }, { children: jsx(PaymentMethodForm, { plugin: plugin, onFail: onFail, onSavePaymentMethod: onSavePaymentMethod }) })));
2584
+ return (jsx(PaymentMethodForm, { plugin: plugin, onFail: onFail, onSavePaymentMethod: onSavePaymentMethod }));
2595
2585
  };
2596
2586
 
2597
2587
  var PaymentMethodDetails = function (_a) {
@@ -2617,17 +2607,17 @@ var CardIcon = function () {
2617
2607
  var Text$d = Typography.Text;
2618
2608
  var PaymentMethodSelector = function (_a) {
2619
2609
  var paymentMethodAllowedPlugins = _a.paymentMethodAllowedPlugins, onSelect = _a.onSelect, value = _a.value;
2620
- return (jsx("div", __assign({ className: "flex flex-col gap-2" }, { children: paymentMethodAllowedPlugins === null || paymentMethodAllowedPlugins === void 0 ? void 0 : paymentMethodAllowedPlugins.map(function (plugin, index) { return (jsx(PaymentOption, { name: plugin.name, onClick: onSelect, paymentOption: plugin, selected: (value === null || value === void 0 ? void 0 : value.id) === plugin.id }, index)); }) })));
2610
+ return (jsx("div", __assign({ className: "flex flex-col gap-2" }, { children: paymentMethodAllowedPlugins === null || paymentMethodAllowedPlugins === void 0 ? void 0 : paymentMethodAllowedPlugins.map(function (plugin, index) { return (jsx(PaymentOption, { name: plugin.name, onClick: onSelect, paymentPlugin: plugin, selected: (value === null || value === void 0 ? void 0 : value.id) === plugin.id }, index)); }) })));
2621
2611
  };
2622
2612
  var PaymentOption = function (_a) {
2623
- var selected = _a.selected, paymentOption = _a.paymentOption, onClick = _a.onClick, name = _a.name;
2613
+ var selected = _a.selected, paymentPlugin = _a.paymentPlugin, onClick = _a.onClick, name = _a.name;
2624
2614
  var brandColor = useContext$1(BrandContext).brandColor;
2625
2615
  var darkMode = useContext$1(BunnyContext).darkMode;
2626
2616
  var isAch = name === null || name === void 0 ? void 0 : name.toLowerCase().includes("ach");
2627
2617
  var isCard = name === null || name === void 0 ? void 0 : name.toLowerCase().includes("card");
2628
2618
  return (jsxs(PaymentOptionContainer, __assign({ "$brandColor": brandColor, "$selected": selected, className: "flex justify-between items-center w-full cursor-pointer py-2 px-4 rounded border-solid ".concat(darkMode
2629
2619
  ? "var(--row-background-dark) border-gray-500"
2630
- : "bg-slate-50 border-slate-200", " border"), onClick: function () { return onClick(paymentOption); } }, { children: [jsxs("div", __assign({ className: "flex gap-2 items-center" }, { children: [jsx(Checkbox, { checked: selected, className: darkMode ? "border-gray-400" : "" }), jsx(Text$d, { children: name })] })), isAch ? (jsx(BankOutlined$1, { className: "text-slate-400" })) : isCard ? (jsx(CardIcon, {})) : (jsx(CardIcon, {}))] })));
2620
+ : "bg-slate-50 border-slate-200", " border"), onClick: function () { return onClick(paymentPlugin); } }, { children: [jsxs("div", __assign({ className: "flex gap-2 items-center" }, { children: [jsx(Checkbox, { checked: selected, className: darkMode ? "border-gray-400" : "" }), jsx(Text$d, { children: name })] })), isAch ? (jsx(BankOutlined$1, { className: "text-slate-400" })) : isCard ? (jsx(CardIcon, {})) : (jsx(CardIcon, {}))] })));
2631
2621
  };
2632
2622
  var PaymentOptionContainer = styled.div(templateObject_1$6 || (templateObject_1$6 = __makeTemplateObject(["\n transition: border 0.3s ease;\n\n ", "\n\n &:hover {\n border-color: ", ";\n }\n"], ["\n transition: border 0.3s ease;\n\n ", "\n\n &:hover {\n border-color: ", ";\n }\n"])), function (_a) {
2633
2623
  var $brandColor = _a.$brandColor, $selected = _a.$selected;
@@ -2689,7 +2679,7 @@ var PaymentForm = function (_a) {
2689
2679
  selectedPaymentMethod) {
2690
2680
  return;
2691
2681
  }
2692
- var pluginPaymentMethod = paymentMethodAllowedPlugins === null || paymentMethodAllowedPlugins === void 0 ? void 0 : paymentMethodAllowedPlugins.find(function (plugin) { var _a; return plugin.name === ((_a = storedPaymentMethod === null || storedPaymentMethod === void 0 ? void 0 : storedPaymentMethod.metadata) === null || _a === void 0 ? void 0 : _a.issuer); });
2682
+ var pluginPaymentMethod = paymentMethodAllowedPlugins === null || paymentMethodAllowedPlugins === void 0 ? void 0 : paymentMethodAllowedPlugins.find(function (plugin) { var _a, _b, _c; return ((_a = plugin.id) === null || _a === void 0 ? void 0 : _a.toString()) === ((_c = (_b = storedPaymentMethod === null || storedPaymentMethod === void 0 ? void 0 : storedPaymentMethod.plugin) === null || _b === void 0 ? void 0 : _b.id) === null || _c === void 0 ? void 0 : _c.toString()); });
2693
2683
  if (pluginPaymentMethod) {
2694
2684
  setSelectedPaymentMethod(pluginPaymentMethod);
2695
2685
  }
@@ -2708,18 +2698,10 @@ var PaymentForm = function (_a) {
2708
2698
  var pluginCount = (paymentMethodAllowedPlugins === null || paymentMethodAllowedPlugins === void 0 ? void 0 : paymentMethodAllowedPlugins.length) || 0;
2709
2699
  return pluginCount > 1;
2710
2700
  }, [paymentMethodAllowedPlugins]);
2711
- var handlePaymentSuccess = function (_a) {
2712
- var pluginPaymentResponse = _a.pluginPaymentResponse, savedPaymentMethodResponse = _a.savedPaymentMethodResponse;
2701
+ var handlePaymentSuccess = function () {
2713
2702
  // Hide payment method selector and form
2714
2703
  setShowPaymentMethodForm(false);
2715
- // Set new selected payment method
2716
- var paymentMethod = paymentMethodAllowedPlugins === null || paymentMethodAllowedPlugins === void 0 ? void 0 : paymentMethodAllowedPlugins.find(function (plugin) { var _a; return plugin.id === ((_a = pluginPaymentResponse === null || pluginPaymentResponse === void 0 ? void 0 : pluginPaymentResponse.plugin) === null || _a === void 0 ? void 0 : _a.id); });
2717
- setSelectedPaymentMethod(paymentMethod);
2718
- // Handle success keeps going up component tree
2719
- onPaymentSuccess === null || onPaymentSuccess === void 0 ? void 0 : onPaymentSuccess({
2720
- pluginPaymentResponse: pluginPaymentResponse,
2721
- savedPaymentMethodResponse: savedPaymentMethodResponse,
2722
- });
2704
+ onPaymentSuccess === null || onPaymentSuccess === void 0 ? void 0 : onPaymentSuccess();
2723
2705
  };
2724
2706
  var handleSavePaymentMethod = function () {
2725
2707
  queryClient.invalidateQueries({
@@ -2732,156 +2714,17 @@ var PaymentForm = function (_a) {
2732
2714
  onClickCancel: function () { return setShowPaymentMethodForm(false); },
2733
2715
  accountId: accountId,
2734
2716
  overrideToken: overrideToken,
2735
- } }, { children: jsx("div", __assign({ className: "flex flex-col gap-0 w-full" }, { children: jsxs(Fragment, { children: [jsx("div", __assign({ className: "px-4" }, { children: jsx(MiniCreditCard, { hideRemoveButton: paying, onClickRemove: function () { return onClickRemove(storedPaymentMethod); }, paymentMethodData: storedPaymentMethod }) })), paying && storedPaymentMethod ? (jsx("div", __assign({ className: "px-4" }, { children: jsx(CheckoutFooter, { quote: quote, invoice: invoice, onPaymentSuccess: handlePaymentSuccess, plugin: selectedPaymentMethod }) }))) : (
2736
- //if not paying and payment method is saved, show Collapse
2737
- jsx(Collapse, __assign({ bordered: false, activeKey: showPaymentMethodForm ? "1" : undefined, ghost: true, collapsible: "disabled", destroyInactivePanel: true }, { children: jsx(Panel, __assign({ header: jsx(Fragment, { children: !showPaymentMethodForm ? (jsx("div", __assign({ className: "pt-4 px-4" }, { children: jsxs(Button$1, __assign({ onClick: function () {
2738
- setShowPaymentMethodForm(true);
2739
- }, type: "default", className: "w-full" }, { children: [storedPaymentMethod ? "Update" : "Add", " payment method"] })) }))) : null }), showArrow: false }, { children: jsx("div", { children: selectedPaymentMethod ? (jsxs("div", __assign({ className: "flex flex-col gap-2 mt-2" }, { children: [showPaymentMethodSelector && (jsx(PaymentMethodSelector, { onSelect: setSelectedPaymentMethod, paymentMethodAllowedPlugins: paymentMethodAllowedPlugins, value: selectedPaymentMethod })), jsx("div", __assign({ className: "flex flex-col" }, { children: jsx(PaymentMethodDetails, { onFail: onFail, onSavePaymentMethod: handleSavePaymentMethod, paymentMethod: selectedPaymentMethod }) }))] }))) : (jsx("div", { children: "No payment method selected" })) }) }), "1") })))] }) })) })));
2740
- };
2741
-
2742
- var MUTATION$8 = "\n mutation checkout(\n $invoiceId: ID,\n $quoteId: ID,\n $paymentMethodId: ID,\n $paymentMethodData: CheckoutPaymentMethodAttributes\n ) {\n checkout(\n invoiceId: $invoiceId,\n quoteId: $quoteId,\n paymentMethodId: $paymentMethodId,\n paymentMethodData: $paymentMethodData\n ) {\n invoice {\n id\n state\n amount\n amountDue\n }\n payment {\n id\n state\n amount\n }\n paymentApplication {\n id\n invoiceId\n paymentId\n }\n transaction {\n id\n amount\n }\n }\n }\n";
2743
- var checkout = function (_a) {
2744
- var quoteId = _a.quoteId, invoiceId = _a.invoiceId, paymentMethodId = _a.paymentMethodId, paymentMethodData = _a.paymentMethodData, token = _a.token, apiHost = _a.apiHost;
2745
- return __awaiter(void 0, void 0, void 0, function () {
2746
- var mutationVars, response, errors;
2747
- return __generator(this, function (_b) {
2748
- switch (_b.label) {
2749
- case 0:
2750
- mutationVars = {
2751
- quoteId: quoteId,
2752
- invoiceId: invoiceId,
2753
- paymentMethodId: paymentMethodId,
2754
- };
2755
- if (paymentMethodData) {
2756
- mutationVars.paymentMethodData = __assign(__assign({}, paymentMethodData), { metadata: paymentMethodData.metadata });
2757
- }
2758
- return [4 /*yield*/, gqlRequest$1({
2759
- query: MUTATION$8,
2760
- token: token,
2761
- vars: mutationVars,
2762
- apiHost: apiHost,
2763
- })];
2764
- case 1:
2765
- response = _b.sent();
2766
- errors = (response === null || response === void 0 ? void 0 : response.checkout).errors;
2767
- if (errors)
2768
- throw errors;
2769
- return [2 /*return*/, {
2770
- savePaymentMethod: paymentMethodData === null || paymentMethodData === void 0 ? void 0 : paymentMethodData.savePaymentMethod,
2771
- }];
2772
- }
2773
- });
2774
- });
2775
- };
2776
-
2777
- var InvoiceCheckout = function (_a) {
2778
- var onSuccess = _a.onSuccess, onFail = _a.onFail, invoice = _a.invoice, entityId = _a.entityId;
2779
- var _b = useContext$1(BunnyContext), apiHost = _b.apiHost, token = _b.token, graphQLClient = _b.graphQLClient;
2780
- var checkoutMutation = useMutation({
2781
- mutationFn: function (_a) {
2782
- var pluginPaymentMethod = _a.pluginPaymentMethod, savedPaymentMethod = _a.savedPaymentMethod;
2783
- if (savedPaymentMethod) {
2784
- var paymentMethodId = savedPaymentMethod.paymentMethodId;
2785
- return checkout({
2786
- invoiceId: invoice === null || invoice === void 0 ? void 0 : invoice.id,
2787
- paymentMethodId: paymentMethodId,
2788
- token: token,
2789
- apiHost: apiHost,
2790
- });
2791
- }
2792
- else if (pluginPaymentMethod) {
2793
- var plugin = pluginPaymentMethod.plugin, savePaymentMethod = pluginPaymentMethod.savePaymentMethod, metadata = pluginPaymentMethod.metadata;
2794
- var paymentToken = pluginPaymentMethod.token;
2795
- return checkout({
2796
- invoiceId: invoice === null || invoice === void 0 ? void 0 : invoice.id,
2797
- paymentMethodData: {
2798
- metadata: metadata,
2799
- pluginGuid: plugin.guid,
2800
- savePaymentMethod: savePaymentMethod,
2801
- token: paymentToken,
2802
- },
2803
- token: token,
2804
- apiHost: apiHost,
2805
- });
2806
- }
2807
- else
2808
- throw new Error("No payment method provided");
2809
- },
2810
- onSuccess: onSuccess,
2811
- onError: onFail,
2812
- });
2813
- // Handlers
2814
- var handleCheckout = function (_a) {
2815
- var pluginPaymentResponse = _a.pluginPaymentResponse, savedPaymentMethodResponse = _a.savedPaymentMethodResponse;
2816
- return __awaiter(void 0, void 0, void 0, function () {
2817
- var token_1, plugin, savePaymentMethod, metadata, paymentMethodId;
2818
- return __generator(this, function (_b) {
2819
- if (pluginPaymentResponse) {
2820
- token_1 = pluginPaymentResponse.token, plugin = pluginPaymentResponse.plugin, savePaymentMethod = pluginPaymentResponse.savePaymentMethod, metadata = pluginPaymentResponse.metadata;
2821
- checkoutMutation.mutate({
2822
- pluginPaymentMethod: {
2823
- savePaymentMethod: savePaymentMethod,
2824
- plugin: plugin,
2825
- metadata: metadata,
2826
- token: token_1,
2827
- },
2828
- });
2829
- }
2830
- else if (savedPaymentMethodResponse) {
2831
- paymentMethodId = savedPaymentMethodResponse.paymentMethodId;
2832
- checkoutMutation.mutate({
2833
- savedPaymentMethod: {
2834
- paymentMethodId: paymentMethodId,
2835
- },
2836
- });
2837
- }
2838
- return [2 /*return*/];
2839
- });
2840
- });
2841
- };
2842
- return (jsx("div", __assign({ className: "w-full pt-12" }, { children: jsx(PaymentForm, { entityId: entityId, onPaymentSuccess: handleCheckout, onFail: onFail, invoice: invoice, graphQLClient: graphQLClient }) })));
2717
+ storedPaymentMethod: storedPaymentMethod,
2718
+ } }, { children: jsx(StripeWrapper, __assign({ plugin: selectedPaymentMethod, token: token, apiHost: apiHost, accountId: accountId }, { children: jsx("div", __assign({ className: "flex flex-col gap-0 w-full" }, { children: jsxs(Fragment, { children: [jsx("div", __assign({ className: "px-4" }, { children: jsx(MiniCreditCard, { onClickRemove: function () { return onClickRemove(storedPaymentMethod); }, paymentMethodData: storedPaymentMethod }) })), paying && storedPaymentMethod ? (jsx("div", __assign({ className: "px-4" }, { children: jsx(CheckoutFooter, { quote: quote, invoice: invoice, onPaymentSuccess: handlePaymentSuccess, plugin: selectedPaymentMethod }) }))) : (
2719
+ //if not paying and payment method is saved, show Collapse
2720
+ jsx(Collapse, __assign({ bordered: false, activeKey: showPaymentMethodForm ? "1" : undefined, ghost: true, collapsible: "disabled", destroyInactivePanel: true }, { children: jsx(Panel, __assign({ header: jsx(Fragment, { children: !showPaymentMethodForm ? (jsx("div", __assign({ className: "pt-4 px-4" }, { children: jsxs(Button$1, __assign({ onClick: function () {
2721
+ setShowPaymentMethodForm(true);
2722
+ }, type: "default", className: "w-full" }, { children: [storedPaymentMethod ? "Update" : "Add", " payment method"] })) }))) : null }), showArrow: false }, { children: jsx("div", { children: selectedPaymentMethod ? (jsxs("div", __assign({ className: "flex flex-col gap-2 mt-2" }, { children: [showPaymentMethodSelector && (jsx(PaymentMethodSelector, { onSelect: setSelectedPaymentMethod, paymentMethodAllowedPlugins: paymentMethodAllowedPlugins, value: selectedPaymentMethod })), jsx("div", __assign({ className: "flex flex-col" }, { children: jsx(PaymentMethodDetails, { onFail: onFail, onSavePaymentMethod: handleSavePaymentMethod, paymentMethod: selectedPaymentMethod }) }))] }))) : (jsx("div", { children: "No payment method selected" })) }) }), "1") })))] }) })) })) })));
2843
2723
  };
2844
-
2845
- var fetchPDF = function (apiEndpoint, invoiceUuid) { return __awaiter(void 0, void 0, void 0, function () {
2846
- var response;
2847
- return __generator(this, function (_a) {
2848
- switch (_a.label) {
2849
- case 0:
2850
- if (!invoiceUuid) {
2851
- throw new Error("Invoice ID is required to fetch PDF");
2852
- }
2853
- return [4 /*yield*/, fetch("".concat(apiEndpoint, "/api/legacy_invoices/").concat(invoiceUuid))];
2854
- case 1:
2855
- response = _a.sent();
2856
- if (!response.ok)
2857
- throw new Error("Failed to fetch PDF");
2858
- return [2 /*return*/, response.blob()]; // Return the PDF as a blob
2859
- }
2860
- });
2861
- }); };
2862
- function InvoicePDF(_a) {
2863
- var invoiceUuid = _a.invoiceUuid, apiHost = _a.apiHost;
2864
- var _b = useState(undefined), pdfUrl = _b[0], setPdfUrl = _b[1];
2865
- var _c = useQuery({
2866
- queryKey: ["invoicePDF", invoiceUuid],
2867
- queryFn: function () { return fetchPDF(apiHost || "", invoiceUuid); },
2868
- enabled: Boolean(invoiceUuid),
2869
- }), pdfBlob = _c.data, isLoading = _c.isLoading;
2870
- useEffect(function () {
2871
- if (pdfBlob) {
2872
- var url_1 = URL.createObjectURL(pdfBlob);
2873
- setPdfUrl(url_1);
2874
- return function () { return URL.revokeObjectURL(url_1); };
2875
- }
2876
- }, [pdfBlob]);
2877
- if (isLoading || !pdfUrl)
2878
- return jsx(Fragment, {});
2879
- return (jsx("iframe", { src: pdfUrl, style: {
2880
- border: "none",
2881
- gridColumn: "1/-1",
2882
- minHeight: "1000px",
2883
- minWidth: "780px",
2884
- }, title: "Invoice PDF", width: "100%" }));
2724
+ function StripeWrapper(_a) {
2725
+ var children = _a.children, plugin = _a.plugin, token = _a.token, apiHost = _a.apiHost, accountId = _a.accountId;
2726
+ var _b = useStripePlugin(plugin, token, apiHost, accountId), stripe = _b.stripe, options = _b.options;
2727
+ return (jsx(Elements, __assign({ options: options, stripe: stripe }, { children: children })));
2885
2728
  }
2886
2729
 
2887
2730
  function Invoice(_a) {
@@ -2902,10 +2745,12 @@ function Invoice(_a) {
2902
2745
  function ActualInvoice() {
2903
2746
  // Context
2904
2747
  var queryClient = useQueryClient();
2905
- var _a = useContext$1(InvoiceQuoteContext), id = _a.id, invoiceQuoteViewComponent = _a.invoiceQuoteViewComponent, backButtonName = _a.backButtonName, onBackButtonClick = _a.onBackButtonClick, onPaymentSuccess = _a.onPaymentSuccess, entityId = _a.entityId, className = _a.className;
2906
- var _b = useContext$1(BunnyContext), apiHost = _b.apiHost, token = _b.token, onTokenExpired = _b.onTokenExpired;
2748
+ var _a = useContext$1(InvoiceQuoteContext), id = _a.id, invoiceQuoteViewComponent = _a.invoiceQuoteViewComponent, backButtonName = _a.backButtonName, onBackButtonClick = _a.onBackButtonClick,
2749
+ // onPaymentSuccess,
2750
+ entityId = _a.entityId, className = _a.className;
2751
+ var _b = useContext$1(BunnyContext), apiHost = _b.apiHost, token = _b.token, onTokenExpired = _b.onTokenExpired, graphQLClient = _b.graphQLClient;
2907
2752
  // Local state
2908
- var isMobile = useIsMobile();
2753
+ var isMobile = useIsMobile(BreakpointNumbers.lg);
2909
2754
  // Hooks
2910
2755
  var showSuccessNotification = useSuccessNotification();
2911
2756
  var handleAllErrorFormats = useAllErrorFormats(onTokenExpired);
@@ -2921,19 +2766,17 @@ function ActualInvoice() {
2921
2766
  }
2922
2767
  if (!formattedInvoice)
2923
2768
  return jsx(Fragment, {});
2924
- var onSuccess = function (_a) {
2925
- var savePaymentMethod = _a.savePaymentMethod;
2926
- if (savePaymentMethod)
2927
- queryClient.invalidateQueries({
2928
- queryKey: QueryKeyFactory.default.accountPaymentMethodKey,
2929
- });
2769
+ var onSuccess = function () {
2770
+ // queryClient.invalidateQueries({
2771
+ // queryKey: QueryKeyFactory.default.accountPaymentMethodKey,
2772
+ // });
2930
2773
  queryClient.invalidateQueries({
2931
2774
  queryKey: QueryKeyFactory.default.transactionsKey(),
2932
2775
  });
2933
2776
  queryClient.invalidateQueries({
2934
2777
  queryKey: QueryKeyFactory.default.createFormattedInvoiceKey(token, id),
2935
2778
  });
2936
- onPaymentSuccess === null || onPaymentSuccess === void 0 ? void 0 : onPaymentSuccess(savePaymentMethod);
2779
+ // onPaymentSuccess?.(savePaymentMethod);
2937
2780
  showSuccessNotification("Your invoice has been paid", "Payment successful");
2938
2781
  };
2939
2782
  var onFail = function (error) {
@@ -2942,9 +2785,7 @@ function ActualInvoice() {
2942
2785
  return (jsxs(Fragment, { children: [jsxs(Helmet, { children: [jsxs("title", { children: [formattedInvoice.vendorName, " ", DOCUMENT_NAME$1.INVOICE] }), jsx("meta", { name: "description", content: quoteMetaDescription(formattedInvoice.vendorName) }), jsx("meta", { property: "og:type", content: "website" }), jsx("meta", { property: "og:title", content: quoteMetaTitle({
2943
2786
  vendorName: formattedInvoice.vendorName,
2944
2787
  documentName: DOCUMENT_NAME$1.INVOICE,
2945
- }) }), jsx("meta", { property: "og:description", content: quoteMetaDescription(formattedInvoice.vendorName) })] }), jsxs("div", __assign({ className: "flex gap-6 ".concat(isMobile ? "flex-col w-full overflow-hidden" : "shadow-padding-xb", " ").concat(className) }, { children: [formattedInvoice.isLegacy ? (jsx("div", __assign({ className: "flex justify-center w-full" }, { children: jsx(InvoicePDF, { invoiceUuid: formattedInvoice.uuid, apiHost: apiHost }) }))) : (invoiceQuoteViewComponent || (jsx(InvoiceQuoteView, { html: formattedInvoice.html, formattedInvoice: formattedInvoice, backButtonName: backButtonName, onBackButtonClick: onBackButtonClick }))), !isMobile && isInvoicePayable && (jsx(Divider, { className: "h-full", type: "vertical" })), isInvoicePayable && (jsx(InvoiceCheckout, { invoice: formattedInvoice, onFail: function (error) {
2946
- onFail(error);
2947
- }, onSuccess: onSuccess, entityId: entityId }))] }))] }));
2788
+ }) }), jsx("meta", { property: "og:description", content: quoteMetaDescription(formattedInvoice.vendorName) })] }), jsxs("div", __assign({ className: "flex gap-6 ".concat(isMobile ? "flex-col w-full overflow-hidden" : "shadow-padding-xb", " ").concat(className) }, { children: [formattedInvoice.isLegacy ? (jsx("div", __assign({ className: "flex justify-center w-full" }, { children: jsx(InvoicePDF, { invoiceUuid: formattedInvoice.uuid, apiHost: apiHost }) }))) : (invoiceQuoteViewComponent || (jsx(InvoiceQuoteView, { html: formattedInvoice.html, formattedInvoice: formattedInvoice, backButtonName: backButtonName, onBackButtonClick: onBackButtonClick }))), isInvoicePayable && (jsx("div", __assign({ className: "w-full pt-12" }, { children: jsx(PaymentForm, { entityId: entityId, onPaymentSuccess: onSuccess, onFail: onFail, invoice: formattedInvoice, graphQLClient: graphQLClient }) })))] }))] }));
2948
2789
  }
2949
2790
 
2950
2791
  var MUTATION$7 = function (id) { return "\n query formattedQuote ($id: ID) {\n formattedQuote (id: $id) {\n payableId\n acceptedAt\n acceptedByName\n amount\n amountDue\n amountsByPeriod {\n id\n name\n amount\n }\n object { documents { id filename size date url } }\n billingCity\n billingCountry\n billingState\n billingStreet\n billingZip\n contactName\n currency\n customerBillingCity\n customerBillingCountry\n customerBillingState\n customerBillingStreet\n customerBillingZip\n customerName\n discount\n discountValue\n duration\n endDate\n expiresAt\n html\n formattedLines {\n amount\n amountsByPeriod {\n quantity\n id\n name\n startDate\n endDate\n amount\n amountsByTier {\n id\n tier {\n starts\n ends\n price\n }\n quantity\n amount\n }\n prorationRate\n }\n billingPeriodEnd\n billingPeriodStart\n chargeType\n discount\n frequency\n isRamp\n periods\n planName\n position\n price\n priceDecimals\n priceListChargeId\n priceListChargeName\n priceListId\n priceListName\n priceTiers {\n price\n starts\n }\n pricingModel\n productName\n prorationRate\n quantity\n showProductNameOnLineItem\n taxCode\n trialEndDate\n trialStartDate\n unitOfMeasure\n vatCode\n }\n netPaymentDays\n notes\n number\n poNumberRequired\n salesContactEmail\n sharedAt\n startDate\n state\n subtotal\n taxAmount\n taxNumberLabel\n taxNumberRequired\n vendorName\n }\n }"; };
@@ -3473,7 +3314,9 @@ function Transactions(_a) {
3473
3314
  TransactionKind.PAYMENT,
3474
3315
  TransactionKind.REFUND,
3475
3316
  TransactionKind.WRITE_OFF,
3476
- ] : _j, style = _a.style, filter = _a.filter, noTransactionsMessage = _a.noTransactionsMessage, entityId = _a.entityId, filterTransactions = _a.filterTransactions, sortTransactions = _a.sortTransactions;
3317
+ ] : _j, style = _a.style, filter = _a.filter, noTransactionsMessage = _a.noTransactionsMessage, entityId = _a.entityId, filterTransactions = _a.filterTransactions, _k = _a.sortTransactions, sortTransactions = _k === void 0 ? function (a, b) {
3318
+ return new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime();
3319
+ } : _k;
3477
3320
  var contextValues = {
3478
3321
  showSearchBar: showSearchBar,
3479
3322
  showTitle: showTitle,
@@ -3494,9 +3337,9 @@ function Transactions(_a) {
3494
3337
  filterTransactions: filterTransactions,
3495
3338
  sortTransactions: sortTransactions,
3496
3339
  };
3497
- var _k = useContext$1(BunnyContext), token = _k.token, apiHost = _k.apiHost;
3340
+ var _l = useContext$1(BunnyContext), token = _l.token, apiHost = _l.apiHost;
3498
3341
  // Local state
3499
- var _l = useState(""), search = _l[0], setSearch = _l[1];
3342
+ var _m = useState(""), search = _m[0], setSearch = _m[1];
3500
3343
  var filterValue = filter ||
3501
3344
  (search ? "filter: \"transaction.transactionableId is ".concat(search, "\"") : "");
3502
3345
  // Queries
@@ -3867,86 +3710,40 @@ var FormBillingState = function (_a) {
3867
3710
 
3868
3711
  var QuoteCheckout = function (_a) {
3869
3712
  var account = _a.account, onSuccess = _a.onSuccess, onFail = _a.onFail, quote = _a.quote, taxationRequiredAccountFields = _a.taxationRequiredAccountFields, entityId = _a.entityId;
3870
- // Context
3871
- var isMobile = useIsMobile();
3872
3713
  var _b = useContext$1(BunnyContext), apiHost = _b.apiHost, token = _b.token, graphQLClient = _b.graphQLClient;
3714
+ var isMobile = useIsMobile();
3873
3715
  var _c = useState(false), isSaving = _c[0], setIsSaving = _c[1];
3874
3716
  var paymentRequired = getQuoteAmountDue(quote) > 0;
3875
3717
  var checkoutMutation = useMutation({
3876
- mutationFn: function (_a) {
3877
- var pluginPaymentMethod = _a.pluginPaymentMethod, savedPaymentMethod = _a.storedPaymentMethod;
3878
- if (!quote)
3879
- throw new Error("Quote is required");
3880
- if (!paymentRequired)
3881
- return checkout({ quoteId: quote.id, token: token, apiHost: apiHost });
3882
- if (savedPaymentMethod) {
3883
- var paymentMethodId = savedPaymentMethod.paymentMethodId;
3884
- return checkout({
3885
- quoteId: quote.id,
3886
- paymentMethodId: paymentMethodId,
3887
- token: token,
3888
- apiHost: apiHost,
3889
- });
3890
- }
3891
- if (pluginPaymentMethod) {
3892
- var plugin = pluginPaymentMethod.plugin, savePaymentMethod = pluginPaymentMethod.savePaymentMethod, metadata = pluginPaymentMethod.metadata;
3893
- var paymentToken = pluginPaymentMethod.token;
3894
- return checkout({
3895
- quoteId: quote.id,
3896
- paymentMethodData: {
3897
- metadata: metadata,
3898
- pluginGuid: plugin.guid,
3899
- savePaymentMethod: savePaymentMethod,
3900
- token: paymentToken,
3901
- },
3902
- token: token,
3903
- apiHost: apiHost,
3904
- });
3905
- }
3906
- throw new Error("Pay payment method provided");
3907
- },
3718
+ mutationFn: function () { return __awaiter(void 0, void 0, void 0, function () {
3719
+ return __generator(this, function (_a) {
3720
+ switch (_a.label) {
3721
+ case 0:
3722
+ if (!quote)
3723
+ throw new Error("Quote is required");
3724
+ if (paymentRequired)
3725
+ throw new Error("Payment is required");
3726
+ return [4 /*yield*/, checkout({ quoteId: quote.id, token: token, apiHost: apiHost })];
3727
+ case 1: return [2 /*return*/, _a.sent()];
3728
+ }
3729
+ });
3730
+ }); },
3908
3731
  onSuccess: onSuccess,
3909
3732
  onError: onFail,
3910
3733
  });
3911
- // Handlers
3912
- var handleCheckout = function (_a) {
3913
- var pluginPaymentResponse = _a.pluginPaymentResponse, savedPaymentMethodResponse = _a.savedPaymentMethodResponse;
3914
- return __awaiter(void 0, void 0, void 0, function () {
3915
- var token_1, plugin, savePaymentMethod, metadata, paymentMethodId;
3916
- return __generator(this, function (_b) {
3734
+ function handleCheckoutNoPayment() {
3735
+ return __awaiter(this, void 0, void 0, function () {
3736
+ return __generator(this, function (_a) {
3917
3737
  setIsSaving(true);
3918
- if (pluginPaymentResponse) {
3919
- token_1 = pluginPaymentResponse.token, plugin = pluginPaymentResponse.plugin, savePaymentMethod = pluginPaymentResponse.savePaymentMethod, metadata = pluginPaymentResponse.metadata;
3920
- checkoutMutation.mutate({
3921
- pluginPaymentMethod: {
3922
- savePaymentMethod: savePaymentMethod,
3923
- plugin: plugin,
3924
- metadata: metadata,
3925
- token: token_1,
3926
- },
3927
- });
3928
- }
3929
- else if (savedPaymentMethodResponse) {
3930
- paymentMethodId = savedPaymentMethodResponse.paymentMethodId;
3931
- checkoutMutation.mutate({
3932
- storedPaymentMethod: {
3933
- paymentMethodId: paymentMethodId,
3934
- },
3935
- });
3936
- }
3937
- else {
3938
- checkoutMutation.mutate({});
3939
- }
3738
+ checkoutMutation.mutate();
3940
3739
  setIsSaving(false);
3941
3740
  return [2 /*return*/];
3942
3741
  });
3943
3742
  });
3944
- };
3743
+ }
3945
3744
  if (taxationRequiredAccountFields)
3946
3745
  return (jsx(PaymentFormWrapper, __assign({ setMaxHeight: false }, { children: jsx(TaxationForm, { account: account, quote: quote }) })));
3947
- return (jsx(Fragment, { children: paymentRequired ? (jsx(PaymentForm, { entityId: entityId, onFail: onFail, onPaymentSuccess: handleCheckout, quote: quote, graphQLClient: graphQLClient })) : (jsx(PaymentFormWrapper, __assign({ setMaxHeight: false }, { children: jsxs("div", __assign({ className: "flex flex-col gap-2 ".concat(isMobile ? "shadow-padding-x" : "") }, { children: [jsx(Button$1, __assign({ onClick: function () {
3948
- handleCheckout({});
3949
- }, type: "primary" }, { children: isSaving ? "Processing..." : "Complete order" })), jsx("div", __assign({ className: "text-xs text-slate-500" }, { children: "No payment is required" }))] })) }))) }));
3746
+ return (jsx(Fragment, { children: paymentRequired ? (jsx(PaymentForm, { entityId: entityId, onFail: onFail, onPaymentSuccess: onSuccess, quote: quote, graphQLClient: graphQLClient })) : (jsx(PaymentFormWrapper, __assign({ setMaxHeight: false }, { children: jsxs("div", __assign({ className: "flex flex-col gap-2 ".concat(isMobile ? "shadow-padding-x" : "") }, { children: [jsx(Button$1, __assign({ onClick: handleCheckoutNoPayment, type: "primary" }, { children: isSaving ? "Processing..." : "Complete order" })), jsx("div", __assign({ className: "text-xs text-slate-500" }, { children: "No payment is required" }))] })) }))) }));
3950
3747
  };
3951
3748
  var PaymentFormWrapper = function (_a) {
3952
3749
  var children = _a.children, setMaxHeight = _a.setMaxHeight, className = _a.className;
@@ -4023,24 +3820,11 @@ var Checkout = function (_a) {
4023
3820
  return null;
4024
3821
  return (jsx("div", __assign({ className: "flex flex-col fixed top-0 left-0 right-0 bottom-0 bg-slate-50 overflow-auto", style: {
4025
3822
  zIndex: 1001,
4026
- } }, { children: jsxs("div", __assign({ className: pageWrapperClassName(isMobile) }, { children: [jsx("div", __assign({ className: "flex justify-end w-full" }, { children: jsx(CloseOutlined$1, { className: "text-base shadow-padding-xb", onClick: onCancel }) })), jsxs("div", __assign({ className: "flex justify-end gap-6 pt-4 ".concat(isMobile ? "flex-col" : "shadow-padding-xb") }, { children: [((invoice === null || invoice === void 0 ? void 0 : invoice.html) || ((_b = quote === null || quote === void 0 ? void 0 : quote.formattedQuote) === null || _b === void 0 ? void 0 : _b.html)) && (jsx(InvoiceQuoteView, { html: invoice ? invoice.html : quote ? quote.formattedQuote.html : "" })), !isMobile && ((invoice === null || invoice === void 0 ? void 0 : invoice.html) || ((_c = quote === null || quote === void 0 ? void 0 : quote.formattedQuote) === null || _c === void 0 ? void 0 : _c.html)) && (jsx(Divider, { className: "h-full", type: "vertical" })), invoice ? (jsx(InvoiceCheckout, { invoice: invoice, onFail: function (error) {
4027
- onFail(error);
4028
- }, onSuccess: function (_a) {
4029
- var savePaymentMethod = _a.savePaymentMethod;
4030
- onSuccess({ savePaymentMethod: savePaymentMethod });
4031
- }, entityId: entityId })) : quote ? (jsx(QuoteCheckout, { account: account, entityId: entityId, onFail: function (error) {
3823
+ } }, { children: jsxs("div", __assign({ className: pageWrapperClassName(isMobile) }, { children: [jsx("div", __assign({ className: "flex justify-end w-full" }, { children: jsx(CloseOutlined$1, { className: "text-base shadow-padding-xb", onClick: onCancel }) })), jsxs("div", __assign({ className: "flex justify-end gap-6 pt-4 ".concat(isMobile ? "flex-col" : "shadow-padding-xb") }, { children: [((invoice === null || invoice === void 0 ? void 0 : invoice.html) || ((_b = quote === null || quote === void 0 ? void 0 : quote.formattedQuote) === null || _b === void 0 ? void 0 : _b.html)) && (jsx(InvoiceQuoteView, { html: invoice ? invoice.html : quote ? quote.formattedQuote.html : "" })), !isMobile && ((invoice === null || invoice === void 0 ? void 0 : invoice.html) || ((_c = quote === null || quote === void 0 ? void 0 : quote.formattedQuote) === null || _c === void 0 ? void 0 : _c.html)) && (jsx(Divider, { className: "h-full", type: "vertical" })), invoice ? (jsx("div", __assign({ className: "w-full pt-12" }, { children: jsx(PaymentForm, { entityId: entityId, onPaymentSuccess: onSuccess, onFail: onFail, invoice: invoice, graphQLClient: graphQLClient }) }))) : quote ? (jsx(QuoteCheckout, { account: account, entityId: entityId, onFail: function (error) {
4032
3824
  onFail(error);
4033
- }, onSuccess: function (_a) {
4034
- var savePaymentMethod = _a.savePaymentMethod;
4035
- onSuccess({ savePaymentMethod: savePaymentMethod });
4036
- }, quote: quote, taxationRequiredAccountFields: taxationRequiredAccountFields, token: token })) : (jsx(PaymentForm, { entityId: entityId, onFail: function (error) {
3825
+ }, onSuccess: onSuccess, quote: quote, taxationRequiredAccountFields: taxationRequiredAccountFields, token: token })) : (jsx(PaymentForm, { entityId: entityId, onFail: function (error) {
4037
3826
  onFail(error);
4038
- }, onPaymentSuccess: function (_a) {
4039
- var pluginPaymentResponse = _a.pluginPaymentResponse;
4040
- onSuccess({
4041
- savePaymentMethod: pluginPaymentResponse === null || pluginPaymentResponse === void 0 ? void 0 : pluginPaymentResponse.savePaymentMethod,
4042
- });
4043
- }, graphQLClient: graphQLClient }))] }))] })) })));
3827
+ }, onPaymentSuccess: onSuccess, graphQLClient: graphQLClient }))] }))] })) })));
4044
3828
  };
4045
3829
 
4046
3830
  var DEFAULT_HEADERS = {
@@ -4323,17 +4107,16 @@ function Signup(_a) {
4323
4107
  });
4324
4108
  });
4325
4109
  }
4326
- function handlePaymentSaveSuccess(paymentSuccess) {
4110
+ function handlePaymentSaveSuccess() {
4327
4111
  return __awaiter(this, void 0, void 0, function () {
4328
- var response, plugin;
4112
+ var plugin;
4329
4113
  return __generator(this, function (_a) {
4330
4114
  switch (_a.label) {
4331
4115
  case 0:
4332
4116
  if (!formData) {
4333
4117
  throw new Error("Form data is required");
4334
4118
  }
4335
- response = paymentSuccess.pluginPaymentResponse;
4336
- plugin = response === null || response === void 0 ? void 0 : response.plugin;
4119
+ plugin = { id: "" };
4337
4120
  if (!(plugin === null || plugin === void 0 ? void 0 : plugin.id)) {
4338
4121
  throw new Error("Plugin ID is required");
4339
4122
  }