import QRCode from 'qrcode';
import { GenerateQrCodeModel } from '../../../../code/type';
import mimeType from 'mime-types';
export async function generateQrCode(source) {
    const input = GenerateQrCodeModel.parse(source);
    const opts = {};
    if (input.errorCorrectionLevel) {
        opts.errorCorrectionLevel = input.errorCorrectionLevel;
    }
    if (input.format) {
        opts.type = mimeType.lookup(`.${input.format}`);
    }
    if (input.margin) {
        opts.margin = input.margin;
    }
    if (input.color) {
        opts.color = input.color;
    }
    return await QRCode.toDataURL('text', opts);
}
//# sourceMappingURL=shared.js.map