@bolttech/form-engine 3.1.1-beta.3 → 3.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.esm.js CHANGED
@@ -1,1650 +1,40 @@
1
- import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
2
- import { createContext, useContext, useRef, useEffect, useState, useMemo, useCallback, Suspense } from 'react';
1
+ 'use client';
2
+ import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
3
+ import { createContext, useContext, useRef, useEffect, useMemo, useState, useCallback, Suspense } from 'react';
3
4
  import { FormGroup, FormField } from '@bolttech/form-engine-core';
4
5
 
5
- var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
6
-
7
- var fails$b = function (exec) {
8
- try {
9
- return !!exec();
10
- } catch (error) {
11
- return true;
12
- }
13
- };
14
-
15
- var fails$a = fails$b;
16
-
17
- var functionBindNative = !fails$a(function () {
18
- // eslint-disable-next-line es/no-function-prototype-bind -- safe
19
- var test = (function () { /* empty */ }).bind();
20
- // eslint-disable-next-line no-prototype-builtins -- safe
21
- return typeof test != 'function' || test.hasOwnProperty('prototype');
22
- });
23
-
24
- var NATIVE_BIND$1 = functionBindNative;
25
-
26
- var FunctionPrototype$1 = Function.prototype;
27
- var call$6 = FunctionPrototype$1.call;
28
- var uncurryThisWithBind = NATIVE_BIND$1 && FunctionPrototype$1.bind.bind(call$6, call$6);
29
-
30
- var functionUncurryThis = NATIVE_BIND$1 ? uncurryThisWithBind : function (fn) {
31
- return function () {
32
- return call$6.apply(fn, arguments);
33
- };
34
- };
35
-
36
- var uncurryThis$a = functionUncurryThis;
37
-
38
- var toString$1 = uncurryThis$a({}.toString);
39
- var stringSlice$1 = uncurryThis$a(''.slice);
40
-
41
- var classofRaw = function (it) {
42
- return stringSlice$1(toString$1(it), 8, -1);
43
- };
44
-
45
- var uncurryThis$9 = functionUncurryThis;
46
- var fails$9 = fails$b;
47
- var classof = classofRaw;
48
-
49
- var $Object$3 = Object;
50
- var split = uncurryThis$9(''.split);
51
-
52
- // fallback for non-array-like ES3 and non-enumerable old V8 strings
53
- var indexedObject = fails$9(function () {
54
- // throws an error in rhino, see https://github.com/mozilla/rhino/issues/346
55
- // eslint-disable-next-line no-prototype-builtins -- safe
56
- return !$Object$3('z').propertyIsEnumerable(0);
57
- }) ? function (it) {
58
- return classof(it) === 'String' ? split(it, '') : $Object$3(it);
59
- } : $Object$3;
60
-
61
- // we can't use just `it == null` since of `document.all` special case
62
- // https://tc39.es/ecma262/#sec-IsHTMLDDA-internal-slot-aec
63
- var isNullOrUndefined$2 = function (it) {
64
- return it === null || it === undefined;
65
- };
66
-
67
- var isNullOrUndefined$1 = isNullOrUndefined$2;
68
-
69
- var $TypeError$6 = TypeError;
70
-
71
- // `RequireObjectCoercible` abstract operation
72
- // https://tc39.es/ecma262/#sec-requireobjectcoercible
73
- var requireObjectCoercible$3 = function (it) {
74
- if (isNullOrUndefined$1(it)) throw new $TypeError$6("Can't call method on " + it);
75
- return it;
76
- };
77
-
78
- // toObject with fallback for non-array-like ES3 strings
79
- var IndexedObject$1 = indexedObject;
80
- var requireObjectCoercible$2 = requireObjectCoercible$3;
81
-
82
- var toIndexedObject$5 = function (it) {
83
- return IndexedObject$1(requireObjectCoercible$2(it));
84
- };
85
-
86
- var check = function (it) {
87
- return it && it.Math === Math && it;
88
- };
89
-
90
- // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
91
- var globalThis_1 =
92
- // eslint-disable-next-line es/no-global-this -- safe
93
- check(typeof globalThis == 'object' && globalThis) ||
94
- check(typeof window == 'object' && window) ||
95
- // eslint-disable-next-line no-restricted-globals -- safe
96
- check(typeof self == 'object' && self) ||
97
- check(typeof commonjsGlobal == 'object' && commonjsGlobal) ||
98
- check(typeof commonjsGlobal == 'object' && commonjsGlobal) ||
99
- // eslint-disable-next-line no-new-func -- fallback
100
- (function () { return this; })() || Function('return this')();
101
-
102
- var sharedStore = {exports: {}};
103
-
104
- var globalThis$c = globalThis_1;
105
-
106
- // eslint-disable-next-line es/no-object-defineproperty -- safe
107
- var defineProperty$5 = Object.defineProperty;
108
-
109
- var defineGlobalProperty$3 = function (key, value) {
110
- try {
111
- defineProperty$5(globalThis$c, key, { value: value, configurable: true, writable: true });
112
- } catch (error) {
113
- globalThis$c[key] = value;
114
- } return value;
115
- };
116
-
117
- var globalThis$b = globalThis_1;
118
- var defineGlobalProperty$2 = defineGlobalProperty$3;
119
-
120
- var SHARED = '__core-js_shared__';
121
- var store$3 = sharedStore.exports = globalThis$b[SHARED] || defineGlobalProperty$2(SHARED, {});
122
-
123
- (store$3.versions || (store$3.versions = [])).push({
124
- version: '3.39.0',
125
- mode: 'global',
126
- copyright: '© 2014-2024 Denis Pushkarev (zloirock.ru)',
127
- license: 'https://github.com/zloirock/core-js/blob/v3.39.0/LICENSE',
128
- source: 'https://github.com/zloirock/core-js'
129
- });
130
-
131
- var store$2 = sharedStore.exports;
132
-
133
- var shared$3 = function (key, value) {
134
- return store$2[key] || (store$2[key] = value || {});
135
- };
136
-
137
- var requireObjectCoercible$1 = requireObjectCoercible$3;
138
-
139
- var $Object$2 = Object;
140
-
141
- // `ToObject` abstract operation
142
- // https://tc39.es/ecma262/#sec-toobject
143
- var toObject$3 = function (argument) {
144
- return $Object$2(requireObjectCoercible$1(argument));
145
- };
146
-
147
- var uncurryThis$8 = functionUncurryThis;
148
- var toObject$2 = toObject$3;
149
-
150
- var hasOwnProperty = uncurryThis$8({}.hasOwnProperty);
151
-
152
- // `HasOwnProperty` abstract operation
153
- // https://tc39.es/ecma262/#sec-hasownproperty
154
- // eslint-disable-next-line es/no-object-hasown -- safe
155
- var hasOwnProperty_1 = Object.hasOwn || function hasOwn(it, key) {
156
- return hasOwnProperty(toObject$2(it), key);
157
- };
158
-
159
- var uncurryThis$7 = functionUncurryThis;
160
-
161
- var id = 0;
162
- var postfix = Math.random();
163
- var toString = uncurryThis$7(1.0.toString);
164
-
165
- var uid$2 = function (key) {
166
- return 'Symbol(' + (key === undefined ? '' : key) + ')_' + toString(++id + postfix, 36);
167
- };
168
-
169
- var globalThis$a = globalThis_1;
170
-
171
- var navigator = globalThis$a.navigator;
172
- var userAgent$1 = navigator && navigator.userAgent;
173
-
174
- var environmentUserAgent = userAgent$1 ? String(userAgent$1) : '';
175
-
176
- var globalThis$9 = globalThis_1;
177
- var userAgent = environmentUserAgent;
178
-
179
- var process = globalThis$9.process;
180
- var Deno = globalThis$9.Deno;
181
- var versions = process && process.versions || Deno && Deno.version;
182
- var v8 = versions && versions.v8;
183
- var match, version;
184
-
185
- if (v8) {
186
- match = v8.split('.');
187
- // in old Chrome, versions of V8 isn't V8 = Chrome / 10
188
- // but their correct versions are not interesting for us
189
- version = match[0] > 0 && match[0] < 4 ? 1 : +(match[0] + match[1]);
190
- }
191
-
192
- // BrowserFS NodeJS `process` polyfill incorrectly set `.v8` to `0.0`
193
- // so check `userAgent` even if `.v8` exists, but 0
194
- if (!version && userAgent) {
195
- match = userAgent.match(/Edge\/(\d+)/);
196
- if (!match || match[1] >= 74) {
197
- match = userAgent.match(/Chrome\/(\d+)/);
198
- if (match) version = +match[1];
199
- }
200
- }
201
-
202
- var environmentV8Version = version;
203
-
204
- /* eslint-disable es/no-symbol -- required for testing */
205
- var V8_VERSION = environmentV8Version;
206
- var fails$8 = fails$b;
207
- var globalThis$8 = globalThis_1;
208
-
209
- var $String$4 = globalThis$8.String;
210
-
211
- // eslint-disable-next-line es/no-object-getownpropertysymbols -- required for testing
212
- var symbolConstructorDetection = !!Object.getOwnPropertySymbols && !fails$8(function () {
213
- var symbol = Symbol('symbol detection');
214
- // Chrome 38 Symbol has incorrect toString conversion
215
- // `get-own-property-symbols` polyfill symbols converted to object are not Symbol instances
216
- // nb: Do not call `String` directly to avoid this being optimized out to `symbol+''` which will,
217
- // of course, fail.
218
- return !$String$4(symbol) || !(Object(symbol) instanceof Symbol) ||
219
- // Chrome 38-40 symbols are not inherited from DOM collections prototypes to instances
220
- !Symbol.sham && V8_VERSION && V8_VERSION < 41;
221
- });
222
-
223
- /* eslint-disable es/no-symbol -- required for testing */
224
- var NATIVE_SYMBOL$1 = symbolConstructorDetection;
225
-
226
- var useSymbolAsUid = NATIVE_SYMBOL$1 &&
227
- !Symbol.sham &&
228
- typeof Symbol.iterator == 'symbol';
229
-
230
- var globalThis$7 = globalThis_1;
231
- var shared$2 = shared$3;
232
- var hasOwn$8 = hasOwnProperty_1;
233
- var uid$1 = uid$2;
234
- var NATIVE_SYMBOL = symbolConstructorDetection;
235
- var USE_SYMBOL_AS_UID$1 = useSymbolAsUid;
236
-
237
- var Symbol$1 = globalThis$7.Symbol;
238
- var WellKnownSymbolsStore = shared$2('wks');
239
- var createWellKnownSymbol = USE_SYMBOL_AS_UID$1 ? Symbol$1['for'] || Symbol$1 : Symbol$1 && Symbol$1.withoutSetter || uid$1;
240
-
241
- var wellKnownSymbol$6 = function (name) {
242
- if (!hasOwn$8(WellKnownSymbolsStore, name)) {
243
- WellKnownSymbolsStore[name] = NATIVE_SYMBOL && hasOwn$8(Symbol$1, name)
244
- ? Symbol$1[name]
245
- : createWellKnownSymbol('Symbol.' + name);
246
- } return WellKnownSymbolsStore[name];
247
- };
248
-
249
- // https://tc39.es/ecma262/#sec-IsHTMLDDA-internal-slot
250
- var documentAll = typeof document == 'object' && document.all;
251
-
252
- // `IsCallable` abstract operation
253
- // https://tc39.es/ecma262/#sec-iscallable
254
- // eslint-disable-next-line unicorn/no-typeof-undefined -- required for testing
255
- var isCallable$d = typeof documentAll == 'undefined' && documentAll !== undefined ? function (argument) {
256
- return typeof argument == 'function' || argument === documentAll;
257
- } : function (argument) {
258
- return typeof argument == 'function';
259
- };
260
-
261
- var isCallable$c = isCallable$d;
262
-
263
- var isObject$8 = function (it) {
264
- return typeof it == 'object' ? it !== null : isCallable$c(it);
265
- };
266
-
267
- var isObject$7 = isObject$8;
268
-
269
- var $String$3 = String;
270
- var $TypeError$5 = TypeError;
271
-
272
- // `Assert: Type(argument) is Object`
273
- var anObject$4 = function (argument) {
274
- if (isObject$7(argument)) return argument;
275
- throw new $TypeError$5($String$3(argument) + ' is not an object');
276
- };
277
-
278
- var objectDefineProperties = {};
279
-
280
- var fails$7 = fails$b;
281
-
282
- // Detect IE8's incomplete defineProperty implementation
283
- var descriptors = !fails$7(function () {
284
- // eslint-disable-next-line es/no-object-defineproperty -- required for testing
285
- return Object.defineProperty({}, 1, { get: function () { return 7; } })[1] !== 7;
286
- });
287
-
288
- var DESCRIPTORS$9 = descriptors;
289
- var fails$6 = fails$b;
290
-
291
- // V8 ~ Chrome 36-
292
- // https://bugs.chromium.org/p/v8/issues/detail?id=3334
293
- var v8PrototypeDefineBug = DESCRIPTORS$9 && fails$6(function () {
294
- // eslint-disable-next-line es/no-object-defineproperty -- required for testing
295
- return Object.defineProperty(function () { /* empty */ }, 'prototype', {
296
- value: 42,
297
- writable: false
298
- }).prototype !== 42;
299
- });
300
-
301
- var objectDefineProperty = {};
302
-
303
- var globalThis$6 = globalThis_1;
304
- var isObject$6 = isObject$8;
305
-
306
- var document$1 = globalThis$6.document;
307
- // typeof document.createElement is 'object' in old IE
308
- var EXISTS$1 = isObject$6(document$1) && isObject$6(document$1.createElement);
309
-
310
- var documentCreateElement$2 = function (it) {
311
- return EXISTS$1 ? document$1.createElement(it) : {};
312
- };
313
-
314
- var DESCRIPTORS$8 = descriptors;
315
- var fails$5 = fails$b;
316
- var createElement = documentCreateElement$2;
317
-
318
- // Thanks to IE8 for its funny defineProperty
319
- var ie8DomDefine = !DESCRIPTORS$8 && !fails$5(function () {
320
- // eslint-disable-next-line es/no-object-defineproperty -- required for testing
321
- return Object.defineProperty(createElement('div'), 'a', {
322
- get: function () { return 7; }
323
- }).a !== 7;
324
- });
325
-
326
- var NATIVE_BIND = functionBindNative;
327
-
328
- var call$5 = Function.prototype.call;
329
-
330
- var functionCall = NATIVE_BIND ? call$5.bind(call$5) : function () {
331
- return call$5.apply(call$5, arguments);
332
- };
333
-
334
- var globalThis$5 = globalThis_1;
335
- var isCallable$b = isCallable$d;
336
-
337
- var aFunction = function (argument) {
338
- return isCallable$b(argument) ? argument : undefined;
339
- };
340
-
341
- var getBuiltIn$3 = function (namespace, method) {
342
- return arguments.length < 2 ? aFunction(globalThis$5[namespace]) : globalThis$5[namespace] && globalThis$5[namespace][method];
343
- };
344
-
345
- var uncurryThis$6 = functionUncurryThis;
346
-
347
- var objectIsPrototypeOf = uncurryThis$6({}.isPrototypeOf);
348
-
349
- var getBuiltIn$2 = getBuiltIn$3;
350
- var isCallable$a = isCallable$d;
351
- var isPrototypeOf = objectIsPrototypeOf;
352
- var USE_SYMBOL_AS_UID = useSymbolAsUid;
353
-
354
- var $Object$1 = Object;
355
-
356
- var isSymbol$2 = USE_SYMBOL_AS_UID ? function (it) {
357
- return typeof it == 'symbol';
358
- } : function (it) {
359
- var $Symbol = getBuiltIn$2('Symbol');
360
- return isCallable$a($Symbol) && isPrototypeOf($Symbol.prototype, $Object$1(it));
361
- };
362
-
363
- var $String$2 = String;
364
-
365
- var tryToString$1 = function (argument) {
366
- try {
367
- return $String$2(argument);
368
- } catch (error) {
369
- return 'Object';
370
- }
371
- };
372
-
373
- var isCallable$9 = isCallable$d;
374
- var tryToString = tryToString$1;
375
-
376
- var $TypeError$4 = TypeError;
377
-
378
- // `Assert: IsCallable(argument) is true`
379
- var aCallable$2 = function (argument) {
380
- if (isCallable$9(argument)) return argument;
381
- throw new $TypeError$4(tryToString(argument) + ' is not a function');
382
- };
383
-
384
- var aCallable$1 = aCallable$2;
385
- var isNullOrUndefined = isNullOrUndefined$2;
386
-
387
- // `GetMethod` abstract operation
388
- // https://tc39.es/ecma262/#sec-getmethod
389
- var getMethod$1 = function (V, P) {
390
- var func = V[P];
391
- return isNullOrUndefined(func) ? undefined : aCallable$1(func);
392
- };
393
-
394
- var call$4 = functionCall;
395
- var isCallable$8 = isCallable$d;
396
- var isObject$5 = isObject$8;
397
-
398
- var $TypeError$3 = TypeError;
399
-
400
- // `OrdinaryToPrimitive` abstract operation
401
- // https://tc39.es/ecma262/#sec-ordinarytoprimitive
402
- var ordinaryToPrimitive$1 = function (input, pref) {
403
- var fn, val;
404
- if (pref === 'string' && isCallable$8(fn = input.toString) && !isObject$5(val = call$4(fn, input))) return val;
405
- if (isCallable$8(fn = input.valueOf) && !isObject$5(val = call$4(fn, input))) return val;
406
- if (pref !== 'string' && isCallable$8(fn = input.toString) && !isObject$5(val = call$4(fn, input))) return val;
407
- throw new $TypeError$3("Can't convert object to primitive value");
408
- };
409
-
410
- var call$3 = functionCall;
411
- var isObject$4 = isObject$8;
412
- var isSymbol$1 = isSymbol$2;
413
- var getMethod = getMethod$1;
414
- var ordinaryToPrimitive = ordinaryToPrimitive$1;
415
- var wellKnownSymbol$5 = wellKnownSymbol$6;
416
-
417
- var $TypeError$2 = TypeError;
418
- var TO_PRIMITIVE = wellKnownSymbol$5('toPrimitive');
419
-
420
- // `ToPrimitive` abstract operation
421
- // https://tc39.es/ecma262/#sec-toprimitive
422
- var toPrimitive$1 = function (input, pref) {
423
- if (!isObject$4(input) || isSymbol$1(input)) return input;
424
- var exoticToPrim = getMethod(input, TO_PRIMITIVE);
425
- var result;
426
- if (exoticToPrim) {
427
- if (pref === undefined) pref = 'default';
428
- result = call$3(exoticToPrim, input, pref);
429
- if (!isObject$4(result) || isSymbol$1(result)) return result;
430
- throw new $TypeError$2("Can't convert object to primitive value");
431
- }
432
- if (pref === undefined) pref = 'number';
433
- return ordinaryToPrimitive(input, pref);
434
- };
435
-
436
- var toPrimitive = toPrimitive$1;
437
- var isSymbol = isSymbol$2;
438
-
439
- // `ToPropertyKey` abstract operation
440
- // https://tc39.es/ecma262/#sec-topropertykey
441
- var toPropertyKey$2 = function (argument) {
442
- var key = toPrimitive(argument, 'string');
443
- return isSymbol(key) ? key : key + '';
444
- };
445
-
446
- var DESCRIPTORS$7 = descriptors;
447
- var IE8_DOM_DEFINE$1 = ie8DomDefine;
448
- var V8_PROTOTYPE_DEFINE_BUG$1 = v8PrototypeDefineBug;
449
- var anObject$3 = anObject$4;
450
- var toPropertyKey$1 = toPropertyKey$2;
451
-
452
- var $TypeError$1 = TypeError;
453
- // eslint-disable-next-line es/no-object-defineproperty -- safe
454
- var $defineProperty = Object.defineProperty;
455
- // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
456
- var $getOwnPropertyDescriptor$1 = Object.getOwnPropertyDescriptor;
457
- var ENUMERABLE = 'enumerable';
458
- var CONFIGURABLE$1 = 'configurable';
459
- var WRITABLE = 'writable';
460
-
461
- // `Object.defineProperty` method
462
- // https://tc39.es/ecma262/#sec-object.defineproperty
463
- objectDefineProperty.f = DESCRIPTORS$7 ? V8_PROTOTYPE_DEFINE_BUG$1 ? function defineProperty(O, P, Attributes) {
464
- anObject$3(O);
465
- P = toPropertyKey$1(P);
466
- anObject$3(Attributes);
467
- if (typeof O === 'function' && P === 'prototype' && 'value' in Attributes && WRITABLE in Attributes && !Attributes[WRITABLE]) {
468
- var current = $getOwnPropertyDescriptor$1(O, P);
469
- if (current && current[WRITABLE]) {
470
- O[P] = Attributes.value;
471
- Attributes = {
472
- configurable: CONFIGURABLE$1 in Attributes ? Attributes[CONFIGURABLE$1] : current[CONFIGURABLE$1],
473
- enumerable: ENUMERABLE in Attributes ? Attributes[ENUMERABLE] : current[ENUMERABLE],
474
- writable: false
475
- };
476
- }
477
- } return $defineProperty(O, P, Attributes);
478
- } : $defineProperty : function defineProperty(O, P, Attributes) {
479
- anObject$3(O);
480
- P = toPropertyKey$1(P);
481
- anObject$3(Attributes);
482
- if (IE8_DOM_DEFINE$1) try {
483
- return $defineProperty(O, P, Attributes);
484
- } catch (error) { /* empty */ }
485
- if ('get' in Attributes || 'set' in Attributes) throw new $TypeError$1('Accessors not supported');
486
- if ('value' in Attributes) O[P] = Attributes.value;
487
- return O;
488
- };
489
-
490
- var ceil = Math.ceil;
491
- var floor = Math.floor;
492
-
493
- // `Math.trunc` method
494
- // https://tc39.es/ecma262/#sec-math.trunc
495
- // eslint-disable-next-line es/no-math-trunc -- safe
496
- var mathTrunc = Math.trunc || function trunc(x) {
497
- var n = +x;
498
- return (n > 0 ? floor : ceil)(n);
499
- };
500
-
501
- var trunc = mathTrunc;
502
-
503
- // `ToIntegerOrInfinity` abstract operation
504
- // https://tc39.es/ecma262/#sec-tointegerorinfinity
505
- var toIntegerOrInfinity$2 = function (argument) {
506
- var number = +argument;
507
- // eslint-disable-next-line no-self-compare -- NaN check
508
- return number !== number || number === 0 ? 0 : trunc(number);
509
- };
510
-
511
- var toIntegerOrInfinity$1 = toIntegerOrInfinity$2;
512
-
513
- var max = Math.max;
514
- var min$1 = Math.min;
515
-
516
- // Helper for a popular repeating case of the spec:
517
- // Let integer be ? ToInteger(index).
518
- // If integer < 0, let result be max((length + integer), 0); else let result be min(integer, length).
519
- var toAbsoluteIndex$1 = function (index, length) {
520
- var integer = toIntegerOrInfinity$1(index);
521
- return integer < 0 ? max(integer + length, 0) : min$1(integer, length);
522
- };
523
-
524
- var toIntegerOrInfinity = toIntegerOrInfinity$2;
525
-
526
- var min = Math.min;
527
-
528
- // `ToLength` abstract operation
529
- // https://tc39.es/ecma262/#sec-tolength
530
- var toLength$1 = function (argument) {
531
- var len = toIntegerOrInfinity(argument);
532
- return len > 0 ? min(len, 0x1FFFFFFFFFFFFF) : 0; // 2 ** 53 - 1 == 9007199254740991
533
- };
534
-
535
- var toLength = toLength$1;
536
-
537
- // `LengthOfArrayLike` abstract operation
538
- // https://tc39.es/ecma262/#sec-lengthofarraylike
539
- var lengthOfArrayLike$1 = function (obj) {
540
- return toLength(obj.length);
541
- };
542
-
543
- var toIndexedObject$4 = toIndexedObject$5;
544
- var toAbsoluteIndex = toAbsoluteIndex$1;
545
- var lengthOfArrayLike = lengthOfArrayLike$1;
546
-
547
- // `Array.prototype.{ indexOf, includes }` methods implementation
548
- var createMethod = function (IS_INCLUDES) {
549
- return function ($this, el, fromIndex) {
550
- var O = toIndexedObject$4($this);
551
- var length = lengthOfArrayLike(O);
552
- if (length === 0) return !IS_INCLUDES && -1;
553
- var index = toAbsoluteIndex(fromIndex, length);
554
- var value;
555
- // Array#includes uses SameValueZero equality algorithm
556
- // eslint-disable-next-line no-self-compare -- NaN check
557
- if (IS_INCLUDES && el !== el) while (length > index) {
558
- value = O[index++];
559
- // eslint-disable-next-line no-self-compare -- NaN check
560
- if (value !== value) return true;
561
- // Array#indexOf ignores holes, Array#includes - not
562
- } else for (;length > index; index++) {
563
- if ((IS_INCLUDES || index in O) && O[index] === el) return IS_INCLUDES || index || 0;
564
- } return !IS_INCLUDES && -1;
565
- };
566
- };
567
-
568
- var arrayIncludes = {
569
- // `Array.prototype.includes` method
570
- // https://tc39.es/ecma262/#sec-array.prototype.includes
571
- includes: createMethod(true),
572
- // `Array.prototype.indexOf` method
573
- // https://tc39.es/ecma262/#sec-array.prototype.indexof
574
- indexOf: createMethod(false)
575
- };
576
-
577
- var hiddenKeys$4 = {};
578
-
579
- var uncurryThis$5 = functionUncurryThis;
580
- var hasOwn$7 = hasOwnProperty_1;
581
- var toIndexedObject$3 = toIndexedObject$5;
582
- var indexOf = arrayIncludes.indexOf;
583
- var hiddenKeys$3 = hiddenKeys$4;
584
-
585
- var push = uncurryThis$5([].push);
586
-
587
- var objectKeysInternal = function (object, names) {
588
- var O = toIndexedObject$3(object);
589
- var i = 0;
590
- var result = [];
591
- var key;
592
- for (key in O) !hasOwn$7(hiddenKeys$3, key) && hasOwn$7(O, key) && push(result, key);
593
- // Don't enum bug & hidden keys
594
- while (names.length > i) if (hasOwn$7(O, key = names[i++])) {
595
- ~indexOf(result, key) || push(result, key);
596
- }
597
- return result;
598
- };
599
-
600
- // IE8- don't enum bug keys
601
- var enumBugKeys$3 = [
602
- 'constructor',
603
- 'hasOwnProperty',
604
- 'isPrototypeOf',
605
- 'propertyIsEnumerable',
606
- 'toLocaleString',
607
- 'toString',
608
- 'valueOf'
609
- ];
610
-
611
- var internalObjectKeys$1 = objectKeysInternal;
612
- var enumBugKeys$2 = enumBugKeys$3;
613
-
614
- // `Object.keys` method
615
- // https://tc39.es/ecma262/#sec-object.keys
616
- // eslint-disable-next-line es/no-object-keys -- safe
617
- var objectKeys$2 = Object.keys || function keys(O) {
618
- return internalObjectKeys$1(O, enumBugKeys$2);
619
- };
620
-
621
- var DESCRIPTORS$6 = descriptors;
622
- var V8_PROTOTYPE_DEFINE_BUG = v8PrototypeDefineBug;
623
- var definePropertyModule$3 = objectDefineProperty;
624
- var anObject$2 = anObject$4;
625
- var toIndexedObject$2 = toIndexedObject$5;
626
- var objectKeys$1 = objectKeys$2;
627
-
628
- // `Object.defineProperties` method
629
- // https://tc39.es/ecma262/#sec-object.defineproperties
630
- // eslint-disable-next-line es/no-object-defineproperties -- safe
631
- objectDefineProperties.f = DESCRIPTORS$6 && !V8_PROTOTYPE_DEFINE_BUG ? Object.defineProperties : function defineProperties(O, Properties) {
632
- anObject$2(O);
633
- var props = toIndexedObject$2(Properties);
634
- var keys = objectKeys$1(Properties);
635
- var length = keys.length;
636
- var index = 0;
637
- var key;
638
- while (length > index) definePropertyModule$3.f(O, key = keys[index++], props[key]);
639
- return O;
640
- };
641
-
642
- var getBuiltIn$1 = getBuiltIn$3;
643
-
644
- var html$1 = getBuiltIn$1('document', 'documentElement');
645
-
646
- var shared$1 = shared$3;
647
- var uid = uid$2;
648
-
649
- var keys = shared$1('keys');
650
-
651
- var sharedKey$3 = function (key) {
652
- return keys[key] || (keys[key] = uid(key));
653
- };
654
-
655
- /* global ActiveXObject -- old IE, WSH */
656
- var anObject$1 = anObject$4;
657
- var definePropertiesModule = objectDefineProperties;
658
- var enumBugKeys$1 = enumBugKeys$3;
659
- var hiddenKeys$2 = hiddenKeys$4;
660
- var html = html$1;
661
- var documentCreateElement$1 = documentCreateElement$2;
662
- var sharedKey$2 = sharedKey$3;
663
-
664
- var GT = '>';
665
- var LT = '<';
666
- var PROTOTYPE = 'prototype';
667
- var SCRIPT = 'script';
668
- var IE_PROTO$1 = sharedKey$2('IE_PROTO');
669
-
670
- var EmptyConstructor = function () { /* empty */ };
671
-
672
- var scriptTag = function (content) {
673
- return LT + SCRIPT + GT + content + LT + '/' + SCRIPT + GT;
674
- };
675
-
676
- // Create object with fake `null` prototype: use ActiveX Object with cleared prototype
677
- var NullProtoObjectViaActiveX = function (activeXDocument) {
678
- activeXDocument.write(scriptTag(''));
679
- activeXDocument.close();
680
- var temp = activeXDocument.parentWindow.Object;
681
- // eslint-disable-next-line no-useless-assignment -- avoid memory leak
682
- activeXDocument = null;
683
- return temp;
684
- };
685
-
686
- // Create object with fake `null` prototype: use iframe Object with cleared prototype
687
- var NullProtoObjectViaIFrame = function () {
688
- // Thrash, waste and sodomy: IE GC bug
689
- var iframe = documentCreateElement$1('iframe');
690
- var JS = 'java' + SCRIPT + ':';
691
- var iframeDocument;
692
- iframe.style.display = 'none';
693
- html.appendChild(iframe);
694
- // https://github.com/zloirock/core-js/issues/475
695
- iframe.src = String(JS);
696
- iframeDocument = iframe.contentWindow.document;
697
- iframeDocument.open();
698
- iframeDocument.write(scriptTag('document.F=Object'));
699
- iframeDocument.close();
700
- return iframeDocument.F;
701
- };
702
-
703
- // Check for document.domain and active x support
704
- // No need to use active x approach when document.domain is not set
705
- // see https://github.com/es-shims/es5-shim/issues/150
706
- // variation of https://github.com/kitcambridge/es5-shim/commit/4f738ac066346
707
- // avoid IE GC bug
708
- var activeXDocument;
709
- var NullProtoObject = function () {
710
- try {
711
- activeXDocument = new ActiveXObject('htmlfile');
712
- } catch (error) { /* ignore */ }
713
- NullProtoObject = typeof document != 'undefined'
714
- ? document.domain && activeXDocument
715
- ? NullProtoObjectViaActiveX(activeXDocument) // old IE
716
- : NullProtoObjectViaIFrame()
717
- : NullProtoObjectViaActiveX(activeXDocument); // WSH
718
- var length = enumBugKeys$1.length;
719
- while (length--) delete NullProtoObject[PROTOTYPE][enumBugKeys$1[length]];
720
- return NullProtoObject();
721
- };
722
-
723
- hiddenKeys$2[IE_PROTO$1] = true;
724
-
725
- // `Object.create` method
726
- // https://tc39.es/ecma262/#sec-object.create
727
- // eslint-disable-next-line es/no-object-create -- safe
728
- var objectCreate = Object.create || function create(O, Properties) {
729
- var result;
730
- if (O !== null) {
731
- EmptyConstructor[PROTOTYPE] = anObject$1(O);
732
- result = new EmptyConstructor();
733
- EmptyConstructor[PROTOTYPE] = null;
734
- // add "__proto__" for Object.getPrototypeOf polyfill
735
- result[IE_PROTO$1] = O;
736
- } else result = NullProtoObject();
737
- return Properties === undefined ? result : definePropertiesModule.f(result, Properties);
738
- };
739
-
740
- var wellKnownSymbol$4 = wellKnownSymbol$6;
741
- var create$1 = objectCreate;
742
- var defineProperty$4 = objectDefineProperty.f;
743
-
744
- var UNSCOPABLES = wellKnownSymbol$4('unscopables');
745
- var ArrayPrototype = Array.prototype;
746
-
747
- // Array.prototype[@@unscopables]
748
- // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables
749
- if (ArrayPrototype[UNSCOPABLES] === undefined) {
750
- defineProperty$4(ArrayPrototype, UNSCOPABLES, {
751
- configurable: true,
752
- value: create$1(null)
753
- });
754
- }
755
-
756
- // add a key to Array.prototype[@@unscopables]
757
- var addToUnscopables$1 = function (key) {
758
- ArrayPrototype[UNSCOPABLES][key] = true;
759
- };
760
-
761
- var iterators = {};
762
-
763
- var globalThis$4 = globalThis_1;
764
- var isCallable$7 = isCallable$d;
765
-
766
- var WeakMap$1 = globalThis$4.WeakMap;
767
-
768
- var weakMapBasicDetection = isCallable$7(WeakMap$1) && /native code/.test(String(WeakMap$1));
769
-
770
- var createPropertyDescriptor$3 = function (bitmap, value) {
771
- return {
772
- enumerable: !(bitmap & 1),
773
- configurable: !(bitmap & 2),
774
- writable: !(bitmap & 4),
775
- value: value
776
- };
777
- };
778
-
779
- var DESCRIPTORS$5 = descriptors;
780
- var definePropertyModule$2 = objectDefineProperty;
781
- var createPropertyDescriptor$2 = createPropertyDescriptor$3;
782
-
783
- var createNonEnumerableProperty$4 = DESCRIPTORS$5 ? function (object, key, value) {
784
- return definePropertyModule$2.f(object, key, createPropertyDescriptor$2(1, value));
785
- } : function (object, key, value) {
786
- object[key] = value;
787
- return object;
788
- };
789
-
790
- var NATIVE_WEAK_MAP = weakMapBasicDetection;
791
- var globalThis$3 = globalThis_1;
792
- var isObject$3 = isObject$8;
793
- var createNonEnumerableProperty$3 = createNonEnumerableProperty$4;
794
- var hasOwn$6 = hasOwnProperty_1;
795
- var shared = sharedStore.exports;
796
- var sharedKey$1 = sharedKey$3;
797
- var hiddenKeys$1 = hiddenKeys$4;
798
-
799
- var OBJECT_ALREADY_INITIALIZED = 'Object already initialized';
800
- var TypeError$1 = globalThis$3.TypeError;
801
- var WeakMap = globalThis$3.WeakMap;
802
- var set, get, has;
803
-
804
- var enforce = function (it) {
805
- return has(it) ? get(it) : set(it, {});
806
- };
807
-
808
- var getterFor = function (TYPE) {
809
- return function (it) {
810
- var state;
811
- if (!isObject$3(it) || (state = get(it)).type !== TYPE) {
812
- throw new TypeError$1('Incompatible receiver, ' + TYPE + ' required');
813
- } return state;
814
- };
815
- };
816
-
817
- if (NATIVE_WEAK_MAP || shared.state) {
818
- var store$1 = shared.state || (shared.state = new WeakMap());
819
- /* eslint-disable no-self-assign -- prototype methods protection */
820
- store$1.get = store$1.get;
821
- store$1.has = store$1.has;
822
- store$1.set = store$1.set;
823
- /* eslint-enable no-self-assign -- prototype methods protection */
824
- set = function (it, metadata) {
825
- if (store$1.has(it)) throw new TypeError$1(OBJECT_ALREADY_INITIALIZED);
826
- metadata.facade = it;
827
- store$1.set(it, metadata);
828
- return metadata;
829
- };
830
- get = function (it) {
831
- return store$1.get(it) || {};
832
- };
833
- has = function (it) {
834
- return store$1.has(it);
835
- };
836
- } else {
837
- var STATE = sharedKey$1('state');
838
- hiddenKeys$1[STATE] = true;
839
- set = function (it, metadata) {
840
- if (hasOwn$6(it, STATE)) throw new TypeError$1(OBJECT_ALREADY_INITIALIZED);
841
- metadata.facade = it;
842
- createNonEnumerableProperty$3(it, STATE, metadata);
843
- return metadata;
844
- };
845
- get = function (it) {
846
- return hasOwn$6(it, STATE) ? it[STATE] : {};
847
- };
848
- has = function (it) {
849
- return hasOwn$6(it, STATE);
850
- };
851
- }
852
-
853
- var internalState = {
854
- set: set,
855
- get: get,
856
- has: has,
857
- enforce: enforce,
858
- getterFor: getterFor
859
- };
860
-
861
- var objectGetOwnPropertyDescriptor = {};
862
-
863
- var objectPropertyIsEnumerable = {};
864
-
865
- var $propertyIsEnumerable = {}.propertyIsEnumerable;
866
- // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
867
- var getOwnPropertyDescriptor$1 = Object.getOwnPropertyDescriptor;
868
-
869
- // Nashorn ~ JDK8 bug
870
- var NASHORN_BUG = getOwnPropertyDescriptor$1 && !$propertyIsEnumerable.call({ 1: 2 }, 1);
871
-
872
- // `Object.prototype.propertyIsEnumerable` method implementation
873
- // https://tc39.es/ecma262/#sec-object.prototype.propertyisenumerable
874
- objectPropertyIsEnumerable.f = NASHORN_BUG ? function propertyIsEnumerable(V) {
875
- var descriptor = getOwnPropertyDescriptor$1(this, V);
876
- return !!descriptor && descriptor.enumerable;
877
- } : $propertyIsEnumerable;
878
-
879
- var DESCRIPTORS$4 = descriptors;
880
- var call$2 = functionCall;
881
- var propertyIsEnumerableModule$1 = objectPropertyIsEnumerable;
882
- var createPropertyDescriptor$1 = createPropertyDescriptor$3;
883
- var toIndexedObject$1 = toIndexedObject$5;
884
- var toPropertyKey = toPropertyKey$2;
885
- var hasOwn$5 = hasOwnProperty_1;
886
- var IE8_DOM_DEFINE = ie8DomDefine;
887
-
888
- // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
889
- var $getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
890
-
891
- // `Object.getOwnPropertyDescriptor` method
892
- // https://tc39.es/ecma262/#sec-object.getownpropertydescriptor
893
- objectGetOwnPropertyDescriptor.f = DESCRIPTORS$4 ? $getOwnPropertyDescriptor : function getOwnPropertyDescriptor(O, P) {
894
- O = toIndexedObject$1(O);
895
- P = toPropertyKey(P);
896
- if (IE8_DOM_DEFINE) try {
897
- return $getOwnPropertyDescriptor(O, P);
898
- } catch (error) { /* empty */ }
899
- if (hasOwn$5(O, P)) return createPropertyDescriptor$1(!call$2(propertyIsEnumerableModule$1.f, O, P), O[P]);
900
- };
901
-
902
- var makeBuiltIn$2 = {exports: {}};
903
-
904
- var DESCRIPTORS$3 = descriptors;
905
- var hasOwn$4 = hasOwnProperty_1;
906
-
907
- var FunctionPrototype = Function.prototype;
908
- // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
909
- var getDescriptor = DESCRIPTORS$3 && Object.getOwnPropertyDescriptor;
910
-
911
- var EXISTS = hasOwn$4(FunctionPrototype, 'name');
912
- // additional protection from minified / mangled / dropped function names
913
- var PROPER = EXISTS && (function something() { /* empty */ }).name === 'something';
914
- var CONFIGURABLE = EXISTS && (!DESCRIPTORS$3 || (DESCRIPTORS$3 && getDescriptor(FunctionPrototype, 'name').configurable));
915
-
916
- var functionName = {
917
- EXISTS: EXISTS,
918
- PROPER: PROPER,
919
- CONFIGURABLE: CONFIGURABLE
920
- };
921
-
922
- var uncurryThis$4 = functionUncurryThis;
923
- var isCallable$6 = isCallable$d;
924
- var store = sharedStore.exports;
925
-
926
- var functionToString = uncurryThis$4(Function.toString);
927
-
928
- // this helper broken in `core-js@3.4.1-3.4.4`, so we can't use `shared` helper
929
- if (!isCallable$6(store.inspectSource)) {
930
- store.inspectSource = function (it) {
931
- return functionToString(it);
932
- };
933
- }
934
-
935
- var inspectSource$1 = store.inspectSource;
936
-
937
- var uncurryThis$3 = functionUncurryThis;
938
- var fails$4 = fails$b;
939
- var isCallable$5 = isCallable$d;
940
- var hasOwn$3 = hasOwnProperty_1;
941
- var DESCRIPTORS$2 = descriptors;
942
- var CONFIGURABLE_FUNCTION_NAME$1 = functionName.CONFIGURABLE;
943
- var inspectSource = inspectSource$1;
944
- var InternalStateModule$1 = internalState;
945
-
946
- var enforceInternalState = InternalStateModule$1.enforce;
947
- var getInternalState$1 = InternalStateModule$1.get;
948
- var $String$1 = String;
949
- // eslint-disable-next-line es/no-object-defineproperty -- safe
950
- var defineProperty$3 = Object.defineProperty;
951
- var stringSlice = uncurryThis$3(''.slice);
952
- var replace = uncurryThis$3(''.replace);
953
- var join = uncurryThis$3([].join);
954
-
955
- var CONFIGURABLE_LENGTH = DESCRIPTORS$2 && !fails$4(function () {
956
- return defineProperty$3(function () { /* empty */ }, 'length', { value: 8 }).length !== 8;
957
- });
958
-
959
- var TEMPLATE = String(String).split('String');
960
-
961
- var makeBuiltIn$1 = makeBuiltIn$2.exports = function (value, name, options) {
962
- if (stringSlice($String$1(name), 0, 7) === 'Symbol(') {
963
- name = '[' + replace($String$1(name), /^Symbol\(([^)]*)\).*$/, '$1') + ']';
964
- }
965
- if (options && options.getter) name = 'get ' + name;
966
- if (options && options.setter) name = 'set ' + name;
967
- if (!hasOwn$3(value, 'name') || (CONFIGURABLE_FUNCTION_NAME$1 && value.name !== name)) {
968
- if (DESCRIPTORS$2) defineProperty$3(value, 'name', { value: name, configurable: true });
969
- else value.name = name;
970
- }
971
- if (CONFIGURABLE_LENGTH && options && hasOwn$3(options, 'arity') && value.length !== options.arity) {
972
- defineProperty$3(value, 'length', { value: options.arity });
973
- }
974
- try {
975
- if (options && hasOwn$3(options, 'constructor') && options.constructor) {
976
- if (DESCRIPTORS$2) defineProperty$3(value, 'prototype', { writable: false });
977
- // in V8 ~ Chrome 53, prototypes of some methods, like `Array.prototype.values`, are non-writable
978
- } else if (value.prototype) value.prototype = undefined;
979
- } catch (error) { /* empty */ }
980
- var state = enforceInternalState(value);
981
- if (!hasOwn$3(state, 'source')) {
982
- state.source = join(TEMPLATE, typeof name == 'string' ? name : '');
983
- } return value;
984
- };
985
-
986
- // add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative
987
- // eslint-disable-next-line no-extend-native -- required
988
- Function.prototype.toString = makeBuiltIn$1(function toString() {
989
- return isCallable$5(this) && getInternalState$1(this).source || inspectSource(this);
990
- }, 'toString');
991
-
992
- var isCallable$4 = isCallable$d;
993
- var definePropertyModule$1 = objectDefineProperty;
994
- var makeBuiltIn = makeBuiltIn$2.exports;
995
- var defineGlobalProperty$1 = defineGlobalProperty$3;
996
-
997
- var defineBuiltIn$3 = function (O, key, value, options) {
998
- if (!options) options = {};
999
- var simple = options.enumerable;
1000
- var name = options.name !== undefined ? options.name : key;
1001
- if (isCallable$4(value)) makeBuiltIn(value, name, options);
1002
- if (options.global) {
1003
- if (simple) O[key] = value;
1004
- else defineGlobalProperty$1(key, value);
1005
- } else {
1006
- try {
1007
- if (!options.unsafe) delete O[key];
1008
- else if (O[key]) simple = true;
1009
- } catch (error) { /* empty */ }
1010
- if (simple) O[key] = value;
1011
- else definePropertyModule$1.f(O, key, {
1012
- value: value,
1013
- enumerable: false,
1014
- configurable: !options.nonConfigurable,
1015
- writable: !options.nonWritable
1016
- });
1017
- } return O;
1018
- };
1019
-
1020
- var objectGetOwnPropertyNames = {};
1021
-
1022
- var internalObjectKeys = objectKeysInternal;
1023
- var enumBugKeys = enumBugKeys$3;
1024
-
1025
- var hiddenKeys = enumBugKeys.concat('length', 'prototype');
1026
-
1027
- // `Object.getOwnPropertyNames` method
1028
- // https://tc39.es/ecma262/#sec-object.getownpropertynames
1029
- // eslint-disable-next-line es/no-object-getownpropertynames -- safe
1030
- objectGetOwnPropertyNames.f = Object.getOwnPropertyNames || function getOwnPropertyNames(O) {
1031
- return internalObjectKeys(O, hiddenKeys);
1032
- };
1033
-
1034
- var objectGetOwnPropertySymbols = {};
1035
-
1036
- // eslint-disable-next-line es/no-object-getownpropertysymbols -- safe
1037
- objectGetOwnPropertySymbols.f = Object.getOwnPropertySymbols;
1038
-
1039
- var getBuiltIn = getBuiltIn$3;
1040
- var uncurryThis$2 = functionUncurryThis;
1041
- var getOwnPropertyNamesModule = objectGetOwnPropertyNames;
1042
- var getOwnPropertySymbolsModule$1 = objectGetOwnPropertySymbols;
1043
- var anObject = anObject$4;
1044
-
1045
- var concat$1 = uncurryThis$2([].concat);
1046
-
1047
- // all object keys, includes non-enumerable and symbols
1048
- var ownKeys$1 = getBuiltIn('Reflect', 'ownKeys') || function ownKeys(it) {
1049
- var keys = getOwnPropertyNamesModule.f(anObject(it));
1050
- var getOwnPropertySymbols = getOwnPropertySymbolsModule$1.f;
1051
- return getOwnPropertySymbols ? concat$1(keys, getOwnPropertySymbols(it)) : keys;
1052
- };
1053
-
1054
- var hasOwn$2 = hasOwnProperty_1;
1055
- var ownKeys = ownKeys$1;
1056
- var getOwnPropertyDescriptorModule = objectGetOwnPropertyDescriptor;
1057
- var definePropertyModule = objectDefineProperty;
1058
-
1059
- var copyConstructorProperties$1 = function (target, source, exceptions) {
1060
- var keys = ownKeys(source);
1061
- var defineProperty = definePropertyModule.f;
1062
- var getOwnPropertyDescriptor = getOwnPropertyDescriptorModule.f;
1063
- for (var i = 0; i < keys.length; i++) {
1064
- var key = keys[i];
1065
- if (!hasOwn$2(target, key) && !(exceptions && hasOwn$2(exceptions, key))) {
1066
- defineProperty(target, key, getOwnPropertyDescriptor(source, key));
1067
- }
1068
- }
1069
- };
1070
-
1071
- var fails$3 = fails$b;
1072
- var isCallable$3 = isCallable$d;
1073
-
1074
- var replacement = /#|\.prototype\./;
1075
-
1076
- var isForced$1 = function (feature, detection) {
1077
- var value = data[normalize(feature)];
1078
- return value === POLYFILL ? true
1079
- : value === NATIVE ? false
1080
- : isCallable$3(detection) ? fails$3(detection)
1081
- : !!detection;
1082
- };
1083
-
1084
- var normalize = isForced$1.normalize = function (string) {
1085
- return String(string).replace(replacement, '.').toLowerCase();
1086
- };
1087
-
1088
- var data = isForced$1.data = {};
1089
- var NATIVE = isForced$1.NATIVE = 'N';
1090
- var POLYFILL = isForced$1.POLYFILL = 'P';
1091
-
1092
- var isForced_1 = isForced$1;
1093
-
1094
- var globalThis$2 = globalThis_1;
1095
- var getOwnPropertyDescriptor = objectGetOwnPropertyDescriptor.f;
1096
- var createNonEnumerableProperty$2 = createNonEnumerableProperty$4;
1097
- var defineBuiltIn$2 = defineBuiltIn$3;
1098
- var defineGlobalProperty = defineGlobalProperty$3;
1099
- var copyConstructorProperties = copyConstructorProperties$1;
1100
- var isForced = isForced_1;
1101
-
1102
- /*
1103
- options.target - name of the target object
1104
- options.global - target is the global object
1105
- options.stat - export as static methods of target
1106
- options.proto - export as prototype methods of target
1107
- options.real - real prototype method for the `pure` version
1108
- options.forced - export even if the native feature is available
1109
- options.bind - bind methods to the target, required for the `pure` version
1110
- options.wrap - wrap constructors to preventing global pollution, required for the `pure` version
1111
- options.unsafe - use the simple assignment of property instead of delete + defineProperty
1112
- options.sham - add a flag to not completely full polyfills
1113
- options.enumerable - export as enumerable property
1114
- options.dontCallGetSet - prevent calling a getter on target
1115
- options.name - the .name of the function if it does not match the key
1116
- */
1117
- var _export = function (options, source) {
1118
- var TARGET = options.target;
1119
- var GLOBAL = options.global;
1120
- var STATIC = options.stat;
1121
- var FORCED, target, key, targetProperty, sourceProperty, descriptor;
1122
- if (GLOBAL) {
1123
- target = globalThis$2;
1124
- } else if (STATIC) {
1125
- target = globalThis$2[TARGET] || defineGlobalProperty(TARGET, {});
1126
- } else {
1127
- target = globalThis$2[TARGET] && globalThis$2[TARGET].prototype;
1128
- }
1129
- if (target) for (key in source) {
1130
- sourceProperty = source[key];
1131
- if (options.dontCallGetSet) {
1132
- descriptor = getOwnPropertyDescriptor(target, key);
1133
- targetProperty = descriptor && descriptor.value;
1134
- } else targetProperty = target[key];
1135
- FORCED = isForced(GLOBAL ? key : TARGET + (STATIC ? '.' : '#') + key, options.forced);
1136
- // contained in target
1137
- if (!FORCED && targetProperty !== undefined) {
1138
- if (typeof sourceProperty == typeof targetProperty) continue;
1139
- copyConstructorProperties(sourceProperty, targetProperty);
1140
- }
1141
- // add a flag to not completely full polyfills
1142
- if (options.sham || (targetProperty && targetProperty.sham)) {
1143
- createNonEnumerableProperty$2(sourceProperty, 'sham', true);
1144
- }
1145
- defineBuiltIn$2(target, key, sourceProperty, options);
1146
- }
1147
- };
1148
-
1149
- var fails$2 = fails$b;
1150
-
1151
- var correctPrototypeGetter = !fails$2(function () {
1152
- function F() { /* empty */ }
1153
- F.prototype.constructor = null;
1154
- // eslint-disable-next-line es/no-object-getprototypeof -- required for testing
1155
- return Object.getPrototypeOf(new F()) !== F.prototype;
1156
- });
1157
-
1158
- var hasOwn$1 = hasOwnProperty_1;
1159
- var isCallable$2 = isCallable$d;
1160
- var toObject$1 = toObject$3;
1161
- var sharedKey = sharedKey$3;
1162
- var CORRECT_PROTOTYPE_GETTER = correctPrototypeGetter;
1163
-
1164
- var IE_PROTO = sharedKey('IE_PROTO');
1165
- var $Object = Object;
1166
- var ObjectPrototype = $Object.prototype;
1167
-
1168
- // `Object.getPrototypeOf` method
1169
- // https://tc39.es/ecma262/#sec-object.getprototypeof
1170
- // eslint-disable-next-line es/no-object-getprototypeof -- safe
1171
- var objectGetPrototypeOf = CORRECT_PROTOTYPE_GETTER ? $Object.getPrototypeOf : function (O) {
1172
- var object = toObject$1(O);
1173
- if (hasOwn$1(object, IE_PROTO)) return object[IE_PROTO];
1174
- var constructor = object.constructor;
1175
- if (isCallable$2(constructor) && object instanceof constructor) {
1176
- return constructor.prototype;
1177
- } return object instanceof $Object ? ObjectPrototype : null;
1178
- };
1179
-
1180
- var fails$1 = fails$b;
1181
- var isCallable$1 = isCallable$d;
1182
- var isObject$2 = isObject$8;
1183
- var getPrototypeOf$1 = objectGetPrototypeOf;
1184
- var defineBuiltIn$1 = defineBuiltIn$3;
1185
- var wellKnownSymbol$3 = wellKnownSymbol$6;
1186
-
1187
- var ITERATOR$2 = wellKnownSymbol$3('iterator');
1188
- var BUGGY_SAFARI_ITERATORS$1 = false;
1189
-
1190
- // `%IteratorPrototype%` object
1191
- // https://tc39.es/ecma262/#sec-%iteratorprototype%-object
1192
- var IteratorPrototype$2, PrototypeOfArrayIteratorPrototype, arrayIterator;
1193
-
1194
- /* eslint-disable es/no-array-prototype-keys -- safe */
1195
- if ([].keys) {
1196
- arrayIterator = [].keys();
1197
- // Safari 8 has buggy iterators w/o `next`
1198
- if (!('next' in arrayIterator)) BUGGY_SAFARI_ITERATORS$1 = true;
1199
- else {
1200
- PrototypeOfArrayIteratorPrototype = getPrototypeOf$1(getPrototypeOf$1(arrayIterator));
1201
- if (PrototypeOfArrayIteratorPrototype !== Object.prototype) IteratorPrototype$2 = PrototypeOfArrayIteratorPrototype;
1202
- }
1203
- }
1204
-
1205
- var NEW_ITERATOR_PROTOTYPE = !isObject$2(IteratorPrototype$2) || fails$1(function () {
1206
- var test = {};
1207
- // FF44- legacy iterators case
1208
- return IteratorPrototype$2[ITERATOR$2].call(test) !== test;
1209
- });
1210
-
1211
- if (NEW_ITERATOR_PROTOTYPE) IteratorPrototype$2 = {};
1212
-
1213
- // `%IteratorPrototype%[@@iterator]()` method
1214
- // https://tc39.es/ecma262/#sec-%iteratorprototype%-@@iterator
1215
- if (!isCallable$1(IteratorPrototype$2[ITERATOR$2])) {
1216
- defineBuiltIn$1(IteratorPrototype$2, ITERATOR$2, function () {
1217
- return this;
1218
- });
1219
- }
1220
-
1221
- var iteratorsCore = {
1222
- IteratorPrototype: IteratorPrototype$2,
1223
- BUGGY_SAFARI_ITERATORS: BUGGY_SAFARI_ITERATORS$1
1224
- };
1225
-
1226
- var defineProperty$2 = objectDefineProperty.f;
1227
- var hasOwn = hasOwnProperty_1;
1228
- var wellKnownSymbol$2 = wellKnownSymbol$6;
1229
-
1230
- var TO_STRING_TAG = wellKnownSymbol$2('toStringTag');
1231
-
1232
- var setToStringTag$3 = function (target, TAG, STATIC) {
1233
- if (target && !STATIC) target = target.prototype;
1234
- if (target && !hasOwn(target, TO_STRING_TAG)) {
1235
- defineProperty$2(target, TO_STRING_TAG, { configurable: true, value: TAG });
1236
- }
1237
- };
1238
-
1239
- var IteratorPrototype$1 = iteratorsCore.IteratorPrototype;
1240
- var create = objectCreate;
1241
- var createPropertyDescriptor = createPropertyDescriptor$3;
1242
- var setToStringTag$2 = setToStringTag$3;
1243
- var Iterators$2 = iterators;
1244
-
1245
- var returnThis$1 = function () { return this; };
1246
-
1247
- var iteratorCreateConstructor = function (IteratorConstructor, NAME, next, ENUMERABLE_NEXT) {
1248
- var TO_STRING_TAG = NAME + ' Iterator';
1249
- IteratorConstructor.prototype = create(IteratorPrototype$1, { next: createPropertyDescriptor(+!ENUMERABLE_NEXT, next) });
1250
- setToStringTag$2(IteratorConstructor, TO_STRING_TAG, false);
1251
- Iterators$2[TO_STRING_TAG] = returnThis$1;
1252
- return IteratorConstructor;
1253
- };
1254
-
1255
- var uncurryThis$1 = functionUncurryThis;
1256
- var aCallable = aCallable$2;
1257
-
1258
- var functionUncurryThisAccessor = function (object, key, method) {
1259
- try {
1260
- // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
1261
- return uncurryThis$1(aCallable(Object.getOwnPropertyDescriptor(object, key)[method]));
1262
- } catch (error) { /* empty */ }
1263
- };
1264
-
1265
- var isObject$1 = isObject$8;
1266
-
1267
- var isPossiblePrototype$1 = function (argument) {
1268
- return isObject$1(argument) || argument === null;
1269
- };
1270
-
1271
- var isPossiblePrototype = isPossiblePrototype$1;
1272
-
1273
- var $String = String;
1274
- var $TypeError = TypeError;
1275
-
1276
- var aPossiblePrototype$1 = function (argument) {
1277
- if (isPossiblePrototype(argument)) return argument;
1278
- throw new $TypeError("Can't set " + $String(argument) + ' as a prototype');
1279
- };
1280
-
1281
- /* eslint-disable no-proto -- safe */
1282
- var uncurryThisAccessor = functionUncurryThisAccessor;
1283
- var isObject = isObject$8;
1284
- var requireObjectCoercible = requireObjectCoercible$3;
1285
- var aPossiblePrototype = aPossiblePrototype$1;
1286
-
1287
- // `Object.setPrototypeOf` method
1288
- // https://tc39.es/ecma262/#sec-object.setprototypeof
1289
- // Works with __proto__ only. Old v8 can't work with null proto objects.
1290
- // eslint-disable-next-line es/no-object-setprototypeof -- safe
1291
- var objectSetPrototypeOf = Object.setPrototypeOf || ('__proto__' in {} ? function () {
1292
- var CORRECT_SETTER = false;
1293
- var test = {};
1294
- var setter;
1295
- try {
1296
- setter = uncurryThisAccessor(Object.prototype, '__proto__', 'set');
1297
- setter(test, []);
1298
- CORRECT_SETTER = test instanceof Array;
1299
- } catch (error) { /* empty */ }
1300
- return function setPrototypeOf(O, proto) {
1301
- requireObjectCoercible(O);
1302
- aPossiblePrototype(proto);
1303
- if (!isObject(O)) return O;
1304
- if (CORRECT_SETTER) setter(O, proto);
1305
- else O.__proto__ = proto;
1306
- return O;
1307
- };
1308
- }() : undefined);
1309
-
1310
- var $$1 = _export;
1311
- var call$1 = functionCall;
1312
- var FunctionName = functionName;
1313
- var isCallable = isCallable$d;
1314
- var createIteratorConstructor = iteratorCreateConstructor;
1315
- var getPrototypeOf = objectGetPrototypeOf;
1316
- var setPrototypeOf = objectSetPrototypeOf;
1317
- var setToStringTag$1 = setToStringTag$3;
1318
- var createNonEnumerableProperty$1 = createNonEnumerableProperty$4;
1319
- var defineBuiltIn = defineBuiltIn$3;
1320
- var wellKnownSymbol$1 = wellKnownSymbol$6;
1321
- var Iterators$1 = iterators;
1322
- var IteratorsCore = iteratorsCore;
1323
-
1324
- var PROPER_FUNCTION_NAME = FunctionName.PROPER;
1325
- var CONFIGURABLE_FUNCTION_NAME = FunctionName.CONFIGURABLE;
1326
- var IteratorPrototype = IteratorsCore.IteratorPrototype;
1327
- var BUGGY_SAFARI_ITERATORS = IteratorsCore.BUGGY_SAFARI_ITERATORS;
1328
- var ITERATOR$1 = wellKnownSymbol$1('iterator');
1329
- var KEYS = 'keys';
1330
- var VALUES = 'values';
1331
- var ENTRIES = 'entries';
1332
-
1333
- var returnThis = function () { return this; };
1334
-
1335
- var iteratorDefine = function (Iterable, NAME, IteratorConstructor, next, DEFAULT, IS_SET, FORCED) {
1336
- createIteratorConstructor(IteratorConstructor, NAME, next);
1337
-
1338
- var getIterationMethod = function (KIND) {
1339
- if (KIND === DEFAULT && defaultIterator) return defaultIterator;
1340
- if (!BUGGY_SAFARI_ITERATORS && KIND && KIND in IterablePrototype) return IterablePrototype[KIND];
1341
-
1342
- switch (KIND) {
1343
- case KEYS: return function keys() { return new IteratorConstructor(this, KIND); };
1344
- case VALUES: return function values() { return new IteratorConstructor(this, KIND); };
1345
- case ENTRIES: return function entries() { return new IteratorConstructor(this, KIND); };
1346
- }
1347
-
1348
- return function () { return new IteratorConstructor(this); };
1349
- };
1350
-
1351
- var TO_STRING_TAG = NAME + ' Iterator';
1352
- var INCORRECT_VALUES_NAME = false;
1353
- var IterablePrototype = Iterable.prototype;
1354
- var nativeIterator = IterablePrototype[ITERATOR$1]
1355
- || IterablePrototype['@@iterator']
1356
- || DEFAULT && IterablePrototype[DEFAULT];
1357
- var defaultIterator = !BUGGY_SAFARI_ITERATORS && nativeIterator || getIterationMethod(DEFAULT);
1358
- var anyNativeIterator = NAME === 'Array' ? IterablePrototype.entries || nativeIterator : nativeIterator;
1359
- var CurrentIteratorPrototype, methods, KEY;
1360
-
1361
- // fix native
1362
- if (anyNativeIterator) {
1363
- CurrentIteratorPrototype = getPrototypeOf(anyNativeIterator.call(new Iterable()));
1364
- if (CurrentIteratorPrototype !== Object.prototype && CurrentIteratorPrototype.next) {
1365
- if (getPrototypeOf(CurrentIteratorPrototype) !== IteratorPrototype) {
1366
- if (setPrototypeOf) {
1367
- setPrototypeOf(CurrentIteratorPrototype, IteratorPrototype);
1368
- } else if (!isCallable(CurrentIteratorPrototype[ITERATOR$1])) {
1369
- defineBuiltIn(CurrentIteratorPrototype, ITERATOR$1, returnThis);
1370
- }
1371
- }
1372
- // Set @@toStringTag to native iterators
1373
- setToStringTag$1(CurrentIteratorPrototype, TO_STRING_TAG, true);
1374
- }
1375
- }
1376
-
1377
- // fix Array.prototype.{ values, @@iterator }.name in V8 / FF
1378
- if (PROPER_FUNCTION_NAME && DEFAULT === VALUES && nativeIterator && nativeIterator.name !== VALUES) {
1379
- if (CONFIGURABLE_FUNCTION_NAME) {
1380
- createNonEnumerableProperty$1(IterablePrototype, 'name', VALUES);
1381
- } else {
1382
- INCORRECT_VALUES_NAME = true;
1383
- defaultIterator = function values() { return call$1(nativeIterator, this); };
1384
- }
1385
- }
1386
-
1387
- // export additional methods
1388
- if (DEFAULT) {
1389
- methods = {
1390
- values: getIterationMethod(VALUES),
1391
- keys: IS_SET ? defaultIterator : getIterationMethod(KEYS),
1392
- entries: getIterationMethod(ENTRIES)
1393
- };
1394
- if (FORCED) for (KEY in methods) {
1395
- if (BUGGY_SAFARI_ITERATORS || INCORRECT_VALUES_NAME || !(KEY in IterablePrototype)) {
1396
- defineBuiltIn(IterablePrototype, KEY, methods[KEY]);
1397
- }
1398
- } else $$1({ target: NAME, proto: true, forced: BUGGY_SAFARI_ITERATORS || INCORRECT_VALUES_NAME }, methods);
1399
- }
1400
-
1401
- // define iterator
1402
- if (IterablePrototype[ITERATOR$1] !== defaultIterator) {
1403
- defineBuiltIn(IterablePrototype, ITERATOR$1, defaultIterator, { name: DEFAULT });
1404
- }
1405
- Iterators$1[NAME] = defaultIterator;
1406
-
1407
- return methods;
1408
- };
1409
-
1410
- // `CreateIterResultObject` abstract operation
1411
- // https://tc39.es/ecma262/#sec-createiterresultobject
1412
- var createIterResultObject$1 = function (value, done) {
1413
- return { value: value, done: done };
1414
- };
1415
-
1416
- var toIndexedObject = toIndexedObject$5;
1417
- var addToUnscopables = addToUnscopables$1;
1418
- var Iterators = iterators;
1419
- var InternalStateModule = internalState;
1420
- var defineProperty$1 = objectDefineProperty.f;
1421
- var defineIterator = iteratorDefine;
1422
- var createIterResultObject = createIterResultObject$1;
1423
- var DESCRIPTORS$1 = descriptors;
1424
-
1425
- var ARRAY_ITERATOR = 'Array Iterator';
1426
- var setInternalState = InternalStateModule.set;
1427
- var getInternalState = InternalStateModule.getterFor(ARRAY_ITERATOR);
1428
-
1429
- // `Array.prototype.entries` method
1430
- // https://tc39.es/ecma262/#sec-array.prototype.entries
1431
- // `Array.prototype.keys` method
1432
- // https://tc39.es/ecma262/#sec-array.prototype.keys
1433
- // `Array.prototype.values` method
1434
- // https://tc39.es/ecma262/#sec-array.prototype.values
1435
- // `Array.prototype[@@iterator]` method
1436
- // https://tc39.es/ecma262/#sec-array.prototype-@@iterator
1437
- // `CreateArrayIterator` internal method
1438
- // https://tc39.es/ecma262/#sec-createarrayiterator
1439
- var es_array_iterator = defineIterator(Array, 'Array', function (iterated, kind) {
1440
- setInternalState(this, {
1441
- type: ARRAY_ITERATOR,
1442
- target: toIndexedObject(iterated), // target
1443
- index: 0, // next index
1444
- kind: kind // kind
1445
- });
1446
- // `%ArrayIteratorPrototype%.next` method
1447
- // https://tc39.es/ecma262/#sec-%arrayiteratorprototype%.next
1448
- }, function () {
1449
- var state = getInternalState(this);
1450
- var target = state.target;
1451
- var index = state.index++;
1452
- if (!target || index >= target.length) {
1453
- state.target = null;
1454
- return createIterResultObject(undefined, true);
1455
- }
1456
- switch (state.kind) {
1457
- case 'keys': return createIterResultObject(index, false);
1458
- case 'values': return createIterResultObject(target[index], false);
1459
- } return createIterResultObject([index, target[index]], false);
1460
- }, 'values');
1461
-
1462
- // argumentsList[@@iterator] is %ArrayProto_values%
1463
- // https://tc39.es/ecma262/#sec-createunmappedargumentsobject
1464
- // https://tc39.es/ecma262/#sec-createmappedargumentsobject
1465
- var values = Iterators.Arguments = Iterators.Array;
1466
-
1467
- // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables
1468
- addToUnscopables('keys');
1469
- addToUnscopables('values');
1470
- addToUnscopables('entries');
1471
-
1472
- // V8 ~ Chrome 45- bug
1473
- if (DESCRIPTORS$1 && values.name !== 'values') try {
1474
- defineProperty$1(values, 'name', { value: 'values' });
1475
- } catch (error) { /* empty */ }
1476
-
1477
- // iterable DOM collections
1478
- // flag - `iterable` interface - 'entries', 'keys', 'values', 'forEach' methods
1479
- var domIterables = {
1480
- CSSRuleList: 0,
1481
- CSSStyleDeclaration: 0,
1482
- CSSValueList: 0,
1483
- ClientRectList: 0,
1484
- DOMRectList: 0,
1485
- DOMStringList: 0,
1486
- DOMTokenList: 1,
1487
- DataTransferItemList: 0,
1488
- FileList: 0,
1489
- HTMLAllCollection: 0,
1490
- HTMLCollection: 0,
1491
- HTMLFormElement: 0,
1492
- HTMLSelectElement: 0,
1493
- MediaList: 0,
1494
- MimeTypeArray: 0,
1495
- NamedNodeMap: 0,
1496
- NodeList: 1,
1497
- PaintRequestList: 0,
1498
- Plugin: 0,
1499
- PluginArray: 0,
1500
- SVGLengthList: 0,
1501
- SVGNumberList: 0,
1502
- SVGPathSegList: 0,
1503
- SVGPointList: 0,
1504
- SVGStringList: 0,
1505
- SVGTransformList: 0,
1506
- SourceBufferList: 0,
1507
- StyleSheetList: 0,
1508
- TextTrackCueList: 0,
1509
- TextTrackList: 0,
1510
- TouchList: 0
1511
- };
1512
-
1513
- // in old WebKit versions, `element.classList` is not an instance of global `DOMTokenList`
1514
- var documentCreateElement = documentCreateElement$2;
1515
-
1516
- var classList = documentCreateElement('span').classList;
1517
- var DOMTokenListPrototype$1 = classList && classList.constructor && classList.constructor.prototype;
1518
-
1519
- var domTokenListPrototype = DOMTokenListPrototype$1 === Object.prototype ? undefined : DOMTokenListPrototype$1;
1520
-
1521
- var globalThis$1 = globalThis_1;
1522
- var DOMIterables = domIterables;
1523
- var DOMTokenListPrototype = domTokenListPrototype;
1524
- var ArrayIteratorMethods = es_array_iterator;
1525
- var createNonEnumerableProperty = createNonEnumerableProperty$4;
1526
- var setToStringTag = setToStringTag$3;
1527
- var wellKnownSymbol = wellKnownSymbol$6;
1528
-
1529
- var ITERATOR = wellKnownSymbol('iterator');
1530
- var ArrayValues = ArrayIteratorMethods.values;
1531
-
1532
- var handlePrototype = function (CollectionPrototype, COLLECTION_NAME) {
1533
- if (CollectionPrototype) {
1534
- // some Chrome versions have non-configurable methods on DOMTokenList
1535
- if (CollectionPrototype[ITERATOR] !== ArrayValues) try {
1536
- createNonEnumerableProperty(CollectionPrototype, ITERATOR, ArrayValues);
1537
- } catch (error) {
1538
- CollectionPrototype[ITERATOR] = ArrayValues;
1539
- }
1540
- setToStringTag(CollectionPrototype, COLLECTION_NAME, true);
1541
- if (DOMIterables[COLLECTION_NAME]) for (var METHOD_NAME in ArrayIteratorMethods) {
1542
- // some Chrome versions have non-configurable methods on DOMTokenList
1543
- if (CollectionPrototype[METHOD_NAME] !== ArrayIteratorMethods[METHOD_NAME]) try {
1544
- createNonEnumerableProperty(CollectionPrototype, METHOD_NAME, ArrayIteratorMethods[METHOD_NAME]);
1545
- } catch (error) {
1546
- CollectionPrototype[METHOD_NAME] = ArrayIteratorMethods[METHOD_NAME];
1547
- }
1548
- }
1549
- }
1550
- };
1551
-
1552
- for (var COLLECTION_NAME in DOMIterables) {
1553
- handlePrototype(globalThis$1[COLLECTION_NAME] && globalThis$1[COLLECTION_NAME].prototype, COLLECTION_NAME);
1554
- }
1555
-
1556
- handlePrototype(DOMTokenListPrototype, 'DOMTokenList');
1557
-
1558
- var DESCRIPTORS = descriptors;
1559
- var uncurryThis = functionUncurryThis;
1560
- var call = functionCall;
1561
- var fails = fails$b;
1562
- var objectKeys = objectKeys$2;
1563
- var getOwnPropertySymbolsModule = objectGetOwnPropertySymbols;
1564
- var propertyIsEnumerableModule = objectPropertyIsEnumerable;
1565
- var toObject = toObject$3;
1566
- var IndexedObject = indexedObject;
1567
-
1568
- // eslint-disable-next-line es/no-object-assign -- safe
1569
- var $assign = Object.assign;
1570
- // eslint-disable-next-line es/no-object-defineproperty -- required for testing
1571
- var defineProperty = Object.defineProperty;
1572
- var concat = uncurryThis([].concat);
1573
-
1574
- // `Object.assign` method
1575
- // https://tc39.es/ecma262/#sec-object.assign
1576
- var objectAssign = !$assign || fails(function () {
1577
- // should have correct order of operations (Edge bug)
1578
- if (DESCRIPTORS && $assign({ b: 1 }, $assign(defineProperty({}, 'a', {
1579
- enumerable: true,
1580
- get: function () {
1581
- defineProperty(this, 'b', {
1582
- value: 3,
1583
- enumerable: false
1584
- });
1585
- }
1586
- }), { b: 2 })).b !== 1) return true;
1587
- // should work with symbols and should have deterministic property order (V8 bug)
1588
- var A = {};
1589
- var B = {};
1590
- // eslint-disable-next-line es/no-symbol -- safe
1591
- var symbol = Symbol('assign detection');
1592
- var alphabet = 'abcdefghijklmnopqrst';
1593
- A[symbol] = 7;
1594
- alphabet.split('').forEach(function (chr) { B[chr] = chr; });
1595
- return $assign({}, A)[symbol] !== 7 || objectKeys($assign({}, B)).join('') !== alphabet;
1596
- }) ? function assign(target, source) { // eslint-disable-line no-unused-vars -- required for `.length`
1597
- var T = toObject(target);
1598
- var argumentsLength = arguments.length;
1599
- var index = 1;
1600
- var getOwnPropertySymbols = getOwnPropertySymbolsModule.f;
1601
- var propertyIsEnumerable = propertyIsEnumerableModule.f;
1602
- while (argumentsLength > index) {
1603
- var S = IndexedObject(arguments[index++]);
1604
- var keys = getOwnPropertySymbols ? concat(objectKeys(S), getOwnPropertySymbols(S)) : objectKeys(S);
1605
- var length = keys.length;
1606
- var j = 0;
1607
- var key;
1608
- while (length > j) {
1609
- key = keys[j++];
1610
- if (!DESCRIPTORS || call(propertyIsEnumerable, S, key)) T[key] = S[key];
1611
- }
1612
- } return T;
1613
- } : $assign;
1614
-
1615
- var $ = _export;
1616
- var assign = objectAssign;
1617
-
1618
- // `Object.assign` method
1619
- // https://tc39.es/ecma262/#sec-object.assign
1620
- // eslint-disable-next-line es/no-object-assign -- required for testing
1621
- $({ target: 'Object', stat: true, arity: 2, forced: Object.assign !== assign }, {
1622
- assign: assign
1623
- });
1624
-
1625
- const BuildSchemaAsFields = ({
1626
- components,
1627
- mappers,
1628
- formIndex,
1629
- mountedForm
1630
- }) => {
1631
- return components && components.map(component => {
1632
- const mapper = mappers === null || mappers === void 0 ? void 0 : mappers.find(el => el.componentName === component.component);
1633
- return mapper ? jsx(AsFormFieldBuilder, Object.assign({
1634
- formIndex: formIndex,
1635
- mapper: mapper,
1636
- formMounted: mountedForm
1637
- }, component, {
1638
- children: component.children && component.children.length > 0 && jsx(BuildSchemaAsFields, {
1639
- formIndex: formIndex,
1640
- mappers: mappers,
1641
- components: component.children,
1642
- mountedForm: mountedForm
1643
- })
1644
- }), component.name) : jsx("div", {
1645
- children: `component mapper not found for ${component.component} from field name ${component.name} on form ${formIndex}`
1646
- }, component.name);
1647
- });
6
+ /******************************************************************************
7
+ Copyright (c) Microsoft Corporation.
8
+
9
+ Permission to use, copy, modify, and/or distribute this software for any
10
+ purpose with or without fee is hereby granted.
11
+
12
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
13
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
14
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
15
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
16
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
17
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
18
+ PERFORMANCE OF THIS SOFTWARE.
19
+ ***************************************************************************** */
20
+ /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
21
+
22
+
23
+ function __rest(s, e) {
24
+ var t = {};
25
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
26
+ t[p] = s[p];
27
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
28
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
29
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
30
+ t[p[i]] = s[p[i]];
31
+ }
32
+ return t;
33
+ }
34
+
35
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
36
+ var e = new Error(message);
37
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
1648
38
  };
