import 'reflect-metadata';
import { APIGatewayProxyResult } from 'aws-lambda';
import type { LambdaInterface } from '@aws-lambda-powertools/commons/types';
import { Logger } from '@aws-lambda-powertools/logger';
import { BeforeInstance, LoggerInterface, Maybe } from '@worktif/utils';
import { LambdaApi, LambdaContext, LambdaEventApi } from '@worktif/purews';
import { EnvConfigRuntime } from '../../config/env.config.runtime';
import { StaticS3Service } from '../../services/aws/s3/s3.static/s3.static.service';
import { SsrService } from '../../services/ssr/ssr.service';
import { HtmlTemplateService } from '../../services/template/html-template.service';
import { RuntimeWebContainer } from '../../bundle/runtime-web.container';
/**
 * @class LambdaRuntimeWeb
 * Represents a handler for serverless rendering and API interactions in a Lambda environment, specifically
 * designed for the Runtime Web application. This class extends the `LambdaApi` base class and implements both
 * `LambdaInterface` and `LoggerInterface`, providing structured logging and server-side operations.
 *
 * Key Features:
 * - Integration with React for handling server-side rendering via SsrService.
 * - Support for dual render modes (lambda-shell and unix-shell) via environment configuration.
 * - Effective caching using AWS S3 for rendered pages to improve performance.
 * - Detailed diagnostics and error handling with injected logging capabilities.
 * - Separation of concerns: React rendering (SsrService), HTML templating (HtmlTemplateService), and caching (S3Service).
 */
export declare class LambdaRuntimeWeb extends LambdaApi implements LambdaInterface, LoggerInterface {
    protected envConfig: EnvConfigRuntime;
    protected ssrService: SsrService;
    protected templateService: HtmlTemplateService;
    protected s3Service: StaticS3Service;
    /**
     * Represents an instance of a Logger.
     * @type {Logger}
     */
    loggerInstance: Logger;
    /**
     * Render mode configuration determining response format.
     * - lambda-shell: Returns complete HTML documents (default)
     * - unix-shell: Returns JSON with RuntimeWebResponse for Unix/NGINX processing
     */
    private renderMode;
    /**
     * Represents an optional container object.
     *
     * This variable may hold a `PureContainer` instance or be undefined. It is wrapped with the `Maybe` utility type to indicate that it could also represent a nullable or optional structure, providing flexibility in its usage within the application.
     *
     * Use this variable to encapsulate and manage contents or elements grouped logically as a container.
     *
     * @type {Maybe<RuntimeWebContainer>}
     */
    protected container?: Maybe<RuntimeWebContainer>;
    /**
     * Represents the runtime configuration for the system, which may or may not be defined.
     *
     * The `runtime` variable can hold an instance of `Maybe<RuntimeConfig>` or be undefined.
     * It is used to determine or store the current operational configuration, which may vary dynamically.
     *
     * @type {Maybe<RuntimeConfig>}
     */
    protected runtimeThreads: Maybe<any>;
    /**
     * Constructs an instance of the class with the provided dependencies.
     *
     * @param {EnvConfigRuntime} envConfig - The environment configuration class to manage environment-specific settings.
     * @param {SsrService} ssrService - The serverless rendering service for React rendering and structured response generation.
     * @param {HtmlTemplateService} templateService - The HTML template service for wrapping React content in HTML documents.
     * @param {StaticS3Service} s3Service - The Static S3 Service instance to handle interactions with AWS S3.
     */
    constructor(envConfig: EnvConfigRuntime, ssrService: SsrService, templateService: HtmlTemplateService, s3Service: StaticS3Service);
    /**
     * Handles lambda-shell mode: Returns complete HTML document.
     *
     * This method:
     * 1. Gets the CloudFront base URL from environment variable
     * 2. Calls HtmlTemplateService to wrap React content in HTML document
     * 3. Caches the result in S3 (non-blocking)
     * 4. Returns complete HTML with proper headers
     *
     * Error handling:
     * - Missing CloudFront URL: Returns 500 error with clear message
     * - HTML processing errors: Caught and logged, returns 500 error
     * - S3 caching errors: Logged as warnings, does not fail request
     *
     * @param {RuntimeWebResponse} response - The structured serverless rendering response from SsrService.
     * @param {string} pathname - The normalized pathname for caching.
     * @param {number} startTime - The request start time for duration calculation.
     * @param {BeforeInstance} [beforeInstance] - Optional logging instance.
     * @return {Promise<APIGatewayProxyResult>} Complete HTML response.
     * @private
     */
    private handleLambdaShellMode;
    /**
     * Handles unix-shell mode: Returns JSON with RuntimeWebResponse.
     *
     * This method returns the structured RuntimeWebResponse as JSON for Unix/NGINX
     * to process. The Unix/NGINX layer will wrap the bodyHtml in an HTML document.
     *
     * @param {RuntimeWebResponse} ssrResponse - The structured serverless rendering response from SsrService.
     * @param {number} startTime - The request start time for duration calculation.
     * @param {BeforeInstance} [beforeInstance] - Optional logging instance.
     * @return {APIGatewayProxyResult} JSON response with RuntimeWebResponse.
     * @private
     */
    private handleUnixShellMode;
    /**
     * Returns a cached HTML response with proper headers.
     *
     * @param {string} html - The cached HTML content.
     * @param {number} startTime - The request start time for duration calculation.
     * @return {APIGatewayProxyResult} Cached HTML response.
     * @private
     */
    private returnCachedResponse;
    /**
     * Handles serverless rendering for a given Lambda event. This method retrieves cached HTML for the requested
     * path if available, otherwise it renders the HTML dynamically using the new serverless rendering pipeline architecture.
     *
     * The handler supports two render modes:
     * - lambda-shell: Returns complete HTML documents (default)
     * - unix-shell: Returns JSON with RuntimeWebResponse for Unix/NGINX processing
     *
     * @param {LambdaEventApi<any, 'post'>} event - The event object containing the API request details.
     * @param {LambdaContext} _ - The Lambda execution context.
     * @param __
     * @param {BeforeInstance} [beforeInstance] - Optional value used for dependency injection prior to execution.
     * @return {Promise<APIGatewayProxyResult>} - The HTTP response object, including the rendered HTML content or an error message.
     */
    handler(event: LambdaEventApi<any, 'get'>, _: LambdaContext, __: any, beforeInstance?: BeforeInstance): Promise<APIGatewayProxyResult>;
    /**
     * Generates a unique ETag string for the given HTML content using a SHA-256 hash.
     * The ETag is used for cache validation and content integrity verification.
     *
     * @param {string} html - The HTML content to generate the ETag for.
     * @return {string} The computed ETag value as a base64-encoded string (first 27 characters for efficiency).
     */
    private composeEtag;
}
