@mux/mux-uploader
Advanced tools
Comparing version 0.1.0-beta.4 to 0.1.0-beta.5
@@ -6,2 +6,15 @@ # Change Log | ||
# [0.1.0-beta.5](https://github.com/muxinc/elements/compare/@mux/mux-uploader@0.1.0-beta.4...@mux/mux-uploader@0.1.0-beta.5) (2022-08-02) | ||
### Bug Fixes | ||
- **mux-uploader:** Fix attempt and chunkSuccess event details not being passed. Also make the data passed consistent by using event for all params. ([09d4cf8](https://github.com/muxinc/elements/commit/09d4cf8e22d8de919e175d039c5f0eb9a42b2591)) | ||
- **mux-uploader:** Update event and event handler typedefs for greater accuracy of types. ([92f28a5](https://github.com/muxinc/elements/commit/92f28a5828ea3c046fa5a1aa711a038a7444f0dc)) | ||
### Features | ||
- **mux-uploader:** Add CSS variables for button border and padding. ([359cd89](https://github.com/muxinc/elements/commit/359cd89472781fc41e33e95574c0d9c845b1d081)) | ||
- **mux-uploader:** Add custom event for when upload starts. ([9fd1efc](https://github.com/muxinc/elements/commit/9fd1efc943bcb60efdb51b455d5b9642af86b920)) | ||
- **mux-uploader:** Support Upchunk's attempt and chunkSuccess events. ([739a88e](https://github.com/muxinc/elements/commit/739a88e5eda697b8344ef14e3a20b1bef19e1a41)) | ||
# [0.1.0-beta.4](https://github.com/muxinc/elements/compare/@mux/mux-uploader@0.1.0-beta.3...@mux/mux-uploader@0.1.0-beta.4) (2022-07-21) | ||
@@ -8,0 +21,0 @@ |
@@ -1,4 +0,4 @@ | ||
(()=>{var Ft=Object.create;var at=Object.defineProperty;var Nt=Object.getOwnPropertyDescriptor;var zt=Object.getOwnPropertyNames;var Xt=Object.getPrototypeOf,Vt=Object.prototype.hasOwnProperty;var qt=a=>at(a,"__esModule",{value:!0});var Wt=(a,e)=>()=>(e||a((e={exports:{}}).exports,e),e.exports);var Gt=(a,e,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of zt(e))!Vt.call(a,n)&&n!=="default"&&at(a,n,{get:()=>e[n],enumerable:!(s=Nt(e,n))||s.enumerable});return a},Yt=a=>Gt(qt(at(a!=null?Ft(Xt(a)):{},"default",a&&a.__esModule&&"default"in a?{get:()=>a.default,enumerable:!0}:{value:a,enumerable:!0})),a);var Rt=(a,e,s)=>{if(!e.has(a))throw TypeError("Cannot "+s)};var At=(a,e,s)=>(Rt(a,e,"read from private field"),s?s.call(a):e.get(a)),Lt=(a,e,s)=>{if(e.has(a))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(a):e.set(a,s)},_t=(a,e,s,n)=>(Rt(a,e,"write to private field"),n?n.call(a,s):e.set(a,s),s);var St=Wt((Q,lt)=>{(function(a,e){typeof Q=="object"&&typeof lt=="object"?lt.exports=e():typeof define=="function"&&define.amd?define([],e):typeof Q=="object"?Q.UpChunk=e():a.UpChunk=e()})(Q,function(){return function(a){var e={};function s(n){if(e[n])return e[n].exports;var u=e[n]={i:n,l:!1,exports:{}};return a[n].call(u.exports,u,u.exports,s),u.l=!0,u.exports}return s.m=a,s.c=e,s.d=function(n,u,p){s.o(n,u)||Object.defineProperty(n,u,{enumerable:!0,get:p})},s.r=function(n){typeof Symbol!="undefined"&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"__esModule",{value:!0})},s.t=function(n,u){if(1&u&&(n=s(n)),8&u||4&u&&typeof n=="object"&&n&&n.__esModule)return n;var p=Object.create(null);if(s.r(p),Object.defineProperty(p,"default",{enumerable:!0,value:n}),2&u&&typeof n!="string")for(var y in n)s.d(p,y,function(C){return n[C]}.bind(null,y));return p},s.n=function(n){var u=n&&n.__esModule?function(){return n.default}:function(){return n};return s.d(u,"a",u),u},s.o=function(n,u){return Object.prototype.hasOwnProperty.call(n,u)},s.p="",s(s.s=1)}([function(a,e){var s;s=function(){return this}();try{s=s||new Function("return this")()}catch{typeof window=="object"&&(s=window)}a.exports=s},function(a,e,s){"use strict";var n=this&&this.__assign||function(){return(n=Object.assign||function(f){for(var t,l=1,b=arguments.length;l<b;l++)for(var T in t=arguments[l])Object.prototype.hasOwnProperty.call(t,T)&&(f[T]=t[T]);return f}).apply(this,arguments)};e.__esModule=!0,e.createUpload=e.UpChunk=void 0;var u=s(2),p=s(4),y=[200,201,202,204,308],C=[408,502,503,504],E=function(){function f(t){var l=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 u.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(t,l){this.eventTarget.addEventListener(t,l)},f.prototype.abort=function(){var t;this.pause(),(t=this.currentXhr)===null||t===void 0||t.abort()},f.prototype.pause=function(){this.paused=!0},f.prototype.resume=function(){this.paused&&(this.paused=!1,this.sendChunks())},f.prototype.dispatch=function(t,l){var b=new CustomEvent(t,{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 t=this;return typeof this.endpoint=="string"?(this.endpointValue=this.endpoint,Promise.resolve(this.endpoint)):this.endpoint(this.file).then(function(l){return t.endpointValue=l,t.endpointValue})},f.prototype.getChunk=function(){var t=this;return new Promise(function(l){var b=t.totalChunks===1?t.file.size:t.chunkByteSize,T=b*t.chunkCount;t.reader.onload=function(){t.reader.result!==null&&(t.chunk=new Blob([t.reader.result],{type:"application/octet-stream"})),l()},t.reader.readAsArrayBuffer(t.file.slice(T,T+b))})},f.prototype.xhrPromise=function(t){var l=this,b=function(T){T.upload.onprogress=function(x){var w,v=100/l.totalChunks,k=v*l.file.size,d=v*l.chunkCount,I=x.loaded/((w=x.total)!==null&&w!==void 0?w:k)*v;l.dispatch("progress",Math.min(d+I,100))}};return new Promise(function(T,x){l.currentXhr=(0,p.default)(n(n({},t),{beforeSend:b}),function(w,v){return l.currentXhr=void 0,w?x(w):T(v)})})},f.prototype.sendChunk=function(){var t=this.chunkCount*this.chunkByteSize,l=t+this.chunk.size-1,b=n(n({},this.headers),{"Content-Type":this.file.type,"Content-Range":"bytes ".concat(t,"-").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 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})},f.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(l){if(y.includes(l.statusCode)){t.dispatch("chunkSuccess",{chunk:t.chunkCount,attempts:t.attemptCount,response:l}),t.attemptCount=0,t.chunkCount=t.chunkCount+1,t.chunkCount<t.totalChunks?t.sendChunks():(t.success=!0,t.dispatch("success"));var b=100*(t.chunkCount/t.totalChunks*t.file.size)/t.file.size;t.dispatch("progress",b)}else if(C.includes(l.statusCode)){if(t.paused||t.offline)return;t.manageRetries()}else{if(t.paused||t.offline)return;t.dispatch("error",{message:"Server responded with ".concat(l.statusCode,". Stopping upload."),chunkNumber:t.chunkCount,attempts:t.attemptCount})}}).catch(function(l){t.paused||t.offline||t.manageRetries()})},f}();e.UpChunk=E,e.createUpload=function(f){return new E(f)}},function(a,e,s){"use strict";(function(n,u){function p(r,o,...i){if(!r)throw new TypeError(y(o,i))}function y(r,o){let i=0;return r.replace(/%[os]/gu,()=>C(o[i++]))}function C(r){return typeof r!="object"||r===null?String(r):Object.prototype.toString.call(r)}let E;Object.defineProperty(e,"__esModule",{value:!0});let f=typeof window!="undefined"?window:typeof self!="undefined"?self:u!==void 0?u:typeof globalThis!="undefined"?globalThis:void 0,t;class l{constructor(o,i){this.code=o,this.message=i}warn(...o){var i;try{if(t)return void t({...this,args:o});let c=((i=new Error().stack)!==null&&i!==void 0?i:"").replace(/^(?:.+?\n){2}/gu,` | ||
`);console.warn(this.message,...o,c)}catch{}}}let b=new l("W01","Unable to initialize event under dispatching."),T=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."),v=new l("W05","Unable to preventDefault inside passive event listener invocation."),k=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."),I=new l("W08","The 'callback' argument must be a function or an object that has 'handleEvent' method: %o"),z=new l("W09","Event attribute handler must be a function: %o");class M{static get NONE(){return X}static get CAPTURING_PHASE(){return B}static get AT_TARGET(){return V}static get BUBBLING_PHASE(){return Y}constructor(o,i){Object.defineProperty(this,"isTrusted",{value:!1,enumerable:!0});let c=i!=null?i:{};q.set(this,{type:String(o),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 o=g(this).currentTarget;return o?[o]:[]}get NONE(){return X}get CAPTURING_PHASE(){return B}get AT_TARGET(){return V}get BUBBLING_PHASE(){return Y}get eventPhase(){return g(this).dispatchFlag?2:0}stopPropagation(){g(this).stopPropagationFlag=!0}get cancelBubble(){return g(this).stopPropagationFlag}set cancelBubble(o){o?g(this).stopPropagationFlag=!0:T.warn()}stopImmediatePropagation(){let o=g(this);o.stopPropagationFlag=o.stopImmediatePropagationFlag=!0}get bubbles(){return g(this).bubbles}get cancelable(){return g(this).cancelable}get returnValue(){return!g(this).canceledFlag}set returnValue(o){o?x.warn():R(g(this))}preventDefault(){R(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(o,i=!1,c=!1){let h=g(this);h.dispatchFlag?b.warn():q.set(this,{...h,type:String(o),bubbles:Boolean(i),cancelable:Boolean(c),target:null,currentTarget:null,stopPropagationFlag:!1,stopImmediatePropagationFlag:!1,canceledFlag:!1})}}let X=0,B=1,V=2,Y=3,q=new WeakMap;function g(r,o="this"){let i=q.get(r);return p(i!=null,"'%s' must be an object that Event constructor created, but got another one: %o",o,r),i}function R(r){r.inPassiveListenerFlag?v.warn():r.cancelable?r.canceledFlag=!0:w.warn()}Object.defineProperty(M,"NONE",{enumerable:!0}),Object.defineProperty(M,"CAPTURING_PHASE",{enumerable:!0}),Object.defineProperty(M,"AT_TARGET",{enumerable:!0}),Object.defineProperty(M,"BUBBLING_PHASE",{enumerable:!0});let S=Object.getOwnPropertyNames(M.prototype);for(let r=0;r<S.length;++r)S[r]!=="constructor"&&Object.defineProperty(M.prototype,S[r],{enumerable:!0});let F;f!==void 0&&f.Event!==void 0&&Object.setPrototypeOf(M.prototype,f.Event.prototype);let ct={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 pt(r){let o=Object.keys(ct);for(let i=0;i<o.length;++i){let c=o[i],h=ct[c];Object.defineProperty(r,c,{get:()=>h,configurable:!0,enumerable:!0})}}class $ extends M{static wrap(o){return new(function i(c){let h=Object.getPrototypeOf(c);if(h==null)return $;let m=tt.get(h);return m==null&&(m=function(A,L){class _ extends A{}let P=Object.keys(L);for(let O=0;O<P.length;++O)Object.defineProperty(_.prototype,P[O],ht(L,P[O]));return _}(i(h),h),tt.set(h,m)),m}(o))(o)}constructor(o){super(o.type,{bubbles:o.bubbles,cancelable:o.cancelable,composed:o.composed}),o.cancelBubble&&super.stopPropagation(),o.defaultPrevented&&super.preventDefault(),dt.set(this,{original:o});let i=Object.keys(o);for(let c=0;c<i.length;++c){let h=i[c];h in this||Object.defineProperty(this,h,ht(o,h))}}stopPropagation(){super.stopPropagation();let{original:o}=U(this);"stopPropagation"in o&&o.stopPropagation()}get cancelBubble(){return super.cancelBubble}set cancelBubble(o){super.cancelBubble=o;let{original:i}=U(this);"cancelBubble"in i&&(i.cancelBubble=o)}stopImmediatePropagation(){super.stopImmediatePropagation();let{original:o}=U(this);"stopImmediatePropagation"in o&&o.stopImmediatePropagation()}get returnValue(){return super.returnValue}set returnValue(o){super.returnValue=o;let{original:i}=U(this);"returnValue"in i&&(i.returnValue=o)}preventDefault(){super.preventDefault();let{original:o}=U(this);"preventDefault"in o&&o.preventDefault()}get timeStamp(){let{original:o}=U(this);return"timeStamp"in o?o.timeStamp:super.timeStamp}}let dt=new WeakMap;function U(r){let o=dt.get(r);return p(o!=null,"'this' is expected an Event object, but got",r),o}let tt=new WeakMap;function ht(r,o){let i=Object.getOwnPropertyDescriptor(r,o);return{get(){let c=U(this).original,h=c[o];return typeof h=="function"?h.bind(c):h},set(c){U(this).original[o]=c},configurable:i.configurable,enumerable:i.enumerable}}function ft(r){return(1&r.flags)==1}function gt(r){return(2&r.flags)==2}function mt(r){return(4&r.flags)==4}function Ht(r){return(8&r.flags)==8}function Ut({callback:r},o,i){try{typeof r=="function"?r.call(o,i):typeof r.handleEvent=="function"&&r.handleEvent(i)}catch(c){(function(h){try{let m=h instanceof Error?h:new Error(C(h));if(E)return void E(m);if(typeof dispatchEvent=="function"&&typeof ErrorEvent=="function")dispatchEvent(new ErrorEvent("error",{error:m,message:m.message}));else if(n!==void 0&&typeof n.emit=="function")return void n.emit("uncaughtException",m);console.error(m)}catch{}})(c)}}function bt({listeners:r},o,i){for(let c=0;c<r.length;++c)if(r[c].callback===o&&ft(r[c])===i)return c;return-1}function yt(r,o,i,c,h,m){let A;m&&(A=st.bind(null,r,o,i),m.addEventListener("abort",A));let L=function(_,P,O,j,et,D){return{callback:_,flags:(P?1:0)|(O?2:0)|(j?4:0),signal:et,signalListener:D}}(o,i,c,h,m,A);return r.cow?(r.cow=!1,r.listeners=[...r.listeners,L]):r.listeners.push(L),L}function st(r,o,i){let c=bt(r,o,i);return c!==-1&&vt(r,c)}function vt(r,o,i=!1){let c=r.listeners[o];return function(h){h.flags|=8}(c),c.signal&&c.signal.removeEventListener("abort",c.signalListener),r.cow&&!i?(r.cow=!1,r.listeners=r.listeners.filter((h,m)=>m!==o),!1):(r.listeners.splice(o,1),!0)}function Et(r,o){var i;return(i=r[o])!==null&&i!==void 0?i:r[o]={attrCallback:void 0,attrListener:void 0,cow:!1,listeners:[]}}tt.set(Object.prototype,$),f!==void 0&&f.Event!==void 0&&tt.set(f.Event.prototype,$);class W{constructor(){Tt.set(this,Object.create(null))}addEventListener(o,i,c){let h=G(this),{callback:m,capture:A,once:L,passive:_,signal:P,type:O}=function(D,N,H){var K;return wt(N),typeof H=="object"&&H!==null?{type:String(D),callback:N!=null?N:void 0,capture:Boolean(H.capture),passive:Boolean(H.passive),once:Boolean(H.once),signal:(K=H.signal)!==null&&K!==void 0?K:void 0}:{type:String(D),callback:N!=null?N:void 0,capture:Boolean(H),passive:!1,once:!1,signal:void 0}}(o,i,c);if(m==null||(P==null?void 0:P.aborted))return;let j=Et(h,O),et=bt(j,m,A);et===-1?yt(j,m,A,_,L,P):function(D,N,H,K){k.warn(ft(D)?"capture":"bubble",D.callback),gt(D)!==N&&d.warn("passive"),mt(D)!==H&&d.warn("once"),D.signal!==K&&d.warn("signal")}(j.listeners[et],_,L,P)}removeEventListener(o,i,c){let h=G(this),{callback:m,capture:A,type:L}=function(P,O,j){return wt(O),typeof j=="object"&&j!==null?{type:String(P),callback:O!=null?O:void 0,capture:Boolean(j.capture)}:{type:String(P),callback:O!=null?O:void 0,capture:Boolean(j)}}(o,i,c),_=h[L];m!=null&&_&&st(_,m,A)}dispatchEvent(o){let i=G(this)[String(o.type)];if(i==null)return!0;let c=o instanceof M?o:$.wrap(o),h=g(c,"event");if(h.dispatchFlag)throw m="This event has been in dispatching.",f.DOMException?new f.DOMException(m,"InvalidStateError"):(F==null&&(F=class Bt extends Error{constructor(L){super(L),Error.captureStackTrace&&Error.captureStackTrace(this,Bt)}get code(){return 11}get name(){return"InvalidStateError"}},Object.defineProperties(F.prototype,{code:{enumerable:!0},name:{enumerable:!0}}),pt(F),pt(F.prototype)),new F(m));var m;if(h.dispatchFlag=!0,h.target=h.currentTarget=this,!h.stopPropagationFlag){let{cow:A,listeners:L}=i;i.cow=!0;for(let _=0;_<L.length;++_){let P=L[_];if(!Ht(P)&&(mt(P)&&vt(i,_,!A)&&(_-=1),h.inPassiveListenerFlag=gt(P),Ut(P,this,c),h.inPassiveListenerFlag=!1,h.stopImmediatePropagationFlag))break}A||(i.cow=!1)}return h.target=null,h.currentTarget=null,h.stopImmediatePropagationFlag=!1,h.stopPropagationFlag=!1,h.dispatchFlag=!1,!h.canceledFlag}}let Tt=new WeakMap;function G(r,o="this"){let i=Tt.get(r);return p(i!=null,"'%s' must be an object that EventTarget constructor created, but got another one: %o",o,r),i}function wt(r){if(typeof r!="function"&&(typeof r!="object"||r===null||typeof r.handleEvent!="function")){if(r!=null&&typeof r!="object")throw new TypeError(y(I.message,[r]));I.warn(r)}}let it=Object.getOwnPropertyNames(W.prototype);for(let r=0;r<it.length;++r)it[r]!=="constructor"&&Object.defineProperty(W.prototype,it[r],{enumerable:!0});function kt(r,o){var i,c;return(c=(i=G(r,"target")[o])===null||i===void 0?void 0:i.attrCallback)!==null&&c!==void 0?c:null}function Pt(r,o,i){i!=null&&typeof i!="function"&&z.warn(i),typeof i=="function"||typeof i=="object"&&i!==null?function(c,h,m){let A=Et(G(c,"target"),String(h));A.attrCallback=m,A.attrListener==null&&(A.attrListener=yt(A,function(L){return function(_){let P=L.attrCallback;typeof P=="function"&&P.call(this,_)}}(A),!1,!1,!1,void 0))}(r,o,i):function(c,h){let m=G(c,"target")[String(h)];m&&m.attrListener&&(st(m,m.attrListener.callback,!1),m.attrCallback=m.attrListener=void 0)}(r,o)}function Ct(r,o,i){Object.defineProperty(r,"on"+o,{get(){return kt(this,o)},set(c){Pt(this,o,c)},configurable:!0,enumerable:!0})}f!==void 0&&f.EventTarget!==void 0&&Object.setPrototypeOf(W.prototype,f.EventTarget.prototype),e.Event=M,e.EventTarget=W,e.default=W,e.defineCustomEventTarget=function(...r){class o extends W{}for(let i=0;i<r.length;++i)Ct(o.prototype,r[i]);return o},e.defineEventAttribute=Ct,e.getEventAttributeValue=kt,e.setErrorHandler=function(r){p(typeof r=="function"||r===void 0,"The error handler must be a function or undefined, but got %o.",r),E=r},e.setEventAttributeValue=Pt,e.setWarningHandler=function(r){p(typeof r=="function"||r===void 0,"The warning handler must be a function or undefined, but got %o.",r),t=r}}).call(this,s(3),s(0))},function(a,e){var s,n,u=a.exports={};function p(){throw new Error("setTimeout has not been defined")}function y(){throw new Error("clearTimeout has not been defined")}function C(v){if(s===setTimeout)return setTimeout(v,0);if((s===p||!s)&&setTimeout)return s=setTimeout,setTimeout(v,0);try{return s(v,0)}catch{try{return s.call(null,v,0)}catch{return s.call(this,v,0)}}}(function(){try{s=typeof setTimeout=="function"?setTimeout:p}catch{s=p}try{n=typeof clearTimeout=="function"?clearTimeout:y}catch{n=y}})();var E,f=[],t=!1,l=-1;function b(){t&&E&&(t=!1,E.length?f=E.concat(f):l=-1,f.length&&T())}function T(){if(!t){var v=C(b);t=!0;for(var k=f.length;k;){for(E=f,f=[];++l<k;)E&&E[l].run();l=-1,k=f.length}E=null,t=!1,function(d){if(n===clearTimeout)return clearTimeout(d);if((n===y||!n)&&clearTimeout)return n=clearTimeout,clearTimeout(d);try{n(d)}catch{try{return n.call(null,d)}catch{return n.call(this,d)}}}(v)}}function x(v,k){this.fun=v,this.array=k}function w(){}u.nextTick=function(v){var k=new Array(arguments.length-1);if(arguments.length>1)for(var d=1;d<arguments.length;d++)k[d-1]=arguments[d];f.push(new x(v,k)),f.length!==1||t||C(T)},x.prototype.run=function(){this.fun.apply(null,this.array)},u.title="browser",u.browser=!0,u.env={},u.argv=[],u.version="",u.versions={},u.on=w,u.addListener=w,u.once=w,u.off=w,u.removeListener=w,u.removeAllListeners=w,u.emit=w,u.prependListener=w,u.prependOnceListener=w,u.listeners=function(v){return[]},u.binding=function(v){throw new Error("process.binding is not supported")},u.cwd=function(){return"/"},u.chdir=function(v){throw new Error("process.chdir is not supported")},u.umask=function(){return 0}},function(a,e,s){"use strict";var n=s(5),u=s(6),p=s(7),y=s(8);function C(t,l,b){var T=t;return u(l)?(b=l,typeof t=="string"&&(T={uri:t})):T=y(l,{uri:t}),T.callback=b,T}function E(t,l,b){return f(l=C(t,l,b))}function f(t){if(t.callback===void 0)throw new Error("callback argument missing");var l=!1,b=function(g,R,S){l||(l=!0,t.callback(g,R,S))};function T(){var g=void 0;if(g=d.response?d.response:d.responseText||function(R){try{if(R.responseType==="document")return R.responseXML;var S=R.responseXML&&R.responseXML.documentElement.nodeName==="parsererror";if(R.responseType===""&&!S)return R.responseXML}catch{}return null}(d),Y)try{g=JSON.parse(g)}catch{}return g}function x(g){return clearTimeout(I),g instanceof Error||(g=new Error(""+(g||"Unknown XMLHttpRequest Error"))),g.statusCode=0,b(g,q)}function w(){if(!k){var g;clearTimeout(I),g=t.useXDR&&d.status===void 0?200:d.status===1223?204:d.status;var R=q,S=null;return g!==0?(R={body:T(),statusCode:g,method:M,headers:{},url:z,rawRequest:d},d.getAllResponseHeaders&&(R.headers=p(d.getAllResponseHeaders()))):S=new Error("Internal XMLHttpRequest Error"),b(S,R,R.body)}}var v,k,d=t.xhr||null;d||(d=t.cors||t.useXDR?new E.XDomainRequest:new E.XMLHttpRequest);var I,z=d.url=t.uri||t.url,M=d.method=t.method||"GET",X=t.body||t.data,B=d.headers=t.headers||{},V=!!t.sync,Y=!1,q={body:void 0,headers:{},statusCode:0,method:M,url:z,rawRequest:d};if("json"in t&&t.json!==!1&&(Y=!0,B.accept||B.Accept||(B.Accept="application/json"),M!=="GET"&&M!=="HEAD"&&(B["content-type"]||B["Content-Type"]||(B["Content-Type"]="application/json"),X=JSON.stringify(t.json===!0?X:t.json))),d.onreadystatechange=function(){d.readyState===4&&setTimeout(w,0)},d.onload=w,d.onerror=x,d.onprogress=function(){},d.onabort=function(){k=!0},d.ontimeout=x,d.open(M,z,!V,t.username,t.password),V||(d.withCredentials=!!t.withCredentials),!V&&t.timeout>0&&(I=setTimeout(function(){if(!k){k=!0,d.abort("timeout");var g=new Error("XMLHttpRequest timeout");g.code="ETIMEDOUT",x(g)}},t.timeout)),d.setRequestHeader)for(v in B)B.hasOwnProperty(v)&&d.setRequestHeader(v,B[v]);else if(t.headers&&!function(g){for(var R in g)if(g.hasOwnProperty(R))return!1;return!0}(t.headers))throw new Error("Headers cannot be set on an XDomainRequest object");return"responseType"in t&&(d.responseType=t.responseType),"beforeSend"in t&&typeof t.beforeSend=="function"&&t.beforeSend(d),d.send(X||null),d}a.exports=E,a.exports.default=E,E.XMLHttpRequest=n.XMLHttpRequest||function(){},E.XDomainRequest="withCredentials"in new E.XMLHttpRequest?E.XMLHttpRequest:n.XDomainRequest,function(t,l){for(var b=0;b<t.length;b++)l(t[b])}(["get","put","post","patch","head","delete"],function(t){E[t==="delete"?"del":t]=function(l,b,T){return(b=C(l,b,T)).method=t.toUpperCase(),f(b)}})},function(a,e,s){(function(n){var u;u=typeof window!="undefined"?window:n!==void 0?n:typeof self!="undefined"?self:{},a.exports=u}).call(this,s(0))},function(a,e){a.exports=function(n){if(!n)return!1;var u=s.call(n);return u==="[object Function]"||typeof n=="function"&&u!=="[object RegExp]"||typeof window!="undefined"&&(n===window.setTimeout||n===window.alert||n===window.confirm||n===window.prompt)};var s=Object.prototype.toString},function(a,e){var s=function(n){return n.replace(/^\s+|\s+$/g,"")};a.exports=function(n){if(!n)return{};for(var u,p={},y=s(n).split(` | ||
`),C=0;C<y.length;C++){var E=y[C],f=E.indexOf(":"),t=s(E.slice(0,f)).toLowerCase(),l=s(E.slice(f+1));p[t]===void 0?p[t]=l:(u=p[t],Object.prototype.toString.call(u)==="[object Array]"?p[t].push(l):p[t]=[p[t],l])}return p}},function(a,e){a.exports=function(){for(var n={},u=0;u<arguments.length;u++){var p=arguments[u];for(var y in p)s.call(p,y)&&(n[y]=p[y])}return n};var s=Object.prototype.hasOwnProperty}])})});if(typeof DocumentFragment=="undefined"){class a{}globalThis.DocumentFragment=a}globalThis.customElements||(globalThis.customElements={get(a){},define(a,e,s){},upgrade(a){},whenDefined(a){return Promise.resolve(globalThis.HTMLElement)}});var J;if(!globalThis.CustomEvent){class a{constructor(s,n={}){Lt(this,J,void 0);_t(this,J,n==null?void 0:n.detail)}get detail(){At(this,J)}initCustomEvent(s,n,u,p){}}J=new WeakMap,globalThis.CustomEvent=a}if(!globalThis.EventTarget){class a{addEventListener(){}removeEventListener(){}dispatchEvent(s){return!0}}globalThis.EventTarget=a}if(!globalThis.HTMLElement){class a extends EventTarget{}globalThis.HTMLElement=a}if(!globalThis.HTMLVideoElement){class a extends EventTarget{}globalThis.HTMLVideoElement=a}var xt,Mt;if(!((xt=globalThis.document)==null?void 0:xt.createElement)){let a=(Mt=globalThis.document)!=null?Mt:{};a.createElement=function(s,n){return new HTMLElement},globalThis.document=a}var Ot=document.createElement("template");Ot.innerHTML=` | ||
(()=>{var Ft=Object.create;var at=Object.defineProperty;var Nt=Object.getOwnPropertyDescriptor;var zt=Object.getOwnPropertyNames;var Xt=Object.getPrototypeOf,Vt=Object.prototype.hasOwnProperty;var qt=a=>at(a,"__esModule",{value:!0});var Wt=(a,e)=>()=>(e||a((e={exports:{}}).exports,e),e.exports);var Gt=(a,e,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of zt(e))!Vt.call(a,n)&&n!=="default"&&at(a,n,{get:()=>e[n],enumerable:!(s=Nt(e,n))||s.enumerable});return a},Kt=a=>Gt(qt(at(a!=null?Ft(Xt(a)):{},"default",a&&a.__esModule&&"default"in a?{get:()=>a.default,enumerable:!0}:{value:a,enumerable:!0})),a);var Pt=(a,e,s)=>{if(!e.has(a))throw TypeError("Cannot "+s)};var Mt=(a,e,s)=>(Pt(a,e,"read from private field"),s?s.call(a):e.get(a)),Rt=(a,e,s)=>{if(e.has(a))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(a):e.set(a,s)},At=(a,e,s,n)=>(Pt(a,e,"write to private field"),n?n.call(a,s):e.set(a,s),s);var Bt=Wt((Q,lt)=>{(function(a,e){typeof Q=="object"&&typeof lt=="object"?lt.exports=e():typeof define=="function"&&define.amd?define([],e):typeof Q=="object"?Q.UpChunk=e():a.UpChunk=e()})(Q,function(){return function(a){var e={};function s(n){if(e[n])return e[n].exports;var u=e[n]={i:n,l:!1,exports:{}};return a[n].call(u.exports,u,u.exports,s),u.l=!0,u.exports}return s.m=a,s.c=e,s.d=function(n,u,p){s.o(n,u)||Object.defineProperty(n,u,{enumerable:!0,get:p})},s.r=function(n){typeof Symbol!="undefined"&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"__esModule",{value:!0})},s.t=function(n,u){if(1&u&&(n=s(n)),8&u||4&u&&typeof n=="object"&&n&&n.__esModule)return n;var p=Object.create(null);if(s.r(p),Object.defineProperty(p,"default",{enumerable:!0,value:n}),2&u&&typeof n!="string")for(var v in n)s.d(p,v,function(L){return n[L]}.bind(null,v));return p},s.n=function(n){var u=n&&n.__esModule?function(){return n.default}:function(){return n};return s.d(u,"a",u),u},s.o=function(n,u){return Object.prototype.hasOwnProperty.call(n,u)},s.p="",s(s.s=1)}([function(a,e){var s;s=function(){return this}();try{s=s||new Function("return this")()}catch{typeof window=="object"&&(s=window)}a.exports=s},function(a,e,s){"use strict";var n=this&&this.__assign||function(){return(n=Object.assign||function(f){for(var t,l=1,b=arguments.length;l<b;l++)for(var T in t=arguments[l])Object.prototype.hasOwnProperty.call(t,T)&&(f[T]=t[T]);return f}).apply(this,arguments)};e.__esModule=!0,e.createUpload=e.UpChunk=void 0;var u=s(2),p=s(4),v=[200,201,202,204,308],L=[408,502,503,504],E=function(){function f(t){var l=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 u.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(t,l){this.eventTarget.addEventListener(t,l)},f.prototype.abort=function(){var t;this.pause(),(t=this.currentXhr)===null||t===void 0||t.abort()},f.prototype.pause=function(){this.paused=!0},f.prototype.resume=function(){this.paused&&(this.paused=!1,this.sendChunks())},f.prototype.dispatch=function(t,l){var b=new CustomEvent(t,{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 t=this;return typeof this.endpoint=="string"?(this.endpointValue=this.endpoint,Promise.resolve(this.endpoint)):this.endpoint(this.file).then(function(l){return t.endpointValue=l,t.endpointValue})},f.prototype.getChunk=function(){var t=this;return new Promise(function(l){var b=t.totalChunks===1?t.file.size:t.chunkByteSize,T=b*t.chunkCount;t.reader.onload=function(){t.reader.result!==null&&(t.chunk=new Blob([t.reader.result],{type:"application/octet-stream"})),l()},t.reader.readAsArrayBuffer(t.file.slice(T,T+b))})},f.prototype.xhrPromise=function(t){var l=this,b=function(T){T.upload.onprogress=function(x){var w,y=100/l.totalChunks,k=y*l.file.size,d=y*l.chunkCount,H=x.loaded/((w=x.total)!==null&&w!==void 0?w:k)*y;l.dispatch("progress",Math.min(d+H,100))}};return new Promise(function(T,x){l.currentXhr=(0,p.default)(n(n({},t),{beforeSend:b}),function(w,y){return l.currentXhr=void 0,w?x(w):T(y)})})},f.prototype.sendChunk=function(){var t=this.chunkCount*this.chunkByteSize,l=t+this.chunk.size-1,b=n(n({},this.headers),{"Content-Type":this.file.type,"Content-Range":"bytes ".concat(t,"-").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 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})},f.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(l){if(v.includes(l.statusCode)){t.dispatch("chunkSuccess",{chunk:t.chunkCount,attempts:t.attemptCount,response:l}),t.attemptCount=0,t.chunkCount=t.chunkCount+1,t.chunkCount<t.totalChunks?t.sendChunks():(t.success=!0,t.dispatch("success"));var b=100*(t.chunkCount/t.totalChunks*t.file.size)/t.file.size;t.dispatch("progress",b)}else if(L.includes(l.statusCode)){if(t.paused||t.offline)return;t.manageRetries()}else{if(t.paused||t.offline)return;t.dispatch("error",{message:"Server responded with ".concat(l.statusCode,". Stopping upload."),chunkNumber:t.chunkCount,attempts:t.attemptCount})}}).catch(function(l){t.paused||t.offline||t.manageRetries()})},f}();e.UpChunk=E,e.createUpload=function(f){return new E(f)}},function(a,e,s){"use strict";(function(n,u){function p(r,o,...i){if(!r)throw new TypeError(v(o,i))}function v(r,o){let i=0;return r.replace(/%[os]/gu,()=>L(o[i++]))}function L(r){return typeof r!="object"||r===null?String(r):Object.prototype.toString.call(r)}let E;Object.defineProperty(e,"__esModule",{value:!0});let f=typeof window!="undefined"?window:typeof self!="undefined"?self:u!==void 0?u:typeof globalThis!="undefined"?globalThis:void 0,t;class l{constructor(o,i){this.code=o,this.message=i}warn(...o){var i;try{if(t)return void t({...this,args:o});let c=((i=new Error().stack)!==null&&i!==void 0?i:"").replace(/^(?:.+?\n){2}/gu,` | ||
`);console.warn(this.message,...o,c)}catch{}}}let b=new l("W01","Unable to initialize event under dispatching."),T=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."),k=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."),H=new l("W08","The 'callback' argument must be a function or an object that has 'handleEvent' method: %o"),z=new l("W09","Event attribute handler must be a function: %o");class _{static get NONE(){return X}static get CAPTURING_PHASE(){return S}static get AT_TARGET(){return V}static get BUBBLING_PHASE(){return K}constructor(o,i){Object.defineProperty(this,"isTrusted",{value:!1,enumerable:!0});let c=i!=null?i:{};q.set(this,{type:String(o),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 o=g(this).currentTarget;return o?[o]:[]}get NONE(){return X}get CAPTURING_PHASE(){return S}get AT_TARGET(){return V}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(o){o?g(this).stopPropagationFlag=!0:T.warn()}stopImmediatePropagation(){let o=g(this);o.stopPropagationFlag=o.stopImmediatePropagationFlag=!0}get bubbles(){return g(this).bubbles}get cancelable(){return g(this).cancelable}get returnValue(){return!g(this).canceledFlag}set returnValue(o){o?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(o,i=!1,c=!1){let h=g(this);h.dispatchFlag?b.warn():q.set(this,{...h,type:String(o),bubbles:Boolean(i),cancelable:Boolean(c),target:null,currentTarget:null,stopPropagationFlag:!1,stopImmediatePropagationFlag:!1,canceledFlag:!1})}}let X=0,S=1,V=2,K=3,q=new WeakMap;function g(r,o="this"){let i=q.get(r);return p(i!=null,"'%s' must be an object that Event constructor created, but got another one: %o",o,r),i}function P(r){r.inPassiveListenerFlag?y.warn():r.cancelable?r.canceledFlag=!0:w.warn()}Object.defineProperty(_,"NONE",{enumerable:!0}),Object.defineProperty(_,"CAPTURING_PHASE",{enumerable:!0}),Object.defineProperty(_,"AT_TARGET",{enumerable:!0}),Object.defineProperty(_,"BUBBLING_PHASE",{enumerable:!0});let B=Object.getOwnPropertyNames(_.prototype);for(let r=0;r<B.length;++r)B[r]!=="constructor"&&Object.defineProperty(_.prototype,B[r],{enumerable:!0});let F;f!==void 0&&f.Event!==void 0&&Object.setPrototypeOf(_.prototype,f.Event.prototype);let ct={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 pt(r){let o=Object.keys(ct);for(let i=0;i<o.length;++i){let c=o[i],h=ct[c];Object.defineProperty(r,c,{get:()=>h,configurable:!0,enumerable:!0})}}class Y extends _{static wrap(o){return new(function i(c){let h=Object.getPrototypeOf(c);if(h==null)return Y;let m=tt.get(h);return m==null&&(m=function(M,R){class A extends M{}let C=Object.keys(R);for(let O=0;O<C.length;++O)Object.defineProperty(A.prototype,C[O],ht(R,C[O]));return A}(i(h),h),tt.set(h,m)),m}(o))(o)}constructor(o){super(o.type,{bubbles:o.bubbles,cancelable:o.cancelable,composed:o.composed}),o.cancelBubble&&super.stopPropagation(),o.defaultPrevented&&super.preventDefault(),dt.set(this,{original:o});let i=Object.keys(o);for(let c=0;c<i.length;++c){let h=i[c];h in this||Object.defineProperty(this,h,ht(o,h))}}stopPropagation(){super.stopPropagation();let{original:o}=I(this);"stopPropagation"in o&&o.stopPropagation()}get cancelBubble(){return super.cancelBubble}set cancelBubble(o){super.cancelBubble=o;let{original:i}=I(this);"cancelBubble"in i&&(i.cancelBubble=o)}stopImmediatePropagation(){super.stopImmediatePropagation();let{original:o}=I(this);"stopImmediatePropagation"in o&&o.stopImmediatePropagation()}get returnValue(){return super.returnValue}set returnValue(o){super.returnValue=o;let{original:i}=I(this);"returnValue"in i&&(i.returnValue=o)}preventDefault(){super.preventDefault();let{original:o}=I(this);"preventDefault"in o&&o.preventDefault()}get timeStamp(){let{original:o}=I(this);return"timeStamp"in o?o.timeStamp:super.timeStamp}}let dt=new WeakMap;function I(r){let o=dt.get(r);return p(o!=null,"'this' is expected an Event object, but got",r),o}let tt=new WeakMap;function ht(r,o){let i=Object.getOwnPropertyDescriptor(r,o);return{get(){let c=I(this).original,h=c[o];return typeof h=="function"?h.bind(c):h},set(c){I(this).original[o]=c},configurable:i.configurable,enumerable:i.enumerable}}function ft(r){return(1&r.flags)==1}function gt(r){return(2&r.flags)==2}function mt(r){return(4&r.flags)==4}function Dt(r){return(8&r.flags)==8}function It({callback:r},o,i){try{typeof r=="function"?r.call(o,i):typeof r.handleEvent=="function"&&r.handleEvent(i)}catch(c){(function(h){try{let m=h instanceof Error?h:new Error(L(h));if(E)return void E(m);if(typeof dispatchEvent=="function"&&typeof ErrorEvent=="function")dispatchEvent(new ErrorEvent("error",{error:m,message:m.message}));else if(n!==void 0&&typeof n.emit=="function")return void n.emit("uncaughtException",m);console.error(m)}catch{}})(c)}}function bt({listeners:r},o,i){for(let c=0;c<r.length;++c)if(r[c].callback===o&&ft(r[c])===i)return c;return-1}function vt(r,o,i,c,h,m){let M;m&&(M=st.bind(null,r,o,i),m.addEventListener("abort",M));let R=function(A,C,O,j,et,U){return{callback:A,flags:(C?1:0)|(O?2:0)|(j?4:0),signal:et,signalListener:U}}(o,i,c,h,m,M);return r.cow?(r.cow=!1,r.listeners=[...r.listeners,R]):r.listeners.push(R),R}function st(r,o,i){let c=bt(r,o,i);return c!==-1&&yt(r,c)}function yt(r,o,i=!1){let c=r.listeners[o];return function(h){h.flags|=8}(c),c.signal&&c.signal.removeEventListener("abort",c.signalListener),r.cow&&!i?(r.cow=!1,r.listeners=r.listeners.filter((h,m)=>m!==o),!1):(r.listeners.splice(o,1),!0)}function Et(r,o){var i;return(i=r[o])!==null&&i!==void 0?i:r[o]={attrCallback:void 0,attrListener:void 0,cow:!1,listeners:[]}}tt.set(Object.prototype,Y),f!==void 0&&f.Event!==void 0&&tt.set(f.Event.prototype,Y);class W{constructor(){Tt.set(this,Object.create(null))}addEventListener(o,i,c){let h=G(this),{callback:m,capture:M,once:R,passive:A,signal:C,type:O}=function(U,N,D){var $;return wt(N),typeof D=="object"&&D!==null?{type:String(U),callback:N!=null?N:void 0,capture:Boolean(D.capture),passive:Boolean(D.passive),once:Boolean(D.once),signal:($=D.signal)!==null&&$!==void 0?$:void 0}:{type:String(U),callback:N!=null?N:void 0,capture:Boolean(D),passive:!1,once:!1,signal:void 0}}(o,i,c);if(m==null||(C==null?void 0:C.aborted))return;let j=Et(h,O),et=bt(j,m,M);et===-1?vt(j,m,M,A,R,C):function(U,N,D,$){k.warn(ft(U)?"capture":"bubble",U.callback),gt(U)!==N&&d.warn("passive"),mt(U)!==D&&d.warn("once"),U.signal!==$&&d.warn("signal")}(j.listeners[et],A,R,C)}removeEventListener(o,i,c){let h=G(this),{callback:m,capture:M,type:R}=function(C,O,j){return wt(O),typeof j=="object"&&j!==null?{type:String(C),callback:O!=null?O:void 0,capture:Boolean(j.capture)}:{type:String(C),callback:O!=null?O:void 0,capture:Boolean(j)}}(o,i,c),A=h[R];m!=null&&A&&st(A,m,M)}dispatchEvent(o){let i=G(this)[String(o.type)];if(i==null)return!0;let c=o instanceof _?o:Y.wrap(o),h=g(c,"event");if(h.dispatchFlag)throw m="This event has been in dispatching.",f.DOMException?new f.DOMException(m,"InvalidStateError"):(F==null&&(F=class St extends Error{constructor(R){super(R),Error.captureStackTrace&&Error.captureStackTrace(this,St)}get code(){return 11}get name(){return"InvalidStateError"}},Object.defineProperties(F.prototype,{code:{enumerable:!0},name:{enumerable:!0}}),pt(F),pt(F.prototype)),new F(m));var m;if(h.dispatchFlag=!0,h.target=h.currentTarget=this,!h.stopPropagationFlag){let{cow:M,listeners:R}=i;i.cow=!0;for(let A=0;A<R.length;++A){let C=R[A];if(!Dt(C)&&(mt(C)&&yt(i,A,!M)&&(A-=1),h.inPassiveListenerFlag=gt(C),It(C,this,c),h.inPassiveListenerFlag=!1,h.stopImmediatePropagationFlag))break}M||(i.cow=!1)}return h.target=null,h.currentTarget=null,h.stopImmediatePropagationFlag=!1,h.stopPropagationFlag=!1,h.dispatchFlag=!1,!h.canceledFlag}}let Tt=new WeakMap;function G(r,o="this"){let i=Tt.get(r);return p(i!=null,"'%s' must be an object that EventTarget constructor created, but got another one: %o",o,r),i}function wt(r){if(typeof r!="function"&&(typeof r!="object"||r===null||typeof r.handleEvent!="function")){if(r!=null&&typeof r!="object")throw new TypeError(v(H.message,[r]));H.warn(r)}}let it=Object.getOwnPropertyNames(W.prototype);for(let r=0;r<it.length;++r)it[r]!=="constructor"&&Object.defineProperty(W.prototype,it[r],{enumerable:!0});function kt(r,o){var i,c;return(c=(i=G(r,"target")[o])===null||i===void 0?void 0:i.attrCallback)!==null&&c!==void 0?c:null}function Ct(r,o,i){i!=null&&typeof i!="function"&&z.warn(i),typeof i=="function"||typeof i=="object"&&i!==null?function(c,h,m){let M=Et(G(c,"target"),String(h));M.attrCallback=m,M.attrListener==null&&(M.attrListener=vt(M,function(R){return function(A){let C=R.attrCallback;typeof C=="function"&&C.call(this,A)}}(M),!1,!1,!1,void 0))}(r,o,i):function(c,h){let m=G(c,"target")[String(h)];m&&m.attrListener&&(st(m,m.attrListener.callback,!1),m.attrCallback=m.attrListener=void 0)}(r,o)}function Lt(r,o,i){Object.defineProperty(r,"on"+o,{get(){return kt(this,o)},set(c){Ct(this,o,c)},configurable:!0,enumerable:!0})}f!==void 0&&f.EventTarget!==void 0&&Object.setPrototypeOf(W.prototype,f.EventTarget.prototype),e.Event=_,e.EventTarget=W,e.default=W,e.defineCustomEventTarget=function(...r){class o extends W{}for(let i=0;i<r.length;++i)Lt(o.prototype,r[i]);return o},e.defineEventAttribute=Lt,e.getEventAttributeValue=kt,e.setErrorHandler=function(r){p(typeof r=="function"||r===void 0,"The error handler must be a function or undefined, but got %o.",r),E=r},e.setEventAttributeValue=Ct,e.setWarningHandler=function(r){p(typeof r=="function"||r===void 0,"The warning handler must be a function or undefined, but got %o.",r),t=r}}).call(this,s(3),s(0))},function(a,e){var s,n,u=a.exports={};function p(){throw new Error("setTimeout has not been defined")}function v(){throw new Error("clearTimeout has not been defined")}function L(y){if(s===setTimeout)return setTimeout(y,0);if((s===p||!s)&&setTimeout)return s=setTimeout,setTimeout(y,0);try{return s(y,0)}catch{try{return s.call(null,y,0)}catch{return s.call(this,y,0)}}}(function(){try{s=typeof setTimeout=="function"?setTimeout:p}catch{s=p}try{n=typeof clearTimeout=="function"?clearTimeout:v}catch{n=v}})();var E,f=[],t=!1,l=-1;function b(){t&&E&&(t=!1,E.length?f=E.concat(f):l=-1,f.length&&T())}function T(){if(!t){var y=L(b);t=!0;for(var k=f.length;k;){for(E=f,f=[];++l<k;)E&&E[l].run();l=-1,k=f.length}E=null,t=!1,function(d){if(n===clearTimeout)return clearTimeout(d);if((n===v||!n)&&clearTimeout)return n=clearTimeout,clearTimeout(d);try{n(d)}catch{try{return n.call(null,d)}catch{return n.call(this,d)}}}(y)}}function x(y,k){this.fun=y,this.array=k}function w(){}u.nextTick=function(y){var k=new Array(arguments.length-1);if(arguments.length>1)for(var d=1;d<arguments.length;d++)k[d-1]=arguments[d];f.push(new x(y,k)),f.length!==1||t||L(T)},x.prototype.run=function(){this.fun.apply(null,this.array)},u.title="browser",u.browser=!0,u.env={},u.argv=[],u.version="",u.versions={},u.on=w,u.addListener=w,u.once=w,u.off=w,u.removeListener=w,u.removeAllListeners=w,u.emit=w,u.prependListener=w,u.prependOnceListener=w,u.listeners=function(y){return[]},u.binding=function(y){throw new Error("process.binding is not supported")},u.cwd=function(){return"/"},u.chdir=function(y){throw new Error("process.chdir is not supported")},u.umask=function(){return 0}},function(a,e,s){"use strict";var n=s(5),u=s(6),p=s(7),v=s(8);function L(t,l,b){var T=t;return u(l)?(b=l,typeof t=="string"&&(T={uri:t})):T=v(l,{uri:t}),T.callback=b,T}function E(t,l,b){return f(l=L(t,l,b))}function f(t){if(t.callback===void 0)throw new Error("callback argument missing");var l=!1,b=function(g,P,B){l||(l=!0,t.callback(g,P,B))};function T(){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(H),g instanceof Error||(g=new Error(""+(g||"Unknown XMLHttpRequest Error"))),g.statusCode=0,b(g,q)}function w(){if(!k){var g;clearTimeout(H),g=t.useXDR&&d.status===void 0?200:d.status===1223?204:d.status;var P=q,B=null;return g!==0?(P={body:T(),statusCode:g,method:_,headers:{},url:z,rawRequest:d},d.getAllResponseHeaders&&(P.headers=p(d.getAllResponseHeaders()))):B=new Error("Internal XMLHttpRequest Error"),b(B,P,P.body)}}var y,k,d=t.xhr||null;d||(d=t.cors||t.useXDR?new E.XDomainRequest:new E.XMLHttpRequest);var H,z=d.url=t.uri||t.url,_=d.method=t.method||"GET",X=t.body||t.data,S=d.headers=t.headers||{},V=!!t.sync,K=!1,q={body:void 0,headers:{},statusCode:0,method:_,url:z,rawRequest:d};if("json"in t&&t.json!==!1&&(K=!0,S.accept||S.Accept||(S.Accept="application/json"),_!=="GET"&&_!=="HEAD"&&(S["content-type"]||S["Content-Type"]||(S["Content-Type"]="application/json"),X=JSON.stringify(t.json===!0?X:t.json))),d.onreadystatechange=function(){d.readyState===4&&setTimeout(w,0)},d.onload=w,d.onerror=x,d.onprogress=function(){},d.onabort=function(){k=!0},d.ontimeout=x,d.open(_,z,!V,t.username,t.password),V||(d.withCredentials=!!t.withCredentials),!V&&t.timeout>0&&(H=setTimeout(function(){if(!k){k=!0,d.abort("timeout");var g=new Error("XMLHttpRequest timeout");g.code="ETIMEDOUT",x(g)}},t.timeout)),d.setRequestHeader)for(y in S)S.hasOwnProperty(y)&&d.setRequestHeader(y,S[y]);else if(t.headers&&!function(g){for(var P in g)if(g.hasOwnProperty(P))return!1;return!0}(t.headers))throw new Error("Headers cannot be set on an XDomainRequest object");return"responseType"in t&&(d.responseType=t.responseType),"beforeSend"in t&&typeof t.beforeSend=="function"&&t.beforeSend(d),d.send(X||null),d}a.exports=E,a.exports.default=E,E.XMLHttpRequest=n.XMLHttpRequest||function(){},E.XDomainRequest="withCredentials"in new E.XMLHttpRequest?E.XMLHttpRequest:n.XDomainRequest,function(t,l){for(var b=0;b<t.length;b++)l(t[b])}(["get","put","post","patch","head","delete"],function(t){E[t==="delete"?"del":t]=function(l,b,T){return(b=L(l,b,T)).method=t.toUpperCase(),f(b)}})},function(a,e,s){(function(n){var u;u=typeof window!="undefined"?window:n!==void 0?n:typeof self!="undefined"?self:{},a.exports=u}).call(this,s(0))},function(a,e){a.exports=function(n){if(!n)return!1;var u=s.call(n);return u==="[object Function]"||typeof n=="function"&&u!=="[object RegExp]"||typeof window!="undefined"&&(n===window.setTimeout||n===window.alert||n===window.confirm||n===window.prompt)};var s=Object.prototype.toString},function(a,e){var s=function(n){return n.replace(/^\s+|\s+$/g,"")};a.exports=function(n){if(!n)return{};for(var u,p={},v=s(n).split(` | ||
`),L=0;L<v.length;L++){var E=v[L],f=E.indexOf(":"),t=s(E.slice(0,f)).toLowerCase(),l=s(E.slice(f+1));p[t]===void 0?p[t]=l:(u=p[t],Object.prototype.toString.call(u)==="[object Array]"?p[t].push(l):p[t]=[p[t],l])}return p}},function(a,e){a.exports=function(){for(var n={},u=0;u<arguments.length;u++){var p=arguments[u];for(var v in p)s.call(p,v)&&(n[v]=p[v])}return n};var s=Object.prototype.hasOwnProperty}])})});if(typeof DocumentFragment=="undefined"){class a{}globalThis.DocumentFragment=a}globalThis.customElements||(globalThis.customElements={get(a){},define(a,e,s){},upgrade(a){},whenDefined(a){return Promise.resolve(globalThis.HTMLElement)}});var J;if(!globalThis.CustomEvent){class a{constructor(s,n={}){Rt(this,J,void 0);At(this,J,n==null?void 0:n.detail)}get detail(){Mt(this,J)}initCustomEvent(s,n,u,p){}}J=new WeakMap,globalThis.CustomEvent=a}if(!globalThis.EventTarget){class a{addEventListener(){}removeEventListener(){}dispatchEvent(s){return!0}}globalThis.EventTarget=a}if(!globalThis.HTMLElement){class a extends EventTarget{}globalThis.HTMLElement=a}if(!globalThis.HTMLVideoElement){class a extends EventTarget{}globalThis.HTMLVideoElement=a}var xt,_t;if(!((xt=globalThis.document)==null?void 0:xt.createElement)){let a=(_t=globalThis.document)!=null?_t:{};a.createElement=function(s,n){return new HTMLElement},globalThis.document=a}var Ot=document.createElement("template");Ot.innerHTML=` | ||
<style> | ||
@@ -33,3 +33,3 @@ :host { | ||
</div> | ||
`;var nt={MUX_UPLOADER:"mux-uploader",OVERLAY_TEXT:"overlay-text"},ut=class extends HTMLElement{constructor(){super();let e=this.attachShadow({mode:"open"});e.appendChild(Ot.content.cloneNode(!0)),this.overlayText=e.getElementById("overlay-label")}connectedCallback(){this.setupDragEvents()}attributeChangedCallback(e,s,n){e===nt.OVERLAY_TEXT&&s!==n?this.overlayText.innerHTML=n!=null?n:"":e==="active"&&this.getAttribute("overlay")&&n!=null&&(this._currentDragTarget=this)}static get observedAttributes(){return[nt.OVERLAY_TEXT,nt.MUX_UPLOADER,"active"]}get muxUploader(){let e=this.getAttribute(nt.MUX_UPLOADER);return e?document.getElementById(e):null}setupDragEvents(){this.addEventListener("dragenter",e=>{this._currentDragTarget=e.target,e.preventDefault(),e.stopPropagation(),this.setAttribute("active","")}),this.addEventListener("dragleave",e=>{this._currentDragTarget===e.target&&(this._currentDragTarget=void 0,this.removeAttribute("active"))}),this.addEventListener("dragover",e=>{e.preventDefault(),e.stopPropagation()}),this.addEventListener("drop",e=>{var y;e.preventDefault(),e.stopPropagation();let{dataTransfer:s}=e,{files:n}=s,u=n[0];((y=this.muxUploader)!=null?y:this).dispatchEvent(new CustomEvent("file-ready",{composed:!0,bubbles:!0,detail:u})),this.removeAttribute("active")})}};globalThis.customElements.get("mux-uploader-drop")||(globalThis.customElements.define("mux-uploader-drop",ut),globalThis.MuxUploaderDropElement=ut);var jt=Yt(St()),$t=` | ||
`;var nt={MUX_UPLOADER:"mux-uploader",OVERLAY_TEXT:"overlay-text"},ut=class extends HTMLElement{constructor(){super();let e=this.attachShadow({mode:"open"});e.appendChild(Ot.content.cloneNode(!0)),this.overlayText=e.getElementById("overlay-label")}connectedCallback(){this.setupDragEvents()}attributeChangedCallback(e,s,n){e===nt.OVERLAY_TEXT&&s!==n?this.overlayText.innerHTML=n!=null?n:"":e==="active"&&this.getAttribute("overlay")&&n!=null&&(this._currentDragTarget=this)}static get observedAttributes(){return[nt.OVERLAY_TEXT,nt.MUX_UPLOADER,"active"]}get muxUploader(){let e=this.getAttribute(nt.MUX_UPLOADER);return e?document.getElementById(e):null}setupDragEvents(){this.addEventListener("dragenter",e=>{this._currentDragTarget=e.target,e.preventDefault(),e.stopPropagation(),this.setAttribute("active","")}),this.addEventListener("dragleave",e=>{this._currentDragTarget===e.target&&(this._currentDragTarget=void 0,this.removeAttribute("active"))}),this.addEventListener("dragover",e=>{e.preventDefault(),e.stopPropagation()}),this.addEventListener("drop",e=>{var v;e.preventDefault(),e.stopPropagation();let{dataTransfer:s}=e,{files:n}=s,u=n[0];((v=this.muxUploader)!=null?v:this).dispatchEvent(new CustomEvent("file-ready",{composed:!0,bubbles:!0,detail:u})),this.removeAttribute("active")})}};globalThis.customElements.get("mux-uploader-drop")||(globalThis.customElements.define("mux-uploader-drop",ut),globalThis.MuxUploaderDropElement=ut);var jt=Kt(Bt()),Yt=` | ||
:host { | ||
@@ -62,5 +62,5 @@ font-family: var(--uploader-font-family, Arial); | ||
background: var(--button-background-color, #fff); | ||
border: 1px solid #000000; | ||
border: var(--button-border, 1px solid #000000); | ||
color: #000000; | ||
padding: 16px 24px; | ||
padding: var(--button-padding, 16px 24px); | ||
border-radius: var(--button-border-radius, 4px); | ||
@@ -198,5 +198,5 @@ -webkit-transition: all 0.2s ease; | ||
} | ||
`,Dt=document.createElement("template");Dt.innerHTML=` | ||
`,Ut=document.createElement("template");Ut.innerHTML=` | ||
<style> | ||
${$t} | ||
${Yt} | ||
</style> | ||
@@ -231,3 +231,3 @@ | ||
</div> | ||
`;var rt={BAR:"bar",RADIAL:"radial"},Kt=a=>`${Math.floor(a)}%`,Jt=a=>{var e;return Number((e=a.svgCircle)==null?void 0:e.getAttribute("r"))},Z=a=>Jt(a)*2*Math.PI,Qt="Media upload progress bar",It=["Enter"," "],ot=class extends HTMLElement{constructor(){super();var n,u,p,y,C,E,f,t,l,b,T;this.handleFilePickerButtonClick=this.handleFilePickerButtonClick.bind(this);let e=this.attachShadow({mode:"open"}),s=Dt.content.cloneNode(!0);e.appendChild(s),this.filePickerButton=(n=this.shadowRoot)==null?void 0:n.querySelector("slot[name=upload-button] > *"),this.svgCircle=(u=this.shadowRoot)==null?void 0:u.querySelector("circle"),this.progressBar=(p=this.shadowRoot)==null?void 0:p.getElementById("progress-bar"),this.uploadPercentage=(y=this.shadowRoot)==null?void 0:y.getElementById("upload-status"),this.statusMessage=(C=this.shadowRoot)==null?void 0:C.getElementById("status-message"),this.retryButton=(E=this.shadowRoot)==null?void 0:E.getElementById("retry-button"),this.srOnlyText=(f=this.shadowRoot)==null?void 0:f.getElementById("sr-only"),(t=this.progressBar)==null||t.setAttribute("aria-description",Qt),(l=this.hiddenFileInput)==null||l.addEventListener("change",x=>{var v,k;let w=(k=(v=this.hiddenFileInput)==null?void 0:v.files)==null?void 0:k[0];w&&this.dispatchEvent(new CustomEvent("file-ready",{composed:!0,bubbles:!0,detail:w}))}),(T=(b=this.shadowRoot)==null?void 0:b.querySelector("slot[name=upload-button]"))==null||T.addEventListener("slotchange",()=>{var x,w;this.filePickerButton=(w=(x=this.shadowRoot)==null?void 0:x.querySelector("slot[name=upload-button]"))==null?void 0:w.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 endpoint(){var e;return(e=this.getAttribute("endpoint"))!=null?e:this._endpoint}set endpoint(e){e!==this.endpoint&&(typeof e=="string"?this.setAttribute("endpoint",e):e==null&&this.removeAttribute("endpoint"),this._endpoint=e)}get formatProgress(){var e;return(e=this._formatProgress)!=null?e:Kt}set formatProgress(e){this._formatProgress=e}setDefaultType(){let e=this.getAttribute("type");e||this.setAttribute("type",rt.BAR),e===rt.RADIAL&&this.svgCircle&&(this.svgCircle.style.strokeDasharray=`${Z(this)} ${Z(this)}`,this.svgCircle.style.strokeDashoffset=`${Z(this)}`)}setupRetry(){var s;(s=this.retryButton)==null||s.addEventListener("click",()=>{this.resetState()});let e=n=>{let{key:u}=n;if(!It.includes(u)){this.removeEventListener("keyup",e);return}this.resetState()};this.addEventListener("keydown",n=>{let{metaKey:u,altKey:p,key:y}=n;if(u||p||!It.includes(y)){this.removeEventListener("keyup",e);return}this.addEventListener("keyup",e)})}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 s;switch(this.uploadPercentage&&(this.uploadPercentage.innerHTML=this.formatProgress(e)),(s=this.progressBar)==null||s.setAttribute("aria-valuenow",`${Math.floor(e)}`),this.getAttribute("type")){case rt.BAR:this.progressBar&&(this.progressBar.style.width=`${e}%`);case rt.RADIAL:if(this.svgCircle){let n=Z(this)-e/100*Z(this);this.svgCircle.style.strokeDashoffset=n.toString()}}}handleUpload(e){var u;let s=this.endpoint;if(s)this.removeAttribute("upload-error"),this.statusMessage&&(this.statusMessage.innerHTML="");else{let p="No url or endpoint specified -- cannot handleUpload";this.statusMessage&&(this.statusMessage.innerHTML=p),this.setAttribute("upload-error",""),console.error(p);return}this.setAttribute("upload-in-progress",""),(u=this.progressBar)==null||u.focus();let n=jt.createUpload({endpoint:s,file:e.detail});n.on("error",p=>{let y="An error has occurred";this.setAttribute("upload-error",""),this.statusMessage&&(this.statusMessage.innerHTML=y),console.error(p.detail.message),this.dispatchEvent(new CustomEvent("error",p))}),n.on("progress",p=>{this.setProgress(p.detail),this.dispatchEvent(new CustomEvent("progress",p))}),n.on("success",p=>{let y="Upload complete!";this.statusMessage&&(this.statusMessage.innerHTML=y),this.srOnlyText&&(this.srOnlyText.innerHTML=y),console.info(y),this.dispatchEvent(new CustomEvent("success",p))})}};globalThis.customElements.get("mux-uploader")||(globalThis.customElements.define("mux-uploader",ot),globalThis.MuxUploaderElement=ot);var ae=ot;})(); | ||
`;var rt={BAR:"bar",RADIAL:"radial"},$t=a=>`${Math.floor(a)}%`,Jt=a=>{var e;return Number((e=a.svgCircle)==null?void 0:e.getAttribute("r"))},Z=a=>Jt(a)*2*Math.PI,Qt="Media upload progress bar",Ht=["Enter"," "],ot=class extends HTMLElement{constructor(){super();var n,u,p,v,L,E,f,t,l,b,T;this.handleFilePickerButtonClick=this.handleFilePickerButtonClick.bind(this);let e=this.attachShadow({mode:"open"}),s=Ut.content.cloneNode(!0);e.appendChild(s),this.filePickerButton=(n=this.shadowRoot)==null?void 0:n.querySelector("slot[name=upload-button] > *"),this.svgCircle=(u=this.shadowRoot)==null?void 0:u.querySelector("circle"),this.progressBar=(p=this.shadowRoot)==null?void 0:p.getElementById("progress-bar"),this.uploadPercentage=(v=this.shadowRoot)==null?void 0:v.getElementById("upload-status"),this.statusMessage=(L=this.shadowRoot)==null?void 0:L.getElementById("status-message"),this.retryButton=(E=this.shadowRoot)==null?void 0:E.getElementById("retry-button"),this.srOnlyText=(f=this.shadowRoot)==null?void 0:f.getElementById("sr-only"),(t=this.progressBar)==null||t.setAttribute("aria-description",Qt),(l=this.hiddenFileInput)==null||l.addEventListener("change",x=>{var y,k;let w=(k=(y=this.hiddenFileInput)==null?void 0:y.files)==null?void 0:k[0];w&&this.dispatchEvent(new CustomEvent("file-ready",{composed:!0,bubbles:!0,detail:w}))}),(T=(b=this.shadowRoot)==null?void 0:b.querySelector("slot[name=upload-button]"))==null||T.addEventListener("slotchange",()=>{var x,w;this.filePickerButton=(w=(x=this.shadowRoot)==null?void 0:x.querySelector("slot[name=upload-button]"))==null?void 0:w.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 endpoint(){var e;return(e=this.getAttribute("endpoint"))!=null?e:this._endpoint}set endpoint(e){e!==this.endpoint&&(typeof e=="string"?this.setAttribute("endpoint",e):e==null&&this.removeAttribute("endpoint"),this._endpoint=e)}get formatProgress(){var e;return(e=this._formatProgress)!=null?e:$t}set formatProgress(e){this._formatProgress=e}setDefaultType(){let e=this.getAttribute("type");e||this.setAttribute("type",rt.BAR),e===rt.RADIAL&&this.svgCircle&&(this.svgCircle.style.strokeDasharray=`${Z(this)} ${Z(this)}`,this.svgCircle.style.strokeDashoffset=`${Z(this)}`)}setupRetry(){var s;(s=this.retryButton)==null||s.addEventListener("click",()=>{this.resetState()});let e=n=>{let{key:u}=n;if(!Ht.includes(u)){this.removeEventListener("keyup",e);return}this.resetState()};this.addEventListener("keydown",n=>{let{metaKey:u,altKey:p,key:v}=n;if(u||p||!Ht.includes(v)){this.removeEventListener("keyup",e);return}this.addEventListener("keyup",e)})}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 s;switch(this.uploadPercentage&&(this.uploadPercentage.innerHTML=this.formatProgress(e)),(s=this.progressBar)==null||s.setAttribute("aria-valuenow",`${Math.floor(e)}`),this.getAttribute("type")){case rt.BAR:this.progressBar&&(this.progressBar.style.width=`${e}%`);case rt.RADIAL:if(this.svgCircle){let n=Z(this)-e/100*Z(this);this.svgCircle.style.strokeDashoffset=n.toString()}}}handleUpload(e){var u;let s=this.endpoint;if(s)this.removeAttribute("upload-error"),this.statusMessage&&(this.statusMessage.innerHTML="");else{let p="No url or endpoint specified -- cannot handleUpload";this.statusMessage&&(this.statusMessage.innerHTML=p),this.setAttribute("upload-error",""),console.error(p);return}this.setAttribute("upload-in-progress",""),(u=this.progressBar)==null||u.focus();let n=jt.createUpload({endpoint:s,file:e.detail});this.dispatchEvent(new CustomEvent("uploadstart",{detail:n})),n.on("attempt",p=>{this.dispatchEvent(new CustomEvent("chunkattempt",p))}),n.on("chunkSuccess",p=>{this.dispatchEvent(new CustomEvent("chunksuccess",p))}),n.on("error",p=>{let v="An error has occurred";this.setAttribute("upload-error",""),this.statusMessage&&(this.statusMessage.innerHTML=v),console.error(p.detail.message),this.dispatchEvent(new CustomEvent("error",p))}),n.on("progress",p=>{this.setProgress(p.detail),this.dispatchEvent(new CustomEvent("progress",p))}),n.on("success",p=>{let v="Upload complete!";this.statusMessage&&(this.statusMessage.innerHTML=v),this.srOnlyText&&(this.srOnlyText.innerHTML=v),console.info(v),this.dispatchEvent(new CustomEvent("success",p))})}};globalThis.customElements.get("mux-uploader")||(globalThis.customElements.define("mux-uploader",ot),globalThis.MuxUploaderElement=ot);var ae=ot;})(); | ||
//# sourceMappingURL=mux-uploader.js.map |
@@ -5,3 +5,17 @@ import '@mux/polyfills'; | ||
declare type Endpoint = UpChunk.UpChunk['endpoint'] | undefined | null; | ||
declare class MuxUploaderElement extends HTMLElement { | ||
export interface MuxUploaderElementEventMap extends Pick<HTMLElementEventMap, Exclude<keyof HTMLElementEventMap, 'error' | 'progress'>> { | ||
uploadstart: CustomEvent<UpChunk.UpChunk>; | ||
chunkattempt: CustomEvent; | ||
chunksuccess: CustomEvent; | ||
error: CustomEvent; | ||
progress: CustomEvent; | ||
success: CustomEvent; | ||
} | ||
interface MuxUploaderElement extends HTMLElement { | ||
addEventListener<K extends keyof MuxUploaderElementEventMap>(type: K, listener: (this: HTMLMediaElement, ev: MuxUploaderElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; | ||
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; | ||
removeEventListener<K extends keyof MuxUploaderElementEventMap>(type: K, listener: (this: HTMLMediaElement, ev: MuxUploaderElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; | ||
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; | ||
} | ||
declare class MuxUploaderElement extends HTMLElement implements MuxUploaderElement { | ||
protected _formatProgress: ((percent: number) => string) | null | undefined; | ||
@@ -8,0 +22,0 @@ protected _filePickerButton: HTMLElement | null | undefined; |
@@ -5,3 +5,17 @@ import '@mux/polyfills'; | ||
declare type Endpoint = UpChunk.UpChunk['endpoint'] | undefined | null; | ||
declare class MuxUploaderElement extends HTMLElement { | ||
export interface MuxUploaderElementEventMap extends Omit<HTMLElementEventMap, 'error' | 'progress'> { | ||
uploadstart: CustomEvent<UpChunk.UpChunk>; | ||
chunkattempt: CustomEvent; | ||
chunksuccess: CustomEvent; | ||
error: CustomEvent; | ||
progress: CustomEvent; | ||
success: CustomEvent; | ||
} | ||
interface MuxUploaderElement extends HTMLElement { | ||
addEventListener<K extends keyof MuxUploaderElementEventMap>(type: K, listener: (this: HTMLMediaElement, ev: MuxUploaderElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; | ||
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; | ||
removeEventListener<K extends keyof MuxUploaderElementEventMap>(type: K, listener: (this: HTMLMediaElement, ev: MuxUploaderElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; | ||
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; | ||
} | ||
declare class MuxUploaderElement extends HTMLElement implements MuxUploaderElement { | ||
protected _formatProgress: ((percent: number) => string) | null | undefined; | ||
@@ -8,0 +22,0 @@ protected _filePickerButton: HTMLElement | null | undefined; |
{ | ||
"name": "@mux/mux-uploader", | ||
"version": "0.1.0-beta.4", | ||
"version": "0.1.0-beta.5", | ||
"description": "An uploader elements to be used with Mux Direct Uploads", | ||
@@ -64,3 +64,3 @@ "main": "./dist/index.cjs", | ||
}, | ||
"gitHead": "2d61f80adc7037225c22e2ac87519881677702d3" | ||
"gitHead": "4ef4afea4e82bf3558225d105dbab0cbff6aa6ce" | ||
} |
@@ -100,10 +100,10 @@ <p align="center"> | ||
| 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 `mux-uploader-drop` to locate `mux-uploader`. Required if you use `mux-uploader-drop`. | N/A | | ||
| `type` | `"bar"` | Specifies the visual type of progress bar. A radial type is in-progress. | "bar" | | ||
| `upload-in-progress` | `boolean` | (Read-only) Toggles visual status of progress bar while upload is in progress. Can be targeted with CSS if you want to control styles while in progress i.e. mux-uploader[upload-in-progress]. | false | | ||
| `upload-error` | `boolean` | (Read-only) Toggles visual status of progress bar when upload encounters an error. Can be targeted with CSS if you want to control styles when an error occurs i.e. mux-uploader[upload-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 | | ||
| Attribute | Type | Description | Default | | ||
| -------------------- | ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------- | | ||
| `endpoint` | `string \| Promise` | Either a) the authenticated URL that your file will be uploaded to or b) an async function that yields a promise that resolves to that url. Check out the [direct uploads docs](https://docs.mux.com/guides/video/upload-files-directly#1-create-an-authenticated-mux-url). Required. | `undefined` | | ||
| `id` | `string` | An ID that allows `mux-uploader-drop` to locate `mux-uploader`. Required if you use `mux-uploader-drop`. | N/A | | ||
| `type` | `"bar"` | Specifies the visual type of progress bar. A radial type is in-progress. | "bar" | | ||
| `upload-in-progress` | `boolean` | (Read-only) Toggles visual status of progress bar while upload is in progress. Can be targeted with CSS if you want to control styles while in progress i.e. mux-uploader[upload-in-progress]. | false | | ||
| `upload-error` | `boolean` | (Read-only) Toggles visual status of progress bar when upload encounters an error. Can be targeted with CSS if you want to control styles when an error occurs i.e. mux-uploader[upload-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 | | ||
@@ -115,3 +115,3 @@ #### `<mux-uploader-drop>` | ||
| `overlay` | `boolean` | Toggles showing an overlay on dragover. | `false` | | ||
| `overlay-text` | `boolean` | Optional text to display on dragover when `overlay` is on. | `''` | | ||
| `overlay-text` | `string` | Optional text to display on dragover when `overlay` is on. | `''` | | ||
| `mux-uploader` | `string ` | Must match the `id` on `MuxUploader`. Required. | N/A | | ||
@@ -123,5 +123,5 @@ | ||
| Attribute | Type | Description | Default | | ||
| ---------------- | ---------- | --------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------- | | ||
| `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 | | ||
| Property | Type | Description | Default | | ||
| ---------------- | ---------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------- | | ||
| `formatProgress` | `function` | A function that accepts numeric percent and is expected to return a string. Allows for customizing how the progress should be rendered - whether you want to display only the number or a sentence with the number etc. i.e. `formatProgress={(percent: number) => `${percent} percent uploaded`}` | A function that yields only the percent as a string i.e. `"60%"` | | ||
@@ -132,9 +132,12 @@ ### Events | ||
`<mux-uploader>` has a handful of events to monitor uploading state. | ||
`<mux-uploader>` has a handful of events - using [Upchunk](https://github.com/muxinc/upchunk/blob/master/README.md) under the hood - to monitor uploading state. | ||
| Event | Description | | ||
| ---------- | ------------------------------------------------------------------------ | | ||
| `error` | Fired when an error occurs in the chunked upload process. | | ||
| `progress` | Fired whenever a chunk of the file has successfully completed uploading. | | ||
| `success` | Fired when the entire file has successfully completed uploading. | | ||
| Event | Description | | ||
| -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | ||
| `uploadstart` | Fired when the upload begins. | | ||
| `chunkattempt` | Fired immediately before a chunk upload is attempted. | | ||
| `chunksuccess` | Fired when an indvidual chunk is successfully uploaded. Sample response: `{ detail: { chunk: Integer, attempts: Integer, response: XhrResponse } }` | | ||
| `error` | Fired when an error occurs in the chunked upload process. | | ||
| `progress` | Fired continuously with incremental upload progress. This returns the current percentage of the file that's been uploaded. Sample response: `{ detail: [0..100] }` | | ||
| `success` | Fired when the entire file has successfully completed uploading. | | ||
@@ -147,15 +150,17 @@ ### Styling | ||
| Name | CSS Property | Default Value | Description | Notes | | ||
| ------------------------------ | ------------------ | ------------- | ------------------------------------------------------- | ------------------------------------------------------------------------------------------------- | | ||
| `--uploader-font-family` | `font-family` | `Arial` | font family of the component | Applies to other elements as well: upload status and error status | | ||
| `--uploader-font-size` | `font-size` | `16px` | font size for text within the component | Also applies to `<mux-uploader-drop>` i.e. overlay text | | ||
| `--uploader-background-color` | `background-color` | `inherit` | background color of area surrounding the upload | | | ||
| `--button-background-color` | `background` | `#fff` | background color of upload button | | | ||
| `--button-border-radius` | `border-radius` | `4px` | border ardius of the upload button | | | ||
| `--button-hover-text` | `color` | `#fff` | text color of upload button on button hover | | | ||
| `--button-hover-background` | `background` | `#404040` | background color of upload button on button hover | | | ||
| `--button-active-text` | `color` | `#fff` | color of upload button text when button is active | | | ||
| `--button-active-background` | `background` | `#000000` | background color of upload button when button is active | Applied via `:active` [pseudo selector](https://developer.mozilla.org/en-US/docs/Web/CSS/:active) | | ||
| `--progress-bar-fill-color` | `background` | `#000000` | background color for progress bar div | | | ||
| `--progress-radial-fill-color` | `stroke` | `black` | stroke color for circle SVG (wip) | | | ||
| Name | CSS Property | Default Value | Description | Notes | | ||
| ------------------------------ | ------------------ | ------------------- | ------------------------------------------------------- | ------------------------------------------------------------------------------------------------- | | ||
| `--uploader-font-family` | `font-family` | `Arial` | font family of the component | Applies to other elements as well: upload status and error status | | ||
| `--uploader-font-size` | `font-size` | `16px` | font size for text within the component | Also applies to `<mux-uploader-drop>` i.e. overlay text | | ||
| `--uploader-background-color` | `background-color` | `inherit` | background color of area surrounding the upload | | | ||
| `--button-background-color` | `background` | `#fff` | background color of upload button | | | ||
| `--button-border-radius` | `border-radius` | `4px` | border radius of the upload button | | | ||
| `--button-border` | `border` | `1px solid #000000` | border of the upload button | | | ||
| `--button-padding` | `padding` | `16px 24px` | padding of the upload button | | | ||
| `--button-hover-text` | `color` | `#fff` | text color of upload button on button hover | | | ||
| `--button-hover-background` | `background` | `#404040` | background color of upload button on button hover | | | ||
| `--button-active-text` | `color` | `#fff` | color of upload button text when button is active | | | ||
| `--button-active-background` | `background` | `#000000` | background color of upload button when button is active | Applied via `:active` [pseudo selector](https://developer.mozilla.org/en-US/docs/Web/CSS/:active) | | ||
| `--progress-bar-fill-color` | `background` | `#000000` | background color for progress bar div | | | ||
| `--progress-radial-fill-color` | `stroke` | `black` | stroke color for circle SVG (wip) | | | ||
@@ -162,0 +167,0 @@ - `<mux-uploader-drop/>` |
@@ -35,5 +35,5 @@ import '@mux/polyfills'; | ||
background: var(--button-background-color, #fff); | ||
border: 1px solid #000000; | ||
border: var(--button-border, 1px solid #000000); | ||
color: #000000; | ||
padding: 16px 24px; | ||
padding: var(--button-padding, 16px 24px); | ||
border-radius: var(--button-border-radius, 4px); | ||
@@ -227,3 +227,36 @@ -webkit-transition: all 0.2s ease; | ||
class MuxUploaderElement extends HTMLElement { | ||
// NOTE: error and progress events are already determined on HTMLElement but have inconsistent types. Should consider renaming events (CJP) | ||
export interface MuxUploaderElementEventMap extends Omit<HTMLElementEventMap, 'error' | 'progress'> { | ||
uploadstart: CustomEvent<UpChunk.UpChunk>; | ||
chunkattempt: CustomEvent; | ||
chunksuccess: CustomEvent; | ||
error: CustomEvent; | ||
progress: CustomEvent; | ||
success: CustomEvent; | ||
} | ||
interface MuxUploaderElement extends HTMLElement { | ||
addEventListener<K extends keyof MuxUploaderElementEventMap>( | ||
type: K, | ||
listener: (this: HTMLMediaElement, ev: MuxUploaderElementEventMap[K]) => any, | ||
options?: boolean | AddEventListenerOptions | ||
): void; | ||
addEventListener( | ||
type: string, | ||
listener: EventListenerOrEventListenerObject, | ||
options?: boolean | AddEventListenerOptions | ||
): void; | ||
removeEventListener<K extends keyof MuxUploaderElementEventMap>( | ||
type: K, | ||
listener: (this: HTMLMediaElement, ev: MuxUploaderElementEventMap[K]) => any, | ||
options?: boolean | EventListenerOptions | ||
): void; | ||
removeEventListener( | ||
type: string, | ||
listener: EventListenerOrEventListenerObject, | ||
options?: boolean | EventListenerOptions | ||
): void; | ||
} | ||
class MuxUploaderElement extends HTMLElement implements MuxUploaderElement { | ||
protected _formatProgress: ((percent: number) => string) | null | undefined; | ||
@@ -448,3 +481,13 @@ protected _filePickerButton: HTMLElement | null | undefined; | ||
upload.on('error', (err) => { | ||
this.dispatchEvent(new CustomEvent('uploadstart', { detail: upload })); | ||
upload.on('attempt', (event) => { | ||
this.dispatchEvent(new CustomEvent('chunkattempt', event)); | ||
}); | ||
upload.on('chunkSuccess', (event) => { | ||
this.dispatchEvent(new CustomEvent('chunksuccess', event)); | ||
}); | ||
upload.on('error', (event) => { | ||
const errorMessage = 'An error has occurred'; | ||
@@ -458,9 +501,9 @@ | ||
console.error(err.detail.message); | ||
this.dispatchEvent(new CustomEvent('error', err)); | ||
console.error(event.detail.message); | ||
this.dispatchEvent(new CustomEvent('error', event)); | ||
}); | ||
upload.on('progress', (progress) => { | ||
this.setProgress(progress.detail); | ||
this.dispatchEvent(new CustomEvent('progress', progress)); | ||
upload.on('progress', (event) => { | ||
this.setProgress(event.detail); | ||
this.dispatchEvent(new CustomEvent('progress', event)); | ||
}); | ||
@@ -467,0 +510,0 @@ |
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
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
Sorry, the diff of this file is not supported yet
489030
2318
167