/**
 * Bundled by jsDelivr using Rollup v4.62.2 and esbuild v0.28.1.
 * Original file: /npm/fetch-event-stream@0.1.6/esm/mod.js
 *
 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
 */
class d extends TransformStream{#e="";constructor(r={allowCR:!1}){super({transform:(e,n)=>{for(e=this.#e+e;;){const u=e.indexOf(`
`),t=r.allowCR?e.indexOf("\r"):-1;if(t!==-1&&t!==e.length-1&&(u===-1||u-1>t)){n.enqueue(e.slice(0,t)),e=e.slice(t+1);continue}if(u===-1)break;const l=e[u-1]==="\r"?u-1:u;n.enqueue(e.slice(0,l)),e=e.slice(u+1)}this.#e=e},flush:e=>{if(this.#e==="")return;const n=r.allowCR&&this.#e.endsWith("\r")?this.#e.slice(0,-1):this.#e;e.enqueue(n)}})}}function a(i){let r=new TextDecoderStream,e=new d({allowCR:!0});return i.pipeThrough(r).pipeThrough(e)}function c(i){let e=/[:]\s*/.exec(i),n=e&&e.index;if(n)return[i.substring(0,n),i.substring(n+e[0].length)]}function s(i,r,e){i.get(r)||i.set(r,e)}async function*o(i,r){if(!i.body)return;let e=a(i.body),n,u=e.getReader(),t;for(;;){if(r&&r.aborted)return u.cancel();if(n=await u.read(),n.done)return;if(!n.value){t&&(yield t),t=void 0;continue}let[l,f]=c(n.value)||[];l==="data"?(t||={},t[l]=t[l]?t[l]+`
`+f:f):l==="event"?(t||={},t[l]=f):l==="id"?(t||={},t[l]=String(+f)===f?+f:f):l==="retry"&&(t||={},t[l]=+f||void 0)}}async function x(i,r){let e=new Request(i,r);s(e.headers,"Accept","text/event-stream"),s(e.headers,"Content-Type","application/json");let n=await libcurl.fetch(e);if(!n.ok)throw n;return o(n,e.signal)}window.events = o;
window.stream = x;
//# sourceMappingURL=/sm/c059c6a17ac906adebf56889fc6d49334d6ef6dcc03f689cdae165e72eb6186c.map


// fetch became libcurl.fetch