// File: fulhax[P]ncpamixer/src/ui/tab.cpp
// Function: Tab::handleEvents(char const* const&)
void Tab::handleEvents(const char* const &event)
{
    if (object == nullptr) {
        return;
    }

    selected_index = pulse.exists(*object, selected_index);

    if (selected_index == static_cast<uint32_t>(-1)) {
        return;
    }

    auto pai = object->find(selected_index);

    PaObject *selected_pobj = nullptr;

    if (pai != object->end()) {
        selected_pobj = pai->second;
    }

    if (!strcmp("mute", event)) {
        if (selected_pobj != nullptr) {
            selected_pobj->toggle_mute();
        }
    } else if (!strcmp("move_first", event)) {
        auto i = object->begin();

        if (i != object->end()) {
            selected_index = i->first;
            selected_block = 0;
        }

    } else if (!strcmp("move_last", event)) {
        auto i = object->rbegin();

        if (i != object->rend()) {
            selected_index = i->first;
            selected_block = object->size() - 1;
        }
    } else if (!strcmp("move_up", event)) {
        auto i = std::prev(object->find(selected_index), 1);

        if (i != object->end()) {
            selected_index = i->first;
            selected_block = (selected_block > 0) ? selected_block - 1 : 0;
        }
    } else if (!strcmp("move_down", event)) {
        auto i = std::next(object->find(selected_index), 1);

        if (i != object->end()) {
            selected_index = i->first;
            selected_block++;
        }
    } else if (!strcmp("toggle_static", event)) {
        ui.static_bar = !ui.static_bar;
    } else if (!strcmp("volume_up", event)) {
        if (selected_pobj != nullptr) {
            selected_pobj->step_volume(1);
        }
    } else if (!strcmp("volume_down", event)) {
        if (selected_pobj != nullptr) {
            selected_pobj->step_volume(-1);
        }
    } else if (!strcmp("set_volume_0", event)) {
        if (selected_pobj != nullptr) {
            selected_pobj->set_volume(0);
        }
    } else if (!strcmp("set_volume_10", event)) {
        if (selected_pobj != nullptr) {
            selected_pobj->set_volume(.1f);
        }
    } else if (!strcmp("set_volume_20", event)) {
        if (selected_pobj != nullptr) {
            selected_pobj->set_volume(.2f);
        }
    } else if (!strcmp("set_volume_30", event)) {
        if (selected_pobj != nullptr) {
            selected_pobj->set_volume(.3f);
        }
    } else if (!strcmp("set_volume_40", event)) {
        if (selected_pobj != nullptr) {
            selected_pobj->set_volume(.4f);
        }
    } else if (!strcmp("set_volume_50", event)) {
        if (selected_pobj != nullptr) {
            selected_pobj->set_volume(.5f);
        }
    } else if (!strcmp("set_volume_60", event)) {
        if (selected_pobj != nullptr) {
            selected_pobj->set_volume(.6f);
        }
    } else if (!strcmp("set_volume_70", event)) {
        if (selected_pobj != nullptr) {
            selected_pobj->set_volume(.7f);
        }
    } else if (!strcmp("set_volume_80", event)) {
        if (selected_pobj != nullptr) {
            selected_pobj->set_volume(.8f);
        }
    } else if (!strcmp("set_volume_90", event)) {
        if (selected_pobj != nullptr) {
            selected_pobj->set_volume(.9f);
        }
    } else if (!strcmp("set_volume_100", event)) {
        if (selected_pobj != nullptr) {
            selected_pobj->set_volume(1.0f);
        }
    } else if (!strcmp("set_default", event)) {
        if (selected_pobj != nullptr) {
            selected_pobj->set_default(selected_pobj->pa_name);
        }
    } else if (!strcmp("switch", event)) {
        if (selected_pobj != nullptr && toggle != nullptr) {
            auto current_toggle = toggle->find(selected_pobj->getRelation());
            current_toggle = std::next(current_toggle, 1);

            if (current_toggle == toggle->end()) {
                current_toggle = toggle->begin();
            }

            selected_pobj->move(current_toggle->first);
        } else if (selected_pobj != nullptr) {
            uint32_t current_attribute = selected_pobj->getRelation();

            if (current_attribute + 1 < selected_pobj->attributes.size()) {
                current_attribute++;
            } else {
                current_attribute = 0;
            }

            if (selected_pobj->attributes.size() > 0) {
                selected_pobj->set_active_attribute(
                    selected_pobj->attributes[current_attribute]->name
                );
            }
        }
    } else if (!strcmp("dropdown", event) || !strcmp("select", event)) {
        handleDropDown(selected_pobj);
    }
}

