import { BuildOptions, Plugin as Plugin$1 } from 'esbuild';
import { Configuration, WebpackPluginInstance } from 'webpack';

declare const RULE_OPERATORS_WITH_VALUE: readonly ["is_equal", "is_not_equal", "starts_with", "does_not_start_with", "matches", "does_not_match"];
declare const RULE_OPERATORS_WITHOUT_VALUE: readonly ["exists", "does_not_exist"];
declare const RULE_CONDITIONALS: readonly ["if", "and", "or"];
declare const RULE_VARIABLES: readonly ("args" | "device_group" | "domain" | "geoip_city" | "geoip_city_continent_code" | "geoip_city_country_code" | "geoip_city_country_name" | "geoip_continent_code" | "geoip_country_code" | "geoip_country_name" | "geoip_region" | "geoip_region_name" | "host" | "remote_addr" | "remote_port" | "remote_user" | "request" | "request_body" | "request_method" | "request_uri" | "scheme" | "uri" | "server_addr" | "server_port" | "ssl_client_fingerprint" | "ssl_client_escaped_cert" | "ssl_client_s_dn" | "ssl_client_s_dn_parsed" | "ssl_client_cert" | "ssl_client_i_dn" | "ssl_client_serial" | "ssl_client_v_end" | "ssl_client_v_remain" | "ssl_client_v_start" | "ssl_client_verify" | "sent_http_name" | "status" | "tcpinfo_rtt" | "upstream_addr" | "upstream_status")[];
declare const FIREWALL_RATE_LIMIT_TYPES: readonly ["second", "minute"];
declare const FIREWALL_RATE_LIMIT_BY: readonly ["clientIp", "global"];
declare const FIREWALL_WAF_MODES: readonly ["learning", "blocking"];
type RuleOperatorWithValue = (typeof RULE_OPERATORS_WITH_VALUE)[number];
type RuleOperatorWithoutValue = (typeof RULE_OPERATORS_WITHOUT_VALUE)[number];
type RuleConditional = (typeof RULE_CONDITIONALS)[number];
type WithDollarBraces<T extends string> = `\${${T}}` | T;
type DynamicVariable = `arg_${string}` | `cookie_${string}` | `http_${string}` | `sent_http_${string}` | `upstream_cookie_${string}` | `upstream_http_${string}`;
type RuleVariable = WithDollarBraces<(typeof RULE_VARIABLES)[number]> | DynamicVariable | WithDollarBraces<DynamicVariable>;
type FirewallRateLimitType = (typeof FIREWALL_RATE_LIMIT_TYPES)[number];
type FirewallRateLimitBy = (typeof FIREWALL_RATE_LIMIT_BY)[number];
type FirewallWafMode = (typeof FIREWALL_WAF_MODES)[number];
declare const NETWORK_LIST_TYPES: readonly ["ip_cidr", "asn", "countries"];
type NetworkListType = (typeof NETWORK_LIST_TYPES)[number];
declare const WAF_MODE: readonly ["learning", "blocking", "counting"];
type WafMode = (typeof WAF_MODE)[number];
declare const WAF_SENSITIVITY: readonly ["low", "medium", "high"];
type WafSensitivity = (typeof WAF_SENSITIVITY)[number];

interface Metadata {
    geoip_asn: string;
    geoip_city: string;
    geoip_city_continent_code: string;
    geoip_city_country_code: string;
    geoip_city_country_name: string;
    geoip_continent_code: string;
    geoip_country_code: string;
    geoip_country_name: string;
    geoip_region: string;
    geoip_region_name: string;
    remote_addr: string;
    remote_port: string;
    remote_user: string;
    server_protocol: string;
    ssl_cipher: string;
    ssl_protocol: string;
    [key: string]: string;
}
/**
 * Represents the FetchEvent interface.
 */
interface FetchEvent extends Event {
    request: Request & {
        metadata: Metadata;
    };
    waitUntil(promise: Promise<any>): void;
    respondWith(response: Response | Promise<Response>): void;
}

/**
 * Domain configuration for Azion.
 */
