cod-dicomweb-server 1.3.13 → 1.3.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cjs/main.js CHANGED
@@ -2014,7 +2014,7 @@ var filePartial = {
2014
2014
  });
2015
2015
  case 6:
2016
2016
  file = _context.sent;
2017
- if (!file) {
2017
+ if (!(file !== null && file !== void 0 && file.byteLength)) {
2018
2018
  _context.next = 11;
2019
2019
  break;
2020
2020
  }
@@ -2091,7 +2091,7 @@ var fileStreaming = {
2091
2091
  });
2092
2092
  case 9:
2093
2093
  file = _context.sent;
2094
- if (!file) {
2094
+ if (!(file !== null && file !== void 0 && file.byteLength)) {
2095
2095
  _context.next = 15;
2096
2096
  break;
2097
2097
  }
@@ -2279,7 +2279,7 @@ var CodDicomWebServer = /*#__PURE__*/function () {
2279
2279
  maxCacheSize: 4 * 1024 * 1024 * 1024,
2280
2280
  // 4GB
2281
2281
  domain: src_constants.url.DOMAIN,
2282
- enableLocalCache: false
2282
+ enableOPFSCache: false
2283
2283
  });
2284
2284
  CodDicomWebServer_defineProperty(this, "fileManager", void 0);
2285
2285
  CodDicomWebServer_defineProperty(this, "metadataManager", void 0);
@@ -2297,10 +2297,10 @@ var CodDicomWebServer = /*#__PURE__*/function () {
2297
2297
  var maxCacheSize = args.maxCacheSize,
2298
2298
  domain = args.domain,
2299
2299
  disableWorker = args.disableWorker,
2300
- enableLocalCache = args.enableLocalCache;
2300
+ enableOPFSCache = args.enableOPFSCache;
2301
2301
  this.options.maxCacheSize = maxCacheSize || this.options.maxCacheSize;
2302
2302
  this.options.domain = domain || this.options.domain;
2303
- this.options.enableLocalCache = !!enableLocalCache;
2303
+ this.options.enableOPFSCache = !!enableOPFSCache;
2304
2304
  var fileStreamingScriptName = src_constants.dataRetrieval.FILE_STREAMING_WORKER_NAME;
2305
2305
  var filePartialScriptName = src_constants.dataRetrieval.FILE_PARTIAL_WORKER_NAME;
2306
2306
  this.fileManager = new fileManager();
@@ -2535,7 +2535,7 @@ var CodDicomWebServer = /*#__PURE__*/function () {
2535
2535
  }
2536
2536
  }));
2537
2537
  case 5:
