Houjie
2025-04-11 1bf977929dd324f3ac64b70debd8a79443c54392
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import { Html5QrcodeScanType, Html5QrcodeConstants } from "../../core";
var ScanTypeSelector = (function () {
    function ScanTypeSelector(supportedScanTypes) {
        this.supportedScanTypes = this.validateAndReturnScanTypes(supportedScanTypes);
    }
    ScanTypeSelector.prototype.getDefaultScanType = function () {
        return this.supportedScanTypes[0];
    };
    ScanTypeSelector.prototype.hasMoreThanOneScanType = function () {
        return this.supportedScanTypes.length > 1;
    };
    ScanTypeSelector.prototype.isCameraScanRequired = function () {
        for (var _i = 0, _a = this.supportedScanTypes; _i < _a.length; _i++) {
            var scanType = _a[_i];
            if (ScanTypeSelector.isCameraScanType(scanType)) {
                return true;
            }
        }
        return false;
    };
    ScanTypeSelector.isCameraScanType = function (scanType) {
        return scanType === Html5QrcodeScanType.SCAN_TYPE_CAMERA;
    };
    ScanTypeSelector.isFileScanType = function (scanType) {
        return scanType === Html5QrcodeScanType.SCAN_TYPE_FILE;
    };
    ScanTypeSelector.prototype.validateAndReturnScanTypes = function (supportedScanTypes) {
        if (!supportedScanTypes || supportedScanTypes.length === 0) {
            return Html5QrcodeConstants.DEFAULT_SUPPORTED_SCAN_TYPE;
        }
        var maxExpectedValues = Html5QrcodeConstants.DEFAULT_SUPPORTED_SCAN_TYPE.length;
        if (supportedScanTypes.length > maxExpectedValues) {
            throw "Max ".concat(maxExpectedValues, " values expected for ")
                + "supportedScanTypes";
        }
        for (var _i = 0, supportedScanTypes_1 = supportedScanTypes; _i < supportedScanTypes_1.length; _i++) {
            var scanType = supportedScanTypes_1[_i];
            if (!Html5QrcodeConstants.DEFAULT_SUPPORTED_SCAN_TYPE
                .includes(scanType)) {
                throw "Unsupported scan type ".concat(scanType);
            }
        }
        return supportedScanTypes;
    };
    return ScanTypeSelector;
}());
export { ScanTypeSelector };
//# sourceMappingURL=scan-type-selector.js.map