type AzionDomain = {
    /** Domain name */
    name: string;
    /** Indicates if access is restricted to CNAME only */
    cnameAccessOnly?: boolean;
    /** List of CNAMEs associated with the domain */
    cnames?: string[];
    /** Associated edge application ID */
    id?: number;
    /** Associated edge appliaction ID */
    edgeApplicationId?: number;
    /** Associated edge firewall ID */
    edgeFirewallId?: number;
    /** Digital certificate ID */
    digitalCertificateId?: string | number | null;
    /** Indicates if the domain is active */
    active?: boolean;
    /** Mutual TLS configuration */
    mtls?: {
        /** Verification mode for MTLS */
        verification: 'enforce' | 'permissive';
        /** ID of the trusted CA certificate */
        trustedCaCertificateId: number;
        /** List of CRL (Certificate Revocation List) IDs */
        crlList?: number[];
    };
};
/**
 * Origin configuration for Azion.
 */
type AzionOrigin = {
    /** Origin ID */
    id?: number;
    /** Origin key */
    key?: string;
    /** Origin name */
    name: string;
    /** Origin type */
    type: string;
    /** Bucket name for S3-like origins */
    bucket?: string | null;
    /** Prefix for S3-like origins */
    prefix?: string | null;
    /** Addresses for the origin */
    addresses?: string[] | {
        /** Address of the origin */
        address: string;
        /** Weight for load balancing */
        weight?: number;
    }[];
    /** Host header to be sent to the origin */
    hostHeader?: string;
    /** Protocol policy for communicating with the origin */
    protocolPolicy?: 'http' | 'https' | 'preserve';
    /** Indicates if redirection should be used */
    redirection?: boolean;
    /** Load balancing method */
    method?: 'ip_hash' | 'least_connections' | 'round_robin';
    /** Path to be appended to the origin address */
    path?: string;
    /** Connection timeout in seconds */
    connectionTimeout?: number;
    /** Timeout between bytes in seconds */
    timeoutBetweenBytes?: number;
    /** HMAC authentication configuration */
    hmac?: {
        /** AWS region */
        region: string;
        /** AWS access key */
        accessKey: string;
        /** AWS secret key */
        secretKey: string;
    };
};
/**
 * Cache configuration for Azion.
 */
type AzionCache = {
    /** Cache name */
    name: string;
    /** Indicates if stale content should be served */
    stale?: boolean;
    /** Indicates if query string parameters should be sorted */
    queryStringSort?: boolean;
    /** HTTP methods to be cached */
    methods?: {
        /** Cache POST requests */
        post?: boolean;
        /** Cache OPTIONS requests */
        options?: boolean;
    };
    /** Browser cache settings */
    browser?: {
        /** Maximum age for browser cache in seconds */
        maxAgeSeconds: number | string;
    };
    /** Edge cache settings */
    edge?: {
        /** Maximum age for edge cache in seconds */
        maxAgeSeconds: number | string;
    };
    /** Cache by cookie configuration */
    cacheByCookie?: {
        /** Cookie caching option */
        option: 'ignore' | 'varies' | 'whitelist' | 'blacklist';
        /** List of cookies to be considered */
        list?: string[];
    };
    /** Cache by query string configuration */
    cacheByQueryString?: {
        /** Query string caching option */
        option: 'ignore' | 'varies' | 'whitelist' | 'blacklist';
        /** List of query string parameters to be considered */
        list?: string[];
    };
};
type AzionRuleCriteriaBase = {
    /** Variable to be evaluated */
    variable: RuleVariable;
    /** Conditional type */
    conditional: RuleConditional;
};
type AzionRuleCriteriaWithValue = AzionRuleCriteriaBase & {
    /** Operator for comparison that requires input value */
    operator: RuleOperatorWithValue;
    /** Input value for comparison */
    inputValue: string;
};
type AzionRuleCriteriaWithoutValue = AzionRuleCriteriaBase & {
    /** Operator for comparison that doesn't require input value */
    operator: RuleOperatorWithoutValue;
};
type AzionRuleCriteria = AzionRuleCriteriaWithValue | AzionRuleCriteriaWithoutValue;
/**
 * Request rule configuration for Azion.
 */
