var oe=Object.create;var C=Object.defineProperty;var ie=Object.getOwnPropertyDescriptor;var se=Object.getOwnPropertyNames;var ue=Object.getPrototypeOf,ae=Object.prototype.hasOwnProperty;var fe=(r,e,t)=>e in r?C(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var ce=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports);var le=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of se(e))!ae.call(r,o)&&o!==t&&C(r,o,{get:()=>e[o],enumerable:!(n=ie(e,o))||n.enumerable});return r};var he=(r,e,t)=>(t=r!=null?oe(ue(r)):{},le(e||!r||!r.__esModule?C(t,"default",{value:r,enumerable:!0}):t,r));var L=(r,e,t)=>fe(r,typeof e!="symbol"?e+"":e,t);var X=ce((qe,k)=>{"use strict";var g=typeof Reflect=="object"?Reflect:null,J=g&&typeof g.apply=="function"?g.apply:function(e,t,n){return Function.prototype.apply.call(e,t,n)},R;g&&typeof g.ownKeys=="function"?R=g.ownKeys:Object.getOwnPropertySymbols?R=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:R=function(e){return Object.getOwnPropertyNames(e)};function ye(r){console&&console.warn&&console.warn(r)}var K=Number.isNaN||function(e){return e!==e};function u(){u.init.call(this)}k.exports=u;k.exports.once=Oe;u.EventEmitter=u;u.prototype._events=void 0;u.prototype._eventsCount=0;u.prototype._maxListeners=void 0;var H=10;function I(r){if(typeof r!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof r)}Object.defineProperty(u,"defaultMaxListeners",{enumerable:!0,get:function(){return H},set:function(r){if(typeof r!="number"||r<0||K(r))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+r+".");H=r}});u.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};u.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||K(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 B(r){return r._maxListeners===void 0?u.defaultMaxListeners:r._maxListeners}u.prototype.getMaxListeners=function(){return B(this)};u.prototype.emit=function(e){for(var t=[],n=1;n0&&(s=t[0]),s instanceof Error)throw s;var a=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw a.context=s,a}var c=i[e];if(c===void 0)return!1;if(typeof c=="function")J(c,this,t);else for(var d=c.length,p=Z(c,d),n=0;n0&&s.length>o&&!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,ye(a)}return r}u.prototype.addListener=function(e,t){return $(this,e,t,!1)};u.prototype.on=u.prototype.addListener;u.prototype.prependListener=function(e,t){return $(this,e,t,!0)};function we(){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 G(r,e,t){var n={fired:!1,wrapFn:void 0,target:r,type:e,listener:t},o=we.bind(n);return o.listener=t,n.wrapFn=o,o}u.prototype.once=function(e,t){return I(t),this.on(e,G(this,e,t)),this};u.prototype.prependOnceListener=function(e,t){return I(t),this.prependListener(e,G(this,e,t)),this};u.prototype.removeListener=function(e,t){var n,o,i,s,a;if(I(t),o=this._events,o===void 0)return this;if(n=o[e],n===void 0)return this;if(n===t||n.listener===t)--this._eventsCount===0?this._events=Object.create(null):(delete o[e],o.removeListener&&this.emit("removeListener",e,n.listener||t));else if(typeof n!="function"){for(i=-1,s=n.length-1;s>=0;s--)if(n[s]===t||n[s].listener===t){a=n[s].listener,i=s;break}if(i<0)return this;i===0?n.shift():_e(n,i),n.length===1&&(o[e]=n[0]),o.removeListener!==void 0&&this.emit("removeListener",e,a||t)}return this};u.prototype.off=u.prototype.removeListener;u.prototype.removeAllListeners=function(e){var t,n,o;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 i=Object.keys(n),s;for(o=0;o=0;o--)this.removeListener(e,t[o]);return this};function q(r,e,t){var n=r._events;if(n===void 0)return[];var o=n[e];return o===void 0?[]:typeof o=="function"?t?[o.listener||o]:[o]:t?Le(o):Z(o,o.length)}u.prototype.listeners=function(e){return q(this,e,!0)};u.prototype.rawListeners=function(e){return q(this,e,!1)};u.listenerCount=function(r,e){return typeof r.listenerCount=="function"?r.listenerCount(e):Q.call(r,e)};u.prototype.listenerCount=Q;function Q(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}u.prototype.eventNames=function(){return this._eventsCount>0?R(this._events):[]};function Z(r,e){for(var t=new Array(e),n=0;n{let n=e.isOk()?{type:"Ok",value:e.value}:{type:"Err",value:e.error},o=t.withStackTrace?new Error().stack:void 0;return{data:n,message:r,stack:o}};function O(r,e,t,n){function o(i){return i instanceof t?i:new t(function(s){s(i)})}return new(t||(t=Promise))(function(i,s){function a(p){try{d(n.next(p))}catch(_){s(_)}}function c(p){try{d(n.throw(p))}catch(_){s(_)}}function d(p){p.done?i(p.value):o(p.value).then(a,c)}d((n=n.apply(r,e||[])).next())})}function F(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 v(r){return this instanceof v?(this.v=r,this):new v(r)}function U(r,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=t.apply(r,e||[]),o,i=[];return o=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),a("next"),a("throw"),a("return",s),o[Symbol.asyncIterator]=function(){return this},o;function s(f){return function(y){return Promise.resolve(y).then(f,_)}}function a(f,y){n[f]&&(o[f]=function(A){return new Promise(function(te,ne){i.push([f,A,te,ne])>1||c(f,A)})},y&&(o[f]=y(o[f])))}function c(f,y){try{d(n[f](y))}catch(A){M(i[0][3],A)}}function d(f){f.value instanceof v?Promise.resolve(f.value.v).then(p,_):M(i[0][2],f)}function p(f){c("next",f)}function _(f){c("throw",f)}function M(f,y){f(y),i.shift(),i.length&&c(i[0][0],i[0][1])}}function me(r){var e,t;return e={},n("next"),n("throw",function(o){throw o}),n("return"),e[Symbol.iterator]=function(){return this},e;function n(o,i){e[o]=r[o]?function(s){return(t=!t)?{value:v(r[o](s)),done:!1}:i?i(s):s}:i}}function de(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 F=="function"?F(r):r[Symbol.iterator](),t={},n("next"),n("throw"),n("return"),t[Symbol.asyncIterator]=function(){return this},t);function n(i){t[i]=r[i]&&function(s){return new Promise(function(a,c){s=r[i](s),o(a,c,s.done,s.value)})}}function o(i,s,a,c){Promise.resolve(c).then(function(d){i({value:d,done:a})},s)}}var h=class r{constructor(e){this._promise=e}static fromSafePromise(e){let t=e.then(n=>new m(n));return new r(t)}static fromPromise(e,t){let n=e.then(o=>new m(o)).catch(o=>new l(t(o)));return new r(n)}static fromThrowable(e,t){return(...n)=>new r(O(this,void 0,void 0,function*(){try{return new m(yield e(...n))}catch(o){return new l(t?t(o):o)}}))}static combine(e){return ve(e)}static combineWithAllErrors(e){return Ee(e)}map(e){return new r(this._promise.then(t=>O(this,void 0,void 0,function*(){return t.isErr()?new l(t.error):new m(yield e(t.value))})))}andThrough(e){return new r(this._promise.then(t=>O(this,void 0,void 0,function*(){if(t.isErr())return new l(t.error);let n=yield e(t.value);return n.isErr()?new l(n.error):new m(t.value)})))}andTee(e){return new r(this._promise.then(t=>O(this,void 0,void 0,function*(){if(t.isErr())return new l(t.error);try{yield e(t.value)}catch{}return new m(t.value)})))}mapErr(e){return new r(this._promise.then(t=>O(this,void 0,void 0,function*(){return t.isOk()?new m(t.value):new l(yield e(t.error))})))}andThen(e){return new r(this._promise.then(t=>{if(t.isErr())return new l(t.error);let n=e(t.value);return n instanceof r?n._promise:n}))}orElse(e){return new r(this._promise.then(t=>O(this,void 0,void 0,function*(){return t.isErr()?e(t.error):new m(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 U(this,arguments,function*(){return yield v(yield v(yield*me(de(yield v(this._promise.then(t=>t.safeUnwrap()))))))})}then(e,t){return this._promise.then(e,t)}[Symbol.asyncIterator](){return U(this,arguments,function*(){let t=yield v(this._promise);return t.isErr()&&(yield yield v(D(t.error))),yield v(t.value)})}};var D=r=>new h(Promise.resolve(new l(r))),Ie=h.fromPromise,xe=h.fromSafePromise,Pe=h.fromThrowable,W=r=>{let e=w([]);for(let t of r)if(t.isErr()){e=E(t.error);break}else e.map(n=>n.push(t.value));return e},ve=r=>h.fromSafePromise(Promise.all(r)).andThen(W),j=r=>{let e=w([]);for(let t of r)t.isErr()&&e.isErr()?e.error.push(t.error):t.isErr()&&e.isOk()?e=E([t.error]):t.isOk()&&e.isOk()&&e.value.push(t.value);return e},Ee=r=>h.fromSafePromise(Promise.all(r)).andThen(j),T;(function(r){function e(o,i){return(...s)=>{try{let a=o(...s);return w(a)}catch(a){return E(i?i(a):a)}}}r.fromThrowable=e;function t(o){return W(o)}r.combine=t;function n(o){return j(o)}r.combineWithAllErrors=n})(T||(T={}));var w=r=>new m(r);function E(r){return new l(r)}var m=class{constructor(e){this.value=e}isOk(){return!0}isErr(){return!this.isOk()}map(e){return w(e(this.value))}mapErr(e){return w(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 w(this.value)}orElse(e){return w(this.value)}asyncAndThen(e){return e(this.value)}asyncAndThrough(e){return e(this.value).map(()=>this.value)}asyncMap(e){return h.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 N("Called `_unsafeUnwrapErr` on an Ok",this,e)}*[Symbol.iterator](){return this.value}},l=class{constructor(e){this.error=e}isOk(){return!1}isErr(){return!this.isOk()}map(e){return E(this.error)}mapErr(e){return E(e(this.error))}andThrough(e){return E(this.error)}andTee(e){return E(this.error)}andThen(e){return E(this.error)}orElse(e){return e(this.error)}asyncAndThen(e){return D(this.error)}asyncAndThrough(e){return D(this.error)}asyncMap(e){return D(this.error)}unwrapOr(e){return e}match(e,t){return t(this.error)}safeUnwrap(){let e=this.error;return function*(){throw yield E(e),new Error("Do not use this generator out of `safeTry`")}()}_unsafeUnwrap(e){throw N("Called `_unsafeUnwrap` on an Err",this,e)}_unsafeUnwrapErr(e){return this.error}*[Symbol.iterator](){let e=this;return yield e,e}},Ce=T.fromThrowable;var b=class extends Error{constructor(t,n={}){let{cause:o,context:i}=n;super(t,{cause:o});L(this,"context");this.name=this.constructor.name,this.context=i}};var S=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)};var V=he(X());var Y=new V.default;var ee=()=>{Y.once("SOCKET_OPENED",()=>{self.postMessage({event:"SOCKET_OPENED"})}),Y.once("OPERATION_FAILED",r=>{self.postMessage({event:"OPERATION_FAILED",error:r})})};var x=class extends b{};var P=class extends x{constructor(){super(...arguments);L(this,"message","Failed to remove the file")}};var re=!1;self.onmessage=r=>{re||(ee(),re=!0),De(r.data).map(()=>{self.postMessage({event:"FILE_REMOVED"})}).mapErr(e=>{self.postMessage({event:"OPERATION_FAILED",error:e})})};var De=r=>h.fromPromise(new Promise((e,t)=>{let n=r.args.lufiFile;fetch(`${new URL(n.serverUrl).href}d/${n.keys.server}/${n.actionToken}`).then(o=>o.ok?e(void 0):t(new P(void 0,{cause:S(o.statusText)})))}),e=>S(e));