import { nothing, TemplateResult } from 'lit';
import { ActivityLifecycle, IntentResult, type Intent, type ResolvedIntent } from './ActivityManager.js';
import { FragmentManager } from './FragmentManager.js';
import type { Fragment } from './Fragment.js';
import type { Application, UpdateRequest } from './Application.js';
import type { ActivityDetail, ActivityWithResultDetail } from '../events/IntentEvents.js';
export interface ActivityResult {
    requestCode: number;
    resultCode: IntentResult;
    data?: unknown;
    intent: Intent;
}
/**
 * ## Activity
 *
 * `Activity` is a core building block of your application, representing a single,
 * focused operation that a user can perform.
 * Activities manage their own lifecycle, UI, and fragments, and communicate with the application
 * and other activities via intents.
 *
 * Activities are managed by the application and can be started, paused, resumed, stopped,
 * and destroyed according to the app's navigation and user actions.
 * They can also start other activities for results, manage fragments, and handle intent
 * events dispatched by hosted web components.
 *
 * ### Lifecycle Methods
 * - `onCreate(intent?)` - Called when the activity is first created.
 * - `onStart()` - Called when the activity becomes visible to the user.
 * - `onResume()` - Called when the activity gains focus and becomes interactive.
 * - `onPause()` - Called when the activity loses focus but is still visible.
 * - `onStop()` - Called when the activity is no longer visible.
 * - `onDestroy()` - Called before the activity is destroyed.
 * - `onRestart()` - Called after the activity has been stopped, just prior to it being started again.
 *
 * ### Example
 * ```typescript
 * class MyActivity extends Activity {
 *   async onCreate(intent?: Intent) {
 *     super.onCreate(intent);
 *     // Initialization logic here
 *   }
 *
 *   render() {
 *     return html`<h1>Hello from MyActivity!</h1>`;
 *   }
 * }
 * ```
 */
