{"version":3,"file":"index.js","names":["c","_c","React","useEffect","useRef","useRouteTransition","transitionDuration","baseClass","initialDelay","ProgressBar","$","isTransitioning","transitionProgress","progressToShow","setProgressToShow","useState","shouldDelayProgress","t0","t1","clearTimerID","delayTimerID","current","clearTimeout","t2","t3","filter","Boolean","t4","join","t5","_jsx","className","style","children","width"],"sources":["../../../../src/providers/RouteTransition/ProgressBar/index.tsx"],"sourcesContent":["'use client'\nimport React, { useEffect, useRef } from 'react'\n\nimport { useRouteTransition } from '../index.js'\nimport './index.scss'\n\nconst transitionDuration = 200\nconst baseClass = 'progress-bar'\nconst initialDelay = 150\n\n/**\n * Renders a progress bar that shows the progress of a route transition.\n * Place this at the root of your application, inside of the `RouteTransitionProvider`.\n * When a transition is triggered, the progress bar will show the progress of that transition and exit when the transition is complete.\n * @returns A progress bar that shows the progress of a route transition\n * @example\n * import { RouteTransitionProvider, ProgressBar, Link } from '@payloadcms/ui'\n * const App = () => (\n * \n * \n * Go Somewhere\n * \n */\nexport const ProgressBar = () => {\n const { isTransitioning, transitionProgress } = useRouteTransition()\n const [progressToShow, setProgressToShow] = React.useState(null)\n const shouldDelayProgress = useRef(true)\n\n useEffect(() => {\n let clearTimerID: NodeJS.Timeout\n let delayTimerID: NodeJS.Timeout\n\n if (isTransitioning) {\n if (shouldDelayProgress.current) {\n delayTimerID = setTimeout(() => {\n setProgressToShow(transitionProgress)\n shouldDelayProgress.current = false\n }, initialDelay)\n } else {\n setProgressToShow(transitionProgress)\n }\n } else {\n shouldDelayProgress.current = true\n\n // Fast forward to 100% when the transition is complete\n // Then fade out the progress bar directly after\n setProgressToShow(1)\n\n // Wait for CSS transition to finish before hiding the progress bar\n // This includes both the fast-forward to 100% and the subsequent fade-out\n clearTimerID = setTimeout(() => {\n setProgressToShow(null)\n }, transitionDuration * 2)\n }\n\n return () => {\n clearTimeout(clearTimerID)\n clearTimeout(delayTimerID)\n }\n }, [isTransitioning, transitionProgress])\n\n if (typeof progressToShow === 'number') {\n return (\n