2 lines
7.7 KiB
JavaScript
2 lines
7.7 KiB
JavaScript
|
|
import{b as C,N as f,B,c as T,f as D,a as L,R as H,E as k,i as x}from"./aws-s3-98528360.js";const E=()=>{};function W(s,t){t===void 0&&(t={});const{body:e=null,headers:a={},method:o="GET",onBeforeRequest:r=E,onUploadProgress:l=E,shouldRetry:i=()=>!0,onAfterRequest:u=E,onTimeout:w=E,responseType:d,retries:c=3,signal:F=null,timeout:_=3e4,withCredentials:j=!1}=t,N=p=>.3*2**(p-1)*1e3,v=new C(_,w);function R(p){return p===void 0&&(p=0),new Promise(async(O,b)=>{const n=new XMLHttpRequest;n.open(o,s,!0),n.withCredentials=j,d&&(n.responseType=d),F==null||F.addEventListener("abort",()=>{n.abort(),b(new DOMException("Aborted","AbortError"))}),n.onload=async()=>{await u(n,p),n.status>=200&&n.status<300?(v.done(),O(n)):i(n)&&p<c?setTimeout(()=>{R(p+1).then(O,b)},N(p)):(v.done(),b(new f(n.statusText,n)))},n.onerror=()=>{i(n)&&p<c?setTimeout(()=>{R(p+1).then(O,b)},N(p)):(v.done(),b(new f(n.statusText,n)))},n.upload.onprogress=U=>{v.progress(),l(U)},a&&Object.keys(a).forEach(U=>{n.setRequestHeader(U,a[U])}),await r(n,p),n.send(e)})}return R()}const X={strings:{uploadStalled:"Upload has not made any progress for %{seconds} seconds. You may want to retry it."}};function h(s,t){if(!Object.prototype.hasOwnProperty.call(s,t))throw new TypeError("attempted to use private field on non-instance");return s}var z=0;function y(s){return"__private_"+z+++"_"+s}const I={version:"3.6.8"};function Q(s,t){let e=t;return e||(e=new Error("Upload error")),typeof e=="string"&&(e=new Error(e)),e instanceof Error||(e=Object.assign(new Error("Upload error"),{data:e})),x(s)?(e=new f(e,s),e):(e.request=s,e)}function q(s){return s.data.slice(0,s.data.size,s.meta.type)}const $={formData:!0,fieldName:"file",method:"post",allowedMetaFields:null,responseUrlFieldName:"url",bundle:!1,headers:{},timeout:30*1e3,limit:5,withCredentials:!1,responseType:"",getResponseData(s){let t={};try{t=JSON.parse(s)}catch{}return t},getResponseError(s,t){let e=new Error("Upload error");return x(t)&&(e=new f(e,t)),e},validateStatus(s){return s>=200&&s<300}};var m=y("getFetcher"),M=y("uploadLocalFile"),P=y("uploadBundle"),A=y("getCompanionClientArgs"),S=y("uploadFiles"),g=y("handleUpload");class J extends B{constructor(t,e){if(super(t,{...$,fieldName:e.bundle?"files[]":"file",...e}),Object.defineProperty(this,S,{value:Y}),Object.defineProperty(this,A,{value:V}),Object.defineProperty(this,P,{value:K}),Object.defineProperty(this,M,{value:G}),Object.defineProperty(this,m,{writable:!0,value:void 0}),Object.defineProperty(this,g,{writable:!0,value:async a=>{if(a.length===0){this.uppy.log("[XHRUpload] No files to upload!");return}this.opts.limit===0&&!this.opts[T]&&this.uppy.log("[XHRUpload] When uploading multiple files at once, consider setting the `limit` option (to `10` for example), to limit the number of concurrent uploads, which helps prevent memory and network issues: https://uppy.io/docs/xhr-upload/#limit-0","warning"),this.uppy.log("[XHRUpload] Uploading...");const o=this.uppy.getFilesByIds(a),r=D(o),l=L(r);if(this.uppy.emit("upload-start",l),this.opts.bundle){if(r.some(u=>u.isRemote))throw new Error("Can’t upload remote files when the `bundle: true` option is set");if(typeof this.opts.headers=="function")throw new TypeError("`headers` may not be a function when the `bundle: true` option is set");await h(this,P)[P](r)}else await h(this,S)[S](r)}}),this.type="uploader",this.id=this.opts.id||"XHRUpload",this.defaultLocale=X,this.i18nInit(),T in this.opts?this.requests=this.opts[T]:this.requests=new H(this.opts.limit),this.opts.bundle&&!this.opts.formData)throw new Error("`opts.formData` must be true when `opts.bundle` is enabled.");if(this.opts.bundle&&typeof this.opts.headers=="function")throw new Error("`opts.headers` can not be a function when the `bundle: true` option is set.");if((e==null?void 0:e.allowedMetaFields)===void 0&&"metaFields"in this.opts)throw new Error("The `metaFields` option has been renamed to `allowedMetaFields`.");this.uploaderEvents=Object.create(null),h(this,m)[m]=a=>async(o,r)=>{try{var l;const i=await W(o,{...r,method:r==null||(l=r.method)==null?void 0:l.
|