function($prop) {
static $assets_loaded = false;
$label = first($prop['label'] ?? false, $prop['text'] ?? false, $prop['caption'] ?? false, 'Action');
$route = array_key_exists('route', $prop) ? $prop['route'] : ($prop['url'] ?? '');
$params = is_array($prop['params'] ?? false) ? $prop['params'] : array();
$class = trim('action-button '.(string)first($prop['class'] ?? false, ''));
$variant = preg_replace('/[^a-z0-9_-]/i', '', (string)first($prop['variant'] ?? false, ''));
if($variant !== '') $class .= ' action-button--'.$variant;
$href = $route !== false ? URL::Link((string)$route, $params) : '';
$tag = strtolower((string)first($prop['tag'] ?? false, $href !== '' ? 'a' : 'button'));
if(!in_array($tag, array('a', 'button'), true)) $tag = 'button';
$method = strtolower((string)first($prop['method'] ?? false, 'get'));
$confirm = (string)first($prop['confirm'] ?? false, '');
$title = (string)first($prop['title'] ?? false, $prop['hint'] ?? false, '');
$attrs = array(
'class' => $class,
);
if($title !== '') $attrs['title'] = $title;
if($confirm !== '') $attrs['data-confirm'] = $confirm;
if($tag === 'a' && $href !== '') $attrs['href'] = $href;
else $attrs['type'] = first($prop['type'] ?? false, 'button');
if(!empty($prop['disabled'])) $attrs['disabled'] = 'disabled';
if(!empty($prop['htmx']))
{
$attrs[$method === 'post' ? 'hx-post' : 'hx-get'] = $href;
if($confirm !== '') $attrs['hx-confirm'] = $confirm;
if(!empty($prop['target'])) $attrs['hx-target'] = (string)$prop['target'];
if(!empty($prop['swap'])) $attrs['hx-swap'] = (string)$prop['swap'];
if(array_key_exists('push_url', $prop)) $attrs['hx-push-url'] = $prop['push_url'] ? 'true' : 'false';
if(!empty($prop['vals']) && is_array($prop['vals'])) $attrs['hx-vals'] = json_encode($prop['vals']);
}
else if($href !== '' && $tag !== 'a')
{
$attrs['data-href'] = $href;
}
$attr_html = '';
foreach($attrs as $name => $value)
$attr_html .= ' '.asafe($name).'="'.asafe((string)$value).'"';
ob_start();
if(!$assets_loaded)
{
$assets_loaded = true;
?>
<= $tag ?>= $attr_html ?>>= safe($label) ?>= $tag ?>> 'Reusable link/button action primitive inspired by htmx-crud-starter UI::url_button.',
];