(()=>{var e={848:(e,t,r)=>{"use strict";var n=r(9623);function s(e){e.startedAt=null,e.state=e.request.progressState=null,e.delayTimer&&clearTimeout(e.delayTimer),e.delayTimer=null}function l(e,t){e.state.size.transferred+=t.length,!e.delayTimer&&e.reportState()}function o(e){e.delayTimer&&(clearTimeout(e.delayTimer),e.delayTimer=null),e.request.progressState=e.request.progressContext=null}function a(e){var t;!e.delayTimer&&e.request.progressState&&((t=e.state).time.elapsed=(Date.now()-e.startedAt)/1e3,t.time.elapsed>=1&&(t.speed=t.size.transferred/t.time.elapsed),null!=t.size.total&&(t.percent=Math.min(t.size.transferred,t.size.total)/t.size.total,null!=t.speed&&(t.time.remaining=1!==t.percent?t.size.total/t.speed-t.time.elapsed:0,t.time.remaining=Math.round(1e3*t.time.remaining)/1e3)),e.request.emit("progress",t))}e.exports=function(e,t){var r;if(e.progressContext)return e;if(e.response)throw new Error("Already got response, it's too late to track progress");return(t=t||{}).throttle=null==t.throttle?1e3:t.throttle,t.delay=t.delay||0,t.lengthHeader=t.lengthHeader||"content-length",(r={}).request=e,r.options=t,r.reportState=n(a.bind(null,r),t.throttle),e.on("request",s.bind(null,r)).on("response",(function(e){return e.on("data",l.bind(null,r)),function(e,t){e.startedAt=Date.now(),e.state=e.request.progressState={time:{elapsed:0,remaining:null},speed:null,percent:null,size:{total:Number(t.headers[e.options.lengthHeader])||null,transferred:0}},e.delayTimer=setTimeout((function(){e.delayTimer=null}),e.options.delay)}(r,e)})).on("end",o.bind(null,r)),e.progressContext=r,e}},9623:e=>{e.exports=function(e,t){var r,n,s,l,o=0;return function(){r=this,n=arguments;var e=new Date-o;return l||(e>=t?a():l=setTimeout(a,t-e)),s};function a(){l=0,o=+new Date,s=e.apply(r,n),r=null,n=null}}}},t={},r=function r(n){var s=t[n];if(void 0!==s)return s.exports;var l=t[n]={exports:{}};return e[n](l,l.exports,r),l.exports}(848);module.exports=r})();
//# sourceMappingURL=request-progress.js.map