@tinyuploader/react
Version:
806 lines (690 loc) • 69.7 kB
JavaScript
(function(U,d){typeof exports=="object"&&typeof module<"u"?module.exports=d(require("react"),require("prop-types")):typeof define=="function"&&define.amd?define(["react","prop-types"],d):(U=typeof globalThis<"u"?globalThis:U||self,U.Uploader=d(U.React,U.PropTypes))})(this,function(U,d){"use strict";var he={exports:{}},ee={};/**
* @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 Ae;function ct(){if(Ae)return ee;Ae=1;var a=U,n=Symbol.for("react.element"),u=Symbol.for("react.fragment"),h=Object.prototype.hasOwnProperty,p=a.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,_={key:!0,ref:!0,__self:!0,__source:!0};function v(m,S,E){var k,I={},W=null,H=null;E!==void 0&&(W=""+E),S.key!==void 0&&(W=""+S.key),S.ref!==void 0&&(H=S.ref);for(k in S)h.call(S,k)&&!_.hasOwnProperty(k)&&(I[k]=S[k]);if(m&&m.defaultProps)for(k in S=m.defaultProps,S)I[k]===void 0&&(I[k]=S[k]);return{$$typeof:n,type:m,key:W,ref:H,props:I,_owner:p.current}}return ee.Fragment=u,ee.jsx=v,ee.jsxs=v,ee}var te={};/**
* @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 Ce;function lt(){return Ce||(Ce=1,process.env.NODE_ENV!=="production"&&function(){var a=U,n=Symbol.for("react.element"),u=Symbol.for("react.portal"),h=Symbol.for("react.fragment"),p=Symbol.for("react.strict_mode"),_=Symbol.for("react.profiler"),v=Symbol.for("react.provider"),m=Symbol.for("react.context"),S=Symbol.for("react.forward_ref"),E=Symbol.for("react.suspense"),k=Symbol.for("react.suspense_list"),I=Symbol.for("react.memo"),W=Symbol.for("react.lazy"),H=Symbol.for("react.offscreen"),X=Symbol.iterator,Y="@@iterator";function C(r){if(r===null||typeof r!="object")return null;var l=X&&r[X]||r[Y];return typeof l=="function"?l:null}var c=a.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function o(r){{for(var l=arguments.length,f=new Array(l>1?l-1:0),b=1;b<l;b++)f[b-1]=arguments[b];t("error",r,f)}}function t(r,l,f){{var b=c.ReactDebugCurrentFrame,A=b.getStackAddendum();A!==""&&(l+="%s",f=f.concat([A]));var j=f.map(function(R){return String(R)});j.unshift("Warning: "+l),Function.prototype.apply.call(console[r],console,j)}}var e=!1,i=!1,s=!1,T=!1,O=!1,w;w=Symbol.for("react.module.reference");function F(r){return!!(typeof r=="string"||typeof r=="function"||r===h||r===_||O||r===p||r===E||r===k||T||r===H||e||i||s||typeof r=="object"&&r!==null&&(r.$$typeof===W||r.$$typeof===I||r.$$typeof===v||r.$$typeof===m||r.$$typeof===S||r.$$typeof===w||r.getModuleId!==void 0))}function me(r,l,f){var b=r.displayName;if(b)return b;var A=l.displayName||l.name||"";return A!==""?f+"("+A+")":f}function Le(r){return r.displayName||"Context"}function V(r){if(r==null)return null;if(typeof r.tag=="number"&&o("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof r=="function")return r.displayName||r.name||null;if(typeof r=="string")return r;switch(r){case h:return"Fragment";case u:return"Portal";case _:return"Profiler";case p:return"StrictMode";case E:return"Suspense";case k:return"SuspenseList"}if(typeof r=="object")switch(r.$$typeof){case m:var l=r;return Le(l)+".Consumer";case v:var f=r;return Le(f._context)+".Provider";case S:return me(r,r.render,"ForwardRef");case I:var b=r.displayName||null;return b!==null?b:V(r.type)||"Memo";case W:{var A=r,j=A._payload,R=A._init;try{return V(R(j))}catch{return null}}}return null}var Q=Object.assign,re=0,Ne,We,Ve,Ye,He,Ge,Qe;function Je(){}Je.__reactDisabledLog=!0;function Ft(){{if(re===0){Ne=console.log,We=console.info,Ve=console.warn,Ye=console.error,He=console.group,Ge=console.groupCollapsed,Qe=console.groupEnd;var r={configurable:!0,enumerable:!0,value:Je,writable:!0};Object.defineProperties(console,{info:r,log:r,warn:r,error:r,group:r,groupCollapsed:r,groupEnd:r})}re++}}function At(){{if(re--,re===0){var r={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:Q({},r,{value:Ne}),info:Q({},r,{value:We}),warn:Q({},r,{value:Ve}),error:Q({},r,{value:Ye}),group:Q({},r,{value:He}),groupCollapsed:Q({},r,{value:Ge}),groupEnd:Q({},r,{value:Qe})})}re<0&&o("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var ye=c.ReactCurrentDispatcher,ve;function oe(r,l,f){{if(ve===void 0)try{throw Error()}catch(A){var b=A.stack.trim().match(/\n( *(at )?)/);ve=b&&b[1]||""}return`
`+ve+r}}var ke=!1,ue;{var Ct=typeof WeakMap=="function"?WeakMap:Map;ue=new Ct}function Ke(r,l){if(!r||ke)return"";{var f=ue.get(r);if(f!==void 0)return f}var b;ke=!0;var A=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var j;j=ye.current,ye.current=null,Ft();try{if(l){var R=function(){throw Error()};if(Object.defineProperty(R.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(R,[])}catch(P){b=P}Reflect.construct(r,[],R)}else{try{R.call()}catch(P){b=P}r.call(R.prototype)}}else{try{throw Error()}catch(P){b=P}r()}}catch(P){if(P&&b&&typeof P.stack=="string"){for(var x=P.stack.split(`
`),z=b.stack.split(`
`),D=x.length-1,M=z.length-1;D>=1&&M>=0&&x[D]!==z[M];)M--;for(;D>=1&&M>=0;D--,M--)if(x[D]!==z[M]){if(D!==1||M!==1)do if(D--,M--,M<0||x[D]!==z[M]){var N=`
`+x[D].replace(" at new "," at ");return r.displayName&&N.includes("<anonymous>")&&(N=N.replace("<anonymous>",r.displayName)),typeof r=="function"&&ue.set(r,N),N}while(D>=1&&M>=0);break}}}finally{ke=!1,ye.current=j,At(),Error.prepareStackTrace=A}var $=r?r.displayName||r.name:"",J=$?oe($):"";return typeof r=="function"&&ue.set(r,J),J}function Et(r,l,f){return Ke(r,!1)}function jt(r){var l=r.prototype;return!!(l&&l.isReactComponent)}function ce(r,l,f){if(r==null)return"";if(typeof r=="function")return Ke(r,jt(r));if(typeof r=="string")return oe(r);switch(r){case E:return oe("Suspense");case k:return oe("SuspenseList")}if(typeof r=="object")switch(r.$$typeof){case S:return Et(r.render);case I:return ce(r.type,l,f);case W:{var b=r,A=b._payload,j=b._init;try{return ce(j(A),l,f)}catch{}}}return""}var se=Object.prototype.hasOwnProperty,qe={},Xe=c.ReactDebugCurrentFrame;function le(r){if(r){var l=r._owner,f=ce(r.type,r._source,l?l.type:null);Xe.setExtraStackFrame(f)}else Xe.setExtraStackFrame(null)}function Ut(r,l,f,b,A){{var j=Function.call.bind(se);for(var R in r)if(j(r,R)){var x=void 0;try{if(typeof r[R]!="function"){var z=Error((b||"React class")+": "+f+" type `"+R+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof r[R]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw z.name="Invariant Violation",z}x=r[R](l,R,b,f,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(D){x=D}x&&!(x instanceof Error)&&(le(A),o("%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",f,R,typeof x),le(null)),x instanceof Error&&!(x.message in qe)&&(qe[x.message]=!0,le(A),o("Failed %s type: %s",f,x.message),le(null))}}}var Bt=Array.isArray;function Se(r){return Bt(r)}function Ot(r){{var l=typeof Symbol=="function"&&Symbol.toStringTag,f=l&&r[Symbol.toStringTag]||r.constructor.name||"Object";return f}}function Dt(r){try{return Ze(r),!1}catch{return!0}}function Ze(r){return""+r}function $e(r){if(Dt(r))return o("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",Ot(r)),Ze(r)}var ie=c.ReactCurrentOwner,Mt={key:!0,ref:!0,__self:!0,__source:!0},et,tt,we;we={};function Tt(r){if(se.call(r,"ref")){var l=Object.getOwnPropertyDescriptor(r,"ref").get;if(l&&l.isReactWarning)return!1}return r.ref!==void 0}function It(r){if(se.call(r,"key")){var l=Object.getOwnPropertyDescriptor(r,"key").get;if(l&&l.isReactWarning)return!1}return r.key!==void 0}function zt(r,l){if(typeof r.ref=="string"&&ie.current&&l&&ie.current.stateNode!==l){var f=V(ie.current.type);we[f]||(o('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',V(ie.current.type),r.ref),we[f]=!0)}}function Pt(r,l){{var f=function(){et||(et=!0,o("%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)",l))};f.isReactWarning=!0,Object.defineProperty(r,"key",{get:f,configurable:!0})}}function Lt(r,l){{var f=function(){tt||(tt=!0,o("%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)",l))};f.isReactWarning=!0,Object.defineProperty(r,"ref",{get:f,configurable:!0})}}var Nt=function(r,l,f,b,A,j,R){var x={$$typeof:n,type:r,key:l,ref:f,props:R,_owner:j};return x._store={},Object.defineProperty(x._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(x,"_self",{configurable:!1,enumerable:!1,writable:!1,value:b}),Object.defineProperty(x,"_source",{configurable:!1,enumerable:!1,writable:!1,value:A}),Object.freeze&&(Object.freeze(x.props),Object.freeze(x)),x};function Wt(r,l,f,b,A){{var j,R={},x=null,z=null;f!==void 0&&($e(f),x=""+f),It(l)&&($e(l.key),x=""+l.key),Tt(l)&&(z=l.ref,zt(l,A));for(j in l)se.call(l,j)&&!Mt.hasOwnProperty(j)&&(R[j]=l[j]);if(r&&r.defaultProps){var D=r.defaultProps;for(j in D)R[j]===void 0&&(R[j]=D[j])}if(x||z){var M=typeof r=="function"?r.displayName||r.name||"Unknown":r;x&&Pt(R,M),z&&Lt(R,M)}return Nt(r,x,z,A,b,ie.current,R)}}var xe=c.ReactCurrentOwner,rt=c.ReactDebugCurrentFrame;function Z(r){if(r){var l=r._owner,f=ce(r.type,r._source,l?l.type:null);rt.setExtraStackFrame(f)}else rt.setExtraStackFrame(null)}var _e;_e=!1;function Re(r){return typeof r=="object"&&r!==null&&r.$$typeof===n}function st(){{if(xe.current){var r=V(xe.current.type);if(r)return`
Check the render method of \``+r+"`."}return""}}function Vt(r){return""}var it={};function Yt(r){{var l=st();if(!l){var f=typeof r=="string"?r:r.displayName||r.name;f&&(l=`
Check the top-level render call using <`+f+">.")}return l}}function nt(r,l){{if(!r._store||r._store.validated||r.key!=null)return;r._store.validated=!0;var f=Yt(l);if(it[f])return;it[f]=!0;var b="";r&&r._owner&&r._owner!==xe.current&&(b=" It was passed a child from "+V(r._owner.type)+"."),Z(r),o('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',f,b),Z(null)}}function at(r,l){{if(typeof r!="object")return;if(Se(r))for(var f=0;f<r.length;f++){var b=r[f];Re(b)&&nt(b,l)}else if(Re(r))r._store&&(r._store.validated=!0);else if(r){var A=C(r);if(typeof A=="function"&&A!==r.entries)for(var j=A.call(r),R;!(R=j.next()).done;)Re(R.value)&&nt(R.value,l)}}}function Ht(r){{var l=r.type;if(l==null||typeof l=="string")return;var f;if(typeof l=="function")f=l.propTypes;else if(typeof l=="object"&&(l.$$typeof===S||l.$$typeof===I))f=l.propTypes;else return;if(f){var b=V(l);Ut(f,r.props,"prop",b,r)}else if(l.PropTypes!==void 0&&!_e){_e=!0;var A=V(l);o("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",A||"Unknown")}typeof l.getDefaultProps=="function"&&!l.getDefaultProps.isReactClassApproved&&o("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Gt(r){{for(var l=Object.keys(r.props),f=0;f<l.length;f++){var b=l[f];if(b!=="children"&&b!=="key"){Z(r),o("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",b),Z(null);break}}r.ref!==null&&(Z(r),o("Invalid attribute `ref` supplied to `React.Fragment`."),Z(null))}}var ot={};function ut(r,l,f,b,A,j){{var R=F(r);if(!R){var x="";(r===void 0||typeof r=="object"&&r!==null&&Object.keys(r).length===0)&&(x+=" 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=Vt();z?x+=z:x+=st();var D;r===null?D="null":Se(r)?D="array":r!==void 0&&r.$$typeof===n?(D="<"+(V(r.type)||"Unknown")+" />",x=" Did you accidentally export a JSX literal instead of a component?"):D=typeof r,o("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",D,x)}var M=Wt(r,l,f,A,j);if(M==null)return M;if(R){var N=l.children;if(N!==void 0)if(b)if(Se(N)){for(var $=0;$<N.length;$++)at(N[$],r);Object.freeze&&Object.freeze(N)}else o("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 at(N,r)}if(se.call(l,"key")){var J=V(r),P=Object.keys(l).filter(function(Zt){return Zt!=="key"}),Fe=P.length>0?"{key: someKey, "+P.join(": ..., ")+": ...}":"{key: someKey}";if(!ot[J+Fe]){var Xt=P.length>0?"{"+P.join(": ..., ")+": ...}":"{}";o(`A props object containing a "key" prop is being spread into JSX:
let props = %s;
<%s {...props} />
React keys must be passed directly to JSX without using spread:
let props = %s;
<%s key={someKey} {...props} />`,Fe,J,Xt,J),ot[J+Fe]=!0}}return r===h?Gt(M):Ht(M),M}}function Qt(r,l,f){return ut(r,l,f,!0)}function Jt(r,l,f){return ut(r,l,f,!1)}var Kt=Jt,qt=Qt;te.Fragment=h,te.jsx=Kt,te.jsxs=qt}()),te}process.env.NODE_ENV==="production"?he.exports=ct():he.exports=lt();var y=he.exports;const fe=U.createContext(null);let ht=0;const de=(a="id")=>`${a}-${+new Date}-${ht++}`,ft=function(a){return typeof a<"u"},K=function(a){return typeof a=="function"},Ee=function(a){return Object.prototype.toString.call(a)==="[object Object]"&&Object.getPrototypeOf(a)===Object.prototype},je=Array.isArray||function(a){return Object.prototype.toString.call(a)==="[object Array]"},pe=a=>a&&K(a.then);function q(a,n,u){if(ft(a.length))for(var h=0,p=a.length;h<p&&n.call(u,a[h],h,a)!==!1;h++);else for(var _ in a)if(n.call(u,a[_],_,a)===!1)break}function ne(){var a,n,u,h,p,_,v=arguments[0]||{},m=1,S=arguments.length,E=!1;for(typeof v=="boolean"&&(E=v,v=arguments[1]||{},m++),typeof v!="object"&&!K(v)&&(v={}),m===S&&(v=this,m--);m<S;m++)if((a=arguments[m])!=null)for(n in a)u=v[n],h=a[n],v!==h&&(E&&h&&(Ee(h)||(p=je(h)))?(p?(p=!1,_=u&&je(u)?u:[]):_=u&&Ee(u)?u:{},v[n]=ne(E,_,h)):h!==void 0&&(v[n]=h));return v}class dt{constructor(){this.event={}}on(n,u){this.event||(this.event={}),this.event[n]||(this.event[n]=[]),!(this.event[n].indexOf(u)>-1)&&this.event[n].push(u)}off(n,u){if(!u){this.event[n]=[];return}if(this.event&&this.event[n]){for(let h=0;h<this.event[n].length;h++)if(u===this.event[n]){this.event.splice(h,1);return}}}emit(n,...u){this.event||(this.event={}),this.event[n]&&this.event[n].forEach(h=>{h(...u)})}once(n,u){function h(...p){u.apply(this,...p),this.off(n,h)}h.func=u,this.on(n,h)}}var Ue={exports:{}};(function(a,n){(function(u){a.exports=u()})(function(u){var h=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];function p(c,o){var t=c[0],e=c[1],i=c[2],s=c[3];t+=(e&i|~e&s)+o[0]-680876936|0,t=(t<<7|t>>>25)+e|0,s+=(t&e|~t&i)+o[1]-389564586|0,s=(s<<12|s>>>20)+t|0,i+=(s&t|~s&e)+o[2]+606105819|0,i=(i<<17|i>>>15)+s|0,e+=(i&s|~i&t)+o[3]-1044525330|0,e=(e<<22|e>>>10)+i|0,t+=(e&i|~e&s)+o[4]-176418897|0,t=(t<<7|t>>>25)+e|0,s+=(t&e|~t&i)+o[5]+1200080426|0,s=(s<<12|s>>>20)+t|0,i+=(s&t|~s&e)+o[6]-1473231341|0,i=(i<<17|i>>>15)+s|0,e+=(i&s|~i&t)+o[7]-45705983|0,e=(e<<22|e>>>10)+i|0,t+=(e&i|~e&s)+o[8]+1770035416|0,t=(t<<7|t>>>25)+e|0,s+=(t&e|~t&i)+o[9]-1958414417|0,s=(s<<12|s>>>20)+t|0,i+=(s&t|~s&e)+o[10]-42063|0,i=(i<<17|i>>>15)+s|0,e+=(i&s|~i&t)+o[11]-1990404162|0,e=(e<<22|e>>>10)+i|0,t+=(e&i|~e&s)+o[12]+1804603682|0,t=(t<<7|t>>>25)+e|0,s+=(t&e|~t&i)+o[13]-40341101|0,s=(s<<12|s>>>20)+t|0,i+=(s&t|~s&e)+o[14]-1502002290|0,i=(i<<17|i>>>15)+s|0,e+=(i&s|~i&t)+o[15]+1236535329|0,e=(e<<22|e>>>10)+i|0,t+=(e&s|i&~s)+o[1]-165796510|0,t=(t<<5|t>>>27)+e|0,s+=(t&i|e&~i)+o[6]-1069501632|0,s=(s<<9|s>>>23)+t|0,i+=(s&e|t&~e)+o[11]+643717713|0,i=(i<<14|i>>>18)+s|0,e+=(i&t|s&~t)+o[0]-373897302|0,e=(e<<20|e>>>12)+i|0,t+=(e&s|i&~s)+o[5]-701558691|0,t=(t<<5|t>>>27)+e|0,s+=(t&i|e&~i)+o[10]+38016083|0,s=(s<<9|s>>>23)+t|0,i+=(s&e|t&~e)+o[15]-660478335|0,i=(i<<14|i>>>18)+s|0,e+=(i&t|s&~t)+o[4]-405537848|0,e=(e<<20|e>>>12)+i|0,t+=(e&s|i&~s)+o[9]+568446438|0,t=(t<<5|t>>>27)+e|0,s+=(t&i|e&~i)+o[14]-1019803690|0,s=(s<<9|s>>>23)+t|0,i+=(s&e|t&~e)+o[3]-187363961|0,i=(i<<14|i>>>18)+s|0,e+=(i&t|s&~t)+o[8]+1163531501|0,e=(e<<20|e>>>12)+i|0,t+=(e&s|i&~s)+o[13]-1444681467|0,t=(t<<5|t>>>27)+e|0,s+=(t&i|e&~i)+o[2]-51403784|0,s=(s<<9|s>>>23)+t|0,i+=(s&e|t&~e)+o[7]+1735328473|0,i=(i<<14|i>>>18)+s|0,e+=(i&t|s&~t)+o[12]-1926607734|0,e=(e<<20|e>>>12)+i|0,t+=(e^i^s)+o[5]-378558|0,t=(t<<4|t>>>28)+e|0,s+=(t^e^i)+o[8]-2022574463|0,s=(s<<11|s>>>21)+t|0,i+=(s^t^e)+o[11]+1839030562|0,i=(i<<16|i>>>16)+s|0,e+=(i^s^t)+o[14]-35309556|0,e=(e<<23|e>>>9)+i|0,t+=(e^i^s)+o[1]-1530992060|0,t=(t<<4|t>>>28)+e|0,s+=(t^e^i)+o[4]+1272893353|0,s=(s<<11|s>>>21)+t|0,i+=(s^t^e)+o[7]-155497632|0,i=(i<<16|i>>>16)+s|0,e+=(i^s^t)+o[10]-1094730640|0,e=(e<<23|e>>>9)+i|0,t+=(e^i^s)+o[13]+681279174|0,t=(t<<4|t>>>28)+e|0,s+=(t^e^i)+o[0]-358537222|0,s=(s<<11|s>>>21)+t|0,i+=(s^t^e)+o[3]-722521979|0,i=(i<<16|i>>>16)+s|0,e+=(i^s^t)+o[6]+76029189|0,e=(e<<23|e>>>9)+i|0,t+=(e^i^s)+o[9]-640364487|0,t=(t<<4|t>>>28)+e|0,s+=(t^e^i)+o[12]-421815835|0,s=(s<<11|s>>>21)+t|0,i+=(s^t^e)+o[15]+530742520|0,i=(i<<16|i>>>16)+s|0,e+=(i^s^t)+o[2]-995338651|0,e=(e<<23|e>>>9)+i|0,t+=(i^(e|~s))+o[0]-198630844|0,t=(t<<6|t>>>26)+e|0,s+=(e^(t|~i))+o[7]+1126891415|0,s=(s<<10|s>>>22)+t|0,i+=(t^(s|~e))+o[14]-1416354905|0,i=(i<<15|i>>>17)+s|0,e+=(s^(i|~t))+o[5]-57434055|0,e=(e<<21|e>>>11)+i|0,t+=(i^(e|~s))+o[12]+1700485571|0,t=(t<<6|t>>>26)+e|0,s+=(e^(t|~i))+o[3]-1894986606|0,s=(s<<10|s>>>22)+t|0,i+=(t^(s|~e))+o[10]-1051523|0,i=(i<<15|i>>>17)+s|0,e+=(s^(i|~t))+o[1]-2054922799|0,e=(e<<21|e>>>11)+i|0,t+=(i^(e|~s))+o[8]+1873313359|0,t=(t<<6|t>>>26)+e|0,s+=(e^(t|~i))+o[15]-30611744|0,s=(s<<10|s>>>22)+t|0,i+=(t^(s|~e))+o[6]-1560198380|0,i=(i<<15|i>>>17)+s|0,e+=(s^(i|~t))+o[13]+1309151649|0,e=(e<<21|e>>>11)+i|0,t+=(i^(e|~s))+o[4]-145523070|0,t=(t<<6|t>>>26)+e|0,s+=(e^(t|~i))+o[11]-1120210379|0,s=(s<<10|s>>>22)+t|0,i+=(t^(s|~e))+o[2]+718787259|0,i=(i<<15|i>>>17)+s|0,e+=(s^(i|~t))+o[9]-343485551|0,e=(e<<21|e>>>11)+i|0,c[0]=t+c[0]|0,c[1]=e+c[1]|0,c[2]=i+c[2]|0,c[3]=s+c[3]|0}function _(c){var o=[],t;for(t=0;t<64;t+=4)o[t>>2]=c.charCodeAt(t)+(c.charCodeAt(t+1)<<8)+(c.charCodeAt(t+2)<<16)+(c.charCodeAt(t+3)<<24);return o}function v(c){var o=[],t;for(t=0;t<64;t+=4)o[t>>2]=c[t]+(c[t+1]<<8)+(c[t+2]<<16)+(c[t+3]<<24);return o}function m(c){var o=c.length,t=[1732584193,-271733879,-1732584194,271733878],e,i,s,T,O,w;for(e=64;e<=o;e+=64)p(t,_(c.substring(e-64,e)));for(c=c.substring(e-64),i=c.length,s=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],e=0;e<i;e+=1)s[e>>2]|=c.charCodeAt(e)<<(e%4<<3);if(s[e>>2]|=128<<(e%4<<3),e>55)for(p(t,s),e=0;e<16;e+=1)s[e]=0;return T=o*8,T=T.toString(16).match(/(.*?)(.{0,8})$/),O=parseInt(T[2],16),w=parseInt(T[1],16)||0,s[14]=O,s[15]=w,p(t,s),t}function S(c){var o=c.length,t=[1732584193,-271733879,-1732584194,271733878],e,i,s,T,O,w;for(e=64;e<=o;e+=64)p(t,v(c.subarray(e-64,e)));for(c=e-64<o?c.subarray(e-64):new Uint8Array(0),i=c.length,s=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],e=0;e<i;e+=1)s[e>>2]|=c[e]<<(e%4<<3);if(s[e>>2]|=128<<(e%4<<3),e>55)for(p(t,s),e=0;e<16;e+=1)s[e]=0;return T=o*8,T=T.toString(16).match(/(.*?)(.{0,8})$/),O=parseInt(T[2],16),w=parseInt(T[1],16)||0,s[14]=O,s[15]=w,p(t,s),t}function E(c){var o="",t;for(t=0;t<4;t+=1)o+=h[c>>t*8+4&15]+h[c>>t*8&15];return o}function k(c){var o;for(o=0;o<c.length;o+=1)c[o]=E(c[o]);return c.join("")}k(m("hello")),typeof ArrayBuffer<"u"&&!ArrayBuffer.prototype.slice&&function(){function c(o,t){return o=o|0||0,o<0?Math.max(o+t,0):Math.min(o,t)}ArrayBuffer.prototype.slice=function(o,t){var e=this.byteLength,i=c(o,e),s=e,T,O,w,F;return t!==u&&(s=c(t,e)),i>s?new ArrayBuffer(0):(T=s-i,O=new ArrayBuffer(T),w=new Uint8Array(O),F=new Uint8Array(this,i,T),w.set(F),O)}}();function I(c){return/[\u0080-\uFFFF]/.test(c)&&(c=unescape(encodeURIComponent(c))),c}function W(c,o){var t=c.length,e=new ArrayBuffer(t),i=new Uint8Array(e),s;for(s=0;s<t;s+=1)i[s]=c.charCodeAt(s);return o?i:e}function H(c){return String.fromCharCode.apply(null,new Uint8Array(c))}function X(c,o,t){var e=new Uint8Array(c.byteLength+o.byteLength);return e.set(new Uint8Array(c)),e.set(new Uint8Array(o),c.byteLength),e}function Y(c){var o=[],t=c.length,e;for(e=0;e<t-1;e+=2)o.push(parseInt(c.substr(e,2),16));return String.fromCharCode.apply(String,o)}function C(){this.reset()}return C.prototype.append=function(c){return this.appendBinary(I(c)),this},C.prototype.appendBinary=function(c){this._buff+=c,this._length+=c.length;var o=this._buff.length,t;for(t=64;t<=o;t+=64)p(this._hash,_(this._buff.substring(t-64,t)));return this._buff=this._buff.substring(t-64),this},C.prototype.end=function(c){var o=this._buff,t=o.length,e,i=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],s;for(e=0;e<t;e+=1)i[e>>2]|=o.charCodeAt(e)<<(e%4<<3);return this._finish(i,t),s=k(this._hash),c&&(s=Y(s)),this.reset(),s},C.prototype.reset=function(){return this._buff="",this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},C.prototype.getState=function(){return{buff:this._buff,length:this._length,hash:this._hash.slice()}},C.prototype.setState=function(c){return this._buff=c.buff,this._length=c.length,this._hash=c.hash,this},C.prototype.destroy=function(){delete this._hash,delete this._buff,delete this._length},C.prototype._finish=function(c,o){var t=o,e,i,s;if(c[t>>2]|=128<<(t%4<<3),t>55)for(p(this._hash,c),t=0;t<16;t+=1)c[t]=0;e=this._length*8,e=e.toString(16).match(/(.*?)(.{0,8})$/),i=parseInt(e[2],16),s=parseInt(e[1],16)||0,c[14]=i,c[15]=s,p(this._hash,c)},C.hash=function(c,o){return C.hashBinary(I(c),o)},C.hashBinary=function(c,o){var t=m(c),e=k(t);return o?Y(e):e},C.ArrayBuffer=function(){this.reset()},C.ArrayBuffer.prototype.append=function(c){var o=X(this._buff.buffer,c),t=o.length,e;for(this._length+=c.byteLength,e=64;e<=t;e+=64)p(this._hash,v(o.subarray(e-64,e)));return this._buff=e-64<t?new Uint8Array(o.buffer.slice(e-64)):new Uint8Array(0),this},C.ArrayBuffer.prototype.end=function(c){var o=this._buff,t=o.length,e=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],i,s;for(i=0;i<t;i+=1)e[i>>2]|=o[i]<<(i%4<<3);return this._finish(e,t),s=k(this._hash),c&&(s=Y(s)),this.reset(),s},C.ArrayBuffer.prototype.reset=function(){return this._buff=new Uint8Array(0),this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},C.ArrayBuffer.prototype.getState=function(){var c=C.prototype.getState.call(this);return c.buff=H(c.buff),c},C.ArrayBuffer.prototype.setState=function(c){return c.buff=W(c.buff,!0),C.prototype.setState.call(this,c)},C.ArrayBuffer.prototype.destroy=C.prototype.destroy,C.ArrayBuffer.prototype._finish=C.prototype._finish,C.ArrayBuffer.hash=function(c,o){var t=S(new Uint8Array(c)),e=k(t);return o?Y(e):e},C})})(Ue);var pt=Ue.exports;const gt=`
/*
* Fastest md5 implementation around (JKM md5).
* Credits: Joseph Myers
*
* @see http://www.myersdaily.org/joseph/javascript/md5-text.html
* @see http://jsperf.com/md5-shootout/7
*/
/* this function is much faster,
so if possible we use it. Some IEs
are the only ones I know of that
need the idiotic second function,
generated by an if clause. */
var add32 = function (a, b) {
return (a + b) & 0xffffffff
},
hex_chr = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f']
function cmn(q, a, b, x, s, t) {
a = add32(add32(a, q), add32(x, t))
return add32((a << s) | (a >>> (32 - s)), b)
}
function md5cycle(x, k) {
var a = x[0],
b = x[1],
c = x[2],
d = x[3]
a += (((b & c) | (~b & d)) + k[0] - 680876936) | 0
a = (((a << 7) | (a >>> 25)) + b) | 0
d += (((a & b) | (~a & c)) + k[1] - 389564586) | 0
d = (((d << 12) | (d >>> 20)) + a) | 0
c += (((d & a) | (~d & b)) + k[2] + 606105819) | 0
c = (((c << 17) | (c >>> 15)) + d) | 0
b += (((c & d) | (~c & a)) + k[3] - 1044525330) | 0
b = (((b << 22) | (b >>> 10)) + c) | 0
a += (((b & c) | (~b & d)) + k[4] - 176418897) | 0
a = (((a << 7) | (a >>> 25)) + b) | 0
d += (((a & b) | (~a & c)) + k[5] + 1200080426) | 0
d = (((d << 12) | (d >>> 20)) + a) | 0
c += (((d & a) | (~d & b)) + k[6] - 1473231341) | 0
c = (((c << 17) | (c >>> 15)) + d) | 0
b += (((c & d) | (~c & a)) + k[7] - 45705983) | 0
b = (((b << 22) | (b >>> 10)) + c) | 0
a += (((b & c) | (~b & d)) + k[8] + 1770035416) | 0
a = (((a << 7) | (a >>> 25)) + b) | 0
d += (((a & b) | (~a & c)) + k[9] - 1958414417) | 0
d = (((d << 12) | (d >>> 20)) + a) | 0
c += (((d & a) | (~d & b)) + k[10] - 42063) | 0
c = (((c << 17) | (c >>> 15)) + d) | 0
b += (((c & d) | (~c & a)) + k[11] - 1990404162) | 0
b = (((b << 22) | (b >>> 10)) + c) | 0
a += (((b & c) | (~b & d)) + k[12] + 1804603682) | 0
a = (((a << 7) | (a >>> 25)) + b) | 0
d += (((a & b) | (~a & c)) + k[13] - 40341101) | 0
d = (((d << 12) | (d >>> 20)) + a) | 0
c += (((d & a) | (~d & b)) + k[14] - 1502002290) | 0
c = (((c << 17) | (c >>> 15)) + d) | 0
b += (((c & d) | (~c & a)) + k[15] + 1236535329) | 0
b = (((b << 22) | (b >>> 10)) + c) | 0
a += (((b & d) | (c & ~d)) + k[1] - 165796510) | 0
a = (((a << 5) | (a >>> 27)) + b) | 0
d += (((a & c) | (b & ~c)) + k[6] - 1069501632) | 0
d = (((d << 9) | (d >>> 23)) + a) | 0
c += (((d & b) | (a & ~b)) + k[11] + 643717713) | 0
c = (((c << 14) | (c >>> 18)) + d) | 0
b += (((c & a) | (d & ~a)) + k[0] - 373897302) | 0
b = (((b << 20) | (b >>> 12)) + c) | 0
a += (((b & d) | (c & ~d)) + k[5] - 701558691) | 0
a = (((a << 5) | (a >>> 27)) + b) | 0
d += (((a & c) | (b & ~c)) + k[10] + 38016083) | 0
d = (((d << 9) | (d >>> 23)) + a) | 0
c += (((d & b) | (a & ~b)) + k[15] - 660478335) | 0
c = (((c << 14) | (c >>> 18)) + d) | 0
b += (((c & a) | (d & ~a)) + k[4] - 405537848) | 0
b = (((b << 20) | (b >>> 12)) + c) | 0
a += (((b & d) | (c & ~d)) + k[9] + 568446438) | 0
a = (((a << 5) | (a >>> 27)) + b) | 0
d += (((a & c) | (b & ~c)) + k[14] - 1019803690) | 0
d = (((d << 9) | (d >>> 23)) + a) | 0
c += (((d & b) | (a & ~b)) + k[3] - 187363961) | 0
c = (((c << 14) | (c >>> 18)) + d) | 0
b += (((c & a) | (d & ~a)) + k[8] + 1163531501) | 0
b = (((b << 20) | (b >>> 12)) + c) | 0
a += (((b & d) | (c & ~d)) + k[13] - 1444681467) | 0
a = (((a << 5) | (a >>> 27)) + b) | 0
d += (((a & c) | (b & ~c)) + k[2] - 51403784) | 0
d = (((d << 9) | (d >>> 23)) + a) | 0
c += (((d & b) | (a & ~b)) + k[7] + 1735328473) | 0
c = (((c << 14) | (c >>> 18)) + d) | 0
b += (((c & a) | (d & ~a)) + k[12] - 1926607734) | 0
b = (((b << 20) | (b >>> 12)) + c) | 0
a += ((b ^ c ^ d) + k[5] - 378558) | 0
a = (((a << 4) | (a >>> 28)) + b) | 0
d += ((a ^ b ^ c) + k[8] - 2022574463) | 0
d = (((d << 11) | (d >>> 21)) + a) | 0
c += ((d ^ a ^ b) + k[11] + 1839030562) | 0
c = (((c << 16) | (c >>> 16)) + d) | 0
b += ((c ^ d ^ a) + k[14] - 35309556) | 0
b = (((b << 23) | (b >>> 9)) + c) | 0
a += ((b ^ c ^ d) + k[1] - 1530992060) | 0
a = (((a << 4) | (a >>> 28)) + b) | 0
d += ((a ^ b ^ c) + k[4] + 1272893353) | 0
d = (((d << 11) | (d >>> 21)) + a) | 0
c += ((d ^ a ^ b) + k[7] - 155497632) | 0
c = (((c << 16) | (c >>> 16)) + d) | 0
b += ((c ^ d ^ a) + k[10] - 1094730640) | 0
b = (((b << 23) | (b >>> 9)) + c) | 0
a += ((b ^ c ^ d) + k[13] + 681279174) | 0
a = (((a << 4) | (a >>> 28)) + b) | 0
d += ((a ^ b ^ c) + k[0] - 358537222) | 0
d = (((d << 11) | (d >>> 21)) + a) | 0
c += ((d ^ a ^ b) + k[3] - 722521979) | 0
c = (((c << 16) | (c >>> 16)) + d) | 0
b += ((c ^ d ^ a) + k[6] + 76029189) | 0
b = (((b << 23) | (b >>> 9)) + c) | 0
a += ((b ^ c ^ d) + k[9] - 640364487) | 0
a = (((a << 4) | (a >>> 28)) + b) | 0
d += ((a ^ b ^ c) + k[12] - 421815835) | 0
d = (((d << 11) | (d >>> 21)) + a) | 0
c += ((d ^ a ^ b) + k[15] + 530742520) | 0
c = (((c << 16) | (c >>> 16)) + d) | 0
b += ((c ^ d ^ a) + k[2] - 995338651) | 0
b = (((b << 23) | (b >>> 9)) + c) | 0
a += ((c ^ (b | ~d)) + k[0] - 198630844) | 0
a = (((a << 6) | (a >>> 26)) + b) | 0
d += ((b ^ (a | ~c)) + k[7] + 1126891415) | 0
d = (((d << 10) | (d >>> 22)) + a) | 0
c += ((a ^ (d | ~b)) + k[14] - 1416354905) | 0
c = (((c << 15) | (c >>> 17)) + d) | 0
b += ((d ^ (c | ~a)) + k[5] - 57434055) | 0
b = (((b << 21) | (b >>> 11)) + c) | 0
a += ((c ^ (b | ~d)) + k[12] + 1700485571) | 0
a = (((a << 6) | (a >>> 26)) + b) | 0
d += ((b ^ (a | ~c)) + k[3] - 1894986606) | 0
d = (((d << 10) | (d >>> 22)) + a) | 0
c += ((a ^ (d | ~b)) + k[10] - 1051523) | 0
c = (((c << 15) | (c >>> 17)) + d) | 0
b += ((d ^ (c | ~a)) + k[1] - 2054922799) | 0
b = (((b << 21) | (b >>> 11)) + c) | 0
a += ((c ^ (b | ~d)) + k[8] + 1873313359) | 0
a = (((a << 6) | (a >>> 26)) + b) | 0
d += ((b ^ (a | ~c)) + k[15] - 30611744) | 0
d = (((d << 10) | (d >>> 22)) + a) | 0
c += ((a ^ (d | ~b)) + k[6] - 1560198380) | 0
c = (((c << 15) | (c >>> 17)) + d) | 0
b += ((d ^ (c | ~a)) + k[13] + 1309151649) | 0
b = (((b << 21) | (b >>> 11)) + c) | 0
a += ((c ^ (b | ~d)) + k[4] - 145523070) | 0
a = (((a << 6) | (a >>> 26)) + b) | 0
d += ((b ^ (a | ~c)) + k[11] - 1120210379) | 0
d = (((d << 10) | (d >>> 22)) + a) | 0
c += ((a ^ (d | ~b)) + k[2] + 718787259) | 0
c = (((c << 15) | (c >>> 17)) + d) | 0
b += ((d ^ (c | ~a)) + k[9] - 343485551) | 0
b = (((b << 21) | (b >>> 11)) + c) | 0
x[0] = (a + x[0]) | 0
x[1] = (b + x[1]) | 0
x[2] = (c + x[2]) | 0
x[3] = (d + x[3]) | 0
}
function md5blk(s) {
var md5blks = [],
i /* Andy King said do it this way. */
for (i = 0; i < 64; i += 4) {
md5blks[i >> 2] =
s.charCodeAt(i) +
(s.charCodeAt(i + 1) << 8) +
(s.charCodeAt(i + 2) << 16) +
(s.charCodeAt(i + 3) << 24)
}
return md5blks
}
function md5blk_array(a) {
var md5blks = [],
i /* Andy King said do it this way. */
for (i = 0; i < 64; i += 4) {
md5blks[i >> 2] = a[i] + (a[i + 1] << 8) + (a[i + 2] << 16) + (a[i + 3] << 24)
}
return md5blks
}
function md51(s) {
var n = s.length,
state = [1732584193, -271733879, -1732584194, 271733878],
i,
length,
tail,
tmp,
lo,
hi
for (i = 64; i <= n; i += 64) {
md5cycle(state, md5blk(s.substring(i - 64, i)))
}
s = s.substring(i - 64)
length = s.length
tail = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
for (i = 0; i < length; i += 1) {
tail[i >> 2] |= s.charCodeAt(i) << (i % 4 << 3)
}
tail[i >> 2] |= 0x80 << (i % 4 << 3)
if (i > 55) {
md5cycle(state, tail)
for (i = 0; i < 16; i += 1) {
tail[i] = 0
}
}
// Beware that the final length might not fit in 32 bits so we take care of that
tmp = n * 8
tmp = tmp.toString(16).match(/(.*?)(.{0,8})$/)
lo = parseInt(tmp[2], 16)
hi = parseInt(tmp[1], 16) || 0
tail[14] = lo
tail[15] = hi
md5cycle(state, tail)
return state
}
function md51_array(a) {
var n = a.length,
state = [1732584193, -271733879, -1732584194, 271733878],
i,
length,
tail,
tmp,
lo,
hi
for (i = 64; i <= n; i += 64) {
md5cycle(state, md5blk_array(a.subarray(i - 64, i)))
}
// Not sure if it is a bug, however IE10 will always produce a sub array of length 1
// containing the last element of the parent array if the sub array specified starts
// beyond the length of the parent array - weird.
// https://connect.microsoft.com/IE/feedback/details/771452/typed-array-subarray-issue
a = i - 64 < n ? a.subarray(i - 64) : new Uint8Array(0)
length = a.length
tail = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
for (i = 0; i < length; i += 1) {
tail[i >> 2] |= a[i] << (i % 4 << 3)
}
tail[i >> 2] |= 0x80 << (i % 4 << 3)
if (i > 55) {
md5cycle(state, tail)
for (i = 0; i < 16; i += 1) {
tail[i] = 0
}
}
// Beware that the final length might not fit in 32 bits so we take care of that
tmp = n * 8
tmp = tmp.toString(16).match(/(.*?)(.{0,8})$/)
lo = parseInt(tmp[2], 16)
hi = parseInt(tmp[1], 16) || 0
tail[14] = lo
tail[15] = hi
md5cycle(state, tail)
return state
}
function rhex(n) {
var s = '',
j
for (j = 0; j < 4; j += 1) {
s += hex_chr[(n >> (j * 8 + 4)) & 0x0f] + hex_chr[(n >> (j * 8)) & 0x0f]
}
return s
}
function hex(x) {
var i
for (i = 0; i < x.length; i += 1) {
x[i] = rhex(x[i])
}
return x.join('')
}
// In some cases the fast add32 function cannot be used..
if (hex(md51('hello')) !== '5d41402abc4b2a76b9719d911017c592') {
add32 = function (x, y) {
var lsw = (x & 0xffff) + (y & 0xffff),
msw = (x >> 16) + (y >> 16) + (lsw >> 16)
return (msw << 16) | (lsw & 0xffff)
}
}
// ---------------------------------------------------
/**
* ArrayBuffer slice polyfill.
*
* @see https://github.com/ttaubert/node-arraybuffer-slice
*/
if (typeof ArrayBuffer !== 'undefined' && !ArrayBuffer.prototype.slice) {
;(function () {
function clamp(val, length) {
val = val | 0 || 0
if (val < 0) {
return Math.max(val + length, 0)
}
return Math.min(val, length)
}
ArrayBuffer.prototype.slice = function (from, to) {
var length = this.byteLength,
begin = clamp(from, length),
end = length,
num,
target,
targetArray,
sourceArray
if (to !== undefined) {
end = clamp(to, length)
}
if (begin > end) {
return new ArrayBuffer(0)
}
num = end - begin
target = new ArrayBuffer(num)
targetArray = new Uint8Array(target)
sourceArray = new Uint8Array(this, begin, num)
targetArray.set(sourceArray)
return target
}
})()
}
// ---------------------------------------------------
/**
* Helpers.
*/
function toUtf8(str) {
if (/[-]/.test(str)) {
str = unescape(encodeURIComponent(str))
}
return str
}
function utf8Str2ArrayBuffer(str, returnUInt8Array) {
var length = str.length,
buff = new ArrayBuffer(length),
arr = new Uint8Array(buff),
i
for (i = 0; i < length; i += 1) {
arr[i] = str.charCodeAt(i)
}
return returnUInt8Array ? arr : buff
}
function arrayBuffer2Utf8Str(buff) {
return String.fromCharCode.apply(null, new Uint8Array(buff))
}
function concatenateArrayBuffers(first, second, returnUInt8Array) {
var result = new Uint8Array(first.byteLength + second.byteLength)
result.set(new Uint8Array(first))
result.set(new Uint8Array(second), first.byteLength)
return returnUInt8Array ? result : result.buffer
}
function hexToBinaryString(hex) {
var bytes = [],
length = hex.length,
x
for (x = 0; x < length - 1; x += 2) {
bytes.push(parseInt(hex.substr(x, 2), 16))
}
return String.fromCharCode.apply(String, bytes)
}
// ---------------------------------------------------
/**
* SparkMD5 OOP implementation.
*
* Use this class to perform an incremental md5, otherwise use the
* static methods instead.
*/
function SparkMD5() {
// call reset to init the instance
this.reset()
}
/**
* Appends a string.
* A conversion will be applied if an utf8 string is detected.
*
* @param {String} str The string to be appended
*
* @return {SparkMD5} The instance itself
*/
SparkMD5.prototype.append = function (str) {
// Converts the string to utf8 bytes if necessary
// Then append as binary
this.appendBinary(toUtf8(str))
return this
}
/**
* Appends a binary string.
*
* @param {String} contents The binary string to be appended
*
* @return {SparkMD5} The instance itself
*/
SparkMD5.prototype.appendBinary = function (contents) {
this._buff += contents
this._length += contents.length
var length = this._buff.length,
i
for (i = 64; i <= length; i += 64) {
md5cycle(this._hash, md5blk(this._buff.substring(i - 64, i)))
}
this._buff = this._buff.substring(i - 64)
return this
}
/**
* Finishes the incremental computation, reseting the internal state and
* returning the result.
*
* @param {Boolean} raw True to get the raw string, false to get the hex string
*
* @return {String} The result
*/
SparkMD5.prototype.end = function (raw) {
var buff = this._buff,
length = buff.length,
i,
tail = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
ret
for (i = 0; i < length; i += 1) {
tail[i >> 2] |= buff.charCodeAt(i) << (i % 4 << 3)
}
this._finish(tail, length)
ret = hex(this._hash)
if (raw) {
ret = hexToBinaryString(ret)
}
this.reset()
return ret
}
/**
* Resets the internal state of the computation.
*
* @return {SparkMD5} The instance itself
*/
SparkMD5.prototype.reset = function () {
this._buff = ''
this._length = 0
this._hash = [1732584193, -271733879, -1732584194, 271733878]
return this
}
/**
* Gets the internal state of the computation.
*
* @return {Object} The state
*/
SparkMD5.prototype.getState = function () {
return {
buff: this._buff,
length: this._length,
hash: this._hash.slice()
}
}
/**
* Gets the internal state of the computation.
*
* @param {Object} state The state
*
* @return {SparkMD5} The instance itself
*/
SparkMD5.prototype.setState = function (state) {
this._buff = state.buff
this._length = state.length
this._hash = state.hash
return this
}
/**
* Releases memory used by the incremental buffer and other additional
* resources. If you plan to use the instance again, use reset instead.
*/
SparkMD5.prototype.destroy = function () {
delete this._hash
delete this._buff
delete this._length
}
/**
* Finish the final calculation based on the tail.
*
* @param {Array} tail The tail (will be modified)
* @param {Number} length The length of the remaining buffer
*/
SparkMD5.prototype._finish = function (tail, length) {
var i = length,
tmp,
lo,
hi
tail[i >> 2] |= 0x80 << (i % 4 << 3)
if (i > 55) {
md5cycle(this._hash, tail)
for (i = 0; i < 16; i += 1) {
tail[i] = 0
}
}
// Do the final computation based on the tail and length
// Beware that the final length may not fit in 32 bits so we take care of that
tmp = this._length * 8
tmp = tmp.toString(16).match(/(.*?)(.{0,8})$/)
lo = parseInt(tmp[2], 16)
hi = parseInt(tmp[1], 16) || 0
tail[14] = lo
tail[15] = hi
md5cycle(this._hash, tail)
}
/**
* Performs the md5 hash on a string.
* A conversion will be applied if utf8 string is detected.
*
* @param {String} str The string
* @param {Boolean} [raw] True to get the raw string, false to get the hex string
*
* @return {String} The result
*/
SparkMD5.hash = function (str, raw) {
// Converts the string to utf8 bytes if necessary
// Then compute it using the binary function
return SparkMD5.hashBinary(toUtf8(str), raw)
}
/**
* Performs the md5 hash on a binary string.
*
* @param {String} content The binary string
* @param {Boolean} [raw] True to get the raw string, false to get the hex string
*
* @return {String} The result
*/
SparkMD5.hashBinary = function (content, raw) {
var hash = md51(content),
ret = hex(hash)
return raw ? hexToBinaryString(ret) : ret
}
// ---------------------------------------------------
/**
* SparkMD5 OOP implementation for array buffers.
*
* Use this class to perform an incremental md5 ONLY for array buffers.
*/
SparkMD5.ArrayBuffer = function () {
// call reset to init the instance
this.reset()
}
/**
* Appends an array buffer.
*
* @param {ArrayBuffer} arr The array to be appended
*
* @return {SparkMD5.ArrayBuffer} The instance itself
*/
SparkMD5.ArrayBuffer.prototype.append = function (arr) {
var buff = concatenateArrayBuffers(this._buff.buffer, arr, true),
length = buff.length,
i
this._length += arr.byteLength
for (i = 64; i <= length; i += 64) {
md5cycle(this._hash, md5blk_array(buff.subarray(i - 64, i)))
}
this._buff = i - 64 < length ? new Uint8Array(buff.buffer.slice(i - 64)) : new Uint8Array(0)
return this
}
/**
* Finishes the incremental computation, reseting the internal state and
* returning the result.
*
* @param {Boolean} raw True to get the raw string, false to get the hex string
*
* @return {String} The result
*/
SparkMD5.ArrayBuffer.prototype.end = function (raw) {
var buff = this._buff,
length = buff.length,
tail = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
i,
ret
for (i = 0; i < length; i += 1) {
tail[i >> 2] |= buff[i] << (i % 4 << 3)
}
this._finish(tail, length)
ret = hex(this._hash)
if (raw) {
ret = hexToBinaryString(ret)
}
this.reset()
return ret
}
/**
* Resets the internal state of the computation.
*
* @return {SparkMD5.ArrayBuffer} The instance itself
*/
SparkMD5.ArrayBuffer.prototype.reset = function () {
this._buff = new Uint8Array(0)
this._length = 0
this._hash = [1732584193, -271733879, -1732584194, 271733878]
return this
}
/**
* Gets the internal state of the computation.
*
* @return {Object} The state
*/
SparkMD5.ArrayBuffer.prototype.getState = function () {
var state = SparkMD5.prototype.getState.call(this)
// Convert buffer to a string
state.buff = arrayBuffer2Utf8Str(state.buff)
return state
}
/**
* Gets the internal state of the computation.
*
* @param {Object} state The state
*
* @return {SparkMD5.ArrayBuffer} The instance itself
*/
SparkMD5.ArrayBuffer.prototype.setState = function (state) {
// Convert string to buffer
state.buff = utf8Str2ArrayBuffer(state.buff, true)
return SparkMD5.prototype.setState.call(this, state)
}
SparkMD5.ArrayBuffer.prototype.destroy = SparkMD5.prototype.destroy
SparkMD5.ArrayBuffer.prototype._finish = SparkMD5.prototype._finish
/**
* Performs the md5 hash on an array buffer.
*
* @param {ArrayBuffer} arr The array buffer
* @param {Boolean} [raw] True to get the raw string, false to get the hex one
*
* @return {String} The result
*/
SparkMD5.ArrayBuffer.hash = function (arr, raw) {
var hash = md51_array(new Uint8Array(arr)),
ret = hex(hash)
return raw ? hexToBinaryString(ret) : ret
}
`,bt=`self.onmessage = (e) => {
const { file, chunkSize, type } = e.data
if(type === 'DONE') {
// console.log('worker closed !')
self.close()
return
}
${gt}
const slice = File.prototype.slice || File.prototype.mozSlice || File.prototype.webkitSlice
const spark = new SparkMD5.ArrayBuffer()
const fileReader = new FileReader()
const totalChunks = Math.ceil(file.size / chunkSize)
const startTime = Date.now()
let currentChunk = 0
fileReader.onload = (e) => {
spark.append(e.target.result)
currentChunk++
if (currentChunk < totalChunks) {
loadNext()
self.postMessage({ error: null, progress: (currentChunk / totalChunks) * 100 })
} else {
const result = {
hash: spark.end(),
time: Date.now() - startTime,
progress: 100
}
self.postMessage({ error: null, ...result })
}
}
fileReader.onerror = (error) => {
console.warn('oops, something went wrong.')
self.postMessage({ error })
}
function loadNext() {
const start = currentChunk * chunkSize
const end = start + chunkSize >= file.size ? file.size : start + chunkSize
fileReader.readAsArrayBuffer(slice.call(file, start, end))
}
loadNext()
}
`,mt=!!window.Worker,yt=({file:a,chunkSize:n},u)=>{console.log("In Web Worker");const h=new Worker(URL.createObjectURL(new Blob([bt]))),p=()=>{h.postMessage({type:"DONE"}),h.terminate()};h.postMessage({file:a,chunkSize:n}),h.onmessage=_=>{const{error:v,progress:m,hash:S,time:E}=_.data;if(v){u(v),p();return}if(m===100){p(),u(null,{progress:m,hash:S,time:E});return}u(null,{progress:m})}},vt=({file:a,chunkSize:n},u)=>{const h=File.prototype.slice||File.prototype.mozSlice||File.prototype.webkitSlice,p=new pt.ArrayBuffer,_=new FileReader,v=Math.ceil(a.size/n),m=Date.now();let S=0;_.onload=function(k){if(p.append(k.target.result),S++,S<v)E(),u(null,{progress:S/v*100});else{const I={hash:p.end(),time:Date.now()-m,progress:100};u(null,I)}},_.onerror=function(k){console.warn("oops, something went wrong."),u(k)};function E(){const k=S*n,I=k+n>=a.size?a.size:k+n;_.readAsArrayBuffer(h.call(a,k,I))}E()},kt=({file:a,chunkSize:n,inWorker:u},h)=>new Promise((p,_)=>{(mt&&u?yt:vt)({file:a,chunkSize:n},(v,{progress:m,hash:S,time:E})=>{v&&_(v),m===100&&p({progress:m,hash:S,time:E}),h&&h({progress:m})})}),g={Init:"init",Reading:"reading",Ready:"ready",Pending:"pending",Uploading:"uploading",UploadSuccess:"uploadSuccess",UploadFail:"uploadFail",Success:"success",Fail:"fail",Pause:"pause",Resume:"resume"},B={Exceed:"exceed",FilesAdded:"filesAdded",FileChange:"fileChange",FileRemove:"fileRemove",FileProgress:"fileProgress",FileFail:"fileFail",FileUploadFail:"fileUploadFail",FileUploadSuccess:"fileUploadSuccess",FileSuccess:"fileSuccess",AllFileSuccess:"allFilesSuccess",Change:"change"},ae={Part:"part",Success:"success",None:"none"};class St{constructor(n,u){this.uploader=n.uploader,this.opts=n.uploader.opts,this.file=n,this.filename=n.name,this.fileId=n.uid,this.totalSize=n.size,this.chunkSize=this.opts.chunkSize,this.fileHash=this.file.hash,this.uid=de("chunk_id"),this.stardByte=this.chunkSize*u,this.endByte=Math.min(this.stardByte+this.chunkSize,this.totalSize),this.size=this.endByte-this.stardByte,this.chunkIndex=u,this.maxRetries=this.opts.maxRetries,this.xhr=null,this.promise=null,this.status=g.Ready,this.progress=0,this.fakeProgress=0,this.timer=null}prepareXhr(){const n=new FormData;this.xhr.responseType="json",this.xhr.withCredentials=this.opts.withCredentials;const u=this.file.rawFile.slice(this.stardByte,this.endByte);return n.append(this.opts.name,u),this.fileHash&&n.append("hash",this.fileHash),n.append("id",this.uid),n.append("fileId",this.fileId),n.append("index",this.chunkIndex),n.append("filename",this.filename),n.append("size",this.size),n.append("totalSize",this.totalSize),n.append("timestamp",Date.now()),q(this.opts.data,(h,p)=>{n.append(p,h)}),this.xhr.open("POST",this.opts.action,!0),"setRequestHeader"in this.xhr&&q(this.opts.headers,(h,p)=>{this.xhr.setRequestHeader(p,h)}),n}async send(){return new Promise(async(n,u)=>{this.status=g.Pending;const h=m=>{this.progress=0,this.file.setProgress(this),this.maxRetries<=0?(this.file.removeUploadingQueue(this),this.status=g.Fail,this.file.isUploading()&&this.file.uploadFile(),u(this)):this.timer=setTimeout(()=>{this.send(),this.maxRetries--,clearTimeout(this.timer)},this.uploader.opts.retryInterval)},p=m=>{this.uploader.opts.requestSucceed(this.xhr)?(this.status=g.Success,this.file.removeUploadingQueue(this),this.file.isUploading()&&this.file.uploadFile(),n(this)):h()},_=m=>{this.progress=Math.min(1,m.loaded/m.total),this.fakeProgress=Math.max(this.progress,this.fakeProgress),this.status=g.Uploading,this.file.changeStatus(g.Uploading),this.file.setProgress(this)};this.xhr=new XMLHttpRequest;const v=this.prepareXhr();this.xhr.upload.addEventListener("progress",_),this.xhr.addEventListener("load",p,!1),this.xhr.addEventListener("error",h,!1),this.xhr.send(v)})}abort(){this.status=g.Ready,this.xhr&&(this.xhr.abort(),this.xhr=null),this.timer&&clearTimeout(this.timer)}cancel(){(this.status===g.Pending||this.status===g.Uploading)&&(this.status=g.Ready,this.abort())}}let ge=class{constructor(a,n){this.uploader=n||{opts:{}},this.opts=this.uploader.opts,this.rawFile=a,K(this.opts.customGenerateUid)?this.uid=this.opts.customGenerateUid(a)||de("fid"):this.uid=de("fid"),this.hash="",this.size=a.size,this.name=a.name||a.fileName,this.type=a.type,this.chunkSize=this.opts.chunkSize,this.changeStatus(a.status||g.Init),this.progress=a.progress||0,this.chunks=[],this.uploadingQueue=new Set,this.readProgress=0,this.path=a.path||""}async start(){await this.computedHash(),this.createChunks(),this.opts.