UNPKG

111 kBJavaScriptView Raw
1(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.superagent = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
2"use strict";
3
4},{}],2:[function(require,module,exports){
5'use strict';
6
7var GetIntrinsic = require('get-intrinsic');
8
9var callBind = require('./');
10
11var $indexOf = callBind(GetIntrinsic('String.prototype.indexOf'));
12
13module.exports = function callBoundIntrinsic(name, allowMissing) {
14 var intrinsic = GetIntrinsic(name, !!allowMissing);
15
16 if (typeof intrinsic === 'function' && $indexOf(name, '.prototype.') > -1) {
17 return callBind(intrinsic);
18 }
19
20 return intrinsic;
21};
22
23},{"./":3,"get-intrinsic":8}],3:[function(require,module,exports){
24'use strict';
25
26var bind = require('function-bind');
27
28var GetIntrinsic = require('get-intrinsic');
29
30var $apply = GetIntrinsic('%Function.prototype.apply%');
31var $call = GetIntrinsic('%Function.prototype.call%');
32var $reflectApply = GetIntrinsic('%Reflect.apply%', true) || bind.call($call, $apply);
33var $gOPD = GetIntrinsic('%Object.getOwnPropertyDescriptor%', true);
34var $defineProperty = GetIntrinsic('%Object.defineProperty%', true);
35var $max = GetIntrinsic('%Math.max%');
36
37if ($defineProperty) {
38 try {
39 $defineProperty({}, 'a', {
40 value: 1
41 });
42 } catch (e) {
43 $defineProperty = null;
44 }
45}
46
47module.exports = function callBind(originalFunction) {
48 var func = $reflectApply(bind, $call, arguments);
49
50 if ($gOPD && $defineProperty) {
51 var desc = $gOPD(func, 'length');
52
53 if (desc.configurable) {
54 $defineProperty(func, 'length', {
55 value: 1 + $max(0, originalFunction.length - (arguments.length - 1))
56 });
57 }
58 }
59
60 return func;
61};
62
63var applyBind = function applyBind() {
64 return $reflectApply(bind, $apply, arguments);
65};
66
67if ($defineProperty) {
68 $defineProperty(module.exports, 'apply', {
69 value: applyBind
70 });
71} else {
72 module.exports.apply = applyBind;
73}
74
75},{"function-bind":7,"get-intrinsic":8}],4:[function(require,module,exports){
76"use strict";
77
78if (typeof module !== 'undefined') {
79 module.exports = Emitter;
80}
81
82function Emitter(obj) {
83 if (obj) return mixin(obj);
84}
85
86;
87
88function mixin(obj) {
89 for (var key in Emitter.prototype) {
90 obj[key] = Emitter.prototype[key];
91 }
92
93 return obj;
94}
95
96Emitter.prototype.on = Emitter.prototype.addEventListener = function (event, fn) {
97 this._callbacks = this._callbacks || {};
98 (this._callbacks['$' + event] = this._callbacks['$' + event] || []).push(fn);
99 return this;
100};
101
102Emitter.prototype.once = function (event, fn) {
103 function on() {
104 this.off(event, on);
105 fn.apply(this, arguments);
106 }
107
108 on.fn = fn;
109 this.on(event, on);
110 return this;
111};
112
113Emitter.prototype.off = Emitter.prototype.removeListener = Emitter.prototype.removeAllListeners = Emitter.prototype.removeEventListener = function (event, fn) {
114 this._callbacks = this._callbacks || {};
115
116 if (0 == arguments.length) {
117 this._callbacks = {};
118 return this;
119 }
120
121 var callbacks = this._callbacks['$' + event];
122 if (!callbacks) return this;
123
124 if (1 == arguments.length) {
125 delete this._callbacks['$' + event];
126 return this;
127 }
128
129 var cb;
130
131 for (var i = 0; i < callbacks.length; i++) {
132 cb = callbacks[i];
133
134 if (cb === fn || cb.fn === fn) {
135 callbacks.splice(i, 1);
136 break;
137 }
138 }
139
140 if (callbacks.length === 0) {
141 delete this._callbacks['$' + event];
142 }
143
144 return this;
145};
146
147Emitter.prototype.emit = function (event) {
148 this._callbacks = this._callbacks || {};
149 var args = new Array(arguments.length - 1),
150 callbacks = this._callbacks['$' + event];
151
152 for (var i = 1; i < arguments.length; i++) {
153 args[i - 1] = arguments[i];
154 }
155
156 if (callbacks) {
157 callbacks = callbacks.slice(0);
158
159 for (var i = 0, len = callbacks.length; i < len; ++i) {
160 callbacks[i].apply(this, args);
161 }
162 }
163
164 return this;
165};
166
167Emitter.prototype.listeners = function (event) {
168 this._callbacks = this._callbacks || {};
169 return this._callbacks['$' + event] || [];
170};
171
172Emitter.prototype.hasListeners = function (event) {
173 return !!this.listeners(event).length;
174};
175
176},{}],5:[function(require,module,exports){
177"use strict";
178
179function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
180
181module.exports = stringify;
182stringify.default = stringify;
183stringify.stable = deterministicStringify;
184stringify.stableStringify = deterministicStringify;
185var LIMIT_REPLACE_NODE = '[...]';
186var CIRCULAR_REPLACE_NODE = '[Circular]';
187var arr = [];
188var replacerStack = [];
189
190function defaultOptions() {
191 return {
192 depthLimit: Number.MAX_SAFE_INTEGER,
193 edgesLimit: Number.MAX_SAFE_INTEGER
194 };
195}
196
197function stringify(obj, replacer, spacer, options) {
198 if (typeof options === 'undefined') {
199 options = defaultOptions();
200 }
201
202 decirc(obj, '', 0, [], undefined, 0, options);
203 var res;
204
205 try {
206 if (replacerStack.length === 0) {
207 res = JSON.stringify(obj, replacer, spacer);
208 } else {
209 res = JSON.stringify(obj, replaceGetterValues(replacer), spacer);
210 }
211 } catch (_) {
212 return JSON.stringify('[unable to serialize, circular reference is too complex to analyze]');
213 } finally {
214 while (arr.length !== 0) {
215 var part = arr.pop();
216
217 if (part.length === 4) {
218 Object.defineProperty(part[0], part[1], part[3]);
219 } else {
220 part[0][part[1]] = part[2];
221 }
222 }
223 }
224
225 return res;
226}
227
228function setReplace(replace, val, k, parent) {
229 var propertyDescriptor = Object.getOwnPropertyDescriptor(parent, k);
230
231 if (propertyDescriptor.get !== undefined) {
232 if (propertyDescriptor.configurable) {
233 Object.defineProperty(parent, k, {
234 value: replace
235 });
236 arr.push([parent, k, val, propertyDescriptor]);
237 } else {
238 replacerStack.push([val, k, replace]);
239 }
240 } else {
241 parent[k] = replace;
242 arr.push([parent, k, val]);
243 }
244}
245
246function decirc(val, k, edgeIndex, stack, parent, depth, options) {
247 depth += 1;
248 var i;
249
250 if (_typeof(val) === 'object' && val !== null) {
251 for (i = 0; i < stack.length; i++) {
252 if (stack[i] === val) {
253 setReplace(CIRCULAR_REPLACE_NODE, val, k, parent);
254 return;
255 }
256 }
257
258 if (typeof options.depthLimit !== 'undefined' && depth > options.depthLimit) {
259 setReplace(LIMIT_REPLACE_NODE, val, k, parent);
260 return;
261 }
262
263 if (typeof options.edgesLimit !== 'undefined' && edgeIndex + 1 > options.edgesLimit) {
264 setReplace(LIMIT_REPLACE_NODE, val, k, parent);
265 return;
266 }
267
268 stack.push(val);
269
270 if (Array.isArray(val)) {
271 for (i = 0; i < val.length; i++) {
272 decirc(val[i], i, i, stack, val, depth, options);
273 }
274 } else {
275 var keys = Object.keys(val);
276
277 for (i = 0; i < keys.length; i++) {
278 var key = keys[i];
279 decirc(val[key], key, i, stack, val, depth, options);
280 }
281 }
282
283 stack.pop();
284 }
285}
286
287function compareFunction(a, b) {
288 if (a < b) {
289 return -1;
290 }
291
292 if (a > b) {
293 return 1;
294 }
295
296 return 0;
297}
298
299function deterministicStringify(obj, replacer, spacer, options) {
300 if (typeof options === 'undefined') {
301 options = defaultOptions();
302 }
303
304 var tmp = deterministicDecirc(obj, '', 0, [], undefined, 0, options) || obj;
305 var res;
306
307 try {
308 if (replacerStack.length === 0) {
309 res = JSON.stringify(tmp, replacer, spacer);
310 } else {
311 res = JSON.stringify(tmp, replaceGetterValues(replacer), spacer);
312 }
313 } catch (_) {
314 return JSON.stringify('[unable to serialize, circular reference is too complex to analyze]');
315 } finally {
316 while (arr.length !== 0) {
317 var part = arr.pop();
318
319 if (part.length === 4) {
320 Object.defineProperty(part[0], part[1], part[3]);
321 } else {
322 part[0][part[1]] = part[2];
323 }
324 }
325 }
326
327 return res;
328}
329
330function deterministicDecirc(val, k, edgeIndex, stack, parent, depth, options) {
331 depth += 1;
332 var i;
333
334 if (_typeof(val) === 'object' && val !== null) {
335 for (i = 0; i < stack.length; i++) {
336 if (stack[i] === val) {
337 setReplace(CIRCULAR_REPLACE_NODE, val, k, parent);
338 return;
339 }
340 }
341
342 try {
343 if (typeof val.toJSON === 'function') {
344 return;
345 }
346 } catch (_) {
347 return;
348 }
349
350 if (typeof options.depthLimit !== 'undefined' && depth > options.depthLimit) {
351 setReplace(LIMIT_REPLACE_NODE, val, k, parent);
352 return;
353 }
354
355 if (typeof options.edgesLimit !== 'undefined' && edgeIndex + 1 > options.edgesLimit) {
356 setReplace(LIMIT_REPLACE_NODE, val, k, parent);
357 return;
358 }
359
360 stack.push(val);
361
362 if (Array.isArray(val)) {
363 for (i = 0; i < val.length; i++) {
364 deterministicDecirc(val[i], i, i, stack, val, depth, options);
365 }
366 } else {
367 var tmp = {};
368 var keys = Object.keys(val).sort(compareFunction);
369
370 for (i = 0; i < keys.length; i++) {
371 var key = keys[i];
372 deterministicDecirc(val[key], key, i, stack, val, depth, options);
373 tmp[key] = val[key];
374 }
375
376 if (typeof parent !== 'undefined') {
377 arr.push([parent, k, val]);
378 parent[k] = tmp;
379 } else {
380 return tmp;
381 }
382 }
383
384 stack.pop();
385 }
386}
387
388function replaceGetterValues(replacer) {
389 replacer = typeof replacer !== 'undefined' ? replacer : function (k, v) {
390 return v;
391 };
392 return function (key, val) {
393 if (replacerStack.length > 0) {
394 for (var i = 0; i < replacerStack.length; i++) {
395 var part = replacerStack[i];
396
397 if (part[1] === key && part[0] === val) {
398 val = part[2];
399 replacerStack.splice(i, 1);
400 break;
401 }
402 }
403 }
404
405 return replacer.call(this, key, val);
406 };
407}
408
409},{}],6:[function(require,module,exports){
410'use strict';
411
412var ERROR_MESSAGE = 'Function.prototype.bind called on incompatible ';
413var slice = Array.prototype.slice;
414var toStr = Object.prototype.toString;
415var funcType = '[object Function]';
416
417module.exports = function bind(that) {
418 var target = this;
419
420 if (typeof target !== 'function' || toStr.call(target) !== funcType) {
421 throw new TypeError(ERROR_MESSAGE + target);
422 }
423
424 var args = slice.call(arguments, 1);
425 var bound;
426
427 var binder = function binder() {
428 if (this instanceof bound) {
429 var result = target.apply(this, args.concat(slice.call(arguments)));
430
431 if (Object(result) === result) {
432 return result;
433 }
434
435 return this;
436 } else {
437 return target.apply(that, args.concat(slice.call(arguments)));
438 }
439 };
440
441 var boundLength = Math.max(0, target.length - args.length);
442 var boundArgs = [];
443
444 for (var i = 0; i < boundLength; i++) {
445 boundArgs.push('$' + i);
446 }
447
448 bound = Function('binder', 'return function (' + boundArgs.join(',') + '){ return binder.apply(this,arguments); }')(binder);
449
450 if (target.prototype) {
451 var Empty = function Empty() {};
452
453 Empty.prototype = target.prototype;
454 bound.prototype = new Empty();
455 Empty.prototype = null;
456 }
457
458 return bound;
459};
460
461},{}],7:[function(require,module,exports){
462'use strict';
463
464var implementation = require('./implementation');
465
466module.exports = Function.prototype.bind || implementation;
467
468},{"./implementation":6}],8:[function(require,module,exports){
469'use strict';
470
471function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
472
473var undefined;
474var $SyntaxError = SyntaxError;
475var $Function = Function;
476var $TypeError = TypeError;
477
478var getEvalledConstructor = function getEvalledConstructor(expressionSyntax) {
479 try {
480 return $Function('"use strict"; return (' + expressionSyntax + ').constructor;')();
481 } catch (e) {}
482};
483
484var $gOPD = Object.getOwnPropertyDescriptor;
485
486if ($gOPD) {
487 try {
488 $gOPD({}, '');
489 } catch (e) {
490 $gOPD = null;
491 }
492}
493
494var throwTypeError = function throwTypeError() {
495 throw new $TypeError();
496};
497
498var ThrowTypeError = $gOPD ? function () {
499 try {
500 arguments.callee;
501 return throwTypeError;
502 } catch (calleeThrows) {
503 try {
504 return $gOPD(arguments, 'callee').get;
505 } catch (gOPDthrows) {
506 return throwTypeError;
507 }
508 }
509}() : throwTypeError;
510
511var hasSymbols = require('has-symbols')();
512
513var getProto = Object.getPrototypeOf || function (x) {
514 return x.__proto__;
515};
516
517var needsEval = {};
518var TypedArray = typeof Uint8Array === 'undefined' ? undefined : getProto(Uint8Array);
519var INTRINSICS = {
520 '%AggregateError%': typeof AggregateError === 'undefined' ? undefined : AggregateError,
521 '%Array%': Array,
522 '%ArrayBuffer%': typeof ArrayBuffer === 'undefined' ? undefined : ArrayBuffer,
523 '%ArrayIteratorPrototype%': hasSymbols ? getProto([][Symbol.iterator]()) : undefined,
524 '%AsyncFromSyncIteratorPrototype%': undefined,
525 '%AsyncFunction%': needsEval,
526 '%AsyncGenerator%': needsEval,
527 '%AsyncGeneratorFunction%': needsEval,
528 '%AsyncIteratorPrototype%': needsEval,
529 '%Atomics%': typeof Atomics === 'undefined' ? undefined : Atomics,
530 '%BigInt%': typeof BigInt === 'undefined' ? undefined : BigInt,
531 '%Boolean%': Boolean,
532 '%DataView%': typeof DataView === 'undefined' ? undefined : DataView,
533 '%Date%': Date,
534 '%decodeURI%': decodeURI,
535 '%decodeURIComponent%': decodeURIComponent,
536 '%encodeURI%': encodeURI,
537 '%encodeURIComponent%': encodeURIComponent,
538 '%Error%': Error,
539 '%eval%': eval,
540 '%EvalError%': EvalError,
541 '%Float32Array%': typeof Float32Array === 'undefined' ? undefined : Float32Array,
542 '%Float64Array%': typeof Float64Array === 'undefined' ? undefined : Float64Array,
543 '%FinalizationRegistry%': typeof FinalizationRegistry === 'undefined' ? undefined : FinalizationRegistry,
544 '%Function%': $Function,
545 '%GeneratorFunction%': needsEval,
546 '%Int8Array%': typeof Int8Array === 'undefined' ? undefined : Int8Array,
547 '%Int16Array%': typeof Int16Array === 'undefined' ? undefined : Int16Array,
548 '%Int32Array%': typeof Int32Array === 'undefined' ? undefined : Int32Array,
549 '%isFinite%': isFinite,
550 '%isNaN%': isNaN,
551 '%IteratorPrototype%': hasSymbols ? getProto(getProto([][Symbol.iterator]())) : undefined,
552 '%JSON%': (typeof JSON === "undefined" ? "undefined" : _typeof(JSON)) === 'object' ? JSON : undefined,
553 '%Map%': typeof Map === 'undefined' ? undefined : Map,
554 '%MapIteratorPrototype%': typeof Map === 'undefined' || !hasSymbols ? undefined : getProto(new Map()[Symbol.iterator]()),
555 '%Math%': Math,
556 '%Number%': Number,
557 '%Object%': Object,
558 '%parseFloat%': parseFloat,
559 '%parseInt%': parseInt,
560 '%Promise%': typeof Promise === 'undefined' ? undefined : Promise,
561 '%Proxy%': typeof Proxy === 'undefined' ? undefined : Proxy,
562 '%RangeError%': RangeError,
563 '%ReferenceError%': ReferenceError,
564 '%Reflect%': typeof Reflect === 'undefined' ? undefined : Reflect,
565 '%RegExp%': RegExp,
566 '%Set%': typeof Set === 'undefined' ? undefined : Set,
567 '%SetIteratorPrototype%': typeof Set === 'undefined' || !hasSymbols ? undefined : getProto(new Set()[Symbol.iterator]()),
568 '%SharedArrayBuffer%': typeof SharedArrayBuffer === 'undefined' ? undefined : SharedArrayBuffer,
569 '%String%': String,
570 '%StringIteratorPrototype%': hasSymbols ? getProto(''[Symbol.iterator]()) : undefined,
571 '%Symbol%': hasSymbols ? Symbol : undefined,
572 '%SyntaxError%': $SyntaxError,
573 '%ThrowTypeError%': ThrowTypeError,
574 '%TypedArray%': TypedArray,
575 '%TypeError%': $TypeError,
576 '%Uint8Array%': typeof Uint8Array === 'undefined' ? undefined : Uint8Array,
577 '%Uint8ClampedArray%': typeof Uint8ClampedArray === 'undefined' ? undefined : Uint8ClampedArray,
578 '%Uint16Array%': typeof Uint16Array === 'undefined' ? undefined : Uint16Array,
579 '%Uint32Array%': typeof Uint32Array === 'undefined' ? undefined : Uint32Array,
580 '%URIError%': URIError,
581 '%WeakMap%': typeof WeakMap === 'undefined' ? undefined : WeakMap,
582 '%WeakRef%': typeof WeakRef === 'undefined' ? undefined : WeakRef,
583 '%WeakSet%': typeof WeakSet === 'undefined' ? undefined : WeakSet
584};
585
586var doEval = function doEval(name) {
587 var value;
588
589 if (name === '%AsyncFunction%') {
590 value = getEvalledConstructor('async function () {}');
591 } else if (name === '%GeneratorFunction%') {
592 value = getEvalledConstructor('function* () {}');
593 } else if (name === '%AsyncGeneratorFunction%') {
594 value = getEvalledConstructor('async function* () {}');
595 } else if (name === '%AsyncGenerator%') {
596 var fn = doEval('%AsyncGeneratorFunction%');
597
598 if (fn) {
599 value = fn.prototype;
600 }
601 } else if (name === '%AsyncIteratorPrototype%') {
602 var gen = doEval('%AsyncGenerator%');
603
604 if (gen) {
605 value = getProto(gen.prototype);
606 }
607 }
608
609 INTRINSICS[name] = value;
610 return value;
611};
612
613var LEGACY_ALIASES = {
614 '%ArrayBufferPrototype%': ['ArrayBuffer', 'prototype'],
615 '%ArrayPrototype%': ['Array', 'prototype'],
616 '%ArrayProto_entries%': ['Array', 'prototype', 'entries'],
617 '%ArrayProto_forEach%': ['Array', 'prototype', 'forEach'],
618 '%ArrayProto_keys%': ['Array', 'prototype', 'keys'],
619 '%ArrayProto_values%': ['Array', 'prototype', 'values'],
620 '%AsyncFunctionPrototype%': ['AsyncFunction', 'prototype'],
621 '%AsyncGenerator%': ['AsyncGeneratorFunction', 'prototype'],
622 '%AsyncGeneratorPrototype%': ['AsyncGeneratorFunction', 'prototype', 'prototype'],
623 '%BooleanPrototype%': ['Boolean', 'prototype'],
624 '%DataViewPrototype%': ['DataView', 'prototype'],
625 '%DatePrototype%': ['Date', 'prototype'],
626 '%ErrorPrototype%': ['Error', 'prototype'],
627 '%EvalErrorPrototype%': ['EvalError', 'prototype'],
628 '%Float32ArrayPrototype%': ['Float32Array', 'prototype'],
629 '%Float64ArrayPrototype%': ['Float64Array', 'prototype'],
630 '%FunctionPrototype%': ['Function', 'prototype'],
631 '%Generator%': ['GeneratorFunction', 'prototype'],
632 '%GeneratorPrototype%': ['GeneratorFunction', 'prototype', 'prototype'],
633 '%Int8ArrayPrototype%': ['Int8Array', 'prototype'],
634 '%Int16ArrayPrototype%': ['Int16Array', 'prototype'],
635 '%Int32ArrayPrototype%': ['Int32Array', 'prototype'],
636 '%JSONParse%': ['JSON', 'parse'],
637 '%JSONStringify%': ['JSON', 'stringify'],
638 '%MapPrototype%': ['Map', 'prototype'],
639 '%NumberPrototype%': ['Number', 'prototype'],
640 '%ObjectPrototype%': ['Object', 'prototype'],
641 '%ObjProto_toString%': ['Object', 'prototype', 'toString'],
642 '%ObjProto_valueOf%': ['Object', 'prototype', 'valueOf'],
643 '%PromisePrototype%': ['Promise', 'prototype'],
644 '%PromiseProto_then%': ['Promise', 'prototype', 'then'],
645 '%Promise_all%': ['Promise', 'all'],
646 '%Promise_reject%': ['Promise', 'reject'],
647 '%Promise_resolve%': ['Promise', 'resolve'],
648 '%RangeErrorPrototype%': ['RangeError', 'prototype'],
649 '%ReferenceErrorPrototype%': ['ReferenceError', 'prototype'],
650 '%RegExpPrototype%': ['RegExp', 'prototype'],
651 '%SetPrototype%': ['Set', 'prototype'],
652 '%SharedArrayBufferPrototype%': ['SharedArrayBuffer', 'prototype'],
653 '%StringPrototype%': ['String', 'prototype'],
654 '%SymbolPrototype%': ['Symbol', 'prototype'],
655 '%SyntaxErrorPrototype%': ['SyntaxError', 'prototype'],
656 '%TypedArrayPrototype%': ['TypedArray', 'prototype'],
657 '%TypeErrorPrototype%': ['TypeError', 'prototype'],
658 '%Uint8ArrayPrototype%': ['Uint8Array', 'prototype'],
659 '%Uint8ClampedArrayPrototype%': ['Uint8ClampedArray', 'prototype'],
660 '%Uint16ArrayPrototype%': ['Uint16Array', 'prototype'],
661 '%Uint32ArrayPrototype%': ['Uint32Array', 'prototype'],
662 '%URIErrorPrototype%': ['URIError', 'prototype'],
663 '%WeakMapPrototype%': ['WeakMap', 'prototype'],
664 '%WeakSetPrototype%': ['WeakSet', 'prototype']
665};
666
667var bind = require('function-bind');
668
669var hasOwn = require('has');
670
671var $concat = bind.call(Function.call, Array.prototype.concat);
672var $spliceApply = bind.call(Function.apply, Array.prototype.splice);
673var $replace = bind.call(Function.call, String.prototype.replace);
674var $strSlice = bind.call(Function.call, String.prototype.slice);
675var rePropName = /[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g;
676var reEscapeChar = /\\(\\)?/g;
677
678var stringToPath = function stringToPath(string) {
679 var first = $strSlice(string, 0, 1);
680 var last = $strSlice(string, -1);
681
682 if (first === '%' && last !== '%') {
683 throw new $SyntaxError('invalid intrinsic syntax, expected closing `%`');
684 } else if (last === '%' && first !== '%') {
685 throw new $SyntaxError('invalid intrinsic syntax, expected opening `%`');
686 }
687
688 var result = [];
689 $replace(string, rePropName, function (match, number, quote, subString) {
690 result[result.length] = quote ? $replace(subString, reEscapeChar, '$1') : number || match;
691 });
692 return result;
693};
694
695var getBaseIntrinsic = function getBaseIntrinsic(name, allowMissing) {
696 var intrinsicName = name;
697 var alias;
698
699 if (hasOwn(LEGACY_ALIASES, intrinsicName)) {
700 alias = LEGACY_ALIASES[intrinsicName];
701 intrinsicName = '%' + alias[0] + '%';
702 }
703
704 if (hasOwn(INTRINSICS, intrinsicName)) {
705 var value = INTRINSICS[intrinsicName];
706
707 if (value === needsEval) {
708 value = doEval(intrinsicName);
709 }
710
711 if (typeof value === 'undefined' && !allowMissing) {
712 throw new $TypeError('intrinsic ' + name + ' exists, but is not available. Please file an issue!');
713 }
714
715 return {
716 alias: alias,
717 name: intrinsicName,
718 value: value
719 };
720 }
721
722 throw new $SyntaxError('intrinsic ' + name + ' does not exist!');
723};
724
725module.exports = function GetIntrinsic(name, allowMissing) {
726 if (typeof name !== 'string' || name.length === 0) {
727 throw new $TypeError('intrinsic name must be a non-empty string');
728 }
729
730 if (arguments.length > 1 && typeof allowMissing !== 'boolean') {
731 throw new $TypeError('"allowMissing" argument must be a boolean');
732 }
733
734 var parts = stringToPath(name);
735 var intrinsicBaseName = parts.length > 0 ? parts[0] : '';
736 var intrinsic = getBaseIntrinsic('%' + intrinsicBaseName + '%', allowMissing);
737 var intrinsicRealName = intrinsic.name;
738 var value = intrinsic.value;
739 var skipFurtherCaching = false;
740 var alias = intrinsic.alias;
741
742 if (alias) {
743 intrinsicBaseName = alias[0];
744 $spliceApply(parts, $concat([0, 1], alias));
745 }
746
747 for (var i = 1, isOwn = true; i < parts.length; i += 1) {
748 var part = parts[i];
749 var first = $strSlice(part, 0, 1);
750 var last = $strSlice(part, -1);
751
752 if ((first === '"' || first === "'" || first === '`' || last === '"' || last === "'" || last === '`') && first !== last) {
753 throw new $SyntaxError('property names with quotes must have matching quotes');
754 }
755
756 if (part === 'constructor' || !isOwn) {
757 skipFurtherCaching = true;
758 }
759
760 intrinsicBaseName += '.' + part;
761 intrinsicRealName = '%' + intrinsicBaseName + '%';
762
763 if (hasOwn(INTRINSICS, intrinsicRealName)) {
764 value = INTRINSICS[intrinsicRealName];
765 } else if (value != null) {
766 if (!(part in value)) {
767 if (!allowMissing) {
768 throw new $TypeError('base intrinsic for ' + name + ' exists, but the property is not available.');
769 }
770
771 return void undefined;
772 }
773
774 if ($gOPD && i + 1 >= parts.length) {
775 var desc = $gOPD(value, part);
776 isOwn = !!desc;
777
778 if (isOwn && 'get' in desc && !('originalValue' in desc.get)) {
779 value = desc.get;
780 } else {
781 value = value[part];
782 }
783 } else {
784 isOwn = hasOwn(value, part);
785 value = value[part];
786 }
787
788 if (isOwn && !skipFurtherCaching) {
789 INTRINSICS[intrinsicRealName] = value;
790 }
791 }
792 }
793
794 return value;
795};
796
797},{"function-bind":7,"has":11,"has-symbols":9}],9:[function(require,module,exports){
798'use strict';
799
800function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
801
802var origSymbol = typeof Symbol !== 'undefined' && Symbol;
803
804var hasSymbolSham = require('./shams');
805
806module.exports = function hasNativeSymbols() {
807 if (typeof origSymbol !== 'function') {
808 return false;
809 }
810
811 if (typeof Symbol !== 'function') {
812 return false;
813 }
814
815 if (_typeof(origSymbol('foo')) !== 'symbol') {
816 return false;
817 }
818
819 if (_typeof(Symbol('bar')) !== 'symbol') {
820 return false;
821 }
822
823 return hasSymbolSham();
824};
825
826},{"./shams":10}],10:[function(require,module,exports){
827'use strict';
828
829function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
830
831module.exports = function hasSymbols() {
832 if (typeof Symbol !== 'function' || typeof Object.getOwnPropertySymbols !== 'function') {
833 return false;
834 }
835
836 if (_typeof(Symbol.iterator) === 'symbol') {
837 return true;
838 }
839
840 var obj = {};
841 var sym = Symbol('test');
842 var symObj = Object(sym);
843
844 if (typeof sym === 'string') {
845 return false;
846 }
847
848 if (Object.prototype.toString.call(sym) !== '[object Symbol]') {
849 return false;
850 }
851
852 if (Object.prototype.toString.call(symObj) !== '[object Symbol]') {
853 return false;
854 }
855
856 var symVal = 42;
857 obj[sym] = symVal;
858
859 for (sym in obj) {
860 return false;
861 }
862
863 if (typeof Object.keys === 'function' && Object.keys(obj).length !== 0) {
864 return false;
865 }
866
867 if (typeof Object.getOwnPropertyNames === 'function' && Object.getOwnPropertyNames(obj).length !== 0) {
868 return false;
869 }
870
871 var syms = Object.getOwnPropertySymbols(obj);
872
873 if (syms.length !== 1 || syms[0] !== sym) {
874 return false;
875 }
876
877 if (!Object.prototype.propertyIsEnumerable.call(obj, sym)) {
878 return false;
879 }
880
881 if (typeof Object.getOwnPropertyDescriptor === 'function') {
882 var descriptor = Object.getOwnPropertyDescriptor(obj, sym);
883
884 if (descriptor.value !== symVal || descriptor.enumerable !== true) {
885 return false;
886 }
887 }
888
889 return true;
890};
891
892},{}],11:[function(require,module,exports){
893'use strict';
894
895var bind = require('function-bind');
896
897module.exports = bind.call(Function.call, Object.prototype.hasOwnProperty);
898
899},{"function-bind":7}],12:[function(require,module,exports){
900"use strict";
901
902function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
903
904var hasMap = typeof Map === 'function' && Map.prototype;
905var mapSizeDescriptor = Object.getOwnPropertyDescriptor && hasMap ? Object.getOwnPropertyDescriptor(Map.prototype, 'size') : null;
906var mapSize = hasMap && mapSizeDescriptor && typeof mapSizeDescriptor.get === 'function' ? mapSizeDescriptor.get : null;
907var mapForEach = hasMap && Map.prototype.forEach;
908var hasSet = typeof Set === 'function' && Set.prototype;
909var setSizeDescriptor = Object.getOwnPropertyDescriptor && hasSet ? Object.getOwnPropertyDescriptor(Set.prototype, 'size') : null;
910var setSize = hasSet && setSizeDescriptor && typeof setSizeDescriptor.get === 'function' ? setSizeDescriptor.get : null;
911var setForEach = hasSet && Set.prototype.forEach;
912var hasWeakMap = typeof WeakMap === 'function' && WeakMap.prototype;
913var weakMapHas = hasWeakMap ? WeakMap.prototype.has : null;
914var hasWeakSet = typeof WeakSet === 'function' && WeakSet.prototype;
915var weakSetHas = hasWeakSet ? WeakSet.prototype.has : null;
916var hasWeakRef = typeof WeakRef === 'function' && WeakRef.prototype;
917var weakRefDeref = hasWeakRef ? WeakRef.prototype.deref : null;
918var booleanValueOf = Boolean.prototype.valueOf;
919var objectToString = Object.prototype.toString;
920var functionToString = Function.prototype.toString;
921var $match = String.prototype.match;
922var $slice = String.prototype.slice;
923var $replace = String.prototype.replace;
924var $toUpperCase = String.prototype.toUpperCase;
925var $toLowerCase = String.prototype.toLowerCase;
926var $test = RegExp.prototype.test;
927var $concat = Array.prototype.concat;
928var $join = Array.prototype.join;
929var $arrSlice = Array.prototype.slice;
930var $floor = Math.floor;
931var bigIntValueOf = typeof BigInt === 'function' ? BigInt.prototype.valueOf : null;
932var gOPS = Object.getOwnPropertySymbols;
933var symToString = typeof Symbol === 'function' && _typeof(Symbol.iterator) === 'symbol' ? Symbol.prototype.toString : null;
934var hasShammedSymbols = typeof Symbol === 'function' && _typeof(Symbol.iterator) === 'object';
935var toStringTag = typeof Symbol === 'function' && Symbol.toStringTag && (_typeof(Symbol.toStringTag) === hasShammedSymbols ? 'object' : 'symbol') ? Symbol.toStringTag : null;
936var isEnumerable = Object.prototype.propertyIsEnumerable;
937var gPO = (typeof Reflect === 'function' ? Reflect.getPrototypeOf : Object.getPrototypeOf) || ([].__proto__ === Array.prototype ? function (O) {
938 return O.__proto__;
939} : null);
940
941function addNumericSeparator(num, str) {
942 if (num === Infinity || num === -Infinity || num !== num || num && num > -1000 && num < 1000 || $test.call(/e/, str)) {
943 return str;
944 }
945
946 var sepRegex = /[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;
947
948 if (typeof num === 'number') {
949 var int = num < 0 ? -$floor(-num) : $floor(num);
950
951 if (int !== num) {
952 var intStr = String(int);
953 var dec = $slice.call(str, intStr.length + 1);
954 return $replace.call(intStr, sepRegex, '$&_') + '.' + $replace.call($replace.call(dec, /([0-9]{3})/g, '$&_'), /_$/, '');
955 }
956 }
957
958 return $replace.call(str, sepRegex, '$&_');
959}
960
961var inspectCustom = require('./util.inspect').custom;
962
963var inspectSymbol = inspectCustom && isSymbol(inspectCustom) ? inspectCustom : null;
964
965module.exports = function inspect_(obj, options, depth, seen) {
966 var opts = options || {};
967
968 if (has(opts, 'quoteStyle') && opts.quoteStyle !== 'single' && opts.quoteStyle !== 'double') {
969 throw new TypeError('option "quoteStyle" must be "single" or "double"');
970 }
971
972 if (has(opts, 'maxStringLength') && (typeof opts.maxStringLength === 'number' ? opts.maxStringLength < 0 && opts.maxStringLength !== Infinity : opts.maxStringLength !== null)) {
973 throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');
974 }
975
976 var customInspect = has(opts, 'customInspect') ? opts.customInspect : true;
977
978 if (typeof customInspect !== 'boolean' && customInspect !== 'symbol') {
979 throw new TypeError('option "customInspect", if provided, must be `true`, `false`, or `\'symbol\'`');
980 }
981
982 if (has(opts, 'indent') && opts.indent !== null && opts.indent !== '\t' && !(parseInt(opts.indent, 10) === opts.indent && opts.indent > 0)) {
983 throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');
984 }
985
986 if (has(opts, 'numericSeparator') && typeof opts.numericSeparator !== 'boolean') {
987 throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');
988 }
989
990 var numericSeparator = opts.numericSeparator;
991
992 if (typeof obj === 'undefined') {
993 return 'undefined';
994 }
995
996 if (obj === null) {
997 return 'null';
998 }
999
1000 if (typeof obj === 'boolean') {
1001 return obj ? 'true' : 'false';
1002 }
1003
1004 if (typeof obj === 'string') {
1005 return inspectString(obj, opts);
1006 }
1007
1008 if (typeof obj === 'number') {
1009 if (obj === 0) {
1010 return Infinity / obj > 0 ? '0' : '-0';
1011 }
1012
1013 var str = String(obj);
1014 return numericSeparator ? addNumericSeparator(obj, str) : str;
1015 }
1016
1017 if (typeof obj === 'bigint') {
1018 var bigIntStr = String(obj) + 'n';
1019 return numericSeparator ? addNumericSeparator(obj, bigIntStr) : bigIntStr;
1020 }
1021
1022 var maxDepth = typeof opts.depth === 'undefined' ? 5 : opts.depth;
1023
1024 if (typeof depth === 'undefined') {
1025 depth = 0;
1026 }
1027
1028 if (depth >= maxDepth && maxDepth > 0 && _typeof(obj) === 'object') {
1029 return isArray(obj) ? '[Array]' : '[Object]';
1030 }
1031
1032 var indent = getIndent(opts, depth);
1033
1034 if (typeof seen === 'undefined') {
1035 seen = [];
1036 } else if (indexOf(seen, obj) >= 0) {
1037 return '[Circular]';
1038 }
1039
1040 function inspect(value, from, noIndent) {
1041 if (from) {
1042 seen = $arrSlice.call(seen);
1043 seen.push(from);
1044 }
1045
1046 if (noIndent) {
1047 var newOpts = {
1048 depth: opts.depth
1049 };
1050
1051 if (has(opts, 'quoteStyle')) {
1052 newOpts.quoteStyle = opts.quoteStyle;
1053 }
1054
1055 return inspect_(value, newOpts, depth + 1, seen);
1056 }
1057
1058 return inspect_(value, opts, depth + 1, seen);
1059 }
1060
1061 if (typeof obj === 'function') {
1062 var name = nameOf(obj);
1063 var keys = arrObjKeys(obj, inspect);
1064 return '[Function' + (name ? ': ' + name : ' (anonymous)') + ']' + (keys.length > 0 ? ' { ' + $join.call(keys, ', ') + ' }' : '');
1065 }
1066
1067 if (isSymbol(obj)) {
1068 var symString = hasShammedSymbols ? $replace.call(String(obj), /^(Symbol\(.*\))_[^)]*$/, '$1') : symToString.call(obj);
1069 return _typeof(obj) === 'object' && !hasShammedSymbols ? markBoxed(symString) : symString;
1070 }
1071
1072 if (isElement(obj)) {
1073 var s = '<' + $toLowerCase.call(String(obj.nodeName));
1074 var attrs = obj.attributes || [];
1075
1076 for (var i = 0; i < attrs.length; i++) {
1077 s += ' ' + attrs[i].name + '=' + wrapQuotes(quote(attrs[i].value), 'double', opts);
1078 }
1079
1080 s += '>';
1081
1082 if (obj.childNodes && obj.childNodes.length) {
1083 s += '...';
1084 }
1085
1086 s += '</' + $toLowerCase.call(String(obj.nodeName)) + '>';
1087 return s;
1088 }
1089
1090 if (isArray(obj)) {
1091 if (obj.length === 0) {
1092 return '[]';
1093 }
1094
1095 var xs = arrObjKeys(obj, inspect);
1096
1097 if (indent && !singleLineValues(xs)) {
1098 return '[' + indentedJoin(xs, indent) + ']';
1099 }
1100
1101 return '[ ' + $join.call(xs, ', ') + ' ]';
1102 }
1103
1104 if (isError(obj)) {
1105 var parts = arrObjKeys(obj, inspect);
1106
1107 if ('cause' in obj && !isEnumerable.call(obj, 'cause')) {
1108 return '{ [' + String(obj) + '] ' + $join.call($concat.call('[cause]: ' + inspect(obj.cause), parts), ', ') + ' }';
1109 }
1110
1111 if (parts.length === 0) {
1112 return '[' + String(obj) + ']';
1113 }
1114
1115 return '{ [' + String(obj) + '] ' + $join.call(parts, ', ') + ' }';
1116 }
1117
1118 if (_typeof(obj) === 'object' && customInspect) {
1119 if (inspectSymbol && typeof obj[inspectSymbol] === 'function') {
1120 return obj[inspectSymbol]();
1121 } else if (customInspect !== 'symbol' && typeof obj.inspect === 'function') {
1122 return obj.inspect();
1123 }
1124 }
1125
1126 if (isMap(obj)) {
1127 var mapParts = [];
1128 mapForEach.call(obj, function (value, key) {
1129 mapParts.push(inspect(key, obj, true) + ' => ' + inspect(value, obj));
1130 });
1131 return collectionOf('Map', mapSize.call(obj), mapParts, indent);
1132 }
1133
1134 if (isSet(obj)) {
1135 var setParts = [];
1136 setForEach.call(obj, function (value) {
1137 setParts.push(inspect(value, obj));
1138 });
1139 return collectionOf('Set', setSize.call(obj), setParts, indent);
1140 }
1141
1142 if (isWeakMap(obj)) {
1143 return weakCollectionOf('WeakMap');
1144 }
1145
1146 if (isWeakSet(obj)) {
1147 return weakCollectionOf('WeakSet');
1148 }
1149
1150 if (isWeakRef(obj)) {
1151 return weakCollectionOf('WeakRef');
1152 }
1153
1154 if (isNumber(obj)) {
1155 return markBoxed(inspect(Number(obj)));
1156 }
1157
1158 if (isBigInt(obj)) {
1159 return markBoxed(inspect(bigIntValueOf.call(obj)));
1160 }
1161
1162 if (isBoolean(obj)) {
1163 return markBoxed(booleanValueOf.call(obj));
1164 }
1165
1166 if (isString(obj)) {
1167 return markBoxed(inspect(String(obj)));
1168 }
1169
1170 if (!isDate(obj) && !isRegExp(obj)) {
1171 var ys = arrObjKeys(obj, inspect);
1172 var isPlainObject = gPO ? gPO(obj) === Object.prototype : obj instanceof Object || obj.constructor === Object;
1173 var protoTag = obj instanceof Object ? '' : 'null prototype';
1174 var stringTag = !isPlainObject && toStringTag && Object(obj) === obj && toStringTag in obj ? $slice.call(toStr(obj), 8, -1) : protoTag ? 'Object' : '';
1175 var constructorTag = isPlainObject || typeof obj.constructor !== 'function' ? '' : obj.constructor.name ? obj.constructor.name + ' ' : '';
1176 var tag = constructorTag + (stringTag || protoTag ? '[' + $join.call($concat.call([], stringTag || [], protoTag || []), ': ') + '] ' : '');
1177
1178 if (ys.length === 0) {
1179 return tag + '{}';
1180 }
1181
1182 if (indent) {
1183 return tag + '{' + indentedJoin(ys, indent) + '}';
1184 }
1185
1186 return tag + '{ ' + $join.call(ys, ', ') + ' }';
1187 }
1188
1189 return String(obj);
1190};
1191
1192function wrapQuotes(s, defaultStyle, opts) {
1193 var quoteChar = (opts.quoteStyle || defaultStyle) === 'double' ? '"' : "'";
1194 return quoteChar + s + quoteChar;
1195}
1196
1197function quote(s) {
1198 return $replace.call(String(s), /"/g, '&quot;');
1199}
1200
1201function isArray(obj) {
1202 return toStr(obj) === '[object Array]' && (!toStringTag || !(_typeof(obj) === 'object' && toStringTag in obj));
1203}
1204
1205function isDate(obj) {
1206 return toStr(obj) === '[object Date]' && (!toStringTag || !(_typeof(obj) === 'object' && toStringTag in obj));
1207}
1208
1209function isRegExp(obj) {
1210 return toStr(obj) === '[object RegExp]' && (!toStringTag || !(_typeof(obj) === 'object' && toStringTag in obj));
1211}
1212
1213function isError(obj) {
1214 return toStr(obj) === '[object Error]' && (!toStringTag || !(_typeof(obj) === 'object' && toStringTag in obj));
1215}
1216
1217function isString(obj) {
1218 return toStr(obj) === '[object String]' && (!toStringTag || !(_typeof(obj) === 'object' && toStringTag in obj));
1219}
1220
1221function isNumber(obj) {
1222 return toStr(obj) === '[object Number]' && (!toStringTag || !(_typeof(obj) === 'object' && toStringTag in obj));
1223}
1224
1225function isBoolean(obj) {
1226 return toStr(obj) === '[object Boolean]' && (!toStringTag || !(_typeof(obj) === 'object' && toStringTag in obj));
1227}
1228
1229function isSymbol(obj) {
1230 if (hasShammedSymbols) {
1231 return obj && _typeof(obj) === 'object' && obj instanceof Symbol;
1232 }
1233
1234 if (_typeof(obj) === 'symbol') {
1235 return true;
1236 }
1237
1238 if (!obj || _typeof(obj) !== 'object' || !symToString) {
1239 return false;
1240 }
1241
1242 try {
1243 symToString.call(obj);
1244 return true;
1245 } catch (e) {}
1246
1247 return false;
1248}
1249
1250function isBigInt(obj) {
1251 if (!obj || _typeof(obj) !== 'object' || !bigIntValueOf) {
1252 return false;
1253 }
1254
1255 try {
1256 bigIntValueOf.call(obj);
1257 return true;
1258 } catch (e) {}
1259
1260 return false;
1261}
1262
1263var hasOwn = Object.prototype.hasOwnProperty || function (key) {
1264 return key in this;
1265};
1266
1267function has(obj, key) {
1268 return hasOwn.call(obj, key);
1269}
1270
1271function toStr(obj) {
1272 return objectToString.call(obj);
1273}
1274
1275function nameOf(f) {
1276 if (f.name) {
1277 return f.name;
1278 }
1279
1280 var m = $match.call(functionToString.call(f), /^function\s*([\w$]+)/);
1281
1282 if (m) {
1283 return m[1];
1284 }
1285
1286 return null;
1287}
1288
1289function indexOf(xs, x) {
1290 if (xs.indexOf) {
1291 return xs.indexOf(x);
1292 }
1293
1294 for (var i = 0, l = xs.length; i < l; i++) {
1295 if (xs[i] === x) {
1296 return i;
1297 }
1298 }
1299
1300 return -1;
1301}
1302
1303function isMap(x) {
1304 if (!mapSize || !x || _typeof(x) !== 'object') {
1305 return false;
1306 }
1307
1308 try {
1309 mapSize.call(x);
1310
1311 try {
1312 setSize.call(x);
1313 } catch (s) {
1314 return true;
1315 }
1316
1317 return x instanceof Map;
1318 } catch (e) {}
1319
1320 return false;
1321}
1322
1323function isWeakMap(x) {
1324 if (!weakMapHas || !x || _typeof(x) !== 'object') {
1325 return false;
1326 }
1327
1328 try {
1329 weakMapHas.call(x, weakMapHas);
1330
1331 try {
1332 weakSetHas.call(x, weakSetHas);
1333 } catch (s) {
1334 return true;
1335 }
1336
1337 return x instanceof WeakMap;
1338 } catch (e) {}
1339
1340 return false;
1341}
1342
1343function isWeakRef(x) {
1344 if (!weakRefDeref || !x || _typeof(x) !== 'object') {
1345 return false;
1346 }
1347
1348 try {
1349 weakRefDeref.call(x);
1350 return true;
1351 } catch (e) {}
1352
1353 return false;
1354}
1355
1356function isSet(x) {
1357 if (!setSize || !x || _typeof(x) !== 'object') {
1358 return false;
1359 }
1360
1361 try {
1362 setSize.call(x);
1363
1364 try {
1365 mapSize.call(x);
1366 } catch (m) {
1367 return true;
1368 }
1369
1370 return x instanceof Set;
1371 } catch (e) {}
1372
1373 return false;
1374}
1375
1376function isWeakSet(x) {
1377 if (!weakSetHas || !x || _typeof(x) !== 'object') {
1378 return false;
1379 }
1380
1381 try {
1382 weakSetHas.call(x, weakSetHas);
1383
1384 try {
1385 weakMapHas.call(x, weakMapHas);
1386 } catch (s) {
1387 return true;
1388 }
1389
1390 return x instanceof WeakSet;
1391 } catch (e) {}
1392
1393 return false;
1394}
1395
1396function isElement(x) {
1397 if (!x || _typeof(x) !== 'object') {
1398 return false;
1399 }
1400
1401 if (typeof HTMLElement !== 'undefined' && x instanceof HTMLElement) {
1402 return true;
1403 }
1404
1405 return typeof x.nodeName === 'string' && typeof x.getAttribute === 'function';
1406}
1407
1408function inspectString(str, opts) {
1409 if (str.length > opts.maxStringLength) {
1410 var remaining = str.length - opts.maxStringLength;
1411 var trailer = '... ' + remaining + ' more character' + (remaining > 1 ? 's' : '');
1412 return inspectString($slice.call(str, 0, opts.maxStringLength), opts) + trailer;
1413 }
1414
1415 var s = $replace.call($replace.call(str, /(['\\])/g, '\\$1'), /[\x00-\x1f]/g, lowbyte);
1416 return wrapQuotes(s, 'single', opts);
1417}
1418
1419function lowbyte(c) {
1420 var n = c.charCodeAt(0);
1421 var x = {
1422 8: 'b',
1423 9: 't',
1424 10: 'n',
1425 12: 'f',
1426 13: 'r'
1427 }[n];
1428
1429 if (x) {
1430 return '\\' + x;
1431 }
1432
1433 return '\\x' + (n < 0x10 ? '0' : '') + $toUpperCase.call(n.toString(16));
1434}
1435
1436function markBoxed(str) {
1437 return 'Object(' + str + ')';
1438}
1439
1440function weakCollectionOf(type) {
1441 return type + ' { ? }';
1442}
1443
1444function collectionOf(type, size, entries, indent) {
1445 var joinedEntries = indent ? indentedJoin(entries, indent) : $join.call(entries, ', ');
1446 return type + ' (' + size + ') {' + joinedEntries + '}';
1447}
1448
1449function singleLineValues(xs) {
1450 for (var i = 0; i < xs.length; i++) {
1451 if (indexOf(xs[i], '\n') >= 0) {
1452 return false;
1453 }
1454 }
1455
1456 return true;
1457}
1458
1459function getIndent(opts, depth) {
1460 var baseIndent;
1461
1462 if (opts.indent === '\t') {
1463 baseIndent = '\t';
1464 } else if (typeof opts.indent === 'number' && opts.indent > 0) {
1465 baseIndent = $join.call(Array(opts.indent + 1), ' ');
1466 } else {
1467 return null;
1468 }
1469
1470 return {
1471 base: baseIndent,
1472 prev: $join.call(Array(depth + 1), baseIndent)
1473 };
1474}
1475
1476function indentedJoin(xs, indent) {
1477 if (xs.length === 0) {
1478 return '';
1479 }
1480
1481 var lineJoiner = '\n' + indent.prev + indent.base;
1482 return lineJoiner + $join.call(xs, ',' + lineJoiner) + '\n' + indent.prev;
1483}
1484
1485function arrObjKeys(obj, inspect) {
1486 var isArr = isArray(obj);
1487 var xs = [];
1488
1489 if (isArr) {
1490 xs.length = obj.length;
1491
1492 for (var i = 0; i < obj.length; i++) {
1493 xs[i] = has(obj, i) ? inspect(obj[i], obj) : '';
1494 }
1495 }
1496
1497 var syms = typeof gOPS === 'function' ? gOPS(obj) : [];
1498 var symMap;
1499
1500 if (hasShammedSymbols) {
1501 symMap = {};
1502
1503 for (var k = 0; k < syms.length; k++) {
1504 symMap['$' + syms[k]] = syms[k];
1505 }
1506 }
1507
1508 for (var key in obj) {
1509 if (!has(obj, key)) {
1510 continue;
1511 }
1512
1513 if (isArr && String(Number(key)) === key && key < obj.length) {
1514 continue;
1515 }
1516
1517 if (hasShammedSymbols && symMap['$' + key] instanceof Symbol) {
1518 continue;
1519 } else if ($test.call(/[^\w$]/, key)) {
1520 xs.push(inspect(key, obj) + ': ' + inspect(obj[key], obj));
1521 } else {
1522 xs.push(key + ': ' + inspect(obj[key], obj));
1523 }
1524 }
1525
1526 if (typeof gOPS === 'function') {
1527 for (var j = 0; j < syms.length; j++) {
1528 if (isEnumerable.call(obj, syms[j])) {
1529 xs.push('[' + inspect(syms[j]) + ']: ' + inspect(obj[syms[j]], obj));
1530 }
1531 }
1532 }
1533
1534 return xs;
1535}
1536
1537},{"./util.inspect":1}],13:[function(require,module,exports){
1538"use strict";
1539
1540var process = module.exports = {};
1541var cachedSetTimeout;
1542var cachedClearTimeout;
1543
1544function defaultSetTimout() {
1545 throw new Error('setTimeout has not been defined');
1546}
1547
1548function defaultClearTimeout() {
1549 throw new Error('clearTimeout has not been defined');
1550}
1551
1552(function () {
1553 try {
1554 if (typeof setTimeout === 'function') {
1555 cachedSetTimeout = setTimeout;
1556 } else {
1557 cachedSetTimeout = defaultSetTimout;
1558 }
1559 } catch (e) {
1560 cachedSetTimeout = defaultSetTimout;
1561 }
1562
1563 try {
1564 if (typeof clearTimeout === 'function') {
1565 cachedClearTimeout = clearTimeout;
1566 } else {
1567 cachedClearTimeout = defaultClearTimeout;
1568 }
1569 } catch (e) {
1570 cachedClearTimeout = defaultClearTimeout;
1571 }
1572})();
1573
1574function runTimeout(fun) {
1575 if (cachedSetTimeout === setTimeout) {
1576 return setTimeout(fun, 0);
1577 }
1578
1579 if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
1580 cachedSetTimeout = setTimeout;
1581 return setTimeout(fun, 0);
1582 }
1583
1584 try {
1585 return cachedSetTimeout(fun, 0);
1586 } catch (e) {
1587 try {
1588 return cachedSetTimeout.call(null, fun, 0);
1589 } catch (e) {
1590 return cachedSetTimeout.call(this, fun, 0);
1591 }
1592 }
1593}
1594
1595function runClearTimeout(marker) {
1596 if (cachedClearTimeout === clearTimeout) {
1597 return clearTimeout(marker);
1598 }
1599
1600 if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
1601 cachedClearTimeout = clearTimeout;
1602 return clearTimeout(marker);
1603 }
1604
1605 try {
1606 return cachedClearTimeout(marker);
1607 } catch (e) {
1608 try {
1609 return cachedClearTimeout.call(null, marker);
1610 } catch (e) {
1611 return cachedClearTimeout.call(this, marker);
1612 }
1613 }
1614}
1615
1616var queue = [];
1617var draining = false;
1618var currentQueue;
1619var queueIndex = -1;
1620
1621function cleanUpNextTick() {
1622 if (!draining || !currentQueue) {
1623 return;
1624 }
1625
1626 draining = false;
1627
1628 if (currentQueue.length) {
1629 queue = currentQueue.concat(queue);
1630 } else {
1631 queueIndex = -1;
1632 }
1633
1634 if (queue.length) {
1635 drainQueue();
1636 }
1637}
1638
1639function drainQueue() {
1640 if (draining) {
1641 return;
1642 }
1643
1644 var timeout = runTimeout(cleanUpNextTick);
1645 draining = true;
1646 var len = queue.length;
1647
1648 while (len) {
1649 currentQueue = queue;
1650 queue = [];
1651
1652 while (++queueIndex < len) {
1653 if (currentQueue) {
1654 currentQueue[queueIndex].run();
1655 }
1656 }
1657
1658 queueIndex = -1;
1659 len = queue.length;
1660 }
1661
1662 currentQueue = null;
1663 draining = false;
1664 runClearTimeout(timeout);
1665}
1666
1667process.nextTick = function (fun) {
1668 var args = new Array(arguments.length - 1);
1669
1670 if (arguments.length > 1) {
1671 for (var i = 1; i < arguments.length; i++) {
1672 args[i - 1] = arguments[i];
1673 }
1674 }
1675
1676 queue.push(new Item(fun, args));
1677
1678 if (queue.length === 1 && !draining) {
1679 runTimeout(drainQueue);
1680 }
1681};
1682
1683function Item(fun, array) {
1684 this.fun = fun;
1685 this.array = array;
1686}
1687
1688Item.prototype.run = function () {
1689 this.fun.apply(null, this.array);
1690};
1691
1692process.title = 'browser';
1693process.browser = true;
1694process.env = {};
1695process.argv = [];
1696process.version = '';
1697process.versions = {};
1698
1699function noop() {}
1700
1701process.on = noop;
1702process.addListener = noop;
1703process.once = noop;
1704process.off = noop;
1705process.removeListener = noop;
1706process.removeAllListeners = noop;
1707process.emit = noop;
1708process.prependListener = noop;
1709process.prependOnceListener = noop;
1710
1711process.listeners = function (name) {
1712 return [];
1713};
1714
1715process.binding = function (name) {
1716 throw new Error('process.binding is not supported');
1717};
1718
1719process.cwd = function () {
1720 return '/';
1721};
1722
1723process.chdir = function (dir) {
1724 throw new Error('process.chdir is not supported');
1725};
1726
1727process.umask = function () {
1728 return 0;
1729};
1730
1731},{}],14:[function(require,module,exports){
1732'use strict';
1733
1734var replace = String.prototype.replace;
1735var percentTwenties = /%20/g;
1736var Format = {
1737 RFC1738: 'RFC1738',
1738 RFC3986: 'RFC3986'
1739};
1740module.exports = {
1741 'default': Format.RFC3986,
1742 formatters: {
1743 RFC1738: function RFC1738(value) {
1744 return replace.call(value, percentTwenties, '+');
1745 },
1746 RFC3986: function RFC3986(value) {
1747 return String(value);
1748 }
1749 },
1750 RFC1738: Format.RFC1738,
1751 RFC3986: Format.RFC3986
1752};
1753
1754},{}],15:[function(require,module,exports){
1755'use strict';
1756
1757var stringify = require('./stringify');
1758
1759var parse = require('./parse');
1760
1761var formats = require('./formats');
1762
1763module.exports = {
1764 formats: formats,
1765 parse: parse,
1766 stringify: stringify
1767};
1768
1769},{"./formats":14,"./parse":16,"./stringify":17}],16:[function(require,module,exports){
1770'use strict';
1771
1772var utils = require('./utils');
1773
1774var has = Object.prototype.hasOwnProperty;
1775var isArray = Array.isArray;
1776var defaults = {
1777 allowDots: false,
1778 allowPrototypes: false,
1779 allowSparse: false,
1780 arrayLimit: 20,
1781 charset: 'utf-8',
1782 charsetSentinel: false,
1783 comma: false,
1784 decoder: utils.decode,
1785 delimiter: '&',
1786 depth: 5,
1787 ignoreQueryPrefix: false,
1788 interpretNumericEntities: false,
1789 parameterLimit: 1000,
1790 parseArrays: true,
1791 plainObjects: false,
1792 strictNullHandling: false
1793};
1794
1795var interpretNumericEntities = function interpretNumericEntities(str) {
1796 return str.replace(/&#(\d+);/g, function ($0, numberStr) {
1797 return String.fromCharCode(parseInt(numberStr, 10));
1798 });
1799};
1800
1801var parseArrayValue = function parseArrayValue(val, options) {
1802 if (val && typeof val === 'string' && options.comma && val.indexOf(',') > -1) {
1803 return val.split(',');
1804 }
1805
1806 return val;
1807};
1808
1809var isoSentinel = 'utf8=%26%2310003%3B';
1810var charsetSentinel = 'utf8=%E2%9C%93';
1811
1812var parseValues = function parseQueryStringValues(str, options) {
1813 var obj = {};
1814 var cleanStr = options.ignoreQueryPrefix ? str.replace(/^\?/, '') : str;
1815 var limit = options.parameterLimit === Infinity ? undefined : options.parameterLimit;
1816 var parts = cleanStr.split(options.delimiter, limit);
1817 var skipIndex = -1;
1818 var i;
1819 var charset = options.charset;
1820
1821 if (options.charsetSentinel) {
1822 for (i = 0; i < parts.length; ++i) {
1823 if (parts[i].indexOf('utf8=') === 0) {
1824 if (parts[i] === charsetSentinel) {
1825 charset = 'utf-8';
1826 } else if (parts[i] === isoSentinel) {
1827 charset = 'iso-8859-1';
1828 }
1829
1830 skipIndex = i;
1831 i = parts.length;
1832 }
1833 }
1834 }
1835
1836 for (i = 0; i < parts.length; ++i) {
1837 if (i === skipIndex) {
1838 continue;
1839 }
1840
1841 var part = parts[i];
1842 var bracketEqualsPos = part.indexOf(']=');
1843 var pos = bracketEqualsPos === -1 ? part.indexOf('=') : bracketEqualsPos + 1;
1844 var key, val;
1845
1846 if (pos === -1) {
1847 key = options.decoder(part, defaults.decoder, charset, 'key');
1848 val = options.strictNullHandling ? null : '';
1849 } else {
1850 key = options.decoder(part.slice(0, pos), defaults.decoder, charset, 'key');
1851 val = utils.maybeMap(parseArrayValue(part.slice(pos + 1), options), function (encodedVal) {
1852 return options.decoder(encodedVal, defaults.decoder, charset, 'value');
1853 });
1854 }
1855
1856 if (val && options.interpretNumericEntities && charset === 'iso-8859-1') {
1857 val = interpretNumericEntities(val);
1858 }
1859
1860 if (part.indexOf('[]=') > -1) {
1861 val = isArray(val) ? [val] : val;
1862 }
1863
1864 if (has.call(obj, key)) {
1865 obj[key] = utils.combine(obj[key], val);
1866 } else {
1867 obj[key] = val;
1868 }
1869 }
1870
1871 return obj;
1872};
1873
1874var parseObject = function parseObject(chain, val, options, valuesParsed) {
1875 var leaf = valuesParsed ? val : parseArrayValue(val, options);
1876
1877 for (var i = chain.length - 1; i >= 0; --i) {
1878 var obj;
1879 var root = chain[i];
1880
1881 if (root === '[]' && options.parseArrays) {
1882 obj = [].concat(leaf);
1883 } else {
1884 obj = options.plainObjects ? Object.create(null) : {};
1885 var cleanRoot = root.charAt(0) === '[' && root.charAt(root.length - 1) === ']' ? root.slice(1, -1) : root;
1886 var index = parseInt(cleanRoot, 10);
1887
1888 if (!options.parseArrays && cleanRoot === '') {
1889 obj = {
1890 0: leaf
1891 };
1892 } else if (!isNaN(index) && root !== cleanRoot && String(index) === cleanRoot && index >= 0 && options.parseArrays && index <= options.arrayLimit) {
1893 obj = [];
1894 obj[index] = leaf;
1895 } else {
1896 obj[cleanRoot] = leaf;
1897 }
1898 }
1899
1900 leaf = obj;
1901 }
1902
1903 return leaf;
1904};
1905
1906var parseKeys = function parseQueryStringKeys(givenKey, val, options, valuesParsed) {
1907 if (!givenKey) {
1908 return;
1909 }
1910
1911 var key = options.allowDots ? givenKey.replace(/\.([^.[]+)/g, '[$1]') : givenKey;
1912 var brackets = /(\[[^[\]]*])/;
1913 var child = /(\[[^[\]]*])/g;
1914 var segment = options.depth > 0 && brackets.exec(key);
1915 var parent = segment ? key.slice(0, segment.index) : key;
1916 var keys = [];
1917
1918 if (parent) {
1919 if (!options.plainObjects && has.call(Object.prototype, parent)) {
1920 if (!options.allowPrototypes) {
1921 return;
1922 }
1923 }
1924
1925 keys.push(parent);
1926 }
1927
1928 var i = 0;
1929
1930 while (options.depth > 0 && (segment = child.exec(key)) !== null && i < options.depth) {
1931 i += 1;
1932
1933 if (!options.plainObjects && has.call(Object.prototype, segment[1].slice(1, -1))) {
1934 if (!options.allowPrototypes) {
1935 return;
1936 }
1937 }
1938
1939 keys.push(segment[1]);
1940 }
1941
1942 if (segment) {
1943 keys.push('[' + key.slice(segment.index) + ']');
1944 }
1945
1946 return parseObject(keys, val, options, valuesParsed);
1947};
1948
1949var normalizeParseOptions = function normalizeParseOptions(opts) {
1950 if (!opts) {
1951 return defaults;
1952 }
1953
1954 if (opts.decoder !== null && opts.decoder !== undefined && typeof opts.decoder !== 'function') {
1955 throw new TypeError('Decoder has to be a function.');
1956 }
1957
1958 if (typeof opts.charset !== 'undefined' && opts.charset !== 'utf-8' && opts.charset !== 'iso-8859-1') {
1959 throw new TypeError('The charset option must be either utf-8, iso-8859-1, or undefined');
1960 }
1961
1962 var charset = typeof opts.charset === 'undefined' ? defaults.charset : opts.charset;
1963 return {
1964 allowDots: typeof opts.allowDots === 'undefined' ? defaults.allowDots : !!opts.allowDots,
1965 allowPrototypes: typeof opts.allowPrototypes === 'boolean' ? opts.allowPrototypes : defaults.allowPrototypes,
1966 allowSparse: typeof opts.allowSparse === 'boolean' ? opts.allowSparse : defaults.allowSparse,
1967 arrayLimit: typeof opts.arrayLimit === 'number' ? opts.arrayLimit : defaults.arrayLimit,
1968 charset: charset,
1969 charsetSentinel: typeof opts.charsetSentinel === 'boolean' ? opts.charsetSentinel : defaults.charsetSentinel,
1970 comma: typeof opts.comma === 'boolean' ? opts.comma : defaults.comma,
1971 decoder: typeof opts.decoder === 'function' ? opts.decoder : defaults.decoder,
1972 delimiter: typeof opts.delimiter === 'string' || utils.isRegExp(opts.delimiter) ? opts.delimiter : defaults.delimiter,
1973 depth: typeof opts.depth === 'number' || opts.depth === false ? +opts.depth : defaults.depth,
1974 ignoreQueryPrefix: opts.ignoreQueryPrefix === true,
1975 interpretNumericEntities: typeof opts.interpretNumericEntities === 'boolean' ? opts.interpretNumericEntities : defaults.interpretNumericEntities,
1976 parameterLimit: typeof opts.parameterLimit === 'number' ? opts.parameterLimit : defaults.parameterLimit,
1977 parseArrays: opts.parseArrays !== false,
1978 plainObjects: typeof opts.plainObjects === 'boolean' ? opts.plainObjects : defaults.plainObjects,
1979 strictNullHandling: typeof opts.strictNullHandling === 'boolean' ? opts.strictNullHandling : defaults.strictNullHandling
1980 };
1981};
1982
1983module.exports = function (str, opts) {
1984 var options = normalizeParseOptions(opts);
1985
1986 if (str === '' || str === null || typeof str === 'undefined') {
1987 return options.plainObjects ? Object.create(null) : {};
1988 }
1989
1990 var tempObj = typeof str === 'string' ? parseValues(str, options) : str;
1991 var obj = options.plainObjects ? Object.create(null) : {};
1992 var keys = Object.keys(tempObj);
1993
1994 for (var i = 0; i < keys.length; ++i) {
1995 var key = keys[i];
1996 var newObj = parseKeys(key, tempObj[key], options, typeof str === 'string');
1997 obj = utils.merge(obj, newObj, options);
1998 }
1999
2000 if (options.allowSparse === true) {
2001 return obj;
2002 }
2003
2004 return utils.compact(obj);
2005};
2006
2007},{"./utils":18}],17:[function(require,module,exports){
2008'use strict';
2009
2010function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2011
2012var getSideChannel = require('side-channel');
2013
2014var utils = require('./utils');
2015
2016var formats = require('./formats');
2017
2018var has = Object.prototype.hasOwnProperty;
2019var arrayPrefixGenerators = {
2020 brackets: function brackets(prefix) {
2021 return prefix + '[]';
2022 },
2023 comma: 'comma',
2024 indices: function indices(prefix, key) {
2025 return prefix + '[' + key + ']';
2026 },
2027 repeat: function repeat(prefix) {
2028 return prefix;
2029 }
2030};
2031var isArray = Array.isArray;
2032var split = String.prototype.split;
2033var push = Array.prototype.push;
2034
2035var pushToArray = function pushToArray(arr, valueOrArray) {
2036 push.apply(arr, isArray(valueOrArray) ? valueOrArray : [valueOrArray]);
2037};
2038
2039var toISO = Date.prototype.toISOString;
2040var defaultFormat = formats['default'];
2041var defaults = {
2042 addQueryPrefix: false,
2043 allowDots: false,
2044 charset: 'utf-8',
2045 charsetSentinel: false,
2046 delimiter: '&',
2047 encode: true,
2048 encoder: utils.encode,
2049 encodeValuesOnly: false,
2050 format: defaultFormat,
2051 formatter: formats.formatters[defaultFormat],
2052 indices: false,
2053 serializeDate: function serializeDate(date) {
2054 return toISO.call(date);
2055 },
2056 skipNulls: false,
2057 strictNullHandling: false
2058};
2059
2060var isNonNullishPrimitive = function isNonNullishPrimitive(v) {
2061 return typeof v === 'string' || typeof v === 'number' || typeof v === 'boolean' || _typeof(v) === 'symbol' || typeof v === 'bigint';
2062};
2063
2064var sentinel = {};
2065
2066var stringify = function stringify(object, prefix, generateArrayPrefix, strictNullHandling, skipNulls, encoder, filter, sort, allowDots, serializeDate, format, formatter, encodeValuesOnly, charset, sideChannel) {
2067 var obj = object;
2068 var tmpSc = sideChannel;
2069 var step = 0;
2070 var findFlag = false;
2071
2072 while ((tmpSc = tmpSc.get(sentinel)) !== undefined && !findFlag) {
2073 var pos = tmpSc.get(object);
2074 step += 1;
2075
2076 if (typeof pos !== 'undefined') {
2077 if (pos === step) {
2078 throw new RangeError('Cyclic object value');
2079 } else {
2080 findFlag = true;
2081 }
2082 }
2083
2084 if (typeof tmpSc.get(sentinel) === 'undefined') {
2085 step = 0;
2086 }
2087 }
2088
2089 if (typeof filter === 'function') {
2090 obj = filter(prefix, obj);
2091 } else if (obj instanceof Date) {
2092 obj = serializeDate(obj);
2093 } else if (generateArrayPrefix === 'comma' && isArray(obj)) {
2094 obj = utils.maybeMap(obj, function (value) {
2095 if (value instanceof Date) {
2096 return serializeDate(value);
2097 }
2098
2099 return value;
2100 });
2101 }
2102
2103 if (obj === null) {
2104 if (strictNullHandling) {
2105 return encoder && !encodeValuesOnly ? encoder(prefix, defaults.encoder, charset, 'key', format) : prefix;
2106 }
2107
2108 obj = '';
2109 }
2110
2111 if (isNonNullishPrimitive(obj) || utils.isBuffer(obj)) {
2112 if (encoder) {
2113 var keyValue = encodeValuesOnly ? prefix : encoder(prefix, defaults.encoder, charset, 'key', format);
2114
2115 if (generateArrayPrefix === 'comma' && encodeValuesOnly) {
2116 var valuesArray = split.call(String(obj), ',');
2117 var valuesJoined = '';
2118
2119 for (var i = 0; i < valuesArray.length; ++i) {
2120 valuesJoined += (i === 0 ? '' : ',') + formatter(encoder(valuesArray[i], defaults.encoder, charset, 'value', format));
2121 }
2122
2123 return [formatter(keyValue) + '=' + valuesJoined];
2124 }
2125
2126 return [formatter(keyValue) + '=' + formatter(encoder(obj, defaults.encoder, charset, 'value', format))];
2127 }
2128
2129 return [formatter(prefix) + '=' + formatter(String(obj))];
2130 }
2131
2132 var values = [];
2133
2134 if (typeof obj === 'undefined') {
2135 return values;
2136 }
2137
2138 var objKeys;
2139
2140 if (generateArrayPrefix === 'comma' && isArray(obj)) {
2141 objKeys = [{
2142 value: obj.length > 0 ? obj.join(',') || null : undefined
2143 }];
2144 } else if (isArray(filter)) {
2145 objKeys = filter;
2146 } else {
2147 var keys = Object.keys(obj);
2148 objKeys = sort ? keys.sort(sort) : keys;
2149 }
2150
2151 for (var j = 0; j < objKeys.length; ++j) {
2152 var key = objKeys[j];
2153 var value = _typeof(key) === 'object' && key.value !== undefined ? key.value : obj[key];
2154
2155 if (skipNulls && value === null) {
2156 continue;
2157 }
2158
2159 var keyPrefix = isArray(obj) ? typeof generateArrayPrefix === 'function' ? generateArrayPrefix(prefix, key) : prefix : prefix + (allowDots ? '.' + key : '[' + key + ']');
2160 sideChannel.set(object, step);
2161 var valueSideChannel = getSideChannel();
2162 valueSideChannel.set(sentinel, sideChannel);
2163 pushToArray(values, stringify(value, keyPrefix, generateArrayPrefix, strictNullHandling, skipNulls, encoder, filter, sort, allowDots, serializeDate, format, formatter, encodeValuesOnly, charset, valueSideChannel));
2164 }
2165
2166 return values;
2167};
2168
2169var normalizeStringifyOptions = function normalizeStringifyOptions(opts) {
2170 if (!opts) {
2171 return defaults;
2172 }
2173
2174 if (opts.encoder !== null && opts.encoder !== undefined && typeof opts.encoder !== 'function') {
2175 throw new TypeError('Encoder has to be a function.');
2176 }
2177
2178 var charset = opts.charset || defaults.charset;
2179
2180 if (typeof opts.charset !== 'undefined' && opts.charset !== 'utf-8' && opts.charset !== 'iso-8859-1') {
2181 throw new TypeError('The charset option must be either utf-8, iso-8859-1, or undefined');
2182 }
2183
2184 var format = formats['default'];
2185
2186 if (typeof opts.format !== 'undefined') {
2187 if (!has.call(formats.formatters, opts.format)) {
2188 throw new TypeError('Unknown format option provided.');
2189 }
2190
2191 format = opts.format;
2192 }
2193
2194 var formatter = formats.formatters[format];
2195 var filter = defaults.filter;
2196
2197 if (typeof opts.filter === 'function' || isArray(opts.filter)) {
2198 filter = opts.filter;
2199 }
2200
2201 return {
2202 addQueryPrefix: typeof opts.addQueryPrefix === 'boolean' ? opts.addQueryPrefix : defaults.addQueryPrefix,
2203 allowDots: typeof opts.allowDots === 'undefined' ? defaults.allowDots : !!opts.allowDots,
2204 charset: charset,
2205 charsetSentinel: typeof opts.charsetSentinel === 'boolean' ? opts.charsetSentinel : defaults.charsetSentinel,
2206 delimiter: typeof opts.delimiter === 'undefined' ? defaults.delimiter : opts.delimiter,
2207 encode: typeof opts.encode === 'boolean' ? opts.encode : defaults.encode,
2208 encoder: typeof opts.encoder === 'function' ? opts.encoder : defaults.encoder,
2209 encodeValuesOnly: typeof opts.encodeValuesOnly === 'boolean' ? opts.encodeValuesOnly : defaults.encodeValuesOnly,
2210 filter: filter,
2211 format: format,
2212 formatter: formatter,
2213 serializeDate: typeof opts.serializeDate === 'function' ? opts.serializeDate : defaults.serializeDate,
2214 skipNulls: typeof opts.skipNulls === 'boolean' ? opts.skipNulls : defaults.skipNulls,
2215 sort: typeof opts.sort === 'function' ? opts.sort : null,
2216 strictNullHandling: typeof opts.strictNullHandling === 'boolean' ? opts.strictNullHandling : defaults.strictNullHandling
2217 };
2218};
2219
2220module.exports = function (object, opts) {
2221 var obj = object;
2222 var options = normalizeStringifyOptions(opts);
2223 var objKeys;
2224 var filter;
2225
2226 if (typeof options.filter === 'function') {
2227 filter = options.filter;
2228 obj = filter('', obj);
2229 } else if (isArray(options.filter)) {
2230 filter = options.filter;
2231 objKeys = filter;
2232 }
2233
2234 var keys = [];
2235
2236 if (_typeof(obj) !== 'object' || obj === null) {
2237 return '';
2238 }
2239
2240 var arrayFormat;
2241
2242 if (opts && opts.arrayFormat in arrayPrefixGenerators) {
2243 arrayFormat = opts.arrayFormat;
2244 } else if (opts && 'indices' in opts) {
2245 arrayFormat = opts.indices ? 'indices' : 'repeat';
2246 } else {
2247 arrayFormat = 'indices';
2248 }
2249
2250 var generateArrayPrefix = arrayPrefixGenerators[arrayFormat];
2251
2252 if (!objKeys) {
2253 objKeys = Object.keys(obj);
2254 }
2255
2256 if (options.sort) {
2257 objKeys.sort(options.sort);
2258 }
2259
2260 var sideChannel = getSideChannel();
2261
2262 for (var i = 0; i < objKeys.length; ++i) {
2263 var key = objKeys[i];
2264
2265 if (options.skipNulls && obj[key] === null) {
2266 continue;
2267 }
2268
2269 pushToArray(keys, stringify(obj[key], key, generateArrayPrefix, options.strictNullHandling, options.skipNulls, options.encode ? options.encoder : null, options.filter, options.sort, options.allowDots, options.serializeDate, options.format, options.formatter, options.encodeValuesOnly, options.charset, sideChannel));
2270 }
2271
2272 var joined = keys.join(options.delimiter);
2273 var prefix = options.addQueryPrefix === true ? '?' : '';
2274
2275 if (options.charsetSentinel) {
2276 if (options.charset === 'iso-8859-1') {
2277 prefix += 'utf8=%26%2310003%3B&';
2278 } else {
2279 prefix += 'utf8=%E2%9C%93&';
2280 }
2281 }
2282
2283 return joined.length > 0 ? prefix + joined : '';
2284};
2285
2286},{"./formats":14,"./utils":18,"side-channel":19}],18:[function(require,module,exports){
2287'use strict';
2288
2289function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2290
2291var formats = require('./formats');
2292
2293var has = Object.prototype.hasOwnProperty;
2294var isArray = Array.isArray;
2295
2296var hexTable = function () {
2297 var array = [];
2298
2299 for (var i = 0; i < 256; ++i) {
2300 array.push('%' + ((i < 16 ? '0' : '') + i.toString(16)).toUpperCase());
2301 }
2302
2303 return array;
2304}();
2305
2306var compactQueue = function compactQueue(queue) {
2307 while (queue.length > 1) {
2308 var item = queue.pop();
2309 var obj = item.obj[item.prop];
2310
2311 if (isArray(obj)) {
2312 var compacted = [];
2313
2314 for (var j = 0; j < obj.length; ++j) {
2315 if (typeof obj[j] !== 'undefined') {
2316 compacted.push(obj[j]);
2317 }
2318 }
2319
2320 item.obj[item.prop] = compacted;
2321 }
2322 }
2323};
2324
2325var arrayToObject = function arrayToObject(source, options) {
2326 var obj = options && options.plainObjects ? Object.create(null) : {};
2327
2328 for (var i = 0; i < source.length; ++i) {
2329 if (typeof source[i] !== 'undefined') {
2330 obj[i] = source[i];
2331 }
2332 }
2333
2334 return obj;
2335};
2336
2337var merge = function merge(target, source, options) {
2338 if (!source) {
2339 return target;
2340 }
2341
2342 if (_typeof(source) !== 'object') {
2343 if (isArray(target)) {
2344 target.push(source);
2345 } else if (target && _typeof(target) === 'object') {
2346 if (options && (options.plainObjects || options.allowPrototypes) || !has.call(Object.prototype, source)) {
2347 target[source] = true;
2348 }
2349 } else {
2350 return [target, source];
2351 }
2352
2353 return target;
2354 }
2355
2356 if (!target || _typeof(target) !== 'object') {
2357 return [target].concat(source);
2358 }
2359
2360 var mergeTarget = target;
2361
2362 if (isArray(target) && !isArray(source)) {
2363 mergeTarget = arrayToObject(target, options);
2364 }
2365
2366 if (isArray(target) && isArray(source)) {
2367 source.forEach(function (item, i) {
2368 if (has.call(target, i)) {
2369 var targetItem = target[i];
2370
2371 if (targetItem && _typeof(targetItem) === 'object' && item && _typeof(item) === 'object') {
2372 target[i] = merge(targetItem, item, options);
2373 } else {
2374 target.push(item);
2375 }
2376 } else {
2377 target[i] = item;
2378 }
2379 });
2380 return target;
2381 }
2382
2383 return Object.keys(source).reduce(function (acc, key) {
2384 var value = source[key];
2385
2386 if (has.call(acc, key)) {
2387 acc[key] = merge(acc[key], value, options);
2388 } else {
2389 acc[key] = value;
2390 }
2391
2392 return acc;
2393 }, mergeTarget);
2394};
2395
2396var assign = function assignSingleSource(target, source) {
2397 return Object.keys(source).reduce(function (acc, key) {
2398 acc[key] = source[key];
2399 return acc;
2400 }, target);
2401};
2402
2403var decode = function decode(str, decoder, charset) {
2404 var strWithoutPlus = str.replace(/\+/g, ' ');
2405
2406 if (charset === 'iso-8859-1') {
2407 return strWithoutPlus.replace(/%[0-9a-f]{2}/gi, unescape);
2408 }
2409
2410 try {
2411 return decodeURIComponent(strWithoutPlus);
2412 } catch (e) {
2413 return strWithoutPlus;
2414 }
2415};
2416
2417var encode = function encode(str, defaultEncoder, charset, kind, format) {
2418 if (str.length === 0) {
2419 return str;
2420 }
2421
2422 var string = str;
2423
2424 if (_typeof(str) === 'symbol') {
2425 string = Symbol.prototype.toString.call(str);
2426 } else if (typeof str !== 'string') {
2427 string = String(str);
2428 }
2429
2430 if (charset === 'iso-8859-1') {
2431 return escape(string).replace(/%u[0-9a-f]{4}/gi, function ($0) {
2432 return '%26%23' + parseInt($0.slice(2), 16) + '%3B';
2433 });
2434 }
2435
2436 var out = '';
2437
2438 for (var i = 0; i < string.length; ++i) {
2439 var c = string.charCodeAt(i);
2440
2441 if (c === 0x2D || c === 0x2E || c === 0x5F || c === 0x7E || c >= 0x30 && c <= 0x39 || c >= 0x41 && c <= 0x5A || c >= 0x61 && c <= 0x7A || format === formats.RFC1738 && (c === 0x28 || c === 0x29)) {
2442 out += string.charAt(i);
2443 continue;
2444 }
2445
2446 if (c < 0x80) {
2447 out = out + hexTable[c];
2448 continue;
2449 }
2450
2451 if (c < 0x800) {
2452 out = out + (hexTable[0xC0 | c >> 6] + hexTable[0x80 | c & 0x3F]);
2453 continue;
2454 }
2455
2456 if (c < 0xD800 || c >= 0xE000) {
2457 out = out + (hexTable[0xE0 | c >> 12] + hexTable[0x80 | c >> 6 & 0x3F] + hexTable[0x80 | c & 0x3F]);
2458 continue;
2459 }
2460
2461 i += 1;
2462 c = 0x10000 + ((c & 0x3FF) << 10 | string.charCodeAt(i) & 0x3FF);
2463 out += hexTable[0xF0 | c >> 18] + hexTable[0x80 | c >> 12 & 0x3F] + hexTable[0x80 | c >> 6 & 0x3F] + hexTable[0x80 | c & 0x3F];
2464 }
2465
2466 return out;
2467};
2468
2469var compact = function compact(value) {
2470 var queue = [{
2471 obj: {
2472 o: value
2473 },
2474 prop: 'o'
2475 }];
2476 var refs = [];
2477
2478 for (var i = 0; i < queue.length; ++i) {
2479 var item = queue[i];
2480 var obj = item.obj[item.prop];
2481 var keys = Object.keys(obj);
2482
2483 for (var j = 0; j < keys.length; ++j) {
2484 var key = keys[j];
2485 var val = obj[key];
2486
2487 if (_typeof(val) === 'object' && val !== null && refs.indexOf(val) === -1) {
2488 queue.push({
2489 obj: obj,
2490 prop: key
2491 });
2492 refs.push(val);
2493 }
2494 }
2495 }
2496
2497 compactQueue(queue);
2498 return value;
2499};
2500
2501var isRegExp = function isRegExp(obj) {
2502 return Object.prototype.toString.call(obj) === '[object RegExp]';
2503};
2504
2505var isBuffer = function isBuffer(obj) {
2506 if (!obj || _typeof(obj) !== 'object') {
2507 return false;
2508 }
2509
2510 return !!(obj.constructor && obj.constructor.isBuffer && obj.constructor.isBuffer(obj));
2511};
2512
2513var combine = function combine(a, b) {
2514 return [].concat(a, b);
2515};
2516
2517var maybeMap = function maybeMap(val, fn) {
2518 if (isArray(val)) {
2519 var mapped = [];
2520
2521 for (var i = 0; i < val.length; i += 1) {
2522 mapped.push(fn(val[i]));
2523 }
2524
2525 return mapped;
2526 }
2527
2528 return fn(val);
2529};
2530
2531module.exports = {
2532 arrayToObject: arrayToObject,
2533 assign: assign,
2534 combine: combine,
2535 compact: compact,
2536 decode: decode,
2537 encode: encode,
2538 isBuffer: isBuffer,
2539 isRegExp: isRegExp,
2540 maybeMap: maybeMap,
2541 merge: merge
2542};
2543
2544},{"./formats":14}],19:[function(require,module,exports){
2545'use strict';
2546
2547function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2548
2549var GetIntrinsic = require('get-intrinsic');
2550
2551var callBound = require('call-bind/callBound');
2552
2553var inspect = require('object-inspect');
2554
2555var $TypeError = GetIntrinsic('%TypeError%');
2556var $WeakMap = GetIntrinsic('%WeakMap%', true);
2557var $Map = GetIntrinsic('%Map%', true);
2558var $weakMapGet = callBound('WeakMap.prototype.get', true);
2559var $weakMapSet = callBound('WeakMap.prototype.set', true);
2560var $weakMapHas = callBound('WeakMap.prototype.has', true);
2561var $mapGet = callBound('Map.prototype.get', true);
2562var $mapSet = callBound('Map.prototype.set', true);
2563var $mapHas = callBound('Map.prototype.has', true);
2564
2565var listGetNode = function listGetNode(list, key) {
2566 for (var prev = list, curr; (curr = prev.next) !== null; prev = curr) {
2567 if (curr.key === key) {
2568 prev.next = curr.next;
2569 curr.next = list.next;
2570 list.next = curr;
2571 return curr;
2572 }
2573 }
2574};
2575
2576var listGet = function listGet(objects, key) {
2577 var node = listGetNode(objects, key);
2578 return node && node.value;
2579};
2580
2581var listSet = function listSet(objects, key, value) {
2582 var node = listGetNode(objects, key);
2583
2584 if (node) {
2585 node.value = value;
2586 } else {
2587 objects.next = {
2588 key: key,
2589 next: objects.next,
2590 value: value
2591 };
2592 }
2593};
2594
2595var listHas = function listHas(objects, key) {
2596 return !!listGetNode(objects, key);
2597};
2598
2599module.exports = function getSideChannel() {
2600 var $wm;
2601 var $m;
2602 var $o;
2603 var channel = {
2604 assert: function assert(key) {
2605 if (!channel.has(key)) {
2606 throw new $TypeError('Side channel does not contain ' + inspect(key));
2607 }
2608 },
2609 get: function get(key) {
2610 if ($WeakMap && key && (_typeof(key) === 'object' || typeof key === 'function')) {
2611 if ($wm) {
2612 return $weakMapGet($wm, key);
2613 }
2614 } else if ($Map) {
2615 if ($m) {
2616 return $mapGet($m, key);
2617 }
2618 } else {
2619 if ($o) {
2620 return listGet($o, key);
2621 }
2622 }
2623 },
2624 has: function has(key) {
2625 if ($WeakMap && key && (_typeof(key) === 'object' || typeof key === 'function')) {
2626 if ($wm) {
2627 return $weakMapHas($wm, key);
2628 }
2629 } else if ($Map) {
2630 if ($m) {
2631 return $mapHas($m, key);
2632 }
2633 } else {
2634 if ($o) {
2635 return listHas($o, key);
2636 }
2637 }
2638
2639 return false;
2640 },
2641 set: function set(key, value) {
2642 if ($WeakMap && key && (_typeof(key) === 'object' || typeof key === 'function')) {
2643 if (!$wm) {
2644 $wm = new $WeakMap();
2645 }
2646
2647 $weakMapSet($wm, key, value);
2648 } else if ($Map) {
2649 if (!$m) {
2650 $m = new $Map();
2651 }
2652
2653 $mapSet($m, key, value);
2654 } else {
2655 if (!$o) {
2656 $o = {
2657 key: {},
2658 next: null
2659 };
2660 }
2661
2662 listSet($o, key, value);
2663 }
2664 }
2665 };
2666 return channel;
2667};
2668
2669},{"call-bind/callBound":2,"get-intrinsic":8,"object-inspect":12}],20:[function(require,module,exports){
2670"use strict";
2671
2672function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
2673
2674function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
2675
2676function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
2677
2678function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
2679
2680function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
2681
2682function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
2683
2684function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
2685
2686function Agent() {
2687 this._defaults = [];
2688}
2689
2690var _loop = function _loop() {
2691 var fn = _arr[_i];
2692
2693 Agent.prototype[fn] = function () {
2694 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
2695 args[_key] = arguments[_key];
2696 }
2697
2698 this._defaults.push({
2699 fn: fn,
2700 args: args
2701 });
2702
2703 return this;
2704 };
2705};
2706
2707for (var _i = 0, _arr = ['use', 'on', 'once', 'set', 'query', 'type', 'accept', 'auth', 'withCredentials', 'sortQuery', 'retry', 'ok', 'redirects', 'timeout', 'buffer', 'serialize', 'parse', 'ca', 'key', 'pfx', 'cert', 'disableTLSCerts']; _i < _arr.length; _i++) {
2708 _loop();
2709}
2710
2711Agent.prototype._setDefaults = function (request) {
2712 var _iterator = _createForOfIteratorHelper(this._defaults),
2713 _step;
2714
2715 try {
2716 for (_iterator.s(); !(_step = _iterator.n()).done;) {
2717 var def = _step.value;
2718 request[def.fn].apply(request, _toConsumableArray(def.args));
2719 }
2720 } catch (err) {
2721 _iterator.e(err);
2722 } finally {
2723 _iterator.f();
2724 }
2725};
2726
2727module.exports = Agent;
2728
2729},{}],21:[function(require,module,exports){
2730"use strict";
2731
2732function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2733
2734function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
2735
2736function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
2737
2738function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
2739
2740var root;
2741
2742if (typeof window !== 'undefined') {
2743 root = window;
2744} else if (typeof self === 'undefined') {
2745 console.warn('Using browser-only version of superagent in non-browser environment');
2746 root = void 0;
2747} else {
2748 root = self;
2749}
2750
2751var Emitter = require('component-emitter');
2752
2753var safeStringify = require('fast-safe-stringify');
2754
2755var qs = require('qs');
2756
2757var RequestBase = require('./request-base');
2758
2759var _require = require('./utils'),
2760 isObject = _require.isObject,
2761 mixin = _require.mixin,
2762 hasOwn = _require.hasOwn;
2763
2764var ResponseBase = require('./response-base');
2765
2766var Agent = require('./agent-base');
2767
2768function noop() {}
2769
2770module.exports = function (method, url) {
2771 if (typeof url === 'function') {
2772 return new exports.Request('GET', method).end(url);
2773 }
2774
2775 if (arguments.length === 1) {
2776 return new exports.Request('GET', method);
2777 }
2778
2779 return new exports.Request(method, url);
2780};
2781
2782exports = module.exports;
2783var request = exports;
2784exports.Request = Request;
2785
2786request.getXHR = function () {
2787 if (root.XMLHttpRequest && (!root.location || root.location.protocol !== 'file:' || !root.ActiveXObject)) {
2788 return new XMLHttpRequest();
2789 }
2790
2791 try {
2792 return new ActiveXObject('Microsoft.XMLHTTP');
2793 } catch (_unused) {}
2794
2795 try {
2796 return new ActiveXObject('Msxml2.XMLHTTP.6.0');
2797 } catch (_unused2) {}
2798
2799 try {
2800 return new ActiveXObject('Msxml2.XMLHTTP.3.0');
2801 } catch (_unused3) {}
2802
2803 try {
2804 return new ActiveXObject('Msxml2.XMLHTTP');
2805 } catch (_unused4) {}
2806
2807 throw new Error('Browser-only version of superagent could not find XHR');
2808};
2809
2810var trim = ''.trim ? function (s) {
2811 return s.trim();
2812} : function (s) {
2813 return s.replace(/(^\s*|\s*$)/g, '');
2814};
2815
2816function serialize(object) {
2817 if (!isObject(object)) return object;
2818 var pairs = [];
2819
2820 for (var key in object) {
2821 if (hasOwn(object, key)) pushEncodedKeyValuePair(pairs, key, object[key]);
2822 }
2823
2824 return pairs.join('&');
2825}
2826
2827function pushEncodedKeyValuePair(pairs, key, value) {
2828 if (value === undefined) return;
2829
2830 if (value === null) {
2831 pairs.push(encodeURI(key));
2832 return;
2833 }
2834
2835 if (Array.isArray(value)) {
2836 var _iterator = _createForOfIteratorHelper(value),
2837 _step;
2838
2839 try {
2840 for (_iterator.s(); !(_step = _iterator.n()).done;) {
2841 var v = _step.value;
2842 pushEncodedKeyValuePair(pairs, key, v);
2843 }
2844 } catch (err) {
2845 _iterator.e(err);
2846 } finally {
2847 _iterator.f();
2848 }
2849 } else if (isObject(value)) {
2850 for (var subkey in value) {
2851 if (hasOwn(value, subkey)) pushEncodedKeyValuePair(pairs, "".concat(key, "[").concat(subkey, "]"), value[subkey]);
2852 }
2853 } else {
2854 pairs.push(encodeURI(key) + '=' + encodeURIComponent(value));
2855 }
2856}
2857
2858request.serializeObject = serialize;
2859
2860function parseString(string_) {
2861 var object = {};
2862 var pairs = string_.split('&');
2863 var pair;
2864 var pos;
2865
2866 for (var i = 0, length_ = pairs.length; i < length_; ++i) {
2867 pair = pairs[i];
2868 pos = pair.indexOf('=');
2869
2870 if (pos === -1) {
2871 object[decodeURIComponent(pair)] = '';
2872 } else {
2873 object[decodeURIComponent(pair.slice(0, pos))] = decodeURIComponent(pair.slice(pos + 1));
2874 }
2875 }
2876
2877 return object;
2878}
2879
2880request.parseString = parseString;
2881request.types = {
2882 html: 'text/html',
2883 json: 'application/json',
2884 xml: 'text/xml',
2885 urlencoded: 'application/x-www-form-urlencoded',
2886 form: 'application/x-www-form-urlencoded',
2887 'form-data': 'application/x-www-form-urlencoded'
2888};
2889request.serialize = {
2890 'application/x-www-form-urlencoded': qs.stringify,
2891 'application/json': safeStringify
2892};
2893request.parse = {
2894 'application/x-www-form-urlencoded': parseString,
2895 'application/json': JSON.parse
2896};
2897
2898function parseHeader(string_) {
2899 var lines = string_.split(/\r?\n/);
2900 var fields = {};
2901 var index;
2902 var line;
2903 var field;
2904 var value;
2905
2906 for (var i = 0, length_ = lines.length; i < length_; ++i) {
2907 line = lines[i];
2908 index = line.indexOf(':');
2909
2910 if (index === -1) {
2911 continue;
2912 }
2913
2914 field = line.slice(0, index).toLowerCase();
2915 value = trim(line.slice(index + 1));
2916 fields[field] = value;
2917 }
2918
2919 return fields;
2920}
2921
2922function isJSON(mime) {
2923 return /[/+]json($|[^-\w])/i.test(mime);
2924}
2925
2926function Response(request_) {
2927 this.req = request_;
2928 this.xhr = this.req.xhr;
2929 this.text = this.req.method !== 'HEAD' && (this.xhr.responseType === '' || this.xhr.responseType === 'text') || typeof this.xhr.responseType === 'undefined' ? this.xhr.responseText : null;
2930 this.statusText = this.req.xhr.statusText;
2931 var status = this.xhr.status;
2932
2933 if (status === 1223) {
2934 status = 204;
2935 }
2936
2937 this._setStatusProperties(status);
2938
2939 this.headers = parseHeader(this.xhr.getAllResponseHeaders());
2940 this.header = this.headers;
2941 this.header['content-type'] = this.xhr.getResponseHeader('content-type');
2942
2943 this._setHeaderProperties(this.header);
2944
2945 if (this.text === null && request_._responseType) {
2946 this.body = this.xhr.response;
2947 } else {
2948 this.body = this.req.method === 'HEAD' ? null : this._parseBody(this.text ? this.text : this.xhr.response);
2949 }
2950}
2951
2952mixin(Response.prototype, ResponseBase.prototype);
2953
2954Response.prototype._parseBody = function (string_) {
2955 var parse = request.parse[this.type];
2956
2957 if (this.req._parser) {
2958 return this.req._parser(this, string_);
2959 }
2960
2961 if (!parse && isJSON(this.type)) {
2962 parse = request.parse['application/json'];
2963 }
2964
2965 return parse && string_ && (string_.length > 0 || string_ instanceof Object) ? parse(string_) : null;
2966};
2967
2968Response.prototype.toError = function () {
2969 var req = this.req;
2970 var method = req.method;
2971 var url = req.url;
2972 var message = "cannot ".concat(method, " ").concat(url, " (").concat(this.status, ")");
2973 var error = new Error(message);
2974 error.status = this.status;
2975 error.method = method;
2976 error.url = url;
2977 return error;
2978};
2979
2980request.Response = Response;
2981
2982function Request(method, url) {
2983 var self = this;
2984 this._query = this._query || [];
2985 this.method = method;
2986 this.url = url;
2987 this.header = {};
2988 this._header = {};
2989 this.on('end', function () {
2990 var error = null;
2991 var res = null;
2992
2993 try {
2994 res = new Response(self);
2995 } catch (error_) {
2996 error = new Error('Parser is unable to parse the response');
2997 error.parse = true;
2998 error.original = error_;
2999
3000 if (self.xhr) {
3001 error.rawResponse = typeof self.xhr.responseType === 'undefined' ? self.xhr.responseText : self.xhr.response;
3002 error.status = self.xhr.status ? self.xhr.status : null;
3003 error.statusCode = error.status;
3004 } else {
3005 error.rawResponse = null;
3006 error.status = null;
3007 }
3008
3009 return self.callback(error);
3010 }
3011
3012 self.emit('response', res);
3013 var new_error;
3014
3015 try {
3016 if (!self._isResponseOK(res)) {
3017 new_error = new Error(res.statusText || res.text || 'Unsuccessful HTTP response');
3018 }
3019 } catch (err) {
3020 new_error = err;
3021 }
3022
3023 if (new_error) {
3024 new_error.original = error;
3025 new_error.response = res;
3026 new_error.status = res.status;
3027 self.callback(new_error, res);
3028 } else {
3029 self.callback(null, res);
3030 }
3031 });
3032}
3033
3034Emitter(Request.prototype);
3035mixin(Request.prototype, RequestBase.prototype);
3036
3037Request.prototype.type = function (type) {
3038 this.set('Content-Type', request.types[type] || type);
3039 return this;
3040};
3041
3042Request.prototype.accept = function (type) {
3043 this.set('Accept', request.types[type] || type);
3044 return this;
3045};
3046
3047Request.prototype.auth = function (user, pass, options) {
3048 if (arguments.length === 1) pass = '';
3049
3050 if (_typeof(pass) === 'object' && pass !== null) {
3051 options = pass;
3052 pass = '';
3053 }
3054
3055 if (!options) {
3056 options = {
3057 type: typeof btoa === 'function' ? 'basic' : 'auto'
3058 };
3059 }
3060
3061 var encoder = function encoder(string) {
3062 if (typeof btoa === 'function') {
3063 return btoa(string);
3064 }
3065
3066 throw new Error('Cannot use basic auth, btoa is not a function');
3067 };
3068
3069 return this._auth(user, pass, options, encoder);
3070};
3071
3072Request.prototype.query = function (value) {
3073 if (typeof value !== 'string') value = serialize(value);
3074 if (value) this._query.push(value);
3075 return this;
3076};
3077
3078Request.prototype.attach = function (field, file, options) {
3079 if (file) {
3080 if (this._data) {
3081 throw new Error("superagent can't mix .send() and .attach()");
3082 }
3083
3084 this._getFormData().append(field, file, options || file.name);
3085 }
3086
3087 return this;
3088};
3089
3090Request.prototype._getFormData = function () {
3091 if (!this._formData) {
3092 this._formData = new root.FormData();
3093 }
3094
3095 return this._formData;
3096};
3097
3098Request.prototype.callback = function (error, res) {
3099 if (this._shouldRetry(error, res)) {
3100 return this._retry();
3101 }
3102
3103 var fn = this._callback;
3104 this.clearTimeout();
3105
3106 if (error) {
3107 if (this._maxRetries) error.retries = this._retries - 1;
3108 this.emit('error', error);
3109 }
3110
3111 fn(error, res);
3112};
3113
3114Request.prototype.crossDomainError = function () {
3115 var error = new Error('Request has been terminated\nPossible causes: the network is offline, Origin is not allowed by Access-Control-Allow-Origin, the page is being unloaded, etc.');
3116 error.crossDomain = true;
3117 error.status = this.status;
3118 error.method = this.method;
3119 error.url = this.url;
3120 this.callback(error);
3121};
3122
3123Request.prototype.agent = function () {
3124 console.warn('This is not supported in browser version of superagent');
3125 return this;
3126};
3127
3128Request.prototype.ca = Request.prototype.agent;
3129Request.prototype.buffer = Request.prototype.ca;
3130
3131Request.prototype.write = function () {
3132 throw new Error('Streaming is not supported in browser version of superagent');
3133};
3134
3135Request.prototype.pipe = Request.prototype.write;
3136
3137Request.prototype._isHost = function (object) {
3138 return object && _typeof(object) === 'object' && !Array.isArray(object) && Object.prototype.toString.call(object) !== '[object Object]';
3139};
3140
3141Request.prototype.end = function (fn) {
3142 if (this._endCalled) {
3143 console.warn('Warning: .end() was called twice. This is not supported in superagent');
3144 }
3145
3146 this._endCalled = true;
3147 this._callback = fn || noop;
3148
3149 this._finalizeQueryString();
3150
3151 this._end();
3152};
3153
3154Request.prototype._setUploadTimeout = function () {
3155 var self = this;
3156
3157 if (this._uploadTimeout && !this._uploadTimeoutTimer) {
3158 this._uploadTimeoutTimer = setTimeout(function () {
3159 self._timeoutError('Upload timeout of ', self._uploadTimeout, 'ETIMEDOUT');
3160 }, this._uploadTimeout);
3161 }
3162};
3163
3164Request.prototype._end = function () {
3165 if (this._aborted) return this.callback(new Error('The request has been aborted even before .end() was called'));
3166 var self = this;
3167 this.xhr = request.getXHR();
3168 var xhr = this.xhr;
3169 var data = this._formData || this._data;
3170
3171 this._setTimeouts();
3172
3173 xhr.addEventListener('readystatechange', function () {
3174 var readyState = xhr.readyState;
3175
3176 if (readyState >= 2 && self._responseTimeoutTimer) {
3177 clearTimeout(self._responseTimeoutTimer);
3178 }
3179
3180 if (readyState !== 4) {
3181 return;
3182 }
3183
3184 var status;
3185
3186 try {
3187 status = xhr.status;
3188 } catch (_unused5) {
3189 status = 0;
3190 }
3191
3192 if (!status) {
3193 if (self.timedout || self._aborted) return;
3194 return self.crossDomainError();
3195 }
3196
3197 self.emit('end');
3198 });
3199
3200 var handleProgress = function handleProgress(direction, e) {
3201 if (e.total > 0) {
3202 e.percent = e.loaded / e.total * 100;
3203
3204 if (e.percent === 100) {
3205 clearTimeout(self._uploadTimeoutTimer);
3206 }
3207 }
3208
3209 e.direction = direction;
3210 self.emit('progress', e);
3211 };
3212
3213 if (this.hasListeners('progress')) {
3214 try {
3215 xhr.addEventListener('progress', handleProgress.bind(null, 'download'));
3216
3217 if (xhr.upload) {
3218 xhr.upload.addEventListener('progress', handleProgress.bind(null, 'upload'));
3219 }
3220 } catch (_unused6) {}
3221 }
3222
3223 if (xhr.upload) {
3224 this._setUploadTimeout();
3225 }
3226
3227 try {
3228 if (this.username && this.password) {
3229 xhr.open(this.method, this.url, true, this.username, this.password);
3230 } else {
3231 xhr.open(this.method, this.url, true);
3232 }
3233 } catch (err) {
3234 return this.callback(err);
3235 }
3236
3237 if (this._withCredentials) xhr.withCredentials = true;
3238
3239 if (!this._formData && this.method !== 'GET' && this.method !== 'HEAD' && typeof data !== 'string' && !this._isHost(data)) {
3240 var contentType = this._header['content-type'];
3241
3242 var _serialize = this._serializer || request.serialize[contentType ? contentType.split(';')[0] : ''];
3243
3244 if (!_serialize && isJSON(contentType)) {
3245 _serialize = request.serialize['application/json'];
3246 }
3247
3248 if (_serialize) data = _serialize(data);
3249 }
3250
3251 for (var field in this.header) {
3252 if (this.header[field] === null) continue;
3253 if (hasOwn(this.header, field)) xhr.setRequestHeader(field, this.header[field]);
3254 }
3255
3256 if (this._responseType) {
3257 xhr.responseType = this._responseType;
3258 }
3259
3260 this.emit('request', this);
3261 xhr.send(typeof data === 'undefined' ? null : data);
3262};
3263
3264request.agent = function () {
3265 return new Agent();
3266};
3267
3268var _loop = function _loop() {
3269 var method = _arr[_i];
3270
3271 Agent.prototype[method.toLowerCase()] = function (url, fn) {
3272 var request_ = new request.Request(method, url);
3273
3274 this._setDefaults(request_);
3275
3276 if (fn) {
3277 request_.end(fn);
3278 }
3279
3280 return request_;
3281 };
3282};
3283
3284for (var _i = 0, _arr = ['GET', 'POST', 'OPTIONS', 'PATCH', 'PUT', 'DELETE']; _i < _arr.length; _i++) {
3285 _loop();
3286}
3287
3288Agent.prototype.del = Agent.prototype.delete;
3289
3290request.get = function (url, data, fn) {
3291 var request_ = request('GET', url);
3292
3293 if (typeof data === 'function') {
3294 fn = data;
3295 data = null;
3296 }
3297
3298 if (data) request_.query(data);
3299 if (fn) request_.end(fn);
3300 return request_;
3301};
3302
3303request.head = function (url, data, fn) {
3304 var request_ = request('HEAD', url);
3305
3306 if (typeof data === 'function') {
3307 fn = data;
3308 data = null;
3309 }
3310
3311 if (data) request_.query(data);
3312 if (fn) request_.end(fn);
3313 return request_;
3314};
3315
3316request.options = function (url, data, fn) {
3317 var request_ = request('OPTIONS', url);
3318
3319 if (typeof data === 'function') {
3320 fn = data;
3321 data = null;
3322 }
3323
3324 if (data) request_.send(data);
3325 if (fn) request_.end(fn);
3326 return request_;
3327};
3328
3329function del(url, data, fn) {
3330 var request_ = request('DELETE', url);
3331
3332 if (typeof data === 'function') {
3333 fn = data;
3334 data = null;
3335 }
3336
3337 if (data) request_.send(data);
3338 if (fn) request_.end(fn);
3339 return request_;
3340}
3341
3342request.del = del;
3343request.delete = del;
3344
3345request.patch = function (url, data, fn) {
3346 var request_ = request('PATCH', url);
3347
3348 if (typeof data === 'function') {
3349 fn = data;
3350 data = null;
3351 }
3352
3353 if (data) request_.send(data);
3354 if (fn) request_.end(fn);
3355 return request_;
3356};
3357
3358request.post = function (url, data, fn) {
3359 var request_ = request('POST', url);
3360
3361 if (typeof data === 'function') {
3362 fn = data;
3363 data = null;
3364 }
3365
3366 if (data) request_.send(data);
3367 if (fn) request_.end(fn);
3368 return request_;
3369};
3370
3371request.put = function (url, data, fn) {
3372 var request_ = request('PUT', url);
3373
3374 if (typeof data === 'function') {
3375 fn = data;
3376 data = null;
3377 }
3378
3379 if (data) request_.send(data);
3380 if (fn) request_.end(fn);
3381 return request_;
3382};
3383
3384},{"./agent-base":20,"./request-base":22,"./response-base":23,"./utils":24,"component-emitter":4,"fast-safe-stringify":5,"qs":15}],22:[function(require,module,exports){
3385(function (process){(function (){
3386"use strict";
3387
3388function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
3389
3390var semver = require('semver');
3391
3392var _require = require('./utils'),
3393 isObject = _require.isObject,
3394 hasOwn = _require.hasOwn;
3395
3396module.exports = RequestBase;
3397
3398function RequestBase() {}
3399
3400RequestBase.prototype.clearTimeout = function () {
3401 clearTimeout(this._timer);
3402 clearTimeout(this._responseTimeoutTimer);
3403 clearTimeout(this._uploadTimeoutTimer);
3404 delete this._timer;
3405 delete this._responseTimeoutTimer;
3406 delete this._uploadTimeoutTimer;
3407 return this;
3408};
3409
3410RequestBase.prototype.parse = function (fn) {
3411 this._parser = fn;
3412 return this;
3413};
3414
3415RequestBase.prototype.responseType = function (value) {
3416 this._responseType = value;
3417 return this;
3418};
3419
3420RequestBase.prototype.serialize = function (fn) {
3421 this._serializer = fn;
3422 return this;
3423};
3424
3425RequestBase.prototype.timeout = function (options) {
3426 if (!options || _typeof(options) !== 'object') {
3427 this._timeout = options;
3428 this._responseTimeout = 0;
3429 this._uploadTimeout = 0;
3430 return this;
3431 }
3432
3433 for (var option in options) {
3434 if (hasOwn(options, option)) {
3435 switch (option) {
3436 case 'deadline':
3437 this._timeout = options.deadline;
3438 break;
3439
3440 case 'response':
3441 this._responseTimeout = options.response;
3442 break;
3443
3444 case 'upload':
3445 this._uploadTimeout = options.upload;
3446 break;
3447
3448 default:
3449 console.warn('Unknown timeout option', option);
3450 }
3451 }
3452 }
3453
3454 return this;
3455};
3456
3457RequestBase.prototype.retry = function (count, fn) {
3458 if (arguments.length === 0 || count === true) count = 1;
3459 if (count <= 0) count = 0;
3460 this._maxRetries = count;
3461 this._retries = 0;
3462 this._retryCallback = fn;
3463 return this;
3464};
3465
3466var ERROR_CODES = new Set(['ETIMEDOUT', 'ECONNRESET', 'EADDRINUSE', 'ECONNREFUSED', 'EPIPE', 'ENOTFOUND', 'ENETUNREACH', 'EAI_AGAIN']);
3467var STATUS_CODES = new Set([408, 413, 429, 500, 502, 503, 504, 521, 522, 524]);
3468
3469RequestBase.prototype._shouldRetry = function (error, res) {
3470 if (!this._maxRetries || this._retries++ >= this._maxRetries) {
3471 return false;
3472 }
3473
3474 if (this._retryCallback) {
3475 try {
3476 var override = this._retryCallback(error, res);
3477
3478 if (override === true) return true;
3479 if (override === false) return false;
3480 } catch (error_) {
3481 console.error(error_);
3482 }
3483 }
3484
3485 if (res && res.status && STATUS_CODES.has(res.status)) return true;
3486
3487 if (error) {
3488 if (error.code && ERROR_CODES.has(error.code)) return true;
3489 if (error.timeout && error.code === 'ECONNABORTED') return true;
3490 if (error.crossDomain) return true;
3491 }
3492
3493 return false;
3494};
3495
3496RequestBase.prototype._retry = function () {
3497 this.clearTimeout();
3498
3499 if (this.req) {
3500 this.req = null;
3501 this.req = this.request();
3502 }
3503
3504 this._aborted = false;
3505 this.timedout = false;
3506 this.timedoutError = null;
3507 return this._end();
3508};
3509
3510RequestBase.prototype.then = function (resolve, reject) {
3511 var _this = this;
3512
3513 if (!this._fullfilledPromise) {
3514 var self = this;
3515
3516 if (this._endCalled) {
3517 console.warn('Warning: superagent request was sent twice, because both .end() and .then() were called. Never call .end() if you use promises');
3518 }
3519
3520 this._fullfilledPromise = new Promise(function (resolve, reject) {
3521 self.on('abort', function () {
3522 if (_this._maxRetries && _this._maxRetries > _this._retries) {
3523 return;
3524 }
3525
3526 if (_this.timedout && _this.timedoutError) {
3527 reject(_this.timedoutError);
3528 return;
3529 }
3530
3531 var error = new Error('Aborted');
3532 error.code = 'ABORTED';
3533 error.status = _this.status;
3534 error.method = _this.method;
3535 error.url = _this.url;
3536 reject(error);
3537 });
3538 self.end(function (error, res) {
3539 if (error) reject(error);else resolve(res);
3540 });
3541 });
3542 }
3543
3544 return this._fullfilledPromise.then(resolve, reject);
3545};
3546
3547RequestBase.prototype.catch = function (cb) {
3548 return this.then(undefined, cb);
3549};
3550
3551RequestBase.prototype.use = function (fn) {
3552 fn(this);
3553 return this;
3554};
3555
3556RequestBase.prototype.ok = function (cb) {
3557 if (typeof cb !== 'function') throw new Error('Callback required');
3558 this._okCallback = cb;
3559 return this;
3560};
3561
3562RequestBase.prototype._isResponseOK = function (res) {
3563 if (!res) {
3564 return false;
3565 }
3566
3567 if (this._okCallback) {
3568 return this._okCallback(res);
3569 }
3570
3571 return res.status >= 200 && res.status < 300;
3572};
3573
3574RequestBase.prototype.get = function (field) {
3575 return this._header[field.toLowerCase()];
3576};
3577
3578RequestBase.prototype.getHeader = RequestBase.prototype.get;
3579
3580RequestBase.prototype.set = function (field, value) {
3581 if (isObject(field)) {
3582 for (var key in field) {
3583 if (hasOwn(field, key)) this.set(key, field[key]);
3584 }
3585
3586 return this;
3587 }
3588
3589 this._header[field.toLowerCase()] = value;
3590 this.header[field] = value;
3591 return this;
3592};
3593
3594RequestBase.prototype.unset = function (field) {
3595 delete this._header[field.toLowerCase()];
3596 delete this.header[field];
3597 return this;
3598};
3599
3600RequestBase.prototype.field = function (name, value, options) {
3601 if (name === null || undefined === name) {
3602 throw new Error('.field(name, val) name can not be empty');
3603 }
3604
3605 if (this._data) {
3606 throw new Error(".field() can't be used if .send() is used. Please use only .send() or only .field() & .attach()");
3607 }
3608
3609 if (isObject(name)) {
3610 for (var key in name) {
3611 if (hasOwn(name, key)) this.field(key, name[key]);
3612 }
3613
3614 return this;
3615 }
3616
3617 if (Array.isArray(value)) {
3618 for (var i in value) {
3619 if (hasOwn(value, i)) this.field(name, value[i]);
3620 }
3621
3622 return this;
3623 }
3624
3625 if (value === null || undefined === value) {
3626 throw new Error('.field(name, val) val can not be empty');
3627 }
3628
3629 if (typeof value === 'boolean') {
3630 value = String(value);
3631 }
3632
3633 this._getFormData().append(name, value, options);
3634
3635 return this;
3636};
3637
3638RequestBase.prototype.abort = function () {
3639 if (this._aborted) {
3640 return this;
3641 }
3642
3643 this._aborted = true;
3644 if (this.xhr) this.xhr.abort();
3645
3646 if (this.req) {
3647 if (semver.gte(process.version, 'v13.0.0') && semver.lt(process.version, 'v14.0.0')) {
3648 throw new Error('Superagent does not work in v13 properly with abort() due to Node.js core changes');
3649 } else if (semver.gte(process.version, 'v14.0.0')) {
3650 this.req.destroyed = true;
3651 }
3652
3653 this.req.abort();
3654 }
3655
3656 this.clearTimeout();
3657 this.emit('abort');
3658 return this;
3659};
3660
3661RequestBase.prototype._auth = function (user, pass, options, base64Encoder) {
3662 switch (options.type) {
3663 case 'basic':
3664 this.set('Authorization', "Basic ".concat(base64Encoder("".concat(user, ":").concat(pass))));
3665 break;
3666
3667 case 'auto':
3668 this.username = user;
3669 this.password = pass;
3670 break;
3671
3672 case 'bearer':
3673 this.set('Authorization', "Bearer ".concat(user));
3674 break;
3675
3676 default:
3677 break;
3678 }
3679
3680 return this;
3681};
3682
3683RequestBase.prototype.withCredentials = function (on) {
3684 if (on === undefined) on = true;
3685 this._withCredentials = on;
3686 return this;
3687};
3688
3689RequestBase.prototype.redirects = function (n) {
3690 this._maxRedirects = n;
3691 return this;
3692};
3693
3694RequestBase.prototype.maxResponseSize = function (n) {
3695 if (typeof n !== 'number') {
3696 throw new TypeError('Invalid argument');
3697 }
3698
3699 this._maxResponseSize = n;
3700 return this;
3701};
3702
3703RequestBase.prototype.toJSON = function () {
3704 return {
3705 method: this.method,
3706 url: this.url,
3707 data: this._data,
3708 headers: this._header
3709 };
3710};
3711
3712RequestBase.prototype.send = function (data) {
3713 var isObject_ = isObject(data);
3714 var type = this._header['content-type'];
3715
3716 if (this._formData) {
3717 throw new Error(".send() can't be used if .attach() or .field() is used. Please use only .send() or only .field() & .attach()");
3718 }
3719
3720 if (isObject_ && !this._data) {
3721 if (Array.isArray(data)) {
3722 this._data = [];
3723 } else if (!this._isHost(data)) {
3724 this._data = {};
3725 }
3726 } else if (data && this._data && this._isHost(this._data)) {
3727 throw new Error("Can't merge these send calls");
3728 }
3729
3730 if (isObject_ && isObject(this._data)) {
3731 for (var key in data) {
3732 if (hasOwn(data, key)) this._data[key] = data[key];
3733 }
3734 } else if (typeof data === 'string') {
3735 if (!type) this.type('form');
3736 type = this._header['content-type'];
3737 if (type) type = type.toLowerCase().trim();
3738
3739 if (type === 'application/x-www-form-urlencoded') {
3740 this._data = this._data ? "".concat(this._data, "&").concat(data) : data;
3741 } else {
3742 this._data = (this._data || '') + data;
3743 }
3744 } else {
3745 this._data = data;
3746 }
3747
3748 if (!isObject_ || this._isHost(data)) {
3749 return this;
3750 }
3751
3752 if (!type) this.type('json');
3753 return this;
3754};
3755
3756RequestBase.prototype.sortQuery = function (sort) {
3757 this._sort = typeof sort === 'undefined' ? true : sort;
3758 return this;
3759};
3760
3761RequestBase.prototype._finalizeQueryString = function () {
3762 var query = this._query.join('&');
3763
3764 if (query) {
3765 this.url += (this.url.includes('?') ? '&' : '?') + query;
3766 }
3767
3768 this._query.length = 0;
3769
3770 if (this._sort) {
3771 var index = this.url.indexOf('?');
3772
3773 if (index >= 0) {
3774 var queryArray = this.url.slice(index + 1).split('&');
3775
3776 if (typeof this._sort === 'function') {
3777 queryArray.sort(this._sort);
3778 } else {
3779 queryArray.sort();
3780 }
3781
3782 this.url = this.url.slice(0, index) + '?' + queryArray.join('&');
3783 }
3784 }
3785};
3786
3787RequestBase.prototype._appendQueryString = function () {
3788 console.warn('Unsupported');
3789};
3790
3791RequestBase.prototype._timeoutError = function (reason, timeout, errno) {
3792 if (this._aborted) {
3793 return;
3794 }
3795
3796 var error = new Error("".concat(reason + timeout, "ms exceeded"));
3797 error.timeout = timeout;
3798 error.code = 'ECONNABORTED';
3799 error.errno = errno;
3800 this.timedout = true;
3801 this.timedoutError = error;
3802 this.abort();
3803 this.callback(error);
3804};
3805
3806RequestBase.prototype._setTimeouts = function () {
3807 var self = this;
3808
3809 if (this._timeout && !this._timer) {
3810 this._timer = setTimeout(function () {
3811 self._timeoutError('Timeout of ', self._timeout, 'ETIME');
3812 }, this._timeout);
3813 }
3814
3815 if (this._responseTimeout && !this._responseTimeoutTimer) {
3816 this._responseTimeoutTimer = setTimeout(function () {
3817 self._timeoutError('Response timeout of ', self._responseTimeout, 'ETIMEDOUT');
3818 }, this._responseTimeout);
3819 }
3820};
3821
3822}).call(this)}).call(this,require('_process'))
3823},{"./utils":24,"_process":13,"semver":1}],23:[function(require,module,exports){
3824"use strict";
3825
3826var utils = require('./utils');
3827
3828module.exports = ResponseBase;
3829
3830function ResponseBase() {}
3831
3832ResponseBase.prototype.get = function (field) {
3833 return this.header[field.toLowerCase()];
3834};
3835
3836ResponseBase.prototype._setHeaderProperties = function (header) {
3837 var ct = header['content-type'] || '';
3838 this.type = utils.type(ct);
3839 var parameters = utils.params(ct);
3840
3841 for (var key in parameters) {
3842 if (Object.prototype.hasOwnProperty.call(parameters, key)) this[key] = parameters[key];
3843 }
3844
3845 this.links = {};
3846
3847 try {
3848 if (header.link) {
3849 this.links = utils.parseLinks(header.link);
3850 }
3851 } catch (_unused) {}
3852};
3853
3854ResponseBase.prototype._setStatusProperties = function (status) {
3855 var type = Math.trunc(status / 100);
3856 this.statusCode = status;
3857 this.status = this.statusCode;
3858 this.statusType = type;
3859 this.info = type === 1;
3860 this.ok = type === 2;
3861 this.redirect = type === 3;
3862 this.clientError = type === 4;
3863 this.serverError = type === 5;
3864 this.error = type === 4 || type === 5 ? this.toError() : false;
3865 this.created = status === 201;
3866 this.accepted = status === 202;
3867 this.noContent = status === 204;
3868 this.badRequest = status === 400;
3869 this.unauthorized = status === 401;
3870 this.notAcceptable = status === 406;
3871 this.forbidden = status === 403;
3872 this.notFound = status === 404;
3873 this.unprocessableEntity = status === 422;
3874};
3875
3876},{"./utils":24}],24:[function(require,module,exports){
3877"use strict";
3878
3879function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
3880
3881function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
3882
3883function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
3884
3885function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
3886
3887exports.type = function (string_) {
3888 return string_.split(/ *; */).shift();
3889};
3890
3891exports.params = function (value) {
3892 var object = {};
3893
3894 var _iterator = _createForOfIteratorHelper(value.split(/ *; */)),
3895 _step;
3896
3897 try {
3898 for (_iterator.s(); !(_step = _iterator.n()).done;) {
3899 var string_ = _step.value;
3900 var parts = string_.split(/ *= */);
3901 var key = parts.shift();
3902
3903 var _value = parts.shift();
3904
3905 if (key && _value) object[key] = _value;
3906 }
3907 } catch (err) {
3908 _iterator.e(err);
3909 } finally {
3910 _iterator.f();
3911 }
3912
3913 return object;
3914};
3915
3916exports.parseLinks = function (value) {
3917 var object = {};
3918
3919 var _iterator2 = _createForOfIteratorHelper(value.split(/ *, */)),
3920 _step2;
3921
3922 try {
3923 for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
3924 var string_ = _step2.value;
3925 var parts = string_.split(/ *; */);
3926 var url = parts[0].slice(1, -1);
3927 var rel = parts[1].split(/ *= */)[1].slice(1, -1);
3928 object[rel] = url;
3929 }
3930 } catch (err) {
3931 _iterator2.e(err);
3932 } finally {
3933 _iterator2.f();
3934 }
3935
3936 return object;
3937};
3938
3939exports.cleanHeader = function (header, changesOrigin) {
3940 delete header['content-type'];
3941 delete header['content-length'];
3942 delete header['transfer-encoding'];
3943 delete header.host;
3944
3945 if (changesOrigin) {
3946 delete header.authorization;
3947 delete header.cookie;
3948 }
3949
3950 return header;
3951};
3952
3953exports.isObject = function (object) {
3954 return object !== null && _typeof(object) === 'object';
3955};
3956
3957exports.hasOwn = Object.hasOwn || function (object, property) {
3958 if (object == null) {
3959 throw new TypeError('Cannot convert undefined or null to object');
3960 }
3961
3962 return Object.prototype.hasOwnProperty.call(new Object(object), property);
3963};
3964
3965exports.mixin = function (target, source) {
3966 for (var key in source) {
3967 if (exports.hasOwn(source, key)) {
3968 target[key] = source[key];
3969 }
3970 }
3971};
3972
3973},{}]},{},[21])(21)
3974});