"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.webText = webText;
const measureText_1 = require("../../../util/web/measureText");
function webText(window, opt) {
    const { document } = window;
    const canvas = document.createElement('canvas');
    let ctx = null;
    try {
        ctx = canvas.getContext('2d');
        if (ctx) {
            ctx.textAlign = 'center';
        }
    }
    catch (err) {
        //
    }
    const text = {
        measureText: (text, fontSize, maxWidth) => {
            if (!ctx) {
                throw new Error('canvas context not available');
            }
            return (0, measureText_1.measureText)(ctx, text, fontSize, maxWidth);
        },
        // @ts-ignore
        TextEncoder: window.TextEncoder,
        // @ts-ignore
        TextDecoder: window.TextDecoder,
    };
    return text;
}
//# sourceMappingURL=text.js.map