cod-dicomweb-server 1.3.9 → 1.3.10

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.
@@ -8,7 +8,7 @@ const filePartial = {
8
8
  }
9
9
  const storageName = createPartialFileName(url, offsets);
10
10
  if (directoryHandle) {
11
- const file = await readFile(directoryHandle, storageName, offsets);
11
+ const file = (await readFile(directoryHandle, storageName, { offsets, isJson: false }));
12
12
  if (file) {
13
13
  callBack({ url, fileArraybuffer: new Uint8Array(file), offsets });
14
14
  return;
@@ -21,7 +21,7 @@ const fileStreaming = {
21
21
  try {
22
22
  const fileName = createStreamingFileName(url);
23
23
  if (directoryHandle) {
24
- const file = await readFile(directoryHandle, fileName);
24
+ const file = (await readFile(directoryHandle, fileName, { isJson: false }));
25
25
  if (file) {
26
26
  callBack({ url, position: file.byteLength, fileArraybuffer: new Uint8Array(file) });
27
27
  return;
@@ -1,13 +1,19 @@
1
+ import { JsonMetadata } from './types';
1
2
  export declare function getDirectoryHandle(): Promise<FileSystemDirectoryHandle>;
2
- export declare function readFile(directoryHandle: FileSystemDirectoryHandle, name: string, offsets?: {
3
- startByte: number;
4
- endByte: number;
5
- }): Promise<ArrayBuffer>;
6
- export declare function writeFile(directoryHandle: FileSystemDirectoryHandle, name: string, file: ArrayBuffer): Promise<void>;
3
+ export declare function readFile(directoryHandle: FileSystemDirectoryHandle, name: string, options?: {
4
+ isJson?: boolean;
5
+ offsets?: {
6
+ startByte: number;
7
+ endByte: number;
8
+ };
9
+ }): Promise<ArrayBuffer | JsonMetadata>;
10
+ export declare function writeFile(directoryHandle: FileSystemDirectoryHandle, name: string, file: ArrayBuffer | JsonMetadata, isJson?: boolean): Promise<void>;
7
11
  export declare function download(fileName: string, file: ArrayBuffer): boolean;
8
12
  export declare function clearPartialFiles(): Promise<void>;
13
+ export declare function parseCachePath(url: string): string;
9
14
  export declare function createStreamingFileName(url: string): string;
10
15
  export declare function createPartialFileName(url: string, offsets?: {
11
16
  startByte: number;
12
17
  endByte: number;
13
18
  }): string;
19
+ export declare function createMetadataFileName(url: string): string;
@@ -15,51 +15,77 @@ export async function getDirectoryHandle() {
15
15
  console.warn(`Error getting directoryhandle: ${error.message}`);
16
16
  }
17
17
  }
18
- export async function readFile(directoryHandle, name, offsets) {
18
+ async function readJsonFile(directoryHandle, name) {
19
+ return await directoryHandle
20
+ .getFileHandle(name)
21
+ .then((fileHandle) => fileHandle
22
+ .getFile()
23
+ .then((file) => file.text())
24
+ .then((metadataString) => JSON.parse(metadataString)))
25
+ .catch(() => null);
26
+ }
27
+ async function readArrayBufferFile(directoryHandle, name) {
28
+ return await directoryHandle
29
+ .getFileHandle(name)
30
+ .then((fileHandle) => fileHandle.getFile().then((file) => file.arrayBuffer()))
31
+ .catch(() => null);
32
+ }
33
+ export async function readFile(directoryHandle, name, options = {}) {
19
34
  if (!name) {
20
35
  return;
21
36
  }
22
- let pathParts = name.split('/');
37
+ const pathParts = name.split('/');
23
38
  let currentDir = directoryHandle;
24
39
  try {
25
40
  for (let i = 0; i < pathParts.length - 1; i++) {
26
- currentDir = await currentDir.getDirectoryHandle(pathParts[i]);
41
+ currentDir = await currentDir.getDirectoryHandle(pathParts[i], { create: true });
27
42
  }
28
43
  const fileName = pathParts.at(-1);
29
- const fileHandle = await currentDir.getFileHandle(fileName);
30
- return await fileHandle.getFile().then((file) => file.arrayBuffer());
44
+ if (options.isJson) {
45
+ return readJsonFile(currentDir, fileName);
46
+ }
47
+ else {
48
+ return readArrayBufferFile(currentDir, fileName).catch(async () => {
49
+ console.warn(`Error reading the file ${name} from partial folder, trying from full file`);
50
+ if (options.offsets && pathParts.includes(FILE_SYSTEM_ROUTES.Partial)) {
51
+ try {
52
+ pathParts.splice(pathParts.findIndex((part) => part === FILE_SYSTEM_ROUTES.Partial), 1);
53
+ currentDir = directoryHandle;
54
+ for (let i = 0; i < pathParts.length - 1; i++) {
55
+ currentDir = await currentDir.getDirectoryHandle(pathParts[i], { create: true });
56
+ }
57
+ const convertedFileName = pathParts.at(-1).split('_')[0] + '.tar';
58
+ const fileArraybuffer = await readArrayBufferFile(currentDir, convertedFileName);
59
+ return fileArraybuffer.slice(options.offsets.startByte, options.offsets.endByte);
60
+ }
61
+ catch (error) {
62
+ console.warn(`Error reading the file ${name}: ${error.message}`);
63
+ }
64
+ }
65
+ });
66
+ }
31
67
  }
32
68
  catch (error) {
33
69
  console.warn(`Error reading the file ${name}: ${error.message}`);
34
- if (offsets && pathParts[0] === FILE_SYSTEM_ROUTES.Partial) {
35
- try {
36
- const seriesInstanceUID = pathParts.at(-1).slice(0, name.lastIndexOf('.')).split('_')[0];
37
- pathParts = pathParts.slice(1);
38
- for (let i = 0; i < pathParts.length - 1; i++) {
39
- currentDir = await currentDir.getDirectoryHandle(pathParts[i]);
40
- }
41
- const fileHandle = await directoryHandle.getFileHandle(seriesInstanceUID + '.tar');
42
- const fileArraybuffer = await fileHandle.getFile().then((file) => file.arrayBuffer());
43
- return fileArraybuffer.slice(offsets.startByte, offsets.endByte);
44
- }
45
- catch (error) {
46
- console.warn(`Error reading the file ${name}: ${error.message}`);
47
- }
48
- }
49
70
  }
50
71
  }
51
- export async function writeFile(directoryHandle, name, file) {
72
+ export async function writeFile(directoryHandle, name, file, isJson = false) {
52
73
  try {
53
74
  const pathParts = name.split('/');
54
75
  let currentDir = directoryHandle;
55
76
  for (let i = 0; i < pathParts.length - 1; i++) {
56
77
  currentDir = await currentDir.getDirectoryHandle(pathParts[i], { create: true });
57
78
  }
58
- const fileName = pathParts[pathParts.length - 1];
79
+ const fileName = pathParts.at(-1);
59
80
  const fileHandle = await currentDir.getFileHandle(fileName, { create: true });
60
81
  // @ts-ignore
61
82
  const fileWritable = await fileHandle.createWritable();
62
- await fileWritable.write(file);
83
+ if (isJson) {
84
+ await fileWritable.write(JSON.stringify(file));
85
+ }
86
+ else {
87
+ await fileWritable.write(file);
88
+ }
63
89
  await fileWritable.close();
64
90
  }
65
91
  catch (error) {
@@ -83,18 +109,41 @@ export function download(fileName, file) {
83
109
  }
84
110
  }
85
111
  export async function clearPartialFiles() {
112
+ const removePartialFolder = async (dirHandle) => {
113
+ // @ts-ignore
114
+ for await (const [name, handle] of dirHandle.entries()) {
115
+ if (handle.kind === 'directory') {
116
+ if (name.toLowerCase() === FILE_SYSTEM_ROUTES.Partial) {
117
+ await dirHandle.removeEntry(name, { recursive: true }).catch((e) => console.warn(`Failed to remove ${name}:`, e));
118
+ }
119
+ else {
120
+ // Recurse into other directories
121
+ await removePartialFolder(handle);
122
+ }
123
+ }
124
+ }
125
+ };
86
126
  try {
87
- await directoryHandle.removeEntry(FILE_SYSTEM_ROUTES.Partial, { recursive: true });
127
+ await removePartialFolder(directoryHandle);
88
128
  }
89
129
  catch (error) {
90
130
  console.warn(`Error clearing partial files: ${error.message}`);
91
131
  }
92
132
  }
133
+ export function parseCachePath(url) {
134
+ const urlObj = new URL(url);
135
+ const bucketPath = urlObj.pathname.match(/\/(.*?)\/studies/)[1];
136
+ const [studyInstanceUID, _, seriesInstanceUID] = urlObj.pathname.match(/studies\/(.*?)(\.tar|\/metadata.json)/)[1].split('/');
137
+ return `${bucketPath}/${studyInstanceUID}/${seriesInstanceUID}`;
138
+ }
93
139
  export function createStreamingFileName(url) {
94
- return url.split('series/')[1];
140
+ return `${parseCachePath(url)}/${url.split('series/')[1]}`;
95
141
  }
96
142
  export function createPartialFileName(url, offsets) {
97
- const seriesInstanceUID = url.split('series/')[1].split('.tar')[0];
143
+ const seriesInstanceUID = url.match(/series\/(.*?).tar/)[1];
98
144
  const offsetPart = `${offsets ? `_${offsets?.startByte}_${offsets?.endByte}` : ''}`;
99
- return `${FILE_SYSTEM_ROUTES.Partial}/${seriesInstanceUID}${offsetPart}.dcm`;
145
+ return `${parseCachePath(url)}/${FILE_SYSTEM_ROUTES.Partial}/${seriesInstanceUID}${offsetPart}.dcm`;
146
+ }
147
+ export function createMetadataFileName(url) {
148
+ return `${parseCachePath(url)}/metadata.json`;
100
149
  }
@@ -1,5 +1,6 @@
1
1
  import { CustomError } from './classes/customClasses';
2
2
  import { createMetadataJsonUrl } from './classes/utils';
3
+ import { createMetadataFileName, getDirectoryHandle, readFile, writeFile } from './fileAccessSystemUtils';
3
4
  class MetadataManager {
4
5
  metadataPromises = {};
5
6
  constructor() { }
@@ -29,6 +30,12 @@ class MetadataManager {
29
30
  if (cachedMetadata) {
30
31
  return await cachedMetadata;
31
32
  }
33
+ const directoryHandle = await getDirectoryHandle();
34
+ const fileName = createMetadataFileName(url);
35
+ const locallyCachedMetadata = (await readFile(directoryHandle, fileName, { isJson: true }));
36
+ if (locallyCachedMetadata) {
37
+ return locallyCachedMetadata;
38
+ }
32
39
  try {
33
40
  this.metadataPromises[url] = fetch(url, { headers })
34
41
  .then((response) => {
@@ -39,7 +46,7 @@ class MetadataManager {
39
46
  })
40
47
  .then((data) => {
41
48
  this.addDeidMetadata(data, url);
42
- return data;
49
+ return writeFile(directoryHandle, fileName, data, true).then(() => data);
43
50
  });
44
51
  return await this.metadataPromises[url];
45
52
  }
package/dist/umd/563.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  *
3
- * cod-dicomweb-server v1.3.9
3
+ * cod-dicomweb-server v1.3.10
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 L(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function j(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,k()?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 P(t){var e="function"==typeof Map?new Map:void 0;return P=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(k())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)},P(t)}function k(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(k=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 L(this,e),j(this,e,arguments)}return S(e,t),E(e)}(P(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 L(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function j(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=P(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 P(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,P(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 k(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(k,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}},L(j.prototype),s(j.prototype,c,(function(){return this})),e.AsyncIterator=j,e.async=function(t,r,n,o,i){void 0===i&&(i=Promise);var a=new j(f(t,r,n,o),i);return e.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},L(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,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 M(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){R(i,n,o,a,c,"next",t)}function c(t){R(i,n,o,a,c,"throw",t)}a(void 0)}))}}function B(t,e,r){return C.apply(this,arguments)}function C(){return C=M(G().mark((function t(e,r,n){var o,i,a,c,u,s,f,l,p;return G().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r){t.next=2;break}return t.abrupt("return");case 2:o=r.split("/"),i=e,t.prev=4,a=0;case 6:if(!(a<o.length-1)){t.next=13;break}return t.next=9,i.getDirectoryHandle(o[a]);case 9:i=t.sent;case 10:a++,t.next=6;break;case 13:return c=o.at(-1),t.next=16,i.getFileHandle(c);case 16:return u=t.sent,t.next=19,u.getFile().then((function(t){return t.arrayBuffer()}));case 19:return t.abrupt("return",t.sent);case 22:if(t.prev=22,t.t0=t.catch(4),console.warn("Error reading the file ".concat(r,": ").concat(t.t0.message)),!n||o[0]!==A){t.next=49;break}t.prev=26,s=o.at(-1).slice(0,r.lastIndexOf(".")).split("_")[0],o=o.slice(1),f=0;case 30:if(!(f<o.length-1)){t.next=37;break}return t.next=33,i.getDirectoryHandle(o[f]);case 33:i=t.sent;case 34:f++,t.next=30;break;case 37:return t.next=39,e.getFileHandle(s+".tar");case 39:return l=t.sent,t.next=42,l.getFile().then((function(t){return t.arrayBuffer()}));case 42:return p=t.sent,t.abrupt("return",p.slice(n.startByte,n.endByte));case 46:t.prev=46,t.t1=t.catch(26),console.warn("Error reading the file ".concat(r,": ").concat(t.t1.message));case 49:case"end":return t.stop()}}),t,null,[[4,22],[26,46]])}))),C.apply(this,arguments)}function D(t,e,r){return H.apply(this,arguments)}function H(){return H=M(G().mark((function t(e,r,n){var o,i,a,c,u,s;return G().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:t.prev=0,o=r.split("/"),i=e,a=0;case 4:if(!(a<o.length-1)){t.next=11;break}return t.next=7,i.getDirectoryHandle(o[a],{create:!0});case 7:i=t.sent;case 8:a++,t.next=4;break;case 11:return c=o[o.length-1],t.next=14,i.getFileHandle(c,{create:!0});case 14:return u=t.sent,t.next=17,u.createWritable();case 17:return s=t.sent,t.next=20,s.write(n);case 20:return t.next=22,s.close();case 22:t.next=27;break;case 24:t.prev=24,t.t0=t.catch(0),console.warn("Error writing the file ".concat(r,": ").concat(t.t0.message));case 27:case"end":return t.stop()}}),t,null,[[0,24]])}))),H.apply(this,arguments)}function I(t,e){var r=t.split("series/")[1].split(".tar")[0],n="".concat(e?"_".concat(null==e?void 0:e.startByte,"_").concat(null==e?void 0:e.endByte):"");return"".concat(A,"/").concat(r).concat(n,".dcm")}function z(t){return z="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},z(t)}function Y(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */Y=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 L(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function j(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"==z(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=P(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 P(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,P(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 k(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(k,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(z(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}},L(j.prototype),s(j.prototype,c,(function(){return this})),e.AsyncIterator=j,e.async=function(t,r,n,o,i){void 0===i&&(i=Promise);var a=new j(f(t,r,n,o),i);return e.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},L(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 U(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 W={partial:function(t,e){return(r=Y().mark((function r(){var n,o,i,a,c,u;return Y().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=I(n,o),!a){r.next=10;break}return r.next=6,B(a,c,o);case 6:if(!(u=r.sent)){r.next=10;break}return e({url:n,fileArraybuffer:new Uint8Array(u),offsets:o}),r.abrupt("return");case 10:return r.next=12,fetch(n,{headers:i}).then((function(t){return t.arrayBuffer()})).then((function(t){e({url:n,fileArraybuffer:new Uint8Array(t),offsets:o}),a&&D(a,c,t)})).catch((function(t){throw new N("filePartial.ts: Error when fetching file: "+(null==t?void 0:t.message))}));case 12: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){U(i,n,o,a,c,"next",t)}function c(t){U(i,n,o,a,c,"throw",t)}a(void 0)}))})();var r}};const X=W;function $(t){return $="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},$(t)}function q(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 J(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?q(Object(r),!0).forEach((function(e){K(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):q(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function K(t,e,r){return(e=function(t){var e=function(t,e){if("object"!=$(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!=$(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==$(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}return u(J(J({},X),{},{partial:function(t){return X.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;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=10;break}return r.next=6,U(a,c,{offsets:o,isJson:!1});case 6:if(!(u=r.sent)){r.next=10;break}return e({url:n,fileArraybuffer:new Uint8Array(u),offsets:o}),r.abrupt("return");case 10:return r.next=12,fetch(n,{headers:i}).then((function(t){return t.arrayBuffer()})).then((function(t){e({url:n,fileArraybuffer:new Uint8Array(t),offsets:o}),a&&W(a,c,t)})).catch((function(t){throw new N("filePartial.ts: Error when fetching file: "+(null==t?void 0:t.message))}));case 12: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