import { html, nothing, type TemplateResult } from 'lit';
import type { NuiType } from '../../types/nui-type.js';
import type { ImageFetchPriority } from '../nui-image/types.js';
import type { AnchorRel, AnchorTarget } from './types.js';
export interface NuiAnchorViewState {
href: string;
rel: AnchorRel;
target: AnchorTarget;
icon: string;
size: string;
src: string;
alt: string;
label: string;
tooltip: string;
fetchpriority: ImageFetchPriority | '';
anchorClass: string;
itemClass: string;
anchorStyle: string;
nuiType: NuiType;
}
export function getAnchorClass(anchorClass: string): string {
return ['nui-anchor', anchorClass].filter(Boolean).join(' ');
}
function renderAnchorLink(state: NuiAnchorViewState): TemplateResult {
const iconSize = state.size || '1em';
return html`
${
state.icon
? html`
`
: nothing
}
${
state.src
? html`
`
: nothing
}
${
state.label
? html`
`
: nothing
}
`;
}
export function renderAnchor(state: NuiAnchorViewState): TemplateResult {
const link = renderAnchorLink(state);
if (!state.tooltip) {
return link;
}
return html`
${link}
`;
}