@kedem/okdb 2.3.5 → 2.4.0

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 (59) hide show
  1. package/CHANGELOG.md +349 -0
  2. package/algorithm-worker-thread.js +1 -1
  3. package/bin/okdb.js +1 -1
  4. package/docs/auth-and-sync.md +28 -4
  5. package/docs/auth-permissions.md +19 -6
  6. package/docs/change-log.md +79 -59
  7. package/docs/data-model.md +20 -18
  8. package/docs/deployment.md +25 -0
  9. package/docs/diagnostics.md +59 -17
  10. package/docs/embeddings.md +57 -6
  11. package/docs/fts.md +50 -5
  12. package/docs/functions.md +21 -8
  13. package/docs/http-api.md +139 -98
  14. package/docs/http-cluster.md +30 -8
  15. package/docs/indexes.md +5 -4
  16. package/docs/logging.md +18 -0
  17. package/docs/migration.md +94 -2
  18. package/docs/pipelines.md +6 -1
  19. package/docs/plugins.md +12 -18
  20. package/docs/process-registry.md +50 -39
  21. package/docs/processors.md +40 -22
  22. package/docs/querying.md +50 -36
  23. package/docs/queue.md +110 -14
  24. package/docs/subscriptions.md +35 -24
  25. package/docs/sync.md +96 -37
  26. package/docs/time-machine.md +23 -17
  27. package/docs/transactions.md +11 -19
  28. package/docs/ttl.md +118 -67
  29. package/docs/upgrade-2.0.md +2 -2
  30. package/docs/views.md +71 -52
  31. package/okdb-functions-sandbox-worker.js +1 -1
  32. package/okdb-http-worker-child.js +1 -1
  33. package/okdb-views-bootstrap-worker.js +1 -1
  34. package/okdb.js +1 -1
  35. package/package.json +1 -1
  36. package/public/sections/db/parts/type-viewer.ok.js +1 -1
  37. package/public/sections/embeddings/parts/engines-overview.ok.js +1 -1
  38. package/public/sections/queue/parts/queue-jobs.ok.js +1 -1
  39. package/public/sections/system/modals/data-ops-modal.ok.js +1 -1
  40. package/types/environment.d.ts +320 -52
  41. package/types/features/admin.d.ts +8 -2
  42. package/types/features/api.d.ts +10 -16
  43. package/types/features/auth.d.ts +135 -16
  44. package/types/features/embeddings.d.ts +639 -31
  45. package/types/features/engines.d.ts +368 -14
  46. package/types/features/files.d.ts +0 -3
  47. package/types/features/fts.d.ts +98 -26
  48. package/types/features/functions.d.ts +175 -15
  49. package/types/features/mcp.d.ts +23 -10
  50. package/types/features/pipelines.d.ts +268 -9
  51. package/types/features/queue.d.ts +230 -34
  52. package/types/features/sync.d.ts +177 -14
  53. package/types/features/time-machine.d.ts +117 -16
  54. package/types/features/views.d.ts +230 -39
  55. package/types/index.d.ts +357 -254
  56. package/types/okdb.d.ts +377 -0
  57. package/types/options.d.ts +309 -48
  58. package/public/test-cron-input.html +0 -60
  59. package/public/test-json-input.html +0 -280
