@solvimon/solvimon-web 0.1.0-alpha.1 → 0.1.0-alpha.3

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 (135) hide show
  1. package/README.md +5 -5
  2. package/dist/{BillingInformation.vue_vue_type_script_setup_true_lang-VMlVPI4O.js → BillingInformation.vue_vue_type_script_setup_true_lang-BD3CrJzj.js} +1 -1
  3. package/dist/{BillingInformation.vue_vue_type_script_setup_true_lang-B42EzZ97.mjs → BillingInformation.vue_vue_type_script_setup_true_lang-DQAp1xwu.mjs} +2 -2
  4. package/dist/{ContentWithAsideLayout-BC-C5Gjt.mjs → ContentWithAsideLayout-CRsFr9TH.mjs} +1 -1
  5. package/dist/{ContentWithAsideLayout-CIVSoqFr.js → ContentWithAsideLayout-DczcgSrt.js} +1 -1
  6. package/dist/{InvoiceDetailsBlock.vue_vue_type_script_setup_true_lang-t6E9_dWJ.js → InvoiceDetailsBlock.vue_vue_type_script_setup_true_lang-BE3I7Oe1.js} +1 -1
  7. package/dist/{InvoiceDetailsBlock.vue_vue_type_script_setup_true_lang-5yBnSRap.mjs → InvoiceDetailsBlock.vue_vue_type_script_setup_true_lang-D0ie9Krt.mjs} +1 -1
  8. package/dist/{PaymentHistoryBlock.vue_vue_type_script_setup_true_lang-CknZKCmY.mjs → PaymentHistoryBlock.vue_vue_type_script_setup_true_lang-DVDOsMnT.mjs} +1 -1
  9. package/dist/{PaymentHistoryBlock.vue_vue_type_script_setup_true_lang-8UxAr2hU.js → PaymentHistoryBlock.vue_vue_type_script_setup_true_lang-sNdlKgdU.js} +1 -1
  10. package/dist/{PaymentIntegrationForm.vue_vue_type_script_setup_true_lang-BCdv5DbH.mjs → PaymentIntegrationForm.vue_vue_type_script_setup_true_lang-DJEZEEwZ.mjs} +5 -5
  11. package/dist/PaymentIntegrationForm.vue_vue_type_script_setup_true_lang-Sn1Jq19s.js +1 -0
  12. package/dist/PricingGroupContent.vue_vue_type_script_setup_true_lang-Bifo4jTH.js +1 -0
  13. package/dist/PricingGroupContent.vue_vue_type_script_setup_true_lang-DWp42_G4.mjs +75 -0
  14. package/dist/{Skeleton.vue_vue_type_script_setup_true_lang-BFFJw-5h.mjs → Skeleton.vue_vue_type_script_setup_true_lang-C-taYlG4.mjs} +5 -4
  15. package/dist/Skeleton.vue_vue_type_script_setup_true_lang-C_BwMlBE.js +1 -0
  16. package/dist/{SubscriptionsList.vue_vue_type_script_setup_true_lang-DfB5BqiH.mjs → SubscriptionsList.vue_vue_type_script_setup_true_lang-Bp5RvQVS.mjs} +5 -5
  17. package/dist/{SubscriptionsList.vue_vue_type_script_setup_true_lang-DqZLFDCv.js → SubscriptionsList.vue_vue_type_script_setup_true_lang-yyhwzYSM.js} +1 -1
  18. package/dist/auto-DzZuCneB.mjs +14387 -0
  19. package/dist/auto-PpnAChnH.js +6 -0
  20. package/dist/{cloneDeep-Hs8Pp07F.js → cloneDeep-DranHQkY.js} +1 -1
  21. package/dist/{component-BkmcE85U.mjs → component-DEo_ndpK.mjs} +92 -78
  22. package/dist/component-XHQYFLA_.js +1 -0
  23. package/dist/components/BillingInformation/BillingInformation.ce.d.ts +1 -1
  24. package/dist/components/BillingInformation/BillingInformation.cjs.js +1 -1
  25. package/dist/components/BillingInformation/BillingInformation.es.js +96 -5
  26. package/dist/components/BillingInformationForm/BillingInformationForm.ce.d.ts +1 -1
  27. package/dist/components/BillingInformationForm/BillingInformationForm.cjs.js +1 -1
  28. package/dist/components/BillingInformationForm/BillingInformationForm.es.js +582 -5
  29. package/dist/components/CustomerPaymentMethods/CustomerPaymentMethods.ce.d.ts +1 -1
  30. package/dist/components/CustomerPaymentMethods/CustomerPaymentMethods.cjs.js +1 -1
  31. package/dist/components/CustomerPaymentMethods/CustomerPaymentMethods.es.js +132 -5
  32. package/dist/components/Invoice/Invoice.ce.d.ts +1 -1
  33. package/dist/components/Invoice/Invoice.cjs.js +1 -1
  34. package/dist/components/Invoice/Invoice.es.js +580 -5
  35. package/dist/components/InvoiceDetails/InvoiceDetails.ce.d.ts +1 -1
  36. package/dist/components/InvoiceDetails/InvoiceDetails.cjs.js +1 -1
  37. package/dist/components/InvoiceDetails/InvoiceDetails.es.js +127 -5
  38. package/dist/components/InvoicesList/InvoicesList.ce.d.ts +1 -1
  39. package/dist/components/InvoicesList/InvoicesList.cjs.js +1 -1
  40. package/dist/components/InvoicesList/InvoicesList.es.js +102 -5
  41. package/dist/components/PaymentHistory/PaymentHistory.ce.d.ts +1 -1
  42. package/dist/components/PaymentHistory/PaymentHistory.cjs.js +1 -1
  43. package/dist/components/PaymentHistory/PaymentHistory.es.js +131 -5
  44. package/dist/components/PaymentMethodForm/PaymentMethodForm.ce.d.ts +1 -1
  45. package/dist/components/PaymentMethodForm/PaymentMethodForm.cjs.js +1 -1
  46. package/dist/components/PaymentMethodForm/PaymentMethodForm.es.js +236 -5
  47. package/dist/components/SubscriptionSchedules/SubscriptionSchedules.ce.d.ts +1 -1
  48. package/dist/components/SubscriptionSchedules/SubscriptionSchedules.cjs.js +1 -1
  49. package/dist/components/SubscriptionSchedules/SubscriptionSchedules.es.js +150 -5
  50. package/dist/components/SubscriptionsList/SubscriptionsList.ce.d.ts +1 -1
  51. package/dist/components/SubscriptionsList/SubscriptionsList.cjs.js +1 -1
  52. package/dist/components/SubscriptionsList/SubscriptionsList.es.js +132 -5
  53. package/dist/components/WalletBalances/WalletBalances.ce.d.ts +3 -0
  54. package/dist/components/WalletBalances/WalletBalances.cjs.js +1 -0
  55. package/dist/{InvoiceDetails.entry.ce-Cnpz8CLJ.mjs → components/WalletBalances/WalletBalances.es.js} +41 -51
  56. package/dist/core/configuration.d.ts +2 -1
  57. package/dist/core/index.cjs.js +1 -1
  58. package/dist/core/index.es.js +1 -1
  59. package/dist/core/registry.d.ts +1 -1
  60. package/dist/core/types.d.ts +4 -0
  61. package/dist/index.cjs.js +1 -1
  62. package/dist/index.d.ts +2 -0
  63. package/dist/index.es.js +40 -34
  64. package/dist/invoices-BW1notiX.js +1 -0
  65. package/dist/{invoices-C31Wz1Bu.mjs → invoices-M5oYVch6.mjs} +1 -1
  66. package/dist/{paymentMethods-CzUqDlvc.js → paymentMethods-BX80t2zk.js} +1 -1
  67. package/dist/{paymentMethods-CrU4G_2Y.mjs → paymentMethods-CqKUfc3w.mjs} +1 -1
  68. package/dist/{payments-C3LPk9k9.js → payments-BHv4hCeJ.js} +1 -1
  69. package/dist/{payments-NtWI8KlU.mjs → payments-CosaPZwo.mjs} +1 -1
  70. package/dist/registry-BwKEYOf7.js +1 -0
  71. package/dist/registry-Cag1Jj7P.mjs +143 -0
  72. package/dist/screens/Checkout/Checkout.ce.d.ts +1 -1
  73. package/dist/screens/Checkout/Checkout.cjs.js +1 -1
  74. package/dist/screens/Checkout/Checkout.es.js +5140 -5
  75. package/dist/screens/CustomerOverview/CustomerOverview.ce.d.ts +1 -1
  76. package/dist/screens/CustomerOverview/CustomerOverview.cjs.js +1 -1
  77. package/dist/screens/CustomerOverview/CustomerOverview.es.js +134 -5
  78. package/dist/screens/UpgradeSubscription/UpgradeSubscription.ce.d.ts +3 -0
  79. package/dist/screens/UpgradeSubscription/UpgradeSubscription.cjs.js +1 -0
  80. package/dist/screens/UpgradeSubscription/UpgradeSubscription.es.js +1012 -0
  81. package/dist/{subscriptions-3R7aMoky.mjs → subscriptions-Bs4DIE8f.mjs} +1 -1
  82. package/dist/{subscriptions-CqK7t-fF.js → subscriptions-CnxvsBXd.js} +1 -1
  83. package/dist/{useActionDispatchProvider-CBo_Hwu5.mjs → useActionDispatchProvider-CgRcOqv3.mjs} +1 -1
  84. package/dist/useActionDispatchProvider-Cru69mAl.js +1 -0
  85. package/dist/{useCustomer-Dp8sGHI0.js → useCustomer-B0NK96dA.js} +1 -1
  86. package/dist/{useCustomer-BRY0tuBH.mjs → useCustomer-DlcjY3fP.mjs} +2 -2
  87. package/dist/{useCustomerPaymentMethodOptions-Fe_dLxfv.mjs → useCustomerPaymentMethodOptions-BzEquyUV.mjs} +7 -6
  88. package/dist/{useCustomerPaymentMethodOptions-DYpMDnJR.js → useCustomerPaymentMethodOptions-C-8BLzqb.js} +1 -1
  89. package/dist/{useIncrementalLoading-fHCizCSo.mjs → useIncrementalLoading-C7ToTmZK.mjs} +9 -7
  90. package/dist/useIncrementalLoading-D60Vttil.js +1 -0
  91. package/dist/{useInvoiceData-dyvoDwFF.mjs → useInvoiceData-CcueV3We.mjs} +2 -2
  92. package/dist/{useInvoiceData-DImEH1ca.js → useInvoiceData-DstXfI7t.js} +1 -1
  93. package/dist/{useInvoicesList-rDvRzMqe.mjs → useInvoicesList-CXng3aUm.mjs} +4 -4
  94. package/dist/{useInvoicesList-BZQ9Y0qN.js → useInvoicesList-DmzjgMlW.js} +1 -1
  95. package/dist/{usePaymentMethods-Dbimodf0.js → usePaymentMethods-DCGVRXA4.js} +1 -1
  96. package/dist/{usePaymentMethods-Bq5fWl1Q.mjs → usePaymentMethods-Db-1R6rI.mjs} +2 -2
  97. package/dist/{useService-Dz13Nxbi.mjs → useService-B4qv5N2D.mjs} +14 -5
  98. package/dist/useService-D-CUtlp3.js +1 -0
  99. package/dist/useWalletBalanceItems-BZyiAhcV.js +1 -0
  100. package/dist/useWalletBalanceItems-CHkLaccm.mjs +105 -0
  101. package/package.json +16 -3
  102. package/dist/BillingInformation.entry.ce-1xVdsWlL.mjs +0 -99
  103. package/dist/BillingInformation.entry.ce-DkrfEvK_.js +0 -1
  104. package/dist/BillingInformationForm.entry.ce-MPMirEsk.js +0 -1
  105. package/dist/BillingInformationForm.entry.ce-xfT0Jqps.mjs +0 -579
  106. package/dist/Checkout.entry.ce-Bif6vR1K.mjs +0 -5185
  107. package/dist/Checkout.entry.ce-CkQnLAn4.js +0 -1
  108. package/dist/CustomerOverview.entry.ce-C__omsVl.js +0 -1
  109. package/dist/CustomerOverview.entry.ce-Ce_Yk8-i.mjs +0 -231
  110. package/dist/CustomerPaymentMethods.entry.ce-CZwy8Aqq.mjs +0 -135
  111. package/dist/CustomerPaymentMethods.entry.ce-DnjlRHPA.js +0 -1
  112. package/dist/Invoice.entry.ce-CdJ9TPZe.mjs +0 -583
  113. package/dist/Invoice.entry.ce-Cgr43ome.js +0 -1
  114. package/dist/InvoiceDetails.entry.ce-jHDyWra2.js +0 -1
  115. package/dist/InvoicesList.entry.ce-38iOW5qh.js +0 -1
  116. package/dist/InvoicesList.entry.ce-BBaHEtAD.mjs +0 -105
  117. package/dist/PaymentHistory.entry.ce-DDeHMhK_.js +0 -1
  118. package/dist/PaymentHistory.entry.ce-Dw2NiP4l.mjs +0 -134
  119. package/dist/PaymentIntegrationForm.vue_vue_type_script_setup_true_lang-xJ8kJbRo.js +0 -1
  120. package/dist/PaymentMethodForm.entry.ce-f4cFExKc.mjs +0 -238
  121. package/dist/PaymentMethodForm.entry.ce-zxeBXZW6.js +0 -1
  122. package/dist/Skeleton.vue_vue_type_script_setup_true_lang-CQqTurIt.js +0 -1
  123. package/dist/SubscriptionSchedules.entry.ce-B4T_yQC1.js +0 -1
  124. package/dist/SubscriptionSchedules.entry.ce-B4vQ7QLk.mjs +0 -153
  125. package/dist/SubscriptionsList.entry.ce-B5SJCQW0.js +0 -1
  126. package/dist/SubscriptionsList.entry.ce-cNYuQZZj.mjs +0 -135
  127. package/dist/auto-B_36W1Fc.js +0 -6
  128. package/dist/auto-BfMZdgp-.mjs +0 -14207
  129. package/dist/component-Df5eNqYX.js +0 -1
  130. package/dist/invoices-8M_3ur_U.js +0 -1
  131. package/dist/registry-By94DXE2.js +0 -1
  132. package/dist/registry-shRKDl3K.mjs +0 -127
  133. package/dist/useActionDispatchProvider-DsIljrhi.js +0 -1
  134. package/dist/useIncrementalLoading-D8oKNxX7.js +0 -1
  135. package/dist/useService-bNNi4GB8.js +0 -1
