@peam-ai/next 0.1.3 → 0.1.4

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.
package/dist/index.js CHANGED
@@ -1,17 +1,136 @@
1
1
  'use strict';
2
2
 
3
3
  var fs = require('fs');
4
- var path = require('path');
5
4
  var logger = require('peam/logger');
6
5
  var parser = require('peam/parser');
7
6
  var search = require('peam/search');
7
+ var fs$1 = require('fs/promises');
8
+ var path = require('path');
9
+
10
+ function _interopNamespace(e) {
11
+ if (e && e.__esModule) return e;
12
+ var n = Object.create(null);
13
+ if (e) {
14
+ Object.keys(e).forEach(function (k) {
15
+ if (k !== 'default') {
16
+ var d = Object.getOwnPropertyDescriptor(e, k);
17
+ Object.defineProperty(n, k, d.get ? d : {
18
+ enumerable: true,
19
+ get: function () { return e[k]; }
20
+ });
21
+ }
22
+ });
23
+ }
24
+ n.default = e;
25
+ return Object.freeze(n);
26
+ }
27
+
28
+ var fs__namespace = /*#__PURE__*/_interopNamespace(fs$1);
29
+ var path__namespace = /*#__PURE__*/_interopNamespace(path);
8
30
 
31
+ var __create = Object.create;
32
+ var __defProp = Object.defineProperty;
33
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
34
+ var __getOwnPropNames = Object.getOwnPropertyNames;
35
+ var __getProtoOf = Object.getPrototypeOf;
36
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
37
  var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
10
38
  get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
11
39
  }) : x)(function(x) {
12
40
  if (typeof require !== "undefined") return require.apply(this, arguments);
13
41
  throw Error('Dynamic require of "' + x + '" is not supported');
14
42
  });
43
+ var __commonJS = (cb2, mod) => function __require2() {
44
+ return mod || (0, cb2[__getOwnPropNames(cb2)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
45
+ };
46
+ var __copyProps = (to, from, except, desc) => {
47
+ if (from && typeof from === "object" || typeof from === "function") {
48
+ for (let key of __getOwnPropNames(from))
49
+ if (!__hasOwnProp.call(to, key) && key !== except)
50
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
51
+ }
52
+ return to;
53
+ };
54
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
55
+ // If the importer is in node compatibility mode or this is not an ESM
56
+ // file that has been converted to a CommonJS file using a Babel-
57
+ // compatible transform (i.e. "__esModule" has not been set), then set
58
+ // "default" to the CommonJS "module.exports" for node compatibility.
59
+ __defProp(target, "default", { value: mod, enumerable: true }) ,
60
+ mod
61
+ ));
62
+
63
+ // ../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js
64
+ var require_picocolors = __commonJS({
65
+ "../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js"(exports$1, module2) {
66
+ var p = process || {};
67
+ var argv = p.argv || [];
68
+ var env = p.env || {};
69
+ var isColorSupported = !(!!env.NO_COLOR || argv.includes("--no-color")) && (!!env.FORCE_COLOR || argv.includes("--color") || p.platform === "win32" || (p.stdout || {}).isTTY && env.TERM !== "dumb" || !!env.CI);
70
+ var formatter = (open, close, replace = open) => (input) => {
71
+ let string = "" + input, index = string.indexOf(close, open.length);
72
+ return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close;
73
+ };
74
+ var replaceClose = (string, close, replace, index) => {
75
+ let result = "", cursor = 0;
76
+ do {
77
+ result += string.substring(cursor, index) + replace;
78
+ cursor = index + close.length;
79
+ index = string.indexOf(close, cursor);
80
+ } while (~index);
81
+ return result + string.substring(cursor);
82
+ };
83
+ var createColors = (enabled = isColorSupported) => {
84
+ let f = enabled ? formatter : () => String;
85
+ return {
86
+ isColorSupported: enabled,
87
+ reset: f("\x1B[0m", "\x1B[0m"),
88
+ bold: f("\x1B[1m", "\x1B[22m", "\x1B[22m\x1B[1m"),
89
+ dim: f("\x1B[2m", "\x1B[22m", "\x1B[22m\x1B[2m"),
90
+ italic: f("\x1B[3m", "\x1B[23m"),
91
+ underline: f("\x1B[4m", "\x1B[24m"),
92
+ inverse: f("\x1B[7m", "\x1B[27m"),
93
+ hidden: f("\x1B[8m", "\x1B[28m"),
94
+ strikethrough: f("\x1B[9m", "\x1B[29m"),
95
+ black: f("\x1B[30m", "\x1B[39m"),
96
+ red: f("\x1B[31m", "\x1B[39m"),
97
+ green: f("\x1B[32m", "\x1B[39m"),
98
+ yellow: f("\x1B[33m", "\x1B[39m"),
99
+ blue: f("\x1B[34m", "\x1B[39m"),
100
+ magenta: f("\x1B[35m", "\x1B[39m"),
101
+ cyan: f("\x1B[36m", "\x1B[39m"),
102
+ white: f("\x1B[37m", "\x1B[39m"),
103
+ gray: f("\x1B[90m", "\x1B[39m"),
104
+ bgBlack: f("\x1B[40m", "\x1B[49m"),
105
+ bgRed: f("\x1B[41m", "\x1B[49m"),
106
+ bgGreen: f("\x1B[42m", "\x1B[49m"),
107
+ bgYellow: f("\x1B[43m", "\x1B[49m"),
108
+ bgBlue: f("\x1B[44m", "\x1B[49m"),
109
+ bgMagenta: f("\x1B[45m", "\x1B[49m"),
110
+ bgCyan: f("\x1B[46m", "\x1B[49m"),
111
+ bgWhite: f("\x1B[47m", "\x1B[49m"),
112
+ blackBright: f("\x1B[90m", "\x1B[39m"),
113
+ redBright: f("\x1B[91m", "\x1B[39m"),
114
+ greenBright: f("\x1B[92m", "\x1B[39m"),
115
+ yellowBright: f("\x1B[93m", "\x1B[39m"),
116
+ blueBright: f("\x1B[94m", "\x1B[39m"),
117
+ magentaBright: f("\x1B[95m", "\x1B[39m"),
118
+ cyanBright: f("\x1B[96m", "\x1B[39m"),
119
+ whiteBright: f("\x1B[97m", "\x1B[39m"),
120
+ bgBlackBright: f("\x1B[100m", "\x1B[49m"),
121
+ bgRedBright: f("\x1B[101m", "\x1B[49m"),
122
+ bgGreenBright: f("\x1B[102m", "\x1B[49m"),
123
+ bgYellowBright: f("\x1B[103m", "\x1B[49m"),
124
+ bgBlueBright: f("\x1B[104m", "\x1B[49m"),
125
+ bgMagentaBright: f("\x1B[105m", "\x1B[49m"),
126
+ bgCyanBright: f("\x1B[106m", "\x1B[49m"),
127
+ bgWhiteBright: f("\x1B[107m", "\x1B[49m")
128
+ };
129
+ };
130
+ module2.exports = createColors();
131
+ module2.exports.createColors = createColors;
132
+ }
133
+ });
15
134
  var log = logger.loggers.adapter;
16
135
  function extractRobotsFromPrerender(prerender) {
17
136
  var _a;
@@ -123,52 +242,2433 @@ function createPeamAdapter(config) {
123
242
  log.error("Error processing", pathname, error);
124
243
  }
125
244
  }
126
- const outputPath = path.join(projectDir, config.outputDir);
127
- fs.mkdirSync(outputPath, { recursive: true });
128
245
  log.debug("Creating search index...");
129
246
  const searchIndexData = await search.buildSearchIndex(pages);
130
- const generatedPath = path.join(outputPath, "generated");
131
- fs.mkdirSync(generatedPath, { recursive: true });
132
- const searchIndexFile = path.join(generatedPath, config.indexFilename);
133
- fs.writeFileSync(searchIndexFile, JSON.stringify(searchIndexData));
134
- const indexJsContent = `// Auto-generated by Peam - DO NOT EDIT THIS FILE
135
- import index from "./generated/${config.indexFilename}";
136
- export default index;
137
- `;
138
- const indexJsFile = path.join(outputPath, "index.js");
139
- fs.writeFileSync(indexJsFile, indexJsContent);
140
- log.debug("Saved search index to:", searchIndexFile);
247
+ await config.searchIndexExporter.export(searchIndexData);
248
+ log.debug("Saved search index via exporter");
141
249
  log.debug("Extraction complete with total pages:", pages.length);
142
250
  }
143
251
  };
144
252
  }
145
253
 
