@kedem/okdb 2.7.1 → 3.0.1

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.
Files changed (69) hide show
  1. package/CHANGELOG.md +111 -33
  2. package/README.md +68 -36
  3. package/bin/okdb +2 -0
  4. package/docs/auth-and-sync.md +30 -24
  5. package/docs/auth-permissions.md +5 -4
  6. package/docs/c-bridge.md +94 -0
  7. package/docs/change-log.md +78 -35
  8. package/docs/data-model.md +32 -8
  9. package/docs/deployment.md +42 -38
  10. package/docs/diagnostics.md +61 -125
  11. package/docs/embeddings.md +143 -51
  12. package/docs/files.md +53 -18
  13. package/docs/fts.md +48 -23
  14. package/docs/functions.md +107 -56
  15. package/docs/getting-started.md +125 -9
  16. package/docs/http-api.md +68 -11
  17. package/docs/http-cluster.md +80 -88
  18. package/docs/index.md +33 -15
  19. package/docs/indexes.md +53 -17
  20. package/docs/licensing.md +18 -4
  21. package/docs/logging.md +11 -22
  22. package/docs/manifest.json +4 -2
  23. package/docs/migration.md +40 -15
  24. package/docs/pipelines.md +96 -32
  25. package/docs/plugins.md +47 -15
  26. package/docs/process-registry.md +23 -24
  27. package/docs/processors.md +26 -23
  28. package/docs/querying.md +102 -29
  29. package/docs/queue.md +167 -51
  30. package/docs/resolved-fields.md +24 -1
  31. package/docs/subscriptions.md +4 -4
  32. package/docs/sync.md +9 -6
  33. package/docs/time-machine.md +40 -11
  34. package/docs/transactions.md +63 -15
  35. package/docs/ttl.md +34 -13
  36. package/docs/upgrade-2.0.md +32 -15
  37. package/docs/upgrade-2.1.md +10 -12
  38. package/docs/upgrade-3.0.md +144 -0
  39. package/docs/views.md +131 -42
  40. package/index.js +1 -0
  41. package/native/linux-x64-gnu/okdb +0 -0
  42. package/native/linux-x64-gnu/okdb-node.linux-x64-gnu.node +0 -0
  43. package/native-loader.d.ts +20 -0
  44. package/native-loader.js +1 -0
  45. package/okdb-native.js +1 -0
  46. package/package.json +27 -14
  47. package/types/environment.d.ts +32 -11
  48. package/types/errors.d.ts +20 -0
  49. package/types/features/admin.d.ts +3 -5
  50. package/types/features/api.d.ts +5 -7
  51. package/types/features/embeddings.d.ts +8 -7
  52. package/types/features/engines.d.ts +9 -1
  53. package/types/features/files.d.ts +2 -1
  54. package/types/features/fts.d.ts +3 -3
  55. package/types/features/functions.d.ts +14 -8
  56. package/types/features/pipelines.d.ts +10 -10
  57. package/types/features/queue.d.ts +15 -10
  58. package/types/features/sync.d.ts +7 -0
  59. package/types/features/time-machine.d.ts +3 -0
  60. package/types/index.d.ts +3 -0
  61. package/types/okdb.d.ts +70 -7
  62. package/types/options.d.ts +12 -8
  63. package/algorithm-worker-thread.js +0 -1
  64. package/bin/okdb.js +0 -2
  65. package/docs/OKDB-ARCHITECTURE.md +0 -1061
  66. package/okdb-functions-sandbox-worker.js +0 -1
  67. package/okdb-http-worker-child.js +0 -1
  68. package/okdb-views-bootstrap-worker.js +0 -1
  69. package/okdb.js +0 -1
package/types/okdb.d.ts CHANGED
@@ -88,7 +88,8 @@ export type OKDBHttpRouteHandler = (req: OKDBHttpRequest & Record<string, any>)
88
88
  export interface OKDBHttp {
89
89
  /**
90
90
  * Start the built-in HTTP server (REST API + admin UI). Single-process only — a
91
- * `{ workers }` option throws HTTP_CLUSTER_REMOVED (use `bin/okdb` or Node `cluster`).
91
+ * `{ workers }` option throws HTTP_CLUSTER_REMOVED (use the `okdb` CLI's cluster, or run
92
+ * several processes behind a load balancer).
92
93
  * `host` binds one address (default: all interfaces); an array binds each address with its
93
94
  * own server sharing one request handler. Returns the Node `http.Server` — for an array, the
94
95
  * one bound to the first address (all of them are on `servers`; an 'error' from any is
@@ -171,6 +172,43 @@ export interface OKDBPressure {
171
172
  score: number;
172
173
  }
173
174
 
175
+ // ── Migration and plugins ─────────────────────────────────────────────────────
176
+
177
+ export interface OKDBMigrate {
178
+ /** Streaming NDJSON export (`{ env?, types?, changes?, blobs? }`). */
179
+ exportToStream(stream: NodeJS.WritableStream, options?: Record<string, unknown>): Promise<unknown>;
180
+ exportToFile(filePath: string, options?: Record<string, unknown>): Promise<unknown>;
181
+ exportEnvsToStream(stream: NodeJS.WritableStream, options?: Record<string, unknown>): Promise<unknown>;
182
+ importFromStream(stream: NodeJS.ReadableStream, options?: Record<string, unknown>): Promise<unknown>;
183
+ importFromFile(filePath: string, options?: Record<string, unknown>): Promise<unknown>;
184
+ /** Hot backup into a new directory (unrestricted from code; HTTP/MCP backups stay under `backup.root`). */
185
+ backup(destDir: string, options?: Record<string, unknown>): Promise<unknown>;
186
+ backupRoot(): string;
187
+ resolveBackupDest(destDir: string): string;
188
+ export(options?: Record<string, unknown>): Promise<unknown>;
189
+ import(data: unknown, options?: Record<string, unknown>): Promise<unknown>;
190
+ exportJSON(options?: Record<string, unknown>): Promise<unknown>;
191
+ importJSON(json: unknown): Promise<unknown>;
192
+ exportBlobs(targetDir: string): Promise<unknown>;
193
+ importBlobs(sourceDir: string): Promise<unknown>;
194
+ validateBlobIntegrity(): Promise<unknown>;
195
+ repairBlobRefs(): Promise<unknown>;
196
+ }
197
+
198
+ /** A plugin module: `register()` runs synchronously at registration (no IO) and may return start/stop hooks. */
199
+ export interface OKDBPluginModule<O = Record<string, unknown>> {
200
+ name: string;
201
+ /** Names of plugins that must be registered first (PLUGIN_DEPENDENCY_MISSING otherwise). */
202
+ requires?: string[];
203
+ register(okdb: OKDB, options: O): void | { start?(okdb: OKDB): unknown; stop?(okdb: OKDB): unknown };
204
+ }
205
+
206
+ export interface OKDBPluginRegistry {
207
+ /** Register before open() (INVALID_STATE after). start() hooks run after open() completes, stop() hooks in reverse
208
+ * order inside close(). */
209
+ register<O>(module: OKDBPluginModule<O>, options?: O): void;
210
+ }
211
+
174
212
  // ── Main class ────────────────────────────────────────────────────────────────
175
213
 
176
214
  /**
@@ -180,7 +218,15 @@ export interface OKDBPressure {
180
218
  * Removed: `db.workers` (throws WORKERS_REMOVED — run more processes with `processors: true`).
181
219
  */
