type RuntimeResourcePendingMarkerProps = {
  source?: string | null;
  isPending?: boolean;
  kind?: string;
};

export const RUNTIME_RESOURCE_PENDING_SELECTOR =
  '[data-runtime-resource-pending="true"]';

export function RuntimeResourcePendingMarker({
  source,
  isPending = true,
  kind,
}: RuntimeResourcePendingMarkerProps) {
  const normalizedSource = source?.trim() ?? '';
  if (!isPending || !normalizedSource) {
    return null;
  }

  return (
    <span
      hidden
      aria-hidden="true"
      data-runtime-resource-pending="true"
      data-runtime-resource-src={normalizedSource}
      data-runtime-resource-kind={kind}
    />
  );
}
