import type { Activity } from './Activity.js';
import type { Application } from './Application.js';
export declare enum ActivityLifecycle {
    /**
     * The activity is initialized, but not yet created.
     * This is the initial state of the activity.
     */
    Initialized = 0,
    /**
     * The activity is created, but not yet started.
     * This is the state after the `onCreate()` method is called.
     */
    Created = 1,
    /**
     * The activity is started, but not yet resumed.
     * This is the state after the `onStart()` method is called.
     */
    Started = 2,
    /**
     * The activity is resumed and visible to the user.
     * This is the state after the `onResume()` method is called.
     */
    Resumed = 3,
    /**
     * The activity is paused, but still visible to the user.
     * This is the state after the `onPause()` method is called.
     */
    Paused = 4,
    /**
     * The activity is stopped and no longer visible to the user.
     * This is the state after the `onStop()` method is called.
     */
    Stopped = 5,
    /**
     * The activity is destroyed and no longer exists.
     * This is the state after the `onDestroy()` method is called.
     */
    Destroyed = 6
}
export declare enum IntentFlags {
    /**
     * Marks that the activity should be rendered as a modal.
     */
    Modal = 1,
    /**
     * The activity is started for result.
     */
    ForResult = 2,
    /**
     * When set, the intent data is passed by reference.
     * By default the activity manager makes a copy of the intent data.
     * This is useful when the data is large and you want to avoid copying it
     * or when you want to share the same data between activities.
     */
    ByReference = 4
}
export interface Intent<T = unknown> {
    /**
     * The action name the activity is registered for.
     */
    action: string;
    /**
     * The data passed to the activity.
     */
    data?: T;
    /**
     * The category of the activity.
     * Optional and currently not used.
     */
    category?: string[];
    /**
     * The flags that control the behavior of the activity.
     */
    flags?: number;
    /**
     * The request code used to distinguish between different activities.
     */
    requestCode?: number;
}
/**
 * An intent returned by an activity after the activity result is ready.
 * This object is only created when the activity is started with the `ForResult` flag.
 */
export interface ResolvedIntent<T = unknown> extends Intent<T> {
    /**
     * The result code returned by the activity.
     */
    result: IntentResult;
}
export declare enum IntentResult {
    RESULT_CANCELED = 0,
    RESULT_OK = 1
}
/**
 * Type for activity constructor with static action property.
 */
export interface ActivityConstructor {
    new (parent: Application): Activity;
    action?: string;
}
/**
 * Enhanced activity registration options.
 */
export interface ActivityRegistrationOptions {
    /** Whether to override existing registrations */
    override?: boolean;
    /** Optional validation function for intents */
    validateIntent?: (intent: Intent) => boolean;
}
/**
 * Manages application activities.
 *
 * An activity is a screen or a portion of a rendered screen that has its own
 * lifecycle methods and routing.
 *
 * An activity is registered by its class definition. Because of that, activities
 * cannot have constructors that require own parameters. Activities have to be
 * self contained or use the event system to request data.
 */
