decord/source/4989_encode.js

189 lines
5.6 KiB
JavaScript
Raw Normal View History

2026-07-25 08:10:48 +00:00
// Module ID: 4989
2026-07-27 11:26:19 +00:00
// Function ID: 42999
2026-07-20 16:05:17 +00:00
// Name: encode
2026-07-25 08:10:48 +00:00
// Dependencies: [4990, 4991, 1497]
2026-07-20 16:05:17 +00:00
2026-07-25 08:10:48 +00:00
// Module 4989 (encode)
2026-07-23 10:11:24 +00:00
const require = arg1;
let dependencyMap = arg6;
2026-07-20 16:05:17 +00:00
function encode(arg0, encode) {
if (!encode.encode) {
return arg0;
} else if (encode.strict) {
2026-07-25 08:10:48 +00:00
let encodeURIComponentResult = require(4990)(arg0);
2026-07-20 16:05:17 +00:00
} else {
const _encodeURIComponent = encodeURIComponent;
encodeURIComponentResult = encodeURIComponent(arg0);
}
}
function keysSorter(arr) {
2026-07-23 10:11:24 +00:00
let closure_0 = arr;
2026-07-20 16:05:17 +00:00
if (Array.isArray(arr)) {
let sorted = arr.sort();
} else {
sorted = arr;
if ("object" === typeof arr) {
const _Object = Object;
const sorted1 = keysSorter(Object.keys(arr)).sort((arg0, arg1) => Number(arg0) - Number(arg1));
2026-07-23 10:11:24 +00:00
sorted = sorted1.map((arg0) => arr[arg0]);
2026-07-20 16:05:17 +00:00
const obj = keysSorter(Object.keys(arr));
}
}
return sorted;
}
arg5.extract = (arg0) => arg0.split("?")[1] || "";
arg5.parse = (str) => {
2026-07-23 10:11:24 +00:00
_require = (function parserForArrayFormat(arrayFormat) {
2026-07-20 16:05:17 +00:00
arrayFormat = arrayFormat.arrayFormat;
if ("index" === arrayFormat) {
return (str) => {
2026-07-23 10:11:24 +00:00
const table = /\[(\d*)\]$/.exec(str);
2026-07-20 16:05:17 +00:00
const replaced = str.replace(/\[\d*\]$/, "");
2026-07-23 10:11:24 +00:00
if (table) {
2026-07-20 16:05:17 +00:00
if (undefined === arg2[replaced]) {
arg2[replaced] = {};
}
2026-07-23 10:11:24 +00:00
arg2[replaced][table[1]] = arg1;
2026-07-20 16:05:17 +00:00
} else {
arg2[replaced] = arg1;
}
};
} else {
2026-07-23 10:11:24 +00:00
return "bracket" === arrayFormat ? ((str) => {
2026-07-20 16:05:17 +00:00
let closure_0 = /(\[\])$/.exec(str);
const replaced = str.replace(/\[\]$/, "");
if (closure_0) {
if (undefined !== arg2[replaced]) {
const items = [];
arg2[replaced] = items.concat(arg2[replaced], arg1);
} else {
const items1 = [arg1];
arg2[replaced] = items1;
}
} else {
arg2[replaced] = arg1;
}
2026-07-23 10:11:24 +00:00
}) : ((arg0, arg1, arg2) => {
2026-07-20 16:05:17 +00:00
if (undefined !== arg2[arg0]) {
const items = [];
arg2[arg0] = items.concat(arg2[arg0], arg1);
} else {
arg2[arg0] = arg1;
}
2026-07-23 10:11:24 +00:00
});
2026-07-20 16:05:17 +00:00
}
2026-07-23 10:11:24 +00:00
})(_require(obj[1])({ arrayFormat: "none" }, arg1));
obj = Object.create(null);
2026-07-20 16:05:17 +00:00
let tmp2 = obj;
if ("string" === typeof str) {
const str4 = str.trim().replace(/^(\?|#|&)/, "");
let reduced = obj;
if (str4) {
2026-07-23 10:11:24 +00:00
let parts = str4.split("&");
2026-07-20 16:05:17 +00:00
const item = parts.forEach((str) => {
const parts = str.replace(/\+/g, " ").split("=");
let joined;
str = str.replace(/\+/g, " ");
if (parts.length > 0) {
joined = parts.join("=");
}
let tmp3 = null;
if (undefined !== joined) {
tmp3 = callback(obj[2])(joined);
}
callback(callback(obj[2])(parts.shift()), tmp3, obj);
});
const _Object = Object;
const keys = Object.keys(obj);
const sorted = keys.sort();
const _Object2 = Object;
reduced = sorted.reduce((arg0, arg1) => {
if (Boolean(obj[arg1])) {
if ("object" === typeof tmp) {
const _Array = Array;
if (!Array.isArray(tmp)) {
2026-07-23 10:11:24 +00:00
arg0[arg1] = outer1_3(tmp);
2026-07-20 16:05:17 +00:00
}
return arg0;
}
}
arg0[arg1] = obj[arg1];
}, Object.create(null));
}
tmp2 = reduced;
const str2 = str.trim();
}
return tmp2;
};
arg5.stringify = (arg0, arg1) => {
2026-07-23 10:11:24 +00:00
const _require = arg0;
2026-07-25 08:10:48 +00:00
const tmp = _require(4991)({ encode: true, strict: true, arrayFormat: "none" }, arg1);
2026-07-23 10:11:24 +00:00
const dependencyMap = tmp;
let closure_2 = (function encoderForArrayFormat(arrayFormat) {
let closure_0 = arrayFormat;
2026-07-20 16:05:17 +00:00
arrayFormat = arrayFormat.arrayFormat;
if ("index" === arrayFormat) {
return (arg0, arg1, arg2) => {
if (null === arg1) {
2026-07-23 10:11:24 +00:00
const items = [callback(arg0, closure_0), "[", arg2, "]"];
2026-07-20 16:05:17 +00:00
let joined = items.join("");
} else {
2026-07-23 10:11:24 +00:00
const items1 = [callback(arg0, closure_0), "[", callback(arg2, closure_0), "]=", callback(arg1, closure_0)];
2026-07-20 16:05:17 +00:00
joined = items1.join("");
}
return joined;
};
} else {
2026-07-23 10:11:24 +00:00
return "bracket" === arrayFormat ? ((arg0, arg1) => {
2026-07-20 16:05:17 +00:00
if (null === arg1) {
2026-07-23 10:11:24 +00:00
let joined = callback(arg0, closure_0);
2026-07-20 16:05:17 +00:00
} else {
2026-07-23 10:11:24 +00:00
const items = [callback(arg0, closure_0), "[]=", callback(arg1, closure_0)];
2026-07-20 16:05:17 +00:00
joined = items.join("");
}
return joined;
2026-07-23 10:11:24 +00:00
}) : ((arg0, arg1) => {
2026-07-20 16:05:17 +00:00
if (null === arg1) {
2026-07-23 10:11:24 +00:00
let joined = callback(arg0, closure_0);
2026-07-20 16:05:17 +00:00
} else {
2026-07-23 10:11:24 +00:00
const items = [callback(arg0, closure_0), "=", callback(arg1, closure_0)];
2026-07-20 16:05:17 +00:00
joined = items.join("");
}
return joined;
2026-07-23 10:11:24 +00:00
});
2026-07-20 16:05:17 +00:00
}
2026-07-23 10:11:24 +00:00
})(tmp);
2026-07-20 16:05:17 +00:00
let str = "";
if (arg0) {
const _Object = Object;
const keys = Object.keys(arg0);
const sorted = keys.sort();
const mapped = sorted.map((arg0) => {
2026-07-23 10:11:24 +00:00
const table = arg0;
if (undefined === table[arg0]) {
2026-07-20 16:05:17 +00:00
return "";
} else if (null === arr) {
2026-07-23 10:11:24 +00:00
return callback(arg0, items);
2026-07-20 16:05:17 +00:00
} else {
const _Array = Array;
if (Array.isArray(arr)) {
2026-07-23 10:11:24 +00:00
items = [];
2026-07-20 16:05:17 +00:00
const substr = arr.slice();
const item = substr.forEach((arg0) => {
if (undefined !== arg0) {
2026-07-23 10:11:24 +00:00
items.push(outer1_2(closure_0, arg0, items.length));
2026-07-20 16:05:17 +00:00
}
});
return items.join("&");
} else {
2026-07-23 10:11:24 +00:00
const text = `${closure_2(arg0, items)}=`;
return `${closure_2(arg0, items)}=` + callback(arr, items);
2026-07-20 16:05:17 +00:00
}
}
});
const found = mapped.filter((arg0) => arg0.length > 0);
str = found.join("&");
}
return str;
};