function fetchImage(src, timeout = 3000) {

  if (imageCache.has(src)) {
    return Promise.resolve(imageCache.get(src));
  }

  return new Promise((resolve, reject) => {
    const timeoutId = setTimeout(() => {
      reject(new Error("Image load timed out"));
    }, timeout);

    const image = new Image();
    image.crossOrigin = "anonymous";

    image.onload = async () => {
      clearTimeout(timeoutId);
      try {
        await image.decode();
        const canvas = document.createElement("canvas");
        canvas.width = image.width;
        canvas.height = image.height;
        const ctx = canvas.getContext("2d");
        ctx.drawImage(image, 0, 0);
        try {
          const dataURL = canvas.toDataURL("image/png");
          // Guarda en cache para futuras llamadas
          imageCache.set(src, dataURL);
          resolve(dataURL);
        } catch (e) {
          reject(new Error("CORS restrictions prevented image capture"));
        }
      } catch (e) {
        reject(e);
      }
    };

    image.onerror = (e) => {
      clearTimeout(timeoutId);
      reject(new Error("Failed to load image: " + (e.message || "Unknown error")));
    };

    image.src = src;
  });
}
@export
@param {*} src
@param {number} [timeout=3000]
@return {*}