decord/source/modules/user_settings/UserSettingSearchManager.tsx

131 lines
3.9 KiB
TypeScript
Raw Normal View History

2026-08-24 06:08:38 +00:00
// Module ID: 15128
// Function ID: 15129
2026-07-29 08:29:29 +00:00
// Name: search
2026-08-24 06:08:38 +00:00
// Dependencies: [6812, 15129, 2]
2026-07-20 16:05:17 +00:00
2026-08-24 06:08:38 +00:00
// Module 15128 (search)
import set2 from "set" /* 2 */;
let result = set2.fileFinishedImporting("modules/user_settings/UserSettingSearchManager.tsx");
2026-07-29 08:29:29 +00:00
class SettingSearchManager {
constructor(arg0) {
obj = Object.create(new.target.prototype);
closure_0 = obj;
obj.terms = global;
map = new Map();
obj.cache = map;
map1 = new Map();
obj.cacheScored = map1;
obj.preprocessed = [];
item = global.forEach((arg0) => {
[tmp, arr] = arg0;
let set;
const items = [];
const items1 = [];
set = new Set();
let item = arr.forEach((toLocaleLowerCase) => {
items.push(toLocaleLowerCase.toLocaleLowerCase());
if (toLocaleLowerCase.includes(" ")) {
const parts = toLocaleLowerCase.split(/\s+/);
const item = parts.forEach((toLocaleLowerCase) => {
const toLocaleLowerCaseResult = toLocaleLowerCase.toLocaleLowerCase();
if (!set.has(toLocaleLowerCaseResult)) {
arr = arr.push(toLocaleLowerCaseResult);
set.add(toLocaleLowerCaseResult);
}
});
}
});
const preprocessed = items.preprocessed;
const items2 = [tmp, { normalizedSearchTerms: items, normalizedTokens: items1 }];
});
return obj;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
}
const prototype = SettingSearchManager.prototype;
prototype["search"] = function search(arg0) {
const self = this;
2026-08-24 06:08:38 +00:00
closure_0 = arg0;
2026-07-29 08:29:29 +00:00
return new Promise((arg0) => {
arg0(self.getMatchingSettings(closure_0));
});
};
prototype["getMatchingSettings"] = function getMatchingSettings(closure_0) {
const self = this;
const cache = this.cache;
const value = cache.get(closure_0);
if (null != value) {
return value;
2026-07-20 16:05:17 +00:00
} else {
2026-07-29 08:29:29 +00:00
const items = [];
const terms = self.terms;
const item = terms.forEach((arg0) => {
[tmp, tmp2] = arg0;
for (const item10015 of tmp2) {
let tmp3 = items;
2026-08-24 06:08:38 +00:00
let tmp4 = closure_1_2;
2026-07-29 08:29:29 +00:00
let tmp6 = closure_0;
2026-08-24 06:08:38 +00:00
let tmp5 = items(closure_1_2[0]);
2026-07-29 08:29:29 +00:00
let formatted = closure_0.toLowerCase();
if (tmp5(formatted, item10015.toLowerCase())) {
let tmp8 = items;
let arr = items.push(tmp);
let tmp10 = obj;
obj.return();
break;
2026-07-20 16:05:17 +00:00
}
}
2026-07-29 08:29:29 +00:00
});
const cache2 = self.cache;
const result = cache2.set(closure_0, items);
return items;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
};
prototype["getScoredSearchResults"] = function getScoredSearchResults(str) {
const trimmed = str.trim();
const toLocaleLowerCaseResult = trimmed.toLocaleLowerCase();
2026-08-24 06:08:38 +00:00
require = toLocaleLowerCaseResult;
2026-07-29 08:29:29 +00:00
if (0 === toLocaleLowerCaseResult.length) {
return [];
} else {
const self = this;
const cacheScored = this.cacheScored;
const value = cacheScored.get(toLocaleLowerCaseResult);
if (null != value) {
return value;
} else {
const items = [];
const preprocessed = self.preprocessed;
let item = preprocessed.forEach((arg0) => {
[tmp, ] = arg0;
2026-08-24 06:08:38 +00:00
c0 = 0;
2026-07-29 08:29:29 +00:00
if (arr.some((arg0) => arg0 === c0)) {
c0 = 1;
} else if (obj.some((str) => str.startsWith(c0))) {
c0 = 0.95;
2026-07-20 16:05:17 +00:00
} else {
2026-07-29 08:29:29 +00:00
const item = arr.forEach((arg0) => {
2026-08-24 06:08:38 +00:00
const result = toLocaleLowerCaseResult(closure_2_2[1]).calculateJaroWinklerSimilarity(c0, arg0);
2026-07-29 08:29:29 +00:00
let num = 0;
if (result >= 0.8) {
num = result;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
closure_0 = Math.max(closure_0, num);
2026-07-20 16:05:17 +00:00
});
}
2026-07-29 08:29:29 +00:00
if (c0 > 0) {
obj = { setting: null, score: null };
obj[0] = tmp;
obj[1] = c0;
arr = items.push(obj);
}
});
const cacheScored2 = self.cacheScored;
let result = cacheScored2.set(toLocaleLowerCaseResult, items);
return items;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
}
};
2026-07-20 16:05:17 +00:00
2026-07-29 08:29:29 +00:00
export default SettingSearchManager;