@bigbinary/neeto-templates-frontend 1.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js ADDED
@@ -0,0 +1,2914 @@
1
+ import React, { useState, useRef, useCallback, useEffect } from 'react';
2
+ import { noop } from '@bigbinary/neeto-cist';
3
+ import { Typography, Dropdown, Input, Spinner, Button, Modal } from '@bigbinary/neetoui';
4
+ import { useDebounce } from '@bigbinary/neeto-commons-frontend/react-utils';
5
+ import { MenuHorizontal, Search, LeftArrow } from '@bigbinary/neeto-icons';
6
+ import PageLoader from '@bigbinary/neeto-molecules/PageLoader';
7
+ import Scrollable from '@bigbinary/neeto-molecules/Scrollable';
8
+ import { useTranslation } from 'react-i18next';
9
+ import { prop } from 'ramda';
10
+ import { QueryClient, useInfiniteQuery, useMutation } from 'react-query';
11
+ import axios from 'axios';
12
+ import require$$0 from 'util';
13
+ import { DEFAULT_STALE_TIME } from '@bigbinary/neeto-commons-frontend/constants';
14
+ import CustomSVG from 'images/dashboard/custom';
15
+ import classnames from 'classnames';
16
+ import { joinHyphenCase, buildUrl } from '@bigbinary/neeto-commons-frontend/utils';
17
+
18
+ function _arrayWithHoles(arr) {
19
+ if (Array.isArray(arr)) return arr;
20
+ }
21
+
22
+ function _iterableToArrayLimit(arr, i) {
23
+ var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"];
24
+ if (null != _i) {
25
+ var _s,
26
+ _e,
27
+ _x,
28
+ _r,
29
+ _arr = [],
30
+ _n = !0,
31
+ _d = !1;
32
+ try {
33
+ if (_x = (_i = _i.call(arr)).next, 0 === i) {
34
+ if (Object(_i) !== _i) return;
35
+ _n = !1;
36
+ } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0);
37
+ } catch (err) {
38
+ _d = !0, _e = err;
39
+ } finally {
40
+ try {
41
+ if (!_n && null != _i["return"] && (_r = _i["return"](), Object(_r) !== _r)) return;
42
+ } finally {
43
+ if (_d) throw _e;
44
+ }
45
+ }
46
+ return _arr;
47
+ }
48
+ }
49
+
50
+ function _arrayLikeToArray(arr, len) {
51
+ if (len == null || len > arr.length) len = arr.length;
52
+ for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
53
+ return arr2;
54
+ }
55
+
56
+ function _unsupportedIterableToArray(o, minLen) {
57
+ if (!o) return;
58
+ if (typeof o === "string") return _arrayLikeToArray(o, minLen);
59
+ var n = Object.prototype.toString.call(o).slice(8, -1);
60
+ if (n === "Object" && o.constructor) n = o.constructor.name;
61
+ if (n === "Map" || n === "Set") return Array.from(o);
62
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
63
+ }
64
+
65
+ function _nonIterableRest() {
66
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
67
+ }
68
+
69
+ function _slicedToArray(arr, i) {
70
+ return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
71
+ }
72
+
73
+ var TEMPLATE_SCREENS = {
74
+ LIST: "List",
75
+ PREVIEW: "Preview"
76
+ };
77
+ var PREVIEW_URL = "/:publicLinkId?embedPreview=true&templateView=true";
78
+ var DEFAULT_CATEGORY = {
79
+ id: "all",
80
+ name: "All"
81
+ };
82
+ var INFINITE_SCROLL_DELAY = 500;
83
+
84
+ function _typeof(obj) {
85
+ "@babel/helpers - typeof";
86
+
87
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
88
+ return typeof obj;
89
+ } : function (obj) {
90
+ return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
91
+ }, _typeof(obj);
92
+ }
93
+
94
+ function _toPrimitive(input, hint) {
95
+ if (_typeof(input) !== "object" || input === null) return input;
96
+ var prim = input[Symbol.toPrimitive];
97
+ if (prim !== undefined) {
98
+ var res = prim.call(input, hint || "default");
99
+ if (_typeof(res) !== "object") return res;
100
+ throw new TypeError("@@toPrimitive must return a primitive value.");
101
+ }
102
+ return (hint === "string" ? String : Number)(input);
103
+ }
104
+
105
+ function _toPropertyKey(arg) {
106
+ var key = _toPrimitive(arg, "string");
107
+ return _typeof(key) === "symbol" ? key : String(key);
108
+ }
109
+
110
+ function _defineProperty(obj, key, value) {
111
+ key = _toPropertyKey(key);
112
+ if (key in obj) {
113
+ Object.defineProperty(obj, key, {
114
+ value: value,
115
+ enumerable: true,
116
+ configurable: true,
117
+ writable: true
118
+ });
119
+ } else {
120
+ obj[key] = value;
121
+ }
122
+ return obj;
123
+ }
124
+
125
+ function _arrayWithoutHoles(arr) {
126
+ if (Array.isArray(arr)) return _arrayLikeToArray(arr);
127
+ }
128
+
129
+ function _iterableToArray(iter) {
130
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
131
+ }
132
+
133
+ function _nonIterableSpread() {
134
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
135
+ }
136
+
137
+ function _toConsumableArray(arr) {
138
+ return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
139
+ }
140
+
141
+ function createObserverCache() {
142
+ var cachesByRoot = new Map();
143
+
144
+ function getObserver(_ref) {
145
+ var root = _ref.root,
146
+ rootMargin = _ref.rootMargin,
147
+ threshold = _ref.threshold;
148
+ var cacheByRoot = cachesByRoot.get(root);
149
+
150
+ if (!cacheByRoot) {
151
+ cacheByRoot = new Map();
152
+ cachesByRoot.set(root, cacheByRoot);
153
+ }
154
+
155
+ var cacheKey = JSON.stringify({
156
+ rootMargin: rootMargin,
157
+ threshold: threshold
158
+ });
159
+ var cachedObserver = cacheByRoot.get(cacheKey);
160
+
161
+ if (!cachedObserver) {
162
+ var entryCallbacks = new Map();
163
+ var observer = new IntersectionObserver(function (entries) {
164
+ entries.forEach(function (entry) {
165
+ var callback = entryCallbacks.get(entry.target);
166
+ callback == null ? void 0 : callback(entry);
167
+ });
168
+ }, {
169
+ root: root,
170
+ rootMargin: rootMargin,
171
+ threshold: threshold
172
+ });
173
+ cachedObserver = {
174
+ observer: observer,
175
+ entryCallbacks: entryCallbacks
176
+ };
177
+ cacheByRoot.set(cacheKey, cachedObserver);
178
+ }
179
+
180
+ return {
181
+ observe: function observe(node, callback) {
182
+ var _cachedObserver, _cachedObserver2;
183
+
184
+ (_cachedObserver = cachedObserver) == null ? void 0 : _cachedObserver.entryCallbacks.set(node, callback);
185
+ (_cachedObserver2 = cachedObserver) == null ? void 0 : _cachedObserver2.observer.observe(node);
186
+ },
187
+ unobserve: function unobserve(node) {
188
+ var _cachedObserver3, _cachedObserver4;
189
+
190
+ (_cachedObserver3 = cachedObserver) == null ? void 0 : _cachedObserver3.entryCallbacks["delete"](node);
191
+ (_cachedObserver4 = cachedObserver) == null ? void 0 : _cachedObserver4.observer.unobserve(node);
192
+ }
193
+ };
194
+ }
195
+
196
+ return {
197
+ getObserver: getObserver
198
+ };
199
+ }
200
+
201
+ var DEFAULT_ROOT_MARGIN = '0px';
202
+ var DEFAULT_THRESHOLD = [0];
203
+ var observerCache = /*#__PURE__*/createObserverCache(); // For more info:
204
+ // https://developers.google.com/web/updates/2016/04/intersectionobserver
205
+ // https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API
206
+
207
+ function useIntersectionObserver(args) {
208
+ var _args$rootMargin, _args$threshold;
209
+
210
+ var rootMargin = (_args$rootMargin = args == null ? void 0 : args.rootMargin) != null ? _args$rootMargin : DEFAULT_ROOT_MARGIN;
211
+ var threshold = (_args$threshold = args == null ? void 0 : args.threshold) != null ? _args$threshold : DEFAULT_THRESHOLD;
212
+ var nodeRef = useRef(null);
213
+ var rootRef = useRef(null);
214
+ var observerRef = useRef(null);
215
+
216
+ var _useState = useState(),
217
+ entry = _useState[0],
218
+ setEntry = _useState[1];
219
+
220
+ var observe = useCallback(function () {
221
+ var node = nodeRef.current;
222
+
223
+ if (!node) {
224
+ setEntry(undefined);
225
+ return;
226
+ }
227
+
228
+ var observer = observerCache.getObserver({
229
+ root: rootRef.current,
230
+ rootMargin: rootMargin,
231
+ threshold: threshold
232
+ });
233
+ observer.observe(node, function (observedEntry) {
234
+ setEntry(observedEntry);
235
+ });
236
+ observerRef.current = observer;
237
+ }, [rootMargin, threshold]);
238
+ var unobserve = useCallback(function () {
239
+ var currentObserver = observerRef.current;
240
+ var node = nodeRef.current;
241
+
242
+ if (node) {
243
+ currentObserver == null ? void 0 : currentObserver.unobserve(node);
244
+ }
245
+
246
+ observerRef.current = null;
247
+ }, []); // React will call the ref callback with the DOM element when the component mounts,
248
+ // and call it with null when it unmounts.
249
+ // So, we don't need an useEffect etc to unobserve nodes.
250
+ // When nodeRef.current is null, it will be unobserved and observe function
251
+ // won't do anything.
252
+
253
+ var refCallback = useCallback(function (node) {
254
+ unobserve();
255
+ nodeRef.current = node;
256
+ observe();
257
+ }, [observe, unobserve]);
258
+ var rootRefCallback = useCallback(function (rootNode) {
259
+ unobserve();
260
+ rootRef.current = rootNode;
261
+ observe();
262
+ }, [observe, unobserve]);
263
+ return [refCallback, {
264
+ entry: entry,
265
+ rootRef: rootRefCallback
266
+ }];
267
+ }
268
+
269
+ function _extends() {
270
+ _extends = Object.assign || function (target) {
271
+ for (var i = 1; i < arguments.length; i++) {
272
+ var source = arguments[i];
273
+
274
+ for (var key in source) {
275
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
276
+ target[key] = source[key];
277
+ }
278
+ }
279
+ }
280
+
281
+ return target;
282
+ };
283
+
284
+ return _extends.apply(this, arguments);
285
+ }
286
+
287
+ function useTrackVisibility(args) {
288
+ var _result$entry;
289
+
290
+ var _useIntersectionObser = useIntersectionObserver(args),
291
+ ref = _useIntersectionObser[0],
292
+ result = _useIntersectionObser[1];
293
+
294
+ var isVisible = Boolean((_result$entry = result.entry) == null ? void 0 : _result$entry.isIntersecting);
295
+
296
+ var _useState = useState(isVisible),
297
+ wasEverVisible = _useState[0],
298
+ setWasEverVisible = _useState[1];
299
+
300
+ if (isVisible && !wasEverVisible) {
301
+ setWasEverVisible(true);
302
+ }
303
+
304
+ return [ref, _extends({}, result, {
305
+ isVisible: isVisible,
306
+ wasEverVisible: wasEverVisible
307
+ })];
308
+ }
309
+
310
+ var DEFAULT_DELAY_IN_MS = 100;
311
+
312
+ function useInfiniteScroll(_ref) {
313
+ var loading = _ref.loading,
314
+ hasNextPage = _ref.hasNextPage,
315
+ onLoadMore = _ref.onLoadMore,
316
+ rootMargin = _ref.rootMargin,
317
+ disabled = _ref.disabled,
318
+ _ref$delayInMs = _ref.delayInMs,
319
+ delayInMs = _ref$delayInMs === void 0 ? DEFAULT_DELAY_IN_MS : _ref$delayInMs;
320
+
321
+ var _useTrackVisibility = useTrackVisibility({
322
+ rootMargin: rootMargin
323
+ }),
324
+ ref = _useTrackVisibility[0],
325
+ _useTrackVisibility$ = _useTrackVisibility[1],
326
+ rootRef = _useTrackVisibility$.rootRef,
327
+ isVisible = _useTrackVisibility$.isVisible;
328
+
329
+ var shouldLoadMore = !disabled && !loading && isVisible && hasNextPage; // eslint-disable-next-line consistent-return
330
+
331
+ useEffect(function () {
332
+ if (shouldLoadMore) {
333
+ // When we trigger 'onLoadMore' and new items are added to the list,
334
+ // right before they become rendered on the screen, 'loading' becomes false
335
+ // and 'isVisible' can be true for a brief time, based on the scroll position.
336
+ // So, it triggers 'onLoadMore' just after the first one is finished.
337
+ // We use a small delay here to prevent this kind of situations.
338
+ // It can be configured by hook args.
339
+ var timer = setTimeout(function () {
340
+ onLoadMore();
341
+ }, delayInMs);
342
+ return function () {
343
+ clearTimeout(timer);
344
+ };
345
+ }
346
+ }, [onLoadMore, shouldLoadMore, delayInMs]);
347
+ return [ref, {
348
+ rootRef: rootRef
349
+ }];
350
+ }
351
+
352
+ function _objectWithoutPropertiesLoose(source, excluded) {
353
+ if (source == null) return {};
354
+ var target = {};
355
+ var sourceKeys = Object.keys(source);
356
+ var key, i;
357
+ for (i = 0; i < sourceKeys.length; i++) {
358
+ key = sourceKeys[i];
359
+ if (excluded.indexOf(key) >= 0) continue;
360
+ target[key] = source[key];
361
+ }
362
+ return target;
363
+ }
364
+
365
+ function _objectWithoutProperties(source, excluded) {
366
+ if (source == null) return {};
367
+ var target = _objectWithoutPropertiesLoose(source, excluded);
368
+ var key, i;
369
+ if (Object.getOwnPropertySymbols) {
370
+ var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
371
+ for (i = 0; i < sourceSymbolKeys.length; i++) {
372
+ key = sourceSymbolKeys[i];
373
+ if (excluded.indexOf(key) >= 0) continue;
374
+ if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
375
+ target[key] = source[key];
376
+ }
377
+ }
378
+ return target;
379
+ }
380
+
381
+ /* eslint complexity: [2, 18], max-statements: [2, 33] */
382
+ var shams = function hasSymbols() {
383
+ if (typeof Symbol !== 'function' || typeof Object.getOwnPropertySymbols !== 'function') { return false; }
384
+ if (typeof Symbol.iterator === 'symbol') { return true; }
385
+
386
+ var obj = {};
387
+ var sym = Symbol('test');
388
+ var symObj = Object(sym);
389
+ if (typeof sym === 'string') { return false; }
390
+
391
+ if (Object.prototype.toString.call(sym) !== '[object Symbol]') { return false; }
392
+ if (Object.prototype.toString.call(symObj) !== '[object Symbol]') { return false; }
393
+
394
+ // temp disabled per https://github.com/ljharb/object.assign/issues/17
395
+ // if (sym instanceof Symbol) { return false; }
396
+ // temp disabled per https://github.com/WebReflection/get-own-property-symbols/issues/4
397
+ // if (!(symObj instanceof Symbol)) { return false; }
398
+
399
+ // if (typeof Symbol.prototype.toString !== 'function') { return false; }
400
+ // if (String(sym) !== Symbol.prototype.toString.call(sym)) { return false; }
401
+
402
+ var symVal = 42;
403
+ obj[sym] = symVal;
404
+ for (sym in obj) { return false; } // eslint-disable-line no-restricted-syntax, no-unreachable-loop
405
+ if (typeof Object.keys === 'function' && Object.keys(obj).length !== 0) { return false; }
406
+
407
+ if (typeof Object.getOwnPropertyNames === 'function' && Object.getOwnPropertyNames(obj).length !== 0) { return false; }
408
+
409
+ var syms = Object.getOwnPropertySymbols(obj);
410
+ if (syms.length !== 1 || syms[0] !== sym) { return false; }
411
+
412
+ if (!Object.prototype.propertyIsEnumerable.call(obj, sym)) { return false; }
413
+
414
+ if (typeof Object.getOwnPropertyDescriptor === 'function') {
415
+ var descriptor = Object.getOwnPropertyDescriptor(obj, sym);
416
+ if (descriptor.value !== symVal || descriptor.enumerable !== true) { return false; }
417
+ }
418
+
419
+ return true;
420
+ };
421
+
422
+ var origSymbol = typeof Symbol !== 'undefined' && Symbol;
423
+ var hasSymbolSham = shams;
424
+
425
+ var hasSymbols$1 = function hasNativeSymbols() {
426
+ if (typeof origSymbol !== 'function') { return false; }
427
+ if (typeof Symbol !== 'function') { return false; }
428
+ if (typeof origSymbol('foo') !== 'symbol') { return false; }
429
+ if (typeof Symbol('bar') !== 'symbol') { return false; }
430
+
431
+ return hasSymbolSham();
432
+ };
433
+
434
+ var test = {
435
+ foo: {}
436
+ };
437
+
438
+ var $Object = Object;
439
+
440
+ var hasProto$1 = function hasProto() {
441
+ return { __proto__: test }.foo === test.foo && !({ __proto__: null } instanceof $Object);
442
+ };
443
+
444
+ /* eslint no-invalid-this: 1 */
445
+
446
+ var ERROR_MESSAGE = 'Function.prototype.bind called on incompatible ';
447
+ var slice = Array.prototype.slice;
448
+ var toStr$1 = Object.prototype.toString;
449
+ var funcType = '[object Function]';
450
+
451
+ var implementation$1 = function bind(that) {
452
+ var target = this;
453
+ if (typeof target !== 'function' || toStr$1.call(target) !== funcType) {
454
+ throw new TypeError(ERROR_MESSAGE + target);
455
+ }
456
+ var args = slice.call(arguments, 1);
457
+
458
+ var bound;
459
+ var binder = function () {
460
+ if (this instanceof bound) {
461
+ var result = target.apply(
462
+ this,
463
+ args.concat(slice.call(arguments))
464
+ );
465
+ if (Object(result) === result) {
466
+ return result;
467
+ }
468
+ return this;
469
+ } else {
470
+ return target.apply(
471
+ that,
472
+ args.concat(slice.call(arguments))
473
+ );
474
+ }
475
+ };
476
+
477
+ var boundLength = Math.max(0, target.length - args.length);
478
+ var boundArgs = [];
479
+ for (var i = 0; i < boundLength; i++) {
480
+ boundArgs.push('$' + i);
481
+ }
482
+
483
+ bound = Function('binder', 'return function (' + boundArgs.join(',') + '){ return binder.apply(this,arguments); }')(binder);
484
+
485
+ if (target.prototype) {
486
+ var Empty = function Empty() {};
487
+ Empty.prototype = target.prototype;
488
+ bound.prototype = new Empty();
489
+ Empty.prototype = null;
490
+ }
491
+
492
+ return bound;
493
+ };
494
+
495
+ var implementation = implementation$1;
496
+
497
+ var functionBind = Function.prototype.bind || implementation;
498
+
499
+ var bind$1 = functionBind;
500
+
501
+ var src = bind$1.call(Function.call, Object.prototype.hasOwnProperty);
502
+
503
+ var undefined$1;
504
+
505
+ var $SyntaxError = SyntaxError;
506
+ var $Function = Function;
507
+ var $TypeError$1 = TypeError;
508
+
509
+ // eslint-disable-next-line consistent-return
510
+ var getEvalledConstructor = function (expressionSyntax) {
511
+ try {
512
+ return $Function('"use strict"; return (' + expressionSyntax + ').constructor;')();
513
+ } catch (e) {}
514
+ };
515
+
516
+ var $gOPD = Object.getOwnPropertyDescriptor;
517
+ if ($gOPD) {
518
+ try {
519
+ $gOPD({}, '');
520
+ } catch (e) {
521
+ $gOPD = null; // this is IE 8, which has a broken gOPD
522
+ }
523
+ }
524
+
525
+ var throwTypeError = function () {
526
+ throw new $TypeError$1();
527
+ };
528
+ var ThrowTypeError = $gOPD
529
+ ? (function () {
530
+ try {
531
+ // eslint-disable-next-line no-unused-expressions, no-caller, no-restricted-properties
532
+ arguments.callee; // IE 8 does not throw here
533
+ return throwTypeError;
534
+ } catch (calleeThrows) {
535
+ try {
536
+ // IE 8 throws on Object.getOwnPropertyDescriptor(arguments, '')
537
+ return $gOPD(arguments, 'callee').get;
538
+ } catch (gOPDthrows) {
539
+ return throwTypeError;
540
+ }
541
+ }
542
+ }())
543
+ : throwTypeError;
544
+
545
+ var hasSymbols = hasSymbols$1();
546
+ var hasProto = hasProto$1();
547
+
548
+ var getProto = Object.getPrototypeOf || (
549
+ hasProto
550
+ ? function (x) { return x.__proto__; } // eslint-disable-line no-proto
551
+ : null
552
+ );
553
+
554
+ var needsEval = {};
555
+
556
+ var TypedArray = typeof Uint8Array === 'undefined' || !getProto ? undefined$1 : getProto(Uint8Array);
557
+
558
+ var INTRINSICS = {
559
+ '%AggregateError%': typeof AggregateError === 'undefined' ? undefined$1 : AggregateError,
560
+ '%Array%': Array,
561
+ '%ArrayBuffer%': typeof ArrayBuffer === 'undefined' ? undefined$1 : ArrayBuffer,
562
+ '%ArrayIteratorPrototype%': hasSymbols && getProto ? getProto([][Symbol.iterator]()) : undefined$1,
563
+ '%AsyncFromSyncIteratorPrototype%': undefined$1,
564
+ '%AsyncFunction%': needsEval,
565
+ '%AsyncGenerator%': needsEval,
566
+ '%AsyncGeneratorFunction%': needsEval,
567
+ '%AsyncIteratorPrototype%': needsEval,
568
+ '%Atomics%': typeof Atomics === 'undefined' ? undefined$1 : Atomics,
569
+ '%BigInt%': typeof BigInt === 'undefined' ? undefined$1 : BigInt,
570
+ '%BigInt64Array%': typeof BigInt64Array === 'undefined' ? undefined$1 : BigInt64Array,
571
+ '%BigUint64Array%': typeof BigUint64Array === 'undefined' ? undefined$1 : BigUint64Array,
572
+ '%Boolean%': Boolean,
573
+ '%DataView%': typeof DataView === 'undefined' ? undefined$1 : DataView,
574
+ '%Date%': Date,
575
+ '%decodeURI%': decodeURI,
576
+ '%decodeURIComponent%': decodeURIComponent,
577
+ '%encodeURI%': encodeURI,
578
+ '%encodeURIComponent%': encodeURIComponent,
579
+ '%Error%': Error,
580
+ '%eval%': eval, // eslint-disable-line no-eval
581
+ '%EvalError%': EvalError,
582
+ '%Float32Array%': typeof Float32Array === 'undefined' ? undefined$1 : Float32Array,
583
+ '%Float64Array%': typeof Float64Array === 'undefined' ? undefined$1 : Float64Array,
584
+ '%FinalizationRegistry%': typeof FinalizationRegistry === 'undefined' ? undefined$1 : FinalizationRegistry,
585
+ '%Function%': $Function,
586
+ '%GeneratorFunction%': needsEval,
587
+ '%Int8Array%': typeof Int8Array === 'undefined' ? undefined$1 : Int8Array,
588
+ '%Int16Array%': typeof Int16Array === 'undefined' ? undefined$1 : Int16Array,
589
+ '%Int32Array%': typeof Int32Array === 'undefined' ? undefined$1 : Int32Array,
590
+ '%isFinite%': isFinite,
591
+ '%isNaN%': isNaN,
592
+ '%IteratorPrototype%': hasSymbols && getProto ? getProto(getProto([][Symbol.iterator]())) : undefined$1,
593
+ '%JSON%': typeof JSON === 'object' ? JSON : undefined$1,
594
+ '%Map%': typeof Map === 'undefined' ? undefined$1 : Map,
595
+ '%MapIteratorPrototype%': typeof Map === 'undefined' || !hasSymbols || !getProto ? undefined$1 : getProto(new Map()[Symbol.iterator]()),
596
+ '%Math%': Math,
597
+ '%Number%': Number,
598
+ '%Object%': Object,
599
+ '%parseFloat%': parseFloat,
600
+ '%parseInt%': parseInt,
601
+ '%Promise%': typeof Promise === 'undefined' ? undefined$1 : Promise,
602
+ '%Proxy%': typeof Proxy === 'undefined' ? undefined$1 : Proxy,
603
+ '%RangeError%': RangeError,
604
+ '%ReferenceError%': ReferenceError,
605
+ '%Reflect%': typeof Reflect === 'undefined' ? undefined$1 : Reflect,
606
+ '%RegExp%': RegExp,
607
+ '%Set%': typeof Set === 'undefined' ? undefined$1 : Set,
608
+ '%SetIteratorPrototype%': typeof Set === 'undefined' || !hasSymbols || !getProto ? undefined$1 : getProto(new Set()[Symbol.iterator]()),
609
+ '%SharedArrayBuffer%': typeof SharedArrayBuffer === 'undefined' ? undefined$1 : SharedArrayBuffer,
610
+ '%String%': String,
611
+ '%StringIteratorPrototype%': hasSymbols && getProto ? getProto(''[Symbol.iterator]()) : undefined$1,
612
+ '%Symbol%': hasSymbols ? Symbol : undefined$1,
613
+ '%SyntaxError%': $SyntaxError,
614
+ '%ThrowTypeError%': ThrowTypeError,
615
+ '%TypedArray%': TypedArray,
616
+ '%TypeError%': $TypeError$1,
617
+ '%Uint8Array%': typeof Uint8Array === 'undefined' ? undefined$1 : Uint8Array,
618
+ '%Uint8ClampedArray%': typeof Uint8ClampedArray === 'undefined' ? undefined$1 : Uint8ClampedArray,
619
+ '%Uint16Array%': typeof Uint16Array === 'undefined' ? undefined$1 : Uint16Array,
620
+ '%Uint32Array%': typeof Uint32Array === 'undefined' ? undefined$1 : Uint32Array,
621
+ '%URIError%': URIError,
622
+ '%WeakMap%': typeof WeakMap === 'undefined' ? undefined$1 : WeakMap,
623
+ '%WeakRef%': typeof WeakRef === 'undefined' ? undefined$1 : WeakRef,
624
+ '%WeakSet%': typeof WeakSet === 'undefined' ? undefined$1 : WeakSet
625
+ };
626
+
627
+ if (getProto) {
628
+ try {
629
+ null.error; // eslint-disable-line no-unused-expressions
630
+ } catch (e) {
631
+ // https://github.com/tc39/proposal-shadowrealm/pull/384#issuecomment-1364264229
632
+ var errorProto = getProto(getProto(e));
633
+ INTRINSICS['%Error.prototype%'] = errorProto;
634
+ }
635
+ }
636
+
637
+ var doEval = function doEval(name) {
638
+ var value;
639
+ if (name === '%AsyncFunction%') {
640
+ value = getEvalledConstructor('async function () {}');
641
+ } else if (name === '%GeneratorFunction%') {
642
+ value = getEvalledConstructor('function* () {}');
643
+ } else if (name === '%AsyncGeneratorFunction%') {
644
+ value = getEvalledConstructor('async function* () {}');
645
+ } else if (name === '%AsyncGenerator%') {
646
+ var fn = doEval('%AsyncGeneratorFunction%');
647
+ if (fn) {
648
+ value = fn.prototype;
649
+ }
650
+ } else if (name === '%AsyncIteratorPrototype%') {
651
+ var gen = doEval('%AsyncGenerator%');
652
+ if (gen && getProto) {
653
+ value = getProto(gen.prototype);
654
+ }
655
+ }
656
+
657
+ INTRINSICS[name] = value;
658
+
659
+ return value;
660
+ };
661
+
662
+ var LEGACY_ALIASES = {
663
+ '%ArrayBufferPrototype%': ['ArrayBuffer', 'prototype'],
664
+ '%ArrayPrototype%': ['Array', 'prototype'],
665
+ '%ArrayProto_entries%': ['Array', 'prototype', 'entries'],
666
+ '%ArrayProto_forEach%': ['Array', 'prototype', 'forEach'],
667
+ '%ArrayProto_keys%': ['Array', 'prototype', 'keys'],
668
+ '%ArrayProto_values%': ['Array', 'prototype', 'values'],
669
+ '%AsyncFunctionPrototype%': ['AsyncFunction', 'prototype'],
670
+ '%AsyncGenerator%': ['AsyncGeneratorFunction', 'prototype'],
671
+ '%AsyncGeneratorPrototype%': ['AsyncGeneratorFunction', 'prototype', 'prototype'],
672
+ '%BooleanPrototype%': ['Boolean', 'prototype'],
673
+ '%DataViewPrototype%': ['DataView', 'prototype'],
674
+ '%DatePrototype%': ['Date', 'prototype'],
675
+ '%ErrorPrototype%': ['Error', 'prototype'],
676
+ '%EvalErrorPrototype%': ['EvalError', 'prototype'],
677
+ '%Float32ArrayPrototype%': ['Float32Array', 'prototype'],
678
+ '%Float64ArrayPrototype%': ['Float64Array', 'prototype'],
679
+ '%FunctionPrototype%': ['Function', 'prototype'],
680
+ '%Generator%': ['GeneratorFunction', 'prototype'],
681
+ '%GeneratorPrototype%': ['GeneratorFunction', 'prototype', 'prototype'],
682
+ '%Int8ArrayPrototype%': ['Int8Array', 'prototype'],
683
+ '%Int16ArrayPrototype%': ['Int16Array', 'prototype'],
684
+ '%Int32ArrayPrototype%': ['Int32Array', 'prototype'],
685
+ '%JSONParse%': ['JSON', 'parse'],
686
+ '%JSONStringify%': ['JSON', 'stringify'],
687
+ '%MapPrototype%': ['Map', 'prototype'],
688
+ '%NumberPrototype%': ['Number', 'prototype'],
689
+ '%ObjectPrototype%': ['Object', 'prototype'],
690
+ '%ObjProto_toString%': ['Object', 'prototype', 'toString'],
691
+ '%ObjProto_valueOf%': ['Object', 'prototype', 'valueOf'],
692
+ '%PromisePrototype%': ['Promise', 'prototype'],
693
+ '%PromiseProto_then%': ['Promise', 'prototype', 'then'],
694
+ '%Promise_all%': ['Promise', 'all'],
695
+ '%Promise_reject%': ['Promise', 'reject'],
696
+ '%Promise_resolve%': ['Promise', 'resolve'],
697
+ '%RangeErrorPrototype%': ['RangeError', 'prototype'],
698
+ '%ReferenceErrorPrototype%': ['ReferenceError', 'prototype'],
699
+ '%RegExpPrototype%': ['RegExp', 'prototype'],
700
+ '%SetPrototype%': ['Set', 'prototype'],
701
+ '%SharedArrayBufferPrototype%': ['SharedArrayBuffer', 'prototype'],
702
+ '%StringPrototype%': ['String', 'prototype'],
703
+ '%SymbolPrototype%': ['Symbol', 'prototype'],
704
+ '%SyntaxErrorPrototype%': ['SyntaxError', 'prototype'],
705
+ '%TypedArrayPrototype%': ['TypedArray', 'prototype'],
706
+ '%TypeErrorPrototype%': ['TypeError', 'prototype'],
707
+ '%Uint8ArrayPrototype%': ['Uint8Array', 'prototype'],
708
+ '%Uint8ClampedArrayPrototype%': ['Uint8ClampedArray', 'prototype'],
709
+ '%Uint16ArrayPrototype%': ['Uint16Array', 'prototype'],
710
+ '%Uint32ArrayPrototype%': ['Uint32Array', 'prototype'],
711
+ '%URIErrorPrototype%': ['URIError', 'prototype'],
712
+ '%WeakMapPrototype%': ['WeakMap', 'prototype'],
713
+ '%WeakSetPrototype%': ['WeakSet', 'prototype']
714
+ };
715
+
716
+ var bind = functionBind;
717
+ var hasOwn$1 = src;
718
+ var $concat$1 = bind.call(Function.call, Array.prototype.concat);
719
+ var $spliceApply = bind.call(Function.apply, Array.prototype.splice);
720
+ var $replace$1 = bind.call(Function.call, String.prototype.replace);
721
+ var $strSlice = bind.call(Function.call, String.prototype.slice);
722
+ var $exec = bind.call(Function.call, RegExp.prototype.exec);
723
+
724
+ /* adapted from https://github.com/lodash/lodash/blob/4.17.15/dist/lodash.js#L6735-L6744 */
725
+ var rePropName = /[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g;
726
+ var reEscapeChar = /\\(\\)?/g; /** Used to match backslashes in property paths. */
727
+ var stringToPath = function stringToPath(string) {
728
+ var first = $strSlice(string, 0, 1);
729
+ var last = $strSlice(string, -1);
730
+ if (first === '%' && last !== '%') {
731
+ throw new $SyntaxError('invalid intrinsic syntax, expected closing `%`');
732
+ } else if (last === '%' && first !== '%') {
733
+ throw new $SyntaxError('invalid intrinsic syntax, expected opening `%`');
734
+ }
735
+ var result = [];
736
+ $replace$1(string, rePropName, function (match, number, quote, subString) {
737
+ result[result.length] = quote ? $replace$1(subString, reEscapeChar, '$1') : number || match;
738
+ });
739
+ return result;
740
+ };
741
+ /* end adaptation */
742
+
743
+ var getBaseIntrinsic = function getBaseIntrinsic(name, allowMissing) {
744
+ var intrinsicName = name;
745
+ var alias;
746
+ if (hasOwn$1(LEGACY_ALIASES, intrinsicName)) {
747
+ alias = LEGACY_ALIASES[intrinsicName];
748
+ intrinsicName = '%' + alias[0] + '%';
749
+ }
750
+
751
+ if (hasOwn$1(INTRINSICS, intrinsicName)) {
752
+ var value = INTRINSICS[intrinsicName];
753
+ if (value === needsEval) {
754
+ value = doEval(intrinsicName);
755
+ }
756
+ if (typeof value === 'undefined' && !allowMissing) {
757
+ throw new $TypeError$1('intrinsic ' + name + ' exists, but is not available. Please file an issue!');
758
+ }
759
+
760
+ return {
761
+ alias: alias,
762
+ name: intrinsicName,
763
+ value: value
764
+ };
765
+ }
766
+
767
+ throw new $SyntaxError('intrinsic ' + name + ' does not exist!');
768
+ };
769
+
770
+ var getIntrinsic = function GetIntrinsic(name, allowMissing) {
771
+ if (typeof name !== 'string' || name.length === 0) {
772
+ throw new $TypeError$1('intrinsic name must be a non-empty string');
773
+ }
774
+ if (arguments.length > 1 && typeof allowMissing !== 'boolean') {
775
+ throw new $TypeError$1('"allowMissing" argument must be a boolean');
776
+ }
777
+
778
+ if ($exec(/^%?[^%]*%?$/, name) === null) {
779
+ throw new $SyntaxError('`%` may not be present anywhere but at the beginning and end of the intrinsic name');
780
+ }
781
+ var parts = stringToPath(name);
782
+ var intrinsicBaseName = parts.length > 0 ? parts[0] : '';
783
+
784
+ var intrinsic = getBaseIntrinsic('%' + intrinsicBaseName + '%', allowMissing);
785
+ var intrinsicRealName = intrinsic.name;
786
+ var value = intrinsic.value;
787
+ var skipFurtherCaching = false;
788
+
789
+ var alias = intrinsic.alias;
790
+ if (alias) {
791
+ intrinsicBaseName = alias[0];
792
+ $spliceApply(parts, $concat$1([0, 1], alias));
793
+ }
794
+
795
+ for (var i = 1, isOwn = true; i < parts.length; i += 1) {
796
+ var part = parts[i];
797
+ var first = $strSlice(part, 0, 1);
798
+ var last = $strSlice(part, -1);
799
+ if (
800
+ (
801
+ (first === '"' || first === "'" || first === '`')
802
+ || (last === '"' || last === "'" || last === '`')
803
+ )
804
+ && first !== last
805
+ ) {
806
+ throw new $SyntaxError('property names with quotes must have matching quotes');
807
+ }
808
+ if (part === 'constructor' || !isOwn) {
809
+ skipFurtherCaching = true;
810
+ }
811
+
812
+ intrinsicBaseName += '.' + part;
813
+ intrinsicRealName = '%' + intrinsicBaseName + '%';
814
+
815
+ if (hasOwn$1(INTRINSICS, intrinsicRealName)) {
816
+ value = INTRINSICS[intrinsicRealName];
817
+ } else if (value != null) {
818
+ if (!(part in value)) {
819
+ if (!allowMissing) {
820
+ throw new $TypeError$1('base intrinsic for ' + name + ' exists, but the property is not available.');
821
+ }
822
+ return void undefined$1;
823
+ }
824
+ if ($gOPD && (i + 1) >= parts.length) {
825
+ var desc = $gOPD(value, part);
826
+ isOwn = !!desc;
827
+
828
+ // By convention, when a data property is converted to an accessor
829
+ // property to emulate a data property that does not suffer from
830
+ // the override mistake, that accessor's getter is marked with
831
+ // an `originalValue` property. Here, when we detect this, we
832
+ // uphold the illusion by pretending to see that original data
833
+ // property, i.e., returning the value rather than the getter
834
+ // itself.
835
+ if (isOwn && 'get' in desc && !('originalValue' in desc.get)) {
836
+ value = desc.get;
837
+ } else {
838
+ value = value[part];
839
+ }
840
+ } else {
841
+ isOwn = hasOwn$1(value, part);
842
+ value = value[part];
843
+ }
844
+
845
+ if (isOwn && !skipFurtherCaching) {
846
+ INTRINSICS[intrinsicRealName] = value;
847
+ }
848
+ }
849
+ }
850
+ return value;
851
+ };
852
+
853
+ var callBind$1 = {exports: {}};
854
+
855
+ callBind$1.exports;
856
+
857
+ (function (module) {
858
+
859
+ var bind = functionBind;
860
+ var GetIntrinsic = getIntrinsic;
861
+
862
+ var $apply = GetIntrinsic('%Function.prototype.apply%');
863
+ var $call = GetIntrinsic('%Function.prototype.call%');
864
+ var $reflectApply = GetIntrinsic('%Reflect.apply%', true) || bind.call($call, $apply);
865
+
866
+ var $gOPD = GetIntrinsic('%Object.getOwnPropertyDescriptor%', true);
867
+ var $defineProperty = GetIntrinsic('%Object.defineProperty%', true);
868
+ var $max = GetIntrinsic('%Math.max%');
869
+
870
+ if ($defineProperty) {
871
+ try {
872
+ $defineProperty({}, 'a', { value: 1 });
873
+ } catch (e) {
874
+ // IE 8 has a broken defineProperty
875
+ $defineProperty = null;
876
+ }
877
+ }
878
+
879
+ module.exports = function callBind(originalFunction) {
880
+ var func = $reflectApply(bind, $call, arguments);
881
+ if ($gOPD && $defineProperty) {
882
+ var desc = $gOPD(func, 'length');
883
+ if (desc.configurable) {
884
+ // original length, plus the receiver, minus any additional arguments (after the receiver)
885
+ $defineProperty(
886
+ func,
887
+ 'length',
888
+ { value: 1 + $max(0, originalFunction.length - (arguments.length - 1)) }
889
+ );
890
+ }
891
+ }
892
+ return func;
893
+ };
894
+
895
+ var applyBind = function applyBind() {
896
+ return $reflectApply(bind, $apply, arguments);
897
+ };
898
+
899
+ if ($defineProperty) {
900
+ $defineProperty(module.exports, 'apply', { value: applyBind });
901
+ } else {
902
+ module.exports.apply = applyBind;
903
+ }
904
+ } (callBind$1));
905
+
906
+ var callBindExports = callBind$1.exports;
907
+
908
+ var GetIntrinsic$1 = getIntrinsic;
909
+
910
+ var callBind = callBindExports;
911
+
912
+ var $indexOf = callBind(GetIntrinsic$1('String.prototype.indexOf'));
913
+
914
+ var callBound$1 = function callBoundIntrinsic(name, allowMissing) {
915
+ var intrinsic = GetIntrinsic$1(name, !!allowMissing);
916
+ if (typeof intrinsic === 'function' && $indexOf(name, '.prototype.') > -1) {
917
+ return callBind(intrinsic);
918
+ }
919
+ return intrinsic;
920
+ };
921
+
922
+ var util_inspect = require$$0.inspect;
923
+
924
+ var hasMap = typeof Map === 'function' && Map.prototype;
925
+ var mapSizeDescriptor = Object.getOwnPropertyDescriptor && hasMap ? Object.getOwnPropertyDescriptor(Map.prototype, 'size') : null;
926
+ var mapSize = hasMap && mapSizeDescriptor && typeof mapSizeDescriptor.get === 'function' ? mapSizeDescriptor.get : null;
927
+ var mapForEach = hasMap && Map.prototype.forEach;
928
+ var hasSet = typeof Set === 'function' && Set.prototype;
929
+ var setSizeDescriptor = Object.getOwnPropertyDescriptor && hasSet ? Object.getOwnPropertyDescriptor(Set.prototype, 'size') : null;
930
+ var setSize = hasSet && setSizeDescriptor && typeof setSizeDescriptor.get === 'function' ? setSizeDescriptor.get : null;
931
+ var setForEach = hasSet && Set.prototype.forEach;
932
+ var hasWeakMap = typeof WeakMap === 'function' && WeakMap.prototype;
933
+ var weakMapHas = hasWeakMap ? WeakMap.prototype.has : null;
934
+ var hasWeakSet = typeof WeakSet === 'function' && WeakSet.prototype;
935
+ var weakSetHas = hasWeakSet ? WeakSet.prototype.has : null;
936
+ var hasWeakRef = typeof WeakRef === 'function' && WeakRef.prototype;
937
+ var weakRefDeref = hasWeakRef ? WeakRef.prototype.deref : null;
938
+ var booleanValueOf = Boolean.prototype.valueOf;
939
+ var objectToString = Object.prototype.toString;
940
+ var functionToString = Function.prototype.toString;
941
+ var $match = String.prototype.match;
942
+ var $slice = String.prototype.slice;
943
+ var $replace = String.prototype.replace;
944
+ var $toUpperCase = String.prototype.toUpperCase;
945
+ var $toLowerCase = String.prototype.toLowerCase;
946
+ var $test = RegExp.prototype.test;
947
+ var $concat = Array.prototype.concat;
948
+ var $join = Array.prototype.join;
949
+ var $arrSlice = Array.prototype.slice;
950
+ var $floor = Math.floor;
951
+ var bigIntValueOf = typeof BigInt === 'function' ? BigInt.prototype.valueOf : null;
952
+ var gOPS = Object.getOwnPropertySymbols;
953
+ var symToString = typeof Symbol === 'function' && typeof Symbol.iterator === 'symbol' ? Symbol.prototype.toString : null;
954
+ var hasShammedSymbols = typeof Symbol === 'function' && typeof Symbol.iterator === 'object';
955
+ // ie, `has-tostringtag/shams
956
+ var toStringTag = typeof Symbol === 'function' && Symbol.toStringTag && (typeof Symbol.toStringTag === hasShammedSymbols ? 'object' : 'symbol')
957
+ ? Symbol.toStringTag
958
+ : null;
959
+ var isEnumerable = Object.prototype.propertyIsEnumerable;
960
+
961
+ var gPO = (typeof Reflect === 'function' ? Reflect.getPrototypeOf : Object.getPrototypeOf) || (
962
+ [].__proto__ === Array.prototype // eslint-disable-line no-proto
963
+ ? function (O) {
964
+ return O.__proto__; // eslint-disable-line no-proto
965
+ }
966
+ : null
967
+ );
968
+
969
+ function addNumericSeparator(num, str) {
970
+ if (
971
+ num === Infinity
972
+ || num === -Infinity
973
+ || num !== num
974
+ || (num && num > -1000 && num < 1000)
975
+ || $test.call(/e/, str)
976
+ ) {
977
+ return str;
978
+ }
979
+ var sepRegex = /[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;
980
+ if (typeof num === 'number') {
981
+ var int = num < 0 ? -$floor(-num) : $floor(num); // trunc(num)
982
+ if (int !== num) {
983
+ var intStr = String(int);
984
+ var dec = $slice.call(str, intStr.length + 1);
985
+ return $replace.call(intStr, sepRegex, '$&_') + '.' + $replace.call($replace.call(dec, /([0-9]{3})/g, '$&_'), /_$/, '');
986
+ }
987
+ }
988
+ return $replace.call(str, sepRegex, '$&_');
989
+ }
990
+
991
+ var utilInspect = util_inspect;
992
+ var inspectCustom = utilInspect.custom;
993
+ var inspectSymbol = isSymbol(inspectCustom) ? inspectCustom : null;
994
+
995
+ var objectInspect = function inspect_(obj, options, depth, seen) {
996
+ var opts = options || {};
997
+
998
+ if (has$3(opts, 'quoteStyle') && (opts.quoteStyle !== 'single' && opts.quoteStyle !== 'double')) {
999
+ throw new TypeError('option "quoteStyle" must be "single" or "double"');
1000
+ }
1001
+ if (
1002
+ has$3(opts, 'maxStringLength') && (typeof opts.maxStringLength === 'number'
1003
+ ? opts.maxStringLength < 0 && opts.maxStringLength !== Infinity
1004
+ : opts.maxStringLength !== null
1005
+ )
1006
+ ) {
1007
+ throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');
1008
+ }
1009
+ var customInspect = has$3(opts, 'customInspect') ? opts.customInspect : true;
1010
+ if (typeof customInspect !== 'boolean' && customInspect !== 'symbol') {
1011
+ throw new TypeError('option "customInspect", if provided, must be `true`, `false`, or `\'symbol\'`');
1012
+ }
1013
+
1014
+ if (
1015
+ has$3(opts, 'indent')
1016
+ && opts.indent !== null
1017
+ && opts.indent !== '\t'
1018
+ && !(parseInt(opts.indent, 10) === opts.indent && opts.indent > 0)
1019
+ ) {
1020
+ throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');
1021
+ }
1022
+ if (has$3(opts, 'numericSeparator') && typeof opts.numericSeparator !== 'boolean') {
1023
+ throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');
1024
+ }
1025
+ var numericSeparator = opts.numericSeparator;
1026
+
1027
+ if (typeof obj === 'undefined') {
1028
+ return 'undefined';
1029
+ }
1030
+ if (obj === null) {
1031
+ return 'null';
1032
+ }
1033
+ if (typeof obj === 'boolean') {
1034
+ return obj ? 'true' : 'false';
1035
+ }
1036
+
1037
+ if (typeof obj === 'string') {
1038
+ return inspectString(obj, opts);
1039
+ }
1040
+ if (typeof obj === 'number') {
1041
+ if (obj === 0) {
1042
+ return Infinity / obj > 0 ? '0' : '-0';
1043
+ }
1044
+ var str = String(obj);
1045
+ return numericSeparator ? addNumericSeparator(obj, str) : str;
1046
+ }
1047
+ if (typeof obj === 'bigint') {
1048
+ var bigIntStr = String(obj) + 'n';
1049
+ return numericSeparator ? addNumericSeparator(obj, bigIntStr) : bigIntStr;
1050
+ }
1051
+
1052
+ var maxDepth = typeof opts.depth === 'undefined' ? 5 : opts.depth;
1053
+ if (typeof depth === 'undefined') { depth = 0; }
1054
+ if (depth >= maxDepth && maxDepth > 0 && typeof obj === 'object') {
1055
+ return isArray$3(obj) ? '[Array]' : '[Object]';
1056
+ }
1057
+
1058
+ var indent = getIndent(opts, depth);
1059
+
1060
+ if (typeof seen === 'undefined') {
1061
+ seen = [];
1062
+ } else if (indexOf(seen, obj) >= 0) {
1063
+ return '[Circular]';
1064
+ }
1065
+
1066
+ function inspect(value, from, noIndent) {
1067
+ if (from) {
1068
+ seen = $arrSlice.call(seen);
1069
+ seen.push(from);
1070
+ }
1071
+ if (noIndent) {
1072
+ var newOpts = {
1073
+ depth: opts.depth
1074
+ };
1075
+ if (has$3(opts, 'quoteStyle')) {
1076
+ newOpts.quoteStyle = opts.quoteStyle;
1077
+ }
1078
+ return inspect_(value, newOpts, depth + 1, seen);
1079
+ }
1080
+ return inspect_(value, opts, depth + 1, seen);
1081
+ }
1082
+
1083
+ if (typeof obj === 'function' && !isRegExp$1(obj)) { // in older engines, regexes are callable
1084
+ var name = nameOf(obj);
1085
+ var keys = arrObjKeys(obj, inspect);
1086
+ return '[Function' + (name ? ': ' + name : ' (anonymous)') + ']' + (keys.length > 0 ? ' { ' + $join.call(keys, ', ') + ' }' : '');
1087
+ }
1088
+ if (isSymbol(obj)) {
1089
+ var symString = hasShammedSymbols ? $replace.call(String(obj), /^(Symbol\(.*\))_[^)]*$/, '$1') : symToString.call(obj);
1090
+ return typeof obj === 'object' && !hasShammedSymbols ? markBoxed(symString) : symString;
1091
+ }
1092
+ if (isElement(obj)) {
1093
+ var s = '<' + $toLowerCase.call(String(obj.nodeName));
1094
+ var attrs = obj.attributes || [];
1095
+ for (var i = 0; i < attrs.length; i++) {
1096
+ s += ' ' + attrs[i].name + '=' + wrapQuotes(quote(attrs[i].value), 'double', opts);
1097
+ }
1098
+ s += '>';
1099
+ if (obj.childNodes && obj.childNodes.length) { s += '...'; }
1100
+ s += '</' + $toLowerCase.call(String(obj.nodeName)) + '>';
1101
+ return s;
1102
+ }
1103
+ if (isArray$3(obj)) {
1104
+ if (obj.length === 0) { return '[]'; }
1105
+ var xs = arrObjKeys(obj, inspect);
1106
+ if (indent && !singleLineValues(xs)) {
1107
+ return '[' + indentedJoin(xs, indent) + ']';
1108
+ }
1109
+ return '[ ' + $join.call(xs, ', ') + ' ]';
1110
+ }
1111
+ if (isError(obj)) {
1112
+ var parts = arrObjKeys(obj, inspect);
1113
+ if (!('cause' in Error.prototype) && 'cause' in obj && !isEnumerable.call(obj, 'cause')) {
1114
+ return '{ [' + String(obj) + '] ' + $join.call($concat.call('[cause]: ' + inspect(obj.cause), parts), ', ') + ' }';
1115
+ }
1116
+ if (parts.length === 0) { return '[' + String(obj) + ']'; }
1117
+ return '{ [' + String(obj) + '] ' + $join.call(parts, ', ') + ' }';
1118
+ }
1119
+ if (typeof obj === 'object' && customInspect) {
1120
+ if (inspectSymbol && typeof obj[inspectSymbol] === 'function' && utilInspect) {
1121
+ return utilInspect(obj, { depth: maxDepth - depth });
1122
+ } else if (customInspect !== 'symbol' && typeof obj.inspect === 'function') {
1123
+ return obj.inspect();
1124
+ }
1125
+ }
1126
+ if (isMap(obj)) {
1127
+ var mapParts = [];
1128
+ if (mapForEach) {
1129
+ mapForEach.call(obj, function (value, key) {
1130
+ mapParts.push(inspect(key, obj, true) + ' => ' + inspect(value, obj));
1131
+ });
1132
+ }
1133
+ return collectionOf('Map', mapSize.call(obj), mapParts, indent);
1134
+ }
1135
+ if (isSet(obj)) {
1136
+ var setParts = [];
1137
+ if (setForEach) {
1138
+ setForEach.call(obj, function (value) {
1139
+ setParts.push(inspect(value, obj));
1140
+ });
1141
+ }
1142
+ return collectionOf('Set', setSize.call(obj), setParts, indent);
1143
+ }
1144
+ if (isWeakMap(obj)) {
1145
+ return weakCollectionOf('WeakMap');
1146
+ }
1147
+ if (isWeakSet(obj)) {
1148
+ return weakCollectionOf('WeakSet');
1149
+ }
1150
+ if (isWeakRef(obj)) {
1151
+ return weakCollectionOf('WeakRef');
1152
+ }
1153
+ if (isNumber(obj)) {
1154
+ return markBoxed(inspect(Number(obj)));
1155
+ }
1156
+ if (isBigInt(obj)) {
1157
+ return markBoxed(inspect(bigIntValueOf.call(obj)));
1158
+ }
1159
+ if (isBoolean(obj)) {
1160
+ return markBoxed(booleanValueOf.call(obj));
1161
+ }
1162
+ if (isString(obj)) {
1163
+ return markBoxed(inspect(String(obj)));
1164
+ }
1165
+ if (!isDate(obj) && !isRegExp$1(obj)) {
1166
+ var ys = arrObjKeys(obj, inspect);
1167
+ var isPlainObject = gPO ? gPO(obj) === Object.prototype : obj instanceof Object || obj.constructor === Object;
1168
+ var protoTag = obj instanceof Object ? '' : 'null prototype';
1169
+ var stringTag = !isPlainObject && toStringTag && Object(obj) === obj && toStringTag in obj ? $slice.call(toStr(obj), 8, -1) : protoTag ? 'Object' : '';
1170
+ var constructorTag = isPlainObject || typeof obj.constructor !== 'function' ? '' : obj.constructor.name ? obj.constructor.name + ' ' : '';
1171
+ var tag = constructorTag + (stringTag || protoTag ? '[' + $join.call($concat.call([], stringTag || [], protoTag || []), ': ') + '] ' : '');
1172
+ if (ys.length === 0) { return tag + '{}'; }
1173
+ if (indent) {
1174
+ return tag + '{' + indentedJoin(ys, indent) + '}';
1175
+ }
1176
+ return tag + '{ ' + $join.call(ys, ', ') + ' }';
1177
+ }
1178
+ return String(obj);
1179
+ };
1180
+
1181
+ function wrapQuotes(s, defaultStyle, opts) {
1182
+ var quoteChar = (opts.quoteStyle || defaultStyle) === 'double' ? '"' : "'";
1183
+ return quoteChar + s + quoteChar;
1184
+ }
1185
+
1186
+ function quote(s) {
1187
+ return $replace.call(String(s), /"/g, '&quot;');
1188
+ }
1189
+
1190
+ function isArray$3(obj) { return toStr(obj) === '[object Array]' && (!toStringTag || !(typeof obj === 'object' && toStringTag in obj)); }
1191
+ function isDate(obj) { return toStr(obj) === '[object Date]' && (!toStringTag || !(typeof obj === 'object' && toStringTag in obj)); }
1192
+ function isRegExp$1(obj) { return toStr(obj) === '[object RegExp]' && (!toStringTag || !(typeof obj === 'object' && toStringTag in obj)); }
1193
+ function isError(obj) { return toStr(obj) === '[object Error]' && (!toStringTag || !(typeof obj === 'object' && toStringTag in obj)); }
1194
+ function isString(obj) { return toStr(obj) === '[object String]' && (!toStringTag || !(typeof obj === 'object' && toStringTag in obj)); }
1195
+ function isNumber(obj) { return toStr(obj) === '[object Number]' && (!toStringTag || !(typeof obj === 'object' && toStringTag in obj)); }
1196
+ function isBoolean(obj) { return toStr(obj) === '[object Boolean]' && (!toStringTag || !(typeof obj === 'object' && toStringTag in obj)); }
1197
+
1198
+ // Symbol and BigInt do have Symbol.toStringTag by spec, so that can't be used to eliminate false positives
1199
+ function isSymbol(obj) {
1200
+ if (hasShammedSymbols) {
1201
+ return obj && typeof obj === 'object' && obj instanceof Symbol;
1202
+ }
1203
+ if (typeof obj === 'symbol') {
1204
+ return true;
1205
+ }
1206
+ if (!obj || typeof obj !== 'object' || !symToString) {
1207
+ return false;
1208
+ }
1209
+ try {
1210
+ symToString.call(obj);
1211
+ return true;
1212
+ } catch (e) {}
1213
+ return false;
1214
+ }
1215
+
1216
+ function isBigInt(obj) {
1217
+ if (!obj || typeof obj !== 'object' || !bigIntValueOf) {
1218
+ return false;
1219
+ }
1220
+ try {
1221
+ bigIntValueOf.call(obj);
1222
+ return true;
1223
+ } catch (e) {}
1224
+ return false;
1225
+ }
1226
+
1227
+ var hasOwn = Object.prototype.hasOwnProperty || function (key) { return key in this; };
1228
+ function has$3(obj, key) {
1229
+ return hasOwn.call(obj, key);
1230
+ }
1231
+
1232
+ function toStr(obj) {
1233
+ return objectToString.call(obj);
1234
+ }
1235
+
1236
+ function nameOf(f) {
1237
+ if (f.name) { return f.name; }
1238
+ var m = $match.call(functionToString.call(f), /^function\s*([\w$]+)/);
1239
+ if (m) { return m[1]; }
1240
+ return null;
1241
+ }
1242
+
1243
+ function indexOf(xs, x) {
1244
+ if (xs.indexOf) { return xs.indexOf(x); }
1245
+ for (var i = 0, l = xs.length; i < l; i++) {
1246
+ if (xs[i] === x) { return i; }
1247
+ }
1248
+ return -1;
1249
+ }
1250
+
1251
+ function isMap(x) {
1252
+ if (!mapSize || !x || typeof x !== 'object') {
1253
+ return false;
1254
+ }
1255
+ try {
1256
+ mapSize.call(x);
1257
+ try {
1258
+ setSize.call(x);
1259
+ } catch (s) {
1260
+ return true;
1261
+ }
1262
+ return x instanceof Map; // core-js workaround, pre-v2.5.0
1263
+ } catch (e) {}
1264
+ return false;
1265
+ }
1266
+
1267
+ function isWeakMap(x) {
1268
+ if (!weakMapHas || !x || typeof x !== 'object') {
1269
+ return false;
1270
+ }
1271
+ try {
1272
+ weakMapHas.call(x, weakMapHas);
1273
+ try {
1274
+ weakSetHas.call(x, weakSetHas);
1275
+ } catch (s) {
1276
+ return true;
1277
+ }
1278
+ return x instanceof WeakMap; // core-js workaround, pre-v2.5.0
1279
+ } catch (e) {}
1280
+ return false;
1281
+ }
1282
+
1283
+ function isWeakRef(x) {
1284
+ if (!weakRefDeref || !x || typeof x !== 'object') {
1285
+ return false;
1286
+ }
1287
+ try {
1288
+ weakRefDeref.call(x);
1289
+ return true;
1290
+ } catch (e) {}
1291
+ return false;
1292
+ }
1293
+
1294
+ function isSet(x) {
1295
+ if (!setSize || !x || typeof x !== 'object') {
1296
+ return false;
1297
+ }
1298
+ try {
1299
+ setSize.call(x);
1300
+ try {
1301
+ mapSize.call(x);
1302
+ } catch (m) {
1303
+ return true;
1304
+ }
1305
+ return x instanceof Set; // core-js workaround, pre-v2.5.0
1306
+ } catch (e) {}
1307
+ return false;
1308
+ }
1309
+
1310
+ function isWeakSet(x) {
1311
+ if (!weakSetHas || !x || typeof x !== 'object') {
1312
+ return false;
1313
+ }
1314
+ try {
1315
+ weakSetHas.call(x, weakSetHas);
1316
+ try {
1317
+ weakMapHas.call(x, weakMapHas);
1318
+ } catch (s) {
1319
+ return true;
1320
+ }
1321
+ return x instanceof WeakSet; // core-js workaround, pre-v2.5.0
1322
+ } catch (e) {}
1323
+ return false;
1324
+ }
1325
+
1326
+ function isElement(x) {
1327
+ if (!x || typeof x !== 'object') { return false; }
1328
+ if (typeof HTMLElement !== 'undefined' && x instanceof HTMLElement) {
1329
+ return true;
1330
+ }
1331
+ return typeof x.nodeName === 'string' && typeof x.getAttribute === 'function';
1332
+ }
1333
+
1334
+ function inspectString(str, opts) {
1335
+ if (str.length > opts.maxStringLength) {
1336
+ var remaining = str.length - opts.maxStringLength;
1337
+ var trailer = '... ' + remaining + ' more character' + (remaining > 1 ? 's' : '');
1338
+ return inspectString($slice.call(str, 0, opts.maxStringLength), opts) + trailer;
1339
+ }
1340
+ // eslint-disable-next-line no-control-regex
1341
+ var s = $replace.call($replace.call(str, /(['\\])/g, '\\$1'), /[\x00-\x1f]/g, lowbyte);
1342
+ return wrapQuotes(s, 'single', opts);
1343
+ }
1344
+
1345
+ function lowbyte(c) {
1346
+ var n = c.charCodeAt(0);
1347
+ var x = {
1348
+ 8: 'b',
1349
+ 9: 't',
1350
+ 10: 'n',
1351
+ 12: 'f',
1352
+ 13: 'r'
1353
+ }[n];
1354
+ if (x) { return '\\' + x; }
1355
+ return '\\x' + (n < 0x10 ? '0' : '') + $toUpperCase.call(n.toString(16));
1356
+ }
1357
+
1358
+ function markBoxed(str) {
1359
+ return 'Object(' + str + ')';
1360
+ }
1361
+
1362
+ function weakCollectionOf(type) {
1363
+ return type + ' { ? }';
1364
+ }
1365
+
1366
+ function collectionOf(type, size, entries, indent) {
1367
+ var joinedEntries = indent ? indentedJoin(entries, indent) : $join.call(entries, ', ');
1368
+ return type + ' (' + size + ') {' + joinedEntries + '}';
1369
+ }
1370
+
1371
+ function singleLineValues(xs) {
1372
+ for (var i = 0; i < xs.length; i++) {
1373
+ if (indexOf(xs[i], '\n') >= 0) {
1374
+ return false;
1375
+ }
1376
+ }
1377
+ return true;
1378
+ }
1379
+
1380
+ function getIndent(opts, depth) {
1381
+ var baseIndent;
1382
+ if (opts.indent === '\t') {
1383
+ baseIndent = '\t';
1384
+ } else if (typeof opts.indent === 'number' && opts.indent > 0) {
1385
+ baseIndent = $join.call(Array(opts.indent + 1), ' ');
1386
+ } else {
1387
+ return null;
1388
+ }
1389
+ return {
1390
+ base: baseIndent,
1391
+ prev: $join.call(Array(depth + 1), baseIndent)
1392
+ };
1393
+ }
1394
+
1395
+ function indentedJoin(xs, indent) {
1396
+ if (xs.length === 0) { return ''; }
1397
+ var lineJoiner = '\n' + indent.prev + indent.base;
1398
+ return lineJoiner + $join.call(xs, ',' + lineJoiner) + '\n' + indent.prev;
1399
+ }
1400
+
1401
+ function arrObjKeys(obj, inspect) {
1402
+ var isArr = isArray$3(obj);
1403
+ var xs = [];
1404
+ if (isArr) {
1405
+ xs.length = obj.length;
1406
+ for (var i = 0; i < obj.length; i++) {
1407
+ xs[i] = has$3(obj, i) ? inspect(obj[i], obj) : '';
1408
+ }
1409
+ }
1410
+ var syms = typeof gOPS === 'function' ? gOPS(obj) : [];
1411
+ var symMap;
1412
+ if (hasShammedSymbols) {
1413
+ symMap = {};
1414
+ for (var k = 0; k < syms.length; k++) {
1415
+ symMap['$' + syms[k]] = syms[k];
1416
+ }
1417
+ }
1418
+
1419
+ for (var key in obj) { // eslint-disable-line no-restricted-syntax
1420
+ if (!has$3(obj, key)) { continue; } // eslint-disable-line no-restricted-syntax, no-continue
1421
+ if (isArr && String(Number(key)) === key && key < obj.length) { continue; } // eslint-disable-line no-restricted-syntax, no-continue
1422
+ if (hasShammedSymbols && symMap['$' + key] instanceof Symbol) {
1423
+ // this is to prevent shammed Symbols, which are stored as strings, from being included in the string key section
1424
+ continue; // eslint-disable-line no-restricted-syntax, no-continue
1425
+ } else if ($test.call(/[^\w$]/, key)) {
1426
+ xs.push(inspect(key, obj) + ': ' + inspect(obj[key], obj));
1427
+ } else {
1428
+ xs.push(key + ': ' + inspect(obj[key], obj));
1429
+ }
1430
+ }
1431
+ if (typeof gOPS === 'function') {
1432
+ for (var j = 0; j < syms.length; j++) {
1433
+ if (isEnumerable.call(obj, syms[j])) {
1434
+ xs.push('[' + inspect(syms[j]) + ']: ' + inspect(obj[syms[j]], obj));
1435
+ }
1436
+ }
1437
+ }
1438
+ return xs;
1439
+ }
1440
+
1441
+ var GetIntrinsic = getIntrinsic;
1442
+ var callBound = callBound$1;
1443
+ var inspect = objectInspect;
1444
+
1445
+ var $TypeError = GetIntrinsic('%TypeError%');
1446
+ var $WeakMap = GetIntrinsic('%WeakMap%', true);
1447
+ var $Map = GetIntrinsic('%Map%', true);
1448
+
1449
+ var $weakMapGet = callBound('WeakMap.prototype.get', true);
1450
+ var $weakMapSet = callBound('WeakMap.prototype.set', true);
1451
+ var $weakMapHas = callBound('WeakMap.prototype.has', true);
1452
+ var $mapGet = callBound('Map.prototype.get', true);
1453
+ var $mapSet = callBound('Map.prototype.set', true);
1454
+ var $mapHas = callBound('Map.prototype.has', true);
1455
+
1456
+ /*
1457
+ * This function traverses the list returning the node corresponding to the
1458
+ * given key.
1459
+ *
1460
+ * That node is also moved to the head of the list, so that if it's accessed
1461
+ * again we don't need to traverse the whole list. By doing so, all the recently
1462
+ * used nodes can be accessed relatively quickly.
1463
+ */
1464
+ var listGetNode = function (list, key) { // eslint-disable-line consistent-return
1465
+ for (var prev = list, curr; (curr = prev.next) !== null; prev = curr) {
1466
+ if (curr.key === key) {
1467
+ prev.next = curr.next;
1468
+ curr.next = list.next;
1469
+ list.next = curr; // eslint-disable-line no-param-reassign
1470
+ return curr;
1471
+ }
1472
+ }
1473
+ };
1474
+
1475
+ var listGet = function (objects, key) {
1476
+ var node = listGetNode(objects, key);
1477
+ return node && node.value;
1478
+ };
1479
+ var listSet = function (objects, key, value) {
1480
+ var node = listGetNode(objects, key);
1481
+ if (node) {
1482
+ node.value = value;
1483
+ } else {
1484
+ // Prepend the new node to the beginning of the list
1485
+ objects.next = { // eslint-disable-line no-param-reassign
1486
+ key: key,
1487
+ next: objects.next,
1488
+ value: value
1489
+ };
1490
+ }
1491
+ };
1492
+ var listHas = function (objects, key) {
1493
+ return !!listGetNode(objects, key);
1494
+ };
1495
+
1496
+ var sideChannel = function getSideChannel() {
1497
+ var $wm;
1498
+ var $m;
1499
+ var $o;
1500
+ var channel = {
1501
+ assert: function (key) {
1502
+ if (!channel.has(key)) {
1503
+ throw new $TypeError('Side channel does not contain ' + inspect(key));
1504
+ }
1505
+ },
1506
+ get: function (key) { // eslint-disable-line consistent-return
1507
+ if ($WeakMap && key && (typeof key === 'object' || typeof key === 'function')) {
1508
+ if ($wm) {
1509
+ return $weakMapGet($wm, key);
1510
+ }
1511
+ } else if ($Map) {
1512
+ if ($m) {
1513
+ return $mapGet($m, key);
1514
+ }
1515
+ } else {
1516
+ if ($o) { // eslint-disable-line no-lonely-if
1517
+ return listGet($o, key);
1518
+ }
1519
+ }
1520
+ },
1521
+ has: function (key) {
1522
+ if ($WeakMap && key && (typeof key === 'object' || typeof key === 'function')) {
1523
+ if ($wm) {
1524
+ return $weakMapHas($wm, key);
1525
+ }
1526
+ } else if ($Map) {
1527
+ if ($m) {
1528
+ return $mapHas($m, key);
1529
+ }
1530
+ } else {
1531
+ if ($o) { // eslint-disable-line no-lonely-if
1532
+ return listHas($o, key);
1533
+ }
1534
+ }
1535
+ return false;
1536
+ },
1537
+ set: function (key, value) {
1538
+ if ($WeakMap && key && (typeof key === 'object' || typeof key === 'function')) {
1539
+ if (!$wm) {
1540
+ $wm = new $WeakMap();
1541
+ }
1542
+ $weakMapSet($wm, key, value);
1543
+ } else if ($Map) {
1544
+ if (!$m) {
1545
+ $m = new $Map();
1546
+ }
1547
+ $mapSet($m, key, value);
1548
+ } else {
1549
+ if (!$o) {
1550
+ /*
1551
+ * Initialize the linked list as an empty node, so that we don't have
1552
+ * to special-case handling of the first node: we can always refer to
1553
+ * it as (previous node).next, instead of something like (list).head
1554
+ */
1555
+ $o = { key: {}, next: null };
1556
+ }
1557
+ listSet($o, key, value);
1558
+ }
1559
+ }
1560
+ };
1561
+ return channel;
1562
+ };
1563
+
1564
+ var replace = String.prototype.replace;
1565
+ var percentTwenties = /%20/g;
1566
+
1567
+ var Format = {
1568
+ RFC1738: 'RFC1738',
1569
+ RFC3986: 'RFC3986'
1570
+ };
1571
+
1572
+ var formats$3 = {
1573
+ 'default': Format.RFC3986,
1574
+ formatters: {
1575
+ RFC1738: function (value) {
1576
+ return replace.call(value, percentTwenties, '+');
1577
+ },
1578
+ RFC3986: function (value) {
1579
+ return String(value);
1580
+ }
1581
+ },
1582
+ RFC1738: Format.RFC1738,
1583
+ RFC3986: Format.RFC3986
1584
+ };
1585
+
1586
+ var formats$2 = formats$3;
1587
+
1588
+ var has$2 = Object.prototype.hasOwnProperty;
1589
+ var isArray$2 = Array.isArray;
1590
+
1591
+ var hexTable = (function () {
1592
+ var array = [];
1593
+ for (var i = 0; i < 256; ++i) {
1594
+ array.push('%' + ((i < 16 ? '0' : '') + i.toString(16)).toUpperCase());
1595
+ }
1596
+
1597
+ return array;
1598
+ }());
1599
+
1600
+ var compactQueue = function compactQueue(queue) {
1601
+ while (queue.length > 1) {
1602
+ var item = queue.pop();
1603
+ var obj = item.obj[item.prop];
1604
+
1605
+ if (isArray$2(obj)) {
1606
+ var compacted = [];
1607
+
1608
+ for (var j = 0; j < obj.length; ++j) {
1609
+ if (typeof obj[j] !== 'undefined') {
1610
+ compacted.push(obj[j]);
1611
+ }
1612
+ }
1613
+
1614
+ item.obj[item.prop] = compacted;
1615
+ }
1616
+ }
1617
+ };
1618
+
1619
+ var arrayToObject = function arrayToObject(source, options) {
1620
+ var obj = options && options.plainObjects ? Object.create(null) : {};
1621
+ for (var i = 0; i < source.length; ++i) {
1622
+ if (typeof source[i] !== 'undefined') {
1623
+ obj[i] = source[i];
1624
+ }
1625
+ }
1626
+
1627
+ return obj;
1628
+ };
1629
+
1630
+ var merge = function merge(target, source, options) {
1631
+ /* eslint no-param-reassign: 0 */
1632
+ if (!source) {
1633
+ return target;
1634
+ }
1635
+
1636
+ if (typeof source !== 'object') {
1637
+ if (isArray$2(target)) {
1638
+ target.push(source);
1639
+ } else if (target && typeof target === 'object') {
1640
+ if ((options && (options.plainObjects || options.allowPrototypes)) || !has$2.call(Object.prototype, source)) {
1641
+ target[source] = true;
1642
+ }
1643
+ } else {
1644
+ return [target, source];
1645
+ }
1646
+
1647
+ return target;
1648
+ }
1649
+
1650
+ if (!target || typeof target !== 'object') {
1651
+ return [target].concat(source);
1652
+ }
1653
+
1654
+ var mergeTarget = target;
1655
+ if (isArray$2(target) && !isArray$2(source)) {
1656
+ mergeTarget = arrayToObject(target, options);
1657
+ }
1658
+
1659
+ if (isArray$2(target) && isArray$2(source)) {
1660
+ source.forEach(function (item, i) {
1661
+ if (has$2.call(target, i)) {
1662
+ var targetItem = target[i];
1663
+ if (targetItem && typeof targetItem === 'object' && item && typeof item === 'object') {
1664
+ target[i] = merge(targetItem, item, options);
1665
+ } else {
1666
+ target.push(item);
1667
+ }
1668
+ } else {
1669
+ target[i] = item;
1670
+ }
1671
+ });
1672
+ return target;
1673
+ }
1674
+
1675
+ return Object.keys(source).reduce(function (acc, key) {
1676
+ var value = source[key];
1677
+
1678
+ if (has$2.call(acc, key)) {
1679
+ acc[key] = merge(acc[key], value, options);
1680
+ } else {
1681
+ acc[key] = value;
1682
+ }
1683
+ return acc;
1684
+ }, mergeTarget);
1685
+ };
1686
+
1687
+ var assign = function assignSingleSource(target, source) {
1688
+ return Object.keys(source).reduce(function (acc, key) {
1689
+ acc[key] = source[key];
1690
+ return acc;
1691
+ }, target);
1692
+ };
1693
+
1694
+ var decode = function (str, decoder, charset) {
1695
+ var strWithoutPlus = str.replace(/\+/g, ' ');
1696
+ if (charset === 'iso-8859-1') {
1697
+ // unescape never throws, no try...catch needed:
1698
+ return strWithoutPlus.replace(/%[0-9a-f]{2}/gi, unescape);
1699
+ }
1700
+ // utf-8
1701
+ try {
1702
+ return decodeURIComponent(strWithoutPlus);
1703
+ } catch (e) {
1704
+ return strWithoutPlus;
1705
+ }
1706
+ };
1707
+
1708
+ var encode = function encode(str, defaultEncoder, charset, kind, format) {
1709
+ // This code was originally written by Brian White (mscdex) for the io.js core querystring library.
1710
+ // It has been adapted here for stricter adherence to RFC 3986
1711
+ if (str.length === 0) {
1712
+ return str;
1713
+ }
1714
+
1715
+ var string = str;
1716
+ if (typeof str === 'symbol') {
1717
+ string = Symbol.prototype.toString.call(str);
1718
+ } else if (typeof str !== 'string') {
1719
+ string = String(str);
1720
+ }
1721
+
1722
+ if (charset === 'iso-8859-1') {
1723
+ return escape(string).replace(/%u[0-9a-f]{4}/gi, function ($0) {
1724
+ return '%26%23' + parseInt($0.slice(2), 16) + '%3B';
1725
+ });
1726
+ }
1727
+
1728
+ var out = '';
1729
+ for (var i = 0; i < string.length; ++i) {
1730
+ var c = string.charCodeAt(i);
1731
+
1732
+ if (
1733
+ c === 0x2D // -
1734
+ || c === 0x2E // .
1735
+ || c === 0x5F // _
1736
+ || c === 0x7E // ~
1737
+ || (c >= 0x30 && c <= 0x39) // 0-9
1738
+ || (c >= 0x41 && c <= 0x5A) // a-z
1739
+ || (c >= 0x61 && c <= 0x7A) // A-Z
1740
+ || (format === formats$2.RFC1738 && (c === 0x28 || c === 0x29)) // ( )
1741
+ ) {
1742
+ out += string.charAt(i);
1743
+ continue;
1744
+ }
1745
+
1746
+ if (c < 0x80) {
1747
+ out = out + hexTable[c];
1748
+ continue;
1749
+ }
1750
+
1751
+ if (c < 0x800) {
1752
+ out = out + (hexTable[0xC0 | (c >> 6)] + hexTable[0x80 | (c & 0x3F)]);
1753
+ continue;
1754
+ }
1755
+
1756
+ if (c < 0xD800 || c >= 0xE000) {
1757
+ out = out + (hexTable[0xE0 | (c >> 12)] + hexTable[0x80 | ((c >> 6) & 0x3F)] + hexTable[0x80 | (c & 0x3F)]);
1758
+ continue;
1759
+ }
1760
+
1761
+ i += 1;
1762
+ c = 0x10000 + (((c & 0x3FF) << 10) | (string.charCodeAt(i) & 0x3FF));
1763
+ /* eslint operator-linebreak: [2, "before"] */
1764
+ out += hexTable[0xF0 | (c >> 18)]
1765
+ + hexTable[0x80 | ((c >> 12) & 0x3F)]
1766
+ + hexTable[0x80 | ((c >> 6) & 0x3F)]
1767
+ + hexTable[0x80 | (c & 0x3F)];
1768
+ }
1769
+
1770
+ return out;
1771
+ };
1772
+
1773
+ var compact = function compact(value) {
1774
+ var queue = [{ obj: { o: value }, prop: 'o' }];
1775
+ var refs = [];
1776
+
1777
+ for (var i = 0; i < queue.length; ++i) {
1778
+ var item = queue[i];
1779
+ var obj = item.obj[item.prop];
1780
+
1781
+ var keys = Object.keys(obj);
1782
+ for (var j = 0; j < keys.length; ++j) {
1783
+ var key = keys[j];
1784
+ var val = obj[key];
1785
+ if (typeof val === 'object' && val !== null && refs.indexOf(val) === -1) {
1786
+ queue.push({ obj: obj, prop: key });
1787
+ refs.push(val);
1788
+ }
1789
+ }
1790
+ }
1791
+
1792
+ compactQueue(queue);
1793
+
1794
+ return value;
1795
+ };
1796
+
1797
+ var isRegExp = function isRegExp(obj) {
1798
+ return Object.prototype.toString.call(obj) === '[object RegExp]';
1799
+ };
1800
+
1801
+ var isBuffer = function isBuffer(obj) {
1802
+ if (!obj || typeof obj !== 'object') {
1803
+ return false;
1804
+ }
1805
+
1806
+ return !!(obj.constructor && obj.constructor.isBuffer && obj.constructor.isBuffer(obj));
1807
+ };
1808
+
1809
+ var combine = function combine(a, b) {
1810
+ return [].concat(a, b);
1811
+ };
1812
+
1813
+ var maybeMap = function maybeMap(val, fn) {
1814
+ if (isArray$2(val)) {
1815
+ var mapped = [];
1816
+ for (var i = 0; i < val.length; i += 1) {
1817
+ mapped.push(fn(val[i]));
1818
+ }
1819
+ return mapped;
1820
+ }
1821
+ return fn(val);
1822
+ };
1823
+
1824
+ var utils$2 = {
1825
+ arrayToObject: arrayToObject,
1826
+ assign: assign,
1827
+ combine: combine,
1828
+ compact: compact,
1829
+ decode: decode,
1830
+ encode: encode,
1831
+ isBuffer: isBuffer,
1832
+ isRegExp: isRegExp,
1833
+ maybeMap: maybeMap,
1834
+ merge: merge
1835
+ };
1836
+
1837
+ var getSideChannel = sideChannel;
1838
+ var utils$1 = utils$2;
1839
+ var formats$1 = formats$3;
1840
+ var has$1 = Object.prototype.hasOwnProperty;
1841
+
1842
+ var arrayPrefixGenerators = {
1843
+ brackets: function brackets(prefix) {
1844
+ return prefix + '[]';
1845
+ },
1846
+ comma: 'comma',
1847
+ indices: function indices(prefix, key) {
1848
+ return prefix + '[' + key + ']';
1849
+ },
1850
+ repeat: function repeat(prefix) {
1851
+ return prefix;
1852
+ }
1853
+ };
1854
+
1855
+ var isArray$1 = Array.isArray;
1856
+ var split = String.prototype.split;
1857
+ var push = Array.prototype.push;
1858
+ var pushToArray = function (arr, valueOrArray) {
1859
+ push.apply(arr, isArray$1(valueOrArray) ? valueOrArray : [valueOrArray]);
1860
+ };
1861
+
1862
+ var toISO = Date.prototype.toISOString;
1863
+
1864
+ var defaultFormat = formats$1['default'];
1865
+ var defaults$1 = {
1866
+ addQueryPrefix: false,
1867
+ allowDots: false,
1868
+ charset: 'utf-8',
1869
+ charsetSentinel: false,
1870
+ delimiter: '&',
1871
+ encode: true,
1872
+ encoder: utils$1.encode,
1873
+ encodeValuesOnly: false,
1874
+ format: defaultFormat,
1875
+ formatter: formats$1.formatters[defaultFormat],
1876
+ // deprecated
1877
+ indices: false,
1878
+ serializeDate: function serializeDate(date) {
1879
+ return toISO.call(date);
1880
+ },
1881
+ skipNulls: false,
1882
+ strictNullHandling: false
1883
+ };
1884
+
1885
+ var isNonNullishPrimitive = function isNonNullishPrimitive(v) {
1886
+ return typeof v === 'string'
1887
+ || typeof v === 'number'
1888
+ || typeof v === 'boolean'
1889
+ || typeof v === 'symbol'
1890
+ || typeof v === 'bigint';
1891
+ };
1892
+
1893
+ var sentinel = {};
1894
+
1895
+ var stringify$1 = function stringify(
1896
+ object,
1897
+ prefix,
1898
+ generateArrayPrefix,
1899
+ commaRoundTrip,
1900
+ strictNullHandling,
1901
+ skipNulls,
1902
+ encoder,
1903
+ filter,
1904
+ sort,
1905
+ allowDots,
1906
+ serializeDate,
1907
+ format,
1908
+ formatter,
1909
+ encodeValuesOnly,
1910
+ charset,
1911
+ sideChannel
1912
+ ) {
1913
+ var obj = object;
1914
+
1915
+ var tmpSc = sideChannel;
1916
+ var step = 0;
1917
+ var findFlag = false;
1918
+ while ((tmpSc = tmpSc.get(sentinel)) !== void undefined && !findFlag) {
1919
+ // Where object last appeared in the ref tree
1920
+ var pos = tmpSc.get(object);
1921
+ step += 1;
1922
+ if (typeof pos !== 'undefined') {
1923
+ if (pos === step) {
1924
+ throw new RangeError('Cyclic object value');
1925
+ } else {
1926
+ findFlag = true; // Break while
1927
+ }
1928
+ }
1929
+ if (typeof tmpSc.get(sentinel) === 'undefined') {
1930
+ step = 0;
1931
+ }
1932
+ }
1933
+
1934
+ if (typeof filter === 'function') {
1935
+ obj = filter(prefix, obj);
1936
+ } else if (obj instanceof Date) {
1937
+ obj = serializeDate(obj);
1938
+ } else if (generateArrayPrefix === 'comma' && isArray$1(obj)) {
1939
+ obj = utils$1.maybeMap(obj, function (value) {
1940
+ if (value instanceof Date) {
1941
+ return serializeDate(value);
1942
+ }
1943
+ return value;
1944
+ });
1945
+ }
1946
+
1947
+ if (obj === null) {
1948
+ if (strictNullHandling) {
1949
+ return encoder && !encodeValuesOnly ? encoder(prefix, defaults$1.encoder, charset, 'key', format) : prefix;
1950
+ }
1951
+
1952
+ obj = '';
1953
+ }
1954
+
1955
+ if (isNonNullishPrimitive(obj) || utils$1.isBuffer(obj)) {
1956
+ if (encoder) {
1957
+ var keyValue = encodeValuesOnly ? prefix : encoder(prefix, defaults$1.encoder, charset, 'key', format);
1958
+ if (generateArrayPrefix === 'comma' && encodeValuesOnly) {
1959
+ var valuesArray = split.call(String(obj), ',');
1960
+ var valuesJoined = '';
1961
+ for (var i = 0; i < valuesArray.length; ++i) {
1962
+ valuesJoined += (i === 0 ? '' : ',') + formatter(encoder(valuesArray[i], defaults$1.encoder, charset, 'value', format));
1963
+ }
1964
+ return [formatter(keyValue) + (commaRoundTrip && isArray$1(obj) && valuesArray.length === 1 ? '[]' : '') + '=' + valuesJoined];
1965
+ }
1966
+ return [formatter(keyValue) + '=' + formatter(encoder(obj, defaults$1.encoder, charset, 'value', format))];
1967
+ }
1968
+ return [formatter(prefix) + '=' + formatter(String(obj))];
1969
+ }
1970
+
1971
+ var values = [];
1972
+
1973
+ if (typeof obj === 'undefined') {
1974
+ return values;
1975
+ }
1976
+
1977
+ var objKeys;
1978
+ if (generateArrayPrefix === 'comma' && isArray$1(obj)) {
1979
+ // we need to join elements in
1980
+ objKeys = [{ value: obj.length > 0 ? obj.join(',') || null : void undefined }];
1981
+ } else if (isArray$1(filter)) {
1982
+ objKeys = filter;
1983
+ } else {
1984
+ var keys = Object.keys(obj);
1985
+ objKeys = sort ? keys.sort(sort) : keys;
1986
+ }
1987
+
1988
+ var adjustedPrefix = commaRoundTrip && isArray$1(obj) && obj.length === 1 ? prefix + '[]' : prefix;
1989
+
1990
+ for (var j = 0; j < objKeys.length; ++j) {
1991
+ var key = objKeys[j];
1992
+ var value = typeof key === 'object' && typeof key.value !== 'undefined' ? key.value : obj[key];
1993
+
1994
+ if (skipNulls && value === null) {
1995
+ continue;
1996
+ }
1997
+
1998
+ var keyPrefix = isArray$1(obj)
1999
+ ? typeof generateArrayPrefix === 'function' ? generateArrayPrefix(adjustedPrefix, key) : adjustedPrefix
2000
+ : adjustedPrefix + (allowDots ? '.' + key : '[' + key + ']');
2001
+
2002
+ sideChannel.set(object, step);
2003
+ var valueSideChannel = getSideChannel();
2004
+ valueSideChannel.set(sentinel, sideChannel);
2005
+ pushToArray(values, stringify(
2006
+ value,
2007
+ keyPrefix,
2008
+ generateArrayPrefix,
2009
+ commaRoundTrip,
2010
+ strictNullHandling,
2011
+ skipNulls,
2012
+ encoder,
2013
+ filter,
2014
+ sort,
2015
+ allowDots,
2016
+ serializeDate,
2017
+ format,
2018
+ formatter,
2019
+ encodeValuesOnly,
2020
+ charset,
2021
+ valueSideChannel
2022
+ ));
2023
+ }
2024
+
2025
+ return values;
2026
+ };
2027
+
2028
+ var normalizeStringifyOptions = function normalizeStringifyOptions(opts) {
2029
+ if (!opts) {
2030
+ return defaults$1;
2031
+ }
2032
+
2033
+ if (opts.encoder !== null && typeof opts.encoder !== 'undefined' && typeof opts.encoder !== 'function') {
2034
+ throw new TypeError('Encoder has to be a function.');
2035
+ }
2036
+
2037
+ var charset = opts.charset || defaults$1.charset;
2038
+ if (typeof opts.charset !== 'undefined' && opts.charset !== 'utf-8' && opts.charset !== 'iso-8859-1') {
2039
+ throw new TypeError('The charset option must be either utf-8, iso-8859-1, or undefined');
2040
+ }
2041
+
2042
+ var format = formats$1['default'];
2043
+ if (typeof opts.format !== 'undefined') {
2044
+ if (!has$1.call(formats$1.formatters, opts.format)) {
2045
+ throw new TypeError('Unknown format option provided.');
2046
+ }
2047
+ format = opts.format;
2048
+ }
2049
+ var formatter = formats$1.formatters[format];
2050
+
2051
+ var filter = defaults$1.filter;
2052
+ if (typeof opts.filter === 'function' || isArray$1(opts.filter)) {
2053
+ filter = opts.filter;
2054
+ }
2055
+
2056
+ return {
2057
+ addQueryPrefix: typeof opts.addQueryPrefix === 'boolean' ? opts.addQueryPrefix : defaults$1.addQueryPrefix,
2058
+ allowDots: typeof opts.allowDots === 'undefined' ? defaults$1.allowDots : !!opts.allowDots,
2059
+ charset: charset,
2060
+ charsetSentinel: typeof opts.charsetSentinel === 'boolean' ? opts.charsetSentinel : defaults$1.charsetSentinel,
2061
+ delimiter: typeof opts.delimiter === 'undefined' ? defaults$1.delimiter : opts.delimiter,
2062
+ encode: typeof opts.encode === 'boolean' ? opts.encode : defaults$1.encode,
2063
+ encoder: typeof opts.encoder === 'function' ? opts.encoder : defaults$1.encoder,
2064
+ encodeValuesOnly: typeof opts.encodeValuesOnly === 'boolean' ? opts.encodeValuesOnly : defaults$1.encodeValuesOnly,
2065
+ filter: filter,
2066
+ format: format,
2067
+ formatter: formatter,
2068
+ serializeDate: typeof opts.serializeDate === 'function' ? opts.serializeDate : defaults$1.serializeDate,
2069
+ skipNulls: typeof opts.skipNulls === 'boolean' ? opts.skipNulls : defaults$1.skipNulls,
2070
+ sort: typeof opts.sort === 'function' ? opts.sort : null,
2071
+ strictNullHandling: typeof opts.strictNullHandling === 'boolean' ? opts.strictNullHandling : defaults$1.strictNullHandling
2072
+ };
2073
+ };
2074
+
2075
+ var stringify_1 = function (object, opts) {
2076
+ var obj = object;
2077
+ var options = normalizeStringifyOptions(opts);
2078
+
2079
+ var objKeys;
2080
+ var filter;
2081
+
2082
+ if (typeof options.filter === 'function') {
2083
+ filter = options.filter;
2084
+ obj = filter('', obj);
2085
+ } else if (isArray$1(options.filter)) {
2086
+ filter = options.filter;
2087
+ objKeys = filter;
2088
+ }
2089
+
2090
+ var keys = [];
2091
+
2092
+ if (typeof obj !== 'object' || obj === null) {
2093
+ return '';
2094
+ }
2095
+
2096
+ var arrayFormat;
2097
+ if (opts && opts.arrayFormat in arrayPrefixGenerators) {
2098
+ arrayFormat = opts.arrayFormat;
2099
+ } else if (opts && 'indices' in opts) {
2100
+ arrayFormat = opts.indices ? 'indices' : 'repeat';
2101
+ } else {
2102
+ arrayFormat = 'indices';
2103
+ }
2104
+
2105
+ var generateArrayPrefix = arrayPrefixGenerators[arrayFormat];
2106
+ if (opts && 'commaRoundTrip' in opts && typeof opts.commaRoundTrip !== 'boolean') {
2107
+ throw new TypeError('`commaRoundTrip` must be a boolean, or absent');
2108
+ }
2109
+ var commaRoundTrip = generateArrayPrefix === 'comma' && opts && opts.commaRoundTrip;
2110
+
2111
+ if (!objKeys) {
2112
+ objKeys = Object.keys(obj);
2113
+ }
2114
+
2115
+ if (options.sort) {
2116
+ objKeys.sort(options.sort);
2117
+ }
2118
+
2119
+ var sideChannel = getSideChannel();
2120
+ for (var i = 0; i < objKeys.length; ++i) {
2121
+ var key = objKeys[i];
2122
+
2123
+ if (options.skipNulls && obj[key] === null) {
2124
+ continue;
2125
+ }
2126
+ pushToArray(keys, stringify$1(
2127
+ obj[key],
2128
+ key,
2129
+ generateArrayPrefix,
2130
+ commaRoundTrip,
2131
+ options.strictNullHandling,
2132
+ options.skipNulls,
2133
+ options.encode ? options.encoder : null,
2134
+ options.filter,
2135
+ options.sort,
2136
+ options.allowDots,
2137
+ options.serializeDate,
2138
+ options.format,
2139
+ options.formatter,
2140
+ options.encodeValuesOnly,
2141
+ options.charset,
2142
+ sideChannel
2143
+ ));
2144
+ }
2145
+
2146
+ var joined = keys.join(options.delimiter);
2147
+ var prefix = options.addQueryPrefix === true ? '?' : '';
2148
+
2149
+ if (options.charsetSentinel) {
2150
+ if (options.charset === 'iso-8859-1') {
2151
+ // encodeURIComponent('&#10003;'), the "numeric entity" representation of a checkmark
2152
+ prefix += 'utf8=%26%2310003%3B&';
2153
+ } else {
2154
+ // encodeURIComponent('✓')
2155
+ prefix += 'utf8=%E2%9C%93&';
2156
+ }
2157
+ }
2158
+
2159
+ return joined.length > 0 ? prefix + joined : '';
2160
+ };
2161
+
2162
+ var utils = utils$2;
2163
+
2164
+ var has = Object.prototype.hasOwnProperty;
2165
+ var isArray = Array.isArray;
2166
+
2167
+ var defaults = {
2168
+ allowDots: false,
2169
+ allowPrototypes: false,
2170
+ allowSparse: false,
2171
+ arrayLimit: 20,
2172
+ charset: 'utf-8',
2173
+ charsetSentinel: false,
2174
+ comma: false,
2175
+ decoder: utils.decode,
2176
+ delimiter: '&',
2177
+ depth: 5,
2178
+ ignoreQueryPrefix: false,
2179
+ interpretNumericEntities: false,
2180
+ parameterLimit: 1000,
2181
+ parseArrays: true,
2182
+ plainObjects: false,
2183
+ strictNullHandling: false
2184
+ };
2185
+
2186
+ var interpretNumericEntities = function (str) {
2187
+ return str.replace(/&#(\d+);/g, function ($0, numberStr) {
2188
+ return String.fromCharCode(parseInt(numberStr, 10));
2189
+ });
2190
+ };
2191
+
2192
+ var parseArrayValue = function (val, options) {
2193
+ if (val && typeof val === 'string' && options.comma && val.indexOf(',') > -1) {
2194
+ return val.split(',');
2195
+ }
2196
+
2197
+ return val;
2198
+ };
2199
+
2200
+ // This is what browsers will submit when the ✓ character occurs in an
2201
+ // application/x-www-form-urlencoded body and the encoding of the page containing
2202
+ // the form is iso-8859-1, or when the submitted form has an accept-charset
2203
+ // attribute of iso-8859-1. Presumably also with other charsets that do not contain
2204
+ // the ✓ character, such as us-ascii.
2205
+ var isoSentinel = 'utf8=%26%2310003%3B'; // encodeURIComponent('&#10003;')
2206
+
2207
+ // These are the percent-encoded utf-8 octets representing a checkmark, indicating that the request actually is utf-8 encoded.
2208
+ var charsetSentinel = 'utf8=%E2%9C%93'; // encodeURIComponent('✓')
2209
+
2210
+ var parseValues = function parseQueryStringValues(str, options) {
2211
+ var obj = {};
2212
+ var cleanStr = options.ignoreQueryPrefix ? str.replace(/^\?/, '') : str;
2213
+ var limit = options.parameterLimit === Infinity ? undefined : options.parameterLimit;
2214
+ var parts = cleanStr.split(options.delimiter, limit);
2215
+ var skipIndex = -1; // Keep track of where the utf8 sentinel was found
2216
+ var i;
2217
+
2218
+ var charset = options.charset;
2219
+ if (options.charsetSentinel) {
2220
+ for (i = 0; i < parts.length; ++i) {
2221
+ if (parts[i].indexOf('utf8=') === 0) {
2222
+ if (parts[i] === charsetSentinel) {
2223
+ charset = 'utf-8';
2224
+ } else if (parts[i] === isoSentinel) {
2225
+ charset = 'iso-8859-1';
2226
+ }
2227
+ skipIndex = i;
2228
+ i = parts.length; // The eslint settings do not allow break;
2229
+ }
2230
+ }
2231
+ }
2232
+
2233
+ for (i = 0; i < parts.length; ++i) {
2234
+ if (i === skipIndex) {
2235
+ continue;
2236
+ }
2237
+ var part = parts[i];
2238
+
2239
+ var bracketEqualsPos = part.indexOf(']=');
2240
+ var pos = bracketEqualsPos === -1 ? part.indexOf('=') : bracketEqualsPos + 1;
2241
+
2242
+ var key, val;
2243
+ if (pos === -1) {
2244
+ key = options.decoder(part, defaults.decoder, charset, 'key');
2245
+ val = options.strictNullHandling ? null : '';
2246
+ } else {
2247
+ key = options.decoder(part.slice(0, pos), defaults.decoder, charset, 'key');
2248
+ val = utils.maybeMap(
2249
+ parseArrayValue(part.slice(pos + 1), options),
2250
+ function (encodedVal) {
2251
+ return options.decoder(encodedVal, defaults.decoder, charset, 'value');
2252
+ }
2253
+ );
2254
+ }
2255
+
2256
+ if (val && options.interpretNumericEntities && charset === 'iso-8859-1') {
2257
+ val = interpretNumericEntities(val);
2258
+ }
2259
+
2260
+ if (part.indexOf('[]=') > -1) {
2261
+ val = isArray(val) ? [val] : val;
2262
+ }
2263
+
2264
+ if (has.call(obj, key)) {
2265
+ obj[key] = utils.combine(obj[key], val);
2266
+ } else {
2267
+ obj[key] = val;
2268
+ }
2269
+ }
2270
+
2271
+ return obj;
2272
+ };
2273
+
2274
+ var parseObject = function (chain, val, options, valuesParsed) {
2275
+ var leaf = valuesParsed ? val : parseArrayValue(val, options);
2276
+
2277
+ for (var i = chain.length - 1; i >= 0; --i) {
2278
+ var obj;
2279
+ var root = chain[i];
2280
+
2281
+ if (root === '[]' && options.parseArrays) {
2282
+ obj = [].concat(leaf);
2283
+ } else {
2284
+ obj = options.plainObjects ? Object.create(null) : {};
2285
+ var cleanRoot = root.charAt(0) === '[' && root.charAt(root.length - 1) === ']' ? root.slice(1, -1) : root;
2286
+ var index = parseInt(cleanRoot, 10);
2287
+ if (!options.parseArrays && cleanRoot === '') {
2288
+ obj = { 0: leaf };
2289
+ } else if (
2290
+ !isNaN(index)
2291
+ && root !== cleanRoot
2292
+ && String(index) === cleanRoot
2293
+ && index >= 0
2294
+ && (options.parseArrays && index <= options.arrayLimit)
2295
+ ) {
2296
+ obj = [];
2297
+ obj[index] = leaf;
2298
+ } else if (cleanRoot !== '__proto__') {
2299
+ obj[cleanRoot] = leaf;
2300
+ }
2301
+ }
2302
+
2303
+ leaf = obj;
2304
+ }
2305
+
2306
+ return leaf;
2307
+ };
2308
+
2309
+ var parseKeys = function parseQueryStringKeys(givenKey, val, options, valuesParsed) {
2310
+ if (!givenKey) {
2311
+ return;
2312
+ }
2313
+
2314
+ // Transform dot notation to bracket notation
2315
+ var key = options.allowDots ? givenKey.replace(/\.([^.[]+)/g, '[$1]') : givenKey;
2316
+
2317
+ // The regex chunks
2318
+
2319
+ var brackets = /(\[[^[\]]*])/;
2320
+ var child = /(\[[^[\]]*])/g;
2321
+
2322
+ // Get the parent
2323
+
2324
+ var segment = options.depth > 0 && brackets.exec(key);
2325
+ var parent = segment ? key.slice(0, segment.index) : key;
2326
+
2327
+ // Stash the parent if it exists
2328
+
2329
+ var keys = [];
2330
+ if (parent) {
2331
+ // If we aren't using plain objects, optionally prefix keys that would overwrite object prototype properties
2332
+ if (!options.plainObjects && has.call(Object.prototype, parent)) {
2333
+ if (!options.allowPrototypes) {
2334
+ return;
2335
+ }
2336
+ }
2337
+
2338
+ keys.push(parent);
2339
+ }
2340
+
2341
+ // Loop through children appending to the array until we hit depth
2342
+
2343
+ var i = 0;
2344
+ while (options.depth > 0 && (segment = child.exec(key)) !== null && i < options.depth) {
2345
+ i += 1;
2346
+ if (!options.plainObjects && has.call(Object.prototype, segment[1].slice(1, -1))) {
2347
+ if (!options.allowPrototypes) {
2348
+ return;
2349
+ }
2350
+ }
2351
+ keys.push(segment[1]);
2352
+ }
2353
+
2354
+ // If there's a remainder, just add whatever is left
2355
+
2356
+ if (segment) {
2357
+ keys.push('[' + key.slice(segment.index) + ']');
2358
+ }
2359
+
2360
+ return parseObject(keys, val, options, valuesParsed);
2361
+ };
2362
+
2363
+ var normalizeParseOptions = function normalizeParseOptions(opts) {
2364
+ if (!opts) {
2365
+ return defaults;
2366
+ }
2367
+
2368
+ if (opts.decoder !== null && opts.decoder !== undefined && typeof opts.decoder !== 'function') {
2369
+ throw new TypeError('Decoder has to be a function.');
2370
+ }
2371
+
2372
+ if (typeof opts.charset !== 'undefined' && opts.charset !== 'utf-8' && opts.charset !== 'iso-8859-1') {
2373
+ throw new TypeError('The charset option must be either utf-8, iso-8859-1, or undefined');
2374
+ }
2375
+ var charset = typeof opts.charset === 'undefined' ? defaults.charset : opts.charset;
2376
+
2377
+ return {
2378
+ allowDots: typeof opts.allowDots === 'undefined' ? defaults.allowDots : !!opts.allowDots,
2379
+ allowPrototypes: typeof opts.allowPrototypes === 'boolean' ? opts.allowPrototypes : defaults.allowPrototypes,
2380
+ allowSparse: typeof opts.allowSparse === 'boolean' ? opts.allowSparse : defaults.allowSparse,
2381
+ arrayLimit: typeof opts.arrayLimit === 'number' ? opts.arrayLimit : defaults.arrayLimit,
2382
+ charset: charset,
2383
+ charsetSentinel: typeof opts.charsetSentinel === 'boolean' ? opts.charsetSentinel : defaults.charsetSentinel,
2384
+ comma: typeof opts.comma === 'boolean' ? opts.comma : defaults.comma,
2385
+ decoder: typeof opts.decoder === 'function' ? opts.decoder : defaults.decoder,
2386
+ delimiter: typeof opts.delimiter === 'string' || utils.isRegExp(opts.delimiter) ? opts.delimiter : defaults.delimiter,
2387
+ // eslint-disable-next-line no-implicit-coercion, no-extra-parens
2388
+ depth: (typeof opts.depth === 'number' || opts.depth === false) ? +opts.depth : defaults.depth,
2389
+ ignoreQueryPrefix: opts.ignoreQueryPrefix === true,
2390
+ interpretNumericEntities: typeof opts.interpretNumericEntities === 'boolean' ? opts.interpretNumericEntities : defaults.interpretNumericEntities,
2391
+ parameterLimit: typeof opts.parameterLimit === 'number' ? opts.parameterLimit : defaults.parameterLimit,
2392
+ parseArrays: opts.parseArrays !== false,
2393
+ plainObjects: typeof opts.plainObjects === 'boolean' ? opts.plainObjects : defaults.plainObjects,
2394
+ strictNullHandling: typeof opts.strictNullHandling === 'boolean' ? opts.strictNullHandling : defaults.strictNullHandling
2395
+ };
2396
+ };
2397
+
2398
+ var parse$1 = function (str, opts) {
2399
+ var options = normalizeParseOptions(opts);
2400
+
2401
+ if (str === '' || str === null || typeof str === 'undefined') {
2402
+ return options.plainObjects ? Object.create(null) : {};
2403
+ }
2404
+
2405
+ var tempObj = typeof str === 'string' ? parseValues(str, options) : str;
2406
+ var obj = options.plainObjects ? Object.create(null) : {};
2407
+
2408
+ // Iterate over the keys and setup the new object
2409
+
2410
+ var keys = Object.keys(tempObj);
2411
+ for (var i = 0; i < keys.length; ++i) {
2412
+ var key = keys[i];
2413
+ var newObj = parseKeys(key, tempObj[key], options, typeof str === 'string');
2414
+ obj = utils.merge(obj, newObj, options);
2415
+ }
2416
+
2417
+ if (options.allowSparse === true) {
2418
+ return obj;
2419
+ }
2420
+
2421
+ return utils.compact(obj);
2422
+ };
2423
+
2424
+ var stringify = stringify_1;
2425
+ var parse = parse$1;
2426
+ var formats = formats$3;
2427
+
2428
+ var lib = {
2429
+ formats: formats,
2430
+ parse: parse,
2431
+ stringify: stringify
2432
+ };
2433
+
2434
+ var generatePath = function generatePath(path, params) {
2435
+ return Object.entries(params).reduce(function (acc, _ref) {
2436
+ var _ref2 = _slicedToArray(_ref, 2),
2437
+ name = _ref2[0],
2438
+ value = _ref2[1];
2439
+ return acc.replace(":".concat(name), value);
2440
+ }, path);
2441
+ };
2442
+
2443
+ var _excluded = ["url"];
2444
+ var list = function list(_ref) {
2445
+ var url = _ref.url,
2446
+ params = _objectWithoutProperties(_ref, _excluded);
2447
+ return axios.get(url, {
2448
+ params: params,
2449
+ paramsSerializer: function paramsSerializer(params) {
2450
+ return lib.stringify(params, {
2451
+ arrayFormat: "brackets"
2452
+ });
2453
+ }
2454
+ });
2455
+ };
2456
+ var create = function create(_ref2) {
2457
+ var id = _ref2.id,
2458
+ url = _ref2.url;
2459
+ return axios.post(url, {
2460
+ createTemplate: {
2461
+ id: id
2462
+ }
2463
+ });
2464
+ };
2465
+ var fetch = function fetch(resourceId, url) {
2466
+ return axios.get(generatePath(url, {
2467
+ resourceId: resourceId
2468
+ }));
2469
+ };
2470
+ var update = function update(_ref3) {
2471
+ var resourceId = _ref3.resourceId,
2472
+ payload = _ref3.payload,
2473
+ url = _ref3.url;
2474
+ return axios.put(generatePath(url, {
2475
+ resourceId: resourceId
2476
+ }), payload);
2477
+ };
2478
+ var templatesApi = {
2479
+ list: list,
2480
+ create: create,
2481
+ update: update,
2482
+ fetch: fetch
2483
+ };
2484
+
2485
+ var QUERY_KEYS = {
2486
+ TEMPLATES: "templates",
2487
+ TEMPLATE_TAGS: "template-tags"
2488
+ };
2489
+
2490
+ var queryClient = new QueryClient({
2491
+ defaultOptions: {
2492
+ queries: {
2493
+ staleTime: DEFAULT_STALE_TIME
2494
+ }
2495
+ }
2496
+ });
2497
+
2498
+ function ownKeys$1(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
2499
+ function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$1(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$1(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
2500
+ var useFetchTemplates = function useFetchTemplates(_ref) {
2501
+ var url = _ref.url,
2502
+ searchTerm = _ref.searchTerm,
2503
+ category = _ref.category;
2504
+ return useInfiniteQuery([QUERY_KEYS.TEMPLATES, searchTerm, category], function (_ref2) {
2505
+ var _ref2$pageParam = _ref2.pageParam,
2506
+ pageParam = _ref2$pageParam === void 0 ? 1 : _ref2$pageParam;
2507
+ return templatesApi.list({
2508
+ pageNumber: pageParam,
2509
+ searchTerm: searchTerm,
2510
+ category: category,
2511
+ url: url
2512
+ });
2513
+ }, {
2514
+ getNextPageParam: function getNextPageParam(lastPage) {
2515
+ return lastPage.hasNextPage ? lastPage.pageNumber + 1 : undefined;
2516
+ },
2517
+ select: function select(data) {
2518
+ var templates = data.pages.flatMap(prop("templates"));
2519
+ var lastPage = data.pages[data.pages.length - 1];
2520
+ return {
2521
+ templates: templates,
2522
+ hasNextPage: lastPage.hasNextPage,
2523
+ pageNumber: lastPage.pageNumber,
2524
+ tags: lastPage.tags,
2525
+ templatesCount: lastPage.templatesCount
2526
+ };
2527
+ }
2528
+ });
2529
+ };
2530
+ var useCreateTemplate = function useCreateTemplate(_ref3, options) {
2531
+ var resourceQueryKey = _ref3.resourceQueryKey;
2532
+ return useMutation(templatesApi.create, _objectSpread$1(_objectSpread$1({}, options), {}, {
2533
+ onSuccess: function onSuccess() {
2534
+ queryClient.invalidateQueries([resourceQueryKey]);
2535
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
2536
+ args[_key] = arguments[_key];
2537
+ }
2538
+ options === null || options === void 0 ? void 0 : options.onSuccess.apply(options, args);
2539
+ }
2540
+ }));
2541
+ };
2542
+
2543
+ var BlankCard = function BlankCard(_ref) {
2544
+ var Icon = _ref.icon,
2545
+ title = _ref.title,
2546
+ description = _ref.description,
2547
+ _ref$onClick = _ref.onClick,
2548
+ onClick = _ref$onClick === void 0 ? noop : _ref$onClick,
2549
+ _ref$disabled = _ref.disabled,
2550
+ disabled = _ref$disabled === void 0 ? false : _ref$disabled;
2551
+ return /*#__PURE__*/React.createElement("div", {
2552
+ className: "neeto-ui-rounded-lg neeto-ui-bg-white hover:neeto-ui-bg-white neeto-ui-border-primary-500 outline-none flex cursor-pointer flex-col items-center justify-center border border-dashed p-6 transition-all duration-300 ease-in-out hover:border-solid focus:border-solid",
2553
+ "data-cy": "start-from-scratch-button",
2554
+ tabIndex: 0,
2555
+ onClick: !disabled ? onClick : noop
2556
+ }, /*#__PURE__*/React.createElement("div", {
2557
+ className: "neeto-ui-text-primary-500 mb-4"
2558
+ }, /*#__PURE__*/React.createElement(Icon, {
2559
+ size: 40
2560
+ })), /*#__PURE__*/React.createElement(Typography, {
2561
+ className: "text-center",
2562
+ lineHeight: "normal",
2563
+ style: "h5",
2564
+ weight: "semibold"
2565
+ }, title), /*#__PURE__*/React.createElement(Typography, {
2566
+ className: "neeto-ui-text-gray-600 text-center",
2567
+ lineHeight: "leading-4",
2568
+ style: "body3"
2569
+ }, description));
2570
+ };
2571
+
2572
+ var ButtonLoader = function ButtonLoader() {
2573
+ return /*#__PURE__*/React.createElement("div", {
2574
+ role: "status"
2575
+ }, /*#__PURE__*/React.createElement("svg", {
2576
+ "aria-hidden": "true",
2577
+ className: "neeto-ui-text-gray-400 inline h-5 w-5 animate-spin",
2578
+ fill: "none",
2579
+ viewBox: "0 0 100 101",
2580
+ xmlns: "http://www.w3.org/2000/svg"
2581
+ }, /*#__PURE__*/React.createElement("path", {
2582
+ d: "M100 50.59c0 27.615-22.386 50.001-50 50.001s-50-22.386-50-50 22.386-50 50-50 50 22.386 50 50zm-90.919 0c0 22.6 18.32 40.92 40.919 40.92 22.599 0 40.919-18.32 40.919-40.92 0-22.598-18.32-40.918-40.919-40.918-22.599 0-40.919 18.32-40.919 40.919z",
2583
+ fill: "currentColor"
2584
+ }), /*#__PURE__*/React.createElement("path", {
2585
+ d: "M93.968 39.04c2.425-.636 3.894-3.128 3.04-5.486A50 50 0 0041.735 1.279c-2.474.414-3.922 2.919-3.285 5.344.637 2.426 3.12 3.849 5.6 3.484a40.916 40.916 0 0144.131 25.769c.902 2.34 3.361 3.802 5.787 3.165z",
2586
+ fill: "#3642df"
2587
+ })));
2588
+ };
2589
+
2590
+ var Menu = Dropdown.Menu,
2591
+ MenuItem = Dropdown.MenuItem;
2592
+ var Card = function Card(_ref) {
2593
+ var template = _ref.template,
2594
+ onClick = _ref.onClick,
2595
+ afterCreate = _ref.afterCreate,
2596
+ resourceQueryKey = _ref.resourceQueryKey,
2597
+ url = _ref.url;
2598
+ var _useTranslation = useTranslation(),
2599
+ t = _useTranslation.t;
2600
+ var _useCreateTemplate = useCreateTemplate({
2601
+ resourceQueryKey: resourceQueryKey
2602
+ }),
2603
+ createTemplate = _useCreateTemplate.mutate,
2604
+ isCreating = _useCreateTemplate.isLoading;
2605
+ var handleCreateTemplate = function handleCreateTemplate(e, templateId) {
2606
+ e.stopPropagation();
2607
+ createTemplate({
2608
+ id: templateId,
2609
+ url: url
2610
+ }, {
2611
+ onSuccess: function onSuccess(response) {
2612
+ return afterCreate(response);
2613
+ }
2614
+ });
2615
+ };
2616
+ return /*#__PURE__*/React.createElement("div", {
2617
+ className: "neeto-template neeto-ui-bg-white outline-none neeto-ui-shadow-sm hover:neeto-ui-border-gray-400 focus:neeto-ui-border-gray-500 neeto-ui-rounded-lg flex cursor-pointer flex-col overflow-hidden border transition-colors duration-300 ease-in-out",
2618
+ "data-cy": "template-card",
2619
+ tabIndex: 0,
2620
+ onClick: onClick
2621
+ }, /*#__PURE__*/React.createElement("div", {
2622
+ className: "neeto-template__header"
2623
+ }, /*#__PURE__*/React.createElement("img", {
2624
+ className: "neeto-template__image",
2625
+ "data-cy": "template-thumbnail-image",
2626
+ src: template.imageUrl || "https://d2v7kzglnr2dnh.cloudfront.net/images/neetoForm/default-form-template.svg"
2627
+ })), /*#__PURE__*/React.createElement("div", {
2628
+ className: "neeto-template__description neeto-ui-bg-white flex items-center justify-between gap-2 rounded-b-lg p-2 py-1.5"
2629
+ }, /*#__PURE__*/React.createElement(Typography, {
2630
+ className: "neeto-ui-text-gray-800 line-clamp-2",
2631
+ "data-cy": "template-card-title",
2632
+ lineHeight: "normal",
2633
+ style: "body2"
2634
+ }, template.title), /*#__PURE__*/React.createElement(Dropdown, {
2635
+ buttonProps: {
2636
+ className: "flex-shrink-0",
2637
+ size: "small"
2638
+ },
2639
+ buttonStyle: "text",
2640
+ icon: MenuHorizontal,
2641
+ onClick: function onClick(e) {
2642
+ return e.stopPropagation();
2643
+ }
2644
+ }, /*#__PURE__*/React.createElement(Menu, null, /*#__PURE__*/React.createElement(MenuItem.Button, {
2645
+ "data-cy": "use-this-template-button",
2646
+ onClick: function onClick(e) {
2647
+ return handleCreateTemplate(e, template.id);
2648
+ }
2649
+ }, t("neetoTemplate.templates.editTemplate"), isCreating && /*#__PURE__*/React.createElement(ButtonLoader, null)), /*#__PURE__*/React.createElement(MenuItem.Button, {
2650
+ "data-cy": "template-preview-button"
2651
+ }, t("neetoTemplate.templates.preview"))))));
2652
+ };
2653
+
2654
+ var CategoryItem = function CategoryItem(_ref) {
2655
+ var label = _ref.label,
2656
+ count = _ref.count,
2657
+ isActive = _ref.isActive,
2658
+ setCurrentCategory = _ref.setCurrentCategory;
2659
+ return /*#__PURE__*/React.createElement("button", {
2660
+ "data-cy": "category-".concat(joinHyphenCase(label)),
2661
+ tabIndex: 0,
2662
+ className: classnames("neeto-ui-rounded-lg outline-none flex w-full items-center justify-between gap-2 border border-solid px-3 py-2 text-sm font-medium leading-4 transition-all duration-300 ease-in-out", {
2663
+ "neeto-ui-text-gray-700 hover:neeto-ui-bg-gray-200 focus:neeto-ui-bg-gray-200 border-transparent": !isActive,
2664
+ "neeto-ui-text-gray-800 neeto-ui-bg-white neeto-ui-border-gray-300 focus:neeto-ui-border-gray-500": isActive
2665
+ }),
2666
+ onClick: setCurrentCategory
2667
+ }, /*#__PURE__*/React.createElement("span", null, label), /*#__PURE__*/React.createElement("span", null, count));
2668
+ };
2669
+
2670
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
2671
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
2672
+ var List = function List(_ref) {
2673
+ var setCurrentScreen = _ref.setCurrentScreen,
2674
+ setSelectedTemplate = _ref.setSelectedTemplate,
2675
+ onCreate = _ref.onCreate,
2676
+ isCreating = _ref.isCreating,
2677
+ afterCreate = _ref.afterCreate,
2678
+ entity = _ref.entity,
2679
+ resourceQueryKey = _ref.resourceQueryKey,
2680
+ url = _ref.url;
2681
+ var _useTranslation = useTranslation(),
2682
+ t = _useTranslation.t;
2683
+ var _useState = useState(DEFAULT_CATEGORY),
2684
+ _useState2 = _slicedToArray(_useState, 2),
2685
+ currentCategory = _useState2[0],
2686
+ _setCurrentCategory = _useState2[1];
2687
+ var _useState3 = useState(""),
2688
+ _useState4 = _slicedToArray(_useState3, 2),
2689
+ searchTerm = _useState4[0],
2690
+ setSearchTerm = _useState4[1];
2691
+ var debouncedSearch = useDebounce(searchTerm).trim();
2692
+ var _useFetchTemplates = useFetchTemplates({
2693
+ url: url,
2694
+ searchTerm: debouncedSearch,
2695
+ category: currentCategory
2696
+ }),
2697
+ _useFetchTemplates$ha = _useFetchTemplates.hasNextPage,
2698
+ hasNextPage = _useFetchTemplates$ha === void 0 ? false : _useFetchTemplates$ha,
2699
+ fetchNextPage = _useFetchTemplates.fetchNextPage,
2700
+ isTemplatesLoading = _useFetchTemplates.isLoading,
2701
+ data = _useFetchTemplates.data;
2702
+ var _useInfiniteScroll = useInfiniteScroll({
2703
+ loading: isTemplatesLoading,
2704
+ hasNextPage: hasNextPage,
2705
+ onLoadMore: fetchNextPage,
2706
+ rootMargin: "0px 0px 700px 0px",
2707
+ delayInMs: INFINITE_SCROLL_DELAY
2708
+ }),
2709
+ _useInfiniteScroll2 = _slicedToArray(_useInfiniteScroll, 2),
2710
+ sentryRef = _useInfiniteScroll2[0],
2711
+ rootRef = _useInfiniteScroll2[1].rootRef;
2712
+ var handleCardClick = function handleCardClick(template) {
2713
+ setCurrentScreen(TEMPLATE_SCREENS.PREVIEW);
2714
+ setSelectedTemplate(template);
2715
+ };
2716
+ if (isTemplatesLoading) {
2717
+ return /*#__PURE__*/React.createElement(PageLoader, null);
2718
+ }
2719
+ var tags = data.tags,
2720
+ templates = data.templates,
2721
+ templatesCount = data.templatesCount;
2722
+ var categories = [_objectSpread(_objectSpread({}, DEFAULT_CATEGORY), {}, {
2723
+ count: templatesCount
2724
+ })].concat(_toConsumableArray(tags));
2725
+ return /*#__PURE__*/React.createElement("div", {
2726
+ className: "neeto-ui-bg-gray-100 gap-18 relative flex min-h-full items-start p-16"
2727
+ }, /*#__PURE__*/React.createElement("div", {
2728
+ className: "top-18 sticky left-0 w-80 flex-shrink-0 space-y-8"
2729
+ }, /*#__PURE__*/React.createElement("div", {
2730
+ className: "space-y-4"
2731
+ }, /*#__PURE__*/React.createElement("div", {
2732
+ className: "space-y-1"
2733
+ }, /*#__PURE__*/React.createElement(Typography, {
2734
+ "data-cy": "create-new-form-title",
2735
+ style: "h2",
2736
+ weight: "semibold"
2737
+ }, t("neetoTemplate.templates.createNewEntity", {
2738
+ entity: entity
2739
+ })), /*#__PURE__*/React.createElement(Typography, {
2740
+ lineHeight: "normal",
2741
+ style: "body2"
2742
+ }, t("neetoTemplate.templates.description"))), /*#__PURE__*/React.createElement(Input, {
2743
+ placeholder: t("neetoTemplate.templates.search"),
2744
+ prefix: /*#__PURE__*/React.createElement(Search, null),
2745
+ type: "search",
2746
+ value: searchTerm,
2747
+ onChange: function onChange(_ref2) {
2748
+ var value = _ref2.target.value;
2749
+ return setSearchTerm(value);
2750
+ }
2751
+ })), /*#__PURE__*/React.createElement("div", {
2752
+ className: "space-y-3"
2753
+ }, /*#__PURE__*/React.createElement(Typography, {
2754
+ className: "uppercase",
2755
+ "data-cy": "template-categories-label",
2756
+ style: "h6"
2757
+ }, t("neetoTemplate.templates.categories")), /*#__PURE__*/React.createElement("div", {
2758
+ className: "space-y-2"
2759
+ }, categories.map(function (_ref3) {
2760
+ var id = _ref3.id,
2761
+ name = _ref3.name,
2762
+ count = _ref3.count;
2763
+ return /*#__PURE__*/React.createElement(CategoryItem, {
2764
+ count: count,
2765
+ isActive: currentCategory.id === id,
2766
+ key: id,
2767
+ label: name,
2768
+ setCurrentCategory: function setCurrentCategory() {
2769
+ return _setCurrentCategory({
2770
+ id: id,
2771
+ name: name
2772
+ });
2773
+ }
2774
+ });
2775
+ })))), /*#__PURE__*/React.createElement(Scrollable, {
2776
+ ref: rootRef
2777
+ }, /*#__PURE__*/React.createElement("div", {
2778
+ className: "flex-grow space-y-6"
2779
+ }, /*#__PURE__*/React.createElement("div", {
2780
+ className: "grid grid-cols-2 gap-6 md:grid-cols-3 2xl:grid-cols-4"
2781
+ }, /*#__PURE__*/React.createElement(BlankCard, {
2782
+ description: t("neetoTemplate.templates.blankCard.description"),
2783
+ disabled: isCreating,
2784
+ icon: isCreating ? Spinner : CustomSVG,
2785
+ title: t("neetoTemplate.templates.blankCard.title"),
2786
+ onClick: onCreate
2787
+ }), templates === null || templates === void 0 ? void 0 : templates.map(function (template, index) {
2788
+ return /*#__PURE__*/React.createElement(Card, {
2789
+ key: index,
2790
+ template: template,
2791
+ afterCreate: afterCreate,
2792
+ resourceQueryKey: resourceQueryKey,
2793
+ url: url,
2794
+ onClick: function onClick() {
2795
+ return handleCardClick(template);
2796
+ }
2797
+ });
2798
+ })), hasNextPage && /*#__PURE__*/React.createElement("div", {
2799
+ className: "my-10 text-center",
2800
+ ref: sentryRef
2801
+ }, /*#__PURE__*/React.createElement(Spinner, null)))));
2802
+ };
2803
+
2804
+ var Preview = function Preview(_ref) {
2805
+ var selectedTemplate = _ref.selectedTemplate,
2806
+ setCurrentScreen = _ref.setCurrentScreen,
2807
+ afterCreate = _ref.afterCreate,
2808
+ resourceQueryKey = _ref.resourceQueryKey,
2809
+ url = _ref.url;
2810
+ var _useTranslation = useTranslation(),
2811
+ t = _useTranslation.t;
2812
+ var _useCreateTemplate = useCreateTemplate({
2813
+ resourceQueryKey: resourceQueryKey
2814
+ }),
2815
+ createTemplate = _useCreateTemplate.mutate,
2816
+ isCreating = _useCreateTemplate.isLoading;
2817
+ var handleCreateTemplate = function handleCreateTemplate() {
2818
+ createTemplate({
2819
+ id: selectedTemplate.id,
2820
+ url: url
2821
+ }, {
2822
+ onSuccess: function onSuccess(response) {
2823
+ return afterCreate(response);
2824
+ }
2825
+ });
2826
+ };
2827
+ var title = selectedTemplate.title,
2828
+ publicLinkId = selectedTemplate.publicLinkId;
2829
+ return /*#__PURE__*/React.createElement("div", {
2830
+ className: "m-auto flex h-full w-full max-w-5xl flex-col space-y-8 py-20"
2831
+ }, /*#__PURE__*/React.createElement("div", {
2832
+ className: "flex items-center justify-between gap-6"
2833
+ }, /*#__PURE__*/React.createElement("div", {
2834
+ className: "flex items-center gap-2"
2835
+ }, /*#__PURE__*/React.createElement(Button, {
2836
+ "data-cy": "preview-template-back-button",
2837
+ icon: LeftArrow,
2838
+ style: "text",
2839
+ onClick: function onClick() {
2840
+ return setCurrentScreen(TEMPLATE_SCREENS.LIST);
2841
+ }
2842
+ }), /*#__PURE__*/React.createElement(Typography, {
2843
+ className: "leading-none",
2844
+ "data-cy": "preview-template-title",
2845
+ style: "h2",
2846
+ weight: "semibold"
2847
+ }, title)), /*#__PURE__*/React.createElement(Button, {
2848
+ "data-cy": "preview-use-template-button",
2849
+ label: t("neetoTemplate.v2.form.templates.editTemplate"),
2850
+ loading: isCreating,
2851
+ onClick: handleCreateTemplate
2852
+ })), /*#__PURE__*/React.createElement("div", {
2853
+ className: "nf-share-preview neeto-ui-rounded-sm sticky top-10"
2854
+ }, /*#__PURE__*/React.createElement("iframe", {
2855
+ className: "w-full flex-1 shadow-inner",
2856
+ "data-cy": "iframe-id",
2857
+ src: buildUrl(PREVIEW_URL, {
2858
+ publicLinkId: publicLinkId
2859
+ })
2860
+ })));
2861
+ };
2862
+
2863
+ var CreateTemplateModal = function CreateTemplateModal(_ref) {
2864
+ var isOpen = _ref.isOpen,
2865
+ onClose = _ref.onClose,
2866
+ isCreating = _ref.isCreating,
2867
+ entity = _ref.entity,
2868
+ resourceQueryKey = _ref.resourceQueryKey,
2869
+ _ref$onCreate = _ref.onCreate,
2870
+ onCreate = _ref$onCreate === void 0 ? noop : _ref$onCreate,
2871
+ _ref$afterCreate = _ref.afterCreate,
2872
+ afterCreate = _ref$afterCreate === void 0 ? noop : _ref$afterCreate,
2873
+ _ref$url = _ref.url,
2874
+ url = _ref$url === void 0 ? "" : _ref$url;
2875
+ var _useState = useState(TEMPLATE_SCREENS.LIST),
2876
+ _useState2 = _slicedToArray(_useState, 2),
2877
+ currentScreen = _useState2[0],
2878
+ setCurrentScreen = _useState2[1];
2879
+ var _useState3 = useState({}),
2880
+ _useState4 = _slicedToArray(_useState3, 2),
2881
+ selectedTemplate = _useState4[0],
2882
+ setSelectedTemplate = _useState4[1];
2883
+ var onModalClose = function onModalClose() {
2884
+ onClose();
2885
+ setTimeout(function () {
2886
+ setCurrentScreen(TEMPLATE_SCREENS.LIST);
2887
+ }, 300); //To accommodate the animation duration.
2888
+ };
2889
+
2890
+ return /*#__PURE__*/React.createElement(Modal, {
2891
+ className: "h-screen w-screen overflow-y-auto",
2892
+ isOpen: isOpen,
2893
+ size: "fullScreen",
2894
+ onClose: onModalClose
2895
+ }, currentScreen === TEMPLATE_SCREENS.LIST ? /*#__PURE__*/React.createElement(List, {
2896
+ setCurrentScreen: setCurrentScreen,
2897
+ setSelectedTemplate: setSelectedTemplate,
2898
+ isCreating: isCreating,
2899
+ afterCreate: afterCreate,
2900
+ onCreate: onCreate,
2901
+ entity: entity,
2902
+ resourceQueryKey: resourceQueryKey,
2903
+ url: url
2904
+ }) : /*#__PURE__*/React.createElement(Preview, {
2905
+ selectedTemplate: selectedTemplate,
2906
+ setCurrentScreen: setCurrentScreen,
2907
+ afterCreate: afterCreate,
2908
+ resourceQueryKey: resourceQueryKey,
2909
+ url: url
2910
+ }));
2911
+ };
2912
+
2913
+ export { CreateTemplateModal as Templates };
2914
+ //# sourceMappingURL=index.js.map