// Replaces the default cursor with a large SVG pointer.
const SVG =
  "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='48' viewBox='0 0 48 48'%3E" +
  "%3Cpath fill='%23000' stroke='%23fff' stroke-width='2.5' stroke-linejoin='round' d='M4 4 L4 36 L12 28 L18 42 L24 39 L18 25 L30 25 Z'/%3E" +
  "%3C/svg%3E";

let el: HTMLStyleElement | null = null;

export function toggle(on: boolean): void {
  if (on) {
    if (document.getElementById('accessmate-cursor')) return;
    el = document.createElement('style');
    el.id = 'accessmate-cursor';
    el.textContent = `*,*::before,*::after{cursor:url("${SVG}") 4 4,auto!important}`;
    document.head.appendChild(el);
  } else {
    el?.remove();
    el = null;
  }
}
