@maveio/components 0.0.156 → 0.0.157

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
- import {a as a$2,d,b as b$2}from'./chunk-FSFJQ67W.js';import {a as a$3}from'./chunk-VZKW2VWI.js';import {a as a$5}from'./chunk-MS5NFI3Q.js';import {a as a$1,b as b$1,c as c$1}from'./chunk-HMISRRKC.js';import {h,i,c as c$2}from'./chunk-A4GZBQEB.js';import {a as a$4}from'./chunk-JBV2AYRP.js';import {a,b,c}from'./chunk-NDDFZTBA.js';var Ot=a((no,Pt)=>{Pt.exports=function(t,r){if(r=r.split(":")[0],t=+t,!t)return false;switch(r){case "http":case "ws":return t!==80;case "https":case "wss":return t!==443;case "ftp":return t!==21;case "gopher":return t!==70;case "file":return false}return t!==0};});var jt=a(Ae=>{var Vr=Object.prototype.hasOwnProperty,Wr;function kt(e){try{return decodeURIComponent(e.replace(/\+/g," "))}catch{return null}}function Rt(e){try{return encodeURIComponent(e)}catch{return null}}function Yr(e){for(var t=/([^=?#&]+)=?([^&]*)/g,r={},n;n=t.exec(e);){var o=kt(n[1]),a=kt(n[2]);o===null||a===null||o in r||(r[o]=a);}return r}function Zr(e,t){t=t||"";var r=[],n,o;typeof t!="string"&&(t="?");for(o in e)if(Vr.call(e,o)){if(n=e[o],!n&&(n===null||n===Wr||isNaN(n))&&(n=""),o=Rt(o),n=Rt(n),o===null||n===null)continue;r.push(o+"="+n);}return r.length?t+r.join("&"):""}Ae.stringify=Zr;Ae.parse=Yr;});var Nt=a((io,It)=>{var Tt=Ot(),be=jt(),Jr=/^[\x00-\x20\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]+/,Dt=/[\n\r\t]/g,Qr=/^[A-Za-z][A-Za-z0-9+-.]*:\/\//,At=/:\d+$/,en=/^([a-z][a-z0-9.+-]*:)?(\/\/)?([\\/]+)?([\S\s]*)/i,tn=/^[a-zA-Z]:/;function Fe(e){return (e||"").toString().replace(Jr,"")}var Le=[["#","hash"],["?","query"],function(t,r){return A(r.protocol)?t.replace(/\\/g,"/"):t},["/","pathname"],["@","auth",1],[NaN,"host",void 0,1,1],[/:(\d*)$/,"port",void 0,1],[NaN,"hostname",void 0,1,1]],Ct={hash:1,query:1};function Lt(e){var t;typeof window<"u"?t=window:typeof global<"u"?t=global:typeof self<"u"?t=self:t={};var r=t.location||{};e=e||r;var n={},o=typeof e,a;if(e.protocol==="blob:")n=new L(unescape(e.pathname),{});else if(o==="string"){n=new L(e,{});for(a in Ct)delete n[a];}else if(o==="object"){for(a in e)a in Ct||(n[a]=e[a]);n.slashes===void 0&&(n.slashes=Qr.test(e.href));}return n}function A(e){return e==="file:"||e==="ftp:"||e==="http:"||e==="https:"||e==="ws:"||e==="wss:"}function Ft(e,t){e=Fe(e),e=e.replace(Dt,""),t=t||{};var r=en.exec(e),n=r[1]?r[1].toLowerCase():"",o=!!r[2],a=!!r[3],l=0,f;return o?a?(f=r[2]+r[3]+r[4],l=r[2].length+r[3].length):(f=r[2]+r[4],l=r[2].length):a?(f=r[3]+r[4],l=r[3].length):f=r[4],n==="file:"?l>=2&&(f=f.slice(2)):A(n)?f=r[4]:n?o&&(f=f.slice(2)):l>=2&&A(t.protocol)&&(f=r[4]),{protocol:n,slashes:o||A(n),slashesCount:l,rest:f}}function rn(e,t){if(e==="")return t;for(var r=(t||"/").split("/").slice(0,-1).concat(e.split("/")),n=r.length,o=r[n-1],a=false,l=0;n--;)r[n]==="."?r.splice(n,1):r[n]===".."?(r.splice(n,1),l++):l&&(n===0&&(a=true),r.splice(n,1),l--);return a&&r.unshift(""),(o==="."||o==="..")&&r.push(""),r.join("/")}function L(e,t,r){if(e=Fe(e),e=e.replace(Dt,""),!(this instanceof L))return new L(e,t,r);var n,o,a,l,f,h,m=Le.slice(),v=typeof t,y=this,C=0;for(v!=="object"&&v!=="string"&&(r=t,t=null),r&&typeof r!="function"&&(r=be.parse),t=Lt(t),o=Ft(e||"",t),n=!o.protocol&&!o.slashes,y.slashes=o.slashes||n&&t.slashes,y.protocol=o.protocol||t.protocol||"",e=o.rest,(o.protocol==="file:"&&(o.slashesCount!==2||tn.test(e))||!o.slashes&&(o.protocol||o.slashesCount<2||!A(y.protocol)))&&(m[3]=[/(.*)/,"pathname"]);C<m.length;C++){if(l=m[C],typeof l=="function"){e=l(e,y);continue}a=l[0],h=l[1],a!==a?y[h]=e:typeof a=="string"?(f=a==="@"?e.lastIndexOf(a):e.indexOf(a),~f&&(typeof l[2]=="number"?(y[h]=e.slice(0,f),e=e.slice(f+l[2])):(y[h]=e.slice(f),e=e.slice(0,f)))):(f=a.exec(e))&&(y[h]=f[1],e=e.slice(0,f.index)),y[h]=y[h]||n&&l[3]&&t[h]||"",l[4]&&(y[h]=y[h].toLowerCase());}r&&(y.query=r(y.query)),n&&t.slashes&&y.pathname.charAt(0)!=="/"&&(y.pathname!==""||t.pathname!=="")&&(y.pathname=rn(y.pathname,t.pathname)),y.pathname.charAt(0)!=="/"&&A(y.protocol)&&(y.pathname="/"+y.pathname),Tt(y.port,y.protocol)||(y.host=y.hostname,y.port=""),y.username=y.password="",y.auth&&(f=y.auth.indexOf(":"),~f?(y.username=y.auth.slice(0,f),y.username=encodeURIComponent(decodeURIComponent(y.username)),y.password=y.auth.slice(f+1),y.password=encodeURIComponent(decodeURIComponent(y.password))):y.username=encodeURIComponent(decodeURIComponent(y.auth)),y.auth=y.password?y.username+":"+y.password:y.username),y.origin=y.protocol!=="file:"&&A(y.protocol)&&y.host?y.protocol+"//"+y.host:"null",y.href=y.toString();}function nn(e,t,r){var n=this;switch(e){case "query":typeof t=="string"&&t.length&&(t=(r||be.parse)(t)),n[e]=t;break;case "port":n[e]=t,Tt(t,n.protocol)?t&&(n.host=n.hostname+":"+t):(n.host=n.hostname,n[e]="");break;case "hostname":n[e]=t,n.port&&(t+=":"+n.port),n.host=t;break;case "host":n[e]=t,At.test(t)?(t=t.split(":"),n.port=t.pop(),n.hostname=t.join(":")):(n.hostname=t,n.port="");break;case "protocol":n.protocol=t.toLowerCase(),n.slashes=!r;break;case "pathname":case "hash":if(t){var o=e==="pathname"?"/":"#";n[e]=t.charAt(0)!==o?o+t:t;}else n[e]=t;break;case "username":case "password":n[e]=encodeURIComponent(t);break;case "auth":var a=t.indexOf(":");~a?(n.username=t.slice(0,a),n.username=encodeURIComponent(decodeURIComponent(n.username)),n.password=t.slice(a+1),n.password=encodeURIComponent(decodeURIComponent(n.password))):n.username=encodeURIComponent(decodeURIComponent(t));}for(var l=0;l<Le.length;l++){var f=Le[l];f[4]&&(n[f[1]]=n[f[1]].toLowerCase());}return n.auth=n.password?n.username+":"+n.password:n.username,n.origin=n.protocol!=="file:"&&A(n.protocol)&&n.host?n.protocol+"//"+n.host:"null",n.href=n.toString(),n}function on(e){(!e||typeof e!="function")&&(e=be.stringify);var t,r=this,n=r.host,o=r.protocol;o&&o.charAt(o.length-1)!==":"&&(o+=":");var a=o+(r.protocol&&r.slashes||A(r.protocol)?"//":"");return r.username?(a+=r.username,r.password&&(a+=":"+r.password),a+="@"):r.password?(a+=":"+r.password,a+="@"):r.protocol!=="file:"&&A(r.protocol)&&!n&&r.pathname!=="/"&&(a+="@"),(n[n.length-1]===":"||At.test(r.hostname)&&!r.port)&&(n+=":"),a+=n+r.pathname,t=typeof r.query=="object"?e(r.query):r.query,t&&(a+=t.charAt(0)!=="?"?"?"+t:t),r.hash&&(a+=r.hash),a}L.prototype={set:nn,toString:on};L.extractProtocol=Ft;L.location=Lt;L.trimLeft=Fe;L.qs=be;It.exports=L;});function Y(e){"@babel/helpers - typeof";return Y=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Y(e)}function _r(e,t,r){return Object.defineProperty(e,"prototype",{writable:false}),e}function xr(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Er(e,t,r){return t=fe(t),Ur(e,Re()?Reflect.construct(t,r||[],fe(e).constructor):t.apply(e,r))}function Ur(e,t){if(t&&(Y(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Pr(e)}function Pr(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Or(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:true,configurable:true}}),Object.defineProperty(e,"prototype",{writable:false}),t&&le(e,t);}function ke(e){var t=typeof Map=="function"?new Map:void 0;return ke=function(n){if(n===null||!Rr(n))return n;if(typeof n!="function")throw new TypeError("Super expression must either be null or a function");if(typeof t<"u"){if(t.has(n))return t.get(n);t.set(n,o);}function o(){return kr(n,arguments,fe(this).constructor)}return o.prototype=Object.create(n.prototype,{constructor:{value:o,enumerable:false,writable:true,configurable:true}}),le(o,n)},ke(e)}function kr(e,t,r){if(Re())return Reflect.construct.apply(null,arguments);var n=[null];n.push.apply(n,t);var o=new(e.bind.apply(e,n));return r&&le(o,r.prototype),o}function Re(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));}catch{}return (Re=function(){return !!e})()}function Rr(e){try{return Function.toString.call(e).indexOf("[native code]")!==-1}catch{return typeof e=="function"}}function le(e,t){return le=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,o){return n.__proto__=o,n},le(e,t)}function fe(e){return fe=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},fe(e)}var jr=function(e){function t(r){var n,o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null,a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:null,l=arguments.length>3&&arguments[3]!==void 0?arguments[3]:null;if(xr(this,t),n=Er(this,t,[r]),n.originalRequest=a,n.originalResponse=l,n.causingError=o,o!=null&&(r+=", caused by ".concat(o.toString())),a!=null){var f=a.getHeader("X-Request-ID")||"n/a",h=a.getMethod(),m=a.getURL(),v=l?l.getStatus():"n/a",y=l?l.getBody()||"":"n/a";r+=", originated from request (method: ".concat(h,", url: ").concat(m,", response code: ").concat(v,", response text: ").concat(y,", request id: ").concat(f,")");}return n.message=r,n}return Or(t,e),_r(t)}(ke(Error)),Z=jr;function B(e){}function ce(e){"@babel/helpers - typeof";return ce=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ce(e)}function Tr(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function it(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||false,n.configurable=true,"value"in n&&(n.writable=true),Object.defineProperty(e,Ar(n.key),n);}}function Dr(e,t,r){return t&&it(e.prototype,t),Object.defineProperty(e,"prototype",{writable:false}),e}function Ar(e){var t=Lr(e,"string");return ce(t)=="symbol"?t:t+""}function Lr(e,t){if(ce(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(ce(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return (String)(e)}var at=function(){function e(){Tr(this,e);}return Dr(e,[{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)}}])}();var pt="3.7.5",Fr=pt,Ir=typeof atob=="function",Nr=typeof btoa=="function",Q=typeof Buffer=="function",st=typeof TextDecoder=="function"?new TextDecoder:void 0,ut=typeof TextEncoder=="function"?new TextEncoder:void 0,Br="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",pe=Array.prototype.slice.call(Br),ge=(e=>{let t={};return e.forEach((r,n)=>t[r]=n),t})(pe),Hr=/^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/,U=String.fromCharCode.bind(String),lt=typeof Uint8Array.from=="function"?Uint8Array.from.bind(Uint8Array):e=>new Uint8Array(Array.prototype.slice.call(e,0)),ht=e=>e.replace(/=/g,"").replace(/[+\/]/g,t=>t=="+"?"-":"_"),dt=e=>e.replace(/[^A-Za-z0-9\+\/]/g,""),yt=e=>{let t,r,n,o,a="",l=e.length%3;for(let f=0;f<e.length;){if((r=e.charCodeAt(f++))>255||(n=e.charCodeAt(f++))>255||(o=e.charCodeAt(f++))>255)throw new TypeError("invalid character found");t=r<<16|n<<8|o,a+=pe[t>>18&63]+pe[t>>12&63]+pe[t>>6&63]+pe[t&63];}return l?a.slice(0,l-3)+"===".substring(l):a},Te=Nr?e=>btoa(e):Q?e=>Buffer.from(e,"binary").toString("base64"):yt,je=Q?e=>Buffer.from(e).toString("base64"):e=>{let r=[];for(let n=0,o=e.length;n<o;n+=4096)r.push(U.apply(null,e.subarray(n,n+4096)));return Te(r.join(""))},ve=(e,t=false)=>t?ht(je(e)):je(e),qr=e=>{if(e.length<2){var t=e.charCodeAt(0);return t<128?e:t<2048?U(192|t>>>6)+U(128|t&63):U(224|t>>>12&15)+U(128|t>>>6&63)+U(128|t&63)}else {var t=65536+(e.charCodeAt(0)-55296)*1024+(e.charCodeAt(1)-56320);return U(240|t>>>18&7)+U(128|t>>>12&63)+U(128|t>>>6&63)+U(128|t&63)}},zr=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,mt=e=>e.replace(zr,qr),ft=Q?e=>Buffer.from(e,"utf8").toString("base64"):ut?e=>je(ut.encode(e)):e=>Te(mt(e)),J=(e,t=false)=>t?ht(ft(e)):ft(e),ct=e=>J(e,true),Mr=/[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g,Gr=e=>{switch(e.length){case 4:var t=(7&e.charCodeAt(0))<<18|(63&e.charCodeAt(1))<<12|(63&e.charCodeAt(2))<<6|63&e.charCodeAt(3),r=t-65536;return U((r>>>10)+55296)+U((r&1023)+56320);case 3:return U((15&e.charCodeAt(0))<<12|(63&e.charCodeAt(1))<<6|63&e.charCodeAt(2));default:return U((31&e.charCodeAt(0))<<6|63&e.charCodeAt(1))}},gt=e=>e.replace(Mr,Gr),vt=e=>{if(e=e.replace(/\s+/g,""),!Hr.test(e))throw new TypeError("malformed base64.");e+="==".slice(2-(e.length&3));let t,r="",n,o;for(let a=0;a<e.length;)t=ge[e.charAt(a++)]<<18|ge[e.charAt(a++)]<<12|(n=ge[e.charAt(a++)])<<6|(o=ge[e.charAt(a++)]),r+=n===64?U(t>>16&255):o===64?U(t>>16&255,t>>8&255):U(t>>16&255,t>>8&255,t&255);return r},De=Ir?e=>atob(dt(e)):Q?e=>Buffer.from(e,"base64").toString("binary"):vt,bt=Q?e=>lt(Buffer.from(e,"base64")):e=>lt(De(e).split("").map(t=>t.charCodeAt(0))),_t=e=>bt(wt(e)),$r=Q?e=>Buffer.from(e,"base64").toString("utf8"):st?e=>st.decode(bt(e)):e=>gt(De(e)),wt=e=>dt(e.replace(/[-_]/g,t=>t=="-"?"+":"/")),Ce=e=>$r(wt(e)),Kr=e=>{if(typeof e!="string")return false;let t=e.replace(/\s+/g,"").replace(/={0,2}$/,"");return !/[^\s0-9a-zA-Z\+/]/.test(t)||!/[^\s0-9a-zA-Z\-_]/.test(t)},St=e=>({value:e,enumerable:false,writable:true,configurable:true}),xt=function(){let e=(t,r)=>Object.defineProperty(String.prototype,t,St(r));e("fromBase64",function(){return Ce(this)}),e("toBase64",function(t){return J(this,t)}),e("toBase64URI",function(){return J(this,true)}),e("toBase64URL",function(){return J(this,true)}),e("toUint8Array",function(){return _t(this)});},Et=function(){let e=(t,r)=>Object.defineProperty(Uint8Array.prototype,t,St(r));e("toBase64",function(t){return ve(this,t)}),e("toBase64URI",function(){return ve(this,true)}),e("toBase64URL",function(){return ve(this,true)});},Xr=()=>{xt(),Et();},Ut={version:pt,VERSION:Fr,atob:De,atobPolyfill:vt,btoa:Te,btoaPolyfill:yt,fromBase64:Ce,toBase64:J,encode:J,encodeURI:ct,encodeURL:ct,utob:mt,btou:gt,decode:Ce,isValid:Kr,fromUint8Array:ve,toUint8Array:_t,extendString:xt,extendUint8Array:Et,extendBuiltins:Xr};var Zt=b(Nt());function Ie(){return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=Math.random()*16|0,r=e==="x"?t:t&3|8;return r.toString(16)})}function Ne(){Ne=function(){return t};var e,t={},r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(u,i,s){u[i]=s.value;},a=typeof Symbol=="function"?Symbol:{},l=a.iterator||"@@iterator",f=a.asyncIterator||"@@asyncIterator",h=a.toStringTag||"@@toStringTag";function m(u,i,s){return Object.defineProperty(u,i,{value:s,enumerable:true,configurable:true,writable:true}),u[i]}try{m({},"");}catch{m=function(s,c,d){return s[c]=d};}function v(u,i,s,c){var d=i&&i.prototype instanceof F?i:F,p=Object.create(d.prototype),g=new M(c||[]);return o(p,"_invoke",{value:Ue(u,s,g)}),p}function y(u,i,s){try{return {type:"normal",arg:u.call(i,s)}}catch(c){return {type:"throw",arg:c}}}t.wrap=v;var C="suspendedStart",oe="suspendedYield",H="executing",D="completed",S={};function F(){}function k(){}function x(){}var T={};m(T,l,function(){return this});var q=Object.getPrototypeOf,I=q&&q(q(G([])));I&&I!==r&&n.call(I,l)&&(T=I);var R=x.prototype=F.prototype=Object.create(T);function ie(u){["next","throw","return"].forEach(function(i){m(u,i,function(s){return this._invoke(i,s)});});}function N(u,i){function s(d,p,g,b){var _=y(u[d],u,p);if(_.type!=="throw"){var P=_.arg,E=P.value;return E&&X(E)=="object"&&n.call(E,"__await")?i.resolve(E.__await).then(function(O){s("next",O,g,b);},function(O){s("throw",O,g,b);}):i.resolve(E).then(function(O){P.value=O,g(P);},function(O){return s("throw",O,g,b)})}b(_.arg);}var c;o(this,"_invoke",{value:function(p,g){function b(){return new i(function(_,P){s(p,g,_,P);})}return c=c?c.then(b,b):b()}});}function Ue(u,i,s){var c=C;return function(d,p){if(c===H)throw Error("Generator is already running");if(c===D){if(d==="throw")throw p;return {value:e,done:true}}for(s.method=d,s.arg=p;;){var g=s.delegate;if(g){var b=ae(g,s);if(b){if(b===S)continue;return b}}if(s.method==="next")s.sent=s._sent=s.arg;else if(s.method==="throw"){if(c===C)throw c=D,s.arg;s.dispatchException(s.arg);}else s.method==="return"&&s.abrupt("return",s.arg);c=H;var _=y(u,i,s);if(_.type==="normal"){if(c=s.done?D:oe,_.arg===S)continue;return {value:_.arg,done:s.done}}_.type==="throw"&&(c=D,s.method="throw",s.arg=_.arg);}}}function ae(u,i){var s=i.method,c=u.iterator[s];if(c===e)return i.delegate=null,s==="throw"&&u.iterator.return&&(i.method="return",i.arg=e,ae(u,i),i.method==="throw")||s!=="return"&&(i.method="throw",i.arg=new TypeError("The iterator does not provide a '"+s+"' method")),S;var d=y(c,u.iterator,i.arg);if(d.type==="throw")return i.method="throw",i.arg=d.arg,i.delegate=null,S;var p=d.arg;return p?p.done?(i[u.resultName]=p.value,i.next=u.nextLoc,i.method!=="return"&&(i.method="next",i.arg=e),i.delegate=null,S):p:(i.method="throw",i.arg=new TypeError("iterator result is not an object"),i.delegate=null,S)}function Pe(u){var i={tryLoc:u[0]};1 in u&&(i.catchLoc=u[1]),2 in u&&(i.finallyLoc=u[2],i.afterLoc=u[3]),this.tryEntries.push(i);}function z(u){var i=u.completion||{};i.type="normal",delete i.arg,u.completion=i;}function M(u){this.tryEntries=[{tryLoc:"root"}],u.forEach(Pe,this),this.reset(true);}function G(u){if(u||u===""){var i=u[l];if(i)return i.call(u);if(typeof u.next=="function")return u;if(!isNaN(u.length)){var s=-1,c=function d(){for(;++s<u.length;)if(n.call(u,s))return d.value=u[s],d.done=false,d;return d.value=e,d.done=true,d};return c.next=c}}throw new TypeError(X(u)+" is not iterable")}return k.prototype=x,o(R,"constructor",{value:x,configurable:true}),o(x,"constructor",{value:k,configurable:true}),k.displayName=m(x,h,"GeneratorFunction"),t.isGeneratorFunction=function(u){var i=typeof u=="function"&&u.constructor;return !!i&&(i===k||(i.displayName||i.name)==="GeneratorFunction")},t.mark=function(u){return Object.setPrototypeOf?Object.setPrototypeOf(u,x):(u.__proto__=x,m(u,h,"GeneratorFunction")),u.prototype=Object.create(R),u},t.awrap=function(u){return {__await:u}},ie(N.prototype),m(N.prototype,f,function(){return this}),t.AsyncIterator=N,t.async=function(u,i,s,c,d){d===void 0&&(d=Promise);var p=new N(v(u,i,s,c),d);return t.isGeneratorFunction(i)?p:p.next().then(function(g){return g.done?g.value:p.next()})},ie(R),m(R,h,"Generator"),m(R,l,function(){return this}),m(R,"toString",function(){return "[object Generator]"}),t.keys=function(u){var i=Object(u),s=[];for(var c in i)s.push(c);return s.reverse(),function d(){for(;s.length;){var p=s.pop();if(p in i)return d.value=p,d.done=false,d}return d.done=true,d}},t.values=G,M.prototype={constructor:M,reset:function(i){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=false,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(z),!i)for(var s in this)s.charAt(0)==="t"&&n.call(this,s)&&!isNaN(+s.slice(1))&&(this[s]=e);},stop:function(){this.done=true;var i=this.tryEntries[0].completion;if(i.type==="throw")throw i.arg;return this.rval},dispatchException:function(i){if(this.done)throw i;var s=this;function c(P,E){return g.type="throw",g.arg=i,s.next=P,E&&(s.method="next",s.arg=e),!!E}for(var d=this.tryEntries.length-1;d>=0;--d){var p=this.tryEntries[d],g=p.completion;if(p.tryLoc==="root")return c("end");if(p.tryLoc<=this.prev){var b=n.call(p,"catchLoc"),_=n.call(p,"finallyLoc");if(b&&_){if(this.prev<p.catchLoc)return c(p.catchLoc,true);if(this.prev<p.finallyLoc)return c(p.finallyLoc)}else if(b){if(this.prev<p.catchLoc)return c(p.catchLoc,true)}else {if(!_)throw Error("try statement without catch or finally");if(this.prev<p.finallyLoc)return c(p.finallyLoc)}}}},abrupt:function(i,s){for(var c=this.tryEntries.length-1;c>=0;--c){var d=this.tryEntries[c];if(d.tryLoc<=this.prev&&n.call(d,"finallyLoc")&&this.prev<d.finallyLoc){var p=d;break}}p&&(i==="break"||i==="continue")&&p.tryLoc<=s&&s<=p.finallyLoc&&(p=null);var g=p?p.completion:{};return g.type=i,g.arg=s,p?(this.method="next",this.next=p.finallyLoc,S):this.complete(g)},complete:function(i,s){if(i.type==="throw")throw i.arg;return i.type==="break"||i.type==="continue"?this.next=i.arg:i.type==="return"?(this.rval=this.arg=i.arg,this.method="return",this.next="end"):i.type==="normal"&&s&&(this.next=s),S},finish:function(i){for(var s=this.tryEntries.length-1;s>=0;--s){var c=this.tryEntries[s];if(c.finallyLoc===i)return this.complete(c.completion,c.afterLoc),z(c),S}},catch:function(i){for(var s=this.tryEntries.length-1;s>=0;--s){var c=this.tryEntries[s];if(c.tryLoc===i){var d=c.completion;if(d.type==="throw"){var p=d.arg;z(c);}return p}}throw Error("illegal catch attempt")},delegateYield:function(i,s,c){return this.delegate={iterator:G(i),resultName:s,nextLoc:c},this.method==="next"&&(this.arg=e),S}},t}function Bt(e,t,r,n,o,a,l){try{var f=e[a](l),h=f.value;}catch(m){r(m);return}f.done?t(h):Promise.resolve(h).then(n,o);}function an(e){return function(){var t=this,r=arguments;return new Promise(function(n,o){var a=e.apply(t,r);function l(h){Bt(a,n,o,l,f,"next",h);}function f(h){Bt(a,n,o,l,f,"throw",h);}l(void 0);})}}function Vt(e,t){return ln(e)||un(e,t)||Wt(e,t)||sn()}function sn(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
2
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function un(e,t){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var n,o,a,l,f=[],h=true,m=false;try{if(a=(r=r.call(e)).next,t===0);else for(;!(h=(n=a.call(r)).done)&&(f.push(n.value),f.length!==t);h=!0);}catch(v){m=true,o=v;}finally{try{if(!h&&r.return!=null&&(l=r.return(),Object(l)!==l))return}finally{if(m)throw o}}return f}}function ln(e){if(Array.isArray(e))return e}function X(e){"@babel/helpers - typeof";return X=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},X(e)}function fn(e,t){var r=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=Wt(e))||t){r&&(e=r);var n=0,o=function(){};return {s:o,n:function(){return n>=e.length?{done:true}:{done:false,value:e[n++]}},e:function(m){throw m},f:o}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
3
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a=true,l=false,f;return {s:function(){r=r.call(e);},n:function(){var m=r.next();return a=m.done,m},e:function(m){l=true,f=m;},f:function(){try{!a&&r.return!=null&&r.return();}finally{if(l)throw f}}}}function Wt(e,t){if(e){if(typeof e=="string")return Ht(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return Ht(e,t)}}function Ht(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function qt(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),r.push.apply(r,n);}return r}function ee(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?qt(Object(r),true).forEach(function(n){cn(e,n,r[n]);}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):qt(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n));});}return e}function cn(e,t,r){return t=Yt(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:true,configurable:true,writable:true}):e[t]=r,e}function pn(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function zt(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||false,n.configurable=true,"value"in n&&(n.writable=true),Object.defineProperty(e,Yt(n.key),n);}}function hn(e,t,r){return t&&zt(e.prototype,t),r&&zt(e,r),Object.defineProperty(e,"prototype",{writable:false}),e}function Yt(e){var t=dn(e,"string");return X(t)=="symbol"?t:t+""}function dn(e,t){if(X(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(X(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return (String)(e)}var Be="tus-v1",_e="ietf-draft-03",yn={endpoint:null,uploadUrl:null,metadata:{},metadataForPartialUploads:{},fingerprint:null,uploadSize:null,onProgress:null,onChunkComplete:null,onSuccess:null,onError:null,onUploadUrlAvailable:null,overridePatchMethod:false,headers:{},addRequestId:false,onBeforeRequest:null,onAfterResponse:null,onShouldRetry:Qt,chunkSize:Number.POSITIVE_INFINITY,retryDelays:[0,1e3,3e3,5e3],parallelUploads:1,parallelUploadBoundaries:null,storeFingerprintForResuming:true,removeFingerprintOnSuccess:false,uploadLengthDeferred:false,uploadDataDuringCreation:false,urlStorage:null,fileReader:null,httpStack:null,protocol:Be},Jt=function(){function e(t,r){pn(this,e),"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=t,this.url=null,this._req=null,this._fingerprint=null,this._urlStorageKey=null,this._offset=null,this._aborted=false,this._size=null,this._source=null,this._retryAttempt=0,this._retryTimeout=null,this._offsetBeforeRetry=0,this._parallelUploads=null,this._parallelUploadUrls=null;}return hn(e,[{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(![Be,_e].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 a=0,l=["uploadUrl","uploadSize","uploadLengthDeferred"];a<l.length;a++){var f=l[a];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(h){return r._fingerprint=h,r._source?r._source:r.options.fileReader.openFile(n,r.options.chunkSize)}).then(function(h){if(r._source=h,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(h){r._emitError(h);});}},{key:"_startParallelUpload",value:function(){var r,n=this,o=this._size,a=0;this._parallelUploads=[];var l=this._parallelUploadUrls!=null?this._parallelUploadUrls.length:this.options.parallelUploads,f=(r=this.options.parallelUploadBoundaries)!==null&&r!==void 0?r:gn(this._source.size,l);this._parallelUploadUrls&&f.forEach(function(v,y){v.uploadUrl=n._parallelUploadUrls[y]||null;}),this._parallelUploadUrls=new Array(f.length);var h=f.map(function(v,y){var C=0;return n._source.slice(v.start,v.end).then(function(oe){var H=oe.value;return new Promise(function(D,S){var F=ee(ee({},n.options),{},{uploadUrl:v.uploadUrl||null,storeFingerprintForResuming:false,removeFingerprintOnSuccess:false,parallelUploads:1,parallelUploadBoundaries:null,metadata:n.options.metadataForPartialUploads,headers:ee(ee({},n.options.headers),{},{"Upload-Concat":"partial"}),onSuccess:D,onError:S,onProgress:function(T){a=a-C+T,C=T,n._emitProgress(a,o);},onUploadUrlAvailable:function(){n._parallelUploadUrls[y]=k.url,n._parallelUploadUrls.filter(function(T){return !!T}).length===f.length&&n._saveUploadInUrlStorage();}}),k=new e(H,F);k.start(),n._parallelUploads.push(k);})})}),m;Promise.all(h).then(function(){m=n._openRequest("POST",n.options.endpoint),m.setHeader("Upload-Concat","final;".concat(n._parallelUploadUrls.join(" ")));var v=Mt(n.options.metadata);return v!==""&&m.setHeader("Upload-Metadata",v),n._sendRequest(m,null)}).then(function(v){if(!te(v.getStatus(),200)){n._emitHttpError(m,v,"tus: unexpected response while creating upload");return}var y=v.getHeader("Location");if(y==null){n._emitHttpError(m,v,"tus: invalid or missing Location header");return}n.url=Xt(n.options.endpoint,y),B("Created upload at ".concat(n.url)),n._emitSuccess(v);}).catch(function(v){n._emitError(v);});}},{key:"_startSingleUpload",value:function(){if(this._aborted=false,this.url!=null){B("Resuming upload from previous URL: ".concat(this.url)),this._resumeUpload();return}if(this.options.uploadUrl!=null){B("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=fn(this._parallelUploads),a;try{for(o.s();!(a=o.n()).done;){var l=a.value;l.abort(r);}}catch(f){o.e(f);}finally{o.f();}}return this._req!==null&&this._req.abort(),this._aborted=true,this._retryTimeout!=null&&(clearTimeout(this._retryTimeout),this._retryTimeout=null),!r||this.url==null?Promise.resolve():e.terminate(this.url,this.options).then(function(){return n._removeFromUrlStorage()})}},{key:"_emitHttpError",value:function(r,n,o,a){this._emitError(new Z(o,a,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),Kt(r,this._retryAttempt,this.options)){var a=this.options.retryDelays[this._retryAttempt++];this._offsetBeforeRetry=this._offset,this._retryTimeout=setTimeout(function(){n.start();},a);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=Mt(this.options.metadata);o!==""&&n.setHeader("Upload-Metadata",o);var a;this.options.uploadDataDuringCreation&&!this.options.uploadLengthDeferred?(this._offset=0,a=this._addChunkToRequest(n)):(this.options.protocol===_e&&n.setHeader("Upload-Complete","?0"),a=this._sendRequest(n,null)),a.then(function(l){if(!te(l.getStatus(),200)){r._emitHttpError(n,l,"tus: unexpected response while creating upload");return}var f=l.getHeader("Location");if(f==null){r._emitHttpError(n,l,"tus: invalid or missing Location header");return}if(r.url=Xt(r.options.endpoint,f),B("Created upload at ".concat(r.url)),typeof r.options.onUploadUrlAvailable=="function"&&r.options.onUploadUrlAvailable(),r._size===0){r._emitSuccess(l),r._source.close();return}r._saveUploadInUrlStorage().then(function(){r.options.uploadDataDuringCreation?r._handleUploadResponse(n,l):(r._offset=0,r._performUpload());});}).catch(function(l){r._emitHttpError(n,null,"tus: failed to create upload",l);});}},{key:"_resumeUpload",value:function(){var r=this,n=this._openRequest("HEAD",this.url),o=this._sendRequest(n,null);o.then(function(a){var l=a.getStatus();if(!te(l,200)){if(l===423){r._emitHttpError(n,a,"tus: upload is currently locked; retry later");return}if(te(l,400)&&r._removeFromUrlStorage(),!r.options.endpoint){r._emitHttpError(n,a,"tus: unable to resume upload (new upload cannot be created without an endpoint)");return}r.url=null,r._createUpload();return}var f=Number.parseInt(a.getHeader("Upload-Offset"),10);if(Number.isNaN(f)){r._emitHttpError(n,a,"tus: invalid or missing offset value");return}var h=Number.parseInt(a.getHeader("Upload-Length"),10);if(Number.isNaN(h)&&!r.options.uploadLengthDeferred&&r.options.protocol===Be){r._emitHttpError(n,a,"tus: invalid or missing length value");return}typeof r.options.onUploadUrlAvailable=="function"&&r.options.onUploadUrlAvailable(),r._saveUploadInUrlStorage().then(function(){if(f===h){r._emitProgress(h,h),r._emitSuccess(a);return}r._offset=f,r._performUpload();});}).catch(function(a){r._emitHttpError(n,null,"tus: failed to resume upload",a);});}},{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(a){if(!te(a.getStatus(),200)){r._emitHttpError(n,a,"tus: unexpected response while uploading chunk");return}r._handleUploadResponse(n,a);}).catch(function(a){r._aborted||r._emitHttpError(n,null,"tus: failed to upload chunk at offset ".concat(r._offset),a);});}}},{key:"_addChunkToRequest",value:function(r){var n=this,o=this._offset,a=this._offset+this.options.chunkSize;return r.setProgressHandler(function(l){n._emitProgress(o+l,n._size);}),r.setHeader("Content-Type","application/offset+octet-stream"),(a===Number.POSITIVE_INFINITY||a>this._size)&&!this.options.uploadLengthDeferred&&(a=this._size),this._source.slice(o,a).then(function(l){var f=l.value,h=l.done,m=f!=null&&f.size?f.size:0;n.options.uploadLengthDeferred&&h&&(n._size=n._offset+m,r.setHeader("Upload-Length","".concat(n._size)));var v=n._offset+m;return !n.options.uploadLengthDeferred&&h&&v!==n._size?Promise.reject(new Error("upload was configured with a size of ".concat(n._size," bytes, but the source is done after ").concat(v," bytes"))):f===null?n._sendRequest(r):(n.options.protocol===_e&&r.setHeader("Upload-Complete",h?"?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=Gt(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 $t(r,n,this.options)}}],[{key:"terminate",value:function(r){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=Gt("DELETE",r,n);return $t(o,null,n).then(function(a){if(a.getStatus()!==204)throw new Z("tus: unexpected response while terminating upload",null,o,a)}).catch(function(a){if(a instanceof Z||(a=new Z("tus: failed to terminate upload",a,o,null)),!Kt(a,0,n))throw a;var l=n.retryDelays[0],f=n.retryDelays.slice(1),h=ee(ee({},n),{},{retryDelays:f});return new Promise(function(m){return setTimeout(m,l)}).then(function(){return e.terminate(r,h)})})}}])}();function Mt(e){return Object.entries(e).map(function(t){var r=Vt(t,2),n=r[0],o=r[1];return "".concat(n," ").concat(Ut.encode(String(o)))}).join(",")}function te(e,t){return e>=t&&e<t+100}function Gt(e,t,r){var n=r.httpStack.createRequest(e,t);r.protocol===_e?n.setHeader("Upload-Draft-Interop-Version","5"):n.setHeader("Tus-Resumable","1.0.0");for(var o=r.headers||{},a=0,l=Object.entries(o);a<l.length;a++){var f=Vt(l[a],2),h=f[0],m=f[1];n.setHeader(h,m);}if(r.addRequestId){var v=Ie();n.setHeader("X-Request-ID",v);}return n}function $t(e,t,r){return He.apply(this,arguments)}function He(){return He=an(Ne().mark(function e(t,r,n){var o;return Ne().wrap(function(l){for(;;)switch(l.prev=l.next){case 0:if(typeof n.onBeforeRequest!="function"){l.next=3;break}return l.next=3,n.onBeforeRequest(t);case 3:return l.next=5,t.send(r);case 5:if(o=l.sent,typeof n.onAfterResponse!="function"){l.next=9;break}return l.next=9,n.onAfterResponse(t,o);case 9:return l.abrupt("return",o);case 10:case "end":return l.stop()}},e)})),He.apply(this,arguments)}function mn(){var e=true;return typeof navigator<"u"&&navigator.onLine===false&&(e=false),e}function Kt(e,t,r){return r.retryDelays==null||t>=r.retryDelays.length||e.originalRequest==null?false:r&&typeof r.onShouldRetry=="function"?r.onShouldRetry(e,t,r):Qt(e)}function Qt(e){var t=e.originalResponse?e.originalResponse.getStatus():0;return (!te(t,400)||t===409||t===423)&&mn()}function Xt(e,t){return new Zt.default(t,e).toString()}function gn(e,t){for(var r=Math.floor(e/t),n=[],o=0;o<t;o++)n.push({start:r*o,end:r*(o+1)});return n[t-1].end=e,n}Jt.defaultOptions=yn;var we=Jt;var vn=function(){return typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative"},Se=vn;function qe(e){return new Promise(function(t,r){var n=new XMLHttpRequest;n.responseType="blob",n.onload=function(){var o=n.response;t(o);},n.onerror=function(o){r(o);},n.open("GET",e),n.send();})}var bn=function(){return typeof window<"u"&&(typeof window.PhoneGap<"u"||typeof window.Cordova<"u"||typeof window.cordova<"u")},er=bn;function ze(e){return new Promise(function(t,r){var n=new FileReader;n.onload=function(){var o=new Uint8Array(n.result);t({value:o});},n.onerror=function(o){r(o);},n.readAsArrayBuffer(e);})}function he(e){"@babel/helpers - typeof";return he=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},he(e)}function _n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function tr(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||false,n.configurable=true,"value"in n&&(n.writable=true),Object.defineProperty(e,Sn(n.key),n);}}function wn(e,t,r){return t&&tr(e.prototype,t),Object.defineProperty(e,"prototype",{writable:false}),e}function Sn(e){var t=xn(e,"string");return he(t)=="symbol"?t:t+""}function xn(e,t){if(he(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(he(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return (String)(e)}var Me=function(){function e(t){_n(this,e),this._file=t,this.size=t.size;}return wn(e,[{key:"slice",value:function(r,n){if(er())return ze(this._file.slice(r,n));var o=this._file.slice(r,n),a=n>=this.size;return Promise.resolve({value:o,done:a})}},{key:"close",value:function(){}}])}();function de(e){"@babel/helpers - typeof";return de=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},de(e)}function En(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function rr(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||false,n.configurable=true,"value"in n&&(n.writable=true),Object.defineProperty(e,Pn(n.key),n);}}function Un(e,t,r){return t&&rr(e.prototype,t),Object.defineProperty(e,"prototype",{writable:false}),e}function Pn(e){var t=On(e,"string");return de(t)=="symbol"?t:t+""}function On(e,t){if(de(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(de(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return (String)(e)}function nr(e){return e===void 0?0:e.size!==void 0?e.size:e.length}function kn(e,t){if(e.concat)return e.concat(t);if(e instanceof Blob)return new Blob([e,t],{type:e.type});if(e.set){var r=new e.constructor(e.length+t.length);return r.set(e),r.set(t,e.length),r}throw new Error("Unknown data type")}var or=function(){function e(t){En(this,e),this._buffer=void 0,this._bufferOffset=0,this._reader=t,this._done=false;}return Un(e,[{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,a=n<=this._bufferOffset+nr(this._buffer);if(this._done||a){var l=this._getDataFromBuffer(r,n),f=l==null?this._done:false;return Promise.resolve({value:l,done:f})}return this._reader.read().then(function(h){var m=h.value,v=h.done;return v?o._done=true:o._buffer===void 0?o._buffer=m:o._buffer=kn(o._buffer,m),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=nr(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 V(e){"@babel/helpers - typeof";return V=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},V(e)}function Ge(){Ge=function(){return t};var e,t={},r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(u,i,s){u[i]=s.value;},a=typeof Symbol=="function"?Symbol:{},l=a.iterator||"@@iterator",f=a.asyncIterator||"@@asyncIterator",h=a.toStringTag||"@@toStringTag";function m(u,i,s){return Object.defineProperty(u,i,{value:s,enumerable:true,configurable:true,writable:true}),u[i]}try{m({},"");}catch{m=function(s,c,d){return s[c]=d};}function v(u,i,s,c){var d=i&&i.prototype instanceof F?i:F,p=Object.create(d.prototype),g=new M(c||[]);return o(p,"_invoke",{value:Ue(u,s,g)}),p}function y(u,i,s){try{return {type:"normal",arg:u.call(i,s)}}catch(c){return {type:"throw",arg:c}}}t.wrap=v;var C="suspendedStart",oe="suspendedYield",H="executing",D="completed",S={};function F(){}function k(){}function x(){}var T={};m(T,l,function(){return this});var q=Object.getPrototypeOf,I=q&&q(q(G([])));I&&I!==r&&n.call(I,l)&&(T=I);var R=x.prototype=F.prototype=Object.create(T);function ie(u){["next","throw","return"].forEach(function(i){m(u,i,function(s){return this._invoke(i,s)});});}function N(u,i){function s(d,p,g,b){var _=y(u[d],u,p);if(_.type!=="throw"){var P=_.arg,E=P.value;return E&&V(E)=="object"&&n.call(E,"__await")?i.resolve(E.__await).then(function(O){s("next",O,g,b);},function(O){s("throw",O,g,b);}):i.resolve(E).then(function(O){P.value=O,g(P);},function(O){return s("throw",O,g,b)})}b(_.arg);}var c;o(this,"_invoke",{value:function(p,g){function b(){return new i(function(_,P){s(p,g,_,P);})}return c=c?c.then(b,b):b()}});}function Ue(u,i,s){var c=C;return function(d,p){if(c===H)throw Error("Generator is already running");if(c===D){if(d==="throw")throw p;return {value:e,done:true}}for(s.method=d,s.arg=p;;){var g=s.delegate;if(g){var b=ae(g,s);if(b){if(b===S)continue;return b}}if(s.method==="next")s.sent=s._sent=s.arg;else if(s.method==="throw"){if(c===C)throw c=D,s.arg;s.dispatchException(s.arg);}else s.method==="return"&&s.abrupt("return",s.arg);c=H;var _=y(u,i,s);if(_.type==="normal"){if(c=s.done?D:oe,_.arg===S)continue;return {value:_.arg,done:s.done}}_.type==="throw"&&(c=D,s.method="throw",s.arg=_.arg);}}}function ae(u,i){var s=i.method,c=u.iterator[s];if(c===e)return i.delegate=null,s==="throw"&&u.iterator.return&&(i.method="return",i.arg=e,ae(u,i),i.method==="throw")||s!=="return"&&(i.method="throw",i.arg=new TypeError("The iterator does not provide a '"+s+"' method")),S;var d=y(c,u.iterator,i.arg);if(d.type==="throw")return i.method="throw",i.arg=d.arg,i.delegate=null,S;var p=d.arg;return p?p.done?(i[u.resultName]=p.value,i.next=u.nextLoc,i.method!=="return"&&(i.method="next",i.arg=e),i.delegate=null,S):p:(i.method="throw",i.arg=new TypeError("iterator result is not an object"),i.delegate=null,S)}function Pe(u){var i={tryLoc:u[0]};1 in u&&(i.catchLoc=u[1]),2 in u&&(i.finallyLoc=u[2],i.afterLoc=u[3]),this.tryEntries.push(i);}function z(u){var i=u.completion||{};i.type="normal",delete i.arg,u.completion=i;}function M(u){this.tryEntries=[{tryLoc:"root"}],u.forEach(Pe,this),this.reset(true);}function G(u){if(u||u===""){var i=u[l];if(i)return i.call(u);if(typeof u.next=="function")return u;if(!isNaN(u.length)){var s=-1,c=function d(){for(;++s<u.length;)if(n.call(u,s))return d.value=u[s],d.done=false,d;return d.value=e,d.done=true,d};return c.next=c}}throw new TypeError(V(u)+" is not iterable")}return k.prototype=x,o(R,"constructor",{value:x,configurable:true}),o(x,"constructor",{value:k,configurable:true}),k.displayName=m(x,h,"GeneratorFunction"),t.isGeneratorFunction=function(u){var i=typeof u=="function"&&u.constructor;return !!i&&(i===k||(i.displayName||i.name)==="GeneratorFunction")},t.mark=function(u){return Object.setPrototypeOf?Object.setPrototypeOf(u,x):(u.__proto__=x,m(u,h,"GeneratorFunction")),u.prototype=Object.create(R),u},t.awrap=function(u){return {__await:u}},ie(N.prototype),m(N.prototype,f,function(){return this}),t.AsyncIterator=N,t.async=function(u,i,s,c,d){d===void 0&&(d=Promise);var p=new N(v(u,i,s,c),d);return t.isGeneratorFunction(i)?p:p.next().then(function(g){return g.done?g.value:p.next()})},ie(R),m(R,h,"Generator"),m(R,l,function(){return this}),m(R,"toString",function(){return "[object Generator]"}),t.keys=function(u){var i=Object(u),s=[];for(var c in i)s.push(c);return s.reverse(),function d(){for(;s.length;){var p=s.pop();if(p in i)return d.value=p,d.done=false,d}return d.done=true,d}},t.values=G,M.prototype={constructor:M,reset:function(i){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=false,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(z),!i)for(var s in this)s.charAt(0)==="t"&&n.call(this,s)&&!isNaN(+s.slice(1))&&(this[s]=e);},stop:function(){this.done=true;var i=this.tryEntries[0].completion;if(i.type==="throw")throw i.arg;return this.rval},dispatchException:function(i){if(this.done)throw i;var s=this;function c(P,E){return g.type="throw",g.arg=i,s.next=P,E&&(s.method="next",s.arg=e),!!E}for(var d=this.tryEntries.length-1;d>=0;--d){var p=this.tryEntries[d],g=p.completion;if(p.tryLoc==="root")return c("end");if(p.tryLoc<=this.prev){var b=n.call(p,"catchLoc"),_=n.call(p,"finallyLoc");if(b&&_){if(this.prev<p.catchLoc)return c(p.catchLoc,true);if(this.prev<p.finallyLoc)return c(p.finallyLoc)}else if(b){if(this.prev<p.catchLoc)return c(p.catchLoc,true)}else {if(!_)throw Error("try statement without catch or finally");if(this.prev<p.finallyLoc)return c(p.finallyLoc)}}}},abrupt:function(i,s){for(var c=this.tryEntries.length-1;c>=0;--c){var d=this.tryEntries[c];if(d.tryLoc<=this.prev&&n.call(d,"finallyLoc")&&this.prev<d.finallyLoc){var p=d;break}}p&&(i==="break"||i==="continue")&&p.tryLoc<=s&&s<=p.finallyLoc&&(p=null);var g=p?p.completion:{};return g.type=i,g.arg=s,p?(this.method="next",this.next=p.finallyLoc,S):this.complete(g)},complete:function(i,s){if(i.type==="throw")throw i.arg;return i.type==="break"||i.type==="continue"?this.next=i.arg:i.type==="return"?(this.rval=this.arg=i.arg,this.method="return",this.next="end"):i.type==="normal"&&s&&(this.next=s),S},finish:function(i){for(var s=this.tryEntries.length-1;s>=0;--s){var c=this.tryEntries[s];if(c.finallyLoc===i)return this.complete(c.completion,c.afterLoc),z(c),S}},catch:function(i){for(var s=this.tryEntries.length-1;s>=0;--s){var c=this.tryEntries[s];if(c.tryLoc===i){var d=c.completion;if(d.type==="throw"){var p=d.arg;z(c);}return p}}throw Error("illegal catch attempt")},delegateYield:function(i,s,c){return this.delegate={iterator:G(i),resultName:s,nextLoc:c},this.method==="next"&&(this.arg=e),S}},t}function ir(e,t,r,n,o,a,l){try{var f=e[a](l),h=f.value;}catch(m){r(m);return}f.done?t(h):Promise.resolve(h).then(n,o);}function Rn(e){return function(){var t=this,r=arguments;return new Promise(function(n,o){var a=e.apply(t,r);function l(h){ir(a,n,o,l,f,"next",h);}function f(h){ir(a,n,o,l,f,"throw",h);}l(void 0);})}}function jn(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function ar(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||false,n.configurable=true,"value"in n&&(n.writable=true),Object.defineProperty(e,Tn(n.key),n);}}function Cn(e,t,r){return t&&ar(e.prototype,t),Object.defineProperty(e,"prototype",{writable:false}),e}function Tn(e){var t=Dn(e,"string");return V(t)=="symbol"?t:t+""}function Dn(e,t){if(V(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(V(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return (String)(e)}var sr=function(){function e(){jn(this,e);}return Cn(e,[{key:"openFile",value:function(){var t=Rn(Ge().mark(function n(o,a){var l;return Ge().wrap(function(h){for(;;)switch(h.prev=h.next){case 0:if(!(Se()&&o&&typeof o.uri<"u")){h.next=11;break}return h.prev=1,h.next=4,qe(o.uri);case 4:return l=h.sent,h.abrupt("return",new Me(l));case 8:throw h.prev=8,h.t0=h.catch(1),new Error("tus: cannot fetch `file.uri` as Blob, make sure the uri is correct and accessible. ".concat(h.t0));case 11:if(!(typeof o.slice=="function"&&typeof o.size<"u")){h.next=13;break}return h.abrupt("return",Promise.resolve(new Me(o)));case 13:if(typeof o.read!="function"){h.next=18;break}if(a=Number(a),Number.isFinite(a)){h.next=17;break}return h.abrupt("return",Promise.reject(new Error("cannot create source for stream without a finite value for the `chunkSize` option")));case 17:return h.abrupt("return",Promise.resolve(new or(o,a)));case 18:return h.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 h.stop()}},n,null,[[1,8]])}));function r(n,o){return t.apply(this,arguments)}return r}()}])}();function $e(e,t){return Se()?Promise.resolve(An(e,t)):Promise.resolve(["tus-br",e.name,e.type,e.size,e.lastModified,t.endpoint].join("-"))}function An(e,t){var r=e.exif?Ln(JSON.stringify(e.exif)):"noexif";return ["tus-rn",e.name||"noname",e.size||"nosize",r,t.endpoint].join("/")}function Ln(e){var t=0;if(e.length===0)return t;for(var r=0;r<e.length;r++){var n=e.charCodeAt(r);t=(t<<5)-t+n,t&=t;}return t}function ye(e){"@babel/helpers - typeof";return ye=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ye(e)}function Ke(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function ur(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||false,n.configurable=true,"value"in n&&(n.writable=true),Object.defineProperty(e,Fn(n.key),n);}}function Xe(e,t,r){return t&&ur(e.prototype,t),Object.defineProperty(e,"prototype",{writable:false}),e}function Fn(e){var t=In(e,"string");return ye(t)=="symbol"?t:t+""}function In(e,t){if(ye(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(ye(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return (String)(e)}var lr=function(){function e(){Ke(this,e);}return Xe(e,[{key:"createRequest",value:function(r,n){return new Nn(r,n)}},{key:"getName",value:function(){return "XHRHttpStack"}}])}();var Nn=function(){function e(t,r){Ke(this,e),this._xhr=new XMLHttpRequest,this._xhr.open(t,r,true),this._method=t,this._url=r,this._headers={};}return Xe(e,[{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,a){r._xhr.onload=function(){o(new Bn(r._xhr));},r._xhr.onerror=function(l){a(l);},r._xhr.send(n);})}},{key:"abort",value:function(){return this._xhr.abort(),Promise.resolve()}},{key:"getUnderlyingObject",value:function(){return this._xhr}}])}(),Bn=function(){function e(t){Ke(this,e),this._xhr=t;}return Xe(e,[{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 me(e){"@babel/helpers - typeof";return me=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},me(e)}function Hn(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function fr(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||false,n.configurable=true,"value"in n&&(n.writable=true),Object.defineProperty(e,zn(n.key),n);}}function qn(e,t,r){return t&&fr(e.prototype,t),Object.defineProperty(e,"prototype",{writable:false}),e}function zn(e){var t=Mn(e,"string");return me(t)=="symbol"?t:t+""}function Mn(e,t){if(me(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(me(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return (String)(e)}var We=false;try{We="localStorage"in window,xe="tusSupport",Ve=localStorage.getItem(xe),localStorage.setItem(xe,Ve),Ve===null&&localStorage.removeItem(xe);}catch(e){if(e.code===e.SECURITY_ERR||e.code===e.QUOTA_EXCEEDED_ERR)We=false;else throw e}var xe,Ve,cr=We,pr=function(){function e(){Hn(this,e);}return qn(e,[{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),a="tus::".concat(r,"::").concat(o);return localStorage.setItem(a,JSON.stringify(n)),Promise.resolve(a)}},{key:"_findEntries",value:function(r){for(var n=[],o=0;o<localStorage.length;o++){var a=localStorage.key(o);if(a.indexOf(r)===0)try{var l=JSON.parse(localStorage.getItem(a));l.urlStorageKey=a,n.push(l);}catch{}}return n}}])}();function ne(e){"@babel/helpers - typeof";return ne=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ne(e)}function Gn(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function hr(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||false,n.configurable=true,"value"in n&&(n.writable=true),Object.defineProperty(e,gr(n.key),n);}}function $n(e,t,r){return r&&hr(e,r),Object.defineProperty(e,"prototype",{writable:false}),e}function Kn(e,t,r){return t=Ee(t),Xn(e,mr()?Reflect.construct(t,r||[],Ee(e).constructor):t.apply(e,r))}function Xn(e,t){if(t&&(ne(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Vn(e)}function Vn(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function mr(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));}catch{}return (mr=function(){return !!e})()}function Ee(e){return Ee=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},Ee(e)}function Wn(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:true,configurable:true}}),Object.defineProperty(e,"prototype",{writable:false}),t&&Ye(e,t);}function Ye(e,t){return Ye=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,o){return n.__proto__=o,n},Ye(e,t)}function dr(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),r.push.apply(r,n);}return r}function re(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?dr(Object(r),true).forEach(function(n){Yn(e,n,r[n]);}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):dr(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n));});}return e}function Yn(e,t,r){return t=gr(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:true,configurable:true,writable:true}):e[t]=r,e}function gr(e){var t=Zn(e,"string");return ne(t)=="symbol"?t:t+""}function Zn(e,t){if(ne(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(ne(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return (t==="string"?String:Number)(e)}var yr=re(re({},we.defaultOptions),{},{httpStack:new lr,fileReader:new sr,urlStorage:cr?new pr:new at,fingerprint:$e}),vr=function(e){function t(){var r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:null,n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return Gn(this,t),n=re(re({},yr),n),Kn(this,t,[r,n])}return Wn(t,e),$n(t,null,[{key:"terminate",value:function(n){var o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return o=re(re({},yr),o),we.terminate(n,o)}}])}(we);var w=class extends i{constructor(){super(...arguments);this.disableCompletion=false;this._progress=0;this._completed=false;this._dragging=false;this.languageController=new d(this);this.lastState="initial";this.lastProgress=-1;}connectedCallback(){super.connectedCallback(),this.addEventListener("click",this.handleActionClick),this.addEventListener("keydown",this.handleActionKeyDown),this.languageController.locale=this.locale||"en",this.embedChannel=a$3.connect(this.token),this.embedChannel.upload_id&&(this._upload_id=this.embedChannel.upload_id),this.embedChannel.channel.on("initiate",({upload_id:r})=>{this._upload_id=r,this.embedChannel.upload_id=r;}),this.embedChannel.channel.on("completed",this.completed.bind(this)),this.embedChannel.channel.on("rendition",this.rendition.bind(this)),this.embedChannel.channel.on("error",this.error.bind(this));}requestUpdate(r,n){super.requestUpdate(r,n),r==="locale"&&(this.languageController.locale=this.locale);}reset(){this._progress=0,this._completed=false,this.embedChannel.channel.push("reset",{});}disconnectedCallback(){this.removeEventListener("click",this.handleActionClick),this.removeEventListener("keydown",this.handleActionKeyDown),super.disconnectedCallback();}handleDrop(r){r.preventDefault(),this._dragging=false;let n=r.dataTransfer;if(!n)return;let o=[];if(n.items){for(let l of n.items)if(l.kind==="file"){let f=l.getAsFile();f&&o.push(f);}}else if(n.files)for(let l of n.files)o.push(l);let a=false;for(let l of o)this.isSupportedFile(l)?(a||(this._progress=1,a=true),this.upload(l)):this.handleUnsupportedFile(l);}handleForm(r){let n=r.target;if(n.files){let o=false;for(let a of n.files)this.isSupportedFile(a)?(o||(this._progress=1,o=true),this.upload(a)):this.handleUnsupportedFile(a);n.value="";}}upload(r){this.dispatchEvent(new CustomEvent("upload",{bubbles:true,composed:true,detail:{file:r}}));let n=new vr(r,{endpoint:a$4.upload.endpoint,retryDelays:[0,3e3,5e3,1e4,2e4,6e4,6e4],metadata:{title:r.name,filetype:r.type,token:this.token,upload_id:this._upload_id},onError:o=>{console.log(o),this.dispatchEvent(new CustomEvent("failed",{bubbles:true,composed:true,detail:o}));},onProgress:(o,a)=>{let l=Math.round(o/a*100);l>this._progress&&(this._progress=l),this.dispatchEvent(new CustomEvent("progress",{bubbles:true,composed:true,detail:{progress:l}}));},onSuccess:()=>{this._progress=100,this.dispatchEvent(new CustomEvent("processing",{bubbles:true,composed:true}));},removeFingerprintOnSuccess:true});n.findPreviousUploads().then(o=>{o.length&&n.resumeFromPreviousUpload(o[0]),n.start();});}completed(r){this.disableCompletion||(this._completed=true),this.dispatchEvent(new CustomEvent("completed",{bubbles:true,composed:true,detail:r}));}rendition(r){this.dispatchEvent(new CustomEvent("rendition",{bubbles:true,composed:true,detail:r}));}error(r){console.warn(`[mave-upload] ${r.message}`),this.dispatchEvent(new CustomEvent("error",{bubbles:true,detail:r}));}render(){switch(this.currentState){case "uploading":return this.renderUploading();case "processing":return this.renderProcessing();case "done":return this.renderDone();default:return this.renderInitial()}}styleOpacity(){return this.languageController.loaded?this._upload_id?{}:{pointerEvents:"none",opacity:"0.5"}:{pointerEvents:"none",opacity:"0"}}styleFont(){return this.font?{fontFamily:this.font}:{fontFamily:"system-ui"}}get currentState(){return this._completed?"done":this._progress>=100&&this._progress>0?"processing":this._progress>0?"uploading":"initial"}openFileDialog(){this.fileInput&&!this.fileInput.disabled&&this.fileInput.click();}findActionTarget(r){for(let n of r.composedPath())if(n instanceof HTMLElement&&n.hasAttribute("data-mave-upload-select"))return n;return null}handleActionClick(r){this.findActionTarget(r)&&(r.preventDefault(),this.openFileDialog());}handleActionKeyDown(r){if(r.key!=="Enter"&&r.key!==" ")return;this.findActionTarget(r)&&(r.preventDefault(),this.openFileDialog());}blockSubmit(r){r.preventDefault();}handleDragEnter(r){r.preventDefault(),this._dragging=true;}handleDragOver(r){r.preventDefault(),r.dataTransfer&&(r.dataTransfer.dropEffect="copy"),this._dragging=true;}handleDragLeave(r){r.preventDefault();let n=r.currentTarget,o=r.relatedTarget;if(!n){this._dragging=false;return}(!o||!(o instanceof Node)||!n.contains(o))&&(this._dragging=false);}isSupportedFile(r){let n=(r.type||"").toLowerCase(),o=w.getFileExtension(r);return n.startsWith("video/")?!o||w.SUPPORTED_VIDEO_EXTENSIONS.has(o):n.startsWith("audio/")?!o||w.SUPPORTED_AUDIO_EXTENSIONS.has(o):o?!!(w.SUPPORTED_VIDEO_EXTENSIONS.has(o)||w.SUPPORTED_AUDIO_EXTENSIONS.has(o)):false}static getFileExtension(r){let n=r.name||"",o=n.lastIndexOf(".");if(!(o===-1||o===n.length-1))return n.slice(o+1).toLowerCase()}handleUnsupportedFile(r){this.dispatchEvent(new CustomEvent("invalid",{bubbles:true,composed:true,detail:{file:r,reason:"unsupported type",allowedExtensions:{video:Array.from(w.SUPPORTED_VIDEO_EXTENSIONS),audio:Array.from(w.SUPPORTED_AUDIO_EXTENSIONS)}}}));}updated(r){super.updated(r);let n=this._progress||0,o=this.currentState;this.setAttribute("state",o),this.setAttribute("progress",`${n}`),this.toggleAttribute("drag-over",this._dragging),this.toggleAttribute("ready",!!this._upload_id&&this.languageController.loaded);let a=o!==this.lastState,l=n!==this.lastProgress,f=r.has("_dragging");(a||l||f)&&this.dispatchEvent(new CustomEvent("statechange",{bubbles:true,composed:true,detail:{state:o,progress:n,dragging:this._dragging}})),this.lastState=o,this.lastProgress=n;}renderInitial(){let r=this.color?this.color:"#1997FF",n=this.radius?this.radius:"16px";return c$2`<form
1
+ import {a as a$2,d,b as b$2}from'./chunk-4GKJNXUA.js';import {a as a$3}from'./chunk-VZKW2VWI.js';import {a as a$5}from'./chunk-MS5NFI3Q.js';import {a as a$1,b as b$1,c as c$1}from'./chunk-HMISRRKC.js';import {h,i,c as c$2}from'./chunk-A4GZBQEB.js';import {a as a$4}from'./chunk-JBV2AYRP.js';import {a,b,c}from'./chunk-NDDFZTBA.js';var Ot=a((no,Pt)=>{Pt.exports=function(t,r){if(r=r.split(":")[0],t=+t,!t)return false;switch(r){case "http":case "ws":return t!==80;case "https":case "wss":return t!==443;case "ftp":return t!==21;case "gopher":return t!==70;case "file":return false}return t!==0};});var Dt=a(Ae=>{var Vr=Object.prototype.hasOwnProperty,Wr;function kt(e){try{return decodeURIComponent(e.replace(/\+/g," "))}catch{return null}}function Rt(e){try{return encodeURIComponent(e)}catch{return null}}function Yr(e){for(var t=/([^=?#&]+)=?([^&]*)/g,r={},n;n=t.exec(e);){var o=kt(n[1]),a=kt(n[2]);o===null||a===null||o in r||(r[o]=a);}return r}function Zr(e,t){t=t||"";var r=[],n,o;typeof t!="string"&&(t="?");for(o in e)if(Vr.call(e,o)){if(n=e[o],!n&&(n===null||n===Wr||isNaN(n))&&(n=""),o=Rt(o),n=Rt(n),o===null||n===null)continue;r.push(o+"="+n);}return r.length?t+r.join("&"):""}Ae.stringify=Zr;Ae.parse=Yr;});var Nt=a((io,It)=>{var jt=Ot(),be=Dt(),Jr=/^[\x00-\x20\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]+/,Tt=/[\n\r\t]/g,Qr=/^[A-Za-z][A-Za-z0-9+-.]*:\/\//,At=/:\d+$/,en=/^([a-z][a-z0-9.+-]*:)?(\/\/)?([\\/]+)?([\S\s]*)/i,tn=/^[a-zA-Z]:/;function Fe(e){return (e||"").toString().replace(Jr,"")}var Le=[["#","hash"],["?","query"],function(t,r){return L(r.protocol)?t.replace(/\\/g,"/"):t},["/","pathname"],["@","auth",1],[NaN,"host",void 0,1,1],[/:(\d*)$/,"port",void 0,1],[NaN,"hostname",void 0,1,1]],Ct={hash:1,query:1};function Lt(e){var t;typeof window<"u"?t=window:typeof global<"u"?t=global:typeof self<"u"?t=self:t={};var r=t.location||{};e=e||r;var n={},o=typeof e,a;if(e.protocol==="blob:")n=new F(unescape(e.pathname),{});else if(o==="string"){n=new F(e,{});for(a in Ct)delete n[a];}else if(o==="object"){for(a in e)a in Ct||(n[a]=e[a]);n.slashes===void 0&&(n.slashes=Qr.test(e.href));}return n}function L(e){return e==="file:"||e==="ftp:"||e==="http:"||e==="https:"||e==="ws:"||e==="wss:"}function Ft(e,t){e=Fe(e),e=e.replace(Tt,""),t=t||{};var r=en.exec(e),n=r[1]?r[1].toLowerCase():"",o=!!r[2],a=!!r[3],u=0,f;return o?a?(f=r[2]+r[3]+r[4],u=r[2].length+r[3].length):(f=r[2]+r[4],u=r[2].length):a?(f=r[3]+r[4],u=r[3].length):f=r[4],n==="file:"?u>=2&&(f=f.slice(2)):L(n)?f=r[4]:n?o&&(f=f.slice(2)):u>=2&&L(t.protocol)&&(f=r[4]),{protocol:n,slashes:o||L(n),slashesCount:u,rest:f}}function rn(e,t){if(e==="")return t;for(var r=(t||"/").split("/").slice(0,-1).concat(e.split("/")),n=r.length,o=r[n-1],a=false,u=0;n--;)r[n]==="."?r.splice(n,1):r[n]===".."?(r.splice(n,1),u++):u&&(n===0&&(a=true),r.splice(n,1),u--);return a&&r.unshift(""),(o==="."||o==="..")&&r.push(""),r.join("/")}function F(e,t,r){if(e=Fe(e),e=e.replace(Tt,""),!(this instanceof F))return new F(e,t,r);var n,o,a,u,f,h,m=Le.slice(),v=typeof t,y=this,j=0;for(v!=="object"&&v!=="string"&&(r=t,t=null),r&&typeof r!="function"&&(r=be.parse),t=Lt(t),o=Ft(e||"",t),n=!o.protocol&&!o.slashes,y.slashes=o.slashes||n&&t.slashes,y.protocol=o.protocol||t.protocol||"",e=o.rest,(o.protocol==="file:"&&(o.slashesCount!==2||tn.test(e))||!o.slashes&&(o.protocol||o.slashesCount<2||!L(y.protocol)))&&(m[3]=[/(.*)/,"pathname"]);j<m.length;j++){if(u=m[j],typeof u=="function"){e=u(e,y);continue}a=u[0],h=u[1],a!==a?y[h]=e:typeof a=="string"?(f=a==="@"?e.lastIndexOf(a):e.indexOf(a),~f&&(typeof u[2]=="number"?(y[h]=e.slice(0,f),e=e.slice(f+u[2])):(y[h]=e.slice(f),e=e.slice(0,f)))):(f=a.exec(e))&&(y[h]=f[1],e=e.slice(0,f.index)),y[h]=y[h]||n&&u[3]&&t[h]||"",u[4]&&(y[h]=y[h].toLowerCase());}r&&(y.query=r(y.query)),n&&t.slashes&&y.pathname.charAt(0)!=="/"&&(y.pathname!==""||t.pathname!=="")&&(y.pathname=rn(y.pathname,t.pathname)),y.pathname.charAt(0)!=="/"&&L(y.protocol)&&(y.pathname="/"+y.pathname),jt(y.port,y.protocol)||(y.host=y.hostname,y.port=""),y.username=y.password="",y.auth&&(f=y.auth.indexOf(":"),~f?(y.username=y.auth.slice(0,f),y.username=encodeURIComponent(decodeURIComponent(y.username)),y.password=y.auth.slice(f+1),y.password=encodeURIComponent(decodeURIComponent(y.password))):y.username=encodeURIComponent(decodeURIComponent(y.auth)),y.auth=y.password?y.username+":"+y.password:y.username),y.origin=y.protocol!=="file:"&&L(y.protocol)&&y.host?y.protocol+"//"+y.host:"null",y.href=y.toString();}function nn(e,t,r){var n=this;switch(e){case "query":typeof t=="string"&&t.length&&(t=(r||be.parse)(t)),n[e]=t;break;case "port":n[e]=t,jt(t,n.protocol)?t&&(n.host=n.hostname+":"+t):(n.host=n.hostname,n[e]="");break;case "hostname":n[e]=t,n.port&&(t+=":"+n.port),n.host=t;break;case "host":n[e]=t,At.test(t)?(t=t.split(":"),n.port=t.pop(),n.hostname=t.join(":")):(n.hostname=t,n.port="");break;case "protocol":n.protocol=t.toLowerCase(),n.slashes=!r;break;case "pathname":case "hash":if(t){var o=e==="pathname"?"/":"#";n[e]=t.charAt(0)!==o?o+t:t;}else n[e]=t;break;case "username":case "password":n[e]=encodeURIComponent(t);break;case "auth":var a=t.indexOf(":");~a?(n.username=t.slice(0,a),n.username=encodeURIComponent(decodeURIComponent(n.username)),n.password=t.slice(a+1),n.password=encodeURIComponent(decodeURIComponent(n.password))):n.username=encodeURIComponent(decodeURIComponent(t));}for(var u=0;u<Le.length;u++){var f=Le[u];f[4]&&(n[f[1]]=n[f[1]].toLowerCase());}return n.auth=n.password?n.username+":"+n.password:n.username,n.origin=n.protocol!=="file:"&&L(n.protocol)&&n.host?n.protocol+"//"+n.host:"null",n.href=n.toString(),n}function on(e){(!e||typeof e!="function")&&(e=be.stringify);var t,r=this,n=r.host,o=r.protocol;o&&o.charAt(o.length-1)!==":"&&(o+=":");var a=o+(r.protocol&&r.slashes||L(r.protocol)?"//":"");return r.username?(a+=r.username,r.password&&(a+=":"+r.password),a+="@"):r.password?(a+=":"+r.password,a+="@"):r.protocol!=="file:"&&L(r.protocol)&&!n&&r.pathname!=="/"&&(a+="@"),(n[n.length-1]===":"||At.test(r.hostname)&&!r.port)&&(n+=":"),a+=n+r.pathname,t=typeof r.query=="object"?e(r.query):r.query,t&&(a+=t.charAt(0)!=="?"?"?"+t:t),r.hash&&(a+=r.hash),a}F.prototype={set:nn,toString:on};F.extractProtocol=Ft;F.location=Lt;F.trimLeft=Fe;F.qs=be;It.exports=F;});function J(e){"@babel/helpers - typeof";return J=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},J(e)}function _r(e,t,r){return Object.defineProperty(e,"prototype",{writable:false}),e}function xr(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Er(e,t,r){return t=fe(t),Ur(e,Re()?Reflect.construct(t,r||[],fe(e).constructor):t.apply(e,r))}function Ur(e,t){if(t&&(J(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Pr(e)}function Pr(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Or(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:true,configurable:true}}),Object.defineProperty(e,"prototype",{writable:false}),t&&ue(e,t);}function ke(e){var t=typeof Map=="function"?new Map:void 0;return ke=function(n){if(n===null||!Rr(n))return n;if(typeof n!="function")throw new TypeError("Super expression must either be null or a function");if(typeof t<"u"){if(t.has(n))return t.get(n);t.set(n,o);}function o(){return kr(n,arguments,fe(this).constructor)}return o.prototype=Object.create(n.prototype,{constructor:{value:o,enumerable:false,writable:true,configurable:true}}),ue(o,n)},ke(e)}function kr(e,t,r){if(Re())return Reflect.construct.apply(null,arguments);var n=[null];n.push.apply(n,t);var o=new(e.bind.apply(e,n));return r&&ue(o,r.prototype),o}function Re(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));}catch{}return (Re=function(){return !!e})()}function Rr(e){try{return Function.toString.call(e).indexOf("[native code]")!==-1}catch{return typeof e=="function"}}function ue(e,t){return ue=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,o){return n.__proto__=o,n},ue(e,t)}function fe(e){return fe=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},fe(e)}var Dr=function(e){function t(r){var n,o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null,a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:null,u=arguments.length>3&&arguments[3]!==void 0?arguments[3]:null;if(xr(this,t),n=Er(this,t,[r]),n.originalRequest=a,n.originalResponse=u,n.causingError=o,o!=null&&(r+=", caused by ".concat(o.toString())),a!=null){var f=a.getHeader("X-Request-ID")||"n/a",h=a.getMethod(),m=a.getURL(),v=u?u.getStatus():"n/a",y=u?u.getBody()||"":"n/a";r+=", originated from request (method: ".concat(h,", url: ").concat(m,", response code: ").concat(v,", response text: ").concat(y,", request id: ").concat(f,")");}return n.message=r,n}return Or(t,e),_r(t)}(ke(Error)),Q=Dr;function z(e){}function ce(e){"@babel/helpers - typeof";return ce=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ce(e)}function jr(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function it(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||false,n.configurable=true,"value"in n&&(n.writable=true),Object.defineProperty(e,Ar(n.key),n);}}function Tr(e,t,r){return t&&it(e.prototype,t),Object.defineProperty(e,"prototype",{writable:false}),e}function Ar(e){var t=Lr(e,"string");return ce(t)=="symbol"?t:t+""}function Lr(e,t){if(ce(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(ce(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return (String)(e)}var at=function(){function e(){jr(this,e);}return Tr(e,[{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)}}])}();var pt="3.7.5",Fr=pt,Ir=typeof atob=="function",Nr=typeof btoa=="function",te=typeof Buffer=="function",st=typeof TextDecoder=="function"?new TextDecoder:void 0,lt=typeof TextEncoder=="function"?new TextEncoder:void 0,Br="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",pe=Array.prototype.slice.call(Br),ge=(e=>{let t={};return e.forEach((r,n)=>t[r]=n),t})(pe),Hr=/^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/,U=String.fromCharCode.bind(String),ut=typeof Uint8Array.from=="function"?Uint8Array.from.bind(Uint8Array):e=>new Uint8Array(Array.prototype.slice.call(e,0)),ht=e=>e.replace(/=/g,"").replace(/[+\/]/g,t=>t=="+"?"-":"_"),dt=e=>e.replace(/[^A-Za-z0-9\+\/]/g,""),yt=e=>{let t,r,n,o,a="",u=e.length%3;for(let f=0;f<e.length;){if((r=e.charCodeAt(f++))>255||(n=e.charCodeAt(f++))>255||(o=e.charCodeAt(f++))>255)throw new TypeError("invalid character found");t=r<<16|n<<8|o,a+=pe[t>>18&63]+pe[t>>12&63]+pe[t>>6&63]+pe[t&63];}return u?a.slice(0,u-3)+"===".substring(u):a},je=Nr?e=>btoa(e):te?e=>Buffer.from(e,"binary").toString("base64"):yt,De=te?e=>Buffer.from(e).toString("base64"):e=>{let r=[];for(let n=0,o=e.length;n<o;n+=4096)r.push(U.apply(null,e.subarray(n,n+4096)));return je(r.join(""))},ve=(e,t=false)=>t?ht(De(e)):De(e),zr=e=>{if(e.length<2){var t=e.charCodeAt(0);return t<128?e:t<2048?U(192|t>>>6)+U(128|t&63):U(224|t>>>12&15)+U(128|t>>>6&63)+U(128|t&63)}else {var t=65536+(e.charCodeAt(0)-55296)*1024+(e.charCodeAt(1)-56320);return U(240|t>>>18&7)+U(128|t>>>12&63)+U(128|t>>>6&63)+U(128|t&63)}},qr=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,mt=e=>e.replace(qr,zr),ft=te?e=>Buffer.from(e,"utf8").toString("base64"):lt?e=>De(lt.encode(e)):e=>je(mt(e)),ee=(e,t=false)=>t?ht(ft(e)):ft(e),ct=e=>ee(e,true),$r=/[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g,Mr=e=>{switch(e.length){case 4:var t=(7&e.charCodeAt(0))<<18|(63&e.charCodeAt(1))<<12|(63&e.charCodeAt(2))<<6|63&e.charCodeAt(3),r=t-65536;return U((r>>>10)+55296)+U((r&1023)+56320);case 3:return U((15&e.charCodeAt(0))<<12|(63&e.charCodeAt(1))<<6|63&e.charCodeAt(2));default:return U((31&e.charCodeAt(0))<<6|63&e.charCodeAt(1))}},gt=e=>e.replace($r,Mr),vt=e=>{if(e=e.replace(/\s+/g,""),!Hr.test(e))throw new TypeError("malformed base64.");e+="==".slice(2-(e.length&3));let t,r="",n,o;for(let a=0;a<e.length;)t=ge[e.charAt(a++)]<<18|ge[e.charAt(a++)]<<12|(n=ge[e.charAt(a++)])<<6|(o=ge[e.charAt(a++)]),r+=n===64?U(t>>16&255):o===64?U(t>>16&255,t>>8&255):U(t>>16&255,t>>8&255,t&255);return r},Te=Ir?e=>atob(dt(e)):te?e=>Buffer.from(e,"base64").toString("binary"):vt,bt=te?e=>ut(Buffer.from(e,"base64")):e=>ut(Te(e).split("").map(t=>t.charCodeAt(0))),_t=e=>bt(wt(e)),Gr=te?e=>Buffer.from(e,"base64").toString("utf8"):st?e=>st.decode(bt(e)):e=>gt(Te(e)),wt=e=>dt(e.replace(/[-_]/g,t=>t=="-"?"+":"/")),Ce=e=>Gr(wt(e)),Kr=e=>{if(typeof e!="string")return false;let t=e.replace(/\s+/g,"").replace(/={0,2}$/,"");return !/[^\s0-9a-zA-Z\+/]/.test(t)||!/[^\s0-9a-zA-Z\-_]/.test(t)},St=e=>({value:e,enumerable:false,writable:true,configurable:true}),xt=function(){let e=(t,r)=>Object.defineProperty(String.prototype,t,St(r));e("fromBase64",function(){return Ce(this)}),e("toBase64",function(t){return ee(this,t)}),e("toBase64URI",function(){return ee(this,true)}),e("toBase64URL",function(){return ee(this,true)}),e("toUint8Array",function(){return _t(this)});},Et=function(){let e=(t,r)=>Object.defineProperty(Uint8Array.prototype,t,St(r));e("toBase64",function(t){return ve(this,t)}),e("toBase64URI",function(){return ve(this,true)}),e("toBase64URL",function(){return ve(this,true)});},Xr=()=>{xt(),Et();},Ut={version:pt,VERSION:Fr,atob:Te,atobPolyfill:vt,btoa:je,btoaPolyfill:yt,fromBase64:Ce,toBase64:ee,encode:ee,encodeURI:ct,encodeURL:ct,utob:mt,btou:gt,decode:Ce,isValid:Kr,fromUint8Array:ve,toUint8Array:_t,extendString:xt,extendUint8Array:Et,extendBuiltins:Xr};var Zt=b(Nt());function Ie(){return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=Math.random()*16|0,r=e==="x"?t:t&3|8;return r.toString(16)})}function Ne(){Ne=function(){return t};var e,t={},r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(l,i,s){l[i]=s.value;},a=typeof Symbol=="function"?Symbol:{},u=a.iterator||"@@iterator",f=a.asyncIterator||"@@asyncIterator",h=a.toStringTag||"@@toStringTag";function m(l,i,s){return Object.defineProperty(l,i,{value:s,enumerable:true,configurable:true,writable:true}),l[i]}try{m({},"");}catch{m=function(s,c,d){return s[c]=d};}function v(l,i,s,c){var d=i&&i.prototype instanceof I?i:I,p=Object.create(d.prototype),g=new G(c||[]);return o(p,"_invoke",{value:Ue(l,s,g)}),p}function y(l,i,s){try{return {type:"normal",arg:l.call(i,s)}}catch(c){return {type:"throw",arg:c}}}t.wrap=v;var j="suspendedStart",ae="suspendedYield",q="executing",A="completed",S={};function I(){}function R(){}function x(){}var T={};m(T,u,function(){return this});var $=Object.getPrototypeOf,N=$&&$($(K([])));N&&N!==r&&n.call(N,u)&&(T=N);var D=x.prototype=I.prototype=Object.create(T);function se(l){["next","throw","return"].forEach(function(i){m(l,i,function(s){return this._invoke(i,s)});});}function B(l,i){function s(d,p,g,b){var _=y(l[d],l,p);if(_.type!=="throw"){var P=_.arg,E=P.value;return E&&W(E)=="object"&&n.call(E,"__await")?i.resolve(E.__await).then(function(O){s("next",O,g,b);},function(O){s("throw",O,g,b);}):i.resolve(E).then(function(O){P.value=O,g(P);},function(O){return s("throw",O,g,b)})}b(_.arg);}var c;o(this,"_invoke",{value:function(p,g){function b(){return new i(function(_,P){s(p,g,_,P);})}return c=c?c.then(b,b):b()}});}function Ue(l,i,s){var c=j;return function(d,p){if(c===q)throw Error("Generator is already running");if(c===A){if(d==="throw")throw p;return {value:e,done:true}}for(s.method=d,s.arg=p;;){var g=s.delegate;if(g){var b=le(g,s);if(b){if(b===S)continue;return b}}if(s.method==="next")s.sent=s._sent=s.arg;else if(s.method==="throw"){if(c===j)throw c=A,s.arg;s.dispatchException(s.arg);}else s.method==="return"&&s.abrupt("return",s.arg);c=q;var _=y(l,i,s);if(_.type==="normal"){if(c=s.done?A:ae,_.arg===S)continue;return {value:_.arg,done:s.done}}_.type==="throw"&&(c=A,s.method="throw",s.arg=_.arg);}}}function le(l,i){var s=i.method,c=l.iterator[s];if(c===e)return i.delegate=null,s==="throw"&&l.iterator.return&&(i.method="return",i.arg=e,le(l,i),i.method==="throw")||s!=="return"&&(i.method="throw",i.arg=new TypeError("The iterator does not provide a '"+s+"' method")),S;var d=y(c,l.iterator,i.arg);if(d.type==="throw")return i.method="throw",i.arg=d.arg,i.delegate=null,S;var p=d.arg;return p?p.done?(i[l.resultName]=p.value,i.next=l.nextLoc,i.method!=="return"&&(i.method="next",i.arg=e),i.delegate=null,S):p:(i.method="throw",i.arg=new TypeError("iterator result is not an object"),i.delegate=null,S)}function Pe(l){var i={tryLoc:l[0]};1 in l&&(i.catchLoc=l[1]),2 in l&&(i.finallyLoc=l[2],i.afterLoc=l[3]),this.tryEntries.push(i);}function M(l){var i=l.completion||{};i.type="normal",delete i.arg,l.completion=i;}function G(l){this.tryEntries=[{tryLoc:"root"}],l.forEach(Pe,this),this.reset(true);}function K(l){if(l||l===""){var i=l[u];if(i)return i.call(l);if(typeof l.next=="function")return l;if(!isNaN(l.length)){var s=-1,c=function d(){for(;++s<l.length;)if(n.call(l,s))return d.value=l[s],d.done=false,d;return d.value=e,d.done=true,d};return c.next=c}}throw new TypeError(W(l)+" is not iterable")}return R.prototype=x,o(D,"constructor",{value:x,configurable:true}),o(x,"constructor",{value:R,configurable:true}),R.displayName=m(x,h,"GeneratorFunction"),t.isGeneratorFunction=function(l){var i=typeof l=="function"&&l.constructor;return !!i&&(i===R||(i.displayName||i.name)==="GeneratorFunction")},t.mark=function(l){return Object.setPrototypeOf?Object.setPrototypeOf(l,x):(l.__proto__=x,m(l,h,"GeneratorFunction")),l.prototype=Object.create(D),l},t.awrap=function(l){return {__await:l}},se(B.prototype),m(B.prototype,f,function(){return this}),t.AsyncIterator=B,t.async=function(l,i,s,c,d){d===void 0&&(d=Promise);var p=new B(v(l,i,s,c),d);return t.isGeneratorFunction(i)?p:p.next().then(function(g){return g.done?g.value:p.next()})},se(D),m(D,h,"Generator"),m(D,u,function(){return this}),m(D,"toString",function(){return "[object Generator]"}),t.keys=function(l){var i=Object(l),s=[];for(var c in i)s.push(c);return s.reverse(),function d(){for(;s.length;){var p=s.pop();if(p in i)return d.value=p,d.done=false,d}return d.done=true,d}},t.values=K,G.prototype={constructor:G,reset:function(i){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=false,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(M),!i)for(var s in this)s.charAt(0)==="t"&&n.call(this,s)&&!isNaN(+s.slice(1))&&(this[s]=e);},stop:function(){this.done=true;var i=this.tryEntries[0].completion;if(i.type==="throw")throw i.arg;return this.rval},dispatchException:function(i){if(this.done)throw i;var s=this;function c(P,E){return g.type="throw",g.arg=i,s.next=P,E&&(s.method="next",s.arg=e),!!E}for(var d=this.tryEntries.length-1;d>=0;--d){var p=this.tryEntries[d],g=p.completion;if(p.tryLoc==="root")return c("end");if(p.tryLoc<=this.prev){var b=n.call(p,"catchLoc"),_=n.call(p,"finallyLoc");if(b&&_){if(this.prev<p.catchLoc)return c(p.catchLoc,true);if(this.prev<p.finallyLoc)return c(p.finallyLoc)}else if(b){if(this.prev<p.catchLoc)return c(p.catchLoc,true)}else {if(!_)throw Error("try statement without catch or finally");if(this.prev<p.finallyLoc)return c(p.finallyLoc)}}}},abrupt:function(i,s){for(var c=this.tryEntries.length-1;c>=0;--c){var d=this.tryEntries[c];if(d.tryLoc<=this.prev&&n.call(d,"finallyLoc")&&this.prev<d.finallyLoc){var p=d;break}}p&&(i==="break"||i==="continue")&&p.tryLoc<=s&&s<=p.finallyLoc&&(p=null);var g=p?p.completion:{};return g.type=i,g.arg=s,p?(this.method="next",this.next=p.finallyLoc,S):this.complete(g)},complete:function(i,s){if(i.type==="throw")throw i.arg;return i.type==="break"||i.type==="continue"?this.next=i.arg:i.type==="return"?(this.rval=this.arg=i.arg,this.method="return",this.next="end"):i.type==="normal"&&s&&(this.next=s),S},finish:function(i){for(var s=this.tryEntries.length-1;s>=0;--s){var c=this.tryEntries[s];if(c.finallyLoc===i)return this.complete(c.completion,c.afterLoc),M(c),S}},catch:function(i){for(var s=this.tryEntries.length-1;s>=0;--s){var c=this.tryEntries[s];if(c.tryLoc===i){var d=c.completion;if(d.type==="throw"){var p=d.arg;M(c);}return p}}throw Error("illegal catch attempt")},delegateYield:function(i,s,c){return this.delegate={iterator:K(i),resultName:s,nextLoc:c},this.method==="next"&&(this.arg=e),S}},t}function Bt(e,t,r,n,o,a,u){try{var f=e[a](u),h=f.value;}catch(m){r(m);return}f.done?t(h):Promise.resolve(h).then(n,o);}function an(e){return function(){var t=this,r=arguments;return new Promise(function(n,o){var a=e.apply(t,r);function u(h){Bt(a,n,o,u,f,"next",h);}function f(h){Bt(a,n,o,u,f,"throw",h);}u(void 0);})}}function Vt(e,t){return un(e)||ln(e,t)||Wt(e,t)||sn()}function sn(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
2
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ln(e,t){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var n,o,a,u,f=[],h=true,m=false;try{if(a=(r=r.call(e)).next,t===0);else for(;!(h=(n=a.call(r)).done)&&(f.push(n.value),f.length!==t);h=!0);}catch(v){m=true,o=v;}finally{try{if(!h&&r.return!=null&&(u=r.return(),Object(u)!==u))return}finally{if(m)throw o}}return f}}function un(e){if(Array.isArray(e))return e}function W(e){"@babel/helpers - typeof";return W=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},W(e)}function fn(e,t){var r=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=Wt(e))||t){r&&(e=r);var n=0,o=function(){};return {s:o,n:function(){return n>=e.length?{done:true}:{done:false,value:e[n++]}},e:function(m){throw m},f:o}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
3
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a=true,u=false,f;return {s:function(){r=r.call(e);},n:function(){var m=r.next();return a=m.done,m},e:function(m){u=true,f=m;},f:function(){try{!a&&r.return!=null&&r.return();}finally{if(u)throw f}}}}function Wt(e,t){if(e){if(typeof e=="string")return Ht(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return Ht(e,t)}}function Ht(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function zt(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),r.push.apply(r,n);}return r}function re(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?zt(Object(r),true).forEach(function(n){cn(e,n,r[n]);}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):zt(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n));});}return e}function cn(e,t,r){return t=Yt(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:true,configurable:true,writable:true}):e[t]=r,e}function pn(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function qt(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||false,n.configurable=true,"value"in n&&(n.writable=true),Object.defineProperty(e,Yt(n.key),n);}}function hn(e,t,r){return t&&qt(e.prototype,t),r&&qt(e,r),Object.defineProperty(e,"prototype",{writable:false}),e}function Yt(e){var t=dn(e,"string");return W(t)=="symbol"?t:t+""}function dn(e,t){if(W(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(W(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return (String)(e)}var Be="tus-v1",_e="ietf-draft-03",yn={endpoint:null,uploadUrl:null,metadata:{},metadataForPartialUploads:{},fingerprint:null,uploadSize:null,onProgress:null,onChunkComplete:null,onSuccess:null,onError:null,onUploadUrlAvailable:null,overridePatchMethod:false,headers:{},addRequestId:false,onBeforeRequest:null,onAfterResponse:null,onShouldRetry:Qt,chunkSize:Number.POSITIVE_INFINITY,retryDelays:[0,1e3,3e3,5e3],parallelUploads:1,parallelUploadBoundaries:null,storeFingerprintForResuming:true,removeFingerprintOnSuccess:false,uploadLengthDeferred:false,uploadDataDuringCreation:false,urlStorage:null,fileReader:null,httpStack:null,protocol:Be},Jt=function(){function e(t,r){pn(this,e),"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=t,this.url=null,this._req=null,this._fingerprint=null,this._urlStorageKey=null,this._offset=null,this._aborted=false,this._size=null,this._source=null,this._retryAttempt=0,this._retryTimeout=null,this._offsetBeforeRetry=0,this._parallelUploads=null,this._parallelUploadUrls=null;}return hn(e,[{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(![Be,_e].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 a=0,u=["uploadUrl","uploadSize","uploadLengthDeferred"];a<u.length;a++){var f=u[a];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(h){return r._fingerprint=h,r._source?r._source:r.options.fileReader.openFile(n,r.options.chunkSize)}).then(function(h){if(r._source=h,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(h){r._emitError(h);});}},{key:"_startParallelUpload",value:function(){var r,n=this,o=this._size,a=0;this._parallelUploads=[];var u=this._parallelUploadUrls!=null?this._parallelUploadUrls.length:this.options.parallelUploads,f=(r=this.options.parallelUploadBoundaries)!==null&&r!==void 0?r:gn(this._source.size,u);this._parallelUploadUrls&&f.forEach(function(v,y){v.uploadUrl=n._parallelUploadUrls[y]||null;}),this._parallelUploadUrls=new Array(f.length);var h=f.map(function(v,y){var j=0;return n._source.slice(v.start,v.end).then(function(ae){var q=ae.value;return new Promise(function(A,S){var I=re(re({},n.options),{},{uploadUrl:v.uploadUrl||null,storeFingerprintForResuming:false,removeFingerprintOnSuccess:false,parallelUploads:1,parallelUploadBoundaries:null,metadata:n.options.metadataForPartialUploads,headers:re(re({},n.options.headers),{},{"Upload-Concat":"partial"}),onSuccess:A,onError:S,onProgress:function(T){a=a-j+T,j=T,n._emitProgress(a,o);},onUploadUrlAvailable:function(){n._parallelUploadUrls[y]=R.url,n._parallelUploadUrls.filter(function(T){return !!T}).length===f.length&&n._saveUploadInUrlStorage();}}),R=new e(q,I);R.start(),n._parallelUploads.push(R);})})}),m;Promise.all(h).then(function(){m=n._openRequest("POST",n.options.endpoint),m.setHeader("Upload-Concat","final;".concat(n._parallelUploadUrls.join(" ")));var v=$t(n.options.metadata);return v!==""&&m.setHeader("Upload-Metadata",v),n._sendRequest(m,null)}).then(function(v){if(!ne(v.getStatus(),200)){n._emitHttpError(m,v,"tus: unexpected response while creating upload");return}var y=v.getHeader("Location");if(y==null){n._emitHttpError(m,v,"tus: invalid or missing Location header");return}n.url=Xt(n.options.endpoint,y),z("Created upload at ".concat(n.url)),n._emitSuccess(v);}).catch(function(v){n._emitError(v);});}},{key:"_startSingleUpload",value:function(){if(this._aborted=false,this.url!=null){z("Resuming upload from previous URL: ".concat(this.url)),this._resumeUpload();return}if(this.options.uploadUrl!=null){z("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=fn(this._parallelUploads),a;try{for(o.s();!(a=o.n()).done;){var u=a.value;u.abort(r);}}catch(f){o.e(f);}finally{o.f();}}return this._req!==null&&this._req.abort(),this._aborted=true,this._retryTimeout!=null&&(clearTimeout(this._retryTimeout),this._retryTimeout=null),!r||this.url==null?Promise.resolve():e.terminate(this.url,this.options).then(function(){return n._removeFromUrlStorage()})}},{key:"_emitHttpError",value:function(r,n,o,a){this._emitError(new Q(o,a,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),Kt(r,this._retryAttempt,this.options)){var a=this.options.retryDelays[this._retryAttempt++];this._offsetBeforeRetry=this._offset,this._retryTimeout=setTimeout(function(){n.start();},a);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=$t(this.options.metadata);o!==""&&n.setHeader("Upload-Metadata",o);var a;this.options.uploadDataDuringCreation&&!this.options.uploadLengthDeferred?(this._offset=0,a=this._addChunkToRequest(n)):(this.options.protocol===_e&&n.setHeader("Upload-Complete","?0"),a=this._sendRequest(n,null)),a.then(function(u){if(!ne(u.getStatus(),200)){r._emitHttpError(n,u,"tus: unexpected response while creating upload");return}var f=u.getHeader("Location");if(f==null){r._emitHttpError(n,u,"tus: invalid or missing Location header");return}if(r.url=Xt(r.options.endpoint,f),z("Created upload at ".concat(r.url)),typeof r.options.onUploadUrlAvailable=="function"&&r.options.onUploadUrlAvailable(),r._size===0){r._emitSuccess(u),r._source.close();return}r._saveUploadInUrlStorage().then(function(){r.options.uploadDataDuringCreation?r._handleUploadResponse(n,u):(r._offset=0,r._performUpload());});}).catch(function(u){r._emitHttpError(n,null,"tus: failed to create upload",u);});}},{key:"_resumeUpload",value:function(){var r=this,n=this._openRequest("HEAD",this.url),o=this._sendRequest(n,null);o.then(function(a){var u=a.getStatus();if(!ne(u,200)){if(u===423){r._emitHttpError(n,a,"tus: upload is currently locked; retry later");return}if(ne(u,400)&&r._removeFromUrlStorage(),!r.options.endpoint){r._emitHttpError(n,a,"tus: unable to resume upload (new upload cannot be created without an endpoint)");return}r.url=null,r._createUpload();return}var f=Number.parseInt(a.getHeader("Upload-Offset"),10);if(Number.isNaN(f)){r._emitHttpError(n,a,"tus: invalid or missing offset value");return}var h=Number.parseInt(a.getHeader("Upload-Length"),10);if(Number.isNaN(h)&&!r.options.uploadLengthDeferred&&r.options.protocol===Be){r._emitHttpError(n,a,"tus: invalid or missing length value");return}typeof r.options.onUploadUrlAvailable=="function"&&r.options.onUploadUrlAvailable(),r._saveUploadInUrlStorage().then(function(){if(f===h){r._emitProgress(h,h),r._emitSuccess(a);return}r._offset=f,r._performUpload();});}).catch(function(a){r._emitHttpError(n,null,"tus: failed to resume upload",a);});}},{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(a){if(!ne(a.getStatus(),200)){r._emitHttpError(n,a,"tus: unexpected response while uploading chunk");return}r._handleUploadResponse(n,a);}).catch(function(a){r._aborted||r._emitHttpError(n,null,"tus: failed to upload chunk at offset ".concat(r._offset),a);});}}},{key:"_addChunkToRequest",value:function(r){var n=this,o=this._offset,a=this._offset+this.options.chunkSize;return r.setProgressHandler(function(u){n._emitProgress(o+u,n._size);}),r.setHeader("Content-Type","application/offset+octet-stream"),(a===Number.POSITIVE_INFINITY||a>this._size)&&!this.options.uploadLengthDeferred&&(a=this._size),this._source.slice(o,a).then(function(u){var f=u.value,h=u.done,m=f!=null&&f.size?f.size:0;n.options.uploadLengthDeferred&&h&&(n._size=n._offset+m,r.setHeader("Upload-Length","".concat(n._size)));var v=n._offset+m;return !n.options.uploadLengthDeferred&&h&&v!==n._size?Promise.reject(new Error("upload was configured with a size of ".concat(n._size," bytes, but the source is done after ").concat(v," bytes"))):f===null?n._sendRequest(r):(n.options.protocol===_e&&r.setHeader("Upload-Complete",h?"?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=Mt(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 Gt(r,n,this.options)}}],[{key:"terminate",value:function(r){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=Mt("DELETE",r,n);return Gt(o,null,n).then(function(a){if(a.getStatus()!==204)throw new Q("tus: unexpected response while terminating upload",null,o,a)}).catch(function(a){if(a instanceof Q||(a=new Q("tus: failed to terminate upload",a,o,null)),!Kt(a,0,n))throw a;var u=n.retryDelays[0],f=n.retryDelays.slice(1),h=re(re({},n),{},{retryDelays:f});return new Promise(function(m){return setTimeout(m,u)}).then(function(){return e.terminate(r,h)})})}}])}();function $t(e){return Object.entries(e).map(function(t){var r=Vt(t,2),n=r[0],o=r[1];return "".concat(n," ").concat(Ut.encode(String(o)))}).join(",")}function ne(e,t){return e>=t&&e<t+100}function Mt(e,t,r){var n=r.httpStack.createRequest(e,t);r.protocol===_e?n.setHeader("Upload-Draft-Interop-Version","5"):n.setHeader("Tus-Resumable","1.0.0");for(var o=r.headers||{},a=0,u=Object.entries(o);a<u.length;a++){var f=Vt(u[a],2),h=f[0],m=f[1];n.setHeader(h,m);}if(r.addRequestId){var v=Ie();n.setHeader("X-Request-ID",v);}return n}function Gt(e,t,r){return He.apply(this,arguments)}function He(){return He=an(Ne().mark(function e(t,r,n){var o;return Ne().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:if(typeof n.onBeforeRequest!="function"){u.next=3;break}return u.next=3,n.onBeforeRequest(t);case 3:return u.next=5,t.send(r);case 5:if(o=u.sent,typeof n.onAfterResponse!="function"){u.next=9;break}return u.next=9,n.onAfterResponse(t,o);case 9:return u.abrupt("return",o);case 10:case "end":return u.stop()}},e)})),He.apply(this,arguments)}function mn(){var e=true;return typeof navigator<"u"&&navigator.onLine===false&&(e=false),e}function Kt(e,t,r){return r.retryDelays==null||t>=r.retryDelays.length||e.originalRequest==null?false:r&&typeof r.onShouldRetry=="function"?r.onShouldRetry(e,t,r):Qt(e)}function Qt(e){var t=e.originalResponse?e.originalResponse.getStatus():0;return (!ne(t,400)||t===409||t===423)&&mn()}function Xt(e,t){return new Zt.default(t,e).toString()}function gn(e,t){for(var r=Math.floor(e/t),n=[],o=0;o<t;o++)n.push({start:r*o,end:r*(o+1)});return n[t-1].end=e,n}Jt.defaultOptions=yn;var we=Jt;var vn=function(){return typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative"},Se=vn;function ze(e){return new Promise(function(t,r){var n=new XMLHttpRequest;n.responseType="blob",n.onload=function(){var o=n.response;t(o);},n.onerror=function(o){r(o);},n.open("GET",e),n.send();})}var bn=function(){return typeof window<"u"&&(typeof window.PhoneGap<"u"||typeof window.Cordova<"u"||typeof window.cordova<"u")},er=bn;function qe(e){return new Promise(function(t,r){var n=new FileReader;n.onload=function(){var o=new Uint8Array(n.result);t({value:o});},n.onerror=function(o){r(o);},n.readAsArrayBuffer(e);})}function he(e){"@babel/helpers - typeof";return he=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},he(e)}function _n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function tr(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||false,n.configurable=true,"value"in n&&(n.writable=true),Object.defineProperty(e,Sn(n.key),n);}}function wn(e,t,r){return t&&tr(e.prototype,t),Object.defineProperty(e,"prototype",{writable:false}),e}function Sn(e){var t=xn(e,"string");return he(t)=="symbol"?t:t+""}function xn(e,t){if(he(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(he(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return (String)(e)}var $e=function(){function e(t){_n(this,e),this._file=t,this.size=t.size;}return wn(e,[{key:"slice",value:function(r,n){if(er())return qe(this._file.slice(r,n));var o=this._file.slice(r,n),a=n>=this.size;return Promise.resolve({value:o,done:a})}},{key:"close",value:function(){}}])}();function de(e){"@babel/helpers - typeof";return de=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},de(e)}function En(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function rr(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||false,n.configurable=true,"value"in n&&(n.writable=true),Object.defineProperty(e,Pn(n.key),n);}}function Un(e,t,r){return t&&rr(e.prototype,t),Object.defineProperty(e,"prototype",{writable:false}),e}function Pn(e){var t=On(e,"string");return de(t)=="symbol"?t:t+""}function On(e,t){if(de(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(de(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return (String)(e)}function nr(e){return e===void 0?0:e.size!==void 0?e.size:e.length}function kn(e,t){if(e.concat)return e.concat(t);if(e instanceof Blob)return new Blob([e,t],{type:e.type});if(e.set){var r=new e.constructor(e.length+t.length);return r.set(e),r.set(t,e.length),r}throw new Error("Unknown data type")}var or=function(){function e(t){En(this,e),this._buffer=void 0,this._bufferOffset=0,this._reader=t,this._done=false;}return Un(e,[{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,a=n<=this._bufferOffset+nr(this._buffer);if(this._done||a){var u=this._getDataFromBuffer(r,n),f=u==null?this._done:false;return Promise.resolve({value:u,done:f})}return this._reader.read().then(function(h){var m=h.value,v=h.done;return v?o._done=true:o._buffer===void 0?o._buffer=m:o._buffer=kn(o._buffer,m),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=nr(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 Y(e){"@babel/helpers - typeof";return Y=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Y(e)}function Me(){Me=function(){return t};var e,t={},r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(l,i,s){l[i]=s.value;},a=typeof Symbol=="function"?Symbol:{},u=a.iterator||"@@iterator",f=a.asyncIterator||"@@asyncIterator",h=a.toStringTag||"@@toStringTag";function m(l,i,s){return Object.defineProperty(l,i,{value:s,enumerable:true,configurable:true,writable:true}),l[i]}try{m({},"");}catch{m=function(s,c,d){return s[c]=d};}function v(l,i,s,c){var d=i&&i.prototype instanceof I?i:I,p=Object.create(d.prototype),g=new G(c||[]);return o(p,"_invoke",{value:Ue(l,s,g)}),p}function y(l,i,s){try{return {type:"normal",arg:l.call(i,s)}}catch(c){return {type:"throw",arg:c}}}t.wrap=v;var j="suspendedStart",ae="suspendedYield",q="executing",A="completed",S={};function I(){}function R(){}function x(){}var T={};m(T,u,function(){return this});var $=Object.getPrototypeOf,N=$&&$($(K([])));N&&N!==r&&n.call(N,u)&&(T=N);var D=x.prototype=I.prototype=Object.create(T);function se(l){["next","throw","return"].forEach(function(i){m(l,i,function(s){return this._invoke(i,s)});});}function B(l,i){function s(d,p,g,b){var _=y(l[d],l,p);if(_.type!=="throw"){var P=_.arg,E=P.value;return E&&Y(E)=="object"&&n.call(E,"__await")?i.resolve(E.__await).then(function(O){s("next",O,g,b);},function(O){s("throw",O,g,b);}):i.resolve(E).then(function(O){P.value=O,g(P);},function(O){return s("throw",O,g,b)})}b(_.arg);}var c;o(this,"_invoke",{value:function(p,g){function b(){return new i(function(_,P){s(p,g,_,P);})}return c=c?c.then(b,b):b()}});}function Ue(l,i,s){var c=j;return function(d,p){if(c===q)throw Error("Generator is already running");if(c===A){if(d==="throw")throw p;return {value:e,done:true}}for(s.method=d,s.arg=p;;){var g=s.delegate;if(g){var b=le(g,s);if(b){if(b===S)continue;return b}}if(s.method==="next")s.sent=s._sent=s.arg;else if(s.method==="throw"){if(c===j)throw c=A,s.arg;s.dispatchException(s.arg);}else s.method==="return"&&s.abrupt("return",s.arg);c=q;var _=y(l,i,s);if(_.type==="normal"){if(c=s.done?A:ae,_.arg===S)continue;return {value:_.arg,done:s.done}}_.type==="throw"&&(c=A,s.method="throw",s.arg=_.arg);}}}function le(l,i){var s=i.method,c=l.iterator[s];if(c===e)return i.delegate=null,s==="throw"&&l.iterator.return&&(i.method="return",i.arg=e,le(l,i),i.method==="throw")||s!=="return"&&(i.method="throw",i.arg=new TypeError("The iterator does not provide a '"+s+"' method")),S;var d=y(c,l.iterator,i.arg);if(d.type==="throw")return i.method="throw",i.arg=d.arg,i.delegate=null,S;var p=d.arg;return p?p.done?(i[l.resultName]=p.value,i.next=l.nextLoc,i.method!=="return"&&(i.method="next",i.arg=e),i.delegate=null,S):p:(i.method="throw",i.arg=new TypeError("iterator result is not an object"),i.delegate=null,S)}function Pe(l){var i={tryLoc:l[0]};1 in l&&(i.catchLoc=l[1]),2 in l&&(i.finallyLoc=l[2],i.afterLoc=l[3]),this.tryEntries.push(i);}function M(l){var i=l.completion||{};i.type="normal",delete i.arg,l.completion=i;}function G(l){this.tryEntries=[{tryLoc:"root"}],l.forEach(Pe,this),this.reset(true);}function K(l){if(l||l===""){var i=l[u];if(i)return i.call(l);if(typeof l.next=="function")return l;if(!isNaN(l.length)){var s=-1,c=function d(){for(;++s<l.length;)if(n.call(l,s))return d.value=l[s],d.done=false,d;return d.value=e,d.done=true,d};return c.next=c}}throw new TypeError(Y(l)+" is not iterable")}return R.prototype=x,o(D,"constructor",{value:x,configurable:true}),o(x,"constructor",{value:R,configurable:true}),R.displayName=m(x,h,"GeneratorFunction"),t.isGeneratorFunction=function(l){var i=typeof l=="function"&&l.constructor;return !!i&&(i===R||(i.displayName||i.name)==="GeneratorFunction")},t.mark=function(l){return Object.setPrototypeOf?Object.setPrototypeOf(l,x):(l.__proto__=x,m(l,h,"GeneratorFunction")),l.prototype=Object.create(D),l},t.awrap=function(l){return {__await:l}},se(B.prototype),m(B.prototype,f,function(){return this}),t.AsyncIterator=B,t.async=function(l,i,s,c,d){d===void 0&&(d=Promise);var p=new B(v(l,i,s,c),d);return t.isGeneratorFunction(i)?p:p.next().then(function(g){return g.done?g.value:p.next()})},se(D),m(D,h,"Generator"),m(D,u,function(){return this}),m(D,"toString",function(){return "[object Generator]"}),t.keys=function(l){var i=Object(l),s=[];for(var c in i)s.push(c);return s.reverse(),function d(){for(;s.length;){var p=s.pop();if(p in i)return d.value=p,d.done=false,d}return d.done=true,d}},t.values=K,G.prototype={constructor:G,reset:function(i){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=false,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(M),!i)for(var s in this)s.charAt(0)==="t"&&n.call(this,s)&&!isNaN(+s.slice(1))&&(this[s]=e);},stop:function(){this.done=true;var i=this.tryEntries[0].completion;if(i.type==="throw")throw i.arg;return this.rval},dispatchException:function(i){if(this.done)throw i;var s=this;function c(P,E){return g.type="throw",g.arg=i,s.next=P,E&&(s.method="next",s.arg=e),!!E}for(var d=this.tryEntries.length-1;d>=0;--d){var p=this.tryEntries[d],g=p.completion;if(p.tryLoc==="root")return c("end");if(p.tryLoc<=this.prev){var b=n.call(p,"catchLoc"),_=n.call(p,"finallyLoc");if(b&&_){if(this.prev<p.catchLoc)return c(p.catchLoc,true);if(this.prev<p.finallyLoc)return c(p.finallyLoc)}else if(b){if(this.prev<p.catchLoc)return c(p.catchLoc,true)}else {if(!_)throw Error("try statement without catch or finally");if(this.prev<p.finallyLoc)return c(p.finallyLoc)}}}},abrupt:function(i,s){for(var c=this.tryEntries.length-1;c>=0;--c){var d=this.tryEntries[c];if(d.tryLoc<=this.prev&&n.call(d,"finallyLoc")&&this.prev<d.finallyLoc){var p=d;break}}p&&(i==="break"||i==="continue")&&p.tryLoc<=s&&s<=p.finallyLoc&&(p=null);var g=p?p.completion:{};return g.type=i,g.arg=s,p?(this.method="next",this.next=p.finallyLoc,S):this.complete(g)},complete:function(i,s){if(i.type==="throw")throw i.arg;return i.type==="break"||i.type==="continue"?this.next=i.arg:i.type==="return"?(this.rval=this.arg=i.arg,this.method="return",this.next="end"):i.type==="normal"&&s&&(this.next=s),S},finish:function(i){for(var s=this.tryEntries.length-1;s>=0;--s){var c=this.tryEntries[s];if(c.finallyLoc===i)return this.complete(c.completion,c.afterLoc),M(c),S}},catch:function(i){for(var s=this.tryEntries.length-1;s>=0;--s){var c=this.tryEntries[s];if(c.tryLoc===i){var d=c.completion;if(d.type==="throw"){var p=d.arg;M(c);}return p}}throw Error("illegal catch attempt")},delegateYield:function(i,s,c){return this.delegate={iterator:K(i),resultName:s,nextLoc:c},this.method==="next"&&(this.arg=e),S}},t}function ir(e,t,r,n,o,a,u){try{var f=e[a](u),h=f.value;}catch(m){r(m);return}f.done?t(h):Promise.resolve(h).then(n,o);}function Rn(e){return function(){var t=this,r=arguments;return new Promise(function(n,o){var a=e.apply(t,r);function u(h){ir(a,n,o,u,f,"next",h);}function f(h){ir(a,n,o,u,f,"throw",h);}u(void 0);})}}function Dn(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function ar(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||false,n.configurable=true,"value"in n&&(n.writable=true),Object.defineProperty(e,jn(n.key),n);}}function Cn(e,t,r){return t&&ar(e.prototype,t),Object.defineProperty(e,"prototype",{writable:false}),e}function jn(e){var t=Tn(e,"string");return Y(t)=="symbol"?t:t+""}function Tn(e,t){if(Y(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(Y(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return (String)(e)}var sr=function(){function e(){Dn(this,e);}return Cn(e,[{key:"openFile",value:function(){var t=Rn(Me().mark(function n(o,a){var u;return Me().wrap(function(h){for(;;)switch(h.prev=h.next){case 0:if(!(Se()&&o&&typeof o.uri<"u")){h.next=11;break}return h.prev=1,h.next=4,ze(o.uri);case 4:return u=h.sent,h.abrupt("return",new $e(u));case 8:throw h.prev=8,h.t0=h.catch(1),new Error("tus: cannot fetch `file.uri` as Blob, make sure the uri is correct and accessible. ".concat(h.t0));case 11:if(!(typeof o.slice=="function"&&typeof o.size<"u")){h.next=13;break}return h.abrupt("return",Promise.resolve(new $e(o)));case 13:if(typeof o.read!="function"){h.next=18;break}if(a=Number(a),Number.isFinite(a)){h.next=17;break}return h.abrupt("return",Promise.reject(new Error("cannot create source for stream without a finite value for the `chunkSize` option")));case 17:return h.abrupt("return",Promise.resolve(new or(o,a)));case 18:return h.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 h.stop()}},n,null,[[1,8]])}));function r(n,o){return t.apply(this,arguments)}return r}()}])}();function Ge(e,t){return Se()?Promise.resolve(An(e,t)):Promise.resolve(["tus-br",e.name,e.type,e.size,e.lastModified,t.endpoint].join("-"))}function An(e,t){var r=e.exif?Ln(JSON.stringify(e.exif)):"noexif";return ["tus-rn",e.name||"noname",e.size||"nosize",r,t.endpoint].join("/")}function Ln(e){var t=0;if(e.length===0)return t;for(var r=0;r<e.length;r++){var n=e.charCodeAt(r);t=(t<<5)-t+n,t&=t;}return t}function ye(e){"@babel/helpers - typeof";return ye=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ye(e)}function Ke(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function lr(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||false,n.configurable=true,"value"in n&&(n.writable=true),Object.defineProperty(e,Fn(n.key),n);}}function Xe(e,t,r){return t&&lr(e.prototype,t),Object.defineProperty(e,"prototype",{writable:false}),e}function Fn(e){var t=In(e,"string");return ye(t)=="symbol"?t:t+""}function In(e,t){if(ye(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(ye(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return (String)(e)}var ur=function(){function e(){Ke(this,e);}return Xe(e,[{key:"createRequest",value:function(r,n){return new Nn(r,n)}},{key:"getName",value:function(){return "XHRHttpStack"}}])}();var Nn=function(){function e(t,r){Ke(this,e),this._xhr=new XMLHttpRequest,this._xhr.open(t,r,true),this._method=t,this._url=r,this._headers={};}return Xe(e,[{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,a){r._xhr.onload=function(){o(new Bn(r._xhr));},r._xhr.onerror=function(u){a(u);},r._xhr.send(n);})}},{key:"abort",value:function(){return this._xhr.abort(),Promise.resolve()}},{key:"getUnderlyingObject",value:function(){return this._xhr}}])}(),Bn=function(){function e(t){Ke(this,e),this._xhr=t;}return Xe(e,[{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 me(e){"@babel/helpers - typeof";return me=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},me(e)}function Hn(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function fr(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||false,n.configurable=true,"value"in n&&(n.writable=true),Object.defineProperty(e,qn(n.key),n);}}function zn(e,t,r){return t&&fr(e.prototype,t),Object.defineProperty(e,"prototype",{writable:false}),e}function qn(e){var t=$n(e,"string");return me(t)=="symbol"?t:t+""}function $n(e,t){if(me(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(me(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return (String)(e)}var We=false;try{We="localStorage"in window,xe="tusSupport",Ve=localStorage.getItem(xe),localStorage.setItem(xe,Ve),Ve===null&&localStorage.removeItem(xe);}catch(e){if(e.code===e.SECURITY_ERR||e.code===e.QUOTA_EXCEEDED_ERR)We=false;else throw e}var xe,Ve,cr=We,pr=function(){function e(){Hn(this,e);}return zn(e,[{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),a="tus::".concat(r,"::").concat(o);return localStorage.setItem(a,JSON.stringify(n)),Promise.resolve(a)}},{key:"_findEntries",value:function(r){for(var n=[],o=0;o<localStorage.length;o++){var a=localStorage.key(o);if(a.indexOf(r)===0)try{var u=JSON.parse(localStorage.getItem(a));u.urlStorageKey=a,n.push(u);}catch{}}return n}}])}();function ie(e){"@babel/helpers - typeof";return ie=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ie(e)}function Mn(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function hr(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||false,n.configurable=true,"value"in n&&(n.writable=true),Object.defineProperty(e,gr(n.key),n);}}function Gn(e,t,r){return r&&hr(e,r),Object.defineProperty(e,"prototype",{writable:false}),e}function Kn(e,t,r){return t=Ee(t),Xn(e,mr()?Reflect.construct(t,r||[],Ee(e).constructor):t.apply(e,r))}function Xn(e,t){if(t&&(ie(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Vn(e)}function Vn(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function mr(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));}catch{}return (mr=function(){return !!e})()}function Ee(e){return Ee=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},Ee(e)}function Wn(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:true,configurable:true}}),Object.defineProperty(e,"prototype",{writable:false}),t&&Ye(e,t);}function Ye(e,t){return Ye=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,o){return n.__proto__=o,n},Ye(e,t)}function dr(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),r.push.apply(r,n);}return r}function oe(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?dr(Object(r),true).forEach(function(n){Yn(e,n,r[n]);}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):dr(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n));});}return e}function Yn(e,t,r){return t=gr(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:true,configurable:true,writable:true}):e[t]=r,e}function gr(e){var t=Zn(e,"string");return ie(t)=="symbol"?t:t+""}function Zn(e,t){if(ie(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(ie(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return (t==="string"?String:Number)(e)}var yr=oe(oe({},we.defaultOptions),{},{httpStack:new ur,fileReader:new sr,urlStorage:cr?new pr:new at,fingerprint:Ge}),vr=function(e){function t(){var r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:null,n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return Mn(this,t),n=oe(oe({},yr),n),Kn(this,t,[r,n])}return Wn(t,e),Gn(t,null,[{key:"terminate",value:function(n){var o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return o=oe(oe({},yr),o),we.terminate(n,o)}}])}(we);var w=class extends i{constructor(){super(...arguments);this.disableCompletion=false;this._progress=0;this._completed=false;this._dragging=false;this._error=null;this.playableEmitted=false;this.languageController=new d(this);this.lastState="initial";this.lastProgress=-1;}connectedCallback(){super.connectedCallback(),this.addEventListener("click",this.handleActionClick),this.addEventListener("keydown",this.handleActionKeyDown),this.languageController.locale=this.locale||"en",this.embedChannel=a$3.connect(this.token),this.embedChannel.upload_id&&(this._upload_id=this.embedChannel.upload_id),this.embedChannel.channel.on("initiate",({upload_id:r})=>{this._upload_id=r,this.embedChannel.upload_id=r,this.playableEmitted=false;}),this.embedChannel.channel.on("completed",this.completed.bind(this)),this.embedChannel.channel.on("rendition",this.rendition.bind(this)),this.embedChannel.channel.on("error",this.error.bind(this));}requestUpdate(r,n){super.requestUpdate(r,n),r==="locale"&&(this.languageController.locale=this.locale);}reset(){this._progress=0,this._completed=false,this._error=null,this.playableEmitted=false,this.currentEmbed=void 0,this.embedChannel.channel.push("reset",{});}disconnectedCallback(){this.removeEventListener("click",this.handleActionClick),this.removeEventListener("keydown",this.handleActionKeyDown),super.disconnectedCallback();}handleDrop(r){r.preventDefault(),this._dragging=false;let n=r.dataTransfer;if(!n)return;let o=[];if(n.items){for(let u of n.items)if(u.kind==="file"){let f=u.getAsFile();f&&o.push(f);}}else if(n.files)for(let u of n.files)o.push(u);if(!o.length)return;this._error=null;let a=false;for(let u of o)this.isSupportedFile(u)?(a||(this._progress=1,a=true),this.upload(u)):this.handleUnsupportedFile(u);}handleForm(r){let n=r.target;if(n.files){n.files.length&&(this._error=null);let o=false;for(let a of n.files)this.isSupportedFile(a)?(o||(this._progress=1,o=true),this.upload(a)):this.handleUnsupportedFile(a);n.value="";}}upload(r){this.dispatchEvent(new CustomEvent("upload",{bubbles:true,composed:true,detail:{file:r}})),this._error=null;let n=new vr(r,{endpoint:a$4.upload.endpoint,retryDelays:[0,3e3,5e3,1e4,2e4,6e4,6e4],metadata:{title:r.name,filetype:r.type,token:this.token,upload_id:this._upload_id},onError:o=>{console.log(o),this.dispatchEvent(new CustomEvent("failed",{bubbles:true,composed:true,detail:o}));},onProgress:(o,a)=>{let u=Math.round(o/a*100);u>this._progress&&(this._progress=u),this.dispatchEvent(new CustomEvent("progress",{bubbles:true,composed:true,detail:{progress:u}}));},onSuccess:()=>{this._progress=100,this.dispatchEvent(new CustomEvent("processing",{bubbles:true,composed:true}));},removeFingerprintOnSuccess:true});n.findPreviousUploads().then(o=>{o.length&&n.resumeFromPreviousUpload(o[0]),n.start();});}completed(r){this.currentEmbed=r?.embed,this.disableCompletion||(this._completed=true),this.dispatchEvent(new CustomEvent("completed",{bubbles:true,composed:true,detail:r}));}rendition(r){!this.playableEmitted&&this.isPlayableRendition(r)&&(this.playableEmitted=true,this.dispatchEvent(new CustomEvent("playable",{bubbles:true,composed:true,detail:{embed:this.currentEmbed}}))),this.dispatchEvent(new CustomEvent("rendition",{bubbles:true,composed:true,detail:r}));}error(r){console.warn(`[mave-upload] ${r.message}`),this._error={reason:"upload error",message:r.message},this._progress=0,this._completed=false,this.dispatchEvent(new CustomEvent("error",{bubbles:true,detail:r}));}isPlayableRendition(r){return typeof r?.container=="string"&&r.container==="hls"&&r?.type==="video"}render(){switch(this.currentState){case "error":return this.renderError();case "uploading":return this.renderUploading();case "processing":return this.renderProcessing();case "done":return this.renderDone();default:return this.renderInitial()}}styleOpacity(){return this.languageController.loaded?this._upload_id?{}:{pointerEvents:"none",opacity:"0.5"}:{pointerEvents:"none",opacity:"0"}}styleFont(){return this.font?{fontFamily:this.font}:{fontFamily:"system-ui"}}get currentState(){return this._error?"error":this._completed?"done":this._progress>=100&&this._progress>0?"processing":this._progress>0?"uploading":"initial"}openFileDialog(){this.fileInput&&!this.fileInput.disabled&&this.fileInput.click();}findActionTarget(r){for(let n of r.composedPath())if(n instanceof HTMLElement&&n.hasAttribute("data-mave-upload-select"))return n;return null}handleActionClick(r){this.findActionTarget(r)&&(r.preventDefault(),this.openFileDialog());}handleActionKeyDown(r){if(r.key!=="Enter"&&r.key!==" ")return;this.findActionTarget(r)&&(r.preventDefault(),this.openFileDialog());}blockSubmit(r){r.preventDefault();}handleDragEnter(r){r.preventDefault(),this._dragging=true;}handleDragOver(r){r.preventDefault(),r.dataTransfer&&(r.dataTransfer.dropEffect="copy"),this._dragging=true;}handleDragLeave(r){r.preventDefault();let n=r.currentTarget,o=r.relatedTarget;if(!n){this._dragging=false;return}(!o||!(o instanceof Node)||!n.contains(o))&&(this._dragging=false);}isSupportedFile(r){let n=(r.type||"").toLowerCase(),o=w.getFileExtension(r);return n.startsWith("video/")?!o||w.SUPPORTED_VIDEO_EXTENSIONS.has(o):n.startsWith("audio/")?!o||w.SUPPORTED_AUDIO_EXTENSIONS.has(o):o?!!(w.SUPPORTED_VIDEO_EXTENSIONS.has(o)||w.SUPPORTED_AUDIO_EXTENSIONS.has(o)):false}static getFileExtension(r){let n=r.name||"",o=n.lastIndexOf(".");if(!(o===-1||o===n.length-1))return n.slice(o+1).toLowerCase()}handleUnsupportedFile(r){let n={file:r,reason:"unsupported type",allowedExtensions:{video:Array.from(w.SUPPORTED_VIDEO_EXTENSIONS),audio:Array.from(w.SUPPORTED_AUDIO_EXTENSIONS)}};this._error=n,this._progress=0,this._completed=false,this.dispatchEvent(new CustomEvent("invalid",{bubbles:true,composed:true,detail:{...n,message:b$2("unsupported file type")}}));}updated(r){super.updated(r);let n=this._progress||0,o=this.currentState;this.setAttribute("state",o),this.setAttribute("progress",`${n}`),this.toggleAttribute("drag-over",this._dragging),this.toggleAttribute("ready",!!this._upload_id&&this.languageController.loaded);let a=o!==this.lastState,u=n!==this.lastProgress,f=r.has("_dragging");(a||u||f)&&this.dispatchEvent(new CustomEvent("statechange",{bubbles:true,composed:true,detail:{state:o,progress:n,dragging:this._dragging,error:this._error}})),this.lastState=o,this.lastProgress=n;}renderInitial(){let r=this.color?this.color:"#1997FF",n=this.radius?this.radius:"16px";return c$2`<form
4
4
  class="state state--initial"
5
5
  style=${a$5({...this.styleOpacity(),...this.styleFont()})}
6
6
  @submit=${this.blockSubmit}
@@ -29,6 +29,40 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
29
29
  @change=${this.handleForm}
30
30
  hidden
31
31
  />
32
+ </form>`}renderError(){let r=this.color?this.color:"#1997FF",n=this.radius?this.radius:"16px",o=this._error?.file?.name,a=this._error?.message??(this._error?.reason==="unsupported type"?b$2("please choose a video or audio file in a supported format."):b$2("something went wrong. please try again.")),u=this._error?.reason==="unsupported type"&&o;return c$2`<form
33
+ class="state state--error"
34
+ style=${a$5({...this.styleOpacity(),...this.styleFont()})}
35
+ @submit=${this.blockSubmit}
36
+ @dragenter=${this.handleDragEnter}
37
+ @dragover=${this.handleDragOver}
38
+ @dragleave=${this.handleDragLeave}
39
+ @drop=${this.handleDrop}
40
+ >
41
+ <slot name="error">
42
+ <div class="upload-default-error" role="alert">
43
+ ${u?c$2`<div class="upload-default-error-filename">${o}</div>`:null}
44
+ <div class="upload-default-error-title">
45
+ ${this._error?.reason==="unsupported type"?b$2("unsupported file type"):b$2("upload failed")}
46
+ </div>
47
+ <div class="upload-default-error-subtitle">${a}</div>
48
+ <button
49
+ type="button"
50
+ data-mave-upload-select
51
+ class="upload-default-button"
52
+ style=${a$5({background:r,borderRadius:n})}
53
+ >
54
+ ${b$2("try again")}
55
+ </button>
56
+ </div>
57
+ </slot>
58
+ <input
59
+ id="mave-upload-input"
60
+ .disabled=${!this._upload_id}
61
+ type="file"
62
+ accept="video/*, audio/*"
63
+ @change=${this.handleForm}
64
+ hidden
65
+ />
32
66
  </form>`}renderUploading(){let r=Math.max(0,Math.min(100,this._progress||0));return c$2`<div class="state state--uploading" style=${a$5(this.styleFont())}>
33
67
  <slot name="uploading">
34
68
  <div class="upload-default-progress" role="status">
@@ -76,6 +110,40 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
76
110
  gap: 12px;
77
111
  }
78
112
 
113
+ .state--error {
114
+ transition: box-shadow 160ms ease;
115
+ gap: 12px;
116
+ }
117
+
118
+ .upload-default-error {
119
+ display: flex;
120
+ flex-direction: column;
121
+ align-items: center;
122
+ gap: 12px;
123
+ text-align: center;
124
+ width: 100%;
125
+ padding: 0 24px;
126
+ }
127
+
128
+ .upload-default-error-filename {
129
+ font-size: 14px;
130
+ font-weight: 500;
131
+ color: #111;
132
+ max-width: 320px;
133
+ overflow-wrap: anywhere;
134
+ }
135
+
136
+ .upload-default-error-title {
137
+ font-size: 24px;
138
+ font-weight: 400;
139
+ color: #e5484d;
140
+ }
141
+
142
+ .upload-default-error-subtitle {
143
+ opacity: 0.6;
144
+ max-width: 320px;
145
+ }
146
+
79
147
  .upload-default-title {
80
148
  font-size: 32px;
81
149
  padding-bottom: 2px;
@@ -151,7 +219,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
151
219
  padding-bottom: 24px;
152
220
  text-align: center;
153
221
  }
154
- `,c([a$1()],w.prototype,"token",2),c([a$1()],w.prototype,"locale",2),c([a$1()],w.prototype,"color",2),c([a$1()],w.prototype,"font",2),c([a$1()],w.prototype,"radius",2),c([a$1({type:Boolean})],w.prototype,"disableCompletion",2),c([b$1()],w.prototype,"_progress",2),c([b$1()],w.prototype,"_upload_id",2),c([b$1()],w.prototype,"_completed",2),c([b$1()],w.prototype,"_dragging",2),c([c$1("#mave-upload-input")],w.prototype,"fileInput",2),w=c([a$2()],w);typeof window<"u"&&window.customElements&&(window.customElements.get("mave-upload")||window.customElements.define("mave-upload",w));/*! Bundled license information:
222
+ `,c([a$1()],w.prototype,"token",2),c([a$1()],w.prototype,"locale",2),c([a$1()],w.prototype,"color",2),c([a$1()],w.prototype,"font",2),c([a$1()],w.prototype,"radius",2),c([a$1({type:Boolean})],w.prototype,"disableCompletion",2),c([b$1()],w.prototype,"_progress",2),c([b$1()],w.prototype,"_upload_id",2),c([b$1()],w.prototype,"_completed",2),c([b$1()],w.prototype,"_dragging",2),c([b$1()],w.prototype,"_error",2),c([c$1("#mave-upload-input")],w.prototype,"fileInput",2),w=c([a$2()],w);typeof window<"u"&&window.customElements&&(window.customElements.get("mave-upload")||window.customElements.define("mave-upload",w));/*! Bundled license information:
155
223
 
156
224
  tus-js-client/lib.esm/upload.js:
157
225
  (*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE *)