@alma/widgets 2.2.9 → 2.3.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.
Files changed (34) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/dist/raw/widgets.css +590 -0
  3. package/dist/raw/widgets.js +2616 -0
  4. package/dist/raw/widgets.js.map +1 -0
  5. package/dist/raw/widgets.m.js +2622 -0
  6. package/dist/raw/widgets.m.js.map +1 -0
  7. package/dist/raw/widgets.modern.js +2521 -0
  8. package/dist/raw/widgets.modern.js.map +1 -0
  9. package/dist/raw/widgets.umd.js +18494 -0
  10. package/dist/raw/widgets.umd.js.map +1 -0
  11. package/dist/types/Widgets/EligibilityModal/DesktopModal/index.d.ts +1 -8
  12. package/dist/types/Widgets/EligibilityModal/MobileModal/index.d.ts +1 -8
  13. package/dist/types/Widgets/EligibilityModal/ModalContainer.d.ts +13 -0
  14. package/dist/types/Widgets/{button.test.d.ts → EligibilityModal/ModalContainer.test.d.ts} +0 -0
  15. package/dist/types/Widgets/EligibilityModal/index.d.ts +2 -1
  16. package/dist/types/Widgets/PaymentPlans/PaymentPlans.test.d.ts +1 -0
  17. package/dist/types/Widgets/{PaymentPlan.d.ts → PaymentPlans/index.d.ts} +3 -2
  18. package/dist/types/Widgets/PaymentPlans/tests/SuggestedPaymentPlan.d.ts +1 -0
  19. package/dist/types/components/LoadingIndicator/index.d.ts +5 -0
  20. package/dist/types/hooks/useFetchEligibility.d.ts +2 -2
  21. package/dist/types/index.d.ts +1 -0
  22. package/dist/types/types.d.ts +12 -5
  23. package/dist/types/utils/merchantOrderPreferences.d.ts +14 -0
  24. package/dist/types/widgets_controller.d.ts +7 -2
  25. package/dist/widgets.css +9 -7
  26. package/dist/widgets.js +1 -1
  27. package/dist/widgets.js.map +1 -1
  28. package/dist/widgets.m.js +1 -1
  29. package/dist/widgets.m.js.map +1 -1
  30. package/dist/widgets.modern.js +1 -1
  31. package/dist/widgets.modern.js.map +1 -1
  32. package/dist/widgets.umd.js +1 -1
  33. package/dist/widgets.umd.js.map +1 -1
  34. package/package.json +4 -2
