"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const react_1 = require("@testing-library/react");
const react_2 = __importDefault(require("react"));
const vitest_1 = require("vitest");
const provider_1 = require("../../provider");
const get_1 = require("./get");
const i18n_hooks_1 = require("./i18n.hooks");
const locales_1 = require("./locales");
(0, vitest_1.describe)("translate function throughput", () => {
    const { result } = (0, react_1.renderHook)(() => (0, i18n_hooks_1.useI18n)("FileUpload"));
    (0, vitest_1.bench)("simple key lookup (no replacements)", () => {
        result.current("item.uploading");
    });
    (0, vitest_1.bench)("key lookup with replacements", () => {
        result.current("item.uploading", { name: "Test", count: 5 });
    });
});
(0, vitest_1.describe)("translate with local overrides", () => {
    const local = {
        item: { uploading: "Hello {name}, you have {count} files" },
    };
    const { result } = (0, react_1.renderHook)(() => (0, i18n_hooks_1.useI18n)("FileUpload", local));
    (0, vitest_1.bench)("local override with replacements", () => {
        result.current("item.uploading", { name: "Test", count: 5 });
    });
});
(0, vitest_1.describe)("translate with multiple context objects", () => {
    const i18n1 = { FileUpload: { dropzone: { button: "Override" } } };
    const i18n2 = { FileUpload: { item: { uploading: "Override2" } } };
    const wrapper = ({ children }) => (react_2.default.createElement(provider_1.Provider, { locale: locales_1.nb, translations: [i18n1, i18n2] }, children));
    const { result } = (0, react_1.renderHook)(() => (0, i18n_hooks_1.useI18n)("FileUpload"), { wrapper });
    (0, vitest_1.bench)("hit in first context object", () => {
        result.current("dropzone.button");
    });
    (0, vitest_1.bench)("hit in second context object", () => {
        result.current("item.uploading");
    });
    (0, vitest_1.bench)("fallback to locale default", () => {
        result.current("item.downloading");
    });
});
(0, vitest_1.describe)("get() function throughput", () => {
    const objects = [
        undefined,
        { FileUpload: { item: { uploading: "First" } } },
        { FileUpload: { item: { downloading: "Second" } } },
        { FileUpload: locales_1.nb.FileUpload },
    ];
    (0, vitest_1.bench)("shallow key hit in first object", () => {
        (0, get_1.get)("item.uploading", objects);
    });
    (0, vitest_1.bench)("key hit in second object (skip first)", () => {
        (0, get_1.get)("item.downloading", objects);
    });
    (0, vitest_1.bench)("deep fallback to last object", () => {
        (0, get_1.get)("dropzone.button", objects);
    });
    (0, vitest_1.bench)("long key dot notation parsing", () => {
        (0, get_1.get)("dropzone.dragAndDropMultiple", [{ FileUpload: locales_1.nb.FileUpload }]);
    });
});
//# sourceMappingURL=i18n.bench.js.map