<?php $attributes ??= new \Illuminate\View\ComponentAttributeBag;

$__newAttributes = [];
$__propNames = \Illuminate\View\ComponentAttributeBag::extractPropNames(([
    'id',
    'resource' => null,
    'editRoute' => null, 
    'deleteRoute' => null,
    'viewRoute' => null,
    'confirmMessage' => 'Are you sure?'
]));

foreach ($attributes->all() as $__key => $__value) {
    if (in_array($__key, $__propNames)) {
        $$__key = $$__key ?? $__value;
    } else {
        $__newAttributes[$__key] = $__value;
    }
}

$attributes = new \Illuminate\View\ComponentAttributeBag($__newAttributes);

unset($__propNames);
unset($__newAttributes);

foreach (array_filter(([
    'id',
    'resource' => null,
    'editRoute' => null, 
    'deleteRoute' => null,
    'viewRoute' => null,
    'confirmMessage' => 'Are you sure?'
]), 'is_string', ARRAY_FILTER_USE_KEY) as $__key => $__value) {
    $$__key = $$__key ?? $__value;
}

$__defined_vars = get_defined_vars();

foreach ($attributes->all() as $__key => $__value) {
    if (array_key_exists($__key, $__defined_vars)) unset($$__key);
}

unset($__defined_vars, $__key, $__value); ?>

<?php
    $editUrl   = $editRoute   ?? ($resource ? route($resource . '.edit', $id)   : null);
    $deleteUrl = $deleteRoute ?? ($resource ? route($resource . '.destroy', $id): null);
    $viewUrl   = $viewRoute   ?? ($resource ? route($resource . '.show', $id)   : null);
?>

<div class="d-flex align-items-center gap-1">
    <?php if($editUrl): ?>
        <a href="<?php echo e($editUrl); ?>"
            class="btn px-2 py-1"
            style="background-color: #d4af37; color: #ffffff; border-radius: 6px;"
            title="Edit">
            <i class="bi bi-pen"></i>
        </a>
    <?php endif; ?>

    <?php if($deleteUrl): ?>
        <form method="POST" action="<?php echo e($deleteUrl); ?>" class="d-inline">
            <?php echo csrf_field(); ?>
            <?php echo method_field('DELETE'); ?>

            <button type="submit"
                class="btn px-2 py-1"
                style="background-color: #8c2b25; color: #ffffff; border-radius: 6px;"
                title="Delete"
                onclick="return confirm('<?php echo e($confirmMessage); ?>')">
                <i class="bi bi-trash"></i>
            </button>
        </form>
    <?php endif; ?>

    <?php if($viewUrl): ?>
        <a href="<?php echo e($viewUrl); ?>"
            class="btn px-2 py-1"
            style="background-color: #0f8d06; color: #ffffff; border-radius: 6px;"
            title="View">
            <i class="bi bi-eye"></i>
        </a>
    <?php endif; ?>
</div>
<?php /**PATH C:\PAW\PiaZhang\resources\views/components/action-button.blade.php ENDPATH**/ ?>