@m4l/core 0.0.28 → 0.0.31

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.
@@ -1,4 +1,4 @@
1
- import { s as snakecaseKeys } from "./snakecase-keys.js";
1
+ import { l as lib } from "./qs.js";
2
2
  import { E as EmitEvents } from "../types/index.js";
3
3
  var axios$2 = { exports: {} };
4
4
  var bind$2 = function bind(fn, thisArg) {
@@ -1291,7 +1291,10 @@ const axiosOperation = async (props, enviroment, hostTools) => {
1291
1291
  method,
1292
1292
  url: `/${endPoint}`,
1293
1293
  data: data2,
1294
- params: snakecaseKeys(parms, { deep: true }),
1294
+ params: {},
1295
+ paramsSerializer: () => {
1296
+ return lib.stringify(parms, { encode: true });
1297
+ },
1295
1298
  headers,
1296
1299
  timeout
1297
1300
  }).then((response) => getResponse(endPoint, response)).catch((error) => Promise.reject(getError(error, hostTools, checkUnAuthorized))).finally(() => {
@@ -0,0 +1,633 @@
1
+ import { s as sideChannel } from "./side-channel.js";
2
+ var replace = String.prototype.replace;
3
+ var percentTwenties = /%20/g;
4
+ var Format = {
5
+ RFC1738: "RFC1738",
6
+ RFC3986: "RFC3986"
7
+ };
8
+ var formats$3 = {
9
+ "default": Format.RFC3986,
10
+ formatters: {
11
+ RFC1738: function(value) {
12
+ return replace.call(value, percentTwenties, "+");
13
+ },
14
+ RFC3986: function(value) {
15
+ return String(value);
16
+ }
17
+ },
18
+ RFC1738: Format.RFC1738,
19
+ RFC3986: Format.RFC3986
20
+ };
21
+ var formats$2 = formats$3;
22
+ var has$2 = Object.prototype.hasOwnProperty;
23
+ var isArray$2 = Array.isArray;
24
+ var hexTable = function() {
25
+ var array = [];
26
+ for (var i = 0; i < 256; ++i) {
27
+ array.push("%" + ((i < 16 ? "0" : "") + i.toString(16)).toUpperCase());
28
+ }
29
+ return array;
30
+ }();
31
+ var compactQueue = function compactQueue2(queue) {
32
+ while (queue.length > 1) {
33
+ var item = queue.pop();
34
+ var obj = item.obj[item.prop];
35
+ if (isArray$2(obj)) {
36
+ var compacted = [];
37
+ for (var j = 0; j < obj.length; ++j) {
38
+ if (typeof obj[j] !== "undefined") {
39
+ compacted.push(obj[j]);
40
+ }
41
+ }
42
+ item.obj[item.prop] = compacted;
43
+ }
44
+ }
45
+ };
46
+ var arrayToObject = function arrayToObject2(source, options) {
47
+ var obj = options && options.plainObjects ? /* @__PURE__ */ Object.create(null) : {};
48
+ for (var i = 0; i < source.length; ++i) {
49
+ if (typeof source[i] !== "undefined") {
50
+ obj[i] = source[i];
51
+ }
52
+ }
53
+ return obj;
54
+ };
55
+ var merge = function merge2(target, source, options) {
56
+ if (!source) {
57
+ return target;
58
+ }
59
+ if (typeof source !== "object") {
60
+ if (isArray$2(target)) {
61
+ target.push(source);
62
+ } else if (target && typeof target === "object") {
63
+ if (options && (options.plainObjects || options.allowPrototypes) || !has$2.call(Object.prototype, source)) {
64
+ target[source] = true;
65
+ }
66
+ } else {
67
+ return [target, source];
68
+ }
69
+ return target;
70
+ }
71
+ if (!target || typeof target !== "object") {
72
+ return [target].concat(source);
73
+ }
74
+ var mergeTarget = target;
75
+ if (isArray$2(target) && !isArray$2(source)) {
76
+ mergeTarget = arrayToObject(target, options);
77
+ }
78
+ if (isArray$2(target) && isArray$2(source)) {
79
+ source.forEach(function(item, i) {
80
+ if (has$2.call(target, i)) {
81
+ var targetItem = target[i];
82
+ if (targetItem && typeof targetItem === "object" && item && typeof item === "object") {
83
+ target[i] = merge2(targetItem, item, options);
84
+ } else {
85
+ target.push(item);
86
+ }
87
+ } else {
88
+ target[i] = item;
89
+ }
90
+ });
91
+ return target;
92
+ }
93
+ return Object.keys(source).reduce(function(acc, key) {
94
+ var value = source[key];
95
+ if (has$2.call(acc, key)) {
96
+ acc[key] = merge2(acc[key], value, options);
97
+ } else {
98
+ acc[key] = value;
99
+ }
100
+ return acc;
101
+ }, mergeTarget);
102
+ };
103
+ var assign = function assignSingleSource(target, source) {
104
+ return Object.keys(source).reduce(function(acc, key) {
105
+ acc[key] = source[key];
106
+ return acc;
107
+ }, target);
108
+ };
109
+ var decode = function(str, decoder, charset) {
110
+ var strWithoutPlus = str.replace(/\+/g, " ");
111
+ if (charset === "iso-8859-1") {
112
+ return strWithoutPlus.replace(/%[0-9a-f]{2}/gi, unescape);
113
+ }
114
+ try {
115
+ return decodeURIComponent(strWithoutPlus);
116
+ } catch (e) {
117
+ return strWithoutPlus;
118
+ }
119
+ };
120
+ var encode = function encode2(str, defaultEncoder, charset, kind, format) {
121
+ if (str.length === 0) {
122
+ return str;
123
+ }
124
+ var string = str;
125
+ if (typeof str === "symbol") {
126
+ string = Symbol.prototype.toString.call(str);
127
+ } else if (typeof str !== "string") {
128
+ string = String(str);
129
+ }
130
+ if (charset === "iso-8859-1") {
131
+ return escape(string).replace(/%u[0-9a-f]{4}/gi, function($0) {
132
+ return "%26%23" + parseInt($0.slice(2), 16) + "%3B";
133
+ });
134
+ }
135
+ var out = "";
136
+ for (var i = 0; i < string.length; ++i) {
137
+ var c = string.charCodeAt(i);
138
+ if (c === 45 || c === 46 || c === 95 || c === 126 || c >= 48 && c <= 57 || c >= 65 && c <= 90 || c >= 97 && c <= 122 || format === formats$2.RFC1738 && (c === 40 || c === 41)) {
139
+ out += string.charAt(i);
140
+ continue;
141
+ }
142
+ if (c < 128) {
143
+ out = out + hexTable[c];
144
+ continue;
145
+ }
146
+ if (c < 2048) {
147
+ out = out + (hexTable[192 | c >> 6] + hexTable[128 | c & 63]);
148
+ continue;
149
+ }
150
+ if (c < 55296 || c >= 57344) {
151
+ out = out + (hexTable[224 | c >> 12] + hexTable[128 | c >> 6 & 63] + hexTable[128 | c & 63]);
152
+ continue;
153
+ }
154
+ i += 1;
155
+ c = 65536 + ((c & 1023) << 10 | string.charCodeAt(i) & 1023);
156
+ out += hexTable[240 | c >> 18] + hexTable[128 | c >> 12 & 63] + hexTable[128 | c >> 6 & 63] + hexTable[128 | c & 63];
157
+ }
158
+ return out;
159
+ };
160
+ var compact = function compact2(value) {
161
+ var queue = [{ obj: { o: value }, prop: "o" }];
162
+ var refs = [];
163
+ for (var i = 0; i < queue.length; ++i) {
164
+ var item = queue[i];
165
+ var obj = item.obj[item.prop];
166
+ var keys = Object.keys(obj);
167
+ for (var j = 0; j < keys.length; ++j) {
168
+ var key = keys[j];
169
+ var val = obj[key];
170
+ if (typeof val === "object" && val !== null && refs.indexOf(val) === -1) {
171
+ queue.push({ obj, prop: key });
172
+ refs.push(val);
173
+ }
174
+ }
175
+ }
176
+ compactQueue(queue);
177
+ return value;
178
+ };
179
+ var isRegExp = function isRegExp2(obj) {
180
+ return Object.prototype.toString.call(obj) === "[object RegExp]";
181
+ };
182
+ var isBuffer = function isBuffer2(obj) {
183
+ if (!obj || typeof obj !== "object") {
184
+ return false;
185
+ }
186
+ return !!(obj.constructor && obj.constructor.isBuffer && obj.constructor.isBuffer(obj));
187
+ };
188
+ var combine = function combine2(a, b) {
189
+ return [].concat(a, b);
190
+ };
191
+ var maybeMap = function maybeMap2(val, fn) {
192
+ if (isArray$2(val)) {
193
+ var mapped = [];
194
+ for (var i = 0; i < val.length; i += 1) {
195
+ mapped.push(fn(val[i]));
196
+ }
197
+ return mapped;
198
+ }
199
+ return fn(val);
200
+ };
201
+ var utils$2 = {
202
+ arrayToObject,
203
+ assign,
204
+ combine,
205
+ compact,
206
+ decode,
207
+ encode,
208
+ isBuffer,
209
+ isRegExp,
210
+ maybeMap,
211
+ merge
212
+ };
213
+ var getSideChannel = sideChannel;
214
+ var utils$1 = utils$2;
215
+ var formats$1 = formats$3;
216
+ var has$1 = Object.prototype.hasOwnProperty;
217
+ var arrayPrefixGenerators = {
218
+ brackets: function brackets(prefix) {
219
+ return prefix + "[]";
220
+ },
221
+ comma: "comma",
222
+ indices: function indices(prefix, key) {
223
+ return prefix + "[" + key + "]";
224
+ },
225
+ repeat: function repeat(prefix) {
226
+ return prefix;
227
+ }
228
+ };
229
+ var isArray$1 = Array.isArray;
230
+ var split = String.prototype.split;
231
+ var push = Array.prototype.push;
232
+ var pushToArray = function(arr, valueOrArray) {
233
+ push.apply(arr, isArray$1(valueOrArray) ? valueOrArray : [valueOrArray]);
234
+ };
235
+ var toISO = Date.prototype.toISOString;
236
+ var defaultFormat = formats$1["default"];
237
+ var defaults$1 = {
238
+ addQueryPrefix: false,
239
+ allowDots: false,
240
+ charset: "utf-8",
241
+ charsetSentinel: false,
242
+ delimiter: "&",
243
+ encode: true,
244
+ encoder: utils$1.encode,
245
+ encodeValuesOnly: false,
246
+ format: defaultFormat,
247
+ formatter: formats$1.formatters[defaultFormat],
248
+ indices: false,
249
+ serializeDate: function serializeDate(date) {
250
+ return toISO.call(date);
251
+ },
252
+ skipNulls: false,
253
+ strictNullHandling: false
254
+ };
255
+ var isNonNullishPrimitive = function isNonNullishPrimitive2(v) {
256
+ return typeof v === "string" || typeof v === "number" || typeof v === "boolean" || typeof v === "symbol" || typeof v === "bigint";
257
+ };
258
+ var sentinel = {};
259
+ var stringify$1 = function stringify(object, prefix, generateArrayPrefix, commaRoundTrip, strictNullHandling, skipNulls, encoder, filter, sort, allowDots, serializeDate2, format, formatter, encodeValuesOnly, charset, sideChannel2) {
260
+ var obj = object;
261
+ var tmpSc = sideChannel2;
262
+ var step = 0;
263
+ var findFlag = false;
264
+ while ((tmpSc = tmpSc.get(sentinel)) !== void 0 && !findFlag) {
265
+ var pos = tmpSc.get(object);
266
+ step += 1;
267
+ if (typeof pos !== "undefined") {
268
+ if (pos === step) {
269
+ throw new RangeError("Cyclic object value");
270
+ } else {
271
+ findFlag = true;
272
+ }
273
+ }
274
+ if (typeof tmpSc.get(sentinel) === "undefined") {
275
+ step = 0;
276
+ }
277
+ }
278
+ if (typeof filter === "function") {
279
+ obj = filter(prefix, obj);
280
+ } else if (obj instanceof Date) {
281
+ obj = serializeDate2(obj);
282
+ } else if (generateArrayPrefix === "comma" && isArray$1(obj)) {
283
+ obj = utils$1.maybeMap(obj, function(value2) {
284
+ if (value2 instanceof Date) {
285
+ return serializeDate2(value2);
286
+ }
287
+ return value2;
288
+ });
289
+ }
290
+ if (obj === null) {
291
+ if (strictNullHandling) {
292
+ return encoder && !encodeValuesOnly ? encoder(prefix, defaults$1.encoder, charset, "key", format) : prefix;
293
+ }
294
+ obj = "";
295
+ }
296
+ if (isNonNullishPrimitive(obj) || utils$1.isBuffer(obj)) {
297
+ if (encoder) {
298
+ var keyValue = encodeValuesOnly ? prefix : encoder(prefix, defaults$1.encoder, charset, "key", format);
299
+ if (generateArrayPrefix === "comma" && encodeValuesOnly) {
300
+ var valuesArray = split.call(String(obj), ",");
301
+ var valuesJoined = "";
302
+ for (var i = 0; i < valuesArray.length; ++i) {
303
+ valuesJoined += (i === 0 ? "" : ",") + formatter(encoder(valuesArray[i], defaults$1.encoder, charset, "value", format));
304
+ }
305
+ return [formatter(keyValue) + (commaRoundTrip && isArray$1(obj) && valuesArray.length === 1 ? "[]" : "") + "=" + valuesJoined];
306
+ }
307
+ return [formatter(keyValue) + "=" + formatter(encoder(obj, defaults$1.encoder, charset, "value", format))];
308
+ }
309
+ return [formatter(prefix) + "=" + formatter(String(obj))];
310
+ }
311
+ var values = [];
312
+ if (typeof obj === "undefined") {
313
+ return values;
314
+ }
315
+ var objKeys;
316
+ if (generateArrayPrefix === "comma" && isArray$1(obj)) {
317
+ objKeys = [{ value: obj.length > 0 ? obj.join(",") || null : void 0 }];
318
+ } else if (isArray$1(filter)) {
319
+ objKeys = filter;
320
+ } else {
321
+ var keys = Object.keys(obj);
322
+ objKeys = sort ? keys.sort(sort) : keys;
323
+ }
324
+ var adjustedPrefix = commaRoundTrip && isArray$1(obj) && obj.length === 1 ? prefix + "[]" : prefix;
325
+ for (var j = 0; j < objKeys.length; ++j) {
326
+ var key = objKeys[j];
327
+ var value = typeof key === "object" && typeof key.value !== "undefined" ? key.value : obj[key];
328
+ if (skipNulls && value === null) {
329
+ continue;
330
+ }
331
+ var keyPrefix = isArray$1(obj) ? typeof generateArrayPrefix === "function" ? generateArrayPrefix(adjustedPrefix, key) : adjustedPrefix : adjustedPrefix + (allowDots ? "." + key : "[" + key + "]");
332
+ sideChannel2.set(object, step);
333
+ var valueSideChannel = getSideChannel();
334
+ valueSideChannel.set(sentinel, sideChannel2);
335
+ pushToArray(values, stringify(value, keyPrefix, generateArrayPrefix, commaRoundTrip, strictNullHandling, skipNulls, encoder, filter, sort, allowDots, serializeDate2, format, formatter, encodeValuesOnly, charset, valueSideChannel));
336
+ }
337
+ return values;
338
+ };
339
+ var normalizeStringifyOptions = function normalizeStringifyOptions2(opts) {
340
+ if (!opts) {
341
+ return defaults$1;
342
+ }
343
+ if (opts.encoder !== null && typeof opts.encoder !== "undefined" && typeof opts.encoder !== "function") {
344
+ throw new TypeError("Encoder has to be a function.");
345
+ }
346
+ var charset = opts.charset || defaults$1.charset;
347
+ if (typeof opts.charset !== "undefined" && opts.charset !== "utf-8" && opts.charset !== "iso-8859-1") {
348
+ throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");
349
+ }
350
+ var format = formats$1["default"];
351
+ if (typeof opts.format !== "undefined") {
352
+ if (!has$1.call(formats$1.formatters, opts.format)) {
353
+ throw new TypeError("Unknown format option provided.");
354
+ }
355
+ format = opts.format;
356
+ }
357
+ var formatter = formats$1.formatters[format];
358
+ var filter = defaults$1.filter;
359
+ if (typeof opts.filter === "function" || isArray$1(opts.filter)) {
360
+ filter = opts.filter;
361
+ }
362
+ return {
363
+ addQueryPrefix: typeof opts.addQueryPrefix === "boolean" ? opts.addQueryPrefix : defaults$1.addQueryPrefix,
364
+ allowDots: typeof opts.allowDots === "undefined" ? defaults$1.allowDots : !!opts.allowDots,
365
+ charset,
366
+ charsetSentinel: typeof opts.charsetSentinel === "boolean" ? opts.charsetSentinel : defaults$1.charsetSentinel,
367
+ delimiter: typeof opts.delimiter === "undefined" ? defaults$1.delimiter : opts.delimiter,
368
+ encode: typeof opts.encode === "boolean" ? opts.encode : defaults$1.encode,
369
+ encoder: typeof opts.encoder === "function" ? opts.encoder : defaults$1.encoder,
370
+ encodeValuesOnly: typeof opts.encodeValuesOnly === "boolean" ? opts.encodeValuesOnly : defaults$1.encodeValuesOnly,
371
+ filter,
372
+ format,
373
+ formatter,
374
+ serializeDate: typeof opts.serializeDate === "function" ? opts.serializeDate : defaults$1.serializeDate,
375
+ skipNulls: typeof opts.skipNulls === "boolean" ? opts.skipNulls : defaults$1.skipNulls,
376
+ sort: typeof opts.sort === "function" ? opts.sort : null,
377
+ strictNullHandling: typeof opts.strictNullHandling === "boolean" ? opts.strictNullHandling : defaults$1.strictNullHandling
378
+ };
379
+ };
380
+ var stringify_1 = function(object, opts) {
381
+ var obj = object;
382
+ var options = normalizeStringifyOptions(opts);
383
+ var objKeys;
384
+ var filter;
385
+ if (typeof options.filter === "function") {
386
+ filter = options.filter;
387
+ obj = filter("", obj);
388
+ } else if (isArray$1(options.filter)) {
389
+ filter = options.filter;
390
+ objKeys = filter;
391
+ }
392
+ var keys = [];
393
+ if (typeof obj !== "object" || obj === null) {
394
+ return "";
395
+ }
396
+ var arrayFormat;
397
+ if (opts && opts.arrayFormat in arrayPrefixGenerators) {
398
+ arrayFormat = opts.arrayFormat;
399
+ } else if (opts && "indices" in opts) {
400
+ arrayFormat = opts.indices ? "indices" : "repeat";
401
+ } else {
402
+ arrayFormat = "indices";
403
+ }
404
+ var generateArrayPrefix = arrayPrefixGenerators[arrayFormat];
405
+ if (opts && "commaRoundTrip" in opts && typeof opts.commaRoundTrip !== "boolean") {
406
+ throw new TypeError("`commaRoundTrip` must be a boolean, or absent");
407
+ }
408
+ var commaRoundTrip = generateArrayPrefix === "comma" && opts && opts.commaRoundTrip;
409
+ if (!objKeys) {
410
+ objKeys = Object.keys(obj);
411
+ }
412
+ if (options.sort) {
413
+ objKeys.sort(options.sort);
414
+ }
415
+ var sideChannel2 = getSideChannel();
416
+ for (var i = 0; i < objKeys.length; ++i) {
417
+ var key = objKeys[i];
418
+ if (options.skipNulls && obj[key] === null) {
419
+ continue;
420
+ }
421
+ pushToArray(keys, stringify$1(obj[key], key, generateArrayPrefix, commaRoundTrip, options.strictNullHandling, options.skipNulls, options.encode ? options.encoder : null, options.filter, options.sort, options.allowDots, options.serializeDate, options.format, options.formatter, options.encodeValuesOnly, options.charset, sideChannel2));
422
+ }
423
+ var joined = keys.join(options.delimiter);
424
+ var prefix = options.addQueryPrefix === true ? "?" : "";
425
+ if (options.charsetSentinel) {
426
+ if (options.charset === "iso-8859-1") {
427
+ prefix += "utf8=%26%2310003%3B&";
428
+ } else {
429
+ prefix += "utf8=%E2%9C%93&";
430
+ }
431
+ }
432
+ return joined.length > 0 ? prefix + joined : "";
433
+ };
434
+ var utils = utils$2;
435
+ var has = Object.prototype.hasOwnProperty;
436
+ var isArray = Array.isArray;
437
+ var defaults = {
438
+ allowDots: false,
439
+ allowPrototypes: false,
440
+ allowSparse: false,
441
+ arrayLimit: 20,
442
+ charset: "utf-8",
443
+ charsetSentinel: false,
444
+ comma: false,
445
+ decoder: utils.decode,
446
+ delimiter: "&",
447
+ depth: 5,
448
+ ignoreQueryPrefix: false,
449
+ interpretNumericEntities: false,
450
+ parameterLimit: 1e3,
451
+ parseArrays: true,
452
+ plainObjects: false,
453
+ strictNullHandling: false
454
+ };
455
+ var interpretNumericEntities = function(str) {
456
+ return str.replace(/&#(\d+);/g, function($0, numberStr) {
457
+ return String.fromCharCode(parseInt(numberStr, 10));
458
+ });
459
+ };
460
+ var parseArrayValue = function(val, options) {
461
+ if (val && typeof val === "string" && options.comma && val.indexOf(",") > -1) {
462
+ return val.split(",");
463
+ }
464
+ return val;
465
+ };
466
+ var isoSentinel = "utf8=%26%2310003%3B";
467
+ var charsetSentinel = "utf8=%E2%9C%93";
468
+ var parseValues = function parseQueryStringValues(str, options) {
469
+ var obj = {};
470
+ var cleanStr = options.ignoreQueryPrefix ? str.replace(/^\?/, "") : str;
471
+ var limit = options.parameterLimit === Infinity ? void 0 : options.parameterLimit;
472
+ var parts = cleanStr.split(options.delimiter, limit);
473
+ var skipIndex = -1;
474
+ var i;
475
+ var charset = options.charset;
476
+ if (options.charsetSentinel) {
477
+ for (i = 0; i < parts.length; ++i) {
478
+ if (parts[i].indexOf("utf8=") === 0) {
479
+ if (parts[i] === charsetSentinel) {
480
+ charset = "utf-8";
481
+ } else if (parts[i] === isoSentinel) {
482
+ charset = "iso-8859-1";
483
+ }
484
+ skipIndex = i;
485
+ i = parts.length;
486
+ }
487
+ }
488
+ }
489
+ for (i = 0; i < parts.length; ++i) {
490
+ if (i === skipIndex) {
491
+ continue;
492
+ }
493
+ var part = parts[i];
494
+ var bracketEqualsPos = part.indexOf("]=");
495
+ var pos = bracketEqualsPos === -1 ? part.indexOf("=") : bracketEqualsPos + 1;
496
+ var key, val;
497
+ if (pos === -1) {
498
+ key = options.decoder(part, defaults.decoder, charset, "key");
499
+ val = options.strictNullHandling ? null : "";
500
+ } else {
501
+ key = options.decoder(part.slice(0, pos), defaults.decoder, charset, "key");
502
+ val = utils.maybeMap(parseArrayValue(part.slice(pos + 1), options), function(encodedVal) {
503
+ return options.decoder(encodedVal, defaults.decoder, charset, "value");
504
+ });
505
+ }
506
+ if (val && options.interpretNumericEntities && charset === "iso-8859-1") {
507
+ val = interpretNumericEntities(val);
508
+ }
509
+ if (part.indexOf("[]=") > -1) {
510
+ val = isArray(val) ? [val] : val;
511
+ }
512
+ if (has.call(obj, key)) {
513
+ obj[key] = utils.combine(obj[key], val);
514
+ } else {
515
+ obj[key] = val;
516
+ }
517
+ }
518
+ return obj;
519
+ };
520
+ var parseObject = function(chain, val, options, valuesParsed) {
521
+ var leaf = valuesParsed ? val : parseArrayValue(val, options);
522
+ for (var i = chain.length - 1; i >= 0; --i) {
523
+ var obj;
524
+ var root = chain[i];
525
+ if (root === "[]" && options.parseArrays) {
526
+ obj = [].concat(leaf);
527
+ } else {
528
+ obj = options.plainObjects ? /* @__PURE__ */ Object.create(null) : {};
529
+ var cleanRoot = root.charAt(0) === "[" && root.charAt(root.length - 1) === "]" ? root.slice(1, -1) : root;
530
+ var index = parseInt(cleanRoot, 10);
531
+ if (!options.parseArrays && cleanRoot === "") {
532
+ obj = { 0: leaf };
533
+ } else if (!isNaN(index) && root !== cleanRoot && String(index) === cleanRoot && index >= 0 && (options.parseArrays && index <= options.arrayLimit)) {
534
+ obj = [];
535
+ obj[index] = leaf;
536
+ } else if (cleanRoot !== "__proto__") {
537
+ obj[cleanRoot] = leaf;
538
+ }
539
+ }
540
+ leaf = obj;
541
+ }
542
+ return leaf;
543
+ };
544
+ var parseKeys = function parseQueryStringKeys(givenKey, val, options, valuesParsed) {
545
+ if (!givenKey) {
546
+ return;
547
+ }
548
+ var key = options.allowDots ? givenKey.replace(/\.([^.[]+)/g, "[$1]") : givenKey;
549
+ var brackets2 = /(\[[^[\]]*])/;
550
+ var child = /(\[[^[\]]*])/g;
551
+ var segment = options.depth > 0 && brackets2.exec(key);
552
+ var parent = segment ? key.slice(0, segment.index) : key;
553
+ var keys = [];
554
+ if (parent) {
555
+ if (!options.plainObjects && has.call(Object.prototype, parent)) {
556
+ if (!options.allowPrototypes) {
557
+ return;
558
+ }
559
+ }
560
+ keys.push(parent);
561
+ }
562
+ var i = 0;
563
+ while (options.depth > 0 && (segment = child.exec(key)) !== null && i < options.depth) {
564
+ i += 1;
565
+ if (!options.plainObjects && has.call(Object.prototype, segment[1].slice(1, -1))) {
566
+ if (!options.allowPrototypes) {
567
+ return;
568
+ }
569
+ }
570
+ keys.push(segment[1]);
571
+ }
572
+ if (segment) {
573
+ keys.push("[" + key.slice(segment.index) + "]");
574
+ }
575
+ return parseObject(keys, val, options, valuesParsed);
576
+ };
577
+ var normalizeParseOptions = function normalizeParseOptions2(opts) {
578
+ if (!opts) {
579
+ return defaults;
580
+ }
581
+ if (opts.decoder !== null && opts.decoder !== void 0 && typeof opts.decoder !== "function") {
582
+ throw new TypeError("Decoder has to be a function.");
583
+ }
584
+ if (typeof opts.charset !== "undefined" && opts.charset !== "utf-8" && opts.charset !== "iso-8859-1") {
585
+ throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");
586
+ }
587
+ var charset = typeof opts.charset === "undefined" ? defaults.charset : opts.charset;
588
+ return {
589
+ allowDots: typeof opts.allowDots === "undefined" ? defaults.allowDots : !!opts.allowDots,
590
+ allowPrototypes: typeof opts.allowPrototypes === "boolean" ? opts.allowPrototypes : defaults.allowPrototypes,
591
+ allowSparse: typeof opts.allowSparse === "boolean" ? opts.allowSparse : defaults.allowSparse,
592
+ arrayLimit: typeof opts.arrayLimit === "number" ? opts.arrayLimit : defaults.arrayLimit,
593
+ charset,
594
+ charsetSentinel: typeof opts.charsetSentinel === "boolean" ? opts.charsetSentinel : defaults.charsetSentinel,
595
+ comma: typeof opts.comma === "boolean" ? opts.comma : defaults.comma,
596
+ decoder: typeof opts.decoder === "function" ? opts.decoder : defaults.decoder,
597
+ delimiter: typeof opts.delimiter === "string" || utils.isRegExp(opts.delimiter) ? opts.delimiter : defaults.delimiter,
598
+ depth: typeof opts.depth === "number" || opts.depth === false ? +opts.depth : defaults.depth,
599
+ ignoreQueryPrefix: opts.ignoreQueryPrefix === true,
600
+ interpretNumericEntities: typeof opts.interpretNumericEntities === "boolean" ? opts.interpretNumericEntities : defaults.interpretNumericEntities,
601
+ parameterLimit: typeof opts.parameterLimit === "number" ? opts.parameterLimit : defaults.parameterLimit,
602
+ parseArrays: opts.parseArrays !== false,
603
+ plainObjects: typeof opts.plainObjects === "boolean" ? opts.plainObjects : defaults.plainObjects,
604
+ strictNullHandling: typeof opts.strictNullHandling === "boolean" ? opts.strictNullHandling : defaults.strictNullHandling
605
+ };
606
+ };
607
+ var parse$1 = function(str, opts) {
608
+ var options = normalizeParseOptions(opts);
609
+ if (str === "" || str === null || typeof str === "undefined") {
610
+ return options.plainObjects ? /* @__PURE__ */ Object.create(null) : {};
611
+ }
612
+ var tempObj = typeof str === "string" ? parseValues(str, options) : str;
613
+ var obj = options.plainObjects ? /* @__PURE__ */ Object.create(null) : {};
614
+ var keys = Object.keys(tempObj);
615
+ for (var i = 0; i < keys.length; ++i) {
616
+ var key = keys[i];
617
+ var newObj = parseKeys(key, tempObj[key], options, typeof str === "string");
618
+ obj = utils.merge(obj, newObj, options);
619
+ }
620
+ if (options.allowSparse === true) {
621
+ return obj;
622
+ }
623
+ return utils.compact(obj);
624
+ };
625
+ var stringify2 = stringify_1;
626
+ var parse = parse$1;
627
+ var formats = formats$3;
628
+ var lib = {
629
+ formats,
630
+ parse,
631
+ stringify: stringify2
632
+ };
633
+ export { lib as l };