#include <ultra64.h>
#include "functions.h"
#include "variables.h"

extern f32  func_80256AB4(f32, f32, f32, f32);
extern f32  func_8025715C(f32, f32);
extern f32 *func_8038C284(ActorMarker *);
extern void func_802C8F7C(f32);
extern void func_802FDCB8(s32);

enum chvilegame_piece_type_e {
    YUMBLIE,
    GRUMBLIE
};

struct vilegame_piece{
    enum chvilegame_piece_type_e type;
    f32 position[3];
    ActorMarker *marker; //yumblie ptr;
};

typedef struct {
    u8 current_type;
    // u8 pad1[3];
    vector(struct vilegame_piece) *game_pieces;
    BKModelBin *grumblie_model_bin;
    u8 unkC;
    u8 unkD;
    u8 player_score;
    u8 vile_score;
    f32 type_change_timer;
    ActorMarker *vile_marker;
}ActorLocal_BGS_3420;

void func_8038A068(Actor *this, s32 next_state);
void chvilegame_update(Actor *this);

/* .data */
ActorInfo D_80390960 = {0xC6, 0x138, 0, 0, NULL, chvilegame_update, NULL, func_80325340, 0, 0, 0.0f, 0};
enum asset_e D_80390984[] = {    0, 0xC66, 0xC68, 0xC6A, 0xC92, 0xC93, 0xC94,    0};
enum asset_e D_803909A4[] = {    0, 0xC67, 0xC69,     0, 0xC95, 0xC96, 0xC97};
enum asset_e D_803909C0[] = {    0, 0xC6E, 0xC6F,     0, 0xC95, 0xC96, 0xC97};
enum asset_e D_803909DC[] = {0xC65, 0xC65, 0xC65, 0xC8F,     0,     0,     0};
enum asset_e D_803909F8[] = {0xC64,     0,     0, 0xC8E,     0,     0,     0,    0}; 
enum asset_e D_80390A18[] = {0xC6D, 0xC70, 0xC71, 0xC8E,     0,     0,     0,    0};

/* .code */
bool func_80389810(f32 arg0[3]) {
    if (func_8028ECAC() != 7) {
        return FALSE;
    }
    func_8028E9C4(2, arg0);
    return TRUE;
}

void func_80389850(Actor *this, s32 arg1) {
    ActorLocal_BGS_3420 *local;
    Actor *vile;
    f32 sp94[3];
    f32 sp88[3];
    f32 sp7C[3];
    s32 var_s0;
    s32 var_v0;

    local = (ActorLocal_BGS_3420 *)&this->local;
    vile = marker_getActor(local->vile_marker);
    if (arg1 != 0) {
        if (gu_sqrtf(this->position[0]*this->position[0] + this->position[1]*this->position[1] + this->position[2]*this->position[2]) < 800.0f) {
            sp7C[0] = 0.0f;
            sp7C[1] = 150.0f;
            sp7C[2] = 300.0f;
            ml_vec3f_yaw_rotate_copy(sp7C, sp7C, vile->yaw);
            sp94[0] = vile->position[0] + sp7C[0];
            sp94[1] = vile->position[1] + sp7C[1];
            sp94[2] = vile->position[2] + sp7C[2];
            func_802C8F70(vile->yaw);
            jiggySpawn(JIGGY_28_BGS_MR_VILE, sp94);
        } else {
            sp7C[0] = 0.0f - vile->position[0];
            sp7C[1] = 0.0f;
            sp7C[2] = 0.0f - vile->position[2];
            ml_vec3f_set_length(sp7C, 150.0f);
            sp7C[1] = 75.0f;
            sp94[0] = vile->position[0] + sp7C[0];
            sp94[1] = vile->position[1] + sp7C[1];
            sp94[2] = vile->position[2] + sp7C[2];
            func_802C8F70(func_8025715C(sp7C[0], sp7C[2]));
            jiggySpawn(JIGGY_28_BGS_MR_VILE, sp94);
        }
    }
    for(var_s0 = 2; var_s0 != 0x3C; var_s0++){
        var_v0 = ((var_s0 & 1)) ?  -(var_s0 / 2) * 0xA : (var_s0 / 2) * 0xA;
        sp7C[0] = 0.0f;
        sp7C[1] = 600.0f;
        sp7C[2] = 1200.0f;
        ml_vec3f_yaw_rotate_copy(sp7C, sp7C, vile->yaw + var_v0);

        sp94[0] = vile->position[0] + sp7C[0];
        sp94[1] = vile->position[1] + sp7C[1];
        sp94[2] = vile->position[2] + sp7C[2];


        sp88[0] = -30.0f;
        sp88[1] = vile->yaw + var_v0;
        sp88[2] = 0.0f;

        sp7C[2] = 0.0f;
        sp7C[1] = sp94[1];
        sp7C[0] = 0.0f;
        if(ml_vec3f_distance(sp94, sp7C) <= 1000.0f){
            break;
        }
    }
    func_802BAE6C(sp94, sp88);
}