@@ -0,0 +1,2616 @@
1
+ function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
2
+
3
+ var React = require('react');
4
+ var React__default = _interopDefault(React);
5
+ var reactIntl = require('react-intl');
6
+ var reactDom = require('react-dom');
7
+ var cx = _interopDefault(require('classnames'));
8
+ var Modal = _interopDefault(require('react-modal'));
9
+ var noScroll = _interopDefault(require('no-scroll'));
10
+ var reactResponsive = require('react-responsive');
11
+ var dateFns = require('date-fns');
12
+
13
+ var ceil = Math.ceil;
14
+ var floor = Math.floor; // `ToInteger` abstract operation
15
+ // https://tc39.github.io/ecma262/#sec-tointeger
16
+
17
+ var toInteger = function (argument) {
18
+ return isNaN(argument = +argument) ? 0 : (argument > 0 ? floor : ceil)(argument);
19
+ };
20
+
21
+ // `RequireObjectCoercible` abstract operation
22
+ // https://tc39.github.io/ecma262/#sec-requireobjectcoercible
23
+ var requireObjectCoercible = function (it) {
24
+ if (it == undefined) throw TypeError("Can't call method on " + it);
25
+ return it;
26
+ };
27
+
28
+ var createMethod = function (CONVERT_TO_STRING) {
29
+ return function ($this, pos) {
30
+ var S = String(requireObjectCoercible($this));
31
+ var position = toInteger(pos);
32
+ var size = S.length;
33
+ var first, second;
34
+ if (position < 0 || position >= size) return CONVERT_TO_STRING ? '' : undefined;
35
+ first = S.charCodeAt(position);
36
+ return first < 0xD800 || first > 0xDBFF || position + 1 === size || (second = S.charCodeAt(position + 1)) < 0xDC00 || second > 0xDFFF ? CONVERT_TO_STRING ? S.charAt(position) : first : CONVERT_TO_STRING ? S.slice(position, position + 2) : (first - 0xD800 << 10) + (second - 0xDC00) + 0x10000;
37
+ };
38
+ };
39
+
40
+ var stringMultibyte = {
41
+ // `String.prototype.codePointAt` method
42
+ // https://tc39.github.io/ecma262/#sec-string.prototype.codepointat
43
+ codeAt: createMethod(false),
44
+ // `String.prototype.at` method
45
+ // https://github.com/mathiasbynens/String.prototype.at
46
+ charAt: createMethod(true)
47
+ };
48
+
49
+ var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
50
+
51
+ function createCommonjsModule(fn, basedir, module) {
52
+ return module = {
53
+ path: basedir,
54
+ exports: {},
55
+ require: function (path, base) {
56
+ return commonjsRequire();
57
+ }
58
+ }, fn(module, module.exports), module.exports;
59
+ }
60
+
61
+ function commonjsRequire () {
62
+ throw new Error('Dynamic requires are not currently supported by @rollup/plugin-commonjs');
63
+ }
64
+
65
+ var check = function (it) {
66
+ return it && it.Math == Math && it;
67
+ }; // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
68
+
69
+
70
+ var global_1 = // eslint-disable-next-line no-undef
71
+ check(typeof globalThis == 'object' && globalThis) || check(typeof window == 'object' && window) || check(typeof self == 'object' && self) || check(typeof commonjsGlobal == 'object' && commonjsGlobal) || // eslint-disable-next-line no-new-func
72
+ function () {
73
+ return this;
74
+ }() || Function('return this')();
75
+
76
+ var fails = function (exec) {
77
+ try {
78
+ return !!exec();
79
+ } catch (error) {
80
+ return true;
81
+ }
82
+ };
83
+
84
+ var descriptors = !fails(function () {
85
+ return Object.defineProperty({}, 1, {
86
+ get: function () {
87
+ return 7;
88
+ }
89
+ })[1] != 7;
90
+ });
91
+
92
+ var isObject = function (it) {
93
+ return typeof it === 'object' ? it !== null : typeof it === 'function';
94
+ };
95
+
96
+ var document$1 = global_1.document; // typeof document.createElement is 'object' in old IE
97
+
98
+ var EXISTS = isObject(document$1) && isObject(document$1.createElement);
99
+
100
+ var documentCreateElement = function (it) {
101
+ return EXISTS ? document$1.createElement(it) : {};
102
+ };
103
+
104
+ var ie8DomDefine = !descriptors && !fails(function () {
105
+ return Object.defineProperty(documentCreateElement('div'), 'a', {
106
+ get: function () {
107
+ return 7;
108
+ }
109
+ }).a != 7;
110
+ });
111
+
112
+ var anObject = function (it) {
113
+ if (!isObject(it)) {
114
+ throw TypeError(String(it) + ' is not an object');
115
+ }
116
+
117
+ return it;
118
+ };
119
+
120
+ // https://tc39.github.io/ecma262/#sec-toprimitive
121
+ // instead of the ES6 spec version, we didn't implement @@toPrimitive case
122
+ // and the second argument - flag - preferred type is a string
123
+
124
+ var toPrimitive = function (input, PREFERRED_STRING) {
125
+ if (!isObject(input)) return input;
126
+ var fn, val;
127
+ if (PREFERRED_STRING && typeof (fn = input.toString) == 'function' && !isObject(val = fn.call(input))) return val;
128
+ if (typeof (fn = input.valueOf) == 'function' && !isObject(val = fn.call(input))) return val;
129
+ if (!PREFERRED_STRING && typeof (fn = input.toString) == 'function' && !isObject(val = fn.call(input))) return val;
130
+ throw TypeError("Can't convert object to primitive value");
131
+ };
132
+
133
+ var nativeDefineProperty = Object.defineProperty; // `Object.defineProperty` method
134
+ // https://tc39.github.io/ecma262/#sec-object.defineproperty
135
+
136
+ var f = descriptors ? nativeDefineProperty : function defineProperty(O, P, Attributes) {
137
+ anObject(O);
138
+ P = toPrimitive(P, true);
139
+ anObject(Attributes);
140
+ if (ie8DomDefine) try {
141
+ return nativeDefineProperty(O, P, Attributes);
142
+ } catch (error) {
143
+ /* empty */
144
+ }
145
+ if ('get' in Attributes || 'set' in Attributes) throw TypeError('Accessors not supported');
146
+ if ('value' in Attributes) O[P] = Attributes.value;
147
+ return O;
148
+ };
149
+ var objectDefineProperty = {
150
+ f: f
151
+ };
152
+
153
+ var createPropertyDescriptor = function (bitmap, value) {
154
+ return {
155
+ enumerable: !(bitmap & 1),
156
+ configurable: !(bitmap & 2),
157
+ writable: !(bitmap & 4),
158
+ value: value
159
+ };
160
+ };
161
+
162
+ var createNonEnumerableProperty = descriptors ? function (object, key, value) {
163
+ return objectDefineProperty.f(object, key, createPropertyDescriptor(1, value));
164
+ } : function (object, key, value) {
165
+ object[key] = value;
166
+ return object;
167
+ };
168
+
169
+ var setGlobal = function (key, value) {
170
+ try {
171
+ createNonEnumerableProperty(global_1, key, value);
172
+ } catch (error) {
173
+ global_1[key] = value;
174
+ }
175
+
176
+ return value;
177
+ };
178
+
179
+ var SHARED = '__core-js_shared__';
180
+ var store = global_1[SHARED] || setGlobal(SHARED, {});
181
+ var sharedStore = store;
182
+
183
+ var functionToString = Function.toString; // this helper broken in `3.4.1-3.4.4`, so we can't use `shared` helper
184
+
185
+ if (typeof sharedStore.inspectSource != 'function') {
186
+ sharedStore.inspectSource = function (it) {
187
+ return functionToString.call(it);
188
+ };
189
+ }
190
+
191
+ var inspectSource = sharedStore.inspectSource;
192
+
193
+ var WeakMap = global_1.WeakMap;
194
+ var nativeWeakMap = typeof WeakMap === 'function' && /native code/.test(inspectSource(WeakMap));
195
+
196
+ var hasOwnProperty = {}.hasOwnProperty;
197
+
198
+ var has = function (it, key) {
199
+ return hasOwnProperty.call(it, key);
200
+ };
201
+
202
+ var shared = createCommonjsModule(function (module) {
203
+ (module.exports = function (key, value) {
204
+ return sharedStore[key] || (sharedStore[key] = value !== undefined ? value : {});
205
+ })('versions', []).push({
206
+ version: '3.8.1',
207
+ mode: 'global',
208
+ copyright: '© 2020 Denis Pushkarev (zloirock.ru)'
209
+ });
210
+ });
211
+
212
+ var id = 0;
213
+ var postfix = Math.random();
214
+
215
+ var uid = function (key) {
216
+ return 'Symbol(' + String(key === undefined ? '' : key) + ')_' + (++id + postfix).toString(36);
217
+ };
218
+
219
+ var keys = shared('keys');
220
+
221
+ var sharedKey = function (key) {
222
+ return keys[key] || (keys[key] = uid(key));
223
+ };
224
+
225
+ var hiddenKeys = {};
226
+
227
+ var WeakMap$1 = global_1.WeakMap;
228
+ var set, get, has$1;
229
+
230
+ var enforce = function (it) {
231
+ return has$1(it) ? get(it) : set(it, {});
232
+ };
233
+
234
+ var getterFor = function (TYPE) {
235
+ return function (it) {
236
+ var state;
237
+
238
+ if (!isObject(it) || (state = get(it)).type !== TYPE) {
239
+ throw TypeError('Incompatible receiver, ' + TYPE + ' required');
240
+ }
241
+
242
+ return state;
243
+ };
244
+ };
245
+
246
+ if (nativeWeakMap) {
247
+ var store$1 = sharedStore.state || (sharedStore.state = new WeakMap$1());
248
+ var wmget = store$1.get;
249
+ var wmhas = store$1.has;
250
+ var wmset = store$1.set;
251
+
252
+ set = function (it, metadata) {
253
+ metadata.facade = it;
254
+ wmset.call(store$1, it, metadata);
255
+ return metadata;
256
+ };
257
+
258
+ get = function (it) {
259
+ return wmget.call(store$1, it) || {};
260
+ };
261
+
262
+ has$1 = function (it) {
263
+ return wmhas.call(store$1, it);
264
+ };
265
+ } else {
266
+ var STATE = sharedKey('state');
267
+ hiddenKeys[STATE] = true;
268
+
269
+ set = function (it, metadata) {
270
+ metadata.facade = it;
271
+ createNonEnumerableProperty(it, STATE, metadata);
272
+ return metadata;
273
+ };
274
+
275
+ get = function (it) {
276
+ return has(it, STATE) ? it[STATE] : {};
277
+ };
278
+
279
+ has$1 = function (it) {
280
+ return has(it, STATE);
281
+ };
282
+ }
283
+
284
+ var internalState = {
285
+ set: set,
286
+ get: get,
287
+ has: has$1,
288
+ enforce: enforce,
289
+ getterFor: getterFor
290
+ };
291
+
292
+ var nativePropertyIsEnumerable = {}.propertyIsEnumerable;
293
+ var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; // Nashorn ~ JDK8 bug
294
+
295
+ var NASHORN_BUG = getOwnPropertyDescriptor && !nativePropertyIsEnumerable.call({
296
+ 1: 2
297
+ }, 1); // `Object.prototype.propertyIsEnumerable` method implementation
298
+ // https://tc39.github.io/ecma262/#sec-object.prototype.propertyisenumerable
299
+
300
+ var f$1 = NASHORN_BUG ? function propertyIsEnumerable(V) {
301
+ var descriptor = getOwnPropertyDescriptor(this, V);
302
+ return !!descriptor && descriptor.enumerable;
303
+ } : nativePropertyIsEnumerable;
304
+ var objectPropertyIsEnumerable = {
305
+ f: f$1
306
+ };
307
+
308
+ var toString = {}.toString;
309
+
310
+ var classofRaw = function (it) {
311
+ return toString.call(it).slice(8, -1);
312
+ };
313
+
314
+ var split = ''.split; // fallback for non-array-like ES3 and non-enumerable old V8 strings
315
+
316
+ var indexedObject = fails(function () {
317
+ // throws an error in rhino, see https://github.com/mozilla/rhino/issues/346
318
+ // eslint-disable-next-line no-prototype-builtins
319
+ return !Object('z').propertyIsEnumerable(0);
320
+ }) ? function (it) {
321
+ return classofRaw(it) == 'String' ? split.call(it, '') : Object(it);
322
+ } : Object;
323
+
324
+ var toIndexedObject = function (it) {
325
+ return indexedObject(requireObjectCoercible(it));
326
+ };
327
+
328
+ var nativeGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; // `Object.getOwnPropertyDescriptor` method
329
+ // https://tc39.github.io/ecma262/#sec-object.getownpropertydescriptor
330
+
331
+ var f$2 = descriptors ? nativeGetOwnPropertyDescriptor : function getOwnPropertyDescriptor(O, P) {
332
+ O = toIndexedObject(O);
333
+ P = toPrimitive(P, true);
334
+ if (ie8DomDefine) try {
335
+ return nativeGetOwnPropertyDescriptor(O, P);
336
+ } catch (error) {
337
+ /* empty */
338
+ }
339
+ if (has(O, P)) return createPropertyDescriptor(!objectPropertyIsEnumerable.f.call(O, P), O[P]);
340
+ };
341
+ var objectGetOwnPropertyDescriptor = {
342
+ f: f$2
343
+ };
344
+
345
+ var redefine = createCommonjsModule(function (module) {
346
+ var getInternalState = internalState.get;
347
+ var enforceInternalState = internalState.enforce;
348
+ var TEMPLATE = String(String).split('String');
349
+ (module.exports = function (O, key, value, options) {
350
+ var unsafe = options ? !!options.unsafe : false;
351
+ var simple = options ? !!options.enumerable : false;
352
+ var noTargetGet = options ? !!options.noTargetGet : false;
353
+ var state;
354
+
355
+ if (typeof value == 'function') {
356
+ if (typeof key == 'string' && !has(value, 'name')) {
357
+ createNonEnumerableProperty(value, 'name', key);
358
+ }
359
+
360
+ state = enforceInternalState(value);
361
+
362
+ if (!state.source) {
363
+ state.source = TEMPLATE.join(typeof key == 'string' ? key : '');
364
+ }
365
+ }
366
+
367
+ if (O === global_1) {
368
+ if (simple) O[key] = value;else setGlobal(key, value);
369
+ return;
370
+ } else if (!unsafe) {
371
+ delete O[key];
372
+ } else if (!noTargetGet && O[key]) {
373
+ simple = true;
374
+ }
375
+
376
+ if (simple) O[key] = value;else createNonEnumerableProperty(O, key, value); // add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative
377
+ })(Function.prototype, 'toString', function toString() {
378
+ return typeof this == 'function' && getInternalState(this).source || inspectSource(this);
379
+ });
380
+ });
381
+
382
+ var path = global_1;
383
+
384
+ var aFunction = function (variable) {
385
+ return typeof variable == 'function' ? variable : undefined;
386
+ };
387
+
388
+ var getBuiltIn = function (namespace, method) {
389
+ return arguments.length < 2 ? aFunction(path[namespace]) || aFunction(global_1[namespace]) : path[namespace] && path[namespace][method] || global_1[namespace] && global_1[namespace][method];
390
+ };
391
+
392
+ var min = Math.min; // `ToLength` abstract operation
393
+ // https://tc39.github.io/ecma262/#sec-tolength
394
+
395
+ var toLength = function (argument) {
396
+ return argument > 0 ? min(toInteger(argument), 0x1FFFFFFFFFFFFF) : 0; // 2 ** 53 - 1 == 9007199254740991
397
+ };
398
+
399
+ var max = Math.max;
400
+ var min$1 = Math.min; // Helper for a popular repeating case of the spec:
401
+ // Let integer be ? ToInteger(index).
402
+ // If integer < 0, let result be max((length + integer), 0); else let result be min(integer, length).
403
+
404
+ var toAbsoluteIndex = function (index, length) {
405
+ var integer = toInteger(index);
406
+ return integer < 0 ? max(integer + length, 0) : min$1(integer, length);
407
+ };
408
+
409
+ var createMethod$1 = function (IS_INCLUDES) {
410
+ return function ($this, el, fromIndex) {
411
+ var O = toIndexedObject($this);
412
+ var length = toLength(O.length);
413
+ var index = toAbsoluteIndex(fromIndex, length);
414
+ var value; // Array#includes uses SameValueZero equality algorithm
415
+ // eslint-disable-next-line no-self-compare
416
+
417
+ if (IS_INCLUDES && el != el) while (length > index) {
418
+ value = O[index++]; // eslint-disable-next-line no-self-compare
419
+
420
+ if (value != value) return true; // Array#indexOf ignores holes, Array#includes - not
421
+ } else for (; length > index; index++) {
422
+ if ((IS_INCLUDES || index in O) && O[index] === el) return IS_INCLUDES || index || 0;
423
+ }
424
+ return !IS_INCLUDES && -1;
425
+ };
426
+ };
427
+
428
+ var arrayIncludes = {
429
+ // `Array.prototype.includes` method
430
+ // https://tc39.github.io/ecma262/#sec-array.prototype.includes
431
+ includes: createMethod$1(true),
432
+ // `Array.prototype.indexOf` method
433
+ // https://tc39.github.io/ecma262/#sec-array.prototype.indexof
434
+ indexOf: createMethod$1(false)
435
+ };
436
+
437
+ var indexOf = arrayIncludes.indexOf;
438
+
439
+ var objectKeysInternal = function (object, names) {
440
+ var O = toIndexedObject(object);
441
+ var i = 0;
442
+ var result = [];
443
+ var key;
444
+
445
+ for (key in O) !has(hiddenKeys, key) && has(O, key) && result.push(key); // Don't enum bug & hidden keys
446
+
447
+
448
+ while (names.length > i) if (has(O, key = names[i++])) {
449
+ ~indexOf(result, key) || result.push(key);
450
+ }
451
+
452
+ return result;
453
+ };
454
+
455
+ // IE8- don't enum bug keys
456
+ var enumBugKeys = ['constructor', 'hasOwnProperty', 'isPrototypeOf', 'propertyIsEnumerable', 'toLocaleString', 'toString', 'valueOf'];
457
+
458
+ var hiddenKeys$1 = enumBugKeys.concat('length', 'prototype'); // `Object.getOwnPropertyNames` method
459
+ // https://tc39.github.io/ecma262/#sec-object.getownpropertynames
460
+
461
+ var f$3 = Object.getOwnPropertyNames || function getOwnPropertyNames(O) {
462
+ return objectKeysInternal(O, hiddenKeys$1);
463
+ };
464
+
465
+ var objectGetOwnPropertyNames = {
466
+ f: f$3
467
+ };
468
+
469
+ var f$4 = Object.getOwnPropertySymbols;
470
+ var objectGetOwnPropertySymbols = {
471
+ f: f$4
472
+ };
473
+
474
+ var ownKeys = getBuiltIn('Reflect', 'ownKeys') || function ownKeys(it) {
475
+ var keys = objectGetOwnPropertyNames.f(anObject(it));
476
+ var getOwnPropertySymbols = objectGetOwnPropertySymbols.f;
477
+ return getOwnPropertySymbols ? keys.concat(getOwnPropertySymbols(it)) : keys;
478
+ };
479
+
480
+ var copyConstructorProperties = function (target, source) {
481
+ var keys = ownKeys(source);
482
+ var defineProperty = objectDefineProperty.f;
483
+ var getOwnPropertyDescriptor = objectGetOwnPropertyDescriptor.f;
484
+
485
+ for (var i = 0; i < keys.length; i++) {
486
+ var key = keys[i];
487
+ if (!has(target, key)) defineProperty(target, key, getOwnPropertyDescriptor(source, key));
488
+ }
489
+ };
490
+
491
+ var replacement = /#|\.prototype\./;
492
+
493
+ var isForced = function (feature, detection) {
494
+ var value = data[normalize(feature)];
495
+ return value == POLYFILL ? true : value == NATIVE ? false : typeof detection == 'function' ? fails(detection) : !!detection;
496
+ };
497
+
498
+ var normalize = isForced.normalize = function (string) {
499
+ return String(string).replace(replacement, '.').toLowerCase();
500
+ };
501
+
502
+ var data = isForced.data = {};
503
+ var NATIVE = isForced.NATIVE = 'N';
504
+ var POLYFILL = isForced.POLYFILL = 'P';
505
+ var isForced_1 = isForced;
506
+
507
+ var getOwnPropertyDescriptor$1 = objectGetOwnPropertyDescriptor.f;
508
+ /*
509
+ options.target - name of the target object
510
+ options.global - target is the global object
511
+ options.stat - export as static methods of target
512
+ options.proto - export as prototype methods of target
513
+ options.real - real prototype method for the `pure` version
514
+ options.forced - export even if the native feature is available
515
+ options.bind - bind methods to the target, required for the `pure` version
516
+ options.wrap - wrap constructors to preventing global pollution, required for the `pure` version
517
+ options.unsafe - use the simple assignment of property instead of delete + defineProperty
518
+ options.sham - add a flag to not completely full polyfills
519
+ options.enumerable - export as enumerable property
520
+ options.noTargetGet - prevent calling a getter on target
521
+ */
522
+
523
+ var _export = function (options, source) {
524
+ var TARGET = options.target;
525
+ var GLOBAL = options.global;
526
+ var STATIC = options.stat;
527
+ var FORCED, target, key, targetProperty, sourceProperty, descriptor;
528
+
529
+ if (GLOBAL) {
530
+ target = global_1;
531
+ } else if (STATIC) {
532
+ target = global_1[TARGET] || setGlobal(TARGET, {});
533
+ } else {
534
+ target = (global_1[TARGET] || {}).prototype;
535
+ }
536
+
537
+ if (target) for (key in source) {
538
+ sourceProperty = source[key];
539
+
540
+ if (options.noTargetGet) {
541
+ descriptor = getOwnPropertyDescriptor$1(target, key);
542
+ targetProperty = descriptor && descriptor.value;
543
+ } else targetProperty = target[key];
544
+
545
+ FORCED = isForced_1(GLOBAL ? key : TARGET + (STATIC ? '.' : '#') + key, options.forced); // contained in target
546
+
547
+ if (!FORCED && targetProperty !== undefined) {
548
+ if (typeof sourceProperty === typeof targetProperty) continue;
549
+ copyConstructorProperties(sourceProperty, targetProperty);
550
+ } // add a flag to not completely full polyfills
551
+
552
+
553
+ if (options.sham || targetProperty && targetProperty.sham) {
554
+ createNonEnumerableProperty(sourceProperty, 'sham', true);
555
+ } // extend global
556
+
557
+
558
+ redefine(target, key, sourceProperty, options);
559
+ }
560
+ };
561
+
562
+ // https://tc39.github.io/ecma262/#sec-toobject
563
+
564
+ var toObject = function (argument) {
565
+ return Object(requireObjectCoercible(argument));
566
+ };
567
+
568
+ var correctPrototypeGetter = !fails(function () {
569
+ function F() {
570
+ /* empty */
571
+ }
572
+
573
+ F.prototype.constructor = null;
574
+ return Object.getPrototypeOf(new F()) !== F.prototype;
575
+ });
576
+
577
+ var IE_PROTO = sharedKey('IE_PROTO');
578
+ var ObjectPrototype = Object.prototype; // `Object.getPrototypeOf` method
579
+ // https://tc39.github.io/ecma262/#sec-object.getprototypeof
580
+
581
+ var objectGetPrototypeOf = correctPrototypeGetter ? Object.getPrototypeOf : function (O) {
582
+ O = toObject(O);
583
+ if (has(O, IE_PROTO)) return O[IE_PROTO];
584
+
585
+ if (typeof O.constructor == 'function' && O instanceof O.constructor) {
586
+ return O.constructor.prototype;
587
+ }
588
+
589
+ return O instanceof Object ? ObjectPrototype : null;
590
+ };
591
+
592
+ var nativeSymbol = !!Object.getOwnPropertySymbols && !fails(function () {
593
+ // Chrome 38 Symbol has incorrect toString conversion
594
+ // eslint-disable-next-line no-undef
595
+ return !String(Symbol());
596
+ });
597
+
598
+ var useSymbolAsUid = nativeSymbol // eslint-disable-next-line no-undef
599
+ && !Symbol.sham // eslint-disable-next-line no-undef
600
+ && typeof Symbol.iterator == 'symbol';
601
+
602
+ var WellKnownSymbolsStore = shared('wks');
603
+ var Symbol$1 = global_1.Symbol;
604
+ var createWellKnownSymbol = useSymbolAsUid ? Symbol$1 : Symbol$1 && Symbol$1.withoutSetter || uid;
605
+
606
+ var wellKnownSymbol = function (name) {
607
+ if (!has(WellKnownSymbolsStore, name)) {
608
+ if (nativeSymbol && has(Symbol$1, name)) WellKnownSymbolsStore[name] = Symbol$1[name];else WellKnownSymbolsStore[name] = createWellKnownSymbol('Symbol.' + name);
609
+ }
610
+
611
+ return WellKnownSymbolsStore[name];
612
+ };
613
+
614
+ var ITERATOR = wellKnownSymbol('iterator');
615
+ var BUGGY_SAFARI_ITERATORS = false;
616
+
617
+ var returnThis = function () {
618
+ return this;
619
+ }; // `%IteratorPrototype%` object
620
+ // https://tc39.github.io/ecma262/#sec-%iteratorprototype%-object
621
+
622
+
623
+ var IteratorPrototype, PrototypeOfArrayIteratorPrototype, arrayIterator;
624
+
625
+ if ([].keys) {
626
+ arrayIterator = [].keys(); // Safari 8 has buggy iterators w/o `next`
627
+
628
+ if (!('next' in arrayIterator)) BUGGY_SAFARI_ITERATORS = true;else {
629
+ PrototypeOfArrayIteratorPrototype = objectGetPrototypeOf(objectGetPrototypeOf(arrayIterator));
630
+ if (PrototypeOfArrayIteratorPrototype !== Object.prototype) IteratorPrototype = PrototypeOfArrayIteratorPrototype;
631
+ }
632
+ }
633
+
634
+ if (IteratorPrototype == undefined) IteratorPrototype = {}; // 25.1.2.1.1 %IteratorPrototype%[@@iterator]()
635
+
636
+ if ( !has(IteratorPrototype, ITERATOR)) {
637
+ createNonEnumerableProperty(IteratorPrototype, ITERATOR, returnThis);
638
+ }
639
+
640
+ var iteratorsCore = {
641
+ IteratorPrototype: IteratorPrototype,
642
+ BUGGY_SAFARI_ITERATORS: BUGGY_SAFARI_ITERATORS
643
+ };
644
+
645
+ // https://tc39.github.io/ecma262/#sec-object.keys
646
+
647
+ var objectKeys = Object.keys || function keys(O) {
648
+ return objectKeysInternal(O, enumBugKeys);
649
+ };
650
+
651
+ // https://tc39.github.io/ecma262/#sec-object.defineproperties
652
+
653
+ var objectDefineProperties = descriptors ? Object.defineProperties : function defineProperties(O, Properties) {
654
+ anObject(O);
655
+ var keys = objectKeys(Properties);
656
+ var length = keys.length;
657
+ var index = 0;
658
+ var key;
659
+
660
+ while (length > index) objectDefineProperty.f(O, key = keys[index++], Properties[key]);
661
+
662
+ return O;
663
+ };
664
+
665
+ var html = getBuiltIn('document', 'documentElement');
666
+
667
+ var GT = '>';
668
+ var LT = '<';
669
+ var PROTOTYPE = 'prototype';
670
+ var SCRIPT = 'script';
671
+ var IE_PROTO$1 = sharedKey('IE_PROTO');
672
+
673
+ var EmptyConstructor = function () {
674
+ /* empty */
675
+ };
676
+
677
+ var scriptTag = function (content) {
678
+ return LT + SCRIPT + GT + content + LT + '/' + SCRIPT + GT;
679
+ }; // Create object with fake `null` prototype: use ActiveX Object with cleared prototype
680
+
681
+
682
+ var NullProtoObjectViaActiveX = function (activeXDocument) {
683
+ activeXDocument.write(scriptTag(''));
684
+ activeXDocument.close();
685
+ var temp = activeXDocument.parentWindow.Object;
686
+ activeXDocument = null; // avoid memory leak
687
+
688
+ return temp;
689
+ }; // Create object with fake `null` prototype: use iframe Object with cleared prototype
690
+
691
+
692
+ var NullProtoObjectViaIFrame = function () {
693
+ // Thrash, waste and sodomy: IE GC bug
694
+ var iframe = documentCreateElement('iframe');
695
+ var JS = 'java' + SCRIPT + ':';
696
+ var iframeDocument;
697
+ iframe.style.display = 'none';
698
+ html.appendChild(iframe); // https://github.com/zloirock/core-js/issues/475
699
+
700
+ iframe.src = String(JS);
701
+ iframeDocument = iframe.contentWindow.document;
702
+ iframeDocument.open();
703
+ iframeDocument.write(scriptTag('document.F=Object'));
704
+ iframeDocument.close();
705
+ return iframeDocument.F;
706
+ }; // Check for document.domain and active x support
707
+ // No need to use active x approach when document.domain is not set
708
+ // see https://github.com/es-shims/es5-shim/issues/150
709
+ // variation of https://github.com/kitcambridge/es5-shim/commit/4f738ac066346
710
+ // avoid IE GC bug
711
+
712
+
713
+ var activeXDocument;
714
+
715
+ var NullProtoObject = function () {
716
+ try {
717
+ /* global ActiveXObject */
718
+ activeXDocument = document.domain && new ActiveXObject('htmlfile');
719
+ } catch (error) {
720
+ /* ignore */
721
+ }
722
+
723
+ NullProtoObject = activeXDocument ? NullProtoObjectViaActiveX(activeXDocument) : NullProtoObjectViaIFrame();
724
+ var length = enumBugKeys.length;
725
+
726
+ while (length--) delete NullProtoObject[PROTOTYPE][enumBugKeys[length]];
727
+
728
+ return NullProtoObject();
729
+ };
730
+
731
+ hiddenKeys[IE_PROTO$1] = true; // `Object.create` method
732
+ // https://tc39.github.io/ecma262/#sec-object.create
733
+
734
+ var objectCreate = Object.create || function create(O, Properties) {
735
+ var result;
736
+
737
+ if (O !== null) {
738
+ EmptyConstructor[PROTOTYPE] = anObject(O);
739
+ result = new EmptyConstructor();
740
+ EmptyConstructor[PROTOTYPE] = null; // add "__proto__" for Object.getPrototypeOf polyfill
741
+
742
+ result[IE_PROTO$1] = O;
743
+ } else result = NullProtoObject();
744
+
745
+ return Properties === undefined ? result : objectDefineProperties(result, Properties);
746
+ };
747
+
748
+ var defineProperty = objectDefineProperty.f;
749
+ var TO_STRING_TAG = wellKnownSymbol('toStringTag');
750
+
751
+ var setToStringTag = function (it, TAG, STATIC) {
752
+ if (it && !has(it = STATIC ? it : it.prototype, TO_STRING_TAG)) {
753
+ defineProperty(it, TO_STRING_TAG, {
754
+ configurable: true,
755
+ value: TAG
756
+ });
757
+ }
758
+ };
759
+
760
+ var iterators = {};
761
+
762
+ var IteratorPrototype$1 = iteratorsCore.IteratorPrototype;
763
+
764
+ var returnThis$1 = function () {
765
+ return this;
766
+ };
767
+
768
+ var createIteratorConstructor = function (IteratorConstructor, NAME, next) {
769
+ var TO_STRING_TAG = NAME + ' Iterator';
770
+ IteratorConstructor.prototype = objectCreate(IteratorPrototype$1, {
771
+ next: createPropertyDescriptor(1, next)
772
+ });
773
+ setToStringTag(IteratorConstructor, TO_STRING_TAG, false);
774
+ iterators[TO_STRING_TAG] = returnThis$1;
775
+ return IteratorConstructor;
776
+ };
777
+
778
+ var aPossiblePrototype = function (it) {
779
+ if (!isObject(it) && it !== null) {
780
+ throw TypeError("Can't set " + String(it) + ' as a prototype');
781
+ }
782
+
783
+ return it;
784
+ };
785
+
786
+ // https://tc39.github.io/ecma262/#sec-object.setprototypeof
787
+ // Works with __proto__ only. Old v8 can't work with null proto objects.
788
+
789
+ /* eslint-disable no-proto */
790
+
791
+ var objectSetPrototypeOf = Object.setPrototypeOf || ('__proto__' in {} ? function () {
792
+ var CORRECT_SETTER = false;
793
+ var test = {};
794
+ var setter;
795
+
796
+ try {
797
+ setter = Object.getOwnPropertyDescriptor(Object.prototype, '__proto__').set;
798
+ setter.call(test, []);
799
+ CORRECT_SETTER = test instanceof Array;
800
+ } catch (error) {
801
+ /* empty */
802
+ }
803
+
804
+ return function setPrototypeOf(O, proto) {
805
+ anObject(O);
806
+ aPossiblePrototype(proto);
807
+ if (CORRECT_SETTER) setter.call(O, proto);else O.__proto__ = proto;
808
+ return O;
809
+ };
810
+ }() : undefined);
811
+
812
+ var IteratorPrototype$2 = iteratorsCore.IteratorPrototype;
813
+ var BUGGY_SAFARI_ITERATORS$1 = iteratorsCore.BUGGY_SAFARI_ITERATORS;
814
+ var ITERATOR$1 = wellKnownSymbol('iterator');
815
+ var KEYS = 'keys';
816
+ var VALUES = 'values';
817
+ var ENTRIES = 'entries';
818
+
819
+ var returnThis$2 = function () {
820
+ return this;
821
+ };
822
+
823
+ var defineIterator = function (Iterable, NAME, IteratorConstructor, next, DEFAULT, IS_SET, FORCED) {
824
+ createIteratorConstructor(IteratorConstructor, NAME, next);
825
+
826
+ var getIterationMethod = function (KIND) {
827
+ if (KIND === DEFAULT && defaultIterator) return defaultIterator;
828
+ if (!BUGGY_SAFARI_ITERATORS$1 && KIND in IterablePrototype) return IterablePrototype[KIND];
829
+
830
+ switch (KIND) {
831
+ case KEYS:
832
+ return function keys() {
833
+ return new IteratorConstructor(this, KIND);
834
+ };
835
+
836
+ case VALUES:
837
+ return function values() {
838
+ return new IteratorConstructor(this, KIND);
839
+ };
840
+
841
+ case ENTRIES:
842
+ return function entries() {
843
+ return new IteratorConstructor(this, KIND);
844
+ };
845
+ }
846
+
847
+ return function () {
848
+ return new IteratorConstructor(this);
849
+ };
850
+ };
851
+
852
+ var TO_STRING_TAG = NAME + ' Iterator';
853
+ var INCORRECT_VALUES_NAME = false;
854
+ var IterablePrototype = Iterable.prototype;
855
+ var nativeIterator = IterablePrototype[ITERATOR$1] || IterablePrototype['@@iterator'] || DEFAULT && IterablePrototype[DEFAULT];
856
+ var defaultIterator = !BUGGY_SAFARI_ITERATORS$1 && nativeIterator || getIterationMethod(DEFAULT);
857
+ var anyNativeIterator = NAME == 'Array' ? IterablePrototype.entries || nativeIterator : nativeIterator;
858
+ var CurrentIteratorPrototype, methods, KEY; // fix native
859
+
860
+ if (anyNativeIterator) {
861
+ CurrentIteratorPrototype = objectGetPrototypeOf(anyNativeIterator.call(new Iterable()));
862
+
863
+ if (IteratorPrototype$2 !== Object.prototype && CurrentIteratorPrototype.next) {
864
+ if ( objectGetPrototypeOf(CurrentIteratorPrototype) !== IteratorPrototype$2) {
865
+ if (objectSetPrototypeOf) {
866
+ objectSetPrototypeOf(CurrentIteratorPrototype, IteratorPrototype$2);
867
+ } else if (typeof CurrentIteratorPrototype[ITERATOR$1] != 'function') {
868
+ createNonEnumerableProperty(CurrentIteratorPrototype, ITERATOR$1, returnThis$2);
869
+ }
870
+ } // Set @@toStringTag to native iterators
871
+
872
+
873
+ setToStringTag(CurrentIteratorPrototype, TO_STRING_TAG, true);
874
+ }
875
+ } // fix Array#{values, @@iterator}.name in V8 / FF
876
+
877
+
878
+ if (DEFAULT == VALUES && nativeIterator && nativeIterator.name !== VALUES) {
879
+ INCORRECT_VALUES_NAME = true;
880
+
881
+ defaultIterator = function values() {
882
+ return nativeIterator.call(this);
883
+ };
884
+ } // define iterator
885
+
886
+
887
+ if ( IterablePrototype[ITERATOR$1] !== defaultIterator) {
888
+ createNonEnumerableProperty(IterablePrototype, ITERATOR$1, defaultIterator);
889
+ }
890
+
891
+ iterators[NAME] = defaultIterator; // export additional methods
892
+
893
+ if (DEFAULT) {
894
+ methods = {
895
+ values: getIterationMethod(VALUES),
896
+ keys: IS_SET ? defaultIterator : getIterationMethod(KEYS),
897
+ entries: getIterationMethod(ENTRIES)
898
+ };
899
+ if (FORCED) for (KEY in methods) {
900
+ if (BUGGY_SAFARI_ITERATORS$1 || INCORRECT_VALUES_NAME || !(KEY in IterablePrototype)) {
901
+ redefine(IterablePrototype, KEY, methods[KEY]);
902
+ }
903
+ } else _export({
904
+ target: NAME,
905
+ proto: true,
906
+ forced: BUGGY_SAFARI_ITERATORS$1 || INCORRECT_VALUES_NAME
907
+ }, methods);
908
+ }
909
+
910
+ return methods;
911
+ };
912
+
913
+ var charAt = stringMultibyte.charAt;
914
+ var STRING_ITERATOR = 'String Iterator';
915
+ var setInternalState = internalState.set;
916
+ var getInternalState = internalState.getterFor(STRING_ITERATOR); // `String.prototype[@@iterator]` method
917
+ // https://tc39.github.io/ecma262/#sec-string.prototype-@@iterator
918
+
919
+ defineIterator(String, 'String', function (iterated) {
920
+ setInternalState(this, {
921
+ type: STRING_ITERATOR,
922
+ string: String(iterated),
923
+ index: 0
924
+ }); // `%StringIteratorPrototype%.next` method
925
+ // https://tc39.github.io/ecma262/#sec-%stringiteratorprototype%.next
926
+ }, function next() {
927
+ var state = getInternalState(this);
928
+ var string = state.string;
929
+ var index = state.index;
930
+ var point;
931
+ if (index >= string.length) return {
932
+ value: undefined,
933
+ done: true
934
+ };
935
+ point = charAt(string, index);
936
+ state.index += point.length;
937
+ return {
938
+ value: point,
939
+ done: false
940
+ };
941
+ });
942
+
943
+ var aFunction$1 = function (it) {
944
+ if (typeof it != 'function') {
945
+ throw TypeError(String(it) + ' is not a function');
946
+ }
947
+
948
+ return it;
949
+ };
950
+
951
+ var functionBindContext = function (fn, that, length) {
952
+ aFunction$1(fn);
953
+ if (that === undefined) return fn;
954
+
955
+ switch (length) {
956
+ case 0:
957
+ return function () {
958
+ return fn.call(that);
959
+ };
960
+
961
+ case 1:
962
+ return function (a) {
963
+ return fn.call(that, a);
964
+ };
965
+
966
+ case 2:
967
+ return function (a, b) {
968
+ return fn.call(that, a, b);
969
+ };
970
+
971
+ case 3:
972
+ return function (a, b, c) {
973
+ return fn.call(that, a, b, c);
974
+ };
975
+ }
976
+
977
+ return function ()
978
+ /* ...args */
979
+ {
980
+ return fn.apply(that, arguments);
981
+ };
982
+ };
983
+
984
+ var iteratorClose = function (iterator) {
985
+ var returnMethod = iterator['return'];
986
+
987
+ if (returnMethod !== undefined) {
988
+ return anObject(returnMethod.call(iterator)).value;
989
+ }
990
+ };
991
+
992
+ var callWithSafeIterationClosing = function (iterator, fn, value, ENTRIES) {
993
+ try {
994
+ return ENTRIES ? fn(anObject(value)[0], value[1]) : fn(value); // 7.4.6 IteratorClose(iterator, completion)
995
+ } catch (error) {
996
+ iteratorClose(iterator);
997
+ throw error;
998
+ }
999
+ };
1000
+
1001
+ var ITERATOR$2 = wellKnownSymbol('iterator');
1002
+ var ArrayPrototype = Array.prototype; // check on default Array iterator
1003
+
1004
+ var isArrayIteratorMethod = function (it) {
1005
+ return it !== undefined && (iterators.Array === it || ArrayPrototype[ITERATOR$2] === it);
1006
+ };
1007
+
1008
+ var createProperty = function (object, key, value) {
1009
+ var propertyKey = toPrimitive(key);
1010
+ if (propertyKey in object) objectDefineProperty.f(object, propertyKey, createPropertyDescriptor(0, value));else object[propertyKey] = value;
1011
+ };
1012
+
1013
+ var TO_STRING_TAG$1 = wellKnownSymbol('toStringTag');
1014
+ var test = {};
1015
+ test[TO_STRING_TAG$1] = 'z';
1016
+ var toStringTagSupport = String(test) === '[object z]';
1017
+
1018
+ var TO_STRING_TAG$2 = wellKnownSymbol('toStringTag'); // ES3 wrong here
1019
+
1020
+ var CORRECT_ARGUMENTS = classofRaw(function () {
1021
+ return arguments;
1022
+ }()) == 'Arguments'; // fallback for IE11 Script Access Denied error
1023
+
1024
+ var tryGet = function (it, key) {
1025
+ try {
1026
+ return it[key];
1027
+ } catch (error) {
1028
+ /* empty */
1029
+ }
1030
+ }; // getting tag from ES6+ `Object.prototype.toString`
1031
+
1032
+
1033
+ var classof = toStringTagSupport ? classofRaw : function (it) {
1034
+ var O, tag, result;
1035
+ return it === undefined ? 'Undefined' : it === null ? 'Null' // @@toStringTag case
1036
+ : typeof (tag = tryGet(O = Object(it), TO_STRING_TAG$2)) == 'string' ? tag // builtinTag case
1037
+ : CORRECT_ARGUMENTS ? classofRaw(O) // ES3 arguments fallback
1038
+ : (result = classofRaw(O)) == 'Object' && typeof O.callee == 'function' ? 'Arguments' : result;
1039
+ };
1040
+
1041
+ var ITERATOR$3 = wellKnownSymbol('iterator');
1042
+
1043
+ var getIteratorMethod = function (it) {
1044
+ if (it != undefined) return it[ITERATOR$3] || it['@@iterator'] || iterators[classof(it)];
1045
+ };
1046
+
1047
+ // https://tc39.github.io/ecma262/#sec-array.from
1048
+
1049
+
1050
+ var arrayFrom = function from(arrayLike
1051
+ /* , mapfn = undefined, thisArg = undefined */
1052
+ ) {
1053
+ var O = toObject(arrayLike);
1054
+ var C = typeof this == 'function' ? this : Array;
1055
+ var argumentsLength = arguments.length;
1056
+ var mapfn = argumentsLength > 1 ? arguments[1] : undefined;
1057
+ var mapping = mapfn !== undefined;
1058
+ var iteratorMethod = getIteratorMethod(O);
1059
+ var index = 0;
1060
+ var length, result, step, iterator, next, value;
1061
+ if (mapping) mapfn = functionBindContext(mapfn, argumentsLength > 2 ? arguments[2] : undefined, 2); // if the target is not iterable or it's an array with the default iterator - use a simple case
1062
+
1063
+ if (iteratorMethod != undefined && !(C == Array && isArrayIteratorMethod(iteratorMethod))) {
1064
+ iterator = iteratorMethod.call(O);
1065
+ next = iterator.next;
1066
+ result = new C();
1067
+
1068
+ for (; !(step = next.call(iterator)).done; index++) {
1069
+ value = mapping ? callWithSafeIterationClosing(iterator, mapfn, [step.value, index], true) : step.value;
1070
+ createProperty(result, index, value);
1071
+ }
1072
+ } else {
1073
+ length = toLength(O.length);
1074
+ result = new C(length);
1075
+
1076
+ for (; length > index; index++) {
1077
+ value = mapping ? mapfn(O[index], index) : O[index];
1078
+ createProperty(result, index, value);
1079
+ }
1080
+ }
1081
+
1082
+ result.length = index;
1083
+ return result;
1084
+ };
1085
+
1086
+ var ITERATOR$4 = wellKnownSymbol('iterator');
1087
+ var SAFE_CLOSING = false;
1088
+
1089
+ try {
1090
+ var called = 0;
1091
+ var iteratorWithReturn = {
1092
+ next: function () {
1093
+ return {
1094
+ done: !!called++
1095
+ };
1096
+ },
1097
+ 'return': function () {
1098
+ SAFE_CLOSING = true;
1099
+ }
1100
+ };
1101
+
1102
+ iteratorWithReturn[ITERATOR$4] = function () {
1103
+ return this;
1104
+ }; // eslint-disable-next-line no-throw-literal
1105
+
1106
+
1107
+ Array.from(iteratorWithReturn, function () {
1108
+ throw 2;
1109
+ });
1110
+ } catch (error) {
1111
+ /* empty */
1112
+ }
1113
+
1114
+ var checkCorrectnessOfIteration = function (exec, SKIP_CLOSING) {
1115
+ if (!SKIP_CLOSING && !SAFE_CLOSING) return false;
1116
+ var ITERATION_SUPPORT = false;
1117
+
1118
+ try {
1119
+ var object = {};
1120
+
1121
+ object[ITERATOR$4] = function () {
1122
+ return {
1123
+ next: function () {
1124
+ return {
1125
+ done: ITERATION_SUPPORT = true
1126
+ };
1127
+ }
1128
+ };
1129
+ };
1130
+
1131
+ exec(object);
1132
+ } catch (error) {
1133
+ /* empty */
1134
+ }
1135
+
1136
+ return ITERATION_SUPPORT;
1137
+ };
1138
+
1139
+ var INCORRECT_ITERATION = !checkCorrectnessOfIteration(function (iterable) {
1140
+ Array.from(iterable);
1141
+ }); // `Array.from` method
1142
+ // https://tc39.github.io/ecma262/#sec-array.from
1143
+
1144
+ _export({
1145
+ target: 'Array',
1146
+ stat: true,
1147
+ forced: INCORRECT_ITERATION
1148
+ }, {
1149
+ from: arrayFrom
1150
+ });
1151
+
1152
+ var widgetTypes;
1153
+
1154
+ (function (widgetTypes) {
1155
+ widgetTypes["PaymentPlans"] = "PaymentPlans";
1156
+ widgetTypes["Modal"] = "Modal";
1157
+ })(widgetTypes || (widgetTypes = {}));
1158
+
1159
+ var apiStatus;
1160
+
1161
+ (function (apiStatus) {
1162
+ apiStatus["PENDING"] = "pending";
1163
+ apiStatus["SUCCESS"] = "success";
1164
+ apiStatus["FAILED"] = "failed";
1165
+ })(apiStatus || (apiStatus = {}));
1166
+
1167
+ var Locale;
1168
+
1169
+ (function (Locale) {
1170
+ Locale["en"] = "en";
1171
+ Locale["fr"] = "fr";
1172
+ Locale["de"] = "de";
1173
+ Locale["it"] = "it";
1174
+ Locale["es"] = "es";
1175
+ Locale["nl"] = "nl";
1176
+ Locale["nl-NL"] = "nl-NL";
1177
+ Locale["nl-BE"] = "nl-BE";
1178
+ })(Locale || (Locale = {}));
1179
+
1180
+ function priceToCents(price) {
1181
+ return Math.round(price * 100);
1182
+ }
1183
+ function priceFromCents(cents) {
1184
+ return Number((cents / 100).toFixed(2));
1185
+ }
1186
+ function formatCents(cents) {
1187
+ return String(priceFromCents(cents)).replace('.', ',');
1188
+ }
1189
+
1190
+ /* eslint-disable */
1191
+
1192
+ (function (ElementProto) {
1193
+ if (typeof ElementProto.matches !== 'function') {
1194
+ ElementProto.matches = ElementProto.msMatchesSelector || ElementProto.mozMatchesSelector || ElementProto.webkitMatchesSelector || function matches(selector) {
1195
+ var element = this;
1196
+ var elements = (element.document || element.ownerDocument).querySelectorAll(selector);
1197
+ var index = 0;
1198
+
1199
+ while (elements[index] && elements[index] !== element) {
1200
+ ++index;
1201
+ }
1202
+
1203
+ return Boolean(elements[index]);
1204
+ };
1205
+ }
1206
+
1207
+ if (typeof ElementProto.closest !== 'function') {
1208
+ ElementProto.closest = function closest(selector) {
1209
+ var element = this;
1210
+
1211
+ while (element && element.nodeType === 1) {
1212
+ if (element.matches(selector)) {
1213
+ return element;
1214
+ }
1215
+
1216
+ element = element.parentNode;
1217
+ }
1218
+
1219
+ return null;
1220
+ };
1221
+ }
1222
+ })(window.Element.prototype);
1223
+ /*
1224
+ * Element.prototype.classList polyfill
1225
+ */
1226
+ // 1. String.prototype.trim polyfill
1227
+
1228
+
1229
+ if (!''.trim) String.prototype.trim = function () {
1230
+ return this.replace(/^[\s]+|[\s]+$/g, '');
1231
+ };
1232
+
1233
+ (function (window) {
1234
+
1235
+ if (!window.DOMException) (DOMException = function DOMException(reason) {
1236
+ this.message = reason;
1237
+ }).prototype = new Error();
1238
+
1239
+ var wsRE = /[\11\12\14\15\40]/,
1240
+ wsIndex = 0,
1241
+ checkIfValidClassListEntry = function checkIfValidClassListEntry(O, V) {
1242
+ if (V === '') throw new DOMException("Failed to execute '" + O + "' on 'DOMTokenList': The token provided must not be empty.");
1243
+ if ((wsIndex = V.search(wsRE)) !== -1) throw new DOMException("Failed to execute '" + O + "' on 'DOMTokenList': " + "The token provided ('" + V[wsIndex] + "') contains HTML space characters, which are not valid in tokens.");
1244
+ }; // 2. Implement the barebones DOMTokenList livelyness polyfill
1245
+
1246
+
1247
+ if (typeof DOMTokenList !== 'function') (function (window) {
1248
+ var document = window.document,
1249
+ Object = window.Object,
1250
+ hasOwnProp = Object.prototype.hasOwnProperty;
1251
+ var defineProperty = Object.defineProperty,
1252
+ allowTokenListConstruction = 0,
1253
+ skipPropChange = 0;
1254
+
1255
+ var DOMTokenList = function DOMTokenList() {
1256
+ if (!allowTokenListConstruction) throw TypeError('Illegal constructor'); // internally let it through
1257
+ };
1258
+
1259
+ DOMTokenList.prototype.toString = DOMTokenList.prototype.toLocaleString = function () {
1260
+ return this.value;
1261
+ };
1262
+
1263
+ DOMTokenList.prototype.add = function () {
1264
+ a: for (var v = 0, argLen = arguments.length, val = '', ele = this[' uCL'], proto = ele[' uCLp']; v !== argLen; ++v) {
1265
+ val = arguments[v] + '', checkIfValidClassListEntry('add', val);
1266
+
1267
+ for (var i = 0, Len = proto.length, resStr = val; i !== Len; ++i) {
1268
+ if (this[i] === val) continue a;else resStr += ' ' + this[i];
1269
+ }
1270
+
1271
+ this[Len] = val, proto.length += 1, proto.value = resStr;
1272
+ }
1273
+ skipPropChange = 1, ele.className = proto.value, skipPropChange = 0;
1274
+ };
1275
+
1276
+ DOMTokenList.prototype.remove = function () {
1277
+ for (var v = 0, argLen = arguments.length, val = '', ele = this[' uCL'], proto = ele[' uCLp']; v !== argLen; ++v) {
1278
+ val = arguments[v] + '', checkIfValidClassListEntry('remove', val);
1279
+
1280
+ for (var i = 0, Len = proto.length, resStr = '', is = 0; i !== Len; ++i) {
1281
+ if (is) {
1282
+ this[i - 1] = this[i];
1283
+ } else {
1284
+ if (this[i] !== val) {
1285
+ resStr += this[i] + ' ';
1286
+ } else {
1287
+ is = 1;
1288
+ }
1289
+ }
1290
+ }
1291
+
1292
+ if (!is) continue;
1293
+ delete this[Len], proto.length -= 1, proto.value = resStr;
1294
+ }
1295
+ skipPropChange = 1, ele.className = proto.value, skipPropChange = 0;
1296
+ };
1297
+
1298
+ window.DOMTokenList = DOMTokenList;
1299
+
1300
+ function whenPropChanges() {
1301
+ var evt = window.event,
1302
+ prop = evt.propertyName;
1303
+
1304
+ if (!skipPropChange && (prop === 'className' || prop === 'classList' && !defineProperty)) {
1305
+ var target = evt.srcElement,
1306
+ protoObjProto = target[' uCLp'],
1307
+ strval = '' + target[prop];
1308
+ var tokens = strval.trim().split(wsRE),
1309
+ resTokenList = target[prop === 'classList' ? ' uCL' : 'classList'];
1310
+ var oldLen = protoObjProto.length;
1311
+
1312
+ a: for (var cI = 0, cLen = protoObjProto.length = tokens.length, sub = 0; cI !== cLen; ++cI) {
1313
+ for (var innerI = 0; innerI !== cI; ++innerI) {
1314
+ if (tokens[innerI] === tokens[cI]) {
1315
+ sub++;
1316
+ continue a;
1317
+ }
1318
+ }
1319
+
1320
+ resTokenList[cI - sub] = tokens[cI];
1321
+ }
1322
+
1323
+ for (var i = cLen - sub; i < oldLen; ++i) {
1324
+ delete resTokenList[i];
1325
+ } //remove trailing indexs
1326
+
1327
+
1328
+ if (prop !== 'classList') return;
1329
+ skipPropChange = 1, target.classList = resTokenList, target.className = strval;
1330
+ skipPropChange = 0, resTokenList.length = tokens.length - sub;
1331
+ }
1332
+ }
1333
+
1334
+ function polyfillClassList(ele) {
1335
+ if (!ele || !('innerHTML' in ele)) throw TypeError('Illegal invocation');
1336
+ ele.detachEvent('onpropertychange', whenPropChanges); // prevent duplicate handler infinite loop
1337
+
1338
+ allowTokenListConstruction = 1;
1339
+
1340
+ try {
1341
+ var protoObj = function protoObj() {};
1342
+
1343
+ protoObj.prototype = new DOMTokenList();
1344
+ } finally {
1345
+ allowTokenListConstruction = 0;
1346
+ }
1347
+
1348
+ var protoObjProto = protoObj.prototype,
1349
+ resTokenList = new protoObj();
1350
+
1351
+ a: for (var toks = ele.className.trim().split(wsRE), cI = 0, cLen = toks.length, sub = 0; cI !== cLen; ++cI) {
1352
+ for (var innerI = 0; innerI !== cI; ++innerI) {
1353
+ if (toks[innerI] === toks[cI]) {
1354
+ sub++;
1355
+ continue a;
1356
+ }
1357
+ }
1358
+
1359
+ this[cI - sub] = toks[cI];
1360
+ }
1361
+ protoObjProto.length = cLen - sub, protoObjProto.value = ele.className, protoObjProto[' uCL'] = ele;
1362
+
1363
+ if (defineProperty) {
1364
+ defineProperty(ele, 'classList', {
1365
+ // IE8 & IE9 allow defineProperty on the DOM
1366
+ enumerable: 1,
1367
+ get: function get() {
1368
+ return resTokenList;
1369
+ },
1370
+ configurable: 0,
1371
+ set: function set(newVal) {
1372
+ skipPropChange = 1, ele.className = protoObjProto.value = newVal += '', skipPropChange = 0;
1373
+ var toks = newVal.trim().split(wsRE),
1374
+ oldLen = protoObjProto.length;
1375
+
1376
+ a: for (var cI = 0, cLen = protoObjProto.length = toks.length, sub = 0; cI !== cLen; ++cI) {
1377
+ for (var innerI = 0; innerI !== cI; ++innerI) {
1378
+ if (toks[innerI] === toks[cI]) {
1379
+ sub++;
1380
+ continue a;
1381
+ }
1382
+ }
1383
+
1384
+ resTokenList[cI - sub] = toks[cI];
1385
+ }
1386
+
1387
+ for (var i = cLen - sub; i < oldLen; ++i) {
1388
+ delete resTokenList[i];
1389
+ } //remove trailing indexs
1390
+
1391
+ }
1392
+ });
1393
+ defineProperty(ele, ' uCLp', {
1394
+ // for accessing the hidden prototype
1395
+ enumerable: 0,
1396
+ configurable: 0,
1397
+ writeable: 0,
1398
+ value: protoObj.prototype
1399
+ });
1400
+ defineProperty(protoObjProto, ' uCL', {
1401
+ enumerable: 0,
1402
+ configurable: 0,
1403
+ writeable: 0,
1404
+ value: ele
1405
+ });
1406
+ } else {
1407
+ ele.classList = resTokenList, ele[' uCL'] = resTokenList, ele[' uCLp'] = protoObj.prototype;
1408
+ }
1409
+
1410
+ ele.attachEvent('onpropertychange', whenPropChanges);
1411
+ }
1412
+
1413
+ try {
1414
+ // Much faster & cleaner version for IE8 & IE9:
1415
+ // Should work in IE8 because Element.prototype instanceof Node is true according to the specs
1416
+ window.Object.defineProperty(window.Element.prototype, 'classList', {
1417
+ enumerable: 1,
1418
+ get: function get(val) {
1419
+ if (!hasOwnProp.call(this, 'classList')) polyfillClassList(this);
1420
+ return this.classList;
1421
+ },
1422
+ configurable: 0,
1423
+ set: function set(val) {
1424
+ this.className = val;
1425
+ }
1426
+ });
1427
+ } catch (e) {
1428
+ // Less performant fallback for older browsers (IE 6-8):
1429
+ window[' uCL'] = polyfillClassList; // the below code ensures polyfillClassList is applied to all current and future elements in the doc.
1430
+
1431
+ document.documentElement.firstChild.appendChild(document.createElement('style')).styleSheet.cssText = '_*{x-uCLp:expression(!this.hasOwnProperty("classList")&&window[" uCL"](this))}' + // IE6
1432
+ '[class]{x-uCLp/**/:expression(!this.hasOwnProperty("classList")&&window[" uCL"](this))}'; //IE7-8
1433
+ }
1434
+ })(window) // 3. Patch in unsupported methods in DOMTokenList
1435
+ ;
1436
+
1437
+ (function (DOMTokenListProto, testClass) {
1438
+ if (!DOMTokenListProto.item) DOMTokenListProto.item = function (i) {
1439
+ function NullCheck(n) {
1440
+ return n === void 0 ? null : n;
1441
+ }
1442
+
1443
+ return NullCheck(this[i]);
1444
+ };
1445
+ if (!DOMTokenListProto.toggle || testClass.toggle('a', 0) !== false) DOMTokenListProto.toggle = function (val) {
1446
+ if (arguments.length > 1) return this[arguments[1] ? 'add' : 'remove'](val), !!arguments[1];
1447
+ var oldValue = this.value;
1448
+ return this.remove(oldValue), oldValue === this.value && (this.add(val), true);
1449
+ /*|| false*/
1450
+ };
1451
+ if (!DOMTokenListProto.replace || typeof testClass.replace('a', 'b') !== 'boolean') DOMTokenListProto.replace = function (oldToken, newToken) {
1452
+ checkIfValidClassListEntry('replace', oldToken), checkIfValidClassListEntry('replace', newToken);
1453
+ var oldValue = this.value;
1454
+ return this.remove(oldToken), this.value !== oldValue && (this.add(newToken), true);
1455
+ };
1456
+ if (!DOMTokenListProto.contains) DOMTokenListProto.contains = function (value) {
1457
+ for (var i = 0, Len = this.length; i !== Len; ++i) {
1458
+ if (this[i] === value) return true;
1459
+ }
1460
+
1461
+ return false;
1462
+ };
1463
+ if (!DOMTokenListProto.forEach) DOMTokenListProto.forEach = function (f) {
1464
+ if (arguments.length === 1) for (var i = 0, Len = this.length; i !== Len; ++i) {
1465
+ f(this[i], i, this);
1466
+ } else for (var i = 0, Len = this.length, tArg = arguments[1]; i !== Len; ++i) {
1467
+ f.call(tArg, this[i], i, this);
1468
+ }
1469
+ };
1470
+ if (!DOMTokenListProto.entries) DOMTokenListProto.entries = function () {
1471
+ var nextIndex = 0,
1472
+ that = this;
1473
+ return {
1474
+ next: function next() {
1475
+ return nextIndex < that.length ? {
1476
+ value: [nextIndex, that[nextIndex]],
1477
+ done: false
1478
+ } : {
1479
+ done: true
1480
+ };
1481
+ }
1482
+ };
1483
+ };
1484
+ if (!DOMTokenListProto.values) DOMTokenListProto.values = function () {
1485
+ var nextIndex = 0,
1486
+ that = this;
1487
+ return {
1488
+ next: function next() {
1489
+ return nextIndex < that.length ? {
1490
+ value: that[nextIndex],
1491
+ done: false
1492
+ } : {
1493
+ done: true
1494
+ };
1495
+ }
1496
+ };
1497
+ };
1498
+ if (!DOMTokenListProto.keys) DOMTokenListProto.keys = function () {
1499
+ var nextIndex = 0,
1500
+ that = this;
1501
+ return {
1502
+ next: function next() {
1503
+ return nextIndex < that.length ? {
1504
+ value: nextIndex,
1505
+ done: false
1506
+ } : {
1507
+ done: true
1508
+ };
1509
+ }
1510
+ };
1511
+ };
1512
+ })(window.DOMTokenList.prototype, window.document.createElement('div').classList);
1513
+ })(window);
1514
+
1515
+ var messagesDE = {
1516
+ "eligibility-modal.bullet-1": "Wählen Sie an der Kasse <strong>Alma</strong> .",
1517
+ "eligibility-modal.bullet-2": "Füllen Sie die <strong>angeforderten</strong> Informationen aus.",
1518
+ "eligibility-modal.bullet-3": "Die Bestätigung Ihrer Zahlung <strong>sofort</strong> !",
1519
+ "eligibility-modal.cost": "Davon Kosten",
1520
+ "eligibility-modal.credit-commitment": "Ein Kredit verpflichtet Sie und muss zurückgezahlt werden. Prüfen Sie Ihre Rückzahlungsfähigkeit, bevor Sie sich verpflichten.",
1521
+ "eligibility-modal.credit-cost": "Davon Kreditkosten",
1522
+ "eligibility-modal.credit-cost-amount": "{creditCost} (APR {TAEG})",
1523
+ "eligibility-modal.no-eligibility": "Ups, die Simulation scheint nicht funktioniert zu haben.",
1524
+ "eligibility-modal.title": "<highlighted>Bezahlen Sie in Raten</highlighted> oder später per Kreditkarte mit Alma.",
1525
+ "eligibility-modal.total": "Insgesamt",
1526
+ "installments.today": "Heutzutage",
1527
+ "payment-plan-strings.day-abbreviation": "J{numberOfDeferredDays}",
1528
+ "payment-plan-strings.default-message": "Bezahlen Sie in Raten mit Alma",
1529
+ "payment-plan-strings.deferred": "{totalAmount} zu zahlen am {dueDate}",
1530
+ "payment-plan-strings.ineligible-greater-than-max": "Bis zu {maxAmount}",
1531
+ "payment-plan-strings.ineligible-lower-than-min": "Ab {minAmount}",
1532
+ "payment-plan-strings.multiple-installments": "{numberOfRemainingInstallments, plural, one {{firstInstallmentAmount} dann {numberOfRemainingInstallments} x {othersInstallmentAmount}} other {{firstInstallmentAmount} dann {numberOfRemainingInstallments} x {othersInstallmentAmount}}}",
1533
+ "payment-plan-strings.multiple-installments-same-amount": "{installmentsCount} x {totalAmount}",
1534
+ "payment-plan-strings.no-fee": "(gebührenfrei)"
1535
+ };
1536
+
1537
+ var messagesEN = {
1538
+ "eligibility-modal.bullet-1": "Choose <strong>Alma</strong> at checkout.",
1539
+ "eligibility-modal.bullet-2": "Fill in the <strong>information</strong> requested.",
1540
+ "eligibility-modal.bullet-3": "Validation of your payment <strong>instantaneous</strong>!",
1541
+ "eligibility-modal.cost": "Of which costs",
1542
+ "eligibility-modal.credit-commitment": "A loan commits you and must be repaid. Check your ability to repay before committing yourself.",
1543
+ "eligibility-modal.credit-cost": "Of which cost of credit",
1544
+ "eligibility-modal.credit-cost-amount": "{creditCost} (APR {TAEG})",
1545
+ "eligibility-modal.no-eligibility": "Oops, looks like the simulation didn't work.",
1546
+ "eligibility-modal.title": "<highlighted>Pay in installments</highlighted> or later by credit card with Alma.",
1547
+ "eligibility-modal.total": "Total",
1548
+ "installments.today": "Today",
1549
+ "payment-plan-strings.day-abbreviation": "T{numberOfDeferredDays}",
1550
+ "payment-plan-strings.default-message": "Pay in installments with Alma",
1551
+ "payment-plan-strings.deferred": "{totalAmount} to be paid on {dueDate}",
1552
+ "payment-plan-strings.ineligible-greater-than-max": "Until {maxAmount}",
1553
+ "payment-plan-strings.ineligible-lower-than-min": "From {minAmount}",
1554
+ "payment-plan-strings.multiple-installments": "{numberOfRemainingInstallments, plural, one {{firstInstallmentAmount} then {numberOfRemainingInstallments} x {othersInstallmentAmount}} other {{firstInstallmentAmount} then {numberOfRemainingInstallments} x {othersInstallmentAmount}}}",
1555
+ "payment-plan-strings.multiple-installments-same-amount": "{installmentsCount} x {totalAmount}",
1556
+ "payment-plan-strings.no-fee": "(free of charge)"
1557
+ };
1558
+
1559
+ var messagesES = {
1560
+ "eligibility-modal.bullet-1": "Elige <strong>Alma</strong> como método de pago.",
1561
+ "eligibility-modal.bullet-2": "Completa la <strong>información</strong> solicitada.",
1562
+ "eligibility-modal.bullet-3": "¡Validación <strong>inmediata</strong> de tu pago!",
1563
+ "eligibility-modal.cost": "Gastos (incl. en el total)",
1564
+ "eligibility-modal.credit-commitment": "Un préstamo te compromete y debe ser devuelto. Comprueba tu capacidad financiera antes de comprometerte.",
1565
+ "eligibility-modal.credit-cost": "Coste de crédito (incl. en el total)",
1566
+ "eligibility-modal.credit-cost-amount": "{creditCost} (TAE {TAEG})",
1567
+ "eligibility-modal.no-eligibility": "Uy, parece que la simulación no ha funcionado.",
1568
+ "eligibility-modal.title": "<highlighted>Paga a plazos</highlighted> o más adelante con tu tarjeta, a través de Alma.",
1569
+ "eligibility-modal.total": "Total",
1570
+ "installments.today": "Hoy",
1571
+ "payment-plan-strings.day-abbreviation": "D{numberOfDeferredDays}",
1572
+ "payment-plan-strings.default-message": "Pagar a plazos con Alma",
1573
+ "payment-plan-strings.deferred": "{totalAmount} a pagar el {dueDate}",
1574
+ "payment-plan-strings.ineligible-greater-than-max": "Hasta {maxAmount}",
1575
+ "payment-plan-strings.ineligible-lower-than-min": "Desde {minAmount}",
1576
+ "payment-plan-strings.multiple-installments": "{numberOfRemainingInstallments, plural, one {{firstInstallmentAmount} hoy, después {numberOfRemainingInstallments} mensualidad de {othersInstallmentAmount}} other {{firstInstallmentAmount} hoy, después {numberOfRemainingInstallments} mensualidades de {othersInstallmentAmount}}}",
1577
+ "payment-plan-strings.multiple-installments-same-amount": "{installmentsCount} plazos de {totalAmount}",
1578
+ "payment-plan-strings.no-fee": "(sin intereses)"
1579
+ };
1580
+
1581
+ var messagesFR = {
1582
+ "eligibility-modal.bullet-1": "Choisissez <strong>Alma</strong> au moment du paiement.",
1583
+ "eligibility-modal.bullet-2": "Renseignez les <strong>informations</strong> demandées.",
1584
+ "eligibility-modal.bullet-3": "La validation de votre paiement <strong>instantanée</strong> !",
1585
+ "eligibility-modal.cost": "Dont frais",
1586
+ "eligibility-modal.credit-commitment": "Un crédit vous engage et doit être remboursé. Vérifiez vos capacités de remboursement avant de vous engager.",
1587
+ "eligibility-modal.credit-cost": "Dont coût du crédit",
1588
+ "eligibility-modal.credit-cost-amount": "{creditCost} (TAEG {TAEG})",
1589
+ "eligibility-modal.no-eligibility": "Oups, il semblerait que la simulation n'aie pas fonctionné.",
1590
+ "eligibility-modal.title": "<highlighted>Payez en plusieurs fois</highlighted> ou plus tard par carte bancaire avec Alma.",
1591
+ "eligibility-modal.total": "Total",
1592
+ "installments.today": "Aujourd'hui",
1593
+ "payment-plan-strings.day-abbreviation": "J{numberOfDeferredDays}",
1594
+ "payment-plan-strings.default-message": "Payez en plusieurs fois avec Alma",
1595
+ "payment-plan-strings.deferred": "{totalAmount} à payer le {dueDate}",
1596
+ "payment-plan-strings.ineligible-greater-than-max": "Jusqu'à {maxAmount}",
1597
+ "payment-plan-strings.ineligible-lower-than-min": "À partir de {minAmount}",
1598
+ "payment-plan-strings.multiple-installments": "{numberOfRemainingInstallments, plural, one {{firstInstallmentAmount} puis {numberOfRemainingInstallments} x {othersInstallmentAmount}} other {{firstInstallmentAmount} puis {numberOfRemainingInstallments} x {othersInstallmentAmount}}}",
1599
+ "payment-plan-strings.multiple-installments-same-amount": "{installmentsCount} x {totalAmount}",
1600
+ "payment-plan-strings.no-fee": "(sans frais)"
1601
+ };
1602
+
1603
+ var messagesIT = {
1604
+ "eligibility-modal.bullet-1": "Scegli <strong>Alma</strong> alla cassa.",
1605
+ "eligibility-modal.bullet-2": "Compila le informazioni <strong></strong> richieste.",
1606
+ "eligibility-modal.bullet-3": "Convalida del tuo pagamento <strong>istantanea</strong>!",
1607
+ "eligibility-modal.cost": "Di cui commissioni",
1608
+ "eligibility-modal.credit-commitment": "Un pagamento rateale ti impegna e deve essere ripagato. Verifica la tua capacità di rimborso prima di impegnarti.",
1609
+ "eligibility-modal.credit-cost": "Di cui commissioni",
1610
+ "eligibility-modal.credit-cost-amount": "{creditCost} (TAEG {TAEG})",
1611
+ "eligibility-modal.no-eligibility": "Ops, sembra che la simulazione non abbia funzionato.",
1612
+ "eligibility-modal.title": "<highlighted>Paga a rate</highlighted> e posticipa il pagamento con Alma, senza interessi.",
1613
+ "eligibility-modal.total": "Totale",
1614
+ "installments.today": "Oggi",
1615
+ "payment-plan-strings.day-abbreviation": "G{numberOfDeferredDays}",
1616
+ "payment-plan-strings.default-message": "Paga a rate con Alma",
1617
+ "payment-plan-strings.deferred": "{totalAmount} da pagare il {dueDate}",
1618
+ "payment-plan-strings.ineligible-greater-than-max": "Disponibile fino a {maxAmount}",
1619
+ "payment-plan-strings.ineligible-lower-than-min": "Pagamento rateale disponibile a partire da {minAmount}",
1620
+ "payment-plan-strings.multiple-installments": "{numberOfRemainingInstallments, plural, one {Oggi paghi {firstInstallmentAmount} poi tra {numberOfRemainingInstallments} mese {othersInstallmentAmount}} other {Oggi paghi {firstInstallmentAmount} poi {numberOfRemainingInstallments} rate mensili di {othersInstallmentAmount}}}",
1621
+ "payment-plan-strings.multiple-installments-same-amount": "In {installmentsCount} rate mensili di {totalAmount}",
1622
+ "payment-plan-strings.no-fee": "(senza interessi)"
1623
+ };
1624
+
1625
+ var messagesNL = {
1626
+ "eligibility-modal.bullet-1": "Kies <strong>Alma</strong> bij het afrekenen.",
1627
+ "eligibility-modal.bullet-2": "Vul de <strong>gevraagde informatie</strong> in.",
1628
+ "eligibility-modal.bullet-3": "Onmiddelijke validatie van uw betaling ",
1629
+ "eligibility-modal.cost": "Waarvan kosten",
1630
+ "eligibility-modal.credit-commitment": "Een lening bindt je en moet worden terugbetaald. Ga na of u kunt terugbetalen voordat u zich vastlegt.",
1631
+ "eligibility-modal.credit-cost": "Waarvan kosten van krediet",
1632
+ "eligibility-modal.credit-cost-amount": "{creditCost} (APR {TAEG})",
1633
+ "eligibility-modal.no-eligibility": "Oeps, het lijkt erop dat de simulatie niet werkte.",
1634
+ "eligibility-modal.title": "<highlighted>Betaal in termijnen</highlighted> of later per credit card met Alma.",
1635
+ "eligibility-modal.total": "Totaal",
1636
+ "installments.today": "Tegenwoordig",
1637
+ "payment-plan-strings.day-abbreviation": "J{numberOfDeferredDays}",
1638
+ "payment-plan-strings.default-message": "Betaal in termijnen met Alma",
1639
+ "payment-plan-strings.deferred": "{totalAmount} te betalen op {dueDate}",
1640
+ "payment-plan-strings.ineligible-greater-than-max": "Tot {maxAmount}",
1641
+ "payment-plan-strings.ineligible-lower-than-min": "Van {minAmount}",
1642
+ "payment-plan-strings.multiple-installments": "{numberOfRemainingInstallments, plural, one {{firstInstallmentAmount} dan {numberOfRemainingInstallments} x {othersInstallmentAmount}} other {{firstInstallmentAmount} dan {numberOfRemainingInstallments} x {othersInstallmentAmount}}}",
1643
+ "payment-plan-strings.multiple-installments-same-amount": "{installmentsCount} x {totalAmount}",
1644
+ "payment-plan-strings.no-fee": "(gratis)"
1645
+ };
1646
+
1647
+ var getTranslationsByLocale = function getTranslationsByLocale(locale) {
1648
+ switch (locale) {
1649
+ case Locale.fr:
1650
+ return messagesFR;
1651
+
1652
+ case Locale.en:
1653
+ return messagesEN;
1654
+
1655
+ case Locale.es:
1656
+ return messagesES;
1657
+
1658
+ case Locale.it:
1659
+ return messagesIT;
1660
+
1661
+ case Locale.de:
1662
+ return messagesDE;
1663
+
1664
+ case Locale.nl:
1665
+ case Locale['nl-BE']:
1666
+ case Locale['nl-NL']:
1667
+ return messagesNL;
1668
+
1669
+ default:
1670
+ return messagesEN;
1671
+ }
1672
+ };
1673
+
1674
+ var Provider = function Provider(_ref) {
1675
+ var children = _ref.children,
1676
+ locale = _ref.locale;
1677
+ return /*#__PURE__*/React__default.createElement(reactIntl.IntlProvider, {
1678
+ messages: getTranslationsByLocale(locale),
1679
+ locale: locale,
1680
+ defaultLocale: "en"
1681
+ }, children);
1682
+ };
1683
+
1684
+ function _extends() {
1685
+ _extends = Object.assign || function (target) {
1686
+ for (var i = 1; i < arguments.length; i++) {
1687
+ var source = arguments[i];
1688
+
1689
+ for (var key in source) {
1690
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
1691
+ target[key] = source[key];
1692
+ }
1693
+ }
1694
+ }
1695
+
1696
+ return target;
1697
+ };
1698
+
1699
+ return _extends.apply(this, arguments);
1700
+ }
1701
+
1702
+ function _objectWithoutPropertiesLoose(source, excluded) {
1703
+ if (source == null) return {};
1704
+ var target = {};
1705
+ var sourceKeys = Object.keys(source);
1706
+ var key, i;
1707
+
1708
+ for (i = 0; i < sourceKeys.length; i++) {
1709
+ key = sourceKeys[i];
1710
+ if (excluded.indexOf(key) >= 0) continue;
1711
+ target[key] = source[key];
1712
+ }
1713
+
1714
+ return target;
1715
+ }
1716
+
1717
+ var fetchFromApi = function fetchFromApi(url, data, headers) {
1718
+ if (url === void 0) {
1719
+ url = '';
1720
+ }
1721
+
1722
+ try {
1723
+ return Promise.resolve(fetch(url, {
1724
+ method: 'POST',
1725
+ headers: _extends({
1726
+ 'Content-Type': 'application/json'
1727
+ }, headers),
1728
+ body: JSON.stringify(data)
1729
+ })).then(function (response) {
1730
+ return response.json();
1731
+ });
1732
+ } catch (e) {
1733
+ return Promise.reject(e);
1734
+ }
1735
+ };
1736
+
1737
+ var filterELigibility = function filterELigibility(eligibilities, configPlans) {
1738
+ // Remove p1x
1739
+ var filteredEligibilityPlans = eligibilities.filter(function (plan) {
1740
+ return !(plan.installments_count === 1 && plan.deferred_days === 0 && plan.deferred_months === 0);
1741
+ }); // If no configPlans was provided, return eligibility response
1742
+
1743
+ if (!configPlans) {
1744
+ return filteredEligibilityPlans;
1745
+ } // Else check if the plan is eligible regarding the related configPlan
1746
+
1747
+
1748
+ return filteredEligibilityPlans.map(function (plan) {
1749
+ var eligibilityDeferredDays = (plan.deferred_months ? plan.deferred_months : 0) * 30 + (plan.deferred_days ? plan.deferred_days : 0); // find the related configPlan
1750
+
1751
+ var relatedConfigPlan = configPlans.find(function (configPlan) {
1752
+ var configPlanDeferredDays = (configPlan.deferredMonths ? configPlan.deferredMonths : 0) * 30 + (configPlan.deferredDays ? configPlan.deferredDays : 0);
1753
+ return plan.installments_count === configPlan.installmentsCount && eligibilityDeferredDays === configPlanDeferredDays;
1754
+ });
1755
+ return _extends({}, plan, {
1756
+ eligible: relatedConfigPlan ? plan.purchase_amount >= (relatedConfigPlan == null ? void 0 : relatedConfigPlan.minAmount) && plan.purchase_amount <= (relatedConfigPlan == null ? void 0 : relatedConfigPlan.maxAmount) : false,
1757
+ minAmount: relatedConfigPlan == null ? void 0 : relatedConfigPlan.minAmount,
1758
+ maxAmount: relatedConfigPlan == null ? void 0 : relatedConfigPlan.maxAmount
1759
+ });
1760
+ });
1761
+ };
1762
+
1763
+ var useFetchEligibility = function useFetchEligibility(purchaseAmount, _ref, plans) {
1764
+ var domain = _ref.domain,
1765
+ merchantId = _ref.merchantId;
1766
+
1767
+ var _useState = React.useState([]),
1768
+ eligibility = _useState[0],
1769
+ setEligibility = _useState[1];
1770
+
1771
+ var _useState2 = React.useState(apiStatus.PENDING),
1772
+ status = _useState2[0],
1773
+ setStatus = _useState2[1];
1774
+
1775
+ var configInstallments = plans == null ? void 0 : plans.map(function (plan) {
1776
+ return {
1777
+ installments_count: plan.installmentsCount,
1778
+ deferred_days: plan == null ? void 0 : plan.deferredDays,
1779
+ deferred_months: plan == null ? void 0 : plan.deferredMonths
1780
+ };
1781
+ });
1782
+ React.useEffect(function () {
1783
+ if (status === apiStatus.PENDING) {
1784
+ fetchFromApi(domain + '/v2/payments/eligibility', {
1785
+ purchase_amount: purchaseAmount,
1786
+ queries: configInstallments
1787
+ }, {
1788
+ Authorization: "Alma-Merchant-Auth " + merchantId
1789
+ }).then(function (res) {
1790
+ setEligibility(res);
1791
+ setStatus(apiStatus.SUCCESS);
1792
+ })["catch"](function () {
1793
+ setStatus(apiStatus.FAILED);
1794
+ });
1795
+ }
1796
+ }, [status]);
1797
+ return [filterELigibility(eligibility, plans), status];
1798
+ };
1799
+
1800
+ var s = {"loadingIndicator":"_31lrj","letter":"_2p94X","loading-indicator-letter":"_229P7","bar":"_1k0PM","loading-indicator-bar":"_2cX7o"};
1801
+
1802
+ var LoadingIndicator = function LoadingIndicator(_ref) {
1803
+ var className = _ref.className;
1804
+ return /*#__PURE__*/React__default.createElement("div", {
1805
+ className: cx(s.loadingIndicator, className),
1806
+ "data-testid": "loader"
1807
+ }, /*#__PURE__*/React__default.createElement("div", {
1808
+ className: s.letter
1809
+ }, "a"), /*#__PURE__*/React__default.createElement("div", {
1810
+ className: s.bar
1811
+ }));
1812
+ };
1813
+
1814
+ var s$1 = {"modal":"_D8SjB","content":"_ocM9x","contentScrollable":"_1GP2F","overlay":"_1yxCb","header":"_12LLh","closeButton":"_3YRro"};
1815
+
1816
+ function CrossIcon(_ref) {
1817
+ var _ref$color = _ref.color,
1818
+ color = _ref$color === void 0 ? '#fff' : _ref$color,
1819
+ className = _ref.className;
1820
+ return /*#__PURE__*/React__default.createElement("svg", {
1821
+ className: className,
1822
+ width: "16",
1823
+ height: "16",
1824
+ viewBox: "0 0 16 16",
1825
+ fill: "none",
1826
+ xmlns: "http://www.w3.org/2000/svg"
1827
+ }, /*#__PURE__*/React__default.createElement("path", {
1828
+ d: "M12.5964 11.404L9.41445 8.22205L12.5964 5.04007C12.7732 4.86329 12.7732 4.50974 12.5964 4.33296L11.8893 3.62585C11.6904 3.42698 11.359 3.44908 11.1822 3.62585L8.00023 6.80783L4.81825 3.62585C4.61938 3.42698 4.28792 3.44908 4.11114 3.62585L3.40404 4.33296C3.20516 4.53183 3.20516 4.84119 3.40404 5.04007L6.58602 8.22205L3.40404 11.404C3.20516 11.6029 3.20517 11.9123 3.40404 12.1111L4.11115 12.8182C4.28792 12.995 4.61938 13.0171 4.81825 12.8182L8.00023 9.63626L11.1822 12.8182C11.359 12.995 11.6904 13.0171 11.8893 12.8182L12.5964 12.1111C12.7732 11.9344 12.7732 11.5808 12.5964 11.404Z",
1829
+ fill: color
1830
+ }));
1831
+ }
1832
+
1833
+ var ControlledModal = function ControlledModal(_ref) {
1834
+ var _cx;
1835
+
1836
+ var children = _ref.children,
1837
+ isOpen = _ref.isOpen,
1838
+ onClose = _ref.onClose,
1839
+ className = _ref.className,
1840
+ contentClassName = _ref.contentClassName,
1841
+ _ref$scrollable = _ref.scrollable,
1842
+ scrollable = _ref$scrollable === void 0 ? false : _ref$scrollable,
1843
+ props = _objectWithoutPropertiesLoose(_ref, ["children", "isOpen", "onClose", "className", "contentClassName", "scrollable"]);
1844
+
1845
+ Modal.setAppElement('body');
1846
+ return /*#__PURE__*/React__default.createElement(Modal, Object.assign({
1847
+ className: cx(s$1.modal, className),
1848
+ overlayClassName: s$1.overlay,
1849
+ onAfterOpen: function onAfterOpen() {
1850
+ noScroll.on();
1851
+ },
1852
+ onAfterClose: function onAfterClose() {
1853
+ noScroll.off();
1854
+ },
1855
+ onRequestClose: onClose,
1856
+ isOpen: isOpen,
1857
+ shouldCloseOnOverlayClick: true,
1858
+ shouldCloseOnEsc: true
1859
+ }, props), /*#__PURE__*/React__default.createElement("div", {
1860
+ className: s$1.header
1861
+ }, /*#__PURE__*/React__default.createElement("button", {
1862
+ onClick: onClose,
1863
+ className: s$1.closeButton,
1864
+ "data-testid": "modal-close-button"
1865
+ }, /*#__PURE__*/React__default.createElement(CrossIcon, null))), /*#__PURE__*/React__default.createElement("div", {
1866
+ className: cx(s$1.content, contentClassName, (_cx = {}, _cx[s$1.contentScrollable] = scrollable, _cx))
1867
+ }, children));
1868
+ };
1869
+
1870
+ var paymentPlanShorthandName = function paymentPlanShorthandName(payment) {
1871
+ var deferred_days = payment.deferred_days,
1872
+ deferred_months = payment.deferred_months,
1873
+ installmentsCount = payment.installments_count;
1874
+ var deferredDaysCount = deferred_days + deferred_months * 30;
1875
+
1876
+ if (installmentsCount === 1) {
1877
+ return /*#__PURE__*/React__default.createElement(reactIntl.FormattedMessage, {
1878
+ id: "payment-plan-strings.day-abbreviation",
1879
+ defaultMessage: "J{numberOfDeferredDays}",
1880
+ values: {
1881
+ numberOfDeferredDays: deferredDaysCount > 0 ? "+" + deferredDaysCount : ''
1882
+ }
1883
+ });
1884
+ } else {
1885
+ return installmentsCount + "x";
1886
+ }
1887
+ };
1888
+ var paymentPlanInfoText = function paymentPlanInfoText(payment) {
1889
+ var deferred_days = payment.deferred_days,
1890
+ deferred_months = payment.deferred_months,
1891
+ installmentsCount = payment.installments_count,
1892
+ eligible = payment.eligible,
1893
+ purchaseAmount = payment.purchase_amount,
1894
+ _payment$minAmount = payment.minAmount,
1895
+ minAmount = _payment$minAmount === void 0 ? 0 : _payment$minAmount,
1896
+ _payment$maxAmount = payment.maxAmount,
1897
+ maxAmount = _payment$maxAmount === void 0 ? 0 : _payment$maxAmount;
1898
+ var deferredDaysCount = deferred_days + deferred_months * 30;
1899
+
1900
+ var withNoFee = function withNoFee() {
1901
+ if (payment.payment_plan.every(function (plan) {
1902
+ return plan.customer_fee === 0 && plan.customer_interest === 0;
1903
+ })) {
1904
+ return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, ' ', /*#__PURE__*/React__default.createElement(reactIntl.FormattedMessage, {
1905
+ id: "payment-plan-strings.no-fee",
1906
+ defaultMessage: '(sans frais)'
1907
+ }));
1908
+ }
1909
+ };
1910
+
1911
+ if (!eligible) {
1912
+ return purchaseAmount > maxAmount ? /*#__PURE__*/React__default.createElement(reactIntl.FormattedMessage, {
1913
+ id: "payment-plan-strings.ineligible-greater-than-max",
1914
+ defaultMessage: "Jusqu'\xE0 {maxAmount}",
1915
+ values: {
1916
+ maxAmount: /*#__PURE__*/React__default.createElement(reactIntl.FormattedNumber, {
1917
+ value: priceFromCents(maxAmount),
1918
+ style: "currency",
1919
+ currency: "EUR"
1920
+ })
1921
+ }
1922
+ }) : /*#__PURE__*/React__default.createElement(reactIntl.FormattedMessage, {
1923
+ id: "payment-plan-strings.ineligible-lower-than-min",
1924
+ defaultMessage: "\xC0 partir de {minAmount}",
1925
+ values: {
1926
+ minAmount: /*#__PURE__*/React__default.createElement(reactIntl.FormattedNumber, {
1927
+ value: priceFromCents(minAmount),
1928
+ style: "currency",
1929
+ currency: "EUR"
1930
+ })
1931
+ }
1932
+ });
1933
+ } else if (deferredDaysCount !== 0 && installmentsCount === 1) {
1934
+ return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(reactIntl.FormattedMessage, {
1935
+ id: "payment-plan-strings.deferred",
1936
+ defaultMessage: "{totalAmount} \xE0 payer le {dueDate}",
1937
+ values: {
1938
+ totalAmount: /*#__PURE__*/React__default.createElement(reactIntl.FormattedNumber, {
1939
+ value: priceFromCents(payment.payment_plan[0].total_amount),
1940
+ style: "currency",
1941
+ currency: "EUR"
1942
+ }),
1943
+ dueDate: /*#__PURE__*/React__default.createElement(reactIntl.FormattedDate, {
1944
+ value: dateFns.secondsToMilliseconds(payment.payment_plan[0].due_date),
1945
+ day: "numeric",
1946
+ month: "long",
1947
+ year: "numeric"
1948
+ })
1949
+ }
1950
+ }), withNoFee());
1951
+ } else if (installmentsCount > 0) {
1952
+ var areInstallmentsOfSameAmount = payment.payment_plan.every(function (installment, index) {
1953
+ return index === 0 || installment.total_amount === payment.payment_plan[0].total_amount;
1954
+ });
1955
+
1956
+ if (areInstallmentsOfSameAmount) {
1957
+ return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(reactIntl.FormattedMessage, {
1958
+ id: "payment-plan-strings.multiple-installments-same-amount",
1959
+ defaultMessage: "{installmentsCount} x {totalAmount}",
1960
+ values: {
1961
+ totalAmount: /*#__PURE__*/React__default.createElement(reactIntl.FormattedNumber, {
1962
+ value: priceFromCents(payment.payment_plan[0].total_amount),
1963
+ style: "currency",
1964
+ currency: "EUR"
1965
+ }),
1966
+ installmentsCount: installmentsCount
1967
+ }
1968
+ }), withNoFee());
1969
+ }
1970
+
1971
+ return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(reactIntl.FormattedMessage, {
1972
+ id: "payment-plan-strings.multiple-installments",
1973
+ defaultMessage: "{numberOfRemainingInstallments, plural, one {{firstInstallmentAmount} puis {numberOfRemainingInstallments} x {othersInstallmentAmount}} other {{firstInstallmentAmount} puis {numberOfRemainingInstallments} x {othersInstallmentAmount}}}",
1974
+ values: {
1975
+ firstInstallmentAmount: /*#__PURE__*/React__default.createElement(reactIntl.FormattedNumber, {
1976
+ value: priceFromCents(payment.payment_plan[0].total_amount),
1977
+ style: "currency",
1978
+ currency: "EUR"
1979
+ }),
1980
+ numberOfRemainingInstallments: installmentsCount - 1,
1981
+ othersInstallmentAmount: /*#__PURE__*/React__default.createElement(reactIntl.FormattedNumber, {
1982
+ value: priceFromCents(payment.payment_plan[1].total_amount),
1983
+ style: "currency",
1984
+ currency: "EUR"
1985
+ })
1986
+ }
1987
+ }), withNoFee());
1988
+ }
1989
+
1990
+ return /*#__PURE__*/React__default.createElement(reactIntl.FormattedMessage, {
1991
+ id: "payment-plan-strings.default-message",
1992
+ defaultMessage: "Payez en plusieurs fois avec Alma"
1993
+ });
1994
+ };
1995
+
1996
+ var s$2 = {"buttons":"_1l2Oa","active":"_3rue7"};
1997
+
1998
+ var EligibilityPlansButtons = function EligibilityPlansButtons(_ref) {
1999
+ var eligibilityPlans = _ref.eligibilityPlans,
2000
+ currentPlanIndex = _ref.currentPlanIndex,
2001
+ setCurrentPlanIndex = _ref.setCurrentPlanIndex;
2002
+ return /*#__PURE__*/React__default.createElement("div", {
2003
+ className: s$2.buttons
2004
+ }, eligibilityPlans.map(function (eligibilityPlan, index) {
2005
+ var _cx;
2006
+
2007
+ return /*#__PURE__*/React__default.createElement("button", {
2008
+ key: index,
2009
+ className: cx((_cx = {}, _cx[s$2.active] = index === currentPlanIndex, _cx)),
2010
+ onClick: function onClick() {
2011
+ return setCurrentPlanIndex(index);
2012
+ }
2013
+ }, paymentPlanShorthandName(eligibilityPlan));
2014
+ }));
2015
+ };
2016
+
2017
+ var s$3 = {"schedule":"_MPKjS","scheduleLine":"_1A7Qv","total":"_14Ejo","creditCost":"_1ZIgu","creditMessage":"_1BUr8"};
2018
+
2019
+ var Schedule = function Schedule(_ref) {
2020
+ var currentPlan = _ref.currentPlan;
2021
+ var total = currentPlan && priceFromCents(currentPlan.purchase_amount + currentPlan.customer_total_cost_amount);
2022
+ var creditCost = currentPlan ? priceFromCents(currentPlan.customer_total_cost_amount) : 0;
2023
+ var TAEG = (currentPlan == null ? void 0 : currentPlan.annual_interest_rate) && currentPlan.annual_interest_rate / 10000;
2024
+ var customerFees = priceFromCents(currentPlan ? currentPlan.customer_total_cost_amount : 0);
2025
+ var isCredit = currentPlan && currentPlan.installments_count > 4;
2026
+ var intl = reactIntl.useIntl();
2027
+ return /*#__PURE__*/React__default.createElement("div", {
2028
+ className: s$3.schedule,
2029
+ "data-testid": "modal-installments-element"
2030
+ }, /*#__PURE__*/React__default.createElement("div", {
2031
+ className: cx(s$3.scheduleLine, s$3.total)
2032
+ }, /*#__PURE__*/React__default.createElement("span", null, /*#__PURE__*/React__default.createElement(reactIntl.FormattedMessage, {
2033
+ id: "eligibility-modal.total",
2034
+ defaultMessage: "Total"
2035
+ })), /*#__PURE__*/React__default.createElement("span", null, /*#__PURE__*/React__default.createElement(reactIntl.FormattedNumber, {
2036
+ value: total,
2037
+ style: "currency",
2038
+ currency: "EUR"
2039
+ }))), /*#__PURE__*/React__default.createElement("div", {
2040
+ className: cx(s$3.scheduleLine, s$3.creditCost)
2041
+ }, isCredit ? /*#__PURE__*/React__default.createElement("span", null, /*#__PURE__*/React__default.createElement(reactIntl.FormattedMessage, {
2042
+ id: "eligibility-modal.credit-cost",
2043
+ defaultMessage: "Dont co\xFBt du cr\xE9dit"
2044
+ })) : /*#__PURE__*/React__default.createElement("span", null, /*#__PURE__*/React__default.createElement(reactIntl.FormattedMessage, {
2045
+ id: "eligibility-modal.cost",
2046
+ defaultMessage: "Dont frais"
2047
+ })), /*#__PURE__*/React__default.createElement("span", null, isCredit ? /*#__PURE__*/React__default.createElement(reactIntl.FormattedMessage, {
2048
+ id: "eligibility-modal.credit-cost-amount",
2049
+ defaultMessage: "{creditCost} (TAEG {TAEG})",
2050
+ values: {
2051
+ creditCost: intl.formatNumber(creditCost, {
2052
+ style: 'currency',
2053
+ currency: 'EUR'
2054
+ }),
2055
+ TAEG: intl.formatNumber(TAEG != null ? TAEG : 0, {
2056
+ style: 'percent',
2057
+ maximumFractionDigits: 2
2058
+ })
2059
+ }
2060
+ }) : /*#__PURE__*/React__default.createElement(reactIntl.FormattedNumber, {
2061
+ value: customerFees,
2062
+ style: "currency",
2063
+ currency: "EUR"
2064
+ }))), ((currentPlan == null ? void 0 : currentPlan.payment_plan) || []).map(function (installment, index) {
2065
+ return /*#__PURE__*/React__default.createElement("div", {
2066
+ className: s$3.scheduleLine,
2067
+ key: index
2068
+ }, /*#__PURE__*/React__default.createElement("span", null, dateFns.isToday(installment.due_date * 1000) ? /*#__PURE__*/React__default.createElement(reactIntl.FormattedMessage, {
2069
+ id: "installments.today",
2070
+ defaultMessage: "Aujourd'hui"
2071
+ }) : /*#__PURE__*/React__default.createElement(reactIntl.FormattedDate, {
2072
+ value: installment.due_date * 1000,
2073
+ day: "numeric",
2074
+ month: "long",
2075
+ year: "numeric"
2076
+ })), /*#__PURE__*/React__default.createElement("span", null, /*#__PURE__*/React__default.createElement(reactIntl.FormattedNumber, {
2077
+ value: priceFromCents(installment.total_amount),
2078
+ style: "currency",
2079
+ currency: "EUR"
2080
+ })));
2081
+ }), isCredit && /*#__PURE__*/React__default.createElement("p", {
2082
+ className: s$3.creditMessage
2083
+ }, /*#__PURE__*/React__default.createElement(reactIntl.FormattedMessage, {
2084
+ id: "eligibility-modal.credit-commitment",
2085
+ defaultMessage: "Un cr\xE9dit vous engage et doit \xEAtre rembours\xE9. V\xE9rifiez vos capacit\xE9s de remboursement\n avant de vous engager."
2086
+ })));
2087
+ };
2088
+
2089
+ var s$4 = {"list":"_180ro","listItem":"_1HqCO","bullet":"_3B8wx"};
2090
+
2091
+ var Info = function Info() {
2092
+ return /*#__PURE__*/React__default.createElement("div", {
2093
+ className: s$4.list,
2094
+ "data-testid": "modal-info-element"
2095
+ }, /*#__PURE__*/React__default.createElement("div", {
2096
+ className: s$4.listItem
2097
+ }, /*#__PURE__*/React__default.createElement("div", {
2098
+ className: s$4.bullet
2099
+ }, "1"), /*#__PURE__*/React__default.createElement("div", null, /*#__PURE__*/React__default.createElement(reactIntl.FormattedMessage, {
2100
+ id: "eligibility-modal.bullet-1",
2101
+ defaultMessage: "Choisissez <strong>Alma</strong> au moment du paiement.",
2102
+ values: {
2103
+ strong: function strong() {
2104
+ return /*#__PURE__*/React__default.createElement("strong", null, [].slice.call(arguments));
2105
+ }
2106
+ }
2107
+ }))), /*#__PURE__*/React__default.createElement("div", {
2108
+ className: s$4.listItem
2109
+ }, /*#__PURE__*/React__default.createElement("div", {
2110
+ className: s$4.bullet
2111
+ }, "2"), /*#__PURE__*/React__default.createElement("div", null, /*#__PURE__*/React__default.createElement(reactIntl.FormattedMessage, {
2112
+ id: "eligibility-modal.bullet-2",
2113
+ defaultMessage: "Renseignez les <strong>informations</strong> demand\xE9es.",
2114
+ values: {
2115
+ strong: function strong() {
2116
+ return /*#__PURE__*/React__default.createElement("strong", null, [].slice.call(arguments));
2117
+ }
2118
+ }
2119
+ }))), /*#__PURE__*/React__default.createElement("div", {
2120
+ className: s$4.listItem
2121
+ }, /*#__PURE__*/React__default.createElement("div", {
2122
+ className: s$4.bullet
2123
+ }, "3"), /*#__PURE__*/React__default.createElement("div", null, /*#__PURE__*/React__default.createElement(reactIntl.FormattedMessage, {
2124
+ id: "eligibility-modal.bullet-3",
2125
+ defaultMessage: "La validation de votre paiement <strong>instantan\xE9e</strong> !",
2126
+ values: {
2127
+ strong: function strong() {
2128
+ return /*#__PURE__*/React__default.createElement("strong", null, [].slice.call(arguments));
2129
+ }
2130
+ }
2131
+ }))));
2132
+ };
2133
+
2134
+ function LogoIcon(_ref) {
2135
+ var _ref$color = _ref.color,
2136
+ color = _ref$color === void 0 ? '#00425D' : _ref$color,
2137
+ _ref$underlineColor = _ref.underlineColor,
2138
+ underlineColor = _ref$underlineColor === void 0 ? '#00425D' : _ref$underlineColor,
2139
+ className = _ref.className;
2140
+ return /*#__PURE__*/React__default.createElement("svg", {
2141
+ className: className,
2142
+ width: "35",
2143
+ height: "23",
2144
+ viewBox: "0 0 40 23",
2145
+ fill: "none",
2146
+ xmlns: "http://www.w3.org/2000/svg"
2147
+ }, /*#__PURE__*/React__default.createElement("path", {
2148
+ d: "M6.38546 10.1313V10.029H4.92542C4.23835 10.029 3.72877 10.0972 3.39668 10.2337C3.07605 10.3587 2.91573 10.6374 2.91573 11.0695C2.91573 11.7177 3.37378 12.0418 4.28988 12.0418C5.05711 12.0418 5.59532 11.8826 5.9045 11.5642C6.22514 11.2344 6.38546 10.7568 6.38546 10.1313ZM3.72304 13.9182C2.64663 13.9182 1.85076 13.6567 1.33546 13.1335C0.820153 12.599 0.5625 11.911 0.5625 11.0695C0.5625 10.0574 0.894586 9.32958 1.55876 8.88606C2.22293 8.43118 3.23636 8.20374 4.59906 8.20374H6.38546V7.82846C6.38546 6.98693 5.84725 6.56616 4.77083 6.56616C3.80893 6.56616 3.27644 6.93007 3.17338 7.65788H0.768622C0.848781 6.78223 1.21522 6.04873 1.86794 5.45738C2.52066 4.86603 3.50547 4.57036 4.82236 4.57036C6.1278 4.57036 7.11261 4.86035 7.77678 5.44032C8.44095 6.0203 8.77304 6.83909 8.77304 7.89669V13.7135H6.60875V12.7241C6.09345 13.5202 5.13155 13.9182 3.72304 13.9182Z",
2149
+ fill: color
2150
+ }), /*#__PURE__*/React__default.createElement("path", {
2151
+ d: "M14.2554 11.6324V13.6965C14.0149 13.7306 13.763 13.7476 13.4996 13.7476C12.5492 13.7476 11.8736 13.5486 11.4728 13.1506C11.072 12.7412 10.8716 12.0873 10.8716 11.1889V0.919922H13.3107V11.0183C13.3107 11.2344 13.3508 11.3936 13.4309 11.496C13.5111 11.5983 13.6771 11.6495 13.929 11.6495C13.9863 11.6495 14.0493 11.6495 14.118 11.6495C14.1982 11.6381 14.244 11.6324 14.2554 11.6324Z",
2152
+ fill: color
2153
+ }), /*#__PURE__*/React__default.createElement("path", {
2154
+ d: "M23.8943 8.63019V13.7135H21.4552V8.40844C21.4552 7.23711 20.9742 6.65145 20.0123 6.65145C19.4512 6.65145 19.0161 6.82203 18.7069 7.16319C18.4092 7.50436 18.2603 7.9763 18.2603 8.57902V13.7135H15.8212V4.77506H18.0714V5.86678C18.5409 5.0025 19.4054 4.57036 20.6651 4.57036C21.856 4.57036 22.7263 4.99113 23.2759 5.83266C24.0432 4.99113 25.0394 4.57036 26.2647 4.57036C27.3182 4.57036 28.1255 4.89446 28.6867 5.54267C29.2478 6.19088 29.5283 7.05516 29.5283 8.13551V13.7135H27.0892V8.40844C27.0892 7.23711 26.6083 6.65145 25.6464 6.65145C25.0738 6.65145 24.6386 6.82772 24.3409 7.18025C24.0432 7.52141 23.8943 8.00473 23.8943 8.63019Z",
2155
+ fill: color
2156
+ }), /*#__PURE__*/React__default.createElement("path", {
2157
+ d: "M37.0321 10.1313V10.029H35.572C34.885 10.029 34.3754 10.0972 34.0433 10.2337C33.7227 10.3587 33.5623 10.6374 33.5623 11.0695C33.5623 11.7177 34.0204 12.0418 34.9365 12.0418C35.7037 12.0418 36.2419 11.8826 36.5511 11.5642C36.8717 11.2344 37.0321 10.7568 37.0321 10.1313ZM34.3696 13.9182C33.2932 13.9182 32.4974 13.6567 31.9821 13.1335C31.4668 12.599 31.2091 11.911 31.2091 11.0695C31.2091 10.0574 31.5412 9.32958 32.2054 8.88606C32.8695 8.43118 33.883 8.20374 35.2457 8.20374H37.0321V7.82846C37.0321 6.98693 36.4939 6.56616 35.4174 6.56616C34.4555 6.56616 33.923 6.93007 33.82 7.65788H31.4152C31.4954 6.78223 31.8618 6.04873 32.5145 5.45738C33.1673 4.86603 34.1521 4.57036 35.469 4.57036C36.7744 4.57036 37.7592 4.86035 38.4234 5.44032C39.0876 6.0203 39.4196 6.83909 39.4196 7.89669V13.7135H37.2554V12.7241C36.7401 13.5202 35.7781 13.9182 34.3696 13.9182Z",
2158
+ fill: color
2159
+ }), /*#__PURE__*/React__default.createElement("rect", {
2160
+ y: "20",
2161
+ width: "40",
2162
+ height: "3",
2163
+ fill: underlineColor
2164
+ }));
2165
+ }
2166
+
2167
+ var s$5 = {"logo":"_3Oyv_"};
2168
+
2169
+ var Logo = function Logo() {
2170
+ return /*#__PURE__*/React__default.createElement("div", {
2171
+ className: s$5.logo
2172
+ }, /*#__PURE__*/React__default.createElement(LogoIcon, {
2173
+ underlineColor: "#FF414D"
2174
+ }));
2175
+ };
2176
+
2177
+ var s$6 = {"title":"_3ERx-"};
2178
+
2179
+ var Title = function Title() {
2180
+ return /*#__PURE__*/React__default.createElement("div", {
2181
+ className: s$6.title,
2182
+ "data-testid": "modal-title-element"
2183
+ }, /*#__PURE__*/React__default.createElement(reactIntl.FormattedMessage, {
2184
+ id: "eligibility-modal.title",
2185
+ defaultMessage: "<highlighted>Payez en plusieurs fois</highlighted> ou plus tard par carte bancaire avec Alma.",
2186
+ values: {
2187
+ highlighted: function highlighted() {
2188
+ return /*#__PURE__*/React__default.createElement("span", null, [].slice.call(arguments));
2189
+ }
2190
+ }
2191
+ }));
2192
+ };
2193
+
2194
+ var s$7 = {"container":"_21g6u","block":"_3zaP5","left":"_2SBRC"};
2195
+
2196
+ var DesktopModal = function DesktopModal(_ref) {
2197
+ var children = _ref.children;
2198
+ return /*#__PURE__*/React__default.createElement("div", {
2199
+ className: s$7.container,
2200
+ "data-testid": "modal-container"
2201
+ }, /*#__PURE__*/React__default.createElement("div", {
2202
+ className: cx([s$7.block, s$7.left])
2203
+ }, /*#__PURE__*/React__default.createElement(Title, null), /*#__PURE__*/React__default.createElement(Info, null), /*#__PURE__*/React__default.createElement(Logo, null)), /*#__PURE__*/React__default.createElement("div", {
2204
+ className: s$7.block
2205
+ }, children));
2206
+ };
2207
+
2208
+ var s$8 = {"noEligibility":"_17qNJ","loader":"_2oTJq"};
2209
+
2210
+ var s$9 = {"container":"_2G7Ch"};
2211
+
2212
+ var MobileModal = function MobileModal(_ref) {
2213
+ var children = _ref.children;
2214
+ return /*#__PURE__*/React__default.createElement("div", {
2215
+ className: s$9.container,
2216
+ "data-testid": "modal-container"
2217
+ }, /*#__PURE__*/React__default.createElement(Title, null), children, /*#__PURE__*/React__default.createElement(Info, null), /*#__PURE__*/React__default.createElement(Logo, null));
2218
+ };
2219
+
2220
+ var EligibilityModal = function EligibilityModal(_ref) {
2221
+ var initialPlanIndex = _ref.initialPlanIndex,
2222
+ onClose = _ref.onClose,
2223
+ eligibilityPlans = _ref.eligibilityPlans,
2224
+ status = _ref.status;
2225
+
2226
+ var _useState = React.useState(initialPlanIndex || 0),
2227
+ currentPlanIndex = _useState[0],
2228
+ setCurrentPlanIndex = _useState[1];
2229
+
2230
+ var isBigScreen = reactResponsive.useMediaQuery({
2231
+ minWidth: 800
2232
+ });
2233
+ var ModalComponent = isBigScreen ? DesktopModal : MobileModal;
2234
+ var eligiblePlans = eligibilityPlans.filter(function (plan) {
2235
+ return plan.eligible;
2236
+ });
2237
+ var currentPlan = eligiblePlans[currentPlanIndex];
2238
+ var modalProps = {
2239
+ eligibilityPlans: eligiblePlans,
2240
+ currentPlanIndex: currentPlanIndex,
2241
+ setCurrentPlanIndex: setCurrentPlanIndex,
2242
+ currentPlan: currentPlan,
2243
+ status: status
2244
+ };
2245
+ return /*#__PURE__*/React__default.createElement(ControlledModal, {
2246
+ onClose: onClose,
2247
+ ariaHideApp: false,
2248
+ scrollable: true,
2249
+ isOpen: true
2250
+ }, /*#__PURE__*/React__default.createElement(ModalComponent, Object.assign({}, modalProps), status === apiStatus.PENDING && /*#__PURE__*/React__default.createElement("div", {
2251
+ className: s$8.loader
2252
+ }, /*#__PURE__*/React__default.createElement(LoadingIndicator, null)), status === apiStatus.SUCCESS && eligiblePlans.length === 0 && /*#__PURE__*/React__default.createElement("div", {
2253
+ className: s$8.noEligibility
2254
+ }, /*#__PURE__*/React__default.createElement(reactIntl.FormattedMessage, {
2255
+ id: "eligibility-modal.no-eligibility",
2256
+ defaultMessage: "Oups, il semblerait que la simulation n'aie pas fonctionn\xE9."
2257
+ })), status === apiStatus.SUCCESS && eligiblePlans.length >= 1 && /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(EligibilityPlansButtons, {
2258
+ eligibilityPlans: eligiblePlans,
2259
+ currentPlanIndex: currentPlanIndex,
2260
+ setCurrentPlanIndex: setCurrentPlanIndex
2261
+ }), /*#__PURE__*/React__default.createElement(Schedule, {
2262
+ currentPlan: currentPlan
2263
+ }))));
2264
+ };
2265
+
2266
+ /**
2267
+ * This component allows to display only the modal, without PaymentPlans.
2268
+ */
2269
+
2270
+ var ModalContainer = function ModalContainer(_ref) {
2271
+ var purchaseAmount = _ref.purchaseAmount,
2272
+ apiData = _ref.apiData,
2273
+ configPlans = _ref.configPlans,
2274
+ onClose = _ref.onClose;
2275
+
2276
+ var _useFetchEligibility = useFetchEligibility(purchaseAmount, apiData, configPlans),
2277
+ eligibilityPlans = _useFetchEligibility[0],
2278
+ status = _useFetchEligibility[1];
2279
+
2280
+ return /*#__PURE__*/React__default.createElement(EligibilityModal, {
2281
+ initialPlanIndex: 0,
2282
+ onClose: onClose,
2283
+ eligibilityPlans: eligibilityPlans,
2284
+ status: status
2285
+ });
2286
+ };
2287
+
2288
+ var s$a = {"loadingIndicator":"_2SwwZ","line1":"_2qODo","line2":"_2YO01"};
2289
+
2290
+ var Loader = function Loader(_ref) {
2291
+ var className = _ref.className;
2292
+ return /*#__PURE__*/React__default.createElement("div", {
2293
+ className: cx(s$a.loadingIndicator, className),
2294
+ "data-testid": "loader"
2295
+ }, /*#__PURE__*/React__default.createElement("div", {
2296
+ className: s$a.line1
2297
+ }), /*#__PURE__*/React__default.createElement("div", {
2298
+ className: s$a.line2
2299
+ }));
2300
+ };
2301
+
2302
+ var useButtonAnimation = function useButtonAnimation(iterateValues, transitionDelay) {
2303
+ var _useState = React.useState(0),
2304
+ current = _useState[0],
2305
+ setCurrent = _useState[1];
2306
+
2307
+ var _useState2 = React.useState(true),
2308
+ update = _useState2[0],
2309
+ setUpdate = _useState2[1];
2310
+
2311
+ React.useEffect(function () {
2312
+ var isMounted = true;
2313
+
2314
+ if (iterateValues.length !== 0) {
2315
+ if (!iterateValues.includes(current) && update) setCurrent(iterateValues[0]);
2316
+ setTimeout(function () {
2317
+ if (update && isMounted) {
2318
+ setCurrent(iterateValues[iterateValues.includes(current) ? (iterateValues.indexOf(current) + 1) % iterateValues.length : 0]);
2319
+ }
2320
+ }, transitionDelay);
2321
+ }
2322
+
2323
+ return function () {
2324
+ isMounted = false;
2325
+ };
2326
+ }, [iterateValues, current]);
2327
+ return {
2328
+ current: current,
2329
+ onHover: function onHover(current) {
2330
+ setCurrent(current);
2331
+ setUpdate(false);
2332
+ },
2333
+ onLeave: function onLeave() {
2334
+ setUpdate(true);
2335
+ }
2336
+ };
2337
+ };
2338
+
2339
+ /**
2340
+ * It returns the **index** of the **first eligible plan** that matches the default installments count
2341
+ *
2342
+ * @param {number | number[]} suggestedPaymentPlan
2343
+ * @param {EligibilityPlan[]} eligibilityPlans
2344
+ * @returns number (index of the first eligible plan that matches the default installments count)
2345
+ */
2346
+ var getIndexOfActivePlan = function getIndexOfActivePlan(_ref) {
2347
+ var suggestedPaymentPlan = _ref.suggestedPaymentPlan,
2348
+ eligibilityPlans = _ref.eligibilityPlans;
2349
+ var suggestedPaymentPlanArray = Array.isArray(suggestedPaymentPlan) ? suggestedPaymentPlan : [suggestedPaymentPlan];
2350
+
2351
+ var _loop = function _loop(index) {
2352
+ var installmentsCount = suggestedPaymentPlanArray[index];
2353
+ var planFound = eligibilityPlans.findIndex(function (plan) {
2354
+ return plan.installments_count === installmentsCount && plan.eligible;
2355
+ });
2356
+
2357
+ if (planFound !== -1) {
2358
+ return {
2359
+ v: planFound
2360
+ };
2361
+ }
2362
+ };
2363
+
2364
+ for (var index in suggestedPaymentPlanArray) {
2365
+ var _ret = _loop(index);
2366
+
2367
+ if (typeof _ret === "object") return _ret.v;
2368
+ }
2369
+
2370
+ return 0;
2371
+ };
2372
+
2373
+ var s$b = {"widgetButton":"_TSkFv","logo":"_LJ4nZ","primaryContainer":"_bMClc","paymentPlans":"_17c_S","plan":"_2Kqjn","active":"_3dG_J","notEligible":"_3O1bg","info":"_25GrF","loader":"_30j1O","error":"_R0YlN","errorText":"_2kGhu","errorButton":"_73d_Y","pending":"_1ZDMS","clickable":"_UksZa","unClickable":"_1lr-q"};
2374
+
2375
+ var VERY_LONG_TIME_IN_MS = 1000 * 3600 * 24 * 365;
2376
+ var DEFAULT_TRANSITION_TIME = 5500;
2377
+
2378
+ var PaymentPlanWidget = function PaymentPlanWidget(_ref) {
2379
+ var _cx, _cx3;
2380
+
2381
+ var purchaseAmount = _ref.purchaseAmount,
2382
+ apiData = _ref.apiData,
2383
+ configPlans = _ref.configPlans,
2384
+ transitionDelay = _ref.transitionDelay,
2385
+ hideIfNotEligible = _ref.hideIfNotEligible,
2386
+ suggestedPaymentPlan = _ref.suggestedPaymentPlan;
2387
+
2388
+ var _useFetchEligibility = useFetchEligibility(purchaseAmount, apiData, configPlans),
2389
+ eligibilityPlans = _useFetchEligibility[0],
2390
+ status = _useFetchEligibility[1];
2391
+
2392
+ var eligiblePlans = eligibilityPlans.filter(function (plan) {
2393
+ return plan.eligible;
2394
+ });
2395
+ var activePlanIndex = getIndexOfActivePlan({
2396
+ eligibilityPlans: eligibilityPlans,
2397
+ suggestedPaymentPlan: suggestedPaymentPlan != null ? suggestedPaymentPlan : 0
2398
+ });
2399
+ var isSuggestedPaymentPlanSpecified = suggestedPaymentPlan !== undefined; // 👈 The merchant decided to focus a tab and remove animated transition.
2400
+
2401
+ var isTransitionSpecified = transitionDelay !== undefined; // 👈 The merchant has specified a transition time
2402
+
2403
+ var _useState = React.useState(false),
2404
+ isOpen = _useState[0],
2405
+ setIsOpen = _useState[1];
2406
+
2407
+ var openModal = function openModal() {
2408
+ return setIsOpen(true);
2409
+ };
2410
+
2411
+ var closeModal = function closeModal() {
2412
+ return setIsOpen(false);
2413
+ };
2414
+
2415
+ var eligiblePlanKeys = eligibilityPlans.reduce(function (acc, plan, index) {
2416
+ return plan.eligible ? [].concat(acc, [index]) : acc;
2417
+ }, []);
2418
+ /**
2419
+ * If merchand specify a suggestedPaymentPlan and no transition, we set a very long transition delay.
2420
+ * Otherwise, we set the transition delay specified by the merchant.
2421
+ * If none of those properties are specified, we set a default transition delay.
2422
+ * @returns
2423
+ */
2424
+
2425
+ var realTransitionTime = function realTransitionTime() {
2426
+ if (isTransitionSpecified) {
2427
+ return transitionDelay != null ? transitionDelay : DEFAULT_TRANSITION_TIME;
2428
+ }
2429
+
2430
+ if (isSuggestedPaymentPlanSpecified) {
2431
+ return VERY_LONG_TIME_IN_MS;
2432
+ }
2433
+
2434
+ return DEFAULT_TRANSITION_TIME;
2435
+ };
2436
+
2437
+ var _useButtonAnimation = useButtonAnimation(eligiblePlanKeys, realTransitionTime()),
2438
+ current = _useButtonAnimation.current,
2439
+ onHover = _useButtonAnimation.onHover,
2440
+ onLeave = _useButtonAnimation.onLeave;
2441
+
2442
+ React.useEffect(function () {
2443
+ // When API has given a response AND the marchand set an active plan by default.
2444
+ if (status === apiStatus.SUCCESS && isSuggestedPaymentPlanSpecified) {
2445
+ onHover(activePlanIndex); // We select the first active plan possible
2446
+
2447
+ onLeave(); // We need to call onLeave to reset the animation
2448
+ }
2449
+ }, [status]);
2450
+ /**
2451
+ * It takes a plan index and returns the index of that plan within the eligible plans
2452
+ *
2453
+ * @param {number} planIndex - The index of the plan that the user has selected.
2454
+ * @returns The index of the planKey in the eligiblePlanKeys array.
2455
+ */
2456
+
2457
+ var getIndexWithinEligiblePlans = function getIndexWithinEligiblePlans(planIndex) {
2458
+ var index = eligiblePlanKeys.findIndex(function (planKey) {
2459
+ return planKey === planIndex;
2460
+ });
2461
+ return index === -1 ? 0 : index;
2462
+ };
2463
+
2464
+ if (status === apiStatus.PENDING) {
2465
+ return /*#__PURE__*/React__default.createElement("div", {
2466
+ className: cx(s$b.widgetButton, s$b.pending)
2467
+ }, /*#__PURE__*/React__default.createElement(Loader, null));
2468
+ }
2469
+
2470
+ if (hideIfNotEligible && eligiblePlans.length === 0 || eligibilityPlans.length === 0 || status === apiStatus.FAILED) {
2471
+ return null;
2472
+ }
2473
+
2474
+ var handleOpenModal = function handleOpenModal(e) {
2475
+ e.preventDefault();
2476
+
2477
+ if (eligiblePlans.length > 0) {
2478
+ openModal();
2479
+ }
2480
+ };
2481
+
2482
+ return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("div", {
2483
+ onClick: handleOpenModal,
2484
+ className: cx(s$b.widgetButton, (_cx = {}, _cx[s$b.clickable] = eligiblePlans.length > 0, _cx[s$b.unClickable] = eligiblePlans.length === 0, _cx)),
2485
+ "data-testid": "widget-button"
2486
+ }, /*#__PURE__*/React__default.createElement("div", {
2487
+ className: s$b.primaryContainer
2488
+ }, /*#__PURE__*/React__default.createElement(LogoIcon, {
2489
+ className: s$b.logo
2490
+ }), /*#__PURE__*/React__default.createElement("div", {
2491
+ className: s$b.paymentPlans
2492
+ }, eligibilityPlans.map(function (eligibilityPlan, key) {
2493
+ var _cx2;
2494
+
2495
+ return /*#__PURE__*/React__default.createElement("div", {
2496
+ key: key,
2497
+ onMouseEnter: function onMouseEnter() {
2498
+ return onHover(key);
2499
+ },
2500
+ onMouseOut: onLeave,
2501
+ className: cx(s$b.plan, (_cx2 = {}, _cx2[s$b.active] = current === key, _cx2[s$b.notEligible] = !eligibilityPlan.eligible, _cx2))
2502
+ }, paymentPlanShorthandName(eligibilityPlan));
2503
+ }))), /*#__PURE__*/React__default.createElement("div", {
2504
+ className: cx(s$b.info, (_cx3 = {}, _cx3[s$b.notEligible] = eligibilityPlans[current] && !eligibilityPlans[current].eligible, _cx3))
2505
+ }, eligibilityPlans.length !== 0 && paymentPlanInfoText(eligibilityPlans[current]))), isOpen && /*#__PURE__*/React__default.createElement(EligibilityModal, {
2506
+ initialPlanIndex: getIndexWithinEligiblePlans(current),
2507
+ onClose: closeModal,
2508
+ eligibilityPlans: eligiblePlans,
2509
+ status: status
2510
+ }));
2511
+ };
2512
+
2513
+ var WidgetsController = /*#__PURE__*/function () {
2514
+ function WidgetsController(apiData) {
2515
+ this.apiData = apiData;
2516
+ }
2517
+
2518
+ var _proto = WidgetsController.prototype;
2519
+
2520
+ _proto.add = function add(widget, options) {
2521
+ var _this = this;
2522
+
2523
+ var containerDiv = document.querySelector(options.container);
2524
+
2525
+ if (containerDiv) {
2526
+ reactDom.unmountComponentAtNode(containerDiv);
2527
+ }
2528
+
2529
+ if (widget === widgetTypes.PaymentPlans) {
2530
+ var container = options.container,
2531
+ purchaseAmount = options.purchaseAmount,
2532
+ plans = options.plans,
2533
+ transitionDelay = options.transitionDelay,
2534
+ hideIfNotEligible = options.hideIfNotEligible,
2535
+ suggestedPaymentPlan = options.suggestedPaymentPlan,
2536
+ _options$locale = options.locale,
2537
+ locale = _options$locale === void 0 ? Locale.en : _options$locale;
2538
+
2539
+ if (containerDiv) {
2540
+ reactDom.render( /*#__PURE__*/React__default.createElement(Provider, {
2541
+ locale: locale
2542
+ }, /*#__PURE__*/React__default.createElement(PaymentPlanWidget, {
2543
+ purchaseAmount: purchaseAmount,
2544
+ apiData: this.apiData,
2545
+ configPlans: plans,
2546
+ transitionDelay: transitionDelay,
2547
+ hideIfNotEligible: hideIfNotEligible,
2548
+ suggestedPaymentPlan: suggestedPaymentPlan
2549
+ })), document.querySelector(container));
2550
+ }
2551
+ }
2552
+
2553
+ if (widget === widgetTypes.Modal) {
2554
+ var _container = options.container,
2555
+ clickableSelector = options.clickableSelector,
2556
+ _purchaseAmount = options.purchaseAmount,
2557
+ _plans = options.plans,
2558
+ _options$locale2 = options.locale,
2559
+ _locale = _options$locale2 === void 0 ? Locale.en : _options$locale2;
2560
+
2561
+ var close = function close() {
2562
+ return containerDiv && reactDom.unmountComponentAtNode(containerDiv);
2563
+ };
2564
+
2565
+ var renderModal = function renderModal() {
2566
+ reactDom.render( /*#__PURE__*/React__default.createElement(Provider, {
2567
+ locale: _locale
2568
+ }, /*#__PURE__*/React__default.createElement(ModalContainer, {
2569
+ purchaseAmount: _purchaseAmount,
2570
+ apiData: _this.apiData,
2571
+ configPlans: _plans,
2572
+ onClose: close
2573
+ })), document.querySelector(_container));
2574
+ }; // if clickableSelector is provided, add an onClick event handler to open the Modal.
2575
+
2576
+
2577
+ if (clickableSelector) {
2578
+ var _document$querySelect;
2579
+
2580
+ (_document$querySelect = document.querySelector(clickableSelector)) == null ? void 0 : _document$querySelect.addEventListener('click', renderModal, false);
2581
+ }
2582
+
2583
+ return {
2584
+ open: renderModal,
2585
+ close: close
2586
+ };
2587
+ }
2588
+ };
2589
+
2590
+ return WidgetsController;
2591
+ }();
2592
+
2593
+ (function (ApiMode) {
2594
+ ApiMode["LIVE"] = "https://api.getalma.eu";
2595
+ ApiMode["TEST"] = "https://api.sandbox.getalma.eu";
2596
+ })(exports.ApiMode || (exports.ApiMode = {}));
2597
+
2598
+ (function (Widgets) {
2599
+ function initialize(merchantId, mode) {
2600
+ return new WidgetsController({
2601
+ domain: mode,
2602
+ merchantId: merchantId
2603
+ });
2604
+ }
2605
+
2606
+ Widgets.initialize = initialize;
2607
+ Widgets.PaymentPlans = widgetTypes.PaymentPlans;
2608
+ Widgets.Modal = widgetTypes.Modal;
2609
+ })(exports.Widgets || (exports.Widgets = {})); // eslint-disable-next-line @typescript-eslint/no-namespace
2610
+
2611
+ (function (Utils) {
2612
+ Utils.priceToCents = priceToCents;
2613
+ Utils.priceFromCents = priceFromCents;
2614
+ Utils.formatCents = formatCents;
2615
+ })(exports.Utils || (exports.Utils = {}));
2616
+ //# sourceMappingURL=widgets.js.map