@semiont/make-meaning 0.2.34 → 0.2.35-build.100

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -222,9 +222,9 @@ Example output:
222
222
  // src/jobs/reference-annotation-worker.ts
223
223
  import { FilesystemRepresentationStore } from "@semiont/content";
224
224
  var ReferenceAnnotationWorker = class extends JobWorker {
225
- constructor(jobQueue, config, eventStore, inferenceClient, eventBus, logger) {
225
+ constructor(jobQueue, config2, eventStore, inferenceClient, eventBus, logger) {
226
226
  super(jobQueue, void 0, void 0, logger);
227
- this.config = config;
227
+ this.config = config2;
228
228
  this.eventStore = eventStore;
229
229
  this.inferenceClient = inferenceClient;
230
230
  this.eventBus = eventBus;
@@ -686,9 +686,9 @@ function generateUuid() {
686
686
 
687
687
  // src/jobs/generation-worker.ts
688
688
  var GenerationWorker = class extends JobWorker2 {
689
- constructor(jobQueue, config, eventStore, inferenceClient, eventBus, logger) {
689
+ constructor(jobQueue, config2, eventStore, inferenceClient, eventBus, logger) {
690
690
  super(jobQueue, void 0, void 0, logger);
691
- this.config = config;
691
+ this.config = config2;
692
692
  this.eventStore = eventStore;
693
693
  this.inferenceClient = inferenceClient;
694
694
  this.eventBus = eventBus;
@@ -981,9 +981,9 @@ import { generateAnnotationId as generateAnnotationId2 } from "@semiont/event-so
981
981
  import { resourceIdToURI as resourceIdToURI2 } from "@semiont/core";
982
982
  import { userId } from "@semiont/core";
983
983
  var HighlightAnnotationWorker = class extends JobWorker3 {
984
- constructor(jobQueue, config, eventStore, inferenceClient, eventBus, logger) {
984
+ constructor(jobQueue, config2, eventStore, inferenceClient, eventBus, logger) {
985
985
  super(jobQueue, void 0, void 0, logger);
986
- this.config = config;
986
+ this.config = config2;
987
987
  this.eventStore = eventStore;
988
988
  this.inferenceClient = inferenceClient;
989
989
  this.eventBus = eventBus;
@@ -1198,9 +1198,9 @@ import { generateAnnotationId as generateAnnotationId3 } from "@semiont/event-so
1198
1198
  import { resourceIdToURI as resourceIdToURI3 } from "@semiont/core";
1199
1199
  import { userId as userId2 } from "@semiont/core";
1200
1200
  var AssessmentAnnotationWorker = class extends JobWorker4 {
1201
- constructor(jobQueue, config, eventStore, inferenceClient, eventBus, logger) {
1201
+ constructor(jobQueue, config2, eventStore, inferenceClient, eventBus, logger) {
1202
1202
  super(jobQueue, void 0, void 0, logger);
1203
- this.config = config;
1203
+ this.config = config2;
1204
1204
  this.eventStore = eventStore;
1205
1205
  this.inferenceClient = inferenceClient;
1206
1206
  this.eventBus = eventBus;
@@ -1419,9 +1419,9 @@ import { generateAnnotationId as generateAnnotationId4 } from "@semiont/event-so
1419
1419
  import { resourceIdToURI as resourceIdToURI4 } from "@semiont/core";
1420
1420
  import { userId as userId3 } from "@semiont/core";
1421
1421
  var CommentAnnotationWorker = class extends JobWorker5 {
1422
- constructor(jobQueue, config, eventStore, inferenceClient, eventBus, logger) {
1422
+ constructor(jobQueue, config2, eventStore, inferenceClient, eventBus, logger) {
1423
1423
  super(jobQueue, void 0, void 0, logger);
1424
- this.config = config;
1424
+ this.config = config2;
1425
1425
  this.eventStore = eventStore;
1426
1426
  this.inferenceClient = inferenceClient;
1427
1427
  this.eventBus = eventBus;
@@ -1651,9 +1651,9 @@ import { resourceIdToURI as resourceIdToURI5 } from "@semiont/core";
1651
1651
  import { getTagSchema } from "@semiont/ontology";
1652
1652
  import { userId as userId4 } from "@semiont/core";
1653
1653
  var TagAnnotationWorker = class extends JobWorker6 {
1654
- constructor(jobQueue, config, eventStore, inferenceClient, eventBus, logger) {
1654
+ constructor(jobQueue, config2, eventStore, inferenceClient, eventBus, logger) {
1655
1655
  super(jobQueue, void 0, void 0, logger);
1656
- this.config = config;
1656
+ this.config = config2;
1657
1657
  this.eventStore = eventStore;
1658
1658
  this.inferenceClient = inferenceClient;
1659
1659
  this.eventBus = eventBus;
@@ -1915,21 +1915,1448 @@ var TagAnnotationWorker = class extends JobWorker6 {
1915
1915
  }
1916
1916
  };
1917
1917
 
1918
+ // ../../node_modules/rxjs/node_modules/tslib/tslib.es6.js
1919
+ var extendStatics = function(d, b) {
1920
+ extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {
1921
+ d2.__proto__ = b2;
1922
+ } || function(d2, b2) {
1923
+ for (var p in b2) if (b2.hasOwnProperty(p)) d2[p] = b2[p];
1924
+ };
1925
+ return extendStatics(d, b);
1926
+ };
1927
+ function __extends(d, b) {
1928
+ extendStatics(d, b);
1929
+ function __() {
1930
+ this.constructor = d;
1931
+ }
1932
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
1933
+ }
1934
+
1935
+ // ../../node_modules/rxjs/_esm5/internal/util/isFunction.js
1936
+ function isFunction(x) {
1937
+ return typeof x === "function";
1938
+ }
1939
+
1940
+ // ../../node_modules/rxjs/_esm5/internal/config.js
1941
+ var _enable_super_gross_mode_that_will_cause_bad_things = false;
1942
+ var config = {
1943
+ Promise: void 0,
1944
+ set useDeprecatedSynchronousErrorHandling(value) {
1945
+ if (value) {
1946
+ var error = /* @__PURE__ */ new Error();
1947
+ /* @__PURE__ */ console.warn("DEPRECATED! RxJS was set to use deprecated synchronous error handling behavior by code at: \n" + error.stack);
1948
+ } else if (_enable_super_gross_mode_that_will_cause_bad_things) {
1949
+ /* @__PURE__ */ console.log("RxJS: Back to a better error behavior. Thank you. <3");
1950
+ }
1951
+ _enable_super_gross_mode_that_will_cause_bad_things = value;
1952
+ },
1953
+ get useDeprecatedSynchronousErrorHandling() {
1954
+ return _enable_super_gross_mode_that_will_cause_bad_things;
1955
+ }
1956
+ };
1957
+
1958
+ // ../../node_modules/rxjs/_esm5/internal/util/hostReportError.js
1959
+ function hostReportError(err) {
1960
+ setTimeout(function() {
1961
+ throw err;
1962
+ }, 0);
1963
+ }
1964
+
1965
+ // ../../node_modules/rxjs/_esm5/internal/Observer.js
1966
+ var empty = {
1967
+ closed: true,
1968
+ next: function(value) {
1969
+ },
1970
+ error: function(err) {
1971
+ if (config.useDeprecatedSynchronousErrorHandling) {
1972
+ throw err;
1973
+ } else {
1974
+ hostReportError(err);
1975
+ }
1976
+ },
1977
+ complete: function() {
1978
+ }
1979
+ };
1980
+
1981
+ // ../../node_modules/rxjs/_esm5/internal/util/isArray.js
1982
+ var isArray = /* @__PURE__ */ (function() {
1983
+ return Array.isArray || (function(x) {
1984
+ return x && typeof x.length === "number";
1985
+ });
1986
+ })();
1987
+
1988
+ // ../../node_modules/rxjs/_esm5/internal/util/isObject.js
1989
+ function isObject(x) {
1990
+ return x !== null && typeof x === "object";
1991
+ }
1992
+
1993
+ // ../../node_modules/rxjs/_esm5/internal/util/UnsubscriptionError.js
1994
+ var UnsubscriptionErrorImpl = /* @__PURE__ */ (function() {
1995
+ function UnsubscriptionErrorImpl2(errors) {
1996
+ Error.call(this);
1997
+ this.message = errors ? errors.length + " errors occurred during unsubscription:\n" + errors.map(function(err, i) {
1998
+ return i + 1 + ") " + err.toString();
1999
+ }).join("\n ") : "";
2000
+ this.name = "UnsubscriptionError";
2001
+ this.errors = errors;
2002
+ return this;
2003
+ }
2004
+ UnsubscriptionErrorImpl2.prototype = /* @__PURE__ */ Object.create(Error.prototype);
2005
+ return UnsubscriptionErrorImpl2;
2006
+ })();
2007
+ var UnsubscriptionError = UnsubscriptionErrorImpl;
2008
+
2009
+ // ../../node_modules/rxjs/_esm5/internal/Subscription.js
2010
+ var Subscription = /* @__PURE__ */ (function() {
2011
+ function Subscription3(unsubscribe) {
2012
+ this.closed = false;
2013
+ this._parentOrParents = null;
2014
+ this._subscriptions = null;
2015
+ if (unsubscribe) {
2016
+ this._ctorUnsubscribe = true;
2017
+ this._unsubscribe = unsubscribe;
2018
+ }
2019
+ }
2020
+ Subscription3.prototype.unsubscribe = function() {
2021
+ var errors;
2022
+ if (this.closed) {
2023
+ return;
2024
+ }
2025
+ var _a = this, _parentOrParents = _a._parentOrParents, _ctorUnsubscribe = _a._ctorUnsubscribe, _unsubscribe = _a._unsubscribe, _subscriptions = _a._subscriptions;
2026
+ this.closed = true;
2027
+ this._parentOrParents = null;
2028
+ this._subscriptions = null;
2029
+ if (_parentOrParents instanceof Subscription3) {
2030
+ _parentOrParents.remove(this);
2031
+ } else if (_parentOrParents !== null) {
2032
+ for (var index = 0; index < _parentOrParents.length; ++index) {
2033
+ var parent_1 = _parentOrParents[index];
2034
+ parent_1.remove(this);
2035
+ }
2036
+ }
2037
+ if (isFunction(_unsubscribe)) {
2038
+ if (_ctorUnsubscribe) {
2039
+ this._unsubscribe = void 0;
2040
+ }
2041
+ try {
2042
+ _unsubscribe.call(this);
2043
+ } catch (e) {
2044
+ errors = e instanceof UnsubscriptionError ? flattenUnsubscriptionErrors(e.errors) : [e];
2045
+ }
2046
+ }
2047
+ if (isArray(_subscriptions)) {
2048
+ var index = -1;
2049
+ var len = _subscriptions.length;
2050
+ while (++index < len) {
2051
+ var sub = _subscriptions[index];
2052
+ if (isObject(sub)) {
2053
+ try {
2054
+ sub.unsubscribe();
2055
+ } catch (e) {
2056
+ errors = errors || [];
2057
+ if (e instanceof UnsubscriptionError) {
2058
+ errors = errors.concat(flattenUnsubscriptionErrors(e.errors));
2059
+ } else {
2060
+ errors.push(e);
2061
+ }
2062
+ }
2063
+ }
2064
+ }
2065
+ }
2066
+ if (errors) {
2067
+ throw new UnsubscriptionError(errors);
2068
+ }
2069
+ };
2070
+ Subscription3.prototype.add = function(teardown) {
2071
+ var subscription = teardown;
2072
+ if (!teardown) {
2073
+ return Subscription3.EMPTY;
2074
+ }
2075
+ switch (typeof teardown) {
2076
+ case "function":
2077
+ subscription = new Subscription3(teardown);
2078
+ case "object":
2079
+ if (subscription === this || subscription.closed || typeof subscription.unsubscribe !== "function") {
2080
+ return subscription;
2081
+ } else if (this.closed) {
2082
+ subscription.unsubscribe();
2083
+ return subscription;
2084
+ } else if (!(subscription instanceof Subscription3)) {
2085
+ var tmp = subscription;
2086
+ subscription = new Subscription3();
2087
+ subscription._subscriptions = [tmp];
2088
+ }
2089
+ break;
2090
+ default: {
2091
+ throw new Error("unrecognized teardown " + teardown + " added to Subscription.");
2092
+ }
2093
+ }
2094
+ var _parentOrParents = subscription._parentOrParents;
2095
+ if (_parentOrParents === null) {
2096
+ subscription._parentOrParents = this;
2097
+ } else if (_parentOrParents instanceof Subscription3) {
2098
+ if (_parentOrParents === this) {
2099
+ return subscription;
2100
+ }
2101
+ subscription._parentOrParents = [_parentOrParents, this];
2102
+ } else if (_parentOrParents.indexOf(this) === -1) {
2103
+ _parentOrParents.push(this);
2104
+ } else {
2105
+ return subscription;
2106
+ }
2107
+ var subscriptions = this._subscriptions;
2108
+ if (subscriptions === null) {
2109
+ this._subscriptions = [subscription];
2110
+ } else {
2111
+ subscriptions.push(subscription);
2112
+ }
2113
+ return subscription;
2114
+ };
2115
+ Subscription3.prototype.remove = function(subscription) {
2116
+ var subscriptions = this._subscriptions;
2117
+ if (subscriptions) {
2118
+ var subscriptionIndex = subscriptions.indexOf(subscription);
2119
+ if (subscriptionIndex !== -1) {
2120
+ subscriptions.splice(subscriptionIndex, 1);
2121
+ }
2122
+ }
2123
+ };
2124
+ Subscription3.EMPTY = (function(empty2) {
2125
+ empty2.closed = true;
2126
+ return empty2;
2127
+ })(new Subscription3());
2128
+ return Subscription3;
2129
+ })();
2130
+ function flattenUnsubscriptionErrors(errors) {
2131
+ return errors.reduce(function(errs, err) {
2132
+ return errs.concat(err instanceof UnsubscriptionError ? err.errors : err);
2133
+ }, []);
2134
+ }
2135
+
2136
+ // ../../node_modules/rxjs/_esm5/internal/symbol/rxSubscriber.js
2137
+ var rxSubscriber = /* @__PURE__ */ (function() {
2138
+ return typeof Symbol === "function" ? /* @__PURE__ */ Symbol("rxSubscriber") : "@@rxSubscriber_" + /* @__PURE__ */ Math.random();
2139
+ })();
2140
+
2141
+ // ../../node_modules/rxjs/_esm5/internal/Subscriber.js
2142
+ var Subscriber = /* @__PURE__ */ (function(_super) {
2143
+ __extends(Subscriber2, _super);
2144
+ function Subscriber2(destinationOrNext, error, complete) {
2145
+ var _this = _super.call(this) || this;
2146
+ _this.syncErrorValue = null;
2147
+ _this.syncErrorThrown = false;
2148
+ _this.syncErrorThrowable = false;
2149
+ _this.isStopped = false;
2150
+ switch (arguments.length) {
2151
+ case 0:
2152
+ _this.destination = empty;
2153
+ break;
2154
+ case 1:
2155
+ if (!destinationOrNext) {
2156
+ _this.destination = empty;
2157
+ break;
2158
+ }
2159
+ if (typeof destinationOrNext === "object") {
2160
+ if (destinationOrNext instanceof Subscriber2) {
2161
+ _this.syncErrorThrowable = destinationOrNext.syncErrorThrowable;
2162
+ _this.destination = destinationOrNext;
2163
+ destinationOrNext.add(_this);
2164
+ } else {
2165
+ _this.syncErrorThrowable = true;
2166
+ _this.destination = new SafeSubscriber(_this, destinationOrNext);
2167
+ }
2168
+ break;
2169
+ }
2170
+ default:
2171
+ _this.syncErrorThrowable = true;
2172
+ _this.destination = new SafeSubscriber(_this, destinationOrNext, error, complete);
2173
+ break;
2174
+ }
2175
+ return _this;
2176
+ }
2177
+ Subscriber2.prototype[rxSubscriber] = function() {
2178
+ return this;
2179
+ };
2180
+ Subscriber2.create = function(next, error, complete) {
2181
+ var subscriber = new Subscriber2(next, error, complete);
2182
+ subscriber.syncErrorThrowable = false;
2183
+ return subscriber;
2184
+ };
2185
+ Subscriber2.prototype.next = function(value) {
2186
+ if (!this.isStopped) {
2187
+ this._next(value);
2188
+ }
2189
+ };
2190
+ Subscriber2.prototype.error = function(err) {
2191
+ if (!this.isStopped) {
2192
+ this.isStopped = true;
2193
+ this._error(err);
2194
+ }
2195
+ };
2196
+ Subscriber2.prototype.complete = function() {
2197
+ if (!this.isStopped) {
2198
+ this.isStopped = true;
2199
+ this._complete();
2200
+ }
2201
+ };
2202
+ Subscriber2.prototype.unsubscribe = function() {
2203
+ if (this.closed) {
2204
+ return;
2205
+ }
2206
+ this.isStopped = true;
2207
+ _super.prototype.unsubscribe.call(this);
2208
+ };
2209
+ Subscriber2.prototype._next = function(value) {
2210
+ this.destination.next(value);
2211
+ };
2212
+ Subscriber2.prototype._error = function(err) {
2213
+ this.destination.error(err);
2214
+ this.unsubscribe();
2215
+ };
2216
+ Subscriber2.prototype._complete = function() {
2217
+ this.destination.complete();
2218
+ this.unsubscribe();
2219
+ };
2220
+ Subscriber2.prototype._unsubscribeAndRecycle = function() {
2221
+ var _parentOrParents = this._parentOrParents;
2222
+ this._parentOrParents = null;
2223
+ this.unsubscribe();
2224
+ this.closed = false;
2225
+ this.isStopped = false;
2226
+ this._parentOrParents = _parentOrParents;
2227
+ return this;
2228
+ };
2229
+ return Subscriber2;
2230
+ })(Subscription);
2231
+ var SafeSubscriber = /* @__PURE__ */ (function(_super) {
2232
+ __extends(SafeSubscriber2, _super);
2233
+ function SafeSubscriber2(_parentSubscriber, observerOrNext, error, complete) {
2234
+ var _this = _super.call(this) || this;
2235
+ _this._parentSubscriber = _parentSubscriber;
2236
+ var next;
2237
+ var context = _this;
2238
+ if (isFunction(observerOrNext)) {
2239
+ next = observerOrNext;
2240
+ } else if (observerOrNext) {
2241
+ next = observerOrNext.next;
2242
+ error = observerOrNext.error;
2243
+ complete = observerOrNext.complete;
2244
+ if (observerOrNext !== empty) {
2245
+ context = Object.create(observerOrNext);
2246
+ if (isFunction(context.unsubscribe)) {
2247
+ _this.add(context.unsubscribe.bind(context));
2248
+ }
2249
+ context.unsubscribe = _this.unsubscribe.bind(_this);
2250
+ }
2251
+ }
2252
+ _this._context = context;
2253
+ _this._next = next;
2254
+ _this._error = error;
2255
+ _this._complete = complete;
2256
+ return _this;
2257
+ }
2258
+ SafeSubscriber2.prototype.next = function(value) {
2259
+ if (!this.isStopped && this._next) {
2260
+ var _parentSubscriber = this._parentSubscriber;
2261
+ if (!config.useDeprecatedSynchronousErrorHandling || !_parentSubscriber.syncErrorThrowable) {
2262
+ this.__tryOrUnsub(this._next, value);
2263
+ } else if (this.__tryOrSetError(_parentSubscriber, this._next, value)) {
2264
+ this.unsubscribe();
2265
+ }
2266
+ }
2267
+ };
2268
+ SafeSubscriber2.prototype.error = function(err) {
2269
+ if (!this.isStopped) {
2270
+ var _parentSubscriber = this._parentSubscriber;
2271
+ var useDeprecatedSynchronousErrorHandling = config.useDeprecatedSynchronousErrorHandling;
2272
+ if (this._error) {
2273
+ if (!useDeprecatedSynchronousErrorHandling || !_parentSubscriber.syncErrorThrowable) {
2274
+ this.__tryOrUnsub(this._error, err);
2275
+ this.unsubscribe();
2276
+ } else {
2277
+ this.__tryOrSetError(_parentSubscriber, this._error, err);
2278
+ this.unsubscribe();
2279
+ }
2280
+ } else if (!_parentSubscriber.syncErrorThrowable) {
2281
+ this.unsubscribe();
2282
+ if (useDeprecatedSynchronousErrorHandling) {
2283
+ throw err;
2284
+ }
2285
+ hostReportError(err);
2286
+ } else {
2287
+ if (useDeprecatedSynchronousErrorHandling) {
2288
+ _parentSubscriber.syncErrorValue = err;
2289
+ _parentSubscriber.syncErrorThrown = true;
2290
+ } else {
2291
+ hostReportError(err);
2292
+ }
2293
+ this.unsubscribe();
2294
+ }
2295
+ }
2296
+ };
2297
+ SafeSubscriber2.prototype.complete = function() {
2298
+ var _this = this;
2299
+ if (!this.isStopped) {
2300
+ var _parentSubscriber = this._parentSubscriber;
2301
+ if (this._complete) {
2302
+ var wrappedComplete = function() {
2303
+ return _this._complete.call(_this._context);
2304
+ };
2305
+ if (!config.useDeprecatedSynchronousErrorHandling || !_parentSubscriber.syncErrorThrowable) {
2306
+ this.__tryOrUnsub(wrappedComplete);
2307
+ this.unsubscribe();
2308
+ } else {
2309
+ this.__tryOrSetError(_parentSubscriber, wrappedComplete);
2310
+ this.unsubscribe();
2311
+ }
2312
+ } else {
2313
+ this.unsubscribe();
2314
+ }
2315
+ }
2316
+ };
2317
+ SafeSubscriber2.prototype.__tryOrUnsub = function(fn, value) {
2318
+ try {
2319
+ fn.call(this._context, value);
2320
+ } catch (err) {
2321
+ this.unsubscribe();
2322
+ if (config.useDeprecatedSynchronousErrorHandling) {
2323
+ throw err;
2324
+ } else {
2325
+ hostReportError(err);
2326
+ }
2327
+ }
2328
+ };
2329
+ SafeSubscriber2.prototype.__tryOrSetError = function(parent, fn, value) {
2330
+ if (!config.useDeprecatedSynchronousErrorHandling) {
2331
+ throw new Error("bad call");
2332
+ }
2333
+ try {
2334
+ fn.call(this._context, value);
2335
+ } catch (err) {
2336
+ if (config.useDeprecatedSynchronousErrorHandling) {
2337
+ parent.syncErrorValue = err;
2338
+ parent.syncErrorThrown = true;
2339
+ return true;
2340
+ } else {
2341
+ hostReportError(err);
2342
+ return true;
2343
+ }
2344
+ }
2345
+ return false;
2346
+ };
2347
+ SafeSubscriber2.prototype._unsubscribe = function() {
2348
+ var _parentSubscriber = this._parentSubscriber;
2349
+ this._context = null;
2350
+ this._parentSubscriber = null;
2351
+ _parentSubscriber.unsubscribe();
2352
+ };
2353
+ return SafeSubscriber2;
2354
+ })(Subscriber);
2355
+
2356
+ // ../../node_modules/rxjs/_esm5/internal/util/canReportError.js
2357
+ function canReportError(observer) {
2358
+ while (observer) {
2359
+ var _a = observer, closed_1 = _a.closed, destination = _a.destination, isStopped = _a.isStopped;
2360
+ if (closed_1 || isStopped) {
2361
+ return false;
2362
+ } else if (destination && destination instanceof Subscriber) {
2363
+ observer = destination;
2364
+ } else {
2365
+ observer = null;
2366
+ }
2367
+ }
2368
+ return true;
2369
+ }
2370
+
2371
+ // ../../node_modules/rxjs/_esm5/internal/util/toSubscriber.js
2372
+ function toSubscriber(nextOrObserver, error, complete) {
2373
+ if (nextOrObserver) {
2374
+ if (nextOrObserver instanceof Subscriber) {
2375
+ return nextOrObserver;
2376
+ }
2377
+ if (nextOrObserver[rxSubscriber]) {
2378
+ return nextOrObserver[rxSubscriber]();
2379
+ }
2380
+ }
2381
+ if (!nextOrObserver && !error && !complete) {
2382
+ return new Subscriber(empty);
2383
+ }
2384
+ return new Subscriber(nextOrObserver, error, complete);
2385
+ }
2386
+
2387
+ // ../../node_modules/rxjs/_esm5/internal/symbol/observable.js
2388
+ var observable = /* @__PURE__ */ (function() {
2389
+ return typeof Symbol === "function" && Symbol.observable || "@@observable";
2390
+ })();
2391
+
2392
+ // ../../node_modules/rxjs/_esm5/internal/util/identity.js
2393
+ function identity(x) {
2394
+ return x;
2395
+ }
2396
+
2397
+ // ../../node_modules/rxjs/_esm5/internal/util/pipe.js
2398
+ function pipeFromArray(fns) {
2399
+ if (fns.length === 0) {
2400
+ return identity;
2401
+ }
2402
+ if (fns.length === 1) {
2403
+ return fns[0];
2404
+ }
2405
+ return function piped(input) {
2406
+ return fns.reduce(function(prev, fn) {
2407
+ return fn(prev);
2408
+ }, input);
2409
+ };
2410
+ }
2411
+
2412
+ // ../../node_modules/rxjs/_esm5/internal/Observable.js
2413
+ var Observable = /* @__PURE__ */ (function() {
2414
+ function Observable2(subscribe) {
2415
+ this._isScalar = false;
2416
+ if (subscribe) {
2417
+ this._subscribe = subscribe;
2418
+ }
2419
+ }
2420
+ Observable2.prototype.lift = function(operator) {
2421
+ var observable2 = new Observable2();
2422
+ observable2.source = this;
2423
+ observable2.operator = operator;
2424
+ return observable2;
2425
+ };
2426
+ Observable2.prototype.subscribe = function(observerOrNext, error, complete) {
2427
+ var operator = this.operator;
2428
+ var sink = toSubscriber(observerOrNext, error, complete);
2429
+ if (operator) {
2430
+ sink.add(operator.call(sink, this.source));
2431
+ } else {
2432
+ sink.add(this.source || config.useDeprecatedSynchronousErrorHandling && !sink.syncErrorThrowable ? this._subscribe(sink) : this._trySubscribe(sink));
2433
+ }
2434
+ if (config.useDeprecatedSynchronousErrorHandling) {
2435
+ if (sink.syncErrorThrowable) {
2436
+ sink.syncErrorThrowable = false;
2437
+ if (sink.syncErrorThrown) {
2438
+ throw sink.syncErrorValue;
2439
+ }
2440
+ }
2441
+ }
2442
+ return sink;
2443
+ };
2444
+ Observable2.prototype._trySubscribe = function(sink) {
2445
+ try {
2446
+ return this._subscribe(sink);
2447
+ } catch (err) {
2448
+ if (config.useDeprecatedSynchronousErrorHandling) {
2449
+ sink.syncErrorThrown = true;
2450
+ sink.syncErrorValue = err;
2451
+ }
2452
+ if (canReportError(sink)) {
2453
+ sink.error(err);
2454
+ } else {
2455
+ console.warn(err);
2456
+ }
2457
+ }
2458
+ };
2459
+ Observable2.prototype.forEach = function(next, promiseCtor) {
2460
+ var _this = this;
2461
+ promiseCtor = getPromiseCtor(promiseCtor);
2462
+ return new promiseCtor(function(resolve4, reject) {
2463
+ var subscription;
2464
+ subscription = _this.subscribe(function(value) {
2465
+ try {
2466
+ next(value);
2467
+ } catch (err) {
2468
+ reject(err);
2469
+ if (subscription) {
2470
+ subscription.unsubscribe();
2471
+ }
2472
+ }
2473
+ }, reject, resolve4);
2474
+ });
2475
+ };
2476
+ Observable2.prototype._subscribe = function(subscriber) {
2477
+ var source = this.source;
2478
+ return source && source.subscribe(subscriber);
2479
+ };
2480
+ Observable2.prototype[observable] = function() {
2481
+ return this;
2482
+ };
2483
+ Observable2.prototype.pipe = function() {
2484
+ var operations = [];
2485
+ for (var _i = 0; _i < arguments.length; _i++) {
2486
+ operations[_i] = arguments[_i];
2487
+ }
2488
+ if (operations.length === 0) {
2489
+ return this;
2490
+ }
2491
+ return pipeFromArray(operations)(this);
2492
+ };
2493
+ Observable2.prototype.toPromise = function(promiseCtor) {
2494
+ var _this = this;
2495
+ promiseCtor = getPromiseCtor(promiseCtor);
2496
+ return new promiseCtor(function(resolve4, reject) {
2497
+ var value;
2498
+ _this.subscribe(function(x) {
2499
+ return value = x;
2500
+ }, function(err) {
2501
+ return reject(err);
2502
+ }, function() {
2503
+ return resolve4(value);
2504
+ });
2505
+ });
2506
+ };
2507
+ Observable2.create = function(subscribe) {
2508
+ return new Observable2(subscribe);
2509
+ };
2510
+ return Observable2;
2511
+ })();
2512
+ function getPromiseCtor(promiseCtor) {
2513
+ if (!promiseCtor) {
2514
+ promiseCtor = config.Promise || Promise;
2515
+ }
2516
+ if (!promiseCtor) {
2517
+ throw new Error("no Promise impl found");
2518
+ }
2519
+ return promiseCtor;
2520
+ }
2521
+
2522
+ // ../../node_modules/rxjs/_esm5/internal/util/ObjectUnsubscribedError.js
2523
+ var ObjectUnsubscribedErrorImpl = /* @__PURE__ */ (function() {
2524
+ function ObjectUnsubscribedErrorImpl2() {
2525
+ Error.call(this);
2526
+ this.message = "object unsubscribed";
2527
+ this.name = "ObjectUnsubscribedError";
2528
+ return this;
2529
+ }
2530
+ ObjectUnsubscribedErrorImpl2.prototype = /* @__PURE__ */ Object.create(Error.prototype);
2531
+ return ObjectUnsubscribedErrorImpl2;
2532
+ })();
2533
+ var ObjectUnsubscribedError = ObjectUnsubscribedErrorImpl;
2534
+
2535
+ // ../../node_modules/rxjs/_esm5/internal/SubjectSubscription.js
2536
+ var SubjectSubscription = /* @__PURE__ */ (function(_super) {
2537
+ __extends(SubjectSubscription2, _super);
2538
+ function SubjectSubscription2(subject, subscriber) {
2539
+ var _this = _super.call(this) || this;
2540
+ _this.subject = subject;
2541
+ _this.subscriber = subscriber;
2542
+ _this.closed = false;
2543
+ return _this;
2544
+ }
2545
+ SubjectSubscription2.prototype.unsubscribe = function() {
2546
+ if (this.closed) {
2547
+ return;
2548
+ }
2549
+ this.closed = true;
2550
+ var subject = this.subject;
2551
+ var observers = subject.observers;
2552
+ this.subject = null;
2553
+ if (!observers || observers.length === 0 || subject.isStopped || subject.closed) {
2554
+ return;
2555
+ }
2556
+ var subscriberIndex = observers.indexOf(this.subscriber);
2557
+ if (subscriberIndex !== -1) {
2558
+ observers.splice(subscriberIndex, 1);
2559
+ }
2560
+ };
2561
+ return SubjectSubscription2;
2562
+ })(Subscription);
2563
+
2564
+ // ../../node_modules/rxjs/_esm5/internal/Subject.js
2565
+ var SubjectSubscriber = /* @__PURE__ */ (function(_super) {
2566
+ __extends(SubjectSubscriber2, _super);
2567
+ function SubjectSubscriber2(destination) {
2568
+ var _this = _super.call(this, destination) || this;
2569
+ _this.destination = destination;
2570
+ return _this;
2571
+ }
2572
+ return SubjectSubscriber2;
2573
+ })(Subscriber);
2574
+ var Subject = /* @__PURE__ */ (function(_super) {
2575
+ __extends(Subject2, _super);
2576
+ function Subject2() {
2577
+ var _this = _super.call(this) || this;
2578
+ _this.observers = [];
2579
+ _this.closed = false;
2580
+ _this.isStopped = false;
2581
+ _this.hasError = false;
2582
+ _this.thrownError = null;
2583
+ return _this;
2584
+ }
2585
+ Subject2.prototype[rxSubscriber] = function() {
2586
+ return new SubjectSubscriber(this);
2587
+ };
2588
+ Subject2.prototype.lift = function(operator) {
2589
+ var subject = new AnonymousSubject(this, this);
2590
+ subject.operator = operator;
2591
+ return subject;
2592
+ };
2593
+ Subject2.prototype.next = function(value) {
2594
+ if (this.closed) {
2595
+ throw new ObjectUnsubscribedError();
2596
+ }
2597
+ if (!this.isStopped) {
2598
+ var observers = this.observers;
2599
+ var len = observers.length;
2600
+ var copy = observers.slice();
2601
+ for (var i = 0; i < len; i++) {
2602
+ copy[i].next(value);
2603
+ }
2604
+ }
2605
+ };
2606
+ Subject2.prototype.error = function(err) {
2607
+ if (this.closed) {
2608
+ throw new ObjectUnsubscribedError();
2609
+ }
2610
+ this.hasError = true;
2611
+ this.thrownError = err;
2612
+ this.isStopped = true;
2613
+ var observers = this.observers;
2614
+ var len = observers.length;
2615
+ var copy = observers.slice();
2616
+ for (var i = 0; i < len; i++) {
2617
+ copy[i].error(err);
2618
+ }
2619
+ this.observers.length = 0;
2620
+ };
2621
+ Subject2.prototype.complete = function() {
2622
+ if (this.closed) {
2623
+ throw new ObjectUnsubscribedError();
2624
+ }
2625
+ this.isStopped = true;
2626
+ var observers = this.observers;
2627
+ var len = observers.length;
2628
+ var copy = observers.slice();
2629
+ for (var i = 0; i < len; i++) {
2630
+ copy[i].complete();
2631
+ }
2632
+ this.observers.length = 0;
2633
+ };
2634
+ Subject2.prototype.unsubscribe = function() {
2635
+ this.isStopped = true;
2636
+ this.closed = true;
2637
+ this.observers = null;
2638
+ };
2639
+ Subject2.prototype._trySubscribe = function(subscriber) {
2640
+ if (this.closed) {
2641
+ throw new ObjectUnsubscribedError();
2642
+ } else {
2643
+ return _super.prototype._trySubscribe.call(this, subscriber);
2644
+ }
2645
+ };
2646
+ Subject2.prototype._subscribe = function(subscriber) {
2647
+ if (this.closed) {
2648
+ throw new ObjectUnsubscribedError();
2649
+ } else if (this.hasError) {
2650
+ subscriber.error(this.thrownError);
2651
+ return Subscription.EMPTY;
2652
+ } else if (this.isStopped) {
2653
+ subscriber.complete();
2654
+ return Subscription.EMPTY;
2655
+ } else {
2656
+ this.observers.push(subscriber);
2657
+ return new SubjectSubscription(this, subscriber);
2658
+ }
2659
+ };
2660
+ Subject2.prototype.asObservable = function() {
2661
+ var observable2 = new Observable();
2662
+ observable2.source = this;
2663
+ return observable2;
2664
+ };
2665
+ Subject2.create = function(destination, source) {
2666
+ return new AnonymousSubject(destination, source);
2667
+ };
2668
+ return Subject2;
2669
+ })(Observable);
2670
+ var AnonymousSubject = /* @__PURE__ */ (function(_super) {
2671
+ __extends(AnonymousSubject2, _super);
2672
+ function AnonymousSubject2(destination, source) {
2673
+ var _this = _super.call(this) || this;
2674
+ _this.destination = destination;
2675
+ _this.source = source;
2676
+ return _this;
2677
+ }
2678
+ AnonymousSubject2.prototype.next = function(value) {
2679
+ var destination = this.destination;
2680
+ if (destination && destination.next) {
2681
+ destination.next(value);
2682
+ }
2683
+ };
2684
+ AnonymousSubject2.prototype.error = function(err) {
2685
+ var destination = this.destination;
2686
+ if (destination && destination.error) {
2687
+ this.destination.error(err);
2688
+ }
2689
+ };
2690
+ AnonymousSubject2.prototype.complete = function() {
2691
+ var destination = this.destination;
2692
+ if (destination && destination.complete) {
2693
+ this.destination.complete();
2694
+ }
2695
+ };
2696
+ AnonymousSubject2.prototype._subscribe = function(subscriber) {
2697
+ var source = this.source;
2698
+ if (source) {
2699
+ return this.source.subscribe(subscriber);
2700
+ } else {
2701
+ return Subscription.EMPTY;
2702
+ }
2703
+ };
2704
+ return AnonymousSubject2;
2705
+ })(Subject);
2706
+
2707
+ // ../../node_modules/rxjs/_esm5/internal/operators/groupBy.js
2708
+ function groupBy(keySelector, elementSelector, durationSelector, subjectSelector) {
2709
+ return function(source) {
2710
+ return source.lift(new GroupByOperator(keySelector, elementSelector, durationSelector, subjectSelector));
2711
+ };
2712
+ }
2713
+ var GroupByOperator = /* @__PURE__ */ (function() {
2714
+ function GroupByOperator2(keySelector, elementSelector, durationSelector, subjectSelector) {
2715
+ this.keySelector = keySelector;
2716
+ this.elementSelector = elementSelector;
2717
+ this.durationSelector = durationSelector;
2718
+ this.subjectSelector = subjectSelector;
2719
+ }
2720
+ GroupByOperator2.prototype.call = function(subscriber, source) {
2721
+ return source.subscribe(new GroupBySubscriber(subscriber, this.keySelector, this.elementSelector, this.durationSelector, this.subjectSelector));
2722
+ };
2723
+ return GroupByOperator2;
2724
+ })();
2725
+ var GroupBySubscriber = /* @__PURE__ */ (function(_super) {
2726
+ __extends(GroupBySubscriber2, _super);
2727
+ function GroupBySubscriber2(destination, keySelector, elementSelector, durationSelector, subjectSelector) {
2728
+ var _this = _super.call(this, destination) || this;
2729
+ _this.keySelector = keySelector;
2730
+ _this.elementSelector = elementSelector;
2731
+ _this.durationSelector = durationSelector;
2732
+ _this.subjectSelector = subjectSelector;
2733
+ _this.groups = null;
2734
+ _this.attemptedToUnsubscribe = false;
2735
+ _this.count = 0;
2736
+ return _this;
2737
+ }
2738
+ GroupBySubscriber2.prototype._next = function(value) {
2739
+ var key;
2740
+ try {
2741
+ key = this.keySelector(value);
2742
+ } catch (err) {
2743
+ this.error(err);
2744
+ return;
2745
+ }
2746
+ this._group(value, key);
2747
+ };
2748
+ GroupBySubscriber2.prototype._group = function(value, key) {
2749
+ var groups = this.groups;
2750
+ if (!groups) {
2751
+ groups = this.groups = /* @__PURE__ */ new Map();
2752
+ }
2753
+ var group = groups.get(key);
2754
+ var element;
2755
+ if (this.elementSelector) {
2756
+ try {
2757
+ element = this.elementSelector(value);
2758
+ } catch (err) {
2759
+ this.error(err);
2760
+ }
2761
+ } else {
2762
+ element = value;
2763
+ }
2764
+ if (!group) {
2765
+ group = this.subjectSelector ? this.subjectSelector() : new Subject();
2766
+ groups.set(key, group);
2767
+ var groupedObservable = new GroupedObservable(key, group, this);
2768
+ this.destination.next(groupedObservable);
2769
+ if (this.durationSelector) {
2770
+ var duration = void 0;
2771
+ try {
2772
+ duration = this.durationSelector(new GroupedObservable(key, group));
2773
+ } catch (err) {
2774
+ this.error(err);
2775
+ return;
2776
+ }
2777
+ this.add(duration.subscribe(new GroupDurationSubscriber(key, group, this)));
2778
+ }
2779
+ }
2780
+ if (!group.closed) {
2781
+ group.next(element);
2782
+ }
2783
+ };
2784
+ GroupBySubscriber2.prototype._error = function(err) {
2785
+ var groups = this.groups;
2786
+ if (groups) {
2787
+ groups.forEach(function(group, key) {
2788
+ group.error(err);
2789
+ });
2790
+ groups.clear();
2791
+ }
2792
+ this.destination.error(err);
2793
+ };
2794
+ GroupBySubscriber2.prototype._complete = function() {
2795
+ var groups = this.groups;
2796
+ if (groups) {
2797
+ groups.forEach(function(group, key) {
2798
+ group.complete();
2799
+ });
2800
+ groups.clear();
2801
+ }
2802
+ this.destination.complete();
2803
+ };
2804
+ GroupBySubscriber2.prototype.removeGroup = function(key) {
2805
+ this.groups.delete(key);
2806
+ };
2807
+ GroupBySubscriber2.prototype.unsubscribe = function() {
2808
+ if (!this.closed) {
2809
+ this.attemptedToUnsubscribe = true;
2810
+ if (this.count === 0) {
2811
+ _super.prototype.unsubscribe.call(this);
2812
+ }
2813
+ }
2814
+ };
2815
+ return GroupBySubscriber2;
2816
+ })(Subscriber);
2817
+ var GroupDurationSubscriber = /* @__PURE__ */ (function(_super) {
2818
+ __extends(GroupDurationSubscriber2, _super);
2819
+ function GroupDurationSubscriber2(key, group, parent) {
2820
+ var _this = _super.call(this, group) || this;
2821
+ _this.key = key;
2822
+ _this.group = group;
2823
+ _this.parent = parent;
2824
+ return _this;
2825
+ }
2826
+ GroupDurationSubscriber2.prototype._next = function(value) {
2827
+ this.complete();
2828
+ };
2829
+ GroupDurationSubscriber2.prototype._unsubscribe = function() {
2830
+ var _a = this, parent = _a.parent, key = _a.key;
2831
+ this.key = this.parent = null;
2832
+ if (parent) {
2833
+ parent.removeGroup(key);
2834
+ }
2835
+ };
2836
+ return GroupDurationSubscriber2;
2837
+ })(Subscriber);
2838
+ var GroupedObservable = /* @__PURE__ */ (function(_super) {
2839
+ __extends(GroupedObservable2, _super);
2840
+ function GroupedObservable2(key, groupSubject, refCountSubscription) {
2841
+ var _this = _super.call(this) || this;
2842
+ _this.key = key;
2843
+ _this.groupSubject = groupSubject;
2844
+ _this.refCountSubscription = refCountSubscription;
2845
+ return _this;
2846
+ }
2847
+ GroupedObservable2.prototype._subscribe = function(subscriber) {
2848
+ var subscription = new Subscription();
2849
+ var _a = this, refCountSubscription = _a.refCountSubscription, groupSubject = _a.groupSubject;
2850
+ if (refCountSubscription && !refCountSubscription.closed) {
2851
+ subscription.add(new InnerRefCountSubscription(refCountSubscription));
2852
+ }
2853
+ subscription.add(groupSubject.subscribe(subscriber));
2854
+ return subscription;
2855
+ };
2856
+ return GroupedObservable2;
2857
+ })(Observable);
2858
+ var InnerRefCountSubscription = /* @__PURE__ */ (function(_super) {
2859
+ __extends(InnerRefCountSubscription2, _super);
2860
+ function InnerRefCountSubscription2(parent) {
2861
+ var _this = _super.call(this) || this;
2862
+ _this.parent = parent;
2863
+ parent.count++;
2864
+ return _this;
2865
+ }
2866
+ InnerRefCountSubscription2.prototype.unsubscribe = function() {
2867
+ var parent = this.parent;
2868
+ if (!parent.closed && !this.closed) {
2869
+ _super.prototype.unsubscribe.call(this);
2870
+ parent.count -= 1;
2871
+ if (parent.count === 0 && parent.attemptedToUnsubscribe) {
2872
+ parent.unsubscribe();
2873
+ }
2874
+ }
2875
+ };
2876
+ return InnerRefCountSubscription2;
2877
+ })(Subscription);
2878
+
2879
+ // ../../node_modules/rxjs/_esm5/internal/util/subscribeToArray.js
2880
+ var subscribeToArray = function(array) {
2881
+ return function(subscriber) {
2882
+ for (var i = 0, len = array.length; i < len && !subscriber.closed; i++) {
2883
+ subscriber.next(array[i]);
2884
+ }
2885
+ subscriber.complete();
2886
+ };
2887
+ };
2888
+
2889
+ // ../../node_modules/rxjs/_esm5/internal/scheduled/scheduleArray.js
2890
+ function scheduleArray(input, scheduler) {
2891
+ return new Observable(function(subscriber) {
2892
+ var sub = new Subscription();
2893
+ var i = 0;
2894
+ sub.add(scheduler.schedule(function() {
2895
+ if (i === input.length) {
2896
+ subscriber.complete();
2897
+ return;
2898
+ }
2899
+ subscriber.next(input[i++]);
2900
+ if (!subscriber.closed) {
2901
+ sub.add(this.schedule());
2902
+ }
2903
+ }));
2904
+ return sub;
2905
+ });
2906
+ }
2907
+
2908
+ // ../../node_modules/rxjs/_esm5/internal/operators/map.js
2909
+ function map(project, thisArg) {
2910
+ return function mapOperation(source) {
2911
+ if (typeof project !== "function") {
2912
+ throw new TypeError("argument is not a function. Are you looking for `mapTo()`?");
2913
+ }
2914
+ return source.lift(new MapOperator(project, thisArg));
2915
+ };
2916
+ }
2917
+ var MapOperator = /* @__PURE__ */ (function() {
2918
+ function MapOperator2(project, thisArg) {
2919
+ this.project = project;
2920
+ this.thisArg = thisArg;
2921
+ }
2922
+ MapOperator2.prototype.call = function(subscriber, source) {
2923
+ return source.subscribe(new MapSubscriber(subscriber, this.project, this.thisArg));
2924
+ };
2925
+ return MapOperator2;
2926
+ })();
2927
+ var MapSubscriber = /* @__PURE__ */ (function(_super) {
2928
+ __extends(MapSubscriber2, _super);
2929
+ function MapSubscriber2(destination, project, thisArg) {
2930
+ var _this = _super.call(this, destination) || this;
2931
+ _this.project = project;
2932
+ _this.count = 0;
2933
+ _this.thisArg = thisArg || _this;
2934
+ return _this;
2935
+ }
2936
+ MapSubscriber2.prototype._next = function(value) {
2937
+ var result;
2938
+ try {
2939
+ result = this.project.call(this.thisArg, value, this.count++);
2940
+ } catch (err) {
2941
+ this.destination.error(err);
2942
+ return;
2943
+ }
2944
+ this.destination.next(result);
2945
+ };
2946
+ return MapSubscriber2;
2947
+ })(Subscriber);
2948
+
2949
+ // ../../node_modules/rxjs/_esm5/internal/util/subscribeToPromise.js
2950
+ var subscribeToPromise = function(promise) {
2951
+ return function(subscriber) {
2952
+ promise.then(function(value) {
2953
+ if (!subscriber.closed) {
2954
+ subscriber.next(value);
2955
+ subscriber.complete();
2956
+ }
2957
+ }, function(err) {
2958
+ return subscriber.error(err);
2959
+ }).then(null, hostReportError);
2960
+ return subscriber;
2961
+ };
2962
+ };
2963
+
2964
+ // ../../node_modules/rxjs/_esm5/internal/symbol/iterator.js
2965
+ function getSymbolIterator() {
2966
+ if (typeof Symbol !== "function" || !Symbol.iterator) {
2967
+ return "@@iterator";
2968
+ }
2969
+ return Symbol.iterator;
2970
+ }
2971
+ var iterator = /* @__PURE__ */ getSymbolIterator();
2972
+
2973
+ // ../../node_modules/rxjs/_esm5/internal/util/subscribeToIterable.js
2974
+ var subscribeToIterable = function(iterable) {
2975
+ return function(subscriber) {
2976
+ var iterator2 = iterable[iterator]();
2977
+ do {
2978
+ var item = void 0;
2979
+ try {
2980
+ item = iterator2.next();
2981
+ } catch (err) {
2982
+ subscriber.error(err);
2983
+ return subscriber;
2984
+ }
2985
+ if (item.done) {
2986
+ subscriber.complete();
2987
+ break;
2988
+ }
2989
+ subscriber.next(item.value);
2990
+ if (subscriber.closed) {
2991
+ break;
2992
+ }
2993
+ } while (true);
2994
+ if (typeof iterator2.return === "function") {
2995
+ subscriber.add(function() {
2996
+ if (iterator2.return) {
2997
+ iterator2.return();
2998
+ }
2999
+ });
3000
+ }
3001
+ return subscriber;
3002
+ };
3003
+ };
3004
+
3005
+ // ../../node_modules/rxjs/_esm5/internal/util/subscribeToObservable.js
3006
+ var subscribeToObservable = function(obj) {
3007
+ return function(subscriber) {
3008
+ var obs = obj[observable]();
3009
+ if (typeof obs.subscribe !== "function") {
3010
+ throw new TypeError("Provided object does not correctly implement Symbol.observable");
3011
+ } else {
3012
+ return obs.subscribe(subscriber);
3013
+ }
3014
+ };
3015
+ };
3016
+
3017
+ // ../../node_modules/rxjs/_esm5/internal/util/isArrayLike.js
3018
+ var isArrayLike = (function(x) {
3019
+ return x && typeof x.length === "number" && typeof x !== "function";
3020
+ });
3021
+
3022
+ // ../../node_modules/rxjs/_esm5/internal/util/isPromise.js
3023
+ function isPromise(value) {
3024
+ return !!value && typeof value.subscribe !== "function" && typeof value.then === "function";
3025
+ }
3026
+
3027
+ // ../../node_modules/rxjs/_esm5/internal/util/subscribeTo.js
3028
+ var subscribeTo = function(result) {
3029
+ if (!!result && typeof result[observable] === "function") {
3030
+ return subscribeToObservable(result);
3031
+ } else if (isArrayLike(result)) {
3032
+ return subscribeToArray(result);
3033
+ } else if (isPromise(result)) {
3034
+ return subscribeToPromise(result);
3035
+ } else if (!!result && typeof result[iterator] === "function") {
3036
+ return subscribeToIterable(result);
3037
+ } else {
3038
+ var value = isObject(result) ? "an invalid object" : "'" + result + "'";
3039
+ var msg = "You provided " + value + " where a stream was expected. You can provide an Observable, Promise, Array, or Iterable.";
3040
+ throw new TypeError(msg);
3041
+ }
3042
+ };
3043
+
3044
+ // ../../node_modules/rxjs/_esm5/internal/scheduled/scheduleObservable.js
3045
+ function scheduleObservable(input, scheduler) {
3046
+ return new Observable(function(subscriber) {
3047
+ var sub = new Subscription();
3048
+ sub.add(scheduler.schedule(function() {
3049
+ var observable2 = input[observable]();
3050
+ sub.add(observable2.subscribe({
3051
+ next: function(value) {
3052
+ sub.add(scheduler.schedule(function() {
3053
+ return subscriber.next(value);
3054
+ }));
3055
+ },
3056
+ error: function(err) {
3057
+ sub.add(scheduler.schedule(function() {
3058
+ return subscriber.error(err);
3059
+ }));
3060
+ },
3061
+ complete: function() {
3062
+ sub.add(scheduler.schedule(function() {
3063
+ return subscriber.complete();
3064
+ }));
3065
+ }
3066
+ }));
3067
+ }));
3068
+ return sub;
3069
+ });
3070
+ }
3071
+
3072
+ // ../../node_modules/rxjs/_esm5/internal/scheduled/schedulePromise.js
3073
+ function schedulePromise(input, scheduler) {
3074
+ return new Observable(function(subscriber) {
3075
+ var sub = new Subscription();
3076
+ sub.add(scheduler.schedule(function() {
3077
+ return input.then(function(value) {
3078
+ sub.add(scheduler.schedule(function() {
3079
+ subscriber.next(value);
3080
+ sub.add(scheduler.schedule(function() {
3081
+ return subscriber.complete();
3082
+ }));
3083
+ }));
3084
+ }, function(err) {
3085
+ sub.add(scheduler.schedule(function() {
3086
+ return subscriber.error(err);
3087
+ }));
3088
+ });
3089
+ }));
3090
+ return sub;
3091
+ });
3092
+ }
3093
+
3094
+ // ../../node_modules/rxjs/_esm5/internal/scheduled/scheduleIterable.js
3095
+ function scheduleIterable(input, scheduler) {
3096
+ if (!input) {
3097
+ throw new Error("Iterable cannot be null");
3098
+ }
3099
+ return new Observable(function(subscriber) {
3100
+ var sub = new Subscription();
3101
+ var iterator2;
3102
+ sub.add(function() {
3103
+ if (iterator2 && typeof iterator2.return === "function") {
3104
+ iterator2.return();
3105
+ }
3106
+ });
3107
+ sub.add(scheduler.schedule(function() {
3108
+ iterator2 = input[iterator]();
3109
+ sub.add(scheduler.schedule(function() {
3110
+ if (subscriber.closed) {
3111
+ return;
3112
+ }
3113
+ var value;
3114
+ var done;
3115
+ try {
3116
+ var result = iterator2.next();
3117
+ value = result.value;
3118
+ done = result.done;
3119
+ } catch (err) {
3120
+ subscriber.error(err);
3121
+ return;
3122
+ }
3123
+ if (done) {
3124
+ subscriber.complete();
3125
+ } else {
3126
+ subscriber.next(value);
3127
+ this.schedule();
3128
+ }
3129
+ }));
3130
+ }));
3131
+ return sub;
3132
+ });
3133
+ }
3134
+
3135
+ // ../../node_modules/rxjs/_esm5/internal/util/isInteropObservable.js
3136
+ function isInteropObservable(input) {
3137
+ return input && typeof input[observable] === "function";
3138
+ }
3139
+
3140
+ // ../../node_modules/rxjs/_esm5/internal/util/isIterable.js
3141
+ function isIterable(input) {
3142
+ return input && typeof input[iterator] === "function";
3143
+ }
3144
+
3145
+ // ../../node_modules/rxjs/_esm5/internal/scheduled/scheduled.js
3146
+ function scheduled(input, scheduler) {
3147
+ if (input != null) {
3148
+ if (isInteropObservable(input)) {
3149
+ return scheduleObservable(input, scheduler);
3150
+ } else if (isPromise(input)) {
3151
+ return schedulePromise(input, scheduler);
3152
+ } else if (isArrayLike(input)) {
3153
+ return scheduleArray(input, scheduler);
3154
+ } else if (isIterable(input) || typeof input === "string") {
3155
+ return scheduleIterable(input, scheduler);
3156
+ }
3157
+ }
3158
+ throw new TypeError((input !== null && typeof input || input) + " is not observable");
3159
+ }
3160
+
3161
+ // ../../node_modules/rxjs/_esm5/internal/observable/from.js
3162
+ function from(input, scheduler) {
3163
+ if (!scheduler) {
3164
+ if (input instanceof Observable) {
3165
+ return input;
3166
+ }
3167
+ return new Observable(subscribeTo(input));
3168
+ } else {
3169
+ return scheduled(input, scheduler);
3170
+ }
3171
+ }
3172
+
3173
+ // ../../node_modules/rxjs/_esm5/internal/innerSubscribe.js
3174
+ var SimpleInnerSubscriber = /* @__PURE__ */ (function(_super) {
3175
+ __extends(SimpleInnerSubscriber2, _super);
3176
+ function SimpleInnerSubscriber2(parent) {
3177
+ var _this = _super.call(this) || this;
3178
+ _this.parent = parent;
3179
+ return _this;
3180
+ }
3181
+ SimpleInnerSubscriber2.prototype._next = function(value) {
3182
+ this.parent.notifyNext(value);
3183
+ };
3184
+ SimpleInnerSubscriber2.prototype._error = function(error) {
3185
+ this.parent.notifyError(error);
3186
+ this.unsubscribe();
3187
+ };
3188
+ SimpleInnerSubscriber2.prototype._complete = function() {
3189
+ this.parent.notifyComplete();
3190
+ this.unsubscribe();
3191
+ };
3192
+ return SimpleInnerSubscriber2;
3193
+ })(Subscriber);
3194
+ var SimpleOuterSubscriber = /* @__PURE__ */ (function(_super) {
3195
+ __extends(SimpleOuterSubscriber2, _super);
3196
+ function SimpleOuterSubscriber2() {
3197
+ return _super !== null && _super.apply(this, arguments) || this;
3198
+ }
3199
+ SimpleOuterSubscriber2.prototype.notifyNext = function(innerValue) {
3200
+ this.destination.next(innerValue);
3201
+ };
3202
+ SimpleOuterSubscriber2.prototype.notifyError = function(err) {
3203
+ this.destination.error(err);
3204
+ };
3205
+ SimpleOuterSubscriber2.prototype.notifyComplete = function() {
3206
+ this.destination.complete();
3207
+ };
3208
+ return SimpleOuterSubscriber2;
3209
+ })(Subscriber);
3210
+ function innerSubscribe(result, innerSubscriber) {
3211
+ if (innerSubscriber.closed) {
3212
+ return void 0;
3213
+ }
3214
+ if (result instanceof Observable) {
3215
+ return result.subscribe(innerSubscriber);
3216
+ }
3217
+ var subscription;
3218
+ try {
3219
+ subscription = subscribeTo(result)(innerSubscriber);
3220
+ } catch (error) {
3221
+ innerSubscriber.error(error);
3222
+ }
3223
+ return subscription;
3224
+ }
3225
+
3226
+ // ../../node_modules/rxjs/_esm5/internal/operators/mergeMap.js
3227
+ function mergeMap(project, resultSelector, concurrent) {
3228
+ if (concurrent === void 0) {
3229
+ concurrent = Number.POSITIVE_INFINITY;
3230
+ }
3231
+ if (typeof resultSelector === "function") {
3232
+ return function(source) {
3233
+ return source.pipe(mergeMap(function(a, i) {
3234
+ return from(project(a, i)).pipe(map(function(b, ii) {
3235
+ return resultSelector(a, b, i, ii);
3236
+ }));
3237
+ }, concurrent));
3238
+ };
3239
+ } else if (typeof resultSelector === "number") {
3240
+ concurrent = resultSelector;
3241
+ }
3242
+ return function(source) {
3243
+ return source.lift(new MergeMapOperator(project, concurrent));
3244
+ };
3245
+ }
3246
+ var MergeMapOperator = /* @__PURE__ */ (function() {
3247
+ function MergeMapOperator2(project, concurrent) {
3248
+ if (concurrent === void 0) {
3249
+ concurrent = Number.POSITIVE_INFINITY;
3250
+ }
3251
+ this.project = project;
3252
+ this.concurrent = concurrent;
3253
+ }
3254
+ MergeMapOperator2.prototype.call = function(observer, source) {
3255
+ return source.subscribe(new MergeMapSubscriber(observer, this.project, this.concurrent));
3256
+ };
3257
+ return MergeMapOperator2;
3258
+ })();
3259
+ var MergeMapSubscriber = /* @__PURE__ */ (function(_super) {
3260
+ __extends(MergeMapSubscriber2, _super);
3261
+ function MergeMapSubscriber2(destination, project, concurrent) {
3262
+ if (concurrent === void 0) {
3263
+ concurrent = Number.POSITIVE_INFINITY;
3264
+ }
3265
+ var _this = _super.call(this, destination) || this;
3266
+ _this.project = project;
3267
+ _this.concurrent = concurrent;
3268
+ _this.hasCompleted = false;
3269
+ _this.buffer = [];
3270
+ _this.active = 0;
3271
+ _this.index = 0;
3272
+ return _this;
3273
+ }
3274
+ MergeMapSubscriber2.prototype._next = function(value) {
3275
+ if (this.active < this.concurrent) {
3276
+ this._tryNext(value);
3277
+ } else {
3278
+ this.buffer.push(value);
3279
+ }
3280
+ };
3281
+ MergeMapSubscriber2.prototype._tryNext = function(value) {
3282
+ var result;
3283
+ var index = this.index++;
3284
+ try {
3285
+ result = this.project(value, index);
3286
+ } catch (err) {
3287
+ this.destination.error(err);
3288
+ return;
3289
+ }
3290
+ this.active++;
3291
+ this._innerSub(result);
3292
+ };
3293
+ MergeMapSubscriber2.prototype._innerSub = function(ish) {
3294
+ var innerSubscriber = new SimpleInnerSubscriber(this);
3295
+ var destination = this.destination;
3296
+ destination.add(innerSubscriber);
3297
+ var innerSubscription = innerSubscribe(ish, innerSubscriber);
3298
+ if (innerSubscription !== innerSubscriber) {
3299
+ destination.add(innerSubscription);
3300
+ }
3301
+ };
3302
+ MergeMapSubscriber2.prototype._complete = function() {
3303
+ this.hasCompleted = true;
3304
+ if (this.active === 0 && this.buffer.length === 0) {
3305
+ this.destination.complete();
3306
+ }
3307
+ this.unsubscribe();
3308
+ };
3309
+ MergeMapSubscriber2.prototype.notifyNext = function(innerValue) {
3310
+ this.destination.next(innerValue);
3311
+ };
3312
+ MergeMapSubscriber2.prototype.notifyComplete = function() {
3313
+ var buffer = this.buffer;
3314
+ this.active--;
3315
+ if (buffer.length > 0) {
3316
+ this._next(buffer.shift());
3317
+ } else if (this.active === 0 && this.hasCompleted) {
3318
+ this.destination.complete();
3319
+ }
3320
+ };
3321
+ return MergeMapSubscriber2;
3322
+ })(SimpleOuterSubscriber);
3323
+
3324
+ // ../../node_modules/rxjs/_esm5/internal/operators/concatMap.js
3325
+ function concatMap(project, resultSelector) {
3326
+ return mergeMap(project, resultSelector, 1);
3327
+ }
3328
+
1918
3329
  // src/graph/consumer.ts
1919
3330
  import { EventQuery } from "@semiont/event-sourcing";
1920
- import { didToAgent } from "@semiont/core";
3331
+ import { didToAgent, burstBuffer } from "@semiont/core";
1921
3332
  import { resourceId as makeResourceId, findBodyItem } from "@semiont/core";
1922
3333
  import { toResourceUri, toAnnotationUri } from "@semiont/event-sourcing";
1923
- var GraphDBConsumer = class {
1924
- constructor(config, eventStore, graphDb, logger) {
1925
- this.config = config;
3334
+ var GraphDBConsumer = class _GraphDBConsumer {
3335
+ constructor(config2, eventStore, graphDb, logger) {
3336
+ this.config = config2;
1926
3337
  this.eventStore = eventStore;
1927
3338
  this.graphDb = graphDb;
1928
3339
  this.logger = logger;
1929
3340
  }
3341
+ // Event types that produce GraphDB mutations — filter everything else
3342
+ static GRAPH_RELEVANT_EVENTS = /* @__PURE__ */ new Set([
3343
+ "resource.created",
3344
+ "resource.archived",
3345
+ "resource.unarchived",
3346
+ "annotation.added",
3347
+ "annotation.removed",
3348
+ "annotation.body.updated",
3349
+ "entitytag.added",
3350
+ "entitytag.removed",
3351
+ "entitytype.added"
3352
+ ]);
3353
+ // Burst buffer thresholds — see class doc and BATCH-GRAPH-CONSUMER-RX.md
3354
+ static BURST_WINDOW_MS = 50;
3355
+ static MAX_BATCH_SIZE = 500;
3356
+ static IDLE_TIMEOUT_MS = 200;
1930
3357
  _globalSubscription = null;
1931
- // Global subscription (receives ALL events)
1932
- processing = /* @__PURE__ */ new Map();
3358
+ eventSubject = new Subject();
3359
+ pipelineSubscription = null;
1933
3360
  lastProcessed = /* @__PURE__ */ new Map();
1934
3361
  logger;
1935
3362
  async initialize() {
@@ -1937,20 +3364,70 @@ var GraphDBConsumer = class {
1937
3364
  await this.subscribeToGlobalEvents();
1938
3365
  }
1939
3366
  /**
1940
- * Subscribe globally to ALL events (system AND resource events)
1941
- * Resource events are now sent to global subscribers (see EventBus.publish)
3367
+ * Subscribe globally to ALL events, pre-filter to graph-relevant types,
3368
+ * and wire through the RxJS burst-buffered pipeline.
1942
3369
  */
1943
3370
  async subscribeToGlobalEvents() {
1944
- this._globalSubscription = this.eventStore.bus.subscriptions.subscribeGlobal(async (storedEvent) => {
1945
- await this.processEvent(storedEvent);
3371
+ this._globalSubscription = this.eventStore.bus.subscriptions.subscribeGlobal(
3372
+ (storedEvent) => {
3373
+ if (!_GraphDBConsumer.GRAPH_RELEVANT_EVENTS.has(storedEvent.event.type)) return;
3374
+ this.eventSubject.next(storedEvent);
3375
+ }
3376
+ );
3377
+ this.pipelineSubscription = this.eventSubject.pipe(
3378
+ // Split into one inner Observable per resource (system events grouped under '__system__')
3379
+ groupBy((se) => se.event.resourceId ?? "__system__"),
3380
+ mergeMap((group) => {
3381
+ if (group.key === "__system__") {
3382
+ return group.pipe(
3383
+ concatMap((se) => from(this.safeApplyEvent(se)))
3384
+ );
3385
+ }
3386
+ return group.pipe(
3387
+ burstBuffer({
3388
+ burstWindowMs: _GraphDBConsumer.BURST_WINDOW_MS,
3389
+ maxBatchSize: _GraphDBConsumer.MAX_BATCH_SIZE,
3390
+ idleTimeoutMs: _GraphDBConsumer.IDLE_TIMEOUT_MS
3391
+ }),
3392
+ concatMap((eventOrBatch) => {
3393
+ if (Array.isArray(eventOrBatch)) {
3394
+ return from(this.processBatch(eventOrBatch));
3395
+ }
3396
+ return from(this.safeApplyEvent(eventOrBatch).then(() => {
3397
+ this.lastProcessed.set(
3398
+ eventOrBatch.event.resourceId,
3399
+ eventOrBatch.metadata.sequenceNumber
3400
+ );
3401
+ }));
3402
+ })
3403
+ );
3404
+ })
3405
+ ).subscribe({
3406
+ error: (err) => {
3407
+ this.logger.error("GraphDB consumer pipeline error", { error: err });
3408
+ }
1946
3409
  });
1947
- this.logger.info("Subscribed to global events (system + resource)");
3410
+ this.logger.info("Subscribed to global events with burst-buffered pipeline");
3411
+ }
3412
+ /**
3413
+ * Wrap applyEventToGraph in try/catch so one failed event doesn't kill the pipeline.
3414
+ */
3415
+ async safeApplyEvent(storedEvent) {
3416
+ try {
3417
+ await this.applyEventToGraph(storedEvent);
3418
+ } catch (error) {
3419
+ this.logger.error("Failed to apply event to graph", {
3420
+ eventType: storedEvent.event.type,
3421
+ resourceId: storedEvent.event.resourceId,
3422
+ error
3423
+ });
3424
+ }
1948
3425
  }
1949
3426
  ensureInitialized() {
1950
3427
  return this.graphDb;
1951
3428
  }
1952
3429
  /**
1953
- * Stop the consumer and unsubscribe from all events
3430
+ * Stop the consumer, flush remaining buffered events, and unsubscribe.
1954
3431
  */
1955
3432
  async stop() {
1956
3433
  this.logger.info("Stopping GraphDB consumer");
@@ -1958,35 +3435,119 @@ var GraphDBConsumer = class {
1958
3435
  this._globalSubscription.unsubscribe();
1959
3436
  }
1960
3437
  this._globalSubscription = null;
3438
+ this.eventSubject.complete();
3439
+ if (this.pipelineSubscription) {
3440
+ this.pipelineSubscription.unsubscribe();
3441
+ this.pipelineSubscription = null;
3442
+ }
3443
+ this.eventSubject = new Subject();
1961
3444
  this.logger.info("GraphDB consumer stopped");
1962
3445
  }
1963
3446
  /**
1964
- * Process event with ordering guarantee (sequential per resource)
3447
+ * Process a batch of events for the same resource.
3448
+ * Partitions into consecutive same-type runs for batch optimization.
1965
3449
  */
1966
- async processEvent(storedEvent) {
1967
- const { resourceId: resourceId3 } = storedEvent.event;
1968
- if (!resourceId3) {
1969
- await this.applyEventToGraph(storedEvent);
1970
- return;
3450
+ async processBatch(events) {
3451
+ const runs = [];
3452
+ let currentRun = [];
3453
+ for (const event of events) {
3454
+ if (currentRun.length > 0 && currentRun[0].event.type !== event.event.type) {
3455
+ runs.push(currentRun);
3456
+ currentRun = [];
3457
+ }
3458
+ currentRun.push(event);
1971
3459
  }
1972
- const previousProcessing = this.processing.get(resourceId3);
1973
- if (previousProcessing) {
1974
- await previousProcessing;
3460
+ if (currentRun.length > 0) runs.push(currentRun);
3461
+ for (const run of runs) {
3462
+ try {
3463
+ if (run.length === 1) {
3464
+ await this.applyEventToGraph(run[0]);
3465
+ } else {
3466
+ await this.applyBatchByType(run);
3467
+ }
3468
+ } catch (error) {
3469
+ this.logger.error("Failed to process batch run", {
3470
+ eventType: run[0].event.type,
3471
+ runSize: run.length,
3472
+ error
3473
+ });
3474
+ }
3475
+ const last = run[run.length - 1];
3476
+ if (last.event.resourceId) {
3477
+ this.lastProcessed.set(last.event.resourceId, last.metadata.sequenceNumber);
3478
+ }
1975
3479
  }
1976
- const processingPromise = this.applyEventToGraph(storedEvent);
1977
- this.processing.set(resourceId3, processingPromise);
1978
- try {
1979
- await processingPromise;
1980
- this.lastProcessed.set(resourceId3, storedEvent.metadata.sequenceNumber);
1981
- } catch (error) {
1982
- this.logger.error("Failed to process event", { error });
1983
- throw error;
1984
- } finally {
1985
- this.processing.delete(resourceId3);
3480
+ this.logger.debug("Processed batch", {
3481
+ resourceId: events[0]?.event.resourceId,
3482
+ batchSize: events.length
3483
+ });
3484
+ }
3485
+ /**
3486
+ * Batch-optimized processing for consecutive events of the same type.
3487
+ * Uses batch graph methods where available, falls back to sequential.
3488
+ */
3489
+ async applyBatchByType(events) {
3490
+ const graphDb = this.ensureInitialized();
3491
+ const type = events[0].event.type;
3492
+ switch (type) {
3493
+ case "resource.created": {
3494
+ const resources = events.map((e) => this.buildResourceDescriptor(e));
3495
+ await graphDb.batchCreateResources(resources);
3496
+ this.logger.info("Batch created resources in graph", { count: events.length });
3497
+ break;
3498
+ }
3499
+ case "annotation.added": {
3500
+ const inputs = events.map((e) => {
3501
+ const event = e.event;
3502
+ return {
3503
+ ...event.payload.annotation,
3504
+ creator: didToAgent(event.userId)
3505
+ };
3506
+ });
3507
+ await graphDb.createAnnotations(inputs);
3508
+ this.logger.info("Batch created annotations in graph", { count: events.length });
3509
+ break;
3510
+ }
3511
+ default:
3512
+ for (const event of events) {
3513
+ await this.applyEventToGraph(event);
3514
+ }
3515
+ }
3516
+ }
3517
+ /**
3518
+ * Build a ResourceDescriptor from a resource.created event.
3519
+ * Extracted for reuse by both applyEventToGraph and applyBatchByType.
3520
+ */
3521
+ buildResourceDescriptor(storedEvent) {
3522
+ const event = storedEvent.event;
3523
+ if (event.type !== "resource.created") {
3524
+ throw new Error("Expected resource.created event");
3525
+ }
3526
+ if (!event.resourceId) {
3527
+ throw new Error("resource.created requires resourceId");
1986
3528
  }
3529
+ const resourceUri2 = toResourceUri(
3530
+ { baseUrl: this.config.services.backend.publicURL },
3531
+ event.resourceId
3532
+ );
3533
+ return {
3534
+ "@context": "https://schema.org/",
3535
+ "@id": resourceUri2,
3536
+ name: event.payload.name,
3537
+ entityTypes: event.payload.entityTypes || [],
3538
+ representations: [{
3539
+ mediaType: event.payload.format,
3540
+ checksum: event.payload.contentChecksum,
3541
+ rel: "original"
3542
+ }],
3543
+ archived: false,
3544
+ dateCreated: (/* @__PURE__ */ new Date()).toISOString(),
3545
+ wasAttributedTo: didToAgent(event.userId),
3546
+ creationMethod: event.payload.creationMethod
3547
+ };
1987
3548
  }
1988
3549
  /**
1989
- * Apply event to GraphDB
3550
+ * Apply a single event to GraphDB.
1990
3551
  */
1991
3552
  async applyEventToGraph(storedEvent) {
1992
3553
  const graphDb = this.ensureInitialized();
@@ -1997,26 +3558,10 @@ var GraphDBConsumer = class {
1997
3558
  });
1998
3559
  switch (event.type) {
1999
3560
  case "resource.created": {
2000
- if (!event.resourceId) throw new Error("resource.created requires resourceId");
2001
- const resourceUri2 = toResourceUri({ baseUrl: this.config.services.backend.publicURL }, event.resourceId);
2002
- const resource = {
2003
- "@context": "https://schema.org/",
2004
- "@id": resourceUri2,
2005
- name: event.payload.name,
2006
- entityTypes: event.payload.entityTypes || [],
2007
- representations: [{
2008
- mediaType: event.payload.format,
2009
- checksum: event.payload.contentChecksum,
2010
- rel: "original"
2011
- }],
2012
- archived: false,
2013
- dateCreated: (/* @__PURE__ */ new Date()).toISOString(),
2014
- wasAttributedTo: didToAgent(event.userId),
2015
- creationMethod: event.payload.creationMethod
2016
- };
2017
- this.logger.debug("Creating resource in graph", { resourceUri: resourceUri2 });
3561
+ const resource = this.buildResourceDescriptor(storedEvent);
3562
+ this.logger.debug("Creating resource in graph", { resourceUri: resource["@id"] });
2018
3563
  await graphDb.createResource(resource);
2019
- this.logger.info("Resource created in graph", { resourceUri: resourceUri2 });
3564
+ this.logger.info("Resource created in graph", { resourceUri: resource["@id"] });
2020
3565
  break;
2021
3566
  }
2022
3567
  case "resource.archived":
@@ -2053,44 +3598,27 @@ var GraphDBConsumer = class {
2053
3598
  });
2054
3599
  try {
2055
3600
  const annotationUri2 = toAnnotationUri({ baseUrl: this.config.services.backend.publicURL }, event.payload.annotationId);
2056
- this.logger.debug("Created annotation URI", { annotationUri: annotationUri2 });
2057
- this.logger.debug("Processing body update", {
2058
- annotationUri: annotationUri2,
2059
- operations: event.payload.operations
2060
- });
2061
3601
  const currentAnnotation = await graphDb.getAnnotation(annotationUri2);
2062
- this.logger.debug("Current annotation lookup result", {
2063
- found: !!currentAnnotation
2064
- });
2065
3602
  if (currentAnnotation) {
2066
- this.logger.debug("Current annotation body", { body: currentAnnotation.body });
2067
3603
  let bodyArray = Array.isArray(currentAnnotation.body) ? [...currentAnnotation.body] : currentAnnotation.body ? [currentAnnotation.body] : [];
2068
3604
  for (const op of event.payload.operations) {
2069
- this.logger.debug("Applying body operation", { operation: op });
2070
3605
  if (op.op === "add") {
2071
3606
  const exists = findBodyItem(bodyArray, op.item) !== -1;
2072
3607
  if (!exists) {
2073
3608
  bodyArray.push(op.item);
2074
- this.logger.debug("Added item to body");
2075
- } else {
2076
- this.logger.debug("Item already exists, skipping");
2077
3609
  }
2078
3610
  } else if (op.op === "remove") {
2079
3611
  const index = findBodyItem(bodyArray, op.item);
2080
3612
  if (index !== -1) {
2081
3613
  bodyArray.splice(index, 1);
2082
- this.logger.debug("Removed item from body");
2083
3614
  }
2084
3615
  } else if (op.op === "replace") {
2085
3616
  const index = findBodyItem(bodyArray, op.oldItem);
2086
3617
  if (index !== -1) {
2087
3618
  bodyArray[index] = op.newItem;
2088
- this.logger.debug("Replaced item in body");
2089
3619
  }
2090
3620
  }
2091
3621
  }
2092
- this.logger.debug("New body array", { bodyArray });
2093
- this.logger.debug("Calling updateAnnotation");
2094
3622
  await graphDb.updateAnnotation(annotationUri2, {
2095
3623
  body: bodyArray
2096
3624
  });
@@ -2108,20 +3636,24 @@ var GraphDBConsumer = class {
2108
3636
  break;
2109
3637
  case "entitytag.added":
2110
3638
  if (!event.resourceId) throw new Error("entitytag.added requires resourceId");
2111
- const doc = await graphDb.getResource(toResourceUri({ baseUrl: this.config.services.backend.publicURL }, event.resourceId));
2112
- if (doc) {
2113
- await graphDb.updateResource(toResourceUri({ baseUrl: this.config.services.backend.publicURL }, event.resourceId), {
2114
- entityTypes: [...doc.entityTypes || [], event.payload.entityType]
2115
- });
3639
+ {
3640
+ const doc = await graphDb.getResource(toResourceUri({ baseUrl: this.config.services.backend.publicURL }, event.resourceId));
3641
+ if (doc) {
3642
+ await graphDb.updateResource(toResourceUri({ baseUrl: this.config.services.backend.publicURL }, event.resourceId), {
3643
+ entityTypes: [...doc.entityTypes || [], event.payload.entityType]
3644
+ });
3645
+ }
2116
3646
  }
2117
3647
  break;
2118
3648
  case "entitytag.removed":
2119
3649
  if (!event.resourceId) throw new Error("entitytag.removed requires resourceId");
2120
- const doc2 = await graphDb.getResource(toResourceUri({ baseUrl: this.config.services.backend.publicURL }, event.resourceId));
2121
- if (doc2) {
2122
- await graphDb.updateResource(toResourceUri({ baseUrl: this.config.services.backend.publicURL }, event.resourceId), {
2123
- entityTypes: (doc2.entityTypes || []).filter((t) => t !== event.payload.entityType)
2124
- });
3650
+ {
3651
+ const doc = await graphDb.getResource(toResourceUri({ baseUrl: this.config.services.backend.publicURL }, event.resourceId));
3652
+ if (doc) {
3653
+ await graphDb.updateResource(toResourceUri({ baseUrl: this.config.services.backend.publicURL }, event.resourceId), {
3654
+ entityTypes: (doc.entityTypes || []).filter((t) => t !== event.payload.entityType)
3655
+ });
3656
+ }
2125
3657
  }
2126
3658
  break;
2127
3659
  case "entitytype.added":
@@ -2132,8 +3664,8 @@ var GraphDBConsumer = class {
2132
3664
  }
2133
3665
  }
2134
3666
  /**
2135
- * Rebuild entire resource from events
2136
- * Useful for recovery or initial sync
3667
+ * Rebuild entire resource from events.
3668
+ * Bypasses the live pipeline reads directly from event store.
2137
3669
  */
2138
3670
  async rebuildResource(resourceId3) {
2139
3671
  const graphDb = this.ensureInitialized();
@@ -2151,8 +3683,9 @@ var GraphDBConsumer = class {
2151
3683
  this.logger.info("Resource rebuild complete", { resourceId: resourceId3, eventCount: events.length });
2152
3684
  }
2153
3685
  /**
2154
- * Rebuild entire GraphDB from all events
2155
- * Uses two-pass approach to ensure all resources exist before creating REFERENCES edges
3686
+ * Rebuild entire GraphDB from all events.
3687
+ * Uses two-pass approach to ensure all resources exist before creating REFERENCES edges.
3688
+ * Bypasses the live pipeline — reads directly from event store.
2156
3689
  */
2157
3690
  async rebuildAll() {
2158
3691
  const graphDb = this.ensureInitialized();
@@ -2186,25 +3719,20 @@ var GraphDBConsumer = class {
2186
3719
  this.logger.info("Rebuild complete");
2187
3720
  }
2188
3721
  /**
2189
- * Get consumer health metrics
3722
+ * Get consumer health metrics.
2190
3723
  */
2191
3724
  getHealthMetrics() {
2192
3725
  return {
2193
3726
  subscriptions: this._globalSubscription ? 1 : 0,
2194
- // Only global subscription
2195
3727
  lastProcessed: Object.fromEntries(this.lastProcessed),
2196
- processing: Array.from(this.processing.keys())
3728
+ pipelineActive: !!this.pipelineSubscription
2197
3729
  };
2198
3730
  }
2199
3731
  /**
2200
- * Shutdown consumer
3732
+ * Shutdown consumer.
2201
3733
  */
2202
3734
  async shutdown() {
2203
- if (this._globalSubscription) {
2204
- this._globalSubscription.unsubscribe();
2205
- this._globalSubscription = null;
2206
- this.logger.info("Unsubscribed from global events");
2207
- }
3735
+ await this.stop();
2208
3736
  this.logger.info("GraphDB consumer shut down");
2209
3737
  }
2210
3738
  };
@@ -2215,13 +3743,13 @@ import * as path from "path";
2215
3743
  import { DEFAULT_ENTITY_TYPES } from "@semiont/ontology";
2216
3744
  import { userId as userId5 } from "@semiont/core";
2217
3745
  var bootstrapCompleted = false;
2218
- async function bootstrapEntityTypes(eventStore, config, logger) {
3746
+ async function bootstrapEntityTypes(eventStore, config2, logger) {
2219
3747
  if (bootstrapCompleted) {
2220
3748
  logger?.debug("Entity types bootstrap already completed, skipping");
2221
3749
  return;
2222
3750
  }
2223
- const configuredPath = config.services.filesystem.path;
2224
- const projectRoot = config._metadata?.projectRoot;
3751
+ const configuredPath = config2.services.filesystem.path;
3752
+ const projectRoot = config2._metadata?.projectRoot;
2225
3753
  let basePath;
2226
3754
  if (path.isAbsolute(configuredPath)) {
2227
3755
  basePath = configuredPath;
@@ -2268,16 +3796,16 @@ function resetBootstrap() {
2268
3796
  }
2269
3797
 
2270
3798
  // src/service.ts
2271
- async function startMakeMeaning(config, eventBus, logger) {
2272
- const configuredPath = config.services?.filesystem?.path;
3799
+ async function startMakeMeaning(config2, eventBus, logger) {
3800
+ const configuredPath = config2.services?.filesystem?.path;
2273
3801
  if (!configuredPath) {
2274
3802
  throw new Error("services.filesystem.path is required for make-meaning service");
2275
3803
  }
2276
- const baseUrl = config.services?.backend?.publicURL;
3804
+ const baseUrl = config2.services?.backend?.publicURL;
2277
3805
  if (!baseUrl) {
2278
3806
  throw new Error("services.backend.publicURL is required for make-meaning service");
2279
3807
  }
2280
- const projectRoot = config._metadata?.projectRoot;
3808
+ const projectRoot = config2._metadata?.projectRoot;
2281
3809
  let basePath;
2282
3810
  if (path2.isAbsolute(configuredPath)) {
2283
3811
  basePath = configuredPath;
@@ -2292,12 +3820,12 @@ async function startMakeMeaning(config, eventBus, logger) {
2292
3820
  const eventStoreLogger = logger.child({ component: "event-store" });
2293
3821
  const eventStore = createEventStoreCore(basePath, baseUrl, void 0, eventBus, eventStoreLogger);
2294
3822
  const bootstrapLogger = logger.child({ component: "entity-types-bootstrap" });
2295
- await bootstrapEntityTypes(eventStore, config, bootstrapLogger);
3823
+ await bootstrapEntityTypes(eventStore, config2, bootstrapLogger);
2296
3824
  const repStoreLogger = logger.child({ component: "representation-store" });
2297
3825
  const repStore = new FilesystemRepresentationStore3({ basePath }, projectRoot, repStoreLogger);
2298
3826
  const inferenceLogger = logger.child({ component: "inference-client" });
2299
- const inferenceClient = await getInferenceClient(config, inferenceLogger);
2300
- const graphDb = await getGraphDatabase(config);
3827
+ const inferenceClient = await getInferenceClient(config2, inferenceLogger);
3828
+ const graphDb = await getGraphDatabase(config2);
2301
3829
  const detectionLogger = logger.child({ component: "reference-detection-worker" });
2302
3830
  const generationLogger = logger.child({ component: "generation-worker" });
2303
3831
  const highlightLogger = logger.child({ component: "highlight-detection-worker" });
@@ -2305,15 +3833,15 @@ async function startMakeMeaning(config, eventBus, logger) {
2305
3833
  const commentLogger = logger.child({ component: "comment-detection-worker" });
2306
3834
  const tagLogger = logger.child({ component: "tag-detection-worker" });
2307
3835
  const graphConsumerLogger = logger.child({ component: "graph-consumer" });
2308
- const graphConsumer = new GraphDBConsumer(config, eventStore, graphDb, graphConsumerLogger);
3836
+ const graphConsumer = new GraphDBConsumer(config2, eventStore, graphDb, graphConsumerLogger);
2309
3837
  await graphConsumer.initialize();
2310
3838
  const workers = {
2311
- detection: new ReferenceAnnotationWorker(jobQueue, config, eventStore, inferenceClient, eventBus, detectionLogger),
2312
- generation: new GenerationWorker(jobQueue, config, eventStore, inferenceClient, eventBus, generationLogger),
2313
- highlight: new HighlightAnnotationWorker(jobQueue, config, eventStore, inferenceClient, eventBus, highlightLogger),
2314
- assessment: new AssessmentAnnotationWorker(jobQueue, config, eventStore, inferenceClient, eventBus, assessmentLogger),
2315
- comment: new CommentAnnotationWorker(jobQueue, config, eventStore, inferenceClient, eventBus, commentLogger),
2316
- tag: new TagAnnotationWorker(jobQueue, config, eventStore, inferenceClient, eventBus, tagLogger)
3839
+ detection: new ReferenceAnnotationWorker(jobQueue, config2, eventStore, inferenceClient, eventBus, detectionLogger),
3840
+ generation: new GenerationWorker(jobQueue, config2, eventStore, inferenceClient, eventBus, generationLogger),
3841
+ highlight: new HighlightAnnotationWorker(jobQueue, config2, eventStore, inferenceClient, eventBus, highlightLogger),
3842
+ assessment: new AssessmentAnnotationWorker(jobQueue, config2, eventStore, inferenceClient, eventBus, assessmentLogger),
3843
+ comment: new CommentAnnotationWorker(jobQueue, config2, eventStore, inferenceClient, eventBus, commentLogger),
3844
+ tag: new TagAnnotationWorker(jobQueue, config2, eventStore, inferenceClient, eventBus, tagLogger)
2317
3845
  };
2318
3846
  workers.detection.start().catch((error) => {
2319
3847
  detectionLogger.error("Worker stopped unexpectedly", { error });
@@ -2362,9 +3890,9 @@ async function startMakeMeaning(config, eventBus, logger) {
2362
3890
  // src/views/entity-types-reader.ts
2363
3891
  import { promises as fs2 } from "fs";
2364
3892
  import * as path3 from "path";
2365
- async function readEntityTypesProjection(config) {
2366
- const configuredPath = config.services.filesystem.path;
2367
- const projectRoot = config._metadata?.projectRoot;
3893
+ async function readEntityTypesProjection(config2) {
3894
+ const configuredPath = config2.services.filesystem.path;
3895
+ const projectRoot = config2._metadata?.projectRoot;
2368
3896
  let basePath;
2369
3897
  if (path3.isAbsolute(configuredPath)) {
2370
3898
  basePath = configuredPath;
@@ -2401,7 +3929,7 @@ var ResourceOperations = class {
2401
3929
  * Create a new resource
2402
3930
  * Orchestrates: content storage → event emission → response building
2403
3931
  */
2404
- static async createResource(input, userId6, eventStore, repStore, config) {
3932
+ static async createResource(input, userId6, eventStore, repStore, config2) {
2405
3933
  const rId = resourceId2(generateUuid());
2406
3934
  const storedRep = await repStore.store(input.content, {
2407
3935
  mediaType: input.format,
@@ -2428,7 +3956,7 @@ var ResourceOperations = class {
2428
3956
  generationPrompt: void 0
2429
3957
  }
2430
3958
  });
2431
- const backendUrl = config.services.backend?.publicURL;
3959
+ const backendUrl = config2.services.backend?.publicURL;
2432
3960
  if (!backendUrl) {
2433
3961
  throw new Error("Backend publicURL not configured");
2434
3962
  }
@@ -2571,9 +4099,9 @@ var ResourceContext = class {
2571
4099
  /**
2572
4100
  * Get resource metadata from view storage
2573
4101
  */
2574
- static async getResourceMetadata(resourceId3, config) {
2575
- const basePath = config.services.filesystem.path;
2576
- const projectRoot = config._metadata?.projectRoot;
4102
+ static async getResourceMetadata(resourceId3, config2) {
4103
+ const basePath = config2.services.filesystem.path;
4104
+ const projectRoot = config2._metadata?.projectRoot;
2577
4105
  const viewStorage = new FilesystemViewStorage(basePath, projectRoot);
2578
4106
  const view = await viewStorage.get(resourceId3);
2579
4107
  if (!view) {
@@ -2584,9 +4112,9 @@ var ResourceContext = class {
2584
4112
  /**
2585
4113
  * List all resources by scanning view storage
2586
4114
  */
2587
- static async listResources(filters, config) {
2588
- const basePath = config.services.filesystem.path;
2589
- const projectRoot = config._metadata?.projectRoot;
4115
+ static async listResources(filters, config2) {
4116
+ const basePath = config2.services.filesystem.path;
4117
+ const projectRoot = config2._metadata?.projectRoot;
2590
4118
  const viewStorage = new FilesystemViewStorage(basePath, projectRoot);
2591
4119
  const allViews = await viewStorage.getAll();
2592
4120
  const resources = [];
@@ -2614,9 +4142,9 @@ var ResourceContext = class {
2614
4142
  * Add content previews to resources (for search results)
2615
4143
  * Retrieves and decodes the first 200 characters of each resource's primary representation
2616
4144
  */
2617
- static async addContentPreviews(resources, config) {
2618
- const basePath = config.services.filesystem.path;
2619
- const projectRoot = config._metadata?.projectRoot;
4145
+ static async addContentPreviews(resources, config2) {
4146
+ const basePath = config2.services.filesystem.path;
4147
+ const projectRoot = config2._metadata?.projectRoot;
2620
4148
  const repStore = new FilesystemRepresentationStore4({ basePath }, projectRoot);
2621
4149
  return await Promise.all(
2622
4150
  resources.map(async (doc) => {
@@ -2638,9 +4166,9 @@ var ResourceContext = class {
2638
4166
  * Get full content for a resource
2639
4167
  * Retrieves and decodes the primary representation
2640
4168
  */
2641
- static async getResourceContent(resource, config) {
2642
- const basePath = config.services.filesystem.path;
2643
- const projectRoot = config._metadata?.projectRoot;
4169
+ static async getResourceContent(resource, config2) {
4170
+ const basePath = config2.services.filesystem.path;
4171
+ const projectRoot = config2._metadata?.projectRoot;
2644
4172
  const repStore = new FilesystemRepresentationStore4({ basePath }, projectRoot);
2645
4173
  const primaryRep = getPrimaryRepresentation2(resource);
2646
4174
  if (primaryRep?.checksum && primaryRep?.mediaType) {
@@ -2663,7 +4191,7 @@ var AnnotationContext = class {
2663
4191
  * @returns Rich context for LLM processing
2664
4192
  * @throws Error if annotation or resource not found
2665
4193
  */
2666
- static async buildLLMContext(annotationUri2, resourceId3, config, options = {}, logger) {
4194
+ static async buildLLMContext(annotationUri2, resourceId3, config2, options = {}, logger) {
2667
4195
  const {
2668
4196
  includeSourceContext = true,
2669
4197
  includeTargetContext = true,
@@ -2673,9 +4201,9 @@ var AnnotationContext = class {
2673
4201
  throw new Error("contextWindow must be between 100 and 5000");
2674
4202
  }
2675
4203
  logger?.debug("Building LLM context", { annotationUri: annotationUri2, resourceId: resourceId3 });
2676
- const basePath = config.services.filesystem.path;
4204
+ const basePath = config2.services.filesystem.path;
2677
4205
  logger?.debug("Filesystem basePath", { basePath });
2678
- const projectRoot = config._metadata?.projectRoot;
4206
+ const projectRoot = config2._metadata?.projectRoot;
2679
4207
  const viewStorage = new FilesystemViewStorage2(basePath, projectRoot);
2680
4208
  const repStore = new FilesystemRepresentationStore5({ basePath }, projectRoot);
2681
4209
  logger?.debug("Getting view for resource", { resourceId: resourceId3 });
@@ -2767,7 +4295,7 @@ var AnnotationContext = class {
2767
4295
  if (targetRep?.checksum && targetRep?.mediaType) {
2768
4296
  const targetContent = await repStore.retrieve(targetRep.checksum, targetRep.mediaType);
2769
4297
  const contentStr = decodeRepresentation3(targetContent, targetRep.mediaType);
2770
- const client = await getInferenceClient2(config, logger);
4298
+ const client = await getInferenceClient2(config2, logger);
2771
4299
  targetContext = {
2772
4300
  content: contentStr.slice(0, contextWindow * 2),
2773
4301
  summary: await generateResourceSummary(targetDoc.name, contentStr, getResourceEntityTypes(targetDoc), client)
@@ -2803,12 +4331,12 @@ var AnnotationContext = class {
2803
4331
  * Get resource annotations from view storage (fast path)
2804
4332
  * Throws if view missing
2805
4333
  */
2806
- static async getResourceAnnotations(resourceId3, config) {
2807
- if (!config.services?.filesystem?.path) {
4334
+ static async getResourceAnnotations(resourceId3, config2) {
4335
+ if (!config2.services?.filesystem?.path) {
2808
4336
  throw new Error("Filesystem path not found in configuration");
2809
4337
  }
2810
- const basePath = config.services.filesystem.path;
2811
- const projectRoot = config._metadata?.projectRoot;
4338
+ const basePath = config2.services.filesystem.path;
4339
+ const projectRoot = config2._metadata?.projectRoot;
2812
4340
  const viewStorage = new FilesystemViewStorage2(basePath, projectRoot);
2813
4341
  const view = await viewStorage.get(resourceId3);
2814
4342
  if (!view) {
@@ -2820,17 +4348,17 @@ var AnnotationContext = class {
2820
4348
  * Get all annotations
2821
4349
  * @returns Array of all annotation objects
2822
4350
  */
2823
- static async getAllAnnotations(resourceId3, config) {
2824
- const annotations = await this.getResourceAnnotations(resourceId3, config);
2825
- return await this.enrichResolvedReferences(annotations.annotations, config);
4351
+ static async getAllAnnotations(resourceId3, config2) {
4352
+ const annotations = await this.getResourceAnnotations(resourceId3, config2);
4353
+ return await this.enrichResolvedReferences(annotations.annotations, config2);
2826
4354
  }
2827
4355
  /**
2828
4356
  * Enrich reference annotations with resolved document names
2829
4357
  * Adds _resolvedDocumentName property to annotations that link to documents
2830
4358
  * @private
2831
4359
  */
2832
- static async enrichResolvedReferences(annotations, config) {
2833
- if (!config.services?.filesystem?.path) {
4360
+ static async enrichResolvedReferences(annotations, config2) {
4361
+ if (!config2.services?.filesystem?.path) {
2834
4362
  return annotations;
2835
4363
  }
2836
4364
  const resolvedUris = /* @__PURE__ */ new Set();
@@ -2847,8 +4375,8 @@ var AnnotationContext = class {
2847
4375
  if (resolvedUris.size === 0) {
2848
4376
  return annotations;
2849
4377
  }
2850
- const basePath = config.services.filesystem.path;
2851
- const projectRoot = config._metadata?.projectRoot;
4378
+ const basePath = config2.services.filesystem.path;
4379
+ const projectRoot = config2._metadata?.projectRoot;
2852
4380
  const viewStorage = new FilesystemViewStorage2(basePath, projectRoot);
2853
4381
  const metadataPromises = Array.from(resolvedUris).map(async (uri) => {
2854
4382
  const docId = uri.split("/resources/")[1];
@@ -2898,8 +4426,8 @@ var AnnotationContext = class {
2898
4426
  * Get resource stats (version info)
2899
4427
  * @returns Version and timestamp info for the annotations
2900
4428
  */
2901
- static async getResourceStats(resourceId3, config) {
2902
- const annotations = await this.getResourceAnnotations(resourceId3, config);
4429
+ static async getResourceStats(resourceId3, config2) {
4430
+ const annotations = await this.getResourceAnnotations(resourceId3, config2);
2903
4431
  return {
2904
4432
  resourceId: annotations.resourceId,
2905
4433
  version: annotations.version,
@@ -2909,12 +4437,12 @@ var AnnotationContext = class {
2909
4437
  /**
2910
4438
  * Check if resource exists in view storage
2911
4439
  */
2912
- static async resourceExists(resourceId3, config) {
2913
- if (!config.services?.filesystem?.path) {
4440
+ static async resourceExists(resourceId3, config2) {
4441
+ if (!config2.services?.filesystem?.path) {
2914
4442
  throw new Error("Filesystem path not found in configuration");
2915
4443
  }
2916
- const basePath = config.services.filesystem.path;
2917
- const projectRoot = config._metadata?.projectRoot;
4444
+ const basePath = config2.services.filesystem.path;
4445
+ const projectRoot = config2._metadata?.projectRoot;
2918
4446
  const viewStorage = new FilesystemViewStorage2(basePath, projectRoot);
2919
4447
  return await viewStorage.exists(resourceId3);
2920
4448
  }
@@ -2922,8 +4450,8 @@ var AnnotationContext = class {
2922
4450
  * Get a single annotation by ID
2923
4451
  * O(1) lookup using resource ID to access view storage
2924
4452
  */
2925
- static async getAnnotation(annotationId3, resourceId3, config) {
2926
- const annotations = await this.getResourceAnnotations(resourceId3, config);
4453
+ static async getAnnotation(annotationId3, resourceId3, config2) {
4454
+ const annotations = await this.getResourceAnnotations(resourceId3, config2);
2927
4455
  return annotations.annotations.find((a) => {
2928
4456
  const shortId = a.id.split("/").pop();
2929
4457
  return shortId === annotationId3;
@@ -2934,26 +4462,26 @@ var AnnotationContext = class {
2934
4462
  * @param filters - Optional filters like resourceId and type
2935
4463
  * @throws Error if resourceId not provided (cross-resource queries not supported in view storage)
2936
4464
  */
2937
- static async listAnnotations(filters, config) {
4465
+ static async listAnnotations(filters, config2) {
2938
4466
  if (!filters?.resourceId) {
2939
4467
  throw new Error("resourceId is required for annotation listing - cross-resource queries not supported in view storage");
2940
4468
  }
2941
- return await this.getAllAnnotations(filters.resourceId, config);
4469
+ return await this.getAllAnnotations(filters.resourceId, config2);
2942
4470
  }
2943
4471
  /**
2944
4472
  * Get annotation context (selected text with surrounding context)
2945
4473
  */
2946
- static async getAnnotationContext(annotationId3, resourceId3, contextBefore, contextAfter, config) {
2947
- const basePath = config.services.filesystem.path;
2948
- const projectRoot = config._metadata?.projectRoot;
4474
+ static async getAnnotationContext(annotationId3, resourceId3, contextBefore, contextAfter, config2) {
4475
+ const basePath = config2.services.filesystem.path;
4476
+ const projectRoot = config2._metadata?.projectRoot;
2949
4477
  const repStore = new FilesystemRepresentationStore5({ basePath }, projectRoot);
2950
- const annotation = await this.getAnnotation(annotationId3, resourceId3, config);
4478
+ const annotation = await this.getAnnotation(annotationId3, resourceId3, config2);
2951
4479
  if (!annotation) {
2952
4480
  throw new Error("Annotation not found");
2953
4481
  }
2954
4482
  const resource = await ResourceContext.getResourceMetadata(
2955
4483
  uriToResourceId(getTargetSource(annotation.target)),
2956
- config
4484
+ config2
2957
4485
  );
2958
4486
  if (!resource) {
2959
4487
  throw new Error("Resource not found");
@@ -2979,17 +4507,17 @@ var AnnotationContext = class {
2979
4507
  /**
2980
4508
  * Generate AI summary of annotation in context
2981
4509
  */
2982
- static async generateAnnotationSummary(annotationId3, resourceId3, config, logger) {
2983
- const basePath = config.services.filesystem.path;
2984
- const projectRoot = config._metadata?.projectRoot;
4510
+ static async generateAnnotationSummary(annotationId3, resourceId3, config2, logger) {
4511
+ const basePath = config2.services.filesystem.path;
4512
+ const projectRoot = config2._metadata?.projectRoot;
2985
4513
  const repStore = new FilesystemRepresentationStore5({ basePath }, projectRoot);
2986
- const annotation = await this.getAnnotation(annotationId3, resourceId3, config);
4514
+ const annotation = await this.getAnnotation(annotationId3, resourceId3, config2);
2987
4515
  if (!annotation) {
2988
4516
  throw new Error("Annotation not found");
2989
4517
  }
2990
4518
  const resource = await ResourceContext.getResourceMetadata(
2991
4519
  uriToResourceId(getTargetSource(annotation.target)),
2992
- config
4520
+ config2
2993
4521
  );
2994
4522
  if (!resource) {
2995
4523
  throw new Error("Resource not found");
@@ -2998,7 +4526,7 @@ var AnnotationContext = class {
2998
4526
  const contextSize = 500;
2999
4527
  const context = this.extractAnnotationContext(annotation, contentStr, contextSize, contextSize);
3000
4528
  const annotationEntityTypes = getEntityTypes2(annotation);
3001
- const summary = await this.generateSummary(resource, context, annotationEntityTypes, config, logger);
4529
+ const summary = await this.generateSummary(resource, context, annotationEntityTypes, config2, logger);
3002
4530
  return {
3003
4531
  summary,
3004
4532
  relevantFields: {
@@ -3049,7 +4577,7 @@ var AnnotationContext = class {
3049
4577
  * Generate LLM summary of annotation in context
3050
4578
  * Creates inference client per-request (HTTP handler context)
3051
4579
  */
3052
- static async generateSummary(resource, context, entityTypes, config, logger) {
4580
+ static async generateSummary(resource, context, entityTypes, config2, logger) {
3053
4581
  const summaryPrompt = `Summarize this text in context:
3054
4582
 
3055
4583
  Context before: "${context.before.substring(Math.max(0, context.before.length - 200))}"
@@ -3058,7 +4586,7 @@ Context after: "${context.after.substring(0, 200)}"
3058
4586
 
3059
4587
  Resource: ${resource.name}
3060
4588
  Entity types: ${entityTypes.join(", ")}`;
3061
- const client = await getInferenceClient2(config, logger);
4589
+ const client = await getInferenceClient2(config2, logger);
3062
4590
  return await client.generateText(summaryPrompt, 500, 0.5);
3063
4591
  }
3064
4592
  };
@@ -3068,8 +4596,8 @@ var AnnotationOperations = class {
3068
4596
  /**
3069
4597
  * Create a new annotation
3070
4598
  */
3071
- static async createAnnotation(request, userId6, eventStore, config) {
3072
- const backendUrl = config.services.backend?.publicURL;
4599
+ static async createAnnotation(request, userId6, eventStore, config2) {
4600
+ const backendUrl = config2.services.backend?.publicURL;
3073
4601
  if (!backendUrl) {
3074
4602
  throw new Error("Backend publicURL not configured");
3075
4603
  }
@@ -3114,11 +4642,11 @@ var AnnotationOperations = class {
3114
4642
  /**
3115
4643
  * Update annotation body with operations (add/remove/replace)
3116
4644
  */
3117
- static async updateAnnotationBody(id, request, userId6, eventStore, config) {
4645
+ static async updateAnnotationBody(id, request, userId6, eventStore, config2) {
3118
4646
  const annotation = await AnnotationContext.getAnnotation(
3119
4647
  annotationId2(id),
3120
4648
  uriToResourceId2(request.resourceId),
3121
- config
4649
+ config2
3122
4650
  );
3123
4651
  if (!annotation) {
3124
4652
  throw new Error("Annotation not found");
@@ -3144,9 +4672,9 @@ var AnnotationOperations = class {
3144
4672
  /**
3145
4673
  * Delete an annotation
3146
4674
  */
3147
- static async deleteAnnotation(id, resourceIdUri, userId6, eventStore, config, logger) {
4675
+ static async deleteAnnotation(id, resourceIdUri, userId6, eventStore, config2, logger) {
3148
4676
  const resourceId3 = uriToResourceId2(resourceIdUri);
3149
- const projection = await AnnotationContext.getResourceAnnotations(resourceId3, config);
4677
+ const projection = await AnnotationContext.getResourceAnnotations(resourceId3, config2);
3150
4678
  const annotation = projection.annotations.find((a) => a.id === id);
3151
4679
  if (!annotation) {
3152
4680
  throw new Error("Annotation not found in resource");
@@ -3205,42 +4733,42 @@ var GraphContext = class {
3205
4733
  * Get all resources referencing this resource (backlinks)
3206
4734
  * Requires graph traversal - must use graph database
3207
4735
  */
3208
- static async getBacklinks(resourceId3, config) {
3209
- const graphDb = await getGraphDatabase2(config);
3210
- const resourceUri2 = resourceIdToURI6(resourceId3, config.services.backend.publicURL);
4736
+ static async getBacklinks(resourceId3, config2) {
4737
+ const graphDb = await getGraphDatabase2(config2);
4738
+ const resourceUri2 = resourceIdToURI6(resourceId3, config2.services.backend.publicURL);
3211
4739
  return await graphDb.getResourceReferencedBy(resourceUri2);
3212
4740
  }
3213
4741
  /**
3214
4742
  * Find shortest path between two resources
3215
4743
  * Requires graph traversal - must use graph database
3216
4744
  */
3217
- static async findPath(fromResourceId, toResourceId, config, maxDepth) {
3218
- const graphDb = await getGraphDatabase2(config);
4745
+ static async findPath(fromResourceId, toResourceId, config2, maxDepth) {
4746
+ const graphDb = await getGraphDatabase2(config2);
3219
4747
  return await graphDb.findPath(fromResourceId, toResourceId, maxDepth);
3220
4748
  }
3221
4749
  /**
3222
4750
  * Get resource connections (graph edges)
3223
4751
  * Requires graph traversal - must use graph database
3224
4752
  */
3225
- static async getResourceConnections(resourceId3, config) {
3226
- const graphDb = await getGraphDatabase2(config);
4753
+ static async getResourceConnections(resourceId3, config2) {
4754
+ const graphDb = await getGraphDatabase2(config2);
3227
4755
  return await graphDb.getResourceConnections(resourceId3);
3228
4756
  }
3229
4757
  /**
3230
4758
  * Search resources by name (cross-resource query)
3231
4759
  * Requires full-text search - must use graph database
3232
4760
  */
3233
- static async searchResources(query, config, limit) {
3234
- const graphDb = await getGraphDatabase2(config);
4761
+ static async searchResources(query, config2, limit) {
4762
+ const graphDb = await getGraphDatabase2(config2);
3235
4763
  return await graphDb.searchResources(query, limit);
3236
4764
  }
3237
4765
  /**
3238
4766
  * Build graph representation with nodes and edges for a resource and its connections
3239
4767
  * Retrieves connections from graph and builds visualization-ready structure
3240
4768
  */
3241
- static async buildGraphRepresentation(resourceId3, maxRelated, config) {
3242
- const graphDb = await getGraphDatabase2(config);
3243
- const publicURL = config.services.backend.publicURL;
4769
+ static async buildGraphRepresentation(resourceId3, maxRelated, config2) {
4770
+ const graphDb = await getGraphDatabase2(config2);
4771
+ const publicURL = config2.services.backend.publicURL;
3244
4772
  const resourceUri2 = resourceIdToURI6(resourceId3, publicURL);
3245
4773
  const mainDoc = await graphDb.getResource(resourceUri2);
3246
4774
  if (!mainDoc) {
@@ -3280,22 +4808,22 @@ var LLMContext = class {
3280
4808
  * Get comprehensive LLM context for a resource
3281
4809
  * Includes: main resource, related resources, annotations, graph, content, summary, references
3282
4810
  */
3283
- static async getResourceContext(resourceId3, options, config, inferenceClient) {
3284
- const mainDoc = await ResourceContext.getResourceMetadata(resourceId3, config);
4811
+ static async getResourceContext(resourceId3, options, config2, inferenceClient) {
4812
+ const mainDoc = await ResourceContext.getResourceMetadata(resourceId3, config2);
3285
4813
  if (!mainDoc) {
3286
4814
  throw new Error("Resource not found");
3287
4815
  }
3288
- const mainContent = options.includeContent ? await ResourceContext.getResourceContent(mainDoc, config) : void 0;
4816
+ const mainContent = options.includeContent ? await ResourceContext.getResourceContent(mainDoc, config2) : void 0;
3289
4817
  const graph = await GraphContext.buildGraphRepresentation(
3290
4818
  resourceId3,
3291
4819
  options.maxResources,
3292
- config
4820
+ config2
3293
4821
  );
3294
4822
  const relatedDocs = [];
3295
4823
  const resourceIdStr = resourceId3.toString();
3296
4824
  for (const node of graph.nodes) {
3297
4825
  if (node.id !== resourceIdStr) {
3298
- const relatedDoc = await ResourceContext.getResourceMetadata(makeResourceId2(node.id), config);
4826
+ const relatedDoc = await ResourceContext.getResourceMetadata(makeResourceId2(node.id), config2);
3299
4827
  if (relatedDoc) {
3300
4828
  relatedDocs.push(relatedDoc);
3301
4829
  }
@@ -3307,14 +4835,14 @@ var LLMContext = class {
3307
4835
  relatedDocs.map(async (doc) => {
3308
4836
  const docId = getResourceId2(doc);
3309
4837
  if (!docId) return;
3310
- const content = await ResourceContext.getResourceContent(doc, config);
4838
+ const content = await ResourceContext.getResourceContent(doc, config2);
3311
4839
  if (content) {
3312
4840
  relatedResourcesContent[docId] = content;
3313
4841
  }
3314
4842
  })
3315
4843
  );
3316
4844
  }
3317
- const annotations = await AnnotationContext.getAllAnnotations(resourceId3, config);
4845
+ const annotations = await AnnotationContext.getAllAnnotations(resourceId3, config2);
3318
4846
  const summary = options.includeSummary && mainContent ? await generateResourceSummary(
3319
4847
  mainDoc.name,
3320
4848
  mainContent,
@@ -3837,12 +5365,12 @@ var AnnotationDetection = class {
3837
5365
  * @param density - Optional target number of comments per 2000 words
3838
5366
  * @returns Array of validated comment matches
3839
5367
  */
3840
- static async detectComments(resourceId3, config, client, instructions, tone, density) {
3841
- const resource = await ResourceContext.getResourceMetadata(resourceId3, config);
5368
+ static async detectComments(resourceId3, config2, client, instructions, tone, density) {
5369
+ const resource = await ResourceContext.getResourceMetadata(resourceId3, config2);
3842
5370
  if (!resource) {
3843
5371
  throw new Error(`Resource ${resourceId3} not found`);
3844
5372
  }
3845
- const content = await this.loadResourceContent(resourceId3, config);
5373
+ const content = await this.loadResourceContent(resourceId3, config2);
3846
5374
  if (!content) {
3847
5375
  throw new Error(`Could not load content for resource ${resourceId3}`);
3848
5376
  }
@@ -3866,12 +5394,12 @@ var AnnotationDetection = class {
3866
5394
  * @param density - Optional target number of highlights per 2000 words
3867
5395
  * @returns Array of validated highlight matches
3868
5396
  */
3869
- static async detectHighlights(resourceId3, config, client, instructions, density) {
3870
- const resource = await ResourceContext.getResourceMetadata(resourceId3, config);
5397
+ static async detectHighlights(resourceId3, config2, client, instructions, density) {
5398
+ const resource = await ResourceContext.getResourceMetadata(resourceId3, config2);
3871
5399
  if (!resource) {
3872
5400
  throw new Error(`Resource ${resourceId3} not found`);
3873
5401
  }
3874
- const content = await this.loadResourceContent(resourceId3, config);
5402
+ const content = await this.loadResourceContent(resourceId3, config2);
3875
5403
  if (!content) {
3876
5404
  throw new Error(`Could not load content for resource ${resourceId3}`);
3877
5405
  }
@@ -3896,12 +5424,12 @@ var AnnotationDetection = class {
3896
5424
  * @param density - Optional target number of assessments per 2000 words
3897
5425
  * @returns Array of validated assessment matches
3898
5426
  */
3899
- static async detectAssessments(resourceId3, config, client, instructions, tone, density) {
3900
- const resource = await ResourceContext.getResourceMetadata(resourceId3, config);
5427
+ static async detectAssessments(resourceId3, config2, client, instructions, tone, density) {
5428
+ const resource = await ResourceContext.getResourceMetadata(resourceId3, config2);
3901
5429
  if (!resource) {
3902
5430
  throw new Error(`Resource ${resourceId3} not found`);
3903
5431
  }
3904
- const content = await this.loadResourceContent(resourceId3, config);
5432
+ const content = await this.loadResourceContent(resourceId3, config2);
3905
5433
  if (!content) {
3906
5434
  throw new Error(`Could not load content for resource ${resourceId3}`);
3907
5435
  }
@@ -3925,7 +5453,7 @@ var AnnotationDetection = class {
3925
5453
  * @param category - The specific category to detect
3926
5454
  * @returns Array of validated tag matches
3927
5455
  */
3928
- static async detectTags(resourceId3, config, client, schemaId, category) {
5456
+ static async detectTags(resourceId3, config2, client, schemaId, category) {
3929
5457
  const schema = getTagSchema2(schemaId);
3930
5458
  if (!schema) {
3931
5459
  throw new Error(`Invalid tag schema: ${schemaId}`);
@@ -3934,11 +5462,11 @@ var AnnotationDetection = class {
3934
5462
  if (!categoryInfo) {
3935
5463
  throw new Error(`Invalid category "${category}" for schema ${schemaId}`);
3936
5464
  }
3937
- const resource = await ResourceContext.getResourceMetadata(resourceId3, config);
5465
+ const resource = await ResourceContext.getResourceMetadata(resourceId3, config2);
3938
5466
  if (!resource) {
3939
5467
  throw new Error(`Resource ${resourceId3} not found`);
3940
5468
  }
3941
- const content = await this.loadResourceContent(resourceId3, config);
5469
+ const content = await this.loadResourceContent(resourceId3, config2);
3942
5470
  if (!content) {
3943
5471
  throw new Error(`Could not load content for resource ${resourceId3}`);
3944
5472
  }
@@ -3969,8 +5497,8 @@ var AnnotationDetection = class {
3969
5497
  * @param config - Environment configuration
3970
5498
  * @returns Resource content as string, or null if not available
3971
5499
  */
3972
- static async loadResourceContent(resourceId3, config) {
3973
- const resource = await ResourceContext.getResourceMetadata(resourceId3, config);
5500
+ static async loadResourceContent(resourceId3, config2) {
5501
+ const resource = await ResourceContext.getResourceMetadata(resourceId3, config2);
3974
5502
  if (!resource) return null;
3975
5503
  const primaryRep = getPrimaryRepresentation4(resource);
3976
5504
  if (!primaryRep) return null;
@@ -3979,8 +5507,8 @@ var AnnotationDetection = class {
3979
5507
  return null;
3980
5508
  }
3981
5509
  if (!primaryRep.checksum || !primaryRep.mediaType) return null;
3982
- const basePath = config.services.filesystem.path;
3983
- const projectRoot = config._metadata?.projectRoot;
5510
+ const basePath = config2.services.filesystem.path;
5511
+ const projectRoot = config2._metadata?.projectRoot;
3984
5512
  const repStore = new FilesystemRepresentationStore6({ basePath }, projectRoot);
3985
5513
  const contentBuffer = await repStore.retrieve(primaryRep.checksum, primaryRep.mediaType);
3986
5514
  return decodeRepresentation4(contentBuffer, primaryRep.mediaType);
@@ -4019,4 +5547,22 @@ export {
4019
5547
  resetBootstrap,
4020
5548
  startMakeMeaning
4021
5549
  };
5550
+ /*! Bundled license information:
5551
+
5552
+ tslib/tslib.es6.js:
5553
+ (*! *****************************************************************************
5554
+ Copyright (c) Microsoft Corporation.
5555
+
5556
+ Permission to use, copy, modify, and/or distribute this software for any
5557
+ purpose with or without fee is hereby granted.
5558
+
5559
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
5560
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
5561
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
5562
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
5563
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
5564
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
5565
+ PERFORMANCE OF THIS SOFTWARE.
5566
+ ***************************************************************************** *)
5567
+ */
4022
5568
  //# sourceMappingURL=index.js.map