autumn-js 0.1.9 → 0.1.10

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 (123) hide show
  1. package/dist/libraries/backend/better-auth.d.mts +33 -33
  2. package/dist/libraries/backend/better-auth.d.ts +33 -33
  3. package/dist/libraries/backend/express.d.mts +1 -1
  4. package/dist/libraries/backend/express.d.ts +1 -1
  5. package/dist/libraries/backend/index.d.mts +1 -1
  6. package/dist/libraries/backend/index.d.ts +1 -1
  7. package/dist/libraries/backend/{referralTypes-BEcapeWf.d.mts → referralTypes-DpLmOy8-.d.mts} +44 -43
  8. package/dist/libraries/backend/{referralTypes-DuAlUwev.d.ts → referralTypes-nXl36Opw.d.ts} +44 -43
  9. package/dist/libraries/backend/utils/withAuth.d.mts +1 -1
  10. package/dist/libraries/backend/utils/withAuth.d.ts +1 -1
  11. package/dist/libraries/react/AutumnContext.d.mts +6 -6
  12. package/dist/libraries/react/AutumnContext.d.ts +6 -6
  13. package/dist/libraries/react/BaseAutumnProvider.d.mts +6 -6
  14. package/dist/libraries/react/BaseAutumnProvider.d.ts +6 -6
  15. package/dist/libraries/react/{ReactAutumnClient-DCMQEadM.d.ts → ReactAutumnClient-BozBPLWS.d.ts} +17 -17
  16. package/dist/libraries/react/{ReactAutumnClient-Dm14G99_.d.mts → ReactAutumnClient-CDp4DLo0.d.mts} +17 -17
  17. package/dist/libraries/react/ReactAutumnProvider.d.mts +2 -2
  18. package/dist/libraries/react/ReactAutumnProvider.d.ts +2 -2
  19. package/dist/libraries/react/{attachTypes-Sv_paJZ2.d.mts → attachTypes-BqXH38Ft.d.mts} +5 -5
  20. package/dist/libraries/react/{attachTypes-QTf_JXj7.d.ts → attachTypes-DxfaWOQB.d.ts} +5 -5
  21. package/dist/libraries/react/{chunk-4UPD6W4L.mjs → chunk-4EPRIJNB.mjs} +425 -423
  22. package/dist/libraries/react/client/ReactAutumnClient.d.mts +6 -6
  23. package/dist/libraries/react/client/ReactAutumnClient.d.ts +6 -6
  24. package/dist/libraries/react/client/clientCompMethods.d.mts +6 -6
  25. package/dist/libraries/react/client/clientCompMethods.d.ts +6 -6
  26. package/dist/libraries/react/client/clientCusMethods.d.mts +6 -6
  27. package/dist/libraries/react/client/clientCusMethods.d.ts +6 -6
  28. package/dist/libraries/react/client/clientEntityMethods.d.mts +6 -6
  29. package/dist/libraries/react/client/clientEntityMethods.d.ts +6 -6
  30. package/dist/libraries/react/client/clientGenMethods.d.mts +6 -6
  31. package/dist/libraries/react/client/clientGenMethods.d.ts +6 -6
  32. package/dist/libraries/react/client/clientProdMethods.d.mts +6 -6
  33. package/dist/libraries/react/client/clientProdMethods.d.ts +6 -6
  34. package/dist/libraries/react/client/clientReferralMethods.d.mts +6 -6
  35. package/dist/libraries/react/client/clientReferralMethods.d.ts +6 -6
  36. package/dist/libraries/react/client/types/clientAttachTypes.d.mts +20 -20
  37. package/dist/libraries/react/client/types/clientAttachTypes.d.ts +20 -20
  38. package/dist/libraries/react/client/types/clientGenTypes.d.mts +4 -4
  39. package/dist/libraries/react/client/types/clientGenTypes.d.ts +4 -4
  40. package/dist/libraries/react/components/checkout-dialog/checkout-dialog-synced.d.mts +2 -2
  41. package/dist/libraries/react/components/checkout-dialog/checkout-dialog-synced.d.ts +2 -2
  42. package/dist/libraries/react/components/checkout-dialog/checkout-dialog-synced.mjs +12 -12
  43. package/dist/libraries/react/components/checkout-dialog/lib/checkout-content.d.mts +2 -2
  44. package/dist/libraries/react/components/checkout-dialog/lib/checkout-content.d.ts +2 -2
  45. package/dist/libraries/react/components/paywall-dialog/lib/paywall-content.d.mts +1 -1
  46. package/dist/libraries/react/components/paywall-dialog/lib/paywall-content.d.ts +1 -1
  47. package/dist/libraries/react/components/paywall-dialog/paywall-dialog-synced.mjs +12 -12
  48. package/dist/libraries/react/components/pricing-table/lib/pricing-table-content.d.mts +1 -1
  49. package/dist/libraries/react/components/pricing-table/lib/pricing-table-content.d.ts +1 -1
  50. package/dist/libraries/react/components/pricing-table/pricing-table-synced.d.mts +1 -1
  51. package/dist/libraries/react/components/pricing-table/pricing-table-synced.d.ts +1 -1
  52. package/dist/libraries/react/components/pricing-table/pricing-table-synced.mjs +12 -12
  53. package/dist/libraries/react/components/ui/dialog.mjs +2 -2
  54. package/dist/libraries/react/components/ui/popover.mjs +2 -2
  55. package/dist/libraries/react/{cusTypes-DbCQV8Sj.d.mts → cusTypes-B2w8Kg9H.d.mts} +4 -3
  56. package/dist/libraries/react/{cusTypes-BeSXIQ6P.d.ts → cusTypes-C8UH2xVw.d.ts} +4 -3
  57. package/dist/libraries/react/{entTypes-0CBBecul.d.ts → entTypes-Byz3wYbQ.d.ts} +1 -1
  58. package/dist/libraries/react/{entTypes-kVUQcah5.d.mts → entTypes-ItJ8BoHV.d.mts} +1 -1
  59. package/dist/libraries/react/{genTypes-fEH_nqSm.d.mts → genTypes-DSvR32on.d.mts} +5 -5
  60. package/dist/libraries/react/{genTypes-DsiuvyWS.d.ts → genTypes-EyxQImzh.d.ts} +5 -5
  61. package/dist/libraries/react/hooks/helpers/handleCheck.d.mts +6 -6
  62. package/dist/libraries/react/hooks/helpers/handleCheck.d.ts +6 -6
  63. package/dist/libraries/react/hooks/helpers/useAutumnBase.d.mts +7 -7
  64. package/dist/libraries/react/hooks/helpers/useAutumnBase.d.ts +7 -7
  65. package/dist/libraries/react/hooks/useAnalytics.d.mts +2 -2
  66. package/dist/libraries/react/hooks/useAnalytics.d.ts +2 -2
  67. package/dist/libraries/react/hooks/useCustomer.d.mts +6 -6
  68. package/dist/libraries/react/hooks/useCustomer.d.ts +6 -6
  69. package/dist/libraries/react/hooks/useCustomerBase.d.mts +6 -6
  70. package/dist/libraries/react/hooks/useCustomerBase.d.ts +6 -6
  71. package/dist/libraries/react/hooks/useEntity.d.mts +4 -4
  72. package/dist/libraries/react/hooks/useEntity.d.ts +4 -4
  73. package/dist/libraries/react/hooks/useEntityBase.d.mts +6 -6
  74. package/dist/libraries/react/hooks/useEntityBase.d.ts +6 -6
  75. package/dist/libraries/react/hooks/usePaywall.d.mts +1 -1
  76. package/dist/libraries/react/hooks/usePaywall.d.ts +1 -1
  77. package/dist/libraries/react/hooks/usePricingTable.d.mts +1 -1
  78. package/dist/libraries/react/hooks/usePricingTable.d.ts +1 -1
  79. package/dist/libraries/react/hooks/usePricingTableBase.d.mts +6 -6
  80. package/dist/libraries/react/hooks/usePricingTableBase.d.ts +6 -6
  81. package/dist/libraries/react/hooks/useProductsBase.d.mts +6 -6
  82. package/dist/libraries/react/hooks/useProductsBase.d.ts +6 -6
  83. package/dist/libraries/react/index.d.mts +1 -0
  84. package/dist/libraries/react/index.d.ts +1 -0
  85. package/dist/libraries/react/{prodTypes--VvnyGlN.d.mts → prodTypes-Bmoibf-M.d.mts} +5 -5
  86. package/dist/libraries/react/{prodTypes--VvnyGlN.d.ts → prodTypes-Bmoibf-M.d.ts} +5 -5
  87. package/dist/next/client/NextAutumnClient.d.mts +6 -6
  88. package/dist/next/client/NextAutumnClient.d.ts +6 -6
  89. package/dist/next/client/NextAutumnProvider.d.mts +1 -1
  90. package/dist/next/client/NextAutumnProvider.d.ts +1 -1
  91. package/dist/next/client/clientUtils.d.mts +2 -2
  92. package/dist/next/client/clientUtils.d.ts +2 -2
  93. package/dist/next/client/{cusTypes-CYojUJSJ.d.ts → cusTypes-DRJ574aU.d.ts} +3 -2
  94. package/dist/next/client/{cusTypes-CIGvysWL.d.mts → cusTypes-c6-g1-Yy.d.mts} +3 -2
  95. package/dist/next/client/{entTypes-mOI7WnPZ.d.mts → entTypes-Bf0302Om.d.mts} +1 -1
  96. package/dist/next/client/{entTypes-BAD1NMvb.d.ts → entTypes-KSBxuyW-.d.ts} +1 -1
  97. package/dist/next/client/hooks/useAutumn.d.mts +3 -3
  98. package/dist/next/client/hooks/useAutumn.d.ts +3 -3
  99. package/dist/next/client/hooks/useCustomer.d.mts +4 -4
  100. package/dist/next/client/hooks/useCustomer.d.ts +4 -4
  101. package/dist/next/client/hooks/useEntity.d.mts +3 -3
  102. package/dist/next/client/hooks/useEntity.d.ts +3 -3
  103. package/dist/next/client/types.d.mts +2 -2
  104. package/dist/next/client/types.d.ts +2 -2
  105. package/dist/next/server/auth/withNextAuth.d.mts +1 -1
  106. package/dist/next/server/auth/withNextAuth.d.ts +1 -1
  107. package/dist/next/server/componentActions.d.mts +1 -1
  108. package/dist/next/server/componentActions.d.ts +1 -1
  109. package/dist/next/server/cusActions.d.mts +1 -1
  110. package/dist/next/server/cusActions.d.ts +1 -1
  111. package/dist/next/server/{cusTypes-CwopPHB0.d.mts → cusTypes-Cu6SOTmn.d.mts} +1 -0
  112. package/dist/next/server/{cusTypes-CwopPHB0.d.ts → cusTypes-Cu6SOTmn.d.ts} +1 -0
  113. package/dist/next/server/genActions.d.mts +1 -1
  114. package/dist/next/server/genActions.d.ts +1 -1
  115. package/dist/sdk/index.d.mts +1 -0
  116. package/dist/sdk/index.d.ts +1 -0
  117. package/package.json +1 -1
  118. package/dist/libraries/react/{chunk-FJWZPMWU.mjs → chunk-7JNU5ABT.mjs} +3 -3
  119. package/dist/libraries/react/{chunk-OTZ65PCT.mjs → chunk-LCWL3TIT.mjs} +3 -3
  120. package/dist/next/client/{attachTypes-DUUIHTBt.d.mts → attachTypes--97TsCMB.d.mts} +2 -2
  121. package/dist/next/client/{attachTypes-CReq8zJ_.d.ts → attachTypes-B1sM-0vf.d.ts} +2 -2
  122. package/dist/next/client/{clientAttachTypes-umadXlvp.d.ts → clientAttachTypes-BXtfXB4v.d.ts} +2 -2
  123. package/dist/next/client/{clientAttachTypes-BzsPgggN.d.mts → clientAttachTypes-qsdoMt_B.d.mts} +2 -2
