"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
exports.executeCloneArticleOperation = function (_a, articleQuery, scheduler, productDataManager) {
    var comId = _a.comId, initialPlacement = _a.initialPlacement, data = _a.data;
    return tslib_1.__awaiter(void 0, void 0, void 0, function () {
        var newComId, _b, articleId, categories, type, articleNumber;
        return tslib_1.__generator(this, function (_c) {
            switch (_c.label) {
                case 0: return [4 /*yield*/, scheduler.queueOperation(comId, function () {
                        return productDataManager.duplicateArticle(comId);
                    })];
                case 1:
                    newComId = _c.sent();
                    _b = articleQuery.getArticleByComId(comId), articleId = _b.articleId, categories = _b.categories, type = _b.type, articleNumber = _b.articleNumber;
                    return [2 /*return*/, [
                            {
                                type: "create",
                                comId: newComId,
                                articleNumber: articleNumber !== undefined
                                    ? articleNumber
                                    : {
                                        baseArticleNumber: articleId,
                                    },
                                categories: categories,
                                placement: initialPlacement,
                                data: data,
                                articleType: type,
                            },
                        ]];
            }
        });
    });
};
