am complete");
          break;
        }

        try {
          const blob = new TextDecoder().decode(value);
          const chunks = blob.split("\n\n");

          for (const chunk of chunks) {
            if (chunk.trim()) {
              processChunk(chunk);
            }
          }
        } catch (e) {
          console.error("Error processing data:", e);
        }
      }
    } catch (error) {
      console.error("Error connecting to event stream:", error);
    }
  }
</script>