window.onssage = function (a){
    console.log(a)
        console.log(JSON.stringify(a))
    }
if (typeof window.OffscreenCanvas !== 'function') {
    window.onssage(false);
}
getWebGL = function (c) {
    let graphicsLib = null;
    try {
        graphicsLib = c.getContext('webgl') || c.getContext('experimental-webgl');
    } catch (ignored) {
    }
    return graphicsLib;
}
let canvas = new window.OffscreenCanvas(0, 0);
let gl = getWebGL(canvas);
if (!gl) {
    window.onssage(false);
}
onmessage = function (e) {
    let segment = e.data.segment;
    try {
        if (segment === 'a' || segment === 'b') {
            let _e$data = e.data, parameters = _e$data.parameters, methods = _e$data.methods;
            let result = [];
            for (let i = 0; i < parameters.length; i++) {
                result.push(gl[methods[0]](parameters[i]));
            }
            return {segment: segment, result: result};
        } else if (segment === 'c' || segment === 'd') {
            let _e$data2 = e.data, _parameters = _e$data2.parameters, extensions = _e$data2.extensions,
                _methods = _e$data2.methods;
            let _result = [];
            let ext = false;
            for (let _i = 0; _i < extensions.length; _i++) {
                ext = ext || gl[_methods[0]](extensions[_i]);
            }
            if (ext) {
                for (let _i2 = 0; _i2 < _parameters.length; _i2++) {
                    _result.push(gl[_methods[1]](ext[_parameters[_i2]]));
                }
            } else {
                _result = -1;
            }
            return {segment: segment, result: _result};
        } else if (segment === 'e') {
            let _e$data3 = e.data, _methods2 = _e$data3.methods, properties = _e$data3.properties;
            let _result2 = function (x) {
                return x ? x[properties[0]] : false;
            }(gl[_methods2[0]]());
            return {segment: segment, result: _result2};
        } else if (segment === 'f') {
            let _e$data4 = e.data, _methods3 = _e$data4.methods, shaderParams = _e$data4.shaderParams,
                shaderFloatPrecision = _e$data4.shaderFloatPrecision, shaderIntPrecision = _e$data4.shaderIntPrecision,
                shaderProperties = _e$data4.shaderProperties;
            let _result3 = [];
            if (typeof gl[_methods3[0]] === 'function') {
                for (let _i3 = 0; _i3 < shaderParams.length; _i3++) {
                    for (let j = 0; j < shaderFloatPrecision.length; j++) {
                        let x = gl[_methods3[0]](shaderParams[_i3], shaderFloatPrecision[j]);
                        x = x == null ? '' : [x[shaderProperties[0]], x[shaderProperties[1]], x[shaderProperties[2]]].join('');
                        _result3.push(x);
                    }
                }
                for (let _i4 = 0; _i4 < shaderParams.length; _i4++) {
                    for (let _j = 0; _j < shaderIntPrecision.length; _j++) {
                        let _x = gl[_methods3[0]](shaderParams[_i4], shaderIntPrecision[_j]);
                        _x = _x == null ? '' : [_x[shaderProperties[0]], _x[shaderProperties[1]], _x[shaderProperties[2]]].join('');
                        _result3.push(_x);
                    }
                }
            } else {
                _result3 = void 0;
            }
            return {segment: segment, result: _result3};
        } else if (segment === 'g') {
            let _methods4 = e.data.methods;
            let _result4 = gl[_methods4[0]]() || [];
            return {segment: segment, result: _result4};
        } else if (segment === 'h') {
            let _result5 = [];
            for (let prop in gl) {
                _result5.push(prop);
            }
            return {segment: segment, result: _result5};
        }
    } catch (error) {
        return false;
    }
};
let gl1 = onmessage({
    data:{
    "segment": "a",
    "parameters": [
        33902,
        33901,
        3386
    ],
    "methods": [
        "getParameter"
    ]
}
})

let gl2 = onmessage({data:{
    "segment": "b",
    "parameters": [
        3413,
        3412,
        3411,
        3410,
        3414,
        35661,
        34076,
        36349,
        34024,
        34930,
        3379,
        36348,
        34921,
        35660,
        36347,
        7937,
        35724,
        3415,
        7936,
        7938
    ],
    "methods": [
        "getParameter"
    ]
}})

let gl3 = onmessage({data:{
    "segment": "c",
    "parameters": [
        "UNMASKED_VENDOR_WEBGL",
        "UNMASKED_RENDERER_WEBGL"
    ],
    "extensions": [
        "WEBGL_debug_renderer_info"
    ],
    "methods": [
        "getExtension",
        "getParameter"
    ]
}})

let gl4 = onmessage({data:{
    "segment": "d",
    "parameters": [
        "MAX_TEXTURE_MAX_ANISOTROPY_EXT"
    ],
    "extensions": [
        "EXT_texture_filter_anisotropic",
        "WEBKIT_EXT_texture_filter_anisotropic",
        "MOZ_EXT_texture_filter_anisotropic"
    ],
    "methods": [
        "getExtension",
        "getParameter"
    ]
}})

let gl5 = onmessage({data:{
    "segment": "e",
    "methods": [
        "getContextAttributes"
    ],
    "properties": [
        "antialias"
    ]
}})
let gl6 = onmessage({data:{
    "segment": "f",
    "methods": [
        "getShaderPrecisionFormat"
    ],
    "shaderParams": [
        35633,
        35632
    ],
    "shaderFloatPrecision": [
        36338,
        36337,
        36336
    ],
    "shaderIntPrecision": [
        36341,
        36340,
        36339
    ],
    "shaderProperties": [
        "precision",
        "rangeMin",
        "rangeMax"
    ]
}})

let gl7 = onmessage({data:{
    "segment": "g",
    "methods": [
        "getSupportedExtensions"
    ]
}})
let gl8 = onmessage({data:{
    "segment": "h"
}})

let glRes = [gl1,gl2,gl3,gl4,gl5,gl6,gl7,gl8]