/*
THIS INFRAGISTICS ULTIMATE SOFTWARE LICENSE  AGREEMENT ("AGREEMENT") LOCATED HERE:
https://www.infragistics.com/legal/license/igultimate-la
https://www.infragistics.com/legal/license/igultimate-eula
GOVERNS THE LICENSING, INSTALLATION AND USE OF INFRAGISTICS SOFTWARE. BY DOWNLOADING AND/OR INSTALLING AND USING INFRAGISTICS SOFTWARE:  you are indicating that you have read and understand this Agreement, and agree to be legally bound by it on behalf of the yourself and your company.
*/
import { CodePageEncoding } from "./CodePageEncoding";
import { String_$type, Number_$type, markType } from "igniteui-angular-core";
import { Dictionary$2 } from "igniteui-angular-core";
import { ArgumentNullException } from "igniteui-angular-core";
import { ArgumentOutOfRangeException } from "igniteui-angular-core";
import { StringBuilder } from "igniteui-angular-core";
import { nullableNotEquals, unwrapNullable } from "igniteui-angular-core";
/**
 * @hidden
 */
export class CodePageSingleByte extends CodePageEncoding {
    constructor(a, b) {
        super();
        this._ae = null;
        this._af = null;
        this._ag = 0;
        this._ag = a;
        this._ae = b;
        if (b == null) {
            return;
        }
        if (this._af != null) {
            return;
        }
        this._af = new Dictionary$2(String_$type, Number_$type, 0);
        for (let c = 0; c < b.length; c++) {
            let d = b[c];
            if (nullableNotEquals(d, null)) {
                this._af.addItem(d.value, c);
            }
        }
    }
    get__codePage() {
        return this._ag;
    }
    get _codePage() {
        return this.get__codePage();
    }
    getChars(a, b, c, d, e) {
        if ((a == null) || (d == null)) {
            throw new ArgumentNullException(0, (a == null) ? "bytes are Null" : "chars are Null");
        }
        if ((b < 0) || (c < 0)) {
            throw new ArgumentOutOfRangeException(1, (b < 0) ? "byteIndex is out of Range" : "byteCount is out of Range");
        }
        if ((a.length - b) < c) {
            throw new ArgumentOutOfRangeException(1, "bytes");
        }
        if ((e < 0) || (e > d.length)) {
            throw new ArgumentOutOfRangeException(1, "charIndex");
        }
        if (a.length == 0) {
            return 0;
        }
        if (d.length == 0) {
            return 0;
        }
        let f = this._ae;
        let g = this._af;
        let h = 0;
        let i = 0;
        for (let j = b; j < b + c; j++) {
            let k = f[a[j]];
            if (nullableNotEquals(k, null)) {
                if (g.containsKey(k.value)) {
                    if (e <= k.value.charCodeAt(0)) {
                        if (i < d.length) {
                            d[i] = k.value;
                            i++;
                        }
                        h++;
                    }
                }
            }
        }
        return h;
    }
    getMaxByteCount(a) {
        return a;
    }
    getMaxCharCount(a) {
        return a;
    }
    getByteCount(a, b, c) {
        return c;
    }
    getBytes2(a, b, c, d, e) {
        let f = this._af;
        for (let g = b; g < b + c; g++) {
            let h;
            if (((() => { let i = f.tryGetValue(a[g], h); h = i.p1; return i.ret; })()) == false && ((() => { let i = f.tryGetValue('?', h); h = i.p1; return i.ret; })()) == false) {
                continue;
            }
            d[e + g - b] = h;
        }
        return c;
    }
    getCharCount1(a, b, c) {
        return c;
    }
    getString1(a, b, c) {
        let d = this._ae;
        let e = new StringBuilder(0);
        for (let f = b; f < b + c; f++) {
            e.k(unwrapNullable(d[a[f]]));
        }
        return e.toString();
    }
}
CodePageSingleByte.$t = markType(CodePageSingleByte, 'CodePageSingleByte', CodePageEncoding.$);
//# sourceMappingURL=CodePageSingleByte.js.map