react-simple-upload
Version:
a react Uploader library implements html5 file upload and provides multiple simultaneous, stable, fault tolerant and resumable uploads
1,299 lines (1,296 loc) • 64.4 kB
JavaScript
import './style.css';
import We, { createContext as mt, useRef as Q, useContext as be, useEffect as le, useState as V, useMemo as se } from "react";
var _ = {}, yt = {
get exports() {
return _;
},
set exports(m) {
_ = m;
}
}, oe = {};
/**
* @license React
* react-jsx-runtime.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
var Be;
function bt() {
if (Be)
return oe;
Be = 1;
var m = We, y = Symbol.for("react.element"), C = Symbol.for("react.fragment"), E = Object.prototype.hasOwnProperty, w = m.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, n = { key: !0, ref: !0, __self: !0, __source: !0 };
function R(p, u, t) {
var r, l = {}, a = null, i = null;
t !== void 0 && (a = "" + t), u.key !== void 0 && (a = "" + u.key), u.ref !== void 0 && (i = u.ref);
for (r in u)
E.call(u, r) && !n.hasOwnProperty(r) && (l[r] = u[r]);
if (p && p.defaultProps)
for (r in u = p.defaultProps, u)
l[r] === void 0 && (l[r] = u[r]);
return { $$typeof: y, type: p, key: a, ref: i, props: l, _owner: w.current };
}
return oe.Fragment = C, oe.jsx = R, oe.jsxs = R, oe;
}
var ue = {};
/**
* @license React
* react-jsx-runtime.development.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
var Ge;
function _t() {
return Ge || (Ge = 1, process.env.NODE_ENV !== "production" && function() {
var m = We, y = Symbol.for("react.element"), C = Symbol.for("react.portal"), E = Symbol.for("react.fragment"), w = Symbol.for("react.strict_mode"), n = Symbol.for("react.profiler"), R = Symbol.for("react.provider"), p = Symbol.for("react.context"), u = Symbol.for("react.forward_ref"), t = Symbol.for("react.suspense"), r = Symbol.for("react.suspense_list"), l = Symbol.for("react.memo"), a = Symbol.for("react.lazy"), i = Symbol.for("react.offscreen"), f = Symbol.iterator, S = "@@iterator";
function s(e) {
if (e === null || typeof e != "object")
return null;
var o = f && e[f] || e[S];
return typeof o == "function" ? o : null;
}
var c = m.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
function d(e) {
{
for (var o = arguments.length, h = new Array(o > 1 ? o - 1 : 0), b = 1; b < o; b++)
h[b - 1] = arguments[b];
v("error", e, h);
}
}
function v(e, o, h) {
{
var b = c.ReactDebugCurrentFrame, F = b.getStackAddendum();
F !== "" && (o += "%s", h = h.concat([F]));
var D = h.map(function(P) {
return String(P);
});
D.unshift("Warning: " + o), Function.prototype.apply.call(console[e], console, D);
}
}
var x = !1, g = !1, O = !1, j = !1, G = !1, I;
I = Symbol.for("react.module.reference");
function L(e) {
return !!(typeof e == "string" || typeof e == "function" || e === E || e === n || G || e === w || e === t || e === r || j || e === i || x || g || O || typeof e == "object" && e !== null && (e.$$typeof === a || e.$$typeof === l || e.$$typeof === R || e.$$typeof === p || e.$$typeof === u || e.$$typeof === I || e.getModuleId !== void 0));
}
function q(e, o, h) {
var b = e.displayName;
if (b)
return b;
var F = o.displayName || o.name || "";
return F !== "" ? h + "(" + F + ")" : h;
}
function X(e) {
return e.displayName || "Context";
}
function M(e) {
if (e == null)
return null;
if (typeof e.tag == "number" && d("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."), typeof e == "function")
return e.displayName || e.name || null;
if (typeof e == "string")
return e;
switch (e) {
case E:
return "Fragment";
case C:
return "Portal";
case n:
return "Profiler";
case w:
return "StrictMode";
case t:
return "Suspense";
case r:
return "SuspenseList";
}
if (typeof e == "object")
switch (e.$$typeof) {
case p:
var o = e;
return X(o) + ".Consumer";
case R:
var h = e;
return X(h._context) + ".Provider";
case u:
return q(e, e.render, "ForwardRef");
case l:
var b = e.displayName || null;
return b !== null ? b : M(e.type) || "Memo";
case a: {
var F = e, D = F._payload, P = F._init;
try {
return M(P(D));
} catch {
return null;
}
}
}
return null;
}
var Y = Object.assign, W = 0, ne, _e, Ee, fe, ee, he, J;
function A() {
}
A.__reactDisabledLog = !0;
function T() {
{
if (W === 0) {
ne = console.log, _e = console.info, Ee = console.warn, fe = console.error, ee = console.group, he = console.groupCollapsed, J = console.groupEnd;
var e = {
configurable: !0,
enumerable: !0,
value: A,
writable: !0
};
Object.defineProperties(console, {
info: e,
log: e,
warn: e,
error: e,
group: e,
groupCollapsed: e,
groupEnd: e
});
}
W++;
}
}
function $() {
{
if (W--, W === 0) {
var e = {
configurable: !0,
enumerable: !0,
writable: !0
};
Object.defineProperties(console, {
log: Y({}, e, {
value: ne
}),
info: Y({}, e, {
value: _e
}),
warn: Y({}, e, {
value: Ee
}),
error: Y({}, e, {
value: fe
}),
group: Y({}, e, {
value: ee
}),
groupCollapsed: Y({}, e, {
value: he
}),
groupEnd: Y({}, e, {
value: J
})
});
}
W < 0 && d("disabledDepth fell below zero. This is a bug in React. Please file an issue.");
}
}
var te = c.ReactCurrentDispatcher, K;
function Z(e, o, h) {
{
if (K === void 0)
try {
throw Error();
} catch (F) {
var b = F.stack.trim().match(/\n( *(at )?)/);
K = b && b[1] || "";
}
return `
` + K + e;
}
}
var pe = !1, de;
{
var He = typeof WeakMap == "function" ? WeakMap : Map;
de = new He();
}
function Fe(e, o) {
if (!e || pe)
return "";
{
var h = de.get(e);
if (h !== void 0)
return h;
}
var b;
pe = !0;
var F = Error.prepareStackTrace;
Error.prepareStackTrace = void 0;
var D;
D = te.current, te.current = null, T();
try {
if (o) {
var P = function() {
throw Error();
};
if (Object.defineProperty(P.prototype, "props", {
set: function() {
throw Error();
}
}), typeof Reflect == "object" && Reflect.construct) {
try {
Reflect.construct(P, []);
} catch (H) {
b = H;
}
Reflect.construct(e, [], P);
} else {
try {
P.call();
} catch (H) {
b = H;
}
e.call(P.prototype);
}
} else {
try {
throw Error();
} catch (H) {
b = H;
}
e();
}
} catch (H) {
if (H && b && typeof H.stack == "string") {
for (var k = H.stack.split(`
`), z = b.stack.split(`
`), N = k.length - 1, U = z.length - 1; N >= 1 && U >= 0 && k[N] !== z[U]; )
U--;
for (; N >= 1 && U >= 0; N--, U--)
if (k[N] !== z[U]) {
if (N !== 1 || U !== 1)
do
if (N--, U--, U < 0 || k[N] !== z[U]) {
var B = `
` + k[N].replace(" at new ", " at ");
return e.displayName && B.includes("<anonymous>") && (B = B.replace("<anonymous>", e.displayName)), typeof e == "function" && de.set(e, B), B;
}
while (N >= 1 && U >= 0);
break;
}
}
} finally {
pe = !1, te.current = D, $(), Error.prepareStackTrace = F;
}
var ie = e ? e.displayName || e.name : "", $e = ie ? Z(ie) : "";
return typeof e == "function" && de.set(e, $e), $e;
}
function Xe(e, o, h) {
return Fe(e, !1);
}
function Je(e) {
var o = e.prototype;
return !!(o && o.isReactComponent);
}
function ve(e, o, h) {
if (e == null)
return "";
if (typeof e == "function")
return Fe(e, Je(e));
if (typeof e == "string")
return Z(e);
switch (e) {
case t:
return Z("Suspense");
case r:
return Z("SuspenseList");
}
if (typeof e == "object")
switch (e.$$typeof) {
case u:
return Xe(e.render);
case l:
return ve(e.type, o, h);
case a: {
var b = e, F = b._payload, D = b._init;
try {
return ve(D(F), o, h);
} catch {
}
}
}
return "";
}
var ge = Object.prototype.hasOwnProperty, we = {}, Te = c.ReactDebugCurrentFrame;
function me(e) {
if (e) {
var o = e._owner, h = ve(e.type, e._source, o ? o.type : null);
Te.setExtraStackFrame(h);
} else
Te.setExtraStackFrame(null);
}
function Ke(e, o, h, b, F) {
{
var D = Function.call.bind(ge);
for (var P in e)
if (D(e, P)) {
var k = void 0;
try {
if (typeof e[P] != "function") {
var z = Error((b || "React class") + ": " + h + " type `" + P + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof e[P] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");
throw z.name = "Invariant Violation", z;
}
k = e[P](o, P, b, h, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED");
} catch (N) {
k = N;
}
k && !(k instanceof Error) && (me(F), d("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).", b || "React class", h, P, typeof k), me(null)), k instanceof Error && !(k.message in we) && (we[k.message] = !0, me(F), d("Failed %s type: %s", h, k.message), me(null));
}
}
}
var Ze = Array.isArray;
function Re(e) {
return Ze(e);
}
function Qe(e) {
{
var o = typeof Symbol == "function" && Symbol.toStringTag, h = o && e[Symbol.toStringTag] || e.constructor.name || "Object";
return h;
}
}
function et(e) {
try {
return De(e), !1;
} catch {
return !0;
}
}
function De(e) {
return "" + e;
}
function Oe(e) {
if (et(e))
return d("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", Qe(e)), De(e);
}
var ae = c.ReactCurrentOwner, tt = {
key: !0,
ref: !0,
__self: !0,
__source: !0
}, je, Ae, Se;
Se = {};
function rt(e) {
if (ge.call(e, "ref")) {
var o = Object.getOwnPropertyDescriptor(e, "ref").get;
if (o && o.isReactWarning)
return !1;
}
return e.ref !== void 0;
}
function it(e) {
if (ge.call(e, "key")) {
var o = Object.getOwnPropertyDescriptor(e, "key").get;
if (o && o.isReactWarning)
return !1;
}
return e.key !== void 0;
}
function st(e, o) {
if (typeof e.ref == "string" && ae.current && o && ae.current.stateNode !== o) {
var h = M(ae.current.type);
Se[h] || (d('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref', M(ae.current.type), e.ref), Se[h] = !0);
}
}
function nt(e, o) {
{
var h = function() {
je || (je = !0, d("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", o));
};
h.isReactWarning = !0, Object.defineProperty(e, "key", {
get: h,
configurable: !0
});
}
}
function at(e, o) {
{
var h = function() {
Ae || (Ae = !0, d("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", o));
};
h.isReactWarning = !0, Object.defineProperty(e, "ref", {
get: h,
configurable: !0
});
}
}
var ot = function(e, o, h, b, F, D, P) {
var k = {
$$typeof: y,
type: e,
key: o,
ref: h,
props: P,
_owner: D
};
return k._store = {}, Object.defineProperty(k._store, "validated", {
configurable: !1,
enumerable: !1,
writable: !0,
value: !1
}), Object.defineProperty(k, "_self", {
configurable: !1,
enumerable: !1,
writable: !1,
value: b
}), Object.defineProperty(k, "_source", {
configurable: !1,
enumerable: !1,
writable: !1,
value: F
}), Object.freeze && (Object.freeze(k.props), Object.freeze(k)), k;
};
function ut(e, o, h, b, F) {
{
var D, P = {}, k = null, z = null;
h !== void 0 && (Oe(h), k = "" + h), it(o) && (Oe(o.key), k = "" + o.key), rt(o) && (z = o.ref, st(o, F));
for (D in o)
ge.call(o, D) && !tt.hasOwnProperty(D) && (P[D] = o[D]);
if (e && e.defaultProps) {
var N = e.defaultProps;
for (D in N)
P[D] === void 0 && (P[D] = N[D]);
}
if (k || z) {
var U = typeof e == "function" ? e.displayName || e.name || "Unknown" : e;
k && nt(P, U), z && at(P, U);
}
return ot(e, k, z, F, b, ae.current, P);
}
}
var xe = c.ReactCurrentOwner, Ne = c.ReactDebugCurrentFrame;
function re(e) {
if (e) {
var o = e._owner, h = ve(e.type, e._source, o ? o.type : null);
Ne.setExtraStackFrame(h);
} else
Ne.setExtraStackFrame(null);
}
var ke;
ke = !1;
function Ce(e) {
return typeof e == "object" && e !== null && e.$$typeof === y;
}
function Ue() {
{
if (xe.current) {
var e = M(xe.current.type);
if (e)
return `
Check the render method of \`` + e + "`.";
}
return "";
}
}
function lt(e) {
{
if (e !== void 0) {
var o = e.fileName.replace(/^.*[\\\/]/, ""), h = e.lineNumber;
return `
Check your code at ` + o + ":" + h + ".";
}
return "";
}
}
var Ie = {};
function ct(e) {
{
var o = Ue();
if (!o) {
var h = typeof e == "string" ? e : e.displayName || e.name;
h && (o = `
Check the top-level render call using <` + h + ">.");
}
return o;
}
}
function Le(e, o) {
{
if (!e._store || e._store.validated || e.key != null)
return;
e._store.validated = !0;
var h = ct(o);
if (Ie[h])
return;
Ie[h] = !0;
var b = "";
e && e._owner && e._owner !== xe.current && (b = " It was passed a child from " + M(e._owner.type) + "."), re(e), d('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.', h, b), re(null);
}
}
function ze(e, o) {
{
if (typeof e != "object")
return;
if (Re(e))
for (var h = 0; h < e.length; h++) {
var b = e[h];
Ce(b) && Le(b, o);
}
else if (Ce(e))
e._store && (e._store.validated = !0);
else if (e) {
var F = s(e);
if (typeof F == "function" && F !== e.entries)
for (var D = F.call(e), P; !(P = D.next()).done; )
Ce(P.value) && Le(P.value, o);
}
}
}
function ft(e) {
{
var o = e.type;
if (o == null || typeof o == "string")
return;
var h;
if (typeof o == "function")
h = o.propTypes;
else if (typeof o == "object" && (o.$$typeof === u || o.$$typeof === l))
h = o.propTypes;
else
return;
if (h) {
var b = M(o);
Ke(h, e.props, "prop", b, e);
} else if (o.PropTypes !== void 0 && !ke) {
ke = !0;
var F = M(o);
d("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", F || "Unknown");
}
typeof o.getDefaultProps == "function" && !o.getDefaultProps.isReactClassApproved && d("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.");
}
}
function ht(e) {
{
for (var o = Object.keys(e.props), h = 0; h < o.length; h++) {
var b = o[h];
if (b !== "children" && b !== "key") {
re(e), d("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.", b), re(null);
break;
}
}
e.ref !== null && (re(e), d("Invalid attribute `ref` supplied to `React.Fragment`."), re(null));
}
}
function Me(e, o, h, b, F, D) {
{
var P = L(e);
if (!P) {
var k = "";
(e === void 0 || typeof e == "object" && e !== null && Object.keys(e).length === 0) && (k += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");
var z = lt(F);
z ? k += z : k += Ue();
var N;
e === null ? N = "null" : Re(e) ? N = "array" : e !== void 0 && e.$$typeof === y ? (N = "<" + (M(e.type) || "Unknown") + " />", k = " Did you accidentally export a JSX literal instead of a component?") : N = typeof e, d("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", N, k);
}
var U = ut(e, o, h, F, D);
if (U == null)
return U;
if (P) {
var B = o.children;
if (B !== void 0)
if (b)
if (Re(B)) {
for (var ie = 0; ie < B.length; ie++)
ze(B[ie], e);
Object.freeze && Object.freeze(B);
} else
d("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");
else
ze(B, e);
}
return e === E ? ht(U) : ft(U), U;
}
}
function pt(e, o, h) {
return Me(e, o, h, !0);
}
function dt(e, o, h) {
return Me(e, o, h, !1);
}
var vt = dt, gt = pt;
ue.Fragment = E, ue.jsx = vt, ue.jsxs = gt;
}()), ue;
}
(function(m) {
process.env.NODE_ENV === "production" ? m.exports = bt() : m.exports = _t();
})(yt);
function ye(m) {
throw new Error('Could not dynamically require "' + m + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
}
var Pe = {}, Et = {
get exports() {
return Pe;
},
set exports(m) {
Pe = m;
}
};
/*!
* Uploader - Uploader library implements html5 file upload and provides multiple simultaneous, stable, fault tolerant and resumable uploads
* @version v0.6.0
* @author dolymood <dolymood@gmail.com>
* @link https://github.com/simple-uploader/Uploader
* @license MIT
*/
(function(m, y) {
(function(C) {
m.exports = C();
})(function() {
return function C(E, w, n) {
function R(t, r) {
if (!w[t]) {
if (!E[t]) {
var l = typeof ye == "function" && ye;
if (!r && l)
return l(t, !0);
if (p)
return p(t, !0);
throw new Error("Cannot find module '" + t + "'");
}
var a = w[t] = { exports: {} };
E[t][0].call(a.exports, function(i) {
var f = E[t][1][i];
return R(f || i);
}, a, a.exports, C, E, w, n);
}
return w[t].exports;
}
for (var p = typeof ye == "function" && ye, u = 0; u < n.length; u++)
R(n[u]);
return R;
}({ 1: [function(C, E, w) {
var n = C("./utils");
function R(u, t, r) {
n.defineNonEnumerable(this, "uploader", u), n.defineNonEnumerable(this, "file", t), n.defineNonEnumerable(this, "bytes", null), this.offset = r, this.tested = !1, this.retries = 0, this.pendingRetry = !1, this.preprocessState = 0, this.readState = 0, this.loaded = 0, this.total = 0, this.chunkSize = n.evalOpts(u.opts.chunkSize, t, this), this.startByte = this.offset * this.chunkSize, this.endByte = this.computeEndByte(), this.xhr = null;
}
var p = R.STATUS = {
PENDING: "pending",
UPLOADING: "uploading",
READING: "reading",
SUCCESS: "success",
ERROR: "error",
COMPLETE: "complete",
PROGRESS: "progress",
RETRY: "retry"
};
n.extend(R.prototype, {
_event: function(u, t) {
t = n.toArray(arguments), t.unshift(this), this.file._chunkEvent.apply(this.file, t);
},
computeEndByte: function() {
var u = Math.min(this.file.size, (this.offset + 1) * this.chunkSize);
return this.file.size - u < this.chunkSize && !this.uploader.opts.forceChunkSize && (u = this.file.size), u;
},
getParams: function() {
return {
chunkNumber: this.offset + 1,
chunkSize: this.chunkSize,
currentChunkSize: this.endByte - this.startByte,
totalSize: this.file.size,
identifier: this.file.uniqueIdentifier,
filename: this.file.name,
relativePath: this.file.relativePath,
totalChunks: this.file.chunks.length
};
},
getTarget: function(u, t) {
return t.length ? (u.indexOf("?") < 0 ? u += "?" : u += "&", u + t.join("&")) : u;
},
test: function() {
this.xhr = new XMLHttpRequest(), this.xhr.addEventListener("load", l, !1), this.xhr.addEventListener("error", l, !1);
var u = n.evalOpts(this.uploader.opts.testMethod, this.file, this), t = this.prepareXhrRequest(u, !0);
this.xhr.send(t);
var r = this;
function l(a) {
var i = r.status(!0);
i === p.ERROR ? (r._event(i, r.message()), r.uploader.uploadNextChunk()) : i === p.SUCCESS ? (r._event(i, r.message()), r.tested = !0) : r.file.paused || (r.tested = !0, r.send());
}
},
preprocessFinished: function() {
this.endByte = this.computeEndByte(), this.preprocessState = 2, this.send();
},
readFinished: function(u) {
this.readState = 2, this.bytes = u, this.send();
},
send: function() {
var u = this.uploader.opts.preprocess, t = this.uploader.opts.readFileFn;
if (n.isFunction(u))
switch (this.preprocessState) {
case 0:
this.preprocessState = 1, u(this);
return;
case 1:
return;
}
switch (this.readState) {
case 0:
this.readState = 1, t(this.file, this.file.fileType, this.startByte, this.endByte, this);
return;
case 1:
return;
}
if (this.uploader.opts.testChunks && !this.tested) {
this.test();
return;
}
this.loaded = 0, this.total = 0, this.pendingRetry = !1, this.xhr = new XMLHttpRequest(), this.xhr.upload.addEventListener("progress", i, !1), this.xhr.addEventListener("load", f, !1), this.xhr.addEventListener("error", f, !1);
var r = n.evalOpts(this.uploader.opts.uploadMethod, this.file, this), l = this.prepareXhrRequest(r, !1, this.uploader.opts.method, this.bytes);
this.xhr.send(l);
var a = this;
function i(S) {
S.lengthComputable && (a.loaded = S.loaded, a.total = S.total), a._event(p.PROGRESS, S);
}
function f(S) {
var s = a.message();
a.processingResponse = !0, a.uploader.opts.processResponse(s, function(c, d) {
if (a.processingResponse = !1, !!a.xhr) {
a.processedState = {
err: c,
res: d
};
var v = a.status();
if (v === p.SUCCESS || v === p.ERROR)
a._event(v, d), v === p.ERROR && a.uploader.uploadNextChunk();
else {
a._event(p.RETRY, d), a.pendingRetry = !0, a.abort(), a.retries++;
var x = a.uploader.opts.chunkRetryInterval;
x !== null ? setTimeout(function() {
a.send();
}, x) : a.send();
}
}
}, a.file, a);
}
},
abort: function() {
var u = this.xhr;
this.xhr = null, this.processingResponse = !1, this.processedState = null, u && u.abort();
},
status: function(u) {
if (this.readState === 1)
return p.READING;
if (this.pendingRetry || this.preprocessState === 1)
return p.UPLOADING;
if (this.xhr) {
if (this.xhr.readyState < 4 || this.processingResponse)
return p.UPLOADING;
var t;
this.uploader.opts.successStatuses.indexOf(this.xhr.status) > -1 ? t = p.SUCCESS : this.uploader.opts.permanentErrors.indexOf(this.xhr.status) > -1 || !u && this.retries >= this.uploader.opts.maxChunkRetries ? t = p.ERROR : (this.abort(), t = p.PENDING);
var r = this.processedState;
return r && r.err && (t = p.ERROR), t;
} else
return p.PENDING;
},
message: function() {
return this.xhr ? this.xhr.responseText : "";
},
progress: function() {
if (this.pendingRetry)
return 0;
var u = this.status();
return u === p.SUCCESS || u === p.ERROR ? 1 : u === p.PENDING ? 0 : this.total > 0 ? this.loaded / this.total : 0;
},
sizeUploaded: function() {
var u = this.endByte - this.startByte;
return this.status() !== p.SUCCESS && (u = this.progress() * u), u;
},
prepareXhrRequest: function(u, t, r, l) {
var a = n.evalOpts(this.uploader.opts.query, this.file, this, t);
a = n.extend(this.getParams(), a), a = this.uploader.opts.processParams(a, this.file, this, t);
var i = n.evalOpts(this.uploader.opts.target, this.file, this, t), f = null;
if (u === "GET" || r === "octet") {
var S = [];
n.each(a, function(s, c) {
S.push([encodeURIComponent(c), encodeURIComponent(s)].join("="));
}), i = this.getTarget(i, S), f = l || null;
} else
f = new FormData(), n.each(a, function(s, c) {
f.append(c, s);
}), typeof l < "u" && f.append(this.uploader.opts.fileParameterName, l, this.file.name);
return this.xhr.open(u, i, !0), this.xhr.withCredentials = this.uploader.opts.withCredentials, n.each(n.evalOpts(this.uploader.opts.headers, this.file, this, t), function(s, c) {
this.xhr.setRequestHeader(c, s);
}, this), f;
}
}), E.exports = R;
}, { "./utils": 5 }], 2: [function(C, E, w) {
var n = C("./utils").each, R = {
_eventData: null,
on: function(p, u) {
this._eventData || (this._eventData = {}), this._eventData[p] || (this._eventData[p] = []);
var t = !1;
n(this._eventData[p], function(r) {
if (r === u)
return t = !0, !1;
}), t || this._eventData[p].push(u);
},
off: function(p, u) {
this._eventData || (this._eventData = {}), !(!this._eventData[p] || !this._eventData[p].length) && (u ? n(this._eventData[p], function(t, r) {
if (t === u)
return this._eventData[p].splice(r, 1), !1;
}, this) : this._eventData[p] = []);
},
trigger: function(p) {
if (this._eventData || (this._eventData = {}), !this._eventData[p])
return !0;
var u = this._eventData[p].slice.call(arguments, 1), t = !1;
return n(this._eventData[p], function(r) {
t = r.apply(this, u) === !1 || t;
}, this), !t;
}
};
E.exports = R;
}, { "./utils": 5 }], 3: [function(C, E, w) {
var n = C("./utils"), R = C("./event"), p = C("./file"), u = C("./chunk"), t = "0.6.0", r = typeof window > "u", l = r ? !1 : window.navigator.msPointerEnabled, a = function() {
if (r)
return !1;
var s = "slice", c = n.isDefined(window.File) && n.isDefined(window.Blob) && n.isDefined(window.FileList), d = null;
return c && (d = window.Blob.prototype, n.each(["slice", "webkitSlice", "mozSlice"], function(v) {
if (d[v])
return s = v, !1;
}), c = !!d[s]), c && (f.sliceName = s), d = null, c;
}(), i = function() {
if (r)
return !1;
var s = window.document.createElement("input");
s.type = "file";
var c = "webkitdirectory" in s || "directory" in s;
return s = null, c;
}();
function f(s) {
this.support = a, this.support && (this.supportDirectory = i, n.defineNonEnumerable(this, "filePaths", {}), this.opts = n.extend({}, f.defaults, s || {}), this.preventEvent = n.bind(this._preventEvent, this), p.call(this, this));
}
var S = function(s, c, d, v, x) {
x.readFinished(s.file[f.sliceName](d, v, c));
};
f.version = t, f.defaults = {
chunkSize: 1024 * 1024,
forceChunkSize: !1,
simultaneousUploads: 3,
singleFile: !1,
fileParameterName: "file",
progressCallbacksInterval: 500,
speedSmoothingFactor: 0.1,
query: {},
headers: {},
withCredentials: !1,
preprocess: null,
method: "multipart",
testMethod: "GET",
uploadMethod: "POST",
prioritizeFirstAndLastChunk: !1,
allowDuplicateUploads: !1,
target: "/",
testChunks: !0,
generateUniqueIdentifier: null,
maxChunkRetries: 0,
chunkRetryInterval: null,
permanentErrors: [404, 415, 500, 501],
successStatuses: [200, 201, 202],
onDropStopPropagation: !1,
initFileFn: null,
readFileFn: S,
checkChunkUploadedByResponse: null,
initialPaused: !1,
processResponse: function(s, c) {
c(null, s);
},
processParams: function(s) {
return s;
}
}, f.utils = n, f.event = R, f.File = p, f.Chunk = u, f.prototype = n.extend({}, p.prototype), n.extend(f.prototype, R), n.extend(f.prototype, {
constructor: f,
_trigger: function(s) {
var c = n.toArray(arguments), d = !this.trigger.apply(this, arguments);
return s !== "catchAll" && (c.unshift("catchAll"), d = !this.trigger.apply(this, c) || d), !d;
},
_triggerAsync: function() {
var s = arguments;
n.nextTick(function() {
this._trigger.apply(this, s);
}, this);
},
addFiles: function(s, c) {
var d = [], v = this.fileList.length;
n.each(s, function(g) {
if ((!l || l && g.size > 0) && !(g.size % 4096 === 0 && (g.name === "." || g.fileName === "."))) {
var O = this.generateUniqueIdentifier(g);
if (this.opts.allowDuplicateUploads || !this.getFromUniqueIdentifier(O)) {
var j = new p(this, g, this);
j.uniqueIdentifier = O, this._trigger("fileAdded", j, c) ? d.push(j) : p.prototype.removeFile.call(this, j);
}
}
}, this);
var x = this.fileList.slice(v);
this._trigger("filesAdded", d, x, c) ? (n.each(d, function(g) {
this.opts.singleFile && this.files.length > 0 && this.removeFile(this.files[0]), this.files.push(g);
}, this), this._trigger("filesSubmitted", d, x, c)) : n.each(x, function(g) {
p.prototype.removeFile.call(this, g);
}, this);
},
addFile: function(s, c) {
this.addFiles([s], c);
},
cancel: function() {
for (var s = this.fileList.length - 1; s >= 0; s--)
this.fileList[s].cancel();
},
removeFile: function(s) {
p.prototype.removeFile.call(this, s), this._trigger("fileRemoved", s);
},
generateUniqueIdentifier: function(s) {
var c = this.opts.generateUniqueIdentifier;
if (n.isFunction(c))
return c(s);
var d = s.relativePath || s.webkitRelativePath || s.fileName || s.name;
return s.size + "-" + d.replace(/[^0-9a-zA-Z_-]/img, "");
},
getFromUniqueIdentifier: function(s) {
var c = !1;
return n.each(this.files, function(d) {
if (d.uniqueIdentifier === s)
return c = d, !1;
}), c;
},
uploadNextChunk: function(s) {
var c = !1, d = u.STATUS.PENDING, v = this.uploader.opts.checkChunkUploadedByResponse;
if (this.opts.prioritizeFirstAndLastChunk && (n.each(this.files, function(g) {
if (!g.paused && !(v && !g._firstResponse && g.isUploading())) {
if (g.chunks.length && g.chunks[0].status() === d)
return g.chunks[0].send(), c = !0, !1;
if (g.chunks.length > 1 && g.chunks[g.chunks.length - 1].status() === d)
return g.chunks[g.chunks.length - 1].send(), c = !0, !1;
}
}), c))
return c;
if (n.each(this.files, function(g) {
if (!g.paused) {
if (v && !g._firstResponse && g.isUploading())
return;
n.each(g.chunks, function(O) {
if (O.status() === d)
return O.send(), c = !0, !1;
});
}
if (c)
return !1;
}), c)
return !0;
var x = !1;
return n.each(this.files, function(g) {
if (!g.isComplete())
return x = !0, !1;
}), !x && !s && this.files.length && this._triggerAsync("complete"), x;
},
upload: function(s) {
var c = this._shouldUploadNext();
if (c !== !1) {
!s && this._trigger("uploadStart");
for (var d = !1, v = 1; v <= this.opts.simultaneousUploads - c && (d = this.uploadNextChunk(!s) || d, !(!d && s)); v++)
;
!d && !s && this._triggerAsync("complete");
}
},
_shouldUploadNext: function() {
var s = 0, c = !0, d = this.opts.simultaneousUploads, v = u.STATUS.UPLOADING;
return n.each(this.files, function(x) {
return n.each(x.chunks, function(g) {
if (g.status() === v && (s++, s >= d))
return c = !1, !1;
}), c;
}), c && s;
},
assignBrowse: function(s, c, d, v) {
typeof s.length > "u" && (s = [s]), n.each(s, function(x) {
var g;
x.tagName === "INPUT" && x.type === "file" ? g = x : (g = document.createElement("input"), g.setAttribute("type", "file"), n.extend(g.style, {
visibility: "hidden",
position: "absolute",
width: "1px",
height: "1px"
}), x.appendChild(g), x.addEventListener("click", function(j) {
x.tagName.toLowerCase() !== "label" && g.click();
}, !1)), !this.opts.singleFile && !d && g.setAttribute("multiple", "multiple"), c && g.setAttribute("webkitdirectory", "webkitdirectory"), v && n.each(v, function(j, G) {
g.setAttribute(G, j);
});
var O = this;
g.addEventListener("change", function(j) {
O._trigger(j.type, j), j.target.value && (O.addFiles(j.target.files, j), j.target.value = "");
}, !1);
}, this);
},
onDrop: function(s) {
this._trigger(s.type, s), this.opts.onDropStopPropagation && s.stopPropagation(), s.preventDefault(), this._parseDataTransfer(s.dataTransfer, s);
},
_parseDataTransfer: function(s, c) {
s.items && s.items[0] && s.items[0].webkitGetAsEntry ? this.webkitReadDataTransfer(s, c) : this.addFiles(s.files, c);
},
webkitReadDataTransfer: function(s, c) {
var d = this, v = s.items.length, x = [];
n.each(s.items, function(I) {
var L = I.webkitGetAsEntry();
if (!L) {
G();
return;
}
L.isFile ? O(I.getAsFile(), L.fullPath) : g(L.createReader());
});
function g(I) {
I.readEntries(function(L) {
L.length ? (v += L.length, n.each(L, function(q) {
if (q.isFile) {
var X = q.fullPath;
q.file(function(M) {
O(M, X);
}, j);
} else
q.isDirectory && g(q.createReader());
}), g(I)) : G();
}, j);
}
function O(I, L) {
I.relativePath = L.substring(1), x.push(I), G();
}
function j(I) {
throw I;
}
function G() {
--v === 0 && d.addFiles(x, c);
}
},
_assignHelper: function(s, c, d) {
typeof s.length > "u" && (s = [s]);
var v = d ? "removeEventListener" : "addEventListener";
n.each(s, function(x) {
n.each(c, function(g, O) {
x[v](O, g, !1);
}, this);
}, this);
},
_preventEvent: function(s) {
n.preventEvent(s), this._trigger(s.type, s);
},
assignDrop: function(s) {
this._onDrop = n.bind(this.onDrop, this), this._assignHelper(s, {
dragover: this.preventEvent,
dragenter: this.preventEvent,
dragleave: this.preventEvent,
drop: this._onDrop
});
},
unAssignDrop: function(s) {
this._assignHelper(s, {
dragover: this.preventEvent,
dragenter: this.preventEvent,
dragleave: this.preventEvent,
drop: this._onDrop
}, !0), this._onDrop = null;
}
}), E.exports = f;
}, { "./chunk": 1, "./event": 2, "./file": 4, "./utils": 5 }], 4: [function(C, E, w) {
var n = C("./utils"), R = C("./chunk");
function p(t, r, l) {
n.defineNonEnumerable(this, "uploader", t), this.isRoot = this.isFolder = t === this, n.defineNonEnumerable(this, "parent", l || null), n.defineNonEnumerable(this, "files", []), n.defineNonEnumerable(this, "fileList", []), n.defineNonEnumerable(this, "chunks", []), n.defineNonEnumerable(this, "_errorFiles", []), n.defineNonEnumerable(this, "file", null), this.id = n.uid(), this.isRoot || !r ? this.file = null : n.isString(r) ? (this.isFolder = !0, this.file = null, this.path = r, this.parent.path && (r = r.substr(this.parent.path.length)), this.name = r.charAt(r.length - 1) === "/" ? r.substr(0, r.length - 1) : r) : (this.file = r, this.fileType = this.file.type, this.name = r.fileName || r.name, this.size = r.size, this.relativePath = r.relativePath || r.webkitRelativePath || this.name, this._parseFile()), this.paused = t.opts.initialPaused, this.error = !1, this.allError = !1, this.aborted = !1, this.completed = !1, this.averageSpeed = 0, this.currentSpeed = 0, this._lastProgressCallback = Date.now(), this._prevUploadedSize = 0, this._prevProgress = 0, this.bootstrap();
}
n.extend(p.prototype, {
_parseFile: function() {
var t = u(this.relativePath);
if (t.length) {
var r = this.uploader.filePaths;
n.each(t, function(l, a) {
var i = r[l];
i || (i = new p(this.uploader, l, this.parent), r[l] = i, this._updateParentFileList(i)), this.parent = i, i.files.push(this), t[a + 1] || i.fileList.push(this);
}, this);
} else
this._updateParentFileList();
},
_updateParentFileList: function(t) {
t || (t = this);
var r = this.parent;
r && r.fileList.push(t);
},
_eachAccess: function(t, r) {
if (this.isFolder) {
n.each(this.files, function(l, a) {
return t.call(this, l, a);
}, this);
return;
}
r.call(this, this);
},
bootstrap: function() {
if (!this.isFolder) {
var t = this.uploader.opts;
n.isFunction(t.initFileFn) && t.initFileFn.call(this, this), this.abort(!0), this._resetError(), this._prevProgress = 0;
for (var r = t.forceChunkSize ? Math.ceil : Math.floor, l = Math.max(r(this.size / t.chunkSize), 1), a = 0; a < l; a++)
this.chunks.push(new R(this.uploader, this, a));
}
},
_measureSpeed: function() {
var t = this.uploader.opts.speedSmoothingFactor, r = Date.now() - this._lastProgressCallback;
if (r) {
var l = this.sizeUploaded();
this.currentSpeed = Math.max((l - this._prevUploadedSize) / r * 1e3, 0), this.averageSpeed = t * this.currentSpeed + (1 - t) * this.averageSpeed, this._prevUploadedSize = l, this.parent && this.parent._checkProgress() && this.parent._measureSpeed();
}
},
_checkProgress: function(t) {
return Date.now() - this._lastProgressCallback >= this.uploader.opts.progressCallbacksInterval;
},
_chunkEvent: function(t, r, l) {
var a = this.uploader, i = R.STATUS, f = this, S = this.getRoot(), s = function() {
f._measureSpeed(), a._trigger("fileProgress", S, f, t), f._lastProgressCallback = Date.now();
};
switch (r) {
case i.PROGRESS:
this._checkProgress() && s();
break;
case i.ERROR:
this._error(), this.abort(!0), a._trigger("fileError", S, this, l, t);
break;
case i.SUCCESS:
if (this._updateUploadedChunks(l, t), this.error)
return;
clearTimeout(this._progeressId), this._progeressId = 0;
var c = Date.now() - this._lastProgressCallback;
c < a.opts.progressCallbacksInterval && (this._progeressId = setTimeout(s, a.opts.progressCallbacksInterval - c)), this.isComplete() ? (clearTimeout(this._progeressId), s(), this.currentSpeed = 0, this.averageSpeed = 0, a._trigger("fileSuccess", S, this, l, t), S.isComplete() && a._trigger("fileComplete", S, this)) : this._progeressId || s();
break;
case i.RETRY:
a._trigger("fileRetry", S, this, t);
break;
}
},
_updateUploadedChunks: function(t, r) {
var l = this.uploader.opts.checkChunkUploadedByResponse;
if (l) {
var a = r.xhr;
n.each(this.chunks, function(i) {
if (!i.tested) {
var f = l.call(this, i, t);
i === r && !f && (i.xhr = null), f && (i.xhr = a), i.tested = !0;
}
}, this), this._firstResponse ? this.uploader.uploadNextChunk() : (this._firstResponse = !0, this.uploader.upload(!0));
} else
this.uploader.uploadNextChunk();
},
_error: function() {
this.error = this.allError = !0;
for (var t = this.parent; t && t !== this.uploader; )
t._errorFiles.push(this), t.error = !0, t._errorFiles.length === t.files.length && (t.allError = !0), t = t.parent;
},
_resetError: function() {
this.error = this.allError = !1;
for (var t = this.parent, r = -1; t && t !== this.uploader; )
r = t._errorFiles.indexOf(this), t._errorFiles.splice(r, 1), t.allError = !1, t._errorFiles.length || (t.error = !1), t = t.parent;
},
isComplete: function() {
if (!this.completed) {
var t = !1;
this._eachAccess(function(r) {
if (!r.isComplete())
return t = !0, !1;
}, function() {
if (this.error)
t = !0;
else {
var r = R.STATUS;
n.each(this.chunks, function(l) {
var a = l.status();
if (a === r.ERROR || a === r.PENDING || a === r.UPLOADING || a === r.READING || l.preprocessState === 1 || l.readState === 1)
return t = !0, !1;
});
}
}), this.completed = !t;
}
return this.completed;
},
isUploading: function() {
var t = !1;
return this._eachAccess(function(r) {
if (r.isUploading())
return t = !0, !1;
}, function() {
var r = R.STATUS.UPLOADING;
n.each(this.chunks, function(l) {
if (l.status() === r)
return t = !0, !1;
});
}), t;
},
resume: function() {
this._eachAccess(function(t) {
t.resume();
}, function() {
this.paused = !1, this.aborted = !1, this.uploader.upload();
}), this.paused = !1, this.aborted = !1;
},
pause: function() {
this._eachAccess(function(t) {
t.pause();
}, function() {
this.paused = !0, this.abort();
}), this.paused = !0;
},
cancel: function() {
this.uploader.removeFile(this);
},
retry: function(t) {
var r = function(l) {
l.error && l.bootstrap();
};
t ? t.bootstrap() : this._eachAccess(r, function() {
this.bootstrap();
}), this.uploader.upload();
},
abort: function(t) {
if (!this.aborted) {
this.currentSpeed = 0, this.averageSpeed = 0, this.aborted = !t;
var r = this.chunks;
t && (this.chunks = []);
var l = R.STATUS.UPLOADING;
n.each(r, function(a) {
a.status() === l && (a.abort(), this.uploader.uploadNextChunk());
}, this);
}
},
progress: function() {
var t = 0, r = 0, l = 0;
return this._eachAccess(function(a, i) {
t += a.progress() * a.size, r += a.size, i === this.files.length - 1 && (l = r > 0 ? t / r : this.isComplete() ? 1 : 0);
}, function() {
if (this.error) {
l = 1;
return;
}
if (this.chunks.length === 1) {
this._prevProgress = Math.max(this._prevProgress, this.chunks[0].progress()), l = this._prevProgress;
return;
}
var a = 0;
n.each(this.chunks, function(f) {
a += f.progress() * (f.endByte - f.startByte);
});
var i = a / this.size;
this._prevProgress = Math.max(this._prevProgress, i > 0.9999 ? 1 : i), l = this._prevProgress;
}), l;
},
getSize: function() {
var t = 0;
return this._eachAccess(function(r) {
t += r.size;
}, function() {
t += this.size;
}), t;
},
getFormatSize: function() {
var t = this.getSize();
return n.formatSize(t);
},
getRoot: function() {