2538
- _context2.t0 = this.options.enableLocalCache;
2538
+ _context2.t0 = this.options.enableOPFSCache;
2539
2539
  if (!_context2.t0) {
2540
2540
  _context2.next = 10;
2541
2541
  break;
@@ -2562,7 +2562,7 @@ var CodDicomWebServer = /*#__PURE__*/function () {
2562
2562
  position = _evt$data.position,
2563
2563
  fileArraybuffer = _evt$data.fileArraybuffer;
2564
2564
  if (url === fileUrl && fileArraybuffer) {
2565
- if (_this3.options.enableLocalCache) {
2565
+ if (_this3.options.enableOPFSCache) {
2566
2566
  _this3.files[fileUrl] = fileArraybuffer;
2567
2567
  } else {
2568
2568
  _this3.fileManager.set(url, {
@@ -2600,7 +2600,7 @@ var CodDicomWebServer = /*#__PURE__*/function () {
2600
2600
  fileArraybuffer = _evt$data2.fileArraybuffer,
2601
2601
  offsets = _evt$data2.offsets;
2602
2602
  if (url === bytesRemovedUrl && offsets.startByte === startByte && offsets.endByte === endByte) {
2603
- if (_this3.options.enableLocalCache) {
2603
+ if (_this3.options.enableOPFSCache) {
2604
2604
  _this3.files[fileUrl] = fileArraybuffer;
2605
2605
  } else {
2606
2606
  _this3.fileManager.set(fileUrl, {
@@ -2654,7 +2654,7 @@ var CodDicomWebServer = /*#__PURE__*/function () {
2654
2654
  isAppending = _evt$data3.isAppending;
2655
2655
  if (isAppending) {
2656
2656
  if (chunk) {
2657
- if (_this3.options.enableLocalCache) {
2657
+ if (_this3.options.enableOPFSCache) {
2658
2658
  _this3.files[url].set(chunk, position - chunk.length);
2659
2659
  } else {
2660
2660
  _this3.fileManager.append(url, chunk, position);
@@ -2672,7 +2672,7 @@ var CodDicomWebServer = /*#__PURE__*/function () {
2672
2672
  }
2673
2673
  if (!requestResolved && url === fileUrl && position > offsets.endByte) {
2674
2674
  try {
2675
- var file = _this3.options.enableLocalCache ? _this3.files[url].slice(offsets.startByte, offsets.endByte) : _this3.fileManager.get(url, offsets);
2675
+ var file = _this3.options.enableOPFSCache ? _this3.files[url].slice(offsets.startByte, offsets.endByte) : _this3.fileManager.get(url, offsets);
2676
2676
  resolveRequest(file === null || file === void 0 ? void 0 : file.buffer);
2677
2677
  } catch (error) {
2678
2678
  rejectRequest(error);
@@ -2682,11 +2682,11 @@ var CodDicomWebServer = /*#__PURE__*/function () {
2682
2682
  }
2683
2683
  };
2684
2684
  var completeRequest = function completeRequest(url) {
2685
- var _this3$filePromises$u;
2685
+ var _this3$filePromises$u, _this3$filePromises$u2;
2686
2686
  requestResolved = true;
2687
- _this3.filePromises[url].requestCount--;
2688
- dataRetrievalManager.removeEventListener(FILE_STREAMING_WORKER_NAME, 'message', handleChunkAppend);
2689
- if (fileFetchingCompleted && _this3.filePromises[url] && !((_this3$filePromises$u = _this3.filePromises[url]) !== null && _this3$filePromises$u !== void 0 && _this3$filePromises$u.requestCount)) {
2687
+ ((_this3$filePromises$u = _this3.filePromises[url]) === null || _this3$filePromises$u === void 0 ? void 0 : _this3$filePromises$u.requestCount) && _this3.filePromises[url].requestCount--;
2688
+ if (fileFetchingCompleted && _this3.filePromises[url] && !((_this3$filePromises$u2 = _this3.filePromises[url]) !== null && _this3$filePromises$u2 !== void 0 && _this3$filePromises$u2.requestCount)) {
2689
+ dataRetrievalManager.removeEventListener(FILE_STREAMING_WORKER_NAME, 'message', handleChunkAppend);
2690
2690
  delete _this3.filePromises[url];
2691
2691
  delete _this3.files[url];
2692
2692
  }
@@ -2700,7 +2700,7 @@ var CodDicomWebServer = /*#__PURE__*/function () {
2700
2700
  if (_this3.fileManager.getPosition(fileUrl) || _this3.files[fileUrl]) {
2701
2701
  var _file;
2702
2702
  var file;
2703
- if (_this3.options.enableLocalCache) {
2703
+ if (_this3.options.enableOPFSCache) {
2704
2704
  file = isBytesOptimized || !offsets ? _this3.files[fileUrl] : _this3.files[fileUrl].slice(offsets.startByte, offsets.endByte);
2705
2705
  } else {
2706
2706
  file = _this3.fileManager.get(fileUrl, isBytesOptimized ? undefined : offsets);
@@ -11,7 +11,7 @@ declare class CodDicomWebServer {
11
11
  maxCacheSize?: number;
12
12
  domain?: string;
13
13
  disableWorker?: boolean;
14
- enableLocalCache?: boolean;
14
+ enableOPFSCache?: boolean;
15
15
  });
16
16
  setOptions: (newOptions: Partial<CodDicomWebServerOptions>) => void;
17
17
  getOptions: () => CodDicomWebServerOptions;
@@ -14,16 +14,16 @@ class CodDicomWebServer {
14
14
  options = {
15
15
  maxCacheSize: 4 * 1024 * 1024 * 1024,
16
16
  domain: constants.url.DOMAIN,
17
- enableLocalCache: false
17
+ enableOPFSCache: false
18
18
  };
19
19
  fileManager;
20
20
  metadataManager;
21
21
  seriesUidFileUrls = {};
22
22
  constructor(args = {}) {
23
- const { maxCacheSize, domain, disableWorker, enableLocalCache } = args;
23
+ const { maxCacheSize, domain, disableWorker, enableOPFSCache } = args;
24
24
  this.options.maxCacheSize = maxCacheSize || this.options.maxCacheSize;
25
25
  this.options.domain = domain || this.options.domain;
26
- this.options.enableLocalCache = !!enableLocalCache;
26
+ this.options.enableOPFSCache = !!enableOPFSCache;
27
27
  const fileStreamingScriptName = constants.dataRetrieval.FILE_STREAMING_WORKER_NAME;
28
28
  const filePartialScriptName = constants.dataRetrieval.FILE_PARTIAL_WORKER_NAME;
29
29
  this.fileManager = new FileManager();
@@ -163,7 +163,7 @@ class CodDicomWebServer {
163
163
  }
164
164
  });
165
165
  }
166
- const directoryHandle = this.options.enableLocalCache && (await getDirectoryHandle());
166
+ const directoryHandle = this.options.enableOPFSCache && (await getDirectoryHandle());
167
167
  const dataRetrievalManager = getDataRetrievalManager();
168
168
  const { FILE_STREAMING_WORKER_NAME, FILE_PARTIAL_WORKER_NAME } = constants.dataRetrieval;
169
169
  let tarPromise;
@@ -178,7 +178,7 @@ class CodDicomWebServer {
178
178
  }
179
179
  const { url, position, fileArraybuffer } = evt.data;
180
180
  if (url === fileUrl && fileArraybuffer) {
181
- if (this.options.enableLocalCache) {
181
+ if (this.options.enableOPFSCache) {
182
182
  this.files[fileUrl] = fileArraybuffer;
183
183
  }
184
184
  else {
@@ -215,7 +215,7 @@ class CodDicomWebServer {
215
215
  }
216
216
  const { url, fileArraybuffer, offsets } = evt.data;
217
217
  if (url === bytesRemovedUrl && offsets.startByte === startByte && offsets.endByte === endByte) {
218
- if (this.options.enableLocalCache) {
218
+ if (this.options.enableOPFSCache) {
219
219
  this.files[fileUrl] = fileArraybuffer;
220
220
  }
221
221
  else {
@@ -260,7 +260,7 @@ class CodDicomWebServer {
260
260
  const { url, position, chunk, totalLength, isAppending } = evt.data;
261
261
  if (isAppending) {
262
262
  if (chunk) {
263
- if (this.options.enableLocalCache) {
263
+ if (this.options.enableOPFSCache) {
264
264
  this.files[url].set(chunk, position - chunk.length);
265
265
  }
266
266
  else {
@@ -281,7 +281,7 @@ class CodDicomWebServer {
281
281
  }
282
282
  if (!requestResolved && url === fileUrl && position > offsets.endByte) {
283
283
  try {
284
- const file = this.options.enableLocalCache
284
+ const file = this.options.enableOPFSCache
285
285
  ? this.files[url].slice(offsets.startByte, offsets.endByte)
286
286
  : this.fileManager.get(url, offsets);
287
287
  resolveRequest(file?.buffer);
@@ -296,9 +296,9 @@ class CodDicomWebServer {
296
296
  };
297
297
  const completeRequest = (url) => {
298
298
  requestResolved = true;
299
- this.filePromises[url].requestCount--;
300
- dataRetrievalManager.removeEventListener(FILE_STREAMING_WORKER_NAME, 'message', handleChunkAppend);
299
+ this.filePromises[url]?.requestCount && this.filePromises[url].requestCount--;
301
300
  if (fileFetchingCompleted && this.filePromises[url] && !this.filePromises[url]?.requestCount) {
301
+ dataRetrievalManager.removeEventListener(FILE_STREAMING_WORKER_NAME, 'message', handleChunkAppend);
302
302
  delete this.filePromises[url];
303
303
  delete this.files[url];
304
304
  }
@@ -312,7 +312,7 @@ class CodDicomWebServer {
312
312
  if (!requestResolved) {
313
313
  if (this.fileManager.getPosition(fileUrl) || this.files[fileUrl]) {
314
314
  let file;
315
- if (this.options.enableLocalCache) {
315
+ if (this.options.enableOPFSCache) {
316
316
  file =
317
317
  isBytesOptimized || !offsets
318
318
  ? this.files[fileUrl]
@@ -9,7 +9,7 @@ const filePartial = {
9
9
  const storageName = createPartialFileName(url, offsets);
10
10
  if (directoryHandle) {
11
11
  const file = (await readFile(directoryHandle, storageName, { offsets, isJson: false }));
12
- if (file) {
12
+ if (file?.byteLength) {
13
13
  const fileBuffer = new Uint8Array(file);
14
14
  callBack({ url, fileArraybuffer: fileBuffer, offsets });
15
15
  return fileBuffer;
@@ -10,7 +10,7 @@ const fileStreaming = {
10
10
  const fileName = createStreamingFileName(url);
11
11
  if (directoryHandle) {
12
12
  const file = (await readFile(directoryHandle, fileName, { isJson: false }));
13
- if (file) {
13
+ if (file?.byteLength) {
14
14
  const totalLength = file.byteLength;
15
15
  const fileBuffer = new Uint8Array(file);
16
16
  callBack({ url, position: totalLength, fileArraybuffer: fileBuffer, totalLength });
@@ -2,6 +2,6 @@ type CodDicomWebServerOptions = {
2
2
  [key: string]: number | string | boolean;
3
3
  maxCacheSize: number;
4
4
  domain: string;
5
- enableLocalCache: boolean;
5
+ enableOPFSCache: boolean;
6
6
  };
7
7
  export type { CodDicomWebServerOptions };
package/dist/umd/563.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  *
3
- * cod-dicomweb-server v1.3.13
3
+ * cod-dicomweb-server v1.3.14
4
4
  * git+https://github.com/gradienthealth/cod-dicomweb-server.git
5
5
  *
6
6
  * Copyright (c) Adithyan Dinesh and project contributors.
@@ -15,5 +15,5 @@
15
15
  * Copyright 2019 Google LLC
16
16
  * SPDX-License-Identifier: Apache-2.0
17
17
  */
18
- const t=Symbol("Comlink.proxy"),e=Symbol("Comlink.endpoint"),r=Symbol("Comlink.releaseProxy"),n=Symbol("Comlink.finalizer"),o=Symbol("Comlink.thrown"),i=t=>"object"==typeof t&&null!==t||"function"==typeof t,a={canHandle:e=>i(e)&&e[t],serialize(t){const{port1:e,port2:r}=new MessageChannel;return u(t,e),[r,[r]]},deserialize:t=>(t.start(),function(t,e){const r=new Map;return t.addEventListener("message",(function(t){const{data:e}=t;if(!e||!e.id)return;const n=r.get(e.id);if(n)try{n(e)}finally{r.delete(e.id)}})),y(t,r,[],e)}(t))},c=new Map([["proxy",a],["throw",{canHandle:t=>i(t)&&o in t,serialize({value:t}){let e;return e=t instanceof Error?{isError:!0,value:{message:t.message,name:t.name,stack:t.stack}}:{isError:!1,value:t},[e,[]]},deserialize(t){if(t.isError)throw Object.assign(new Error(t.value.message),t.value);throw t.value}}]]);function u(e,r=globalThis,i=["*"]){r.addEventListener("message",(function a(c){if(!c||!c.data)return;if(!function(t,e){for(const r of t){if(e===r||"*"===r)return!0;if(r instanceof RegExp&&r.test(e))return!0}return!1}(i,c.origin))return void console.warn(`Invalid origin '${c.origin}' for comlink proxy`);const{id:f,type:l,path:p}=Object.assign({path:[]},c.data),h=(c.data.argumentList||[]).map(m);let y;try{const r=p.slice(0,-1).reduce(((t,e)=>t[e]),e),n=p.reduce(((t,e)=>t[e]),e);switch(l){case"GET":y=n;break;case"SET":r[p.slice(-1)[0]]=m(c.data.value),y=!0;break;case"APPLY":y=n.apply(r,h);break;case"CONSTRUCT":y=function(e){return Object.assign(e,{[t]:!0})}(new n(...h));break;case"ENDPOINT":{const{port1:t,port2:r}=new MessageChannel;u(e,r),y=function(t,e){return d.set(t,e),t}(t,[t])}break;case"RELEASE":y=void 0;break;default:return}}catch(t){y={value:t,[o]:0}}Promise.resolve(y).catch((t=>({value:t,[o]:0}))).then((t=>{const[o,i]=g(t);r.postMessage(Object.assign(Object.assign({},o),{id:f}),i),"RELEASE"===l&&(r.removeEventListener("message",a),s(r),n in e&&"function"==typeof e[n]&&e[n]())})).catch((t=>{const[e,n]=g({value:new TypeError("Unserializable return value"),[o]:0});r.postMessage(Object.assign(Object.assign({},e),{id:f}),n)}))})),r.start&&r.start()}function s(t){(function(t){return"MessagePort"===t.constructor.name})(t)&&t.close()}function f(t){if(t)throw new Error("Proxy has been released and is not useable")}function l(t){return b(t,new Map,{type:"RELEASE"}).then((()=>{s(t)}))}const p=new WeakMap,h="FinalizationRegistry"in globalThis&&new FinalizationRegistry((t=>{const e=(p.get(t)||0)-1;p.set(t,e),0===e&&l(t)}));function y(t,n,o=[],i=function(){}){let a=!1;const c=new Proxy(i,{get(e,i){if(f(a),i===r)return()=>{!function(t){h&&h.unregister(t)}(c),l(t),n.clear(),a=!0};if("then"===i){if(0===o.length)return{then:()=>c};const e=b(t,n,{type:"GET",path:o.map((t=>t.toString()))}).then(m);return e.then.bind(e)}return y(t,n,[...o,i])},set(e,r,i){f(a);const[c,u]=g(i);return b(t,n,{type:"SET",path:[...o,r].map((t=>t.toString())),value:c},u).then(m)},apply(r,i,c){f(a);const u=o[o.length-1];if(u===e)return b(t,n,{type:"ENDPOINT"}).then(m);if("bind"===u)return y(t,n,o.slice(0,-1));const[s,l]=v(c);return b(t,n,{type:"APPLY",path:o.map((t=>t.toString())),argumentList:s},l).then(m)},construct(e,r){f(a);const[i,c]=v(r);return b(t,n,{type:"CONSTRUCT",path:o.map((t=>t.toString())),argumentList:i},c).then(m)}});return function(t,e){const r=(p.get(e)||0)+1;p.set(e,r),h&&h.register(t,e,t)}(c,t),c}function v(t){const e=t.map(g);return[e.map((t=>t[0])),(r=e.map((t=>t[1])),Array.prototype.concat.apply([],r))];var r}const d=new WeakMap;function g(t){for(const[e,r]of c)if(r.canHandle(t)){const[n,o]=r.serialize(t);return[{type:"HANDLER",name:e,value:n},o]}return[{type:"RAW",value:t},d.get(t)||[]]}function m(t){switch(t.type){case"HANDLER":return c.get(t.name).deserialize(t.value);case"RAW":return t.value}}function b(t,e,r,n){return new Promise((o=>{const i=new Array(4).fill(0).map((()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16))).join("-");e.set(i,o),t.start&&t.start(),t.postMessage(Object.assign({id:i},r),n)}))}function w(t){return w="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},w(t)}function x(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,O(n.key),n)}}function E(t,e,r){return e&&x(t.prototype,e),r&&x(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function O(t){var e=function(t,e){if("object"!=w(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!=w(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==w(e)?e:e+""}function j(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function L(t,e,r){return e=T(e),function(t,e){if(e&&("object"==w(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,P()?Reflect.construct(e,r||[],T(t).constructor):e.apply(t,r))}function S(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&_(t,e)}function k(t){var e="function"==typeof Map?new Map:void 0;return k=function(t){if(null===t||!function(t){try{return-1!==Function.toString.call(t).indexOf("[native code]")}catch(e){return"function"==typeof t}}(t))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,r)}function r(){return function(t,e,r){if(P())return Reflect.construct.apply(null,arguments);var n=[null];n.push.apply(n,e);var o=new(t.bind.apply(t,n));return r&&_(o,r.prototype),o}(t,arguments,T(this).constructor)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),_(r,t)},k(t)}function P(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(P=function(){return!!t})()}function _(t,e){return _=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},_(t,e)}function T(t){return T=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},T(t)}var N=function(t){function e(){return j(this,e),L(this,e,arguments)}return S(e,t),E(e)}(k(Error)),A="partial";function F(t){return F="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},F(t)}function G(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */G=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(t,e,r){t[e]=r.value},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",c=i.asyncIterator||"@@asyncIterator",u=i.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,r){return t[e]=r}}function f(t,e,r,n){var i=e&&e.prototype instanceof g?e:g,a=Object.create(i.prototype),c=new T(n||[]);return o(a,"_invoke",{value:S(t,r,c)}),a}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var p="suspendedStart",h="suspendedYield",y="executing",v="completed",d={};function g(){}function m(){}function b(){}var w={};s(w,a,(function(){return this}));var x=Object.getPrototypeOf,E=x&&x(x(N([])));E&&E!==r&&n.call(E,a)&&(w=E);var O=b.prototype=g.prototype=Object.create(w);function j(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function L(t,e){function r(o,i,a,c){var u=l(t[o],t,i);if("throw"!==u.type){var s=u.arg,f=s.value;return f&&"object"==F(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,a,c)}),(function(t){r("throw",t,a,c)})):e.resolve(f).then((function(t){s.value=t,a(s)}),(function(t){return r("throw",t,a,c)}))}c(u.arg)}var i;o(this,"_invoke",{value:function(t,n){function o(){return new e((function(e,o){r(t,n,e,o)}))}return i=i?i.then(o,o):o()}})}function S(e,r,n){var o=p;return function(i,a){if(o===y)throw Error("Generator is already running");if(o===v){if("throw"===i)throw a;return{value:t,done:!0}}for(n.method=i,n.arg=a;;){var c=n.delegate;if(c){var u=k(c,n);if(u){if(u===d)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===p)throw o=v,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=y;var s=l(e,r,n);if("normal"===s.type){if(o=n.done?v:h,s.arg===d)continue;return{value:s.arg,done:n.done}}"throw"===s.type&&(o=v,n.method="throw",n.arg=s.arg)}}}function k(e,r){var n=r.method,o=e.iterator[n];if(o===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,k(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),d;var i=l(o,e.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,d;var a=i.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,d):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,d)}function P(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function _(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function T(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(P,this),this.reset(!0)}function N(e){if(e||""===e){var r=e[a];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var o=-1,i=function r(){for(;++o<e.length;)if(n.call(e,o))return r.value=e[o],r.done=!1,r;return r.value=t,r.done=!0,r};return i.next=i}}throw new TypeError(F(e)+" is not iterable")}return m.prototype=b,o(O,"constructor",{value:b,configurable:!0}),o(b,"constructor",{value:m,configurable:!0}),m.displayName=s(b,u,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===m||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,b):(t.__proto__=b,s(t,u,"GeneratorFunction")),t.prototype=Object.create(O),t},e.awrap=function(t){return{__await:t}},j(L.prototype),s(L.prototype,c,(function(){return this})),e.AsyncIterator=L,e.async=function(t,r,n,o,i){void 0===i&&(i=Promise);var a=new L(f(t,r,n,o),i);return e.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},j(O),s(O,u,"Generator"),s(O,a,(function(){return this})),s(O,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=N,T.prototype={constructor:T,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(_),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function o(n,o){return c.type="throw",c.arg=e,r.next=n,o&&(r.method="next",r.arg=t),!!o}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],c=a.completion;if("root"===a.tryLoc)return o("end");if(a.tryLoc<=this.prev){var u=n.call(a,"catchLoc"),s=n.call(a,"finallyLoc");if(u&&s){if(this.prev<a.catchLoc)return o(a.catchLoc,!0);if(this.prev<a.finallyLoc)return o(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return o(a.catchLoc,!0)}else{if(!s)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return o(a.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,d):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),d},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),_(r),d}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;_(r)}return o}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:N(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),d}},e}function R(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(t,e)||function(t,e){if(t){if("string"==typeof t)return M(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?M(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function M(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function I(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function C(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){I(i,n,o,a,c,"next",t)}function c(t){I(i,n,o,a,c,"throw",t)}a(void 0)}))}}function B(t,e){return D.apply(this,arguments)}function D(){return D=C(G().mark((function t(e,r){return G().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.getFileHandle(r).then((function(t){return t.getFile().then((function(t){return t.text()})).then((function(t){return JSON.parse(t)}))})).catch((function(){return null}));case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)}))),D.apply(this,arguments)}function H(t,e){return z.apply(this,arguments)}function z(){return z=C(G().mark((function t(e,r){return G().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.getFileHandle(r).then((function(t){return t.getFile().then((function(t){return t.arrayBuffer()}))})).catch((function(){return null}));case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)}))),z.apply(this,arguments)}function U(t,e){return Y.apply(this,arguments)}function Y(){return Y=C(G().mark((function t(e,r){var n,o,i,a,c,u=arguments;return G().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=u.length>2&&void 0!==u[2]?u[2]:{},r){t.next=3;break}return t.abrupt("return");case 3:o=r.split("/"),i=e,t.prev=5,a=0;case 7:if(!(a<o.length-1)){t.next=14;break}return t.next=10,i.getDirectoryHandle(o[a],{create:!0});case 10:i=t.sent;case 11:a++,t.next=7;break;case 14:if(c=o.at(-1),!n.isJson){t.next=19;break}return t.abrupt("return",B(i,c));case 19:return t.abrupt("return",H(i,c).catch(C(G().mark((function t(){var a,c,u;return G().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(console.warn("Error reading the file ".concat(r," from partial folder, trying from full file")),!n.offsets||!o.includes(A)){t.next=23;break}t.prev=2,o.splice(o.findIndex((function(t){return t===A})),1),i=e,a=0;case 6:if(!(a<o.length-1)){t.next=13;break}return t.next=9,i.getDirectoryHandle(o[a],{create:!0});case 9:i=t.sent;case 10:a++,t.next=6;break;case 13:return c=o.at(-1).split("_")[0]+".tar",t.next=16,H(i,c);case 16:return u=t.sent,t.abrupt("return",u.slice(n.offsets.startByte,n.offsets.endByte));case 20:t.prev=20,t.t0=t.catch(2),console.warn("Error reading the file ".concat(r,": ").concat(t.t0.message));case 23:case"end":return t.stop()}}),t,null,[[2,20]])})))));case 20:t.next=25;break;case 22:t.prev=22,t.t0=t.catch(5),console.warn("Error reading the file ".concat(r,": ").concat(t.t0.message));case 25:case"end":return t.stop()}}),t,null,[[5,22]])}))),Y.apply(this,arguments)}function W(t,e,r){return J.apply(this,arguments)}function J(){return J=C(G().mark((function t(e,r,n){var o,i,a,c,u,s,f,l=arguments;return G().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:o=l.length>3&&void 0!==l[3]&&l[3],t.prev=1,i=r.split("/"),a=e,c=0;case 5:if(!(c<i.length-1)){t.next=12;break}return t.next=8,a.getDirectoryHandle(i[c],{create:!0});case 8:a=t.sent;case 9:c++,t.next=5;break;case 12:return u=i.at(-1),t.next=15,a.getFileHandle(u,{create:!0});case 15:return s=t.sent,t.next=18,s.createWritable();case 18:if(f=t.sent,!o){t.next=24;break}return t.next=22,f.write(JSON.stringify(n));case 22:t.next=26;break;case 24:return t.next=26,f.write(n);case 26:return t.next=28,f.close();case 28:t.next=33;break;case 30:t.prev=30,t.t0=t.catch(1),console.warn("Error writing the file ".concat(r,": ").concat(t.t0.message));case 33:case"end":return t.stop()}}),t,null,[[1,30]])}))),J.apply(this,arguments)}function $(t){var e=new URL(t),r=e.pathname.match(/\/(.*?)\/studies/)[1],n=R(e.pathname.match(/studies\/(.*?)(\.tar|\/metadata.json)/)[1].split("/"),3),o=n[0],i=(n[1],n[2]);return"".concat(r,"/").concat(o,"/").concat(i)}function X(t,e){var r=t.match(/series\/(.*?).tar/)[1],n="".concat(e?"_".concat(null==e?void 0:e.startByte,"_").concat(null==e?void 0:e.endByte):"");return"".concat($(t),"/").concat(A,"/").concat(r).concat(n,".dcm")}function q(t){return q="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},q(t)}function K(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */K=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(t,e,r){t[e]=r.value},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",c=i.asyncIterator||"@@asyncIterator",u=i.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,r){return t[e]=r}}function f(t,e,r,n){var i=e&&e.prototype instanceof g?e:g,a=Object.create(i.prototype),c=new T(n||[]);return o(a,"_invoke",{value:S(t,r,c)}),a}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var p="suspendedStart",h="suspendedYield",y="executing",v="completed",d={};function g(){}function m(){}function b(){}var w={};s(w,a,(function(){return this}));var x=Object.getPrototypeOf,E=x&&x(x(N([])));E&&E!==r&&n.call(E,a)&&(w=E);var O=b.prototype=g.prototype=Object.create(w);function j(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function L(t,e){function r(o,i,a,c){var u=l(t[o],t,i);if("throw"!==u.type){var s=u.arg,f=s.value;return f&&"object"==q(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,a,c)}),(function(t){r("throw",t,a,c)})):e.resolve(f).then((function(t){s.value=t,a(s)}),(function(t){return r("throw",t,a,c)}))}c(u.arg)}var i;o(this,"_invoke",{value:function(t,n){function o(){return new e((function(e,o){r(t,n,e,o)}))}return i=i?i.then(o,o):o()}})}function S(e,r,n){var o=p;return function(i,a){if(o===y)throw Error("Generator is already running");if(o===v){if("throw"===i)throw a;return{value:t,done:!0}}for(n.method=i,n.arg=a;;){var c=n.delegate;if(c){var u=k(c,n);if(u){if(u===d)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===p)throw o=v,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=y;var s=l(e,r,n);if("normal"===s.type){if(o=n.done?v:h,s.arg===d)continue;return{value:s.arg,done:n.done}}"throw"===s.type&&(o=v,n.method="throw",n.arg=s.arg)}}}function k(e,r){var n=r.method,o=e.iterator[n];if(o===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,k(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),d;var i=l(o,e.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,d;var a=i.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,d):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,d)}function P(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function _(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function T(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(P,this),this.reset(!0)}function N(e){if(e||""===e){var r=e[a];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var o=-1,i=function r(){for(;++o<e.length;)if(n.call(e,o))return r.value=e[o],r.done=!1,r;return r.value=t,r.done=!0,r};return i.next=i}}throw new TypeError(q(e)+" is not iterable")}return m.prototype=b,o(O,"constructor",{value:b,configurable:!0}),o(b,"constructor",{value:m,configurable:!0}),m.displayName=s(b,u,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===m||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,b):(t.__proto__=b,s(t,u,"GeneratorFunction")),t.prototype=Object.create(O),t},e.awrap=function(t){return{__await:t}},j(L.prototype),s(L.prototype,c,(function(){return this})),e.AsyncIterator=L,e.async=function(t,r,n,o,i){void 0===i&&(i=Promise);var a=new L(f(t,r,n,o),i);return e.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},j(O),s(O,u,"Generator"),s(O,a,(function(){return this})),s(O,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=N,T.prototype={constructor:T,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(_),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function o(n,o){return c.type="throw",c.arg=e,r.next=n,o&&(r.method="next",r.arg=t),!!o}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],c=a.completion;if("root"===a.tryLoc)return o("end");if(a.tryLoc<=this.prev){var u=n.call(a,"catchLoc"),s=n.call(a,"finallyLoc");if(u&&s){if(this.prev<a.catchLoc)return o(a.catchLoc,!0);if(this.prev<a.finallyLoc)return o(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return o(a.catchLoc,!0)}else{if(!s)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return o(a.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,d):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),d},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),_(r),d}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;_(r)}return o}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:N(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),d}},e}function Q(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}var V={partial:function(t,e){return(r=K().mark((function r(){var n,o,i,a,c,u,s;return K().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(n=t.url,o=t.offsets,i=t.headers,a=t.directoryHandle,null!=o&&o.startByte&&null!=o&&o.endByte&&(i.Range="bytes=".concat(o.startByte,"-").concat(o.endByte-1)),c=X(n,o),!a){r.next=11;break}return r.next=6,U(a,c,{offsets:o,isJson:!1});case 6:if(!(u=r.sent)){r.next=11;break}return s=new Uint8Array(u),e({url:n,fileArraybuffer:s,offsets:o}),r.abrupt("return",s);case 11:return r.next=13,fetch(n,{headers:i}).then((function(t){return t.arrayBuffer()})).then((function(t){var r=new Uint8Array(t);return e({url:n,fileArraybuffer:r,offsets:o}),a&&W(a,c,t),r})).catch((function(t){throw new N("filePartial.ts: Error when fetching file: "+(null==t?void 0:t.message))}));case 13:return r.abrupt("return",r.sent);case 14:case"end":return r.stop()}}),r)})),function(){var t=this,e=arguments;return new Promise((function(n,o){var i=r.apply(t,e);function a(t){Q(i,n,o,a,c,"next",t)}function c(t){Q(i,n,o,a,c,"throw",t)}a(void 0)}))})();var r}};const Z=V;function tt(t){return tt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},tt(t)}function et(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function rt(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?et(Object(r),!0).forEach((function(e){nt(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):et(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function nt(t,e,r){return(e=function(t){var e=function(t,e){if("object"!=tt(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!=tt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==tt(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}return u(rt(rt({},Z),{},{partial:function(t){return Z.partial(t,postMessage)}})),{}})()));
18
+ const t=Symbol("Comlink.proxy"),e=Symbol("Comlink.endpoint"),r=Symbol("Comlink.releaseProxy"),n=Symbol("Comlink.finalizer"),o=Symbol("Comlink.thrown"),i=t=>"object"==typeof t&&null!==t||"function"==typeof t,a={canHandle:e=>i(e)&&e[t],serialize(t){const{port1:e,port2:r}=new MessageChannel;return u(t,e),[r,[r]]},deserialize:t=>(t.start(),function(t,e){const r=new Map;return t.addEventListener("message",(function(t){const{data:e}=t;if(!e||!e.id)return;const n=r.get(e.id);if(n)try{n(e)}finally{r.delete(e.id)}})),y(t,r,[],e)}(t))},c=new Map([["proxy",a],["throw",{canHandle:t=>i(t)&&o in t,serialize({value:t}){let e;return e=t instanceof Error?{isError:!0,value:{message:t.message,name:t.name,stack:t.stack}}:{isError:!1,value:t},[e,[]]},deserialize(t){if(t.isError)throw Object.assign(new Error(t.value.message),t.value);throw t.value}}]]);function u(e,r=globalThis,i=["*"]){r.addEventListener("message",(function a(c){if(!c||!c.data)return;if(!function(t,e){for(const r of t){if(e===r||"*"===r)return!0;if(r instanceof RegExp&&r.test(e))return!0}return!1}(i,c.origin))return void console.warn(`Invalid origin '${c.origin}' for comlink proxy`);const{id:f,type:l,path:p}=Object.assign({path:[]},c.data),h=(c.data.argumentList||[]).map(m);let y;try{const r=p.slice(0,-1).reduce(((t,e)=>t[e]),e),n=p.reduce(((t,e)=>t[e]),e);switch(l){case"GET":y=n;break;case"SET":r[p.slice(-1)[0]]=m(c.data.value),y=!0;break;case"APPLY":y=n.apply(r,h);break;case"CONSTRUCT":y=function(e){return Object.assign(e,{[t]:!0})}(new n(...h));break;case"ENDPOINT":{const{port1:t,port2:r}=new MessageChannel;u(e,r),y=function(t,e){return d.set(t,e),t}(t,[t])}break;case"RELEASE":y=void 0;break;default:return}}catch(t){y={value:t,[o]:0}}Promise.resolve(y).catch((t=>({value:t,[o]:0}))).then((t=>{const[o,i]=g(t);r.postMessage(Object.assign(Object.assign({},o),{id:f}),i),"RELEASE"===l&&(r.removeEventListener("message",a),s(r),n in e&&"function"==typeof e[n]&&e[n]())})).catch((t=>{const[e,n]=g({value:new TypeError("Unserializable return value"),[o]:0});r.postMessage(Object.assign(Object.assign({},e),{id:f}),n)}))})),r.start&&r.start()}function s(t){(function(t){return"MessagePort"===t.constructor.name})(t)&&t.close()}function f(t){if(t)throw new Error("Proxy has been released and is not useable")}function l(t){return b(t,new Map,{type:"RELEASE"}).then((()=>{s(t)}))}const p=new WeakMap,h="FinalizationRegistry"in globalThis&&new FinalizationRegistry((t=>{const e=(p.get(t)||0)-1;p.set(t,e),0===e&&l(t)}));function y(t,n,o=[],i=function(){}){let a=!1;const c=new Proxy(i,{get(e,i){if(f(a),i===r)return()=>{!function(t){h&&h.unregister(t)}(c),l(t),n.clear(),a=!0};if("then"===i){if(0===o.length)return{then:()=>c};const e=b(t,n,{type:"GET",path:o.map((t=>t.toString()))}).then(m);return e.then.bind(e)}return y(t,n,[...o,i])},set(e,r,i){f(a);const[c,u]=g(i);return b(t,n,{type:"SET",path:[...o,r].map((t=>t.toString())),value:c},u).then(m)},apply(r,i,c){f(a);const u=o[o.length-1];if(u===e)return b(t,n,{type:"ENDPOINT"}).then(m);if("bind"===u)return y(t,n,o.slice(0,-1));const[s,l]=v(c);return b(t,n,{type:"APPLY",path:o.map((t=>t.toString())),argumentList:s},l).then(m)},construct(e,r){f(a);const[i,c]=v(r);return b(t,n,{type:"CONSTRUCT",path:o.map((t=>t.toString())),argumentList:i},c).then(m)}});return function(t,e){const r=(p.get(e)||0)+1;p.set(e,r),h&&h.register(t,e,t)}(c,t),c}function v(t){const e=t.map(g);return[e.map((t=>t[0])),(r=e.map((t=>t[1])),Array.prototype.concat.apply([],r))];var r}const d=new WeakMap;function g(t){for(const[e,r]of c)if(r.canHandle(t)){const[n,o]=r.serialize(t);return[{type:"HANDLER",name:e,value:n},o]}return[{type:"RAW",value:t},d.get(t)||[]]}function m(t){switch(t.type){case"HANDLER":return c.get(t.name).deserialize(t.value);case"RAW":return t.value}}function b(t,e,r,n){return new Promise((o=>{const i=new Array(4).fill(0).map((()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16))).join("-");e.set(i,o),t.start&&t.start(),t.postMessage(Object.assign({id:i},r),n)}))}function w(t){return w="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},w(t)}function x(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,O(n.key),n)}}function E(t,e,r){return e&&x(t.prototype,e),r&&x(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function O(t){var e=function(t,e){if("object"!=w(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!=w(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==w(e)?e:e+""}function j(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function L(t,e,r){return e=T(e),function(t,e){if(e&&("object"==w(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,P()?Reflect.construct(e,r||[],T(t).constructor):e.apply(t,r))}function S(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&_(t,e)}function k(t){var e="function"==typeof Map?new Map:void 0;return k=function(t){if(null===t||!function(t){try{return-1!==Function.toString.call(t).indexOf("[native code]")}catch(e){return"function"==typeof t}}(t))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,r)}function r(){return function(t,e,r){if(P())return Reflect.construct.apply(null,arguments);var n=[null];n.push.apply(n,e);var o=new(t.bind.apply(t,n));return r&&_(o,r.prototype),o}(t,arguments,T(this).constructor)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),_(r,t)},k(t)}function P(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(P=function(){return!!t})()}function _(t,e){return _=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},_(t,e)}function T(t){return T=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},T(t)}var N=function(t){function e(){return j(this,e),L(this,e,arguments)}return S(e,t),E(e)}(k(Error)),A="partial";function F(t){return F="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},F(t)}function G(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */G=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(t,e,r){t[e]=r.value},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",c=i.asyncIterator||"@@asyncIterator",u=i.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,r){return t[e]=r}}function f(t,e,r,n){var i=e&&e.prototype instanceof g?e:g,a=Object.create(i.prototype),c=new T(n||[]);return o(a,"_invoke",{value:S(t,r,c)}),a}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var p="suspendedStart",h="suspendedYield",y="executing",v="completed",d={};function g(){}function m(){}function b(){}var w={};s(w,a,(function(){return this}));var x=Object.getPrototypeOf,E=x&&x(x(N([])));E&&E!==r&&n.call(E,a)&&(w=E);var O=b.prototype=g.prototype=Object.create(w);function j(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function L(t,e){function r(o,i,a,c){var u=l(t[o],t,i);if("throw"!==u.type){var s=u.arg,f=s.value;return f&&"object"==F(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,a,c)}),(function(t){r("throw",t,a,c)})):e.resolve(f).then((function(t){s.value=t,a(s)}),(function(t){return r("throw",t,a,c)}))}c(u.arg)}var i;o(this,"_invoke",{value:function(t,n){function o(){return new e((function(e,o){r(t,n,e,o)}))}return i=i?i.then(o,o):o()}})}function S(e,r,n){var o=p;return function(i,a){if(o===y)throw Error("Generator is already running");if(o===v){if("throw"===i)throw a;return{value:t,done:!0}}for(n.method=i,n.arg=a;;){var c=n.delegate;if(c){var u=k(c,n);if(u){if(u===d)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===p)throw o=v,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=y;var s=l(e,r,n);if("normal"===s.type){if(o=n.done?v:h,s.arg===d)continue;return{value:s.arg,done:n.done}}"throw"===s.type&&(o=v,n.method="throw",n.arg=s.arg)}}}function k(e,r){var n=r.method,o=e.iterator[n];if(o===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,k(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),d;var i=l(o,e.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,d;var a=i.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,d):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,d)}function P(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function _(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function T(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(P,this),this.reset(!0)}function N(e){if(e||""===e){var r=e[a];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var o=-1,i=function r(){for(;++o<e.length;)if(n.call(e,o))return r.value=e[o],r.done=!1,r;return r.value=t,r.done=!0,r};return i.next=i}}throw new TypeError(F(e)+" is not iterable")}return m.prototype=b,o(O,"constructor",{value:b,configurable:!0}),o(b,"constructor",{value:m,configurable:!0}),m.displayName=s(b,u,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===m||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,b):(t.__proto__=b,s(t,u,"GeneratorFunction")),t.prototype=Object.create(O),t},e.awrap=function(t){return{__await:t}},j(L.prototype),s(L.prototype,c,(function(){return this})),e.AsyncIterator=L,e.async=function(t,r,n,o,i){void 0===i&&(i=Promise);var a=new L(f(t,r,n,o),i);return e.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},j(O),s(O,u,"Generator"),s(O,a,(function(){return this})),s(O,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=N,T.prototype={constructor:T,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(_),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function o(n,o){return c.type="throw",c.arg=e,r.next=n,o&&(r.method="next",r.arg=t),!!o}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],c=a.completion;if("root"===a.tryLoc)return o("end");if(a.tryLoc<=this.prev){var u=n.call(a,"catchLoc"),s=n.call(a,"finallyLoc");if(u&&s){if(this.prev<a.catchLoc)return o(a.catchLoc,!0);if(this.prev<a.finallyLoc)return o(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return o(a.catchLoc,!0)}else{if(!s)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return o(a.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,d):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),d},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),_(r),d}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;_(r)}return o}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:N(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),d}},e}function R(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(t,e)||function(t,e){if(t){if("string"==typeof t)return M(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?M(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function M(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function I(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function C(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){I(i,n,o,a,c,"next",t)}function c(t){I(i,n,o,a,c,"throw",t)}a(void 0)}))}}function B(t,e){return D.apply(this,arguments)}function D(){return D=C(G().mark((function t(e,r){return G().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.getFileHandle(r).then((function(t){return t.getFile().then((function(t){return t.text()})).then((function(t){return JSON.parse(t)}))})).catch((function(){return null}));case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)}))),D.apply(this,arguments)}function H(t,e){return z.apply(this,arguments)}function z(){return z=C(G().mark((function t(e,r){return G().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.getFileHandle(r).then((function(t){return t.getFile().then((function(t){return t.arrayBuffer()}))})).catch((function(){return null}));case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)}))),z.apply(this,arguments)}function U(t,e){return Y.apply(this,arguments)}function Y(){return Y=C(G().mark((function t(e,r){var n,o,i,a,c,u=arguments;return G().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=u.length>2&&void 0!==u[2]?u[2]:{},r){t.next=3;break}return t.abrupt("return");case 3:o=r.split("/"),i=e,t.prev=5,a=0;case 7:if(!(a<o.length-1)){t.next=14;break}return t.next=10,i.getDirectoryHandle(o[a],{create:!0});case 10:i=t.sent;case 11:a++,t.next=7;break;case 14:if(c=o.at(-1),!n.isJson){t.next=19;break}return t.abrupt("return",B(i,c));case 19:return t.abrupt("return",H(i,c).catch(C(G().mark((function t(){var a,c,u;return G().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(console.warn("Error reading the file ".concat(r," from partial folder, trying from full file")),!n.offsets||!o.includes(A)){t.next=23;break}t.prev=2,o.splice(o.findIndex((function(t){return t===A})),1),i=e,a=0;case 6:if(!(a<o.length-1)){t.next=13;break}return t.next=9,i.getDirectoryHandle(o[a],{create:!0});case 9:i=t.sent;case 10:a++,t.next=6;break;case 13:return c=o.at(-1).split("_")[0]+".tar",t.next=16,H(i,c);case 16:return u=t.sent,t.abrupt("return",u.slice(n.offsets.startByte,n.offsets.endByte));case 20:t.prev=20,t.t0=t.catch(2),console.warn("Error reading the file ".concat(r,": ").concat(t.t0.message));case 23:case"end":return t.stop()}}),t,null,[[2,20]])})))));case 20:t.next=25;break;case 22:t.prev=22,t.t0=t.catch(5),console.warn("Error reading the file ".concat(r,": ").concat(t.t0.message));case 25:case"end":return t.stop()}}),t,null,[[5,22]])}))),Y.apply(this,arguments)}function W(t,e,r){return J.apply(this,arguments)}function J(){return J=C(G().mark((function t(e,r,n){var o,i,a,c,u,s,f,l=arguments;return G().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:o=l.length>3&&void 0!==l[3]&&l[3],t.prev=1,i=r.split("/"),a=e,c=0;case 5:if(!(c<i.length-1)){t.next=12;break}return t.next=8,a.getDirectoryHandle(i[c],{create:!0});case 8:a=t.sent;case 9:c++,t.next=5;break;case 12:return u=i.at(-1),t.next=15,a.getFileHandle(u,{create:!0});case 15:return s=t.sent,t.next=18,s.createWritable();case 18:if(f=t.sent,!o){t.next=24;break}return t.next=22,f.write(JSON.stringify(n));case 22:t.next=26;break;case 24:return t.next=26,f.write(n);case 26:return t.next=28,f.close();case 28:t.next=33;break;case 30:t.prev=30,t.t0=t.catch(1),console.warn("Error writing the file ".concat(r,": ").concat(t.t0.message));case 33:case"end":return t.stop()}}),t,null,[[1,30]])}))),J.apply(this,arguments)}function $(t){var e=new URL(t),r=e.pathname.match(/\/(.*?)\/studies/)[1],n=R(e.pathname.match(/studies\/(.*?)(\.tar|\/metadata.json)/)[1].split("/"),3),o=n[0],i=(n[1],n[2]);return"".concat(r,"/").concat(o,"/").concat(i)}function X(t,e){var r=t.match(/series\/(.*?).tar/)[1],n="".concat(e?"_".concat(null==e?void 0:e.startByte,"_").concat(null==e?void 0:e.endByte):"");return"".concat($(t),"/").concat(A,"/").concat(r).concat(n,".dcm")}function q(t){return q="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},q(t)}function K(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */K=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(t,e,r){t[e]=r.value},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",c=i.asyncIterator||"@@asyncIterator",u=i.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,r){return t[e]=r}}function f(t,e,r,n){var i=e&&e.prototype instanceof g?e:g,a=Object.create(i.prototype),c=new T(n||[]);return o(a,"_invoke",{value:S(t,r,c)}),a}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var p="suspendedStart",h="suspendedYield",y="executing",v="completed",d={};function g(){}function m(){}function b(){}var w={};s(w,a,(function(){return this}));var x=Object.getPrototypeOf,E=x&&x(x(N([])));E&&E!==r&&n.call(E,a)&&(w=E);var O=b.prototype=g.prototype=Object.create(w);function j(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function L(t,e){function r(o,i,a,c){var u=l(t[o],t,i);if("throw"!==u.type){var s=u.arg,f=s.value;return f&&"object"==q(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,a,c)}),(function(t){r("throw",t,a,c)})):e.resolve(f).then((function(t){s.value=t,a(s)}),(function(t){return r("throw",t,a,c)}))}c(u.arg)}var i;o(this,"_invoke",{value:function(t,n){function o(){return new e((function(e,o){r(t,n,e,o)}))}return i=i?i.then(o,o):o()}})}function S(e,r,n){var o=p;return function(i,a){if(o===y)throw Error("Generator is already running");if(o===v){if("throw"===i)throw a;return{value:t,done:!0}}for(n.method=i,n.arg=a;;){var c=n.delegate;if(c){var u=k(c,n);if(u){if(u===d)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===p)throw o=v,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=y;var s=l(e,r,n);if("normal"===s.type){if(o=n.done?v:h,s.arg===d)continue;return{value:s.arg,done:n.done}}"throw"===s.type&&(o=v,n.method="throw",n.arg=s.arg)}}}function k(e,r){var n=r.method,o=e.iterator[n];if(o===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,k(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),d;var i=l(o,e.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,d;var a=i.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,d):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,d)}function P(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function _(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function T(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(P,this),this.reset(!0)}function N(e){if(e||""===e){var r=e[a];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var o=-1,i=function r(){for(;++o<e.length;)if(n.call(e,o))return r.value=e[o],r.done=!1,r;return r.value=t,r.done=!0,r};return i.next=i}}throw new TypeError(q(e)+" is not iterable")}return m.prototype=b,o(O,"constructor",{value:b,configurable:!0}),o(b,"constructor",{value:m,configurable:!0}),m.displayName=s(b,u,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===m||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,b):(t.__proto__=b,s(t,u,"GeneratorFunction")),t.prototype=Object.create(O),t},e.awrap=function(t){return{__await:t}},j(L.prototype),s(L.prototype,c,(function(){return this})),e.AsyncIterator=L,e.async=function(t,r,n,o,i){void 0===i&&(i=Promise);var a=new L(f(t,r,n,o),i);return e.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},j(O),s(O,u,"Generator"),s(O,a,(function(){return this})),s(O,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=N,T.prototype={constructor:T,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(_),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function o(n,o){return c.type="throw",c.arg=e,r.next=n,o&&(r.method="next",r.arg=t),!!o}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],c=a.completion;if("root"===a.tryLoc)return o("end");if(a.tryLoc<=this.prev){var u=n.call(a,"catchLoc"),s=n.call(a,"finallyLoc");if(u&&s){if(this.prev<a.catchLoc)return o(a.catchLoc,!0);if(this.prev<a.finallyLoc)return o(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return o(a.catchLoc,!0)}else{if(!s)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return o(a.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,d):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),d},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),_(r),d}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;_(r)}return o}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:N(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),d}},e}function Q(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}var V={partial:function(t,e){return(r=K().mark((function r(){var n,o,i,a,c,u,s;return K().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(n=t.url,o=t.offsets,i=t.headers,a=t.directoryHandle,null!=o&&o.startByte&&null!=o&&o.endByte&&(i.Range="bytes=".concat(o.startByte,"-").concat(o.endByte-1)),c=X(n,o),!a){r.next=11;break}return r.next=6,U(a,c,{offsets:o,isJson:!1});case 6:if(null==(u=r.sent)||!u.byteLength){r.next=11;break}return s=new Uint8Array(u),e({url:n,fileArraybuffer:s,offsets:o}),r.abrupt("return",s);case 11:return r.next=13,fetch(n,{headers:i}).then((function(t){return t.arrayBuffer()})).then((function(t){var r=new Uint8Array(t);return e({url:n,fileArraybuffer:r,offsets:o}),a&&W(a,c,t),r})).catch((function(t){throw new N("filePartial.ts: Error when fetching file: "+(null==t?void 0:t.message))}));case 13:return r.abrupt("return",r.sent);case 14:case"end":return r.stop()}}),r)})),function(){var t=this,e=arguments;return new Promise((function(n,o){var i=r.apply(t,e);function a(t){Q(i,n,o,a,c,"next",t)}function c(t){Q(i,n,o,a,c,"throw",t)}a(void 0)}))})();var r}};const Z=V;function tt(t){return tt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},tt(t)}function et(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function rt(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?et(Object(r),!0).forEach((function(e){nt(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):et(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function nt(t,e,r){return(e=function(t){var e=function(t,e){if("object"!=tt(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!=tt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==tt(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}return u(rt(rt({},Z),{},{partial:function(t){return Z.partial(t,postMessage)}})),{}})()));
19
19
  //# sourceMappingURL=563.js.map