@sanity/client 3.3.2 → 3.3.3-esm.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/README.md +1 -1
  2. package/dist/sanityClient.browser.mjs +2948 -0
  3. package/dist/sanityClient.browser.mjs.map +7 -0
  4. package/lib/assets/assetsClient.js +29 -15
  5. package/lib/auth/authClient.js +11 -3
  6. package/lib/config.js +40 -22
  7. package/lib/data/dataMethods.js +38 -24
  8. package/lib/data/encodeQueryString.js +9 -2
  9. package/lib/data/listen.js +30 -22
  10. package/lib/data/patch.js +36 -27
  11. package/lib/data/transaction.js +27 -11
  12. package/lib/datasets/datasetsClient.js +18 -4
  13. package/lib/generateHelpUrl.js +13 -0
  14. package/lib/http/browserMiddleware.js +7 -1
  15. package/lib/http/errors.js +16 -8
  16. package/lib/http/nodeMiddleware.js +16 -7
  17. package/lib/http/queryString.js +10 -2
  18. package/lib/http/request.js +23 -23
  19. package/lib/http/requestOptions.js +13 -5
  20. package/lib/projects/projectsClient.js +11 -3
  21. package/lib/sanityClient.js +59 -45
  22. package/lib/users/usersClient.js +11 -3
  23. package/lib/util/defaults.js +10 -2
  24. package/lib/util/getSelection.js +9 -2
  25. package/lib/util/observable.js +24 -13
  26. package/lib/util/once.js +10 -2
  27. package/lib/util/pick.js +10 -2
  28. package/lib/validators.js +38 -15
  29. package/lib/warnings.js +16 -6
  30. package/package.json +45 -19
  31. package/sanityClient.d.ts +114 -18
  32. package/umd/sanityClient.js +173 -105
  33. package/umd/sanityClient.min.js +1 -1
  34. package/test/client.test.js +0 -2561
  35. package/test/encodeQueryString.test.js +0 -36
  36. package/test/fixtures/horsehead-nebula.jpg +0 -0
  37. package/test/fixtures/pdf-sample.pdf +0 -0
  38. package/test/helpers/sseServer.js +0 -26
  39. package/test/listen.test.js +0 -205
  40. package/test/warnings.test.disabled.js +0 -80
