import { Page as Page$2 } from 'playwright';
import * as _midscene_spp_core from '@midscene_spp/core';
import { BaseElement, Rect, UIContext, PlaywrightParserOpt, PlanningLocateParam, ElementTreeNode, Size, Point, PageType } from '@midscene_spp/core';
import { ElementInfo, ElementNode } from '@midscene_spp/shared/extractor';
import { Page as Page$1, KeyInput } from 'puppeteer';
import { DebugFunction } from '@midscene_spp/shared/logger';
import { NodeType } from '@midscene_spp/shared/constants';

declare class WebElementInfo implements BaseElement {
    content: string;
    locator?: string;
    rect: Rect;
    center: [number, number];
    id: string;
    indexId: number;
    attributes: {
        nodeType: NodeType;
        [key: string]: string;
    };
    xpaths?: string[];
    constructor({ content, rect, locator, id, attributes, indexId, xpaths, }: {
        content: string;
        rect: Rect;
        locator?: string;
        id: string;
        attributes: {
            nodeType: NodeType;
            [key: string]: string;
        };
        indexId: number;
        xpaths?: string[];
    });
}

type WebUIContext = UIContext<WebElementInfo> & {
    url: string;
};
declare function parseContextFromWebPage(page: WebPage$1, _opt?: PlaywrightParserOpt): Promise<WebUIContext>;
declare function reportFileName(tag?: string): string;
declare function printReportMsg(filepath: string): void;
/**
 * Get the current execution file name
 * @returns The name of the current execution file
 */
declare function getCurrentExecutionFile(trace?: string): string | false;
declare function generateCacheId(fileName?: string): string;
declare const ERROR_CODE_NOT_IMPLEMENTED_AS_DESIGNED = "NOT_IMPLEMENTED_AS_DESIGNED";
declare function replaceIllegalPathCharsAndSpace(str: string): string;
declare function forceClosePopup(page: Page$1 | Page$2, debug: DebugFunction): void;
declare function matchElementFromPlan(planLocateParam: PlanningLocateParam, tree: ElementTreeNode<BaseElement>): any;

type MouseButton = 'left' | 'right' | 'middle';
interface MouseAction {
    click: (x: number, y: number, options: {
        button: MouseButton;
    }) => Promise<void>;
    wheel: (deltaX: number, deltaY: number) => Promise<void>;
    move: (x: number, y: number) => Promise<void>;
    drag: (from: {
        x: number;
        y: number;
    }, to: {
        x: number;
        y: number;
    }) => Promise<void>;
}
interface KeyboardAction {
    type: (text: string) => Promise<void>;
    press: (action: {
        key: WebKeyInput;
        command?: string;
    } | {
        key: WebKeyInput;
        command?: string;
    }[]) => Promise<void>;
}
interface ChromePageDestroyOptions {
    closeTab?: boolean;
}
declare abstract class AbstractPage {
    abstract pageType: string;
    abstract getElementsInfo(): Promise<ElementInfo[]>;
    abstract getElementsNodeTree(): Promise<ElementNode>;
    abstract url(): string | Promise<string>;
    abstract screenshotBase64?(): Promise<string>;
    abstract size(): Promise<Size>;
    get mouse(): MouseAction;
    get keyboard(): KeyboardAction;
    clearInput(element: ElementInfo): Promise<void>;
    abstract scrollUntilTop(startingPoint?: Point): Promise<void>;
    abstract scrollUntilBottom(startingPoint?: Point): Promise<void>;
    abstract scrollUntilLeft(startingPoint?: Point): Promise<void>;
    abstract scrollUntilRight(startingPoint?: Point): Promise<void>;
    abstract scrollUp(distance?: number, startingPoint?: Point): Promise<void>;
    abstract scrollDown(distance?: number, startingPoint?: Point): Promise<void>;
    abstract scrollLeft(distance?: number, startingPoint?: Point): Promise<void>;
    abstract scrollRight(distance?: number): Promise<void>;
    abstract _forceUsePageContext?(): Promise<WebUIContext>;
    abstract waitUntilNetworkIdle?(options?: {
        idleTime?: number;
        concurrency?: number;
    }): Promise<void>;
    abstract destroy(options?: ChromePageDestroyOptions): Promise<void>;
    abstract evaluateJavaScript?<T = any>(script: string): Promise<T>;
}