1649
39
 
1650
40
  const FormGroupContext = /*#__PURE__*/createContext({});
@@ -1660,7 +50,8 @@ const IsolatedContext = ({
1660
50
  config
1661
51
  }) => {
1662
52
  const formGroupInstance = useRef(new FormGroup({
1663
- config
53
+ config,
54
+ mappers
1664
55
  }));
1665
56
  const formGroupContextMountRef = useRef(false);
1666
57
  const addFormWithIndex = index => {
@@ -1770,36 +161,292 @@ const useFormGroupContext = props => {
1770
161
  return context;
1771
162
  };
1772
163
 
1773
- /******************************************************************************
1774
- Copyright (c) Microsoft Corporation.
1775
-
1776
- Permission to use, copy, modify, and/or distribute this software for any
1777
- purpose with or without fee is hereby granted.
1778
-
1779
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
1780
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
1781
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
1782
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
1783
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
1784
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
1785
- PERFORMANCE OF THIS SOFTWARE.
1786
- ***************************************************************************** */
1787
-
1788
- function __rest(s, e) {
1789
- var t = {};
1790
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
1791
- t[p] = s[p];
1792
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
1793
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
1794
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
1795
- t[p[i]] = s[p[i]];
1796
- }
1797
- return t;
1798
- }
1799
-
1800
- typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
1801
- var e = new Error(message);
1802
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
164
+ /**
165
+ * Renders the React element defined on the mappers configuration
166
+ *
167
+ * @param param component props, field instance and children to render
168
+ * @returns
169
+ */
170
+ const FieldWrapperComponentRender = ({
171
+ props,
172
+ fieldInstance,
173
+ children,
174
+ mapper
175
+ }) => {
176
+ var _a, _b, _c;
177
+ const Component = (mapper === null || mapper === void 0 ? void 0 : mapper.component) || ((_a = fieldInstance === null || fieldInstance === void 0 ? void 0 : fieldInstance.mapper) === null || _a === void 0 ? void 0 : _a.component);
178
+ const Asynccomponent = (mapper === null || mapper === void 0 ? void 0 : mapper.asynccomponent) || ((_b = fieldInstance === null || fieldInstance === void 0 ? void 0 : fieldInstance.mapper) === null || _b === void 0 ? void 0 : _b.asynccomponent);
179
+ if (Component) return jsx(Component, Object.assign({}, props, {
180
+ children: children && children
181
+ }));
182
+ if (Asynccomponent) return jsx(Suspense, {
183
+ children: jsx(Asynccomponent, Object.assign({}, props, {
184
+ children: children && children
185
+ }))
186
+ });
187
+ return jsx("div", {
188
+ children: `failed to render field ${fieldInstance === null || fieldInstance === void 0 ? void 0 : fieldInstance.name} with componentName:${(_c = fieldInstance === null || fieldInstance === void 0 ? void 0 : fieldInstance.mapper) === null || _c === void 0 ? void 0 : _c.componentName}, please check mappers`
189
+ });
190
+ };
191
+ /**
192
+ * Base field Wrapper to render the component with the necessary configurations from the schema
193
+ * and mapper configuration
194
+ *
195
+ * @param {TFieldWrapperProps} param FieldWrapper params
196
+ * @returns {ReactElement}
197
+ */
198
+ const FieldWrapper = ({
199
+ name,
200
+ formIndex,
201
+ children,
202
+ props,
203
+ context,
204
+ mounted,
205
+ mapper,
206
+ visibility,
207
+ component
208
+ }) => {
209
+ var _a, _b, _c;
210
+ const localContext = useFormGroupContext({});
211
+ const fieldMapper = mapper || ((_a = localContext.mappers) === null || _a === void 0 ? void 0 : _a.find(mapper => mapper.componentName === component));
212
+ /**
213
+ * picks the right context prioritizing the context passed as prop
214
+ */
215
+ const {
216
+ formGroupInstance,
217
+ debugMode
218
+ } = useMemo(() => context ? context : localContext, [context, localContext]);
219
+ /**
220
+ * retrieves the field instance when it's mounted
221
+ */
222
+ const fieldInstance = useMemo(() => {
223
+ var _a;
224
+ return (_a = formGroupInstance.getForm({
225
+ key: formIndex
226
+ })) === null || _a === void 0 ? void 0 : _a.getField({
227
+ key: name
228
+ });
229
+ }, [mounted]);
230
+ /**
231
+ * props with templates stripped until the field isn't ready on the instance
232
+ */
233
+ const filteredProps = useMemo(() => {
234
+ return FormField.filterProps(props);
235
+ }, []);
236
+ /**
237
+ * sends props changed on the adapter for comparison to effectively change props for the instance
238
+ */
239
+ useEffect(() => {
240
+ if (fieldInstance && props) fieldInstance.adapterProps = props;
241
+ }, [props]);
242
+ const [valueState, setValueState] = useState((fieldInstance === null || fieldInstance === void 0 ? void 0 : fieldInstance.stateValue) || {
243
+ [((_b = fieldMapper === null || fieldMapper === void 0 ? void 0 : fieldMapper.events) === null || _b === void 0 ? void 0 : _b.setValue) || 'value']: ''
244
+ });
245
+ const [state, setState] = useState({
246
+ visibility: typeof visibility === 'boolean' ? visibility : true,
247
+ props: filteredProps
248
+ });
249
+ /**
250
+ * handles the mounting and unmounting logic onto the field instance
251
+ */
252
+ useEffect(() => {
253
+ if (!fieldInstance || (fieldInstance === null || fieldInstance === void 0 ? void 0 : fieldInstance.mounted)) return;
254
+ fieldInstance.mountField({
255
+ valueSubscription: value => {
256
+ setValueState(value);
257
+ },
258
+ propsSubscription: ({
259
+ visibility,
260
+ props,
261
+ errors
262
+ }) => {
263
+ setState(prev => Object.assign(Object.assign({}, prev), {
264
+ visibility,
265
+ props,
266
+ errors
267
+ }));
268
+ }
269
+ });
270
+ }, [fieldInstance]);
271
+ /**
272
+ * recycle effect to remove the field Subscriptions due to memory leaks
273
+ */
274
+ useEffect(() => {
275
+ return () => {
276
+ (fieldInstance === null || fieldInstance === void 0 ? void 0 : fieldInstance.mounted) && (fieldInstance === null || fieldInstance === void 0 ? void 0 : fieldInstance.destroyField());
277
+ };
278
+ }, []);
279
+ /**
280
+ * handles the value change onto the field instance
281
+ */
282
+ const handleChange = useCallback(event => {
283
+ if (!mounted) return;
284
+ fieldInstance === null || fieldInstance === void 0 ? void 0 : fieldInstance.emitValue({
285
+ value: event,
286
+ event: 'ON_FIELD_CHANGE'
287
+ });
288
+ }, [mounted]);
289
+ /**
290
+ * handles the event emission onto the field instance
291
+ */
292
+ const handleEvent = useCallback(event => {
293
+ if (!mounted) return;
294
+ fieldInstance === null || fieldInstance === void 0 ? void 0 : fieldInstance.emitEvents({
295
+ event
296
+ });
297
+ }, [mounted]);
298
+ /**
299
+ * handles the mappers configuration to bind the event submission callback
300
+ * to the corresponding prop defined on the mappers
301
+ */
302
+ const mapProps = useMemo(() => {
303
+ const events = fieldMapper === null || fieldMapper === void 0 ? void 0 : fieldMapper.events;
304
+ const props = {};
305
+ if (events === null || events === void 0 ? void 0 : events.onBlur) props[events.onBlur] = () => handleEvent('ON_FIELD_BLUR');
306
+ if (events === null || events === void 0 ? void 0 : events.getValue) props[events.getValue] = handleChange;
307
+ if (events === null || events === void 0 ? void 0 : events.onFocus) props[events.onFocus] = () => handleEvent('ON_FIELD_FOCUS');
308
+ if (events === null || events === void 0 ? void 0 : events.onClick) props[events.onClick] = () => handleEvent('ON_FIELD_CLICK');
309
+ if (events === null || events === void 0 ? void 0 : events.onSubmit) props[events.onSubmit] = () => handleEvent('ON_FORM_SUBMIT');
310
+ if (events === null || events === void 0 ? void 0 : events.onKeyUp) props[events.onKeyUp] = () => handleEvent('ON_FIELD_KEYUP');
311
+ if (events === null || events === void 0 ? void 0 : events.onKeyDown) props[events.onKeyDown] = () => handleEvent('ON_FIELD_KEYDOWN');
312
+ return props;
313
+ }, [mounted]);
314
+ return state.visibility ? jsxs(Fragment, {
315
+ children: [debugMode && jsxs("div", {
316
+ style: {
317
+ width: '100%',
318
+ display: 'flex',
319
+ flexDirection: 'column'
320
+ },
321
+ children: [jsxs("b", {
322
+ style: {
323
+ padding: '0px',
324
+ margin: '0px'
325
+ },
326
+ children: ["name:", name]
327
+ }), jsx("br", {}), jsx("hr", {})]
328
+ }), jsx(FieldWrapperComponentRender, {
329
+ props: Object.assign(Object.assign(Object.assign(Object.assign({}, mapProps), state.props), state.errors), valueState),
330
+ fieldInstance: fieldInstance,
331
+ mapper: fieldMapper,
332
+ children: children ? children : ((_c = state === null || state === void 0 ? void 0 : state.props) === null || _c === void 0 ? void 0 : _c.children) ? state === null || state === void 0 ? void 0 : state.props.children : null
333
+ })]
334
+ }) : jsx(Fragment, {});
335
+ };
336
+
337
+ /**
338
+ * Component Wrapper to render form fields without the Form component, gets additional formId and mapper since
339
+ * it won't rely on them and needs to be manually declared
340
+ *
341
+ * @param {TAsFormFieldBuilderProps} props JSON schema props along with FieldWrapper props and mapper props
342
+ * @returns {ReactElement}
343
+ */
344
+ const AsFormFieldBuilder = props => {
345
+ const context = useFormGroupContext({});
346
+ /**
347
+ * state to track the field instance mounting (client-side reactivity activation)
348
+ */
349
+ const [mounted, setMounted] = useState(false);
350
+ const mountedRef = useRef(false);
351
+ /**
352
+ * initializer to create or add a form instance to the formGroup by it's formId
353
+ * and add the field to the form instance
354
+ */
355
+ useEffect(() => {
356
+ var _a, _b;
357
+ if (mountedRef.current) return;
358
+ if (typeof props.formMounted === 'undefined' && !((_a = context.formGroupInstance) === null || _a === void 0 ? void 0 : _a.forms.has(props.formIndex))) {
359
+ context.addFormWithIndex(props.formIndex);
360
+ }
361
+ if (props.formMounted || typeof props.formMounted === 'undefined') {
362
+ const formInstance = context.formGroupInstance.forms.get(props.formIndex);
363
+ if (formInstance && !formInstance.fields.has(props.name)) {
364
+ const fieldSchema = Object.assign(Object.assign({}, props), {
365
+ component: ((_b = props.mapper) === null || _b === void 0 ? void 0 : _b.componentName) || props.component,
366
+ children: undefined
367
+ });
368
+ formInstance.addField({
369
+ fieldSchema,
370
+ mapperElement: props.mapper
371
+ });
372
+ }
373
+ setMounted(true);
374
+ mountedRef.current = true;
375
+ }
376
+ }, [props.formMounted]);
377
+ /**
378
+ * recycle effect to remove the field from the form instance when the field leaves the vDOM
379
+ * and the subscriptions
380
+ */
381
+ useEffect(() => {
382
+ return () => {
383
+ var _a, _b;
384
+ if ((_b = (_a = context.getForm({
385
+ key: props.formIndex
386
+ })) === null || _a === void 0 ? void 0 : _a.getField({
387
+ key: props.name
388
+ })) === null || _b === void 0 ? void 0 : _b.mounted) context.formGroupInstance.removeField({
389
+ formIndex: props.formIndex,
390
+ fieldIndex: props.name
391
+ });
392
+ };
393
+ }, []);
394
+ /**
395
+ * allows to control field selected value on each event
396
+ */
397
+ useEffect(() => {
398
+ var _a;
399
+ if (!props.onSelected) return;
400
+ const callback = payload => {
401
+ if (props.onSelected) {
402
+ props.onSelected(payload);
403
+ }
404
+ };
405
+ const sub = (_a = context.formGroupInstance.forms.get(props.formIndex)) === null || _a === void 0 ? void 0 : _a.subscribeFieldEvent({
406
+ callback
407
+ });
408
+ return () => sub === null || sub === void 0 ? void 0 : sub.unsubscribe();
409
+ }, [props.onSelected]);
410
+ return jsx(FieldWrapper, {
411
+ formIndex: props.formIndex,
412
+ name: props.name,
413
+ props: props.props,
414
+ context: !context.active ? context : null,
415
+ mounted: mounted,
416
+ mapper: props.mapper,
417
+ visibility: props.visibility,
418
+ component: props.component,
419
+ children: props.children && props.children
420
+ });
421
+ };
422
+
423
+ const BuildSchemaAsFields = ({
424
+ components,
425
+ mappers,
426
+ formIndex,
427
+ mountedForm
428
+ }) => {
429
+ return components && components.map(_a => {
430
+ var {
431
+ component
432
+ } = _a,
433
+ componentEl = __rest(_a, ["component"]);
434
+ const mapper = mappers === null || mappers === void 0 ? void 0 : mappers.find(el => el.componentName === component);
435
+ return mapper ? jsx(AsFormFieldBuilder, Object.assign({
436
+ formIndex: formIndex,
437
+ mapper: mapper,
438
+ formMounted: mountedForm
439
+ }, componentEl, {
440
+ children: componentEl.children && componentEl.children.length > 0 && jsx(BuildSchemaAsFields, {
441
+ formIndex: formIndex,
442
+ mappers: mappers,
443
+ components: componentEl.children,
444
+ mountedForm: mountedForm
445
+ })
446
+ }), componentEl.name) : jsx("div", {
447
+ children: `component mapper not found for ${component} from field name ${componentEl.name} on form ${formIndex}`
448
+ }, componentEl.name);
449
+ });
1803
450
  };
1804
451
 
1805
452
  /**
@@ -1815,7 +462,17 @@ const eventsMapping = {
1815
462
  ON_API_FIELD_REQUEST: 'onApiRequest',
1816
463
  ON_API_FIELD_RESPONSE: 'onApiResponse',
1817
464
  ON_FIELD_CLICK: 'onClick',
1818
- ON_FIELD_CLEARED: 'onFieldCleared'
465
+ ON_FIELD_CLEARED: 'onCleared',
466
+ ON_FIELD_UNMOUNT: 'onUnmount'
467
+ };
468
+ const uniqueIdGen = () => {
469
+ const timestamp = +new Date();
470
+ const rand = Math.random() * 1e5;
471
+ const finalNumb = timestamp * rand;
472
+ const string = (Math.random() + 1).toString(36).substring(7);
473
+ const mixedID = finalNumb + string + '-';
474
+ const shuffle = str => [...str].sort(() => Math.random() - 0.5).join('');
475
+ return shuffle(mixedID);
1819
476
  };
1820
477
 
1821
478
  /**
@@ -1824,15 +481,56 @@ const eventsMapping = {
1824
481
  function useForm(_a, deps) {
1825
482
  var {
1826
483
  id,
484
+ index,
1827
485
  onData,
1828
486
  onSubmit,
1829
487
  onFormMount,
1830
- onValid
488
+ onValid,
489
+ iVars,
490
+ initialValues,
491
+ stopEventsOnSubmit
1831
492
  } = _a,
1832
- rest = __rest(_a, ["id", "onData", "onSubmit", "onFormMount", "onValid"]);
493
+ rest = __rest(_a, ["id", "index", "onData", "onSubmit", "onFormMount", "onValid", "iVars", "initialValues", "stopEventsOnSubmit"]);
1833
494
  const {
1834
495
  formGroupInstance
1835
496
  } = useFormGroupContext({});
497
+ const useFormIndex = index || id;
498
+ if (!useFormIndex) {
499
+ throw new Error('useForm hook must have an id or an index');
500
+ }
501
+ useEffect(() => {
502
+ if (!formGroupInstance.forms.has(useFormIndex)) {
503
+ console.log('failed to set stopEventsOnSubmit due to no form instance');
504
+ return;
505
+ }
506
+ if (typeof stopEventsOnSubmit === 'boolean') {
507
+ formGroupInstance.getForm({
508
+ key: useFormIndex
509
+ }).stopEventsOnSubmit = stopEventsOnSubmit;
510
+ }
511
+ }, []);
512
+ /**
513
+ * iVars change tracker to update iVars onto form instance
514
+ */
515
+ useEffect(() => {
516
+ if (!formGroupInstance.forms.has(useFormIndex)) {
517
+ console.log('failed to add iVars due to no form instance');
518
+ return;
519
+ }
520
+ if (iVars) formGroupInstance.forms.get(useFormIndex).iVars = iVars;
521
+ // if (iVars) formInstance.current.iVars = iVars;
522
+ }, [iVars]);
523
+ /**
524
+ * initialValues setter for async initialValues
525
+ */
526
+ useEffect(() => {
527
+ if (!formGroupInstance.forms.has(useFormIndex)) {
528
+ console.log('failed to add initialValues due to no form instance');
529
+ return;
530
+ }
531
+ if (initialValues) formGroupInstance.forms.get(useFormIndex).initialValues = initialValues;
532
+ // if (initialValues) formInstance.current.initialValues = initialValues;
533
+ }, [initialValues]);
1836
534
  /**
1837
535
  * reference to store all updated callback functions rerendered by props change
1838
536
  */
@@ -1854,6 +552,14 @@ function useForm(_a, deps) {
1854
552
  onValid
1855
553
  };
1856
554
  }, [onData, onSubmit, onFormMount, onValid]);