@@ -0,0 +1,2948 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __commonJS = (cb, mod) => function __require() {
8
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
19
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
20
+ mod
21
+ ));
22
+
23
+ // node_modules/rxjs/internal/util/isFunction.js
24
+ var require_isFunction = __commonJS({
25
+ "node_modules/rxjs/internal/util/isFunction.js"(exports) {
26
+ "use strict";
27
+ Object.defineProperty(exports, "__esModule", { value: true });
28
+ function isFunction(x) {
29
+ return typeof x === "function";
30
+ }
31
+ exports.isFunction = isFunction;
32
+ }
33
+ });
34
+
35
+ // node_modules/rxjs/internal/config.js
36
+ var require_config = __commonJS({
37
+ "node_modules/rxjs/internal/config.js"(exports) {
38
+ "use strict";
39
+ Object.defineProperty(exports, "__esModule", { value: true });
40
+ var _enable_super_gross_mode_that_will_cause_bad_things = false;
41
+ exports.config = {
42
+ Promise: void 0,
43
+ set useDeprecatedSynchronousErrorHandling(value) {
44
+ if (value) {
45
+ var error = new Error();
46
+ console.warn("DEPRECATED! RxJS was set to use deprecated synchronous error handling behavior by code at: \n" + error.stack);
47
+ } else if (_enable_super_gross_mode_that_will_cause_bad_things) {
48
+ console.log("RxJS: Back to a better error behavior. Thank you. <3");
49
+ }
50
+ _enable_super_gross_mode_that_will_cause_bad_things = value;
51
+ },
52
+ get useDeprecatedSynchronousErrorHandling() {
53
+ return _enable_super_gross_mode_that_will_cause_bad_things;
54
+ }
55
+ };
56
+ }
57
+ });
58
+
59
+ // node_modules/rxjs/internal/util/hostReportError.js
60
+ var require_hostReportError = __commonJS({
61
+ "node_modules/rxjs/internal/util/hostReportError.js"(exports) {
62
+ "use strict";
63
+ Object.defineProperty(exports, "__esModule", { value: true });
64
+ function hostReportError(err) {
65
+ setTimeout(function() {
66
+ throw err;
67
+ }, 0);
68
+ }
69
+ exports.hostReportError = hostReportError;
70
+ }
71
+ });
72
+
73
+ // node_modules/rxjs/internal/Observer.js
74
+ var require_Observer = __commonJS({
75
+ "node_modules/rxjs/internal/Observer.js"(exports) {
76
+ "use strict";
77
+ Object.defineProperty(exports, "__esModule", { value: true });
78
+ var config_1 = require_config();
79
+ var hostReportError_1 = require_hostReportError();
80
+ exports.empty = {
81
+ closed: true,
82
+ next: function(value) {
83
+ },
84
+ error: function(err) {
85
+ if (config_1.config.useDeprecatedSynchronousErrorHandling) {
86
+ throw err;
87
+ } else {
88
+ hostReportError_1.hostReportError(err);
89
+ }
90
+ },
91
+ complete: function() {
92
+ }
93
+ };
94
+ }
95
+ });
96
+
97
+ // node_modules/rxjs/internal/util/isArray.js
98
+ var require_isArray = __commonJS({
99
+ "node_modules/rxjs/internal/util/isArray.js"(exports) {
100
+ "use strict";
101
+ Object.defineProperty(exports, "__esModule", { value: true });
102
+ exports.isArray = function() {
103
+ return Array.isArray || function(x) {
104
+ return x && typeof x.length === "number";
105
+ };
106
+ }();
107
+ }
108
+ });
109
+
110
+ // node_modules/rxjs/internal/util/isObject.js
111
+ var require_isObject = __commonJS({
112
+ "node_modules/rxjs/internal/util/isObject.js"(exports) {
113
+ "use strict";
114
+ Object.defineProperty(exports, "__esModule", { value: true });
115
+ function isObject(x) {
116
+ return x !== null && typeof x === "object";
117
+ }
118
+ exports.isObject = isObject;
119
+ }
120
+ });
121
+
122
+ // node_modules/rxjs/internal/util/UnsubscriptionError.js
123
+ var require_UnsubscriptionError = __commonJS({
124
+ "node_modules/rxjs/internal/util/UnsubscriptionError.js"(exports) {
125
+ "use strict";
126
+ Object.defineProperty(exports, "__esModule", { value: true });
127
+ var UnsubscriptionErrorImpl = function() {
128
+ function UnsubscriptionErrorImpl2(errors) {
129
+ Error.call(this);
130
+ this.message = errors ? errors.length + " errors occurred during unsubscription:\n" + errors.map(function(err, i) {
131
+ return i + 1 + ") " + err.toString();
132
+ }).join("\n ") : "";
133
+ this.name = "UnsubscriptionError";
134
+ this.errors = errors;
135
+ return this;
136
+ }
137
+ UnsubscriptionErrorImpl2.prototype = Object.create(Error.prototype);
138
+ return UnsubscriptionErrorImpl2;
139
+ }();
140
+ exports.UnsubscriptionError = UnsubscriptionErrorImpl;
141
+ }
142
+ });
143
+
144
+ // node_modules/rxjs/internal/Subscription.js
145
+ var require_Subscription = __commonJS({
146
+ "node_modules/rxjs/internal/Subscription.js"(exports) {
147
+ "use strict";
148
+ Object.defineProperty(exports, "__esModule", { value: true });
149
+ var isArray_1 = require_isArray();
150
+ var isObject_1 = require_isObject();
151
+ var isFunction_1 = require_isFunction();
152
+ var UnsubscriptionError_1 = require_UnsubscriptionError();
153
+ var Subscription = function() {
154
+ function Subscription2(unsubscribe) {
155
+ this.closed = false;
156
+ this._parentOrParents = null;
157
+ this._subscriptions = null;
158
+ if (unsubscribe) {
159
+ this._ctorUnsubscribe = true;
160
+ this._unsubscribe = unsubscribe;
161
+ }
162
+ }
163
+ Subscription2.prototype.unsubscribe = function() {
164
+ var errors;
165
+ if (this.closed) {
166
+ return;
167
+ }
168
+ var _a = this, _parentOrParents = _a._parentOrParents, _ctorUnsubscribe = _a._ctorUnsubscribe, _unsubscribe = _a._unsubscribe, _subscriptions = _a._subscriptions;
169
+ this.closed = true;
170
+ this._parentOrParents = null;
171
+ this._subscriptions = null;
172
+ if (_parentOrParents instanceof Subscription2) {
173
+ _parentOrParents.remove(this);
174
+ } else if (_parentOrParents !== null) {
175
+ for (var index = 0; index < _parentOrParents.length; ++index) {
176
+ var parent_1 = _parentOrParents[index];
177
+ parent_1.remove(this);
178
+ }
179
+ }
180
+ if (isFunction_1.isFunction(_unsubscribe)) {
181
+ if (_ctorUnsubscribe) {
182
+ this._unsubscribe = void 0;
183
+ }
184
+ try {
185
+ _unsubscribe.call(this);
186
+ } catch (e) {
187
+ errors = e instanceof UnsubscriptionError_1.UnsubscriptionError ? flattenUnsubscriptionErrors(e.errors) : [e];
188
+ }
189
+ }
190
+ if (isArray_1.isArray(_subscriptions)) {
191
+ var index = -1;
192
+ var len = _subscriptions.length;
193
+ while (++index < len) {
194
+ var sub = _subscriptions[index];
195
+ if (isObject_1.isObject(sub)) {
196
+ try {
197
+ sub.unsubscribe();
198
+ } catch (e) {
199
+ errors = errors || [];
200
+ if (e instanceof UnsubscriptionError_1.UnsubscriptionError) {
201
+ errors = errors.concat(flattenUnsubscriptionErrors(e.errors));
202
+ } else {
203
+ errors.push(e);
204
+ }
205
+ }
206
+ }
207
+ }
208
+ }
209
+ if (errors) {
210
+ throw new UnsubscriptionError_1.UnsubscriptionError(errors);
211
+ }
212
+ };
213
+ Subscription2.prototype.add = function(teardown) {
214
+ var subscription = teardown;
215
+ if (!teardown) {
216
+ return Subscription2.EMPTY;
217
+ }
218
+ switch (typeof teardown) {
219
+ case "function":
220
+ subscription = new Subscription2(teardown);
221
+ case "object":
222
+ if (subscription === this || subscription.closed || typeof subscription.unsubscribe !== "function") {
223
+ return subscription;
224
+ } else if (this.closed) {
225
+ subscription.unsubscribe();
226
+ return subscription;
227
+ } else if (!(subscription instanceof Subscription2)) {
228
+ var tmp = subscription;
229
+ subscription = new Subscription2();
230
+ subscription._subscriptions = [tmp];
231
+ }
232
+ break;
233
+ default: {
234
+ throw new Error("unrecognized teardown " + teardown + " added to Subscription.");
235
+ }
236
+ }
237
+ var _parentOrParents = subscription._parentOrParents;
238
+ if (_parentOrParents === null) {
239
+ subscription._parentOrParents = this;
240
+ } else if (_parentOrParents instanceof Subscription2) {
241
+ if (_parentOrParents === this) {
242
+ return subscription;
243
+ }
244
+ subscription._parentOrParents = [_parentOrParents, this];
245
+ } else if (_parentOrParents.indexOf(this) === -1) {
246
+ _parentOrParents.push(this);
247
+ } else {
248
+ return subscription;
249
+ }
250
+ var subscriptions = this._subscriptions;
251
+ if (subscriptions === null) {
252
+ this._subscriptions = [subscription];
253
+ } else {
254
+ subscriptions.push(subscription);
255
+ }
256
+ return subscription;
257
+ };
258
+ Subscription2.prototype.remove = function(subscription) {
259
+ var subscriptions = this._subscriptions;
260
+ if (subscriptions) {
261
+ var subscriptionIndex = subscriptions.indexOf(subscription);
262
+ if (subscriptionIndex !== -1) {
263
+ subscriptions.splice(subscriptionIndex, 1);
264
+ }
265
+ }
266
+ };
267
+ Subscription2.EMPTY = function(empty) {
268
+ empty.closed = true;
269
+ return empty;
270
+ }(new Subscription2());
271
+ return Subscription2;
272
+ }();
273
+ exports.Subscription = Subscription;
274
+ function flattenUnsubscriptionErrors(errors) {
275
+ return errors.reduce(function(errs, err) {
276
+ return errs.concat(err instanceof UnsubscriptionError_1.UnsubscriptionError ? err.errors : err);
277
+ }, []);
278
+ }
279
+ }
280
+ });
281
+
282
+ // node_modules/rxjs/internal/symbol/rxSubscriber.js
283
+ var require_rxSubscriber = __commonJS({
284
+ "node_modules/rxjs/internal/symbol/rxSubscriber.js"(exports) {
285
+ "use strict";
286
+ Object.defineProperty(exports, "__esModule", { value: true });
287
+ exports.rxSubscriber = function() {
288
+ return typeof Symbol === "function" ? Symbol("rxSubscriber") : "@@rxSubscriber_" + Math.random();
289
+ }();
290
+ exports.$$rxSubscriber = exports.rxSubscriber;
291
+ }
292
+ });
293
+
294
+ // node_modules/rxjs/internal/Subscriber.js
295
+ var require_Subscriber = __commonJS({
296
+ "node_modules/rxjs/internal/Subscriber.js"(exports) {
297
+ "use strict";
298
+ var __extends = exports && exports.__extends || function() {
299
+ var extendStatics = function(d, b) {
300
+ extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {
301
+ d2.__proto__ = b2;
302
+ } || function(d2, b2) {
303
+ for (var p in b2)
304
+ if (b2.hasOwnProperty(p))
305
+ d2[p] = b2[p];
306
+ };
307
+ return extendStatics(d, b);
308
+ };
309
+ return function(d, b) {
310
+ extendStatics(d, b);
311
+ function __() {
312
+ this.constructor = d;
313
+ }
314
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
315
+ };
316
+ }();
317
+ Object.defineProperty(exports, "__esModule", { value: true });
318
+ var isFunction_1 = require_isFunction();
319
+ var Observer_1 = require_Observer();
320
+ var Subscription_1 = require_Subscription();
321
+ var rxSubscriber_1 = require_rxSubscriber();
322
+ var config_1 = require_config();
323
+ var hostReportError_1 = require_hostReportError();
324
+ var Subscriber = function(_super) {
325
+ __extends(Subscriber2, _super);
326
+ function Subscriber2(destinationOrNext, error, complete) {
327
+ var _this = _super.call(this) || this;
328
+ _this.syncErrorValue = null;
329
+ _this.syncErrorThrown = false;
330
+ _this.syncErrorThrowable = false;
331
+ _this.isStopped = false;
332
+ switch (arguments.length) {
333
+ case 0:
334
+ _this.destination = Observer_1.empty;
335
+ break;
336
+ case 1:
337
+ if (!destinationOrNext) {
338
+ _this.destination = Observer_1.empty;
339
+ break;
340
+ }
341
+ if (typeof destinationOrNext === "object") {
342
+ if (destinationOrNext instanceof Subscriber2) {
343
+ _this.syncErrorThrowable = destinationOrNext.syncErrorThrowable;
344
+ _this.destination = destinationOrNext;
345
+ destinationOrNext.add(_this);
346
+ } else {
347
+ _this.syncErrorThrowable = true;
348
+ _this.destination = new SafeSubscriber(_this, destinationOrNext);
349
+ }
350
+ break;
351
+ }
352
+ default:
353
+ _this.syncErrorThrowable = true;
354
+ _this.destination = new SafeSubscriber(_this, destinationOrNext, error, complete);
355
+ break;
356
+ }
357
+ return _this;
358
+ }
359
+ Subscriber2.prototype[rxSubscriber_1.rxSubscriber] = function() {
360
+ return this;
361
+ };
362
+ Subscriber2.create = function(next, error, complete) {
363
+ var subscriber = new Subscriber2(next, error, complete);
364
+ subscriber.syncErrorThrowable = false;
365
+ return subscriber;
366
+ };
367
+ Subscriber2.prototype.next = function(value) {
368
+ if (!this.isStopped) {
369
+ this._next(value);
370
+ }
371
+ };
372
+ Subscriber2.prototype.error = function(err) {
373
+ if (!this.isStopped) {
374
+ this.isStopped = true;
375
+ this._error(err);
376
+ }
377
+ };
378
+ Subscriber2.prototype.complete = function() {
379
+ if (!this.isStopped) {
380
+ this.isStopped = true;
381
+ this._complete();
382
+ }
383
+ };
384
+ Subscriber2.prototype.unsubscribe = function() {
385
+ if (this.closed) {
386
+ return;
387
+ }
388
+ this.isStopped = true;
389
+ _super.prototype.unsubscribe.call(this);
390
+ };
391
+ Subscriber2.prototype._next = function(value) {
392
+ this.destination.next(value);
393
+ };
394
+ Subscriber2.prototype._error = function(err) {
395
+ this.destination.error(err);
396
+ this.unsubscribe();
397
+ };
398
+ Subscriber2.prototype._complete = function() {
399
+ this.destination.complete();
400
+ this.unsubscribe();
401
+ };
402
+ Subscriber2.prototype._unsubscribeAndRecycle = function() {
403
+ var _parentOrParents = this._parentOrParents;
404
+ this._parentOrParents = null;
405
+ this.unsubscribe();
406
+ this.closed = false;
407
+ this.isStopped = false;
408
+ this._parentOrParents = _parentOrParents;
409
+ return this;
410
+ };
411
+ return Subscriber2;
412
+ }(Subscription_1.Subscription);
413
+ exports.Subscriber = Subscriber;
414
+ var SafeSubscriber = function(_super) {
415
+ __extends(SafeSubscriber2, _super);
416
+ function SafeSubscriber2(_parentSubscriber, observerOrNext, error, complete) {
417
+ var _this = _super.call(this) || this;
418
+ _this._parentSubscriber = _parentSubscriber;
419
+ var next;
420
+ var context = _this;
421
+ if (isFunction_1.isFunction(observerOrNext)) {
422
+ next = observerOrNext;
423
+ } else if (observerOrNext) {
424
+ next = observerOrNext.next;
425
+ error = observerOrNext.error;
426
+ complete = observerOrNext.complete;
427
+ if (observerOrNext !== Observer_1.empty) {
428
+ context = Object.create(observerOrNext);
429
+ if (isFunction_1.isFunction(context.unsubscribe)) {
430
+ _this.add(context.unsubscribe.bind(context));
431
+ }
432
+ context.unsubscribe = _this.unsubscribe.bind(_this);
433
+ }
434
+ }
435
+ _this._context = context;
436
+ _this._next = next;
437
+ _this._error = error;
438
+ _this._complete = complete;
439
+ return _this;
440
+ }
441
+ SafeSubscriber2.prototype.next = function(value) {
442
+ if (!this.isStopped && this._next) {
443
+ var _parentSubscriber = this._parentSubscriber;
444
+ if (!config_1.config.useDeprecatedSynchronousErrorHandling || !_parentSubscriber.syncErrorThrowable) {
445
+ this.__tryOrUnsub(this._next, value);
446
+ } else if (this.__tryOrSetError(_parentSubscriber, this._next, value)) {
447
+ this.unsubscribe();
448
+ }
449
+ }
450
+ };
451
+ SafeSubscriber2.prototype.error = function(err) {
452
+ if (!this.isStopped) {
453
+ var _parentSubscriber = this._parentSubscriber;
454
+ var useDeprecatedSynchronousErrorHandling = config_1.config.useDeprecatedSynchronousErrorHandling;
455
+ if (this._error) {
456
+ if (!useDeprecatedSynchronousErrorHandling || !_parentSubscriber.syncErrorThrowable) {
457
+ this.__tryOrUnsub(this._error, err);
458
+ this.unsubscribe();
459
+ } else {
460
+ this.__tryOrSetError(_parentSubscriber, this._error, err);
461
+ this.unsubscribe();
462
+ }
463
+ } else if (!_parentSubscriber.syncErrorThrowable) {
464
+ this.unsubscribe();
465
+ if (useDeprecatedSynchronousErrorHandling) {
466
+ throw err;
467
+ }
468
+ hostReportError_1.hostReportError(err);
469
+ } else {
470
+ if (useDeprecatedSynchronousErrorHandling) {
471
+ _parentSubscriber.syncErrorValue = err;
472
+ _parentSubscriber.syncErrorThrown = true;
473
+ } else {
474
+ hostReportError_1.hostReportError(err);
475
+ }
476
+ this.unsubscribe();
477
+ }
478
+ }
479
+ };
480
+ SafeSubscriber2.prototype.complete = function() {
481
+ var _this = this;
482
+ if (!this.isStopped) {
483
+ var _parentSubscriber = this._parentSubscriber;
484
+ if (this._complete) {
485
+ var wrappedComplete = function() {
486
+ return _this._complete.call(_this._context);
487
+ };
488
+ if (!config_1.config.useDeprecatedSynchronousErrorHandling || !_parentSubscriber.syncErrorThrowable) {
489
+ this.__tryOrUnsub(wrappedComplete);
490
+ this.unsubscribe();
491
+ } else {
492
+ this.__tryOrSetError(_parentSubscriber, wrappedComplete);
493
+ this.unsubscribe();
494
+ }
495
+ } else {
496
+ this.unsubscribe();
497
+ }
498
+ }
499
+ };
500
+ SafeSubscriber2.prototype.__tryOrUnsub = function(fn, value) {
501
+ try {
502
+ fn.call(this._context, value);
503
+ } catch (err) {
504
+ this.unsubscribe();
505
+ if (config_1.config.useDeprecatedSynchronousErrorHandling) {
506
+ throw err;
507
+ } else {
508
+ hostReportError_1.hostReportError(err);
509
+ }
510
+ }
511
+ };
512
+ SafeSubscriber2.prototype.__tryOrSetError = function(parent, fn, value) {
513
+ if (!config_1.config.useDeprecatedSynchronousErrorHandling) {
514
+ throw new Error("bad call");
515
+ }
516
+ try {
517
+ fn.call(this._context, value);
518
+ } catch (err) {
519
+ if (config_1.config.useDeprecatedSynchronousErrorHandling) {
520
+ parent.syncErrorValue = err;
521
+ parent.syncErrorThrown = true;
522
+ return true;
523
+ } else {
524
+ hostReportError_1.hostReportError(err);
525
+ return true;
526
+ }
527
+ }
528
+ return false;
529
+ };
530
+ SafeSubscriber2.prototype._unsubscribe = function() {
531
+ var _parentSubscriber = this._parentSubscriber;
532
+ this._context = null;
533
+ this._parentSubscriber = null;
534
+ _parentSubscriber.unsubscribe();
535
+ };
536
+ return SafeSubscriber2;
537
+ }(Subscriber);
538
+ exports.SafeSubscriber = SafeSubscriber;
539
+ }
540
+ });
541
+
542
+ // node_modules/rxjs/internal/util/canReportError.js
543
+ var require_canReportError = __commonJS({
544
+ "node_modules/rxjs/internal/util/canReportError.js"(exports) {
545
+ "use strict";
546
+ Object.defineProperty(exports, "__esModule", { value: true });
547
+ var Subscriber_1 = require_Subscriber();
548
+ function canReportError(observer) {
549
+ while (observer) {
550
+ var _a = observer, closed_1 = _a.closed, destination = _a.destination, isStopped = _a.isStopped;
551
+ if (closed_1 || isStopped) {
552
+ return false;
553
+ } else if (destination && destination instanceof Subscriber_1.Subscriber) {
554
+ observer = destination;
555
+ } else {
556
+ observer = null;
557
+ }
558
+ }
559
+ return true;
560
+ }
561
+ exports.canReportError = canReportError;
562
+ }
563
+ });
564
+
565
+ // node_modules/rxjs/internal/util/toSubscriber.js
566
+ var require_toSubscriber = __commonJS({
567
+ "node_modules/rxjs/internal/util/toSubscriber.js"(exports) {
568
+ "use strict";
569
+ Object.defineProperty(exports, "__esModule", { value: true });
570
+ var Subscriber_1 = require_Subscriber();
571
+ var rxSubscriber_1 = require_rxSubscriber();
572
+ var Observer_1 = require_Observer();
573
+ function toSubscriber(nextOrObserver, error, complete) {
574
+ if (nextOrObserver) {
575
+ if (nextOrObserver instanceof Subscriber_1.Subscriber) {
576
+ return nextOrObserver;
577
+ }
578
+ if (nextOrObserver[rxSubscriber_1.rxSubscriber]) {
579
+ return nextOrObserver[rxSubscriber_1.rxSubscriber]();
580
+ }
581
+ }
582
+ if (!nextOrObserver && !error && !complete) {
583
+ return new Subscriber_1.Subscriber(Observer_1.empty);
584
+ }
585
+ return new Subscriber_1.Subscriber(nextOrObserver, error, complete);
586
+ }
587
+ exports.toSubscriber = toSubscriber;
588
+ }
589
+ });
590
+
591
+ // node_modules/rxjs/internal/symbol/observable.js
592
+ var require_observable = __commonJS({
593
+ "node_modules/rxjs/internal/symbol/observable.js"(exports) {
594
+ "use strict";
595
+ Object.defineProperty(exports, "__esModule", { value: true });
596
+ exports.observable = function() {
597
+ return typeof Symbol === "function" && Symbol.observable || "@@observable";
598
+ }();
599
+ }
600
+ });
601
+
602
+ // node_modules/rxjs/internal/util/identity.js
603
+ var require_identity = __commonJS({
604
+ "node_modules/rxjs/internal/util/identity.js"(exports) {
605
+ "use strict";
606
+ Object.defineProperty(exports, "__esModule", { value: true });
607
+ function identity(x) {
608
+ return x;
609
+ }
610
+ exports.identity = identity;
611
+ }
612
+ });
613
+
614
+ // node_modules/rxjs/internal/util/pipe.js
615
+ var require_pipe = __commonJS({
616
+ "node_modules/rxjs/internal/util/pipe.js"(exports) {
617
+ "use strict";
618
+ Object.defineProperty(exports, "__esModule", { value: true });
619
+ var identity_1 = require_identity();
620
+ function pipe() {
621
+ var fns = [];
622
+ for (var _i = 0; _i < arguments.length; _i++) {
623
+ fns[_i] = arguments[_i];
624
+ }
625
+ return pipeFromArray(fns);
626
+ }
627
+ exports.pipe = pipe;
628
+ function pipeFromArray(fns) {
629
+ if (fns.length === 0) {
630
+ return identity_1.identity;
631
+ }
632
+ if (fns.length === 1) {
633
+ return fns[0];
634
+ }
635
+ return function piped(input) {
636
+ return fns.reduce(function(prev, fn) {
637
+ return fn(prev);
638
+ }, input);
639
+ };
640
+ }
641
+ exports.pipeFromArray = pipeFromArray;
642
+ }
643
+ });
644
+
645
+ // node_modules/rxjs/internal/Observable.js
646
+ var require_Observable = __commonJS({
647
+ "node_modules/rxjs/internal/Observable.js"(exports) {
648
+ "use strict";
649
+ Object.defineProperty(exports, "__esModule", { value: true });
650
+ var canReportError_1 = require_canReportError();
651
+ var toSubscriber_1 = require_toSubscriber();
652
+ var observable_1 = require_observable();
653
+ var pipe_1 = require_pipe();
654
+ var config_1 = require_config();
655
+ var Observable2 = function() {
656
+ function Observable3(subscribe) {
657
+ this._isScalar = false;
658
+ if (subscribe) {
659
+ this._subscribe = subscribe;
660
+ }
661
+ }
662
+ Observable3.prototype.lift = function(operator) {
663
+ var observable2 = new Observable3();
664
+ observable2.source = this;
665
+ observable2.operator = operator;
666
+ return observable2;
667
+ };
668
+ Observable3.prototype.subscribe = function(observerOrNext, error, complete) {
669
+ var operator = this.operator;
670
+ var sink = toSubscriber_1.toSubscriber(observerOrNext, error, complete);
671
+ if (operator) {
672
+ sink.add(operator.call(sink, this.source));
673
+ } else {
674
+ sink.add(this.source || config_1.config.useDeprecatedSynchronousErrorHandling && !sink.syncErrorThrowable ? this._subscribe(sink) : this._trySubscribe(sink));
675
+ }
676
+ if (config_1.config.useDeprecatedSynchronousErrorHandling) {
677
+ if (sink.syncErrorThrowable) {
678
+ sink.syncErrorThrowable = false;
679
+ if (sink.syncErrorThrown) {
680
+ throw sink.syncErrorValue;
681
+ }
682
+ }
683
+ }
684
+ return sink;
685
+ };
686
+ Observable3.prototype._trySubscribe = function(sink) {
687
+ try {
688
+ return this._subscribe(sink);
689
+ } catch (err) {
690
+ if (config_1.config.useDeprecatedSynchronousErrorHandling) {
691
+ sink.syncErrorThrown = true;
692
+ sink.syncErrorValue = err;
693
+ }
694
+ if (canReportError_1.canReportError(sink)) {
695
+ sink.error(err);
696
+ } else {
697
+ console.warn(err);
698
+ }
699
+ }
700
+ };
701
+ Observable3.prototype.forEach = function(next, promiseCtor) {
702
+ var _this = this;
703
+ promiseCtor = getPromiseCtor(promiseCtor);
704
+ return new promiseCtor(function(resolve, reject) {
705
+ var subscription;
706
+ subscription = _this.subscribe(function(value) {
707
+ try {
708
+ next(value);
709
+ } catch (err) {
710
+ reject(err);
711
+ if (subscription) {
712
+ subscription.unsubscribe();
713
+ }
714
+ }
715
+ }, reject, resolve);
716
+ });
717
+ };
718
+ Observable3.prototype._subscribe = function(subscriber) {
719
+ var source = this.source;
720
+ return source && source.subscribe(subscriber);
721
+ };
722
+ Observable3.prototype[observable_1.observable] = function() {
723
+ return this;
724
+ };
725
+ Observable3.prototype.pipe = function() {
726
+ var operations = [];
727
+ for (var _i = 0; _i < arguments.length; _i++) {
728
+ operations[_i] = arguments[_i];
729
+ }
730
+ if (operations.length === 0) {
731
+ return this;
732
+ }
733
+ return pipe_1.pipeFromArray(operations)(this);
734
+ };
735
+ Observable3.prototype.toPromise = function(promiseCtor) {
736
+ var _this = this;
737
+ promiseCtor = getPromiseCtor(promiseCtor);
738
+ return new promiseCtor(function(resolve, reject) {
739
+ var value;
740
+ _this.subscribe(function(x) {
741
+ return value = x;
742
+ }, function(err) {
743
+ return reject(err);
744
+ }, function() {
745
+ return resolve(value);
746
+ });
747
+ });
748
+ };
749
+ Observable3.create = function(subscribe) {
750
+ return new Observable3(subscribe);
751
+ };
752
+ return Observable3;
753
+ }();
754
+ exports.Observable = Observable2;
755
+ function getPromiseCtor(promiseCtor) {
756
+ if (!promiseCtor) {
757
+ promiseCtor = config_1.config.Promise || Promise;
758
+ }
759
+ if (!promiseCtor) {
760
+ throw new Error("no Promise impl found");
761
+ }
762
+ return promiseCtor;
763
+ }
764
+ }
765
+ });
766
+
767
+ // node_modules/rxjs/internal/operators/filter.js
768
+ var require_filter = __commonJS({
769
+ "node_modules/rxjs/internal/operators/filter.js"(exports) {
770
+ "use strict";
771
+ var __extends = exports && exports.__extends || function() {
772
+ var extendStatics = function(d, b) {
773
+ extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {
774
+ d2.__proto__ = b2;
775
+ } || function(d2, b2) {
776
+ for (var p in b2)
777
+ if (b2.hasOwnProperty(p))
778
+ d2[p] = b2[p];
779
+ };
780
+ return extendStatics(d, b);
781
+ };
782
+ return function(d, b) {
783
+ extendStatics(d, b);
784
+ function __() {
785
+ this.constructor = d;
786
+ }
787
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
788
+ };
789
+ }();
790
+ Object.defineProperty(exports, "__esModule", { value: true });
791
+ var Subscriber_1 = require_Subscriber();
792
+ function filter2(predicate, thisArg) {
793
+ return function filterOperatorFunction(source) {
794
+ return source.lift(new FilterOperator(predicate, thisArg));
795
+ };
796
+ }
797
+ exports.filter = filter2;
798
+ var FilterOperator = function() {
799
+ function FilterOperator2(predicate, thisArg) {
800
+ this.predicate = predicate;
801
+ this.thisArg = thisArg;
802
+ }
803
+ FilterOperator2.prototype.call = function(subscriber, source) {
804
+ return source.subscribe(new FilterSubscriber(subscriber, this.predicate, this.thisArg));
805
+ };
806
+ return FilterOperator2;
807
+ }();
808
+ var FilterSubscriber = function(_super) {
809
+ __extends(FilterSubscriber2, _super);
810
+ function FilterSubscriber2(destination, predicate, thisArg) {
811
+ var _this = _super.call(this, destination) || this;
812
+ _this.predicate = predicate;
813
+ _this.thisArg = thisArg;
814
+ _this.count = 0;
815
+ return _this;
816
+ }
817
+ FilterSubscriber2.prototype._next = function(value) {
818
+ var result;
819
+ try {
820
+ result = this.predicate.call(this.thisArg, value, this.count++);
821
+ } catch (err) {
822
+ this.destination.error(err);
823
+ return;
824
+ }
825
+ if (result) {
826
+ this.destination.next(value);
827
+ }
828
+ };
829
+ return FilterSubscriber2;
830
+ }(Subscriber_1.Subscriber);
831
+ }
832
+ });
833
+
834
+ // node_modules/rxjs/internal/operators/map.js
835
+ var require_map = __commonJS({
836
+ "node_modules/rxjs/internal/operators/map.js"(exports) {
837
+ "use strict";
838
+ var __extends = exports && exports.__extends || function() {
839
+ var extendStatics = function(d, b) {
840
+ extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {
841
+ d2.__proto__ = b2;
842
+ } || function(d2, b2) {
843
+ for (var p in b2)
844
+ if (b2.hasOwnProperty(p))
845
+ d2[p] = b2[p];
846
+ };
847
+ return extendStatics(d, b);
848
+ };
849
+ return function(d, b) {
850
+ extendStatics(d, b);
851
+ function __() {
852
+ this.constructor = d;
853
+ }
854
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
855
+ };
856
+ }();
857
+ Object.defineProperty(exports, "__esModule", { value: true });
858
+ var Subscriber_1 = require_Subscriber();
859
+ function map2(project, thisArg) {
860
+ return function mapOperation(source) {
861
+ if (typeof project !== "function") {
862
+ throw new TypeError("argument is not a function. Are you looking for `mapTo()`?");
863
+ }
864
+ return source.lift(new MapOperator(project, thisArg));
865
+ };
866
+ }
867
+ exports.map = map2;
868
+ var MapOperator = function() {
869
+ function MapOperator2(project, thisArg) {
870
+ this.project = project;
871
+ this.thisArg = thisArg;
872
+ }
873
+ MapOperator2.prototype.call = function(subscriber, source) {
874
+ return source.subscribe(new MapSubscriber(subscriber, this.project, this.thisArg));
875
+ };
876
+ return MapOperator2;
877
+ }();
878
+ exports.MapOperator = MapOperator;
879
+ var MapSubscriber = function(_super) {
880
+ __extends(MapSubscriber2, _super);
881
+ function MapSubscriber2(destination, project, thisArg) {
882
+ var _this = _super.call(this, destination) || this;
883
+ _this.project = project;
884
+ _this.count = 0;
885
+ _this.thisArg = thisArg || _this;
886
+ return _this;
887
+ }
888
+ MapSubscriber2.prototype._next = function(value) {
889
+ var result;
890
+ try {
891
+ result = this.project.call(this.thisArg, value, this.count++);
892
+ } catch (err) {
893
+ this.destination.error(err);
894
+ return;
895
+ }
896
+ this.destination.next(result);
897
+ };
898
+ return MapSubscriber2;
899
+ }(Subscriber_1.Subscriber);
900
+ }
901
+ });
902
+
903
+ // node_modules/event-source-polyfill/src/eventsource.js
904
+ var require_eventsource = __commonJS({
905
+ "node_modules/event-source-polyfill/src/eventsource.js"(exports, module) {
906
+ (function(global) {
907
+ "use strict";
908
+ var setTimeout2 = global.setTimeout;
909
+ var clearTimeout2 = global.clearTimeout;
910
+ var XMLHttpRequest = global.XMLHttpRequest;
911
+ var XDomainRequest = global.XDomainRequest;
912
+ var ActiveXObject = global.ActiveXObject;
913
+ var NativeEventSource = global.EventSource;
914
+ var document = global.document;
915
+ var Promise2 = global.Promise;
916
+ var fetch = global.fetch;
917
+ var Response = global.Response;
918
+ var TextDecoder = global.TextDecoder;
919
+ var TextEncoder = global.TextEncoder;
920
+ var AbortController = global.AbortController;
921
+ if (typeof window !== "undefined" && typeof document !== "undefined" && !("readyState" in document) && document.body == null) {
922
+ document.readyState = "loading";
923
+ window.addEventListener("load", function(event) {
924
+ document.readyState = "complete";
925
+ }, false);
926
+ }
927
+ if (XMLHttpRequest == null && ActiveXObject != null) {
928
+ XMLHttpRequest = function() {
929
+ return new ActiveXObject("Microsoft.XMLHTTP");
930
+ };
931
+ }
932
+ if (Object.create == void 0) {
933
+ Object.create = function(C) {
934
+ function F() {
935
+ }
936
+ F.prototype = C;
937
+ return new F();
938
+ };
939
+ }
940
+ if (!Date.now) {
941
+ Date.now = function now() {
942
+ return new Date().getTime();
943
+ };
944
+ }
945
+ if (AbortController == void 0) {
946
+ var originalFetch2 = fetch;
947
+ fetch = function(url, options) {
948
+ var signal = options.signal;
949
+ return originalFetch2(url, { headers: options.headers, credentials: options.credentials, cache: options.cache }).then(function(response) {
950
+ var reader = response.body.getReader();
951
+ signal._reader = reader;
952
+ if (signal._aborted) {
953
+ signal._reader.cancel();
954
+ }
955
+ return {
956
+ status: response.status,
957
+ statusText: response.statusText,
958
+ headers: response.headers,
959
+ body: {
960
+ getReader: function() {
961
+ return reader;
962
+ }
963
+ }
964
+ };
965
+ });
966
+ };
967
+ AbortController = function() {
968
+ this.signal = {
969
+ _reader: null,
970
+ _aborted: false
971
+ };
972
+ this.abort = function() {
973
+ if (this.signal._reader != null) {
974
+ this.signal._reader.cancel();
975
+ }
976
+ this.signal._aborted = true;
977
+ };
978
+ };
979
+ }
980
+ function TextDecoderPolyfill() {
981
+ this.bitsNeeded = 0;
982
+ this.codePoint = 0;
983
+ }
984
+ TextDecoderPolyfill.prototype.decode = function(octets) {
985
+ function valid(codePoint2, shift, octetsCount2) {
986
+ if (octetsCount2 === 1) {
987
+ return codePoint2 >= 128 >> shift && codePoint2 << shift <= 2047;
988
+ }
989
+ if (octetsCount2 === 2) {
990
+ return codePoint2 >= 2048 >> shift && codePoint2 << shift <= 55295 || codePoint2 >= 57344 >> shift && codePoint2 << shift <= 65535;
991
+ }
992
+ if (octetsCount2 === 3) {
993
+ return codePoint2 >= 65536 >> shift && codePoint2 << shift <= 1114111;
994
+ }
995
+ throw new Error();
996
+ }
997
+ function octetsCount(bitsNeeded2, codePoint2) {
998
+ if (bitsNeeded2 === 6 * 1) {
999
+ return codePoint2 >> 6 > 15 ? 3 : codePoint2 > 31 ? 2 : 1;
1000
+ }
1001
+ if (bitsNeeded2 === 6 * 2) {
1002
+ return codePoint2 > 15 ? 3 : 2;
1003
+ }
1004
+ if (bitsNeeded2 === 6 * 3) {
1005
+ return 3;
1006
+ }
1007
+ throw new Error();
1008
+ }
1009
+ var REPLACER = 65533;
1010
+ var string = "";
1011
+ var bitsNeeded = this.bitsNeeded;
1012
+ var codePoint = this.codePoint;
1013
+ for (var i = 0; i < octets.length; i += 1) {
1014
+ var octet = octets[i];
1015
+ if (bitsNeeded !== 0) {
1016
+ if (octet < 128 || octet > 191 || !valid(codePoint << 6 | octet & 63, bitsNeeded - 6, octetsCount(bitsNeeded, codePoint))) {
1017
+ bitsNeeded = 0;
1018
+ codePoint = REPLACER;
1019
+ string += String.fromCharCode(codePoint);
1020
+ }
1021
+ }
1022
+ if (bitsNeeded === 0) {
1023
+ if (octet >= 0 && octet <= 127) {
1024
+ bitsNeeded = 0;
1025
+ codePoint = octet;
1026
+ } else if (octet >= 192 && octet <= 223) {
1027
+ bitsNeeded = 6 * 1;
1028
+ codePoint = octet & 31;
1029
+ } else if (octet >= 224 && octet <= 239) {
1030
+ bitsNeeded = 6 * 2;
1031
+ codePoint = octet & 15;
1032
+ } else if (octet >= 240 && octet <= 247) {
1033
+ bitsNeeded = 6 * 3;
1034
+ codePoint = octet & 7;
1035
+ } else {
1036
+ bitsNeeded = 0;
1037
+ codePoint = REPLACER;
1038
+ }
1039
+ if (bitsNeeded !== 0 && !valid(codePoint, bitsNeeded, octetsCount(bitsNeeded, codePoint))) {
1040
+ bitsNeeded = 0;
1041
+ codePoint = REPLACER;
1042
+ }
1043
+ } else {
1044
+ bitsNeeded -= 6;
1045
+ codePoint = codePoint << 6 | octet & 63;
1046
+ }
1047
+ if (bitsNeeded === 0) {
1048
+ if (codePoint <= 65535) {
1049
+ string += String.fromCharCode(codePoint);
1050
+ } else {
1051
+ string += String.fromCharCode(55296 + (codePoint - 65535 - 1 >> 10));
1052
+ string += String.fromCharCode(56320 + (codePoint - 65535 - 1 & 1023));
1053
+ }
1054
+ }
1055
+ }
1056
+ this.bitsNeeded = bitsNeeded;
1057
+ this.codePoint = codePoint;
1058
+ return string;
1059
+ };
1060
+ var supportsStreamOption = function() {
1061
+ try {
1062
+ return new TextDecoder().decode(new TextEncoder().encode("test"), { stream: true }) === "test";
1063
+ } catch (error) {
1064
+ console.debug("TextDecoder does not support streaming option. Using polyfill instead: " + error);
1065
+ }
1066
+ return false;
1067
+ };
1068
+ if (TextDecoder == void 0 || TextEncoder == void 0 || !supportsStreamOption()) {
1069
+ TextDecoder = TextDecoderPolyfill;
1070
+ }
1071
+ var k = function() {
1072
+ };
1073
+ function XHRWrapper(xhr) {
1074
+ this.withCredentials = false;
1075
+ this.readyState = 0;
1076
+ this.status = 0;
1077
+ this.statusText = "";
1078
+ this.responseText = "";
1079
+ this.onprogress = k;
1080
+ this.onload = k;
1081
+ this.onerror = k;
1082
+ this.onreadystatechange = k;
1083
+ this._contentType = "";
1084
+ this._xhr = xhr;
1085
+ this._sendTimeout = 0;
1086
+ this._abort = k;
1087
+ }
1088
+ XHRWrapper.prototype.open = function(method, url) {
1089
+ this._abort(true);
1090
+ var that = this;
1091
+ var xhr = this._xhr;
1092
+ var state = 1;
1093
+ var timeout = 0;
1094
+ this._abort = function(silent) {
1095
+ if (that._sendTimeout !== 0) {
1096
+ clearTimeout2(that._sendTimeout);
1097
+ that._sendTimeout = 0;
1098
+ }
1099
+ if (state === 1 || state === 2 || state === 3) {
1100
+ state = 4;
1101
+ xhr.onload = k;
1102
+ xhr.onerror = k;
1103
+ xhr.onabort = k;
1104
+ xhr.onprogress = k;
1105
+ xhr.onreadystatechange = k;
1106
+ xhr.abort();
1107
+ if (timeout !== 0) {
1108
+ clearTimeout2(timeout);
1109
+ timeout = 0;
1110
+ }
1111
+ if (!silent) {
1112
+ that.readyState = 4;
1113
+ that.onabort(null);
1114
+ that.onreadystatechange();
1115
+ }
1116
+ }
1117
+ state = 0;
1118
+ };
1119
+ var onStart = function() {
1120
+ if (state === 1) {
1121
+ var status = 0;
1122
+ var statusText = "";
1123
+ var contentType = void 0;
1124
+ if (!("contentType" in xhr)) {
1125
+ try {
1126
+ status = xhr.status;
1127
+ statusText = xhr.statusText;
1128
+ contentType = xhr.getResponseHeader("Content-Type");
1129
+ } catch (error) {
1130
+ status = 0;
1131
+ statusText = "";
1132
+ contentType = void 0;
1133
+ }
1134
+ } else {
1135
+ status = 200;
1136
+ statusText = "OK";
1137
+ contentType = xhr.contentType;
1138
+ }
1139
+ if (status !== 0) {
1140
+ state = 2;
1141
+ that.readyState = 2;
1142
+ that.status = status;
1143
+ that.statusText = statusText;
1144
+ that._contentType = contentType;
1145
+ that.onreadystatechange();
1146
+ }
1147
+ }
1148
+ };
1149
+ var onProgress = function() {
1150
+ onStart();
1151
+ if (state === 2 || state === 3) {
1152
+ state = 3;
1153
+ var responseText = "";
1154
+ try {
1155
+ responseText = xhr.responseText;
1156
+ } catch (error) {
1157
+ }
1158
+ that.readyState = 3;
1159
+ that.responseText = responseText;
1160
+ that.onprogress();
1161
+ }
1162
+ };
1163
+ var onFinish = function(type, event) {
1164
+ if (event == null || event.preventDefault == null) {
1165
+ event = {
1166
+ preventDefault: k
1167
+ };
1168
+ }
1169
+ onProgress();
1170
+ if (state === 1 || state === 2 || state === 3) {
1171
+ state = 4;
1172
+ if (timeout !== 0) {
1173
+ clearTimeout2(timeout);
1174
+ timeout = 0;
1175
+ }
1176
+ that.readyState = 4;
1177
+ if (type === "load") {
1178
+ that.onload(event);
1179
+ } else if (type === "error") {
1180
+ that.onerror(event);
1181
+ } else if (type === "abort") {
1182
+ that.onabort(event);
1183
+ } else {
1184
+ throw new TypeError();
1185
+ }
1186
+ that.onreadystatechange();
1187
+ }
1188
+ };
1189
+ var onReadyStateChange = function(event) {
1190
+ if (xhr != void 0) {
1191
+ if (xhr.readyState === 4) {
1192
+ if (!("onload" in xhr) || !("onerror" in xhr) || !("onabort" in xhr)) {
1193
+ onFinish(xhr.responseText === "" ? "error" : "load", event);
1194
+ }
1195
+ } else if (xhr.readyState === 3) {
1196
+ if (!("onprogress" in xhr)) {
1197
+ onProgress();
1198
+ }
1199
+ } else if (xhr.readyState === 2) {
1200
+ onStart();
1201
+ }
1202
+ }
1203
+ };
1204
+ var onTimeout = function() {
1205
+ timeout = setTimeout2(function() {
1206
+ onTimeout();
1207
+ }, 500);
1208
+ if (xhr.readyState === 3) {
1209
+ onProgress();
1210
+ }
1211
+ };
1212
+ if ("onload" in xhr) {
1213
+ xhr.onload = function(event) {
1214
+ onFinish("load", event);
1215
+ };
1216
+ }
1217
+ if ("onerror" in xhr) {
1218
+ xhr.onerror = function(event) {
1219
+ onFinish("error", event);
1220
+ };
1221
+ }
1222
+ if ("onabort" in xhr) {
1223
+ xhr.onabort = function(event) {
1224
+ onFinish("abort", event);
1225
+ };
1226
+ }
1227
+ if ("onprogress" in xhr) {
1228
+ xhr.onprogress = onProgress;
1229
+ }
1230
+ if ("onreadystatechange" in xhr) {
1231
+ xhr.onreadystatechange = function(event) {
1232
+ onReadyStateChange(event);
1233
+ };
1234
+ }
1235
+ if ("contentType" in xhr || !("ontimeout" in XMLHttpRequest.prototype)) {
1236
+ url += (url.indexOf("?") === -1 ? "?" : "&") + "padding=true";
1237
+ }
1238
+ xhr.open(method, url, true);
1239
+ if ("readyState" in xhr) {
1240
+ timeout = setTimeout2(function() {
1241
+ onTimeout();
1242
+ }, 0);
1243
+ }
1244
+ };
1245
+ XHRWrapper.prototype.abort = function() {
1246
+ this._abort(false);
1247
+ };
1248
+ XHRWrapper.prototype.getResponseHeader = function(name) {
1249
+ return this._contentType;
1250
+ };
1251
+ XHRWrapper.prototype.setRequestHeader = function(name, value) {
1252
+ var xhr = this._xhr;
1253
+ if ("setRequestHeader" in xhr) {
1254
+ xhr.setRequestHeader(name, value);
1255
+ }
1256
+ };
1257
+ XHRWrapper.prototype.getAllResponseHeaders = function() {
1258
+ return this._xhr.getAllResponseHeaders != void 0 ? this._xhr.getAllResponseHeaders() || "" : "";
1259
+ };
1260
+ XHRWrapper.prototype.send = function() {
1261
+ if ((!("ontimeout" in XMLHttpRequest.prototype) || !("sendAsBinary" in XMLHttpRequest.prototype) && !("mozAnon" in XMLHttpRequest.prototype)) && document != void 0 && document.readyState != void 0 && document.readyState !== "complete") {
1262
+ var that = this;
1263
+ that._sendTimeout = setTimeout2(function() {
1264
+ that._sendTimeout = 0;
1265
+ that.send();
1266
+ }, 4);
1267
+ return;
1268
+ }
1269
+ var xhr = this._xhr;
1270
+ if ("withCredentials" in xhr) {
1271
+ xhr.withCredentials = this.withCredentials;
1272
+ }
1273
+ try {
1274
+ xhr.send(void 0);
1275
+ } catch (error1) {
1276
+ throw error1;
1277
+ }
1278
+ };
1279
+ function toLowerCase(name) {
1280
+ return name.replace(/[A-Z]/g, function(c) {
1281
+ return String.fromCharCode(c.charCodeAt(0) + 32);
1282
+ });
1283
+ }
1284
+ function HeadersPolyfill(all) {
1285
+ var map2 = /* @__PURE__ */ Object.create(null);
1286
+ var array = all.split("\r\n");
1287
+ for (var i = 0; i < array.length; i += 1) {
1288
+ var line = array[i];
1289
+ var parts = line.split(": ");
1290
+ var name = parts.shift();
1291
+ var value = parts.join(": ");
1292
+ map2[toLowerCase(name)] = value;
1293
+ }
1294
+ this._map = map2;
1295
+ }
1296
+ HeadersPolyfill.prototype.get = function(name) {
1297
+ return this._map[toLowerCase(name)];
1298
+ };
1299
+ if (XMLHttpRequest != null && XMLHttpRequest.HEADERS_RECEIVED == null) {
1300
+ XMLHttpRequest.HEADERS_RECEIVED = 2;
1301
+ }
1302
+ function XHRTransport() {
1303
+ }
1304
+ XHRTransport.prototype.open = function(xhr, onStartCallback, onProgressCallback, onFinishCallback, url, withCredentials, headers) {
1305
+ xhr.open("GET", url);
1306
+ var offset = 0;
1307
+ xhr.onprogress = function() {
1308
+ var responseText = xhr.responseText;
1309
+ var chunk = responseText.slice(offset);
1310
+ offset += chunk.length;
1311
+ onProgressCallback(chunk);
1312
+ };
1313
+ xhr.onerror = function(event) {
1314
+ event.preventDefault();
1315
+ onFinishCallback(new Error("NetworkError"));
1316
+ };
1317
+ xhr.onload = function() {
1318
+ onFinishCallback(null);
1319
+ };
1320
+ xhr.onabort = function() {
1321
+ onFinishCallback(null);
1322
+ };
1323
+ xhr.onreadystatechange = function() {
1324
+ if (xhr.readyState === XMLHttpRequest.HEADERS_RECEIVED) {
1325
+ var status = xhr.status;
1326
+ var statusText = xhr.statusText;
1327
+ var contentType = xhr.getResponseHeader("Content-Type");
1328
+ var headers2 = xhr.getAllResponseHeaders();
1329
+ onStartCallback(status, statusText, contentType, new HeadersPolyfill(headers2));
1330
+ }
1331
+ };
1332
+ xhr.withCredentials = withCredentials;
1333
+ for (var name in headers) {
1334
+ if (Object.prototype.hasOwnProperty.call(headers, name)) {
1335
+ xhr.setRequestHeader(name, headers[name]);
1336
+ }
1337
+ }
1338
+ xhr.send();
1339
+ return xhr;
1340
+ };
1341
+ function HeadersWrapper(headers) {
1342
+ this._headers = headers;
1343
+ }
1344
+ HeadersWrapper.prototype.get = function(name) {
1345
+ return this._headers.get(name);
1346
+ };
1347
+ function FetchTransport() {
1348
+ }
1349
+ FetchTransport.prototype.open = function(xhr, onStartCallback, onProgressCallback, onFinishCallback, url, withCredentials, headers) {
1350
+ var reader = null;
1351
+ var controller = new AbortController();
1352
+ var signal = controller.signal;
1353
+ var textDecoder = new TextDecoder();
1354
+ fetch(url, {
1355
+ headers,
1356
+ credentials: withCredentials ? "include" : "same-origin",
1357
+ signal,
1358
+ cache: "no-store"
1359
+ }).then(function(response) {
1360
+ reader = response.body.getReader();
1361
+ onStartCallback(response.status, response.statusText, response.headers.get("Content-Type"), new HeadersWrapper(response.headers));
1362
+ return new Promise2(function(resolve, reject) {
1363
+ var readNextChunk = function() {
1364
+ reader.read().then(function(result) {
1365
+ if (result.done) {
1366
+ resolve(void 0);
1367
+ } else {
1368
+ var chunk = textDecoder.decode(result.value, { stream: true });
1369
+ onProgressCallback(chunk);
1370
+ readNextChunk();
1371
+ }
1372
+ })["catch"](function(error) {
1373
+ reject(error);
1374
+ });
1375
+ };
1376
+ readNextChunk();
1377
+ });
1378
+ })["catch"](function(error) {
1379
+ if (error.name === "AbortError") {
1380
+ return void 0;
1381
+ } else {
1382
+ return error;
1383
+ }
1384
+ }).then(function(error) {
1385
+ onFinishCallback(error);
1386
+ });
1387
+ return {
1388
+ abort: function() {
1389
+ if (reader != null) {
1390
+ reader.cancel();
1391
+ }
1392
+ controller.abort();
1393
+ }
1394
+ };
1395
+ };
1396
+ function EventTarget() {
1397
+ this._listeners = /* @__PURE__ */ Object.create(null);
1398
+ }
1399
+ function throwError(e) {
1400
+ setTimeout2(function() {
1401
+ throw e;
1402
+ }, 0);
1403
+ }
1404
+ EventTarget.prototype.dispatchEvent = function(event) {
1405
+ event.target = this;
1406
+ var typeListeners = this._listeners[event.type];
1407
+ if (typeListeners != void 0) {
1408
+ var length = typeListeners.length;
1409
+ for (var i = 0; i < length; i += 1) {
1410
+ var listener = typeListeners[i];
1411
+ try {
1412
+ if (typeof listener.handleEvent === "function") {
1413
+ listener.handleEvent(event);
1414
+ } else {
1415
+ listener.call(this, event);
1416
+ }
1417
+ } catch (e) {
1418
+ throwError(e);
1419
+ }
1420
+ }
1421
+ }
1422
+ };
1423
+ EventTarget.prototype.addEventListener = function(type, listener) {
1424
+ type = String(type);
1425
+ var listeners = this._listeners;
1426
+ var typeListeners = listeners[type];
1427
+ if (typeListeners == void 0) {
1428
+ typeListeners = [];
1429
+ listeners[type] = typeListeners;
1430
+ }
1431
+ var found = false;
1432
+ for (var i = 0; i < typeListeners.length; i += 1) {
1433
+ if (typeListeners[i] === listener) {
1434
+ found = true;
1435
+ }
1436
+ }
1437
+ if (!found) {
1438
+ typeListeners.push(listener);
1439
+ }
1440
+ };
1441
+ EventTarget.prototype.removeEventListener = function(type, listener) {
1442
+ type = String(type);
1443
+ var listeners = this._listeners;
1444
+ var typeListeners = listeners[type];
1445
+ if (typeListeners != void 0) {
1446
+ var filtered = [];
1447
+ for (var i = 0; i < typeListeners.length; i += 1) {
1448
+ if (typeListeners[i] !== listener) {
1449
+ filtered.push(typeListeners[i]);
1450
+ }
1451
+ }
1452
+ if (filtered.length === 0) {
1453
+ delete listeners[type];
1454
+ } else {
1455
+ listeners[type] = filtered;
1456
+ }
1457
+ }
1458
+ };
1459
+ function Event(type) {
1460
+ this.type = type;
1461
+ this.target = void 0;
1462
+ }
1463
+ function MessageEvent(type, options) {
1464
+ Event.call(this, type);
1465
+ this.data = options.data;
1466
+ this.lastEventId = options.lastEventId;
1467
+ }
1468
+ MessageEvent.prototype = Object.create(Event.prototype);
1469
+ function ConnectionEvent(type, options) {
1470
+ Event.call(this, type);
1471
+ this.status = options.status;
1472
+ this.statusText = options.statusText;
1473
+ this.headers = options.headers;
1474
+ }
1475
+ ConnectionEvent.prototype = Object.create(Event.prototype);
1476
+ function ErrorEvent(type, options) {
1477
+ Event.call(this, type);
1478
+ this.error = options.error;
1479
+ }
1480
+ ErrorEvent.prototype = Object.create(Event.prototype);
1481
+ var WAITING = -1;
1482
+ var CONNECTING = 0;
1483
+ var OPEN = 1;
1484
+ var CLOSED = 2;
1485
+ var AFTER_CR = -1;
1486
+ var FIELD_START = 0;
1487
+ var FIELD = 1;
1488
+ var VALUE_START = 2;
1489
+ var VALUE = 3;
1490
+ var contentTypeRegExp = /^text\/event\-stream(;.*)?$/i;
1491
+ var MINIMUM_DURATION = 1e3;
1492
+ var MAXIMUM_DURATION = 18e6;
1493
+ var parseDuration = function(value, def) {
1494
+ var n = value == null ? def : parseInt(value, 10);
1495
+ if (n !== n) {
1496
+ n = def;
1497
+ }
1498
+ return clampDuration(n);
1499
+ };
1500
+ var clampDuration = function(n) {
1501
+ return Math.min(Math.max(n, MINIMUM_DURATION), MAXIMUM_DURATION);
1502
+ };
1503
+ var fire = function(that, f, event) {
1504
+ try {
1505
+ if (typeof f === "function") {
1506
+ f.call(that, event);
1507
+ }
1508
+ } catch (e) {
1509
+ throwError(e);
1510
+ }
1511
+ };
1512
+ function EventSourcePolyfill(url, options) {
1513
+ EventTarget.call(this);
1514
+ options = options || {};
1515
+ this.onopen = void 0;
1516
+ this.onmessage = void 0;
1517
+ this.onerror = void 0;
1518
+ this.url = void 0;
1519
+ this.readyState = void 0;
1520
+ this.withCredentials = void 0;
1521
+ this.headers = void 0;
1522
+ this._close = void 0;
1523
+ start(this, url, options);
1524
+ }
1525
+ function getBestXHRTransport() {
1526
+ return XMLHttpRequest != void 0 && "withCredentials" in XMLHttpRequest.prototype || XDomainRequest == void 0 ? new XMLHttpRequest() : new XDomainRequest();
1527
+ }
1528
+ var isFetchSupported = fetch != void 0 && Response != void 0 && "body" in Response.prototype;
1529
+ function start(es, url, options) {
1530
+ url = String(url);
1531
+ var withCredentials = Boolean(options.withCredentials);
1532
+ var lastEventIdQueryParameterName = options.lastEventIdQueryParameterName || "lastEventId";
1533
+ var initialRetry = clampDuration(1e3);
1534
+ var heartbeatTimeout = parseDuration(options.heartbeatTimeout, 45e3);
1535
+ var lastEventId = "";
1536
+ var retry = initialRetry;
1537
+ var wasActivity = false;
1538
+ var textLength = 0;
1539
+ var headers = options.headers || {};
1540
+ var TransportOption = options.Transport;
1541
+ var xhr = isFetchSupported && TransportOption == void 0 ? void 0 : new XHRWrapper(TransportOption != void 0 ? new TransportOption() : getBestXHRTransport());
1542
+ var transport = TransportOption != null && typeof TransportOption !== "string" ? new TransportOption() : xhr == void 0 ? new FetchTransport() : new XHRTransport();
1543
+ var abortController = void 0;
1544
+ var timeout = 0;
1545
+ var currentState = WAITING;
1546
+ var dataBuffer = "";
1547
+ var lastEventIdBuffer = "";
1548
+ var eventTypeBuffer = "";
1549
+ var textBuffer = "";
1550
+ var state = FIELD_START;
1551
+ var fieldStart = 0;
1552
+ var valueStart = 0;
1553
+ var onStart = function(status, statusText, contentType, headers2) {
1554
+ if (currentState === CONNECTING) {
1555
+ if (status === 200 && contentType != void 0 && contentTypeRegExp.test(contentType)) {
1556
+ currentState = OPEN;
1557
+ wasActivity = Date.now();
1558
+ retry = initialRetry;
1559
+ es.readyState = OPEN;
1560
+ var event = new ConnectionEvent("open", {
1561
+ status,
1562
+ statusText,
1563
+ headers: headers2
1564
+ });
1565
+ es.dispatchEvent(event);
1566
+ fire(es, es.onopen, event);
1567
+ } else {
1568
+ var message = "";
1569
+ if (status !== 200) {
1570
+ if (statusText) {
1571
+ statusText = statusText.replace(/\s+/g, " ");
1572
+ }
1573
+ message = "EventSource's response has a status " + status + " " + statusText + " that is not 200. Aborting the connection.";
1574
+ } else {
1575
+ message = "EventSource's response has a Content-Type specifying an unsupported type: " + (contentType == void 0 ? "-" : contentType.replace(/\s+/g, " ")) + ". Aborting the connection.";
1576
+ }
1577
+ close();
1578
+ var event = new ConnectionEvent("error", {
1579
+ status,
1580
+ statusText,
1581
+ headers: headers2
1582
+ });
1583
+ es.dispatchEvent(event);
1584
+ fire(es, es.onerror, event);
1585
+ console.error(message);
1586
+ }
1587
+ }
1588
+ };
1589
+ var onProgress = function(textChunk) {
1590
+ if (currentState === OPEN) {
1591
+ var n = -1;
1592
+ for (var i = 0; i < textChunk.length; i += 1) {
1593
+ var c = textChunk.charCodeAt(i);
1594
+ if (c === "\n".charCodeAt(0) || c === "\r".charCodeAt(0)) {
1595
+ n = i;
1596
+ }
1597
+ }
1598
+ var chunk = (n !== -1 ? textBuffer : "") + textChunk.slice(0, n + 1);
1599
+ textBuffer = (n === -1 ? textBuffer : "") + textChunk.slice(n + 1);
1600
+ if (textChunk !== "") {
1601
+ wasActivity = Date.now();
1602
+ textLength += textChunk.length;
1603
+ }
1604
+ for (var position = 0; position < chunk.length; position += 1) {
1605
+ var c = chunk.charCodeAt(position);
1606
+ if (state === AFTER_CR && c === "\n".charCodeAt(0)) {
1607
+ state = FIELD_START;
1608
+ } else {
1609
+ if (state === AFTER_CR) {
1610
+ state = FIELD_START;
1611
+ }
1612
+ if (c === "\r".charCodeAt(0) || c === "\n".charCodeAt(0)) {
1613
+ if (state !== FIELD_START) {
1614
+ if (state === FIELD) {
1615
+ valueStart = position + 1;
1616
+ }
1617
+ var field = chunk.slice(fieldStart, valueStart - 1);
1618
+ var value = chunk.slice(valueStart + (valueStart < position && chunk.charCodeAt(valueStart) === " ".charCodeAt(0) ? 1 : 0), position);
1619
+ if (field === "data") {
1620
+ dataBuffer += "\n";
1621
+ dataBuffer += value;
1622
+ } else if (field === "id") {
1623
+ lastEventIdBuffer = value;
1624
+ } else if (field === "event") {
1625
+ eventTypeBuffer = value;
1626
+ } else if (field === "retry") {
1627
+ initialRetry = parseDuration(value, initialRetry);
1628
+ retry = initialRetry;
1629
+ } else if (field === "heartbeatTimeout") {
1630
+ heartbeatTimeout = parseDuration(value, heartbeatTimeout);
1631
+ if (timeout !== 0) {
1632
+ clearTimeout2(timeout);
1633
+ timeout = setTimeout2(function() {
1634
+ onTimeout();
1635
+ }, heartbeatTimeout);
1636
+ }
1637
+ }
1638
+ }
1639
+ if (state === FIELD_START) {
1640
+ if (dataBuffer !== "") {
1641
+ lastEventId = lastEventIdBuffer;
1642
+ if (eventTypeBuffer === "") {
1643
+ eventTypeBuffer = "message";
1644
+ }
1645
+ var event = new MessageEvent(eventTypeBuffer, {
1646
+ data: dataBuffer.slice(1),
1647
+ lastEventId: lastEventIdBuffer
1648
+ });
1649
+ es.dispatchEvent(event);
1650
+ if (eventTypeBuffer === "open") {
1651
+ fire(es, es.onopen, event);
1652
+ } else if (eventTypeBuffer === "message") {
1653
+ fire(es, es.onmessage, event);
1654
+ } else if (eventTypeBuffer === "error") {
1655
+ fire(es, es.onerror, event);
1656
+ }
1657
+ if (currentState === CLOSED) {
1658
+ return;
1659
+ }
1660
+ }
1661
+ dataBuffer = "";
1662
+ eventTypeBuffer = "";
1663
+ }
1664
+ state = c === "\r".charCodeAt(0) ? AFTER_CR : FIELD_START;
1665
+ } else {
1666
+ if (state === FIELD_START) {
1667
+ fieldStart = position;
1668
+ state = FIELD;
1669
+ }
1670
+ if (state === FIELD) {
1671
+ if (c === ":".charCodeAt(0)) {
1672
+ valueStart = position + 1;
1673
+ state = VALUE_START;
1674
+ }
1675
+ } else if (state === VALUE_START) {
1676
+ state = VALUE;
1677
+ }
1678
+ }
1679
+ }
1680
+ }
1681
+ }
1682
+ };
1683
+ var onFinish = function(error) {
1684
+ if (currentState === OPEN || currentState === CONNECTING) {
1685
+ currentState = WAITING;
1686
+ if (timeout !== 0) {
1687
+ clearTimeout2(timeout);
1688
+ timeout = 0;
1689
+ }
1690
+ timeout = setTimeout2(function() {
1691
+ onTimeout();
1692
+ }, retry);
1693
+ retry = clampDuration(Math.min(initialRetry * 16, retry * 2));
1694
+ es.readyState = CONNECTING;
1695
+ var event = new ErrorEvent("error", { error });
1696
+ es.dispatchEvent(event);
1697
+ fire(es, es.onerror, event);
1698
+ if (error != void 0) {
1699
+ console.error(error);
1700
+ }
1701
+ }
1702
+ };
1703
+ var close = function() {
1704
+ currentState = CLOSED;
1705
+ if (abortController != void 0) {
1706
+ abortController.abort();
1707
+ abortController = void 0;
1708
+ }
1709
+ if (timeout !== 0) {
1710
+ clearTimeout2(timeout);
1711
+ timeout = 0;
1712
+ }
1713
+ es.readyState = CLOSED;
1714
+ };
1715
+ var onTimeout = function() {
1716
+ timeout = 0;
1717
+ if (currentState !== WAITING) {
1718
+ if (!wasActivity && abortController != void 0) {
1719
+ onFinish(new Error("No activity within " + heartbeatTimeout + " milliseconds. " + (currentState === CONNECTING ? "No response received." : textLength + " chars received.") + " Reconnecting."));
1720
+ if (abortController != void 0) {
1721
+ abortController.abort();
1722
+ abortController = void 0;
1723
+ }
1724
+ } else {
1725
+ var nextHeartbeat = Math.max((wasActivity || Date.now()) + heartbeatTimeout - Date.now(), 1);
1726
+ wasActivity = false;
1727
+ timeout = setTimeout2(function() {
1728
+ onTimeout();
1729
+ }, nextHeartbeat);
1730
+ }
1731
+ return;
1732
+ }
1733
+ wasActivity = false;
1734
+ textLength = 0;
1735
+ timeout = setTimeout2(function() {
1736
+ onTimeout();
1737
+ }, heartbeatTimeout);
1738
+ currentState = CONNECTING;
1739
+ dataBuffer = "";
1740
+ eventTypeBuffer = "";
1741
+ lastEventIdBuffer = lastEventId;
1742
+ textBuffer = "";
1743
+ fieldStart = 0;
1744
+ valueStart = 0;
1745
+ state = FIELD_START;
1746
+ var requestURL = url;
1747
+ if (url.slice(0, 5) !== "data:" && url.slice(0, 5) !== "blob:") {
1748
+ if (lastEventId !== "") {
1749
+ var i = url.indexOf("?");
1750
+ requestURL = i === -1 ? url : url.slice(0, i + 1) + url.slice(i + 1).replace(/(?:^|&)([^=&]*)(?:=[^&]*)?/g, function(p, paramName) {
1751
+ return paramName === lastEventIdQueryParameterName ? "" : p;
1752
+ });
1753
+ requestURL += (url.indexOf("?") === -1 ? "?" : "&") + lastEventIdQueryParameterName + "=" + encodeURIComponent(lastEventId);
1754
+ }
1755
+ }
1756
+ var withCredentials2 = es.withCredentials;
1757
+ var requestHeaders = {};
1758
+ requestHeaders["Accept"] = "text/event-stream";
1759
+ var headers2 = es.headers;
1760
+ if (headers2 != void 0) {
1761
+ for (var name in headers2) {
1762
+ if (Object.prototype.hasOwnProperty.call(headers2, name)) {
1763
+ requestHeaders[name] = headers2[name];
1764
+ }
1765
+ }
1766
+ }
1767
+ try {
1768
+ abortController = transport.open(xhr, onStart, onProgress, onFinish, requestURL, withCredentials2, requestHeaders);
1769
+ } catch (error) {
1770
+ close();
1771
+ throw error;
1772
+ }
1773
+ };
1774
+ es.url = url;
1775
+ es.readyState = CONNECTING;
1776
+ es.withCredentials = withCredentials;
1777
+ es.headers = headers;
1778
+ es._close = close;
1779
+ onTimeout();
1780
+ }
1781
+ EventSourcePolyfill.prototype = Object.create(EventTarget.prototype);
1782
+ EventSourcePolyfill.prototype.CONNECTING = CONNECTING;
1783
+ EventSourcePolyfill.prototype.OPEN = OPEN;
1784
+ EventSourcePolyfill.prototype.CLOSED = CLOSED;
1785
+ EventSourcePolyfill.prototype.close = function() {
1786
+ this._close();
1787
+ };
1788
+ EventSourcePolyfill.CONNECTING = CONNECTING;
1789
+ EventSourcePolyfill.OPEN = OPEN;
1790
+ EventSourcePolyfill.CLOSED = CLOSED;
1791
+ EventSourcePolyfill.prototype.withCredentials = void 0;
1792
+ var R = NativeEventSource;
1793
+ if (XMLHttpRequest != void 0 && (NativeEventSource == void 0 || !("withCredentials" in NativeEventSource.prototype))) {
1794
+ R = EventSourcePolyfill;
1795
+ }
1796
+ (function(factory) {
1797
+ if (typeof module === "object" && typeof module.exports === "object") {
1798
+ var v = factory(exports);
1799
+ if (v !== void 0)
1800
+ module.exports = v;
1801
+ } else if (typeof define === "function" && define.amd) {
1802
+ define(["exports"], factory);
1803
+ } else {
1804
+ factory(global);
1805
+ }
1806
+ })(function(exports2) {
1807
+ exports2.EventSourcePolyfill = EventSourcePolyfill;
1808
+ exports2.NativeEventSource = NativeEventSource;
1809
+ exports2.EventSource = R;
1810
+ });
1811
+ })(typeof globalThis === "undefined" ? typeof window !== "undefined" ? window : typeof self !== "undefined" ? self : exports : globalThis);
1812
+ }
1813
+ });
1814
+
1815
+ // node_modules/@sanity/eventsource/browser.js
1816
+ var require_browser = __commonJS({
1817
+ "node_modules/@sanity/eventsource/browser.js"(exports, module) {
1818
+ var evs = require_eventsource();
1819
+ module.exports = evs.EventSourcePolyfill;
1820
+ }
1821
+ });
1822
+
1823
+ // node_modules/make-error/index.js
1824
+ var require_make_error = __commonJS({
1825
+ "node_modules/make-error/index.js"(exports, module) {
1826
+ "use strict";
1827
+ var construct = typeof Reflect !== "undefined" ? Reflect.construct : void 0;
1828
+ var defineProperty = Object.defineProperty;
1829
+ var captureStackTrace = Error.captureStackTrace;
1830
+ if (captureStackTrace === void 0) {
1831
+ captureStackTrace = function captureStackTrace2(error) {
1832
+ var container = new Error();
1833
+ defineProperty(error, "stack", {
1834
+ configurable: true,
1835
+ get: function getStack() {
1836
+ var stack = container.stack;
1837
+ defineProperty(this, "stack", {
1838
+ configurable: true,
1839
+ value: stack,
1840
+ writable: true
1841
+ });
1842
+ return stack;
1843
+ },
1844
+ set: function setStack(stack) {
1845
+ defineProperty(error, "stack", {
1846
+ configurable: true,
1847
+ value: stack,
1848
+ writable: true
1849
+ });
1850
+ }
1851
+ });
1852
+ };
1853
+ }
1854
+ function BaseError(message) {
1855
+ if (message !== void 0) {
1856
+ defineProperty(this, "message", {
1857
+ configurable: true,
1858
+ value: message,
1859
+ writable: true
1860
+ });
1861
+ }
1862
+ var cname = this.constructor.name;
1863
+ if (cname !== void 0 && cname !== this.name) {
1864
+ defineProperty(this, "name", {
1865
+ configurable: true,
1866
+ value: cname,
1867
+ writable: true
1868
+ });
1869
+ }
1870
+ captureStackTrace(this, this.constructor);
1871
+ }
1872
+ BaseError.prototype = Object.create(Error.prototype, {
1873
+ constructor: {
1874
+ configurable: true,
1875
+ value: BaseError,
1876
+ writable: true
1877
+ }
1878
+ });
1879
+ var setFunctionName = function() {
1880
+ function setFunctionName2(fn, name) {
1881
+ return defineProperty(fn, "name", {
1882
+ configurable: true,
1883
+ value: name
1884
+ });
1885
+ }
1886
+ try {
1887
+ var f = function() {
1888
+ };
1889
+ setFunctionName2(f, "foo");
1890
+ if (f.name === "foo") {
1891
+ return setFunctionName2;
1892
+ }
1893
+ } catch (_) {
1894
+ }
1895
+ }();
1896
+ function makeError2(constructor, super_) {
1897
+ if (super_ == null || super_ === Error) {
1898
+ super_ = BaseError;
1899
+ } else if (typeof super_ !== "function") {
1900
+ throw new TypeError("super_ should be a function");
1901
+ }
1902
+ var name;
1903
+ if (typeof constructor === "string") {
1904
+ name = constructor;
1905
+ constructor = construct !== void 0 ? function() {
1906
+ return construct(super_, arguments, this.constructor);
1907
+ } : function() {
1908
+ super_.apply(this, arguments);
1909
+ };
1910
+ if (setFunctionName !== void 0) {
1911
+ setFunctionName(constructor, name);
1912
+ name = void 0;
1913
+ }
1914
+ } else if (typeof constructor !== "function") {
1915
+ throw new TypeError("constructor should be either a string or a function");
1916
+ }
1917
+ constructor.super_ = constructor["super"] = super_;
1918
+ var properties = {
1919
+ constructor: {
1920
+ configurable: true,
1921
+ value: constructor,
1922
+ writable: true
1923
+ }
1924
+ };
1925
+ if (name !== void 0) {
1926
+ properties.name = {
1927
+ configurable: true,
1928
+ value: name,
1929
+ writable: true
1930
+ };
1931
+ }
1932
+ constructor.prototype = Object.create(super_.prototype, properties);
1933
+ return constructor;
1934
+ }
1935
+ exports = module.exports = makeError2;
1936
+ exports.BaseError = BaseError;
1937
+ }
1938
+ });
1939
+
1940
+ // src/util/observable.js
1941
+ var import_Observable = __toESM(require_Observable());
1942
+ var import_filter = __toESM(require_filter());
1943
+ var import_map = __toESM(require_map());
1944
+
1945
+ // src/util/getSelection.js
1946
+ function getSelection(sel) {
1947
+ if (typeof sel === "string" || Array.isArray(sel)) {
1948
+ return { id: sel };
1949
+ }
1950
+ if (sel && sel.query) {
1951
+ return "params" in sel ? { query: sel.query, params: sel.params } : { query: sel.query };
1952
+ }
1953
+ const selectionOpts = [
1954
+ "* Document ID (<docId>)",
1955
+ "* Array of document IDs",
1956
+ "* Object containing `query`"
1957
+ ].join("\n");
1958
+ throw new Error(`Unknown selection - must be one of:
1959
+
1960
+ ${selectionOpts}`);
1961
+ }
1962
+
1963
+ // src/validators.js
1964
+ var VALID_ASSET_TYPES = ["image", "file"];
1965
+ var VALID_INSERT_LOCATIONS = ["before", "after", "replace"];
1966
+ var dataset = (name) => {
1967
+ if (!/^(~[a-z0-9]{1}[-\w]{0,63}|[a-z0-9]{1}[-\w]{0,63})$/.test(name)) {
1968
+ throw new Error(
1969
+ "Datasets can only contain lowercase characters, numbers, underscores and dashes, and start with tilde, and be maximum 64 characters"
1970
+ );
1971
+ }
1972
+ };
1973
+ var projectId = (id) => {
1974
+ if (!/^[-a-z0-9]+$/i.test(id)) {
1975
+ throw new Error("`projectId` can only contain only a-z, 0-9 and dashes");
1976
+ }
1977
+ };
1978
+ var validateAssetType = (type) => {
1979
+ if (VALID_ASSET_TYPES.indexOf(type) === -1) {
1980
+ throw new Error(`Invalid asset type: ${type}. Must be one of ${VALID_ASSET_TYPES.join(", ")}`);
1981
+ }
1982
+ };
1983
+ var validateObject = (op, val) => {
1984
+ if (val === null || typeof val !== "object" || Array.isArray(val)) {
1985
+ throw new Error(`${op}() takes an object of properties`);
1986
+ }
1987
+ };
1988
+ var validateDocumentId = (op, id) => {
1989
+ if (typeof id !== "string" || !/^[a-z0-9_.-]+$/i.test(id)) {
1990
+ throw new Error(`${op}(): "${id}" is not a valid document ID`);
1991
+ }
1992
+ };
1993
+ var requireDocumentId = (op, doc) => {
1994
+ if (!doc._id) {
1995
+ throw new Error(`${op}() requires that the document contains an ID ("_id" property)`);
1996
+ }
1997
+ validateDocumentId(op, doc._id);
1998
+ };
1999
+ var validateInsert = (at, selector, items) => {
2000
+ const signature = "insert(at, selector, items)";
2001
+ if (VALID_INSERT_LOCATIONS.indexOf(at) === -1) {
2002
+ const valid = VALID_INSERT_LOCATIONS.map((loc) => `"${loc}"`).join(", ");
2003
+ throw new Error(`${signature} takes an "at"-argument which is one of: ${valid}`);
2004
+ }
2005
+ if (typeof selector !== "string") {
2006
+ throw new Error(`${signature} takes a "selector"-argument which must be a string`);
2007
+ }
2008
+ if (!Array.isArray(items)) {
2009
+ throw new Error(`${signature} takes an "items"-argument which must be an array`);
2010
+ }
2011
+ };
2012
+ var hasDataset = (config) => {
2013
+ if (!config.dataset) {
2014
+ throw new Error("`dataset` must be provided to perform queries");
2015
+ }
2016
+ return config.dataset || "";
2017
+ };
2018
+ var requestTag = (tag) => {
2019
+ if (typeof tag !== "string" || !/^[a-z0-9._-]{1,75}$/i.test(tag)) {
2020
+ throw new Error(
2021
+ `Tag can only contain alphanumeric characters, underscores, dashes and dots, and be between one and 75 characters long.`
2022
+ );
2023
+ }
2024
+ return tag;
2025
+ };
2026
+
2027
+ // src/data/patch.js
2028
+ function Patch(selection, operations = {}, client = null) {
2029
+ this.selection = selection;
2030
+ this.operations = Object.assign({}, operations);
2031
+ this.client = client;
2032
+ }
2033
+ Object.assign(Patch.prototype, {
2034
+ clone() {
2035
+ return new Patch(this.selection, Object.assign({}, this.operations), this.client);
2036
+ },
2037
+ set(props) {
2038
+ return this.assign("set", props);
2039
+ },
2040
+ diffMatchPatch(props) {
2041
+ validateObject("diffMatchPatch", props);
2042
+ return this.assign("diffMatchPatch", props);
2043
+ },
2044
+ unset(attrs) {
2045
+ if (!Array.isArray(attrs)) {
2046
+ throw new Error("unset(attrs) takes an array of attributes to unset, non-array given");
2047
+ }
2048
+ this.operations = Object.assign({}, this.operations, { unset: attrs });
2049
+ return this;
2050
+ },
2051
+ setIfMissing(props) {
2052
+ return this.assign("setIfMissing", props);
2053
+ },
2054
+ replace(props) {
2055
+ validateObject("replace", props);
2056
+ return this._set("set", { $: props });
2057
+ },
2058
+ inc(props) {
2059
+ return this.assign("inc", props);
2060
+ },
2061
+ dec(props) {
2062
+ return this.assign("dec", props);
2063
+ },
2064
+ insert(at, selector, items) {
2065
+ validateInsert(at, selector, items);
2066
+ return this.assign("insert", { [at]: selector, items });
2067
+ },
2068
+ append(selector, items) {
2069
+ return this.insert("after", `${selector}[-1]`, items);
2070
+ },
2071
+ prepend(selector, items) {
2072
+ return this.insert("before", `${selector}[0]`, items);
2073
+ },
2074
+ splice(selector, start, deleteCount, items) {
2075
+ const delAll = typeof deleteCount === "undefined" || deleteCount === -1;
2076
+ const startIndex = start < 0 ? start - 1 : start;
2077
+ const delCount = delAll ? -1 : Math.max(0, start + deleteCount);
2078
+ const delRange = startIndex < 0 && delCount >= 0 ? "" : delCount;
2079
+ const rangeSelector = `${selector}[${startIndex}:${delRange}]`;
2080
+ return this.insert("replace", rangeSelector, items || []);
2081
+ },
2082
+ ifRevisionId(rev) {
2083
+ this.operations.ifRevisionID = rev;
2084
+ return this;
2085
+ },
2086
+ serialize() {
2087
+ return Object.assign(getSelection(this.selection), this.operations);
2088
+ },
2089
+ toJSON() {
2090
+ return this.serialize();
2091
+ },
2092
+ commit(options = {}) {
2093
+ if (!this.client) {
2094
+ throw new Error(
2095
+ "No `client` passed to patch, either provide one or pass the patch to a clients `mutate()` method"
2096
+ );
2097
+ }
2098
+ const returnFirst = typeof this.selection === "string";
2099
+ const opts = Object.assign({ returnFirst, returnDocuments: true }, options);
2100
+ return this.client.mutate({ patch: this.serialize() }, opts);
2101
+ },
2102
+ reset() {
2103
+ this.operations = {};
2104
+ return this;
2105
+ },
2106
+ _set(op, props) {
2107
+ return this.assign(op, props, false);
2108
+ },
2109
+ assign(op, props, merge = true) {
2110
+ validateObject(op, props);
2111
+ this.operations = Object.assign({}, this.operations, {
2112
+ [op]: Object.assign({}, merge && this.operations[op] || {}, props)
2113
+ });
2114
+ return this;
2115
+ }
2116
+ });
2117
+ var patch_default = Patch;
2118
+
2119
+ // src/data/transaction.js
2120
+ var defaultMutateOptions = { returnDocuments: false };
2121
+ function Transaction(operations = [], client, transactionId) {
2122
+ this.trxId = transactionId;
2123
+ this.operations = operations;
2124
+ this.client = client;
2125
+ }
2126
+ Object.assign(Transaction.prototype, {
2127
+ clone() {
2128
+ return new Transaction(this.operations.slice(0), this.client, this.trxId);
2129
+ },
2130
+ create(doc) {
2131
+ validateObject("create", doc);
2132
+ return this._add({ create: doc });
2133
+ },
2134
+ createIfNotExists(doc) {
2135
+ const op = "createIfNotExists";
2136
+ validateObject(op, doc);
2137
+ requireDocumentId(op, doc);
2138
+ return this._add({ [op]: doc });
2139
+ },
2140
+ createOrReplace(doc) {
2141
+ const op = "createOrReplace";
2142
+ validateObject(op, doc);
2143
+ requireDocumentId(op, doc);
2144
+ return this._add({ [op]: doc });
2145
+ },
2146
+ delete(documentId) {
2147
+ validateDocumentId("delete", documentId);
2148
+ return this._add({ delete: { id: documentId } });
2149
+ },
2150
+ patch(documentId, patchOps) {
2151
+ const isBuilder = typeof patchOps === "function";
2152
+ const isPatch = documentId instanceof patch_default;
2153
+ if (isPatch) {
2154
+ return this._add({ patch: documentId.serialize() });
2155
+ }
2156
+ if (isBuilder) {
2157
+ const patch = patchOps(new patch_default(documentId, {}, this.client));
2158
+ if (!(patch instanceof patch_default)) {
2159
+ throw new Error("function passed to `patch()` must return the patch");
2160
+ }
2161
+ return this._add({ patch: patch.serialize() });
2162
+ }
2163
+ return this._add({ patch: Object.assign({ id: documentId }, patchOps) });
2164
+ },
2165
+ transactionId(id) {
2166
+ if (!id) {
2167
+ return this.trxId;
2168
+ }
2169
+ this.trxId = id;
2170
+ return this;
2171
+ },
2172
+ serialize() {
2173
+ return this.operations.slice();
2174
+ },
2175
+ toJSON() {
2176
+ return this.serialize();
2177
+ },
2178
+ commit(options) {
2179
+ if (!this.client) {
2180
+ throw new Error(
2181
+ "No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method"
2182
+ );
2183
+ }
2184
+ return this.client.mutate(
2185
+ this.serialize(),
2186
+ Object.assign({ transactionId: this.trxId }, defaultMutateOptions, options || {})
2187
+ );
2188
+ },
2189
+ reset() {
2190
+ this.operations = [];
2191
+ return this;
2192
+ },
2193
+ _add(mut) {
2194
+ this.operations.push(mut);
2195
+ return this;
2196
+ }
2197
+ });
2198
+ var transaction_default = Transaction;
2199
+
2200
+ // src/data/encodeQueryString.js
2201
+ var enc = encodeURIComponent;
2202
+ var encodeQueryString_default = ({ query, params = {}, options = {} }) => {
2203
+ const { tag, ...opts } = options;
2204
+ const q = `query=${enc(query)}`;
2205
+ const base = tag ? `?tag=${enc(tag)}&${q}` : `?${q}`;
2206
+ const qString = Object.keys(params).reduce(
2207
+ (qs, param) => `${qs}&${enc(`$${param}`)}=${enc(JSON.stringify(params[param]))}`,
2208
+ base
2209
+ );
2210
+ return Object.keys(opts).reduce((qs, option) => {
2211
+ return options[option] ? `${qs}&${enc(option)}=${enc(options[option])}` : qs;
2212
+ }, qString);
2213
+ };
2214
+
2215
+ // src/data/listen.js
2216
+ var import_eventsource = __toESM(require_browser());
2217
+
2218
+ // src/util/pick.js
2219
+ var pick_default = (obj, props) => props.reduce((selection, prop) => {
2220
+ if (typeof obj[prop] === "undefined") {
2221
+ return selection;
2222
+ }
2223
+ selection[prop] = obj[prop];
2224
+ return selection;
2225
+ }, {});
2226
+
2227
+ // src/util/defaults.js
2228
+ var defaults_default = (obj, defaults) => Object.keys(defaults).concat(Object.keys(obj)).reduce((target, prop) => {
2229
+ target[prop] = typeof obj[prop] === "undefined" ? defaults[prop] : obj[prop];
2230
+ return target;
2231
+ }, {});
2232
+
2233
+ // src/data/listen.js
2234
+ var MAX_URL_LENGTH = 16e3 - 1200;
2235
+ var EventSource = import_eventsource.default;
2236
+ var possibleOptions = [
2237
+ "includePreviousRevision",
2238
+ "includeResult",
2239
+ "visibility",
2240
+ "effectFormat",
2241
+ "tag"
2242
+ ];
2243
+ var defaultOptions = {
2244
+ includeResult: true
2245
+ };
2246
+ function listen(query, params, opts = {}) {
2247
+ const { url, token, withCredentials, requestTagPrefix } = this.clientConfig;
2248
+ const tag = opts.tag && requestTagPrefix ? [requestTagPrefix, opts.tag].join(".") : opts.tag;
2249
+ const options = { ...defaults_default(opts, defaultOptions), tag };
2250
+ const listenOpts = pick_default(options, possibleOptions);
2251
+ const qs = encodeQueryString_default({ query, params, options: listenOpts, tag });
2252
+ const uri = `${url}${this.getDataUrl("listen", qs)}`;
2253
+ if (uri.length > MAX_URL_LENGTH) {
2254
+ return new import_Observable.Observable((observer) => observer.error(new Error("Query too large for listener")));
2255
+ }
2256
+ const listenFor = options.events ? options.events : ["mutation"];
2257
+ const shouldEmitReconnect = listenFor.indexOf("reconnect") !== -1;
2258
+ const esOptions = {};
2259
+ if (token || withCredentials) {
2260
+ esOptions.withCredentials = true;
2261
+ }
2262
+ if (token) {
2263
+ esOptions.headers = {
2264
+ Authorization: `Bearer ${token}`
2265
+ };
2266
+ }
2267
+ return new import_Observable.Observable((observer) => {
2268
+ let es = getEventSource();
2269
+ let reconnectTimer;
2270
+ let stopped = false;
2271
+ function onError() {
2272
+ if (stopped) {
2273
+ return;
2274
+ }
2275
+ emitReconnect();
2276
+ if (stopped) {
2277
+ return;
2278
+ }
2279
+ if (es.readyState === EventSource.CLOSED) {
2280
+ unsubscribe();
2281
+ clearTimeout(reconnectTimer);
2282
+ reconnectTimer = setTimeout(open, 100);
2283
+ }
2284
+ }
2285
+ function onChannelError(err) {
2286
+ observer.error(cooerceError(err));
2287
+ }
2288
+ function onMessage(evt) {
2289
+ const event = parseEvent(evt);
2290
+ return event instanceof Error ? observer.error(event) : observer.next(event);
2291
+ }
2292
+ function onDisconnect(evt) {
2293
+ stopped = true;
2294
+ unsubscribe();
2295
+ observer.complete();
2296
+ }
2297
+ function unsubscribe() {
2298
+ es.removeEventListener("error", onError, false);
2299
+ es.removeEventListener("channelError", onChannelError, false);
2300
+ es.removeEventListener("disconnect", onDisconnect, false);
2301
+ listenFor.forEach((type) => es.removeEventListener(type, onMessage, false));
2302
+ es.close();
2303
+ }
2304
+ function emitReconnect() {
2305
+ if (shouldEmitReconnect) {
2306
+ observer.next({ type: "reconnect" });
2307
+ }
2308
+ }
2309
+ function getEventSource() {
2310
+ const evs = new EventSource(uri, esOptions);
2311
+ evs.addEventListener("error", onError, false);
2312
+ evs.addEventListener("channelError", onChannelError, false);
2313
+ evs.addEventListener("disconnect", onDisconnect, false);
2314
+ listenFor.forEach((type) => evs.addEventListener(type, onMessage, false));
2315
+ return evs;
2316
+ }
2317
+ function open() {
2318
+ es = getEventSource();
2319
+ }
2320
+ function stop() {
2321
+ stopped = true;
2322
+ unsubscribe();
2323
+ }
2324
+ return stop;
2325
+ });
2326
+ }
2327
+ function parseEvent(event) {
2328
+ try {
2329
+ const data = event.data && JSON.parse(event.data) || {};
2330
+ return Object.assign({ type: event.type }, data);
2331
+ } catch (err) {
2332
+ return err;
2333
+ }
2334
+ }
2335
+ function cooerceError(err) {
2336
+ if (err instanceof Error) {
2337
+ return err;
2338
+ }
2339
+ const evt = parseEvent(err);
2340
+ return evt instanceof Error ? evt : new Error(extractErrorMessage(evt));
2341
+ }
2342
+ function extractErrorMessage(err) {
2343
+ if (!err.error) {
2344
+ return err.message || "Unknown listener error";
2345
+ }
2346
+ if (err.error.description) {
2347
+ return err.error.description;
2348
+ }
2349
+ return typeof err.error === "string" ? err.error : JSON.stringify(err.error, null, 2);
2350
+ }
2351
+
2352
+ // src/data/dataMethods.js
2353
+ var excludeFalsey = (param, defValue) => {
2354
+ const value = typeof param === "undefined" ? defValue : param;
2355
+ return param === false ? void 0 : value;
2356
+ };
2357
+ var getMutationQuery = (options = {}) => {
2358
+ return {
2359
+ dryRun: options.dryRun,
2360
+ returnIds: true,
2361
+ returnDocuments: excludeFalsey(options.returnDocuments, true),
2362
+ visibility: options.visibility || "sync",
2363
+ autoGenerateArrayKeys: options.autoGenerateArrayKeys,
2364
+ skipCrossDatasetReferenceValidation: options.skipCrossDatasetReferenceValidation
2365
+ };
2366
+ };
2367
+ var isResponse = (event) => event.type === "response";
2368
+ var getBody = (event) => event.body;
2369
+ var indexBy = (docs, attr) => docs.reduce((indexed, doc) => {
2370
+ indexed[attr(doc)] = doc;
2371
+ return indexed;
2372
+ }, /* @__PURE__ */ Object.create(null));
2373
+ var toPromise = (observable2) => observable2.toPromise();
2374
+ var getQuerySizeLimit = 11264;
2375
+ var dataMethods_default = {
2376
+ listen,
2377
+ getDataUrl(operation, path) {
2378
+ const config = this.clientConfig;
2379
+ const catalog = hasDataset(config);
2380
+ const baseUri = `/${operation}/${catalog}`;
2381
+ const uri = path ? `${baseUri}/${path}` : baseUri;
2382
+ return `/data${uri}`.replace(/\/($|\?)/, "$1");
2383
+ },
2384
+ fetch(query, params, options = {}) {
2385
+ const mapResponse = options.filterResponse === false ? (res) => res : (res) => res.result;
2386
+ const observable2 = this._dataRequest("query", { query, params }, options).pipe((0, import_map.map)(mapResponse));
2387
+ return this.isPromiseAPI() ? toPromise(observable2) : observable2;
2388
+ },
2389
+ getDocument(id, opts = {}) {
2390
+ const options = { uri: this.getDataUrl("doc", id), json: true, tag: opts.tag };
2391
+ const observable2 = this._requestObservable(options).pipe(
2392
+ (0, import_filter.filter)(isResponse),
2393
+ (0, import_map.map)((event) => event.body.documents && event.body.documents[0])
2394
+ );
2395
+ return this.isPromiseAPI() ? toPromise(observable2) : observable2;
2396
+ },
2397
+ getDocuments(ids, opts = {}) {
2398
+ const options = { uri: this.getDataUrl("doc", ids.join(",")), json: true, tag: opts.tag };
2399
+ const observable2 = this._requestObservable(options).pipe(
2400
+ (0, import_filter.filter)(isResponse),
2401
+ (0, import_map.map)((event) => {
2402
+ const indexed = indexBy(event.body.documents || [], (doc) => doc._id);
2403
+ return ids.map((id) => indexed[id] || null);
2404
+ })
2405
+ );
2406
+ return this.isPromiseAPI() ? toPromise(observable2) : observable2;
2407
+ },
2408
+ create(doc, options) {
2409
+ return this._create(doc, "create", options);
2410
+ },
2411
+ createIfNotExists(doc, options) {
2412
+ requireDocumentId("createIfNotExists", doc);
2413
+ return this._create(doc, "createIfNotExists", options);
2414
+ },
2415
+ createOrReplace(doc, options) {
2416
+ requireDocumentId("createOrReplace", doc);
2417
+ return this._create(doc, "createOrReplace", options);
2418
+ },
2419
+ patch(selector, operations) {
2420
+ return new patch_default(selector, operations, this);
2421
+ },
2422
+ delete(selection, options) {
2423
+ return this.dataRequest("mutate", { mutations: [{ delete: getSelection(selection) }] }, options);
2424
+ },
2425
+ mutate(mutations, options) {
2426
+ const mut = mutations instanceof patch_default || mutations instanceof transaction_default ? mutations.serialize() : mutations;
2427
+ const muts = Array.isArray(mut) ? mut : [mut];
2428
+ const transactionId = options && options.transactionId;
2429
+ return this.dataRequest("mutate", { mutations: muts, transactionId }, options);
2430
+ },
2431
+ transaction(operations) {
2432
+ return new transaction_default(operations, this);
2433
+ },
2434
+ dataRequest(endpoint, body, options = {}) {
2435
+ const request2 = this._dataRequest(endpoint, body, options);
2436
+ return this.isPromiseAPI() ? toPromise(request2) : request2;
2437
+ },
2438
+ _dataRequest(endpoint, body, options = {}) {
2439
+ const isMutation = endpoint === "mutate";
2440
+ const isQuery = endpoint === "query";
2441
+ const strQuery = !isMutation && encodeQueryString_default(body);
2442
+ const useGet = !isMutation && strQuery.length < getQuerySizeLimit;
2443
+ const stringQuery = useGet ? strQuery : "";
2444
+ const returnFirst = options.returnFirst;
2445
+ const { timeout, token, tag, headers } = options;
2446
+ const uri = this.getDataUrl(endpoint, stringQuery);
2447
+ const reqOptions = {
2448
+ method: useGet ? "GET" : "POST",
2449
+ uri,
2450
+ json: true,
2451
+ body: useGet ? void 0 : body,
2452
+ query: isMutation && getMutationQuery(options),
2453
+ timeout,
2454
+ headers,
2455
+ token,
2456
+ tag,
2457
+ canUseCdn: isQuery
2458
+ };
2459
+ return this._requestObservable(reqOptions).pipe(
2460
+ (0, import_filter.filter)(isResponse),
2461
+ (0, import_map.map)(getBody),
2462
+ (0, import_map.map)((res) => {
2463
+ if (!isMutation) {
2464
+ return res;
2465
+ }
2466
+ const results = res.results || [];
2467
+ if (options.returnDocuments) {
2468
+ return returnFirst ? results[0] && results[0].document : results.map((mut) => mut.document);
2469
+ }
2470
+ const key = returnFirst ? "documentId" : "documentIds";
2471
+ const ids = returnFirst ? results[0] && results[0].id : results.map((mut) => mut.id);
2472
+ return {
2473
+ transactionId: res.transactionId,
2474
+ results,
2475
+ [key]: ids
2476
+ };
2477
+ })
2478
+ );
2479
+ },
2480
+ _create(doc, op, options = {}) {
2481
+ const mutation = { [op]: doc };
2482
+ const opts = Object.assign({ returnFirst: true, returnDocuments: true }, options);
2483
+ return this.dataRequest("mutate", { mutations: [mutation] }, opts);
2484
+ }
2485
+ };
2486
+
2487
+ // src/datasets/datasetsClient.js
2488
+ function DatasetsClient(client) {
2489
+ this.request = client.request.bind(client);
2490
+ }
2491
+ Object.assign(DatasetsClient.prototype, {
2492
+ create(name, options) {
2493
+ return this._modify("PUT", name, options);
2494
+ },
2495
+ edit(name, options) {
2496
+ return this._modify("PATCH", name, options);
2497
+ },
2498
+ delete(name) {
2499
+ return this._modify("DELETE", name);
2500
+ },
2501
+ list() {
2502
+ return this.request({ uri: "/datasets" });
2503
+ },
2504
+ _modify(method, name, body) {
2505
+ dataset(name);
2506
+ return this.request({ method, uri: `/datasets/${name}`, body });
2507
+ }
2508
+ });
2509
+ var datasetsClient_default = DatasetsClient;
2510
+
2511
+ // src/projects/projectsClient.js
2512
+ function ProjectsClient(client) {
2513
+ this.client = client;
2514
+ }
2515
+ Object.assign(ProjectsClient.prototype, {
2516
+ list() {
2517
+ return this.client.request({ uri: "/projects" });
2518
+ },
2519
+ getById(id) {
2520
+ return this.client.request({ uri: `/projects/${id}` });
2521
+ }
2522
+ });
2523
+ var projectsClient_default = ProjectsClient;
2524
+
2525
+ // src/http/queryString.js
2526
+ var queryString_default = (params) => {
2527
+ const qs = [];
2528
+ for (const key in params) {
2529
+ if (params.hasOwnProperty(key)) {
2530
+ qs.push(`${encodeURIComponent(key)}=${encodeURIComponent(params[key])}`);
2531
+ }
2532
+ }
2533
+ return qs.length > 0 ? `?${qs.join("&")}` : "";
2534
+ };
2535
+
2536
+ // src/assets/assetsClient.js
2537
+ function AssetsClient(client) {
2538
+ this.client = client;
2539
+ }
2540
+ function optionsFromFile(opts, file) {
2541
+ if (typeof window === "undefined" || !(file instanceof window.File)) {
2542
+ return opts;
2543
+ }
2544
+ return Object.assign(
2545
+ {
2546
+ filename: opts.preserveFilename === false ? void 0 : file.name,
2547
+ contentType: file.type
2548
+ },
2549
+ opts
2550
+ );
2551
+ }
2552
+ Object.assign(AssetsClient.prototype, {
2553
+ upload(assetType, body, opts = {}) {
2554
+ validateAssetType(assetType);
2555
+ let meta = opts.extract || void 0;
2556
+ if (meta && !meta.length) {
2557
+ meta = ["none"];
2558
+ }
2559
+ const dataset2 = hasDataset(this.client.clientConfig);
2560
+ const assetEndpoint = assetType === "image" ? "images" : "files";
2561
+ const options = optionsFromFile(opts, body);
2562
+ const { tag, label, title, description, creditLine, filename, source } = options;
2563
+ const query = {
2564
+ label,
2565
+ title,
2566
+ description,
2567
+ filename,
2568
+ meta,
2569
+ creditLine
2570
+ };
2571
+ if (source) {
2572
+ query.sourceId = source.id;
2573
+ query.sourceName = source.name;
2574
+ query.sourceUrl = source.url;
2575
+ }
2576
+ const observable2 = this.client._requestObservable({
2577
+ tag,
2578
+ method: "POST",
2579
+ timeout: options.timeout || 0,
2580
+ uri: `/assets/${assetEndpoint}/${dataset2}`,
2581
+ headers: options.contentType ? { "Content-Type": options.contentType } : {},
2582
+ query,
2583
+ body
2584
+ });
2585
+ return this.client.isPromiseAPI() ? observable2.pipe(
2586
+ (0, import_filter.filter)((event) => event.type === "response"),
2587
+ (0, import_map.map)((event) => event.body.document)
2588
+ ).toPromise() : observable2;
2589
+ },
2590
+ delete(type, id) {
2591
+ console.warn("client.assets.delete() is deprecated, please use client.delete(<document-id>)");
2592
+ let docId = id || "";
2593
+ if (!/^(image|file)-/.test(docId)) {
2594
+ docId = `${type}-${docId}`;
2595
+ } else if (type._id) {
2596
+ docId = type._id;
2597
+ }
2598
+ hasDataset(this.client.clientConfig);
2599
+ return this.client.delete(docId);
2600
+ },
2601
+ getImageUrl(ref, query) {
2602
+ const id = ref._ref || ref;
2603
+ if (typeof id !== "string") {
2604
+ throw new Error(
2605
+ "getImageUrl() needs either an object with a _ref, or a string with an asset document ID"
2606
+ );
2607
+ }
2608
+ if (!/^image-[A-Za-z0-9_]+-\d+x\d+-[a-z]{1,5}$/.test(id)) {
2609
+ throw new Error(
2610
+ `Unsupported asset ID "${id}". URL generation only works for auto-generated IDs.`
2611
+ );
2612
+ }
2613
+ const [, assetId, size, format] = id.split("-");
2614
+ hasDataset(this.client.clientConfig);
2615
+ const { projectId: projectId2, dataset: dataset2 } = this.client.clientConfig;
2616
+ const qs = query ? queryString_default(query) : "";
2617
+ return `https://cdn.sanity.io/images/${projectId2}/${dataset2}/${assetId}-${size}.${format}${qs}`;
2618
+ }
2619
+ });
2620
+ var assetsClient_default = AssetsClient;
2621
+
2622
+ // src/users/usersClient.js
2623
+ function UsersClient(client) {
2624
+ this.client = client;
2625
+ }
2626
+ Object.assign(UsersClient.prototype, {
2627
+ getById(id) {
2628
+ return this.client.request({ uri: `/users/${id}` });
2629
+ }
2630
+ });
2631
+ var usersClient_default = UsersClient;
2632
+
2633
+ // src/auth/authClient.js
2634
+ function AuthClient(client) {
2635
+ this.client = client;
2636
+ }
2637
+ Object.assign(AuthClient.prototype, {
2638
+ getLoginProviders() {
2639
+ return this.client.request({ uri: "/auth/providers" });
2640
+ },
2641
+ logout() {
2642
+ return this.client.request({ uri: "/auth/logout", method: "POST" });
2643
+ }
2644
+ });
2645
+ var authClient_default = AuthClient;
2646
+
2647
+ // src/http/request.js
2648
+ import getIt from "get-it";
2649
+ import { observable, jsonRequest, jsonResponse, progress } from "get-it/middleware";
2650
+
2651
+ // src/http/errors.js
2652
+ var import_make_error = __toESM(require_make_error());
2653
+ function ClientError(res) {
2654
+ const props = extractErrorProps(res);
2655
+ ClientError.super.call(this, props.message);
2656
+ Object.assign(this, props);
2657
+ }
2658
+ function ServerError(res) {
2659
+ const props = extractErrorProps(res);
2660
+ ServerError.super.call(this, props.message);
2661
+ Object.assign(this, props);
2662
+ }
2663
+ function extractErrorProps(res) {
2664
+ const body = res.body;
2665
+ const props = {
2666
+ response: res,
2667
+ statusCode: res.statusCode,
2668
+ responseBody: stringifyBody(body, res)
2669
+ };
2670
+ if (body.error && body.message) {
2671
+ props.message = `${body.error} - ${body.message}`;
2672
+ return props;
2673
+ }
2674
+ if (body.error && body.error.description) {
2675
+ props.message = body.error.description;
2676
+ props.details = body.error;
2677
+ return props;
2678
+ }
2679
+ props.message = body.error || body.message || httpErrorMessage(res);
2680
+ return props;
2681
+ }
2682
+ function httpErrorMessage(res) {
2683
+ const statusMessage = res.statusMessage ? ` ${res.statusMessage}` : "";
2684
+ return `${res.method}-request to ${res.url} resulted in HTTP ${res.statusCode}${statusMessage}`;
2685
+ }
2686
+ function stringifyBody(body, res) {
2687
+ const contentType = (res.headers["content-type"] || "").toLowerCase();
2688
+ const isJson = contentType.indexOf("application/json") !== -1;
2689
+ return isJson ? JSON.stringify(body, null, 2) : body;
2690
+ }
2691
+ (0, import_make_error.default)(ClientError);
2692
+ (0, import_make_error.default)(ServerError);
2693
+
2694
+ // src/http/browserMiddleware.js
2695
+ var browserMiddleware_default = [];
2696
+
2697
+ // src/http/request.js
2698
+ var httpError = {
2699
+ onResponse: (res) => {
2700
+ if (res.statusCode >= 500) {
2701
+ throw new ServerError(res);
2702
+ } else if (res.statusCode >= 400) {
2703
+ throw new ClientError(res);
2704
+ }
2705
+ return res;
2706
+ }
2707
+ };
2708
+ var printWarnings = {
2709
+ onResponse: (res) => {
2710
+ const warn = res.headers["x-sanity-warning"];
2711
+ const warnings = Array.isArray(warn) ? warn : [warn];
2712
+ warnings.filter(Boolean).forEach((msg) => console.warn(msg));
2713
+ return res;
2714
+ }
2715
+ };
2716
+ var envSpecific = browserMiddleware_default;
2717
+ var middleware = envSpecific.concat([
2718
+ printWarnings,
2719
+ jsonRequest(),
2720
+ jsonResponse(),
2721
+ progress(),
2722
+ httpError,
2723
+ observable({ implementation: import_Observable.Observable })
2724
+ ]);
2725
+ var request = getIt(middleware);
2726
+ function httpRequest(options, requester = request) {
2727
+ return requester(Object.assign({ maxRedirects: 0 }, options));
2728
+ }
2729
+ httpRequest.defaultRequester = request;
2730
+ httpRequest.ClientError = ClientError;
2731
+ httpRequest.ServerError = ServerError;
2732
+ var request_default = httpRequest;
2733
+
2734
+ // src/http/requestOptions.js
2735
+ var projectHeader = "X-Sanity-Project-ID";
2736
+ var requestOptions_default = (config, overrides = {}) => {
2737
+ const headers = {};
2738
+ const token = overrides.token || config.token;
2739
+ if (token) {
2740
+ headers.Authorization = `Bearer ${token}`;
2741
+ }
2742
+ if (!overrides.useGlobalApi && !config.useProjectHostname && config.projectId) {
2743
+ headers[projectHeader] = config.projectId;
2744
+ }
2745
+ const withCredentials = Boolean(
2746
+ typeof overrides.withCredentials === "undefined" ? config.token || config.withCredentials : overrides.withCredentials
2747
+ );
2748
+ const timeout = typeof overrides.timeout === "undefined" ? config.timeout : overrides.timeout;
2749
+ return Object.assign({}, overrides, {
2750
+ headers: Object.assign({}, headers, overrides.headers || {}),
2751
+ timeout: typeof timeout === "undefined" ? 5 * 60 * 1e3 : timeout,
2752
+ proxy: overrides.proxy || config.proxy,
2753
+ json: true,
2754
+ withCredentials
2755
+ });
2756
+ };
2757
+
2758
+ // src/generateHelpUrl.js
2759
+ var BASE_URL = "https://docs.sanity.io/help/";
2760
+ function generateHelpUrl(slug) {
2761
+ return BASE_URL + slug;
2762
+ }
2763
+
2764
+ // src/util/once.js
2765
+ var once_default = (fn) => {
2766
+ let didCall = false;
2767
+ let returnValue;
2768
+ return (...args) => {
2769
+ if (didCall) {
2770
+ return returnValue;
2771
+ }
2772
+ returnValue = fn(...args);
2773
+ didCall = true;
2774
+ return returnValue;
2775
+ };
2776
+ };
2777
+
2778
+ // src/warnings.js
2779
+ var createWarningPrinter = (message) => once_default((...args) => console.warn(message.join(" "), ...args));
2780
+ var printCdnWarning = createWarningPrinter([
2781
+ "You are not using the Sanity CDN. That means your data is always fresh, but the CDN is faster and",
2782
+ `cheaper. Think about it! For more info, see ${generateHelpUrl("js-client-cdn-configuration")}.`,
2783
+ "To hide this warning, please set the `useCdn` option to either `true` or `false` when creating",
2784
+ "the client."
2785
+ ]);
2786
+ var printBrowserTokenWarning = createWarningPrinter([
2787
+ "You have configured Sanity client to use a token in the browser. This may cause unintentional security issues.",
2788
+ `See ${generateHelpUrl(
2789
+ "js-client-browser-token"
2790
+ )} for more information and how to hide this warning.`
2791
+ ]);
2792
+ var printNoApiVersionSpecifiedWarning = createWarningPrinter([
2793
+ "Using the Sanity client without specifying an API version is deprecated.",
2794
+ `See ${generateHelpUrl("js-client-api-version")}`
2795
+ ]);
2796
+
2797
+ // src/config.js
2798
+ var defaultCdnHost = "apicdn.sanity.io";
2799
+ var defaultConfig = {
2800
+ apiHost: "https://api.sanity.io",
2801
+ apiVersion: "1",
2802
+ useProjectHostname: true,
2803
+ isPromiseAPI: true
2804
+ };
2805
+ var LOCALHOSTS = ["localhost", "127.0.0.1", "0.0.0.0"];
2806
+ var isLocal = (host) => LOCALHOSTS.indexOf(host) !== -1;
2807
+ var validateApiVersion = function validateApiVersion2(apiVersion) {
2808
+ if (apiVersion === "1" || apiVersion === "X") {
2809
+ return;
2810
+ }
2811
+ const apiDate = new Date(apiVersion);
2812
+ const apiVersionValid = /^\d{4}-\d{2}-\d{2}$/.test(apiVersion) && apiDate instanceof Date && apiDate.getTime() > 0;
2813
+ if (!apiVersionValid) {
2814
+ throw new Error("Invalid API version string, expected `1` or date in format `YYYY-MM-DD`");
2815
+ }
2816
+ };
2817
+ var initConfig = (config, prevConfig) => {
2818
+ const specifiedConfig = Object.assign({}, prevConfig, config);
2819
+ if (!specifiedConfig.apiVersion) {
2820
+ printNoApiVersionSpecifiedWarning();
2821
+ }
2822
+ const newConfig = Object.assign({}, defaultConfig, specifiedConfig);
2823
+ const projectBased = newConfig.useProjectHostname;
2824
+ if (typeof Promise === "undefined") {
2825
+ const helpUrl = generateHelpUrl("js-client-promise-polyfill");
2826
+ throw new Error(`No native Promise-implementation found, polyfill needed - see ${helpUrl}`);
2827
+ }
2828
+ if (projectBased && !newConfig.projectId) {
2829
+ throw new Error("Configuration must contain `projectId`");
2830
+ }
2831
+ const isBrowser = typeof window !== "undefined" && window.location && window.location.hostname;
2832
+ const isLocalhost = isBrowser && isLocal(window.location.hostname);
2833
+ if (isBrowser && isLocalhost && newConfig.token && newConfig.ignoreBrowserTokenWarning !== true) {
2834
+ printBrowserTokenWarning();
2835
+ } else if (typeof newConfig.useCdn === "undefined") {
2836
+ printCdnWarning();
2837
+ }
2838
+ if (projectBased) {
2839
+ projectId(newConfig.projectId);
2840
+ }
2841
+ if (newConfig.dataset) {
2842
+ dataset(newConfig.dataset);
2843
+ }
2844
+ if ("requestTagPrefix" in newConfig) {
2845
+ newConfig.requestTagPrefix = newConfig.requestTagPrefix ? requestTag(newConfig.requestTagPrefix).replace(/\.+$/, "") : void 0;
2846
+ }
2847
+ newConfig.apiVersion = `${newConfig.apiVersion}`.replace(/^v/, "");
2848
+ newConfig.isDefaultApi = newConfig.apiHost === defaultConfig.apiHost;
2849
+ newConfig.useCdn = Boolean(newConfig.useCdn) && !newConfig.withCredentials;
2850
+ validateApiVersion(newConfig.apiVersion);
2851
+ const hostParts = newConfig.apiHost.split("://", 2);
2852
+ const protocol = hostParts[0];
2853
+ const host = hostParts[1];
2854
+ const cdnHost = newConfig.isDefaultApi ? defaultCdnHost : host;
2855
+ if (newConfig.useProjectHostname) {
2856
+ newConfig.url = `${protocol}://${newConfig.projectId}.${host}/v${newConfig.apiVersion}`;
2857
+ newConfig.cdnUrl = `${protocol}://${newConfig.projectId}.${cdnHost}/v${newConfig.apiVersion}`;
2858
+ } else {
2859
+ newConfig.url = `${newConfig.apiHost}/v${newConfig.apiVersion}`;
2860
+ newConfig.cdnUrl = newConfig.url;
2861
+ }
2862
+ return newConfig;
2863
+ };
2864
+
2865
+ // src/sanityClient.js
2866
+ var toPromise2 = (observable2) => observable2.toPromise();
2867
+ function SanityClient(config = defaultConfig) {
2868
+ if (!(this instanceof SanityClient)) {
2869
+ return new SanityClient(config);
2870
+ }
2871
+ this.config(config);
2872
+ this.assets = new assetsClient_default(this);
2873
+ this.datasets = new datasetsClient_default(this);
2874
+ this.projects = new projectsClient_default(this);
2875
+ this.users = new usersClient_default(this);
2876
+ this.auth = new authClient_default(this);
2877
+ if (this.clientConfig.isPromiseAPI) {
2878
+ const observableConfig = Object.assign({}, this.clientConfig, { isPromiseAPI: false });
2879
+ this.observable = new SanityClient(observableConfig);
2880
+ }
2881
+ }
2882
+ Object.assign(SanityClient.prototype, dataMethods_default);
2883
+ Object.assign(SanityClient.prototype, {
2884
+ clone() {
2885
+ return new SanityClient(this.config());
2886
+ },
2887
+ config(newConfig) {
2888
+ if (typeof newConfig === "undefined") {
2889
+ return Object.assign({}, this.clientConfig);
2890
+ }
2891
+ if (this.observable) {
2892
+ const observableConfig = Object.assign({}, newConfig, { isPromiseAPI: false });
2893
+ this.observable.config(observableConfig);
2894
+ }
2895
+ this.clientConfig = initConfig(newConfig, this.clientConfig || {});
2896
+ return this;
2897
+ },
2898
+ withConfig(newConfig) {
2899
+ return this.clone().config(newConfig);
2900
+ },
2901
+ getUrl(uri, useCdn = false) {
2902
+ const base = useCdn ? this.clientConfig.cdnUrl : this.clientConfig.url;
2903
+ return `${base}/${uri.replace(/^\//, "")}`;
2904
+ },
2905
+ isPromiseAPI() {
2906
+ return this.clientConfig.isPromiseAPI;
2907
+ },
2908
+ _requestObservable(options) {
2909
+ const uri = options.url || options.uri;
2910
+ const canUseCdn = typeof options.canUseCdn === "undefined" ? ["GET", "HEAD"].indexOf(options.method || "GET") >= 0 && uri.indexOf("/data/") === 0 : options.canUseCdn;
2911
+ const useCdn = this.clientConfig.useCdn && canUseCdn;
2912
+ const tag = options.tag && this.clientConfig.requestTagPrefix ? [this.clientConfig.requestTagPrefix, options.tag].join(".") : options.tag || this.clientConfig.requestTagPrefix;
2913
+ if (tag) {
2914
+ options.query = { tag: requestTag(tag), ...options.query };
2915
+ }
2916
+ const reqOptions = requestOptions_default(
2917
+ this.clientConfig,
2918
+ Object.assign({}, options, {
2919
+ url: this.getUrl(uri, useCdn)
2920
+ })
2921
+ );
2922
+ return new import_Observable.Observable(
2923
+ (subscriber) => request_default(reqOptions, this.clientConfig.requester).subscribe(subscriber)
2924
+ );
2925
+ },
2926
+ request(options) {
2927
+ const observable2 = this._requestObservable(options).pipe(
2928
+ (0, import_filter.filter)((event) => event.type === "response"),
2929
+ (0, import_map.map)((event) => event.body)
2930
+ );
2931
+ return this.isPromiseAPI() ? toPromise2(observable2) : observable2;
2932
+ }
2933
+ });
2934
+ SanityClient.Patch = patch_default;
2935
+ SanityClient.Transaction = transaction_default;
2936
+ SanityClient.ClientError = request_default.ClientError;
2937
+ SanityClient.ServerError = request_default.ServerError;
2938
+ SanityClient.requester = request_default.defaultRequester;
2939
+ var sanityClient_default = SanityClient;
2940
+ export {
2941
+ sanityClient_default as default
2942
+ };
2943
+ /** @license
2944
+ * eventsource.js
2945
+ * Available under MIT License (MIT)
2946
+ * https://github.com/Yaffle/EventSource/
2947
+ */
2948
+ //# sourceMappingURL=sanityClient.browser.mjs.map