declare class ChromeExtensionProxyPage implements AbstractPage {
    pageType: string;
    forceSameTabNavigation: boolean;
    private version;
    private viewportSize?;
    private activeTabId;
    private tabIdOfDebuggerAttached;
    private attachingDebugger;
    private destroyed;
    constructor(forceSameTabNavigation: boolean);
    setActiveTabId(tabId: number): Promise<void>;
    getActiveTabId(): Promise<number | null>;
    /**
     * Get a list of current tabs
     * @returns {Promise<Array<{id: number, title: string, url: string}>>}
     */
    getBrowserTabList(): Promise<{
        id: string;
        title: string;
        url: string;
        currentActiveTab: boolean;
    }[]>;
    getTabIdOrConnectToCurrentTab(): Promise<number>;
    private attachDebugger;
    private showMousePointer;
    private hideMousePointer;
    private detachDebugger;
    private enableWaterFlowAnimation;
    private disableWaterFlowAnimation;
    private sendCommandToDebugger;
    private getPageContentByCDP;
    evaluateJavaScript(script: string): Promise<any>;
    waitUntilNetworkIdle(): Promise<void>;
    getElementsInfo(): Promise<ElementInfo[]>;
    getXpathsById(id: string): Promise<any>;
    getElementInfoByXpath(xpath: string): Promise<any>;
    getElementsNodeTree(): Promise<ElementTreeNode<ElementInfo>>;
    size(): Promise<Size>;
    screenshotBase64(): Promise<string>;
    url(): Promise<string>;
    scrollUntilTop(startingPoint?: Point): Promise<void>;
    scrollUntilBottom(startingPoint?: Point): Promise<void>;
    scrollUntilLeft(startingPoint?: Point): Promise<void>;
    scrollUntilRight(startingPoint?: Point): Promise<void>;
    scrollUp(distance?: number, startingPoint?: Point): Promise<void>;
    scrollDown(distance?: number, startingPoint?: Point): Promise<void>;
    scrollLeft(distance?: number, startingPoint?: Point): Promise<void>;
    scrollRight(distance?: number, startingPoint?: Point): Promise<void>;
    clearInput(element: ElementInfo): Promise<void>;
    private latestMouseX;
    private latestMouseY;
    mouse: {
        click: (x: number, y: number) => Promise<void>;
        wheel: (deltaX: number, deltaY: number, startX?: number, startY?: number) => Promise<void>;
        move: (x: number, y: number) => Promise<void>;
        drag: (from: {
            x: number;
            y: number;
        }, to: {
            x: number;
            y: number;
        }) => Promise<void>;
    };
    keyboard: {
        type: (text: string) => Promise<void>;
        press: (action: {
            key: WebKeyInput;
            command?: string;
        } | {
            key: WebKeyInput;
            command?: string;
        }[]) => Promise<void>;
    };
    destroy(): Promise<void>;
}

declare class StaticPage implements AbstractPage {
    pageType: string;
    private uiContext;
    constructor(uiContext: WebUIContext);
    evaluateJavaScript<T = any>(script: string): Promise<T>;
    getElementsInfo(): Promise<any>;
    getElementsNodeTree(): Promise<any>;
    getXpathsById(id: string): Promise<any>;
    getElementInfoByXpath(xpath: string): Promise<any>;
    size(): Promise<_midscene_spp_core.Size>;
    screenshotBase64(): Promise<string>;
    url(): Promise<string>;
    scrollUntilTop(startingPoint?: Point): Promise<any>;
    scrollUntilBottom(startingPoint?: Point): Promise<any>;
    scrollUntilLeft(startingPoint?: Point): Promise<any>;
    scrollUntilRight(startingPoint?: Point): Promise<any>;
    scrollUp(distance?: number, startingPoint?: Point): Promise<any>;
    scrollDown(distance?: number, startingPoint?: Point): Promise<any>;
    scrollLeft(distance?: number, startingPoint?: Point): Promise<any>;
    scrollRight(distance?: number, startingPoint?: Point): Promise<any>;
    clearInput(): Promise<any>;
    mouse: {
        click: any;
        wheel: any;
        move: any;
        drag: any;
    };
    keyboard: {
        type: any;
        press: any;
    };
    _forceUsePageContext(): Promise<WebUIContext>;
    destroy(): Promise<void>;
}

