@hulkapps/app-manager-vue 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,4091 @@
1
+ import http from 'http';
2
+ import https from 'https';
3
+ import url from 'url';
4
+ import stream from 'stream';
5
+ import assert from 'assert';
6
+ import tty from 'tty';
7
+ import util from 'util';
8
+ import os from 'os';
9
+ import zlib from 'zlib';
10
+
11
+ var bind = function bind(fn, thisArg) {
12
+ return function wrap() {
13
+ var args = new Array(arguments.length);
14
+ for (var i = 0; i < args.length; i++) {
15
+ args[i] = arguments[i];
16
+ }
17
+ return fn.apply(thisArg, args);
18
+ };
19
+ };
20
+
21
+ // utils is a library of generic helper functions non-specific to axios
22
+
23
+ var toString = Object.prototype.toString;
24
+
25
+ /**
26
+ * Determine if a value is an Array
27
+ *
28
+ * @param {Object} val The value to test
29
+ * @returns {boolean} True if value is an Array, otherwise false
30
+ */
31
+ function isArray(val) {
32
+ return Array.isArray(val);
33
+ }
34
+
35
+ /**
36
+ * Determine if a value is undefined
37
+ *
38
+ * @param {Object} val The value to test
39
+ * @returns {boolean} True if the value is undefined, otherwise false
40
+ */
41
+ function isUndefined(val) {
42
+ return typeof val === 'undefined';
43
+ }
44
+
45
+ /**
46
+ * Determine if a value is a Buffer
47
+ *
48
+ * @param {Object} val The value to test
49
+ * @returns {boolean} True if value is a Buffer, otherwise false
50
+ */
51
+ function isBuffer(val) {
52
+ return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor)
53
+ && typeof val.constructor.isBuffer === 'function' && val.constructor.isBuffer(val);
54
+ }
55
+
56
+ /**
57
+ * Determine if a value is an ArrayBuffer
58
+ *
59
+ * @param {Object} val The value to test
60
+ * @returns {boolean} True if value is an ArrayBuffer, otherwise false
61
+ */
62
+ function isArrayBuffer(val) {
63
+ return toString.call(val) === '[object ArrayBuffer]';
64
+ }
65
+
66
+ /**
67
+ * Determine if a value is a FormData
68
+ *
69
+ * @param {Object} val The value to test
70
+ * @returns {boolean} True if value is an FormData, otherwise false
71
+ */
72
+ function isFormData(val) {
73
+ return toString.call(val) === '[object FormData]';
74
+ }
75
+
76
+ /**
77
+ * Determine if a value is a view on an ArrayBuffer
78
+ *
79
+ * @param {Object} val The value to test
80
+ * @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false
81
+ */
82
+ function isArrayBufferView(val) {
83
+ var result;
84
+ if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) {
85
+ result = ArrayBuffer.isView(val);
86
+ } else {
87
+ result = (val) && (val.buffer) && (isArrayBuffer(val.buffer));
88
+ }
89
+ return result;
90
+ }
91
+
92
+ /**
93
+ * Determine if a value is a String
94
+ *
95
+ * @param {Object} val The value to test
96
+ * @returns {boolean} True if value is a String, otherwise false
97
+ */
98
+ function isString(val) {
99
+ return typeof val === 'string';
100
+ }
101
+
102
+ /**
103
+ * Determine if a value is a Number
104
+ *
105
+ * @param {Object} val The value to test
106
+ * @returns {boolean} True if value is a Number, otherwise false
107
+ */
108
+ function isNumber(val) {
109
+ return typeof val === 'number';
110
+ }
111
+
112
+ /**
113
+ * Determine if a value is an Object
114
+ *
115
+ * @param {Object} val The value to test
116
+ * @returns {boolean} True if value is an Object, otherwise false
117
+ */
118
+ function isObject(val) {
119
+ return val !== null && typeof val === 'object';
120
+ }
121
+
122
+ /**
123
+ * Determine if a value is a plain Object
124
+ *
125
+ * @param {Object} val The value to test
126
+ * @return {boolean} True if value is a plain Object, otherwise false
127
+ */
128
+ function isPlainObject(val) {
129
+ if (toString.call(val) !== '[object Object]') {
130
+ return false;
131
+ }
132
+
133
+ var prototype = Object.getPrototypeOf(val);
134
+ return prototype === null || prototype === Object.prototype;
135
+ }
136
+
137
+ /**
138
+ * Determine if a value is a Date
139
+ *
140
+ * @param {Object} val The value to test
141
+ * @returns {boolean} True if value is a Date, otherwise false
142
+ */
143
+ function isDate(val) {
144
+ return toString.call(val) === '[object Date]';
145
+ }
146
+
147
+ /**
148
+ * Determine if a value is a File
149
+ *
150
+ * @param {Object} val The value to test
151
+ * @returns {boolean} True if value is a File, otherwise false
152
+ */
153
+ function isFile(val) {
154
+ return toString.call(val) === '[object File]';
155
+ }
156
+
157
+ /**
158
+ * Determine if a value is a Blob
159
+ *
160
+ * @param {Object} val The value to test
161
+ * @returns {boolean} True if value is a Blob, otherwise false
162
+ */
163
+ function isBlob(val) {
164
+ return toString.call(val) === '[object Blob]';
165
+ }
166
+
167
+ /**
168
+ * Determine if a value is a Function
169
+ *
170
+ * @param {Object} val The value to test
171
+ * @returns {boolean} True if value is a Function, otherwise false
172
+ */
173
+ function isFunction(val) {
174
+ return toString.call(val) === '[object Function]';
175
+ }
176
+
177
+ /**
178
+ * Determine if a value is a Stream
179
+ *
180
+ * @param {Object} val The value to test
181
+ * @returns {boolean} True if value is a Stream, otherwise false
182
+ */
183
+ function isStream(val) {
184
+ return isObject(val) && isFunction(val.pipe);
185
+ }
186
+
187
+ /**
188
+ * Determine if a value is a URLSearchParams object
189
+ *
190
+ * @param {Object} val The value to test
191
+ * @returns {boolean} True if value is a URLSearchParams object, otherwise false
192
+ */
193
+ function isURLSearchParams(val) {
194
+ return toString.call(val) === '[object URLSearchParams]';
195
+ }
196
+
197
+ /**
198
+ * Trim excess whitespace off the beginning and end of a string
199
+ *
200
+ * @param {String} str The String to trim
201
+ * @returns {String} The String freed of excess whitespace
202
+ */
203
+ function trim(str) {
204
+ return str.trim ? str.trim() : str.replace(/^\s+|\s+$/g, '');
205
+ }
206
+
207
+ /**
208
+ * Determine if we're running in a standard browser environment
209
+ *
210
+ * This allows axios to run in a web worker, and react-native.
211
+ * Both environments support XMLHttpRequest, but not fully standard globals.
212
+ *
213
+ * web workers:
214
+ * typeof window -> undefined
215
+ * typeof document -> undefined
216
+ *
217
+ * react-native:
218
+ * navigator.product -> 'ReactNative'
219
+ * nativescript
220
+ * navigator.product -> 'NativeScript' or 'NS'
221
+ */
222
+ function isStandardBrowserEnv() {
223
+ if (typeof navigator !== 'undefined' && (navigator.product === 'ReactNative' ||
224
+ navigator.product === 'NativeScript' ||
225
+ navigator.product === 'NS')) {
226
+ return false;
227
+ }
228
+ return (
229
+ typeof window !== 'undefined' &&
230
+ typeof document !== 'undefined'
231
+ );
232
+ }
233
+
234
+ /**
235
+ * Iterate over an Array or an Object invoking a function for each item.
236
+ *
237
+ * If `obj` is an Array callback will be called passing
238
+ * the value, index, and complete array for each item.
239
+ *
240
+ * If 'obj' is an Object callback will be called passing
241
+ * the value, key, and complete object for each property.
242
+ *
243
+ * @param {Object|Array} obj The object to iterate
244
+ * @param {Function} fn The callback to invoke for each item
245
+ */
246
+ function forEach(obj, fn) {
247
+ // Don't bother if no value provided
248
+ if (obj === null || typeof obj === 'undefined') {
249
+ return;
250
+ }
251
+
252
+ // Force an array if not already something iterable
253
+ if (typeof obj !== 'object') {
254
+ /*eslint no-param-reassign:0*/
255
+ obj = [obj];
256
+ }
257
+
258
+ if (isArray(obj)) {
259
+ // Iterate over array values
260
+ for (var i = 0, l = obj.length; i < l; i++) {
261
+ fn.call(null, obj[i], i, obj);
262
+ }
263
+ } else {
264
+ // Iterate over object keys
265
+ for (var key in obj) {
266
+ if (Object.prototype.hasOwnProperty.call(obj, key)) {
267
+ fn.call(null, obj[key], key, obj);
268
+ }
269
+ }
270
+ }
271
+ }
272
+
273
+ /**
274
+ * Accepts varargs expecting each argument to be an object, then
275
+ * immutably merges the properties of each object and returns result.
276
+ *
277
+ * When multiple objects contain the same key the later object in
278
+ * the arguments list will take precedence.
279
+ *
280
+ * Example:
281
+ *
282
+ * ```js
283
+ * var result = merge({foo: 123}, {foo: 456});
284
+ * console.log(result.foo); // outputs 456
285
+ * ```
286
+ *
287
+ * @param {Object} obj1 Object to merge
288
+ * @returns {Object} Result of all merge properties
289
+ */
290
+ function merge(/* obj1, obj2, obj3, ... */) {
291
+ var result = {};
292
+ function assignValue(val, key) {
293
+ if (isPlainObject(result[key]) && isPlainObject(val)) {
294
+ result[key] = merge(result[key], val);
295
+ } else if (isPlainObject(val)) {
296
+ result[key] = merge({}, val);
297
+ } else if (isArray(val)) {
298
+ result[key] = val.slice();
299
+ } else {
300
+ result[key] = val;
301
+ }
302
+ }
303
+
304
+ for (var i = 0, l = arguments.length; i < l; i++) {
305
+ forEach(arguments[i], assignValue);
306
+ }
307
+ return result;
308
+ }
309
+
310
+ /**
311
+ * Extends object a by mutably adding to it the properties of object b.
312
+ *
313
+ * @param {Object} a The object to be extended
314
+ * @param {Object} b The object to copy properties from
315
+ * @param {Object} thisArg The object to bind function to
316
+ * @return {Object} The resulting value of object a
317
+ */
318
+ function extend(a, b, thisArg) {
319
+ forEach(b, function assignValue(val, key) {
320
+ if (thisArg && typeof val === 'function') {
321
+ a[key] = bind(val, thisArg);
322
+ } else {
323
+ a[key] = val;
324
+ }
325
+ });
326
+ return a;
327
+ }
328
+
329
+ /**
330
+ * Remove byte order marker. This catches EF BB BF (the UTF-8 BOM)
331
+ *
332
+ * @param {string} content with BOM
333
+ * @return {string} content value without BOM
334
+ */
335
+ function stripBOM(content) {
336
+ if (content.charCodeAt(0) === 0xFEFF) {
337
+ content = content.slice(1);
338
+ }
339
+ return content;
340
+ }
341
+
342
+ var utils = {
343
+ isArray: isArray,
344
+ isArrayBuffer: isArrayBuffer,
345
+ isBuffer: isBuffer,
346
+ isFormData: isFormData,
347
+ isArrayBufferView: isArrayBufferView,
348
+ isString: isString,
349
+ isNumber: isNumber,
350
+ isObject: isObject,
351
+ isPlainObject: isPlainObject,
352
+ isUndefined: isUndefined,
353
+ isDate: isDate,
354
+ isFile: isFile,
355
+ isBlob: isBlob,
356
+ isFunction: isFunction,
357
+ isStream: isStream,
358
+ isURLSearchParams: isURLSearchParams,
359
+ isStandardBrowserEnv: isStandardBrowserEnv,
360
+ forEach: forEach,
361
+ merge: merge,
362
+ extend: extend,
363
+ trim: trim,
364
+ stripBOM: stripBOM
365
+ };
366
+
367
+ function encode(val) {
368
+ return encodeURIComponent(val).
369
+ replace(/%3A/gi, ':').
370
+ replace(/%24/g, '$').
371
+ replace(/%2C/gi, ',').
372
+ replace(/%20/g, '+').
373
+ replace(/%5B/gi, '[').
374
+ replace(/%5D/gi, ']');
375
+ }
376
+
377
+ /**
378
+ * Build a URL by appending params to the end
379
+ *
380
+ * @param {string} url The base of the url (e.g., http://www.google.com)
381
+ * @param {object} [params] The params to be appended
382
+ * @returns {string} The formatted url
383
+ */
384
+ var buildURL = function buildURL(url, params, paramsSerializer) {
385
+ /*eslint no-param-reassign:0*/
386
+ if (!params) {
387
+ return url;
388
+ }
389
+
390
+ var serializedParams;
391
+ if (paramsSerializer) {
392
+ serializedParams = paramsSerializer(params);
393
+ } else if (utils.isURLSearchParams(params)) {
394
+ serializedParams = params.toString();
395
+ } else {
396
+ var parts = [];
397
+
398
+ utils.forEach(params, function serialize(val, key) {
399
+ if (val === null || typeof val === 'undefined') {
400
+ return;
401
+ }
402
+
403
+ if (utils.isArray(val)) {
404
+ key = key + '[]';
405
+ } else {
406
+ val = [val];
407
+ }
408
+
409
+ utils.forEach(val, function parseValue(v) {
410
+ if (utils.isDate(v)) {
411
+ v = v.toISOString();
412
+ } else if (utils.isObject(v)) {
413
+ v = JSON.stringify(v);
414
+ }
415
+ parts.push(encode(key) + '=' + encode(v));
416
+ });
417
+ });
418
+
419
+ serializedParams = parts.join('&');
420
+ }
421
+
422
+ if (serializedParams) {
423
+ var hashmarkIndex = url.indexOf('#');
424
+ if (hashmarkIndex !== -1) {
425
+ url = url.slice(0, hashmarkIndex);
426
+ }
427
+
428
+ url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
429
+ }
430
+
431
+ return url;
432
+ };
433
+
434
+ function InterceptorManager() {
435
+ this.handlers = [];
436
+ }
437
+
438
+ /**
439
+ * Add a new interceptor to the stack
440
+ *
441
+ * @param {Function} fulfilled The function to handle `then` for a `Promise`
442
+ * @param {Function} rejected The function to handle `reject` for a `Promise`
443
+ *
444
+ * @return {Number} An ID used to remove interceptor later
445
+ */
446
+ InterceptorManager.prototype.use = function use(fulfilled, rejected, options) {
447
+ this.handlers.push({
448
+ fulfilled: fulfilled,
449
+ rejected: rejected,
450
+ synchronous: options ? options.synchronous : false,
451
+ runWhen: options ? options.runWhen : null
452
+ });
453
+ return this.handlers.length - 1;
454
+ };
455
+
456
+ /**
457
+ * Remove an interceptor from the stack
458
+ *
459
+ * @param {Number} id The ID that was returned by `use`
460
+ */
461
+ InterceptorManager.prototype.eject = function eject(id) {
462
+ if (this.handlers[id]) {
463
+ this.handlers[id] = null;
464
+ }
465
+ };
466
+
467
+ /**
468
+ * Iterate over all the registered interceptors
469
+ *
470
+ * This method is particularly useful for skipping over any
471
+ * interceptors that may have become `null` calling `eject`.
472
+ *
473
+ * @param {Function} fn The function to call for each interceptor
474
+ */
475
+ InterceptorManager.prototype.forEach = function forEach(fn) {
476
+ utils.forEach(this.handlers, function forEachHandler(h) {
477
+ if (h !== null) {
478
+ fn(h);
479
+ }
480
+ });
481
+ };
482
+
483
+ var InterceptorManager_1 = InterceptorManager;
484
+
485
+ var normalizeHeaderName = function normalizeHeaderName(headers, normalizedName) {
486
+ utils.forEach(headers, function processHeader(value, name) {
487
+ if (name !== normalizedName && name.toUpperCase() === normalizedName.toUpperCase()) {
488
+ headers[normalizedName] = value;
489
+ delete headers[name];
490
+ }
491
+ });
492
+ };
493
+
494
+ /**
495
+ * Update an Error with the specified config, error code, and response.
496
+ *
497
+ * @param {Error} error The error to update.
498
+ * @param {Object} config The config.
499
+ * @param {string} [code] The error code (for example, 'ECONNABORTED').
500
+ * @param {Object} [request] The request.
501
+ * @param {Object} [response] The response.
502
+ * @returns {Error} The error.
503
+ */
504
+ var enhanceError = function enhanceError(error, config, code, request, response) {
505
+ error.config = config;
506
+ if (code) {
507
+ error.code = code;
508
+ }
509
+
510
+ error.request = request;
511
+ error.response = response;
512
+ error.isAxiosError = true;
513
+
514
+ error.toJSON = function toJSON() {
515
+ return {
516
+ // Standard
517
+ message: this.message,
518
+ name: this.name,
519
+ // Microsoft
520
+ description: this.description,
521
+ number: this.number,
522
+ // Mozilla
523
+ fileName: this.fileName,
524
+ lineNumber: this.lineNumber,
525
+ columnNumber: this.columnNumber,
526
+ stack: this.stack,
527
+ // Axios
528
+ config: this.config,
529
+ code: this.code,
530
+ status: this.response && this.response.status ? this.response.status : null
531
+ };
532
+ };
533
+ return error;
534
+ };
535
+
536
+ var transitional = {
537
+ silentJSONParsing: true,
538
+ forcedJSONParsing: true,
539
+ clarifyTimeoutError: false
540
+ };
541
+
542
+ /**
543
+ * Create an Error with the specified message, config, error code, request and response.
544
+ *
545
+ * @param {string} message The error message.
546
+ * @param {Object} config The config.
547
+ * @param {string} [code] The error code (for example, 'ECONNABORTED').
548
+ * @param {Object} [request] The request.
549
+ * @param {Object} [response] The response.
550
+ * @returns {Error} The created error.
551
+ */
552
+ var createError = function createError(message, config, code, request, response) {
553
+ var error = new Error(message);
554
+ return enhanceError(error, config, code, request, response);
555
+ };
556
+
557
+ /**
558
+ * Resolve or reject a Promise based on response status.
559
+ *
560
+ * @param {Function} resolve A function that resolves the promise.
561
+ * @param {Function} reject A function that rejects the promise.
562
+ * @param {object} response The response.
563
+ */
564
+ var settle = function settle(resolve, reject, response) {
565
+ var validateStatus = response.config.validateStatus;
566
+ if (!response.status || !validateStatus || validateStatus(response.status)) {
567
+ resolve(response);
568
+ } else {
569
+ reject(createError(
570
+ 'Request failed with status code ' + response.status,
571
+ response.config,
572
+ null,
573
+ response.request,
574
+ response
575
+ ));
576
+ }
577
+ };
578
+
579
+ var cookies = (
580
+ utils.isStandardBrowserEnv() ?
581
+
582
+ // Standard browser envs support document.cookie
583
+ (function standardBrowserEnv() {
584
+ return {
585
+ write: function write(name, value, expires, path, domain, secure) {
586
+ var cookie = [];
587
+ cookie.push(name + '=' + encodeURIComponent(value));
588
+
589
+ if (utils.isNumber(expires)) {
590
+ cookie.push('expires=' + new Date(expires).toGMTString());
591
+ }
592
+
593
+ if (utils.isString(path)) {
594
+ cookie.push('path=' + path);
595
+ }
596
+
597
+ if (utils.isString(domain)) {
598
+ cookie.push('domain=' + domain);
599
+ }
600
+
601
+ if (secure === true) {
602
+ cookie.push('secure');
603
+ }
604
+
605
+ document.cookie = cookie.join('; ');
606
+ },
607
+
608
+ read: function read(name) {
609
+ var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
610
+ return (match ? decodeURIComponent(match[3]) : null);
611
+ },
612
+
613
+ remove: function remove(name) {
614
+ this.write(name, '', Date.now() - 86400000);
615
+ }
616
+ };
617
+ })() :
618
+
619
+ // Non standard browser env (web workers, react-native) lack needed support.
620
+ (function nonStandardBrowserEnv() {
621
+ return {
622
+ write: function write() {},
623
+ read: function read() { return null; },
624
+ remove: function remove() {}
625
+ };
626
+ })()
627
+ );
628
+
629
+ /**
630
+ * Determines whether the specified URL is absolute
631
+ *
632
+ * @param {string} url The URL to test
633
+ * @returns {boolean} True if the specified URL is absolute, otherwise false
634
+ */
635
+ var isAbsoluteURL = function isAbsoluteURL(url) {
636
+ // A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
637
+ // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
638
+ // by any combination of letters, digits, plus, period, or hyphen.
639
+ return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
640
+ };
641
+
642
+ /**
643
+ * Creates a new URL by combining the specified URLs
644
+ *
645
+ * @param {string} baseURL The base URL
646
+ * @param {string} relativeURL The relative URL
647
+ * @returns {string} The combined URL
648
+ */
649
+ var combineURLs = function combineURLs(baseURL, relativeURL) {
650
+ return relativeURL
651
+ ? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '')
652
+ : baseURL;
653
+ };
654
+
655
+ /**
656
+ * Creates a new URL by combining the baseURL with the requestedURL,
657
+ * only when the requestedURL is not already an absolute URL.
658
+ * If the requestURL is absolute, this function returns the requestedURL untouched.
659
+ *
660
+ * @param {string} baseURL The base URL
661
+ * @param {string} requestedURL Absolute or relative URL to combine
662
+ * @returns {string} The combined full path
663
+ */
664
+ var buildFullPath = function buildFullPath(baseURL, requestedURL) {
665
+ if (baseURL && !isAbsoluteURL(requestedURL)) {
666
+ return combineURLs(baseURL, requestedURL);
667
+ }
668
+ return requestedURL;
669
+ };
670
+
671
+ // Headers whose duplicates are ignored by node
672
+ // c.f. https://nodejs.org/api/http.html#http_message_headers
673
+ var ignoreDuplicateOf = [
674
+ 'age', 'authorization', 'content-length', 'content-type', 'etag',
675
+ 'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since',
676
+ 'last-modified', 'location', 'max-forwards', 'proxy-authorization',
677
+ 'referer', 'retry-after', 'user-agent'
678
+ ];
679
+
680
+ /**
681
+ * Parse headers into an object
682
+ *
683
+ * ```
684
+ * Date: Wed, 27 Aug 2014 08:58:49 GMT
685
+ * Content-Type: application/json
686
+ * Connection: keep-alive
687
+ * Transfer-Encoding: chunked
688
+ * ```
689
+ *
690
+ * @param {String} headers Headers needing to be parsed
691
+ * @returns {Object} Headers parsed into an object
692
+ */
693
+ var parseHeaders = function parseHeaders(headers) {
694
+ var parsed = {};
695
+ var key;
696
+ var val;
697
+ var i;
698
+
699
+ if (!headers) { return parsed; }
700
+
701
+ utils.forEach(headers.split('\n'), function parser(line) {
702
+ i = line.indexOf(':');
703
+ key = utils.trim(line.substr(0, i)).toLowerCase();
704
+ val = utils.trim(line.substr(i + 1));
705
+
706
+ if (key) {
707
+ if (parsed[key] && ignoreDuplicateOf.indexOf(key) >= 0) {
708
+ return;
709
+ }
710
+ if (key === 'set-cookie') {
711
+ parsed[key] = (parsed[key] ? parsed[key] : []).concat([val]);
712
+ } else {
713
+ parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
714
+ }
715
+ }
716
+ });
717
+
718
+ return parsed;
719
+ };
720
+
721
+ var isURLSameOrigin = (
722
+ utils.isStandardBrowserEnv() ?
723
+
724
+ // Standard browser envs have full support of the APIs needed to test
725
+ // whether the request URL is of the same origin as current location.
726
+ (function standardBrowserEnv() {
727
+ var msie = /(msie|trident)/i.test(navigator.userAgent);
728
+ var urlParsingNode = document.createElement('a');
729
+ var originURL;
730
+
731
+ /**
732
+ * Parse a URL to discover it's components
733
+ *
734
+ * @param {String} url The URL to be parsed
735
+ * @returns {Object}
736
+ */
737
+ function resolveURL(url) {
738
+ var href = url;
739
+
740
+ if (msie) {
741
+ // IE needs attribute set twice to normalize properties
742
+ urlParsingNode.setAttribute('href', href);
743
+ href = urlParsingNode.href;
744
+ }
745
+
746
+ urlParsingNode.setAttribute('href', href);
747
+
748
+ // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
749
+ return {
750
+ href: urlParsingNode.href,
751
+ protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
752
+ host: urlParsingNode.host,
753
+ search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
754
+ hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
755
+ hostname: urlParsingNode.hostname,
756
+ port: urlParsingNode.port,
757
+ pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
758
+ urlParsingNode.pathname :
759
+ '/' + urlParsingNode.pathname
760
+ };
761
+ }
762
+
763
+ originURL = resolveURL(window.location.href);
764
+
765
+ /**
766
+ * Determine if a URL shares the same origin as the current location
767
+ *
768
+ * @param {String} requestURL The URL to test
769
+ * @returns {boolean} True if URL shares the same origin, otherwise false
770
+ */
771
+ return function isURLSameOrigin(requestURL) {
772
+ var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
773
+ return (parsed.protocol === originURL.protocol &&
774
+ parsed.host === originURL.host);
775
+ };
776
+ })() :
777
+
778
+ // Non standard browser envs (web workers, react-native) lack needed support.
779
+ (function nonStandardBrowserEnv() {
780
+ return function isURLSameOrigin() {
781
+ return true;
782
+ };
783
+ })()
784
+ );
785
+
786
+ /**
787
+ * A `Cancel` is an object that is thrown when an operation is canceled.
788
+ *
789
+ * @class
790
+ * @param {string=} message The message.
791
+ */
792
+ function Cancel(message) {
793
+ this.message = message;
794
+ }
795
+
796
+ Cancel.prototype.toString = function toString() {
797
+ return 'Cancel' + (this.message ? ': ' + this.message : '');
798
+ };
799
+
800
+ Cancel.prototype.__CANCEL__ = true;
801
+
802
+ var Cancel_1 = Cancel;
803
+
804
+ var xhr = function xhrAdapter(config) {
805
+ return new Promise(function dispatchXhrRequest(resolve, reject) {
806
+ var requestData = config.data;
807
+ var requestHeaders = config.headers;
808
+ var responseType = config.responseType;
809
+ var onCanceled;
810
+ function done() {
811
+ if (config.cancelToken) {
812
+ config.cancelToken.unsubscribe(onCanceled);
813
+ }
814
+
815
+ if (config.signal) {
816
+ config.signal.removeEventListener('abort', onCanceled);
817
+ }
818
+ }
819
+
820
+ if (utils.isFormData(requestData)) {
821
+ delete requestHeaders['Content-Type']; // Let the browser set it
822
+ }
823
+
824
+ var request = new XMLHttpRequest();
825
+
826
+ // HTTP basic authentication
827
+ if (config.auth) {
828
+ var username = config.auth.username || '';
829
+ var password = config.auth.password ? unescape(encodeURIComponent(config.auth.password)) : '';
830
+ requestHeaders.Authorization = 'Basic ' + btoa(username + ':' + password);
831
+ }
832
+
833
+ var fullPath = buildFullPath(config.baseURL, config.url);
834
+ request.open(config.method.toUpperCase(), buildURL(fullPath, config.params, config.paramsSerializer), true);
835
+
836
+ // Set the request timeout in MS
837
+ request.timeout = config.timeout;
838
+
839
+ function onloadend() {
840
+ if (!request) {
841
+ return;
842
+ }
843
+ // Prepare the response
844
+ var responseHeaders = 'getAllResponseHeaders' in request ? parseHeaders(request.getAllResponseHeaders()) : null;
845
+ var responseData = !responseType || responseType === 'text' || responseType === 'json' ?
846
+ request.responseText : request.response;
847
+ var response = {
848
+ data: responseData,
849
+ status: request.status,
850
+ statusText: request.statusText,
851
+ headers: responseHeaders,
852
+ config: config,
853
+ request: request
854
+ };
855
+
856
+ settle(function _resolve(value) {
857
+ resolve(value);
858
+ done();
859
+ }, function _reject(err) {
860
+ reject(err);
861
+ done();
862
+ }, response);
863
+
864
+ // Clean up request
865
+ request = null;
866
+ }
867
+
868
+ if ('onloadend' in request) {
869
+ // Use onloadend if available
870
+ request.onloadend = onloadend;
871
+ } else {
872
+ // Listen for ready state to emulate onloadend
873
+ request.onreadystatechange = function handleLoad() {
874
+ if (!request || request.readyState !== 4) {
875
+ return;
876
+ }
877
+
878
+ // The request errored out and we didn't get a response, this will be
879
+ // handled by onerror instead
880
+ // With one exception: request that using file: protocol, most browsers
881
+ // will return status as 0 even though it's a successful request
882
+ if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {
883
+ return;
884
+ }
885
+ // readystate handler is calling before onerror or ontimeout handlers,
886
+ // so we should call onloadend on the next 'tick'
887
+ setTimeout(onloadend);
888
+ };
889
+ }
890
+
891
+ // Handle browser request cancellation (as opposed to a manual cancellation)
892
+ request.onabort = function handleAbort() {
893
+ if (!request) {
894
+ return;
895
+ }
896
+
897
+ reject(createError('Request aborted', config, 'ECONNABORTED', request));
898
+
899
+ // Clean up request
900
+ request = null;
901
+ };
902
+
903
+ // Handle low level network errors
904
+ request.onerror = function handleError() {
905
+ // Real errors are hidden from us by the browser
906
+ // onerror should only fire if it's a network error
907
+ reject(createError('Network Error', config, null, request));
908
+
909
+ // Clean up request
910
+ request = null;
911
+ };
912
+
913
+ // Handle timeout
914
+ request.ontimeout = function handleTimeout() {
915
+ var timeoutErrorMessage = config.timeout ? 'timeout of ' + config.timeout + 'ms exceeded' : 'timeout exceeded';
916
+ var transitional$1 = config.transitional || transitional;
917
+ if (config.timeoutErrorMessage) {
918
+ timeoutErrorMessage = config.timeoutErrorMessage;
919
+ }
920
+ reject(createError(
921
+ timeoutErrorMessage,
922
+ config,
923
+ transitional$1.clarifyTimeoutError ? 'ETIMEDOUT' : 'ECONNABORTED',
924
+ request));
925
+
926
+ // Clean up request
927
+ request = null;
928
+ };
929
+
930
+ // Add xsrf header
931
+ // This is only done if running in a standard browser environment.
932
+ // Specifically not if we're in a web worker, or react-native.
933
+ if (utils.isStandardBrowserEnv()) {
934
+ // Add xsrf header
935
+ var xsrfValue = (config.withCredentials || isURLSameOrigin(fullPath)) && config.xsrfCookieName ?
936
+ cookies.read(config.xsrfCookieName) :
937
+ undefined;
938
+
939
+ if (xsrfValue) {
940
+ requestHeaders[config.xsrfHeaderName] = xsrfValue;
941
+ }
942
+ }
943
+
944
+ // Add headers to the request
945
+ if ('setRequestHeader' in request) {
946
+ utils.forEach(requestHeaders, function setRequestHeader(val, key) {
947
+ if (typeof requestData === 'undefined' && key.toLowerCase() === 'content-type') {
948
+ // Remove Content-Type if data is undefined
949
+ delete requestHeaders[key];
950
+ } else {
951
+ // Otherwise add header to the request
952
+ request.setRequestHeader(key, val);
953
+ }
954
+ });
955
+ }
956
+
957
+ // Add withCredentials to request if needed
958
+ if (!utils.isUndefined(config.withCredentials)) {
959
+ request.withCredentials = !!config.withCredentials;
960
+ }
961
+
962
+ // Add responseType to request if needed
963
+ if (responseType && responseType !== 'json') {
964
+ request.responseType = config.responseType;
965
+ }
966
+
967
+ // Handle progress if needed
968
+ if (typeof config.onDownloadProgress === 'function') {
969
+ request.addEventListener('progress', config.onDownloadProgress);
970
+ }
971
+
972
+ // Not all browsers support upload events
973
+ if (typeof config.onUploadProgress === 'function' && request.upload) {
974
+ request.upload.addEventListener('progress', config.onUploadProgress);
975
+ }
976
+
977
+ if (config.cancelToken || config.signal) {
978
+ // Handle cancellation
979
+ // eslint-disable-next-line func-names
980
+ onCanceled = function(cancel) {
981
+ if (!request) {
982
+ return;
983
+ }
984
+ reject(!cancel || (cancel && cancel.type) ? new Cancel_1('canceled') : cancel);
985
+ request.abort();
986
+ request = null;
987
+ };
988
+
989
+ config.cancelToken && config.cancelToken.subscribe(onCanceled);
990
+ if (config.signal) {
991
+ config.signal.aborted ? onCanceled() : config.signal.addEventListener('abort', onCanceled);
992
+ }
993
+ }
994
+
995
+ if (!requestData) {
996
+ requestData = null;
997
+ }
998
+
999
+ // Send the request
1000
+ request.send(requestData);
1001
+ });
1002
+ };
1003
+
1004
+ function createCommonjsModule(fn, basedir, module) {
1005
+ return module = {
1006
+ path: basedir,
1007
+ exports: {},
1008
+ require: function (path, base) {
1009
+ return commonjsRequire(path, (base === undefined || base === null) ? module.path : base);
1010
+ }
1011
+ }, fn(module, module.exports), module.exports;
1012
+ }
1013
+
1014
+ function commonjsRequire () {
1015
+ throw new Error('Dynamic requires are not currently supported by @rollup/plugin-commonjs');
1016
+ }
1017
+
1018
+ /**
1019
+ * Helpers.
1020
+ */
1021
+
1022
+ var s = 1000;
1023
+ var m = s * 60;
1024
+ var h = m * 60;
1025
+ var d = h * 24;
1026
+ var w = d * 7;
1027
+ var y = d * 365.25;
1028
+
1029
+ /**
1030
+ * Parse or format the given `val`.
1031
+ *
1032
+ * Options:
1033
+ *
1034
+ * - `long` verbose formatting [false]
1035
+ *
1036
+ * @param {String|Number} val
1037
+ * @param {Object} [options]
1038
+ * @throws {Error} throw an error if val is not a non-empty string or a number
1039
+ * @return {String|Number}
1040
+ * @api public
1041
+ */
1042
+
1043
+ var ms = function(val, options) {
1044
+ options = options || {};
1045
+ var type = typeof val;
1046
+ if (type === 'string' && val.length > 0) {
1047
+ return parse(val);
1048
+ } else if (type === 'number' && isFinite(val)) {
1049
+ return options.long ? fmtLong(val) : fmtShort(val);
1050
+ }
1051
+ throw new Error(
1052
+ 'val is not a non-empty string or a valid number. val=' +
1053
+ JSON.stringify(val)
1054
+ );
1055
+ };
1056
+
1057
+ /**
1058
+ * Parse the given `str` and return milliseconds.
1059
+ *
1060
+ * @param {String} str
1061
+ * @return {Number}
1062
+ * @api private
1063
+ */
1064
+
1065
+ function parse(str) {
1066
+ str = String(str);
1067
+ if (str.length > 100) {
1068
+ return;
1069
+ }
1070
+ var match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(
1071
+ str
1072
+ );
1073
+ if (!match) {
1074
+ return;
1075
+ }
1076
+ var n = parseFloat(match[1]);
1077
+ var type = (match[2] || 'ms').toLowerCase();
1078
+ switch (type) {
1079
+ case 'years':
1080
+ case 'year':
1081
+ case 'yrs':
1082
+ case 'yr':
1083
+ case 'y':
1084
+ return n * y;
1085
+ case 'weeks':
1086
+ case 'week':
1087
+ case 'w':
1088
+ return n * w;
1089
+ case 'days':
1090
+ case 'day':
1091
+ case 'd':
1092
+ return n * d;
1093
+ case 'hours':
1094
+ case 'hour':
1095
+ case 'hrs':
1096
+ case 'hr':
1097
+ case 'h':
1098
+ return n * h;
1099
+ case 'minutes':
1100
+ case 'minute':
1101
+ case 'mins':
1102
+ case 'min':
1103
+ case 'm':
1104
+ return n * m;
1105
+ case 'seconds':
1106
+ case 'second':
1107
+ case 'secs':
1108
+ case 'sec':
1109
+ case 's':
1110
+ return n * s;
1111
+ case 'milliseconds':
1112
+ case 'millisecond':
1113
+ case 'msecs':
1114
+ case 'msec':
1115
+ case 'ms':
1116
+ return n;
1117
+ default:
1118
+ return undefined;
1119
+ }
1120
+ }
1121
+
1122
+ /**
1123
+ * Short format for `ms`.
1124
+ *
1125
+ * @param {Number} ms
1126
+ * @return {String}
1127
+ * @api private
1128
+ */
1129
+
1130
+ function fmtShort(ms) {
1131
+ var msAbs = Math.abs(ms);
1132
+ if (msAbs >= d) {
1133
+ return Math.round(ms / d) + 'd';
1134
+ }
1135
+ if (msAbs >= h) {
1136
+ return Math.round(ms / h) + 'h';
1137
+ }
1138
+ if (msAbs >= m) {
1139
+ return Math.round(ms / m) + 'm';
1140
+ }
1141
+ if (msAbs >= s) {
1142
+ return Math.round(ms / s) + 's';
1143
+ }
1144
+ return ms + 'ms';
1145
+ }
1146
+
1147
+ /**
1148
+ * Long format for `ms`.
1149
+ *
1150
+ * @param {Number} ms
1151
+ * @return {String}
1152
+ * @api private
1153
+ */
1154
+
1155
+ function fmtLong(ms) {
1156
+ var msAbs = Math.abs(ms);
1157
+ if (msAbs >= d) {
1158
+ return plural(ms, msAbs, d, 'day');
1159
+ }
1160
+ if (msAbs >= h) {
1161
+ return plural(ms, msAbs, h, 'hour');
1162
+ }
1163
+ if (msAbs >= m) {
1164
+ return plural(ms, msAbs, m, 'minute');
1165
+ }
1166
+ if (msAbs >= s) {
1167
+ return plural(ms, msAbs, s, 'second');
1168
+ }
1169
+ return ms + ' ms';
1170
+ }
1171
+
1172
+ /**
1173
+ * Pluralization helper.
1174
+ */
1175
+
1176
+ function plural(ms, msAbs, n, name) {
1177
+ var isPlural = msAbs >= n * 1.5;
1178
+ return Math.round(ms / n) + ' ' + name + (isPlural ? 's' : '');
1179
+ }
1180
+
1181
+ /**
1182
+ * This is the common logic for both the Node.js and web browser
1183
+ * implementations of `debug()`.
1184
+ */
1185
+
1186
+ function setup(env) {
1187
+ createDebug.debug = createDebug;
1188
+ createDebug.default = createDebug;
1189
+ createDebug.coerce = coerce;
1190
+ createDebug.disable = disable;
1191
+ createDebug.enable = enable;
1192
+ createDebug.enabled = enabled;
1193
+ createDebug.humanize = ms;
1194
+ createDebug.destroy = destroy;
1195
+
1196
+ Object.keys(env).forEach(key => {
1197
+ createDebug[key] = env[key];
1198
+ });
1199
+
1200
+ /**
1201
+ * The currently active debug mode names, and names to skip.
1202
+ */
1203
+
1204
+ createDebug.names = [];
1205
+ createDebug.skips = [];
1206
+
1207
+ /**
1208
+ * Map of special "%n" handling functions, for the debug "format" argument.
1209
+ *
1210
+ * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N".
1211
+ */
1212
+ createDebug.formatters = {};
1213
+
1214
+ /**
1215
+ * Selects a color for a debug namespace
1216
+ * @param {String} namespace The namespace string for the debug instance to be colored
1217
+ * @return {Number|String} An ANSI color code for the given namespace
1218
+ * @api private
1219
+ */
1220
+ function selectColor(namespace) {
1221
+ let hash = 0;
1222
+
1223
+ for (let i = 0; i < namespace.length; i++) {
1224
+ hash = ((hash << 5) - hash) + namespace.charCodeAt(i);
1225
+ hash |= 0; // Convert to 32bit integer
1226
+ }
1227
+
1228
+ return createDebug.colors[Math.abs(hash) % createDebug.colors.length];
1229
+ }
1230
+ createDebug.selectColor = selectColor;
1231
+
1232
+ /**
1233
+ * Create a debugger with the given `namespace`.
1234
+ *
1235
+ * @param {String} namespace
1236
+ * @return {Function}
1237
+ * @api public
1238
+ */
1239
+ function createDebug(namespace) {
1240
+ let prevTime;
1241
+ let enableOverride = null;
1242
+ let namespacesCache;
1243
+ let enabledCache;
1244
+
1245
+ function debug(...args) {
1246
+ // Disabled?
1247
+ if (!debug.enabled) {
1248
+ return;
1249
+ }
1250
+
1251
+ const self = debug;
1252
+
1253
+ // Set `diff` timestamp
1254
+ const curr = Number(new Date());
1255
+ const ms = curr - (prevTime || curr);
1256
+ self.diff = ms;
1257
+ self.prev = prevTime;
1258
+ self.curr = curr;
1259
+ prevTime = curr;
1260
+
1261
+ args[0] = createDebug.coerce(args[0]);
1262
+
1263
+ if (typeof args[0] !== 'string') {
1264
+ // Anything else let's inspect with %O
1265
+ args.unshift('%O');
1266
+ }
1267
+
1268
+ // Apply any `formatters` transformations
1269
+ let index = 0;
1270
+ args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {
1271
+ // If we encounter an escaped % then don't increase the array index
1272
+ if (match === '%%') {
1273
+ return '%';
1274
+ }
1275
+ index++;
1276
+ const formatter = createDebug.formatters[format];
1277
+ if (typeof formatter === 'function') {
1278
+ const val = args[index];
1279
+ match = formatter.call(self, val);
1280
+
1281
+ // Now we need to remove `args[index]` since it's inlined in the `format`
1282
+ args.splice(index, 1);
1283
+ index--;
1284
+ }
1285
+ return match;
1286
+ });
1287
+
1288
+ // Apply env-specific formatting (colors, etc.)
1289
+ createDebug.formatArgs.call(self, args);
1290
+
1291
+ const logFn = self.log || createDebug.log;
1292
+ logFn.apply(self, args);
1293
+ }
1294
+
1295
+ debug.namespace = namespace;
1296
+ debug.useColors = createDebug.useColors();
1297
+ debug.color = createDebug.selectColor(namespace);
1298
+ debug.extend = extend;
1299
+ debug.destroy = createDebug.destroy; // XXX Temporary. Will be removed in the next major release.
1300
+
1301
+ Object.defineProperty(debug, 'enabled', {
1302
+ enumerable: true,
1303
+ configurable: false,
1304
+ get: () => {
1305
+ if (enableOverride !== null) {
1306
+ return enableOverride;
1307
+ }
1308
+ if (namespacesCache !== createDebug.namespaces) {
1309
+ namespacesCache = createDebug.namespaces;
1310
+ enabledCache = createDebug.enabled(namespace);
1311
+ }
1312
+
1313
+ return enabledCache;
1314
+ },
1315
+ set: v => {
1316
+ enableOverride = v;
1317
+ }
1318
+ });
1319
+
1320
+ // Env-specific initialization logic for debug instances
1321
+ if (typeof createDebug.init === 'function') {
1322
+ createDebug.init(debug);
1323
+ }
1324
+
1325
+ return debug;
1326
+ }
1327
+
1328
+ function extend(namespace, delimiter) {
1329
+ const newDebug = createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace);
1330
+ newDebug.log = this.log;
1331
+ return newDebug;
1332
+ }
1333
+
1334
+ /**
1335
+ * Enables a debug mode by namespaces. This can include modes
1336
+ * separated by a colon and wildcards.
1337
+ *
1338
+ * @param {String} namespaces
1339
+ * @api public
1340
+ */
1341
+ function enable(namespaces) {
1342
+ createDebug.save(namespaces);
1343
+ createDebug.namespaces = namespaces;
1344
+
1345
+ createDebug.names = [];
1346
+ createDebug.skips = [];
1347
+
1348
+ let i;
1349
+ const split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/);
1350
+ const len = split.length;
1351
+
1352
+ for (i = 0; i < len; i++) {
1353
+ if (!split[i]) {
1354
+ // ignore empty strings
1355
+ continue;
1356
+ }
1357
+
1358
+ namespaces = split[i].replace(/\*/g, '.*?');
1359
+
1360
+ if (namespaces[0] === '-') {
1361
+ createDebug.skips.push(new RegExp('^' + namespaces.slice(1) + '$'));
1362
+ } else {
1363
+ createDebug.names.push(new RegExp('^' + namespaces + '$'));
1364
+ }
1365
+ }
1366
+ }
1367
+
1368
+ /**
1369
+ * Disable debug output.
1370
+ *
1371
+ * @return {String} namespaces
1372
+ * @api public
1373
+ */
1374
+ function disable() {
1375
+ const namespaces = [
1376
+ ...createDebug.names.map(toNamespace),
1377
+ ...createDebug.skips.map(toNamespace).map(namespace => '-' + namespace)
1378
+ ].join(',');
1379
+ createDebug.enable('');
1380
+ return namespaces;
1381
+ }
1382
+
1383
+ /**
1384
+ * Returns true if the given mode name is enabled, false otherwise.
1385
+ *
1386
+ * @param {String} name
1387
+ * @return {Boolean}
1388
+ * @api public
1389
+ */
1390
+ function enabled(name) {
1391
+ if (name[name.length - 1] === '*') {
1392
+ return true;
1393
+ }
1394
+
1395
+ let i;
1396
+ let len;
1397
+
1398
+ for (i = 0, len = createDebug.skips.length; i < len; i++) {
1399
+ if (createDebug.skips[i].test(name)) {
1400
+ return false;
1401
+ }
1402
+ }
1403
+
1404
+ for (i = 0, len = createDebug.names.length; i < len; i++) {
1405
+ if (createDebug.names[i].test(name)) {
1406
+ return true;
1407
+ }
1408
+ }
1409
+
1410
+ return false;
1411
+ }
1412
+
1413
+ /**
1414
+ * Convert regexp to namespace
1415
+ *
1416
+ * @param {RegExp} regxep
1417
+ * @return {String} namespace
1418
+ * @api private
1419
+ */
1420
+ function toNamespace(regexp) {
1421
+ return regexp.toString()
1422
+ .substring(2, regexp.toString().length - 2)
1423
+ .replace(/\.\*\?$/, '*');
1424
+ }
1425
+
1426
+ /**
1427
+ * Coerce `val`.
1428
+ *
1429
+ * @param {Mixed} val
1430
+ * @return {Mixed}
1431
+ * @api private
1432
+ */
1433
+ function coerce(val) {
1434
+ if (val instanceof Error) {
1435
+ return val.stack || val.message;
1436
+ }
1437
+ return val;
1438
+ }
1439
+
1440
+ /**
1441
+ * XXX DO NOT USE. This is a temporary stub function.
1442
+ * XXX It WILL be removed in the next major release.
1443
+ */
1444
+ function destroy() {
1445
+ console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');
1446
+ }
1447
+
1448
+ createDebug.enable(createDebug.load());
1449
+
1450
+ return createDebug;
1451
+ }
1452
+
1453
+ var common = setup;
1454
+
1455
+ var browser = createCommonjsModule(function (module, exports) {
1456
+ /* eslint-env browser */
1457
+
1458
+ /**
1459
+ * This is the web browser implementation of `debug()`.
1460
+ */
1461
+
1462
+ exports.formatArgs = formatArgs;
1463
+ exports.save = save;
1464
+ exports.load = load;
1465
+ exports.useColors = useColors;
1466
+ exports.storage = localstorage();
1467
+ exports.destroy = (() => {
1468
+ let warned = false;
1469
+
1470
+ return () => {
1471
+ if (!warned) {
1472
+ warned = true;
1473
+ console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');
1474
+ }
1475
+ };
1476
+ })();
1477
+
1478
+ /**
1479
+ * Colors.
1480
+ */
1481
+
1482
+ exports.colors = [
1483
+ '#0000CC',
1484
+ '#0000FF',
1485
+ '#0033CC',
1486
+ '#0033FF',
1487
+ '#0066CC',
1488
+ '#0066FF',
1489
+ '#0099CC',
1490
+ '#0099FF',
1491
+ '#00CC00',
1492
+ '#00CC33',
1493
+ '#00CC66',
1494
+ '#00CC99',
1495
+ '#00CCCC',
1496
+ '#00CCFF',
1497
+ '#3300CC',
1498
+ '#3300FF',
1499
+ '#3333CC',
1500
+ '#3333FF',
1501
+ '#3366CC',
1502
+ '#3366FF',
1503
+ '#3399CC',
1504
+ '#3399FF',
1505
+ '#33CC00',
1506
+ '#33CC33',
1507
+ '#33CC66',
1508
+ '#33CC99',
1509
+ '#33CCCC',
1510
+ '#33CCFF',
1511
+ '#6600CC',
1512
+ '#6600FF',
1513
+ '#6633CC',
1514
+ '#6633FF',
1515
+ '#66CC00',
1516
+ '#66CC33',
1517
+ '#9900CC',
1518
+ '#9900FF',
1519
+ '#9933CC',
1520
+ '#9933FF',
1521
+ '#99CC00',
1522
+ '#99CC33',
1523
+ '#CC0000',
1524
+ '#CC0033',
1525
+ '#CC0066',
1526
+ '#CC0099',
1527
+ '#CC00CC',
1528
+ '#CC00FF',
1529
+ '#CC3300',
1530
+ '#CC3333',
1531
+ '#CC3366',
1532
+ '#CC3399',
1533
+ '#CC33CC',
1534
+ '#CC33FF',
1535
+ '#CC6600',
1536
+ '#CC6633',
1537
+ '#CC9900',
1538
+ '#CC9933',
1539
+ '#CCCC00',
1540
+ '#CCCC33',
1541
+ '#FF0000',
1542
+ '#FF0033',
1543
+ '#FF0066',
1544
+ '#FF0099',
1545
+ '#FF00CC',
1546
+ '#FF00FF',
1547
+ '#FF3300',
1548
+ '#FF3333',
1549
+ '#FF3366',
1550
+ '#FF3399',
1551
+ '#FF33CC',
1552
+ '#FF33FF',
1553
+ '#FF6600',
1554
+ '#FF6633',
1555
+ '#FF9900',
1556
+ '#FF9933',
1557
+ '#FFCC00',
1558
+ '#FFCC33'
1559
+ ];
1560
+
1561
+ /**
1562
+ * Currently only WebKit-based Web Inspectors, Firefox >= v31,
1563
+ * and the Firebug extension (any Firefox version) are known
1564
+ * to support "%c" CSS customizations.
1565
+ *
1566
+ * TODO: add a `localStorage` variable to explicitly enable/disable colors
1567
+ */
1568
+
1569
+ // eslint-disable-next-line complexity
1570
+ function useColors() {
1571
+ // NB: In an Electron preload script, document will be defined but not fully
1572
+ // initialized. Since we know we're in Chrome, we'll just detect this case
1573
+ // explicitly
1574
+ if (typeof window !== 'undefined' && window.process && (window.process.type === 'renderer' || window.process.__nwjs)) {
1575
+ return true;
1576
+ }
1577
+
1578
+ // Internet Explorer and Edge do not support colors.
1579
+ if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
1580
+ return false;
1581
+ }
1582
+
1583
+ // Is webkit? http://stackoverflow.com/a/16459606/376773
1584
+ // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
1585
+ return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) ||
1586
+ // Is firebug? http://stackoverflow.com/a/398120/376773
1587
+ (typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) ||
1588
+ // Is firefox >= v31?
1589
+ // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
1590
+ (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) ||
1591
+ // Double check webkit in userAgent just in case we are in a worker
1592
+ (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/));
1593
+ }
1594
+
1595
+ /**
1596
+ * Colorize log arguments if enabled.
1597
+ *
1598
+ * @api public
1599
+ */
1600
+
1601
+ function formatArgs(args) {
1602
+ args[0] = (this.useColors ? '%c' : '') +
1603
+ this.namespace +
1604
+ (this.useColors ? ' %c' : ' ') +
1605
+ args[0] +
1606
+ (this.useColors ? '%c ' : ' ') +
1607
+ '+' + module.exports.humanize(this.diff);
1608
+
1609
+ if (!this.useColors) {
1610
+ return;
1611
+ }
1612
+
1613
+ const c = 'color: ' + this.color;
1614
+ args.splice(1, 0, c, 'color: inherit');
1615
+
1616
+ // The final "%c" is somewhat tricky, because there could be other
1617
+ // arguments passed either before or after the %c, so we need to
1618
+ // figure out the correct index to insert the CSS into
1619
+ let index = 0;
1620
+ let lastC = 0;
1621
+ args[0].replace(/%[a-zA-Z%]/g, match => {
1622
+ if (match === '%%') {
1623
+ return;
1624
+ }
1625
+ index++;
1626
+ if (match === '%c') {
1627
+ // We only are interested in the *last* %c
1628
+ // (the user may have provided their own)
1629
+ lastC = index;
1630
+ }
1631
+ });
1632
+
1633
+ args.splice(lastC, 0, c);
1634
+ }
1635
+
1636
+ /**
1637
+ * Invokes `console.debug()` when available.
1638
+ * No-op when `console.debug` is not a "function".
1639
+ * If `console.debug` is not available, falls back
1640
+ * to `console.log`.
1641
+ *
1642
+ * @api public
1643
+ */
1644
+ exports.log = console.debug || console.log || (() => {});
1645
+
1646
+ /**
1647
+ * Save `namespaces`.
1648
+ *
1649
+ * @param {String} namespaces
1650
+ * @api private
1651
+ */
1652
+ function save(namespaces) {
1653
+ try {
1654
+ if (namespaces) {
1655
+ exports.storage.setItem('debug', namespaces);
1656
+ } else {
1657
+ exports.storage.removeItem('debug');
1658
+ }
1659
+ } catch (error) {
1660
+ // Swallow
1661
+ // XXX (@Qix-) should we be logging these?
1662
+ }
1663
+ }
1664
+
1665
+ /**
1666
+ * Load `namespaces`.
1667
+ *
1668
+ * @return {String} returns the previously persisted debug modes
1669
+ * @api private
1670
+ */
1671
+ function load() {
1672
+ let r;
1673
+ try {
1674
+ r = exports.storage.getItem('debug');
1675
+ } catch (error) {
1676
+ // Swallow
1677
+ // XXX (@Qix-) should we be logging these?
1678
+ }
1679
+
1680
+ // If debug isn't set in LS, and we're in Electron, try to load $DEBUG
1681
+ if (!r && typeof process !== 'undefined' && 'env' in process) {
1682
+ r = process.env.DEBUG;
1683
+ }
1684
+
1685
+ return r;
1686
+ }
1687
+
1688
+ /**
1689
+ * Localstorage attempts to return the localstorage.
1690
+ *
1691
+ * This is necessary because safari throws
1692
+ * when a user disables cookies/localstorage
1693
+ * and you attempt to access it.
1694
+ *
1695
+ * @return {LocalStorage}
1696
+ * @api private
1697
+ */
1698
+
1699
+ function localstorage() {
1700
+ try {
1701
+ // TVMLKit (Apple TV JS Runtime) does not have a window object, just localStorage in the global context
1702
+ // The Browser also has localStorage in the global context.
1703
+ return localStorage;
1704
+ } catch (error) {
1705
+ // Swallow
1706
+ // XXX (@Qix-) should we be logging these?
1707
+ }
1708
+ }
1709
+
1710
+ module.exports = common(exports);
1711
+
1712
+ const {formatters} = module.exports;
1713
+
1714
+ /**
1715
+ * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
1716
+ */
1717
+
1718
+ formatters.j = function (v) {
1719
+ try {
1720
+ return JSON.stringify(v);
1721
+ } catch (error) {
1722
+ return '[UnexpectedJSONParseError]: ' + error.message;
1723
+ }
1724
+ };
1725
+ });
1726
+
1727
+ var hasFlag = (flag, argv) => {
1728
+ argv = argv || process.argv;
1729
+ const prefix = flag.startsWith('-') ? '' : (flag.length === 1 ? '-' : '--');
1730
+ const pos = argv.indexOf(prefix + flag);
1731
+ const terminatorPos = argv.indexOf('--');
1732
+ return pos !== -1 && (terminatorPos === -1 ? true : pos < terminatorPos);
1733
+ };
1734
+
1735
+ const env = process.env;
1736
+
1737
+ let forceColor;
1738
+ if (hasFlag('no-color') ||
1739
+ hasFlag('no-colors') ||
1740
+ hasFlag('color=false')) {
1741
+ forceColor = false;
1742
+ } else if (hasFlag('color') ||
1743
+ hasFlag('colors') ||
1744
+ hasFlag('color=true') ||
1745
+ hasFlag('color=always')) {
1746
+ forceColor = true;
1747
+ }
1748
+ if ('FORCE_COLOR' in env) {
1749
+ forceColor = env.FORCE_COLOR.length === 0 || parseInt(env.FORCE_COLOR, 10) !== 0;
1750
+ }
1751
+
1752
+ function translateLevel(level) {
1753
+ if (level === 0) {
1754
+ return false;
1755
+ }
1756
+
1757
+ return {
1758
+ level,
1759
+ hasBasic: true,
1760
+ has256: level >= 2,
1761
+ has16m: level >= 3
1762
+ };
1763
+ }
1764
+
1765
+ function supportsColor(stream) {
1766
+ if (forceColor === false) {
1767
+ return 0;
1768
+ }
1769
+
1770
+ if (hasFlag('color=16m') ||
1771
+ hasFlag('color=full') ||
1772
+ hasFlag('color=truecolor')) {
1773
+ return 3;
1774
+ }
1775
+
1776
+ if (hasFlag('color=256')) {
1777
+ return 2;
1778
+ }
1779
+
1780
+ if (stream && !stream.isTTY && forceColor !== true) {
1781
+ return 0;
1782
+ }
1783
+
1784
+ const min = forceColor ? 1 : 0;
1785
+
1786
+ if (process.platform === 'win32') {
1787
+ // Node.js 7.5.0 is the first version of Node.js to include a patch to
1788
+ // libuv that enables 256 color output on Windows. Anything earlier and it
1789
+ // won't work. However, here we target Node.js 8 at minimum as it is an LTS
1790
+ // release, and Node.js 7 is not. Windows 10 build 10586 is the first Windows
1791
+ // release that supports 256 colors. Windows 10 build 14931 is the first release
1792
+ // that supports 16m/TrueColor.
1793
+ const osRelease = os.release().split('.');
1794
+ if (
1795
+ Number(process.versions.node.split('.')[0]) >= 8 &&
1796
+ Number(osRelease[0]) >= 10 &&
1797
+ Number(osRelease[2]) >= 10586
1798
+ ) {
1799
+ return Number(osRelease[2]) >= 14931 ? 3 : 2;
1800
+ }
1801
+
1802
+ return 1;
1803
+ }
1804
+
1805
+ if ('CI' in env) {
1806
+ if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI'].some(sign => sign in env) || env.CI_NAME === 'codeship') {
1807
+ return 1;
1808
+ }
1809
+
1810
+ return min;
1811
+ }
1812
+
1813
+ if ('TEAMCITY_VERSION' in env) {
1814
+ return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
1815
+ }
1816
+
1817
+ if (env.COLORTERM === 'truecolor') {
1818
+ return 3;
1819
+ }
1820
+
1821
+ if ('TERM_PROGRAM' in env) {
1822
+ const version = parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
1823
+
1824
+ switch (env.TERM_PROGRAM) {
1825
+ case 'iTerm.app':
1826
+ return version >= 3 ? 3 : 2;
1827
+ case 'Apple_Terminal':
1828
+ return 2;
1829
+ // No default
1830
+ }
1831
+ }
1832
+
1833
+ if (/-256(color)?$/i.test(env.TERM)) {
1834
+ return 2;
1835
+ }
1836
+
1837
+ if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
1838
+ return 1;
1839
+ }
1840
+
1841
+ if ('COLORTERM' in env) {
1842
+ return 1;
1843
+ }
1844
+
1845
+ if (env.TERM === 'dumb') {
1846
+ return min;
1847
+ }
1848
+
1849
+ return min;
1850
+ }
1851
+
1852
+ function getSupportLevel(stream) {
1853
+ const level = supportsColor(stream);
1854
+ return translateLevel(level);
1855
+ }
1856
+
1857
+ var supportsColor_1 = {
1858
+ supportsColor: getSupportLevel,
1859
+ stdout: getSupportLevel(process.stdout),
1860
+ stderr: getSupportLevel(process.stderr)
1861
+ };
1862
+
1863
+ var node = createCommonjsModule(function (module, exports) {
1864
+ /**
1865
+ * Module dependencies.
1866
+ */
1867
+
1868
+
1869
+
1870
+
1871
+ /**
1872
+ * This is the Node.js implementation of `debug()`.
1873
+ */
1874
+
1875
+ exports.init = init;
1876
+ exports.log = log;
1877
+ exports.formatArgs = formatArgs;
1878
+ exports.save = save;
1879
+ exports.load = load;
1880
+ exports.useColors = useColors;
1881
+ exports.destroy = util.deprecate(
1882
+ () => {},
1883
+ 'Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.'
1884
+ );
1885
+
1886
+ /**
1887
+ * Colors.
1888
+ */
1889
+
1890
+ exports.colors = [6, 2, 3, 4, 5, 1];
1891
+
1892
+ try {
1893
+ // Optional dependency (as in, doesn't need to be installed, NOT like optionalDependencies in package.json)
1894
+ // eslint-disable-next-line import/no-extraneous-dependencies
1895
+ const supportsColor = supportsColor_1;
1896
+
1897
+ if (supportsColor && (supportsColor.stderr || supportsColor).level >= 2) {
1898
+ exports.colors = [
1899
+ 20,
1900
+ 21,
1901
+ 26,
1902
+ 27,
1903
+ 32,
1904
+ 33,
1905
+ 38,
1906
+ 39,
1907
+ 40,
1908
+ 41,
1909
+ 42,
1910
+ 43,
1911
+ 44,
1912
+ 45,
1913
+ 56,
1914
+ 57,
1915
+ 62,
1916
+ 63,
1917
+ 68,
1918
+ 69,
1919
+ 74,
1920
+ 75,
1921
+ 76,
1922
+ 77,
1923
+ 78,
1924
+ 79,
1925
+ 80,
1926
+ 81,
1927
+ 92,
1928
+ 93,
1929
+ 98,
1930
+ 99,
1931
+ 112,
1932
+ 113,
1933
+ 128,
1934
+ 129,
1935
+ 134,
1936
+ 135,
1937
+ 148,
1938
+ 149,
1939
+ 160,
1940
+ 161,
1941
+ 162,
1942
+ 163,
1943
+ 164,
1944
+ 165,
1945
+ 166,
1946
+ 167,
1947
+ 168,
1948
+ 169,
1949
+ 170,
1950
+ 171,
1951
+ 172,
1952
+ 173,
1953
+ 178,
1954
+ 179,
1955
+ 184,
1956
+ 185,
1957
+ 196,
1958
+ 197,
1959
+ 198,
1960
+ 199,
1961
+ 200,
1962
+ 201,
1963
+ 202,
1964
+ 203,
1965
+ 204,
1966
+ 205,
1967
+ 206,
1968
+ 207,
1969
+ 208,
1970
+ 209,
1971
+ 214,
1972
+ 215,
1973
+ 220,
1974
+ 221
1975
+ ];
1976
+ }
1977
+ } catch (error) {
1978
+ // Swallow - we only care if `supports-color` is available; it doesn't have to be.
1979
+ }
1980
+
1981
+ /**
1982
+ * Build up the default `inspectOpts` object from the environment variables.
1983
+ *
1984
+ * $ DEBUG_COLORS=no DEBUG_DEPTH=10 DEBUG_SHOW_HIDDEN=enabled node script.js
1985
+ */
1986
+
1987
+ exports.inspectOpts = Object.keys(process.env).filter(key => {
1988
+ return /^debug_/i.test(key);
1989
+ }).reduce((obj, key) => {
1990
+ // Camel-case
1991
+ const prop = key
1992
+ .substring(6)
1993
+ .toLowerCase()
1994
+ .replace(/_([a-z])/g, (_, k) => {
1995
+ return k.toUpperCase();
1996
+ });
1997
+
1998
+ // Coerce string value into JS value
1999
+ let val = process.env[key];
2000
+ if (/^(yes|on|true|enabled)$/i.test(val)) {
2001
+ val = true;
2002
+ } else if (/^(no|off|false|disabled)$/i.test(val)) {
2003
+ val = false;
2004
+ } else if (val === 'null') {
2005
+ val = null;
2006
+ } else {
2007
+ val = Number(val);
2008
+ }
2009
+
2010
+ obj[prop] = val;
2011
+ return obj;
2012
+ }, {});
2013
+
2014
+ /**
2015
+ * Is stdout a TTY? Colored output is enabled when `true`.
2016
+ */
2017
+
2018
+ function useColors() {
2019
+ return 'colors' in exports.inspectOpts ?
2020
+ Boolean(exports.inspectOpts.colors) :
2021
+ tty.isatty(process.stderr.fd);
2022
+ }
2023
+
2024
+ /**
2025
+ * Adds ANSI color escape codes if enabled.
2026
+ *
2027
+ * @api public
2028
+ */
2029
+
2030
+ function formatArgs(args) {
2031
+ const {namespace: name, useColors} = this;
2032
+
2033
+ if (useColors) {
2034
+ const c = this.color;
2035
+ const colorCode = '\u001B[3' + (c < 8 ? c : '8;5;' + c);
2036
+ const prefix = ` ${colorCode};1m${name} \u001B[0m`;
2037
+
2038
+ args[0] = prefix + args[0].split('\n').join('\n' + prefix);
2039
+ args.push(colorCode + 'm+' + module.exports.humanize(this.diff) + '\u001B[0m');
2040
+ } else {
2041
+ args[0] = getDate() + name + ' ' + args[0];
2042
+ }
2043
+ }
2044
+
2045
+ function getDate() {
2046
+ if (exports.inspectOpts.hideDate) {
2047
+ return '';
2048
+ }
2049
+ return new Date().toISOString() + ' ';
2050
+ }
2051
+
2052
+ /**
2053
+ * Invokes `util.format()` with the specified arguments and writes to stderr.
2054
+ */
2055
+
2056
+ function log(...args) {
2057
+ return process.stderr.write(util.format(...args) + '\n');
2058
+ }
2059
+
2060
+ /**
2061
+ * Save `namespaces`.
2062
+ *
2063
+ * @param {String} namespaces
2064
+ * @api private
2065
+ */
2066
+ function save(namespaces) {
2067
+ if (namespaces) {
2068
+ process.env.DEBUG = namespaces;
2069
+ } else {
2070
+ // If you set a process.env field to null or undefined, it gets cast to the
2071
+ // string 'null' or 'undefined'. Just delete instead.
2072
+ delete process.env.DEBUG;
2073
+ }
2074
+ }
2075
+
2076
+ /**
2077
+ * Load `namespaces`.
2078
+ *
2079
+ * @return {String} returns the previously persisted debug modes
2080
+ * @api private
2081
+ */
2082
+
2083
+ function load() {
2084
+ return process.env.DEBUG;
2085
+ }
2086
+
2087
+ /**
2088
+ * Init logic for `debug` instances.
2089
+ *
2090
+ * Create a new `inspectOpts` object in case `useColors` is set
2091
+ * differently for a particular `debug` instance.
2092
+ */
2093
+
2094
+ function init(debug) {
2095
+ debug.inspectOpts = {};
2096
+
2097
+ const keys = Object.keys(exports.inspectOpts);
2098
+ for (let i = 0; i < keys.length; i++) {
2099
+ debug.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]];
2100
+ }
2101
+ }
2102
+
2103
+ module.exports = common(exports);
2104
+
2105
+ const {formatters} = module.exports;
2106
+
2107
+ /**
2108
+ * Map %o to `util.inspect()`, all on a single line.
2109
+ */
2110
+
2111
+ formatters.o = function (v) {
2112
+ this.inspectOpts.colors = this.useColors;
2113
+ return util.inspect(v, this.inspectOpts)
2114
+ .split('\n')
2115
+ .map(str => str.trim())
2116
+ .join(' ');
2117
+ };
2118
+
2119
+ /**
2120
+ * Map %O to `util.inspect()`, allowing multiple lines if needed.
2121
+ */
2122
+
2123
+ formatters.O = function (v) {
2124
+ this.inspectOpts.colors = this.useColors;
2125
+ return util.inspect(v, this.inspectOpts);
2126
+ };
2127
+ });
2128
+
2129
+ var src = createCommonjsModule(function (module) {
2130
+ /**
2131
+ * Detect Electron renderer / nwjs process, which is node, but we should
2132
+ * treat as a browser.
2133
+ */
2134
+
2135
+ if (typeof process === 'undefined' || process.type === 'renderer' || process.browser === true || process.__nwjs) {
2136
+ module.exports = browser;
2137
+ } else {
2138
+ module.exports = node;
2139
+ }
2140
+ });
2141
+
2142
+ var debug;
2143
+
2144
+ var debug_1 = function () {
2145
+ if (!debug) {
2146
+ try {
2147
+ /* eslint global-require: off */
2148
+ debug = src("follow-redirects");
2149
+ }
2150
+ catch (error) { /* */ }
2151
+ if (typeof debug !== "function") {
2152
+ debug = function () { /* */ };
2153
+ }
2154
+ }
2155
+ debug.apply(null, arguments);
2156
+ };
2157
+
2158
+ var URL = url.URL;
2159
+
2160
+
2161
+ var Writable = stream.Writable;
2162
+
2163
+
2164
+
2165
+ // Create handlers that pass events from native requests
2166
+ var events = ["abort", "aborted", "connect", "error", "socket", "timeout"];
2167
+ var eventHandlers = Object.create(null);
2168
+ events.forEach(function (event) {
2169
+ eventHandlers[event] = function (arg1, arg2, arg3) {
2170
+ this._redirectable.emit(event, arg1, arg2, arg3);
2171
+ };
2172
+ });
2173
+
2174
+ // Error types with codes
2175
+ var RedirectionError = createErrorType(
2176
+ "ERR_FR_REDIRECTION_FAILURE",
2177
+ "Redirected request failed"
2178
+ );
2179
+ var TooManyRedirectsError = createErrorType(
2180
+ "ERR_FR_TOO_MANY_REDIRECTS",
2181
+ "Maximum number of redirects exceeded"
2182
+ );
2183
+ var MaxBodyLengthExceededError = createErrorType(
2184
+ "ERR_FR_MAX_BODY_LENGTH_EXCEEDED",
2185
+ "Request body larger than maxBodyLength limit"
2186
+ );
2187
+ var WriteAfterEndError = createErrorType(
2188
+ "ERR_STREAM_WRITE_AFTER_END",
2189
+ "write after end"
2190
+ );
2191
+
2192
+ // An HTTP(S) request that can be redirected
2193
+ function RedirectableRequest(options, responseCallback) {
2194
+ // Initialize the request
2195
+ Writable.call(this);
2196
+ this._sanitizeOptions(options);
2197
+ this._options = options;
2198
+ this._ended = false;
2199
+ this._ending = false;
2200
+ this._redirectCount = 0;
2201
+ this._redirects = [];
2202
+ this._requestBodyLength = 0;
2203
+ this._requestBodyBuffers = [];
2204
+
2205
+ // Attach a callback if passed
2206
+ if (responseCallback) {
2207
+ this.on("response", responseCallback);
2208
+ }
2209
+
2210
+ // React to responses of native requests
2211
+ var self = this;
2212
+ this._onNativeResponse = function (response) {
2213
+ self._processResponse(response);
2214
+ };
2215
+
2216
+ // Perform the first request
2217
+ this._performRequest();
2218
+ }
2219
+ RedirectableRequest.prototype = Object.create(Writable.prototype);
2220
+
2221
+ RedirectableRequest.prototype.abort = function () {
2222
+ abortRequest(this._currentRequest);
2223
+ this.emit("abort");
2224
+ };
2225
+
2226
+ // Writes buffered data to the current native request
2227
+ RedirectableRequest.prototype.write = function (data, encoding, callback) {
2228
+ // Writing is not allowed if end has been called
2229
+ if (this._ending) {
2230
+ throw new WriteAfterEndError();
2231
+ }
2232
+
2233
+ // Validate input and shift parameters if necessary
2234
+ if (!(typeof data === "string" || typeof data === "object" && ("length" in data))) {
2235
+ throw new TypeError("data should be a string, Buffer or Uint8Array");
2236
+ }
2237
+ if (typeof encoding === "function") {
2238
+ callback = encoding;
2239
+ encoding = null;
2240
+ }
2241
+
2242
+ // Ignore empty buffers, since writing them doesn't invoke the callback
2243
+ // https://github.com/nodejs/node/issues/22066
2244
+ if (data.length === 0) {
2245
+ if (callback) {
2246
+ callback();
2247
+ }
2248
+ return;
2249
+ }
2250
+ // Only write when we don't exceed the maximum body length
2251
+ if (this._requestBodyLength + data.length <= this._options.maxBodyLength) {
2252
+ this._requestBodyLength += data.length;
2253
+ this._requestBodyBuffers.push({ data: data, encoding: encoding });
2254
+ this._currentRequest.write(data, encoding, callback);
2255
+ }
2256
+ // Error when we exceed the maximum body length
2257
+ else {
2258
+ this.emit("error", new MaxBodyLengthExceededError());
2259
+ this.abort();
2260
+ }
2261
+ };
2262
+
2263
+ // Ends the current native request
2264
+ RedirectableRequest.prototype.end = function (data, encoding, callback) {
2265
+ // Shift parameters if necessary
2266
+ if (typeof data === "function") {
2267
+ callback = data;
2268
+ data = encoding = null;
2269
+ }
2270
+ else if (typeof encoding === "function") {
2271
+ callback = encoding;
2272
+ encoding = null;
2273
+ }
2274
+
2275
+ // Write data if needed and end
2276
+ if (!data) {
2277
+ this._ended = this._ending = true;
2278
+ this._currentRequest.end(null, null, callback);
2279
+ }
2280
+ else {
2281
+ var self = this;
2282
+ var currentRequest = this._currentRequest;
2283
+ this.write(data, encoding, function () {
2284
+ self._ended = true;
2285
+ currentRequest.end(null, null, callback);
2286
+ });
2287
+ this._ending = true;
2288
+ }
2289
+ };
2290
+
2291
+ // Sets a header value on the current native request
2292
+ RedirectableRequest.prototype.setHeader = function (name, value) {
2293
+ this._options.headers[name] = value;
2294
+ this._currentRequest.setHeader(name, value);
2295
+ };
2296
+
2297
+ // Clears a header value on the current native request
2298
+ RedirectableRequest.prototype.removeHeader = function (name) {
2299
+ delete this._options.headers[name];
2300
+ this._currentRequest.removeHeader(name);
2301
+ };
2302
+
2303
+ // Global timeout for all underlying requests
2304
+ RedirectableRequest.prototype.setTimeout = function (msecs, callback) {
2305
+ var self = this;
2306
+
2307
+ // Destroys the socket on timeout
2308
+ function destroyOnTimeout(socket) {
2309
+ socket.setTimeout(msecs);
2310
+ socket.removeListener("timeout", socket.destroy);
2311
+ socket.addListener("timeout", socket.destroy);
2312
+ }
2313
+
2314
+ // Sets up a timer to trigger a timeout event
2315
+ function startTimer(socket) {
2316
+ if (self._timeout) {
2317
+ clearTimeout(self._timeout);
2318
+ }
2319
+ self._timeout = setTimeout(function () {
2320
+ self.emit("timeout");
2321
+ clearTimer();
2322
+ }, msecs);
2323
+ destroyOnTimeout(socket);
2324
+ }
2325
+
2326
+ // Stops a timeout from triggering
2327
+ function clearTimer() {
2328
+ // Clear the timeout
2329
+ if (self._timeout) {
2330
+ clearTimeout(self._timeout);
2331
+ self._timeout = null;
2332
+ }
2333
+
2334
+ // Clean up all attached listeners
2335
+ self.removeListener("abort", clearTimer);
2336
+ self.removeListener("error", clearTimer);
2337
+ self.removeListener("response", clearTimer);
2338
+ if (callback) {
2339
+ self.removeListener("timeout", callback);
2340
+ }
2341
+ if (!self.socket) {
2342
+ self._currentRequest.removeListener("socket", startTimer);
2343
+ }
2344
+ }
2345
+
2346
+ // Attach callback if passed
2347
+ if (callback) {
2348
+ this.on("timeout", callback);
2349
+ }
2350
+
2351
+ // Start the timer if or when the socket is opened
2352
+ if (this.socket) {
2353
+ startTimer(this.socket);
2354
+ }
2355
+ else {
2356
+ this._currentRequest.once("socket", startTimer);
2357
+ }
2358
+
2359
+ // Clean up on events
2360
+ this.on("socket", destroyOnTimeout);
2361
+ this.on("abort", clearTimer);
2362
+ this.on("error", clearTimer);
2363
+ this.on("response", clearTimer);
2364
+
2365
+ return this;
2366
+ };
2367
+
2368
+ // Proxy all other public ClientRequest methods
2369
+ [
2370
+ "flushHeaders", "getHeader",
2371
+ "setNoDelay", "setSocketKeepAlive",
2372
+ ].forEach(function (method) {
2373
+ RedirectableRequest.prototype[method] = function (a, b) {
2374
+ return this._currentRequest[method](a, b);
2375
+ };
2376
+ });
2377
+
2378
+ // Proxy all public ClientRequest properties
2379
+ ["aborted", "connection", "socket"].forEach(function (property) {
2380
+ Object.defineProperty(RedirectableRequest.prototype, property, {
2381
+ get: function () { return this._currentRequest[property]; },
2382
+ });
2383
+ });
2384
+
2385
+ RedirectableRequest.prototype._sanitizeOptions = function (options) {
2386
+ // Ensure headers are always present
2387
+ if (!options.headers) {
2388
+ options.headers = {};
2389
+ }
2390
+
2391
+ // Since http.request treats host as an alias of hostname,
2392
+ // but the url module interprets host as hostname plus port,
2393
+ // eliminate the host property to avoid confusion.
2394
+ if (options.host) {
2395
+ // Use hostname if set, because it has precedence
2396
+ if (!options.hostname) {
2397
+ options.hostname = options.host;
2398
+ }
2399
+ delete options.host;
2400
+ }
2401
+
2402
+ // Complete the URL object when necessary
2403
+ if (!options.pathname && options.path) {
2404
+ var searchPos = options.path.indexOf("?");
2405
+ if (searchPos < 0) {
2406
+ options.pathname = options.path;
2407
+ }
2408
+ else {
2409
+ options.pathname = options.path.substring(0, searchPos);
2410
+ options.search = options.path.substring(searchPos);
2411
+ }
2412
+ }
2413
+ };
2414
+
2415
+
2416
+ // Executes the next native request (initial or redirect)
2417
+ RedirectableRequest.prototype._performRequest = function () {
2418
+ // Load the native protocol
2419
+ var protocol = this._options.protocol;
2420
+ var nativeProtocol = this._options.nativeProtocols[protocol];
2421
+ if (!nativeProtocol) {
2422
+ this.emit("error", new TypeError("Unsupported protocol " + protocol));
2423
+ return;
2424
+ }
2425
+
2426
+ // If specified, use the agent corresponding to the protocol
2427
+ // (HTTP and HTTPS use different types of agents)
2428
+ if (this._options.agents) {
2429
+ var scheme = protocol.substr(0, protocol.length - 1);
2430
+ this._options.agent = this._options.agents[scheme];
2431
+ }
2432
+
2433
+ // Create the native request
2434
+ var request = this._currentRequest =
2435
+ nativeProtocol.request(this._options, this._onNativeResponse);
2436
+ this._currentUrl = url.format(this._options);
2437
+
2438
+ // Set up event handlers
2439
+ request._redirectable = this;
2440
+ for (var e = 0; e < events.length; e++) {
2441
+ request.on(events[e], eventHandlers[events[e]]);
2442
+ }
2443
+
2444
+ // End a redirected request
2445
+ // (The first request must be ended explicitly with RedirectableRequest#end)
2446
+ if (this._isRedirect) {
2447
+ // Write the request entity and end.
2448
+ var i = 0;
2449
+ var self = this;
2450
+ var buffers = this._requestBodyBuffers;
2451
+ (function writeNext(error) {
2452
+ // Only write if this request has not been redirected yet
2453
+ /* istanbul ignore else */
2454
+ if (request === self._currentRequest) {
2455
+ // Report any write errors
2456
+ /* istanbul ignore if */
2457
+ if (error) {
2458
+ self.emit("error", error);
2459
+ }
2460
+ // Write the next buffer if there are still left
2461
+ else if (i < buffers.length) {
2462
+ var buffer = buffers[i++];
2463
+ /* istanbul ignore else */
2464
+ if (!request.finished) {
2465
+ request.write(buffer.data, buffer.encoding, writeNext);
2466
+ }
2467
+ }
2468
+ // End the request if `end` has been called on us
2469
+ else if (self._ended) {
2470
+ request.end();
2471
+ }
2472
+ }
2473
+ }());
2474
+ }
2475
+ };
2476
+
2477
+ // Processes a response from the current native request
2478
+ RedirectableRequest.prototype._processResponse = function (response) {
2479
+ // Store the redirected response
2480
+ var statusCode = response.statusCode;
2481
+ if (this._options.trackRedirects) {
2482
+ this._redirects.push({
2483
+ url: this._currentUrl,
2484
+ headers: response.headers,
2485
+ statusCode: statusCode,
2486
+ });
2487
+ }
2488
+
2489
+ // RFC7231§6.4: The 3xx (Redirection) class of status code indicates
2490
+ // that further action needs to be taken by the user agent in order to
2491
+ // fulfill the request. If a Location header field is provided,
2492
+ // the user agent MAY automatically redirect its request to the URI
2493
+ // referenced by the Location field value,
2494
+ // even if the specific status code is not understood.
2495
+
2496
+ // If the response is not a redirect; return it as-is
2497
+ var location = response.headers.location;
2498
+ if (!location || this._options.followRedirects === false ||
2499
+ statusCode < 300 || statusCode >= 400) {
2500
+ response.responseUrl = this._currentUrl;
2501
+ response.redirects = this._redirects;
2502
+ this.emit("response", response);
2503
+
2504
+ // Clean up
2505
+ this._requestBodyBuffers = [];
2506
+ return;
2507
+ }
2508
+
2509
+ // The response is a redirect, so abort the current request
2510
+ abortRequest(this._currentRequest);
2511
+ // Discard the remainder of the response to avoid waiting for data
2512
+ response.destroy();
2513
+
2514
+ // RFC7231§6.4: A client SHOULD detect and intervene
2515
+ // in cyclical redirections (i.e., "infinite" redirection loops).
2516
+ if (++this._redirectCount > this._options.maxRedirects) {
2517
+ this.emit("error", new TooManyRedirectsError());
2518
+ return;
2519
+ }
2520
+
2521
+ // RFC7231§6.4: Automatic redirection needs to done with
2522
+ // care for methods not known to be safe, […]
2523
+ // RFC7231§6.4.2–3: For historical reasons, a user agent MAY change
2524
+ // the request method from POST to GET for the subsequent request.
2525
+ if ((statusCode === 301 || statusCode === 302) && this._options.method === "POST" ||
2526
+ // RFC7231§6.4.4: The 303 (See Other) status code indicates that
2527
+ // the server is redirecting the user agent to a different resource […]
2528
+ // A user agent can perform a retrieval request targeting that URI
2529
+ // (a GET or HEAD request if using HTTP) […]
2530
+ (statusCode === 303) && !/^(?:GET|HEAD)$/.test(this._options.method)) {
2531
+ this._options.method = "GET";
2532
+ // Drop a possible entity and headers related to it
2533
+ this._requestBodyBuffers = [];
2534
+ removeMatchingHeaders(/^content-/i, this._options.headers);
2535
+ }
2536
+
2537
+ // Drop the Host header, as the redirect might lead to a different host
2538
+ var currentHostHeader = removeMatchingHeaders(/^host$/i, this._options.headers);
2539
+
2540
+ // If the redirect is relative, carry over the host of the last request
2541
+ var currentUrlParts = url.parse(this._currentUrl);
2542
+ var currentHost = currentHostHeader || currentUrlParts.host;
2543
+ var currentUrl = /^\w+:/.test(location) ? this._currentUrl :
2544
+ url.format(Object.assign(currentUrlParts, { host: currentHost }));
2545
+
2546
+ // Determine the URL of the redirection
2547
+ var redirectUrl;
2548
+ try {
2549
+ redirectUrl = url.resolve(currentUrl, location);
2550
+ }
2551
+ catch (cause) {
2552
+ this.emit("error", new RedirectionError(cause));
2553
+ return;
2554
+ }
2555
+
2556
+ // Create the redirected request
2557
+ debug_1("redirecting to", redirectUrl);
2558
+ this._isRedirect = true;
2559
+ var redirectUrlParts = url.parse(redirectUrl);
2560
+ Object.assign(this._options, redirectUrlParts);
2561
+
2562
+ // Drop confidential headers when redirecting to a less secure protocol
2563
+ // or to a different domain that is not a superdomain
2564
+ if (redirectUrlParts.protocol !== currentUrlParts.protocol &&
2565
+ redirectUrlParts.protocol !== "https:" ||
2566
+ redirectUrlParts.host !== currentHost &&
2567
+ !isSubdomain(redirectUrlParts.host, currentHost)) {
2568
+ removeMatchingHeaders(/^(?:authorization|cookie)$/i, this._options.headers);
2569
+ }
2570
+
2571
+ // Evaluate the beforeRedirect callback
2572
+ if (typeof this._options.beforeRedirect === "function") {
2573
+ var responseDetails = { headers: response.headers };
2574
+ try {
2575
+ this._options.beforeRedirect.call(null, this._options, responseDetails);
2576
+ }
2577
+ catch (err) {
2578
+ this.emit("error", err);
2579
+ return;
2580
+ }
2581
+ this._sanitizeOptions(this._options);
2582
+ }
2583
+
2584
+ // Perform the redirected request
2585
+ try {
2586
+ this._performRequest();
2587
+ }
2588
+ catch (cause) {
2589
+ this.emit("error", new RedirectionError(cause));
2590
+ }
2591
+ };
2592
+
2593
+ // Wraps the key/value object of protocols with redirect functionality
2594
+ function wrap(protocols) {
2595
+ // Default settings
2596
+ var exports = {
2597
+ maxRedirects: 21,
2598
+ maxBodyLength: 10 * 1024 * 1024,
2599
+ };
2600
+
2601
+ // Wrap each protocol
2602
+ var nativeProtocols = {};
2603
+ Object.keys(protocols).forEach(function (scheme) {
2604
+ var protocol = scheme + ":";
2605
+ var nativeProtocol = nativeProtocols[protocol] = protocols[scheme];
2606
+ var wrappedProtocol = exports[scheme] = Object.create(nativeProtocol);
2607
+
2608
+ // Executes a request, following redirects
2609
+ function request(input, options, callback) {
2610
+ // Parse parameters
2611
+ if (typeof input === "string") {
2612
+ var urlStr = input;
2613
+ try {
2614
+ input = urlToOptions(new URL(urlStr));
2615
+ }
2616
+ catch (err) {
2617
+ /* istanbul ignore next */
2618
+ input = url.parse(urlStr);
2619
+ }
2620
+ }
2621
+ else if (URL && (input instanceof URL)) {
2622
+ input = urlToOptions(input);
2623
+ }
2624
+ else {
2625
+ callback = options;
2626
+ options = input;
2627
+ input = { protocol: protocol };
2628
+ }
2629
+ if (typeof options === "function") {
2630
+ callback = options;
2631
+ options = null;
2632
+ }
2633
+
2634
+ // Set defaults
2635
+ options = Object.assign({
2636
+ maxRedirects: exports.maxRedirects,
2637
+ maxBodyLength: exports.maxBodyLength,
2638
+ }, input, options);
2639
+ options.nativeProtocols = nativeProtocols;
2640
+
2641
+ assert.equal(options.protocol, protocol, "protocol mismatch");
2642
+ debug_1("options", options);
2643
+ return new RedirectableRequest(options, callback);
2644
+ }
2645
+
2646
+ // Executes a GET request, following redirects
2647
+ function get(input, options, callback) {
2648
+ var wrappedRequest = wrappedProtocol.request(input, options, callback);
2649
+ wrappedRequest.end();
2650
+ return wrappedRequest;
2651
+ }
2652
+
2653
+ // Expose the properties on the wrapped protocol
2654
+ Object.defineProperties(wrappedProtocol, {
2655
+ request: { value: request, configurable: true, enumerable: true, writable: true },
2656
+ get: { value: get, configurable: true, enumerable: true, writable: true },
2657
+ });
2658
+ });
2659
+ return exports;
2660
+ }
2661
+
2662
+ /* istanbul ignore next */
2663
+ function noop() { /* empty */ }
2664
+
2665
+ // from https://github.com/nodejs/node/blob/master/lib/internal/url.js
2666
+ function urlToOptions(urlObject) {
2667
+ var options = {
2668
+ protocol: urlObject.protocol,
2669
+ hostname: urlObject.hostname.startsWith("[") ?
2670
+ /* istanbul ignore next */
2671
+ urlObject.hostname.slice(1, -1) :
2672
+ urlObject.hostname,
2673
+ hash: urlObject.hash,
2674
+ search: urlObject.search,
2675
+ pathname: urlObject.pathname,
2676
+ path: urlObject.pathname + urlObject.search,
2677
+ href: urlObject.href,
2678
+ };
2679
+ if (urlObject.port !== "") {
2680
+ options.port = Number(urlObject.port);
2681
+ }
2682
+ return options;
2683
+ }
2684
+
2685
+ function removeMatchingHeaders(regex, headers) {
2686
+ var lastValue;
2687
+ for (var header in headers) {
2688
+ if (regex.test(header)) {
2689
+ lastValue = headers[header];
2690
+ delete headers[header];
2691
+ }
2692
+ }
2693
+ return (lastValue === null || typeof lastValue === "undefined") ?
2694
+ undefined : String(lastValue).trim();
2695
+ }
2696
+
2697
+ function createErrorType(code, defaultMessage) {
2698
+ function CustomError(cause) {
2699
+ Error.captureStackTrace(this, this.constructor);
2700
+ if (!cause) {
2701
+ this.message = defaultMessage;
2702
+ }
2703
+ else {
2704
+ this.message = defaultMessage + ": " + cause.message;
2705
+ this.cause = cause;
2706
+ }
2707
+ }
2708
+ CustomError.prototype = new Error();
2709
+ CustomError.prototype.constructor = CustomError;
2710
+ CustomError.prototype.name = "Error [" + code + "]";
2711
+ CustomError.prototype.code = code;
2712
+ return CustomError;
2713
+ }
2714
+
2715
+ function abortRequest(request) {
2716
+ for (var e = 0; e < events.length; e++) {
2717
+ request.removeListener(events[e], eventHandlers[events[e]]);
2718
+ }
2719
+ request.on("error", noop);
2720
+ request.abort();
2721
+ }
2722
+
2723
+ function isSubdomain(subdomain, domain) {
2724
+ const dot = subdomain.length - domain.length - 1;
2725
+ return dot > 0 && subdomain[dot] === "." && subdomain.endsWith(domain);
2726
+ }
2727
+
2728
+ // Exports
2729
+ var followRedirects = wrap({ http: http, https: https });
2730
+ var wrap_1 = wrap;
2731
+ followRedirects.wrap = wrap_1;
2732
+
2733
+ var data = {
2734
+ "version": "0.26.1"
2735
+ };
2736
+
2737
+ var httpFollow = followRedirects.http;
2738
+ var httpsFollow = followRedirects.https;
2739
+
2740
+
2741
+ var VERSION$1 = data.version;
2742
+
2743
+
2744
+
2745
+
2746
+
2747
+ var isHttps = /https:?/;
2748
+
2749
+ /**
2750
+ *
2751
+ * @param {http.ClientRequestArgs} options
2752
+ * @param {AxiosProxyConfig} proxy
2753
+ * @param {string} location
2754
+ */
2755
+ function setProxy(options, proxy, location) {
2756
+ options.hostname = proxy.host;
2757
+ options.host = proxy.host;
2758
+ options.port = proxy.port;
2759
+ options.path = location;
2760
+
2761
+ // Basic proxy authorization
2762
+ if (proxy.auth) {
2763
+ var base64 = Buffer.from(proxy.auth.username + ':' + proxy.auth.password, 'utf8').toString('base64');
2764
+ options.headers['Proxy-Authorization'] = 'Basic ' + base64;
2765
+ }
2766
+
2767
+ // If a proxy is used, any redirects must also pass through the proxy
2768
+ options.beforeRedirect = function beforeRedirect(redirection) {
2769
+ redirection.headers.host = redirection.host;
2770
+ setProxy(redirection, proxy, redirection.href);
2771
+ };
2772
+ }
2773
+
2774
+ /*eslint consistent-return:0*/
2775
+ var http_1 = function httpAdapter(config) {
2776
+ return new Promise(function dispatchHttpRequest(resolvePromise, rejectPromise) {
2777
+ var onCanceled;
2778
+ function done() {
2779
+ if (config.cancelToken) {
2780
+ config.cancelToken.unsubscribe(onCanceled);
2781
+ }
2782
+
2783
+ if (config.signal) {
2784
+ config.signal.removeEventListener('abort', onCanceled);
2785
+ }
2786
+ }
2787
+ var resolve = function resolve(value) {
2788
+ done();
2789
+ resolvePromise(value);
2790
+ };
2791
+ var rejected = false;
2792
+ var reject = function reject(value) {
2793
+ done();
2794
+ rejected = true;
2795
+ rejectPromise(value);
2796
+ };
2797
+ var data = config.data;
2798
+ var headers = config.headers;
2799
+ var headerNames = {};
2800
+
2801
+ Object.keys(headers).forEach(function storeLowerName(name) {
2802
+ headerNames[name.toLowerCase()] = name;
2803
+ });
2804
+
2805
+ // Set User-Agent (required by some servers)
2806
+ // See https://github.com/axios/axios/issues/69
2807
+ if ('user-agent' in headerNames) {
2808
+ // User-Agent is specified; handle case where no UA header is desired
2809
+ if (!headers[headerNames['user-agent']]) {
2810
+ delete headers[headerNames['user-agent']];
2811
+ }
2812
+ // Otherwise, use specified value
2813
+ } else {
2814
+ // Only set header if it hasn't been set in config
2815
+ headers['User-Agent'] = 'axios/' + VERSION$1;
2816
+ }
2817
+
2818
+ if (data && !utils.isStream(data)) {
2819
+ if (Buffer.isBuffer(data)) ; else if (utils.isArrayBuffer(data)) {
2820
+ data = Buffer.from(new Uint8Array(data));
2821
+ } else if (utils.isString(data)) {
2822
+ data = Buffer.from(data, 'utf-8');
2823
+ } else {
2824
+ return reject(createError(
2825
+ 'Data after transformation must be a string, an ArrayBuffer, a Buffer, or a Stream',
2826
+ config
2827
+ ));
2828
+ }
2829
+
2830
+ if (config.maxBodyLength > -1 && data.length > config.maxBodyLength) {
2831
+ return reject(createError('Request body larger than maxBodyLength limit', config));
2832
+ }
2833
+
2834
+ // Add Content-Length header if data exists
2835
+ if (!headerNames['content-length']) {
2836
+ headers['Content-Length'] = data.length;
2837
+ }
2838
+ }
2839
+
2840
+ // HTTP basic authentication
2841
+ var auth = undefined;
2842
+ if (config.auth) {
2843
+ var username = config.auth.username || '';
2844
+ var password = config.auth.password || '';
2845
+ auth = username + ':' + password;
2846
+ }
2847
+
2848
+ // Parse url
2849
+ var fullPath = buildFullPath(config.baseURL, config.url);
2850
+ var parsed = url.parse(fullPath);
2851
+ var protocol = parsed.protocol || 'http:';
2852
+
2853
+ if (!auth && parsed.auth) {
2854
+ var urlAuth = parsed.auth.split(':');
2855
+ var urlUsername = urlAuth[0] || '';
2856
+ var urlPassword = urlAuth[1] || '';
2857
+ auth = urlUsername + ':' + urlPassword;
2858
+ }
2859
+
2860
+ if (auth && headerNames.authorization) {
2861
+ delete headers[headerNames.authorization];
2862
+ }
2863
+
2864
+ var isHttpsRequest = isHttps.test(protocol);
2865
+ var agent = isHttpsRequest ? config.httpsAgent : config.httpAgent;
2866
+
2867
+ try {
2868
+ buildURL(parsed.path, config.params, config.paramsSerializer).replace(/^\?/, '');
2869
+ } catch (err) {
2870
+ var customErr = new Error(err.message);
2871
+ customErr.config = config;
2872
+ customErr.url = config.url;
2873
+ customErr.exists = true;
2874
+ reject(customErr);
2875
+ }
2876
+
2877
+ var options = {
2878
+ path: buildURL(parsed.path, config.params, config.paramsSerializer).replace(/^\?/, ''),
2879
+ method: config.method.toUpperCase(),
2880
+ headers: headers,
2881
+ agent: agent,
2882
+ agents: { http: config.httpAgent, https: config.httpsAgent },
2883
+ auth: auth
2884
+ };
2885
+
2886
+ if (config.socketPath) {
2887
+ options.socketPath = config.socketPath;
2888
+ } else {
2889
+ options.hostname = parsed.hostname;
2890
+ options.port = parsed.port;
2891
+ }
2892
+
2893
+ var proxy = config.proxy;
2894
+ if (!proxy && proxy !== false) {
2895
+ var proxyEnv = protocol.slice(0, -1) + '_proxy';
2896
+ var proxyUrl = process.env[proxyEnv] || process.env[proxyEnv.toUpperCase()];
2897
+ if (proxyUrl) {
2898
+ var parsedProxyUrl = url.parse(proxyUrl);
2899
+ var noProxyEnv = process.env.no_proxy || process.env.NO_PROXY;
2900
+ var shouldProxy = true;
2901
+
2902
+ if (noProxyEnv) {
2903
+ var noProxy = noProxyEnv.split(',').map(function trim(s) {
2904
+ return s.trim();
2905
+ });
2906
+
2907
+ shouldProxy = !noProxy.some(function proxyMatch(proxyElement) {
2908
+ if (!proxyElement) {
2909
+ return false;
2910
+ }
2911
+ if (proxyElement === '*') {
2912
+ return true;
2913
+ }
2914
+ if (proxyElement[0] === '.' &&
2915
+ parsed.hostname.substr(parsed.hostname.length - proxyElement.length) === proxyElement) {
2916
+ return true;
2917
+ }
2918
+
2919
+ return parsed.hostname === proxyElement;
2920
+ });
2921
+ }
2922
+
2923
+ if (shouldProxy) {
2924
+ proxy = {
2925
+ host: parsedProxyUrl.hostname,
2926
+ port: parsedProxyUrl.port,
2927
+ protocol: parsedProxyUrl.protocol
2928
+ };
2929
+
2930
+ if (parsedProxyUrl.auth) {
2931
+ var proxyUrlAuth = parsedProxyUrl.auth.split(':');
2932
+ proxy.auth = {
2933
+ username: proxyUrlAuth[0],
2934
+ password: proxyUrlAuth[1]
2935
+ };
2936
+ }
2937
+ }
2938
+ }
2939
+ }
2940
+
2941
+ if (proxy) {
2942
+ options.headers.host = parsed.hostname + (parsed.port ? ':' + parsed.port : '');
2943
+ setProxy(options, proxy, protocol + '//' + parsed.hostname + (parsed.port ? ':' + parsed.port : '') + options.path);
2944
+ }
2945
+
2946
+ var transport;
2947
+ var isHttpsProxy = isHttpsRequest && (proxy ? isHttps.test(proxy.protocol) : true);
2948
+ if (config.transport) {
2949
+ transport = config.transport;
2950
+ } else if (config.maxRedirects === 0) {
2951
+ transport = isHttpsProxy ? https : http;
2952
+ } else {
2953
+ if (config.maxRedirects) {
2954
+ options.maxRedirects = config.maxRedirects;
2955
+ }
2956
+ transport = isHttpsProxy ? httpsFollow : httpFollow;
2957
+ }
2958
+
2959
+ if (config.maxBodyLength > -1) {
2960
+ options.maxBodyLength = config.maxBodyLength;
2961
+ }
2962
+
2963
+ if (config.insecureHTTPParser) {
2964
+ options.insecureHTTPParser = config.insecureHTTPParser;
2965
+ }
2966
+
2967
+ // Create the request
2968
+ var req = transport.request(options, function handleResponse(res) {
2969
+ if (req.aborted) return;
2970
+
2971
+ // uncompress the response body transparently if required
2972
+ var stream = res;
2973
+
2974
+ // return the last request in case of redirects
2975
+ var lastRequest = res.req || req;
2976
+
2977
+
2978
+ // if no content, is HEAD request or decompress disabled we should not decompress
2979
+ if (res.statusCode !== 204 && lastRequest.method !== 'HEAD' && config.decompress !== false) {
2980
+ switch (res.headers['content-encoding']) {
2981
+ /*eslint default-case:0*/
2982
+ case 'gzip':
2983
+ case 'compress':
2984
+ case 'deflate':
2985
+ // add the unzipper to the body stream processing pipeline
2986
+ stream = stream.pipe(zlib.createUnzip());
2987
+
2988
+ // remove the content-encoding in order to not confuse downstream operations
2989
+ delete res.headers['content-encoding'];
2990
+ break;
2991
+ }
2992
+ }
2993
+
2994
+ var response = {
2995
+ status: res.statusCode,
2996
+ statusText: res.statusMessage,
2997
+ headers: res.headers,
2998
+ config: config,
2999
+ request: lastRequest
3000
+ };
3001
+
3002
+ if (config.responseType === 'stream') {
3003
+ response.data = stream;
3004
+ settle(resolve, reject, response);
3005
+ } else {
3006
+ var responseBuffer = [];
3007
+ var totalResponseBytes = 0;
3008
+ stream.on('data', function handleStreamData(chunk) {
3009
+ responseBuffer.push(chunk);
3010
+ totalResponseBytes += chunk.length;
3011
+
3012
+ // make sure the content length is not over the maxContentLength if specified
3013
+ if (config.maxContentLength > -1 && totalResponseBytes > config.maxContentLength) {
3014
+ // stream.destoy() emit aborted event before calling reject() on Node.js v16
3015
+ rejected = true;
3016
+ stream.destroy();
3017
+ reject(createError('maxContentLength size of ' + config.maxContentLength + ' exceeded',
3018
+ config, null, lastRequest));
3019
+ }
3020
+ });
3021
+
3022
+ stream.on('aborted', function handlerStreamAborted() {
3023
+ if (rejected) {
3024
+ return;
3025
+ }
3026
+ stream.destroy();
3027
+ reject(createError('error request aborted', config, 'ERR_REQUEST_ABORTED', lastRequest));
3028
+ });
3029
+
3030
+ stream.on('error', function handleStreamError(err) {
3031
+ if (req.aborted) return;
3032
+ reject(enhanceError(err, config, null, lastRequest));
3033
+ });
3034
+
3035
+ stream.on('end', function handleStreamEnd() {
3036
+ try {
3037
+ var responseData = responseBuffer.length === 1 ? responseBuffer[0] : Buffer.concat(responseBuffer);
3038
+ if (config.responseType !== 'arraybuffer') {
3039
+ responseData = responseData.toString(config.responseEncoding);
3040
+ if (!config.responseEncoding || config.responseEncoding === 'utf8') {
3041
+ responseData = utils.stripBOM(responseData);
3042
+ }
3043
+ }
3044
+ response.data = responseData;
3045
+ } catch (err) {
3046
+ reject(enhanceError(err, config, err.code, response.request, response));
3047
+ }
3048
+ settle(resolve, reject, response);
3049
+ });
3050
+ }
3051
+ });
3052
+
3053
+ // Handle errors
3054
+ req.on('error', function handleRequestError(err) {
3055
+ if (req.aborted && err.code !== 'ERR_FR_TOO_MANY_REDIRECTS') return;
3056
+ reject(enhanceError(err, config, null, req));
3057
+ });
3058
+
3059
+ // set tcp keep alive to prevent drop connection by peer
3060
+ req.on('socket', function handleRequestSocket(socket) {
3061
+ // default interval of sending ack packet is 1 minute
3062
+ socket.setKeepAlive(true, 1000 * 60);
3063
+ });
3064
+
3065
+ // Handle request timeout
3066
+ if (config.timeout) {
3067
+ // This is forcing a int timeout to avoid problems if the `req` interface doesn't handle other types.
3068
+ var timeout = parseInt(config.timeout, 10);
3069
+
3070
+ if (isNaN(timeout)) {
3071
+ reject(createError(
3072
+ 'error trying to parse `config.timeout` to int',
3073
+ config,
3074
+ 'ERR_PARSE_TIMEOUT',
3075
+ req
3076
+ ));
3077
+
3078
+ return;
3079
+ }
3080
+
3081
+ // Sometime, the response will be very slow, and does not respond, the connect event will be block by event loop system.
3082
+ // And timer callback will be fired, and abort() will be invoked before connection, then get "socket hang up" and code ECONNRESET.
3083
+ // At this time, if we have a large number of request, nodejs will hang up some socket on background. and the number will up and up.
3084
+ // And then these socket which be hang up will devoring CPU little by little.
3085
+ // ClientRequest.setTimeout will be fired on the specify milliseconds, and can make sure that abort() will be fired after connect.
3086
+ req.setTimeout(timeout, function handleRequestTimeout() {
3087
+ req.abort();
3088
+ var timeoutErrorMessage = '';
3089
+ if (config.timeoutErrorMessage) {
3090
+ timeoutErrorMessage = config.timeoutErrorMessage;
3091
+ } else {
3092
+ timeoutErrorMessage = 'timeout of ' + config.timeout + 'ms exceeded';
3093
+ }
3094
+ var transitional$1 = config.transitional || transitional;
3095
+ reject(createError(
3096
+ timeoutErrorMessage,
3097
+ config,
3098
+ transitional$1.clarifyTimeoutError ? 'ETIMEDOUT' : 'ECONNABORTED',
3099
+ req
3100
+ ));
3101
+ });
3102
+ }
3103
+
3104
+ if (config.cancelToken || config.signal) {
3105
+ // Handle cancellation
3106
+ // eslint-disable-next-line func-names
3107
+ onCanceled = function(cancel) {
3108
+ if (req.aborted) return;
3109
+
3110
+ req.abort();
3111
+ reject(!cancel || (cancel && cancel.type) ? new Cancel_1('canceled') : cancel);
3112
+ };
3113
+
3114
+ config.cancelToken && config.cancelToken.subscribe(onCanceled);
3115
+ if (config.signal) {
3116
+ config.signal.aborted ? onCanceled() : config.signal.addEventListener('abort', onCanceled);
3117
+ }
3118
+ }
3119
+
3120
+
3121
+ // Send the request
3122
+ if (utils.isStream(data)) {
3123
+ data.on('error', function handleStreamError(err) {
3124
+ reject(enhanceError(err, config, null, req));
3125
+ }).pipe(req);
3126
+ } else {
3127
+ req.end(data);
3128
+ }
3129
+ });
3130
+ };
3131
+
3132
+ var DEFAULT_CONTENT_TYPE = {
3133
+ 'Content-Type': 'application/x-www-form-urlencoded'
3134
+ };
3135
+
3136
+ function setContentTypeIfUnset(headers, value) {
3137
+ if (!utils.isUndefined(headers) && utils.isUndefined(headers['Content-Type'])) {
3138
+ headers['Content-Type'] = value;
3139
+ }
3140
+ }
3141
+
3142
+ function getDefaultAdapter() {
3143
+ var adapter;
3144
+ if (typeof XMLHttpRequest !== 'undefined') {
3145
+ // For browsers use XHR adapter
3146
+ adapter = xhr;
3147
+ } else if (typeof process !== 'undefined' && Object.prototype.toString.call(process) === '[object process]') {
3148
+ // For node use HTTP adapter
3149
+ adapter = http_1;
3150
+ }
3151
+ return adapter;
3152
+ }
3153
+
3154
+ function stringifySafely(rawValue, parser, encoder) {
3155
+ if (utils.isString(rawValue)) {
3156
+ try {
3157
+ (parser || JSON.parse)(rawValue);
3158
+ return utils.trim(rawValue);
3159
+ } catch (e) {
3160
+ if (e.name !== 'SyntaxError') {
3161
+ throw e;
3162
+ }
3163
+ }
3164
+ }
3165
+
3166
+ return (encoder || JSON.stringify)(rawValue);
3167
+ }
3168
+
3169
+ var defaults = {
3170
+
3171
+ transitional: transitional,
3172
+
3173
+ adapter: getDefaultAdapter(),
3174
+
3175
+ transformRequest: [function transformRequest(data, headers) {
3176
+ normalizeHeaderName(headers, 'Accept');
3177
+ normalizeHeaderName(headers, 'Content-Type');
3178
+
3179
+ if (utils.isFormData(data) ||
3180
+ utils.isArrayBuffer(data) ||
3181
+ utils.isBuffer(data) ||
3182
+ utils.isStream(data) ||
3183
+ utils.isFile(data) ||
3184
+ utils.isBlob(data)
3185
+ ) {
3186
+ return data;
3187
+ }
3188
+ if (utils.isArrayBufferView(data)) {
3189
+ return data.buffer;
3190
+ }
3191
+ if (utils.isURLSearchParams(data)) {
3192
+ setContentTypeIfUnset(headers, 'application/x-www-form-urlencoded;charset=utf-8');
3193
+ return data.toString();
3194
+ }
3195
+ if (utils.isObject(data) || (headers && headers['Content-Type'] === 'application/json')) {
3196
+ setContentTypeIfUnset(headers, 'application/json');
3197
+ return stringifySafely(data);
3198
+ }
3199
+ return data;
3200
+ }],
3201
+
3202
+ transformResponse: [function transformResponse(data) {
3203
+ var transitional = this.transitional || defaults.transitional;
3204
+ var silentJSONParsing = transitional && transitional.silentJSONParsing;
3205
+ var forcedJSONParsing = transitional && transitional.forcedJSONParsing;
3206
+ var strictJSONParsing = !silentJSONParsing && this.responseType === 'json';
3207
+
3208
+ if (strictJSONParsing || (forcedJSONParsing && utils.isString(data) && data.length)) {
3209
+ try {
3210
+ return JSON.parse(data);
3211
+ } catch (e) {
3212
+ if (strictJSONParsing) {
3213
+ if (e.name === 'SyntaxError') {
3214
+ throw enhanceError(e, this, 'E_JSON_PARSE');
3215
+ }
3216
+ throw e;
3217
+ }
3218
+ }
3219
+ }
3220
+
3221
+ return data;
3222
+ }],
3223
+
3224
+ /**
3225
+ * A timeout in milliseconds to abort a request. If set to 0 (default) a
3226
+ * timeout is not created.
3227
+ */
3228
+ timeout: 0,
3229
+
3230
+ xsrfCookieName: 'XSRF-TOKEN',
3231
+ xsrfHeaderName: 'X-XSRF-TOKEN',
3232
+
3233
+ maxContentLength: -1,
3234
+ maxBodyLength: -1,
3235
+
3236
+ validateStatus: function validateStatus(status) {
3237
+ return status >= 200 && status < 300;
3238
+ },
3239
+
3240
+ headers: {
3241
+ common: {
3242
+ 'Accept': 'application/json, text/plain, */*'
3243
+ }
3244
+ }
3245
+ };
3246
+
3247
+ utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {
3248
+ defaults.headers[method] = {};
3249
+ });
3250
+
3251
+ utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
3252
+ defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);
3253
+ });
3254
+
3255
+ var defaults_1 = defaults;
3256
+
3257
+ /**
3258
+ * Transform the data for a request or a response
3259
+ *
3260
+ * @param {Object|String} data The data to be transformed
3261
+ * @param {Array} headers The headers for the request or response
3262
+ * @param {Array|Function} fns A single function or Array of functions
3263
+ * @returns {*} The resulting transformed data
3264
+ */
3265
+ var transformData = function transformData(data, headers, fns) {
3266
+ var context = this || defaults_1;
3267
+ /*eslint no-param-reassign:0*/
3268
+ utils.forEach(fns, function transform(fn) {
3269
+ data = fn.call(context, data, headers);
3270
+ });
3271
+
3272
+ return data;
3273
+ };
3274
+
3275
+ var isCancel = function isCancel(value) {
3276
+ return !!(value && value.__CANCEL__);
3277
+ };
3278
+
3279
+ /**
3280
+ * Throws a `Cancel` if cancellation has been requested.
3281
+ */
3282
+ function throwIfCancellationRequested(config) {
3283
+ if (config.cancelToken) {
3284
+ config.cancelToken.throwIfRequested();
3285
+ }
3286
+
3287
+ if (config.signal && config.signal.aborted) {
3288
+ throw new Cancel_1('canceled');
3289
+ }
3290
+ }
3291
+
3292
+ /**
3293
+ * Dispatch a request to the server using the configured adapter.
3294
+ *
3295
+ * @param {object} config The config that is to be used for the request
3296
+ * @returns {Promise} The Promise to be fulfilled
3297
+ */
3298
+ var dispatchRequest = function dispatchRequest(config) {
3299
+ throwIfCancellationRequested(config);
3300
+
3301
+ // Ensure headers exist
3302
+ config.headers = config.headers || {};
3303
+
3304
+ // Transform request data
3305
+ config.data = transformData.call(
3306
+ config,
3307
+ config.data,
3308
+ config.headers,
3309
+ config.transformRequest
3310
+ );
3311
+
3312
+ // Flatten headers
3313
+ config.headers = utils.merge(
3314
+ config.headers.common || {},
3315
+ config.headers[config.method] || {},
3316
+ config.headers
3317
+ );
3318
+
3319
+ utils.forEach(
3320
+ ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
3321
+ function cleanHeaderConfig(method) {
3322
+ delete config.headers[method];
3323
+ }
3324
+ );
3325
+
3326
+ var adapter = config.adapter || defaults_1.adapter;
3327
+
3328
+ return adapter(config).then(function onAdapterResolution(response) {
3329
+ throwIfCancellationRequested(config);
3330
+
3331
+ // Transform response data
3332
+ response.data = transformData.call(
3333
+ config,
3334
+ response.data,
3335
+ response.headers,
3336
+ config.transformResponse
3337
+ );
3338
+
3339
+ return response;
3340
+ }, function onAdapterRejection(reason) {
3341
+ if (!isCancel(reason)) {
3342
+ throwIfCancellationRequested(config);
3343
+
3344
+ // Transform response data
3345
+ if (reason && reason.response) {
3346
+ reason.response.data = transformData.call(
3347
+ config,
3348
+ reason.response.data,
3349
+ reason.response.headers,
3350
+ config.transformResponse
3351
+ );
3352
+ }
3353
+ }
3354
+
3355
+ return Promise.reject(reason);
3356
+ });
3357
+ };
3358
+
3359
+ /**
3360
+ * Config-specific merge-function which creates a new config-object
3361
+ * by merging two configuration objects together.
3362
+ *
3363
+ * @param {Object} config1
3364
+ * @param {Object} config2
3365
+ * @returns {Object} New object resulting from merging config2 to config1
3366
+ */
3367
+ var mergeConfig = function mergeConfig(config1, config2) {
3368
+ // eslint-disable-next-line no-param-reassign
3369
+ config2 = config2 || {};
3370
+ var config = {};
3371
+
3372
+ function getMergedValue(target, source) {
3373
+ if (utils.isPlainObject(target) && utils.isPlainObject(source)) {
3374
+ return utils.merge(target, source);
3375
+ } else if (utils.isPlainObject(source)) {
3376
+ return utils.merge({}, source);
3377
+ } else if (utils.isArray(source)) {
3378
+ return source.slice();
3379
+ }
3380
+ return source;
3381
+ }
3382
+
3383
+ // eslint-disable-next-line consistent-return
3384
+ function mergeDeepProperties(prop) {
3385
+ if (!utils.isUndefined(config2[prop])) {
3386
+ return getMergedValue(config1[prop], config2[prop]);
3387
+ } else if (!utils.isUndefined(config1[prop])) {
3388
+ return getMergedValue(undefined, config1[prop]);
3389
+ }
3390
+ }
3391
+
3392
+ // eslint-disable-next-line consistent-return
3393
+ function valueFromConfig2(prop) {
3394
+ if (!utils.isUndefined(config2[prop])) {
3395
+ return getMergedValue(undefined, config2[prop]);
3396
+ }
3397
+ }
3398
+
3399
+ // eslint-disable-next-line consistent-return
3400
+ function defaultToConfig2(prop) {
3401
+ if (!utils.isUndefined(config2[prop])) {
3402
+ return getMergedValue(undefined, config2[prop]);
3403
+ } else if (!utils.isUndefined(config1[prop])) {
3404
+ return getMergedValue(undefined, config1[prop]);
3405
+ }
3406
+ }
3407
+
3408
+ // eslint-disable-next-line consistent-return
3409
+ function mergeDirectKeys(prop) {
3410
+ if (prop in config2) {
3411
+ return getMergedValue(config1[prop], config2[prop]);
3412
+ } else if (prop in config1) {
3413
+ return getMergedValue(undefined, config1[prop]);
3414
+ }
3415
+ }
3416
+
3417
+ var mergeMap = {
3418
+ 'url': valueFromConfig2,
3419
+ 'method': valueFromConfig2,
3420
+ 'data': valueFromConfig2,
3421
+ 'baseURL': defaultToConfig2,
3422
+ 'transformRequest': defaultToConfig2,
3423
+ 'transformResponse': defaultToConfig2,
3424
+ 'paramsSerializer': defaultToConfig2,
3425
+ 'timeout': defaultToConfig2,
3426
+ 'timeoutMessage': defaultToConfig2,
3427
+ 'withCredentials': defaultToConfig2,
3428
+ 'adapter': defaultToConfig2,
3429
+ 'responseType': defaultToConfig2,
3430
+ 'xsrfCookieName': defaultToConfig2,
3431
+ 'xsrfHeaderName': defaultToConfig2,
3432
+ 'onUploadProgress': defaultToConfig2,
3433
+ 'onDownloadProgress': defaultToConfig2,
3434
+ 'decompress': defaultToConfig2,
3435
+ 'maxContentLength': defaultToConfig2,
3436
+ 'maxBodyLength': defaultToConfig2,
3437
+ 'transport': defaultToConfig2,
3438
+ 'httpAgent': defaultToConfig2,
3439
+ 'httpsAgent': defaultToConfig2,
3440
+ 'cancelToken': defaultToConfig2,
3441
+ 'socketPath': defaultToConfig2,
3442
+ 'responseEncoding': defaultToConfig2,
3443
+ 'validateStatus': mergeDirectKeys
3444
+ };
3445
+
3446
+ utils.forEach(Object.keys(config1).concat(Object.keys(config2)), function computeConfigValue(prop) {
3447
+ var merge = mergeMap[prop] || mergeDeepProperties;
3448
+ var configValue = merge(prop);
3449
+ (utils.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
3450
+ });
3451
+
3452
+ return config;
3453
+ };
3454
+
3455
+ var VERSION = data.version;
3456
+
3457
+ var validators$1 = {};
3458
+
3459
+ // eslint-disable-next-line func-names
3460
+ ['object', 'boolean', 'number', 'function', 'string', 'symbol'].forEach(function(type, i) {
3461
+ validators$1[type] = function validator(thing) {
3462
+ return typeof thing === type || 'a' + (i < 1 ? 'n ' : ' ') + type;
3463
+ };
3464
+ });
3465
+
3466
+ var deprecatedWarnings = {};
3467
+
3468
+ /**
3469
+ * Transitional option validator
3470
+ * @param {function|boolean?} validator - set to false if the transitional option has been removed
3471
+ * @param {string?} version - deprecated version / removed since version
3472
+ * @param {string?} message - some message with additional info
3473
+ * @returns {function}
3474
+ */
3475
+ validators$1.transitional = function transitional(validator, version, message) {
3476
+ function formatMessage(opt, desc) {
3477
+ return '[Axios v' + VERSION + '] Transitional option \'' + opt + '\'' + desc + (message ? '. ' + message : '');
3478
+ }
3479
+
3480
+ // eslint-disable-next-line func-names
3481
+ return function(value, opt, opts) {
3482
+ if (validator === false) {
3483
+ throw new Error(formatMessage(opt, ' has been removed' + (version ? ' in ' + version : '')));
3484
+ }
3485
+
3486
+ if (version && !deprecatedWarnings[opt]) {
3487
+ deprecatedWarnings[opt] = true;
3488
+ // eslint-disable-next-line no-console
3489
+ console.warn(
3490
+ formatMessage(
3491
+ opt,
3492
+ ' has been deprecated since v' + version + ' and will be removed in the near future'
3493
+ )
3494
+ );
3495
+ }
3496
+
3497
+ return validator ? validator(value, opt, opts) : true;
3498
+ };
3499
+ };
3500
+
3501
+ /**
3502
+ * Assert object's properties type
3503
+ * @param {object} options
3504
+ * @param {object} schema
3505
+ * @param {boolean?} allowUnknown
3506
+ */
3507
+
3508
+ function assertOptions(options, schema, allowUnknown) {
3509
+ if (typeof options !== 'object') {
3510
+ throw new TypeError('options must be an object');
3511
+ }
3512
+ var keys = Object.keys(options);
3513
+ var i = keys.length;
3514
+ while (i-- > 0) {
3515
+ var opt = keys[i];
3516
+ var validator = schema[opt];
3517
+ if (validator) {
3518
+ var value = options[opt];
3519
+ var result = value === undefined || validator(value, opt, options);
3520
+ if (result !== true) {
3521
+ throw new TypeError('option ' + opt + ' must be ' + result);
3522
+ }
3523
+ continue;
3524
+ }
3525
+ if (allowUnknown !== true) {
3526
+ throw Error('Unknown option ' + opt);
3527
+ }
3528
+ }
3529
+ }
3530
+
3531
+ var validator = {
3532
+ assertOptions: assertOptions,
3533
+ validators: validators$1
3534
+ };
3535
+
3536
+ var validators = validator.validators;
3537
+ /**
3538
+ * Create a new instance of Axios
3539
+ *
3540
+ * @param {Object} instanceConfig The default config for the instance
3541
+ */
3542
+ function Axios(instanceConfig) {
3543
+ this.defaults = instanceConfig;
3544
+ this.interceptors = {
3545
+ request: new InterceptorManager_1(),
3546
+ response: new InterceptorManager_1()
3547
+ };
3548
+ }
3549
+
3550
+ /**
3551
+ * Dispatch a request
3552
+ *
3553
+ * @param {Object} config The config specific for this request (merged with this.defaults)
3554
+ */
3555
+ Axios.prototype.request = function request(configOrUrl, config) {
3556
+ /*eslint no-param-reassign:0*/
3557
+ // Allow for axios('example/url'[, config]) a la fetch API
3558
+ if (typeof configOrUrl === 'string') {
3559
+ config = config || {};
3560
+ config.url = configOrUrl;
3561
+ } else {
3562
+ config = configOrUrl || {};
3563
+ }
3564
+
3565
+ config = mergeConfig(this.defaults, config);
3566
+
3567
+ // Set config.method
3568
+ if (config.method) {
3569
+ config.method = config.method.toLowerCase();
3570
+ } else if (this.defaults.method) {
3571
+ config.method = this.defaults.method.toLowerCase();
3572
+ } else {
3573
+ config.method = 'get';
3574
+ }
3575
+
3576
+ var transitional = config.transitional;
3577
+
3578
+ if (transitional !== undefined) {
3579
+ validator.assertOptions(transitional, {
3580
+ silentJSONParsing: validators.transitional(validators.boolean),
3581
+ forcedJSONParsing: validators.transitional(validators.boolean),
3582
+ clarifyTimeoutError: validators.transitional(validators.boolean)
3583
+ }, false);
3584
+ }
3585
+
3586
+ // filter out skipped interceptors
3587
+ var requestInterceptorChain = [];
3588
+ var synchronousRequestInterceptors = true;
3589
+ this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
3590
+ if (typeof interceptor.runWhen === 'function' && interceptor.runWhen(config) === false) {
3591
+ return;
3592
+ }
3593
+
3594
+ synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous;
3595
+
3596
+ requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected);
3597
+ });
3598
+
3599
+ var responseInterceptorChain = [];
3600
+ this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
3601
+ responseInterceptorChain.push(interceptor.fulfilled, interceptor.rejected);
3602
+ });
3603
+
3604
+ var promise;
3605
+
3606
+ if (!synchronousRequestInterceptors) {
3607
+ var chain = [dispatchRequest, undefined];
3608
+
3609
+ Array.prototype.unshift.apply(chain, requestInterceptorChain);
3610
+ chain = chain.concat(responseInterceptorChain);
3611
+
3612
+ promise = Promise.resolve(config);
3613
+ while (chain.length) {
3614
+ promise = promise.then(chain.shift(), chain.shift());
3615
+ }
3616
+
3617
+ return promise;
3618
+ }
3619
+
3620
+
3621
+ var newConfig = config;
3622
+ while (requestInterceptorChain.length) {
3623
+ var onFulfilled = requestInterceptorChain.shift();
3624
+ var onRejected = requestInterceptorChain.shift();
3625
+ try {
3626
+ newConfig = onFulfilled(newConfig);
3627
+ } catch (error) {
3628
+ onRejected(error);
3629
+ break;
3630
+ }
3631
+ }
3632
+
3633
+ try {
3634
+ promise = dispatchRequest(newConfig);
3635
+ } catch (error) {
3636
+ return Promise.reject(error);
3637
+ }
3638
+
3639
+ while (responseInterceptorChain.length) {
3640
+ promise = promise.then(responseInterceptorChain.shift(), responseInterceptorChain.shift());
3641
+ }
3642
+
3643
+ return promise;
3644
+ };
3645
+
3646
+ Axios.prototype.getUri = function getUri(config) {
3647
+ config = mergeConfig(this.defaults, config);
3648
+ return buildURL(config.url, config.params, config.paramsSerializer).replace(/^\?/, '');
3649
+ };
3650
+
3651
+ // Provide aliases for supported request methods
3652
+ utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
3653
+ /*eslint func-names:0*/
3654
+ Axios.prototype[method] = function(url, config) {
3655
+ return this.request(mergeConfig(config || {}, {
3656
+ method: method,
3657
+ url: url,
3658
+ data: (config || {}).data
3659
+ }));
3660
+ };
3661
+ });
3662
+
3663
+ utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
3664
+ /*eslint func-names:0*/
3665
+ Axios.prototype[method] = function(url, data, config) {
3666
+ return this.request(mergeConfig(config || {}, {
3667
+ method: method,
3668
+ url: url,
3669
+ data: data
3670
+ }));
3671
+ };
3672
+ });
3673
+
3674
+ var Axios_1 = Axios;
3675
+
3676
+ /**
3677
+ * A `CancelToken` is an object that can be used to request cancellation of an operation.
3678
+ *
3679
+ * @class
3680
+ * @param {Function} executor The executor function.
3681
+ */
3682
+ function CancelToken(executor) {
3683
+ if (typeof executor !== 'function') {
3684
+ throw new TypeError('executor must be a function.');
3685
+ }
3686
+
3687
+ var resolvePromise;
3688
+
3689
+ this.promise = new Promise(function promiseExecutor(resolve) {
3690
+ resolvePromise = resolve;
3691
+ });
3692
+
3693
+ var token = this;
3694
+
3695
+ // eslint-disable-next-line func-names
3696
+ this.promise.then(function(cancel) {
3697
+ if (!token._listeners) return;
3698
+
3699
+ var i;
3700
+ var l = token._listeners.length;
3701
+
3702
+ for (i = 0; i < l; i++) {
3703
+ token._listeners[i](cancel);
3704
+ }
3705
+ token._listeners = null;
3706
+ });
3707
+
3708
+ // eslint-disable-next-line func-names
3709
+ this.promise.then = function(onfulfilled) {
3710
+ var _resolve;
3711
+ // eslint-disable-next-line func-names
3712
+ var promise = new Promise(function(resolve) {
3713
+ token.subscribe(resolve);
3714
+ _resolve = resolve;
3715
+ }).then(onfulfilled);
3716
+
3717
+ promise.cancel = function reject() {
3718
+ token.unsubscribe(_resolve);
3719
+ };
3720
+
3721
+ return promise;
3722
+ };
3723
+
3724
+ executor(function cancel(message) {
3725
+ if (token.reason) {
3726
+ // Cancellation has already been requested
3727
+ return;
3728
+ }
3729
+
3730
+ token.reason = new Cancel_1(message);
3731
+ resolvePromise(token.reason);
3732
+ });
3733
+ }
3734
+
3735
+ /**
3736
+ * Throws a `Cancel` if cancellation has been requested.
3737
+ */
3738
+ CancelToken.prototype.throwIfRequested = function throwIfRequested() {
3739
+ if (this.reason) {
3740
+ throw this.reason;
3741
+ }
3742
+ };
3743
+
3744
+ /**
3745
+ * Subscribe to the cancel signal
3746
+ */
3747
+
3748
+ CancelToken.prototype.subscribe = function subscribe(listener) {
3749
+ if (this.reason) {
3750
+ listener(this.reason);
3751
+ return;
3752
+ }
3753
+
3754
+ if (this._listeners) {
3755
+ this._listeners.push(listener);
3756
+ } else {
3757
+ this._listeners = [listener];
3758
+ }
3759
+ };
3760
+
3761
+ /**
3762
+ * Unsubscribe from the cancel signal
3763
+ */
3764
+
3765
+ CancelToken.prototype.unsubscribe = function unsubscribe(listener) {
3766
+ if (!this._listeners) {
3767
+ return;
3768
+ }
3769
+ var index = this._listeners.indexOf(listener);
3770
+ if (index !== -1) {
3771
+ this._listeners.splice(index, 1);
3772
+ }
3773
+ };
3774
+
3775
+ /**
3776
+ * Returns an object that contains a new `CancelToken` and a function that, when called,
3777
+ * cancels the `CancelToken`.
3778
+ */
3779
+ CancelToken.source = function source() {
3780
+ var cancel;
3781
+ var token = new CancelToken(function executor(c) {
3782
+ cancel = c;
3783
+ });
3784
+ return {
3785
+ token: token,
3786
+ cancel: cancel
3787
+ };
3788
+ };
3789
+
3790
+ var CancelToken_1 = CancelToken;
3791
+
3792
+ /**
3793
+ * Syntactic sugar for invoking a function and expanding an array for arguments.
3794
+ *
3795
+ * Common use case would be to use `Function.prototype.apply`.
3796
+ *
3797
+ * ```js
3798
+ * function f(x, y, z) {}
3799
+ * var args = [1, 2, 3];
3800
+ * f.apply(null, args);
3801
+ * ```
3802
+ *
3803
+ * With `spread` this example can be re-written.
3804
+ *
3805
+ * ```js
3806
+ * spread(function(x, y, z) {})([1, 2, 3]);
3807
+ * ```
3808
+ *
3809
+ * @param {Function} callback
3810
+ * @returns {Function}
3811
+ */
3812
+ var spread = function spread(callback) {
3813
+ return function wrap(arr) {
3814
+ return callback.apply(null, arr);
3815
+ };
3816
+ };
3817
+
3818
+ /**
3819
+ * Determines whether the payload is an error thrown by Axios
3820
+ *
3821
+ * @param {*} payload The value to test
3822
+ * @returns {boolean} True if the payload is an error thrown by Axios, otherwise false
3823
+ */
3824
+ var isAxiosError = function isAxiosError(payload) {
3825
+ return utils.isObject(payload) && (payload.isAxiosError === true);
3826
+ };
3827
+
3828
+ /**
3829
+ * Create an instance of Axios
3830
+ *
3831
+ * @param {Object} defaultConfig The default config for the instance
3832
+ * @return {Axios} A new instance of Axios
3833
+ */
3834
+ function createInstance(defaultConfig) {
3835
+ var context = new Axios_1(defaultConfig);
3836
+ var instance = bind(Axios_1.prototype.request, context);
3837
+
3838
+ // Copy axios.prototype to instance
3839
+ utils.extend(instance, Axios_1.prototype, context);
3840
+
3841
+ // Copy context to instance
3842
+ utils.extend(instance, context);
3843
+
3844
+ // Factory for creating new instances
3845
+ instance.create = function create(instanceConfig) {
3846
+ return createInstance(mergeConfig(defaultConfig, instanceConfig));
3847
+ };
3848
+
3849
+ return instance;
3850
+ }
3851
+
3852
+ // Create the default instance to be exported
3853
+ var axios$1 = createInstance(defaults_1);
3854
+
3855
+ // Expose Axios class to allow class inheritance
3856
+ axios$1.Axios = Axios_1;
3857
+
3858
+ // Expose Cancel & CancelToken
3859
+ axios$1.Cancel = Cancel_1;
3860
+ axios$1.CancelToken = CancelToken_1;
3861
+ axios$1.isCancel = isCancel;
3862
+ axios$1.VERSION = data.version;
3863
+
3864
+ // Expose all/spread
3865
+ axios$1.all = function all(promises) {
3866
+ return Promise.all(promises);
3867
+ };
3868
+ axios$1.spread = spread;
3869
+
3870
+ // Expose isAxiosError
3871
+ axios$1.isAxiosError = isAxiosError;
3872
+
3873
+ var axios_1 = axios$1;
3874
+
3875
+ // Allow use of default import syntax in TypeScript
3876
+ var _default = axios$1;
3877
+ axios_1.default = _default;
3878
+
3879
+ var axios = axios_1;
3880
+
3881
+ //
3882
+ var script = {
3883
+ name: "Banners",
3884
+ props: {
3885
+ type: {
3886
+ type: String,
3887
+
3888
+ validator(value) {
3889
+ return ['header', 'footer'].includes(value);
3890
+ },
3891
+
3892
+ default() {
3893
+ return 'header';
3894
+ }
3895
+
3896
+ }
3897
+ },
3898
+
3899
+ data() {
3900
+ return {
3901
+ dismissedBanners: [],
3902
+ staticContent: {}
3903
+ };
3904
+ },
3905
+
3906
+ computed: {
3907
+ mappedStaticContentHeaders: function () {
3908
+ const computed = [];
3909
+ const banner_type = this.type === 'header' ? 'headers' : 'footers';
3910
+
3911
+ for (var key in this.staticContent[banner_type]) {
3912
+ if (!this.dismissedBanners.includes(parseInt(key))) {
3913
+ computed.push(this.staticContent[banner_type][key]);
3914
+ }
3915
+ }
3916
+
3917
+ return computed;
3918
+ }
3919
+ },
3920
+ methods: {
3921
+ dismissBanner(key) {
3922
+ this.dismissedBanners.push(key);
3923
+ }
3924
+
3925
+ },
3926
+
3927
+ async mounted() {
3928
+ const {
3929
+ data
3930
+ } = await axios.get(`${this.app_manager_config.baseUrl}/api/app-manager/marketing-banners`);
3931
+ this.staticContent = data.banners;
3932
+ }
3933
+
3934
+ };
3935
+
3936
+ function normalizeComponent(template, style, script, scopeId, isFunctionalTemplate, moduleIdentifier /* server only */, shadowMode, createInjector, createInjectorSSR, createInjectorShadow) {
3937
+ if (typeof shadowMode !== 'boolean') {
3938
+ createInjectorSSR = createInjector;
3939
+ createInjector = shadowMode;
3940
+ shadowMode = false;
3941
+ }
3942
+ // Vue.extend constructor export interop.
3943
+ const options = typeof script === 'function' ? script.options : script;
3944
+ // render functions
3945
+ if (template && template.render) {
3946
+ options.render = template.render;
3947
+ options.staticRenderFns = template.staticRenderFns;
3948
+ options._compiled = true;
3949
+ // functional template
3950
+ if (isFunctionalTemplate) {
3951
+ options.functional = true;
3952
+ }
3953
+ }
3954
+ // scopedId
3955
+ if (scopeId) {
3956
+ options._scopeId = scopeId;
3957
+ }
3958
+ let hook;
3959
+ if (moduleIdentifier) {
3960
+ // server build
3961
+ hook = function (context) {
3962
+ // 2.3 injection
3963
+ context =
3964
+ context || // cached call
3965
+ (this.$vnode && this.$vnode.ssrContext) || // stateful
3966
+ (this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext); // functional
3967
+ // 2.2 with runInNewContext: true
3968
+ if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') {
3969
+ context = __VUE_SSR_CONTEXT__;
3970
+ }
3971
+ // inject component styles
3972
+ if (style) {
3973
+ style.call(this, createInjectorSSR(context));
3974
+ }
3975
+ // register component module identifier for async chunk inference
3976
+ if (context && context._registeredComponents) {
3977
+ context._registeredComponents.add(moduleIdentifier);
3978
+ }
3979
+ };
3980
+ // used by ssr in case component is cached and beforeCreate
3981
+ // never gets called
3982
+ options._ssrRegister = hook;
3983
+ }
3984
+ else if (style) {
3985
+ hook = shadowMode
3986
+ ? function (context) {
3987
+ style.call(this, createInjectorShadow(context, this.$root.$options.shadowRoot));
3988
+ }
3989
+ : function (context) {
3990
+ style.call(this, createInjector(context));
3991
+ };
3992
+ }
3993
+ if (hook) {
3994
+ if (options.functional) {
3995
+ // register for functional component in vue file
3996
+ const originalRender = options.render;
3997
+ options.render = function renderWithStyleInjection(h, context) {
3998
+ hook.call(context);
3999
+ return originalRender(h, context);
4000
+ };
4001
+ }
4002
+ else {
4003
+ // inject component registration as beforeCreate hook
4004
+ const existing = options.beforeCreate;
4005
+ options.beforeCreate = existing ? [].concat(existing, hook) : [hook];
4006
+ }
4007
+ }
4008
+ return script;
4009
+ }
4010
+
4011
+ /* script */
4012
+ const __vue_script__ = script;
4013
+ /* template */
4014
+
4015
+ var __vue_render__ = function () {
4016
+ var _vm = this;
4017
+
4018
+ var _h = _vm.$createElement;
4019
+
4020
+ var _c = _vm._self._c || _h;
4021
+
4022
+ return _vm.mappedStaticContentHeaders.length ? _c('PLayoutSection', _vm._l(_vm.mappedStaticContentHeaders, function (header, key) {
4023
+ return _c('PBanner', {
4024
+ key: key,
4025
+ attrs: {
4026
+ "id": "static-content-header-" + key,
4027
+ "status": header.status
4028
+ },
4029
+ on: {
4030
+ "dismiss": function () {
4031
+ return _vm.dismissBanner(key);
4032
+ }
4033
+ }
4034
+ }, [_c('span', {
4035
+ domProps: {
4036
+ "innerHTML": _vm._s(header.content)
4037
+ }
4038
+ })]);
4039
+ }), 1) : _vm._e();
4040
+ };
4041
+
4042
+ var __vue_staticRenderFns__ = [];
4043
+ /* style */
4044
+
4045
+ const __vue_inject_styles__ = undefined;
4046
+ /* scoped */
4047
+
4048
+ const __vue_scope_id__ = "data-v-69017906";
4049
+ /* module identifier */
4050
+
4051
+ const __vue_module_identifier__ = undefined;
4052
+ /* functional template */
4053
+
4054
+ const __vue_is_functional_template__ = false;
4055
+ /* style inject */
4056
+
4057
+ /* style inject SSR */
4058
+
4059
+ /* style inject shadow dom */
4060
+
4061
+ const __vue_component__ = /*#__PURE__*/normalizeComponent({
4062
+ render: __vue_render__,
4063
+ staticRenderFns: __vue_staticRenderFns__
4064
+ }, __vue_inject_styles__, __vue_script__, __vue_scope_id__, __vue_is_functional_template__, __vue_module_identifier__, false, undefined, undefined, undefined);
4065
+
4066
+ var __vue_component__$1 = __vue_component__;
4067
+
4068
+ /* eslint-disable import/prefer-default-export */
4069
+
4070
+ var components = /*#__PURE__*/Object.freeze({
4071
+ __proto__: null,
4072
+ Banners: __vue_component__$1
4073
+ });
4074
+
4075
+ // Import vue components
4076
+ const defaultConfig = {
4077
+ baseUrl: ''
4078
+ }; // install function executed by Vue.use()
4079
+
4080
+ const install = function installAppManagerVue(Vue) {
4081
+ let config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
4082
+ Object.entries(components).forEach(_ref => {
4083
+ let [componentName, component] = _ref;
4084
+ Vue.component(componentName, component);
4085
+ });
4086
+ Vue.prototype.app_manager_config = { ...defaultConfig,
4087
+ ...config
4088
+ };
4089
+ }; // Create module definition for Vue.use()
4090
+
4091
+ export { __vue_component__$1 as Banners, install as default };