@iblai/web-utils 1.4.0 → 1.5.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.d.ts +2 -1
- package/dist/index.esm.js +355 -25
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +481 -151
- package/dist/index.js.map +1 -1
- package/dist/package.json +1 -1
- package/dist/web-utils/src/providers/tenant-provider.d.ts +2 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var React = 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
|
-
|
|
7
|
+
require('react-dom');
|
|
8
8
|
var axios = require('axios');
|
|
9
9
|
|
|
10
10
|
function _interopNamespaceDefault(e) {
|
|
@@ -24,7 +24,7 @@ function _interopNamespaceDefault(e) {
|
|
|
24
24
|
return Object.freeze(n);
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
var
|
|
27
|
+
var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
|
|
28
28
|
|
|
29
29
|
const SUBSCRIPTION_TRIGGERS = {
|
|
30
30
|
PRICING_MODAL: "TRIGGER_PRICING_MODAL",
|
|
@@ -114,9 +114,9 @@ const useSubscriptionHandler = (subscriptionFlow) => {
|
|
|
114
114
|
const [getUserApps] = dataLayer.useLazyGetUserAppsQuery();
|
|
115
115
|
// Trial period state management
|
|
116
116
|
const [createStripeCustomerPortal] = dataLayer.useCreateStripeCustomerPortalMutation();
|
|
117
|
-
const [freeTrialIntervalCheckCounter, setFreeTrialIntervalCheckCounter] =
|
|
118
|
-
const [trialCounterStarted, setTrialCounterStarted] =
|
|
119
|
-
const [freeTrialIntervalID, setFreeTrialIntervalID] =
|
|
117
|
+
const [freeTrialIntervalCheckCounter, setFreeTrialIntervalCheckCounter] = React.useState(24 * 60 * 60000); // Default check every 24 hours
|
|
118
|
+
const [trialCounterStarted, setTrialCounterStarted] = React.useState(false);
|
|
119
|
+
const [freeTrialIntervalID, setFreeTrialIntervalID] = React.useState(0);
|
|
120
120
|
// Utility queries and hooks
|
|
121
121
|
const [getFreeUsageCount] = dataLayer.useLazyGetFreeUsageCountQuery();
|
|
122
122
|
const { getTimeDifferenceBetweenTwoDates, getDayJSDurationObjFromSeconds } = useDayJs();
|
|
@@ -553,6 +553,13 @@ const MENTOR_AI_CONFIG = {
|
|
|
553
553
|
description: "Display the accessibility menu in the mentor platform.",
|
|
554
554
|
type: "boolean",
|
|
555
555
|
},
|
|
556
|
+
{
|
|
557
|
+
slug: "persistent_chat_input_label",
|
|
558
|
+
label: "Persistent Chat Input Label",
|
|
559
|
+
defaultValue: false,
|
|
560
|
+
description: "Show a visible, persistent label above the chat input. When off, the label is available to screen readers only.",
|
|
561
|
+
type: "boolean",
|
|
562
|
+
},
|
|
556
563
|
{
|
|
557
564
|
slug: "mentor_include_community_mentors",
|
|
558
565
|
label: "Community Mentors",
|
|
@@ -1957,7 +1964,7 @@ class SubscriptionFlowV2 {
|
|
|
1957
1964
|
}
|
|
1958
1965
|
|
|
1959
1966
|
const useExternalPricingPlan = ({ pricingModalData, userEmail, }) => {
|
|
1960
|
-
const pricingBoxIframeRef =
|
|
1967
|
+
const pricingBoxIframeRef = React.useRef(null);
|
|
1961
1968
|
const getIFrameReadyData = async () => {
|
|
1962
1969
|
return {
|
|
1963
1970
|
referenceId: (pricingModalData === null || pricingModalData === void 0 ? void 0 : pricingModalData.referenceId) || "",
|
|
@@ -1976,7 +1983,7 @@ const useExternalPricingPlan = ({ pricingModalData, userEmail, }) => {
|
|
|
1976
1983
|
(_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 }), "*");
|
|
1977
1984
|
}
|
|
1978
1985
|
};
|
|
1979
|
-
|
|
1986
|
+
React.useEffect(() => {
|
|
1980
1987
|
window.addEventListener("message", handleIframePostMessageInteractions);
|
|
1981
1988
|
return () => {
|
|
1982
1989
|
window.removeEventListener("message", handleIframePostMessageInteractions);
|
|
@@ -2006,16 +2013,16 @@ var hasRequiredUseSyncExternalStoreWithSelector_production;
|
|
|
2006
2013
|
function requireUseSyncExternalStoreWithSelector_production () {
|
|
2007
2014
|
if (hasRequiredUseSyncExternalStoreWithSelector_production) return useSyncExternalStoreWithSelector_production;
|
|
2008
2015
|
hasRequiredUseSyncExternalStoreWithSelector_production = 1;
|
|
2009
|
-
var React =
|
|
2016
|
+
var React$1 = React;
|
|
2010
2017
|
function is(x, y) {
|
|
2011
2018
|
return (x === y && (0 !== x || 1 / x === 1 / y)) || (x !== x && y !== y);
|
|
2012
2019
|
}
|
|
2013
2020
|
var objectIs = "function" === typeof Object.is ? Object.is : is,
|
|
2014
|
-
useSyncExternalStore = React.useSyncExternalStore,
|
|
2015
|
-
useRef = React.useRef,
|
|
2016
|
-
useEffect = React.useEffect,
|
|
2017
|
-
useMemo = React.useMemo,
|
|
2018
|
-
useDebugValue = React.useDebugValue;
|
|
2021
|
+
useSyncExternalStore = React$1.useSyncExternalStore,
|
|
2022
|
+
useRef = React$1.useRef,
|
|
2023
|
+
useEffect = React$1.useEffect,
|
|
2024
|
+
useMemo = React$1.useMemo,
|
|
2025
|
+
useDebugValue = React$1.useDebugValue;
|
|
2019
2026
|
useSyncExternalStoreWithSelector_production.useSyncExternalStoreWithSelector = function (
|
|
2020
2027
|
subscribe,
|
|
2021
2028
|
getSnapshot,
|
|
@@ -2108,13 +2115,13 @@ function requireUseSyncExternalStoreWithSelector_development () {
|
|
|
2108
2115
|
"function" ===
|
|
2109
2116
|
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart &&
|
|
2110
2117
|
__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
|
|
2111
|
-
var React =
|
|
2118
|
+
var React$1 = React,
|
|
2112
2119
|
objectIs = "function" === typeof Object.is ? Object.is : is,
|
|
2113
|
-
useSyncExternalStore = React.useSyncExternalStore,
|
|
2114
|
-
useRef = React.useRef,
|
|
2115
|
-
useEffect = React.useEffect,
|
|
2116
|
-
useMemo = React.useMemo,
|
|
2117
|
-
useDebugValue = React.useDebugValue;
|
|
2120
|
+
useSyncExternalStore = React$1.useSyncExternalStore,
|
|
2121
|
+
useRef = React$1.useRef,
|
|
2122
|
+
useEffect = React$1.useEffect,
|
|
2123
|
+
useMemo = React$1.useMemo,
|
|
2124
|
+
useDebugValue = React$1.useDebugValue;
|
|
2118
2125
|
useSyncExternalStoreWithSelector_development.useSyncExternalStoreWithSelector = function (
|
|
2119
2126
|
subscribe,
|
|
2120
2127
|
getSnapshot,
|
|
@@ -2241,17 +2248,17 @@ var gT = typeof globalThis !== "undefined" ? globalThis : (
|
|
|
2241
2248
|
{}
|
|
2242
2249
|
);
|
|
2243
2250
|
function getContext() {
|
|
2244
|
-
if (!
|
|
2251
|
+
if (!React__namespace.createContext) return {};
|
|
2245
2252
|
const contextMap = gT[ContextKey] ??= /* @__PURE__ */ new Map();
|
|
2246
|
-
let realContext = contextMap.get(
|
|
2253
|
+
let realContext = contextMap.get(React__namespace.createContext);
|
|
2247
2254
|
if (!realContext) {
|
|
2248
|
-
realContext =
|
|
2255
|
+
realContext = React__namespace.createContext(
|
|
2249
2256
|
null
|
|
2250
2257
|
);
|
|
2251
2258
|
if (process.env.NODE_ENV !== "production") {
|
|
2252
2259
|
realContext.displayName = "ReactRedux";
|
|
2253
2260
|
}
|
|
2254
|
-
contextMap.set(
|
|
2261
|
+
contextMap.set(React__namespace.createContext, realContext);
|
|
2255
2262
|
}
|
|
2256
2263
|
return realContext;
|
|
2257
2264
|
}
|
|
@@ -2260,7 +2267,7 @@ var ReactReduxContext = /* @__PURE__ */ getContext();
|
|
|
2260
2267
|
// src/hooks/useReduxContext.ts
|
|
2261
2268
|
function createReduxContextHook(context = ReactReduxContext) {
|
|
2262
2269
|
return function useReduxContext2() {
|
|
2263
|
-
const contextValue =
|
|
2270
|
+
const contextValue = React__namespace.useContext(context);
|
|
2264
2271
|
if (process.env.NODE_ENV !== "production" && !contextValue) {
|
|
2265
2272
|
throw new Error(
|
|
2266
2273
|
"could not find react-redux context value; please ensure the component is wrapped in a <Provider>"
|
|
@@ -2321,8 +2328,8 @@ function createSelectorHook(context = ReactReduxContext) {
|
|
|
2321
2328
|
}
|
|
2322
2329
|
const reduxContext = useReduxContext2();
|
|
2323
2330
|
const { store, subscription, getServerState } = reduxContext;
|
|
2324
|
-
const firstRun =
|
|
2325
|
-
const wrappedSelector =
|
|
2331
|
+
const firstRun = React__namespace.useRef(true);
|
|
2332
|
+
const wrappedSelector = React__namespace.useCallback(
|
|
2326
2333
|
{
|
|
2327
2334
|
[selector.name](state) {
|
|
2328
2335
|
const selected = selector(state);
|
|
@@ -2385,7 +2392,7 @@ function createSelectorHook(context = ReactReduxContext) {
|
|
|
2385
2392
|
wrappedSelector,
|
|
2386
2393
|
equalityFn
|
|
2387
2394
|
);
|
|
2388
|
-
|
|
2395
|
+
React__namespace.useDebugValue(selectedState);
|
|
2389
2396
|
return selectedState;
|
|
2390
2397
|
};
|
|
2391
2398
|
Object.assign(useSelector2, {
|
|
@@ -2826,14 +2833,14 @@ async function validateJwtToken(storageService) {
|
|
|
2826
2833
|
}
|
|
2827
2834
|
}
|
|
2828
2835
|
function useAuthProvider({ middleware = new Map(), onAuthSuccess, onAuthFailure, redirectToAuthSpa, hasNonExpiredAuthToken, username, pathname, storageService, skipAuthCheck, token, enableStorageSync = true, }) {
|
|
2829
|
-
const [isAuthenticating, setIsAuthenticating] =
|
|
2830
|
-
const [userIsAccessingPublicRoute, setUserIsAccessingPublicRoute] =
|
|
2831
|
-
const [initialSyncComplete, setInitialSyncComplete] =
|
|
2832
|
-
const cookieCheckIntervalRef =
|
|
2833
|
-
const lastLogoutTimestampRef =
|
|
2836
|
+
const [isAuthenticating, setIsAuthenticating] = React.useState(true);
|
|
2837
|
+
const [userIsAccessingPublicRoute, setUserIsAccessingPublicRoute] = React.useState(false);
|
|
2838
|
+
const [initialSyncComplete, setInitialSyncComplete] = React.useState(false);
|
|
2839
|
+
const cookieCheckIntervalRef = React.useRef(null);
|
|
2840
|
+
const lastLogoutTimestampRef = React.useRef(null);
|
|
2834
2841
|
// Guard to prevent poll from firing after a redirect has been initiated.
|
|
2835
2842
|
// Once set, no further redirects or cookie syncs will happen.
|
|
2836
|
-
const isRedirectingRef =
|
|
2843
|
+
const isRedirectingRef = React.useRef(false);
|
|
2837
2844
|
// RTK Query hook for refreshing JWT token
|
|
2838
2845
|
const [refreshJwtToken] = dataLayer.useLazyRefreshJwtTokenQuery();
|
|
2839
2846
|
/**
|
|
@@ -2845,6 +2852,11 @@ function useAuthProvider({ middleware = new Map(), onAuthSuccess, onAuthFailure,
|
|
|
2845
2852
|
console.log("[AuthProvider] Redirect already in progress, skipping");
|
|
2846
2853
|
return;
|
|
2847
2854
|
}
|
|
2855
|
+
// Skip if a tenant switch is already in progress
|
|
2856
|
+
if (isWeb$1() && document.cookie.includes("ibl_tenant_switching")) {
|
|
2857
|
+
console.log("[AuthProvider] Tenant switch in progress, skipping redirect");
|
|
2858
|
+
return;
|
|
2859
|
+
}
|
|
2848
2860
|
isRedirectingRef.current = true;
|
|
2849
2861
|
// NOTE: we intentionally do NOT clear the interval here.
|
|
2850
2862
|
// The isRedirectingRef guard prevents redundant redirects while navigation
|
|
@@ -2869,7 +2881,7 @@ function useAuthProvider({ middleware = new Map(), onAuthSuccess, onAuthFailure,
|
|
|
2869
2881
|
* On React Native, this is a no-op
|
|
2870
2882
|
* Skipped if enableStorageSync is false
|
|
2871
2883
|
*/
|
|
2872
|
-
|
|
2884
|
+
React.useEffect(() => {
|
|
2873
2885
|
console.log("[AuthProvider] cookie-sync effect running", {
|
|
2874
2886
|
pathname,
|
|
2875
2887
|
enableStorageSync,
|
|
@@ -2940,6 +2952,8 @@ function useAuthProvider({ middleware = new Map(), onAuthSuccess, onAuthFailure,
|
|
|
2940
2952
|
needsRefresh,
|
|
2941
2953
|
userDataOutOfSync,
|
|
2942
2954
|
pathname,
|
|
2955
|
+
currentLogoutTimestamp,
|
|
2956
|
+
lastLogoutTimestampRef: lastLogoutTimestampRef.current,
|
|
2943
2957
|
});
|
|
2944
2958
|
if (needsRefresh) {
|
|
2945
2959
|
console.log("[auth-redirect] Cookie sync detected changes from another SPA, refreshing page");
|
|
@@ -2974,7 +2988,7 @@ function useAuthProvider({ middleware = new Map(), onAuthSuccess, onAuthFailure,
|
|
|
2974
2988
|
* On React Native, this is a no-op
|
|
2975
2989
|
* Skipped if enableStorageSync is false
|
|
2976
2990
|
*/
|
|
2977
|
-
|
|
2991
|
+
React.useEffect(() => {
|
|
2978
2992
|
if (!storageService || !isWeb$1() || !enableStorageSync)
|
|
2979
2993
|
return;
|
|
2980
2994
|
const handleStorageChange = async (event) => {
|
|
@@ -3074,7 +3088,7 @@ function useAuthProvider({ middleware = new Map(), onAuthSuccess, onAuthFailure,
|
|
|
3074
3088
|
safeRedirectToAuthSpa();
|
|
3075
3089
|
}
|
|
3076
3090
|
}
|
|
3077
|
-
|
|
3091
|
+
React.useEffect(() => {
|
|
3078
3092
|
// Wait for initial sync to complete before performing auth check
|
|
3079
3093
|
if (!initialSyncComplete) {
|
|
3080
3094
|
console.log("[useAuthProvider] Waiting for initial sync to complete...");
|
|
@@ -3107,13 +3121,13 @@ function useAuthProvider({ middleware = new Map(), onAuthSuccess, onAuthFailure,
|
|
|
3107
3121
|
setUserIsAccessingPublicRoute,
|
|
3108
3122
|
};
|
|
3109
3123
|
}
|
|
3110
|
-
const AuthContext =
|
|
3124
|
+
const AuthContext = React.createContext(undefined);
|
|
3111
3125
|
/**
|
|
3112
3126
|
* Hook to access the auth context
|
|
3113
3127
|
* @throws Error if used outside of AuthContextProvider
|
|
3114
3128
|
*/
|
|
3115
3129
|
const useAuthContext = () => {
|
|
3116
|
-
const context =
|
|
3130
|
+
const context = React.useContext(AuthContext);
|
|
3117
3131
|
if (!context)
|
|
3118
3132
|
console.error("useAuthContext must be used within a provider");
|
|
3119
3133
|
return context;
|
|
@@ -3196,7 +3210,7 @@ function AuthProvider({ children, fallback, middleware = new Map(), onAuthSucces
|
|
|
3196
3210
|
const isWeb = () => {
|
|
3197
3211
|
return typeof window !== "undefined" && typeof document !== "undefined";
|
|
3198
3212
|
};
|
|
3199
|
-
const TenantContext =
|
|
3213
|
+
const TenantContext = React.createContext(undefined);
|
|
3200
3214
|
/**
|
|
3201
3215
|
* Context Provider component that wraps children with tenant context
|
|
3202
3216
|
*/
|
|
@@ -3205,7 +3219,7 @@ const TenantContextProvider = ({ value, children }) => (jsxRuntime.jsx(TenantCon
|
|
|
3205
3219
|
* Hook to access the tenant context
|
|
3206
3220
|
* @returns TenantContextType
|
|
3207
3221
|
*/
|
|
3208
|
-
const useTenantContext = () =>
|
|
3222
|
+
const useTenantContext = () => React.useContext(TenantContext);
|
|
3209
3223
|
/**
|
|
3210
3224
|
* TenantProvider Component
|
|
3211
3225
|
*
|
|
@@ -3216,26 +3230,26 @@ const useTenantContext = () => o.useContext(TenantContext);
|
|
|
3216
3230
|
* 4. Handles tenant-specific domain redirects
|
|
3217
3231
|
* 5. Maintains tenant access state
|
|
3218
3232
|
*/
|
|
3219
|
-
function TenantProvider({ children, fallback, onAuthSuccess, onAuthFailure, currentTenant, requestedTenant, saveCurrentTenant, saveUserTenants, handleTenantSwitch, saveVisitingTenant, removeVisitingTenant, saveUserTokens, saveTenant, onAutoJoinUserToTenant, redirectToAuthSpa, username, isIframed = false, setUseMentorProvider, skip = false, onLoadPlatformPermissions, skipCustomDomainCheck = false, }) {
|
|
3233
|
+
function TenantProvider({ children, fallback, onAuthSuccess, onAuthFailure, currentTenant, requestedTenant, saveCurrentTenant, saveUserTenants, handleTenantSwitch, saveVisitingTenant, removeVisitingTenant, saveUserTokens, saveTenant, onAutoJoinUserToTenant, redirectToAuthSpa, username, isIframed = false, setUseMentorProvider, skip = false, onLoadPlatformPermissions, skipCustomDomainCheck = false, onTenantMismatch = () => { }, }) {
|
|
3220
3234
|
// If skip is true, just return children without any provider logic
|
|
3221
3235
|
if (skip) {
|
|
3222
3236
|
return jsxRuntime.jsx(jsxRuntime.Fragment, { children: children });
|
|
3223
3237
|
}
|
|
3224
3238
|
const { userIsAccessingPublicRoute, setUserIsAccessingPublicRoute } = useAuthContext();
|
|
3225
|
-
const [determineUserPath, setDetermineUserPath] =
|
|
3226
|
-
const [isLoading, setIsLoading] =
|
|
3239
|
+
const [determineUserPath, setDetermineUserPath] = React.useState(false);
|
|
3240
|
+
const [isLoading, setIsLoading] = React.useState(true);
|
|
3227
3241
|
const [fetchUserTenants] = dataLayer.useLazyGetUserTenantsQuery();
|
|
3228
3242
|
const [getUserApps] = dataLayer.useLazyGetUserAppsQuery();
|
|
3229
3243
|
const [joinTenant] = dataLayer.useJoinTenantMutation();
|
|
3230
3244
|
const [fetchTenantMetadata] = dataLayer.useLazyGetTenantMetadataQuery();
|
|
3231
3245
|
const [getAppToken] = dataLayer.useGetAppTokensMutation();
|
|
3232
|
-
const [tenantKey, setTenantKey] =
|
|
3233
|
-
const [metadata, setMetadata] =
|
|
3246
|
+
const [tenantKey, setTenantKey] = React.useState(currentTenant);
|
|
3247
|
+
const [metadata, setMetadata] = React.useState({});
|
|
3234
3248
|
// Fetch custom domain to get platform_key
|
|
3235
3249
|
const currentDomain = typeof window !== "undefined" ? window.location.hostname : "";
|
|
3236
3250
|
const { data: customDomainData, isLoading: isLoadingCustomDomain, isError: isCustomDomainError, } = dataLayer.useGetCustomDomainsQuery({ params: { domain: currentDomain } }, { skip: !isWeb() || !currentDomain || skipCustomDomainCheck });
|
|
3237
3251
|
// Extract platform_key from custom domain response to use as requestedTenant
|
|
3238
|
-
const { customDomainPlatformKey, isAdvertisingTenant } =
|
|
3252
|
+
const { customDomainPlatformKey, isAdvertisingTenant } = React.useMemo(() => {
|
|
3239
3253
|
let platformKey;
|
|
3240
3254
|
let isAdvertising = false;
|
|
3241
3255
|
if (customDomainData &&
|
|
@@ -3606,7 +3620,7 @@ function TenantProvider({ children, fallback, onAuthSuccess, onAuthFailure, curr
|
|
|
3606
3620
|
}
|
|
3607
3621
|
}
|
|
3608
3622
|
// Effect to handle tenant determination when auth state changes
|
|
3609
|
-
|
|
3623
|
+
React.useEffect(() => {
|
|
3610
3624
|
// Wait for custom domain query to complete (unless skipped or error)
|
|
3611
3625
|
const customDomainQuerySkipped = !isWeb() || !currentDomain;
|
|
3612
3626
|
if (!customDomainQuerySkipped && isLoadingCustomDomain) {
|
|
@@ -3647,6 +3661,30 @@ function TenantProvider({ children, fallback, onAuthSuccess, onAuthFailure, curr
|
|
|
3647
3661
|
isLoadingCustomDomain,
|
|
3648
3662
|
isCustomDomainError,
|
|
3649
3663
|
]);
|
|
3664
|
+
// Poll every 2s: if requestedTenant exists, differs from currentTenant,
|
|
3665
|
+
// and user is not on a public route, invoke the onTenantMismatch callback.
|
|
3666
|
+
React.useEffect(() => {
|
|
3667
|
+
if (!onTenantMismatch)
|
|
3668
|
+
return;
|
|
3669
|
+
const interval = setInterval(() => {
|
|
3670
|
+
if (requestedTenant &&
|
|
3671
|
+
currentTenant &&
|
|
3672
|
+
requestedTenant !== currentTenant &&
|
|
3673
|
+
!userIsAccessingPublicRoute) {
|
|
3674
|
+
console.log("[TenantProvider] Tenant mismatch detected", {
|
|
3675
|
+
requestedTenant,
|
|
3676
|
+
currentTenant,
|
|
3677
|
+
});
|
|
3678
|
+
onTenantMismatch();
|
|
3679
|
+
}
|
|
3680
|
+
}, 2000);
|
|
3681
|
+
return () => clearInterval(interval);
|
|
3682
|
+
}, [
|
|
3683
|
+
requestedTenant,
|
|
3684
|
+
currentTenant,
|
|
3685
|
+
userIsAccessingPublicRoute,
|
|
3686
|
+
onTenantMismatch,
|
|
3687
|
+
]);
|
|
3650
3688
|
// Show fallback component during tenant determination
|
|
3651
3689
|
if (isLoading) {
|
|
3652
3690
|
return fallback;
|
|
@@ -3685,7 +3723,7 @@ function MentorProvider({ children, fallback, onAuthSuccess, onAuthFailure, redi
|
|
|
3685
3723
|
if (skip) {
|
|
3686
3724
|
return jsxRuntime.jsx(jsxRuntime.Fragment, { children: children });
|
|
3687
3725
|
}
|
|
3688
|
-
const [isLoading, setIsLoading] =
|
|
3726
|
+
const [isLoading, setIsLoading] = React.useState(true);
|
|
3689
3727
|
const { userIsAccessingPublicRoute, isLoggedIn } = useAuthContext();
|
|
3690
3728
|
const { determineUserPath, tenantKey, metadata } = useTenantContext();
|
|
3691
3729
|
const isMainTenant = tenantKey === mainTenantKey;
|
|
@@ -4022,7 +4060,7 @@ function MentorProvider({ children, fallback, onAuthSuccess, onAuthFailure, redi
|
|
|
4022
4060
|
}
|
|
4023
4061
|
}
|
|
4024
4062
|
// Effect to handle mentor determination when tenant path is determined
|
|
4025
|
-
|
|
4063
|
+
React.useEffect(() => {
|
|
4026
4064
|
async function checkMentor() {
|
|
4027
4065
|
console.log("starting mentor check process", determineUserPath, requestedMentorId, tenantKey, userIsAccessingPublicRoute, window.location.href);
|
|
4028
4066
|
if (userIsAccessingPublicRoute && !requestedMentorId) {
|
|
@@ -6462,43 +6500,43 @@ class TimeTracker {
|
|
|
6462
6500
|
|
|
6463
6501
|
function useTimeTracker(config) {
|
|
6464
6502
|
var _a;
|
|
6465
|
-
const trackerRef =
|
|
6466
|
-
const enabledRef =
|
|
6467
|
-
const defaultGetCurrentUrl =
|
|
6503
|
+
const trackerRef = React.useRef(null);
|
|
6504
|
+
const enabledRef = React.useRef((_a = config.enabled) !== null && _a !== void 0 ? _a : true);
|
|
6505
|
+
const defaultGetCurrentUrl = React.useCallback(() => {
|
|
6468
6506
|
if (typeof window !== "undefined") {
|
|
6469
6507
|
return window.location.pathname + window.location.search;
|
|
6470
6508
|
}
|
|
6471
6509
|
return "/";
|
|
6472
6510
|
}, []);
|
|
6473
6511
|
const getCurrentUrl = config.getCurrentUrl || defaultGetCurrentUrl;
|
|
6474
|
-
const defaultOnRouteChange =
|
|
6512
|
+
const defaultOnRouteChange = React.useCallback(() => {
|
|
6475
6513
|
// No-op for platforms that don't support route change events
|
|
6476
6514
|
return () => { };
|
|
6477
6515
|
}, []);
|
|
6478
6516
|
const onRouteChange = config.onRouteChange || defaultOnRouteChange;
|
|
6479
|
-
const pause =
|
|
6517
|
+
const pause = React.useCallback(() => {
|
|
6480
6518
|
if (trackerRef.current) {
|
|
6481
6519
|
trackerRef.current.pause();
|
|
6482
6520
|
}
|
|
6483
6521
|
}, []);
|
|
6484
|
-
const resume =
|
|
6522
|
+
const resume = React.useCallback(() => {
|
|
6485
6523
|
if (trackerRef.current) {
|
|
6486
6524
|
trackerRef.current.resume();
|
|
6487
6525
|
}
|
|
6488
6526
|
}, []);
|
|
6489
|
-
const getTimeSpentSinceLastReset =
|
|
6527
|
+
const getTimeSpentSinceLastReset = React.useCallback(() => {
|
|
6490
6528
|
if (trackerRef.current) {
|
|
6491
6529
|
return trackerRef.current.getTimeSpentSinceLastReset();
|
|
6492
6530
|
}
|
|
6493
6531
|
return 0;
|
|
6494
6532
|
}, []);
|
|
6495
|
-
const getTrackerCurrentUrl =
|
|
6533
|
+
const getTrackerCurrentUrl = React.useCallback(() => {
|
|
6496
6534
|
if (trackerRef.current) {
|
|
6497
6535
|
return trackerRef.current.getCurrentUrl();
|
|
6498
6536
|
}
|
|
6499
6537
|
return getCurrentUrl();
|
|
6500
6538
|
}, [getCurrentUrl]);
|
|
6501
|
-
|
|
6539
|
+
React.useEffect(() => {
|
|
6502
6540
|
var _a;
|
|
6503
6541
|
enabledRef.current = (_a = config.enabled) !== null && _a !== void 0 ? _a : true;
|
|
6504
6542
|
if (enabledRef.current) {
|
|
@@ -6522,7 +6560,7 @@ function useTimeTracker(config) {
|
|
|
6522
6560
|
getCurrentUrl,
|
|
6523
6561
|
onRouteChange,
|
|
6524
6562
|
]);
|
|
6525
|
-
|
|
6563
|
+
React.useEffect(() => {
|
|
6526
6564
|
var _a;
|
|
6527
6565
|
if (config.enabled !== enabledRef.current) {
|
|
6528
6566
|
if (config.enabled && !trackerRef.current) {
|
|
@@ -6557,34 +6595,34 @@ function useTimeTracker(config) {
|
|
|
6557
6595
|
|
|
6558
6596
|
function useTimeTrackerNative(config) {
|
|
6559
6597
|
var _a;
|
|
6560
|
-
const trackerRef =
|
|
6561
|
-
const enabledRef =
|
|
6562
|
-
const getCurrentUrl =
|
|
6598
|
+
const trackerRef = React.useRef(null);
|
|
6599
|
+
const enabledRef = React.useRef((_a = config.enabled) !== null && _a !== void 0 ? _a : true);
|
|
6600
|
+
const getCurrentUrl = React.useCallback(() => {
|
|
6563
6601
|
return config.getCurrentRoute();
|
|
6564
6602
|
}, [config]);
|
|
6565
|
-
const pause =
|
|
6603
|
+
const pause = React.useCallback(() => {
|
|
6566
6604
|
if (trackerRef.current) {
|
|
6567
6605
|
trackerRef.current.pause();
|
|
6568
6606
|
}
|
|
6569
6607
|
}, []);
|
|
6570
|
-
const resume =
|
|
6608
|
+
const resume = React.useCallback(() => {
|
|
6571
6609
|
if (trackerRef.current) {
|
|
6572
6610
|
trackerRef.current.resume();
|
|
6573
6611
|
}
|
|
6574
6612
|
}, []);
|
|
6575
|
-
const getTimeSpentSinceLastReset =
|
|
6613
|
+
const getTimeSpentSinceLastReset = React.useCallback(() => {
|
|
6576
6614
|
if (trackerRef.current) {
|
|
6577
6615
|
return trackerRef.current.getTimeSpentSinceLastReset();
|
|
6578
6616
|
}
|
|
6579
6617
|
return 0;
|
|
6580
6618
|
}, []);
|
|
6581
|
-
const getTrackerCurrentUrl =
|
|
6619
|
+
const getTrackerCurrentUrl = React.useCallback(() => {
|
|
6582
6620
|
if (trackerRef.current) {
|
|
6583
6621
|
return trackerRef.current.getCurrentUrl();
|
|
6584
6622
|
}
|
|
6585
6623
|
return getCurrentUrl();
|
|
6586
6624
|
}, [getCurrentUrl]);
|
|
6587
|
-
|
|
6625
|
+
React.useEffect(() => {
|
|
6588
6626
|
var _a;
|
|
6589
6627
|
enabledRef.current = (_a = config.enabled) !== null && _a !== void 0 ? _a : true;
|
|
6590
6628
|
if (enabledRef.current) {
|
|
@@ -6608,7 +6646,7 @@ function useTimeTrackerNative(config) {
|
|
|
6608
6646
|
config.onRouteChange,
|
|
6609
6647
|
getCurrentUrl,
|
|
6610
6648
|
]);
|
|
6611
|
-
|
|
6649
|
+
React.useEffect(() => {
|
|
6612
6650
|
var _a;
|
|
6613
6651
|
if (config.enabled !== enabledRef.current) {
|
|
6614
6652
|
if (config.enabled && !trackerRef.current) {
|
|
@@ -7092,45 +7130,45 @@ function isTauriApp() {
|
|
|
7092
7130
|
}
|
|
7093
7131
|
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, }) => {
|
|
7094
7132
|
const dispatch = useDispatch();
|
|
7095
|
-
const isWebSocketPaused =
|
|
7096
|
-
const ws =
|
|
7097
|
-
const isConnected =
|
|
7098
|
-
const messageQueue =
|
|
7133
|
+
const isWebSocketPaused = React.useRef(false);
|
|
7134
|
+
const ws = React.useRef(null);
|
|
7135
|
+
const isConnected = React.useRef(false);
|
|
7136
|
+
const messageQueue = React.useRef([]);
|
|
7099
7137
|
// Keep sessionId in a ref so sendMessage always reads the latest value,
|
|
7100
7138
|
// avoiding stale closures when Redux updates sessionIds between renders.
|
|
7101
|
-
const sessionIdRef =
|
|
7139
|
+
const sessionIdRef = React.useRef(sessionId);
|
|
7102
7140
|
sessionIdRef.current = sessionId;
|
|
7103
|
-
const currentStreamingMessage =
|
|
7141
|
+
const currentStreamingMessage = React.useRef({
|
|
7104
7142
|
id: null,
|
|
7105
7143
|
content: "",
|
|
7106
7144
|
});
|
|
7107
7145
|
// Track artifact state during streaming
|
|
7108
|
-
const currentArtifact =
|
|
7146
|
+
const currentArtifact = React.useRef(null);
|
|
7109
7147
|
// Store pending artifact version to add when message is finalized (eos)
|
|
7110
7148
|
// This is needed because artifact_end can fire before eos
|
|
7111
|
-
const pendingArtifactVersion =
|
|
7149
|
+
const pendingArtifactVersion = React.useRef(null);
|
|
7112
7150
|
// Content buffer for batching artifact streaming updates
|
|
7113
7151
|
// This prevents excessive state updates and the "Maximum update depth exceeded" error
|
|
7114
|
-
const artifactContentBuffer =
|
|
7152
|
+
const artifactContentBuffer = React.useRef({
|
|
7115
7153
|
content: "",
|
|
7116
7154
|
lastFlushTime: 0,
|
|
7117
7155
|
flushTimer: null,
|
|
7118
7156
|
});
|
|
7119
|
-
const stopGenerationSocket =
|
|
7120
|
-
const isInitialConnection =
|
|
7121
|
-
const connectionAttempts =
|
|
7157
|
+
const stopGenerationSocket = React.useRef(null);
|
|
7158
|
+
const isInitialConnection = React.useRef(true);
|
|
7159
|
+
const connectionAttempts = React.useRef(0);
|
|
7122
7160
|
const { userIsAccessingPublicRoute } = useAuthContext();
|
|
7123
7161
|
const iframeContext = useSelector(selectIframeContext);
|
|
7124
7162
|
const chatMetadata = useSelector(selectMetadata);
|
|
7125
7163
|
const documentFilter = useSelector(selectDocumentFilter);
|
|
7126
7164
|
const linkToken = useSelector(selectToken);
|
|
7127
7165
|
// Ollama/offline mode state
|
|
7128
|
-
const ollamaAbortController =
|
|
7129
|
-
const ollamaConversationHistory =
|
|
7166
|
+
const ollamaAbortController = React.useRef(null);
|
|
7167
|
+
const ollamaConversationHistory = React.useRef([]);
|
|
7130
7168
|
// Track offline state in a ref so event handlers can access current value
|
|
7131
7169
|
// Note: This ref is updated in the main useEffect that handles offline changes
|
|
7132
|
-
const isOfflineRef =
|
|
7133
|
-
const triggerHapticFeedback =
|
|
7170
|
+
const isOfflineRef = React.useRef(isOffline);
|
|
7171
|
+
const triggerHapticFeedback = React.useCallback(async () => {
|
|
7134
7172
|
if (enableHaptics && hapticFeedback) {
|
|
7135
7173
|
try {
|
|
7136
7174
|
await hapticFeedback.impactAsync("medium");
|
|
@@ -7983,7 +8021,7 @@ const useChat = ({ wsUrl, wsToken, flowConfig, sessionId, stopGenerationWsUrl, e
|
|
|
7983
8021
|
});
|
|
7984
8022
|
});
|
|
7985
8023
|
};
|
|
7986
|
-
const sendMessage =
|
|
8024
|
+
const sendMessage = React.useCallback(async (tab, text, options) => {
|
|
7987
8025
|
var _a, _b;
|
|
7988
8026
|
dispatch(chatActions.setShowingSharedChat(false));
|
|
7989
8027
|
// Allow sending if there's text OR file references
|
|
@@ -8264,7 +8302,7 @@ const useChat = ({ wsUrl, wsToken, flowConfig, sessionId, stopGenerationWsUrl, e
|
|
|
8264
8302
|
onStreamingMessageUpdate === null || onStreamingMessageUpdate === void 0 ? void 0 : onStreamingMessageUpdate(currentStreamingMessage.current);
|
|
8265
8303
|
};
|
|
8266
8304
|
// Initialize WebSocket on mount and handle offline changes
|
|
8267
|
-
|
|
8305
|
+
React.useEffect(() => {
|
|
8268
8306
|
var _a;
|
|
8269
8307
|
// IMPORTANT: Update the ref FIRST before any socket operations
|
|
8270
8308
|
// This ensures error handlers see the correct offline state immediately
|
|
@@ -8294,7 +8332,7 @@ const useChat = ({ wsUrl, wsToken, flowConfig, sessionId, stopGenerationWsUrl, e
|
|
|
8294
8332
|
resetConnection();
|
|
8295
8333
|
};
|
|
8296
8334
|
}, [isOffline]);
|
|
8297
|
-
|
|
8335
|
+
React.useEffect(() => {
|
|
8298
8336
|
sendMessageToParentWebsite === null || sendMessageToParentWebsite === void 0 ? void 0 : sendMessageToParentWebsite({ loaded: true, auth: { ...localStorage } });
|
|
8299
8337
|
}, []);
|
|
8300
8338
|
return {
|
|
@@ -12880,7 +12918,7 @@ function safeAssign(target, ...args) {
|
|
|
12880
12918
|
// src/query/react/constants.ts
|
|
12881
12919
|
var UNINITIALIZED_VALUE = Symbol();
|
|
12882
12920
|
function useStableQueryArgs(queryArgs, serialize, endpointDefinition, endpointName) {
|
|
12883
|
-
const incoming =
|
|
12921
|
+
const incoming = React.useMemo(() => ({
|
|
12884
12922
|
queryArgs,
|
|
12885
12923
|
serialized: typeof queryArgs == "object" ? serialize({
|
|
12886
12924
|
queryArgs,
|
|
@@ -12888,8 +12926,8 @@ function useStableQueryArgs(queryArgs, serialize, endpointDefinition, endpointNa
|
|
|
12888
12926
|
endpointName
|
|
12889
12927
|
}) : queryArgs
|
|
12890
12928
|
}), [queryArgs, serialize, endpointDefinition, endpointName]);
|
|
12891
|
-
const cache =
|
|
12892
|
-
|
|
12929
|
+
const cache = React.useRef(incoming);
|
|
12930
|
+
React.useEffect(() => {
|
|
12893
12931
|
if (cache.current.serialized !== incoming.serialized) {
|
|
12894
12932
|
cache.current = incoming;
|
|
12895
12933
|
}
|
|
@@ -12897,8 +12935,8 @@ function useStableQueryArgs(queryArgs, serialize, endpointDefinition, endpointNa
|
|
|
12897
12935
|
return cache.current.serialized === incoming.serialized ? cache.current.queryArgs : queryArgs;
|
|
12898
12936
|
}
|
|
12899
12937
|
function useShallowStableValue(value) {
|
|
12900
|
-
const cache =
|
|
12901
|
-
|
|
12938
|
+
const cache = React.useRef(value);
|
|
12939
|
+
React.useEffect(() => {
|
|
12902
12940
|
if (!shallowEqual(cache.current, value)) {
|
|
12903
12941
|
cache.current = value;
|
|
12904
12942
|
}
|
|
@@ -12911,7 +12949,7 @@ var canUseDOM = () => !!(typeof window !== "undefined" && typeof window.document
|
|
|
12911
12949
|
var isDOM = /* @__PURE__ */ canUseDOM();
|
|
12912
12950
|
var isRunningInReactNative = () => typeof navigator !== "undefined" && navigator.product === "ReactNative";
|
|
12913
12951
|
var isReactNative = /* @__PURE__ */ isRunningInReactNative();
|
|
12914
|
-
var getUseIsomorphicLayoutEffect = () => isDOM || isReactNative ?
|
|
12952
|
+
var getUseIsomorphicLayoutEffect = () => isDOM || isReactNative ? React.useLayoutEffect : React.useEffect;
|
|
12915
12953
|
var useIsomorphicLayoutEffect = /* @__PURE__ */ getUseIsomorphicLayoutEffect();
|
|
12916
12954
|
var noPendingQueryStateSelector = (selected) => {
|
|
12917
12955
|
if (selected.isUninitialized) {
|
|
@@ -12948,7 +12986,7 @@ function buildHooks({
|
|
|
12948
12986
|
serializeQueryArgs,
|
|
12949
12987
|
context
|
|
12950
12988
|
}) {
|
|
12951
|
-
const usePossiblyImmediateEffect = unstable__sideEffectsInRender ? (cb) => cb() :
|
|
12989
|
+
const usePossiblyImmediateEffect = unstable__sideEffectsInRender ? (cb) => cb() : React.useEffect;
|
|
12952
12990
|
return {
|
|
12953
12991
|
buildQueryHooks,
|
|
12954
12992
|
buildInfiniteQueryHooks,
|
|
@@ -13020,7 +13058,7 @@ function buildHooks({
|
|
|
13020
13058
|
function usePrefetch(endpointName, defaultOptions) {
|
|
13021
13059
|
const dispatch = useDispatch();
|
|
13022
13060
|
const stableDefaultOptions = useShallowStableValue(defaultOptions);
|
|
13023
|
-
return
|
|
13061
|
+
return React.useCallback((arg, options) => dispatch(api.util.prefetch(endpointName, arg, {
|
|
13024
13062
|
...stableDefaultOptions,
|
|
13025
13063
|
...options
|
|
13026
13064
|
})), [endpointName, dispatch, stableDefaultOptions]);
|
|
@@ -13038,7 +13076,7 @@ function buildHooks({
|
|
|
13038
13076
|
initiate
|
|
13039
13077
|
} = api.endpoints[endpointName];
|
|
13040
13078
|
const dispatch = useDispatch();
|
|
13041
|
-
const subscriptionSelectorsRef =
|
|
13079
|
+
const subscriptionSelectorsRef = React.useRef(void 0);
|
|
13042
13080
|
if (!subscriptionSelectorsRef.current) {
|
|
13043
13081
|
const returnedValue = dispatch(api.internalActions.internal_getRTKQSubscriptions());
|
|
13044
13082
|
if (process.env.NODE_ENV !== "production") {
|
|
@@ -13068,7 +13106,7 @@ function buildHooks({
|
|
|
13068
13106
|
});
|
|
13069
13107
|
const initialPageParam = rest.initialPageParam;
|
|
13070
13108
|
const stableInitialPageParam = useShallowStableValue(initialPageParam);
|
|
13071
|
-
const promiseRef =
|
|
13109
|
+
const promiseRef = React.useRef(void 0);
|
|
13072
13110
|
let {
|
|
13073
13111
|
queryCacheKey,
|
|
13074
13112
|
requestId
|
|
@@ -13119,8 +13157,8 @@ function buildHooks({
|
|
|
13119
13157
|
select
|
|
13120
13158
|
} = api.endpoints[endpointName];
|
|
13121
13159
|
const stableArg = useStableQueryArgs(skip ? skipToken : arg, serializeQueryArgs, context.endpointDefinitions[endpointName], endpointName);
|
|
13122
|
-
const lastValue =
|
|
13123
|
-
const selectDefaultResult =
|
|
13160
|
+
const lastValue = React.useRef(void 0);
|
|
13161
|
+
const selectDefaultResult = React.useMemo(() => (
|
|
13124
13162
|
// Normally ts-ignores are bad and should be avoided, but we're
|
|
13125
13163
|
// already casting this selector to be `Selector<any>` anyway,
|
|
13126
13164
|
// so the inconsistencies don't matter here
|
|
@@ -13136,7 +13174,7 @@ function buildHooks({
|
|
|
13136
13174
|
}
|
|
13137
13175
|
})
|
|
13138
13176
|
), [select, stableArg]);
|
|
13139
|
-
const querySelector =
|
|
13177
|
+
const querySelector = React.useMemo(() => selectFromResult ? createSelector([selectDefaultResult], selectFromResult, {
|
|
13140
13178
|
devModeChecks: {
|
|
13141
13179
|
identityFunctionCheck: "never"
|
|
13142
13180
|
}
|
|
@@ -13152,7 +13190,7 @@ function buildHooks({
|
|
|
13152
13190
|
return useQueryState;
|
|
13153
13191
|
}
|
|
13154
13192
|
function usePromiseRefUnsubscribeOnUnmount(promiseRef) {
|
|
13155
|
-
|
|
13193
|
+
React.useEffect(() => {
|
|
13156
13194
|
return () => {
|
|
13157
13195
|
promiseRef.current?.unsubscribe?.();
|
|
13158
13196
|
promiseRef.current = void 0;
|
|
@@ -13167,7 +13205,7 @@ function buildHooks({
|
|
|
13167
13205
|
const useQuerySubscription = (arg, options = {}) => {
|
|
13168
13206
|
const [promiseRef] = useQuerySubscriptionCommonImpl(endpointName, arg, options);
|
|
13169
13207
|
usePromiseRefUnsubscribeOnUnmount(promiseRef);
|
|
13170
|
-
return
|
|
13208
|
+
return React.useMemo(() => ({
|
|
13171
13209
|
/**
|
|
13172
13210
|
* A method to manually refetch data for the query
|
|
13173
13211
|
*/
|
|
@@ -13184,8 +13222,8 @@ function buildHooks({
|
|
|
13184
13222
|
initiate
|
|
13185
13223
|
} = api.endpoints[endpointName];
|
|
13186
13224
|
const dispatch = useDispatch();
|
|
13187
|
-
const [arg, setArg] =
|
|
13188
|
-
const promiseRef =
|
|
13225
|
+
const [arg, setArg] = React.useState(UNINITIALIZED_VALUE);
|
|
13226
|
+
const promiseRef = React.useRef(void 0);
|
|
13189
13227
|
const stableSubscriptionOptions = useShallowStableValue({
|
|
13190
13228
|
refetchOnReconnect,
|
|
13191
13229
|
refetchOnFocus,
|
|
@@ -13198,11 +13236,11 @@ function buildHooks({
|
|
|
13198
13236
|
promiseRef.current?.updateSubscriptionOptions(stableSubscriptionOptions);
|
|
13199
13237
|
}
|
|
13200
13238
|
}, [stableSubscriptionOptions]);
|
|
13201
|
-
const subscriptionOptionsRef =
|
|
13239
|
+
const subscriptionOptionsRef = React.useRef(stableSubscriptionOptions);
|
|
13202
13240
|
usePossiblyImmediateEffect(() => {
|
|
13203
13241
|
subscriptionOptionsRef.current = stableSubscriptionOptions;
|
|
13204
13242
|
}, [stableSubscriptionOptions]);
|
|
13205
|
-
const trigger =
|
|
13243
|
+
const trigger = React.useCallback(function(arg2, preferCacheValue = false) {
|
|
13206
13244
|
let promise;
|
|
13207
13245
|
batch(() => {
|
|
13208
13246
|
promiseRef.current?.unsubscribe();
|
|
@@ -13214,24 +13252,24 @@ function buildHooks({
|
|
|
13214
13252
|
});
|
|
13215
13253
|
return promise;
|
|
13216
13254
|
}, [dispatch, initiate]);
|
|
13217
|
-
const reset =
|
|
13255
|
+
const reset = React.useCallback(() => {
|
|
13218
13256
|
if (promiseRef.current?.queryCacheKey) {
|
|
13219
13257
|
dispatch(api.internalActions.removeQueryResult({
|
|
13220
13258
|
queryCacheKey: promiseRef.current?.queryCacheKey
|
|
13221
13259
|
}));
|
|
13222
13260
|
}
|
|
13223
13261
|
}, [dispatch]);
|
|
13224
|
-
|
|
13262
|
+
React.useEffect(() => {
|
|
13225
13263
|
return () => {
|
|
13226
13264
|
promiseRef?.current?.unsubscribe();
|
|
13227
13265
|
};
|
|
13228
13266
|
}, []);
|
|
13229
|
-
|
|
13267
|
+
React.useEffect(() => {
|
|
13230
13268
|
if (arg !== UNINITIALIZED_VALUE && !promiseRef.current) {
|
|
13231
13269
|
trigger(arg, true);
|
|
13232
13270
|
}
|
|
13233
13271
|
}, [arg, trigger]);
|
|
13234
|
-
return
|
|
13272
|
+
return React.useMemo(() => [trigger, arg, {
|
|
13235
13273
|
reset
|
|
13236
13274
|
}], [trigger, arg, reset]);
|
|
13237
13275
|
};
|
|
@@ -13248,10 +13286,10 @@ function buildHooks({
|
|
|
13248
13286
|
...options,
|
|
13249
13287
|
skip: arg === UNINITIALIZED_VALUE
|
|
13250
13288
|
});
|
|
13251
|
-
const info =
|
|
13289
|
+
const info = React.useMemo(() => ({
|
|
13252
13290
|
lastArg: arg
|
|
13253
13291
|
}), [arg]);
|
|
13254
|
-
return
|
|
13292
|
+
return React.useMemo(() => [trigger, {
|
|
13255
13293
|
...queryStateResults,
|
|
13256
13294
|
reset
|
|
13257
13295
|
}, info], [trigger, queryStateResults, reset, info]);
|
|
@@ -13263,8 +13301,8 @@ function buildHooks({
|
|
|
13263
13301
|
...options
|
|
13264
13302
|
});
|
|
13265
13303
|
const debugValue = pick(queryStateResults, ...COMMON_HOOK_DEBUG_FIELDS);
|
|
13266
|
-
|
|
13267
|
-
return
|
|
13304
|
+
React.useDebugValue(debugValue);
|
|
13305
|
+
return React.useMemo(() => ({
|
|
13268
13306
|
...queryStateResults,
|
|
13269
13307
|
...querySubscriptionResults
|
|
13270
13308
|
}), [queryStateResults, querySubscriptionResults]);
|
|
@@ -13274,11 +13312,11 @@ function buildHooks({
|
|
|
13274
13312
|
function buildInfiniteQueryHooks(endpointName) {
|
|
13275
13313
|
const useInfiniteQuerySubscription = (arg, options = {}) => {
|
|
13276
13314
|
const [promiseRef, dispatch, initiate, stableSubscriptionOptions] = useQuerySubscriptionCommonImpl(endpointName, arg, options);
|
|
13277
|
-
const subscriptionOptionsRef =
|
|
13315
|
+
const subscriptionOptionsRef = React.useRef(stableSubscriptionOptions);
|
|
13278
13316
|
usePossiblyImmediateEffect(() => {
|
|
13279
13317
|
subscriptionOptionsRef.current = stableSubscriptionOptions;
|
|
13280
13318
|
}, [stableSubscriptionOptions]);
|
|
13281
|
-
const trigger =
|
|
13319
|
+
const trigger = React.useCallback(function(arg2, direction) {
|
|
13282
13320
|
let promise;
|
|
13283
13321
|
batch(() => {
|
|
13284
13322
|
promiseRef.current?.unsubscribe();
|
|
@@ -13301,8 +13339,8 @@ function buildHooks({
|
|
|
13301
13339
|
context.endpointDefinitions[endpointName],
|
|
13302
13340
|
endpointName
|
|
13303
13341
|
);
|
|
13304
|
-
const refetch =
|
|
13305
|
-
return
|
|
13342
|
+
const refetch = React.useCallback(() => refetchOrErrorIfUnmounted(promiseRef), [promiseRef]);
|
|
13343
|
+
return React.useMemo(() => {
|
|
13306
13344
|
const fetchNextPage = () => {
|
|
13307
13345
|
return trigger(stableArg, "forward");
|
|
13308
13346
|
};
|
|
@@ -13335,8 +13373,8 @@ function buildHooks({
|
|
|
13335
13373
|
...options
|
|
13336
13374
|
});
|
|
13337
13375
|
const debugValue = pick(queryStateResults, ...COMMON_HOOK_DEBUG_FIELDS, "hasNextPage", "hasPreviousPage");
|
|
13338
|
-
|
|
13339
|
-
return
|
|
13376
|
+
React.useDebugValue(debugValue);
|
|
13377
|
+
return React.useMemo(() => ({
|
|
13340
13378
|
...queryStateResults,
|
|
13341
13379
|
fetchNextPage,
|
|
13342
13380
|
fetchPreviousPage,
|
|
@@ -13355,13 +13393,13 @@ function buildHooks({
|
|
|
13355
13393
|
initiate
|
|
13356
13394
|
} = api.endpoints[name];
|
|
13357
13395
|
const dispatch = useDispatch();
|
|
13358
|
-
const [promise, setPromise] =
|
|
13359
|
-
|
|
13396
|
+
const [promise, setPromise] = React.useState();
|
|
13397
|
+
React.useEffect(() => () => {
|
|
13360
13398
|
if (!promise?.arg.fixedCacheKey) {
|
|
13361
13399
|
promise?.reset();
|
|
13362
13400
|
}
|
|
13363
13401
|
}, [promise]);
|
|
13364
|
-
const triggerMutation =
|
|
13402
|
+
const triggerMutation = React.useCallback(function(arg) {
|
|
13365
13403
|
const promise2 = dispatch(initiate(arg, {
|
|
13366
13404
|
fixedCacheKey
|
|
13367
13405
|
}));
|
|
@@ -13371,14 +13409,14 @@ function buildHooks({
|
|
|
13371
13409
|
const {
|
|
13372
13410
|
requestId
|
|
13373
13411
|
} = promise || {};
|
|
13374
|
-
const selectDefaultResult =
|
|
13412
|
+
const selectDefaultResult = React.useMemo(() => select({
|
|
13375
13413
|
fixedCacheKey,
|
|
13376
13414
|
requestId: promise?.requestId
|
|
13377
13415
|
}), [fixedCacheKey, promise, select]);
|
|
13378
|
-
const mutationSelector =
|
|
13416
|
+
const mutationSelector = React.useMemo(() => selectFromResult ? createSelector([selectDefaultResult], selectFromResult) : selectDefaultResult, [selectFromResult, selectDefaultResult]);
|
|
13379
13417
|
const currentState = useSelector(mutationSelector, shallowEqual);
|
|
13380
13418
|
const originalArgs = fixedCacheKey == null ? promise?.arg.originalArgs : void 0;
|
|
13381
|
-
const reset =
|
|
13419
|
+
const reset = React.useCallback(() => {
|
|
13382
13420
|
batch(() => {
|
|
13383
13421
|
if (promise) {
|
|
13384
13422
|
setPromise(void 0);
|
|
@@ -13392,13 +13430,13 @@ function buildHooks({
|
|
|
13392
13430
|
});
|
|
13393
13431
|
}, [dispatch, fixedCacheKey, promise, requestId]);
|
|
13394
13432
|
const debugValue = pick(currentState, ...COMMON_HOOK_DEBUG_FIELDS, "endpointName");
|
|
13395
|
-
|
|
13396
|
-
const finalState =
|
|
13433
|
+
React.useDebugValue(debugValue);
|
|
13434
|
+
const finalState = React.useMemo(() => ({
|
|
13397
13435
|
...currentState,
|
|
13398
13436
|
originalArgs,
|
|
13399
13437
|
reset
|
|
13400
13438
|
}), [currentState, originalArgs, reset]);
|
|
13401
|
-
return
|
|
13439
|
+
return React.useMemo(() => [triggerMutation, finalState], [triggerMutation, finalState]);
|
|
13402
13440
|
};
|
|
13403
13441
|
}
|
|
13404
13442
|
}
|
|
@@ -18479,10 +18517,10 @@ function useAdvancedChat({ tenantKey, mentorId, username = ANONYMOUS_USERNAME, t
|
|
|
18479
18517
|
isOffline,
|
|
18480
18518
|
onOfflineWithoutLocalLLM,
|
|
18481
18519
|
});
|
|
18482
|
-
const [isLoadingChats, setIsLoadingChats] =
|
|
18520
|
+
const [isLoadingChats, setIsLoadingChats] = React.useState(true);
|
|
18483
18521
|
const [getSessionChats] = dataLayer.useLazyGetSessionIdQuery();
|
|
18484
18522
|
const [getSharedSessionChats] = dataLayer.useLazyGetSharedSessionIdQuery();
|
|
18485
|
-
const getChats =
|
|
18523
|
+
const getChats = React.useCallback(async () => {
|
|
18486
18524
|
var _a, _b, _c, _d;
|
|
18487
18525
|
let data;
|
|
18488
18526
|
try {
|
|
@@ -18579,7 +18617,7 @@ function useAdvancedChat({ tenantKey, mentorId, username = ANONYMOUS_USERNAME, t
|
|
|
18579
18617
|
getSessionChats,
|
|
18580
18618
|
dispatch,
|
|
18581
18619
|
]);
|
|
18582
|
-
|
|
18620
|
+
React.useEffect(() => {
|
|
18583
18621
|
if (cachedSessionId === null || cachedSessionId === void 0 ? void 0 : cachedSessionId[mentorId]) {
|
|
18584
18622
|
dispatch(chatActions.updateSessionIds(cachedSessionId === null || cachedSessionId === void 0 ? void 0 : cachedSessionId[mentorId]));
|
|
18585
18623
|
// Skip fetching previous chats when offline
|
|
@@ -18594,7 +18632,7 @@ function useAdvancedChat({ tenantKey, mentorId, username = ANONYMOUS_USERNAME, t
|
|
|
18594
18632
|
setIsLoadingChats(false);
|
|
18595
18633
|
}
|
|
18596
18634
|
}, [cachedSessionId, isOffline]);
|
|
18597
|
-
const startNewChat =
|
|
18635
|
+
const startNewChat = React.useCallback(async () => {
|
|
18598
18636
|
// Reset all chat state
|
|
18599
18637
|
if (!showingSharedChat) {
|
|
18600
18638
|
dispatch(chatActions.resetChats(undefined));
|
|
@@ -18655,7 +18693,7 @@ function useAdvancedChat({ tenantKey, mentorId, username = ANONYMOUS_USERNAME, t
|
|
|
18655
18693
|
dispatch,
|
|
18656
18694
|
errorHandler,
|
|
18657
18695
|
]);
|
|
18658
|
-
|
|
18696
|
+
React.useEffect(() => {
|
|
18659
18697
|
if (!showingSharedChat || mentorSettings.allowAnonymous) {
|
|
18660
18698
|
if (mentorSettings.allowAnonymous !== undefined &&
|
|
18661
18699
|
!(cachedSessionId === null || cachedSessionId === void 0 ? void 0 : cachedSessionId[mentorId])) {
|
|
@@ -18663,7 +18701,7 @@ function useAdvancedChat({ tenantKey, mentorId, username = ANONYMOUS_USERNAME, t
|
|
|
18663
18701
|
}
|
|
18664
18702
|
}
|
|
18665
18703
|
}, [shouldStartNewChat, showingSharedChat, mentorSettings.allowAnonymous]);
|
|
18666
|
-
|
|
18704
|
+
React.useEffect(() => {
|
|
18667
18705
|
if (sessionIds[activeTab] && sessionIds[activeTab] !== sessionId) {
|
|
18668
18706
|
dispatch(chatActions.setSessionId(sessionIds[activeTab]));
|
|
18669
18707
|
// Reset WebSocket connection when session ID changes
|
|
@@ -18843,15 +18881,15 @@ function useMentorTools({ tenantKey, mentorId, username = ANONYMOUS_USERNAME, er
|
|
|
18843
18881
|
errorHandler === null || errorHandler === void 0 ? void 0 : errorHandler("Failed to update session", error);
|
|
18844
18882
|
}
|
|
18845
18883
|
};
|
|
18846
|
-
const webBrowsingIsEnabled =
|
|
18847
|
-
const screenSharingIsEnabled =
|
|
18848
|
-
const deepSearchIsEnabled =
|
|
18849
|
-
const studyModeIsEnabled =
|
|
18850
|
-
const imageGenerationIsEnabled =
|
|
18851
|
-
const codeInterpreterIsEnabled =
|
|
18852
|
-
const promptsIsEnabled =
|
|
18853
|
-
const googleSlidesIsEnabled =
|
|
18854
|
-
const googleDocumentIsEnabled =
|
|
18884
|
+
const webBrowsingIsEnabled = React.useMemo(() => hasTool(tools, mentorSettings, TOOLS.WEB_SEARCH), [tools, mentorSettings]);
|
|
18885
|
+
const screenSharingIsEnabled = React.useMemo(() => hasTool(tools, mentorSettings, TOOLS.SCREEN_SHARE), [tools, mentorSettings]);
|
|
18886
|
+
const deepSearchIsEnabled = React.useMemo(() => hasTool(tools, mentorSettings, TOOLS.DEEP_RESEARCH), [tools, mentorSettings]);
|
|
18887
|
+
const studyModeIsEnabled = React.useMemo(() => hasTool(tools, mentorSettings, TOOLS.STUDY_MODE), [tools, mentorSettings]);
|
|
18888
|
+
const imageGenerationIsEnabled = React.useMemo(() => hasTool(tools, mentorSettings, TOOLS.IMAGE_GENERATION), [tools, mentorSettings]);
|
|
18889
|
+
const codeInterpreterIsEnabled = React.useMemo(() => hasTool(tools, mentorSettings, TOOLS.CODE_INTERPRETER), [tools, mentorSettings]);
|
|
18890
|
+
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]);
|
|
18891
|
+
const googleSlidesIsEnabled = React.useMemo(() => hasTool(tools, mentorSettings, TOOLS.GOOGLE_SLIDES), [tools, mentorSettings]);
|
|
18892
|
+
const googleDocumentIsEnabled = React.useMemo(() => hasTool(tools, mentorSettings, TOOLS.GOOGLE_DOCUMENT), [tools, mentorSettings]);
|
|
18855
18893
|
return {
|
|
18856
18894
|
tools,
|
|
18857
18895
|
activeTools,
|
|
@@ -18984,8 +19022,300 @@ function useProfileImageUpload(options = {}) {
|
|
|
18984
19022
|
// This will be deprecated in favor of the new configuration system
|
|
18985
19023
|
const METADATAS = loadMetadataConfig();
|
|
18986
19024
|
|
|
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}))});
|
|
19025
|
+
function __insertCSS(code) {
|
|
19026
|
+
if (typeof document == 'undefined') return
|
|
19027
|
+
let head = document.head || document.getElementsByTagName('head')[0];
|
|
19028
|
+
let style = document.createElement('style');
|
|
19029
|
+
style.type = 'text/css';
|
|
19030
|
+
head.appendChild(style)
|
|
19031
|
+
;style.styleSheet ? (style.styleSheet.cssText = code) : style.appendChild(document.createTextNode(code));
|
|
19032
|
+
}
|
|
19033
|
+
Array(12).fill(0);
|
|
19034
|
+
|
|
19035
|
+
let toastsCounter = 1;
|
|
19036
|
+
class Observer {
|
|
19037
|
+
constructor(){
|
|
19038
|
+
// We use arrow functions to maintain the correct `this` reference
|
|
19039
|
+
this.subscribe = (subscriber)=>{
|
|
19040
|
+
this.subscribers.push(subscriber);
|
|
19041
|
+
return ()=>{
|
|
19042
|
+
const index = this.subscribers.indexOf(subscriber);
|
|
19043
|
+
this.subscribers.splice(index, 1);
|
|
19044
|
+
};
|
|
19045
|
+
};
|
|
19046
|
+
this.publish = (data)=>{
|
|
19047
|
+
this.subscribers.forEach((subscriber)=>subscriber(data));
|
|
19048
|
+
};
|
|
19049
|
+
this.addToast = (data)=>{
|
|
19050
|
+
this.publish(data);
|
|
19051
|
+
this.toasts = [
|
|
19052
|
+
...this.toasts,
|
|
19053
|
+
data
|
|
19054
|
+
];
|
|
19055
|
+
};
|
|
19056
|
+
this.create = (data)=>{
|
|
19057
|
+
var _data_id;
|
|
19058
|
+
const { message, ...rest } = data;
|
|
19059
|
+
const id = typeof (data == null ? void 0 : data.id) === 'number' || ((_data_id = data.id) == null ? void 0 : _data_id.length) > 0 ? data.id : toastsCounter++;
|
|
19060
|
+
const alreadyExists = this.toasts.find((toast)=>{
|
|
19061
|
+
return toast.id === id;
|
|
19062
|
+
});
|
|
19063
|
+
const dismissible = data.dismissible === undefined ? true : data.dismissible;
|
|
19064
|
+
if (this.dismissedToasts.has(id)) {
|
|
19065
|
+
this.dismissedToasts.delete(id);
|
|
19066
|
+
}
|
|
19067
|
+
if (alreadyExists) {
|
|
19068
|
+
this.toasts = this.toasts.map((toast)=>{
|
|
19069
|
+
if (toast.id === id) {
|
|
19070
|
+
this.publish({
|
|
19071
|
+
...toast,
|
|
19072
|
+
...data,
|
|
19073
|
+
id,
|
|
19074
|
+
title: message
|
|
19075
|
+
});
|
|
19076
|
+
return {
|
|
19077
|
+
...toast,
|
|
19078
|
+
...data,
|
|
19079
|
+
id,
|
|
19080
|
+
dismissible,
|
|
19081
|
+
title: message
|
|
19082
|
+
};
|
|
19083
|
+
}
|
|
19084
|
+
return toast;
|
|
19085
|
+
});
|
|
19086
|
+
} else {
|
|
19087
|
+
this.addToast({
|
|
19088
|
+
title: message,
|
|
19089
|
+
...rest,
|
|
19090
|
+
dismissible,
|
|
19091
|
+
id
|
|
19092
|
+
});
|
|
19093
|
+
}
|
|
19094
|
+
return id;
|
|
19095
|
+
};
|
|
19096
|
+
this.dismiss = (id)=>{
|
|
19097
|
+
if (id) {
|
|
19098
|
+
this.dismissedToasts.add(id);
|
|
19099
|
+
requestAnimationFrame(()=>this.subscribers.forEach((subscriber)=>subscriber({
|
|
19100
|
+
id,
|
|
19101
|
+
dismiss: true
|
|
19102
|
+
})));
|
|
19103
|
+
} else {
|
|
19104
|
+
this.toasts.forEach((toast)=>{
|
|
19105
|
+
this.subscribers.forEach((subscriber)=>subscriber({
|
|
19106
|
+
id: toast.id,
|
|
19107
|
+
dismiss: true
|
|
19108
|
+
}));
|
|
19109
|
+
});
|
|
19110
|
+
}
|
|
19111
|
+
return id;
|
|
19112
|
+
};
|
|
19113
|
+
this.message = (message, data)=>{
|
|
19114
|
+
return this.create({
|
|
19115
|
+
...data,
|
|
19116
|
+
message
|
|
19117
|
+
});
|
|
19118
|
+
};
|
|
19119
|
+
this.error = (message, data)=>{
|
|
19120
|
+
return this.create({
|
|
19121
|
+
...data,
|
|
19122
|
+
message,
|
|
19123
|
+
type: 'error'
|
|
19124
|
+
});
|
|
19125
|
+
};
|
|
19126
|
+
this.success = (message, data)=>{
|
|
19127
|
+
return this.create({
|
|
19128
|
+
...data,
|
|
19129
|
+
type: 'success',
|
|
19130
|
+
message
|
|
19131
|
+
});
|
|
19132
|
+
};
|
|
19133
|
+
this.info = (message, data)=>{
|
|
19134
|
+
return this.create({
|
|
19135
|
+
...data,
|
|
19136
|
+
type: 'info',
|
|
19137
|
+
message
|
|
19138
|
+
});
|
|
19139
|
+
};
|
|
19140
|
+
this.warning = (message, data)=>{
|
|
19141
|
+
return this.create({
|
|
19142
|
+
...data,
|
|
19143
|
+
type: 'warning',
|
|
19144
|
+
message
|
|
19145
|
+
});
|
|
19146
|
+
};
|
|
19147
|
+
this.loading = (message, data)=>{
|
|
19148
|
+
return this.create({
|
|
19149
|
+
...data,
|
|
19150
|
+
type: 'loading',
|
|
19151
|
+
message
|
|
19152
|
+
});
|
|
19153
|
+
};
|
|
19154
|
+
this.promise = (promise, data)=>{
|
|
19155
|
+
if (!data) {
|
|
19156
|
+
// Nothing to show
|
|
19157
|
+
return;
|
|
19158
|
+
}
|
|
19159
|
+
let id = undefined;
|
|
19160
|
+
if (data.loading !== undefined) {
|
|
19161
|
+
id = this.create({
|
|
19162
|
+
...data,
|
|
19163
|
+
promise,
|
|
19164
|
+
type: 'loading',
|
|
19165
|
+
message: data.loading,
|
|
19166
|
+
description: typeof data.description !== 'function' ? data.description : undefined
|
|
19167
|
+
});
|
|
19168
|
+
}
|
|
19169
|
+
const p = Promise.resolve(promise instanceof Function ? promise() : promise);
|
|
19170
|
+
let shouldDismiss = id !== undefined;
|
|
19171
|
+
let result;
|
|
19172
|
+
const originalPromise = p.then(async (response)=>{
|
|
19173
|
+
result = [
|
|
19174
|
+
'resolve',
|
|
19175
|
+
response
|
|
19176
|
+
];
|
|
19177
|
+
const isReactElementResponse = React.isValidElement(response);
|
|
19178
|
+
if (isReactElementResponse) {
|
|
19179
|
+
shouldDismiss = false;
|
|
19180
|
+
this.create({
|
|
19181
|
+
id,
|
|
19182
|
+
type: 'default',
|
|
19183
|
+
message: response
|
|
19184
|
+
});
|
|
19185
|
+
} else if (isHttpResponse(response) && !response.ok) {
|
|
19186
|
+
shouldDismiss = false;
|
|
19187
|
+
const promiseData = typeof data.error === 'function' ? await data.error(`HTTP error! status: ${response.status}`) : data.error;
|
|
19188
|
+
const description = typeof data.description === 'function' ? await data.description(`HTTP error! status: ${response.status}`) : data.description;
|
|
19189
|
+
const isExtendedResult = typeof promiseData === 'object' && !React.isValidElement(promiseData);
|
|
19190
|
+
const toastSettings = isExtendedResult ? promiseData : {
|
|
19191
|
+
message: promiseData
|
|
19192
|
+
};
|
|
19193
|
+
this.create({
|
|
19194
|
+
id,
|
|
19195
|
+
type: 'error',
|
|
19196
|
+
description,
|
|
19197
|
+
...toastSettings
|
|
19198
|
+
});
|
|
19199
|
+
} else if (response instanceof Error) {
|
|
19200
|
+
shouldDismiss = false;
|
|
19201
|
+
const promiseData = typeof data.error === 'function' ? await data.error(response) : data.error;
|
|
19202
|
+
const description = typeof data.description === 'function' ? await data.description(response) : data.description;
|
|
19203
|
+
const isExtendedResult = typeof promiseData === 'object' && !React.isValidElement(promiseData);
|
|
19204
|
+
const toastSettings = isExtendedResult ? promiseData : {
|
|
19205
|
+
message: promiseData
|
|
19206
|
+
};
|
|
19207
|
+
this.create({
|
|
19208
|
+
id,
|
|
19209
|
+
type: 'error',
|
|
19210
|
+
description,
|
|
19211
|
+
...toastSettings
|
|
19212
|
+
});
|
|
19213
|
+
} else if (data.success !== undefined) {
|
|
19214
|
+
shouldDismiss = false;
|
|
19215
|
+
const promiseData = typeof data.success === 'function' ? await data.success(response) : data.success;
|
|
19216
|
+
const description = typeof data.description === 'function' ? await data.description(response) : data.description;
|
|
19217
|
+
const isExtendedResult = typeof promiseData === 'object' && !React.isValidElement(promiseData);
|
|
19218
|
+
const toastSettings = isExtendedResult ? promiseData : {
|
|
19219
|
+
message: promiseData
|
|
19220
|
+
};
|
|
19221
|
+
this.create({
|
|
19222
|
+
id,
|
|
19223
|
+
type: 'success',
|
|
19224
|
+
description,
|
|
19225
|
+
...toastSettings
|
|
19226
|
+
});
|
|
19227
|
+
}
|
|
19228
|
+
}).catch(async (error)=>{
|
|
19229
|
+
result = [
|
|
19230
|
+
'reject',
|
|
19231
|
+
error
|
|
19232
|
+
];
|
|
19233
|
+
if (data.error !== undefined) {
|
|
19234
|
+
shouldDismiss = false;
|
|
19235
|
+
const promiseData = typeof data.error === 'function' ? await data.error(error) : data.error;
|
|
19236
|
+
const description = typeof data.description === 'function' ? await data.description(error) : data.description;
|
|
19237
|
+
const isExtendedResult = typeof promiseData === 'object' && !React.isValidElement(promiseData);
|
|
19238
|
+
const toastSettings = isExtendedResult ? promiseData : {
|
|
19239
|
+
message: promiseData
|
|
19240
|
+
};
|
|
19241
|
+
this.create({
|
|
19242
|
+
id,
|
|
19243
|
+
type: 'error',
|
|
19244
|
+
description,
|
|
19245
|
+
...toastSettings
|
|
19246
|
+
});
|
|
19247
|
+
}
|
|
19248
|
+
}).finally(()=>{
|
|
19249
|
+
if (shouldDismiss) {
|
|
19250
|
+
// Toast is still in load state (and will be indefinitely — dismiss it)
|
|
19251
|
+
this.dismiss(id);
|
|
19252
|
+
id = undefined;
|
|
19253
|
+
}
|
|
19254
|
+
data.finally == null ? void 0 : data.finally.call(data);
|
|
19255
|
+
});
|
|
19256
|
+
const unwrap = ()=>new Promise((resolve, reject)=>originalPromise.then(()=>result[0] === 'reject' ? reject(result[1]) : resolve(result[1])).catch(reject));
|
|
19257
|
+
if (typeof id !== 'string' && typeof id !== 'number') {
|
|
19258
|
+
// cannot Object.assign on undefined
|
|
19259
|
+
return {
|
|
19260
|
+
unwrap
|
|
19261
|
+
};
|
|
19262
|
+
} else {
|
|
19263
|
+
return Object.assign(id, {
|
|
19264
|
+
unwrap
|
|
19265
|
+
});
|
|
19266
|
+
}
|
|
19267
|
+
};
|
|
19268
|
+
this.custom = (jsx, data)=>{
|
|
19269
|
+
const id = (data == null ? void 0 : data.id) || toastsCounter++;
|
|
19270
|
+
this.create({
|
|
19271
|
+
jsx: jsx(id),
|
|
19272
|
+
id,
|
|
19273
|
+
...data
|
|
19274
|
+
});
|
|
19275
|
+
return id;
|
|
19276
|
+
};
|
|
19277
|
+
this.getActiveToasts = ()=>{
|
|
19278
|
+
return this.toasts.filter((toast)=>!this.dismissedToasts.has(toast.id));
|
|
19279
|
+
};
|
|
19280
|
+
this.subscribers = [];
|
|
19281
|
+
this.toasts = [];
|
|
19282
|
+
this.dismissedToasts = new Set();
|
|
19283
|
+
}
|
|
19284
|
+
}
|
|
19285
|
+
const ToastState = new Observer();
|
|
19286
|
+
// bind this to the toast function
|
|
19287
|
+
const toastFunction = (message, data)=>{
|
|
19288
|
+
const id = (data == null ? void 0 : data.id) || toastsCounter++;
|
|
19289
|
+
ToastState.addToast({
|
|
19290
|
+
title: message,
|
|
19291
|
+
...data,
|
|
19292
|
+
id
|
|
19293
|
+
});
|
|
19294
|
+
return id;
|
|
19295
|
+
};
|
|
19296
|
+
const isHttpResponse = (data)=>{
|
|
19297
|
+
return data && typeof data === 'object' && 'ok' in data && typeof data.ok === 'boolean' && 'status' in data && typeof data.status === 'number';
|
|
19298
|
+
};
|
|
19299
|
+
const basicToast = toastFunction;
|
|
19300
|
+
const getHistory = ()=>ToastState.toasts;
|
|
19301
|
+
const getToasts = ()=>ToastState.getActiveToasts();
|
|
19302
|
+
// We use `Object.assign` to maintain the correct types as we would lose them otherwise
|
|
19303
|
+
const toast = Object.assign(basicToast, {
|
|
19304
|
+
success: ToastState.success,
|
|
19305
|
+
info: ToastState.info,
|
|
19306
|
+
warning: ToastState.warning,
|
|
19307
|
+
error: ToastState.error,
|
|
19308
|
+
custom: ToastState.custom,
|
|
19309
|
+
message: ToastState.message,
|
|
19310
|
+
promise: ToastState.promise,
|
|
19311
|
+
dismiss: ToastState.dismiss,
|
|
19312
|
+
loading: ToastState.loading
|
|
19313
|
+
}, {
|
|
19314
|
+
getHistory,
|
|
19315
|
+
getToasts
|
|
19316
|
+
});
|
|
19317
|
+
|
|
19318
|
+
__insertCSS("[data-sonner-toaster][dir=ltr],html[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%)}[data-sonner-toaster][dir=rtl],html[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%)}[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:0;z-index:999999999;transition:transform .4s ease}@media (hover:none) and (pointer:coarse){[data-sonner-toaster][data-lifted=true]{transform:none}}[data-sonner-toaster][data-x-position=right]{right:var(--offset-right)}[data-sonner-toaster][data-x-position=left]{left:var(--offset-left)}[data-sonner-toaster][data-x-position=center]{left:50%;transform:translateX(-50%)}[data-sonner-toaster][data-y-position=top]{top:var(--offset-top)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--offset-bottom)}[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);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:0;overflow-wrap:anywhere}[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 rgba(0,0,0,.1);width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}[data-sonner-toast]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-y-position=top]{top:0;--y:translateY(-100%);--lift:1;--lift-amount:calc(1 * var(--gap))}[data-sonner-toast][data-y-position=bottom]{bottom:0;--y:translateY(100%);--lift:-1;--lift-amount:calc(var(--lift) * var(--gap))}[data-sonner-toast][data-styled=true] [data-description]{font-weight:400;line-height:1.4;color:#3f3f3f}[data-rich-colors=true][data-sonner-toast][data-styled=true] [data-description]{color:inherit}[data-sonner-toaster][data-sonner-theme=dark] [data-description]{color:#e8e8e8}[data-sonner-toast][data-styled=true] [data-title]{font-weight:500;line-height:1.5;color:inherit}[data-sonner-toast][data-styled=true] [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)}[data-sonner-toast][data-promise=true] [data-icon]>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}[data-sonner-toast][data-styled=true] [data-icon]>*{flex-shrink:0}[data-sonner-toast][data-styled=true] [data-icon] svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}[data-sonner-toast][data-styled=true] [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;font-weight:500;cursor:pointer;outline:0;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}[data-sonner-toast][data-styled=true] [data-button]:focus-visible{box-shadow:0 0 0 2px rgba(0,0,0,.4)}[data-sonner-toast][data-styled=true] [data-button]:first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}[data-sonner-toast][data-styled=true] [data-cancel]{color:var(--normal-text);background:rgba(0,0,0,.08)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-styled=true] [data-cancel]{background:rgba(255,255,255,.3)}[data-sonner-toast][data-styled=true] [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);background:var(--normal-bg);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-styled=true] [data-close-button]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-styled=true] [data-disabled=true]{cursor:not-allowed}[data-sonner-toast][data-styled=true]:hover [data-close-button]:hover{background:var(--gray2);border-color:var(--gray5)}[data-sonner-toast][data-swiping=true]::before{content:'';position:absolute;left:-100%;right:-100%;height:100%;z-index:-1}[data-sonner-toast][data-y-position=top][data-swiping=true]::before{bottom:50%;transform:scaleY(3) translateY(50%)}[data-sonner-toast][data-y-position=bottom][data-swiping=true]::before{top:50%;transform:scaleY(3) translateY(-50%)}[data-sonner-toast][data-swiping=false][data-removed=true]::before{content:'';position:absolute;inset:0;transform:scaleY(2)}[data-sonner-toast][data-expanded=true]::after{content:'';position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}[data-sonner-toast][data-mounted=true]{--y:translateY(0);opacity:1}[data-sonner-toast][data-expanded=false][data-front=false]{--scale:var(--toasts-before) * 0.05 + 1;--y:translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}[data-sonner-toast]>*{transition:opacity .4s}[data-sonner-toast][data-x-position=right]{right:0}[data-sonner-toast][data-x-position=left]{left:0}[data-sonner-toast][data-expanded=false][data-front=false][data-styled=true]>*{opacity:0}[data-sonner-toast][data-visible=false]{opacity:0;pointer-events:none}[data-sonner-toast][data-mounted=true][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}[data-sonner-toast][data-removed=true][data-front=true][data-swipe-out=false]{--y:translateY(calc(var(--lift) * -100%));opacity:0}[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}[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}[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,0)) translateX(var(--swipe-amount-x,0));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{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{from{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{from{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-sonner-theme=light]{--normal-bg:#fff;--normal-border:var(--gray4);--normal-text:var(--gray12);--success-bg:hsl(143, 85%, 96%);--success-border:hsl(145, 92%, 87%);--success-text:hsl(140, 100%, 27%);--info-bg:hsl(208, 100%, 97%);--info-border:hsl(221, 91%, 93%);--info-text:hsl(210, 92%, 45%);--warning-bg:hsl(49, 100%, 97%);--warning-border:hsl(49, 91%, 84%);--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-sonner-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-sonner-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg:#fff;--normal-border:var(--gray3);--normal-text:var(--gray12)}[data-sonner-toaster][data-sonner-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, 43%, 17%);--info-text:hsl(216, 87%, 65%);--warning-bg:hsl(64, 100%, 6%);--warning-border:hsl(60, 100%, 9%);--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-sonner-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-sonner-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]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[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]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[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]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[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]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}[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:first-child{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)}100%{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}100%{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}100%{opacity:.15}}@media (prefers-reduced-motion){.sonner-loading-bar,[data-sonner-toast],[data-sonner-toast]>*{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%)}");
|
|
18989
19319
|
|
|
18990
19320
|
function buildCheckoutUrl(baseUrl, email, clientReferenceId) {
|
|
18991
19321
|
const separator = baseUrl.includes("?") ? "&" : "?";
|
|
@@ -18993,9 +19323,9 @@ function buildCheckoutUrl(baseUrl, email, clientReferenceId) {
|
|
|
18993
19323
|
}
|
|
18994
19324
|
const useStripeUpgrade = ({ redirectUrl, sourcePlatformKey, mainPlatformKey, currentUserEmail, }) => {
|
|
18995
19325
|
const [triggerGetSession] = dataLayer.useLazyGetStripePricingPageSessionQuery();
|
|
18996
|
-
const [isLoading, setIsLoading] =
|
|
18997
|
-
const [freeUrl, setFreeUrl] =
|
|
18998
|
-
const [premiumUrl, setPremiumUrl] =
|
|
19326
|
+
const [isLoading, setIsLoading] = React.useState(false);
|
|
19327
|
+
const [freeUrl, setFreeUrl] = React.useState(null);
|
|
19328
|
+
const [premiumUrl, setPremiumUrl] = React.useState(null);
|
|
18999
19329
|
const handleUpgrade = async (redirectPlan) => {
|
|
19000
19330
|
setIsLoading(true);
|
|
19001
19331
|
try {
|
|
@@ -19028,7 +19358,7 @@ const useStripeUpgrade = ({ redirectUrl, sourcePlatformKey, mainPlatformKey, cur
|
|
|
19028
19358
|
}
|
|
19029
19359
|
}
|
|
19030
19360
|
catch (_a) {
|
|
19031
|
-
|
|
19361
|
+
toast.error("Failed to load upgrade options. Please try again.");
|
|
19032
19362
|
}
|
|
19033
19363
|
finally {
|
|
19034
19364
|
setIsLoading(false);
|