@mux/mux-uploader-react
Advanced tools
Comparing version 0.1.0-canary.1-1d57669 to 0.1.0-canary.10-3e02bf0
@@ -1,29 +0,11 @@ | ||
var Qe=Object.create;var se=Object.defineProperty;var Ye=Object.getOwnPropertyDescriptor;var $e=Object.getOwnPropertyNames;var Ze=Object.getPrototypeOf,et=Object.prototype.hasOwnProperty;var Me=e=>se(e,"__esModule",{value:!0});var tt=(e,n)=>()=>(n||e((n={exports:{}}).exports,n),n.exports),nt=(e,n)=>{Me(e);for(var o in n)se(e,o,{get:n[o],enumerable:!0})},rt=(e,n,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of $e(n))!et.call(e,r)&&r!=="default"&&se(e,r,{get:()=>n[r],enumerable:!(o=Ye(n,r))||o.enumerable});return e},K=e=>rt(Me(se(e!=null?Qe(Ze(e)):{},"default",e&&e.__esModule&&"default"in e?{get:()=>e.default,enumerable:!0}:{value:e,enumerable:!0})),e);var Oe=(e,n,o)=>{if(!n.has(e))throw TypeError("Cannot "+o)};var Se=(e,n,o)=>(Oe(e,n,"read from private field"),o?o.call(e):n.get(e)),Le=(e,n,o)=>{if(n.has(e))throw TypeError("Cannot add the same private member more than once");n instanceof WeakSet?n.add(e):n.set(e,o)},De=(e,n,o,r)=>(Oe(e,n,"write to private field"),r?r.call(e,o):n.set(e,o),o);var _e=tt((Z,de)=>{(function(e,n){typeof Z=="object"&&typeof de=="object"?de.exports=n():typeof define=="function"&&define.amd?define([],n):typeof Z=="object"?Z.UpChunk=n():e.UpChunk=n()})(Z,function(){return function(e){var n={};function o(r){if(n[r])return n[r].exports;var a=n[r]={i:r,l:!1,exports:{}};return e[r].call(a.exports,a,a.exports,o),a.l=!0,a.exports}return o.m=e,o.c=n,o.d=function(r,a,c){o.o(r,a)||Object.defineProperty(r,a,{enumerable:!0,get:c})},o.r=function(r){typeof Symbol!="undefined"&&Symbol.toStringTag&&Object.defineProperty(r,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(r,"__esModule",{value:!0})},o.t=function(r,a){if(1&a&&(r=o(r)),8&a||4&a&&typeof r=="object"&&r&&r.__esModule)return r;var c=Object.create(null);if(o.r(c),Object.defineProperty(c,"default",{enumerable:!0,value:r}),2&a&&typeof r!="string")for(var b in r)o.d(c,b,function(E){return r[E]}.bind(null,b));return c},o.n=function(r){var a=r&&r.__esModule?function(){return r.default}:function(){return r};return o.d(a,"a",a),a},o.o=function(r,a){return Object.prototype.hasOwnProperty.call(r,a)},o.p="",o(o.s=1)}([function(e,n){var o;o=function(){return this}();try{o=o||new Function("return this")()}catch{typeof window=="object"&&(o=window)}e.exports=o},function(e,n,o){"use strict";var r=this&&this.__assign||function(){return(r=Object.assign||function(d){for(var t,u=1,v=arguments.length;u<v;u++)for(var w in t=arguments[u])Object.prototype.hasOwnProperty.call(t,w)&&(d[w]=t[w]);return d}).apply(this,arguments)};n.__esModule=!0,n.createUpload=n.UpChunk=void 0;var a=o(2),c=o(4),b=[200,201,202,204,308],E=[408,502,503,504],y=function(){function d(t){var u=this;this.endpoint=t.endpoint,this.file=t.file,this.headers=t.headers||{},this.method=t.method||"PUT",this.chunkSize=t.chunkSize||30720,this.attempts=t.attempts||5,this.delayBeforeAttempt=t.delayBeforeAttempt||1,this.maxFileBytes=1024*(t.maxFileSize||0),this.chunkCount=0,this.chunkByteSize=1024*this.chunkSize,this.totalChunks=Math.ceil(this.file.size/this.chunkByteSize),this.attemptCount=0,this.offline=!1,this.paused=!1,this.success=!1,this.reader=new FileReader,this.eventTarget=new a.EventTarget,this.validateOptions(),this.getEndpoint().then(function(){return u.sendChunks()}),typeof window!="undefined"&&(window.addEventListener("online",function(){u.offline&&(u.offline=!1,u.dispatch("online"),u.sendChunks())}),window.addEventListener("offline",function(){u.offline=!0,u.dispatch("offline")}))}return d.prototype.on=function(t,u){this.eventTarget.addEventListener(t,u)},d.prototype.abort=function(){var t;this.pause(),(t=this.currentXhr)===null||t===void 0||t.abort()},d.prototype.pause=function(){this.paused=!0},d.prototype.resume=function(){this.paused&&(this.paused=!1,this.sendChunks())},d.prototype.dispatch=function(t,u){var v=new CustomEvent(t,{detail:u});this.eventTarget.dispatchEvent(v)},d.prototype.validateOptions=function(){if(!this.endpoint||typeof this.endpoint!="function"&&typeof this.endpoint!="string")throw new TypeError("endpoint must be defined as a string or a function that returns a promise");if(!(this.file instanceof File))throw new TypeError("file must be a File object");if(this.headers&&typeof this.headers!="object")throw new TypeError("headers must be null or an object");if(this.chunkSize&&(typeof this.chunkSize!="number"||this.chunkSize<=0||this.chunkSize%256!=0))throw new TypeError("chunkSize must be a positive number in multiples of 256");if(this.maxFileBytes>0&&this.maxFileBytes<this.file.size)throw new Error("file size exceeds maximum (".concat(this.file.size," > ").concat(this.maxFileBytes,")"));if(this.attempts&&(typeof this.attempts!="number"||this.attempts<=0))throw new TypeError("retries must be a positive number");if(this.delayBeforeAttempt&&(typeof this.delayBeforeAttempt!="number"||this.delayBeforeAttempt<0))throw new TypeError("delayBeforeAttempt must be a positive number")},d.prototype.getEndpoint=function(){var t=this;return typeof this.endpoint=="string"?(this.endpointValue=this.endpoint,Promise.resolve(this.endpoint)):this.endpoint(this.file).then(function(u){return t.endpointValue=u,t.endpointValue})},d.prototype.getChunk=function(){var t=this;return new Promise(function(u){var v=t.totalChunks===1?t.file.size:t.chunkByteSize,w=v*t.chunkCount;t.reader.onload=function(){t.reader.result!==null&&(t.chunk=new Blob([t.reader.result],{type:"application/octet-stream"})),u()},t.reader.readAsArrayBuffer(t.file.slice(w,w+v))})},d.prototype.xhrPromise=function(t){var u=this,v=function(w){w.upload.onprogress=function(L){var R,T=100/u.totalChunks,C=T*u.file.size,h=T*u.chunkCount,_=L.loaded/((R=L.total)!==null&&R!==void 0?R:C)*T;u.dispatch("progress",Math.min(h+_,100))}};return new Promise(function(w,L){u.currentXhr=(0,c.default)(r(r({},t),{beforeSend:v}),function(R,T){return u.currentXhr=void 0,R?L(R):w(T)})})},d.prototype.sendChunk=function(){var t=this.chunkCount*this.chunkByteSize,u=t+this.chunk.size-1,v=r(r({},this.headers),{"Content-Type":this.file.type,"Content-Range":"bytes ".concat(t,"-").concat(u,"/").concat(this.file.size)});return this.dispatch("attempt",{chunkNumber:this.chunkCount,chunkSize:this.chunk.size}),this.xhrPromise({headers:v,url:this.endpointValue,method:this.method,body:this.chunk})},d.prototype.manageRetries=function(){var t=this;if(this.attemptCount<this.attempts)return setTimeout(function(){return t.sendChunks()},1e3*this.delayBeforeAttempt),void this.dispatch("attemptFailure",{message:"An error occured uploading chunk ".concat(this.chunkCount,". ").concat(this.attempts-this.attemptCount," retries left."),chunkNumber:this.chunkCount,attemptsLeft:this.attempts-this.attemptCount});this.dispatch("error",{message:"An error occured uploading chunk ".concat(this.chunkCount,". No more retries, stopping upload"),chunk:this.chunkCount,attempts:this.attemptCount})},d.prototype.sendChunks=function(){var t=this;this.paused||this.offline||this.success||this.getChunk().then(function(){return t.attemptCount=t.attemptCount+1,t.sendChunk()}).then(function(u){if(b.includes(u.statusCode)){t.dispatch("chunkSuccess",{chunk:t.chunkCount,attempts:t.attemptCount,response:u}),t.attemptCount=0,t.chunkCount=t.chunkCount+1,t.chunkCount<t.totalChunks?t.sendChunks():(t.success=!0,t.dispatch("success"));var v=100*(t.chunkCount/t.totalChunks*t.file.size)/t.file.size;t.dispatch("progress",v)}else if(E.includes(u.statusCode)){if(t.paused||t.offline)return;t.manageRetries()}else{if(t.paused||t.offline)return;t.dispatch("error",{message:"Server responded with ".concat(u.statusCode,". Stopping upload."),chunkNumber:t.chunkCount,attempts:t.attemptCount})}}).catch(function(u){t.paused||t.offline||t.manageRetries()})},d}();n.UpChunk=y,n.createUpload=function(d){return new y(d)}},function(e,n,o){"use strict";(function(r,a){function c(s,i,...l){if(!s)throw new TypeError(b(i,l))}function b(s,i){let l=0;return s.replace(/%[os]/gu,()=>E(i[l++]))}function E(s){return typeof s!="object"||s===null?String(s):Object.prototype.toString.call(s)}let y;Object.defineProperty(n,"__esModule",{value:!0});let d=typeof window!="undefined"?window:typeof self!="undefined"?self:a!==void 0?a:typeof globalThis!="undefined"?globalThis:void 0,t;class u{constructor(i,l){this.code=i,this.message=l}warn(...i){var l;try{if(t)return void t({...this,args:i});let p=((l=new Error().stack)!==null&&l!==void 0?l:"").replace(/^(?:.+?\n){2}/gu,` | ||
`);console.warn(this.message,...i,p)}catch{}}}let v=new u("W01","Unable to initialize event under dispatching."),w=new u("W02","Assigning any falsy value to 'cancelBubble' property has no effect."),L=new u("W03","Assigning any truthy value to 'returnValue' property has no effect."),R=new u("W04","Unable to preventDefault on non-cancelable events."),T=new u("W05","Unable to preventDefault inside passive event listener invocation."),C=new u("W06","An event listener wasn't added because it has been added already: %o, %o"),h=new u("W07","The %o option value was abandoned because the event listener wasn't added as duplicated."),_=new u("W08","The 'callback' argument must be a function or an object that has 'handleEvent' method: %o"),z=new u("W09","Event attribute handler must be a function: %o");class O{static get NONE(){return q}static get CAPTURING_PHASE(){return D}static get AT_TARGET(){return V}static get BUBBLING_PHASE(){return J}constructor(i,l){Object.defineProperty(this,"isTrusted",{value:!1,enumerable:!0});let p=l!=null?l:{};X.set(this,{type:String(i),bubbles:Boolean(p.bubbles),cancelable:Boolean(p.cancelable),composed:Boolean(p.composed),target:null,currentTarget:null,stopPropagationFlag:!1,stopImmediatePropagationFlag:!1,canceledFlag:!1,inPassiveListenerFlag:!1,dispatchFlag:!1,timeStamp:Date.now()})}get type(){return g(this).type}get target(){return g(this).target}get srcElement(){return g(this).target}get currentTarget(){return g(this).currentTarget}composedPath(){let i=g(this).currentTarget;return i?[i]:[]}get NONE(){return q}get CAPTURING_PHASE(){return D}get AT_TARGET(){return V}get BUBBLING_PHASE(){return J}get eventPhase(){return g(this).dispatchFlag?2:0}stopPropagation(){g(this).stopPropagationFlag=!0}get cancelBubble(){return g(this).stopPropagationFlag}set cancelBubble(i){i?g(this).stopPropagationFlag=!0:w.warn()}stopImmediatePropagation(){let i=g(this);i.stopPropagationFlag=i.stopImmediatePropagationFlag=!0}get bubbles(){return g(this).bubbles}get cancelable(){return g(this).cancelable}get returnValue(){return!g(this).canceledFlag}set returnValue(i){i?L.warn():k(g(this))}preventDefault(){k(g(this))}get defaultPrevented(){return g(this).canceledFlag}get composed(){return g(this).composed}get isTrusted(){return!1}get timeStamp(){return g(this).timeStamp}initEvent(i,l=!1,p=!1){let f=g(this);f.dispatchFlag?v.warn():X.set(this,{...f,type:String(i),bubbles:Boolean(l),cancelable:Boolean(p),target:null,currentTarget:null,stopPropagationFlag:!1,stopImmediatePropagationFlag:!1,canceledFlag:!1})}}let q=0,D=1,V=2,J=3,X=new WeakMap;function g(s,i="this"){let l=X.get(s);return c(l!=null,"'%s' must be an object that Event constructor created, but got another one: %o",i,s),l}function k(s){s.inPassiveListenerFlag?T.warn():s.cancelable?s.canceledFlag=!0:R.warn()}Object.defineProperty(O,"NONE",{enumerable:!0}),Object.defineProperty(O,"CAPTURING_PHASE",{enumerable:!0}),Object.defineProperty(O,"AT_TARGET",{enumerable:!0}),Object.defineProperty(O,"BUBBLING_PHASE",{enumerable:!0});let B=Object.getOwnPropertyNames(O.prototype);for(let s=0;s<B.length;++s)B[s]!=="constructor"&&Object.defineProperty(O.prototype,B[s],{enumerable:!0});let N;d!==void 0&&d.Event!==void 0&&Object.setPrototypeOf(O.prototype,d.Event.prototype);let he={INDEX_SIZE_ERR:1,DOMSTRING_SIZE_ERR:2,HIERARCHY_REQUEST_ERR:3,WRONG_DOCUMENT_ERR:4,INVALID_CHARACTER_ERR:5,NO_DATA_ALLOWED_ERR:6,NO_MODIFICATION_ALLOWED_ERR:7,NOT_FOUND_ERR:8,NOT_SUPPORTED_ERR:9,INUSE_ATTRIBUTE_ERR:10,INVALID_STATE_ERR:11,SYNTAX_ERR:12,INVALID_MODIFICATION_ERR:13,NAMESPACE_ERR:14,INVALID_ACCESS_ERR:15,VALIDATION_ERR:16,TYPE_MISMATCH_ERR:17,SECURITY_ERR:18,NETWORK_ERR:19,ABORT_ERR:20,URL_MISMATCH_ERR:21,QUOTA_EXCEEDED_ERR:22,TIMEOUT_ERR:23,INVALID_NODE_TYPE_ERR:24,DATA_CLONE_ERR:25};function fe(s){let i=Object.keys(he);for(let l=0;l<i.length;++l){let p=i[l],f=he[p];Object.defineProperty(s,p,{get:()=>f,configurable:!0,enumerable:!0})}}class Q extends O{static wrap(i){return new(function l(p){let f=Object.getPrototypeOf(p);if(f==null)return Q;let m=re.get(f);return m==null&&(m=function(A,P){class M extends A{}let x=Object.keys(P);for(let S=0;S<x.length;++S)Object.defineProperty(M.prototype,x[S],me(P,x[S]));return M}(l(f),f),re.set(f,m)),m}(i))(i)}constructor(i){super(i.type,{bubbles:i.bubbles,cancelable:i.cancelable,composed:i.composed}),i.cancelBubble&&super.stopPropagation(),i.defaultPrevented&&super.preventDefault(),ge.set(this,{original:i});let l=Object.keys(i);for(let p=0;p<l.length;++p){let f=l[p];f in this||Object.defineProperty(this,f,me(i,f))}}stopPropagation(){super.stopPropagation();let{original:i}=F(this);"stopPropagation"in i&&i.stopPropagation()}get cancelBubble(){return super.cancelBubble}set cancelBubble(i){super.cancelBubble=i;let{original:l}=F(this);"cancelBubble"in l&&(l.cancelBubble=i)}stopImmediatePropagation(){super.stopImmediatePropagation();let{original:i}=F(this);"stopImmediatePropagation"in i&&i.stopImmediatePropagation()}get returnValue(){return super.returnValue}set returnValue(i){super.returnValue=i;let{original:l}=F(this);"returnValue"in l&&(l.returnValue=i)}preventDefault(){super.preventDefault();let{original:i}=F(this);"preventDefault"in i&&i.preventDefault()}get timeStamp(){let{original:i}=F(this);return"timeStamp"in i?i.timeStamp:super.timeStamp}}let ge=new WeakMap;function F(s){let i=ge.get(s);return c(i!=null,"'this' is expected an Event object, but got",s),i}let re=new WeakMap;function me(s,i){let l=Object.getOwnPropertyDescriptor(s,i);return{get(){let p=F(this).original,f=p[i];return typeof f=="function"?f.bind(p):f},set(p){F(this).original[i]=p},configurable:l.configurable,enumerable:l.enumerable}}function be(s){return(1&s.flags)==1}function ye(s){return(2&s.flags)==2}function ve(s){return(4&s.flags)==4}function Ke(s){return(8&s.flags)==8}function Je({callback:s},i,l){try{typeof s=="function"?s.call(i,l):typeof s.handleEvent=="function"&&s.handleEvent(l)}catch(p){(function(f){try{let m=f instanceof Error?f:new Error(E(f));if(y)return void y(m);if(typeof dispatchEvent=="function"&&typeof ErrorEvent=="function")dispatchEvent(new ErrorEvent("error",{error:m,message:m.message}));else if(r!==void 0&&typeof r.emit=="function")return void r.emit("uncaughtException",m);console.error(m)}catch{}})(p)}}function Ee({listeners:s},i,l){for(let p=0;p<s.length;++p)if(s[p].callback===i&&be(s[p])===l)return p;return-1}function Te(s,i,l,p,f,m){let A;m&&(A=ce.bind(null,s,i,l),m.addEventListener("abort",A));let P=function(M,x,S,U,oe,j){return{callback:M,flags:(x?1:0)|(S?2:0)|(U?4:0),signal:oe,signalListener:j}}(i,l,p,f,m,A);return s.cow?(s.cow=!1,s.listeners=[...s.listeners,P]):s.listeners.push(P),P}function ce(s,i,l){let p=Ee(s,i,l);return p!==-1&&we(s,p)}function we(s,i,l=!1){let p=s.listeners[i];return function(f){f.flags|=8}(p),p.signal&&p.signal.removeEventListener("abort",p.signalListener),s.cow&&!l?(s.cow=!1,s.listeners=s.listeners.filter((f,m)=>m!==i),!1):(s.listeners.splice(i,1),!0)}function Re(s,i){var l;return(l=s[i])!==null&&l!==void 0?l:s[i]={attrCallback:void 0,attrListener:void 0,cow:!1,listeners:[]}}re.set(Object.prototype,Q),d!==void 0&&d.Event!==void 0&&re.set(d.Event.prototype,Q);class G{constructor(){xe.set(this,Object.create(null))}addEventListener(i,l,p){let f=W(this),{callback:m,capture:A,once:P,passive:M,signal:x,type:S}=function(j,H,I){var Y;return ke(H),typeof I=="object"&&I!==null?{type:String(j),callback:H!=null?H:void 0,capture:Boolean(I.capture),passive:Boolean(I.passive),once:Boolean(I.once),signal:(Y=I.signal)!==null&&Y!==void 0?Y:void 0}:{type:String(j),callback:H!=null?H:void 0,capture:Boolean(I),passive:!1,once:!1,signal:void 0}}(i,l,p);if(m==null||(x==null?void 0:x.aborted))return;let U=Re(f,S),oe=Ee(U,m,A);oe===-1?Te(U,m,A,M,P,x):function(j,H,I,Y){C.warn(be(j)?"capture":"bubble",j.callback),ye(j)!==H&&h.warn("passive"),ve(j)!==I&&h.warn("once"),j.signal!==Y&&h.warn("signal")}(U.listeners[oe],M,P,x)}removeEventListener(i,l,p){let f=W(this),{callback:m,capture:A,type:P}=function(x,S,U){return ke(S),typeof U=="object"&&U!==null?{type:String(x),callback:S!=null?S:void 0,capture:Boolean(U.capture)}:{type:String(x),callback:S!=null?S:void 0,capture:Boolean(U)}}(i,l,p),M=f[P];m!=null&&M&&ce(M,m,A)}dispatchEvent(i){let l=W(this)[String(i.type)];if(l==null)return!0;let p=i instanceof O?i:Q.wrap(i),f=g(p,"event");if(f.dispatchFlag)throw m="This event has been in dispatching.",d.DOMException?new d.DOMException(m,"InvalidStateError"):(N==null&&(N=class je extends Error{constructor(P){super(P),Error.captureStackTrace&&Error.captureStackTrace(this,je)}get code(){return 11}get name(){return"InvalidStateError"}},Object.defineProperties(N.prototype,{code:{enumerable:!0},name:{enumerable:!0}}),fe(N),fe(N.prototype)),new N(m));var m;if(f.dispatchFlag=!0,f.target=f.currentTarget=this,!f.stopPropagationFlag){let{cow:A,listeners:P}=l;l.cow=!0;for(let M=0;M<P.length;++M){let x=P[M];if(!Ke(x)&&(ve(x)&&we(l,M,!A)&&(M-=1),f.inPassiveListenerFlag=ye(x),Je(x,this,p),f.inPassiveListenerFlag=!1,f.stopImmediatePropagationFlag))break}A||(l.cow=!1)}return f.target=null,f.currentTarget=null,f.stopImmediatePropagationFlag=!1,f.stopPropagationFlag=!1,f.dispatchFlag=!1,!f.canceledFlag}}let xe=new WeakMap;function W(s,i="this"){let l=xe.get(s);return c(l!=null,"'%s' must be an object that EventTarget constructor created, but got another one: %o",i,s),l}function ke(s){if(typeof s!="function"&&(typeof s!="object"||s===null||typeof s.handleEvent!="function")){if(s!=null&&typeof s!="object")throw new TypeError(b(_.message,[s]));_.warn(s)}}let pe=Object.getOwnPropertyNames(G.prototype);for(let s=0;s<pe.length;++s)pe[s]!=="constructor"&&Object.defineProperty(G.prototype,pe[s],{enumerable:!0});function Ae(s,i){var l,p;return(p=(l=W(s,"target")[i])===null||l===void 0?void 0:l.attrCallback)!==null&&p!==void 0?p:null}function Ce(s,i,l){l!=null&&typeof l!="function"&&z.warn(l),typeof l=="function"||typeof l=="object"&&l!==null?function(p,f,m){let A=Re(W(p,"target"),String(f));A.attrCallback=m,A.attrListener==null&&(A.attrListener=Te(A,function(P){return function(M){let x=P.attrCallback;typeof x=="function"&&x.call(this,M)}}(A),!1,!1,!1,void 0))}(s,i,l):function(p,f){let m=W(p,"target")[String(f)];m&&m.attrListener&&(ce(m,m.attrListener.callback,!1),m.attrCallback=m.attrListener=void 0)}(s,i)}function Pe(s,i,l){Object.defineProperty(s,"on"+i,{get(){return Ae(this,i)},set(p){Ce(this,i,p)},configurable:!0,enumerable:!0})}d!==void 0&&d.EventTarget!==void 0&&Object.setPrototypeOf(G.prototype,d.EventTarget.prototype),n.Event=O,n.EventTarget=G,n.default=G,n.defineCustomEventTarget=function(...s){class i extends G{}for(let l=0;l<s.length;++l)Pe(i.prototype,s[l]);return i},n.defineEventAttribute=Pe,n.getEventAttributeValue=Ae,n.setErrorHandler=function(s){c(typeof s=="function"||s===void 0,"The error handler must be a function or undefined, but got %o.",s),y=s},n.setEventAttributeValue=Ce,n.setWarningHandler=function(s){c(typeof s=="function"||s===void 0,"The warning handler must be a function or undefined, but got %o.",s),t=s}}).call(this,o(3),o(0))},function(e,n){var o,r,a=e.exports={};function c(){throw new Error("setTimeout has not been defined")}function b(){throw new Error("clearTimeout has not been defined")}function E(T){if(o===setTimeout)return setTimeout(T,0);if((o===c||!o)&&setTimeout)return o=setTimeout,setTimeout(T,0);try{return o(T,0)}catch{try{return o.call(null,T,0)}catch{return o.call(this,T,0)}}}(function(){try{o=typeof setTimeout=="function"?setTimeout:c}catch{o=c}try{r=typeof clearTimeout=="function"?clearTimeout:b}catch{r=b}})();var y,d=[],t=!1,u=-1;function v(){t&&y&&(t=!1,y.length?d=y.concat(d):u=-1,d.length&&w())}function w(){if(!t){var T=E(v);t=!0;for(var C=d.length;C;){for(y=d,d=[];++u<C;)y&&y[u].run();u=-1,C=d.length}y=null,t=!1,function(h){if(r===clearTimeout)return clearTimeout(h);if((r===b||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(h);try{r(h)}catch{try{return r.call(null,h)}catch{return r.call(this,h)}}}(T)}}function L(T,C){this.fun=T,this.array=C}function R(){}a.nextTick=function(T){var C=new Array(arguments.length-1);if(arguments.length>1)for(var h=1;h<arguments.length;h++)C[h-1]=arguments[h];d.push(new L(T,C)),d.length!==1||t||E(w)},L.prototype.run=function(){this.fun.apply(null,this.array)},a.title="browser",a.browser=!0,a.env={},a.argv=[],a.version="",a.versions={},a.on=R,a.addListener=R,a.once=R,a.off=R,a.removeListener=R,a.removeAllListeners=R,a.emit=R,a.prependListener=R,a.prependOnceListener=R,a.listeners=function(T){return[]},a.binding=function(T){throw new Error("process.binding is not supported")},a.cwd=function(){return"/"},a.chdir=function(T){throw new Error("process.chdir is not supported")},a.umask=function(){return 0}},function(e,n,o){"use strict";var r=o(5),a=o(6),c=o(7),b=o(8);function E(t,u,v){var w=t;return a(u)?(v=u,typeof t=="string"&&(w={uri:t})):w=b(u,{uri:t}),w.callback=v,w}function y(t,u,v){return d(u=E(t,u,v))}function d(t){if(t.callback===void 0)throw new Error("callback argument missing");var u=!1,v=function(g,k,B){u||(u=!0,t.callback(g,k,B))};function w(){var g=void 0;if(g=h.response?h.response:h.responseText||function(k){try{if(k.responseType==="document")return k.responseXML;var B=k.responseXML&&k.responseXML.documentElement.nodeName==="parsererror";if(k.responseType===""&&!B)return k.responseXML}catch{}return null}(h),J)try{g=JSON.parse(g)}catch{}return g}function L(g){return clearTimeout(_),g instanceof Error||(g=new Error(""+(g||"Unknown XMLHttpRequest Error"))),g.statusCode=0,v(g,X)}function R(){if(!C){var g;clearTimeout(_),g=t.useXDR&&h.status===void 0?200:h.status===1223?204:h.status;var k=X,B=null;return g!==0?(k={body:w(),statusCode:g,method:O,headers:{},url:z,rawRequest:h},h.getAllResponseHeaders&&(k.headers=c(h.getAllResponseHeaders()))):B=new Error("Internal XMLHttpRequest Error"),v(B,k,k.body)}}var T,C,h=t.xhr||null;h||(h=t.cors||t.useXDR?new y.XDomainRequest:new y.XMLHttpRequest);var _,z=h.url=t.uri||t.url,O=h.method=t.method||"GET",q=t.body||t.data,D=h.headers=t.headers||{},V=!!t.sync,J=!1,X={body:void 0,headers:{},statusCode:0,method:O,url:z,rawRequest:h};if("json"in t&&t.json!==!1&&(J=!0,D.accept||D.Accept||(D.Accept="application/json"),O!=="GET"&&O!=="HEAD"&&(D["content-type"]||D["Content-Type"]||(D["Content-Type"]="application/json"),q=JSON.stringify(t.json===!0?q:t.json))),h.onreadystatechange=function(){h.readyState===4&&setTimeout(R,0)},h.onload=R,h.onerror=L,h.onprogress=function(){},h.onabort=function(){C=!0},h.ontimeout=L,h.open(O,z,!V,t.username,t.password),V||(h.withCredentials=!!t.withCredentials),!V&&t.timeout>0&&(_=setTimeout(function(){if(!C){C=!0,h.abort("timeout");var g=new Error("XMLHttpRequest timeout");g.code="ETIMEDOUT",L(g)}},t.timeout)),h.setRequestHeader)for(T in D)D.hasOwnProperty(T)&&h.setRequestHeader(T,D[T]);else if(t.headers&&!function(g){for(var k in g)if(g.hasOwnProperty(k))return!1;return!0}(t.headers))throw new Error("Headers cannot be set on an XDomainRequest object");return"responseType"in t&&(h.responseType=t.responseType),"beforeSend"in t&&typeof t.beforeSend=="function"&&t.beforeSend(h),h.send(q||null),h}e.exports=y,e.exports.default=y,y.XMLHttpRequest=r.XMLHttpRequest||function(){},y.XDomainRequest="withCredentials"in new y.XMLHttpRequest?y.XMLHttpRequest:r.XDomainRequest,function(t,u){for(var v=0;v<t.length;v++)u(t[v])}(["get","put","post","patch","head","delete"],function(t){y[t==="delete"?"del":t]=function(u,v,w){return(v=E(u,v,w)).method=t.toUpperCase(),d(v)}})},function(e,n,o){(function(r){var a;a=typeof window!="undefined"?window:r!==void 0?r:typeof self!="undefined"?self:{},e.exports=a}).call(this,o(0))},function(e,n){e.exports=function(r){if(!r)return!1;var a=o.call(r);return a==="[object Function]"||typeof r=="function"&&a!=="[object RegExp]"||typeof window!="undefined"&&(r===window.setTimeout||r===window.alert||r===window.confirm||r===window.prompt)};var o=Object.prototype.toString},function(e,n){var o=function(r){return r.replace(/^\s+|\s+$/g,"")};e.exports=function(r){if(!r)return{};for(var a,c={},b=o(r).split(` | ||
`),E=0;E<b.length;E++){var y=b[E],d=y.indexOf(":"),t=o(y.slice(0,d)).toLowerCase(),u=o(y.slice(d+1));c[t]===void 0?c[t]=u:(a=c[t],Object.prototype.toString.call(a)==="[object Array]"?c[t].push(u):c[t]=[c[t],u])}return c}},function(e,n){e.exports=function(){for(var r={},a=0;a<arguments.length;a++){var c=arguments[a];for(var b in c)o.call(c,b)&&(r[b]=c[b])}return r};var o=Object.prototype.hasOwnProperty}])})});nt(exports,{MuxUploaderDrop:()=>Ge,default:()=>yt});var ne=K(require("react"));if(typeof DocumentFragment=="undefined"){class e{}globalThis.DocumentFragment=e}globalThis.customElements||(globalThis.customElements={get(e){},define(e,n,o){},upgrade(e){},whenDefined(e){return Promise.resolve(globalThis.HTMLElement)}});var $;if(!globalThis.CustomEvent){class e{constructor(o,r={}){Le(this,$,void 0);De(this,$,r==null?void 0:r.detail)}get detail(){Se(this,$)}initCustomEvent(o,r,a,c){}}$=new WeakMap,globalThis.CustomEvent=e}if(!globalThis.EventTarget){class e{addEventListener(){}removeEventListener(){}dispatchEvent(o){return!0}}globalThis.EventTarget=e}if(!globalThis.HTMLElement){class e extends EventTarget{}globalThis.HTMLElement=e}if(!globalThis.HTMLVideoElement){class e extends EventTarget{}globalThis.HTMLVideoElement=e}var Be,Ue;if(!((Be=globalThis.document)==null?void 0:Be.createElement)){let e=(Ue=globalThis.document)!=null?Ue:{};e.createElement=function(o,r){return new HTMLElement},globalThis.document=e}var Ie=K(_e()),Fe=document.createElement("template");Fe.innerHTML=` | ||
var et=Object.create;var se=Object.defineProperty;var tt=Object.getOwnPropertyDescriptor;var nt=Object.getOwnPropertyNames;var rt=Object.getPrototypeOf,ot=Object.prototype.hasOwnProperty;var Le=e=>se(e,"__esModule",{value:!0});var st=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),it=(e,t)=>{Le(e);for(var r in t)se(e,r,{get:t[r],enumerable:!0})},at=(e,t,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of nt(t))!ot.call(e,o)&&o!=="default"&&se(e,o,{get:()=>t[o],enumerable:!(r=tt(t,o))||r.enumerable});return e},z=e=>at(Le(se(e!=null?et(rt(e)):{},"default",e&&e.__esModule&&"default"in e?{get:()=>e.default,enumerable:!0}:{value:e,enumerable:!0})),e);var Se=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)};var _e=(e,t,r)=>(Se(e,t,"read from private field"),r?r.call(e):t.get(e)),Be=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},Ue=(e,t,r,o)=>(Se(e,t,"write to private field"),o?o.call(e,r):t.set(e,r),r);var Fe=st((ee,he)=>{(function(e,t){typeof ee=="object"&&typeof he=="object"?he.exports=t():typeof define=="function"&&define.amd?define([],t):typeof ee=="object"?ee.UpChunk=t():e.UpChunk=t()})(ee,function(){return function(e){var t={};function r(o){if(t[o])return t[o].exports;var a=t[o]={i:o,l:!1,exports:{}};return e[o].call(a.exports,a,a.exports,r),a.l=!0,a.exports}return r.m=e,r.c=t,r.d=function(o,a,p){r.o(o,a)||Object.defineProperty(o,a,{enumerable:!0,get:p})},r.r=function(o){typeof Symbol!="undefined"&&Symbol.toStringTag&&Object.defineProperty(o,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(o,"__esModule",{value:!0})},r.t=function(o,a){if(1&a&&(o=r(o)),8&a||4&a&&typeof o=="object"&&o&&o.__esModule)return o;var p=Object.create(null);if(r.r(p),Object.defineProperty(p,"default",{enumerable:!0,value:o}),2&a&&typeof o!="string")for(var T in o)r.d(p,T,function(R){return o[R]}.bind(null,T));return p},r.n=function(o){var a=o&&o.__esModule?function(){return o.default}:function(){return o};return r.d(a,"a",a),a},r.o=function(o,a){return Object.prototype.hasOwnProperty.call(o,a)},r.p="",r(r.s=1)}([function(e,t){var r;r=function(){return this}();try{r=r||new Function("return this")()}catch{typeof window=="object"&&(r=window)}e.exports=r},function(e,t,r){"use strict";var o=this&&this.__assign||function(){return(o=Object.assign||function(f){for(var n,l=1,b=arguments.length;l<b;l++)for(var E in n=arguments[l])Object.prototype.hasOwnProperty.call(n,E)&&(f[E]=n[E]);return f}).apply(this,arguments)};t.__esModule=!0,t.createUpload=t.UpChunk=void 0;var a=r(2),p=r(4),T=[200,201,202,204,308],R=[408,502,503,504],v=function(){function f(n){var l=this;this.endpoint=n.endpoint,this.file=n.file,this.headers=n.headers||{},this.method=n.method||"PUT",this.chunkSize=n.chunkSize||30720,this.attempts=n.attempts||5,this.delayBeforeAttempt=n.delayBeforeAttempt||1,this.maxFileBytes=1024*(n.maxFileSize||0),this.chunkCount=0,this.chunkByteSize=1024*this.chunkSize,this.totalChunks=Math.ceil(this.file.size/this.chunkByteSize),this.attemptCount=0,this.offline=!1,this.paused=!1,this.success=!1,this.reader=new FileReader,this.eventTarget=new a.EventTarget,this.validateOptions(),this.getEndpoint().then(function(){return l.sendChunks()}),typeof window!="undefined"&&(window.addEventListener("online",function(){l.offline&&(l.offline=!1,l.dispatch("online"),l.sendChunks())}),window.addEventListener("offline",function(){l.offline=!0,l.dispatch("offline")}))}return f.prototype.on=function(n,l){this.eventTarget.addEventListener(n,l)},f.prototype.abort=function(){var n;this.pause(),(n=this.currentXhr)===null||n===void 0||n.abort()},f.prototype.pause=function(){this.paused=!0},f.prototype.resume=function(){this.paused&&(this.paused=!1,this.sendChunks())},f.prototype.dispatch=function(n,l){var b=new CustomEvent(n,{detail:l});this.eventTarget.dispatchEvent(b)},f.prototype.validateOptions=function(){if(!this.endpoint||typeof this.endpoint!="function"&&typeof this.endpoint!="string")throw new TypeError("endpoint must be defined as a string or a function that returns a promise");if(!(this.file instanceof File))throw new TypeError("file must be a File object");if(this.headers&&typeof this.headers!="object")throw new TypeError("headers must be null or an object");if(this.chunkSize&&(typeof this.chunkSize!="number"||this.chunkSize<=0||this.chunkSize%256!=0))throw new TypeError("chunkSize must be a positive number in multiples of 256");if(this.maxFileBytes>0&&this.maxFileBytes<this.file.size)throw new Error("file size exceeds maximum (".concat(this.file.size," > ").concat(this.maxFileBytes,")"));if(this.attempts&&(typeof this.attempts!="number"||this.attempts<=0))throw new TypeError("retries must be a positive number");if(this.delayBeforeAttempt&&(typeof this.delayBeforeAttempt!="number"||this.delayBeforeAttempt<0))throw new TypeError("delayBeforeAttempt must be a positive number")},f.prototype.getEndpoint=function(){var n=this;return typeof this.endpoint=="string"?(this.endpointValue=this.endpoint,Promise.resolve(this.endpoint)):this.endpoint(this.file).then(function(l){return n.endpointValue=l,n.endpointValue})},f.prototype.getChunk=function(){var n=this;return new Promise(function(l){var b=n.totalChunks===1?n.file.size:n.chunkByteSize,E=b*n.chunkCount;n.reader.onload=function(){n.reader.result!==null&&(n.chunk=new Blob([n.reader.result],{type:"application/octet-stream"})),l()},n.reader.readAsArrayBuffer(n.file.slice(E,E+b))})},f.prototype.xhrPromise=function(n){var l=this,b=function(E){E.upload.onprogress=function(x){var w,y=100/l.totalChunks,A=y*l.file.size,d=y*l.chunkCount,j=x.loaded/((w=x.total)!==null&&w!==void 0?w:A)*y;l.dispatch("progress",Math.min(d+j,100))}};return new Promise(function(E,x){l.currentXhr=(0,p.default)(o(o({},n),{beforeSend:b}),function(w,y){return l.currentXhr=void 0,w?x(w):E(y)})})},f.prototype.sendChunk=function(){var n=this.chunkCount*this.chunkByteSize,l=n+this.chunk.size-1,b=o(o({},this.headers),{"Content-Type":this.file.type,"Content-Range":"bytes ".concat(n,"-").concat(l,"/").concat(this.file.size)});return this.dispatch("attempt",{chunkNumber:this.chunkCount,chunkSize:this.chunk.size}),this.xhrPromise({headers:b,url:this.endpointValue,method:this.method,body:this.chunk})},f.prototype.manageRetries=function(){var n=this;if(this.attemptCount<this.attempts)return setTimeout(function(){return n.sendChunks()},1e3*this.delayBeforeAttempt),void this.dispatch("attemptFailure",{message:"An error occured uploading chunk ".concat(this.chunkCount,". ").concat(this.attempts-this.attemptCount," retries left."),chunkNumber:this.chunkCount,attemptsLeft:this.attempts-this.attemptCount});this.dispatch("error",{message:"An error occured uploading chunk ".concat(this.chunkCount,". No more retries, stopping upload"),chunk:this.chunkCount,attempts:this.attemptCount})},f.prototype.sendChunks=function(){var n=this;this.paused||this.offline||this.success||this.getChunk().then(function(){return n.attemptCount=n.attemptCount+1,n.sendChunk()}).then(function(l){if(T.includes(l.statusCode)){n.dispatch("chunkSuccess",{chunk:n.chunkCount,attempts:n.attemptCount,response:l}),n.attemptCount=0,n.chunkCount=n.chunkCount+1,n.chunkCount<n.totalChunks?n.sendChunks():(n.success=!0,n.dispatch("success"));var b=100*(n.chunkCount/n.totalChunks*n.file.size)/n.file.size;n.dispatch("progress",b)}else if(R.includes(l.statusCode)){if(n.paused||n.offline)return;n.manageRetries()}else{if(n.paused||n.offline)return;n.dispatch("error",{message:"Server responded with ".concat(l.statusCode,". Stopping upload."),chunkNumber:n.chunkCount,attempts:n.attemptCount})}}).catch(function(l){n.paused||n.offline||n.manageRetries()})},f}();t.UpChunk=v,t.createUpload=function(f){return new v(f)}},function(e,t,r){"use strict";(function(o,a){function p(s,i,...u){if(!s)throw new TypeError(T(i,u))}function T(s,i){let u=0;return s.replace(/%[os]/gu,()=>R(i[u++]))}function R(s){return typeof s!="object"||s===null?String(s):Object.prototype.toString.call(s)}let v;Object.defineProperty(t,"__esModule",{value:!0});let f=typeof window!="undefined"?window:typeof self!="undefined"?self:a!==void 0?a:typeof globalThis!="undefined"?globalThis:void 0,n;class l{constructor(i,u){this.code=i,this.message=u}warn(...i){var u;try{if(n)return void n({...this,args:i});let c=((u=new Error().stack)!==null&&u!==void 0?u:"").replace(/^(?:.+?\n){2}/gu,` | ||
`);console.warn(this.message,...i,c)}catch{}}}let b=new l("W01","Unable to initialize event under dispatching."),E=new l("W02","Assigning any falsy value to 'cancelBubble' property has no effect."),x=new l("W03","Assigning any truthy value to 'returnValue' property has no effect."),w=new l("W04","Unable to preventDefault on non-cancelable events."),y=new l("W05","Unable to preventDefault inside passive event listener invocation."),A=new l("W06","An event listener wasn't added because it has been added already: %o, %o"),d=new l("W07","The %o option value was abandoned because the event listener wasn't added as duplicated."),j=new l("W08","The 'callback' argument must be a function or an object that has 'handleEvent' method: %o"),V=new l("W09","Event attribute handler must be a function: %o");class L{static get NONE(){return q}static get CAPTURING_PHASE(){return _}static get AT_TARGET(){return W}static get BUBBLING_PHASE(){return K}constructor(i,u){Object.defineProperty(this,"isTrusted",{value:!1,enumerable:!0});let c=u!=null?u:{};G.set(this,{type:String(i),bubbles:Boolean(c.bubbles),cancelable:Boolean(c.cancelable),composed:Boolean(c.composed),target:null,currentTarget:null,stopPropagationFlag:!1,stopImmediatePropagationFlag:!1,canceledFlag:!1,inPassiveListenerFlag:!1,dispatchFlag:!1,timeStamp:Date.now()})}get type(){return g(this).type}get target(){return g(this).target}get srcElement(){return g(this).target}get currentTarget(){return g(this).currentTarget}composedPath(){let i=g(this).currentTarget;return i?[i]:[]}get NONE(){return q}get CAPTURING_PHASE(){return _}get AT_TARGET(){return W}get BUBBLING_PHASE(){return K}get eventPhase(){return g(this).dispatchFlag?2:0}stopPropagation(){g(this).stopPropagationFlag=!0}get cancelBubble(){return g(this).stopPropagationFlag}set cancelBubble(i){i?g(this).stopPropagationFlag=!0:E.warn()}stopImmediatePropagation(){let i=g(this);i.stopPropagationFlag=i.stopImmediatePropagationFlag=!0}get bubbles(){return g(this).bubbles}get cancelable(){return g(this).cancelable}get returnValue(){return!g(this).canceledFlag}set returnValue(i){i?x.warn():P(g(this))}preventDefault(){P(g(this))}get defaultPrevented(){return g(this).canceledFlag}get composed(){return g(this).composed}get isTrusted(){return!1}get timeStamp(){return g(this).timeStamp}initEvent(i,u=!1,c=!1){let h=g(this);h.dispatchFlag?b.warn():G.set(this,{...h,type:String(i),bubbles:Boolean(u),cancelable:Boolean(c),target:null,currentTarget:null,stopPropagationFlag:!1,stopImmediatePropagationFlag:!1,canceledFlag:!1})}}let q=0,_=1,W=2,K=3,G=new WeakMap;function g(s,i="this"){let u=G.get(s);return p(u!=null,"'%s' must be an object that Event constructor created, but got another one: %o",i,s),u}function P(s){s.inPassiveListenerFlag?y.warn():s.cancelable?s.canceledFlag=!0:w.warn()}Object.defineProperty(L,"NONE",{enumerable:!0}),Object.defineProperty(L,"CAPTURING_PHASE",{enumerable:!0}),Object.defineProperty(L,"AT_TARGET",{enumerable:!0}),Object.defineProperty(L,"BUBBLING_PHASE",{enumerable:!0});let B=Object.getOwnPropertyNames(L.prototype);for(let s=0;s<B.length;++s)B[s]!=="constructor"&&Object.defineProperty(L.prototype,B[s],{enumerable:!0});let N;f!==void 0&&f.Event!==void 0&&Object.setPrototypeOf(L.prototype,f.Event.prototype);let ge={INDEX_SIZE_ERR:1,DOMSTRING_SIZE_ERR:2,HIERARCHY_REQUEST_ERR:3,WRONG_DOCUMENT_ERR:4,INVALID_CHARACTER_ERR:5,NO_DATA_ALLOWED_ERR:6,NO_MODIFICATION_ALLOWED_ERR:7,NOT_FOUND_ERR:8,NOT_SUPPORTED_ERR:9,INUSE_ATTRIBUTE_ERR:10,INVALID_STATE_ERR:11,SYNTAX_ERR:12,INVALID_MODIFICATION_ERR:13,NAMESPACE_ERR:14,INVALID_ACCESS_ERR:15,VALIDATION_ERR:16,TYPE_MISMATCH_ERR:17,SECURITY_ERR:18,NETWORK_ERR:19,ABORT_ERR:20,URL_MISMATCH_ERR:21,QUOTA_EXCEEDED_ERR:22,TIMEOUT_ERR:23,INVALID_NODE_TYPE_ERR:24,DATA_CLONE_ERR:25};function me(s){let i=Object.keys(ge);for(let u=0;u<i.length;++u){let c=i[u],h=ge[c];Object.defineProperty(s,c,{get:()=>h,configurable:!0,enumerable:!0})}}class Z extends L{static wrap(i){return new(function u(c){let h=Object.getPrototypeOf(c);if(h==null)return Z;let m=re.get(h);return m==null&&(m=function(C,M){class O extends C{}let k=Object.keys(M);for(let S=0;S<k.length;++S)Object.defineProperty(O.prototype,k[S],ye(M,k[S]));return O}(u(h),h),re.set(h,m)),m}(i))(i)}constructor(i){super(i.type,{bubbles:i.bubbles,cancelable:i.cancelable,composed:i.composed}),i.cancelBubble&&super.stopPropagation(),i.defaultPrevented&&super.preventDefault(),be.set(this,{original:i});let u=Object.keys(i);for(let c=0;c<u.length;++c){let h=u[c];h in this||Object.defineProperty(this,h,ye(i,h))}}stopPropagation(){super.stopPropagation();let{original:i}=F(this);"stopPropagation"in i&&i.stopPropagation()}get cancelBubble(){return super.cancelBubble}set cancelBubble(i){super.cancelBubble=i;let{original:u}=F(this);"cancelBubble"in u&&(u.cancelBubble=i)}stopImmediatePropagation(){super.stopImmediatePropagation();let{original:i}=F(this);"stopImmediatePropagation"in i&&i.stopImmediatePropagation()}get returnValue(){return super.returnValue}set returnValue(i){super.returnValue=i;let{original:u}=F(this);"returnValue"in u&&(u.returnValue=i)}preventDefault(){super.preventDefault();let{original:i}=F(this);"preventDefault"in i&&i.preventDefault()}get timeStamp(){let{original:i}=F(this);return"timeStamp"in i?i.timeStamp:super.timeStamp}}let be=new WeakMap;function F(s){let i=be.get(s);return p(i!=null,"'this' is expected an Event object, but got",s),i}let re=new WeakMap;function ye(s,i){let u=Object.getOwnPropertyDescriptor(s,i);return{get(){let c=F(this).original,h=c[i];return typeof h=="function"?h.bind(c):h},set(c){F(this).original[i]=c},configurable:u.configurable,enumerable:u.enumerable}}function ve(s){return(1&s.flags)==1}function Ee(s){return(2&s.flags)==2}function Te(s){return(4&s.flags)==4}function Je(s){return(8&s.flags)==8}function Qe({callback:s},i,u){try{typeof s=="function"?s.call(i,u):typeof s.handleEvent=="function"&&s.handleEvent(u)}catch(c){(function(h){try{let m=h instanceof Error?h:new Error(R(h));if(v)return void v(m);if(typeof dispatchEvent=="function"&&typeof ErrorEvent=="function")dispatchEvent(new ErrorEvent("error",{error:m,message:m.message}));else if(o!==void 0&&typeof o.emit=="function")return void o.emit("uncaughtException",m);console.error(m)}catch{}})(c)}}function we({listeners:s},i,u){for(let c=0;c<s.length;++c)if(s[c].callback===i&&ve(s[c])===u)return c;return-1}function ke(s,i,u,c,h,m){let C;m&&(C=pe.bind(null,s,i,u),m.addEventListener("abort",C));let M=function(O,k,S,U,oe,D){return{callback:O,flags:(k?1:0)|(S?2:0)|(U?4:0),signal:oe,signalListener:D}}(i,u,c,h,m,C);return s.cow?(s.cow=!1,s.listeners=[...s.listeners,M]):s.listeners.push(M),M}function pe(s,i,u){let c=we(s,i,u);return c!==-1&&Re(s,c)}function Re(s,i,u=!1){let c=s.listeners[i];return function(h){h.flags|=8}(c),c.signal&&c.signal.removeEventListener("abort",c.signalListener),s.cow&&!u?(s.cow=!1,s.listeners=s.listeners.filter((h,m)=>m!==i),!1):(s.listeners.splice(i,1),!0)}function xe(s,i){var u;return(u=s[i])!==null&&u!==void 0?u:s[i]={attrCallback:void 0,attrListener:void 0,cow:!1,listeners:[]}}re.set(Object.prototype,Z),f!==void 0&&f.Event!==void 0&&re.set(f.Event.prototype,Z);class ${constructor(){Pe.set(this,Object.create(null))}addEventListener(i,u,c){let h=Y(this),{callback:m,capture:C,once:M,passive:O,signal:k,type:S}=function(D,H,I){var J;return Ce(H),typeof I=="object"&&I!==null?{type:String(D),callback:H!=null?H:void 0,capture:Boolean(I.capture),passive:Boolean(I.passive),once:Boolean(I.once),signal:(J=I.signal)!==null&&J!==void 0?J:void 0}:{type:String(D),callback:H!=null?H:void 0,capture:Boolean(I),passive:!1,once:!1,signal:void 0}}(i,u,c);if(m==null||(k==null?void 0:k.aborted))return;let U=xe(h,S),oe=we(U,m,C);oe===-1?ke(U,m,C,O,M,k):function(D,H,I,J){A.warn(ve(D)?"capture":"bubble",D.callback),Ee(D)!==H&&d.warn("passive"),Te(D)!==I&&d.warn("once"),D.signal!==J&&d.warn("signal")}(U.listeners[oe],O,M,k)}removeEventListener(i,u,c){let h=Y(this),{callback:m,capture:C,type:M}=function(k,S,U){return Ce(S),typeof U=="object"&&U!==null?{type:String(k),callback:S!=null?S:void 0,capture:Boolean(U.capture)}:{type:String(k),callback:S!=null?S:void 0,capture:Boolean(U)}}(i,u,c),O=h[M];m!=null&&O&&pe(O,m,C)}dispatchEvent(i){let u=Y(this)[String(i.type)];if(u==null)return!0;let c=i instanceof L?i:Z.wrap(i),h=g(c,"event");if(h.dispatchFlag)throw m="This event has been in dispatching.",f.DOMException?new f.DOMException(m,"InvalidStateError"):(N==null&&(N=class Ie extends Error{constructor(M){super(M),Error.captureStackTrace&&Error.captureStackTrace(this,Ie)}get code(){return 11}get name(){return"InvalidStateError"}},Object.defineProperties(N.prototype,{code:{enumerable:!0},name:{enumerable:!0}}),me(N),me(N.prototype)),new N(m));var m;if(h.dispatchFlag=!0,h.target=h.currentTarget=this,!h.stopPropagationFlag){let{cow:C,listeners:M}=u;u.cow=!0;for(let O=0;O<M.length;++O){let k=M[O];if(!Je(k)&&(Te(k)&&Re(u,O,!C)&&(O-=1),h.inPassiveListenerFlag=Ee(k),Qe(k,this,c),h.inPassiveListenerFlag=!1,h.stopImmediatePropagationFlag))break}C||(u.cow=!1)}return h.target=null,h.currentTarget=null,h.stopImmediatePropagationFlag=!1,h.stopPropagationFlag=!1,h.dispatchFlag=!1,!h.canceledFlag}}let Pe=new WeakMap;function Y(s,i="this"){let u=Pe.get(s);return p(u!=null,"'%s' must be an object that EventTarget constructor created, but got another one: %o",i,s),u}function Ce(s){if(typeof s!="function"&&(typeof s!="object"||s===null||typeof s.handleEvent!="function")){if(s!=null&&typeof s!="object")throw new TypeError(T(j.message,[s]));j.warn(s)}}let de=Object.getOwnPropertyNames($.prototype);for(let s=0;s<de.length;++s)de[s]!=="constructor"&&Object.defineProperty($.prototype,de[s],{enumerable:!0});function Ae(s,i){var u,c;return(c=(u=Y(s,"target")[i])===null||u===void 0?void 0:u.attrCallback)!==null&&c!==void 0?c:null}function Me(s,i,u){u!=null&&typeof u!="function"&&V.warn(u),typeof u=="function"||typeof u=="object"&&u!==null?function(c,h,m){let C=xe(Y(c,"target"),String(h));C.attrCallback=m,C.attrListener==null&&(C.attrListener=ke(C,function(M){return function(O){let k=M.attrCallback;typeof k=="function"&&k.call(this,O)}}(C),!1,!1,!1,void 0))}(s,i,u):function(c,h){let m=Y(c,"target")[String(h)];m&&m.attrListener&&(pe(m,m.attrListener.callback,!1),m.attrCallback=m.attrListener=void 0)}(s,i)}function Oe(s,i,u){Object.defineProperty(s,"on"+i,{get(){return Ae(this,i)},set(c){Me(this,i,c)},configurable:!0,enumerable:!0})}f!==void 0&&f.EventTarget!==void 0&&Object.setPrototypeOf($.prototype,f.EventTarget.prototype),t.Event=L,t.EventTarget=$,t.default=$,t.defineCustomEventTarget=function(...s){class i extends ${}for(let u=0;u<s.length;++u)Oe(i.prototype,s[u]);return i},t.defineEventAttribute=Oe,t.getEventAttributeValue=Ae,t.setErrorHandler=function(s){p(typeof s=="function"||s===void 0,"The error handler must be a function or undefined, but got %o.",s),v=s},t.setEventAttributeValue=Me,t.setWarningHandler=function(s){p(typeof s=="function"||s===void 0,"The warning handler must be a function or undefined, but got %o.",s),n=s}}).call(this,r(3),r(0))},function(e,t){var r,o,a=e.exports={};function p(){throw new Error("setTimeout has not been defined")}function T(){throw new Error("clearTimeout has not been defined")}function R(y){if(r===setTimeout)return setTimeout(y,0);if((r===p||!r)&&setTimeout)return r=setTimeout,setTimeout(y,0);try{return r(y,0)}catch{try{return r.call(null,y,0)}catch{return r.call(this,y,0)}}}(function(){try{r=typeof setTimeout=="function"?setTimeout:p}catch{r=p}try{o=typeof clearTimeout=="function"?clearTimeout:T}catch{o=T}})();var v,f=[],n=!1,l=-1;function b(){n&&v&&(n=!1,v.length?f=v.concat(f):l=-1,f.length&&E())}function E(){if(!n){var y=R(b);n=!0;for(var A=f.length;A;){for(v=f,f=[];++l<A;)v&&v[l].run();l=-1,A=f.length}v=null,n=!1,function(d){if(o===clearTimeout)return clearTimeout(d);if((o===T||!o)&&clearTimeout)return o=clearTimeout,clearTimeout(d);try{o(d)}catch{try{return o.call(null,d)}catch{return o.call(this,d)}}}(y)}}function x(y,A){this.fun=y,this.array=A}function w(){}a.nextTick=function(y){var A=new Array(arguments.length-1);if(arguments.length>1)for(var d=1;d<arguments.length;d++)A[d-1]=arguments[d];f.push(new x(y,A)),f.length!==1||n||R(E)},x.prototype.run=function(){this.fun.apply(null,this.array)},a.title="browser",a.browser=!0,a.env={},a.argv=[],a.version="",a.versions={},a.on=w,a.addListener=w,a.once=w,a.off=w,a.removeListener=w,a.removeAllListeners=w,a.emit=w,a.prependListener=w,a.prependOnceListener=w,a.listeners=function(y){return[]},a.binding=function(y){throw new Error("process.binding is not supported")},a.cwd=function(){return"/"},a.chdir=function(y){throw new Error("process.chdir is not supported")},a.umask=function(){return 0}},function(e,t,r){"use strict";var o=r(5),a=r(6),p=r(7),T=r(8);function R(n,l,b){var E=n;return a(l)?(b=l,typeof n=="string"&&(E={uri:n})):E=T(l,{uri:n}),E.callback=b,E}function v(n,l,b){return f(l=R(n,l,b))}function f(n){if(n.callback===void 0)throw new Error("callback argument missing");var l=!1,b=function(g,P,B){l||(l=!0,n.callback(g,P,B))};function E(){var g=void 0;if(g=d.response?d.response:d.responseText||function(P){try{if(P.responseType==="document")return P.responseXML;var B=P.responseXML&&P.responseXML.documentElement.nodeName==="parsererror";if(P.responseType===""&&!B)return P.responseXML}catch{}return null}(d),K)try{g=JSON.parse(g)}catch{}return g}function x(g){return clearTimeout(j),g instanceof Error||(g=new Error(""+(g||"Unknown XMLHttpRequest Error"))),g.statusCode=0,b(g,G)}function w(){if(!A){var g;clearTimeout(j),g=n.useXDR&&d.status===void 0?200:d.status===1223?204:d.status;var P=G,B=null;return g!==0?(P={body:E(),statusCode:g,method:L,headers:{},url:V,rawRequest:d},d.getAllResponseHeaders&&(P.headers=p(d.getAllResponseHeaders()))):B=new Error("Internal XMLHttpRequest Error"),b(B,P,P.body)}}var y,A,d=n.xhr||null;d||(d=n.cors||n.useXDR?new v.XDomainRequest:new v.XMLHttpRequest);var j,V=d.url=n.uri||n.url,L=d.method=n.method||"GET",q=n.body||n.data,_=d.headers=n.headers||{},W=!!n.sync,K=!1,G={body:void 0,headers:{},statusCode:0,method:L,url:V,rawRequest:d};if("json"in n&&n.json!==!1&&(K=!0,_.accept||_.Accept||(_.Accept="application/json"),L!=="GET"&&L!=="HEAD"&&(_["content-type"]||_["Content-Type"]||(_["Content-Type"]="application/json"),q=JSON.stringify(n.json===!0?q:n.json))),d.onreadystatechange=function(){d.readyState===4&&setTimeout(w,0)},d.onload=w,d.onerror=x,d.onprogress=function(){},d.onabort=function(){A=!0},d.ontimeout=x,d.open(L,V,!W,n.username,n.password),W||(d.withCredentials=!!n.withCredentials),!W&&n.timeout>0&&(j=setTimeout(function(){if(!A){A=!0,d.abort("timeout");var g=new Error("XMLHttpRequest timeout");g.code="ETIMEDOUT",x(g)}},n.timeout)),d.setRequestHeader)for(y in _)_.hasOwnProperty(y)&&d.setRequestHeader(y,_[y]);else if(n.headers&&!function(g){for(var P in g)if(g.hasOwnProperty(P))return!1;return!0}(n.headers))throw new Error("Headers cannot be set on an XDomainRequest object");return"responseType"in n&&(d.responseType=n.responseType),"beforeSend"in n&&typeof n.beforeSend=="function"&&n.beforeSend(d),d.send(q||null),d}e.exports=v,e.exports.default=v,v.XMLHttpRequest=o.XMLHttpRequest||function(){},v.XDomainRequest="withCredentials"in new v.XMLHttpRequest?v.XMLHttpRequest:o.XDomainRequest,function(n,l){for(var b=0;b<n.length;b++)l(n[b])}(["get","put","post","patch","head","delete"],function(n){v[n==="delete"?"del":n]=function(l,b,E){return(b=R(l,b,E)).method=n.toUpperCase(),f(b)}})},function(e,t,r){(function(o){var a;a=typeof window!="undefined"?window:o!==void 0?o:typeof self!="undefined"?self:{},e.exports=a}).call(this,r(0))},function(e,t){e.exports=function(o){if(!o)return!1;var a=r.call(o);return a==="[object Function]"||typeof o=="function"&&a!=="[object RegExp]"||typeof window!="undefined"&&(o===window.setTimeout||o===window.alert||o===window.confirm||o===window.prompt)};var r=Object.prototype.toString},function(e,t){var r=function(o){return o.replace(/^\s+|\s+$/g,"")};e.exports=function(o){if(!o)return{};for(var a,p={},T=r(o).split(` | ||
`),R=0;R<T.length;R++){var v=T[R],f=v.indexOf(":"),n=r(v.slice(0,f)).toLowerCase(),l=r(v.slice(f+1));p[n]===void 0?p[n]=l:(a=p[n],Object.prototype.toString.call(a)==="[object Array]"?p[n].push(l):p[n]=[p[n],l])}return p}},function(e,t){e.exports=function(){for(var o={},a=0;a<arguments.length;a++){var p=arguments[a];for(var T in p)r.call(p,T)&&(o[T]=p[T])}return o};var r=Object.prototype.hasOwnProperty}])})});it(exports,{MuxUploaderDrop:()=>$e,default:()=>Ct});var X=z(require("react"));if(typeof DocumentFragment=="undefined"){class e{}globalThis.DocumentFragment=e}globalThis.customElements||(globalThis.customElements={get(e){},define(e,t,r){},upgrade(e){},whenDefined(e){return Promise.resolve(globalThis.HTMLElement)}});var Q;if(!globalThis.CustomEvent){class e{constructor(r,o={}){Be(this,Q,void 0);Ue(this,Q,o==null?void 0:o.detail)}get detail(){_e(this,Q)}initCustomEvent(r,o,a,p){}}Q=new WeakMap,globalThis.CustomEvent=e}if(!globalThis.EventTarget){class e{addEventListener(){}removeEventListener(){}dispatchEvent(r){return!0}}globalThis.EventTarget=e}if(!globalThis.HTMLElement){class e extends EventTarget{}globalThis.HTMLElement=e}if(!globalThis.HTMLVideoElement){class e extends EventTarget{}globalThis.HTMLVideoElement=e}var De,je;if(!((De=globalThis.document)==null?void 0:De.createElement)){let e=(je=globalThis.document)!=null?je:{};e.createElement=function(r,o){return new HTMLElement},globalThis.document=e}var ze=z(Fe()),Ne=document.createElement("template");Ne.innerHTML=` | ||
<style> | ||
/* These styles simulate a user passing these via props. Until | ||
that's implemented, we just hardcode it for non-full-screen demo purposes. (TD). | ||
*/ | ||
.dropzone { | ||
position: absolute; | ||
top: 0; | ||
left: 0; | ||
right: 0; | ||
bottom: 0; | ||
height: 100%; | ||
width: 100%; | ||
:host { | ||
position: relative; | ||
} | ||
/* TO-DO: Make default dropzone hover more apparent. (TD).*/ | ||
:host([disable-drop]) .dropzone { | ||
#overlay { | ||
display: none; | ||
} | ||
.overlay { | ||
display: none; | ||
} | ||
:host([fullscreen]) .dropzone { | ||
position: absolute; | ||
@@ -36,20 +18,6 @@ top: 0; | ||
width: 100%; | ||
z-index: 1; | ||
} | ||
:host([fullscreen][overlay]) .overlay { | ||
position: absolute; | ||
top: 0; | ||
bottom: 0; | ||
right: 0; | ||
left: 0; | ||
height: 100%; | ||
width: 100%; | ||
z-index: -1; | ||
} | ||
:host([active][fullscreen][overlay]) .overlay { | ||
z-index: 10; | ||
background-color: var(--overlay-background-color, rgba(226, 253, 255, 0.95)); | ||
:host([active][overlay]) > #overlay { | ||
background: var(--overlay-background-color, rgba(226, 253, 255, 0.95)); | ||
display: flex; | ||
@@ -60,18 +28,9 @@ flex-direction: column; | ||
} | ||
h1 { | ||
display: none; | ||
} | ||
:host([active][overlay]) h1 { | ||
display: block; | ||
} | ||
</style> | ||
<div class="overlay" id="overlay"> | ||
<h1 id="overlay-text"></h1> | ||
<slot></slot> | ||
<div id="overlay"> | ||
<h1 id="overlay-label"></h1> | ||
</div> | ||
<div class="dropzone" id="dropzone"> | ||
</div> | ||
`;var Ne=class extends HTMLElement{constructor(){super();let e=this.attachShadow({mode:"open"});e.appendChild(Fe.content.cloneNode(!0)),this.overlay=e.getElementById("overlay"),this.overlayText=e.getElementById("overlay-text")}connectedCallback(){this.setupDragEvents()}attributeChangedCallback(){this.shadowRoot.getElementById("overlay-text").innerHTML=this.getAttribute("text")}static get observedAttributes(){return["text","mux-uploader"]}get muxUploader(){let e=this.getAttribute("mux-uploader");return e?document.getElementById(e):null}setupDragEvents(){this.addEventListener("dragenter",e=>{e.preventDefault(),e.stopPropagation(),this.setAttribute("active","")}),this.addEventListener("dragleave",e=>{this.removeAttribute("active")}),this.addEventListener("dragover",e=>{e.preventDefault(),e.stopPropagation()}),this.addEventListener("drop",e=>{var n;e.preventDefault(),e.stopPropagation();let{dataTransfer:o}=e,{files:r}=o,a=r[0];((n=this.muxUploader)!=null?n:this).dispatchEvent(new CustomEvent("file-ready",{composed:!0,bubbles:!0,detail:a})),this.removeAttribute("active")})}};globalThis.customElements.get("mux-uploader-drop")||(globalThis.customElements.define("mux-uploader-drop",Ne),globalThis.MuxUploaderDropElement=Ne);var ot=` | ||
`;var ie={MUX_UPLOADER:"mux-uploader",OVERLAY_TEXT:"overlay-text"},He=class extends HTMLElement{constructor(){super();let e=this.attachShadow({mode:"open"});e.appendChild(Ne.content.cloneNode(!0)),this.overlayText=e.getElementById("overlay-label")}connectedCallback(){this.setupDragEvents()}attributeChangedCallback(e,t,r){e===ie.OVERLAY_TEXT&&t!==r&&(this.overlayText.innerHTML=r!=null?r:"")}static get observedAttributes(){return[ie.OVERLAY_TEXT,ie.MUX_UPLOADER]}get muxUploader(){let e=this.getAttribute(ie.MUX_UPLOADER);return e?document.getElementById(e):null}setupDragEvents(){this.addEventListener("dragenter",e=>{e.preventDefault(),e.stopPropagation(),this.setAttribute("active","")}),this.addEventListener("dragleave",e=>{this.removeAttribute("active")}),this.addEventListener("dragover",e=>{e.preventDefault(),e.stopPropagation()}),this.addEventListener("drop",e=>{var t;e.preventDefault(),e.stopPropagation();let{dataTransfer:r}=e,{files:o}=r,a=o[0];((t=this.muxUploader)!=null?t:this).dispatchEvent(new CustomEvent("file-ready",{composed:!0,bubbles:!0,detail:a})),this.removeAttribute("active")})}};globalThis.customElements.get("mux-uploader-drop")||(globalThis.customElements.define("mux-uploader-drop",He),globalThis.MuxUploaderDropElement=He);var ut=` | ||
:host { | ||
@@ -112,3 +71,2 @@ font-family: var(--uploader-font-family, Arial); | ||
font-size: inherit; | ||
z-index: 10; | ||
position: relative; | ||
@@ -151,3 +109,2 @@ } | ||
cursor: pointer; | ||
z-index: 10; | ||
position: relative; | ||
@@ -243,9 +200,7 @@ } | ||
} | ||
`,He=document.createElement("template");He.innerHTML=` | ||
`,Xe=document.createElement("template");Xe.innerHTML=` | ||
<style> | ||
${ot} | ||
${ut} | ||
</style> | ||
<p class="upload-instruction" id="upload-instruction">Drop file to upload</p> | ||
<div class="sr-only" id="sr-only" aria-live="polite"></div> | ||
@@ -258,6 +213,5 @@ | ||
<input type="file" /> | ||
<!--TO-DO: Slots not receiving events or not having the right visual behaviour as the original elements. (TD).--> | ||
<slot name="custom-button"><button type="button">Upload video</button></slot> | ||
<slot name="custom-progress"><p class="upload-status" id="upload-status"></p></slot> | ||
<input id="hidden-file-input" type="file" /> | ||
<slot name="upload-button"><button type="button">Upload video</button></slot> | ||
<p class="upload-status" id="upload-status"></p> | ||
@@ -280,7 +234,3 @@ <div class="bar-type"> | ||
</div> | ||
<slot name="dropzone"> | ||
<mux-uploader-drop></mux-uploader-drop> | ||
</slot> | ||
`;var ie={BAR:"bar",RADIAL:"radial"},st=e=>{var n;return Number((n=e.svgCircle)==null?void 0:n.getAttribute("r"))},ee=e=>st(e)*2*Math.PI,it="Media upload progress bar",ze=["Enter"," "],qe=class extends HTMLElement{constructor(){super();var e,n,o,r,a,c,b,E,y;let d=this.attachShadow({mode:"open"}),t=He.content.cloneNode(!0);d.appendChild(t),this.hiddenFileInput=(e=this.shadowRoot)==null?void 0:e.querySelector('input[type="file"]'),this.filePickerButton=(n=this.shadowRoot)==null?void 0:n.querySelector("button"),this.svgCircle=(o=this.shadowRoot)==null?void 0:o.querySelector("circle"),this.progressBar=(r=this.shadowRoot)==null?void 0:r.getElementById("progress-bar"),this.uploadPercentage=(a=this.shadowRoot)==null?void 0:a.getElementById("upload-status"),this.statusMessage=(c=this.shadowRoot)==null?void 0:c.getElementById("status-message"),this.retryButton=(b=this.shadowRoot)==null?void 0:b.getElementById("retry-button"),this.srOnlyText=(E=this.shadowRoot)==null?void 0:E.getElementById("sr-only"),(y=this.progressBar)==null||y.setAttribute("aria-description",it)}connectedCallback(){var e;if(this.setDefaultType(),this.setupFilePickerButton(),this.setupRetry(),this.setupDropHandler(),this.hasAttribute("disable-drop")){let n=(e=this.shadowRoot)==null?void 0:e.querySelector("mux-uploader-drop");n==null||n.setAttribute("disable-drop","")}}disconnectedCallback(){this.removeEventListener("file-ready",this.handleUpload,!1)}get url(){return this.getAttribute("url")}set url(e){this.setAttribute("url",e)}setDefaultType(){let e=this.getAttribute("type");e||this.setAttribute("type",ie.BAR),e===ie.RADIAL&&this.svgCircle&&(this.svgCircle.style.strokeDasharray=`${ee(this)} ${ee(this)}`,this.svgCircle.style.strokeDashoffset=`${ee(this)}`)}setupRetry(){var e;(e=this.retryButton)==null||e.addEventListener("click",()=>{this.resetState()});let n=o=>{let{key:r}=o;if(!ze.includes(r)){this.removeEventListener("keyup",n);return}this.resetState()};this.addEventListener("keydown",o=>{let{metaKey:r,altKey:a,key:c}=o;if(r||a||!ze.includes(c)){this.removeEventListener("keyup",n);return}this.addEventListener("keyup",n)})}setupDropHandler(){this.addEventListener("file-ready",this.handleUpload)}resetState(){this.removeAttribute("upload-error"),this.removeAttribute("upload-in-progress"),this.statusMessage&&(this.statusMessage.innerHTML=""),this.uploadPercentage&&(this.uploadPercentage.innerHTML="")}setupFilePickerButton(){var e,n,o,r;(n=(e=this.shadowRoot)==null?void 0:e.querySelector("slot[name=custom-button]"))==null||n.addEventListener("slotchange",()=>{var a;this.filePickerButton=(a=this.shadowRoot)==null?void 0:a.querySelector("slot[name=custom-button]")}),(o=this.filePickerButton)==null||o.addEventListener("click",()=>{var a;(a=this.hiddenFileInput)==null||a.click()}),(r=this.hiddenFileInput)==null||r.addEventListener("change",a=>{var c,b;let E=(b=(c=this.hiddenFileInput)==null?void 0:c.files)==null?void 0:b[0];E&&this.dispatchEvent(new CustomEvent("file-ready",{composed:!0,bubbles:!0,detail:E}))})}setProgress(e){var n;switch(this.uploadPercentage&&(this.uploadPercentage.innerHTML=`${Math.floor(e)}%`),(n=this.progressBar)==null||n.setAttribute("aria-valuenow",`${Math.floor(e)}`),this.getAttribute("type")){case ie.BAR:this.progressBar&&(this.progressBar.style.width=`${e}%`);case ie.RADIAL:if(this.svgCircle){let o=ee(this)-e/100*ee(this);this.svgCircle.style.strokeDashoffset=o.toString()}}}handleUpload(e){var n;let o=this.url,r="No url attribute specified -- cannot handleUpload";o?this.statusMessage&&(this.statusMessage.innerHTML=""):(this.statusMessage&&(this.statusMessage.innerHTML=r),console.error(r)),this.statusMessage&&(this.removeAttribute("upload-error"),this.statusMessage.innerHTML=""),this.setAttribute("upload-in-progress",""),(n=this.progressBar)==null||n.focus();let a=(0,Ie.createUpload)({endpoint:o||"https://storage.googleapis.com/video-storage-us-east1-uploads/B6vYEZ9utvayi7tJlcwjG4ckho8W5100QHse5OEIyOqg?Expires=1654714562&GoogleAccessId=direct-uploads-writer-prod%40mux-cloud.iam.gserviceaccount.com&Signature=ZQLdkP8u432oNZ5WtQwPB22qR%2B03BWd0DOdEFohak0dNG2fzJpE9RLCyAb8uJo3N8YH62UecxJs%2FefKFETicJd978Dldh3E4yTJQLWFR%2B%2FpCrYdS6EQRG7D08Vb9yz82jRJRgJ37cnJgNCzUFUx8AFX%2FG0o8BA3Wcm2AkdcLRWhvt2tj5wTzbxm8ZBflhYckJs7kNaiKEfIXk0UzNBPRJPGzyjzKUyyU1Keu0rERepH7BM8wJeGiw7KrD1TkqeMcA2NSpht4COKXYp3aNrryLGYfx%2B362U3KR0TaRalskKdqODbhBtTlLbFRALog3mGFq3CVJ2CG5Vztq6rXa00VRQ%3D%3D&upload_id=ADPycdsGqgIsU8tBAiu2k4Gt5hPa4QUaURD71neXpjQMfoQUeFGVDvE3qyAN7kzAVUcbSfK6tDhHwpSNiQMSvW41tPiTxw",file:e.detail});a.on("error",c=>{let b="An error has occurred";this.setAttribute("upload-error",""),this.statusMessage&&(this.statusMessage.innerHTML=b),console.error(c.detail.message)}),a.on("progress",c=>{this.setProgress(c.detail)}),a.on("success",()=>{let c="Upload complete!";this.statusMessage&&(this.statusMessage.innerHTML=c),this.srOnlyText&&(this.srOnlyText.innerHTML=c),console.info(c)})}};globalThis.customElements.get("mux-uploader")||(globalThis.customElements.define("mux-uploader",qe),globalThis.MuxUploaderElement=qe);var te=K(require("react"));var Ve={className:"class",classname:"class",htmlFor:"for",crossOrigin:"crossorigin",viewBox:"viewBox",playsInline:"playsinline",autoPlay:"autoplay"},at=e=>e==null,lt=(e,n)=>at(n)?!1:e in n,ut=e=>e.replace(/[A-Z]/g,n=>`-${n.toLowerCase()}`),ct=(e,n)=>{if(!(typeof n=="boolean"&&!n)){if(lt(e,Ve))return Ve[e];if(typeof n!=null)return/[A-Z]/.test(e)?ut(e):e}};var pt=(e,n)=>typeof e=="boolean"?"":e,ae=(e={})=>Object.entries(e).reduce((n,[o,r])=>{let a=ct(o,r);if(!a)return n;let c=pt(r,o);return n[a]=c,n},{});var Xe=K(require("react"));var le=K(require("react")),ue=(...e)=>{let n=(0,le.useRef)(null);return(0,le.useEffect)(()=>{e.forEach(o=>{!o||(typeof o=="function"?o(n.current):o.current=n.current)})},[e]),n};var dt=te.default.forwardRef(({children:e,...n},o)=>te.default.createElement("mux-uploader-drop",ae({...n,ref:o}),e)),ht=(e,n)=>{let{fullscreen:o,overlay:r,text:a,disableDrop:c,...b}=n;return[b]},ft=te.default.forwardRef((e,n)=>{let{fullscreen:o,overlay:r,text:a,disableDrop:c}=e,b=(0,Xe.useRef)(null),E=ue(b,n),[y]=ht(b,e);return te.default.createElement(dt,{ref:E,fullscreen:o,overlay:r,text:a,disableDrop:c,...y})}),Ge=ft;var We=K(require("react"));var gt=ne.default.forwardRef(({children:e,...n},o)=>ne.default.createElement("mux-uploader",ae({...n,ref:o}),e)),mt=(e,n)=>{let{url:o,id:r,type:a,status:c,disableDrop:b,...E}=n;return[E]},bt=ne.default.forwardRef((e,n)=>{let{url:o,id:r,type:a,status:c,disableDrop:b}=e,E=(0,We.useRef)(null),y=ue(E,n),[d]=mt(E,e);return ne.default.createElement(gt,{ref:y,url:o,id:r,type:a,status:c,disableDrop:b,...d})});var yt=bt; | ||
`;var ae={BAR:"bar",RADIAL:"radial"},lt=e=>`${Math.floor(e)}%`,ct=e=>{var t;return Number((t=e.svgCircle)==null?void 0:t.getAttribute("r"))},te=e=>ct(e)*2*Math.PI,pt="Media upload progress bar",Ve=["Enter"," "],qe=class extends HTMLElement{constructor(){super();var e,t,r,o,a,p,T,R,v,f,n;this.handleFilePickerButtonClick=this.handleFilePickerButtonClick.bind(this);let l=this.attachShadow({mode:"open"}),b=Xe.content.cloneNode(!0);l.appendChild(b),this.filePickerButton=(e=this.shadowRoot)==null?void 0:e.querySelector("slot[name=upload-button] > *"),this.svgCircle=(t=this.shadowRoot)==null?void 0:t.querySelector("circle"),this.progressBar=(r=this.shadowRoot)==null?void 0:r.getElementById("progress-bar"),this.uploadPercentage=(o=this.shadowRoot)==null?void 0:o.getElementById("upload-status"),this.statusMessage=(a=this.shadowRoot)==null?void 0:a.getElementById("status-message"),this.retryButton=(p=this.shadowRoot)==null?void 0:p.getElementById("retry-button"),this.srOnlyText=(T=this.shadowRoot)==null?void 0:T.getElementById("sr-only"),(R=this.progressBar)==null||R.setAttribute("aria-description",pt),(v=this.hiddenFileInput)==null||v.addEventListener("change",E=>{var x,w;let y=(w=(x=this.hiddenFileInput)==null?void 0:x.files)==null?void 0:w[0];y&&this.dispatchEvent(new CustomEvent("file-ready",{composed:!0,bubbles:!0,detail:y}))}),(n=(f=this.shadowRoot)==null?void 0:f.querySelector("slot[name=upload-button]"))==null||n.addEventListener("slotchange",()=>{var E,x;this.filePickerButton=(x=(E=this.shadowRoot)==null?void 0:E.querySelector("slot[name=upload-button]"))==null?void 0:x.assignedNodes()[0]})}connectedCallback(){this.setDefaultType(),this.setupRetry(),this.addEventListener("file-ready",this.handleUpload)}disconnectedCallback(){this.removeEventListener("file-ready",this.handleUpload,!1)}get filePickerButton(){return this._filePickerButton}set filePickerButton(e){e!==this._filePickerButton&&(this._filePickerButton&&this._filePickerButton.removeEventListener("click",this.handleFilePickerButtonClick),this._filePickerButton=e,this._filePickerButton&&this._filePickerButton.addEventListener("click",this.handleFilePickerButtonClick))}get hiddenFileInput(){var e;return(e=this.shadowRoot)==null?void 0:e.querySelector("#hidden-file-input")}handleFilePickerButtonClick(e){this.hiddenFileInput.click()}get url(){return this.getAttribute("url")}set url(e){this.setAttribute("url",e)}get formatProgress(){var e;return(e=this._formatProgress)!=null?e:lt}set formatProgress(e){this._formatProgress=e}setDefaultType(){let e=this.getAttribute("type");e||this.setAttribute("type",ae.BAR),e===ae.RADIAL&&this.svgCircle&&(this.svgCircle.style.strokeDasharray=`${te(this)} ${te(this)}`,this.svgCircle.style.strokeDashoffset=`${te(this)}`)}setupRetry(){var e;(e=this.retryButton)==null||e.addEventListener("click",()=>{this.resetState()});let t=r=>{let{key:o}=r;if(!Ve.includes(o)){this.removeEventListener("keyup",t);return}this.resetState()};this.addEventListener("keydown",r=>{let{metaKey:o,altKey:a,key:p}=r;if(o||a||!Ve.includes(p)){this.removeEventListener("keyup",t);return}this.addEventListener("keyup",t)})}resetState(){this.removeAttribute("upload-error"),this.removeAttribute("upload-in-progress"),this.hiddenFileInput.value="",this.statusMessage&&(this.statusMessage.innerHTML=""),this.uploadPercentage&&(this.uploadPercentage.innerHTML="")}setProgress(e){var t;switch(this.uploadPercentage&&(this.uploadPercentage.innerHTML=this.formatProgress(e)),(t=this.progressBar)==null||t.setAttribute("aria-valuenow",`${Math.floor(e)}`),this.getAttribute("type")){case ae.BAR:this.progressBar&&(this.progressBar.style.width=`${e}%`);case ae.RADIAL:if(this.svgCircle){let r=te(this)-e/100*te(this);this.svgCircle.style.strokeDashoffset=r.toString()}}}handleUpload(e){var t;let r=this.url;if(r)this.removeAttribute("upload-error"),this.statusMessage&&(this.statusMessage.innerHTML="");else{let a="No url attribute specified -- cannot handleUpload";this.statusMessage&&(this.statusMessage.innerHTML=a),this.setAttribute("upload-error",""),console.error(a);return}this.setAttribute("upload-in-progress",""),(t=this.progressBar)==null||t.focus();let o=(0,ze.createUpload)({endpoint:r,file:e.detail});o.on("error",a=>{let p="An error has occurred";this.setAttribute("upload-error",""),this.statusMessage&&(this.statusMessage.innerHTML=p),console.error(a.detail.message),this.dispatchEvent(new CustomEvent("error",a))}),o.on("progress",a=>{this.setProgress(a.detail),this.dispatchEvent(new CustomEvent("progress",a))}),o.on("success",a=>{let p="Upload complete!";this.statusMessage&&(this.statusMessage.innerHTML=p),this.srOnlyText&&(this.srOnlyText.innerHTML=p),console.info(p),this.dispatchEvent(new CustomEvent("success",a))})}};globalThis.customElements.get("mux-uploader")||(globalThis.customElements.define("mux-uploader",qe),globalThis.MuxUploaderElement=qe);var ne=z(require("react"));var We={className:"class",classname:"class",htmlFor:"for",crossOrigin:"crossorigin",viewBox:"viewBox",playsInline:"playsinline",autoPlay:"autoplay"},dt=e=>e==null,ht=(e,t)=>dt(t)?!1:e in t,ft=e=>e.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`),gt=(e,t)=>{if(!(typeof t=="boolean"&&!t)){if(ht(e,We))return We[e];if(typeof t!=null)return/[A-Z]/.test(e)?ft(e):e}};var mt=(e,t)=>typeof e=="boolean"?"":e,ue=(e={})=>Object.entries(e).reduce((t,[r,o])=>{let a=gt(r,o);if(!a)return t;let p=mt(o,r);return t[a]=p,t},{});var Ge=z(require("react"));var le=z(require("react")),ce=(...e)=>{let t=(0,le.useRef)(null);return(0,le.useEffect)(()=>{e.forEach(r=>{!r||(typeof r=="function"?r(t.current):r.current=t.current)})},[e]),t};var bt=ne.default.forwardRef(({children:e,...t},r)=>ne.default.createElement("mux-uploader-drop",ue({...t,ref:r}),e)),yt=ne.default.forwardRef((e,t)=>{let r=(0,Ge.useRef)(null),o=ce(r,t);return ne.default.createElement(bt,{ref:o,...e})}),$e=yt;var Ze=z(require("react"));var Ye=z(require("react")),vt=Object.prototype.hasOwnProperty,Et=(e,t)=>{if(Object.is(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;if(Array.isArray(e))return!Array.isArray(t)||e.length!==t.length?!1:e.some((a,p)=>t[p]===a);let r=Object.keys(e),o=Object.keys(t);if(r.length!==o.length)return!1;for(let a=0;a<r.length;a++)if(!vt.call(t,r[a])||!Object.is(e[r[a]],t[r[a]]))return!1;return!0},Tt=(e,t,r)=>!Et(t,e[r]),wt=(e,t,r)=>{e[r]=t},kt=(e,t,r,o=wt,a=Tt)=>(0,Ye.useEffect)(()=>{let p=r==null?void 0:r.current;!p||!a(p,t,e)||o(p,t,e)},[r==null?void 0:r.current,t]),Ke=kt;var Rt=X.default.forwardRef(({children:e,...t},r)=>X.default.createElement("mux-uploader",ue({...t,ref:r}),e)),fe=(e,t,r)=>(0,X.useEffect)(()=>{let o=t==null?void 0:t.current;if(!(!o||!r))return o.addEventListener(e,r),()=>{o.removeEventListener(e,r)}},[t==null?void 0:t.current,r]),xt=(e,t)=>{let{onError:r,onProgress:o,onSuccess:a,formatProgress:p,...T}=t;return Ke("formatProgress",p,e),fe("error",e,r),fe("progress",e,o),fe("success",e,a),[T]},Pt=X.default.forwardRef((e,t)=>{let r=(0,Ze.useRef)(null),o=ce(r,t),[a]=xt(r,e);return X.default.createElement(Rt,{ref:o,...a})});var Ct=Pt; | ||
//# sourceMappingURL=index.js.map |
@@ -12,5 +12,8 @@ import React from 'react'; | ||
status?: boolean; | ||
disableDrop?: boolean; | ||
style?: CSSProperties; | ||
children?: React.ReactNode; | ||
formatProgress?: (percent: number) => string; | ||
onError?: EventListener; | ||
onProgress?: EventListener; | ||
onSuccess?: EventListener; | ||
}; | ||
@@ -17,0 +20,0 @@ declare const MuxUploader: React.ForwardRefExoticComponent<MuxUploaderProps & React.RefAttributes<MuxUploaderElement>>; |
@@ -7,10 +7,8 @@ import React from 'react'; | ||
export declare type MuxUploaderDropProps = { | ||
slot?: string; | ||
fullscreen?: boolean; | ||
overlay?: boolean; | ||
text?: string; | ||
disableDrop?: boolean; | ||
overlayText?: string; | ||
style?: CSSProperties; | ||
children?: React.ReactNode; | ||
}; | ||
declare const MuxUploaderDrop: React.ForwardRefExoticComponent<MuxUploaderDropProps & React.RefAttributes<MuxUploaderDropElement>>; | ||
export default MuxUploaderDrop; |
@@ -12,5 +12,8 @@ import React from 'react'; | ||
status?: boolean; | ||
disableDrop?: boolean; | ||
style?: CSSProperties; | ||
children?: React.ReactNode; | ||
formatProgress?: (percent: number) => string; | ||
onError?: EventListener; | ||
onProgress?: EventListener; | ||
onSuccess?: EventListener; | ||
}; | ||
@@ -17,0 +20,0 @@ declare const MuxUploader: React.ForwardRefExoticComponent<MuxUploaderProps & React.RefAttributes<MuxUploaderElement>>; |
@@ -7,10 +7,8 @@ import React from 'react'; | ||
export declare type MuxUploaderDropProps = { | ||
slot?: string; | ||
fullscreen?: boolean; | ||
overlay?: boolean; | ||
text?: string; | ||
disableDrop?: boolean; | ||
overlayText?: string; | ||
style?: CSSProperties; | ||
children?: React.ReactNode; | ||
}; | ||
declare const MuxUploaderDrop: React.ForwardRefExoticComponent<MuxUploaderDropProps & React.RefAttributes<MuxUploaderDropElement>>; | ||
export default MuxUploaderDrop; |
{ | ||
"name": "@mux/mux-uploader-react", | ||
"version": "0.1.0-canary.1-1d57669", | ||
"version": "0.1.0-canary.10-3e02bf0", | ||
"type": "commonjs", | ||
@@ -49,3 +49,3 @@ "description": "An uploader element for React that handles Mux Direct Uploads and a visual progress bar for you", | ||
"dependencies": { | ||
"@mux/mux-uploader": "^0.1.0-beta.2", | ||
"@mux/mux-uploader": "0.1.0-beta.3", | ||
"prop-types": "^15.7.2" | ||
@@ -52,0 +52,0 @@ }, |
@@ -10,5 +10,5 @@ <p align="center"> | ||
`<MuxUploader></MuxUploader>` is React component for uploading files to Mux. | ||
`<MuxUploader>` is React component for uploading files to Mux. | ||
`MuxUploaderDrop` is an optional supporting React component for drop-in drag and drop and overlay. You can always configure your own drag and drop with `MuxUploader`. | ||
`<MuxUploaderDrop>` is an optional supporting React component for drop-in drag and drop and overlay. You can always configure your own drag and drop with `<MuxUploader>`. | ||
@@ -52,12 +52,12 @@ If you are looking for a direct upload interface and a progress bar, you're in the right place. | ||
<h1>Simple MuxUploader and Mux Uploader Drop Examples</h1> | ||
{/* Upload button by itself with default drag an drop scoped to the space it takes up. Displays upload progress in text as percentage. */} | ||
{/* Upload button by itself. Displays upload progress in text as percentage. */} | ||
<MuxUploader url="authenticated-url" type="bar" status></MuxUploader> | ||
{/* Upload button by itself with drag an drop disabled. Does not display text percentage. */} | ||
<MuxUploader url="authenticated-url" type="bar" disableDrop></MuxUploader> | ||
{/* Upload button by itself. Does not display text percentage. */} | ||
<MuxUploader url="authenticated-url" type="bar"></MuxUploader> | ||
{/* Upload button with access to additional drag and drop features via slots i.e. fullscreen drag and drop with text overlay (work-in-progress). */} | ||
<MuxUploader url="authenticated-url"> | ||
<MuxUploaderDrop slot="dropzone" text="Upload to stream.new" fullscreen overlay></MuxUploaderDrop> | ||
</MuxUploader> | ||
{/* Upload button with access to optional supplentary drag and drop features. */} | ||
<MuxUploaderDrop mux-uploader="uploader"> | ||
<MuxUploader url="authenticated-url" id="uploader"></MuxUploader> | ||
</MuxUploaderDrop> | ||
</div> | ||
@@ -68,27 +68,32 @@ ); | ||
### Attributes | ||
### Props | ||
#### `MuxUploader` | ||
#### `<MuxUploader>` | ||
| Attribute | Type | Description | Default | | ||
| ------------------ | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------- | | ||
| `url` | `string` | The authenticated URL that your file will be uploaded to. Check out the [direct uploads docs](https://docs.mux.com/guides/video/upload-files-directly#1-create-an-authenticated-mux-url) for how to create one. Required. | `undefined` | | ||
| `id` | `string` | An ID that allows `MuxUploaderDrop` to locate `MuxUploader`. Not necessary unless the unlikely scenario you need to nest `MuxUploader` inside `MuxUploaderDrop`. | N/A | | ||
| `type` | `"bar"` | Specifies the visual type of progress bar. A radial type is in-progress. | "bar" | | ||
| `uploadInProgress` | `boolean` | Toggles visual status of progress bar while upload is in progress. | false | | ||
| `uploadError` | `boolean` | Toggles visual status of progress bar when upload encounters an error. | false | | ||
| `status` | `boolean` | Toggles text status visibility of progress bar. The text that is displayed is a percentage by default. If you prefer just the progress bar with no text upload status, don't include this attribute. | false | | ||
| Property | Type | Description | Default | | ||
| ---------------- | ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------- | | ||
| `url` | `string` | The authenticated URL that your file will be uploaded to. Check out the [direct uploads docs](https://docs.mux.com/guides/video/upload-files-directly#1-create-an-authenticated-mux-url) for how to create one. Required. | `undefined` | | ||
| `id` | `string` | An ID that allows `<MuxUploaderDrop>` to locate `<MuxUploader>`. Required if you use `<MuxUploaderDrop>`. | N/A | | ||
| `type` | `"bar"` | Specifies the visual type of progress bar. A radial type is in-progress. | "bar" | | ||
| `status` | `boolean` | Toggles text status visibility of progress bar. The text that is displayed is a percentage by default. If you prefer just the progress bar with no text upload status, don't include this attribute. | false | | ||
| `formatProgress` | `function` | A function that accepts numeric percent and is expected to return a string. Allows for customizing how the progress should be rendered. | A function the yields a percent progress string | | ||
#### `MuxUploaderDrop` | ||
#### `<MuxUploaderDrop>` | ||
| Attribute | Type | Description | Default | | ||
| -------------- | --------- | ------------------------------------------------------ | ------- | | ||
| `fullscreen` | `boolean` | Toggles fullscreen drag and drop (work-in-progress). | false | | ||
| `overlay` | `boolean` | Toggles fullscreen overlay on dragover. | false | | ||
| `disableDrop ` | `boolean` | Toggles off drag and drop which is enabled by default. | false | | ||
| Property | Type | Description | Default | | ||
| ------------- | --------- | ---------------------------------------------------------- | ------- | | ||
| `overlay` | `boolean` | Toggles fullscreen overlay on dragover. | false | | ||
| `overlayText` | `boolean` | Optional text to display on dragover when `overlay` is on. | `''` | | ||
| `muxUploader` | `string ` | Must match the `id` on `<MuxUploader>`. Required. | N/A | | ||
### Methods | ||
### Callbacks | ||
| Method | Description | | ||
| ---------------- | --------------------------- | | ||
| `handleUpload()` | Begins upload of the media. | | ||
#### `<MuxUploader>` | ||
`<MuxUploader>` has a handful of events to monitor uploading state. | ||
| Prop | Description | | ||
| ------------ | -------------------------------------------------------------------------- | | ||
| `onError` | Invoked when an error occurs in the chunked upload process. | | ||
| `onProgress` | Invoked whenever a chunk of the file has successfully completed uploading. | | ||
| `onSuccess` | Invoked when the entire file has successfully completed uploading. | |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
200282
23
669
97
+ Added@mux/mux-uploader@0.1.0-beta.3(transitive)
- Removed@mux/mux-uploader@0.1.0-canary.99-2ffa983(transitive)