void func_80389B48(ActorMarker *marker, enum asset_e text_id, s32 arg2){
    Actor *this;

    this = marker_getActor(marker);
    if(arg2 == 1){
        func_8038A068(this, 4);
    }
    else{
        func_8038A068(this, 3);
    }
}

void func_80389B98(ActorMarker *marker, enum asset_e text_id, s32 arg2){
    Actor *this;

    this = marker_getActor(marker);
    func_8038A068(this, 1);
}

void func_80389BC8(ActorMarker *marker, enum asset_e text_id, s32 arg2){
    Actor *this;

    this = marker_getActor(marker);
    func_8038A068(this, 5);
}

void func_80389BF8(ActorMarker *marker, enum asset_e text_id, s32 arg2) {
    Actor *this;
    ActorLocal_BGS_3420 *local;

    this = marker_getActor(marker);
    local = (ActorLocal_BGS_3420 *)&this->local;
    func_80324E88(0.0f);
    func_80324E38(0.0f, 0);
    local->unkC--;
    func_8038A068(this, 7);
}

void func_80389C58(ActorMarker *marker) {
    Actor *this;
    ActorLocal_BGS_3420 *local;

    this = marker_getActor(marker);
    local = (ActorLocal_BGS_3420 *)&this->local;
    func_80389850(this, 0);
    func_80311480(D_80390984[local->unkC], 0xF, func_8038C284(local->vile_marker), this->marker, func_80389BF8, NULL);
}

void func_80389CD8(ActorMarker *marker, enum asset_e text_id, s32 arg2){
    Actor *this;

    this = marker_getActor(marker);
    func_80324E88(0.0f);
    func_80324E38(0.0f, 0);
    func_8038A068(this, 5);
}

void func_80389D20(ActorMarker *marker) {
    Actor *this;
    ActorLocal_BGS_3420 *local;

    this = marker_getActor(marker);
    local = (ActorLocal_BGS_3420 *)&this->local;
    func_80389850(this, 0);
    if (local->unkC == local->unkD) {
        func_80311480(D_803909A4[local->unkC], 0xF, func_8038C284(local->vile_marker), this->marker, func_80389CD8, NULL);
    } else {
        func_80311480(D_803909C0[local->unkC], 0xF, func_8038C284(local->vile_marker), this->marker, func_80389CD8, NULL);
    }
    func_80347A14(0);
}

void func_80389DF8(ActorMarker *marker, enum asset_e text_id, s32 arg2){
    Actor *this;

    this = marker_getActor(marker);
    func_80324E88(0.0f);
    func_80324E38(0.0f, 0);
    func_8038A068(this, 1);
}

void func_80389E40(ActorMarker *marker) {
    Actor *this;
    ActorLocal_BGS_3420 *local;

    this = marker_getActor(marker);
    local = (ActorLocal_BGS_3420 *)&this->local;

    func_80389850(this, 1);
    func_80311480(0xC6B, 0xF, func_8038C284(local->vile_marker), this->marker, func_80389DF8, NULL);
}

void func_80389EAC(ActorMarker *marker, enum asset_e text_id, s32 arg2){
    Actor *this;
    ActorLocal_BGS_3420 *local;

    this = marker_getActor(marker);
    local = (ActorLocal_BGS_3420 *)&this->local;
    func_80324E88(0.0f);
    func_80324E38(0.0f, 0);
    local->unkC = 3;
    func_8038A068(this, 1);
}

