"use client"; import type { PropsWithChildren, ReactNode } from "react"; import { createContext, Suspense, use, useContext } from "react"; import { Box } from "@mantine/core"; const TourTargetsEnabledContext = createContext(false); let tourLibraryPromise: Promise | undefined; const loadTourLibrary = () => { if (tourLibraryPromise) return tourLibraryPromise; const currentPromise = import("@gfazioli/mantine-onboarding-tour"); tourLibraryPromise = currentPromise; void currentPromise.catch(() => { if (tourLibraryPromise === currentPromise) tourLibraryPromise = undefined; }); return currentPromise; }; export const TourTargetsProvider = ({ enabled = true, children }: PropsWithChildren<{ enabled?: boolean }>) => ( {children} ); const LoadedTourTarget = ({ id, children }: { id: string; children: ReactNode }) => { const { OnboardingTour } = use(loadTourLibrary()); return {children}; }; export const TourTarget = ({ id, children }: { id: string; children: ReactNode }) => { const isEnabled = useContext(TourTargetsEnabledContext); if (!isEnabled) return children; const target = {children}; return ( {target} ); };