opusdev/vector-similarity-api
1
1/*! Axios v1.13.5 Copyright (c) 2026 Matt Zabriskie and contributors */2/**3 * Create a bound version of a function with a specified `this` context4 *5 * @param {Function} fn - The function to bind6 * @param {*} thisArg - The value to be passed as the `this` parameter7 * @returns {Function} A new function that will call the original function with the specified `this` context8 */9function bind(fn, thisArg) {10 return function wrap() {11 return fn.apply(thisArg, arguments);12 };13}14 15// utils is a library of generic helper functions non-specific to axios16 17const { toString } = Object.prototype;18const { getPrototypeOf } = Object;19const { iterator, toStringTag } = Symbol;20 21const kindOf = ((cache) => (thing) => {22 const str = toString.call(thing);23 return cache[str] || (cache[str] = str.slice(8, -1).toLowerCase());24})(Object.create(null));25 26const kindOfTest = (type) => {27 type = type.toLowerCase();28 return (thing) => kindOf(thing) === type;29};30 31const typeOfTest = (type) => (thing) => typeof thing === type;32 33/**34 * Determine if a value is a non-null object35 *36 * @param {Object} val The value to test37 *38 * @returns {boolean} True if value is an Array, otherwise false39 */40const { isArray } = Array;41 42/**43 * Determine if a value is undefined44 *45 * @param {*} val The value to test46 *47 * @returns {boolean} True if the value is undefined, otherwise false48 */49const isUndefined = typeOfTest("undefined");50 51/**52 * Determine if a value is a Buffer53 *54 * @param {*} val The value to test55 *56 * @returns {boolean} True if value is a Buffer, otherwise false57 */58function isBuffer(val) {59 return (60 val !== null &&61 !isUndefined(val) &&62 val.constructor !== null &&63 !isUndefined(val.constructor) &&64 isFunction$1(val.constructor.isBuffer) &&65 val.constructor.isBuffer(val)66 );67}68 69/**70 * Determine if a value is an ArrayBuffer71 *72 * @param {*} val The value to test73 *74 * @returns {boolean} True if value is an ArrayBuffer, otherwise false75 */76const isArrayBuffer = kindOfTest("ArrayBuffer");77 78/**79 * Determine if a value is a view on an ArrayBuffer80 *81 * @param {*} val The value to test82 *83 * @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false84 */85function isArrayBufferView(val) {86 let result;87 if (typeof ArrayBuffer !== "undefined" && ArrayBuffer.isView) {88 result = ArrayBuffer.isView(val);89 } else {90 result = val && val.buffer && isArrayBuffer(val.buffer);91 }92 return result;93}94 95/**96 * Determine if a value is a String97 *98 * @param {*} val The value to test99 *100 * @returns {boolean} True if value is a String, otherwise false101 */102const isString = typeOfTest("string");103 104/**105 * Determine if a value is a Function106 *107 * @param {*} val The value to test108 * @returns {boolean} True if value is a Function, otherwise false109 */110const isFunction$1 = typeOfTest("function");111 112/**113 * Determine if a value is a Number114 *115 * @param {*} val The value to test116 *117 * @returns {boolean} True if value is a Number, otherwise false118 */119const isNumber = typeOfTest("number");120 121/**122 * Determine if a value is an Object123 *124 * @param {*} thing The value to test125 *126 * @returns {boolean} True if value is an Object, otherwise false127 */128const isObject = (thing) => thing !== null && typeof thing === "object";129 130/**131 * Determine if a value is a Boolean132 *133 * @param {*} thing The value to test134 * @returns {boolean} True if value is a Boolean, otherwise false135 */136const isBoolean = (thing) => thing === true || thing === false;137 138/**139 * Determine if a value is a plain Object140 *141 * @param {*} val The value to test142 *143 * @returns {boolean} True if value is a plain Object, otherwise false144 */145const isPlainObject = (val) => {146 if (kindOf(val) !== "object") {147 return false;148 }149 150 const prototype = getPrototypeOf(val);151 return (152 (prototype === null ||153 prototype === Object.prototype ||154 Object.getPrototypeOf(prototype) === null) &&155 !(toStringTag in val) &&156 !(iterator in val)157 );158};159 160/**161 * Determine if a value is an empty object (safely handles Buffers)162 *163 * @param {*} val The value to test164 *165 * @returns {boolean} True if value is an empty object, otherwise false166 */167const isEmptyObject = (val) => {168 // Early return for non-objects or Buffers to prevent RangeError169 if (!isObject(val) || isBuffer(val)) {170 return false;171 }172 173 try {174 return (175 Object.keys(val).length === 0 &&176 Object.getPrototypeOf(val) === Object.prototype177 );178 } catch (e) {179 // Fallback for any other objects that might cause RangeError with Object.keys()180 return false;181 }182};183 184/**185 * Determine if a value is a Date186 *187 * @param {*} val The value to test188 *189 * @returns {boolean} True if value is a Date, otherwise false190 */191const isDate = kindOfTest("Date");192 193/**194 * Determine if a value is a File195 *196 * @param {*} val The value to test197 *198 * @returns {boolean} True if value is a File, otherwise false199 */200const isFile = kindOfTest("File");201 202/**203 * Determine if a value is a Blob204 *205 * @param {*} val The value to test206 *207 * @returns {boolean} True if value is a Blob, otherwise false208 */209const isBlob = kindOfTest("Blob");210 211/**212 * Determine if a value is a FileList213 *214 * @param {*} val The value to test215 *216 * @returns {boolean} True if value is a File, otherwise false217 */218const isFileList = kindOfTest("FileList");219 220/**221 * Determine if a value is a Stream222 *223 * @param {*} val The value to test224 *225 * @returns {boolean} True if value is a Stream, otherwise false226 */227const isStream = (val) => isObject(val) && isFunction$1(val.pipe);228 229/**230 * Determine if a value is a FormData231 *232 * @param {*} thing The value to test233 *234 * @returns {boolean} True if value is an FormData, otherwise false235 */236const isFormData = (thing) => {237 let kind;238 return (239 thing &&240 ((typeof FormData === "function" && thing instanceof FormData) ||241 (isFunction$1(thing.append) &&242 ((kind = kindOf(thing)) === "formdata" ||243 // detect form-data instance244 (kind === "object" &&245 isFunction$1(thing.toString) &&246 thing.toString() === "[object FormData]"))))247 );248};249 250/**251 * Determine if a value is a URLSearchParams object252 *253 * @param {*} val The value to test254 *255 * @returns {boolean} True if value is a URLSearchParams object, otherwise false256 */257const isURLSearchParams = kindOfTest("URLSearchParams");258 259const [isReadableStream, isRequest, isResponse, isHeaders] = [260 "ReadableStream",261 "Request",262 "Response",263 "Headers",264].map(kindOfTest);265 266/**267 * Trim excess whitespace off the beginning and end of a string268 *269 * @param {String} str The String to trim270 *271 * @returns {String} The String freed of excess whitespace272 */273const trim = (str) =>274 str.trim ? str.trim() : str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, "");275 276/**277 * Iterate over an Array or an Object invoking a function for each item.278 *279 * If `obj` is an Array callback will be called passing280 * the value, index, and complete array for each item.281 *282 * If 'obj' is an Object callback will be called passing283 * the value, key, and complete object for each property.284 *285 * @param {Object|Array<unknown>} obj The object to iterate286 * @param {Function} fn The callback to invoke for each item287 *288 * @param {Object} [options]289 * @param {Boolean} [options.allOwnKeys = false]290 * @returns {any}291 */292function forEach(obj, fn, { allOwnKeys = false } = {}) {293 // Don't bother if no value provided294 if (obj === null || typeof obj === "undefined") {295 return;296 }297 298 let i;299 let l;300 301 // Force an array if not already something iterable302 if (typeof obj !== "object") {303 /*eslint no-param-reassign:0*/304 obj = [obj];305 }306 307 if (isArray(obj)) {308 // Iterate over array values309 for (i = 0, l = obj.length; i < l; i++) {310 fn.call(null, obj[i], i, obj);311 }312 } else {313 // Buffer check314 if (isBuffer(obj)) {315 return;316 }317 318 // Iterate over object keys319 const keys = allOwnKeys320 ? Object.getOwnPropertyNames(obj)321 : Object.keys(obj);322 const len = keys.length;323 let key;324 325 for (i = 0; i < len; i++) {326 key = keys[i];327 fn.call(null, obj[key], key, obj);328 }329 }330}331 332function findKey(obj, key) {333 if (isBuffer(obj)) {334 return null;335 }336 337 key = key.toLowerCase();338 const keys = Object.keys(obj);339 let i = keys.length;340 let _key;341 while (i-- > 0) {342 _key = keys[i];343 if (key === _key.toLowerCase()) {344 return _key;345 }346 }347 return null;348}349 350const _global = (() => {351 /*eslint no-undef:0*/352 if (typeof globalThis !== "undefined") return globalThis;353 return typeof self !== "undefined"354 ? self355 : typeof window !== "undefined"356 ? window357 : global;358})();359 360const isContextDefined = (context) =>361 !isUndefined(context) && context !== _global;362 363/**364 * Accepts varargs expecting each argument to be an object, then365 * immutably merges the properties of each object and returns result.366 *367 * When multiple objects contain the same key the later object in368 * the arguments list will take precedence.369 *370 * Example:371 *372 * ```js373 * const result = merge({foo: 123}, {foo: 456});374 * console.log(result.foo); // outputs 456375 * ```376 *377 * @param {Object} obj1 Object to merge378 *379 * @returns {Object} Result of all merge properties380 */381function merge(/* obj1, obj2, obj3, ... */) {382 const { caseless, skipUndefined } = (isContextDefined(this) && this) || {};383 const result = {};384 const assignValue = (val, key) => {385 // Skip dangerous property names to prevent prototype pollution386 if (key === "__proto__" || key === "constructor" || key === "prototype") {387 return;388 }389 390 const targetKey = (caseless && findKey(result, key)) || key;391 if (isPlainObject(result[targetKey]) && isPlainObject(val)) {392 result[targetKey] = merge(result[targetKey], val);393 } else if (isPlainObject(val)) {394 result[targetKey] = merge({}, val);395 } else if (isArray(val)) {396 result[targetKey] = val.slice();397 } else if (!skipUndefined || !isUndefined(val)) {398 result[targetKey] = val;399 }400 };401 402 for (let i = 0, l = arguments.length; i < l; i++) {403 arguments[i] && forEach(arguments[i], assignValue);404 }405 return result;406}407 408/**409 * Extends object a by mutably adding to it the properties of object b.410 *411 * @param {Object} a The object to be extended412 * @param {Object} b The object to copy properties from413 * @param {Object} thisArg The object to bind function to414 *415 * @param {Object} [options]416 * @param {Boolean} [options.allOwnKeys]417 * @returns {Object} The resulting value of object a418 */419const extend = (a, b, thisArg, { allOwnKeys } = {}) => {420 forEach(421 b,422 (val, key) => {423 if (thisArg && isFunction$1(val)) {424 Object.defineProperty(a, key, {425 value: bind(val, thisArg),426 writable: true,427 enumerable: true,428 configurable: true,429 });430 } else {431 Object.defineProperty(a, key, {432 value: val,433 writable: true,434 enumerable: true,435 configurable: true,436 });437 }438 },439 { allOwnKeys },440 );441 return a;442};443 444/**445 * Remove byte order marker. This catches EF BB BF (the UTF-8 BOM)446 *447 * @param {string} content with BOM448 *449 * @returns {string} content value without BOM450 */451const stripBOM = (content) => {452 if (content.charCodeAt(0) === 0xfeff) {453 content = content.slice(1);454 }455 return content;456};457 458/**459 * Inherit the prototype methods from one constructor into another460 * @param {function} constructor461 * @param {function} superConstructor462 * @param {object} [props]463 * @param {object} [descriptors]464 *465 * @returns {void}466 */467const inherits = (constructor, superConstructor, props, descriptors) => {468 constructor.prototype = Object.create(469 superConstructor.prototype,470 descriptors,471 );472 Object.defineProperty(constructor.prototype, "constructor", {473 value: constructor,474 writable: true,475 enumerable: false,476 configurable: true,477 });478 Object.defineProperty(constructor, "super", {479 value: superConstructor.prototype,480 });481 props && Object.assign(constructor.prototype, props);482};483 484/**485 * Resolve object with deep prototype chain to a flat object486 * @param {Object} sourceObj source object487 * @param {Object} [destObj]488 * @param {Function|Boolean} [filter]489 * @param {Function} [propFilter]490 *491 * @returns {Object}492 */493const toFlatObject = (sourceObj, destObj, filter, propFilter) => {494 let props;495 let i;496 let prop;497 const merged = {};498 499 destObj = destObj || {};500 // eslint-disable-next-line no-eq-null,eqeqeq501 if (sourceObj == null) return destObj;502 503 do {504 props = Object.getOwnPropertyNames(sourceObj);505 i = props.length;506 while (i-- > 0) {507 prop = props[i];508 if (509 (!propFilter || propFilter(prop, sourceObj, destObj)) &&510 !merged[prop]511 ) {512 destObj[prop] = sourceObj[prop];513 merged[prop] = true;514 }515 }516 sourceObj = filter !== false && getPrototypeOf(sourceObj);517 } while (518 sourceObj &&519 (!filter || filter(sourceObj, destObj)) &&520 sourceObj !== Object.prototype521 );522 523 return destObj;524};525 526/**527 * Determines whether a string ends with the characters of a specified string528 *529 * @param {String} str530 * @param {String} searchString531 * @param {Number} [position= 0]532 *533 * @returns {boolean}534 */535const endsWith = (str, searchString, position) => {536 str = String(str);537 if (position === undefined || position > str.length) {538 position = str.length;539 }540 position -= searchString.length;541 const lastIndex = str.indexOf(searchString, position);542 return lastIndex !== -1 && lastIndex === position;543};544 545/**546 * Returns new array from array like object or null if failed547 *548 * @param {*} [thing]549 *550 * @returns {?Array}551 */552const toArray = (thing) => {553 if (!thing) return null;554 if (isArray(thing)) return thing;555 let i = thing.length;556 if (!isNumber(i)) return null;557 const arr = new Array(i);558 while (i-- > 0) {559 arr[i] = thing[i];560 }561 return arr;562};563 564/**565 * Checking if the Uint8Array exists and if it does, it returns a function that checks if the566 * thing passed in is an instance of Uint8Array567 *568 * @param {TypedArray}569 *570 * @returns {Array}571 */572// eslint-disable-next-line func-names573const isTypedArray = ((TypedArray) => {574 // eslint-disable-next-line func-names575 return (thing) => {576 return TypedArray && thing instanceof TypedArray;577 };578})(typeof Uint8Array !== "undefined" && getPrototypeOf(Uint8Array));579 580/**581 * For each entry in the object, call the function with the key and value.582 *583 * @param {Object<any, any>} obj - The object to iterate over.584 * @param {Function} fn - The function to call for each entry.585 *586 * @returns {void}587 */588const forEachEntry = (obj, fn) => {589 const generator = obj && obj[iterator];590 591 const _iterator = generator.call(obj);592 593 let result;594 595 while ((result = _iterator.next()) && !result.done) {596 const pair = result.value;597 fn.call(obj, pair[0], pair[1]);598 }599};600 601/**602 * It takes a regular expression and a string, and returns an array of all the matches603 *604 * @param {string} regExp - The regular expression to match against.605 * @param {string} str - The string to search.606 *607 * @returns {Array<boolean>}608 */609const matchAll = (regExp, str) => {610 let matches;611 const arr = [];612 613 while ((matches = regExp.exec(str)) !== null) {614 arr.push(matches);615 }616 617 return arr;618};619 620/* Checking if the kindOfTest function returns true when passed an HTMLFormElement. */621const isHTMLForm = kindOfTest("HTMLFormElement");622 623const toCamelCase = (str) => {624 return str625 .toLowerCase()626 .replace(/[-_\s]([a-z\d])(\w*)/g, function replacer(m, p1, p2) {627 return p1.toUpperCase() + p2;628 });629};630 631/* Creating a function that will check if an object has a property. */632const hasOwnProperty = (633 ({ hasOwnProperty }) =>634 (obj, prop) =>635 hasOwnProperty.call(obj, prop)636)(Object.prototype);637 638/**639 * Determine if a value is a RegExp object640 *641 * @param {*} val The value to test642 *643 * @returns {boolean} True if value is a RegExp object, otherwise false644 */645const isRegExp = kindOfTest("RegExp");646 647const reduceDescriptors = (obj, reducer) => {648 const descriptors = Object.getOwnPropertyDescriptors(obj);649 const reducedDescriptors = {};650 651 forEach(descriptors, (descriptor, name) => {652 let ret;653 if ((ret = reducer(descriptor, name, obj)) !== false) {654 reducedDescriptors[name] = ret || descriptor;655 }656 });657 658 Object.defineProperties(obj, reducedDescriptors);659};660 661/**662 * Makes all methods read-only663 * @param {Object} obj664 */665 666const freezeMethods = (obj) => {667 reduceDescriptors(obj, (descriptor, name) => {668 // skip restricted props in strict mode669 if (670 isFunction$1(obj) &&671 ["arguments", "caller", "callee"].indexOf(name) !== -1672 ) {673 return false;674 }675 676 const value = obj[name];677 678 if (!isFunction$1(value)) return;679 680 descriptor.enumerable = false;681 682 if ("writable" in descriptor) {683 descriptor.writable = false;684 return;685 }686 687 if (!descriptor.set) {688 descriptor.set = () => {689 throw Error("Can not rewrite read-only method '" + name + "'");690 };691 }692 });693};694 695const toObjectSet = (arrayOrString, delimiter) => {696 const obj = {};697 698 const define = (arr) => {699 arr.forEach((value) => {700 obj[value] = true;701 });702 };703 704 isArray(arrayOrString)705 ? define(arrayOrString)706 : define(String(arrayOrString).split(delimiter));707 708 return obj;709};710 711const noop = () => {};712 713const toFiniteNumber = (value, defaultValue) => {714 return value != null && Number.isFinite((value = +value))715 ? value716 : defaultValue;717};718 719/**720 * If the thing is a FormData object, return true, otherwise return false.721 *722 * @param {unknown} thing - The thing to check.723 *724 * @returns {boolean}725 */726function isSpecCompliantForm(thing) {727 return !!(728 thing &&729 isFunction$1(thing.append) &&730 thing[toStringTag] === "FormData" &&731 thing[iterator]732 );733}734 735const toJSONObject = (obj) => {736 const stack = new Array(10);737 738 const visit = (source, i) => {739 if (isObject(source)) {740 if (stack.indexOf(source) >= 0) {741 return;742 }743 744 //Buffer check745 if (isBuffer(source)) {746 return source;747 }748 749 if (!("toJSON" in source)) {750 stack[i] = source;751 const target = isArray(source) ? [] : {};752 753 forEach(source, (value, key) => {754 const reducedValue = visit(value, i + 1);755 !isUndefined(reducedValue) && (target[key] = reducedValue);756 });757 758 stack[i] = undefined;759 760 return target;761 }762 }763 764 return source;765 };766 767 return visit(obj, 0);768};769 770const isAsyncFn = kindOfTest("AsyncFunction");771 772const isThenable = (thing) =>773 thing &&774 (isObject(thing) || isFunction$1(thing)) &&775 isFunction$1(thing.then) &&776 isFunction$1(thing.catch);777 778// original code779// https://github.com/DigitalBrainJS/AxiosPromise/blob/16deab13710ec09779922131f3fa5954320f83ab/lib/utils.js#L11-L34780 781const _setImmediate = ((setImmediateSupported, postMessageSupported) => {782 if (setImmediateSupported) {783 return setImmediate;784 }785 786 return postMessageSupported787 ? ((token, callbacks) => {788 _global.addEventListener(789 "message",790 ({ source, data }) => {791 if (source === _global && data === token) {792 callbacks.length && callbacks.shift()();793 }794 },795 false,796 );797 798 return (cb) => {799 callbacks.push(cb);800 _global.postMessage(token, "*");801 };802 })(`axios@${Math.random()}`, [])803 : (cb) => setTimeout(cb);804})(typeof setImmediate === "function", isFunction$1(_global.postMessage));805 806const asap =807 typeof queueMicrotask !== "undefined"808 ? queueMicrotask.bind(_global)809 : (typeof process !== "undefined" && process.nextTick) || _setImmediate;810 811// *********************812 813const isIterable = (thing) => thing != null && isFunction$1(thing[iterator]);814 815const utils$1 = {816 isArray,817 isArrayBuffer,818 isBuffer,819 isFormData,820 isArrayBufferView,821 isString,822 isNumber,823 isBoolean,824 isObject,825 isPlainObject,826 isEmptyObject,827 isReadableStream,828 isRequest,829 isResponse,830 isHeaders,831 isUndefined,832 isDate,833 isFile,834 isBlob,835 isRegExp,836 isFunction: isFunction$1,837 isStream,838 isURLSearchParams,839 isTypedArray,840 isFileList,841 forEach,842 merge,843 extend,844 trim,845 stripBOM,846 inherits,847 toFlatObject,848 kindOf,849 kindOfTest,850 endsWith,851 toArray,852 forEachEntry,853 matchAll,854 isHTMLForm,855 hasOwnProperty,856 hasOwnProp: hasOwnProperty, // an alias to avoid ESLint no-prototype-builtins detection857 reduceDescriptors,858 freezeMethods,859 toObjectSet,860 toCamelCase,861 noop,862 toFiniteNumber,863 findKey,864 global: _global,865 isContextDefined,866 isSpecCompliantForm,867 toJSONObject,868 isAsyncFn,869 isThenable,870 setImmediate: _setImmediate,871 asap,872 isIterable,873};874 875class AxiosError$1 extends Error {876 static from(error, code, config, request, response, customProps) {877 const axiosError = new AxiosError$1(error.message, code || error.code, config, request, response);878 axiosError.cause = error;879 axiosError.name = error.name;880 customProps && Object.assign(axiosError, customProps);881 return axiosError;882 }883 884 /**885 * Create an Error with the specified message, config, error code, request and response.886 *887 * @param {string} message The error message.888 * @param {string} [code] The error code (for example, 'ECONNABORTED').889 * @param {Object} [config] The config.890 * @param {Object} [request] The request.891 * @param {Object} [response] The response.892 *893 * @returns {Error} The created error.894 */895 constructor(message, code, config, request, response) {896 super(message);897 this.name = 'AxiosError';898 this.isAxiosError = true;899 code && (this.code = code);900 config && (this.config = config);901 request && (this.request = request);902 if (response) {903 this.response = response;904 this.status = response.status;905 }906 }907 908 toJSON() {909 return {910 // Standard911 message: this.message,912 name: this.name,913 // Microsoft914 description: this.description,915 number: this.number,916 // Mozilla917 fileName: this.fileName,918 lineNumber: this.lineNumber,919 columnNumber: this.columnNumber,920 stack: this.stack,921 // Axios922 config: utils$1.toJSONObject(this.config),923 code: this.code,924 status: this.status,925 };926 }927}928 929// This can be changed to static properties as soon as the parser options in .eslint.cjs are updated.930AxiosError$1.ERR_BAD_OPTION_VALUE = 'ERR_BAD_OPTION_VALUE';931AxiosError$1.ERR_BAD_OPTION = 'ERR_BAD_OPTION';932AxiosError$1.ECONNABORTED = 'ECONNABORTED';933AxiosError$1.ETIMEDOUT = 'ETIMEDOUT';934AxiosError$1.ERR_NETWORK = 'ERR_NETWORK';935AxiosError$1.ERR_FR_TOO_MANY_REDIRECTS = 'ERR_FR_TOO_MANY_REDIRECTS';936AxiosError$1.ERR_DEPRECATED = 'ERR_DEPRECATED';937AxiosError$1.ERR_BAD_RESPONSE = 'ERR_BAD_RESPONSE';938AxiosError$1.ERR_BAD_REQUEST = 'ERR_BAD_REQUEST';939AxiosError$1.ERR_CANCELED = 'ERR_CANCELED';940AxiosError$1.ERR_NOT_SUPPORT = 'ERR_NOT_SUPPORT';941AxiosError$1.ERR_INVALID_URL = 'ERR_INVALID_URL';942 943const AxiosError$2 = AxiosError$1;944 945// eslint-disable-next-line strict946const httpAdapter = null;947 948/**949 * Determines if the given thing is a array or js object.950 *951 * @param {string} thing - The object or array to be visited.952 *953 * @returns {boolean}954 */955function isVisitable(thing) {956 return utils$1.isPlainObject(thing) || utils$1.isArray(thing);957}958 959/**960 * It removes the brackets from the end of a string961 *962 * @param {string} key - The key of the parameter.963 *964 * @returns {string} the key without the brackets.965 */966function removeBrackets(key) {967 return utils$1.endsWith(key, '[]') ? key.slice(0, -2) : key;968}969 970/**971 * It takes a path, a key, and a boolean, and returns a string972 *973 * @param {string} path - The path to the current key.974 * @param {string} key - The key of the current object being iterated over.975 * @param {string} dots - If true, the key will be rendered with dots instead of brackets.976 *977 * @returns {string} The path to the current key.978 */979function renderKey(path, key, dots) {980 if (!path) return key;981 return path.concat(key).map(function each(token, i) {982 // eslint-disable-next-line no-param-reassign983 token = removeBrackets(token);984 return !dots && i ? '[' + token + ']' : token;985 }).join(dots ? '.' : '');986}987 988/**989 * If the array is an array and none of its elements are visitable, then it's a flat array.990 *991 * @param {Array<any>} arr - The array to check992 *993 * @returns {boolean}994 */995function isFlatArray(arr) {996 return utils$1.isArray(arr) && !arr.some(isVisitable);997}998 999const predicates = utils$1.toFlatObject(utils$1, {}, null, function filter(prop) {1000 return /^is[A-Z]/.test(prop);1001});1002 1003/**1004 * Convert a data object to FormData1005 *1006 * @param {Object} obj1007 * @param {?Object} [formData]1008 * @param {?Object} [options]1009 * @param {Function} [options.visitor]1010 * @param {Boolean} [options.metaTokens = true]1011 * @param {Boolean} [options.dots = false]1012 * @param {?Boolean} [options.indexes = false]1013 *1014 * @returns {Object}1015 **/1016 1017/**1018 * It converts an object into a FormData object1019 *1020 * @param {Object<any, any>} obj - The object to convert to form data.1021 * @param {string} formData - The FormData object to append to.1022 * @param {Object<string, any>} options1023 *1024 * @returns1025 */1026function toFormData$1(obj, formData, options) {1027 if (!utils$1.isObject(obj)) {1028 throw new TypeError('target must be an object');1029 }1030 1031 // eslint-disable-next-line no-param-reassign1032 formData = formData || new (FormData)();1033 1034 // eslint-disable-next-line no-param-reassign1035 options = utils$1.toFlatObject(options, {1036 metaTokens: true,1037 dots: false,1038 indexes: false1039 }, false, function defined(option, source) {1040 // eslint-disable-next-line no-eq-null,eqeqeq1041 return !utils$1.isUndefined(source[option]);1042 });1043 1044 const metaTokens = options.metaTokens;1045 // eslint-disable-next-line no-use-before-define1046 const visitor = options.visitor || defaultVisitor;1047 const dots = options.dots;1048 const indexes = options.indexes;1049 const _Blob = options.Blob || typeof Blob !== 'undefined' && Blob;1050 const useBlob = _Blob && utils$1.isSpecCompliantForm(formData);1051 1052 if (!utils$1.isFunction(visitor)) {1053 throw new TypeError('visitor must be a function');1054 }1055 1056 function convertValue(value) {1057 if (value === null) return '';1058 1059 if (utils$1.isDate(value)) {1060 return value.toISOString();1061 }1062 1063 if (utils$1.isBoolean(value)) {1064 return value.toString();1065 }1066 1067 if (!useBlob && utils$1.isBlob(value)) {1068 throw new AxiosError$2('Blob is not supported. Use a Buffer instead.');1069 }1070 1071 if (utils$1.isArrayBuffer(value) || utils$1.isTypedArray(value)) {1072 return useBlob && typeof Blob === 'function' ? new Blob([value]) : Buffer.from(value);1073 }1074 1075 return value;1076 }1077 1078 /**1079 * Default visitor.1080 *1081 * @param {*} value1082 * @param {String|Number} key1083 * @param {Array<String|Number>} path1084 * @this {FormData}1085 *1086 * @returns {boolean} return true to visit the each prop of the value recursively1087 */1088 function defaultVisitor(value, key, path) {1089 let arr = value;1090 1091 if (value && !path && typeof value === 'object') {1092 if (utils$1.endsWith(key, '{}')) {1093 // eslint-disable-next-line no-param-reassign1094 key = metaTokens ? key : key.slice(0, -2);1095 // eslint-disable-next-line no-param-reassign1096 value = JSON.stringify(value);1097 } else if (1098 (utils$1.isArray(value) && isFlatArray(value)) ||1099 ((utils$1.isFileList(value) || utils$1.endsWith(key, '[]')) && (arr = utils$1.toArray(value))1100 )) {1101 // eslint-disable-next-line no-param-reassign1102 key = removeBrackets(key);1103 1104 arr.forEach(function each(el, index) {1105 !(utils$1.isUndefined(el) || el === null) && formData.append(1106 // eslint-disable-next-line no-nested-ternary1107 indexes === true ? renderKey([key], index, dots) : (indexes === null ? key : key + '[]'),1108 convertValue(el)1109 );1110 });1111 return false;1112 }1113 }1114 1115 if (isVisitable(value)) {1116 return true;1117 }1118 1119 formData.append(renderKey(path, key, dots), convertValue(value));1120 1121 return false;1122 }1123 1124 const stack = [];1125 1126 const exposedHelpers = Object.assign(predicates, {1127 defaultVisitor,1128 convertValue,1129 isVisitable1130 });1131 1132 function build(value, path) {1133 if (utils$1.isUndefined(value)) return;1134 1135 if (stack.indexOf(value) !== -1) {1136 throw Error('Circular reference detected in ' + path.join('.'));1137 }1138 1139 stack.push(value);1140 1141 utils$1.forEach(value, function each(el, key) {1142 const result = !(utils$1.isUndefined(el) || el === null) && visitor.call(1143 formData, el, utils$1.isString(key) ? key.trim() : key, path, exposedHelpers1144 );1145 1146 if (result === true) {1147 build(el, path ? path.concat(key) : [key]);1148 }1149 });1150 1151 stack.pop();1152 }1153 1154 if (!utils$1.isObject(obj)) {1155 throw new TypeError('data must be an object');1156 }1157 1158 build(obj);1159 1160 return formData;1161}1162 1163/**1164 * It encodes a string by replacing all characters that are not in the unreserved set with1165 * their percent-encoded equivalents1166 *1167 * @param {string} str - The string to encode.1168 *1169 * @returns {string} The encoded string.1170 */1171function encode$1(str) {1172 const charMap = {1173 '!': '%21',1174 "'": '%27',1175 '(': '%28',1176 ')': '%29',1177 '~': '%7E',1178 '%20': '+',1179 '%00': '\x00'1180 };1181 return encodeURIComponent(str).replace(/[!'()~]|%20|%00/g, function replacer(match) {1182 return charMap[match];1183 });1184}1185 1186/**1187 * It takes a params object and converts it to a FormData object1188 *1189 * @param {Object<string, any>} params - The parameters to be converted to a FormData object.1190 * @param {Object<string, any>} options - The options object passed to the Axios constructor.1191 *1192 * @returns {void}1193 */1194function AxiosURLSearchParams(params, options) {1195 this._pairs = [];1196 1197 params && toFormData$1(params, this, options);1198}1199 1200const prototype = AxiosURLSearchParams.prototype;