export declare class Activity extends EventTarget {
    /**
     * The root element where the activity's content should be rendered.
     * Set this if you want to render outside the application's default render root (e.g., for modals).
     */
    renderRoot?: HTMLElement;
    /**
     * An optional static action name for the activity.
     * Use this as the registration key for referencing the activity in intents.
     *
     * @example
     * ```typescript
     * class LoginActivity extends Activity {
     *   static action = 'login';
     * }
     * ```
     */
    static action?: string;
    /** The current lifecycle state of the activity. */
    lifecycle: ActivityLifecycle;
    /** The parent application instance. */
    protected parent: Application;
    /** The fragment manager for managing fragments within this activity. */
    protected manager: FragmentManager;
    /** Data to be returned as a result to the calling activity. */
    protected resultData?: unknown;
    /** The exit code for the activity result. */
    protected exitCode: IntentResult;
    /** Gets the current result code for the activity. */
    get resultCode(): IntentResult;
    /**
     * Constructs a new Activity.
     * @param parent The parent application instance.
     */
    constructor(parent: Application);
    /**
     * Returns the current activity instance.
     * @returns This activity.
     */
    getActivity(): Activity;
    /**
     * Checks if the activity is in the `Destroyed` state.
     * @returns `true` if destroyed, `false` otherwise.
     */
    isDestroyed(): boolean;
    /**
     * Checks if the activity is in the `Resumed` state.
     * @returns `true` if resumed, `false` otherwise.
     */
    isResumed(): boolean;
    /**
     * Called when the activity is starting. Override to perform initialization logic.
     * @param intent Optional intent data.
     * @example
     * ```typescript
     * async onCreate(intent?: Intent) {
     *   await fetchData();
     * }
     * ```
     */
    onCreate(intent?: Intent): void | Promise<void>;
    /**
     * Called when the activity becomes visible to the user.
     * Override to start animations or prepare UI.
     */
    onStart(): void | Promise<void>;
    /**
     * Called when the activity gains focus and becomes interactive.
     * Override to start input handling or resume tasks.
     */
    onResume(): void | Promise<void>;
    /**
     * Called when the activity loses focus but is still visible.
     * Override to pause ongoing tasks or save state.
     */
    onPause(): void | Promise<void>;
    /**
     * Called when the activity is no longer visible to the user.
     * Override to stop UI updates or animations.
     */
    onStop(): void | Promise<void>;
    /**
     * Called after the activity has been stopped, just prior to it being started again.
     */
    onRestart(): void | Promise<void>;
    /**
     * Called before the activity is destroyed. Override to clean up resources.
     */
    onDestroy(): void | Promise<void>;
    /**
     * Called when a new intent is delivered to the activity.
     * Override to handle new intents.
     * @param intent New intent data.
     */
    onNewIntent(intent: Intent): void | Promise<void>;
    /**
     * Called by the renderer when the activity is rendered for the first time.
     * Override to perform actions after first render.
     */
    onFirstRender(): void;
    /**
     * Renders the activity's view. Override to provide UI.
     * @returns A Lit TemplateResult or `nothing` if nothing should be rendered.
     * @example
     * ```typescript
     * render() {
     *   return html`<div>Hello, world!</div>`;
     * }
     * ```
     */
    render(): TemplateResult | typeof nothing;
    /**
     * Finishes the activity and notifies the application.
     * @example
     * ```typescript
     * await this.finish();
     * ```
     */
    finish(): Promise<void>;
    /**
     * Requests the parent application to update the UI.
     * @param opts Update options.
     * @example
     * ```typescript
     * this.requestUpdate();
     * ```
     */
    requestUpdate(opts?: UpdateRequest): void;
    /**
     * Registers a new fragment with this activity.
     * @param key The fragment's key.
     * @param fragment The fragment instance.
     * @param data Optional data to pass to the fragment.
     * @example
     * ```typescript
     * await this.addFragment('profile', new ProfileFragment());
     * ```
     */
    addFragment(key: string, fragment: Fragment, data?: unknown): Promise<void>;
    /**
     * Shows a registered fragment.
     * @param key The fragment's key.
     * @param root Optional root element to render into.
     */
    showFragment(key: string, root?: HTMLElement): Promise<void>;
    /**
     * Hides a registered fragment.
     * @param key The fragment's key.
     */
    hideFragment(key: string): Promise<void>;
    /**
     * Returns the parent application instance.
     * @returns The application.
     */
    getApplication(): Application;
    /**
     * Starts a new activity.
     * @param intent The intent to start.
     * @example
     * ```typescript
     * await this.startActivity({ action: 'login' });
     * ```
     */
    startActivity(intent: Intent): Promise<Activity>;
    /**
     * Starts a new activity for a result.
     * @template T The type of the result data expected.
     * @param intent The intent to start.
     * @returns A promise that resolves when the started activity finishes, returning the result Intent with
     * data of type T.
     * @example
     * ```typescript
     * const resultIntent = await this.startActivityForResult<{ userId: string }>({ action: 'pickUser' });
     * if (resultIntent.resultCode === IntentResult.RESULT_OK) {
     *   console.log(resultIntent.data?.userId);
     * }
     * ```
     */
    startActivityForResult<T>(intent: Intent): Promise<ResolvedIntent<T | undefined>>;
    /**
     * Sets the result to be returned to the calling activity.
     * @param resultCode The result code.
     * @param data Optional result data.
     * @example
     * ```typescript
     * this.setResult(IntentResult.RESULT_OK, { userId: 123 });
     * ```
     */
    setResult(resultCode: IntentResult, data?: unknown): void;
    /**
     * Gets the result data set by `setResult`.
     * @returns The result data or `undefined`.
     */
    getResult(): unknown | undefined;
    /**
     * Handles intent events dispatched by web components hosted by this activity.
     *
     * Usage example:
     * ```html
     * <custom-element @startactivity="${this.handleIntentEvent}"></custom-element>
     * <custom-element @startactivityforresult="${this.handleIntentEvent}"></custom-element>
     * ```
     *
     * @param event The intent event.
     * @throws Error if the event type is not recognized.
     */
    handleIntentEvent(event: CustomEvent<ActivityDetail | ActivityWithResultDetail>): Promise<void>;
}
//# sourceMappingURL=Activity.d.ts.map