void func_80389F08(ActorMarker *marker) {
    Actor *vile;
    Actor *this;
    ActorLocal_BGS_3420 *local;
    s32 i;
    s32 var_s2;

    this = marker_getActor(marker);
    local = (ActorLocal_BGS_3420 *)&this->local;
    func_80389850(this, 0);
    var_s2 = func_80326F58(0x49);
    vile = marker_getActor(local->vile_marker);
    if (var_s2 > 0) {
        func_8025A6EC(COMUSIC_15_EXTRA_LIFE_COLLECTED, 0x7FF8);
    }
    for(i = 0; i < 3; i++){
        if (var_s2 < 3) {
            func_802C8F70(vile->yaw + (f32) (i * 30));
            func_802C8F7C(2.0f);
            func_802C937C(6, vile->position);
            var_s2 += 1;
        } else {
            item_inc(ITEM_16_LIFE);
        }
    }
    func_80311480(0xC98, 0xF, func_8038C284(local->vile_marker), this->marker, func_80389EAC, NULL);
}


void func_8038A044(void){
    func_8025A58C(-1, 400);
}

void func_8038A068(Actor *this, s32 next_state) {
    ActorLocal_BGS_3420 *local;

    local = (ActorLocal_BGS_3420 *)&this->local;
    mapSpecificFlags_set(6, FALSE);
    if (next_state == 1) {
        if (local->vile_marker != NULL) {
            func_8038C408(local->vile_marker);
        }
    }
    if (next_state == 2) {
        func_8038C3B0(local->vile_marker);
        if (local->unkC == 3) {
            if (local->unkD >= 4) {
                func_80311480(0xC91, 0xE, func_8038C284(local->vile_marker), this->marker, func_80389B48, NULL);
            } else {
                func_80311480((local->unkC == local->unkD) ? 0xC8D : 0xC90, 0xE, func_8038C284(local->vile_marker), this->marker, func_80389B48, NULL);
            }
        } else {
            func_80311480((local->unkC == local->unkD) ? 0xC63 : 0xC6C, 0xE, func_8038C284(local->vile_marker), this->marker, func_80389B48, NULL);
        }
    }
    if (next_state == 3) {
        func_80311480(D_803909DC[local->unkC], 4, func_8038C284(local->vile_marker), this->marker, func_80389B98, NULL);
    }
    if (next_state == 4) {
        if (local->unkC == local->unkD) {
            func_80311480(D_803909F8[local->unkC], 0xE | ((D_803909F8[local->unkC] == 0xC8E) ? 1 : 0) | 0xE, func_8038C284(local->vile_marker), this->marker, func_80389BC8, NULL);
        } else {
            func_80311480(D_80390A18[local->unkC], 0xF , func_8038C284(local->vile_marker), this->marker, func_80389BC8, NULL);
        }
        func_80347A14(0);
    }
    if (next_state == 5) {
        local->unkC++;
        if (local->unkD < local->unkC) {
            local->unkD = local->unkC;
        }
        if (local->unkC == 7) {
            func_8038C434(local->vile_marker);
        } else {
            local->current_type = YUMBLIE;
            local->player_score = 0;
            local->vile_score = 0;
            if (func_803203FC(2) != 0) {
                local->type_change_timer = 5.0f;
            } else {
                local->type_change_timer = 10.0f;
            }
            item_set(ITEM_0_HOURGLASS_TIMER, 3600-1);
            item_set(ITEM_6_HOURGLASS, TRUE);
            mapSpecificFlags_set(6, TRUE);
            func_8038C3DC(local->vile_marker);
            func_8025A58C(0, 4000);
            timedFunc_set_2(1.0f, func_8025A6EC, COMUSIC_55_BGS_MR_VILE, 28000);
        }
    }
    if (this->state == 5) {
        if (local->unkC != 7) {
            item_set(ITEM_6_HOURGLASS, FALSE);
            if ((next_state != 6) && (next_state != 8) && (next_state != 9)) {
                func_8038A044();
            }
        }
        func_8038C460(local->vile_marker);
        func_80347A14(1);
    }
    if (next_state == 6) {
        func_8038C3B0(local->vile_marker);
        func_80324E38(0.0f, 3);
        timedFunc_set_2(1.0f, func_8025A6EC, COMUSIC_3C_MINIGAME_LOSS, 28000);
        timedFunc_set_0(4.0f, func_8038A044);
        timedFunc_set_1(4.0f, func_80389C58, (s32) this->marker);
    }
    if (next_state == 8) {
        func_8038C3B0(local->vile_marker);
        func_80324E38(0.0f, 3);
        timedFunc_set_2(1.0f, func_8025A6EC, COMUSIC_3B_MINIGAME_VICTORY, 28000);
        timedFunc_set_0(3.0f, func_8038A044);
        timedFunc_set_1(3.0f, func_80389D20, (s32) this->marker);
    }
    if (next_state == 9) {
        func_8038C3B0(local->vile_marker);
        func_80324E38(0.0f, 3);
        timedFunc_set_2(1.0f, func_8025A6EC, COMUSIC_3B_MINIGAME_VICTORY, 28000);
        timedFunc_set_0(3.0f, func_8038A044);
        timedFunc_set_1(3.0f, func_80389E40, (s32) this->marker);
    }
    if (next_state == 0xA) {
        func_8038C3B0(local->vile_marker);
        func_80324E38(0.5f, 3);
        timedFunc_set_2(1.0f, func_8025A6EC, COMUSIC_3B_MINIGAME_VICTORY, 28000);
        timedFunc_set_1(3.0f, func_80389F08, (s32) this->marker);
    }
    if (next_state == 7) {
        func_8038C384(local->vile_marker);
    }
    this->state = next_state;
}

