var vr=Object.defineProperty;var gr=(t,e,r)=>e in t?vr(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var B=(t,e,r)=>gr(t,typeof e!="symbol"?e+"":e,r);import{ck as Ke,cl as we,X as Ve,x as De,k as $,bh as ee,aQ as Ht,t as br,bu as Ue,v as _r,cm as it,aH as at,b5 as wr,b6 as Er,bg as Sr,as as Ur,g as Rr,r as We,j as Pr}from"./main-TIUJvpaR.js";import{U as st,a as Or}from"./uploaded-file-CLeM2EFo.js";import{p as xr}from"./pretty-bytes-bO14ePu9.js";var Re={exports:{}},Pe={};/**
 * @license React
 * use-sync-external-store-shim.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 ut;function Cr(){if(ut)return Pe;ut=1;var t=Ke();function e(P,E){return P===E&&(P!==0||1/P===1/E)||P!==P&&E!==E}var r=typeof Object.is=="function"?Object.is:e,n=t.useState,o=t.useEffect,i=t.useLayoutEffect,s=t.useDebugValue;function f(P,E){var x=E(),I=n({inst:{value:x,getSnapshot:E}}),O=I[0].inst,A=I[1];return i(function(){O.value=x,O.getSnapshot=E,p(O)&&A({inst:O})},[P,x,E]),o(function(){return p(O)&&A({inst:O}),P(function(){p(O)&&A({inst:O})})},[P]),s(x),x}function p(P){var E=P.getSnapshot;P=P.value;try{var x=E();return!r(P,x)}catch{return!0}}function d(P,E){return E()}var _=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?d:f;return Pe.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:_,Pe}var lt;function Tr(){return lt||(lt=1,Re.exports=Cr()),Re.exports}var Oe={exports:{}},xe={};/**
 * @license React
 * use-sync-external-store-shim/with-selector.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 ft;function kr(){if(ft)return xe;ft=1;var t=Ke(),e=Tr();function r(d,_){return d===_&&(d!==0||1/d===1/_)||d!==d&&_!==_}var n=typeof Object.is=="function"?Object.is:r,o=e.useSyncExternalStore,i=t.useRef,s=t.useEffect,f=t.useMemo,p=t.useDebugValue;return xe.useSyncExternalStoreWithSelector=function(d,_,P,E,x){var I=i(null);if(I.current===null){var O={hasValue:!1,value:null};I.current=O}else O=I.current;I=f(function(){function w(R){if(!h){if(h=!0,c=R,R=E(R),x!==void 0&&O.hasValue){var S=O.value;if(x(S,R))return y=S}return y=R}if(S=y,n(c,R))return S;var k=E(R);return x!==void 0&&x(S,k)?(c=R,S):(c=R,y=k)}var h=!1,c,y,m=P===void 0?null:P;return[function(){return w(_())},m===null?void 0:function(){return w(m())}]},[_,P,E,x]);var A=o(d,I[0],I[1]);return s(function(){O.hasValue=!0,O.value=A},[A]),p(A),A},xe}var ct;function Ar(){return ct||(ct=1,Oe.exports=kr()),Oe.exports}var Ir=Ar();const Lr=we(Ir);function pt(t,e,r){let n=t instanceof st?t:new st(t);return r!=null&&r.modifyUploadedFile&&(n=r.modifyUploadedFile(n)),{file:n,percentage:0,bytesUploaded:0,status:"pending",options:{...e,restrictions:jr(e)}}}function jr(t){var r;if(t.restrictions)return t.restrictions;const e=Ve().uploading_types[t.uploadType];return e.max_file_size||e.accept?{maxFileSize:e.max_file_size?parseInt(`${e.max_file_size}`):void 0,allowedFileTypes:(r=e.accept)==null?void 0:r.map(function(n){switch(n){case"image":return"image/*";case"video":return"video/*";case"audio":return"audio/*";default:return n}})}:null}const Mt=2097152;var Ce,ht;function Dr(){if(ht)return Ce;ht=1;function t(e,r){this.text=e=e||"",this.hasWild=~e.indexOf("*"),this.separator=r,this.parts=e.split(r)}return t.prototype.match=function(e){var r=!0,n=this.parts,o,i=n.length,s;if(typeof e=="string"||e instanceof String)if(!this.hasWild&&this.text!=e)r=!1;else{for(s=(e||"").split(this.separator),o=0;r&&o<i;o++)n[o]!=="*"&&(o<s.length?r=n[o]===s[o]:r=!1);r=r&&s}else if(typeof e.splice=="function")for(r=[],o=e.length;o--;)this.match(e[o])&&(r[r.length]=e[o]);else if(typeof e=="object"){r={};for(var f in e)this.match(f)&&(r[f]=e[f])}return r},Ce=function(e,r,n){var o=new t(e,n||/[\/\.]/);return typeof r<"u"?o.match(r):o},Ce}var Te,dt;function Fr(){if(dt)return Te;dt=1;var t=Dr(),e=/[\/\+\.]/;return Te=function(r,n){function o(i){var s=t(i,r,e);return s&&s.length>=2}return n?o(n.split(";")[0]):o},Te}var Nr=Fr();const qr=we(Nr);function zr(t,e){if(!e)return;const{maxFileSize:r,allowedFileTypes:n}=e;if(r&&t.size!=null&&t.size>r)return De("`:file` exceeds maximum allowed size of :size",{values:{file:t.name,size:xr(r)}});if(n!=null&&n.length&&!Br(t,n))return De("This file type is not allowed")}function Br(t,e){return e.map(r=>r.split(",")).flat().some(r=>{if(r.includes("/"))return t.mime?qr(t.mime.replace(/;.*?$/,""),r):!1;const n=r.replace(".","").toLowerCase();return n&&t.extension?t.extension.toLowerCase()===n:!1})}class Hr{constructor(){B(this,"aliveTimer");B(this,"isDone",!1);B(this,"timeout",3e4);B(this,"timeoutHandler",null)}progress(){this.isDone||!this.timeoutHandler||this.timeout>0&&(clearTimeout(this.aliveTimer),this.aliveTimer=setTimeout(this.timeoutHandler,this.timeout))}done(){this.isDone||(clearTimeout(this.aliveTimer),this.aliveTimer=null,this.isDone=!0)}}class Xe{constructor(e,r){B(this,"abortController");this.file=e,this.config=r,this.abortController=new AbortController}async start(){const e=new FormData,{onSuccess:r,onError:n,onProgress:o,metadata:i}=this.config;e.set("file",this.file.native),e.set("clientMime",this.file.mime),e.set("clientExtension",this.file.extension),e.set("uploadType",this.config.uploadType),e.set("backendId",this.config.backendId),i&&Object.entries(i).forEach(([f,p])=>{e.set(f,`${p}`)});const s=await $.post("file-entries",e,{onUploadProgress:f=>{f.event.lengthComputable&&(o==null||o({bytesUploaded:f.loaded,bytesTotal:f.total||0}))},signal:this.abortController.signal,headers:{"Content-Type":"multipart/form-data"}}).catch(f=>{f.code!=="ERR_CANCELED"&&(n==null||n(ee(f),this.file))});this.abortController.signal.aborted||s&&s.data.fileEntry&&(r==null||r(s.data.fileEntry,this.file))}abort(){return this.abortController.abort(),Promise.resolve()}static async create(e,r){return new Xe(e,r)}}var ke,yt;function Mr(){if(yt)return ke;yt=1;const t=new Set(["ENOTFOUND","ENETUNREACH","UNABLE_TO_GET_ISSUER_CERT","UNABLE_TO_GET_CRL","UNABLE_TO_DECRYPT_CERT_SIGNATURE","UNABLE_TO_DECRYPT_CRL_SIGNATURE","UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY","CERT_SIGNATURE_FAILURE","CRL_SIGNATURE_FAILURE","CERT_NOT_YET_VALID","CERT_HAS_EXPIRED","CRL_NOT_YET_VALID","CRL_HAS_EXPIRED","ERROR_IN_CERT_NOT_BEFORE_FIELD","ERROR_IN_CERT_NOT_AFTER_FIELD","ERROR_IN_CRL_LAST_UPDATE_FIELD","ERROR_IN_CRL_NEXT_UPDATE_FIELD","OUT_OF_MEM","DEPTH_ZERO_SELF_SIGNED_CERT","SELF_SIGNED_CERT_IN_CHAIN","UNABLE_TO_GET_ISSUER_CERT_LOCALLY","UNABLE_TO_VERIFY_LEAF_SIGNATURE","CERT_CHAIN_TOO_LONG","CERT_REVOKED","INVALID_CA","PATH_LENGTH_EXCEEDED","INVALID_PURPOSE","CERT_UNTRUSTED","CERT_REJECTED","HOSTNAME_MISMATCH"]);return ke=e=>!t.has(e&&e.code),ke}var $r=Mr();const Gr=we($r),Ye="axios-retry";function $t(t){const e=["ERR_CANCELED","ECONNABORTED"];return t.response||!t.code||e.includes(t.code)?!1:Gr(t)}const Gt=["get","head","options"],Kr=Gt.concat(["put","delete"]);function Qe(t){return t.code!=="ECONNABORTED"&&(!t.response||t.response.status===429||t.response.status>=500&&t.response.status<=599)}function Vr(t){var e;return(e=t.config)!=null&&e.method?Qe(t)&&Gt.indexOf(t.config.method)!==-1:!1}function Kt(t){var e;return(e=t.config)!=null&&e.method?Qe(t)&&Kr.indexOf(t.config.method)!==-1:!1}function Vt(t){return $t(t)||Kt(t)}function Ze(t=void 0){var n;const e=(n=t==null?void 0:t.response)==null?void 0:n.headers["retry-after"];if(!e)return 0;let r=(Number(e)||0)*1e3;return r===0&&(r=(new Date(e).valueOf()||0)-Date.now()),Math.max(0,r)}function Wr(t=0,e=void 0){return Math.max(0,Ze(e))}function Xr(t=0,e=void 0,r=100){const n=2**t*r,o=Math.max(n,Ze(e)),i=o*.2*Math.random();return o+i}function Yr(t=100){return(e=0,r=void 0)=>{const n=e*t;return Math.max(n,Ze(r))}}const Qr={retries:3,retryCondition:Vt,retryDelay:Wr,shouldResetTimeout:!1,onRetry:()=>{},onMaxRetryTimesExceeded:()=>{},validateResponse:null};function Zr(t,e){return{...Qr,...e,...t[Ye]}}function mt(t,e,r=!1){const n=Zr(t,e||{});return n.retryCount=n.retryCount||0,(!n.lastRequestTime||r)&&(n.lastRequestTime=Date.now()),t[Ye]=n,n}function Jr(t,e){t.defaults.agent===e.agent&&delete e.agent,t.defaults.httpAgent===e.httpAgent&&delete e.httpAgent,t.defaults.httpsAgent===e.httpsAgent&&delete e.httpsAgent}async function en(t,e){const{retries:r,retryCondition:n}=t,o=(t.retryCount||0)<r&&n(e);if(typeof o=="object")try{return await o!==!1}catch{return!1}return o}async function tn(t,e,r,n){var p;e.retryCount+=1;const{retryDelay:o,shouldResetTimeout:i,onRetry:s}=e,f=o(e.retryCount,r);if(Jr(t,n),!i&&n.timeout&&e.lastRequestTime){const d=Date.now()-e.lastRequestTime,_=n.timeout-d-f;if(_<=0)return Promise.reject(r);n.timeout=_}return n.transformRequest=[d=>d],await s(e.retryCount,r,n),(p=n.signal)!=null&&p.aborted?Promise.resolve(t(n)):new Promise(d=>{var E;const _=()=>{clearTimeout(P),d(t(n))},P=setTimeout(()=>{var x;d(t(n)),(x=n.signal)!=null&&x.removeEventListener&&n.signal.removeEventListener("abort",_)},f);(E=n.signal)!=null&&E.addEventListener&&n.signal.addEventListener("abort",_,{once:!0})})}async function rn(t,e){t.retryCount>=t.retries&&await t.onMaxRetryTimesExceeded(e,t.retryCount)}const G=(t,e)=>{const r=t.interceptors.request.use(o=>{var i;return mt(o,e,!0),(i=o[Ye])!=null&&i.validateResponse&&(o.validateStatus=()=>!1),o}),n=t.interceptors.response.use(null,async o=>{var f;const{config:i}=o;if(!i)return Promise.reject(o);const s=mt(i,e);return o.response&&((f=s.validateResponse)!=null&&f.call(s,o.response))?o.response:await en(s,o)?tn(t,s,o,i):(await rn(s,o),Promise.reject(o))});return{requestInterceptorId:r,responseInterceptorId:n}};G.isNetworkError=$t;G.isSafeRequestError=Vr;G.isIdempotentRequestError=Kt;G.isNetworkOrIdempotentRequestError=Vt;G.exponentialDelay=Xr;G.linearDelay=Yr;G.isRetryableError=Qe;const Wt=1024*1024,nn=20*Wt,on=10,an=5;class Ee{constructor(e,r){B(this,"abortController");B(this,"chunks",[]);B(this,"uploadId");B(this,"fileKey");B(this,"chunkAxios");B(this,"abortedByUser",!1);B(this,"uploadedParts");this.file=e,this.config=r,this.abortController=new AbortController,this.chunkAxios=Ht.create(),G(this.chunkAxios,{retries:3})}get storageKey(){return`s3-multipart::${this.file.fingerprint}`}async start(){var n,o,i,s,f;const e=br(this.storageKey);if(e&&await this.getUploadedParts(e),!((n=this.uploadedParts)!=null&&n.length)&&(await this.createMultipartUpload(),!this.uploadId))return;if(this.prepareChunks(),await this.uploadParts()==="done"){if(!await this.completeMultipartUpload())return;try{const d=await this.createFileEntry();if(d!=null&&d.fileEntry){(i=(o=this.config).onSuccess)==null||i.call(o,d==null?void 0:d.fileEntry,this.file),Ue(this.storageKey);return}}catch{}}this.abortController.signal.aborted||this.abortController.abort(),this.abortedByUser||(f=(s=this.config).onError)==null||f.call(s,null,this.file)}async abort(){this.abortedByUser=!0,this.abortController.abort(),await this.abortUploadOnS3()}async uploadParts(){const e=this.chunks.filter(n=>!n.done);if(!e.length)return Promise.resolve("done");const r=await this.batchSignUrls(e.slice(0,on));if(r){for(;r.length;){const o=r.splice(0,an).map(s=>this.uploadPartToS3(s));if(!(await Promise.all(o)).every(s=>s))return}return await this.uploadParts()}}async batchSignUrls(e){const r=await this.chunkAxios.post("api/v1/s3/multipart/batch-sign-part-urls",{backendId:this.config.backendId,uploadType:this.config.uploadType,partNumbers:e.map(n=>n.partNumber),uploadId:this.uploadId,key:this.fileKey},{signal:this.abortController.signal}).then(n=>n.data).catch(n=>{this.abortController.signal.aborted||this.abortController.abort()});return r==null?void 0:r.urls}async uploadPartToS3({url:e,partNumber:r}){const n=this.chunks.find(o=>o.partNumber===r);if(n)return this.chunkAxios.put(e,n.blob,{withCredentials:!1,signal:this.abortController.signal,onUploadProgress:o=>{var s,f;if(!o.event.lengthComputable)return;n.bytesUploaded=o.loaded;const i=this.chunks.reduce((p,d)=>p+d.bytesUploaded,0);(f=(s=this.config).onProgress)==null||f.call(s,{bytesUploaded:i,bytesTotal:this.file.size})}}).then(o=>{const i=o.headers.etag;if(i)return n.done=!0,n.etag=i,!0}).catch(o=>{!this.abortController.signal.aborted&&o!==void 0&&this.abortController.abort()})}async createMultipartUpload(){const e=await $.post("s3/multipart/create",{clientName:this.file.name,clientMime:this.file.mime,clientSize:this.file.size,clientExtension:this.file.extension,uploadType:this.config.uploadType,backendId:this.config.backendId,...this.config.metadata}).then(r=>r.data).catch(r=>{var n,o;r.code!=="ERR_CANCELED"&&((o=(n=this.config).onError)==null||o.call(n,ee(r),this.file))});e&&(this.uploadId=e.uploadId,this.fileKey=e.key,_r(this.storageKey,{createdAt:new Date().toISOString(),fileKey:this.fileKey,uploadId:this.uploadId}))}async getUploadedParts({fileKey:e,uploadId:r}){var o;const n=await $.post("s3/multipart/get-uploaded-parts",{backendId:this.config.backendId,uploadType:this.config.uploadType,key:e,uploadId:r}).then(i=>i.data).catch(()=>(Ue(this.storageKey),null));(o=n==null?void 0:n.parts)!=null&&o.length&&(this.uploadedParts=n.parts,this.uploadId=r,this.fileKey=e)}async completeMultipartUpload(){return $.post("s3/multipart/complete",{backendId:this.config.backendId,uploadType:this.config.uploadType,key:this.fileKey,uploadId:this.uploadId,parts:this.chunks.map(e=>({ETag:e.etag,PartNumber:e.partNumber}))}).then(e=>e.data).catch(()=>{var e,r;(r=(e=this.config).onError)==null||r.call(e,null,this.file),this.abortUploadOnS3()}).finally(()=>{Ue(this.storageKey)})}async createFileEntry(){return await $.post("s3/entries",{...this.config.metadata,clientMime:this.file.mime,clientName:this.file.name,clientSize:this.file.size,clientExtension:this.file.extension,filename:this.fileKey.split("/").pop(),uploadType:this.config.uploadType,backendId:this.config.backendId}).then(e=>e.data).catch()}prepareChunks(){var n;this.chunks=[];const e=Math.max(5*Wt,Math.ceil(this.file.size/1e4)),r=Math.max(nn,e);if(this.file.size===0)this.chunks.push({blob:this.file.native,done:!1,partNumber:1,bytesUploaded:0});else{let o=1;for(let i=0;i<this.file.size;i+=r){const s=Math.min(this.file.size,i+r),f=(n=this.uploadedParts)==null?void 0:n.find(p=>p.PartNumber===o);this.chunks.push({blob:this.file.native.slice(i,s),done:!!f,partNumber:o,etag:f?f.ETag:void 0,bytesUploaded:f!=null&&f.Size?parseInt(f==null?void 0:f.Size):0}),o++}}}abortUploadOnS3(){return $.post("s3/multipart/abort",{key:this.fileKey,uploadId:this.uploadId})}static async create(e,r){return new Ee(e,r)}}class Je{constructor(e,r){B(this,"abortController");B(this,"presignedRequest");this.file=e,this.config=r,this.abortController=new AbortController}async start(){var n,o,i,s;if(this.presignedRequest=await this.presignPostUrl(),!this.presignedRequest||await this.uploadFileToS3()!=="uploaded")return;const r=await this.createFileEntry();r!=null&&r.fileEntry?(o=(n=this.config).onSuccess)==null||o.call(n,r.fileEntry,this.file):this.abortController.signal||(s=(i=this.config).onError)==null||s.call(i,null,this.file)}abort(){return this.abortController.abort(),Promise.resolve()}presignPostUrl(){return $.post("s3/simple/presign",{clientName:this.file.name,clientMime:this.file.mime,clientSize:this.file.size,clientExtension:this.file.extension,uploadType:this.config.uploadType,backendId:this.config.backendId,...this.config.metadata},{signal:this.abortController.signal}).then(e=>e.data).catch(e=>{var r,n;e.code!=="ERR_CANCELED"&&((n=(r=this.config).onError)==null||n.call(r,ee(e),this.file))})}uploadFileToS3(){const{url:e,acl:r}=this.presignedRequest;return Ht.put(e,this.file.native,{signal:this.abortController.signal,withCredentials:!1,headers:{"Content-Type":this.file.mime,"x-amz-acl":r},onUploadProgress:n=>{var o,i;n.event.lengthComputable&&((i=(o=this.config).onProgress)==null||i.call(o,{bytesUploaded:n.loaded,bytesTotal:n.total||0}))}}).then(()=>"uploaded").catch(n=>{var o,i;n.code!=="ERR_CANCELED"&&((i=(o=this.config).onError)==null||i.call(o,ee(n),this.file))})}async createFileEntry(){return await $.post("s3/entries",{...this.config.metadata,clientMime:this.file.mime,clientName:this.file.name,clientSize:this.file.size,clientExtension:this.file.extension,filename:this.presignedRequest.key.split("/").pop(),uploadType:this.config.uploadType,backendId:this.config.backendId}).then(e=>e.data).catch(e=>{var r,n;e.code!=="ERR_CANCELED"&&((n=(r=this.config).onError)==null||n.call(r,ee(e),this.file))})}static async create(e,r){return new Je(e,r)}}var Ae={},vt;function sn(){return vt||(vt=1,(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=A,t.setCookie=t.removeCookie=t.getCookie=void 0,t.stringifyOptions=E;var e=Ke();function r(w,h){return f(w)||s(w,h)||o(w,h)||n()}function n(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function o(w,h){if(w){if(typeof w=="string")return i(w,h);var c=Object.prototype.toString.call(w).slice(8,-1);if(c==="Object"&&w.constructor&&(c=w.constructor.name),c==="Map"||c==="Set")return Array.from(w);if(c==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(c))return i(w,h)}}function i(w,h){(h==null||h>w.length)&&(h=w.length);for(var c=0,y=new Array(h);c<h;c++)y[c]=w[c];return y}function s(w,h){var c=w==null?null:typeof Symbol<"u"&&w[Symbol.iterator]||w["@@iterator"];if(c!=null){var y=[],m=!0,R=!1,S,k;try{for(c=c.call(w);!(m=(S=c.next()).done)&&(y.push(S.value),!(h&&y.length===h));m=!0);}catch(C){R=!0,k=C}finally{try{!m&&c.return!=null&&c.return()}finally{if(R)throw k}}return y}}function f(w){if(Array.isArray(w))return w}function p(w,h){var c=Object.keys(w);if(Object.getOwnPropertySymbols){var y=Object.getOwnPropertySymbols(w);h&&(y=y.filter(function(m){return Object.getOwnPropertyDescriptor(w,m).enumerable})),c.push.apply(c,y)}return c}function d(w){for(var h=1;h<arguments.length;h++){var c=arguments[h]!=null?arguments[h]:{};h%2?p(Object(c),!0).forEach(function(y){_(w,y,c[y])}):Object.getOwnPropertyDescriptors?Object.defineProperties(w,Object.getOwnPropertyDescriptors(c)):p(Object(c)).forEach(function(y){Object.defineProperty(w,y,Object.getOwnPropertyDescriptor(c,y))})}return w}function _(w,h,c){return h in w?Object.defineProperty(w,h,{value:c,enumerable:!0,configurable:!0,writable:!0}):w[h]=c,w}var P=typeof window<"u";function E(w){return Object.keys(w).reduce(function(h,c){return c==="days"||w[c]===!1?h:w[c]===!0?"".concat(h,"; ").concat(c):"".concat(h,"; ").concat(c,"=").concat(w[c])},"")}var x=function(h,c,y){if(P){var m=d({days:7,path:"/"},y),R=new Date(Date.now()+m.days*864e5).toUTCString();document.cookie=h+"="+encodeURIComponent(c)+"; expires="+R+E(m)}};t.setCookie=x;var I=function(h){var c=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";return P&&document.cookie.split("; ").reduce(function(y,m){var R=m.split("=");return R[0]===h?decodeURIComponent(R[1]):y},"")||c};t.getCookie=I;var O=function(h){document.cookie="".concat(h,"=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;")};t.removeCookie=O;function A(w,h){var c=(0,e.useState)(function(){return I(w,h)}),y=r(c,2),m=y[0],R=y[1],S=(0,e.useCallback)(function(){R(void 0),O(w)},[w]),k=(0,e.useCallback)(function(C,N){R(C),x(w,C,N)},[w]);return[m,k,S]}})(Ae)),Ae}var un=sn();function Fe(t){"@babel/helpers - typeof";return Fe=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Fe(t)}function ln(t,e,r){return Object.defineProperty(t,"prototype",{writable:!1}),t}function fn(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function cn(t,e,r){return e=se(e),pn(t,et()?Reflect.construct(e,r||[],se(t).constructor):e.apply(t,r))}function pn(t,e){if(e&&(Fe(e)==="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return hn(t)}function hn(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function dn(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&ae(t,e)}function Ne(t){var e=typeof Map=="function"?new Map:void 0;return Ne=function(n){if(n===null||!mn(n))return n;if(typeof n!="function")throw new TypeError("Super expression must either be null or a function");if(typeof e<"u"){if(e.has(n))return e.get(n);e.set(n,o)}function o(){return yn(n,arguments,se(this).constructor)}return o.prototype=Object.create(n.prototype,{constructor:{value:o,enumerable:!1,writable:!0,configurable:!0}}),ae(o,n)},Ne(t)}function yn(t,e,r){if(et())return Reflect.construct.apply(null,arguments);var n=[null];n.push.apply(n,e);var o=new(t.bind.apply(t,n));return r&&ae(o,r.prototype),o}function et(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(et=function(){return!!t})()}function mn(t){try{return Function.toString.call(t).indexOf("[native code]")!==-1}catch{return typeof t=="function"}}function ae(t,e){return ae=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,o){return n.__proto__=o,n},ae(t,e)}function se(t){return se=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},se(t)}var he=(function(t){function e(r){var n,o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null,i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:null,s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:null;if(fn(this,e),n=cn(this,e,[r]),n.originalRequest=i,n.originalResponse=s,n.causingError=o,o!=null&&(r+=", caused by ".concat(o.toString())),i!=null){var f=i.getHeader("X-Request-ID")||"n/a",p=i.getMethod(),d=i.getURL(),_=s?s.getStatus():"n/a",P=s?s.getBody()||"":"n/a";r+=", originated from request (method: ".concat(p,", url: ").concat(d,", response code: ").concat(_,", response text: ").concat(P,", request id: ").concat(f,")")}return n.message=r,n}return dn(e,t),ln(e)})(Ne(Error));function ue(t){"@babel/helpers - typeof";return ue=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},ue(t)}function vn(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function gn(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,_n(n.key),n)}}function bn(t,e,r){return e&&gn(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}function _n(t){var e=wn(t,"string");return ue(e)=="symbol"?e:e+""}function wn(t,e){if(ue(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e);if(ue(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}var En=(function(){function t(){vn(this,t)}return bn(t,[{key:"listAllUploads",value:function(){return Promise.resolve([])}},{key:"findUploadsByFingerprint",value:function(r){return Promise.resolve([])}},{key:"removeUpload",value:function(r){return Promise.resolve()}},{key:"addUpload",value:function(r,n){return Promise.resolve(null)}}])})();const Xt="3.7.8",Sn=Xt,ne=typeof Buffer=="function",gt=typeof TextDecoder=="function"?new TextDecoder:void 0,bt=typeof TextEncoder=="function"?new TextEncoder:void 0,Un="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",oe=Array.prototype.slice.call(Un),de=(t=>{let e={};return t.forEach((r,n)=>e[r]=n),e})(oe),Rn=/^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/,F=String.fromCharCode.bind(String),_t=typeof Uint8Array.from=="function"?Uint8Array.from.bind(Uint8Array):t=>new Uint8Array(Array.prototype.slice.call(t,0)),Yt=t=>t.replace(/=/g,"").replace(/[+\/]/g,e=>e=="+"?"-":"_"),Qt=t=>t.replace(/[^A-Za-z0-9\+\/]/g,""),Zt=t=>{let e,r,n,o,i="";const s=t.length%3;for(let f=0;f<t.length;){if((r=t.charCodeAt(f++))>255||(n=t.charCodeAt(f++))>255||(o=t.charCodeAt(f++))>255)throw new TypeError("invalid character found");e=r<<16|n<<8|o,i+=oe[e>>18&63]+oe[e>>12&63]+oe[e>>6&63]+oe[e&63]}return s?i.slice(0,s-3)+"===".substring(s):i},tt=typeof btoa=="function"?t=>btoa(t):ne?t=>Buffer.from(t,"binary").toString("base64"):Zt,qe=ne?t=>Buffer.from(t).toString("base64"):t=>{let r=[];for(let n=0,o=t.length;n<o;n+=4096)r.push(F.apply(null,t.subarray(n,n+4096)));return tt(r.join(""))},me=(t,e=!1)=>e?Yt(qe(t)):qe(t),Pn=t=>{if(t.length<2){var e=t.charCodeAt(0);return e<128?t:e<2048?F(192|e>>>6)+F(128|e&63):F(224|e>>>12&15)+F(128|e>>>6&63)+F(128|e&63)}else{var e=65536+(t.charCodeAt(0)-55296)*1024+(t.charCodeAt(1)-56320);return F(240|e>>>18&7)+F(128|e>>>12&63)+F(128|e>>>6&63)+F(128|e&63)}},On=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,Jt=t=>t.replace(On,Pn),wt=ne?t=>Buffer.from(t,"utf8").toString("base64"):bt?t=>qe(bt.encode(t)):t=>tt(Jt(t)),te=(t,e=!1)=>e?Yt(wt(t)):wt(t),Et=t=>te(t,!0),xn=/[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g,Cn=t=>{switch(t.length){case 4:var e=(7&t.charCodeAt(0))<<18|(63&t.charCodeAt(1))<<12|(63&t.charCodeAt(2))<<6|63&t.charCodeAt(3),r=e-65536;return F((r>>>10)+55296)+F((r&1023)+56320);case 3:return F((15&t.charCodeAt(0))<<12|(63&t.charCodeAt(1))<<6|63&t.charCodeAt(2));default:return F((31&t.charCodeAt(0))<<6|63&t.charCodeAt(1))}},er=t=>t.replace(xn,Cn),tr=t=>{if(t=t.replace(/\s+/g,""),!Rn.test(t))throw new TypeError("malformed base64.");t+="==".slice(2-(t.length&3));let e,r,n,o=[];for(let i=0;i<t.length;)e=de[t.charAt(i++)]<<18|de[t.charAt(i++)]<<12|(r=de[t.charAt(i++)])<<6|(n=de[t.charAt(i++)]),r===64?o.push(F(e>>16&255)):n===64?o.push(F(e>>16&255,e>>8&255)):o.push(F(e>>16&255,e>>8&255,e&255));return o.join("")},rt=typeof atob=="function"?t=>atob(Qt(t)):ne?t=>Buffer.from(t,"base64").toString("binary"):tr,rr=ne?t=>_t(Buffer.from(t,"base64")):t=>_t(rt(t).split("").map(e=>e.charCodeAt(0))),nr=t=>rr(or(t)),Tn=ne?t=>Buffer.from(t,"base64").toString("utf8"):gt?t=>gt.decode(rr(t)):t=>er(rt(t)),or=t=>Qt(t.replace(/[-_]/g,e=>e=="-"?"+":"/")),ze=t=>Tn(or(t)),kn=t=>{if(typeof t!="string")return!1;const e=t.replace(/\s+/g,"").replace(/={0,2}$/,"");return!/[^\s0-9a-zA-Z\+/]/.test(e)||!/[^\s0-9a-zA-Z\-_]/.test(e)},ir=t=>({value:t,enumerable:!1,writable:!0,configurable:!0}),ar=function(){const t=(e,r)=>Object.defineProperty(String.prototype,e,ir(r));t("fromBase64",function(){return ze(this)}),t("toBase64",function(e){return te(this,e)}),t("toBase64URI",function(){return te(this,!0)}),t("toBase64URL",function(){return te(this,!0)}),t("toUint8Array",function(){return nr(this)})},sr=function(){const t=(e,r)=>Object.defineProperty(Uint8Array.prototype,e,ir(r));t("toBase64",function(e){return me(this,e)}),t("toBase64URI",function(){return me(this,!0)}),t("toBase64URL",function(){return me(this,!0)})},An=()=>{ar(),sr()},In={version:Xt,VERSION:Sn,atob:rt,atobPolyfill:tr,btoa:tt,btoaPolyfill:Zt,fromBase64:ze,toBase64:te,encode:te,encodeURI:Et,encodeURL:Et,utob:Jt,btou:er,decode:ze,isValid:kn,fromUint8Array:me,toUint8Array:nr,extendString:ar,extendUint8Array:sr,extendBuiltins:An};var Ie,St;function Ln(){return St||(St=1,Ie=function(e,r){if(r=r.split(":")[0],e=+e,!e)return!1;switch(r){case"http":case"ws":return e!==80;case"https":case"wss":return e!==443;case"ftp":return e!==21;case"gopher":return e!==70;case"file":return!1}return e!==0}),Ie}var ye={},Ut;function jn(){if(Ut)return ye;Ut=1;var t=Object.prototype.hasOwnProperty,e;function r(s){try{return decodeURIComponent(s.replace(/\+/g," "))}catch{return null}}function n(s){try{return encodeURIComponent(s)}catch{return null}}function o(s){for(var f=/([^=?#&]+)=?([^&]*)/g,p={},d;d=f.exec(s);){var _=r(d[1]),P=r(d[2]);_===null||P===null||_ in p||(p[_]=P)}return p}function i(s,f){f=f||"";var p=[],d,_;typeof f!="string"&&(f="?");for(_ in s)if(t.call(s,_)){if(d=s[_],!d&&(d===null||d===e||isNaN(d))&&(d=""),_=n(_),d=n(d),_===null||d===null)continue;p.push(_+"="+d)}return p.length?f+p.join("&"):""}return ye.stringify=i,ye.parse=o,ye}var Le,Rt;function Dn(){if(Rt)return Le;Rt=1;var t=Ln(),e=jn(),r=/^[\x00-\x20\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]+/,n=/[\n\r\t]/g,o=/^[A-Za-z][A-Za-z0-9+-.]*:\/\//,i=/:\d+$/,s=/^([a-z][a-z0-9.+-]*:)?(\/\/)?([\\/]+)?([\S\s]*)/i,f=/^[a-zA-Z]:/;function p(h){return(h||"").toString().replace(r,"")}var d=[["#","hash"],["?","query"],function(c,y){return E(y.protocol)?c.replace(/\\/g,"/"):c},["/","pathname"],["@","auth",1],[NaN,"host",void 0,1,1],[/:(\d*)$/,"port",void 0,1],[NaN,"hostname",void 0,1,1]],_={hash:1,query:1};function P(h){var c;typeof window<"u"?c=window:typeof it<"u"?c=it:typeof self<"u"?c=self:c={};var y=c.location||{};h=h||y;var m={},R=typeof h,S;if(h.protocol==="blob:")m=new O(unescape(h.pathname),{});else if(R==="string"){m=new O(h,{});for(S in _)delete m[S]}else if(R==="object"){for(S in h)S in _||(m[S]=h[S]);m.slashes===void 0&&(m.slashes=o.test(h.href))}return m}function E(h){return h==="file:"||h==="ftp:"||h==="http:"||h==="https:"||h==="ws:"||h==="wss:"}function x(h,c){h=p(h),h=h.replace(n,""),c=c||{};var y=s.exec(h),m=y[1]?y[1].toLowerCase():"",R=!!y[2],S=!!y[3],k=0,C;return R?S?(C=y[2]+y[3]+y[4],k=y[2].length+y[3].length):(C=y[2]+y[4],k=y[2].length):S?(C=y[3]+y[4],k=y[3].length):C=y[4],m==="file:"?k>=2&&(C=C.slice(2)):E(m)?C=y[4]:m?R&&(C=C.slice(2)):k>=2&&E(c.protocol)&&(C=y[4]),{protocol:m,slashes:R||E(m),slashesCount:k,rest:C}}function I(h,c){if(h==="")return c;for(var y=(c||"/").split("/").slice(0,-1).concat(h.split("/")),m=y.length,R=y[m-1],S=!1,k=0;m--;)y[m]==="."?y.splice(m,1):y[m]===".."?(y.splice(m,1),k++):k&&(m===0&&(S=!0),y.splice(m,1),k--);return S&&y.unshift(""),(R==="."||R==="..")&&y.push(""),y.join("/")}function O(h,c,y){if(h=p(h),h=h.replace(n,""),!(this instanceof O))return new O(h,c,y);var m,R,S,k,C,N,M=d.slice(),X=typeof c,U=this,H=0;for(X!=="object"&&X!=="string"&&(y=c,c=null),y&&typeof y!="function"&&(y=e.parse),c=P(c),R=x(h||"",c),m=!R.protocol&&!R.slashes,U.slashes=R.slashes||m&&c.slashes,U.protocol=R.protocol||c.protocol||"",h=R.rest,(R.protocol==="file:"&&(R.slashesCount!==2||f.test(h))||!R.slashes&&(R.protocol||R.slashesCount<2||!E(U.protocol)))&&(M[3]=[/(.*)/,"pathname"]);H<M.length;H++){if(k=M[H],typeof k=="function"){h=k(h,U);continue}S=k[0],N=k[1],S!==S?U[N]=h:typeof S=="string"?(C=S==="@"?h.lastIndexOf(S):h.indexOf(S),~C&&(typeof k[2]=="number"?(U[N]=h.slice(0,C),h=h.slice(C+k[2])):(U[N]=h.slice(C),h=h.slice(0,C)))):(C=S.exec(h))&&(U[N]=C[1],h=h.slice(0,C.index)),U[N]=U[N]||m&&k[3]&&c[N]||"",k[4]&&(U[N]=U[N].toLowerCase())}y&&(U.query=y(U.query)),m&&c.slashes&&U.pathname.charAt(0)!=="/"&&(U.pathname!==""||c.pathname!=="")&&(U.pathname=I(U.pathname,c.pathname)),U.pathname.charAt(0)!=="/"&&E(U.protocol)&&(U.pathname="/"+U.pathname),t(U.port,U.protocol)||(U.host=U.hostname,U.port=""),U.username=U.password="",U.auth&&(C=U.auth.indexOf(":"),~C?(U.username=U.auth.slice(0,C),U.username=encodeURIComponent(decodeURIComponent(U.username)),U.password=U.auth.slice(C+1),U.password=encodeURIComponent(decodeURIComponent(U.password))):U.username=encodeURIComponent(decodeURIComponent(U.auth)),U.auth=U.password?U.username+":"+U.password:U.username),U.origin=U.protocol!=="file:"&&E(U.protocol)&&U.host?U.protocol+"//"+U.host:"null",U.href=U.toString()}function A(h,c,y){var m=this;switch(h){case"query":typeof c=="string"&&c.length&&(c=(y||e.parse)(c)),m[h]=c;break;case"port":m[h]=c,t(c,m.protocol)?c&&(m.host=m.hostname+":"+c):(m.host=m.hostname,m[h]="");break;case"hostname":m[h]=c,m.port&&(c+=":"+m.port),m.host=c;break;case"host":m[h]=c,i.test(c)?(c=c.split(":"),m.port=c.pop(),m.hostname=c.join(":")):(m.hostname=c,m.port="");break;case"protocol":m.protocol=c.toLowerCase(),m.slashes=!y;break;case"pathname":case"hash":if(c){var R=h==="pathname"?"/":"#";m[h]=c.charAt(0)!==R?R+c:c}else m[h]=c;break;case"username":case"password":m[h]=encodeURIComponent(c);break;case"auth":var S=c.indexOf(":");~S?(m.username=c.slice(0,S),m.username=encodeURIComponent(decodeURIComponent(m.username)),m.password=c.slice(S+1),m.password=encodeURIComponent(decodeURIComponent(m.password))):m.username=encodeURIComponent(decodeURIComponent(c))}for(var k=0;k<d.length;k++){var C=d[k];C[4]&&(m[C[1]]=m[C[1]].toLowerCase())}return m.auth=m.password?m.username+":"+m.password:m.username,m.origin=m.protocol!=="file:"&&E(m.protocol)&&m.host?m.protocol+"//"+m.host:"null",m.href=m.toString(),m}function w(h){(!h||typeof h!="function")&&(h=e.stringify);var c,y=this,m=y.host,R=y.protocol;R&&R.charAt(R.length-1)!==":"&&(R+=":");var S=R+(y.protocol&&y.slashes||E(y.protocol)?"//":"");return y.username?(S+=y.username,y.password&&(S+=":"+y.password),S+="@"):y.password?(S+=":"+y.password,S+="@"):y.protocol!=="file:"&&E(y.protocol)&&!m&&y.pathname!=="/"&&(S+="@"),(m[m.length-1]===":"||i.test(y.hostname)&&!y.port)&&(m+=":"),S+=m+y.pathname,c=typeof y.query=="object"?h(y.query):y.query,c&&(S+=c.charAt(0)!=="?"?"?"+c:c),y.hash&&(S+=y.hash),S}return O.prototype={set:A,toString:w},O.extractProtocol=x,O.location=P,O.trimLeft=p,O.qs=e,Le=O,Le}var Fn=Dn();const Nn=we(Fn);function qn(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){var e=Math.random()*16|0,r=t==="x"?e:e&3|8;return r.toString(16)})}function Be(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */Be=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(l,a,u){l[a]=u.value},i=typeof Symbol=="function"?Symbol:{},s=i.iterator||"@@iterator",f=i.asyncIterator||"@@asyncIterator",p=i.toStringTag||"@@toStringTag";function d(l,a,u){return Object.defineProperty(l,a,{value:u,enumerable:!0,configurable:!0,writable:!0}),l[a]}try{d({},"")}catch{d=function(u,v,b){return u[v]=b}}function _(l,a,u,v){var b=a&&a.prototype instanceof w?a:w,g=Object.create(b.prototype),T=new H(v||[]);return o(g,"_invoke",{value:N(l,u,T)}),g}function P(l,a,u){try{return{type:"normal",arg:l.call(a,u)}}catch(v){return{type:"throw",arg:v}}}e.wrap=_;var E="suspendedStart",x="suspendedYield",I="executing",O="completed",A={};function w(){}function h(){}function c(){}var y={};d(y,s,function(){return this});var m=Object.getPrototypeOf,R=m&&m(m(K([])));R&&R!==r&&n.call(R,s)&&(y=R);var S=c.prototype=w.prototype=Object.create(y);function k(l){["next","throw","return"].forEach(function(a){d(l,a,function(u){return this._invoke(a,u)})})}function C(l,a){function u(b,g,T,L){var j=P(l[b],l,g);if(j.type!=="throw"){var q=j.arg,D=q.value;return D&&V(D)=="object"&&n.call(D,"__await")?a.resolve(D.__await).then(function(z){u("next",z,T,L)},function(z){u("throw",z,T,L)}):a.resolve(D).then(function(z){q.value=z,T(q)},function(z){return u("throw",z,T,L)})}L(j.arg)}var v;o(this,"_invoke",{value:function(g,T){function L(){return new a(function(j,q){u(g,T,j,q)})}return v=v?v.then(L,L):L()}})}function N(l,a,u){var v=E;return function(b,g){if(v===I)throw Error("Generator is already running");if(v===O){if(b==="throw")throw g;return{value:t,done:!0}}for(u.method=b,u.arg=g;;){var T=u.delegate;if(T){var L=M(T,u);if(L){if(L===A)continue;return L}}if(u.method==="next")u.sent=u._sent=u.arg;else if(u.method==="throw"){if(v===E)throw v=O,u.arg;u.dispatchException(u.arg)}else u.method==="return"&&u.abrupt("return",u.arg);v=I;var j=P(l,a,u);if(j.type==="normal"){if(v=u.done?O:x,j.arg===A)continue;return{value:j.arg,done:u.done}}j.type==="throw"&&(v=O,u.method="throw",u.arg=j.arg)}}}function M(l,a){var u=a.method,v=l.iterator[u];if(v===t)return a.delegate=null,u==="throw"&&l.iterator.return&&(a.method="return",a.arg=t,M(l,a),a.method==="throw")||u!=="return"&&(a.method="throw",a.arg=new TypeError("The iterator does not provide a '"+u+"' method")),A;var b=P(v,l.iterator,a.arg);if(b.type==="throw")return a.method="throw",a.arg=b.arg,a.delegate=null,A;var g=b.arg;return g?g.done?(a[l.resultName]=g.value,a.next=l.nextLoc,a.method!=="return"&&(a.method="next",a.arg=t),a.delegate=null,A):g:(a.method="throw",a.arg=new TypeError("iterator result is not an object"),a.delegate=null,A)}function X(l){var a={tryLoc:l[0]};1 in l&&(a.catchLoc=l[1]),2 in l&&(a.finallyLoc=l[2],a.afterLoc=l[3]),this.tryEntries.push(a)}function U(l){var a=l.completion||{};a.type="normal",delete a.arg,l.completion=a}function H(l){this.tryEntries=[{tryLoc:"root"}],l.forEach(X,this),this.reset(!0)}function K(l){if(l||l===""){var a=l[s];if(a)return a.call(l);if(typeof l.next=="function")return l;if(!isNaN(l.length)){var u=-1,v=function b(){for(;++u<l.length;)if(n.call(l,u))return b.value=l[u],b.done=!1,b;return b.value=t,b.done=!0,b};return v.next=v}}throw new TypeError(V(l)+" is not iterable")}return h.prototype=c,o(S,"constructor",{value:c,configurable:!0}),o(c,"constructor",{value:h,configurable:!0}),h.displayName=d(c,p,"GeneratorFunction"),e.isGeneratorFunction=function(l){var a=typeof l=="function"&&l.constructor;return!!a&&(a===h||(a.displayName||a.name)==="GeneratorFunction")},e.mark=function(l){return Object.setPrototypeOf?Object.setPrototypeOf(l,c):(l.__proto__=c,d(l,p,"GeneratorFunction")),l.prototype=Object.create(S),l},e.awrap=function(l){return{__await:l}},k(C.prototype),d(C.prototype,f,function(){return this}),e.AsyncIterator=C,e.async=function(l,a,u,v,b){b===void 0&&(b=Promise);var g=new C(_(l,a,u,v),b);return e.isGeneratorFunction(a)?g:g.next().then(function(T){return T.done?T.value:g.next()})},k(S),d(S,p,"Generator"),d(S,s,function(){return this}),d(S,"toString",function(){return"[object Generator]"}),e.keys=function(l){var a=Object(l),u=[];for(var v in a)u.push(v);return u.reverse(),function b(){for(;u.length;){var g=u.pop();if(g in a)return b.value=g,b.done=!1,b}return b.done=!0,b}},e.values=K,H.prototype={constructor:H,reset:function(a){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(U),!a)for(var u in this)u.charAt(0)==="t"&&n.call(this,u)&&!isNaN(+u.slice(1))&&(this[u]=t)},stop:function(){this.done=!0;var a=this.tryEntries[0].completion;if(a.type==="throw")throw a.arg;return this.rval},dispatchException:function(a){if(this.done)throw a;var u=this;function v(q,D){return T.type="throw",T.arg=a,u.next=q,D&&(u.method="next",u.arg=t),!!D}for(var b=this.tryEntries.length-1;b>=0;--b){var g=this.tryEntries[b],T=g.completion;if(g.tryLoc==="root")return v("end");if(g.tryLoc<=this.prev){var L=n.call(g,"catchLoc"),j=n.call(g,"finallyLoc");if(L&&j){if(this.prev<g.catchLoc)return v(g.catchLoc,!0);if(this.prev<g.finallyLoc)return v(g.finallyLoc)}else if(L){if(this.prev<g.catchLoc)return v(g.catchLoc,!0)}else{if(!j)throw Error("try statement without catch or finally");if(this.prev<g.finallyLoc)return v(g.finallyLoc)}}}},abrupt:function(a,u){for(var v=this.tryEntries.length-1;v>=0;--v){var b=this.tryEntries[v];if(b.tryLoc<=this.prev&&n.call(b,"finallyLoc")&&this.prev<b.finallyLoc){var g=b;break}}g&&(a==="break"||a==="continue")&&g.tryLoc<=u&&u<=g.finallyLoc&&(g=null);var T=g?g.completion:{};return T.type=a,T.arg=u,g?(this.method="next",this.next=g.finallyLoc,A):this.complete(T)},complete:function(a,u){if(a.type==="throw")throw a.arg;return a.type==="break"||a.type==="continue"?this.next=a.arg:a.type==="return"?(this.rval=this.arg=a.arg,this.method="return",this.next="end"):a.type==="normal"&&u&&(this.next=u),A},finish:function(a){for(var u=this.tryEntries.length-1;u>=0;--u){var v=this.tryEntries[u];if(v.finallyLoc===a)return this.complete(v.completion,v.afterLoc),U(v),A}},catch:function(a){for(var u=this.tryEntries.length-1;u>=0;--u){var v=this.tryEntries[u];if(v.tryLoc===a){var b=v.completion;if(b.type==="throw"){var g=b.arg;U(v)}return g}}throw Error("illegal catch attempt")},delegateYield:function(a,u,v){return this.delegate={iterator:K(a),resultName:u,nextLoc:v},this.method==="next"&&(this.arg=t),A}},e}function Pt(t,e,r,n,o,i,s){try{var f=t[i](s),p=f.value}catch(d){r(d);return}f.done?e(p):Promise.resolve(p).then(n,o)}function zn(t){return function(){var e=this,r=arguments;return new Promise(function(n,o){var i=t.apply(e,r);function s(p){Pt(i,n,o,s,f,"next",p)}function f(p){Pt(i,n,o,s,f,"throw",p)}s(void 0)})}}function ur(t,e){return Mn(t)||Hn(t,e)||lr(t,e)||Bn()}function Bn(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Hn(t,e){var r=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(r!=null){var n,o,i,s,f=[],p=!0,d=!1;try{if(i=(r=r.call(t)).next,e!==0)for(;!(p=(n=i.call(r)).done)&&(f.push(n.value),f.length!==e);p=!0);}catch(_){d=!0,o=_}finally{try{if(!p&&r.return!=null&&(s=r.return(),Object(s)!==s))return}finally{if(d)throw o}}return f}}function Mn(t){if(Array.isArray(t))return t}function V(t){"@babel/helpers - typeof";return V=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},V(t)}function $n(t,e){var r=typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=lr(t))||e){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(d){throw d},f:o}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var i=!0,s=!1,f;return{s:function(){r=r.call(t)},n:function(){var d=r.next();return i=d.done,d},e:function(d){s=!0,f=d},f:function(){try{!i&&r.return!=null&&r.return()}finally{if(s)throw f}}}}function lr(t,e){if(t){if(typeof t=="string")return Ot(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);if(r==="Object"&&t.constructor&&(r=t.constructor.name),r==="Map"||r==="Set")return Array.from(t);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return Ot(t,e)}}function Ot(t,e){(e==null||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function xt(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),r.push.apply(r,n)}return r}function Y(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?xt(Object(r),!0).forEach(function(n){Gn(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):xt(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function Gn(t,e,r){return e=fr(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Kn(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function Ct(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,fr(n.key),n)}}function Vn(t,e,r){return e&&Ct(t.prototype,e),r&&Ct(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function fr(t){var e=Wn(t,"string");return V(e)=="symbol"?e:e+""}function Wn(t,e){if(V(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e);if(V(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}var ve="tus-v1",ge="ietf-draft-03",ie="ietf-draft-05",Xn={endpoint:null,uploadUrl:null,metadata:{},metadataForPartialUploads:{},fingerprint:null,uploadSize:null,onProgress:null,onChunkComplete:null,onSuccess:null,onError:null,onUploadUrlAvailable:null,overridePatchMethod:!1,headers:{},addRequestId:!1,onBeforeRequest:null,onAfterResponse:null,onShouldRetry:cr,chunkSize:Number.POSITIVE_INFINITY,retryDelays:[0,1e3,3e3,5e3],parallelUploads:1,parallelUploadBoundaries:null,storeFingerprintForResuming:!0,removeFingerprintOnSuccess:!1,uploadLengthDeferred:!1,uploadDataDuringCreation:!1,urlStorage:null,fileReader:null,httpStack:null,protocol:ve},be=(function(){function t(e,r){Kn(this,t),"resume"in r&&console.log("tus: The `resume` option has been removed in tus-js-client v2. Please use the URL storage API instead."),this.options=r,this.options.chunkSize=Number(this.options.chunkSize),this._urlStorage=this.options.urlStorage,this.file=e,this.url=null,this._req=null,this._fingerprint=null,this._urlStorageKey=null,this._offset=null,this._aborted=!1,this._size=null,this._source=null,this._retryAttempt=0,this._retryTimeout=null,this._offsetBeforeRetry=0,this._parallelUploads=null,this._parallelUploadUrls=null}return Vn(t,[{key:"findPreviousUploads",value:function(){var r=this;return this.options.fingerprint(this.file,this.options).then(function(n){return r._urlStorage.findUploadsByFingerprint(n)})}},{key:"resumeFromPreviousUpload",value:function(r){this.url=r.uploadUrl||null,this._parallelUploadUrls=r.parallelUploadUrls||null,this._urlStorageKey=r.urlStorageKey}},{key:"start",value:function(){var r=this,n=this.file;if(!n){this._emitError(new Error("tus: no file or stream to upload provided"));return}if(![ve,ge,ie].includes(this.options.protocol)){this._emitError(new Error("tus: unsupported protocol ".concat(this.options.protocol)));return}if(!this.options.endpoint&&!this.options.uploadUrl&&!this.url){this._emitError(new Error("tus: neither an endpoint or an upload URL is provided"));return}var o=this.options.retryDelays;if(o!=null&&Object.prototype.toString.call(o)!=="[object Array]"){this._emitError(new Error("tus: the `retryDelays` option must either be an array or null"));return}if(this.options.parallelUploads>1)for(var i=0,s=["uploadUrl","uploadSize","uploadLengthDeferred"];i<s.length;i++){var f=s[i];if(this.options[f]){this._emitError(new Error("tus: cannot use the ".concat(f," option when parallelUploads is enabled")));return}}if(this.options.parallelUploadBoundaries){if(this.options.parallelUploads<=1){this._emitError(new Error("tus: cannot use the `parallelUploadBoundaries` option when `parallelUploads` is disabled"));return}if(this.options.parallelUploads!==this.options.parallelUploadBoundaries.length){this._emitError(new Error("tus: the `parallelUploadBoundaries` must have the same length as the value of `parallelUploads`"));return}}this.options.fingerprint(n,this.options).then(function(p){return r._fingerprint=p,r._source?r._source:r.options.fileReader.openFile(n,r.options.chunkSize)}).then(function(p){if(r._source=p,r.options.uploadLengthDeferred)r._size=null;else if(r.options.uploadSize!=null){if(r._size=Number(r.options.uploadSize),Number.isNaN(r._size)){r._emitError(new Error("tus: cannot convert `uploadSize` option into a number"));return}}else if(r._size=r._source.size,r._size==null){r._emitError(new Error("tus: cannot automatically derive upload's size from input. Specify it manually using the `uploadSize` option or use the `uploadLengthDeferred` option"));return}r.options.parallelUploads>1||r._parallelUploadUrls!=null?r._startParallelUpload():r._startSingleUpload()}).catch(function(p){r._emitError(p)})}},{key:"_startParallelUpload",value:function(){var r,n=this,o=this._size,i=0;this._parallelUploads=[];var s=this._parallelUploadUrls!=null?this._parallelUploadUrls.length:this.options.parallelUploads,f=(r=this.options.parallelUploadBoundaries)!==null&&r!==void 0?r:Qn(this._source.size,s);this._parallelUploadUrls&&f.forEach(function(_,P){_.uploadUrl=n._parallelUploadUrls[P]||null}),this._parallelUploadUrls=new Array(f.length);var p=f.map(function(_,P){var E=0;return n._source.slice(_.start,_.end).then(function(x){var I=x.value;return new Promise(function(O,A){var w=Y(Y({},n.options),{},{uploadUrl:_.uploadUrl||null,storeFingerprintForResuming:!1,removeFingerprintOnSuccess:!1,parallelUploads:1,parallelUploadBoundaries:null,metadata:n.options.metadataForPartialUploads,headers:Y(Y({},n.options.headers),{},{"Upload-Concat":"partial"}),onSuccess:O,onError:A,onProgress:function(y){i=i-E+y,E=y,n._emitProgress(i,o)},onUploadUrlAvailable:function(){n._parallelUploadUrls[P]=h.url,n._parallelUploadUrls.filter(function(y){return!!y}).length===f.length&&n._saveUploadInUrlStorage()}}),h=new t(I,w);h.start(),n._parallelUploads.push(h)})})}),d;Promise.all(p).then(function(){d=n._openRequest("POST",n.options.endpoint),d.setHeader("Upload-Concat","final;".concat(n._parallelUploadUrls.join(" ")));var _=Tt(n.options.metadata);return _!==""&&d.setHeader("Upload-Metadata",_),n._sendRequest(d,null)}).then(function(_){if(!Z(_.getStatus(),200)){n._emitHttpError(d,_,"tus: unexpected response while creating upload");return}var P=_.getHeader("Location");if(P==null){n._emitHttpError(d,_,"tus: invalid or missing Location header");return}n.url=Lt(n.options.endpoint,P),"Created upload at ".concat(n.url),n._emitSuccess(_)}).catch(function(_){n._emitError(_)})}},{key:"_startSingleUpload",value:function(){if(this._aborted=!1,this.url!=null){"Resuming upload from previous URL: ".concat(this.url),this._resumeUpload();return}if(this.options.uploadUrl!=null){"Resuming upload from provided URL: ".concat(this.options.uploadUrl),this.url=this.options.uploadUrl,this._resumeUpload();return}this._createUpload()}},{key:"abort",value:function(r){var n=this;if(this._parallelUploads!=null){var o=$n(this._parallelUploads),i;try{for(o.s();!(i=o.n()).done;){var s=i.value;s.abort(r)}}catch(f){o.e(f)}finally{o.f()}}return this._req!==null&&this._req.abort(),this._aborted=!0,this._retryTimeout!=null&&(clearTimeout(this._retryTimeout),this._retryTimeout=null),!r||this.url==null?Promise.resolve():t.terminate(this.url,this.options).then(function(){return n._removeFromUrlStorage()})}},{key:"_emitHttpError",value:function(r,n,o,i){this._emitError(new he(o,i,r,n))}},{key:"_emitError",value:function(r){var n=this;if(!this._aborted){if(this.options.retryDelays!=null){var o=this._offset!=null&&this._offset>this._offsetBeforeRetry;if(o&&(this._retryAttempt=0),It(r,this._retryAttempt,this.options)){var i=this.options.retryDelays[this._retryAttempt++];this._offsetBeforeRetry=this._offset,this._retryTimeout=setTimeout(function(){n.start()},i);return}}if(typeof this.options.onError=="function")this.options.onError(r);else throw r}}},{key:"_emitSuccess",value:function(r){this.options.removeFingerprintOnSuccess&&this._removeFromUrlStorage(),typeof this.options.onSuccess=="function"&&this.options.onSuccess({lastResponse:r})}},{key:"_emitProgress",value:function(r,n){typeof this.options.onProgress=="function"&&this.options.onProgress(r,n)}},{key:"_emitChunkComplete",value:function(r,n,o){typeof this.options.onChunkComplete=="function"&&this.options.onChunkComplete(r,n,o)}},{key:"_createUpload",value:function(){var r=this;if(!this.options.endpoint){this._emitError(new Error("tus: unable to create upload because no endpoint is provided"));return}var n=this._openRequest("POST",this.options.endpoint);this.options.uploadLengthDeferred?n.setHeader("Upload-Defer-Length","1"):n.setHeader("Upload-Length","".concat(this._size));var o=Tt(this.options.metadata);o!==""&&n.setHeader("Upload-Metadata",o);var i;this.options.uploadDataDuringCreation&&!this.options.uploadLengthDeferred?(this._offset=0,i=this._addChunkToRequest(n)):((this.options.protocol===ge||this.options.protocol===ie)&&n.setHeader("Upload-Complete","?0"),i=this._sendRequest(n,null)),i.then(function(s){if(!Z(s.getStatus(),200)){r._emitHttpError(n,s,"tus: unexpected response while creating upload");return}var f=s.getHeader("Location");if(f==null){r._emitHttpError(n,s,"tus: invalid or missing Location header");return}if(r.url=Lt(r.options.endpoint,f),"Created upload at ".concat(r.url),typeof r.options.onUploadUrlAvailable=="function"&&r.options.onUploadUrlAvailable(),r._size===0){r._emitSuccess(s),r._source.close();return}r._saveUploadInUrlStorage().then(function(){r.options.uploadDataDuringCreation?r._handleUploadResponse(n,s):(r._offset=0,r._performUpload())})}).catch(function(s){r._emitHttpError(n,null,"tus: failed to create upload",s)})}},{key:"_resumeUpload",value:function(){var r=this,n=this._openRequest("HEAD",this.url),o=this._sendRequest(n,null);o.then(function(i){var s=i.getStatus();if(!Z(s,200)){if(s===423){r._emitHttpError(n,i,"tus: upload is currently locked; retry later");return}if(Z(s,400)&&r._removeFromUrlStorage(),!r.options.endpoint){r._emitHttpError(n,i,"tus: unable to resume upload (new upload cannot be created without an endpoint)");return}r.url=null,r._createUpload();return}var f=Number.parseInt(i.getHeader("Upload-Offset"),10);if(Number.isNaN(f)){r._emitHttpError(n,i,"tus: invalid or missing offset value");return}var p=Number.parseInt(i.getHeader("Upload-Length"),10);if(Number.isNaN(p)&&!r.options.uploadLengthDeferred&&r.options.protocol===ve){r._emitHttpError(n,i,"tus: invalid or missing length value");return}typeof r.options.onUploadUrlAvailable=="function"&&r.options.onUploadUrlAvailable(),r._saveUploadInUrlStorage().then(function(){if(f===p){r._emitProgress(p,p),r._emitSuccess(i);return}r._offset=f,r._performUpload()})}).catch(function(i){r._emitHttpError(n,null,"tus: failed to resume upload",i)})}},{key:"_performUpload",value:function(){var r=this;if(!this._aborted){var n;this.options.overridePatchMethod?(n=this._openRequest("POST",this.url),n.setHeader("X-HTTP-Method-Override","PATCH")):n=this._openRequest("PATCH",this.url),n.setHeader("Upload-Offset","".concat(this._offset));var o=this._addChunkToRequest(n);o.then(function(i){if(!Z(i.getStatus(),200)){r._emitHttpError(n,i,"tus: unexpected response while uploading chunk");return}r._handleUploadResponse(n,i)}).catch(function(i){r._aborted||r._emitHttpError(n,null,"tus: failed to upload chunk at offset ".concat(r._offset),i)})}}},{key:"_addChunkToRequest",value:function(r){var n=this,o=this._offset,i=this._offset+this.options.chunkSize;return r.setProgressHandler(function(s){n._emitProgress(o+s,n._size)}),this.options.protocol===ve?r.setHeader("Content-Type","application/offset+octet-stream"):this.options.protocol===ie&&r.setHeader("Content-Type","application/partial-upload"),(i===Number.POSITIVE_INFINITY||i>this._size)&&!this.options.uploadLengthDeferred&&(i=this._size),this._source.slice(o,i).then(function(s){var f=s.value,p=s.done,d=f!=null&&f.size?f.size:0;n.options.uploadLengthDeferred&&p&&(n._size=n._offset+d,r.setHeader("Upload-Length","".concat(n._size)));var _=n._offset+d;return!n.options.uploadLengthDeferred&&p&&_!==n._size?Promise.reject(new Error("upload was configured with a size of ".concat(n._size," bytes, but the source is done after ").concat(_," bytes"))):f===null?n._sendRequest(r):((n.options.protocol===ge||n.options.protocol===ie)&&r.setHeader("Upload-Complete",p?"?1":"?0"),n._emitProgress(n._offset,n._size),n._sendRequest(r,f))})}},{key:"_handleUploadResponse",value:function(r,n){var o=Number.parseInt(n.getHeader("Upload-Offset"),10);if(Number.isNaN(o)){this._emitHttpError(r,n,"tus: invalid or missing offset value");return}if(this._emitProgress(o,this._size),this._emitChunkComplete(o-this._offset,o,this._size),this._offset=o,o===this._size){this._emitSuccess(n),this._source.close();return}this._performUpload()}},{key:"_openRequest",value:function(r,n){var o=kt(r,n,this.options);return this._req=o,o}},{key:"_removeFromUrlStorage",value:function(){var r=this;this._urlStorageKey&&(this._urlStorage.removeUpload(this._urlStorageKey).catch(function(n){r._emitError(n)}),this._urlStorageKey=null)}},{key:"_saveUploadInUrlStorage",value:function(){var r=this;if(!this.options.storeFingerprintForResuming||!this._fingerprint||this._urlStorageKey!==null)return Promise.resolve();var n={size:this._size,metadata:this.options.metadata,creationTime:new Date().toString()};return this._parallelUploads?n.parallelUploadUrls=this._parallelUploadUrls:n.uploadUrl=this.url,this._urlStorage.addUpload(this._fingerprint,n).then(function(o){r._urlStorageKey=o})}},{key:"_sendRequest",value:function(r){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null;return At(r,n,this.options)}}],[{key:"terminate",value:function(r){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=kt("DELETE",r,n);return At(o,null,n).then(function(i){if(i.getStatus()!==204)throw new he("tus: unexpected response while terminating upload",null,o,i)}).catch(function(i){if(i instanceof he||(i=new he("tus: failed to terminate upload",i,o,null)),!It(i,0,n))throw i;var s=n.retryDelays[0],f=n.retryDelays.slice(1),p=Y(Y({},n),{},{retryDelays:f});return new Promise(function(d){return setTimeout(d,s)}).then(function(){return t.terminate(r,p)})})}}])})();function Tt(t){return Object.entries(t).map(function(e){var r=ur(e,2),n=r[0],o=r[1];return"".concat(n," ").concat(In.encode(String(o)))}).join(",")}function Z(t,e){return t>=e&&t<e+100}function kt(t,e,r){var n=r.httpStack.createRequest(t,e);r.protocol===ge?n.setHeader("Upload-Draft-Interop-Version","5"):r.protocol===ie?n.setHeader("Upload-Draft-Interop-Version","6"):n.setHeader("Tus-Resumable","1.0.0");for(var o=r.headers||{},i=0,s=Object.entries(o);i<s.length;i++){var f=ur(s[i],2),p=f[0],d=f[1];n.setHeader(p,d)}if(r.addRequestId){var _=qn();n.setHeader("X-Request-ID",_)}return n}function At(t,e,r){return He.apply(this,arguments)}function He(){return He=zn(Be().mark(function t(e,r,n){var o;return Be().wrap(function(s){for(;;)switch(s.prev=s.next){case 0:if(typeof n.onBeforeRequest!="function"){s.next=3;break}return s.next=3,n.onBeforeRequest(e);case 3:return s.next=5,e.send(r);case 5:if(o=s.sent,typeof n.onAfterResponse!="function"){s.next=9;break}return s.next=9,n.onAfterResponse(e,o);case 9:return s.abrupt("return",o);case 10:case"end":return s.stop()}},t)})),He.apply(this,arguments)}function Yn(){var t=!0;return typeof navigator<"u"&&navigator.onLine===!1&&(t=!1),t}function It(t,e,r){return r.retryDelays==null||e>=r.retryDelays.length||t.originalRequest==null?!1:r&&typeof r.onShouldRetry=="function"?r.onShouldRetry(t,e,r):cr(t)}function cr(t){var e=t.originalResponse?t.originalResponse.getStatus():0;return(!Z(e,400)||e===409||e===423)&&Yn()}function Lt(t,e){return new Nn(e,t).toString()}function Qn(t,e){for(var r=Math.floor(t/e),n=[],o=0;o<e;o++)n.push({start:r*o,end:r*(o+1)});return n[e-1].end=t,n}be.defaultOptions=Xn;var pr=function(){return typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative"};function Zn(t){return new Promise(function(e,r){var n=new XMLHttpRequest;n.responseType="blob",n.onload=function(){var o=n.response;e(o)},n.onerror=function(o){r(o)},n.open("GET",t),n.send()})}var Jn=function(){return typeof window<"u"&&(typeof window.PhoneGap<"u"||typeof window.Cordova<"u"||typeof window.cordova<"u")};function eo(t){return new Promise(function(e,r){var n=new FileReader;n.onload=function(){var o=new Uint8Array(n.result);e({value:o})},n.onerror=function(o){r(o)},n.readAsArrayBuffer(t)})}function le(t){"@babel/helpers - typeof";return le=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},le(t)}function to(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function ro(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,oo(n.key),n)}}function no(t,e,r){return e&&ro(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}function oo(t){var e=io(t,"string");return le(e)=="symbol"?e:e+""}function io(t,e){if(le(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e);if(le(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}var jt=(function(){function t(e){to(this,t),this._file=e,this.size=e.size}return no(t,[{key:"slice",value:function(r,n){if(Jn())return eo(this._file.slice(r,n));var o=this._file.slice(r,n),i=n>=this.size;return Promise.resolve({value:o,done:i})}},{key:"close",value:function(){}}])})();function fe(t){"@babel/helpers - typeof";return fe=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},fe(t)}function ao(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function so(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,lo(n.key),n)}}function uo(t,e,r){return e&&so(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}function lo(t){var e=fo(t,"string");return fe(e)=="symbol"?e:e+""}function fo(t,e){if(fe(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e);if(fe(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}function Dt(t){return t===void 0?0:t.size!==void 0?t.size:t.length}function co(t,e){if(t.concat)return t.concat(e);if(t instanceof Blob)return new Blob([t,e],{type:t.type});if(t.set){var r=new t.constructor(t.length+e.length);return r.set(t),r.set(e,t.length),r}throw new Error("Unknown data type")}var po=(function(){function t(e){ao(this,t),this._buffer=void 0,this._bufferOffset=0,this._reader=e,this._done=!1}return uo(t,[{key:"slice",value:function(r,n){return r<this._bufferOffset?Promise.reject(new Error("Requested data is before the reader's current offset")):this._readUntilEnoughDataOrDone(r,n)}},{key:"_readUntilEnoughDataOrDone",value:function(r,n){var o=this,i=n<=this._bufferOffset+Dt(this._buffer);if(this._done||i){var s=this._getDataFromBuffer(r,n),f=s==null?this._done:!1;return Promise.resolve({value:s,done:f})}return this._reader.read().then(function(p){var d=p.value,_=p.done;return _?o._done=!0:o._buffer===void 0?o._buffer=d:o._buffer=co(o._buffer,d),o._readUntilEnoughDataOrDone(r,n)})}},{key:"_getDataFromBuffer",value:function(r,n){r>this._bufferOffset&&(this._buffer=this._buffer.slice(r-this._bufferOffset),this._bufferOffset=r);var o=Dt(this._buffer)===0;return this._done&&o?null:this._buffer.slice(0,n-r)}},{key:"close",value:function(){this._reader.cancel&&this._reader.cancel()}}])})();function W(t){"@babel/helpers - typeof";return W=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},W(t)}function Me(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */Me=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(l,a,u){l[a]=u.value},i=typeof Symbol=="function"?Symbol:{},s=i.iterator||"@@iterator",f=i.asyncIterator||"@@asyncIterator",p=i.toStringTag||"@@toStringTag";function d(l,a,u){return Object.defineProperty(l,a,{value:u,enumerable:!0,configurable:!0,writable:!0}),l[a]}try{d({},"")}catch{d=function(u,v,b){return u[v]=b}}function _(l,a,u,v){var b=a&&a.prototype instanceof w?a:w,g=Object.create(b.prototype),T=new H(v||[]);return o(g,"_invoke",{value:N(l,u,T)}),g}function P(l,a,u){try{return{type:"normal",arg:l.call(a,u)}}catch(v){return{type:"throw",arg:v}}}e.wrap=_;var E="suspendedStart",x="suspendedYield",I="executing",O="completed",A={};function w(){}function h(){}function c(){}var y={};d(y,s,function(){return this});var m=Object.getPrototypeOf,R=m&&m(m(K([])));R&&R!==r&&n.call(R,s)&&(y=R);var S=c.prototype=w.prototype=Object.create(y);function k(l){["next","throw","return"].forEach(function(a){d(l,a,function(u){return this._invoke(a,u)})})}function C(l,a){function u(b,g,T,L){var j=P(l[b],l,g);if(j.type!=="throw"){var q=j.arg,D=q.value;return D&&W(D)=="object"&&n.call(D,"__await")?a.resolve(D.__await).then(function(z){u("next",z,T,L)},function(z){u("throw",z,T,L)}):a.resolve(D).then(function(z){q.value=z,T(q)},function(z){return u("throw",z,T,L)})}L(j.arg)}var v;o(this,"_invoke",{value:function(g,T){function L(){return new a(function(j,q){u(g,T,j,q)})}return v=v?v.then(L,L):L()}})}function N(l,a,u){var v=E;return function(b,g){if(v===I)throw Error("Generator is already running");if(v===O){if(b==="throw")throw g;return{value:t,done:!0}}for(u.method=b,u.arg=g;;){var T=u.delegate;if(T){var L=M(T,u);if(L){if(L===A)continue;return L}}if(u.method==="next")u.sent=u._sent=u.arg;else if(u.method==="throw"){if(v===E)throw v=O,u.arg;u.dispatchException(u.arg)}else u.method==="return"&&u.abrupt("return",u.arg);v=I;var j=P(l,a,u);if(j.type==="normal"){if(v=u.done?O:x,j.arg===A)continue;return{value:j.arg,done:u.done}}j.type==="throw"&&(v=O,u.method="throw",u.arg=j.arg)}}}function M(l,a){var u=a.method,v=l.iterator[u];if(v===t)return a.delegate=null,u==="throw"&&l.iterator.return&&(a.method="return",a.arg=t,M(l,a),a.method==="throw")||u!=="return"&&(a.method="throw",a.arg=new TypeError("The iterator does not provide a '"+u+"' method")),A;var b=P(v,l.iterator,a.arg);if(b.type==="throw")return a.method="throw",a.arg=b.arg,a.delegate=null,A;var g=b.arg;return g?g.done?(a[l.resultName]=g.value,a.next=l.nextLoc,a.method!=="return"&&(a.method="next",a.arg=t),a.delegate=null,A):g:(a.method="throw",a.arg=new TypeError("iterator result is not an object"),a.delegate=null,A)}function X(l){var a={tryLoc:l[0]};1 in l&&(a.catchLoc=l[1]),2 in l&&(a.finallyLoc=l[2],a.afterLoc=l[3]),this.tryEntries.push(a)}function U(l){var a=l.completion||{};a.type="normal",delete a.arg,l.completion=a}function H(l){this.tryEntries=[{tryLoc:"root"}],l.forEach(X,this),this.reset(!0)}function K(l){if(l||l===""){var a=l[s];if(a)return a.call(l);if(typeof l.next=="function")return l;if(!isNaN(l.length)){var u=-1,v=function b(){for(;++u<l.length;)if(n.call(l,u))return b.value=l[u],b.done=!1,b;return b.value=t,b.done=!0,b};return v.next=v}}throw new TypeError(W(l)+" is not iterable")}return h.prototype=c,o(S,"constructor",{value:c,configurable:!0}),o(c,"constructor",{value:h,configurable:!0}),h.displayName=d(c,p,"GeneratorFunction"),e.isGeneratorFunction=function(l){var a=typeof l=="function"&&l.constructor;return!!a&&(a===h||(a.displayName||a.name)==="GeneratorFunction")},e.mark=function(l){return Object.setPrototypeOf?Object.setPrototypeOf(l,c):(l.__proto__=c,d(l,p,"GeneratorFunction")),l.prototype=Object.create(S),l},e.awrap=function(l){return{__await:l}},k(C.prototype),d(C.prototype,f,function(){return this}),e.AsyncIterator=C,e.async=function(l,a,u,v,b){b===void 0&&(b=Promise);var g=new C(_(l,a,u,v),b);return e.isGeneratorFunction(a)?g:g.next().then(function(T){return T.done?T.value:g.next()})},k(S),d(S,p,"Generator"),d(S,s,function(){return this}),d(S,"toString",function(){return"[object Generator]"}),e.keys=function(l){var a=Object(l),u=[];for(var v in a)u.push(v);return u.reverse(),function b(){for(;u.length;){var g=u.pop();if(g in a)return b.value=g,b.done=!1,b}return b.done=!0,b}},e.values=K,H.prototype={constructor:H,reset:function(a){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(U),!a)for(var u in this)u.charAt(0)==="t"&&n.call(this,u)&&!isNaN(+u.slice(1))&&(this[u]=t)},stop:function(){this.done=!0;var a=this.tryEntries[0].completion;if(a.type==="throw")throw a.arg;return this.rval},dispatchException:function(a){if(this.done)throw a;var u=this;function v(q,D){return T.type="throw",T.arg=a,u.next=q,D&&(u.method="next",u.arg=t),!!D}for(var b=this.tryEntries.length-1;b>=0;--b){var g=this.tryEntries[b],T=g.completion;if(g.tryLoc==="root")return v("end");if(g.tryLoc<=this.prev){var L=n.call(g,"catchLoc"),j=n.call(g,"finallyLoc");if(L&&j){if(this.prev<g.catchLoc)return v(g.catchLoc,!0);if(this.prev<g.finallyLoc)return v(g.finallyLoc)}else if(L){if(this.prev<g.catchLoc)return v(g.catchLoc,!0)}else{if(!j)throw Error("try statement without catch or finally");if(this.prev<g.finallyLoc)return v(g.finallyLoc)}}}},abrupt:function(a,u){for(var v=this.tryEntries.length-1;v>=0;--v){var b=this.tryEntries[v];if(b.tryLoc<=this.prev&&n.call(b,"finallyLoc")&&this.prev<b.finallyLoc){var g=b;break}}g&&(a==="break"||a==="continue")&&g.tryLoc<=u&&u<=g.finallyLoc&&(g=null);var T=g?g.completion:{};return T.type=a,T.arg=u,g?(this.method="next",this.next=g.finallyLoc,A):this.complete(T)},complete:function(a,u){if(a.type==="throw")throw a.arg;return a.type==="break"||a.type==="continue"?this.next=a.arg:a.type==="return"?(this.rval=this.arg=a.arg,this.method="return",this.next="end"):a.type==="normal"&&u&&(this.next=u),A},finish:function(a){for(var u=this.tryEntries.length-1;u>=0;--u){var v=this.tryEntries[u];if(v.finallyLoc===a)return this.complete(v.completion,v.afterLoc),U(v),A}},catch:function(a){for(var u=this.tryEntries.length-1;u>=0;--u){var v=this.tryEntries[u];if(v.tryLoc===a){var b=v.completion;if(b.type==="throw"){var g=b.arg;U(v)}return g}}throw Error("illegal catch attempt")},delegateYield:function(a,u,v){return this.delegate={iterator:K(a),resultName:u,nextLoc:v},this.method==="next"&&(this.arg=t),A}},e}function Ft(t,e,r,n,o,i,s){try{var f=t[i](s),p=f.value}catch(d){r(d);return}f.done?e(p):Promise.resolve(p).then(n,o)}function ho(t){return function(){var e=this,r=arguments;return new Promise(function(n,o){var i=t.apply(e,r);function s(p){Ft(i,n,o,s,f,"next",p)}function f(p){Ft(i,n,o,s,f,"throw",p)}s(void 0)})}}function yo(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function mo(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,go(n.key),n)}}function vo(t,e,r){return e&&mo(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}function go(t){var e=bo(t,"string");return W(e)=="symbol"?e:e+""}function bo(t,e){if(W(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e);if(W(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}var _o=(function(){function t(){yo(this,t)}return vo(t,[{key:"openFile",value:(function(){var e=ho(Me().mark(function n(o,i){var s;return Me().wrap(function(p){for(;;)switch(p.prev=p.next){case 0:if(!(pr()&&o&&typeof o.uri<"u")){p.next=11;break}return p.prev=1,p.next=4,Zn(o.uri);case 4:return s=p.sent,p.abrupt("return",new jt(s));case 8:throw p.prev=8,p.t0=p.catch(1),new Error("tus: cannot fetch `file.uri` as Blob, make sure the uri is correct and accessible. ".concat(p.t0));case 11:if(!(typeof o.slice=="function"&&typeof o.size<"u")){p.next=13;break}return p.abrupt("return",Promise.resolve(new jt(o)));case 13:if(typeof o.read!="function"){p.next=18;break}if(i=Number(i),Number.isFinite(i)){p.next=17;break}return p.abrupt("return",Promise.reject(new Error("cannot create source for stream without a finite value for the `chunkSize` option")));case 17:return p.abrupt("return",Promise.resolve(new po(o,i)));case 18:return p.abrupt("return",Promise.reject(new Error("source object may only be an instance of File, Blob, or Reader in this environment")));case 19:case"end":return p.stop()}},n,null,[[1,8]])}));function r(n,o){return e.apply(this,arguments)}return r})()}])})();function wo(t,e){return pr()?Promise.resolve(Eo(t,e)):Promise.resolve(["tus-br",t.name,t.type,t.size,t.lastModified,e.endpoint].join("-"))}function Eo(t,e){var r=t.exif?So(JSON.stringify(t.exif)):"noexif";return["tus-rn",t.name||"noname",t.size||"nosize",r,e.endpoint].join("/")}function So(t){var e=0;if(t.length===0)return e;for(var r=0;r<t.length;r++){var n=t.charCodeAt(r);e=(e<<5)-e+n,e&=e}return e}function ce(t){"@babel/helpers - typeof";return ce=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},ce(t)}function nt(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function Uo(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Ro(n.key),n)}}function ot(t,e,r){return e&&Uo(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}function Ro(t){var e=Po(t,"string");return ce(e)=="symbol"?e:e+""}function Po(t,e){if(ce(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e);if(ce(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}var Oo=(function(){function t(){nt(this,t)}return ot(t,[{key:"createRequest",value:function(r,n){return new xo(r,n)}},{key:"getName",value:function(){return"XHRHttpStack"}}])})(),xo=(function(){function t(e,r){nt(this,t),this._xhr=new XMLHttpRequest,this._xhr.open(e,r,!0),this._method=e,this._url=r,this._headers={}}return ot(t,[{key:"getMethod",value:function(){return this._method}},{key:"getURL",value:function(){return this._url}},{key:"setHeader",value:function(r,n){this._xhr.setRequestHeader(r,n),this._headers[r]=n}},{key:"getHeader",value:function(r){return this._headers[r]}},{key:"setProgressHandler",value:function(r){"upload"in this._xhr&&(this._xhr.upload.onprogress=function(n){n.lengthComputable&&r(n.loaded)})}},{key:"send",value:function(){var r=this,n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:null;return new Promise(function(o,i){r._xhr.onload=function(){o(new Co(r._xhr))},r._xhr.onerror=function(s){i(s)},r._xhr.send(n)})}},{key:"abort",value:function(){return this._xhr.abort(),Promise.resolve()}},{key:"getUnderlyingObject",value:function(){return this._xhr}}])})(),Co=(function(){function t(e){nt(this,t),this._xhr=e}return ot(t,[{key:"getStatus",value:function(){return this._xhr.status}},{key:"getHeader",value:function(r){return this._xhr.getResponseHeader(r)}},{key:"getBody",value:function(){return this._xhr.responseText}},{key:"getUnderlyingObject",value:function(){return this._xhr}}])})();function pe(t){"@babel/helpers - typeof";return pe=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},pe(t)}function To(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function ko(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Io(n.key),n)}}function Ao(t,e,r){return e&&ko(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}function Io(t){var e=Lo(t,"string");return pe(e)=="symbol"?e:e+""}function Lo(t,e){if(pe(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e);if(pe(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}var $e=!1;try{$e="localStorage"in window;var je="tusSupport",Nt=localStorage.getItem(je);localStorage.setItem(je,Nt),Nt===null&&localStorage.removeItem(je)}catch(t){if(t.code===t.SECURITY_ERR||t.code===t.QUOTA_EXCEEDED_ERR)$e=!1;else throw t}var jo=$e,Do=(function(){function t(){To(this,t)}return Ao(t,[{key:"findAllUploads",value:function(){var r=this._findEntries("tus::");return Promise.resolve(r)}},{key:"findUploadsByFingerprint",value:function(r){var n=this._findEntries("tus::".concat(r,"::"));return Promise.resolve(n)}},{key:"removeUpload",value:function(r){return localStorage.removeItem(r),Promise.resolve()}},{key:"addUpload",value:function(r,n){var o=Math.round(Math.random()*1e12),i="tus::".concat(r,"::").concat(o);return localStorage.setItem(i,JSON.stringify(n)),Promise.resolve(i)}},{key:"_findEntries",value:function(r){for(var n=[],o=0;o<localStorage.length;o++){var i=localStorage.key(o);if(i.indexOf(r)===0)try{var s=JSON.parse(localStorage.getItem(i));s.urlStorageKey=i,n.push(s)}catch{}}return n}}])})();function re(t){"@babel/helpers - typeof";return re=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},re(t)}function Fo(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function No(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,dr(n.key),n)}}function qo(t,e,r){return r&&No(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function zo(t,e,r){return e=_e(e),Bo(t,hr()?Reflect.construct(e,r||[],_e(t).constructor):e.apply(t,r))}function Bo(t,e){if(e&&(re(e)==="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Ho(t)}function Ho(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function hr(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(hr=function(){return!!t})()}function _e(t){return _e=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},_e(t)}function Mo(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Ge(t,e)}function Ge(t,e){return Ge=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,o){return n.__proto__=o,n},Ge(t,e)}function qt(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),r.push.apply(r,n)}return r}function J(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?qt(Object(r),!0).forEach(function(n){$o(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):qt(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function $o(t,e,r){return e=dr(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function dr(t){var e=Go(t,"string");return re(e)=="symbol"?e:e+""}function Go(t,e){if(re(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e);if(re(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var zt=J(J({},be.defaultOptions),{},{httpStack:new Oo,fileReader:new _o,urlStorage:jo?new Do:new En,fingerprint:wo}),Ko=(function(t){function e(){var r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:null,n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return Fo(this,e),n=J(J({},zt),n),zo(this,e,[r,n])}return Mo(e,t),qo(e,null,[{key:"terminate",value:function(n){var o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return o=J(J({},zt),o),be.terminate(n,o)}}])})(be);class Se{constructor(e){this.upload=e}start(){this.upload.start()}abort(){return this.upload.abort(!0)}static async create(e,{onProgress:r,onSuccess:n,onError:o,uploadType:i,backendId:s,metadata:f,chunkSize:p,baseUrl:d}){const _=["tus",e.fingerprint,"drive"].join("-"),P=new Ko(e.native,{fingerprint:()=>Promise.resolve(_),removeFingerprintOnSuccess:!0,endpoint:`${d}/api/v1/tus/upload`,chunkSize:p,retryDelays:[0,3e3,5e3,1e4,2e4],overridePatchMethod:!0,metadata:{name:window.btoa(e.id),clientName:e.name,clientExtension:e.extension,clientMime:e.mime||"",clientSize:`${e.size}`,uploadType:i,backendId:s,...f},headers:{"X-XSRF-TOKEN":un.getCookie("XSRF-TOKEN")},onError:x=>{var I;if("originalResponse"in x&&x.originalResponse)try{const O=(I=JSON.parse(x.originalResponse.getBody()))==null?void 0:I.message;o==null||o(O,e)}catch{o==null||o(null,e)}else o==null||o(null,e)},onProgress(x,I){r==null||r({bytesUploaded:x,bytesTotal:I})},onSuccess:async()=>{var I;const x=(I=P.url)==null?void 0:I.split("/").pop();try{if(x){const O=await Vo(x);n==null||n(O.fileEntry,e)}}catch(O){localStorage.removeItem(_),o==null||o(ee(O),e)}}}),E=await P.findPreviousUploads();return E.length&&P.resumeFromPreviousUpload(E[0]),new Se(P)}}function Vo(t){return $.post("tus/entries",{uploadKey:t}).then(e=>e.data)}async function Wo(t,e){var _,P;const r=Ve().settings,n=t.options,o=t.file;if(n!=null&&n.restrictions){const E=zr(o,n.restrictions);if(E)return e.updateFileUpload(o.id,{errorMessage:E,status:"failed",request:void 0,timer:void 0}),n.showToastOnRestrictionFail&&at.danger(E),e.runQueue(),null}const i=Zo(n.uploadType);if(!i)throw new Error("No backend found for upload type "+n.uploadType);const s=new Hr,f={uploadType:n==null?void 0:n.uploadType,backendId:i.id,metadata:{...n==null?void 0:n.metadata,relativePath:o.relativePath,parentId:((_=n==null?void 0:n.metadata)==null?void 0:_.parentId)||""},chunkSize:((P=r.uploading)==null?void 0:P.chunk_size)??Mt,baseUrl:r.base_url,onError:E=>{var x;e.updateFileUpload(o.id,{errorMessage:E,status:"failed"}),e.runQueue(),s.done(),(x=n==null?void 0:n.onError)==null||x.call(n,E,o),n.showToastOnBackendError&&E&&at.danger(E)},onSuccess:E=>{var x;e.updateFileUpload(o.id,{status:"completed",entry:E}),e.runQueue(),s.done(),(x=n==null?void 0:n.onSuccess)==null||x.call(n,E,o)},onProgress:({bytesUploaded:E,bytesTotal:x})=>{var O;const I=E/x*100;e.updateFileUpload(o.id,{percentage:I,bytesUploaded:E}),s.progress(),(O=n==null?void 0:n.onProgress)==null||O.call(n,{bytesUploaded:E,bytesTotal:x})}},d=await Qo(o,i).create(o,f);return s.timeoutHandler=()=>{d.abort(),e.updateFileUpload(o.id,{status:"failed",errorMessage:De("Upload timed out")}),e.runQueue()},e.updateFileUpload(o.id,{status:"inProgress",request:d}),d.start(),d}const yr=1024*1024,Xo=4*yr,Yo=100*yr,Qo=(t,e)=>e.driver==="s3"&&e.direct_upload?t.size>=Yo?Ee:Je:t.size>=Xo?Se:Xe;function Zo(t){const e=Ve().uploading_types;if(e&&t){const r=e[t];return r.backends[Math.floor(Math.random()*r.backends.length)]}return null}Sr();const Bt={uploadStarted:!1,concurrency:3,fileUploads:new Map,activeUploadsCount:0,inProgressUploadsCount:0,pendingUploadsCount:0,completedUploadsCount:0},Jo=({settings:t,options:e})=>wr()(Er((r,n)=>({...Bt,reset:()=>{r(Bt)},getUpload:o=>n().fileUploads.get(o),getCompletedFileEntries:()=>[...n().fileUploads.values()].filter(o=>!!o.entry).map(o=>o.entry),clearInactive:()=>{r(o=>{o.fileUploads.forEach((i,s)=>{i.status!=="inProgress"&&o.fileUploads.delete(s)}),Q(o)}),n().runQueue()},abortUpload:o=>{var s;const i=n().fileUploads.get(o);i&&((s=i.request)==null||s.abort(),n().uploadStarted?(n().updateFileUpload(o,{status:"aborted",percentage:0}),n().runQueue()):n().removeUpload(o))},updateFileUpload:(o,i)=>{r(s=>{const f=s.fileUploads.get(o);f&&(s.fileUploads.set(o,{...f,...i}),"status"in i&&Q(s))})},addCompletedFileUpload:(o,i)=>{r(s=>{s.fileUploads.set(`${o.id}`,{file:new Or(o),status:"completed",entry:o,percentage:100,bytesUploaded:o.file_size||0,options:{uploadType:i}}),Q(s)})},uploadSingle:(o,i)=>{const s=pt(o,i,e),f=new Map(n().fileUploads);return f.set(s.file.id,s),r(p=>{Q(p),p.fileUploads=f,p.uploadStarted=!0}),n().runQueue(),s.file.id},removeUpload:o=>{r(i=>{i.fileUploads.delete(o),Q(i)})},uploadMultiple:(o,i,{startUpload:s=!0}={})=>{const f=new Map(n().fileUploads);return[...o].forEach(p=>{const d=pt(p,i,e);f.set(d.file.id,d)}),r(p=>{p.uploadStarted=s,p.fileUploads=f,Q(p)}),s&&n().runQueue(),[...f.keys()]},startUpload:()=>{r(o=>{o.uploadStarted=!0}),n().runQueue()},runQueue:async()=>{if(n().uploadStarted===!1)return;const o=[...n().fileUploads.values()],i=o.filter(f=>f.status==="inProgress");let s=n().concurrency;if(i.filter(f=>{var p;return f.file.relativePath||f.request instanceof Ee||f.request instanceof Se&&f.file.size>(((p=t.uploading)==null?void 0:p.chunk_size)??Mt)}).length&&(s=1),i.length<s){const f=o.find(p=>p.status==="pending");f?await Wo(f,n()):r(p=>{p.uploadStarted=!1})}}}))),Q=t=>{const e=[...t.fileUploads.values()];t.completedUploadsCount=e.filter(r=>r.status==="completed").length,t.inProgressUploadsCount=e.filter(r=>r.status==="inProgress").length,t.pendingUploadsCount=e.filter(r=>r.status==="pending").length,t.activeUploadsCount=e.filter(r=>r.status==="inProgress"||r.status==="pending").length},{useSyncExternalStoreWithSelector:ei}=Lr,ti=t=>t;function ri(t,e=ti,r){const n=ei(t.subscribe,t.getState,t.getInitialState,e,r);return Ur.useDebugValue(n),n}const mr=We.createContext(null);function si(t,e){const r=We.useContext(mr);return ri(r,t,e)}function ui({children:t,options:e}){const r=Rr(),[n]=We.useState(()=>Jo({settings:r,options:e}));return Pr.jsx(mr.Provider,{value:n,children:t})}export{ui as F,Tr as a,jr as r,si as u,Ir as w};
