@sanity/client 6.5.0 → 6.5.1-canary.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/package.json +3 -3
- package/umd/sanityClient.js +438 -35
- package/umd/sanityClient.min.js +3 -3
package/dist/index.cjs
CHANGED
|
@@ -8,7 +8,7 @@ var getIt = require('get-it');
|
|
|
8
8
|
var rxjs = require('rxjs');
|
|
9
9
|
var operators = require('rxjs/operators');
|
|
10
10
|
var name = "@sanity/client";
|
|
11
|
-
var version = "6.5.0";
|
|
11
|
+
var version = "6.5.1-canary.0";
|
|
12
12
|
const middleware = [middleware$1.debug({
|
|
13
13
|
verbose: true,
|
|
14
14
|
namespace: "sanity:client"
|
package/dist/index.js
CHANGED
|
@@ -4,7 +4,7 @@ export { adapter as unstable__adapter, environment as unstable__environment } fr
|
|
|
4
4
|
import { Observable, lastValueFrom } from 'rxjs';
|
|
5
5
|
import { map, filter } from 'rxjs/operators';
|
|
6
6
|
var name = "@sanity/client";
|
|
7
|
-
var version = "6.5.0";
|
|
7
|
+
var version = "6.5.1-canary.0";
|
|
8
8
|
const middleware = [debug({
|
|
9
9
|
verbose: true,
|
|
10
10
|
namespace: "sanity:client"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/client",
|
|
3
|
-
"version": "6.5.0",
|
|
3
|
+
"version": "6.5.1-canary.0",
|
|
4
4
|
"description": "Client for retrieving, creating and patching data from Sanity.io",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sanity",
|
|
@@ -99,7 +99,7 @@
|
|
|
99
99
|
"@edge-runtime/vm": "^3.1.4",
|
|
100
100
|
"@rollup/plugin-commonjs": "^25.0.5",
|
|
101
101
|
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
102
|
-
"@sanity/pkg-utils": "^
|
|
102
|
+
"@sanity/pkg-utils": "^3.0.0",
|
|
103
103
|
"@types/node": "^20.8.4",
|
|
104
104
|
"@typescript-eslint/eslint-plugin": "^6.7.5",
|
|
105
105
|
"@typescript-eslint/parser": "^6.7.5",
|
|
@@ -115,7 +115,7 @@
|
|
|
115
115
|
"prettier": "^3.0.3",
|
|
116
116
|
"prettier-plugin-packagejson": "^2.4.6",
|
|
117
117
|
"rimraf": "^5.0.1",
|
|
118
|
-
"rollup": "^
|
|
118
|
+
"rollup": "^4.0.2",
|
|
119
119
|
"sse-channel": "^4.0.0",
|
|
120
120
|
"terser": "^5.21.0",
|
|
121
121
|
"typescript": "^5.2.2",
|
package/umd/sanityClient.js
CHANGED
|
@@ -4,13 +4,13 @@
|
|
|
4
4
|
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.SanityClient = {}));
|
|
5
5
|
})(this, (function (exports) { 'use strict';
|
|
6
6
|
|
|
7
|
-
const isReactNative = typeof navigator === "undefined" ? false : navigator.product === "ReactNative";
|
|
8
|
-
const defaultOptions$
|
|
9
|
-
timeout: isReactNative ? 6e4 : 12e4
|
|
7
|
+
const isReactNative$1 = typeof navigator === "undefined" ? false : navigator.product === "ReactNative";
|
|
8
|
+
const defaultOptions$2 = {
|
|
9
|
+
timeout: isReactNative$1 ? 6e4 : 12e4
|
|
10
10
|
};
|
|
11
|
-
const processOptions = function processOptions2(opts) {
|
|
11
|
+
const processOptions$1 = function processOptions2(opts) {
|
|
12
12
|
const options = {
|
|
13
|
-
...defaultOptions$
|
|
13
|
+
...defaultOptions$2,
|
|
14
14
|
...(typeof opts === "string" ? {
|
|
15
15
|
url: opts
|
|
16
16
|
} : opts)
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
const {
|
|
19
19
|
searchParams
|
|
20
20
|
} = new URL(options.url, "http://localhost");
|
|
21
|
-
options.timeout = normalizeTimeout(options.timeout);
|
|
21
|
+
options.timeout = normalizeTimeout$1(options.timeout);
|
|
22
22
|
if (options.query) {
|
|
23
23
|
for (const [key, value] of Object.entries(options.query)) {
|
|
24
24
|
if (value !== void 0) {
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
options.method = options.body && !options.method ? "POST" : (options.method || "GET").toUpperCase();
|
|
41
41
|
return options;
|
|
42
42
|
};
|
|
43
|
-
function normalizeTimeout(time) {
|
|
43
|
+
function normalizeTimeout$1(time) {
|
|
44
44
|
if (time === false || time === 0) {
|
|
45
45
|
return false;
|
|
46
46
|
}
|
|
@@ -49,16 +49,16 @@
|
|
|
49
49
|
}
|
|
50
50
|
const delay = Number(time);
|
|
51
51
|
if (isNaN(delay)) {
|
|
52
|
-
return normalizeTimeout(defaultOptions$
|
|
52
|
+
return normalizeTimeout$1(defaultOptions$2.timeout);
|
|
53
53
|
}
|
|
54
54
|
return {
|
|
55
55
|
connect: delay,
|
|
56
56
|
socket: delay
|
|
57
57
|
};
|
|
58
58
|
}
|
|
59
|
-
const validUrl = /^https?:\/\//i;
|
|
60
|
-
const validateOptions = function validateOptions2(options) {
|
|
61
|
-
if (!validUrl.test(options.url)) {
|
|
59
|
+
const validUrl$1 = /^https?:\/\//i;
|
|
60
|
+
const validateOptions$1 = function validateOptions2(options) {
|
|
61
|
+
if (!validUrl$1.test(options.url)) {
|
|
62
62
|
throw new Error('"'.concat(options.url, '" is not a valid URL'));
|
|
63
63
|
}
|
|
64
64
|
};
|
|
@@ -147,8 +147,8 @@
|
|
|
147
147
|
ware[name] = ware[name] || [];
|
|
148
148
|
return ware;
|
|
149
149
|
}, {
|
|
150
|
-
processOptions: [processOptions],
|
|
151
|
-
validateOptions: [validateOptions]
|
|
150
|
+
processOptions: [processOptions$1],
|
|
151
|
+
validateOptions: [validateOptions$1]
|
|
152
152
|
});
|
|
153
153
|
function request(opts) {
|
|
154
154
|
const onResponse = (reqErr, res, ctx) => {
|
|
@@ -219,15 +219,15 @@
|
|
|
219
219
|
initMiddleware.forEach(request.use);
|
|
220
220
|
return request;
|
|
221
221
|
}
|
|
222
|
-
var __defProp$
|
|
223
|
-
var __defNormalProp$
|
|
222
|
+
var __defProp$2 = Object.defineProperty;
|
|
223
|
+
var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, {
|
|
224
224
|
enumerable: true,
|
|
225
225
|
configurable: true,
|
|
226
226
|
writable: true,
|
|
227
227
|
value
|
|
228
228
|
}) : obj[key] = value;
|
|
229
|
-
var __publicField$
|
|
230
|
-
__defNormalProp$
|
|
229
|
+
var __publicField$2 = (obj, key, value) => {
|
|
230
|
+
__defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
231
231
|
return value;
|
|
232
232
|
};
|
|
233
233
|
var __accessCheck$7 = (obj, member, msg) => {
|
|
@@ -252,20 +252,20 @@
|
|
|
252
252
|
/**
|
|
253
253
|
* Public interface, interop with real XMLHttpRequest
|
|
254
254
|
*/
|
|
255
|
-
__publicField$
|
|
256
|
-
__publicField$
|
|
257
|
-
__publicField$
|
|
258
|
-
__publicField$
|
|
255
|
+
__publicField$2(this, "onabort");
|
|
256
|
+
__publicField$2(this, "onerror");
|
|
257
|
+
__publicField$2(this, "onreadystatechange");
|
|
258
|
+
__publicField$2(this, "ontimeout");
|
|
259
259
|
/**
|
|
260
260
|
* https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/readyState
|
|
261
261
|
*/
|
|
262
|
-
__publicField$
|
|
263
|
-
__publicField$
|
|
264
|
-
__publicField$
|
|
265
|
-
__publicField$
|
|
266
|
-
__publicField$
|
|
267
|
-
__publicField$
|
|
268
|
-
__publicField$
|
|
262
|
+
__publicField$2(this, "readyState", 0);
|
|
263
|
+
__publicField$2(this, "response");
|
|
264
|
+
__publicField$2(this, "responseText");
|
|
265
|
+
__publicField$2(this, "responseType", "");
|
|
266
|
+
__publicField$2(this, "status");
|
|
267
|
+
__publicField$2(this, "statusText");
|
|
268
|
+
__publicField$2(this, "withCredentials");
|
|
269
269
|
/**
|
|
270
270
|
* Private implementation details
|
|
271
271
|
*/
|
|
@@ -498,6 +498,8 @@
|
|
|
498
498
|
};
|
|
499
499
|
const environment = "browser";
|
|
500
500
|
|
|
501
|
+
var middleware_browser = {};
|
|
502
|
+
|
|
501
503
|
var browser$3 = {exports: {}};
|
|
502
504
|
|
|
503
505
|
/**
|
|
@@ -1217,6 +1219,75 @@
|
|
|
1217
1219
|
};
|
|
1218
1220
|
} (browser$3, browser$3.exports));
|
|
1219
1221
|
|
|
1222
|
+
var browserExports = browser$3.exports;
|
|
1223
|
+
|
|
1224
|
+
var defaultOptionsValidator41aa9136 = {};
|
|
1225
|
+
|
|
1226
|
+
const isReactNative = typeof navigator === "undefined" ? false : navigator.product === "ReactNative";
|
|
1227
|
+
const defaultOptions$1 = {
|
|
1228
|
+
timeout: isReactNative ? 6e4 : 12e4
|
|
1229
|
+
};
|
|
1230
|
+
const processOptions = function processOptions2(opts) {
|
|
1231
|
+
const options = {
|
|
1232
|
+
...defaultOptions$1,
|
|
1233
|
+
...(typeof opts === "string" ? {
|
|
1234
|
+
url: opts
|
|
1235
|
+
} : opts)
|
|
1236
|
+
};
|
|
1237
|
+
const {
|
|
1238
|
+
searchParams
|
|
1239
|
+
} = new URL(options.url, "http://localhost");
|
|
1240
|
+
options.timeout = normalizeTimeout(options.timeout);
|
|
1241
|
+
if (options.query) {
|
|
1242
|
+
for (const [key, value] of Object.entries(options.query)) {
|
|
1243
|
+
if (value !== void 0) {
|
|
1244
|
+
if (Array.isArray(value)) {
|
|
1245
|
+
for (const v of value) {
|
|
1246
|
+
searchParams.append(key, v);
|
|
1247
|
+
}
|
|
1248
|
+
} else {
|
|
1249
|
+
searchParams.append(key, value);
|
|
1250
|
+
}
|
|
1251
|
+
}
|
|
1252
|
+
}
|
|
1253
|
+
}
|
|
1254
|
+
const [url] = options.url.split("?");
|
|
1255
|
+
const search = searchParams.toString();
|
|
1256
|
+
if (search) {
|
|
1257
|
+
options.url = "".concat(url, "?").concat(search);
|
|
1258
|
+
}
|
|
1259
|
+
options.method = options.body && !options.method ? "POST" : (options.method || "GET").toUpperCase();
|
|
1260
|
+
return options;
|
|
1261
|
+
};
|
|
1262
|
+
function normalizeTimeout(time) {
|
|
1263
|
+
if (time === false || time === 0) {
|
|
1264
|
+
return false;
|
|
1265
|
+
}
|
|
1266
|
+
if (time.connect || time.socket) {
|
|
1267
|
+
return time;
|
|
1268
|
+
}
|
|
1269
|
+
const delay = Number(time);
|
|
1270
|
+
if (isNaN(delay)) {
|
|
1271
|
+
return normalizeTimeout(defaultOptions$1.timeout);
|
|
1272
|
+
}
|
|
1273
|
+
return {
|
|
1274
|
+
connect: delay,
|
|
1275
|
+
socket: delay
|
|
1276
|
+
};
|
|
1277
|
+
}
|
|
1278
|
+
const validUrl = /^https?:\/\//i;
|
|
1279
|
+
const validateOptions = function validateOptions2(options) {
|
|
1280
|
+
if (!validUrl.test(options.url)) {
|
|
1281
|
+
throw new Error('"'.concat(options.url, '" is not a valid URL'));
|
|
1282
|
+
}
|
|
1283
|
+
};
|
|
1284
|
+
defaultOptionsValidator41aa9136.processOptions = processOptions;
|
|
1285
|
+
defaultOptionsValidator41aa9136.validateOptions = validateOptions;
|
|
1286
|
+
|
|
1287
|
+
var isPlainObject$3 = {};
|
|
1288
|
+
|
|
1289
|
+
Object.defineProperty(isPlainObject$3, '__esModule', { value: true });
|
|
1290
|
+
|
|
1220
1291
|
/*!
|
|
1221
1292
|
* is-plain-object <https://github.com/jonschlinkert/is-plain-object>
|
|
1222
1293
|
*
|
|
@@ -1228,7 +1299,7 @@
|
|
|
1228
1299
|
return Object.prototype.toString.call(o) === '[object Object]';
|
|
1229
1300
|
}
|
|
1230
1301
|
|
|
1231
|
-
function isPlainObject$
|
|
1302
|
+
function isPlainObject$2(o) {
|
|
1232
1303
|
var ctor,prot;
|
|
1233
1304
|
|
|
1234
1305
|
if (isObject(o) === false) return false;
|
|
@@ -1250,6 +1321,184 @@
|
|
|
1250
1321
|
return true;
|
|
1251
1322
|
}
|
|
1252
1323
|
|
|
1324
|
+
isPlainObject$3.isPlainObject = isPlainObject$2;
|
|
1325
|
+
|
|
1326
|
+
Object.defineProperty(middleware_browser, '__esModule', {
|
|
1327
|
+
value: true
|
|
1328
|
+
});
|
|
1329
|
+
var debugIt = browserExports;
|
|
1330
|
+
var defaultOptionsValidator = defaultOptionsValidator41aa9136;
|
|
1331
|
+
var isPlainObject$1 = isPlainObject$3;
|
|
1332
|
+
function _interopDefaultCompat$1(e) {
|
|
1333
|
+
return e && typeof e === 'object' && 'default' in e ? e : {
|
|
1334
|
+
default: e
|
|
1335
|
+
};
|
|
1336
|
+
}
|
|
1337
|
+
var debugIt__default = /*#__PURE__*/_interopDefaultCompat$1(debugIt);
|
|
1338
|
+
function agent(opts) {
|
|
1339
|
+
return {};
|
|
1340
|
+
}
|
|
1341
|
+
const leadingSlash = /^\//;
|
|
1342
|
+
const trailingSlash = /\/$/;
|
|
1343
|
+
function base(baseUrl) {
|
|
1344
|
+
const baseUri = baseUrl.replace(trailingSlash, "");
|
|
1345
|
+
return {
|
|
1346
|
+
processOptions: options => {
|
|
1347
|
+
if (/^https?:\/\//i.test(options.url)) {
|
|
1348
|
+
return options;
|
|
1349
|
+
}
|
|
1350
|
+
const url = [baseUri, options.url.replace(leadingSlash, "")].join("/");
|
|
1351
|
+
return Object.assign({}, options, {
|
|
1352
|
+
url
|
|
1353
|
+
});
|
|
1354
|
+
}
|
|
1355
|
+
};
|
|
1356
|
+
}
|
|
1357
|
+
const SENSITIVE_HEADERS = ["cookie", "authorization"];
|
|
1358
|
+
const hasOwn = Object.prototype.hasOwnProperty;
|
|
1359
|
+
const redactKeys = (source, redacted) => {
|
|
1360
|
+
const target = {};
|
|
1361
|
+
for (const key in source) {
|
|
1362
|
+
if (hasOwn.call(source, key)) {
|
|
1363
|
+
target[key] = redacted.indexOf(key.toLowerCase()) > -1 ? "<redacted>" : source[key];
|
|
1364
|
+
}
|
|
1365
|
+
}
|
|
1366
|
+
return target;
|
|
1367
|
+
};
|
|
1368
|
+
function debug() {
|
|
1369
|
+
let opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1370
|
+
const verbose = opts.verbose;
|
|
1371
|
+
const namespace = opts.namespace || "get-it";
|
|
1372
|
+
const defaultLogger = debugIt__default.default(namespace);
|
|
1373
|
+
const log = opts.log || defaultLogger;
|
|
1374
|
+
const shortCircuit = log === defaultLogger && !debugIt__default.default.enabled(namespace);
|
|
1375
|
+
let requestId = 0;
|
|
1376
|
+
return {
|
|
1377
|
+
processOptions: options => {
|
|
1378
|
+
options.debug = log;
|
|
1379
|
+
options.requestId = options.requestId || ++requestId;
|
|
1380
|
+
return options;
|
|
1381
|
+
},
|
|
1382
|
+
onRequest: event => {
|
|
1383
|
+
if (shortCircuit || !event) {
|
|
1384
|
+
return event;
|
|
1385
|
+
}
|
|
1386
|
+
const options = event.options;
|
|
1387
|
+
log("[%s] HTTP %s %s", options.requestId, options.method, options.url);
|
|
1388
|
+
if (verbose && options.body && typeof options.body === "string") {
|
|
1389
|
+
log("[%s] Request body: %s", options.requestId, options.body);
|
|
1390
|
+
}
|
|
1391
|
+
if (verbose && options.headers) {
|
|
1392
|
+
const headers = opts.redactSensitiveHeaders === false ? options.headers : redactKeys(options.headers, SENSITIVE_HEADERS);
|
|
1393
|
+
log("[%s] Request headers: %s", options.requestId, JSON.stringify(headers, null, 2));
|
|
1394
|
+
}
|
|
1395
|
+
return event;
|
|
1396
|
+
},
|
|
1397
|
+
onResponse: (res, context) => {
|
|
1398
|
+
if (shortCircuit || !res) {
|
|
1399
|
+
return res;
|
|
1400
|
+
}
|
|
1401
|
+
const reqId = context.options.requestId;
|
|
1402
|
+
log("[%s] Response code: %s %s", reqId, res.statusCode, res.statusMessage);
|
|
1403
|
+
if (verbose && res.body) {
|
|
1404
|
+
log("[%s] Response body: %s", reqId, stringifyBody$1(res));
|
|
1405
|
+
}
|
|
1406
|
+
return res;
|
|
1407
|
+
},
|
|
1408
|
+
onError: (err, context) => {
|
|
1409
|
+
const reqId = context.options.requestId;
|
|
1410
|
+
if (!err) {
|
|
1411
|
+
log("[%s] Error encountered, but handled by an earlier middleware", reqId);
|
|
1412
|
+
return err;
|
|
1413
|
+
}
|
|
1414
|
+
log("[%s] ERROR: %s", reqId, err.message);
|
|
1415
|
+
return err;
|
|
1416
|
+
}
|
|
1417
|
+
};
|
|
1418
|
+
}
|
|
1419
|
+
function stringifyBody$1(res) {
|
|
1420
|
+
const contentType = (res.headers["content-type"] || "").toLowerCase();
|
|
1421
|
+
const isJson = contentType.indexOf("application/json") !== -1;
|
|
1422
|
+
return isJson ? tryFormat(res.body) : res.body;
|
|
1423
|
+
}
|
|
1424
|
+
function tryFormat(body) {
|
|
1425
|
+
try {
|
|
1426
|
+
const parsed = typeof body === "string" ? JSON.parse(body) : body;
|
|
1427
|
+
return JSON.stringify(parsed, null, 2);
|
|
1428
|
+
} catch (err) {
|
|
1429
|
+
return body;
|
|
1430
|
+
}
|
|
1431
|
+
}
|
|
1432
|
+
function headers(_headers) {
|
|
1433
|
+
let opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1434
|
+
return {
|
|
1435
|
+
processOptions: options => {
|
|
1436
|
+
const existing = options.headers || {};
|
|
1437
|
+
options.headers = opts.override ? Object.assign({}, existing, _headers) : Object.assign({}, _headers, existing);
|
|
1438
|
+
return options;
|
|
1439
|
+
}
|
|
1440
|
+
};
|
|
1441
|
+
}
|
|
1442
|
+
var __defProp$1 = Object.defineProperty;
|
|
1443
|
+
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, {
|
|
1444
|
+
enumerable: true,
|
|
1445
|
+
configurable: true,
|
|
1446
|
+
writable: true,
|
|
1447
|
+
value
|
|
1448
|
+
}) : obj[key] = value;
|
|
1449
|
+
var __publicField$1 = (obj, key, value) => {
|
|
1450
|
+
__defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
1451
|
+
return value;
|
|
1452
|
+
};
|
|
1453
|
+
class HttpError extends Error {
|
|
1454
|
+
constructor(res, ctx) {
|
|
1455
|
+
super();
|
|
1456
|
+
__publicField$1(this, "response");
|
|
1457
|
+
__publicField$1(this, "request");
|
|
1458
|
+
const truncatedUrl = res.url.length > 400 ? "".concat(res.url.slice(0, 399), "\u2026") : res.url;
|
|
1459
|
+
let msg = "".concat(res.method, "-request to ").concat(truncatedUrl, " resulted in ");
|
|
1460
|
+
msg += "HTTP ".concat(res.statusCode, " ").concat(res.statusMessage);
|
|
1461
|
+
this.message = msg.trim();
|
|
1462
|
+
this.response = res;
|
|
1463
|
+
this.request = ctx.options;
|
|
1464
|
+
}
|
|
1465
|
+
}
|
|
1466
|
+
function httpErrors() {
|
|
1467
|
+
return {
|
|
1468
|
+
onResponse: (res, ctx) => {
|
|
1469
|
+
const isHttpError = res.statusCode >= 400;
|
|
1470
|
+
if (!isHttpError) {
|
|
1471
|
+
return res;
|
|
1472
|
+
}
|
|
1473
|
+
throw new HttpError(res, ctx);
|
|
1474
|
+
}
|
|
1475
|
+
};
|
|
1476
|
+
}
|
|
1477
|
+
function injectResponse() {
|
|
1478
|
+
let opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1479
|
+
if (typeof opts.inject !== "function") {
|
|
1480
|
+
throw new Error("`injectResponse` middleware requires a `inject` function");
|
|
1481
|
+
}
|
|
1482
|
+
const inject = function inject2(prevValue, event) {
|
|
1483
|
+
const response = opts.inject(event, prevValue);
|
|
1484
|
+
if (!response) {
|
|
1485
|
+
return prevValue;
|
|
1486
|
+
}
|
|
1487
|
+
const options = event.context.options;
|
|
1488
|
+
return {
|
|
1489
|
+
body: "",
|
|
1490
|
+
url: options.url,
|
|
1491
|
+
method: options.method,
|
|
1492
|
+
headers: {},
|
|
1493
|
+
statusCode: 200,
|
|
1494
|
+
statusMessage: "OK",
|
|
1495
|
+
...response
|
|
1496
|
+
};
|
|
1497
|
+
};
|
|
1498
|
+
return {
|
|
1499
|
+
interceptRequest: inject
|
|
1500
|
+
};
|
|
1501
|
+
}
|
|
1253
1502
|
const isBuffer = typeof Buffer === "undefined" ? () => false : obj => Buffer.isBuffer(obj);
|
|
1254
1503
|
const serializeTypes = ["boolean", "string", "number"];
|
|
1255
1504
|
function jsonRequest() {
|
|
@@ -1260,7 +1509,7 @@
|
|
|
1260
1509
|
return options;
|
|
1261
1510
|
}
|
|
1262
1511
|
const isStream = typeof body.pipe === "function";
|
|
1263
|
-
const shouldSerialize = !isStream && !isBuffer(body) && (serializeTypes.indexOf(typeof body) !== -1 || Array.isArray(body) || isPlainObject$1(body));
|
|
1512
|
+
const shouldSerialize = !isStream && !isBuffer(body) && (serializeTypes.indexOf(typeof body) !== -1 || Array.isArray(body) || isPlainObject$1.isPlainObject(body));
|
|
1264
1513
|
if (!shouldSerialize) {
|
|
1265
1514
|
return options;
|
|
1266
1515
|
}
|
|
@@ -1300,13 +1549,41 @@
|
|
|
1300
1549
|
}
|
|
1301
1550
|
}
|
|
1302
1551
|
}
|
|
1552
|
+
function isBrowserOptions(options) {
|
|
1553
|
+
return typeof options === "object" && options !== null && !("protocol" in options);
|
|
1554
|
+
}
|
|
1555
|
+
function mtls() {
|
|
1556
|
+
let config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1557
|
+
if (!config.ca) {
|
|
1558
|
+
throw new Error('Required mtls option "ca" is missing');
|
|
1559
|
+
}
|
|
1560
|
+
if (!config.cert) {
|
|
1561
|
+
throw new Error('Required mtls option "cert" is missing');
|
|
1562
|
+
}
|
|
1563
|
+
if (!config.key) {
|
|
1564
|
+
throw new Error('Required mtls option "key" is missing');
|
|
1565
|
+
}
|
|
1566
|
+
return {
|
|
1567
|
+
finalizeOptions: options => {
|
|
1568
|
+
if (isBrowserOptions(options)) {
|
|
1569
|
+
return options;
|
|
1570
|
+
}
|
|
1571
|
+
const mtlsOpts = {
|
|
1572
|
+
cert: config.cert,
|
|
1573
|
+
key: config.key,
|
|
1574
|
+
ca: config.ca
|
|
1575
|
+
};
|
|
1576
|
+
return Object.assign({}, options, mtlsOpts);
|
|
1577
|
+
}
|
|
1578
|
+
};
|
|
1579
|
+
}
|
|
1303
1580
|
let actualGlobal = {};
|
|
1304
1581
|
if (typeof globalThis !== "undefined") {
|
|
1305
1582
|
actualGlobal = globalThis;
|
|
1306
1583
|
} else if (typeof window !== "undefined") {
|
|
1307
1584
|
actualGlobal = window;
|
|
1308
|
-
} else if (typeof
|
|
1309
|
-
actualGlobal =
|
|
1585
|
+
} else if (typeof commonjsGlobal !== "undefined") {
|
|
1586
|
+
actualGlobal = commonjsGlobal;
|
|
1310
1587
|
} else if (typeof self !== "undefined") {
|
|
1311
1588
|
actualGlobal = self;
|
|
1312
1589
|
}
|
|
@@ -1376,6 +1653,35 @@
|
|
|
1376
1653
|
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
1377
1654
|
return value;
|
|
1378
1655
|
};
|
|
1656
|
+
const promise = function () {
|
|
1657
|
+
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1658
|
+
const PromiseImplementation = options.implementation || Promise;
|
|
1659
|
+
if (!PromiseImplementation) {
|
|
1660
|
+
throw new Error("`Promise` is not available in global scope, and no implementation was passed");
|
|
1661
|
+
}
|
|
1662
|
+
return {
|
|
1663
|
+
onReturn: (channels, context) => new PromiseImplementation((resolve, reject) => {
|
|
1664
|
+
const cancel = context.options.cancelToken;
|
|
1665
|
+
if (cancel) {
|
|
1666
|
+
cancel.promise.then(reason => {
|
|
1667
|
+
channels.abort.publish(reason);
|
|
1668
|
+
reject(reason);
|
|
1669
|
+
});
|
|
1670
|
+
}
|
|
1671
|
+
channels.error.subscribe(reject);
|
|
1672
|
+
channels.response.subscribe(response => {
|
|
1673
|
+
resolve(options.onlyBody ? response.body : response);
|
|
1674
|
+
});
|
|
1675
|
+
setTimeout(() => {
|
|
1676
|
+
try {
|
|
1677
|
+
channels.request.publish(context);
|
|
1678
|
+
} catch (err) {
|
|
1679
|
+
reject(err);
|
|
1680
|
+
}
|
|
1681
|
+
}, 0);
|
|
1682
|
+
})
|
|
1683
|
+
};
|
|
1684
|
+
};
|
|
1379
1685
|
class Cancel {
|
|
1380
1686
|
constructor(message) {
|
|
1381
1687
|
__publicField(this, "__CANCEL__", true);
|
|
@@ -1416,6 +1722,21 @@
|
|
|
1416
1722
|
cancel
|
|
1417
1723
|
};
|
|
1418
1724
|
});
|
|
1725
|
+
let CancelToken = _CancelToken;
|
|
1726
|
+
const isCancel = value => !!(value && (value == null ? void 0 : value.__CANCEL__));
|
|
1727
|
+
promise.Cancel = Cancel;
|
|
1728
|
+
promise.CancelToken = CancelToken;
|
|
1729
|
+
promise.isCancel = isCancel;
|
|
1730
|
+
function proxy(_proxy) {
|
|
1731
|
+
if (_proxy !== false && (!_proxy || !_proxy.host)) {
|
|
1732
|
+
throw new Error("Proxy middleware takes an object of host, port and auth properties");
|
|
1733
|
+
}
|
|
1734
|
+
return {
|
|
1735
|
+
processOptions: options => Object.assign({
|
|
1736
|
+
proxy: _proxy
|
|
1737
|
+
}, options)
|
|
1738
|
+
};
|
|
1739
|
+
}
|
|
1419
1740
|
var defaultShouldRetry = (err, attempt, options) => {
|
|
1420
1741
|
if (options.method !== "GET" && options.method !== "HEAD") {
|
|
1421
1742
|
return false;
|
|
@@ -1460,6 +1781,88 @@
|
|
|
1460
1781
|
});
|
|
1461
1782
|
};
|
|
1462
1783
|
retry.shouldRetry = defaultShouldRetry;
|
|
1784
|
+
function encode(data) {
|
|
1785
|
+
const query = new URLSearchParams();
|
|
1786
|
+
const nest = (name, _value) => {
|
|
1787
|
+
const value = _value instanceof Set ? Array.from(_value) : _value;
|
|
1788
|
+
if (Array.isArray(value)) {
|
|
1789
|
+
if (value.length) {
|
|
1790
|
+
for (const index in value) {
|
|
1791
|
+
nest("".concat(name, "[").concat(index, "]"), value[index]);
|
|
1792
|
+
}
|
|
1793
|
+
} else {
|
|
1794
|
+
query.append("".concat(name, "[]"), "");
|
|
1795
|
+
}
|
|
1796
|
+
} else if (typeof value === "object" && value !== null) {
|
|
1797
|
+
for (const [key, obj] of Object.entries(value)) {
|
|
1798
|
+
nest("".concat(name, "[").concat(key, "]"), obj);
|
|
1799
|
+
}
|
|
1800
|
+
} else {
|
|
1801
|
+
query.append(name, value);
|
|
1802
|
+
}
|
|
1803
|
+
};
|
|
1804
|
+
for (const [key, value] of Object.entries(data)) {
|
|
1805
|
+
nest(key, value);
|
|
1806
|
+
}
|
|
1807
|
+
return query.toString();
|
|
1808
|
+
}
|
|
1809
|
+
function urlEncoded() {
|
|
1810
|
+
return {
|
|
1811
|
+
processOptions: options => {
|
|
1812
|
+
const body = options.body;
|
|
1813
|
+
if (!body) {
|
|
1814
|
+
return options;
|
|
1815
|
+
}
|
|
1816
|
+
const isStream = typeof body.pipe === "function";
|
|
1817
|
+
const shouldSerialize = !isStream && !isBuffer(body) && isPlainObject$1.isPlainObject(body);
|
|
1818
|
+
if (!shouldSerialize) {
|
|
1819
|
+
return options;
|
|
1820
|
+
}
|
|
1821
|
+
return {
|
|
1822
|
+
...options,
|
|
1823
|
+
body: encode(options.body),
|
|
1824
|
+
headers: {
|
|
1825
|
+
...options.headers,
|
|
1826
|
+
"Content-Type": "application/x-www-form-urlencoded"
|
|
1827
|
+
}
|
|
1828
|
+
};
|
|
1829
|
+
}
|
|
1830
|
+
};
|
|
1831
|
+
}
|
|
1832
|
+
function buildKeepAlive(agent) {
|
|
1833
|
+
return function keepAlive() {
|
|
1834
|
+
let config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1835
|
+
const ms = config.ms || 1e3;
|
|
1836
|
+
const maxFree = config.maxFree || 256;
|
|
1837
|
+
const agentOptions = {
|
|
1838
|
+
keepAlive: true,
|
|
1839
|
+
keepAliveMsecs: ms,
|
|
1840
|
+
maxFreeSockets: maxFree
|
|
1841
|
+
};
|
|
1842
|
+
return agent(agentOptions);
|
|
1843
|
+
};
|
|
1844
|
+
}
|
|
1845
|
+
const keepAlive = buildKeepAlive(agent);
|
|
1846
|
+
middleware_browser.processOptions = defaultOptionsValidator.processOptions;
|
|
1847
|
+
middleware_browser.validateOptions = defaultOptionsValidator.validateOptions;
|
|
1848
|
+
middleware_browser.Cancel = Cancel;
|
|
1849
|
+
middleware_browser.CancelToken = CancelToken;
|
|
1850
|
+
middleware_browser.agent = agent;
|
|
1851
|
+
middleware_browser.base = base;
|
|
1852
|
+
middleware_browser.debug = debug;
|
|
1853
|
+
middleware_browser.headers = headers;
|
|
1854
|
+
middleware_browser.httpErrors = httpErrors;
|
|
1855
|
+
middleware_browser.injectResponse = injectResponse;
|
|
1856
|
+
var jsonRequest_1 = middleware_browser.jsonRequest = jsonRequest;
|
|
1857
|
+
var jsonResponse_1 = middleware_browser.jsonResponse = jsonResponse;
|
|
1858
|
+
middleware_browser.keepAlive = keepAlive;
|
|
1859
|
+
middleware_browser.mtls = mtls;
|
|
1860
|
+
var observable_1 = middleware_browser.observable = observable$1;
|
|
1861
|
+
var progress_1 = middleware_browser.progress = progress;
|
|
1862
|
+
middleware_browser.promise = promise;
|
|
1863
|
+
middleware_browser.proxy = proxy;
|
|
1864
|
+
var retry_1 = middleware_browser.retry = retry;
|
|
1865
|
+
middleware_browser.urlEncoded = urlEncoded;
|
|
1463
1866
|
|
|
1464
1867
|
/******************************************************************************
|
|
1465
1868
|
Copyright (c) Microsoft Corporation.
|
|
@@ -2238,13 +2641,13 @@
|
|
|
2238
2641
|
maxRetries = 5,
|
|
2239
2642
|
retryDelay
|
|
2240
2643
|
} = _ref;
|
|
2241
|
-
const request = getIt([maxRetries > 0 ?
|
|
2644
|
+
const request = getIt([maxRetries > 0 ? retry_1({
|
|
2242
2645
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2243
2646
|
retryDelay,
|
|
2244
2647
|
// This option is typed incorrectly in get-it.
|
|
2245
2648
|
maxRetries,
|
|
2246
2649
|
shouldRetry
|
|
2247
|
-
}) : {}, ...envMiddleware, printWarnings,
|
|
2650
|
+
}) : {}, ...envMiddleware, printWarnings, jsonRequest_1(), jsonResponse_1(), progress_1(), httpError, observable_1({
|
|
2248
2651
|
implementation: Observable
|
|
2249
2652
|
})]);
|
|
2250
2653
|
function httpRequest(options) {
|
|
@@ -2263,7 +2666,7 @@
|
|
|
2263
2666
|
const isQuery = uri.startsWith("/data/query");
|
|
2264
2667
|
const isRetriableResponse = err.response && (err.response.statusCode === 429 || err.response.statusCode === 502 || err.response.statusCode === 503);
|
|
2265
2668
|
if ((isSafe || isQuery) && isRetriableResponse) return true;
|
|
2266
|
-
return
|
|
2669
|
+
return retry_1.shouldRetry(err, attempt, options);
|
|
2267
2670
|
}
|
|
2268
2671
|
const BASE_URL = "https://www.sanity.io/help/";
|
|
2269
2672
|
function generateHelpUrl(slug) {
|
package/umd/sanityClient.min.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).SanityClient={})}(this,(function(e){"use strict";const t={timeout:"undefined"!=typeof navigator&&"ReactNative"===navigator.product?6e4:12e4},r=function(e){const r={...t,..."string"==typeof e?{url:e}:e},{searchParams:o}=new URL(r.url,"http://localhost");if(r.timeout=n(r.timeout),r.query)for(const[e,t]of Object.entries(r.query))if(void 0!==t)if(Array.isArray(t))for(const r of t)o.append(e,r);else o.append(e,t);const[s]=r.url.split("?"),i=o.toString();return i&&(r.url="".concat(s,"?").concat(i)),r.method=r.body&&!r.method?"POST":(r.method||"GET").toUpperCase(),r};function n(e){if(!1===e||0===e)return!1;if(e.connect||e.socket)return e;const r=Number(e);return isNaN(r)?n(t.timeout):{connect:r,socket:r}}const o=/^https?:\/\//i,s=function(e){if(!o.test(e.url))throw new Error('"'.concat(e.url,'" is not a valid URL'))};var i="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function a(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var c=function(e){return e.replace(/^\s+|\s+$/g,"")},u=a((function(e){if(!e)return{};for(var t,r={},n=c(e).split("\n"),o=0;o<n.length;o++){var s=n[o],i=s.indexOf(":"),a=c(s.slice(0,i)).toLowerCase(),u=c(s.slice(i+1));void 0===r[a]?r[a]=u:(t=r[a],"[object Array]"===Object.prototype.toString.call(t)?r[a].push(u):r[a]=[r[a],u])}return r}));const l=["request","response","progress","error","abort"],h=["processOptions","validateOptions","interceptRequest","finalizeOptions","onRequest","onResponse","onError","onReturn","onHeaders"];function d(e,t){const n=[],o=h.reduce(((e,t)=>(e[t]=e[t]||[],e)),{processOptions:[r],validateOptions:[s]});function i(e){const r=l.reduce(((e,t)=>(e[t]=function(){const e=Object.create(null);let t=0;return{publish:function(t){for(const r in e)e[r](t)},subscribe:function(r){const n=t++;return e[n]=r,function(){delete e[n]}}}}(),e)),{}),n=(e=>function(t,r){const n="onError"===t;let o=r;for(var s=arguments.length,i=new Array(s>2?s-2:0),a=2;a<s;a++)i[a-2]=arguments[a];for(let r=0;r<e[t].length&&(o=(0,e[t][r])(o,...i),!n||o);r++);return o})(o),s=n("processOptions",e);n("validateOptions",s);const i={options:s,channels:r,applyMiddleware:n};let a;const c=r.request.subscribe((e=>{a=t(e,((t,o)=>((e,t,o)=>{let s=e,i=t;if(!s)try{i=n("onResponse",t,o)}catch(e){i=null,s=e}s=s&&n("onError",s,o),s?r.error.publish(s):i&&r.response.publish(i)})(t,o,e)))}));r.abort.subscribe((()=>{c(),a&&a.abort()}));const u=n("onReturn",r,i);return u===r&&r.request.publish(i),u}return i.use=function(e){if(!e)throw new Error("Tried to add middleware that resolved to falsey value");if("function"==typeof e)throw new Error("Tried to add middleware that was a function. It probably expects you to pass options to it.");if(e.onReturn&&o.onReturn.length>0)throw new Error("Tried to add new middleware with `onReturn` handler, but another handler has already been registered for this event");return h.forEach((t=>{e[t]&&o[t].push(e[t])})),n.push(e),i},i.clone=()=>d(n,t),e.forEach(i.use),i}var p,f,y,g,v,m,w,b=Object.defineProperty,C=(e,t,r)=>(((e,t,r)=>{t in e?b(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r})(e,"symbol"!=typeof t?t+"":t,r),r),E=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},x=(e,t,r)=>(E(e,t,"read from private field"),r?r.call(e):t.get(e)),T=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},O=(e,t,r,n)=>(E(e,t,"write to private field"),n?n.call(e,r):t.set(e,r),r);class S{constructor(){C(this,"onabort"),C(this,"onerror"),C(this,"onreadystatechange"),C(this,"ontimeout"),C(this,"readyState",0),C(this,"response"),C(this,"responseText"),C(this,"responseType",""),C(this,"status"),C(this,"statusText"),C(this,"withCredentials"),T(this,p,void 0),T(this,f,void 0),T(this,y,void 0),T(this,g,{}),T(this,v,void 0),T(this,m,{}),T(this,w,void 0)}open(e,t,r){O(this,p,e),O(this,f,t),O(this,y,""),this.readyState=1,this.onreadystatechange(),O(this,v,void 0)}abort(){x(this,v)&&x(this,v).abort()}getAllResponseHeaders(){return x(this,y)}setRequestHeader(e,t){x(this,g)[e]=t}setInit(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];O(this,m,e),O(this,w,t)}send(e){const t="arraybuffer"!==this.responseType,r={...x(this,m),method:x(this,p),headers:x(this,g),body:e};"function"==typeof AbortController&&x(this,w)&&(O(this,v,new AbortController),"undefined"!=typeof EventTarget&&x(this,v).signal instanceof EventTarget&&(r.signal=x(this,v).signal)),"undefined"!=typeof document&&(r.credentials=this.withCredentials?"include":"omit"),fetch(x(this,f),r).then((e=>(e.headers.forEach(((e,t)=>{O(this,y,x(this,y)+"".concat(t,": ").concat(e,"\r\n"))})),this.status=e.status,this.statusText=e.statusText,this.readyState=3,t?e.text():e.arrayBuffer()))).then((e=>{"string"==typeof e?this.responseText=e:this.response=e,this.readyState=4,this.onreadystatechange()})).catch((e=>{var t;"AbortError"!==e.name?null==(t=this.onerror)||t.call(this,e):this.onabort()}))}}p=new WeakMap,f=new WeakMap,y=new WeakMap,g=new WeakMap,v=new WeakMap,m=new WeakMap,w=new WeakMap;const _="function"==typeof XMLHttpRequest?"xhr":"fetch",j="xhr"===_?XMLHttpRequest:S,A=(e,t)=>{var r;const n=e.options,o=e.applyMiddleware("finalizeOptions",n),s={},i=e.applyMiddleware("interceptRequest",void 0,{adapter:_,context:e});if(i){const e=setTimeout(t,0,null,i);return{abort:()=>clearTimeout(e)}}let a=new j;a instanceof S&&"object"==typeof o.fetch&&a.setInit(o.fetch,null==(r=o.useAbortSignal)||r);const c=o.headers,l=o.timeout;let h=!1,d=!1,p=!1;if(a.onerror=e=>{g(new Error("Request error while attempting to reach ".concat(o.url).concat(e.lengthComputable?"(".concat(e.loaded," of ").concat(e.total," bytes transferred)"):"")))},a.ontimeout=e=>{g(new Error("Request timeout while attempting to reach ".concat(o.url).concat(e.lengthComputable?"(".concat(e.loaded," of ").concat(e.total," bytes transferred)"):"")))},a.onabort=()=>{y(!0),h=!0},a.onreadystatechange=()=>{!function(){if(!l)return;y(),s.socket=setTimeout((()=>f("ESOCKETTIMEDOUT")),l.socket)}(),h||4!==a.readyState||0!==a.status&&function(){if(h||d||p)return;if(0===a.status)return void g(new Error("Unknown XHR error"));y(),d=!0,t(null,{body:a.response||(""===a.responseType||"text"===a.responseType?a.responseText:""),url:o.url,method:o.method,headers:u(a.getAllResponseHeaders()),statusCode:a.status,statusMessage:a.statusText})}()},a.open(o.method,o.url,!0),a.withCredentials=!!o.withCredentials,c&&a.setRequestHeader)for(const e in c)c.hasOwnProperty(e)&&a.setRequestHeader(e,c[e]);return o.rawBody&&(a.responseType="arraybuffer"),e.applyMiddleware("onRequest",{options:o,adapter:_,request:a,context:e}),a.send(o.body||null),l&&(s.connect=setTimeout((()=>f("ETIMEDOUT")),l.connect)),{abort:function(){h=!0,a&&a.abort()}};function f(t){p=!0,a.abort();const r=new Error("ESOCKETTIMEDOUT"===t?"Socket timed out on request to ".concat(o.url):"Connection timed out on request to ".concat(o.url));r.code=t,e.channels.error.publish(r)}function y(e){(e||h||a.readyState>=2&&s.connect)&&clearTimeout(s.connect),s.socket&&clearTimeout(s.socket)}function g(e){if(d)return;y(!0),d=!0,a=null;const r=e||new Error("Network error while attempting to reach ".concat(o.url));r.isNetworkError=!0,r.request=o,t(r)}};var k,R,M={exports:{}};function F(){if(R)return k;R=1;var e=1e3,t=60*e,r=60*t,n=24*r,o=7*n,s=365.25*n;function i(e,t,r,n){var o=t>=1.5*r;return Math.round(e/r)+" "+n+(o?"s":"")}return k=function(a,c){c=c||{};var u=typeof a;if("string"===u&&a.length>0)return function(i){if((i=String(i)).length>100)return;var a=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(i);if(!a)return;var c=parseFloat(a[1]);switch((a[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return c*s;case"weeks":case"week":case"w":return c*o;case"days":case"day":case"d":return c*n;case"hours":case"hour":case"hrs":case"hr":case"h":return c*r;case"minutes":case"minute":case"mins":case"min":case"m":return c*t;case"seconds":case"second":case"secs":case"sec":case"s":return c*e;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return c;default:return}}(a);if("number"===u&&isFinite(a))return c.long?function(o){var s=Math.abs(o);if(s>=n)return i(o,s,n,"day");if(s>=r)return i(o,s,r,"hour");if(s>=t)return i(o,s,t,"minute");if(s>=e)return i(o,s,e,"second");return o+" ms"}(a):function(o){var s=Math.abs(o);if(s>=n)return Math.round(o/n)+"d";if(s>=r)return Math.round(o/r)+"h";if(s>=t)return Math.round(o/t)+"m";if(s>=e)return Math.round(o/e)+"s";return o+"ms"}(a);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(a))}}var I=function(e){function t(e){let n,o,s,i=null;function a(...e){if(!a.enabled)return;const r=a,o=Number(new Date),s=o-(n||o);r.diff=s,r.prev=n,r.curr=o,n=o,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let i=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,((n,o)=>{if("%%"===n)return"%";i++;const s=t.formatters[o];if("function"==typeof s){const t=e[i];n=s.call(r,t),e.splice(i,1),i--}return n})),t.formatArgs.call(r,e);(r.log||t.log).apply(r,e)}return a.namespace=e,a.useColors=t.useColors(),a.color=t.selectColor(e),a.extend=r,a.destroy=t.destroy,Object.defineProperty(a,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==i?i:(o!==t.namespaces&&(o=t.namespaces,s=t.enabled(e)),s),set:e=>{i=e}}),"function"==typeof t.init&&t.init(a),a}function r(e,r){const n=t(this.namespace+(void 0===r?":":r)+e);return n.log=this.log,n}function n(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return t.debug=t,t.default=t,t.coerce=function(e){if(e instanceof Error)return e.stack||e.message;return e},t.disable=function(){const e=[...t.names.map(n),...t.skips.map(n).map((e=>"-"+e))].join(",");return t.enable(""),e},t.enable=function(e){let r;t.save(e),t.namespaces=e,t.names=[],t.skips=[];const n=("string"==typeof e?e:"").split(/[\s,]+/),o=n.length;for(r=0;r<o;r++)n[r]&&("-"===(e=n[r].replace(/\*/g,".*?"))[0]?t.skips.push(new RegExp("^"+e.slice(1)+"$")):t.names.push(new RegExp("^"+e+"$")))},t.enabled=function(e){if("*"===e[e.length-1])return!0;let r,n;for(r=0,n=t.skips.length;r<n;r++)if(t.skips[r].test(e))return!1;for(r=0,n=t.names.length;r<n;r++)if(t.names[r].test(e))return!0;return!1},t.humanize=F(),t.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(e).forEach((r=>{t[r]=e[r]})),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let r=0;for(let t=0;t<e.length;t++)r=(r<<5)-r+e.charCodeAt(t),r|=0;return t.colors[Math.abs(r)%t.colors.length]},t.enable(t.load()),t};
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).SanityClient={})}(this,(function(e){"use strict";const t={timeout:"undefined"!=typeof navigator&&"ReactNative"===navigator.product?6e4:12e4},r=function(e){const r={...t,..."string"==typeof e?{url:e}:e},{searchParams:o}=new URL(r.url,"http://localhost");if(r.timeout=n(r.timeout),r.query)for(const[e,t]of Object.entries(r.query))if(void 0!==t)if(Array.isArray(t))for(const r of t)o.append(e,r);else o.append(e,t);const[s]=r.url.split("?"),i=o.toString();return i&&(r.url="".concat(s,"?").concat(i)),r.method=r.body&&!r.method?"POST":(r.method||"GET").toUpperCase(),r};function n(e){if(!1===e||0===e)return!1;if(e.connect||e.socket)return e;const r=Number(e);return isNaN(r)?n(t.timeout):{connect:r,socket:r}}const o=/^https?:\/\//i,s=function(e){if(!o.test(e.url))throw new Error('"'.concat(e.url,'" is not a valid URL'))};var i="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function a(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var c=function(e){return e.replace(/^\s+|\s+$/g,"")},u=function(e){if(!e)return{};for(var t,r={},n=c(e).split("\n"),o=0;o<n.length;o++){var s=n[o],i=s.indexOf(":"),a=c(s.slice(0,i)).toLowerCase(),u=c(s.slice(i+1));void 0===r[a]?r[a]=u:(t=r[a],"[object Array]"===Object.prototype.toString.call(t)?r[a].push(u):r[a]=[r[a],u])}return r},l=a(u);const d=["request","response","progress","error","abort"],h=["processOptions","validateOptions","interceptRequest","finalizeOptions","onRequest","onResponse","onError","onReturn","onHeaders"];function p(e,t){const n=[],o=h.reduce(((e,t)=>(e[t]=e[t]||[],e)),{processOptions:[r],validateOptions:[s]});function i(e){const r=d.reduce(((e,t)=>(e[t]=function(){const e=Object.create(null);let t=0;return{publish:function(t){for(const r in e)e[r](t)},subscribe:function(r){const n=t++;return e[n]=r,function(){delete e[n]}}}}(),e)),{}),n=(e=>function(t,r){const n="onError"===t;let o=r;for(var s=arguments.length,i=new Array(s>2?s-2:0),a=2;a<s;a++)i[a-2]=arguments[a];for(let r=0;r<e[t].length&&(o=(0,e[t][r])(o,...i),!n||o);r++);return o})(o),s=n("processOptions",e);n("validateOptions",s);const i={options:s,channels:r,applyMiddleware:n};let a;const c=r.request.subscribe((e=>{a=t(e,((t,o)=>((e,t,o)=>{let s=e,i=t;if(!s)try{i=n("onResponse",t,o)}catch(e){i=null,s=e}s=s&&n("onError",s,o),s?r.error.publish(s):i&&r.response.publish(i)})(t,o,e)))}));r.abort.subscribe((()=>{c(),a&&a.abort()}));const u=n("onReturn",r,i);return u===r&&r.request.publish(i),u}return i.use=function(e){if(!e)throw new Error("Tried to add middleware that resolved to falsey value");if("function"==typeof e)throw new Error("Tried to add middleware that was a function. It probably expects you to pass options to it.");if(e.onReturn&&o.onReturn.length>0)throw new Error("Tried to add new middleware with `onReturn` handler, but another handler has already been registered for this event");return h.forEach((t=>{e[t]&&o[t].push(e[t])})),n.push(e),i},i.clone=()=>p(n,t),e.forEach(i.use),i}var f,y,g,m,v,b,w,C=Object.defineProperty,E=(e,t,r)=>(((e,t,r)=>{t in e?C(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r})(e,"symbol"!=typeof t?t+"":t,r),r),x=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},O=(e,t,r)=>(x(e,t,"read from private field"),r?r.call(e):t.get(e)),T=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},j=(e,t,r,n)=>(x(e,t,"write to private field"),n?n.call(e,r):t.set(e,r),r);class S{constructor(){E(this,"onabort"),E(this,"onerror"),E(this,"onreadystatechange"),E(this,"ontimeout"),E(this,"readyState",0),E(this,"response"),E(this,"responseText"),E(this,"responseType",""),E(this,"status"),E(this,"statusText"),E(this,"withCredentials"),T(this,f,void 0),T(this,y,void 0),T(this,g,void 0),T(this,m,{}),T(this,v,void 0),T(this,b,{}),T(this,w,void 0)}open(e,t,r){j(this,f,e),j(this,y,t),j(this,g,""),this.readyState=1,this.onreadystatechange(),j(this,v,void 0)}abort(){O(this,v)&&O(this,v).abort()}getAllResponseHeaders(){return O(this,g)}setRequestHeader(e,t){O(this,m)[e]=t}setInit(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];j(this,b,e),j(this,w,t)}send(e){const t="arraybuffer"!==this.responseType,r={...O(this,b),method:O(this,f),headers:O(this,m),body:e};"function"==typeof AbortController&&O(this,w)&&(j(this,v,new AbortController),"undefined"!=typeof EventTarget&&O(this,v).signal instanceof EventTarget&&(r.signal=O(this,v).signal)),"undefined"!=typeof document&&(r.credentials=this.withCredentials?"include":"omit"),fetch(O(this,y),r).then((e=>(e.headers.forEach(((e,t)=>{j(this,g,O(this,g)+"".concat(t,": ").concat(e,"\r\n"))})),this.status=e.status,this.statusText=e.statusText,this.readyState=3,t?e.text():e.arrayBuffer()))).then((e=>{"string"==typeof e?this.responseText=e:this.response=e,this.readyState=4,this.onreadystatechange()})).catch((e=>{var t;"AbortError"!==e.name?null==(t=this.onerror)||t.call(this,e):this.onabort()}))}}f=new WeakMap,y=new WeakMap,g=new WeakMap,m=new WeakMap,v=new WeakMap,b=new WeakMap,w=new WeakMap;const _="function"==typeof XMLHttpRequest?"xhr":"fetch",A="xhr"===_?XMLHttpRequest:S,R=(e,t)=>{var r;const n=e.options,o=e.applyMiddleware("finalizeOptions",n),s={},i=e.applyMiddleware("interceptRequest",void 0,{adapter:_,context:e});if(i){const e=setTimeout(t,0,null,i);return{abort:()=>clearTimeout(e)}}let a=new A;a instanceof S&&"object"==typeof o.fetch&&a.setInit(o.fetch,null==(r=o.useAbortSignal)||r);const c=o.headers,u=o.timeout;let d=!1,h=!1,p=!1;if(a.onerror=e=>{g(new Error("Request error while attempting to reach ".concat(o.url).concat(e.lengthComputable?"(".concat(e.loaded," of ").concat(e.total," bytes transferred)"):"")))},a.ontimeout=e=>{g(new Error("Request timeout while attempting to reach ".concat(o.url).concat(e.lengthComputable?"(".concat(e.loaded," of ").concat(e.total," bytes transferred)"):"")))},a.onabort=()=>{y(!0),d=!0},a.onreadystatechange=()=>{!function(){if(!u)return;y(),s.socket=setTimeout((()=>f("ESOCKETTIMEDOUT")),u.socket)}(),d||4!==a.readyState||0!==a.status&&function(){if(d||h||p)return;if(0===a.status)return void g(new Error("Unknown XHR error"));y(),h=!0,t(null,{body:a.response||(""===a.responseType||"text"===a.responseType?a.responseText:""),url:o.url,method:o.method,headers:l(a.getAllResponseHeaders()),statusCode:a.status,statusMessage:a.statusText})}()},a.open(o.method,o.url,!0),a.withCredentials=!!o.withCredentials,c&&a.setRequestHeader)for(const e in c)c.hasOwnProperty(e)&&a.setRequestHeader(e,c[e]);return o.rawBody&&(a.responseType="arraybuffer"),e.applyMiddleware("onRequest",{options:o,adapter:_,request:a,context:e}),a.send(o.body||null),u&&(s.connect=setTimeout((()=>f("ETIMEDOUT")),u.connect)),{abort:function(){d=!0,a&&a.abort()}};function f(t){p=!0,a.abort();const r=new Error("ESOCKETTIMEDOUT"===t?"Socket timed out on request to ".concat(o.url):"Connection timed out on request to ".concat(o.url));r.code=t,e.channels.error.publish(r)}function y(e){(e||d||a.readyState>=2&&s.connect)&&clearTimeout(s.connect),s.socket&&clearTimeout(s.socket)}function g(e){if(h)return;y(!0),h=!0,a=null;const r=e||new Error("Network error while attempting to reach ".concat(o.url));r.isNetworkError=!0,r.request=o,t(r)}};var k,P,M={},q={exports:{}};function I(){if(P)return k;P=1;var e=1e3,t=60*e,r=60*t,n=24*r,o=7*n,s=365.25*n;function i(e,t,r,n){var o=t>=1.5*r;return Math.round(e/r)+" "+n+(o?"s":"")}return k=function(a,c){c=c||{};var u=typeof a;if("string"===u&&a.length>0)return function(i){if((i=String(i)).length>100)return;var a=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(i);if(!a)return;var c=parseFloat(a[1]);switch((a[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return c*s;case"weeks":case"week":case"w":return c*o;case"days":case"day":case"d":return c*n;case"hours":case"hour":case"hrs":case"hr":case"h":return c*r;case"minutes":case"minute":case"mins":case"min":case"m":return c*t;case"seconds":case"second":case"secs":case"sec":case"s":return c*e;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return c;default:return}}(a);if("number"===u&&isFinite(a))return c.long?function(o){var s=Math.abs(o);if(s>=n)return i(o,s,n,"day");if(s>=r)return i(o,s,r,"hour");if(s>=t)return i(o,s,t,"minute");if(s>=e)return i(o,s,e,"second");return o+" ms"}(a):function(o){var s=Math.abs(o);if(s>=n)return Math.round(o/n)+"d";if(s>=r)return Math.round(o/r)+"h";if(s>=t)return Math.round(o/t)+"m";if(s>=e)return Math.round(o/e)+"s";return o+"ms"}(a);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(a))}}var F=function(e){function t(e){let n,o,s,i=null;function a(...e){if(!a.enabled)return;const r=a,o=Number(new Date),s=o-(n||o);r.diff=s,r.prev=n,r.curr=o,n=o,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let i=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,((n,o)=>{if("%%"===n)return"%";i++;const s=t.formatters[o];if("function"==typeof s){const t=e[i];n=s.call(r,t),e.splice(i,1),i--}return n})),t.formatArgs.call(r,e);(r.log||t.log).apply(r,e)}return a.namespace=e,a.useColors=t.useColors(),a.color=t.selectColor(e),a.extend=r,a.destroy=t.destroy,Object.defineProperty(a,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==i?i:(o!==t.namespaces&&(o=t.namespaces,s=t.enabled(e)),s),set:e=>{i=e}}),"function"==typeof t.init&&t.init(a),a}function r(e,r){const n=t(this.namespace+(void 0===r?":":r)+e);return n.log=this.log,n}function n(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return t.debug=t,t.default=t,t.coerce=function(e){if(e instanceof Error)return e.stack||e.message;return e},t.disable=function(){const e=[...t.names.map(n),...t.skips.map(n).map((e=>"-"+e))].join(",");return t.enable(""),e},t.enable=function(e){let r;t.save(e),t.namespaces=e,t.names=[],t.skips=[];const n=("string"==typeof e?e:"").split(/[\s,]+/),o=n.length;for(r=0;r<o;r++)n[r]&&("-"===(e=n[r].replace(/\*/g,".*?"))[0]?t.skips.push(new RegExp("^"+e.slice(1)+"$")):t.names.push(new RegExp("^"+e+"$")))},t.enabled=function(e){if("*"===e[e.length-1])return!0;let r,n;for(r=0,n=t.skips.length;r<n;r++)if(t.skips[r].test(e))return!1;for(r=0,n=t.names.length;r<n;r++)if(t.names[r].test(e))return!0;return!1},t.humanize=I(),t.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(e).forEach((r=>{t[r]=e[r]})),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let r=0;for(let t=0;t<e.length;t++)r=(r<<5)-r+e.charCodeAt(t),r|=0;return t.colors[Math.abs(r)%t.colors.length]},t.enable(t.load()),t};!function(e,t){t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const r="color: "+this.color;t.splice(1,0,r,"color: inherit");let n=0,o=0;t[0].replace(/%[a-zA-Z%]/g,(e=>{"%%"!==e&&(n++,"%c"===e&&(o=n))})),t.splice(o,0,r)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}},t.load=function(){let e;try{e=t.storage.getItem("debug")}catch(e){}!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG);return e},t.useColors=function(){if("undefined"!=typeof window&&window.process&&("renderer"===window.process.type||window.process.__nwjs))return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage=function(){try{return localStorage}catch(e){}}(),t.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=F(t);const{formatters:r}=e.exports;r.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}(q,q.exports);var D=q.exports,N={};const H={timeout:"undefined"!=typeof navigator&&"ReactNative"===navigator.product?6e4:12e4};function L(e){if(!1===e||0===e)return!1;if(e.connect||e.socket)return e;const t=Number(e);return isNaN(t)?L(H.timeout):{connect:t,socket:t}}const W=/^https?:\/\//i;N.processOptions=function(e){const t={...H,..."string"==typeof e?{url:e}:e},{searchParams:r}=new URL(t.url,"http://localhost");if(t.timeout=L(t.timeout),t.query)for(const[e,n]of Object.entries(t.query))if(void 0!==n)if(Array.isArray(n))for(const t of n)r.append(e,t);else r.append(e,n);const[n]=t.url.split("?"),o=r.toString();return o&&(t.url="".concat(n,"?").concat(o)),t.method=t.body&&!t.method?"POST":(t.method||"GET").toUpperCase(),t},N.validateOptions=function(e){if(!W.test(e.url))throw new Error('"'.concat(e.url,'" is not a valid URL'))};var z={};
|
|
2
2
|
/*!
|
|
3
3
|
* is-plain-object <https://github.com/jonschlinkert/is-plain-object>
|
|
4
4
|
*
|
|
5
5
|
* Copyright (c) 2014-2017, Jon Schlinkert.
|
|
6
6
|
* Released under the MIT License.
|
|
7
7
|
*/
|
|
8
|
-
function P(e){return"[object Object]"===Object.prototype.toString.call(e)}!function(e,t){t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const r="color: "+this.color;t.splice(1,0,r,"color: inherit");let n=0,o=0;t[0].replace(/%[a-zA-Z%]/g,(e=>{"%%"!==e&&(n++,"%c"===e&&(o=n))})),t.splice(o,0,r)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}},t.load=function(){let e;try{e=t.storage.getItem("debug")}catch(e){}!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG);return e},t.useColors=function(){if("undefined"!=typeof window&&window.process&&("renderer"===window.process.type||window.process.__nwjs))return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage=function(){try{return localStorage}catch(e){}}(),t.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=I(t);const{formatters:r}=e.exports;r.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}(M,M.exports);const D="undefined"==typeof Buffer?()=>!1:e=>Buffer.isBuffer(e),q=["boolean","string","number"];function N(){return{processOptions:e=>{const t=e.body;if(!t)return e;var r,n,o;return!("function"==typeof t.pipe)&&!D(t)&&(-1!==q.indexOf(typeof t)||Array.isArray(t)||!1!==P(r=t)&&(void 0===(n=r.constructor)||!1!==P(o=n.prototype)&&!1!==o.hasOwnProperty("isPrototypeOf")))?Object.assign({},e,{body:JSON.stringify(e.body),headers:Object.assign({},e.headers,{"Content-Type":"application/json"})}):e}}}function H(e){return{onResponse:r=>{const n=r.headers["content-type"]||"",o=e&&e.force||-1!==n.indexOf("application/json");return r.body&&n&&o?Object.assign({},r,{body:t(r.body)}):r},processOptions:e=>Object.assign({},e,{headers:Object.assign({Accept:"application/json"},e.headers)})};function t(e){try{return JSON.parse(e)}catch(e){throw e.message="Failed to parsed response body as JSON: ".concat(e.message),e}}}let W={};"undefined"!=typeof globalThis?W=globalThis:"undefined"!=typeof window?W=window:"undefined"!=typeof global?W=global:"undefined"!=typeof self&&(W=self);var z=W;function U(){const e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).implementation||z.Observable;if(!e)throw new Error("`Observable` is not available in global scope, and no implementation was passed");return{onReturn:(t,r)=>new e((e=>(t.error.subscribe((t=>e.error(t))),t.progress.subscribe((t=>e.next(Object.assign({type:"progress"},t)))),t.response.subscribe((t=>{e.next(Object.assign({type:"response"},t)),e.complete()})),t.request.publish(r),()=>t.abort.publish())))}}var L=Object.defineProperty,B=(e,t,r)=>(((e,t,r)=>{t in e?L(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r})(e,"symbol"!=typeof t?t+"":t,r),r);class ${constructor(e){B(this,"__CANCEL__",!0),B(this,"message"),this.message=e}toString(){return"Cancel".concat(this.message?": ".concat(this.message):"")}}const G=class{constructor(e){if(B(this,"promise"),B(this,"reason"),"function"!=typeof e)throw new TypeError("executor must be a function.");let t=null;this.promise=new Promise((e=>{t=e})),e((e=>{this.reason||(this.reason=new $(e),t(this.reason))}))}};B(G,"source",(()=>{let e;return{token:new G((t=>{e=t})),cancel:e}}));var V=(e,t,r)=>("GET"===r.method||"HEAD"===r.method)&&(e.isNetworkError||!1);function J(e){return 100*Math.pow(2,e)+100*Math.random()}const X=function(){return(e=>{const t=e.maxRetries||5,r=e.retryDelay||J,n=e.shouldRetry;return{onError:(e,o)=>{const s=o.options,i=s.maxRetries||t,a=s.shouldRetry||n,c=s.attemptNumber||0;if(null!==(u=s.body)&&"object"==typeof u&&"function"==typeof u.pipe)return e;var u;if(!a(e,c,s)||c>=i)return e;const l=Object.assign({},o,{options:Object.assign({},s,{attemptNumber:c+1})});return setTimeout((()=>o.channels.request.publish(l)),r(c)),null}}})({shouldRetry:V,...arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}})};X.shouldRetry=V;var Y=function(e,t){return Y=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},Y(e,t)};function K(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}Y(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}function Z(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function Q(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,s=r.call(e),i=[];try{for(;(void 0===t||t-- >0)&&!(n=s.next()).done;)i.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=s.return)&&r.call(s)}finally{if(o)throw o.error}}return i}function ee(e,t,r){if(r||2===arguments.length)for(var n,o=0,s=t.length;o<s;o++)!n&&o in t||(n||(n=Array.prototype.slice.call(t,0,o)),n[o]=t[o]);return e.concat(n||Array.prototype.slice.call(t))}function te(e){return"function"==typeof e}function re(e){var t=e((function(e){Error.call(e),e.stack=(new Error).stack}));return t.prototype=Object.create(Error.prototype),t.prototype.constructor=t,t}"function"==typeof SuppressedError&&SuppressedError;var ne=re((function(e){return function(t){e(this),this.message=t?t.length+" errors occurred during unsubscription:\n"+t.map((function(e,t){return t+1+") "+e.toString()})).join("\n "):"",this.name="UnsubscriptionError",this.errors=t}}));function oe(e,t){if(e){var r=e.indexOf(t);0<=r&&e.splice(r,1)}}var se=function(){function e(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}var t;return e.prototype.unsubscribe=function(){var e,t,r,n,o;if(!this.closed){this.closed=!0;var s=this._parentage;if(s)if(this._parentage=null,Array.isArray(s))try{for(var i=Z(s),a=i.next();!a.done;a=i.next()){a.value.remove(this)}}catch(t){e={error:t}}finally{try{a&&!a.done&&(t=i.return)&&t.call(i)}finally{if(e)throw e.error}}else s.remove(this);var c=this.initialTeardown;if(te(c))try{c()}catch(e){o=e instanceof ne?e.errors:[e]}var u=this._finalizers;if(u){this._finalizers=null;try{for(var l=Z(u),h=l.next();!h.done;h=l.next()){var d=h.value;try{ae(d)}catch(e){o=null!=o?o:[],e instanceof ne?o=ee(ee([],Q(o)),Q(e.errors)):o.push(e)}}}catch(e){r={error:e}}finally{try{h&&!h.done&&(n=l.return)&&n.call(l)}finally{if(r)throw r.error}}}if(o)throw new ne(o)}},e.prototype.add=function(t){var r;if(t&&t!==this)if(this.closed)ae(t);else{if(t instanceof e){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=null!==(r=this._finalizers)&&void 0!==r?r:[]).push(t)}},e.prototype._hasParent=function(e){var t=this._parentage;return t===e||Array.isArray(t)&&t.includes(e)},e.prototype._addParent=function(e){var t=this._parentage;this._parentage=Array.isArray(t)?(t.push(e),t):t?[t,e]:e},e.prototype._removeParent=function(e){var t=this._parentage;t===e?this._parentage=null:Array.isArray(t)&&oe(t,e)},e.prototype.remove=function(t){var r=this._finalizers;r&&oe(r,t),t instanceof e&&t._removeParent(this)},e.EMPTY=((t=new e).closed=!0,t),e}();function ie(e){return e instanceof se||e&&"closed"in e&&te(e.remove)&&te(e.add)&&te(e.unsubscribe)}function ae(e){te(e)?e():e.unsubscribe()}se.EMPTY;var ce={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},ue={setTimeout:function(e,t){for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];var o=ue.delegate;return(null==o?void 0:o.setTimeout)?o.setTimeout.apply(o,ee([e,t],Q(r))):setTimeout.apply(void 0,ee([e,t],Q(r)))},clearTimeout:function(e){var t=ue.delegate;return((null==t?void 0:t.clearTimeout)||clearTimeout)(e)},delegate:void 0};function le(){}var he=function(e){function t(t){var r=e.call(this)||this;return r.isStopped=!1,t?(r.destination=t,ie(t)&&t.add(r)):r.destination=ve,r}return K(t,e),t.create=function(e,t,r){return new ye(e,t,r)},t.prototype.next=function(e){this.isStopped||this._next(e)},t.prototype.error=function(e){this.isStopped||(this.isStopped=!0,this._error(e))},t.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,e.prototype.unsubscribe.call(this),this.destination=null)},t.prototype._next=function(e){this.destination.next(e)},t.prototype._error=function(e){try{this.destination.error(e)}finally{this.unsubscribe()}},t.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},t}(se),de=Function.prototype.bind;function pe(e,t){return de.call(e,t)}var fe=function(){function e(e){this.partialObserver=e}return e.prototype.next=function(e){var t=this.partialObserver;if(t.next)try{t.next(e)}catch(e){ge(e)}},e.prototype.error=function(e){var t=this.partialObserver;if(t.error)try{t.error(e)}catch(e){ge(e)}else ge(e)},e.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(e){ge(e)}},e}(),ye=function(e){function t(t,r,n){var o,s,i=e.call(this)||this;te(t)||!t?o={next:null!=t?t:void 0,error:null!=r?r:void 0,complete:null!=n?n:void 0}:i&&ce.useDeprecatedNextContext?((s=Object.create(t)).unsubscribe=function(){return i.unsubscribe()},o={next:t.next&&pe(t.next,s),error:t.error&&pe(t.error,s),complete:t.complete&&pe(t.complete,s)}):o=t;return i.destination=new fe(o),i}return K(t,e),t}(he);function ge(e){var t;t=e,ue.setTimeout((function(){throw t}))}var ve={closed:!0,next:le,error:function(e){throw e},complete:le},me="function"==typeof Symbol&&Symbol.observable||"@@observable";function we(e){return e}var be=function(){function e(e){e&&(this._subscribe=e)}return e.prototype.lift=function(t){var r=new e;return r.source=this,r.operator=t,r},e.prototype.subscribe=function(e,t,r){var n,o=this,s=(n=e)&&n instanceof he||function(e){return e&&te(e.next)&&te(e.error)&&te(e.complete)}(n)&&ie(n)?e:new ye(e,t,r);return function(){var e=o,t=e.operator,r=e.source;s.add(t?t.call(s,r):r?o._subscribe(s):o._trySubscribe(s))}(),s},e.prototype._trySubscribe=function(e){try{return this._subscribe(e)}catch(t){e.error(t)}},e.prototype.forEach=function(e,t){var r=this;return new(t=Ce(t))((function(t,n){var o=new ye({next:function(t){try{e(t)}catch(e){n(e),o.unsubscribe()}},error:n,complete:t});r.subscribe(o)}))},e.prototype._subscribe=function(e){var t;return null===(t=this.source)||void 0===t?void 0:t.subscribe(e)},e.prototype[me]=function(){return this},e.prototype.pipe=function(){for(var e,t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return(0===(e=t).length?we:1===e.length?e[0]:function(t){return e.reduce((function(e,t){return t(e)}),t)})(this)},e.prototype.toPromise=function(e){var t=this;return new(e=Ce(e))((function(e,r){var n;t.subscribe((function(e){return n=e}),(function(e){return r(e)}),(function(){return e(n)}))}))},e.create=function(t){return new e(t)},e}();function Ce(e){var t;return null!==(t=null!=e?e:ce.Promise)&&void 0!==t?t:Promise}function Ee(e){return function(t){if(function(e){return te(null==e?void 0:e.lift)}(t))return t.lift((function(t){try{return e(t,this)}catch(e){this.error(e)}}));throw new TypeError("Unable to lift unknown Observable type")}}function xe(e,t,r,n,o){return new Te(e,t,r,n,o)}var Te=function(e){function t(t,r,n,o,s,i){var a=e.call(this,t)||this;return a.onFinalize=s,a.shouldUnsubscribe=i,a._next=r?function(e){try{r(e)}catch(e){t.error(e)}}:e.prototype._next,a._error=o?function(e){try{o(e)}catch(e){t.error(e)}finally{this.unsubscribe()}}:e.prototype._error,a._complete=n?function(){try{n()}catch(e){t.error(e)}finally{this.unsubscribe()}}:e.prototype._complete,a}return K(t,e),t.prototype.unsubscribe=function(){var t;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var r=this.closed;e.prototype.unsubscribe.call(this),!r&&(null===(t=this.onFinalize)||void 0===t||t.call(this))}},t}(he),Oe=re((function(e){return function(){e(this),this.name="EmptyError",this.message="no elements in sequence"}}));function Se(e,t){var r="object"==typeof t;return new Promise((function(n,o){var s,i=!1;e.subscribe({next:function(e){s=e,i=!0},error:o,complete:function(){i?n(s):r?n(t.defaultValue):o(new Oe)}})}))}function _e(e,t){return Ee((function(r,n){var o=0;r.subscribe(xe(n,(function(r){n.next(e.call(t,r,o++))})))}))}function je(e,t){return Ee((function(r,n){var o=0;r.subscribe(xe(n,(function(r){return e.call(t,r,o++)&&n.next(r)})))}))}var Ae=[];class ke extends Error{constructor(e){const t=Me(e);super(t.message),this.statusCode=400,Object.assign(this,t)}}class Re extends Error{constructor(e){const t=Me(e);super(t.message),this.statusCode=500,Object.assign(this,t)}}function Me(e){const t=e.body,r={response:e,statusCode:e.statusCode,responseBody:Ie(t,e),message:"",details:void 0};if(t.error&&t.message)return r.message="".concat(t.error," - ").concat(t.message),r;if(function(e){return Fe(e)&&Fe(e.error)&&"mutationError"===e.error.type&&"string"==typeof e.error.description}(t)){const e=t.error.items||[],n=e.slice(0,5).map((e=>{var t;return null==(t=e.error)?void 0:t.description})).filter(Boolean);let o=n.length?":\n- ".concat(n.join("\n- ")):"";return e.length>5&&(o+="\n...and ".concat(e.length-5," more")),r.message="".concat(t.error.description).concat(o),r.details=t.error,r}return t.error&&t.error.description?(r.message=t.error.description,r.details=t.error,r):(r.message=t.error||t.message||function(e){const t=e.statusMessage?" ".concat(e.statusMessage):"";return"".concat(e.method,"-request to ").concat(e.url," resulted in HTTP ").concat(e.statusCode).concat(t)}(e),r)}function Fe(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function Ie(e,t){return-1!==(t.headers["content-type"]||"").toLowerCase().indexOf("application/json")?JSON.stringify(e,null,2):e}const Pe={onResponse:e=>{if(e.statusCode>=500)throw new Re(e);if(e.statusCode>=400)throw new ke(e);return e}},De={onResponse:e=>{const t=e.headers["x-sanity-warning"];return(Array.isArray(t)?t:[t]).filter(Boolean).forEach((e=>console.warn(e))),e}};function qe(e,t){let{maxRetries:r=5,retryDelay:n}=t;const o=function(){return d(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],arguments.length>1&&void 0!==arguments[1]?arguments[1]:A)}([r>0?X({retryDelay:n,maxRetries:r,shouldRetry:Ne}):{},...e,De,N(),H(),{onRequest:e=>{if("xhr"!==e.adapter)return;const t=e.request,r=e.context;function n(e){return t=>{const n=t.lengthComputable?t.loaded/t.total*100:-1;r.channels.progress.publish({stage:e,percent:n,total:t.total,loaded:t.loaded,lengthComputable:t.lengthComputable})}}"upload"in t&&"onprogress"in t.upload&&(t.upload.onprogress=n("upload")),"onprogress"in t&&(t.onprogress=n("download"))}},Pe,U({implementation:be})]);function s(e){return(arguments.length>1&&void 0!==arguments[1]?arguments[1]:o)({maxRedirects:0,...e})}return s.defaultRequester=o,s}function Ne(e,t,r){const n="GET"===r.method||"HEAD"===r.method,o=(r.uri||r.url).startsWith("/data/query"),s=e.response&&(429===e.response.statusCode||502===e.response.statusCode||503===e.response.statusCode);return!(!n&&!o||!s)||X.shouldRetry(e,t,r)}function He(e){return"https://www.sanity.io/help/"+e}const We=["image","file"],ze=["before","after","replace"],Ue=e=>{if(!/^(~[a-z0-9]{1}[-\w]{0,63}|[a-z0-9]{1}[-\w]{0,63})$/.test(e))throw new Error("Datasets can only contain lowercase characters, numbers, underscores and dashes, and start with tilde, and be maximum 64 characters")},Le=(e,t)=>{if(null===t||"object"!=typeof t||Array.isArray(t))throw new Error("".concat(e,"() takes an object of properties"))},Be=(e,t)=>{if("string"!=typeof t||!/^[a-z0-9_][a-z0-9_.-]{0,127}$/i.test(t)||t.includes(".."))throw new Error("".concat(e,'(): "').concat(t,'" is not a valid document ID'))},$e=(e,t)=>{if(!t._id)throw new Error("".concat(e,'() requires that the document contains an ID ("_id" property)'));Be(e,t._id)},Ge=e=>{if(!e.dataset)throw new Error("`dataset` must be provided to perform queries");return e.dataset||""},Ve=e=>{if("string"!=typeof e||!/^[a-z0-9._-]{1,75}$/i.test(e))throw new Error("Tag can only contain alphanumeric characters, underscores, dashes and dots, and be between one and 75 characters long.");return e};const Je=e=>function(e){let t,r=!1;return function(){return r||(t=e(...arguments),r=!0),t}}((function(){for(var t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];return console.warn(e.join(" "),...r)})),Xe=Je(["Since you haven't set a value for `useCdn`, we will deliver content using our","global, edge-cached API-CDN. If you wish to have content delivered faster, set","`useCdn: false` to use the Live API. Note: You may incur higher costs using the live API."]),Ye=Je(["The Sanity client is configured with the `perspective` set to `previewDrafts`, which doesn't support the API-CDN.","The Live API will be used instead. Set `useCdn: false` in your configuration to hide this warning."]),Ke=Je(["You have configured Sanity client to use a token in the browser. This may cause unintentional security issues.","See ".concat(He("js-client-browser-token")," for more information and how to hide this warning.")]),Ze=Je(["Using the Sanity client without specifying an API version is deprecated.","See ".concat(He("js-client-api-version"))]),Qe=Je(["The default export of @sanity/client has been deprecated. Use the named export `createClient` instead."]),et={apiHost:"https://api.sanity.io",apiVersion:"1",useProjectHostname:!0},tt=["localhost","127.0.0.1","0.0.0.0"],rt=function(e){switch(e){case"previewDrafts":case"published":case"raw":return;default:throw new TypeError("Invalid API perspective string, expected `published`, `previewDrafts` or `raw`")}},nt=(e,t)=>{const r=Object.assign({},t,e);r.apiVersion||Ze();const n=Object.assign({},et,r),o=n.useProjectHostname;if("undefined"==typeof Promise){const e=He("js-client-promise-polyfill");throw new Error("No native Promise-implementation found, polyfill needed - see ".concat(e))}if(o&&!n.projectId)throw new Error("Configuration must contain `projectId`");if("string"==typeof n.perspective&&rt(n.perspective),"encodeSourceMapAtPath"in n||"encodeSourceMap"in n||"studioUrl"in n||"logger"in n)throw new Error("It looks like you're using options meant for '@sanity/preview-kit/client', such as 'encodeSourceMapAtPath', 'encodeSourceMap', 'studioUrl' and 'logger'. Make sure you're using the right import.");const s="undefined"!=typeof window&&window.location&&window.location.hostname,i=s&&(e=>-1!==tt.indexOf(e))(window.location.hostname);s&&i&&n.token&&!0!==n.ignoreBrowserTokenWarning?Ke():void 0===n.useCdn&&Xe(),o&&(e=>{if(!/^[-a-z0-9]+$/i.test(e))throw new Error("`projectId` can only contain only a-z, 0-9 and dashes")})(n.projectId),n.dataset&&Ue(n.dataset),"requestTagPrefix"in n&&(n.requestTagPrefix=n.requestTagPrefix?Ve(n.requestTagPrefix).replace(/\.+$/,""):void 0),n.apiVersion="".concat(n.apiVersion).replace(/^v/,""),n.isDefaultApi=n.apiHost===et.apiHost,n.useCdn=!1!==n.useCdn&&!n.withCredentials,function(e){if("1"===e||"X"===e)return;const t=new Date(e);if(!(/^\d{4}-\d{2}-\d{2}$/.test(e)&&t instanceof Date&&t.getTime()>0))throw new Error("Invalid API version string, expected `1` or date in format `YYYY-MM-DD`")}(n.apiVersion);const a=n.apiHost.split("://",2),c=a[0],u=a[1],l=n.isDefaultApi?"apicdn.sanity.io":u;return n.useProjectHostname?(n.url="".concat(c,"://").concat(n.projectId,".").concat(u,"/v").concat(n.apiVersion),n.cdnUrl="".concat(c,"://").concat(n.projectId,".").concat(l,"/v").concat(n.apiVersion)):(n.url="".concat(n.apiHost,"/v").concat(n.apiVersion),n.cdnUrl=n.url),n},ot="X-Sanity-Project-ID";function st(e){if("string"==typeof e||Array.isArray(e))return{id:e};if("object"==typeof e&&null!==e&&"query"in e&&"string"==typeof e.query)return"params"in e&&"object"==typeof e.params&&null!==e.params?{query:e.query,params:e.params}:{query:e.query};const t=["* Document ID (<docId>)","* Array of document IDs","* Object containing `query`"].join("\n");throw new Error("Unknown selection - must be one of:\n\n".concat(t))}const it=e=>{let{query:t,params:r={},options:n={}}=e;const o=new URLSearchParams,{tag:s,...i}=n;s&&o.append("tag",s),o.append("query",t);for(const[e,t]of Object.entries(r))o.append("$".concat(e),JSON.stringify(t));for(const[e,t]of Object.entries(i))t&&o.append(e,"".concat(t));return"?".concat(o)};var at,ct,ut=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},lt=(e,t,r)=>(ut(e,t,"read from private field"),r?r.call(e):t.get(e)),ht=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},dt=(e,t,r,n)=>(ut(e,t,"write to private field"),n?n.call(e,r):t.set(e,r),r);class pt{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.selection=e,this.operations=t}set(e){return this._assign("set",e)}setIfMissing(e){return this._assign("setIfMissing",e)}diffMatchPatch(e){return Le("diffMatchPatch",e),this._assign("diffMatchPatch",e)}unset(e){if(!Array.isArray(e))throw new Error("unset(attrs) takes an array of attributes to unset, non-array given");return this.operations=Object.assign({},this.operations,{unset:e}),this}inc(e){return this._assign("inc",e)}dec(e){return this._assign("dec",e)}insert(e,t,r){return((e,t,r)=>{const n="insert(at, selector, items)";if(-1===ze.indexOf(e)){const e=ze.map((e=>'"'.concat(e,'"'))).join(", ");throw new Error("".concat(n,' takes an "at"-argument which is one of: ').concat(e))}if("string"!=typeof t)throw new Error("".concat(n,' takes a "selector"-argument which must be a string'));if(!Array.isArray(r))throw new Error("".concat(n,' takes an "items"-argument which must be an array'))})(e,t,r),this._assign("insert",{[e]:t,items:r})}append(e,t){return this.insert("after","".concat(e,"[-1]"),t)}prepend(e,t){return this.insert("before","".concat(e,"[0]"),t)}splice(e,t,r,n){const o=t<0?t-1:t,s=void 0===r||-1===r?-1:Math.max(0,t+r),i=o<0&&s>=0?"":s,a="".concat(e,"[").concat(o,":").concat(i,"]");return this.insert("replace",a,n||[])}ifRevisionId(e){return this.operations.ifRevisionID=e,this}serialize(){return{...st(this.selection),...this.operations}}toJSON(){return this.serialize()}reset(){return this.operations={},this}_assign(e,t){let r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];return Le(e,t),this.operations=Object.assign({},this.operations,{[e]:Object.assign({},r&&this.operations[e]||{},t)}),this}_set(e,t){return this._assign(e,t,!1)}}at=new WeakMap;let ft=class e extends pt{constructor(e,t,r){super(e,t),ht(this,at,void 0),dt(this,at,r)}clone(){return new e(this.selection,{...this.operations},lt(this,at))}commit(e){if(!lt(this,at))throw new Error("No `client` passed to patch, either provide one or pass the patch to a clients `mutate()` method");const t="string"==typeof this.selection,r=Object.assign({returnFirst:t,returnDocuments:!0},e);return lt(this,at).mutate({patch:this.serialize()},r)}};ct=new WeakMap;let yt=class e extends pt{constructor(e,t,r){super(e,t),ht(this,ct,void 0),dt(this,ct,r)}clone(){return new e(this.selection,{...this.operations},lt(this,ct))}commit(e){if(!lt(this,ct))throw new Error("No `client` passed to patch, either provide one or pass the patch to a clients `mutate()` method");const t="string"==typeof this.selection,r=Object.assign({returnFirst:t,returnDocuments:!0},e);return lt(this,ct).mutate({patch:this.serialize()},r)}};var gt,vt,mt=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},wt=(e,t,r)=>(mt(e,t,"read from private field"),r?r.call(e):t.get(e)),bt=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},Ct=(e,t,r,n)=>(mt(e,t,"write to private field"),n?n.call(e,r):t.set(e,r),r);const Et={returnDocuments:!1};class xt{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1?arguments[1]:void 0;this.operations=e,this.trxId=t}create(e){return Le("create",e),this._add({create:e})}createIfNotExists(e){const t="createIfNotExists";return Le(t,e),$e(t,e),this._add({[t]:e})}createOrReplace(e){const t="createOrReplace";return Le(t,e),$e(t,e),this._add({[t]:e})}delete(e){return Be("delete",e),this._add({delete:{id:e}})}transactionId(e){return e?(this.trxId=e,this):this.trxId}serialize(){return[...this.operations]}toJSON(){return this.serialize()}reset(){return this.operations=[],this}_add(e){return this.operations.push(e),this}}gt=new WeakMap;let Tt=class e extends xt{constructor(e,t,r){super(e,r),bt(this,gt,void 0),Ct(this,gt,t)}clone(){return new e([...this.operations],wt(this,gt),this.trxId)}commit(e){if(!wt(this,gt))throw new Error("No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method");return wt(this,gt).mutate(this.serialize(),Object.assign({transactionId:this.trxId},Et,e||{}))}patch(e,t){const r="function"==typeof t;if("string"!=typeof e&&e instanceof yt)return this._add({patch:e.serialize()});if(r){const r=t(new yt(e,{},wt(this,gt)));if(!(r instanceof yt))throw new Error("function passed to `patch()` must return the patch");return this._add({patch:r.serialize()})}return this._add({patch:{id:e,...t}})}};vt=new WeakMap;let Ot=class e extends xt{constructor(e,t,r){super(e,r),bt(this,vt,void 0),Ct(this,vt,t)}clone(){return new e([...this.operations],wt(this,vt),this.trxId)}commit(e){if(!wt(this,vt))throw new Error("No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method");return wt(this,vt).mutate(this.serialize(),Object.assign({transactionId:this.trxId},Et,e||{}))}patch(e,t){const r="function"==typeof t;if("string"!=typeof e&&e instanceof ft)return this._add({patch:e.serialize()});if(r){const r=t(new ft(e,{},wt(this,vt)));if(!(r instanceof ft))throw new Error("function passed to `patch()` must return the patch");return this._add({patch:r.serialize()})}return this._add({patch:{id:e,...t}})}};const St=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{dryRun:e.dryRun,returnIds:!0,returnDocuments:(t=e.returnDocuments,r=!0,!1===t?void 0:void 0===t?r:t),visibility:e.visibility||"sync",autoGenerateArrayKeys:e.autoGenerateArrayKeys,skipCrossDatasetReferenceValidation:e.skipCrossDatasetReferenceValidation};var t,r},_t=e=>"response"===e.type,jt=e=>e.body,At=11264;function kt(e,t,r,n){let o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};const s=!1===o.filterResponse?e=>e:e=>e.result,{cache:i,next:a,...c}={useAbortSignal:void 0!==o.signal,...o};return qt(e,t,"query",{query:r,params:n},void 0!==i||void 0!==a?{...c,fetch:{cache:i,next:a}}:c).pipe(_e(s))}function Rt(e,t,r){let n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return Ht(e,t,{uri:zt(e,"doc",r),json:!0,tag:n.tag}).pipe(je(_t),_e((e=>e.body.documents&&e.body.documents[0])))}function Mt(e,t,r){let n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return Ht(e,t,{uri:zt(e,"doc",r.join(",")),json:!0,tag:n.tag}).pipe(je(_t),_e((e=>{const t=(n=e.body.documents||[],o=e=>e._id,n.reduce(((e,t)=>(e[o(t)]=t,e)),Object.create(null)));var n,o;return r.map((e=>t[e]||null))})))}function Ft(e,t,r,n){return $e("createIfNotExists",r),Nt(e,t,r,"createIfNotExists",n)}function It(e,t,r,n){return $e("createOrReplace",r),Nt(e,t,r,"createOrReplace",n)}function Pt(e,t,r,n){return qt(e,t,"mutate",{mutations:[{delete:st(r)}]},n)}function Dt(e,t,r,n){let o;o=r instanceof yt||r instanceof ft?{patch:r.serialize()}:r instanceof Tt||r instanceof Ot?r.serialize():r;return qt(e,t,"mutate",{mutations:Array.isArray(o)?o:[o],transactionId:n&&n.transactionId||void 0},n)}function qt(e,t,r,n){let o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};const s="mutate"===r,i="query"===r,a=s?"":it(n),c=!s&&a.length<At,u=c?a:"",l=o.returnFirst,{timeout:h,token:d,tag:p,headers:f}=o;return Ht(e,t,{method:c?"GET":"POST",uri:zt(e,r,u),json:!0,body:c?void 0:n,query:s&&St(o),timeout:h,headers:f,token:d,tag:p,perspective:o.perspective,resultSourceMap:o.resultSourceMap,canUseCdn:i,signal:o.signal,fetch:o.fetch,useAbortSignal:o.useAbortSignal}).pipe(je(_t),_e(jt),_e((e=>{if(!s)return e;const t=e.results||[];if(o.returnDocuments)return l?t[0]&&t[0].document:t.map((e=>e.document));const r=l?"documentId":"documentIds",n=l?t[0]&&t[0].id:t.map((e=>e.id));return{transactionId:e.transactionId,results:t,[r]:n}})))}function Nt(e,t,r,n){let o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};return qt(e,t,"mutate",{mutations:[{[n]:r}]},Object.assign({returnFirst:!0,returnDocuments:!0},o))}function Ht(e,t,r){var n;const o=r.url||r.uri,s=e.config(),i=void 0===r.canUseCdn?["GET","HEAD"].indexOf(r.method||"GET")>=0&&0===o.indexOf("/data/"):r.canUseCdn;let a=s.useCdn&&i;const c=r.tag&&s.requestTagPrefix?[s.requestTagPrefix,r.tag].join("."):r.tag||s.requestTagPrefix;if(c&&null!==r.tag&&(r.query={tag:Ve(c),...r.query}),["GET","HEAD","POST"].indexOf(r.method||"GET")>=0&&0===o.indexOf("/data/query/")){(null!=(n=r.resultSourceMap)?n:s.resultSourceMap)&&(r.query={resultSourceMap:!0,...r.query});const e=r.perspective||s.perspective;"string"==typeof e&&"raw"!==e&&(rt(e),r.query={perspective:e,...r.query},"previewDrafts"===e&&a&&(a=!1,Ye()))}const u=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const r={},n=t.token||e.token;n&&(r.Authorization="Bearer ".concat(n)),t.useGlobalApi||e.useProjectHostname||!e.projectId||(r[ot]=e.projectId);const o=Boolean(void 0===t.withCredentials?e.token||e.withCredentials:t.withCredentials),s=void 0===t.timeout?e.timeout:t.timeout;return Object.assign({},t,{headers:Object.assign({},r,t.headers||{}),timeout:void 0===s?3e5:s,proxy:t.proxy||e.proxy,json:!0,withCredentials:o,fetch:"object"==typeof t.fetch&&"object"==typeof e.fetch?{...e.fetch,...t.fetch}:t.fetch||e.fetch})}(s,Object.assign({},r,{url:Ut(e,o,a)})),l=new be((e=>t(u,s.requester).subscribe(e)));return r.signal?l.pipe((h=r.signal,e=>new be((t=>{const r=()=>t.error(function(e){var t,r;if(Lt)return new DOMException(null!=(t=null==e?void 0:e.reason)?t:"The operation was aborted.","AbortError");const n=new Error(null!=(r=null==e?void 0:e.reason)?r:"The operation was aborted.");return n.name="AbortError",n}(h));if(h&&h.aborted)return void r();const n=e.subscribe(t);return h.addEventListener("abort",r),()=>{h.removeEventListener("abort",r),n.unsubscribe()}})))):l;var h}function Wt(e,t,r){return Ht(e,t,r).pipe(je((e=>"response"===e.type)),_e((e=>e.body)))}function zt(e,t,r){const n=e.config(),o=Ge(n),s="/".concat(t,"/").concat(o),i=r?"".concat(s,"/").concat(r):s;return"/data".concat(i).replace(/\/($|\?)/,"$1")}function Ut(e,t){let r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const{url:n,cdnUrl:o}=e.config();return"".concat(r?o:n,"/").concat(t.replace(/^\//,""))}const Lt=Boolean(globalThis.DOMException);var Bt,$t,Gt,Vt,Jt=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},Xt=(e,t,r)=>(Jt(e,t,"read from private field"),r?r.call(e):t.get(e)),Yt=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},Kt=(e,t,r,n)=>(Jt(e,t,"write to private field"),n?n.call(e,r):t.set(e,r),r);class Zt{constructor(e,t){Yt(this,Bt,void 0),Yt(this,$t,void 0),Kt(this,Bt,e),Kt(this,$t,t)}upload(e,t,r){return er(Xt(this,Bt),Xt(this,$t),e,t,r)}}Bt=new WeakMap,$t=new WeakMap;class Qt{constructor(e,t){Yt(this,Gt,void 0),Yt(this,Vt,void 0),Kt(this,Gt,e),Kt(this,Vt,t)}upload(e,t,r){return Se(er(Xt(this,Gt),Xt(this,Vt),e,t,r).pipe(je((e=>"response"===e.type)),_e((e=>e.body.document))))}}function er(e,t,r,n){let o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};(e=>{if(-1===We.indexOf(e))throw new Error("Invalid asset type: ".concat(e,". Must be one of ").concat(We.join(", ")))})(r);let s=o.extract||void 0;s&&!s.length&&(s=["none"]);const i=Ge(e.config()),a="image"===r?"images":"files",c=function(e,t){if("undefined"==typeof File||!(t instanceof File))return e;return Object.assign({filename:!1===e.preserveFilename?void 0:t.name,contentType:t.type},e)}(o,n),{tag:u,label:l,title:h,description:d,creditLine:p,filename:f,source:y}=c,g={label:l,title:h,description:d,filename:f,meta:s,creditLine:p};return y&&(g.sourceId=y.id,g.sourceName=y.name,g.sourceUrl=y.url),Ht(e,t,{tag:u,method:"POST",timeout:c.timeout||0,uri:"/assets/".concat(a,"/").concat(i),headers:c.contentType?{"Content-Type":c.contentType}:{},query:g,body:n})}Gt=new WeakMap,Vt=new WeakMap;var tr=(e,t)=>Object.keys(t).concat(Object.keys(e)).reduce(((r,n)=>(r[n]=void 0===e[n]?t[n]:e[n],r)),{});const rr=["includePreviousRevision","includeResult","visibility","effectFormat","tag"],nr={includeResult:!0};function or(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const{url:n,token:o,withCredentials:s,requestTagPrefix:i}=this.config(),a=r.tag&&i?[i,r.tag].join("."):r.tag,c={...tr(r,nr),tag:a},u=(l=c,rr.reduce(((e,t)=>(void 0===l[t]||(e[t]=l[t]),e)),{}));var l;const h=it({query:e,params:t,options:{tag:a,...u}}),d="".concat(n).concat(zt(this,"listen",h));if(d.length>14800)return new be((e=>e.error(new Error("Query too large for listener"))));const p=c.events?c.events:["mutation"],f=-1!==p.indexOf("reconnect"),y={};return(o||s)&&(y.withCredentials=!0),o&&(y.headers={Authorization:"Bearer ".concat(o)}),new be((e=>{let t,r;u().then((e=>{t=e})).catch((t=>{e.error(t),h()}));let n=!1;function o(){n||(f&&e.next({type:"reconnect"}),n||t.readyState===t.CLOSED&&(c(),clearTimeout(r),r=setTimeout(l,100)))}function s(t){e.error(function(e){if(e instanceof Error)return e;const t=sr(e);return t instanceof Error?t:new Error(function(e){if(!e.error)return e.message||"Unknown listener error";if(e.error.description)return e.error.description;return"string"==typeof e.error?e.error:JSON.stringify(e.error,null,2)}(t))}(t))}function i(t){const r=sr(t);return r instanceof Error?e.error(r):e.next(r)}function a(){n=!0,c(),e.complete()}function c(){t&&(t.removeEventListener("error",o),t.removeEventListener("channelError",s),t.removeEventListener("disconnect",a),p.forEach((e=>t.removeEventListener(e,i))),t.close())}async function u(){const{default:e}=await Promise.resolve().then((function(){return Kr})),t=new e(d,y);return t.addEventListener("error",o),t.addEventListener("channelError",s),t.addEventListener("disconnect",a),p.forEach((e=>t.addEventListener(e,i))),t}function l(){u().then((e=>{t=e})).catch((t=>{e.error(t),h()}))}function h(){n=!0,c()}return h}))}function sr(e){try{const t=e.data&&JSON.parse(e.data)||{};return Object.assign({type:e.type},t)}catch(e){return e}}var ir,ar,cr,ur,lr=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},hr=(e,t,r)=>(lr(e,t,"read from private field"),r?r.call(e):t.get(e)),dr=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},pr=(e,t,r,n)=>(lr(e,t,"write to private field"),n?n.call(e,r):t.set(e,r),r);class fr{constructor(e,t){dr(this,ir,void 0),dr(this,ar,void 0),pr(this,ir,e),pr(this,ar,t)}create(e,t){return gr(hr(this,ir),hr(this,ar),"PUT",e,t)}edit(e,t){return gr(hr(this,ir),hr(this,ar),"PATCH",e,t)}delete(e){return gr(hr(this,ir),hr(this,ar),"DELETE",e)}list(){return Wt(hr(this,ir),hr(this,ar),{uri:"/datasets",tag:null})}}ir=new WeakMap,ar=new WeakMap;class yr{constructor(e,t){dr(this,cr,void 0),dr(this,ur,void 0),pr(this,cr,e),pr(this,ur,t)}create(e,t){return Se(gr(hr(this,cr),hr(this,ur),"PUT",e,t))}edit(e,t){return Se(gr(hr(this,cr),hr(this,ur),"PATCH",e,t))}delete(e){return Se(gr(hr(this,cr),hr(this,ur),"DELETE",e))}list(){return Se(Wt(hr(this,cr),hr(this,ur),{uri:"/datasets",tag:null}))}}function gr(e,t,r,n,o){return Ue(n),Wt(e,t,{method:r,uri:"/datasets/".concat(n),body:o,tag:null})}cr=new WeakMap,ur=new WeakMap;var vr,mr,wr,br,Cr=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},Er=(e,t,r)=>(Cr(e,t,"read from private field"),r?r.call(e):t.get(e)),xr=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},Tr=(e,t,r,n)=>(Cr(e,t,"write to private field"),n?n.call(e,r):t.set(e,r),r);class Or{constructor(e,t){xr(this,vr,void 0),xr(this,mr,void 0),Tr(this,vr,e),Tr(this,mr,t)}list(e){const t=!1===(null==e?void 0:e.includeMembers)?"/projects?includeMembers=false":"/projects";return Wt(Er(this,vr),Er(this,mr),{uri:t})}getById(e){return Wt(Er(this,vr),Er(this,mr),{uri:"/projects/".concat(e)})}}vr=new WeakMap,mr=new WeakMap;class Sr{constructor(e,t){xr(this,wr,void 0),xr(this,br,void 0),Tr(this,wr,e),Tr(this,br,t)}list(e){const t=!1===(null==e?void 0:e.includeMembers)?"/projects?includeMembers=false":"/projects";return Se(Wt(Er(this,wr),Er(this,br),{uri:t}))}getById(e){return Se(Wt(Er(this,wr),Er(this,br),{uri:"/projects/".concat(e)}))}}wr=new WeakMap,br=new WeakMap;var _r,jr,Ar,kr,Rr=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},Mr=(e,t,r)=>(Rr(e,t,"read from private field"),r?r.call(e):t.get(e)),Fr=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},Ir=(e,t,r,n)=>(Rr(e,t,"write to private field"),n?n.call(e,r):t.set(e,r),r);class Pr{constructor(e,t){Fr(this,_r,void 0),Fr(this,jr,void 0),Ir(this,_r,e),Ir(this,jr,t)}getById(e){return Wt(Mr(this,_r),Mr(this,jr),{uri:"/users/".concat(e)})}}_r=new WeakMap,jr=new WeakMap;class Dr{constructor(e,t){Fr(this,Ar,void 0),Fr(this,kr,void 0),Ir(this,Ar,e),Ir(this,kr,t)}getById(e){return Se(Wt(Mr(this,Ar),Mr(this,kr),{uri:"/users/".concat(e)}))}}Ar=new WeakMap,kr=new WeakMap;var qr,Nr,Hr,Wr,zr=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},Ur=(e,t,r)=>(zr(e,t,"read from private field"),r?r.call(e):t.get(e)),Lr=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},Br=(e,t,r,n)=>(zr(e,t,"write to private field"),n?n.call(e,r):t.set(e,r),r);qr=new WeakMap,Nr=new WeakMap;let $r=class e{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:et;Lr(this,qr,void 0),Lr(this,Nr,void 0),this.listen=or,this.config(t),Br(this,Nr,e),this.assets=new Zt(this,Ur(this,Nr)),this.datasets=new fr(this,Ur(this,Nr)),this.projects=new Or(this,Ur(this,Nr)),this.users=new Pr(this,Ur(this,Nr))}clone(){return new e(Ur(this,Nr),this.config())}config(e){if(void 0===e)return{...Ur(this,qr)};if(Ur(this,qr)&&!1===Ur(this,qr).allowReconfigure)throw new Error("Existing client instance cannot be reconfigured - use `withConfig(newConfig)` to return a new client");return Br(this,qr,nt(e,Ur(this,qr)||{})),this}withConfig(t){return new e(Ur(this,Nr),{...this.config(),...t})}fetch(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return kt(this,Ur(this,Nr),e,t,r)}getDocument(e,t){return Rt(this,Ur(this,Nr),e,t)}getDocuments(e,t){return Mt(this,Ur(this,Nr),e,t)}create(e,t){return Nt(this,Ur(this,Nr),e,"create",t)}createIfNotExists(e,t){return Ft(this,Ur(this,Nr),e,t)}createOrReplace(e,t){return It(this,Ur(this,Nr),e,t)}delete(e,t){return Pt(this,Ur(this,Nr),e,t)}mutate(e,t){return Dt(this,Ur(this,Nr),e,t)}patch(e,t){return new ft(e,t,this)}transaction(e){return new Ot(e,this)}request(e){return Wt(this,Ur(this,Nr),e)}getUrl(e,t){return Ut(this,e,t)}getDataUrl(e,t){return zt(this,e,t)}};Hr=new WeakMap,Wr=new WeakMap;let Gr=class e{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:et;Lr(this,Hr,void 0),Lr(this,Wr,void 0),this.listen=or,this.config(t),Br(this,Wr,e),this.assets=new Qt(this,Ur(this,Wr)),this.datasets=new yr(this,Ur(this,Wr)),this.projects=new Sr(this,Ur(this,Wr)),this.users=new Dr(this,Ur(this,Wr)),this.observable=new $r(e,t)}clone(){return new e(Ur(this,Wr),this.config())}config(e){if(void 0===e)return{...Ur(this,Hr)};if(Ur(this,Hr)&&!1===Ur(this,Hr).allowReconfigure)throw new Error("Existing client instance cannot be reconfigured - use `withConfig(newConfig)` to return a new client");return this.observable&&this.observable.config(e),Br(this,Hr,nt(e,Ur(this,Hr)||{})),this}withConfig(t){return new e(Ur(this,Wr),{...this.config(),...t})}fetch(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return Se(kt(this,Ur(this,Wr),e,t,r))}getDocument(e,t){return Se(Rt(this,Ur(this,Wr),e,t))}getDocuments(e,t){return Se(Mt(this,Ur(this,Wr),e,t))}create(e,t){return Se(Nt(this,Ur(this,Wr),e,"create",t))}createIfNotExists(e,t){return Se(Ft(this,Ur(this,Wr),e,t))}createOrReplace(e,t){return Se(It(this,Ur(this,Wr),e,t))}delete(e,t){return Se(Pt(this,Ur(this,Wr),e,t))}mutate(e,t){return Se(Dt(this,Ur(this,Wr),e,t))}patch(e,t){return new yt(e,t,this)}transaction(e){return new Tt(e,this)}request(e){return Se(Wt(this,Ur(this,Wr),e))}dataRequest(e,t,r){return Se(qt(this,Ur(this,Wr),e,t,r))}getUrl(e,t){return Ut(this,e,t)}getDataUrl(e,t){return zt(this,e,t)}};const Vr=qe(Ae,{}),Jr=Vr.defaultRequester;var Xr={exports:{}};
|
|
8
|
+
function U(e){return"[object Object]"===Object.prototype.toString.call(e)}Object.defineProperty(z,"__esModule",{value:!0}),z.isPlainObject=function(e){var t,r;return!1!==U(e)&&(void 0===(t=e.constructor)||!1!==U(r=t.prototype)&&!1!==r.hasOwnProperty("isPrototypeOf"))},Object.defineProperty(M,"__esModule",{value:!0});var B=N,$=z;function G(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var J=G(D);function V(e){return{}}const X=/^\//,Y=/\/$/;const K=["cookie","authorization"],Z=Object.prototype.hasOwnProperty;var Q=Object.defineProperty,ee=(e,t,r)=>(((e,t,r)=>{t in e?Q(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r})(e,"symbol"!=typeof t?t+"":t,r),r);class te extends Error{constructor(e,t){super(),ee(this,"response"),ee(this,"request");const r=e.url.length>400?"".concat(e.url.slice(0,399),"…"):e.url;let n="".concat(e.method,"-request to ").concat(r," resulted in ");n+="HTTP ".concat(e.statusCode," ").concat(e.statusMessage),this.message=n.trim(),this.response=e,this.request=t.options}}const re="undefined"==typeof Buffer?()=>!1:e=>Buffer.isBuffer(e),ne=["boolean","string","number"];let oe={};"undefined"!=typeof globalThis?oe=globalThis:"undefined"!=typeof window?oe=window:void 0!==i?oe=i:"undefined"!=typeof self&&(oe=self);var se=oe;var ie=Object.defineProperty,ae=(e,t,r)=>(((e,t,r)=>{t in e?ie(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r})(e,"symbol"!=typeof t?t+"":t,r),r);const ce=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t=e.implementation||Promise;if(!t)throw new Error("`Promise` is not available in global scope, and no implementation was passed");return{onReturn:(r,n)=>new t(((t,o)=>{const s=n.options.cancelToken;s&&s.promise.then((e=>{r.abort.publish(e),o(e)})),r.error.subscribe(o),r.response.subscribe((r=>{t(e.onlyBody?r.body:r)})),setTimeout((()=>{try{r.request.publish(n)}catch(e){o(e)}}),0)}))}};class ue{constructor(e){ae(this,"__CANCEL__",!0),ae(this,"message"),this.message=e}toString(){return"Cancel".concat(this.message?": ".concat(this.message):"")}}const le=class{constructor(e){if(ae(this,"promise"),ae(this,"reason"),"function"!=typeof e)throw new TypeError("executor must be a function.");let t=null;this.promise=new Promise((e=>{t=e})),e((e=>{this.reason||(this.reason=new ue(e),t(this.reason))}))}};ae(le,"source",(()=>{let e;return{token:new le((t=>{e=t})),cancel:e}}));let de=le;ce.Cancel=ue,ce.CancelToken=de,ce.isCancel=e=>!(!e||!(null==e?void 0:e.__CANCEL__));var he=(e,t,r)=>("GET"===r.method||"HEAD"===r.method)&&(e.isNetworkError||!1);function pe(e){return 100*Math.pow(2,e)+100*Math.random()}const fe=function(){return(e=>{const t=e.maxRetries||5,r=e.retryDelay||pe,n=e.shouldRetry;return{onError:(e,o)=>{const s=o.options,i=s.maxRetries||t,a=s.shouldRetry||n,c=s.attemptNumber||0;if(null!==(u=s.body)&&"object"==typeof u&&"function"==typeof u.pipe)return e;var u;if(!a(e,c,s)||c>=i)return e;const l=Object.assign({},o,{options:Object.assign({},s,{attemptNumber:c+1})});return setTimeout((()=>o.channels.request.publish(l)),r(c)),null}}})({shouldRetry:he,...arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}})};function ye(e){const t=new URLSearchParams,r=(e,n)=>{const o=n instanceof Set?Array.from(n):n;if(Array.isArray(o))if(o.length)for(const t in o)r("".concat(e,"[").concat(t,"]"),o[t]);else t.append("".concat(e,"[]"),"");else if("object"==typeof o&&null!==o)for(const[t,n]of Object.entries(o))r("".concat(e,"[").concat(t,"]"),n);else t.append(e,o)};for(const[t,n]of Object.entries(e))r(t,n);return t.toString()}fe.shouldRetry=he;const ge=function(e){return function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const r=t.ms||1e3,n=t.maxFree||256;return e({keepAlive:!0,keepAliveMsecs:r,maxFreeSockets:n})}}(V);M.processOptions=B.processOptions,M.validateOptions=B.validateOptions,M.Cancel=ue,M.CancelToken=de,M.agent=V,M.base=function(e){const t=e.replace(Y,"");return{processOptions:e=>{if(/^https?:\/\//i.test(e.url))return e;const r=[t,e.url.replace(X,"")].join("/");return Object.assign({},e,{url:r})}}},M.debug=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t=e.verbose,r=e.namespace||"get-it",n=J.default(r),o=e.log||n,s=o===n&&!J.default.enabled(r);let i=0;return{processOptions:e=>(e.debug=o,e.requestId=e.requestId||++i,e),onRequest:r=>{if(s||!r)return r;const n=r.options;if(o("[%s] HTTP %s %s",n.requestId,n.method,n.url),t&&n.body&&"string"==typeof n.body&&o("[%s] Request body: %s",n.requestId,n.body),t&&n.headers){const t=!1===e.redactSensitiveHeaders?n.headers:((e,t)=>{const r={};for(const n in e)Z.call(e,n)&&(r[n]=t.indexOf(n.toLowerCase())>-1?"<redacted>":e[n]);return r})(n.headers,K);o("[%s] Request headers: %s",n.requestId,JSON.stringify(t,null,2))}return r},onResponse:(e,r)=>{if(s||!e)return e;const n=r.options.requestId;return o("[%s] Response code: %s %s",n,e.statusCode,e.statusMessage),t&&e.body&&o("[%s] Response body: %s",n,function(e){const t=(e.headers["content-type"]||"").toLowerCase();return-1!==t.indexOf("application/json")?function(e){try{const t="string"==typeof e?JSON.parse(e):e;return JSON.stringify(t,null,2)}catch(t){return e}}(e.body):e.body}(e)),e},onError:(e,t)=>{const r=t.options.requestId;return e?(o("[%s] ERROR: %s",r,e.message),e):(o("[%s] Error encountered, but handled by an earlier middleware",r),e)}}},M.headers=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return{processOptions:r=>{const n=r.headers||{};return r.headers=t.override?Object.assign({},n,e):Object.assign({},e,n),r}}},M.httpErrors=function(){return{onResponse:(e,t)=>{if(!(e.statusCode>=400))return e;throw new te(e,t)}}},M.injectResponse=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if("function"!=typeof e.inject)throw new Error("`injectResponse` middleware requires a `inject` function");return{interceptRequest:function(t,r){const n=e.inject(r,t);if(!n)return t;const o=r.context.options;return{body:"",url:o.url,method:o.method,headers:{},statusCode:200,statusMessage:"OK",...n}}}};var me=M.jsonRequest=function(){return{processOptions:e=>{const t=e.body;if(!t)return e;return!("function"==typeof t.pipe)&&!re(t)&&(-1!==ne.indexOf(typeof t)||Array.isArray(t)||$.isPlainObject(t))?Object.assign({},e,{body:JSON.stringify(e.body),headers:Object.assign({},e.headers,{"Content-Type":"application/json"})}):e}}},ve=M.jsonResponse=function(e){return{onResponse:r=>{const n=r.headers["content-type"]||"",o=e&&e.force||-1!==n.indexOf("application/json");return r.body&&n&&o?Object.assign({},r,{body:t(r.body)}):r},processOptions:e=>Object.assign({},e,{headers:Object.assign({Accept:"application/json"},e.headers)})};function t(e){try{return JSON.parse(e)}catch(e){throw e.message="Failed to parsed response body as JSON: ".concat(e.message),e}}};M.keepAlive=ge,M.mtls=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!e.ca)throw new Error('Required mtls option "ca" is missing');if(!e.cert)throw new Error('Required mtls option "cert" is missing');if(!e.key)throw new Error('Required mtls option "key" is missing');return{finalizeOptions:t=>{if(function(e){return"object"==typeof e&&null!==e&&!("protocol"in e)}(t))return t;const r={cert:e.cert,key:e.key,ca:e.ca};return Object.assign({},t,r)}}};var be=M.observable=function(){const e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).implementation||se.Observable;if(!e)throw new Error("`Observable` is not available in global scope, and no implementation was passed");return{onReturn:(t,r)=>new e((e=>(t.error.subscribe((t=>e.error(t))),t.progress.subscribe((t=>e.next(Object.assign({type:"progress"},t)))),t.response.subscribe((t=>{e.next(Object.assign({type:"response"},t)),e.complete()})),t.request.publish(r),()=>t.abort.publish())))}},we=M.progress=function(){return{onRequest:e=>{if("xhr"!==e.adapter)return;const t=e.request,r=e.context;function n(e){return t=>{const n=t.lengthComputable?t.loaded/t.total*100:-1;r.channels.progress.publish({stage:e,percent:n,total:t.total,loaded:t.loaded,lengthComputable:t.lengthComputable})}}"upload"in t&&"onprogress"in t.upload&&(t.upload.onprogress=n("upload")),"onprogress"in t&&(t.onprogress=n("download"))}}};M.promise=ce,M.proxy=function(e){if(!(!1===e||e&&e.host))throw new Error("Proxy middleware takes an object of host, port and auth properties");return{processOptions:t=>Object.assign({proxy:e},t)}};var Ce=M.retry=fe;M.urlEncoded=function(){return{processOptions:e=>{const t=e.body;if(!t)return e;return!("function"==typeof t.pipe)&&!re(t)&&$.isPlainObject(t)?{...e,body:ye(e.body),headers:{...e.headers,"Content-Type":"application/x-www-form-urlencoded"}}:e}}};var Ee=function(e,t){return Ee=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},Ee(e,t)};function xe(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}Ee(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}function Oe(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function Te(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,s=r.call(e),i=[];try{for(;(void 0===t||t-- >0)&&!(n=s.next()).done;)i.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=s.return)&&r.call(s)}finally{if(o)throw o.error}}return i}function je(e,t,r){if(r||2===arguments.length)for(var n,o=0,s=t.length;o<s;o++)!n&&o in t||(n||(n=Array.prototype.slice.call(t,0,o)),n[o]=t[o]);return e.concat(n||Array.prototype.slice.call(t))}function Se(e){return"function"==typeof e}function _e(e){var t=e((function(e){Error.call(e),e.stack=(new Error).stack}));return t.prototype=Object.create(Error.prototype),t.prototype.constructor=t,t}"function"==typeof SuppressedError&&SuppressedError;var Ae=_e((function(e){return function(t){e(this),this.message=t?t.length+" errors occurred during unsubscription:\n"+t.map((function(e,t){return t+1+") "+e.toString()})).join("\n "):"",this.name="UnsubscriptionError",this.errors=t}}));function Re(e,t){if(e){var r=e.indexOf(t);0<=r&&e.splice(r,1)}}var ke=function(){function e(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}var t;return e.prototype.unsubscribe=function(){var e,t,r,n,o;if(!this.closed){this.closed=!0;var s=this._parentage;if(s)if(this._parentage=null,Array.isArray(s))try{for(var i=Oe(s),a=i.next();!a.done;a=i.next()){a.value.remove(this)}}catch(t){e={error:t}}finally{try{a&&!a.done&&(t=i.return)&&t.call(i)}finally{if(e)throw e.error}}else s.remove(this);var c=this.initialTeardown;if(Se(c))try{c()}catch(e){o=e instanceof Ae?e.errors:[e]}var u=this._finalizers;if(u){this._finalizers=null;try{for(var l=Oe(u),d=l.next();!d.done;d=l.next()){var h=d.value;try{Me(h)}catch(e){o=null!=o?o:[],e instanceof Ae?o=je(je([],Te(o)),Te(e.errors)):o.push(e)}}}catch(e){r={error:e}}finally{try{d&&!d.done&&(n=l.return)&&n.call(l)}finally{if(r)throw r.error}}}if(o)throw new Ae(o)}},e.prototype.add=function(t){var r;if(t&&t!==this)if(this.closed)Me(t);else{if(t instanceof e){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=null!==(r=this._finalizers)&&void 0!==r?r:[]).push(t)}},e.prototype._hasParent=function(e){var t=this._parentage;return t===e||Array.isArray(t)&&t.includes(e)},e.prototype._addParent=function(e){var t=this._parentage;this._parentage=Array.isArray(t)?(t.push(e),t):t?[t,e]:e},e.prototype._removeParent=function(e){var t=this._parentage;t===e?this._parentage=null:Array.isArray(t)&&Re(t,e)},e.prototype.remove=function(t){var r=this._finalizers;r&&Re(r,t),t instanceof e&&t._removeParent(this)},e.EMPTY=((t=new e).closed=!0,t),e}();function Pe(e){return e instanceof ke||e&&"closed"in e&&Se(e.remove)&&Se(e.add)&&Se(e.unsubscribe)}function Me(e){Se(e)?e():e.unsubscribe()}ke.EMPTY;var qe={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},Ie={setTimeout:function(e,t){for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];var o=Ie.delegate;return(null==o?void 0:o.setTimeout)?o.setTimeout.apply(o,je([e,t],Te(r))):setTimeout.apply(void 0,je([e,t],Te(r)))},clearTimeout:function(e){var t=Ie.delegate;return((null==t?void 0:t.clearTimeout)||clearTimeout)(e)},delegate:void 0};function Fe(){}var De=function(e){function t(t){var r=e.call(this)||this;return r.isStopped=!1,t?(r.destination=t,Pe(t)&&t.add(r)):r.destination=Ue,r}return xe(t,e),t.create=function(e,t,r){return new We(e,t,r)},t.prototype.next=function(e){this.isStopped||this._next(e)},t.prototype.error=function(e){this.isStopped||(this.isStopped=!0,this._error(e))},t.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,e.prototype.unsubscribe.call(this),this.destination=null)},t.prototype._next=function(e){this.destination.next(e)},t.prototype._error=function(e){try{this.destination.error(e)}finally{this.unsubscribe()}},t.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},t}(ke),Ne=Function.prototype.bind;function He(e,t){return Ne.call(e,t)}var Le=function(){function e(e){this.partialObserver=e}return e.prototype.next=function(e){var t=this.partialObserver;if(t.next)try{t.next(e)}catch(e){ze(e)}},e.prototype.error=function(e){var t=this.partialObserver;if(t.error)try{t.error(e)}catch(e){ze(e)}else ze(e)},e.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(e){ze(e)}},e}(),We=function(e){function t(t,r,n){var o,s,i=e.call(this)||this;Se(t)||!t?o={next:null!=t?t:void 0,error:null!=r?r:void 0,complete:null!=n?n:void 0}:i&&qe.useDeprecatedNextContext?((s=Object.create(t)).unsubscribe=function(){return i.unsubscribe()},o={next:t.next&&He(t.next,s),error:t.error&&He(t.error,s),complete:t.complete&&He(t.complete,s)}):o=t;return i.destination=new Le(o),i}return xe(t,e),t}(De);function ze(e){var t;t=e,Ie.setTimeout((function(){throw t}))}var Ue={closed:!0,next:Fe,error:function(e){throw e},complete:Fe},Be="function"==typeof Symbol&&Symbol.observable||"@@observable";function $e(e){return e}var Ge=function(){function e(e){e&&(this._subscribe=e)}return e.prototype.lift=function(t){var r=new e;return r.source=this,r.operator=t,r},e.prototype.subscribe=function(e,t,r){var n,o=this,s=(n=e)&&n instanceof De||function(e){return e&&Se(e.next)&&Se(e.error)&&Se(e.complete)}(n)&&Pe(n)?e:new We(e,t,r);return function(){var e=o,t=e.operator,r=e.source;s.add(t?t.call(s,r):r?o._subscribe(s):o._trySubscribe(s))}(),s},e.prototype._trySubscribe=function(e){try{return this._subscribe(e)}catch(t){e.error(t)}},e.prototype.forEach=function(e,t){var r=this;return new(t=Je(t))((function(t,n){var o=new We({next:function(t){try{e(t)}catch(e){n(e),o.unsubscribe()}},error:n,complete:t});r.subscribe(o)}))},e.prototype._subscribe=function(e){var t;return null===(t=this.source)||void 0===t?void 0:t.subscribe(e)},e.prototype[Be]=function(){return this},e.prototype.pipe=function(){for(var e,t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return(0===(e=t).length?$e:1===e.length?e[0]:function(t){return e.reduce((function(e,t){return t(e)}),t)})(this)},e.prototype.toPromise=function(e){var t=this;return new(e=Je(e))((function(e,r){var n;t.subscribe((function(e){return n=e}),(function(e){return r(e)}),(function(){return e(n)}))}))},e.create=function(t){return new e(t)},e}();function Je(e){var t;return null!==(t=null!=e?e:qe.Promise)&&void 0!==t?t:Promise}function Ve(e){return function(t){if(function(e){return Se(null==e?void 0:e.lift)}(t))return t.lift((function(t){try{return e(t,this)}catch(e){this.error(e)}}));throw new TypeError("Unable to lift unknown Observable type")}}function Xe(e,t,r,n,o){return new Ye(e,t,r,n,o)}var Ye=function(e){function t(t,r,n,o,s,i){var a=e.call(this,t)||this;return a.onFinalize=s,a.shouldUnsubscribe=i,a._next=r?function(e){try{r(e)}catch(e){t.error(e)}}:e.prototype._next,a._error=o?function(e){try{o(e)}catch(e){t.error(e)}finally{this.unsubscribe()}}:e.prototype._error,a._complete=n?function(){try{n()}catch(e){t.error(e)}finally{this.unsubscribe()}}:e.prototype._complete,a}return xe(t,e),t.prototype.unsubscribe=function(){var t;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var r=this.closed;e.prototype.unsubscribe.call(this),!r&&(null===(t=this.onFinalize)||void 0===t||t.call(this))}},t}(De),Ke=_e((function(e){return function(){e(this),this.name="EmptyError",this.message="no elements in sequence"}}));function Ze(e,t){var r="object"==typeof t;return new Promise((function(n,o){var s,i=!1;e.subscribe({next:function(e){s=e,i=!0},error:o,complete:function(){i?n(s):r?n(t.defaultValue):o(new Ke)}})}))}function Qe(e,t){return Ve((function(r,n){var o=0;r.subscribe(Xe(n,(function(r){n.next(e.call(t,r,o++))})))}))}function et(e,t){return Ve((function(r,n){var o=0;r.subscribe(Xe(n,(function(r){return e.call(t,r,o++)&&n.next(r)})))}))}var tt=[];class rt extends Error{constructor(e){const t=ot(e);super(t.message),this.statusCode=400,Object.assign(this,t)}}class nt extends Error{constructor(e){const t=ot(e);super(t.message),this.statusCode=500,Object.assign(this,t)}}function ot(e){const t=e.body,r={response:e,statusCode:e.statusCode,responseBody:it(t,e),message:"",details:void 0};if(t.error&&t.message)return r.message="".concat(t.error," - ").concat(t.message),r;if(function(e){return st(e)&&st(e.error)&&"mutationError"===e.error.type&&"string"==typeof e.error.description}(t)){const e=t.error.items||[],n=e.slice(0,5).map((e=>{var t;return null==(t=e.error)?void 0:t.description})).filter(Boolean);let o=n.length?":\n- ".concat(n.join("\n- ")):"";return e.length>5&&(o+="\n...and ".concat(e.length-5," more")),r.message="".concat(t.error.description).concat(o),r.details=t.error,r}return t.error&&t.error.description?(r.message=t.error.description,r.details=t.error,r):(r.message=t.error||t.message||function(e){const t=e.statusMessage?" ".concat(e.statusMessage):"";return"".concat(e.method,"-request to ").concat(e.url," resulted in HTTP ").concat(e.statusCode).concat(t)}(e),r)}function st(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function it(e,t){return-1!==(t.headers["content-type"]||"").toLowerCase().indexOf("application/json")?JSON.stringify(e,null,2):e}const at={onResponse:e=>{if(e.statusCode>=500)throw new nt(e);if(e.statusCode>=400)throw new rt(e);return e}},ct={onResponse:e=>{const t=e.headers["x-sanity-warning"];return(Array.isArray(t)?t:[t]).filter(Boolean).forEach((e=>console.warn(e))),e}};function ut(e,t){let{maxRetries:r=5,retryDelay:n}=t;const o=function(){return p(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],arguments.length>1&&void 0!==arguments[1]?arguments[1]:R)}([r>0?Ce({retryDelay:n,maxRetries:r,shouldRetry:lt}):{},...e,ct,me(),ve(),we(),at,be({implementation:Ge})]);function s(e){return(arguments.length>1&&void 0!==arguments[1]?arguments[1]:o)({maxRedirects:0,...e})}return s.defaultRequester=o,s}function lt(e,t,r){const n="GET"===r.method||"HEAD"===r.method,o=(r.uri||r.url).startsWith("/data/query"),s=e.response&&(429===e.response.statusCode||502===e.response.statusCode||503===e.response.statusCode);return!(!n&&!o||!s)||Ce.shouldRetry(e,t,r)}function dt(e){return"https://www.sanity.io/help/"+e}const ht=["image","file"],pt=["before","after","replace"],ft=e=>{if(!/^(~[a-z0-9]{1}[-\w]{0,63}|[a-z0-9]{1}[-\w]{0,63})$/.test(e))throw new Error("Datasets can only contain lowercase characters, numbers, underscores and dashes, and start with tilde, and be maximum 64 characters")},yt=(e,t)=>{if(null===t||"object"!=typeof t||Array.isArray(t))throw new Error("".concat(e,"() takes an object of properties"))},gt=(e,t)=>{if("string"!=typeof t||!/^[a-z0-9_][a-z0-9_.-]{0,127}$/i.test(t)||t.includes(".."))throw new Error("".concat(e,'(): "').concat(t,'" is not a valid document ID'))},mt=(e,t)=>{if(!t._id)throw new Error("".concat(e,'() requires that the document contains an ID ("_id" property)'));gt(e,t._id)},vt=e=>{if(!e.dataset)throw new Error("`dataset` must be provided to perform queries");return e.dataset||""},bt=e=>{if("string"!=typeof e||!/^[a-z0-9._-]{1,75}$/i.test(e))throw new Error("Tag can only contain alphanumeric characters, underscores, dashes and dots, and be between one and 75 characters long.");return e};const wt=e=>function(e){let t,r=!1;return function(){return r||(t=e(...arguments),r=!0),t}}((function(){for(var t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];return console.warn(e.join(" "),...r)})),Ct=wt(["Since you haven't set a value for `useCdn`, we will deliver content using our","global, edge-cached API-CDN. If you wish to have content delivered faster, set","`useCdn: false` to use the Live API. Note: You may incur higher costs using the live API."]),Et=wt(["The Sanity client is configured with the `perspective` set to `previewDrafts`, which doesn't support the API-CDN.","The Live API will be used instead. Set `useCdn: false` in your configuration to hide this warning."]),xt=wt(["You have configured Sanity client to use a token in the browser. This may cause unintentional security issues.","See ".concat(dt("js-client-browser-token")," for more information and how to hide this warning.")]),Ot=wt(["Using the Sanity client without specifying an API version is deprecated.","See ".concat(dt("js-client-api-version"))]),Tt=wt(["The default export of @sanity/client has been deprecated. Use the named export `createClient` instead."]),jt={apiHost:"https://api.sanity.io",apiVersion:"1",useProjectHostname:!0},St=["localhost","127.0.0.1","0.0.0.0"],_t=function(e){switch(e){case"previewDrafts":case"published":case"raw":return;default:throw new TypeError("Invalid API perspective string, expected `published`, `previewDrafts` or `raw`")}},At=(e,t)=>{const r=Object.assign({},t,e);r.apiVersion||Ot();const n=Object.assign({},jt,r),o=n.useProjectHostname;if("undefined"==typeof Promise){const e=dt("js-client-promise-polyfill");throw new Error("No native Promise-implementation found, polyfill needed - see ".concat(e))}if(o&&!n.projectId)throw new Error("Configuration must contain `projectId`");if("string"==typeof n.perspective&&_t(n.perspective),"encodeSourceMapAtPath"in n||"encodeSourceMap"in n||"studioUrl"in n||"logger"in n)throw new Error("It looks like you're using options meant for '@sanity/preview-kit/client', such as 'encodeSourceMapAtPath', 'encodeSourceMap', 'studioUrl' and 'logger'. Make sure you're using the right import.");const s="undefined"!=typeof window&&window.location&&window.location.hostname,i=s&&(e=>-1!==St.indexOf(e))(window.location.hostname);s&&i&&n.token&&!0!==n.ignoreBrowserTokenWarning?xt():void 0===n.useCdn&&Ct(),o&&(e=>{if(!/^[-a-z0-9]+$/i.test(e))throw new Error("`projectId` can only contain only a-z, 0-9 and dashes")})(n.projectId),n.dataset&&ft(n.dataset),"requestTagPrefix"in n&&(n.requestTagPrefix=n.requestTagPrefix?bt(n.requestTagPrefix).replace(/\.+$/,""):void 0),n.apiVersion="".concat(n.apiVersion).replace(/^v/,""),n.isDefaultApi=n.apiHost===jt.apiHost,n.useCdn=!1!==n.useCdn&&!n.withCredentials,function(e){if("1"===e||"X"===e)return;const t=new Date(e);if(!(/^\d{4}-\d{2}-\d{2}$/.test(e)&&t instanceof Date&&t.getTime()>0))throw new Error("Invalid API version string, expected `1` or date in format `YYYY-MM-DD`")}(n.apiVersion);const a=n.apiHost.split("://",2),c=a[0],u=a[1],l=n.isDefaultApi?"apicdn.sanity.io":u;return n.useProjectHostname?(n.url="".concat(c,"://").concat(n.projectId,".").concat(u,"/v").concat(n.apiVersion),n.cdnUrl="".concat(c,"://").concat(n.projectId,".").concat(l,"/v").concat(n.apiVersion)):(n.url="".concat(n.apiHost,"/v").concat(n.apiVersion),n.cdnUrl=n.url),n},Rt="X-Sanity-Project-ID";function kt(e){if("string"==typeof e||Array.isArray(e))return{id:e};if("object"==typeof e&&null!==e&&"query"in e&&"string"==typeof e.query)return"params"in e&&"object"==typeof e.params&&null!==e.params?{query:e.query,params:e.params}:{query:e.query};const t=["* Document ID (<docId>)","* Array of document IDs","* Object containing `query`"].join("\n");throw new Error("Unknown selection - must be one of:\n\n".concat(t))}const Pt=e=>{let{query:t,params:r={},options:n={}}=e;const o=new URLSearchParams,{tag:s,...i}=n;s&&o.append("tag",s),o.append("query",t);for(const[e,t]of Object.entries(r))o.append("$".concat(e),JSON.stringify(t));for(const[e,t]of Object.entries(i))t&&o.append(e,"".concat(t));return"?".concat(o)};var Mt,qt,It=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},Ft=(e,t,r)=>(It(e,t,"read from private field"),r?r.call(e):t.get(e)),Dt=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},Nt=(e,t,r,n)=>(It(e,t,"write to private field"),n?n.call(e,r):t.set(e,r),r);class Ht{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.selection=e,this.operations=t}set(e){return this._assign("set",e)}setIfMissing(e){return this._assign("setIfMissing",e)}diffMatchPatch(e){return yt("diffMatchPatch",e),this._assign("diffMatchPatch",e)}unset(e){if(!Array.isArray(e))throw new Error("unset(attrs) takes an array of attributes to unset, non-array given");return this.operations=Object.assign({},this.operations,{unset:e}),this}inc(e){return this._assign("inc",e)}dec(e){return this._assign("dec",e)}insert(e,t,r){return((e,t,r)=>{const n="insert(at, selector, items)";if(-1===pt.indexOf(e)){const e=pt.map((e=>'"'.concat(e,'"'))).join(", ");throw new Error("".concat(n,' takes an "at"-argument which is one of: ').concat(e))}if("string"!=typeof t)throw new Error("".concat(n,' takes a "selector"-argument which must be a string'));if(!Array.isArray(r))throw new Error("".concat(n,' takes an "items"-argument which must be an array'))})(e,t,r),this._assign("insert",{[e]:t,items:r})}append(e,t){return this.insert("after","".concat(e,"[-1]"),t)}prepend(e,t){return this.insert("before","".concat(e,"[0]"),t)}splice(e,t,r,n){const o=t<0?t-1:t,s=void 0===r||-1===r?-1:Math.max(0,t+r),i=o<0&&s>=0?"":s,a="".concat(e,"[").concat(o,":").concat(i,"]");return this.insert("replace",a,n||[])}ifRevisionId(e){return this.operations.ifRevisionID=e,this}serialize(){return{...kt(this.selection),...this.operations}}toJSON(){return this.serialize()}reset(){return this.operations={},this}_assign(e,t){let r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];return yt(e,t),this.operations=Object.assign({},this.operations,{[e]:Object.assign({},r&&this.operations[e]||{},t)}),this}_set(e,t){return this._assign(e,t,!1)}}Mt=new WeakMap;let Lt=class e extends Ht{constructor(e,t,r){super(e,t),Dt(this,Mt,void 0),Nt(this,Mt,r)}clone(){return new e(this.selection,{...this.operations},Ft(this,Mt))}commit(e){if(!Ft(this,Mt))throw new Error("No `client` passed to patch, either provide one or pass the patch to a clients `mutate()` method");const t="string"==typeof this.selection,r=Object.assign({returnFirst:t,returnDocuments:!0},e);return Ft(this,Mt).mutate({patch:this.serialize()},r)}};qt=new WeakMap;let Wt=class e extends Ht{constructor(e,t,r){super(e,t),Dt(this,qt,void 0),Nt(this,qt,r)}clone(){return new e(this.selection,{...this.operations},Ft(this,qt))}commit(e){if(!Ft(this,qt))throw new Error("No `client` passed to patch, either provide one or pass the patch to a clients `mutate()` method");const t="string"==typeof this.selection,r=Object.assign({returnFirst:t,returnDocuments:!0},e);return Ft(this,qt).mutate({patch:this.serialize()},r)}};var zt,Ut,Bt=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},$t=(e,t,r)=>(Bt(e,t,"read from private field"),r?r.call(e):t.get(e)),Gt=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},Jt=(e,t,r,n)=>(Bt(e,t,"write to private field"),n?n.call(e,r):t.set(e,r),r);const Vt={returnDocuments:!1};class Xt{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1?arguments[1]:void 0;this.operations=e,this.trxId=t}create(e){return yt("create",e),this._add({create:e})}createIfNotExists(e){const t="createIfNotExists";return yt(t,e),mt(t,e),this._add({[t]:e})}createOrReplace(e){const t="createOrReplace";return yt(t,e),mt(t,e),this._add({[t]:e})}delete(e){return gt("delete",e),this._add({delete:{id:e}})}transactionId(e){return e?(this.trxId=e,this):this.trxId}serialize(){return[...this.operations]}toJSON(){return this.serialize()}reset(){return this.operations=[],this}_add(e){return this.operations.push(e),this}}zt=new WeakMap;let Yt=class e extends Xt{constructor(e,t,r){super(e,r),Gt(this,zt,void 0),Jt(this,zt,t)}clone(){return new e([...this.operations],$t(this,zt),this.trxId)}commit(e){if(!$t(this,zt))throw new Error("No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method");return $t(this,zt).mutate(this.serialize(),Object.assign({transactionId:this.trxId},Vt,e||{}))}patch(e,t){const r="function"==typeof t;if("string"!=typeof e&&e instanceof Wt)return this._add({patch:e.serialize()});if(r){const r=t(new Wt(e,{},$t(this,zt)));if(!(r instanceof Wt))throw new Error("function passed to `patch()` must return the patch");return this._add({patch:r.serialize()})}return this._add({patch:{id:e,...t}})}};Ut=new WeakMap;let Kt=class e extends Xt{constructor(e,t,r){super(e,r),Gt(this,Ut,void 0),Jt(this,Ut,t)}clone(){return new e([...this.operations],$t(this,Ut),this.trxId)}commit(e){if(!$t(this,Ut))throw new Error("No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method");return $t(this,Ut).mutate(this.serialize(),Object.assign({transactionId:this.trxId},Vt,e||{}))}patch(e,t){const r="function"==typeof t;if("string"!=typeof e&&e instanceof Lt)return this._add({patch:e.serialize()});if(r){const r=t(new Lt(e,{},$t(this,Ut)));if(!(r instanceof Lt))throw new Error("function passed to `patch()` must return the patch");return this._add({patch:r.serialize()})}return this._add({patch:{id:e,...t}})}};const Zt=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{dryRun:e.dryRun,returnIds:!0,returnDocuments:(t=e.returnDocuments,r=!0,!1===t?void 0:void 0===t?r:t),visibility:e.visibility||"sync",autoGenerateArrayKeys:e.autoGenerateArrayKeys,skipCrossDatasetReferenceValidation:e.skipCrossDatasetReferenceValidation};var t,r},Qt=e=>"response"===e.type,er=e=>e.body,tr=11264;function rr(e,t,r,n){let o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};const s=!1===o.filterResponse?e=>e:e=>e.result,{cache:i,next:a,...c}={useAbortSignal:void 0!==o.signal,...o};return ur(e,t,"query",{query:r,params:n},void 0!==i||void 0!==a?{...c,fetch:{cache:i,next:a}}:c).pipe(Qe(s))}function nr(e,t,r){let n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return dr(e,t,{uri:pr(e,"doc",r),json:!0,tag:n.tag}).pipe(et(Qt),Qe((e=>e.body.documents&&e.body.documents[0])))}function or(e,t,r){let n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return dr(e,t,{uri:pr(e,"doc",r.join(",")),json:!0,tag:n.tag}).pipe(et(Qt),Qe((e=>{const t=(n=e.body.documents||[],o=e=>e._id,n.reduce(((e,t)=>(e[o(t)]=t,e)),Object.create(null)));var n,o;return r.map((e=>t[e]||null))})))}function sr(e,t,r,n){return mt("createIfNotExists",r),lr(e,t,r,"createIfNotExists",n)}function ir(e,t,r,n){return mt("createOrReplace",r),lr(e,t,r,"createOrReplace",n)}function ar(e,t,r,n){return ur(e,t,"mutate",{mutations:[{delete:kt(r)}]},n)}function cr(e,t,r,n){let o;o=r instanceof Wt||r instanceof Lt?{patch:r.serialize()}:r instanceof Yt||r instanceof Kt?r.serialize():r;return ur(e,t,"mutate",{mutations:Array.isArray(o)?o:[o],transactionId:n&&n.transactionId||void 0},n)}function ur(e,t,r,n){let o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};const s="mutate"===r,i="query"===r,a=s?"":Pt(n),c=!s&&a.length<tr,u=c?a:"",l=o.returnFirst,{timeout:d,token:h,tag:p,headers:f}=o;return dr(e,t,{method:c?"GET":"POST",uri:pr(e,r,u),json:!0,body:c?void 0:n,query:s&&Zt(o),timeout:d,headers:f,token:h,tag:p,perspective:o.perspective,resultSourceMap:o.resultSourceMap,canUseCdn:i,signal:o.signal,fetch:o.fetch,useAbortSignal:o.useAbortSignal}).pipe(et(Qt),Qe(er),Qe((e=>{if(!s)return e;const t=e.results||[];if(o.returnDocuments)return l?t[0]&&t[0].document:t.map((e=>e.document));const r=l?"documentId":"documentIds",n=l?t[0]&&t[0].id:t.map((e=>e.id));return{transactionId:e.transactionId,results:t,[r]:n}})))}function lr(e,t,r,n){let o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};return ur(e,t,"mutate",{mutations:[{[n]:r}]},Object.assign({returnFirst:!0,returnDocuments:!0},o))}function dr(e,t,r){var n;const o=r.url||r.uri,s=e.config(),i=void 0===r.canUseCdn?["GET","HEAD"].indexOf(r.method||"GET")>=0&&0===o.indexOf("/data/"):r.canUseCdn;let a=s.useCdn&&i;const c=r.tag&&s.requestTagPrefix?[s.requestTagPrefix,r.tag].join("."):r.tag||s.requestTagPrefix;if(c&&null!==r.tag&&(r.query={tag:bt(c),...r.query}),["GET","HEAD","POST"].indexOf(r.method||"GET")>=0&&0===o.indexOf("/data/query/")){(null!=(n=r.resultSourceMap)?n:s.resultSourceMap)&&(r.query={resultSourceMap:!0,...r.query});const e=r.perspective||s.perspective;"string"==typeof e&&"raw"!==e&&(_t(e),r.query={perspective:e,...r.query},"previewDrafts"===e&&a&&(a=!1,Et()))}const u=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const r={},n=t.token||e.token;n&&(r.Authorization="Bearer ".concat(n)),t.useGlobalApi||e.useProjectHostname||!e.projectId||(r[Rt]=e.projectId);const o=Boolean(void 0===t.withCredentials?e.token||e.withCredentials:t.withCredentials),s=void 0===t.timeout?e.timeout:t.timeout;return Object.assign({},t,{headers:Object.assign({},r,t.headers||{}),timeout:void 0===s?3e5:s,proxy:t.proxy||e.proxy,json:!0,withCredentials:o,fetch:"object"==typeof t.fetch&&"object"==typeof e.fetch?{...e.fetch,...t.fetch}:t.fetch||e.fetch})}(s,Object.assign({},r,{url:fr(e,o,a)})),l=new Ge((e=>t(u,s.requester).subscribe(e)));return r.signal?l.pipe((d=r.signal,e=>new Ge((t=>{const r=()=>t.error(function(e){var t,r;if(yr)return new DOMException(null!=(t=null==e?void 0:e.reason)?t:"The operation was aborted.","AbortError");const n=new Error(null!=(r=null==e?void 0:e.reason)?r:"The operation was aborted.");return n.name="AbortError",n}(d));if(d&&d.aborted)return void r();const n=e.subscribe(t);return d.addEventListener("abort",r),()=>{d.removeEventListener("abort",r),n.unsubscribe()}})))):l;var d}function hr(e,t,r){return dr(e,t,r).pipe(et((e=>"response"===e.type)),Qe((e=>e.body)))}function pr(e,t,r){const n=e.config(),o=vt(n),s="/".concat(t,"/").concat(o),i=r?"".concat(s,"/").concat(r):s;return"/data".concat(i).replace(/\/($|\?)/,"$1")}function fr(e,t){let r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const{url:n,cdnUrl:o}=e.config();return"".concat(r?o:n,"/").concat(t.replace(/^\//,""))}const yr=Boolean(globalThis.DOMException);var gr,mr,vr,br,wr=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},Cr=(e,t,r)=>(wr(e,t,"read from private field"),r?r.call(e):t.get(e)),Er=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},xr=(e,t,r,n)=>(wr(e,t,"write to private field"),n?n.call(e,r):t.set(e,r),r);class Or{constructor(e,t){Er(this,gr,void 0),Er(this,mr,void 0),xr(this,gr,e),xr(this,mr,t)}upload(e,t,r){return jr(Cr(this,gr),Cr(this,mr),e,t,r)}}gr=new WeakMap,mr=new WeakMap;class Tr{constructor(e,t){Er(this,vr,void 0),Er(this,br,void 0),xr(this,vr,e),xr(this,br,t)}upload(e,t,r){return Ze(jr(Cr(this,vr),Cr(this,br),e,t,r).pipe(et((e=>"response"===e.type)),Qe((e=>e.body.document))))}}function jr(e,t,r,n){let o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};(e=>{if(-1===ht.indexOf(e))throw new Error("Invalid asset type: ".concat(e,". Must be one of ").concat(ht.join(", ")))})(r);let s=o.extract||void 0;s&&!s.length&&(s=["none"]);const i=vt(e.config()),a="image"===r?"images":"files",c=function(e,t){if("undefined"==typeof File||!(t instanceof File))return e;return Object.assign({filename:!1===e.preserveFilename?void 0:t.name,contentType:t.type},e)}(o,n),{tag:u,label:l,title:d,description:h,creditLine:p,filename:f,source:y}=c,g={label:l,title:d,description:h,filename:f,meta:s,creditLine:p};return y&&(g.sourceId=y.id,g.sourceName=y.name,g.sourceUrl=y.url),dr(e,t,{tag:u,method:"POST",timeout:c.timeout||0,uri:"/assets/".concat(a,"/").concat(i),headers:c.contentType?{"Content-Type":c.contentType}:{},query:g,body:n})}vr=new WeakMap,br=new WeakMap;var Sr=(e,t)=>Object.keys(t).concat(Object.keys(e)).reduce(((r,n)=>(r[n]=void 0===e[n]?t[n]:e[n],r)),{});const _r=["includePreviousRevision","includeResult","visibility","effectFormat","tag"],Ar={includeResult:!0};function Rr(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const{url:n,token:o,withCredentials:s,requestTagPrefix:i}=this.config(),a=r.tag&&i?[i,r.tag].join("."):r.tag,c={...Sr(r,Ar),tag:a},u=(l=c,_r.reduce(((e,t)=>(void 0===l[t]||(e[t]=l[t]),e)),{}));var l;const d=Pt({query:e,params:t,options:{tag:a,...u}}),h="".concat(n).concat(pr(this,"listen",d));if(h.length>14800)return new Ge((e=>e.error(new Error("Query too large for listener"))));const p=c.events?c.events:["mutation"],f=-1!==p.indexOf("reconnect"),y={};return(o||s)&&(y.withCredentials=!0),o&&(y.headers={Authorization:"Bearer ".concat(o)}),new Ge((e=>{let t,r;u().then((e=>{t=e})).catch((t=>{e.error(t),d()}));let n=!1;function o(){n||(f&&e.next({type:"reconnect"}),n||t.readyState===t.CLOSED&&(c(),clearTimeout(r),r=setTimeout(l,100)))}function s(t){e.error(function(e){if(e instanceof Error)return e;const t=kr(e);return t instanceof Error?t:new Error(function(e){if(!e.error)return e.message||"Unknown listener error";if(e.error.description)return e.error.description;return"string"==typeof e.error?e.error:JSON.stringify(e.error,null,2)}(t))}(t))}function i(t){const r=kr(t);return r instanceof Error?e.error(r):e.next(r)}function a(){n=!0,c(),e.complete()}function c(){t&&(t.removeEventListener("error",o),t.removeEventListener("channelError",s),t.removeEventListener("disconnect",a),p.forEach((e=>t.removeEventListener(e,i))),t.close())}async function u(){const{default:e}=await Promise.resolve().then((function(){return On})),t=new e(h,y);return t.addEventListener("error",o),t.addEventListener("channelError",s),t.addEventListener("disconnect",a),p.forEach((e=>t.addEventListener(e,i))),t}function l(){u().then((e=>{t=e})).catch((t=>{e.error(t),d()}))}function d(){n=!0,c()}return d}))}function kr(e){try{const t=e.data&&JSON.parse(e.data)||{};return Object.assign({type:e.type},t)}catch(e){return e}}var Pr,Mr,qr,Ir,Fr=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},Dr=(e,t,r)=>(Fr(e,t,"read from private field"),r?r.call(e):t.get(e)),Nr=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},Hr=(e,t,r,n)=>(Fr(e,t,"write to private field"),n?n.call(e,r):t.set(e,r),r);class Lr{constructor(e,t){Nr(this,Pr,void 0),Nr(this,Mr,void 0),Hr(this,Pr,e),Hr(this,Mr,t)}create(e,t){return zr(Dr(this,Pr),Dr(this,Mr),"PUT",e,t)}edit(e,t){return zr(Dr(this,Pr),Dr(this,Mr),"PATCH",e,t)}delete(e){return zr(Dr(this,Pr),Dr(this,Mr),"DELETE",e)}list(){return hr(Dr(this,Pr),Dr(this,Mr),{uri:"/datasets",tag:null})}}Pr=new WeakMap,Mr=new WeakMap;class Wr{constructor(e,t){Nr(this,qr,void 0),Nr(this,Ir,void 0),Hr(this,qr,e),Hr(this,Ir,t)}create(e,t){return Ze(zr(Dr(this,qr),Dr(this,Ir),"PUT",e,t))}edit(e,t){return Ze(zr(Dr(this,qr),Dr(this,Ir),"PATCH",e,t))}delete(e){return Ze(zr(Dr(this,qr),Dr(this,Ir),"DELETE",e))}list(){return Ze(hr(Dr(this,qr),Dr(this,Ir),{uri:"/datasets",tag:null}))}}function zr(e,t,r,n,o){return ft(n),hr(e,t,{method:r,uri:"/datasets/".concat(n),body:o,tag:null})}qr=new WeakMap,Ir=new WeakMap;var Ur,Br,$r,Gr,Jr=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},Vr=(e,t,r)=>(Jr(e,t,"read from private field"),r?r.call(e):t.get(e)),Xr=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},Yr=(e,t,r,n)=>(Jr(e,t,"write to private field"),n?n.call(e,r):t.set(e,r),r);class Kr{constructor(e,t){Xr(this,Ur,void 0),Xr(this,Br,void 0),Yr(this,Ur,e),Yr(this,Br,t)}list(e){const t=!1===(null==e?void 0:e.includeMembers)?"/projects?includeMembers=false":"/projects";return hr(Vr(this,Ur),Vr(this,Br),{uri:t})}getById(e){return hr(Vr(this,Ur),Vr(this,Br),{uri:"/projects/".concat(e)})}}Ur=new WeakMap,Br=new WeakMap;class Zr{constructor(e,t){Xr(this,$r,void 0),Xr(this,Gr,void 0),Yr(this,$r,e),Yr(this,Gr,t)}list(e){const t=!1===(null==e?void 0:e.includeMembers)?"/projects?includeMembers=false":"/projects";return Ze(hr(Vr(this,$r),Vr(this,Gr),{uri:t}))}getById(e){return Ze(hr(Vr(this,$r),Vr(this,Gr),{uri:"/projects/".concat(e)}))}}$r=new WeakMap,Gr=new WeakMap;var Qr,en,tn,rn,nn=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},on=(e,t,r)=>(nn(e,t,"read from private field"),r?r.call(e):t.get(e)),sn=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},an=(e,t,r,n)=>(nn(e,t,"write to private field"),n?n.call(e,r):t.set(e,r),r);class cn{constructor(e,t){sn(this,Qr,void 0),sn(this,en,void 0),an(this,Qr,e),an(this,en,t)}getById(e){return hr(on(this,Qr),on(this,en),{uri:"/users/".concat(e)})}}Qr=new WeakMap,en=new WeakMap;class un{constructor(e,t){sn(this,tn,void 0),sn(this,rn,void 0),an(this,tn,e),an(this,rn,t)}getById(e){return Ze(hr(on(this,tn),on(this,rn),{uri:"/users/".concat(e)}))}}tn=new WeakMap,rn=new WeakMap;var ln,dn,hn,pn,fn=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},yn=(e,t,r)=>(fn(e,t,"read from private field"),r?r.call(e):t.get(e)),gn=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},mn=(e,t,r,n)=>(fn(e,t,"write to private field"),n?n.call(e,r):t.set(e,r),r);ln=new WeakMap,dn=new WeakMap;let vn=class e{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:jt;gn(this,ln,void 0),gn(this,dn,void 0),this.listen=Rr,this.config(t),mn(this,dn,e),this.assets=new Or(this,yn(this,dn)),this.datasets=new Lr(this,yn(this,dn)),this.projects=new Kr(this,yn(this,dn)),this.users=new cn(this,yn(this,dn))}clone(){return new e(yn(this,dn),this.config())}config(e){if(void 0===e)return{...yn(this,ln)};if(yn(this,ln)&&!1===yn(this,ln).allowReconfigure)throw new Error("Existing client instance cannot be reconfigured - use `withConfig(newConfig)` to return a new client");return mn(this,ln,At(e,yn(this,ln)||{})),this}withConfig(t){return new e(yn(this,dn),{...this.config(),...t})}fetch(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return rr(this,yn(this,dn),e,t,r)}getDocument(e,t){return nr(this,yn(this,dn),e,t)}getDocuments(e,t){return or(this,yn(this,dn),e,t)}create(e,t){return lr(this,yn(this,dn),e,"create",t)}createIfNotExists(e,t){return sr(this,yn(this,dn),e,t)}createOrReplace(e,t){return ir(this,yn(this,dn),e,t)}delete(e,t){return ar(this,yn(this,dn),e,t)}mutate(e,t){return cr(this,yn(this,dn),e,t)}patch(e,t){return new Lt(e,t,this)}transaction(e){return new Kt(e,this)}request(e){return hr(this,yn(this,dn),e)}getUrl(e,t){return fr(this,e,t)}getDataUrl(e,t){return pr(this,e,t)}};hn=new WeakMap,pn=new WeakMap;let bn=class e{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:jt;gn(this,hn,void 0),gn(this,pn,void 0),this.listen=Rr,this.config(t),mn(this,pn,e),this.assets=new Tr(this,yn(this,pn)),this.datasets=new Wr(this,yn(this,pn)),this.projects=new Zr(this,yn(this,pn)),this.users=new un(this,yn(this,pn)),this.observable=new vn(e,t)}clone(){return new e(yn(this,pn),this.config())}config(e){if(void 0===e)return{...yn(this,hn)};if(yn(this,hn)&&!1===yn(this,hn).allowReconfigure)throw new Error("Existing client instance cannot be reconfigured - use `withConfig(newConfig)` to return a new client");return this.observable&&this.observable.config(e),mn(this,hn,At(e,yn(this,hn)||{})),this}withConfig(t){return new e(yn(this,pn),{...this.config(),...t})}fetch(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return Ze(rr(this,yn(this,pn),e,t,r))}getDocument(e,t){return Ze(nr(this,yn(this,pn),e,t))}getDocuments(e,t){return Ze(or(this,yn(this,pn),e,t))}create(e,t){return Ze(lr(this,yn(this,pn),e,"create",t))}createIfNotExists(e,t){return Ze(sr(this,yn(this,pn),e,t))}createOrReplace(e,t){return Ze(ir(this,yn(this,pn),e,t))}delete(e,t){return Ze(ar(this,yn(this,pn),e,t))}mutate(e,t){return Ze(cr(this,yn(this,pn),e,t))}patch(e,t){return new Wt(e,t,this)}transaction(e){return new Yt(e,this)}request(e){return Ze(hr(this,yn(this,pn),e))}dataRequest(e,t,r){return Ze(ur(this,yn(this,pn),e,t,r))}getUrl(e,t){return fr(this,e,t)}getDataUrl(e,t){return pr(this,e,t)}};const wn=ut(tt,{}),Cn=wn.defaultRequester;var En={exports:{}};
|
|
9
9
|
/** @license
|
|
10
10
|
* eventsource.js
|
|
11
11
|
* Available under MIT License (MIT)
|
|
12
12
|
* https://github.com/Yaffle/EventSource/
|
|
13
|
-
*/!function(e,t){!function(r){var n=r.setTimeout,o=r.clearTimeout,s=r.XMLHttpRequest,i=r.XDomainRequest,a=r.ActiveXObject,c=r.EventSource,u=r.document,l=r.Promise,h=r.fetch,d=r.Response,p=r.TextDecoder,f=r.TextEncoder,y=r.AbortController;if("undefined"==typeof window||void 0===u||"readyState"in u||null!=u.body||(u.readyState="loading",window.addEventListener("load",(function(e){u.readyState="complete"}),!1)),null==s&&null!=a&&(s=function(){return new a("Microsoft.XMLHTTP")}),null==Object.create&&(Object.create=function(e){function t(){}return t.prototype=e,new t}),Date.now||(Date.now=function(){return(new Date).getTime()}),null==y){var g=h;h=function(e,t){var r=t.signal;return g(e,{headers:t.headers,credentials:t.credentials,cache:t.cache}).then((function(e){var t=e.body.getReader();return r._reader=t,r._aborted&&r._reader.cancel(),{status:e.status,statusText:e.statusText,headers:e.headers,body:{getReader:function(){return t}}}}))},y=function(){this.signal={_reader:null,_aborted:!1},this.abort=function(){null!=this.signal._reader&&this.signal._reader.cancel(),this.signal._aborted=!0}}}function v(){this.bitsNeeded=0,this.codePoint=0}v.prototype.decode=function(e){function t(e,t,r){if(1===r)return e>=128>>t&&e<<t<=2047;if(2===r)return e>=2048>>t&&e<<t<=55295||e>=57344>>t&&e<<t<=65535;if(3===r)return e>=65536>>t&&e<<t<=1114111;throw new Error}function r(e,t){if(6===e)return t>>6>15?3:t>31?2:1;if(12===e)return t>15?3:2;if(18===e)return 3;throw new Error}for(var n=65533,o="",s=this.bitsNeeded,i=this.codePoint,a=0;a<e.length;a+=1){var c=e[a];0!==s&&(c<128||c>191||!t(i<<6|63&c,s-6,r(s,i)))&&(s=0,i=n,o+=String.fromCharCode(i)),0===s?(c>=0&&c<=127?(s=0,i=c):c>=192&&c<=223?(s=6,i=31&c):c>=224&&c<=239?(s=12,i=15&c):c>=240&&c<=247?(s=18,i=7&c):(s=0,i=n),0===s||t(i,s,r(s,i))||(s=0,i=n)):(s-=6,i=i<<6|63&c),0===s&&(i<=65535?o+=String.fromCharCode(i):(o+=String.fromCharCode(55296+(i-65535-1>>10)),o+=String.fromCharCode(56320+(i-65535-1&1023))))}return this.bitsNeeded=s,this.codePoint=i,o};null!=p&&null!=f&&function(){try{return"test"===(new p).decode((new f).encode("test"),{stream:!0})}catch(e){console.debug("TextDecoder does not support streaming option. Using polyfill instead: "+e)}return!1}()||(p=v);var m=function(){};function w(e){this.withCredentials=!1,this.readyState=0,this.status=0,this.statusText="",this.responseText="",this.onprogress=m,this.onload=m,this.onerror=m,this.onreadystatechange=m,this._contentType="",this._xhr=e,this._sendTimeout=0,this._abort=m}function b(e){return e.replace(/[A-Z]/g,(function(e){return String.fromCharCode(e.charCodeAt(0)+32)}))}function C(e){for(var t=Object.create(null),r=e.split("\r\n"),n=0;n<r.length;n+=1){var o=r[n].split(": "),s=o.shift(),i=o.join(": ");t[b(s)]=i}this._map=t}function E(){}function x(e){this._headers=e}function T(){}function O(){this._listeners=Object.create(null)}function S(e){n((function(){throw e}),0)}function _(e){this.type=e,this.target=void 0}function j(e,t){_.call(this,e),this.data=t.data,this.lastEventId=t.lastEventId}function A(e,t){_.call(this,e),this.status=t.status,this.statusText=t.statusText,this.headers=t.headers}function k(e,t){_.call(this,e),this.error=t.error}w.prototype.open=function(e,t){this._abort(!0);var r=this,i=this._xhr,a=1,c=0;this._abort=function(e){0!==r._sendTimeout&&(o(r._sendTimeout),r._sendTimeout=0),1!==a&&2!==a&&3!==a||(a=4,i.onload=m,i.onerror=m,i.onabort=m,i.onprogress=m,i.onreadystatechange=m,i.abort(),0!==c&&(o(c),c=0),e||(r.readyState=4,r.onabort(null),r.onreadystatechange())),a=0};var u=function(){if(1===a){var e=0,t="",n=void 0;if("contentType"in i)e=200,t="OK",n=i.contentType;else try{e=i.status,t=i.statusText,n=i.getResponseHeader("Content-Type")}catch(r){e=0,t="",n=void 0}0!==e&&(a=2,r.readyState=2,r.status=e,r.statusText=t,r._contentType=n,r.onreadystatechange())}},l=function(){if(u(),2===a||3===a){a=3;var e="";try{e=i.responseText}catch(e){}r.readyState=3,r.responseText=e,r.onprogress()}},h=function(e,t){if(null!=t&&null!=t.preventDefault||(t={preventDefault:m}),l(),1===a||2===a||3===a){if(a=4,0!==c&&(o(c),c=0),r.readyState=4,"load"===e)r.onload(t);else if("error"===e)r.onerror(t);else{if("abort"!==e)throw new TypeError;r.onabort(t)}r.onreadystatechange()}},d=function(){c=n((function(){d()}),500),3===i.readyState&&l()};"onload"in i&&(i.onload=function(e){h("load",e)}),"onerror"in i&&(i.onerror=function(e){h("error",e)}),"onabort"in i&&(i.onabort=function(e){h("abort",e)}),"onprogress"in i&&(i.onprogress=l),"onreadystatechange"in i&&(i.onreadystatechange=function(e){!function(e){null!=i&&(4===i.readyState?"onload"in i&&"onerror"in i&&"onabort"in i||h(""===i.responseText?"error":"load",e):3===i.readyState?"onprogress"in i||l():2===i.readyState&&u())}(e)}),!("contentType"in i)&&"ontimeout"in s.prototype||(t+=(-1===t.indexOf("?")?"?":"&")+"padding=true"),i.open(e,t,!0),"readyState"in i&&(c=n((function(){d()}),0))},w.prototype.abort=function(){this._abort(!1)},w.prototype.getResponseHeader=function(e){return this._contentType},w.prototype.setRequestHeader=function(e,t){var r=this._xhr;"setRequestHeader"in r&&r.setRequestHeader(e,t)},w.prototype.getAllResponseHeaders=function(){return null!=this._xhr.getAllResponseHeaders&&this._xhr.getAllResponseHeaders()||""},w.prototype.send=function(){if("ontimeout"in s.prototype&&("sendAsBinary"in s.prototype||"mozAnon"in s.prototype)||null==u||null==u.readyState||"complete"===u.readyState){var e=this._xhr;"withCredentials"in e&&(e.withCredentials=this.withCredentials);try{e.send(void 0)}catch(e){throw e}}else{var t=this;t._sendTimeout=n((function(){t._sendTimeout=0,t.send()}),4)}},C.prototype.get=function(e){return this._map[b(e)]},null!=s&&null==s.HEADERS_RECEIVED&&(s.HEADERS_RECEIVED=2),E.prototype.open=function(e,t,r,n,o,i,a){e.open("GET",o);var c=0;for(var u in e.onprogress=function(){var t=e.responseText.slice(c);c+=t.length,r(t)},e.onerror=function(e){e.preventDefault(),n(new Error("NetworkError"))},e.onload=function(){n(null)},e.onabort=function(){n(null)},e.onreadystatechange=function(){if(e.readyState===s.HEADERS_RECEIVED){var r=e.status,n=e.statusText,o=e.getResponseHeader("Content-Type"),i=e.getAllResponseHeaders();t(r,n,o,new C(i))}},e.withCredentials=i,a)Object.prototype.hasOwnProperty.call(a,u)&&e.setRequestHeader(u,a[u]);return e.send(),e},x.prototype.get=function(e){return this._headers.get(e)},T.prototype.open=function(e,t,r,n,o,s,i){var a=null,c=new y,u=c.signal,d=new p;return h(o,{headers:i,credentials:s?"include":"same-origin",signal:u,cache:"no-store"}).then((function(e){return a=e.body.getReader(),t(e.status,e.statusText,e.headers.get("Content-Type"),new x(e.headers)),new l((function(e,t){var n=function(){a.read().then((function(t){if(t.done)e(void 0);else{var o=d.decode(t.value,{stream:!0});r(o),n()}})).catch((function(e){t(e)}))};n()}))})).catch((function(e){return"AbortError"===e.name?void 0:e})).then((function(e){n(e)})),{abort:function(){null!=a&&a.cancel(),c.abort()}}},O.prototype.dispatchEvent=function(e){e.target=this;var t=this._listeners[e.type];if(null!=t)for(var r=t.length,n=0;n<r;n+=1){var o=t[n];try{"function"==typeof o.handleEvent?o.handleEvent(e):o.call(this,e)}catch(e){S(e)}}},O.prototype.addEventListener=function(e,t){e=String(e);var r=this._listeners,n=r[e];null==n&&(n=[],r[e]=n);for(var o=!1,s=0;s<n.length;s+=1)n[s]===t&&(o=!0);o||n.push(t)},O.prototype.removeEventListener=function(e,t){e=String(e);var r=this._listeners,n=r[e];if(null!=n){for(var o=[],s=0;s<n.length;s+=1)n[s]!==t&&o.push(n[s]);0===o.length?delete r[e]:r[e]=o}},j.prototype=Object.create(_.prototype),A.prototype=Object.create(_.prototype),k.prototype=Object.create(_.prototype);var R=-1,M=0,F=1,I=2,P=-1,D=0,q=1,N=2,H=3,W=/^text\/event\-stream(;.*)?$/i,z=function(e,t){var r=null==e?t:parseInt(e,10);return r!=r&&(r=t),U(r)},U=function(e){return Math.min(Math.max(e,1e3),18e6)},L=function(e,t,r){try{"function"==typeof t&&t.call(e,r)}catch(e){S(e)}};function B(e,t){O.call(this),t=t||{},this.onopen=void 0,this.onmessage=void 0,this.onerror=void 0,this.url=void 0,this.readyState=void 0,this.withCredentials=void 0,this.headers=void 0,this._close=void 0,function(e,t,r){t=String(t);var a=Boolean(r.withCredentials),c=r.lastEventIdQueryParameterName||"lastEventId",u=U(1e3),l=z(r.heartbeatTimeout,45e3),h="",d=u,p=!1,f=0,y=r.headers||{},g=r.Transport,v=$&&null==g?void 0:new w(null!=g?new g:null!=s&&"withCredentials"in s.prototype||null==i?new s:new i),m=null!=g&&"string"!=typeof g?new g:null==v?new T:new E,b=void 0,C=0,x=R,O="",S="",_="",B="",G=D,V=0,J=0,X=function(t,r,n,o){if(x===M)if(200===t&&null!=n&&W.test(n)){x=F,p=Date.now(),d=u,e.readyState=F;var s=new A("open",{status:t,statusText:r,headers:o});e.dispatchEvent(s),L(e,e.onopen,s)}else{var i="";200!==t?(r&&(r=r.replace(/\s+/g," ")),i="EventSource's response has a status "+t+" "+r+" that is not 200. Aborting the connection."):i="EventSource's response has a Content-Type specifying an unsupported type: "+(null==n?"-":n.replace(/\s+/g," "))+". Aborting the connection.",Z();s=new A("error",{status:t,statusText:r,headers:o});e.dispatchEvent(s),L(e,e.onerror,s),console.error(i)}},Y=function(t){if(x===F){for(var r=-1,s=0;s<t.length;s+=1){(c=t.charCodeAt(s))!=="\n".charCodeAt(0)&&c!=="\r".charCodeAt(0)||(r=s)}var i=(-1!==r?B:"")+t.slice(0,r+1);B=(-1===r?B:"")+t.slice(r+1),""!==t&&(p=Date.now(),f+=t.length);for(var a=0;a<i.length;a+=1){var c=i.charCodeAt(a);if(G===P&&c==="\n".charCodeAt(0))G=D;else if(G===P&&(G=D),c==="\r".charCodeAt(0)||c==="\n".charCodeAt(0)){if(G!==D){G===q&&(J=a+1);var y=i.slice(V,J-1),g=i.slice(J+(J<a&&i.charCodeAt(J)===" ".charCodeAt(0)?1:0),a);"data"===y?(O+="\n",O+=g):"id"===y?S=g:"event"===y?_=g:"retry"===y?(u=z(g,u),d=u):"heartbeatTimeout"===y&&(l=z(g,l),0!==C&&(o(C),C=n((function(){Q()}),l)))}if(G===D){if(""!==O){h=S,""===_&&(_="message");var v=new j(_,{data:O.slice(1),lastEventId:S});if(e.dispatchEvent(v),"open"===_?L(e,e.onopen,v):"message"===_?L(e,e.onmessage,v):"error"===_&&L(e,e.onerror,v),x===I)return}O="",_=""}G=c==="\r".charCodeAt(0)?P:D}else G===D&&(V=a,G=q),G===q?c===":".charCodeAt(0)&&(J=a+1,G=N):G===N&&(G=H)}}},K=function(t){if(x===F||x===M){x=R,0!==C&&(o(C),C=0),C=n((function(){Q()}),d),d=U(Math.min(16*u,2*d)),e.readyState=M;var r=new k("error",{error:t});e.dispatchEvent(r),L(e,e.onerror,r),null!=t&&console.error(t)}},Z=function(){x=I,null!=b&&(b.abort(),b=void 0),0!==C&&(o(C),C=0),e.readyState=I},Q=function(){if(C=0,x===R){p=!1,f=0,C=n((function(){Q()}),l),x=M,O="",_="",S=h,B="",V=0,J=0,G=D;var r=t;if("data:"!==t.slice(0,5)&&"blob:"!==t.slice(0,5)&&""!==h){var o=t.indexOf("?");r=-1===o?t:t.slice(0,o+1)+t.slice(o+1).replace(/(?:^|&)([^=&]*)(?:=[^&]*)?/g,(function(e,t){return t===c?"":e})),r+=(-1===t.indexOf("?")?"?":"&")+c+"="+encodeURIComponent(h)}var s=e.withCredentials,i={Accept:"text/event-stream"},a=e.headers;if(null!=a)for(var u in a)Object.prototype.hasOwnProperty.call(a,u)&&(i[u]=a[u]);try{b=m.open(v,X,Y,K,r,s,i)}catch(e){throw Z(),e}}else if(p||null==b){var d=Math.max((p||Date.now())+l-Date.now(),1);p=!1,C=n((function(){Q()}),d)}else K(new Error("No activity within "+l+" milliseconds. "+(x===M?"No response received.":f+" chars received.")+" Reconnecting.")),null!=b&&(b.abort(),b=void 0)};e.url=t,e.readyState=M,e.withCredentials=a,e.headers=y,e._close=Z,Q()}(this,e,t)}var $=null!=h&&null!=d&&"body"in d.prototype;B.prototype=Object.create(O.prototype),B.prototype.CONNECTING=M,B.prototype.OPEN=F,B.prototype.CLOSED=I,B.prototype.close=function(){this._close()},B.CONNECTING=M,B.OPEN=F,B.CLOSED=I,B.prototype.withCredentials=void 0;var G,V=c;null==s||null!=c&&"withCredentials"in c.prototype||(V=B),G=function(e){e.EventSourcePolyfill=B,e.NativeEventSource=c,e.EventSource=V}(t),void 0!==G&&(e.exports=G)}("undefined"==typeof globalThis?"undefined"!=typeof window?window:"undefined"!=typeof self?self:i:globalThis)}(Xr,Xr.exports);var Yr=a(Xr.exports.EventSourcePolyfill),Kr=Object.freeze({__proto__:null,default:Yr});e.BasePatch=pt,e.BaseTransaction=xt,e.ClientError=ke,e.ObservablePatch=ft,e.ObservableSanityClient=$r,e.ObservableTransaction=Ot,e.Patch=yt,e.SanityClient=Gr,e.ServerError=Re,e.Transaction=Tt,e.createClient=e=>new Gr(qe(Ae,{maxRetries:e.maxRetries,retryDelay:e.retryDelay}),e),e.default=function(e){return Qe(),new Gr(Vr,e)},e.requester=Jr,e.unstable__adapter=_,e.unstable__environment="browser",Object.defineProperty(e,"__esModule",{value:!0})}));
|
|
13
|
+
*/!function(e,t){!function(r){var n=r.setTimeout,o=r.clearTimeout,s=r.XMLHttpRequest,i=r.XDomainRequest,a=r.ActiveXObject,c=r.EventSource,u=r.document,l=r.Promise,d=r.fetch,h=r.Response,p=r.TextDecoder,f=r.TextEncoder,y=r.AbortController;if("undefined"==typeof window||void 0===u||"readyState"in u||null!=u.body||(u.readyState="loading",window.addEventListener("load",(function(e){u.readyState="complete"}),!1)),null==s&&null!=a&&(s=function(){return new a("Microsoft.XMLHTTP")}),null==Object.create&&(Object.create=function(e){function t(){}return t.prototype=e,new t}),Date.now||(Date.now=function(){return(new Date).getTime()}),null==y){var g=d;d=function(e,t){var r=t.signal;return g(e,{headers:t.headers,credentials:t.credentials,cache:t.cache}).then((function(e){var t=e.body.getReader();return r._reader=t,r._aborted&&r._reader.cancel(),{status:e.status,statusText:e.statusText,headers:e.headers,body:{getReader:function(){return t}}}}))},y=function(){this.signal={_reader:null,_aborted:!1},this.abort=function(){null!=this.signal._reader&&this.signal._reader.cancel(),this.signal._aborted=!0}}}function m(){this.bitsNeeded=0,this.codePoint=0}m.prototype.decode=function(e){function t(e,t,r){if(1===r)return e>=128>>t&&e<<t<=2047;if(2===r)return e>=2048>>t&&e<<t<=55295||e>=57344>>t&&e<<t<=65535;if(3===r)return e>=65536>>t&&e<<t<=1114111;throw new Error}function r(e,t){if(6===e)return t>>6>15?3:t>31?2:1;if(12===e)return t>15?3:2;if(18===e)return 3;throw new Error}for(var n=65533,o="",s=this.bitsNeeded,i=this.codePoint,a=0;a<e.length;a+=1){var c=e[a];0!==s&&(c<128||c>191||!t(i<<6|63&c,s-6,r(s,i)))&&(s=0,i=n,o+=String.fromCharCode(i)),0===s?(c>=0&&c<=127?(s=0,i=c):c>=192&&c<=223?(s=6,i=31&c):c>=224&&c<=239?(s=12,i=15&c):c>=240&&c<=247?(s=18,i=7&c):(s=0,i=n),0===s||t(i,s,r(s,i))||(s=0,i=n)):(s-=6,i=i<<6|63&c),0===s&&(i<=65535?o+=String.fromCharCode(i):(o+=String.fromCharCode(55296+(i-65535-1>>10)),o+=String.fromCharCode(56320+(i-65535-1&1023))))}return this.bitsNeeded=s,this.codePoint=i,o};null!=p&&null!=f&&function(){try{return"test"===(new p).decode((new f).encode("test"),{stream:!0})}catch(e){console.debug("TextDecoder does not support streaming option. Using polyfill instead: "+e)}return!1}()||(p=m);var v=function(){};function b(e){this.withCredentials=!1,this.readyState=0,this.status=0,this.statusText="",this.responseText="",this.onprogress=v,this.onload=v,this.onerror=v,this.onreadystatechange=v,this._contentType="",this._xhr=e,this._sendTimeout=0,this._abort=v}function w(e){return e.replace(/[A-Z]/g,(function(e){return String.fromCharCode(e.charCodeAt(0)+32)}))}function C(e){for(var t=Object.create(null),r=e.split("\r\n"),n=0;n<r.length;n+=1){var o=r[n].split(": "),s=o.shift(),i=o.join(": ");t[w(s)]=i}this._map=t}function E(){}function x(e){this._headers=e}function O(){}function T(){this._listeners=Object.create(null)}function j(e){n((function(){throw e}),0)}function S(e){this.type=e,this.target=void 0}function _(e,t){S.call(this,e),this.data=t.data,this.lastEventId=t.lastEventId}function A(e,t){S.call(this,e),this.status=t.status,this.statusText=t.statusText,this.headers=t.headers}function R(e,t){S.call(this,e),this.error=t.error}b.prototype.open=function(e,t){this._abort(!0);var r=this,i=this._xhr,a=1,c=0;this._abort=function(e){0!==r._sendTimeout&&(o(r._sendTimeout),r._sendTimeout=0),1!==a&&2!==a&&3!==a||(a=4,i.onload=v,i.onerror=v,i.onabort=v,i.onprogress=v,i.onreadystatechange=v,i.abort(),0!==c&&(o(c),c=0),e||(r.readyState=4,r.onabort(null),r.onreadystatechange())),a=0};var u=function(){if(1===a){var e=0,t="",n=void 0;if("contentType"in i)e=200,t="OK",n=i.contentType;else try{e=i.status,t=i.statusText,n=i.getResponseHeader("Content-Type")}catch(r){e=0,t="",n=void 0}0!==e&&(a=2,r.readyState=2,r.status=e,r.statusText=t,r._contentType=n,r.onreadystatechange())}},l=function(){if(u(),2===a||3===a){a=3;var e="";try{e=i.responseText}catch(e){}r.readyState=3,r.responseText=e,r.onprogress()}},d=function(e,t){if(null!=t&&null!=t.preventDefault||(t={preventDefault:v}),l(),1===a||2===a||3===a){if(a=4,0!==c&&(o(c),c=0),r.readyState=4,"load"===e)r.onload(t);else if("error"===e)r.onerror(t);else{if("abort"!==e)throw new TypeError;r.onabort(t)}r.onreadystatechange()}},h=function(){c=n((function(){h()}),500),3===i.readyState&&l()};"onload"in i&&(i.onload=function(e){d("load",e)}),"onerror"in i&&(i.onerror=function(e){d("error",e)}),"onabort"in i&&(i.onabort=function(e){d("abort",e)}),"onprogress"in i&&(i.onprogress=l),"onreadystatechange"in i&&(i.onreadystatechange=function(e){!function(e){null!=i&&(4===i.readyState?"onload"in i&&"onerror"in i&&"onabort"in i||d(""===i.responseText?"error":"load",e):3===i.readyState?"onprogress"in i||l():2===i.readyState&&u())}(e)}),!("contentType"in i)&&"ontimeout"in s.prototype||(t+=(-1===t.indexOf("?")?"?":"&")+"padding=true"),i.open(e,t,!0),"readyState"in i&&(c=n((function(){h()}),0))},b.prototype.abort=function(){this._abort(!1)},b.prototype.getResponseHeader=function(e){return this._contentType},b.prototype.setRequestHeader=function(e,t){var r=this._xhr;"setRequestHeader"in r&&r.setRequestHeader(e,t)},b.prototype.getAllResponseHeaders=function(){return null!=this._xhr.getAllResponseHeaders&&this._xhr.getAllResponseHeaders()||""},b.prototype.send=function(){if("ontimeout"in s.prototype&&("sendAsBinary"in s.prototype||"mozAnon"in s.prototype)||null==u||null==u.readyState||"complete"===u.readyState){var e=this._xhr;"withCredentials"in e&&(e.withCredentials=this.withCredentials);try{e.send(void 0)}catch(e){throw e}}else{var t=this;t._sendTimeout=n((function(){t._sendTimeout=0,t.send()}),4)}},C.prototype.get=function(e){return this._map[w(e)]},null!=s&&null==s.HEADERS_RECEIVED&&(s.HEADERS_RECEIVED=2),E.prototype.open=function(e,t,r,n,o,i,a){e.open("GET",o);var c=0;for(var u in e.onprogress=function(){var t=e.responseText.slice(c);c+=t.length,r(t)},e.onerror=function(e){e.preventDefault(),n(new Error("NetworkError"))},e.onload=function(){n(null)},e.onabort=function(){n(null)},e.onreadystatechange=function(){if(e.readyState===s.HEADERS_RECEIVED){var r=e.status,n=e.statusText,o=e.getResponseHeader("Content-Type"),i=e.getAllResponseHeaders();t(r,n,o,new C(i))}},e.withCredentials=i,a)Object.prototype.hasOwnProperty.call(a,u)&&e.setRequestHeader(u,a[u]);return e.send(),e},x.prototype.get=function(e){return this._headers.get(e)},O.prototype.open=function(e,t,r,n,o,s,i){var a=null,c=new y,u=c.signal,h=new p;return d(o,{headers:i,credentials:s?"include":"same-origin",signal:u,cache:"no-store"}).then((function(e){return a=e.body.getReader(),t(e.status,e.statusText,e.headers.get("Content-Type"),new x(e.headers)),new l((function(e,t){var n=function(){a.read().then((function(t){if(t.done)e(void 0);else{var o=h.decode(t.value,{stream:!0});r(o),n()}})).catch((function(e){t(e)}))};n()}))})).catch((function(e){return"AbortError"===e.name?void 0:e})).then((function(e){n(e)})),{abort:function(){null!=a&&a.cancel(),c.abort()}}},T.prototype.dispatchEvent=function(e){e.target=this;var t=this._listeners[e.type];if(null!=t)for(var r=t.length,n=0;n<r;n+=1){var o=t[n];try{"function"==typeof o.handleEvent?o.handleEvent(e):o.call(this,e)}catch(e){j(e)}}},T.prototype.addEventListener=function(e,t){e=String(e);var r=this._listeners,n=r[e];null==n&&(n=[],r[e]=n);for(var o=!1,s=0;s<n.length;s+=1)n[s]===t&&(o=!0);o||n.push(t)},T.prototype.removeEventListener=function(e,t){e=String(e);var r=this._listeners,n=r[e];if(null!=n){for(var o=[],s=0;s<n.length;s+=1)n[s]!==t&&o.push(n[s]);0===o.length?delete r[e]:r[e]=o}},_.prototype=Object.create(S.prototype),A.prototype=Object.create(S.prototype),R.prototype=Object.create(S.prototype);var k=-1,P=0,M=1,q=2,I=-1,F=0,D=1,N=2,H=3,L=/^text\/event\-stream(;.*)?$/i,W=function(e,t){var r=null==e?t:parseInt(e,10);return r!=r&&(r=t),z(r)},z=function(e){return Math.min(Math.max(e,1e3),18e6)},U=function(e,t,r){try{"function"==typeof t&&t.call(e,r)}catch(e){j(e)}};function B(e,t){T.call(this),t=t||{},this.onopen=void 0,this.onmessage=void 0,this.onerror=void 0,this.url=void 0,this.readyState=void 0,this.withCredentials=void 0,this.headers=void 0,this._close=void 0,function(e,t,r){t=String(t);var a=Boolean(r.withCredentials),c=r.lastEventIdQueryParameterName||"lastEventId",u=z(1e3),l=W(r.heartbeatTimeout,45e3),d="",h=u,p=!1,f=0,y=r.headers||{},g=r.Transport,m=$&&null==g?void 0:new b(null!=g?new g:null!=s&&"withCredentials"in s.prototype||null==i?new s:new i),v=null!=g&&"string"!=typeof g?new g:null==m?new O:new E,w=void 0,C=0,x=k,T="",j="",S="",B="",G=F,J=0,V=0,X=function(t,r,n,o){if(x===P)if(200===t&&null!=n&&L.test(n)){x=M,p=Date.now(),h=u,e.readyState=M;var s=new A("open",{status:t,statusText:r,headers:o});e.dispatchEvent(s),U(e,e.onopen,s)}else{var i="";200!==t?(r&&(r=r.replace(/\s+/g," ")),i="EventSource's response has a status "+t+" "+r+" that is not 200. Aborting the connection."):i="EventSource's response has a Content-Type specifying an unsupported type: "+(null==n?"-":n.replace(/\s+/g," "))+". Aborting the connection.",Z();s=new A("error",{status:t,statusText:r,headers:o});e.dispatchEvent(s),U(e,e.onerror,s),console.error(i)}},Y=function(t){if(x===M){for(var r=-1,s=0;s<t.length;s+=1){(c=t.charCodeAt(s))!=="\n".charCodeAt(0)&&c!=="\r".charCodeAt(0)||(r=s)}var i=(-1!==r?B:"")+t.slice(0,r+1);B=(-1===r?B:"")+t.slice(r+1),""!==t&&(p=Date.now(),f+=t.length);for(var a=0;a<i.length;a+=1){var c=i.charCodeAt(a);if(G===I&&c==="\n".charCodeAt(0))G=F;else if(G===I&&(G=F),c==="\r".charCodeAt(0)||c==="\n".charCodeAt(0)){if(G!==F){G===D&&(V=a+1);var y=i.slice(J,V-1),g=i.slice(V+(V<a&&i.charCodeAt(V)===" ".charCodeAt(0)?1:0),a);"data"===y?(T+="\n",T+=g):"id"===y?j=g:"event"===y?S=g:"retry"===y?(u=W(g,u),h=u):"heartbeatTimeout"===y&&(l=W(g,l),0!==C&&(o(C),C=n((function(){Q()}),l)))}if(G===F){if(""!==T){d=j,""===S&&(S="message");var m=new _(S,{data:T.slice(1),lastEventId:j});if(e.dispatchEvent(m),"open"===S?U(e,e.onopen,m):"message"===S?U(e,e.onmessage,m):"error"===S&&U(e,e.onerror,m),x===q)return}T="",S=""}G=c==="\r".charCodeAt(0)?I:F}else G===F&&(J=a,G=D),G===D?c===":".charCodeAt(0)&&(V=a+1,G=N):G===N&&(G=H)}}},K=function(t){if(x===M||x===P){x=k,0!==C&&(o(C),C=0),C=n((function(){Q()}),h),h=z(Math.min(16*u,2*h)),e.readyState=P;var r=new R("error",{error:t});e.dispatchEvent(r),U(e,e.onerror,r),null!=t&&console.error(t)}},Z=function(){x=q,null!=w&&(w.abort(),w=void 0),0!==C&&(o(C),C=0),e.readyState=q},Q=function(){if(C=0,x===k){p=!1,f=0,C=n((function(){Q()}),l),x=P,T="",S="",j=d,B="",J=0,V=0,G=F;var r=t;if("data:"!==t.slice(0,5)&&"blob:"!==t.slice(0,5)&&""!==d){var o=t.indexOf("?");r=-1===o?t:t.slice(0,o+1)+t.slice(o+1).replace(/(?:^|&)([^=&]*)(?:=[^&]*)?/g,(function(e,t){return t===c?"":e})),r+=(-1===t.indexOf("?")?"?":"&")+c+"="+encodeURIComponent(d)}var s=e.withCredentials,i={Accept:"text/event-stream"},a=e.headers;if(null!=a)for(var u in a)Object.prototype.hasOwnProperty.call(a,u)&&(i[u]=a[u]);try{w=v.open(m,X,Y,K,r,s,i)}catch(e){throw Z(),e}}else if(p||null==w){var h=Math.max((p||Date.now())+l-Date.now(),1);p=!1,C=n((function(){Q()}),h)}else K(new Error("No activity within "+l+" milliseconds. "+(x===P?"No response received.":f+" chars received.")+" Reconnecting.")),null!=w&&(w.abort(),w=void 0)};e.url=t,e.readyState=P,e.withCredentials=a,e.headers=y,e._close=Z,Q()}(this,e,t)}var $=null!=d&&null!=h&&"body"in h.prototype;B.prototype=Object.create(T.prototype),B.prototype.CONNECTING=P,B.prototype.OPEN=M,B.prototype.CLOSED=q,B.prototype.close=function(){this._close()},B.CONNECTING=P,B.OPEN=M,B.CLOSED=q,B.prototype.withCredentials=void 0;var G,J=c;null==s||null!=c&&"withCredentials"in c.prototype||(J=B),G=function(e){e.EventSourcePolyfill=B,e.NativeEventSource=c,e.EventSource=J}(t),void 0!==G&&(e.exports=G)}("undefined"==typeof globalThis?"undefined"!=typeof window?window:"undefined"!=typeof self?self:i:globalThis)}(En,En.exports);var xn=a(En.exports.EventSourcePolyfill),On=Object.freeze({__proto__:null,default:xn});e.BasePatch=Ht,e.BaseTransaction=Xt,e.ClientError=rt,e.ObservablePatch=Lt,e.ObservableSanityClient=vn,e.ObservableTransaction=Kt,e.Patch=Wt,e.SanityClient=bn,e.ServerError=nt,e.Transaction=Yt,e.createClient=e=>new bn(ut(tt,{maxRetries:e.maxRetries,retryDelay:e.retryDelay}),e),e.default=function(e){return Tt(),new bn(wn,e)},e.requester=Cn,e.unstable__adapter=_,e.unstable__environment="browser",Object.defineProperty(e,"__esModule",{value:!0})}));
|