void chvilegame_player_consume_piece(Actor *this) {
    ActorLocal_BGS_3420 *local;
    bool is_correct_type;
    f32 sp44[3];
    struct vilegame_piece *begin;
    struct vilegame_piece *end;
    struct vilegame_piece *i_ptr;

    local = (ActorLocal_BGS_3420 *)&this->local;

    begin = (struct vilegame_piece *)vector_getBegin(local->game_pieces);
    end = (struct vilegame_piece *) vector_getEnd(local->game_pieces);
    if ((end != begin) && func_80389810(sp44)){
        sp44[1] = 0.0f;
        for(i_ptr = begin; i_ptr < end; i_ptr++){
            if ((ml_vec3f_distance(i_ptr->position, sp44) < 65.25) && chyumblie_is_edible(i_ptr->marker)) {
                is_correct_type = ((local->current_type != YUMBLIE) && (i_ptr->type != YUMBLIE)) || (((local->current_type == YUMBLIE) && i_ptr->type == YUMBLIE));
                if (is_correct_type) {
                    local->player_score++;
                    if (local->player_score == 35) {
                        item_inc(ITEM_16_LIFE);
                        func_8025A6EC(COMUSIC_15_EXTRA_LIFE_COLLECTED, 0x7FF8);
                    }
                    timedFunc_set_1(0.0f, func_802FDCB8, 0x1A);
                    timedFunc_set_1(0.5f, func_802FDCB8, 0x1A);
                    timedFunc_set_1(1.0f, func_802FDCB8, 0x1A);
                }
                func_8028F6B8(0x17, (i_ptr->type != YUMBLIE) ? 0x3F7 : 0x3F6);
                if (!is_correct_type) {
                    func_8028F66C(0x18);
                }
                func_8038B684(i_ptr->marker);
                return;
            }
        }
    }
}

bool chvilegame_cpu_consume_piece(ActorMarker *marker, f32 position[3]) {
    Actor *this;
    ActorLocal_BGS_3420 *local;
    struct vilegame_piece *begin;
    struct vilegame_piece *end;
    struct vilegame_piece *i_ptr;

    this = marker_getActor(marker);
    local = (ActorLocal_BGS_3420 *)&this->local;
    if (this->state != 5){
        return FALSE;
    }
    begin = vector_getBegin(local->game_pieces);
    end = vector_getEnd(local->game_pieces);
    for(i_ptr = begin; i_ptr < end; i_ptr++){
        if ((ml_vec3f_distance(i_ptr->position, position) < 50.0f) && func_8038B684(i_ptr->marker)) {
            local->vile_score++;
            timedFunc_set_1(0.0f, func_802FDCB8, 0x1B);
            timedFunc_set_1(0.5f, func_802FDCB8, 0x1B);
            timedFunc_set_1(1.0f, func_802FDCB8, 0x1B);
            return TRUE;
        }
    }
    return FALSE;
}

