@hipnation-truth/sdk 0.23.2 → 0.25.1

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/react.js CHANGED
@@ -4,8 +4,10 @@ var __defProp = Object.defineProperty;
4
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __getOwnPropSymbols = Object.getOwnPropertySymbols;
7
+ var __getProtoOf = Object.getPrototypeOf;
7
8
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
9
  var __propIsEnum = Object.prototype.propertyIsEnumerable;
10
+ var __reflectGet = Reflect.get;
9
11
  var __pow = Math.pow;
10
12
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
11
13
  var __spreadValues = (a, b) => {
@@ -32,6 +34,7 @@ var __copyProps = (to, from, except, desc) => {
32
34
  return to;
33
35
  };
34
36
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
37
+ var __superGet = (cls, obj, key) => __reflectGet(__getProtoOf(cls), key, obj);
35
38
  var __async = (__this, __arguments, generator) => {
36
39
  return new Promise((resolve, reject) => {
37
40
  var fulfilled = (value) => {
@@ -61,11 +64,13 @@ __export(react_exports, {
61
64
  CONNECTED_CALL_STATES: () => CONNECTED_CALL_STATES,
62
65
  CONVEX_URLS: () => CONVEX_URLS2,
63
66
  DialpadCallState: () => DialpadCallState,
67
+ NoopStore: () => NoopStore,
64
68
  RINGING_CALL_STATES: () => RINGING_CALL_STATES,
65
69
  TERMINAL_CALL_STATES: () => TERMINAL_CALL_STATES,
66
70
  TruthProvider: () => TruthProvider,
67
71
  TruthTrackingProvider: () => TruthTrackingProvider,
68
72
  getTruthClient: () => getTruthClient,
73
+ readPersistedSavedAt: () => readPersistedSavedAt,
69
74
  resolveApiBaseUrl: () => resolveApiBaseUrl,
70
75
  resolveConvexUrl: () => resolveConvexUrl,
71
76
  useActiveCalls: () => useActiveCalls,
@@ -88,6 +93,8 @@ __export(react_exports, {
88
93
  useMessages: () => useMessages,
89
94
  useNotifications: () => useNotifications,
90
95
  useNotificationsActions: () => useNotificationsActions,
96
+ useOfflineEnabled: () => useOfflineEnabled,
97
+ useOfflineStore: () => useOfflineStore,
91
98
  usePatient: () => usePatient,
92
99
  usePatientBasic: () => usePatientBasic,
93
100
  usePatientByElationId: () => usePatientByElationId,
@@ -117,6 +124,21 @@ module.exports = __toCommonJS(react_exports);
117
124
  // src/react/calls.ts
118
125
  var import_react = require("convex/react");
119
126
  var import_server = require("convex/server");
127
+
128
+ // src/react/offline/use-persistent-query.ts
129
+ var import_react_query = require("@convex-dev/react-query");
130
+ var import_react_query2 = require("@tanstack/react-query");
131
+ function usePersistentQuery(ref, args) {
132
+ const { data } = (0, import_react_query2.useQuery)(
133
+ (0, import_react_query.convexQuery)(
134
+ ref,
135
+ args
136
+ )
137
+ );
138
+ return data;
139
+ }
140
+
141
+ // src/react/calls.ts
120
142
  var DialpadCallState = {
121
143
  Calling: "calling",
122
144
  Ringing: "ringing",
@@ -163,7 +185,7 @@ function useActiveCalls(options) {
163
185
  }
164
186
  function useDialpadCallsForConversation(conversationId, options) {
165
187
  const skipped = !conversationId;
166
- const result = (0, import_react.useQuery)(
188
+ const result = usePersistentQuery(
167
189
  listForConversationRef,
168
190
  skipped ? SKIP : {
169
191
  conversationId,
@@ -174,7 +196,7 @@ function useDialpadCallsForConversation(conversationId, options) {
174
196
  }
175
197
  function useDialpadCallByCallId(callId) {
176
198
  const skipped = !callId;
177
- const result = (0, import_react.useQuery)(
199
+ const result = usePersistentQuery(
178
200
  getByCallIdRef,
179
201
  skipped ? SKIP : { callId }
180
202
  );
@@ -182,7 +204,7 @@ function useDialpadCallByCallId(callId) {
182
204
  }
183
205
  function useDialpadCallLog(callId, options) {
184
206
  const skipped = !callId;
185
- const result = (0, import_react.useQuery)(
207
+ const result = usePersistentQuery(
186
208
  listLogForCallIdRef,
187
209
  skipped ? SKIP : { callId, limit: options == null ? void 0 : options.limit }
188
210
  );
@@ -190,12 +212,11 @@ function useDialpadCallLog(callId, options) {
190
212
  }
191
213
 
192
214
  // src/react/conversation-by-id.ts
193
- var import_react2 = require("convex/react");
194
215
  var import_server2 = require("convex/server");
195
216
  var conversationsGetByIdRef = (0, import_server2.makeFunctionReference)("conversations:getById");
196
217
  function useConversationById(id) {
197
218
  const skipped = !id;
198
- const result = (0, import_react2.useQuery)(
219
+ const result = usePersistentQuery(
199
220
  conversationsGetByIdRef,
200
221
  skipped ? "skip" : { id }
201
222
  );
@@ -210,9 +231,8 @@ function useConversationById(id) {
210
231
  }
211
232
 
212
233
  // src/react/conversations.ts
213
- var import_react3 = require("convex/react");
214
234
  var import_server3 = require("convex/server");
215
- var import_react4 = require("react");
235
+ var import_react2 = require("react");
216
236
  var conversationsListForUserRef = (0, import_server3.makeFunctionReference)("conversations:listForUser");
217
237
  var conversationsSearchForUserRef = (0, import_server3.makeFunctionReference)("conversations:searchForUser");
218
238
  var conversationsGetUnreadTotalForUserRef = (0, import_server3.makeFunctionReference)("conversations:getUnreadTotalForUser");
@@ -240,14 +260,14 @@ function useConversations(filters) {
240
260
  const trimmedSearch = (_b = (_a = filters.search) == null ? void 0 : _a.trim()) != null ? _b : "";
241
261
  const isSearchMode = trimmedSearch.length > 0;
242
262
  const skipped = !filters.userId;
243
- const listResult = (0, import_react3.useQuery)(
263
+ const listResult = usePersistentQuery(
244
264
  conversationsListForUserRef,
245
265
  skipped || isSearchMode ? SKIP2 : {
246
266
  userId: filters.userId,
247
267
  limit: filters.limit
248
268
  }
249
269
  );
250
- const searchResult = (0, import_react3.useQuery)(
270
+ const searchResult = usePersistentQuery(
251
271
  conversationsSearchForUserRef,
252
272
  skipped || !isSearchMode ? SKIP2 : {
253
273
  userId: filters.userId,
@@ -259,7 +279,7 @@ function useConversations(filters) {
259
279
  }
260
280
  function useConversationByPhonePair(phonePair) {
261
281
  const skipped = !phonePair;
262
- const result = (0, import_react3.useQuery)(
282
+ const result = usePersistentQuery(
263
283
  conversationsGetByPhonePairRef,
264
284
  skipped ? SKIP2 : { phonePair }
265
285
  );
@@ -267,7 +287,7 @@ function useConversationByPhonePair(phonePair) {
267
287
  }
268
288
  function useMessages(conversationId, options) {
269
289
  const skipped = !conversationId;
270
- const result = (0, import_react3.useQuery)(
290
+ const result = usePersistentQuery(
271
291
  conversationMessagesGetByConversationIdRef,
272
292
  skipped ? SKIP2 : {
273
293
  conversationId,
@@ -278,7 +298,7 @@ function useMessages(conversationId, options) {
278
298
  }
279
299
  function useUnreadCount(userId) {
280
300
  const skipped = !userId;
281
- const result = (0, import_react3.useQuery)(
301
+ const result = usePersistentQuery(
282
302
  conversationsGetUnreadTotalForUserRef,
283
303
  skipped ? SKIP2 : { userId }
284
304
  );
@@ -288,7 +308,7 @@ function useUnreadAggregate(userId, options) {
288
308
  const skipped = !userId;
289
309
  const phones = options == null ? void 0 : options.providerPhones;
290
310
  const stablePhones = useMemoizedPhones(phones);
291
- const result = (0, import_react3.useQuery)(
311
+ const result = usePersistentQuery(
292
312
  conversationsGetUnreadAggregateForUserRef,
293
313
  skipped ? SKIP2 : {
294
314
  userId,
@@ -299,7 +319,7 @@ function useUnreadAggregate(userId, options) {
299
319
  }
300
320
  function useMemoizedPhones(phones) {
301
321
  const key = phones ? [...phones].sort().join("|") : "";
302
- return (0, import_react4.useMemo)(
322
+ return (0, import_react2.useMemo)(
303
323
  () => (phones == null ? void 0 : phones.length) ? [...phones].sort() : void 0,
304
324
  // eslint-disable-next-line react-hooks/exhaustive-deps
305
325
  [key]
@@ -307,7 +327,7 @@ function useMemoizedPhones(phones) {
307
327
  }
308
328
  function useConversationNotes(conversationId) {
309
329
  const skipped = !conversationId;
310
- const result = (0, import_react3.useQuery)(
330
+ const result = usePersistentQuery(
311
331
  conversationNotesListForConversationRef,
312
332
  skipped ? SKIP2 : { conversationId }
313
333
  );
@@ -315,7 +335,7 @@ function useConversationNotes(conversationId) {
315
335
  }
316
336
  function useConversationTasks(conversationId) {
317
337
  const skipped = !conversationId;
318
- const result = (0, import_react3.useQuery)(
338
+ const result = usePersistentQuery(
319
339
  conversationTasksListForConversationRef,
320
340
  skipped ? SKIP2 : { conversationId }
321
341
  );
@@ -323,7 +343,7 @@ function useConversationTasks(conversationId) {
323
343
  }
324
344
  function useConversationNotesByPhonePair(phonePair) {
325
345
  const skipped = !phonePair;
326
- const result = (0, import_react3.useQuery)(
346
+ const result = usePersistentQuery(
327
347
  conversationNotesListByPhonePairRef,
328
348
  skipped ? SKIP2 : { phonePair }
329
349
  );
@@ -331,7 +351,7 @@ function useConversationNotesByPhonePair(phonePair) {
331
351
  }
332
352
  function useConversationTasksForUser(userId, options) {
333
353
  const skipped = !userId;
334
- const result = (0, import_react3.useQuery)(
354
+ const result = usePersistentQuery(
335
355
  conversationTasksListForUserRef,
336
356
  skipped ? SKIP2 : { userId, limit: options == null ? void 0 : options.limit }
337
357
  );
@@ -339,7 +359,7 @@ function useConversationTasksForUser(userId, options) {
339
359
  }
340
360
  function useConversationTasksByPhonePair(phonePair) {
341
361
  const skipped = !phonePair;
342
- const result = (0, import_react3.useQuery)(
362
+ const result = usePersistentQuery(
343
363
  conversationTasksListByPhonePairRef,
344
364
  skipped ? SKIP2 : { phonePair }
345
365
  );
@@ -347,15 +367,62 @@ function useConversationTasksByPhonePair(phonePair) {
347
367
  }
348
368
 
349
369
  // src/react/hooks.ts
350
- var import_react7 = require("convex/react");
351
- var import_react8 = require("react");
370
+ var import_react5 = require("react");
352
371
 
353
372
  // src/react/provider.ts
354
- var import_react5 = require("convex/react");
355
- var import_react6 = require("react");
373
+ var import_react_query3 = require("@convex-dev/react-query");
374
+ var import_react_query4 = require("@tanstack/react-query");
375
+ var import_react_query_persist_client = require("@tanstack/react-query-persist-client");
376
+ var import_react3 = require("convex/react");
377
+ var import_react4 = require("react");
356
378
 
357
- // src/client.ts
379
+ // src/auth-convex-client.ts
358
380
  var import_browser = require("convex/browser");
381
+ var AuthAwareConvexHttpClient = class _AuthAwareConvexHttpClient extends import_browser.ConvexHttpClient {
382
+ constructor(address, getAuthToken) {
383
+ super(address);
384
+ this.getAuthToken = getAuthToken;
385
+ }
386
+ /**
387
+ * Pull a fresh token from the fetcher and apply it. A fetcher error
388
+ * keeps the previously-applied token rather than dropping auth
389
+ * mid-session.
390
+ */
391
+ syncAuth() {
392
+ return __async(this, null, function* () {
393
+ if (!this.getAuthToken) {
394
+ return;
395
+ }
396
+ try {
397
+ const token = yield this.getAuthToken();
398
+ if (token) {
399
+ this.setAuth(token);
400
+ } else {
401
+ this.clearAuth();
402
+ }
403
+ } catch (e) {
404
+ }
405
+ });
406
+ }
407
+ query(query, ...args) {
408
+ return __async(this, null, function* () {
409
+ yield this.syncAuth();
410
+ return __superGet(_AuthAwareConvexHttpClient.prototype, this, "query").call(this, query, ...args);
411
+ });
412
+ }
413
+ mutation(mutation, ...args) {
414
+ return __async(this, null, function* () {
415
+ yield this.syncAuth();
416
+ return __superGet(_AuthAwareConvexHttpClient.prototype, this, "mutation").call(this, mutation, ...args);
417
+ });
418
+ }
419
+ action(action, ...args) {
420
+ return __async(this, null, function* () {
421
+ yield this.syncAuth();
422
+ return __superGet(_AuthAwareConvexHttpClient.prototype, this, "action").call(this, action, ...args);
423
+ });
424
+ }
425
+ };
359
426
 
360
427
  // src/resources/appointments.ts
361
428
  var AppointmentResource = class {
@@ -2172,7 +2239,7 @@ var TruthClient = class {
2172
2239
  this._webPushReady = null;
2173
2240
  var _a, _b, _c, _d, _e, _f, _g, _h;
2174
2241
  const convexUrl = (_b = (_a = config.convexUrl) != null ? _a : CONVEX_URLS[config.environment]) != null ? _b : CONVEX_URLS.local;
2175
- this.convex = new import_browser.ConvexHttpClient(convexUrl);
2242
+ this.convex = new AuthAwareConvexHttpClient(convexUrl, config.getAuthToken);
2176
2243
  this.tracker = new Tracker({
2177
2244
  apiKey: config.apiKey,
2178
2245
  environment: config.environment,
@@ -2311,7 +2378,81 @@ var TruthClient = class {
2311
2378
  }
2312
2379
  };
2313
2380
 
2381
+ // src/react/offline/envelope.ts
2382
+ var SCHEMA_VERSION = 1;
2383
+
2384
+ // src/react/offline/persister.ts
2385
+ var PERSIST_CACHE_KEY = "truth-offline:tanstack-cache";
2386
+ function isPersistedClient(value) {
2387
+ if (typeof value !== "object" || value === null) {
2388
+ return false;
2389
+ }
2390
+ const candidate = value;
2391
+ return typeof candidate.timestamp === "number" && Number.isFinite(candidate.timestamp) && typeof candidate.clientState === "object" && candidate.clientState !== null;
2392
+ }
2393
+ function createOfflinePersister(store, cacheKey = PERSIST_CACHE_KEY) {
2394
+ return {
2395
+ persistClient(client) {
2396
+ try {
2397
+ store.set(cacheKey, JSON.stringify(client));
2398
+ } catch (e) {
2399
+ }
2400
+ },
2401
+ restoreClient() {
2402
+ try {
2403
+ const raw = store.get(cacheKey);
2404
+ if (raw == null) {
2405
+ return void 0;
2406
+ }
2407
+ const parsed = JSON.parse(raw);
2408
+ if (!isPersistedClient(parsed)) {
2409
+ return void 0;
2410
+ }
2411
+ return parsed;
2412
+ } catch (e) {
2413
+ return void 0;
2414
+ }
2415
+ },
2416
+ removeClient() {
2417
+ try {
2418
+ store.delete(cacheKey);
2419
+ } catch (e) {
2420
+ }
2421
+ }
2422
+ };
2423
+ }
2424
+ function readPersistedSavedAt(store, cacheKey = PERSIST_CACHE_KEY) {
2425
+ try {
2426
+ const raw = store.get(cacheKey);
2427
+ if (raw == null) {
2428
+ return null;
2429
+ }
2430
+ const parsed = JSON.parse(raw);
2431
+ return typeof parsed.timestamp === "number" ? parsed.timestamp : null;
2432
+ } catch (e) {
2433
+ return null;
2434
+ }
2435
+ }
2436
+
2437
+ // src/react/offline/store.ts
2438
+ var NoopStore = class {
2439
+ get() {
2440
+ return null;
2441
+ }
2442
+ set() {
2443
+ }
2444
+ delete() {
2445
+ }
2446
+ clearAll() {
2447
+ }
2448
+ };
2449
+ var NOOP_STORE = new NoopStore();
2450
+ function isNoopStore(store) {
2451
+ return store == null || store instanceof NoopStore;
2452
+ }
2453
+
2314
2454
  // src/react/provider.ts
2455
+ var OFFLINE_MAX_AGE_MS = 1e3 * 60 * 60 * 24 * 7;
2315
2456
  var CONVEX_URLS2 = {
2316
2457
  local: "https://courteous-duck-623.convex.cloud",
2317
2458
  staging: "https://courteous-duck-623.convex.cloud",
@@ -2351,12 +2492,20 @@ function readEnv(name) {
2351
2492
  const v = process.env[name];
2352
2493
  return typeof v === "string" && v.length > 0 ? v : void 0;
2353
2494
  }
2354
- var TruthSdkContext = (0, import_react6.createContext)(null);
2495
+ var TruthSdkContext = (0, import_react4.createContext)(null);
2355
2496
  function useTruthSdkContext() {
2356
- return (0, import_react6.useContext)(TruthSdkContext);
2497
+ return (0, import_react4.useContext)(TruthSdkContext);
2498
+ }
2499
+ function useOfflineStore() {
2500
+ var _a, _b;
2501
+ return (_b = (_a = (0, import_react4.useContext)(TruthSdkContext)) == null ? void 0 : _a.offlineStore) != null ? _b : NOOP_STORE;
2502
+ }
2503
+ function useOfflineEnabled() {
2504
+ var _a, _b;
2505
+ return (_b = (_a = (0, import_react4.useContext)(TruthSdkContext)) == null ? void 0 : _a.offlineEnabled) != null ? _b : false;
2357
2506
  }
2358
2507
  function useTruthClient() {
2359
- const ctx = (0, import_react6.useContext)(TruthSdkContext);
2508
+ const ctx = (0, import_react4.useContext)(TruthSdkContext);
2360
2509
  if (!ctx) {
2361
2510
  throw new Error(
2362
2511
  "useTruthClient() called outside <TruthProvider>. Wrap your app in <TruthProvider> from @hipnation-truth/sdk/react."
@@ -2381,14 +2530,66 @@ function TruthProvider({
2381
2530
  source,
2382
2531
  sourceVersion,
2383
2532
  tenantId,
2533
+ getAuthToken,
2534
+ offlineStore = NOOP_STORE,
2535
+ offlineEnabled = false,
2384
2536
  children
2385
2537
  }) {
2386
2538
  var _a, _b;
2387
2539
  const url = resolveConvexUrl(environment, convexUrl);
2388
2540
  const resolvedApiBaseUrl = (_a = apiBaseUrl != null ? apiBaseUrl : readEnv("EXPO_PUBLIC_TRUTH_API_BASE_URL")) != null ? _a : resolveApiBaseUrl(environment);
2389
2541
  const resolvedApiKey = (_b = apiKey != null ? apiKey : readEnv("EXPO_PUBLIC_TRUTH_API_KEY")) != null ? _b : "";
2390
- const convexClient = (0, import_react6.useMemo)(() => new import_react5.ConvexReactClient(url), [url]);
2391
- const truthClient = (0, import_react6.useMemo)(
2542
+ const convexClient = (0, import_react4.useMemo)(() => new import_react3.ConvexReactClient(url), [url]);
2543
+ const getAuthTokenRef = (0, import_react4.useRef)(getAuthToken);
2544
+ getAuthTokenRef.current = getAuthToken;
2545
+ const hasAuthFetcher = Boolean(getAuthToken);
2546
+ const stableGetAuthToken = (0, import_react4.useMemo)(
2547
+ () => hasAuthFetcher ? () => __async(null, null, function* () {
2548
+ var _a2, _b2;
2549
+ return (_b2 = yield (_a2 = getAuthTokenRef.current) == null ? void 0 : _a2.call(getAuthTokenRef)) != null ? _b2 : null;
2550
+ }) : void 0,
2551
+ [hasAuthFetcher]
2552
+ );
2553
+ (0, import_react4.useEffect)(() => {
2554
+ if (stableGetAuthToken) {
2555
+ convexClient.setAuth(() => __async(null, null, function* () {
2556
+ var _a2;
2557
+ return (_a2 = yield stableGetAuthToken()) != null ? _a2 : null;
2558
+ }));
2559
+ } else {
2560
+ convexClient.clearAuth();
2561
+ }
2562
+ }, [convexClient, stableGetAuthToken]);
2563
+ const convexQueryClient = (0, import_react4.useMemo)(
2564
+ () => new import_react_query3.ConvexQueryClient(convexClient),
2565
+ [convexClient]
2566
+ );
2567
+ const queryClient = (0, import_react4.useMemo)(() => {
2568
+ return new import_react_query4.QueryClient({
2569
+ defaultOptions: {
2570
+ queries: {
2571
+ queryKeyHashFn: convexQueryClient.hashFn(),
2572
+ queryFn: convexQueryClient.queryFn(),
2573
+ gcTime: OFFLINE_MAX_AGE_MS,
2574
+ // Convex throws on subscribe rather than returning errors;
2575
+ // retrying a permanently-failing query buys nothing.
2576
+ retry: false
2577
+ }
2578
+ }
2579
+ });
2580
+ }, [convexQueryClient]);
2581
+ const connectedClientRef = (0, import_react4.useRef)(null);
2582
+ (0, import_react4.useEffect)(() => {
2583
+ if (connectedClientRef.current !== convexQueryClient) {
2584
+ convexQueryClient.connect(queryClient);
2585
+ connectedClientRef.current = convexQueryClient;
2586
+ }
2587
+ }, [convexQueryClient, queryClient]);
2588
+ const persister = (0, import_react4.useMemo)(
2589
+ () => offlineEnabled && !isNoopStore(offlineStore) ? createOfflinePersister(offlineStore) : void 0,
2590
+ [offlineEnabled, offlineStore]
2591
+ );
2592
+ const truthClient = (0, import_react4.useMemo)(
2392
2593
  () => new TruthClient({
2393
2594
  // Pin the resource client to the SAME deployment the React hooks
2394
2595
  // use; without this it falls back to CONVEX_URLS[environment] and a
@@ -2400,7 +2601,8 @@ function TruthProvider({
2400
2601
  source: source != null ? source : "unknown",
2401
2602
  sourceVersion: sourceVersion != null ? sourceVersion : "unknown",
2402
2603
  tenantId: tenantId != null ? tenantId : "",
2403
- autoInitServiceWorker: false
2604
+ autoInitServiceWorker: false,
2605
+ getAuthToken: stableGetAuthToken
2404
2606
  }),
2405
2607
  [
2406
2608
  url,
@@ -2409,10 +2611,11 @@ function TruthProvider({
2409
2611
  environment,
2410
2612
  source,
2411
2613
  sourceVersion,
2412
- tenantId
2614
+ tenantId,
2615
+ stableGetAuthToken
2413
2616
  ]
2414
2617
  );
2415
- (0, import_react6.useEffect)(() => {
2618
+ (0, import_react4.useEffect)(() => {
2416
2619
  _activeClient = truthClient;
2417
2620
  return () => {
2418
2621
  if (_activeClient === truthClient) {
@@ -2422,19 +2625,47 @@ function TruthProvider({
2422
2625
  });
2423
2626
  };
2424
2627
  }, [truthClient]);
2425
- const sdkContext = (0, import_react6.useMemo)(
2628
+ const sdkContext = (0, import_react4.useMemo)(
2426
2629
  () => ({
2427
2630
  apiBaseUrl: resolvedApiBaseUrl,
2428
2631
  apiKey: resolvedApiKey,
2429
2632
  environment,
2430
- client: truthClient
2633
+ client: truthClient,
2634
+ offlineStore,
2635
+ offlineEnabled
2431
2636
  }),
2432
- [resolvedApiBaseUrl, resolvedApiKey, environment, truthClient]
2637
+ [
2638
+ resolvedApiBaseUrl,
2639
+ resolvedApiKey,
2640
+ environment,
2641
+ truthClient,
2642
+ offlineStore,
2643
+ offlineEnabled
2644
+ ]
2433
2645
  );
2434
- return (0, import_react6.createElement)(
2646
+ const convexTree = (0, import_react4.createElement)(
2647
+ import_react3.ConvexProvider,
2648
+ { client: convexClient },
2649
+ children
2650
+ );
2651
+ const queryTree = persister ? (0, import_react4.createElement)(
2652
+ import_react_query_persist_client.PersistQueryClientProvider,
2653
+ {
2654
+ client: queryClient,
2655
+ persistOptions: {
2656
+ persister,
2657
+ maxAge: OFFLINE_MAX_AGE_MS,
2658
+ // A SCHEMA_VERSION bump busts the entire dehydrated cache, so
2659
+ // an older build's shapes can never rehydrate the new UI.
2660
+ buster: String(SCHEMA_VERSION)
2661
+ }
2662
+ },
2663
+ convexTree
2664
+ ) : (0, import_react4.createElement)(import_react_query4.QueryClientProvider, { client: queryClient }, convexTree);
2665
+ return (0, import_react4.createElement)(
2435
2666
  TruthSdkContext.Provider,
2436
2667
  { value: sdkContext },
2437
- (0, import_react6.createElement)(import_react5.ConvexProvider, { client: convexClient }, children)
2668
+ queryTree
2438
2669
  );
2439
2670
  }
2440
2671
 
@@ -2448,45 +2679,45 @@ var appointmentsListRef = (0, import_server5.makeFunctionReference)("appointment
2448
2679
  var appointmentsGetRef = (0, import_server5.makeFunctionReference)("appointments:get");
2449
2680
  var appointmentsByElationIdRef = (0, import_server5.makeFunctionReference)("appointments:getByElationId");
2450
2681
  function usePatients(options) {
2451
- return (0, import_react7.useQuery)(patientsListRef, options != null ? options : {});
2682
+ return usePersistentQuery(patientsListRef, options != null ? options : {});
2452
2683
  }
2453
2684
  function usePatient(id) {
2454
- return (0, import_react7.useQuery)(patientsGetRef, { id });
2685
+ return usePersistentQuery(patientsGetRef, { id });
2455
2686
  }
2456
2687
  function usePatientByElationId(elationId) {
2457
- return (0, import_react7.useQuery)(patientsByElationIdRef, {
2688
+ return usePersistentQuery(patientsByElationIdRef, {
2458
2689
  elationId
2459
2690
  });
2460
2691
  }
2461
2692
  function usePatientByHintId(hintId) {
2462
- return (0, import_react7.useQuery)(patientsByHintIdRef, {
2693
+ return usePersistentQuery(patientsByHintIdRef, {
2463
2694
  hintId
2464
2695
  });
2465
2696
  }
2466
2697
  function useAppointments(options) {
2467
- return (0, import_react7.useQuery)(
2698
+ return usePersistentQuery(
2468
2699
  appointmentsListRef,
2469
2700
  options != null ? options : {}
2470
2701
  );
2471
2702
  }
2472
2703
  function useAppointment(id) {
2473
- return (0, import_react7.useQuery)(appointmentsGetRef, { id });
2704
+ return usePersistentQuery(appointmentsGetRef, { id });
2474
2705
  }
2475
2706
  function useAppointmentByElationId(elationId) {
2476
- return (0, import_react7.useQuery)(appointmentsByElationIdRef, {
2707
+ return usePersistentQuery(appointmentsByElationIdRef, {
2477
2708
  elationId
2478
2709
  });
2479
2710
  }
2480
2711
  var physiciansGetByElationIdsRef = (0, import_server5.makeFunctionReference)("physicians:getByElationIds");
2481
2712
  var physiciansGetByElationIdRef = (0, import_server5.makeFunctionReference)("physicians:getByElationId");
2482
2713
  function usePhysiciansByElationIds(ids) {
2483
- return (0, import_react7.useQuery)(
2714
+ return usePersistentQuery(
2484
2715
  physiciansGetByElationIdsRef,
2485
2716
  ids && ids.length > 0 ? { ids } : "skip"
2486
2717
  );
2487
2718
  }
2488
2719
  function usePhysicianByElationId(id) {
2489
- return (0, import_react7.useQuery)(
2720
+ return usePersistentQuery(
2490
2721
  physiciansGetByElationIdRef,
2491
2722
  id !== void 0 ? { id } : "skip"
2492
2723
  );
@@ -2500,23 +2731,23 @@ function usePatientMedical(elationId, options) {
2500
2731
  const sdkContext = useTruthSdkContext();
2501
2732
  const apiBaseUrl = (_a = options == null ? void 0 : options.apiBaseUrl) != null ? _a : sdkContext == null ? void 0 : sdkContext.apiBaseUrl;
2502
2733
  const apiKey = (_b = options == null ? void 0 : options.apiKey) != null ? _b : sdkContext == null ? void 0 : sdkContext.apiKey;
2503
- const medications = (0, import_react7.useQuery)(
2734
+ const medications = usePersistentQuery(
2504
2735
  medicationsByPatientRef,
2505
2736
  elationId !== void 0 ? { elationPatientId: elationId } : "skip"
2506
2737
  );
2507
- const problems = (0, import_react7.useQuery)(
2738
+ const problems = usePersistentQuery(
2508
2739
  problemsByPatientRef,
2509
2740
  elationId !== void 0 ? { elationPatientId: elationId } : "skip"
2510
2741
  );
2511
- const allergies = (0, import_react7.useQuery)(
2742
+ const allergies = usePersistentQuery(
2512
2743
  allergiesByPatientRef,
2513
2744
  elationId !== void 0 ? { elationPatientId: elationId } : "skip"
2514
2745
  );
2515
- const appointments = (0, import_react7.useQuery)(
2746
+ const appointments = usePersistentQuery(
2516
2747
  appointmentsByPatientRef,
2517
2748
  elationId !== void 0 ? { elationPatientId: elationId } : "skip"
2518
2749
  );
2519
- (0, import_react8.useEffect)(() => {
2750
+ (0, import_react5.useEffect)(() => {
2520
2751
  if (elationId === void 0 || (options == null ? void 0 : options.skipRefresh)) {
2521
2752
  return;
2522
2753
  }
@@ -2547,15 +2778,15 @@ function usePatientBasic(input, options) {
2547
2778
  const sdkContext = useTruthSdkContext();
2548
2779
  const apiBaseUrl = (_a = options == null ? void 0 : options.apiBaseUrl) != null ? _a : sdkContext == null ? void 0 : sdkContext.apiBaseUrl;
2549
2780
  const apiKey = (_b = options == null ? void 0 : options.apiKey) != null ? _b : sdkContext == null ? void 0 : sdkContext.apiKey;
2550
- const elationRow = (0, import_react7.useQuery)(
2781
+ const elationRow = usePersistentQuery(
2551
2782
  elationPatientByIdRef,
2552
2783
  input.elationId !== void 0 ? { elationId: input.elationId } : "skip"
2553
2784
  );
2554
- const hintRow = (0, import_react7.useQuery)(
2785
+ const hintRow = usePersistentQuery(
2555
2786
  hintPatientByIdRef,
2556
2787
  input.hintId !== void 0 ? { hintId: input.hintId } : "skip"
2557
2788
  );
2558
- (0, import_react8.useEffect)(() => {
2789
+ (0, import_react5.useEffect)(() => {
2559
2790
  if (options == null ? void 0 : options.skipRefresh) {
2560
2791
  return;
2561
2792
  }
@@ -2594,7 +2825,7 @@ function usePatientBasic(input, options) {
2594
2825
  };
2595
2826
  }
2596
2827
  function usePharmacyByNcpdpId(ncpdpId) {
2597
- return (0, import_react7.useQuery)(
2828
+ return usePersistentQuery(
2598
2829
  pharmacyByNcpdpRef,
2599
2830
  ncpdpId ? { ncpdpId } : "skip"
2600
2831
  );
@@ -2604,11 +2835,11 @@ function usePatientPhoto(elationId, options) {
2604
2835
  const sdkContext = useTruthSdkContext();
2605
2836
  const apiBaseUrl = (_a = options == null ? void 0 : options.apiBaseUrl) != null ? _a : sdkContext == null ? void 0 : sdkContext.apiBaseUrl;
2606
2837
  const apiKey = (_b = options == null ? void 0 : options.apiKey) != null ? _b : sdkContext == null ? void 0 : sdkContext.apiKey;
2607
- const photo = (0, import_react7.useQuery)(
2838
+ const photo = usePersistentQuery(
2608
2839
  patientPhotoByIdRef,
2609
2840
  elationId !== void 0 ? { elationPatientId: elationId } : "skip"
2610
2841
  );
2611
- (0, import_react8.useEffect)(() => {
2842
+ (0, import_react5.useEffect)(() => {
2612
2843
  if (options == null ? void 0 : options.skipRefresh) {
2613
2844
  return;
2614
2845
  }
@@ -2637,7 +2868,7 @@ var messagesByPhonesRef = (0, import_server5.makeFunctionReference)("conversatio
2637
2868
  var messagesByConversationIdRef = (0, import_server5.makeFunctionReference)("conversationMessages:getByConversationId");
2638
2869
  function useConversationMessages(input, options) {
2639
2870
  const hasPair = !!input.phoneA && !!input.phoneB;
2640
- const byPair = (0, import_react7.useQuery)(
2871
+ const byPair = usePersistentQuery(
2641
2872
  messagesByPhonesRef,
2642
2873
  hasPair ? {
2643
2874
  phoneA: input.phoneA,
@@ -2645,7 +2876,7 @@ function useConversationMessages(input, options) {
2645
2876
  limit: options == null ? void 0 : options.limit
2646
2877
  } : "skip"
2647
2878
  );
2648
- const byConvo = (0, import_react7.useQuery)(
2879
+ const byConvo = usePersistentQuery(
2649
2880
  messagesByConversationIdRef,
2650
2881
  !hasPair && input.conversationId ? { conversationId: input.conversationId, limit: options == null ? void 0 : options.limit } : "skip"
2651
2882
  );
@@ -2653,7 +2884,7 @@ function useConversationMessages(input, options) {
2653
2884
  }
2654
2885
 
2655
2886
  // src/react/notifications.ts
2656
- var import_react9 = require("react");
2887
+ var import_react6 = require("react");
2657
2888
  function loadExpo() {
2658
2889
  return __async(this, null, function* () {
2659
2890
  try {
@@ -2668,12 +2899,12 @@ function useNotifications(options) {
2668
2899
  const sdkContext = useTruthSdkContext();
2669
2900
  const apiBaseUrl = (_b = (_a = options.apiBaseUrl) != null ? _a : sdkContext == null ? void 0 : sdkContext.apiBaseUrl) != null ? _b : "";
2670
2901
  const apiKey = (_d = (_c = options.apiKey) != null ? _c : sdkContext == null ? void 0 : sdkContext.apiKey) != null ? _d : "";
2671
- const [permissionStatus, setPermissionStatus] = (0, import_react9.useState)("unknown");
2672
- const [devicePushToken, setDevicePushToken] = (0, import_react9.useState)(null);
2673
- const expoRef = (0, import_react9.useRef)(null);
2674
- const isWebRef = (0, import_react9.useRef)(false);
2675
- const vapidKeyRef = (0, import_react9.useRef)((_e = options.vapidPublicKey) != null ? _e : null);
2676
- (0, import_react9.useEffect)(() => {
2902
+ const [permissionStatus, setPermissionStatus] = (0, import_react6.useState)("unknown");
2903
+ const [devicePushToken, setDevicePushToken] = (0, import_react6.useState)(null);
2904
+ const expoRef = (0, import_react6.useRef)(null);
2905
+ const isWebRef = (0, import_react6.useRef)(false);
2906
+ const vapidKeyRef = (0, import_react6.useRef)((_e = options.vapidPublicKey) != null ? _e : null);
2907
+ (0, import_react6.useEffect)(() => {
2677
2908
  let mounted = true;
2678
2909
  void (() => __async(null, null, function* () {
2679
2910
  var _a2;
@@ -2729,7 +2960,7 @@ function useNotifications(options) {
2729
2960
  mounted = false;
2730
2961
  };
2731
2962
  }, [apiBaseUrl, apiKey]);
2732
- const register = (0, import_react9.useCallback)(() => __async(null, null, function* () {
2963
+ const register = (0, import_react6.useCallback)(() => __async(null, null, function* () {
2733
2964
  var _a2, _b2;
2734
2965
  if (!options.userId) {
2735
2966
  return { ok: false, reason: "missing_userId" };
@@ -2842,7 +3073,7 @@ function useNotifications(options) {
2842
3073
  options.appVersion,
2843
3074
  options.serviceWorkerPath
2844
3075
  ]);
2845
- const unregister = (0, import_react9.useCallback)(() => __async(null, null, function* () {
3076
+ const unregister = (0, import_react6.useCallback)(() => __async(null, null, function* () {
2846
3077
  if (!devicePushToken) {
2847
3078
  return;
2848
3079
  }
@@ -2857,7 +3088,7 @@ function useNotifications(options) {
2857
3088
  });
2858
3089
  setDevicePushToken(null);
2859
3090
  }), [apiBaseUrl, apiKey, devicePushToken]);
2860
- const addReceivedListener = (0, import_react9.useCallback)(
3091
+ const addReceivedListener = (0, import_react6.useCallback)(
2861
3092
  (listener) => {
2862
3093
  if (isWebRef.current) {
2863
3094
  if (typeof navigator === "undefined" || !("serviceWorker" in navigator)) {
@@ -2886,7 +3117,7 @@ function useNotifications(options) {
2886
3117
  },
2887
3118
  []
2888
3119
  );
2889
- const addResponseListener = (0, import_react9.useCallback)(
3120
+ const addResponseListener = (0, import_react6.useCallback)(
2890
3121
  (listener) => {
2891
3122
  if (isWebRef.current) {
2892
3123
  if (typeof navigator === "undefined" || !("serviceWorker" in navigator)) {
@@ -2915,7 +3146,7 @@ function useNotifications(options) {
2915
3146
  },
2916
3147
  []
2917
3148
  );
2918
- const getBadgeCount = (0, import_react9.useCallback)(() => __async(null, null, function* () {
3149
+ const getBadgeCount = (0, import_react6.useCallback)(() => __async(null, null, function* () {
2919
3150
  var _a2;
2920
3151
  const expo = expoRef.current;
2921
3152
  if (!(expo == null ? void 0 : expo.getBadgeCountAsync)) {
@@ -2923,7 +3154,7 @@ function useNotifications(options) {
2923
3154
  }
2924
3155
  return (_a2 = yield expo.getBadgeCountAsync()) != null ? _a2 : 0;
2925
3156
  }), []);
2926
- const setBadgeCount = (0, import_react9.useCallback)((count) => __async(null, null, function* () {
3157
+ const setBadgeCount = (0, import_react6.useCallback)((count) => __async(null, null, function* () {
2927
3158
  const expo = expoRef.current;
2928
3159
  if (!(expo == null ? void 0 : expo.setBadgeCountAsync)) {
2929
3160
  return;
@@ -2931,7 +3162,7 @@ function useNotifications(options) {
2931
3162
  yield expo.setBadgeCountAsync(count);
2932
3163
  }), []);
2933
3164
  const autoRegister = options.autoRegister !== false;
2934
- (0, import_react9.useEffect)(() => {
3165
+ (0, import_react6.useEffect)(() => {
2935
3166
  if (!autoRegister) {
2936
3167
  return;
2937
3168
  }
@@ -2968,7 +3199,7 @@ function useNotificationsActions() {
2968
3199
  const sdkContext = useTruthSdkContext();
2969
3200
  const apiBaseUrl = (_a = sdkContext == null ? void 0 : sdkContext.apiBaseUrl) != null ? _a : "";
2970
3201
  const apiKey = (_b = sdkContext == null ? void 0 : sdkContext.apiKey) != null ? _b : "";
2971
- const post = (0, import_react9.useCallback)(
3202
+ const post = (0, import_react6.useCallback)(
2972
3203
  (path, body) => __async(null, null, function* () {
2973
3204
  if (!apiBaseUrl || !apiKey) {
2974
3205
  throw new Error(
@@ -2994,7 +3225,7 @@ function useNotificationsActions() {
2994
3225
  }),
2995
3226
  [apiBaseUrl, apiKey]
2996
3227
  );
2997
- const get = (0, import_react9.useCallback)(
3228
+ const get = (0, import_react6.useCallback)(
2998
3229
  (path) => __async(null, null, function* () {
2999
3230
  const res = yield fetch(`${apiBaseUrl}/api${path}`, {
3000
3231
  method: "GET",
@@ -3010,21 +3241,21 @@ function useNotificationsActions() {
3010
3241
  }),
3011
3242
  [apiBaseUrl, apiKey]
3012
3243
  );
3013
- const send = (0, import_react9.useCallback)(
3244
+ const send = (0, import_react6.useCallback)(
3014
3245
  (input) => post("/notifications/send", input),
3015
3246
  [post]
3016
3247
  );
3017
- const schedule = (0, import_react9.useCallback)(
3248
+ const schedule = (0, import_react6.useCallback)(
3018
3249
  (input) => post("/notifications/schedule", input),
3019
3250
  [post]
3020
3251
  );
3021
- const getPreferences = (0, import_react9.useCallback)(
3252
+ const getPreferences = (0, import_react6.useCallback)(
3022
3253
  (userId) => get(
3023
3254
  `/notifications/preferences/${encodeURIComponent(userId)}`
3024
3255
  ),
3025
3256
  [get]
3026
3257
  );
3027
- const updatePreferences = (0, import_react9.useCallback)(
3258
+ const updatePreferences = (0, import_react6.useCallback)(
3028
3259
  (userId, prefs) => post(
3029
3260
  `/notifications/preferences/${encodeURIComponent(userId)}`,
3030
3261
  prefs
@@ -3059,7 +3290,6 @@ function detectPlatform(tokenType) {
3059
3290
  }
3060
3291
 
3061
3292
  // src/react/patient-family.ts
3062
- var import_react10 = require("convex/react");
3063
3293
  var import_server6 = require("convex/server");
3064
3294
  var patientsFamilyMembersRef = (0, import_server6.makeFunctionReference)("patients:listFamilyMembers");
3065
3295
  var SKIP3 = "skip";
@@ -3068,7 +3298,7 @@ function usePatientFamilyMembers(input) {
3068
3298
  const hasPhoneNumbers = !!((input == null ? void 0 : input.phoneNumbers) && input.phoneNumbers.length > 0);
3069
3299
  const shouldQuery = hasFamilyId || hasPhoneNumbers;
3070
3300
  const args = shouldQuery ? __spreadValues(__spreadValues(__spreadValues({}, (input == null ? void 0 : input.familyId) ? { familyId: input.familyId } : {}), (input == null ? void 0 : input.phoneNumbers) && input.phoneNumbers.length > 0 ? { phoneNumbers: input.phoneNumbers } : {}), (input == null ? void 0 : input.excludeHintId) ? { excludeHintId: input.excludeHintId } : {}) : SKIP3;
3071
- const result = (0, import_react10.useQuery)(
3301
+ const result = usePersistentQuery(
3072
3302
  patientsFamilyMembersRef,
3073
3303
  args
3074
3304
  );
@@ -3083,7 +3313,6 @@ function usePatientFamilyMembers(input) {
3083
3313
  }
3084
3314
 
3085
3315
  // src/react/patient-search.ts
3086
- var import_react11 = require("convex/react");
3087
3316
  var import_server7 = require("convex/server");
3088
3317
  var patientsSearchRef = (0, import_server7.makeFunctionReference)("patients:search");
3089
3318
  var SKIP4 = "skip";
@@ -3091,7 +3320,7 @@ function usePatientSearch(options) {
3091
3320
  var _a;
3092
3321
  const trimmedQuery = ((_a = options.query) != null ? _a : "").trim();
3093
3322
  const skipped = trimmedQuery.length === 0;
3094
- const result = (0, import_react11.useQuery)(
3323
+ const result = usePersistentQuery(
3095
3324
  patientsSearchRef,
3096
3325
  skipped ? SKIP4 : __spreadValues(__spreadValues(__spreadValues({
3097
3326
  query: trimmedQuery
@@ -3108,23 +3337,22 @@ function usePatientSearch(options) {
3108
3337
  }
3109
3338
 
3110
3339
  // src/react/patients-bulk.ts
3111
- var import_react12 = require("convex/react");
3112
3340
  var import_server8 = require("convex/server");
3113
- var import_react13 = require("react");
3341
+ var import_react7 = require("react");
3114
3342
  var patientsGetByIdsRef = (0, import_server8.makeFunctionReference)("patients:getByIds");
3115
3343
  var patientsGetByPhonesRef = (0, import_server8.makeFunctionReference)("patients:getByPhones");
3116
3344
  var SKIP5 = "skip";
3117
3345
  function usePatientsByIds(ids) {
3118
- const stableIds = (0, import_react13.useMemo)(() => {
3346
+ const stableIds = (0, import_react7.useMemo)(() => {
3119
3347
  const arr = ids != null ? ids : [];
3120
3348
  return [...new Set(arr)].sort();
3121
3349
  }, [ids]);
3122
3350
  const skipped = stableIds.length === 0;
3123
- const result = (0, import_react12.useQuery)(
3351
+ const result = usePersistentQuery(
3124
3352
  patientsGetByIdsRef,
3125
3353
  skipped ? SKIP5 : { ids: stableIds }
3126
3354
  );
3127
- const mapped = (0, import_react13.useMemo)(() => {
3355
+ const mapped = (0, import_react7.useMemo)(() => {
3128
3356
  if (result === void 0) {
3129
3357
  return void 0;
3130
3358
  }
@@ -3146,17 +3374,17 @@ function usePatientsByIds(ids) {
3146
3374
  };
3147
3375
  }
3148
3376
  function usePatientsByPhones(phones) {
3149
- const stableDigits = (0, import_react13.useMemo)(() => {
3377
+ const stableDigits = (0, import_react7.useMemo)(() => {
3150
3378
  const arr = phones != null ? phones : [];
3151
3379
  const digits = arr.map((p) => p.replace(/\D+/g, "")).filter((s) => s.length > 0);
3152
3380
  return [...new Set(digits)].sort();
3153
3381
  }, [phones]);
3154
3382
  const skipped = stableDigits.length === 0;
3155
- const result = (0, import_react12.useQuery)(
3383
+ const result = usePersistentQuery(
3156
3384
  patientsGetByPhonesRef,
3157
3385
  skipped ? SKIP5 : { phoneDigits: stableDigits }
3158
3386
  );
3159
- const mapped = (0, import_react13.useMemo)(() => {
3387
+ const mapped = (0, import_react7.useMemo)(() => {
3160
3388
  if (result === void 0) {
3161
3389
  return void 0;
3162
3390
  }
@@ -3173,14 +3401,13 @@ function usePatientsByPhones(phones) {
3173
3401
  }
3174
3402
 
3175
3403
  // src/react/reminders.ts
3176
- var import_react14 = require("convex/react");
3177
3404
  var import_server9 = require("convex/server");
3178
3405
  var remindersListPendingByConversationIdsRef = (0, import_server9.makeFunctionReference)("reminders:listPendingByConversationIds");
3179
3406
  var SKIP6 = "skip";
3180
3407
  function useRemindersForConversations(conversationIds) {
3181
3408
  const ids = conversationIds != null ? conversationIds : [];
3182
3409
  const skipped = ids.length === 0;
3183
- const result = (0, import_react14.useQuery)(
3410
+ const result = usePersistentQuery(
3184
3411
  remindersListPendingByConversationIdsRef,
3185
3412
  skipped ? SKIP6 : { conversationIds: ids }
3186
3413
  );
@@ -3196,23 +3423,23 @@ function useRemindersForConversations(conversationIds) {
3196
3423
  }
3197
3424
 
3198
3425
  // src/react/tasks.ts
3199
- var import_react15 = require("convex/react");
3426
+ var import_react8 = require("convex/react");
3200
3427
  var import_server10 = require("convex/server");
3201
- var import_react16 = require("react");
3428
+ var import_react9 = require("react");
3202
3429
  var conversationTasksMarkSeenRef = (0, import_server10.makeFunctionReference)("conversationTasks:markSeen");
3203
3430
  function useConversationTaskMarkSeen() {
3204
- const mutate = (0, import_react15.useMutation)(
3431
+ const mutate = (0, import_react8.useMutation)(
3205
3432
  conversationTasksMarkSeenRef
3206
3433
  );
3207
- return (0, import_react16.useCallback)(
3434
+ return (0, import_react9.useCallback)(
3208
3435
  (taskId, userId) => mutate({ taskId, userId }),
3209
3436
  [mutate]
3210
3437
  );
3211
3438
  }
3212
3439
 
3213
3440
  // src/react/tracking.ts
3214
- var import_react17 = require("react");
3215
- var TruthTrackingContext = (0, import_react17.createContext)(
3441
+ var import_react10 = require("react");
3442
+ var TruthTrackingContext = (0, import_react10.createContext)(
3216
3443
  null
3217
3444
  );
3218
3445
  function TruthTrackingProvider({
@@ -3225,7 +3452,7 @@ function TruthTrackingProvider({
3225
3452
  }) {
3226
3453
  var _a, _b;
3227
3454
  const resolvedApiKey = (_b = apiKey != null ? apiKey : typeof process !== "undefined" ? (_a = process.env) == null ? void 0 : _a.EXPO_PUBLIC_TRUTH_API_KEY : void 0) != null ? _b : "";
3228
- const value = (0, import_react17.useMemo)(() => {
3455
+ const value = (0, import_react10.useMemo)(() => {
3229
3456
  const tracker = new Tracker({
3230
3457
  apiKey: resolvedApiKey,
3231
3458
  environment,
@@ -3244,10 +3471,10 @@ function TruthTrackingProvider({
3244
3471
  }
3245
3472
  };
3246
3473
  }, [resolvedApiKey, environment, source, sourceVersion, tenantId]);
3247
- return (0, import_react17.createElement)(TruthTrackingContext.Provider, { value }, children);
3474
+ return (0, import_react10.createElement)(TruthTrackingContext.Provider, { value }, children);
3248
3475
  }
3249
3476
  function useTruth() {
3250
- const ctx = (0, import_react17.useContext)(TruthTrackingContext);
3477
+ const ctx = (0, import_react10.useContext)(TruthTrackingContext);
3251
3478
  if (!ctx) {
3252
3479
  throw new Error("useTruth must be used within a TruthTrackingProvider");
3253
3480
  }
@@ -3255,13 +3482,12 @@ function useTruth() {
3255
3482
  }
3256
3483
 
3257
3484
  // src/react/user-settings.ts
3258
- var import_react18 = require("convex/react");
3259
3485
  var import_server11 = require("convex/server");
3260
3486
  var userSettingsGetByUserIdRef = (0, import_server11.makeFunctionReference)("userSettings:getByUserId");
3261
3487
  var SKIP7 = "skip";
3262
3488
  function useUserSettings(userId) {
3263
3489
  const skip = !userId;
3264
- const result = (0, import_react18.useQuery)(
3490
+ const result = usePersistentQuery(
3265
3491
  userSettingsGetByUserIdRef,
3266
3492
  skip ? SKIP7 : { userId }
3267
3493
  );
@@ -3276,15 +3502,15 @@ function useUserSettings(userId) {
3276
3502
  }
3277
3503
 
3278
3504
  // src/react/users.ts
3279
- var import_react19 = require("react");
3505
+ var import_react11 = require("react");
3280
3506
  function useUserSync(input) {
3281
3507
  var _a, _b, _c, _d;
3282
3508
  const sdkContext = useTruthSdkContext();
3283
3509
  const apiBaseUrl = (_b = (_a = input.apiBaseUrl) != null ? _a : sdkContext == null ? void 0 : sdkContext.apiBaseUrl) != null ? _b : "";
3284
3510
  const apiKey = (_d = (_c = input.apiKey) != null ? _c : sdkContext == null ? void 0 : sdkContext.apiKey) != null ? _d : "";
3285
- const [status, setStatus] = (0, import_react19.useState)("idle");
3286
- const [error, setError] = (0, import_react19.useState)(null);
3287
- const lastKeyRef = (0, import_react19.useRef)(null);
3511
+ const [status, setStatus] = (0, import_react11.useState)("idle");
3512
+ const [error, setError] = (0, import_react11.useState)(null);
3513
+ const lastKeyRef = (0, import_react11.useRef)(null);
3288
3514
  const sync = () => __async(null, null, function* () {
3289
3515
  if (!input.userId) {
3290
3516
  return { ok: false, reason: "missing_userId" };
@@ -3327,7 +3553,7 @@ function useUserSync(input) {
3327
3553
  return { ok: false, reason: message };
3328
3554
  }
3329
3555
  });
3330
- (0, import_react19.useEffect)(() => {
3556
+ (0, import_react11.useEffect)(() => {
3331
3557
  var _a2, _b2, _c2, _d2, _e;
3332
3558
  if (!input.userId) {
3333
3559
  return;
@@ -3366,13 +3592,13 @@ function useUserSync(input) {
3366
3592
  }
3367
3593
 
3368
3594
  // src/react/voicemail.ts
3369
- var import_react20 = require("react");
3595
+ var import_react12 = require("react");
3370
3596
  function useVoicemailUrl(client) {
3371
- const [url, setUrl] = (0, import_react20.useState)(null);
3372
- const [isLoading, setIsLoading] = (0, import_react20.useState)(false);
3373
- const [error, setError] = (0, import_react20.useState)(null);
3374
- const inFlightRef = (0, import_react20.useRef)(false);
3375
- const fetchUrl = (0, import_react20.useCallback)(
3597
+ const [url, setUrl] = (0, import_react12.useState)(null);
3598
+ const [isLoading, setIsLoading] = (0, import_react12.useState)(false);
3599
+ const [error, setError] = (0, import_react12.useState)(null);
3600
+ const inFlightRef = (0, import_react12.useRef)(false);
3601
+ const fetchUrl = (0, import_react12.useCallback)(
3376
3602
  (voicemailLink) => __async(null, null, function* () {
3377
3603
  if (inFlightRef.current) {
3378
3604
  return null;
@@ -3404,11 +3630,13 @@ function useVoicemailUrl(client) {
3404
3630
  CONNECTED_CALL_STATES,
3405
3631
  CONVEX_URLS,
3406
3632
  DialpadCallState,
3633
+ NoopStore,
3407
3634
  RINGING_CALL_STATES,
3408
3635
  TERMINAL_CALL_STATES,
3409
3636
  TruthProvider,
3410
3637
  TruthTrackingProvider,
3411
3638
  getTruthClient,
3639
+ readPersistedSavedAt,
3412
3640
  resolveApiBaseUrl,
3413
3641
  resolveConvexUrl,
3414
3642
  useActiveCalls,
@@ -3431,6 +3659,8 @@ function useVoicemailUrl(client) {
3431
3659
  useMessages,
3432
3660
  useNotifications,
3433
3661
  useNotificationsActions,
3662
+ useOfflineEnabled,
3663
+ useOfflineStore,
3434
3664
  usePatient,
3435
3665
  usePatientBasic,
3436
3666
  usePatientByElationId,