@@ -3,24 +3,6 @@
3
3
  import {
4
4
  getPaywallContent
5
5
  } from "./chunk-I5ZGIAIX.mjs";
6
- import {
7
- getCheckoutContent
8
- } from "./chunk-BLM4DAAR.mjs";
9
- import {
10
- getPricingTableContent
11
- } from "./chunk-URQMBRFZ.mjs";
12
- import {
13
- Popover,
14
- PopoverContent,
15
- PopoverTrigger
16
- } from "./chunk-OTZ65PCT.mjs";
17
- import {
18
- Switch
19
- } from "./chunk-YWQTQ72B.mjs";
20
- import {
21
- loadingStyles,
22
- spinnerStyles
23
- } from "./chunk-WVKYZYFT.mjs";
24
6
  import {
25
7
  Accordion,
26
8
  AccordionContent,
@@ -36,7 +18,7 @@ import {
36
18
  DialogContent,
37
19
  DialogFooter,
38
20
  DialogTitle
39
- } from "./chunk-FJWZPMWU.mjs";
21
+ } from "./chunk-7JNU5ABT.mjs";
40
22
  import {
41
23
  ArrowRight,
42
24
  ChevronDown,
@@ -45,6 +27,24 @@ import {
45
27
  import {
46
28
  Input
47
29
  } from "./chunk-GUM4HIGI.mjs";
30
+ import {
31
+ Popover,
32
+ PopoverContent,
33
+ PopoverTrigger
34
+ } from "./chunk-LCWL3TIT.mjs";
35
+ import {
36
+ Switch
37
+ } from "./chunk-YWQTQ72B.mjs";
38
+ import {
39
+ getPricingTableContent
40
+ } from "./chunk-URQMBRFZ.mjs";
41
+ import {
42
+ getCheckoutContent
43
+ } from "./chunk-BLM4DAAR.mjs";
44
+ import {
45
+ loadingStyles,
46
+ spinnerStyles
47
+ } from "./chunk-WVKYZYFT.mjs";
48
48
  import {
49
49
  usePaywall
50
50
  } from "./chunk-JJVQIA5V.mjs";
@@ -59,408 +59,99 @@ import {
59
59
  } from "./chunk-CPN2LD2I.mjs";
60
60
 
61
61
  // src/libraries/react/components/checkout-dialog/checkout-dialog-synced.tsx
62
- import { useEffect, useState } from "react";
62
+ import { useEffect, useState as useState2 } from "react";
63
+
64
+ // src/libraries/react/components/paywall-dialog/paywall-dialog-synced.tsx
63
65
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
64
- var formatCurrency = ({
65
- amount,
66
- currency
67
- }) => {
68
- return new Intl.NumberFormat("en-US", {
69
- style: "currency",
70
- currency
71
- }).format(amount);
72
- };
73
- function CheckoutDialog(params) {
74
- const { attach } = useCustomer();
75
- const [checkoutResult, setCheckoutResult] = useState(params?.checkoutResult);
76
- useEffect(() => {
77
- if (params.checkoutResult) {
78
- setCheckoutResult(params.checkoutResult);
79
- }
80
- }, [params.checkoutResult]);
81
- const [loading, setLoading] = useState(false);
82
- if (!checkoutResult) {
66
+ function PaywallDialog(params) {
67
+ const { data: preview } = usePaywall({
68
+ featureId: params?.featureId,
69
+ entityId: params?.entityId
70
+ });
71
+ if (!params || !preview) {
83
72
  return /* @__PURE__ */ jsx(Fragment, {});
84
73
  }
85
74
  const { open, setOpen } = params;
86
- const { title, message } = getCheckoutContent(checkoutResult);
87
- const isFree = checkoutResult?.product.properties?.is_free;
88
- const isPaid = isFree === false;
89
- return /* @__PURE__ */ jsx(Dialog, { open, onOpenChange: setOpen, children: /* @__PURE__ */ jsxs(DialogContent, { className: "au-p-0 au-pt-4 au-gap-0 au-text-foreground au-text-sm", children: [
90
- /* @__PURE__ */ jsx(DialogTitle, { className: "au-px-6 au-mb-1", children: title }),
91
- /* @__PURE__ */ jsx("div", { className: "au-px-6 au-mt-1 au-mb-4 au-text-muted-foreground", children: message }),
92
- isPaid && checkoutResult && /* @__PURE__ */ jsx(
93
- PriceInformation,
94
- {
95
- checkoutResult,
96
- setCheckoutResult
97
- }
98
- ),
99
- /* @__PURE__ */ jsx(DialogFooter, { className: "au-flex au-flex-col sm:au-flex-row au-justify-between au-gap-x-4 au-py-2 au-pl-6 au-pr-3 au-bg-secondary au-border-t au-shadow-inner", children: /* @__PURE__ */ jsx(
75
+ const { title, message } = getPaywallContent(preview);
76
+ return /* @__PURE__ */ jsx(Dialog, { open, onOpenChange: setOpen, children: /* @__PURE__ */ jsxs(DialogContent, { className: "au-p-0 au-pt-4 au-gap-0 au-text-foreground au-overflow-hidden au-text-sm", children: [
77
+ /* @__PURE__ */ jsx(DialogTitle, { className: cn("au-font-bold au-text-xl au-px-6"), children: title }),
78
+ /* @__PURE__ */ jsx("div", { className: "au-px-6 au-my-2", children: message }),
79
+ /* @__PURE__ */ jsx(DialogFooter, { className: "au-flex au-flex-col sm:au-flex-row au-justify-between au-gap-x-4 au-py-2 au-mt-4 au-pl-6 au-pr-3 au-bg-secondary au-border-t", children: /* @__PURE__ */ jsx(
100
80
  Button,
101
81
  {
102
82
  size: "sm",
83
+ className: "au-font-medium au-shadow au-transition au-min-w-20",
103
84
  onClick: async () => {
104
- setLoading(true);
105
- const options = checkoutResult.options.map((option) => {
106
- return {
107
- featureId: option.feature_id,
108
- quantity: option.quantity
109
- };
110
- });
111
- await attach({
112
- productId: checkoutResult.product.id,
113
- options
114
- });
115
85
  setOpen(false);
116
- setLoading(false);
117
86
  },
118
- disabled: loading,
119
- className: "au-min-w-16 au-flex au-items-center au-gap-2",
120
- children: loading ? /* @__PURE__ */ jsx(LoaderCircle, { className: "au-w-4 au-h-4 au-animate-spin" }) : /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx("span", { className: "au-whitespace-nowrap au-flex au-gap-1", children: "Confirm" }) })
87
+ children: "Confirm"
121
88
  }
122
89
  ) })
123
90
  ] }) });
124
91
  }
125
- function PriceInformation({
126
- checkoutResult,
127
- setCheckoutResult
92
+
93
+ // src/libraries/react/components/pricing-table/pricing-table-synced.tsx
94
+ import React from "react";
95
+ import { createContext, useContext, useState } from "react";
96
+ import { Fragment as Fragment2, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
97
+ function PricingTable({
98
+ productDetails
128
99
  }) {
129
- return /* @__PURE__ */ jsxs("div", { className: "au-px-6 au-mb-4 au-flex au-flex-col au-gap-4", children: [
130
- /* @__PURE__ */ jsx(
131
- ProductItems,
132
- {
133
- checkoutResult,
134
- setCheckoutResult
135
- }
136
- ),
137
- /* @__PURE__ */ jsxs("div", { className: "au-flex au-flex-col au-gap-2", children: [
138
- checkoutResult?.has_prorations && checkoutResult.lines.length > 0 && /* @__PURE__ */ jsx(CheckoutLines, { checkoutResult }),
139
- /* @__PURE__ */ jsx(DueAmounts, { checkoutResult })
140
- ] })
141
- ] });
142
- }
143
- function DueAmounts({ checkoutResult }) {
144
- const { next_cycle, product } = checkoutResult;
145
- const nextCycleAtStr = next_cycle ? new Date(next_cycle.starts_at).toLocaleDateString() : void 0;
146
- const hasUsagePrice = product.items.some(
147
- (item) => item.usage_model === "pay_per_use"
100
+ const { customer, checkout } = useCustomer({ errorOnNotFound: false });
101
+ const [isAnnual, setIsAnnual] = useState(false);
102
+ const { products, isLoading, error } = usePricingTable({ productDetails });
103
+ if (isLoading) {
104
+ return /* @__PURE__ */ jsx2("div", { style: loadingStyles, children: /* @__PURE__ */ jsx2(LoaderCircle, { style: spinnerStyles }) });
105
+ }
106
+ if (error) {
107
+ return /* @__PURE__ */ jsx2("div", { children: " Something went wrong..." });
108
+ }
109
+ const intervals = Array.from(
110
+ new Set(
111
+ products?.map((p) => p.properties?.interval_group).filter((i) => !!i)
112
+ )
148
113
  );
149
- const showNextCycle = next_cycle && next_cycle.total !== checkoutResult.total;
150
- return /* @__PURE__ */ jsxs("div", { className: "au-flex au-flex-col au-gap-1", children: [
151
- /* @__PURE__ */ jsxs("div", { className: "au-flex au-justify-between", children: [
152
- /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx("p", { className: "au-font-medium au-text-md", children: "Total due today" }) }),
153
- /* @__PURE__ */ jsx("p", { className: "au-font-medium au-text-md", children: formatCurrency({
154
- amount: checkoutResult?.total,
155
- currency: checkoutResult?.currency
156
- }) })
157
- ] }),
158
- showNextCycle && /* @__PURE__ */ jsxs("div", { className: "au-flex au-justify-between au-text-muted-foreground", children: [
159
- /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsxs("p", { className: "au-text-md", children: [
160
- "Due next cycle (",
161
- nextCycleAtStr,
162
- ")"
163
- ] }) }),
164
- /* @__PURE__ */ jsxs("p", { className: "au-text-md", children: [
165
- formatCurrency({
166
- amount: next_cycle.total,
167
- currency: checkoutResult?.currency
168
- }),
169
- hasUsagePrice && /* @__PURE__ */ jsx("span", { children: " + usage prices" })
170
- ] })
171
- ] })
172
- ] });
173
- }
174
- function ProductItems({
175
- checkoutResult,
176
- setCheckoutResult
177
- }) {
178
- const isUpdateQuantity = checkoutResult?.product.scenario === "active" && checkoutResult.product.properties.updateable;
179
- const isOneOff = checkoutResult?.product.properties.is_one_off;
180
- return /* @__PURE__ */ jsxs("div", { className: "au-flex au-flex-col au-gap-2", children: [
181
- /* @__PURE__ */ jsx("p", { className: "au-text-sm au-font-medium", children: "Price" }),
182
- checkoutResult?.product.items.filter((item) => item.type !== "feature").map((item, index) => {
183
- if (item.usage_model == "prepaid") {
184
- return /* @__PURE__ */ jsx(
185
- PrepaidItem,
186
- {
187
- item,
188
- checkoutResult,
189
- setCheckoutResult
190
- },
191
- index
192
- );
193
- }
194
- if (isUpdateQuantity) {
195
- return null;
114
+ const multiInterval = intervals.length > 1;
115
+ const intervalFilter = (product) => {
116
+ if (!product.properties?.interval_group) {
117
+ return true;
118
+ }
119
+ if (multiInterval) {
120
+ if (isAnnual) {
121
+ return product.properties?.interval_group === "year";
122
+ } else {
123
+ return product.properties?.interval_group === "month";
196
124
  }
197
- return /* @__PURE__ */ jsxs("div", { className: "au-flex au-justify-between", children: [
198
- /* @__PURE__ */ jsx("p", { className: "au-text-muted-foreground", children: item.feature ? item.feature.name : isOneOff ? "Price" : "Subscription" }),
199
- /* @__PURE__ */ jsxs("p", { children: [
200
- item.display?.primary_text,
201
- " ",
202
- item.display?.secondary_text
203
- ] })
204
- ] }, index);
205
- })
206
- ] });
207
- }
208
- function CheckoutLines({ checkoutResult }) {
209
- return /* @__PURE__ */ jsx(Accordion, { type: "single", collapsible: true, children: /* @__PURE__ */ jsxs(AccordionItem, { value: "total", className: "au-border-b-0", children: [
210
- /* @__PURE__ */ jsx(CustomAccordionTrigger, { className: "au-justify-between au-w-full au-my-0 au-py-0 au-border-none", children: /* @__PURE__ */ jsxs("div", { className: "au-cursor-pointer au-flex au-items-center au-gap-1 au-w-full au-justify-end", children: [
211
- /* @__PURE__ */ jsx("p", { className: "au-font-light au-text-muted-foreground", children: "View details" }),
212
- /* @__PURE__ */ jsx(
213
- ChevronDown,
214
- {
215
- className: "au-text-muted-foreground au-mt-0.5 au-rotate-90 au-transition-transform au-duration-200 au-ease-in-out",
216
- size: 14
217
- }
218
- )
219
- ] }) }),
220
- /* @__PURE__ */ jsx(AccordionContent, { className: "au-mt-2 au-mb-0 au-pb-2 au-flex au-flex-col au-gap-2", children: checkoutResult?.lines.filter((line) => line.amount != 0).map((line, index) => {
221
- return /* @__PURE__ */ jsxs("div", { className: "au-flex au-justify-between", children: [
222
- /* @__PURE__ */ jsx("p", { className: "au-text-muted-foreground", children: line.description }),
223
- /* @__PURE__ */ jsx("p", { className: "au-text-muted-foreground", children: new Intl.NumberFormat("en-US", {
224
- style: "currency",
225
- currency: checkoutResult?.currency
226
- }).format(line.amount) })
227
- ] }, index);
228
- }) })
229
- ] }) });
230
- }
231
- function CustomAccordionTrigger({
232
- className,
233
- children,
234
- ...props
235
- }) {
236
- return /* @__PURE__ */ jsx(Header, { className: "au-flex", children: /* @__PURE__ */ jsx(
237
- Trigger2,
125
+ }
126
+ return true;
127
+ };
128
+ return /* @__PURE__ */ jsx2("div", { className: cn("au-root"), children: products && /* @__PURE__ */ jsx2(
129
+ PricingTableContainer,
238
130
  {
239
- "data-slot": "accordion-trigger",
240
- className: cn(
241
- "focus-visible:au-border-ring focus-visible:au-ring-ring/50 au-flex au-flex-1 au-items-start au-justify-between au-gap-4 au-rounded-md au-py-4 au-text-left au-text-sm au-font-medium au-transition-all au-outline-none focus-visible:au-ring-[3px] disabled:au-pointer-events-none disabled:au-opacity-50 [&[data-state=open]_svg]:au-rotate-0",
242
- className
243
- ),
244
- ...props,
245
- children
246
- }
247
- ) });
248
- }
249
- var PrepaidItem = ({
250
- item,
251
- checkoutResult,
252
- setCheckoutResult
253
- }) => {
254
- const { quantity = 0, billing_units: billingUnits = 1 } = item;
255
- const [quantityInput, setQuantityInput] = useState(
256
- (quantity / billingUnits).toString()
257
- );
258
- const { checkout } = useCustomer();
259
- const [loading, setLoading] = useState(false);
260
- const [open, setOpen] = useState(false);
261
- const scenario = checkoutResult.product.scenario;
262
- const handleSave = async () => {
263
- setLoading(true);
264
- try {
265
- const newOptions = checkoutResult.options.filter((option) => option.feature_id !== item.feature_id).map((option) => {
266
- return {
267
- featureId: option.feature_id,
268
- quantity: option.quantity
269
- };
270
- });
271
- newOptions.push({
272
- featureId: item.feature_id,
273
- quantity: Number(quantityInput) * billingUnits
274
- });
275
- const { data, error } = await checkout({
276
- productId: checkoutResult.product.id,
277
- options: newOptions,
278
- dialog: CheckoutDialog
279
- });
280
- if (error) {
281
- console.error(error);
282
- return;
283
- }
284
- setCheckoutResult(data);
285
- } catch (error) {
286
- console.error(error);
287
- } finally {
288
- setLoading(false);
289
- setOpen(false);
290
- }
291
- };
292
- const disableSelection = scenario === "renew";
293
- return /* @__PURE__ */ jsxs("div", { className: "au-flex au-justify-between", children: [
294
- /* @__PURE__ */ jsxs("div", { className: "au-flex au-gap-2", children: [
295
- /* @__PURE__ */ jsx("p", { className: "au-text-muted-foreground", children: item.feature?.name }),
296
- /* @__PURE__ */ jsxs(Popover, { open, onOpenChange: setOpen, children: [
297
- /* @__PURE__ */ jsxs(
298
- PopoverTrigger,
299
- {
300
- className: cn(
301
- "au-text-muted-foreground au-text-xs au-px-1 au-py-0.5 au-rounded-md au-flex au-items-center au-gap-1 au-bg-accent/80",
302
- disableSelection !== true && "hover:au-bg-accent hover:au-text-foreground"
303
- ),
304
- disabled: disableSelection,
305
- children: [
306
- "Qty: ",
307
- quantity,
308
- /* @__PURE__ */ jsx(ChevronDown, { size: 12 })
309
- ]
310
- }
311
- ),
312
- /* @__PURE__ */ jsxs(
313
- PopoverContent,
314
- {
315
- align: "start",
316
- className: "au-w-80 au-text-sm au-p-4 au-pt-3 au-flex au-flex-col au-gap-4",
317
- children: [
318
- /* @__PURE__ */ jsxs("div", { className: "au-flex au-flex-col au-gap-1", children: [
319
- /* @__PURE__ */ jsx("p", { className: "au-text-sm au-font-medium", children: item.feature?.name }),
320
- /* @__PURE__ */ jsxs("p", { className: "au-text-muted-foreground", children: [
321
- item.display?.primary_text,
322
- " ",
323
- item.display?.secondary_text
324
- ] })
325
- ] }),
326
- /* @__PURE__ */ jsxs("div", { className: "au-flex au-justify-between au-items-end", children: [
327
- /* @__PURE__ */ jsxs("div", { className: "au-flex au-gap-2 au-items-center", children: [
328
- /* @__PURE__ */ jsx(
329
- Input,
330
- {
331
- className: "au-h-7 au-w-16 focus:!au-ring-2",
332
- value: quantityInput,
333
- onChange: (e) => setQuantityInput(e.target.value)
334
- }
335
- ),
336
- /* @__PURE__ */ jsxs("p", { className: "au-text-muted-foreground", children: [
337
- billingUnits > 1 && `x ${billingUnits} `,
338
- item.feature?.name
339
- ] })
340
- ] }),
341
- /* @__PURE__ */ jsx(
342
- Button,
343
- {
344
- onClick: handleSave,
345
- className: "au-w-14 !au-h-7 au-text-sm au-items-center au-bg-white au-text-foreground au-shadow-sm au-border au-border-zinc-200 hover:au-bg-zinc-100",
346
- disabled: loading,
347
- children: loading ? /* @__PURE__ */ jsx(LoaderCircle, { className: "au-text-muted-foreground au-animate-spin !au-w-4 !au-h-4" }) : "Save"
348
- }
349
- )
350
- ] })
351
- ]
352
- }
353
- )
354
- ] })
355
- ] }),
356
- /* @__PURE__ */ jsxs("p", { children: [
357
- item.display?.primary_text,
358
- " ",
359
- item.display?.secondary_text
360
- ] })
361
- ] });
362
- };
363
- var PriceItem = ({
364
- children,
365
- className,
366
- ...props
367
- }) => {
368
- return /* @__PURE__ */ jsx(
369
- "div",
370
- {
371
- className: cn(
372
- "au-flex au-flex-col au-pb-4 sm:au-pb-0 au-gap-1 sm:au-flex-row au-justify-between sm:au-h-7 sm:au-gap-2 sm:au-items-center",
373
- className
374
- ),
375
- ...props,
376
- children
377
- }
378
- );
379
- };
380
- var PricingDialogButton = ({
381
- children,
382
- size,
383
- onClick,
384
- disabled,
385
- className
386
- }) => {
387
- return /* @__PURE__ */ jsxs(
388
- Button,
389
- {
390
- onClick,
391
- disabled,
392
- size,
393
- className: cn(className, "au-shadow-sm au-shadow-stone-400"),
394
- children: [
395
- children,
396
- /* @__PURE__ */ jsx(ArrowRight, { className: "!au-h-3" })
397
- ]
398
- }
399
- );
400
- };
401
-
402
- // src/libraries/react/components/pricing-table/pricing-table-synced.tsx
403
- import React2 from "react";
404
- import { createContext, useContext, useState as useState2 } from "react";
405
- import { Fragment as Fragment2, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
406
- function PricingTable({
407
- productDetails
408
- }) {
409
- const { customer, checkout } = useCustomer({ errorOnNotFound: false });
410
- const [isAnnual, setIsAnnual] = useState2(false);
411
- const { products, isLoading, error } = usePricingTable({ productDetails });
412
- if (isLoading) {
413
- return /* @__PURE__ */ jsx2("div", { style: loadingStyles, children: /* @__PURE__ */ jsx2(LoaderCircle, { style: spinnerStyles }) });
414
- }
415
- if (error) {
416
- return /* @__PURE__ */ jsx2("div", { children: " Something went wrong..." });
417
- }
418
- const intervals = Array.from(
419
- new Set(
420
- products?.map((p) => p.properties?.interval_group).filter((i) => !!i)
421
- )
422
- );
423
- const multiInterval = intervals.length > 1;
424
- const intervalFilter = (product) => {
425
- if (!product.properties?.interval_group) {
426
- return true;
427
- }
428
- if (multiInterval) {
429
- if (isAnnual) {
430
- return product.properties?.interval_group === "year";
431
- } else {
432
- return product.properties?.interval_group === "month";
433
- }
434
- }
435
- return true;
436
- };
437
- return /* @__PURE__ */ jsx2("div", { className: cn("au-root"), children: products && /* @__PURE__ */ jsx2(
438
- PricingTableContainer,
439
- {
440
- products,
441
- isAnnualToggle: isAnnual,
442
- setIsAnnualToggle: setIsAnnual,
443
- multiInterval,
444
- children: products.filter(intervalFilter).map((product, index) => /* @__PURE__ */ jsx2(
445
- PricingCard,
446
- {
447
- productId: product.id,
448
- buttonProps: {
449
- disabled: product.scenario === "active" && !product.properties.updateable || product.scenario === "scheduled",
450
- onClick: async () => {
451
- if (product.id && customer) {
452
- await checkout({
453
- productId: product.id,
454
- dialog: CheckoutDialog
455
- });
456
- } else if (product.display?.button_url) {
457
- window.open(product.display?.button_url, "_blank");
458
- }
459
- }
460
- }
461
- },
462
- index
463
- ))
131
+ products,
132
+ isAnnualToggle: isAnnual,
133
+ setIsAnnualToggle: setIsAnnual,
134
+ multiInterval,
135
+ children: products.filter(intervalFilter).map((product, index) => /* @__PURE__ */ jsx2(
136
+ PricingCard,
137
+ {
138
+ productId: product.id,
139
+ buttonProps: {
140
+ disabled: product.scenario === "active" && !product.properties.updateable || product.scenario === "scheduled",
141
+ onClick: async () => {
142
+ if (product.id && customer) {
143
+ await checkout({
144
+ productId: product.id,
145
+ dialog: CheckoutDialog
146
+ });
147
+ } else if (product.display?.button_url) {
148
+ window.open(product.display?.button_url, "_blank");
149
+ }
150
+ }
151
+ }
152
+ },
153
+ index
154
+ ))
464
155
  }
465
156
  ) });
466
157
  }
@@ -637,8 +328,8 @@ var PricingFeatureList = ({
637
328
  )) })
638
329
  ] });
639
330
  };
640
- var PricingCardButton = React2.forwardRef(({ recommended, children, className, onClick, ...props }, ref) => {
641
- const [loading, setLoading] = useState2(false);
331
+ var PricingCardButton = React.forwardRef(({ recommended, children, className, onClick, ...props }, ref) => {
332
+ const [loading, setLoading] = useState(false);
642
333
  const handleClick = async (e) => {
643
334
  setLoading(true);
644
335
  try {
@@ -696,36 +387,350 @@ var RecommendedBadge = ({ recommended }) => {
696
387
  return /* @__PURE__ */ jsx2("div", { className: "au-bg-secondary au-absolute au-border au-text-muted-foreground au-text-sm au-font-medium lg:au-rounded-full au-px-3 lg:au-py-0.5 lg:au-top-4 lg:au-right-4 au-top-[-1px] au-right-[-1px] au-rounded-bl-lg", children: recommended });
697
388
  };
698
389
 
699
- // src/libraries/react/components/paywall-dialog/paywall-dialog-synced.tsx
390
+ // src/libraries/react/components/checkout-dialog/checkout-dialog-synced.tsx
700
391
  import { Fragment as Fragment3, jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
701
- function PaywallDialog(params) {
702
- const { data: preview } = usePaywall({
703
- featureId: params?.featureId,
704
- entityId: params?.entityId
705
- });
706
- if (!params || !preview) {
392
+ var formatCurrency = ({
393
+ amount,
394
+ currency
395
+ }) => {
396
+ return new Intl.NumberFormat("en-US", {
397
+ style: "currency",
398
+ currency
399
+ }).format(amount);
400
+ };
401
+ function CheckoutDialog(params) {
402
+ const { attach } = useCustomer();
403
+ const [checkoutResult, setCheckoutResult] = useState2(params?.checkoutResult);
404
+ useEffect(() => {
405
+ if (params.checkoutResult) {
406
+ setCheckoutResult(params.checkoutResult);
407
+ }
408
+ }, [params.checkoutResult]);
409
+ const [loading, setLoading] = useState2(false);
410
+ if (!checkoutResult) {
707
411
  return /* @__PURE__ */ jsx3(Fragment3, {});
708
412
  }
709
413
  const { open, setOpen } = params;
710
- const { title, message } = getPaywallContent(preview);
711
- return /* @__PURE__ */ jsx3(Dialog, { open, onOpenChange: setOpen, children: /* @__PURE__ */ jsxs3(DialogContent, { className: "au-p-0 au-pt-4 au-gap-0 au-text-foreground au-overflow-hidden au-text-sm", children: [
712
- /* @__PURE__ */ jsx3(DialogTitle, { className: cn("au-font-bold au-text-xl au-px-6"), children: title }),
713
- /* @__PURE__ */ jsx3("div", { className: "au-px-6 au-my-2", children: message }),
714
- /* @__PURE__ */ jsx3(DialogFooter, { className: "au-flex au-flex-col sm:au-flex-row au-justify-between au-gap-x-4 au-py-2 au-mt-4 au-pl-6 au-pr-3 au-bg-secondary au-border-t", children: /* @__PURE__ */ jsx3(
414
+ const { title, message } = getCheckoutContent(checkoutResult);
415
+ const isFree = checkoutResult?.product.properties?.is_free;
416
+ const isPaid = isFree === false;
417
+ return /* @__PURE__ */ jsx3(Dialog, { open, onOpenChange: setOpen, children: /* @__PURE__ */ jsxs3(DialogContent, { className: "au-p-0 au-pt-4 au-gap-0 au-text-foreground au-text-sm", children: [
418
+ /* @__PURE__ */ jsx3(DialogTitle, { className: "au-px-6 au-mb-1", children: title }),
419
+ /* @__PURE__ */ jsx3("div", { className: "au-px-6 au-mt-1 au-mb-4 au-text-muted-foreground", children: message }),
420
+ isPaid && checkoutResult && /* @__PURE__ */ jsx3(
421
+ PriceInformation,
422
+ {
423
+ checkoutResult,
424
+ setCheckoutResult
425
+ }
426
+ ),
427
+ /* @__PURE__ */ jsx3(DialogFooter, { className: "au-flex au-flex-col sm:au-flex-row au-justify-between au-gap-x-4 au-py-2 au-pl-6 au-pr-3 au-bg-secondary au-border-t au-shadow-inner", children: /* @__PURE__ */ jsx3(
715
428
  Button,
716
429
  {
717
430
  size: "sm",
718
- className: "au-font-medium au-shadow au-transition au-min-w-20",
719
431
  onClick: async () => {
432
+ setLoading(true);
433
+ const options = checkoutResult.options.map((option) => {
434
+ return {
435
+ featureId: option.feature_id,
436
+ quantity: option.quantity
437
+ };
438
+ });
439
+ await attach({
440
+ productId: checkoutResult.product.id,
441
+ options
442
+ });
720
443
  setOpen(false);
444
+ setLoading(false);
721
445
  },
722
- children: "Confirm"
446
+ disabled: loading,
447
+ className: "au-min-w-16 au-flex au-items-center au-gap-2",
448
+ children: loading ? /* @__PURE__ */ jsx3(LoaderCircle, { className: "au-w-4 au-h-4 au-animate-spin" }) : /* @__PURE__ */ jsx3(Fragment3, { children: /* @__PURE__ */ jsx3("span", { className: "au-whitespace-nowrap au-flex au-gap-1", children: "Confirm" }) })
723
449
  }
724
450
  ) })
725
451
  ] }) });
726
452
  }
453
+ function PriceInformation({
454
+ checkoutResult,
455
+ setCheckoutResult
456
+ }) {
457
+ return /* @__PURE__ */ jsxs3("div", { className: "au-px-6 au-mb-4 au-flex au-flex-col au-gap-4", children: [
458
+ /* @__PURE__ */ jsx3(
459
+ ProductItems,
460
+ {
461
+ checkoutResult,
462
+ setCheckoutResult
463
+ }
464
+ ),
465
+ /* @__PURE__ */ jsxs3("div", { className: "au-flex au-flex-col au-gap-2", children: [
466
+ checkoutResult?.has_prorations && checkoutResult.lines.length > 0 && /* @__PURE__ */ jsx3(CheckoutLines, { checkoutResult }),
467
+ /* @__PURE__ */ jsx3(DueAmounts, { checkoutResult })
468
+ ] })
469
+ ] });
470
+ }
471
+ function DueAmounts({ checkoutResult }) {
472
+ const { next_cycle, product } = checkoutResult;
473
+ const nextCycleAtStr = next_cycle ? new Date(next_cycle.starts_at).toLocaleDateString() : void 0;
474
+ const hasUsagePrice = product.items.some(
475
+ (item) => item.usage_model === "pay_per_use"
476
+ );
477
+ const showNextCycle = next_cycle && next_cycle.total !== checkoutResult.total;
478
+ return /* @__PURE__ */ jsxs3("div", { className: "au-flex au-flex-col au-gap-1", children: [
479
+ /* @__PURE__ */ jsxs3("div", { className: "au-flex au-justify-between", children: [
480
+ /* @__PURE__ */ jsx3("div", { children: /* @__PURE__ */ jsx3("p", { className: "au-font-medium au-text-md", children: "Total due today" }) }),
481
+ /* @__PURE__ */ jsx3("p", { className: "au-font-medium au-text-md", children: formatCurrency({
482
+ amount: checkoutResult?.total,
483
+ currency: checkoutResult?.currency
484
+ }) })
485
+ ] }),
486
+ showNextCycle && /* @__PURE__ */ jsxs3("div", { className: "au-flex au-justify-between au-text-muted-foreground", children: [
487
+ /* @__PURE__ */ jsx3("div", { children: /* @__PURE__ */ jsxs3("p", { className: "au-text-md", children: [
488
+ "Due next cycle (",
489
+ nextCycleAtStr,
490
+ ")"
491
+ ] }) }),
492
+ /* @__PURE__ */ jsxs3("p", { className: "au-text-md", children: [
493
+ formatCurrency({
494
+ amount: next_cycle.total,
495
+ currency: checkoutResult?.currency
496
+ }),
497
+ hasUsagePrice && /* @__PURE__ */ jsx3("span", { children: " + usage prices" })
498
+ ] })
499
+ ] })
500
+ ] });
501
+ }
502
+ function ProductItems({
503
+ checkoutResult,
504
+ setCheckoutResult
505
+ }) {
506
+ const isUpdateQuantity = checkoutResult?.product.scenario === "active" && checkoutResult.product.properties.updateable;
507
+ const isOneOff = checkoutResult?.product.properties.is_one_off;
508
+ return /* @__PURE__ */ jsxs3("div", { className: "au-flex au-flex-col au-gap-2", children: [
509
+ /* @__PURE__ */ jsx3("p", { className: "au-text-sm au-font-medium", children: "Price" }),
510
+ checkoutResult?.product.items.filter((item) => item.type !== "feature").map((item, index) => {
511
+ if (item.usage_model == "prepaid") {
512
+ return /* @__PURE__ */ jsx3(
513
+ PrepaidItem,
514
+ {
515
+ item,
516
+ checkoutResult,
517
+ setCheckoutResult
518
+ },
519
+ index
520
+ );
521
+ }
522
+ if (isUpdateQuantity) {
523
+ return null;
524
+ }
525
+ return /* @__PURE__ */ jsxs3("div", { className: "au-flex au-justify-between", children: [
526
+ /* @__PURE__ */ jsx3("p", { className: "au-text-muted-foreground", children: item.feature ? item.feature.name : isOneOff ? "Price" : "Subscription" }),
527
+ /* @__PURE__ */ jsxs3("p", { children: [
528
+ item.display?.primary_text,
529
+ " ",
530
+ item.display?.secondary_text
531
+ ] })
532
+ ] }, index);
533
+ })
534
+ ] });
535
+ }
536
+ function CheckoutLines({ checkoutResult }) {
537
+ return /* @__PURE__ */ jsx3(Accordion, { type: "single", collapsible: true, children: /* @__PURE__ */ jsxs3(AccordionItem, { value: "total", className: "au-border-b-0", children: [
538
+ /* @__PURE__ */ jsx3(CustomAccordionTrigger, { className: "au-justify-between au-w-full au-my-0 au-py-0 au-border-none", children: /* @__PURE__ */ jsxs3("div", { className: "au-cursor-pointer au-flex au-items-center au-gap-1 au-w-full au-justify-end", children: [
539
+ /* @__PURE__ */ jsx3("p", { className: "au-font-light au-text-muted-foreground", children: "View details" }),
540
+ /* @__PURE__ */ jsx3(
541
+ ChevronDown,
542
+ {
543
+ className: "au-text-muted-foreground au-mt-0.5 au-rotate-90 au-transition-transform au-duration-200 au-ease-in-out",
544
+ size: 14
545
+ }
546
+ )
547
+ ] }) }),
548
+ /* @__PURE__ */ jsx3(AccordionContent, { className: "au-mt-2 au-mb-0 au-pb-2 au-flex au-flex-col au-gap-2", children: checkoutResult?.lines.filter((line) => line.amount != 0).map((line, index) => {
549
+ return /* @__PURE__ */ jsxs3("div", { className: "au-flex au-justify-between", children: [
550
+ /* @__PURE__ */ jsx3("p", { className: "au-text-muted-foreground", children: line.description }),
551
+ /* @__PURE__ */ jsx3("p", { className: "au-text-muted-foreground", children: new Intl.NumberFormat("en-US", {
552
+ style: "currency",
553
+ currency: checkoutResult?.currency
554
+ }).format(line.amount) })
555
+ ] }, index);
556
+ }) })
557
+ ] }) });
558
+ }
559
+ function CustomAccordionTrigger({
560
+ className,
561
+ children,
562
+ ...props
563
+ }) {
564
+ return /* @__PURE__ */ jsx3(Header, { className: "au-flex", children: /* @__PURE__ */ jsx3(
565
+ Trigger2,
566
+ {
567
+ "data-slot": "accordion-trigger",
568
+ className: cn(
569
+ "focus-visible:au-border-ring focus-visible:au-ring-ring/50 au-flex au-flex-1 au-items-start au-justify-between au-gap-4 au-rounded-md au-py-4 au-text-left au-text-sm au-font-medium au-transition-all au-outline-none focus-visible:au-ring-[3px] disabled:au-pointer-events-none disabled:au-opacity-50 [&[data-state=open]_svg]:au-rotate-0",
570
+ className
571
+ ),
572
+ ...props,
573
+ children
574
+ }
575
+ ) });
576
+ }
577
+ var PrepaidItem = ({
578
+ item,
579
+ checkoutResult,
580
+ setCheckoutResult
581
+ }) => {
582
+ const { quantity = 0, billing_units: billingUnits = 1 } = item;
583
+ const [quantityInput, setQuantityInput] = useState2(
584
+ (quantity / billingUnits).toString()
585
+ );
586
+ const { checkout } = useCustomer();
587
+ const [loading, setLoading] = useState2(false);
588
+ const [open, setOpen] = useState2(false);
589
+ const scenario = checkoutResult.product.scenario;
590
+ const handleSave = async () => {
591
+ setLoading(true);
592
+ try {
593
+ const newOptions = checkoutResult.options.filter((option) => option.feature_id !== item.feature_id).map((option) => {
594
+ return {
595
+ featureId: option.feature_id,
596
+ quantity: option.quantity
597
+ };
598
+ });
599
+ newOptions.push({
600
+ featureId: item.feature_id,
601
+ quantity: Number(quantityInput) * billingUnits
602
+ });
603
+ const { data, error } = await checkout({
604
+ productId: checkoutResult.product.id,
605
+ options: newOptions,
606
+ dialog: CheckoutDialog
607
+ });
608
+ if (error) {
609
+ console.error(error);
610
+ return;
611
+ }
612
+ setCheckoutResult(data);
613
+ } catch (error) {
614
+ console.error(error);
615
+ } finally {
616
+ setLoading(false);
617
+ setOpen(false);
618
+ }
619
+ };
620
+ const disableSelection = scenario === "renew";
621
+ return /* @__PURE__ */ jsxs3("div", { className: "au-flex au-justify-between", children: [
622
+ /* @__PURE__ */ jsxs3("div", { className: "au-flex au-gap-2", children: [
623
+ /* @__PURE__ */ jsx3("p", { className: "au-text-muted-foreground", children: item.feature?.name }),
624
+ /* @__PURE__ */ jsxs3(Popover, { open, onOpenChange: setOpen, children: [
625
+ /* @__PURE__ */ jsxs3(
626
+ PopoverTrigger,
627
+ {
628
+ className: cn(
629
+ "au-text-muted-foreground au-text-xs au-px-1 au-py-0.5 au-rounded-md au-flex au-items-center au-gap-1 au-bg-accent/80",
630
+ disableSelection !== true && "hover:au-bg-accent hover:au-text-foreground"
631
+ ),
632
+ disabled: disableSelection,
633
+ children: [
634
+ "Qty: ",
635
+ quantity,
636
+ /* @__PURE__ */ jsx3(ChevronDown, { size: 12 })
637
+ ]
638
+ }
639
+ ),
640
+ /* @__PURE__ */ jsxs3(
641
+ PopoverContent,
642
+ {
643
+ align: "start",
644
+ className: "au-w-80 au-text-sm au-p-4 au-pt-3 au-flex au-flex-col au-gap-4",
645
+ children: [
646
+ /* @__PURE__ */ jsxs3("div", { className: "au-flex au-flex-col au-gap-1", children: [
647
+ /* @__PURE__ */ jsx3("p", { className: "au-text-sm au-font-medium", children: item.feature?.name }),
648
+ /* @__PURE__ */ jsxs3("p", { className: "au-text-muted-foreground", children: [
649
+ item.display?.primary_text,
650
+ " ",
651
+ item.display?.secondary_text
652
+ ] })
653
+ ] }),
654
+ /* @__PURE__ */ jsxs3("div", { className: "au-flex au-justify-between au-items-end", children: [
655
+ /* @__PURE__ */ jsxs3("div", { className: "au-flex au-gap-2 au-items-center", children: [
656
+ /* @__PURE__ */ jsx3(
657
+ Input,
658
+ {
659
+ className: "au-h-7 au-w-16 focus:!au-ring-2",
660
+ value: quantityInput,
661
+ onChange: (e) => setQuantityInput(e.target.value)
662
+ }
663
+ ),
664
+ /* @__PURE__ */ jsxs3("p", { className: "au-text-muted-foreground", children: [
665
+ billingUnits > 1 && `x ${billingUnits} `,
666
+ item.feature?.name
667
+ ] })
668
+ ] }),
669
+ /* @__PURE__ */ jsx3(
670
+ Button,
671
+ {
672
+ onClick: handleSave,
673
+ className: "au-w-14 !au-h-7 au-text-sm au-items-center au-bg-white au-text-foreground au-shadow-sm au-border au-border-zinc-200 hover:au-bg-zinc-100",
674
+ disabled: loading,
675
+ children: loading ? /* @__PURE__ */ jsx3(LoaderCircle, { className: "au-text-muted-foreground au-animate-spin !au-w-4 !au-h-4" }) : "Save"
676
+ }
677
+ )
678
+ ] })
679
+ ]
680
+ }
681
+ )
682
+ ] })
683
+ ] }),
684
+ /* @__PURE__ */ jsxs3("p", { children: [
685
+ item.display?.primary_text,
686
+ " ",
687
+ item.display?.secondary_text
688
+ ] })
689
+ ] });
690
+ };
691
+ var PriceItem = ({
692
+ children,
693
+ className,
694
+ ...props
695
+ }) => {
696
+ return /* @__PURE__ */ jsx3(
697
+ "div",
698
+ {
699
+ className: cn(
700
+ "au-flex au-flex-col au-pb-4 sm:au-pb-0 au-gap-1 sm:au-flex-row au-justify-between sm:au-h-7 sm:au-gap-2 sm:au-items-center",
701
+ className
702
+ ),
703
+ ...props,
704
+ children
705
+ }
706
+ );
707
+ };
708
+ var PricingDialogButton = ({
709
+ children,
710
+ size,
711
+ onClick,
712
+ disabled,
713
+ className
714
+ }) => {
715
+ return /* @__PURE__ */ jsxs3(
716
+ Button,
717
+ {
718
+ onClick,
719
+ disabled,
720
+ size,
721
+ className: cn(className, "au-shadow-sm au-shadow-stone-400"),
722
+ children: [
723
+ children,
724
+ /* @__PURE__ */ jsx3(ArrowRight, { className: "!au-h-3" })
725
+ ]
726
+ }
727
+ );
728
+ };
727
729
 
728
730
  export {
731
+ CheckoutDialog,
732
+ PriceItem,
733
+ PricingDialogButton,
729
734
  PaywallDialog,
730
735
  PricingTable,
731
736
  usePricingTableContext,
@@ -734,8 +739,5 @@ export {
734
739
  PricingFeatureList,
735
740
  PricingCardButton,
736
741
  AnnualSwitch,
737
- RecommendedBadge,
738
- CheckoutDialog,
739
- PriceItem,
740
- PricingDialogButton
742
+ RecommendedBadge
741
743
  };