// Assembly:
subq $0x138, %rsp            # imm = 0x138
movq %rdi, 0x130(%rsp)
movq %rsi, 0x128(%rsp)
movq 0x130(%rsp), %rax
movq %rax, 0x40(%rsp)
cmpq $0x0, 0x10(%rax)
jne 0x18750
jmp 0x1912d
movq 0x40(%rsp), %rax
movq 0x10(%rax), %rsi
leaq 0xf8(%rsp), %rdi
movq %rdi, 0x30(%rsp)
callq 0x1b110
movq 0x40(%rsp), %rax
movq 0x30(%rsp), %rdi
movl 0xc(%rax), %esi
callq 0xb900
movl %eax, 0x3c(%rsp)
jmp 0x18783
movq 0x40(%rsp), %rax
movl 0x3c(%rsp), %ecx
movl %ecx, 0xc(%rax)
leaq 0xf8(%rsp), %rdi
callq 0xd070
movq 0x40(%rsp), %rax
cmpl $-0x1, 0xc(%rax)
jne 0x187d2
jmp 0x1912d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xf0(%rsp)
movl %eax, 0xec(%rsp)
leaq 0xf8(%rsp), %rdi
callq 0xd070
jmp 0x19135
movq 0x40(%rsp), %rsi
movq 0x10(%rsi), %rdi
addq $0xc, %rsi
callq 0xd330
movq %rax, %rcx
movq 0x40(%rsp), %rax
movq %rcx, 0xe0(%rsp)
movq $0x0, 0xd8(%rsp)
movq 0x10(%rax), %rdi
callq 0xd200
movq %rax, 0xd0(%rsp)
leaq 0xe0(%rsp), %rdi
leaq 0xd0(%rsp), %rsi
callq 0xd1e0
testb $0x1, %al
jne 0x1882c
jmp 0x18845
leaq 0xe0(%rsp), %rdi
callq 0xd230
movq 0x8(%rax), %rax
movq %rax, 0xd8(%rsp)
movq 0x128(%rsp), %rax
movq (%rax), %rsi
leaq 0x9184(%rip), %rdi      # 0x219db
callq 0x7980
cmpl $0x0, %eax
jne 0x1887e
cmpq $0x0, 0xd8(%rsp)
je 0x18879
movq 0xd8(%rsp), %rdi
callq 0x8ff0
jmp 0x1912d
movq 0x128(%rsp), %rax
movq (%rax), %rsi
leaq 0x9150(%rip), %rdi      # 0x219e0
callq 0x7980
cmpl $0x0, %eax
jne 0x1890a
movq 0x40(%rsp), %rax
movq 0x10(%rax), %rdi
callq 0xd1b0
movq %rax, %rcx
movq 0x40(%rsp), %rax
movq %rcx, 0xc8(%rsp)
movq 0x10(%rax), %rdi
callq 0xd200
movq %rax, 0xc0(%rsp)
leaq 0xc8(%rsp), %rdi
leaq 0xc0(%rsp), %rsi
callq 0xd1e0
testb $0x1, %al
jne 0x188e4
jmp 0x18905
leaq 0xc8(%rsp), %rdi
callq 0xd230
movq %rax, %rcx
movq 0x40(%rsp), %rax
movl (%rcx), %ecx
movl %ecx, 0xc(%rax)
movl $0x0, 0x20(%rax)
jmp 0x1912b
movq 0x128(%rsp), %rax
movq (%rax), %rsi
leaq 0x90cf(%rip), %rdi      # 0x219eb
callq 0x7980
cmpl $0x0, %eax
jne 0x189a4
movq 0x40(%rsp), %rax
movq 0x10(%rax), %rsi
leaq 0xb8(%rsp), %rdi
callq 0x1b140
movq 0x40(%rsp), %rax
movq 0x10(%rax), %rsi
leaq 0xb0(%rsp), %rdi
callq 0x1b1a0
leaq 0xb8(%rsp), %rdi
leaq 0xb0(%rsp), %rsi
callq 0x1b170
testb $0x1, %al
jne 0x1896d
jmp 0x1899f
leaq 0xb8(%rsp), %rdi
callq 0x1b1d0
movq %rax, %rcx
movq 0x40(%rsp), %rax
movl (%rcx), %ecx
movl %ecx, 0xc(%rax)
movq 0x10(%rax), %rdi
callq 0x1b210
movq %rax, %rcx
movq 0x40(%rsp), %rax
subq $0x1, %rcx
movl %ecx, 0x20(%rax)
jmp 0x19129
movq 0x128(%rsp), %rax
movq (%rax), %rsi
leaq 0x903f(%rip), %rdi      # 0x219f5
callq 0x7980
cmpl $0x0, %eax
jne 0x18a76
movq 0x40(%rsp), %rsi
movq 0x10(%rsi), %rdi
addq $0xc, %rsi
callq 0xd330
movq %rax, 0xa0(%rsp)
movq 0xa0(%rsp), %rdi
movl $0x1, %esi
callq 0x1b220
movq %rax, %rcx
movq 0x40(%rsp), %rax
movq %rcx, 0xa8(%rsp)
movq 0x10(%rax), %rdi
callq 0xd200
movq %rax, 0x98(%rsp)
leaq 0xa8(%rsp), %rdi
leaq 0x98(%rsp), %rsi
callq 0xd1e0
testb $0x1, %al
jne 0x18a2c
jmp 0x18a71
leaq 0xa8(%rsp), %rdi
callq 0xd230
movq %rax, %rcx
movq 0x40(%rsp), %rax
movl (%rcx), %ecx
movl %ecx, 0xc(%rax)
cmpl $0x0, 0x20(%rax)
jle 0x18a5d
movq 0x40(%rsp), %rax
movl 0x20(%rax), %eax
subl $0x1, %eax
movl %eax, 0x2c(%rsp)
jmp 0x18a65
xorl %eax, %eax
movl %eax, 0x2c(%rsp)
jmp 0x18a65
movq 0x40(%rsp), %rax
movl 0x2c(%rsp), %ecx
movl %ecx, 0x20(%rax)
jmp 0x19127
movq 0x128(%rsp), %rax
movq (%rax), %rsi
leaq 0x8f75(%rip), %rdi      # 0x219fd
callq 0x7980
cmpl $0x0, %eax
jne 0x18b26
movq 0x40(%rsp), %rsi
movq 0x10(%rsi), %rdi
addq $0xc, %rsi
callq 0xd330
movq %rax, 0x88(%rsp)
movq 0x88(%rsp), %rdi
movl $0x1, %esi
callq 0x1b260
movq %rax, %rcx
movq 0x40(%rsp), %rax
movq %rcx, 0x90(%rsp)
movq 0x10(%rax), %rdi
callq 0xd200
movq %rax, 0x80(%rsp)
leaq 0x90(%rsp), %rdi
leaq 0x80(%rsp), %rsi
callq 0xd1e0
testb $0x1, %al
jne 0x18afe
jmp 0x18b21
leaq 0x90(%rsp), %rdi
callq 0xd230
movq %rax, %rcx
movq 0x40(%rsp), %rax
movl (%rcx), %ecx
movl %ecx, 0xc(%rax)
movl 0x20(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x20(%rax)
jmp 0x19125
movq 0x128(%rsp), %rax
movq (%rax), %rsi
leaq 0x8ecf(%rip), %rdi      # 0x21a07
callq 0x7980
cmpl $0x0, %eax
jne 0x18b67
leaq 0x12daf(%rip), %rax     # 0x2b8f8
movb 0x103(%rax), %cl
xorb $-0x1, %cl
andb $0x1, %cl
leaq 0x12d9c(%rip), %rax     # 0x2b8f8
movb %cl, 0x103(%rax)
jmp 0x19123
movq 0x128(%rsp), %rax
movq (%rax), %rsi
leaq 0x8e9c(%rip), %rdi      # 0x21a15
callq 0x7980
cmpl $0x0, %eax
jne 0x18ba5
cmpq $0x0, 0xd8(%rsp)
je 0x18ba0
movq 0xd8(%rsp), %rdi
movl $0x1, %esi
callq 0x8f80
jmp 0x19121
movq 0x128(%rsp), %rax
movq (%rax), %rsi
leaq 0x8e68(%rip), %rdi      # 0x21a1f
callq 0x7980
cmpl $0x0, %eax
jne 0x18be3
cmpq $0x0, 0xd8(%rsp)
je 0x18bde
movq 0xd8(%rsp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x8f80
jmp 0x1911f
movq 0x128(%rsp), %rax
movq (%rax), %rsi
leaq 0x8e36(%rip), %rdi      # 0x21a2b
callq 0x7980
cmpl $0x0, %eax
jne 0x18c1f
cmpq $0x0, 0xd8(%rsp)
je 0x18c1a
movq 0xd8(%rsp), %rdi
xorps %xmm0, %xmm0
callq 0x8ea0
jmp 0x1911d
movq 0x128(%rsp), %rax
movq (%rax), %rsi
leaq 0x8e07(%rip), %rdi      # 0x21a38
callq 0x7980
cmpl $0x0, %eax
jne 0x18c60
cmpq $0x0, 0xd8(%rsp)
je 0x18c5b
movq 0xd8(%rsp), %rdi
movss 0x8d1a(%rip), %xmm0     # 0x21970
callq 0x8ea0
jmp 0x1911b
movq 0x128(%rsp), %rax
movq (%rax), %rsi
leaq 0x8dd4(%rip), %rdi      # 0x21a46
callq 0x7980
cmpl $0x0, %eax
jne 0x18ca1
cmpq $0x0, 0xd8(%rsp)
je 0x18c9c
movq 0xd8(%rsp), %rdi
movss 0x8ce1(%rip), %xmm0     # 0x21978
callq 0x8ea0
jmp 0x19119
movq 0x128(%rsp), %rax
movq (%rax), %rsi
leaq 0x8da1(%rip), %rdi      # 0x21a54
callq 0x7980
cmpl $0x0, %eax
jne 0x18ce2
cmpq $0x0, 0xd8(%rsp)
je 0x18cdd
movq 0xd8(%rsp), %rdi
movss 0x8ca4(%rip), %xmm0     # 0x2197c
callq 0x8ea0
jmp 0x19117
movq 0x128(%rsp), %rax
movq (%rax), %rsi
leaq 0x8d6e(%rip), %rdi      # 0x21a62
callq 0x7980
cmpl $0x0, %eax
jne 0x18d23
cmpq $0x0, 0xd8(%rsp)
je 0x18d1e
movq 0xd8(%rsp), %rdi
movss 0x8c67(%rip), %xmm0     # 0x21980
callq 0x8ea0
jmp 0x19115
movq 0x128(%rsp), %rax
movq (%rax), %rsi
leaq 0x8d3b(%rip), %rdi      # 0x21a70
callq 0x7980
cmpl $0x0, %eax
jne 0x18d64
cmpq $0x0, 0xd8(%rsp)
je 0x18d5f
movq 0xd8(%rsp), %rdi
movss 0x8c2a(%rip), %xmm0     # 0x21984
callq 0x8ea0
jmp 0x19113
movq 0x128(%rsp), %rax
movq (%rax), %rsi
leaq 0x8d08(%rip), %rdi      # 0x21a7e
callq 0x7980
cmpl $0x0, %eax
jne 0x18da5
cmpq $0x0, 0xd8(%rsp)
je 0x18da0
movq 0xd8(%rsp), %rdi
movss 0x8bed(%rip), %xmm0     # 0x21988
callq 0x8ea0
jmp 0x19111
movq 0x128(%rsp), %rax
movq (%rax), %rsi
leaq 0x8cd5(%rip), %rdi      # 0x21a8c
callq 0x7980
cmpl $0x0, %eax
jne 0x18de6
cmpq $0x0, 0xd8(%rsp)
je 0x18de1
movq 0xd8(%rsp), %rdi
movss 0x8bb0(%rip), %xmm0     # 0x2198c
callq 0x8ea0
jmp 0x1910f
movq 0x128(%rsp), %rax
movq (%rax), %rsi
leaq 0x8ca2(%rip), %rdi      # 0x21a9a
callq 0x7980
cmpl $0x0, %eax
jne 0x18e27
cmpq $0x0, 0xd8(%rsp)
je 0x18e22
movq 0xd8(%rsp), %rdi
movss 0x8b73(%rip), %xmm0     # 0x21990
callq 0x8ea0
jmp 0x1910d
movq 0x128(%rsp), %rax
movq (%rax), %rsi
leaq 0x8c6f(%rip), %rdi      # 0x21aa8
callq 0x7980
cmpl $0x0, %eax
jne 0x18e68
cmpq $0x0, 0xd8(%rsp)
je 0x18e63
movq 0xd8(%rsp), %rdi
movss 0x8b36(%rip), %xmm0     # 0x21994
callq 0x8ea0
jmp 0x1910b
movq 0x128(%rsp), %rax
movq (%rax), %rsi
leaq 0x8c3c(%rip), %rdi      # 0x21ab6
callq 0x7980
cmpl $0x0, %eax
jne 0x18ea9
cmpq $0x0, 0xd8(%rsp)
je 0x18ea4
movq 0xd8(%rsp), %rdi
movss 0x73f1(%rip), %xmm0     # 0x20290
callq 0x8ea0
jmp 0x19109
movq 0x128(%rsp), %rax
movq (%rax), %rsi
leaq 0x8c0a(%rip), %rdi      # 0x21ac5
callq 0x7980
cmpl $0x0, %eax
jne 0x18ef1
cmpq $0x0, 0xd8(%rsp)
je 0x18eec
movq 0xd8(%rsp), %rdi
movq 0xd8(%rsp), %rsi
addq $0x10f, %rsi            # imm = 0x10F
callq 0x9130
jmp 0x19107
movq 0x128(%rsp), %rax
movq (%rax), %rsi
leaq 0x8bce(%rip), %rdi      # 0x21ad1
callq 0x7980
cmpl $0x0, %eax
jne 0x190b9
cmpq $0x0, 0xd8(%rsp)
je 0x18ffc
movq 0x40(%rsp), %rax
cmpq $0x0, 0x18(%rax)
je 0x18ffc
movq 0x40(%rsp), %rax
movq 0x18(%rax), %rax
movq %rax, 0x20(%rsp)
movq 0xd8(%rsp), %rdi
movq (%rdi), %rax
callq *0x18(%rax)
movq 0x20(%rsp), %rdi
movl %eax, 0x74(%rsp)
leaq 0x74(%rsp), %rsi
callq 0xd330
movq %rax, 0x78(%rsp)
movq 0x78(%rsp), %rax
movq %rax, 0x60(%rsp)
movq 0x60(%rsp), %rdi
movl $0x1, %esi
callq 0x1b260
movq %rax, %rcx
movq 0x40(%rsp), %rax
movq %rcx, 0x68(%rsp)
movq 0x68(%rsp), %rcx
movq %rcx, 0x78(%rsp)
movq 0x18(%rax), %rdi
callq 0xd200
movq %rax, 0x58(%rsp)
leaq 0x78(%rsp), %rdi
leaq 0x58(%rsp), %rsi
callq 0xd310
testb $0x1, %al
jne 0x18fb7
jmp 0x18fd4
movq 0x40(%rsp), %rax
movq 0x18(%rax), %rdi
callq 0xd1b0
movq %rax, 0x50(%rsp)
movq 0x50(%rsp), %rax
movq %rax, 0x78(%rsp)
movq 0xd8(%rsp), %rax
movq %rax, 0x18(%rsp)
leaq 0x78(%rsp), %rdi
callq 0xd230
movq 0x18(%rsp), %rdi
movl (%rax), %esi
callq 0x9060
jmp 0x190b7
cmpq $0x0, 0xd8(%rsp)
je 0x190b5
movq 0xd8(%rsp), %rdi
movq (%rdi), %rax
callq *0x18(%rax)
movl %eax, 0x4c(%rsp)
movl 0x4c(%rsp), %eax
addl $0x1, %eax
movl %eax, %eax
movq %rax, 0x10(%rsp)
movq 0xd8(%rsp), %rdi
addq $0x238, %rdi            # imm = 0x238
callq 0x92c0
movq %rax, %rcx
movq 0x10(%rsp), %rax
cmpq %rcx, %rax
jae 0x19059
movl 0x4c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x4c(%rsp)
jmp 0x19061
movl $0x0, 0x4c(%rsp)
movq 0xd8(%rsp), %rdi
addq $0x238, %rdi            # imm = 0x238
callq 0x92c0
cmpq $0x0, %rax
jbe 0x190b3
movq 0xd8(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0xd8(%rsp), %rdi
addq $0x238, %rdi            # imm = 0x238
movl 0x4c(%rsp), %eax
movl %eax, %esi
callq 0x92e0
movq 0x8(%rsp), %rdi
movq (%rax), %rsi
addq $0x8, %rsi
callq 0x90c0
jmp 0x190b5
jmp 0x190b7
jmp 0x19105
movq 0x128(%rsp), %rax
movq (%rax), %rsi
leaq 0x8a0d(%rip), %rdi      # 0x21ad8
callq 0x7980
cmpl $0x0, %eax
je 0x190f1
movq 0x128(%rsp), %rax
movq (%rax), %rsi
leaq 0x89fa(%rip), %rdi      # 0x21ae1
callq 0x7980
cmpl $0x0, %eax
jne 0x19103
movq 0x40(%rsp), %rdi
movq 0xd8(%rsp), %rsi
callq 0x19150
jmp 0x19105
jmp 0x19107
jmp 0x19109
jmp 0x1910b
jmp 0x1910d
jmp 0x1910f
jmp 0x19111
jmp 0x19113
jmp 0x19115
jmp 0x19117
jmp 0x19119
jmp 0x1911b
jmp 0x1911d
jmp 0x1911f
jmp 0x19121
jmp 0x19123
jmp 0x19125
jmp 0x19127
jmp 0x19129
jmp 0x1912b
jmp 0x1912d
addq $0x138, %rsp            # imm = 0x138
retq
movq 0xf0(%rsp), %rdi
callq 0x7c40
nopw %cs:(%rax,%rax)