@mainmoneyapp/js-checkout 0.0.0-stage → 0.1.1

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.
package/dist/index.js ADDED
@@ -0,0 +1,1245 @@
1
+ // src/checkout.ts
2
+ import {
3
+ ConfigurationException as ConfigurationException2,
4
+ CurrencyMismatchException,
5
+ Emitter,
6
+ createTranslator,
7
+ extractCustomerName,
8
+ isPhoneIdentifier,
9
+ isTerminalStatus as isTerminalStatus2
10
+ } from "@mainmoneyapp/js-core";
11
+ import { createHttp } from "@mainmoneyapp/js-http";
12
+
13
+ // src/poll.ts
14
+ import { ConfigurationException, isTerminalStatus } from "@mainmoneyapp/js-core";
15
+ import { decodeJson } from "@mainmoneyapp/js-http";
16
+ async function pollStatus(options) {
17
+ if (options.pollUrl.trim() === "") {
18
+ throw new ConfigurationException("pollUrl is required when polling is enabled");
19
+ }
20
+ let latest = { status: "PENDING" };
21
+ while (!options.signal?.aborted) {
22
+ const url = withQuery(options.pollUrl, { reference: options.reference, operation: options.operation });
23
+ const response = await options.fetchImpl(url, {
24
+ method: "GET",
25
+ headers: { ...options.pollHeaders },
26
+ signal: options.signal
27
+ });
28
+ latest = decodeJson(response.status, await response.text());
29
+ if (typeof latest.status === "string" && isTerminalStatus(latest.status)) {
30
+ return latest;
31
+ }
32
+ await sleep(options.intervalMs, options.signal);
33
+ }
34
+ return latest;
35
+ }
36
+ function withQuery(uri, query) {
37
+ const parsed = new URL(uri, uri.startsWith("http") ? void 0 : "https://placeholder.invalid");
38
+ for (const [name, value] of Object.entries(query)) {
39
+ parsed.searchParams.set(name, value);
40
+ }
41
+ if (uri.startsWith("http://") || uri.startsWith("https://")) {
42
+ return parsed.toString();
43
+ }
44
+ return `${parsed.pathname}${parsed.search}`;
45
+ }
46
+ function sleep(ms, signal) {
47
+ return new Promise((resolve, reject) => {
48
+ if (signal?.aborted) {
49
+ reject(signal.reason ?? new Error("aborted"));
50
+ return;
51
+ }
52
+ const timer = setTimeout(resolve, ms);
53
+ signal?.addEventListener(
54
+ "abort",
55
+ () => {
56
+ clearTimeout(timer);
57
+ reject(signal.reason ?? new Error("aborted"));
58
+ },
59
+ { once: true }
60
+ );
61
+ });
62
+ }
63
+
64
+ // src/checkout.ts
65
+ var MIN_NATIONAL_AFTER_DIAL_CODE = 8;
66
+ var MIN_LOCAL_NUMBER_DIGITS = 7;
67
+ var MAX_LOCAL_NUMBER_DIGITS = 12;
68
+ function toE164Digits(input, dialCode) {
69
+ const code = dialCode.replace(/\D/g, "");
70
+ const digits = input.replace(/\D/g, "").replace(/^0+/, "");
71
+ const national = digits.startsWith(code) && digits.length - code.length >= MIN_NATIONAL_AFTER_DIAL_CODE ? digits.slice(code.length).replace(/^0+/, "") : digits;
72
+ return `${code}${national}`;
73
+ }
74
+ function providerAcceptedCurrencies(provider) {
75
+ if (provider.accepted_currencies !== void 0 && provider.accepted_currencies.length > 0) {
76
+ return [...provider.accepted_currencies];
77
+ }
78
+ return [provider.currency_code];
79
+ }
80
+ function unionProviderCurrencies(providers) {
81
+ const codes = /* @__PURE__ */ new Set();
82
+ for (const provider of providers) {
83
+ for (const code of providerAcceptedCurrencies(provider)) {
84
+ codes.add(code);
85
+ }
86
+ }
87
+ return [...codes].sort();
88
+ }
89
+ function createCheckout(session, options) {
90
+ const pollEnabled = options.pollStatus !== false;
91
+ if (pollEnabled) {
92
+ if (options.pollUrl === void 0 || options.pollUrl.trim() === "") {
93
+ throw new ConfigurationException2("pollUrl is required when pollStatus is true");
94
+ }
95
+ if (options.pollHeaders === void 0) {
96
+ throw new ConfigurationException2("pollHeaders is required when pollStatus is true");
97
+ }
98
+ }
99
+ const http = options.http ?? createHttp(session);
100
+ const catalogOverrides = { ...session.messages, ...options.messages };
101
+ let translate = createTranslator(options.locale ?? session.locale, catalogOverrides);
102
+ const t = (key, vars) => translate(key, vars);
103
+ const theme = { ...session.theme, ...options.theme };
104
+ const emitter = new Emitter();
105
+ const pollAbort = new AbortController();
106
+ const explicitCurrency = options.currency?.trim() ?? "";
107
+ const lockCurrency = options.lockCurrency === true || explicitCurrency !== "";
108
+ const state = {
109
+ step: "country",
110
+ operation: options.operation,
111
+ countries: [],
112
+ providers: [],
113
+ identifier: "",
114
+ customerName: null,
115
+ amount: options.amount ?? "",
116
+ lockAmount: options.lockAmount === true,
117
+ currency: explicitCurrency,
118
+ lockCurrency,
119
+ availableCurrencies: explicitCurrency !== "" ? [explicitCurrency] : [],
120
+ partnerFee: null,
121
+ locale: options.locale ?? session.locale,
122
+ paymentMethods: ["mobile_money"],
123
+ activeMethod: "mobile_money",
124
+ feeBearer: "MERCHANT",
125
+ customerEmail: "",
126
+ canPay: false,
127
+ theme
128
+ };
129
+ let lastMatchedIdentifier = "";
130
+ let returnStep = "overview";
131
+ const notify = () => {
132
+ emitter.emit("change", getState());
133
+ };
134
+ const getState = () => ({ ...structuredClone(state), canPay: computeCanPay() });
135
+ const hasValidLocalNumber = () => {
136
+ const digits = e164OrIdentifier().replace(/\D/g, "");
137
+ const dial = state.selectedCountry?.phone_code?.replace(/\D/g, "") ?? "";
138
+ const national = digits.length - dial.length;
139
+ return national >= MIN_LOCAL_NUMBER_DIGITS && national <= MAX_LOCAL_NUMBER_DIGITS;
140
+ };
141
+ const computeCanPay = () => {
142
+ const amount = Number(state.amount);
143
+ return state.step === "details" && state.activeMethod === "mobile_money" && state.selectedCountry !== void 0 && state.providers.length > 0 && state.currency !== "" && Number.isFinite(amount) && amount > 0 && hasValidLocalNumber();
144
+ };
145
+ const messageFromError = (error) => {
146
+ if (error instanceof Error && error.message !== "") {
147
+ return error.message;
148
+ }
149
+ return "Merchant backend request failed";
150
+ };
151
+ const fail = (error) => {
152
+ state.error = messageFromError(error);
153
+ notify();
154
+ };
155
+ const routingOperationType = () => {
156
+ return state.operation === "deposit" ? "DEPOSIT" : "PAYOUT";
157
+ };
158
+ const paginated = (payload) => {
159
+ if (Array.isArray(payload)) {
160
+ return payload;
161
+ }
162
+ if (payload !== null && typeof payload === "object" && Array.isArray(payload.results)) {
163
+ return payload.results;
164
+ }
165
+ return [];
166
+ };
167
+ const applyProviderCurrency = (provider) => {
168
+ if (state.lockCurrency) {
169
+ return;
170
+ }
171
+ const accepted = providerAcceptedCurrencies(provider);
172
+ state.availableCurrencies = accepted;
173
+ if (accepted.includes(provider.currency_code)) {
174
+ state.currency = provider.currency_code;
175
+ } else if (accepted.length > 0) {
176
+ state.currency = accepted[0];
177
+ }
178
+ };
179
+ const PAYMENT_METHODS = ["mobile_money", "card", "mainmoney"];
180
+ const applyPaymentPreferences = (prefs) => {
181
+ if (Array.isArray(prefs.payment_methods)) {
182
+ const methods = PAYMENT_METHODS.filter((method) => prefs.payment_methods.includes(method));
183
+ state.paymentMethods = methods;
184
+ if (!methods.includes(state.activeMethod)) {
185
+ state.activeMethod = methods[0] ?? "mobile_money";
186
+ }
187
+ }
188
+ if (prefs.fee_bearer === "CUSTOMER" || prefs.fee_bearer === "MERCHANT") {
189
+ state.feeBearer = prefs.fee_bearer;
190
+ }
191
+ };
192
+ const loadCountries = async () => {
193
+ try {
194
+ const payload = await http.get(session.paths.countries);
195
+ state.countries = paginated(payload);
196
+ state.error = void 0;
197
+ } catch (error) {
198
+ fail(error);
199
+ return;
200
+ }
201
+ try {
202
+ const prefs = await http.get(session.paths.checkoutPreferences);
203
+ applyPaymentPreferences(prefs);
204
+ if (prefs.primary_color !== void 0) {
205
+ state.theme = {
206
+ primary: String(prefs.primary_color ?? state.theme.primary),
207
+ secondary: String(prefs.secondary_color ?? state.theme.secondary),
208
+ accent: String(prefs.accent_color ?? state.theme.accent),
209
+ background: String(prefs.background_color ?? state.theme.background)
210
+ };
211
+ }
212
+ } catch {
213
+ }
214
+ notify();
215
+ };
216
+ const selectCountry = async (code) => {
217
+ const country = state.countries.find((item) => item.code === code);
218
+ if (country === void 0) {
219
+ fail(new ConfigurationException2("Unknown country"));
220
+ return;
221
+ }
222
+ try {
223
+ const payload = await http.get(session.paths.providers, {
224
+ country: code,
225
+ operation_type: routingOperationType()
226
+ });
227
+ state.selectedCountry = country;
228
+ state.selectedProvider = void 0;
229
+ state.highlightedProviderCode = void 0;
230
+ state.customerName = null;
231
+ lastMatchedIdentifier = "";
232
+ state.providers = paginated(payload);
233
+ if (!state.lockCurrency) {
234
+ state.availableCurrencies = unionProviderCurrencies(state.providers);
235
+ if (state.currency === "" && state.availableCurrencies.length > 0) {
236
+ state.currency = state.availableCurrencies[0];
237
+ }
238
+ }
239
+ state.error = void 0;
240
+ state.step = "details";
241
+ if (state.providers.length === 1 && state.operation === "deposit") {
242
+ state.selectedProvider = state.providers[0];
243
+ applyProviderCurrency(state.providers[0]);
244
+ await refreshLimitsAndFees();
245
+ }
246
+ notify();
247
+ } catch (error) {
248
+ fail(error);
249
+ }
250
+ };
251
+ const selectProvider = async (code) => {
252
+ const provider = state.providers.find((item) => item.code === code);
253
+ if (provider === void 0) {
254
+ fail(new ConfigurationException2("Unknown provider"));
255
+ return;
256
+ }
257
+ try {
258
+ state.selectedProvider = provider;
259
+ applyProviderCurrency(provider);
260
+ await refreshLimitsAndFees();
261
+ notify();
262
+ } catch (error) {
263
+ fail(error);
264
+ }
265
+ };
266
+ const setIdentifier = (value) => {
267
+ state.identifier = value;
268
+ };
269
+ const setCustomerEmail = (value) => {
270
+ state.customerEmail = value.trim();
271
+ };
272
+ const setMethod = (method) => {
273
+ if (!state.paymentMethods.includes(method) || state.activeMethod === method) {
274
+ return;
275
+ }
276
+ state.activeMethod = method;
277
+ state.error = void 0;
278
+ notify();
279
+ };
280
+ const setLocale = (locale) => {
281
+ if (state.locale === locale) {
282
+ return;
283
+ }
284
+ state.locale = locale;
285
+ translate = createTranslator(locale, catalogOverrides);
286
+ notify();
287
+ };
288
+ const matchProvider = async () => {
289
+ const trimmed = state.identifier.trim();
290
+ if (trimmed === "") {
291
+ return;
292
+ }
293
+ if (trimmed === lastMatchedIdentifier) {
294
+ return;
295
+ }
296
+ try {
297
+ const payload = await http.get(session.paths.matchProvider, {
298
+ account_number: e164OrIdentifier(),
299
+ get_lookup: true,
300
+ operation_type: routingOperationType()
301
+ });
302
+ const entity = typeof payload.entity === "string" ? payload.entity : void 0;
303
+ if (entity !== void 0) {
304
+ state.highlightedProviderCode = entity;
305
+ const matched = state.providers.find((item) => item.code === entity);
306
+ if (matched !== void 0) {
307
+ state.selectedProvider = matched;
308
+ applyProviderCurrency(matched);
309
+ }
310
+ }
311
+ state.customerName = extractCustomerName(payload);
312
+ lastMatchedIdentifier = trimmed;
313
+ await refreshLimitsAndFees();
314
+ notify();
315
+ } catch (error) {
316
+ fail(error);
317
+ }
318
+ };
319
+ const setCurrency = async (code) => {
320
+ if (state.lockCurrency) {
321
+ return;
322
+ }
323
+ const normalized = code.trim().toUpperCase();
324
+ if (normalized === "" || !state.availableCurrencies.includes(normalized)) {
325
+ fail(new ConfigurationException2("Unknown currency"));
326
+ return;
327
+ }
328
+ try {
329
+ state.currency = normalized;
330
+ await refreshLimitsAndFees();
331
+ notify();
332
+ } catch (error) {
333
+ fail(error);
334
+ }
335
+ };
336
+ const setAmount = async (amount) => {
337
+ if (state.lockAmount) {
338
+ return;
339
+ }
340
+ try {
341
+ state.amount = amount;
342
+ await refreshLimitsAndFees();
343
+ notify();
344
+ } catch (error) {
345
+ fail(error);
346
+ }
347
+ };
348
+ const refreshLimitsAndFees = async () => {
349
+ if (state.selectedProvider === void 0 || state.amount.trim() === "" || state.currency === "") {
350
+ return;
351
+ }
352
+ const operation = routingOperationType();
353
+ const limitsPayload = await http.get(session.paths.amountLimits, {
354
+ financial_entity_code: state.selectedProvider.code,
355
+ currency: state.currency,
356
+ operation_type: operation
357
+ });
358
+ const limits = paginated(limitsPayload);
359
+ state.limits = limits[0];
360
+ if (state.limits !== void 0) {
361
+ const amount = Number(state.amount);
362
+ const min = state.limits.amount_min === null ? void 0 : Number(state.limits.amount_min);
363
+ const max = state.limits.amount_max === null ? void 0 : Number(state.limits.amount_max);
364
+ if (min !== void 0 && amount < min || max !== void 0 && amount > max) {
365
+ state.error = t("limits", {
366
+ min: state.limits.amount_min ?? "",
367
+ max: state.limits.amount_max ?? ""
368
+ });
369
+ } else {
370
+ state.error = void 0;
371
+ }
372
+ }
373
+ const fees = merchantFees();
374
+ state.fees = await http.post(session.paths.feesSimulate, {
375
+ provider_code: state.selectedProvider.code,
376
+ operation_type: operation,
377
+ amount: state.amount,
378
+ currency: state.currency,
379
+ ...fees !== "" ? { fees } : {}
380
+ });
381
+ };
382
+ const prepare = async () => {
383
+ if (state.selectedCountry === void 0 || state.selectedProvider === void 0) {
384
+ state.error = t("required");
385
+ notify();
386
+ return false;
387
+ }
388
+ if (state.identifier.trim() === "" || state.amount.trim() === "" || state.currency === "") {
389
+ state.error = t("required");
390
+ notify();
391
+ return false;
392
+ }
393
+ try {
394
+ if (options.onPartnerFee !== void 0) {
395
+ const fee = await options.onPartnerFee(getState());
396
+ if (fee !== null && fee.currency !== state.currency) {
397
+ fail(new CurrencyMismatchException());
398
+ return false;
399
+ }
400
+ state.partnerFee = fee;
401
+ }
402
+ if (state.operation === "payout" && options.onValidateBalance !== void 0) {
403
+ const result = await options.onValidateBalance(getState());
404
+ if (!result.ok) {
405
+ state.error = result.message ?? t("balanceRejected");
406
+ notify();
407
+ return false;
408
+ }
409
+ }
410
+ state.error = void 0;
411
+ return true;
412
+ } catch (error) {
413
+ fail(error);
414
+ return false;
415
+ }
416
+ };
417
+ const goOverview = async () => {
418
+ if (await prepare()) {
419
+ state.step = "overview";
420
+ notify();
421
+ }
422
+ };
423
+ const pay = async () => {
424
+ if (state.activeMethod !== "mobile_money") {
425
+ return;
426
+ }
427
+ if (state.selectedProvider === void 0 || lastMatchedIdentifier !== state.identifier.trim()) {
428
+ await matchProvider();
429
+ }
430
+ if (state.selectedProvider === void 0) {
431
+ state.error = t("selectProvider");
432
+ notify();
433
+ return;
434
+ }
435
+ if (await prepare()) {
436
+ returnStep = "details";
437
+ await confirm();
438
+ }
439
+ };
440
+ const goBack = () => {
441
+ if (state.step === "overview") {
442
+ state.step = "details";
443
+ } else if (state.step === "details") {
444
+ state.step = "country";
445
+ }
446
+ notify();
447
+ };
448
+ const confirm = async () => {
449
+ if (state.selectedProvider === void 0) {
450
+ fail(new ConfigurationException2("Provider is required"));
451
+ return;
452
+ }
453
+ state.step = "confirming";
454
+ state.error = void 0;
455
+ notify();
456
+ try {
457
+ const reference = options.reference ?? crypto.randomUUID();
458
+ let created;
459
+ if (state.operation === "deposit") {
460
+ const payload = {
461
+ provider_code: state.selectedProvider.code,
462
+ reference,
463
+ amount: state.amount,
464
+ currency: state.currency,
465
+ customer_phone: e164OrIdentifier()
466
+ };
467
+ if (state.customerName !== null) {
468
+ payload.customer_name = state.customerName;
469
+ }
470
+ if (state.customerEmail !== "") {
471
+ payload.customer_email = state.customerEmail;
472
+ }
473
+ const fees = merchantFees();
474
+ if (fees !== "") {
475
+ payload.fees = fees;
476
+ }
477
+ created = await http.post(session.paths.deposits, payload, {
478
+ "Idempotency-Key": reference
479
+ });
480
+ } else {
481
+ created = await http.post(session.paths.payouts, {
482
+ provider_code: state.selectedProvider.code,
483
+ reference,
484
+ amount: state.amount,
485
+ currency: state.currency,
486
+ destination_account: e164OrIdentifier()
487
+ }, { "Idempotency-Key": reference });
488
+ }
489
+ state.status = created;
490
+ if (typeof created.status === "string" && isTerminalStatus2(created.status)) {
491
+ state.step = "terminal";
492
+ notify();
493
+ emitter.emit("complete", getState());
494
+ return;
495
+ }
496
+ if (!pollEnabled) {
497
+ state.step = "ongoing";
498
+ notify();
499
+ emitter.emit("ongoing", getState());
500
+ return;
501
+ }
502
+ state.step = "polling";
503
+ notify();
504
+ const status = await pollStatus({
505
+ pollUrl: options.pollUrl ?? "",
506
+ pollHeaders: options.pollHeaders ?? {},
507
+ fetchImpl: session.fetch,
508
+ reference,
509
+ operation: state.operation,
510
+ intervalMs: options.pollIntervalMs ?? 2e3,
511
+ signal: pollAbort.signal
512
+ });
513
+ state.status = status;
514
+ state.step = "terminal";
515
+ notify();
516
+ emitter.emit("complete", getState());
517
+ if (typeof status.status === "string") {
518
+ emitter.emit("status", status);
519
+ }
520
+ } catch (error) {
521
+ state.step = returnStep;
522
+ fail(error);
523
+ }
524
+ };
525
+ const merchantFees = () => {
526
+ if (state.operation !== "deposit") {
527
+ return "";
528
+ }
529
+ return state.partnerFee?.amount ?? options.fees ?? "";
530
+ };
531
+ const e164OrIdentifier = () => {
532
+ const raw = state.identifier.trim();
533
+ if (!isPhoneIdentifier(state.selectedProvider) || state.selectedCountry?.phone_code === void 0) {
534
+ return raw;
535
+ }
536
+ return toE164Digits(raw, state.selectedCountry.phone_code);
537
+ };
538
+ const close = () => {
539
+ pollAbort.abort();
540
+ };
541
+ return {
542
+ t,
543
+ getState,
544
+ subscribe: (listener) => emitter.on("change", listener),
545
+ loadCountries,
546
+ selectCountry,
547
+ selectProvider,
548
+ setIdentifier,
549
+ setCustomerEmail,
550
+ setMethod,
551
+ setLocale,
552
+ matchProvider,
553
+ setCurrency,
554
+ setAmount,
555
+ goOverview,
556
+ goBack,
557
+ pay,
558
+ confirm,
559
+ close
560
+ };
561
+ }
562
+
563
+ // src/mount.ts
564
+ import { applyTheme, isPhoneIdentifier as isPhoneIdentifier2 } from "@mainmoneyapp/js-core";
565
+
566
+ // src/assets/logo.ts
567
+ var DEFAULT_LOGO_URL = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAewAAAHsCAYAAAAQKp5gAAAguklEQVR4nO3dT2yUZ57g8V/vdEvzz1WjbbVmZaia0UozYeKYuTQJjsyFaHCvsBSkMURygrSkycE+pBeQBqNGC0hEmJECSR/sAyQcSCy14wORsBQYNXvAwpnxnOI4TbSH2a7CaFarltb2zLZGPTO9B1w0SWgCrreq3qfq85FarRDq9dt0d771PO/zPs83uos9vwoAINf+Q6tvAAD4eoINAAkQbABIgGADQAIEGwASINgAkADBBoAECDYAJECwASABgg0ACRBsAEiAYANAAgQbABIg2ACQAMEGgAQINgAkQLABIAGCDQAJEGwASIBgA0ACBBsAEiDYAJAAwQaABAg2ACRAsAEgAYINAAkQbABIgGADQAIEGwASINgAkADBBoAECDYAJECwASABgg0ACRBsAEiAYANAAgQbABIg2ACQAMEGgAQINgAkQLABIAGCDQAJEGwASIBgA0ACBBsAEiDYAJAAwQaABAg2ACRAsAEgAYINAAkQbABIgGADQAIEGwASINgAkADBBoAECDYAJECwASABgg0ACRBsAEiAYANAAgQbABIg2ACQAMEGgAQINgAkQLABIAGCDQAJEGwASIBgA0ACBBsAEiDYAJAAwQaABAg2ACRAsAEgAYINAAkQbABIgGADQAIEGwASINgAkADBBoAECDYAJECwASABgg0ACRBsAEiAYANAAgQbABIg2ACQAMEGgAQINgAkQLABIAGCDQAJEGwASIBgA0ACBBsAEiDYAJAAwQaABAg2ACRAsAEgAYINAAkQbABIgGADQAIEGwASINgAkADBBoAECDYAJECwASABgg0ACRBsAEiAYANAAgQbABIg2ACQAMEGgAQINgAkQLABIAGCDQAJEGwASIBgA0ACBBsAEiDYAJAAwQaABAg2ACRAsAEgAYINAAkQbABIgGADQAIEGwASINgAkADBBoAECDYAJECwASABgg0ACRBsAEiAYANAAgQbABIg2ACQAMEGgAQINgAkQLABIAGCDQAJEGwASIBgA0ACBBsAEiDYAJAAwQaABAg2ACRAsAEgAYINAAkQbABIgGADQAIEGwASINgAkADBBoAECDYAJECwASABgg0ACRBsAEiAYANAAgQbABIg2ACQAMEGgAQINgAkQLABIAGCDQAJEGwASIBgA0ACBBsAEiDYAJAAwQaABAg2ACRAsAEgAd9s9Q2QX/uG98TmcvcXfm1tZS1WVtYiIqJaWY6IiNWVtVhdWY1q5W7T7xGgUwh2B3tYkB/00tf8/YdZXVmLamX5/r9XK3fjTuVuVCvLcWf9r6HTFIqFKBZ/PwrFQhSKXVEqb7r/9570/2MRER9MfXj/CzOd4xvdxZ5ftfomaI2Zq5eir39b03/u0uLtuFO5G58u3o6lxc/jTmU5lhZvN/0+IAuFYiFK5e7o6d0SxWJXPN37VBSLhdhc7r7/71kbGjwQ83MLmV+XfDP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uAjvCN7mLPr1p9E9Cp+n7v2/HMbxei6z/c23p06V9WY/6ffp77UAPNJ9gAkADPsAEgAYINAAkQbABIgGADQAIEGwASINgAkADBBoAECDYAJECwASABgg0ACRBsAEiAYANAAgQbABIg2ACQAMEGgAQINgAkQLABIAGCDQAJEGwASIBgA0ACBBsAEiDYAJAAwQaABAg2ACRAsAEgAYINAAkQbABIgGADQAIEGwASINgAkADBBoAECDYAJECwASABgg0ACRBsAEiAYANAAgQbABIg2ACQAMEGgAQINgAkQLABIAGCDQAJEGwASIBgA0ACBBsAEiDYAJAAwQaABAg2ACRAsAEgAYINAAkQbABIgGADQAIEGwASINgAkADBBoAECDYAJECwASABgg0ACRBsAEiAYANAAgQbABIg2ACQAMEGgAQINgAkQLABIAGCDQAJEGwASIBgA0ACBBsAEiDYAJAAwQaABAg2ACRAsAEgAYINAAkQbABIgGADQAIEGwASINgAkADBBoAECDYAJECwASABgg0ACRBsAEiAYANAAgQbABIg2ACQAMEGgAQINgAkQLABIAGCDQAJEGwASIBgA0ACBBsAEiDYAJAAwQaABAg2ACRAsAEgAYINAAkQbABIgGADQAIEGwASINgAkADBBoAECDYAJECwASABgg0ACRBsAEiAYANAAgQbABIg2ACQAMEGgAQINgAkQLABIAGCDQAJEGwASIBgA0ACBBsAEiDYAJAAwQaABAg2ACRAsAEgAYINAAkQbABIgGADQAIEGwASINgAkADBBoAECDYAJECwASABgg0ACRBsAEiAYANAAgQbABIg2ACQAMEGgAQINgAkQLABIAGCDQAJEGwASIBgA0ACBBsAEiDYAJAAwQaABAg2ACRAsAEgAYINAAkQbABIgGADQAIEGwASINgAkADBBoAECDYAJECwASABgg0ACRBsAEiAYANAAgQbABIg2ACQAMEGgAQINgAkQLABIAGCDQAJEGwASIBgA0ACBBsAEiDYAJAAwQaABAg2ACRAsAEgAf8f3StgqrS6+EwAAAAASUVORK5CYII=";
568
+
569
+ // src/form.ts
570
+ var LOCALES = ["en", "fr"];
571
+ var TAB_LABEL_KEYS = {
572
+ mobile_money: "tabMobileMoney",
573
+ card: "tabCard",
574
+ mainmoney: "tabMainMoney"
575
+ };
576
+ var TAB_ORDER = ["card", "mobile_money", "mainmoney"];
577
+ var FOOTER_LINK_KEYS = ["privacy", "terms", "security", "help"];
578
+ function formChrome(checkout, state, logoUrl, links, body) {
579
+ const root = document.createElement("div");
580
+ root.className = "mm-form";
581
+ root.append(header(checkout, state, logoUrl), body, footer(checkout, links));
582
+ return root;
583
+ }
584
+ function formBody(checkout, state) {
585
+ const body = document.createElement("div");
586
+ body.className = "mm-form-body";
587
+ const title = document.createElement("h2");
588
+ title.className = "mm-title";
589
+ title.textContent = checkout.t("formTitle");
590
+ const subtitle = document.createElement("p");
591
+ subtitle.className = "mm-subtitle";
592
+ subtitle.textContent = checkout.t("formSubtitle");
593
+ body.append(title, subtitle);
594
+ if (state.paymentMethods.length > 1) {
595
+ body.append(tabs(checkout, state));
596
+ }
597
+ if (state.activeMethod === "mobile_money") {
598
+ body.append(mobileMoneyPane(checkout, state));
599
+ } else if (state.activeMethod === "card") {
600
+ body.append(placeholderPane(checkout.t("cardSoon")));
601
+ } else {
602
+ body.append(qrPane(checkout.t("mainmoneySoon")));
603
+ }
604
+ body.append(payButton(checkout, state));
605
+ return body;
606
+ }
607
+ function header(checkout, state, logoUrl) {
608
+ const row = document.createElement("div");
609
+ row.className = "mm-header";
610
+ const language = document.createElement("div");
611
+ language.className = "mm-language";
612
+ const caption = document.createElement("span");
613
+ caption.textContent = `${checkout.t("language")}:`;
614
+ language.append(caption);
615
+ for (const locale of LOCALES) {
616
+ const button = document.createElement("button");
617
+ button.type = "button";
618
+ button.className = "mm-language-option";
619
+ button.textContent = locale.toUpperCase();
620
+ button.setAttribute("aria-pressed", String(state.locale === locale));
621
+ if (state.locale === locale) {
622
+ button.classList.add("is-active");
623
+ }
624
+ button.addEventListener("click", () => checkout.setLocale(locale));
625
+ language.append(button);
626
+ }
627
+ const powered = document.createElement("div");
628
+ powered.className = "mm-powered";
629
+ const text = document.createElement("span");
630
+ text.textContent = checkout.t("poweredBy");
631
+ const logo = document.createElement("img");
632
+ logo.src = logoUrl;
633
+ logo.alt = "";
634
+ logo.className = "mm-powered-logo";
635
+ const brand = document.createElement("strong");
636
+ brand.className = "mm-powered-brand";
637
+ brand.textContent = "MainMoney";
638
+ powered.append(text, logo, brand);
639
+ row.append(language, powered);
640
+ return row;
641
+ }
642
+ function footer(checkout, links) {
643
+ const wrap = document.createElement("div");
644
+ wrap.className = "mm-footer";
645
+ const copyright = document.createElement("div");
646
+ copyright.className = "mm-copyright";
647
+ copyright.textContent = `\xA9 ${(/* @__PURE__ */ new Date()).getFullYear()} MainMoney. ${checkout.t("rights")}`;
648
+ wrap.append(copyright);
649
+ const nav = document.createElement("nav");
650
+ nav.className = "mm-footer-links";
651
+ for (const key of FOOTER_LINK_KEYS) {
652
+ const href = links[key];
653
+ if (href === void 0 || href === "") {
654
+ continue;
655
+ }
656
+ const anchor = document.createElement("a");
657
+ anchor.href = href;
658
+ anchor.target = "_blank";
659
+ anchor.rel = "noopener noreferrer";
660
+ anchor.textContent = checkout.t(key);
661
+ nav.append(anchor);
662
+ }
663
+ if (nav.childElementCount > 0) {
664
+ wrap.append(nav);
665
+ }
666
+ return wrap;
667
+ }
668
+ function tabs(checkout, state) {
669
+ const row = document.createElement("div");
670
+ row.className = "mm-tabs";
671
+ row.setAttribute("role", "tablist");
672
+ for (const method of TAB_ORDER.filter((item) => state.paymentMethods.includes(item))) {
673
+ const tab = document.createElement("button");
674
+ tab.type = "button";
675
+ tab.className = "mm-tab";
676
+ tab.setAttribute("role", "tab");
677
+ tab.setAttribute("aria-selected", String(state.activeMethod === method));
678
+ tab.textContent = checkout.t(TAB_LABEL_KEYS[method]);
679
+ if (state.activeMethod === method) {
680
+ tab.classList.add("is-active");
681
+ }
682
+ tab.addEventListener("click", () => checkout.setMethod(method));
683
+ row.append(tab);
684
+ }
685
+ return row;
686
+ }
687
+ function mobileMoneyPane(checkout, state) {
688
+ const pane = document.createElement("div");
689
+ pane.className = "mm-pane";
690
+ pane.append(emailField(checkout, state));
691
+ pane.append(phoneField(checkout, state));
692
+ if (!state.lockAmount || state.amount === "") {
693
+ pane.append(amountField(checkout, state));
694
+ }
695
+ pane.append(feeBox(checkout, state));
696
+ pane.append(providerLogos(checkout, state));
697
+ appendError(pane, state);
698
+ return pane;
699
+ }
700
+ function placeholderPane(message) {
701
+ const pane = document.createElement("div");
702
+ pane.className = "mm-pane mm-placeholder";
703
+ pane.textContent = message;
704
+ return pane;
705
+ }
706
+ function qrPane(message) {
707
+ const pane = document.createElement("div");
708
+ pane.className = "mm-pane mm-placeholder mm-qr";
709
+ const frame = document.createElement("div");
710
+ frame.className = "mm-qr-frame";
711
+ frame.setAttribute("aria-hidden", "true");
712
+ const text = document.createElement("p");
713
+ text.textContent = message;
714
+ pane.append(frame, text);
715
+ return pane;
716
+ }
717
+ function floatingField(labelText, control, hint) {
718
+ const wrap = document.createElement("div");
719
+ wrap.className = "mm-floating";
720
+ const box = document.createElement("div");
721
+ box.className = "mm-floating-box";
722
+ const label2 = document.createElement("span");
723
+ label2.className = "mm-floating-label";
724
+ label2.textContent = labelText;
725
+ box.append(label2, control);
726
+ wrap.append(box);
727
+ if (hint !== void 0) {
728
+ const note = document.createElement("p");
729
+ note.className = "mm-hint";
730
+ note.textContent = hint;
731
+ wrap.append(note);
732
+ }
733
+ return wrap;
734
+ }
735
+ function emailField(checkout, state) {
736
+ const input = document.createElement("input");
737
+ input.className = "mm-input mm-input-bare";
738
+ input.type = "email";
739
+ input.autocomplete = "email";
740
+ input.placeholder = checkout.t("emailPlaceholder");
741
+ input.value = state.customerEmail;
742
+ input.addEventListener("input", () => checkout.setCustomerEmail(input.value));
743
+ return floatingField(checkout.t("emailLabel"), input, checkout.t("emailHint"));
744
+ }
745
+ function phoneField(checkout, state) {
746
+ const row = document.createElement("div");
747
+ row.className = "mm-phone-row";
748
+ const flag = document.createElement("span");
749
+ flag.className = "mm-flag";
750
+ flag.append(flagNode(state.selectedCountry));
751
+ const dial = document.createElement("select");
752
+ dial.className = "mm-dial";
753
+ dial.setAttribute("aria-label", checkout.t("country"));
754
+ for (const country of state.countries) {
755
+ if (country.phone_code === void 0 || country.phone_code === "") {
756
+ continue;
757
+ }
758
+ const option = document.createElement("option");
759
+ option.value = country.code;
760
+ option.textContent = `+${country.phone_code}`;
761
+ option.title = country.name;
762
+ option.selected = state.selectedCountry?.code === country.code;
763
+ dial.append(option);
764
+ }
765
+ dial.addEventListener("change", () => {
766
+ void checkout.selectCountry(dial.value).catch(() => void 0);
767
+ });
768
+ const divider = document.createElement("span");
769
+ divider.className = "mm-phone-divider";
770
+ const input = document.createElement("input");
771
+ input.className = "mm-input mm-input-bare";
772
+ input.type = "tel";
773
+ input.inputMode = "tel";
774
+ input.autocomplete = "tel-national";
775
+ input.placeholder = "812345678";
776
+ input.value = state.identifier;
777
+ input.addEventListener("input", () => {
778
+ checkout.setIdentifier(input.value);
779
+ refreshPayButton(checkout, input);
780
+ });
781
+ input.addEventListener("blur", () => {
782
+ void checkout.matchProvider().catch(() => void 0);
783
+ });
784
+ row.append(flag, dial, divider, input);
785
+ return floatingField(checkout.t("phone"), row, checkout.t("phoneHint"));
786
+ }
787
+ function amountField(checkout, state) {
788
+ const row = document.createElement("div");
789
+ row.className = "mm-amount-row";
790
+ const input = document.createElement("input");
791
+ input.className = "mm-input mm-input-bare";
792
+ input.inputMode = "decimal";
793
+ input.value = state.amount;
794
+ input.disabled = state.lockAmount;
795
+ input.addEventListener("input", () => refreshPayButton(checkout, input));
796
+ input.addEventListener("change", () => {
797
+ void checkout.setAmount(input.value).catch(() => void 0);
798
+ });
799
+ row.append(input);
800
+ if (state.lockCurrency || state.availableCurrencies.length <= 1) {
801
+ const badge = document.createElement("span");
802
+ badge.className = "mm-currency-suffix";
803
+ badge.textContent = state.currency;
804
+ row.append(badge);
805
+ } else {
806
+ const select = document.createElement("select");
807
+ select.className = "mm-currency-suffix mm-select";
808
+ for (const code of state.availableCurrencies) {
809
+ const option = document.createElement("option");
810
+ option.value = code;
811
+ option.textContent = code;
812
+ option.selected = state.currency === code;
813
+ select.append(option);
814
+ }
815
+ select.addEventListener("change", () => {
816
+ void checkout.setCurrency(select.value).catch(() => void 0);
817
+ });
818
+ row.append(select);
819
+ }
820
+ return floatingField(checkout.t("amount"), row);
821
+ }
822
+ function feeBox(checkout, state) {
823
+ const box = document.createElement("div");
824
+ box.className = "mm-fee-box";
825
+ const q = quote(state);
826
+ box.append(feeRow(checkout.t("merchantReceives"), formatMoney(q.receives, state)));
827
+ box.append(feeRow(checkout.t("processingFee"), formatMoney(q.fee, state)));
828
+ const total = feeRow(checkout.t("youPay"), formatMoney(q.pay, state));
829
+ total.classList.add("mm-fee-total");
830
+ box.append(total);
831
+ return box;
832
+ }
833
+ function feeRow(labelText, value) {
834
+ const row = document.createElement("div");
835
+ row.className = "mm-fee-row";
836
+ const label2 = document.createElement("span");
837
+ label2.textContent = labelText;
838
+ const amount = document.createElement("span");
839
+ amount.textContent = value;
840
+ row.append(label2, amount);
841
+ return row;
842
+ }
843
+ function providerLogos(checkout, state) {
844
+ const wrap = document.createElement("div");
845
+ wrap.className = "mm-providers";
846
+ if (state.providers.length === 0) {
847
+ const empty = document.createElement("p");
848
+ empty.className = "mm-hint";
849
+ empty.textContent = state.selectedCountry === void 0 ? "" : checkout.t("noProviders");
850
+ wrap.append(empty);
851
+ return wrap;
852
+ }
853
+ for (const provider of state.providers) {
854
+ wrap.append(providerChip(checkout, state, provider));
855
+ }
856
+ return wrap;
857
+ }
858
+ function providerChip(checkout, state, provider) {
859
+ const chip = document.createElement("button");
860
+ chip.type = "button";
861
+ chip.className = "mm-provider-chip";
862
+ chip.title = provider.name;
863
+ chip.setAttribute("aria-label", provider.name);
864
+ chip.setAttribute("aria-pressed", String(state.selectedProvider?.code === provider.code));
865
+ if (state.selectedProvider?.code === provider.code) {
866
+ chip.classList.add("is-selected");
867
+ }
868
+ if (provider.logo) {
869
+ const img = document.createElement("img");
870
+ img.src = provider.logo;
871
+ img.alt = provider.name;
872
+ img.loading = "lazy";
873
+ chip.append(img);
874
+ } else {
875
+ chip.textContent = provider.name;
876
+ }
877
+ chip.addEventListener("click", () => {
878
+ void checkout.selectProvider(provider.code).catch(() => void 0);
879
+ });
880
+ return chip;
881
+ }
882
+ function payButton(checkout, state) {
883
+ const button = document.createElement("button");
884
+ button.type = "button";
885
+ button.className = "mm-pay";
886
+ applyPayState(button, checkout, state);
887
+ button.addEventListener("click", () => {
888
+ void checkout.pay().catch(() => void 0);
889
+ });
890
+ return button;
891
+ }
892
+ function applyPayState(button, checkout, state) {
893
+ const ready = state.canPay;
894
+ button.disabled = !ready;
895
+ const total = ready ? formatMoney(quote(state).pay, state) : "\u2014";
896
+ button.textContent = `${checkout.t("pay")} ${total}`;
897
+ }
898
+ function refreshPayButton(checkout, from) {
899
+ const button = from.closest(".mm-form")?.querySelector(".mm-pay") ?? null;
900
+ if (button !== null) {
901
+ applyPayState(button, checkout, checkout.getState());
902
+ }
903
+ }
904
+ function quote(state) {
905
+ const amount = state.amount.trim() === "" ? null : state.amount;
906
+ const fees = state.fees;
907
+ return {
908
+ receives: fees?.merchant_receives ?? amount,
909
+ fee: fees?.processing_fee ?? null,
910
+ pay: fees?.total_to_pay ?? amount
911
+ };
912
+ }
913
+ function formatMoney(value, state) {
914
+ if (value === null || value === "" || state.currency === "") {
915
+ return "\u2014";
916
+ }
917
+ const number = Number(value);
918
+ if (!Number.isFinite(number)) {
919
+ return "\u2014";
920
+ }
921
+ try {
922
+ return new Intl.NumberFormat(state.locale, { style: "currency", currency: state.currency }).format(number);
923
+ } catch {
924
+ return `${number.toFixed(2)} ${state.currency}`;
925
+ }
926
+ }
927
+ function flagNode(country) {
928
+ if (country?.flag) {
929
+ const img = document.createElement("img");
930
+ img.src = country.flag;
931
+ img.alt = country.name;
932
+ img.className = "mm-flag-image";
933
+ return img;
934
+ }
935
+ return document.createTextNode(flagEmoji(country?.code));
936
+ }
937
+ function flagEmoji(code) {
938
+ if (code === void 0 || !/^[A-Za-z]{2}$/.test(code)) {
939
+ return "";
940
+ }
941
+ return [...code.toUpperCase()].map((char) => String.fromCodePoint(127462 + char.charCodeAt(0) - 65)).join("");
942
+ }
943
+ function appendError(parent, state) {
944
+ if (state.error === void 0 || state.error === "") {
945
+ return;
946
+ }
947
+ const error = document.createElement("div");
948
+ error.className = "mm-error";
949
+ error.setAttribute("role", "alert");
950
+ error.textContent = state.error;
951
+ parent.append(error);
952
+ }
953
+
954
+ // src/mount.ts
955
+ function mountCheckout(element, checkout, options = {}) {
956
+ const logoUrl = options.logoUrl ?? DEFAULT_LOGO_URL;
957
+ const useForm = (state) => (options.layout ?? (state.operation === "deposit" ? "form" : "wizard")) === "form";
958
+ let preselecting = false;
959
+ const renderForm = (state) => {
960
+ if (state.step === "country" && state.countries.length > 0 && !preselecting) {
961
+ preselecting = true;
962
+ const preferred = state.countries.find((country) => country.code === options.defaultCountry) ?? state.countries[0];
963
+ void checkout.selectCountry(preferred.code).catch(() => void 0).finally(() => {
964
+ preselecting = false;
965
+ });
966
+ }
967
+ let body;
968
+ if (state.step === "confirming" || state.step === "polling") {
969
+ body = confirmingStep(checkout, state, logoUrl);
970
+ } else if (state.step === "ongoing") {
971
+ body = messageStep(checkout.t("ongoing"));
972
+ } else if (state.step === "terminal") {
973
+ const status = state.status?.status ?? "";
974
+ body = messageStep(status.toUpperCase() === "SUCCESS" ? checkout.t("success") : checkout.t("failed"));
975
+ } else {
976
+ body = formBody(checkout, state);
977
+ }
978
+ element.append(formChrome(checkout, state, logoUrl, options.links ?? {}, body));
979
+ };
980
+ const render = (state) => {
981
+ applyTheme(element, state.theme);
982
+ element.classList.add("mm-checkout");
983
+ element.innerHTML = "";
984
+ if (useForm(state)) {
985
+ element.classList.add("mm-checkout-form");
986
+ renderForm(state);
987
+ return;
988
+ }
989
+ element.classList.remove("mm-checkout-form");
990
+ if (state.step === "country") {
991
+ element.append(countryStep(checkout, state));
992
+ } else if (state.step === "details") {
993
+ element.append(detailsStep(checkout, state));
994
+ } else if (state.step === "overview") {
995
+ element.append(overviewStep(checkout, state));
996
+ } else if (state.step === "confirming" || state.step === "polling") {
997
+ element.append(confirmingStep(checkout, state, logoUrl));
998
+ } else if (state.step === "ongoing") {
999
+ element.append(messageStep(checkout.t("ongoing")));
1000
+ } else {
1001
+ const status = state.status?.status ?? "";
1002
+ element.append(messageStep(status.toUpperCase() === "SUCCESS" ? checkout.t("success") : checkout.t("failed")));
1003
+ }
1004
+ appendError2(element, state);
1005
+ };
1006
+ render(checkout.getState());
1007
+ return checkout.subscribe(render);
1008
+ }
1009
+ function countryStep(checkout, state) {
1010
+ const wrap = document.createElement("div");
1011
+ wrap.append(label(checkout.t("country")));
1012
+ const select = document.createElement("select");
1013
+ select.className = "mm-select";
1014
+ const placeholder = document.createElement("option");
1015
+ placeholder.value = "";
1016
+ placeholder.textContent = checkout.t("selectCountry");
1017
+ select.append(placeholder);
1018
+ for (const country of state.countries) {
1019
+ const option = document.createElement("option");
1020
+ option.value = country.code;
1021
+ option.textContent = country.name;
1022
+ if (state.selectedCountry?.code === country.code) {
1023
+ option.selected = true;
1024
+ }
1025
+ select.append(option);
1026
+ }
1027
+ select.addEventListener("change", () => {
1028
+ if (select.value !== "") {
1029
+ run(() => checkout.selectCountry(select.value));
1030
+ }
1031
+ });
1032
+ wrap.append(select);
1033
+ return wrap;
1034
+ }
1035
+ function detailsStep(checkout, state) {
1036
+ const wrap = document.createElement("div");
1037
+ const phone = isPhoneIdentifier2(state.selectedProvider);
1038
+ wrap.append(providerList(checkout, state));
1039
+ wrap.append(identifierField(checkout, state, phone));
1040
+ if (state.customerName !== null) {
1041
+ wrap.append(overviewRow(checkout.t("customerName"), state.customerName));
1042
+ }
1043
+ wrap.append(amountField2(checkout, state));
1044
+ wrap.append(actions(checkout, () => run(() => checkout.goOverview()), checkout.t("next"), true));
1045
+ return wrap;
1046
+ }
1047
+ function overviewStep(checkout, state) {
1048
+ const wrap = document.createElement("div");
1049
+ const phone = isPhoneIdentifier2(state.selectedProvider);
1050
+ wrap.append(overviewRow(checkout.t("country"), state.selectedCountry?.name ?? ""));
1051
+ wrap.append(overviewRow(checkout.t("provider"), state.selectedProvider?.name ?? ""));
1052
+ wrap.append(overviewRow(phone ? checkout.t("phone") : checkout.t("account"), state.identifier));
1053
+ if (state.customerName !== null) {
1054
+ wrap.append(overviewRow(checkout.t("customerName"), state.customerName));
1055
+ }
1056
+ wrap.append(overviewRow(checkout.t("amount"), `${state.amount} ${state.currency}`));
1057
+ if (state.fees !== void 0) {
1058
+ wrap.append(overviewRow(checkout.t("fees"), `${state.fees.total_merchant_fee} ${state.currency}`));
1059
+ wrap.append(overviewRow(checkout.t("netAmount"), `${state.fees.net_amount} ${state.currency}`));
1060
+ }
1061
+ if (state.partnerFee !== null) {
1062
+ wrap.append(
1063
+ overviewRow(state.partnerFee.label ?? checkout.t("partnerFee"), `${state.partnerFee.amount} ${state.partnerFee.currency}`)
1064
+ );
1065
+ }
1066
+ wrap.append(actions(checkout, () => run(() => checkout.confirm()), checkout.t("confirm"), true));
1067
+ return wrap;
1068
+ }
1069
+ function confirmingStep(checkout, state, logoUrl) {
1070
+ const wrap = document.createElement("div");
1071
+ wrap.className = "mm-confirm";
1072
+ const spinner = document.createElement("div");
1073
+ spinner.className = "mm-spinner";
1074
+ const curveA = document.createElement("div");
1075
+ curveA.className = "mm-spinner-curve";
1076
+ const curveB = document.createElement("div");
1077
+ curveB.className = "mm-spinner-curve";
1078
+ const logo = document.createElement("img");
1079
+ logo.className = "mm-spinner-logo";
1080
+ logo.alt = "MainMoney";
1081
+ logo.src = logoUrl;
1082
+ spinner.append(curveA, curveB, logo);
1083
+ const caption = document.createElement("div");
1084
+ caption.textContent = state.step === "polling" ? checkout.t("polling") : checkout.t("confirming");
1085
+ wrap.append(spinner, caption);
1086
+ return wrap;
1087
+ }
1088
+ function messageStep(text) {
1089
+ const wrap = document.createElement("div");
1090
+ wrap.className = "mm-confirm";
1091
+ wrap.textContent = text;
1092
+ return wrap;
1093
+ }
1094
+ function providerList(checkout, state) {
1095
+ const wrap = document.createElement("div");
1096
+ wrap.append(label(checkout.t("provider")));
1097
+ for (const provider of state.providers) {
1098
+ const row = document.createElement("button");
1099
+ row.type = "button";
1100
+ row.className = "mm-provider";
1101
+ if (state.selectedProvider?.code === provider.code) {
1102
+ row.classList.add("is-selected");
1103
+ }
1104
+ if (state.highlightedProviderCode === provider.code) {
1105
+ row.classList.add("is-highlighted");
1106
+ }
1107
+ row.textContent = provider.name;
1108
+ if (state.highlightedProviderCode === provider.code) {
1109
+ const badge = document.createElement("span");
1110
+ badge.className = "mm-badge";
1111
+ badge.textContent = checkout.t("highlighted");
1112
+ row.append(badge);
1113
+ }
1114
+ row.addEventListener("click", () => {
1115
+ run(() => checkout.selectProvider(provider.code));
1116
+ });
1117
+ wrap.append(row);
1118
+ }
1119
+ return wrap;
1120
+ }
1121
+ function identifierField(checkout, state, phone) {
1122
+ const field = document.createElement("div");
1123
+ field.className = "mm-field";
1124
+ field.append(label(phone ? checkout.t("phone") : checkout.t("account")));
1125
+ const input = document.createElement("input");
1126
+ input.className = "mm-input";
1127
+ input.value = state.identifier;
1128
+ input.addEventListener("input", () => checkout.setIdentifier(input.value));
1129
+ input.addEventListener("blur", () => {
1130
+ run(() => checkout.matchProvider());
1131
+ });
1132
+ if (phone && state.selectedCountry?.phone_code) {
1133
+ const row = document.createElement("div");
1134
+ row.className = "mm-phone";
1135
+ const prefix = document.createElement("div");
1136
+ prefix.className = "mm-phone-prefix";
1137
+ prefix.textContent = `+${state.selectedCountry.phone_code}`;
1138
+ row.append(prefix, input);
1139
+ field.append(row);
1140
+ } else {
1141
+ field.append(input);
1142
+ }
1143
+ return field;
1144
+ }
1145
+ function amountField2(checkout, state) {
1146
+ const field = document.createElement("div");
1147
+ field.className = "mm-field";
1148
+ field.append(label(checkout.t("amount")));
1149
+ const row = document.createElement("div");
1150
+ row.className = "mm-amount-row";
1151
+ const input = document.createElement("input");
1152
+ input.className = "mm-input";
1153
+ input.value = state.amount;
1154
+ input.inputMode = "decimal";
1155
+ if (state.lockAmount) {
1156
+ input.disabled = true;
1157
+ input.readOnly = true;
1158
+ } else {
1159
+ input.addEventListener("change", () => {
1160
+ run(() => checkout.setAmount(input.value));
1161
+ });
1162
+ }
1163
+ row.append(input);
1164
+ row.append(currencySuffix(checkout, state));
1165
+ field.append(row);
1166
+ return field;
1167
+ }
1168
+ function currencySuffix(checkout, state) {
1169
+ if (state.lockCurrency) {
1170
+ const badge = document.createElement("div");
1171
+ badge.className = "mm-currency-suffix";
1172
+ badge.textContent = state.currency;
1173
+ return badge;
1174
+ }
1175
+ const select = document.createElement("select");
1176
+ select.className = "mm-currency-suffix mm-select";
1177
+ for (const code of state.availableCurrencies) {
1178
+ const option = document.createElement("option");
1179
+ option.value = code;
1180
+ option.textContent = code;
1181
+ if (state.currency === code) {
1182
+ option.selected = true;
1183
+ }
1184
+ select.append(option);
1185
+ }
1186
+ select.addEventListener("change", () => {
1187
+ if (select.value !== "") {
1188
+ run(() => checkout.setCurrency(select.value));
1189
+ }
1190
+ });
1191
+ return select;
1192
+ }
1193
+ function overviewRow(labelText, value) {
1194
+ const row = document.createElement("div");
1195
+ row.className = "mm-overview-row";
1196
+ const left = document.createElement("span");
1197
+ left.textContent = labelText;
1198
+ const right = document.createElement("span");
1199
+ right.textContent = value;
1200
+ row.append(left, right);
1201
+ return row;
1202
+ }
1203
+ function actions(checkout, onPrimary, primaryLabel, showBack) {
1204
+ const row = document.createElement("div");
1205
+ row.className = "mm-actions";
1206
+ if (showBack) {
1207
+ const back = document.createElement("button");
1208
+ back.type = "button";
1209
+ back.className = "mm-button mm-button-secondary";
1210
+ back.textContent = checkout.t("back");
1211
+ back.addEventListener("click", () => checkout.goBack());
1212
+ row.append(back);
1213
+ }
1214
+ const primary = document.createElement("button");
1215
+ primary.type = "button";
1216
+ primary.className = "mm-button mm-button-primary";
1217
+ primary.textContent = primaryLabel;
1218
+ primary.addEventListener("click", onPrimary);
1219
+ row.append(primary);
1220
+ return row;
1221
+ }
1222
+ function label(text) {
1223
+ const node = document.createElement("label");
1224
+ node.className = "mm-label";
1225
+ node.textContent = text;
1226
+ return node;
1227
+ }
1228
+ function appendError2(parent, state) {
1229
+ if (state.error === void 0 || state.error === "") {
1230
+ return;
1231
+ }
1232
+ const error = document.createElement("div");
1233
+ error.className = "mm-error";
1234
+ error.textContent = state.error;
1235
+ parent.append(error);
1236
+ }
1237
+ function run(op) {
1238
+ void op().catch(() => void 0);
1239
+ }
1240
+ export {
1241
+ createCheckout,
1242
+ mountCheckout,
1243
+ pollStatus,
1244
+ toE164Digits
1245
+ };