@iblai/web-utils 1.3.2 → 1.4.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
@@ -1,9 +1,10 @@
1
1
  'use strict';
2
2
 
3
- var React = require('react');
3
+ var o = require('react');
4
4
  var dataLayer = require('@iblai/data-layer');
5
5
  var jsxRuntime = require('react/jsx-runtime');
6
6
  var iblaiApi = require('@iblai/iblai-api');
7
+ var vt = require('react-dom');
7
8
  var axios = require('axios');
8
9
 
9
10
  function _interopNamespaceDefault(e) {
@@ -23,7 +24,7 @@ function _interopNamespaceDefault(e) {
23
24
  return Object.freeze(n);
24
25
  }
25
26
 
26
- var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
27
+ var o__namespace = /*#__PURE__*/_interopNamespaceDefault(o);
27
28
 
28
29
  const SUBSCRIPTION_TRIGGERS = {
29
30
  PRICING_MODAL: "TRIGGER_PRICING_MODAL",
@@ -113,9 +114,9 @@ const useSubscriptionHandler = (subscriptionFlow) => {
113
114
  const [getUserApps] = dataLayer.useLazyGetUserAppsQuery();
114
115
  // Trial period state management
115
116
  const [createStripeCustomerPortal] = dataLayer.useCreateStripeCustomerPortalMutation();
116
- const [freeTrialIntervalCheckCounter, setFreeTrialIntervalCheckCounter] = React.useState(24 * 60 * 60000); // Default check every 24 hours
117
- const [trialCounterStarted, setTrialCounterStarted] = React.useState(false);
118
- const [freeTrialIntervalID, setFreeTrialIntervalID] = React.useState(0);
117
+ const [freeTrialIntervalCheckCounter, setFreeTrialIntervalCheckCounter] = o.useState(24 * 60 * 60000); // Default check every 24 hours
118
+ const [trialCounterStarted, setTrialCounterStarted] = o.useState(false);
119
+ const [freeTrialIntervalID, setFreeTrialIntervalID] = o.useState(0);
119
120
  // Utility queries and hooks
120
121
  const [getFreeUsageCount] = dataLayer.useLazyGetFreeUsageCountQuery();
121
122
  const { getTimeDifferenceBetweenTwoDates, getDayJSDurationObjFromSeconds } = useDayJs();
@@ -1956,7 +1957,7 @@ class SubscriptionFlowV2 {
1956
1957
  }
1957
1958
 
1958
1959
  const useExternalPricingPlan = ({ pricingModalData, userEmail, }) => {
1959
- const pricingBoxIframeRef = React.useRef(null);
1960
+ const pricingBoxIframeRef = o.useRef(null);
1960
1961
  const getIFrameReadyData = async () => {
1961
1962
  return {
1962
1963
  referenceId: (pricingModalData === null || pricingModalData === void 0 ? void 0 : pricingModalData.referenceId) || "",
@@ -1975,7 +1976,7 @@ const useExternalPricingPlan = ({ pricingModalData, userEmail, }) => {
1975
1976
  (_b = (_a = pricingBoxIframeRef === null || pricingBoxIframeRef === void 0 ? void 0 : pricingBoxIframeRef.current) === null || _a === void 0 ? void 0 : _a.contentWindow) === null || _b === void 0 ? void 0 : _b.postMessage(JSON.stringify({ data: dataToSend }), "*");
1976
1977
  }
1977
1978
  };
1978
- React.useEffect(() => {
1979
+ o.useEffect(() => {
1979
1980
  window.addEventListener("message", handleIframePostMessageInteractions);
1980
1981
  return () => {
1981
1982
  window.removeEventListener("message", handleIframePostMessageInteractions);
@@ -2005,16 +2006,16 @@ var hasRequiredUseSyncExternalStoreWithSelector_production;
2005
2006
  function requireUseSyncExternalStoreWithSelector_production () {
2006
2007
  if (hasRequiredUseSyncExternalStoreWithSelector_production) return useSyncExternalStoreWithSelector_production;
2007
2008
  hasRequiredUseSyncExternalStoreWithSelector_production = 1;
2008
- var React$1 = React;
2009
+ var React = o;
2009
2010
  function is(x, y) {
2010
2011
  return (x === y && (0 !== x || 1 / x === 1 / y)) || (x !== x && y !== y);
2011
2012
  }
2012
2013
  var objectIs = "function" === typeof Object.is ? Object.is : is,
2013
- useSyncExternalStore = React$1.useSyncExternalStore,
2014
- useRef = React$1.useRef,
2015
- useEffect = React$1.useEffect,
2016
- useMemo = React$1.useMemo,
2017
- useDebugValue = React$1.useDebugValue;
2014
+ useSyncExternalStore = React.useSyncExternalStore,
2015
+ useRef = React.useRef,
2016
+ useEffect = React.useEffect,
2017
+ useMemo = React.useMemo,
2018
+ useDebugValue = React.useDebugValue;
2018
2019
  useSyncExternalStoreWithSelector_production.useSyncExternalStoreWithSelector = function (
2019
2020
  subscribe,
2020
2021
  getSnapshot,
@@ -2107,13 +2108,13 @@ function requireUseSyncExternalStoreWithSelector_development () {
2107
2108
  "function" ===
2108
2109
  typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart &&
2109
2110
  __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
2110
- var React$1 = React,
2111
+ var React = o,
2111
2112
  objectIs = "function" === typeof Object.is ? Object.is : is,
2112
- useSyncExternalStore = React$1.useSyncExternalStore,
2113
- useRef = React$1.useRef,
2114
- useEffect = React$1.useEffect,
2115
- useMemo = React$1.useMemo,
2116
- useDebugValue = React$1.useDebugValue;
2113
+ useSyncExternalStore = React.useSyncExternalStore,
2114
+ useRef = React.useRef,
2115
+ useEffect = React.useEffect,
2116
+ useMemo = React.useMemo,
2117
+ useDebugValue = React.useDebugValue;
2117
2118
  useSyncExternalStoreWithSelector_development.useSyncExternalStoreWithSelector = function (
2118
2119
  subscribe,
2119
2120
  getSnapshot,
@@ -2240,17 +2241,17 @@ var gT = typeof globalThis !== "undefined" ? globalThis : (
2240
2241
  {}
2241
2242
  );
2242
2243
  function getContext() {
2243
- if (!React__namespace.createContext) return {};
2244
+ if (!o__namespace.createContext) return {};
2244
2245
  const contextMap = gT[ContextKey] ??= /* @__PURE__ */ new Map();
2245
- let realContext = contextMap.get(React__namespace.createContext);
2246
+ let realContext = contextMap.get(o__namespace.createContext);
2246
2247
  if (!realContext) {
2247
- realContext = React__namespace.createContext(
2248
+ realContext = o__namespace.createContext(
2248
2249
  null
2249
2250
  );
2250
2251
  if (process.env.NODE_ENV !== "production") {
2251
2252
  realContext.displayName = "ReactRedux";
2252
2253
  }
2253
- contextMap.set(React__namespace.createContext, realContext);
2254
+ contextMap.set(o__namespace.createContext, realContext);
2254
2255
  }
2255
2256
  return realContext;
2256
2257
  }
@@ -2259,7 +2260,7 @@ var ReactReduxContext = /* @__PURE__ */ getContext();
2259
2260
  // src/hooks/useReduxContext.ts
2260
2261
  function createReduxContextHook(context = ReactReduxContext) {
2261
2262
  return function useReduxContext2() {
2262
- const contextValue = React__namespace.useContext(context);
2263
+ const contextValue = o__namespace.useContext(context);
2263
2264
  if (process.env.NODE_ENV !== "production" && !contextValue) {
2264
2265
  throw new Error(
2265
2266
  "could not find react-redux context value; please ensure the component is wrapped in a <Provider>"
@@ -2320,8 +2321,8 @@ function createSelectorHook(context = ReactReduxContext) {
2320
2321
  }
2321
2322
  const reduxContext = useReduxContext2();
2322
2323
  const { store, subscription, getServerState } = reduxContext;
2323
- const firstRun = React__namespace.useRef(true);
2324
- const wrappedSelector = React__namespace.useCallback(
2324
+ const firstRun = o__namespace.useRef(true);
2325
+ const wrappedSelector = o__namespace.useCallback(
2325
2326
  {
2326
2327
  [selector.name](state) {
2327
2328
  const selected = selector(state);
@@ -2384,7 +2385,7 @@ function createSelectorHook(context = ReactReduxContext) {
2384
2385
  wrappedSelector,
2385
2386
  equalityFn
2386
2387
  );
2387
- React__namespace.useDebugValue(selectedState);
2388
+ o__namespace.useDebugValue(selectedState);
2388
2389
  return selectedState;
2389
2390
  };
2390
2391
  Object.assign(useSelector2, {
@@ -2825,14 +2826,14 @@ async function validateJwtToken(storageService) {
2825
2826
  }
2826
2827
  }
2827
2828
  function useAuthProvider({ middleware = new Map(), onAuthSuccess, onAuthFailure, redirectToAuthSpa, hasNonExpiredAuthToken, username, pathname, storageService, skipAuthCheck, token, enableStorageSync = true, }) {
2828
- const [isAuthenticating, setIsAuthenticating] = React.useState(true);
2829
- const [userIsAccessingPublicRoute, setUserIsAccessingPublicRoute] = React.useState(false);
2830
- const [initialSyncComplete, setInitialSyncComplete] = React.useState(false);
2831
- const cookieCheckIntervalRef = React.useRef(null);
2832
- const lastLogoutTimestampRef = React.useRef(null);
2829
+ const [isAuthenticating, setIsAuthenticating] = o.useState(true);
2830
+ const [userIsAccessingPublicRoute, setUserIsAccessingPublicRoute] = o.useState(false);
2831
+ const [initialSyncComplete, setInitialSyncComplete] = o.useState(false);
2832
+ const cookieCheckIntervalRef = o.useRef(null);
2833
+ const lastLogoutTimestampRef = o.useRef(null);
2833
2834
  // Guard to prevent poll from firing after a redirect has been initiated.
2834
2835
  // Once set, no further redirects or cookie syncs will happen.
2835
- const isRedirectingRef = React.useRef(false);
2836
+ const isRedirectingRef = o.useRef(false);
2836
2837
  // RTK Query hook for refreshing JWT token
2837
2838
  const [refreshJwtToken] = dataLayer.useLazyRefreshJwtTokenQuery();
2838
2839
  /**
@@ -2868,7 +2869,7 @@ function useAuthProvider({ middleware = new Map(), onAuthSuccess, onAuthFailure,
2868
2869
  * On React Native, this is a no-op
2869
2870
  * Skipped if enableStorageSync is false
2870
2871
  */
2871
- React.useEffect(() => {
2872
+ o.useEffect(() => {
2872
2873
  console.log("[AuthProvider] cookie-sync effect running", {
2873
2874
  pathname,
2874
2875
  enableStorageSync,
@@ -2973,7 +2974,7 @@ function useAuthProvider({ middleware = new Map(), onAuthSuccess, onAuthFailure,
2973
2974
  * On React Native, this is a no-op
2974
2975
  * Skipped if enableStorageSync is false
2975
2976
  */
2976
- React.useEffect(() => {
2977
+ o.useEffect(() => {
2977
2978
  if (!storageService || !isWeb$1() || !enableStorageSync)
2978
2979
  return;
2979
2980
  const handleStorageChange = async (event) => {
@@ -3073,7 +3074,7 @@ function useAuthProvider({ middleware = new Map(), onAuthSuccess, onAuthFailure,
3073
3074
  safeRedirectToAuthSpa();
3074
3075
  }
3075
3076
  }
3076
- React.useEffect(() => {
3077
+ o.useEffect(() => {
3077
3078
  // Wait for initial sync to complete before performing auth check
3078
3079
  if (!initialSyncComplete) {
3079
3080
  console.log("[useAuthProvider] Waiting for initial sync to complete...");
@@ -3106,13 +3107,13 @@ function useAuthProvider({ middleware = new Map(), onAuthSuccess, onAuthFailure,
3106
3107
  setUserIsAccessingPublicRoute,
3107
3108
  };
3108
3109
  }
3109
- const AuthContext = React.createContext(undefined);
3110
+ const AuthContext = o.createContext(undefined);
3110
3111
  /**
3111
3112
  * Hook to access the auth context
3112
3113
  * @throws Error if used outside of AuthContextProvider
3113
3114
  */
3114
3115
  const useAuthContext = () => {
3115
- const context = React.useContext(AuthContext);
3116
+ const context = o.useContext(AuthContext);
3116
3117
  if (!context)
3117
3118
  console.error("useAuthContext must be used within a provider");
3118
3119
  return context;
@@ -3195,7 +3196,7 @@ function AuthProvider({ children, fallback, middleware = new Map(), onAuthSucces
3195
3196
  const isWeb = () => {
3196
3197
  return typeof window !== "undefined" && typeof document !== "undefined";
3197
3198
  };
3198
- const TenantContext = React.createContext(undefined);
3199
+ const TenantContext = o.createContext(undefined);
3199
3200
  /**
3200
3201
  * Context Provider component that wraps children with tenant context
3201
3202
  */
@@ -3204,7 +3205,7 @@ const TenantContextProvider = ({ value, children }) => (jsxRuntime.jsx(TenantCon
3204
3205
  * Hook to access the tenant context
3205
3206
  * @returns TenantContextType
3206
3207
  */
3207
- const useTenantContext = () => React.useContext(TenantContext);
3208
+ const useTenantContext = () => o.useContext(TenantContext);
3208
3209
  /**
3209
3210
  * TenantProvider Component
3210
3211
  *
@@ -3221,20 +3222,20 @@ function TenantProvider({ children, fallback, onAuthSuccess, onAuthFailure, curr
3221
3222
  return jsxRuntime.jsx(jsxRuntime.Fragment, { children: children });
3222
3223
  }
3223
3224
  const { userIsAccessingPublicRoute, setUserIsAccessingPublicRoute } = useAuthContext();
3224
- const [determineUserPath, setDetermineUserPath] = React.useState(false);
3225
- const [isLoading, setIsLoading] = React.useState(true);
3225
+ const [determineUserPath, setDetermineUserPath] = o.useState(false);
3226
+ const [isLoading, setIsLoading] = o.useState(true);
3226
3227
  const [fetchUserTenants] = dataLayer.useLazyGetUserTenantsQuery();
3227
3228
  const [getUserApps] = dataLayer.useLazyGetUserAppsQuery();
3228
3229
  const [joinTenant] = dataLayer.useJoinTenantMutation();
3229
3230
  const [fetchTenantMetadata] = dataLayer.useLazyGetTenantMetadataQuery();
3230
3231
  const [getAppToken] = dataLayer.useGetAppTokensMutation();
3231
- const [tenantKey, setTenantKey] = React.useState(currentTenant);
3232
- const [metadata, setMetadata] = React.useState({});
3232
+ const [tenantKey, setTenantKey] = o.useState(currentTenant);
3233
+ const [metadata, setMetadata] = o.useState({});
3233
3234
  // Fetch custom domain to get platform_key
3234
3235
  const currentDomain = typeof window !== "undefined" ? window.location.hostname : "";
3235
3236
  const { data: customDomainData, isLoading: isLoadingCustomDomain, isError: isCustomDomainError, } = dataLayer.useGetCustomDomainsQuery({ params: { domain: currentDomain } }, { skip: !isWeb() || !currentDomain || skipCustomDomainCheck });
3236
3237
  // Extract platform_key from custom domain response to use as requestedTenant
3237
- const { customDomainPlatformKey, isAdvertisingTenant } = React.useMemo(() => {
3238
+ const { customDomainPlatformKey, isAdvertisingTenant } = o.useMemo(() => {
3238
3239
  let platformKey;
3239
3240
  let isAdvertising = false;
3240
3241
  if (customDomainData &&
@@ -3513,6 +3514,7 @@ function TenantProvider({ children, fallback, onAuthSuccess, onAuthFailure, curr
3513
3514
  platform_name: tenant.platform_name,
3514
3515
  is_advertising: !!((_d = tenantMetadata === null || tenantMetadata === void 0 ? void 0 : tenantMetadata.metadata) === null || _d === void 0 ? void 0 : _d.is_advertising),
3515
3516
  is_enterprise: tenant.is_enterprise,
3517
+ show_paywall: tenant.show_paywall,
3516
3518
  });
3517
3519
  const rbacPermissions = await loadPlatformPermissions(tenant.key);
3518
3520
  onLoadPlatformPermissions === null || onLoadPlatformPermissions === void 0 ? void 0 : onLoadPlatformPermissions(rbacPermissions);
@@ -3604,7 +3606,7 @@ function TenantProvider({ children, fallback, onAuthSuccess, onAuthFailure, curr
3604
3606
  }
3605
3607
  }
3606
3608
  // Effect to handle tenant determination when auth state changes
3607
- React.useEffect(() => {
3609
+ o.useEffect(() => {
3608
3610
  // Wait for custom domain query to complete (unless skipped or error)
3609
3611
  const customDomainQuerySkipped = !isWeb() || !currentDomain;
3610
3612
  if (!customDomainQuerySkipped && isLoadingCustomDomain) {
@@ -3683,7 +3685,7 @@ function MentorProvider({ children, fallback, onAuthSuccess, onAuthFailure, redi
3683
3685
  if (skip) {
3684
3686
  return jsxRuntime.jsx(jsxRuntime.Fragment, { children: children });
3685
3687
  }
3686
- const [isLoading, setIsLoading] = React.useState(true);
3688
+ const [isLoading, setIsLoading] = o.useState(true);
3687
3689
  const { userIsAccessingPublicRoute, isLoggedIn } = useAuthContext();
3688
3690
  const { determineUserPath, tenantKey, metadata } = useTenantContext();
3689
3691
  const isMainTenant = tenantKey === mainTenantKey;
@@ -4020,7 +4022,7 @@ function MentorProvider({ children, fallback, onAuthSuccess, onAuthFailure, redi
4020
4022
  }
4021
4023
  }
4022
4024
  // Effect to handle mentor determination when tenant path is determined
4023
- React.useEffect(() => {
4025
+ o.useEffect(() => {
4024
4026
  async function checkMentor() {
4025
4027
  console.log("starting mentor check process", determineUserPath, requestedMentorId, tenantKey, userIsAccessingPublicRoute, window.location.href);
4026
4028
  if (userIsAccessingPublicRoute && !requestedMentorId) {
@@ -6460,43 +6462,43 @@ class TimeTracker {
6460
6462
 
6461
6463
  function useTimeTracker(config) {
6462
6464
  var _a;
6463
- const trackerRef = React.useRef(null);
6464
- const enabledRef = React.useRef((_a = config.enabled) !== null && _a !== void 0 ? _a : true);
6465
- const defaultGetCurrentUrl = React.useCallback(() => {
6465
+ const trackerRef = o.useRef(null);
6466
+ const enabledRef = o.useRef((_a = config.enabled) !== null && _a !== void 0 ? _a : true);
6467
+ const defaultGetCurrentUrl = o.useCallback(() => {
6466
6468
  if (typeof window !== "undefined") {
6467
6469
  return window.location.pathname + window.location.search;
6468
6470
  }
6469
6471
  return "/";
6470
6472
  }, []);
6471
6473
  const getCurrentUrl = config.getCurrentUrl || defaultGetCurrentUrl;
6472
- const defaultOnRouteChange = React.useCallback(() => {
6474
+ const defaultOnRouteChange = o.useCallback(() => {
6473
6475
  // No-op for platforms that don't support route change events
6474
6476
  return () => { };
6475
6477
  }, []);
6476
6478
  const onRouteChange = config.onRouteChange || defaultOnRouteChange;
6477
- const pause = React.useCallback(() => {
6479
+ const pause = o.useCallback(() => {
6478
6480
  if (trackerRef.current) {
6479
6481
  trackerRef.current.pause();
6480
6482
  }
6481
6483
  }, []);
6482
- const resume = React.useCallback(() => {
6484
+ const resume = o.useCallback(() => {
6483
6485
  if (trackerRef.current) {
6484
6486
  trackerRef.current.resume();
6485
6487
  }
6486
6488
  }, []);
6487
- const getTimeSpentSinceLastReset = React.useCallback(() => {
6489
+ const getTimeSpentSinceLastReset = o.useCallback(() => {
6488
6490
  if (trackerRef.current) {
6489
6491
  return trackerRef.current.getTimeSpentSinceLastReset();
6490
6492
  }
6491
6493
  return 0;
6492
6494
  }, []);
6493
- const getTrackerCurrentUrl = React.useCallback(() => {
6495
+ const getTrackerCurrentUrl = o.useCallback(() => {
6494
6496
  if (trackerRef.current) {
6495
6497
  return trackerRef.current.getCurrentUrl();
6496
6498
  }
6497
6499
  return getCurrentUrl();
6498
6500
  }, [getCurrentUrl]);
6499
- React.useEffect(() => {
6501
+ o.useEffect(() => {
6500
6502
  var _a;
6501
6503
  enabledRef.current = (_a = config.enabled) !== null && _a !== void 0 ? _a : true;
6502
6504
  if (enabledRef.current) {
@@ -6520,7 +6522,7 @@ function useTimeTracker(config) {
6520
6522
  getCurrentUrl,
6521
6523
  onRouteChange,
6522
6524
  ]);
6523
- React.useEffect(() => {
6525
+ o.useEffect(() => {
6524
6526
  var _a;
6525
6527
  if (config.enabled !== enabledRef.current) {
6526
6528
  if (config.enabled && !trackerRef.current) {
@@ -6555,34 +6557,34 @@ function useTimeTracker(config) {
6555
6557
 
6556
6558
  function useTimeTrackerNative(config) {
6557
6559
  var _a;
6558
- const trackerRef = React.useRef(null);
6559
- const enabledRef = React.useRef((_a = config.enabled) !== null && _a !== void 0 ? _a : true);
6560
- const getCurrentUrl = React.useCallback(() => {
6560
+ const trackerRef = o.useRef(null);
6561
+ const enabledRef = o.useRef((_a = config.enabled) !== null && _a !== void 0 ? _a : true);
6562
+ const getCurrentUrl = o.useCallback(() => {
6561
6563
  return config.getCurrentRoute();
6562
6564
  }, [config]);
6563
- const pause = React.useCallback(() => {
6565
+ const pause = o.useCallback(() => {
6564
6566
  if (trackerRef.current) {
6565
6567
  trackerRef.current.pause();
6566
6568
  }
6567
6569
  }, []);
6568
- const resume = React.useCallback(() => {
6570
+ const resume = o.useCallback(() => {
6569
6571
  if (trackerRef.current) {
6570
6572
  trackerRef.current.resume();
6571
6573
  }
6572
6574
  }, []);
6573
- const getTimeSpentSinceLastReset = React.useCallback(() => {
6575
+ const getTimeSpentSinceLastReset = o.useCallback(() => {
6574
6576
  if (trackerRef.current) {
6575
6577
  return trackerRef.current.getTimeSpentSinceLastReset();
6576
6578
  }
6577
6579
  return 0;
6578
6580
  }, []);
6579
- const getTrackerCurrentUrl = React.useCallback(() => {
6581
+ const getTrackerCurrentUrl = o.useCallback(() => {
6580
6582
  if (trackerRef.current) {
6581
6583
  return trackerRef.current.getCurrentUrl();
6582
6584
  }
6583
6585
  return getCurrentUrl();
6584
6586
  }, [getCurrentUrl]);
6585
- React.useEffect(() => {
6587
+ o.useEffect(() => {
6586
6588
  var _a;
6587
6589
  enabledRef.current = (_a = config.enabled) !== null && _a !== void 0 ? _a : true;
6588
6590
  if (enabledRef.current) {
@@ -6606,7 +6608,7 @@ function useTimeTrackerNative(config) {
6606
6608
  config.onRouteChange,
6607
6609
  getCurrentUrl,
6608
6610
  ]);
6609
- React.useEffect(() => {
6611
+ o.useEffect(() => {
6610
6612
  var _a;
6611
6613
  if (config.enabled !== enabledRef.current) {
6612
6614
  if (config.enabled && !trackerRef.current) {
@@ -7090,45 +7092,45 @@ function isTauriApp() {
7090
7092
  }
7091
7093
  const useChat = ({ wsUrl, wsToken, flowConfig, sessionId, stopGenerationWsUrl, enableHaptics = false, hapticFeedback, store, errorHandler, onStatusChange, onStreamingChange, onStreamingMessageUpdate, WebSocketImpl = WebSocket, redirectToAuthSpa, sendMessageToParentWebsite, on402Error, onOAuthRequired, onOAuthResolved, onOfflineWithoutLocalLLM, isOffline = false, }) => {
7092
7094
  const dispatch = useDispatch();
7093
- const isWebSocketPaused = React.useRef(false);
7094
- const ws = React.useRef(null);
7095
- const isConnected = React.useRef(false);
7096
- const messageQueue = React.useRef([]);
7095
+ const isWebSocketPaused = o.useRef(false);
7096
+ const ws = o.useRef(null);
7097
+ const isConnected = o.useRef(false);
7098
+ const messageQueue = o.useRef([]);
7097
7099
  // Keep sessionId in a ref so sendMessage always reads the latest value,
7098
7100
  // avoiding stale closures when Redux updates sessionIds between renders.
7099
- const sessionIdRef = React.useRef(sessionId);
7101
+ const sessionIdRef = o.useRef(sessionId);
7100
7102
  sessionIdRef.current = sessionId;
7101
- const currentStreamingMessage = React.useRef({
7103
+ const currentStreamingMessage = o.useRef({
7102
7104
  id: null,
7103
7105
  content: "",
7104
7106
  });
7105
7107
  // Track artifact state during streaming
7106
- const currentArtifact = React.useRef(null);
7108
+ const currentArtifact = o.useRef(null);
7107
7109
  // Store pending artifact version to add when message is finalized (eos)
7108
7110
  // This is needed because artifact_end can fire before eos
7109
- const pendingArtifactVersion = React.useRef(null);
7111
+ const pendingArtifactVersion = o.useRef(null);
7110
7112
  // Content buffer for batching artifact streaming updates
7111
7113
  // This prevents excessive state updates and the "Maximum update depth exceeded" error
7112
- const artifactContentBuffer = React.useRef({
7114
+ const artifactContentBuffer = o.useRef({
7113
7115
  content: "",
7114
7116
  lastFlushTime: 0,
7115
7117
  flushTimer: null,
7116
7118
  });
7117
- const stopGenerationSocket = React.useRef(null);
7118
- const isInitialConnection = React.useRef(true);
7119
- const connectionAttempts = React.useRef(0);
7119
+ const stopGenerationSocket = o.useRef(null);
7120
+ const isInitialConnection = o.useRef(true);
7121
+ const connectionAttempts = o.useRef(0);
7120
7122
  const { userIsAccessingPublicRoute } = useAuthContext();
7121
7123
  const iframeContext = useSelector(selectIframeContext);
7122
7124
  const chatMetadata = useSelector(selectMetadata);
7123
7125
  const documentFilter = useSelector(selectDocumentFilter);
7124
7126
  const linkToken = useSelector(selectToken);
7125
7127
  // Ollama/offline mode state
7126
- const ollamaAbortController = React.useRef(null);
7127
- const ollamaConversationHistory = React.useRef([]);
7128
+ const ollamaAbortController = o.useRef(null);
7129
+ const ollamaConversationHistory = o.useRef([]);
7128
7130
  // Track offline state in a ref so event handlers can access current value
7129
7131
  // Note: This ref is updated in the main useEffect that handles offline changes
7130
- const isOfflineRef = React.useRef(isOffline);
7131
- const triggerHapticFeedback = React.useCallback(async () => {
7132
+ const isOfflineRef = o.useRef(isOffline);
7133
+ const triggerHapticFeedback = o.useCallback(async () => {
7132
7134
  if (enableHaptics && hapticFeedback) {
7133
7135
  try {
7134
7136
  await hapticFeedback.impactAsync("medium");
@@ -7981,7 +7983,7 @@ const useChat = ({ wsUrl, wsToken, flowConfig, sessionId, stopGenerationWsUrl, e
7981
7983
  });
7982
7984
  });
7983
7985
  };
7984
- const sendMessage = React.useCallback(async (tab, text, options) => {
7986
+ const sendMessage = o.useCallback(async (tab, text, options) => {
7985
7987
  var _a, _b;
7986
7988
  dispatch(chatActions.setShowingSharedChat(false));
7987
7989
  // Allow sending if there's text OR file references
@@ -8262,7 +8264,7 @@ const useChat = ({ wsUrl, wsToken, flowConfig, sessionId, stopGenerationWsUrl, e
8262
8264
  onStreamingMessageUpdate === null || onStreamingMessageUpdate === void 0 ? void 0 : onStreamingMessageUpdate(currentStreamingMessage.current);
8263
8265
  };
8264
8266
  // Initialize WebSocket on mount and handle offline changes
8265
- React.useEffect(() => {
8267
+ o.useEffect(() => {
8266
8268
  var _a;
8267
8269
  // IMPORTANT: Update the ref FIRST before any socket operations
8268
8270
  // This ensures error handlers see the correct offline state immediately
@@ -8292,7 +8294,7 @@ const useChat = ({ wsUrl, wsToken, flowConfig, sessionId, stopGenerationWsUrl, e
8292
8294
  resetConnection();
8293
8295
  };
8294
8296
  }, [isOffline]);
8295
- React.useEffect(() => {
8297
+ o.useEffect(() => {
8296
8298
  sendMessageToParentWebsite === null || sendMessageToParentWebsite === void 0 ? void 0 : sendMessageToParentWebsite({ loaded: true, auth: { ...localStorage } });
8297
8299
  }, []);
8298
8300
  return {
@@ -12878,7 +12880,7 @@ function safeAssign(target, ...args) {
12878
12880
  // src/query/react/constants.ts
12879
12881
  var UNINITIALIZED_VALUE = Symbol();
12880
12882
  function useStableQueryArgs(queryArgs, serialize, endpointDefinition, endpointName) {
12881
- const incoming = React.useMemo(() => ({
12883
+ const incoming = o.useMemo(() => ({
12882
12884
  queryArgs,
12883
12885
  serialized: typeof queryArgs == "object" ? serialize({
12884
12886
  queryArgs,
@@ -12886,8 +12888,8 @@ function useStableQueryArgs(queryArgs, serialize, endpointDefinition, endpointNa
12886
12888
  endpointName
12887
12889
  }) : queryArgs
12888
12890
  }), [queryArgs, serialize, endpointDefinition, endpointName]);
12889
- const cache = React.useRef(incoming);
12890
- React.useEffect(() => {
12891
+ const cache = o.useRef(incoming);
12892
+ o.useEffect(() => {
12891
12893
  if (cache.current.serialized !== incoming.serialized) {
12892
12894
  cache.current = incoming;
12893
12895
  }
@@ -12895,8 +12897,8 @@ function useStableQueryArgs(queryArgs, serialize, endpointDefinition, endpointNa
12895
12897
  return cache.current.serialized === incoming.serialized ? cache.current.queryArgs : queryArgs;
12896
12898
  }
12897
12899
  function useShallowStableValue(value) {
12898
- const cache = React.useRef(value);
12899
- React.useEffect(() => {
12900
+ const cache = o.useRef(value);
12901
+ o.useEffect(() => {
12900
12902
  if (!shallowEqual(cache.current, value)) {
12901
12903
  cache.current = value;
12902
12904
  }
@@ -12909,7 +12911,7 @@ var canUseDOM = () => !!(typeof window !== "undefined" && typeof window.document
12909
12911
  var isDOM = /* @__PURE__ */ canUseDOM();
12910
12912
  var isRunningInReactNative = () => typeof navigator !== "undefined" && navigator.product === "ReactNative";
12911
12913
  var isReactNative = /* @__PURE__ */ isRunningInReactNative();
12912
- var getUseIsomorphicLayoutEffect = () => isDOM || isReactNative ? React.useLayoutEffect : React.useEffect;
12914
+ var getUseIsomorphicLayoutEffect = () => isDOM || isReactNative ? o.useLayoutEffect : o.useEffect;
12913
12915
  var useIsomorphicLayoutEffect = /* @__PURE__ */ getUseIsomorphicLayoutEffect();
12914
12916
  var noPendingQueryStateSelector = (selected) => {
12915
12917
  if (selected.isUninitialized) {
@@ -12946,7 +12948,7 @@ function buildHooks({
12946
12948
  serializeQueryArgs,
12947
12949
  context
12948
12950
  }) {
12949
- const usePossiblyImmediateEffect = unstable__sideEffectsInRender ? (cb) => cb() : React.useEffect;
12951
+ const usePossiblyImmediateEffect = unstable__sideEffectsInRender ? (cb) => cb() : o.useEffect;
12950
12952
  return {
12951
12953
  buildQueryHooks,
12952
12954
  buildInfiniteQueryHooks,
@@ -13018,7 +13020,7 @@ function buildHooks({
13018
13020
  function usePrefetch(endpointName, defaultOptions) {
13019
13021
  const dispatch = useDispatch();
13020
13022
  const stableDefaultOptions = useShallowStableValue(defaultOptions);
13021
- return React.useCallback((arg, options) => dispatch(api.util.prefetch(endpointName, arg, {
13023
+ return o.useCallback((arg, options) => dispatch(api.util.prefetch(endpointName, arg, {
13022
13024
  ...stableDefaultOptions,
13023
13025
  ...options
13024
13026
  })), [endpointName, dispatch, stableDefaultOptions]);
@@ -13036,7 +13038,7 @@ function buildHooks({
13036
13038
  initiate
13037
13039
  } = api.endpoints[endpointName];
13038
13040
  const dispatch = useDispatch();
13039
- const subscriptionSelectorsRef = React.useRef(void 0);
13041
+ const subscriptionSelectorsRef = o.useRef(void 0);
13040
13042
  if (!subscriptionSelectorsRef.current) {
13041
13043
  const returnedValue = dispatch(api.internalActions.internal_getRTKQSubscriptions());
13042
13044
  if (process.env.NODE_ENV !== "production") {
@@ -13066,7 +13068,7 @@ function buildHooks({
13066
13068
  });
13067
13069
  const initialPageParam = rest.initialPageParam;
13068
13070
  const stableInitialPageParam = useShallowStableValue(initialPageParam);
13069
- const promiseRef = React.useRef(void 0);
13071
+ const promiseRef = o.useRef(void 0);
13070
13072
  let {
13071
13073
  queryCacheKey,
13072
13074
  requestId
@@ -13117,8 +13119,8 @@ function buildHooks({
13117
13119
  select
13118
13120
  } = api.endpoints[endpointName];
13119
13121
  const stableArg = useStableQueryArgs(skip ? skipToken : arg, serializeQueryArgs, context.endpointDefinitions[endpointName], endpointName);
13120
- const lastValue = React.useRef(void 0);
13121
- const selectDefaultResult = React.useMemo(() => (
13122
+ const lastValue = o.useRef(void 0);
13123
+ const selectDefaultResult = o.useMemo(() => (
13122
13124
  // Normally ts-ignores are bad and should be avoided, but we're
13123
13125
  // already casting this selector to be `Selector<any>` anyway,
13124
13126
  // so the inconsistencies don't matter here
@@ -13134,7 +13136,7 @@ function buildHooks({
13134
13136
  }
13135
13137
  })
13136
13138
  ), [select, stableArg]);
13137
- const querySelector = React.useMemo(() => selectFromResult ? createSelector([selectDefaultResult], selectFromResult, {
13139
+ const querySelector = o.useMemo(() => selectFromResult ? createSelector([selectDefaultResult], selectFromResult, {
13138
13140
  devModeChecks: {
13139
13141
  identityFunctionCheck: "never"
13140
13142
  }
@@ -13150,7 +13152,7 @@ function buildHooks({
13150
13152
  return useQueryState;
13151
13153
  }
13152
13154
  function usePromiseRefUnsubscribeOnUnmount(promiseRef) {
13153
- React.useEffect(() => {
13155
+ o.useEffect(() => {
13154
13156
  return () => {
13155
13157
  promiseRef.current?.unsubscribe?.();
13156
13158
  promiseRef.current = void 0;
@@ -13165,7 +13167,7 @@ function buildHooks({
13165
13167
  const useQuerySubscription = (arg, options = {}) => {
13166
13168
  const [promiseRef] = useQuerySubscriptionCommonImpl(endpointName, arg, options);
13167
13169
  usePromiseRefUnsubscribeOnUnmount(promiseRef);
13168
- return React.useMemo(() => ({
13170
+ return o.useMemo(() => ({
13169
13171
  /**
13170
13172
  * A method to manually refetch data for the query
13171
13173
  */
@@ -13182,8 +13184,8 @@ function buildHooks({
13182
13184
  initiate
13183
13185
  } = api.endpoints[endpointName];
13184
13186
  const dispatch = useDispatch();
13185
- const [arg, setArg] = React.useState(UNINITIALIZED_VALUE);
13186
- const promiseRef = React.useRef(void 0);
13187
+ const [arg, setArg] = o.useState(UNINITIALIZED_VALUE);
13188
+ const promiseRef = o.useRef(void 0);
13187
13189
  const stableSubscriptionOptions = useShallowStableValue({
13188
13190
  refetchOnReconnect,
13189
13191
  refetchOnFocus,
@@ -13196,11 +13198,11 @@ function buildHooks({
13196
13198
  promiseRef.current?.updateSubscriptionOptions(stableSubscriptionOptions);
13197
13199
  }
13198
13200
  }, [stableSubscriptionOptions]);
13199
- const subscriptionOptionsRef = React.useRef(stableSubscriptionOptions);
13201
+ const subscriptionOptionsRef = o.useRef(stableSubscriptionOptions);
13200
13202
  usePossiblyImmediateEffect(() => {
13201
13203
  subscriptionOptionsRef.current = stableSubscriptionOptions;
13202
13204
  }, [stableSubscriptionOptions]);
13203
- const trigger = React.useCallback(function(arg2, preferCacheValue = false) {
13205
+ const trigger = o.useCallback(function(arg2, preferCacheValue = false) {
13204
13206
  let promise;
13205
13207
  batch(() => {
13206
13208
  promiseRef.current?.unsubscribe();
@@ -13212,24 +13214,24 @@ function buildHooks({
13212
13214
  });
13213
13215
  return promise;
13214
13216
  }, [dispatch, initiate]);
13215
- const reset = React.useCallback(() => {
13217
+ const reset = o.useCallback(() => {
13216
13218
  if (promiseRef.current?.queryCacheKey) {
13217
13219
  dispatch(api.internalActions.removeQueryResult({
13218
13220
  queryCacheKey: promiseRef.current?.queryCacheKey
13219
13221
  }));
13220
13222
  }
13221
13223
  }, [dispatch]);
13222
- React.useEffect(() => {
13224
+ o.useEffect(() => {
13223
13225
  return () => {
13224
13226
  promiseRef?.current?.unsubscribe();
13225
13227
  };
13226
13228
  }, []);
13227
- React.useEffect(() => {
13229
+ o.useEffect(() => {
13228
13230
  if (arg !== UNINITIALIZED_VALUE && !promiseRef.current) {
13229
13231
  trigger(arg, true);
13230
13232
  }
13231
13233
  }, [arg, trigger]);
13232
- return React.useMemo(() => [trigger, arg, {
13234
+ return o.useMemo(() => [trigger, arg, {
13233
13235
  reset
13234
13236
  }], [trigger, arg, reset]);
13235
13237
  };
@@ -13246,10 +13248,10 @@ function buildHooks({
13246
13248
  ...options,
13247
13249
  skip: arg === UNINITIALIZED_VALUE
13248
13250
  });
13249
- const info = React.useMemo(() => ({
13251
+ const info = o.useMemo(() => ({
13250
13252
  lastArg: arg
13251
13253
  }), [arg]);
13252
- return React.useMemo(() => [trigger, {
13254
+ return o.useMemo(() => [trigger, {
13253
13255
  ...queryStateResults,
13254
13256
  reset
13255
13257
  }, info], [trigger, queryStateResults, reset, info]);
@@ -13261,8 +13263,8 @@ function buildHooks({
13261
13263
  ...options
13262
13264
  });
13263
13265
  const debugValue = pick(queryStateResults, ...COMMON_HOOK_DEBUG_FIELDS);
13264
- React.useDebugValue(debugValue);
13265
- return React.useMemo(() => ({
13266
+ o.useDebugValue(debugValue);
13267
+ return o.useMemo(() => ({
13266
13268
  ...queryStateResults,
13267
13269
  ...querySubscriptionResults
13268
13270
  }), [queryStateResults, querySubscriptionResults]);
@@ -13272,11 +13274,11 @@ function buildHooks({
13272
13274
  function buildInfiniteQueryHooks(endpointName) {
13273
13275
  const useInfiniteQuerySubscription = (arg, options = {}) => {
13274
13276
  const [promiseRef, dispatch, initiate, stableSubscriptionOptions] = useQuerySubscriptionCommonImpl(endpointName, arg, options);
13275
- const subscriptionOptionsRef = React.useRef(stableSubscriptionOptions);
13277
+ const subscriptionOptionsRef = o.useRef(stableSubscriptionOptions);
13276
13278
  usePossiblyImmediateEffect(() => {
13277
13279
  subscriptionOptionsRef.current = stableSubscriptionOptions;
13278
13280
  }, [stableSubscriptionOptions]);
13279
- const trigger = React.useCallback(function(arg2, direction) {
13281
+ const trigger = o.useCallback(function(arg2, direction) {
13280
13282
  let promise;
13281
13283
  batch(() => {
13282
13284
  promiseRef.current?.unsubscribe();
@@ -13299,8 +13301,8 @@ function buildHooks({
13299
13301
  context.endpointDefinitions[endpointName],
13300
13302
  endpointName
13301
13303
  );
13302
- const refetch = React.useCallback(() => refetchOrErrorIfUnmounted(promiseRef), [promiseRef]);
13303
- return React.useMemo(() => {
13304
+ const refetch = o.useCallback(() => refetchOrErrorIfUnmounted(promiseRef), [promiseRef]);
13305
+ return o.useMemo(() => {
13304
13306
  const fetchNextPage = () => {
13305
13307
  return trigger(stableArg, "forward");
13306
13308
  };
@@ -13333,8 +13335,8 @@ function buildHooks({
13333
13335
  ...options
13334
13336
  });
13335
13337
  const debugValue = pick(queryStateResults, ...COMMON_HOOK_DEBUG_FIELDS, "hasNextPage", "hasPreviousPage");
13336
- React.useDebugValue(debugValue);
13337
- return React.useMemo(() => ({
13338
+ o.useDebugValue(debugValue);
13339
+ return o.useMemo(() => ({
13338
13340
  ...queryStateResults,
13339
13341
  fetchNextPage,
13340
13342
  fetchPreviousPage,
@@ -13353,13 +13355,13 @@ function buildHooks({
13353
13355
  initiate
13354
13356
  } = api.endpoints[name];
13355
13357
  const dispatch = useDispatch();
13356
- const [promise, setPromise] = React.useState();
13357
- React.useEffect(() => () => {
13358
+ const [promise, setPromise] = o.useState();
13359
+ o.useEffect(() => () => {
13358
13360
  if (!promise?.arg.fixedCacheKey) {
13359
13361
  promise?.reset();
13360
13362
  }
13361
13363
  }, [promise]);
13362
- const triggerMutation = React.useCallback(function(arg) {
13364
+ const triggerMutation = o.useCallback(function(arg) {
13363
13365
  const promise2 = dispatch(initiate(arg, {
13364
13366
  fixedCacheKey
13365
13367
  }));
@@ -13369,14 +13371,14 @@ function buildHooks({
13369
13371
  const {
13370
13372
  requestId
13371
13373
  } = promise || {};
13372
- const selectDefaultResult = React.useMemo(() => select({
13374
+ const selectDefaultResult = o.useMemo(() => select({
13373
13375
  fixedCacheKey,
13374
13376
  requestId: promise?.requestId
13375
13377
  }), [fixedCacheKey, promise, select]);
13376
- const mutationSelector = React.useMemo(() => selectFromResult ? createSelector([selectDefaultResult], selectFromResult) : selectDefaultResult, [selectFromResult, selectDefaultResult]);
13378
+ const mutationSelector = o.useMemo(() => selectFromResult ? createSelector([selectDefaultResult], selectFromResult) : selectDefaultResult, [selectFromResult, selectDefaultResult]);
13377
13379
  const currentState = useSelector(mutationSelector, shallowEqual);
13378
13380
  const originalArgs = fixedCacheKey == null ? promise?.arg.originalArgs : void 0;
13379
- const reset = React.useCallback(() => {
13381
+ const reset = o.useCallback(() => {
13380
13382
  batch(() => {
13381
13383
  if (promise) {
13382
13384
  setPromise(void 0);
@@ -13390,13 +13392,13 @@ function buildHooks({
13390
13392
  });
13391
13393
  }, [dispatch, fixedCacheKey, promise, requestId]);
13392
13394
  const debugValue = pick(currentState, ...COMMON_HOOK_DEBUG_FIELDS, "endpointName");
13393
- React.useDebugValue(debugValue);
13394
- const finalState = React.useMemo(() => ({
13395
+ o.useDebugValue(debugValue);
13396
+ const finalState = o.useMemo(() => ({
13395
13397
  ...currentState,
13396
13398
  originalArgs,
13397
13399
  reset
13398
13400
  }), [currentState, originalArgs, reset]);
13399
- return React.useMemo(() => [triggerMutation, finalState], [triggerMutation, finalState]);
13401
+ return o.useMemo(() => [triggerMutation, finalState], [triggerMutation, finalState]);
13400
13402
  };
13401
13403
  }
13402
13404
  }
@@ -18477,10 +18479,10 @@ function useAdvancedChat({ tenantKey, mentorId, username = ANONYMOUS_USERNAME, t
18477
18479
  isOffline,
18478
18480
  onOfflineWithoutLocalLLM,
18479
18481
  });
18480
- const [isLoadingChats, setIsLoadingChats] = React.useState(true);
18482
+ const [isLoadingChats, setIsLoadingChats] = o.useState(true);
18481
18483
  const [getSessionChats] = dataLayer.useLazyGetSessionIdQuery();
18482
18484
  const [getSharedSessionChats] = dataLayer.useLazyGetSharedSessionIdQuery();
18483
- const getChats = React.useCallback(async () => {
18485
+ const getChats = o.useCallback(async () => {
18484
18486
  var _a, _b, _c, _d;
18485
18487
  let data;
18486
18488
  try {
@@ -18577,7 +18579,7 @@ function useAdvancedChat({ tenantKey, mentorId, username = ANONYMOUS_USERNAME, t
18577
18579
  getSessionChats,
18578
18580
  dispatch,
18579
18581
  ]);
18580
- React.useEffect(() => {
18582
+ o.useEffect(() => {
18581
18583
  if (cachedSessionId === null || cachedSessionId === void 0 ? void 0 : cachedSessionId[mentorId]) {
18582
18584
  dispatch(chatActions.updateSessionIds(cachedSessionId === null || cachedSessionId === void 0 ? void 0 : cachedSessionId[mentorId]));
18583
18585
  // Skip fetching previous chats when offline
@@ -18592,7 +18594,7 @@ function useAdvancedChat({ tenantKey, mentorId, username = ANONYMOUS_USERNAME, t
18592
18594
  setIsLoadingChats(false);
18593
18595
  }
18594
18596
  }, [cachedSessionId, isOffline]);
18595
- const startNewChat = React.useCallback(async () => {
18597
+ const startNewChat = o.useCallback(async () => {
18596
18598
  // Reset all chat state
18597
18599
  if (!showingSharedChat) {
18598
18600
  dispatch(chatActions.resetChats(undefined));
@@ -18653,7 +18655,7 @@ function useAdvancedChat({ tenantKey, mentorId, username = ANONYMOUS_USERNAME, t
18653
18655
  dispatch,
18654
18656
  errorHandler,
18655
18657
  ]);
18656
- React.useEffect(() => {
18658
+ o.useEffect(() => {
18657
18659
  if (!showingSharedChat || mentorSettings.allowAnonymous) {
18658
18660
  if (mentorSettings.allowAnonymous !== undefined &&
18659
18661
  !(cachedSessionId === null || cachedSessionId === void 0 ? void 0 : cachedSessionId[mentorId])) {
@@ -18661,7 +18663,7 @@ function useAdvancedChat({ tenantKey, mentorId, username = ANONYMOUS_USERNAME, t
18661
18663
  }
18662
18664
  }
18663
18665
  }, [shouldStartNewChat, showingSharedChat, mentorSettings.allowAnonymous]);
18664
- React.useEffect(() => {
18666
+ o.useEffect(() => {
18665
18667
  if (sessionIds[activeTab] && sessionIds[activeTab] !== sessionId) {
18666
18668
  dispatch(chatActions.setSessionId(sessionIds[activeTab]));
18667
18669
  // Reset WebSocket connection when session ID changes
@@ -18841,15 +18843,15 @@ function useMentorTools({ tenantKey, mentorId, username = ANONYMOUS_USERNAME, er
18841
18843
  errorHandler === null || errorHandler === void 0 ? void 0 : errorHandler("Failed to update session", error);
18842
18844
  }
18843
18845
  };
18844
- const webBrowsingIsEnabled = React.useMemo(() => hasTool(tools, mentorSettings, TOOLS.WEB_SEARCH), [tools, mentorSettings]);
18845
- const screenSharingIsEnabled = React.useMemo(() => hasTool(tools, mentorSettings, TOOLS.SCREEN_SHARE), [tools, mentorSettings]);
18846
- const deepSearchIsEnabled = React.useMemo(() => hasTool(tools, mentorSettings, TOOLS.DEEP_RESEARCH), [tools, mentorSettings]);
18847
- const studyModeIsEnabled = React.useMemo(() => hasTool(tools, mentorSettings, TOOLS.STUDY_MODE), [tools, mentorSettings]);
18848
- const imageGenerationIsEnabled = React.useMemo(() => hasTool(tools, mentorSettings, TOOLS.IMAGE_GENERATION), [tools, mentorSettings]);
18849
- const codeInterpreterIsEnabled = React.useMemo(() => hasTool(tools, mentorSettings, TOOLS.CODE_INTERPRETER), [tools, mentorSettings]);
18850
- const promptsIsEnabled = React.useMemo(() => { var _a, _b; return !!(((_a = prompts === null || prompts === void 0 ? void 0 : prompts.results) === null || _a === void 0 ? void 0 : _a.length) && ((_b = prompts === null || prompts === void 0 ? void 0 : prompts.results) === null || _b === void 0 ? void 0 : _b.length) > 0); }, [(_a = prompts === null || prompts === void 0 ? void 0 : prompts.results) === null || _a === void 0 ? void 0 : _a.length]);
18851
- const googleSlidesIsEnabled = React.useMemo(() => hasTool(tools, mentorSettings, TOOLS.GOOGLE_SLIDES), [tools, mentorSettings]);
18852
- const googleDocumentIsEnabled = React.useMemo(() => hasTool(tools, mentorSettings, TOOLS.GOOGLE_DOCUMENT), [tools, mentorSettings]);
18846
+ const webBrowsingIsEnabled = o.useMemo(() => hasTool(tools, mentorSettings, TOOLS.WEB_SEARCH), [tools, mentorSettings]);
18847
+ const screenSharingIsEnabled = o.useMemo(() => hasTool(tools, mentorSettings, TOOLS.SCREEN_SHARE), [tools, mentorSettings]);
18848
+ const deepSearchIsEnabled = o.useMemo(() => hasTool(tools, mentorSettings, TOOLS.DEEP_RESEARCH), [tools, mentorSettings]);
18849
+ const studyModeIsEnabled = o.useMemo(() => hasTool(tools, mentorSettings, TOOLS.STUDY_MODE), [tools, mentorSettings]);
18850
+ const imageGenerationIsEnabled = o.useMemo(() => hasTool(tools, mentorSettings, TOOLS.IMAGE_GENERATION), [tools, mentorSettings]);
18851
+ const codeInterpreterIsEnabled = o.useMemo(() => hasTool(tools, mentorSettings, TOOLS.CODE_INTERPRETER), [tools, mentorSettings]);
18852
+ const promptsIsEnabled = o.useMemo(() => { var _a, _b; return !!(((_a = prompts === null || prompts === void 0 ? void 0 : prompts.results) === null || _a === void 0 ? void 0 : _a.length) && ((_b = prompts === null || prompts === void 0 ? void 0 : prompts.results) === null || _b === void 0 ? void 0 : _b.length) > 0); }, [(_a = prompts === null || prompts === void 0 ? void 0 : prompts.results) === null || _a === void 0 ? void 0 : _a.length]);
18853
+ const googleSlidesIsEnabled = o.useMemo(() => hasTool(tools, mentorSettings, TOOLS.GOOGLE_SLIDES), [tools, mentorSettings]);
18854
+ const googleDocumentIsEnabled = o.useMemo(() => hasTool(tools, mentorSettings, TOOLS.GOOGLE_DOCUMENT), [tools, mentorSettings]);
18853
18855
  return {
18854
18856
  tools,
18855
18857
  activeTools,
@@ -18982,6 +18984,64 @@ function useProfileImageUpload(options = {}) {
18982
18984
  // This will be deprecated in favor of the new configuration system
18983
18985
  const METADATAS = loadMetadataConfig();
18984
18986
 
18987
+ var jt=n=>{switch(n){case "success":return ee;case "info":return ae;case "warning":return oe;case "error":return se;default:return null}},te=Array(12).fill(0),Yt=({visible:n,className:e})=>o.createElement("div",{className:["sonner-loading-wrapper",e].filter(Boolean).join(" "),"data-visible":n},o.createElement("div",{className:"sonner-spinner"},te.map((t,a)=>o.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${a}`})))),ee=o.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},o.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",clipRule:"evenodd"})),oe=o.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},o.createElement("path",{fillRule:"evenodd",d:"M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",clipRule:"evenodd"})),ae=o.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},o.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",clipRule:"evenodd"})),se=o.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},o.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})),Ot=o.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},o.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),o.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"}));var Ft=()=>{let[n,e]=o.useState(document.hidden);return o.useEffect(()=>{let t=()=>{e(document.hidden);};return document.addEventListener("visibilitychange",t),()=>window.removeEventListener("visibilitychange",t)},[]),n};var bt=1,yt=class{constructor(){this.subscribe=e=>(this.subscribers.push(e),()=>{let t=this.subscribers.indexOf(e);this.subscribers.splice(t,1);});this.publish=e=>{this.subscribers.forEach(t=>t(e));};this.addToast=e=>{this.publish(e),this.toasts=[...this.toasts,e];};this.create=e=>{var S;let{message:t,...a}=e,u=typeof(e==null?void 0:e.id)=="number"||((S=e.id)==null?void 0:S.length)>0?e.id:bt++,f=this.toasts.find(g=>g.id===u),w=e.dismissible===void 0?true:e.dismissible;return this.dismissedToasts.has(u)&&this.dismissedToasts.delete(u),f?this.toasts=this.toasts.map(g=>g.id===u?(this.publish({...g,...e,id:u,title:t}),{...g,...e,id:u,dismissible:w,title:t}):g):this.addToast({title:t,...a,dismissible:w,id:u}),u};this.dismiss=e=>(this.dismissedToasts.add(e),e||this.toasts.forEach(t=>{this.subscribers.forEach(a=>a({id:t.id,dismiss:true}));}),this.subscribers.forEach(t=>t({id:e,dismiss:true})),e);this.message=(e,t)=>this.create({...t,message:e});this.error=(e,t)=>this.create({...t,message:e,type:"error"});this.success=(e,t)=>this.create({...t,type:"success",message:e});this.info=(e,t)=>this.create({...t,type:"info",message:e});this.warning=(e,t)=>this.create({...t,type:"warning",message:e});this.loading=(e,t)=>this.create({...t,type:"loading",message:e});this.promise=(e,t)=>{if(!t)return;let a;t.loading!==void 0&&(a=this.create({...t,promise:e,type:"loading",message:t.loading,description:typeof t.description!="function"?t.description:void 0}));let u=e instanceof Promise?e:e(),f=a!==void 0,w,S=u.then(async i=>{if(w=["resolve",i],o.isValidElement(i))f=false,this.create({id:a,type:"default",message:i});else if(ie(i)&&!i.ok){f=false;let T=typeof t.error=="function"?await t.error(`HTTP error! status: ${i.status}`):t.error,F=typeof t.description=="function"?await t.description(`HTTP error! status: ${i.status}`):t.description;this.create({id:a,type:"error",message:T,description:F});}else if(t.success!==void 0){f=false;let T=typeof t.success=="function"?await t.success(i):t.success,F=typeof t.description=="function"?await t.description(i):t.description;this.create({id:a,type:"success",message:T,description:F});}}).catch(async i=>{if(w=["reject",i],t.error!==void 0){f=false;let D=typeof t.error=="function"?await t.error(i):t.error,T=typeof t.description=="function"?await t.description(i):t.description;this.create({id:a,type:"error",message:D,description:T});}}).finally(()=>{var i;f&&(this.dismiss(a),a=void 0),(i=t.finally)==null||i.call(t);}),g=()=>new Promise((i,D)=>S.then(()=>w[0]==="reject"?D(w[1]):i(w[1])).catch(D));return typeof a!="string"&&typeof a!="number"?{unwrap:g}:Object.assign(a,{unwrap:g})};this.custom=(e,t)=>{let a=(t==null?void 0:t.id)||bt++;return this.create({jsx:e(a),id:a,...t}),a};this.getActiveToasts=()=>this.toasts.filter(e=>!this.dismissedToasts.has(e.id));this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set;}},v=new yt,ne=(n,e)=>{let t=(e==null?void 0:e.id)||bt++;return v.addToast({title:n,...e,id:t}),t},ie=n=>n&&typeof n=="object"&&"ok"in n&&typeof n.ok=="boolean"&&"status"in n&&typeof n.status=="number",le=ne,ce=()=>v.toasts,de=()=>v.getActiveToasts(),ue=Object.assign(le,{success:v.success,info:v.info,warning:v.warning,error:v.error,custom:v.custom,message:v.message,promise:v.promise,dismiss:v.dismiss,loading:v.loading},{getHistory:ce,getToasts:de});function wt(n,{insertAt:e}={}){if(typeof document=="undefined")return;let t=document.head||document.getElementsByTagName("head")[0],a=document.createElement("style");a.type="text/css",e==="top"&&t.firstChild?t.insertBefore(a,t.firstChild):t.appendChild(a),a.styleSheet?a.styleSheet.cssText=n:a.appendChild(document.createTextNode(n));}wt(`:where(html[dir="ltr"]),:where([data-sonner-toaster][dir="ltr"]){--toast-icon-margin-start: -3px;--toast-icon-margin-end: 4px;--toast-svg-margin-start: -1px;--toast-svg-margin-end: 0px;--toast-button-margin-start: auto;--toast-button-margin-end: 0;--toast-close-button-start: 0;--toast-close-button-end: unset;--toast-close-button-transform: translate(-35%, -35%)}:where(html[dir="rtl"]),:where([data-sonner-toaster][dir="rtl"]){--toast-icon-margin-start: 4px;--toast-icon-margin-end: -3px;--toast-svg-margin-start: 0px;--toast-svg-margin-end: -1px;--toast-button-margin-start: 0;--toast-button-margin-end: auto;--toast-close-button-start: unset;--toast-close-button-end: 0;--toast-close-button-transform: translate(35%, -35%)}:where([data-sonner-toaster]){position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1: hsl(0, 0%, 99%);--gray2: hsl(0, 0%, 97.3%);--gray3: hsl(0, 0%, 95.1%);--gray4: hsl(0, 0%, 93%);--gray5: hsl(0, 0%, 90.9%);--gray6: hsl(0, 0%, 88.7%);--gray7: hsl(0, 0%, 85.8%);--gray8: hsl(0, 0%, 78%);--gray9: hsl(0, 0%, 56.1%);--gray10: hsl(0, 0%, 52.3%);--gray11: hsl(0, 0%, 43.5%);--gray12: hsl(0, 0%, 9%);--border-radius: 8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:none;z-index:999999999;transition:transform .4s ease}:where([data-sonner-toaster][data-lifted="true"]){transform:translateY(-10px)}@media (hover: none) and (pointer: coarse){:where([data-sonner-toaster][data-lifted="true"]){transform:none}}:where([data-sonner-toaster][data-x-position="right"]){right:var(--offset-right)}:where([data-sonner-toaster][data-x-position="left"]){left:var(--offset-left)}:where([data-sonner-toaster][data-x-position="center"]){left:50%;transform:translate(-50%)}:where([data-sonner-toaster][data-y-position="top"]){top:var(--offset-top)}:where([data-sonner-toaster][data-y-position="bottom"]){bottom:var(--offset-bottom)}:where([data-sonner-toast]){--y: translateY(100%);--lift-amount: calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);filter:blur(0);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:none;overflow-wrap:anywhere}:where([data-sonner-toast][data-styled="true"]){padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px #0000001a;width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}:where([data-sonner-toast]:focus-visible){box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast][data-y-position="top"]){top:0;--y: translateY(-100%);--lift: 1;--lift-amount: calc(1 * var(--gap))}:where([data-sonner-toast][data-y-position="bottom"]){bottom:0;--y: translateY(100%);--lift: -1;--lift-amount: calc(var(--lift) * var(--gap))}:where([data-sonner-toast]) :where([data-description]){font-weight:400;line-height:1.4;color:inherit}:where([data-sonner-toast]) :where([data-title]){font-weight:500;line-height:1.5;color:inherit}:where([data-sonner-toast]) :where([data-icon]){display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}:where([data-sonner-toast][data-promise="true"]) :where([data-icon])>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}:where([data-sonner-toast]) :where([data-icon])>*{flex-shrink:0}:where([data-sonner-toast]) :where([data-icon]) svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}:where([data-sonner-toast]) :where([data-content]){display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;cursor:pointer;outline:none;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}:where([data-sonner-toast]) :where([data-button]):focus-visible{box-shadow:0 0 0 2px #0006}:where([data-sonner-toast]) :where([data-button]):first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}:where([data-sonner-toast]) :where([data-cancel]){color:var(--normal-text);background:rgba(0,0,0,.08)}:where([data-sonner-toast][data-theme="dark"]) :where([data-cancel]){background:rgba(255,255,255,.3)}:where([data-sonner-toast]) :where([data-close-button]){position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast] [data-close-button]{background:var(--gray1)}:where([data-sonner-toast]) :where([data-close-button]):focus-visible{box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast]) :where([data-disabled="true"]){cursor:not-allowed}:where([data-sonner-toast]):hover :where([data-close-button]):hover{background:var(--gray2);border-color:var(--gray5)}:where([data-sonner-toast][data-swiping="true"]):before{content:"";position:absolute;left:-50%;right:-50%;height:100%;z-index:-1}:where([data-sonner-toast][data-y-position="top"][data-swiping="true"]):before{bottom:50%;transform:scaleY(3) translateY(50%)}:where([data-sonner-toast][data-y-position="bottom"][data-swiping="true"]):before{top:50%;transform:scaleY(3) translateY(-50%)}:where([data-sonner-toast][data-swiping="false"][data-removed="true"]):before{content:"";position:absolute;inset:0;transform:scaleY(2)}:where([data-sonner-toast]):after{content:"";position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}:where([data-sonner-toast][data-mounted="true"]){--y: translateY(0);opacity:1}:where([data-sonner-toast][data-expanded="false"][data-front="false"]){--scale: var(--toasts-before) * .05 + 1;--y: translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}:where([data-sonner-toast])>*{transition:opacity .4s}:where([data-sonner-toast][data-expanded="false"][data-front="false"][data-styled="true"])>*{opacity:0}:where([data-sonner-toast][data-visible="false"]){opacity:0;pointer-events:none}:where([data-sonner-toast][data-mounted="true"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}:where([data-sonner-toast][data-removed="true"][data-front="true"][data-swipe-out="false"]){--y: translateY(calc(var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="false"]){--y: translateY(40%);opacity:0;transition:transform .5s,opacity .2s}:where([data-sonner-toast][data-removed="true"][data-front="false"]):before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y, 0px)) translate(var(--swipe-amount-x, 0px));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width: 600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-theme=light]{--normal-bg: #fff;--normal-border: var(--gray4);--normal-text: var(--gray12);--success-bg: hsl(143, 85%, 96%);--success-border: hsl(145, 92%, 91%);--success-text: hsl(140, 100%, 27%);--info-bg: hsl(208, 100%, 97%);--info-border: hsl(221, 91%, 91%);--info-text: hsl(210, 92%, 45%);--warning-bg: hsl(49, 100%, 97%);--warning-border: hsl(49, 91%, 91%);--warning-text: hsl(31, 92%, 45%);--error-bg: hsl(359, 100%, 97%);--error-border: hsl(359, 100%, 94%);--error-text: hsl(360, 100%, 45%)}[data-sonner-toaster][data-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg: #000;--normal-border: hsl(0, 0%, 20%);--normal-text: var(--gray1)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg: #fff;--normal-border: var(--gray3);--normal-text: var(--gray12)}[data-sonner-toaster][data-theme=dark]{--normal-bg: #000;--normal-bg-hover: hsl(0, 0%, 12%);--normal-border: hsl(0, 0%, 20%);--normal-border-hover: hsl(0, 0%, 25%);--normal-text: var(--gray1);--success-bg: hsl(150, 100%, 6%);--success-border: hsl(147, 100%, 12%);--success-text: hsl(150, 86%, 65%);--info-bg: hsl(215, 100%, 6%);--info-border: hsl(223, 100%, 12%);--info-text: hsl(216, 87%, 65%);--warning-bg: hsl(64, 100%, 6%);--warning-border: hsl(60, 100%, 12%);--warning-text: hsl(46, 87%, 65%);--error-bg: hsl(358, 76%, 10%);--error-border: hsl(357, 89%, 16%);--error-text: hsl(358, 100%, 81%)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success],[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info],[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning],[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error],[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size: 16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:nth-child(1){animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}to{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}to{opacity:.15}}@media (prefers-reduced-motion){[data-sonner-toast],[data-sonner-toast]>*,.sonner-loading-bar{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}
18988
+ `);function tt(n){return n.label!==void 0}var pe=3,me="32px",ge="16px",Wt=4e3,he=356,be=14,ye=20,we=200;function M(...n){return n.filter(Boolean).join(" ")}function xe(n){let[e,t]=n.split("-"),a=[];return e&&a.push(e),t&&a.push(t),a}var ve=n=>{var Dt,Pt,Nt,Bt,Ct,kt,It,Mt,Ht,At,Lt;let{invert:e,toast:t,unstyled:a,interacting:u,setHeights:f,visibleToasts:w,heights:S,index:g,toasts:i,expanded:D,removeToast:T,defaultRichColors:F,closeButton:et,style:ut,cancelButtonStyle:ft,actionButtonStyle:l,className:ot="",descriptionClassName:at="",duration:X,position:st,gap:pt,loadingIcon:rt,expandByDefault:B,classNames:s,icons:P,closeButtonAriaLabel:nt="Close toast",pauseWhenPageIsHidden:it}=n,[Y,C]=o.useState(null),[lt,J]=o.useState(null),[W,H]=o.useState(false),[A,mt]=o.useState(false),[L,z]=o.useState(false),[ct,d]=o.useState(false),[h,y]=o.useState(false),[R,j]=o.useState(0),[p,_]=o.useState(0),O=o.useRef(t.duration||X||Wt),G=o.useRef(null),k=o.useRef(null),Vt=g===0,Ut=g+1<=w,N=t.type,V=t.dismissible!==false,Kt=t.className||"",Xt=t.descriptionClassName||"",dt=o.useMemo(()=>S.findIndex(r=>r.toastId===t.id)||0,[S,t.id]),Jt=o.useMemo(()=>{var r;return (r=t.closeButton)!=null?r:et},[t.closeButton,et]),Tt=o.useMemo(()=>t.duration||X||Wt,[t.duration,X]),gt=o.useRef(0),U=o.useRef(0),St=o.useRef(0),K=o.useRef(null),[Gt,Qt]=st.split("-"),Rt=o.useMemo(()=>S.reduce((r,m,c)=>c>=dt?r:r+m.height,0),[S,dt]),Et=Ft(),qt=t.invert||e,ht=N==="loading";U.current=o.useMemo(()=>dt*pt+Rt,[dt,Rt]),o.useEffect(()=>{O.current=Tt;},[Tt]),o.useEffect(()=>{H(true);},[]),o.useEffect(()=>{let r=k.current;if(r){let m=r.getBoundingClientRect().height;return _(m),f(c=>[{toastId:t.id,height:m,position:t.position},...c]),()=>f(c=>c.filter(b=>b.toastId!==t.id))}},[f,t.id]),o.useLayoutEffect(()=>{if(!W)return;let r=k.current,m=r.style.height;r.style.height="auto";let c=r.getBoundingClientRect().height;r.style.height=m,_(c),f(b=>b.find(x=>x.toastId===t.id)?b.map(x=>x.toastId===t.id?{...x,height:c}:x):[{toastId:t.id,height:c,position:t.position},...b]);},[W,t.title,t.description,f,t.id]);let $=o.useCallback(()=>{mt(true),j(U.current),f(r=>r.filter(m=>m.toastId!==t.id)),setTimeout(()=>{T(t);},we);},[t,T,f,U]);o.useEffect(()=>{if(t.promise&&N==="loading"||t.duration===1/0||t.type==="loading")return;let r;return D||u||it&&Et?(()=>{if(St.current<gt.current){let b=new Date().getTime()-gt.current;O.current=O.current-b;}St.current=new Date().getTime();})():(()=>{O.current!==1/0&&(gt.current=new Date().getTime(),r=setTimeout(()=>{var b;(b=t.onAutoClose)==null||b.call(t,t),$();},O.current));})(),()=>clearTimeout(r)},[D,u,t,N,it,Et,$]),o.useEffect(()=>{t.delete&&$();},[$,t.delete]);function Zt(){var r,m,c;return P!=null&&P.loading?o.createElement("div",{className:M(s==null?void 0:s.loader,(r=t==null?void 0:t.classNames)==null?void 0:r.loader,"sonner-loader"),"data-visible":N==="loading"},P.loading):rt?o.createElement("div",{className:M(s==null?void 0:s.loader,(m=t==null?void 0:t.classNames)==null?void 0:m.loader,"sonner-loader"),"data-visible":N==="loading"},rt):o.createElement(Yt,{className:M(s==null?void 0:s.loader,(c=t==null?void 0:t.classNames)==null?void 0:c.loader),visible:N==="loading"})}return o.createElement("li",{tabIndex:0,ref:k,className:M(ot,Kt,s==null?void 0:s.toast,(Dt=t==null?void 0:t.classNames)==null?void 0:Dt.toast,s==null?void 0:s.default,s==null?void 0:s[N],(Pt=t==null?void 0:t.classNames)==null?void 0:Pt[N]),"data-sonner-toast":"","data-rich-colors":(Nt=t.richColors)!=null?Nt:F,"data-styled":!(t.jsx||t.unstyled||a),"data-mounted":W,"data-promise":!!t.promise,"data-swiped":h,"data-removed":A,"data-visible":Ut,"data-y-position":Gt,"data-x-position":Qt,"data-index":g,"data-front":Vt,"data-swiping":L,"data-dismissible":V,"data-type":N,"data-invert":qt,"data-swipe-out":ct,"data-swipe-direction":lt,"data-expanded":!!(D||B&&W),style:{"--index":g,"--toasts-before":g,"--z-index":i.length-g,"--offset":`${A?R:U.current}px`,"--initial-height":B?"auto":`${p}px`,...ut,...t.style},onDragEnd:()=>{z(false),C(null),K.current=null;},onPointerDown:r=>{ht||!V||(G.current=new Date,j(U.current),r.target.setPointerCapture(r.pointerId),r.target.tagName!=="BUTTON"&&(z(true),K.current={x:r.clientX,y:r.clientY}));},onPointerUp:()=>{var x,Q,q,Z;if(ct||!V)return;K.current=null;let r=Number(((x=k.current)==null?void 0:x.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),m=Number(((Q=k.current)==null?void 0:Q.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),c=new Date().getTime()-((q=G.current)==null?void 0:q.getTime()),b=Y==="x"?r:m,I=Math.abs(b)/c;if(Math.abs(b)>=ye||I>.11){j(U.current),(Z=t.onDismiss)==null||Z.call(t,t),J(Y==="x"?r>0?"right":"left":m>0?"down":"up"),$(),d(true),y(false);return}z(false),C(null);},onPointerMove:r=>{var Q,q,Z,zt;if(!K.current||!V||((Q=window.getSelection())==null?void 0:Q.toString().length)>0)return;let c=r.clientY-K.current.y,b=r.clientX-K.current.x,I=(q=n.swipeDirections)!=null?q:xe(st);!Y&&(Math.abs(b)>1||Math.abs(c)>1)&&C(Math.abs(b)>Math.abs(c)?"x":"y");let x={x:0,y:0};Y==="y"?(I.includes("top")||I.includes("bottom"))&&(I.includes("top")&&c<0||I.includes("bottom")&&c>0)&&(x.y=c):Y==="x"&&(I.includes("left")||I.includes("right"))&&(I.includes("left")&&b<0||I.includes("right")&&b>0)&&(x.x=b),(Math.abs(x.x)>0||Math.abs(x.y)>0)&&y(true),(Z=k.current)==null||Z.style.setProperty("--swipe-amount-x",`${x.x}px`),(zt=k.current)==null||zt.style.setProperty("--swipe-amount-y",`${x.y}px`);}},Jt&&!t.jsx?o.createElement("button",{"aria-label":nt,"data-disabled":ht,"data-close-button":true,onClick:ht||!V?()=>{}:()=>{var r;$(),(r=t.onDismiss)==null||r.call(t,t);},className:M(s==null?void 0:s.closeButton,(Bt=t==null?void 0:t.classNames)==null?void 0:Bt.closeButton)},(Ct=P==null?void 0:P.close)!=null?Ct:Ot):null,t.jsx||o.isValidElement(t.title)?t.jsx?t.jsx:typeof t.title=="function"?t.title():t.title:o.createElement(o.Fragment,null,N||t.icon||t.promise?o.createElement("div",{"data-icon":"",className:M(s==null?void 0:s.icon,(kt=t==null?void 0:t.classNames)==null?void 0:kt.icon)},t.promise||t.type==="loading"&&!t.icon?t.icon||Zt():null,t.type!=="loading"?t.icon||(P==null?void 0:P[N])||jt(N):null):null,o.createElement("div",{"data-content":"",className:M(s==null?void 0:s.content,(It=t==null?void 0:t.classNames)==null?void 0:It.content)},o.createElement("div",{"data-title":"",className:M(s==null?void 0:s.title,(Mt=t==null?void 0:t.classNames)==null?void 0:Mt.title)},typeof t.title=="function"?t.title():t.title),t.description?o.createElement("div",{"data-description":"",className:M(at,Xt,s==null?void 0:s.description,(Ht=t==null?void 0:t.classNames)==null?void 0:Ht.description)},typeof t.description=="function"?t.description():t.description):null),o.isValidElement(t.cancel)?t.cancel:t.cancel&&tt(t.cancel)?o.createElement("button",{"data-button":true,"data-cancel":true,style:t.cancelButtonStyle||ft,onClick:r=>{var m,c;tt(t.cancel)&&V&&((c=(m=t.cancel).onClick)==null||c.call(m,r),$());},className:M(s==null?void 0:s.cancelButton,(At=t==null?void 0:t.classNames)==null?void 0:At.cancelButton)},t.cancel.label):null,o.isValidElement(t.action)?t.action:t.action&&tt(t.action)?o.createElement("button",{"data-button":true,"data-action":true,style:t.actionButtonStyle||l,onClick:r=>{var m,c;tt(t.action)&&((c=(m=t.action).onClick)==null||c.call(m,r),!r.defaultPrevented&&$());},className:M(s==null?void 0:s.actionButton,(Lt=t==null?void 0:t.classNames)==null?void 0:Lt.actionButton)},t.action.label):null))};function _t(){if(typeof window=="undefined"||typeof document=="undefined")return "ltr";let n=document.documentElement.getAttribute("dir");return n==="auto"||!n?window.getComputedStyle(document.documentElement).direction:n}function Te(n,e){let t={};return [n,e].forEach((a,u)=>{let f=u===1,w=f?"--mobile-offset":"--offset",S=f?ge:me;function g(i){["top","right","bottom","left"].forEach(D=>{t[`${w}-${D}`]=typeof i=="number"?`${i}px`:i;});}typeof a=="number"||typeof a=="string"?g(a):typeof a=="object"?["top","right","bottom","left"].forEach(i=>{a[i]===void 0?t[`${w}-${i}`]=S:t[`${w}-${i}`]=typeof a[i]=="number"?`${a[i]}px`:a[i];}):g(S);}),t}o.forwardRef(function(e,t){let{invert:a,position:u="bottom-right",hotkey:f=["altKey","KeyT"],expand:w,closeButton:S,className:g,offset:i,mobileOffset:D,theme:T="light",richColors:F,duration:et,style:ut,visibleToasts:ft=pe,toastOptions:l,dir:ot=_t(),gap:at=be,loadingIcon:X,icons:st,containerAriaLabel:pt="Notifications",pauseWhenPageIsHidden:rt}=e,[B,s]=o.useState([]),P=o.useMemo(()=>Array.from(new Set([u].concat(B.filter(d=>d.position).map(d=>d.position)))),[B,u]),[nt,it]=o.useState([]),[Y,C]=o.useState(false),[lt,J]=o.useState(false),[W,H]=o.useState(T!=="system"?T:typeof window!="undefined"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),A=o.useRef(null),mt=f.join("+").replace(/Key/g,"").replace(/Digit/g,""),L=o.useRef(null),z=o.useRef(false),ct=o.useCallback(d=>{s(h=>{var y;return (y=h.find(R=>R.id===d.id))!=null&&y.delete||v.dismiss(d.id),h.filter(({id:R})=>R!==d.id)});},[]);return o.useEffect(()=>v.subscribe(d=>{if(d.dismiss){s(h=>h.map(y=>y.id===d.id?{...y,delete:true}:y));return}setTimeout(()=>{vt.flushSync(()=>{s(h=>{let y=h.findIndex(R=>R.id===d.id);return y!==-1?[...h.slice(0,y),{...h[y],...d},...h.slice(y+1)]:[d,...h]});});});}),[]),o.useEffect(()=>{if(T!=="system"){H(T);return}if(T==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?H("dark"):H("light")),typeof window=="undefined")return;let d=window.matchMedia("(prefers-color-scheme: dark)");try{d.addEventListener("change",({matches:h})=>{H(h?"dark":"light");});}catch(h){d.addListener(({matches:y})=>{try{H(y?"dark":"light");}catch(R){console.error(R);}});}},[T]),o.useEffect(()=>{B.length<=1&&C(false);},[B]),o.useEffect(()=>{let d=h=>{var R,j;f.every(p=>h[p]||h.code===p)&&(C(true),(R=A.current)==null||R.focus()),h.code==="Escape"&&(document.activeElement===A.current||(j=A.current)!=null&&j.contains(document.activeElement))&&C(false);};return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[f]),o.useEffect(()=>{if(A.current)return ()=>{L.current&&(L.current.focus({preventScroll:true}),L.current=null,z.current=false);}},[A.current]),o.createElement("section",{ref:t,"aria-label":`${pt} ${mt}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:true},P.map((d,h)=>{var j;let[y,R]=d.split("-");return B.length?o.createElement("ol",{key:d,dir:ot==="auto"?_t():ot,tabIndex:-1,ref:A,className:g,"data-sonner-toaster":true,"data-theme":W,"data-y-position":y,"data-lifted":Y&&B.length>1&&!w,"data-x-position":R,style:{"--front-toast-height":`${((j=nt[0])==null?void 0:j.height)||0}px`,"--width":`${he}px`,"--gap":`${at}px`,...ut,...Te(i,D)},onBlur:p=>{z.current&&!p.currentTarget.contains(p.relatedTarget)&&(z.current=false,L.current&&(L.current.focus({preventScroll:true}),L.current=null));},onFocus:p=>{p.target instanceof HTMLElement&&p.target.dataset.dismissible==="false"||z.current||(z.current=true,L.current=p.relatedTarget);},onMouseEnter:()=>C(true),onMouseMove:()=>C(true),onMouseLeave:()=>{lt||C(false);},onDragEnd:()=>C(false),onPointerDown:p=>{p.target instanceof HTMLElement&&p.target.dataset.dismissible==="false"||J(true);},onPointerUp:()=>J(false)},B.filter(p=>!p.position&&h===0||p.position===d).map((p,_)=>{var O,G;return o.createElement(ve,{key:p.id,icons:st,index:_,toast:p,defaultRichColors:F,duration:(O=l==null?void 0:l.duration)!=null?O:et,className:l==null?void 0:l.className,descriptionClassName:l==null?void 0:l.descriptionClassName,invert:a,visibleToasts:ft,closeButton:(G=l==null?void 0:l.closeButton)!=null?G:S,interacting:lt,position:d,style:l==null?void 0:l.style,unstyled:l==null?void 0:l.unstyled,classNames:l==null?void 0:l.classNames,cancelButtonStyle:l==null?void 0:l.cancelButtonStyle,actionButtonStyle:l==null?void 0:l.actionButtonStyle,removeToast:ct,toasts:B.filter(k=>k.position==p.position),heights:nt.filter(k=>k.position==p.position),setHeights:it,expandByDefault:w,gap:at,loadingIcon:X,expanded:Y,pauseWhenPageIsHidden:rt,swipeDirections:e.swipeDirections})})):null}))});
18989
+
18990
+ function buildCheckoutUrl(baseUrl, email, clientReferenceId) {
18991
+ const separator = baseUrl.includes("?") ? "&" : "?";
18992
+ return `${baseUrl}${separator}locked_prefilled_email=${encodeURIComponent(email)}&client_reference_id=${encodeURIComponent(clientReferenceId)}`;
18993
+ }
18994
+ const useStripeUpgrade = ({ redirectUrl, sourcePlatformKey, mainPlatformKey, currentUserEmail, }) => {
18995
+ const [triggerGetSession] = dataLayer.useLazyGetStripePricingPageSessionQuery();
18996
+ const [isLoading, setIsLoading] = o.useState(false);
18997
+ const [freeUrl, setFreeUrl] = o.useState(null);
18998
+ const [premiumUrl, setPremiumUrl] = o.useState(null);
18999
+ const handleUpgrade = async (redirectPlan) => {
19000
+ setIsLoading(true);
19001
+ try {
19002
+ const result = await triggerGetSession({
19003
+ platform_key: mainPlatformKey,
19004
+ params: {
19005
+ redirect_url: redirectUrl,
19006
+ source_platform_key: sourcePlatformKey,
19007
+ },
19008
+ }).unwrap();
19009
+ const { payment_link_url, client_reference_id } = result;
19010
+ if (!payment_link_url || !isJSON(payment_link_url)) {
19011
+ return;
19012
+ }
19013
+ const links = JSON.parse(payment_link_url);
19014
+ const referenceId = client_reference_id !== null && client_reference_id !== void 0 ? client_reference_id : "";
19015
+ const resolvedFreeUrl = links.free
19016
+ ? buildCheckoutUrl(links.free, currentUserEmail, referenceId)
19017
+ : null;
19018
+ const resolvedPremiumUrl = links.premium
19019
+ ? buildCheckoutUrl(links.premium, currentUserEmail, referenceId)
19020
+ : null;
19021
+ setFreeUrl(resolvedFreeUrl);
19022
+ setPremiumUrl(resolvedPremiumUrl);
19023
+ if (!redirectPlan)
19024
+ return;
19025
+ const target = redirectPlan === "free" ? resolvedFreeUrl : resolvedPremiumUrl;
19026
+ if (target) {
19027
+ window.location.href = target;
19028
+ }
19029
+ }
19030
+ catch (_a) {
19031
+ ue.error("Failed to load upgrade options. Please try again.");
19032
+ }
19033
+ finally {
19034
+ setIsLoading(false);
19035
+ }
19036
+ };
19037
+ return {
19038
+ isLoading,
19039
+ freeUrl,
19040
+ premiumUrl,
19041
+ handleUpgrade,
19042
+ };
19043
+ };
19044
+
18985
19045
  var util;
18986
19046
  (function (util) {
18987
19047
  util.assertEqual = (val) => val;
@@ -23749,6 +23809,7 @@ exports.useExternalPricingPlan = useExternalPricingPlan;
23749
23809
  exports.useMentorSettings = useMentorSettings;
23750
23810
  exports.useMentorTools = useMentorTools;
23751
23811
  exports.useProfileImageUpload = useProfileImageUpload;
23812
+ exports.useStripeUpgrade = useStripeUpgrade;
23752
23813
  exports.useSubscriptionHandler = useSubscriptionHandler;
23753
23814
  exports.useSubscriptionHandlerV2 = useSubscriptionHandlerV2;
23754
23815
  exports.useTenantContext = useTenantContext;