import { CosmeticRule } from '@adguard/agtree';

/**
 * Domain configuration for a script rule.
 */
type DomainConfig = {
    /**
     * List of domains where the script should be applied.
     */
    permittedDomains: string[];
    /**
     * List of domains where the script should NOT be applied.
     */
    restrictedDomains: string[];
};
/**
 * Handles local script rules in JSON format with domain configurations.
 *
 * This format is used for Manifest V2 extensions. If not provided, all
 * script rules are allowed.
 * Should be provided in Firefox AMO according to their policies.
 *
 * The primary purpose is to enable runtime checking of JS rules to determine
 * whether a rule comes from built-in filters or is a custom rule.
 */
declare class LocalScriptRulesJson {
    /**
     * Filename for the local script rules JSON file.
     */
    static readonly FILENAME = "local_script_rules.json";
    /**
     * Default comment for the JSON file explaining the AMO compliance approach.
     */
    private static readonly DEFAULT_COMMENT;
    /**
     * Extracts domain configuration from a cosmetic rule node.
     *
     * @param ruleNode Cosmetic rule node with domains.
     *
     * @returns Domain configuration with permitted and restricted domains.
     */
    static extractDomainConfig(ruleNode: CosmeticRule): DomainConfig;
    /**
     * Checks if a domain config is a duplicate using deep comparison.
     *
     * @param config Config to check.
     * @param existingConfigs Array of existing configs.
     *
     * @returns True if config already exists.
     */
    static isDuplicateConfig(config: DomainConfig, existingConfigs: DomainConfig[]): boolean;
    /**
     * Parses filter rules and extracts JS injection rules with domain information.
     *
     * @param filterRules Array of filter rule strings.
     *
     * @returns Map of script bodies to their domain configurations.
     */
    static parse(filterRules: string[]): Map<string, DomainConfig[]>;
    /**
     * Serializes rules map into a formatted JSON string.
     *
     * @param rules Map of script bodies to their domain configurations.
     *
     * @returns Serialized JSON string.
     */
    static serialize(rules: Map<string, DomainConfig[]>): string;
    /**
     * Deserializes local script rules from JSON content.
     *
     * @param content JSON content string.
     *
     * @returns Map of script bodies to their domain configurations.
     */
    static deserialize(content: string): Map<string, DomainConfig[]>;
    /**
     * Extends existing rules with new rules, merging domain configurations.
     *
     * @param existing Map of existing script bodies to their domain configurations.
     * @param newRules Map of new script bodies to their domain configurations.
     *
     * @returns Merged map of all rules with combined domain configurations.
     */
    static extend(existing: Map<string, DomainConfig[]>, newRules: Map<string, DomainConfig[]>): Map<string, DomainConfig[]>;
}

export { LocalScriptRulesJson };
export type { DomainConfig };