type AzionRequestRule = {
    /** Rule name */
    name: string;
    /** Rule description */
    description?: string;
    /** Indicates if the rule is active */
    active?: boolean;
    /** Match criteria for the rule */
    match?: string;
    /** Variable to be used in the match */
    variable?: RuleVariable;
    /** Array of criteria for complex conditions */
    criteria?: AzionRuleCriteria[];
    /** Behavior to be applied when the rule matches */
    behavior?: {
        /** Set a new origin */
        setOrigin?: {
            /** Origin name */
            name: string;
            /** Origin type */
            type: string;
        };
        /** Rewrite the request */
        rewrite?: string;
        /** Set headers */
        setHeaders?: string[];
        /** Bypass cache */
        bypassCache?: boolean | null;
        /** Force HTTPS */
        httpToHttps?: boolean | null;
        /** Redirect with 301 status */
        redirectTo301?: string | null;
        /** Redirect with 302 status */
        redirectTo302?: string | null;
        /** Forward cookies */
        forwardCookies?: boolean | null;
        /** Set a cookie */
        setCookie?: string | null;
        /** Deliver the content */
        deliver?: boolean | null;
        /** Deny */
        deny?: boolean | null;
        /** No content */
        noContent?: boolean | null;
        /** enable GZIP compression */
        enableGZIP?: boolean | null;
        /** Filter cookie */
        filterCookie?: string | null;
        /** Filter header */
        filterHeader?: string | null;
        /** Optimize images */
        optimizeImages?: boolean | null;
        /** Capture configuration */
        capture?: {
            /** Match pattern */
            match: string;
            /** Captured value */
            captured: string;
            /** Subject to capture from */
            subject: string;
        };
        /** Run a serverless function */
        runFunction?: string;
        /** Set cache configuration */
        setCache?: string | {
            /** Cache name */
            name: string;
            /** Browser cache TTL */
            browser_cache_settings_maximum_ttl?: number | null;
            /** CDN cache TTL */
            cdn_cache_settings_maximum_ttl?: number | null;
        };
    };
};
/**
 * Response rule configuration for Azion.
 */
type AzionResponseRule = {
    /** Rule name */
    name: string;
    /** Rule description */
    description?: string;
    /** Indicates if the rule is active */
    active?: boolean;
    /** Match criteria for the rule */
    match?: string;
    /** Variable to be used in the match */
    variable?: RuleVariable;
    /** Array of criteria for complex conditions */
    criteria?: AzionRuleCriteria[];
    /** Behavior to be applied when the rule matches */
    behavior?: {
        /** Set a cookie */
        setCookie?: string | null;
        /** Set headers */
        setHeaders?: string[];
        /** Deliver the content */
        deliver?: boolean | null;
        /** Capture configuration */
        capture?: {
            /** Match pattern */
            match: string;
            /** Captured value */
            captured: string;
            /** Subject to capture from */
            subject: string;
        };
        /** Enable GZIP compression */
        enableGZIP?: boolean | null;
        /** Filter a cookie */
        filterCookie?: string | null;
        /** Filter a header */
        filterHeader?: string | null;
        /** Run a serverless function */
        runFunction?: string;
        /** Redirect with 301 status */
        redirectTo301?: string | null;
        /** Redirect with 302 status */
        redirectTo302?: string | null;
    };
};
/**
 * Rules configuration for Azion.
 */
type AzionRules = {
    /** Request rules */
    request?: AzionRequestRule[];
    /** Response rules */
    response?: AzionResponseRule[];
};
/**
 * Purge configuration for Azion.
 */
type AzionPurge = {
    /** Purge type */
    type: 'url' | 'cachekey' | 'wildcard';
    /** URLs to be purged */
    urls: string[];
    /** HTTP method for purge request */
    method?: 'delete';
    /** Cache layer to be purged */
    layer?: 'edge_caching' | 'l2_caching';
};
type PresetInput = string | AzionBuildPreset;
type BuildEntryPoint = string | string[] | Record<string, string>;
interface AzionBuild<T extends Configuration | BuildOptions | unknown = Configuration | BuildOptions> {
    entry?: BuildEntryPoint;
    bundler?: 'webpack' | 'esbuild';
    preset?: PresetInput;
    polyfills?: boolean;
    extend?: (context: T) => T;
    memoryFS?: {
        injectionDirs: string[];
        removePathPrefix: string;
    };
}
/**
 * Network list configuration for Azion.
 */
type AzionNetworkList = {
    /** Network list identifier */
    id: number;
    /** Network list type */
    listType: NetworkListType;
    /** List of networks */
    listContent: string[] | number[];
};
/**
 * Function configuration for Azion.
 */
type AzionFunction = {
    /** Function name */
    name: string;
    /** Function path */
    path: string;
    /** Optional arguments to be passed to the function */
    args?: Record<string, unknown>;
};
/**
 * Main configuration type for Azion.
 */
