2 lines
64 KiB
JavaScript
Executable File
2 lines
64 KiB
JavaScript
Executable File
var Kt=Object.create;var Ve=Object.defineProperty;var Zt=Object.getOwnPropertyDescriptor;var $t=Object.getOwnPropertyNames;var Vt=Object.getPrototypeOf,Xt=Object.prototype.hasOwnProperty;var Qt=(r,e,t)=>e in r?Ve(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var Yt=(r=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(r,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):r)(function(r){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+r+'" is not supported')});var Jr=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),en=(r,e)=>{for(var t in e)Ve(r,t,{get:e[t],enumerable:!0})},rn=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of $t(e))!Xt.call(r,i)&&i!==t&&Ve(r,i,{get:()=>e[i],enumerable:!(n=Zt(e,i))||n.enumerable});return r};var wr=(r,e,t)=>(t=r!=null?Kt(Vt(r)):{},rn(e||!r||!r.__esModule?Ve(t,"default",{value:r,enumerable:!0}):t,r));var d=(r,e,t)=>Qt(r,typeof e!="symbol"?e+"":e,t);var Ar=Jr((Yn,Er)=>{"use strict";var Oe=typeof Reflect=="object"?Reflect:null,Gr=Oe&&typeof Oe.apply=="function"?Oe.apply:function(e,t,n){return Function.prototype.apply.call(e,t,n)},Xe;Oe&&typeof Oe.ownKeys=="function"?Xe=Oe.ownKeys:Object.getOwnPropertySymbols?Xe=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Xe=function(e){return Object.getOwnPropertyNames(e)};function tn(r){console&&console.warn&&console.warn(r)}var Hr=Number.isNaN||function(e){return e!==e};function I(){I.init.call(this)}Er.exports=I;Er.exports.once=an;I.EventEmitter=I;I.prototype._events=void 0;I.prototype._eventsCount=0;I.prototype._maxListeners=void 0;var Wr=10;function Qe(r){if(typeof r!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof r)}Object.defineProperty(I,"defaultMaxListeners",{enumerable:!0,get:function(){return Wr},set:function(r){if(typeof r!="number"||r<0||Hr(r))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+r+".");Wr=r}});I.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};I.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||Hr(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this};function qr(r){return r._maxListeners===void 0?I.defaultMaxListeners:r._maxListeners}I.prototype.getMaxListeners=function(){return qr(this)};I.prototype.emit=function(e){for(var t=[],n=1;n<arguments.length;n++)t.push(arguments[n]);var i=e==="error",o=this._events;if(o!==void 0)i=i&&o.error===void 0;else if(!i)return!1;if(i){var s;if(t.length>0&&(s=t[0]),s instanceof Error)throw s;var a=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw a.context=s,a}var f=o[e];if(f===void 0)return!1;if(typeof f=="function")Gr(f,this,t);else for(var c=f.length,h=Xr(f,c),n=0;n<c;++n)Gr(h[n],this,t);return!0};function Kr(r,e,t,n){var i,o,s;if(Qe(t),o=r._events,o===void 0?(o=r._events=Object.create(null),r._eventsCount=0):(o.newListener!==void 0&&(r.emit("newListener",e,t.listener?t.listener:t),o=r._events),s=o[e]),s===void 0)s=o[e]=t,++r._eventsCount;else if(typeof s=="function"?s=o[e]=n?[t,s]:[s,t]:n?s.unshift(t):s.push(t),i=qr(r),i>0&&s.length>i&&!s.warned){s.warned=!0;var a=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");a.name="MaxListenersExceededWarning",a.emitter=r,a.type=e,a.count=s.length,tn(a)}return r}I.prototype.addListener=function(e,t){return Kr(this,e,t,!1)};I.prototype.on=I.prototype.addListener;I.prototype.prependListener=function(e,t){return Kr(this,e,t,!0)};function nn(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function Zr(r,e,t){var n={fired:!1,wrapFn:void 0,target:r,type:e,listener:t},i=nn.bind(n);return i.listener=t,n.wrapFn=i,i}I.prototype.once=function(e,t){return Qe(t),this.on(e,Zr(this,e,t)),this};I.prototype.prependOnceListener=function(e,t){return Qe(t),this.prependListener(e,Zr(this,e,t)),this};I.prototype.removeListener=function(e,t){var n,i,o,s,a;if(Qe(t),i=this._events,i===void 0)return this;if(n=i[e],n===void 0)return this;if(n===t||n.listener===t)--this._eventsCount===0?this._events=Object.create(null):(delete i[e],i.removeListener&&this.emit("removeListener",e,n.listener||t));else if(typeof n!="function"){for(o=-1,s=n.length-1;s>=0;s--)if(n[s]===t||n[s].listener===t){a=n[s].listener,o=s;break}if(o<0)return this;o===0?n.shift():on(n,o),n.length===1&&(i[e]=n[0]),i.removeListener!==void 0&&this.emit("removeListener",e,a||t)}return this};I.prototype.off=I.prototype.removeListener;I.prototype.removeAllListeners=function(e){var t,n,i;if(n=this._events,n===void 0)return this;if(n.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):n[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete n[e]),this;if(arguments.length===0){var o=Object.keys(n),s;for(i=0;i<o.length;++i)s=o[i],s!=="removeListener"&&this.removeAllListeners(s);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(t=n[e],typeof t=="function")this.removeListener(e,t);else if(t!==void 0)for(i=t.length-1;i>=0;i--)this.removeListener(e,t[i]);return this};function $r(r,e,t){var n=r._events;if(n===void 0)return[];var i=n[e];return i===void 0?[]:typeof i=="function"?t?[i.listener||i]:[i]:t?sn(i):Xr(i,i.length)}I.prototype.listeners=function(e){return $r(this,e,!0)};I.prototype.rawListeners=function(e){return $r(this,e,!1)};I.listenerCount=function(r,e){return typeof r.listenerCount=="function"?r.listenerCount(e):Vr.call(r,e)};I.prototype.listenerCount=Vr;function Vr(r){var e=this._events;if(e!==void 0){var t=e[r];if(typeof t=="function")return 1;if(t!==void 0)return t.length}return 0}I.prototype.eventNames=function(){return this._eventsCount>0?Xe(this._events):[]};function Xr(r,e){for(var t=new Array(e),n=0;n<e;++n)t[n]=r[n];return t}function on(r,e){for(;e+1<r.length;e++)r[e]=r[e+1];r.pop()}function sn(r){for(var e=new Array(r.length),t=0;t<e.length;++t)e[t]=r[t].listener||r[t];return e}function an(r,e){return new Promise(function(t,n){function i(s){r.removeListener(e,o),n(s)}function o(){typeof r.removeListener=="function"&&r.removeListener("error",i),t([].slice.call(arguments))}Qr(r,e,o,{once:!0}),e!=="error"&&un(r,i,{once:!0})})}function un(r,e,t){typeof r.on=="function"&&Qr(r,"error",e,t)}function Qr(r,e,t,n){if(typeof r.on=="function")n.once?r.once(e,t):r.on(e,t);else if(typeof r.addEventListener=="function")r.addEventListener(e,function i(o){n.once&&r.removeEventListener(e,i),t(o)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof r)}});var pt=Jr((Gi,Re)=>{"use strict";var u={cipher:{},hash:{},keyexchange:{},mode:{},misc:{},codec:{},exception:{corrupt:function(r){this.toString=function(){return"CORRUPT: "+this.message},this.message=r},invalid:function(r){this.toString=function(){return"INVALID: "+this.message},this.message=r},bug:function(r){this.toString=function(){return"BUG: "+this.message},this.message=r},notReady:function(r){this.toString=function(){return"NOT READY: "+this.message},this.message=r}}};u.cipher.aes=function(r){this.w[0][0][0]||this.C();var e,t,n,i,o=this.w[0][4],s=this.w[1];e=r.length;var a=1;if(e!==4&&e!==6&&e!==8)throw new u.exception.invalid("invalid aes key size");for(this.b=[n=r.slice(0),i=[]],r=e;r<4*e+28;r++)t=n[r-1],(r%e===0||e===8&&r%e===4)&&(t=o[t>>>24]<<24^o[t>>16&255]<<16^o[t>>8&255]<<8^o[t&255],r%e===0&&(t=t<<8^t>>>24^a<<24,a=a<<1^283*(a>>7))),n[r]=n[r-e]^t;for(e=0;r;e++,r--)t=n[e&3?r:r-4],i[e]=4>=r||4>e?t:s[0][o[t>>>24]]^s[1][o[t>>16&255]]^s[2][o[t>>8&255]]^s[3][o[t&255]]};u.cipher.aes.prototype={encrypt:function(r){return ct(this,r,0)},decrypt:function(r){return ct(this,r,1)},w:[[[],[],[],[],[]],[[],[],[],[],[]]],C:function(){var r=this.w[0],e=this.w[1],t=r[4],n=e[4],i,o,s,a=[],f=[],c,h,l,p;for(i=0;256>i;i++)f[(a[i]=i<<1^283*(i>>7))^i]=i;for(o=s=0;!t[o];o^=c||1,s=f[s]||1)for(l=s^s<<1^s<<2^s<<3^s<<4,l=l>>8^l&255^99,t[o]=l,n[l]=o,h=a[i=a[c=a[o]]],p=16843009*h^65537*i^257*c^16843008*o,h=257*a[l]^16843008*l,i=0;4>i;i++)r[i][o]=h=h<<24^h>>>8,e[i][l]=p=p<<24^p>>>8;for(i=0;5>i;i++)r[i]=r[i].slice(0),e[i]=e[i].slice(0)}};function ct(r,e,t){if(e.length!==4)throw new u.exception.invalid("invalid aes block size");var n=r.b[t],i=e[0]^n[0],o=e[t?3:1]^n[1],s=e[2]^n[2];e=e[t?1:3]^n[3];var a,f,c,h=n.length/4-2,l,p=4,v=[0,0,0,0];a=r.w[t],r=a[0];var A=a[1],g=a[2],y=a[3],D=a[4];for(l=0;l<h;l++)a=r[i>>>24]^A[o>>16&255]^g[s>>8&255]^y[e&255]^n[p],f=r[o>>>24]^A[s>>16&255]^g[e>>8&255]^y[i&255]^n[p+1],c=r[s>>>24]^A[e>>16&255]^g[i>>8&255]^y[o&255]^n[p+2],e=r[e>>>24]^A[i>>16&255]^g[o>>8&255]^y[s&255]^n[p+3],p+=4,i=a,o=f,s=c;for(l=0;4>l;l++)v[t?3&-l:l]=D[i>>>24]<<24^D[o>>16&255]<<16^D[s>>8&255]<<8^D[e&255]^n[p++],a=i,i=o,o=s,s=e,e=a;return v}u.bitArray={bitSlice:function(r,e,t){return r=u.bitArray.Y(r.slice(e/32),32-(e&31)).slice(1),t===void 0?r:u.bitArray.clamp(r,t-e)},extract:function(r,e,t){var n=Math.floor(-e-t&31);return((e+t-1^e)&-32?r[e/32|0]<<32-n^r[e/32+1|0]>>>n:r[e/32|0]>>>n)&(1<<t)-1},concat:function(r,e){if(r.length===0||e.length===0)return r.concat(e);var t=r[r.length-1],n=u.bitArray.getPartial(t);return n===32?r.concat(e):u.bitArray.Y(e,n,t|0,r.slice(0,r.length-1))},bitLength:function(r){var e=r.length;return e===0?0:32*(e-1)+u.bitArray.getPartial(r[e-1])},clamp:function(r,e){if(32*r.length<e)return r;r=r.slice(0,Math.ceil(e/32));var t=r.length;return e=e&31,0<t&&e&&(r[t-1]=u.bitArray.partial(e,r[t-1]&2147483648>>e-1,1)),r},partial:function(r,e,t){return r===32?e:(t?e|0:e<<32-r)+1099511627776*r},getPartial:function(r){return Math.round(r/1099511627776)||32},equal:function(r,e){if(u.bitArray.bitLength(r)!==u.bitArray.bitLength(e))return!1;var t=0,n;for(n=0;n<r.length;n++)t|=r[n]^e[n];return t===0},Y:function(r,e,t,n){var i;for(i=0,n===void 0&&(n=[]);32<=e;e-=32)n.push(t),t=0;if(e===0)return n.concat(r);for(i=0;i<r.length;i++)n.push(t|r[i]>>>e),t=r[i]<<32-e;return i=r.length?r[r.length-1]:0,r=u.bitArray.getPartial(i),n.push(u.bitArray.partial(e+r&31,32<e+r?t:n.pop(),1)),n},P:function(r,e){return[r[0]^e[0],r[1]^e[1],r[2]^e[2],r[3]^e[3]]},byteswapM:function(r){var e,t;for(e=0;e<r.length;++e)t=r[e],r[e]=t>>>24|t>>>8&65280|(t&65280)<<8|t<<24;return r}};u.codec.utf8String={fromBits:function(r){var e="",t=u.bitArray.bitLength(r),n,i;for(n=0;n<t/8;n++)!(n&3)&&(i=r[n/4]),e+=String.fromCharCode(i>>>8>>>8>>>8),i<<=8;return decodeURIComponent(escape(e))},toBits:function(r){r=unescape(encodeURIComponent(r));var e=[],t,n=0;for(t=0;t<r.length;t++)n=n<<8|r.charCodeAt(t),(t&3)===3&&(e.push(n),n=0);return t&3&&e.push(u.bitArray.partial(8*(t&3),n)),e}};u.codec.hex={fromBits:function(r){var e="",t;for(t=0;t<r.length;t++)e+=((r[t]|0)+0xf00000000000).toString(16).substr(4);return e.substr(0,u.bitArray.bitLength(r)/4)},toBits:function(r){var e,t=[],n;for(r=r.replace(/\s|0x/g,""),n=r.length,r=r+"00000000",e=0;e<r.length;e+=8)t.push(parseInt(r.substr(e,8),16)^0);return u.bitArray.clamp(t,4*n)}};u.codec.base64={S:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",fromBits:function(r,e,t){var n="",i=0,o=u.codec.base64.S,s=0,a=u.bitArray.bitLength(r);for(t&&(o=o.substr(0,62)+"-_"),t=0;6*n.length<a;)n+=o.charAt((s^r[t]>>>i)>>>26),6>i?(s=r[t]<<6-i,i+=26,t++):(s<<=6,i-=6);for(;n.length&3&&!e;)n+="=";return n},toBits:function(r,e){r=r.replace(/\s|=/g,"");var t=[],n,i=0,o=u.codec.base64.S,s=0,a;for(e&&(o=o.substr(0,62)+"-_"),n=0;n<r.length;n++){if(a=o.indexOf(r.charAt(n)),0>a)throw new u.exception.invalid("this isn't base64!");26<i?(i-=26,t.push(s^a>>>i),s=a<<32-i):(i+=6,s^=a<<32-i)}return i&56&&t.push(u.bitArray.partial(i&56,s,1)),t}};u.codec.base64url={fromBits:function(r){return u.codec.base64.fromBits(r,1,1)},toBits:function(r){return u.codec.base64.toBits(r,1)}};u.hash.sha256=function(r){this.b[0]||this.C(),r?(this.g=r.g.slice(0),this.f=r.f.slice(0),this.c=r.c):this.reset()};u.hash.sha256.hash=function(r){return new u.hash.sha256().update(r).finalize()};u.hash.sha256.prototype={blockSize:512,reset:function(){return this.g=this.o.slice(0),this.f=[],this.c=0,this},update:function(r){typeof r=="string"&&(r=u.codec.utf8String.toBits(r));var e,t=this.f=u.bitArray.concat(this.f,r);if(e=this.c,r=this.c=e+u.bitArray.bitLength(r),9007199254740991<r)throw new u.exception.invalid("Cannot hash more than 2^53 - 1 bits");if(typeof Uint32Array<"u"){var n=new Uint32Array(t),i=0;for(e=512+e-(512+e&511);e<=r;e+=512)this.l(n.subarray(16*i,16*(i+1))),i+=1;t.splice(0,16*i)}else for(e=512+e-(512+e&511);e<=r;e+=512)this.l(t.splice(0,16));return this},finalize:function(){var r,t=this.f,e=this.g,t=u.bitArray.concat(t,[u.bitArray.partial(1,1)]);for(r=t.length+2;r&15;r++)t.push(0);for(t.push(Math.floor(this.c/4294967296)),t.push(this.c|0);t.length;)this.l(t.splice(0,16));return this.reset(),e},o:[],b:[],C:function(){function r(o){return 4294967296*(o-Math.floor(o))|0}for(var e=0,t=2,n,i;64>e;t++){for(i=!0,n=2;n*n<=t;n++)if(t%n===0){i=!1;break}i&&(8>e&&(this.o[e]=r(Math.pow(t,.5))),this.b[e]=r(Math.pow(t,1/3)),e++)}},l:function(r){var e,t,n,i=this.g,o=this.b,s=i[0],a=i[1],f=i[2],c=i[3],h=i[4],l=i[5],p=i[6],v=i[7];for(e=0;64>e;e++)16>e?t=r[e]:(t=r[e+1&15],n=r[e+14&15],t=r[e&15]=(t>>>7^t>>>18^t>>>3^t<<25^t<<14)+(n>>>17^n>>>19^n>>>10^n<<15^n<<13)+r[e&15]+r[e+9&15]|0),t=t+v+(h>>>6^h>>>11^h>>>25^h<<26^h<<21^h<<7)+(p^h&(l^p))+o[e],v=p,p=l,l=h,h=c+t|0,c=f,f=a,a=s,s=t+(a&f^c&(a^f))+(a>>>2^a>>>13^a>>>22^a<<30^a<<19^a<<10)|0;i[0]=i[0]+s|0,i[1]=i[1]+a|0,i[2]=i[2]+f|0,i[3]=i[3]+c|0,i[4]=i[4]+h|0,i[5]=i[5]+l|0,i[6]=i[6]+p|0,i[7]=i[7]+v|0}};u.hash.sha512=function(r){this.b[0]||this.C(),r?(this.g=r.g.slice(0),this.f=r.f.slice(0),this.c=r.c):this.reset()};u.hash.sha512.hash=function(r){return new u.hash.sha512().update(r).finalize()};u.hash.sha512.prototype={blockSize:1024,reset:function(){return this.g=this.o.slice(0),this.f=[],this.c=0,this},update:function(r){typeof r=="string"&&(r=u.codec.utf8String.toBits(r));var e,t=this.f=u.bitArray.concat(this.f,r);if(e=this.c,r=this.c=e+u.bitArray.bitLength(r),9007199254740991<r)throw new u.exception.invalid("Cannot hash more than 2^53 - 1 bits");if(typeof Uint32Array<"u"){var n=new Uint32Array(t),i=0;for(e=1024+e-(1024+e&1023);e<=r;e+=1024)this.l(n.subarray(32*i,32*(i+1))),i+=1;t.splice(0,32*i)}else for(e=1024+e-(1024+e&1023);e<=r;e+=1024)this.l(t.splice(0,32));return this},finalize:function(){var r,t=this.f,e=this.g,t=u.bitArray.concat(t,[u.bitArray.partial(1,1)]);for(r=t.length+4;r&31;r++)t.push(0);for(t.push(0),t.push(0),t.push(Math.floor(this.c/4294967296)),t.push(this.c|0);t.length;)this.l(t.splice(0,32));return this.reset(),e},o:[],ia:[12372232,13281083,9762859,1914609,15106769,4090911,4308331,8266105],b:[],ka:[2666018,15689165,5061423,9034684,4764984,380953,1658779,7176472,197186,7368638,14987916,16757986,8096111,1480369,13046325,6891156,15813330,5187043,9229749,11312229,2818677,10937475,4324308,1135541,6741931,11809296,16458047,15666916,11046850,698149,229999,945776,13774844,2541862,12856045,9810911,11494366,7844520,15576806,8533307,15795044,4337665,16291729,5553712,15684120,6662416,7413802,12308920,13816008,4303699,9366425,10176680,13195875,4295371,6546291,11712675,15708924,1519456,15772530,6568428,6495784,8568297,13007125,7492395,2515356,12632583,14740254,7262584,1535930,13146278,16321966,1853211,294276,13051027,13221564,1051980,4080310,6651434,14088940,4675607],C:function(){function r(s){return 4294967296*(s-Math.floor(s))|0}function e(s){return 1099511627776*(s-Math.floor(s))&255}for(var t=0,n=2,i,o;80>t;n++){for(o=!0,i=2;i*i<=n;i++)if(n%i===0){o=!1;break}o&&(8>t&&(this.o[2*t]=r(Math.pow(n,.5)),this.o[2*t+1]=e(Math.pow(n,.5))<<24|this.ia[t]),this.b[2*t]=r(Math.pow(n,1/3)),this.b[2*t+1]=e(Math.pow(n,1/3))<<24|this.ka[t],t++)}},l:function(r){var e,t,n=this.g,i=this.b,o=n[0],s=n[1],a=n[2],f=n[3],c=n[4],h=n[5],l=n[6],p=n[7],v=n[8],A=n[9],g=n[10],y=n[11],D=n[12],U=n[13],O=n[14],E=n[15],x;if(typeof Uint32Array<"u"){x=Array(160);for(var L=0;32>L;L++)x[L]=r[L]}else x=r;var L=o,b=s,w=a,m=f,S=c,C=h,z=l,V=p,P=v,k=A,_=g,R=y,q=D,G=U,de=O,Z=E;for(r=0;80>r;r++){if(16>r)e=x[2*r],t=x[2*r+1];else{t=x[2*(r-15)];var F=x[2*(r-15)+1];e=(F<<31|t>>>1)^(F<<24|t>>>8)^t>>>7;var X=(t<<31|F>>>1)^(t<<24|F>>>8)^(t<<25|F>>>7);t=x[2*(r-2)];var j=x[2*(r-2)+1],F=(j<<13|t>>>19)^(t<<3|j>>>29)^t>>>6,j=(t<<13|j>>>19)^(j<<3|t>>>29)^(t<<26|j>>>6),te=x[2*(r-7)],re=x[2*(r-16)],ne=x[2*(r-16)+1];t=X+x[2*(r-7)+1],e=e+te+(t>>>0<X>>>0?1:0),t+=j,e+=F+(t>>>0<j>>>0?1:0),t+=ne,e+=re+(t>>>0<ne>>>0?1:0)}x[2*r]=e|=0,x[2*r+1]=t|=0;var te=P&_^~P&q,Y=k&R^~k&G,j=L&w^L&S^w&S,N=b&m^b&C^m&C,re=(b<<4|L>>>28)^(L<<30|b>>>2)^(L<<25|b>>>7),ne=(L<<4|b>>>28)^(b<<30|L>>>2)^(b<<25|L>>>7),we=i[2*r],xe=i[2*r+1],F=Z+((P<<18|k>>>14)^(P<<14|k>>>18)^(k<<23|P>>>9)),X=de+((k<<18|P>>>14)^(k<<14|P>>>18)^(P<<23|k>>>9))+(F>>>0<Z>>>0?1:0),F=F+Y,X=X+(te+(F>>>0<Y>>>0?1:0)),F=F+xe,X=X+(we+(F>>>0<xe>>>0?1:0)),F=F+t|0,X=X+(e+(F>>>0<t>>>0?1:0));t=ne+N,e=re+j+(t>>>0<ne>>>0?1:0),de=q,Z=G,q=_,G=R,_=P,R=k,k=V+F|0,P=z+X+(k>>>0<V>>>0?1:0)|0,z=S,V=C,S=w,C=m,w=L,m=b,b=F+t|0,L=X+e+(b>>>0<F>>>0?1:0)|0}s=n[1]=s+b|0,n[0]=o+L+(s>>>0<b>>>0?1:0)|0,f=n[3]=f+m|0,n[2]=a+w+(f>>>0<m>>>0?1:0)|0,h=n[5]=h+C|0,n[4]=c+S+(h>>>0<C>>>0?1:0)|0,p=n[7]=p+V|0,n[6]=l+z+(p>>>0<V>>>0?1:0)|0,A=n[9]=A+k|0,n[8]=v+P+(A>>>0<k>>>0?1:0)|0,y=n[11]=y+R|0,n[10]=g+_+(y>>>0<R>>>0?1:0)|0,U=n[13]=U+G|0,n[12]=D+q+(U>>>0<G>>>0?1:0)|0,E=n[15]=E+Z|0,n[14]=O+de+(E>>>0<Z>>>0?1:0)|0}};u.mode.ccm={name:"ccm",F:[],listenProgress:function(r){u.mode.ccm.F.push(r)},unListenProgress:function(r){r=u.mode.ccm.F.indexOf(r),-1<r&&u.mode.ccm.F.splice(r,1)},da:function(r){var e=u.mode.ccm.F.slice(),t;for(t=0;t<e.length;t+=1)e[t](r)},encrypt:function(r,e,t,n,i){var o,s=e.slice(0),a=u.bitArray,f=a.bitLength(t)/8,c=a.bitLength(s)/8;if(i=i||64,n=n||[],7>f)throw new u.exception.invalid("ccm: iv must be at least 7 bytes");for(o=2;4>o&&c>>>8*o;o++);return o<15-f&&(o=15-f),t=a.clamp(t,8*(15-o)),e=u.mode.ccm.U(r,e,t,n,i,o),s=u.mode.ccm.V(r,s,t,e,i,o),a.concat(s.data,s.tag)},decrypt:function(r,e,t,n,i){i=i||64,n=n||[];var o=u.bitArray,s=o.bitLength(t)/8,c=o.bitLength(e),a=o.clamp(e,c-i),f=o.bitSlice(e,c-i),c=(c-i)/8;if(7>s)throw new u.exception.invalid("ccm: iv must be at least 7 bytes");for(e=2;4>e&&c>>>8*e;e++);if(e<15-s&&(e=15-s),t=o.clamp(t,8*(15-e)),a=u.mode.ccm.V(r,a,t,f,i,e),r=u.mode.ccm.U(r,a.data,t,n,i,e),!o.equal(a.tag,r))throw new u.exception.corrupt("ccm: tag doesn't match");return a.data},ma:function(r,e,t,n,i,o){var s=[],a=u.bitArray,f=a.P;if(n=[a.partial(8,(e.length?64:0)|n-2<<2|o-1)],n=a.concat(n,t),n[3]|=i,n=r.encrypt(n),e.length)for(t=a.bitLength(e)/8,65279>=t?s=[a.partial(16,t)]:4294967295>=t&&(s=a.concat([a.partial(16,65534)],[t])),s=a.concat(s,e),e=0;e<s.length;e+=4)n=r.encrypt(f(n,s.slice(e,e+4).concat([0,0,0])));return n},U:function(r,e,t,n,i,o){var s=u.bitArray,a=s.P;if(i/=8,i%2||4>i||16<i)throw new u.exception.invalid("ccm: invalid tag length");if(4294967295<n.length||4294967295<e.length)throw new u.exception.bug("ccm: can't deal with 4GiB or more data");for(t=u.mode.ccm.ma(r,n,t,i,s.bitLength(e)/8,o),n=0;n<e.length;n+=4)t=r.encrypt(a(t,e.slice(n,n+4).concat([0,0,0])));return s.clamp(t,8*i)},V:function(r,e,t,n,i,o){var s,a=u.bitArray;s=a.P;var f=e.length,c=a.bitLength(e),h=f/50,l=h;if(t=a.concat([a.partial(8,o-1)],t).concat([0,0,0]).slice(0,4),n=a.bitSlice(s(n,r.encrypt(t)),0,i),!f)return{tag:n,data:[]};for(s=0;s<f;s+=4)s>h&&(u.mode.ccm.da(s/f),h+=l),t[3]++,i=r.encrypt(t),e[s]^=i[0],e[s+1]^=i[1],e[s+2]^=i[2],e[s+3]^=i[3];return{tag:n,data:a.clamp(e,c)}}};u.misc.hmac=function(r,e){this.W=e=e||u.hash.sha256;var t=[[],[]],n,i=e.prototype.blockSize/32;for(this.B=[new e,new e],r.length>i&&(r=e.hash(r)),n=0;n<i;n++)t[0][n]=r[n]^909522486,t[1][n]=r[n]^1549556828;this.B[0].update(t[0]),this.B[1].update(t[1]),this.O=new e(this.B[0])};u.misc.hmac.prototype.encrypt=u.misc.hmac.prototype.mac=function(r){if(this.Z)throw new u.exception.invalid("encrypt on already updated hmac called!");return this.update(r),this.digest(r)};u.misc.hmac.prototype.reset=function(){this.O=new this.W(this.B[0]),this.Z=!1};u.misc.hmac.prototype.update=function(r){this.Z=!0,this.O.update(r)};u.misc.hmac.prototype.digest=function(){var r=this.O.finalize(),r=new this.W(this.B[1]).update(r).finalize();return this.reset(),r};u.misc.pbkdf2=function(r,e,t,n,i){if(t=t||1e4,0>n||0>t)throw new u.exception.invalid("invalid params to pbkdf2");typeof r=="string"&&(r=u.codec.utf8String.toBits(r)),typeof e=="string"&&(e=u.codec.utf8String.toBits(e)),i=i||u.misc.hmac,r=new i(r);var o,s,a,f,c=[],h=u.bitArray;for(f=1;32*c.length<(n||1);f++){for(i=o=r.encrypt(h.concat(e,[f])),s=1;s<t;s++)for(o=r.encrypt(o),a=0;a<o.length;a++)i[a]^=o[a];c=c.concat(i)}return n&&(c=h.clamp(c,n)),c};u.prng=function(r){this.h=[new u.hash.sha256],this.s=[0],this.N=0,this.G={},this.M=0,this.T={},this.X=this.i=this.u=this.fa=0,this.b=[0,0,0,0,0,0,0,0],this.m=[0,0,0,0],this.K=void 0,this.L=r,this.D=!1,this.J={progress:{},seeded:{}},this.A=this.ea=0,this.H=1,this.I=2,this.aa=65536,this.R=[0,48,64,96,128,192,256,384,512,768,1024],this.ba=3e4,this.$=80};u.prng.prototype={randomWords:function(r,e){var t=[],n;n=this.isReady(e);var i;if(n===this.A)throw new u.exception.notReady("generator isn't seeded");if(n&this.I){n=!(n&this.H),i=[];var o=0,s;for(this.X=i[0]=new Date().valueOf()+this.ba,s=0;16>s;s++)i.push(4294967296*Math.random()|0);for(s=0;s<this.h.length&&(i=i.concat(this.h[s].finalize()),o+=this.s[s],this.s[s]=0,n||!(this.N&1<<s));s++);for(this.N>=1<<this.h.length&&(this.h.push(new u.hash.sha256),this.s.push(0)),this.i-=o,o>this.u&&(this.u=o),this.N++,this.b=u.hash.sha256.hash(this.b.concat(i)),this.K=new u.cipher.aes(this.b),n=0;4>n&&(this.m[n]=this.m[n]+1|0,!this.m[n]);n++);}for(n=0;n<r;n+=4)(n+1)%this.aa===0&<(this),i=Dr(this),t.push(i[0],i[1],i[2],i[3]);return lt(this),t.slice(0,r)},setDefaultParanoia:function(r,e){if(r===0&&e!=="Setting paranoia=0 will ruin your security; use it only for testing")throw new u.exception.invalid("Setting paranoia=0 will ruin your security; use it only for testing");this.L=r},addEntropy:function(r,e,t){t=t||"user";var n,i,o=new Date().valueOf(),s=this.G[t],a=this.isReady(),f=0;switch(n=this.T[t],n===void 0&&(n=this.T[t]=this.fa++),s===void 0&&(s=this.G[t]=0),this.G[t]=(this.G[t]+1)%this.h.length,typeof r){case"number":e===void 0&&(e=1),this.h[s].update([n,this.M++,1,e,o,1,r|0]);break;case"object":if(t=Object.prototype.toString.call(r),t==="[object Uint32Array]"){for(i=[],t=0;t<r.length;t++)i.push(r[t]);r=i}else for(t!=="[object Array]"&&(f=1),t=0;t<r.length&&!f;t++)typeof r[t]!="number"&&(f=1);if(!f){if(e===void 0)for(t=e=0;t<r.length;t++)for(i=r[t];0<i;)e++,i=i>>>1;this.h[s].update([n,this.M++,2,e,o,r.length].concat(r))}break;case"string":e===void 0&&(e=r.length),this.h[s].update([n,this.M++,3,e,o,r.length]),this.h[s].update(r);break;default:f=1}if(f)throw new u.exception.bug("random: addEntropy only supports number, array of numbers or string");this.s[s]+=e,this.i+=e,a===this.A&&(this.isReady()!==this.A&&ht("seeded",Math.max(this.u,this.i)),ht("progress",this.getProgress()))},isReady:function(r){return r=this.R[r!==void 0?r:this.L],this.u&&this.u>=r?this.s[0]>this.$&&new Date().valueOf()>this.X?this.I|this.H:this.H:this.i>=r?this.I|this.A:this.A},getProgress:function(r){return r=this.R[r||this.L],this.u>=r||this.i>r?1:this.i/r},startCollectors:function(){if(!this.D){if(this.a={loadTimeCollector:Ne(this,this.la),mouseCollector:Ne(this,this.na),keyboardCollector:Ne(this,this.ja),accelerometerCollector:Ne(this,this.ca),touchCollector:Ne(this,this.pa)},window.addEventListener)window.addEventListener("load",this.a.loadTimeCollector,!1),window.addEventListener("mousemove",this.a.mouseCollector,!1),window.addEventListener("keypress",this.a.keyboardCollector,!1),window.addEventListener("devicemotion",this.a.accelerometerCollector,!1),window.addEventListener("touchmove",this.a.touchCollector,!1);else if(document.attachEvent)document.attachEvent("onload",this.a.loadTimeCollector),document.attachEvent("onmousemove",this.a.mouseCollector),document.attachEvent("keypress",this.a.keyboardCollector);else throw new u.exception.bug("can't attach event");this.D=!0}},stopCollectors:function(){this.D&&(window.removeEventListener?(window.removeEventListener("load",this.a.loadTimeCollector,!1),window.removeEventListener("mousemove",this.a.mouseCollector,!1),window.removeEventListener("keypress",this.a.keyboardCollector,!1),window.removeEventListener("devicemotion",this.a.accelerometerCollector,!1),window.removeEventListener("touchmove",this.a.touchCollector,!1)):document.detachEvent&&(document.detachEvent("onload",this.a.loadTimeCollector),document.detachEvent("onmousemove",this.a.mouseCollector),document.detachEvent("keypress",this.a.keyboardCollector)),this.D=!1)},addEventListener:function(r,e){this.J[r][this.ea++]=e},removeEventListener:function(r,e){var t,n,i=this.J[r],o=[];for(n in i)i.hasOwnProperty(n)&&i[n]===e&&o.push(n);for(t=0;t<o.length;t++)n=o[t],delete i[n]},ja:function(){je(this,1)},na:function(r){var e,t;try{e=r.x||r.clientX||r.offsetX||0,t=r.y||r.clientY||r.offsetY||0}catch{t=e=0}e!=0&&t!=0&&this.addEntropy([e,t],2,"mouse"),je(this,0)},pa:function(r){r=r.touches[0]||r.changedTouches[0],this.addEntropy([r.pageX||r.clientX,r.pageY||r.clientY],1,"touch"),je(this,0)},la:function(){je(this,2)},ca:function(r){if(r=r.accelerationIncludingGravity.x||r.accelerationIncludingGravity.y||r.accelerationIncludingGravity.z,window.orientation){var e=window.orientation;typeof e=="number"&&this.addEntropy(e,1,"accelerometer")}r&&this.addEntropy(r,2,"accelerometer"),je(this,0)}};function ht(r,e){var t,n=u.random.J[r],i=[];for(t in n)n.hasOwnProperty(t)&&i.push(n[t]);for(t=0;t<i.length;t++)i[t](e)}function je(r,e){typeof window<"u"&&window.performance&&typeof window.performance.now=="function"?r.addEntropy(window.performance.now(),e,"loadtime"):r.addEntropy(new Date().valueOf(),e,"loadtime")}function lt(r){r.b=Dr(r).concat(Dr(r)),r.K=new u.cipher.aes(r.b)}function Dr(r){for(var e=0;4>e&&(r.m[e]=r.m[e]+1|0,!r.m[e]);e++);return r.K.encrypt(r.m)}function Ne(r,e){return function(){e.apply(r,arguments)}}u.random=new u.prng(6);e:try{if(tr=typeof Re<"u"&&Re.exports){try{nr=Yt("crypto")}catch{nr=null}tr=rr=nr}if(tr&&rr.randomBytes)Je=rr.randomBytes(128),Je=new Uint32Array(new Uint8Array(Je).buffer),u.random.addEntropy(Je,1024,"crypto['randomBytes']");else if(typeof window<"u"&&typeof Uint32Array<"u"){if(Ge=new Uint32Array(32),window.crypto&&window.crypto.getRandomValues)window.crypto.getRandomValues(Ge);else if(window.msCrypto&&window.msCrypto.getRandomValues)window.msCrypto.getRandomValues(Ge);else break e;u.random.addEntropy(Ge,1024,"crypto['getRandomValues']")}}catch(r){typeof window<"u"&&window.console&&(console.log("There was an error collecting entropy from the browser:"),console.log(r))}var Je,rr,Ge,tr,nr;u.json={defaults:{v:1,iter:1e4,ks:128,ts:64,mode:"ccm",adata:"",cipher:"aes"},ha:function(r,e,t,n){t=t||{},n=n||{};var i=u.json,o=i.j({iv:u.random.randomWords(4,0)},i.defaults),s;if(i.j(o,t),t=o.adata,typeof o.salt=="string"&&(o.salt=u.codec.base64.toBits(o.salt)),typeof o.iv=="string"&&(o.iv=u.codec.base64.toBits(o.iv)),!u.mode[o.mode]||!u.cipher[o.cipher]||typeof r=="string"&&100>=o.iter||o.ts!==64&&o.ts!==96&&o.ts!==128||o.ks!==128&&o.ks!==192&&o.ks!==256||2>o.iv.length||4<o.iv.length)throw new u.exception.invalid("json encrypt: invalid parameters");return typeof r=="string"?(s=u.misc.cachedPbkdf2(r,o),r=s.key.slice(0,o.ks/32),o.salt=s.salt):u.ecc&&r instanceof u.ecc.elGamal.publicKey&&(s=r.kem(),o.kemtag=s.tag,r=s.key.slice(0,o.ks/32)),typeof e=="string"&&(e=u.codec.utf8String.toBits(e)),typeof t=="string"&&(o.adata=t=u.codec.utf8String.toBits(t)),s=new u.cipher[o.cipher](r),i.j(n,o),n.key=r,o.ct=o.mode==="ccm"&&u.arrayBuffer&&u.arrayBuffer.ccm&&e instanceof ArrayBuffer?u.arrayBuffer.ccm.encrypt(s,e,o.iv,t,o.ts):u.mode[o.mode].encrypt(s,e,o.iv,t,o.ts),o},encrypt:function(r,e,t,n){var i=u.json,o=i.ha.apply(i,arguments);return i.encode(o)},ga:function(r,e,t,n){t=t||{},n=n||{};var i=u.json;e=i.j(i.j(i.j({},i.defaults),e),t,!0);var o,s;if(o=e.adata,typeof e.salt=="string"&&(e.salt=u.codec.base64.toBits(e.salt)),typeof e.iv=="string"&&(e.iv=u.codec.base64.toBits(e.iv)),!u.mode[e.mode]||!u.cipher[e.cipher]||typeof r=="string"&&100>=e.iter||e.ts!==64&&e.ts!==96&&e.ts!==128||e.ks!==128&&e.ks!==192&&e.ks!==256||!e.iv||2>e.iv.length||4<e.iv.length)throw new u.exception.invalid("json decrypt: invalid parameters");return typeof r=="string"?(s=u.misc.cachedPbkdf2(r,e),r=s.key.slice(0,e.ks/32),e.salt=s.salt):u.ecc&&r instanceof u.ecc.elGamal.secretKey&&(r=r.unkem(u.codec.base64.toBits(e.kemtag)).slice(0,e.ks/32)),typeof o=="string"&&(o=u.codec.utf8String.toBits(o)),s=new u.cipher[e.cipher](r),o=e.mode==="ccm"&&u.arrayBuffer&&u.arrayBuffer.ccm&&e.ct instanceof ArrayBuffer?u.arrayBuffer.ccm.decrypt(s,e.ct,e.iv,e.tag,o,e.ts):u.mode[e.mode].decrypt(s,e.ct,e.iv,o,e.ts),i.j(n,e),n.key=r,t.raw===1?o:u.codec.utf8String.fromBits(o)},decrypt:function(r,e,t,n){var i=u.json;return i.ga(r,i.decode(e),t,n)},encode:function(r){var e,t="{",n="";for(e in r)if(r.hasOwnProperty(e)){if(!e.match(/^[a-z0-9]+$/i))throw new u.exception.invalid("json encode: invalid property name");switch(t+=n+'"'+e+'":',n=",",typeof r[e]){case"number":case"boolean":t+=r[e];break;case"string":t+='"'+escape(r[e])+'"';break;case"object":t+='"'+u.codec.base64.fromBits(r[e],0)+'"';break;default:throw new u.exception.bug("json encode: unsupported type")}}return t+"}"},decode:function(r){if(r=r.replace(/\s/g,""),!r.match(/^\{.*\}$/))throw new u.exception.invalid("json decode: this isn't json!");r=r.replace(/^\{|\}$/g,"").split(/,/);var e={},t,n;for(t=0;t<r.length;t++){if(!(n=r[t].match(/^\s*(?:(["']?)([a-z][a-z0-9]*)\1)\s*:\s*(?:(-?\d+)|"([a-z0-9+\/%*_.@=\-]*)"|(true|false))$/i)))throw new u.exception.invalid("json decode: this isn't json!");n[3]!=null?e[n[2]]=parseInt(n[3],10):n[4]!=null?e[n[2]]=n[2].match(/^(ct|adata|salt|iv)$/)?u.codec.base64.toBits(n[4]):unescape(n[4]):n[5]!=null&&(e[n[2]]=n[5]==="true")}return e},j:function(r,e,t){if(r===void 0&&(r={}),e===void 0)return r;for(var n in e)if(e.hasOwnProperty(n)){if(t&&r[n]!==void 0&&r[n]!==e[n])throw new u.exception.invalid("required parameter overridden");r[n]=e[n]}return r},ra:function(r,e){var t={},n;for(n in r)r.hasOwnProperty(n)&&r[n]!==e[n]&&(t[n]=r[n]);return t},qa:function(r,e){var t={},n;for(n=0;n<e.length;n++)r[e[n]]!==void 0&&(t[e[n]]=r[e[n]]);return t}};u.encrypt=u.json.encrypt;u.decrypt=u.json.decrypt;u.misc.oa={};u.misc.cachedPbkdf2=function(r,e){var t=u.misc.oa,n;return e=e||{},n=e.iter||1e3,t=t[r]=t[r]||{},n=t[n]=t[n]||{firstSalt:e.salt&&e.salt.length?e.salt.slice(0):u.random.randomWords(2,0)},t=e.salt===void 0?n.firstSalt:e.salt,n[t]=n[t]||u.misc.pbkdf2(r,t,e.iter),{key:n[t].slice(0),salt:t.slice(0)}};typeof Re<"u"&&Re.exports&&(Re.exports=u);typeof define=="function"&&define([],function(){return u})});var Nr={};en(Nr,{addFilesToArchive:()=>Gt,cancel:()=>Nn,compress:()=>Wt,decompress:()=>Jn,download:()=>Gn,events:()=>jr,getFileIndexInQueue:()=>Xn,infos:()=>Wn,pause:()=>Hn,remove:()=>qn,resume:()=>Kn,upload:()=>$n});var Jt=wr(Ar());var fn={withStackTrace:!1},rt=(r,e,t=fn)=>{let n=e.isOk()?{type:"Ok",value:e.value}:{type:"Err",value:e.error},i=t.withStackTrace?new Error().stack:void 0;return{data:n,message:r,stack:i}};function Ce(r,e,t,n){function i(o){return o instanceof t?o:new t(function(s){s(o)})}return new(t||(t=Promise))(function(o,s){function a(h){try{c(n.next(h))}catch(l){s(l)}}function f(h){try{c(n.throw(h))}catch(l){s(l)}}function c(h){h.done?o(h.value):i(h.value).then(a,f)}c((n=n.apply(r,e||[])).next())})}function Yr(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],n=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function he(r){return this instanceof he?(this.v=r,this):new he(r)}function et(r,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=t.apply(r,e||[]),i,o=[];return i=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),a("next"),a("throw"),a("return",s),i[Symbol.asyncIterator]=function(){return this},i;function s(v){return function(A){return Promise.resolve(A).then(v,l)}}function a(v,A){n[v]&&(i[v]=function(g){return new Promise(function(y,D){o.push([v,g,y,D])>1||f(v,g)})},A&&(i[v]=A(i[v])))}function f(v,A){try{c(n[v](A))}catch(g){p(o[0][3],g)}}function c(v){v.value instanceof he?Promise.resolve(v.value.v).then(h,l):p(o[0][2],v)}function h(v){f("next",v)}function l(v){f("throw",v)}function p(v,A){v(A),o.shift(),o.length&&f(o[0][0],o[0][1])}}function cn(r){var e,t;return e={},n("next"),n("throw",function(i){throw i}),n("return"),e[Symbol.iterator]=function(){return this},e;function n(i,o){e[i]=r[i]?function(s){return(t=!t)?{value:he(r[i](s)),done:!1}:o?o(s):s}:o}}function hn(r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=r[Symbol.asyncIterator],t;return e?e.call(r):(r=typeof Yr=="function"?Yr(r):r[Symbol.iterator](),t={},n("next"),n("throw"),n("return"),t[Symbol.asyncIterator]=function(){return this},t);function n(o){t[o]=r[o]&&function(s){return new Promise(function(a,f){s=r[o](s),i(a,f,s.done,s.value)})}}function i(o,s,a,f){Promise.resolve(f).then(function(c){o({value:c,done:a})},s)}}var M=class r{constructor(e){this._promise=e}static fromSafePromise(e){let t=e.then(n=>new ie(n));return new r(t)}static fromPromise(e,t){let n=e.then(i=>new ie(i)).catch(i=>new oe(t(i)));return new r(n)}static fromThrowable(e,t){return(...n)=>new r(Ce(this,void 0,void 0,function*(){try{return new ie(yield e(...n))}catch(i){return new oe(t?t(i):i)}}))}static combine(e){return ln(e)}static combineWithAllErrors(e){return pn(e)}map(e){return new r(this._promise.then(t=>Ce(this,void 0,void 0,function*(){return t.isErr()?new oe(t.error):new ie(yield e(t.value))})))}andThrough(e){return new r(this._promise.then(t=>Ce(this,void 0,void 0,function*(){if(t.isErr())return new oe(t.error);let n=yield e(t.value);return n.isErr()?new oe(n.error):new ie(t.value)})))}andTee(e){return new r(this._promise.then(t=>Ce(this,void 0,void 0,function*(){if(t.isErr())return new oe(t.error);try{yield e(t.value)}catch{}return new ie(t.value)})))}mapErr(e){return new r(this._promise.then(t=>Ce(this,void 0,void 0,function*(){return t.isOk()?new ie(t.value):new oe(yield e(t.error))})))}andThen(e){return new r(this._promise.then(t=>{if(t.isErr())return new oe(t.error);let n=e(t.value);return n instanceof r?n._promise:n}))}orElse(e){return new r(this._promise.then(t=>Ce(this,void 0,void 0,function*(){return t.isErr()?e(t.error):new ie(t.value)})))}match(e,t){return this._promise.then(n=>n.match(e,t))}unwrapOr(e){return this._promise.then(t=>t.unwrapOr(e))}safeUnwrap(){return et(this,arguments,function*(){return yield he(yield he(yield*cn(hn(yield he(this._promise.then(t=>t.safeUnwrap()))))))})}then(e,t){return this._promise.then(e,t)}[Symbol.asyncIterator](){return et(this,arguments,function*(){let t=yield he(this._promise);return t.isErr()&&(yield yield he(W(t.error))),yield he(t.value)})}},K=r=>new M(Promise.resolve(new ie(r))),W=r=>new M(Promise.resolve(new oe(r))),ei=M.fromPromise,ri=M.fromSafePromise,ti=M.fromThrowable,tt=r=>{let e=pe([]);for(let t of r)if(t.isErr()){e=le(t.error);break}else e.map(n=>n.push(t.value));return e},ln=r=>M.fromSafePromise(Promise.all(r)).andThen(tt),nt=r=>{let e=pe([]);for(let t of r)t.isErr()&&e.isErr()?e.error.push(t.error):t.isErr()&&e.isOk()?e=le([t.error]):t.isOk()&&e.isOk()&&e.value.push(t.value);return e},pn=r=>M.fromSafePromise(Promise.all(r)).andThen(nt),xr;(function(r){function e(i,o){return(...s)=>{try{let a=i(...s);return pe(a)}catch(a){return le(o?o(a):a)}}}r.fromThrowable=e;function t(i){return tt(i)}r.combine=t;function n(i){return nt(i)}r.combineWithAllErrors=n})(xr||(xr={}));var pe=r=>new ie(r);function le(r){return new oe(r)}var ie=class{constructor(e){this.value=e}isOk(){return!0}isErr(){return!this.isOk()}map(e){return pe(e(this.value))}mapErr(e){return pe(this.value)}andThen(e){return e(this.value)}andThrough(e){return e(this.value).map(t=>this.value)}andTee(e){try{e(this.value)}catch{}return pe(this.value)}orElse(e){return pe(this.value)}asyncAndThen(e){return e(this.value)}asyncAndThrough(e){return e(this.value).map(()=>this.value)}asyncMap(e){return M.fromSafePromise(e(this.value))}unwrapOr(e){return this.value}match(e,t){return e(this.value)}safeUnwrap(){let e=this.value;return function*(){return e}()}_unsafeUnwrap(e){return this.value}_unsafeUnwrapErr(e){throw rt("Called `_unsafeUnwrapErr` on an Ok",this,e)}*[Symbol.iterator](){return this.value}},oe=class{constructor(e){this.error=e}isOk(){return!1}isErr(){return!this.isOk()}map(e){return le(this.error)}mapErr(e){return le(e(this.error))}andThrough(e){return le(this.error)}andTee(e){return le(this.error)}andThen(e){return le(this.error)}orElse(e){return e(this.error)}asyncAndThen(e){return W(this.error)}asyncAndThrough(e){return W(this.error)}asyncMap(e){return W(this.error)}unwrapOr(e){return e}match(e,t){return t(this.error)}safeUnwrap(){let e=this.error;return function*(){throw yield le(e),new Error("Do not use this generator out of `safeTry`")}()}_unsafeUnwrap(e){throw rt("Called `_unsafeUnwrap` on an Err",this,e)}_unsafeUnwrapErr(e){return this.error}*[Symbol.iterator](){let e=this;return yield e,e}},ni=xr.fromThrowable;var Ee=class r{constructor(e,t){d(this,"actionToken","");d(this,"chunksReady",0);d(this,"createdAt",0);d(this,"delay",0);d(this,"delAtFirstView",!1);d(this,"keys",{client:"",server:""});d(this,"name","");d(this,"password","");d(this,"queueIndex",0);d(this,"serverUrl");d(this,"size",0);d(this,"uploadStatus",3);d(this,"totalChunks",0);d(this,"type","");d(this,"zipped",!1);this.serverUrl=e,Object.assign(this,t)}downloadUrl(){let e=new URL(this.serverUrl);return new URL(`${e.origin+e.pathname}r/${this.keys.server}#${this.keys.client}`)}removeUrl(){let e=new URL(this.serverUrl);return new URL(`${e.origin+e.pathname}d/${this.keys.server}/${this.actionToken}`)}static fromDownloadUrl(e,t=""){let n=e.pathname.split("r/"),i={client:e.hash.slice(1).split("&")[0],server:n[1]};return new r(e.origin+n[0],{keys:i,password:t})}static fromRemoveUrl(e,t=""){let n=e.pathname.split("d/"),i=n[1].split("/"),o={client:"",server:i[0]};return new r(e.origin+n[0],{keys:o,password:t,actionToken:i[1]})}};var at=wr(Ar());var $=class extends Error{constructor(t,n={}){let{cause:i,context:o}=n;super(t,{cause:i});d(this,"context");this.name=this.constructor.name,this.context=o}};var Ye=class extends ${constructor(){super(...arguments);d(this,"message","Unable to connect. Is the computer able to access the url?")}};var er=class extends ${constructor(){super(...arguments);d(this,"message","The server returned an error")}};var J=r=>{if(r instanceof Error)return r;let e="[Unable to stringify the thrown value]";try{e=JSON.stringify(r)}catch{}return new Error(e)},ot=r=>{let e=r.href.match(/(.*?)\/?(?:\/[dr]{1}\/|login\/?|files\/?)/),t=e&&e[1]?e[1]:r.origin;return M.fromPromise(fetch(t+"/about/config"),n=>new Ye(void 0,{cause:J(n)})).andThen(n=>n.ok?M.fromPromise(n.json(),i=>J(i)):W(new er(void 0,{context:n.statusText})))},st=()=>typeof Deno<"u",Lr=()=>st()||globalThis.isSecureContext||globalThis.location.protocol==="https:",ke=r=>st()?new URL(`./worker/${r}.ts`,new URL(".",import.meta.url).href):new URL(import.meta.resolve(`./${r!=="encrypt"?`worker/${r}`:r}.js`));var Ae=class{constructor(e,t){d(this,"events",new at.default);d(this,"lufiFile");d(this,"status",2);d(this,"downloadedFile");d(this,"tmpChunks",[]);d(this,"worker");d(this,"isTerminated",!1);d(this,"complete",()=>{this.status=0,this.events.emit("JOB_TERMINATED")});d(this,"hasFailed",()=>this.status===1);d(this,"onError",e=>(this.worker.onerror=t=>{e(t)},this));d(this,"onMessage",e=>(this.worker.onmessage=t=>{e&&e(t);let n=t.data.event;n&&(n==="FILE_UPDATED"?Object.assign(this.lufiFile,t.data.lufiFile):this.dispatchEvent(n,t.data.error))},this));d(this,"onMessageError",e=>(this.worker.onmessageerror=t=>{e(t)},this));d(this,"onProgress",e=>(this.events.on("CHUNK_UPLOADED",()=>{e()}),this.events.on("CHUNK_DOWNLOADED",()=>{e()}),this));d(this,"requestMessage",(e,t=[])=>(this.worker.postMessage(e,t),this));d(this,"terminate",()=>(this.worker.terminate(),this));d(this,"waitForCompletion",()=>this.isTerminated?this.status===0?K(this):W(J("Job has failed")):M.fromPromise(new Promise((e,t)=>{this.events.once("OPERATION_FAILED",n=>{t(n)}),this.events.once("JOB_TERMINATED",()=>{this.status===0&&e(this)})}),e=>J(e)));d(this,"dispatchEvent",(e,t)=>{this.events.emit(e,t)});switch(t){case 0:this.worker=new Worker(ke("cancel"),{type:"module"});break;case 1:this.worker=new Worker(ke("download"),{type:"module"});break;case 2:this.worker=new Worker(ke("infos"),{type:"module"});break;case 3:this.worker=new Worker(ke("remove"),{type:"module"});break;case 4:this.worker=new Worker(ke("upload"),{type:"module"});break}this.lufiFile=e,this.events.once("JOB_TERMINATED",()=>{this.isTerminated=!0,this.terminate()}),this.events.once("OPERATION_FAILED",n=>{this.status=1,this.lufiFile.uploadStatus=2,this.events.emit("JOB_TERMINATED",n)}),this.onError(n=>console.error(n.error))}};var Se=(t=>(t[t.Sjcl=0]="Sjcl",t[t.WebCrypto=1]="WebCrypto",t))(Se||{});var Pe=class{constructor(e,t){if(!e||e.length!=64)throw Error("Charset must contain 64 characters");this._charset=e,this._noPadding=!!t,this._valid=new RegExp("^["+this._charset.replace("-","\\-")+"]+={0,2}$")}Encode(e){let t=e.byteLength;if(!t)return"";let n=new Uint8Array(e),i="";for(let o=0;o<t;o+=3)i+=this._charset[n[o]>>2]+this._charset[(n[o]&3)<<4|n[o+1]>>4]+this._charset[(n[o+1]&15)<<2|n[o+2]>>6]+this._charset[n[o+2]&63];return t%3==2?(i=i.substring(0,i.length-1),this._noPadding||(i+="=")):t%3==1&&(i=i.substring(0,i.length-2),this._noPadding||(i+="==")),i}Decode(e){if(e=(e||"").replace(/[\s]/g,""),!e)return new ArrayBuffer(0);if(!this._valid.test(e))throw Error("Invalid base64 input sequence");let t=Math.floor(e.length*.75);e[e.length-2]=="="?t-=2:e[e.length-1]=="="&&t--;let n=new Uint8Array(t),i,o,s,a,f=0,c=0;for(;f<e.length*.75;)i=this._charset.indexOf(e.charAt(c++)),o=this._charset.indexOf(e.charAt(c++)),s=this._charset.indexOf(e.charAt(c++)),a=this._charset.indexOf(e.charAt(c++)),n[f++]=i<<2|o>>4,n[f++]=(o&15)<<4|s>>2,n[f++]=(s&3)<<6|a;return n.buffer}};var zi=new Pe("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/");var yn=new Pe("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",!0);function br(r){return yn.Encode(r)}var We=wr(pt());var fe=class extends ${};var Te=class extends fe{constructor(){super(...arguments);d(this,"message","Unable to hash the provided string")}};var vt=()=>{try{return K(We.default.codec.base64.fromBits(We.default.random.randomWords(8,10)))}catch(r){return W(new fe("Unable to generate key",{cause:J(r)}))}},mt=r=>{try{return K(We.default.codec.hex.fromBits(We.default.hash.sha512.hash(r)))}catch(e){return W(new Te(void 0,{cause:J(e)}))}};var dt=()=>M.fromPromise(new Promise((r,e)=>crypto.subtle.generateKey({name:"AES-GCM",length:256},!0,["encrypt","decrypt"]).then(t=>crypto.subtle.exportKey("raw",t).then(n=>r(br(n))).catch(n=>{e(new fe("Unable to base64 encode the url",{cause:J(n)}))})).catch(t=>e(t))),r=>new fe("Unable to generate key",{cause:J(r)})),yt=r=>{let e=async()=>Array.from(new Uint8Array(await crypto.subtle.digest("SHA-512",new TextEncoder().encode(r)))).map(t=>t.toString(16).padStart(2,"0")).join("");return M.fromPromise(e(),t=>new Te(void 0,{cause:J(t)}))};var gt=(r=1)=>r===0?vt():dt(),Or=(r,e)=>e===0?mt(r):yt(r);var wt={},bn=function(r,e,t,n,i){var o=new Worker(wt[e]||(wt[e]=URL.createObjectURL(new Blob([r+';addEventListener("error",function(e){e=e.error;postMessage({$e$:[e.message,e.code,e.stack]})})'],{type:"text/javascript"}))));return o.onmessage=function(s){var a=s.data,f=a.$e$;if(f){var c=new Error(f[0]);c.code=f[1],c.stack=f[2],i(c,null)}else i(null,a)},o.postMessage(t,n),o},B=Uint8Array,ee=Uint16Array,Ke=Int32Array,ze=new B([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Fe=new B([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),He=new B([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),bt=function(r,e){for(var t=new ee(31),n=0;n<31;++n)t[n]=e+=1<<r[n-1];for(var i=new Ke(t[30]),n=1;n<30;++n)for(var o=t[n];o<t[n+1];++o)i[o]=o-t[n]<<5|n;return{b:t,r:i}},Dt=bt(ze,2),Mr=Dt.b,ur=Dt.r;Mr[28]=258,ur[258]=28;var Ot=bt(Fe,0),Ct=Ot.b,kr=Ot.r,qe=new ee(32768);for(T=0;T<32768;++T)ye=(T&43690)>>1|(T&21845)<<1,ye=(ye&52428)>>2|(ye&13107)<<2,ye=(ye&61680)>>4|(ye&3855)<<4,qe[T]=((ye&65280)>>8|(ye&255)<<8)>>1;var ye,T,ae=function(r,e,t){for(var n=r.length,i=0,o=new ee(e);i<n;++i)r[i]&&++o[r[i]-1];var s=new ee(e);for(i=1;i<e;++i)s[i]=s[i-1]+o[i-1]<<1;var a;if(t){a=new ee(1<<e);var f=15-e;for(i=0;i<n;++i)if(r[i])for(var c=i<<4|r[i],h=e-r[i],l=s[r[i]-1]++<<h,p=l|(1<<h)-1;l<=p;++l)a[qe[l]>>f]=c}else for(a=new ee(n),i=0;i<n;++i)r[i]&&(a[i]=qe[s[r[i]-1]++]>>15-r[i]);return a},ge=new B(288);for(T=0;T<144;++T)ge[T]=8;var T;for(T=144;T<256;++T)ge[T]=9;var T;for(T=256;T<280;++T)ge[T]=7;var T;for(T=280;T<288;++T)ge[T]=8;var T,Ie=new B(32);for(T=0;T<32;++T)Ie[T]=5;var T,kt=ae(ge,9,0),St=ae(ge,9,1),Pt=ae(Ie,5,0),Rt=ae(Ie,5,1),or=function(r){for(var e=r[0],t=1;t<r.length;++t)r[t]>e&&(e=r[t]);return e},se=function(r,e,t){var n=e/8|0;return(r[n]|r[n+1]<<8)>>(e&7)&t},sr=function(r,e){var t=e/8|0;return(r[t]|r[t+1]<<8|r[t+2]<<16)>>(e&7)},Ze=function(r){return(r+7)/8|0},Le=function(r,e,t){return(e==null||e<0)&&(e=0),(t==null||t>r.length)&&(t=r.length),new B(r.subarray(e,t))};var Tt=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],H=function(r,e,t){var n=new Error(e||Tt[r]);if(n.code=r,Error.captureStackTrace&&Error.captureStackTrace(n,H),!t)throw n;return n},Mt=function(r,e,t,n){var i=r.length,o=n?n.length:0;if(!i||e.f&&!e.l)return t||new B(0);var s=!t,a=s||e.i!=2,f=e.i;s&&(t=new B(i*3));var c=function(X){var _e=t.length;if(X>_e){var De=new B(Math.max(_e*2,X));De.set(t),t=De}},h=e.f||0,l=e.p||0,p=e.b||0,v=e.l,A=e.d,g=e.m,y=e.n,D=i*8;do{if(!v){h=se(r,l,1);var U=se(r,l+1,3);if(l+=3,U)if(U==1)v=St,A=Rt,g=9,y=5;else if(U==2){var L=se(r,l,31)+257,b=se(r,l+10,15)+4,w=L+se(r,l+5,31)+1;l+=14;for(var m=new B(w),S=new B(19),C=0;C<b;++C)S[He[C]]=se(r,l+C*3,7);l+=b*3;for(var z=or(S),V=(1<<z)-1,P=ae(S,z,1),C=0;C<w;){var k=P[se(r,l,V)];l+=k&15;var O=k>>4;if(O<16)m[C++]=O;else{var _=0,R=0;for(O==16?(R=3+se(r,l,3),l+=2,_=m[C-1]):O==17?(R=3+se(r,l,7),l+=3):O==18&&(R=11+se(r,l,127),l+=7);R--;)m[C++]=_}}var q=m.subarray(0,L),G=m.subarray(L);g=or(q),y=or(G),v=ae(q,g,1),A=ae(G,y,1)}else H(1);else{var O=Ze(l)+4,E=r[O-4]|r[O-3]<<8,x=O+E;if(x>i){f&&H(0);break}a&&c(p+E),t.set(r.subarray(O,x),p),e.b=p+=E,e.p=l=x*8,e.f=h;continue}if(l>D){f&&H(0);break}}a&&c(p+131072);for(var de=(1<<g)-1,Z=(1<<y)-1,te=l;;te=l){var _=v[sr(r,l)&de],Y=_>>4;if(l+=_&15,l>D){f&&H(0);break}if(_||H(2),Y<256)t[p++]=Y;else if(Y==256){te=l,v=null;break}else{var j=Y-254;if(Y>264){var C=Y-257,N=ze[C];j=se(r,l,(1<<N)-1)+Mr[C],l+=N}var re=A[sr(r,l)&Z],ne=re>>4;re||H(3),l+=re&15;var G=Ct[ne];if(ne>3){var N=Fe[ne];G+=sr(r,l)&(1<<N)-1,l+=N}if(l>D){f&&H(0);break}a&&c(p+131072);var we=p+j;if(p<G){var xe=o-G,F=Math.min(G,we);for(xe+p<0&&H(3);p<F;++p)t[p]=n[xe+p]}for(;p<we;++p)t[p]=t[p-G]}}e.l=v,e.p=te,e.b=p,e.f=h,v&&(h=1,e.m=g,e.d=A,e.n=y)}while(!h);return p!=t.length&&s?Le(t,0,p):t.subarray(0,p)},ve=function(r,e,t){t<<=e&7;var n=e/8|0;r[n]|=t,r[n+1]|=t>>8},Me=function(r,e,t){t<<=e&7;var n=e/8|0;r[n]|=t,r[n+1]|=t>>8,r[n+2]|=t>>16},ar=function(r,e){for(var t=[],n=0;n<r.length;++n)r[n]&&t.push({s:n,f:r[n]});var i=t.length,o=t.slice();if(!i)return{t:Ir,l:0};if(i==1){var s=new B(t[0].s+1);return s[t[0].s]=1,{t:s,l:1}}t.sort(function(x,L){return x.f-L.f}),t.push({s:-1,f:25001});var a=t[0],f=t[1],c=0,h=1,l=2;for(t[0]={s:-1,f:a.f+f.f,l:a,r:f};h!=i-1;)a=t[t[c].f<t[l].f?c++:l++],f=t[c!=h&&t[c].f<t[l].f?c++:l++],t[h++]={s:-1,f:a.f+f.f,l:a,r:f};for(var p=o[0].s,n=1;n<i;++n)o[n].s>p&&(p=o[n].s);var v=new ee(p+1),A=fr(t[h-1],v,0);if(A>e){var n=0,g=0,y=A-e,D=1<<y;for(o.sort(function(L,b){return v[b.s]-v[L.s]||L.f-b.f});n<i;++n){var U=o[n].s;if(v[U]>e)g+=D-(1<<A-v[U]),v[U]=e;else break}for(g>>=y;g>0;){var O=o[n].s;v[O]<e?g-=1<<e-v[O]++-1:++n}for(;n>=0&&g;--n){var E=o[n].s;v[E]==e&&(--v[E],++g)}A=e}return{t:new B(v),l:A}},fr=function(r,e,t){return r.s==-1?Math.max(fr(r.l,e,t+1),fr(r.r,e,t+1)):e[r.s]=t},Sr=function(r){for(var e=r.length;e&&!r[--e];);for(var t=new ee(++e),n=0,i=r[0],o=1,s=function(f){t[n++]=f},a=1;a<=e;++a)if(r[a]==i&&a!=e)++o;else{if(!i&&o>2){for(;o>138;o-=138)s(32754);o>2&&(s(o>10?o-11<<5|28690:o-3<<5|12305),o=0)}else if(o>3){for(s(i),--o;o>6;o-=6)s(8304);o>2&&(s(o-3<<5|8208),o=0)}for(;o--;)s(i);o=1,i=r[a]}return{c:t.subarray(0,n),n:e}},Ue=function(r,e){for(var t=0,n=0;n<e.length;++n)t+=r[n]*e[n];return t},Ur=function(r,e,t){var n=t.length,i=Ze(e+2);r[i]=n&255,r[i+1]=n>>8,r[i+2]=r[i]^255,r[i+3]=r[i+1]^255;for(var o=0;o<n;++o)r[i+o+4]=t[o];return(i+4+n)*8},Pr=function(r,e,t,n,i,o,s,a,f,c,h){ve(e,h++,t),++i[256];for(var l=ar(i,15),p=l.t,v=l.l,A=ar(o,15),g=A.t,y=A.l,D=Sr(p),U=D.c,O=D.n,E=Sr(g),x=E.c,L=E.n,b=new ee(19),w=0;w<U.length;++w)++b[U[w]&31];for(var w=0;w<x.length;++w)++b[x[w]&31];for(var m=ar(b,7),S=m.t,C=m.l,z=19;z>4&&!S[He[z-1]];--z);var V=c+5<<3,P=Ue(i,ge)+Ue(o,Ie)+s,k=Ue(i,p)+Ue(o,g)+s+14+3*z+Ue(b,S)+2*b[16]+3*b[17]+7*b[18];if(f>=0&&V<=P&&V<=k)return Ur(e,h,r.subarray(f,f+c));var _,R,q,G;if(ve(e,h,1+(k<P)),h+=2,k<P){_=ae(p,v,0),R=p,q=ae(g,y,0),G=g;var de=ae(S,C,0);ve(e,h,O-257),ve(e,h+5,L-1),ve(e,h+10,z-4),h+=14;for(var w=0;w<z;++w)ve(e,h+3*w,S[He[w]]);h+=3*z;for(var Z=[U,x],te=0;te<2;++te)for(var Y=Z[te],w=0;w<Y.length;++w){var j=Y[w]&31;ve(e,h,de[j]),h+=S[j],j>15&&(ve(e,h,Y[w]>>5&127),h+=Y[w]>>12)}}else _=kt,R=ge,q=Pt,G=Ie;for(var w=0;w<a;++w){var N=n[w];if(N>255){var j=N>>18&31;Me(e,h,_[j+257]),h+=R[j+257],j>7&&(ve(e,h,N>>23&31),h+=ze[j]);var re=N&31;Me(e,h,q[re]),h+=G[re],re>3&&(Me(e,h,N>>5&8191),h+=Fe[re])}else Me(e,h,_[N]),h+=R[N]}return Me(e,h,_[256]),h+R[256]},Ut=new Ke([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Ir=new B(0),It=function(r,e,t,n,i,o){var s=o.z||r.length,a=new B(n+s+5*(1+Math.ceil(s/7e3))+i),f=a.subarray(n,a.length-i),c=o.l,h=(o.r||0)&7;if(e){h&&(f[0]=o.r>>3);for(var l=Ut[e-1],p=l>>13,v=l&8191,A=(1<<t)-1,g=o.p||new ee(32768),y=o.h||new ee(A+1),D=Math.ceil(t/3),U=2*D,O=function(gr){return(r[gr]^r[gr+1]<<D^r[gr+2]<<U)&A},E=new Ke(25e3),x=new ee(288),L=new ee(32),b=0,w=0,m=o.i||0,S=0,C=o.w||0,z=0;m+2<s;++m){var V=O(m),P=m&32767,k=y[V];if(g[P]=k,y[V]=P,C<=m){var _=s-m;if((b>7e3||S>24576)&&(_>423||!c)){h=Pr(r,f,0,E,x,L,w,S,z,m-z,h),S=b=w=0,z=m;for(var R=0;R<286;++R)x[R]=0;for(var R=0;R<30;++R)L[R]=0}var q=2,G=0,de=v,Z=P-k&32767;if(_>2&&V==O(m-Z))for(var te=Math.min(p,_)-1,Y=Math.min(32767,m),j=Math.min(258,_);Z<=Y&&--de&&P!=k;){if(r[m+q]==r[m+q-Z]){for(var N=0;N<j&&r[m+N]==r[m+N-Z];++N);if(N>q){if(q=N,G=Z,N>te)break;for(var re=Math.min(Z,N-2),ne=0,R=0;R<re;++R){var we=m-Z+R&32767,xe=g[we],F=we-xe&32767;F>ne&&(ne=F,k=we)}}}P=k,k=g[P],Z+=P-k&32767}if(G){E[S++]=268435456|ur[q]<<18|kr[G];var X=ur[q]&31,_e=kr[G]&31;w+=ze[X]+Fe[_e],++x[257+X],++L[_e],C=m+q,++b}else E[S++]=r[m],++x[r[m]]}}for(m=Math.max(m,C);m<s;++m)E[S++]=r[m],++x[r[m]];h=Pr(r,f,c,E,x,L,w,S,z,m-z,h),c||(o.r=h&7|f[h/8|0]<<3,h-=7,o.h=y,o.p=g,o.i=m,o.w=C)}else{for(var m=o.w||0;m<s+c;m+=65535){var De=m+65535;De>=s&&(f[h/8|0]=c,De=s),h=Ur(f,h+1,r.subarray(m,De))}o.i=s}return Le(a,0,n+Ze(h)+i)},Dn=function(){for(var r=new Int32Array(256),e=0;e<256;++e){for(var t=e,n=9;--n;)t=(t&1&&-306674912)^t>>>1;r[e]=t}return r}(),On=function(){var r=-1;return{p:function(e){for(var t=r,n=0;n<e.length;++n)t=Dn[t&255^e[n]]^t>>>8;r=t},d:function(){return~r}}};var zt=function(r,e,t,n,i){if(!i&&(i={l:1},e.dictionary)){var o=e.dictionary.subarray(-32768),s=new B(o.length+r.length);s.set(o),s.set(r,o.length),r=s,i.w=o.length}return It(r,e.level==null?6:e.level,e.mem==null?i.l?Math.ceil(Math.max(8,Math.min(13,Math.log(r.length)))*1.5):20:12+e.mem,t,n,i)},zr=function(r,e){var t={};for(var n in r)t[n]=r[n];for(var n in e)t[n]=e[n];return t},Et=function(r,e,t){for(var n=r(),i=r.toString(),o=i.slice(i.indexOf("[")+1,i.lastIndexOf("]")).replace(/\s+/g,"").split(","),s=0;s<n.length;++s){var a=n[s],f=o[s];if(typeof a=="function"){e+=";"+f+"=";var c=a.toString();if(a.prototype)if(c.indexOf("[native code]")!=-1){var h=c.indexOf(" ",8)+1;e+=c.slice(h,c.indexOf("(",h))}else{e+=c;for(var l in a.prototype)e+=";"+f+".prototype."+l+"="+a.prototype[l].toString()}else e+=c}else t[f]=a}return e},ir=[],Cn=function(r){var e=[];for(var t in r)r[t].buffer&&e.push((r[t]=new r[t].constructor(r[t])).buffer);return e},kn=function(r,e,t,n){if(!ir[t]){for(var i="",o={},s=r.length-1,a=0;a<s;++a)i=Et(r[a],i,o);ir[t]={c:Et(r[s],i,o),e:o}}var f=zr({},ir[t].e);return bn(ir[t].c+";onmessage=function(e){for(var k in e.data)self[k]=e.data[k];onmessage="+e.toString()+"}",t,f,Cn(f),n)},Sn=function(){return[B,ee,Ke,ze,Fe,He,Mr,Ct,St,Rt,qe,Tt,ae,or,se,sr,Ze,Le,H,Mt,Br,hr,Ft]},Pn=function(){return[B,ee,Ke,ze,Fe,He,ur,kr,kt,ge,Pt,Ie,qe,Ut,Ir,ae,ve,Me,ar,fr,Sr,Ue,Ur,Pr,Ze,Le,It,zt,Fr,hr]};var hr=function(r){return postMessage(r,[r.buffer])},Ft=function(r){return r&&{out:r.size&&new B(r.size),dictionary:r.dictionary}},Bt=function(r,e,t,n,i,o){var s=kn(t,n,i,function(a,f){s.terminate(),o(a,f)});return s.postMessage([r,e],e.consume?[r.buffer]:[]),function(){s.terminate()}};var me=function(r,e){return r[e]|r[e+1]<<8},ce=function(r,e){return(r[e]|r[e+1]<<8|r[e+2]<<16|r[e+3]<<24)>>>0},Cr=function(r,e){return ce(r,e)+ce(r,e+4)*4294967296},Q=function(r,e,t){for(;t;++e)r[e]=t,t>>>=8};function Rn(r,e,t){return t||(t=e,e={}),typeof t!="function"&&H(7),Bt(r,e,[Pn],function(n){return hr(Fr(n.data[0],n.data[1]))},0,t)}function Fr(r,e){return zt(r,e||{},0,0)}function Tn(r,e,t){return t||(t=e,e={}),typeof t!="function"&&H(7),Bt(r,e,[Sn],function(n){return hr(Br(n.data[0],Ft(n.data[1])))},1,t)}function Br(r,e){return Mt(r,{i:2},e&&e.out,e&&e.dictionary)}var _t=function(r,e,t,n){for(var i in r){var o=r[i],s=e+i,a=n;Array.isArray(o)&&(a=zr(n,o[1]),o=o[0]),o instanceof B?t[s]=[o,a]:(t[s+="/"]=[new B(0),a],_t(o,s,t,n))}},At=typeof TextEncoder<"u"&&new TextEncoder,Rr=typeof TextDecoder<"u"&&new TextDecoder,Mn=0;try{Rr.decode(Ir,{stream:!0}),Mn=1}catch{}var Un=function(r){for(var e="",t=0;;){var n=r[t++],i=(n>127)+(n>223)+(n>239);if(t+i>r.length)return{s:e,r:Le(r,t-1)};i?i==3?(n=((n&15)<<18|(r[t++]&63)<<12|(r[t++]&63)<<6|r[t++]&63)-65536,e+=String.fromCharCode(55296|n>>10,56320|n&1023)):i&1?e+=String.fromCharCode((n&31)<<6|r[t++]&63):e+=String.fromCharCode((n&15)<<12|(r[t++]&63)<<6|r[t++]&63):e+=String.fromCharCode(n)}};function xt(r,e){if(e){for(var t=new B(r.length),n=0;n<r.length;++n)t[n]=r.charCodeAt(n);return t}if(At)return At.encode(r);for(var i=r.length,o=new B(r.length+(r.length>>1)),s=0,a=function(h){o[s++]=h},n=0;n<i;++n){if(s+5>o.length){var f=new B(s+8+(i-n<<1));f.set(o),o=f}var c=r.charCodeAt(n);c<128||e?a(c):c<2048?(a(192|c>>6),a(128|c&63)):c>55295&&c<57344?(c=65536+(c&1047552)|r.charCodeAt(++n)&1023,a(240|c>>18),a(128|c>>12&63),a(128|c>>6&63),a(128|c&63)):(a(224|c>>12),a(128|c>>6&63),a(128|c&63))}return Le(o,0,s)}function In(r,e){if(e){for(var t="",n=0;n<r.length;n+=16384)t+=String.fromCharCode.apply(null,r.subarray(n,n+16384));return t}else{if(Rr)return Rr.decode(r);var i=Un(r),o=i.s,t=i.r;return t.length&&H(8),o}}var zn=function(r,e){return e+30+me(r,e+26)+me(r,e+28)},Fn=function(r,e,t){var n=me(r,e+28),i=In(r.subarray(e+46,e+46+n),!(me(r,e+8)&2048)),o=e+46+n,s=ce(r,e+20),a=t&&s==4294967295?Bn(r,o):[s,ce(r,e+24),ce(r,e+42)],f=a[0],c=a[1],h=a[2];return[me(r,e+10),f,c,i,o+me(r,e+30)+me(r,e+32),h]},Bn=function(r,e){for(;me(r,e)!=1;e+=4+me(r,e+2));return[Cr(r,e+12),Cr(r,e+4),Cr(r,e+20)]},Tr=function(r){var e=0;if(r)for(var t in r){var n=r[t].length;n>65535&&H(9),e+=n+4}return e},Lt=function(r,e,t,n,i,o,s,a){var f=n.length,c=t.extra,h=a&&a.length,l=Tr(c);Q(r,e,s!=null?33639248:67324752),e+=4,s!=null&&(r[e++]=20,r[e++]=t.os),r[e]=20,e+=2,r[e++]=t.flag<<1|(o<0&&8),r[e++]=i&&8,r[e++]=t.compression&255,r[e++]=t.compression>>8;var p=new Date(t.mtime==null?Date.now():t.mtime),v=p.getFullYear()-1980;if((v<0||v>119)&&H(10),Q(r,e,v<<25|p.getMonth()+1<<21|p.getDate()<<16|p.getHours()<<11|p.getMinutes()<<5|p.getSeconds()>>1),e+=4,o!=-1&&(Q(r,e,t.crc),Q(r,e+4,o<0?-o-2:o),Q(r,e+8,t.size)),Q(r,e+12,f),Q(r,e+14,l),e+=16,s!=null&&(Q(r,e,h),Q(r,e+6,t.attrs),Q(r,e+10,s),e+=14),r.set(n,e),e+=f,l)for(var A in c){var g=c[A],y=g.length;Q(r,e,+A),Q(r,e+2,y),r.set(g,e+4),e+=4+y}return h&&(r.set(a,e),e+=h),e},_n=function(r,e,t,n,i){Q(r,e,101010256),Q(r,e+8,t),Q(r,e+10,t),Q(r,e+12,n),Q(r,e+16,i)};function jt(r,e,t){t||(t=e,e={}),typeof t!="function"&&H(7);var n={};_t(r,"",n,e);var i=Object.keys(n),o=i.length,s=0,a=0,f=o,c=new Array(o),h=[],l=function(){for(var y=0;y<h.length;++y)h[y]()},p=function(y,D){cr(function(){t(y,D)})};cr(function(){p=t});var v=function(){var y=new B(a+22),D=s,U=a-s;a=0;for(var O=0;O<f;++O){var E=c[O];try{var x=E.c.length;Lt(y,a,E,E.f,E.u,x);var L=30+E.f.length+Tr(E.extra),b=a+L;y.set(E.c,b),Lt(y,s,E,E.f,E.u,x,a,E.m),s+=16+L+(E.m?E.m.length:0),a=b+x}catch(w){return p(w,null)}}_n(y,s,c.length,U,D),p(null,y)};o||v();for(var A=function(y){var D=i[y],U=n[D],O=U[0],E=U[1],x=On(),L=O.length;x.p(O);var b=xt(D),w=b.length,m=E.comment,S=m&&xt(m),C=S&&S.length,z=Tr(E.extra),V=E.level==0?0:8,P=function(k,_){if(k)l(),p(k,null);else{var R=_.length;c[y]=zr(E,{size:L,crc:x.d(),c:_,f:b,m:S,u:w!=D.length||S&&m.length!=C,compression:V}),s+=30+w+z+R,a+=76+2*(w+z)+(C||0)+R,--o||v()}};if(w>65535&&P(H(11,0,1),null),!V)P(null,O);else if(L<16e4)try{P(null,Fr(O,E))}catch(k){P(k,null)}else h.push(Rn(O,E,P))},g=0;g<f;++g)A(g);return l}var cr=typeof queueMicrotask=="function"?queueMicrotask:typeof setTimeout=="function"?setTimeout:function(r){r()};function Nt(r,e,t){t||(t=e,e={}),typeof t!="function"&&H(7);var n=[],i=function(){for(var y=0;y<n.length;++y)n[y]()},o={},s=function(y,D){cr(function(){t(y,D)})};cr(function(){s=t});for(var a=r.length-22;ce(r,a)!=101010256;--a)if(!a||r.length-a>65558)return s(H(13,0,1),null),i;var f=me(r,a+8);if(f){var c=f,h=ce(r,a+16),l=h==4294967295||c==65535;if(l){var p=ce(r,a-12);l=ce(r,p)==101075792,l&&(c=f=ce(r,p+32),h=ce(r,p+48))}for(var v=e&&e.filter,A=function(y){var D=Fn(r,h,l),U=D[0],O=D[1],E=D[2],x=D[3],L=D[4],b=D[5],w=zn(r,b);h=L;var m=function(C,z){C?(i(),s(C,null)):(z&&(o[x]=z),--f||s(null,o))};if(!v||v({name:x,size:O,originalSize:E,compression:U}))if(!U)m(null,Le(r,w,w+O));else if(U==8){var S=r.subarray(w,w+O);if(E<524288||O>.8*E)try{m(null,Br(S,{out:new B(E)}))}catch(C){m(C,null)}else n.push(Tn(S,{size:E},m))}else m(H(14,"unknown compression type "+U,1),null);else m(null,null)},g=0;g<c;++g)A(g)}else s(null,{});return i}var Be=class extends ${};var lr=class extends Be{constructor(){super(...arguments);d(this,"message","An error occured while trying to compress the data")}};var pr=class extends Be{constructor(){super(...arguments);d(this,"message","An error occured while trying to decompress the data")}};var vr=class extends ${constructor(){super(...arguments);d(this,"message","An error occured while downloading the data")}};var mr=class extends ${constructor(){super(...arguments);d(this,"message","An error occured while trying to retrieve server informations")}};var ue=class extends ${};var dr=class extends ue{constructor(){super(...arguments);d(this,"message","An error occured while trying to pause the job")}};var yr=class extends ue{constructor(){super(...arguments);d(this,"message","An error occured while trying to resume the job")}};var $e=class extends ${constructor(){super(...arguments);d(this,"message","An error occured while uploading the data")}};var jn=15e5,be={},jr=new Jt.default,Nn=r=>{r.terminate();let e=new Ae(r.lufiFile,0);return M.fromPromise(new Promise((t,n)=>{e.onMessage(i=>{i.data.event==="UPLOAD_CANCELLED"&&(be[e.lufiFile.keys.client].uploadStatus=0,t(e)),i.data.event==="OPERATION_FAILED"&&n(new ue("An error occured while trying to cancel an upload",{cause:i.data.error}))}).requestMessage({args:{lufiFile:e.lufiFile}})}),t=>J(t))},Gt=(r,e={})=>{let t=async n=>{var i;for(let o of n){let s=((i=o.name.split("/"))==null?void 0:i.pop())||o.name,a=s.split(".").shift(),f=s.split(".").pop(),c=s;if(e[c]!==void 0){let h=1;do c=`${a}_(${h}).${f}`,h++;while(e[c]!==void 0)}jr.emit("ARCHIVE_ADDED_FILE",{name:c,size:o.size}),e[c]=await o.bytes()}};return M.fromPromise(t(r),n=>J(n)).andThen(()=>K(e))},Wt=(r,e)=>{let t=()=>new Promise((n,i)=>{jt(r,(o,s)=>{o&&i(o),n(s)})});return M.fromPromise(t(),n=>n).andThen(n=>{try{return K(new File([new Blob([n])],e,{type:"application/zip"}))}catch(i){return W(i)}}).orElse(n=>W(new lr(void 0,{cause:J(n)})))},Jn=r=>{let e=async()=>{let t=await r.bytes();return new Promise((n,i)=>{Nt(t,(o,s)=>{o&&i(o),n(s)})})};return M.fromPromise(e(),t=>t).andThen(t=>{try{let n=[];for(let i in t)n.push(new File([new Blob([t[i]])],i));return K(n)}catch(n){return W(n)}}).orElse(t=>W(new pr(void 0,{cause:J(t)})))},Ht=(r,e)=>e?ot(r).andThen(t=>{if(t.version.tag>"0.07.0"){let n=Lr()?1:0;return Or(e,n).andThen(i=>K(Ee.fromDownloadUrl(r,i)))}else return K(Ee.fromDownloadUrl(r,e))}):K(Ee.fromDownloadUrl(r)),Gn=(r,e)=>Ht(r,e).andThen(t=>{let n=new Ae(t,1);return M.fromPromise(new Promise((i,o)=>n.onMessage(s=>{qt(i,o,n,s),s.data.event==="CHUNK_DOWNLOADED"&&(n.tmpChunks[s.data.chunk.index]=new Blob([s.data.chunk.buffer])),s.data.event==="DOWNLOAD_COMPLETE"&&(n.downloadedFile=new File(n.tmpChunks,t.name,{type:t.type}),n.tmpChunks=[],n.complete())}).requestMessage({args:{lufiFile:t}})),i=>new vr(void 0,{cause:J(i)}))}),Wn=(r,e)=>Ht(r,e).andThen(t=>K(new Ae(t,2))).andThen(t=>M.fromPromise(new Promise((n,i)=>{t.onMessage(o=>{o.data.event==="INFOS_RETRIEVED"&&(t.complete(),n(t)),o.data.event==="OPERATION_FAILED"&&i(new ue("An error occured while trying to retrieve informations of the file",{cause:o.data.error}))}).requestMessage({args:{lufiFile:t.lufiFile}})}),n=>new mr(void 0,{cause:J(n)}))),Hn=r=>{try{return r.status=3,K(r.requestMessage({action:0,args:{lufiFile:r.lufiFile}}))}catch(e){return W(new dr(void 0,{cause:J(e)}))}},qn=(r,e)=>{let t=Ee.fromRemoveUrl(r,e),n=new Ae(t,3);return M.fromPromise(new Promise((i,o)=>{n.onMessage(s=>{s.data.event==="FILE_REMOVED"&&(n.complete(),i(n)),s.data.event==="OPERATION_FAILED"&&o(new ue("An error occured while trying to remove a file",{cause:s.data.error()}))}).requestMessage({args:{lufiFile:t}})}),i=>J(i))},Kn=r=>{try{return r.status=2,K(r.requestMessage({action:2,args:{lufiFile:r.lufiFile}}))}catch(e){return W(new yr(void 0,{cause:J(e)}))}},Zn=(r,e,t=jn)=>{let n=Math.ceil(r.size/t)||1;be[e].totalChunks=n;let i=[];for(let o=0;o<n;o++){let s=o*t,a=Math.min(s+t,r.size);i.push(r.slice(s,a,r.type))}return pe(i)},$n=(r,e,t=0,n=!1,i=!1,o="documents.zip",s="",a=1)=>{let f=[];return i?e.length===1&&e[0].type==="application/zip"?f.push(_r(r,e[0],t,n,i,s,a)):f.push(Gt(e).andThen(c=>Wt(c,o).andThen(h=>(jr.emit("ARCHIVE_CREATED",h),_r(r,h,t,n,i,s,a))))):e.forEach(c=>{f.push(_r(r,c,t,n,i,s,a))}),M.combine(f).orElse(c=>W(new $e(void 0,{cause:c})))},_r=(r,e,t,n,i,o,s)=>gt(s).andThen(a=>o?Or(o,s).andThen(f=>K({password:f,clientKey:a})):K({password:o,clientKey:a})).andThen(({password:a,clientKey:f})=>{be[f]=new Ee(r.toString(),{delay:t,delAtFirstView:n,zipped:i,password:a,name:e.name.split("/").pop(),size:e.size,type:e.type,keys:{client:f,server:""}});let c=new Ae(be[f],4);return Zn(e,f).asyncAndThen(h=>{be[f].uploadStatus=4;let l=new Promise((v,A)=>{c.onMessage(g=>{switch(qt(v,A,c,g),g.data.event){case"UPLOAD_COMPLETE":c.complete(),c.lufiFile.uploadStatus=1;break}})}),p=async v=>{for(let[A,g]of v.entries()){let y=await g.arrayBuffer();c.requestMessage({args:{chunk:{buffer:y,index:A},lufiFile:be[f],algo:s}},[y])}};return M.fromPromise(p(h),v=>new ue("An error occurred while sending chunks",{cause:J(v)})).andThen(()=>M.fromPromise(l,v=>J(v)))}).orElse(h=>W(new $e("An error occured while uploading a file",{cause:h})))}),qt=(r,e,t,n)=>{n.data.event==="SOCKET_OPENED"&&r(t),n.data.event==="OPERATION_FAILED"&&e(new ue("The job returned an error",{cause:n.data.error}))},Vn=()=>Object.values(be).filter(r=>r.uploadStatus===4),Xn=r=>Object.keys(Vn()).indexOf(r);export{Se as CryptoAlgorithm,M as ResultAsync,le as err,W as errAsync,Lr as isSecureContext,Nr as lufi,pe as ok,K as okAsync};
|