BKModelBin *chvilegame_get_grumblie_model(ActorMarker *marker){
    Actor *this;
    ActorLocal_BGS_3420 *local;


    this = marker_getActor(marker);
    local = (ActorLocal_BGS_3420 *)&this->local;
    return local->grumblie_model_bin;
}

s32 chvilegame_get_piece_count(ActorMarker *marker){
    Actor *this;
    ActorLocal_BGS_3420 *local;


    this = marker_getActor(marker);
    local = (ActorLocal_BGS_3420 *)&this->local;
    return vector_size(local->game_pieces);
}

s32 func_8038A9E0(ActorMarker *marker){
    Actor *this;
    ActorLocal_BGS_3420 *local;


    this = marker_getActor(marker);
    local = (ActorLocal_BGS_3420 *)&this->local;
    return local->unkC;
}

s32 chvilegame_get_score_difference(ActorMarker *marker){
    Actor *this;
    ActorLocal_BGS_3420 *local;


    this = marker_getActor(marker);
    local = (ActorLocal_BGS_3420 *)&this->local;
    return local->vile_score - local->player_score;
}

bool chvilegame_find_closest_piece(ActorMarker *marker, f32 position[0], f32 yaw, f32 dst[3]) {
    f32 piece_direction[3];
    f32 target_direction[3];
    Actor *this;
    ActorLocal_BGS_3420 *local;
    struct vilegame_piece *closest_piece;
    struct vilegame_piece *begin;
    struct vilegame_piece *end;
    struct vilegame_piece *i_ptr;
    f32 distance;
    f32 angle_diff;

    this = marker_getActor(marker);
    local = (ActorLocal_BGS_3420 *)&this->local;
    target_direction[0] = 0.0f;
    target_direction[1] = 0.0f;
    target_direction[2] = 100.0f;
    ml_vec3f_yaw_rotate_copy(target_direction, target_direction, yaw);
    closest_piece = NULL;
    begin = (struct vilegame_piece *) vector_getBegin(local->game_pieces);
    end = (struct vilegame_piece *) vector_getEnd(local->game_pieces);
    for(i_ptr = begin; i_ptr < end; i_ptr++){
        if( ((local->current_type != YUMBLIE) && (i_ptr->type != YUMBLIE)) 
            || ((local->current_type == YUMBLIE) && (i_ptr->type == YUMBLIE))
        ){
            piece_direction[0] = i_ptr->position[0] - position[0];
            piece_direction[1] = i_ptr->position[1] - position[1];
            piece_direction[2] = i_ptr->position[2] - position[2];
            distance = ml_vec3f_distance(i_ptr->position, position);
            angle_diff = func_80256AB4(target_direction[0], target_direction[2], piece_direction[0], piece_direction[2]);
            if( (distance > 300.0f) 
                || ((-0.8 < angle_diff) && (angle_diff < 0.8) && ((piece_direction[0]*target_direction[0] + piece_direction[1]*target_direction[1] + piece_direction[2]*target_direction[2]) >= 0.0f))
            ) {
                if ((closest_piece == NULL) || (distance < ml_vec3f_distance(position, closest_piece->position))){
                    closest_piece = i_ptr;
                }
            }
        }
    }
    if (closest_piece != NULL) {
        dst[0] = closest_piece->position[0];
        dst[1] = closest_piece->position[1];
        dst[2] = closest_piece->position[2];
        return TRUE;
    }
    return FALSE;
}

void chvilegame_new_piece(ActorMarker *game_marker, ActorMarker *piece_marker, f32 position[3], enum chvilegame_piece_type_e yumblie_type){
    Actor *this;
    ActorLocal_BGS_3420 *local;
    struct vilegame_piece *temp_v0;

    this = marker_getActor(game_marker);
    local = (ActorLocal_BGS_3420 *)&this->local;
    temp_v0 = (struct vilegame_piece *)vector_pushBackNew(&local->game_pieces);
    temp_v0->type = yumblie_type;
    temp_v0->marker = piece_marker;
    temp_v0->position[0] = position[0];
    temp_v0->position[1] = position[1];
    temp_v0->position[2] = position[2];
    temp_v0->position[1] = 0.0f;
}

void chvilegame_free(Actor *this){
    ActorLocal_BGS_3420 *local;

    local = (ActorLocal_BGS_3420 *)&this->local;
    func_8038A068(this, 0);
    vector_free(local->game_pieces);
    assetcache_release(local->grumblie_model_bin);
}

