"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.TimewarpedChameleon = void 0;
const golden_1 = require("../../../simulation/utils/golden");
const utils_1 = require("../../../utils");
const card_interface_1 = require("../../card.interface");
const _card_mappings_1 = require("../_card-mappings");
exports.TimewarpedChameleon = {
    cardIds: ["BG34_Giant_042", "BG34_Giant_042_G"],
    startOfCombatTiming: 'start-of-combat',
    startOfCombat: (minion, input) => {
        const board = input.playerBoard.filter((e) => e.health > 0 && !e.definitelyDead);
        const chameleonIndex = input.playerBoard.findIndex((entity) => entity.entityId === minion.entityId);
        if (chameleonIndex > 0) {
            const minionToTheLeft = board[chameleonIndex - 1];
            if (!!minionToTheLeft) {
                const clone = {
                    ...(0, utils_1.copyEntity)(minionToTheLeft),
                    entityId: input.gameState.sharedState.currentEntityId++,
                };
                if (minion.cardId === "BG34_Giant_042_G") {
                    (0, golden_1.makeMinionGolden)(clone, minion, input.playerBoard, input.playerEntity, input.opponentBoard, input.opponentEntity, input.gameState);
                }
                input.playerBoard.splice(chameleonIndex, 1, clone);
                input.gameState.spectator.registerPowerTarget(minion, minionToTheLeft, input.playerBoard, input.playerEntity, input.opponentEntity);
                const onSpawnedImpl = _card_mappings_1.cardMappings[clone.cardId];
                if ((0, card_interface_1.hasOnSpawned)(onSpawnedImpl)) {
                    onSpawnedImpl.onSpawned(clone, {
                        hero: input.playerEntity,
                        board: board,
                        gameState: input.gameState,
                        applyAttackAuras: true,
                        applyHealthAuras: true,
                    });
                }
                return { hasTriggered: true, shouldRecomputeCurrentAttacker: false };
            }
        }
        return { hasTriggered: false, shouldRecomputeCurrentAttacker: false };
    },
};
//# sourceMappingURL=timewarped-chameleon.js.map