@php
    $shareText = $shareText ?? '';
    $copyId = 'copy-invoice-'.$invoice->id;
    $compact = $compact ?? false;
    $btn = $compact ? 'btn btn-outline-secondary btn-sm' : 'btn btn-outline-secondary btn-sm';
@endphp
<div class="action-bar">
    @can('invoices.print')
        <a class="{{ $btn }}" href="{{ route('invoices.print',$invoice) }}" title="{{ __('messages.a4') }}"><i class="bi bi-printer"></i>@unless($compact) {{ __('messages.a4') }}@endunless</a>
        @unless($compact)
            <a class="{{ $btn }}" href="{{ route('invoices.thermal',$invoice) }}"><i class="bi bi-receipt"></i> {{ __('messages.thermal') }}</a>
            <a class="{{ $btn }}" href="{{ route('invoices.pdf',$invoice) }}"><i class="bi bi-file-earmark-pdf"></i> PDF</a>
        @endunless
    @endcan
    @can('invoices.share')
        <textarea id="{{ $copyId }}" class="visually-hidden" readonly>{{ $shareText }}</textarea>
        <button type="button" class="{{ $btn }}" data-copy="{{ $copyId }}" data-copied="{{ __('messages.copied') }}" title="{{ __('messages.copy_invoice') }}">
            <i class="bi bi-copy"></i>@unless($compact) {{ __('messages.copy_invoice') }}@endunless
        </button>
        <a class="btn btn-outline-success btn-sm" target="_blank" rel="noopener" href="{{ whatsapp_url($invoice->customer?->phone, $shareText) }}" title="{{ __('messages.send_whatsapp') }}">
            <i class="bi bi-whatsapp"></i>@unless($compact) {{ __('messages.send_whatsapp') }}@endunless
        </a>
    @endcan
    @can('invoices.edit')
        <a class="btn btn-outline-primary btn-sm" href="{{ route('invoices.edit',$invoice) }}" title="{{ __('messages.edit') }}"><i class="bi bi-pencil"></i>@unless($compact) {{ __('messages.edit') }}@endunless</a>
    @endcan
    @can('invoices.delete')
        <form method="post" action="{{ route('invoices.destroy',$invoice) }}" class="d-inline" onsubmit="return confirm(@json(__('messages.confirm_delete_invoice')))">
            @csrf
            @method('DELETE')
            <input type="hidden" name="reason" value="{{ __('messages.deleted') }}">
            <button class="btn btn-outline-danger btn-sm" title="{{ __('messages.delete') }}"><i class="bi bi-trash"></i>@unless($compact) {{ __('messages.delete') }}@endunless</button>
        </form>
    @endcan
</div>
