'use client'; import { computeRenderSuspended, toManifestExperiments, useFunnelRuntimeConfig, useFunnelFlowController as useSharedFunnelFlowController, } from '@funnelsgrove/runtime'; import { publicAnalyticsSdk } from '@funnelsgrove/analytics'; import { funnelManifest } from '@/config/funnel.manifest'; import { stepById, stepComponentById } from '@/steps'; import { defaultFunnelStepId, funnelExperiments, funnelStepSequence, getChoiceTargetsForStep, getPathForStep, getSequentialNextStepId, getStepIdFromPath, isFunnelStepId, resolveConfiguredNextStep, resolveRuntimeInitialStepId, type FunnelStepId, } from './funnel-runtime'; type FunnelFlowControllerInput = { initialStepId?: FunnelStepId; lockToInitialStep?: boolean; }; export { computeRenderSuspended }; export function useFunnelFlowController({ initialStepId = defaultFunnelStepId, lockToInitialStep = false, }: FunnelFlowControllerInput = {}) { const publishedRuntime = useFunnelRuntimeConfig(); const activeFunnelExperiments = publishedRuntime.config ? toManifestExperiments(publishedRuntime.config.experiments).map((experiment) => ({ ...experiment, stepId: experiment.stepId as FunnelStepId, variants: experiment.variants.map((variant) => ({ ...variant, routeToStepId: variant.routeToStepId as FunnelStepId, })), })) : funnelExperiments; return useSharedFunnelFlowController({ analytics: publicAnalyticsSdk, stepContractVersion: funnelManifest.stepContractVersion, initialStepId, lockToInitialStep, defaultStepId: defaultFunnelStepId, stepSequence: funnelStepSequence, stepById, stepComponentById, funnelExperiments: activeFunnelExperiments, getPathForStep, getStepIdFromPath, getSequentialNextStepId, getChoiceTargetsForStep, isFunnelStepId, resolveConfiguredNextStep, resolveRuntimeInitialStepId, }); }