flexsearch.debug.js 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963
  1. /**!
  2. * FlexSearch.js v0.7.2 (Debug)
  3. * Copyright 2018-2021 Nextapps GmbH
  4. * Author: Thomas Wilkerling
  5. * Licence: Apache-2.0
  6. * https://github.com/nextapps-de/flexsearch
  7. */
  8. (function(self){'use strict';
  9. function r(a, b) {
  10. return "undefined" !== typeof a ? a : b;
  11. }
  12. function v(a) {
  13. const b = Array(a);
  14. for (let c = 0; c < a; c++) {
  15. b[c] = w();
  16. }
  17. return b;
  18. }
  19. function w() {
  20. return Object.create(null);
  21. }
  22. function aa(a, b) {
  23. return b.length - a.length;
  24. }
  25. function x(a) {
  26. return "string" === typeof a;
  27. }
  28. function z(a) {
  29. return "object" === typeof a;
  30. }
  31. function D(a) {
  32. return "function" === typeof a;
  33. }
  34. ;function ba(a, b, c, d) {
  35. if (a && (b && (a = E(a, b)), this.matcher && (a = E(a, this.matcher)), this.stemmer && 1 < a.length && (a = E(a, this.stemmer)), d && 1 < a.length && (a = F(a)), c || "" === c)) {
  36. a = a.split(c);
  37. if (this.filter) {
  38. b = this.filter;
  39. c = a.length;
  40. d = [];
  41. for (let e = 0, f = 0; e < c; e++) {
  42. const g = a[e];
  43. g && !b[g] && (d[f++] = g);
  44. }
  45. a = d;
  46. }
  47. return a;
  48. }
  49. return a;
  50. }
  51. const ca = /[\p{Z}\p{S}\p{P}\p{C}]+/u, da = /[\u0300-\u036f]/g;
  52. function ea(a, b) {
  53. const c = Object.keys(a), d = c.length, e = [];
  54. let f = "", g = 0;
  55. for (let h = 0, k, m; h < d; h++) {
  56. k = c[h], (m = a[k]) ? (e[g++] = G(b ? "(?!\\b)" + k + "(\\b|_)" : k), e[g++] = m) : f += (f ? "|" : "") + k;
  57. }
  58. f && (e[g++] = G(b ? "(?!\\b)(" + f + ")(\\b|_)" : "(" + f + ")"), e[g] = "");
  59. return e;
  60. }
  61. function E(a, b) {
  62. for (let c = 0, d = b.length; c < d && (a = a.replace(b[c], b[c + 1]), a); c += 2) {
  63. }
  64. return a;
  65. }
  66. function G(a) {
  67. return new RegExp(a, "g");
  68. }
  69. function F(a) {
  70. let b = "", c = "";
  71. for (let d = 0, e = a.length, f; d < e; d++) {
  72. (f = a[d]) !== c && (b += c = f);
  73. }
  74. return b;
  75. }
  76. ;var ha = {encode:fa, rtl:!1, tokenize:""};
  77. function fa(a) {
  78. return ba.call(this, a.toLowerCase(), !1, ca, !1);
  79. }
  80. ;const ia = {}, I = {};
  81. function ja(a) {
  82. J(a, "add");
  83. J(a, "append");
  84. J(a, "search");
  85. J(a, "update");
  86. J(a, "remove");
  87. }
  88. function J(a, b) {
  89. a[b + "Async"] = function() {
  90. const c = this, d = arguments;
  91. var e = d[d.length - 1];
  92. let f;
  93. D(e) && (f = e, delete d[d.length - 1]);
  94. e = new Promise(function(g) {
  95. setTimeout(function() {
  96. c.async = !0;
  97. const h = c[b].apply(c, d);
  98. c.async = !1;
  99. g(h);
  100. });
  101. });
  102. return f ? (e.then(f), this) : e;
  103. };
  104. }
  105. ;function ka(a, b, c, d) {
  106. const e = a.length;
  107. let f = [], g, h, k = 0;
  108. d && (d = []);
  109. for (let m = e - 1; 0 <= m; m--) {
  110. const p = a[m], u = p.length, q = w();
  111. let n = !g;
  112. for (let l = 0; l < u; l++) {
  113. const t = p[l], y = t.length;
  114. if (y) {
  115. for (let C = 0, B, A; C < y; C++) {
  116. if (A = t[C], g) {
  117. if (g[A]) {
  118. if (!m) {
  119. if (c) {
  120. c--;
  121. } else {
  122. if (f[k++] = A, k === b) {
  123. return f;
  124. }
  125. }
  126. }
  127. if (m || d) {
  128. q[A] = 1;
  129. }
  130. n = !0;
  131. }
  132. if (d && (h[A] = (B = h[A]) ? ++B : B = 1, B < e)) {
  133. const H = d[B - 2] || (d[B - 2] = []);
  134. H[H.length] = A;
  135. }
  136. } else {
  137. q[A] = 1;
  138. }
  139. }
  140. }
  141. }
  142. if (d) {
  143. g || (h = q);
  144. } else {
  145. if (!n) {
  146. return [];
  147. }
  148. }
  149. g = q;
  150. }
  151. if (d) {
  152. for (let m = d.length - 1, p, u; 0 <= m; m--) {
  153. p = d[m];
  154. u = p.length;
  155. for (let q = 0, n; q < u; q++) {
  156. if (n = p[q], !g[n]) {
  157. if (c) {
  158. c--;
  159. } else {
  160. if (f[k++] = n, k === b) {
  161. return f;
  162. }
  163. }
  164. g[n] = 1;
  165. }
  166. }
  167. }
  168. }
  169. return f;
  170. }
  171. function la(a, b) {
  172. const c = w(), d = w(), e = [];
  173. for (let f = 0; f < a.length; f++) {
  174. c[a[f]] = 1;
  175. }
  176. for (let f = 0, g; f < b.length; f++) {
  177. g = b[f];
  178. for (let h = 0, k; h < g.length; h++) {
  179. k = g[h], c[k] && !d[k] && (d[k] = 1, e[e.length] = k);
  180. }
  181. }
  182. return e;
  183. }
  184. ;function K(a) {
  185. this.limit = !0 !== a && a;
  186. this.cache = w();
  187. this.queue = [];
  188. }
  189. function ma(a, b, c) {
  190. z(a) && (a = a.query);
  191. let d = this.cache.get(a);
  192. d || (d = this.search(a, b, c), this.cache.set(a, d));
  193. return d;
  194. }
  195. K.prototype.set = function(a, b) {
  196. if (!this.cache[a]) {
  197. var c = this.queue.length;
  198. c === this.limit ? delete this.cache[this.queue[c - 1]] : c++;
  199. for (--c; 0 < c; c--) {
  200. this.queue[c] = this.queue[c - 1];
  201. }
  202. this.queue[0] = a;
  203. }
  204. this.cache[a] = b;
  205. };
  206. K.prototype.get = function(a) {
  207. const b = this.cache[a];
  208. if (this.limit && b && (a = this.queue.indexOf(a))) {
  209. const c = this.queue[a - 1];
  210. this.queue[a - 1] = this.queue[a];
  211. this.queue[a] = c;
  212. }
  213. return b;
  214. };
  215. K.prototype.del = function(a) {
  216. for (let b = 0, c, d; b < this.queue.length; b++) {
  217. d = this.queue[b], c = this.cache[d], -1 !== c.indexOf(a) && (this.queue.splice(b--, 1), delete this.cache[d]);
  218. }
  219. };
  220. const na = {memory:{charset:"latin:extra", resolution:3, minlength:4, fastupdate:!1}, performance:{resolution:3, minlength:3, optimize:!1, context:{depth:2, resolution:1}}, match:{charset:"latin:extra", tokenize:"reverse", }, score:{charset:"latin:advanced", resolution:20, minlength:3, context:{depth:3, resolution:9, }}, "default":{}, };
  221. function pa(a, b, c, d, e, f) {
  222. setTimeout(function() {
  223. const g = a(c, JSON.stringify(f));
  224. g && g.then ? g.then(function() {
  225. b.export(a, b, c, d, e + 1);
  226. }) : b.export(a, b, c, d, e + 1);
  227. });
  228. }
  229. ;function L(a, b) {
  230. if (!(this instanceof L)) {
  231. return new L(a);
  232. }
  233. var c;
  234. if (a) {
  235. if (x(a)) {
  236. na[a] || console.warn("Preset not found: " + a), a = na[a];
  237. } else {
  238. if (c = a.preset) {
  239. c[c] || console.warn("Preset not found: " + c), a = Object.assign({}, c[c], a);
  240. }
  241. }
  242. c = a.charset;
  243. var d = a.lang;
  244. x(c) && (-1 === c.indexOf(":") && (c += ":default"), c = I[c]);
  245. x(d) && (d = ia[d]);
  246. } else {
  247. a = {};
  248. }
  249. let e, f, g = a.context || {};
  250. this.encode = a.encode || c && c.encode || fa;
  251. this.register = b || w();
  252. this.resolution = e = a.resolution || 9;
  253. this.tokenize = b = c && c.tokenize || a.tokenize || "strict";
  254. this.depth = "strict" === b && g.depth;
  255. this.bidirectional = r(g.bidirectional, !0);
  256. this.optimize = f = r(a.optimize, !0);
  257. this.fastupdate = r(a.fastupdate, !0);
  258. this.minlength = a.minlength || 1;
  259. this.boost = a.boost;
  260. this.map = f ? v(e) : w();
  261. this.resolution_ctx = e = g.resolution || 1;
  262. this.ctx = f ? v(e) : w();
  263. this.rtl = c && c.rtl || a.rtl;
  264. this.matcher = (b = a.matcher || d && d.matcher) && ea(b, !1);
  265. this.stemmer = (b = a.stemmer || d && d.stemmer) && ea(b, !0);
  266. if (c = b = a.filter || d && d.filter) {
  267. c = b;
  268. d = w();
  269. for (let h = 0, k = c.length; h < k; h++) {
  270. d[c[h]] = 1;
  271. }
  272. c = d;
  273. }
  274. this.filter = c;
  275. this.cache = (b = a.cache) && new K(b);
  276. }
  277. L.prototype.append = function(a, b) {
  278. return this.add(a, b, !0);
  279. };
  280. L.prototype.add = function(a, b, c, d) {
  281. if (b && (a || 0 === a)) {
  282. if (!d && !c && this.register[a]) {
  283. return this.update(a, b);
  284. }
  285. b = this.encode(b);
  286. if (d = b.length) {
  287. const m = w(), p = w(), u = this.depth, q = this.resolution;
  288. for (let n = 0; n < d; n++) {
  289. let l = b[this.rtl ? d - 1 - n : n];
  290. var e = l.length;
  291. if (l && e >= this.minlength && (u || !p[l])) {
  292. var f = M(q, d, n), g = "";
  293. switch(this.tokenize) {
  294. case "full":
  295. if (3 < e) {
  296. for (f = 0; f < e; f++) {
  297. for (var h = e; h > f; h--) {
  298. if (h - f >= this.minlength) {
  299. var k = M(q, d, n, e, f);
  300. g = l.substring(f, h);
  301. this.push_index(p, g, k, a, c);
  302. }
  303. }
  304. }
  305. break;
  306. }
  307. case "reverse":
  308. if (2 < e) {
  309. for (h = e - 1; 0 < h; h--) {
  310. g = l[h] + g, g.length >= this.minlength && (k = M(q, d, n, e, h), this.push_index(p, g, k, a, c));
  311. }
  312. g = "";
  313. }
  314. case "forward":
  315. if (1 < e) {
  316. for (h = 0; h < e; h++) {
  317. g += l[h], g.length >= this.minlength && this.push_index(p, g, f, a, c);
  318. }
  319. break;
  320. }
  321. default:
  322. if (this.boost && (f = Math.min(f / this.boost(b, l, n) | 0, q - 1)), this.push_index(p, l, f, a, c), u && 1 < d && n < d - 1) {
  323. for (e = w(), g = this.resolution_ctx, f = l, h = Math.min(u + 1, d - n), e[f] = 1, k = 1; k < h; k++) {
  324. if ((l = b[this.rtl ? d - 1 - n - k : n + k]) && l.length >= this.minlength && !e[l]) {
  325. e[l] = 1;
  326. const t = M(g + (d / 2 > g ? 0 : 1), d, n, h - 1, k - 1), y = this.bidirectional && l > f;
  327. this.push_index(m, y ? f : l, t, a, c, y ? l : f);
  328. }
  329. }
  330. }
  331. }
  332. }
  333. }
  334. this.fastupdate || (this.register[a] = 1);
  335. }
  336. }
  337. return this;
  338. };
  339. function M(a, b, c, d, e) {
  340. return c && 1 < a ? b + (d || 0) <= a ? c + (e || 0) : (a - 1) / (b + (d || 0)) * (c + (e || 0)) + 1 | 0 : 0;
  341. }
  342. L.prototype.push_index = function(a, b, c, d, e, f) {
  343. let g = f ? this.ctx : this.map;
  344. if (!a[b] || f && !a[b][f]) {
  345. this.optimize && (g = g[c]), f ? (a = a[b] || (a[b] = w()), a[f] = 1, g = g[f] || (g[f] = w())) : a[b] = 1, g = g[b] || (g[b] = []), this.optimize || (g = g[c] || (g[c] = [])), e && -1 !== g.indexOf(d) || (g[g.length] = d, this.fastupdate && (a = this.register[d] || (this.register[d] = []), a[a.length] = g));
  346. }
  347. };
  348. L.prototype.search = function(a, b, c) {
  349. c || (!b && z(a) ? (c = a, a = c.query) : z(b) && (c = b));
  350. let d = [], e;
  351. let f, g = 0;
  352. if (c) {
  353. b = c.limit;
  354. g = c.offset || 0;
  355. var h = c.context;
  356. f = c.suggest;
  357. }
  358. if (a && (a = this.encode(a), e = a.length, 1 < e)) {
  359. c = w();
  360. var k = [];
  361. for (let p = 0, u = 0, q; p < e; p++) {
  362. if ((q = a[p]) && q.length >= this.minlength && !c[q]) {
  363. if (this.optimize || f || this.map[q]) {
  364. k[u++] = q, c[q] = 1;
  365. } else {
  366. return d;
  367. }
  368. }
  369. }
  370. a = k;
  371. e = a.length;
  372. }
  373. if (!e) {
  374. return d;
  375. }
  376. b || (b = 100);
  377. h = this.depth && 1 < e && !1 !== h;
  378. c = 0;
  379. let m;
  380. h ? (m = a[0], c = 1) : 1 < e && a.sort(aa);
  381. for (let p, u; c < e; c++) {
  382. u = a[c];
  383. h ? (p = this.add_result(d, f, b, g, 2 === e, u, m), f && !1 === p && d.length || (m = u)) : p = this.add_result(d, f, b, g, 1 === e, u);
  384. if (p) {
  385. return p;
  386. }
  387. if (f && c === e - 1) {
  388. k = d.length;
  389. if (!k) {
  390. if (h) {
  391. h = 0;
  392. c = -1;
  393. continue;
  394. }
  395. return d;
  396. }
  397. if (1 === k) {
  398. return qa(d[0], b, g);
  399. }
  400. }
  401. }
  402. return ka(d, b, g, f);
  403. };
  404. L.prototype.add_result = function(a, b, c, d, e, f, g) {
  405. let h = [], k = g ? this.ctx : this.map;
  406. this.optimize || (k = ra(k, f, g, this.bidirectional));
  407. if (k) {
  408. let m = 0;
  409. const p = Math.min(k.length, g ? this.resolution_ctx : this.resolution);
  410. for (let u = 0, q = 0, n, l; u < p; u++) {
  411. if (n = k[u]) {
  412. if (this.optimize && (n = ra(n, f, g, this.bidirectional)), d && n && e && (l = n.length, l <= d ? (d -= l, n = null) : (n = n.slice(d), d = 0)), n && (h[m++] = n, e && (q += n.length, q >= c))) {
  413. break;
  414. }
  415. }
  416. }
  417. if (m) {
  418. if (e) {
  419. return qa(h, c, 0);
  420. }
  421. a[a.length] = h;
  422. return;
  423. }
  424. }
  425. return !b && h;
  426. };
  427. function qa(a, b, c) {
  428. a = 1 === a.length ? a[0] : [].concat.apply([], a);
  429. return c || a.length > b ? a.slice(c, c + b) : a;
  430. }
  431. function ra(a, b, c, d) {
  432. c ? (d = d && b > c, a = (a = a[d ? b : c]) && a[d ? c : b]) : a = a[b];
  433. return a;
  434. }
  435. L.prototype.contain = function(a) {
  436. return !!this.register[a];
  437. };
  438. L.prototype.update = function(a, b) {
  439. return this.remove(a).add(a, b);
  440. };
  441. L.prototype.remove = function(a, b) {
  442. const c = this.register[a];
  443. if (c) {
  444. if (this.fastupdate) {
  445. for (let d = 0, e; d < c.length; d++) {
  446. e = c[d], e.splice(e.indexOf(a), 1);
  447. }
  448. } else {
  449. N(this.map, a, this.resolution, this.optimize), this.depth && N(this.ctx, a, this.resolution_ctx, this.optimize);
  450. }
  451. b || delete this.register[a];
  452. this.cache && this.cache.del(a);
  453. }
  454. return this;
  455. };
  456. function N(a, b, c, d, e) {
  457. let f = 0;
  458. if (a.constructor === Array) {
  459. if (e) {
  460. b = a.indexOf(b), -1 !== b ? 1 < a.length && (a.splice(b, 1), f++) : f++;
  461. } else {
  462. e = Math.min(a.length, c);
  463. for (let g = 0, h; g < e; g++) {
  464. if (h = a[g]) {
  465. f = N(h, b, c, d, e), d || f || delete a[g];
  466. }
  467. }
  468. }
  469. } else {
  470. for (let g in a) {
  471. (f = N(a[g], b, c, d, e)) || delete a[g];
  472. }
  473. }
  474. return f;
  475. }
  476. L.prototype.searchCache = ma;
  477. L.prototype.export = function(a, b, c, d, e) {
  478. let f, g;
  479. switch(e || (e = 0)) {
  480. case 0:
  481. f = "reg";
  482. if (this.fastupdate) {
  483. g = w();
  484. for (let h in this.register) {
  485. g[h] = 1;
  486. }
  487. } else {
  488. g = this.register;
  489. }
  490. break;
  491. case 1:
  492. f = "cfg";
  493. g = {doc:0, opt:this.optimize ? 1 : 0};
  494. break;
  495. case 2:
  496. f = "map";
  497. g = this.map;
  498. break;
  499. case 3:
  500. f = "ctx";
  501. g = this.ctx;
  502. break;
  503. default:
  504. return;
  505. }
  506. pa(a, b || this, c ? c + "." + f : f, d, e, g);
  507. return !0;
  508. };
  509. L.prototype.import = function(a, b) {
  510. if (b) {
  511. switch(x(b) && (b = JSON.parse(b)), a) {
  512. case "cfg":
  513. this.optimize = !!b.opt;
  514. break;
  515. case "reg":
  516. this.fastupdate = !1;
  517. this.register = b;
  518. break;
  519. case "map":
  520. this.map = b;
  521. break;
  522. case "ctx":
  523. this.ctx = b;
  524. }
  525. }
  526. };
  527. ja(L.prototype);
  528. function sa(a) {
  529. a = a.data;
  530. var b = self._index;
  531. const c = a.args;
  532. var d = a.task;
  533. switch(d) {
  534. case "init":
  535. d = a.options || {};
  536. a = a.factory;
  537. b = d.encode;
  538. d.cache = !1;
  539. b && 0 === b.indexOf("function") && (d.encode = Function("return " + b)());
  540. a ? (Function("return " + a)()(self), self._index = new self.FlexSearch.Index(d), delete self.FlexSearch) : self._index = new L(d);
  541. break;
  542. default:
  543. a = a.id, b = b[d].apply(b, c), postMessage("search" === d ? {id:a, msg:b} : {id:a});
  544. }
  545. }
  546. ;let ta = 0;
  547. function O(a) {
  548. if (!(this instanceof O)) {
  549. return new O(a);
  550. }
  551. var b;
  552. a ? D(b = a.encode) && (a.encode = b.toString()) : a = {};
  553. (b = (self || window)._factory) && (b = b.toString());
  554. const c = self.exports, d = this;
  555. this.worker = ua(b, c, a.worker);
  556. this.resolver = w();
  557. if (this.worker) {
  558. if (c) {
  559. this.worker.on("message", function(e) {
  560. d.resolver[e.id](e.msg);
  561. delete d.resolver[e.id];
  562. });
  563. } else {
  564. this.worker.onmessage = function(e) {
  565. e = e.data;
  566. d.resolver[e.id](e.msg);
  567. delete d.resolver[e.id];
  568. };
  569. }
  570. this.worker.postMessage({task:"init", factory:b, options:a});
  571. }
  572. }
  573. Q("add");
  574. Q("append");
  575. Q("search");
  576. Q("update");
  577. Q("remove");
  578. function Q(a) {
  579. O.prototype[a] = O.prototype[a + "Async"] = function() {
  580. const b = this, c = [].slice.call(arguments);
  581. var d = c[c.length - 1];
  582. let e;
  583. D(d) && (e = d, c.splice(c.length - 1, 1));
  584. d = new Promise(function(f) {
  585. setTimeout(function() {
  586. b.resolver[++ta] = f;
  587. b.worker.postMessage({task:a, id:ta, args:c});
  588. });
  589. });
  590. return e ? (d.then(e), this) : d;
  591. };
  592. }
  593. function ua(a, b, c) {
  594. let d;
  595. try {
  596. d = b ? eval('new (require("worker_threads")["Worker"])("../dist/node/node.js")') : a ? new Worker(URL.createObjectURL(new Blob(["onmessage=" + sa.toString()], {type:"text/javascript"}))) : new Worker(x(c) ? c : "worker/worker.js", {type:"module"});
  597. } catch (e) {
  598. }
  599. return d;
  600. }
  601. ;function R(a) {
  602. if (!(this instanceof R)) {
  603. return new R(a);
  604. }
  605. var b = a.document || a.doc || a, c;
  606. this.tree = [];
  607. this.field = [];
  608. this.marker = [];
  609. this.register = w();
  610. this.key = (c = b.key || b.id) && S(c, this.marker) || "id";
  611. this.fastupdate = r(a.fastupdate, !0);
  612. this.storetree = (c = b.store) && !0 !== c && [];
  613. this.store = c && w();
  614. this.tag = (c = b.tag) && S(c, this.marker);
  615. this.tagindex = c && w();
  616. this.cache = (c = a.cache) && new K(c);
  617. a.cache = !1;
  618. this.worker = a.worker;
  619. this.async = !1;
  620. c = w();
  621. let d = b.index || b.field || b;
  622. x(d) && (d = [d]);
  623. for (let e = 0, f, g; e < d.length; e++) {
  624. f = d[e], x(f) || (g = f, f = f.field), g = z(g) ? Object.assign({}, a, g) : a, this.worker && (c[f] = new O(g), c[f].worker || (this.worker = !1)), this.worker || (c[f] = new L(g, this.register)), this.tree[e] = S(f, this.marker), this.field[e] = f;
  625. }
  626. if (this.storetree) {
  627. for (a = b.store, x(a) && (a = [a]), b = 0; b < a.length; b++) {
  628. this.storetree[b] = S(a[b], this.marker);
  629. }
  630. }
  631. this.index = c;
  632. }
  633. function S(a, b) {
  634. const c = a.split(":");
  635. let d = 0;
  636. for (let e = 0; e < c.length; e++) {
  637. a = c[e], 0 <= a.indexOf("[]") && (a = a.substring(0, a.length - 2)) && (b[d] = !0), a && (c[d++] = a);
  638. }
  639. d < c.length && (c.length = d);
  640. return 1 < d ? c : c[0];
  641. }
  642. function T(a, b) {
  643. if (x(b)) {
  644. a = a[b];
  645. } else {
  646. for (let c = 0; a && c < b.length; c++) {
  647. a = a[b[c]];
  648. }
  649. }
  650. return a;
  651. }
  652. function U(a, b, c, d, e) {
  653. a = a[e];
  654. if (d === c.length - 1) {
  655. b[e] = a;
  656. } else {
  657. if (a) {
  658. if (a.constructor === Array) {
  659. for (b = b[e] = Array(a.length), e = 0; e < a.length; e++) {
  660. U(a, b, c, d, e);
  661. }
  662. } else {
  663. b = b[e] || (b[e] = w()), e = c[++d], U(a, b, c, d, e);
  664. }
  665. }
  666. }
  667. }
  668. function V(a, b, c, d, e, f, g, h) {
  669. if (a = a[g]) {
  670. if (d === b.length - 1) {
  671. if (a.constructor === Array) {
  672. if (c[d]) {
  673. for (b = 0; b < a.length; b++) {
  674. e.add(f, a[b], !0, !0);
  675. }
  676. return;
  677. }
  678. a = a.join(" ");
  679. }
  680. e.add(f, a, h, !0);
  681. } else {
  682. if (a.constructor === Array) {
  683. for (g = 0; g < a.length; g++) {
  684. V(a, b, c, d, e, f, g, h);
  685. }
  686. } else {
  687. g = b[++d], V(a, b, c, d, e, f, g, h);
  688. }
  689. }
  690. }
  691. }
  692. R.prototype.add = function(a, b, c) {
  693. z(a) && (b = a, a = T(b, this.key));
  694. if (b && (a || 0 === a)) {
  695. if (!c && this.register[a]) {
  696. return this.update(a, b);
  697. }
  698. for (let d = 0, e, f; d < this.field.length; d++) {
  699. f = this.field[d], e = this.tree[d], x(e) && (e = [e]), V(b, e, this.marker, 0, this.index[f], a, e[0], c);
  700. }
  701. if (this.tag) {
  702. let d = T(b, this.tag), e = w();
  703. x(d) && (d = [d]);
  704. for (let f = 0, g, h; f < d.length; f++) {
  705. if (g = d[f], !e[g] && (e[g] = 1, h = this.tagindex[g] || (this.tagindex[g] = []), !c || -1 === h.indexOf(a))) {
  706. if (h[h.length] = a, this.fastupdate) {
  707. const k = this.register[a] || (this.register[a] = []);
  708. k[k.length] = h;
  709. }
  710. }
  711. }
  712. }
  713. if (this.store && (!c || !this.store[a])) {
  714. let d;
  715. if (this.storetree) {
  716. d = w();
  717. for (let e = 0, f; e < this.storetree.length; e++) {
  718. f = this.storetree[e], x(f) ? d[f] = b[f] : U(b, d, f, 0, f[0]);
  719. }
  720. }
  721. this.store[a] = d || b;
  722. }
  723. }
  724. return this;
  725. };
  726. R.prototype.append = function(a, b) {
  727. return this.add(a, b, !0);
  728. };
  729. R.prototype.update = function(a, b) {
  730. return this.remove(a).add(a, b);
  731. };
  732. R.prototype.remove = function(a) {
  733. z(a) && (a = T(a, this.key));
  734. if (this.register[a]) {
  735. for (var b = 0; b < this.field.length && (this.index[this.field[b]].remove(a, !this.worker), !this.fastupdate); b++) {
  736. }
  737. if (this.tag && !this.fastupdate) {
  738. for (let c in this.tagindex) {
  739. b = this.tagindex[c];
  740. const d = b.indexOf(a);
  741. -1 !== d && (1 < b.length ? b.splice(d, 1) : delete this.tagindex[c]);
  742. }
  743. }
  744. this.store && delete this.store[a];
  745. delete this.register[a];
  746. }
  747. return this;
  748. };
  749. R.prototype.search = function(a, b, c, d) {
  750. c || (!b && z(a) ? (c = a, a = c.query) : z(b) && (c = b, b = 0));
  751. let e = [], f = [], g, h, k, m, p, u, q = 0;
  752. if (c) {
  753. if (c.constructor === Array) {
  754. k = c, c = null;
  755. } else {
  756. k = (g = c.pluck) || c.index || c.field;
  757. m = c.tag;
  758. h = this.store && c.enrich;
  759. p = "and" === c.bool;
  760. b = c.limit || 100;
  761. u = c.offset || 0;
  762. if (m && (x(m) && (m = [m]), !a)) {
  763. for (let l = 0, t; l < m.length; l++) {
  764. if (t = va.call(this, m[l], b, u, h)) {
  765. e[e.length] = t, q++;
  766. }
  767. }
  768. return q ? e : [];
  769. }
  770. x(k) && (k = [k]);
  771. }
  772. }
  773. k || (k = this.field);
  774. p = p && (1 < k.length || m && 1 < m.length);
  775. const n = !d && (this.worker || this.async) && [];
  776. for (let l = 0, t, y, C; l < k.length; l++) {
  777. let B;
  778. y = k[l];
  779. x(y) || (B = y, y = y.field);
  780. if (n) {
  781. n[l] = this.index[y].searchAsync(a, b, B || c);
  782. } else {
  783. C = (t = d ? d[l] : this.index[y].search(a, b, B || c)) && t.length;
  784. if (m && C) {
  785. const A = [];
  786. let H = 0;
  787. p && (A[0] = [t]);
  788. for (let W = 0, oa, P; W < m.length; W++) {
  789. if (oa = m[W], C = (P = this.tagindex[oa]) && P.length) {
  790. H++, A[A.length] = p ? [P] : P;
  791. }
  792. }
  793. H && (t = p ? ka(A, b || 100, u || 0) : la(t, A), C = t.length);
  794. }
  795. if (C) {
  796. f[q] = y, e[q++] = t;
  797. } else {
  798. if (p) {
  799. return [];
  800. }
  801. }
  802. }
  803. }
  804. if (n) {
  805. const l = this;
  806. return new Promise(function(t) {
  807. Promise.all(n).then(function(y) {
  808. t(l.search(a, b, c, y));
  809. });
  810. });
  811. }
  812. if (!q) {
  813. return [];
  814. }
  815. if (g && (!h || !this.store)) {
  816. return e[0];
  817. }
  818. for (let l = 0, t; l < f.length; l++) {
  819. t = e[l];
  820. t.length && h && (t = wa.call(this, t));
  821. if (g) {
  822. return t;
  823. }
  824. e[l] = {field:f[l], result:t};
  825. }
  826. return e;
  827. };
  828. function va(a, b, c, d) {
  829. let e = this.tagindex[a], f = e && e.length - c;
  830. if (f && 0 < f) {
  831. if (f > b || c) {
  832. e = e.slice(c, c + b);
  833. }
  834. d && (e = wa.call(this, e));
  835. return {tag:a, result:e};
  836. }
  837. }
  838. function wa(a) {
  839. const b = Array(a.length);
  840. for (let c = 0, d; c < a.length; c++) {
  841. d = a[c], b[c] = {id:d, doc:this.store[d]};
  842. }
  843. return b;
  844. }
  845. R.prototype.contain = function(a) {
  846. return !!this.register[a];
  847. };
  848. R.prototype.get = function(a) {
  849. return this.store[a];
  850. };
  851. R.prototype.set = function(a, b) {
  852. this.store[a] = b;
  853. return this;
  854. };
  855. R.prototype.searchCache = ma;
  856. R.prototype.export = function(a, b, c, d, e) {
  857. e || (e = 0);
  858. d || (d = 0);
  859. if (d < this.field.length) {
  860. const f = this.field[d], g = this.index[f];
  861. b = this;
  862. setTimeout(function() {
  863. g.export(a, b, e ? f.replace(":", "-") : "", d, e++) || (d++, e = 1, b.export(a, b, f, d, e));
  864. });
  865. } else {
  866. let f;
  867. switch(e) {
  868. case 1:
  869. c = "tag";
  870. f = this.tagindex;
  871. break;
  872. case 2:
  873. c = "store";
  874. f = this.store;
  875. break;
  876. default:
  877. return;
  878. }
  879. pa(a, this, c, d, e, f);
  880. }
  881. };
  882. R.prototype.import = function(a, b) {
  883. if (b) {
  884. switch(x(b) && (b = JSON.parse(b)), a) {
  885. case "tag":
  886. this.tagindex = b;
  887. break;
  888. case "reg":
  889. this.fastupdate = !1;
  890. this.register = b;
  891. for (let d = 0, e; d < this.field.length; d++) {
  892. e = this.index[this.field[d]], e.register = b, e.fastupdate = !1;
  893. }
  894. break;
  895. case "store":
  896. this.store = b;
  897. break;
  898. default:
  899. a = a.split(".");
  900. const c = a[0];
  901. a = a[1];
  902. c && a && this.index[c].import(a, b);
  903. }
  904. }
  905. };
  906. ja(R.prototype);
  907. var ya = {encode:xa, rtl:!1, tokenize:""};
  908. const za = G("[\u00e0\u00e1\u00e2\u00e3\u00e4\u00e5]"), Aa = G("[\u00e8\u00e9\u00ea\u00eb]"), Ba = G("[\u00ec\u00ed\u00ee\u00ef]"), Ca = G("[\u00f2\u00f3\u00f4\u00f5\u00f6\u0151]"), Da = G("[\u00f9\u00fa\u00fb\u00fc\u0171]"), Ea = G("[\u00fd\u0177\u00ff]"), Fa = G("\u00f1"), Ga = G("[\u00e7c]"), Ha = G("\u00df"), Ia = G(" & "), Ja = [za, "a", Aa, "e", Ba, "i", Ca, "o", Da, "u", Ea, "y", Fa, "n", Ga, "k", Ha, "s", Ia, " and "];
  909. function xa(a) {
  910. var b = a = "" + a;
  911. b.normalize && (b = b.normalize("NFD").replace(da, ""));
  912. return ba.call(this, b.toLowerCase(), !a.normalize && Ja, ca, !1);
  913. }
  914. ;var La = {encode:Ka, rtl:!1, tokenize:"strict"};
  915. const Ma = /[^a-z0-9]+/, Na = {b:"p", v:"f", w:"f", z:"s", x:"s", "\u00df":"s", d:"t", n:"m", c:"k", g:"k", j:"k", q:"k", i:"e", y:"e", u:"o"};
  916. function Ka(a) {
  917. a = xa.call(this, a).join(" ");
  918. const b = [];
  919. if (a) {
  920. const c = a.split(Ma), d = c.length;
  921. for (let e = 0, f, g = 0; e < d; e++) {
  922. if ((a = c[e]) && (!this.filter || !this.filter[a])) {
  923. f = a[0];
  924. let h = Na[f] || f, k = h;
  925. for (let m = 1; m < a.length; m++) {
  926. f = a[m];
  927. const p = Na[f] || f;
  928. p && p !== k && (h += p, k = p);
  929. }
  930. b[g++] = h;
  931. }
  932. }
  933. }
  934. return b;
  935. }
  936. ;var Pa = {encode:Oa, rtl:!1, tokenize:""};
  937. const Qa = G("ae"), Ra = G("oe"), Sa = G("sh"), Ta = G("th"), Ua = G("ph"), Va = G("pf"), Wa = [Qa, "a", Ra, "o", Sa, "s", Ta, "t", Ua, "f", Va, "f", G("(?![aeo])h(?![aeo])"), "", G("(?!^[aeo])h(?!^[aeo])"), ""];
  938. function Oa(a, b) {
  939. a && (a = Ka.call(this, a).join(" "), 2 < a.length && (a = E(a, Wa)), b || (1 < a.length && (a = F(a)), a && (a = a.split(" "))));
  940. return a;
  941. }
  942. ;var Ya = {encode:Xa, rtl:!1, tokenize:""};
  943. const Za = G("(?!\\b)[aeo]");
  944. function Xa(a) {
  945. a && (a = Oa.call(this, a, !0), 1 < a.length && (a = a.replace(Za, "")), 1 < a.length && (a = F(a)), a && (a = a.split(" ")));
  946. return a;
  947. }
  948. ;I["latin:default"] = ha;
  949. I["latin:simple"] = ya;
  950. I["latin:balance"] = La;
  951. I["latin:advanced"] = Pa;
  952. I["latin:extra"] = Ya;
  953. const X = self;
  954. let Y;
  955. const Z = {Index:L, Document:R, Worker:O, registerCharset:function(a, b) {
  956. I[a] = b;
  957. }, registerLanguage:function(a, b) {
  958. ia[a] = b;
  959. }};
  960. (Y = X.define) && Y.amd ? Y([], function() {
  961. return Z;
  962. }) : X.exports ? X.exports = Z : X.FlexSearch = Z;
  963. }(this));