@rpcbase/client 0.437.0 → 0.439.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -434,6 +434,10 @@ function _temp8() {
434
434
  };
435
435
  }
436
436
  let apiClient;
437
+ const isApiClientRequestOptions = (value) => {
438
+ if (!value || typeof value !== "object") return false;
439
+ return "signal" in value;
440
+ };
437
441
  const initApiClient = async (args) => {
438
442
  if (env.SSR) {
439
443
  if (!args) {
@@ -441,7 +445,7 @@ const initApiClient = async (args) => {
441
445
  }
442
446
  const {
443
447
  getServerApiClient
444
- } = await import("./getServerApiClient-BzqOKL0g.js");
448
+ } = await import("./getServerApiClient-DnG8591C.js");
445
449
  apiClient = await getServerApiClient(args.app);
446
450
  } else {
447
451
  const axios = (await import("axios/dist/browser/axios.cjs")).default;
@@ -453,7 +457,8 @@ const initApiClient = async (args) => {
453
457
  }
454
458
  });
455
459
  const createMethod = (method) => {
456
- return async (path, payload, _ctx) => {
460
+ return async (path, payload, ctxOrOptions, options) => {
461
+ const requestOptions = isApiClientRequestOptions(ctxOrOptions) ? ctxOrOptions : options;
457
462
  const config = {
458
463
  method,
459
464
  url: path,
@@ -462,6 +467,9 @@ const initApiClient = async (args) => {
462
467
  } : {
463
468
  data: payload
464
469
  },
470
+ ...requestOptions?.signal ? {
471
+ signal: requestOptions.signal
472
+ } : {},
465
473
  headers: {
466
474
  // ...(typeof ctxOrPath !== 'string' && {
467
475
  // // 'X-Custom-Header': ctxOrPath.someHeaderValue,
@@ -2328,6 +2336,7 @@ const DELIVERY_KEY_PREFIX = "rb:notifications:delivery:";
2328
2336
  const DELIVERY_LOCK_PREFIX = "rb-notifications-delivery:";
2329
2337
  const FALLBACK_DELIVERY_LOCK_KEY_PREFIX = "rb:notifications:delivery-lock:";
2330
2338
  const NOTIFICATION_TAB_ID = `${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;
2339
+ const DEFAULT_NOTIFICATION_APP_NAME = "default";
2331
2340
  const NotificationsRealtimeContext = createContext(null);
2332
2341
  const toIso = (value) => {
2333
2342
  if (value instanceof Date) return value.toISOString();
@@ -2362,19 +2371,58 @@ const buildDisabledTopics = (settings) => {
2362
2371
  return pref.inApp === false ? topic : null;
2363
2372
  }).filter((topic) => Boolean(topic));
2364
2373
  };
2365
- const getWebpushLink = (item) => {
2374
+ const getNotificationLink = (item) => {
2375
+ const dataLink = item.data?.link?.trim();
2376
+ if (dataLink) return dataLink;
2366
2377
  const platformWebpush = item.platform?.webpush;
2367
2378
  if (!platformWebpush || typeof platformWebpush !== "object" || Array.isArray(platformWebpush)) return "";
2368
2379
  const fcmOptions = platformWebpush.fcmOptions;
2369
2380
  if (!fcmOptions || typeof fcmOptions !== "object" || Array.isArray(fcmOptions)) return "";
2370
- return typeof fcmOptions.link === "string" ? fcmOptions.link : "";
2371
- };
2372
- const getScopedUserKey = (userId) => encodeURIComponent(userId);
2373
- const getTabStateKey = (userId) => `${TAB_STATE_KEY_PREFIX}${getScopedUserKey(userId)}:${NOTIFICATION_TAB_ID}`;
2374
- const getTabStateKeyPrefix = (userId) => `${TAB_STATE_KEY_PREFIX}${getScopedUserKey(userId)}:`;
2375
- const getDeliveryKey = (userId, notificationId) => `${DELIVERY_KEY_PREFIX}${getScopedUserKey(userId)}:${encodeURIComponent(notificationId)}`;
2376
- const getDeliveryLockName = (userId) => `${DELIVERY_LOCK_PREFIX}${getScopedUserKey(userId)}`;
2377
- const getFallbackDeliveryLockKey = (userId) => `${FALLBACK_DELIVERY_LOCK_KEY_PREFIX}${getScopedUserKey(userId)}`;
2381
+ const link = fcmOptions.link;
2382
+ return typeof link === "string" ? link.trim() : "";
2383
+ };
2384
+ const getNotificationActionMode = (item) => {
2385
+ return item.data?.linkMode === "merge_current_search" ? "merge_current_search" : "navigate";
2386
+ };
2387
+ const getNotificationAction = (item) => {
2388
+ const link = getNotificationLink(item);
2389
+ if (!link) return null;
2390
+ return {
2391
+ link,
2392
+ mode: getNotificationActionMode(item)
2393
+ };
2394
+ };
2395
+ const pushUrlWithoutReload = (url) => {
2396
+ window.history.pushState(window.history.state, "", url);
2397
+ window.dispatchEvent(new PopStateEvent("popstate", {
2398
+ state: window.history.state
2399
+ }));
2400
+ };
2401
+ const applyNotificationAction = (action) => {
2402
+ if (action.mode === "merge_current_search") {
2403
+ const currentUrl = new URL(window.location.href);
2404
+ const actionUrl = new URL(action.link, currentUrl);
2405
+ actionUrl.searchParams.forEach((value, key) => {
2406
+ currentUrl.searchParams.set(key, value);
2407
+ });
2408
+ if (actionUrl.hash) {
2409
+ currentUrl.hash = actionUrl.hash;
2410
+ }
2411
+ pushUrlWithoutReload(`${currentUrl.pathname}${currentUrl.search}${currentUrl.hash}`);
2412
+ return;
2413
+ }
2414
+ window.location.href = action.link;
2415
+ };
2416
+ const getNormalizedNotificationAppName = (appName) => {
2417
+ const normalized = typeof appName === "string" ? appName.trim() : "";
2418
+ return normalized || DEFAULT_NOTIFICATION_APP_NAME;
2419
+ };
2420
+ const getScopedNotificationKey = (userId, appName) => `${encodeURIComponent(appName)}:${encodeURIComponent(userId)}`;
2421
+ const getTabStateKey = (userId, appName) => `${TAB_STATE_KEY_PREFIX}${getScopedNotificationKey(userId, appName)}:${NOTIFICATION_TAB_ID}`;
2422
+ const getTabStateKeyPrefix = (userId, appName) => `${TAB_STATE_KEY_PREFIX}${getScopedNotificationKey(userId, appName)}:`;
2423
+ const getDeliveryKey = (userId, appName, notificationId) => `${DELIVERY_KEY_PREFIX}${getScopedNotificationKey(userId, appName)}:${encodeURIComponent(notificationId)}`;
2424
+ const getDeliveryLockName = (userId, appName) => `${DELIVERY_LOCK_PREFIX}${getScopedNotificationKey(userId, appName)}`;
2425
+ const getFallbackDeliveryLockKey = (userId, appName) => `${FALLBACK_DELIVERY_LOCK_KEY_PREFIX}${getScopedNotificationKey(userId, appName)}`;
2378
2426
  const getLocalStorage = () => {
2379
2427
  if (typeof window === "undefined") return null;
2380
2428
  try {
@@ -2402,7 +2450,7 @@ const isDocumentActive = () => {
2402
2450
  if (typeof document === "undefined") return false;
2403
2451
  return document.visibilityState === "visible" && document.hasFocus();
2404
2452
  };
2405
- const writeNotificationTabState = (userId) => {
2453
+ const writeNotificationTabState = (userId, appName) => {
2406
2454
  const storage = getLocalStorage();
2407
2455
  if (!storage) return;
2408
2456
  const state = {
@@ -2411,24 +2459,24 @@ const writeNotificationTabState = (userId) => {
2411
2459
  updatedAt: Date.now()
2412
2460
  };
2413
2461
  try {
2414
- storage.setItem(getTabStateKey(userId), JSON.stringify(state));
2462
+ storage.setItem(getTabStateKey(userId, appName), JSON.stringify(state));
2415
2463
  } catch {
2416
2464
  return;
2417
2465
  }
2418
2466
  };
2419
- const removeNotificationTabState = (userId) => {
2467
+ const removeNotificationTabState = (userId, appName) => {
2420
2468
  const storage = getLocalStorage();
2421
2469
  if (!storage) return;
2422
2470
  try {
2423
- storage.removeItem(getTabStateKey(userId));
2471
+ storage.removeItem(getTabStateKey(userId, appName));
2424
2472
  } catch {
2425
2473
  return;
2426
2474
  }
2427
2475
  };
2428
- const hasActiveNotificationTab = (userId) => {
2476
+ const hasActiveNotificationTab = (userId, appName) => {
2429
2477
  const storage = getLocalStorage();
2430
2478
  if (!storage) return false;
2431
- const prefix = getTabStateKeyPrefix(userId);
2479
+ const prefix = getTabStateKeyPrefix(userId, appName);
2432
2480
  const now = Date.now();
2433
2481
  try {
2434
2482
  for (let index = storage.length - 1; index >= 0; index -= 1) {
@@ -2447,13 +2495,13 @@ const hasActiveNotificationTab = (userId) => {
2447
2495
  }
2448
2496
  return false;
2449
2497
  };
2450
- const claimNotificationDeliveriesFromStorage = (items, userId, mode) => {
2498
+ const claimNotificationDeliveriesFromStorage = (items, userId, appName, mode) => {
2451
2499
  const storage = getLocalStorage();
2452
2500
  if (!storage) return items;
2453
2501
  const now = Date.now();
2454
2502
  const claimed = [];
2455
2503
  for (const item of items) {
2456
- const key = getDeliveryKey(userId, item.id);
2504
+ const key = getDeliveryKey(userId, appName, item.id);
2457
2505
  const current = parseJsonRecord(storage.getItem(key));
2458
2506
  const deliveredAt = typeof current?.deliveredAt === "number" ? current.deliveredAt : 0;
2459
2507
  if (deliveredAt && now - deliveredAt < DELIVERY_TTL_MS) continue;
@@ -2474,7 +2522,7 @@ const claimNotificationDeliveriesFromStorage = (items, userId, mode) => {
2474
2522
  }
2475
2523
  return claimed;
2476
2524
  };
2477
- const acquireFallbackDeliveryLock = (userId) => {
2525
+ const acquireFallbackDeliveryLock = (userId, appName) => {
2478
2526
  const storage = getLocalStorage();
2479
2527
  if (!storage) {
2480
2528
  return {
@@ -2482,7 +2530,7 @@ const acquireFallbackDeliveryLock = (userId) => {
2482
2530
  expiresAt: Date.now() + FALLBACK_DELIVERY_LOCK_TTL_MS
2483
2531
  };
2484
2532
  }
2485
- const key = getFallbackDeliveryLockKey(userId);
2533
+ const key = getFallbackDeliveryLockKey(userId, appName);
2486
2534
  const now = Date.now();
2487
2535
  try {
2488
2536
  const current = parseJsonRecord(storage.getItem(key));
@@ -2502,10 +2550,10 @@ const acquireFallbackDeliveryLock = (userId) => {
2502
2550
  };
2503
2551
  }
2504
2552
  };
2505
- const releaseFallbackDeliveryLock = (userId, marker) => {
2553
+ const releaseFallbackDeliveryLock = (userId, appName, marker) => {
2506
2554
  const storage = getLocalStorage();
2507
2555
  if (!storage) return;
2508
- const key = getFallbackDeliveryLockKey(userId);
2556
+ const key = getFallbackDeliveryLockKey(userId, appName);
2509
2557
  try {
2510
2558
  const stored = parseJsonRecord(storage.getItem(key));
2511
2559
  if (stored?.token === marker.token) {
@@ -2515,25 +2563,25 @@ const releaseFallbackDeliveryLock = (userId, marker) => {
2515
2563
  return;
2516
2564
  }
2517
2565
  };
2518
- const withFallbackDeliveryLock = (userId, callback, fallback) => {
2519
- const marker = acquireFallbackDeliveryLock(userId);
2566
+ const withFallbackDeliveryLock = (userId, appName, callback, fallback) => {
2567
+ const marker = acquireFallbackDeliveryLock(userId, appName);
2520
2568
  if (!marker) return fallback;
2521
2569
  try {
2522
2570
  return callback();
2523
2571
  } finally {
2524
- releaseFallbackDeliveryLock(userId, marker);
2572
+ releaseFallbackDeliveryLock(userId, appName, marker);
2525
2573
  }
2526
2574
  };
2527
- const claimNotificationDeliveries = async (items, userId, mode) => {
2575
+ const claimNotificationDeliveries = async (items, userId, appName, mode) => {
2528
2576
  if (items.length === 0) return [];
2529
2577
  const claim = () => {
2530
- if (mode === "native" && hasActiveNotificationTab(userId)) return [];
2531
- return claimNotificationDeliveriesFromStorage(items, userId, mode);
2578
+ if (mode === "native" && hasActiveNotificationTab(userId, appName)) return [];
2579
+ return claimNotificationDeliveriesFromStorage(items, userId, appName, mode);
2532
2580
  };
2533
2581
  const locks = getLockManager();
2534
- if (!locks) return withFallbackDeliveryLock(userId, claim, []);
2582
+ if (!locks) return withFallbackDeliveryLock(userId, appName, claim, []);
2535
2583
  try {
2536
- const claimed = await locks.request(getDeliveryLockName(userId), {
2584
+ const claimed = await locks.request(getDeliveryLockName(userId, appName), {
2537
2585
  mode: "exclusive",
2538
2586
  ifAvailable: true
2539
2587
  }, (lock) => {
@@ -2563,16 +2611,16 @@ const canShowNativeNotification = () => {
2563
2611
  if (!("Notification" in window)) return false;
2564
2612
  return window.Notification.permission === "granted";
2565
2613
  };
2566
- const focusNotificationLink = (link) => {
2614
+ const focusNotificationAction = (action) => {
2567
2615
  window.focus();
2568
- if (link) {
2569
- window.location.href = link;
2616
+ if (action) {
2617
+ applyNotificationAction(action);
2570
2618
  }
2571
2619
  };
2572
2620
  const showNativeNotification = (item) => {
2573
2621
  if (!canShowNativeNotification()) return;
2574
2622
  try {
2575
- const link = getWebpushLink(item);
2623
+ const action = getNotificationAction(item);
2576
2624
  const browserNotification = new window.Notification(item.title, {
2577
2625
  body: item.body,
2578
2626
  icon: item.image,
@@ -2580,10 +2628,11 @@ const showNativeNotification = (item) => {
2580
2628
  data: {
2581
2629
  ...item.data,
2582
2630
  notificationId: item.id,
2583
- link
2631
+ link: action?.link ?? "",
2632
+ linkMode: action?.mode ?? "navigate"
2584
2633
  }
2585
2634
  });
2586
- browserNotification.onclick = () => focusNotificationLink(link);
2635
+ browserNotification.onclick = () => focusNotificationAction(action);
2587
2636
  } catch {
2588
2637
  return;
2589
2638
  }
@@ -2596,7 +2645,7 @@ const showNativeNotifications = (items) => {
2596
2645
  body: "Open the notifications drawer to view them.",
2597
2646
  tag: `${NATIVE_NOTIFICATION_TAG_PREFIX}:summary`
2598
2647
  });
2599
- browserNotification.onclick = () => focusNotificationLink("");
2648
+ browserNotification.onclick = () => focusNotificationAction(null);
2600
2649
  } catch {
2601
2650
  return;
2602
2651
  }
@@ -2606,25 +2655,26 @@ const showNativeNotifications = (items) => {
2606
2655
  showNativeNotification(item);
2607
2656
  }
2608
2657
  };
2609
- const showNotificationsForCurrentFocusState = async (items, userId) => {
2610
- writeNotificationTabState(userId);
2658
+ const showNotificationsForCurrentFocusState = async (items, userId, appName) => {
2659
+ writeNotificationTabState(userId, appName);
2611
2660
  if (isDocumentActive()) {
2612
- const claimed2 = await claimNotificationDeliveries(items, userId, "in-app");
2661
+ const claimed2 = await claimNotificationDeliveries(items, userId, appName, "in-app");
2613
2662
  if (claimed2.length > 0) {
2614
2663
  showInAppNotifications(claimed2);
2615
2664
  }
2616
2665
  return;
2617
2666
  }
2618
2667
  if (!canShowNativeNotification()) return;
2619
- const claimed = await claimNotificationDeliveries(items, userId, "native");
2668
+ const claimed = await claimNotificationDeliveries(items, userId, appName, "native");
2620
2669
  if (claimed.length > 0) {
2621
2670
  showNativeNotifications(claimed);
2622
2671
  }
2623
2672
  };
2624
2673
  function NotificationsRealtimeProvider(t0) {
2625
- const $ = c(52);
2674
+ const $ = c(57);
2626
2675
  const {
2627
2676
  userId,
2677
+ appName,
2628
2678
  limit: t1,
2629
2679
  toastOnNew: t2,
2630
2680
  children
@@ -2640,207 +2690,217 @@ function NotificationsRealtimeProvider(t0) {
2640
2690
  t3 = $[1];
2641
2691
  }
2642
2692
  const trimmedUserId = t3;
2643
- const canUseRts = Boolean(trimmedUserId);
2644
2693
  let t4;
2645
- if ($[2] !== canUseRts || $[3] !== trimmedUserId) {
2646
- t4 = canUseRts ? {
2647
- userId: trimmedUserId
2648
- } : {};
2649
- $[2] = canUseRts;
2650
- $[3] = trimmedUserId;
2651
- $[4] = t4;
2694
+ if ($[2] !== appName) {
2695
+ t4 = getNormalizedNotificationAppName(appName);
2696
+ $[2] = appName;
2697
+ $[3] = t4;
2652
2698
  } else {
2653
- t4 = $[4];
2699
+ t4 = $[3];
2654
2700
  }
2701
+ const normalizedAppName = t4;
2702
+ const canUseRts = Boolean(trimmedUserId);
2655
2703
  let t5;
2656
- if ($[5] !== canUseRts) {
2657
- t5 = {
2658
- key: "rb.notifications.settings",
2659
- limit: 1,
2660
- enabled: canUseRts
2661
- };
2662
- $[5] = canUseRts;
2704
+ if ($[4] !== canUseRts || $[5] !== trimmedUserId) {
2705
+ t5 = canUseRts ? {
2706
+ userId: trimmedUserId
2707
+ } : {};
2708
+ $[4] = canUseRts;
2709
+ $[5] = trimmedUserId;
2663
2710
  $[6] = t5;
2664
2711
  } else {
2665
2712
  t5 = $[6];
2666
2713
  }
2667
- const settingsQuery = useQuery("RBNotificationSettings", t4, t5);
2668
- const settings = settingsQuery.data?.[0] ?? null;
2669
2714
  let t6;
2670
- if ($[7] !== settings) {
2671
- t6 = buildDisabledTopics(settings);
2672
- $[7] = settings;
2715
+ if ($[7] !== canUseRts) {
2716
+ t6 = {
2717
+ key: "rb.notifications.settings",
2718
+ limit: 1,
2719
+ enabled: canUseRts
2720
+ };
2721
+ $[7] = canUseRts;
2673
2722
  $[8] = t6;
2674
2723
  } else {
2675
2724
  t6 = $[8];
2676
2725
  }
2677
- const disabledTopics = t6;
2726
+ const settingsQuery = useQuery("RBNotificationSettings", t5, t6);
2727
+ const settings = settingsQuery.data?.[0] ?? null;
2678
2728
  let t7;
2729
+ if ($[9] !== settings) {
2730
+ t7 = buildDisabledTopics(settings);
2731
+ $[9] = settings;
2732
+ $[10] = t7;
2733
+ } else {
2734
+ t7 = $[10];
2735
+ }
2736
+ const disabledTopics = t7;
2737
+ let t8;
2679
2738
  bb0: {
2680
2739
  if (!canUseRts) {
2681
- let t83;
2682
- if ($[9] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
2683
- t83 = {};
2684
- $[9] = t83;
2740
+ let t93;
2741
+ if ($[11] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
2742
+ t93 = {};
2743
+ $[11] = t93;
2685
2744
  } else {
2686
- t83 = $[9];
2745
+ t93 = $[11];
2687
2746
  }
2688
- t7 = t83;
2747
+ t8 = t93;
2689
2748
  break bb0;
2690
2749
  }
2691
- let t82;
2692
- if ($[10] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
2693
- t82 = {
2750
+ let t92;
2751
+ if ($[12] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
2752
+ t92 = {
2694
2753
  $exists: false
2695
2754
  };
2696
- $[10] = t82;
2755
+ $[12] = t92;
2697
2756
  } else {
2698
- t82 = $[10];
2757
+ t92 = $[12];
2699
2758
  }
2700
2759
  let base;
2701
- if ($[11] !== disabledTopics || $[12] !== trimmedUserId) {
2760
+ if ($[13] !== disabledTopics || $[14] !== trimmedUserId) {
2702
2761
  base = {
2703
2762
  userId: trimmedUserId,
2704
- archivedAt: t82
2763
+ archivedAt: t92
2705
2764
  };
2706
2765
  if (disabledTopics.length > 0) {
2707
- let t92;
2708
- if ($[14] !== disabledTopics) {
2709
- t92 = {
2766
+ let t102;
2767
+ if ($[16] !== disabledTopics) {
2768
+ t102 = {
2710
2769
  $nin: disabledTopics
2711
2770
  };
2712
- $[14] = disabledTopics;
2713
- $[15] = t92;
2771
+ $[16] = disabledTopics;
2772
+ $[17] = t102;
2714
2773
  } else {
2715
- t92 = $[15];
2774
+ t102 = $[17];
2716
2775
  }
2717
- base.topic = t92;
2776
+ base.topic = t102;
2718
2777
  }
2719
- $[11] = disabledTopics;
2720
- $[12] = trimmedUserId;
2721
- $[13] = base;
2778
+ $[13] = disabledTopics;
2779
+ $[14] = trimmedUserId;
2780
+ $[15] = base;
2722
2781
  } else {
2723
- base = $[13];
2782
+ base = $[15];
2724
2783
  }
2725
- t7 = base;
2784
+ t8 = base;
2726
2785
  }
2727
- const query = t7;
2728
- let t8;
2729
- if ($[16] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
2730
- t8 = {
2786
+ const query = t8;
2787
+ let t9;
2788
+ if ($[18] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
2789
+ t9 = {
2731
2790
  createdAt: -1
2732
2791
  };
2733
- $[16] = t8;
2792
+ $[18] = t9;
2734
2793
  } else {
2735
- t8 = $[16];
2794
+ t9 = $[18];
2736
2795
  }
2737
- let t9;
2738
- if ($[17] !== canUseRts || $[18] !== limit) {
2739
- t9 = {
2796
+ let t10;
2797
+ if ($[19] !== canUseRts || $[20] !== limit) {
2798
+ t10 = {
2740
2799
  key: "rb.notifications",
2741
- sort: t8,
2800
+ sort: t9,
2742
2801
  limit,
2743
2802
  enabled: canUseRts
2744
2803
  };
2745
- $[17] = canUseRts;
2746
- $[18] = limit;
2747
- $[19] = t9;
2804
+ $[19] = canUseRts;
2805
+ $[20] = limit;
2806
+ $[21] = t10;
2748
2807
  } else {
2749
- t9 = $[19];
2808
+ t10 = $[21];
2750
2809
  }
2751
- const notificationsQuery = useQuery("RBNotification", query, t9);
2752
- let t10;
2810
+ const notificationsQuery = useQuery("RBNotification", query, t10);
2811
+ let t11;
2753
2812
  bb1: {
2754
2813
  const raw = notificationsQuery.data;
2755
2814
  if (!Array.isArray(raw)) {
2756
- let t113;
2757
- if ($[20] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
2758
- t113 = [];
2759
- $[20] = t113;
2815
+ let t123;
2816
+ if ($[22] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
2817
+ t123 = [];
2818
+ $[22] = t123;
2760
2819
  } else {
2761
- t113 = $[20];
2820
+ t123 = $[22];
2762
2821
  }
2763
- t10 = t113;
2822
+ t11 = t123;
2764
2823
  break bb1;
2765
2824
  }
2766
- let t112;
2767
- if ($[21] !== raw) {
2768
- t112 = raw.map(_temp).filter(_temp2);
2769
- $[21] = raw;
2770
- $[22] = t112;
2825
+ let t122;
2826
+ if ($[23] !== raw) {
2827
+ t122 = raw.map(_temp).filter(_temp2);
2828
+ $[23] = raw;
2829
+ $[24] = t122;
2771
2830
  } else {
2772
- t112 = $[22];
2831
+ t122 = $[24];
2773
2832
  }
2774
- t10 = t112;
2833
+ t11 = t122;
2775
2834
  }
2776
- const notifications = t10;
2777
- let t11;
2778
- if ($[23] !== notifications) {
2779
- t11 = notifications.reduce(_temp3, 0);
2780
- $[23] = notifications;
2781
- $[24] = t11;
2782
- } else {
2783
- t11 = $[24];
2784
- }
2785
- const unreadCount = t11;
2835
+ const notifications = t11;
2786
2836
  let t12;
2787
2837
  if ($[25] !== notifications) {
2788
- t12 = notifications.reduce(_temp4, 0);
2838
+ t12 = notifications.reduce(_temp3, 0);
2789
2839
  $[25] = notifications;
2790
2840
  $[26] = t12;
2791
2841
  } else {
2792
2842
  t12 = $[26];
2793
2843
  }
2794
- const unseenCount = t12;
2844
+ const unreadCount = t12;
2795
2845
  let t13;
2796
- if ($[27] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
2797
- t13 = /* @__PURE__ */ new Set();
2798
- $[27] = t13;
2846
+ if ($[27] !== notifications) {
2847
+ t13 = notifications.reduce(_temp4, 0);
2848
+ $[27] = notifications;
2849
+ $[28] = t13;
2799
2850
  } else {
2800
- t13 = $[27];
2851
+ t13 = $[28];
2801
2852
  }
2802
- const lastToastIds = useRef(t13);
2803
- const hasSeededToastIds = useRef(false);
2853
+ const unseenCount = t13;
2804
2854
  let t14;
2805
- if ($[28] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
2806
- t14 = Date.now();
2807
- $[28] = t14;
2855
+ if ($[29] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
2856
+ t14 = /* @__PURE__ */ new Set();
2857
+ $[29] = t14;
2808
2858
  } else {
2809
- t14 = $[28];
2859
+ t14 = $[29];
2810
2860
  }
2811
- const toastStartMs = useRef(t14);
2861
+ const lastToastIds = useRef(t14);
2862
+ const hasSeededToastIds = useRef(false);
2812
2863
  let t15;
2813
- if ($[29] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
2814
- t15 = () => {
2864
+ if ($[30] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
2865
+ t15 = Date.now();
2866
+ $[30] = t15;
2867
+ } else {
2868
+ t15 = $[30];
2869
+ }
2870
+ const toastStartMs = useRef(t15);
2871
+ let t16;
2872
+ if ($[31] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
2873
+ t16 = () => {
2815
2874
  hasSeededToastIds.current = false;
2816
2875
  lastToastIds.current = /* @__PURE__ */ new Set();
2817
2876
  toastStartMs.current = Date.now();
2818
2877
  };
2819
- $[29] = t15;
2820
- } else {
2821
- t15 = $[29];
2822
- }
2823
- let t16;
2824
- if ($[30] !== trimmedUserId) {
2825
- t16 = [trimmedUserId];
2826
- $[30] = trimmedUserId;
2827
2878
  $[31] = t16;
2828
2879
  } else {
2829
2880
  t16 = $[31];
2830
2881
  }
2831
- useEffect(t15, t16);
2832
2882
  let t17;
2883
+ if ($[32] !== normalizedAppName || $[33] !== trimmedUserId) {
2884
+ t17 = [normalizedAppName, trimmedUserId];
2885
+ $[32] = normalizedAppName;
2886
+ $[33] = trimmedUserId;
2887
+ $[34] = t17;
2888
+ } else {
2889
+ t17 = $[34];
2890
+ }
2891
+ useEffect(t16, t17);
2833
2892
  let t18;
2834
- if ($[32] !== canUseRts || $[33] !== trimmedUserId) {
2835
- t17 = () => {
2893
+ let t19;
2894
+ if ($[35] !== canUseRts || $[36] !== normalizedAppName || $[37] !== trimmedUserId) {
2895
+ t18 = () => {
2836
2896
  if (!canUseRts) {
2837
2897
  return;
2838
2898
  }
2839
2899
  if (typeof window === "undefined" || typeof document === "undefined") {
2840
2900
  return;
2841
2901
  }
2842
- const writeState = () => writeNotificationTabState(trimmedUserId);
2843
- const removeState = () => removeNotificationTabState(trimmedUserId);
2902
+ const writeState = () => writeNotificationTabState(trimmedUserId, normalizedAppName);
2903
+ const removeState = () => removeNotificationTabState(trimmedUserId, normalizedAppName);
2844
2904
  writeState();
2845
2905
  const intervalId = window.setInterval(writeState, ACTIVE_TAB_HEARTBEAT_MS);
2846
2906
  window.addEventListener("focus", writeState);
@@ -2858,20 +2918,21 @@ function NotificationsRealtimeProvider(t0) {
2858
2918
  removeState();
2859
2919
  };
2860
2920
  };
2861
- t18 = [canUseRts, trimmedUserId];
2862
- $[32] = canUseRts;
2863
- $[33] = trimmedUserId;
2864
- $[34] = t17;
2865
- $[35] = t18;
2921
+ t19 = [canUseRts, normalizedAppName, trimmedUserId];
2922
+ $[35] = canUseRts;
2923
+ $[36] = normalizedAppName;
2924
+ $[37] = trimmedUserId;
2925
+ $[38] = t18;
2926
+ $[39] = t19;
2866
2927
  } else {
2867
- t17 = $[34];
2868
- t18 = $[35];
2928
+ t18 = $[38];
2929
+ t19 = $[39];
2869
2930
  }
2870
- useEffect(t17, t18);
2871
- let t19;
2931
+ useEffect(t18, t19);
2872
2932
  let t20;
2873
- if ($[36] !== canUseRts || $[37] !== notifications || $[38] !== notificationsQuery.loading || $[39] !== toastOnNew || $[40] !== trimmedUserId) {
2874
- t19 = () => {
2933
+ let t21;
2934
+ if ($[40] !== canUseRts || $[41] !== normalizedAppName || $[42] !== notifications || $[43] !== notificationsQuery.loading || $[44] !== toastOnNew || $[45] !== trimmedUserId) {
2935
+ t20 = () => {
2875
2936
  if (!toastOnNew) {
2876
2937
  return;
2877
2938
  }
@@ -2892,7 +2953,7 @@ function NotificationsRealtimeProvider(t0) {
2892
2953
  return createdAtMs >= toastStartMs.current - NEW_NOTIFICATION_START_TOLERANCE_MS;
2893
2954
  });
2894
2955
  if (eligible.length) {
2895
- showNotificationsForCurrentFocusState(eligible, trimmedUserId);
2956
+ showNotificationsForCurrentFocusState(eligible, trimmedUserId, normalizedAppName);
2896
2957
  }
2897
2958
  return;
2898
2959
  }
@@ -2913,51 +2974,52 @@ function NotificationsRealtimeProvider(t0) {
2913
2974
  if (!eligible_0.length) {
2914
2975
  return;
2915
2976
  }
2916
- showNotificationsForCurrentFocusState(eligible_0, trimmedUserId);
2977
+ showNotificationsForCurrentFocusState(eligible_0, trimmedUserId, normalizedAppName);
2917
2978
  };
2918
- t20 = [canUseRts, notifications, notificationsQuery.loading, toastOnNew, trimmedUserId];
2919
- $[36] = canUseRts;
2920
- $[37] = notifications;
2921
- $[38] = notificationsQuery.loading;
2922
- $[39] = toastOnNew;
2923
- $[40] = trimmedUserId;
2924
- $[41] = t19;
2925
- $[42] = t20;
2979
+ t21 = [canUseRts, normalizedAppName, notifications, notificationsQuery.loading, toastOnNew, trimmedUserId];
2980
+ $[40] = canUseRts;
2981
+ $[41] = normalizedAppName;
2982
+ $[42] = notifications;
2983
+ $[43] = notificationsQuery.loading;
2984
+ $[44] = toastOnNew;
2985
+ $[45] = trimmedUserId;
2986
+ $[46] = t20;
2987
+ $[47] = t21;
2926
2988
  } else {
2927
- t19 = $[41];
2928
- t20 = $[42];
2989
+ t20 = $[46];
2990
+ t21 = $[47];
2929
2991
  }
2930
- useEffect(t19, t20);
2931
- let t21;
2932
- if ($[43] !== notifications || $[44] !== notificationsQuery.error || $[45] !== notificationsQuery.loading || $[46] !== unreadCount || $[47] !== unseenCount) {
2933
- t21 = {
2992
+ useEffect(t20, t21);
2993
+ let t22;
2994
+ if ($[48] !== notifications || $[49] !== notificationsQuery.error || $[50] !== notificationsQuery.loading || $[51] !== unreadCount || $[52] !== unseenCount) {
2995
+ t22 = {
2934
2996
  notifications,
2935
2997
  unreadCount,
2936
2998
  unseenCount,
2937
2999
  loading: notificationsQuery.loading,
2938
3000
  error: notificationsQuery.error
2939
3001
  };
2940
- $[43] = notifications;
2941
- $[44] = notificationsQuery.error;
2942
- $[45] = notificationsQuery.loading;
2943
- $[46] = unreadCount;
2944
- $[47] = unseenCount;
2945
- $[48] = t21;
3002
+ $[48] = notifications;
3003
+ $[49] = notificationsQuery.error;
3004
+ $[50] = notificationsQuery.loading;
3005
+ $[51] = unreadCount;
3006
+ $[52] = unseenCount;
3007
+ $[53] = t22;
2946
3008
  } else {
2947
- t21 = $[48];
2948
- }
2949
- const value = t21;
2950
- const t22 = canUseRts ? value : null;
2951
- let t23;
2952
- if ($[49] !== children || $[50] !== t22) {
2953
- t23 = /* @__PURE__ */ jsx(NotificationsRealtimeContext.Provider, { value: t22, children });
2954
- $[49] = children;
2955
- $[50] = t22;
2956
- $[51] = t23;
3009
+ t22 = $[53];
3010
+ }
3011
+ const value = t22;
3012
+ const t23 = canUseRts ? value : null;
3013
+ let t24;
3014
+ if ($[54] !== children || $[55] !== t23) {
3015
+ t24 = /* @__PURE__ */ jsx(NotificationsRealtimeContext.Provider, { value: t23, children });
3016
+ $[54] = children;
3017
+ $[55] = t23;
3018
+ $[56] = t24;
2957
3019
  } else {
2958
- t23 = $[51];
3020
+ t24 = $[56];
2959
3021
  }
2960
- return t23;
3022
+ return t24;
2961
3023
  }
2962
3024
  function _temp5(n_2) {
2963
3025
  return n_2.id;