import { IMirror } from '@posthog/rrweb-types';
import { serializedNode as serializedNode_2 } from '@posthog/rrweb-types';
import { serializedNodeWithId } from '@posthog/rrweb-types';

export declare function absolutifyURLs(cssText: string | null, href: string): string;

export declare function adaptCssForReplay(cssText: string, cache: BuildCache): string;

export declare type attributes = {
    [key: string]: string | number | true | null;
};

export declare type BuildCache = {
    stylesWithHoverClass: Map<string, string>;
};

export declare function buildNodeWithSN(n: serializedNodeWithId, options: {
    doc: Document;
    mirror: Mirror;
    skipChild?: boolean;
    hackCss: boolean;
    afterAppend?: (n: Node, id: number) => unknown;
    cache: BuildCache;
}): Node | null;

export declare type cdataNode = {
    type: NodeType.CDATA;
    textContent: '';
};

export declare function checkDataURLSize(dataURL: string, maxLength: number | undefined): string;

export declare type commentNode = {
    type: NodeType.Comment;
    textContent: string;
};

export declare function createCache(): BuildCache;

export declare function createMirror(): Mirror;

declare interface CSSImportRule_2 extends CSSRule {
    readonly href: string;
    readonly layerName: string | null;
    readonly media: MediaList;
    readonly styleSheet: CSSStyleSheet;
    readonly supportsText?: string | null;
}

export declare type DialogAttributes = {
    open: string;
    rr_open_mode: 'modal' | 'non-modal';
};

export declare type documentNode = {
    type: NodeType.Document;
    childNodes: serializedNodeWithId[];
    compatMode?: string;
};

export declare type documentTypeNode = {
    type: NodeType.DocumentType;
    name: string;
    publicId: string;
    systemId: string;
};

export declare type elementNode = {
    type: NodeType.Element;
    tagName: string;
    attributes: attributes;
    childNodes: serializedNodeWithId[];
    isSVG?: true;
    needBlock?: boolean;
    isCustom?: true;
};

export declare function escapeImportStatement(rule: CSSImportRule_2): string;

export declare function extractFileExtension(path: string, baseURL?: string): string | null;

export declare function fixSafariColons(cssStringified: string): string;

export declare function getInputType(element: HTMLElement): Lowercase<string> | null;

export declare interface ICanvas extends HTMLCanvasElement {
    __context: string;
}

export declare type idNodeMap = Map<number, Node>;

export declare function is2DCanvasBlank(canvas: HTMLCanvasElement): boolean;

export declare function isCSSImportRule(rule: CSSRule): rule is CSSImportRule_2;

export declare function isCSSStyleRule(rule: CSSRule): rule is CSSStyleRule;

export declare function isElement(n: Node): n is Element;

export declare function isNativeShadowDom(shadowRoot: ShadowRoot): boolean;

export declare function isNodeMetaEqual(a: serializedNode_2, b: serializedNode_2): boolean;

export declare function isShadowRoot(n: Node): n is ShadowRoot;

export declare type KeepIframeSrcFn = (src: string) => boolean;

export declare type legacyAttributes = {
    selected: false;
};

export declare type MaskInputFn = (text: string, element: HTMLElement) => string;

export declare type MaskInputOptions = Partial<{
    color: boolean;
    date: boolean;
    'datetime-local': boolean;
    email: boolean;
    month: boolean;
    number: boolean;
    range: boolean;
    search: boolean;
    tel: boolean;
    text: boolean;
    time: boolean;
    url: boolean;
    week: boolean;
    textarea: boolean;
    select: boolean;
    password: boolean;
}>;

export declare function maskInputValue({ element, maskInputOptions, tagName, type, value, maskInputFn, }: {
    element: HTMLElement;
    maskInputOptions: MaskInputOptions;
    tagName: string;
    type: string | null;
    value: string | null;
    maskInputFn?: MaskInputFn;
}): string;

export declare type MaskTextFn = (text: string, element: HTMLElement | null) => string;

export declare class Mirror implements IMirror<Node> {
    private idNodeMap;
    private nodeMetaMap;
    getId(n: Node | undefined | null): number;
    getNode(id: number): Node | null;
    getIds(): number[];
    getMeta(n: Node): serializedNodeWithId | null;
    removeNodeFromMap(n: Node): void;
    has(id: number): boolean;
    hasNode(node: Node): boolean;
    add(n: Node, meta: serializedNodeWithId): void;
    replace(id: number, n: Node): void;
    reset(): void;
}

export declare type nodeMetaMap = WeakMap<Node, serializedNodeWithId>;

export declare enum NodeType {
    Document = 0,
    DocumentType = 1,
    Element = 2,
    Text = 3,
    CDATA = 4,
    Comment = 5
}

export declare function rebuild(n: serializedNodeWithId, options: {
    doc: Document;
    onVisit?: (node: Node) => unknown;
    hackCss?: boolean;
    afterAppend?: (n: Node, id: number) => unknown;
    cache: BuildCache;
    mirror: Mirror;
}): Node | null;

export declare function recompressBase64Image(img: HTMLImageElement, dataURL: string, type?: string, quality?: number): string;

export declare type serializedElementNodeWithId = Extract<serializedNodeWithId, Record<'type', NodeType.Element>>;

export declare type serializedNode = (documentNode | documentTypeNode | elementNode | textNode | cdataNode | commentNode) & {
    rootId?: number;
    isShadowHost?: boolean;
    isShadow?: boolean;
};

export declare type SlimDOMOptions = Partial<{
    script: boolean;
    comment: boolean;
    headFavicon: boolean;
    headWhitespace: boolean;
    headMetaDescKeywords: boolean;
    headMetaSocial: boolean;
    headMetaRobots: boolean;
    headMetaHttpEquiv: boolean;
    headMetaAuthorship: boolean;
    headMetaVerification: boolean;
    headTitleMutations: boolean;
}>;

export declare function stringifyRule(rule: CSSRule, sheetHref: string | null): string;

export declare function stringifyStylesheet(s: CSSStyleSheet): string | null;

export declare type tagMap = {
    [key: string]: string;
};

export declare type textNode = {
    type: NodeType.Text;
    textContent: string;
    isStyle?: true;
};

export declare function toLowerCase<T extends string>(str: T): Lowercase<T>;

export { }