254
+ // ../logger/dist/index.mjs
255
+ var import_picocolors = __toESM(require_picocolors());
256
+ var PEAM_LOGGING_KEY = "PEAM_LOGGING";
257
+ function readBrowserLoggingSetting() {
258
+ var _a;
259
+ try {
260
+ const g = globalThis;
261
+ if (!g.localStorage) return void 0;
262
+ return (_a = g.localStorage.getItem(PEAM_LOGGING_KEY)) != null ? _a : void 0;
263
+ } catch (e) {
264
+ return void 0;
265
+ }
266
+ }
267
+ function readServerLoggingSetting() {
268
+ try {
269
+ return typeof process !== "undefined" && typeof process.env !== "undefined" && PEAM_LOGGING_KEY in process.env ? process.env[PEAM_LOGGING_KEY] : void 0;
270
+ } catch (e) {
271
+ return void 0;
272
+ }
273
+ }
274
+ function isLoggingEnabled() {
275
+ const serverSetting = readServerLoggingSetting();
276
+ if (serverSetting !== void 0) return Boolean(serverSetting);
277
+ const browserSetting = readBrowserLoggingSetting();
278
+ if (browserSetting !== void 0) return Boolean(browserSetting);
279
+ return false;
280
+ }
281
+ function createLogger(namespace) {
282
+ return {
283
+ error: (message, ...args) => print(message, args, { namespace, color: "red" }),
284
+ warn: (message, ...args) => print(message, args, { namespace, color: "yellow" }),
285
+ debug: (message, ...args) => print(message, args, { namespace, color: "yellow" })
286
+ };
287
+ }
288
+ function print(message, args, { namespace, color = "white" }) {
289
+ var _a;
290
+ if (!isLoggingEnabled()) return;
291
+ const colorize = (_a = import_picocolors.default[color]) != null ? _a : import_picocolors.default.white;
292
+ const header = `${colorize("[Peam]")} `;
293
+ const ns = namespace ? `${import_picocolors.default.dim(namespace)} ` : "";
294
+ console.log(header + ns + colorize(String(message)), ...args);
295
+ }
296
+ var loggers2 = {
297
+ search: createLogger("peam:search")
298
+ };
299
+
300
+ // ../../node_modules/.pnpm/flexsearch@0.8.212/node_modules/flexsearch/dist/flexsearch.bundle.module.min.mjs
301
+ var import_meta = {};
302
+ var w;
303
+ function H(a, c, b) {
304
+ const e = typeof b, d = typeof a;
305
+ if (e !== "undefined") {
306
+ if (d !== "undefined") {
307
+ if (b) {
308
+ if (d === "function" && e === d) return function(k) {
309
+ return a(b(k));
310
+ };
311
+ c = a.constructor;
312
+ if (c === b.constructor) {
313
+ if (c === Array) return b.concat(a);
314
+ if (c === Map) {
315
+ var f = new Map(b);
316
+ for (var g of a) f.set(g[0], g[1]);
317
+ return f;
318
+ }
319
+ if (c === Set) {
320
+ g = new Set(b);
321
+ for (f of a.values()) g.add(f);
322
+ return g;
323
+ }
324
+ }
325
+ }
326
+ return a;
327
+ }
328
+ return b;
329
+ }
330
+ return d === "undefined" ? c : a;
331
+ }
332
+ function aa(a, c) {
333
+ return typeof a === "undefined" ? c : a;
334
+ }
335
+ function I() {
336
+ return /* @__PURE__ */ Object.create(null);
337
+ }
338
+ function M(a) {
339
+ return typeof a === "string";
340
+ }
341
+ function ba(a) {
342
+ return typeof a === "object";
343
+ }
344
+ function ca(a, c) {
345
+ if (M(c)) a = a[c];
346
+ else for (let b = 0; a && b < c.length; b++) a = a[c[b]];
347
+ return a;
348
+ }
349
+ var ea = /[^\p{L}\p{N}]+/u;
350
+ var fa = /(\d{3})/g;
351
+ var ha = /(\D)(\d{3})/g;
352
+ var ia = /(\d{3})(\D)/g;
353
+ var ja = /[\u0300-\u036f]/g;
354
+ function ka(a = {}) {
355
+ if (!this || this.constructor !== ka) return new ka(...arguments);
356
+ if (arguments.length) for (a = 0; a < arguments.length; a++) this.assign(arguments[a]);
357
+ else this.assign(a);
358
+ }
359
+ w = ka.prototype;
360
+ w.assign = function(a) {
361
+ this.normalize = H(a.normalize, true, this.normalize);
362
+ let c = a.include, b = c || a.exclude || a.split, e;
363
+ if (b || b === "") {
364
+ if (typeof b === "object" && b.constructor !== RegExp) {
365
+ let d = "";
366
+ e = !c;
367
+ c || (d += "\\p{Z}");
368
+ b.letter && (d += "\\p{L}");
369
+ b.number && (d += "\\p{N}", e = !!c);
370
+ b.symbol && (d += "\\p{S}");
371
+ b.punctuation && (d += "\\p{P}");
372
+ b.control && (d += "\\p{C}");
373
+ if (b = b.char) d += typeof b === "object" ? b.join("") : b;
374
+ try {
375
+ this.split = new RegExp("[" + (c ? "^" : "") + d + "]+", "u");
376
+ } catch (f) {
377
+ this.split = /\s+/;
378
+ }
379
+ } else this.split = b, e = b === false || "a1a".split(b).length < 2;
380
+ this.numeric = H(a.numeric, e);
381
+ } else {
382
+ try {
383
+ this.split = H(this.split, ea);
384
+ } catch (d) {
385
+ this.split = /\s+/;
386
+ }
387
+ this.numeric = H(a.numeric, H(this.numeric, true));
388
+ }
389
+ this.prepare = H(a.prepare, null, this.prepare);
390
+ this.finalize = H(a.finalize, null, this.finalize);
391
+ b = a.filter;
392
+ this.filter = typeof b === "function" ? b : H(b && new Set(b), null, this.filter);
393
+ this.dedupe = H(a.dedupe, true, this.dedupe);
394
+ this.matcher = H((b = a.matcher) && new Map(b), null, this.matcher);
395
+ this.mapper = H((b = a.mapper) && new Map(b), null, this.mapper);
396
+ this.stemmer = H(
397
+ (b = a.stemmer) && new Map(b),
398
+ null,
399
+ this.stemmer
400
+ );
401
+ this.replacer = H(a.replacer, null, this.replacer);
402
+ this.minlength = H(a.minlength, 1, this.minlength);
403
+ this.maxlength = H(a.maxlength, 1024, this.maxlength);
404
+ this.rtl = H(a.rtl, false, this.rtl);
405
+ if (this.cache = b = H(a.cache, true, this.cache)) this.F = null, this.L = typeof b === "number" ? b : 2e5, this.B = /* @__PURE__ */ new Map(), this.D = /* @__PURE__ */ new Map(), this.I = this.H = 128;
406
+ this.h = "";
407
+ this.J = null;
408
+ this.A = "";
409
+ this.K = null;
410
+ if (this.matcher) for (const d of this.matcher.keys()) this.h += (this.h ? "|" : "") + d;
411
+ if (this.stemmer) for (const d of this.stemmer.keys()) this.A += (this.A ? "|" : "") + d;
412
+ return this;
413
+ };
414
+ w.addStemmer = function(a, c) {
415
+ this.stemmer || (this.stemmer = /* @__PURE__ */ new Map());
416
+ this.stemmer.set(a, c);
417
+ this.A += (this.A ? "|" : "") + a;
418
+ this.K = null;
419
+ this.cache && Q(this);
420
+ return this;
421
+ };
422
+ w.addFilter = function(a) {
423
+ typeof a === "function" ? this.filter = a : (this.filter || (this.filter = /* @__PURE__ */ new Set()), this.filter.add(a));
424
+ this.cache && Q(this);
425
+ return this;
426
+ };
427
+ w.addMapper = function(a, c) {
428
+ if (typeof a === "object") return this.addReplacer(a, c);
429
+ if (a.length > 1) return this.addMatcher(a, c);
430
+ this.mapper || (this.mapper = /* @__PURE__ */ new Map());
431
+ this.mapper.set(a, c);
432
+ this.cache && Q(this);
433
+ return this;
434
+ };
435
+ w.addMatcher = function(a, c) {
436
+ if (typeof a === "object") return this.addReplacer(a, c);
437
+ if (a.length < 2 && (this.dedupe || this.mapper)) return this.addMapper(a, c);
438
+ this.matcher || (this.matcher = /* @__PURE__ */ new Map());
439
+ this.matcher.set(a, c);
440
+ this.h += (this.h ? "|" : "") + a;
441
+ this.J = null;
442
+ this.cache && Q(this);
443
+ return this;
444
+ };
445
+ w.addReplacer = function(a, c) {
446
+ if (typeof a === "string") return this.addMatcher(a, c);
447
+ this.replacer || (this.replacer = []);
448
+ this.replacer.push(a, c);
449
+ this.cache && Q(this);
450
+ return this;
451
+ };
452
+ w.encode = function(a, c) {
453
+ if (this.cache && a.length <= this.H) if (this.F) {
454
+ if (this.B.has(a)) return this.B.get(a);
455
+ } else this.F = setTimeout(Q, 50, this);
456
+ this.normalize && (typeof this.normalize === "function" ? a = this.normalize(a) : a = ja ? a.normalize("NFKD").replace(ja, "").toLowerCase() : a.toLowerCase());
457
+ this.prepare && (a = this.prepare(a));
458
+ this.numeric && a.length > 3 && (a = a.replace(ha, "$1 $2").replace(ia, "$1 $2").replace(fa, "$1 "));
459
+ const b = !(this.dedupe || this.mapper || this.filter || this.matcher || this.stemmer || this.replacer);
460
+ let e = [], d = I(), f, g, k = this.split || this.split === "" ? a.split(this.split) : [a];
461
+ for (let l = 0, m, p; l < k.length; l++) if ((m = p = k[l]) && !(m.length < this.minlength || m.length > this.maxlength)) {
462
+ if (c) {
463
+ if (d[m]) continue;
464
+ d[m] = 1;
465
+ } else {
466
+ if (f === m) continue;
467
+ f = m;
468
+ }
469
+ if (b) e.push(m);
470
+ else if (!this.filter || (typeof this.filter === "function" ? this.filter(m) : !this.filter.has(m))) {
471
+ if (this.cache && m.length <= this.I) if (this.F) {
472
+ var h = this.D.get(m);
473
+ if (h || h === "") {
474
+ h && e.push(h);
475
+ continue;
476
+ }
477
+ } else this.F = setTimeout(Q, 50, this);
478
+ if (this.stemmer) {
479
+ this.K || (this.K = new RegExp("(?!^)(" + this.A + ")$"));
480
+ let u;
481
+ for (; u !== m && m.length > 2; ) u = m, m = m.replace(this.K, (r) => this.stemmer.get(r));
482
+ }
483
+ if (m && (this.mapper || this.dedupe && m.length > 1)) {
484
+ h = "";
485
+ for (let u = 0, r = "", t, n; u < m.length; u++) t = m.charAt(u), t === r && this.dedupe || ((n = this.mapper && this.mapper.get(t)) || n === "" ? n === r && this.dedupe || !(r = n) || (h += n) : h += r = t);
486
+ m = h;
487
+ }
488
+ this.matcher && m.length > 1 && (this.J || (this.J = new RegExp("(" + this.h + ")", "g")), m = m.replace(this.J, (u) => this.matcher.get(u)));
489
+ if (m && this.replacer) for (h = 0; m && h < this.replacer.length; h += 2) m = m.replace(
490
+ this.replacer[h],
491
+ this.replacer[h + 1]
492
+ );
493
+ this.cache && p.length <= this.I && (this.D.set(p, m), this.D.size > this.L && (this.D.clear(), this.I = this.I / 1.1 | 0));
494
+ if (m) {
495
+ if (m !== p) if (c) {
496
+ if (d[m]) continue;
497
+ d[m] = 1;
498
+ } else {
499
+ if (g === m) continue;
500
+ g = m;
501
+ }
502
+ e.push(m);
503
+ }
504
+ }
505
+ }
506
+ this.finalize && (e = this.finalize(e) || e);
507
+ this.cache && a.length <= this.H && (this.B.set(a, e), this.B.size > this.L && (this.B.clear(), this.H = this.H / 1.1 | 0));
508
+ return e;
509
+ };
510
+ function Q(a) {
511
+ a.F = null;
512
+ a.B.clear();
513
+ a.D.clear();
514
+ }
515
+ function la(a, c, b) {
516
+ b || (c || typeof a !== "object" ? typeof c === "object" && (b = c, c = 0) : b = a);
517
+ b && (a = b.query || a, c = b.limit || c);
518
+ let e = "" + (c || 0);
519
+ b && (e += (b.offset || 0) + !!b.context + !!b.suggest + (b.resolve !== false) + (b.resolution || this.resolution) + (b.boost || 0));
520
+ a = ("" + a).toLowerCase();
521
+ this.cache || (this.cache = new ma());
522
+ let d = this.cache.get(a + e);
523
+ if (!d) {
524
+ const f = b && b.cache;
525
+ f && (b.cache = false);
526
+ d = this.search(a, c, b);
527
+ f && (b.cache = f);
528
+ this.cache.set(a + e, d);
529
+ }
530
+ return d;
531
+ }
532
+ function ma(a) {
533
+ this.limit = a && a !== true ? a : 1e3;
534
+ this.cache = /* @__PURE__ */ new Map();
535
+ this.h = "";
536
+ }
537
+ ma.prototype.set = function(a, c) {
538
+ this.cache.set(this.h = a, c);
539
+ this.cache.size > this.limit && this.cache.delete(this.cache.keys().next().value);
540
+ };
541
+ ma.prototype.get = function(a) {
542
+ const c = this.cache.get(a);
543
+ c && this.h !== a && (this.cache.delete(a), this.cache.set(this.h = a, c));
544
+ return c;
545
+ };
546
+ ma.prototype.remove = function(a) {
547
+ for (const c of this.cache) {
548
+ const b = c[0];
549
+ c[1].includes(a) && this.cache.delete(b);
550
+ }
551
+ };
552
+ ma.prototype.clear = function() {
553
+ this.cache.clear();
554
+ this.h = "";
555
+ };
556
+ var na = { normalize: false, numeric: false, dedupe: false };
557
+ var oa = {};
558
+ var ra = /* @__PURE__ */ new Map([["b", "p"], ["v", "f"], ["w", "f"], ["z", "s"], ["x", "s"], ["d", "t"], ["n", "m"], ["c", "k"], ["g", "k"], ["j", "k"], ["q", "k"], ["i", "e"], ["y", "e"], ["u", "o"]]);
559
+ var sa = /* @__PURE__ */ new Map([["ae", "a"], ["oe", "o"], ["sh", "s"], ["kh", "k"], ["th", "t"], ["ph", "f"], ["pf", "f"]]);
560
+ var ta = [/([^aeo])h(.)/g, "$1$2", /([aeo])h([^aeo]|$)/g, "$1$2", /(.)\1+/g, "$1"];
561
+ var ua = { a: "", e: "", i: "", o: "", u: "", y: "", b: 1, f: 1, p: 1, v: 1, c: 2, g: 2, j: 2, k: 2, q: 2, s: 2, x: 2, z: 2, "\xDF": 2, d: 3, t: 3, l: 4, m: 5, n: 5, r: 6 };
562
+ var va = { Exact: na, Default: oa, Normalize: oa, LatinBalance: { mapper: ra }, LatinAdvanced: { mapper: ra, matcher: sa, replacer: ta }, LatinExtra: { mapper: ra, replacer: ta.concat([/(?!^)[aeo]/g, ""]), matcher: sa }, LatinSoundex: { dedupe: false, include: { letter: true }, finalize: function(a) {
563
+ for (let b = 0; b < a.length; b++) {
564
+ var c = a[b];
565
+ let e = c.charAt(0), d = ua[e];
566
+ for (let f = 1, g; f < c.length && (g = c.charAt(f), g === "h" || g === "w" || !(g = ua[g]) || g === d || (e += g, d = g, e.length !== 4)); f++) ;
567
+ a[b] = e;
568
+ }
569
+ } }, CJK: { split: "" }, LatinExact: na, LatinDefault: oa, LatinSimple: oa };
570
+ function wa(a, c, b, e) {
571
+ let d = [];
572
+ for (let f = 0, g; f < a.index.length; f++) if (g = a.index[f], c >= g.length) c -= g.length;
573
+ else {
574
+ c = g[e ? "splice" : "slice"](c, b);
575
+ const k = c.length;
576
+ if (k && (d = d.length ? d.concat(c) : c, b -= k, e && (a.length -= k), !b)) break;
577
+ c = 0;
578
+ }
579
+ return d;
580
+ }
581
+ function xa(a) {
582
+ if (!this || this.constructor !== xa) return new xa(a);
583
+ this.index = a ? [a] : [];
584
+ this.length = a ? a.length : 0;
585
+ const c = this;
586
+ return new Proxy([], { get(b, e) {
587
+ if (e === "length") return c.length;
588
+ if (e === "push") return function(d) {
589
+ c.index[c.index.length - 1].push(d);
590
+ c.length++;
591
+ };
592
+ if (e === "pop") return function() {
593
+ if (c.length) return c.length--, c.index[c.index.length - 1].pop();
594
+ };
595
+ if (e === "indexOf") return function(d) {
596
+ let f = 0;
597
+ for (let g = 0, k, h; g < c.index.length; g++) {
598
+ k = c.index[g];
599
+ h = k.indexOf(d);
600
+ if (h >= 0) return f + h;
601
+ f += k.length;
602
+ }
603
+ return -1;
604
+ };
605
+ if (e === "includes") return function(d) {
606
+ for (let f = 0; f < c.index.length; f++) if (c.index[f].includes(d)) return true;
607
+ return false;
608
+ };
609
+ if (e === "slice") return function(d, f) {
610
+ return wa(c, d || 0, f || c.length, false);
611
+ };
612
+ if (e === "splice") return function(d, f) {
613
+ return wa(c, d || 0, f || c.length, true);
614
+ };
615
+ if (e === "constructor") return Array;
616
+ if (typeof e !== "symbol") return (b = c.index[e / 2 ** 31 | 0]) && b[e];
617
+ }, set(b, e, d) {
618
+ b = e / 2 ** 31 | 0;
619
+ (c.index[b] || (c.index[b] = []))[e] = d;
620
+ c.length++;
621
+ return true;
622
+ } });
623
+ }
624
+ xa.prototype.clear = function() {
625
+ this.index.length = 0;
626
+ };
627
+ xa.prototype.push = function() {
628
+ };
629
+ function R(a = 8) {
630
+ if (!this || this.constructor !== R) return new R(a);
631
+ this.index = I();
632
+ this.h = [];
633
+ this.size = 0;
634
+ a > 32 ? (this.B = Aa, this.A = BigInt(a)) : (this.B = Ba, this.A = a);
635
+ }
636
+ R.prototype.get = function(a) {
637
+ const c = this.index[this.B(a)];
638
+ return c && c.get(a);
639
+ };
640
+ R.prototype.set = function(a, c) {
641
+ var b = this.B(a);
642
+ let e = this.index[b];
643
+ e ? (b = e.size, e.set(a, c), (b -= e.size) && this.size++) : (this.index[b] = e = /* @__PURE__ */ new Map([[a, c]]), this.h.push(e), this.size++);
644
+ };
645
+ function S(a = 8) {
646
+ if (!this || this.constructor !== S) return new S(a);
647
+ this.index = I();
648
+ this.h = [];
649
+ this.size = 0;
650
+ a > 32 ? (this.B = Aa, this.A = BigInt(a)) : (this.B = Ba, this.A = a);
651
+ }
652
+ S.prototype.add = function(a) {
653
+ var c = this.B(a);
654
+ let b = this.index[c];
655
+ b ? (c = b.size, b.add(a), (c -= b.size) && this.size++) : (this.index[c] = b = /* @__PURE__ */ new Set([a]), this.h.push(b), this.size++);
656
+ };
657
+ w = R.prototype;
658
+ w.has = S.prototype.has = function(a) {
659
+ const c = this.index[this.B(a)];
660
+ return c && c.has(a);
661
+ };
662
+ w.delete = S.prototype.delete = function(a) {
663
+ const c = this.index[this.B(a)];
664
+ c && c.delete(a) && this.size--;
665
+ };
666
+ w.clear = S.prototype.clear = function() {
667
+ this.index = I();
668
+ this.h = [];
669
+ this.size = 0;
670
+ };
671
+ w.values = S.prototype.values = function* () {
672
+ for (let a = 0; a < this.h.length; a++) for (let c of this.h[a].values()) yield c;
673
+ };
674
+ w.keys = S.prototype.keys = function* () {
675
+ for (let a = 0; a < this.h.length; a++) for (let c of this.h[a].keys()) yield c;
676
+ };
677
+ w.entries = S.prototype.entries = function* () {
678
+ for (let a = 0; a < this.h.length; a++) for (let c of this.h[a].entries()) yield c;
679
+ };
680
+ function Ba(a) {
681
+ let c = 2 ** this.A - 1;
682
+ if (typeof a == "number") return a & c;
683
+ let b = 0, e = this.A + 1;
684
+ for (let d = 0; d < a.length; d++) b = (b * e ^ a.charCodeAt(d)) & c;
685
+ return this.A === 32 ? b + 2 ** 31 : b;
686
+ }
687
+ function Aa(a) {
688
+ let c = BigInt(2) ** this.A - BigInt(1);
689
+ var b = typeof a;
690
+ if (b === "bigint") return a & c;
691
+ if (b === "number") return BigInt(a) & c;
692
+ b = BigInt(0);
693
+ let e = this.A + BigInt(1);
694
+ for (let d = 0; d < a.length; d++) b = (b * e ^ BigInt(a.charCodeAt(d))) & c;
695
+ return b;
696
+ }
697
+ var Ca;
698
+ var Da;
699
+ async function Ea(a) {
700
+ a = a.data;
701
+ var c = a.task;
702
+ const b = a.id;
703
+ let e = a.args;
704
+ switch (c) {
705
+ case "init":
706
+ Da = a.options || {};
707
+ (c = a.factory) ? (Function("return " + c)()(self), Ca = new self.FlexSearch.Index(Da), delete self.FlexSearch) : Ca = new T(Da);
708
+ postMessage({ id: b });
709
+ break;
710
+ default:
711
+ let d;
712
+ c === "export" && (e[1] ? (e[0] = Da.export, e[2] = 0, e[3] = 1) : e = null);
713
+ c === "import" ? e[0] && (a = await Da.import.call(Ca, e[0]), Ca.import(e[0], a)) : ((d = e && Ca[c].apply(Ca, e)) && d.then && (d = await d), d && d.await && (d = await d.await), c === "search" && d.result && (d = d.result));
714
+ postMessage(c === "search" ? { id: b, msg: d } : { id: b });
715
+ }
716
+ }
717
+ function Fa(a) {
718
+ Ga.call(a, "add");
719
+ Ga.call(a, "append");
720
+ Ga.call(a, "search");
721
+ Ga.call(a, "update");
722
+ Ga.call(a, "remove");
723
+ Ga.call(a, "searchCache");
724
+ }
725
+ var Ha;
726
+ var Ia;
727
+ var Ja;
728
+ function Ka() {
729
+ Ha = Ja = 0;
730
+ }
731
+ function Ga(a) {
732
+ this[a + "Async"] = function() {
733
+ const c = arguments;
734
+ var b = c[c.length - 1];
735
+ let e;
736
+ typeof b === "function" && (e = b, delete c[c.length - 1]);
737
+ Ha ? Ja || (Ja = Date.now() - Ia >= this.priority * this.priority * 3) : (Ha = setTimeout(Ka, 0), Ia = Date.now());
738
+ if (Ja) {
739
+ const f = this;
740
+ return new Promise((g) => {
741
+ setTimeout(function() {
742
+ g(f[a + "Async"].apply(f, c));
743
+ }, 0);
744
+ });
745
+ }
746
+ const d = this[a].apply(this, c);
747
+ b = d.then ? d : new Promise((f) => f(d));
748
+ e && b.then(e);
749
+ return b;
750
+ };
751
+ }
752
+ var V = 0;
753
+ function La(a = {}, c) {
754
+ function b(k) {
755
+ function h(l) {
756
+ l = l.data || l;
757
+ const m = l.id, p = m && f.h[m];
758
+ p && (p(l.msg), delete f.h[m]);
759
+ }
760
+ this.worker = k;
761
+ this.h = I();
762
+ if (this.worker) {
763
+ d ? this.worker.on("message", h) : this.worker.onmessage = h;
764
+ if (a.config) return new Promise(function(l) {
765
+ V > 1e9 && (V = 0);
766
+ f.h[++V] = function() {
767
+ l(f);
768
+ };
769
+ f.worker.postMessage({ id: V, task: "init", factory: e, options: a });
770
+ });
771
+ this.priority = a.priority || 4;
772
+ this.encoder = c || null;
773
+ this.worker.postMessage({ task: "init", factory: e, options: a });
774
+ return this;
775
+ }
776
+ }
777
+ if (!this || this.constructor !== La) return new La(a);
778
+ let e = typeof self !== "undefined" ? self._factory : typeof window !== "undefined" ? window._factory : null;
779
+ e && (e = e.toString());
780
+ const d = typeof window === "undefined", f = this, g = Ma(e, d, a.worker);
781
+ return g.then ? g.then(function(k) {
782
+ return b.call(f, k);
783
+ }) : b.call(this, g);
784
+ }
785
+ W("add");
786
+ W("append");
787
+ W("search");
788
+ W("update");
789
+ W("remove");
790
+ W("clear");
791
+ W("export");
792
+ W("import");
793
+ La.prototype.searchCache = la;
794
+ Fa(La.prototype);
795
+ function W(a) {
796
+ La.prototype[a] = function() {
797
+ const c = this, b = [].slice.call(arguments);
798
+ var e = b[b.length - 1];
799
+ let d;
800
+ typeof e === "function" && (d = e, b.pop());
801
+ e = new Promise(function(f) {
802
+ a === "export" && typeof b[0] === "function" && (b[0] = null);
803
+ V > 1e9 && (V = 0);
804
+ c.h[++V] = f;
805
+ c.worker.postMessage({ task: a, id: V, args: b });
806
+ });
807
+ return d ? (e.then(d), this) : e;
808
+ };
809
+ }
810
+ function Ma(a, c, b) {
811
+ return c ? typeof module !== "undefined" ? new (__require("worker_threads"))["Worker"](__dirname + "/worker/node.js") : import('worker_threads').then(function(worker) {
812
+ return new worker["Worker"](import_meta.dirname + "/node/node.mjs");
813
+ }) : a ? new window.Worker(URL.createObjectURL(new Blob(["onmessage=" + Ea.toString()], { type: "text/javascript" }))) : new window.Worker(typeof b === "string" ? b : import_meta.url.replace("/worker.js", "/worker/worker.js").replace(
814
+ "flexsearch.bundle.module.min.js",
815
+ "module/worker/worker.js"
816
+ ).replace("flexsearch.bundle.module.min.mjs", "module/worker/worker.js"), { type: "module" });
817
+ }
818
+ Na.prototype.add = function(a, c, b) {
819
+ ba(a) && (c = a, a = ca(c, this.key));
820
+ if (c && (a || a === 0)) {
821
+ if (!b && this.reg.has(a)) return this.update(a, c);
822
+ for (let k = 0, h; k < this.field.length; k++) {
823
+ h = this.B[k];
824
+ var e = this.index.get(this.field[k]);
825
+ if (typeof h === "function") {
826
+ var d = h(c);
827
+ d && e.add(a, d, b, true);
828
+ } else if (d = h.G, !d || d(c)) h.constructor === String ? h = ["" + h] : M(h) && (h = [h]), Qa(c, h, this.D, 0, e, a, h[0], b);
829
+ }
830
+ if (this.tag) for (e = 0; e < this.A.length; e++) {
831
+ var f = this.A[e];
832
+ d = this.tag.get(this.F[e]);
833
+ let k = I();
834
+ if (typeof f === "function") {
835
+ if (f = f(c), !f) continue;
836
+ } else {
837
+ var g = f.G;
838
+ if (g && !g(c)) continue;
839
+ f.constructor === String && (f = "" + f);
840
+ f = ca(c, f);
841
+ }
842
+ if (d && f) {
843
+ M(f) && (f = [f]);
844
+ for (let h = 0, l, m; h < f.length; h++) if (l = f[h], !k[l] && (k[l] = 1, (g = d.get(l)) ? m = g : d.set(l, m = []), !b || !m.includes(a))) {
845
+ if (m.length === 2 ** 31 - 1) {
846
+ g = new xa(m);
847
+ if (this.fastupdate) for (let p of this.reg.values()) p.includes(m) && (p[p.indexOf(m)] = g);
848
+ d.set(l, m = g);
849
+ }
850
+ m.push(a);
851
+ this.fastupdate && ((g = this.reg.get(a)) ? g.push(m) : this.reg.set(a, [m]));
852
+ }
853
+ }
854
+ }
855
+ if (this.store && (!b || !this.store.has(a))) {
856
+ let k;
857
+ if (this.h) {
858
+ k = I();
859
+ for (let h = 0, l; h < this.h.length; h++) {
860
+ l = this.h[h];
861
+ if ((b = l.G) && !b(c)) continue;
862
+ let m;
863
+ if (typeof l === "function") {
864
+ m = l(c);
865
+ if (!m) continue;
866
+ l = [l.O];
867
+ } else if (M(l) || l.constructor === String) {
868
+ k[l] = c[l];
869
+ continue;
870
+ }
871
+ Ra(c, k, l, 0, l[0], m);
872
+ }
873
+ }
874
+ this.store.set(a, k || c);
875
+ }
876
+ this.worker && (this.fastupdate || this.reg.add(a));
877
+ }
878
+ return this;
879
+ };
880
+ function Ra(a, c, b, e, d, f) {
881
+ a = a[d];
882
+ if (e === b.length - 1) c[d] = f || a;
883
+ else if (a) if (a.constructor === Array) for (c = c[d] = Array(a.length), d = 0; d < a.length; d++) Ra(a, c, b, e, d);
884
+ else c = c[d] || (c[d] = I()), d = b[++e], Ra(a, c, b, e, d);
885
+ }
886
+ function Qa(a, c, b, e, d, f, g, k) {
887
+ if (a = a[g]) if (e === c.length - 1) {
888
+ if (a.constructor === Array) {
889
+ if (b[e]) {
890
+ for (c = 0; c < a.length; c++) d.add(f, a[c], true, true);
891
+ return;
892
+ }
893
+ a = a.join(" ");
894
+ }
895
+ d.add(f, a, k, true);
896
+ } else if (a.constructor === Array) for (g = 0; g < a.length; g++) Qa(a, c, b, e, d, f, g, k);
897
+ else g = c[++e], Qa(a, c, b, e, d, f, g, k);
898
+ }
899
+ function Sa(a, c, b, e) {
900
+ if (!a.length) return a;
901
+ if (a.length === 1) return a = a[0], a = b || a.length > c ? a.slice(b, b + c) : a, e ? Ta.call(this, a) : a;
902
+ let d = [];
903
+ for (let f = 0, g, k; f < a.length; f++) if ((g = a[f]) && (k = g.length)) {
904
+ if (b) {
905
+ if (b >= k) {
906
+ b -= k;
907
+ continue;
908
+ }
909
+ g = g.slice(b, b + c);
910
+ k = g.length;
911
+ b = 0;
912
+ }
913
+ k > c && (g = g.slice(0, c), k = c);
914
+ if (!d.length && k >= c) return e ? Ta.call(this, g) : g;
915
+ d.push(g);
916
+ c -= k;
917
+ if (!c) break;
918
+ }
919
+ d = d.length > 1 ? [].concat.apply([], d) : d[0];
920
+ return e ? Ta.call(this, d) : d;
921
+ }
922
+ function Ua(a, c, b, e) {
923
+ var d = e[0];
924
+ if (d[0] && d[0].query) return a[c].apply(a, d);
925
+ if (!(c !== "and" && c !== "not" || a.result.length || a.await || d.suggest)) return e.length > 1 && (d = e[e.length - 1]), (e = d.resolve) ? a.await || a.result : a;
926
+ let f = [], g = 0, k = 0, h, l, m, p, u;
927
+ for (c = 0; c < e.length; c++) if (d = e[c]) {
928
+ var r = void 0;
929
+ if (d.constructor === X) r = d.await || d.result;
930
+ else if (d.then || d.constructor === Array) r = d;
931
+ else {
932
+ g = d.limit || 0;
933
+ k = d.offset || 0;
934
+ m = d.suggest;
935
+ l = d.resolve;
936
+ h = ((p = d.highlight || a.highlight) || d.enrich) && l;
937
+ r = d.queue;
938
+ let t = d.async || r, n = d.index, q = d.query;
939
+ n ? a.index || (a.index = n) : n = a.index;
940
+ if (q || d.tag) {
941
+ const x = d.field || d.pluck;
942
+ x && (!q || a.query && !p || (a.query = q, a.field = x, a.highlight = p), n = n.index.get(x));
943
+ if (r && (u || a.await)) {
944
+ u = 1;
945
+ let v;
946
+ const A = a.C.length, D = new Promise(function(F) {
947
+ v = F;
948
+ });
949
+ (function(F, E) {
950
+ D.h = function() {
951
+ E.index = null;
952
+ E.resolve = false;
953
+ let B = t ? F.searchAsync(E) : F.search(E);
954
+ if (B.then) return B.then(function(z) {
955
+ a.C[A] = z = z.result || z;
956
+ v(z);
957
+ return z;
958
+ });
959
+ B = B.result || B;
960
+ v(B);
961
+ return B;
962
+ };
963
+ })(n, Object.assign({}, d));
964
+ a.C.push(D);
965
+ f[c] = D;
966
+ continue;
967
+ } else d.resolve = false, d.index = null, r = t ? n.searchAsync(d) : n.search(d), d.resolve = l, d.index = n;
968
+ } else if (d.and) r = Va(d, "and", n);
969
+ else if (d.or) r = Va(d, "or", n);
970
+ else if (d.not) r = Va(d, "not", n);
971
+ else if (d.xor) r = Va(d, "xor", n);
972
+ else continue;
973
+ }
974
+ r.await ? (u = 1, r = r.await) : r.then ? (u = 1, r = r.then(function(t) {
975
+ return t.result || t;
976
+ })) : r = r.result || r;
977
+ f[c] = r;
978
+ }
979
+ u && !a.await && (a.await = new Promise(function(t) {
980
+ a.return = t;
981
+ }));
982
+ if (u) {
983
+ const t = Promise.all(f).then(function(n) {
984
+ for (let q = 0; q < a.C.length; q++) if (a.C[q] === t) {
985
+ a.C[q] = function() {
986
+ return b.call(a, n, g, k, h, l, m, p);
987
+ };
988
+ break;
989
+ }
990
+ Wa(a);
991
+ });
992
+ a.C.push(t);
993
+ } else if (a.await) a.C.push(function() {
994
+ return b.call(a, f, g, k, h, l, m, p);
995
+ });
996
+ else return b.call(a, f, g, k, h, l, m, p);
997
+ return l ? a.await || a.result : a;
998
+ }
999
+ function Va(a, c, b) {
1000
+ a = a[c];
1001
+ const e = a[0] || a;
1002
+ e.index || (e.index = b);
1003
+ b = new X(e);
1004
+ a.length > 1 && (b = b[c].apply(b, a.slice(1)));
1005
+ return b;
1006
+ }
1007
+ X.prototype.or = function() {
1008
+ return Ua(this, "or", Xa, arguments);
1009
+ };
1010
+ function Xa(a, c, b, e, d, f, g) {
1011
+ a.length && (this.result.length && a.push(this.result), a.length < 2 ? this.result = a[0] : (this.result = Ya(a, c, b, false, this.h), b = 0));
1012
+ d && (this.await = null);
1013
+ return d ? this.resolve(c, b, e, g) : this;
1014
+ }
1015
+ X.prototype.and = function() {
1016
+ return Ua(this, "and", Za, arguments);
1017
+ };
1018
+ function Za(a, c, b, e, d, f, g) {
1019
+ if (!f && !this.result.length) return d ? this.result : this;
1020
+ let k;
1021
+ if (a.length) if (this.result.length && a.unshift(this.result), a.length < 2) this.result = a[0];
1022
+ else {
1023
+ let h = 0;
1024
+ for (let l = 0, m, p; l < a.length; l++) if ((m = a[l]) && (p = m.length)) h < p && (h = p);
1025
+ else if (!f) {
1026
+ h = 0;
1027
+ break;
1028
+ }
1029
+ h ? (this.result = $a(a, h, c, b, f, this.h, d), k = true) : this.result = [];
1030
+ }
1031
+ else f || (this.result = a);
1032
+ d && (this.await = null);
1033
+ return d ? this.resolve(c, b, e, g, k) : this;
1034
+ }
1035
+ X.prototype.xor = function() {
1036
+ return Ua(this, "xor", ab, arguments);
1037
+ };
1038
+ function ab(a, c, b, e, d, f, g) {
1039
+ if (a.length) if (this.result.length && a.unshift(this.result), a.length < 2) this.result = a[0];
1040
+ else {
1041
+ a: {
1042
+ f = b;
1043
+ var k = this.h;
1044
+ const h = [], l = I();
1045
+ let m = 0;
1046
+ for (let p = 0, u; p < a.length; p++) if (u = a[p]) {
1047
+ m < u.length && (m = u.length);
1048
+ for (let r = 0, t; r < u.length; r++) if (t = u[r]) for (let n = 0, q; n < t.length; n++) q = t[n], l[q] = l[q] ? 2 : 1;
1049
+ }
1050
+ for (let p = 0, u, r = 0; p < m; p++) for (let t = 0, n; t < a.length; t++) if (n = a[t]) {
1051
+ if (u = n[p]) {
1052
+ for (let q = 0, x; q < u.length; q++) if (x = u[q], l[x] === 1) if (f) f--;
1053
+ else if (d) {
1054
+ if (h.push(x), h.length === c) {
1055
+ a = h;
1056
+ break a;
1057
+ }
1058
+ } else {
1059
+ const v = p + (t ? k : 0);
1060
+ h[v] || (h[v] = []);
1061
+ h[v].push(x);
1062
+ if (++r === c) {
1063
+ a = h;
1064
+ break a;
1065
+ }
1066
+ }
1067
+ }
1068
+ }
1069
+ a = h;
1070
+ }
1071
+ this.result = a;
1072
+ k = true;
1073
+ }
1074
+ else f || (this.result = a);
1075
+ d && (this.await = null);
1076
+ return d ? this.resolve(c, b, e, g, k) : this;
1077
+ }
1078
+ X.prototype.not = function() {
1079
+ return Ua(this, "not", bb, arguments);
1080
+ };
1081
+ function bb(a, c, b, e, d, f, g) {
1082
+ if (!f && !this.result.length) return d ? this.result : this;
1083
+ if (a.length && this.result.length) {
1084
+ a: {
1085
+ f = b;
1086
+ var k = [];
1087
+ a = new Set(a.flat().flat());
1088
+ for (let h = 0, l, m = 0; h < this.result.length; h++) if (l = this.result[h]) {
1089
+ for (let p = 0, u; p < l.length; p++) if (u = l[p], !a.has(u)) {
1090
+ if (f) f--;
1091
+ else if (d) {
1092
+ if (k.push(u), k.length === c) {
1093
+ a = k;
1094
+ break a;
1095
+ }
1096
+ } else if (k[h] || (k[h] = []), k[h].push(u), ++m === c) {
1097
+ a = k;
1098
+ break a;
1099
+ }
1100
+ }
1101
+ }
1102
+ a = k;
1103
+ }
1104
+ this.result = a;
1105
+ k = true;
1106
+ }
1107
+ d && (this.await = null);
1108
+ return d ? this.resolve(c, b, e, g, k) : this;
1109
+ }
1110
+ function cb(a, c, b, e, d) {
1111
+ let f, g, k;
1112
+ typeof d === "string" ? (f = d, d = "") : f = d.template;
1113
+ g = f.indexOf("$1");
1114
+ k = f.substring(g + 2);
1115
+ g = f.substring(0, g);
1116
+ let h = d && d.boundary, l = !d || d.clip !== false, m = d && d.merge && k && g && new RegExp(k + " " + g, "g");
1117
+ d = d && d.ellipsis;
1118
+ var p = 0;
1119
+ if (typeof d === "object") {
1120
+ var u = d.template;
1121
+ p = u.length - 2;
1122
+ d = d.pattern;
1123
+ }
1124
+ typeof d !== "string" && (d = d === false ? "" : "...");
1125
+ p && (d = u.replace("$1", d));
1126
+ u = d.length - p;
1127
+ let r, t;
1128
+ typeof h === "object" && (r = h.before, r === 0 && (r = -1), t = h.after, t === 0 && (t = -1), h = h.total || 9e5);
1129
+ p = /* @__PURE__ */ new Map();
1130
+ for (let Oa = 0, da, db, pa; Oa < c.length; Oa++) {
1131
+ let qa;
1132
+ if (e) qa = c, pa = e;
1133
+ else {
1134
+ var n = c[Oa];
1135
+ pa = n.field;
1136
+ if (!pa) continue;
1137
+ qa = n.result;
1138
+ }
1139
+ db = b.get(pa);
1140
+ da = db.encoder;
1141
+ n = p.get(da);
1142
+ typeof n !== "string" && (n = da.encode(a), p.set(da, n));
1143
+ for (let ya = 0; ya < qa.length; ya++) {
1144
+ var q = qa[ya].doc;
1145
+ if (!q) continue;
1146
+ q = ca(q, pa);
1147
+ if (!q) continue;
1148
+ var x = q.trim().split(/\s+/);
1149
+ if (!x.length) continue;
1150
+ q = "";
1151
+ var v = [];
1152
+ let za = [];
1153
+ var A = -1, D = -1, F = 0;
1154
+ for (var E = 0; E < x.length; E++) {
1155
+ var B = x[E], z = da.encode(B);
1156
+ z = z.length > 1 ? z.join(" ") : z[0];
1157
+ let y;
1158
+ if (z && B) {
1159
+ var C = B.length, J = (da.split ? B.replace(da.split, "") : B).length - z.length, G = "", N = 0;
1160
+ for (var O = 0; O < n.length; O++) {
1161
+ var P = n[O];
1162
+ if (P) {
1163
+ var L = P.length;
1164
+ L += J < 0 ? 0 : J;
1165
+ N && L <= N || (P = z.indexOf(P), P > -1 && (G = (P ? B.substring(0, P) : "") + g + B.substring(P, P + L) + k + (P + L < C ? B.substring(P + L) : ""), N = L, y = true));
1166
+ }
1167
+ }
1168
+ G && (h && (A < 0 && (A = q.length + (q ? 1 : 0)), D = q.length + (q ? 1 : 0) + G.length, F += C, za.push(v.length), v.push({ match: G })), q += (q ? " " : "") + G);
1169
+ }
1170
+ if (!y) B = x[E], q += (q ? " " : "") + B, h && v.push({ text: B });
1171
+ else if (h && F >= h) break;
1172
+ }
1173
+ F = za.length * (f.length - 2);
1174
+ if (r || t || h && q.length - F > h) if (F = h + F - u * 2, E = D - A, r > 0 && (E += r), t > 0 && (E += t), E <= F) x = r ? A - (r > 0 ? r : 0) : A - ((F - E) / 2 | 0), v = t ? D + (t > 0 ? t : 0) : x + F, l || (x > 0 && q.charAt(x) !== " " && q.charAt(x - 1) !== " " && (x = q.indexOf(" ", x), x < 0 && (x = 0)), v < q.length && q.charAt(v - 1) !== " " && q.charAt(v) !== " " && (v = q.lastIndexOf(" ", v), v < D ? v = D : ++v)), q = (x ? d : "") + q.substring(x, v) + (v < q.length ? d : "");
1175
+ else {
1176
+ D = [];
1177
+ A = {};
1178
+ F = {};
1179
+ E = {};
1180
+ B = {};
1181
+ z = {};
1182
+ G = J = C = 0;
1183
+ for (O = N = 1; ; ) {
1184
+ var U = void 0;
1185
+ for (let y = 0, K; y < za.length; y++) {
1186
+ K = za[y];
1187
+ if (G) if (J !== G) {
1188
+ if (E[y + 1]) continue;
1189
+ K += G;
1190
+ if (A[K]) {
1191
+ C -= u;
1192
+ F[y + 1] = 1;
1193
+ E[y + 1] = 1;
1194
+ continue;
1195
+ }
1196
+ if (K >= v.length - 1) {
1197
+ if (K >= v.length) {
1198
+ E[y + 1] = 1;
1199
+ K >= x.length && (F[y + 1] = 1);
1200
+ continue;
1201
+ }
1202
+ C -= u;
1203
+ }
1204
+ q = v[K].text;
1205
+ if (L = t && z[y]) if (L > 0) {
1206
+ if (q.length > L) if (E[y + 1] = 1, l) q = q.substring(0, L);
1207
+ else continue;
1208
+ (L -= q.length) || (L = -1);
1209
+ z[y] = L;
1210
+ } else {
1211
+ E[y + 1] = 1;
1212
+ continue;
1213
+ }
1214
+ if (C + q.length + 1 <= h) q = " " + q, D[y] += q;
1215
+ else if (l) U = h - C - 1, U > 0 && (q = " " + q.substring(0, U), D[y] += q), E[y + 1] = 1;
1216
+ else {
1217
+ E[y + 1] = 1;
1218
+ continue;
1219
+ }
1220
+ } else {
1221
+ if (E[y]) continue;
1222
+ K -= J;
1223
+ if (A[K]) {
1224
+ C -= u;
1225
+ E[y] = 1;
1226
+ F[y] = 1;
1227
+ continue;
1228
+ }
1229
+ if (K <= 0) {
1230
+ if (K < 0) {
1231
+ E[y] = 1;
1232
+ F[y] = 1;
1233
+ continue;
1234
+ }
1235
+ C -= u;
1236
+ }
1237
+ q = v[K].text;
1238
+ if (L = r && B[y]) if (L > 0) {
1239
+ if (q.length > L) if (E[y] = 1, l) q = q.substring(q.length - L);
1240
+ else continue;
1241
+ (L -= q.length) || (L = -1);
1242
+ B[y] = L;
1243
+ } else {
1244
+ E[y] = 1;
1245
+ continue;
1246
+ }
1247
+ if (C + q.length + 1 <= h) q += " ", D[y] = q + D[y];
1248
+ else if (l) U = q.length + 1 - (h - C), U >= 0 && U < q.length && (q = q.substring(U) + " ", D[y] = q + D[y]), E[y] = 1;
1249
+ else {
1250
+ E[y] = 1;
1251
+ continue;
1252
+ }
1253
+ }
1254
+ else {
1255
+ q = v[K].match;
1256
+ r && (B[y] = r);
1257
+ t && (z[y] = t);
1258
+ y && C++;
1259
+ let Pa;
1260
+ K ? !y && u && (C += u) : (F[y] = 1, E[y] = 1);
1261
+ K >= x.length - 1 ? Pa = 1 : K < v.length - 1 && v[K + 1].match ? Pa = 1 : u && (C += u);
1262
+ C -= f.length - 2;
1263
+ if (!y || C + q.length <= h) D[y] = q;
1264
+ else {
1265
+ U = N = O = F[y] = 0;
1266
+ break;
1267
+ }
1268
+ Pa && (F[y + 1] = 1, E[y + 1] = 1);
1269
+ }
1270
+ C += q.length;
1271
+ U = A[K] = 1;
1272
+ }
1273
+ if (U) J === G ? G++ : J++;
1274
+ else {
1275
+ J === G ? N = 0 : O = 0;
1276
+ if (!N && !O) break;
1277
+ N ? (J++, G = J) : G++;
1278
+ }
1279
+ }
1280
+ q = "";
1281
+ for (let y = 0, K; y < D.length; y++) K = (F[y] ? y ? " " : "" : (y && !d ? " " : "") + d) + D[y], q += K;
1282
+ d && !F[D.length] && (q += d);
1283
+ }
1284
+ m && (q = q.replace(m, " "));
1285
+ qa[ya].highlight = q;
1286
+ }
1287
+ if (e) break;
1288
+ }
1289
+ return c;
1290
+ }
1291
+ function X(a, c) {
1292
+ if (!this || this.constructor !== X) return new X(a, c);
1293
+ let b = 0, e, d, f, g, k, h;
1294
+ if (a && a.index) {
1295
+ const l = a;
1296
+ c = l.index;
1297
+ b = l.boost || 0;
1298
+ if (d = l.query) {
1299
+ f = l.field || l.pluck;
1300
+ g = l.highlight;
1301
+ const m = l.resolve;
1302
+ a = l.async || l.queue;
1303
+ l.resolve = false;
1304
+ l.index = null;
1305
+ a = a ? c.searchAsync(l) : c.search(l);
1306
+ l.resolve = m;
1307
+ l.index = c;
1308
+ a = a.result || a;
1309
+ } else a = [];
1310
+ }
1311
+ if (a && a.then) {
1312
+ const l = this;
1313
+ a = a.then(function(m) {
1314
+ l.C[0] = l.result = m.result || m;
1315
+ Wa(l);
1316
+ });
1317
+ e = [a];
1318
+ a = [];
1319
+ k = new Promise(function(m) {
1320
+ h = m;
1321
+ });
1322
+ }
1323
+ this.index = c || null;
1324
+ this.result = a || [];
1325
+ this.h = b;
1326
+ this.C = e || [];
1327
+ this.await = k || null;
1328
+ this.return = h || null;
1329
+ this.highlight = g || null;
1330
+ this.query = d || "";
1331
+ this.field = f || "";
1332
+ }
1333
+ w = X.prototype;
1334
+ w.limit = function(a) {
1335
+ if (this.await) {
1336
+ const c = this;
1337
+ this.C.push(function() {
1338
+ return c.limit(a).result;
1339
+ });
1340
+ } else if (this.result.length) {
1341
+ const c = [];
1342
+ for (let b = 0, e; b < this.result.length; b++) if (e = this.result[b]) if (e.length <= a) {
1343
+ if (c[b] = e, a -= e.length, !a) break;
1344
+ } else {
1345
+ c[b] = e.slice(0, a);
1346
+ break;
1347
+ }
1348
+ this.result = c;
1349
+ }
1350
+ return this;
1351
+ };
1352
+ w.offset = function(a) {
1353
+ if (this.await) {
1354
+ const c = this;
1355
+ this.C.push(function() {
1356
+ return c.offset(a).result;
1357
+ });
1358
+ } else if (this.result.length) {
1359
+ const c = [];
1360
+ for (let b = 0, e; b < this.result.length; b++) if (e = this.result[b]) e.length <= a ? a -= e.length : (c[b] = e.slice(a), a = 0);
1361
+ this.result = c;
1362
+ }
1363
+ return this;
1364
+ };
1365
+ w.boost = function(a) {
1366
+ if (this.await) {
1367
+ const c = this;
1368
+ this.C.push(function() {
1369
+ return c.boost(a).result;
1370
+ });
1371
+ } else this.h += a;
1372
+ return this;
1373
+ };
1374
+ function Wa(a, c) {
1375
+ let b = a.result;
1376
+ var e = a.await;
1377
+ a.await = null;
1378
+ for (let d = 0, f; d < a.C.length; d++) if (f = a.C[d]) {
1379
+ if (typeof f === "function") b = f(), a.C[d] = b = b.result || b, d--;
1380
+ else if (f.h) b = f.h(), a.C[d] = b = b.result || b, d--;
1381
+ else if (f.then) return a.await = e;
1382
+ }
1383
+ e = a.return;
1384
+ a.C = [];
1385
+ a.return = null;
1386
+ c || e(b);
1387
+ return b;
1388
+ }
1389
+ w.resolve = function(a, c, b, e, d) {
1390
+ let f = this.await ? Wa(this, true) : this.result;
1391
+ if (f.then) {
1392
+ const g = this;
1393
+ return f.then(function() {
1394
+ return g.resolve(a, c, b, e, d);
1395
+ });
1396
+ }
1397
+ f.length && (typeof a === "object" ? (e = a.highlight || this.highlight, b = !!e || a.enrich, c = a.offset, a = a.limit) : (e = e || this.highlight, b = !!e || b), f = d ? b ? Ta.call(this.index, f) : f : Sa.call(this.index, f, a || 100, c, b));
1398
+ return this.finalize(f, e);
1399
+ };
1400
+ w.finalize = function(a, c) {
1401
+ if (a.then) {
1402
+ const e = this;
1403
+ return a.then(function(d) {
1404
+ return e.finalize(d, c);
1405
+ });
1406
+ }
1407
+ c && a.length && this.query && (a = cb(this.query, a, this.index.index, this.field, c));
1408
+ const b = this.return;
1409
+ this.highlight = this.index = this.result = this.C = this.await = this.return = null;
1410
+ this.query = this.field = "";
1411
+ b && b(a);
1412
+ return a;
1413
+ };
1414
+ function $a(a, c, b, e, d, f, g) {
1415
+ const k = a.length;
1416
+ let h = [], l, m;
1417
+ l = I();
1418
+ for (let p = 0, u, r, t, n; p < c; p++) for (let q = 0; q < k; q++) if (t = a[q], p < t.length && (u = t[p])) for (let x = 0; x < u.length; x++) {
1419
+ r = u[x];
1420
+ (m = l[r]) ? l[r]++ : (m = 0, l[r] = 1);
1421
+ n = h[m] || (h[m] = []);
1422
+ if (!g) {
1423
+ let v = p + (q || !d ? 0 : f || 0);
1424
+ n = n[v] || (n[v] = []);
1425
+ }
1426
+ n.push(r);
1427
+ if (g && b && m === k - 1 && n.length - e === b) return e ? n.slice(e) : n;
1428
+ }
1429
+ if (a = h.length) if (d) h = h.length > 1 ? Ya(h, b, e, g, f) : (h = h[0]) && b && h.length > b || e ? h.slice(e, b + e) : h;
1430
+ else {
1431
+ if (a < k) return [];
1432
+ h = h[a - 1];
1433
+ if (b || e) if (g) {
1434
+ if (h.length > b || e) h = h.slice(e, b + e);
1435
+ } else {
1436
+ d = [];
1437
+ for (let p = 0, u; p < h.length; p++) if (u = h[p]) if (e && u.length > e) e -= u.length;
1438
+ else {
1439
+ if (b && u.length > b || e) u = u.slice(e, b + e), b -= u.length, e && (e -= u.length);
1440
+ d.push(u);
1441
+ if (!b) break;
1442
+ }
1443
+ h = d;
1444
+ }
1445
+ }
1446
+ return h;
1447
+ }
1448
+ function Ya(a, c, b, e, d) {
1449
+ const f = [], g = I();
1450
+ let k;
1451
+ var h = a.length;
1452
+ let l;
1453
+ if (e) for (d = h - 1; d >= 0; d--) {
1454
+ if (l = (e = a[d]) && e.length) {
1455
+ for (h = 0; h < l; h++) if (k = e[h], !g[k]) {
1456
+ if (g[k] = 1, b) b--;
1457
+ else if (f.push(k), f.length === c) return f;
1458
+ }
1459
+ }
1460
+ }
1461
+ else for (let m = h - 1, p, u = 0; m >= 0; m--) {
1462
+ p = a[m];
1463
+ for (let r = 0; r < p.length; r++) if (l = (e = p[r]) && e.length) {
1464
+ for (let t = 0; t < l; t++) if (k = e[t], !g[k]) if (g[k] = 1, b) b--;
1465
+ else {
1466
+ let n = (r + (m < h - 1 ? d || 0 : 0)) / (m + 1) | 0;
1467
+ (f[n] || (f[n] = [])).push(k);
1468
+ if (++u === c) return f;
1469
+ }
1470
+ }
1471
+ }
1472
+ return f;
1473
+ }
1474
+ function eb(a, c, b, e, d) {
1475
+ const f = I(), g = [];
1476
+ for (let k = 0, h; k < c.length; k++) {
1477
+ h = c[k];
1478
+ for (let l = 0; l < h.length; l++) f[h[l]] = 1;
1479
+ }
1480
+ if (d) for (let k = 0, h; k < a.length; k++) {
1481
+ if (h = a[k], f[h]) {
1482
+ if (e) e--;
1483
+ else if (g.push(h), f[h] = 0, b && --b === 0) break;
1484
+ }
1485
+ }
1486
+ else for (let k = 0, h, l; k < a.result.length; k++) for (h = a.result[k], c = 0; c < h.length; c++) l = h[c], f[l] && ((g[k] || (g[k] = [])).push(l), f[l] = 0);
1487
+ return g;
1488
+ }
1489
+ Na.prototype.search = function(a, c, b, e) {
1490
+ b || (!c && ba(a) ? (b = a, a = "") : ba(c) && (b = c, c = 0));
1491
+ let d = [];
1492
+ var f = [];
1493
+ let g;
1494
+ let k, h, l, m, p;
1495
+ let u = 0, r = true, t;
1496
+ if (b) {
1497
+ b.constructor === Array && (b = { index: b });
1498
+ a = b.query || a;
1499
+ g = b.pluck;
1500
+ k = b.merge;
1501
+ l = b.boost;
1502
+ p = g || b.field || (p = b.index) && (p.index ? null : p);
1503
+ var n = this.tag && b.tag;
1504
+ h = b.suggest;
1505
+ r = b.resolve !== false;
1506
+ m = b.cache;
1507
+ t = r && this.store && b.highlight;
1508
+ var q = !!t || r && this.store && b.enrich;
1509
+ c = b.limit || c;
1510
+ var x = b.offset || 0;
1511
+ c || (c = r ? 100 : 0);
1512
+ if (n && (!this.db || !e)) {
1513
+ n.constructor !== Array && (n = [n]);
1514
+ var v = [];
1515
+ for (let B = 0, z; B < n.length; B++) if (z = n[B], z.field && z.tag) {
1516
+ var A = z.tag;
1517
+ if (A.constructor === Array) for (var D = 0; D < A.length; D++) v.push(z.field, A[D]);
1518
+ else v.push(z.field, A);
1519
+ } else {
1520
+ A = Object.keys(z);
1521
+ for (let C = 0, J, G; C < A.length; C++) if (J = A[C], G = z[J], G.constructor === Array) for (D = 0; D < G.length; D++) v.push(J, G[D]);
1522
+ else v.push(J, G);
1523
+ }
1524
+ n = v;
1525
+ if (!a) {
1526
+ f = [];
1527
+ if (v.length) for (n = 0; n < v.length; n += 2) {
1528
+ if (this.db) {
1529
+ e = this.index.get(v[n]);
1530
+ if (!e) continue;
1531
+ f.push(e = e.db.tag(v[n + 1], c, x, q));
1532
+ } else e = fb.call(this, v[n], v[n + 1], c, x, q);
1533
+ d.push(r ? { field: v[n], tag: v[n + 1], result: e } : [e]);
1534
+ }
1535
+ if (f.length) {
1536
+ const B = this;
1537
+ return Promise.all(f).then(function(z) {
1538
+ for (let C = 0; C < z.length; C++) r ? d[C].result = z[C] : d[C] = z[C];
1539
+ return r ? d : new X(d.length > 1 ? $a(d, 1, 0, 0, h, l) : d[0], B);
1540
+ });
1541
+ }
1542
+ return r ? d : new X(d.length > 1 ? $a(d, 1, 0, 0, h, l) : d[0], this);
1543
+ }
1544
+ }
1545
+ r || g || !(p = p || this.field) || (M(p) ? g = p : (p.constructor === Array && p.length === 1 && (p = p[0]), g = p.field || p.index));
1546
+ p && p.constructor !== Array && (p = [p]);
1547
+ }
1548
+ p || (p = this.field);
1549
+ let F;
1550
+ v = (this.worker || this.db) && !e && [];
1551
+ for (let B = 0, z, C, J; B < p.length; B++) {
1552
+ C = p[B];
1553
+ if (this.db && this.tag && !this.B[B]) continue;
1554
+ let G;
1555
+ M(C) || (G = C, C = G.field, a = G.query || a, c = aa(G.limit, c), x = aa(G.offset, x), h = aa(G.suggest, h), t = r && this.store && aa(G.highlight, t), q = !!t || r && this.store && aa(G.enrich, q), m = aa(G.cache, m));
1556
+ if (e) z = e[B];
1557
+ else {
1558
+ A = G || b || {};
1559
+ D = A.enrich;
1560
+ var E = this.index.get(C);
1561
+ n && (this.db && (A.tag = n, A.field = p, F = E.db.support_tag_search), !F && D && (A.enrich = false), F || (A.limit = 0, A.offset = 0));
1562
+ z = m ? E.searchCache(a, n && !F ? 0 : c, A) : E.search(a, n && !F ? 0 : c, A);
1563
+ n && !F && (A.limit = c, A.offset = x);
1564
+ D && (A.enrich = D);
1565
+ if (v) {
1566
+ v[B] = z;
1567
+ continue;
1568
+ }
1569
+ }
1570
+ J = (z = z.result || z) && z.length;
1571
+ if (n && J) {
1572
+ A = [];
1573
+ D = 0;
1574
+ if (this.db && e) {
1575
+ if (!F) for (E = p.length; E < e.length; E++) {
1576
+ let N = e[E];
1577
+ if (N && N.length) D++, A.push(N);
1578
+ else if (!h) return r ? d : new X(d, this);
1579
+ }
1580
+ } else for (let N = 0, O, P; N < n.length; N += 2) {
1581
+ O = this.tag.get(n[N]);
1582
+ if (!O) if (h) continue;
1583
+ else return r ? d : new X(d, this);
1584
+ if (P = (O = O && O.get(n[N + 1])) && O.length) D++, A.push(O);
1585
+ else if (!h) return r ? d : new X(d, this);
1586
+ }
1587
+ if (D) {
1588
+ z = eb(z, A, c, x, r);
1589
+ J = z.length;
1590
+ if (!J && !h) return r ? z : new X(z, this);
1591
+ D--;
1592
+ }
1593
+ }
1594
+ if (J) f[u] = C, d.push(z), u++;
1595
+ else if (p.length === 1) return r ? d : new X(
1596
+ d,
1597
+ this
1598
+ );
1599
+ }
1600
+ if (v) {
1601
+ if (this.db && n && n.length && !F) for (q = 0; q < n.length; q += 2) {
1602
+ f = this.index.get(n[q]);
1603
+ if (!f) if (h) continue;
1604
+ else return r ? d : new X(d, this);
1605
+ v.push(f.db.tag(n[q + 1], c, x, false));
1606
+ }
1607
+ const B = this;
1608
+ return Promise.all(v).then(function(z) {
1609
+ b && (b.resolve = r);
1610
+ z.length && (z = B.search(a, c, b, z));
1611
+ return z;
1612
+ });
1613
+ }
1614
+ if (!u) return r ? d : new X(d, this);
1615
+ if (g && (!q || !this.store)) return d = d[0], r ? d : new X(d, this);
1616
+ v = [];
1617
+ for (x = 0; x < f.length; x++) {
1618
+ n = d[x];
1619
+ q && n.length && typeof n[0].doc === "undefined" && (this.db ? v.push(n = this.index.get(this.field[0]).db.enrich(n)) : n = Ta.call(this, n));
1620
+ if (g) return r ? t ? cb(a, n, this.index, g, t) : n : new X(n, this);
1621
+ d[x] = { field: f[x], result: n };
1622
+ }
1623
+ if (q && this.db && v.length) {
1624
+ const B = this;
1625
+ return Promise.all(v).then(function(z) {
1626
+ for (let C = 0; C < z.length; C++) d[C].result = z[C];
1627
+ t && (d = cb(a, d, B.index, g, t));
1628
+ return k ? gb(d) : d;
1629
+ });
1630
+ }
1631
+ t && (d = cb(a, d, this.index, g, t));
1632
+ return k ? gb(d) : d;
1633
+ };
1634
+ function gb(a) {
1635
+ const c = [], b = I(), e = I();
1636
+ for (let d = 0, f, g, k, h, l, m, p; d < a.length; d++) {
1637
+ f = a[d];
1638
+ g = f.field;
1639
+ k = f.result;
1640
+ for (let u = 0; u < k.length; u++) if (l = k[u], typeof l !== "object" ? l = { id: h = l } : h = l.id, (m = b[h]) ? m.push(g) : (l.field = b[h] = [g], c.push(l)), p = l.highlight) m = e[h], m || (e[h] = m = {}, l.highlight = m), m[g] = p;
1641
+ }
1642
+ return c;
1643
+ }
1644
+ function fb(a, c, b, e, d) {
1645
+ a = this.tag.get(a);
1646
+ if (!a) return [];
1647
+ a = a.get(c);
1648
+ if (!a) return [];
1649
+ c = a.length - e;
1650
+ if (c > 0) {
1651
+ if (b && c > b || e) a = a.slice(e, e + b);
1652
+ d && (a = Ta.call(this, a));
1653
+ }
1654
+ return a;
1655
+ }
1656
+ function Ta(a) {
1657
+ if (!this || !this.store) return a;
1658
+ if (this.db) return this.index.get(this.field[0]).db.enrich(a);
1659
+ const c = Array(a.length);
1660
+ for (let b = 0, e; b < a.length; b++) e = a[b], c[b] = { id: e, doc: this.store.get(e) };
1661
+ return c;
1662
+ }
1663
+ function Na(a) {
1664
+ if (!this || this.constructor !== Na) return new Na(a);
1665
+ const c = a.document || a.doc || a;
1666
+ let b, e;
1667
+ this.B = [];
1668
+ this.field = [];
1669
+ this.D = [];
1670
+ this.key = (b = c.key || c.id) && hb(b, this.D) || "id";
1671
+ (e = a.keystore || 0) && (this.keystore = e);
1672
+ this.fastupdate = !!a.fastupdate;
1673
+ this.reg = !this.fastupdate || a.worker || a.db ? e ? new S(e) : /* @__PURE__ */ new Set() : e ? new R(e) : /* @__PURE__ */ new Map();
1674
+ this.h = (b = c.store || null) && b && b !== true && [];
1675
+ this.store = b ? e ? new R(e) : /* @__PURE__ */ new Map() : null;
1676
+ this.cache = (b = a.cache || null) && new ma(b);
1677
+ a.cache = false;
1678
+ this.worker = a.worker || false;
1679
+ this.priority = a.priority || 4;
1680
+ this.index = ib.call(this, a, c);
1681
+ this.tag = null;
1682
+ if (b = c.tag) {
1683
+ if (typeof b === "string" && (b = [b]), b.length) {
1684
+ this.tag = /* @__PURE__ */ new Map();
1685
+ this.A = [];
1686
+ this.F = [];
1687
+ for (let d = 0, f, g; d < b.length; d++) {
1688
+ f = b[d];
1689
+ g = f.field || f;
1690
+ if (!g) throw Error("The tag field from the document descriptor is undefined.");
1691
+ f.custom ? this.A[d] = f.custom : (this.A[d] = hb(g, this.D), f.filter && (typeof this.A[d] === "string" && (this.A[d] = new String(this.A[d])), this.A[d].G = f.filter));
1692
+ this.F[d] = g;
1693
+ this.tag.set(g, /* @__PURE__ */ new Map());
1694
+ }
1695
+ }
1696
+ }
1697
+ if (this.worker) {
1698
+ this.fastupdate = false;
1699
+ a = [];
1700
+ for (const d of this.index.values()) d.then && a.push(d);
1701
+ if (a.length) {
1702
+ const d = this;
1703
+ return Promise.all(a).then(function(f) {
1704
+ let g = 0;
1705
+ for (const k of d.index.entries()) {
1706
+ const h = k[0];
1707
+ let l = k[1];
1708
+ l.then && (l = f[g], d.index.set(h, l), g++);
1709
+ }
1710
+ return d;
1711
+ });
1712
+ }
1713
+ } else a.db && (this.fastupdate = false, this.mount(a.db));
1714
+ }
1715
+ w = Na.prototype;
1716
+ w.mount = function(a) {
1717
+ let c = this.field;
1718
+ if (this.tag) for (let f = 0, g; f < this.F.length; f++) {
1719
+ g = this.F[f];
1720
+ var b = void 0;
1721
+ this.index.set(g, b = new T({}, this.reg));
1722
+ c === this.field && (c = c.slice(0));
1723
+ c.push(g);
1724
+ b.tag = this.tag.get(g);
1725
+ }
1726
+ b = [];
1727
+ const e = { db: a.db, type: a.type, fastupdate: a.fastupdate };
1728
+ for (let f = 0, g, k; f < c.length; f++) {
1729
+ e.field = k = c[f];
1730
+ g = this.index.get(k);
1731
+ const h = new a.constructor(a.id, e);
1732
+ h.id = a.id;
1733
+ b[f] = h.mount(g);
1734
+ g.document = true;
1735
+ f ? g.bypass = true : g.store = this.store;
1736
+ }
1737
+ const d = this;
1738
+ return this.db = Promise.all(b).then(function() {
1739
+ d.db = true;
1740
+ });
1741
+ };
1742
+ w.commit = async function() {
1743
+ const a = [];
1744
+ for (const c of this.index.values()) a.push(c.commit());
1745
+ await Promise.all(a);
1746
+ this.reg.clear();
1747
+ };
1748
+ w.destroy = function() {
1749
+ const a = [];
1750
+ for (const c of this.index.values()) a.push(c.destroy());
1751
+ return Promise.all(a);
1752
+ };
1753
+ function ib(a, c) {
1754
+ const b = /* @__PURE__ */ new Map();
1755
+ let e = c.index || c.field || c;
1756
+ M(e) && (e = [e]);
1757
+ for (let f = 0, g, k; f < e.length; f++) {
1758
+ g = e[f];
1759
+ M(g) || (k = g, g = g.field);
1760
+ k = ba(k) ? Object.assign({}, a, k) : a;
1761
+ if (this.worker) {
1762
+ var d = void 0;
1763
+ d = (d = k.encoder) && d.encode ? d : new ka(typeof d === "string" ? va[d] : d || {});
1764
+ d = new La(k, d);
1765
+ b.set(g, d);
1766
+ }
1767
+ this.worker || b.set(g, new T(k, this.reg));
1768
+ k.custom ? this.B[f] = k.custom : (this.B[f] = hb(g, this.D), k.filter && (typeof this.B[f] === "string" && (this.B[f] = new String(this.B[f])), this.B[f].G = k.filter));
1769
+ this.field[f] = g;
1770
+ }
1771
+ if (this.h) {
1772
+ a = c.store;
1773
+ M(a) && (a = [a]);
1774
+ for (let f = 0, g, k; f < a.length; f++) g = a[f], k = g.field || g, g.custom ? (this.h[f] = g.custom, g.custom.O = k) : (this.h[f] = hb(k, this.D), g.filter && (typeof this.h[f] === "string" && (this.h[f] = new String(this.h[f])), this.h[f].G = g.filter));
1775
+ }
1776
+ return b;
1777
+ }
1778
+ function hb(a, c) {
1779
+ const b = a.split(":");
1780
+ let e = 0;
1781
+ for (let d = 0; d < b.length; d++) a = b[d], a[a.length - 1] === "]" && (a = a.substring(0, a.length - 2)) && (c[e] = true), a && (b[e++] = a);
1782
+ e < b.length && (b.length = e);
1783
+ return e > 1 ? b : b[0];
1784
+ }
1785
+ w.append = function(a, c) {
1786
+ return this.add(a, c, true);
1787
+ };
1788
+ w.update = function(a, c) {
1789
+ return this.remove(a).add(a, c);
1790
+ };
1791
+ w.remove = function(a) {
1792
+ ba(a) && (a = ca(a, this.key));
1793
+ for (var c of this.index.values()) c.remove(a, true);
1794
+ if (this.reg.has(a)) {
1795
+ if (this.tag && !this.fastupdate) for (let b of this.tag.values()) for (let e of b) {
1796
+ c = e[0];
1797
+ const d = e[1], f = d.indexOf(a);
1798
+ f > -1 && (d.length > 1 ? d.splice(f, 1) : b.delete(c));
1799
+ }
1800
+ this.store && this.store.delete(a);
1801
+ this.reg.delete(a);
1802
+ }
1803
+ this.cache && this.cache.remove(a);
1804
+ return this;
1805
+ };
1806
+ w.clear = function() {
1807
+ const a = [];
1808
+ for (const c of this.index.values()) {
1809
+ const b = c.clear();
1810
+ b.then && a.push(b);
1811
+ }
1812
+ if (this.tag) for (const c of this.tag.values()) c.clear();
1813
+ this.store && this.store.clear();
1814
+ this.cache && this.cache.clear();
1815
+ return a.length ? Promise.all(a) : this;
1816
+ };
1817
+ w.contain = function(a) {
1818
+ return this.db ? this.index.get(this.field[0]).db.has(a) : this.reg.has(a);
1819
+ };
1820
+ w.cleanup = function() {
1821
+ for (const a of this.index.values()) a.cleanup();
1822
+ return this;
1823
+ };
1824
+ w.get = function(a) {
1825
+ return this.db ? this.index.get(this.field[0]).db.enrich(a).then(function(c) {
1826
+ return c[0] && c[0].doc || null;
1827
+ }) : this.store.get(a) || null;
1828
+ };
1829
+ w.set = function(a, c) {
1830
+ typeof a === "object" && (c = a, a = ca(c, this.key));
1831
+ this.store.set(a, c);
1832
+ return this;
1833
+ };
1834
+ w.searchCache = la;
1835
+ w.export = jb;
1836
+ w.import = kb;
1837
+ Fa(Na.prototype);
1838
+ function lb(a, c = 0) {
1839
+ let b = [], e = [];
1840
+ c && (c = 25e4 / c * 5e3 | 0);
1841
+ for (const d of a.entries()) e.push(d), e.length === c && (b.push(e), e = []);
1842
+ e.length && b.push(e);
1843
+ return b;
1844
+ }
1845
+ function mb(a, c) {
1846
+ c || (c = /* @__PURE__ */ new Map());
1847
+ for (let b = 0, e; b < a.length; b++) e = a[b], c.set(e[0], e[1]);
1848
+ return c;
1849
+ }
1850
+ function nb(a, c = 0) {
1851
+ let b = [], e = [];
1852
+ c && (c = 25e4 / c * 1e3 | 0);
1853
+ for (const d of a.entries()) e.push([d[0], lb(d[1])[0] || []]), e.length === c && (b.push(e), e = []);
1854
+ e.length && b.push(e);
1855
+ return b;
1856
+ }
1857
+ function ob(a, c) {
1858
+ c || (c = /* @__PURE__ */ new Map());
1859
+ for (let b = 0, e, d; b < a.length; b++) e = a[b], d = c.get(e[0]), c.set(e[0], mb(e[1], d));
1860
+ return c;
1861
+ }
1862
+ function pb(a) {
1863
+ let c = [], b = [];
1864
+ for (const e of a.keys()) b.push(e), b.length === 25e4 && (c.push(b), b = []);
1865
+ b.length && c.push(b);
1866
+ return c;
1867
+ }
1868
+ function qb(a, c) {
1869
+ c || (c = /* @__PURE__ */ new Set());
1870
+ for (let b = 0; b < a.length; b++) c.add(a[b]);
1871
+ return c;
1872
+ }
1873
+ function rb(a, c, b, e, d, f, g = 0) {
1874
+ const k = e && e.constructor === Array;
1875
+ var h = k ? e.shift() : e;
1876
+ if (!h) return this.export(a, c, d, f + 1);
1877
+ if ((h = a((c ? c + "." : "") + (g + 1) + "." + b, JSON.stringify(h))) && h.then) {
1878
+ const l = this;
1879
+ return h.then(function() {
1880
+ return rb.call(l, a, c, b, k ? e : null, d, f, g + 1);
1881
+ });
1882
+ }
1883
+ return rb.call(this, a, c, b, k ? e : null, d, f, g + 1);
1884
+ }
1885
+ function jb(a, c, b = 0, e = 0) {
1886
+ if (b < this.field.length) {
1887
+ const g = this.field[b];
1888
+ if ((c = this.index.get(g).export(a, g, b, e = 1)) && c.then) {
1889
+ const k = this;
1890
+ return c.then(function() {
1891
+ return k.export(a, g, b + 1);
1892
+ });
1893
+ }
1894
+ return this.export(a, g, b + 1);
1895
+ }
1896
+ let d, f;
1897
+ switch (e) {
1898
+ case 0:
1899
+ d = "reg";
1900
+ f = pb(this.reg);
1901
+ c = null;
1902
+ break;
1903
+ case 1:
1904
+ d = "tag";
1905
+ f = this.tag && nb(this.tag, this.reg.size);
1906
+ c = null;
1907
+ break;
1908
+ case 2:
1909
+ d = "doc";
1910
+ f = this.store && lb(this.store);
1911
+ c = null;
1912
+ break;
1913
+ default:
1914
+ return;
1915
+ }
1916
+ return rb.call(this, a, c, d, f || null, b, e);
1917
+ }
1918
+ function kb(a, c) {
1919
+ var b = a.split(".");
1920
+ b[b.length - 1] === "json" && b.pop();
1921
+ const e = b.length > 2 ? b[0] : "";
1922
+ b = b.length > 2 ? b[2] : b[1];
1923
+ if (this.worker && e) return this.index.get(e).import(a);
1924
+ if (c) {
1925
+ typeof c === "string" && (c = JSON.parse(c));
1926
+ if (e) return this.index.get(e).import(b, c);
1927
+ switch (b) {
1928
+ case "reg":
1929
+ this.fastupdate = false;
1930
+ this.reg = qb(c, this.reg);
1931
+ for (let d = 0, f; d < this.field.length; d++) f = this.index.get(this.field[d]), f.fastupdate = false, f.reg = this.reg;
1932
+ if (this.worker) {
1933
+ c = [];
1934
+ for (const d of this.index.values()) c.push(d.import(a));
1935
+ return Promise.all(c);
1936
+ }
1937
+ break;
1938
+ case "tag":
1939
+ this.tag = ob(c, this.tag);
1940
+ break;
1941
+ case "doc":
1942
+ this.store = mb(c, this.store);
1943
+ }
1944
+ }
1945
+ }
1946
+ function sb(a, c) {
1947
+ let b = "";
1948
+ for (const e of a.entries()) {
1949
+ a = e[0];
1950
+ const d = e[1];
1951
+ let f = "";
1952
+ for (let g = 0, k; g < d.length; g++) {
1953
+ k = d[g] || [""];
1954
+ let h = "";
1955
+ for (let l = 0; l < k.length; l++) h += (h ? "," : "") + (c === "string" ? '"' + k[l] + '"' : k[l]);
1956
+ h = "[" + h + "]";
1957
+ f += (f ? "," : "") + h;
1958
+ }
1959
+ f = '["' + a + '",[' + f + "]]";
1960
+ b += (b ? "," : "") + f;
1961
+ }
1962
+ return b;
1963
+ }
1964
+ T.prototype.remove = function(a, c) {
1965
+ const b = this.reg.size && (this.fastupdate ? this.reg.get(a) : this.reg.has(a));
1966
+ if (b) {
1967
+ if (this.fastupdate) for (let e = 0, d, f; e < b.length; e++) {
1968
+ if ((d = b[e]) && (f = d.length)) if (d[f - 1] === a) d.pop();
1969
+ else {
1970
+ const g = d.indexOf(a);
1971
+ g >= 0 && d.splice(g, 1);
1972
+ }
1973
+ }
1974
+ else tb(this.map, a), this.depth && tb(this.ctx, a);
1975
+ c || this.reg.delete(a);
1976
+ }
1977
+ this.db && (this.commit_task.push({ del: a }), this.M && ub(this));
1978
+ this.cache && this.cache.remove(a);
1979
+ return this;
1980
+ };
1981
+ function tb(a, c) {
1982
+ let b = 0;
1983
+ var e = typeof c === "undefined";
1984
+ if (a.constructor === Array) for (let d = 0, f, g, k; d < a.length; d++) {
1985
+ if ((f = a[d]) && f.length) {
1986
+ if (e) return 1;
1987
+ g = f.indexOf(c);
1988
+ if (g >= 0) {
1989
+ if (f.length > 1) return f.splice(g, 1), 1;
1990
+ delete a[d];
1991
+ if (b) return 1;
1992
+ k = 1;
1993
+ } else {
1994
+ if (k) return 1;
1995
+ b++;
1996
+ }
1997
+ }
1998
+ }
1999
+ else for (let d of a.entries()) e = d[0], tb(d[1], c) ? b++ : a.delete(e);
2000
+ return b;
2001
+ }
2002
+ var vb = { memory: { resolution: 1 }, performance: { resolution: 3, fastupdate: true, context: { depth: 1, resolution: 1 } }, match: { tokenize: "forward" }, score: { resolution: 9, context: { depth: 2, resolution: 3 } } };
2003
+ T.prototype.add = function(a, c, b, e) {
2004
+ if (c && (a || a === 0)) {
2005
+ if (!e && !b && this.reg.has(a)) return this.update(a, c);
2006
+ e = this.depth;
2007
+ c = this.encoder.encode(c, !e);
2008
+ const l = c.length;
2009
+ if (l) {
2010
+ const m = I(), p = I(), u = this.resolution;
2011
+ for (let r = 0; r < l; r++) {
2012
+ let t = c[this.rtl ? l - 1 - r : r];
2013
+ var d = t.length;
2014
+ if (d && (e || !p[t])) {
2015
+ var f = this.score ? this.score(c, t, r, null, 0) : wb(u, l, r), g = "";
2016
+ switch (this.tokenize) {
2017
+ case "tolerant":
2018
+ Y(this, p, t, f, a, b);
2019
+ if (d > 2) {
2020
+ for (let n = 1, q, x, v, A; n < d - 1; n++) q = t.charAt(n), x = t.charAt(n + 1), v = t.substring(0, n) + x, A = t.substring(n + 2), g = v + q + A, Y(this, p, g, f, a, b), g = v + A, Y(this, p, g, f, a, b);
2021
+ Y(this, p, t.substring(0, t.length - 1), f, a, b);
2022
+ }
2023
+ break;
2024
+ case "full":
2025
+ if (d > 2) {
2026
+ for (let n = 0, q; n < d; n++) for (f = d; f > n; f--) {
2027
+ g = t.substring(n, f);
2028
+ q = this.rtl ? d - 1 - n : n;
2029
+ var k = this.score ? this.score(c, t, r, g, q) : wb(u, l, r, d, q);
2030
+ Y(this, p, g, k, a, b);
2031
+ }
2032
+ break;
2033
+ }
2034
+ case "bidirectional":
2035
+ case "reverse":
2036
+ if (d > 1) {
2037
+ for (k = d - 1; k > 0; k--) {
2038
+ g = t[this.rtl ? d - 1 - k : k] + g;
2039
+ var h = this.score ? this.score(c, t, r, g, k) : wb(u, l, r, d, k);
2040
+ Y(this, p, g, h, a, b);
2041
+ }
2042
+ g = "";
2043
+ }
2044
+ case "forward":
2045
+ if (d > 1) {
2046
+ for (k = 0; k < d; k++) g += t[this.rtl ? d - 1 - k : k], Y(
2047
+ this,
2048
+ p,
2049
+ g,
2050
+ f,
2051
+ a,
2052
+ b
2053
+ );
2054
+ break;
2055
+ }
2056
+ default:
2057
+ if (Y(this, p, t, f, a, b), e && l > 1 && r < l - 1) for (d = this.N, g = t, f = Math.min(e + 1, this.rtl ? r + 1 : l - r), k = 1; k < f; k++) {
2058
+ t = c[this.rtl ? l - 1 - r - k : r + k];
2059
+ h = this.bidirectional && t > g;
2060
+ const n = this.score ? this.score(c, g, r, t, k - 1) : wb(d + (l / 2 > d ? 0 : 1), l, r, f - 1, k - 1);
2061
+ Y(this, m, h ? g : t, n, a, b, h ? t : g);
2062
+ }
2063
+ }
2064
+ }
2065
+ }
2066
+ this.fastupdate || this.reg.add(a);
2067
+ }
2068
+ }
2069
+ this.db && (this.commit_task.push(b ? { ins: a } : { del: a }), this.M && ub(this));
2070
+ return this;
2071
+ };
2072
+ function Y(a, c, b, e, d, f, g) {
2073
+ let k, h;
2074
+ if (!(k = c[b]) || g && !k[g]) {
2075
+ g ? (c = k || (c[b] = I()), c[g] = 1, h = a.ctx, (k = h.get(g)) ? h = k : h.set(g, h = a.keystore ? new R(a.keystore) : /* @__PURE__ */ new Map())) : (h = a.map, c[b] = 1);
2076
+ (k = h.get(b)) ? h = k : h.set(b, h = k = []);
2077
+ if (f) {
2078
+ for (let l = 0, m; l < k.length; l++) if ((m = k[l]) && m.includes(d)) {
2079
+ if (l <= e) return;
2080
+ m.splice(m.indexOf(d), 1);
2081
+ a.fastupdate && (c = a.reg.get(d)) && c.splice(c.indexOf(m), 1);
2082
+ break;
2083
+ }
2084
+ }
2085
+ h = h[e] || (h[e] = []);
2086
+ h.push(d);
2087
+ if (h.length === 2 ** 31 - 1) {
2088
+ c = new xa(h);
2089
+ if (a.fastupdate) for (let l of a.reg.values()) l.includes(h) && (l[l.indexOf(h)] = c);
2090
+ k[e] = h = c;
2091
+ }
2092
+ a.fastupdate && ((e = a.reg.get(d)) ? e.push(h) : a.reg.set(d, [h]));
2093
+ }
2094
+ }
2095
+ function wb(a, c, b, e, d) {
2096
+ return b && a > 1 ? c + (e || 0) <= a ? b + (d || 0) : (a - 1) / (c + (e || 0)) * (b + (d || 0)) + 1 | 0 : 0;
2097
+ }
2098
+ T.prototype.search = function(a, c, b) {
2099
+ b || (c || typeof a !== "object" ? typeof c === "object" && (b = c, c = 0) : (b = a, a = ""));
2100
+ if (b && b.cache) return b.cache = false, a = this.searchCache(a, c, b), b.cache = true, a;
2101
+ let e = [], d, f, g, k = 0, h, l, m, p, u;
2102
+ b && (a = b.query || a, c = b.limit || c, k = b.offset || 0, f = b.context, g = b.suggest, u = (h = b.resolve) && b.enrich, m = b.boost, p = b.resolution, l = this.db && b.tag);
2103
+ typeof h === "undefined" && (h = this.resolve);
2104
+ f = this.depth && f !== false;
2105
+ let r = this.encoder.encode(a, !f);
2106
+ d = r.length;
2107
+ c = c || (h ? 100 : 0);
2108
+ if (d === 1) return xb.call(
2109
+ this,
2110
+ r[0],
2111
+ "",
2112
+ c,
2113
+ k,
2114
+ h,
2115
+ u,
2116
+ l
2117
+ );
2118
+ if (d === 2 && f && !g) return xb.call(this, r[1], r[0], c, k, h, u, l);
2119
+ let t = I(), n = 0, q;
2120
+ f && (q = r[0], n = 1);
2121
+ p || p === 0 || (p = q ? this.N : this.resolution);
2122
+ if (this.db) {
2123
+ if (this.db.search && (b = this.db.search(this, r, c, k, g, h, u, l), b !== false)) return b;
2124
+ const x = this;
2125
+ return (async function() {
2126
+ for (let v, A; n < d; n++) {
2127
+ if ((A = r[n]) && !t[A]) {
2128
+ t[A] = 1;
2129
+ v = await yb(x, A, q, 0, 0, false, false);
2130
+ if (v = zb(v, e, g, p)) {
2131
+ e = v;
2132
+ break;
2133
+ }
2134
+ q && (g && v && e.length || (q = A));
2135
+ }
2136
+ g && q && n === d - 1 && !e.length && (p = x.resolution, q = "", n = -1, t = I());
2137
+ }
2138
+ return Ab(e, p, c, k, g, m, h);
2139
+ })();
2140
+ }
2141
+ for (let x, v; n < d; n++) {
2142
+ if ((v = r[n]) && !t[v]) {
2143
+ t[v] = 1;
2144
+ x = yb(this, v, q, 0, 0, false, false);
2145
+ if (x = zb(x, e, g, p)) {
2146
+ e = x;
2147
+ break;
2148
+ }
2149
+ q && (g && x && e.length || (q = v));
2150
+ }
2151
+ g && q && n === d - 1 && !e.length && (p = this.resolution, q = "", n = -1, t = I());
2152
+ }
2153
+ return Ab(e, p, c, k, g, m, h);
2154
+ };
2155
+ function Ab(a, c, b, e, d, f, g) {
2156
+ let k = a.length, h = a;
2157
+ if (k > 1) h = $a(a, c, b, e, d, f, g);
2158
+ else if (k === 1) return g ? Sa.call(null, a[0], b, e) : new X(a[0], this);
2159
+ return g ? h : new X(h, this);
2160
+ }
2161
+ function xb(a, c, b, e, d, f, g) {
2162
+ a = yb(this, a, c, b, e, d, f, g);
2163
+ return this.db ? a.then(function(k) {
2164
+ return d ? k || [] : new X(k, this);
2165
+ }) : a && a.length ? d ? Sa.call(this, a, b, e) : new X(a, this) : d ? [] : new X([], this);
2166
+ }
2167
+ function zb(a, c, b, e) {
2168
+ let d = [];
2169
+ if (a && a.length) {
2170
+ if (a.length <= e) {
2171
+ c.push(a);
2172
+ return;
2173
+ }
2174
+ for (let f = 0, g; f < e; f++) if (g = a[f]) d[f] = g;
2175
+ if (d.length) {
2176
+ c.push(d);
2177
+ return;
2178
+ }
2179
+ }
2180
+ if (!b) return d;
2181
+ }
2182
+ function yb(a, c, b, e, d, f, g, k) {
2183
+ let h;
2184
+ b && (h = a.bidirectional && c > b) && (h = b, b = c, c = h);
2185
+ if (a.db) return a.db.get(c, b, e, d, f, g, k);
2186
+ a = b ? (a = a.ctx.get(b)) && a.get(c) : a.map.get(c);
2187
+ return a;
2188
+ }
2189
+ function T(a, c) {
2190
+ if (!this || this.constructor !== T) return new T(a);
2191
+ if (a) {
2192
+ var b = M(a) ? a : a.preset;
2193
+ b && (a = Object.assign({}, vb[b], a));
2194
+ } else a = {};
2195
+ b = a.context;
2196
+ const e = b === true ? { depth: 1 } : b || {}, d = M(a.encoder) ? va[a.encoder] : a.encode || a.encoder || {};
2197
+ this.encoder = d.encode ? d : typeof d === "object" ? new ka(d) : { encode: d };
2198
+ this.resolution = a.resolution || 9;
2199
+ this.tokenize = b = (b = a.tokenize) && b !== "default" && b !== "exact" && b || "strict";
2200
+ this.depth = b === "strict" && e.depth || 0;
2201
+ this.bidirectional = e.bidirectional !== false;
2202
+ this.fastupdate = !!a.fastupdate;
2203
+ this.score = a.score || null;
2204
+ (b = a.keystore || 0) && (this.keystore = b);
2205
+ this.map = b ? new R(b) : /* @__PURE__ */ new Map();
2206
+ this.ctx = b ? new R(b) : /* @__PURE__ */ new Map();
2207
+ this.reg = c || (this.fastupdate ? b ? new R(b) : /* @__PURE__ */ new Map() : b ? new S(b) : /* @__PURE__ */ new Set());
2208
+ this.N = e.resolution || 3;
2209
+ this.rtl = d.rtl || a.rtl || false;
2210
+ this.cache = (b = a.cache || null) && new ma(b);
2211
+ this.resolve = a.resolve !== false;
2212
+ if (b = a.db) this.db = this.mount(b);
2213
+ this.M = a.commit !== false;
2214
+ this.commit_task = [];
2215
+ this.commit_timer = null;
2216
+ this.priority = a.priority || 4;
2217
+ }
2218
+ w = T.prototype;
2219
+ w.mount = function(a) {
2220
+ this.commit_timer && (clearTimeout(this.commit_timer), this.commit_timer = null);
2221
+ return a.mount(this);
2222
+ };
2223
+ w.commit = function() {
2224
+ this.commit_timer && (clearTimeout(this.commit_timer), this.commit_timer = null);
2225
+ return this.db.commit(this);
2226
+ };
2227
+ w.destroy = function() {
2228
+ this.commit_timer && (clearTimeout(this.commit_timer), this.commit_timer = null);
2229
+ return this.db.destroy();
2230
+ };
2231
+ function ub(a) {
2232
+ a.commit_timer || (a.commit_timer = setTimeout(function() {
2233
+ a.commit_timer = null;
2234
+ a.db.commit(a);
2235
+ }, 1));
2236
+ }
2237
+ w.clear = function() {
2238
+ this.map.clear();
2239
+ this.ctx.clear();
2240
+ this.reg.clear();
2241
+ this.cache && this.cache.clear();
2242
+ return this.db ? (this.commit_timer && clearTimeout(this.commit_timer), this.commit_timer = null, this.commit_task = [], this.db.clear()) : this;
2243
+ };
2244
+ w.append = function(a, c) {
2245
+ return this.add(a, c, true);
2246
+ };
2247
+ w.contain = function(a) {
2248
+ return this.db ? this.db.has(a) : this.reg.has(a);
2249
+ };
2250
+ w.update = function(a, c) {
2251
+ const b = this, e = this.remove(a);
2252
+ return e && e.then ? e.then(() => b.add(a, c)) : this.add(a, c);
2253
+ };
2254
+ w.cleanup = function() {
2255
+ if (!this.fastupdate) return this;
2256
+ tb(this.map);
2257
+ this.depth && tb(this.ctx);
2258
+ return this;
2259
+ };
2260
+ w.searchCache = la;
2261
+ w.export = function(a, c, b = 0, e = 0) {
2262
+ let d, f;
2263
+ switch (e) {
2264
+ case 0:
2265
+ d = "reg";
2266
+ f = pb(this.reg);
2267
+ break;
2268
+ case 1:
2269
+ d = "cfg";
2270
+ f = null;
2271
+ break;
2272
+ case 2:
2273
+ d = "map";
2274
+ f = lb(this.map, this.reg.size);
2275
+ break;
2276
+ case 3:
2277
+ d = "ctx";
2278
+ f = nb(this.ctx, this.reg.size);
2279
+ break;
2280
+ default:
2281
+ return;
2282
+ }
2283
+ return rb.call(this, a, c, d, f, b, e);
2284
+ };
2285
+ w.import = function(a, c) {
2286
+ if (c) switch (typeof c === "string" && (c = JSON.parse(c)), a = a.split("."), a[a.length - 1] === "json" && a.pop(), a.length === 3 && a.shift(), a = a.length > 1 ? a[1] : a[0], a) {
2287
+ case "reg":
2288
+ this.fastupdate = false;
2289
+ this.reg = qb(c, this.reg);
2290
+ break;
2291
+ case "map":
2292
+ this.map = mb(c, this.map);
2293
+ break;
2294
+ case "ctx":
2295
+ this.ctx = ob(c, this.ctx);
2296
+ }
2297
+ };
2298
+ w.serialize = function(a = true) {
2299
+ let c = "", b = "", e = "";
2300
+ if (this.reg.size) {
2301
+ let f;
2302
+ for (var d of this.reg.keys()) f || (f = typeof d), c += (c ? "," : "") + (f === "string" ? '"' + d + '"' : d);
2303
+ c = "index.reg=new Set([" + c + "]);";
2304
+ b = sb(this.map, f);
2305
+ b = "index.map=new Map([" + b + "]);";
2306
+ for (const g of this.ctx.entries()) {
2307
+ d = g[0];
2308
+ let k = sb(g[1], f);
2309
+ k = "new Map([" + k + "])";
2310
+ k = '["' + d + '",' + k + "]";
2311
+ e += (e ? "," : "") + k;
2312
+ }
2313
+ e = "index.ctx=new Map([" + e + "]);";
2314
+ }
2315
+ return a ? "function inject(index){" + c + b + e + "}" : c + b + e;
2316
+ };
2317
+ Fa(T.prototype);
2318
+ var Bb = typeof window !== "undefined" && (window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB);
2319
+ var Cb = ["map", "ctx", "tag", "reg", "cfg"];
2320
+ var Db = I();
2321
+ function Eb(a, c = {}) {
2322
+ if (!this || this.constructor !== Eb) return new Eb(a, c);
2323
+ typeof a === "object" && (c = a, a = a.name);
2324
+ a || console.info("Default storage space was used, because a name was not passed.");
2325
+ this.id = "flexsearch" + (a ? ":" + a.toLowerCase().replace(/[^a-z0-9_\-]/g, "") : "");
2326
+ this.field = c.field ? c.field.toLowerCase().replace(/[^a-z0-9_\-]/g, "") : "";
2327
+ this.type = c.type;
2328
+ this.fastupdate = this.support_tag_search = false;
2329
+ this.db = null;
2330
+ this.h = {};
2331
+ }
2332
+ w = Eb.prototype;
2333
+ w.mount = function(a) {
2334
+ if (a.index) return a.mount(this);
2335
+ a.db = this;
2336
+ return this.open();
2337
+ };
2338
+ w.open = function() {
2339
+ if (this.db) return this.db;
2340
+ let a = this;
2341
+ navigator.storage && navigator.storage.persist && navigator.storage.persist();
2342
+ Db[a.id] || (Db[a.id] = []);
2343
+ Db[a.id].push(a.field);
2344
+ const c = Bb.open(a.id, 1);
2345
+ c.onupgradeneeded = function() {
2346
+ const b = a.db = this.result;
2347
+ for (let e = 0, d; e < Cb.length; e++) {
2348
+ d = Cb[e];
2349
+ for (let f = 0, g; f < Db[a.id].length; f++) g = Db[a.id][f], b.objectStoreNames.contains(d + (d !== "reg" ? g ? ":" + g : "" : "")) || b.createObjectStore(d + (d !== "reg" ? g ? ":" + g : "" : ""));
2350
+ }
2351
+ };
2352
+ return a.db = Z(c, function(b) {
2353
+ a.db = b;
2354
+ a.db.onversionchange = function() {
2355
+ a.close();
2356
+ };
2357
+ });
2358
+ };
2359
+ w.close = function() {
2360
+ this.db && this.db.close();
2361
+ this.db = null;
2362
+ };
2363
+ w.destroy = function() {
2364
+ const a = Bb.deleteDatabase(this.id);
2365
+ return Z(a);
2366
+ };
2367
+ w.clear = function() {
2368
+ const a = [];
2369
+ for (let b = 0, e; b < Cb.length; b++) {
2370
+ e = Cb[b];
2371
+ for (let d = 0, f; d < Db[this.id].length; d++) f = Db[this.id][d], a.push(e + (e !== "reg" ? f ? ":" + f : "" : ""));
2372
+ }
2373
+ const c = this.db.transaction(a, "readwrite");
2374
+ for (let b = 0; b < a.length; b++) c.objectStore(a[b]).clear();
2375
+ return Z(c);
2376
+ };
2377
+ w.get = function(a, c, b = 0, e = 0, d = true, f = false) {
2378
+ a = this.db.transaction((c ? "ctx" : "map") + (this.field ? ":" + this.field : ""), "readonly").objectStore((c ? "ctx" : "map") + (this.field ? ":" + this.field : "")).get(c ? c + ":" + a : a);
2379
+ const g = this;
2380
+ return Z(a).then(function(k) {
2381
+ let h = [];
2382
+ if (!k || !k.length) return h;
2383
+ if (d) {
2384
+ if (!b && !e && k.length === 1) return k[0];
2385
+ for (let l = 0, m; l < k.length; l++) if ((m = k[l]) && m.length) {
2386
+ if (e >= m.length) {
2387
+ e -= m.length;
2388
+ continue;
2389
+ }
2390
+ const p = b ? e + Math.min(m.length - e, b) : m.length;
2391
+ for (let u = e; u < p; u++) h.push(m[u]);
2392
+ e = 0;
2393
+ if (h.length === b) break;
2394
+ }
2395
+ return f ? g.enrich(h) : h;
2396
+ }
2397
+ return k;
2398
+ });
2399
+ };
2400
+ w.tag = function(a, c = 0, b = 0, e = false) {
2401
+ a = this.db.transaction("tag" + (this.field ? ":" + this.field : ""), "readonly").objectStore("tag" + (this.field ? ":" + this.field : "")).get(a);
2402
+ const d = this;
2403
+ return Z(a).then(function(f) {
2404
+ if (!f || !f.length || b >= f.length) return [];
2405
+ if (!c && !b) return f;
2406
+ f = f.slice(b, b + c);
2407
+ return e ? d.enrich(f) : f;
2408
+ });
2409
+ };
2410
+ w.enrich = function(a) {
2411
+ typeof a !== "object" && (a = [a]);
2412
+ const c = this.db.transaction("reg", "readonly").objectStore("reg"), b = [];
2413
+ for (let e = 0; e < a.length; e++) b[e] = Z(c.get(a[e]));
2414
+ return Promise.all(b).then(function(e) {
2415
+ for (let d = 0; d < e.length; d++) e[d] = { id: a[d], doc: e[d] ? JSON.parse(e[d]) : null };
2416
+ return e;
2417
+ });
2418
+ };
2419
+ w.has = function(a) {
2420
+ a = this.db.transaction("reg", "readonly").objectStore("reg").getKey(a);
2421
+ return Z(a).then(function(c) {
2422
+ return !!c;
2423
+ });
2424
+ };
2425
+ w.search = null;
2426
+ w.info = function() {
2427
+ };
2428
+ w.transaction = function(a, c, b) {
2429
+ a += a !== "reg" ? this.field ? ":" + this.field : "" : "";
2430
+ let e = this.h[a + ":" + c];
2431
+ if (e) return b.call(this, e);
2432
+ let d = this.db.transaction(a, c);
2433
+ this.h[a + ":" + c] = e = d.objectStore(a);
2434
+ const f = b.call(this, e);
2435
+ this.h[a + ":" + c] = null;
2436
+ return Z(d).finally(function() {
2437
+ return f;
2438
+ });
2439
+ };
2440
+ w.commit = async function(a) {
2441
+ let c = a.commit_task, b = [];
2442
+ a.commit_task = [];
2443
+ for (let e = 0, d; e < c.length; e++) d = c[e], d.del && b.push(d.del);
2444
+ b.length && await this.remove(b);
2445
+ a.reg.size && (await this.transaction("map", "readwrite", function(e) {
2446
+ for (const d of a.map) {
2447
+ const f = d[0], g = d[1];
2448
+ g.length && (e.get(f).onsuccess = function() {
2449
+ let k = this.result;
2450
+ var h;
2451
+ if (k && k.length) {
2452
+ const l = Math.max(k.length, g.length);
2453
+ for (let m = 0, p, u; m < l; m++) if ((u = g[m]) && u.length) {
2454
+ if ((p = k[m]) && p.length) for (h = 0; h < u.length; h++) p.push(u[h]);
2455
+ else k[m] = u;
2456
+ h = 1;
2457
+ }
2458
+ } else k = g, h = 1;
2459
+ h && e.put(k, f);
2460
+ });
2461
+ }
2462
+ }), await this.transaction("ctx", "readwrite", function(e) {
2463
+ for (const d of a.ctx) {
2464
+ const f = d[0], g = d[1];
2465
+ for (const k of g) {
2466
+ const h = k[0], l = k[1];
2467
+ l.length && (e.get(f + ":" + h).onsuccess = function() {
2468
+ let m = this.result;
2469
+ var p;
2470
+ if (m && m.length) {
2471
+ const u = Math.max(m.length, l.length);
2472
+ for (let r = 0, t, n; r < u; r++) if ((n = l[r]) && n.length) {
2473
+ if ((t = m[r]) && t.length) for (p = 0; p < n.length; p++) t.push(n[p]);
2474
+ else m[r] = n;
2475
+ p = 1;
2476
+ }
2477
+ } else m = l, p = 1;
2478
+ p && e.put(m, f + ":" + h);
2479
+ });
2480
+ }
2481
+ }
2482
+ }), a.store ? await this.transaction(
2483
+ "reg",
2484
+ "readwrite",
2485
+ function(e) {
2486
+ for (const d of a.store) {
2487
+ const f = d[0], g = d[1];
2488
+ e.put(typeof g === "object" ? JSON.stringify(g) : 1, f);
2489
+ }
2490
+ }
2491
+ ) : a.bypass || await this.transaction("reg", "readwrite", function(e) {
2492
+ for (const d of a.reg.keys()) e.put(1, d);
2493
+ }), a.tag && await this.transaction("tag", "readwrite", function(e) {
2494
+ for (const d of a.tag) {
2495
+ const f = d[0], g = d[1];
2496
+ g.length && (e.get(f).onsuccess = function() {
2497
+ let k = this.result;
2498
+ k = k && k.length ? k.concat(g) : g;
2499
+ e.put(k, f);
2500
+ });
2501
+ }
2502
+ }), a.map.clear(), a.ctx.clear(), a.tag && a.tag.clear(), a.store && a.store.clear(), a.document || a.reg.clear());
2503
+ };
2504
+ function Fb(a, c, b) {
2505
+ const e = a.value;
2506
+ let d, f = 0;
2507
+ for (let g = 0, k; g < e.length; g++) {
2508
+ if (k = b ? e : e[g]) {
2509
+ for (let h = 0, l, m; h < c.length; h++) if (m = c[h], l = k.indexOf(m), l >= 0) if (d = 1, k.length > 1) k.splice(l, 1);
2510
+ else {
2511
+ e[g] = [];
2512
+ break;
2513
+ }
2514
+ f += k.length;
2515
+ }
2516
+ if (b) break;
2517
+ }
2518
+ f ? d && a.update(e) : a.delete();
2519
+ a.continue();
2520
+ }
2521
+ w.remove = function(a) {
2522
+ typeof a !== "object" && (a = [a]);
2523
+ return Promise.all([this.transaction("map", "readwrite", function(c) {
2524
+ c.openCursor().onsuccess = function() {
2525
+ const b = this.result;
2526
+ b && Fb(b, a);
2527
+ };
2528
+ }), this.transaction("ctx", "readwrite", function(c) {
2529
+ c.openCursor().onsuccess = function() {
2530
+ const b = this.result;
2531
+ b && Fb(b, a);
2532
+ };
2533
+ }), this.transaction("tag", "readwrite", function(c) {
2534
+ c.openCursor().onsuccess = function() {
2535
+ const b = this.result;
2536
+ b && Fb(b, a, true);
2537
+ };
2538
+ }), this.transaction("reg", "readwrite", function(c) {
2539
+ for (let b = 0; b < a.length; b++) c.delete(a[b]);
2540
+ })]);
2541
+ };
2542
+ function Z(a, c) {
2543
+ return new Promise((b, e) => {
2544
+ a.onsuccess = a.oncomplete = function() {
2545
+ c && c(this.result);
2546
+ c = null;
2547
+ b(this.result);
2548
+ };
2549
+ a.onerror = a.onblocked = e;
2550
+ a = null;
2551
+ });
2552
+ }
2553
+ var __defProp2 = Object.defineProperty;
2554
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
2555
+ var __hasOwnProp2 = Object.prototype.hasOwnProperty;
2556
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
2557
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2558
+ var __spreadValues = (a, b) => {
2559
+ for (var prop in b || (b = {}))
2560
+ if (__hasOwnProp2.call(b, prop))
2561
+ __defNormalProp(a, prop, b[prop]);
2562
+ if (__getOwnPropSymbols)
2563
+ for (var prop of __getOwnPropSymbols(b)) {
2564
+ if (__propIsEnum.call(b, prop))
2565
+ __defNormalProp(a, prop, b[prop]);
2566
+ }
2567
+ return a;
2568
+ };
2569
+ var __async = (__this, __arguments, generator) => {
2570
+ return new Promise((resolve, reject) => {
2571
+ var fulfilled = (value) => {
2572
+ try {
2573
+ step(generator.next(value));
2574
+ } catch (e) {
2575
+ reject(e);
2576
+ }
2577
+ };
2578
+ var rejected = (value) => {
2579
+ try {
2580
+ step(generator.throw(value));
2581
+ } catch (e) {
2582
+ reject(e);
2583
+ }
2584
+ };
2585
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
2586
+ step((generator = generator.apply(__this, __arguments)).next());
2587
+ });
2588
+ };
2589
+ var log3 = loggers2.search;
2590
+ var FileBasedSearchIndexExporter = class {
2591
+ constructor(options) {
2592
+ this.cachedData = null;
2593
+ this.baseDir = options.baseDir;
2594
+ this.indexPath = options.indexPath;
2595
+ }
2596
+ getFullPath() {
2597
+ return path__namespace.join(this.baseDir, this.indexPath);
2598
+ }
2599
+ loadData() {
2600
+ return __async(this, null, function* () {
2601
+ if (this.cachedData) {
2602
+ return this.cachedData;
2603
+ }
2604
+ const fullPath = this.getFullPath();
2605
+ try {
2606
+ const fileContent = yield fs__namespace.readFile(fullPath, "utf-8");
2607
+ const data = JSON.parse(fileContent);
2608
+ if (!data || !data.keys || !Array.isArray(data.keys) || !data.data) {
2609
+ log3.warn("Invalid search index structure in file:", fullPath);
2610
+ return null;
2611
+ }
2612
+ if (data.keys.length === 0) {
2613
+ log3.debug("Search index is empty:", fullPath);
2614
+ return null;
2615
+ }
2616
+ this.cachedData = data;
2617
+ log3.debug("Search index loaded from file:", fullPath, "with", data.keys.length, "keys");
2618
+ return data;
2619
+ } catch (error) {
2620
+ log3.error("Failed to load search index from file:", fullPath, error);
2621
+ return null;
2622
+ }
2623
+ });
2624
+ }
2625
+ import() {
2626
+ return __async(this, null, function* () {
2627
+ const data = yield this.loadData();
2628
+ return data;
2629
+ });
2630
+ }
2631
+ export(data) {
2632
+ return __async(this, null, function* () {
2633
+ const fullPath = this.getFullPath();
2634
+ try {
2635
+ const dir = path__namespace.dirname(fullPath);
2636
+ yield fs__namespace.mkdir(dir, { recursive: true });
2637
+ yield fs__namespace.writeFile(fullPath, JSON.stringify(data, null, 2), "utf-8");
2638
+ log3.debug("Search index saved to file:", fullPath, "with", data.keys.length, "keys");
2639
+ } catch (error) {
2640
+ log3.error("Failed to save search index to file:", fullPath, error);
2641
+ throw error;
2642
+ }
2643
+ });
2644
+ }
2645
+ };
2646
+ function createExporterFromConfig(exporterConfig) {
2647
+ if (exporterConfig.type === "fileBased") {
2648
+ return new FileBasedSearchIndexExporter(__spreadValues({}, exporterConfig.config));
2649
+ }
2650
+ throw new Error(`Unknown exporter type: ${exporterConfig.type}`);
2651
+ }
2652
+
146
2653
  // src/config.ts
