@almadar/ui 1.0.13 → 1.0.15

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.
@@ -1,10 +1,8 @@
1
1
  import { apiClient } from './chunk-XSEDIUM6.js';
2
2
  import { useEventBus, SelectionContext } from './chunk-TTXKOHDO.js';
3
3
  import { subscribe, getSnapshot, clearEntities, removeEntity, updateSingleton, updateEntity, spawnEntity, getSingleton, getAllEntities, getByType, getEntity } from './chunk-N7MVUW4R.js';
4
- import { __privateAdd, __privateGet, __privateSet, __privateMethod } from './chunk-S7EYY36U.js';
5
- import * as React6 from 'react';
6
4
  import { useCallback, useState, useEffect, useMemo, useContext, useSyncExternalStore } from 'react';
7
- import 'react/jsx-runtime';
5
+ import { useQueryClient, useMutation, useQuery } from '@tanstack/react-query';
8
6
 
9
7
  function useOrbitalHistory(options) {
10
8
  const { appId, authToken, userId, onHistoryChange, onRevertSuccess } = options;
@@ -1165,1251 +1163,6 @@ function parseQueryBinding(binding) {
1165
1163
  field: parts.length > 1 ? parts.slice(1).join(".") : void 0
1166
1164
  };
1167
1165
  }