182
220
  export declare class OKDB {
183
- static defaults: OKDBOptions;
221
+ /** Default values of the storage options (`maxDbs`, `pageSize`, `compression`, `mapSize`, `durability`, …). */
222
+ static readonly defaults: OKDBOptions;
223
+ /** Every constructor option name okdb recognizes; an unknown key logs a warning (once per process). */
224
+ static readonly KNOWN_OPTIONS: ReadonlySet<string>;
225
+ /** Which core this process runs: always `'native'` in okdb 3. */
226
+ static readonly implementation: 'native';
227
+ /** Absolute path of the native file this process loaded (`native/<platform>/okdb-node.<platform>.node`, or the
228
+ * `OKDB_NATIVE_BINARY` override). A C-bridge host in the same process dlopens this file. */
229
+ static readonly nativeBinaryPath: string | null;
184
230
  /** Sentinel Buffer for open-ended index range ends: `end: [prefix, OKDB.HIGH_SENTINEL]`. */
185
231
  static HIGH_SENTINEL: Buffer;
186
232
  /**
@@ -229,10 +275,17 @@ export declare class OKDB {
229
275
  readonly http: OKDBHttp;
230
276
  readonly auth: OKDBAuth;
231
277
  readonly log: unknown;
232
- /** UDP bus (null when the shmbuf native binding is missing). */
233
- readonly bus: unknown;
234
- /** null when constructed with `admin: false`. */
278
+ /** The local UDP bus that wakes peer processes on the same store (`{ state, isRunning, emit }`); null before open() /
279
+ * after close() or when the bus is off. */
280
+ readonly bus: {
281
+ readonly state: string;
282
+ readonly isRunning: boolean;
283
+ emit(event: string, data?: string): void;
284
+ } | null;
285
+ /** Not available in okdb 3: any member call throws NOT_IMPLEMENTED_NATIVE (null when constructed with `admin: false`).
286
+ * The admin UI itself is served by `db.http.listen()`. */
235
287
  readonly admin: OKDBAdmin | null;
288
+ /** Not available in okdb 3: any member call throws NOT_IMPLEMENTED_NATIVE. Add routes with `db.http.add()`. */
236
289
  readonly api: OKDBApi;
237
290
  readonly sync: OKDBSync;
238
291
  readonly embeddings: OKDBEmbeddings;
@@ -250,12 +303,19 @@ export declare class OKDB {
250
303
  /** Process registry (the `/api/processes` census). */
251
304
  readonly processes: unknown;
252
305
  readonly meta: unknown;
253
- readonly migrate: unknown;
254
- readonly plugins: unknown;
306
+ /** Export / import / backup (see docs/migration.md). */
307
+ readonly migrate: OKDBMigrate;
308
+ /** Plugin registry (see docs/plugins.md): register before open(). */
309
+ readonly plugins: OKDBPluginRegistry;
255
310
  /** Named cross-process mutexes in `~system`. */
256
311
  readonly locks: unknown;
257
312
  /** The default env's processor. */
258
313
  readonly processor: OKDBEnvProcessor;
314
+ /** The default env's views (`db.env('default').views`). */
315
+ readonly views: import('./features/views').OKDBViews;
316
+ /** C-bridge attach helpers (see docs/c-bridge.md): the handle for `attach()`, the address of this image's
317
+ * `OkdbBridgeV1` table for ABI 1, and the path of the loaded native file. */
318
+ readonly _native: { bridgeHandle(): number; bridgeTable(): bigint; bridgeLibPath(): string };
259
319
 
260
320
  // ── Queue and files are shortcuts to the default env ──────────────────────
261
321
  readonly queue: OKDBQueue;
@@ -278,6 +338,9 @@ export declare class OKDB {
278
338
  diag(): Record<string, unknown>;
279
339
  /** @deprecated Pools were removed; use per-processor pause/resume instead. */
280
340
  setProcessingConfig(config: Record<string, unknown>): Promise<void>;
341
+ /** Boot the stored runtime declarations (engines/pipelines when `engines` is on, views on a participating node) —
342
+ * what open() does unless constructed with `runtimeDeclarations: false`. */
343
+ bootRuntimeDeclarations(): Promise<void>;
281
344
 
282
345
  // ── Environment management ────────────────────────────────────────────────
283
346
  readonly default: OKDBEnvironment;
@@ -14,7 +14,7 @@ export type OKDBIndexSpec = string | string[];
14
14
  /**
15
15
  * `new OKDB(path, options)`.
16
16
  *
17
- * Removed options throw at construction (see docs/upgrade-2.0.md): `asyncProcessors`
17
+ * Removed options throw at construction (see docs/upgrade-2.0.md; unchanged in 3.0): `asyncProcessors`
18
18
  * (ASYNC_PROCESSORS_REMOVED), `processing` (PROCESSING_REMOVED), `bus` (BUS_OPTION_REMOVED),
19
19
  * `envs` (ENVS_REMOVED), `deferProcessing` (DEFER_PROCESSING_REMOVED), `workers` (WORKERS_REMOVED),
20
20
  * `sync: true | false` (SYNC_OPTION_REMOVED — `sync` is only the settings object now),
@@ -25,11 +25,12 @@ export interface OKDBOptions {
25
25
  maxDbs?: number;
26
26
  pageSize?: number;
27
27
  compression?: boolean;
28
- encryptionKey?: string | Buffer;
28
+ /** Encryption key for data at rest (a string; pass the same key on every open). */
29
+ encryptionKey?: string;
29
30
  mapSize?: number;
30
31
  durability?: 'strict' | 'balanced' | 'fast' | 'custom';
31
32
  allowUnsafe?: boolean;
32
- /** Raw lmdb-js options (advanced; validated against `durability`). */
33
+ /** Raw LMDB environment flags (advanced; validated against `durability`). */
33
34
  lmdb?: Record<string, unknown>;
34
35
  auth?: OKDBAuthOptions;
35
36
  /** Sync (replication) settings for `db.sync`. */
@@ -85,8 +86,9 @@ export interface OKDBOptions {
85
86
  subscriptions?: { beatMs?: number; [key: string]: unknown };
86
87
  /** Debug switches (e.g. `{ logRequests: true }`). */
87
88
  debug?: { logRequests?: boolean; [key: string]: unknown };
88
- /** Action when a license expires at runtime. */
89
- onLicenseExpired?: string;
89
+ /** Action when a license expires at runtime: `'log'` (default — drop to the next license / free tier and keep running)
90
+ * or `'shutdown'` (exit the process). */
91
+ onLicenseExpired?: 'log' | 'shutdown';
90
92
  }
91
93
 
92
94
  export interface OKDBAutoCompactOptions {
@@ -162,7 +164,8 @@ export interface OKDBEnvironmentConfig {
162
164
  durability?: 'strict' | 'balanced' | 'fast' | 'custom';
163
165
  lmdb?: Record<string, unknown>;
164
166
  compression?: boolean;
165
- encryptionKey?: string | Buffer;
167
+ /** Encryption key for data at rest (a string; pass the same key on every open). */
168
+ encryptionKey?: string;
166
169
  parentEnv?: string;
167
170
  /** Per-env role overrides (same meaning as the constructor flags). */
168
171
  engines?: boolean;
@@ -196,7 +199,7 @@ export interface OKDBRangeOptions {
196
199
  offset?: number;
197
200
  versions?: boolean;
198
201
  snapshot?: OKDBSnapshotMode;
199
- /** A caller-managed lmdb read transaction (advanced). */
202
+ /** A caller-managed read transaction (advanced). */
200
203
  transaction?: unknown;
201
204
  }
202
205
 
@@ -346,7 +349,7 @@ export interface OKDBTransactionOptions {
346
349
  // ── Result shapes ─────────────────────────────────────────────────────────────
347
350
 
348
351
  /**
349
- * Lazy range result (lmdb-js RangeIterable or okdb's guarded equivalent). Iterate it or chain
352
+ * Lazy range result. Iterate it or chain
350
353
  * `map`/`filter`; materialize with `Array.from(...)`.
351
354
  */
352
355
  export interface OKDBRangeIterable<T> extends Iterable<T> {
@@ -497,6 +500,7 @@ export interface OKDBInfoResult {
497
500
  mapSize: number;
498
501
  clock: number;
499
502
  plugins: string[];
503
+ /** `lmdb` (the 2.x JS binding version) is null in okdb 3; `lmdbNative` is the LMDB library version. */
500
504
  versions: { okdb: string; lmdb: string | null; lmdbNative: string };
501
505
  version: string;
502
506
  ttl: OKDBTtlStats;
@@ -1 +0,0 @@
1
- 'use strict';const _0x2bb8dc=_0x4d49;(function(_0x3100ca,_0x527ae4){const _0x31934c=_0x4d49,_0x326104=_0x3100ca();while(!![]){try{const _0x1c5d54=-parseInt(_0x31934c(0x1d9))/0x1*(parseInt(_0x31934c(0x204))/0x2)+parseInt(_0x31934c(0x1eb))/0x3+parseInt(_0x31934c(0x1c2))/0x4+-parseInt(_0x31934c(0x232))/0x5*(parseInt(_0x31934c(0x1b0))/0x6)+-parseInt(_0x31934c(0x173))/0x7*(parseInt(_0x31934c(0x16c))/0x8)+parseInt(_0x31934c(0x1f1))/0x9+parseInt(_0x31934c(0x16f))/0xa*(parseInt(_0x31934c(0x17e))/0xb);if(_0x1c5d54===_0x527ae4)break;else _0x326104['push'](_0x326104['shift']());}catch(_0x559b23){_0x326104['push'](_0x326104['shift']());}}}(_0x1e68,0x5f2ee));function _0x4d49(_0x3eade8,_0x482bfa){_0x3eade8=_0x3eade8-0x15b;const _0x1e68d9=_0x1e68();let _0x4d4977=_0x1e68d9[_0x3eade8];return _0x4d4977;}var require$$0$1=require(_0x2bb8dc(0x21d)),require$$0=require('fs'),require$$1=require(_0x2bb8dc(0x179)),require$$2=require('os'),require$$3=require('crypto');function getDefaultExportFromCjs(_0x1b20f6){const _0x573f2e=_0x2bb8dc;return _0x1b20f6&&_0x1b20f6[_0x573f2e(0x1ca)]&&Object[_0x573f2e(0x21b)]['hasOwnProperty'][_0x573f2e(0x187)](_0x1b20f6,_0x573f2e(0x1e0))?_0x1b20f6[_0x573f2e(0x1e0)]:_0x1b20f6;}var algorithmWorkerThread$1={},snapshotStore,hasRequiredSnapshotStore;function requireSnapshotStore(){const _0x4b8fc4=_0x2bb8dc;if(hasRequiredSnapshotStore)return snapshotStore;hasRequiredSnapshotStore=0x1;const _0x543d78=require$$0,_0x3c540b=require$$1,_0x97a72d=require$$2,_0x346446=require$$3;function _0x5dd036(){const _0x171c64=_0x4d49;return Date[_0x171c64(0x22b)]();}function _0x2511cc(_0xe6d812){const _0x422827=_0x4d49;try{return _0x543d78[_0x422827(0x20a)](_0xe6d812);}catch{return![];}}function _0x3b8d72(_0x2d9223){const _0x26ec34=_0x4d49;try{return _0x543d78[_0x26ec34(0x18e)](_0x2d9223,_0x26ec34(0x15c));}catch{return null;}}function _0x2acabb(_0x3b60e1,_0x45adf8){const _0x586645=_0x4d49,_0x1e093a=_0x3b60e1+_0x586645(0x212)+_0x346446[_0x586645(0x1b4)](0x6)[_0x586645(0x1f2)]('hex');_0x543d78[_0x586645(0x21f)](_0x1e093a,_0x45adf8),_0x543d78['renameSync'](_0x1e093a,_0x3b60e1);}function _0x41394b(_0x3438bd,_0x1ca208=0x10){const _0x1daf93=_0x4d49,_0x55c4c9=String(Math['max'](0x0,Math[_0x1daf93(0x1a1)](_0x3438bd||0x0)));return _0x55c4c9['length']>=_0x1ca208?_0x55c4c9:'0'[_0x1daf93(0x1a5)](_0x1ca208-_0x55c4c9[_0x1daf93(0x1d3)])+_0x55c4c9;}return snapshotStore=class _0x34e4c3{constructor({dir:_0x3fd176,keepSnapshots:keepSnapshots=0x3,log:log=null}={}){const _0xfd6d0c=_0x4d49;if(!_0x3fd176)throw new Error(_0xfd6d0c(0x1e9));this[_0xfd6d0c(0x1f0)]=_0x3fd176,this[_0xfd6d0c(0x219)]=_0x3c540b['join'](_0x3fd176,_0xfd6d0c(0x177)),this[_0xfd6d0c(0x1cb)]=_0x3c540b[_0xfd6d0c(0x186)](_0x3fd176,'CURRENT'),this[_0xfd6d0c(0x18a)]=_0x3c540b[_0xfd6d0c(0x186)](_0x3fd176,_0xfd6d0c(0x1cf)),this[_0xfd6d0c(0x208)]=keepSnapshots,this['log']=log,_0x543d78[_0xfd6d0c(0x1b3)](this[_0xfd6d0c(0x1f0)],{'recursive':!![]}),_0x543d78[_0xfd6d0c(0x1b3)](this[_0xfd6d0c(0x219)],{'recursive':!![]});}['_snapshotDir'](_0x2dc4b6){const _0x45dac1=_0x4d49;return _0x3c540b['join'](this[_0x45dac1(0x219)],_0x2dc4b6);}[_0x4b8fc4(0x195)](_0x4138c){const _0x36d255=_0x4b8fc4,_0x4a396b=this[_0x36d255(0x18c)](_0x4138c);return{'dir':_0x4a396b,'index':_0x3c540b[_0x36d255(0x186)](_0x4a396b,_0x36d255(0x169)),'labels':_0x3c540b[_0x36d255(0x186)](_0x4a396b,'labels.json'),'state':_0x3c540b[_0x36d255(0x186)](_0x4a396b,'state.json')};}[_0x4b8fc4(0x1e3)](){if(!_0x2511cc(this['currentPath']))return null;const _0x37cfb6=_0x3b8d72(this['currentPath']);if(!_0x37cfb6)return null;const _0x17ae13=String(_0x37cfb6)['trim']();return _0x17ae13||null;}['readCurrentClock'](){const _0x232a45=_0x4b8fc4,_0x2a9fa8=this[_0x232a45(0x1e3)]();if(!_0x2a9fa8)return 0x0;const _0x21c779=Number(_0x2a9fa8);return Number['isFinite'](_0x21c779)?_0x21c779:0x0;}['listSnapshotIds'](){const _0x207946=_0x4b8fc4;try{return _0x543d78[_0x207946(0x185)](this[_0x207946(0x219)],{'withFileTypes':!![]})['filter'](_0x29401e=>_0x29401e['isDirectory']())[_0x207946(0x1d1)](_0x298150=>_0x298150[_0x207946(0x1af)])['filter'](_0x22477f=>!_0x22477f[_0x207946(0x165)]('.tmp-'))[_0x207946(0x15f)](_0x4718ba=>!_0x4718ba[_0x207946(0x165)]('_tmp-'))[_0x207946(0x1c9)]();}catch{return[];}}[_0x4b8fc4(0x1c6)](){const _0x5bc07a=_0x4b8fc4,_0xf61c99=this[_0x5bc07a(0x1e3)]();if(_0xf61c99)return _0xf61c99;const _0x11b0b3=this[_0x5bc07a(0x220)]();if(!_0x11b0b3[_0x5bc07a(0x1d3)])return null;return _0x11b0b3[_0x11b0b3[_0x5bc07a(0x1d3)]-0x1];}[_0x4b8fc4(0x1b1)]({maxAgeMs:maxAgeMs=0x6*0x36ee80}={}){const _0x151c99=_0x4b8fc4;let _0x185520;try{_0x185520=_0x543d78[_0x151c99(0x185)](this['snapshotsDir'],{'withFileTypes':!![]});}catch{return;}const _0x2c3777=_0x5dd036()-maxAgeMs;for(const _0x360908 of _0x185520){if(!_0x360908[_0x151c99(0x19e)]())continue;const _0x5edca4=_0x360908[_0x151c99(0x1af)];if(!_0x5edca4[_0x151c99(0x165)]('.tmp-')&&!_0x5edca4[_0x151c99(0x165)](_0x151c99(0x1fd)))continue;const _0x47e894=_0x3c540b['join'](this['snapshotsDir'],_0x5edca4);try{const _0x3856f9=_0x543d78['statSync'](_0x47e894);if(_0x3856f9[_0x151c99(0x17d)]>_0x2c3777)continue;}catch{}try{_0x543d78['rmSync'](_0x47e894,{'recursive':!![],'force':!![]});}catch{}}}[_0x4b8fc4(0x1f3)]({keep:keep=null}={}){const _0x1adeb7=_0x4b8fc4,_0x342e11=Math['max'](0x1,Math[_0x1adeb7(0x1a1)](keep??this[_0x1adeb7(0x208)]??0x3)),_0x711a52=this[_0x1adeb7(0x220)]();if(_0x711a52[_0x1adeb7(0x1d3)]<=_0x342e11)return;const _0x2ab277=this[_0x1adeb7(0x1e3)](),_0x49dcef=_0x711a52['slice'](0x0,Math[_0x1adeb7(0x1bf)](0x0,_0x711a52[_0x1adeb7(0x1d3)]-_0x342e11));for(const _0x4f0ebf of _0x49dcef){if(_0x2ab277&&_0x4f0ebf===_0x2ab277)continue;const _0x2584fb=this['_snapshotDir'](_0x4f0ebf);try{_0x543d78['rmSync'](_0x2584fb,{'recursive':!![],'force':!![]});}catch{}}}async['loadSnapshot'](_0x365739,_0x40a598){const _0xb99f5a=_0x4b8fc4;if(!_0x365739)throw new Error(_0xb99f5a(0x194));const _0x2a5064=this[_0xb99f5a(0x195)](_0x365739);if(!_0x2511cc(_0x2a5064[_0xb99f5a(0x19a)])||!_0x2511cc(_0x2a5064[_0xb99f5a(0x199)])||!_0x2511cc(_0x2a5064['state']))throw new Error('snapshot\x20incomplete:\x20'+_0x365739);const _0x55c5b3=await _0x40a598(_0x2a5064);return _0x55c5b3||{};}async['publishSnapshot'](_0x4ce5fd,_0x593789,{keep:keep=null,lockTimeoutMs:lockTimeoutMs=0x0,staleLockMaxAgeMs:staleLockMaxAgeMs=0xea60}={}){const _0xc51624=_0x4b8fc4,_0x32207d=Number(_0x4ce5fd);if(!Number['isFinite'](_0x32207d)||_0x32207d<0x0)throw new Error('candidateClock\x20must\x20be\x20finite\x20>=\x200');const _0x133e93=_0x41394b(_0x32207d),_0x2b6488=this[_0xc51624(0x18c)](_0x133e93),_0x187092=_0x3c540b[_0xc51624(0x186)](this[_0xc51624(0x219)],'.tmp-'+_0x133e93+'-'+_0x346446[_0xc51624(0x1b4)](0x6)['toString'](_0xc51624(0x1ed)));_0x543d78['mkdirSync'](_0x187092,{'recursive':!![]});const _0x1794a5={'dir':_0x187092,'index':_0x3c540b['join'](_0x187092,_0xc51624(0x169)),'labels':_0x3c540b[_0xc51624(0x186)](_0x187092,_0xc51624(0x20c)),'state':_0x3c540b[_0xc51624(0x186)](_0x187092,'state.json')};await _0x593789(_0x1794a5,{'id':_0x133e93,'clock':_0x32207d});const _0x4a3e79=JSON[_0xc51624(0x1e6)]({'pid':process[_0xc51624(0x1f4)],'host':_0x97a72d[_0xc51624(0x1ea)](),'at':_0x5dd036()}),_0x3be81a=_0x5dd036();let _0x679e90=null;const _0x5710e1=()=>{const _0x210858=_0xc51624;try{const _0x399bc2=JSON[_0x210858(0x21e)](_0x543d78['readFileSync'](this[_0x210858(0x18a)],_0x210858(0x15c)));if(_0x399bc2['at']&&_0x5dd036()-_0x399bc2['at']>staleLockMaxAgeMs){const _0x3519ba=_0x5dd036()-_0x399bc2['at'],_0x1883ba=_0x210858(0x168)+Math[_0x210858(0x164)](_0x3519ba/0x3e8)+_0x210858(0x18b)+_0x399bc2['pid']+_0x210858(0x191)+_0x399bc2[_0x210858(0x22c)]+_0x210858(0x160)+'This\x20is\x20risky\x20on\x20slow\x20disks\x20or\x20overloaded\x20machines.\x20Consider\x20increasing\x20staleLockMaxAgeMs\x20if\x20this\x20happens\x20frequently.';this[_0x210858(0x1fc)]?.[_0x210858(0x18f)]?this[_0x210858(0x1fc)][_0x210858(0x18f)](_0x1883ba):console[_0x210858(0x18f)](_0x210858(0x175),_0x1883ba);try{_0x543d78[_0x210858(0x213)](this[_0x210858(0x18a)]);}catch{}return!![];}}catch{try{_0x543d78['unlinkSync'](this[_0x210858(0x18a)]);}catch{}}return![];},_0xc6c814=()=>{const _0xac2ff9=_0xc51624;try{return _0x679e90=_0x543d78[_0xac2ff9(0x1cd)](this[_0xac2ff9(0x18a)],'wx'),_0x543d78[_0xac2ff9(0x21f)](_0x679e90,_0x4a3e79),!![];}catch(_0x5bfeec){if(_0x5bfeec&&_0x5bfeec['code']===_0xac2ff9(0x1a7))return![];throw _0x5bfeec;}};if(!_0xc6c814()){_0x5710e1(),_0xc6c814();if(_0x679e90==null&&lockTimeoutMs>0x0)while(_0x5dd036()-_0x3be81a<lockTimeoutMs){await new Promise(_0x32966f=>setTimeout(_0x32966f,0x19));if(_0xc6c814())break;_0x5710e1();}}if(_0x679e90==null){try{_0x543d78['rmSync'](_0x187092,{'recursive':!![],'force':!![]});}catch{}return{'published':![],'reason':_0xc51624(0x1dc)};}try{const _0x417aaa=this['readCurrentClock']();if(_0x32207d<=_0x417aaa){try{_0x543d78[_0xc51624(0x1b6)](_0x187092,{'recursive':!![],'force':!![]});}catch{}return{'published':![],'reason':_0xc51624(0x16e),'currentClock':_0x417aaa};}if(!_0x2511cc(_0x2b6488))_0x543d78[_0xc51624(0x198)](_0x187092,_0x2b6488);else try{_0x543d78[_0xc51624(0x1b6)](_0x187092,{'recursive':!![],'force':!![]});}catch{}return _0x2acabb(this[_0xc51624(0x1cb)],_0x133e93+'\x0a'),this[_0xc51624(0x1f3)]({'keep':keep}),{'published':!![],'currentClock':_0x32207d};}finally{try{_0x543d78[_0xc51624(0x15e)](_0x679e90);}catch{}try{_0x543d78[_0xc51624(0x213)](this['lockPath']);}catch{}}}},snapshotStore;}var labelMap,hasRequiredLabelMap;function requireLabelMap(){const _0x529b5e=_0x2bb8dc;if(hasRequiredLabelMap)return labelMap;hasRequiredLabelMap=0x1;const _0x301d55=require$$0;class _0x3f5a48{constructor(){const _0x2b53a1=_0x4d49;this[_0x2b53a1(0x1e5)]=new Map(),this['labelToKey']=new Map(),this[_0x2b53a1(0x1f5)]=0x0,this[_0x2b53a1(0x1ee)]=0x0,this[_0x2b53a1(0x1ab)]=new Map(),this[_0x2b53a1(0x202)]=!![];}async[_0x529b5e(0x1b9)](){const _0x40a927=_0x529b5e;this['keyToLabel']=new Map(),this['labelToKey']=new Map(),this[_0x40a927(0x1ab)]=new Map(),this[_0x40a927(0x202)]=!![],this['nextLabel']=0x0,this[_0x40a927(0x1ee)]=0x0;}async[_0x529b5e(0x218)](_0x2e9ee8){const _0x2cd088=_0x529b5e;if(!_0x2e9ee8||!_0x301d55['existsSync'](_0x2e9ee8))return await this[_0x2cd088(0x1b9)](),!![];let _0x544310;try{_0x544310=_0x301d55['readFileSync'](_0x2e9ee8,_0x2cd088(0x15c));}catch{return await this[_0x2cd088(0x1b9)](),!![];}let _0x2769ba;try{_0x2769ba=JSON[_0x2cd088(0x21e)](_0x544310);}catch{return await this[_0x2cd088(0x1b9)](),!![];}const _0x5261ae=Array[_0x2cd088(0x207)](_0x2769ba?.['entries'])?_0x2769ba[_0x2cd088(0x166)]:[],_0x12b4f6=Number[_0x2cd088(0x230)](_0x2769ba?.['nextLabel'])?_0x2769ba[_0x2cd088(0x1f5)]:0x0,_0x5e3769=new Map(),_0xb7dabf=new Map(),_0x55b348=new Map(),_0x3cd269=_0x2769ba?.[_0x2cd088(0x21a)]>=0x2;let _0x29f00d=-0x1;for(const _0x469a62 of _0x5261ae){if(!Array[_0x2cd088(0x207)](_0x469a62)||_0x469a62[_0x2cd088(0x1d3)]<0x2)continue;const _0x58c1dc=Number(_0x469a62[0x0]),_0x32e58c=String(_0x469a62[0x1]??'');if(!Number[_0x2cd088(0x230)](_0x58c1dc)||_0x58c1dc<0x0)continue;if(!_0x32e58c)continue;_0x5e3769[_0x2cd088(0x197)](_0x32e58c,_0x58c1dc),_0xb7dabf[_0x2cd088(0x197)](_0x58c1dc,_0x32e58c);if(_0x3cd269&&typeof _0x469a62[0x2]==='number')_0x55b348['set'](_0x32e58c,_0x469a62[0x2]);if(_0x58c1dc>_0x29f00d)_0x29f00d=_0x58c1dc;}return this['keyToLabel']=_0x5e3769,this[_0x2cd088(0x170)]=_0xb7dabf,this[_0x2cd088(0x1ab)]=_0x55b348,this[_0x2cd088(0x202)]=_0x3cd269,this[_0x2cd088(0x1f5)]=Math['max'](_0x12b4f6,_0x29f00d+0x1,0x0),this[_0x2cd088(0x1ee)]=0x0,!![];}[_0x529b5e(0x211)](_0x23803a){const _0x462ab5=_0x529b5e;return this[_0x462ab5(0x1e5)]['get'](_0x23803a);}[_0x529b5e(0x1fa)](_0x533f1c){const _0x510ab7=_0x529b5e;let _0x2f6bc2=this[_0x510ab7(0x1e5)]['get'](_0x533f1c);if(_0x2f6bc2!==undefined)return _0x2f6bc2;return _0x2f6bc2=this[_0x510ab7(0x1f5)]++,this[_0x510ab7(0x1e5)][_0x510ab7(0x197)](_0x533f1c,_0x2f6bc2),this[_0x510ab7(0x170)][_0x510ab7(0x197)](_0x2f6bc2,_0x533f1c),_0x2f6bc2;}[_0x529b5e(0x217)](_0x447ffa,_0x1ca962){const _0x1c36cd=_0x529b5e;if(_0x1ca962==null)this[_0x1c36cd(0x1ab)][_0x1c36cd(0x19c)](_0x447ffa);else this['keyToFp']['set'](_0x447ffa,_0x1ca962);}['fingerprintOf'](_0x42dc90){const _0x55f150=_0x529b5e;return this[_0x55f150(0x1ab)][_0x55f150(0x167)](_0x42dc90);}[_0x529b5e(0x1f9)](){const _0x241756=_0x529b5e;return this['keyToLabel'][_0x241756(0x1f9)]();}[_0x529b5e(0x1de)](_0x1b8b36){const _0xe1d486=_0x529b5e,_0x35755a=this[_0xe1d486(0x1e5)]['get'](_0x1b8b36);if(_0x35755a===undefined)return;this['keyToFp']['delete'](_0x1b8b36),this[_0xe1d486(0x1e5)]['delete'](_0x1b8b36),this['labelToKey'][_0xe1d486(0x19c)](_0x35755a),this['_tombstoneCount']++;}[_0x529b5e(0x210)](_0x596c79){const _0xd60826=_0x529b5e;return this[_0xd60826(0x170)][_0xd60826(0x167)](_0x596c79)??null;}[_0x529b5e(0x1a0)](){const _0x9f79b2=_0x529b5e;return this[_0x9f79b2(0x1e5)][_0x9f79b2(0x1a0)];}['tombstoneCount'](){return this['_tombstoneCount'];}async[_0x529b5e(0x1cc)](_0x5ed1b8){const _0x3b86a0=_0x529b5e,_0x20df5b=_0x5ed1b8+_0x3b86a0(0x1be),_0x433112=[];for(const [_0x18028b,_0x41df2c]of this['labelToKey'][_0x3b86a0(0x166)]()){const _0x4287f1=this[_0x3b86a0(0x1ab)][_0x3b86a0(0x167)](_0x41df2c);_0x433112['push'](_0x4287f1==null?[_0x18028b,_0x41df2c]:[_0x18028b,_0x41df2c,_0x4287f1]);}_0x433112[_0x3b86a0(0x1c9)]((_0x185443,_0x56f695)=>_0x185443[0x0]-_0x56f695[0x0]);const _0x4c0e76={'version':0x2,'nextLabel':this['nextLabel'],'entries':_0x433112};_0x301d55[_0x3b86a0(0x21f)](_0x20df5b,JSON[_0x3b86a0(0x1e6)](_0x4c0e76)),_0x301d55['renameSync'](_0x20df5b,_0x5ed1b8);}}return labelMap=_0x3f5a48,labelMap;}var indexConvergence,hasRequiredIndexConvergence;function requireIndexConvergence(){if(hasRequiredIndexConvergence)return indexConvergence;hasRequiredIndexConvergence=0x1;function _0x10564d(_0x3eb555){const _0x28ae4f=_0x4d49,_0x7d746b=new Uint32Array(_0x3eb555['buffer'],_0x3eb555[_0x28ae4f(0x1d4)],_0x3eb555[_0x28ae4f(0x1d3)]);let _0x381f6d=0x811c9dc5,_0x40e7b5=0x9747b28c;for(let _0x13c1e4=0x0;_0x13c1e4<_0x7d746b[_0x28ae4f(0x1d3)];_0x13c1e4++){const _0xe891da=_0x7d746b[_0x13c1e4];_0x381f6d=Math['imul'](_0x381f6d^_0xe891da,0x1000193)>>>0x0;let _0x5dc6bc=Math[_0x28ae4f(0x1a3)](_0xe891da,0xcc9e2d51);_0x5dc6bc=_0x5dc6bc<<0xf|_0x5dc6bc>>>0x11,_0x40e7b5=Math[_0x28ae4f(0x1a3)](_0x40e7b5^Math[_0x28ae4f(0x1a3)](_0x5dc6bc,0x1b873593),0x5)+0xe6546b64,_0x40e7b5>>>=0x0;}return _0x40e7b5=Math[_0x28ae4f(0x1a3)](_0x40e7b5^_0x40e7b5>>>0x10,0x85ebca6b)>>>0x0,(_0x381f6d>>>0x0)*0x100000+(_0x40e7b5&0xfffff);}function _0xb3cc8e(_0x34e0aa,_0x9bc043,_0x17fc20,{upsert:_0x47ceec,remove:_0x4ec194}){const _0x2daab8=_0x4d49,_0x30d84a=new Set();let _0x237ab4=0x0,_0xee4557=0x0,_0x3440aa=0x0;for(const {key:_0xa0dae8,vector:_0x595644}of _0x9bc043){if(!(_0x595644 instanceof Float32Array)||_0x595644[_0x2daab8(0x1d3)]!==_0x17fc20)continue;_0x30d84a[_0x2daab8(0x174)](_0xa0dae8);const _0x53d46b=_0x10564d(_0x595644),_0x21c19c=_0x34e0aa['labelForExisting'](_0xa0dae8)!==undefined;if(_0x21c19c&&_0x34e0aa[_0x2daab8(0x20d)](_0xa0dae8)===_0x53d46b)continue;_0x47ceec(_0xa0dae8,_0x595644,_0x53d46b);if(_0x21c19c)_0xee4557++;else _0x237ab4++;}for(const _0x2d4fce of[..._0x34e0aa[_0x2daab8(0x1f9)]()]){if(_0x30d84a['has'](_0x2d4fce))continue;_0x4ec194(_0x2d4fce),_0x3440aa++;}return{'added':_0x237ab4,'changed':_0xee4557,'removed':_0x3440aa};}return indexConvergence={'fingerprint':_0x10564d,'reconcileIndex':_0xb3cc8e},indexConvergence;}var hnsw,hasRequiredHnsw;function requireHnsw(){if(hasRequiredHnsw)return hnsw;hasRequiredHnsw=0x1;const _0x3cb458=requireSnapshotStore(),_0xdd6a39=requireLabelMap(),{fingerprint:_0x33f25c,reconcileIndex:_0x17ff07}=requireIndexConvergence(),_0x211b99=0x1;let _0x1ab192=null;function _0x404832(){const _0x214f28=_0x4d49;if(_0x1ab192)return _0x1ab192;try{return _0x1ab192=require(_0x214f28(0x1a9)),_0x1ab192;}catch(_0x287517){const _0x55e690=new Error('HNSW\x20algorithm\x20unavailable:\x20the\x20native\x20\x22hnswlib-node\x22\x20bindings\x20could\x20not\x20be\x20loaded\x20'+('for\x20Node\x20'+process[_0x214f28(0x226)][_0x214f28(0x20f)]+_0x214f28(0x1fb)+process['platform']+'/'+process[_0x214f28(0x17c)]+'.\x20')+_0x214f28(0x22e)+('Original\x20error:\x20'+(_0x287517?.[_0x214f28(0x1df)]||String(_0x287517))));_0x55e690[_0x214f28(0x1f6)]=_0x214f28(0x22f),_0x55e690[_0x214f28(0x180)]=_0x287517;throw _0x55e690;}}return hnsw=function _0x4ea813(_0x3dd386={},{dims:_0x167713,dir:_0x54bfe2}){const _0x4541bc=_0x4d49,_0x2a2ddf=_0x404832();if(!_0x167713||_0x167713<=0x0)throw new Error(_0x4541bc(0x203));if(!_0x54bfe2)throw new Error(_0x4541bc(0x1b7));const _0x18b524={'metric':_0x3dd386[_0x4541bc(0x1ff)]??_0x4541bc(0x188),'M':_0x3dd386['M']??0x10,'efConstruction':_0x3dd386[_0x4541bc(0x1c0)]??0xc8,'efSearch':_0x3dd386[_0x4541bc(0x1bb)]??0x40,'maxElements':_0x3dd386['maxElements']??0x400,'growFactor':_0x3dd386[_0x4541bc(0x1ce)]??0x2,'snapshotEveryChanges':_0x3dd386[_0x4541bc(0x200)]??0xc350,'keepSnapshots':_0x3dd386[_0x4541bc(0x208)]??0x2,'tmpMaxAgeMs':_0x3dd386[_0x4541bc(0x233)]??0x6*0x36ee80},_0x134eda=new _0x3cb458({'dir':_0x54bfe2,'keepSnapshots':_0x18b524['keepSnapshots']}),_0x52d7a7=new _0xdd6a39();let _0x2afc78=null,_0x3f99ba=0x0,_0x18b72e=null,_0x36bb6d=Promise[_0x4541bc(0x161)]();const _0x25d3ab=_0x3fd874=>{const _0x39a032=_0x4541bc,_0x1160a8=_0x36bb6d['then'](_0x3fd874);return _0x36bb6d=_0x1160a8[_0x39a032(0x1ec)](()=>{}),_0x1160a8;};async function _0x3dc048(_0x34a322){const _0x14da99=_0x4541bc;await _0x52d7a7[_0x14da99(0x1b9)](),_0x34a322=_0x34a322??[];const _0x14ee20=Math['max'](_0x18b524[_0x14da99(0x209)],Math[_0x14da99(0x227)](_0x34a322['length']*(_0x18b524[_0x14da99(0x1ce)]||1.2)),0x1);_0x2afc78=new _0x2a2ddf[(_0x14da99(0x1a6))](_0x18b524[_0x14da99(0x1ff)],_0x167713),_0x2afc78[_0x14da99(0x216)]({'maxElements':_0x14ee20,'efConstruction':_0x18b524[_0x14da99(0x1c0)],'M':_0x18b524['M']});for(const {key:_0x1234dd,vector:_0xe268aa}of _0x34a322){if(!(_0xe268aa instanceof Float32Array)||_0xe268aa[_0x14da99(0x1d3)]!==_0x167713)continue;_0x4bad0e(_0x1234dd,_0xe268aa);}_0x2afc78[_0x14da99(0x1a2)](_0x18b524[_0x14da99(0x1bb)]),_0x3f99ba=0x0;}async function _0x3483ec(_0x4ce1f9){return _0x3dc048(_0x4ce1f9?await _0x4ce1f9():[]);}function _0x17aa50(){const _0x1a87c7=_0x4541bc;if(_0x2afc78['getCurrentCount']()<_0x2afc78['getMaxElements']())return;const _0xe4621b=Math[_0x1a87c7(0x227)](_0x2afc78['getMaxElements']()*(_0x18b524[_0x1a87c7(0x1ce)]||0x2));_0x2afc78[_0x1a87c7(0x183)](_0xe4621b),_0x18b524[_0x1a87c7(0x209)]=_0xe4621b;}function _0x4bad0e(_0x4397c3,_0x33cc60,_0x551a30){const _0x3ea556=_0x4541bc,_0x172f77=_0x52d7a7[_0x3ea556(0x1fa)](_0x4397c3);try{_0x2afc78['markDelete'](_0x172f77);}catch{}_0x17aa50(),_0x2afc78['addPoint'](Array[_0x3ea556(0x20b)](_0x33cc60),_0x172f77),_0x52d7a7[_0x3ea556(0x217)](_0x4397c3,_0x551a30??_0x33f25c(_0x33cc60));}function _0x17864f(_0x2749de){const _0x5e923e=_0x4541bc,_0x4ac58a=_0x52d7a7[_0x5e923e(0x211)](_0x2749de);if(_0x4ac58a===undefined)return![];try{_0x2afc78['markDelete'](_0x4ac58a);}catch{}return _0x52d7a7[_0x5e923e(0x1de)](_0x2749de),!![];}function _0x442cee(){const _0x56228c=_0x4541bc;return Math[_0x56228c(0x1bf)](Date['now'](),_0x134eda[_0x56228c(0x1b2)]()+0x1);}async function _0x2f027d(_0x4ee884){const _0x3e75a7=_0x4541bc;if(!_0x2afc78||!_0x4ee884)return![];const _0x3c4d3c=await _0x134eda[_0x3e75a7(0x214)](_0x4ee884,async _0x310ae8=>{const _0x4b54a0=_0x3e75a7;_0x2afc78[_0x4b54a0(0x1b5)](_0x310ae8[_0x4b54a0(0x19a)]),await _0x52d7a7[_0x4b54a0(0x1cc)](_0x310ae8[_0x4b54a0(0x199)]);const _0x47aa16=require$$0;_0x47aa16[_0x4b54a0(0x21f)](_0x310ae8[_0x4b54a0(0x231)],JSON[_0x4b54a0(0x1e6)]({'manifestVersion':_0x211b99,'dims':_0x167713,'metric':_0x18b524[_0x4b54a0(0x1ff)],'clock':_0x4ee884,'snapshotAt':Date['now']()},null,0x2));},{'keep':_0x18b524[_0x3e75a7(0x208)]});if(_0x3c4d3c?.[_0x3e75a7(0x1dd)])_0x3f99ba=0x0;return _0x3c4d3c?.[_0x3e75a7(0x1dd)]??![];}async function _0x182aae(){const _0x3886e2=_0x4541bc,_0x3e1243=_0x134eda[_0x3886e2(0x1e3)]()||_0x134eda[_0x3886e2(0x1c6)]();if(!_0x3e1243)return null;let _0x31aa9c,_0x19b512=![];return await _0x134eda[_0x3886e2(0x222)](_0x3e1243,async _0x205741=>{const _0x4949de=_0x3886e2,_0x442888=require$$0;_0x31aa9c=JSON[_0x4949de(0x21e)](_0x442888[_0x4949de(0x18e)](_0x205741[_0x4949de(0x231)],_0x4949de(0x15c)));if(_0x31aa9c[_0x4949de(0x22d)]!==_0x211b99||_0x31aa9c[_0x4949de(0x22a)]!==_0x167713||_0x31aa9c[_0x4949de(0x1ff)]!==_0x18b524[_0x4949de(0x1ff)]){_0x31aa9c=null;return;}await _0x52d7a7[_0x4949de(0x218)](_0x205741[_0x4949de(0x199)]),_0x2afc78=new _0x2a2ddf['HierarchicalNSW'](_0x18b524[_0x4949de(0x1ff)],_0x167713),_0x2afc78[_0x4949de(0x16d)](_0x205741[_0x4949de(0x19a)]),_0x2afc78['setEf'](_0x18b524[_0x4949de(0x1bb)]),_0x19b512=!![];}),_0x19b512?_0x31aa9c?.[_0x3886e2(0x1fe)]??0x0:null;}return{async 'load'(_0x47b14e){return _0x25d3ab(async()=>{const _0x228973=_0x4d49;_0x134eda[_0x228973(0x1b1)]({'maxAgeMs':_0x18b524[_0x228973(0x233)]}),_0x18b72e=_0x47b14e??null;const _0x5ec447=await _0x182aae(),_0xcf61a1=_0x47b14e?await _0x47b14e():null;if(_0x5ec447!=null){if(_0xcf61a1){if(!_0x52d7a7[_0x228973(0x202)])return await _0x3dc048(_0xcf61a1),null;const _0x3e8c2e=_0x17ff07(_0x52d7a7,_0xcf61a1,_0x167713,{'upsert':_0x4bad0e,'remove':_0x17864f});_0x3f99ba+=_0x3e8c2e[_0x228973(0x1bd)]+_0x3e8c2e['changed']+_0x3e8c2e[_0x228973(0x182)];}return _0x5ec447;}return await _0x3dc048(_0xcf61a1),null;});},async 'add'(_0x3f2f6c,_0x4ffd63,_0x32d0b0){return _0x25d3ab(async()=>{const _0x5b60f2=_0x4d49;if(!_0x2afc78)return;const _0x32846d=_0x4ffd63 instanceof Float32Array?_0x4ffd63:new Float32Array(_0x4ffd63),_0x7bcc99=_0x33f25c(_0x32846d);if(_0x52d7a7[_0x5b60f2(0x20d)](_0x3f2f6c)===_0x7bcc99)return;_0x4bad0e(_0x3f2f6c,_0x32846d,_0x7bcc99),_0x3f99ba++,_0x3f99ba>=_0x18b524['snapshotEveryChanges']&&await _0x2f027d(_0x442cee());});},async 'remove'(_0x2b6ad3){return _0x25d3ab(async()=>{if(!_0x2afc78)return;if(_0x17864f(_0x2b6ad3))_0x3f99ba++;});},'search'(_0x597282,{limit:limit=0xa,efSearch:_0x1d66d1}={}){const _0xfa7597=_0x4541bc;if(!_0x2afc78)return[];if(Number[_0xfa7597(0x230)](_0x1d66d1))_0x2afc78[_0xfa7597(0x1a2)](_0x1d66d1);const _0x4f49a3=Math[_0xfa7597(0x223)](limit,_0x2afc78[_0xfa7597(0x234)]()||0x1),{neighbors:_0x20a524,distances:_0x2644d1}=_0x2afc78[_0xfa7597(0x205)](Array[_0xfa7597(0x20b)](_0x597282),_0x4f49a3),_0x2b3e4c=[];for(let _0x4f204d=0x0;_0x4f204d<_0x20a524[_0xfa7597(0x1d3)];_0x4f204d++){const _0x3f7ca8=_0x52d7a7[_0xfa7597(0x210)](_0x20a524[_0x4f204d]);if(!_0x3f7ca8)continue;const _0xcd361a=_0x18b524['metric']==='cosine'?Math['max'](0x0,0x1-_0x2644d1[_0x4f204d]):0x1/(0x1+_0x2644d1[_0x4f204d]);_0x2b3e4c[_0xfa7597(0x19f)]({'key':_0x3f7ca8,'score':_0xcd361a});}return _0x2b3e4c;},async 'snapshot'(_0x1daa31){return _0x25d3ab(()=>_0x2f027d(_0x1daa31??_0x442cee()));},async 'rebuild'(_0x112f5c){return _0x25d3ab(()=>{if(_0x112f5c!=null)_0x18b72e=_0x112f5c;return _0x3483ec(_0x112f5c??_0x18b72e);});},async 'stop'(){const _0x231d5d=_0x4541bc;return _0x25d3ab(()=>_0x3f99ba>0x0||!_0x134eda[_0x231d5d(0x1e3)]()?_0x2f027d(_0x442cee()):![]);},'count'(){return _0x52d7a7['size']();},'info'(){const _0x8fad7=_0x4541bc;return{'algorithm':_0x8fad7(0x224),'metric':_0x18b524['metric'],'M':_0x18b524['M'],'efConstruction':_0x18b524[_0x8fad7(0x1c0)],'efSearch':_0x18b524['efSearch'],'maxElements':_0x2afc78?.[_0x8fad7(0x19b)]()??_0x18b524['maxElements'],'count':_0x52d7a7[_0x8fad7(0x1a0)](),'changesSince':_0x3f99ba,'snapshotDir':_0x54bfe2,'latestSnapshot':_0x134eda[_0x8fad7(0x1e3)]()??null};}};},hnsw;}var flat,hasRequiredFlat;function requireFlat(){if(hasRequiredFlat)return flat;hasRequiredFlat=0x1,flat=function _0x16f701(_0x5b5226={}){const _0x40660d=new Map();return{async 'load'(_0x4c4fe5){const _0x3731d8=_0x4d49;_0x40660d[_0x3731d8(0x1c3)]();if(_0x4c4fe5)for(const {key:_0x3b6a09,vector:_0x441c97}of await _0x4c4fe5()){_0x40660d[_0x3731d8(0x197)](_0x3b6a09,_0x441c97);}},async 'add'(_0x18db81,_0x54f47f,_0x247e3c){const _0x23f24d=_0x4d49;_0x40660d[_0x23f24d(0x197)](_0x18db81,_0x54f47f);},async 'remove'(_0x6b958){const _0x370976=_0x4d49;_0x40660d[_0x370976(0x19c)](_0x6b958);},'search'(_0x381588,{limit:limit=0xa,threshold:threshold=0x0}={}){const _0x28f996=_0x4d49,_0x5f4960=[];for(const [_0x36ceff,_0xefe58e]of _0x40660d){const _0x34d48b=_0xd30eb6(_0x381588,_0xefe58e);if(_0x34d48b>=threshold)_0x5f4960[_0x28f996(0x19f)]({'key':_0x36ceff,'score':_0x34d48b});}return _0x5f4960[_0x28f996(0x1c9)]((_0xdfd28e,_0x4657a9)=>_0x4657a9[_0x28f996(0x15b)]-_0xdfd28e['score']),_0x5f4960[_0x28f996(0x17f)](0x0,limit);},async 'snapshot'(){return![];},async 'rebuild'(_0x975c8d){await this['load'](_0x975c8d);},async 'stop'(){},'count'(){const _0x3d5ce1=_0x4d49;return _0x40660d[_0x3d5ce1(0x1a0)];},'info'(){const _0x3bfb80=_0x4d49;return{'algorithm':_0x3bfb80(0x189),'count':_0x40660d[_0x3bfb80(0x1a0)]};}};};function _0xd30eb6(_0x335e26,_0x58d36a){const _0x53ff7e=_0x4d49;let _0x6a7292=0x0,_0x4af5be=0x0,_0x352574=0x0;for(let _0xb679a3=0x0;_0xb679a3<_0x335e26[_0x53ff7e(0x1d3)];_0xb679a3++){_0x6a7292+=_0x335e26[_0xb679a3]*_0x58d36a[_0xb679a3],_0x4af5be+=_0x335e26[_0xb679a3]*_0x335e26[_0xb679a3],_0x352574+=_0x58d36a[_0xb679a3]*_0x58d36a[_0xb679a3];}const _0x3d4110=Math[_0x53ff7e(0x1f7)](_0x4af5be)*Math[_0x53ff7e(0x1f7)](_0x352574);return _0x3d4110===0x0?0x0:_0x6a7292/_0x3d4110;}return flat;}var okdbTimers,hasRequiredOkdbTimers;function requireOkdbTimers(){if(hasRequiredOkdbTimers)return okdbTimers;hasRequiredOkdbTimers=0x1;const _0x2a99f4=0x2**0x1f-0x1;function _0x4328cf(_0x187641){if(!(_0x187641>0x0))return 0x0;return _0x187641>_0x2a99f4?_0x2a99f4:_0x187641;}function _0x3f31d7(_0x3e604d){return _0x3e604d===Infinity;}return okdbTimers={'MAX_TIMER_DELAY':_0x2a99f4,'clampTimerDelay':_0x4328cf,'isNeverDelay':_0x3f31d7},okdbTimers;}var writerLock,hasRequiredWriterLock;function requireWriterLock(){if(hasRequiredWriterLock)return writerLock;hasRequiredWriterLock=0x1;const _0x38a152=require$$0,{clampTimerDelay:_0x126fbb}=requireOkdbTimers(),_0x5daa7f=require$$1,_0x26daf9=require$$3;return writerLock=function _0x1308e0(_0x243e04,{maxAgeMs:maxAgeMs=0x3a98,heartbeatMs:heartbeatMs=0x1388,onLost:onLost=null}={}){const _0x575632=_0x4d49,_0x2e8567=_0x5daa7f['join'](_0x243e04,_0x575632(0x1e2)),_0x43ca97=_0x26daf9[_0x575632(0x1b4)](0x8)[_0x575632(0x1f2)]('hex');let _0x24aa1c=![],_0x4056a8=null;const _0x417abd=()=>JSON['stringify']({'pid':process['pid'],'token':_0x43ca97,'at':Date[_0x575632(0x22b)]()});function _0x189290(){const _0x26a775=_0x575632;try{return JSON[_0x26a775(0x21e)](_0x38a152[_0x26a775(0x18e)](_0x2e8567,_0x26a775(0x15c)));}catch(_0x214600){return _0x214600?.[_0x26a775(0x1f6)]===_0x26a775(0x1c5)?null:{'unreadable':!![]};}}function _0x459cfc(){const _0x3d2c46=_0x575632;try{const _0x287c8c=_0x38a152[_0x3d2c46(0x1cd)](_0x2e8567,'wx');try{_0x38a152['writeFileSync'](_0x287c8c,_0x417abd());}finally{_0x38a152[_0x3d2c46(0x15e)](_0x287c8c);}return!![];}catch(_0x28a26d){if(_0x28a26d?.[_0x3d2c46(0x1f6)]===_0x3d2c46(0x1a7))return![];throw _0x28a26d;}}function _0x2ef3f5(_0x406d8e){const _0x44fb62=_0x575632;if(!_0x406d8e)return!![];if(_0x406d8e[_0x44fb62(0x229)])return!![];return Date['now']()-(_0x406d8e['at']??0x0)>=maxAgeMs;}function _0x3a94d1(){if(_0x4056a8)clearInterval(_0x4056a8);_0x4056a8=null;}function _0x32959b(){const _0x188941=_0x575632;_0x3a94d1(),_0x4056a8=setInterval(()=>{const _0x9b645a=_0x4d49,_0x22abb0=_0x189290();if(_0x22abb0&&!_0x22abb0[_0x9b645a(0x229)]&&_0x22abb0['token']!==_0x43ca97){_0x24aa1c=![],_0x3a94d1();try{onLost?.();}catch{}return;}try{_0x38a152[_0x9b645a(0x21f)](_0x2e8567,_0x417abd());}catch{}},_0x126fbb(heartbeatMs)),_0x4056a8[_0x188941(0x1bc)]?.();}function _0x4575ef(){const _0x48d9dd=_0x575632,_0x3d20b1=_0x189290();return!!_0x3d20b1&&_0x3d20b1[_0x48d9dd(0x225)]===_0x43ca97;}return{'path':_0x2e8567,'token':_0x43ca97,'acquire'(){const _0x2d2a65=_0x575632,_0x4f6190=_0x189290();if(_0x4f6190&&_0x4f6190['token']===_0x43ca97){_0x24aa1c=!![];if(!_0x4056a8)_0x32959b();return!![];}let _0x22350e=_0x459cfc();if(!_0x22350e&&_0x2ef3f5(_0x189290())){try{_0x38a152[_0x2d2a65(0x213)](_0x2e8567);}catch{}_0x22350e=_0x459cfc();}if(_0x22350e&&!_0x4575ef())_0x22350e=![];_0x24aa1c=_0x22350e;if(_0x22350e)_0x32959b();return _0x22350e;},'held'(){return _0x24aa1c;},'isFree'(){const _0x1ba443=_0x575632,_0x50a600=_0x189290();if(_0x50a600&&_0x50a600[_0x1ba443(0x225)]===_0x43ca97)return![];return _0x2ef3f5(_0x50a600);},'release'(){const _0x405479=_0x575632;_0x3a94d1();if(!_0x24aa1c)return;_0x24aa1c=![];if(_0x4575ef())try{_0x38a152[_0x405479(0x213)](_0x2e8567);}catch{}}};},writerLock;}var usearch,hasRequiredUsearch;function requireUsearch(){if(hasRequiredUsearch)return usearch;hasRequiredUsearch=0x1;const _0x360e92=require$$0,{clampTimerDelay:_0x53e9ce,isNeverDelay:_0x5684ab}=requireOkdbTimers(),_0x2cd8fc=requireSnapshotStore(),_0x550e55=requireLabelMap(),_0x238985=requireWriterLock(),{fingerprint:_0x526174,reconcileIndex:_0x59ccc2}=requireIndexConvergence(),_0x141e1e=0x1;let _0x4949e9=null;function _0x2b3217(){const _0x3a8bdb=_0x4d49;if(_0x4949e9)return _0x4949e9;try{return _0x4949e9=require(_0x3a8bdb(0x18d)),_0x4949e9;}catch(_0x13aa29){const _0x1fa087=new Error(_0x3a8bdb(0x196)+(_0x3a8bdb(0x1ef)+process['versions'][_0x3a8bdb(0x20f)]+_0x3a8bdb(0x1fb)+process[_0x3a8bdb(0x1e4)]+'/'+process[_0x3a8bdb(0x17c)]+'.\x20')+_0x3a8bdb(0x193)+(_0x3a8bdb(0x1d5)+(_0x13aa29?.[_0x3a8bdb(0x1df)]||String(_0x13aa29))));_0x1fa087['code']=_0x3a8bdb(0x1aa),_0x1fa087[_0x3a8bdb(0x180)]=_0x13aa29;throw _0x1fa087;}}function _0x136f34(_0x48673e,_0x734989){const _0xb401e3=_0x4d49;switch(_0x48673e){case'cosine':return _0x734989['MetricKind']['Cos'];case'l2':return _0x734989[_0xb401e3(0x221)][_0xb401e3(0x1db)];case'ip':return _0x734989[_0xb401e3(0x221)]['IP'];default:return _0x734989[_0xb401e3(0x221)][_0xb401e3(0x184)];}}return usearch=function _0x22957f(_0xcb6293={},{dims:_0x2bc9d0,dir:_0x43e18a,fetchAll:fetchAll=null,onChange:onChange=null}={}){const _0x2c9538=_0x4d49,_0x1b8e01=_0x2b3217();if(!_0x2bc9d0||_0x2bc9d0<=0x0)throw new Error('usearch\x20algorithm\x20requires\x20dims\x20>\x200');if(!_0x43e18a)throw new Error(_0x2c9538(0x1ae));const _0x5857bf={'metric':_0xcb6293[_0x2c9538(0x1ff)]??_0x2c9538(0x188),'connectivity':_0xcb6293[_0x2c9538(0x1c1)]??0x10,'expansionAdd':_0xcb6293['expansionAdd']??0x80,'expansionSearch':_0xcb6293[_0x2c9538(0x1d8)]??0x40,'snapshotEveryChanges':_0xcb6293[_0x2c9538(0x200)]??0xc350,'snapshotMaxLagMs':_0xcb6293[_0x2c9538(0x192)]??0x2710,'keepSnapshots':_0xcb6293[_0x2c9538(0x208)]??0x2,'tmpMaxAgeMs':_0xcb6293[_0x2c9538(0x233)]??0x6*0x36ee80,'heartbeatIntervalMs':_0xcb6293['heartbeatIntervalMs']??0x1388,'writerLockMaxAgeMs':_0xcb6293[_0x2c9538(0x1d2)]??0x3a98,'viewRefreshMs':_0xcb6293[_0x2c9538(0x1e1)]??0x3e8},_0x392d36=new _0x2cd8fc({'dir':_0x43e18a,'keepSnapshots':_0x5857bf[_0x2c9538(0x208)]}),_0x5d64ed=_0x238985(_0x43e18a,{'maxAgeMs':_0x5857bf[_0x2c9538(0x1d2)],'heartbeatMs':_0x5857bf[_0x2c9538(0x163)],'onLost':()=>{const _0x177bcd=_0x2c9538;_0x40b5a0(_0x32fa59)[_0x177bcd(0x1ec)](()=>{});}});let _0x5730fa=new _0x550e55(),_0x54da18=null,_0x13bde7=0x0,_0x5f2179=null,_0x5d9ba5=![],_0x4754dd=![],_0x3590b3=null,_0x30fe74=0x0,_0x300699=null,_0x4de774=0x0,_0x436cf6=![],_0x188f3a=Promise[_0x2c9538(0x161)]();const _0x40b5a0=_0x1f3fe3=>{const _0x2d48a5=_0x2c9538,_0x5c2be4=_0x188f3a[_0x2d48a5(0x15d)](_0x1f3fe3);return _0x188f3a=_0x5c2be4[_0x2d48a5(0x1ec)](()=>{}),_0x5c2be4;},_0x1bc1a6=()=>{try{onChange?.();}catch{}};function _0xe6913d(){const _0x231230=_0x2c9538;return new _0x1b8e01[(_0x231230(0x1c7))]({'dimensions':_0x2bc9d0,'metric':_0x136f34(_0x5857bf[_0x231230(0x1ff)],_0x1b8e01),'quantization':_0x1b8e01['ScalarKind'][_0x231230(0x16b)],'connectivity':_0x5857bf[_0x231230(0x1c1)],'expansion_add':_0x5857bf[_0x231230(0x1f8)],'expansion_search':_0x5857bf['expansionSearch'],'multi':![]});}function _0xe6bd6b(_0x39765b){return _0x39765b instanceof Float32Array?_0x39765b:new Float32Array(_0x39765b);}function _0x422ded(){if(fetchAll)return fetchAll();if(_0x5f2179)return _0x5f2179();return Promise['resolve'](null);}function _0x874e7b(_0x175a48,_0x2abe0b,_0x10c861){const _0x5e0fcf=_0x2c9538,_0x5d6808=_0x5730fa[_0x5e0fcf(0x211)](_0x175a48);if(_0x5d6808!==undefined)try{_0x54da18[_0x5e0fcf(0x201)](BigInt(_0x5d6808));}catch{}const _0x48e591=_0x5730fa[_0x5e0fcf(0x1fa)](_0x175a48);_0x54da18[_0x5e0fcf(0x174)](BigInt(_0x48e591),_0x2abe0b),_0x5730fa[_0x5e0fcf(0x217)](_0x175a48,_0x10c861??_0x526174(_0x2abe0b));}function _0x400941(_0x2d8973){const _0x4fb5df=_0x2c9538,_0x182d57=_0x5730fa[_0x4fb5df(0x211)](_0x2d8973);if(_0x182d57===undefined)return![];try{_0x54da18[_0x4fb5df(0x201)](BigInt(_0x182d57));}catch{}return _0x5730fa[_0x4fb5df(0x1de)](_0x2d8973),!![];}function _0x36739f(_0x34abd0){const _0x3bdf30=_0x2c9538;_0x5730fa=new _0x550e55(),_0x54da18=_0xe6913d();for(const {key:_0x200213,vector:_0x2d901c}of _0x34abd0??[]){if(!(_0x2d901c instanceof Float32Array)||_0x2d901c[_0x3bdf30(0x1d3)]!==_0x2bc9d0)continue;_0x874e7b(_0x200213,_0x2d901c);}_0x13bde7=0x0;}function _0x172f03(){const _0x351a68=_0x2c9538;return Math[_0x351a68(0x1bf)](Date[_0x351a68(0x22b)](),_0x392d36['readCurrentClock']()+0x1);}function _0x405d55(){if(_0x3590b3)clearTimeout(_0x3590b3);_0x3590b3=null;}function _0x198f5e(){const _0x14585b=_0x2c9538;if(!_0x5857bf[_0x14585b(0x192)]||_0x5684ab(_0x5857bf[_0x14585b(0x192)])||_0x3590b3||!_0x4754dd||_0x13bde7<=0x0)return;const _0x4d2a2b=_0x53e9ce(Math[_0x14585b(0x1bf)](_0x5857bf['snapshotMaxLagMs'],0xa*_0x30fe74));_0x3590b3=setTimeout(()=>{const _0x66b08e=_0x14585b;_0x3590b3=null,_0x40b5a0(async()=>{if(_0x4754dd&&_0x13bde7>0x0)await _0x4bdbf2();_0x198f5e(),_0x1bc1a6();})[_0x66b08e(0x1ec)](()=>{});},_0x4d2a2b),_0x3590b3['unref']?.();}async function _0x4bdbf2(_0x3d4ecb){const _0x4b8cdb=_0x2c9538;if(!_0x54da18)return![];const _0x3135b6=_0x3d4ecb??_0x172f03(),_0x387247=Date[_0x4b8cdb(0x22b)](),_0x51b272=await _0x392d36[_0x4b8cdb(0x214)](_0x3135b6,async _0x95b489=>{const _0x5c0fc1=_0x4b8cdb;_0x54da18[_0x5c0fc1(0x1c4)](_0x95b489[_0x5c0fc1(0x19a)]),await _0x5730fa[_0x5c0fc1(0x1cc)](_0x95b489[_0x5c0fc1(0x199)]),_0x360e92[_0x5c0fc1(0x21f)](_0x95b489[_0x5c0fc1(0x231)],JSON[_0x5c0fc1(0x1e6)]({'manifestVersion':_0x141e1e,'algorithm':'usearch','dims':_0x2bc9d0,'metric':_0x5857bf[_0x5c0fc1(0x1ff)],'clock':_0x3135b6,'snapshotAt':Date[_0x5c0fc1(0x22b)]()},null,0x2));},{'keep':_0x5857bf[_0x4b8cdb(0x208)]});return _0x30fe74=Date[_0x4b8cdb(0x22b)]()-_0x387247,_0x51b272?.[_0x4b8cdb(0x1dd)]&&(_0x13bde7=0x0,_0x405d55()),_0x51b272?.[_0x4b8cdb(0x1dd)]??![];}function _0x375b6d(){_0x13bde7++;if(_0x13bde7>=_0x5857bf['snapshotEveryChanges'])return _0x4bdbf2();return _0x198f5e(),null;}async function _0x573f90(){const _0x5dcf41=_0x2c9538,_0xd5e221=_0x392d36[_0x5dcf41(0x1e3)]()||_0x392d36[_0x5dcf41(0x1c6)]();if(!_0xd5e221)return null;let _0x45c15e,_0x430c69=![];try{await _0x392d36[_0x5dcf41(0x222)](_0xd5e221,async _0x3acbcc=>{const _0x113009=_0x5dcf41;_0x45c15e=JSON[_0x113009(0x21e)](_0x360e92[_0x113009(0x18e)](_0x3acbcc['state'],_0x113009(0x15c)));if(_0x45c15e[_0x113009(0x22d)]!==_0x141e1e||_0x45c15e[_0x113009(0x1e8)]!==_0x113009(0x18d)||_0x45c15e[_0x113009(0x22a)]!==_0x2bc9d0||_0x45c15e[_0x113009(0x1ff)]!==_0x5857bf[_0x113009(0x1ff)]){_0x45c15e=null;return;}const _0x32ca46=new _0x550e55();await _0x32ca46[_0x113009(0x218)](_0x3acbcc[_0x113009(0x199)]);const _0x135ec8=_0xe6913d();_0x135ec8[_0x113009(0x1da)](_0x3acbcc[_0x113009(0x19a)]),_0x5730fa=_0x32ca46,_0x54da18=_0x135ec8,_0x430c69=!![];});}catch{return null;}return _0x430c69?_0x45c15e?.[_0x5dcf41(0x1fe)]??0x0:null;}async function _0x1c622a(_0x5904c9){const _0x64c9a9=_0x2c9538;_0x300699=null;const _0x2a8342=await _0x573f90();if(_0x2a8342!=null){_0x13bde7=0x0;if(_0x5904c9){if(!_0x5730fa['hasFingerprints'])return _0x36739f(_0x5904c9),await _0x4bdbf2(),null;const _0x225f26=_0x59ccc2(_0x5730fa,_0x5904c9,_0x2bc9d0,{'upsert':_0x874e7b,'remove':_0x400941}),_0x20c88a=_0x225f26[_0x64c9a9(0x1bd)]+_0x225f26[_0x64c9a9(0x1d6)]+_0x225f26[_0x64c9a9(0x182)];_0x20c88a>0x0&&(_0x13bde7+=_0x20c88a,await _0x4bdbf2());}return _0x2a8342;}_0x36739f(_0x5904c9??[]);if(_0x54da18[_0x64c9a9(0x1a0)]()>0x0)await _0x4bdbf2();return null;}async function _0x5472c6(){_0x4754dd=!![],await _0x1c622a(await _0x422ded());}async function _0x32fa59(){const _0x2307bc=_0x2c9538;if(!_0x4754dd)return;_0x4754dd=![],_0x405d55(),_0x13bde7=0x0;const _0x173997=_0x392d36[_0x2307bc(0x1e3)]()||_0x392d36[_0x2307bc(0x1c6)]();await _0x54d47e(_0x173997),_0x1bc1a6();}async function _0x54d47e(_0x377f2f){const _0x34fcd0=_0x2c9538;if(!_0x377f2f)return![];let _0x55fb8e=![];try{await _0x392d36[_0x34fcd0(0x222)](_0x377f2f,async _0x2c2ad2=>{const _0x15238b=_0x34fcd0,_0x1f3443=JSON[_0x15238b(0x21e)](_0x360e92[_0x15238b(0x18e)](_0x2c2ad2[_0x15238b(0x231)],'utf8'));if(_0x1f3443[_0x15238b(0x22d)]!==_0x141e1e||_0x1f3443[_0x15238b(0x1e8)]!=='usearch'||_0x1f3443['dims']!==_0x2bc9d0||_0x1f3443['metric']!==_0x5857bf[_0x15238b(0x1ff)])return;const _0x4f6c0e=new _0x550e55();await _0x4f6c0e[_0x15238b(0x218)](_0x2c2ad2[_0x15238b(0x199)]);const _0x516af6=_0xe6913d();_0x516af6['view'](_0x2c2ad2[_0x15238b(0x19a)]),_0x54da18=_0x516af6,_0x5730fa=_0x4f6c0e,_0x300699=_0x377f2f,_0x55fb8e=!![];});}catch{}return _0x55fb8e;}function _0x460926(){const _0xb05d04=_0x2c9538,_0x14b409=Date['now']();if(_0x14b409-_0x4de774<_0x5857bf[_0xb05d04(0x1e1)])return;_0x4de774=_0x14b409;if(_0x436cf6)return;if(_0x5d64ed['isFree']()){_0x436cf6=!![],_0x40b5a0(async()=>{!_0x4754dd&&_0x5d9ba5&&_0x5d64ed['acquire']()&&(await _0x5472c6(),_0x1bc1a6());})[_0xb05d04(0x1ec)](()=>{})['finally'](()=>{_0x436cf6=![];});return;}const _0x3e391d=_0x392d36[_0xb05d04(0x1e3)]()||_0x392d36[_0xb05d04(0x1c6)]();if(!_0x3e391d||_0x3e391d===_0x300699)return;_0x436cf6=!![],_0x40b5a0(async()=>{if(!_0x4754dd&&await _0x54d47e(_0x3e391d))_0x1bc1a6();})[_0xb05d04(0x1ec)](()=>{})[_0xb05d04(0x215)](()=>{_0x436cf6=![];});}return{async 'load'(_0x142ee1){return _0x40b5a0(async()=>{const _0x4e7a01=_0x4d49;_0x392d36[_0x4e7a01(0x1b1)]({'maxAgeMs':_0x5857bf[_0x4e7a01(0x233)]}),_0x5f2179=_0x142ee1??null,_0x4754dd=_0x5d64ed[_0x4e7a01(0x1a8)]();let _0x5e21bb=null;if(_0x4754dd)_0x5e21bb=await _0x1c622a(_0x142ee1?await _0x142ee1():null);else{const _0x5f3ea5=_0x392d36[_0x4e7a01(0x1e3)]()||_0x392d36[_0x4e7a01(0x1c6)]();await _0x54d47e(_0x5f3ea5);}return _0x5d9ba5=!![],_0x5e21bb;});},async 'add'(_0x3966d8,_0x527c05,_0x4cfff8){return _0x40b5a0(async()=>{const _0x46ce4c=_0x4d49;if(!_0x5d9ba5)return;const _0x1c2ccf=_0xe6bd6b(_0x527c05);if(!_0x4754dd){if(!_0x5d64ed[_0x46ce4c(0x1a8)]())return;await _0x5472c6();}if(!_0x54da18)return;const _0x154528=_0x526174(_0x1c2ccf);if(_0x5730fa[_0x46ce4c(0x20d)](_0x3966d8)===_0x154528)return;_0x874e7b(_0x3966d8,_0x1c2ccf,_0x154528),await _0x375b6d();});},async 'remove'(_0x5f4a78){return _0x40b5a0(async()=>{const _0x37a079=_0x4d49;if(!_0x5d9ba5)return;if(!_0x4754dd){if(!_0x5d64ed[_0x37a079(0x1a8)]())return;await _0x5472c6();}if(!_0x54da18)return;if(_0x400941(_0x5f4a78))await _0x375b6d();});},'search'(_0x541931,{limit:limit=0xa}={}){const _0x4835bb=_0x2c9538;if(!_0x4754dd&&_0x5d9ba5)_0x460926();if(!_0x54da18)return[];const _0x41fb28=_0x54da18['size']();if(_0x41fb28===0x0)return[];const _0xba1279=Math[_0x4835bb(0x223)](limit,_0x41fb28),_0x1e2887=_0x54da18['search'](_0xe6bd6b(_0x541931),_0xba1279,0x0),_0x57fde5=[],_0x19888d=_0x1e2887['keys'],_0x1f96be=_0x1e2887[_0x4835bb(0x176)];for(let _0x3b74d6=0x0;_0x3b74d6<_0x19888d[_0x4835bb(0x1d3)];_0x3b74d6++){const _0x374549=_0x19888d[_0x3b74d6];if(_0x374549===0xffffffffffffffffn)continue;const _0x5e1771=Number(_0x374549),_0x52d681=_0x5730fa[_0x4835bb(0x210)](_0x5e1771);if(!_0x52d681)continue;const _0xa1cd75=_0x1f96be[_0x3b74d6];let _0x10d715;if(_0x5857bf[_0x4835bb(0x1ff)]===_0x4835bb(0x188))_0x10d715=Math[_0x4835bb(0x1bf)](0x0,0x1-_0xa1cd75);else{if(_0x5857bf['metric']==='ip')_0x10d715=-_0xa1cd75;else _0x10d715=0x1/(0x1+_0xa1cd75);}_0x57fde5['push']({'key':_0x52d681,'score':_0x10d715});}return _0x57fde5;},async 'snapshot'(_0x172ebf){return _0x40b5a0(()=>_0x4754dd?_0x4bdbf2(_0x172ebf??undefined):![]);},async 'rebuild'(_0x42621f){return _0x40b5a0(async()=>{const _0x456f36=_0x4d49;if(_0x42621f!=null)_0x5f2179=_0x42621f;if(!_0x4754dd){if(!_0x5d64ed[_0x456f36(0x1a8)]())return;_0x4754dd=!![];}const _0x517348=_0x42621f?await _0x42621f():await _0x422ded();_0x36739f(_0x517348??[]),_0x5d9ba5=!![],await _0x4bdbf2();});},async 'stop'(){return _0x40b5a0(async()=>{const _0x5ae974=_0x4d49;_0x405d55();if(_0x4754dd){if(_0x13bde7>0x0||!_0x392d36[_0x5ae974(0x1e3)]())await _0x4bdbf2();_0x5d64ed['release']();}_0x4754dd=![],_0x5d9ba5=![];});},'count'(){const _0x8131a0=_0x2c9538;return _0x5730fa[_0x8131a0(0x1a0)]();},'info'(){const _0x4e4f92=_0x2c9538;return{'algorithm':'usearch','role':_0x4754dd?_0x4e4f92(0x1ac):_0x4e4f92(0x1d7),'metric':_0x5857bf['metric'],'connectivity':_0x5857bf['connectivity'],'expansionAdd':_0x5857bf['expansionAdd'],'expansionSearch':_0x5857bf[_0x4e4f92(0x1d8)],'snapshotEveryChanges':_0x5857bf[_0x4e4f92(0x200)],'snapshotMaxLagMs':_0x5857bf[_0x4e4f92(0x192)],'count':_0x5730fa[_0x4e4f92(0x1a0)](),'size':_0x54da18?.[_0x4e4f92(0x1a0)]?.()??0x0,'capacity':_0x54da18?.['capacity']?.()??0x0,'changesSince':_0x4754dd?_0x13bde7:null,'viewedSnapshot':_0x300699??null,'snapshotDir':_0x43e18a,'latestSnapshot':_0x392d36[_0x4e4f92(0x1e3)]()??null};}};},usearch;}var hasRequiredAlgorithmWorkerThread;function requireAlgorithmWorkerThread(){const _0xc52c80=_0x2bb8dc;if(hasRequiredAlgorithmWorkerThread)return algorithmWorkerThread$1;hasRequiredAlgorithmWorkerThread=0x1;const {parentPort:_0x26d19,workerData:_0x548e68}=require$$0$1,{algorithmName:_0x3b9751,algorithmConfig:_0x1c7595,dims:_0x239f27,dir:_0x131290}=_0x548e68;let _0x2263bd=0x1;const _0xef114=new Map();function _0x5622c8(){const _0x98f1ab=_0x2263bd++;return new Promise((_0x481e25,_0x5919f3)=>{const _0x473be6=_0x4d49;_0xef114[_0x473be6(0x197)](_0x98f1ab,{'resolve':_0x481e25,'reject':_0x5919f3}),_0x26d19['postMessage']({'op':_0x473be6(0x190),'fid':_0x98f1ab});});}const _0x2848c4={'dims':_0x239f27,'dir':_0x131290,'fetchAll':_0x5622c8,'onChange':()=>_0x190dc0()};let _0x451cb6;if(_0x3b9751===_0xc52c80(0x224))_0x451cb6=requireHnsw()(_0x1c7595,_0x2848c4);else{if(_0x3b9751===_0xc52c80(0x189))_0x451cb6=requireFlat()(_0x1c7595,_0x2848c4);else{if(_0x3b9751==='usearch')_0x451cb6=requireUsearch()(_0x1c7595,_0x2848c4);else throw new Error(_0xc52c80(0x19d)+_0x3b9751+'\x22');}}function _0x190dc0(){const _0xffddef=_0xc52c80;try{_0x26d19[_0xffddef(0x228)]({'op':'sync','count':_0x451cb6['count'](),'info':_0x451cb6[_0xffddef(0x1b8)](),'memory':process[_0xffddef(0x16a)]()});}catch{}}function _0x2a8a7c(_0x2a15e4){const _0x4d53f8=_0xc52c80;return(_0x2a15e4||[])[_0x4d53f8(0x1d1)](_0x417d23=>({'key':_0x417d23[_0x4d53f8(0x1c8)],'vector':_0x417d23[_0x4d53f8(0x206)]instanceof Float32Array?_0x417d23[_0x4d53f8(0x206)]:new Float32Array(_0x417d23[_0x4d53f8(0x206)])}));}return _0x26d19['on'](_0xc52c80(0x1df),async _0x4bb72a=>{const _0x19aaf3=_0xc52c80;if(_0x4bb72a['op']===_0x19aaf3(0x17b)){const _0x1fd1d5=_0xef114[_0x19aaf3(0x167)](_0x4bb72a[_0x19aaf3(0x162)]);if(!_0x1fd1d5)return;_0xef114[_0x19aaf3(0x19c)](_0x4bb72a[_0x19aaf3(0x162)]);if(_0x4bb72a['error'])_0x1fd1d5['reject'](new Error(_0x4bb72a[_0x19aaf3(0x1ad)]));else _0x1fd1d5[_0x19aaf3(0x161)](_0x2a8a7c(_0x4bb72a[_0x19aaf3(0x20e)]));return;}const {id:_0xb1e6a2,op:_0x592700,args:_0x121046}=_0x4bb72a;try{let _0x18e6d6;switch(_0x592700){case _0x19aaf3(0x1da):{_0x18e6d6=await _0x451cb6[_0x19aaf3(0x1da)](_0x121046[_0x19aaf3(0x178)]?_0x5622c8:null),_0x190dc0();break;}case _0x19aaf3(0x174):{const _0x36cf04=_0x121046[_0x19aaf3(0x206)]instanceof Float32Array?_0x121046['vector']:new Float32Array(_0x121046[_0x19aaf3(0x206)]);await _0x451cb6[_0x19aaf3(0x174)](_0x121046['key'],_0x36cf04,_0x121046[_0x19aaf3(0x1fe)]??undefined),_0x190dc0(),_0x18e6d6=null;break;}case _0x19aaf3(0x201):{await _0x451cb6[_0x19aaf3(0x201)](_0x121046[_0x19aaf3(0x1c8)]),_0x190dc0(),_0x18e6d6=null;break;}case _0x19aaf3(0x171):{const _0x54dcab=_0x121046['queryVec']instanceof Float32Array?_0x121046[_0x19aaf3(0x1e7)]:new Float32Array(_0x121046[_0x19aaf3(0x1e7)]);_0x18e6d6=_0x451cb6[_0x19aaf3(0x171)](_0x54dcab,_0x121046[_0x19aaf3(0x172)]||{});break;}case'snapshot':{_0x18e6d6=await _0x451cb6['snapshot'](_0x121046[_0x19aaf3(0x1fe)]),_0x190dc0();break;}case _0x19aaf3(0x1d0):{const _0x321516=_0x2a8a7c(_0x121046[_0x19aaf3(0x20e)]);await _0x451cb6[_0x19aaf3(0x1d0)](async()=>_0x321516),_0x190dc0(),_0x18e6d6=null;break;}case'stop':{await _0x451cb6[_0x19aaf3(0x1ba)](),_0x190dc0(),_0x18e6d6=null;break;}case _0x19aaf3(0x1a4):{_0x18e6d6=_0x451cb6['count']();break;}case'info':{_0x18e6d6=_0x451cb6['info']();break;}default:throw new Error(_0x19aaf3(0x21c)+_0x592700+'\x22');}_0x26d19[_0x19aaf3(0x228)]({'id':_0xb1e6a2,'result':_0x18e6d6});}catch(_0x3825ad){_0x26d19[_0x19aaf3(0x228)]({'id':_0xb1e6a2,'error':{'message':_0x3825ad?.['message']||String(_0x3825ad),'code':_0x3825ad?.[_0x19aaf3(0x1f6)]}});}}),_0x26d19['postMessage']({'op':_0xc52c80(0x17a)}),algorithmWorkerThread$1;}var algorithmWorkerThreadExports=requireAlgorithmWorkerThread(),algorithmWorkerThread=getDefaultExportFromCjs(algorithmWorkerThreadExports);module[_0x2bb8dc(0x181)]=algorithmWorkerThread;function _0x1e68(){const _0x5e2fad=['vectors','node','keyForLabel','labelForExisting','.tmp-','unlinkSync','publishSnapshot','finally','initIndex','setFingerprint','loadFrom','snapshotsDir','version','prototype','Unknown\x20op:\x20\x22','worker_threads','parse','writeFileSync','listSnapshotIds','MetricKind','loadSnapshot','min','hnsw','token','versions','ceil','postMessage','unreadable','dims','now','host','manifestVersion','Install\x20compatible\x20bindings\x20or\x20use\x20algorithm\x20\x22flat\x22\x20instead.\x20','HNSW_BINDINGS_UNAVAILABLE','isInteger','state','15MJvQxU','tmpMaxAgeMs','getCurrentCount','score','utf8','then','closeSync','filter',').\x20','resolve','fid','heartbeatIntervalMs','round','startsWith','entries','get','Breaking\x20stale\x20snapshot\x20lock\x20(age:\x20','index.hnsw','memoryUsage','F32','280KIWqNy','readIndexSync','stale','6230FhJVba','labelToKey','search','opts','69545MGSlIA','add','[SnapshotStore]','distances','snapshots','hasRows','path','ready','fetchAllResult','arch','mtimeMs','44OYliiw','slice','cause','exports','removed','resizeIndex','Cos','readdirSync','join','call','cosine','flat','lockPath','s,\x20pid:\x20','_snapshotDir','usearch','readFileSync','warn','fetchAll',',\x20host:\x20','snapshotMaxLagMs','Install\x20compatible\x20bindings\x20or\x20use\x20algorithm\x20\x22flat\x22/\x22hnsw\x22\x20instead.\x20','snapshot\x20id\x20required','_snapshotPaths','usearch\x20algorithm\x20unavailable:\x20the\x20native\x20\x22usearch\x22\x20bindings\x20could\x20not\x20be\x20loaded\x20','set','renameSync','labels','index','getMaxElements','delete','Unknown\x20algorithm:\x20\x22','isDirectory','push','size','trunc','setEf','imul','count','repeat','HierarchicalNSW','EEXIST','acquire','hnswlib-node','USEARCH_BINDINGS_UNAVAILABLE','keyToFp','writer','error','usearch\x20algorithm\x20requires\x20dir\x20for\x20snapshot\x20storage','name','406314jIJfuO','cleanupTmpDirs','readCurrentClock','mkdirSync','randomBytes','writeIndexSync','rmSync','hnsw\x20algorithm\x20requires\x20dir\x20for\x20snapshot\x20storage','info','reset','stop','efSearch','unref','added','.tmp','max','efConstruction','connectivity','2102068dPDXGX','clear','save','ENOENT','latestSnapshotId','Index','key','sort','__esModule','currentPath','snapshotTo','openSync','growFactor','SNAPSHOT.LOCK','rebuild','map','writerLockMaxAgeMs','length','byteOffset','Original\x20error:\x20','changed','reader','expansionSearch','52ZqGVnK','load','L2sq','lock_busy','published','tombstone','message','default','viewRefreshMs','WRITER.LOCK','readCurrentId','platform','keyToLabel','stringify','queryVec','algorithm','SnapshotStore\x20requires\x20dir','hostname','1463910jzOeIG','catch','hex','_tombstoneCount','for\x20Node\x20','dir','5637681pnAFZQ','toString','prune','pid','nextLabel','code','sqrt','expansionAdd','keys','labelForEphemeral','\x20on\x20','log','_tmp-','clock','metric','snapshotEveryChanges','remove','hasFingerprints','hnsw\x20algorithm\x20requires\x20dims\x20>\x200','26986xyfvPX','searchKnn','vector','isArray','keepSnapshots','maxElements','existsSync','from','labels.json','fingerprintOf'];_0x1e68=function(){return _0x5e2fad;};return _0x1e68();}