"use strict";const path=require("path"),yazl=require("yazl"),assert=require("assert"),stream=require("stream"),utils=require("../utils"),ready=require("get-ready");class ZipFileStream extends stream.Transform{constructor(e){super(e);const r=utils.sourceType(e.source),a=new yazl.ZipFile,s=a.outputStream;if(s.on("data",e=>this.push(e)),s.on("end",()=>this.ready(!0)),a.on("error",e=>this.emit("error",e)),"file"!==r&&assert(e.relativePath,"opts.relativePath is required when compressing a buffer, or a stream"),r&&this.end(),"file"===r)a.addFile(e.source,e.relativePath||path.basename(e.source),e.yazl);else if("buffer"===r)a.addBuffer(e.source,e.relativePath,e.yazl);else if("stream"===r)a.addReadStream(e.source,e.relativePath,e.yazl);else{const r=this._passThrough=new stream.PassThrough;this.on("finish",()=>r.end()),a.addReadStream(r,e.relativePath,e.yazl)}a.end(e.yazl)}_transform(e,r,a){this._passThrough&&this._passThrough.write(e,r,a)}_flush(e){this.ready(e)}}ready.mixin(ZipFileStream.prototype),module.exports=ZipFileStream;