type AzionConfig = {
    /** Build configuration */
    build?: AzionBuild;
    /** Domain configuration */
    domain?: AzionDomain;
    /** Origin configurations */
    origin?: AzionOrigin[];
    /** Cache configurations */
    cache?: AzionCache[];
    /** Functions configurations */
    functions?: AzionFunction[];
    /** Rules configuration */
    rules?: AzionRules;
    /** Purge configurations */
    purge?: AzionPurge[];
    /** Firewall configuration */
    firewall?: AzionFirewall;
    /** Network list configurations */
    networkList?: AzionNetworkList[];
    /** WAF configuration */
    waf?: AzionWaf[];
};
/**
 * Firewall behavior configuration for Azion.
 */
type AzionFirewallBehavior = {
    /** Run a serverless function */
    runFunction?: string;
    /** Set WAF ruleset */
    setWafRuleset?: {
        /** WAF mode */
        wafMode: FirewallWafMode;
        /** WAF ID */
        wafId: string;
    };
    /** Set rate limit */
    setRateLimit?: {
        /** Rate limit type */
        type: FirewallRateLimitType;
        /** Rate limit by */
        limitBy: FirewallRateLimitBy;
        /** Average rate limit */
        averageRateLimit: string;
        /** Maximum burst size */
        maximumBurstSize: string;
    };
    /** Deny the request */
    deny?: boolean;
    /** Drop the request */
    drop?: boolean;
    /** Set custom response */
    setCustomResponse?: {
        /** HTTP status code (200-499) */
        statusCode: number | string;
        /** Response content type */
        contentType: string;
        /** Response content body */
        contentBody: string;
    };
};
type AzionFirewallCriteriaBase = {
    /** Variable to be evaluated */
    variable: RuleVariable;
    /** Conditional type */
    conditional: RuleConditional;
};
type AzionFirewallCriteriaWithValue = AzionFirewallCriteriaBase & {
    /** Operator for comparison that requires input value */
    operator: RuleOperatorWithValue;
    /** Input value for comparison */
    inputValue: string;
};
type AzionFirewallCriteriaWithoutValue = AzionFirewallCriteriaBase & {
    /** Operator for comparison that doesn't require input value */
    operator: RuleOperatorWithoutValue;
};
type AzionFirewallCriteria = AzionFirewallCriteriaWithValue | AzionFirewallCriteriaWithoutValue;
/**
 * Firewall rule configuration for Azion.
 */
type AzionFirewallRule = {
    /** Rule name */
    name: string;
    /** Rule description */
    description?: string;
    /** Indicates if the rule is active */
    active?: boolean;
    /** Match criteria for the rule */
    match?: string;
    /** Variable to be used in the match */
    variable?: RuleVariable;
    /** Array of criteria for complex conditions */
    criteria?: AzionFirewallCriteria[];
    /** Behavior to be applied when the rule matches */
    behavior: AzionFirewallBehavior;
};
/**
 * Firewall configuration for Azion.
 */
type AzionFirewall = {
    /** Firewall name */
    name: string;
    /** List of domains */
    domains?: string[];
    /** Indicates if the firewall is active */
    active?: boolean;
    /** Indicates if Edge Functions are enabled */
    edgeFunctions?: boolean;
    /** Indicates if Network Protection is enabled */
    networkProtection?: boolean;
    /** Indicates if WAF is enabled */
    waf?: boolean;
    /** Variable to be used in the match */
    variable?: RuleVariable;
    /** List of firewall rules */
    rules?: AzionFirewallRule[];
    /** Debug mode */
    debugRules?: boolean;
};
type AzionWaf = {
    /** WAF ID */
    id?: number;
    /** WAF name */
    name: string;
    /** WAF mode */
    mode: WafMode;
    /** WAF active */
    active: boolean;
    /** WAF sqlInjection */
    sqlInjection?: {
        sensitivity: WafSensitivity;
    };
    /** WAF remoteFileInclusion */
    remoteFileInclusion?: {
        sensitivity: WafSensitivity;
    };
    /** WAF directoryTraversal */
    directoryTraversal?: {
        sensitivity: WafSensitivity;
    };
    /** WAF crossSiteScripting */
    crossSiteScripting?: {
        sensitivity: WafSensitivity;
    };
    /** WAF evadingTricks */
    evadingTricks?: {
        sensitivity: WafSensitivity;
    };
    /** WAF fileUpload */
    fileUpload?: {
        sensitivity: WafSensitivity;
    };
    /** WAF unwantedAccess */
    unwantedAccess?: {
        sensitivity: WafSensitivity;
    };
    /** WAF identifiedAttack */
    identifiedAttack?: {
        sensitivity: WafSensitivity;
    };
    /** WAF bypassAddress */
    bypassAddresses?: string[];
};
type BuildConfiguration = Omit<AzionBuild<Configuration | BuildOptions>, 'preset' | 'entry'> & {
    entry: Record<string, string>;
    baseOutputDir?: string;
    preset: AzionBuildPreset;
    setup: BundlerSetup;
};
interface BundlerSetup {
    contentToInject?: string;
    defineVars?: Record<string, string>;
}
interface BuildContext {
    production: boolean;
    handler: BuildEntryPoint;
    skipFrameworkBuild?: boolean;
}
type PresetMetadata = {
    name: string;
    registry?: string;
    ext?: string;
};
interface AzionBuildPreset {
    config: AzionConfig;
    handler?: (event: FetchEvent) => Promise<Response>;
    prebuild?: (config: BuildConfiguration, ctx: BuildContext) => Promise<void | AzionPrebuildResult>;
    postbuild?: (config: BuildConfiguration, ctx: BuildContext) => Promise<void>;
    metadata: PresetMetadata;
}
interface AzionPrebuildResult {
    /** Files to be injected into memory during build process */
    filesToInject: string[];
    injection: {
        globals: {
            _ENTRIES?: string;
            AsyncLocalStorage?: string;
            [key: string]: string | undefined;
        };
        entry?: string;
        banner?: string;
    };
    bundler: {
        defineVars: {
            __CONFIG__?: string;
            __BUILD_METADATA__?: string;
            [key: string]: string | undefined;
        };
        plugins: (Plugin$1 | WebpackPluginInstance)[];
    };
}

