1import{f as Me,g as Bt,r as F,j as l}from"./react-vendor-DDlTsOEd.js";import{D as qt,a as Ht,b as Mt,c as Gt}from"./dialog-CWLM8hAZ.js";import{g as Vt,K as Q,n as me,A as K,l as Y,f as Te,X as yt,R as Kt,aj as gt,s as Yt,J as Wt,ad as oe,F as vt}from"./index-dMYrr1t8.js";import{U as se}from"./upload-Csh4KAbr.js";import{F as ze}from"./AdminLayout-C0t6TWD9.js";import{C as bt}from"./circle-x-DRWcnEQU.js";import{I as xt}from"./image-CrlXsVPe.js";const Xt=[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]],Fe=Vt("folder-open",Xt);function Pe(e){"@babel/helpers - typeof";return Pe=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},Pe(e)}function Jt(e,t,r){return Object.defineProperty(e,"prototype",{writable:!1}),e}function Zt(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Qt(e,t,r){return t=ue(t),er(e,Le()?Reflect.construct(t,r||[],ue(e).constructor):t.apply(e,r))}function er(e,t){if(t&&(Pe(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return tr(e)}function tr(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function rr(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:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&le(e,t)}function Ee(e){var t=typeof Map=="function"?new Map:void 0;return Ee=function(n){if(n===null||!or(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,a)}function a(){return nr(n,arguments,ue(this).constructor)}return a.prototype=Object.create(n.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}),le(a,n)},Ee(e)}function nr(e,t,r){if(Le())return Reflect.construct.apply(null,arguments);var n=[null];n.push.apply(n,t);var a=new(e.bind.apply(e,n));return r&&le(a,r.prototype),a}function Le(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Le=function(){return!!e})()}function or(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,a){return n.__proto__=a,n},le(e,t)}function ue(e){return ue=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},ue(e)}var ye=(function(e){function t(r){var n,a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null,s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:null,c=arguments.length>3&&arguments[3]!==void 0?arguments[3]:null;if(Zt(this,t),n=Qt(this,t,[r]),n.originalRequest=s,n.originalResponse=c,n.causingError=a,a!=null&&(r+=", caused by ".concat(a.toString())),s!=null){var y=s.getHeader("X-Request-ID")||"n/a",f=s.getMethod(),x=s.getURL(),S=c?c.getStatus():"n/a",R=c?c.getBody()||"":"n/a";r+=", originated from request (method: ".concat(f,", url: ").concat(x,", response code: ").concat(S,", response text: ").concat(R,", request id: ").concat(y,")")}return n.message=r,n}return rr(t,e),Jt(t)})(Ee(Error));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 ar(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function ir(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,lr(n.key),n)}}function sr(e,t,r){return t&&ir(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function lr(e){var t=ur(e,"string");return ce(t)=="symbol"?t:t+""}function ur(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 cr=(function(){function e(){ar(this,e)}return sr(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)}}])})();const _t="3.7.8",fr=_t,ne=typeof Buffer=="function",Ge=typeof TextDecoder=="function"?new TextDecoder:void 0,Ve=typeof TextEncoder=="function"?new TextEncoder:void 0,dr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
1+/=",ae=Array.prototype.slice.call(dr),ge=(e=>{let t={};return e.forEach((r,n)=>t[r]=n),t})(ae),pr=/^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/,H=String.fromCharCode.bind(String),Ke=typeof Uint8Array.from=="function"?Uint8Array.from.bind(Uint8Array):e=>new Uint8Array(Array.prototype.slice.call(e,0)),wt=e=>e.replace(/=/g,"").replace(/[+\/]/g,t=>t=="+"?"-":"_"),jt=e=>e.replace(/[^A-Za-z0-9\+\/]/g,""),St=e=>{let t,r,n,a,s="";const c=e.length%3;for(let y=0;y<e.length;){if((r=e.charCodeAt(y++))>255||(n=e.charCodeAt(y++))>255||(a=e.charCodeAt(y++))>255)throw new TypeError("invalid character found");t=r<<16|n<<8|a,s+=ae[t>>18&63]+ae[t>>12&63]+ae[t>>6&63]+ae[t&63]}return c?s.slice(0,c-3)+"===".substring(c):s},Ie=typeof btoa=="function"?e=>btoa(e):ne?e=>Buffer.from(e,"binary").toString("base64"):St,Oe=ne?e=>Buffer.from(e).toString("base64"):e=>{let r=[];for(let n=0,a=e.length;n<a;n+=4096)r.push(H.apply(null,e.subarray(n,n+4096)));return Ie(r.join(""))},be=(e,t=!1)=>t?wt(Oe(e)):Oe(e),hr=e=>{if(e.length<2){var t=e.charCodeAt(0);return t<128?e:t<2048?H(192|t>>>6)+H(128|t&63):H(224|t>>>12&15)+H(128|t>>>6&63)+H(128|t&63)}else{var t=65536+(e.charCodeAt(0)-55296)*1024+(e.charCodeAt(1)-56320);return H(240|t>>>18&7)+H(128|t>>>12&63)+H(128|t>>>6&63)+H(128|t&63)}},mr=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,Ut=e=>e.replace(mr,hr),Ye=ne?e=>Buffer.from(e,"utf8").toString("base64"):Ve?e=>Oe(Ve.encode(e)):e=>Ie(Ut(e)),te=(e,t=!1)=>t?wt(Ye(e)):Ye(e),We=e=>te(e,!0),yr=/[\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 H((r>>>10)+55296)+H((r&1023)+56320);case 3:return H((15&e.charCodeAt(0))<<12|(63&e.charCodeAt(1))<<6|63&e.charCodeAt(2));default:return H((31&e.charCodeAt(0))<<6|63&e.charCodeAt(1))}},Nt=e=>e.replace(yr,gr),Pt=e=>{if(e=e.replace(/\s+/g,""),!pr.test(e))throw new TypeError("malformed base64.");e+="==".slice(2-(e.length&3));let t,r,n,a=[];for(let s=0;s<e.length;)t=ge[e.charAt(s++)]<<18|ge[e.charAt(s++)]<<12|(r=ge[e.charAt(s++)])<<6|(n=ge[e.charAt(s++)]),r===64?a.push(H(t>>16&255)):n===64?a.push(H(t>>16&255,t>>8&255)):a.push(H(t>>16&255,t>>8&255,t&255));return a.join("")},Be=typeof atob=="function"?e=>atob(jt(e)):ne?e=>Buffer.from(e,"base64").toString("binary"):Pt,Et=ne?e=>Ke(Buffer.from(e,"base64")):e=>Ke(Be(e).split("").map(t=>t.charCodeAt(0))),Ot=e=>Et(kt(e)),vr=ne?e=>Buffer.from(e,"base64").toString("utf8"):Ge?e=>Ge.decode(Et(e)):e=>Nt(Be(e)),kt=e=>jt(e.replace(/[-_]/g,t=>t=="-"?"+":"/")),ke=e=>vr(kt(e)),br=e=>{if(typeof e!="string")return!1;const t=e.replace(/\s+/g,"").replace(/={0,2}$/,"");return!/[^\s0-9a-zA-Z\+/]/.test(t)||!/[^\s0-9a-zA-Z\-_]/.test(t)},Rt=e=>({value:e,enumerable:!1,writable:!0,configurable:!0}),Ct=function(){const e=(t,r)=>Object.defineProperty(String.prototype,t,Rt(r));e("fromBase64",function(){return ke(this)}),e("toBase64",function(t){return te(this,t)}),e("toBase64URI",function(){return te(this,!0)}),e("toBase64URL",function(){return te(this,!0)}),e("toUint8Array",function(){return Ot(this)})},At=function(){const e=(t,r)=>Object.defineProperty(Uint8Array.prototype,t,Rt(r));e("toBase64",function(t){return be(this,t)}),e("toBase64URI",function(){return be(this,!0)}),e("toBase64URL",function(){return be(this,!0)})},xr=()=>{Ct(),At()},_r={version:_t,VERSION:fr,atob:Be,atobPolyfill:Pt,btoa:Ie,btoaPolyfill:St,fromBase64:ke,toBase64:te,encode:te,encodeURI:We,encodeURL:We,utob:Ut,btou:Nt,decode:ke,isValid:br,fromUint8Array:be,toUint8Array:Ot,extendString:Ct,extendUint8Array:At,extendBuiltins:xr};var Se,Xe;function wr(){return Xe||(Xe=1,Se=function(t,r){if(r=r.split(":")[0],t=+t,!t)return!1;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!1}return t!==0}),Se}var ve={},Je;function jr(){if(Je)return ve;Je=1;var e=Object.prototype.hasOwnProperty,t;function r(c){try{return decodeURIComponent(c.replace(/\+/g," "))}catch{return null}}function n(c){try{return encodeURIComponent(c)}catch{return null}}function a(c){for(var y=/([^=?#&]+)=?([^&]*)/g,f={},x;x=y.exec(c);){var S=r(x[1]),R=r(x[2]);S===null||R===null||S in f||(f[S]=R)}return f}function s(c,y){y=y||"";var f=[],x,S;
1typeof y!="string"&&(y="?");for(S in c)if(e.call(c,S)){if(x=c[S],!x&&(x===null||x===t||isNaN(x))&&(x=""),S=n(S),x=n(x),S===null||x===null)continue;f.push(S+"="+x)}return f.length?y+f.join("&"):""}return ve.stringify=s,ve.parse=a,ve}var Ue,Ze;function Sr(){if(Ze)return Ue;Ze=1;var e=wr(),t=jr(),r=/^[\x00-\x20\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]+/,n=/[\n\r\t]/g,a=/^[A-Za-z][A-Za-z0-9+-.]*:\/\//,s=/:\d+$/,c=/^([a-z][a-z0-9.+-]*:)?(\/\/)?([\\/]+)?([\S\s]*)/i,y=/^[a-zA-Z]:/;function f(_){return(_||"").toString().replace(r,"")}var x=[["#","hash"],["?","query"],function(g,b){return P(b.protocol)?g.replace(/\\/g,"/"):g},["/","pathname"],["@","auth",1],[NaN,"host",void 0,1,1],[/:(\d*)$/,"port",void 0,1],[NaN,"hostname",void 0,1,1]],S={hash:1,query:1};function R(_){var g;typeof window<"u"?g=window:typeof Me<"u"?g=Me:typeof self<"u"?g=self:g={};var b=g.location||{};_=_||b;var h={},d=typeof _,j;if(_.protocol==="blob:")h=new C(unescape(_.pathname),{});else if(d==="string"){h=new C(_,{});for(j in S)delete h[j]}
1else if(d==="object"){for(j in _)j in S||(h[j]=_[j]);h.slashes===void 0&&(h.slashes=a.test(_.href))}return h}function P(_){return _==="file:"||_==="ftp:"||_==="http:"||_==="https:"||_==="ws:"||_==="wss:"}function $(_,g){_=f(_),_=_.replace(n,""),g=g||{};var b=c.exec(_),h=b[1]?b[1].toLowerCase():"",d=!!b[2],j=!!b[3],k=0,U;return d?j?(U=b[2]+b[3]+b[4],k=b[2].length+b[3].length):(U=b[2]+b[4],k=b[2].length):j?(U=b[3]+b[4],k=b[3].length):U=b[4],h==="file:"?k>=2&&(U=U.slice(2)):P(h)?U=b[4]:h?d&&(U=U.slice(2)):k>=2&&P(g.protocol)&&(U=b[4]),{protocol:h,slashes:d||P(h),slashesCount:k,rest:U}}function B(_,g){if(_==="")return g;for(var b=(g||"/").split("/").slice(0,-1).concat(_.split("/")),h=b.length,d=b[h-1],j=!1,k=0;h--;)b[h]==="."?b.splice(h,1):b[h]===".."?(b.splice(h,1),k++):k&&(h===0&&(j=!0),b.splice(h,1),k--);return j&&b.unshift(""),(d==="."||d==="..")&&b.push(""),b.join("/")}function C(_,g,b){if(_=f(_),_=_.replace(n,""),!(this instanceof C))return new C(_,g,b);var h,d,j,k,U,D,N=x.slice(),z=typeof g,w=this,I=0;for(z!=="object"&&z!=="string"&&(b=g,g=null),b&&typeof b!="function"&&(b=t.parse),g=R(g),d=$(_||"",g),h=!d.protocol&&!d.slashes,w.slashes=d.slashes||h&&g.slashes,w.protocol=d.protocol||g.protocol||"",_=d.rest,(d.protocol==="file:"&&(d.slashesCount!==2||y.test(_))||!d.slashes&&(d.protocol||d.slashesCount<2||!P(w.protocol)))&&(N[3]=[/(.*)/,"pathname"]);I<N.length;I++){if(k=N[I],typeof k=="function"){_=k(_,w);continue}j=k[0],D=k[1],j!==j?w[D]=_:typeof j=="string"?(U=j==="@"?_.lastIndexOf(j):_.indexOf(j),~U&&(typeof k[2]=="number"?(w[D]=_.slice(0,U),_=_.slice(U+k[2])):(w[D]=_.slice(U),_=_.slice(0,U)))):(U=j.exec(_))&&(w[D]=U[1],_=_.slice(0,U.index)),w[D]=w[D]||h&&k[3]&&g[D]||"",k[4]&&(w[D]=w[D].toLowerCase())}b&&(w.query=b(w.query)),h&&g.slashes&&w.pathname.charAt(0)!=="/"&&(w.pathname!==""||g.pathname!=="")&&(w.pathname=B(w.pathname,g.pathname)),w.pathname.charAt(0)!=="/"&&P(w.protocol)&&(w.pathname="/"+w.pathname),e(w.port,w.protocol)||(w.host=w.hostname,w.port=""),w.username=w.password="",w.auth&&(U=w.auth.indexOf(":"),~U?(w.username=w.auth.slice(0,U),w.username=encodeURIComponent(decodeURIComponent(w.username)),w.password=w.auth.slice(U+1),w.password=encodeURIComponent(decodeURIComponent(w.password))):w.username=encodeURIComponent(decodeURIComponent(w.auth)),w.auth=w.password?w.username+":"+w.password:w.username),w.origin=w.protocol!=="file:"&&P(w.protocol)&&w.host?w.protocol+"//"+w.host:"null",w.href=w.toString()}function O(_,g,b){var h=this;switch(_){case"query":typeof g=="string"&&g.length&&(g=(b||t.parse)(g)),h[_]=g;break;case"port":h[_]=g,e(g,h.protocol)?g&&(h.host=h.hostname+":"+g):(h.host=h.hostname,h[_]="");break;case"hostname":h[_]=g,h.port&&(g+=":"+h.port),h.host=g;break;case"host":h[_]=g,s.test(g)?(g=g.split(":"),h.port=g.pop(),h.hostname=g.join(":")):(h.hostname=g,h.port="");break;case"protocol":h.protocol=g.toLowerCase(),h.slashes=!b;break;case"pathname":case"hash":if(g){var d=_==="pathname"?"/":"#";h[_]=g.charAt(0)!==d?d+g:g}else h[_]=g;break;case"username":case"password":h[_]=encodeURIComponent(g);break;case"auth":var j=g.indexOf(":");~j?(h.username=g.slice(0,j),h.username=encodeURIComponent(decodeURIComponent(h.username)),h.password=g.slice(j+1),h.password=encodeURIComponent(decodeURIComponent(h.password))):h.username=encodeURIComponent(decodeURIComponent(g))}for(var k=0;k<x.length;k++){var U=x[k];U[4]&&(h[U[1]]=h[U[1]].toLowerCase())}return h.auth=h.password?h.username+":"+h.password:h.username,h.origin=h.protocol!=="file:"&&P(h.protocol)&&h.host?h.protocol+"//"+h.host:"null",h.href=h.toString(),h}function L(_){(!_||typeof _!="function")&&(_=t.stringify);var g,b=this,h=b.host,d=b.protocol;d&&d.charAt(d.length-1)!==":"&&(d+=":");var j=d+(b.protocol&&b.slashes||P(b.protocol)?"//":"");return b.username?(j+=b.username,b.password&&(j+=":"+b.password),j+="@"):b.password?(j+=":"+b.password,j+="@"):b.protocol!=="file:"&&P(b.protocol)&&!h&&b.pathname!=="/"&&(j+="@"),(h[h.length-1]===":"||s.test(b.hostname)&&!b.port)&&(h+=":"),j+=h+b.pathname,g=typeof b.query=="object"?_(b.query):b.query,g&&(j+=g.charAt(0)!=="?"?"?"+g:g),b.hash&&(j+=b.hash),j}return C.prototype={set:O,toString:L},C.extractProtocol=$,C.location=R,C.trimLeft=f,C.qs=t,Ue=C,Ue}var Ur=Sr();const Nr=Bt(Ur);function Pr(){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 Re(){Re=function(){return t};var e,t={},r=Object.prototype,n=r.hasOwnProperty,a=Object.defineProperty||function(u,o,i){u[o]=i.value},s=typeof Symbol=="function"?Symbol:{},c=s.iterator||"@@iterator",y=s.asyncIterator||"@@asyncIterator",f=s.toStringTag||"@@toStringTag";function x(u,o,i){return Object.defineProperty(u,o,{value:i,enumerable:!0,configurable:!0,writable:!0}),u[o]}try{x({},"")}catch{x=function(i,p,v){return i[p]=v}}function S(u,o,i,p){var v=o&&o.prototype instanceof L?o:L,m=Object.create(v.prototype),E=new I(p||[]);return a(m,"_invoke",{value:D(u,i,E)}),m}function R(u,o,i){try{return{type:"normal",arg:u.call(o,i)}}catch(p){return{type:"throw",arg:p}}}t.wrap=S;var P="suspendedStart",$="suspendedYield",B="executing",C="completed",O={};function L(){}function _(){}function g(){}var b={};x(b,c,function(){return this});var h=Object.getPrototypeOf,d=h&&h(h(M([])));d&&d!==r&&n.call(d,c)&&(b=d);var j=g.prototype=L.prototype=Object.create(b);function k(u){["next","throw","return"].forEach(function(o){x(u,o,function(i){return this._invoke(o,i)})})}function U(u,o){function i(v,m,E,A){var T=R(u[v],u,m);if(T.type!=="throw"){var G=T.arg,q=G.value;return q&&W(q)=="object"&&n.call(q,"__await")?o.resolve(q.__await).then(function(V){i("next",V,E,A)},function(V){i("throw",V,E,A)}):o.resolve(q).then(function(V){G.value=V,E(G)},function(V){return i("throw",V,E,A)})}A(T.arg)}var p;a(this,"_invoke",{value:function(m,E){function A(){return new o(function(T,G){i(m,E,T,G)})}return p=p?p.then(A,A):A()}})}function D(u,o,i){var p=P;return function(v,m){if(p===B)throw Error("Generator is already running");if(p===C){if(v==="throw")throw m;return{value:e,done:!0}}for(i.method=v,i.arg=m;;){var E=i.delegate;if(E){var A=N(E,i);if(A){if(A===O)continue;return A}}if(i.method==="next")i.sent=i._sent=i.arg;else if(i.method==="throw"){if(p===P)throw p=C,i.arg;i.dispatchException(i.arg)}else i.method==="return"&&i.abrupt("return",i.arg);p=B;var T=R(u,o,i);if(T.type==="normal"){if(p=i.done?C:$,T.arg===O)continue;return{value:T.arg,done:i.done}}T.type==="throw"&&(p=C,i.method="throw",i.arg=T.arg)}}}function N(u,o){var i=o.method,p=u.iterator[i];if(p===e)return o.delegate=null,i==="throw"&&u.iterator.return&&
1(o.method="return",o.arg=e,N(u,o),o.method==="throw")||i!=="return"&&(o.method="throw",o.arg=new TypeError("The iterator does not provide a '"+i+"' method")),O;var v=R(p,u.iterator,o.arg);if(v.type==="throw")return o.method="throw",o.arg=v.arg,o.delegate=null,O;var m=v.arg;return m?m.done?(o[u.resultName]=m.value,o.next=u.nextLoc,o.method!=="return"&&(o.method="next",o.arg=e),o.delegate=null,O):m:(o.method="throw",o.arg=new TypeError("iterator result is not an object"),o.delegate=null,O)}function z(u){var o={tryLoc:u[0]};1 in u&&(o.catchLoc=u[1]),2 in u&&(o.finallyLoc=u[2],o.afterLoc=u[3]),this.tryEntries.push(o)}function w(u){var o=u.completion||{};o.type="normal",delete o.arg,u.completion=o}function I(u){this.tryEntries=[{tryLoc:"root"}],u.forEach(z,this),this.reset(!0)}function M(u){if(u||u===""){var o=u[c];if(o)return o.call(u);if(typeof u.next=="function")return u;if(!isNaN(u.length)){var i=-1,p=function v(){for(;++i<u.length;)if(n.call(u,i))return v.value=u[i],v.done=!1,v;return v.value=e,v.done=!0,v};return p.next=p}}throw new TypeError(W(u)+" is not iterable")}return _.prototype=g,a(j,"constructor",{value:g,configurable:!0}),a(g,"constructor",{value:_,configurable:!0}),_.displayName=x(g,f,"GeneratorFunction"),t.isGeneratorFunction=function(u){var o=typeof u=="function"&&u.constructor;return!!o&&(o===_||(o.displayName||o.name)==="GeneratorFunction")},t.mark=function(u){return Object.setPrototypeOf?Object.setPrototypeOf(u,g):(u.__proto__=g,x(u,f,"GeneratorFunction")),u.prototype=Object.create(j),u},t.awrap=function(u){return{__await:u}},k(U.prototype),x(U.prototype,y,function(){return this}),t.AsyncIterator=U,t.async=function(u,o,i,p,v){v===void 0&&(v=Promise);var m=new U(S(u,o,i,p),v);return t.isGeneratorFunction(o)?m:m.next().then(function(E){return E.done?E.value:m.next()})},k(j),x(j,f,"Generator"),x(j,c,function(){return this}),x(j,"toString",function(){return"[object Generator]"}),t.keys=function(u){var o=Object(u),i=[];for(var p in o)i.push(p);return i.reverse(),function v(){for(;i.length;){var m=i.pop();if(m in o)return v.value=m,v.done=!1,v}return v.done=!0,v}},t.values=M,I.prototype={constructor:I,reset:function(o){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(w),!o)for(var i in this)i.charAt(0)==="t"&&n.call(this,i)&&!isNaN(+i.slice(1))&&(this[i]=e)},stop:function(){this.done=!0;var o=this.tryEntries[0].completion;if(o.type==="throw")throw o.arg;return this.rval},dispatchException:function(o){if(this.done)throw o;var i=this;function p(G,q){return E.type="throw",E.arg=o,i.next=G,q&&(i.method="next",i.arg=e),!!q}for(var v=this.tryEntries.length-1;v>=0;--v){var m=this.tryEntries[v],E=m.completion;if(m.tryLoc==="root")return p("end");if(m.tryLoc<=this.prev){var A=n.call(m,"catchLoc"),T=n.call(m,"finallyLoc");if(A&&T){if(this.prev<m.catchLoc)return p(m.catchLoc,!0);if(this.prev<m.finallyLoc)return p(m.finallyLoc)}else if(A){if(this.prev<m.catchLoc)return p(m.catchLoc,!0)}else{if(!T)throw Error("try statement without catch or finally");if(this.prev<m.finallyLoc)return p(m.finallyLoc)}}}},abrupt:function(o,i){for(var p=this.tryEntries.length-1;p>=0;--p){var v=this.tryEntries[p];if(v.tryLoc<=this.prev&&n.call(v,"finallyLoc")&&this.prev<v.finallyLoc){var m=v;break}}m&&(o==="break"||o==="continue")&&m.tryLoc<=i&&i<=m.finallyLoc&&(m=null);var E=m?m.completion:{};return E.type=o,E.arg=i,m?(this.method="next",this.next=m.finallyLoc,O):this.complete(E)},complete:function(o,i){if(o.type==="throw")throw o.arg;return o.type==="break"||o.type==="continue"?this.next=o.arg:o.type==="return"?(this.rval=this.arg=o.arg,this.method="return",this.next="end"):o.type==="normal"&&i&&(this.next=i),O},finish:function(o){for(var i=this.tryEntries.length-1;i>=0;--i){var p=this.tryEntries[i];if(p.finallyLoc===o)return this.complete(p.completion,p.afterLoc),w(p),O}},catch:function(o){for(var i=this.tryEntries.length-1;i>=0;--i){var p=this.tryEntries[i];if(p.tryLoc===o){var v=p.completion;if(v.type==="throw"){var m=v.arg;w(p)}return m}}throw Error("illegal catch attempt")},delegateYield:function(o,i,p){return this.delegate={iterator:M(o),resultName:i,nextLoc:p},this.method==="next"&&(this.arg=e),O}},t}function Qe(e,t,r,n,a,s,c){try{var y=e[s](c),f=y.value}catch(x){r(x);return}
1y.done?t(f):Promise.resolve(f).then(n,a)}function Er(e){return function(){var t=this,r=arguments;return new Promise(function(n,a){var s=e.apply(t,r);function c(f){Qe(s,n,a,c,y,"next",f)}function y(f){Qe(s,n,a,c,y,"throw",f)}c(void 0)})}}function $t(e,t){return Rr(e)||kr(e,t)||Dt(e,t)||Or()}function Or(){throw new TypeError(`Invalid attempt to destructure non-iterable instance. 2In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function kr(e,t){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var n,a,s,c,y=[],f=!0,x=!1;try{if(s=(r=r.call(e)).next,t!==0)for(;!(f=(n=s.call(r)).done)&&(y.push(n.value),y.length!==t);f=!0);}catch(S){x=!0,a=S}finally{try{if(!f&&r.return!=null&&(c=r.return(),Object(c)!==c))return}finally{if(x)throw a}}return y}}function Rr(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 Cr(e,t){var r=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=Dt(e))||t){r&&(e=r);var n=0,a=function(){};return{s:a,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(x){throw x},f:a}}throw new TypeError(`Invalid attempt to iterate non-iterable instance. 3In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var s=!0,c=!1,y;return{s:function(){r=r.call(e)},n:function(){var x=r.next();return s=x.done,x},e:function(x){c=!0,y=x},f:function(){try{!s&&r.return!=null&&r.return()}finally{if(c)throw y}}}}function Dt(e,t){if(e){if(typeof e=="string")return et(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 et(e,t)}}function et(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 tt(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function J(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?tt(Object(r),!0).forEach(function(n){Ar(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):tt(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function Ar(e,t,r){return t=Tt(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function $r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function rt(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,Tt(n.key),n)}}function Dr(e,t,r){return t&&rt(e.prototype,t),r&&rt(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function Tt(e){var t=Tr(e,"string");return W(t)=="symbol"?t:t+""}function Tr(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 xe="tus-v1",_e="ietf-draft-03",ie="ietf-draft-05",zr={endpoint:null,uploadUrl:null,metadata:{},metadataForPartialUploads:{},fingerprint:null,uploadSize:null,onProgress:null,onChunkComplete:null,onSuccess:null,onError:null,onUploadUrlAvailable:null,overridePatchMethod:!1,headers:{},addRequestId:!1,onBeforeRequest:null,onAfterResponse:null,onShouldRetry:zt,chunkSize:Number.POSITIVE_INFINITY,retryDelays:[0,1e3,3e3,5e3],parallelUploads:1,parallelUploadBoundaries:null,storeFingerprintForResuming:!0,removeFingerprintOnSuccess:!1,uploadLengthDeferred:!1,uploadDataDuringCreation:!1,urlStorage:null,fileReader:null,httpStack:null,protocol:xe},we=(function(){function e(t,r){$r(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=!1,this._size=null,this._source=null,this._retryAttempt=0,this._retryTimeout=null,this._offsetBeforeRetry=0,this._parallelUploads=null,this._parallelUploadUrls=null}return Dr(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(![xe,_e,ie].includes(this.options.protocol)){this._emitError(new Error("tus: unsupported protocol ".concat(this.options.protocol)));return}if(!this.options.endpoint&&!this.options.uploadUrl&&!this.url){this._emitError(new Error("tus: neither an endpoint or an upload URL is provided"));return}var a=this.options.retryDelays;if(a!=null&&Object.prototype.toString.call(a)!=="[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 s=0,c=["uploadUrl","uploadSize","uploadLengthDeferred"];s<c.length;s++){var y=c[s];if(this.options[y]){this._emitError(new Error("tus: cannot use the ".concat(y," 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(f){return r._fingerprint=f,r._source?r._source:r.options.fileReader.openFile(n,r.options.chunkSize)}).then(function(f){if(r._source=f,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(f){r._emitError(f)})}},{key:"_startParallelUpload",value:function(){var r,n=this,a=this._size,s=0;this._parallelUploads=[];var c=this._parallelUploadUrls!=null?this._parallelUploadUrls.length:this.options.parallelUploads,y=(r=this.options.parallelUploadBoundaries)!==null&&r!==void 0?r:Lr(this._source.size,c);
3this._parallelUploadUrls&&y.forEach(function(S,R){S.uploadUrl=n._parallelUploadUrls[R]||null}),this._parallelUploadUrls=new Array(y.length);var f=y.map(function(S,R){var P=0;return n._source.slice(S.start,S.end).then(function($){var B=$.value;return new Promise(function(C,O){var L=J(J({},n.options),{},{uploadUrl:S.uploadUrl||null,storeFingerprintForResuming:!1,removeFingerprintOnSuccess:!1,parallelUploads:1,parallelUploadBoundaries:null,metadata:n.options.metadataForPartialUploads,headers:J(J({},n.options.headers),{},{"Upload-Concat":"partial"}),onSuccess:C,onError:O,onProgress:function(b){s=s-P+b,P=b,n._emitProgress(s,a)},onUploadUrlAvailable:function(){n._parallelUploadUrls[R]=_.url,n._parallelUploadUrls.filter(function(b){return!!b}).length===y.length&&n._saveUploadInUrlStorage()}}),_=new e(B,L);_.start(),n._parallelUploads.push(_)})})}),x;Promise.all(f).then(function(){x=n._openRequest("POST",n.options.endpoint),x.setHeader("Upload-Concat","final;".concat(n._parallelUploadUrls.join(" ")));var S=nt(n.options.metadata);return S!==""&&x.setHeader("Upload-Metadata",S),n._sendRequest(x,null)}).then(function(S){if(!Z(S.getStatus(),200)){n._emitHttpError(x,S,"tus: unexpected response while creating upload");return}var R=S.getHeader("Location");if(R==null){n._emitHttpError(x,S,"tus: invalid or missing Location header");return}n.url=st(n.options.endpoint,R),"Created upload at ".concat(n.url),n._emitSuccess(S)}).catch(function(S){n._emitError(S)})}},{key:"_startSingleUpload",value:function(){if(this._aborted=!1,this.url!=null){"Resuming upload from previous URL: ".concat(this.url),this._resumeUpload();return}if(this.options.uploadUrl!=null){"Resuming upload from provided URL: ".concat(this.options.uploadUrl),this.url=this.options.uploadUrl,this._resumeUpload();return}this._createUpload()}},{key:"abort",value:function(r){var n=this;if(this._parallelUploads!=null){var a=Cr(this._parallelUploads),s;try{for(a.s();!(s=a.n()).done;){var c=s.value;c.abort(r)}}catch(y){a.e(y)}finally{a.f()}}return this._req!==null&&this._req.abort(),this._aborted=!0,this._retryTimeout!=null&&(clearTimeout(this._retryTimeout),this._retryTimeout=null),!r||this.url==null?Promise.resolve():e.terminate(this.url,this.options).then(function(){return n._removeFromUrlStorage()})}},{key:"_emitHttpError",value:function(r,n,a,s){this._emitError(new ye(a,s,r,n))}},{key:"_emitError",value:function(r){var n=this;if(!this._aborted){if(this.options.retryDelays!=null){var a=this._offset!=null&&this._offset>this._offsetBeforeRetry;if(a&&(this._retryAttempt=0),it(r,this._retryAttempt,this.options)){var s=this.options.retryDelays[this._retryAttempt++];this._offsetBeforeRetry=this._offset,this._retryTimeout=setTimeout(function(){n.start()},s);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,a){typeof this.options.onChunkComplete=="function"&&this.options.onChunkComplete(r,n,a)}},{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 a=nt(this.options.metadata);a!==""&&n.setHeader("Upload-Metadata",a);var s;this.options.uploadDataDuringCreation&&!this.options.uploadLengthDeferred?(this._offset=0,s=this._addChunkToRequest(n)):((this.options.protocol===_e||this.options.protocol===ie)&&n.setHeader("Upload-Complete","?0"),s=this._sendRequest(n,null)),s.then(function(c){if(!Z(c.getStatus(),200)){r._emitHttpError(n,c,"tus: unexpected response while creating upload");return}var y=c.getHeader("Location");
3if(y==null){r._emitHttpError(n,c,"tus: invalid or missing Location header");return}if(r.url=st(r.options.endpoint,y),"Created upload at ".concat(r.url),typeof r.options.onUploadUrlAvailable=="function"&&r.options.onUploadUrlAvailable(),r._size===0){r._emitSuccess(c),r._source.close();return}r._saveUploadInUrlStorage().then(function(){r.options.uploadDataDuringCreation?r._handleUploadResponse(n,c):(r._offset=0,r._performUpload())})}).catch(function(c){r._emitHttpError(n,null,"tus: failed to create upload",c)})}},{key:"_resumeUpload",value:function(){var r=this,n=this._openRequest("HEAD",this.url),a=this._sendRequest(n,null);a.then(function(s){var c=s.getStatus();if(!Z(c,200)){if(c===423){r._emitHttpError(n,s,"tus: upload is currently locked; retry later");return}if(Z(c,400)&&r._removeFromUrlStorage(),!r.options.endpoint){r._emitHttpError(n,s,"tus: unable to resume upload (new upload cannot be created without an endpoint)");return}r.url=null,r._createUpload();return}var y=Number.parseInt(s.getHeader("Upload-Offset"),10);if(Number.isNaN(y)){r._emitHttpError(n,s,"tus: invalid or missing offset value");return}var f=Number.parseInt(s.getHeader("Upload-Length"),10);if(Number.isNaN(f)&&!r.options.uploadLengthDeferred&&r.options.protocol===xe){r._emitHttpError(n,s,"tus: invalid or missing length value");return}typeof r.options.onUploadUrlAvailable=="function"&&r.options.onUploadUrlAvailable(),r._saveUploadInUrlStorage().then(function(){if(y===f){r._emitProgress(f,f),r._emitSuccess(s);return}r._offset=y,r._performUpload()})}).catch(function(s){r._emitHttpError(n,null,"tus: failed to resume upload",s)})}},{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 a=this._addChunkToRequest(n);a.then(function(s){if(!Z(s.getStatus(),200)){r._emitHttpError(n,s,"tus: unexpected response while uploading chunk");return}r._handleUploadResponse(n,s)}).catch(function(s){r._aborted||r._emitHttpError(n,null,"tus: failed to upload chunk at offset ".concat(r._offset),s)})}}},{key:"_addChunkToRequest",value:function(r){var n=this,a=this._offset,s=this._offset+this.options.chunkSize;return r.setProgressHandler(function(c){n._emitProgress(a+c,n._size)}),this.options.protocol===xe?r.setHeader("Content-Type","application/offset+octet-stream"):this.options.protocol===ie&&r.setHeader("Content-Type","application/partial-upload"),(s===Number.POSITIVE_INFINITY||s>this._size)&&!this.options.uploadLengthDeferred&&(s=this._size),this._source.slice(a,s).then(function(c){var y=c.value,f=c.done,x=y!=null&&y.size?y.size:0;n.options.uploadLengthDeferred&&f&&(n._size=n._offset+x,r.setHeader("Upload-Length","".concat(n._size)));var S=n._offset+x;return!n.options.uploadLengthDeferred&&f&&S!==n._size?Promise.reject(new Error("upload was configured with a size of ".concat(n._size," bytes, but the source is done after ").concat(S," bytes"))):y===null?n._sendRequest(r):((n.options.protocol===_e||n.options.protocol===ie)&&r.setHeader("Upload-Complete",f?"?1":"?0"),n._emitProgress(n._offset,n._size),n._sendRequest(r,y))})}},{key:"_handleUploadResponse",value:function(r,n){var a=Number.parseInt(n.getHeader("Upload-Offset"),10);if(Number.isNaN(a)){this._emitHttpError(r,n,"tus: invalid or missing offset value");return}if(this._emitProgress(a,this._size),this._emitChunkComplete(a-this._offset,a,this._size),this._offset=a,a===this._size){this._emitSuccess(n),this._source.close();return}this._performUpload()}},{key:"_openRequest",value:function(r,n){var a=ot(r,n,this.options);return this._req=a,a}},{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(a){r._urlStorageKey=a})}},{key:"_sendRequest",value:function(r){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null;return at(r,n,this.options)}}],[{key:"terminate",value:function(r){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},a=ot("DELETE",r,n);return at(a,null,n).then(function(s){if(s.getStatus()!==204)throw new ye("tus: unexpected response while terminating upload",null,a,s)}).catch(function(s){if(s instanceof ye||(s=new ye("tus: failed to terminate upload",s,a,null)),!it(s,0,n))throw s;var c=n.retryDelays[0],y=n.retryDelays.slice(1),f=J(J({},n),{},{retryDelays:y});return new Promise(function(x){return setTimeout(x,c)}).then(function(){return e.terminate(r,f)})})}}])})();function nt(e){return Object.entries(e).map(function(t){var r=$t(t,2),n=r[0],a=r[1];return"".concat(n," ").concat(_r.encode(String(a)))}).join(",")}function Z(e,t){return e>=t&&e<t+100}function ot(e,t,r){var n=r.httpStack.createRequest(e,t);r.protocol===_e?n.setHeader("Upload-Draft-Interop-Version","5"):r.protocol===ie?n.setHeader("Upload-Draft-Interop-Version","6"):n.setHeader("Tus-Resumable","1.0.0");for(var a=r.headers||{},s=0,c=Object.entries(a);s<c.length;s++){var y=$t(c[s],2),f=y[0],x=y[1];n.setHeader(f,x)}if(r.addRequestId){var S=Pr();n.setHeader("X-Request-ID",S)}return n}function at(e,t,r){return Ce.apply(this,arguments)}function Ce(){return Ce=Er(Re().mark(function e(t,r,n){var a;return Re().wrap(function(c){for(;;)switch(c.prev=c.next){case 0:if(typeof n.onBeforeRequest!="function"){c.next=3;break}return c.next=3,n.onBeforeRequest(t);case 3:return c.next=5,t.send(r);case 5:if(a=c.sent,typeof n.onAfterResponse!="function"){c.next=9;break}return c.next=9,n.onAfterResponse(t,a);case 9:return c.abrupt("return",a);case 10:case"end":return c.stop()}},e)})),Ce.apply(this,arguments)}function Fr(){var e=!0;return typeof navigator<"u"&&navigator.onLine===!1&&(e=!1),e}function it(e,t,r){return r.retryDelays==null||t>=r.retryDelays.length||e.originalRequest==null?!1:r&&typeof r.onShouldRetry=="function"?r.onShouldRetry(e,t,r):zt(e)}function zt(e){var t=e.originalResponse?e.originalResponse.getStatus():0;return(!Z(t,400)||t===409||t===423)&&Fr()}function st(e,t){return new Nr(t,e).toString()}function Lr(e,t){for(var r=Math.floor(e/t),n=[],a=0;a<t;a++)n.push({start:r*a,end:r*(a+1)});return n[t-1].end=e,n}we.defaultOptions=zr;var Ft=function(){return typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative"};function Ir(e){return new Promise(function(t,r){var n=new XMLHttpRequest;n.responseType="blob",n.onload=function(){var a=n.response;t(a)},n.onerror=function(a){r(a)},n.open("GET",e),n.send()})}var Br=function(){return typeof window<"u"&&(typeof window.PhoneGap<"u"||typeof window.Cordova<"u"||typeof window.cordova<"u")};function qr(e){return new Promise(function(t,r){var n=new FileReader;n.onload=function(){var a=new Uint8Array(n.result);t({value:a})},n.onerror=function(a){r(a)},n.readAsArrayBuffer(e)})}function fe(e){"@babel/helpers - typeof";return fe=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},fe(e)}function Hr(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Mr(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,Vr(n.key),n)}}function Gr(e,t,r){return t&&Mr(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function Vr(e){var t=Kr(e,"string");return fe(t)=="symbol"?t:t+""}function Kr(e,t){if(fe(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(fe(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}var lt=(function(){function e(t){Hr(this,e),this._file=t,this.size=t.size}return Gr(e,[{key:"slice",value:function(r,n){if(Br())return qr(this._file.slice(r,n));var a=this._file.slice(r,n),s=n>=this.size;return Promise.resolve({value:a,done:s})}},{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 Yr(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Wr(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,Jr(n.key),n)}}function Xr(e,t,r){return t&&Wr(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function Jr(e){var t=Zr(e,"string");return de(t)=="symbol"?t:t+""}function Zr(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 ut(e){return e===void 0?0:e.size!==void 0?e.size:e.length}function Qr(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 en=(function(){function e(t){Yr(this,e),this._buffer=void 0,this._bufferOffset=0,this._reader=t,this._done=!1}return Xr(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 a=this,s=n<=this._bufferOffset+ut(this._buffer);if(this._done||s){var c=this._getDataFromBuffer(r,n),y=c==null?this._done:!1;return Promise.resolve({value:c,done:y})}return this._reader.read().then(function(f){var x=f.value,S=f.done;return S?a._done=!0:a._buffer===void 0?a._buffer=x:a._buffer=Qr(a._buffer,x),a._readUntilEnoughDataOrDone(r,n)})}},{key:"_getDataFromBuffer",value:function(r,n){r>this._bufferOffset&&(this._buffer=this._buffer.slice(r-this._bufferOffset),this._bufferOffset=r);var a=ut(this._buffer)===0;return this._done&&a?null:this._buffer.slice(0,n-r)}},{key:"close",value:function(){this._reader.cancel&&this._reader.cancel()}}])})();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 Ae(){Ae=function(){return t};var e,t={},r=Object.prototype,n=r.hasOwnProperty,a=Object.defineProperty||function(u,o,i){u[o]=i.value},s=typeof Symbol=="function"?Symbol:{},c=s.iterator||"@@iterator",y=s.asyncIterator||"@@asyncIterator",f=s.toStringTag||"@@toStringTag";function x(u,o,i){return Object.defineProperty(u,o,{value:i,enumerable:!0,configurable:!0,writable:!0}),u[o]}try{x({},"")}catch{x=function(i,p,v){return i[p]=v}}function S(u,o,i,p){var v=o&&o.prototype instanceof L?o:L,m=Object.create(v.prototype),E=new I(p||[]);return a(m,"_invoke",{value:D(u,i,E)}),m}function R(u,o,i){try{return{type:"normal",arg:u.call(o,i)}}catch(p){return{type:"throw",arg:p}}}t.wrap=S;var P="suspendedStart",$="suspendedYield",B="executing",C="completed",O={};function L(){}function _(){}function g(){}var b={};x(b,c,function(){return this});var h=Object.getPrototypeOf,d=h&&h(h(M([])));d&&d!==r&&n.call(d,c)&&(b=d);var j=g.prototype=L.prototype=Object.create(b);function k(u){["next","throw","return"].forEach(function(o){x(u,o,function(i){return this._invoke(o,i)})})}function U(u,o){function i(v,m,E,A){var T=R(u[v],u,m);if(T.type!=="throw"){var G=T.arg,q=G.value;return q&&X(q)=="object"&&n.call(q,"__await")?o.resolve(q.__await).then(function(V){i("next",V,E,A)},function(V){i("throw",V,E,A)}):o.resolve(q).then(function(V){G.value=V,E(G)},function(V){return i("throw",V,E,A)})}A(T.arg)}var p;a(this,"_invoke",{value:function(m,E){function A(){return new o(function(T,G){i(m,E,T,G)})}return p=p?p.then(A,A):A()}})}function D(u,o,i){var p=P;return function(v,m){if(p===B)throw Error("Generator is already running");if(p===C){if(v==="throw")throw m;return{value:e,done:!0}}for(i.method=v,i.arg=m;;){var E=i.delegate;if(E){var A=N(E,i);if(A){if(A===O)continue;return A}}if(i.method==="next")i.sent=i._sent=i.arg;else if(i.method==="throw"){if(p===P)throw p=C,i.arg;i.dispatchException(i.arg)}else i.method==="return"&&i.abrupt("return",i.arg);p=B;var T=R(u,o,i);if(T.type==="normal"){if(p=i.done?C:$,T.arg===O)continue;return{value:T.arg,done:i.done}}T.type==="throw"&&(p=C,i.method="throw",i.arg=T.arg)}}}function N(u,o){var i=o.method,p=u.iterator[i];if(p===e)return o.delegate=null,i==="throw"&&u.iterator.return&&
3(o.method="return",o.arg=e,N(u,o),o.method==="throw")||i!=="return"&&(o.method="throw",o.arg=new TypeError("The iterator does not provide a '"+i+"' method")),O;var v=R(p,u.iterator,o.arg);if(v.type==="throw")return o.method="throw",o.arg=v.arg,o.delegate=null,O;var m=v.arg;return m?m.done?(o[u.resultName]=m.value,o.next=u.nextLoc,o.method!=="return"&&(o.method="next",o.arg=e),o.delegate=null,O):m:(o.method="throw",o.arg=new TypeError("iterator result is not an object"),o.delegate=null,O)}function z(u){var o={tryLoc:u[0]};1 in u&&(o.catchLoc=u[1]),2 in u&&(o.finallyLoc=u[2],o.afterLoc=u[3]),this.tryEntries.push(o)}function w(u){var o=u.completion||{};o.type="normal",delete o.arg,u.completion=o}function I(u){this.tryEntries=[{tryLoc:"root"}],u.forEach(z,this),this.reset(!0)}function M(u){if(u||u===""){var o=u[c];if(o)return o.call(u);if(typeof u.next=="function")return u;if(!isNaN(u.length)){var i=-1,p=function v(){for(;++i<u.length;)if(n.call(u,i))return v.value=u[i],v.done=!1,v;return v.value=e,v.done=!0,v};return p.next=p}}throw new TypeError(X(u)+" is not iterable")}return _.prototype=g,a(j,"constructor",{value:g,configurable:!0}),a(g,"constructor",{value:_,configurable:!0}),_.displayName=x(g,f,"GeneratorFunction"),t.isGeneratorFunction=function(u){var o=typeof u=="function"&&u.constructor;return!!o&&(o===_||(o.displayName||o.name)==="GeneratorFunction")},t.mark=function(u){return Object.setPrototypeOf?Object.setPrototypeOf(u,g):(u.__proto__=g,x(u,f,"GeneratorFunction")),u.prototype=Object.create(j),u},t.awrap=function(u){return{__await:u}},k(U.prototype),x(U.prototype,y,function(){return this}),t.AsyncIterator=U,t.async=function(u,o,i,p,v){v===void 0&&(v=Promise);var m=new U(S(u,o,i,p),v);return t.isGeneratorFunction(o)?m:m.next().then(function(E){return E.done?E.value:m.next()})},k(j),x(j,f,"Generator"),x(j,c,function(){return this}),x(j,"toString",function(){return"[object Generator]"}),t.keys=function(u){var o=Object(u),i=[];for(var p in o)i.push(p);return i.reverse(),function v(){for(;i.length;){var m=i.pop();if(m in o)return v.value=m,v.done=!1,v}return v.done=!0,v}},t.values=M,I.prototype={constructor:I,reset:function(o){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(w),!o)for(var i in this)i.charAt(0)==="t"&&n.call(this,i)&&!isNaN(+i.slice(1))&&(this[i]=e)},stop:function(){this.done=!0;var o=this.tryEntries[0].completion;if(o.type==="throw")throw o.arg;return this.rval},dispatchException:function(o){if(this.done)throw o;var i=this;function p(G,q){return E.type="throw",E.arg=o,i.next=G,q&&(i.method="next",i.arg=e),!!q}for(var v=this.tryEntries.length-1;v>=0;--v){var m=this.tryEntries[v],E=m.completion;if(m.tryLoc==="root")return p("end");if(m.tryLoc<=this.prev){var A=n.call(m,"catchLoc"),T=n.call(m,"finallyLoc");if(A&&T){if(this.prev<m.catchLoc)return p(m.catchLoc,!0);if(this.prev<m.finallyLoc)return p(m.finallyLoc)}else if(A){if(this.prev<m.catchLoc)return p(m.catchLoc,!0)}else{if(!T)throw Error("try statement without catch or finally");if(this.prev<m.finallyLoc)return p(m.finallyLoc)}}}},abrupt:function(o,i){for(var p=this.tryEntries.length-1;p>=0;--p){var v=this.tryEntries[p];if(v.tryLoc<=this.prev&&n.call(v,"finallyLoc")&&this.prev<v.finallyLoc){var m=v;break}}m&&(o==="break"||o==="continue")&&m.tryLoc<=i&&i<=m.finallyLoc&&(m=null);var E=m?m.completion:{};return E.type=o,E.arg=i,m?(this.method="next",this.next=m.finallyLoc,O):this.complete(E)},complete:function(o,i){if(o.type==="throw")throw o.arg;return o.type==="break"||o.type==="continue"?this.next=o.arg:o.type==="return"?(this.rval=this.arg=o.arg,this.method="return",this.next="end"):o.type==="normal"&&i&&(this.next=i),O},finish:function(o){for(var i=this.tryEntries.length-1;i>=0;--i){var p=this.tryEntries[i];if(p.finallyLoc===o)return this.complete(p.completion,p.afterLoc),w(p),O}},catch:function(o){for(var i=this.tryEntries.length-1;i>=0;--i){var p=this.tryEntries[i];if(p.tryLoc===o){var v=p.completion;if(v.type==="throw"){var m=v.arg;w(p)}return m}}throw Error("illegal catch attempt")},delegateYield:function(o,i,p){return this.delegate={iterator:M(o),resultName:i,nextLoc:p},this.method==="next"&&(this.arg=e),O}},t}function ct(e,t,r,n,a,s,c){try{var y=e[s](c),f=y.value}catch(x){r(x);return}
3y.done?t(f):Promise.resolve(f).then(n,a)}function tn(e){return function(){var t=this,r=arguments;return new Promise(function(n,a){var s=e.apply(t,r);function c(f){ct(s,n,a,c,y,"next",f)}function y(f){ct(s,n,a,c,y,"throw",f)}c(void 0)})}}function rn(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function nn(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,an(n.key),n)}}function on(e,t,r){return t&&nn(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function an(e){var t=sn(e,"string");return X(t)=="symbol"?t:t+""}function sn(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 ln=(function(){function e(){rn(this,e)}return on(e,[{key:"openFile",value:(function(){var t=tn(Ae().mark(function n(a,s){var c;return Ae().wrap(function(f){for(;;)switch(f.prev=f.next){case 0:if(!(Ft()&&a&&typeof a.uri<"u")){f.next=11;break}return f.prev=1,f.next=4,Ir(a.uri);case 4:return c=f.sent,f.abrupt("return",new lt(c));case 8:throw f.prev=8,f.t0=f.catch(1),new Error("tus: cannot fetch `file.uri` as Blob, make sure the uri is correct and accessible. ".concat(f.t0));case 11:if(!(typeof a.slice=="function"&&typeof a.size<"u")){f.next=13;break}return f.abrupt("return",Promise.resolve(new lt(a)));case 13:if(typeof a.read!="function"){f.next=18;break}if(s=Number(s),Number.isFinite(s)){f.next=17;break}return f.abrupt("return",Promise.reject(new Error("cannot create source for stream without a finite value for the `chunkSize` option")));case 17:return f.abrupt("return",Promise.resolve(new en(a,s)));case 18:return f.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 f.stop()}},n,null,[[1,8]])}));function r(n,a){return t.apply(this,arguments)}return r})()}])})();function un(e,t){return Ft()?Promise.resolve(cn(e,t)):Promise.resolve(["tus-br",e.name,e.type,e.size,e.lastModified,t.endpoint].join("-"))}function cn(e,t){var r=e.exif?fn(JSON.stringify(e.exif)):"noexif";return["tus-rn",e.name||"noname",e.size||"nosize",r,t.endpoint].join("/")}function fn(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 pe(e){"@babel/helpers - typeof";return pe=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},pe(e)}function qe(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function dn(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,pn(n.key),n)}}function He(e,t,r){return t&&dn(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function pn(e){var t=hn(e,"string");return pe(t)=="symbol"?t:t+""}function hn(e,t){if(pe(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(pe(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}var mn=(function(){function e(){qe(this,e)}return He(e,[{key:"createRequest",value:function(r,n){return new yn(r,n)}},{key:"getName",value:function(){return"XHRHttpStack"}}])})(),yn=(function(){function e(t,r){qe(this,e),this._xhr=new XMLHttpRequest,this._xhr.open(t,r,!0),this._method=t,this._url=r,this._headers={}}return He(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(a,s){r._xhr.onload=function(){a(new gn(r._xhr))},r._xhr.onerror=function(c){s(c)},r._xhr.send(n)})}},{key:"abort",value:function(){return this._xhr.abort(),Promise.resolve()}},{key:"getUnderlyingObject",value:function(){return this._xhr}}])})(),gn=(function(){function e(t){qe(this,e),this._xhr=t}return He(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 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 vn(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function bn(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,_n(n.key),n)}}function xn(e,t,r){return t&&bn(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function _n(e){var t=wn(e,"string");return he(t)=="symbol"?t:t+""}function wn(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=!1;try{$e="localStorage"in window;var Ne="tusSupport",ft=localStorage.getItem(Ne);localStorage.setItem(Ne,ft),ft===null&&localStorage.removeItem(Ne)}catch(e){if(e.code===e.SECURITY_ERR||e.code===e.QUOTA_EXCEEDED_ERR)$e=!1;else throw e}var jn=$e,Sn=(function(){function e(){vn(this,e)}return xn(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 a=Math.round(Math.random()*1e12),s="tus::".concat(r,"::").concat(a);return localStorage.setItem(s,JSON.stringify(n)),Promise.resolve(s)}},{key:"_findEntries",value:function(r){for(var n=[],a=0;a<localStorage.length;a++){var s=localStorage.key(a);if(s.indexOf(r)===0)try{var c=JSON.parse(localStorage.getItem(s));c.urlStorageKey=s,n.push(c)}catch{}}return n}}])})();function re(e){"@babel/helpers - typeof";return re=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},re(e)}function Un(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Nn(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,It(n.key),n)}}function Pn(e,t,r){return r&&Nn(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function En(e,t,r){return t=je(t),On(e,Lt()?Reflect.construct(t,r||[],je(e).constructor):t.apply(e,r))}function On(e,t){if(t&&(re(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return kn(e)}function kn(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Lt(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Lt=function(){return!!e})()}function je(e){return je=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},je(e)}function Rn(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:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&De(e,t)}function De(e,t){return De=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,a){return n.__proto__=a,n},De(e,t)}function dt(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).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]:{};
3t%2?dt(Object(r),!0).forEach(function(n){Cn(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):dt(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function Cn(e,t,r){return t=It(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function It(e){var t=An(e,"string");return re(t)=="symbol"?t:t+""}function An(e,t){if(re(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(re(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}var pt=ee(ee({},we.defaultOptions),{},{httpStack:new mn,fileReader:new ln,urlStorage:jn?new Sn:new cr,fingerprint:un}),$n=(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 Un(this,t),n=ee(ee({},pt),n),En(this,t,[r,n])}return Rn(t,e),Pn(t,null,[{key:"terminate",value:function(n){var a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return a=ee(ee({},pt),a),we.terminate(n,a)}}])})(we);function Dn(e){return e<1024*1024?`${(e/1024).toFixed(1)} KB`:e<1024*1024*1024?`${(e/1024/1024).toFixed(1)} MB`:`${(e/1024/1024/1024).toFixed(2)} GB`}function Tn({item:e,onRemove:t}){const r=e.status==="uploading",n=e.status==="done",a=e.status==="failed",s=e.status==="waiting";return l.jsxs("div",{className:`flex items-center gap-3 p-3 rounded-xl border transition-colors ${r?"bg-blue-50 border-blue-200":n?"bg-emerald-50 border-emerald-100":a?"bg-red-50 border-red-100":"bg-white border-gray-100"}`,children:[l.jsxs("div",{className:"shrink-0",children:[r&&l.jsx(me,{size:18,className:"text-blue-500 animate-spin"}),n&&l.jsx(Te,{size:18,className:"text-emerald-500"}),a&&l.jsx(bt,{size:18,className:"text-red-400"}),s&&l.jsx(ze,{size:18,className:"text-gray-900"})]}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("p",{className:"text-sm font-medium text-gray-900 truncate",title:e.file.name,children:e.file.name}),l.jsx("p",{className:"text-xs text-gray-900",children:Dn(e.file.size)}),r&&l.jsx("div",{className:"mt-1.5 w-full bg-blue-100 rounded-full h-1.5",children:l.jsx("div",{className:"bg-blue-500 h-1.5 rounded-full transition-all duration-200",style:{width:`${e.progress}%`}})}),a&&e.error&&l.jsx("p",{className:"text-xs text-red-500 mt-0.5 truncate",children:e.error})]}),l.jsxs("div",{className:"shrink-0 flex items-center gap-2",children:[r&&l.jsxs("span",{className:"text-xs font-semibold text-blue-600",children:[e.progress,"%"]}),n&&l.jsx("span",{className:"text-xs font-medium text-emerald-600 bg-emerald-100 px-2 py-0.5 rounded-full",children:"Done"}),a&&l.jsx("span",{className:"text-xs font-medium text-red-500 bg-red-100 px-2 py-0.5 rounded-full",children:"Failed"}),(s||a)&&l.jsx("button",{onClick:()=>t(e.id),className:"text-gray-900 hover:text-red-500 transition-colors",title:"Remove",children:l.jsx(yt,{size:14})})]})]})}function zn({folders:e=[],defaultFolderId:t=null,onComplete:r}){const[n,a]=F.useState([]),[s,c]=F.useState(!1),[y,f]=F.useState(t),x=F.useRef(null),S=F.useRef(!1);F.useEffect(()=>{f(t)},[t]);const R=n.filter(d=>d.status==="uploading").length,P=n.filter(d=>d.status==="done").length,$=n.filter(d=>d.status==="failed").length,B=n.filter(d=>d.status==="waiting").length,C=n.length,O=R>0||B>0,L=F.useCallback(d=>{const j=Array.from(d).filter(U=>U.type.startsWith("video/"));if(j.length===0)return;const k=j.map(U=>({id:`${U.name}-${U.size}-${Date.now()}-${Math.random()}`,file:U,status:"waiting",progress:0}));a(U=>[...U,...k])},[]);F.useEffect(()=>{async function d(){S.current||a(j=>{const k=j.findIndex(D=>D.status==="waiting");if(k===-1)return j;S.current=!0;const U=j[k];return(async()=>{try{const D=await Mn(U.file,N=>{a(z=>z.map(w=>w.id===U.id?{...w,progress:N,status:"uploading"}:w))});y&&D?.guid&&await fetch(`${K}/admin/media/videos/${D.guid}/folder`,{method:"PATCH",headers:{Authorization:`Bearer ${Y()}`,"Content-Type":"application/json"},body:JSON.stringify({folderId:y})}),a(N=>N.map(z=>z.id===U.id?{...z,status:"done",progress:100}:z))}catch(D){a(N=>N.map(z=>z.id===U.id?{...z,status:"failed",error:D.message}:z))}finally{S.current=!1,a(D=>[...D])}})(),j.map((D,N)=>N===k?{...D,status:"uploading"}:D)})}d()},[n,y]),F.useEffect(()=>{C>0&&B===0&&R===0&&r?.()},[B,R,C,r]);function _(d){d.preventDefault(),c(!1),L(d.dataTransfer.files)}function g(d){a(j=>j.filter(k=>
3k.id!==d))}function b(){a(d=>d.filter(j=>j.status==="waiting"||j.status==="uploading"))}const h=e.find(d=>d.id===y);return l.jsxs("div",{className:"space-y-3",children:[e.length>0&&l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(Fe,{size:14,className:"text-gray-900 shrink-0"}),l.jsx("span",{className:"text-xs text-gray-900 shrink-0",children:"Upload to folder:"}),l.jsxs("select",{value:y??"",onChange:d=>f(d.target.value?Number(d.target.value):null),disabled:O,className:"flex-1 text-xs border border-gray-200 rounded-lg px-2 py-1.5 bg-white text-gray-900 focus:outline-none focus:ring-2 focus:ring-indigo-300 disabled:opacity-60",children:[l.jsx("option",{value:"",children:"â No folder (All Media)"}),e.map(d=>l.jsx("option",{value:d.id,children:d.name},d.id))]}),h&&l.jsx("span",{className:"w-3 h-3 rounded-sm shrink-0",style:{background:h.color}})]}),l.jsxs("div",{onDrop:_,onDragOver:d=>{d.preventDefault(),c(!0)},onDragLeave:()=>c(!1),className:`rounded-2xl border-2 border-dashed p-6 text-center transition-all ${s?"border-blue-400 bg-blue-50":"border-gray-200 bg-white hover:border-blue-300 hover:bg-blue-50/20"}`,children:[l.jsx("input",{ref:x,type:"file",accept:"video/*",multiple:!0,className:"hidden",onChange:d=>{d.target.files&&L(d.target.files),d.target.value=""}}),l.jsx(se,{size:28,className:"text-gray-900 mx-auto mb-2"}),l.jsx("p",{className:"text-sm font-semibold text-gray-900",children:s?"Drop videos to queue them":"Drag & drop videos here, or click to browse"}),l.jsx("p",{className:"text-xs text-gray-900 mt-1",children:"Select multiple files â they upload one at a time. MP4, MOV, AVI, MKV up to 2 GB each."}),l.jsxs(Q,{size:"sm",className:"mt-3 bg-blue-600 hover:bg-blue-700 gap-1.5",onClick:()=>x.current?.click(),children:[l.jsx(se,{size:14})," Choose Videos"]})]}),n.length>0&&l.jsxs("div",{className:"space-y-2",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{className:"flex items-center gap-3 text-xs text-gray-900",children:[O&&l.jsxs("span",{className:"flex items-center gap-1 font-medium text-blue-600",children:[l.jsx(me,{size:12,className:"animate-spin"}),"Uploading ",P+1," of ",C]}),!O&&P>0&&l.jsxs("span",{className:"font-medium text-emerald-600",children:[P," uploaded successfully"]}),$>0&&l.jsxs("span",{className:"text-red-500",children:[$," failed"]}),B>0&&!O&&l.jsxs("span",{children:[B," waiting"]})]}),(P>0||$>0)&&l.jsx("button",{onClick:b,className:"text-xs text-gray-900 hover:text-gray-600 transition-colors",children:"Clear finished"})]}),O&&C>1&&l.jsx("div",{className:"w-full bg-gray-100 rounded-full h-1.5",children:l.jsx("div",{className:"bg-blue-400 h-1.5 rounded-full transition-all duration-300",style:{width:`${Math.round(P/C*100)}%`}})}),l.jsx("div",{className:"space-y-2 max-h-72 overflow-y-auto pr-1",children:n.map(d=>l.jsx(Tn,{item:d,onRemove:g},d.id))})]})]})}const ht={0:{label:"Created",color:"bg-gray-100 text-gray-900"},1:{label:"Uploaded",color:"bg-blue-50 text-blue-600"},2:{label:"Processing",color:"bg-yellow-50 text-yellow-600"},3:{label:"Encoding",color:"bg-orange-50 text-orange-600"},4:{label:"Ready",color:"bg-emerald-50 text-emerald-700"},5:{label:"Error",color:"bg-red-50 text-red-600"},6:{label:"Failed",color:"bg-red-50 text-red-600"}};function Fn(e){if(!e)return"";const t=Math.floor(e/3600),r=Math.floor(e%3600/60),n=e%60;return t>0?`${t}:${r.toString().padStart(2,"0")}:${n.toString().padStart(2,"0")}`:`${r}:${n.toString().padStart(2,"0")}`}function Ln(e){return e?e<1024*1024?`${(e/1024).toFixed(1)} KB`:e<1024*1024*1024?`${(e/1024/1024).toFixed(1)} MB`:`${(e/1024/1024/1024).toFixed(2)} GB`:""}function In(e,t){return!t||!e.thumbnailFileName?"":`https://${t}/${e.guid}/${e.thumbnailFileName}`}function Bn(e,t){return`https://iframe.mediadelivery.net/embed/${t}/${e.guid}`}function qn(e,t){return`https://${t}/${e.guid}/playlist.m3u8`}function Hn(){const[e,t]=F.useState([]),[r,n]=F.useState(null),[a,s]=F.useState(!1),[c,y]=F.useState("");async function f(){try{const P=await(await fetch(`${K}/admin/media/config`,{headers:{Authorization:`Bearer ${Y()}`}})).json();P.success&&n(P.data)}catch{}}async function x(R=c){s(!0);try{const $=await(await fetch(`${K}/admin/media/videos?search=${encodeURIComponent(R)}`,{headers:{Authorization:`Bearer ${Y()}`}})).json();$.success?t($.data?.items??$.data??[]):oe({title:$.error??"Failed to load videos",variant:"destructive"})}catch{oe({title:"Network error loading videos",variant:"destructive"})}finally{s(!1)}}async function S(R){try{const $=await(await fetch(`${K}/admin/media/videos/${R}`,{method:"DELETE",headers:{Authorization:`Bearer ${Y()}`}})).json();return $.success?(t(B=>B.filter(C=>C.guid!==R)),oe({title:"Video deleted"}),!0):(oe({title:$.error??"Delete failed",variant:"destructive"}),!1)}catch{return oe({title:"Delete failed",variant:"destructive"}),!1}}return F.useEffect(()=>{f(),x()},[]),{videos:e,config:r,loading:a,search:c,setSearch:y,fetchVideos:x,deleteVideo:S}}async function mt(e){if(!(e.headers.get("content-type")??"").includes("application/json"))throw new Error(`Server returned an unexpected response
3(HTTP ${e.status}). Check that the API server is running.`);return e.json()}async function Mn(e,t,r){const n=await fetch(`${K}/admin/media/videos`,{method:"POST",headers:{Authorization:`Bearer ${Y()}`,"Content-Type":"application/json"},body:JSON.stringify({title:e.name.replace(/\.[^.]+$/,""),originalDate:e.lastModified}),signal:r}),a=await mt(n);if(!a.success)throw new Error(a.error??"Failed to create video entry");const s=a.data,c=await fetch(`${K}/admin/media/videos/${s.guid}/tus-credentials`,{headers:{Authorization:`Bearer ${Y()}`},signal:r}),y=await mt(c);if(!y.success)throw new Error(y.error??"Failed to get upload credentials");const f=y.data;return await new Promise((x,S)=>{new $n(e,{endpoint:f.tusEndpoint,retryDelays:[0,3e3,5e3,1e4,2e4],chunkSize:52428800,headers:{AuthorizationSignature:f.authSignature,AuthorizationExpire:String(f.authExpire),VideoId:f.videoId,LibraryId:f.libraryId},metadata:{filetype:e.type||"video/mp4",title:e.name.replace(/\.[^.]+$/,"")},onProgress(P,$){t(Math.round(P/$*100))},onSuccess(){x()},onError(P){S(new Error(P instanceof Error?P.message:String(P)))}}).start()}),s}function Gn({video:e,config:t,onSelect:r,onDelete:n,selected:a}){const s=In(e,t.cdnHostname),c=ht[e.status]??ht[0],y=e.status===4;return l.jsxs("div",{onClick:()=>y&&r?.(e),className:`group relative bg-white rounded-xl border overflow-hidden transition-all ${r&&y?"cursor-pointer hover:border-blue-400 hover:shadow-md":"cursor-default"} ${a?"border-blue-500 ring-2 ring-blue-200":"border-gray-200"}`,children:[l.jsxs("div",{className:"aspect-video bg-gray-100 relative overflow-hidden",children:[s?l.jsx("img",{src:s,alt:e.title,className:"w-full h-full object-cover",onError:f=>{f.target.style.display="none"}}):l.jsx("div",{className:"w-full h-full flex items-center justify-center",children:l.jsx(ze,{size:28,className:"text-gray-900"})}),e.length>0&&l.jsx("span",{className:"absolute bottom-1.5 right-1.5 bg-black/70 text-white text-[10px] font-mono px-1.5 py-0.5 rounded",children:Fn(e.length)}),!y&&l.jsx("div",{className:"absolute inset-0 bg-black/40 flex items-center justify-center",children:e.status===5||e.status===6?l.jsx(gt,{size:24,className:"text-red-400"}):l.jsx(me,{size:24,className:"text-white animate-spin"})}),a&&l.jsx("div",{className:"absolute top-1.5 right-1.5",children:l.jsx(Te,{size:20,className:"text-blue-500 fill-white"})})]}),l.jsxs("div",{className:"p-2.5",children:[l.jsx("p",{className:"text-sm font-medium text-gray-900 truncate leading-tight mb-1",title:e.title,children:e.title}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("span",{className:`text-[10px] font-medium px-1.5 py-0.5 rounded-full ${c.color}`,children:[c.label,e.status===3&&e.encodeProgress>0?` ${e.encodeProgress}%`:""]}),e.storageSize>0&&l.jsx("span",{className:"text-[10px] text-gray-900",children:Ln(e.storageSize)})]})]}),n&&l.jsx("button",{onClick:f=>
3{f.stopPropagation(),confirm("Delete this video?")&&n(e.guid)},className:"absolute top-1.5 left-1.5 opacity-0 group-hover:opacity-100 transition-opacity bg-black/60 hover:bg-red-600 text-white rounded-md p-1 text-xs leading-none",title:"Delete",children:"â"})]})}function Vn({onUploaded:e}){return l.jsx(zn,{onComplete:e})}function ao({open:e,onClose:t,onSelect:r}){const{videos:n,config:a,loading:s,search:c,setSearch:y,fetchVideos:f,deleteVideo:x}=Hn(),[S,R]=F.useState(null),[P,$]=F.useState(!1),[B,C]=F.useState([]),[O,L]=F.useState(null);async function _(){try{const j=await(await fetch(`${K}/admin/media/folders`,{headers:{Authorization:`Bearer ${Y()}`}})).json();j.success&&C(j.data??[])}catch{}}F.useEffect(()=>{e&&(_(),L(null),$(!1))},[e]);const g=O===null?n:n.filter(d=>d.folderId===O),b=c?g.filter(d=>d.title.toLowerCase().includes(c.toLowerCase())):g;function h(d){a&&(R(d.guid),r(Bn(d,a.libraryId),qn(d,a.cdnHostname),d.title),t())}return l.jsx(qt,{open:e,onOpenChange:d=>!d&&t(),children:l.jsxs(Ht,{className:"max-w-4xl bg-white border-gray-200 text-gray-900 max-h-[85vh] flex flex-col p-0",children:[l.jsx(Mt,{className:"px-5 pt-5 pb-3 border-b border-gray-100 shrink-0",children:l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx(Gt,{className:"text-gray-900",children:"Choose Video"}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsxs(Q,{size:"sm",variant:"outline",onClick:()=>$(!P),className:"border-blue-200 text-blue-700 hover:bg-blue-50 gap-1.5",children:[l.jsx(se,{size:14})," Upload New"]}),l.jsx(Q,{size:"sm",variant:"ghost",onClick:()=>f(),className:"text-gray-900 hover:text-gray-700",title:"Refresh",children:l.jsx(Kt,{size:14,className:s?"animate-spin":""})})]})]})}),l.jsxs("div",{className:"flex flex-1 min-h-0 overflow-hidden",children:[l.jsxs("div",{className:"w-44 border-r border-gray-100 shrink-0 flex flex-col overflow-y-auto p-2 gap-0.5",children:[l.jsxs("button",{onClick:()=>L(null),className:`w-full text-left text-sm px-2.5 py-1.5 rounded-lg flex items-center gap-2 transition-colors ${O===null?"bg-blue-50 text-blue-700 font-medium":"text-gray-900 hover:bg-gray-100"}`,children:[l.jsx(Fe,{size:14,className:"shrink-0"}),l.jsx("span",{className:"truncate",children:"All Videos"}),l.jsx("span",{className:"ml-auto text-xs text-gray-900",children:n.length})]}),B.map(d=>{const j=n.filter(k=>k.folderId===d.id).length;return l.jsxs("button",{onClick:()=>L(d.id),className:`w-full text-left text-sm px-2.5 py-1.5 rounded-lg flex items-center gap-2 transition-colors ${O===d.id?"bg-blue-50 text-blue-700 font-medium":"text-gray-900 hover:bg-gray-100"}`,children:[l.jsx("span",{className:"w-2.5 h-2.5 rounded-full shrink-0",style:{background:d.color??"#94a3b8"}}),l.jsx("span",{className:"truncate",children:d.name}),l.jsx("span",{className:"ml-auto text-xs text-gray-900",children:j})]},d.id)})]}),l.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-4",children:[P&&l.jsx(Vn,{onUploaded:()=>{$(!1),f()}}),a&&!a.configured&&l.jsxs("div",{className:"bg-amber-50 border border-amber-200 rounded-xl p-4 text-sm text-amber-800",children:[l.jsx(gt,{size:16,className:"inline mr-2 text-amber-600"}),"Bunny Stream credentials not set. Add ",l.jsx("code",{className:"bg-amber-100 px-1 rounded",children:"BUNNY_STREAM_ACCESS_KEY"}),","," ",l.jsx("code",{className:"bg-amber-100 px-1 rounded",children:"BUNNY_STREAM_LIBRARY_ID"}),", and"," ",l.jsx("code",{className:"bg-amber-100 px-1 rounded",children:"BUNNY_CDN_HOSTNAME"})," to Replit Secrets."]}),l.jsxs("div",{className:"relative",children:[l.jsx(Yt,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-gray-900"}),l.jsx(Wt,{value:c,onChange:d=>{y(d.target.value),f(d.target.value)},placeholder:"Search videosâ¦",className:"pl-8 bg-white border-gray-200 text-gray-900 text-sm"})]}),s?l.jsx("div",{className:"grid grid-cols-3 gap-3",children:[1,2,3,4,5,6].map(d=>l.jsx("div",{className:"aspect-video bg-gray-100 rounded-xl animate-pulse"},d))}):b.length===0?l.jsxs("div",{className:"py-12 text-center",children:[l.jsx(ze,{size:32,className:"text-gray-900 mx-auto mb-2"}),l.jsx("p",{className:"text-sm text-gray-900",children:c?"No videos match your search":O!==null?"No videos in this folder":"No videos in your library yet"}),!c&&l.jsxs(Q,{size:"sm",onClick:()=>$(!0),className:"mt-3 bg-blue-600 hover:bg-blue-700 gap-1.5",children:[l.jsx(se,{size:14})," Upload First Video"]})]}):l.jsx("div",{className:"grid grid-cols-3 gap-3",children:b.map(d=>l.jsx(Gn,{video:d,config:a,onSelect:h,onDelete:x,selected:S===d.guid},d.guid))})]})]}),l.jsxs("div",{className:"px-5 py-3 border-t border-gray-100 shrink-0 flex items-center justify-between",children:[l.jsxs("p",{className:"text-xs text-gray-900",children:[b.length," video",b.length!==1?"s":""," · click to insert"]}),l.jsx(Q,{variant:"outline",onClick:t,className:"border-gray-200 text-gray-900",children:"Cancel"})]})]})})}function Kn(e){return e<1024*1024?`${(e/1024).toFixed(1)} KB`:e<1024*1024*1024?`${(e/1024/1024).toFixed(1)} MB`:`${(e/1024/1024/1024).toFixed(2)} GB`}function Yn(e,t){return fetch(e,{...t,headers:{Authorization:`Bearer ${Y()}`,...t?.headers??{}}})}async function Wn(e,t){const r=new FormData;return r.append("file",e),r.append("name",e.name),r.append("originalDate",String(e.lastModified)),await new Promise((n,a)=>{const s=new XMLHttpRequest;s.open("POST",`${K}/admin/media/files/upload`),s.setRequestHeader("Authorization",`Bearer ${Y()}`),s.upload.onprogress=c=>{c.lengthComputable&&t(Math.round(c.loaded/c.total*100))},s.onload=()=>{let c={};try{c=JSON.parse(s.responseText||"{}")}catch{c={}}if(s.status<300&&c.success&&c.data?.fileId){n({fileId:c.data.fileId});return}a(new Error(c.error??`Upload failed: ${s.status}`))},s.onerror=()=>a(new Error("Network error during upload")),s.send(r)})}function Xn({item:e,isImage:t,onRemove:r}){const n=e.status==="uploading",a=e.status==="done",s=e.status==="failed",c=e.status==="waiting";return l.jsxs("div",{className:`flex items-center gap-3 p-3 rounded-xl border transition-colors ${n?"bg-blue-50 border-blue-200":a?"bg-emerald-50 border-emerald-100":s?"bg-red-50 border-red-100":"bg-white border-gray-100"}`,children:[l.jsxs("div",{className:"shrink-0",children:[n&&l.jsx(me,{size:18,className:"text-blue-500 animate-spin"}),a&&l.jsx(Te,{size:18,className:"text-emerald-500"}),s&&l.jsx(bt,{size:18,className:"text-red-400"}),c&&(t?l.jsx(xt,{size:18,className:"text-gray-900"}):l.jsx(vt,{size:18,className:"text-gray-900"}))]}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("p",{className:"text-sm font-medium text-gray-900 truncate",title:e.file.name,children:e.file.name}),l.jsx("p",{className:"text-xs text-gray-900",children:Kn(e.file.size)}),n&&l.jsx("div",{className:"mt-1.5 w-full bg-blue-100 rounded-full h-1.5",children:l.jsx("div",{className:"bg-blue-500 h-1.5 rounded-full transition-all duration-200",style:{width:`${e.progress}%`}})}),s&&e.error&&l.jsx("p",{className:"text-xs text-red-500 mt-0.5 truncate",children:e.error})]}),l.jsxs("div",{className:"shrink-0 flex items-center gap-2",children:[n&&l.jsxs("span",{className:"text-xs font-semibold text-blue-600",children:[e.progress,"%"]}),a&&l.jsx("span",{className:"text-xs font-medium text-emerald-600 bg-emerald-100 px-2 py-0.5 rounded-full",children:"Done"}),s&&l.jsx("span",{className:"text-xs font-medium text-red-500 bg-red-100 px-2 py-0.5 rounded-full",children:"Failed"}),(c||s)&&l.jsx("button",{onClick:()=>r(e.id),className:"text-gray-900 hover:text-red-500 transition-colors",title:"Remove",children:l.jsx(yt,{size:14})})]})]})}const Jn=3;function io({accept:e,acceptMime:t,label:r,hint:n,isImage:a=!1,folders:s=[],defaultFolderId:c=null,onComplete:y}){const[f,x]=F.useState([]),[S,R]=F.useState(!1),[P,$]=F.useState(c),B=F.useRef(null),C=F.useRef(0);F.useEffect(()=>{$(c)},[c]);const O=f.filter(N=>N.status==="uploading").length,L=f.filter(N=>N.status==="done").length,_=f.filter(N=>N.status==="failed").length,g=f.filter(N=>N.status==="waiting").length,b=f.length,h=O>0||g>0,d=F.useCallback(N=>{const z=Array.from(N).filter(I=>t.length===0||t.some(M=>M.endsWith("/*")?I.type.startsWith(M.replace("/*","/")):I.type===M||I.name.toLowerCase().endsWith(M.replace(".",""))));if(z.length===0)return;const w=z.map(I=>({id:`${I.name}-${I.size}-${Date.now()}-${Math.random()}`,file:I,status:"waiting",progress:0}));x(I=>[...I,...w])},[t]);F.useEffect(()=>{function N(){x(z=>{const w=z.filter(o=>o.status==="waiting"),I=Jn-C.current;if(I<=0||w.length===0)return z;const M=w.slice(0,I);C.current+=M.length;const u=new Set(M.map(o=>o.id));return M.forEach(o=>{(async()=>{try{const{fileId:i}=await Wn(o.file,p=>{x(v=>v.map(m=>m.id===o.id?{...m,progress:p,status:"uploading"}:m))});P&&i&&await Yn(`${K}/admin/media/files/${i}/folder`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({folderId:P})}),x(p=>p.map(v=>v.id===o.id?{...v,status:"done",progress:100,fileId:i}:v))}catch(i){x(p=>p.map(v=>v.id===o.id?{...v,status:"failed",error:i.message}:v))}finally{C.current=Math.max(0,C.current-1),x(i=>[...i])}})()}),z.map(o=>u.has(o.id)?{...o,status:"uploading"}:o)})}N()},[f,P]),F.useEffect(()=>{b>0&&g===0&&O===0&&y?.()},[g,O,b,y]);function j(N){N.preventDefault(),R(!1),d(N.dataTransfer.files)}function k(N){x(z=>z.filter(w=>w.id!==N))}function U(){x(N=>N.filter(z=>z.status==="waiting"||z.status==="uploading"))}const D=s.find(N=>N.id===P);return l.jsxs("div",{className:"space-y-3",children:[s.length>0&&l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(Fe,{size:14,className:"text-gray-900 shrink-0"}),l.jsx("span",{className:"text-xs text-gray-900 shrink-0",children:"Upload to folder:"}),l.jsxs("select",{value:P??"",onChange:N=>$(N.target.value?Number(N.target.value):null),disabled:h,className:"flex-1 text-xs border border-gray-200 rounded-lg px-2 py-1.5 bg-white text-gray-900 focus:outline-none focus:ring-2 focus:ring-indigo-300 disabled:opacity-60",children:[l.jsx("option",{value:"",children:"â No folder (All Media)"}),s.map(N=>l.jsx("option",{value:N.id,children:N.name},N.id))]}),D&&l.jsx("span",{className:"w-3 h-3 rounded-sm shrink-0",style:{background:D.color}})]}),l.jsxs("div",{onDrop:j,onDragOver:N=>{N.preventDefault(),R(!0)},onDragLeave:()=>R(!1),className:`rounded-2xl border-2 border-dashed p-6 text-center transition-all ${S?"border-blue-400 bg-blue-50":"border-gray-200 bg-white hover:border-blue-300 hover:bg-blue-50/20"}`,children:[l.jsx("input",{ref:B,type:"file",accept:e,multiple:!0,className:"hidden",onChange:N=>{N.target.files&&d(N.target.files),N.target.value=""}}),a?l.jsx(xt,{size:28,className:"text-gray-900 mx-auto mb-2"}):l.jsx(vt,{size:28,className:"text-gray-900 mx-auto mb-2"}),l.jsx("p",{className:"text-sm font-semibold text-gray-900",children:S?"Drop files to queue them":r}),l.jsx("p",{className:"text-xs text-gray-900 mt-1",children:n}),l.jsxs(Q,{size:"sm",className:"mt-3 bg-blue-600 hover:bg-blue-700 gap-1.5",onClick:()=>B.current?.click(),children:[l.jsx(se,{size:14})," Choose Files"]})]}),f.length>0&&l.jsxs("div",{className:"space-y-2",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{className:"flex items-center gap-3 text-xs text-gray-900",children:[h&&l.jsxs("span",{className:"flex items-center gap-1 font-medium text-blue-600",children:[l.jsx(me,{size:12,className:"animate-spin"}),O," uploading",g>0?`, ${g} waiting`:""," (",L,"/",b," done)"]}),!h&&L>0&&l.jsxs("span",{className:"font-medium text-emerald-600",children:[L," uploaded successfully"]}),_>0&&l.jsxs("span",{className:"text-red-500",children:[_," failed"]})]}),(L>0||_>0)&&l.jsx("button",{onClick:U,className:"text-xs text-gray-900 hover:text-gray-600 transition-colors",children:"Clear finished"})]}),h&&b>1&&l.jsx("div",{className:"w-full bg-gray-100 rounded-full h-1.5",children:l.jsx("div",{className:"bg-blue-400 h-1.5 rounded-full transition-all duration-300",style:{width:`${Math.round(L/b*100)}%`}})}),l.jsx("div",{className:"space-y-2 max-h-72 overflow-y-auto pr-1",children:f.map(N=>l.jsx(Xn,{item:N,isImage:a,onRemove:k},N.id))})]})]})}export{io as B,Fe as F,ao as M,zn as a,Bn as e,qn as h,In as t,Hn as u};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.