1168
-
1169
- // ../../node_modules/.pnpm/@tanstack+query-core@5.90.20/node_modules/@tanstack/query-core/build/modern/subscribable.js
1170
- var Subscribable = class {
1171
- constructor() {
1172
- this.listeners = /* @__PURE__ */ new Set();
1173
- this.subscribe = this.subscribe.bind(this);
1174
- }
1175
- subscribe(listener) {
1176
- this.listeners.add(listener);
1177
- this.onSubscribe();
1178
- return () => {
1179
- this.listeners.delete(listener);
1180
- this.onUnsubscribe();
1181
- };
1182
- }
1183
- hasListeners() {
1184
- return this.listeners.size > 0;
1185
- }
1186
- onSubscribe() {
1187
- }
1188
- onUnsubscribe() {
1189
- }
1190
- };
1191
-
1192
- // ../../node_modules/.pnpm/@tanstack+query-core@5.90.20/node_modules/@tanstack/query-core/build/modern/timeoutManager.js
1193
- var defaultTimeoutProvider = {
1194
- // We need the wrapper function syntax below instead of direct references to
1195
- // global setTimeout etc.
1196
- //
1197
- // BAD: `setTimeout: setTimeout`
1198
- // GOOD: `setTimeout: (cb, delay) => setTimeout(cb, delay)`
1199
- //
1200
- // If we use direct references here, then anything that wants to spy on or
1201
- // replace the global setTimeout (like tests) won't work since we'll already
1202
- // have a hard reference to the original implementation at the time when this
1203
- // file was imported.
1204
- setTimeout: (callback, delay) => setTimeout(callback, delay),
1205
- clearTimeout: (timeoutId) => clearTimeout(timeoutId),
1206
- setInterval: (callback, delay) => setInterval(callback, delay),
1207
- clearInterval: (intervalId) => clearInterval(intervalId)
1208
- };
1209
- var _provider, _providerCalled, _a;
1210
- var TimeoutManager = (_a = class {
1211
- constructor() {
1212
- // We cannot have TimeoutManager<T> as we must instantiate it with a concrete
1213
- // type at app boot; and if we leave that type, then any new timer provider
1214
- // would need to support ReturnType<typeof setTimeout>, which is infeasible.
1215
- //
1216
- // We settle for type safety for the TimeoutProvider type, and accept that
1217
- // this class is unsafe internally to allow for extension.
1218
- __privateAdd(this, _provider, defaultTimeoutProvider);
1219
- __privateAdd(this, _providerCalled, false);
1220
- }
1221
- setTimeoutProvider(provider) {
1222
- if (process.env.NODE_ENV !== "production") {
1223
- if (__privateGet(this, _providerCalled) && provider !== __privateGet(this, _provider)) {
1224
- console.error(
1225
- `[timeoutManager]: Switching provider after calls to previous provider might result in unexpected behavior.`,
1226
- { previous: __privateGet(this, _provider), provider }
1227
- );
1228
- }
1229
- }
1230
- __privateSet(this, _provider, provider);
1231
- if (process.env.NODE_ENV !== "production") {
1232
- __privateSet(this, _providerCalled, false);
1233
- }
1234
- }
1235
- setTimeout(callback, delay) {
1236
- if (process.env.NODE_ENV !== "production") {
1237
- __privateSet(this, _providerCalled, true);
1238
- }
1239
- return __privateGet(this, _provider).setTimeout(callback, delay);
1240
- }
1241
- clearTimeout(timeoutId) {
1242
- __privateGet(this, _provider).clearTimeout(timeoutId);
1243
- }
1244
- setInterval(callback, delay) {
1245
- if (process.env.NODE_ENV !== "production") {
1246
- __privateSet(this, _providerCalled, true);
1247
- }
1248
- return __privateGet(this, _provider).setInterval(callback, delay);
1249
- }
1250
- clearInterval(intervalId) {
1251
- __privateGet(this, _provider).clearInterval(intervalId);
1252
- }
1253
- }, _provider = new WeakMap(), _providerCalled = new WeakMap(), _a);
1254
- var timeoutManager = new TimeoutManager();
1255
- function systemSetTimeoutZero(callback) {
1256
- setTimeout(callback, 0);
1257
- }
1258
-
1259
- // ../../node_modules/.pnpm/@tanstack+query-core@5.90.20/node_modules/@tanstack/query-core/build/modern/utils.js
1260
- var isServer = typeof window === "undefined" || "Deno" in globalThis;
1261
- function noop() {
1262
- }
1263
- function isValidTimeout(value) {
1264
- return typeof value === "number" && value >= 0 && value !== Infinity;
1265
- }
1266
- function timeUntilStale(updatedAt, staleTime) {
1267
- return Math.max(updatedAt + (staleTime || 0) - Date.now(), 0);
1268
- }
1269
- function resolveStaleTime(staleTime, query) {
1270
- return typeof staleTime === "function" ? staleTime(query) : staleTime;
1271
- }
1272
- function resolveEnabled(enabled, query) {
1273
- return typeof enabled === "function" ? enabled(query) : enabled;
1274
- }
1275
- function hashKey(queryKey) {
1276
- return JSON.stringify(
1277
- queryKey,
1278
- (_, val) => isPlainObject(val) ? Object.keys(val).sort().reduce((result, key) => {
1279
- result[key] = val[key];
1280
- return result;
1281
- }, {}) : val
1282
- );
1283
- }
1284
- var hasOwn = Object.prototype.hasOwnProperty;
1285
- function replaceEqualDeep(a, b, depth = 0) {
1286
- if (a === b) {
1287
- return a;
1288
- }
1289
- if (depth > 500) return b;
1290
- const array = isPlainArray(a) && isPlainArray(b);
1291
- if (!array && !(isPlainObject(a) && isPlainObject(b))) return b;
1292
- const aItems = array ? a : Object.keys(a);
1293
- const aSize = aItems.length;
1294
- const bItems = array ? b : Object.keys(b);
1295
- const bSize = bItems.length;
1296
- const copy = array ? new Array(bSize) : {};
1297
- let equalItems = 0;
1298
- for (let i = 0; i < bSize; i++) {
1299
- const key = array ? i : bItems[i];
1300
- const aItem = a[key];
1301
- const bItem = b[key];
1302
- if (aItem === bItem) {
1303
- copy[key] = aItem;
1304
- if (array ? i < aSize : hasOwn.call(a, key)) equalItems++;
1305
- continue;
1306
- }
1307
- if (aItem === null || bItem === null || typeof aItem !== "object" || typeof bItem !== "object") {
1308
- copy[key] = bItem;
1309
- continue;
1310
- }
1311
- const v = replaceEqualDeep(aItem, bItem, depth + 1);
1312
- copy[key] = v;
1313
- if (v === aItem) equalItems++;
1314
- }
1315
- return aSize === bSize && equalItems === aSize ? a : copy;
1316
- }
1317
- function shallowEqualObjects(a, b) {
1318
- if (!b || Object.keys(a).length !== Object.keys(b).length) {
1319
- return false;
1320
- }
1321
- for (const key in a) {
1322
- if (a[key] !== b[key]) {
1323
- return false;
1324
- }
1325
- }
1326
- return true;
1327
- }
1328
- function isPlainArray(value) {
1329
- return Array.isArray(value) && value.length === Object.keys(value).length;
1330
- }
1331
- function isPlainObject(o) {
1332
- if (!hasObjectPrototype(o)) {
1333
- return false;
1334
- }
1335
- const ctor = o.constructor;
1336
- if (ctor === void 0) {
1337
- return true;
1338
- }
1339
- const prot = ctor.prototype;
1340
- if (!hasObjectPrototype(prot)) {
1341
- return false;
1342
- }
1343
- if (!prot.hasOwnProperty("isPrototypeOf")) {
1344
- return false;
1345
- }
1346
- if (Object.getPrototypeOf(o) !== Object.prototype) {
1347
- return false;
1348
- }
1349
- return true;
1350
- }
1351
- function hasObjectPrototype(o) {
1352
- return Object.prototype.toString.call(o) === "[object Object]";
1353
- }
1354
- function replaceData(prevData, data, options) {
1355
- if (typeof options.structuralSharing === "function") {
1356
- return options.structuralSharing(prevData, data);
1357
- } else if (options.structuralSharing !== false) {
1358
- if (process.env.NODE_ENV !== "production") {
1359
- try {
1360
- return replaceEqualDeep(prevData, data);
1361
- } catch (error) {
1362
- console.error(
1363
- `Structural sharing requires data to be JSON serializable. To fix this, turn off structuralSharing or return JSON-serializable data from your queryFn. [${options.queryHash}]: ${error}`
1364
- );
1365
- throw error;
1366
- }
1367
- }
1368
- return replaceEqualDeep(prevData, data);
1369
- }
1370
- return data;
1371
- }
1372
- function shouldThrowError(throwOnError, params) {
1373
- if (typeof throwOnError === "function") {
1374
- return throwOnError(...params);
1375
- }
1376
- return !!throwOnError;
1377
- }
1378
-
1379
- // ../../node_modules/.pnpm/@tanstack+query-core@5.90.20/node_modules/@tanstack/query-core/build/modern/focusManager.js
1380
- var _focused, _cleanup, _setup, _a2;
1381
- var FocusManager = (_a2 = class extends Subscribable {
1382
- constructor() {
1383
- super();
1384
- __privateAdd(this, _focused);
1385
- __privateAdd(this, _cleanup);
1386
- __privateAdd(this, _setup);
1387
- __privateSet(this, _setup, (onFocus) => {
1388
- if (!isServer && window.addEventListener) {
1389
- const listener = () => onFocus();
1390
- window.addEventListener("visibilitychange", listener, false);
1391
- return () => {
1392
- window.removeEventListener("visibilitychange", listener);
1393
- };
1394
- }
1395
- return;
1396
- });
1397
- }
1398
- onSubscribe() {
1399
- if (!__privateGet(this, _cleanup)) {
1400
- this.setEventListener(__privateGet(this, _setup));
1401
- }
1402
- }
1403
- onUnsubscribe() {
1404
- var _a6;
1405
- if (!this.hasListeners()) {
1406
- (_a6 = __privateGet(this, _cleanup)) == null ? void 0 : _a6.call(this);
1407
- __privateSet(this, _cleanup, void 0);
1408
- }
1409
- }
1410
- setEventListener(setup) {
1411
- var _a6;
1412
- __privateSet(this, _setup, setup);
1413
- (_a6 = __privateGet(this, _cleanup)) == null ? void 0 : _a6.call(this);
1414
- __privateSet(this, _cleanup, setup((focused) => {
1415
- if (typeof focused === "boolean") {
1416
- this.setFocused(focused);
1417
- } else {
1418
- this.onFocus();
1419
- }
1420
- }));
1421
- }
1422
- setFocused(focused) {
1423
- const changed = __privateGet(this, _focused) !== focused;
1424
- if (changed) {
1425
- __privateSet(this, _focused, focused);
1426
- this.onFocus();
1427
- }
1428
- }
1429
- onFocus() {
1430
- const isFocused = this.isFocused();
1431
- this.listeners.forEach((listener) => {
1432
- listener(isFocused);
1433
- });
1434
- }
1435
- isFocused() {
1436
- if (typeof __privateGet(this, _focused) === "boolean") {
1437
- return __privateGet(this, _focused);
1438
- }
1439
- return globalThis.document?.visibilityState !== "hidden";
1440
- }
1441
- }, _focused = new WeakMap(), _cleanup = new WeakMap(), _setup = new WeakMap(), _a2);
1442
- var focusManager = new FocusManager();
1443
-
1444
- // ../../node_modules/.pnpm/@tanstack+query-core@5.90.20/node_modules/@tanstack/query-core/build/modern/thenable.js
1445
- function pendingThenable() {
1446
- let resolve;
1447
- let reject;
1448
- const thenable = new Promise((_resolve, _reject) => {
1449
- resolve = _resolve;
1450
- reject = _reject;
1451
- });
1452
- thenable.status = "pending";
1453
- thenable.catch(() => {
1454
- });
1455
- function finalize(data) {
1456
- Object.assign(thenable, data);
1457
- delete thenable.resolve;
1458
- delete thenable.reject;
1459
- }
1460
- thenable.resolve = (value) => {
1461
- finalize({
1462
- status: "fulfilled",
1463
- value
1464
- });
1465
- resolve(value);
1466
- };
1467
- thenable.reject = (reason) => {
1468
- finalize({
1469
- status: "rejected",
1470
- reason
1471
- });
1472
- reject(reason);
1473
- };
1474
- return thenable;
1475
- }
1476
-
1477
- // ../../node_modules/.pnpm/@tanstack+query-core@5.90.20/node_modules/@tanstack/query-core/build/modern/notifyManager.js
1478
- var defaultScheduler = systemSetTimeoutZero;
1479
- function createNotifyManager() {
1480
- let queue = [];
1481
- let transactions = 0;
1482
- let notifyFn = (callback) => {
1483
- callback();
1484
- };
1485
- let batchNotifyFn = (callback) => {
1486
- callback();
1487
- };
1488
- let scheduleFn = defaultScheduler;
1489
- const schedule = (callback) => {
1490
- if (transactions) {
1491
- queue.push(callback);
1492
- } else {
1493
- scheduleFn(() => {
1494
- notifyFn(callback);
1495
- });
1496
- }
1497
- };
1498
- const flush = () => {
1499
- const originalQueue = queue;
1500
- queue = [];
1501
- if (originalQueue.length) {
1502
- scheduleFn(() => {
1503
- batchNotifyFn(() => {
1504
- originalQueue.forEach((callback) => {
1505
- notifyFn(callback);
1506
- });
1507
- });
1508
- });
1509
- }
1510
- };
1511
- return {
1512
- batch: (callback) => {
1513
- let result;
1514
- transactions++;
1515
- try {
1516
- result = callback();
1517
- } finally {
1518
- transactions--;
1519
- if (!transactions) {
1520
- flush();
1521
- }
1522
- }
1523
- return result;
1524
- },
1525
- /**
1526
- * All calls to the wrapped function will be batched.
1527
- */
1528
- batchCalls: (callback) => {
1529
- return (...args) => {
1530
- schedule(() => {
1531
- callback(...args);
1532
- });
1533
- };
1534
- },
1535
- schedule,
1536
- /**
1537
- * Use this method to set a custom notify function.
1538
- * This can be used to for example wrap notifications with `React.act` while running tests.
1539
- */
1540
- setNotifyFunction: (fn) => {
1541
- notifyFn = fn;
1542
- },
1543
- /**
1544
- * Use this method to set a custom function to batch notifications together into a single tick.
1545
- * By default React Query will use the batch function provided by ReactDOM or React Native.
1546
- */
1547
- setBatchNotifyFunction: (fn) => {
1548
- batchNotifyFn = fn;
1549
- },
1550
- setScheduler: (fn) => {
1551
- scheduleFn = fn;
1552
- }
1553
- };
1554
- }
1555
- var notifyManager = createNotifyManager();
1556
-
1557
- // ../../node_modules/.pnpm/@tanstack+query-core@5.90.20/node_modules/@tanstack/query-core/build/modern/onlineManager.js
1558
- var _online, _cleanup2, _setup2, _a3;
1559
- var OnlineManager = (_a3 = class extends Subscribable {
1560
- constructor() {
1561
- super();
1562
- __privateAdd(this, _online, true);
1563
- __privateAdd(this, _cleanup2);
1564
- __privateAdd(this, _setup2);
1565
- __privateSet(this, _setup2, (onOnline) => {
1566
- if (!isServer && window.addEventListener) {
1567
- const onlineListener = () => onOnline(true);
1568
- const offlineListener = () => onOnline(false);
1569
- window.addEventListener("online", onlineListener, false);
1570
- window.addEventListener("offline", offlineListener, false);
1571
- return () => {
1572
- window.removeEventListener("online", onlineListener);
1573
- window.removeEventListener("offline", offlineListener);
1574
- };
1575
- }
1576
- return;
1577
- });
1578
- }
1579
- onSubscribe() {
1580
- if (!__privateGet(this, _cleanup2)) {
1581
- this.setEventListener(__privateGet(this, _setup2));
1582
- }
1583
- }
1584
- onUnsubscribe() {
1585
- var _a6;
1586
- if (!this.hasListeners()) {
1587
- (_a6 = __privateGet(this, _cleanup2)) == null ? void 0 : _a6.call(this);
1588
- __privateSet(this, _cleanup2, void 0);
1589
- }
1590
- }
1591
- setEventListener(setup) {
1592
- var _a6;
1593
- __privateSet(this, _setup2, setup);
1594
- (_a6 = __privateGet(this, _cleanup2)) == null ? void 0 : _a6.call(this);
1595
- __privateSet(this, _cleanup2, setup(this.setOnline.bind(this)));
1596
- }
1597
- setOnline(online) {
1598
- const changed = __privateGet(this, _online) !== online;
1599
- if (changed) {
1600
- __privateSet(this, _online, online);
1601
- this.listeners.forEach((listener) => {
1602
- listener(online);
1603
- });
1604
- }
1605
- }
1606
- isOnline() {
1607
- return __privateGet(this, _online);
1608
- }
1609
- }, _online = new WeakMap(), _cleanup2 = new WeakMap(), _setup2 = new WeakMap(), _a3);
1610
- var onlineManager = new OnlineManager();
1611
-
1612
- // ../../node_modules/.pnpm/@tanstack+query-core@5.90.20/node_modules/@tanstack/query-core/build/modern/retryer.js
1613
- function canFetch(networkMode) {
1614
- return (networkMode ?? "online") === "online" ? onlineManager.isOnline() : true;
1615
- }
1616
-
1617
- // ../../node_modules/.pnpm/@tanstack+query-core@5.90.20/node_modules/@tanstack/query-core/build/modern/query.js
1618
- function fetchState(data, options) {
1619
- return {
1620
- fetchFailureCount: 0,
1621
- fetchFailureReason: null,
1622
- fetchStatus: canFetch(options.networkMode) ? "fetching" : "paused",
1623
- ...data === void 0 && {
1624
- error: null,
1625
- status: "pending"
1626
- }
1627
- };
1628
- }
1629
-
1630
- // ../../node_modules/.pnpm/@tanstack+query-core@5.90.20/node_modules/@tanstack/query-core/build/modern/queryObserver.js
1631
- var _client, _currentQuery, _currentQueryInitialState, _currentResult, _currentResultState, _currentResultOptions, _currentThenable, _selectError, _selectFn, _selectResult, _lastQueryWithDefinedData, _staleTimeoutId, _refetchIntervalId, _currentRefetchInterval, _trackedProps, _QueryObserver_instances, executeFetch_fn, updateStaleTimeout_fn, computeRefetchInterval_fn, updateRefetchInterval_fn, updateTimers_fn, clearStaleTimeout_fn, clearRefetchInterval_fn, updateQuery_fn, notify_fn, _a4;
1632
- var QueryObserver = (_a4 = class extends Subscribable {
1633
- constructor(client, options) {
1634
- super();
1635
- __privateAdd(this, _QueryObserver_instances);
1636
- __privateAdd(this, _client);
1637
- __privateAdd(this, _currentQuery);
1638
- __privateAdd(this, _currentQueryInitialState);
1639
- __privateAdd(this, _currentResult);
1640
- __privateAdd(this, _currentResultState);
1641
- __privateAdd(this, _currentResultOptions);
1642
- __privateAdd(this, _currentThenable);
1643
- __privateAdd(this, _selectError);
1644
- __privateAdd(this, _selectFn);
1645
- __privateAdd(this, _selectResult);
1646
- // This property keeps track of the last query with defined data.
1647
- // It will be used to pass the previous data and query to the placeholder function between renders.
1648
- __privateAdd(this, _lastQueryWithDefinedData);
1649
- __privateAdd(this, _staleTimeoutId);
1650
- __privateAdd(this, _refetchIntervalId);
1651
- __privateAdd(this, _currentRefetchInterval);
1652
- __privateAdd(this, _trackedProps, /* @__PURE__ */ new Set());
1653
- this.options = options;
1654
- __privateSet(this, _client, client);
1655
- __privateSet(this, _selectError, null);
1656
- __privateSet(this, _currentThenable, pendingThenable());
1657
- this.bindMethods();
1658
- this.setOptions(options);
1659
- }
1660
- bindMethods() {
1661
- this.refetch = this.refetch.bind(this);
1662
- }
1663
- onSubscribe() {
1664
- if (this.listeners.size === 1) {
1665
- __privateGet(this, _currentQuery).addObserver(this);
1666
- if (shouldFetchOnMount(__privateGet(this, _currentQuery), this.options)) {
1667
- __privateMethod(this, _QueryObserver_instances, executeFetch_fn).call(this);
1668
- } else {
1669
- this.updateResult();
1670
- }
1671
- __privateMethod(this, _QueryObserver_instances, updateTimers_fn).call(this);
1672
- }
1673
- }
1674
- onUnsubscribe() {
1675
- if (!this.hasListeners()) {
1676
- this.destroy();
1677
- }
1678
- }
1679
- shouldFetchOnReconnect() {
1680
- return shouldFetchOn(
1681
- __privateGet(this, _currentQuery),
1682
- this.options,
1683
- this.options.refetchOnReconnect
1684
- );
1685
- }
1686
- shouldFetchOnWindowFocus() {
1687
- return shouldFetchOn(
1688
- __privateGet(this, _currentQuery),
1689
- this.options,
1690
- this.options.refetchOnWindowFocus
1691
- );
1692
- }
1693
- destroy() {
1694
- this.listeners = /* @__PURE__ */ new Set();
1695
- __privateMethod(this, _QueryObserver_instances, clearStaleTimeout_fn).call(this);
1696
- __privateMethod(this, _QueryObserver_instances, clearRefetchInterval_fn).call(this);
1697
- __privateGet(this, _currentQuery).removeObserver(this);
1698
- }
1699
- setOptions(options) {
1700
- const prevOptions = this.options;
1701
- const prevQuery = __privateGet(this, _currentQuery);
1702
- this.options = __privateGet(this, _client).defaultQueryOptions(options);
1703
- if (this.options.enabled !== void 0 && typeof this.options.enabled !== "boolean" && typeof this.options.enabled !== "function" && typeof resolveEnabled(this.options.enabled, __privateGet(this, _currentQuery)) !== "boolean") {
1704
- throw new Error(
1705
- "Expected enabled to be a boolean or a callback that returns a boolean"
1706
- );
1707
- }
1708
- __privateMethod(this, _QueryObserver_instances, updateQuery_fn).call(this);
1709
- __privateGet(this, _currentQuery).setOptions(this.options);
1710
- if (prevOptions._defaulted && !shallowEqualObjects(this.options, prevOptions)) {
1711
- __privateGet(this, _client).getQueryCache().notify({
1712
- type: "observerOptionsUpdated",
1713
- query: __privateGet(this, _currentQuery),
1714
- observer: this
1715
- });
1716
- }
1717
- const mounted = this.hasListeners();
1718
- if (mounted && shouldFetchOptionally(
1719
- __privateGet(this, _currentQuery),
1720
- prevQuery,
1721
- this.options,
1722
- prevOptions
1723
- )) {
1724
- __privateMethod(this, _QueryObserver_instances, executeFetch_fn).call(this);
1725
- }
1726
- this.updateResult();
1727
- if (mounted && (__privateGet(this, _currentQuery) !== prevQuery || resolveEnabled(this.options.enabled, __privateGet(this, _currentQuery)) !== resolveEnabled(prevOptions.enabled, __privateGet(this, _currentQuery)) || resolveStaleTime(this.options.staleTime, __privateGet(this, _currentQuery)) !== resolveStaleTime(prevOptions.staleTime, __privateGet(this, _currentQuery)))) {
1728
- __privateMethod(this, _QueryObserver_instances, updateStaleTimeout_fn).call(this);
1729
- }
1730
- const nextRefetchInterval = __privateMethod(this, _QueryObserver_instances, computeRefetchInterval_fn).call(this);
1731
- if (mounted && (__privateGet(this, _currentQuery) !== prevQuery || resolveEnabled(this.options.enabled, __privateGet(this, _currentQuery)) !== resolveEnabled(prevOptions.enabled, __privateGet(this, _currentQuery)) || nextRefetchInterval !== __privateGet(this, _currentRefetchInterval))) {
1732
- __privateMethod(this, _QueryObserver_instances, updateRefetchInterval_fn).call(this, nextRefetchInterval);
1733
- }
1734
- }
1735
- getOptimisticResult(options) {
1736
- const query = __privateGet(this, _client).getQueryCache().build(__privateGet(this, _client), options);
1737
- const result = this.createResult(query, options);
1738
- if (shouldAssignObserverCurrentProperties(this, result)) {
1739
- __privateSet(this, _currentResult, result);
1740
- __privateSet(this, _currentResultOptions, this.options);
1741
- __privateSet(this, _currentResultState, __privateGet(this, _currentQuery).state);
1742
- }
1743
- return result;
1744
- }
1745
- getCurrentResult() {
1746
- return __privateGet(this, _currentResult);
1747
- }
1748
- trackResult(result, onPropTracked) {
1749
- return new Proxy(result, {
1750
- get: (target, key) => {
1751
- this.trackProp(key);
1752
- onPropTracked?.(key);
1753
- if (key === "promise") {
1754
- this.trackProp("data");
1755
- if (!this.options.experimental_prefetchInRender && __privateGet(this, _currentThenable).status === "pending") {
1756
- __privateGet(this, _currentThenable).reject(
1757
- new Error(
1758
- "experimental_prefetchInRender feature flag is not enabled"
1759
- )
1760
- );
1761
- }
1762
- }
1763
- return Reflect.get(target, key);
1764
- }
1765
- });
1766
- }
1767
- trackProp(key) {
1768
- __privateGet(this, _trackedProps).add(key);
1769
- }
1770
- getCurrentQuery() {
1771
- return __privateGet(this, _currentQuery);
1772
- }
1773
- refetch({ ...options } = {}) {
1774
- return this.fetch({
1775
- ...options
1776
- });
1777
- }
1778
- fetchOptimistic(options) {
1779
- const defaultedOptions = __privateGet(this, _client).defaultQueryOptions(options);
1780
- const query = __privateGet(this, _client).getQueryCache().build(__privateGet(this, _client), defaultedOptions);
1781
- return query.fetch().then(() => this.createResult(query, defaultedOptions));
1782
- }
1783
- fetch(fetchOptions) {
1784
- return __privateMethod(this, _QueryObserver_instances, executeFetch_fn).call(this, {
1785
- ...fetchOptions,
1786
- cancelRefetch: fetchOptions.cancelRefetch ?? true
1787
- }).then(() => {
1788
- this.updateResult();
1789
- return __privateGet(this, _currentResult);
1790
- });
1791
- }
1792
- createResult(query, options) {
1793
- const prevQuery = __privateGet(this, _currentQuery);
1794
- const prevOptions = this.options;
1795
- const prevResult = __privateGet(this, _currentResult);
1796
- const prevResultState = __privateGet(this, _currentResultState);
1797
- const prevResultOptions = __privateGet(this, _currentResultOptions);
1798
- const queryChange = query !== prevQuery;
1799
- const queryInitialState = queryChange ? query.state : __privateGet(this, _currentQueryInitialState);
1800
- const { state } = query;
1801
- let newState = { ...state };
1802
- let isPlaceholderData = false;
1803
- let data;
1804
- if (options._optimisticResults) {
1805
- const mounted = this.hasListeners();
1806
- const fetchOnMount = !mounted && shouldFetchOnMount(query, options);
1807
- const fetchOptionally = mounted && shouldFetchOptionally(query, prevQuery, options, prevOptions);
1808
- if (fetchOnMount || fetchOptionally) {
1809
- newState = {
1810
- ...newState,
1811
- ...fetchState(state.data, query.options)
1812
- };
1813
- }
1814
- if (options._optimisticResults === "isRestoring") {
1815
- newState.fetchStatus = "idle";
1816
- }
1817
- }
1818
- let { error, errorUpdatedAt, status } = newState;
1819
- data = newState.data;
1820
- let skipSelect = false;
1821
- if (options.placeholderData !== void 0 && data === void 0 && status === "pending") {
1822
- let placeholderData;
1823
- if (prevResult?.isPlaceholderData && options.placeholderData === prevResultOptions?.placeholderData) {
1824
- placeholderData = prevResult.data;
1825
- skipSelect = true;
1826
- } else {
1827
- placeholderData = typeof options.placeholderData === "function" ? options.placeholderData(
1828
- __privateGet(this, _lastQueryWithDefinedData)?.state.data,
1829
- __privateGet(this, _lastQueryWithDefinedData)
1830
- ) : options.placeholderData;
1831
- }
1832
- if (placeholderData !== void 0) {
1833
- status = "success";
1834
- data = replaceData(
1835
- prevResult?.data,
1836
- placeholderData,
1837
- options
1838
- );
1839
- isPlaceholderData = true;
1840
- }
1841
- }
1842
- if (options.select && data !== void 0 && !skipSelect) {
1843
- if (prevResult && data === prevResultState?.data && options.select === __privateGet(this, _selectFn)) {
1844
- data = __privateGet(this, _selectResult);
1845
- } else {
1846
- try {
1847
- __privateSet(this, _selectFn, options.select);
1848
- data = options.select(data);
1849
- data = replaceData(prevResult?.data, data, options);
1850
- __privateSet(this, _selectResult, data);
1851
- __privateSet(this, _selectError, null);
1852
- } catch (selectError) {
1853
- __privateSet(this, _selectError, selectError);
1854
- }
1855
- }
1856
- }
1857
- if (__privateGet(this, _selectError)) {
1858
- error = __privateGet(this, _selectError);
1859
- data = __privateGet(this, _selectResult);
1860
- errorUpdatedAt = Date.now();
1861
- status = "error";
1862
- }
1863
- const isFetching = newState.fetchStatus === "fetching";
1864
- const isPending = status === "pending";
1865
- const isError = status === "error";
1866
- const isLoading = isPending && isFetching;
1867
- const hasData = data !== void 0;
1868
- const result = {
1869
- status,
1870
- fetchStatus: newState.fetchStatus,
1871
- isPending,
1872
- isSuccess: status === "success",
1873
- isError,
1874
- isInitialLoading: isLoading,
1875
- isLoading,
1876
- data,
1877
- dataUpdatedAt: newState.dataUpdatedAt,
1878
- error,
1879
- errorUpdatedAt,
1880
- failureCount: newState.fetchFailureCount,
1881
- failureReason: newState.fetchFailureReason,
1882
- errorUpdateCount: newState.errorUpdateCount,
1883
- isFetched: newState.dataUpdateCount > 0 || newState.errorUpdateCount > 0,
1884
- isFetchedAfterMount: newState.dataUpdateCount > queryInitialState.dataUpdateCount || newState.errorUpdateCount > queryInitialState.errorUpdateCount,
1885
- isFetching,
1886
- isRefetching: isFetching && !isPending,
1887
- isLoadingError: isError && !hasData,
1888
- isPaused: newState.fetchStatus === "paused",
1889
- isPlaceholderData,
1890
- isRefetchError: isError && hasData,
1891
- isStale: isStale(query, options),
1892
- refetch: this.refetch,
1893
- promise: __privateGet(this, _currentThenable),
1894
- isEnabled: resolveEnabled(options.enabled, query) !== false
1895
- };
1896
- const nextResult = result;
1897
- if (this.options.experimental_prefetchInRender) {
1898
- const hasResultData = nextResult.data !== void 0;
1899
- const isErrorWithoutData = nextResult.status === "error" && !hasResultData;
1900
- const finalizeThenableIfPossible = (thenable) => {
1901
- if (isErrorWithoutData) {
1902
- thenable.reject(nextResult.error);
1903
- } else if (hasResultData) {
1904
- thenable.resolve(nextResult.data);
1905
- }
1906
- };
1907
- const recreateThenable = () => {
1908
- const pending = __privateSet(this, _currentThenable, nextResult.promise = pendingThenable());
1909
- finalizeThenableIfPossible(pending);
1910
- };
1911
- const prevThenable = __privateGet(this, _currentThenable);
1912
- switch (prevThenable.status) {
1913
- case "pending":
1914
- if (query.queryHash === prevQuery.queryHash) {
1915
- finalizeThenableIfPossible(prevThenable);
1916
- }
1917
- break;
1918
- case "fulfilled":
1919
- if (isErrorWithoutData || nextResult.data !== prevThenable.value) {
1920
- recreateThenable();
1921
- }
1922
- break;
1923
- case "rejected":
1924
- if (!isErrorWithoutData || nextResult.error !== prevThenable.reason) {
1925
- recreateThenable();
1926
- }
1927
- break;
1928
- }
1929
- }
1930
- return nextResult;
1931
- }
1932
- updateResult() {
1933
- const prevResult = __privateGet(this, _currentResult);
1934
- const nextResult = this.createResult(__privateGet(this, _currentQuery), this.options);
1935
- __privateSet(this, _currentResultState, __privateGet(this, _currentQuery).state);
1936
- __privateSet(this, _currentResultOptions, this.options);
1937
- if (__privateGet(this, _currentResultState).data !== void 0) {
1938
- __privateSet(this, _lastQueryWithDefinedData, __privateGet(this, _currentQuery));
1939
- }
1940
- if (shallowEqualObjects(nextResult, prevResult)) {
1941
- return;
1942
- }
1943
- __privateSet(this, _currentResult, nextResult);
1944
- const shouldNotifyListeners = () => {
1945
- if (!prevResult) {
1946
- return true;
1947
- }
1948
- const { notifyOnChangeProps } = this.options;
1949
- const notifyOnChangePropsValue = typeof notifyOnChangeProps === "function" ? notifyOnChangeProps() : notifyOnChangeProps;
1950
- if (notifyOnChangePropsValue === "all" || !notifyOnChangePropsValue && !__privateGet(this, _trackedProps).size) {
1951
- return true;
1952
- }
1953
- const includedProps = new Set(
1954
- notifyOnChangePropsValue ?? __privateGet(this, _trackedProps)
1955
- );
1956
- if (this.options.throwOnError) {
1957
- includedProps.add("error");
1958
- }
1959
- return Object.keys(__privateGet(this, _currentResult)).some((key) => {
1960
- const typedKey = key;
1961
- const changed = __privateGet(this, _currentResult)[typedKey] !== prevResult[typedKey];
1962
- return changed && includedProps.has(typedKey);
1963
- });
1964
- };
1965
- __privateMethod(this, _QueryObserver_instances, notify_fn).call(this, { listeners: shouldNotifyListeners() });
1966
- }
1967
- onQueryUpdate() {
1968
- this.updateResult();
1969
- if (this.hasListeners()) {
1970
- __privateMethod(this, _QueryObserver_instances, updateTimers_fn).call(this);
1971
- }
1972
- }
1973
- }, _client = new WeakMap(), _currentQuery = new WeakMap(), _currentQueryInitialState = new WeakMap(), _currentResult = new WeakMap(), _currentResultState = new WeakMap(), _currentResultOptions = new WeakMap(), _currentThenable = new WeakMap(), _selectError = new WeakMap(), _selectFn = new WeakMap(), _selectResult = new WeakMap(), _lastQueryWithDefinedData = new WeakMap(), _staleTimeoutId = new WeakMap(), _refetchIntervalId = new WeakMap(), _currentRefetchInterval = new WeakMap(), _trackedProps = new WeakMap(), _QueryObserver_instances = new WeakSet(), executeFetch_fn = function(fetchOptions) {
1974
- __privateMethod(this, _QueryObserver_instances, updateQuery_fn).call(this);
1975
- let promise = __privateGet(this, _currentQuery).fetch(
1976
- this.options,
1977
- fetchOptions
1978
- );
1979
- if (!fetchOptions?.throwOnError) {
1980
- promise = promise.catch(noop);
1981
- }
1982
- return promise;
1983
- }, updateStaleTimeout_fn = function() {
1984
- __privateMethod(this, _QueryObserver_instances, clearStaleTimeout_fn).call(this);
1985
- const staleTime = resolveStaleTime(
1986
- this.options.staleTime,
1987
- __privateGet(this, _currentQuery)
1988
- );
1989
- if (isServer || __privateGet(this, _currentResult).isStale || !isValidTimeout(staleTime)) {
1990
- return;
1991
- }
1992
- const time = timeUntilStale(__privateGet(this, _currentResult).dataUpdatedAt, staleTime);
1993
- const timeout = time + 1;
1994
- __privateSet(this, _staleTimeoutId, timeoutManager.setTimeout(() => {
1995
- if (!__privateGet(this, _currentResult).isStale) {
1996
- this.updateResult();
1997
- }
1998
- }, timeout));
1999
- }, computeRefetchInterval_fn = function() {
2000
- return (typeof this.options.refetchInterval === "function" ? this.options.refetchInterval(__privateGet(this, _currentQuery)) : this.options.refetchInterval) ?? false;
2001
- }, updateRefetchInterval_fn = function(nextInterval) {
2002
- __privateMethod(this, _QueryObserver_instances, clearRefetchInterval_fn).call(this);
2003
- __privateSet(this, _currentRefetchInterval, nextInterval);
2004
- if (isServer || resolveEnabled(this.options.enabled, __privateGet(this, _currentQuery)) === false || !isValidTimeout(__privateGet(this, _currentRefetchInterval)) || __privateGet(this, _currentRefetchInterval) === 0) {
2005
- return;
2006
- }
2007
- __privateSet(this, _refetchIntervalId, timeoutManager.setInterval(() => {
2008
- if (this.options.refetchIntervalInBackground || focusManager.isFocused()) {
2009
- __privateMethod(this, _QueryObserver_instances, executeFetch_fn).call(this);
2010
- }
2011
- }, __privateGet(this, _currentRefetchInterval)));
2012
- }, updateTimers_fn = function() {
2013
- __privateMethod(this, _QueryObserver_instances, updateStaleTimeout_fn).call(this);
2014
- __privateMethod(this, _QueryObserver_instances, updateRefetchInterval_fn).call(this, __privateMethod(this, _QueryObserver_instances, computeRefetchInterval_fn).call(this));
2015
- }, clearStaleTimeout_fn = function() {
2016
- if (__privateGet(this, _staleTimeoutId)) {
2017
- timeoutManager.clearTimeout(__privateGet(this, _staleTimeoutId));
2018
- __privateSet(this, _staleTimeoutId, void 0);
2019
- }
2020
- }, clearRefetchInterval_fn = function() {
2021
- if (__privateGet(this, _refetchIntervalId)) {
2022
- timeoutManager.clearInterval(__privateGet(this, _refetchIntervalId));
2023
- __privateSet(this, _refetchIntervalId, void 0);
2024
- }
2025
- }, updateQuery_fn = function() {
2026
- const query = __privateGet(this, _client).getQueryCache().build(__privateGet(this, _client), this.options);
2027
- if (query === __privateGet(this, _currentQuery)) {
2028
- return;
2029
- }
2030
- const prevQuery = __privateGet(this, _currentQuery);
2031
- __privateSet(this, _currentQuery, query);
2032
- __privateSet(this, _currentQueryInitialState, query.state);
2033
- if (this.hasListeners()) {
2034
- prevQuery?.removeObserver(this);
2035
- query.addObserver(this);
2036
- }
2037
- }, notify_fn = function(notifyOptions) {
2038
- notifyManager.batch(() => {
2039
- if (notifyOptions.listeners) {
2040
- this.listeners.forEach((listener) => {
2041
- listener(__privateGet(this, _currentResult));
2042
- });
2043
- }
2044
- __privateGet(this, _client).getQueryCache().notify({
2045
- query: __privateGet(this, _currentQuery),
2046
- type: "observerResultsUpdated"
2047
- });
2048
- });
2049
- }, _a4);
2050
- function shouldLoadOnMount(query, options) {
2051
- return resolveEnabled(options.enabled, query) !== false && query.state.data === void 0 && !(query.state.status === "error" && options.retryOnMount === false);
2052
- }
2053
- function shouldFetchOnMount(query, options) {
2054
- return shouldLoadOnMount(query, options) || query.state.data !== void 0 && shouldFetchOn(query, options, options.refetchOnMount);
2055
- }
2056
- function shouldFetchOn(query, options, field) {
2057
- if (resolveEnabled(options.enabled, query) !== false && resolveStaleTime(options.staleTime, query) !== "static") {
2058
- const value = typeof field === "function" ? field(query) : field;
2059
- return value === "always" || value !== false && isStale(query, options);
2060
- }
2061
- return false;
2062
- }
2063
- function shouldFetchOptionally(query, prevQuery, options, prevOptions) {
2064
- return (query !== prevQuery || resolveEnabled(prevOptions.enabled, query) === false) && (!options.suspense || query.state.status !== "error") && isStale(query, options);
2065
- }
2066
- function isStale(query, options) {
2067
- return resolveEnabled(options.enabled, query) !== false && query.isStaleByTime(resolveStaleTime(options.staleTime, query));
2068
- }
2069
- function shouldAssignObserverCurrentProperties(observer, optimisticResult) {
2070
- if (!shallowEqualObjects(observer.getCurrentResult(), optimisticResult)) {
2071
- return true;
2072
- }
2073
- return false;
2074
- }
2075
-
2076
- // ../../node_modules/.pnpm/@tanstack+query-core@5.90.20/node_modules/@tanstack/query-core/build/modern/mutation.js
2077
- function getDefaultState() {
2078
- return {
2079
- context: void 0,
2080
- data: void 0,
2081
- error: null,
2082
- failureCount: 0,
2083
- failureReason: null,
2084
- isPaused: false,
2085
- status: "idle",
2086
- variables: void 0,
2087
- submittedAt: 0
2088
- };
2089
- }
2090
-
2091
- // ../../node_modules/.pnpm/@tanstack+query-core@5.90.20/node_modules/@tanstack/query-core/build/modern/mutationObserver.js
2092
- var _client2, _currentResult2, _currentMutation, _mutateOptions, _MutationObserver_instances, updateResult_fn, notify_fn2, _a5;
2093
- var MutationObserver = (_a5 = class extends Subscribable {
2094
- constructor(client, options) {
2095
- super();
2096
- __privateAdd(this, _MutationObserver_instances);
2097
- __privateAdd(this, _client2);
2098
- __privateAdd(this, _currentResult2);
2099
- __privateAdd(this, _currentMutation);
2100
- __privateAdd(this, _mutateOptions);
2101
- __privateSet(this, _client2, client);
2102
- this.setOptions(options);
2103
- this.bindMethods();
2104
- __privateMethod(this, _MutationObserver_instances, updateResult_fn).call(this);
2105
- }
2106
- bindMethods() {
2107
- this.mutate = this.mutate.bind(this);
2108
- this.reset = this.reset.bind(this);
2109
- }
2110
- setOptions(options) {
2111
- const prevOptions = this.options;
2112
- this.options = __privateGet(this, _client2).defaultMutationOptions(options);
2113
- if (!shallowEqualObjects(this.options, prevOptions)) {
2114
- __privateGet(this, _client2).getMutationCache().notify({
2115
- type: "observerOptionsUpdated",
2116
- mutation: __privateGet(this, _currentMutation),
2117
- observer: this
2118
- });
2119
- }
2120
- if (prevOptions?.mutationKey && this.options.mutationKey && hashKey(prevOptions.mutationKey) !== hashKey(this.options.mutationKey)) {
2121
- this.reset();
2122
- } else if (__privateGet(this, _currentMutation)?.state.status === "pending") {
2123
- __privateGet(this, _currentMutation).setOptions(this.options);
2124
- }
2125
- }
2126
- onUnsubscribe() {
2127
- if (!this.hasListeners()) {
2128
- __privateGet(this, _currentMutation)?.removeObserver(this);
2129
- }
2130
- }
2131
- onMutationUpdate(action) {
2132
- __privateMethod(this, _MutationObserver_instances, updateResult_fn).call(this);
2133
- __privateMethod(this, _MutationObserver_instances, notify_fn2).call(this, action);
2134
- }
2135
- getCurrentResult() {
2136
- return __privateGet(this, _currentResult2);
2137
- }
2138
- reset() {
2139
- __privateGet(this, _currentMutation)?.removeObserver(this);
2140
- __privateSet(this, _currentMutation, void 0);
2141
- __privateMethod(this, _MutationObserver_instances, updateResult_fn).call(this);
2142
- __privateMethod(this, _MutationObserver_instances, notify_fn2).call(this);
2143
- }
2144
- mutate(variables, options) {
2145
- __privateSet(this, _mutateOptions, options);
2146
- __privateGet(this, _currentMutation)?.removeObserver(this);
2147
- __privateSet(this, _currentMutation, __privateGet(this, _client2).getMutationCache().build(__privateGet(this, _client2), this.options));
2148
- __privateGet(this, _currentMutation).addObserver(this);
2149
- return __privateGet(this, _currentMutation).execute(variables);
2150
- }
2151
- }, _client2 = new WeakMap(), _currentResult2 = new WeakMap(), _currentMutation = new WeakMap(), _mutateOptions = new WeakMap(), _MutationObserver_instances = new WeakSet(), updateResult_fn = function() {
2152
- const state = __privateGet(this, _currentMutation)?.state ?? getDefaultState();
2153
- __privateSet(this, _currentResult2, {
2154
- ...state,
2155
- isPending: state.status === "pending",
2156
- isSuccess: state.status === "success",
2157
- isError: state.status === "error",
2158
- isIdle: state.status === "idle",
2159
- mutate: this.mutate,
2160
- reset: this.reset
2161
- });
2162
- }, notify_fn2 = function(action) {
2163
- notifyManager.batch(() => {
2164
- if (__privateGet(this, _mutateOptions) && this.hasListeners()) {
2165
- const variables = __privateGet(this, _currentResult2).variables;
2166
- const onMutateResult = __privateGet(this, _currentResult2).context;
2167
- const context = {
2168
- client: __privateGet(this, _client2),
2169
- meta: this.options.meta,
2170
- mutationKey: this.options.mutationKey
2171
- };
2172
- if (action?.type === "success") {
2173
- try {
2174
- __privateGet(this, _mutateOptions).onSuccess?.(
2175
- action.data,
2176
- variables,
2177
- onMutateResult,
2178
- context
2179
- );
2180
- } catch (e) {
2181
- void Promise.reject(e);
2182
- }
2183
- try {
2184
- __privateGet(this, _mutateOptions).onSettled?.(
2185
- action.data,
2186
- null,
2187
- variables,
2188
- onMutateResult,
2189
- context
2190
- );
2191
- } catch (e) {
2192
- void Promise.reject(e);
2193
- }
2194
- } else if (action?.type === "error") {
2195
- try {
2196
- __privateGet(this, _mutateOptions).onError?.(
2197
- action.error,
2198
- variables,
2199
- onMutateResult,
2200
- context
2201
- );
2202
- } catch (e) {
2203
- void Promise.reject(e);
2204
- }
2205
- try {
2206
- __privateGet(this, _mutateOptions).onSettled?.(
2207
- void 0,
2208
- action.error,
2209
- variables,
2210
- onMutateResult,
2211
- context
2212
- );
2213
- } catch (e) {
2214
- void Promise.reject(e);
2215
- }
2216
- }
2217
- }
2218
- this.listeners.forEach((listener) => {
2219
- listener(__privateGet(this, _currentResult2));
2220
- });
2221
- });
2222
- }, _a5);
2223
- var QueryClientContext = React6.createContext(
2224
- void 0
2225
- );
2226
- var useQueryClient = (queryClient) => {
2227
- const client = React6.useContext(QueryClientContext);
2228
- if (!client) {
2229
- throw new Error("No QueryClient set, use QueryClientProvider to set one");
2230
- }
2231
- return client;
2232
- };
2233
- var IsRestoringContext = React6.createContext(false);
2234
- var useIsRestoring = () => React6.useContext(IsRestoringContext);
2235
- IsRestoringContext.Provider;
2236
- function createValue() {
2237
- let isReset = false;
2238
- return {
2239
- clearReset: () => {
2240
- isReset = false;
2241
- },
2242
- reset: () => {
2243
- isReset = true;
2244
- },
2245
- isReset: () => {
2246
- return isReset;
2247
- }
2248
- };
2249
- }
2250
- var QueryErrorResetBoundaryContext = React6.createContext(createValue());
2251
- var useQueryErrorResetBoundary = () => React6.useContext(QueryErrorResetBoundaryContext);
2252
- var ensurePreventErrorBoundaryRetry = (options, errorResetBoundary, query) => {
2253
- const throwOnError = query?.state.error && typeof options.throwOnError === "function" ? shouldThrowError(options.throwOnError, [query.state.error, query]) : options.throwOnError;
2254
- if (options.suspense || options.experimental_prefetchInRender || throwOnError) {
2255
- if (!errorResetBoundary.isReset()) {
2256
- options.retryOnMount = false;
2257
- }
2258
- }
2259
- };
2260
- var useClearResetErrorBoundary = (errorResetBoundary) => {
2261
- React6.useEffect(() => {
2262
- errorResetBoundary.clearReset();
2263
- }, [errorResetBoundary]);
2264
- };
2265
- var getHasError = ({
2266
- result,
2267
- errorResetBoundary,
2268
- throwOnError,
2269
- query,
2270
- suspense
2271
- }) => {
2272
- return result.isError && !errorResetBoundary.isReset() && !result.isFetching && query && (suspense && result.data === void 0 || shouldThrowError(throwOnError, [result.error, query]));
2273
- };
2274
-
2275
- // ../../node_modules/.pnpm/@tanstack+react-query@5.90.20_react@18.3.1/node_modules/@tanstack/react-query/build/modern/suspense.js
2276
- var ensureSuspenseTimers = (defaultedOptions) => {
2277
- if (defaultedOptions.suspense) {
2278
- const MIN_SUSPENSE_TIME_MS = 1e3;
2279
- const clamp = (value) => value === "static" ? value : Math.max(value ?? MIN_SUSPENSE_TIME_MS, MIN_SUSPENSE_TIME_MS);
2280
- const originalStaleTime = defaultedOptions.staleTime;
2281
- defaultedOptions.staleTime = typeof originalStaleTime === "function" ? (...args) => clamp(originalStaleTime(...args)) : clamp(originalStaleTime);
2282
- if (typeof defaultedOptions.gcTime === "number") {
2283
- defaultedOptions.gcTime = Math.max(
2284
- defaultedOptions.gcTime,
2285
- MIN_SUSPENSE_TIME_MS
2286
- );
2287
- }
2288
- }
2289
- };
2290
- var willFetch = (result, isRestoring) => result.isLoading && result.isFetching && !isRestoring;
2291
- var shouldSuspend = (defaultedOptions, result) => defaultedOptions?.suspense && result.isPending;
2292
- var fetchOptimistic = (defaultedOptions, observer, errorResetBoundary) => observer.fetchOptimistic(defaultedOptions).catch(() => {
2293
- errorResetBoundary.clearReset();
2294
- });
2295
- function useBaseQuery(options, Observer, queryClient) {
2296
- if (process.env.NODE_ENV !== "production") {
2297
- if (typeof options !== "object" || Array.isArray(options)) {
2298
- throw new Error(
2299
- 'Bad argument type. Starting with v5, only the "Object" form is allowed when calling query related functions. Please use the error stack to find the culprit call. More info here: https://tanstack.com/query/latest/docs/react/guides/migrating-to-v5#supports-a-single-signature-one-object'
2300
- );
2301
- }
2302
- }
2303
- const isRestoring = useIsRestoring();
2304
- const errorResetBoundary = useQueryErrorResetBoundary();
2305
- const client = useQueryClient();
2306
- const defaultedOptions = client.defaultQueryOptions(options);
2307
- client.getDefaultOptions().queries?._experimental_beforeQuery?.(
2308
- defaultedOptions
2309
- );
2310
- const query = client.getQueryCache().get(defaultedOptions.queryHash);
2311
- if (process.env.NODE_ENV !== "production") {
2312
- if (!defaultedOptions.queryFn) {
2313
- console.error(
2314
- `[${defaultedOptions.queryHash}]: No queryFn was passed as an option, and no default queryFn was found. The queryFn parameter is only optional when using a default queryFn. More info here: https://tanstack.com/query/latest/docs/framework/react/guides/default-query-function`
2315
- );
2316
- }
2317
- }
2318
- defaultedOptions._optimisticResults = isRestoring ? "isRestoring" : "optimistic";
2319
- ensureSuspenseTimers(defaultedOptions);
2320
- ensurePreventErrorBoundaryRetry(defaultedOptions, errorResetBoundary, query);
2321
- useClearResetErrorBoundary(errorResetBoundary);
2322
- const isNewCacheEntry = !client.getQueryCache().get(defaultedOptions.queryHash);
2323
- const [observer] = React6.useState(
2324
- () => new Observer(
2325
- client,
2326
- defaultedOptions
2327
- )
2328
- );
2329
- const result = observer.getOptimisticResult(defaultedOptions);
2330
- const shouldSubscribe = !isRestoring && options.subscribed !== false;
2331
- React6.useSyncExternalStore(
2332
- React6.useCallback(
2333
- (onStoreChange) => {
2334
- const unsubscribe = shouldSubscribe ? observer.subscribe(notifyManager.batchCalls(onStoreChange)) : noop;
2335
- observer.updateResult();
2336
- return unsubscribe;
2337
- },
2338
- [observer, shouldSubscribe]
2339
- ),
2340
- () => observer.getCurrentResult(),
2341
- () => observer.getCurrentResult()
2342
- );
2343
- React6.useEffect(() => {
2344
- observer.setOptions(defaultedOptions);
2345
- }, [defaultedOptions, observer]);
2346
- if (shouldSuspend(defaultedOptions, result)) {
2347
- throw fetchOptimistic(defaultedOptions, observer, errorResetBoundary);
2348
- }
2349
- if (getHasError({
2350
- result,
2351
- errorResetBoundary,
2352
- throwOnError: defaultedOptions.throwOnError,
2353
- query,
2354
- suspense: defaultedOptions.suspense
2355
- })) {
2356
- throw result.error;
2357
- }
2358
- client.getDefaultOptions().queries?._experimental_afterQuery?.(
2359
- defaultedOptions,
2360
- result
2361
- );
2362
- if (defaultedOptions.experimental_prefetchInRender && !isServer && willFetch(result, isRestoring)) {
2363
- const promise = isNewCacheEntry ? (
2364
- // Fetch immediately on render in order to ensure `.promise` is resolved even if the component is unmounted
2365
- fetchOptimistic(defaultedOptions, observer, errorResetBoundary)
2366
- ) : (
2367
- // subscribe to the "cache promise" so that we can finalize the currentThenable once data comes in
2368
- query?.promise
2369
- );
2370
- promise?.catch(noop).finally(() => {
2371
- observer.updateResult();
2372
- });
2373
- }
2374
- return !defaultedOptions.notifyOnChangeProps ? observer.trackResult(result) : result;
2375
- }
2376
-
2377
- // ../../node_modules/.pnpm/@tanstack+react-query@5.90.20_react@18.3.1/node_modules/@tanstack/react-query/build/modern/useQuery.js
2378
- function useQuery(options, queryClient) {
2379
- return useBaseQuery(options, QueryObserver);
2380
- }
2381
- function useMutation(options, queryClient) {
2382
- const client = useQueryClient();
2383
- const [observer] = React6.useState(
2384
- () => new MutationObserver(
2385
- client,
2386
- options
2387
- )
2388
- );
2389
- React6.useEffect(() => {
2390
- observer.setOptions(options);
2391
- }, [observer, options]);
2392
- const result = React6.useSyncExternalStore(
2393
- React6.useCallback(
2394
- (onStoreChange) => observer.subscribe(notifyManager.batchCalls(onStoreChange)),
2395
- [observer]
2396
- ),
2397
- () => observer.getCurrentResult(),
2398
- () => observer.getCurrentResult()
2399
- );
2400
- const mutate = React6.useCallback(
2401
- (variables, mutateOptions) => {
2402
- observer.mutate(variables, mutateOptions).catch(noop);
2403
- },
2404
- [observer]
2405
- );
2406
- if (result.error && shouldThrowError(observer.options.throwOnError, [result.error])) {
2407
- throw result.error;
2408
- }
2409
- return { ...result, mutate, mutateAsync: result.mutate };
2410
- }
2411
-
2412
- // hooks/useOrbitalMutations.ts
2413
1166
  var ENTITY_EVENTS = {
2414
1167
  CREATE: "ENTITY_CREATE",
2415
1168
  UPDATE: "ENTITY_UPDATE",