147
2654
  var defaultConfig = {
148
- outputDir: ".peam",
149
- indexFilename: "index.json",
2655
+ searchExporter: {
2656
+ type: "fileBased",
2657
+ config: { baseDir: process.cwd(), indexPath: ".peam/index.json" }
2658
+ },
150
2659
  respectRobotsTxt: true,
151
- robotsTxtPath: void 0,
152
2660
  exclude: []
153
2661
  };
154
- var getConfig = () => {
155
- return {
156
- outputDir: process.env.PEAM_OUTPUT_DIR || defaultConfig.outputDir,
157
- indexFilename: process.env.PEAM_INDEX_FILENAME || defaultConfig.indexFilename,
158
- respectRobotsTxt: process.env.PEAM_RESPECT_ROBOTS_TXT !== void 0 ? process.env.PEAM_RESPECT_ROBOTS_TXT === "true" : defaultConfig.respectRobotsTxt,
159
- robotsTxtPath: process.env.PEAM_ROBOTS_TXT_PATH || defaultConfig.robotsTxtPath,
160
- exclude: process.env.PEAM_EXCLUDE ? JSON.parse(process.env.PEAM_EXCLUDE) : defaultConfig.exclude
161
- };
162
- };
163
2662
  function setNextConfig(nextConfig, peamConfig) {
2663
+ var _a, _b, _c, _d, _e, _f;
164
2664
  const envVars = {
165
- PEAM_OUTPUT_DIR: peamConfig.outputDir,
166
- PEAM_INDEX_FILENAME: peamConfig.indexFilename,
167
- PEAM_RESPECT_ROBOTS_TXT: String(peamConfig.respectRobotsTxt),
168
- PEAM_EXCLUDE: JSON.stringify(peamConfig.exclude),
2665
+ PEAM_SEARCH_EXPORTER_TYPE: (_b = (_a = peamConfig == null ? void 0 : peamConfig.searchExporter) == null ? void 0 : _a.type) != null ? _b : defaultConfig.searchExporter.type,
2666
+ PEAM_SEARCH_EXPORTER_CONFIG: (_d = JSON.stringify((_c = peamConfig == null ? void 0 : peamConfig.searchExporter) == null ? void 0 : _c.config)) != null ? _d : JSON.stringify(defaultConfig.searchExporter.config),
2667
+ PEAM_RESPECT_ROBOTS_TXT: String((_e = peamConfig == null ? void 0 : peamConfig.respectRobotsTxt) != null ? _e : defaultConfig.respectRobotsTxt),
2668
+ PEAM_EXCLUDE: (_f = JSON.stringify(peamConfig == null ? void 0 : peamConfig.exclude)) != null ? _f : JSON.stringify(defaultConfig.exclude),
169
2669
  PEAM_ROBOTS_TXT_PATH: ""
170
2670
  };
171
- if (peamConfig.robotsTxtPath) {
2671
+ if (peamConfig == null ? void 0 : peamConfig.robotsTxtPath) {
172
2672
  envVars.PEAM_ROBOTS_TXT_PATH = String(peamConfig.robotsTxtPath);
173
2673
  }
174
2674
  Object.assign(process.env, envVars);
@@ -177,69 +2677,40 @@ function setNextConfig(nextConfig, peamConfig) {
177
2677
  ...envVars
178
2678
  };
179
2679
  }
180
- var log2 = logger.loggers.next;
2680
+ var getConfig = () => {
2681
+ if (!process.env.PEAM_SEARCH_EXPORTER_TYPE || !process.env.PEAM_SEARCH_EXPORTER_CONFIG) {
2682
+ throw new Error(
2683
+ "Peam configuration not found. Make sure withPeam() is properly configured in your next.config file."
2684
+ );
2685
+ }
2686
+ const searchExporter = {
2687
+ type: process.env.PEAM_SEARCH_EXPORTER_TYPE,
2688
+ config: JSON.parse(process.env.PEAM_SEARCH_EXPORTER_CONFIG)
2689
+ };
2690
+ const resolvedConfig = {
2691
+ searchIndexExporter: createExporterFromConfig(searchExporter),
2692
+ respectRobotsTxt: process.env.PEAM_RESPECT_ROBOTS_TXT === "true",
2693
+ robotsTxtPath: process.env.PEAM_ROBOTS_TXT_PATH || void 0,
2694
+ exclude: process.env.PEAM_EXCLUDE ? JSON.parse(process.env.PEAM_EXCLUDE) : []
2695
+ };
2696
+ return resolvedConfig;
2697
+ };
2698
+
2699
+ // src/withPeam.ts
181
2700
  function withPeam(peamConfig) {
182
2701
  return function(nextConfig = {}) {
183
- var _a;
184
- const config = {
185
- ...defaultConfig,
186
- ...peamConfig
187
- };
188
- setNextConfig(nextConfig, config);
189
- const projectRoot = process.cwd();
190
- const peamPath = path.join(projectRoot, config.outputDir);
191
- const peamIndexExists = fs.existsSync(path.join(peamPath, "index.js"));
192
- if (!peamIndexExists) {
193
- try {
194
- const generatedDir = path.join(peamPath, "generated");
195
- fs.mkdirSync(generatedDir, { recursive: true });
196
- fs.writeFileSync(path.join(generatedDir, "index.json"), JSON.stringify({ data: {}, keys: [] }, null, 2));
197
- fs.writeFileSync(
198
- path.join(peamPath, "index.js"),
199
- '// Auto-generated by Peam - DO NOT EDIT THIS FILE\nimport index from "./generated/index.json";\nexport default index;\n'
200
- );
201
- log2.debug("Created stub index files. Run build to generate actual search index.");
202
- } catch (error) {
203
- log2.warn("Could not create stub files:", error);
204
- log2.warn("Search functionality will not work until build completes.");
205
- }
206
- }
207
- const indexPath = `./${config.outputDir}`;
2702
+ setNextConfig(nextConfig, peamConfig);
208
2703
  return {
209
2704
  ...nextConfig,
210
2705
  experimental: {
211
2706
  ...nextConfig.experimental,
212
2707
  adapterPath: __require.resolve("../dist/peam.adapter.js")
213
- },
214
- turbopack: {
215
- ...nextConfig.turbopack || {},
216
- resolveAlias: {
217
- ...((_a = nextConfig.turbopack) == null ? void 0 : _a.resolveAlias) || {},
218
- "peam_index/generated": indexPath
219
- }
220
- },
221
- webpack(webpackConfig, ctx) {
222
- if (!webpackConfig.resolve) {
223
- webpackConfig.resolve = {};
224
- }
225
- if (!webpackConfig.resolve.alias) {
226
- webpackConfig.resolve.alias = {};
227
- }
228
- webpackConfig.resolve.alias = {
229
- ...webpackConfig.resolve.alias,
230
- "peam_index/generated": peamPath
231
- };
232
- if (typeof nextConfig.webpack === "function") {
233
- return nextConfig.webpack(webpackConfig, ctx);
234
- }
235
- return webpackConfig;
236
2708
  }
237
2709
  };
238
2710
  };
239
2711
  }
240
2712
 
241
2713
  exports.createPeamAdapter = createPeamAdapter;
242
- exports.defaultConfig = defaultConfig;
243
2714
  exports.getConfig = getConfig;
244
2715
  exports.setNextConfig = setNextConfig;
245
2716
  exports.withPeam = withPeam;