/*
 * SDK Pullenti Unitext, version 4.33, fabruary 2026. Copyright (c) 2013-2026, Pullenti. All rights reserved. 
 * Non-Commercial Freeware and Commercial Software. 
 * This class is generated using the converter UniSharping (www.unisharping.ru) from Pullenti C# project. 
 * The latest version of the code is available on the site www.pullenti.ru
 */


const UniTextGenNumType = require("./UniTextGenNumType");
const UnitextHelper = require("./UnitextHelper");

// Уровень стиля нумерации
class UniTextGenNumLevel {
    
    constructor() {
        this.type = UniTextGenNumType.BULLET;
        this.format = null;
        this.start = 1;
        this.current = 0;
        this.style = null;
    }
    
    clone() {
        let res = new UniTextGenNumLevel();
        res.type = this.type;
        res.format = this.format;
        res.start = this.start;
        res.current = this.current;
        if (this.style !== null) 
            res.style = this.style.clone(false);
        return res;
    }
    
    toString() {
        return (String(this.type) + " '" + this.format + "' from " + this.start);
    }
    
    getValue(cur) {
        if (this.type === UniTextGenNumType.BULLET) 
            return this.format;
        if (this.type === UniTextGenNumType.DECIMAL) 
            return cur.toString();
        if (this.type === UniTextGenNumType.LOWERLETTER) 
            return ((String.fromCharCode(((('a'.charCodeAt(0)) + cur) - 1))));
        if (this.type === UniTextGenNumType.LOWERCYRLETTER) {
            if (cur >= 10) 
                cur++;
            return ((String.fromCharCode(((('а'.charCodeAt(0)) + cur) - 1))));
        }
        if (this.type === UniTextGenNumType.UPPERCYRLETTER) {
            if (cur >= 10) 
                cur++;
            return ((String.fromCharCode(((('А'.charCodeAt(0)) + cur) - 1))));
        }
        if (this.type === UniTextGenNumType.UPPERLETTER) 
            return ((String.fromCharCode(((('A'.charCodeAt(0)) + cur) - 1))));
        if (this.type === UniTextGenNumType.LOWERROMAN) {
            if (cur > 0 && ((cur - 1) < UnitextHelper.m_Romans.length)) 
                return UnitextHelper.m_Romans[cur - 1].toLowerCase();
        }
        if (this.type === UniTextGenNumType.UPPERROMAN) {
            if (cur > 0 && ((cur - 1) < UnitextHelper.m_Romans.length)) 
                return UnitextHelper.m_Romans[cur - 1];
        }
        return cur.toString();
    }
    
    static _new114(_arg1) {
        let res = new UniTextGenNumLevel();
        res.type = _arg1;
        return res;
    }
    
    static _new132(_arg1, _arg2) {
        let res = new UniTextGenNumLevel();
        res.type = _arg1;
        res.format = _arg2;
        return res;
    }
}


module.exports = UniTextGenNumLevel