declare module '@point-of-sale/receipt-printer-encoder' {
    export default class ReceiptPrinterEncoder {
        constructor(options?: Record<string, unknown>);

        initialize(): this;
        align(alignment: 'left' | 'center' | 'right'): this;
        bold(value?: boolean): this;
        line(text: string): this;
        text(text: string): this;
        newline(count?: number): this;
        rule(options?: { style?: string; width?: number }): this;
        table(
            columns: Array<Record<string, unknown>>,
            rows: Array<Array<string | ((encoder: ReceiptPrinterEncoder) => ReceiptPrinterEncoder)>>,
        ): this;
        cut(): this;
        encode(): Uint8Array;
    }
}

declare module '@point-of-sale/webserial-receipt-printer' {
    export type SerialPrinterDevice = {
        type: 'serial';
        vendorId: number | null;
        productId: number | null;
        language: string | null;
        codepageMapping: string | null;
    };

    export default class WebSerialReceiptPrinter {
        constructor(options?: Record<string, unknown>);

        connect(): Promise<void>;
        reconnect(device: { vendorId?: number | null; productId?: number | null }): Promise<void>;
        print(data: Uint8Array | number[]): Promise<void>;
        addEventListener(
            event: 'connected' | 'disconnected' | 'data',
            callback: (device?: SerialPrinterDevice) => void,
        ): void;
    }
}

declare module '@point-of-sale/webbluetooth-receipt-printer' {
    export type BluetoothPrinterDevice = {
        type: 'bluetooth';
        name: string;
        id: string;
        language: 'esc-pos' | 'star-prnt';
        codepageMapping: string;
    };

    export default class WebBluetoothReceiptPrinter {
        connect(): Promise<void>;
        reconnect(device: { id: string }): Promise<void>;
        print(data: Uint8Array | number[]): Promise<void>;
        addEventListener(
            event: 'connected' | 'disconnected',
            callback: (device?: BluetoothPrinterDevice) => void,
        ): void;
    }
}