@@ -0,0 +1,1012 @@
1
+ import { defineComponent, computed, openBlock, createBlock, unref, withCtx, createVNode, createTextVNode, toDisplayString, createElementBlock, Fragment, createElementVNode, renderList, createCommentVNode, normalizeClass, ref, onMounted, watch } from "vue";
2
+ import { b as useIntl, d as _sfc_main$1g, _ as _sfc_main$2$1, O as formatAmount, m as _sfc_main$2H, g as _sfc_main$7, c as createRequestService, u as useConfig, n as _sfc_main$4$1, D as _sfc_main$16, Q as _sfc_main$2p, p as _sfc_main$9, q as defineCustomElement, o as getComponentName } from "../../component-DEo_ndpK.mjs";
3
+ import { _ as _sfc_main$6, a as _sfc_main$8 } from "../../PricingGroupContent.vue_vue_type_script_setup_true_lang-DWp42_G4.mjs";
4
+ import { c as createPaymentMethodsService } from "../../paymentMethods-CqKUfc3w.mjs";
5
+ import { u as usePortal, C as ContentWithAsideLayout } from "../../ContentWithAsideLayout-CRsFr9TH.mjs";
6
+ import { u as useActionDispatchProvider } from "../../useActionDispatchProvider-CgRcOqv3.mjs";
7
+ const mockSubscriptionGetResponse = {
8
+ id: "ppsu_hwDeeN0vhvcVCsAIdp1G",
9
+ pricing_plan_schedule_infos: [
10
+ {
11
+ id: "ppsc_IwDeeN0vhvcVCIAQdq1a",
12
+ pricing_plan_version_id: "ppve_MwDeeN0vhvcEuaADdd1f",
13
+ start_at: "2026-04-05T22:00:00Z",
14
+ pricing_plan_version: {
15
+ pricing_categories: [
16
+ {
17
+ product_category: {
18
+ id: "proc_iwDeeN0vhphn6VAtBD1w",
19
+ name: "Add ons"
20
+ },
21
+ display_order: 1,
22
+ pricings: [
23
+ {
24
+ id: "pric_ywDeeN0vhvcPguAadr1V",
25
+ name: "Integration setup",
26
+ products: [{ name: "Integration setup" }],
27
+ items: [
28
+ {
29
+ id: "prii_NwDeeN0vhvcPguAxds12",
30
+ product_items: [
31
+ {
32
+ name: "Rillet integration setup",
33
+ model_type: "ONE_OFF"
34
+ }
35
+ ],
36
+ configs: [
37
+ {
38
+ on_demand: true,
39
+ bands: [
40
+ {
41
+ fixed_amount: {
42
+ quantity: "5000.00",
43
+ currency: "EUR"
44
+ }
45
+ }
46
+ ]
47
+ }
48
+ ]
49
+ },
50
+ {
51
+ id: "prii_IwDeeN0vhvcPgvAsdS1Q",
52
+ product_items: [
53
+ {
54
+ name: "Attio integration setup",
55
+ model_type: "ONE_OFF"
56
+ }
57
+ ],
58
+ configs: [
59
+ {
60
+ on_demand: true,
61
+ // FLAT type: price is in `amount`, not `fixed_amount`
62
+ bands: [
63
+ {
64
+ amount: {
65
+ quantity: "50000.00",
66
+ currency: "EUR"
67
+ }
68
+ }
69
+ ]
70
+ }
71
+ ]
72
+ }
73
+ ]
74
+ }
75
+ ],
76
+ pricing_groups: []
77
+ }
78
+ ]
79
+ }
80
+ }
81
+ ]
82
+ };
83
+ const isOnDemandOneOffItem = (item) => {
84
+ var _a, _b;
85
+ return (((_a = item.configs) == null ? void 0 : _a.some((c) => c.on_demand)) ?? false) && (((_b = item.product_items) == null ? void 0 : _b.some((pi) => pi.model_type === "ONE_OFF")) ?? false);
86
+ };
87
+ const itemToRow = (item) => {
88
+ var _a, _b;
89
+ return {
90
+ id: item.id,
91
+ name: (_b = (_a = item.product_items) == null ? void 0 : _a[0]) == null ? void 0 : _b.name,
92
+ items: [
93
+ {
94
+ id: item.id,
95
+ configs: (item.configs ?? []).map((config) => ({
96
+ bands: (config.bands ?? []).map((band) => ({
97
+ fixed_amount: band.fixed_amount ?? band.amount
98
+ }))
99
+ }))
100
+ }
101
+ ]
102
+ };
103
+ };
104
+ const pricingToRows = (pricing) => (pricing.items ?? []).filter(isOnDemandOneOffItem).map(itemToRow);
105
+ const categoryToOnDemand = (category) => ({
106
+ display_order: category.display_order,
107
+ product_category: category.product_category,
108
+ pricings: (category.pricings ?? []).flatMap(pricingToRows),
109
+ pricing_groups: (category.pricing_groups ?? []).map((group) => ({
110
+ id: group.id,
111
+ name: group.name,
112
+ pricings: (group.pricings ?? []).flatMap(pricingToRows)
113
+ })).filter((g) => g.pricings.length > 0)
114
+ });
115
+ const ITEM_PRICES_EUR = Object.fromEntries(
116
+ mockSubscriptionGetResponse.pricing_plan_schedule_infos.flatMap((s) => s.pricing_plan_version.pricing_categories).flatMap((cat) => cat.pricings).flatMap((p) => p.items).filter(isOnDemandOneOffItem).map((item) => {
117
+ var _a, _b, _c, _d, _e;
118
+ const band = (_c = (_b = (_a = item.configs) == null ? void 0 : _a[0]) == null ? void 0 : _b.bands) == null ? void 0 : _c[0];
119
+ const raw = ((_d = band == null ? void 0 : band.fixed_amount) == null ? void 0 : _d.quantity) ?? ((_e = band == null ? void 0 : band.amount) == null ? void 0 : _e.quantity) ?? "0";
120
+ return [item.id, parseFloat(raw)];
121
+ })
122
+ );
123
+ const VAT_RATE = 0.21;
124
+ const eur = (amount) => ({ quantity: amount.toFixed(2), currency: "EUR" });
125
+ const mockPaymentAcceptor = {
126
+ id: "paya_NwDeeN0vgXgeP1AyNx14",
127
+ object_type: "PAYMENT_ACCEPTOR",
128
+ status: "ACTIVE",
129
+ reference: "mock-payment-acceptor",
130
+ name: "Mock payment acceptor",
131
+ type: "PAYMENT_GATEWAY"
132
+ };
133
+ const mockPaymentIntegration = {
134
+ id: "intg_zwDeeN0vgXgeM6APNW1g",
135
+ object_type: "INTEGRATION",
136
+ reference: "mock-payment-integration",
137
+ name: "Mock payment integration",
138
+ description: "Mock payment integration",
139
+ status: "ACTIVE",
140
+ type: "PAYMENT_GATEWAY"
141
+ };
142
+ const getMockPreviewResponse = (selectedItemIds) => {
143
+ const base = selectedItemIds.reduce((sum, id) => sum + (ITEM_PRICES_EUR[id] ?? 0), 0);
144
+ const tax = Math.round(base * VAT_RATE * 100) / 100;
145
+ const total = base + tax;
146
+ return {
147
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
148
+ invoice: {
149
+ tax_summary: {
150
+ base_amount: eur(base),
151
+ tax_amount: eur(tax),
152
+ total_amount: eur(total),
153
+ country_code: "NL"
154
+ }
155
+ },
156
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
157
+ first_invoice: {},
158
+ invoice_infos: []
159
+ };
160
+ };
161
+ const getMockOnDemandPricingItemsResponse = (subscriptionId) => {
162
+ var _a;
163
+ const now = Date.now();
164
+ const schedules = mockSubscriptionGetResponse.pricing_plan_schedule_infos;
165
+ const activeSchedule = schedules.find((s) => {
166
+ const start = Date.parse(s.start_at);
167
+ return Number.isFinite(start) && start <= now;
168
+ }) ?? schedules[0];
169
+ const categories = (((_a = activeSchedule == null ? void 0 : activeSchedule.pricing_plan_version) == null ? void 0 : _a.pricing_categories) ?? []).map(categoryToOnDemand).filter((c) => {
170
+ var _a2, _b;
171
+ return (((_a2 = c.pricings) == null ? void 0 : _a2.length) ?? 0) > 0 || (((_b = c.pricing_groups) == null ? void 0 : _b.length) ?? 0) > 0;
172
+ });
173
+ return {
174
+ pricing_plan_subscription_id: subscriptionId || mockSubscriptionGetResponse.id,
175
+ pricing_plan_schedule_id: (activeSchedule == null ? void 0 : activeSchedule.id) ?? "",
176
+ pricing_plan_version_id: (activeSchedule == null ? void 0 : activeSchedule.pricing_plan_version_id) ?? "",
177
+ billing_period: { type: "MONTH", value: 1 },
178
+ billing_currency: "EUR",
179
+ pricing_categories: categories
180
+ };
181
+ };
182
+ const getMockPaymentMethodOptionsResponse = () => [
183
+ {
184
+ payment_acceptor: mockPaymentAcceptor,
185
+ integration: mockPaymentIntegration,
186
+ options: [
187
+ {
188
+ name: "iDeal",
189
+ payment_method_variant: "ONLINE_BANKING",
190
+ payment_gateway_variant: "ADYEN",
191
+ adyen: { name: "iDEAL | Wero", type: "ideal" }
192
+ },
193
+ {
194
+ name: "Cards",
195
+ payment_method_variant: "CARD",
196
+ payment_gateway_variant: "ADYEN",
197
+ adyen: {
198
+ name: "Cards",
199
+ type: "scheme",
200
+ brands: [
201
+ "maestro",
202
+ "accel",
203
+ "amex",
204
+ "cup",
205
+ "diners",
206
+ "hipercard",
207
+ "jcb",
208
+ "mc",
209
+ "nyce",
210
+ "pulse",
211
+ "star",
212
+ "visa"
213
+ ]
214
+ }
215
+ },
216
+ {
217
+ name: "PayPal",
218
+ payment_method_variant: "DIGITAL_WALLET",
219
+ payment_gateway_variant: "ADYEN",
220
+ adyen: { name: "PayPal", type: "paypal", configuration: { intent: "capture" } }
221
+ },
222
+ {
223
+ name: "Trustly",
224
+ payment_method_variant: "ONLINE_BANKING",
225
+ payment_gateway_variant: "ADYEN",
226
+ adyen: { name: "Trustly - Instant Bank Payment", type: "trustly" }
227
+ }
228
+ ]
229
+ }
230
+ ];
231
+ const _hoisted_1$3 = { class: "mb-3 flex flex-col gap-2" };
232
+ const _hoisted_2$2 = { class: "flex flex-col gap-1 border-t pt-3" };
233
+ const _hoisted_3$1 = { class: "flex items-center justify-between" };
234
+ const _hoisted_4$1 = { class: "flex items-center justify-between" };
235
+ const _hoisted_5$1 = { class: "flex items-center justify-between border-t pt-3" };
236
+ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
237
+ __name: "UpgradeOrderSummary",
238
+ props: {
239
+ selectedPricings: { type: Array },
240
+ invoice: { type: Object },
241
+ isPending: { type: Boolean }
242
+ },
243
+ setup(__props) {
244
+ const props = __props;
245
+ const { $t } = useIntl();
246
+ const isEmpty = computed(() => props.selectedPricings.length === 0);
247
+ const getPrice = (pricing) => {
248
+ var _a, _b, _c, _d, _e, _f;
249
+ return (_f = (_e = (_d = (_c = (_b = (_a = pricing.items) == null ? void 0 : _a[0]) == null ? void 0 : _b.configs) == null ? void 0 : _c[0]) == null ? void 0 : _d.bands) == null ? void 0 : _e[0]) == null ? void 0 : _f.fixed_amount;
250
+ };
251
+ return (_ctx, _cache) => {
252
+ return openBlock(), createBlock(unref(_sfc_main$1g), null, {
253
+ default: withCtx(() => {
254
+ var _a;
255
+ return [
256
+ createVNode(unref(_sfc_main$2$1), {
257
+ variant: "heading-3",
258
+ tag: "h2",
259
+ class: "mb-3"
260
+ }, {
261
+ default: withCtx(() => [
262
+ createTextVNode(toDisplayString(unref($t)({
263
+ defaultMessage: "Order summary",
264
+ id: "upgrade_subscription.order_summary.title",
265
+ description: "Title for the order summary section on the upgrade subscription page"
266
+ })), 1)
267
+ ]),
268
+ _: 1
269
+ }),
270
+ isEmpty.value ? (openBlock(), createBlock(unref(_sfc_main$2$1), {
271
+ key: 0,
272
+ variant: "body-sm",
273
+ shade: "lighter"
274
+ }, {
275
+ default: withCtx(() => [
276
+ createTextVNode(toDisplayString(unref($t)({
277
+ defaultMessage: "Select add-ons to see pricing.",
278
+ id: "upgrade_subscription.order_summary.empty_state",
279
+ description: "Placeholder shown when no add-ons are selected in the order summary"
280
+ })), 1)
281
+ ]),
282
+ _: 1
283
+ })) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [
284
+ createElementVNode("div", _hoisted_1$3, [
285
+ (openBlock(true), createElementBlock(Fragment, null, renderList(__props.selectedPricings, (pricing) => {
286
+ return openBlock(), createElementBlock("div", {
287
+ key: pricing.id,
288
+ class: "flex items-center justify-between"
289
+ }, [
290
+ createElementVNode("div", null, [
291
+ createVNode(unref(_sfc_main$2$1), { variant: "body-sm" }, {
292
+ default: withCtx(() => {
293
+ var _a2, _b;
294
+ return [
295
+ createTextVNode(toDisplayString(pricing.name ?? ((_b = (_a2 = pricing.products) == null ? void 0 : _a2[0]) == null ? void 0 : _b.name)), 1)
296
+ ];
297
+ }),
298
+ _: 2
299
+ }, 1024),
300
+ createVNode(unref(_sfc_main$2$1), {
301
+ variant: "body-xs",
302
+ shade: "lighter"
303
+ }, {
304
+ default: withCtx(() => [
305
+ createTextVNode(toDisplayString(unref($t)({
306
+ defaultMessage: "one-off",
307
+ id: "upgrade_subscription.order_summary.one_off_label",
308
+ description: "One-off payment label next to a line item in order summary"
309
+ })), 1)
310
+ ]),
311
+ _: 1
312
+ })
313
+ ]),
314
+ getPrice(pricing) ? (openBlock(), createBlock(unref(_sfc_main$2$1), {
315
+ key: 0,
316
+ variant: "body-sm"
317
+ }, {
318
+ default: withCtx(() => [
319
+ createTextVNode(toDisplayString(unref(formatAmount)(getPrice(pricing))), 1)
320
+ ]),
321
+ _: 2
322
+ }, 1024)) : createCommentVNode("", true)
323
+ ]);
324
+ }), 128))
325
+ ]),
326
+ ((_a = __props.invoice) == null ? void 0 : _a.tax_summary) ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
327
+ createElementVNode("div", _hoisted_2$2, [
328
+ createElementVNode("div", _hoisted_3$1, [
329
+ createVNode(unref(_sfc_main$2$1), {
330
+ variant: "body-sm",
331
+ shade: "lighter"
332
+ }, {
333
+ default: withCtx(() => [
334
+ createTextVNode(toDisplayString(unref($t)({
335
+ defaultMessage: "Total excluding taxes",
336
+ id: "upgrade_subscription.order_summary.subtotal_label",
337
+ description: "Subtotal before tax label in order summary"
338
+ })), 1)
339
+ ]),
340
+ _: 1
341
+ }),
342
+ createVNode(unref(_sfc_main$2$1), { variant: "body-sm" }, {
343
+ default: withCtx(() => [
344
+ createTextVNode(toDisplayString(unref(formatAmount)(__props.invoice.tax_summary.base_amount)), 1)
345
+ ]),
346
+ _: 1
347
+ })
348
+ ]),
349
+ createElementVNode("div", _hoisted_4$1, [
350
+ createVNode(unref(_sfc_main$2$1), {
351
+ variant: "body-sm",
352
+ shade: "lighter"
353
+ }, {
354
+ default: withCtx(() => [
355
+ createTextVNode(toDisplayString(unref($t)({
356
+ defaultMessage: "Taxes",
357
+ id: "upgrade_subscription.order_summary.taxes_label",
358
+ description: "Tax amount label in order summary"
359
+ })), 1)
360
+ ]),
361
+ _: 1
362
+ }),
363
+ createVNode(unref(_sfc_main$2$1), { variant: "body-sm" }, {
364
+ default: withCtx(() => [
365
+ createTextVNode(toDisplayString(unref(formatAmount)(__props.invoice.tax_summary.tax_amount)), 1)
366
+ ]),
367
+ _: 1
368
+ })
369
+ ])
370
+ ]),
371
+ createElementVNode("div", _hoisted_5$1, [
372
+ createVNode(unref(_sfc_main$2$1), {
373
+ variant: "body-sm",
374
+ weight: "semibold"
375
+ }, {
376
+ default: withCtx(() => [
377
+ createTextVNode(toDisplayString(unref($t)({
378
+ defaultMessage: "Total due today",
379
+ id: "upgrade_subscription.order_summary.total_label",
380
+ description: "Total amount due today label in order summary"
381
+ })), 1)
382
+ ]),
383
+ _: 1
384
+ }),
385
+ createVNode(unref(_sfc_main$2$1), {
386
+ variant: "body-sm",
387
+ weight: "semibold"
388
+ }, {
389
+ default: withCtx(() => [
390
+ createTextVNode(toDisplayString(unref(formatAmount)(__props.invoice.tax_summary.total_amount)), 1)
391
+ ]),
392
+ _: 1
393
+ })
394
+ ])
395
+ ], 64)) : createCommentVNode("", true)
396
+ ], 64))
397
+ ];
398
+ }),
399
+ _: 1
400
+ });
401
+ };
402
+ }
403
+ });
404
+ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
405
+ __name: "OnDemandPricingRow",
406
+ props: {
407
+ pricing: { type: Object },
408
+ selected: { type: Boolean }
409
+ },
410
+ emits: ["toggle"],
411
+ setup(__props, { emit: __emit }) {
412
+ const props = __props;
413
+ const emit = __emit;
414
+ const { $t } = useIntl();
415
+ const title = computed(() => {
416
+ var _a, _b;
417
+ return props.pricing.name ?? ((_b = (_a = props.pricing.products) == null ? void 0 : _a[0]) == null ? void 0 : _b.name) ?? "—";
418
+ });
419
+ const price = computed(() => {
420
+ var _a, _b, _c, _d, _e, _f;
421
+ return (_f = (_e = (_d = (_c = (_b = (_a = props.pricing.items) == null ? void 0 : _a[0]) == null ? void 0 : _b.configs) == null ? void 0 : _c[0]) == null ? void 0 : _d.bands) == null ? void 0 : _e[0]) == null ? void 0 : _f.fixed_amount;
422
+ });
423
+ const description = computed(
424
+ () => price.value ? `${formatAmount(price.value)} ${$t({
425
+ defaultMessage: "one-off",
426
+ id: "on_demand_pricing_row.one_off_label",
427
+ description: "One-off label shown next to the price in an on-demand pricing row"
428
+ })}` : ""
429
+ );
430
+ return (_ctx, _cache) => {
431
+ return openBlock(), createBlock(unref(_sfc_main$1g), {
432
+ "content-background": __props.selected ? "none" : "gray",
433
+ class: normalizeClass({ "!bg-white": __props.selected })
434
+ }, {
435
+ default: withCtx(() => [
436
+ createVNode(_sfc_main$6, {
437
+ name: title.value,
438
+ description: description.value
439
+ }, {
440
+ default: withCtx(() => [
441
+ __props.selected ? (openBlock(), createBlock(unref(_sfc_main$2H), {
442
+ key: 0,
443
+ color: "gray",
444
+ variant: "outline",
445
+ size: "sm",
446
+ "icon-prefix": "remove_shopping_cart",
447
+ onClick: _cache[0] || (_cache[0] = ($event) => emit("toggle", __props.pricing.id))
448
+ }, {
449
+ default: withCtx(() => [
450
+ createTextVNode(toDisplayString(unref($t)({
451
+ defaultMessage: "Remove",
452
+ id: "on_demand_pricing_row.remove_button_label",
453
+ description: "Label for the remove button in an on-demand pricing row"
454
+ })), 1)
455
+ ]),
456
+ _: 1
457
+ })) : (openBlock(), createBlock(unref(_sfc_main$2H), {
458
+ key: 1,
459
+ color: "primary",
460
+ size: "sm",
461
+ "icon-prefix": "add",
462
+ onClick: _cache[1] || (_cache[1] = ($event) => emit("toggle", __props.pricing.id))
463
+ }, {
464
+ default: withCtx(() => [
465
+ createTextVNode(toDisplayString(unref($t)({
466
+ defaultMessage: "Add to cart",
467
+ id: "on_demand_pricing_row.add_to_cart_button_label",
468
+ description: "Label for the add to cart button in an on-demand pricing row"
469
+ })), 1)
470
+ ]),
471
+ _: 1
472
+ }))
473
+ ]),
474
+ _: 1
475
+ }, 8, ["name", "description"])
476
+ ]),
477
+ _: 1
478
+ }, 8, ["content-background", "class"]);
479
+ };
480
+ }
481
+ });
482
+ const _hoisted_1$2 = { class: "grid grid-cols-1 gap-1" };
483
+ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
484
+ __name: "OnDemandPricingList",
485
+ props: {
486
+ categories: { type: Array },
487
+ selectedPricingIds: { type: Array }
488
+ },
489
+ emits: ["toggle"],
490
+ setup(__props, { emit: __emit }) {
491
+ const props = __props;
492
+ const emit = __emit;
493
+ const sortedCategories = computed(
494
+ () => [...props.categories].sort((a, b) => (a.display_order ?? 0) - (b.display_order ?? 0))
495
+ );
496
+ return (_ctx, _cache) => {
497
+ return openBlock(true), createElementBlock(Fragment, null, renderList(sortedCategories.value, (category) => {
498
+ return openBlock(), createElementBlock("div", {
499
+ key: category.id ?? category.display_order,
500
+ class: "flex flex-col gap-2"
501
+ }, [
502
+ createVNode(unref(_sfc_main$2$1), {
503
+ variant: "heading-3",
504
+ tag: "h2"
505
+ }, {
506
+ default: withCtx(() => {
507
+ var _a;
508
+ return [
509
+ createTextVNode(toDisplayString(((_a = category.product_category) == null ? void 0 : _a.name) ?? category.name), 1)
510
+ ];
511
+ }),
512
+ _: 2
513
+ }, 1024),
514
+ createElementVNode("div", _hoisted_1$2, [
515
+ (openBlock(true), createElementBlock(Fragment, null, renderList(category.pricings, (pricing) => {
516
+ return openBlock(), createBlock(_sfc_main$4, {
517
+ key: pricing.id,
518
+ pricing,
519
+ selected: __props.selectedPricingIds.includes(pricing.id),
520
+ onToggle: _cache[0] || (_cache[0] = ($event) => emit("toggle", $event))
521
+ }, null, 8, ["pricing", "selected"]);
522
+ }), 128)),
523
+ (openBlock(true), createElementBlock(Fragment, null, renderList(category.pricing_groups, (group) => {
524
+ return openBlock(), createElementBlock(Fragment, {
525
+ key: group.id
526
+ }, [
527
+ createVNode(unref(_sfc_main$2$1), {
528
+ variant: "body-sm",
529
+ weight: "semibold",
530
+ class: "mt-2"
531
+ }, {
532
+ default: withCtx(() => [
533
+ createTextVNode(toDisplayString(group.name), 1)
534
+ ]),
535
+ _: 2
536
+ }, 1024),
537
+ (openBlock(true), createElementBlock(Fragment, null, renderList(group.pricings, (pricing) => {
538
+ return openBlock(), createBlock(_sfc_main$4, {
539
+ key: pricing.id,
540
+ pricing,
541
+ selected: __props.selectedPricingIds.includes(pricing.id),
542
+ onToggle: _cache[1] || (_cache[1] = ($event) => emit("toggle", $event))
543
+ }, null, 8, ["pricing", "selected"]);
544
+ }), 128))
545
+ ], 64);
546
+ }), 128))
547
+ ])
548
+ ]);
549
+ }), 128);
550
+ };
551
+ }
552
+ });
553
+ const _hoisted_1$1 = { class: "flex flex-col gap-4" };
554
+ const _hoisted_2$1 = {
555
+ key: 0,
556
+ class: "flex flex-col gap-2"
557
+ };
558
+ const _hoisted_3 = { class: "flex flex-col gap-1" };
559
+ const _hoisted_4 = {
560
+ key: 1,
561
+ class: "flex flex-col gap-2"
562
+ };
563
+ const _hoisted_5 = { class: "flex flex-col gap-1" };
564
+ const _hoisted_6 = { class: "flex items-center gap-3" };
565
+ const _hoisted_7 = {
566
+ key: 0,
567
+ class: "flex h-9 w-9 shrink-0 items-center gap-0.5"
568
+ };
569
+ const _hoisted_8 = ["src", "alt"];
570
+ const _hoisted_9 = {
571
+ key: 1,
572
+ class: "flex h-9 w-9 shrink-0 items-center justify-center overflow-clip rounded"
573
+ };
574
+ const _hoisted_10 = ["src", "alt"];
575
+ const _hoisted_11 = {
576
+ key: 2,
577
+ class: "flex flex-col gap-1"
578
+ };
579
+ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
580
+ __name: "PaymentMethodPicker",
581
+ props: {
582
+ customerId: { type: String },
583
+ subscriptionId: { type: String },
584
+ selectedId: { type: String }
585
+ },
586
+ emits: ["select"],
587
+ setup(__props, { emit: __emit }) {
588
+ const props = __props;
589
+ const emit = __emit;
590
+ const { $t } = useIntl();
591
+ const { getPaymentMethods } = createPaymentMethodsService();
592
+ const savedMethods = ref([]);
593
+ const paymentMethodOptions = ref([]);
594
+ const isPending = ref(false);
595
+ const newOptions = computed(
596
+ () => paymentMethodOptions.value.flatMap((entry) => entry.options ?? [])
597
+ );
598
+ const adyenLogoUrl = (type) => `https://checkoutshopper-live.adyen.com/checkoutshopper/images/logos/${type}.svg`;
599
+ const adyenBrandLogoUrl = (brand) => `https://checkoutshopper-live.adyen.com/checkoutshopper/images/logos/small/${brand}.svg`;
600
+ const PREFERRED_BRANDS = ["visa", "mc", "amex", "maestro"];
601
+ const displayBrands = (brands) => {
602
+ if (!brands) return [];
603
+ const preferred = PREFERRED_BRANDS.filter((b) => brands.includes(b));
604
+ const rest = brands.filter((b) => !PREFERRED_BRANDS.includes(b));
605
+ return [...preferred, ...rest].slice(0, 4);
606
+ };
607
+ onMounted(async () => {
608
+ isPending.value = true;
609
+ try {
610
+ const savedResponse = await getPaymentMethods({
611
+ customerId: props.customerId,
612
+ pagination: { page: 1, pageSize: 50 }
613
+ });
614
+ savedMethods.value = savedResponse.data;
615
+ paymentMethodOptions.value = getMockPaymentMethodOptionsResponse();
616
+ } finally {
617
+ isPending.value = false;
618
+ }
619
+ });
620
+ return (_ctx, _cache) => {
621
+ return openBlock(), createElementBlock("div", _hoisted_1$1, [
622
+ savedMethods.value.length > 0 ? (openBlock(), createElementBlock("div", _hoisted_2$1, [
623
+ createVNode(unref(_sfc_main$2$1), {
624
+ variant: "heading-3",
625
+ tag: "h2"
626
+ }, {
627
+ default: withCtx(() => [
628
+ createTextVNode(toDisplayString(unref($t)({
629
+ defaultMessage: "Saved payment methods",
630
+ id: "upgrade_subscription.payment_picker.saved_title",
631
+ description: "Heading for the saved payment methods section in the upgrade subscription payment picker"
632
+ })), 1)
633
+ ]),
634
+ _: 1
635
+ }),
636
+ createElementVNode("div", _hoisted_3, [
637
+ (openBlock(true), createElementBlock(Fragment, null, renderList(savedMethods.value, (method) => {
638
+ return openBlock(), createBlock(unref(_sfc_main$1g), {
639
+ key: method.id,
640
+ "content-background": __props.selectedId === method.id ? "none" : "gray",
641
+ class: normalizeClass([{ "!bg-white": __props.selectedId === method.id }, "cursor-pointer"]),
642
+ onClick: ($event) => emit("select", method.id)
643
+ }, {
644
+ default: withCtx(() => [
645
+ createVNode(unref(_sfc_main$7), { "payment-method": method }, null, 8, ["payment-method"])
646
+ ]),
647
+ _: 2
648
+ }, 1032, ["content-background", "class", "onClick"]);
649
+ }), 128))
650
+ ])
651
+ ])) : createCommentVNode("", true),
652
+ newOptions.value.length > 0 ? (openBlock(), createElementBlock("div", _hoisted_4, [
653
+ createVNode(unref(_sfc_main$2$1), {
654
+ variant: "heading-3",
655
+ tag: "h2"
656
+ }, {
657
+ default: withCtx(() => [
658
+ createTextVNode(toDisplayString(unref($t)({
659
+ defaultMessage: "All payment methods",
660
+ id: "upgrade_subscription.payment_picker.all_title",
661
+ description: "Heading for the all payment methods section in the upgrade subscription payment picker"
662
+ })), 1)
663
+ ]),
664
+ _: 1
665
+ }),
666
+ createElementVNode("div", _hoisted_5, [
667
+ (openBlock(true), createElementBlock(Fragment, null, renderList(newOptions.value, (option) => {
668
+ return openBlock(), createBlock(unref(_sfc_main$1g), {
669
+ key: option.adyen.type,
670
+ "content-background": __props.selectedId === option.adyen.type ? "none" : "gray",
671
+ class: normalizeClass([{ "!bg-white": __props.selectedId === option.adyen.type }, "cursor-pointer"]),
672
+ onClick: ($event) => emit("select", option.adyen.type)
673
+ }, {
674
+ default: withCtx(() => [
675
+ createElementVNode("div", _hoisted_6, [
676
+ option.adyen.type === "scheme" ? (openBlock(), createElementBlock("div", _hoisted_7, [
677
+ (openBlock(true), createElementBlock(Fragment, null, renderList(displayBrands(option.adyen.brands), (brand) => {
678
+ return openBlock(), createElementBlock("img", {
679
+ key: brand,
680
+ src: adyenBrandLogoUrl(brand),
681
+ alt: brand,
682
+ class: "h-5 w-auto rounded"
683
+ }, null, 8, _hoisted_8);
684
+ }), 128))
685
+ ])) : (openBlock(), createElementBlock("div", _hoisted_9, [
686
+ createElementVNode("img", {
687
+ src: adyenLogoUrl(option.adyen.type),
688
+ alt: option.name,
689
+ class: "h-9 w-9 object-contain"
690
+ }, null, 8, _hoisted_10)
691
+ ])),
692
+ createVNode(unref(_sfc_main$2$1), { variant: "body-sm" }, {
693
+ default: withCtx(() => [
694
+ createTextVNode(toDisplayString(option.name), 1)
695
+ ]),
696
+ _: 2
697
+ }, 1024)
698
+ ])
699
+ ]),
700
+ _: 2
701
+ }, 1032, ["content-background", "class", "onClick"]);
702
+ }), 128))
703
+ ])
704
+ ])) : createCommentVNode("", true),
705
+ isPending.value ? (openBlock(), createElementBlock("div", _hoisted_11, [..._cache[0] || (_cache[0] = [
706
+ createElementVNode("div", { class: "h-[52px] animate-pulse rounded-md bg-gray-100" }, null, -1),
707
+ createElementVNode("div", { class: "h-[52px] animate-pulse rounded-md bg-gray-100" }, null, -1),
708
+ createElementVNode("div", { class: "h-[52px] animate-pulse rounded-md bg-gray-100" }, null, -1)
709
+ ])])) : createCommentVNode("", true)
710
+ ]);
711
+ };
712
+ }
713
+ });
714
+ function createPricingPlanSchedulesService() {
715
+ const request = createRequestService();
716
+ const config = useConfig();
717
+ function chargeOnDemandPricingItems({
718
+ scheduleId,
719
+ pricingPlanVersionId,
720
+ pricingItemIds,
721
+ startAt,
722
+ finalizeImmediately = true,
723
+ paymentMethodId
724
+ }) {
725
+ return request({
726
+ url: `${config.apiUrls.config}/portal/pricing-plan-schedules/${scheduleId}/charge-on-demand-pricing-items`,
727
+ options: { method: "POST" },
728
+ data: {
729
+ ...pricingPlanVersionId ? { pricing_plan_version_id: pricingPlanVersionId } : {},
730
+ pricing_item_ids: pricingItemIds,
731
+ ...startAt ? { start_at: startAt } : {},
732
+ finalize_immediately: finalizeImmediately,
733
+ ...paymentMethodId ? { payment_method_id: paymentMethodId } : {}
734
+ }
735
+ });
736
+ }
737
+ return { chargeOnDemandPricingItems };
738
+ }
739
+ const _hoisted_1 = {
740
+ key: 0,
741
+ class: "flex h-full items-center justify-center p-8"
742
+ };
743
+ const _hoisted_2 = { class: "flex flex-col items-center py-10" };
744
+ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
745
+ __name: "UpgradeSubscription",
746
+ props: {
747
+ configuration: { type: Object }
748
+ },
749
+ setup(__props) {
750
+ const props = __props;
751
+ const { $t } = useIntl();
752
+ const { dispatchAction } = useActionDispatchProvider();
753
+ const { chargeOnDemandPricingItems } = createPricingPlanSchedulesService();
754
+ const portal = usePortal();
755
+ const customerId = computed(() => portal.value.customer_id);
756
+ const selectedPricingIds = ref([]);
757
+ const selectedPaymentMethodId = ref(void 0);
758
+ const isPurchasePending = ref(false);
759
+ const isPurchased = ref(false);
760
+ const previewInvoice = ref(void 0);
761
+ const isPreviewPending = ref(false);
762
+ const mockResponse = computed(
763
+ () => getMockOnDemandPricingItemsResponse(props.configuration.subscriptionId)
764
+ );
765
+ const categories = computed(() => mockResponse.value.pricing_categories);
766
+ const allOnDemandPricings = computed(
767
+ () => categories.value.flatMap((cat) => [
768
+ ...cat.pricings ?? [],
769
+ ...(cat.pricing_groups ?? []).flatMap((g) => g.pricings ?? [])
770
+ ])
771
+ );
772
+ const selectedPricings = computed(
773
+ () => allOnDemandPricings.value.filter((p) => selectedPricingIds.value.includes(p.id))
774
+ );
775
+ let previewTimer;
776
+ watch(selectedPricingIds, (ids) => {
777
+ clearTimeout(previewTimer);
778
+ if (ids.length === 0) {
779
+ previewInvoice.value = void 0;
780
+ isPreviewPending.value = false;
781
+ return;
782
+ }
783
+ isPreviewPending.value = true;
784
+ previewTimer = setTimeout(() => {
785
+ previewInvoice.value = getMockPreviewResponse(ids).invoice;
786
+ isPreviewPending.value = false;
787
+ }, 400);
788
+ });
789
+ const handleToggle = (pricingId) => {
790
+ if (selectedPricingIds.value.includes(pricingId)) {
791
+ selectedPricingIds.value = selectedPricingIds.value.filter((id) => id !== pricingId);
792
+ } else {
793
+ selectedPricingIds.value = [...selectedPricingIds.value, pricingId];
794
+ }
795
+ };
796
+ const canPurchase = computed(
797
+ () => selectedPricingIds.value.length > 0 && !!selectedPaymentMethodId.value
798
+ );
799
+ const purchaseError = ref(void 0);
800
+ const isSavedPaymentMethod = (id) => id.startsWith("pmet_");
801
+ const handlePurchase = async () => {
802
+ if (!canPurchase.value) return;
803
+ isPurchasePending.value = true;
804
+ purchaseError.value = void 0;
805
+ try {
806
+ const pricingItemIds = selectedPricings.value.map((p) => {
807
+ var _a, _b;
808
+ return (_b = (_a = p.items) == null ? void 0 : _a[0]) == null ? void 0 : _b.id;
809
+ }).filter((id) => !!id);
810
+ const savedMethodId = selectedPaymentMethodId.value && isSavedPaymentMethod(selectedPaymentMethodId.value) ? selectedPaymentMethodId.value : void 0;
811
+ const invoice = await chargeOnDemandPricingItems({
812
+ scheduleId: mockResponse.value.pricing_plan_schedule_id,
813
+ pricingPlanVersionId: mockResponse.value.pricing_plan_version_id,
814
+ pricingItemIds,
815
+ finalizeImmediately: true,
816
+ paymentMethodId: savedMethodId
817
+ });
818
+ if (savedMethodId) {
819
+ isPurchased.value = true;
820
+ } else {
821
+ dispatchAction({ action: "pay-invoice", data: { invoiceId: invoice.id } });
822
+ }
823
+ } catch {
824
+ purchaseError.value = $t({
825
+ defaultMessage: "Something went wrong. Please try again.",
826
+ id: "upgrade_subscription.purchase_error",
827
+ description: "Error message shown when the purchase call fails on the upgrade subscription page"
828
+ });
829
+ } finally {
830
+ isPurchasePending.value = false;
831
+ }
832
+ };
833
+ return (_ctx, _cache) => {
834
+ return isPurchased.value ? (openBlock(), createElementBlock("div", _hoisted_1, [
835
+ createVNode(unref(_sfc_main$1g), null, {
836
+ default: withCtx(() => [
837
+ createElementVNode("div", _hoisted_2, [
838
+ createVNode(unref(_sfc_main$4$1), {
839
+ icon: "check_circle",
840
+ class: "text-green-400",
841
+ size: "lg"
842
+ }),
843
+ createVNode(unref(_sfc_main$2$1), {
844
+ variant: "heading-3",
845
+ tag: "span",
846
+ class: "mt-2"
847
+ }, {
848
+ default: withCtx(() => [
849
+ createTextVNode(toDisplayString(unref($t)({
850
+ defaultMessage: "Payment successful",
851
+ id: "upgrade_subscription.success.title",
852
+ description: "Title shown after a successful add-on purchase"
853
+ })), 1)
854
+ ]),
855
+ _: 1
856
+ }),
857
+ createVNode(unref(_sfc_main$2$1), {
858
+ variant: "body-sm",
859
+ shade: "lighter",
860
+ tag: "span",
861
+ class: "mt-1"
862
+ }, {
863
+ default: withCtx(() => [
864
+ createTextVNode(toDisplayString(unref($t)({
865
+ defaultMessage: "Your add-ons have been activated.",
866
+ id: "upgrade_subscription.success.subtitle",
867
+ description: "Subtitle shown after a successful add-on purchase"
868
+ })), 1)
869
+ ]),
870
+ _: 1
871
+ })
872
+ ])
873
+ ]),
874
+ _: 1
875
+ })
876
+ ])) : (openBlock(), createBlock(unref(ContentWithAsideLayout), { key: 1 }, {
877
+ content: withCtx(() => [
878
+ categories.value.length > 0 ? (openBlock(), createBlock(_sfc_main$3, {
879
+ key: 0,
880
+ categories: categories.value,
881
+ "selected-pricing-ids": selectedPricingIds.value,
882
+ onToggle: handleToggle
883
+ }, null, 8, ["categories", "selected-pricing-ids"])) : (openBlock(), createBlock(unref(_sfc_main$2$1), {
884
+ key: 1,
885
+ variant: "body-sm",
886
+ shade: "lighter",
887
+ class: "p-4"
888
+ }, {
889
+ default: withCtx(() => [
890
+ createTextVNode(toDisplayString(unref($t)({
891
+ defaultMessage: "No on-demand add-ons are available for this subscription.",
892
+ id: "upgrade_subscription.empty_state",
893
+ description: "Shown when there are no on-demand add-ons available for the subscription"
894
+ })), 1)
895
+ ]),
896
+ _: 1
897
+ })),
898
+ createVNode(unref(_sfc_main$2p), { spacing: "sm" }),
899
+ createVNode(_sfc_main$2, {
900
+ "customer-id": customerId.value,
901
+ "subscription-id": __props.configuration.subscriptionId,
902
+ "selected-id": selectedPaymentMethodId.value,
903
+ onSelect: _cache[0] || (_cache[0] = ($event) => selectedPaymentMethodId.value = $event)
904
+ }, null, 8, ["customer-id", "subscription-id", "selected-id"])
905
+ ]),
906
+ aside: withCtx(() => [
907
+ createVNode(_sfc_main$5, {
908
+ "selected-pricings": selectedPricings.value,
909
+ invoice: previewInvoice.value,
910
+ "is-pending": isPreviewPending.value
911
+ }, null, 8, ["selected-pricings", "invoice", "is-pending"]),
912
+ purchaseError.value ? (openBlock(), createBlock(unref(_sfc_main$16), {
913
+ key: 0,
914
+ title: purchaseError.value
915
+ }, null, 8, ["title"])) : createCommentVNode("", true),
916
+ createVNode(unref(_sfc_main$2H), {
917
+ size: "lg",
918
+ class: "full-width",
919
+ type: "button",
920
+ disabled: !canPurchase.value || isPurchasePending.value,
921
+ loading: isPurchasePending.value,
922
+ onClick: handlePurchase
923
+ }, {
924
+ default: withCtx(() => [
925
+ createTextVNode(toDisplayString(unref($t)({
926
+ defaultMessage: "Purchase",
927
+ id: "upgrade_subscription.purchase_button.label",
928
+ description: "Label for the purchase button on the upgrade subscription page"
929
+ })), 1)
930
+ ]),
931
+ _: 1
932
+ }, 8, ["disabled", "loading"]),
933
+ createVNode(unref(_sfc_main$2$1), {
934
+ tag: "div",
935
+ variant: "body-sm",
936
+ shade: "lighter",
937
+ class: "flex grow justify-center"
938
+ }, {
939
+ default: withCtx(() => [
940
+ createVNode(_sfc_main$8, {
941
+ icon: "lock",
942
+ kpi: unref($t)({
943
+ defaultMessage: "Secure and encrypted payments",
944
+ id: "upgrade_subscription.kpi.encrypted_payments.label",
945
+ description: "The encrypted payments KPI shown on the upgrade subscription page"
946
+ })
947
+ }, null, 8, ["kpi"])
948
+ ]),
949
+ _: 1
950
+ })
951
+ ]),
952
+ _: 1
953
+ }));
954
+ };
955
+ }
956
+ });
957
+ const _sfc_main = /* @__PURE__ */ defineComponent({
958
+ __name: "UpgradeSubscription.entry",
959
+ props: {
960
+ environment: { type: String },
961
+ locale: { type: String },
962
+ dateLocale: { type: String },
963
+ messages: { type: Object },
964
+ showTimezones: { type: Boolean },
965
+ primaryColor: { type: String },
966
+ secondaryColor: { type: String },
967
+ isShadowRoot: { type: Boolean },
968
+ experimentalFeatures: { type: Array },
969
+ logLevel: { type: String },
970
+ onLog: { type: Function },
971
+ allowedPortalTypes: { type: Array },
972
+ portalObject: { type: Object },
973
+ customElementName: { type: String },
974
+ branding: { type: Object },
975
+ configuration: { type: Object }
976
+ },
977
+ setup(__props) {
978
+ return (_ctx, _cache) => {
979
+ var _a, _b, _c, _d;
980
+ return openBlock(), createBlock(_sfc_main$9, {
981
+ "custom-element-name": unref(COMPONENT_NAME),
982
+ environment: __props.environment,
983
+ locale: __props.locale,
984
+ "portal-object": __props.portalObject,
985
+ "allowed-portal-types": ["CUSTOMER"],
986
+ "primary-color": (_b = (_a = __props.branding) == null ? void 0 : _a.colors) == null ? void 0 : _b.primary,
987
+ "secondary-color": (_d = (_c = __props.branding) == null ? void 0 : _c.colors) == null ? void 0 : _d.secondary,
988
+ "experimental-features": __props.experimentalFeatures,
989
+ "log-level": __props.logLevel,
990
+ "on-log": __props.onLog,
991
+ onError: _cache[0] || (_cache[0] = (error) => _ctx.$emit("error", error))
992
+ }, {
993
+ default: withCtx(() => [
994
+ createVNode(_sfc_main$1, { configuration: __props.configuration }, null, 8, ["configuration"])
995
+ ]),
996
+ _: 1
997
+ }, 8, ["custom-element-name", "environment", "locale", "portal-object", "primary-color", "secondary-color", "experimental-features", "log-level", "on-log"]);
998
+ };
999
+ }
1000
+ });
1001
+ const SolvimonUpgradeSubscription = defineCustomElement(_sfc_main);
1002
+ const COMPONENT_NAME = getComponentName("upgrade-subscription");
1003
+ const defineSolvimonUpgradeSubscription = () => {
1004
+ if (!customElements.get(COMPONENT_NAME)) {
1005
+ customElements.define(COMPONENT_NAME, SolvimonUpgradeSubscription);
1006
+ }
1007
+ };
1008
+ export {
1009
+ COMPONENT_NAME,
1010
+ SolvimonUpgradeSubscription,
1011
+ defineSolvimonUpgradeSubscription
1012
+ };