(function (global, factory) {
    typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular-ru/cdk/array'), require('rxjs'), require('@angular-ru/cdk/date'), require('@angular-ru/cdk/utils'), require('@angular-ru/cdk/table-utils'), require('@angular-ru/cdk/webworker'), require('@ngx-translate/core')) :
    typeof define === 'function' && define.amd ? define('@angular-ru/cdk/excel', ['exports', '@angular/core', '@angular-ru/cdk/array', 'rxjs', '@angular-ru/cdk/date', '@angular-ru/cdk/utils', '@angular-ru/cdk/table-utils', '@angular-ru/cdk/webworker', '@ngx-translate/core'], factory) :
    (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global["angular-ru"] = global["angular-ru"] || {}, global["angular-ru"].cdk = global["angular-ru"].cdk || {}, global["angular-ru"].cdk.excel = {}), global.ng.core, global["angular-ru"].cdk.array, global.rxjs, global["angular-ru"].cdk.date, global["angular-ru"].cdk.utils, global["angular-ru"].cdk["table-utils"], global["angular-ru"].cdk.webworker, global.i1$1));
})(this, (function (exports, i0, array, rxjs, date, utils, i1, i2, i1$1) { 'use strict';

    function _interopNamespace(e) {
        if (e && e.__esModule) return e;
        var n = Object.create(null);
        if (e) {
            Object.keys(e).forEach(function (k) {
                if (k !== 'default') {
                    var d = Object.getOwnPropertyDescriptor(e, k);
                    Object.defineProperty(n, k, d.get ? d : {
                        enumerable: true,
                        get: function () { return e[k]; }
                    });
                }
            });
        }
        n["default"] = e;
        return Object.freeze(n);
    }

    var i0__namespace = /*#__PURE__*/_interopNamespace(i0);
    var i1__namespace = /*#__PURE__*/_interopNamespace(i1);
    var i2__namespace = /*#__PURE__*/_interopNamespace(i2);
    var i1__namespace$1 = /*#__PURE__*/_interopNamespace(i1$1);

    /*! *****************************************************************************
    Copyright (c) Microsoft Corporation.

    Permission to use, copy, modify, and/or distribute this software for any
    purpose with or without fee is hereby granted.

    THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
    REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
    AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
    INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
    LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
    OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
    PERFORMANCE OF THIS SOFTWARE.
    ***************************************************************************** */
    /* global Reflect, Promise */
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b)
                if (Object.prototype.hasOwnProperty.call(b, p))
                    d[p] = b[p]; };
        return extendStatics(d, b);
    };
    function __extends(d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    }
    var __assign = function () {
        __assign = Object.assign || function __assign(t) {
            for (var s, i = 1, n = arguments.length; i < n; i++) {
                s = arguments[i];
                for (var p in s)
                    if (Object.prototype.hasOwnProperty.call(s, p))
                        t[p] = s[p];
            }
            return t;
        };
        return __assign.apply(this, arguments);
    };
    function __rest(s, e) {
        var t = {};
        for (var p in s)
            if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
                t[p] = s[p];
        if (s != null && typeof Object.getOwnPropertySymbols === "function")
            for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
                if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
                    t[p[i]] = s[p[i]];
            }
        return t;
    }
    function __decorate(decorators, target, key, desc) {
        var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
        if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
            r = Reflect.decorate(decorators, target, key, desc);
        else
            for (var i = decorators.length - 1; i >= 0; i--)
                if (d = decorators[i])
                    r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
        return c > 3 && r && Object.defineProperty(target, key, r), r;
    }
    function __param(paramIndex, decorator) {
        return function (target, key) { decorator(target, key, paramIndex); };
    }
    function __metadata(metadataKey, metadataValue) {
        if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
            return Reflect.metadata(metadataKey, metadataValue);
    }
    function __awaiter(thisArg, _arguments, P, generator) {
        function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
        return new (P || (P = Promise))(function (resolve, reject) {
            function fulfilled(value) { try {
                step(generator.next(value));
            }
            catch (e) {
                reject(e);
            } }
            function rejected(value) { try {
                step(generator["throw"](value));
            }
            catch (e) {
                reject(e);
            } }
            function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
            step((generator = generator.apply(thisArg, _arguments || [])).next());
        });
    }
    function __generator(thisArg, body) {
        var _ = { label: 0, sent: function () { if (t[0] & 1)
                throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
        return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function () { return this; }), g;
        function verb(n) { return function (v) { return step([n, v]); }; }
        function step(op) {
            if (f)
                throw new TypeError("Generator is already executing.");
            while (_)
                try {
                    if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
                        return t;
                    if (y = 0, t)
                        op = [op[0] & 2, t.value];
                    switch (op[0]) {
                        case 0:
                        case 1:
                            t = op;
                            break;
                        case 4:
                            _.label++;
                            return { value: op[1], done: false };
                        case 5:
                            _.label++;
                            y = op[1];
                            op = [0];
                            continue;
                        case 7:
                            op = _.ops.pop();
                            _.trys.pop();
                            continue;
                        default:
                            if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
                                _ = 0;
                                continue;
                            }
                            if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) {
                                _.label = op[1];
                                break;
                            }
                            if (op[0] === 6 && _.label < t[1]) {
                                _.label = t[1];
                                t = op;
                                break;
                            }
                            if (t && _.label < t[2]) {
                                _.label = t[2];
                                _.ops.push(op);
                                break;
                            }
                            if (t[2])
                                _.ops.pop();
                            _.trys.pop();
                            continue;
                    }
                    op = body.call(thisArg, _);
                }
                catch (e) {
                    op = [6, e];
                    y = 0;
                }
                finally {
                    f = t = 0;
                }
            if (op[0] & 5)
                throw op[1];
            return { value: op[0] ? op[1] : void 0, done: true };
        }
    }
    var __createBinding = Object.create ? (function (o, m, k, k2) {
        if (k2 === undefined)
            k2 = k;
        Object.defineProperty(o, k2, { enumerable: true, get: function () { return m[k]; } });
    }) : (function (o, m, k, k2) {
        if (k2 === undefined)
            k2 = k;
        o[k2] = m[k];
    });
    function __exportStar(m, o) {
        for (var p in m)
            if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p))
                __createBinding(o, m, p);
    }
    function __values(o) {
        var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
        if (m)
            return m.call(o);
        if (o && typeof o.length === "number")
            return {
                next: function () {
                    if (o && i >= o.length)
                        o = void 0;
                    return { value: o && o[i++], done: !o };
                }
            };
        throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
    }
    function __read(o, n) {
        var m = typeof Symbol === "function" && o[Symbol.iterator];
        if (!m)
            return o;
        var i = m.call(o), r, ar = [], e;
        try {
            while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
                ar.push(r.value);
        }
        catch (error) {
            e = { error: error };
        }
        finally {
            try {
                if (r && !r.done && (m = i["return"]))
                    m.call(i);
            }
            finally {
                if (e)
                    throw e.error;
            }
        }
        return ar;
    }
    /** @deprecated */
    function __spread() {
        for (var ar = [], i = 0; i < arguments.length; i++)
            ar = ar.concat(__read(arguments[i]));
        return ar;
    }
    /** @deprecated */
    function __spreadArrays() {
        for (var s = 0, i = 0, il = arguments.length; i < il; i++)
            s += arguments[i].length;
        for (var r = Array(s), k = 0, i = 0; i < il; i++)
            for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
                r[k] = a[j];
        return r;
    }
    function __spreadArray(to, from, pack) {
        if (pack || arguments.length === 2)
            for (var i = 0, l = from.length, ar; i < l; i++) {
                if (ar || !(i in from)) {
                    if (!ar)
                        ar = Array.prototype.slice.call(from, 0, i);
                    ar[i] = from[i];
                }
            }
        return to.concat(ar || Array.prototype.slice.call(from));
    }
    function __await(v) {
        return this instanceof __await ? (this.v = v, this) : new __await(v);
    }
    function __asyncGenerator(thisArg, _arguments, generator) {
        if (!Symbol.asyncIterator)
            throw new TypeError("Symbol.asyncIterator is not defined.");
        var g = generator.apply(thisArg, _arguments || []), i, q = [];
        return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
        function verb(n) { if (g[n])
            i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
        function resume(n, v) { try {
            step(g[n](v));
        }
        catch (e) {
            settle(q[0][3], e);
        } }
        function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
        function fulfill(value) { resume("next", value); }
        function reject(value) { resume("throw", value); }
        function settle(f, v) { if (f(v), q.shift(), q.length)
            resume(q[0][0], q[0][1]); }
    }
    function __asyncDelegator(o) {
        var i, p;
        return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
        function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
    }
    function __asyncValues(o) {
        if (!Symbol.asyncIterator)
            throw new TypeError("Symbol.asyncIterator is not defined.");
        var m = o[Symbol.asyncIterator], i;
        return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
        function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
        function settle(resolve, reject, d, v) { Promise.resolve(v).then(function (v) { resolve({ value: v, done: d }); }, reject); }
    }
    function __makeTemplateObject(cooked, raw) {
        if (Object.defineProperty) {
            Object.defineProperty(cooked, "raw", { value: raw });
        }
        else {
            cooked.raw = raw;
        }
        return cooked;
    }
    ;
    var __setModuleDefault = Object.create ? (function (o, v) {
        Object.defineProperty(o, "default", { enumerable: true, value: v });
    }) : function (o, v) {
        o["default"] = v;
    };
    function __importStar(mod) {
        if (mod && mod.__esModule)
            return mod;
        var result = {};
        if (mod != null)
            for (var k in mod)
                if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
                    __createBinding(result, mod, k);
        __setModuleDefault(result, mod);
        return result;
    }
    function __importDefault(mod) {
        return (mod && mod.__esModule) ? mod : { default: mod };
    }
    function __classPrivateFieldGet(receiver, state, kind, f) {
        if (kind === "a" && !f)
            throw new TypeError("Private accessor was defined without a getter");
        if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
            throw new TypeError("Cannot read private member from an object whose class did not declare it");
        return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
    }
    function __classPrivateFieldSet(receiver, state, value, kind, f) {
        if (kind === "m")
            throw new TypeError("Private method is not writable");
        if (kind === "a" && !f)
            throw new TypeError("Private accessor was defined without a setter");
        if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
            throw new TypeError("Cannot write private member to an object whose class did not declare it");
        return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
    }

    var EXCEL_BUILDER_INTERCEPTOR_TOKEN = new i0.InjectionToken('EXCEL_BUILDER_INTERCEPTOR_TOKEN');

    var bold = {
        "0": 5.9285736083984375,
        "1": 5.9285736083984375,
        "2": 5.9285736083984375,
        "3": 5.9285736083984375,
        "4": 5.9285736083984375,
        "5": 5.9285736083984375,
        "6": 5.9285736083984375,
        "7": 5.9285736083984375,
        "8": 5.9285736083984375,
        "9": 5.9285736083984375,
        "!": 3.5498504638671875,
        "\"": 5.0541229248046875,
        "#": 5.9285736083984375,
        $: 5.9285736083984375,
        "%": 9.478424072265625,
        "&": 7.6982879638671875,
        "'": 2.5348663330078125,
        "(": 3.5498504638671875,
        ")": 3.5498504638671875,
        "*": 4.1484375,
        "+": 6.2252655029296875,
        ",": 2.9616851806640625,
        "-": 3.5498504638671875,
        ".": 2.9616851806640625,
        "/": 2.9616851806640625,
        ":": 3.5498504638671875,
        ";": 3.5498504638671875,
        "<": 6.2252655029296875,
        "=": 6.2252655029296875,
        ">": 6.2252655029296875,
        "?": 6.51153564453125,
        "@": 10.394515991210938,
        A: 7.6982879638671875,
        B: 7.6982879638671875,
        C: 7.6982879638671875,
        D: 7.6982879638671875,
        E: 7.1101226806640625,
        F: 6.51153564453125,
        G: 8.291671752929688,
        H: 7.6982879638671875,
        I: 2.9616851806640625,
        J: 5.9285736083984375,
        K: 7.6982879638671875,
        L: 6.51153564453125,
        M: 8.879852294921875,
        N: 7.6982879638671875,
        O: 8.291671752929688,
        P: 7.1101226806640625,
        Q: 8.291671752929688,
        R: 7.6982879638671875,
        S: 7.1101226806640625,
        T: 6.51153564453125,
        U: 7.6982879638671875,
        V: 7.1101226806640625,
        W: 10.0614013671875,
        X: 7.1101226806640625,
        Y: 7.1101226806640625,
        Z: 6.51153564453125,
        "[": 3.5498504638671875,
        "\\": 2.9616851806640625,
        "]": 3.5498504638671875,
        "^": 6.2252655029296875,
        _: 5.9285736083984375,
        "`": 3.5498504638671875,
        a: 5.9285736083984375,
        b: 6.51153564453125,
        c: 5.9285736083984375,
        d: 6.51153564453125,
        e: 5.9285736083984375,
        f: 3.5498504638671875,
        g: 6.51153564453125,
        h: 6.51153564453125,
        i: 2.9616851806640625,
        j: 2.9616851806640625,
        k: 5.9285736083984375,
        l: 2.9616851806640625,
        m: 9.478424072265625,
        n: 6.51153564453125,
        o: 6.51153564453125,
        p: 6.51153564453125,
        q: 6.51153564453125,
        r: 4.1484375,
        s: 5.9285736083984375,
        t: 3.5498504638671875,
        u: 6.51153564453125,
        v: 5.9285736083984375,
        w: 8.291671752929688,
        x: 5.9285736083984375,
        y: 5.9285736083984375,
        z: 5.329986572265625,
        "{": 4.1484375,
        "|": 2.9824981689453125,
        "}": 4.1484375,
        "~": 6.2252655029296875,
        "¡": 3.5498504638671875,
        "¢": 5.9285736083984375,
        "£": 5.9285736083984375,
        "¤": 5.9285736083984375,
        "¥": 5.9285736083984375,
        "¦": 2.9824981689453125,
        "§": 5.9285736083984375,
        "¨": 3.5498504638671875,
        "©": 7.8544464111328125,
        "«": 5.9285736083984375,
        "¬": 6.2252655029296875,
        "®": 7.8544464111328125,
        "¯": 5.886932373046875,
        "°": 4.262939453125,
        "±": 5.850494384765625,
        "²": 3.5498504638671875,
        "³": 3.5498504638671875,
        "´": 3.5498504638671875,
        "µ": 6.1419830322265625,
        "¶": 5.9285736083984375,
        "·": 3.5498504638671875,
        "¸": 3.5498504638671875,
        "¹": 3.5498504638671875,
        "»": 5.9285736083984375,
        "¼": 8.8902587890625,
        "½": 8.8902587890625,
        "¾": 8.8902587890625,
        "¿": 6.51153564453125,
        "À": 7.6982879638671875,
        "Á": 7.6982879638671875,
        "Â": 7.6982879638671875,
        "Ã": 7.6982879638671875,
        "Ä": 7.6982879638671875,
        "Å": 7.6982879638671875,
        "Æ": 10.659988403320312,
        "Ç": 7.6982879638671875,
        "È": 7.1101226806640625,
        "É": 7.1101226806640625,
        "Ê": 7.1101226806640625,
        "Ë": 7.1101226806640625,
        "Ì": 2.9616851806640625,
        "Í": 2.9616851806640625,
        "Î": 2.9616851806640625,
        "Ï": 2.9616851806640625,
        "Ð": 7.6982879638671875,
        "Ñ": 7.6982879638671875,
        "Ò": 8.291671752929688,
        "Ó": 8.291671752929688,
        "Ô": 8.291671752929688,
        "Õ": 8.291671752929688,
        "Ö": 8.291671752929688,
        "×": 6.2252655029296875,
        "Ø": 8.291671752929688,
        "Ù": 7.6982879638671875,
        "Ú": 7.6982879638671875,
        "Û": 7.6982879638671875,
        "Ü": 7.6982879638671875,
        "Ý": 7.1101226806640625,
        "Þ": 7.1101226806640625,
        "ß": 6.51153564453125,
        "à": 5.9285736083984375,
        "á": 5.9285736083984375,
        "â": 5.9285736083984375,
        "ã": 5.9285736083984375,
        "ä": 5.9285736083984375,
        "å": 5.9285736083984375,
        "æ": 9.478424072265625,
        "ç": 5.9285736083984375,
        "è": 5.9285736083984375,
        "é": 5.9285736083984375,
        "ê": 5.9285736083984375,
        "ë": 5.9285736083984375,
        "ì": 2.9616851806640625,
        "í": 2.9616851806640625,
        "î": 2.9616851806640625,
        "ï": 2.9616851806640625,
        "ð": 6.51153564453125,
        "ñ": 6.51153564453125,
        "ò": 6.51153564453125,
        "ó": 6.51153564453125,
        "ô": 6.51153564453125,
        "õ": 6.51153564453125,
        "ö": 6.51153564453125,
        "÷": 5.850494384765625,
        "ø": 6.51153564453125,
        "ù": 6.51153564453125,
        "ú": 6.51153564453125,
        "û": 6.51153564453125,
        "ü": 6.51153564453125,
        "ý": 5.9285736083984375,
        "þ": 6.51153564453125,
        "ÿ": 5.9285736083984375,
        "Œ": 10.659988403320312,
        "œ": 10.0614013671875,
        "Š": 7.1101226806640625,
        "š": 5.9285736083984375,
        "Ÿ": 7.1101226806640625,
        "Ƒ": 6.51153564453125,
        "ƒ": 5.9285736083984375,
        "ˆ": 3.5498504638671875,
        "˜": 3.5498504638671875,
        "Μ": 8.879852294921875,
        "Ё": 7.1309356689453125,
        "А": 7.6982879638671875,
        "Б": 7.661865234375,
        "В": 7.6982879638671875,
        "Г": 6.0430755615234375,
        "Д": 7.5941925048828125,
        "Е": 7.1101226806640625,
        "Ж": 9.63458251953125,
        "З": 6.6781005859375,
        "И": 7.661865234375,
        "Й": 7.661865234375,
        "К": 6.5063323974609375,
        "Л": 7.47967529296875,
        "М": 8.879852294921875,
        "Н": 7.6982879638671875,
        "О": 8.291671752929688,
        "П": 7.661865234375,
        "Р": 7.1101226806640625,
        "С": 7.6982879638671875,
        "Т": 6.51153564453125,
        "У": 6.631256103515625,
        "Ф": 9.098464965820312,
        "Х": 7.1101226806640625,
        "Ц": 7.786773681640625,
        "Ч": 7.4900970458984375,
        "Ш": 10.7120361328125,
        "Щ": 10.86297607421875,
        "Ъ": 9.270233154296875,
        "Ы": 10.4361572265625,
        "Ь": 7.661865234375,
        "Э": 7.5837860107421875,
        "Ю": 10.99310302734375,
        "Я": 7.661865234375,
        "а": 5.9285736083984375,
        "б": 6.58441162109375,
        "в": 6.5531768798828125,
        "г": 4.4399261474609375,
        "д": 6.7665863037109375,
        "е": 5.9285736083984375,
        "ж": 7.5577545166015625,
        "з": 5.2987518310546875,
        "и": 6.5531768798828125,
        "й": 6.5531768798828125,
        "к": 5.3351898193359375,
        "л": 6.77178955078125,
        "м": 7.88568115234375,
        "н": 6.43865966796875,
        "о": 6.51153564453125,
        "п": 6.43865966796875,
        "р": 6.51153564453125,
        "с": 5.9285736083984375,
        "т": 5.220672607421875,
        "у": 5.9285736083984375,
        "ф": 9.327484130859375,
        "х": 5.9285736083984375,
        "ц": 6.5531768798828125,
        "ч": 6.1888275146484375,
        "ш": 8.885055541992188,
        "щ": 8.994354248046875,
        "ъ": 7.7711639404296875,
        "ы": 9.103668212890625,
        "ь": 6.5531768798828125,
        "э": 5.886932373046875,
        "ю": 9.103668212890625,
        "я": 6.2200469970703125,
        "ё": 5.9285736083984375,
        "–": 5.9285736083984375,
        "—": 10.659988403320312,
        "‘": 2.9616851806640625,
        "’": 2.9616851806640625,
        "“": 5.329986572265625,
        "”": 5.329986572265625,
        "„": 5.329986572265625,
        "†": 5.9285736083984375,
        "‡": 5.9285736083984375,
        "•": 3.732025146484375,
        "…": 10.659988403320312,
        "‰": 10.659988403320312,
        "‹": 3.5498504638671875,
        "›": 3.5498504638671875,
        "€": 5.9285736083984375,
        "™": 10.659988403320312,
        " ": 2.9616851806640625
    };
    var regular = {
        "0": 5.9285736083984375,
        "1": 5.9285736083984375,
        "2": 5.9285736083984375,
        "3": 5.9285736083984375,
        "4": 5.9285736083984375,
        "5": 5.9285736083984375,
        "6": 5.9285736083984375,
        "7": 5.9285736083984375,
        "8": 5.9285736083984375,
        "9": 5.9285736083984375,
        "!": 2.9616851806640625,
        "\"": 3.7840728759765625,
        "#": 5.9285736083984375,
        $: 5.9285736083984375,
        "%": 9.478424072265625,
        "&": 7.1101226806640625,
        "'": 2.0351715087890625,
        "(": 3.5498504638671875,
        ")": 3.5498504638671875,
        "*": 4.1484375,
        "+": 6.2252655029296875,
        ",": 2.9616851806640625,
        "-": 3.5498504638671875,
        ".": 2.9616851806640625,
        "/": 2.9616851806640625,
        ":": 2.9616851806640625,
        ";": 2.9616851806640625,
        "<": 6.2252655029296875,
        "=": 6.2252655029296875,
        ">": 6.2252655029296875,
        "?": 5.9285736083984375,
        "@": 10.821334838867188,
        A: 7.1101226806640625,
        B: 7.1101226806640625,
        C: 7.6982879638671875,
        D: 7.6982879638671875,
        E: 7.1101226806640625,
        F: 6.51153564453125,
        G: 8.291671752929688,
        H: 7.6982879638671875,
        I: 2.9616851806640625,
        J: 5.329986572265625,
        K: 7.1101226806640625,
        L: 5.9285736083984375,
        M: 8.879852294921875,
        N: 7.6982879638671875,
        O: 8.291671752929688,
        P: 7.1101226806640625,
        Q: 8.291671752929688,
        R: 7.6982879638671875,
        S: 7.1101226806640625,
        T: 6.51153564453125,
        U: 7.6982879638671875,
        V: 7.1101226806640625,
        W: 10.0614013671875,
        X: 7.1101226806640625,
        Y: 7.1101226806640625,
        Z: 6.51153564453125,
        "[": 2.9616851806640625,
        "\\": 2.9616851806640625,
        "]": 2.9616851806640625,
        "^": 5.0020599365234375,
        _: 5.9285736083984375,
        "`": 3.5498504638671875,
        a: 5.9285736083984375,
        b: 5.9285736083984375,
        c: 5.329986572265625,
        d: 5.9285736083984375,
        e: 5.9285736083984375,
        f: 2.9616851806640625,
        g: 5.9285736083984375,
        h: 5.9285736083984375,
        i: 2.3683013916015625,
        j: 2.3683013916015625,
        k: 5.329986572265625,
        l: 2.3683013916015625,
        m: 8.879852294921875,
        n: 5.9285736083984375,
        o: 5.9285736083984375,
        p: 5.9285736083984375,
        q: 5.9285736083984375,
        r: 3.5498504638671875,
        s: 5.329986572265625,
        t: 2.9616851806640625,
        u: 5.9285736083984375,
        v: 5.329986572265625,
        w: 7.6982879638671875,
        x: 5.329986572265625,
        y: 5.329986572265625,
        z: 5.329986572265625,
        "{": 3.5602569580078125,
        "|": 2.7690887451171875,
        "}": 3.5602569580078125,
        "~": 6.2252655029296875,
        "¡": 3.5498504638671875,
        "¢": 5.9285736083984375,
        "£": 5.9285736083984375,
        "¤": 5.9285736083984375,
        "¥": 5.9285736083984375,
        "¦": 2.7690887451171875,
        "§": 5.9285736083984375,
        "¨": 3.5498504638671875,
        "©": 7.8544464111328125,
        "«": 5.9285736083984375,
        "¬": 6.2252655029296875,
        "®": 7.8544464111328125,
        "¯": 5.886932373046875,
        "°": 4.262939453125,
        "±": 5.850494384765625,
        "²": 3.5498504638671875,
        "³": 3.5498504638671875,
        "´": 3.5498504638671875,
        "µ": 6.1419830322265625,
        "¶": 5.7255706787109375,
        "·": 3.5498504638671875,
        "¸": 3.5498504638671875,
        "¹": 3.5498504638671875,
        "»": 5.9285736083984375,
        "¼": 8.8902587890625,
        "½": 8.8902587890625,
        "¾": 8.8902587890625,
        "¿": 6.51153564453125,
        "À": 7.1101226806640625,
        "Á": 7.1101226806640625,
        "Â": 7.1101226806640625,
        "Ã": 7.1101226806640625,
        "Ä": 7.1101226806640625,
        "Å": 7.1101226806640625,
        "Æ": 10.659988403320312,
        "Ç": 7.6982879638671875,
        "È": 7.1101226806640625,
        "É": 7.1101226806640625,
        "Ê": 7.1101226806640625,
        "Ë": 7.1101226806640625,
        "Ì": 2.9616851806640625,
        "Í": 2.9616851806640625,
        "Î": 2.9616851806640625,
        "Ï": 2.9616851806640625,
        "Ð": 7.6982879638671875,
        "Ñ": 7.6982879638671875,
        "Ò": 8.291671752929688,
        "Ó": 8.291671752929688,
        "Ô": 8.291671752929688,
        "Õ": 8.291671752929688,
        "Ö": 8.291671752929688,
        "×": 6.2252655029296875,
        "Ø": 8.291671752929688,
        "Ù": 7.6982879638671875,
        "Ú": 7.6982879638671875,
        "Û": 7.6982879638671875,
        "Ü": 7.6982879638671875,
        "Ý": 7.1101226806640625,
        "Þ": 7.1101226806640625,
        "ß": 6.51153564453125,
        "à": 5.9285736083984375,
        "á": 5.9285736083984375,
        "â": 5.9285736083984375,
        "ã": 5.9285736083984375,
        "ä": 5.9285736083984375,
        "å": 5.9285736083984375,
        "æ": 9.478424072265625,
        "ç": 5.329986572265625,
        "è": 5.9285736083984375,
        "é": 5.9285736083984375,
        "ê": 5.9285736083984375,
        "ë": 5.9285736083984375,
        "ì": 2.9616851806640625,
        "í": 2.9616851806640625,
        "î": 2.9616851806640625,
        "ï": 2.9616851806640625,
        "ð": 5.9285736083984375,
        "ñ": 5.9285736083984375,
        "ò": 5.9285736083984375,
        "ó": 5.9285736083984375,
        "ô": 5.9285736083984375,
        "õ": 5.9285736083984375,
        "ö": 5.9285736083984375,
        "÷": 5.850494384765625,
        "ø": 6.51153564453125,
        "ù": 5.9285736083984375,
        "ú": 5.9285736083984375,
        "û": 5.9285736083984375,
        "ü": 5.9285736083984375,
        "ý": 5.329986572265625,
        "þ": 5.9285736083984375,
        "ÿ": 5.329986572265625,
        "Œ": 10.659988403320312,
        "œ": 10.0614013671875,
        "Š": 7.1101226806640625,
        "š": 5.329986572265625,
        "Ÿ": 7.1101226806640625,
        "Ƒ": 6.51153564453125,
        "ƒ": 5.9285736083984375,
        "ˆ": 3.5498504638671875,
        "˜": 3.5498504638671875,
        "Μ": 8.879852294921875,
        "Ё": 7.115325927734375,
        "А": 7.1101226806640625,
        "Б": 6.99560546875,
        "В": 7.1101226806640625,
        "Г": 5.7724151611328125,
        "Д": 7.21942138671875,
        "Е": 7.1101226806640625,
        "Ж": 9.842788696289062,
        "З": 6.43865966796875,
        "И": 7.661865234375,
        "Й": 7.661865234375,
        "К": 6.2096405029296875,
        "Л": 6.99560546875,
        "М": 8.879852294921875,
        "Н": 7.6982879638671875,
        "О": 8.291671752929688,
        "П": 7.661865234375,
        "Р": 7.1101226806640625,
        "С": 7.6982879638671875,
        "Т": 6.51153564453125,
        "У": 6.77178955078125,
        "Ф": 8.104293823242188,
        "Х": 7.1101226806640625,
        "Ц": 7.88568115234375,
        "Ч": 7.10491943359375,
        "Ш": 9.769912719726562,
        "Щ": 9.993728637695312,
        "Ъ": 8.437408447265625,
        "Ы": 9.436782836914062,
        "Ь": 6.99560546875,
        "Э": 7.661865234375,
        "Ю": 10.769287109375,
        "Я": 7.6982879638671875,
        "а": 5.9285736083984375,
        "б": 6.1055450439453125,
        "в": 5.663116455078125,
        "г": 3.88818359375,
        "д": 6.2200469970703125,
        "е": 5.9285736083984375,
        "ж": 7.1309356689453125,
        "з": 4.8875579833984375,
        "и": 5.95458984375,
        "й": 5.95458984375,
        "к": 4.6637420654296875,
        "л": 6.2200469970703125,
        "м": 7.3287353515625,
        "н": 5.886932373046875,
        "о": 5.9285736083984375,
        "п": 5.7724151611328125,
        "р": 5.9285736083984375,
        "с": 5.329986572265625,
        "т": 4.882354736328125,
        "у": 5.329986572265625,
        "ф": 8.770538330078125,
        "х": 5.329986572265625,
        "ц": 6.1055450439453125,
        "ч": 5.553802490234375,
        "ш": 8.551925659179688,
        "щ": 8.770538330078125,
        "ъ": 6.6624908447265625,
        "ы": 7.661865234375,
        "ь": 5.553802490234375,
        "э": 5.439300537109375,
        "ю": 7.9949798583984375,
        "я": 5.7724151611328125,
        "ё": 5.9285736083984375,
        "–": 5.9285736083984375,
        "—": 10.659988403320312,
        "‘": 2.3683013916015625,
        "’": 2.3683013916015625,
        "“": 3.5498504638671875,
        "”": 3.5498504638671875,
        "„": 3.5498504638671875,
        "†": 5.9285736083984375,
        "‡": 5.9285736083984375,
        "•": 3.732025146484375,
        "…": 10.659988403320312,
        "‰": 10.659988403320312,
        "‹": 3.5498504638671875,
        "›": 3.5498504638671875,
        "€": 5.9285736083984375,
        "™": 10.659988403320312,
        " ": 2.9616851806640625
    };
    var widthOfSymbolsMap = {
        bold: bold,
        regular: regular
    };

    var ExcelBuilderService = /** @class */ (function () {
        function ExcelBuilderService(plainTableComposer, webWorker) {
            this.plainTableComposer = plainTableComposer;
            this.webWorker = webWorker;
        }
        ExcelBuilderService.downloadWorkbook = function (blob, workbookName) {
            utils.downloadFile({ blob: blob, name: workbookName + "." + date.toFormatDateTime(), extension: 'xls' });
        };
        // eslint-disable-next-line max-lines-per-function
        ExcelBuilderService.prototype.exportExcelByWorkbook = function (workbook) {
            return __awaiter(this, void 0, void 0, function () {
                var preparedWorkbook;
                return __generator(this, function (_d) {
                    switch (_d.label) {
                        case 0: return [4 /*yield*/, this.prepareWorkbook(workbook)];
                        case 1:
                            preparedWorkbook = _d.sent();
                            this.webWorker
                                // eslint-disable-next-line max-lines-per-function,sonarjs/cognitive-complexity
                                .run(function (input) {
                                function isEmptyValue(value) {
                                    var val = typeof value === 'string' ? value.trim() : value;
                                    return [undefined, null, NaN, '', Infinity].includes(val);
                                }
                                var ExcelBuilder = /** @class */ (function () {
                                    function ExcelBuilder(sizes, flattenTranslatedKeys) {
                                        this.sizes = sizes;
                                        this.flattenTranslatedKeys = flattenTranslatedKeys;
                                    }
                                    ExcelBuilder.generateWorkbook = function (xmlWorksheets) {
                                        return "\n                            <?xml version=\"1.0\"?>\n                            <?mso-application progid=\"Excel.Sheet\"?>\n                            <Workbook\n                                xmlns=\"urn:schemas-microsoft-com:office:spreadsheet\"\n                                xmlns:o=\"urn:schemas-microsoft-com:office:office\"\n                                xmlns:x=\"urn:schemas-microsoft-com:office:excel\"\n                                xmlns:ss=\"urn:schemas-microsoft-com:office:spreadsheet\"\n                                xmlns:html=\"https://www.w3.org/TR/html40/\"\n                            >\n                                " + ExcelBuilder.commonStyles + "\n                                " + xmlWorksheets + "\n                            </Workbook>";
                                    };
                                    ExcelBuilder.renderCell = function (value, styleId) {
                                        var type = typeof value === 'number' ? 'Number' : 'String';
                                        var cellValue = isEmptyValue(value) ? '-' : value;
                                        if (typeof cellValue === 'string') {
                                            cellValue = cellValue.trim();
                                            cellValue = cellValue.replace(/[<>]/g, '');
                                        }
                                        return "<Cell ss:StyleID=\"" + styleId + "\"><Data ss:Type=\"" + type + "\">" + cellValue + "</Data></Cell>";
                                    };
                                    ExcelBuilder.isFilled = function (value) {
                                        return typeof value === 'string' && value.length > 0;
                                    };
                                    ExcelBuilder.prototype.buildWorkbook = function (worksheets) {
                                        var xmlWorksheets = this.generateWorksheets(worksheets);
                                        return ExcelBuilder.generateWorkbook(xmlWorksheets);
                                    };
                                    ExcelBuilder.prototype.generateWorksheets = function (worksheets) {
                                        var _this = this;
                                        var xmlSheets = worksheets.map(function (worksheet) { return _this.generateWorksheet(worksheet); });
                                        return xmlSheets.join('');
                                    };
                                    ExcelBuilder.prototype.generateWorksheet = function (worksheet) {
                                        var _d = this.sizes, minColumnWidth = _d.minColumnWidth, rowHeight = _d.rowHeight;
                                        var xmlColumns = this.generateColumnsDescriptor(worksheet);
                                        var xmlBodyRows = this.generateBodyRows(worksheet.flatEntries);
                                        return "\n                        <Worksheet ss:Name=\"" + worksheet.worksheetName + "\">\n                            <Table ss:DefaultColumnWidth=\"" + minColumnWidth + "\" ss:DefaultRowHeight=\"" + rowHeight + "\">\n                                " + xmlColumns + "\n                                " + xmlBodyRows + "\n                            </Table>\n                        </Worksheet>";
                                    };
                                    ExcelBuilder.prototype.generateColumnsDescriptor = function (worksheet) {
                                        var _this = this;
                                        var _a, _b;
                                        var keys = Object.keys((_b = (_a = worksheet.flatEntries) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : []);
                                        var columnsDescriptor = '';
                                        var columnCells = '';
                                        keys.forEach(function (key) {
                                            var _a, _b, _c;
                                            var title = _this.getTranslatedTitle(key, worksheet.prefixKeyForTranslate);
                                            var parameters = (_a = worksheet.columnParameters) === null || _a === void 0 ? void 0 : _a[key];
                                            var entriesColumn = worksheet.flatEntries.map(function (entry) { var _a, _b; return (_b = (_a = entry[key]) === null || _a === void 0 ? void 0 : _a.toString()) !== null && _b !== void 0 ? _b : ''; });
                                            var widthSetting = (_b = parameters === null || parameters === void 0 ? void 0 : parameters.width) !== null && _b !== void 0 ? _b : (_c = worksheet.generalColumnParameters) === null || _c === void 0 ? void 0 : _c.width;
                                            var width = _this.getWidthOfColumn(title, entriesColumn, widthSetting);
                                            columnsDescriptor += "<Column ss:Width=\"" + width + "\" />";
                                            columnCells += ExcelBuilder.renderCell(title, "HeadCellStyle" /* HEAD */);
                                        });
                                        return "\n                            " + columnsDescriptor + "\n                            <Row>" + columnCells + "</Row>";
                                    };
                                    ExcelBuilder.prototype.getWidthOfColumn = function (title, entries, width) {
                                        var minColumnWidth = this.sizes.minColumnWidth;
                                        if (width === "MAX_WIDTH" /* MAX_WIDTH */) {
                                            return this.calcMaxWidthByEntries(entries, title);
                                        }
                                        else if (typeof width === 'number') {
                                            return width;
                                        }
                                        else {
                                            return minColumnWidth;
                                        }
                                    };
                                    ExcelBuilder.prototype.calcMaxWidthByEntries = function (entries, title) {
                                        var _this = this;
                                        var titleLength = this.getWidthOfString(title, 'bold');
                                        var indentMeasuredInSymbols = 2;
                                        var indent = this.sizes.fontWidth * indentMeasuredInSymbols;
                                        var maxLength = entries.reduce(function (length, entry) {
                                            var currentLength = _this.getWidthOfString(entry, 'regular');
                                            return Math.max(currentLength, length);
                                        }, titleLength);
                                        return Math.round(maxLength) + indent;
                                    };
                                    ExcelBuilder.prototype.getWidthOfString = function (string, fontWeight) {
                                        var e_1, _d;
                                        var _a;
                                        var width = 0;
                                        try {
                                            for (var string_1 = __values(string), string_1_1 = string_1.next(); !string_1_1.done; string_1_1 = string_1.next()) {
                                                var symbol = string_1_1.value;
                                                width += (_a = input.widthOfSymbols[fontWeight][symbol]) !== null && _a !== void 0 ? _a : this.sizes.fontWidth;
                                            }
                                        }
                                        catch (e_1_1) { e_1 = { error: e_1_1 }; }
                                        finally {
                                            try {
                                                if (string_1_1 && !string_1_1.done && (_d = string_1.return)) _d.call(string_1);
                                            }
                                            finally { if (e_1) throw e_1.error; }
                                        }
                                        return width;
                                    };
                                    ExcelBuilder.prototype.getTranslatedTitle = function (key, translatePrefix) {
                                        var _a;
                                        var translatePath = ExcelBuilder.isFilled(translatePrefix)
                                            ? translatePrefix + "." + key
                                            : key;
                                        return (_a = this.flattenTranslatedKeys[translatePath]) !== null && _a !== void 0 ? _a : key;
                                    };
                                    ExcelBuilder.prototype.generateBodyRows = function (entries) {
                                        var _this = this;
                                        var rowHeight = this.sizes.rowHeight;
                                        var xmlRows = entries.map(function (cell) {
                                            var xmlCells = _this.generateCells(cell);
                                            return "<Row ss:Height=\"" + rowHeight + "\">" + xmlCells + "</Row>";
                                        });
                                        return xmlRows.join('');
                                    };
                                    ExcelBuilder.prototype.generateCells = function (flatCell) {
                                        var _d = this.sizes, fontWidth = _d.fontWidth, minColumnWidth = _d.minColumnWidth;
                                        var keys = Object.keys(flatCell);
                                        var xmlCells = keys.map(function (key) {
                                            var value = flatCell[key];
                                            var symbolCount = String(value).length;
                                            var overflow = symbolCount * fontWidth >= minColumnWidth;
                                            var localStyleId = overflow ? "CellBigDataStyle" /* BIG_DATA */ : "BodyCellStyle" /* BODY */;
                                            return ExcelBuilder.renderCell(value, localStyleId);
                                        });
                                        return xmlCells.join('');
                                    };
                                    return ExcelBuilder;
                                }());
                                ExcelBuilder.commonBorderStyles = "\n                        <Borders>\n                            <Border ss:Position=\"Top\" ss:Color=\"#000000\" ss:LineStyle=\"Continuous\" ss:Weight=\"1\"/>\n                            <Border ss:Position=\"Bottom\" ss:Color=\"#000000\" ss:LineStyle=\"Continuous\" ss:Weight=\"1\"/>\n                            <Border ss:Position=\"Right\" ss:Color=\"#000000\" ss:LineStyle=\"Continuous\" ss:Weight=\"1\"/>\n                            <Border ss:Position=\"Left\" ss:Color=\"#000000\" ss:LineStyle=\"Continuous\" ss:Weight=\"1\"/>\n                        </Borders>";
                                ExcelBuilder.commonStyles = "\n                        <Styles>\n                            <Style ss:ID=\"" + "HeadCellStyle" /* HEAD */ + "\">\n                                <Alignment ss:Horizontal=\"Center\" ss:Vertical=\"Center\" ss:WrapText=\"0\" />\n                                <Font ss:Bold=\"1\" ss:FontName=\"Arial\" />\n                                " + ExcelBuilder.commonBorderStyles + "\n                            </Style>\n                            <Style ss:ID=\"" + "CellBigDataStyle" /* BIG_DATA */ + "\">\n                                <Alignment ss:Horizontal=\"Center\" ss:Vertical=\"Center\" ss:WrapText=\"1\" />\n                                <Font ss:Bold=\"0\" ss:FontName=\"Arial\" />\n                                " + ExcelBuilder.commonBorderStyles + "\n                            </Style>\n                            <Style ss:ID=\"" + "BodyCellStyle" /* BODY */ + "\">\n                                <Alignment ss:Horizontal=\"Center\" ss:Vertical=\"Center\" ss:WrapText=\"0\" />\n                                <Font ss:Bold=\"0\" ss:FontName=\"Arial\" />\n                                " + ExcelBuilder.commonBorderStyles + "\n                            </Style>\n                        </Styles>";
                                var xmlBookTemplate = new ExcelBuilder({ fontWidth: 6, fontSize: 7, minColumnWidth: 150, rowHeight: 40 }, input.preparedTranslatedKeys).buildWorkbook(input.worksheets);
                                var UTF8 = '\ufeff';
                                return new Blob([UTF8, xmlBookTemplate], { type: 'application/vnd.ms-excel;charset=UTF-8' });
                            }, preparedWorkbook)
                                .then(function (blob) { return ExcelBuilderService.downloadWorkbook(blob, workbook.filename); });
                            return [2 /*return*/];
                    }
                });
            });
        };
        ExcelBuilderService.prototype.prepareWorkbook = function (workbook) {
            return __awaiter(this, void 0, void 0, function () {
                var preparedWorksheets, preparedTranslatedKeys, _d;
                var _this = this;
                return __generator(this, function (_e) {
                    switch (_e.label) {
                        case 0: return [4 /*yield*/, Promise.all(workbook.worksheets.map(function (worksheet) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_d) {
                                switch (_d.label) {
                                    case 0: return [4 /*yield*/, this.prepareWorksheet(worksheet)];
                                    case 1: return [2 /*return*/, _d.sent()];
                                }
                            }); }); }))];
                        case 1:
                            preparedWorksheets = _e.sent();
                            if (!workbook.translatedKeys) return [3 /*break*/, 3];
                            return [4 /*yield*/, this.plainTableComposer.composeSingle(workbook.translatedKeys)];
                        case 2:
                            _d = _e.sent();
                            return [3 /*break*/, 4];
                        case 3:
                            _d = {};
                            _e.label = 4;
                        case 4:
                            preparedTranslatedKeys = _d;
                            return [2 /*return*/, Object.assign(Object.assign({}, workbook), { worksheets: preparedWorksheets, preparedTranslatedKeys: preparedTranslatedKeys, widthOfSymbols: widthOfSymbolsMap })];
                    }
                });
            });
        };
        ExcelBuilderService.prototype.prepareWorksheet = function (worksheet) {
            return __awaiter(this, void 0, void 0, function () {
                var flatEntries;
                return __generator(this, function (_d) {
                    switch (_d.label) {
                        case 0:
                            flatEntries = [];
                            if (!utils.isNotNil(worksheet.entries)) return [3 /*break*/, 2];
                            return [4 /*yield*/, this.plainTableComposer.compose(worksheet.entries, {
                                    includeKeys: worksheet.keys,
                                    excludeKeys: worksheet.excludeKeys
                                })];
                        case 1:
                            flatEntries = _d.sent();
                            _d.label = 2;
                        case 2: return [2 /*return*/, Object.assign(Object.assign({}, worksheet), { flatEntries: flatEntries })];
                    }
                });
            });
        };
        return ExcelBuilderService;
    }());
    /** @nocollapse */ /** @nocollapse */ ExcelBuilderService.ɵfac = function ExcelBuilderService_Factory(t) { return new (t || ExcelBuilderService)(i0__namespace.ɵɵinject(i1__namespace.PlainTableComposerService), i0__namespace.ɵɵinject(i2__namespace.WebWorkerThreadService)); };
    /** @nocollapse */ /** @nocollapse */ ExcelBuilderService.ɵprov = /** @pureOrBreakMyCode */ i0__namespace.ɵɵdefineInjectable({ token: ExcelBuilderService, factory: ExcelBuilderService.ɵfac });
    (function () {
        (typeof ngDevMode === "undefined" || ngDevMode) && i0__namespace.ɵsetClassMetadata(ExcelBuilderService, [{
                type: i0.Injectable
            }], function () { return [{ type: i1__namespace.PlainTableComposerService }, { type: i2__namespace.WebWorkerThreadService }]; }, null);
    })();

    var ExcelService = /** @class */ (function () {
        function ExcelService(interceptor, builder) {
            this.interceptor = interceptor;
            this.builder = builder;
        }
        ExcelService.prototype.exportExcel = function (workbook) {
            var _this = this;
            rxjs.firstValueFrom(this.getTranslatedColumn()
            // eslint-disable-next-line rxjs/no-topromise
            ).then(function (translatedKeys) { return __awaiter(_this, void 0, void 0, function () {
                var _a;
                return __generator(this, function (_g) {
                    switch (_g.label) {
                        case 0: return [4 /*yield*/, this.builder.exportExcelByWorkbook({
                                filename: this.interceptFilename(workbook),
                                worksheets: this.interceptWorksheets(workbook),
                                translatedKeys: (_a = translatedKeys !== null && translatedKeys !== void 0 ? translatedKeys : workbook.translatedKeys) !== null && _a !== void 0 ? _a : {}
                            })];
                        case 1:
                            _g.sent();
                            return [2 /*return*/];
                    }
                });
            }); });
        };
        ExcelService.prototype.interceptFilename = function (workbook) {
            var _a, _b, _c, _d;
            return (_d = (_c = (_b = (_a = this.interceptor).instant) === null || _b === void 0 ? void 0 : _b.call(_a, workbook.filename)) !== null && _c !== void 0 ? _c : workbook.filename) !== null && _d !== void 0 ? _d : 'UNKNOWN FILENAME';
        };
        ExcelService.prototype.interceptWorksheets = function (workbook) {
            var _this = this;
            var _a;
            return ((_a = workbook.worksheets) !== null && _a !== void 0 ? _a : []).map(function (worksheet) {
                var _a, _b, _c, _d, _e, _f;
                var worksheetName = (_d = (_c = (_b = (_a = _this.interceptor) === null || _a === void 0 ? void 0 : _a.instant) === null || _b === void 0 ? void 0 : _b.call(_a, worksheet.worksheetName)) !== null && _c !== void 0 ? _c : worksheet.worksheetName) !== null && _d !== void 0 ? _d : 'UNKNOWN WORKSHEET NAME';
                var keys = (_e = worksheet.keys) === null || _e === void 0 ? void 0 : _e.filter(array.exclude((_f = worksheet.excludeKeys) !== null && _f !== void 0 ? _f : []));
                return Object.assign(Object.assign({}, worksheet), { keys: keys, worksheetName: worksheetName });
            });
        };
        ExcelService.prototype.getTranslatedColumn = function () {
            var _a, _b, _c;
            return (_c = (_b = (_a = this.interceptor) === null || _a === void 0 ? void 0 : _a.getTranslationMap) === null || _b === void 0 ? void 0 : _b.call(_a)) !== null && _c !== void 0 ? _c : rxjs.of(null);
        };
        return ExcelService;
    }());
    /** @nocollapse */ /** @nocollapse */ ExcelService.ɵfac = function ExcelService_Factory(t) { return new (t || ExcelService)(i0__namespace.ɵɵinject(EXCEL_BUILDER_INTERCEPTOR_TOKEN), i0__namespace.ɵɵinject(ExcelBuilderService)); };
    /** @nocollapse */ /** @nocollapse */ ExcelService.ɵprov = /** @pureOrBreakMyCode */ i0__namespace.ɵɵdefineInjectable({ token: ExcelService, factory: ExcelService.ɵfac });
    (function () {
        (typeof ngDevMode === "undefined" || ngDevMode) && i0__namespace.ɵsetClassMetadata(ExcelService, [{
                type: i0.Injectable
            }], function () {
            return [{ type: undefined, decorators: [{
                            type: i0.Inject,
                            args: [EXCEL_BUILDER_INTERCEPTOR_TOKEN]
                        }] }, { type: ExcelBuilderService }];
        }, null);
    })();

    var ExcelBuilderDefaultTextColumnInterceptor = /** @class */ (function () {
        function ExcelBuilderDefaultTextColumnInterceptor() {
        }
        return ExcelBuilderDefaultTextColumnInterceptor;
    }());
    /** @nocollapse */ /** @nocollapse */ ExcelBuilderDefaultTextColumnInterceptor.ɵfac = function ExcelBuilderDefaultTextColumnInterceptor_Factory(t) { return new (t || ExcelBuilderDefaultTextColumnInterceptor)(); };
    /** @nocollapse */ /** @nocollapse */ ExcelBuilderDefaultTextColumnInterceptor.ɵprov = /** @pureOrBreakMyCode */ i0__namespace.ɵɵdefineInjectable({ token: ExcelBuilderDefaultTextColumnInterceptor, factory: ExcelBuilderDefaultTextColumnInterceptor.ɵfac });
    (function () {
        (typeof ngDevMode === "undefined" || ngDevMode) && i0__namespace.ɵsetClassMetadata(ExcelBuilderDefaultTextColumnInterceptor, [{
                type: i0.Injectable
            }], null, null);
    })();

    var ExcelBuilderModule = /** @class */ (function () {
        function ExcelBuilderModule() {
        }
        ExcelBuilderModule.forRoot = function () {
            return {
                ngModule: ExcelBuilderModule,
                providers: [
                    ExcelService,
                    ExcelBuilderService,
                    { provide: EXCEL_BUILDER_INTERCEPTOR_TOKEN, useClass: ExcelBuilderDefaultTextColumnInterceptor }
                ]
            };
        };
        return ExcelBuilderModule;
    }());
    /** @nocollapse */ /** @nocollapse */ ExcelBuilderModule.ɵfac = function ExcelBuilderModule_Factory(t) { return new (t || ExcelBuilderModule)(); };
    /** @nocollapse */ /** @nocollapse */ ExcelBuilderModule.ɵmod = /** @pureOrBreakMyCode */ i0__namespace.ɵɵdefineNgModule({ type: ExcelBuilderModule });
    /** @nocollapse */ /** @nocollapse */ ExcelBuilderModule.ɵinj = /** @pureOrBreakMyCode */ i0__namespace.ɵɵdefineInjector({ providers: [i2.WebWorkerThreadService], imports: [[i1.PlainTableComposerModule.forRoot()]] });
    (function () {
        (typeof ngDevMode === "undefined" || ngDevMode) && i0__namespace.ɵsetClassMetadata(ExcelBuilderModule, [{
                type: i0.NgModule,
                args: [{
                        imports: [i1.PlainTableComposerModule.forRoot()],
                        providers: [i2.WebWorkerThreadService]
                    }]
            }], null, null);
    })();
    (function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0__namespace.ɵɵsetNgModuleScope(ExcelBuilderModule, { imports: [i1__namespace.PlainTableComposerModule] }); })();

    var ExcelNgxTranslateInterceptor = /** @class */ (function () {
        function ExcelNgxTranslateInterceptor(translate) {
            this.translate = translate;
        }
        ExcelNgxTranslateInterceptor.prototype.instant = function (key) {
            return utils.isNotNil(key) ? this.translate.instant(key) : key;
        };
        ExcelNgxTranslateInterceptor.prototype.getTranslationMap = function () {
            var _a;
            var lang = (_a = this.translate.currentLang) !== null && _a !== void 0 ? _a : this.translate.defaultLang;
            if (utils.isNil(lang)) {
                throw new Error('Not found lang');
            }
            return this.translate.getTranslation(lang);
        };
        return ExcelNgxTranslateInterceptor;
    }());
    /** @nocollapse */ /** @nocollapse */ ExcelNgxTranslateInterceptor.ɵfac = function ExcelNgxTranslateInterceptor_Factory(t) { return new (t || ExcelNgxTranslateInterceptor)(i0__namespace.ɵɵinject(i1__namespace$1.TranslateService)); };
    /** @nocollapse */ /** @nocollapse */ ExcelNgxTranslateInterceptor.ɵprov = /** @pureOrBreakMyCode */ i0__namespace.ɵɵdefineInjectable({ token: ExcelNgxTranslateInterceptor, factory: ExcelNgxTranslateInterceptor.ɵfac });
    (function () {
        (typeof ngDevMode === "undefined" || ngDevMode) && i0__namespace.ɵsetClassMetadata(ExcelNgxTranslateInterceptor, [{
                type: i0.Injectable
            }], function () { return [{ type: i1__namespace$1.TranslateService }]; }, null);
    })();

    var EXCEL_BUILDER_NGX_TRANSLATE_FALLBACK_PROVIDER = {
        provide: EXCEL_BUILDER_INTERCEPTOR_TOKEN,
        useClass: ExcelNgxTranslateInterceptor
    };

    /**
     * Generated bundle index. Do not edit.
     */

    exports.EXCEL_BUILDER_INTERCEPTOR_TOKEN = EXCEL_BUILDER_INTERCEPTOR_TOKEN;
    exports.EXCEL_BUILDER_NGX_TRANSLATE_FALLBACK_PROVIDER = EXCEL_BUILDER_NGX_TRANSLATE_FALLBACK_PROVIDER;
    exports.ExcelBuilderDefaultTextColumnInterceptor = ExcelBuilderDefaultTextColumnInterceptor;
    exports.ExcelBuilderModule = ExcelBuilderModule;
    exports.ExcelBuilderService = ExcelBuilderService;
    exports.ExcelNgxTranslateInterceptor = ExcelNgxTranslateInterceptor;
    exports.ExcelService = ExcelService;

    Object.defineProperty(exports, '__esModule', { value: true });

}));
//# sourceMappingURL=angular-ru-cdk-excel.umd.js.map
