autumn-js 0.1.49 → 0.1.51-beta.0

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