export declare class ActivityManager {
    #private;
    private currentActivity?;
    /**
     * Stores activity *classes* by unique ID (action name).
     */
    private activityClasses;
    /**
     * Stores the resolvers for activities started for result.
     */
    private resultResolvers;
    /**
     * Represents the activity stack. It is used to manage
     * the UI state after calling the back action.
     */
    private activityStack;
    /**
     * A stack of activities that are rendered over other activities
     * in a dialog.
     */
    private modalActivityStack;
    private generateActivityId;
    constructor(parent: Application);
    /**
     * Registers an activity class with enhanced options.
     * @param action The action name to register the activity for.
     * @param activityClass The activity class constructor.
     * @param options Optional registration configuration.
     */
    registerActivity(action: string, activityClass: ActivityConstructor, options?: ActivityRegistrationOptions): void;
    /**
     * Creates an activity and pushes it into the stack, but it does not initialize any of the lifecycle methods.
     * It is a way to put an activity at some place of the stack,
     * but it will be only initialized when other activities finis.
     *
     * Note, if you add an uninitialized activity and you won't add more activities then this activity may never run.
     * Make sure that there's always another activity.
     *
     * @param intent The intent that created this activity.
     */
    createActivity(intent: Intent): Promise<void>;
    /**
     * Starts a new activity and brings it to the foreground.
     *
     * @param intent The intent that created this activity.
     */
    startActivity(intent: Intent): Promise<Activity>;
    private buildActivity;
    /**
     * Starts an activity that should return a result to the calling activity.
     *
     * @template T The type of the result data expected.
     * @param intent The intent to start the activity.
     * @returns A promise that resolves when the started activity finishes, returning the result Intent with
     * data of type T.
     * @example
     * ```typescript
     * const resultIntent = await mgr.startActivityForResult<{ userId: string }>({ action: 'pickUser' });
     * if (resultIntent.resultCode === IntentResult.RESULT_OK) {
     *   console.log(resultIntent.data?.userId);
     * }
     * ```
     */
    startActivityForResult<T>(intent: Intent): Promise<ResolvedIntent<T | undefined>>;
    isDestroyed(activity: Activity): boolean;
    /**
     * @param activity The activity to finish.
     */
    finishActivity(activity: Activity): Promise<void>;
    private resolveActivityResult;
    private bringLastActivityToFront;
    getTopActivity(): Activity | undefined;
    getCurrentActivity(): Activity | undefined;
    /**
     * Sets the styles for the current activity.
     * This method adds or removes CSS classes based on the activity's class name
     * and action, allowing for dynamic styling based on the active activity.
     * @param activity The activity to set styles for.
     * If not provided, it will not set any styles.
     * If the activity is the same as the current one, it does nothing.
     */
    setupStyles(activity?: Activity, oldActivity?: Activity): void;
    /**
     * A helper method to handle the transition between activities, ensuring
     * lifecycle methods are called in the correct order (pause the previous activity,
     * then start/resume the new one). This centralizes lifecycle management.
     *
     * @param activity The activity to bring to the foreground.
     */
    private updateCurrentActivity;
    /**
     * Safely executes an async lifecycle method with error handling.
     * @param lifecycleMethod The lifecycle method to execute.
     * @param activity The activity instance.
     * @param methodName The name of the method for error reporting.
     * @returns Promise that resolves when the method completes or rejects with wrapped error.
     */
    private safeExecuteLifecycleMethod;
    /**
     * Allows navigating back through the activity stack.
     * Call `ActivityManager.navigateBack()` when the user performs a back action
     * (e.g., clicks a back button).
     * @returns Promise that resolves to true if navigation was successful, false if at root.
     */
    navigateBack(): Promise<boolean>;
    /**
     * Navigates to a specific activity in the stack, clearing activities above it.
     * @param action The action of the activity to navigate to.
     * @returns Promise that resolves to true if navigation was successful.
     */
    navigateToActivity(action: string): Promise<boolean>;
    /**
     * Clears the entire activity stack and starts a new root activity.
     * @param intent The intent for the new root activity.
     */
    clearStackAndStart(intent: Intent): Promise<void>;
    /**
     * Creates an intent with better type safety and validation.
     * @param action The action name.
     * @param data Optional intent data.
     * @param options Optional intent configuration.
     * @returns A properly formed intent.
     */
    createIntent<T = unknown>(action: string, data?: T, options?: {
        category?: string[];
        flags?: number;
        requestCode?: number;
    }): Intent<T>;
    createRequestCode(): number;
    findActiveActivity(action: string): Activity | undefined;
    /**
     * Transitions an activity from Created to Resumed state.
     * @param activity The activity to transition.
     * @returns true if successful, false if activity was destroyed during transition.
     */
    private transitionCreatedToResumed;
    /**
     * Transitions an activity from Started to Resumed state.
     * @param activity The activity to transition.
     * @returns true if successful, false if activity was destroyed during transition.
     */
    private transitionStartedToResumed;
    /**
     * Transitions an activity from Initialized to Resumed state.
     * @param activity The activity to transition.
     * @param intent The intent used to create the activity.
     * @returns true if successful, false if activity was destroyed during transition.
     */
    private transitionInitializedToResumed;
    /**
     * Cleans up resources for destroyed activities to prevent memory leaks.
     * @param activity The activity to clean up.
     */
    private cleanupActivity;
    /**
     * Validates that an activity stack is in a consistent state.
     * @param stack The activity stack to validate.
     * @returns Array of validation errors, empty if valid.
     */
    private validateStackConsistency;
    /**
     * Gets diagnostic information about the current state of the activity manager.
     * Useful for debugging and monitoring.
     * @returns Object containing current state information.
     */
    getDiagnostics(): {
        totalActivities: number;
        modalActivities: number;
        currentActivity?: string;
        topActivity?: string;
        stackValidation: string[];
        modalStackValidation: string[];
    };
    /**
     * Gets all registered activity actions.
     * @returns Array of registered action names.
     */
    getRegisteredActions(): string[];
    /**
     * Checks if an action is registered.
     * @param action The action to check.
     * @returns true if the action is registered, false otherwise.
     */
    isActionRegistered(action: string): boolean;
}
//# sourceMappingURL=ActivityManager.d.ts.map