// actions.js

import { Runtime } from './runtime.js';

let initialized = false;

export function initCardActions() {

    if (initialized) return;

    initialized = true;

    document.addEventListener('click', async (e) => {

        const btn = e.target.closest('.card-action');

        if (!btn) return;

        const action = btn.dataset.action;

        const id = btn.dataset.id;

        Runtime.bus.emit(
            action,
            {
                id,
                button: btn
            }
        );
    });
}
