'use strict';Object.defineProperty(exports,Symbol.toStringTag,{value:'Module'});const textLineTransformStream=require('../../_virtual/text-line-transform-stream.cjs'),require$$0=require('node:stream/web');var hasRequiredTextLineTransformStream; function requireTextLineTransformStream () { if (hasRequiredTextLineTransformStream) return textLineTransformStream.__exports; hasRequiredTextLineTransformStream = 1; (function (exports) { Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "TextLineStream", { enumerable: true, get: function() { return TextLineStream; } }); const _web = require$$0; class TextLineStream extends _web.TransformStream { // private __buf = ''; constructor({ allowCR = false } = {}){ let __buf = ''; let chunkIndex = 0; super({ transform (chunk, controller) { chunk = __buf + chunk; chunkIndex = 0; for(;;){ const lfIndex = chunk.indexOf('\n', chunkIndex); if (allowCR) { const crIndex = chunk.indexOf('\r', chunkIndex); if (crIndex !== -1 && crIndex !== chunk.length - 1 && (lfIndex === -1 || lfIndex - 1 > crIndex)) { controller.enqueue(chunk.slice(chunkIndex, crIndex)); chunkIndex = crIndex + 1; continue; } } if (lfIndex === -1) { break; } // enqueue current line, and loop again to find next line let crOrLfIndex = lfIndex; if (chunk[lfIndex - 1] === '\r') { crOrLfIndex--; } controller.enqueue(chunk.slice(chunkIndex, crOrLfIndex)); chunkIndex = lfIndex + 1; continue; } __buf = chunk.slice(chunkIndex); }, flush (controller) { if (__buf.length > 0) { // eslint-disable-next-line sukka/string/prefer-string-starts-ends-with -- performance if (allowCR && __buf[__buf.length - 1] === '\r') { controller.enqueue(__buf.slice(0, -1)); } else { controller.enqueue(__buf); } } } }); } } } (textLineTransformStream.__exports)); return textLineTransformStream.__exports; }exports.__require=requireTextLineTransformStream;