package/CHANGELOG.md CHANGED
@@ -4,6 +4,355 @@ All notable changes to `@kedem/okdb` are documented here. Format loosely follows
4
4
  [Keep a Changelog](https://keepachangelog.com/en/1.0.0/); versions follow [SemVer](https://semver.org/).
5
5
  Dates are release dates.
6
6
 
7
+ ## [2.4.0] - 2026-09-25
8
+
9
+ ### Security
10
+
11
+ - **Sync link scope was not enforced by the node serving the data.** `/api/sync/delta` served
12
+ whatever envs the caller named, ignoring the link's `envs` list and direction — a peer linked
13
+ for env `a` (or linked receive-only) could pull env `b` just by asking, and a `poke` made the
14
+ poked node pull every env from the poker regardless of the link. The delta server now serves a
15
+ signed peer only `~system` plus the data envs the link lets it send to that peer (others are
16
+ omitted and listed in the response's `denied`); the pulling node applies only envs it asked for
17
+ and the link lets it receive, whatever the remote sends (a pre-fix peer can't push past the
18
+ link); a pull without an explicit env list (join, poke, `reconcilePeer`) asks for the link's
19
+ envs only; and a signed `poke` can only trigger a pull from the signer, never a named third
20
+ node. With no link anywhere the cluster stays in legacy full-mesh mode. Note that `~system`
21
+ (the control plane — `~sync_nodes`, `~sync_links`, `~tokens` hashes, `~licenses`, …) still
22
+ replicates with every registered peer: a link scopes data, not trust (see
23
+ [Auth and Sync → What a peer can do](docs/auth-and-sync.md#what-a-peer-can-do)).
24
+ - **`system_backup` (HTTP + MCP) could write a full copy of the store to any server path.** It now
25
+ writes only under the backup root — the new `backup.root` option, default `<store>-backups` next
26
+ to the store — rejecting `..`, other absolute paths and symlinks that resolve outside it
27
+ (`400 BACKUP_PATH_OUTSIDE_ROOT`) and existing non-empty directories (`409`). `destDir` is relative
28
+ to the root and optional; the route is marked destructive, so MCP clients must confirm it.
29
+ - **Per-env authorization was skipped on the files, queue, FTS and functions routes.** These
30
+ routes declare `access.scope: 'env'` (a string shorthand), but the permission check only read
31
+ `access.scope.env`, so no env was resolved: the protected `~` env gate did not apply (a token
32
+ with global `queue:read` could read `/api/env/~system/queue/...` without `protected:read`), and
33
+ per-env grants were ignored (a token granted `{ orders: ['files:read'] }` got 403 on
34
+ `/api/env/orders/files`). The shorthand now resolves the `:env` path param like
35
+ `scope: { env: 'params.env' }`.
36
+ - **Query filters could execute arbitrary code via `$where`.** Filters are compiled by `sift`,
37
+ whose `$where` operator compiles a string with `new Function` and runs it in-process — so any
38
+ caller able to pass a filter (`data:read` over HTTP `…/type/:type/query` and `…/count`, the MCP
39
+ query tool, FTS/vector post-filters, view definitions, subscription filters) could run code on
40
+ the server. Every call site now compiles through one helper (`src/core/okdb-query-filter.js`)
41
+ that allows only declarative operators; `$where` (string or function, at any nesting depth) is
42
+ rejected with `QUERY_OPERATOR_FORBIDDEN` (HTTP 400) and never evaluated. A view stored with
43
+ `$where` before this fix is not activated on open (logged; remove and re-create it), and a
44
+ stored subscription filter using it never matches.
45
+
46
+ ### Changed
47
+
48
+ - **FTS results are ranked by relevance (Okapi BM25).** Every token match used to score a flat
49
+ weight and AND-mode results came back in docId order, cut at `limit` — so "top 50" meant the
50
+ oldest 50 matches. Search now scores every matching doc with BM25 (k1 = 1.2, b = 0.75: term
51
+ frequency, inverse document frequency, doc-length normalization) and returns the best `limit`
52
+ across **all** matches (bounded top-k; ties break oldest-first). `score` is the BM25 value on
53
+ `ftsQuery`/`searchDocs` rows and `ftsScore` on `query({ fts })` rows; `maxScore` is now the
54
+ query's BM25 upper bound (was `numTerms × 2`). Prefix mode scores an exact word above a
55
+ prefix-only completion. Storage: tf and doc length ride along as marker terms in the existing
56
+ posting lists (no new sub-DBs), index format 4 → 5. **Existing indexes upgrade in place on
57
+ open** (a re-scan that only adds the markers — no clear), so search keeps answering throughout,
58
+ ranked by idf alone until the upgrade finishes; `fts.ready(type)` resolves when it has.
59
+ - **Hybrid `query({ fts, vector })`**: row `score` is now the actual fused RRF value (was a
60
+ rank-derived placeholder), and `fts.weight` / `vector.weight` (default 1) scale each signal's
61
+ contribution to the fusion.
62
+ - **Bus POKE is throttled per `(env, type)`**: the first change sends immediately and further
63
+ changes within `OKDB_BUS_POKE_WINDOW_MS` (default 10 ms; `0` = unthrottled) collapse into one
64
+ trailing datagram, so a sustained writer no longer sends one datagram per changed document. A
65
+ process that is the only holder of an env delivers pokes in-process with no datagram.
66
+ - **Views over small sources bootstrap in place.** A view whose source has fewer than
67
+ `OKDB_VIEWS_BOOTSTRAP_WORKER_MIN_DOCS` documents (default 5000) is bootstrapped on the calling
68
+ thread instead of spawning a bootstrap worker.
69
+ - **Timing knobs are overridable by env var** (defaults unchanged, meant for tests):
70
+ `OKDB_COMPACT_CLOSE_GRACE_MS`, `OKDB_COMPACT_DRAIN_TIMEOUT_MS`,
71
+ `OKDB_CLUSTER_RESPAWN_BACKOFF_MS`, `OKDB_FTS_DROP_COMMITTED_TIMEOUT_MS`,
72
+ `OKDB_READER_CHECK_MIN_INTERVAL_MS`, `OKDB_LOG_FLUSH_MS`, `OKDB_ENV_RELEASE_GRACE_MS`.
73
+ `OKDB_QUEUE_RECONCILE_MS` is now taken as given (it had a 2 s floor).
74
+
75
+ ### Fixed
76
+
77
+ - **Embeddings on synced peers**: the indexer's `start()` now ensures its `doc_status` type, so
78
+ it exists on peers that received the pipeline by sync.
79
+ - **FTS filters starved at the default limit.** `ftsQuery(type, name, text, filter)` applied the
80
+ filter AFTER taking the top `limit` (default 50) hits, so a selective filter returned nothing
81
+ unless `limit` was raised; `query({ fts })` over-fetched a fixed 200 candidates with the same
82
+ failure beyond that. The filter (and a `query` index constraint) is now applied while ranking:
83
+ candidates stream best-first until `limit` rows pass or the matches run out. An explicit
84
+ `fts.limit` in `query()` still caps how many FTS candidates are considered.
85
+
86
+ - **Cron jobs silently stopped recurring.** A permanently failed run (`markJobFail`) and a claim
87
+ timeout with no tries left (reconcile) left a cron job `failed` forever, and a done run wrote
88
+ `done` and rescheduled in a second commit (a crash between the two ended the series) while
89
+ emitting `queue:done` for a job that went straight back to pending. Every terminal path of a cron
90
+ run now re-queues the same row as `pending` at the next cron time (`tries: 0`, the finished run
91
+ recorded in `job.last_run`) in the one write that ends the run, and emits the new
92
+ `queue:rescheduled` event instead of `queue:done`/`queue:failed`. A run's own retries still go
93
+ first; `cancelJob` is the one path that stops a series.
94
+ - **A cancelled or timed-out job kept swallowing its idempotency key.** `cancelJob` and reconcile's
95
+ timeout → `failed` didn't release `idempotency_key`, so a later enqueue with that key returned
96
+ the dead job's id and queued nothing. Keys now dedup against live (pending/running) jobs only and
97
+ every terminal state releases them; a terminal row still holding one (written before this fix)
98
+ is released in the same commit as the new job.
99
+ - **Orphan payloads from enqueue.** The payload was committed before the job, so a duplicate
100
+ idempotency key or a lost race left payloads with no job (e.g. 6 jobs, 8 payloads). Payload and
101
+ job are now one transaction, and `removeJob` (incl. `done_ttl`/`failed_ttl: 0` retention) deletes
102
+ both in one commit.
103
+ - **`queue.list` paging repeated rows and failed with filters.** The next page started at (and
104
+ repeated) the previous page's last row, rows sharing one `when` were mis-paged, and
105
+ `list({ type or status, cursor })` threw "prefix cannot be combined with startIndex/endIndex".
106
+ Cursors are now opaque exclusive strings that page every type/status/sort/direction combination
107
+ with no repeats or gaps (`list({ type, sort: 'priority' })` also works now — it needed a missing
108
+ index). A cursor reused with a different filter, or an old index-key array cursor, throws
109
+ `BAD_PARAM`. **Breaking for callers that built or inspected cursors** — treat them as opaque.
110
+ - **Cancelling a job didn't stop its running handler.** `ctx` had no abort signal and the
111
+ auto-heartbeat's cancel detection was dead (`markJobHeartbeat` resolved quietly on a lost claim).
112
+ Handlers now get `ctx.signal` (an `AbortSignal`), aborted on cancel (`JOB_CANCELLED` — at once in
113
+ the cancelling process, at the next heartbeat elsewhere), on a lost claim (`CLAIM_LOST`), or when
114
+ `stop(timeout)` runs out (`WORKER_STOPPING`). Cancellation is cooperative — handlers are never
115
+ killed. `markJobHeartbeat` now rejects on a lost claim (`NOT_FOUND` / `INVALID_STATE` /
116
+ `CLAIM_MISMATCH`). Queue-worker engines pass the signal to the function sandbox
117
+ (`functions.run(name, payload, { signal })`), which cancels the function and contains it if it
118
+ doesn't unwind.
119
+ - **`stop(timeout)` could run a job twice.** On timeout it released the claims of handlers still
120
+ running, so another consumer started the same job concurrently. It now aborts their `ctx.signal`
121
+ and keeps the claim (still heartbeated) until each handler settles: then the job is completed
122
+ (resolved) or released to pending without burning a try (threw). A process that exits first
123
+ leaves the claim to reconcile (at-least-once).
124
+ - **Changing a pipeline's embedder model mixed vectors from two models in one index.** A patched
125
+ embedder `model` with the same dims was accepted with only a note to rebuild, vectors did not
126
+ record their model, and chunks re-embed only when their text changes — so new and edited docs
127
+ landed in the new model's space next to old vectors, silently degrading search. The indexer now
128
+ records the embedder fingerprint (`{ type, model, dims }`) next to the pipeline's vectors; when
129
+ the configured embedder no longer matches (patched model, `replaceMember`, an indexer re-pointed
130
+ at another embedder, or a change arriving by sync) the pipeline is **stale**: new embeds are held
131
+ (`stats().waiting.reason: 'EMBEDDER_CHANGED'`, never mixed), `stats().vector_space`,
132
+ `embeddings.vectorSpace(name)` and `pipelines.get()` (`stale`, `vector_space`) report it, the
133
+ admin pipeline card shows **needs re-embed**, and search keeps serving the old vectors with
134
+ `meta.stale` + `meta.warning` on the query/nearest endpoints. `rebuild()` ("Re-embed all")
135
+ re-embeds with the new model and clears it; a patch that keeps the fingerprint (new `api_key`,
136
+ `url`, a no-op) changes nothing. Nothing is re-embedded automatically. Also: the query-embedder
137
+ instance a passive node builds from the durable record is now rebuilt when that record's config
138
+ changes (it kept the old model), and the indexer's hash→vector cache is cleared on a model change.
139
+
140
+ - **A view with a custom `bucket.project` made the whole store fail to re-open.** The projection
141
+ was a function, which persistence silently dropped, so on the next `open()` the stored bucket had
142
+ neither `preset` nor `project` and compiling it threw `Unknown bucket preset: undefined` — and
143
+ `views.rebuild()` of any other view threw too (its bootstrap worker re-opens the store). A custom
144
+ projection is now referenced by **name**: register it process-wide with
145
+ `OKDB.registerBucketProjection(name, fn)` before `open()` and set `bucket.project: '<name>'`,
146
+ which persists and recompiles on reopen, peers and rebuild (and can be created over HTTP).
147
+ `create()` refuses a function with `BUCKET_PROJECT_NOT_PERSISTABLE` and an unregistered name with
148
+ `BUCKET_PROJECT_UNKNOWN`. **Breaking for callers passing a function** — register it and pass its
149
+ name instead.
150
+ - **One bad stored view definition no longer fails `open()`.** Generalizing the `$where` guard: any
151
+ stored view whose definition can't be compiled at boot (unregistered custom reducer or projection,
152
+ a pre-fix function-projection bucket, a forbidden operator) is held back with a logged error —
153
+ `views.get()` returns `null`, `views.getMeta()` reports `state: 'error'` with the error code,
154
+ every other view boots and rebuilds normally, and `views.remove()` still works. `views.rebuild()`
155
+ of a held-back view retries the compile and fully re-derives it on success. Existing stores that
156
+ hold a pre-fix projection view open again; that view is held back (`BUCKET_CONFIG_INVALID`) until
157
+ removed and re-created.
158
+ - **Custom reducers ignored documents that already existed when the view was created.** The
159
+ bootstrap-worker eligibility check skipped every `$`-prefixed key while looking for custom
160
+ reducer names — which always start with `$` — so the scan ran on a worker thread that had no such
161
+ reducer and silently dropped it: after `create()` the value was `null` and only later writes
162
+ counted. Custom-reducer (and custom-projection) views now bootstrap on the main thread, so
163
+ bootstrap, live writes and `views.rebuild()` agree, including custom sub-reducers inside
164
+ `$group`/`$ref`.
165
+ - **Custom reducers across a reopen.** A reducer name nothing resolves used to be dropped silently
166
+ (a typo, or a stored view opened before `registerReducer` ran — the view then never updated that
167
+ reducer again). `create()` now refuses it with `VIEW_UNKNOWN_REDUCER`; the new process-wide
168
+ `OKDB.registerViewReducer(name, { apply })` (before `open()`) keeps such views live from boot;
169
+ a stored view whose reducer is only registered later via `env.views.registerReducer` is held back
170
+ at `open()` and fully re-derived when it is registered, so no write is lost.
171
+ - **`registerReducer('$group')` (or `'$ref'`) was accepted and then silently shadowed** by the
172
+ built-in. Every built-in reducer name and `$ref` are now rejected with `VIEW_REDUCER_CONFLICT`.
173
+ - **TTL items could outlive their expiry indefinitely in an idle env.** The sweep timer was armed
174
+ only by `setTTL()`/`clearTTL()` and at open — never re-armed after a timer-driven sweep, and
175
+ never armed by a TTL set through the write option (`put(..., { ttl })`, HTTP PUT `ttl`) or a
176
+ type's `defaultTTL` — so, with no further writes, `put(..., { ttl: 200 })` was still readable
177
+ long after it expired. Every path that sets an expiry now arms the single per-env timer when the
178
+ expiry is earlier than its target (no re-arm otherwise), every sweep re-arms it for the next
179
+ expiry (immediately when a `batchSize`-capped sweep leaves due items), and a sweep error retries
180
+ after 1 s. When only unremovable items are due (FK `restrict`), sweeps back off (1 s → 10 s)
181
+ instead of spinning — also on the write path, which previously re-swept on every write. The
182
+ timer stays `unref()`'d and is cleared on close.
183
+ - **`db.range(it)` / `env.range(it)` never ended**: they looped until lmdb's `iterate()` returned
184
+ `null`, but it returns `{ value, done }` results, so the generator yielded `{ done: true }`
185
+ forever. It now yields each item and stops at `done`; plain iterables are accepted too.
186
+ - **`POST /api[/env/:env]/transaction` rejected a bare-array body** with 400 `VALIDATION_ERROR`
187
+ ("operations is required"), although the handler and the route's own example use one. The route
188
+ now uses `http.bodyMode: 'array'` (implemented in request validation: a bare-array body binds to
189
+ the route's single array input field), so both `{ "operations": [...] }` and `[...]` validate.
190
+ - **Queue: `markJobComplete` / `markJobFail` / `markJobProgress` with a `null` claim id acted on
191
+ another worker's claimed job** — the ownership check was skipped. They (and the
192
+ `completeJob`/`failJob` aliases) now throw `CLAIM_REQUIRED` without a claim id, and
193
+ `CLAIM_MISMATCH` for a claim that is not the job's current one.
194
+ - **Queue: `updateBucket` skipped its version check** (it passed a bare version where `update`
195
+ expects `{ ifVersion }`), so a concurrent token claim could be overwritten. It now retries
196
+ against a fresh read on a version conflict.
197
+ - **Queue: `list({ bucket, tag })` ignored both filters.** `tag` matches any of a job's `tags`,
198
+ `bucket` any of its `buckets[].id` (or the legacy `bucket`); `limit` counts matching jobs.
199
+ - **Auth: `verifyPassword` could crash the process** — on a scrypt error it rejected and then fell
200
+ through to `timingSafeEqual` inside the callback (an uncaught exception), and a stored hash of
201
+ the wrong length threw the same way. It now rejects cleanly on a scrypt error and returns
202
+ `false` for a malformed stored hash. `hashPassword` had the same fall-through.
203
+ - **Admin log History was dead: `GET /api/system/logs` returned 500** (`getRange: unrecognized
204
+ option "0"` — a stale 3-argument call) and loaded every stored log row into memory before
205
+ filtering. It now walks the ts index newest-first (a `[level|node|feature, ts]` index for a
206
+ single-valued filter), examines at most 5 000 rows per call and pages with an opaque
207
+ `next_cursor` (`"<ts>:<key>"`; same-ts rows are neither skipped nor repeated). A sparse filter
208
+ can return a short page with a non-null cursor — keep paging until it is `null`.
209
+ - **Export blocked the event loop and ignored backpressure.** `exportToStream` wrote every row in
210
+ one synchronous loop (200k docs: one ≈0.6 s stall, ≈52 MB buffered in the stream). It now reads
211
+ and writes 1 000-row chunks, awaits `drain` when `write()` returns `false` and yields between
212
+ chunks (200k docs: longest stall ≈10–47 ms, ≈0.3 MB buffered). Consistency is documented as it
213
+ is: per chunk (each key at most once), not point-in-time — use `backup()` for a snapshot.
214
+ - **`migrate.backup()` dropped data a restored store needed.** Time-machine history
215
+ (`<env>/time-machine/`) is now copied (LMDB native copy, just before its env); an env whose
216
+ directory name differs from its name (`ws:one` → `ws-one`) was copied where the restored
217
+ registry never looked and came back **empty**; `~fts` is still not copied (derived), but a store
218
+ opened without its `~fts` files now rebuilds every READY index from the documents instead of
219
+ serving silently empty search. Blobs are copied after all metadata, without the `tmp/` staging
220
+ dir; `~processes` is skipped; `envNames` always includes `~system`; the destination must be
221
+ new/empty and outside the store (`BACKUP_DEST_NOT_EMPTY`, `BACKUP_DEST_INSIDE_STORE`); an
222
+ `okdb-backup.json` manifest marks a complete backup. New `okdb restore <dir> --path <target>`.
223
+ - **Removed / unknown constructor options were silently accepted.** `workers` now throws
224
+ `WORKERS_REMOVED` and a boolean `sync` throws `SYNC_OPTION_REMOVED` (the `sync` settings object
225
+ is unchanged); any other unknown top-level key logs one warning naming it, with a did-you-mean
226
+ for near-misses (`procesors` → `processors`). The `db.workers` error and the inline-processor
227
+ messages now cite documents that exist.
228
+ - **Foreign-key `onDelete` silently did nothing when a key or type contained `@`.** The reverse-ref
229
+ index joined `target@targetKey@source@sourceKey@field` into one string and split it back on
230
+ `@`, so an email/URL key mis-parsed: `cascade` left the child behind, `restrict` let the parent
231
+ be deleted (leaving the child dangling), and `set_null` was never applied. Index rows are now
232
+ structured array keys (every component round-trips exactly), and readers never parse a key
233
+ string. The 2.4.0 storage migration `fk-ref-index-structured-keys` drops each env's index and
234
+ re-derives it from the FK schemas + source docs on first open; a leftover old-format row is
235
+ skipped, never misread. Same fix for numeric source keys (previously stringified, so their
236
+ cascade/set_null was skipped too), for the cascade cycle guard (`'a@b'`+`'c'` collided with
237
+ `'a'`+`'b@c'` and skipped a delete), and for dropping type `A` sweeping index rows of type
238
+ `A@x`. Clearing ref violations for key `a` no longer also clears those of key `a@b`. A store
239
+ opened by 2.4.0 is refused by older builds (`STORE_VERSION_NEWER`).
240
+ - **A queue job could stay `running` after its handler finished.** Completing or failing a job was
241
+ a single version-checked write, so a concurrent write to the same row by the claimant itself — an
242
+ un-awaited `ctx.markProgress()`, the auto-heartbeat — made it fail with "Version mismatch". The
243
+ worker only logged a warning; the job then sat `running` until its claim expired and was failed
244
+ or run again. Complete, fail and release now re-read and retry while the claim is still ours,
245
+ and give up only when the claim was actually lost.
246
+ - **`ctx.heartbeat()` shrank the claim to ~1 s** when the handler had no explicit `ttl`, so
247
+ another process's reconcile could take over a job that was still running. Manual and automatic
248
+ heartbeats now extend by the ttl the job was claimed with.
249
+ - **`max_tries: null` (documented as unlimited) was stored as 1.** An explicit `null` on enqueue,
250
+ on a job-type default or as the queue's `default_max_tries` now means unlimited retries.
251
+ - **Queue handler results were dropped.** A local handler's return value, or the `result` passed
252
+ to `markJobComplete`, is now stored on the done job as `job.result` (when JSON-serializable and
253
+ ≤ 16 KB; otherwise `null`). A manual `retryJob` clears it.
254
+ - **A synced node could skip a storage migration on its own files.** The `~migrations` log in
255
+ `~system` replicated to peers, and startup trusted any row by id — so a node that pulled a row
256
+ from an already-upgraded peer never ran that migration on its own layout. `~migrations` is now
257
+ node-local: left out of sync deltas and refused when a not-yet-fixed peer sends it. For rows
258
+ already replicated into existing stores, a row counts when this store wrote it, or when this
259
+ store's own (never replicated) layout stamp already covers the migration's version — so a
260
+ lagging node migrates, and a node whose own row was overwritten by a peer's does not re-run it.
261
+ - **Vector and hybrid `query()` returned nothing from the vector side for chunked pipelines.**
262
+ `env.query(type, filter, { vector })` looked documents up under the raw chunk keys
263
+ (`docKey\tchunkHash`), so vector-only queries returned `[]` and hybrid `{ fts, vector }` quietly
264
+ degraded to FTS-only. Vector hits are now mapped to their source documents — one row per doc,
265
+ best chunk wins, the matched chunk exposed as `chunkHash` + `chunk: { start, end }` — with chunk
266
+ candidates over-fetched so `limit` counts documents. New
267
+ `okdb.embeddings.searchDocs(name, query, { limit })` / `pipeline.api.searchDocs()` is the
268
+ document-level search; `search()` stays chunk-level.
269
+ - **`POST …/pipelines/:pipeline/query` returned chunk hits, so `limit: 10` could yield 5 documents.**
270
+ It now returns one row per document; pass `chunks: true` for the raw chunk-level hits.
271
+ `…/nearest` is unchanged.
272
+ - **`POST /api/env/:env/type/:type/query` with `options.vector` failed with 500** (the async hybrid
273
+ result was iterated as an array). Rows now also carry `score`/`vectorScore`/`ftsScore` and chunk
274
+ info when present.
275
+ - **Several processes starting on a brand-new store could crash natively.** lmdb-js (3.5.x) has a
276
+ bug affecting concurrent opens: an LMDB open that overlaps another process's commit to the same
277
+ env can move the shared transaction id backwards, and later writes then fail with `SIGSEGV` in
278
+ `mdb_cursor_put`, `MDB_PROBLEM`, an LMDB assertion, or a silently lost commit. On a fresh path
279
+ every booting process opens the same system envs while the others make their first writes to
280
+ them, so ≈1% of 6-process fresh boots crashed. `open()` now takes a cross-process **boot lock**
281
+ while the store is being initialised (an env it opens at boot has no data file yet), so those
282
+ boots run one at a time; `close()` joins it only while a peer is initialising. A dead or stale
283
+ holder is taken over, and a waiter that exceeds `OKDB_BOOT_LOCK_TIMEOUT_MS` (default 60 s) logs
284
+ a warning and proceeds unserialised. An established store is not serialised, so opening a
285
+ process alongside a peer that is actively writing — and runtime `createEnvironment()` /
286
+ `removeEnvironment()` — remain exposed until the issue is fixed upstream; staggered starts keep
287
+ that window small (see [Roles & Deployment](docs/deployment.md)).
288
+ - **Concurrent opens of a fresh path could also die with `SIGBUS` or hang.** A process attaching
289
+ to a shared-memory segment in the instant between a peer creating it and sizing it mapped a
290
+ 0-byte object and crashed on first access; the segment is now sized by whoever attaches first.
291
+ And `open()` could hang forever in "features + processors" when a peer won the race to build an
292
+ index: `indexReady()` waited on a promise only the building process resolves — it now also
293
+ follows the stored index status.
294
+ - **Live subscriptions could come up disabled on one of several concurrently booting processes.**
295
+ The process that lost the race to create the `~sub` types logged "already registered" and ran
296
+ with subscriptions off; setup is now race-safe. Subscription routing is also lazy: a process
297
+ does per-change subscription work only while it holds an open subscription connection, and
298
+ sessions are indexed by `[dataEnv, type]` (20k writes with 200 sessions: 8.2 s → 0.4 s CPU).
299
+ - **`fts.ready()` waited forever when another process finished the build.** A pending `ready()`
300
+ was only woken by a build end in its own instance; it now also follows the stored index status.
301
+ - **Compaction could crash or stall processes running live FTS.** Lock handles kept across a
302
+ compaction's reopen wrote to the closed pre-swap env ("The environment is already closed.",
303
+ uncatchable); a process opening during a peer's compaction crash-looped on `FTS_DRAINING`; a
304
+ processor drain parked on the compaction held up the env close for its whole grace period; and
305
+ the FTS posting + docs compound write parked on the drain while already holding its writer slot
306
+ — a self-deadlock that made every non-forced `compact()` over a live FTS drain defer. All four
307
+ are fixed (drain-quantum writes are released on close and re-run after the reopen). A lone
308
+ process now skips the close grace period, so its `env.compact()` takes ≈0.1–0.25 s instead of
309
+ 3–4 s. A write rejected at the compaction gate no longer leaks a writer admission slot.
310
+ - **Views could double-count or miss writes made while they bootstrapped.** A delayed `~views`
311
+ poke could activate a second copy of a view while `create()` was still running (every later
312
+ write applied twice, e.g. 3 500 instead of 3 000); the bootstrap scan and its change replay could
313
+ both count a document written during the scan; a write in flight at a sync view's hand-off to
314
+ live processing could be lost; `rebuild()`/`stop()` could race a running scan (12 000 counted for
315
+ 10 000 docs); and the view-rebuild lease was never awaited. Activation is now idempotent, the scan
316
+ leaves every document changed after the create-time clock to the replay, and a sync view's final
317
+ replay and its `ready` flip happen in one write, so counts are exact for inserts. Known limitation: a sync view can
318
+ still double-count an _update or delete_ of an already-scanned document during its bootstrap;
319
+ `views.rebuild()` corrects it. An interrupted bootstrap is not resumed — the next `open()`
320
+ rebuilds the view.
321
+ - **`close()` during a view bootstrap could hang process exit.** Terminating the bootstrap worker
322
+ in the middle of an LMDB write left lmdb's native write thread waiting forever. The worker is now
323
+ cancelled cooperatively at a batch boundary and closes its own store (`terminate()` only after
324
+ `OKDB_VIEW_WORKER_CANCEL_TIMEOUT_MS`, default 10 s); `create()` resolves after the worker exits,
325
+ and no worker starts into a closing env. The bootstrap's change replay runs in chunks
326
+ (`OKDB_VIEWS_REPLAY_QUANTUM`, default 1 000) and yields, instead of one long loop stall.
327
+ - **The change-feed could announce a same-process write without its previous value.** A poke-driven
328
+ drain could reach a change between its commit and the in-process event, emit it without
329
+ `prevValue`, and the richer in-process event was then dropped as a duplicate. The drain now
330
+ leaves such changes to the in-process event.
331
+ - **Functions failed to compile under load.** Evaluating a function's source was bounded by a
332
+ hard-coded 100 ms wall clock, so a busy process got spurious `FUNCTION_SCRIPT_COMPILE_FAILED`.
333
+ The bound is now 1 s (`OKDB_FN_COMPILE_TIMEOUT_MS`).
334
+ - **`functions.run(name, payload, { timeoutMs })` ignored `timeoutMs`.** It now overrides the
335
+ stored `runtime.timeoutMs` for that call; it must be a positive finite number
336
+ (`FUNCTION_INVALID_TIMEOUT`) and is capped at `OKDB_FN_MAX_TIMEOUT_MS` (default 600 s).
337
+ - **Materializer pipelines committed once per document.** Each op was its own awaited durable
338
+ write; a drained batch now applies in one transaction (chunks of 2 000 ops), with license write
339
+ accounting unchanged — 6 000 docs ≈3.0 s → ≈0.9 s.
340
+ - **Embeddings: `createPipeline` dropped the indexer's `flushQuantum` / `drainDeadlineMs`**, so
341
+ they could not be tuned per pipeline; both are now passed through (defaults 32 changes and
342
+ 10 min). **`flush()` resolved silently when it timed out**, reporting "indexed" while the
343
+ cursor still trailed; `api.flush({ timeoutMs })` / `indexer.flush()` now reject with
344
+ `INDEXER_FLUSH_TIMEOUT` (default 30 s) — **callers that relied on it always resolving must
345
+ handle the rejection**.
346
+ - **Cluster: pause/resume and lease hand-offs took up to 2 s to show in `~processes`.** The
347
+ supervisor now republishes a worker's row (100 ms debounce) when its processing state changes,
348
+ not only on the heartbeat. The CLI's cluster banner no longer calls the supervisor "the
349
+ processor".
350
+ - **Docs: `OKDB_BUS_SECRET` was documented but never read.** The bus is namespaced automatically by
351
+ the store's identity (`okdb-<db id>`) — a namespace, not authentication; there is nothing to
352
+ configure. The HTTP-cluster docs also wrongly said the supervisor stays out of the request path:
353
+ on Linux/macOS it accepts every new connection (`NODE_CLUSTER_SCHED_POLICY=none` opts out; see
354
+ [HTTP Clustering → Connection distribution](docs/http-cluster.md#connection-distribution)).
355
+
7
356
  ## [2.3.5] - 2026-09-24
8
357
 
9
358
  ### Fixed
@@ -1 +1 @@
1
- 'use strict';const _0x4eed99=_0x156b;(function(_0x3aca52,_0x565bdb){const _0x104523=_0x156b,_0x37c1ee=_0x3aca52();while(!![]){try{const _0x52ec28=parseInt(_0x104523(0x18f))/0x1+-parseInt(_0x104523(0x12e))/0x2*(parseInt(_0x104523(0x1a1))/0x3)+parseInt(_0x104523(0x17f))/0x4+-parseInt(_0x104523(0x142))/0x5+parseInt(_0x104523(0x152))/0x6+parseInt(_0x104523(0x1a0))/0x7+-parseInt(_0x104523(0x1b4))/0x8;if(_0x52ec28===_0x565bdb)break;else _0x37c1ee['push'](_0x37c1ee['shift']());}catch(_0x1a430e){_0x37c1ee['push'](_0x37c1ee['shift']());}}}(_0x4b1e,0x346f9));function _0x156b(_0x2c722d,_0x2f1491){_0x2c722d=_0x2c722d-0x118;const _0x4b1e1a=_0x4b1e();let _0x156b37=_0x4b1e1a[_0x2c722d];return _0x156b37;}var require$$0$1=require('worker_threads'),require$$0=require('fs'),require$$1=require(_0x4eed99(0x15f)),require$$2=require('os'),require$$3=require(_0x4eed99(0x120));function getDefaultExportFromCjs(_0xc52e7d){const _0x52faf1=_0x4eed99;return _0xc52e7d&&_0xc52e7d['__esModule']&&Object[_0x52faf1(0x19f)][_0x52faf1(0x1da)][_0x52faf1(0x134)](_0xc52e7d,_0x52faf1(0x1e0))?_0xc52e7d[_0x52faf1(0x1e0)]:_0xc52e7d;}var algorithmWorkerThread$1={},snapshotStore,hasRequiredSnapshotStore;function requireSnapshotStore(){const _0x4020b7=_0x4eed99;if(hasRequiredSnapshotStore)return snapshotStore;hasRequiredSnapshotStore=0x1;const _0x56eede=require$$0,_0x259e3f=require$$1,_0x15f925=require$$2,_0x4bd6c1=require$$3;function _0x1e2ba0(){const _0x56c592=_0x156b;return Date[_0x56c592(0x1e4)]();}function _0xa93444(_0x46c81a){try{return _0x56eede['existsSync'](_0x46c81a);}catch{return![];}}function _0x526347(_0x414d6c){const _0x43b958=_0x156b;try{return _0x56eede[_0x43b958(0x14a)](_0x414d6c,_0x43b958(0x189));}catch{return null;}}function _0x21dc53(_0x17898f,_0x63a31f){const _0x5a9c21=_0x156b,_0x52052e=_0x17898f+_0x5a9c21(0x149)+_0x4bd6c1[_0x5a9c21(0x1a2)](0x6)[_0x5a9c21(0x1e8)]('hex');_0x56eede[_0x5a9c21(0x1ea)](_0x52052e,_0x63a31f),_0x56eede[_0x5a9c21(0x18d)](_0x52052e,_0x17898f);}function _0x16ced2(_0x4f4ec0,_0x2b6c6d=0x10){const _0x3d02aa=_0x156b,_0x3ce5e6=String(Math[_0x3d02aa(0x1c3)](0x0,Math['trunc'](_0x4f4ec0||0x0)));return _0x3ce5e6[_0x3d02aa(0x11e)]>=_0x2b6c6d?_0x3ce5e6:'0'[_0x3d02aa(0x199)](_0x2b6c6d-_0x3ce5e6[_0x3d02aa(0x11e)])+_0x3ce5e6;}return snapshotStore=class _0x24cd90{constructor({dir:_0x2c7c30,keepSnapshots:keepSnapshots=0x3,log:log=null}={}){const _0x4b0f48=_0x156b;if(!_0x2c7c30)throw new Error(_0x4b0f48(0x185));this[_0x4b0f48(0x1b9)]=_0x2c7c30,this[_0x4b0f48(0x16f)]=_0x259e3f[_0x4b0f48(0x1b6)](_0x2c7c30,_0x4b0f48(0x1aa)),this['currentPath']=_0x259e3f['join'](_0x2c7c30,_0x4b0f48(0x14e)),this[_0x4b0f48(0x197)]=_0x259e3f[_0x4b0f48(0x1b6)](_0x2c7c30,_0x4b0f48(0x184)),this[_0x4b0f48(0x1d3)]=keepSnapshots,this[_0x4b0f48(0x13a)]=log,_0x56eede[_0x4b0f48(0x163)](this[_0x4b0f48(0x1b9)],{'recursive':!![]}),_0x56eede[_0x4b0f48(0x163)](this[_0x4b0f48(0x16f)],{'recursive':!![]});}[_0x4020b7(0x1d5)](_0x53b925){const _0x19987b=_0x4020b7;return _0x259e3f[_0x19987b(0x1b6)](this[_0x19987b(0x16f)],_0x53b925);}[_0x4020b7(0x17b)](_0x193c6b){const _0x5e1337=_0x4020b7,_0xa1b2c8=this[_0x5e1337(0x1d5)](_0x193c6b);return{'dir':_0xa1b2c8,'index':_0x259e3f['join'](_0xa1b2c8,_0x5e1337(0x1cd)),'labels':_0x259e3f[_0x5e1337(0x1b6)](_0xa1b2c8,_0x5e1337(0x153)),'state':_0x259e3f['join'](_0xa1b2c8,_0x5e1337(0x15d))};}[_0x4020b7(0x1d2)](){const _0x2c1d1d=_0x4020b7;if(!_0xa93444(this['currentPath']))return null;const _0x5a69cb=_0x526347(this[_0x2c1d1d(0x124)]);if(!_0x5a69cb)return null;const _0x41bb6c=String(_0x5a69cb)['trim']();return _0x41bb6c||null;}[_0x4020b7(0x1a8)](){const _0x108607=_0x4020b7,_0x7a4293=this[_0x108607(0x1d2)]();if(!_0x7a4293)return 0x0;const _0x68a7e=Number(_0x7a4293);return Number[_0x108607(0x1bc)](_0x68a7e)?_0x68a7e:0x0;}[_0x4020b7(0x187)](){const _0x1c4912=_0x4020b7;try{return _0x56eede[_0x1c4912(0x1ce)](this['snapshotsDir'],{'withFileTypes':!![]})[_0x1c4912(0x1df)](_0x29b5e3=>_0x29b5e3[_0x1c4912(0x144)]())[_0x1c4912(0x1ca)](_0x449695=>_0x449695[_0x1c4912(0x12d)])[_0x1c4912(0x1df)](_0x3dbfb6=>!_0x3dbfb6['startsWith']('.tmp-'))[_0x1c4912(0x1df)](_0x4e8395=>!_0x4e8395[_0x1c4912(0x133)](_0x1c4912(0x164)))[_0x1c4912(0x1c5)]();}catch{return[];}}[_0x4020b7(0x1ab)](){const _0x448031=_0x4020b7,_0x48eba3=this[_0x448031(0x1d2)]();if(_0x48eba3)return _0x48eba3;const _0x41762c=this[_0x448031(0x187)]();if(!_0x41762c[_0x448031(0x11e)])return null;return _0x41762c[_0x41762c[_0x448031(0x11e)]-0x1];}[_0x4020b7(0x175)]({maxAgeMs:maxAgeMs=0x6*0x36ee80}={}){const _0x1f45b7=_0x4020b7;let _0x46df4c;try{_0x46df4c=_0x56eede[_0x1f45b7(0x1ce)](this[_0x1f45b7(0x16f)],{'withFileTypes':!![]});}catch{return;}const _0x25f4f3=_0x1e2ba0()-maxAgeMs;for(const _0x47cf67 of _0x46df4c){if(!_0x47cf67[_0x1f45b7(0x144)]())continue;const _0x5351e0=_0x47cf67[_0x1f45b7(0x12d)];if(!_0x5351e0['startsWith'](_0x1f45b7(0x149))&&!_0x5351e0[_0x1f45b7(0x133)](_0x1f45b7(0x164)))continue;const _0x52624b=_0x259e3f[_0x1f45b7(0x1b6)](this[_0x1f45b7(0x16f)],_0x5351e0);try{const _0x1d9452=_0x56eede[_0x1f45b7(0x194)](_0x52624b);if(_0x1d9452[_0x1f45b7(0x1e1)]>_0x25f4f3)continue;}catch{}try{_0x56eede[_0x1f45b7(0x1be)](_0x52624b,{'recursive':!![],'force':!![]});}catch{}}}[_0x4020b7(0x135)]({keep:keep=null}={}){const _0xa6b7a7=_0x4020b7,_0x45b2be=Math['max'](0x1,Math[_0xa6b7a7(0x129)](keep??this['keepSnapshots']??0x3)),_0x13b561=this['listSnapshotIds']();if(_0x13b561[_0xa6b7a7(0x11e)]<=_0x45b2be)return;const _0x17ef9f=this[_0xa6b7a7(0x1d2)](),_0x112979=_0x13b561[_0xa6b7a7(0x130)](0x0,Math[_0xa6b7a7(0x1c3)](0x0,_0x13b561[_0xa6b7a7(0x11e)]-_0x45b2be));for(const _0x41904f of _0x112979){if(_0x17ef9f&&_0x41904f===_0x17ef9f)continue;const _0x42e24b=this[_0xa6b7a7(0x1d5)](_0x41904f);try{_0x56eede[_0xa6b7a7(0x1be)](_0x42e24b,{'recursive':!![],'force':!![]});}catch{}}}async['loadSnapshot'](_0x938190,_0x435ce7){const _0x59fc93=_0x4020b7;if(!_0x938190)throw new Error(_0x59fc93(0x1a3));const _0x27ce09=this[_0x59fc93(0x17b)](_0x938190);if(!_0xa93444(_0x27ce09[_0x59fc93(0x11c)])||!_0xa93444(_0x27ce09[_0x59fc93(0x17a)])||!_0xa93444(_0x27ce09[_0x59fc93(0x148)]))throw new Error(_0x59fc93(0x1d6)+_0x938190);const _0x149115=await _0x435ce7(_0x27ce09);return _0x149115||{};}async[_0x4020b7(0x140)](_0x2d8463,_0x97e323,{keep:keep=null,lockTimeoutMs:lockTimeoutMs=0x0,staleLockMaxAgeMs:staleLockMaxAgeMs=0xea60}={}){const _0x20fada=_0x4020b7,_0x12e688=Number(_0x2d8463);if(!Number['isFinite'](_0x12e688)||_0x12e688<0x0)throw new Error(_0x20fada(0x195));const _0x2d9fd7=_0x16ced2(_0x12e688),_0xb5192a=this[_0x20fada(0x1d5)](_0x2d9fd7),_0x1b93ae=_0x259e3f[_0x20fada(0x1b6)](this[_0x20fada(0x16f)],_0x20fada(0x149)+_0x2d9fd7+'-'+_0x4bd6c1[_0x20fada(0x1a2)](0x6)['toString']('hex'));_0x56eede['mkdirSync'](_0x1b93ae,{'recursive':!![]});const _0x264896={'dir':_0x1b93ae,'index':_0x259e3f[_0x20fada(0x1b6)](_0x1b93ae,_0x20fada(0x1cd)),'labels':_0x259e3f[_0x20fada(0x1b6)](_0x1b93ae,'labels.json'),'state':_0x259e3f['join'](_0x1b93ae,'state.json')};await _0x97e323(_0x264896,{'id':_0x2d9fd7,'clock':_0x12e688});const _0x107998=JSON[_0x20fada(0x14d)]({'pid':process[_0x20fada(0x181)],'host':_0x15f925[_0x20fada(0x188)](),'at':_0x1e2ba0()}),_0x22a089=_0x1e2ba0();let _0x4960a9=null;const _0xcfcd9e=()=>{const _0x39bf2d=_0x20fada;try{const _0xf47285=JSON[_0x39bf2d(0x1f3)](_0x56eede[_0x39bf2d(0x14a)](this[_0x39bf2d(0x197)],_0x39bf2d(0x189)));if(_0xf47285['at']&&_0x1e2ba0()-_0xf47285['at']>staleLockMaxAgeMs){const _0x317da3=_0x1e2ba0()-_0xf47285['at'],_0x10ae19=_0x39bf2d(0x1b3)+Math[_0x39bf2d(0x1b0)](_0x317da3/0x3e8)+_0x39bf2d(0x1bb)+_0xf47285['pid']+_0x39bf2d(0x145)+_0xf47285[_0x39bf2d(0x168)]+_0x39bf2d(0x143)+_0x39bf2d(0x1c2);this[_0x39bf2d(0x13a)]?.[_0x39bf2d(0x13c)]?this[_0x39bf2d(0x13a)][_0x39bf2d(0x13c)](_0x10ae19):console['warn'](_0x39bf2d(0x18a),_0x10ae19);try{_0x56eede[_0x39bf2d(0x118)](this[_0x39bf2d(0x197)]);}catch{}return!![];}}catch{try{_0x56eede[_0x39bf2d(0x118)](this[_0x39bf2d(0x197)]);}catch{}}return![];},_0x1c96f2=()=>{const _0x3b775c=_0x20fada;try{return _0x4960a9=_0x56eede[_0x3b775c(0x1cf)](this[_0x3b775c(0x197)],'wx'),_0x56eede[_0x3b775c(0x1ea)](_0x4960a9,_0x107998),!![];}catch(_0x2555b1){if(_0x2555b1&&_0x2555b1[_0x3b775c(0x1ad)]===_0x3b775c(0x17c))return![];throw _0x2555b1;}};if(!_0x1c96f2()){_0xcfcd9e(),_0x1c96f2();if(_0x4960a9==null&&lockTimeoutMs>0x0)while(_0x1e2ba0()-_0x22a089<lockTimeoutMs){await new Promise(_0xbf33a7=>setTimeout(_0xbf33a7,0x19));if(_0x1c96f2())break;_0xcfcd9e();}}if(_0x4960a9==null){try{_0x56eede['rmSync'](_0x1b93ae,{'recursive':!![],'force':!![]});}catch{}return{'published':![],'reason':_0x20fada(0x125)};}try{const _0x1a2cf4=this[_0x20fada(0x1a8)]();if(_0x12e688<=_0x1a2cf4){try{_0x56eede[_0x20fada(0x1be)](_0x1b93ae,{'recursive':!![],'force':!![]});}catch{}return{'published':![],'reason':'stale','currentClock':_0x1a2cf4};}if(!_0xa93444(_0xb5192a))_0x56eede[_0x20fada(0x18d)](_0x1b93ae,_0xb5192a);else try{_0x56eede[_0x20fada(0x1be)](_0x1b93ae,{'recursive':!![],'force':!![]});}catch{}return _0x21dc53(this[_0x20fada(0x124)],_0x2d9fd7+'\x0a'),this[_0x20fada(0x135)]({'keep':keep}),{'published':!![],'currentClock':_0x12e688};}finally{try{_0x56eede['closeSync'](_0x4960a9);}catch{}try{_0x56eede[_0x20fada(0x118)](this[_0x20fada(0x197)]);}catch{}}}},snapshotStore;}var labelMap,hasRequiredLabelMap;function requireLabelMap(){const _0x2544a9=_0x4eed99;if(hasRequiredLabelMap)return labelMap;hasRequiredLabelMap=0x1;const _0x53a33d=require$$0;class _0xdfb5ab{constructor(){const _0x20a0c6=_0x156b;this['keyToLabel']=new Map(),this[_0x20a0c6(0x128)]=new Map(),this['nextLabel']=0x0,this['_tombstoneCount']=0x0,this['keyToFp']=new Map(),this[_0x20a0c6(0x1c4)]=!![];}async[_0x2544a9(0x160)](){const _0x105e61=_0x2544a9;this['keyToLabel']=new Map(),this[_0x105e61(0x128)]=new Map(),this['keyToFp']=new Map(),this['hasFingerprints']=!![],this[_0x105e61(0x1d4)]=0x0,this[_0x105e61(0x1d9)]=0x0;}async['loadFrom'](_0x4e969c){const _0x332247=_0x2544a9;if(!_0x4e969c||!_0x53a33d[_0x332247(0x1ec)](_0x4e969c))return await this[_0x332247(0x160)](),!![];let _0x4ea9b4;try{_0x4ea9b4=_0x53a33d['readFileSync'](_0x4e969c,'utf8');}catch{return await this[_0x332247(0x160)](),!![];}let _0x460b7f;try{_0x460b7f=JSON[_0x332247(0x1f3)](_0x4ea9b4);}catch{return await this[_0x332247(0x160)](),!![];}const _0xd058c2=Array['isArray'](_0x460b7f?.['entries'])?_0x460b7f[_0x332247(0x166)]:[],_0x45899e=Number[_0x332247(0x174)](_0x460b7f?.[_0x332247(0x1d4)])?_0x460b7f[_0x332247(0x1d4)]:0x0,_0x5cd9b=new Map(),_0x49ec94=new Map(),_0x4fc454=new Map(),_0x3e1f7e=_0x460b7f?.['version']>=0x2;let _0xa45346=-0x1;for(const _0xcdbc58 of _0xd058c2){if(!Array[_0x332247(0x158)](_0xcdbc58)||_0xcdbc58[_0x332247(0x11e)]<0x2)continue;const _0x58b28f=Number(_0xcdbc58[0x0]),_0x574130=String(_0xcdbc58[0x1]??'');if(!Number[_0x332247(0x174)](_0x58b28f)||_0x58b28f<0x0)continue;if(!_0x574130)continue;_0x5cd9b[_0x332247(0x169)](_0x574130,_0x58b28f),_0x49ec94['set'](_0x58b28f,_0x574130);if(_0x3e1f7e&&typeof _0xcdbc58[0x2]==='number')_0x4fc454[_0x332247(0x169)](_0x574130,_0xcdbc58[0x2]);if(_0x58b28f>_0xa45346)_0xa45346=_0x58b28f;}return this[_0x332247(0x146)]=_0x5cd9b,this['labelToKey']=_0x49ec94,this[_0x332247(0x155)]=_0x4fc454,this[_0x332247(0x1c4)]=_0x3e1f7e,this[_0x332247(0x1d4)]=Math[_0x332247(0x1c3)](_0x45899e,_0xa45346+0x1,0x0),this['_tombstoneCount']=0x0,!![];}[_0x2544a9(0x19a)](_0x43cf55){const _0x4ad0c4=_0x2544a9;return this[_0x4ad0c4(0x146)]['get'](_0x43cf55);}[_0x2544a9(0x147)](_0x4cafa9){const _0x36b8da=_0x2544a9;let _0x562532=this['keyToLabel'][_0x36b8da(0x1b5)](_0x4cafa9);if(_0x562532!==undefined)return _0x562532;return _0x562532=this[_0x36b8da(0x1d4)]++,this['keyToLabel'][_0x36b8da(0x169)](_0x4cafa9,_0x562532),this[_0x36b8da(0x128)][_0x36b8da(0x169)](_0x562532,_0x4cafa9),_0x562532;}[_0x2544a9(0x176)](_0x3238f7,_0x3ef4a5){const _0x28d49c=_0x2544a9;if(_0x3ef4a5==null)this['keyToFp'][_0x28d49c(0x170)](_0x3238f7);else this[_0x28d49c(0x155)][_0x28d49c(0x169)](_0x3238f7,_0x3ef4a5);}[_0x2544a9(0x138)](_0x2c31b9){const _0x404007=_0x2544a9;return this[_0x404007(0x155)][_0x404007(0x1b5)](_0x2c31b9);}[_0x2544a9(0x161)](){const _0x391ed6=_0x2544a9;return this[_0x391ed6(0x146)][_0x391ed6(0x161)]();}[_0x2544a9(0x198)](_0x8a119f){const _0x276aed=_0x2544a9,_0x4f1668=this[_0x276aed(0x146)][_0x276aed(0x1b5)](_0x8a119f);if(_0x4f1668===undefined)return;this[_0x276aed(0x155)][_0x276aed(0x170)](_0x8a119f),this[_0x276aed(0x146)]['delete'](_0x8a119f),this['labelToKey'][_0x276aed(0x170)](_0x4f1668),this[_0x276aed(0x1d9)]++;}[_0x2544a9(0x13e)](_0x2e114b){const _0x1dd9dd=_0x2544a9;return this[_0x1dd9dd(0x128)][_0x1dd9dd(0x1b5)](_0x2e114b)??null;}[_0x2544a9(0x131)](){const _0x31b34a=_0x2544a9;return this[_0x31b34a(0x146)][_0x31b34a(0x131)];}[_0x2544a9(0x1a4)](){const _0x305644=_0x2544a9;return this[_0x305644(0x1d9)];}async[_0x2544a9(0x15b)](_0x5d24f7){const _0x55e3db=_0x2544a9,_0x197f60=_0x5d24f7+_0x55e3db(0x11d),_0x506261=[];for(const [_0x4c49ec,_0x50287b]of this['labelToKey']['entries']()){const _0x366d40=this[_0x55e3db(0x155)]['get'](_0x50287b);_0x506261['push'](_0x366d40==null?[_0x4c49ec,_0x50287b]:[_0x4c49ec,_0x50287b,_0x366d40]);}_0x506261[_0x55e3db(0x1c5)]((_0x2a920b,_0x329b1e)=>_0x2a920b[0x0]-_0x329b1e[0x0]);const _0x1d7507={'version':0x2,'nextLabel':this[_0x55e3db(0x1d4)],'entries':_0x506261};_0x53a33d['writeFileSync'](_0x197f60,JSON[_0x55e3db(0x14d)](_0x1d7507)),_0x53a33d[_0x55e3db(0x18d)](_0x197f60,_0x5d24f7);}}return labelMap=_0xdfb5ab,labelMap;}function _0x4b1e(){const _0x233a92=['efConstruction','MetricKind','setEf','index','.tmp','length','cosine','crypto','arch','vectors','ready','currentPath','lock_busy','tmpMaxAgeMs','algorithm','labelToKey','trunc','maxElements','key','heartbeatIntervalMs','name','5314bDhUyA','clock','slice','size','removed','startsWith','call','prune','metric','getMaxElements','fingerprintOf','unref','log','connectivity','warn','F32','keyForLabel','ENOENT','publishSnapshot','Index','507555ygBQot',').\x20','isDirectory',',\x20host:\x20','keyToLabel','labelForEphemeral','state','.tmp-','readFileSync','loadSnapshot','score','stringify','CURRENT','message','finally','resolve','958470WhPOLp','labels.json','distances','keyToFp','markDelete','stop','isArray','expansionSearch','vector','snapshotTo','buffer','state.json','remove','path','reset','keys','\x20on\x20','mkdirSync','_tmp-','info','entries','writer','host','set','load','writeIndexSync','rebuild','search','searchKnn','snapshotsDir','delete','hnsw','usearch\x20algorithm\x20requires\x20dims\x20>\x200','min','isInteger','cleanupTmpDirs','setFingerprint','closeSync','count','viewRefreshMs','labels','_snapshotPaths','EEXIST','hnswlib-node','reader','1297008xicmEZ','loadFrom','pid','isFree','L2sq','SNAPSHOT.LOCK','SnapshotStore\x20requires\x20dir','HierarchicalNSW','listSnapshotIds','hostname','utf8','[SnapshotStore]','token','hnsw\x20algorithm\x20requires\x20dir\x20for\x20snapshot\x20storage','renameSync','opts','37530kDNaEL','HNSW\x20algorithm\x20unavailable:\x20the\x20native\x20\x22hnswlib-node\x22\x20bindings\x20could\x20not\x20be\x20loaded\x20','expansionAdd','platform','efSearch','statSync','candidateClock\x20must\x20be\x20finite\x20>=\x200','unreadable','lockPath','tombstone','repeat','labelForExisting','changed','view','resizeIndex','error','prototype','2401525iOPtXv','57eTwSck','randomBytes','snapshot\x20id\x20required','tombstoneCount','initIndex','usearch\x20algorithm\x20requires\x20dir\x20for\x20snapshot\x20storage','acquire','readCurrentClock','hex','snapshots','latestSnapshotId','getCurrentCount','code','from','flat','round','add','versions','Breaking\x20stale\x20snapshot\x20lock\x20(age:\x20','3982648CCDGNY','get','join','snapshotMaxLagMs','growFactor','dir','usearch','s,\x20pid:\x20','isFinite','HNSW_BINDINGS_UNAVAILABLE','rmSync','Original\x20error:\x20','Unknown\x20op:\x20\x22','manifestVersion','This\x20is\x20risky\x20on\x20slow\x20disks\x20or\x20overloaded\x20machines.\x20Consider\x20increasing\x20staleLockMaxAgeMs\x20if\x20this\x20happens\x20frequently.','max','hasFingerprints','sort','hnsw\x20algorithm\x20requires\x20dims\x20>\x200','cause','catch','fid','map','writerLockMaxAgeMs','readIndexSync','index.hnsw','readdirSync','openSync','fetchAll','Cos','readCurrentId','keepSnapshots','nextLabel','_snapshotDir','snapshot\x20incomplete:\x20','node','for\x20Node\x20','_tombstoneCount','hasOwnProperty','ceil','memoryUsage','USEARCH_BINDINGS_UNAVAILABLE','byteOffset','filter','default','mtimeMs','snapshotEveryChanges','reject','now','sync','snapshot','published','toString','postMessage','writeFileSync','then','existsSync','dims','has','fetchAllResult','WRITER.LOCK','save','imul','parse','push','Install\x20compatible\x20bindings\x20or\x20use\x20algorithm\x20\x22flat\x22\x20instead.\x20','unlinkSync'];_0x4b1e=function(){return _0x233a92;};return _0x4b1e();}var indexConvergence,hasRequiredIndexConvergence;function requireIndexConvergence(){if(hasRequiredIndexConvergence)return indexConvergence;hasRequiredIndexConvergence=0x1;function _0x3de669(_0x3f4c9c){const _0x34f329=_0x156b,_0x1dc662=new Uint32Array(_0x3f4c9c[_0x34f329(0x15c)],_0x3f4c9c[_0x34f329(0x1de)],_0x3f4c9c['length']);let _0x343d0f=0x811c9dc5,_0x38ba16=0x9747b28c;for(let _0x31950f=0x0;_0x31950f<_0x1dc662['length'];_0x31950f++){const _0xb8917f=_0x1dc662[_0x31950f];_0x343d0f=Math[_0x34f329(0x1f2)](_0x343d0f^_0xb8917f,0x1000193)>>>0x0;let _0x58d4e5=Math[_0x34f329(0x1f2)](_0xb8917f,0xcc9e2d51);_0x58d4e5=_0x58d4e5<<0xf|_0x58d4e5>>>0x11,_0x38ba16=Math[_0x34f329(0x1f2)](_0x38ba16^Math[_0x34f329(0x1f2)](_0x58d4e5,0x1b873593),0x5)+0xe6546b64,_0x38ba16>>>=0x0;}return _0x38ba16=Math[_0x34f329(0x1f2)](_0x38ba16^_0x38ba16>>>0x10,0x85ebca6b)>>>0x0,(_0x343d0f>>>0x0)*0x100000+(_0x38ba16&0xfffff);}function _0x4129c1(_0x525ca3,_0xdc3f9b,_0x588d34,{upsert:_0x41c910,remove:_0x365cf7}){const _0x482919=_0x156b,_0x12e8ce=new Set();let _0x48b490=0x0,_0x4ee804=0x0,_0x7b38d8=0x0;for(const {key:_0x5439f7,vector:_0x5e80a9}of _0xdc3f9b){if(!(_0x5e80a9 instanceof Float32Array)||_0x5e80a9[_0x482919(0x11e)]!==_0x588d34)continue;_0x12e8ce[_0x482919(0x1b1)](_0x5439f7);const _0x4a9adf=_0x3de669(_0x5e80a9),_0x562dd4=_0x525ca3[_0x482919(0x19a)](_0x5439f7)!==undefined;if(_0x562dd4&&_0x525ca3[_0x482919(0x138)](_0x5439f7)===_0x4a9adf)continue;_0x41c910(_0x5439f7,_0x5e80a9,_0x4a9adf);if(_0x562dd4)_0x4ee804++;else _0x48b490++;}for(const _0x412d5f of[..._0x525ca3[_0x482919(0x161)]()]){if(_0x12e8ce[_0x482919(0x1ee)](_0x412d5f))continue;_0x365cf7(_0x412d5f),_0x7b38d8++;}return{'added':_0x48b490,'changed':_0x4ee804,'removed':_0x7b38d8};}return indexConvergence={'fingerprint':_0x3de669,'reconcileIndex':_0x4129c1},indexConvergence;}var hnsw,hasRequiredHnsw;function requireHnsw(){if(hasRequiredHnsw)return hnsw;hasRequiredHnsw=0x1;const _0x557ce7=requireSnapshotStore(),_0x43dd87=requireLabelMap(),{fingerprint:_0x329d56,reconcileIndex:_0x38d4fd}=requireIndexConvergence(),_0x1f9987=0x1;let _0x415250=null;function _0x30ac40(){const _0x122b2b=_0x156b;if(_0x415250)return _0x415250;try{return _0x415250=require(_0x122b2b(0x17d)),_0x415250;}catch(_0x270acf){const _0x3c4a01=new Error(_0x122b2b(0x190)+(_0x122b2b(0x1d8)+process[_0x122b2b(0x1b2)]['node']+_0x122b2b(0x162)+process['platform']+'/'+process[_0x122b2b(0x121)]+'.\x20')+_0x122b2b(0x1f5)+(_0x122b2b(0x1bf)+(_0x270acf?.[_0x122b2b(0x14f)]||String(_0x270acf))));_0x3c4a01['code']=_0x122b2b(0x1bd),_0x3c4a01[_0x122b2b(0x1c7)]=_0x270acf;throw _0x3c4a01;}}return hnsw=function _0x247a32(_0x37a652={},{dims:_0x3e90b3,dir:_0xfe8058}){const _0xa10ee0=_0x156b,_0x181b13=_0x30ac40();if(!_0x3e90b3||_0x3e90b3<=0x0)throw new Error(_0xa10ee0(0x1c6));if(!_0xfe8058)throw new Error(_0xa10ee0(0x18c));const _0x16728d={'metric':_0x37a652[_0xa10ee0(0x136)]??_0xa10ee0(0x11f),'M':_0x37a652['M']??0x10,'efConstruction':_0x37a652[_0xa10ee0(0x119)]??0xc8,'efSearch':_0x37a652[_0xa10ee0(0x193)]??0x40,'maxElements':_0x37a652[_0xa10ee0(0x12a)]??0x400,'growFactor':_0x37a652[_0xa10ee0(0x1b8)]??0x2,'snapshotEveryChanges':_0x37a652['snapshotEveryChanges']??0xc350,'keepSnapshots':_0x37a652[_0xa10ee0(0x1d3)]??0x2,'tmpMaxAgeMs':_0x37a652['tmpMaxAgeMs']??0x6*0x36ee80},_0x105736=new _0x557ce7({'dir':_0xfe8058,'keepSnapshots':_0x16728d['keepSnapshots']}),_0x4766aa=new _0x43dd87();let _0x266b0b=null,_0x30b9cc=0x0,_0x150668=null,_0x5cae69=Promise[_0xa10ee0(0x151)]();const _0x302383=_0x101f9f=>{const _0x57350c=_0xa10ee0,_0x2760b6=_0x5cae69[_0x57350c(0x1eb)](_0x101f9f);return _0x5cae69=_0x2760b6[_0x57350c(0x1c8)](()=>{}),_0x2760b6;};async function _0x1be4a8(_0x9a4bee){const _0x437e5b=_0xa10ee0;await _0x4766aa[_0x437e5b(0x160)](),_0x9a4bee=_0x9a4bee??[];const _0xcf2fe=Math[_0x437e5b(0x1c3)](_0x16728d['maxElements'],Math[_0x437e5b(0x1db)](_0x9a4bee[_0x437e5b(0x11e)]*(_0x16728d[_0x437e5b(0x1b8)]||1.2)),0x1);_0x266b0b=new _0x181b13[(_0x437e5b(0x186))](_0x16728d[_0x437e5b(0x136)],_0x3e90b3),_0x266b0b[_0x437e5b(0x1a5)]({'maxElements':_0xcf2fe,'efConstruction':_0x16728d[_0x437e5b(0x119)],'M':_0x16728d['M']});for(const {key:_0x59b0dd,vector:_0x9878a1}of _0x9a4bee){if(!(_0x9878a1 instanceof Float32Array)||_0x9878a1[_0x437e5b(0x11e)]!==_0x3e90b3)continue;_0x5f1939(_0x59b0dd,_0x9878a1);}_0x266b0b[_0x437e5b(0x11b)](_0x16728d[_0x437e5b(0x193)]),_0x30b9cc=0x0;}async function _0x168d1e(_0xc62517){return _0x1be4a8(_0xc62517?await _0xc62517():[]);}function _0x3bbc20(){const _0x4f7e17=_0xa10ee0;if(_0x266b0b[_0x4f7e17(0x1ac)]()<_0x266b0b[_0x4f7e17(0x137)]())return;const _0x469e10=Math[_0x4f7e17(0x1db)](_0x266b0b[_0x4f7e17(0x137)]()*(_0x16728d['growFactor']||0x2));_0x266b0b[_0x4f7e17(0x19d)](_0x469e10),_0x16728d[_0x4f7e17(0x12a)]=_0x469e10;}function _0x5f1939(_0xa25205,_0x583ec7,_0x4d4ebc){const _0x4b0f64=_0xa10ee0,_0x5c442e=_0x4766aa[_0x4b0f64(0x147)](_0xa25205);try{_0x266b0b[_0x4b0f64(0x156)](_0x5c442e);}catch{}_0x3bbc20(),_0x266b0b['addPoint'](Array[_0x4b0f64(0x1ae)](_0x583ec7),_0x5c442e),_0x4766aa[_0x4b0f64(0x176)](_0xa25205,_0x4d4ebc??_0x329d56(_0x583ec7));}function _0x55edb7(_0x4081c8){const _0x2b727e=_0xa10ee0,_0x272f42=_0x4766aa[_0x2b727e(0x19a)](_0x4081c8);if(_0x272f42===undefined)return![];try{_0x266b0b[_0x2b727e(0x156)](_0x272f42);}catch{}return _0x4766aa[_0x2b727e(0x198)](_0x4081c8),!![];}function _0x463721(){const _0x4de843=_0xa10ee0;return Math['max'](Date['now'](),_0x105736[_0x4de843(0x1a8)]()+0x1);}async function _0x10a3f5(_0x505ea0){const _0x2ca20e=_0xa10ee0;if(!_0x266b0b||!_0x505ea0)return![];const _0x108d10=await _0x105736[_0x2ca20e(0x140)](_0x505ea0,async _0x2f8c83=>{const _0x55945a=_0x2ca20e;_0x266b0b[_0x55945a(0x16b)](_0x2f8c83['index']),await _0x4766aa[_0x55945a(0x15b)](_0x2f8c83[_0x55945a(0x17a)]);const _0x3db385=require$$0;_0x3db385['writeFileSync'](_0x2f8c83[_0x55945a(0x148)],JSON['stringify']({'manifestVersion':_0x1f9987,'dims':_0x3e90b3,'metric':_0x16728d['metric'],'clock':_0x505ea0,'snapshotAt':Date[_0x55945a(0x1e4)]()},null,0x2));},{'keep':_0x16728d[_0x2ca20e(0x1d3)]});if(_0x108d10?.['published'])_0x30b9cc=0x0;return _0x108d10?.['published']??![];}async function _0xa2fdee(){const _0x58d274=_0xa10ee0,_0x544af0=_0x105736[_0x58d274(0x1d2)]()||_0x105736[_0x58d274(0x1ab)]();if(!_0x544af0)return null;let _0x4be05b,_0x41ea3d=![];return await _0x105736[_0x58d274(0x14b)](_0x544af0,async _0x3dfc77=>{const _0x16a860=_0x58d274,_0x1c15d4=require$$0;_0x4be05b=JSON[_0x16a860(0x1f3)](_0x1c15d4[_0x16a860(0x14a)](_0x3dfc77['state'],_0x16a860(0x189)));if(_0x4be05b[_0x16a860(0x1c1)]!==_0x1f9987||_0x4be05b[_0x16a860(0x1ed)]!==_0x3e90b3||_0x4be05b['metric']!==_0x16728d[_0x16a860(0x136)]){_0x4be05b=null;return;}await _0x4766aa['loadFrom'](_0x3dfc77[_0x16a860(0x17a)]),_0x266b0b=new _0x181b13[(_0x16a860(0x186))](_0x16728d[_0x16a860(0x136)],_0x3e90b3),_0x266b0b[_0x16a860(0x1cc)](_0x3dfc77[_0x16a860(0x11c)]),_0x266b0b['setEf'](_0x16728d[_0x16a860(0x193)]),_0x41ea3d=!![];}),_0x41ea3d?_0x4be05b?.['clock']??0x0:null;}return{async 'load'(_0x2eda64){return _0x302383(async()=>{const _0x2d3aad=_0x156b;_0x105736[_0x2d3aad(0x175)]({'maxAgeMs':_0x16728d[_0x2d3aad(0x126)]}),_0x150668=_0x2eda64??null;const _0x3f7fe9=await _0xa2fdee(),_0x6fa7b9=_0x2eda64?await _0x2eda64():null;if(_0x3f7fe9!=null){if(_0x6fa7b9){if(!_0x4766aa[_0x2d3aad(0x1c4)])return await _0x1be4a8(_0x6fa7b9),null;const _0x2cdce0=_0x38d4fd(_0x4766aa,_0x6fa7b9,_0x3e90b3,{'upsert':_0x5f1939,'remove':_0x55edb7});_0x30b9cc+=_0x2cdce0['added']+_0x2cdce0[_0x2d3aad(0x19b)]+_0x2cdce0[_0x2d3aad(0x132)];}return _0x3f7fe9;}return await _0x1be4a8(_0x6fa7b9),null;});},async 'add'(_0x4f7061,_0x176856,_0x1e5646){return _0x302383(async()=>{const _0x36d670=_0x156b;if(!_0x266b0b)return;const _0x2bf4ff=_0x176856 instanceof Float32Array?_0x176856:new Float32Array(_0x176856),_0x53ceda=_0x329d56(_0x2bf4ff);if(_0x4766aa[_0x36d670(0x138)](_0x4f7061)===_0x53ceda)return;_0x5f1939(_0x4f7061,_0x2bf4ff,_0x53ceda),_0x30b9cc++,_0x30b9cc>=_0x16728d[_0x36d670(0x1e2)]&&await _0x10a3f5(_0x463721());});},async 'remove'(_0x18e845){return _0x302383(async()=>{if(!_0x266b0b)return;if(_0x55edb7(_0x18e845))_0x30b9cc++;});},'search'(_0x340c98,{limit:limit=0xa,efSearch:_0x52cebc}={}){const _0x52377f=_0xa10ee0;if(!_0x266b0b)return[];if(Number['isInteger'](_0x52cebc))_0x266b0b[_0x52377f(0x11b)](_0x52cebc);const _0x3782ae=Math[_0x52377f(0x173)](limit,_0x266b0b[_0x52377f(0x1ac)]()||0x1),{neighbors:_0xa000dc,distances:_0xf3dffb}=_0x266b0b[_0x52377f(0x16e)](Array[_0x52377f(0x1ae)](_0x340c98),_0x3782ae),_0xc01819=[];for(let _0x4e05a7=0x0;_0x4e05a7<_0xa000dc['length'];_0x4e05a7++){const _0xf45872=_0x4766aa['keyForLabel'](_0xa000dc[_0x4e05a7]);if(!_0xf45872)continue;const _0x188ff9=_0x16728d[_0x52377f(0x136)]==='cosine'?Math[_0x52377f(0x1c3)](0x0,0x1-_0xf3dffb[_0x4e05a7]):0x1/(0x1+_0xf3dffb[_0x4e05a7]);_0xc01819[_0x52377f(0x1f4)]({'key':_0xf45872,'score':_0x188ff9});}return _0xc01819;},async 'snapshot'(_0x59f1b0){return _0x302383(()=>_0x10a3f5(_0x59f1b0??_0x463721()));},async 'rebuild'(_0x1c3383){return _0x302383(()=>{if(_0x1c3383!=null)_0x150668=_0x1c3383;return _0x168d1e(_0x1c3383??_0x150668);});},async 'stop'(){const _0x14df8c=_0xa10ee0;return _0x302383(()=>_0x30b9cc>0x0||!_0x105736[_0x14df8c(0x1d2)]()?_0x10a3f5(_0x463721()):![]);},'count'(){const _0x323144=_0xa10ee0;return _0x4766aa[_0x323144(0x131)]();},'info'(){const _0x3a444e=_0xa10ee0;return{'algorithm':_0x3a444e(0x171),'metric':_0x16728d[_0x3a444e(0x136)],'M':_0x16728d['M'],'efConstruction':_0x16728d[_0x3a444e(0x119)],'efSearch':_0x16728d[_0x3a444e(0x193)],'maxElements':_0x266b0b?.['getMaxElements']()??_0x16728d[_0x3a444e(0x12a)],'count':_0x4766aa['size'](),'changesSince':_0x30b9cc,'snapshotDir':_0xfe8058,'latestSnapshot':_0x105736['readCurrentId']()??null};}};},hnsw;}var flat,hasRequiredFlat;function requireFlat(){if(hasRequiredFlat)return flat;hasRequiredFlat=0x1,flat=function _0x9fa58e(_0x1c5a29={}){const _0x533777=new Map();return{async 'load'(_0x2fe6b0){_0x533777['clear']();if(_0x2fe6b0)for(const {key:_0x4200e0,vector:_0x522e40}of await _0x2fe6b0()){_0x533777['set'](_0x4200e0,_0x522e40);}},async 'add'(_0x3e14b6,_0x444ad3,_0x12d38c){_0x533777['set'](_0x3e14b6,_0x444ad3);},async 'remove'(_0x19f893){const _0x8a6f1d=_0x156b;_0x533777[_0x8a6f1d(0x170)](_0x19f893);},'search'(_0x4f84e2,{limit:limit=0xa,threshold:threshold=0x0}={}){const _0x5c60da=_0x156b,_0x43c414=[];for(const [_0x455012,_0xd0a36c]of _0x533777){const _0x43eb25=_0x3581a3(_0x4f84e2,_0xd0a36c);if(_0x43eb25>=threshold)_0x43c414[_0x5c60da(0x1f4)]({'key':_0x455012,'score':_0x43eb25});}return _0x43c414[_0x5c60da(0x1c5)]((_0x3c7ca0,_0x23cde0)=>_0x23cde0['score']-_0x3c7ca0[_0x5c60da(0x14c)]),_0x43c414['slice'](0x0,limit);},async 'snapshot'(){return![];},async 'rebuild'(_0x163b53){const _0x19df8d=_0x156b;await this[_0x19df8d(0x16a)](_0x163b53);},async 'stop'(){},'count'(){const _0x4fb166=_0x156b;return _0x533777[_0x4fb166(0x131)];},'info'(){const _0x3bf44b=_0x156b;return{'algorithm':_0x3bf44b(0x1af),'count':_0x533777[_0x3bf44b(0x131)]};}};};function _0x3581a3(_0x356103,_0x53c180){const _0x12ecf2=_0x156b;let _0x47fa94=0x0,_0x816fe7=0x0,_0x1ff549=0x0;for(let _0x94fef1=0x0;_0x94fef1<_0x356103[_0x12ecf2(0x11e)];_0x94fef1++){_0x47fa94+=_0x356103[_0x94fef1]*_0x53c180[_0x94fef1],_0x816fe7+=_0x356103[_0x94fef1]*_0x356103[_0x94fef1],_0x1ff549+=_0x53c180[_0x94fef1]*_0x53c180[_0x94fef1];}const _0x1ca317=Math['sqrt'](_0x816fe7)*Math['sqrt'](_0x1ff549);return _0x1ca317===0x0?0x0:_0x47fa94/_0x1ca317;}return flat;}var writerLock,hasRequiredWriterLock;function requireWriterLock(){if(hasRequiredWriterLock)return writerLock;hasRequiredWriterLock=0x1;const _0xf32dc6=require$$0,_0x137cdf=require$$1,_0x16db22=require$$3;return writerLock=function _0x2a9b94(_0x1a6edc,{maxAgeMs:maxAgeMs=0x3a98,heartbeatMs:heartbeatMs=0x1388,onLost:onLost=null}={}){const _0x134f38=_0x156b,_0x5ebf0b=_0x137cdf['join'](_0x1a6edc,_0x134f38(0x1f0)),_0x45b3a4=_0x16db22[_0x134f38(0x1a2)](0x8)[_0x134f38(0x1e8)](_0x134f38(0x1a9));let _0x5b5f3c=![],_0x23a7c0=null;const _0x4b0d6b=()=>JSON[_0x134f38(0x14d)]({'pid':process[_0x134f38(0x181)],'token':_0x45b3a4,'at':Date[_0x134f38(0x1e4)]()});function _0x1c46f1(){const _0x1c7ab3=_0x134f38;try{return JSON[_0x1c7ab3(0x1f3)](_0xf32dc6[_0x1c7ab3(0x14a)](_0x5ebf0b,'utf8'));}catch(_0x53c9a6){return _0x53c9a6?.[_0x1c7ab3(0x1ad)]===_0x1c7ab3(0x13f)?null:{'unreadable':!![]};}}function _0x3786cb(){const _0x538221=_0x134f38;try{const _0xd9d1e4=_0xf32dc6[_0x538221(0x1cf)](_0x5ebf0b,'wx');try{_0xf32dc6['writeFileSync'](_0xd9d1e4,_0x4b0d6b());}finally{_0xf32dc6[_0x538221(0x177)](_0xd9d1e4);}return!![];}catch(_0x1558d3){if(_0x1558d3?.['code']===_0x538221(0x17c))return![];throw _0x1558d3;}}function _0x11e651(_0x2bc38a){const _0x502635=_0x134f38;if(!_0x2bc38a)return!![];if(_0x2bc38a[_0x502635(0x196)])return!![];return Date['now']()-(_0x2bc38a['at']??0x0)>=maxAgeMs;}function _0x39530c(){if(_0x23a7c0)clearInterval(_0x23a7c0);_0x23a7c0=null;}function _0x225ce0(){const _0xcdd14c=_0x134f38;_0x39530c(),_0x23a7c0=setInterval(()=>{const _0xe2823b=_0x156b,_0xf6bc48=_0x1c46f1();if(_0xf6bc48&&!_0xf6bc48[_0xe2823b(0x196)]&&_0xf6bc48[_0xe2823b(0x18b)]!==_0x45b3a4){_0x5b5f3c=![],_0x39530c();try{onLost?.();}catch{}return;}try{_0xf32dc6[_0xe2823b(0x1ea)](_0x5ebf0b,_0x4b0d6b());}catch{}},heartbeatMs),_0x23a7c0[_0xcdd14c(0x139)]?.();}function _0x434772(){const _0x48470e=_0x134f38,_0x1f8490=_0x1c46f1();return!!_0x1f8490&&_0x1f8490[_0x48470e(0x18b)]===_0x45b3a4;}return{'path':_0x5ebf0b,'token':_0x45b3a4,'acquire'(){const _0x3d4247=_0x1c46f1();if(_0x3d4247&&_0x3d4247['token']===_0x45b3a4){_0x5b5f3c=!![];if(!_0x23a7c0)_0x225ce0();return!![];}let _0x2cc1bb=_0x3786cb();if(!_0x2cc1bb&&_0x11e651(_0x1c46f1())){try{_0xf32dc6['unlinkSync'](_0x5ebf0b);}catch{}_0x2cc1bb=_0x3786cb();}if(_0x2cc1bb&&!_0x434772())_0x2cc1bb=![];_0x5b5f3c=_0x2cc1bb;if(_0x2cc1bb)_0x225ce0();return _0x2cc1bb;},'held'(){return _0x5b5f3c;},'isFree'(){const _0x38d87d=_0x1c46f1();if(_0x38d87d&&_0x38d87d['token']===_0x45b3a4)return![];return _0x11e651(_0x38d87d);},'release'(){const _0x538484=_0x134f38;_0x39530c();if(!_0x5b5f3c)return;_0x5b5f3c=![];if(_0x434772())try{_0xf32dc6[_0x538484(0x118)](_0x5ebf0b);}catch{}}};},writerLock;}var usearch,hasRequiredUsearch;function requireUsearch(){if(hasRequiredUsearch)return usearch;hasRequiredUsearch=0x1;const _0x58403e=require$$0,_0xee6ad7=requireSnapshotStore(),_0x96f7f6=requireLabelMap(),_0x3aa322=requireWriterLock(),{fingerprint:_0x38e09f,reconcileIndex:_0x5cf85f}=requireIndexConvergence(),_0xdff0d2=0x1;let _0x3711e9=null;function _0x2d3a0f(){const _0x5d7618=_0x156b;if(_0x3711e9)return _0x3711e9;try{return _0x3711e9=require(_0x5d7618(0x1ba)),_0x3711e9;}catch(_0x39bc3f){const _0x50c60d=new Error('usearch\x20algorithm\x20unavailable:\x20the\x20native\x20\x22usearch\x22\x20bindings\x20could\x20not\x20be\x20loaded\x20'+('for\x20Node\x20'+process[_0x5d7618(0x1b2)][_0x5d7618(0x1d7)]+_0x5d7618(0x162)+process[_0x5d7618(0x192)]+'/'+process[_0x5d7618(0x121)]+'.\x20')+'Install\x20compatible\x20bindings\x20or\x20use\x20algorithm\x20\x22flat\x22/\x22hnsw\x22\x20instead.\x20'+(_0x5d7618(0x1bf)+(_0x39bc3f?.['message']||String(_0x39bc3f))));_0x50c60d[_0x5d7618(0x1ad)]=_0x5d7618(0x1dd),_0x50c60d[_0x5d7618(0x1c7)]=_0x39bc3f;throw _0x50c60d;}}function _0x46f24c(_0x506908,_0x5a5a95){const _0x5dc3bd=_0x156b;switch(_0x506908){case'cosine':return _0x5a5a95[_0x5dc3bd(0x11a)]['Cos'];case'l2':return _0x5a5a95[_0x5dc3bd(0x11a)][_0x5dc3bd(0x183)];case'ip':return _0x5a5a95[_0x5dc3bd(0x11a)]['IP'];default:return _0x5a5a95['MetricKind'][_0x5dc3bd(0x1d1)];}}return usearch=function _0x23fa8d(_0xc61c51={},{dims:_0x153dce,dir:_0x554b58,fetchAll:fetchAll=null,onChange:onChange=null}={}){const _0x27c1eb=_0x156b,_0x405abf=_0x2d3a0f();if(!_0x153dce||_0x153dce<=0x0)throw new Error(_0x27c1eb(0x172));if(!_0x554b58)throw new Error(_0x27c1eb(0x1a6));const _0x358215={'metric':_0xc61c51['metric']??_0x27c1eb(0x11f),'connectivity':_0xc61c51[_0x27c1eb(0x13b)]??0x10,'expansionAdd':_0xc61c51[_0x27c1eb(0x191)]??0x80,'expansionSearch':_0xc61c51[_0x27c1eb(0x159)]??0x40,'snapshotEveryChanges':_0xc61c51[_0x27c1eb(0x1e2)]??0xc350,'snapshotMaxLagMs':_0xc61c51[_0x27c1eb(0x1b7)]??0x2710,'keepSnapshots':_0xc61c51['keepSnapshots']??0x2,'tmpMaxAgeMs':_0xc61c51[_0x27c1eb(0x126)]??0x6*0x36ee80,'heartbeatIntervalMs':_0xc61c51['heartbeatIntervalMs']??0x1388,'writerLockMaxAgeMs':_0xc61c51[_0x27c1eb(0x1cb)]??0x3a98,'viewRefreshMs':_0xc61c51['viewRefreshMs']??0x3e8},_0x5b50d2=new _0xee6ad7({'dir':_0x554b58,'keepSnapshots':_0x358215[_0x27c1eb(0x1d3)]}),_0x1666ce=_0x3aa322(_0x554b58,{'maxAgeMs':_0x358215['writerLockMaxAgeMs'],'heartbeatMs':_0x358215[_0x27c1eb(0x12c)],'onLost':()=>{const _0x2768b1=_0x27c1eb;_0x471fe3(_0x41867d)[_0x2768b1(0x1c8)](()=>{});}});let _0x14b643=new _0x96f7f6(),_0xf17d5b=null,_0x20bc86=0x0,_0x5b87a4=null,_0x397f57=![],_0x4fa648=![],_0x520412=null,_0x5d4741=0x0,_0x491fdd=null,_0x481b8b=0x0,_0x27fdcd=![],_0x16a231=Promise[_0x27c1eb(0x151)]();const _0x471fe3=_0x37a63b=>{const _0x1f0f37=_0x27c1eb,_0x1a441b=_0x16a231[_0x1f0f37(0x1eb)](_0x37a63b);return _0x16a231=_0x1a441b[_0x1f0f37(0x1c8)](()=>{}),_0x1a441b;},_0x4ad40f=()=>{try{onChange?.();}catch{}};function _0x45488c(){const _0x2a175d=_0x27c1eb;return new _0x405abf[(_0x2a175d(0x141))]({'dimensions':_0x153dce,'metric':_0x46f24c(_0x358215['metric'],_0x405abf),'quantization':_0x405abf['ScalarKind'][_0x2a175d(0x13d)],'connectivity':_0x358215[_0x2a175d(0x13b)],'expansion_add':_0x358215[_0x2a175d(0x191)],'expansion_search':_0x358215['expansionSearch'],'multi':![]});}function _0x34b098(_0x7f8ba){return _0x7f8ba instanceof Float32Array?_0x7f8ba:new Float32Array(_0x7f8ba);}function _0x1bc00f(){const _0x3866d8=_0x27c1eb;if(fetchAll)return fetchAll();if(_0x5b87a4)return _0x5b87a4();return Promise[_0x3866d8(0x151)](null);}function _0x5adb56(_0x5bfc80,_0xc60c28,_0x389c99){const _0x52acd5=_0x27c1eb,_0xe82613=_0x14b643[_0x52acd5(0x19a)](_0x5bfc80);if(_0xe82613!==undefined)try{_0xf17d5b[_0x52acd5(0x15e)](BigInt(_0xe82613));}catch{}const _0x3ab509=_0x14b643[_0x52acd5(0x147)](_0x5bfc80);_0xf17d5b[_0x52acd5(0x1b1)](BigInt(_0x3ab509),_0xc60c28),_0x14b643['setFingerprint'](_0x5bfc80,_0x389c99??_0x38e09f(_0xc60c28));}function _0x29d0d0(_0x2d34e4){const _0xad8c97=_0x27c1eb,_0x3fed10=_0x14b643[_0xad8c97(0x19a)](_0x2d34e4);if(_0x3fed10===undefined)return![];try{_0xf17d5b['remove'](BigInt(_0x3fed10));}catch{}return _0x14b643[_0xad8c97(0x198)](_0x2d34e4),!![];}function _0x268286(_0x572afa){const _0x4b1523=_0x27c1eb;_0x14b643=new _0x96f7f6(),_0xf17d5b=_0x45488c();for(const {key:_0xb90229,vector:_0x459d95}of _0x572afa??[]){if(!(_0x459d95 instanceof Float32Array)||_0x459d95[_0x4b1523(0x11e)]!==_0x153dce)continue;_0x5adb56(_0xb90229,_0x459d95);}_0x20bc86=0x0;}function _0x2398a1(){const _0x402fc4=_0x27c1eb;return Math[_0x402fc4(0x1c3)](Date[_0x402fc4(0x1e4)](),_0x5b50d2[_0x402fc4(0x1a8)]()+0x1);}function _0x508d2a(){if(_0x520412)clearTimeout(_0x520412);_0x520412=null;}function _0x83b289(){const _0x32a813=_0x27c1eb;if(!_0x358215['snapshotMaxLagMs']||_0x520412||!_0x4fa648||_0x20bc86<=0x0)return;const _0x2239ef=Math[_0x32a813(0x1c3)](_0x358215['snapshotMaxLagMs'],0xa*_0x5d4741);_0x520412=setTimeout(()=>{_0x520412=null,_0x471fe3(async()=>{if(_0x4fa648&&_0x20bc86>0x0)await _0x20e1ec();_0x83b289(),_0x4ad40f();})['catch'](()=>{});},_0x2239ef),_0x520412[_0x32a813(0x139)]?.();}async function _0x20e1ec(_0x122da2){const _0x22e516=_0x27c1eb;if(!_0xf17d5b)return![];const _0x525b66=_0x122da2??_0x2398a1(),_0x21ae1d=Date[_0x22e516(0x1e4)](),_0x8d9b2c=await _0x5b50d2['publishSnapshot'](_0x525b66,async _0x27afeb=>{const _0xbab5a6=_0x22e516;_0xf17d5b[_0xbab5a6(0x1f1)](_0x27afeb['index']),await _0x14b643[_0xbab5a6(0x15b)](_0x27afeb[_0xbab5a6(0x17a)]),_0x58403e['writeFileSync'](_0x27afeb[_0xbab5a6(0x148)],JSON[_0xbab5a6(0x14d)]({'manifestVersion':_0xdff0d2,'algorithm':_0xbab5a6(0x1ba),'dims':_0x153dce,'metric':_0x358215[_0xbab5a6(0x136)],'clock':_0x525b66,'snapshotAt':Date['now']()},null,0x2));},{'keep':_0x358215['keepSnapshots']});return _0x5d4741=Date[_0x22e516(0x1e4)]()-_0x21ae1d,_0x8d9b2c?.[_0x22e516(0x1e7)]&&(_0x20bc86=0x0,_0x508d2a()),_0x8d9b2c?.[_0x22e516(0x1e7)]??![];}function _0x4f3774(){const _0x491a77=_0x27c1eb;_0x20bc86++;if(_0x20bc86>=_0x358215[_0x491a77(0x1e2)])return _0x20e1ec();return _0x83b289(),null;}async function _0x24eb54(){const _0x465b91=_0x27c1eb,_0x2b894c=_0x5b50d2[_0x465b91(0x1d2)]()||_0x5b50d2[_0x465b91(0x1ab)]();if(!_0x2b894c)return null;let _0xf6986c,_0x5b8834=![];try{await _0x5b50d2[_0x465b91(0x14b)](_0x2b894c,async _0xff4950=>{const _0x1312c5=_0x465b91;_0xf6986c=JSON[_0x1312c5(0x1f3)](_0x58403e[_0x1312c5(0x14a)](_0xff4950[_0x1312c5(0x148)],_0x1312c5(0x189)));if(_0xf6986c['manifestVersion']!==_0xdff0d2||_0xf6986c[_0x1312c5(0x127)]!==_0x1312c5(0x1ba)||_0xf6986c['dims']!==_0x153dce||_0xf6986c['metric']!==_0x358215[_0x1312c5(0x136)]){_0xf6986c=null;return;}const _0xcec90f=new _0x96f7f6();await _0xcec90f[_0x1312c5(0x180)](_0xff4950['labels']);const _0x2671c8=_0x45488c();_0x2671c8[_0x1312c5(0x16a)](_0xff4950[_0x1312c5(0x11c)]),_0x14b643=_0xcec90f,_0xf17d5b=_0x2671c8,_0x5b8834=!![];});}catch{return null;}return _0x5b8834?_0xf6986c?.[_0x465b91(0x12f)]??0x0:null;}async function _0x57372c(_0x1044bd){const _0x91151b=_0x27c1eb;_0x491fdd=null;const _0x3580af=await _0x24eb54();if(_0x3580af!=null){_0x20bc86=0x0;if(_0x1044bd){if(!_0x14b643[_0x91151b(0x1c4)])return _0x268286(_0x1044bd),await _0x20e1ec(),null;const _0x5b34bd=_0x5cf85f(_0x14b643,_0x1044bd,_0x153dce,{'upsert':_0x5adb56,'remove':_0x29d0d0}),_0x334587=_0x5b34bd['added']+_0x5b34bd[_0x91151b(0x19b)]+_0x5b34bd[_0x91151b(0x132)];_0x334587>0x0&&(_0x20bc86+=_0x334587,await _0x20e1ec());}return _0x3580af;}_0x268286(_0x1044bd??[]);if(_0xf17d5b[_0x91151b(0x131)]()>0x0)await _0x20e1ec();return null;}async function _0x5846d1(){_0x4fa648=!![],await _0x57372c(await _0x1bc00f());}async function _0x41867d(){const _0x2c0f21=_0x27c1eb;if(!_0x4fa648)return;_0x4fa648=![],_0x508d2a(),_0x20bc86=0x0;const _0x316a31=_0x5b50d2[_0x2c0f21(0x1d2)]()||_0x5b50d2[_0x2c0f21(0x1ab)]();await _0x17656b(_0x316a31),_0x4ad40f();}async function _0x17656b(_0x2ca50b){const _0x59fecb=_0x27c1eb;if(!_0x2ca50b)return![];let _0x7b7400=![];try{await _0x5b50d2[_0x59fecb(0x14b)](_0x2ca50b,async _0x4e9e2a=>{const _0x57778b=_0x59fecb,_0x511c81=JSON[_0x57778b(0x1f3)](_0x58403e[_0x57778b(0x14a)](_0x4e9e2a['state'],_0x57778b(0x189)));if(_0x511c81['manifestVersion']!==_0xdff0d2||_0x511c81[_0x57778b(0x127)]!=='usearch'||_0x511c81['dims']!==_0x153dce||_0x511c81[_0x57778b(0x136)]!==_0x358215['metric'])return;const _0x28a28e=new _0x96f7f6();await _0x28a28e['loadFrom'](_0x4e9e2a[_0x57778b(0x17a)]);const _0x13b4d0=_0x45488c();_0x13b4d0[_0x57778b(0x19c)](_0x4e9e2a[_0x57778b(0x11c)]),_0xf17d5b=_0x13b4d0,_0x14b643=_0x28a28e,_0x491fdd=_0x2ca50b,_0x7b7400=!![];});}catch{}return _0x7b7400;}function _0x38bcbe(){const _0x45e84a=_0x27c1eb,_0x4615d0=Date[_0x45e84a(0x1e4)]();if(_0x4615d0-_0x481b8b<_0x358215[_0x45e84a(0x179)])return;_0x481b8b=_0x4615d0;if(_0x27fdcd)return;if(_0x1666ce[_0x45e84a(0x182)]()){_0x27fdcd=!![],_0x471fe3(async()=>{!_0x4fa648&&_0x397f57&&_0x1666ce['acquire']()&&(await _0x5846d1(),_0x4ad40f());})[_0x45e84a(0x1c8)](()=>{})['finally'](()=>{_0x27fdcd=![];});return;}const _0x391d15=_0x5b50d2['readCurrentId']()||_0x5b50d2[_0x45e84a(0x1ab)]();if(!_0x391d15||_0x391d15===_0x491fdd)return;_0x27fdcd=!![],_0x471fe3(async()=>{if(!_0x4fa648&&await _0x17656b(_0x391d15))_0x4ad40f();})[_0x45e84a(0x1c8)](()=>{})[_0x45e84a(0x150)](()=>{_0x27fdcd=![];});}return{async 'load'(_0xf7d3dc){return _0x471fe3(async()=>{const _0x2082e2=_0x156b;_0x5b50d2[_0x2082e2(0x175)]({'maxAgeMs':_0x358215[_0x2082e2(0x126)]}),_0x5b87a4=_0xf7d3dc??null,_0x4fa648=_0x1666ce[_0x2082e2(0x1a7)]();let _0x17b765=null;if(_0x4fa648)_0x17b765=await _0x57372c(_0xf7d3dc?await _0xf7d3dc():null);else{const _0xe20a0e=_0x5b50d2['readCurrentId']()||_0x5b50d2[_0x2082e2(0x1ab)]();await _0x17656b(_0xe20a0e);}return _0x397f57=!![],_0x17b765;});},async 'add'(_0x301167,_0x264b06,_0xc7954d){return _0x471fe3(async()=>{const _0x54f977=_0x156b;if(!_0x397f57)return;const _0x39b4ab=_0x34b098(_0x264b06);if(!_0x4fa648){if(!_0x1666ce['acquire']())return;await _0x5846d1();}if(!_0xf17d5b)return;const _0x420cc6=_0x38e09f(_0x39b4ab);if(_0x14b643[_0x54f977(0x138)](_0x301167)===_0x420cc6)return;_0x5adb56(_0x301167,_0x39b4ab,_0x420cc6),await _0x4f3774();});},async 'remove'(_0x4097de){return _0x471fe3(async()=>{const _0x2e505d=_0x156b;if(!_0x397f57)return;if(!_0x4fa648){if(!_0x1666ce[_0x2e505d(0x1a7)]())return;await _0x5846d1();}if(!_0xf17d5b)return;if(_0x29d0d0(_0x4097de))await _0x4f3774();});},'search'(_0x3239be,{limit:limit=0xa}={}){const _0xe7db22=_0x27c1eb;if(!_0x4fa648&&_0x397f57)_0x38bcbe();if(!_0xf17d5b)return[];const _0x218d65=_0xf17d5b[_0xe7db22(0x131)]();if(_0x218d65===0x0)return[];const _0x499d31=Math[_0xe7db22(0x173)](limit,_0x218d65),_0x65abaa=_0xf17d5b[_0xe7db22(0x16d)](_0x34b098(_0x3239be),_0x499d31,0x0),_0x21adcf=[],_0x536eb5=_0x65abaa['keys'],_0x404a05=_0x65abaa[_0xe7db22(0x154)];for(let _0x3074e1=0x0;_0x3074e1<_0x536eb5[_0xe7db22(0x11e)];_0x3074e1++){const _0xc58b7a=_0x536eb5[_0x3074e1];if(_0xc58b7a===0xffffffffffffffffn)continue;const _0x859320=Number(_0xc58b7a),_0x25c627=_0x14b643[_0xe7db22(0x13e)](_0x859320);if(!_0x25c627)continue;const _0x1c68d3=_0x404a05[_0x3074e1];let _0x41cb2c;if(_0x358215['metric']===_0xe7db22(0x11f))_0x41cb2c=Math[_0xe7db22(0x1c3)](0x0,0x1-_0x1c68d3);else{if(_0x358215[_0xe7db22(0x136)]==='ip')_0x41cb2c=-_0x1c68d3;else _0x41cb2c=0x1/(0x1+_0x1c68d3);}_0x21adcf[_0xe7db22(0x1f4)]({'key':_0x25c627,'score':_0x41cb2c});}return _0x21adcf;},async 'snapshot'(_0x29a533){return _0x471fe3(()=>_0x4fa648?_0x20e1ec(_0x29a533??undefined):![]);},async 'rebuild'(_0x52c50c){return _0x471fe3(async()=>{const _0x474a94=_0x156b;if(_0x52c50c!=null)_0x5b87a4=_0x52c50c;if(!_0x4fa648){if(!_0x1666ce[_0x474a94(0x1a7)]())return;_0x4fa648=!![];}const _0x145c13=_0x52c50c?await _0x52c50c():await _0x1bc00f();_0x268286(_0x145c13??[]),_0x397f57=!![],await _0x20e1ec();});},async 'stop'(){return _0x471fe3(async()=>{const _0x2e582d=_0x156b;_0x508d2a();if(_0x4fa648){if(_0x20bc86>0x0||!_0x5b50d2[_0x2e582d(0x1d2)]())await _0x20e1ec();_0x1666ce['release']();}_0x4fa648=![],_0x397f57=![];});},'count'(){return _0x14b643['size']();},'info'(){const _0x48b874=_0x27c1eb;return{'algorithm':_0x48b874(0x1ba),'role':_0x4fa648?_0x48b874(0x167):_0x48b874(0x17e),'metric':_0x358215[_0x48b874(0x136)],'connectivity':_0x358215[_0x48b874(0x13b)],'expansionAdd':_0x358215[_0x48b874(0x191)],'expansionSearch':_0x358215[_0x48b874(0x159)],'snapshotEveryChanges':_0x358215[_0x48b874(0x1e2)],'snapshotMaxLagMs':_0x358215['snapshotMaxLagMs'],'count':_0x14b643[_0x48b874(0x131)](),'size':_0xf17d5b?.[_0x48b874(0x131)]?.()??0x0,'capacity':_0xf17d5b?.['capacity']?.()??0x0,'changesSince':_0x4fa648?_0x20bc86:null,'viewedSnapshot':_0x491fdd??null,'snapshotDir':_0x554b58,'latestSnapshot':_0x5b50d2[_0x48b874(0x1d2)]()??null};}};},usearch;}var hasRequiredAlgorithmWorkerThread;function requireAlgorithmWorkerThread(){const _0x2fa091=_0x4eed99;if(hasRequiredAlgorithmWorkerThread)return algorithmWorkerThread$1;hasRequiredAlgorithmWorkerThread=0x1;const {parentPort:_0x184aff,workerData:_0x3ab348}=require$$0$1,{algorithmName:_0x278f83,algorithmConfig:_0x16a9df,dims:_0x19959b,dir:_0x74caf8}=_0x3ab348;let _0x44f1f0=0x1;const _0x142207=new Map();function _0x2fbfc3(){const _0x1b3806=_0x44f1f0++;return new Promise((_0x22171c,_0x2d6a65)=>{const _0x5b8478=_0x156b;_0x142207[_0x5b8478(0x169)](_0x1b3806,{'resolve':_0x22171c,'reject':_0x2d6a65}),_0x184aff[_0x5b8478(0x1e9)]({'op':_0x5b8478(0x1d0),'fid':_0x1b3806});});}const _0x1e6feb={'dims':_0x19959b,'dir':_0x74caf8,'fetchAll':_0x2fbfc3,'onChange':()=>_0x2390ba()};let _0x19d43f;if(_0x278f83===_0x2fa091(0x171))_0x19d43f=requireHnsw()(_0x16a9df,_0x1e6feb);else{if(_0x278f83===_0x2fa091(0x1af))_0x19d43f=requireFlat()(_0x16a9df,_0x1e6feb);else{if(_0x278f83===_0x2fa091(0x1ba))_0x19d43f=requireUsearch()(_0x16a9df,_0x1e6feb);else throw new Error('Unknown\x20algorithm:\x20\x22'+_0x278f83+'\x22');}}function _0x2390ba(){const _0x2e2e32=_0x2fa091;try{_0x184aff['postMessage']({'op':_0x2e2e32(0x1e5),'count':_0x19d43f[_0x2e2e32(0x178)](),'info':_0x19d43f[_0x2e2e32(0x165)](),'memory':process[_0x2e2e32(0x1dc)]()});}catch{}}function _0x14fb2b(_0x3a6846){const _0xdd410b=_0x2fa091;return(_0x3a6846||[])['map'](_0x27b979=>({'key':_0x27b979['key'],'vector':_0x27b979['vector']instanceof Float32Array?_0x27b979[_0xdd410b(0x15a)]:new Float32Array(_0x27b979[_0xdd410b(0x15a)])}));}return _0x184aff['on']('message',async _0x419bab=>{const _0x38a59c=_0x2fa091;if(_0x419bab['op']===_0x38a59c(0x1ef)){const _0x2d7b06=_0x142207[_0x38a59c(0x1b5)](_0x419bab[_0x38a59c(0x1c9)]);if(!_0x2d7b06)return;_0x142207[_0x38a59c(0x170)](_0x419bab[_0x38a59c(0x1c9)]);if(_0x419bab[_0x38a59c(0x19e)])_0x2d7b06[_0x38a59c(0x1e3)](new Error(_0x419bab['error']));else _0x2d7b06[_0x38a59c(0x151)](_0x14fb2b(_0x419bab[_0x38a59c(0x122)]));return;}const {id:_0x2414df,op:_0x455166,args:_0x11f6d1}=_0x419bab;try{let _0x59c231;switch(_0x455166){case'load':{_0x59c231=await _0x19d43f[_0x38a59c(0x16a)](_0x11f6d1['hasRows']?_0x2fbfc3:null),_0x2390ba();break;}case _0x38a59c(0x1b1):{const _0xf16e41=_0x11f6d1[_0x38a59c(0x15a)]instanceof Float32Array?_0x11f6d1[_0x38a59c(0x15a)]:new Float32Array(_0x11f6d1['vector']);await _0x19d43f[_0x38a59c(0x1b1)](_0x11f6d1['key'],_0xf16e41,_0x11f6d1['clock']??undefined),_0x2390ba(),_0x59c231=null;break;}case _0x38a59c(0x15e):{await _0x19d43f[_0x38a59c(0x15e)](_0x11f6d1[_0x38a59c(0x12b)]),_0x2390ba(),_0x59c231=null;break;}case _0x38a59c(0x16d):{const _0x3037b5=_0x11f6d1['queryVec']instanceof Float32Array?_0x11f6d1['queryVec']:new Float32Array(_0x11f6d1['queryVec']);_0x59c231=_0x19d43f['search'](_0x3037b5,_0x11f6d1[_0x38a59c(0x18e)]||{});break;}case _0x38a59c(0x1e6):{_0x59c231=await _0x19d43f[_0x38a59c(0x1e6)](_0x11f6d1['clock']),_0x2390ba();break;}case'rebuild':{const _0x5be3d4=_0x14fb2b(_0x11f6d1[_0x38a59c(0x122)]);await _0x19d43f[_0x38a59c(0x16c)](async()=>_0x5be3d4),_0x2390ba(),_0x59c231=null;break;}case _0x38a59c(0x157):{await _0x19d43f[_0x38a59c(0x157)](),_0x2390ba(),_0x59c231=null;break;}case _0x38a59c(0x178):{_0x59c231=_0x19d43f[_0x38a59c(0x178)]();break;}case _0x38a59c(0x165):{_0x59c231=_0x19d43f[_0x38a59c(0x165)]();break;}default:throw new Error(_0x38a59c(0x1c0)+_0x455166+'\x22');}_0x184aff['postMessage']({'id':_0x2414df,'result':_0x59c231});}catch(_0x5647e7){_0x184aff[_0x38a59c(0x1e9)]({'id':_0x2414df,'error':{'message':_0x5647e7?.['message']||String(_0x5647e7),'code':_0x5647e7?.[_0x38a59c(0x1ad)]}});}}),_0x184aff[_0x2fa091(0x1e9)]({'op':_0x2fa091(0x123)}),algorithmWorkerThread$1;}var algorithmWorkerThreadExports=requireAlgorithmWorkerThread(),algorithmWorkerThread=getDefaultExportFromCjs(algorithmWorkerThreadExports);module['exports']=algorithmWorkerThread;
1
+ 'use strict';const _0x31c441=_0x2d84;(function(_0x8aa4bb,_0x3ce597){const _0x4834b3=_0x2d84,_0x7a0cc3=_0x8aa4bb();while(!![]){try{const _0x2df0ca=parseInt(_0x4834b3(0x196))/0x1+parseInt(_0x4834b3(0x20f))/0x2*(-parseInt(_0x4834b3(0x16e))/0x3)+parseInt(_0x4834b3(0x176))/0x4+-parseInt(_0x4834b3(0x19b))/0x5*(-parseInt(_0x4834b3(0x208))/0x6)+parseInt(_0x4834b3(0x162))/0x7+-parseInt(_0x4834b3(0x1b9))/0x8+-parseInt(_0x4834b3(0x1a9))/0x9*(parseInt(_0x4834b3(0x18d))/0xa);if(_0x2df0ca===_0x3ce597)break;else _0x7a0cc3['push'](_0x7a0cc3['shift']());}catch(_0xae0633){_0x7a0cc3['push'](_0x7a0cc3['shift']());}}}(_0x1f86,0x94049));var require$$0$1=require(_0x31c441(0x165)),require$$0=require('fs'),require$$1=require('path'),require$$2=require('os'),require$$3=require(_0x31c441(0x169));function _0x2d84(_0x4bff9c,_0x5304ac){_0x4bff9c=_0x4bff9c-0x162;const _0x1f86ad=_0x1f86();let _0x2d8461=_0x1f86ad[_0x4bff9c];return _0x2d8461;}function getDefaultExportFromCjs(_0x2d144f){const _0x56e563=_0x31c441;return _0x2d144f&&_0x2d144f[_0x56e563(0x1ca)]&&Object[_0x56e563(0x1cd)][_0x56e563(0x199)][_0x56e563(0x182)](_0x2d144f,_0x56e563(0x173))?_0x2d144f[_0x56e563(0x173)]:_0x2d144f;}var algorithmWorkerThread$1={},snapshotStore,hasRequiredSnapshotStore;function requireSnapshotStore(){const _0x5a627c=_0x31c441;if(hasRequiredSnapshotStore)return snapshotStore;hasRequiredSnapshotStore=0x1;const _0x284fa=require$$0,_0x5397ba=require$$1,_0x5b0cdb=require$$2,_0x4d7da0=require$$3;function _0x22d13b(){const _0x424e1f=_0x2d84;return Date[_0x424e1f(0x1ff)]();}function _0x3bf671(_0x579fea){const _0x36c2c6=_0x2d84;try{return _0x284fa[_0x36c2c6(0x1dd)](_0x579fea);}catch{return![];}}function _0xd8b77(_0x21ae9c){const _0x36ad3d=_0x2d84;try{return _0x284fa[_0x36ad3d(0x188)](_0x21ae9c,_0x36ad3d(0x179));}catch{return null;}}function _0x425259(_0x363690,_0x14d938){const _0x4b839d=_0x2d84,_0x174e90=_0x363690+_0x4b839d(0x164)+_0x4d7da0['randomBytes'](0x6)[_0x4b839d(0x16f)](_0x4b839d(0x20d));_0x284fa['writeFileSync'](_0x174e90,_0x14d938),_0x284fa[_0x4b839d(0x1c8)](_0x174e90,_0x363690);}function _0x29df22(_0x33b9fa,_0x16f5ff=0x10){const _0x427e5e=_0x2d84,_0x15ae65=String(Math[_0x427e5e(0x22d)](0x0,Math[_0x427e5e(0x191)](_0x33b9fa||0x0)));return _0x15ae65['length']>=_0x16f5ff?_0x15ae65:'0'[_0x427e5e(0x17e)](_0x16f5ff-_0x15ae65[_0x427e5e(0x21f)])+_0x15ae65;}return snapshotStore=class _0x4042e7{constructor({dir:_0x19e8f9,keepSnapshots:keepSnapshots=0x3,log:log=null}={}){const _0x2a8ab3=_0x2d84;if(!_0x19e8f9)throw new Error(_0x2a8ab3(0x16b));this[_0x2a8ab3(0x22a)]=_0x19e8f9,this['snapshotsDir']=_0x5397ba[_0x2a8ab3(0x20c)](_0x19e8f9,_0x2a8ab3(0x1d1)),this['currentPath']=_0x5397ba[_0x2a8ab3(0x20c)](_0x19e8f9,_0x2a8ab3(0x1af)),this[_0x2a8ab3(0x204)]=_0x5397ba[_0x2a8ab3(0x20c)](_0x19e8f9,_0x2a8ab3(0x1fc)),this[_0x2a8ab3(0x238)]=keepSnapshots,this[_0x2a8ab3(0x1d3)]=log,_0x284fa[_0x2a8ab3(0x1c6)](this[_0x2a8ab3(0x22a)],{'recursive':!![]}),_0x284fa[_0x2a8ab3(0x1c6)](this[_0x2a8ab3(0x21d)],{'recursive':!![]});}[_0x5a627c(0x1f8)](_0x4a81ca){const _0x34c984=_0x5a627c;return _0x5397ba['join'](this[_0x34c984(0x21d)],_0x4a81ca);}[_0x5a627c(0x23b)](_0x2cbfeb){const _0x981f2=_0x5a627c,_0x3948c4=this[_0x981f2(0x1f8)](_0x2cbfeb);return{'dir':_0x3948c4,'index':_0x5397ba[_0x981f2(0x20c)](_0x3948c4,_0x981f2(0x198)),'labels':_0x5397ba[_0x981f2(0x20c)](_0x3948c4,_0x981f2(0x207)),'state':_0x5397ba[_0x981f2(0x20c)](_0x3948c4,_0x981f2(0x18e))};}[_0x5a627c(0x1da)](){const _0x4b122e=_0x5a627c;if(!_0x3bf671(this['currentPath']))return null;const _0x50541b=_0xd8b77(this['currentPath']);if(!_0x50541b)return null;const _0x3bd471=String(_0x50541b)[_0x4b122e(0x1aa)]();return _0x3bd471||null;}['readCurrentClock'](){const _0xf08db0=_0x5a627c,_0xe8c0b8=this['readCurrentId']();if(!_0xe8c0b8)return 0x0;const _0x526566=Number(_0xe8c0b8);return Number[_0xf08db0(0x232)](_0x526566)?_0x526566:0x0;}[_0x5a627c(0x1b8)](){const _0x10410c=_0x5a627c;try{return _0x284fa[_0x10410c(0x1bd)](this[_0x10410c(0x21d)],{'withFileTypes':!![]})[_0x10410c(0x1ac)](_0x3d5538=>_0x3d5538[_0x10410c(0x1cb)]())[_0x10410c(0x1bb)](_0x1a3d89=>_0x1a3d89[_0x10410c(0x233)])['filter'](_0x5d08c3=>!_0x5d08c3[_0x10410c(0x219)](_0x10410c(0x164)))[_0x10410c(0x1ac)](_0x425ec5=>!_0x425ec5[_0x10410c(0x219)](_0x10410c(0x16d)))[_0x10410c(0x23a)]();}catch{return[];}}[_0x5a627c(0x1c4)](){const _0x41bf4d=_0x5a627c,_0x4fe705=this['readCurrentId']();if(_0x4fe705)return _0x4fe705;const _0x3a5f24=this[_0x41bf4d(0x1b8)]();if(!_0x3a5f24['length'])return null;return _0x3a5f24[_0x3a5f24[_0x41bf4d(0x21f)]-0x1];}['cleanupTmpDirs']({maxAgeMs:maxAgeMs=0x6*0x36ee80}={}){const _0x524283=_0x5a627c;let _0x1b310a;try{_0x1b310a=_0x284fa[_0x524283(0x1bd)](this['snapshotsDir'],{'withFileTypes':!![]});}catch{return;}const _0x3336be=_0x22d13b()-maxAgeMs;for(const _0x3dbdc0 of _0x1b310a){if(!_0x3dbdc0[_0x524283(0x1cb)]())continue;const _0x29993d=_0x3dbdc0['name'];if(!_0x29993d[_0x524283(0x219)]('.tmp-')&&!_0x29993d[_0x524283(0x219)](_0x524283(0x16d)))continue;const _0x17b5f0=_0x5397ba[_0x524283(0x20c)](this[_0x524283(0x21d)],_0x29993d);try{const _0x439c98=_0x284fa[_0x524283(0x200)](_0x17b5f0);if(_0x439c98[_0x524283(0x1ad)]>_0x3336be)continue;}catch{}try{_0x284fa['rmSync'](_0x17b5f0,{'recursive':!![],'force':!![]});}catch{}}}[_0x5a627c(0x1e4)]({keep:keep=null}={}){const _0x26c439=_0x5a627c,_0x39771c=Math[_0x26c439(0x22d)](0x1,Math[_0x26c439(0x191)](keep??this[_0x26c439(0x238)]??0x3)),_0x51880d=this[_0x26c439(0x1b8)]();if(_0x51880d[_0x26c439(0x21f)]<=_0x39771c)return;const _0x55193e=this[_0x26c439(0x1da)](),_0x516b21=_0x51880d[_0x26c439(0x23f)](0x0,Math[_0x26c439(0x22d)](0x0,_0x51880d['length']-_0x39771c));for(const _0x59958c of _0x516b21){if(_0x55193e&&_0x59958c===_0x55193e)continue;const _0x204615=this[_0x26c439(0x1f8)](_0x59958c);try{_0x284fa[_0x26c439(0x218)](_0x204615,{'recursive':!![],'force':!![]});}catch{}}}async[_0x5a627c(0x183)](_0x86a72,_0x1effa8){const _0x125fd6=_0x5a627c;if(!_0x86a72)throw new Error('snapshot\x20id\x20required');const _0x51f2bd=this[_0x125fd6(0x23b)](_0x86a72);if(!_0x3bf671(_0x51f2bd[_0x125fd6(0x211)])||!_0x3bf671(_0x51f2bd[_0x125fd6(0x19f)])||!_0x3bf671(_0x51f2bd[_0x125fd6(0x178)]))throw new Error(_0x125fd6(0x229)+_0x86a72);const _0xf24f51=await _0x1effa8(_0x51f2bd);return _0xf24f51||{};}async[_0x5a627c(0x1a1)](_0x343ef0,_0x4ccdf4,{keep:keep=null,lockTimeoutMs:lockTimeoutMs=0x0,staleLockMaxAgeMs:staleLockMaxAgeMs=0xea60}={}){const _0x3f51fe=_0x5a627c,_0x9c40db=Number(_0x343ef0);if(!Number[_0x3f51fe(0x232)](_0x9c40db)||_0x9c40db<0x0)throw new Error(_0x3f51fe(0x22f));const _0x21c3d5=_0x29df22(_0x9c40db),_0x52539c=this[_0x3f51fe(0x1f8)](_0x21c3d5),_0x5f389d=_0x5397ba[_0x3f51fe(0x20c)](this[_0x3f51fe(0x21d)],_0x3f51fe(0x164)+_0x21c3d5+'-'+_0x4d7da0[_0x3f51fe(0x236)](0x6)[_0x3f51fe(0x16f)](_0x3f51fe(0x20d)));_0x284fa[_0x3f51fe(0x1c6)](_0x5f389d,{'recursive':!![]});const _0x1708c9={'dir':_0x5f389d,'index':_0x5397ba[_0x3f51fe(0x20c)](_0x5f389d,_0x3f51fe(0x198)),'labels':_0x5397ba['join'](_0x5f389d,_0x3f51fe(0x207)),'state':_0x5397ba['join'](_0x5f389d,_0x3f51fe(0x18e))};await _0x4ccdf4(_0x1708c9,{'id':_0x21c3d5,'clock':_0x9c40db});const _0x4606a9=JSON['stringify']({'pid':process[_0x3f51fe(0x1db)],'host':_0x5b0cdb[_0x3f51fe(0x1f3)](),'at':_0x22d13b()}),_0xcdc217=_0x22d13b();let _0x168909=null;const _0xc17cab=()=>{const _0x4de0fd=_0x3f51fe;try{const _0x57a58c=JSON['parse'](_0x284fa[_0x4de0fd(0x188)](this[_0x4de0fd(0x204)],_0x4de0fd(0x179)));if(_0x57a58c['at']&&_0x22d13b()-_0x57a58c['at']>staleLockMaxAgeMs){const _0x1854b2=_0x22d13b()-_0x57a58c['at'],_0x25fc51='Breaking\x20stale\x20snapshot\x20lock\x20(age:\x20'+Math[_0x4de0fd(0x1e5)](_0x1854b2/0x3e8)+_0x4de0fd(0x1d6)+_0x57a58c[_0x4de0fd(0x1db)]+_0x4de0fd(0x1ab)+_0x57a58c[_0x4de0fd(0x172)]+_0x4de0fd(0x201)+_0x4de0fd(0x1ea);this[_0x4de0fd(0x1d3)]?.[_0x4de0fd(0x185)]?this['log'][_0x4de0fd(0x185)](_0x25fc51):console[_0x4de0fd(0x185)](_0x4de0fd(0x235),_0x25fc51);try{_0x284fa['unlinkSync'](this[_0x4de0fd(0x204)]);}catch{}return!![];}}catch{try{_0x284fa[_0x4de0fd(0x18a)](this[_0x4de0fd(0x204)]);}catch{}}return![];},_0x463da9=()=>{const _0x79b200=_0x3f51fe;try{return _0x168909=_0x284fa[_0x79b200(0x192)](this[_0x79b200(0x204)],'wx'),_0x284fa['writeFileSync'](_0x168909,_0x4606a9),!![];}catch(_0x35aa1f){if(_0x35aa1f&&_0x35aa1f[_0x79b200(0x1e3)]===_0x79b200(0x1c2))return![];throw _0x35aa1f;}};if(!_0x463da9()){_0xc17cab(),_0x463da9();if(_0x168909==null&&lockTimeoutMs>0x0)while(_0x22d13b()-_0xcdc217<lockTimeoutMs){await new Promise(_0x5f046a=>setTimeout(_0x5f046a,0x19));if(_0x463da9())break;_0xc17cab();}}if(_0x168909==null){try{_0x284fa['rmSync'](_0x5f389d,{'recursive':!![],'force':!![]});}catch{}return{'published':![],'reason':'lock_busy'};}try{const _0x103664=this[_0x3f51fe(0x1a4)]();if(_0x9c40db<=_0x103664){try{_0x284fa[_0x3f51fe(0x218)](_0x5f389d,{'recursive':!![],'force':!![]});}catch{}return{'published':![],'reason':_0x3f51fe(0x18b),'currentClock':_0x103664};}if(!_0x3bf671(_0x52539c))_0x284fa[_0x3f51fe(0x1c8)](_0x5f389d,_0x52539c);else try{_0x284fa[_0x3f51fe(0x218)](_0x5f389d,{'recursive':!![],'force':!![]});}catch{}return _0x425259(this[_0x3f51fe(0x227)],_0x21c3d5+'\x0a'),this['prune']({'keep':keep}),{'published':!![],'currentClock':_0x9c40db};}finally{try{_0x284fa[_0x3f51fe(0x240)](_0x168909);}catch{}try{_0x284fa[_0x3f51fe(0x18a)](this['lockPath']);}catch{}}}},snapshotStore;}var labelMap,hasRequiredLabelMap;function requireLabelMap(){const _0x2f931d=_0x31c441;if(hasRequiredLabelMap)return labelMap;hasRequiredLabelMap=0x1;const _0x28b42e=require$$0;class _0x1bf8d0{constructor(){const _0x455d65=_0x2d84;this[_0x455d65(0x1a2)]=new Map(),this[_0x455d65(0x215)]=new Map(),this[_0x455d65(0x1f7)]=0x0,this[_0x455d65(0x22b)]=0x0,this[_0x455d65(0x203)]=new Map(),this[_0x455d65(0x242)]=!![];}async[_0x2f931d(0x1e0)](){const _0x58871e=_0x2f931d;this['keyToLabel']=new Map(),this[_0x58871e(0x215)]=new Map(),this[_0x58871e(0x203)]=new Map(),this[_0x58871e(0x242)]=!![],this['nextLabel']=0x0,this['_tombstoneCount']=0x0;}async[_0x2f931d(0x210)](_0x456cc9){const _0x353c6b=_0x2f931d;if(!_0x456cc9||!_0x28b42e[_0x353c6b(0x1dd)](_0x456cc9))return await this[_0x353c6b(0x1e0)](),!![];let _0x4ac263;try{_0x4ac263=_0x28b42e[_0x353c6b(0x188)](_0x456cc9,'utf8');}catch{return await this['reset'](),!![];}let _0x5adfbe;try{_0x5adfbe=JSON['parse'](_0x4ac263);}catch{return await this[_0x353c6b(0x1e0)](),!![];}const _0x48ae15=Array[_0x353c6b(0x21e)](_0x5adfbe?.[_0x353c6b(0x1a3)])?_0x5adfbe['entries']:[],_0x4f2dea=Number[_0x353c6b(0x187)](_0x5adfbe?.['nextLabel'])?_0x5adfbe[_0x353c6b(0x1f7)]:0x0,_0x4fe8f4=new Map(),_0x1c7d93=new Map(),_0x781fc=new Map(),_0x25538d=_0x5adfbe?.[_0x353c6b(0x1d4)]>=0x2;let _0xe7ded7=-0x1;for(const _0x40621f of _0x48ae15){if(!Array[_0x353c6b(0x21e)](_0x40621f)||_0x40621f[_0x353c6b(0x21f)]<0x2)continue;const _0x5bd4b4=Number(_0x40621f[0x0]),_0x424668=String(_0x40621f[0x1]??'');if(!Number[_0x353c6b(0x187)](_0x5bd4b4)||_0x5bd4b4<0x0)continue;if(!_0x424668)continue;_0x4fe8f4[_0x353c6b(0x1ba)](_0x424668,_0x5bd4b4),_0x1c7d93[_0x353c6b(0x1ba)](_0x5bd4b4,_0x424668);if(_0x25538d&&typeof _0x40621f[0x2]==='number')_0x781fc[_0x353c6b(0x1ba)](_0x424668,_0x40621f[0x2]);if(_0x5bd4b4>_0xe7ded7)_0xe7ded7=_0x5bd4b4;}return this[_0x353c6b(0x1a2)]=_0x4fe8f4,this[_0x353c6b(0x215)]=_0x1c7d93,this[_0x353c6b(0x203)]=_0x781fc,this[_0x353c6b(0x242)]=_0x25538d,this[_0x353c6b(0x1f7)]=Math[_0x353c6b(0x22d)](_0x4f2dea,_0xe7ded7+0x1,0x0),this[_0x353c6b(0x22b)]=0x0,!![];}[_0x2f931d(0x1a0)](_0x5ec151){const _0x3fbd7c=_0x2f931d;return this[_0x3fbd7c(0x1a2)][_0x3fbd7c(0x19d)](_0x5ec151);}[_0x2f931d(0x1ec)](_0x1bf2b7){const _0x286075=_0x2f931d;let _0x2845f0=this[_0x286075(0x1a2)][_0x286075(0x19d)](_0x1bf2b7);if(_0x2845f0!==undefined)return _0x2845f0;return _0x2845f0=this[_0x286075(0x1f7)]++,this['keyToLabel']['set'](_0x1bf2b7,_0x2845f0),this[_0x286075(0x215)][_0x286075(0x1ba)](_0x2845f0,_0x1bf2b7),_0x2845f0;}[_0x2f931d(0x1d0)](_0xa4f0a7,_0x1962b3){const _0x214c34=_0x2f931d;if(_0x1962b3==null)this[_0x214c34(0x203)][_0x214c34(0x16c)](_0xa4f0a7);else this[_0x214c34(0x203)][_0x214c34(0x1ba)](_0xa4f0a7,_0x1962b3);}[_0x2f931d(0x1a8)](_0x3a34a7){const _0xdfdf34=_0x2f931d;return this[_0xdfdf34(0x203)][_0xdfdf34(0x19d)](_0x3a34a7);}[_0x2f931d(0x1eb)](){const _0xecdc20=_0x2f931d;return this[_0xecdc20(0x1a2)][_0xecdc20(0x1eb)]();}[_0x2f931d(0x221)](_0x39616f){const _0x356526=_0x2f931d,_0x2f1e05=this['keyToLabel'][_0x356526(0x19d)](_0x39616f);if(_0x2f1e05===undefined)return;this[_0x356526(0x203)]['delete'](_0x39616f),this[_0x356526(0x1a2)][_0x356526(0x16c)](_0x39616f),this[_0x356526(0x215)][_0x356526(0x16c)](_0x2f1e05),this[_0x356526(0x22b)]++;}[_0x2f931d(0x170)](_0x3010dd){const _0x502a10=_0x2f931d;return this[_0x502a10(0x215)][_0x502a10(0x19d)](_0x3010dd)??null;}[_0x2f931d(0x1d2)](){const _0x3352a8=_0x2f931d;return this[_0x3352a8(0x1a2)][_0x3352a8(0x1d2)];}[_0x2f931d(0x20e)](){return this['_tombstoneCount'];}async[_0x2f931d(0x184)](_0x38d983){const _0x5e79f5=_0x2f931d,_0x2ddc43=_0x38d983+_0x5e79f5(0x1fa),_0x17597d=[];for(const [_0x69f573,_0x2b68e5]of this[_0x5e79f5(0x215)][_0x5e79f5(0x1a3)]()){const _0x46f1c2=this[_0x5e79f5(0x203)]['get'](_0x2b68e5);_0x17597d[_0x5e79f5(0x1b6)](_0x46f1c2==null?[_0x69f573,_0x2b68e5]:[_0x69f573,_0x2b68e5,_0x46f1c2]);}_0x17597d[_0x5e79f5(0x23a)]((_0xe6e5c5,_0x3f1b9e)=>_0xe6e5c5[0x0]-_0x3f1b9e[0x0]);const _0xf4255={'version':0x2,'nextLabel':this[_0x5e79f5(0x1f7)],'entries':_0x17597d};_0x28b42e[_0x5e79f5(0x1f9)](_0x2ddc43,JSON[_0x5e79f5(0x174)](_0xf4255)),_0x28b42e[_0x5e79f5(0x1c8)](_0x2ddc43,_0x38d983);}}return labelMap=_0x1bf8d0,labelMap;}function _0x1f86(){const _0x28332c=['key','remove','repeat','initIndex','cleanupTmpDirs','stop','call','loadSnapshot','snapshotTo','warn','readIndexSync','isInteger','readFileSync','flat','unlinkSync','stale','has','66950HAITDA','state.json','F32','hnsw\x20algorithm\x20requires\x20dims\x20>\x200','trunc','openSync','count','writerLockMaxAgeMs','buffer','1027802xmHBzM','usearch\x20algorithm\x20requires\x20dir\x20for\x20snapshot\x20storage','index.hnsw','hasOwnProperty','rebuild','10pvOEGF','writer','get','memoryUsage','labels','labelForExisting','publishSnapshot','keyToLabel','entries','readCurrentClock','vectors','HierarchicalNSW','Unknown\x20op:\x20\x22','fingerprintOf','2745mDEGBA','trim',',\x20host:\x20','filter','mtimeMs','Unknown\x20algorithm:\x20\x22','CURRENT','heartbeatIntervalMs','Install\x20compatible\x20bindings\x20or\x20use\x20algorithm\x20\x22flat\x22\x20instead.\x20','HNSW_BINDINGS_UNAVAILABLE','markDelete','exports','efConstruction','push','growFactor','listSnapshotIds','142912JRywTp','set','map','unreadable','readdirSync','addPoint','tmpMaxAgeMs','fid','ScalarKind','EEXIST','added','latestSnapshotId','unref','mkdirSync','connectivity','renameSync','clock','__esModule','isDirectory','searchKnn','prototype','save','viewRefreshMs','setFingerprint','snapshots','size','log','version','usearch\x20algorithm\x20unavailable:\x20the\x20native\x20\x22usearch\x22\x20bindings\x20could\x20not\x20be\x20loaded\x20','s,\x20pid:\x20','min','getMaxElements','algorithm','readCurrentId','pid','Index','existsSync','search','metric','reset','HNSW\x20algorithm\x20unavailable:\x20the\x20native\x20\x22hnswlib-node\x22\x20bindings\x20could\x20not\x20be\x20loaded\x20','snapshotMaxLagMs','code','prune','round','removed','fetchAllResult','setEf','parse','This\x20is\x20risky\x20on\x20slow\x20disks\x20or\x20overloaded\x20machines.\x20Consider\x20increasing\x20staleLockMaxAgeMs\x20if\x20this\x20happens\x20frequently.','keys','labelForEphemeral','then','changed','L2sq','ready','from','catch','hostname','distances','queryVec','cosine','nextLabel','_snapshotDir','writeFileSync','.tmp','manifestVersion','SNAPSHOT.LOCK','expansionSearch','token','now','statSync',').\x20','hnsw','keyToFp','lockPath','clear','imul','labels.json','1998012NFgHmI','acquire','expansionAdd','sync','join','hex','tombstoneCount','3716VmVUzR','loadFrom','index','Original\x20error:\x20','arch','sqrt','labelToKey','hnswlib-node','Install\x20compatible\x20bindings\x20or\x20use\x20algorithm\x20\x22flat\x22/\x22hnsw\x22\x20instead.\x20','rmSync','startsWith','efSearch','resolve','capacity','snapshotsDir','isArray','length','postMessage','tombstone','error','add','Cos','MetricKind','info','currentPath','cause','snapshot\x20incomplete:\x20','dir','_tombstoneCount','snapshotEveryChanges','max','published','candidateClock\x20must\x20be\x20finite\x20>=\x200','snapshot','dims','isFinite','name','usearch','[SnapshotStore]','randomBytes','reject','keepSnapshots','resizeIndex','sort','_snapshotPaths','load','platform','view','slice','closeSync','node','hasFingerprints','4871594ApfACz','vector','.tmp-','worker_threads','maxElements','fetchAll','message','crypto','ENOENT','SnapshotStore\x20requires\x20dir','delete','_tmp-','1095zVcftO','toString','keyForLabel','for\x20Node\x20','host','default','stringify','versions','3818168uNbgTk','score','state','utf8','isFree','writeIndexSync'];_0x1f86=function(){return _0x28332c;};return _0x1f86();}var indexConvergence,hasRequiredIndexConvergence;function requireIndexConvergence(){if(hasRequiredIndexConvergence)return indexConvergence;hasRequiredIndexConvergence=0x1;function _0x251f2c(_0x4020b1){const _0x155005=_0x2d84,_0x3d6e72=new Uint32Array(_0x4020b1[_0x155005(0x195)],_0x4020b1['byteOffset'],_0x4020b1[_0x155005(0x21f)]);let _0xee6a18=0x811c9dc5,_0x1d9d43=0x9747b28c;for(let _0xf3feca=0x0;_0xf3feca<_0x3d6e72[_0x155005(0x21f)];_0xf3feca++){const _0x4c1564=_0x3d6e72[_0xf3feca];_0xee6a18=Math[_0x155005(0x206)](_0xee6a18^_0x4c1564,0x1000193)>>>0x0;let _0x310520=Math[_0x155005(0x206)](_0x4c1564,0xcc9e2d51);_0x310520=_0x310520<<0xf|_0x310520>>>0x11,_0x1d9d43=Math[_0x155005(0x206)](_0x1d9d43^Math[_0x155005(0x206)](_0x310520,0x1b873593),0x5)+0xe6546b64,_0x1d9d43>>>=0x0;}return _0x1d9d43=Math[_0x155005(0x206)](_0x1d9d43^_0x1d9d43>>>0x10,0x85ebca6b)>>>0x0,(_0xee6a18>>>0x0)*0x100000+(_0x1d9d43&0xfffff);}function _0x2f12fb(_0x3920e0,_0x207b09,_0x476e5c,{upsert:_0x190562,remove:_0x1d288a}){const _0x500091=_0x2d84,_0x3f24d3=new Set();let _0x22c909=0x0,_0x36de1b=0x0,_0x501138=0x0;for(const {key:_0x55e2cb,vector:_0x43d32e}of _0x207b09){if(!(_0x43d32e instanceof Float32Array)||_0x43d32e['length']!==_0x476e5c)continue;_0x3f24d3[_0x500091(0x223)](_0x55e2cb);const _0x4a62ea=_0x251f2c(_0x43d32e),_0x31a226=_0x3920e0['labelForExisting'](_0x55e2cb)!==undefined;if(_0x31a226&&_0x3920e0[_0x500091(0x1a8)](_0x55e2cb)===_0x4a62ea)continue;_0x190562(_0x55e2cb,_0x43d32e,_0x4a62ea);if(_0x31a226)_0x36de1b++;else _0x22c909++;}for(const _0x291c16 of[..._0x3920e0[_0x500091(0x1eb)]()]){if(_0x3f24d3[_0x500091(0x18c)](_0x291c16))continue;_0x1d288a(_0x291c16),_0x501138++;}return{'added':_0x22c909,'changed':_0x36de1b,'removed':_0x501138};}return indexConvergence={'fingerprint':_0x251f2c,'reconcileIndex':_0x2f12fb},indexConvergence;}var hnsw,hasRequiredHnsw;function requireHnsw(){if(hasRequiredHnsw)return hnsw;hasRequiredHnsw=0x1;const _0x1fb427=requireSnapshotStore(),_0x444cf1=requireLabelMap(),{fingerprint:_0xd485ae,reconcileIndex:_0x281f25}=requireIndexConvergence(),_0x358c59=0x1;let _0x418d43=null;function _0x3959f2(){const _0x276e7b=_0x2d84;if(_0x418d43)return _0x418d43;try{return _0x418d43=require(_0x276e7b(0x216)),_0x418d43;}catch(_0x43a772){const _0x1affec=new Error(_0x276e7b(0x1e1)+(_0x276e7b(0x171)+process[_0x276e7b(0x175)][_0x276e7b(0x241)]+'\x20on\x20'+process[_0x276e7b(0x23d)]+'/'+process[_0x276e7b(0x213)]+'.\x20')+_0x276e7b(0x1b1)+(_0x276e7b(0x212)+(_0x43a772?.[_0x276e7b(0x168)]||String(_0x43a772))));_0x1affec[_0x276e7b(0x1e3)]=_0x276e7b(0x1b2),_0x1affec[_0x276e7b(0x228)]=_0x43a772;throw _0x1affec;}}return hnsw=function _0x3c2782(_0x36cb1d={},{dims:_0x16a73f,dir:_0x347adb}){const _0x2d4734=_0x2d84,_0x200658=_0x3959f2();if(!_0x16a73f||_0x16a73f<=0x0)throw new Error(_0x2d4734(0x190));if(!_0x347adb)throw new Error('hnsw\x20algorithm\x20requires\x20dir\x20for\x20snapshot\x20storage');const _0x28d43f={'metric':_0x36cb1d[_0x2d4734(0x1df)]??_0x2d4734(0x1f6),'M':_0x36cb1d['M']??0x10,'efConstruction':_0x36cb1d[_0x2d4734(0x1b5)]??0xc8,'efSearch':_0x36cb1d[_0x2d4734(0x21a)]??0x40,'maxElements':_0x36cb1d[_0x2d4734(0x166)]??0x400,'growFactor':_0x36cb1d[_0x2d4734(0x1b7)]??0x2,'snapshotEveryChanges':_0x36cb1d[_0x2d4734(0x22c)]??0xc350,'keepSnapshots':_0x36cb1d[_0x2d4734(0x238)]??0x2,'tmpMaxAgeMs':_0x36cb1d[_0x2d4734(0x1bf)]??0x6*0x36ee80},_0x2dbad3=new _0x1fb427({'dir':_0x347adb,'keepSnapshots':_0x28d43f['keepSnapshots']}),_0x4d24b4=new _0x444cf1();let _0x79e3e7=null,_0x481dcd=0x0,_0x60e80e=null,_0x4752c2=Promise[_0x2d4734(0x21b)]();const _0x8a94b9=_0x3c9496=>{const _0x2c9c7f=_0x2d4734,_0x4b935c=_0x4752c2[_0x2c9c7f(0x1ed)](_0x3c9496);return _0x4752c2=_0x4b935c[_0x2c9c7f(0x1f2)](()=>{}),_0x4b935c;};async function _0x914392(_0x46255c){const _0xd8571d=_0x2d4734;await _0x4d24b4['reset'](),_0x46255c=_0x46255c??[];const _0x2c4950=Math[_0xd8571d(0x22d)](_0x28d43f[_0xd8571d(0x166)],Math['ceil'](_0x46255c[_0xd8571d(0x21f)]*(_0x28d43f[_0xd8571d(0x1b7)]||1.2)),0x1);_0x79e3e7=new _0x200658[(_0xd8571d(0x1a6))](_0x28d43f[_0xd8571d(0x1df)],_0x16a73f),_0x79e3e7[_0xd8571d(0x17f)]({'maxElements':_0x2c4950,'efConstruction':_0x28d43f[_0xd8571d(0x1b5)],'M':_0x28d43f['M']});for(const {key:_0x4be879,vector:_0x1a2640}of _0x46255c){if(!(_0x1a2640 instanceof Float32Array)||_0x1a2640['length']!==_0x16a73f)continue;_0x19d79f(_0x4be879,_0x1a2640);}_0x79e3e7[_0xd8571d(0x1e8)](_0x28d43f[_0xd8571d(0x21a)]),_0x481dcd=0x0;}async function _0x54dea5(_0x5199b){return _0x914392(_0x5199b?await _0x5199b():[]);}function _0x5dcaec(){const _0x19402e=_0x2d4734;if(_0x79e3e7['getCurrentCount']()<_0x79e3e7['getMaxElements']())return;const _0x4a0421=Math['ceil'](_0x79e3e7[_0x19402e(0x1d8)]()*(_0x28d43f[_0x19402e(0x1b7)]||0x2));_0x79e3e7[_0x19402e(0x239)](_0x4a0421),_0x28d43f['maxElements']=_0x4a0421;}function _0x19d79f(_0x3fc6cb,_0x1b62e2,_0x3c1c00){const _0x162d83=_0x2d4734,_0x374c82=_0x4d24b4[_0x162d83(0x1ec)](_0x3fc6cb);try{_0x79e3e7[_0x162d83(0x1b3)](_0x374c82);}catch{}_0x5dcaec(),_0x79e3e7[_0x162d83(0x1be)](Array[_0x162d83(0x1f1)](_0x1b62e2),_0x374c82),_0x4d24b4[_0x162d83(0x1d0)](_0x3fc6cb,_0x3c1c00??_0xd485ae(_0x1b62e2));}function _0x20903c(_0x31d992){const _0x5cd496=_0x2d4734,_0x16ca1d=_0x4d24b4[_0x5cd496(0x1a0)](_0x31d992);if(_0x16ca1d===undefined)return![];try{_0x79e3e7[_0x5cd496(0x1b3)](_0x16ca1d);}catch{}return _0x4d24b4['tombstone'](_0x31d992),!![];}function _0x31b616(){const _0x33f0d0=_0x2d4734;return Math[_0x33f0d0(0x22d)](Date['now'](),_0x2dbad3['readCurrentClock']()+0x1);}async function _0x412b9c(_0x300bf8){const _0x16b521=_0x2d4734;if(!_0x79e3e7||!_0x300bf8)return![];const _0x3e54e6=await _0x2dbad3[_0x16b521(0x1a1)](_0x300bf8,async _0x4e8039=>{const _0x167c25=_0x16b521;_0x79e3e7[_0x167c25(0x17b)](_0x4e8039[_0x167c25(0x211)]),await _0x4d24b4[_0x167c25(0x184)](_0x4e8039[_0x167c25(0x19f)]);const _0xe2d72c=require$$0;_0xe2d72c[_0x167c25(0x1f9)](_0x4e8039[_0x167c25(0x178)],JSON[_0x167c25(0x174)]({'manifestVersion':_0x358c59,'dims':_0x16a73f,'metric':_0x28d43f[_0x167c25(0x1df)],'clock':_0x300bf8,'snapshotAt':Date[_0x167c25(0x1ff)]()},null,0x2));},{'keep':_0x28d43f['keepSnapshots']});if(_0x3e54e6?.[_0x16b521(0x22e)])_0x481dcd=0x0;return _0x3e54e6?.[_0x16b521(0x22e)]??![];}async function _0x4affc9(){const _0x13a19b=_0x2d4734,_0x46b98e=_0x2dbad3[_0x13a19b(0x1da)]()||_0x2dbad3['latestSnapshotId']();if(!_0x46b98e)return null;let _0x477672,_0x54ac6f=![];return await _0x2dbad3[_0x13a19b(0x183)](_0x46b98e,async _0x267754=>{const _0x55c7b2=_0x13a19b,_0x128324=require$$0;_0x477672=JSON[_0x55c7b2(0x1e9)](_0x128324['readFileSync'](_0x267754[_0x55c7b2(0x178)],'utf8'));if(_0x477672[_0x55c7b2(0x1fb)]!==_0x358c59||_0x477672['dims']!==_0x16a73f||_0x477672[_0x55c7b2(0x1df)]!==_0x28d43f[_0x55c7b2(0x1df)]){_0x477672=null;return;}await _0x4d24b4[_0x55c7b2(0x210)](_0x267754['labels']),_0x79e3e7=new _0x200658[(_0x55c7b2(0x1a6))](_0x28d43f['metric'],_0x16a73f),_0x79e3e7[_0x55c7b2(0x186)](_0x267754[_0x55c7b2(0x211)]),_0x79e3e7[_0x55c7b2(0x1e8)](_0x28d43f[_0x55c7b2(0x21a)]),_0x54ac6f=!![];}),_0x54ac6f?_0x477672?.[_0x13a19b(0x1c9)]??0x0:null;}return{async 'load'(_0x1033f6){return _0x8a94b9(async()=>{const _0x38646d=_0x2d84;_0x2dbad3[_0x38646d(0x180)]({'maxAgeMs':_0x28d43f['tmpMaxAgeMs']}),_0x60e80e=_0x1033f6??null;const _0x3a09fa=await _0x4affc9(),_0x63d59f=_0x1033f6?await _0x1033f6():null;if(_0x3a09fa!=null){if(_0x63d59f){if(!_0x4d24b4[_0x38646d(0x242)])return await _0x914392(_0x63d59f),null;const _0x59dfa4=_0x281f25(_0x4d24b4,_0x63d59f,_0x16a73f,{'upsert':_0x19d79f,'remove':_0x20903c});_0x481dcd+=_0x59dfa4[_0x38646d(0x1c3)]+_0x59dfa4[_0x38646d(0x1ee)]+_0x59dfa4[_0x38646d(0x1e6)];}return _0x3a09fa;}return await _0x914392(_0x63d59f),null;});},async 'add'(_0x1a6801,_0x375721,_0x3f9193){return _0x8a94b9(async()=>{const _0xe30912=_0x2d84;if(!_0x79e3e7)return;const _0x48d3b5=_0x375721 instanceof Float32Array?_0x375721:new Float32Array(_0x375721),_0x438152=_0xd485ae(_0x48d3b5);if(_0x4d24b4[_0xe30912(0x1a8)](_0x1a6801)===_0x438152)return;_0x19d79f(_0x1a6801,_0x48d3b5,_0x438152),_0x481dcd++,_0x481dcd>=_0x28d43f['snapshotEveryChanges']&&await _0x412b9c(_0x31b616());});},async 'remove'(_0x41e6ff){return _0x8a94b9(async()=>{if(!_0x79e3e7)return;if(_0x20903c(_0x41e6ff))_0x481dcd++;});},'search'(_0x36cca3,{limit:limit=0xa,efSearch:_0x7afc31}={}){const _0x5e74e9=_0x2d4734;if(!_0x79e3e7)return[];if(Number[_0x5e74e9(0x187)](_0x7afc31))_0x79e3e7[_0x5e74e9(0x1e8)](_0x7afc31);const _0x1ebebe=Math[_0x5e74e9(0x1d7)](limit,_0x79e3e7['getCurrentCount']()||0x1),{neighbors:_0x21fa2e,distances:_0x28526d}=_0x79e3e7[_0x5e74e9(0x1cc)](Array[_0x5e74e9(0x1f1)](_0x36cca3),_0x1ebebe),_0x5c927a=[];for(let _0x3d87e0=0x0;_0x3d87e0<_0x21fa2e[_0x5e74e9(0x21f)];_0x3d87e0++){const _0x36e0f8=_0x4d24b4['keyForLabel'](_0x21fa2e[_0x3d87e0]);if(!_0x36e0f8)continue;const _0x390105=_0x28d43f[_0x5e74e9(0x1df)]===_0x5e74e9(0x1f6)?Math[_0x5e74e9(0x22d)](0x0,0x1-_0x28526d[_0x3d87e0]):0x1/(0x1+_0x28526d[_0x3d87e0]);_0x5c927a[_0x5e74e9(0x1b6)]({'key':_0x36e0f8,'score':_0x390105});}return _0x5c927a;},async 'snapshot'(_0x21d39e){return _0x8a94b9(()=>_0x412b9c(_0x21d39e??_0x31b616()));},async 'rebuild'(_0x1566d5){return _0x8a94b9(()=>{if(_0x1566d5!=null)_0x60e80e=_0x1566d5;return _0x54dea5(_0x1566d5??_0x60e80e);});},async 'stop'(){const _0x59a1e8=_0x2d4734;return _0x8a94b9(()=>_0x481dcd>0x0||!_0x2dbad3[_0x59a1e8(0x1da)]()?_0x412b9c(_0x31b616()):![]);},'count'(){return _0x4d24b4['size']();},'info'(){const _0x2611ae=_0x2d4734;return{'algorithm':_0x2611ae(0x202),'metric':_0x28d43f[_0x2611ae(0x1df)],'M':_0x28d43f['M'],'efConstruction':_0x28d43f[_0x2611ae(0x1b5)],'efSearch':_0x28d43f['efSearch'],'maxElements':_0x79e3e7?.[_0x2611ae(0x1d8)]()??_0x28d43f[_0x2611ae(0x166)],'count':_0x4d24b4['size'](),'changesSince':_0x481dcd,'snapshotDir':_0x347adb,'latestSnapshot':_0x2dbad3[_0x2611ae(0x1da)]()??null};}};},hnsw;}var flat,hasRequiredFlat;function requireFlat(){if(hasRequiredFlat)return flat;hasRequiredFlat=0x1,flat=function _0x16f875(_0x2edc8c={}){const _0x5cef76=new Map();return{async 'load'(_0x31f29b){const _0xb4b4b5=_0x2d84;_0x5cef76[_0xb4b4b5(0x205)]();if(_0x31f29b)for(const {key:_0x4f4158,vector:_0x33c97b}of await _0x31f29b()){_0x5cef76[_0xb4b4b5(0x1ba)](_0x4f4158,_0x33c97b);}},async 'add'(_0x5daafc,_0x1f6850,_0x838ddf){const _0xee981b=_0x2d84;_0x5cef76[_0xee981b(0x1ba)](_0x5daafc,_0x1f6850);},async 'remove'(_0x30f7cc){const _0x464815=_0x2d84;_0x5cef76[_0x464815(0x16c)](_0x30f7cc);},'search'(_0x21dce8,{limit:limit=0xa,threshold:threshold=0x0}={}){const _0x25f799=_0x2d84,_0x5a9546=[];for(const [_0x29a4c5,_0x5decd5]of _0x5cef76){const _0x11be6b=_0x15f014(_0x21dce8,_0x5decd5);if(_0x11be6b>=threshold)_0x5a9546['push']({'key':_0x29a4c5,'score':_0x11be6b});}return _0x5a9546['sort']((_0x5eb0e7,_0x2bc023)=>_0x2bc023[_0x25f799(0x177)]-_0x5eb0e7['score']),_0x5a9546[_0x25f799(0x23f)](0x0,limit);},async 'snapshot'(){return![];},async 'rebuild'(_0x36c4e5){const _0xed4006=_0x2d84;await this[_0xed4006(0x23c)](_0x36c4e5);},async 'stop'(){},'count'(){const _0x5c4da1=_0x2d84;return _0x5cef76[_0x5c4da1(0x1d2)];},'info'(){const _0x504eb3=_0x2d84;return{'algorithm':_0x504eb3(0x189),'count':_0x5cef76[_0x504eb3(0x1d2)]};}};};function _0x15f014(_0x1e568a,_0x449640){const _0x1b164d=_0x2d84;let _0x2dd384=0x0,_0x50430a=0x0,_0x663a19=0x0;for(let _0x10e6d8=0x0;_0x10e6d8<_0x1e568a[_0x1b164d(0x21f)];_0x10e6d8++){_0x2dd384+=_0x1e568a[_0x10e6d8]*_0x449640[_0x10e6d8],_0x50430a+=_0x1e568a[_0x10e6d8]*_0x1e568a[_0x10e6d8],_0x663a19+=_0x449640[_0x10e6d8]*_0x449640[_0x10e6d8];}const _0x5ed06a=Math[_0x1b164d(0x214)](_0x50430a)*Math[_0x1b164d(0x214)](_0x663a19);return _0x5ed06a===0x0?0x0:_0x2dd384/_0x5ed06a;}return flat;}var writerLock,hasRequiredWriterLock;function requireWriterLock(){if(hasRequiredWriterLock)return writerLock;hasRequiredWriterLock=0x1;const _0xe50081=require$$0,_0xad5568=require$$1,_0x44dc2c=require$$3;return writerLock=function _0xc2395d(_0x506a19,{maxAgeMs:maxAgeMs=0x3a98,heartbeatMs:heartbeatMs=0x1388,onLost:onLost=null}={}){const _0x4312c3=_0x2d84,_0x203edd=_0xad5568[_0x4312c3(0x20c)](_0x506a19,'WRITER.LOCK'),_0x41065f=_0x44dc2c['randomBytes'](0x8)[_0x4312c3(0x16f)](_0x4312c3(0x20d));let _0x41dc27=![],_0x3f94ca=null;const _0x1b7370=()=>JSON[_0x4312c3(0x174)]({'pid':process[_0x4312c3(0x1db)],'token':_0x41065f,'at':Date['now']()});function _0x185a18(){const _0x16b2b7=_0x4312c3;try{return JSON[_0x16b2b7(0x1e9)](_0xe50081[_0x16b2b7(0x188)](_0x203edd,_0x16b2b7(0x179)));}catch(_0xb48cf){return _0xb48cf?.[_0x16b2b7(0x1e3)]===_0x16b2b7(0x16a)?null:{'unreadable':!![]};}}function _0x592a66(){const _0x10398b=_0x4312c3;try{const _0xc6c378=_0xe50081['openSync'](_0x203edd,'wx');try{_0xe50081['writeFileSync'](_0xc6c378,_0x1b7370());}finally{_0xe50081[_0x10398b(0x240)](_0xc6c378);}return!![];}catch(_0x4f67f6){if(_0x4f67f6?.[_0x10398b(0x1e3)]===_0x10398b(0x1c2))return![];throw _0x4f67f6;}}function _0x35fd65(_0x1930af){const _0x101617=_0x4312c3;if(!_0x1930af)return!![];if(_0x1930af[_0x101617(0x1bc)])return!![];return Date[_0x101617(0x1ff)]()-(_0x1930af['at']??0x0)>=maxAgeMs;}function _0x2cff93(){if(_0x3f94ca)clearInterval(_0x3f94ca);_0x3f94ca=null;}function _0x2a116f(){_0x2cff93(),_0x3f94ca=setInterval(()=>{const _0x4790c8=_0x2d84,_0x4fad04=_0x185a18();if(_0x4fad04&&!_0x4fad04[_0x4790c8(0x1bc)]&&_0x4fad04['token']!==_0x41065f){_0x41dc27=![],_0x2cff93();try{onLost?.();}catch{}return;}try{_0xe50081[_0x4790c8(0x1f9)](_0x203edd,_0x1b7370());}catch{}},heartbeatMs),_0x3f94ca['unref']?.();}function _0x29cc34(){const _0x18655f=_0x185a18();return!!_0x18655f&&_0x18655f['token']===_0x41065f;}return{'path':_0x203edd,'token':_0x41065f,'acquire'(){const _0x28fc98=_0x4312c3,_0x3a4b63=_0x185a18();if(_0x3a4b63&&_0x3a4b63[_0x28fc98(0x1fe)]===_0x41065f){_0x41dc27=!![];if(!_0x3f94ca)_0x2a116f();return!![];}let _0x58c108=_0x592a66();if(!_0x58c108&&_0x35fd65(_0x185a18())){try{_0xe50081[_0x28fc98(0x18a)](_0x203edd);}catch{}_0x58c108=_0x592a66();}if(_0x58c108&&!_0x29cc34())_0x58c108=![];_0x41dc27=_0x58c108;if(_0x58c108)_0x2a116f();return _0x58c108;},'held'(){return _0x41dc27;},'isFree'(){const _0x119b01=_0x4312c3,_0x2a26f6=_0x185a18();if(_0x2a26f6&&_0x2a26f6[_0x119b01(0x1fe)]===_0x41065f)return![];return _0x35fd65(_0x2a26f6);},'release'(){const _0x2577f6=_0x4312c3;_0x2cff93();if(!_0x41dc27)return;_0x41dc27=![];if(_0x29cc34())try{_0xe50081[_0x2577f6(0x18a)](_0x203edd);}catch{}}};},writerLock;}var usearch,hasRequiredUsearch;function requireUsearch(){if(hasRequiredUsearch)return usearch;hasRequiredUsearch=0x1;const _0x3f7825=require$$0,_0x155c3a=requireSnapshotStore(),_0x111234=requireLabelMap(),_0x5d580d=requireWriterLock(),{fingerprint:_0x5bc402,reconcileIndex:_0x1506e5}=requireIndexConvergence(),_0x5c9c9c=0x1;let _0x3555d2=null;function _0x5c9970(){const _0x497c9b=_0x2d84;if(_0x3555d2)return _0x3555d2;try{return _0x3555d2=require(_0x497c9b(0x234)),_0x3555d2;}catch(_0x2e24ed){const _0x205425=new Error(_0x497c9b(0x1d5)+(_0x497c9b(0x171)+process['versions'][_0x497c9b(0x241)]+'\x20on\x20'+process[_0x497c9b(0x23d)]+'/'+process[_0x497c9b(0x213)]+'.\x20')+_0x497c9b(0x217)+(_0x497c9b(0x212)+(_0x2e24ed?.[_0x497c9b(0x168)]||String(_0x2e24ed))));_0x205425['code']='USEARCH_BINDINGS_UNAVAILABLE',_0x205425[_0x497c9b(0x228)]=_0x2e24ed;throw _0x205425;}}function _0x171c90(_0x5cc736,_0x172679){const _0xce8d25=_0x2d84;switch(_0x5cc736){case _0xce8d25(0x1f6):return _0x172679[_0xce8d25(0x225)][_0xce8d25(0x224)];case'l2':return _0x172679['MetricKind'][_0xce8d25(0x1ef)];case'ip':return _0x172679['MetricKind']['IP'];default:return _0x172679[_0xce8d25(0x225)][_0xce8d25(0x224)];}}return usearch=function _0x3152eb(_0xb59072={},{dims:_0x32473d,dir:_0x3ea71d,fetchAll:fetchAll=null,onChange:onChange=null}={}){const _0x52ce53=_0x2d84,_0x3c9bdc=_0x5c9970();if(!_0x32473d||_0x32473d<=0x0)throw new Error('usearch\x20algorithm\x20requires\x20dims\x20>\x200');if(!_0x3ea71d)throw new Error(_0x52ce53(0x197));const _0x417b8f={'metric':_0xb59072['metric']??_0x52ce53(0x1f6),'connectivity':_0xb59072[_0x52ce53(0x1c7)]??0x10,'expansionAdd':_0xb59072[_0x52ce53(0x20a)]??0x80,'expansionSearch':_0xb59072[_0x52ce53(0x1fd)]??0x40,'snapshotEveryChanges':_0xb59072[_0x52ce53(0x22c)]??0xc350,'snapshotMaxLagMs':_0xb59072[_0x52ce53(0x1e2)]??0x2710,'keepSnapshots':_0xb59072['keepSnapshots']??0x2,'tmpMaxAgeMs':_0xb59072[_0x52ce53(0x1bf)]??0x6*0x36ee80,'heartbeatIntervalMs':_0xb59072['heartbeatIntervalMs']??0x1388,'writerLockMaxAgeMs':_0xb59072[_0x52ce53(0x194)]??0x3a98,'viewRefreshMs':_0xb59072[_0x52ce53(0x1cf)]??0x3e8},_0xdd6b29=new _0x155c3a({'dir':_0x3ea71d,'keepSnapshots':_0x417b8f[_0x52ce53(0x238)]}),_0x175485=_0x5d580d(_0x3ea71d,{'maxAgeMs':_0x417b8f['writerLockMaxAgeMs'],'heartbeatMs':_0x417b8f[_0x52ce53(0x1b0)],'onLost':()=>{const _0x1c996b=_0x52ce53;_0x351773(_0xf55ec9)[_0x1c996b(0x1f2)](()=>{});}});let _0x7d20a7=new _0x111234(),_0x543918=null,_0x149e2b=0x0,_0x18a34e=null,_0x30b4c7=![],_0x5274bf=![],_0x11b35b=null,_0x43a35d=0x0,_0x137947=null,_0x1adb6a=0x0,_0x19729d=![],_0x53ca0a=Promise[_0x52ce53(0x21b)]();const _0x351773=_0x22156a=>{const _0x1891b5=_0x52ce53,_0x2df6bf=_0x53ca0a[_0x1891b5(0x1ed)](_0x22156a);return _0x53ca0a=_0x2df6bf['catch'](()=>{}),_0x2df6bf;},_0x4954b3=()=>{try{onChange?.();}catch{}};function _0x3d1af6(){const _0xe61000=_0x52ce53;return new _0x3c9bdc[(_0xe61000(0x1dc))]({'dimensions':_0x32473d,'metric':_0x171c90(_0x417b8f[_0xe61000(0x1df)],_0x3c9bdc),'quantization':_0x3c9bdc[_0xe61000(0x1c1)][_0xe61000(0x18f)],'connectivity':_0x417b8f[_0xe61000(0x1c7)],'expansion_add':_0x417b8f[_0xe61000(0x20a)],'expansion_search':_0x417b8f['expansionSearch'],'multi':![]});}function _0x3a6fb7(_0x1864d0){return _0x1864d0 instanceof Float32Array?_0x1864d0:new Float32Array(_0x1864d0);}function _0x3a5ac2(){const _0x3b5828=_0x52ce53;if(fetchAll)return fetchAll();if(_0x18a34e)return _0x18a34e();return Promise[_0x3b5828(0x21b)](null);}function _0x5d8e9b(_0x1ff191,_0x77177e,_0x2a2725){const _0x2f33b0=_0x52ce53,_0x1ca197=_0x7d20a7['labelForExisting'](_0x1ff191);if(_0x1ca197!==undefined)try{_0x543918[_0x2f33b0(0x17d)](BigInt(_0x1ca197));}catch{}const _0x342c35=_0x7d20a7['labelForEphemeral'](_0x1ff191);_0x543918[_0x2f33b0(0x223)](BigInt(_0x342c35),_0x77177e),_0x7d20a7['setFingerprint'](_0x1ff191,_0x2a2725??_0x5bc402(_0x77177e));}function _0x5df581(_0x3adb70){const _0x1ead1c=_0x52ce53,_0x2a729e=_0x7d20a7['labelForExisting'](_0x3adb70);if(_0x2a729e===undefined)return![];try{_0x543918[_0x1ead1c(0x17d)](BigInt(_0x2a729e));}catch{}return _0x7d20a7[_0x1ead1c(0x221)](_0x3adb70),!![];}function _0x1b76a8(_0x308419){const _0x2feb32=_0x52ce53;_0x7d20a7=new _0x111234(),_0x543918=_0x3d1af6();for(const {key:_0x5cc6e5,vector:_0x581a07}of _0x308419??[]){if(!(_0x581a07 instanceof Float32Array)||_0x581a07[_0x2feb32(0x21f)]!==_0x32473d)continue;_0x5d8e9b(_0x5cc6e5,_0x581a07);}_0x149e2b=0x0;}function _0x4b2277(){const _0x4fdfb3=_0x52ce53;return Math[_0x4fdfb3(0x22d)](Date[_0x4fdfb3(0x1ff)](),_0xdd6b29[_0x4fdfb3(0x1a4)]()+0x1);}function _0x41d488(){if(_0x11b35b)clearTimeout(_0x11b35b);_0x11b35b=null;}function _0x4c8f6b(){const _0x4205e2=_0x52ce53;if(!_0x417b8f[_0x4205e2(0x1e2)]||_0x11b35b||!_0x5274bf||_0x149e2b<=0x0)return;const _0x360952=Math[_0x4205e2(0x22d)](_0x417b8f[_0x4205e2(0x1e2)],0xa*_0x43a35d);_0x11b35b=setTimeout(()=>{const _0x5da3ce=_0x4205e2;_0x11b35b=null,_0x351773(async()=>{if(_0x5274bf&&_0x149e2b>0x0)await _0x4d0724();_0x4c8f6b(),_0x4954b3();})[_0x5da3ce(0x1f2)](()=>{});},_0x360952),_0x11b35b[_0x4205e2(0x1c5)]?.();}async function _0x4d0724(_0x5de075){const _0x199b9a=_0x52ce53;if(!_0x543918)return![];const _0x58668e=_0x5de075??_0x4b2277(),_0x5a6cd5=Date[_0x199b9a(0x1ff)](),_0x247ffe=await _0xdd6b29['publishSnapshot'](_0x58668e,async _0x3995c5=>{const _0x3b064c=_0x199b9a;_0x543918[_0x3b064c(0x1ce)](_0x3995c5[_0x3b064c(0x211)]),await _0x7d20a7['snapshotTo'](_0x3995c5[_0x3b064c(0x19f)]),_0x3f7825[_0x3b064c(0x1f9)](_0x3995c5['state'],JSON[_0x3b064c(0x174)]({'manifestVersion':_0x5c9c9c,'algorithm':_0x3b064c(0x234),'dims':_0x32473d,'metric':_0x417b8f[_0x3b064c(0x1df)],'clock':_0x58668e,'snapshotAt':Date[_0x3b064c(0x1ff)]()},null,0x2));},{'keep':_0x417b8f['keepSnapshots']});return _0x43a35d=Date[_0x199b9a(0x1ff)]()-_0x5a6cd5,_0x247ffe?.[_0x199b9a(0x22e)]&&(_0x149e2b=0x0,_0x41d488()),_0x247ffe?.[_0x199b9a(0x22e)]??![];}function _0x4ff402(){_0x149e2b++;if(_0x149e2b>=_0x417b8f['snapshotEveryChanges'])return _0x4d0724();return _0x4c8f6b(),null;}async function _0x19dbb3(){const _0x56a81f=_0x52ce53,_0x38c92a=_0xdd6b29[_0x56a81f(0x1da)]()||_0xdd6b29[_0x56a81f(0x1c4)]();if(!_0x38c92a)return null;let _0xaed38,_0x53ffd3=![];try{await _0xdd6b29[_0x56a81f(0x183)](_0x38c92a,async _0x15bb47=>{const _0x21646c=_0x56a81f;_0xaed38=JSON['parse'](_0x3f7825[_0x21646c(0x188)](_0x15bb47[_0x21646c(0x178)],_0x21646c(0x179)));if(_0xaed38[_0x21646c(0x1fb)]!==_0x5c9c9c||_0xaed38[_0x21646c(0x1d9)]!==_0x21646c(0x234)||_0xaed38[_0x21646c(0x231)]!==_0x32473d||_0xaed38[_0x21646c(0x1df)]!==_0x417b8f[_0x21646c(0x1df)]){_0xaed38=null;return;}const _0x26980b=new _0x111234();await _0x26980b['loadFrom'](_0x15bb47[_0x21646c(0x19f)]);const _0x1a8881=_0x3d1af6();_0x1a8881[_0x21646c(0x23c)](_0x15bb47[_0x21646c(0x211)]),_0x7d20a7=_0x26980b,_0x543918=_0x1a8881,_0x53ffd3=!![];});}catch{return null;}return _0x53ffd3?_0xaed38?.[_0x56a81f(0x1c9)]??0x0:null;}async function _0x4adee2(_0x5bc1c9){const _0x13edf1=_0x52ce53;_0x137947=null;const _0x5ca1f2=await _0x19dbb3();if(_0x5ca1f2!=null){_0x149e2b=0x0;if(_0x5bc1c9){if(!_0x7d20a7[_0x13edf1(0x242)])return _0x1b76a8(_0x5bc1c9),await _0x4d0724(),null;const _0x378ded=_0x1506e5(_0x7d20a7,_0x5bc1c9,_0x32473d,{'upsert':_0x5d8e9b,'remove':_0x5df581}),_0xc58851=_0x378ded[_0x13edf1(0x1c3)]+_0x378ded[_0x13edf1(0x1ee)]+_0x378ded['removed'];_0xc58851>0x0&&(_0x149e2b+=_0xc58851,await _0x4d0724());}return _0x5ca1f2;}_0x1b76a8(_0x5bc1c9??[]);if(_0x543918['size']()>0x0)await _0x4d0724();return null;}async function _0x534d8d(){_0x5274bf=!![],await _0x4adee2(await _0x3a5ac2());}async function _0xf55ec9(){const _0x422faa=_0x52ce53;if(!_0x5274bf)return;_0x5274bf=![],_0x41d488(),_0x149e2b=0x0;const _0x2811e6=_0xdd6b29[_0x422faa(0x1da)]()||_0xdd6b29[_0x422faa(0x1c4)]();await _0x475943(_0x2811e6),_0x4954b3();}async function _0x475943(_0x334141){const _0x3eb723=_0x52ce53;if(!_0x334141)return![];let _0x11aeb1=![];try{await _0xdd6b29[_0x3eb723(0x183)](_0x334141,async _0x2445bd=>{const _0x35abbd=_0x3eb723,_0x12a3a5=JSON[_0x35abbd(0x1e9)](_0x3f7825[_0x35abbd(0x188)](_0x2445bd['state'],_0x35abbd(0x179)));if(_0x12a3a5[_0x35abbd(0x1fb)]!==_0x5c9c9c||_0x12a3a5[_0x35abbd(0x1d9)]!=='usearch'||_0x12a3a5[_0x35abbd(0x231)]!==_0x32473d||_0x12a3a5['metric']!==_0x417b8f['metric'])return;const _0x230af7=new _0x111234();await _0x230af7[_0x35abbd(0x210)](_0x2445bd['labels']);const _0x27b00d=_0x3d1af6();_0x27b00d[_0x35abbd(0x23e)](_0x2445bd['index']),_0x543918=_0x27b00d,_0x7d20a7=_0x230af7,_0x137947=_0x334141,_0x11aeb1=!![];});}catch{}return _0x11aeb1;}function _0x13b679(){const _0x32b960=_0x52ce53,_0xc0ef04=Date['now']();if(_0xc0ef04-_0x1adb6a<_0x417b8f[_0x32b960(0x1cf)])return;_0x1adb6a=_0xc0ef04;if(_0x19729d)return;if(_0x175485[_0x32b960(0x17a)]()){_0x19729d=!![],_0x351773(async()=>{!_0x5274bf&&_0x30b4c7&&_0x175485['acquire']()&&(await _0x534d8d(),_0x4954b3());})[_0x32b960(0x1f2)](()=>{})['finally'](()=>{_0x19729d=![];});return;}const _0x2b6c62=_0xdd6b29[_0x32b960(0x1da)]()||_0xdd6b29[_0x32b960(0x1c4)]();if(!_0x2b6c62||_0x2b6c62===_0x137947)return;_0x19729d=!![],_0x351773(async()=>{if(!_0x5274bf&&await _0x475943(_0x2b6c62))_0x4954b3();})[_0x32b960(0x1f2)](()=>{})['finally'](()=>{_0x19729d=![];});}return{async 'load'(_0x4fb34c){return _0x351773(async()=>{const _0x2dc33a=_0x2d84;_0xdd6b29['cleanupTmpDirs']({'maxAgeMs':_0x417b8f[_0x2dc33a(0x1bf)]}),_0x18a34e=_0x4fb34c??null,_0x5274bf=_0x175485[_0x2dc33a(0x209)]();let _0x4fdd27=null;if(_0x5274bf)_0x4fdd27=await _0x4adee2(_0x4fb34c?await _0x4fb34c():null);else{const _0x4700e0=_0xdd6b29['readCurrentId']()||_0xdd6b29['latestSnapshotId']();await _0x475943(_0x4700e0);}return _0x30b4c7=!![],_0x4fdd27;});},async 'add'(_0x59f4ef,_0xe5560e,_0x4cbf96){return _0x351773(async()=>{const _0x39d4ec=_0x2d84;if(!_0x30b4c7)return;const _0x39f600=_0x3a6fb7(_0xe5560e);if(!_0x5274bf){if(!_0x175485[_0x39d4ec(0x209)]())return;await _0x534d8d();}if(!_0x543918)return;const _0x2256d4=_0x5bc402(_0x39f600);if(_0x7d20a7[_0x39d4ec(0x1a8)](_0x59f4ef)===_0x2256d4)return;_0x5d8e9b(_0x59f4ef,_0x39f600,_0x2256d4),await _0x4ff402();});},async 'remove'(_0x12e722){return _0x351773(async()=>{const _0x510dd3=_0x2d84;if(!_0x30b4c7)return;if(!_0x5274bf){if(!_0x175485[_0x510dd3(0x209)]())return;await _0x534d8d();}if(!_0x543918)return;if(_0x5df581(_0x12e722))await _0x4ff402();});},'search'(_0x26cdd9,{limit:limit=0xa}={}){const _0x1e1ed4=_0x52ce53;if(!_0x5274bf&&_0x30b4c7)_0x13b679();if(!_0x543918)return[];const _0x2be802=_0x543918[_0x1e1ed4(0x1d2)]();if(_0x2be802===0x0)return[];const _0x2c8285=Math[_0x1e1ed4(0x1d7)](limit,_0x2be802),_0x4c6bd4=_0x543918[_0x1e1ed4(0x1de)](_0x3a6fb7(_0x26cdd9),_0x2c8285,0x0),_0x22d6c1=[],_0x455581=_0x4c6bd4[_0x1e1ed4(0x1eb)],_0x48686c=_0x4c6bd4[_0x1e1ed4(0x1f4)];for(let _0x22da7d=0x0;_0x22da7d<_0x455581['length'];_0x22da7d++){const _0xe1306=_0x455581[_0x22da7d];if(_0xe1306===0xffffffffffffffffn)continue;const _0x33b24a=Number(_0xe1306),_0x5cdfb2=_0x7d20a7[_0x1e1ed4(0x170)](_0x33b24a);if(!_0x5cdfb2)continue;const _0x4862c9=_0x48686c[_0x22da7d];let _0x1bc978;if(_0x417b8f[_0x1e1ed4(0x1df)]===_0x1e1ed4(0x1f6))_0x1bc978=Math[_0x1e1ed4(0x22d)](0x0,0x1-_0x4862c9);else{if(_0x417b8f[_0x1e1ed4(0x1df)]==='ip')_0x1bc978=-_0x4862c9;else _0x1bc978=0x1/(0x1+_0x4862c9);}_0x22d6c1['push']({'key':_0x5cdfb2,'score':_0x1bc978});}return _0x22d6c1;},async 'snapshot'(_0x1a2dc9){return _0x351773(()=>_0x5274bf?_0x4d0724(_0x1a2dc9??undefined):![]);},async 'rebuild'(_0x48fce2){return _0x351773(async()=>{const _0x17ab7a=_0x2d84;if(_0x48fce2!=null)_0x18a34e=_0x48fce2;if(!_0x5274bf){if(!_0x175485[_0x17ab7a(0x209)]())return;_0x5274bf=!![];}const _0x14bf78=_0x48fce2?await _0x48fce2():await _0x3a5ac2();_0x1b76a8(_0x14bf78??[]),_0x30b4c7=!![],await _0x4d0724();});},async 'stop'(){return _0x351773(async()=>{const _0x582b20=_0x2d84;_0x41d488();if(_0x5274bf){if(_0x149e2b>0x0||!_0xdd6b29[_0x582b20(0x1da)]())await _0x4d0724();_0x175485['release']();}_0x5274bf=![],_0x30b4c7=![];});},'count'(){const _0x6992a6=_0x52ce53;return _0x7d20a7[_0x6992a6(0x1d2)]();},'info'(){const _0x5ae89e=_0x52ce53;return{'algorithm':_0x5ae89e(0x234),'role':_0x5274bf?_0x5ae89e(0x19c):'reader','metric':_0x417b8f[_0x5ae89e(0x1df)],'connectivity':_0x417b8f[_0x5ae89e(0x1c7)],'expansionAdd':_0x417b8f[_0x5ae89e(0x20a)],'expansionSearch':_0x417b8f[_0x5ae89e(0x1fd)],'snapshotEveryChanges':_0x417b8f[_0x5ae89e(0x22c)],'snapshotMaxLagMs':_0x417b8f[_0x5ae89e(0x1e2)],'count':_0x7d20a7['size'](),'size':_0x543918?.['size']?.()??0x0,'capacity':_0x543918?.[_0x5ae89e(0x21c)]?.()??0x0,'changesSince':_0x5274bf?_0x149e2b:null,'viewedSnapshot':_0x137947??null,'snapshotDir':_0x3ea71d,'latestSnapshot':_0xdd6b29[_0x5ae89e(0x1da)]()??null};}};},usearch;}var hasRequiredAlgorithmWorkerThread;function requireAlgorithmWorkerThread(){const _0x144f87=_0x31c441;if(hasRequiredAlgorithmWorkerThread)return algorithmWorkerThread$1;hasRequiredAlgorithmWorkerThread=0x1;const {parentPort:_0x4cbaf6,workerData:_0x57378d}=require$$0$1,{algorithmName:_0x3b42c6,algorithmConfig:_0x3feafc,dims:_0x1feeda,dir:_0x1f8af4}=_0x57378d;let _0x445bfc=0x1;const _0x52892f=new Map();function _0x589a0e(){const _0x2e7a42=_0x445bfc++;return new Promise((_0x595598,_0x5848de)=>{const _0xb1e74b=_0x2d84;_0x52892f[_0xb1e74b(0x1ba)](_0x2e7a42,{'resolve':_0x595598,'reject':_0x5848de}),_0x4cbaf6[_0xb1e74b(0x220)]({'op':_0xb1e74b(0x167),'fid':_0x2e7a42});});}const _0x3dec94={'dims':_0x1feeda,'dir':_0x1f8af4,'fetchAll':_0x589a0e,'onChange':()=>_0x2a8b92()};let _0x52b023;if(_0x3b42c6===_0x144f87(0x202))_0x52b023=requireHnsw()(_0x3feafc,_0x3dec94);else{if(_0x3b42c6===_0x144f87(0x189))_0x52b023=requireFlat()(_0x3feafc,_0x3dec94);else{if(_0x3b42c6===_0x144f87(0x234))_0x52b023=requireUsearch()(_0x3feafc,_0x3dec94);else throw new Error(_0x144f87(0x1ae)+_0x3b42c6+'\x22');}}function _0x2a8b92(){const _0x4704d6=_0x144f87;try{_0x4cbaf6[_0x4704d6(0x220)]({'op':_0x4704d6(0x20b),'count':_0x52b023['count'](),'info':_0x52b023[_0x4704d6(0x226)](),'memory':process[_0x4704d6(0x19e)]()});}catch{}}function _0x20d348(_0x55da20){const _0x46b533=_0x144f87;return(_0x55da20||[])[_0x46b533(0x1bb)](_0x325413=>({'key':_0x325413['key'],'vector':_0x325413[_0x46b533(0x163)]instanceof Float32Array?_0x325413[_0x46b533(0x163)]:new Float32Array(_0x325413[_0x46b533(0x163)])}));}return _0x4cbaf6['on'](_0x144f87(0x168),async _0x4ebb64=>{const _0x53c9d9=_0x144f87;if(_0x4ebb64['op']===_0x53c9d9(0x1e7)){const _0x33220c=_0x52892f[_0x53c9d9(0x19d)](_0x4ebb64['fid']);if(!_0x33220c)return;_0x52892f[_0x53c9d9(0x16c)](_0x4ebb64[_0x53c9d9(0x1c0)]);if(_0x4ebb64[_0x53c9d9(0x222)])_0x33220c[_0x53c9d9(0x237)](new Error(_0x4ebb64[_0x53c9d9(0x222)]));else _0x33220c[_0x53c9d9(0x21b)](_0x20d348(_0x4ebb64[_0x53c9d9(0x1a5)]));return;}const {id:_0x1664a3,op:_0x2fcb72,args:_0x36ce92}=_0x4ebb64;try{let _0xe6e6e3;switch(_0x2fcb72){case _0x53c9d9(0x23c):{_0xe6e6e3=await _0x52b023[_0x53c9d9(0x23c)](_0x36ce92['hasRows']?_0x589a0e:null),_0x2a8b92();break;}case'add':{const _0x272376=_0x36ce92[_0x53c9d9(0x163)]instanceof Float32Array?_0x36ce92[_0x53c9d9(0x163)]:new Float32Array(_0x36ce92[_0x53c9d9(0x163)]);await _0x52b023[_0x53c9d9(0x223)](_0x36ce92[_0x53c9d9(0x17c)],_0x272376,_0x36ce92[_0x53c9d9(0x1c9)]??undefined),_0x2a8b92(),_0xe6e6e3=null;break;}case'remove':{await _0x52b023[_0x53c9d9(0x17d)](_0x36ce92[_0x53c9d9(0x17c)]),_0x2a8b92(),_0xe6e6e3=null;break;}case'search':{const _0x143752=_0x36ce92[_0x53c9d9(0x1f5)]instanceof Float32Array?_0x36ce92['queryVec']:new Float32Array(_0x36ce92['queryVec']);_0xe6e6e3=_0x52b023[_0x53c9d9(0x1de)](_0x143752,_0x36ce92['opts']||{});break;}case _0x53c9d9(0x230):{_0xe6e6e3=await _0x52b023['snapshot'](_0x36ce92[_0x53c9d9(0x1c9)]),_0x2a8b92();break;}case _0x53c9d9(0x19a):{const _0x3a5271=_0x20d348(_0x36ce92[_0x53c9d9(0x1a5)]);await _0x52b023['rebuild'](async()=>_0x3a5271),_0x2a8b92(),_0xe6e6e3=null;break;}case _0x53c9d9(0x181):{await _0x52b023[_0x53c9d9(0x181)](),_0x2a8b92(),_0xe6e6e3=null;break;}case'count':{_0xe6e6e3=_0x52b023[_0x53c9d9(0x193)]();break;}case _0x53c9d9(0x226):{_0xe6e6e3=_0x52b023[_0x53c9d9(0x226)]();break;}default:throw new Error(_0x53c9d9(0x1a7)+_0x2fcb72+'\x22');}_0x4cbaf6[_0x53c9d9(0x220)]({'id':_0x1664a3,'result':_0xe6e6e3});}catch(_0x119725){_0x4cbaf6['postMessage']({'id':_0x1664a3,'error':{'message':_0x119725?.[_0x53c9d9(0x168)]||String(_0x119725),'code':_0x119725?.['code']}});}}),_0x4cbaf6[_0x144f87(0x220)]({'op':_0x144f87(0x1f0)}),algorithmWorkerThread$1;}var algorithmWorkerThreadExports=requireAlgorithmWorkerThread(),algorithmWorkerThread=getDefaultExportFromCjs(algorithmWorkerThreadExports);module[_0x31c441(0x1b4)]=algorithmWorkerThread;