555
+ /**
556
+ * Guard to prevent onFormMount from firing more than once per form lifecycle.
557
+ * This prevents infinite loops when the parent component (e.g. Builder.io)
558
+ * rerenders with new callback references causing subscriptions to re-fire.
559
+ * Field-level onMount (ON_FIELD_MOUNT) is NOT guarded — it must fire
560
+ * every time a field becomes visible via visibility conditions.
561
+ */
562
+ const formMountHasRunRef = useRef(false);
1857
563
  /**
1858
564
  * handle function call after the debounce occurs on the form instance field event
1859
565
  * subject in order to call the most updated function with the updated function
@@ -1869,18 +575,20 @@ function useForm(_a, deps) {
1869
575
  }
1870
576
  };
1871
577
  const sub = (_a = formGroupInstance.getForm({
1872
- key: id
578
+ key: useFormIndex
1873
579
  })) === null || _a === void 0 ? void 0 : _a.subscribeFieldEvent({
1874
580
  callback
1875
581
  });
1876
582
  const mountCallback = payload => {
1877
583
  var _a, _b;
1878
- if (formValuesCallbackRefs.current.onMount) {
584
+ if (formMountHasRunRef.current) return;
585
+ formMountHasRunRef.current = true;
586
+ if (formValuesCallbackRefs.current.onFormMount) {
1879
587
  (_b = (_a = formValuesCallbackRefs.current).onFormMount) === null || _b === void 0 ? void 0 : _b.call(_a, payload);
1880
588
  }
1881
589
  };
1882
590
  const mountSub = (_b = formGroupInstance.getForm({
1883
- key: id
591
+ key: useFormIndex
1884
592
  })) === null || _b === void 0 ? void 0 : _b.subscribeOnMount(mountCallback);
1885
593
  const dataCallback = payload => {
1886
594
  var _a, _b;
@@ -1889,7 +597,7 @@ function useForm(_a, deps) {
1889
597
  }
1890
598
  };
1891
599
  const dataSub = (_c = formGroupInstance.getForm({
1892
- key: id
600
+ key: useFormIndex
1893
601
  })) === null || _c === void 0 ? void 0 : _c.subscribeData(dataCallback);
1894
602
  const validationCallback = payload => {
1895
603
  if (formValuesCallbackRefs.current.onValid) {
@@ -1897,7 +605,7 @@ function useForm(_a, deps) {
1897
605
  }
1898
606
  };
1899
607
  const validSub = (_d = formGroupInstance.getForm({
1900
- key: id
608
+ key: useFormIndex
1901
609
  })) === null || _d === void 0 ? void 0 : _d.subscribeFormValidation(validationCallback);
1902
610
  const submitCallback = payload => {
1903
611
  var _a, _b;
@@ -1906,7 +614,7 @@ function useForm(_a, deps) {
1906
614
  }
1907
615
  };
1908
616
  const submitSub = (_e = formGroupInstance.getForm({
1909
- key: id
617
+ key: useFormIndex
1910
618
  })) === null || _e === void 0 ? void 0 : _e.subscribeOnSubmit(submitCallback);
1911
619
  return () => {
1912
620
  sub === null || sub === void 0 ? void 0 : sub.unsubscribe();
@@ -1932,6 +640,7 @@ function Form({
1932
640
  action,
1933
641
  method,
1934
642
  config,
643
+ prefetchedData,
1935
644
  onSubmit,
1936
645
  onFormMount,
1937
646
  onData,
@@ -1944,6 +653,7 @@ function Form({
1944
653
  onKeyUp,
1945
654
  onMount,
1946
655
  onValid,
656
+ stopEventsOnSubmit,
1947
657
  children
1948
658
  }) {
1949
659
  const {
@@ -1956,397 +666,132 @@ function Form({
1956
666
  const [mounted, setMounted] = useState(false);
1957
667
  const mountedRef = useRef(false);
1958
668
  /**
1959
- * effect to create the form instance and notify the recursive generated fields of it's mounted status
1960
- */
1961
- useEffect(() => {
1962
- if (mountedRef.current) return;
1963
- formGroupInstance.addForm({
1964
- key: schemaIndex,
1965
- params: {
1966
- schema,
1967
- initialValues: initialValues || (schema === null || schema === void 0 ? void 0 : schema.initialValues),
1968
- iVars: iVars || (schema === null || schema === void 0 ? void 0 : schema.iVars),
1969
- action: action || (schema === null || schema === void 0 ? void 0 : schema.action),
1970
- method: method || (schema === null || schema === void 0 ? void 0 : schema.method),
1971
- index: schemaIndex,
1972
- mappers,
1973
- config: config || formGroupInstance.config
1974
- }
1975
- });
1976
- setMounted(true);
1977
- mountedRef.current = true;
1978
- // }
1979
- }, []);
1980
- /**
1981
- * iVars change tracker to update iVars onto form instance
1982
- */
1983
- useEffect(() => {
1984
- if (!formGroupInstance.forms.has(schemaIndex)) {
1985
- console.log('failed to add iVars due to no form instance');
1986
- return;
1987
- }
1988
- if (iVars && mounted) formGroupInstance.forms.get(schemaIndex).iVars = iVars;
1989
- // if (iVars) formInstance.current.iVars = iVars;
1990
- }, [iVars, mounted]);
1991
- /**
1992
- * initialValues setter for async initialValues
1993
- */
1994
- useEffect(() => {
1995
- if (!formGroupInstance.forms.has(schemaIndex)) {
1996
- console.log('failed to add initialValues due to no form instance');
1997
- return;
1998
- }
1999
- if (initialValues && mounted) formGroupInstance.forms.get(schemaIndex).initialValues = initialValues;
2000
- // if (initialValues) formInstance.current.initialValues = initialValues;
2001
- }, [initialValues, mounted]);
2002
- /**
2003
- * hook usage to keep event bindings updated on callback functions passed as props
2004
- */
2005
- useForm({
2006
- id: schemaIndex,
2007
- onApiResponse,
2008
- onBlur,
2009
- onChange,
2010
- onClick,
2011
- onFocus,
2012
- onKeyDown,
2013
- onKeyUp,
2014
- onMount,
2015
- onSubmit,
2016
- onFormMount,
2017
- onData,
2018
- onValid
2019
- });
2020
- /*
2021
- @TODO move this logic inside form-core, add action and method onto form element,
2022
- might need a ref of the form to collect all the form parameters when there is a
2023
- normal form submition with redirect
2024
- */
2025
- const handleSubmit = event => {
2026
- const formElement = getForm({
2027
- key: schemaIndex
2028
- });
2029
- if (!(formElement === null || formElement === void 0 ? void 0 : formElement.action) && event) {
2030
- event.preventDefault();
2031
- }
2032
- formElement === null || formElement === void 0 ? void 0 : formElement.submit();
2033
- };
2034
- return jsxs(Fragment, {
2035
- children: [debugMode && jsxs(Fragment, {
2036
- children: [jsx("b", {
2037
- style: {
2038
- padding: '0px',
2039
- margin: '0px'
2040
- },
2041
- children: `form index: ${schemaIndex}`
2042
- }), jsx("button", {
2043
- onClick: () => console.log(getForm({
2044
- key: schemaIndex
2045
- })),
2046
- children: "print form instance"
2047
- }), jsx("button", {
2048
- onClick: () => {
2049
- var _a;
2050
- return console.log((_a = getForm({
2051
- key: schemaIndex
2052
- })) === null || _a === void 0 ? void 0 : _a.getFormValues());
2053
- },
2054
- children: "print form values"
2055
- }), jsx("button", {
2056
- onClick: () => {
2057
- var _a;
2058
- return (_a = getForm({
2059
- key: schemaIndex
2060
- })) === null || _a === void 0 ? void 0 : _a.submit();
2061
- },
2062
- children: "try submit"
2063
- }), jsx("br", {}), jsx("hr", {})]
2064
- }), jsx("form", {
2065
- onSubmit: handleSubmit,
2066
- children: jsx(BuildSchemaAsFields, {
2067
- formIndex: schemaIndex,
2068
- mappers: mappers,
2069
- components: schema === null || schema === void 0 ? void 0 : schema.components,
2070
- mountedForm: mounted
2071
- })
2072
- })]
2073
- });
2074
- }
2075
-
2076
- /**
2077
- * Component wrapper to aid building schemas with react without writting a JSON schema
2078
- * along with BuildAsFormFieldTree inside a Form component, FieldWrapper gets this props
2079
- * to build the component as it does with a JSON schema, this component only works inside
2080
- * the Form component
2081
- *
2082
- * @param {TAsFormFieldProps} props JSON schema props
2083
- * @returns {ReactNode}
2084
- */
2085
- const AsFormField = props => {
2086
- return props.children;
2087
- };
2088
-
2089
- /**
2090
- * Renders the React element defined on the mappers configuration
2091
- *
2092
- * @param param component props, field instance and children to render
2093
- * @returns
2094
- */
2095
- const FieldWrapperComponentRender = ({
2096
- props,
2097
- fieldInstance,
2098
- children,
2099
- mapper
2100
- }) => {
2101
- var _a, _b, _c;
2102
- const Component = (mapper === null || mapper === void 0 ? void 0 : mapper.component) || ((_a = fieldInstance === null || fieldInstance === void 0 ? void 0 : fieldInstance.mapper) === null || _a === void 0 ? void 0 : _a.component);
2103
- const Asynccomponent = (mapper === null || mapper === void 0 ? void 0 : mapper.asynccomponent) || ((_b = fieldInstance === null || fieldInstance === void 0 ? void 0 : fieldInstance.mapper) === null || _b === void 0 ? void 0 : _b.asynccomponent);
2104
- if (Component) return jsx(Component, Object.assign({}, props, {
2105
- children: children && children
2106
- }));
2107
- if (Asynccomponent) return jsx(Suspense, {
2108
- children: jsx(Asynccomponent, Object.assign({}, props, {
2109
- children: children && children
2110
- }))
2111
- });
2112
- return jsx("div", {
2113
- children: `failed to render field ${fieldInstance === null || fieldInstance === void 0 ? void 0 : fieldInstance.name} with componentName:${(_c = fieldInstance === null || fieldInstance === void 0 ? void 0 : fieldInstance.mapper) === null || _c === void 0 ? void 0 : _c.componentName}, please check mappers`
2114
- });
2115
- };
2116
- /**
2117
- * Base field Wrapper to render the component with the necessary configurations from the schema
2118
- * and mapper configuration
2119
- *
2120
- * @param {TFieldWrapperProps} param FieldWrapper params
2121
- * @returns {ReactElement}
2122
- */
2123
- const FieldWrapper = ({
2124
- name,
2125
- formIndex,
2126
- children,
2127
- props,
2128
- context,
2129
- mounted,
2130
- mapper,
2131
- visibility
2132
- }) => {
2133
- var _a, _b, _c;
2134
- const localContext = useFormGroupContext({});
2135
- /**
2136
- * picks the right context prioritizing the context passed as prop
2137
- */
2138
- const {
2139
- formGroupInstance,
2140
- debugMode
2141
- } = useMemo(() => context ? context : localContext, [context, localContext]);
2142
- const fieldInstance = useMemo(() => {
2143
- var _a;
2144
- return (_a = formGroupInstance.getForm({
2145
- key: formIndex
2146
- })) === null || _a === void 0 ? void 0 : _a.getField({
2147
- key: name
2148
- });
2149
- }, [mounted]);
2150
- /**
2151
- * props with templates stripped until the field ins't ready on the instance
2152
- */
2153
- const filteredProps = useMemo(() => {
2154
- let returnProps = {};
2155
- if (props) {
2156
- returnProps = FormField.filterProps(props);
2157
- }
2158
- if (fieldInstance) fieldInstance.props = returnProps;
2159
- return returnProps;
2160
- }, [props]);
2161
- const [valueState, setValueState] = useState((fieldInstance === null || fieldInstance === void 0 ? void 0 : fieldInstance.stateValue) || {
2162
- [((_a = mapper === null || mapper === void 0 ? void 0 : mapper.events) === null || _a === void 0 ? void 0 : _a.setValue) || 'value']: ''
2163
- });
2164
- const [state, setState] = useState({
2165
- visibility: typeof visibility === 'boolean' ? visibility : true,
2166
- props: filteredProps
2167
- });
2168
- /**
2169
- * handles the mounting and unmounting logic onto the field instance
669
+ * Synchronously ensures the form instance exists during render.
670
+ * This allows the component tree to render meaningful HTML during SSR.
671
+ * Subscriptions and reactivity are still deferred to useEffect (client-only).
672
+ *
673
+ * Note: iVars and initialValues are also set in useForm hook (via useEffect),
674
+ * but they need to be here as well so the FormCore constructor has them available
675
+ * during the synchronous render phase for SSR template resolution.
2170
676
  */
2171
- useEffect(() => {
2172
- if (!fieldInstance || (fieldInstance === null || fieldInstance === void 0 ? void 0 : fieldInstance.mounted)) return;
2173
- fieldInstance.mountField({
2174
- valueSubscription: value => {
2175
- setValueState(value);
2176
- },
2177
- propsSubscription: ({
2178
- visibility,
2179
- props,
2180
- errors
2181
- }) => {
2182
- setState(prev => Object.assign(Object.assign({}, prev), {
2183
- visibility,
2184
- props,
2185
- errors
2186
- }));
677
+ useMemo(() => {
678
+ if (formGroupInstance.getForm({
679
+ key: schemaIndex
680
+ })) return;
681
+ const schemaWithPrefetch = prefetchedData && schema ? Object.assign(Object.assign({}, schema), {
682
+ prefetchedData
683
+ }) : schema;
684
+ formGroupInstance.addForm({
685
+ key: schemaIndex,
686
+ params: {
687
+ schema: schemaWithPrefetch,
688
+ action: action || (schema === null || schema === void 0 ? void 0 : schema.action),
689
+ method: method || (schema === null || schema === void 0 ? void 0 : schema.method),
690
+ index: schemaIndex,
691
+ mappers,
692
+ iVars: iVars || (schema === null || schema === void 0 ? void 0 : schema.iVars),
693
+ initialValues: initialValues || (schema === null || schema === void 0 ? void 0 : schema.initialValues),
694
+ config: config || formGroupInstance.config
2187
695
  }
2188
696
  });
2189
- }, [fieldInstance]);
697
+ }, []);
2190
698
  /**
2191
- * recycle effect to remove the field Subscriptions due to memory leaks
699
+ * effect to notify the recursive generated fields of the form's mounted status
700
+ * and activate client-side reactivity (subscriptions, events, etc.)
2192
701
  */
2193
702
  useEffect(() => {
2194
- return () => {
2195
- (fieldInstance === null || fieldInstance === void 0 ? void 0 : fieldInstance.mounted) && (fieldInstance === null || fieldInstance === void 0 ? void 0 : fieldInstance.destroyField());
2196
- };
703
+ if (mountedRef.current) return;
704
+ setMounted(true);
705
+ mountedRef.current = true;
2197
706
  }, []);
2198
707
  /**
2199
- * handles the value change onto the field instance
2200
- */
2201
- const handleChange = useCallback(event => {
2202
- if (!mounted) return;
2203
- fieldInstance === null || fieldInstance === void 0 ? void 0 : fieldInstance.emitValue({
2204
- value: event,
2205
- event: 'ON_FIELD_CHANGE'
2206
- });
2207
- }, [mounted]);
2208
- /**
2209
- * handles the event emission onto the field instance
708
+ * hook usage to keep event bindings updated on callback functions passed as props
2210
709
  */
2211
- const handleEvent = useCallback(event => {
2212
- if (!mounted) return;
2213
- fieldInstance === null || fieldInstance === void 0 ? void 0 : fieldInstance.emitEvents({
2214
- event
710
+ useForm({
711
+ index: schemaIndex,
712
+ initialValues,
713
+ iVars,
714
+ stopEventsOnSubmit,
715
+ onApiResponse,
716
+ onBlur,
717
+ onChange,
718
+ onClick,
719
+ onFocus,
720
+ onKeyDown,
721
+ onKeyUp,
722
+ onMount,
723
+ onSubmit,
724
+ onFormMount,
725
+ onData,
726
+ onValid
727
+ });
728
+ /*
729
+ @TODO move this logic inside form-core, add action and method onto form element,
730
+ might need a ref of the form to collect all the form parameters when there is a
731
+ normal form submition with redirect
732
+ */
733
+ const handleSubmit = event => {
734
+ const formElement = getForm({
735
+ key: schemaIndex
2215
736
  });
2216
- }, [mounted]);
2217
- /**
2218
- * handles the mappers configuration to bind the event submission callback
2219
- * to the corresponding prop defined on the mappers
2220
- */
2221
- const mapProps = useMemo(() => {
2222
- const events = mapper === null || mapper === void 0 ? void 0 : mapper.events;
2223
- const props = {};
2224
- if (events === null || events === void 0 ? void 0 : events.onBlur) props[events.onBlur] = () => handleEvent('ON_FIELD_BLUR');
2225
- if (events === null || events === void 0 ? void 0 : events.getValue) props[events.getValue] = handleChange;
2226
- if (events === null || events === void 0 ? void 0 : events.onFocus) props[events.onFocus] = () => handleEvent('ON_FIELD_FOCUS');
2227
- if (events === null || events === void 0 ? void 0 : events.onClick) props[events.onClick] = () => handleEvent('ON_FIELD_CLICK');
2228
- if (events === null || events === void 0 ? void 0 : events.onSubmit) props[events.onSubmit] = () => handleEvent('ON_FORM_SUBMIT');
2229
- if (events === null || events === void 0 ? void 0 : events.onKeyUp) props[events.onKeyUp] = () => handleEvent('ON_FIELD_KEYUP');
2230
- if (events === null || events === void 0 ? void 0 : events.onKeyDown) props[events.onKeyDown] = () => handleEvent('ON_FIELD_KEYDOWN');
2231
- return props;
2232
- }, [mounted]);
2233
- return state.visibility ? jsxs(Fragment, {
2234
- children: [debugMode && jsxs("div", {
2235
- style: {
2236
- width: '100%',
2237
- display: 'flex',
2238
- flexDirection: 'column'
2239
- },
2240
- children: [jsxs("b", {
737
+ if (!(formElement === null || formElement === void 0 ? void 0 : formElement.action) && event) {
738
+ event.preventDefault();
739
+ }
740
+ formElement === null || formElement === void 0 ? void 0 : formElement.submit();
741
+ };
742
+ return jsxs(Fragment, {
743
+ children: [debugMode && jsxs(Fragment, {
744
+ children: [jsx("b", {
2241
745
  style: {
2242
746
  padding: '0px',
2243
747
  margin: '0px'
2244
748
  },
2245
- children: ["name:", name]
2246
- }), jsxs("b", {
2247
- style: {
2248
- padding: '0px',
2249
- margin: '0px'
749
+ children: `form index: ${schemaIndex}`
750
+ }), jsx("button", {
751
+ onClick: () => console.log(getForm({
752
+ key: schemaIndex
753
+ })),
754
+ children: "print form instance"
755
+ }), jsx("button", {
756
+ onClick: () => {
757
+ var _a;
758
+ return console.log((_a = getForm({
759
+ key: schemaIndex
760
+ })) === null || _a === void 0 ? void 0 : _a.getFormValues());
2250
761
  },
2251
- children: ["order:", (_b = fieldInstance === null || fieldInstance === void 0 ? void 0 : fieldInstance.originalSchema) === null || _b === void 0 ? void 0 : _b.order]
2252
- }), jsxs("b", {
2253
- style: {
2254
- padding: '0px',
2255
- margin: '0px'
762
+ children: "print form values"
763
+ }), jsx("button", {
764
+ onClick: () => {
765
+ var _a;
766
+ return (_a = getForm({
767
+ key: schemaIndex
768
+ })) === null || _a === void 0 ? void 0 : _a.submit();
2256
769
  },
2257
- children: ["path:", fieldInstance === null || fieldInstance === void 0 ? void 0 : fieldInstance.path]
770
+ children: "try submit"
2258
771
  }), jsx("br", {}), jsx("hr", {})]
2259
- }), jsx(FieldWrapperComponentRender, {
2260
- props: Object.assign(Object.assign(Object.assign(Object.assign({}, mapProps), state.props), state.errors), valueState),
2261
- fieldInstance: fieldInstance,
2262
- mapper: mapper,
2263
- children: children ? children : ((_c = state === null || state === void 0 ? void 0 : state.props) === null || _c === void 0 ? void 0 : _c.children) ? state === null || state === void 0 ? void 0 : state.props.children : null
772
+ }), jsxs("form", {
773
+ onSubmit: handleSubmit,
774
+ children: [jsx(BuildSchemaAsFields, {
775
+ formIndex: schemaIndex,
776
+ mappers: mappers,
777
+ components: schema === null || schema === void 0 ? void 0 : schema.components,
778
+ mountedForm: mounted
779
+ }), children]
2264
780
  })]
2265
- }) : jsx(Fragment, {});
2266
- };
781
+ });
782
+ }
2267
783
 
2268
784
  /**
2269
- * Component Wrapper to render form fields without the Form component, gets additional formId and mapper since
2270
- * it won't rely on them and needs to be manually declared
785
+ * Component wrapper to aid building schemas with react without writting a JSON schema
786
+ * along with BuildAsFormFieldTree inside a Form component, FieldWrapper gets this props
787
+ * to build the component as it does with a JSON schema, this component only works inside
788
+ * the Form component
2271
789
  *
2272
- * @param {TAsFormFieldBuilderProps} props JSON schema props along with FieldWrapper props and mapper props
2273
- * @returns {ReactElement}
790
+ * @param {TAsFormFieldProps} props JSON schema props
791
+ * @returns {ReactNode}
2274
792
  */
2275
- const AsFormFieldBuilder = props => {
2276
- const context = useFormGroupContext({});
2277
- /**
2278
- * state to track the field instance creation process
2279
- */
2280
- const [mounted, setMounted] = useState(false);
2281
- const mountedRef = useRef(false);
2282
- /**
2283
- * initializer to create or add a form instance to the formGroup by it's formId
2284
- * and add the field to the form instance
2285
- * Also has the logic to remove it once this element is removed
2286
- */
2287
- useEffect(() => {
2288
- var _a;
2289
- if (mountedRef.current) return;
2290
- if (typeof props.formMounted === 'undefined' && !((_a = context.formGroupInstance) === null || _a === void 0 ? void 0 : _a.forms.has(props.formIndex))) {
2291
- context.addFormWithIndex(props.formIndex);
2292
- }
2293
- if (props.formMounted || typeof props.formMounted === 'undefined') {
2294
- const fieldSchema = Object.assign(Object.assign({}, props), {
2295
- component: props.mapper.componentName,
2296
- children: undefined
2297
- });
2298
- const formInstance = context.formGroupInstance.forms.get(props.formIndex);
2299
- formInstance === null || formInstance === void 0 ? void 0 : formInstance.addField({
2300
- fieldSchema,
2301
- mapperElement: props.mapper
2302
- });
2303
- setMounted(true);
2304
- mountedRef.current = true;
2305
- }
2306
- }, [props.formMounted]);
2307
- /**
2308
- * recycle effect to remove the field from the form instance when the field leaves the vDOM
2309
- * and the subscriptions
2310
- */
2311
- useEffect(() => {
2312
- return () => {
2313
- var _a, _b;
2314
- if ((_b = (_a = context.getForm({
2315
- key: props.formIndex
2316
- })) === null || _a === void 0 ? void 0 : _a.getField({
2317
- key: props.name
2318
- })) === null || _b === void 0 ? void 0 : _b.mounted) context.formGroupInstance.removeField({
2319
- formIndex: props.formIndex,
2320
- fieldIndex: props.name
2321
- });
2322
- };
2323
- }, []);
2324
- /**
2325
- * allows to control field selected value on each event
2326
- */
2327
- useEffect(() => {
2328
- var _a;
2329
- if (!props.onSelected) return;
2330
- const callback = payload => {
2331
- if (props.onSelected) {
2332
- props.onSelected(payload);
2333
- }
2334
- };
2335
- const sub = (_a = context.formGroupInstance.forms.get(props.formIndex)) === null || _a === void 0 ? void 0 : _a.subscribeFieldEvent({
2336
- callback
2337
- });
2338
- return () => sub === null || sub === void 0 ? void 0 : sub.unsubscribe();
2339
- }, [props.onSelected]);
2340
- return jsx(FieldWrapper, {
2341
- formIndex: props.formIndex,
2342
- name: props.name,
2343
- props: props.props,
2344
- context: !context.active ? context : null,
2345
- mounted: mounted,
2346
- mapper: props.mapper,
2347
- visibility: props.visibility,
2348
- children: props.children && props.children
2349
- });
793
+ const AsFormField = props => {
794
+ return props.children;
2350
795
  };
2351
796
 
2352
797
  function useFormGroup({
@@ -2409,6 +854,124 @@ function useFormGroup({
2409
854
  return;
2410
855
  }
2411
856
 
857
+ /**
858
+ * Adapter do manage repeated list elements on form
859
+ *
860
+ * @param {TAsFormFieldRepeaterProps} props Repeater properties to configure the elements repeater
861
+ * @returns {ReactElement}
862
+ */
863
+ const AsFormFieldRepeater = ({
864
+ RepeaterComponent,
865
+ addFieldName,
866
+ removeFieldName,
867
+ existingElements,
868
+ initialElements,
869
+ stateUpdater,
870
+ formPrefix,
871
+ RepeaterFooter
872
+ }) => {
873
+ const {
874
+ getForm,
875
+ formGroupInstance
876
+ } = useFormGroupContext();
877
+ const [elements, setElements] = useState(typeof existingElements === 'object' && existingElements !== null ? Object.keys(existingElements).map(() => uniqueIdGen()) : typeof initialElements === 'number' ? Array.from(Array(initialElements), () => uniqueIdGen()) : []);
878
+ const mountedRef = useRef(false);
879
+ const prevElements = useRef(0);
880
+ const REPEATER_FOOTER_ID = useMemo(() => uniqueIdGen(), []);
881
+ const listeningElements = useMemo(() => {
882
+ return [...elements, REPEATER_FOOTER_ID];
883
+ }, [elements]);
884
+ useFormGroup({
885
+ ids: listeningElements,
886
+ onData: payload => {
887
+ if (stateUpdater) {
888
+ if (formPrefix) {
889
+ stateUpdater(elements.reduce((acc, curr, index) => {
890
+ const value = payload[curr];
891
+ acc[`${formPrefix}${index + 1}`] = value;
892
+ return acc;
893
+ }, {}));
894
+ return;
895
+ }
896
+ stateUpdater(payload);
897
+ }
898
+ }
899
+ }, [listeningElements]);
900
+ useEffect(() => {
901
+ // @TODO: refactor, quick workarount to emit data when removing a form from the list
902
+ if (prevElements.current > elements.length) {
903
+ formGroupInstance.dataSubject$.next({
904
+ event: 'ON_FIELD_UNMOUNT',
905
+ fieldIndex: 'unmounted_repeater_form',
906
+ formIndex: elements[0]
907
+ });
908
+ }
909
+ if (!mountedRef.current) {
910
+ elements.forEach((key, index) => {
911
+ const form = getForm({
912
+ key
913
+ });
914
+ if (form && (existingElements === null || existingElements === void 0 ? void 0 : existingElements[index])) {
915
+ form.initialValues = existingElements[index];
916
+ }
917
+ });
918
+ }
919
+ const subs = listeningElements.map(key => {
920
+ var _a;
921
+ return (_a = getForm({
922
+ key
923
+ })) === null || _a === void 0 ? void 0 : _a.subscribeFieldEvent({
924
+ callback({
925
+ event,
926
+ fieldName,
927
+ fieldInstance
928
+ }) {
929
+ if (fieldInstance === null || fieldInstance === void 0 ? void 0 : fieldInstance.formIndex) {
930
+ if (event === 'ON_FIELD_CLICK' && fieldInstance.formIndex === REPEATER_FOOTER_ID) {
931
+ setElements(prev => {
932
+ prev.push(uniqueIdGen());
933
+ return [...prev];
934
+ });
935
+ return;
936
+ }
937
+ if (event === 'ON_FIELD_CLICK' && fieldName === addFieldName) {
938
+ setElements(prev => {
939
+ const index = prev.indexOf(fieldInstance === null || fieldInstance === void 0 ? void 0 : fieldInstance.formIndex);
940
+ prev.splice(index + 1, 0, uniqueIdGen());
941
+ return [...prev];
942
+ });
943
+ }
944
+ if (event === 'ON_FIELD_CLICK' && fieldName === removeFieldName) {
945
+ if ((fieldInstance === null || fieldInstance === void 0 ? void 0 : fieldInstance.formIndex) && elements.length > 0) setElements(prev => {
946
+ const index = prev.indexOf(fieldInstance === null || fieldInstance === void 0 ? void 0 : fieldInstance.formIndex);
947
+ prev.splice(index, 1);
948
+ return [...prev];
949
+ });
950
+ }
951
+ }
952
+ }
953
+ });
954
+ });
955
+ mountedRef.current = true;
956
+ prevElements.current = elements.length;
957
+ return () => {
958
+ subs.map(sub => sub === null || sub === void 0 ? void 0 : sub.unsubscribe());
959
+ };
960
+ }, [elements]);
961
+ return jsxs("div", {
962
+ style: {
963
+ display: 'flex',
964
+ flexDirection: 'column'
965
+ },
966
+ children: [elements.map((el, index) => jsx(RepeaterComponent, {
967
+ formIndex: el,
968
+ index: index
969
+ }, el)), RepeaterFooter && jsx(RepeaterFooter, {
970
+ formIndex: REPEATER_FOOTER_ID
971
+ })]
972
+ });
973
+ };
974
+
2412
975
  const defaultChangeEvent = event => {
2413
976
  return event.currentTarget.value;
2414
977
  };
@@ -2451,4 +1014,4 @@ const dropdownChangeEvent = (event, opts) => {
2451
1014
  }
2452
1015
  };
2453
1016
 
2454
- export { AsFormField, AsFormFieldBuilder, Form, FormGroupContext, FormGroupContextProvider, checkedChangeEvent, datepickerChangeEvent, defaultChangeEvent, dropdownChangeEvent, numberInputChangeEvent, useForm, useFormGroup, useFormGroupContext, valueChangeEvent };
1017
+ export { AsFormField, AsFormFieldBuilder, AsFormFieldRepeater, Form, FormGroupContext, FormGroupContextProvider, checkedChangeEvent, datepickerChangeEvent, defaultChangeEvent, dropdownChangeEvent, numberInputChangeEvent, useForm, useFormGroup, useFormGroupContext, valueChangeEvent };