!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.UpChunk=t():e.UpChunk=t()}(this,(function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=1)}([function(e,t){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(e){"object"==typeof window&&(n=window)}e.exports=n},function(e,t,n){"use strict";var r=this&&this.__assign||function(){return(r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n0&&this.maxFileBytes "+this.maxFileBytes+")");if(this.attempts&&("number"!=typeof this.attempts||this.attempts<=0))throw new TypeError("retries must be a positive number");if(this.delayBeforeAttempt&&("number"!=typeof this.delayBeforeAttempt||this.delayBeforeAttempt<0))throw new TypeError("delayBeforeAttempt must be a positive number")},e.prototype.getEndpoint=function(){var e=this;return"string"==typeof this.endpoint?(this.endpointValue=this.endpoint,Promise.resolve(this.endpoint)):this.endpoint(this.file).then((function(t){return e.endpointValue=t,e.endpointValue}))},e.prototype.getChunk=function(){var e=this;return new Promise((function(t){var n=1===e.totalChunks?e.file.size:e.chunkByteSize,r=n*e.chunkCount;e.reader.onload=function(){null!==e.reader.result&&(e.chunk=new Blob([e.reader.result],{type:"application/octet-stream"})),t()},e.reader.readAsArrayBuffer(e.file.slice(r,r+n))}))},e.prototype.xhrPromise=function(e){var t=this,n=function(e){e.upload.onprogress=function(e){var n,r=100/t.totalChunks,o=r*t.file.size,i=r*t.chunkCount,s=e.loaded/(null!==(n=e.total)&&void 0!==n?n:o)*r;t.dispatch("progress",Math.min(i+s,100))}};return new Promise((function(o,s){t.currentXhr=i.default(r(r({},e),{beforeSend:n}),(function(e,n){return t.currentXhr=void 0,e?s(e):o(n)}))}))},e.prototype.sendChunk=function(){var e=this.chunkCount*this.chunkByteSize,t=e+this.chunk.size-1,n=r(r({},this.headers),{"Content-Type":this.file.type,"Content-Range":"bytes "+e+"-"+t+"/"+this.file.size});return this.dispatch("attempt",{chunkNumber:this.chunkCount,chunkSize:this.chunk.size}),this.xhrPromise({headers:n,url:this.endpointValue,method:this.method,body:this.chunk})},e.prototype.manageRetries=function(){var e=this;if(this.attemptCounti(t[n++]))}function i(e){return"object"!=typeof e||null===e?String(e):Object.prototype.toString.call(e)}let s;Object.defineProperty(t,"__esModule",{value:!0});const a="undefined"!=typeof window?window:"undefined"!=typeof self?self:void 0!==n?n:"undefined"!=typeof globalThis?globalThis:void 0;let u;class c{constructor(e,t){this.code=e,this.message=t}warn(...e){var t;try{if(u)return void u({...this,args:e});const n=(null!==(t=(new Error).stack)&&void 0!==t?t:"").replace(/^(?:.+?\n){2}/gu,"\n");console.warn(this.message,...e,n)}catch(e){}}}const l=new c("W01","Unable to initialize event under dispatching."),p=new c("W02","Assigning any falsy value to 'cancelBubble' property has no effect."),f=new c("W03","Assigning any truthy value to 'returnValue' property has no effect."),h=new c("W04","Unable to preventDefault on non-cancelable events."),d=new c("W05","Unable to preventDefault inside passive event listener invocation."),g=new c("W06","An event listener wasn't added because it has been added already: %o, %o"),b=new c("W07","The %o option value was abandoned because the event listener wasn't added as duplicated."),m=new c("W08","The 'callback' argument must be a function or an object that has 'handleEvent' method: %o"),y=new c("W09","Event attribute handler must be a function: %o");class v{static get NONE(){return E}static get CAPTURING_PHASE(){return w}static get AT_TARGET(){return T}static get BUBBLING_PHASE(){return R}constructor(e,t){Object.defineProperty(this,"isTrusted",{value:!1,enumerable:!0});const n=null!=t?t:{};k.set(this,{type:String(e),bubbles:Boolean(n.bubbles),cancelable:Boolean(n.cancelable),composed:Boolean(n.composed),target:null,currentTarget:null,stopPropagationFlag:!1,stopImmediatePropagationFlag:!1,canceledFlag:!1,inPassiveListenerFlag:!1,dispatchFlag:!1,timeStamp:Date.now()})}get type(){return C(this).type}get target(){return C(this).target}get srcElement(){return C(this).target}get currentTarget(){return C(this).currentTarget}composedPath(){const e=C(this).currentTarget;return e?[e]:[]}get NONE(){return E}get CAPTURING_PHASE(){return w}get AT_TARGET(){return T}get BUBBLING_PHASE(){return R}get eventPhase(){return C(this).dispatchFlag?2:0}stopPropagation(){C(this).stopPropagationFlag=!0}get cancelBubble(){return C(this).stopPropagationFlag}set cancelBubble(e){e?C(this).stopPropagationFlag=!0:p.warn()}stopImmediatePropagation(){const e=C(this);e.stopPropagationFlag=e.stopImmediatePropagationFlag=!0}get bubbles(){return C(this).bubbles}get cancelable(){return C(this).cancelable}get returnValue(){return!C(this).canceledFlag}set returnValue(e){e?f.warn():O(C(this))}preventDefault(){O(C(this))}get defaultPrevented(){return C(this).canceledFlag}get composed(){return C(this).composed}get isTrusted(){return!1}get timeStamp(){return C(this).timeStamp}initEvent(e,t=!1,n=!1){const r=C(this);r.dispatchFlag?l.warn():k.set(this,{...r,type:String(e),bubbles:Boolean(t),cancelable:Boolean(n),target:null,currentTarget:null,stopPropagationFlag:!1,stopImmediatePropagationFlag:!1,canceledFlag:!1})}}const E=0,w=1,T=2,R=3,k=new WeakMap;function C(e,t="this"){const n=k.get(e);return r(null!=n,"'%s' must be an object that Event constructor created, but got another one: %o",t,e),n}function O(e){e.inPassiveListenerFlag?d.warn():e.cancelable?e.canceledFlag=!0:h.warn()}Object.defineProperty(v,"NONE",{enumerable:!0}),Object.defineProperty(v,"CAPTURING_PHASE",{enumerable:!0}),Object.defineProperty(v,"AT_TARGET",{enumerable:!0}),Object.defineProperty(v,"BUBBLING_PHASE",{enumerable:!0});const P=Object.getOwnPropertyNames(v.prototype);for(let e=0;eo,configurable:!0,enumerable:!0})}}class j extends v{static wrap(e){return new(function e(t){const n=Object.getPrototypeOf(t);if(null==n)return j;let r=I.get(n);null==r&&(r=function(e,t){class n extends e{}const r=Object.keys(t);for(let e=0;en!==t),!1):(e.listeners.splice(t,1),!0)}function W(e,t){var n;return null!==(n=e[t])&&void 0!==n?n:e[t]={attrCallback:void 0,attrListener:void 0,cow:!1,listeners:[]}}I.set(Object.prototype,j),void 0!==a&&void 0!==a.Event&&I.set(a.Event.prototype,j);class q{constructor(){G.set(this,Object.create(null))}addEventListener(e,t,n){const r=Y(this),{callback:o,capture:i,once:s,passive:a,signal:u,type:c}=function(e,t,n){var r;if(J(t),"object"==typeof n&&null!==n)return{type:String(e),callback:null!=t?t:void 0,capture:Boolean(n.capture),passive:Boolean(n.passive),once:Boolean(n.once),signal:null!==(r=n.signal)&&void 0!==r?r:void 0};return{type:String(e),callback:null!=t?t:void 0,capture:Boolean(n),passive:!1,once:!1,signal:void 0}}(e,t,n);if(null==o||(null==u?void 0:u.aborted))return;const l=W(r,c),p=H(l,o,i);-1===p?z(l,o,i,a,s,u):function(e,t,n,r){g.warn(F(e)?"capture":"bubble",e.callback),D(e)!==t&&b.warn("passive");x(e)!==n&&b.warn("once");e.signal!==r&&b.warn("signal")}(l.listeners[p],a,s,u)}removeEventListener(e,t,n){const r=Y(this),{callback:o,capture:i,type:s}=function(e,t,n){if(J(t),"object"==typeof n&&null!==n)return{type:String(e),callback:null!=t?t:void 0,capture:Boolean(n.capture)};return{type:String(e),callback:null!=t?t:void 0,capture:Boolean(n)}}(e,t,n),a=r[s];null!=o&&a&&X(a,o,i)}dispatchEvent(e){const t=Y(this)[String(e.type)];if(null==t)return!0;const n=e instanceof v?e:j.wrap(e),r=C(n,"event");if(r.dispatchFlag)throw o="This event has been in dispatching.",a.DOMException?new a.DOMException(o,"InvalidStateError"):(null==S&&(S=class e extends Error{constructor(t){super(t),Error.captureStackTrace&&Error.captureStackTrace(this,e)}get code(){return 11}get name(){return"InvalidStateError"}},Object.defineProperties(S.prototype,{code:{enumerable:!0},name:{enumerable:!0}}),_(S),_(S.prototype)),new S(o));var o;if(r.dispatchFlag=!0,r.target=r.currentTarget=this,!r.stopPropagationFlag){const{cow:e,listeners:o}=t;t.cow=!0;for(let i=0;i1)for(var n=1;n0&&(p=setTimeout((function(){if(!c){c=!0,l.abort("timeout");var e=new Error("XMLHttpRequest timeout");e.code="ETIMEDOUT",o(e)}}),e.timeout)),l.setRequestHeader)for(a in g)g.hasOwnProperty(a)&&l.setRequestHeader(a,g[a]);else if(e.headers&&!function(e){for(var t in e)if(e.hasOwnProperty(t))return!1;return!0}(e.headers))throw new Error("Headers cannot be set on an XDomainRequest object");return"responseType"in e&&(l.responseType=e.responseType),"beforeSend"in e&&"function"==typeof e.beforeSend&&e.beforeSend(l),l.send(d||null),l}e.exports=u,e.exports.default=u,u.XMLHttpRequest=r.XMLHttpRequest||function(){},u.XDomainRequest="withCredentials"in new u.XMLHttpRequest?u.XMLHttpRequest:r.XDomainRequest,function(e,t){for(var n=0;n