var __extends = (this && this.__extends) || (function () {
    var extendStatics = Object.setPrototypeOf ||
        ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
        function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var F01XXXBase;
(function (F01XXXBase) {
    var _this = this;
    var InterfaceRules = (function () {
        function InterfaceRules(_document) {
            _this = _super.call(this, _document) || this;
            this._document = _document;
        }
        return InterfaceRules;
    }());
    F01XXXBase.InterfaceRules = InterfaceRules;
    var BaseHierarchySheet = (function (_super) {
        __extends(BaseHierarchySheet, _super);
        function BaseHierarchySheet() {
            return _super !== null && _super.apply(this, arguments) || this;
        }
        BaseHierarchySheet._totalRowName = "\u0412\u0441\u0435\u0433\u043E";
        BaseHierarchySheet._totalObjRowName = "\u0418\u0442\u043E\u0433\u043E \u043F\u043E \u043E\u0431\u044A\u0435\u043A\u0442\u0443 \u0437\u0430\u043A\u0443\u043F\u043A\u0438";
        BaseHierarchySheet._totalRowInfo = {
            IsCalculated: false,
            Name: BaseHierarchySheet._totalRowName,
            Format: SheetFormatCollection.Default
        };
        BaseHierarchySheet._totalObjRowInfo = {
            IsCalculated: false,
            Name: BaseHierarchySheet._totalObjRowName,
            Format: SheetFormatCollection.Default
        };
        BaseHierarchySheet._subTotalRowInfos = [
            BaseHierarchySheet._totalObjRowInfo
        ];
        BaseHierarchySheet.SprColConstAll = {
            Cell: { Type: SheetCellTypes.Spr },
            SubTotalRow: BaseHierarchySheet._subTotalRowInfos,
            TotalRow: BaseHierarchySheet._totalRowInfo
        };
        BaseHierarchySheet.RelatedColConstAll = {
            Cell: { Type: SheetCellTypes.Related },
            SubTotalRow: BaseHierarchySheet._subTotalRowInfos,
            TotalRow: BaseHierarchySheet._totalRowInfo
        };
        BaseHierarchySheet.FreeColConstAll = {
            Cell: { Type: SheetCellTypes.Free },
            SubTotalRow: BaseHierarchySheet._subTotalRowInfos,
            TotalRow: BaseHierarchySheet._totalRowInfo
        };
        BaseHierarchySheet.DefaultColConstAll = {
            Cell: { Type: SheetCellTypes.Default },
            SubTotalRow: BaseHierarchySheet._subTotalRowInfos,
            TotalRow: BaseHierarchySheet._totalRowInfo
        };
        BaseHierarchySheet._CodeInfo = {
            Column: 8,
            Length: 6,
            LevelIncs: [1000, 1],
            CalcTotalCode: function () {
                return "010000";
            }
        };
        return BaseHierarchySheet;
    }(HierarchyYearGroupSheet));
    F01XXXBase.BaseHierarchySheet = BaseHierarchySheet;
    var UsdSheetColumnBlocks;
    (function (UsdSheetColumnBlocks) {
        UsdSheetColumnBlocks[UsdSheetColumnBlocks["Usd"] = 0] = "Usd";
        UsdSheetColumnBlocks[UsdSheetColumnBlocks["Rub"] = 1] = "Rub";
        UsdSheetColumnBlocks[UsdSheetColumnBlocks["OtherRub"] = 2] = "OtherRub";
        UsdSheetColumnBlocks[UsdSheetColumnBlocks["Total"] = 3] = "Total";
    })(UsdSheetColumnBlocks || (UsdSheetColumnBlocks = {}));
    var BaseUsdHierarchySheet = (function (_super) {
        __extends(BaseUsdHierarchySheet, _super);
        function BaseUsdHierarchySheet(document, _startDataColumn, _allDataCalc) {
            if (_allDataCalc === void 0) { _allDataCalc = false; }
            var _this = _super.call(this, document) || this;
            _this._startDataColumn = _startDataColumn;
            _this._allDataCalc = _allDataCalc;
            _this._fullSheetInfo = null;
            _this._formulaYearsCount = document.MainDataYearsCount;
            _this._addFormulaYearsCount = document.AddDataYearsCount;
            _this._startFormulaColumn = _this.CalcStartBlockColumn(UsdSheetColumnBlocks.Rub) + 1;
            _this._startAddFormulaColumn = _this.CalcEndBlockColumn(UsdSheetColumnBlocks.Total) + 2;
            return _this;
        }
        Object.defineProperty(BaseUsdHierarchySheet.prototype, "SheetInfo", {
            get: function () {
                var _this = this;
                if (this._fullSheetInfo == null) {
                    this._fullSheetInfo = this.StartSheetInfo;
                    var insertColumns = function () {
                        var columnInfos = [];
                        for (var _i = 0; _i < arguments.length; _i++) {
                            columnInfos[_i] = arguments[_i];
                        }
                        for (var _a = 0, columnInfos_1 = columnInfos; _a < columnInfos_1.length; _a++) {
                            var columnInfo = columnInfos_1[_a];
                            for (var i = 0; i < _this._formulaYearsCount; i++) {
                                _this._fullSheetInfo.ColumnsInfo.push(columnInfo);
                            }
                        }
                    };
                    var dataColFormat = this._allDataCalc
                        ? SheetColumnInfoCollection.CalcColAllCalc
                        : SheetColumnInfoCollection.FreeColAllCalc;
                    insertColumns(dataColFormat, SheetColumnInfoCollection.CalcColAllCalc, dataColFormat, SheetColumnInfoCollection.CalcColAllCalc);
                    for (var j = 0; j < this._addFormulaYearsCount; j++) {
                        this._fullSheetInfo.ColumnsInfo.push(dataColFormat);
                        this._fullSheetInfo.ColumnsInfo.push(SheetColumnInfoCollection.CalcColAllCalc);
                        this._fullSheetInfo.ColumnsInfo.push(dataColFormat);
                        this._fullSheetInfo.ColumnsInfo.push(SheetColumnInfoCollection.CalcColAllCalc);
                    }
                }
                return this._fullSheetInfo;
            },
            enumerable: true,
            configurable: true
        });
        BaseUsdHierarchySheet.prototype.CalcStartBlockColumn = function (block) {
            return this._startDataColumn + this._formulaYearsCount * block;
        };
        BaseUsdHierarchySheet.prototype.CalcEndBlockColumn = function (block) {
            return this._startDataColumn + this._formulaYearsCount * (block + 1) - 1;
        };
        BaseUsdHierarchySheet.prototype.GetYearsCaptionEventHandler = function (tableId, index, defaultCaption, fieldCaption) {
            return this.Document.CommonRules.CalcColumnCaption(index, this._startFormulaColumn, 2, this._formulaYearsCount);
        };
        BaseUsdHierarchySheet.prototype.GetAddYearsCaptionEventHandler = function (tableId, index, defaultCaption, fieldCaption) {
            var startColumn = this._startAddFormulaColumn + BaseUsdHierarchySheet._blocksCount * index + UsdSheetColumnBlocks.Rub;
            var result = "\u0432\u0441\u0435\u0433\u043E \u043E\u0431\u044A\u0435\u043C \u0431\u044E\u0434\u0436\u0435\u0442\u043D\u044B\u0445 \u0430\u0441\u0441\u0438\u0433\u043D\u043E\u0432\u0430\u043D\u0438\u0439,\n\u0442\u044B\u0441 \u0440\u0443\u0431\n(\u0433\u0440. " + startColumn + " + \u0433\u0440. " + (startColumn + 1) + ")";
            return result;
        };
        BaseUsdHierarchySheet._blocksCount = ObasHelper.GetEnumLength(UsdSheetColumnBlocks);
        return BaseUsdHierarchySheet;
    }(BaseHierarchySheet));
    F01XXXBase.BaseUsdHierarchySheet = BaseUsdHierarchySheet;
    var PurchaseObjectHierarchySheet = (function (_super) {
        __extends(PurchaseObjectHierarchySheet, _super);
        function PurchaseObjectHierarchySheet() {
            return _super !== null && _super.apply(this, arguments) || this;
        }
        Object.defineProperty(PurchaseObjectHierarchySheet.prototype, "SheetInfo", {
            get: function () {
                return PurchaseObjectHierarchySheet._sheetInfo;
            },
            enumerable: true,
            configurable: true
        });
        PurchaseObjectHierarchySheet._sheetInfo = {
            MaxLevel: 2,
            CodeInfo: PurchaseObjectHierarchySheet._CodeInfo,
            ColumnsInfo: [
                SheetColumnInfoCollection.SprColDefaultTotal,
                SheetColumnInfoCollection.SprColDefaultTotal,
                SheetColumnInfoCollection.SprColDefaultTotal,
                SheetColumnInfoCollection.SprColAllDefault,
                SheetColumnInfoCollection.SprColAllDefault,
                SheetColumnInfoCollection.SprColAllDefault,
                SheetColumnInfoCollection.SprColAllDefault,
                PurchaseObjectHierarchySheet.FreeColConstAll,
                PurchaseObjectHierarchySheet.DefaultColConstAll,
                SheetColumnInfoCollection.FreeColAllCalc,
                SheetColumnInfoCollection.FreeColAllCalc,
                SheetColumnInfoCollection.FreeColAllCalc,
                SheetColumnInfoCollection.FreeColAllCalc,
                SheetColumnInfoCollection.FreeColAllCalc
            ]
        };
        return PurchaseObjectHierarchySheet;
    }(BaseHierarchySheet));
    F01XXXBase.PurchaseObjectHierarchySheet = PurchaseObjectHierarchySheet;
    var PurchaseObjectUsdHierarchySheet = (function (_super) {
        __extends(PurchaseObjectUsdHierarchySheet, _super);
        function PurchaseObjectUsdHierarchySheet(document) {
            return _super.call(this, document, 9) || this;
        }
        Object.defineProperty(PurchaseObjectUsdHierarchySheet.prototype, "StartSheetInfo", {
            get: function () {
                return PurchaseObjectUsdHierarchySheet._sheetInfo;
            },
            enumerable: true,
            configurable: true
        });
        PurchaseObjectUsdHierarchySheet._sheetInfo = {
            MaxLevel: 2,
            CodeInfo: PurchaseObjectUsdHierarchySheet._CodeInfo,
            ColumnsInfo: [
                SheetColumnInfoCollection.SprColDefaultTotal,
                SheetColumnInfoCollection.SprColDefaultTotal,
                SheetColumnInfoCollection.SprColDefaultTotal,
                SheetColumnInfoCollection.SprColAllDefault,
                SheetColumnInfoCollection.SprColAllDefault,
                SheetColumnInfoCollection.SprColAllDefault,
                SheetColumnInfoCollection.SprColAllDefault,
                PurchaseObjectUsdHierarchySheet.FreeColConstAll,
                PurchaseObjectUsdHierarchySheet.DefaultColConstAll
            ]
        };
        return PurchaseObjectUsdHierarchySheet;
    }(BaseUsdHierarchySheet));
    F01XXXBase.PurchaseObjectUsdHierarchySheet = PurchaseObjectUsdHierarchySheet;
})(F01XXXBase || (F01XXXBase = {}));
