import { Ref, ComputedRef, InjectionKey } from 'vue'; import { ExperimentSummary, ExperimentStatus } from '../types'; export interface UseAppExperimentOptions { /** * Called when the shared store adopts an experiment — a modal selection or a * resolved deep link. The record always comes from the platform. */ onSelect?: (experiment: ExperimentSummary) => void | Promise; onSave?: () => string | null | Promise; onDetach?: () => void; saveDisabled?: Ref | ComputedRef; saveDisabledMessage?: string | Ref | ComputedRef; } export interface AppExperimentPopoverBinding { experimentName?: string; experimentCode?: string; experimentStatus?: ExperimentStatus; /** An experiment is bound but its record has not arrived yet. */ isResolving: boolean; /** Resolution failed; the binding is kept so the user can retry or detach. */ error?: string; showSave: boolean; showDetach: boolean; saveDisabled: boolean; saveDisabledMessage?: string; saveLoading: boolean; saveSuccessMessage?: string; } export interface AppExperimentSelectorModalBinding { modelValue: boolean; currentExperimentId: number | null; } export interface UseAppExperimentReturn { experimentName: ComputedRef; experimentCode: ComputedRef; experimentStatus: ComputedRef; experimentId: ComputedRef; isResolving: ComputedRef; error: ComputedRef; popover: ComputedRef; selectorModal: ComputedRef; openModal: () => void; closeModal: () => void; handleSave: () => Promise; handleDetach: () => void; } export interface AppExperimentState { experimentName: ComputedRef; experimentCode: ComputedRef; experimentStatus: ComputedRef; experimentId: ComputedRef; isResolving: ComputedRef; error: ComputedRef; showModal: Ref; saveLoading: Ref; saveSuccessMessage: Ref; showSave: Ref; showDetach: ComputedRef; closeModal: () => void; saveDisabled: ComputedRef; saveDisabledMessage: ComputedRef; popover: ComputedRef; selectorModal: ComputedRef; openModal: () => void; handleSave: () => Promise; handleDetach: () => void; } export declare const APP_EXPERIMENT_KEY: InjectionKey; /** * Projects the current experiment from the shared store into an AppTopBar app * shell, and owns the shell-local concerns the store has no opinion on: the * selector modal's open state and the save flow. * * The composable never writes a selection of its own. `ExperimentSelectorModal` * commits to the store and this reads back, so a displayed name can only ever * have come from the platform. * * @example Recommended * ```ts * const appExperiment = useAppExperiment({ * onSelect: experiment => loadExperiment(experiment.id), * }) * ``` */ export declare function useAppExperiment(options?: UseAppExperimentOptions): UseAppExperimentReturn;