void chvilegame_remove_piece(ActorMarker *game_marker, ActorMarker *piece_marker) {
    Actor *this;
    ActorLocal_BGS_3420 *local;
    struct vilegame_piece *begin;
    struct vilegame_piece *end;
    struct vilegame_piece *i_ptr;

    this = marker_getActor(game_marker);
    local = (ActorLocal_BGS_3420 *)&this->local;
    begin = (struct vilegame_piece *)vector_getBegin(local->game_pieces);
    end = (struct vilegame_piece *)vector_getEnd(local->game_pieces);
    for(i_ptr = begin; i_ptr < end; i_ptr++){
        if (piece_marker == i_ptr->marker) {
            vector_remove(local->game_pieces, i_ptr - begin);
            return;
        }
    }
}

void chvilegame_update(Actor *this) {
    ActorLocal_BGS_3420 *local;
    f32 sp50;
    f32 sp4C;
    u8 temp_v0;
    s32 sp30[6];
    s32 sp2C;

    sp50 = time_getDelta();
    local = (ActorLocal_BGS_3420 *)&this->local;
    if (!this->unk16C_4) {
        this->unk16C_4 = TRUE;
        this->marker->unk30 = &chvilegame_free;
        local->game_pieces = vector_new(sizeof(struct vilegame_piece), 0x20);
        local->grumblie_model_bin = assetcache_get(0x3F7);
        local->unkC = 0;
        local->vile_marker = NULL;
        if (this->state == 0) {
            local->unkD = 0;
        } else {
            this->state = 0;
        }
        if (jiggyscore_isSpawned(JIGGY_28_BGS_MR_VILE)) {
            local->unkC = 3;
            local->unkD = 3;
        }
        if (func_803203FC(2)) {
            local->unkC = 2;
            local->unkD = 3;
        }
        func_8038A068(this, 1);
        return;
    }
    if (local->vile_marker == NULL) {
        local->vile_marker = func_80326D68(this->position, 0x13A, -1, &sp4C)->marker;
    }
    if (this->state == 1) {
        if (func_803203FC(2)) {
            if (func_803203FC(3)) {
                func_8038A068(this, 5);
            }
        } else if (func_8038C2A8(local->vile_marker)) {
            func_8038A068(this, 2);
        }
    }
    if (this->state == 5) {
        if (local->unkC == 7) {
            func_8024E55C(0, sp30);
            if ((sp30[BUTTON_Z] > 0) && func_8038C2A8(local->vile_marker)) {
                func_8038A068(this, 0xA);
            }
        } else {
            chvilegame_player_consume_piece(this);
            if ((local->unkC == 3) || (local->unkC == 6)) {
                if (func_8025773C(&local->type_change_timer, sp50)) {
                    local->current_type = !local->current_type;
                    if (func_803203FC(2)) {
                        local->type_change_timer = 5.0f;
                    } else {
                        local->type_change_timer = 10.0f;
                    }
                }
                if (local->type_change_timer > 3.5) {
                    if (local->current_type != 0) {
                        func_803463D4(ITEM_1D_GRUMBLIE, FALSE);
                    } else {
                        func_803463D4(ITEM_1E_YUMBLIE, FALSE);
                    }
                }
            }
            sp2C = item_getCount(ITEM_1A_PLAYER_VILE_SCORE);
            item_set(ITEM_1A_PLAYER_VILE_SCORE, local->player_score);
            item_set(ITEM_1B_VILE_VILE_SCORE, local->vile_score);
            if ((sp2C != 0) && (local->player_score == 0)) {
                func_802FA5D0();
            }
            if (item_empty(ITEM_6_HOURGLASS)) {
                if (func_803203FC(2)) {
                    func_803204E4(3, 0);
                    func_803204E4(5, ( local->vile_score < local->player_score) ? TRUE : FALSE);
                    func_8038A068(this, 1);
                } else if (local->vile_score < local->player_score) {
                    if (local->unkC == 3) {
                        func_8038A068(this, 9);
                    } else {
                        func_8038A068(this, 8);
                    }
                } else {
                    func_8038A068(this, 6);
                }
            }
        }
    }
    if ((this->state == 7) && (func_8038C338(local->vile_marker) != 0)) {
        func_8038A068(this, 1);
    }
}