declare class Page<AgentType extends 'puppeteer' | 'playwright', PageType extends Page$1 | Page$2> implements AbstractPage {
    underlyingPage: PageType;
    protected waitForNavigationTimeout: number;
    private viewportSize?;
    pageType: AgentType;
    private evaluate;
    constructor(underlyingPage: PageType, pageType: AgentType, opts?: {
        waitForNavigationTimeout?: number;
    });
    evaluateJavaScript<T = any>(script: string): Promise<T>;
    waitForNavigation(): Promise<void>;
    getElementsInfo(): Promise<ElementInfo[]>;
    getXpathsById(id: string): Promise<any>;
    getElementInfoByXpath(xpath: string): Promise<any>;
    getElementsNodeTree(): Promise<ElementTreeNode<ElementInfo>>;
    size(): Promise<Size>;
    screenshotBase64(): Promise<string>;
    url(): Promise<string>;
    get mouse(): {
        click: (x: number, y: number, options?: {
            button?: MouseButton;
            count?: number;
        }) => Promise<void>;
        wheel: (deltaX: number, deltaY: number) => Promise<void>;
        move: (x: number, y: number) => Promise<void>;
        drag: (from: {
            x: number;
            y: number;
        }, to: {
            x: number;
            y: number;
        }) => Promise<void>;
    };
    get keyboard(): {
        type: (text: string) => Promise<void>;
        press: (action: {
            key: WebKeyInput;
            command?: string;
        } | {
            key: WebKeyInput;
            command?: string;
        }[]) => Promise<void>;
        down: (key: WebKeyInput) => Promise<void>;
        up: (key: WebKeyInput) => Promise<void>;
    };
    clearInput(element: ElementInfo): Promise<void>;
    private everMoved;
    private moveToPointBeforeScroll;
    scrollUntilTop(startingPoint?: Point): Promise<void>;
    scrollUntilBottom(startingPoint?: Point): Promise<void>;
    scrollUntilLeft(startingPoint?: Point): Promise<void>;
    scrollUntilRight(startingPoint?: Point): Promise<void>;
    scrollUp(distance?: number, startingPoint?: Point): Promise<void>;
    scrollDown(distance?: number, startingPoint?: Point): Promise<void>;
    scrollLeft(distance?: number, startingPoint?: Point): Promise<void>;
    scrollRight(distance?: number, startingPoint?: Point): Promise<void>;
    navigate(url: string): Promise<void>;
    destroy(): Promise<void>;
}

declare class WebPage$2 extends Page<'puppeteer', Page$1> {
    waitForNavigationTimeout: number;
    waitForNetworkIdleTimeout: number;
    constructor(page: Page$1, opts?: {
        waitForNavigationTimeout?: number;
        waitForNetworkIdleTimeout?: number;
    });
    waitUntilNetworkIdle(options?: {
        idleTime?: number;
        concurrency?: number;
        timeout?: number;
    }): Promise<void>;
}

interface AndroidDevicePage extends AbstractPage {
  pageType: PageType;
  connect(): Promise<any>;
  launch(uri: string): Promise<any>;

  screenshotBase64(): Promise<string>;
  getElementsNodeTree(): Promise<ElementTreeNode<ElementInfo>>;
  url(): string | Promise<string>;
  size(): Promise<Size>;

  scrollUntilTop(startingPoint?: Point): Promise<void>;
  scrollUntilBottom(startingPoint?: Point): Promise<void>;
  scrollUntilLeft(startingPoint?: Point): Promise<void>;
  scrollUntilRight(startingPoint?: Point): Promise<void>;
  scrollUp(distance?: number, startingPoint?: Point): Promise<void>;
  scrollDown(distance?: number, startingPoint?: Point): Promise<void>;
  scrollLeft(distance?: number, startingPoint?: Point): Promise<void>;
  scrollRight(distance?: number): Promise<void>;

  getXpathsById(id: string): Promise<string[]>;
  getElementInfoByXpath(xpath: string): Promise<ElementInfo>;

  back(): Promise<void>;
  home(): Promise<void>;
  recentApps(): Promise<void>;
}

type WebPage$1 =
  | WebPage
  | WebPage$2
  | StaticPage
  | ChromeExtensionProxyPage
  | AndroidDevicePage;

type WebKeyInput = KeyInput;

declare class WebPage extends Page<'playwright', Page$2> {
    constructor(page: Page$2);
}

export { type AndroidDevicePage as A, ChromeExtensionProxyPage as C, ERROR_CODE_NOT_IMPLEMENTED_AS_DESIGNED as E, StaticPage as S, type WebPage$1 as W, AbstractPage as a, WebPage$2 as b, WebPage as c, WebElementInfo as d, type WebUIContext as e, type ChromePageDestroyOptions as f, printReportMsg as g, getCurrentExecutionFile as h, generateCacheId as i, replaceIllegalPathCharsAndSpace as j, forceClosePopup as k, matchElementFromPlan as m, parseContextFromWebPage as p, reportFileName as r };
