@props(['name', 'class' => ''])

@php
    $path = public_path("icons/{$name}.svg");

    if (! is_file($path)) {
        throw new InvalidArgumentException("Icon [{$name}] not found.");
    }

    $svg = file_get_contents($path);
    $svg = preg_replace('/<svg\b/', '<svg class="w-full h-full"', $svg, 1);
@endphp

<span {{ $attributes->merge(['class' => 'inline-flex shrink-0 '.$class]) }} aria-hidden="true">
    {!! $svg !!}
</span>
