@tinyuploader/react
Version:
25 lines • 52 kB
JavaScript
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const U=require("react");function ke(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var V={exports:{}},$={};/**
* @license React
* react-jsx-runtime.production.js
*
* Copyright (c) Meta Platforms, Inc. and 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 _e(){if(ge)return $;ge=1;var n=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function i(o,h,d){var g=null;if(d!==void 0&&(g=""+d),h.key!==void 0&&(g=""+h.key),"key"in h){d={};for(var y in h)y!=="key"&&(d[y]=h[y])}else d=h;return h=d.ref,{$$typeof:n,type:o,key:g,ref:h!==void 0?h:null,props:d}}return $.Fragment=e,$.jsx=i,$.jsxs=i,$}var H={};/**
* @license React
* react-jsx-runtime.development.js
*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var ye;function je(){return ye||(ye=1,process.env.NODE_ENV!=="production"&&function(){function n(c){if(c==null)return null;if(typeof c=="function")return c.$$typeof===Y?null:c.displayName||c.name||null;if(typeof c=="string")return c;switch(c){case _:return"Fragment";case l:return"Profiler";case F:return"StrictMode";case a:return"Suspense";case r:return"SuspenseList";case N:return"Activity"}if(typeof c=="object")switch(typeof c.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),c.$$typeof){case T:return"Portal";case s:return(c.displayName||"Context")+".Provider";case u:return(c._context.displayName||"Context")+".Consumer";case t:var b=c.render;return c=c.displayName,c||(c=b.displayName||b.name||"",c=c!==""?"ForwardRef("+c+")":"ForwardRef"),c;case w:return b=c.displayName||null,b!==null?b:n(c.type)||"Memo";case x:b=c._payload,c=c._init;try{return n(c(b))}catch{}}return null}function e(c){return""+c}function i(c){try{e(c);var b=!1}catch{b=!0}if(b){b=console;var k=b.error,j=typeof Symbol=="function"&&Symbol.toStringTag&&c[Symbol.toStringTag]||c.constructor.name||"Object";return k.call(b,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",j),e(c)}}function o(c){if(c===_)return"<>";if(typeof c=="object"&&c!==null&&c.$$typeof===x)return"<...>";try{var b=n(c);return b?"<"+b+">":"<...>"}catch{return"<...>"}}function h(){var c=Z.A;return c===null?null:c.getOwner()}function d(){return Error("react-stack-top-frame")}function g(c){if(he.call(c,"key")){var b=Object.getOwnPropertyDescriptor(c,"key").get;if(b&&b.isReactWarning)return!1}return c.key!==void 0}function y(c,b){function k(){ce||(ce=!0,console.error("%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://react.dev/link/special-props)",b))}k.isReactWarning=!0,Object.defineProperty(c,"key",{get:k,configurable:!0})}function R(){var c=n(this.type);return de[c]||(de[c]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),c=this.props.ref,c!==void 0?c:null}function C(c,b,k,j,B,O,K,ee){return k=O.ref,c={$$typeof:z,type:c,key:b,props:O,_owner:B},(k!==void 0?k:null)!==null?Object.defineProperty(c,"ref",{enumerable:!1,get:R}):Object.defineProperty(c,"ref",{enumerable:!1,value:null}),c._store={},Object.defineProperty(c._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(c,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(c,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:K}),Object.defineProperty(c,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:ee}),Object.freeze&&(Object.freeze(c.props),Object.freeze(c)),c}function v(c,b,k,j,B,O,K,ee){var P=b.children;if(P!==void 0)if(j)if(Ee(P)){for(j=0;j<P.length;j++)E(P[j]);Object.freeze&&Object.freeze(P)}else console.error("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 E(P);if(he.call(b,"key")){P=n(c);var I=Object.keys(b).filter(function(Ae){return Ae!=="key"});j=0<I.length?"{key: someKey, "+I.join(": ..., ")+": ...}":"{key: someKey}",me[P+j]||(I=0<I.length?"{"+I.join(": ..., ")+": ...}":"{}",console.error(`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} />`,j,P,I,P),me[P+j]=!0)}if(P=null,k!==void 0&&(i(k),P=""+k),g(b)&&(i(b.key),P=""+b.key),"key"in b){k={};for(var te in b)te!=="key"&&(k[te]=b[te])}else k=b;return P&&y(k,typeof c=="function"?c.displayName||c.name||"Unknown":c),C(c,P,O,B,h(),k,K,ee)}function E(c){typeof c=="object"&&c!==null&&c.$$typeof===z&&c._store&&(c._store.validated=1)}var A=U,z=Symbol.for("react.transitional.element"),T=Symbol.for("react.portal"),_=Symbol.for("react.fragment"),F=Symbol.for("react.strict_mode"),l=Symbol.for("react.profiler"),u=Symbol.for("react.consumer"),s=Symbol.for("react.context"),t=Symbol.for("react.forward_ref"),a=Symbol.for("react.suspense"),r=Symbol.for("react.suspense_list"),w=Symbol.for("react.memo"),x=Symbol.for("react.lazy"),N=Symbol.for("react.activity"),Y=Symbol.for("react.client.reference"),Z=A.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,he=Object.prototype.hasOwnProperty,Ee=Array.isArray,Q=console.createTask?console.createTask:function(){return null};A={"react-stack-bottom-frame":function(c){return c()}};var ce,de={},pe=A["react-stack-bottom-frame"].bind(A,d)(),fe=Q(o(d)),me={};H.Fragment=_,H.jsx=function(c,b,k,j,B){var O=1e4>Z.recentlyCreatedOwnerStacks++;return v(c,b,k,!1,j,B,O?Error("react-stack-top-frame"):pe,O?Q(o(c)):fe)},H.jsxs=function(c,b,k,j,B){var O=1e4>Z.recentlyCreatedOwnerStacks++;return v(c,b,k,!0,j,B,O?Error("react-stack-top-frame"):pe,O?Q(o(c)):fe)}}()),H}var ve;function Pe(){return ve||(ve=1,process.env.NODE_ENV==="production"?V.exports=_e():V.exports=je()),V.exports}var p=Pe(),se={exports:{}},be;function Ue(){return be||(be=1,function(n,e){(function(i){n.exports=i()})(function(i){var o=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];function h(l,u){var s=l[0],t=l[1],a=l[2],r=l[3];s+=(t&a|~t&r)+u[0]-680876936|0,s=(s<<7|s>>>25)+t|0,r+=(s&t|~s&a)+u[1]-389564586|0,r=(r<<12|r>>>20)+s|0,a+=(r&s|~r&t)+u[2]+606105819|0,a=(a<<17|a>>>15)+r|0,t+=(a&r|~a&s)+u[3]-1044525330|0,t=(t<<22|t>>>10)+a|0,s+=(t&a|~t&r)+u[4]-176418897|0,s=(s<<7|s>>>25)+t|0,r+=(s&t|~s&a)+u[5]+1200080426|0,r=(r<<12|r>>>20)+s|0,a+=(r&s|~r&t)+u[6]-1473231341|0,a=(a<<17|a>>>15)+r|0,t+=(a&r|~a&s)+u[7]-45705983|0,t=(t<<22|t>>>10)+a|0,s+=(t&a|~t&r)+u[8]+1770035416|0,s=(s<<7|s>>>25)+t|0,r+=(s&t|~s&a)+u[9]-1958414417|0,r=(r<<12|r>>>20)+s|0,a+=(r&s|~r&t)+u[10]-42063|0,a=(a<<17|a>>>15)+r|0,t+=(a&r|~a&s)+u[11]-1990404162|0,t=(t<<22|t>>>10)+a|0,s+=(t&a|~t&r)+u[12]+1804603682|0,s=(s<<7|s>>>25)+t|0,r+=(s&t|~s&a)+u[13]-40341101|0,r=(r<<12|r>>>20)+s|0,a+=(r&s|~r&t)+u[14]-1502002290|0,a=(a<<17|a>>>15)+r|0,t+=(a&r|~a&s)+u[15]+1236535329|0,t=(t<<22|t>>>10)+a|0,s+=(t&r|a&~r)+u[1]-165796510|0,s=(s<<5|s>>>27)+t|0,r+=(s&a|t&~a)+u[6]-1069501632|0,r=(r<<9|r>>>23)+s|0,a+=(r&t|s&~t)+u[11]+643717713|0,a=(a<<14|a>>>18)+r|0,t+=(a&s|r&~s)+u[0]-373897302|0,t=(t<<20|t>>>12)+a|0,s+=(t&r|a&~r)+u[5]-701558691|0,s=(s<<5|s>>>27)+t|0,r+=(s&a|t&~a)+u[10]+38016083|0,r=(r<<9|r>>>23)+s|0,a+=(r&t|s&~t)+u[15]-660478335|0,a=(a<<14|a>>>18)+r|0,t+=(a&s|r&~s)+u[4]-405537848|0,t=(t<<20|t>>>12)+a|0,s+=(t&r|a&~r)+u[9]+568446438|0,s=(s<<5|s>>>27)+t|0,r+=(s&a|t&~a)+u[14]-1019803690|0,r=(r<<9|r>>>23)+s|0,a+=(r&t|s&~t)+u[3]-187363961|0,a=(a<<14|a>>>18)+r|0,t+=(a&s|r&~s)+u[8]+1163531501|0,t=(t<<20|t>>>12)+a|0,s+=(t&r|a&~r)+u[13]-1444681467|0,s=(s<<5|s>>>27)+t|0,r+=(s&a|t&~a)+u[2]-51403784|0,r=(r<<9|r>>>23)+s|0,a+=(r&t|s&~t)+u[7]+1735328473|0,a=(a<<14|a>>>18)+r|0,t+=(a&s|r&~s)+u[12]-1926607734|0,t=(t<<20|t>>>12)+a|0,s+=(t^a^r)+u[5]-378558|0,s=(s<<4|s>>>28)+t|0,r+=(s^t^a)+u[8]-2022574463|0,r=(r<<11|r>>>21)+s|0,a+=(r^s^t)+u[11]+1839030562|0,a=(a<<16|a>>>16)+r|0,t+=(a^r^s)+u[14]-35309556|0,t=(t<<23|t>>>9)+a|0,s+=(t^a^r)+u[1]-1530992060|0,s=(s<<4|s>>>28)+t|0,r+=(s^t^a)+u[4]+1272893353|0,r=(r<<11|r>>>21)+s|0,a+=(r^s^t)+u[7]-155497632|0,a=(a<<16|a>>>16)+r|0,t+=(a^r^s)+u[10]-1094730640|0,t=(t<<23|t>>>9)+a|0,s+=(t^a^r)+u[13]+681279174|0,s=(s<<4|s>>>28)+t|0,r+=(s^t^a)+u[0]-358537222|0,r=(r<<11|r>>>21)+s|0,a+=(r^s^t)+u[3]-722521979|0,a=(a<<16|a>>>16)+r|0,t+=(a^r^s)+u[6]+76029189|0,t=(t<<23|t>>>9)+a|0,s+=(t^a^r)+u[9]-640364487|0,s=(s<<4|s>>>28)+t|0,r+=(s^t^a)+u[12]-421815835|0,r=(r<<11|r>>>21)+s|0,a+=(r^s^t)+u[15]+530742520|0,a=(a<<16|a>>>16)+r|0,t+=(a^r^s)+u[2]-995338651|0,t=(t<<23|t>>>9)+a|0,s+=(a^(t|~r))+u[0]-198630844|0,s=(s<<6|s>>>26)+t|0,r+=(t^(s|~a))+u[7]+1126891415|0,r=(r<<10|r>>>22)+s|0,a+=(s^(r|~t))+u[14]-1416354905|0,a=(a<<15|a>>>17)+r|0,t+=(r^(a|~s))+u[5]-57434055|0,t=(t<<21|t>>>11)+a|0,s+=(a^(t|~r))+u[12]+1700485571|0,s=(s<<6|s>>>26)+t|0,r+=(t^(s|~a))+u[3]-1894986606|0,r=(r<<10|r>>>22)+s|0,a+=(s^(r|~t))+u[10]-1051523|0,a=(a<<15|a>>>17)+r|0,t+=(r^(a|~s))+u[1]-2054922799|0,t=(t<<21|t>>>11)+a|0,s+=(a^(t|~r))+u[8]+1873313359|0,s=(s<<6|s>>>26)+t|0,r+=(t^(s|~a))+u[15]-30611744|0,r=(r<<10|r>>>22)+s|0,a+=(s^(r|~t))+u[6]-1560198380|0,a=(a<<15|a>>>17)+r|0,t+=(r^(a|~s))+u[13]+1309151649|0,t=(t<<21|t>>>11)+a|0,s+=(a^(t|~r))+u[4]-145523070|0,s=(s<<6|s>>>26)+t|0,r+=(t^(s|~a))+u[11]-1120210379|0,r=(r<<10|r>>>22)+s|0,a+=(s^(r|~t))+u[2]+718787259|0,a=(a<<15|a>>>17)+r|0,t+=(r^(a|~s))+u[9]-343485551|0,t=(t<<21|t>>>11)+a|0,l[0]=s+l[0]|0,l[1]=t+l[1]|0,l[2]=a+l[2]|0,l[3]=r+l[3]|0}function d(l){var u=[],s;for(s=0;s<64;s+=4)u[s>>2]=l.charCodeAt(s)+(l.charCodeAt(s+1)<<8)+(l.charCodeAt(s+2)<<16)+(l.charCodeAt(s+3)<<24);return u}function g(l){var u=[],s;for(s=0;s<64;s+=4)u[s>>2]=l[s]+(l[s+1]<<8)+(l[s+2]<<16)+(l[s+3]<<24);return u}function y(l){var u=l.length,s=[1732584193,-271733879,-1732584194,271733878],t,a,r,w,x,N;for(t=64;t<=u;t+=64)h(s,d(l.substring(t-64,t)));for(l=l.substring(t-64),a=l.length,r=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],t=0;t<a;t+=1)r[t>>2]|=l.charCodeAt(t)<<(t%4<<3);if(r[t>>2]|=128<<(t%4<<3),t>55)for(h(s,r),t=0;t<16;t+=1)r[t]=0;return w=u*8,w=w.toString(16).match(/(.*?)(.{0,8})$/),x=parseInt(w[2],16),N=parseInt(w[1],16)||0,r[14]=x,r[15]=N,h(s,r),s}function R(l){var u=l.length,s=[1732584193,-271733879,-1732584194,271733878],t,a,r,w,x,N;for(t=64;t<=u;t+=64)h(s,g(l.subarray(t-64,t)));for(l=t-64<u?l.subarray(t-64):new Uint8Array(0),a=l.length,r=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],t=0;t<a;t+=1)r[t>>2]|=l[t]<<(t%4<<3);if(r[t>>2]|=128<<(t%4<<3),t>55)for(h(s,r),t=0;t<16;t+=1)r[t]=0;return w=u*8,w=w.toString(16).match(/(.*?)(.{0,8})$/),x=parseInt(w[2],16),N=parseInt(w[1],16)||0,r[14]=x,r[15]=N,h(s,r),s}function C(l){var u="",s;for(s=0;s<4;s+=1)u+=o[l>>s*8+4&15]+o[l>>s*8&15];return u}function v(l){var u;for(u=0;u<l.length;u+=1)l[u]=C(l[u]);return l.join("")}v(y("hello")),typeof ArrayBuffer<"u"&&!ArrayBuffer.prototype.slice&&function(){function l(u,s){return u=u|0||0,u<0?Math.max(u+s,0):Math.min(u,s)}ArrayBuffer.prototype.slice=function(u,s){var t=this.byteLength,a=l(u,t),r=t,w,x,N,Y;return s!==i&&(r=l(s,t)),a>r?new ArrayBuffer(0):(w=r-a,x=new ArrayBuffer(w),N=new Uint8Array(x),Y=new Uint8Array(this,a,w),N.set(Y),x)}}();function E(l){return/[\u0080-\uFFFF]/.test(l)&&(l=unescape(encodeURIComponent(l))),l}function A(l,u){var s=l.length,t=new ArrayBuffer(s),a=new Uint8Array(t),r;for(r=0;r<s;r+=1)a[r]=l.charCodeAt(r);return u?a:t}function z(l){return String.fromCharCode.apply(null,new Uint8Array(l))}function T(l,u,s){var t=new Uint8Array(l.byteLength+u.byteLength);return t.set(new Uint8Array(l)),t.set(new Uint8Array(u),l.byteLength),t}function _(l){var u=[],s=l.length,t;for(t=0;t<s-1;t+=2)u.push(parseInt(l.substr(t,2),16));return String.fromCharCode.apply(String,u)}function F(){this.reset()}return F.prototype.append=function(l){return this.appendBinary(E(l)),this},F.prototype.appendBinary=function(l){this._buff+=l,this._length+=l.length;var u=this._buff.length,s;for(s=64;s<=u;s+=64)h(this._hash,d(this._buff.substring(s-64,s)));return this._buff=this._buff.substring(s-64),this},F.prototype.end=function(l){var u=this._buff,s=u.length,t,a=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],r;for(t=0;t<s;t+=1)a[t>>2]|=u.charCodeAt(t)<<(t%4<<3);return this._finish(a,s),r=v(this._hash),l&&(r=_(r)),this.reset(),r},F.prototype.reset=function(){return this._buff="",this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},F.prototype.getState=function(){return{buff:this._buff,length:this._length,hash:this._hash.slice()}},F.prototype.setState=function(l){return this._buff=l.buff,this._length=l.length,this._hash=l.hash,this},F.prototype.destroy=function(){delete this._hash,delete this._buff,delete this._length},F.prototype._finish=function(l,u){var s=u,t,a,r;if(l[s>>2]|=128<<(s%4<<3),s>55)for(h(this._hash,l),s=0;s<16;s+=1)l[s]=0;t=this._length*8,t=t.toString(16).match(/(.*?)(.{0,8})$/),a=parseInt(t[2],16),r=parseInt(t[1],16)||0,l[14]=a,l[15]=r,h(this._hash,l)},F.hash=function(l,u){return F.hashBinary(E(l),u)},F.hashBinary=function(l,u){var s=y(l),t=v(s);return u?_(t):t},F.ArrayBuffer=function(){this.reset()},F.ArrayBuffer.prototype.append=function(l){var u=T(this._buff.buffer,l),s=u.length,t;for(this._length+=l.byteLength,t=64;t<=s;t+=64)h(this._hash,g(u.subarray(t-64,t)));return this._buff=t-64<s?new Uint8Array(u.buffer.slice(t-64)):new Uint8Array(0),this},F.ArrayBuffer.prototype.end=function(l){var u=this._buff,s=u.length,t=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],a,r;for(a=0;a<s;a+=1)t[a>>2]|=u[a]<<(a%4<<3);return this._finish(t,s),r=v(this._hash),l&&(r=_(r)),this.reset(),r},F.ArrayBuffer.prototype.reset=function(){return this._buff=new Uint8Array(0),this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},F.ArrayBuffer.prototype.getState=function(){var l=F.prototype.getState.call(this);return l.buff=z(l.buff),l},F.ArrayBuffer.prototype.setState=function(l){return l.buff=A(l.buff,!0),F.prototype.setState.call(this,l)},F.ArrayBuffer.prototype.destroy=F.prototype.destroy,F.ArrayBuffer.prototype._finish=F.prototype._finish,F.ArrayBuffer.hash=function(l,u){var s=R(new Uint8Array(l)),t=v(s);return u?_(t):t},F})}(se)),se.exports}var ze=Ue();const Te=ke(ze);var Ne=Object.defineProperty,Le=(n,e,i)=>e in n?Ne(n,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):n[e]=i,m=(n,e,i)=>Le(n,typeof e!="symbol"?e+"":e,i);const J=(n,e)=>toString.call(n).slice(8,-1).toLowerCase()===e,M=function(n){return typeof n=="function"},Me=n=>J(n,"object"),re=n=>Me(n)&&n!==null,ae=n=>J(n,"array"),Oe=n=>n&&M(n.then),Be=function(n){return J(n,"string")},Ie=function(n){return J(n,"boolean")};let De=0;const ne=(n="id")=>`${n}-${+new Date}-${De++}`;function G(n,e,i){if(ae(n)){const d=n;for(var o=0,h=d.length;o<h&&e.call(i,d[o],o,d)!==!1;o++);}else{const d=n;for(const g in d)if(Object.prototype.hasOwnProperty.call(d,g)&&e.call(i,d[g],g,d)===!1)break}}function W(){var n,e,i,o,h,d,g=arguments[0]||{},y=1,R=arguments.length,C=!1;for(typeof g=="boolean"&&(C=g,g=arguments[1]||{},y++),typeof g!="object"&&!M(g)&&(g={}),y===R&&(g=this,y--);y<R;y++)if((n=arguments[y])!=null)for(e in n)i=g[e],o=n[e],g!==o&&(C&&o&&(re(o)||(h=ae(o)))?(h?(h=!1,d=i&&ae(i)?i:[]):d=i&&re(i)?i:{},g[e]=W(C,d,o)):o!==void 0&&(g[e]=o));return g}const q=n=>typeof n=="function"?n()||{}:re(n)?n:{},qe=n=>{if(!n||isNaN(Number(n))||Number(n)<=0||n==="")return"0 B";const e=["B","KB","MB","GB","TB","PB","EB","ZB","YB"],i=1024,o=Number(n),h=Math.floor(Math.log(o)/Math.log(i));return`${(o/Math.pow(i,h)).toFixed(2)} ${e[Math.min(h,e.length-1)]}`},$e=(n,e=300)=>{let i=0;return function(...o){let h=+new Date;h-i>e&&(i=h,n.apply(this,o))}};class He{constructor(e){m(this,"uploader"),m(this,"listeners"),m(this,"inputs"),this.uploader=e,this.listeners=[],this.inputs=[]}assignBrowse(e,i={}){if(!e){console.warn("DOM 节点不存在");return}const o=this.createOrGetInput(e);this.setInputAttributes(o,i),this.attachBrowseEvents(e,o)}assignDrop(e){if(!e){console.warn("DOM 节点不存在");return}const i=h=>h.preventDefault(),o={dragover:i,dragenter:i,dragleave:i,drop:this.handleDrop.bind(this)};G(o,(h,d)=>{e.addEventListener(d,h,{passive:!1}),this.listeners.push({node:e,event:d,handler:h})})}createOrGetInput(e){if(e instanceof HTMLInputElement&&e.tagName==="INPUT"&&e.type==="file")return e;const i=document.createElement("input");return i.type="file",W(i.style,{visibility:"hidden",position:"absolute",width:"1px",height:"1px"}),e.appendChild(i),this.inputs.push(i),i}setInputAttributes(e,i){G(i,(o,h)=>e.setAttribute(h,o)),e.toggleAttribute("multiple",!!i.multiple)}attachBrowseEvents(e,i){const o=()=>i.click(),h=d=>{const g=d.target;this.uploader.addFiles(g.files),g.value=""};e.addEventListener("click",o,{passive:!0}),i.addEventListener("change",h,{passive:!0}),this.listeners.push({node:e,event:"click",handler:o},{node:i,event:"change",handler:h})}handleDrop(e){var i;e.preventDefault(),e.stopPropagation(),e instanceof DragEvent&&this.uploader.addFiles((i=e.dataTransfer)==null?void 0:i.files)}destroy(){return this.listeners.forEach(({node:e,event:i,handler:o})=>{e.removeEventListener(i,o)}),this.listeners=[],this.inputs.forEach(e=>{e.parentNode&&e.parentNode.removeChild(e)}),this.inputs=[],this}}class We{constructor(){m(this,"events"),this.events=new Map}on(e,i){if(!M(i))return;const o=this.events.get(e)||[];o.includes(i)||(o.push(i),this.events.set(e,o))}off(e,i){var o;if(!this.events.has(e))return;if(!i){this.events.set(e,[]);return}const h=(o=this.events.get(e))==null?void 0:o.filter(d=>d!==i);this.events.set(e,h)}emit(e,...i){const o=this.events.get(e);o&&o.length&&o.forEach(h=>h(...i))}once(e,i){if(!M(i))return;const o=(...h)=>{i(...h),this.off(e,o)};this.on(e,o)}clear(e){if(!e){this.events.clear();return}this.events.has(e)&&this.events.set(e,[])}}const f={Init:"init",AddFail:"addFail",Reading:"reading",Ready:"ready",CheckFail:"checkFail",Uploading:"uploading",UploadSuccess:"uploadSuccess",UploadFail:"uploadFail",Success:"success",Fail:"fail",Pause:"pause",Resume:"resume"},L={Ready:"ready",Pending:"pending",Uploading:"uploading",Success:"success",Fail:"fail"},S={Exceed:"exceed",FileAdded:"fileAdded",FileAddFail:"fileAddFail",FilesAdded:"filesAdded",FileChange:"fileChange",FileRemove:"fileRemove",FileReadStart:"fileReadStart",FileReadProgress:"fileReadProgress",FileReadEnd:"fileReadEnd",FileReadFail:"fileReadFail",FilePause:"filePause",FileResume:"fileResume",FileProgress:"fileProgress",FileUploadSuccess:"fileUploadSuccess",FileUploadFail:"fileUploadFail",FileSuccess:"fileSuccess",FileFail:"fileFail",AllFileSuccess:"allFileSuccess"},D={None:"none",Part:"part",WaitMerge:"waitMerge",Success:"success"},oe={Check:"check",Upload:"upload",Merge:"merge"};function Ye(n){const{method:e="POST",withCredentials:i=!0,responseType:o="json",action:h,data:d,headers:g,onSuccess:y,onFail:R,onProgress:C}=n;let v=new XMLHttpRequest;v.responseType=o,v.withCredentials=i,v.open(e,h,!0);const E=new FormData;return Object.entries(d).forEach(([A,z])=>E.append(A,z)),"setRequestHeader"in v&&Object.entries(g).forEach(([A,z])=>v.setRequestHeader(A,z)),v.addEventListener("timeout",()=>{R&&R(new Error("Request timed out"),v)}),v.upload.addEventListener("progress",A=>{C&&C(A)}),v.addEventListener("error",A=>{R&&R(A,v)},!1),v.addEventListener("readystatechange",A=>{if(v.readyState===4){if(v.status<200||v.status>=300){R&&R(new Error(`xhr: status === ${v.status}`),v);return}y&&y(A,v)}}),v.send(E),{abort(){v.abort(),v=null}}}class Ve{constructor(e,i){m(this,"uploader"),m(this,"options"),m(this,"file"),m(this,"fileId"),m(this,"rawFile"),m(this,"fileHash"),m(this,"filename"),m(this,"totalSize"),m(this,"chunkSize"),m(this,"totalChunks"),m(this,"uid"),m(this,"chunkIndex"),m(this,"status"),m(this,"startByte"),m(this,"endByte"),m(this,"size"),m(this,"maxRetries"),m(this,"progress"),m(this,"fakeProgress"),m(this,"timer"),m(this,"request"),m(this,"customRequest"),this.uploader=e.uploader,this.options=e.uploader.options,this.file=e,this.rawFile=e.rawFile,this.fileId=e.uid,this.fileHash=e.hash,this.filename=e.name,this.totalSize=e.size,this.chunkSize=this.options.chunkSize,this.totalChunks=e.totalChunks,this.uid=ne(),this.chunkIndex=i,this.status=L.Ready,this.startByte=this.chunkSize*i,this.endByte=Math.min(this.startByte+this.chunkSize,this.totalSize),this.size=this.endByte-this.startByte,this.maxRetries=this.options.maxRetries,this.progress=0,this.fakeProgress=0,this.timer=null,this.request=null,this.customRequest=this.options.customRequest||Ye}onSuccess(e,i,o,h){this.options.requestSucceed(i)?(this.status=L.Success,this.file.removeUploadingChunk(this),this.file.isUploading()&&this.file.upload(),o(this)):this.onFail(e,h)}onFail(e,i){var o;this.progress=0,this.file.setProgress(),!((o=this.request)!=null&&o.canceled)&&(this.maxRetries<=0?(this.file.removeUploadingChunk(this),this.status=L.Fail,this.file.isUploading()&&this.file.upload(),i(e,this)):this.timer=setTimeout(()=>{this.send(),this.maxRetries--,clearTimeout(this.timer)},this.options.retryInterval))}onProgress(e){this.progress=Math.min(1,e.loaded/e.total),this.fakeProgress=Math.max(this.progress,this.fakeProgress),this.status=L.Uploading,this.file.changeStatus(f.Uploading),this.file.setProgress()}prepare(){const{name:e,data:i,processData:o}=this.options,{data:h}=this.file,d={[e]:this.file.rawFile.slice(this.startByte,this.endByte),hash:this.fileHash,id:this.uid,fileId:this.fileId,index:this.chunkIndex,filename:this.filename,size:this.size,totalSize:this.totalSize,totalChunks:this.totalChunks,...q(i),...h};return M(o)&&o(d,oe.Upload)||d}send(){this.status=L.Pending;const{action:e,headers:i,withCredentials:o,name:h}=this.options;return new Promise((d,g)=>{this.request=this.customRequest({action:e,name:h,withCredentials:o,headers:q(i),data:this.prepare(),query:{...q(this.options.data),...this.file.data},onSuccess:(y,R)=>this.onSuccess(y,R,d,g),onFail:y=>this.onFail(y,g),onProgress:y=>this.onProgress(y)}),this.request.canceled=!1})}abort(){this.status=L.Ready,this.request&&(this.request.canceled=!0,this.request.abort()),this.timer&&clearTimeout(this.timer)}}class ie{constructor(e,i,o){m(this,"uploader"),m(this,"options"),m(this,"hasher"),m(this,"id"),m(this,"uid"),m(this,"status"),m(this,"prevStatusLastRecord"),m(this,"rawFile"),m(this,"name"),m(this,"size"),m(this,"type"),m(this,"hash"),m(this,"url"),m(this,"progress"),m(this,"chunkSize"),m(this,"chunks"),m(this,"totalChunks"),m(this,"uploadingChunks"),m(this,"readProgress"),m(this,"errorMessage"),m(this,"data"),m(this,"abortRead"),this.uploader=i,this.options=this.uploader.options,this.hasher=this.uploader.hasher,this.prevStatusLastRecord=[],this.rawFile=e,this.name=e.name,this.size=e.size,this.type=e.type,this.hash="",this.url="",this.status="",this.progress=0,this.chunkSize=this.options.chunkSize,this.chunks=[],this.totalChunks=0,this.uploadingChunks=new Set,this.readProgress=0,this.errorMessage="",this.data={},this.uid=this.generateId(),o?(Object.keys(o).forEach(h=>{this[h]=o[h]}),this.name=o.name,this.url=o.url,this.readProgress=1,this.progress=1,this.changeStatus(f.Success)):this.changeStatus(f.Init)}generateId(){const{customGenerateUid:e}=this.options;return!e||!M(e)?ne():e(this)||ne()}setErrorMessage(e){return this.errorMessage=String(e),this}setData(e){return this.data={...this.data,...e},this}get renderSize(){return qe(this.size)}changeStatus(e){(e!==this.status||e===f.Reading)&&(this.prevStatusLastRecord.push(this.status),this.status=e,this.uploader&&this.uploader.emitCallback&&this.uploader.emitCallback(S.FileChange,this))}isInit(){return this.status===f.Init}isAddFail(){return this.status===f.AddFail}isReading(){return this.status===f.Reading}isReady(){return this.status===f.Ready}isCheckFail(){return this.status===f.CheckFail}isUploading(){return this.status===f.Uploading}isUploadSuccess(){return this.status===f.UploadSuccess}isUploadFail(){return this.status===f.UploadFail}isSuccess(){return this.status===f.Success}isFail(){return this.status===f.Fail}isPause(){return this.status===f.Pause}isResume(){return this.status===f.Resume}createChunks(){this.totalChunks=Math.ceil(this.size/this.chunkSize)||1,this.chunks=Array.from({length:this.totalChunks},(e,i)=>new Ve(this,i))}async read(){if(!this.options.withHash){this.createChunks(),this.changeStatus(f.Ready);return}this.uploader.emitCallback(S.FileReadStart,this),this.changeStatus(f.Reading);try{const e=Date.now(),{hash:i,progress:o}=await this._computeHash();this.hash=i,this.readProgress=o,this.uploader.emitCallback(S.FileReadEnd,this),console.log(`${this.options.useWebWoker?"Web Worker":"Main Thread"} read file took`,(Date.now()-e)/1e3,"s"),this.abortRead=null}catch(e){throw console.warn(e.message),e&&e.message&&e.message.toLowerCase().includes("cancel")||this.setErrorMessage("File read failed"),this.changeStatus(f.Init),this.uploader.emitCallback(S.FileReadFail,this),new Error("File read failed")}this.createChunks(),this.changeStatus(f.Ready)}async _computeHash(){try{const e=$e(d=>{this.readProgress=d,this.uploader.emitCallback(S.FileReadProgress,this)},200);if(this.options.useWebWoker&&this.hasher.hashionName!=="sparkMd5Webworker")throw new Error(`
Please install "SparkWorker" plugin -> npm i hashion;
https://www.npmjs.com/package/hashion
`);const{promise:i,abort:o}=this.hasher.computedHash({file:this.rawFile,chunkSize:this.chunkSize},({progress:d})=>e(d));this.abortRead=o;const h=await i;return e(h.progress),h}catch(e){throw e}}_processData(e){const{data:i,processData:o}=this.options,h={...q(i),...this.data};return M(o)&&o(h,e)||h}async checkRequest(){const{checkRequest:e}=this.options;if(!M(e))return Promise.resolve();const i=h=>{this.chunks.forEach(d=>{d.status=h,d.progress=1,d.fakeProgress=1})},o={[D.Part]:h=>{this.chunks.forEach(d=>{h.includes(d.chunkIndex)&&(d.status=L.Success,d.progress=1,d.fakeProgress=1)})},[D.WaitMerge]:()=>{this.changeStatus(f.UploadSuccess),i(L.Success)},[D.Success]:h=>{this.changeStatus(f.Success),i(L.Success),this.url=h},[D.None]:()=>{}};try{const h=await Promise.resolve(e(this,this._processData(oe.Check),q(this.options.headers)));if(!h||!h.status)throw new Error("Invalid check response format");const d=o[h.status];if(!d)throw new Error(`Unknown check status: ${h.status}`);return d(h.data),Promise.resolve()}catch(h){this.changeStatus(f.CheckFail),this.uploader.upload();const d=new Error(`Check request failed: ${h.message}`);throw d.originalError=h,d}}addUploadingChunk(e){this.uploadingChunks.add(e)}removeUploadingChunk(e){this.uploadingChunks.delete(e)}async upload(){if(this.isInit()&&await this.read(),this.isReady()&&this.options.checkRequest&&(await this.checkRequest(),this.status===f.Pause))return;if(this.isUploadSuccess())return this.merge();if(this.isSuccess())return this.success();const e=this.chunks.filter(i=>i.status===L.Ready);if(G(e,()=>{if(this.uploadingChunks.size>=this.options.maxConcurrency)return!1;const i=e.shift();if(i)this.addUploadingChunk(i);else return!1}),this.uploadingChunks.size>0){const i=[...this.uploadingChunks].filter(o=>o.status===L.Ready);Promise.race(i.map(o=>o.send()));return}this.chunks.some(i=>i.status===L.Fail)?this.uploadFail():(this.uploadSuccess(),this.setProgress(),this.merge())}setProgress(){const e=this.chunks.reduce((i,o)=>{const h=this.options.fakeProgress?o.fakeProgress:o.progress;return i+=h*(o.size/this.size)},0);this.progress=Math.min(1,e),(this.isUploadSuccess()||this.isSuccess())&&(this.progress=1),this.uploader.emitCallback(S.FileProgress,this)}uploadFail(){this.changeStatus(f.UploadFail),this.uploader.emitCallback(S.FileUploadFail,this),this._continueUpload()}uploadSuccess(){this.changeStatus(f.UploadSuccess),this.uploader.emitCallback(S.FileUploadSuccess,this)}async merge(){const{mergeRequest:e}=this.options;if(!M(e))return this.success();try{const i=e(this,this._processData(oe.Merge),q(this.options.headers)),o=await Promise.resolve(i);Ie(o)?o?this.success():this.mergeFail():(this.url=o,this.success())}catch(i){console.log(i),this.mergeFail()}}mergeFail(){this.changeStatus(f.Fail),this.uploader.emitCallback(S.FileFail,this),this._continueUpload()}success(){this.changeStatus(f.Success),this.progress=1,this.uploader.emitCallback(S.FileSuccess,this),this._continueUpload()}_continueUpload(){const e=this.uploader.fileList.find(i=>i.isPause());e&&e.resume(),this.uploader.upload()}cancel(){this.uploadingChunks.forEach(e=>e.abort()),this.uploadingChunks.clear()}async remove(){this.abortRead&&this.abortRead(),setTimeout(()=>{this.cancel(),this.chunks=[],this.changeStatus("removed");const e=this.uploader.fileList.indexOf(this);e>-1&&this.uploader.fileList.splice(e,1),this.uploader.emitCallback(S.FileRemove,this),this.uploader.upload()},0)}pause(){this.abortRead&&this.abortRead(),setTimeout(()=>{this.cancel(),this.changeStatus(f.Pause),this.uploader.emitCallback(S.FilePause,this),this.uploader.upload()},0)}resume(){this.isPause()&&(this.changeStatus(f.Resume),this.uploader.emitCallback(S.FileResume,this),this.uploader.upload())}retry(){if(!this.isAddFail()){if(this.isCheckFail()){this.changeStatus(f.Ready),this.upload();return}if(this.isUploadSuccess()||this.isFail()){this.merge();return}this.isUploadFail()&&(G(this.chunks,e=>{e.status===L.Fail&&(e.status=L.Ready,e.maxRetries=e.options.maxRetries)}),this.upload())}}}const Re={accept:"*",multiple:!0,fileList:[],limit:10,autoUpload:!0,customGenerateUid:void 0,beforeAdd:n=>!0,beforeRemove:n=>!0,addFailToRemove:!0,chunkSize:2*1024*1024,fakeProgress:!0,withHash:!0,useWebWoker:!1,name:"file",action:"",customRequest:null,withCredentials:!0,headers:{},data:{},requestSucceed:n=>[200,201,202,206].includes(n.status),maxConcurrency:6,maxRetries:3,retryInterval:1e3,checkRequest:n=>({status:D.None}),mergeRequest:n=>!0,processData:(n,e)=>n};var Ge=Object.defineProperty,Je=(n,e,i)=>e in n?Ge(n,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):n[e]=i,we=(n,e,i)=>Je(n,typeof e!="symbol"?e+"":e,i);class Xe{constructor(e,i){we(this,"hashCarrier"),we(this,"hashionName"),this.hashionName=e.name,this.hashCarrier=new e(i)}computedHash({file:e,chunkSize:i},o){let h;return{promise:new Promise((d,g)=>{Promise.resolve(this.hashCarrier.computeHash({file:e,chunkSize:i},(y,{progress:R,hash:C,time:v})=>{y&&g(y),R===100&&d({progress:R,hash:C,time:v}),o&&o({progress:R})})).then(y=>{h={abort:y==null?void 0:y.abort,reject:g}})}),abort:()=>{h&&(h.abort&&h.abort(),h.reject(new Error("Canceled promise to rejected")))}}}}var Ze=Object.defineProperty,Qe=(n,e,i)=>e in n?Ze(n,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):n[e]=i,le=(n,e,i)=>Qe(n,typeof e!="symbol"?e+"":e,i);const Ke=File.prototype.slice||File.prototype.mozSlice||File.prototype.webkitSlice;class ue{constructor(){le(this,"name"),this.name="spark-md5"}async computeHash(e,i){const{file:o,chunkSize:h}=e;let d=!1;const g=new Te.ArrayBuffer,y=new FileReader,R=Math.ceil(o.size/h),C=Date.now();let v=0;const E=new AbortController,A=E.signal;A.addEventListener("abort",()=>{d||(y.abort(),i(new Error("Hash calculation cancelled"),{progress:0}))}),y.onload=function(T){var _;if(!A.aborted)if(g.append((_=T.target)==null?void 0:_.result),v++,v<R)z(),i(null,{progress:v/R*100});else{d=!0,i(null,{hash:g.end(),time:Date.now()-C,progress:100});return}},y.onerror=function(T){A.aborted||(console.warn("spark-md5: Hash calculation error"),i(T,{progress:0}))};function z(){if(A.aborted)return;const T=v*h,_=T+h>=o.size?o.size:T+h;y.readAsArrayBuffer(Ke.call(o,T,_))}return z(),{abort:()=>E.abort()}}}le(ue,"pluginName","hash-plugin"),le(ue,"name","spark-md5");class et{constructor(e){m(this,"container"),m(this,"event"),m(this,"options"),m(this,"hasher"),m(this,"fileList"),this.container=new He(this),this.event=new We,this.options=W(Re,e),this.hasher=null,this.fileList=(this.options.fileList||[]).map(i=>new ie(i,this,i)),this._setupFileListeners(),this.use(ue)}on(e,i){this.event.on(e,i)}emit(e,...i){this.event.emit(e,...i)}emitCallback(e,...i){this.emit(e,...i,this.fileList)}updateData(e){this.options.data=e}updateHeaders(e){this.options.headers=e}setOption(e){this.options=W(this.options,e)}use(e){e.pluginName==="hash-plugin"&&(this.hasher=new Xe(e))}formatAccept(e){return Be(e)?e:Array.isArray(e)?e.join(","):""}assignBrowse(e,i={}){const{accept:o,...h}=i,d={multiple:this.options.multiple,accept:this.formatAccept(o||this.options.accept)};this.container.assignBrowse(e,W({},d,h))}assignDrop(e){this.container.assignDrop(e)}_setupFileListeners(){const e=(i,o)=>{o.length&&o.every(h=>h.isSuccess())&&this.emit(S.AllFileSuccess,this.fileList)};this.on(S.FileSuccess,e),this.on(S.FileRemove,e)}setDefaultFileList(e){e.forEach(i=>{this.fileList.push(new ie(i,this,i))})}async addFiles(e){const{limit:i,multiple:o,addFailToRemove:h,beforeAdd:d,autoUpload:g}=this.options;let y=[...e];if(y.length===0)return;if(i>0&&y.length+this.fileList.length>i){this.emitCallback(S.Exceed,y);return}o||(y=y.slice(0,1));const R=y.map(C=>new ie(C,this,null));await Promise.all(R.map(C=>this._handleFileAdd(C,d))),this.fileList=this.fileList.filter(C=>C.isAddFail()&&h?(this.doRemove(C),!1):!0),R.length>0&&this.emitCallback(S.FilesAdded,this.fileList),g&&this.submit()}async _handleFileAdd(e,i){try{if(M(i)&&await i(e)===!1)throw new Error("Before add rejected");this.emitCallback(S.FileAdded,e)}catch{e.changeStatus(f.AddFail),this.emitCallback(S.FileAddFail,e)}this.fileList.push(e)}async upload(){if(this.fileList.length!==0)for(let e=0;e<this.fileList.length;e++){const i=this.fileList[e];if(!(i.isAddFail()||i.isCheckFail())){if(i.isUploading()||i.isReading())return;if(i.isResume()){const o=i.prevStatusLastRecord[i.prevStatusLastRecord.length-2];o&&i.changeStatus(o),i.upload();return}if(i.isReady()||i.isInit()){i.upload();return}}}}submit(){this.upload()}remove(e){const{beforeRemove:i}=this.options;if(!i)this.doRemove(e);else if(M(i)){const o=i(e);Oe(o)?o.then(()=>{this.doRemove(e)}):o!==!1&&this.doRemove(e)}}clear(){for(let e=this.fileList.length-1;e>=0;e--)this.fileList[e].remove();this.fileList=[]}doRemove(e){if(!e){this.clear();return}e.remove()}pause(e){e&&this.fileList.indexOf(e)>-1&&e.pause()}resume(e){e&&(this.fileList.filter(i=>i.isUploading()||i.isReading()).forEach(i=>{i.pause()}),e.resume())}retry(e){e&&(this.fileList.filter(i=>i.isUploading()||i.isReading()).forEach(i=>{i.pause()}),this.fileList.indexOf(e)>-1&&e.retry())}destroy(){this.clear(),this.event.clear(),this.container.destroy()}}const tt=n=>new et(n),st={sdk:null,setUploader:()=>null},Fe=U.createContext(st);function it({children:n}){const[e,i]=U.useState(null),o={sdk:e,setUploader:h=>i(h)};return p.jsx(Fe.Provider,{value:o,children:n})}const X=()=>U.useContext(Fe),xe=({size:n=32,style:e})=>p.jsxs("svg",{style:e,className:"tiny-uploader-icon tiny-uploader-icon-upload",viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg","p-id":"20916",width:n,height:n,children:[p.jsx("path",{d:"M789.464615 885.799385h-168.448c-70.025846 0-125.794462-58.958769-125.794461-130.244923v-243.239385c0-9.846154 8.310154-18.432 17.801846-18.432 9.491692 0 17.801846 8.585846 17.801846 18.432v242.018461c0 51.593846 40.329846 93.380923 90.190769 93.380924h168.448c84.283077 0 154.269538-65.102769 158.995693-148.637539 2.363077-44.228923-11.815385-87.236923-41.511385-119.177846-29.656615-31.940923-68.804923-50.412308-112.718769-50.412308h-3.544616a19.298462 19.298462 0 0 1-14.25723-6.104615c-3.544615-4.923077-4.726154-9.846154-3.544616-15.990154 7.089231-35.603692 8.270769-72.467692 1.181539-108.110769-20.164923-119.177846-116.302769-210.077538-232.566154-223.586462-74.752-8.625231-148.322462 15.950769-205.272615 68.804923a278.134154 278.134154 0 0 0-89.009231 203.933539c0 8.585846-5.907692 17.211077-15.399385 18.432-92.553846 13.508923-160.177231 98.264615-156.632615 196.529231 3.544615 100.785231 90.190769 184.32 192.196923 184.32h81.92c9.452308 0 17.762462 8.585846 17.762461 18.432s-8.270769 17.211077-18.983384 17.211076H266.24c-119.847385 0-221.892923-98.304-226.619077-218.702769-4.765538-111.812923 68.804923-208.856615 172.032-232.211692 4.726154-82.313846 40.329846-159.704615 100.824615-215.000615 64.078769-58.958769 147.140923-87.236923 233.787077-77.39077 131.702154 13.508923 240.836923 117.956923 263.404308 253.085539 5.907692 34.422154 7.089231 67.584 2.363077 100.745846a179.790769 179.790769 0 0 1 121.028923 61.44c36.785231 40.566154 54.587077 92.16 51.003077 147.416615-5.907692 102.006154-91.372308 183.059692-194.56 183.059693z","p-id":"20917"}),p.jsx("path",{d:"M652.996923 649.924923a17.486769 17.486769 0 0 1-12.996923-4.923077l-128.157538-133.907692-128.157539 132.686769a16.817231 16.817231 0 0 1-24.891077 0 18.235077 18.235077 0 0 1 0-25.796923l141.193846-146.195692c7.089231-7.404308 18.983385-7.404308 24.891077 0l141.193846 146.195692c7.128615 7.364923 7.128615 18.432 0 25.796923a18.786462 18.786462 0 0 1-13.036307 6.144z","p-id":"20918"})]}),rt=({children:n})=>{const{sdk:e}=X(),i=U.useRef(null);U.useEffect(()=>{e&&(e.assignDrop(i.current),e.assignBrowse(i.current))},[e]);const o=()=>p.jsxs(p.Fragment,{children:[p.jsx(xe,{size:64,style:{transform:"scale(0.65)"}}),p.jsxs("div",{className:"tiny-uploader-drop_text",children:["Drop file here or ",p.jsx("em",{children:"click to upload"})]}),p.jsx("div",{className:"tiny-uploader-drop_hint"})]});return p.jsx("div",{ref:i,className:"tiny-uploader-drop",children:n||o()})},at=({children:n})=>p.jsx("span",{className:"tiny-uploader-button",children:n}),nt=({children:n})=>{const{sdk:e}=X(),i=U.useRef(null);return U.useEffect(()=>{e&&e.assignBrowse(i.current)},[e]),p.jsx("div",{ref:i,className:"tiny-uplpader-trigger",children:n||p.jsx(at,{children:"Click to Upload"})})};function Ce(n){var e,i,o="";if(typeof n=="string"||typeof n=="number")o+=n;else if(typeof n=="object")if(Array.isArray(n)){var h=n.length;for(e=0;e<h;e++)n[e]&&(i=Ce(n[e]))&&(o&&(o+=" "),o+=i)}else for(i in n)n[i]&&(o&&(o+=" "),o+=i);return o}function Se(){for(var n,e,i=0,o="",h=arguments.length;i<h;i++)(n=arguments[i])&&(e=Ce(n))&&(o&&(o+=" "),o+=e);return o}const ot=({size:n=32})=>p.jsxs("svg",{className:"tiny-uploader-icon tiny-uploader-icon-file",viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg","p-id":"69323",width:n,height:n,children:[p.jsx("path",{d:"M842.666667 285.866667l-187.733334-187.733334c-14.933333-14.933333-32-21.333333-53.333333-21.333333H234.666667C194.133333 74.666667 160 108.8 160 149.333333v725.333334c0 40.533333 34.133333 74.666667 74.666667 74.666666h554.666666c40.533333 0 74.666667-34.133333 74.666667-74.666666V337.066667c0-19.2-8.533333-38.4-21.333333-51.2z m-44.8 44.8c-2.133333 2.133333-4.266667 0-8.533334 0h-170.666666c-6.4 0-10.666667-4.266667-10.666667-10.666667V149.333333c0-2.133333 0-6.4-2.133333-8.533333 0 0 2.133333 0 2.133333 2.133333l189.866667 187.733334z m-8.533334 554.666666H234.666667c-6.4 0-10.666667-4.266667-10.666667-10.666666V149.333333c0-6.4 4.266667-10.666667 10.666667-10.666666h311.466666c-2.133333 4.266667-2.133333 6.4-2.133333 10.666666v170.666667c0 40.533333 34.133333 74.666667 74.666667 74.666667h170.666666c4.266667 0 6.4 0 10.666667-2.133334V874.666667c0 6.4-4.266667 10.666667-10.666667 10.666666z",fill:"#666666","p-id":"69324"}),p.jsx("path",{d:"M640 693.333333H341.333333c-17.066667 0-32 14.933333-32 32s14.933333 32 32 32h298.666667c17.066667 0 32-14.933333 32-32s-14.933333-32-32-32zM640 522.666667H341.333333c-17.066667 0-32 14.933333-32 32s14.933333 32 32 32h298.666667c17.066667 0 32-14.933333 32-32s-14.933333-32-32-32zM341.333333 416h85.333334c17.066667 0 32-14.933333 32-32s-14.933333-32-32-32h-85.333334c-17.066667 0-32 14.933333-32 32s14.933333 32 32 32z",fill:"#666666","p-id":"69325"})]}),lt=({size:n=32})=>p.jsx("svg",{className:"tiny-uploader-icon tiny-uploader-icon--loading",viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg","p-id":"10889",width:n,height:n,children:p.jsx("path",{d:"M876.864 782.592c3.264 0 6.272-3.2 6.272-6.656 0-3.456-3.008-6.592-6.272-6.592-3.264 0-6.272 3.2-6.272 6.592 0 3.456 3.008 6.656 6.272 6.656z m-140.544 153.344c2.304 2.432 5.568 3.84 8.768 3.84a12.16 12.16 0 0 0 8.832-3.84 13.76 13.76 0 0 0 0-18.56 12.224 12.224 0 0 0-8.832-3.84 12.16 12.16 0 0 0-8.768 3.84 13.696 13.696 0 0 0 0 18.56zM552.32 1018.24c3.456 3.648 8.32 5.76 13.184 5.76a18.368 18.368 0 0 0 13.184-5.76 20.608 20.608 0 0 0 0-27.968 18.368 18.368 0 0 0-13.184-5.824 18.368 18.368 0 0 0-13.184 5.76 20.608 20.608 0 0 0 0 28.032z m-198.336-5.76c4.608 4.8 11.072 7.68 17.6 7.68a24.448 24.448 0 0 0 17.536-7.68 27.456 27.456 0 0 0 0-37.248 24.448 24.448 0 0 0-17.536-7.68 24.448 24.448 0 0 0-17.6 7.68 27.52 27.52 0 0 0 0 37.184z m-175.68-91.84c5.76 6.08 13.824 9.6 21.952 9.6a30.592 30.592 0 0 0 22.016-9.6 34.368 34.368 0 0 0 0-46.592 30.592 30.592 0 0 0-22.016-9.6 30.592 30.592 0 0 0-21.952 9.6 34.368 34.368 0 0 0 0 46.592z m-121.152-159.36c6.912 7.36 16.64 11.648 26.368 11.648a36.736 36.736 0 0 0 26.432-11.584 41.28 41.28 0 0 0 0-55.936 36.736 36.736 0 0 0-26.432-11.584 36.8 36.8 0 0 0-26.368 11.52 41.28 41.28 0 0 0 0 56zM12.736 564.672a42.88 42.88 0 0 0 30.784 13.44 42.88 42.88 0 0 0 30.784-13.44 48.128 48.128 0 0 0 0-65.216 42.88 42.88 0 0 0-30.72-13.44 42.88 42.88 0 0 0-30.848 13.44 48.128 48.128 0 0 0 0 65.216z m39.808-195.392a48.96 48.96 0 0 0 35.2 15.36 48.96 48.96 0 0 0 35.2-15.36 54.976 54.976 0 0 0 0-74.56 48.96 48.96 0 0 0-35.2-15.424 48.96 48.96 0 0 0-35.2 15.424 54.976 54.976 0 0 0 0 74.56zM168.32 212.48c10.368 11.008 24.96 17.408 39.68 17.408 14.592 0 29.184-6.4 39.552-17.408a61.888 61.888 0 0 0 0-83.84 55.104 55.104 0 0 0-39.616-17.408c-14.656 0-29.248 6.4-39.616 17.408a61.888 61.888 0 0 0 0 83.84zM337.344 124.8c11.52 12.16 27.712 19.264 43.968 19.264 16.256 0 32.448-7.04 43.968-19.264a68.672 68.672 0 0 0 0-93.184 61.248 61.248 0 0 0-43.968-19.264 61.248 61.248 0 0 0-43.968 19.264 68.736 68.736 0 0 0 0 93.184z m189.632-1.088c12.672 13.44 30.528 21.248 48.448 21.248s35.712-7.808 48.384-21.248a75.584 75.584 0 0 0 0-102.464A67.392 67.392 0 0 0 575.36 0c-17.92 0-35.776 7.808-48.448 21.248a75.584 75.584 0 0 0 0 102.464z m173.824 86.592c13.824 14.592 33.28 23.104 52.736 23.104 19.584 0 39.04-8.512 52.8-23.104a82.432 82.432 0 0 0 0-111.744 73.472 73.472 0 0 0-52.8-23.168c-19.52 0-38.912 8.512-52.736 23.168a82.432 82.432 0 0 0 0 111.744z m124.032 158.528c14.976 15.872 36.032 25.088 57.216 25.088 21.12 0 42.24-9.216 57.152-25.088a89.344 89.344 0 0 0 0-121.088 79.616 79.616 0 0 0-57.152-25.088c-21.184 0-42.24 9.216-57.216 25.088a89.344 89.344 0 0 0 0 121.088z m50.432 204.032c16.128 17.088 38.784 27.008 61.632 27.008 22.784 0 45.44-9.92 61.568-27.008a96.256 96.256 0 0 0 0-130.432 85.76 85.76 0 0 0-61.568-27.072c-22.848 0-45.44 9.984-61.632 27.072a96.192 96.192 0 0 0 0 130.432z",fill:"#262626","p-id":"10890"})}),ut=({size:n=32})=>p.jsx("svg",{className:"tiny-uploader-icon tiny-uploader-icon-success",viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg","p-id":"14620",width:n,height:n,children:p.jsx("path",{d:"M512 1024c-144.768-3.968-265.258667-54.186667-361.386667-150.613333C54.186667 777.258667 3.968 656.768 0 512c3.968-144.768 54.186667-265.258667 150.613333-361.386667C246.741333 54.186667 367.232 3.968 512 0c144.768 3.968 265.258667 54.186667 361.386667 150.613333C969.813333 246.741333 1020.032 367.232 1024 512c-3.968 144.768-54.186667 265.258667-150.613333 361.386667-96.128 96.426667-216.618667 146.645333-361.386667 150.613333z m0-928c-118.058667 2.56-216.192 43.093333-294.4 121.6C139.093333 295.808 98.56 393.941333 96 512c2.56 118.058667 43.093333 216.192 121.6 294.4 78.208 78.506667 176.341333 119.04 294.4 121.6 118.058667-2.56 216.192-43.093333 294.4-121.6 78.506667-78.208 119.04-176.341333 121.6-294.4-2.56-118.058667-43.093333-216.192-121.6-294.4-78.208-78.506667-176.341333-119.04-294.4-121.6z m-47.786667 640c-13.354667 0-24.746667-4.693333-34.133333-14.08l-128-128c-9.386667-9.941333-14.08-21.333333-14.08-34.133333 0-12.501333 4.821333-23.594667 14.506667-33.28 9.685333-9.685333 20.906667-14.506667 33.706666-14.506667 12.501333 0 23.765333 4.693333 33.706667 14.08l86.186667 85.76 190.72-301.653333c8.234667-11.392 18.474667-18.474667 30.72-21.333334a46.933333 46.933333 0 0 1 35.84 7.253334c11.648 7.381333 18.901333 17.194667 21.76 29.44 2.56 12.245333 0.128 24.32-7.253334 36.266666l-224 352c-7.978667 12.8-19.626667 20.181333-34.986666 22.186667h-4.693334z",fill:"#67c23a","p-id":"14621"})}),ht=({size:n=32})=>p.jsx("svg",{className:"tiny-uploader-icon tiny-uploader-icon-pause",viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg","p-id":"50387",width:n,height:n,children:p.jsx("path",{d:"M640.229819 336.813079c30.19669 0 54.674007 24.477317 54.674006 54.674007v244.423206c0 30.19669-24.477317 54.674007-54.674006 54.674007s-54.674007-24.477317-54.674007-54.674007V391.487086c-0.009999-30.19669 24.477317-54.674007 54.674007-54.674007z m-257.301795 0c30.19669 0 54.674007 24.477317 54.674006 54.674007v244.423206c0 30.19669-24.477317 54.674007-54.674006 54.674007s-54.674007-24.477317-54.674007-54.674007V391.487086c0-30.19669 24.477317-54.674007 54.674007-54.674007z m420.613892 471.618301c-163.852039 160.942358-427.153176 158.612613-588.135529-5.19943S56.693785 376.128769 220.485831 215.116419s427.083184-158.792593 588.135529 4.959456C886.002877 298.747252 928.948169 404.955609 927.988275 515.303513s-45.714989 215.796345-124.446359 293.127867z m73.521941-655.308165C731.879772 5.489398 512.063868-40.145599 320.10491 37.485891 128.145953 115.107382 1.849797 300.727035 0.119987 507.774338s121.426689 394.756727 312.055793 475.587867 411.184926 38.885737 558.818742-106.298348c201.597901-198.22827 204.307604-522.35274 6.069335-723.940642z",fill:"#606060","p-id":"50388"})}),ct=({size:n=32})=>p.jsx("svg",{className:"tiny-uploader-icon tiny-uploader-icon-play",viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg","p-id":"40556",width:n,height:n,children:p.jsx("path",{d:"M791.04 384L378.88 147.626667a145.92 145.92 0 0 0-218.88 128v474.453333A145.92 145.92 0 0 0 305.92 896a146.346667 146.346667 0 0 0 72.96-19.626667L791.04 640a145.92 145.92 0 0 0 0-252.586667z m-42.666667 178.773333l-412.16 239.786667a61.44 61.44 0 0 1-60.586666 0 60.586667 60.586667 0 0 1-30.293334-52.48V273.92a60.586667 60.586667 0 0 1 30.293334-52.48A64.426667 64.426667 0 0 1 305.92 213.333333a65.706667 65.706667 0 0 1 30.293333 8.106667l412.16 238.08a60.586667 60.586667 0 0 1 0 104.96z","p-id":"40557"})}),dt=({size:n=32})=>p.jsx("svg",{className:"tiny-uploader-icon tiny-uploader-icon-remove",viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg","p-id":"26718",width:n,height:n,children:p.jsx("path",{d:"M644.608 307.2L512 439.808 379.392 307.2 307.2 379.392 439.808 512 307.2 644.608 379.392 716.8 512 584.192 644.608 716.8 716.8 644.608 584.192 512 716.8 379.392 644.608 307.2zM512 0C228.864 0 0 228.864 0 512s228.864 512 512 512 512-228.864 512-512S795.136 0 512 0z m0 921.6c-225.792 0-409.6-183.808-409.6-409.6s183.808-409.6 409.6-409.6 409.6 183.808 409.6 409.6-183.808 409.6-409.6 409.6z",fill:"#f56c6c","p-id":"26719"})}),pt=({size:n=32})=>p.jsx("svg",{className:"tiny-uploader-icon tiny-uploader-icon-retry",viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg","p-id":"25652",width:n,height:n,children:p.jsx("path",{d:"M512 170.624c-117.248 0-220.8 59.2-282.24 149.376h111.616v85.312h-256v-256h85.312v106.624a426.688 426.688 0 0 1 768 256h-85.312A341.312 341.312 0 0 0 512 170.688zM170.688 512a341.312 341.312 0 0 0 623.616 192h-111.616V618.624h256v256h-85.312V768a426.688 426.688 0 0 1-768-256h85.312z","p-id":"25653",fill:"#707070"})}),ft=n=>{const{file:e,onClick:i}=n,[o,h]=U.useState("0%"),{sdk:d}=X(),g=E=>(E*100).toFixed(2),y=E=>d==null?void 0:d.pause(E),R=E=>d==null?void 0:d.resume(E),C=E=>d==null?void 0:d.retry(E),v=E=>d==null?void 0:d.remove(E);return U.useEffect(()=>{h(`${g(e.progress)}%`)},[e.progress]),p.jsx("div",{className:"tiny-uploader-file","data-status":e.status,"data-id":e.id,children:p.jsxs("div",{className:"tiny-uploader-info-wrap",children:[p.jsxs("div",{className:"tiny-uploader-filename-container",title:e.name,onClick:()=>i(e),children:[p.jsx(ot,{size:16}),p.jsxs("div",{className:Se({"tiny-uploader-filename":!0,"tiny-uploader-name-fail":e.status===f.AddFail||e.status===f.CheckFail||e.status===f.Fail||e.status===f.UploadFail}),children:[e.name,e.size>0&&p.jsx("span",{className:"tiny-uploader-size",children:`(${e.renderSize})`})]})]}),p.jsxs("div",{style:{display:"flex",alignItems:"center"},children:[p.jsxs("div",{className:"tiny-uploader-status",children:[(e.status===f.Ready||e.status===f.Reading)&&p.jsx(lt,{size:14}),e.errorMessage&&p.jsx("div",{className:"tiny-uploader-error-meessage",children:e.errorMessage})]}),p.jsx("div",{className:"tiny-uploader-percent",children:e.status===f.Success?p.jsx(ut,{size:16}):`${g(e.progress)} %`}),p.jsxs("div",{className:"tiny-uploader-actions",children:[(e.status===f.Uploading||e.status===f.Ready||e.status===f.Reading)&&p.jsx("span",{className:"tiny-uploader-action",onClick:()=>y(e),children:p.jsx(ht,{size:16})}),e.status===f.Pause&&p.jsx("span",{className:"tiny-uploader-action",onClick:()=>R(e),children:p.jsx(ct,{size:16})}),(e.status===f.CheckFail||e.status===f.Fail||e.status===f.UploadFail)&&p.jsx("span",{className:"tiny-uploader-action",onClick:()=>C(e),children:p.jsx(pt,{size:16})}),p.jsx("span",{className:"tiny-uploader-action",onClick:()=>v(e),children:p.jsx(dt,{size:16})})]})]}),(e.status===f.Uploading||e.status===f.Pause||e.status===f.Resume||e.status===f.UploadSuccess||e.status===f.UploadFail)&&p.jsx("div",{class