interface WebpackPluginClasses {
    NodePolyfillsPlugin: new (isProduction: boolean) => WebpackPluginInstance;
    AzionPolyfillsPlugin: new (isProduction: boolean) => WebpackPluginInstance;
    BabelCustomLoaderPlugin: new (preset?: string, presetsAllowed?: string[]) => WebpackPluginInstance | undefined;
}
interface ESBuildPluginClasses {
    NodePolyfillsPlugin: (isProduction: boolean) => Plugin$1;
    AzionPolyfillsPlugin: (isProduction: boolean) => Plugin$1;
}
interface WebpackConfiguration extends Configuration {
    plugins?: WebpackPluginInstance[];
    banner?: {
        js?: string;
    };
    define?: Record<string, string>;
}
type ESBuildConfiguration = {
    plugins?: Plugin$1[];
    define?: Record<string, string>;
} & BuildOptions & {
    banner?: {
        js?: string;
    };
};
type BundlerProviderConfig = WebpackConfiguration | ESBuildConfiguration;
interface BundlerPluginFunctions<C extends BundlerProviderConfig> {
    applyPolyfills: (ctx: BuildContext) => (config: C) => (buildConfiguration: BuildConfiguration) => C;
    applyAzionModule: (ctx: BuildContext) => (config: C) => C;
}
interface Plugin {
    (config: Record<string, unknown>): Record<string, unknown>;
}

interface ESBuildBundler {
    baseConfig: ESBuildConfiguration;
    mergeConfig: (config: ESBuildConfiguration) => ESBuildConfiguration;
    applyConfig: (config: ESBuildConfiguration) => ESBuildConfiguration;
    executeBuild: (config: ESBuildBundler) => Promise<void>;
}
/**
 * Creates ESBuild bundler instance
 */
declare const createAzionESBuildConfig: (buildConfig: BuildConfiguration, ctx: BuildContext) => ESBuildBundler;
/**
 * Executes the esbuild build process
 */
declare const executeESBuildBuild: (bundler: ESBuildBundler) => Promise<void>;

interface WebpackBundler {
    baseConfig: WebpackConfiguration;
    mergeConfig: (config: WebpackConfiguration) => WebpackConfiguration;
    applyConfig: (config: WebpackConfiguration) => WebpackConfiguration;
    executeBuild: (config: WebpackBundler) => Promise<void>;
}
/**
 * Creates Webpack bundler instance
 */
declare const createAzionWebpackConfig: (buildConfig: BuildConfiguration, ctx: BuildContext) => WebpackBundler;
/**
 * Executes the webpack build process
 */
declare const executeWebpackBuild: (bundler: WebpackBundler) => Promise<void>;

export { type BundlerPluginFunctions, type BundlerProviderConfig, type ESBuildConfiguration, type ESBuildPluginClasses, type Plugin, type WebpackConfiguration, type WebpackPluginClasses, createAzionESBuildConfig, createAzionWebpackConfig, executeESBuildBuild, executeWebpackBuild };
