cod-dicomweb-server 1.2.4 → 1.3.1
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/README.md +21 -0
- package/dist/cjs/1104a37b16dee0d2ada1.ts +14 -0
- package/dist/cjs/7d4e5892d21def245792.ts +14 -0
- package/dist/cjs/main.js +1957 -0
- package/dist/esm/classes/CodDicomWebServer.d.ts +1 -0
- package/dist/esm/classes/CodDicomWebServer.js +65 -48
- package/dist/esm/classes/customClasses.d.ts +19 -0
- package/dist/esm/classes/customClasses.js +13 -0
- package/dist/esm/classes/index.d.ts +2 -0
- package/dist/esm/classes/index.js +2 -0
- package/dist/esm/classes/utils.js +4 -3
- package/dist/esm/constants/enums.d.ts +4 -0
- package/dist/esm/constants/enums.js +5 -0
- package/dist/esm/constants/index.d.ts +3 -3
- package/dist/esm/constants/index.js +3 -3
- package/dist/esm/dataRetrieval/dataRetrievalManager.d.ts +17 -0
- package/dist/esm/dataRetrieval/dataRetrievalManager.js +54 -0
- package/dist/esm/dataRetrieval/register.d.ts +4 -0
- package/dist/esm/dataRetrieval/register.js +25 -0
- package/dist/esm/dataRetrieval/requestManager.d.ts +12 -0
- package/dist/esm/dataRetrieval/requestManager.js +65 -0
- package/dist/esm/dataRetrieval/scripts/filePartial.d.ts +18 -0
- package/dist/esm/dataRetrieval/scripts/filePartial.js +16 -0
- package/dist/esm/{webWorker → dataRetrieval}/scripts/fileStreaming.d.ts +7 -1
- package/dist/esm/{webWorker → dataRetrieval}/scripts/fileStreaming.js +11 -10
- package/dist/esm/dataRetrieval/utils/environment.d.ts +1 -0
- package/dist/esm/dataRetrieval/utils/environment.js +3 -0
- package/dist/esm/dataRetrieval/workerManager.d.ts +10 -0
- package/dist/esm/{webWorker → dataRetrieval}/workerManager.js +9 -8
- package/dist/esm/dataRetrieval/workers/filePartialWorker.js +7 -0
- package/dist/esm/dataRetrieval/workers/fileStreamingWorker.js +7 -0
- package/dist/esm/fileManager.d.ts +2 -2
- package/dist/esm/fileManager.js +8 -8
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/metadataManager.js +3 -2
- package/dist/esm/types/fileManagerOptions.d.ts +1 -1
- package/dist/esm/types/index.d.ts +1 -1
- package/dist/esm/types/index.js +1 -1
- package/dist/esm/types/metadata.d.ts +1 -1
- package/dist/esm/types/scriptObject.d.ts +4 -0
- package/dist/umd/614.js +19 -0
- package/dist/umd/614.js.map +1 -0
- package/dist/umd/66.js +19 -0
- package/dist/umd/66.js.map +1 -0
- package/dist/umd/main.js +2 -2
- package/dist/umd/main.js.map +1 -1
- package/package.json +13 -4
- package/dist/esm/types/workerCustomMessageEvents.d.ts +0 -10
- package/dist/esm/webWorker/registerWorkers.d.ts +0 -4
- package/dist/esm/webWorker/registerWorkers.js +0 -16
- package/dist/esm/webWorker/scripts/filePartial.d.ts +0 -7
- package/dist/esm/webWorker/scripts/filePartial.js +0 -11
- package/dist/esm/webWorker/workerManager.d.ts +0 -10
- package/dist/esm/webWorker/workers/filePartialWorker.js +0 -3
- package/dist/esm/webWorker/workers/fileStreamingWorker.js +0 -3
- package/dist/umd/16.js +0 -19
- package/dist/umd/16.js.map +0 -1
- package/dist/umd/170.js +0 -19
- package/dist/umd/170.js.map +0 -1
- /package/dist/esm/constants/{worker.d.ts → dataRetrieval.d.ts} +0 -0
- /package/dist/esm/constants/{worker.js → dataRetrieval.js} +0 -0
- /package/dist/esm/{webWorker → dataRetrieval}/workers/filePartialWorker.d.ts +0 -0
- /package/dist/esm/{webWorker → dataRetrieval}/workers/fileStreamingWorker.d.ts +0 -0
- /package/dist/esm/types/{workerCustomMessageEvents.js → scriptObject.js} +0 -0
package/dist/umd/main.js
CHANGED
|
@@ -11,11 +11,11 @@
|
|
|
11
11
|
*/
|
|
12
12
|
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var r=t();for(var n in r)("object"==typeof exports?exports:e)[n]=r[n]}}(self,(()=>(()=>{var e={915:function(e,t,r){
|
|
13
13
|
/*! dicom-parser - 1.8.12 - 2023-02-20 | (c) 2017 Chris Hafey | https://github.com/cornerstonejs/dicomParser */
|
|
14
|
-
e.exports=function(e){return r=[function(t,r){t.exports=e},function(e,t,r){"use strict";r.r(t),r.d(t,"isStringVr",(function(){return a})),r.d(t,"isPrivateTag",(function(){return i})),r.d(t,"parsePN",(function(){return o})),r.d(t,"parseTM",(function(){return s})),r.d(t,"parseDA",(function(){return u})),r.d(t,"explicitElementToString",(function(){return f})),r.d(t,"explicitDataSetToJS",(function(){return l})),r.d(t,"createJPEGBasicOffsetTable",(function(){return p})),r.d(t,"parseDicomDataSetExplicit",(function(){return F})),r.d(t,"parseDicomDataSetImplicit",(function(){return U})),r.d(t,"readFixedString",(function(){return v})),r.d(t,"alloc",(function(){return N})),r.d(t,"version",(function(){return _})),r.d(t,"bigEndianByteArrayParser",(function(){return j})),r.d(t,"ByteStream",(function(){return R})),r.d(t,"sharedCopy",(function(){return M})),r.d(t,"DataSet",(function(){return E})),r.d(t,"findAndSetUNElementLength",(function(){return g})),r.d(t,"findEndOfEncapsulatedElement",(function(){return y})),r.d(t,"findItemDelimitationItemAndSetElementLength",(function(){return x})),r.d(t,"littleEndianByteArrayParser",(function(){return q})),r.d(t,"parseDicom",(function(){return G})),r.d(t,"readDicomElementExplicit",(function(){return L})),r.d(t,"readDicomElementImplicit",(function(){return S})),r.d(t,"readEncapsulatedImageFrame",(function(){return Y})),r.d(t,"readEncapsulatedPixelData",(function(){return $})),r.d(t,"readEncapsulatedPixelDataFromFragments",(function(){return H})),r.d(t,"readPart10Header",(function(){return C})),r.d(t,"readSequenceItemsExplicit",(function(){return T})),r.d(t,"readSequenceItemsImplicit",(function(){return k})),r.d(t,"readSequenceItem",(function(){return A})),r.d(t,"readTag",(function(){return m}));var n={AE:!0,AS:!0,AT:!1,CS:!0,DA:!0,DS:!0,DT:!0,FL:!1,FD:!1,IS:!0,LO:!0,LT:!0,OB:!1,OD:!1,OF:!1,OW:!1,PN:!0,SH:!0,SL:!1,SQ:!1,SS:!1,ST:!0,TM:!0,UI:!0,UL:!1,UN:void 0,UR:!0,US:!1,UT:!0},a=function(e){return n[e]},i=function(e){if(e=parseInt(e[4],16),isNaN(e))throw"dicomParser.isPrivateTag: cannot parse last character of group";return e%2==1},o=function(e){if(void 0!==e)return{familyName:(e=e.split("^"))[0],givenName:e[1],middleName:e[2],prefix:e[3],suffix:e[4]}};function s(e,t){if(2<=e.length){var r=parseInt(e.substring(0,2),10),n=4<=e.length?parseInt(e.substring(2,4),10):void 0,a=6<=e.length?parseInt(e.substring(4,6),10):void 0,i=(i=8<=e.length?e.substring(7,13):void 0)?parseInt(i,10)*Math.pow(10,6-i.length):void 0;if(t&&(isNaN(r)||void 0!==n&&isNaN(n)||void 0!==a&&isNaN(a)||void 0!==i&&isNaN(i)||r<0||23<r||n&&(n<0||59<n)||a&&(a<0||59<a)||i&&(i<0||999999<i)))throw"invalid TM '".concat(e,"'");return{hours:r,minutes:n,seconds:a,fractionalSeconds:i}}if(t)throw"invalid TM '".concat(e,"'")}function c(e,t,r){return!isNaN(r)&&0<t&&t<=12&&0<e&&e<=function(e,t){switch(e){case 2:return t%4==0&&t%100||t%400==0?29:28;case 9:case 4:case 6:case 11:return 30;default:return 31}}(t,r)}function u(e,t){if(e&&8===e.length){var r=parseInt(e.substring(0,4),10),n=parseInt(e.substring(4,6),10),a=parseInt(e.substring(6,8),10);if(t&&!0!==c(a,n,r))throw"invalid DA '".concat(e,"'");return{year:r,month:n,day:a}}if(t)throw"invalid DA '".concat(e,"'")}function f(e,t){if(void 0===e||void 0===t)throw"dicomParser.explicitElementToString: missing required parameters";if(void 0===t.vr)throw"dicomParser.explicitElementToString: cannot convert implicit element to string";var r,n=t.vr,i=t.tag;function o(t,r){for(var n="",a=0;a<t;a++)0!==a&&(n+="/"),n+=r.call(e,i,a).toString();return n}if(!0===a(n))r=e.string(i);else{if("AT"===n){var s=e.uint32(i);return void 0===s?void 0:"x".concat((s=s<0?4294967295+s+1:s).toString(16).toUpperCase())}"US"===n?r=o(t.length/2,e.uint16):"SS"===n?r=o(t.length/2,e.int16):"UL"===n?r=o(t.length/4,e.uint32):"SL"===n?r=o(t.length/4,e.int32):"FD"===n?r=o(t.length/8,e.double):"FL"===n&&(r=o(t.length/4,e.float))}return r}function l(e,t){if(void 0===e)throw"dicomParser.explicitDataSetToJS: missing required parameter dataSet";t=t||{omitPrivateAttibutes:!0,maxElementLength:128};var r,n={};for(r in e.elements){var a=e.elements[r];if(!0!==t.omitPrivateAttibutes||!i(r))if(a.items){for(var o=[],s=0;s<a.items.length;s++)o.push(l(a.items[s].dataSet,t));n[r]=o}else{var c=void 0;a.length<t.maxElementLength&&(c=f(e,a)),n[r]=void 0!==c?c:{dataOffset:a.dataOffset,length:a.length}}}return n}function d(e,t){return 255===e.byteArray[t]&&217===e.byteArray[t+1]}function h(e,t,r){for(var n,a,i=r;i<t.fragments.length;i++)if(a=i,d(n=e,(a=t.fragments[a]).position+a.length-2)||d(n,a.position+a.length-3))return i}function p(e,t,r){if(void 0===e)throw"dicomParser.createJPEGBasicOffsetTable: missing required parameter dataSet";if(void 0===t)throw"dicomParser.createJPEGBasicOffsetTable: missing required parameter pixelDataElement";if("x7fe00010"!==t.tag)throw"dicomParser.createJPEGBasicOffsetTable: parameter 'pixelDataElement' refers to non pixel data tag (expected tag = x7fe00010'";if(!0!==t.encapsulatedPixelData)throw"dicomParser.createJPEGBasicOffsetTable: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(!0!==t.hadUndefinedLength)throw"dicomParser.createJPEGBasicOffsetTable: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(void 0===t.basicOffsetTable)throw"dicomParser.createJPEGBasicOffsetTable: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(void 0===t.fragments)throw"dicomParser.createJPEGBasicOffsetTable: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(t.fragments.length<=0)throw"dicomParser.createJPEGBasicOffsetTable: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(r&&r.length<=0)throw"dicomParser.createJPEGBasicOffsetTable: parameter 'fragments' must not be zero length";r=r||t.fragments;for(var n=[],a=0;;){n.push(t.fragments[a].offset);var i=h(e,t,a);if(void 0===i||i===t.fragments.length-1)return n;a=i+1}}function m(e){if(void 0===e)throw"dicomParser.readTag: missing required parameter 'byteStream'";var t=256*e.readUint16()*256;return e=e.readUint16(),"x".concat("00000000".concat((t+e).toString(16)).substr(-8))}function y(e,t,r){if(void 0===e)throw"dicomParser.findEndOfEncapsulatedElement: missing required parameter 'byteStream'";if(void 0===t)throw"dicomParser.findEndOfEncapsulatedElement: missing required parameter 'element'";if(t.encapsulatedPixelData=!0,t.basicOffsetTable=[],t.fragments=[],"xfffee000"!==m(e))throw"dicomParser.findEndOfEncapsulatedElement: basic offset table not found";for(var n=e.readUint32()/4,a=0;a<n;a++){var i=e.readUint32();t.basicOffsetTable.push(i)}for(var o=e.position;e.position<e.byteArray.length;){var s=m(e),c=e.readUint32();if("xfffee0dd"===s)return e.seek(c),void(t.length=e.position-t.dataOffset);if("xfffee000"!==s)return r&&r.push("unexpected tag ".concat(s," while searching for end of pixel data element with undefined length")),c>e.byteArray.length-e.position&&(c=e.byteArray.length-e.position),t.fragments.push({offset:e.position-o-8,position:e.position,length:c}),e.seek(c),void(t.length=e.position-t.dataOffset);t.fragments.push({offset:e.position-o-8,position:e.position,length:c}),e.seek(c)}r&&r.push("pixel data element ".concat(t.tag," missing sequence delimiter tag xfffee0dd"))}function g(e,t){if(void 0===e)throw"dicomParser.findAndSetUNElementLength: missing required parameter 'byteStream'";for(var r=e.byteArray.length-8;e.position<=r;)if(65534===e.readUint16()&&57565===e.readUint16())return 0!==e.readUint32()&&e.warnings("encountered non zero length following item delimiter at position ".concat(e.position-4," while reading element of undefined length with tag ").concat(t.tag)),void(t.length=e.position-t.dataOffset);t.length=e.byteArray.length-t.dataOffset,e.seek(e.byteArray.length-e.position)}function v(e,t,r){if(r<0)throw"dicomParser.readFixedString - length cannot be less than 0";if(t+r>e.length)throw"dicomParser.readFixedString: attempt to read past end of buffer";for(var n,a="",i=0;i<r;i++){if(0===(n=e[t+i]))return t+=r,a;a+=String.fromCharCode(n)}return a}function b(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function w(e,t){return void 0!==e.parser?e.parser:t}var E=function(){function e(t,r,n){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.byteArrayParser=t,this.byteArray=r,this.elements=n}var t,r,n;return t=e,(r=[{key:"uint16",value:function(e,t){if(t=void 0!==t?t:0,(e=this.elements[e])&&0!==e.length)return w(e,this.byteArrayParser).readUint16(this.byteArray,e.dataOffset+2*t)}},{key:"int16",value:function(e,t){if(t=void 0!==t?t:0,(e=this.elements[e])&&0!==e.length)return w(e,this.byteArrayParser).readInt16(this.byteArray,e.dataOffset+2*t)}},{key:"uint32",value:function(e,t){if(t=void 0!==t?t:0,(e=this.elements[e])&&0!==e.length)return w(e,this.byteArrayParser).readUint32(this.byteArray,e.dataOffset+4*t)}},{key:"int32",value:function(e,t){if(t=void 0!==t?t:0,(e=this.elements[e])&&0!==e.length)return w(e,this.byteArrayParser).readInt32(this.byteArray,e.dataOffset+4*t)}},{key:"float",value:function(e,t){if(t=void 0!==t?t:0,(e=this.elements[e])&&0!==e.length)return w(e,this.byteArrayParser).readFloat(this.byteArray,e.dataOffset+4*t)}},{key:"double",value:function(e,t){if(t=void 0!==t?t:0,(e=this.elements[e])&&0!==e.length)return w(e,this.byteArrayParser).readDouble(this.byteArray,e.dataOffset+8*t)}},{key:"numStringValues",value:function(e){if((e=this.elements[e])&&0<e.length)return null===(e=v(this.byteArray,e.dataOffset,e.length).match(/\\/g))?1:e.length+1}},{key:"string",value:function(e,t){return(e=this.elements[e])&&e.Value?e.Value:e&&0<e.length?(e=v(this.byteArray,e.dataOffset,e.length),0<=t?e.split("\\")[t].trim():e.trim()):void 0}},{key:"text",value:function(e,t){if((e=this.elements[e])&&0<e.length)return e=v(this.byteArray,e.dataOffset,e.length),0<=t?e.split("\\")[t].replace(/ +$/,""):e.replace(/ +$/,"")}},{key:"floatString",value:function(e,t){var r=this.elements[e];if(r&&0<r.length&&void 0!==(t=this.string(e,t=void 0!==t?t:0)))return parseFloat(t)}},{key:"intString",value:function(e,t){var r=this.elements[e];if(r&&0<r.length&&void 0!==(t=this.string(e,t=void 0!==t?t:0)))return parseInt(t)}},{key:"attributeTag",value:function(e){if((r=this.elements[e])&&4===r.length){var t=w(r,this.byteArrayParser).readUint16,r=(e=this.byteArray,r.dataOffset);return"x".concat("00000000".concat((256*t(e,r)*256+t(e,r+2)).toString(16)).substr(-8))}}}])&&b(t.prototype,r),n&&b(t,n),Object.defineProperty(t,"prototype",{writable:!1}),e}();function x(e,t){if(void 0===e)throw"dicomParser.readDicomElementImplicit: missing required parameter 'byteStream'";for(var r=e.byteArray.length-8;e.position<=r;)if(65534===e.readUint16()&&57357===e.readUint16())return 0!==e.readUint32()&&e.warnings("encountered non zero length following item delimiter at position ".concat(e.position-4," while reading element of undefined length with tag ").concat(t.tag)),void(t.length=e.position-t.dataOffset);t.length=e.byteArray.length-t.dataOffset,e.seek(e.byteArray.length-e.position)}var P=function(e,t){return void 0!==e.vr?"SQ"===e.vr:t.position+4<=t.byteArray.length?(e=m(t),t.seek(-4),"xfffee000"===e||"xfffee0dd"===e):(t.warnings.push("eof encountered before finding sequence item tag or sequence delimiter tag in peeking to determine VR"),!1)};function S(e,t,r){if(void 0===e)throw"dicomParser.readDicomElementImplicit: missing required parameter 'byteStream'";var n;return 4294967295===(n={tag:n=m(e),vr:void 0!==r?r(n):void 0,length:e.readUint32(),dataOffset:e.position}).length&&(n.hadUndefinedLength=!0),n.tag===t||(!P(n,e)||i(n.tag)&&!n.hadUndefinedLength?n.hadUndefinedLength?x(e,n):e.seek(n.length):(k(e,n,r),i(n.tag)&&(n.items=void 0))),n}function A(e){if(void 0===e)throw"dicomParser.readSequenceItem: missing required parameter 'byteStream'";var t={tag:m(e),length:e.readUint32(),dataOffset:e.position};if("xfffee000"!==t.tag)throw"dicomParser.readSequenceItem: item tag (FFFE,E000) not found at offset ".concat(e.position);return t}function O(e,t){var r=A(e);return 4294967295===r.length?(r.hadUndefinedLength=!0,r.dataSet=function(e,t){for(var r={};e.position<e.byteArray.length;){var n=S(e,void 0,t);if("xfffee00d"===(r[n.tag]=n).tag)return new E(e.byteArrayParser,e.byteArray,r)}return e.warnings.push("eof encountered before finding sequence item delimiter in sequence item of undefined length"),new E(e.byteArrayParser,e.byteArray,r)}(e,t),r.length=e.position-r.dataOffset):(r.dataSet=new E(e.byteArrayParser,e.byteArray,{}),U(r.dataSet,e,e.position+r.length,{vrCallback:t})),r}function k(e,t,r){if(void 0===e)throw"dicomParser.readSequenceItemsImplicit: missing required parameter 'byteStream'";if(void 0===t)throw"dicomParser.readSequenceItemsImplicit: missing required parameter 'element'";t.items=[],(4294967295===t.length?function(e,t,r){for(;e.position+4<=e.byteArray.length;){var n=m(e);if(e.seek(-4),"xfffee0dd"===n)return t.length=e.position-t.dataOffset,e.seek(8);n=O(e,r),t.items.push(n)}e.warnings.push("eof encountered before finding sequence delimiter in sequence of undefined length"),t.length=e.byteArray.length-t.dataOffset}:function(e,t,r){for(var n=t.dataOffset+t.length;e.position<n;){var a=O(e,r);t.items.push(a)}})(e,t,r)}function I(e,t){var r=A(e);return 4294967295===r.length?(r.hadUndefinedLength=!0,r.dataSet=function(e,t){for(var r={};e.position<e.byteArray.length;){var n=L(e,t);if("xfffee00d"===(r[n.tag]=n).tag)return new E(e.byteArrayParser,e.byteArray,r)}return t.push("eof encountered before finding item delimiter tag while reading sequence item of undefined length"),new E(e.byteArrayParser,e.byteArray,r)}(e,t),r.length=e.position-r.dataOffset):(r.dataSet=new E(e.byteArrayParser,e.byteArray,{}),F(r.dataSet,e,e.position+r.length)),r}function T(e,t,r){if(void 0===e)throw"dicomParser.readSequenceItemsExplicit: missing required parameter 'byteStream'";if(void 0===t)throw"dicomParser.readSequenceItemsExplicit: missing required parameter 'element'";t.items=[],(4294967295===t.length?function(e,t,r){for(;e.position+4<=e.byteArray.length;){var n=m(e);if(e.seek(-4),"xfffee0dd"===n)return t.length=e.position-t.dataOffset,e.seek(8);n=I(e,r),t.items.push(n)}r.push("eof encountered before finding sequence delimitation tag while reading sequence of undefined length"),t.length=e.position-t.dataOffset}:function(e,t,r){for(var n=t.dataOffset+t.length;e.position<n;){var a=I(e,r);t.items.push(a)}})(e,t,r)}var D=function(e){return"OB"===e||"OD"===e||"OL"===e||"OW"===e||"SQ"===e||"OF"===e||"UC"===e||"UR"===e||"UT"===e||"UN"===e?4:2};function L(e,t,r){if(void 0===e)throw"dicomParser.readDicomElementExplicit: missing required parameter 'byteStream'";var n={tag:m(e),vr:e.readFixedString(2)};return 2===D(n.vr)?n.length=e.readUint16():(e.seek(2),n.length=e.readUint32()),n.dataOffset=e.position,4294967295===n.length&&(n.hadUndefinedLength=!0),n.tag===r||("SQ"===n.vr?T(e,n,t):4294967295===n.length?"x7fe00010"===n.tag?y(e,n,t):("UN"===n.vr?k:x)(e,n):e.seek(n.length)),n}function F(e,t,r){var n=3<arguments.length&&void 0!==arguments[3]?arguments[3]:{};if(r=void 0===r?t.byteArray.length:r,void 0===t)throw"dicomParser.parseDicomDataSetExplicit: missing required parameter 'byteStream'";if(r<t.position||r>t.byteArray.length)throw"dicomParser.parseDicomDataSetExplicit: invalid value for parameter 'maxP osition'";for(var a=e.elements;t.position<r;){var i=L(t,e.warnings,n.untilTag);if((a[i.tag]=i).tag===n.untilTag)return}if(t.position>r)throw"dicomParser:parseDicomDataSetExplicit: buffer overrun"}function U(e,t,r){var n=3<arguments.length&&void 0!==arguments[3]?arguments[3]:{};if(r=void 0===r?e.byteArray.length:r,void 0===t)throw"dicomParser.parseDicomDataSetImplicit: missing required parameter 'byteStream'";if(r<t.position||r>t.byteArray.length)throw"dicomParser.parseDicomDataSetImplicit: invalid value for parameter 'maxPosition'";for(var a=e.elements;t.position<r;){var i=S(t,n.untilTag,n.vrCallback);if((a[i.tag]=i).tag===n.untilTag)return}}function N(e,t){if("undefined"!=typeof Buffer&&e instanceof Buffer)return Buffer.alloc(t);if(e instanceof Uint8Array)return new Uint8Array(t);throw"dicomParser.alloc: unknown type for byteArray"}var _="1.8.12",j={readUint16:function(e,t){if(t<0)throw"bigEndianByteArrayParser.readUint16: position cannot be less than 0";if(t+2>e.length)throw"bigEndianByteArrayParser.readUint16: attempt to read past end of buffer";return(e[t]<<8)+e[t+1]},readInt16:function(e,t){if(t<0)throw"bigEndianByteArrayParser.readInt16: position cannot be less than 0";if(t+2>e.length)throw"bigEndianByteArrayParser.readInt16: attempt to read past end of buffer";return 32768&(t=(e[t]<<8)+e[t+1])?t-65535-1:t},readUint32:function(e,t){if(t<0)throw"bigEndianByteArrayParser.readUint32: position cannot be less than 0";if(t+4>e.length)throw"bigEndianByteArrayParser.readUint32: attempt to read past end of buffer";return 256*(256*(256*e[t]+e[t+1])+e[t+2])+e[t+3]},readInt32:function(e,t){if(t<0)throw"bigEndianByteArrayParser.readInt32: position cannot be less than 0";if(t+4>e.length)throw"bigEndianByteArrayParser.readInt32: attempt to read past end of buffer";return(e[t]<<24)+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3]},readFloat:function(e,t){if(t<0)throw"bigEndianByteArrayParser.readFloat: position cannot be less than 0";if(t+4>e.length)throw"bigEndianByteArrayParser.readFloat: attempt to read past end of buffer";var r=new Uint8Array(4);return r[3]=e[t],r[2]=e[t+1],r[1]=e[t+2],r[0]=e[t+3],new Float32Array(r.buffer)[0]},readDouble:function(e,t){if(t<0)throw"bigEndianByteArrayParser.readDouble: position cannot be less than 0";if(t+8>e.length)throw"bigEndianByteArrayParser.readDouble: attempt to read past end of buffer";var r=new Uint8Array(8);return r[7]=e[t],r[6]=e[t+1],r[5]=e[t+2],r[4]=e[t+3],r[3]=e[t+4],r[2]=e[t+5],r[1]=e[t+6],r[0]=e[t+7],new Float64Array(r.buffer)[0]}};function M(e,t,r){if("undefined"!=typeof Buffer&&e instanceof Buffer)return e.slice(t,t+r);if(e instanceof Uint8Array)return new Uint8Array(e.buffer,e.byteOffset+t,r);throw"dicomParser.from: unknown type for byteArray"}function B(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}var R=function(){function e(t,r,n){if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),void 0===t)throw"dicomParser.ByteStream: missing required parameter 'byteArrayParser'";if(void 0===r)throw"dicomParser.ByteStream: missing required parameter 'byteArray'";if(r instanceof Uint8Array==0&&("undefined"==typeof Buffer||r instanceof Buffer==0))throw"dicomParser.ByteStream: parameter byteArray is not of type Uint8Array or Buffer";if(n<0)throw"dicomParser.ByteStream: parameter 'position' cannot be less than 0";if(n>=r.length)throw"dicomParser.ByteStream: parameter 'position' cannot be greater than or equal to 'byteArray' length";this.byteArrayParser=t,this.byteArray=r,this.position=n||0,this.warnings=[]}var t,r,n;return t=e,(r=[{key:"seek",value:function(e){if(this.position+e<0)throw"dicomParser.ByteStream.prototype.seek: cannot seek to position < 0";this.position+=e}},{key:"readByteStream",value:function(t){if(this.position+t>this.byteArray.length)throw"dicomParser.ByteStream.prototype.readByteStream: readByteStream - buffer overread";var r=M(this.byteArray,this.position,t);return this.position+=t,new e(this.byteArrayParser,r)}},{key:"getSize",value:function(){return this.byteArray.length}},{key:"readUint16",value:function(){var e=this.byteArrayParser.readUint16(this.byteArray,this.position);return this.position+=2,e}},{key:"readUint32",value:function(){var e=this.byteArrayParser.readUint32(this.byteArray,this.position);return this.position+=4,e}},{key:"readFixedString",value:function(e){var t=v(this.byteArray,this.position,e);return this.position+=e,t}}])&&B(t.prototype,r),n&&B(t,n),Object.defineProperty(t,"prototype",{writable:!1}),e}(),q={readUint16:function(e,t){if(t<0)throw"littleEndianByteArrayParser.readUint16: position cannot be less than 0";if(t+2>e.length)throw"littleEndianByteArrayParser.readUint16: attempt to read past end of buffer";return e[t]+256*e[t+1]},readInt16:function(e,t){if(t<0)throw"littleEndianByteArrayParser.readInt16: position cannot be less than 0";if(t+2>e.length)throw"littleEndianByteArrayParser.readInt16: attempt to read past end of buffer";return 32768&(t=e[t]+(e[t+1]<<8))?t-65535-1:t},readUint32:function(e,t){if(t<0)throw"littleEndianByteArrayParser.readUint32: position cannot be less than 0";if(t+4>e.length)throw"littleEndianByteArrayParser.readUint32: attempt to read past end of buffer";return e[t]+256*e[t+1]+256*e[t+2]*256+256*e[t+3]*256*256},readInt32:function(e,t){if(t<0)throw"littleEndianByteArrayParser.readInt32: position cannot be less than 0";if(t+4>e.length)throw"littleEndianByteArrayParser.readInt32: attempt to read past end of buffer";return e[t]+(e[t+1]<<8)+(e[t+2]<<16)+(e[t+3]<<24)},readFloat:function(e,t){if(t<0)throw"littleEndianByteArrayParser.readFloat: position cannot be less than 0";if(t+4>e.length)throw"littleEndianByteArrayParser.readFloat: attempt to read past end of buffer";var r=new Uint8Array(4);return r[0]=e[t],r[1]=e[t+1],r[2]=e[t+2],r[3]=e[t+3],new Float32Array(r.buffer)[0]},readDouble:function(e,t){if(t<0)throw"littleEndianByteArrayParser.readDouble: position cannot be less than 0";if(t+8>e.length)throw"littleEndianByteArrayParser.readDouble: attempt to read past end of buffer";var r=new Uint8Array(8);return r[0]=e[t],r[1]=e[t+1],r[2]=e[t+2],r[3]=e[t+3],r[4]=e[t+4],r[5]=e[t+5],r[6]=e[t+6],r[7]=e[t+7],new Float64Array(r.buffer)[0]}};function C(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};if(void 0===e)throw"dicomParser.readPart10Header: missing required parameter 'byteArray'";var r=t.TransferSyntaxUID,n=new R(q,e);return function(){var e=function(){if(n.getSize()<=132&&r)return!1;if(n.seek(128),"DICM"===n.readFixedString(4))return!0;if(!(t||{}).TransferSyntaxUID)throw"dicomParser.readPart10Header: DICM prefix not found at location 132 - this is not a valid DICOM P10 file.";return n.seek(0),!1}(),a=[],i={};if(!e)return n.position=0,{elements:{x00020010:{tag:"x00020010",vr:"UI",Value:r}},warnings:a};for(;n.position<n.byteArray.length;){var o=n.position,s=L(n,a);if("x0002ffff"<s.tag){n.position=o;break}s.parser=q,i[s.tag]=s}return(e=new E(n.byteArrayParser,n.byteArray,i)).warnings=n.warnings,e.position=n.position,e}()}var W="1.2.840.10008.1.2.2";function G(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};if(void 0===e)throw new Error("dicomParser.parseDicom: missing required parameter 'byteArray'");var n,a=function(t){if(void 0===t.elements.x00020010)throw new Error("dicomParser.parseDicom: missing required meta header attribute 0002,0010");return(t=t.elements.x00020010)&&t.Value||v(e,t.dataOffset,t.length)};function i(n){var i="1.2.840.10008.1.2"!==(o=a(n)),o=function(n,a){var i="[object process]"===Object.prototype.toString.call("undefined"!=typeof process?process:0);if("1.2.840.10008.1.2.1.99"!==n)return new R(n===W?j:q,e,a);if(t&&t.inflater)return n=t.inflater(e,a),new R(q,n,0);if(1==i){var o=r(0),s=M(e,a,e.length-a);return o=o.inflateRawSync(s),s=N(e,o.length+a),e.copy(s,0,0,a),o.copy(s,a),new R(q,s,0)}if("undefined"==typeof pako)throw"dicomParser.parseDicom: no inflater available to handle deflate transfer syntax";return o=e.slice(a),s=pako.inflateRaw(o),(o=N(e,s.length+a)).set(e.slice(0,a),0),o.set(s,a),new R(q,o,0)}(o,n.position);(n=new E(o.byteArrayParser,o.byteArray,{})).warnings=o.warnings;try{(i?F:U)(n,o,o.byteArray.length,t)}catch(o){throw{exception:o,dataSet:n}}return n}return function(e,t){for(var r in e.elements)e.elements.hasOwnProperty(r)&&(t.elements[r]=e.elements[r]);return void 0!==e.warnings&&(t.warnings=e.warnings.concat(t.warnings)),t}(n=C(e,t),i(n))}var z=function(e,t,r){for(var n=0,a=t;a<t+r;a++)n+=e[a].length;return n};function H(e,t,r,n,a){if(a=a||t.fragments,void 0===e)throw"dicomParser.readEncapsulatedPixelDataFromFragments: missing required parameter 'dataSet'";if(void 0===t)throw"dicomParser.readEncapsulatedPixelDataFromFragments: missing required parameter 'pixelDataElement'";if(void 0===r)throw"dicomParser.readEncapsulatedPixelDataFromFragments: missing required parameter 'startFragmentIndex'";if(void 0===(n=n||1))throw"dicomParser.readEncapsulatedPixelDataFromFragments: missing required parameter 'numFragments'";if("x7fe00010"!==t.tag)throw"dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'pixelDataElement' refers to non pixel data tag (expected tag = x7fe00010";if(!0!==t.encapsulatedPixelData)throw"dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(!0!==t.hadUndefinedLength)throw"dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(void 0===t.basicOffsetTable)throw"dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(void 0===t.fragments)throw"dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(t.fragments.length<=0)throw"dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(r<0)throw"dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'startFragmentIndex' must be >= 0";if(r>=t.fragments.length)throw"dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'startFragmentIndex' must be < number of fragments";if(n<1)throw"dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'numFragments' must be > 0";if(r+n>t.fragments.length)throw"dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'startFragment' + 'numFragments' < number of fragments";var i=new R(e.byteArrayParser,e.byteArray,t.dataOffset);if("xfffee000"!==(t=A(i)).tag)throw"dicomParser.readEncapsulatedPixelData: missing basic offset table xfffee000";i.seek(t.length);var o=i.position;if(1===n)return M(i.byteArray,o+a[r].offset+8,a[r].length);t=z(a,r,n);for(var s=N(i.byteArray,t),c=0,u=r;u<r+n;u++)for(var f=o+a[u].offset+8,l=0;l<a[u].length;l++)s[c++]=i.byteArray[f++];return s}var V=function(e,t){for(var r=0;r<e.length;r++)if(e[r].offset===t)return r},J=function(e,t,r,n){if(e===t.length-1)return r.length-n;for(var a=t[e+1],i=n+1;i<r.length;i++)if(r[i].offset===a)return i-n;throw"dicomParser.calculateNumberOfFragmentsForFrame: could not find fragment with offset matching basic offset table"};function Y(e,t,r,n,a){if(n=n||t.basicOffsetTable,a=a||t.fragments,void 0===e)throw"dicomParser.readEncapsulatedImageFrame: missing required parameter 'dataSet'";if(void 0===t)throw"dicomParser.readEncapsulatedImageFrame: missing required parameter 'pixelDataElement'";if(void 0===r)throw"dicomParser.readEncapsulatedImageFrame: missing required parameter 'frameIndex'";if(void 0===n)throw"dicomParser.readEncapsulatedImageFrame: parameter 'pixelDataElement' does not have basicOffsetTable";if("x7fe00010"!==t.tag)throw"dicomParser.readEncapsulatedImageFrame: parameter 'pixelDataElement' refers to non pixel data tag (expected tag = x7fe00010)";if(!0!==t.encapsulatedPixelData)throw"dicomParser.readEncapsulatedImageFrame: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(!0!==t.hadUndefinedLength)throw"dicomParser.readEncapsulatedImageFrame: parameter 'pixelDataElement' refers to pixel data element that does not have undefined length";if(void 0===t.fragments)throw"dicomParser.readEncapsulatedImageFrame: parameter 'pixelDataElement' refers to pixel data element that does not have fragments";if(0===n.length)throw"dicomParser.readEncapsulatedImageFrame: basicOffsetTable has zero entries";if(r<0)throw"dicomParser.readEncapsulatedImageFrame: parameter 'frameIndex' must be >= 0";if(r>=n.length)throw"dicomParser.readEncapsulatedImageFrame: parameter 'frameIndex' must be < basicOffsetTable.length";var i=n[r];if(void 0===(i=V(a,i)))throw"dicomParser.readEncapsulatedImageFrame: unable to find fragment that matches basic offset table entry";return H(e,t,i,J(r,n,a,i),a)}var Z=!1;function $(e,t,r){if(Z||(Z=!0,console&&console.log&&console.log("WARNING: dicomParser.readEncapsulatedPixelData() has been deprecated")),void 0===e)throw"dicomParser.readEncapsulatedPixelData: missing required parameter 'dataSet'";if(void 0===t)throw"dicomParser.readEncapsulatedPixelData: missing required parameter 'element'";if(void 0===r)throw"dicomParser.readEncapsulatedPixelData: missing required parameter 'frame'";if("x7fe00010"!==t.tag)throw"dicomParser.readEncapsulatedPixelData: parameter 'element' refers to non pixel data tag (expected tag = x7fe00010)";if(!0!==t.encapsulatedPixelData)throw"dicomParser.readEncapsulatedPixelData: parameter 'element' refers to pixel data element that does not have encapsulated pixel data";if(!0!==t.hadUndefinedLength)throw"dicomParser.readEncapsulatedPixelData: parameter 'element' refers to pixel data element that does not have encapsulated pixel data";if(void 0===t.basicOffsetTable)throw"dicomParser.readEncapsulatedPixelData: parameter 'element' refers to pixel data element that does not have encapsulated pixel data";if(void 0===t.fragments)throw"dicomParser.readEncapsulatedPixelData: parameter 'element' refers to pixel data element that does not have encapsulated pixel data";if(r<0)throw"dicomParser.readEncapsulatedPixelData: parameter 'frame' must be >= 0";return 0!==t.basicOffsetTable.length?Y(e,t,r):H(e,t,0,t.fragments.length)}t.default={isStringVr:a,isPrivateTag:i,parsePN:o,parseTM:s,parseDA:u,explicitElementToString:f,explicitDataSetToJS:l,createJPEGBasicOffsetTable:p,parseDicomDataSetExplicit:F,parseDicomDataSetImplicit:U,readFixedString:v,alloc:N,version:_,bigEndianByteArrayParser:j,ByteStream:R,sharedCopy:M,DataSet:E,findAndSetUNElementLength:g,findEndOfEncapsulatedElement:y,findItemDelimitationItemAndSetElementLength:x,littleEndianByteArrayParser:q,parseDicom:G,readDicomElementExplicit:L,readDicomElementImplicit:S,readEncapsulatedImageFrame:Y,readEncapsulatedPixelData:$,readEncapsulatedPixelDataFromFragments:H,readPart10Header:C,readSequenceItemsExplicit:T,readSequenceItemsImplicit:k,readSequenceItem:A,readTag:m,LEI:"1.2.840.10008.1.2",LEE:"1.2.840.10008.1.2.1"}}],n={},t.m=r,t.c=n,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:n})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,r){if(1&r&&(e=t(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(t.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var a in e)t.d(n,a,function(t){return e[t]}.bind(null,a));return n},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=1);function t(e){if(n[e])return n[e].exports;var a=n[e]={i:e,l:!1,exports:{}};return r[e].call(a.exports,a,a.exports,t),a.l=!0,a.exports}var r,n}(r(559))},559:()=>{}},t={};function r(n){var a=t[n];if(void 0!==a)return a.exports;var i=t[n]={exports:{}};return e[n].call(i.exports,i,i.exports,r),i.exports}r.m=e,r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.u=e=>e+".js",r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(()=>{var e;r.g.importScripts&&(e=r.g.location+"");var t=r.g.document;if(!e&&t&&(t.currentScript&&"SCRIPT"===t.currentScript.tagName.toUpperCase()&&(e=t.currentScript.src),!e)){var n=t.getElementsByTagName("script");if(n.length)for(var a=n.length-1;a>-1&&(!e||!/^http(s?):/.test(e));)e=n[a--].src}if(!e)throw new Error("Automatic publicPath is not supported in this browser");e=e.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),r.p=e})(),r.b=document.baseURI||self.location.href;var n={};return(()=>{"use strict";r.r(n),r.d(n,{CodDicomWebServer:()=>de,FetchType:()=>i,default:()=>he});var e={};r.r(e),r.d(e,{FetchType:()=>i,RequestType:()=>o});var t={};r.r(t),r.d(t,{DOMAIN:()=>W,FILE_EXTENSIONS:()=>G,URL_VALIDATION_STRING:()=>z});var a={};r.r(a),r.d(a,{FILE_PARTIAL_WORKER_NAME:()=>H,FILE_STREAMING_WORKER_NAME:()=>V,THRESHOLD:()=>J});var i=function(e){return e[e.BYTES_OPTIMIZED=0]="BYTES_OPTIMIZED",e[e.API_OPTIMIZED=1]="API_OPTIMIZED",e}({}),o=function(e){return e[e.FRAME=0]="FRAME",e[e.THUMBNAIL=1]="THUMBNAIL",e[e.SERIES_METADATA=2]="SERIES_METADATA",e[e.INSTANCE_METADATA=3]="INSTANCE_METADATA",e}({}),s=r(915);
|
|
14
|
+
e.exports=function(e){return r=[function(t,r){t.exports=e},function(e,t,r){"use strict";r.r(t),r.d(t,"isStringVr",(function(){return i})),r.d(t,"isPrivateTag",(function(){return a})),r.d(t,"parsePN",(function(){return o})),r.d(t,"parseTM",(function(){return s})),r.d(t,"parseDA",(function(){return u})),r.d(t,"explicitElementToString",(function(){return f})),r.d(t,"explicitDataSetToJS",(function(){return l})),r.d(t,"createJPEGBasicOffsetTable",(function(){return p})),r.d(t,"parseDicomDataSetExplicit",(function(){return F})),r.d(t,"parseDicomDataSetImplicit",(function(){return D})),r.d(t,"readFixedString",(function(){return g})),r.d(t,"alloc",(function(){return _})),r.d(t,"version",(function(){return N})),r.d(t,"bigEndianByteArrayParser",(function(){return U})),r.d(t,"ByteStream",(function(){return B})),r.d(t,"sharedCopy",(function(){return M})),r.d(t,"DataSet",(function(){return E})),r.d(t,"findAndSetUNElementLength",(function(){return v})),r.d(t,"findEndOfEncapsulatedElement",(function(){return m})),r.d(t,"findItemDelimitationItemAndSetElementLength",(function(){return x})),r.d(t,"littleEndianByteArrayParser",(function(){return G})),r.d(t,"parseDicom",(function(){return z})),r.d(t,"readDicomElementExplicit",(function(){return j})),r.d(t,"readDicomElementImplicit",(function(){return S})),r.d(t,"readEncapsulatedImageFrame",(function(){return J})),r.d(t,"readEncapsulatedPixelData",(function(){return Q})),r.d(t,"readEncapsulatedPixelDataFromFragments",(function(){return Y})),r.d(t,"readPart10Header",(function(){return q})),r.d(t,"readSequenceItemsExplicit",(function(){return T})),r.d(t,"readSequenceItemsImplicit",(function(){return A})),r.d(t,"readSequenceItem",(function(){return O})),r.d(t,"readTag",(function(){return y}));var n={AE:!0,AS:!0,AT:!1,CS:!0,DA:!0,DS:!0,DT:!0,FL:!1,FD:!1,IS:!0,LO:!0,LT:!0,OB:!1,OD:!1,OF:!1,OW:!1,PN:!0,SH:!0,SL:!1,SQ:!1,SS:!1,ST:!0,TM:!0,UI:!0,UL:!1,UN:void 0,UR:!0,US:!1,UT:!0},i=function(e){return n[e]},a=function(e){if(e=parseInt(e[4],16),isNaN(e))throw"dicomParser.isPrivateTag: cannot parse last character of group";return e%2==1},o=function(e){if(void 0!==e)return{familyName:(e=e.split("^"))[0],givenName:e[1],middleName:e[2],prefix:e[3],suffix:e[4]}};function s(e,t){if(2<=e.length){var r=parseInt(e.substring(0,2),10),n=4<=e.length?parseInt(e.substring(2,4),10):void 0,i=6<=e.length?parseInt(e.substring(4,6),10):void 0,a=(a=8<=e.length?e.substring(7,13):void 0)?parseInt(a,10)*Math.pow(10,6-a.length):void 0;if(t&&(isNaN(r)||void 0!==n&&isNaN(n)||void 0!==i&&isNaN(i)||void 0!==a&&isNaN(a)||r<0||23<r||n&&(n<0||59<n)||i&&(i<0||59<i)||a&&(a<0||999999<a)))throw"invalid TM '".concat(e,"'");return{hours:r,minutes:n,seconds:i,fractionalSeconds:a}}if(t)throw"invalid TM '".concat(e,"'")}function c(e,t,r){return!isNaN(r)&&0<t&&t<=12&&0<e&&e<=function(e,t){switch(e){case 2:return t%4==0&&t%100||t%400==0?29:28;case 9:case 4:case 6:case 11:return 30;default:return 31}}(t,r)}function u(e,t){if(e&&8===e.length){var r=parseInt(e.substring(0,4),10),n=parseInt(e.substring(4,6),10),i=parseInt(e.substring(6,8),10);if(t&&!0!==c(i,n,r))throw"invalid DA '".concat(e,"'");return{year:r,month:n,day:i}}if(t)throw"invalid DA '".concat(e,"'")}function f(e,t){if(void 0===e||void 0===t)throw"dicomParser.explicitElementToString: missing required parameters";if(void 0===t.vr)throw"dicomParser.explicitElementToString: cannot convert implicit element to string";var r,n=t.vr,a=t.tag;function o(t,r){for(var n="",i=0;i<t;i++)0!==i&&(n+="/"),n+=r.call(e,a,i).toString();return n}if(!0===i(n))r=e.string(a);else{if("AT"===n){var s=e.uint32(a);return void 0===s?void 0:"x".concat((s=s<0?4294967295+s+1:s).toString(16).toUpperCase())}"US"===n?r=o(t.length/2,e.uint16):"SS"===n?r=o(t.length/2,e.int16):"UL"===n?r=o(t.length/4,e.uint32):"SL"===n?r=o(t.length/4,e.int32):"FD"===n?r=o(t.length/8,e.double):"FL"===n&&(r=o(t.length/4,e.float))}return r}function l(e,t){if(void 0===e)throw"dicomParser.explicitDataSetToJS: missing required parameter dataSet";t=t||{omitPrivateAttibutes:!0,maxElementLength:128};var r,n={};for(r in e.elements){var i=e.elements[r];if(!0!==t.omitPrivateAttibutes||!a(r))if(i.items){for(var o=[],s=0;s<i.items.length;s++)o.push(l(i.items[s].dataSet,t));n[r]=o}else{var c=void 0;i.length<t.maxElementLength&&(c=f(e,i)),n[r]=void 0!==c?c:{dataOffset:i.dataOffset,length:i.length}}}return n}function h(e,t){return 255===e.byteArray[t]&&217===e.byteArray[t+1]}function d(e,t,r){for(var n,i,a=r;a<t.fragments.length;a++)if(i=a,h(n=e,(i=t.fragments[i]).position+i.length-2)||h(n,i.position+i.length-3))return a}function p(e,t,r){if(void 0===e)throw"dicomParser.createJPEGBasicOffsetTable: missing required parameter dataSet";if(void 0===t)throw"dicomParser.createJPEGBasicOffsetTable: missing required parameter pixelDataElement";if("x7fe00010"!==t.tag)throw"dicomParser.createJPEGBasicOffsetTable: parameter 'pixelDataElement' refers to non pixel data tag (expected tag = x7fe00010'";if(!0!==t.encapsulatedPixelData)throw"dicomParser.createJPEGBasicOffsetTable: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(!0!==t.hadUndefinedLength)throw"dicomParser.createJPEGBasicOffsetTable: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(void 0===t.basicOffsetTable)throw"dicomParser.createJPEGBasicOffsetTable: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(void 0===t.fragments)throw"dicomParser.createJPEGBasicOffsetTable: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(t.fragments.length<=0)throw"dicomParser.createJPEGBasicOffsetTable: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(r&&r.length<=0)throw"dicomParser.createJPEGBasicOffsetTable: parameter 'fragments' must not be zero length";r=r||t.fragments;for(var n=[],i=0;;){n.push(t.fragments[i].offset);var a=d(e,t,i);if(void 0===a||a===t.fragments.length-1)return n;i=a+1}}function y(e){if(void 0===e)throw"dicomParser.readTag: missing required parameter 'byteStream'";var t=256*e.readUint16()*256;return e=e.readUint16(),"x".concat("00000000".concat((t+e).toString(16)).substr(-8))}function m(e,t,r){if(void 0===e)throw"dicomParser.findEndOfEncapsulatedElement: missing required parameter 'byteStream'";if(void 0===t)throw"dicomParser.findEndOfEncapsulatedElement: missing required parameter 'element'";if(t.encapsulatedPixelData=!0,t.basicOffsetTable=[],t.fragments=[],"xfffee000"!==y(e))throw"dicomParser.findEndOfEncapsulatedElement: basic offset table not found";for(var n=e.readUint32()/4,i=0;i<n;i++){var a=e.readUint32();t.basicOffsetTable.push(a)}for(var o=e.position;e.position<e.byteArray.length;){var s=y(e),c=e.readUint32();if("xfffee0dd"===s)return e.seek(c),void(t.length=e.position-t.dataOffset);if("xfffee000"!==s)return r&&r.push("unexpected tag ".concat(s," while searching for end of pixel data element with undefined length")),c>e.byteArray.length-e.position&&(c=e.byteArray.length-e.position),t.fragments.push({offset:e.position-o-8,position:e.position,length:c}),e.seek(c),void(t.length=e.position-t.dataOffset);t.fragments.push({offset:e.position-o-8,position:e.position,length:c}),e.seek(c)}r&&r.push("pixel data element ".concat(t.tag," missing sequence delimiter tag xfffee0dd"))}function v(e,t){if(void 0===e)throw"dicomParser.findAndSetUNElementLength: missing required parameter 'byteStream'";for(var r=e.byteArray.length-8;e.position<=r;)if(65534===e.readUint16()&&57565===e.readUint16())return 0!==e.readUint32()&&e.warnings("encountered non zero length following item delimiter at position ".concat(e.position-4," while reading element of undefined length with tag ").concat(t.tag)),void(t.length=e.position-t.dataOffset);t.length=e.byteArray.length-t.dataOffset,e.seek(e.byteArray.length-e.position)}function g(e,t,r){if(r<0)throw"dicomParser.readFixedString - length cannot be less than 0";if(t+r>e.length)throw"dicomParser.readFixedString: attempt to read past end of buffer";for(var n,i="",a=0;a<r;a++){if(0===(n=e[t+a]))return t+=r,i;i+=String.fromCharCode(n)}return i}function b(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function w(e,t){return void 0!==e.parser?e.parser:t}var E=function(){function e(t,r,n){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.byteArrayParser=t,this.byteArray=r,this.elements=n}var t,r,n;return t=e,(r=[{key:"uint16",value:function(e,t){if(t=void 0!==t?t:0,(e=this.elements[e])&&0!==e.length)return w(e,this.byteArrayParser).readUint16(this.byteArray,e.dataOffset+2*t)}},{key:"int16",value:function(e,t){if(t=void 0!==t?t:0,(e=this.elements[e])&&0!==e.length)return w(e,this.byteArrayParser).readInt16(this.byteArray,e.dataOffset+2*t)}},{key:"uint32",value:function(e,t){if(t=void 0!==t?t:0,(e=this.elements[e])&&0!==e.length)return w(e,this.byteArrayParser).readUint32(this.byteArray,e.dataOffset+4*t)}},{key:"int32",value:function(e,t){if(t=void 0!==t?t:0,(e=this.elements[e])&&0!==e.length)return w(e,this.byteArrayParser).readInt32(this.byteArray,e.dataOffset+4*t)}},{key:"float",value:function(e,t){if(t=void 0!==t?t:0,(e=this.elements[e])&&0!==e.length)return w(e,this.byteArrayParser).readFloat(this.byteArray,e.dataOffset+4*t)}},{key:"double",value:function(e,t){if(t=void 0!==t?t:0,(e=this.elements[e])&&0!==e.length)return w(e,this.byteArrayParser).readDouble(this.byteArray,e.dataOffset+8*t)}},{key:"numStringValues",value:function(e){if((e=this.elements[e])&&0<e.length)return null===(e=g(this.byteArray,e.dataOffset,e.length).match(/\\/g))?1:e.length+1}},{key:"string",value:function(e,t){return(e=this.elements[e])&&e.Value?e.Value:e&&0<e.length?(e=g(this.byteArray,e.dataOffset,e.length),0<=t?e.split("\\")[t].trim():e.trim()):void 0}},{key:"text",value:function(e,t){if((e=this.elements[e])&&0<e.length)return e=g(this.byteArray,e.dataOffset,e.length),0<=t?e.split("\\")[t].replace(/ +$/,""):e.replace(/ +$/,"")}},{key:"floatString",value:function(e,t){var r=this.elements[e];if(r&&0<r.length&&void 0!==(t=this.string(e,t=void 0!==t?t:0)))return parseFloat(t)}},{key:"intString",value:function(e,t){var r=this.elements[e];if(r&&0<r.length&&void 0!==(t=this.string(e,t=void 0!==t?t:0)))return parseInt(t)}},{key:"attributeTag",value:function(e){if((r=this.elements[e])&&4===r.length){var t=w(r,this.byteArrayParser).readUint16,r=(e=this.byteArray,r.dataOffset);return"x".concat("00000000".concat((256*t(e,r)*256+t(e,r+2)).toString(16)).substr(-8))}}}])&&b(t.prototype,r),n&&b(t,n),Object.defineProperty(t,"prototype",{writable:!1}),e}();function x(e,t){if(void 0===e)throw"dicomParser.readDicomElementImplicit: missing required parameter 'byteStream'";for(var r=e.byteArray.length-8;e.position<=r;)if(65534===e.readUint16()&&57357===e.readUint16())return 0!==e.readUint32()&&e.warnings("encountered non zero length following item delimiter at position ".concat(e.position-4," while reading element of undefined length with tag ").concat(t.tag)),void(t.length=e.position-t.dataOffset);t.length=e.byteArray.length-t.dataOffset,e.seek(e.byteArray.length-e.position)}var P=function(e,t){return void 0!==e.vr?"SQ"===e.vr:t.position+4<=t.byteArray.length?(e=y(t),t.seek(-4),"xfffee000"===e||"xfffee0dd"===e):(t.warnings.push("eof encountered before finding sequence item tag or sequence delimiter tag in peeking to determine VR"),!1)};function S(e,t,r){if(void 0===e)throw"dicomParser.readDicomElementImplicit: missing required parameter 'byteStream'";var n;return 4294967295===(n={tag:n=y(e),vr:void 0!==r?r(n):void 0,length:e.readUint32(),dataOffset:e.position}).length&&(n.hadUndefinedLength=!0),n.tag===t||(!P(n,e)||a(n.tag)&&!n.hadUndefinedLength?n.hadUndefinedLength?x(e,n):e.seek(n.length):(A(e,n,r),a(n.tag)&&(n.items=void 0))),n}function O(e){if(void 0===e)throw"dicomParser.readSequenceItem: missing required parameter 'byteStream'";var t={tag:y(e),length:e.readUint32(),dataOffset:e.position};if("xfffee000"!==t.tag)throw"dicomParser.readSequenceItem: item tag (FFFE,E000) not found at offset ".concat(e.position);return t}function L(e,t){var r=O(e);return 4294967295===r.length?(r.hadUndefinedLength=!0,r.dataSet=function(e,t){for(var r={};e.position<e.byteArray.length;){var n=S(e,void 0,t);if("xfffee00d"===(r[n.tag]=n).tag)return new E(e.byteArrayParser,e.byteArray,r)}return e.warnings.push("eof encountered before finding sequence item delimiter in sequence item of undefined length"),new E(e.byteArrayParser,e.byteArray,r)}(e,t),r.length=e.position-r.dataOffset):(r.dataSet=new E(e.byteArrayParser,e.byteArray,{}),D(r.dataSet,e,e.position+r.length,{vrCallback:t})),r}function A(e,t,r){if(void 0===e)throw"dicomParser.readSequenceItemsImplicit: missing required parameter 'byteStream'";if(void 0===t)throw"dicomParser.readSequenceItemsImplicit: missing required parameter 'element'";t.items=[],(4294967295===t.length?function(e,t,r){for(;e.position+4<=e.byteArray.length;){var n=y(e);if(e.seek(-4),"xfffee0dd"===n)return t.length=e.position-t.dataOffset,e.seek(8);n=L(e,r),t.items.push(n)}e.warnings.push("eof encountered before finding sequence delimiter in sequence of undefined length"),t.length=e.byteArray.length-t.dataOffset}:function(e,t,r){for(var n=t.dataOffset+t.length;e.position<n;){var i=L(e,r);t.items.push(i)}})(e,t,r)}function k(e,t){var r=O(e);return 4294967295===r.length?(r.hadUndefinedLength=!0,r.dataSet=function(e,t){for(var r={};e.position<e.byteArray.length;){var n=j(e,t);if("xfffee00d"===(r[n.tag]=n).tag)return new E(e.byteArrayParser,e.byteArray,r)}return t.push("eof encountered before finding item delimiter tag while reading sequence item of undefined length"),new E(e.byteArrayParser,e.byteArray,r)}(e,t),r.length=e.position-r.dataOffset):(r.dataSet=new E(e.byteArrayParser,e.byteArray,{}),F(r.dataSet,e,e.position+r.length)),r}function T(e,t,r){if(void 0===e)throw"dicomParser.readSequenceItemsExplicit: missing required parameter 'byteStream'";if(void 0===t)throw"dicomParser.readSequenceItemsExplicit: missing required parameter 'element'";t.items=[],(4294967295===t.length?function(e,t,r){for(;e.position+4<=e.byteArray.length;){var n=y(e);if(e.seek(-4),"xfffee0dd"===n)return t.length=e.position-t.dataOffset,e.seek(8);n=k(e,r),t.items.push(n)}r.push("eof encountered before finding sequence delimitation tag while reading sequence of undefined length"),t.length=e.position-t.dataOffset}:function(e,t,r){for(var n=t.dataOffset+t.length;e.position<n;){var i=k(e,r);t.items.push(i)}})(e,t,r)}var I=function(e){return"OB"===e||"OD"===e||"OL"===e||"OW"===e||"SQ"===e||"OF"===e||"UC"===e||"UR"===e||"UT"===e||"UN"===e?4:2};function j(e,t,r){if(void 0===e)throw"dicomParser.readDicomElementExplicit: missing required parameter 'byteStream'";var n={tag:y(e),vr:e.readFixedString(2)};return 2===I(n.vr)?n.length=e.readUint16():(e.seek(2),n.length=e.readUint32()),n.dataOffset=e.position,4294967295===n.length&&(n.hadUndefinedLength=!0),n.tag===r||("SQ"===n.vr?T(e,n,t):4294967295===n.length?"x7fe00010"===n.tag?m(e,n,t):("UN"===n.vr?A:x)(e,n):e.seek(n.length)),n}function F(e,t,r){var n=3<arguments.length&&void 0!==arguments[3]?arguments[3]:{};if(r=void 0===r?t.byteArray.length:r,void 0===t)throw"dicomParser.parseDicomDataSetExplicit: missing required parameter 'byteStream'";if(r<t.position||r>t.byteArray.length)throw"dicomParser.parseDicomDataSetExplicit: invalid value for parameter 'maxP osition'";for(var i=e.elements;t.position<r;){var a=j(t,e.warnings,n.untilTag);if((i[a.tag]=a).tag===n.untilTag)return}if(t.position>r)throw"dicomParser:parseDicomDataSetExplicit: buffer overrun"}function D(e,t,r){var n=3<arguments.length&&void 0!==arguments[3]?arguments[3]:{};if(r=void 0===r?e.byteArray.length:r,void 0===t)throw"dicomParser.parseDicomDataSetImplicit: missing required parameter 'byteStream'";if(r<t.position||r>t.byteArray.length)throw"dicomParser.parseDicomDataSetImplicit: invalid value for parameter 'maxPosition'";for(var i=e.elements;t.position<r;){var a=S(t,n.untilTag,n.vrCallback);if((i[a.tag]=a).tag===n.untilTag)return}}function _(e,t){if("undefined"!=typeof Buffer&&e instanceof Buffer)return Buffer.alloc(t);if(e instanceof Uint8Array)return new Uint8Array(t);throw"dicomParser.alloc: unknown type for byteArray"}var N="1.8.12",U={readUint16:function(e,t){if(t<0)throw"bigEndianByteArrayParser.readUint16: position cannot be less than 0";if(t+2>e.length)throw"bigEndianByteArrayParser.readUint16: attempt to read past end of buffer";return(e[t]<<8)+e[t+1]},readInt16:function(e,t){if(t<0)throw"bigEndianByteArrayParser.readInt16: position cannot be less than 0";if(t+2>e.length)throw"bigEndianByteArrayParser.readInt16: attempt to read past end of buffer";return 32768&(t=(e[t]<<8)+e[t+1])?t-65535-1:t},readUint32:function(e,t){if(t<0)throw"bigEndianByteArrayParser.readUint32: position cannot be less than 0";if(t+4>e.length)throw"bigEndianByteArrayParser.readUint32: attempt to read past end of buffer";return 256*(256*(256*e[t]+e[t+1])+e[t+2])+e[t+3]},readInt32:function(e,t){if(t<0)throw"bigEndianByteArrayParser.readInt32: position cannot be less than 0";if(t+4>e.length)throw"bigEndianByteArrayParser.readInt32: attempt to read past end of buffer";return(e[t]<<24)+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3]},readFloat:function(e,t){if(t<0)throw"bigEndianByteArrayParser.readFloat: position cannot be less than 0";if(t+4>e.length)throw"bigEndianByteArrayParser.readFloat: attempt to read past end of buffer";var r=new Uint8Array(4);return r[3]=e[t],r[2]=e[t+1],r[1]=e[t+2],r[0]=e[t+3],new Float32Array(r.buffer)[0]},readDouble:function(e,t){if(t<0)throw"bigEndianByteArrayParser.readDouble: position cannot be less than 0";if(t+8>e.length)throw"bigEndianByteArrayParser.readDouble: attempt to read past end of buffer";var r=new Uint8Array(8);return r[7]=e[t],r[6]=e[t+1],r[5]=e[t+2],r[4]=e[t+3],r[3]=e[t+4],r[2]=e[t+5],r[1]=e[t+6],r[0]=e[t+7],new Float64Array(r.buffer)[0]}};function M(e,t,r){if("undefined"!=typeof Buffer&&e instanceof Buffer)return e.slice(t,t+r);if(e instanceof Uint8Array)return new Uint8Array(e.buffer,e.byteOffset+t,r);throw"dicomParser.from: unknown type for byteArray"}function R(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}var B=function(){function e(t,r,n){if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),void 0===t)throw"dicomParser.ByteStream: missing required parameter 'byteArrayParser'";if(void 0===r)throw"dicomParser.ByteStream: missing required parameter 'byteArray'";if(r instanceof Uint8Array==0&&("undefined"==typeof Buffer||r instanceof Buffer==0))throw"dicomParser.ByteStream: parameter byteArray is not of type Uint8Array or Buffer";if(n<0)throw"dicomParser.ByteStream: parameter 'position' cannot be less than 0";if(n>=r.length)throw"dicomParser.ByteStream: parameter 'position' cannot be greater than or equal to 'byteArray' length";this.byteArrayParser=t,this.byteArray=r,this.position=n||0,this.warnings=[]}var t,r,n;return t=e,(r=[{key:"seek",value:function(e){if(this.position+e<0)throw"dicomParser.ByteStream.prototype.seek: cannot seek to position < 0";this.position+=e}},{key:"readByteStream",value:function(t){if(this.position+t>this.byteArray.length)throw"dicomParser.ByteStream.prototype.readByteStream: readByteStream - buffer overread";var r=M(this.byteArray,this.position,t);return this.position+=t,new e(this.byteArrayParser,r)}},{key:"getSize",value:function(){return this.byteArray.length}},{key:"readUint16",value:function(){var e=this.byteArrayParser.readUint16(this.byteArray,this.position);return this.position+=2,e}},{key:"readUint32",value:function(){var e=this.byteArrayParser.readUint32(this.byteArray,this.position);return this.position+=4,e}},{key:"readFixedString",value:function(e){var t=g(this.byteArray,this.position,e);return this.position+=e,t}}])&&R(t.prototype,r),n&&R(t,n),Object.defineProperty(t,"prototype",{writable:!1}),e}(),G={readUint16:function(e,t){if(t<0)throw"littleEndianByteArrayParser.readUint16: position cannot be less than 0";if(t+2>e.length)throw"littleEndianByteArrayParser.readUint16: attempt to read past end of buffer";return e[t]+256*e[t+1]},readInt16:function(e,t){if(t<0)throw"littleEndianByteArrayParser.readInt16: position cannot be less than 0";if(t+2>e.length)throw"littleEndianByteArrayParser.readInt16: attempt to read past end of buffer";return 32768&(t=e[t]+(e[t+1]<<8))?t-65535-1:t},readUint32:function(e,t){if(t<0)throw"littleEndianByteArrayParser.readUint32: position cannot be less than 0";if(t+4>e.length)throw"littleEndianByteArrayParser.readUint32: attempt to read past end of buffer";return e[t]+256*e[t+1]+256*e[t+2]*256+256*e[t+3]*256*256},readInt32:function(e,t){if(t<0)throw"littleEndianByteArrayParser.readInt32: position cannot be less than 0";if(t+4>e.length)throw"littleEndianByteArrayParser.readInt32: attempt to read past end of buffer";return e[t]+(e[t+1]<<8)+(e[t+2]<<16)+(e[t+3]<<24)},readFloat:function(e,t){if(t<0)throw"littleEndianByteArrayParser.readFloat: position cannot be less than 0";if(t+4>e.length)throw"littleEndianByteArrayParser.readFloat: attempt to read past end of buffer";var r=new Uint8Array(4);return r[0]=e[t],r[1]=e[t+1],r[2]=e[t+2],r[3]=e[t+3],new Float32Array(r.buffer)[0]},readDouble:function(e,t){if(t<0)throw"littleEndianByteArrayParser.readDouble: position cannot be less than 0";if(t+8>e.length)throw"littleEndianByteArrayParser.readDouble: attempt to read past end of buffer";var r=new Uint8Array(8);return r[0]=e[t],r[1]=e[t+1],r[2]=e[t+2],r[3]=e[t+3],r[4]=e[t+4],r[5]=e[t+5],r[6]=e[t+6],r[7]=e[t+7],new Float64Array(r.buffer)[0]}};function q(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};if(void 0===e)throw"dicomParser.readPart10Header: missing required parameter 'byteArray'";var r=t.TransferSyntaxUID,n=new B(G,e);return function(){var e=function(){if(n.getSize()<=132&&r)return!1;if(n.seek(128),"DICM"===n.readFixedString(4))return!0;if(!(t||{}).TransferSyntaxUID)throw"dicomParser.readPart10Header: DICM prefix not found at location 132 - this is not a valid DICOM P10 file.";return n.seek(0),!1}(),i=[],a={};if(!e)return n.position=0,{elements:{x00020010:{tag:"x00020010",vr:"UI",Value:r}},warnings:i};for(;n.position<n.byteArray.length;){var o=n.position,s=j(n,i);if("x0002ffff"<s.tag){n.position=o;break}s.parser=G,a[s.tag]=s}return(e=new E(n.byteArrayParser,n.byteArray,a)).warnings=n.warnings,e.position=n.position,e}()}var C="1.2.840.10008.1.2.2";function z(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};if(void 0===e)throw new Error("dicomParser.parseDicom: missing required parameter 'byteArray'");var n,i=function(t){if(void 0===t.elements.x00020010)throw new Error("dicomParser.parseDicom: missing required meta header attribute 0002,0010");return(t=t.elements.x00020010)&&t.Value||g(e,t.dataOffset,t.length)};function a(n){var a="1.2.840.10008.1.2"!==(o=i(n)),o=function(n,i){var a="[object process]"===Object.prototype.toString.call("undefined"!=typeof process?process:0);if("1.2.840.10008.1.2.1.99"!==n)return new B(n===C?U:G,e,i);if(t&&t.inflater)return n=t.inflater(e,i),new B(G,n,0);if(1==a){var o=r(0),s=M(e,i,e.length-i);return o=o.inflateRawSync(s),s=_(e,o.length+i),e.copy(s,0,0,i),o.copy(s,i),new B(G,s,0)}if("undefined"==typeof pako)throw"dicomParser.parseDicom: no inflater available to handle deflate transfer syntax";return o=e.slice(i),s=pako.inflateRaw(o),(o=_(e,s.length+i)).set(e.slice(0,i),0),o.set(s,i),new B(G,o,0)}(o,n.position);(n=new E(o.byteArrayParser,o.byteArray,{})).warnings=o.warnings;try{(a?F:D)(n,o,o.byteArray.length,t)}catch(o){throw{exception:o,dataSet:n}}return n}return function(e,t){for(var r in e.elements)e.elements.hasOwnProperty(r)&&(t.elements[r]=e.elements[r]);return void 0!==e.warnings&&(t.warnings=e.warnings.concat(t.warnings)),t}(n=q(e,t),a(n))}var W=function(e,t,r){for(var n=0,i=t;i<t+r;i++)n+=e[i].length;return n};function Y(e,t,r,n,i){if(i=i||t.fragments,void 0===e)throw"dicomParser.readEncapsulatedPixelDataFromFragments: missing required parameter 'dataSet'";if(void 0===t)throw"dicomParser.readEncapsulatedPixelDataFromFragments: missing required parameter 'pixelDataElement'";if(void 0===r)throw"dicomParser.readEncapsulatedPixelDataFromFragments: missing required parameter 'startFragmentIndex'";if(void 0===(n=n||1))throw"dicomParser.readEncapsulatedPixelDataFromFragments: missing required parameter 'numFragments'";if("x7fe00010"!==t.tag)throw"dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'pixelDataElement' refers to non pixel data tag (expected tag = x7fe00010";if(!0!==t.encapsulatedPixelData)throw"dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(!0!==t.hadUndefinedLength)throw"dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(void 0===t.basicOffsetTable)throw"dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(void 0===t.fragments)throw"dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(t.fragments.length<=0)throw"dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(r<0)throw"dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'startFragmentIndex' must be >= 0";if(r>=t.fragments.length)throw"dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'startFragmentIndex' must be < number of fragments";if(n<1)throw"dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'numFragments' must be > 0";if(r+n>t.fragments.length)throw"dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'startFragment' + 'numFragments' < number of fragments";var a=new B(e.byteArrayParser,e.byteArray,t.dataOffset);if("xfffee000"!==(t=O(a)).tag)throw"dicomParser.readEncapsulatedPixelData: missing basic offset table xfffee000";a.seek(t.length);var o=a.position;if(1===n)return M(a.byteArray,o+i[r].offset+8,i[r].length);t=W(i,r,n);for(var s=_(a.byteArray,t),c=0,u=r;u<r+n;u++)for(var f=o+i[u].offset+8,l=0;l<i[u].length;l++)s[c++]=a.byteArray[f++];return s}var H=function(e,t){for(var r=0;r<e.length;r++)if(e[r].offset===t)return r},V=function(e,t,r,n){if(e===t.length-1)return r.length-n;for(var i=t[e+1],a=n+1;a<r.length;a++)if(r[a].offset===i)return a-n;throw"dicomParser.calculateNumberOfFragmentsForFrame: could not find fragment with offset matching basic offset table"};function J(e,t,r,n,i){if(n=n||t.basicOffsetTable,i=i||t.fragments,void 0===e)throw"dicomParser.readEncapsulatedImageFrame: missing required parameter 'dataSet'";if(void 0===t)throw"dicomParser.readEncapsulatedImageFrame: missing required parameter 'pixelDataElement'";if(void 0===r)throw"dicomParser.readEncapsulatedImageFrame: missing required parameter 'frameIndex'";if(void 0===n)throw"dicomParser.readEncapsulatedImageFrame: parameter 'pixelDataElement' does not have basicOffsetTable";if("x7fe00010"!==t.tag)throw"dicomParser.readEncapsulatedImageFrame: parameter 'pixelDataElement' refers to non pixel data tag (expected tag = x7fe00010)";if(!0!==t.encapsulatedPixelData)throw"dicomParser.readEncapsulatedImageFrame: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(!0!==t.hadUndefinedLength)throw"dicomParser.readEncapsulatedImageFrame: parameter 'pixelDataElement' refers to pixel data element that does not have undefined length";if(void 0===t.fragments)throw"dicomParser.readEncapsulatedImageFrame: parameter 'pixelDataElement' refers to pixel data element that does not have fragments";if(0===n.length)throw"dicomParser.readEncapsulatedImageFrame: basicOffsetTable has zero entries";if(r<0)throw"dicomParser.readEncapsulatedImageFrame: parameter 'frameIndex' must be >= 0";if(r>=n.length)throw"dicomParser.readEncapsulatedImageFrame: parameter 'frameIndex' must be < basicOffsetTable.length";var a=n[r];if(void 0===(a=H(i,a)))throw"dicomParser.readEncapsulatedImageFrame: unable to find fragment that matches basic offset table entry";return Y(e,t,a,V(r,n,i,a),i)}var K=!1;function Q(e,t,r){if(K||(K=!0,console&&console.log&&console.log("WARNING: dicomParser.readEncapsulatedPixelData() has been deprecated")),void 0===e)throw"dicomParser.readEncapsulatedPixelData: missing required parameter 'dataSet'";if(void 0===t)throw"dicomParser.readEncapsulatedPixelData: missing required parameter 'element'";if(void 0===r)throw"dicomParser.readEncapsulatedPixelData: missing required parameter 'frame'";if("x7fe00010"!==t.tag)throw"dicomParser.readEncapsulatedPixelData: parameter 'element' refers to non pixel data tag (expected tag = x7fe00010)";if(!0!==t.encapsulatedPixelData)throw"dicomParser.readEncapsulatedPixelData: parameter 'element' refers to pixel data element that does not have encapsulated pixel data";if(!0!==t.hadUndefinedLength)throw"dicomParser.readEncapsulatedPixelData: parameter 'element' refers to pixel data element that does not have encapsulated pixel data";if(void 0===t.basicOffsetTable)throw"dicomParser.readEncapsulatedPixelData: parameter 'element' refers to pixel data element that does not have encapsulated pixel data";if(void 0===t.fragments)throw"dicomParser.readEncapsulatedPixelData: parameter 'element' refers to pixel data element that does not have encapsulated pixel data";if(r<0)throw"dicomParser.readEncapsulatedPixelData: parameter 'frame' must be >= 0";return 0!==t.basicOffsetTable.length?J(e,t,r):Y(e,t,0,t.fragments.length)}t.default={isStringVr:i,isPrivateTag:a,parsePN:o,parseTM:s,parseDA:u,explicitElementToString:f,explicitDataSetToJS:l,createJPEGBasicOffsetTable:p,parseDicomDataSetExplicit:F,parseDicomDataSetImplicit:D,readFixedString:g,alloc:_,version:N,bigEndianByteArrayParser:U,ByteStream:B,sharedCopy:M,DataSet:E,findAndSetUNElementLength:v,findEndOfEncapsulatedElement:m,findItemDelimitationItemAndSetElementLength:x,littleEndianByteArrayParser:G,parseDicom:z,readDicomElementExplicit:j,readDicomElementImplicit:S,readEncapsulatedImageFrame:J,readEncapsulatedPixelData:Q,readEncapsulatedPixelDataFromFragments:Y,readPart10Header:q,readSequenceItemsExplicit:T,readSequenceItemsImplicit:A,readSequenceItem:O,readTag:y,LEI:"1.2.840.10008.1.2",LEE:"1.2.840.10008.1.2.1"}}],n={},t.m=r,t.c=n,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:n})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,r){if(1&r&&(e=t(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(t.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var i in e)t.d(n,i,function(t){return e[t]}.bind(null,i));return n},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=1);function t(e){if(n[e])return n[e].exports;var i=n[e]={i:e,l:!1,exports:{}};return r[e].call(i.exports,i,i.exports,t),i.l=!0,i.exports}var r,n}(r(559))},559:()=>{}},t={};function r(n){var i=t[n];if(void 0!==i)return i.exports;var a=t[n]={exports:{}};return e[n].call(a.exports,a,a.exports,r),a.exports}r.m=e,r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.u=e=>e+".js",r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(()=>{var e;r.g.importScripts&&(e=r.g.location+"");var t=r.g.document;if(!e&&t&&(t.currentScript&&"SCRIPT"===t.currentScript.tagName.toUpperCase()&&(e=t.currentScript.src),!e)){var n=t.getElementsByTagName("script");if(n.length)for(var i=n.length-1;i>-1&&(!e||!/^http(s?):/.test(e));)e=n[i--].src}if(!e)throw new Error("Automatic publicPath is not supported in this browser");e=e.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),r.p=e})(),r.b=document.baseURI||self.location.href;var n={};return(()=>{"use strict";r.r(n),r.d(n,{CodDicomWebServer:()=>$e,FetchType:()=>a,default:()=>Xe});var e={};r.r(e),r.d(e,{DataRetrieveMode:()=>s,FetchType:()=>a,RequestType:()=>o});var t={};r.r(t),r.d(t,{DOMAIN:()=>P,FILE_EXTENSIONS:()=>S,URL_VALIDATION_STRING:()=>O});var i={};r.r(i),r.d(i,{FILE_PARTIAL_WORKER_NAME:()=>L,FILE_STREAMING_WORKER_NAME:()=>A,THRESHOLD:()=>k});var a=function(e){return e[e.BYTES_OPTIMIZED=0]="BYTES_OPTIMIZED",e[e.API_OPTIMIZED=1]="API_OPTIMIZED",e}({}),o=function(e){return e[e.FRAME=0]="FRAME",e[e.THUMBNAIL=1]="THUMBNAIL",e[e.SERIES_METADATA=2]="SERIES_METADATA",e[e.INSTANCE_METADATA=3]="INSTANCE_METADATA",e}({}),s=function(e){return e[e.WORKER=0]="WORKER",e[e.REQUEST=1]="REQUEST",e}({}),c=r(915);function u(e){return u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},u(e)}function f(e,t,r){return(t=d(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function l(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,d(n.key),n)}}function h(e,t,r){return t&&l(e.prototype,t),r&&l(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function d(e){var t=function(e,t){if("object"!=u(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=u(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==u(t)?t:t+""}function p(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function y(e,t,r){return t=w(t),function(e,t){if(t&&("object"==u(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,g()?Reflect.construct(t,r||[],w(e).constructor):t.apply(e,r))}function m(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&b(e,t)}function v(e){var t="function"==typeof Map?new Map:void 0;return v=function(e){if(null===e||!function(e){try{return-1!==Function.toString.call(e).indexOf("[native code]")}catch(t){return"function"==typeof e}}(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return function(e,t,r){if(g())return Reflect.construct.apply(null,arguments);var n=[null];n.push.apply(n,t);var i=new(e.bind.apply(e,n));return r&&b(i,r.prototype),i}(e,arguments,w(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),b(r,e)},v(e)}function g(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(g=function(){return!!e})()}function b(e,t){return b=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},b(e,t)}function w(e){return w=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},w(e)}var E=function(e){function t(){return p(this,t),y(this,t,arguments)}return m(t,e),h(t)}(v(Error)),x=function(e){function t(e,r){var n;return p(this,t),f(n=y(this,t,[e]),"error",void 0),f(n,"message",void 0),n.message=e,n.error=r,n}return m(t,e),h(t)}(v(Event)),P="https://storage.googleapis.com",S=[".tar",".zip"],O="/dicomweb/",L="filePartial",A="fileStreaming",k=1e4;const T={Enums:e,url:t,dataRetrieval:i};function I(e){return I="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},I(e)}function j(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */j=function(){return t};var e,t={},r=Object.prototype,n=r.hasOwnProperty,i=Object.defineProperty||function(e,t,r){e[t]=r.value},a="function"==typeof Symbol?Symbol:{},o=a.iterator||"@@iterator",s=a.asyncIterator||"@@asyncIterator",c=a.toStringTag||"@@toStringTag";function u(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(e){u=function(e,t,r){return e[t]=r}}function f(e,t,r,n){var a=t&&t.prototype instanceof v?t:v,o=Object.create(a.prototype),s=new F(n||[]);return i(o,"_invoke",{value:L(e,r,s)}),o}function l(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}t.wrap=f;var h="suspendedStart",d="suspendedYield",p="executing",y="completed",m={};function v(){}function g(){}function b(){}var w={};u(w,o,(function(){return this}));var E=Object.getPrototypeOf,x=E&&E(E(D([])));x&&x!==r&&n.call(x,o)&&(w=x);var P=b.prototype=v.prototype=Object.create(w);function S(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function O(e,t){function r(i,a,o,s){var c=l(e[i],e,a);if("throw"!==c.type){var u=c.arg,f=u.value;return f&&"object"==I(f)&&n.call(f,"__await")?t.resolve(f.__await).then((function(e){r("next",e,o,s)}),(function(e){r("throw",e,o,s)})):t.resolve(f).then((function(e){u.value=e,o(u)}),(function(e){return r("throw",e,o,s)}))}s(c.arg)}var a;i(this,"_invoke",{value:function(e,n){function i(){return new t((function(t,i){r(e,n,t,i)}))}return a=a?a.then(i,i):i()}})}function L(t,r,n){var i=h;return function(a,o){if(i===p)throw Error("Generator is already running");if(i===y){if("throw"===a)throw o;return{value:e,done:!0}}for(n.method=a,n.arg=o;;){var s=n.delegate;if(s){var c=A(s,n);if(c){if(c===m)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===h)throw i=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=p;var u=l(t,r,n);if("normal"===u.type){if(i=n.done?y:d,u.arg===m)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(i=y,n.method="throw",n.arg=u.arg)}}}function A(t,r){var n=r.method,i=t.iterator[n];if(i===e)return r.delegate=null,"throw"===n&&t.iterator.return&&(r.method="return",r.arg=e,A(t,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),m;var a=l(i,t.iterator,r.arg);if("throw"===a.type)return r.method="throw",r.arg=a.arg,r.delegate=null,m;var o=a.arg;return o?o.done?(r[t.resultName]=o.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,m):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,m)}function k(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function T(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function F(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(k,this),this.reset(!0)}function D(t){if(t||""===t){var r=t[o];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var i=-1,a=function r(){for(;++i<t.length;)if(n.call(t,i))return r.value=t[i],r.done=!1,r;return r.value=e,r.done=!0,r};return a.next=a}}throw new TypeError(I(t)+" is not iterable")}return g.prototype=b,i(P,"constructor",{value:b,configurable:!0}),i(b,"constructor",{value:g,configurable:!0}),g.displayName=u(b,c,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===g||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,b):(e.__proto__=b,u(e,c,"GeneratorFunction")),e.prototype=Object.create(P),e},t.awrap=function(e){return{__await:e}},S(O.prototype),u(O.prototype,s,(function(){return this})),t.AsyncIterator=O,t.async=function(e,r,n,i,a){void 0===a&&(a=Promise);var o=new O(f(e,r,n,i),a);return t.isGeneratorFunction(r)?o:o.next().then((function(e){return e.done?e.value:o.next()}))},S(P),u(P,c,"Generator"),u(P,o,(function(){return this})),u(P,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},t.values=D,F.prototype={constructor:F,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(T),!t)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function i(n,i){return s.type="throw",s.arg=t,r.next=n,i&&(r.method="next",r.arg=e),!!i}for(var a=this.tryEntries.length-1;a>=0;--a){var o=this.tryEntries[a],s=o.completion;if("root"===o.tryLoc)return i("end");if(o.tryLoc<=this.prev){var c=n.call(o,"catchLoc"),u=n.call(o,"finallyLoc");if(c&&u){if(this.prev<o.catchLoc)return i(o.catchLoc,!0);if(this.prev<o.finallyLoc)return i(o.finallyLoc)}else if(c){if(this.prev<o.catchLoc)return i(o.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return i(o.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var a=i;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=t&&t<=a.finallyLoc&&(a=null);var o=a?a.completion:{};return o.type=e,o.arg=t,a?(this.method="next",this.next=a.finallyLoc,m):this.complete(o)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),m},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),T(r),m}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var i=n.arg;T(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:D(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),m}},t}function F(e,t,r,n,i,a,o){try{var s=e[a](o),c=s.value}catch(e){return void r(e)}s.done?t(c):Promise.resolve(c).then(n,i)}function D(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,N(n.key),n)}}function _(e,t,r){return(t=N(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function N(e){var t=function(e,t){if("object"!=I(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=I(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==I(t)?t:t+""}const U=function(){return e=function e(){var t=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),_(this,"loaderRegistry",{}),_(this,"listenerCallback",(function(e,r,n){var i,a=null===(i=t.loaderRegistry[e])||void 0===i?void 0:i.listeners[r];a&&a.forEach((function(e){return e({data:n})}))}))},t=[{key:"register",value:function(e,t){try{if(!t)throw new E("Loader object for ".concat(e," is not provided"));this.loaderRegistry[e]={loaderObject:t,listeners:{}}}catch(e){throw console.warn(e),new E("throws")}}},{key:"executeTask",value:(n=j().mark((function e(t,r,n){var i,a,o=this;return j().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(a=null===(i=this.loaderRegistry[t])||void 0===i?void 0:i.loaderObject){e.next=3;break}throw new E("Loader ".concat(t," not registered"));case 3:return e.prev=3,e.next=6,a[r](n,(function(e){return o.listenerCallback(t,"message",e)}));case 6:return e.abrupt("return",e.sent);case 9:throw e.prev=9,e.t0=e.catch(3),console.error('Error executing task "'.concat(r,'" on "').concat(t,'":'),e.t0),new E('Task "'.concat(r,'" failed: ').concat(e.t0.message));case 13:case"end":return e.stop()}}),e,this,[[3,9]])})),i=function(){var e=this,t=arguments;return new Promise((function(r,i){var a=n.apply(e,t);function o(e){F(a,r,i,o,s,"next",e)}function s(e){F(a,r,i,o,s,"throw",e)}o(void 0)}))},function(e,t,r){return i.apply(this,arguments)})},{key:"addEventListener",value:function(e,t,r){var n=this.loaderRegistry[e];n?n.listeners[t]?n.listeners[t].push(r):n.listeners[t]=[r]:console.error("Loader '".concat(e,"' is not registered."))}},{key:"removeEventListener",value:function(e,t,r){var n=this.loaderRegistry[e];n?n.listeners[t]=(n.listeners[t]||[]).filter((function(e){return e!==r})):console.error("Loader '".concat(e,"' is not registered."))}},{key:"reset",value:function(){this.loaderRegistry={}}}],t&&D(e.prototype,t),r&&D(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t,r,n,i}();
|
|
15
15
|
/**
|
|
16
16
|
* @license
|
|
17
17
|
* Copyright 2019 Google LLC
|
|
18
18
|
* SPDX-License-Identifier: Apache-2.0
|
|
19
19
|
*/
|
|
20
|
-
const c=Symbol("Comlink.proxy"),u=Symbol("Comlink.endpoint"),f=Symbol("Comlink.releaseProxy"),l=Symbol("Comlink.finalizer"),d=Symbol("Comlink.thrown"),h=e=>"object"==typeof e&&null!==e||"function"==typeof e,p=new Map([["proxy",{canHandle:e=>h(e)&&e[c],serialize(e){const{port1:t,port2:r}=new MessageChannel;return m(e,t),[r,[r]]},deserialize:e=>(e.start(),g(e))}],["throw",{canHandle:e=>h(e)&&d in e,serialize({value:e}){let t;return t=e instanceof Error?{isError:!0,value:{message:e.message,name:e.name,stack:e.stack}}:{isError:!1,value:e},[t,[]]},deserialize(e){if(e.isError)throw Object.assign(new Error(e.value.message),e.value);throw e.value}}]]);function m(e,t=globalThis,r=["*"]){t.addEventListener("message",(function n(a){if(!a||!a.data)return;if(!function(e,t){for(const r of e){if(t===r||"*"===r)return!0;if(r instanceof RegExp&&r.test(t))return!0}return!1}(r,a.origin))return void console.warn(`Invalid origin '${a.origin}' for comlink proxy`);const{id:i,type:o,path:s}=Object.assign({path:[]},a.data),u=(a.data.argumentList||[]).map(O);let f;try{const t=s.slice(0,-1).reduce(((e,t)=>e[t]),e),r=s.reduce(((e,t)=>e[t]),e);switch(o){case"GET":f=r;break;case"SET":t[s.slice(-1)[0]]=O(a.data.value),f=!0;break;case"APPLY":f=r.apply(t,u);break;case"CONSTRUCT":f=function(e){return Object.assign(e,{[c]:!0})}(new r(...u));break;case"ENDPOINT":{const{port1:t,port2:r}=new MessageChannel;m(e,r),f=function(e,t){return S.set(e,t),e}(t,[t])}break;case"RELEASE":f=void 0;break;default:return}}catch(e){f={value:e,[d]:0}}Promise.resolve(f).catch((e=>({value:e,[d]:0}))).then((r=>{const[a,s]=A(r);t.postMessage(Object.assign(Object.assign({},a),{id:i}),s),"RELEASE"===o&&(t.removeEventListener("message",n),y(t),l in e&&"function"==typeof e[l]&&e[l]())})).catch((e=>{const[r,n]=A({value:new TypeError("Unserializable return value"),[d]:0});t.postMessage(Object.assign(Object.assign({},r),{id:i}),n)}))})),t.start&&t.start()}function y(e){(function(e){return"MessagePort"===e.constructor.name})(e)&&e.close()}function g(e,t){const r=new Map;return e.addEventListener("message",(function(e){const{data:t}=e;if(!t||!t.id)return;const n=r.get(t.id);if(n)try{n(t)}finally{r.delete(t.id)}})),x(e,r,[],t)}function v(e){if(e)throw new Error("Proxy has been released and is not useable")}function b(e){return k(e,new Map,{type:"RELEASE"}).then((()=>{y(e)}))}const w=new WeakMap,E="FinalizationRegistry"in globalThis&&new FinalizationRegistry((e=>{const t=(w.get(e)||0)-1;w.set(e,t),0===t&&b(e)}));function x(e,t,r=[],n=function(){}){let a=!1;const i=new Proxy(n,{get(n,o){if(v(a),o===f)return()=>{!function(e){E&&E.unregister(e)}(i),b(e),t.clear(),a=!0};if("then"===o){if(0===r.length)return{then:()=>i};const n=k(e,t,{type:"GET",path:r.map((e=>e.toString()))}).then(O);return n.then.bind(n)}return x(e,t,[...r,o])},set(n,i,o){v(a);const[s,c]=A(o);return k(e,t,{type:"SET",path:[...r,i].map((e=>e.toString())),value:s},c).then(O)},apply(n,i,o){v(a);const s=r[r.length-1];if(s===u)return k(e,t,{type:"ENDPOINT"}).then(O);if("bind"===s)return x(e,t,r.slice(0,-1));const[c,f]=P(o);return k(e,t,{type:"APPLY",path:r.map((e=>e.toString())),argumentList:c},f).then(O)},construct(n,i){v(a);const[o,s]=P(i);return k(e,t,{type:"CONSTRUCT",path:r.map((e=>e.toString())),argumentList:o},s).then(O)}});return function(e,t){const r=(w.get(t)||0)+1;w.set(t,r),E&&E.register(e,t,e)}(i,e),i}function P(e){const t=e.map(A);return[t.map((e=>e[0])),(r=t.map((e=>e[1])),Array.prototype.concat.apply([],r))];var r}const S=new WeakMap;function A(e){for(const[t,r]of p)if(r.canHandle(e)){const[n,a]=r.serialize(e);return[{type:"HANDLER",name:t,value:n},a]}return[{type:"RAW",value:e},S.get(e)||[]]}function O(e){switch(e.type){case"HANDLER":return p.get(e.name).deserialize(e.value);case"RAW":return e.value}}function k(e,t,r,n){return new Promise((a=>{const i=new Array(4).fill(0).map((()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16))).join("-");t.set(i,a),e.start&&e.start(),e.postMessage(Object.assign({id:i},r),n)}))}function I(e){return I="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},I(e)}function T(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */T=function(){return t};var e,t={},r=Object.prototype,n=r.hasOwnProperty,a=Object.defineProperty||function(e,t,r){e[t]=r.value},i="function"==typeof Symbol?Symbol:{},o=i.iterator||"@@iterator",s=i.asyncIterator||"@@asyncIterator",c=i.toStringTag||"@@toStringTag";function u(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(e){u=function(e,t,r){return e[t]=r}}function f(e,t,r,n){var i=t&&t.prototype instanceof g?t:g,o=Object.create(i.prototype),s=new F(n||[]);return a(o,"_invoke",{value:O(e,r,s)}),o}function l(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}t.wrap=f;var d="suspendedStart",h="suspendedYield",p="executing",m="completed",y={};function g(){}function v(){}function b(){}var w={};u(w,o,(function(){return this}));var E=Object.getPrototypeOf,x=E&&E(E(U([])));x&&x!==r&&n.call(x,o)&&(w=x);var P=b.prototype=g.prototype=Object.create(w);function S(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function A(e,t){function r(a,i,o,s){var c=l(e[a],e,i);if("throw"!==c.type){var u=c.arg,f=u.value;return f&&"object"==I(f)&&n.call(f,"__await")?t.resolve(f.__await).then((function(e){r("next",e,o,s)}),(function(e){r("throw",e,o,s)})):t.resolve(f).then((function(e){u.value=e,o(u)}),(function(e){return r("throw",e,o,s)}))}s(c.arg)}var i;a(this,"_invoke",{value:function(e,n){function a(){return new t((function(t,a){r(e,n,t,a)}))}return i=i?i.then(a,a):a()}})}function O(t,r,n){var a=d;return function(i,o){if(a===p)throw Error("Generator is already running");if(a===m){if("throw"===i)throw o;return{value:e,done:!0}}for(n.method=i,n.arg=o;;){var s=n.delegate;if(s){var c=k(s,n);if(c){if(c===y)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(a===d)throw a=m,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);a=p;var u=l(t,r,n);if("normal"===u.type){if(a=n.done?m:h,u.arg===y)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(a=m,n.method="throw",n.arg=u.arg)}}}function k(t,r){var n=r.method,a=t.iterator[n];if(a===e)return r.delegate=null,"throw"===n&&t.iterator.return&&(r.method="return",r.arg=e,k(t,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),y;var i=l(a,t.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,y;var o=i.arg;return o?o.done?(r[t.resultName]=o.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,y):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,y)}function D(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function L(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function F(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(D,this),this.reset(!0)}function U(t){if(t||""===t){var r=t[o];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var a=-1,i=function r(){for(;++a<t.length;)if(n.call(t,a))return r.value=t[a],r.done=!1,r;return r.value=e,r.done=!0,r};return i.next=i}}throw new TypeError(I(t)+" is not iterable")}return v.prototype=b,a(P,"constructor",{value:b,configurable:!0}),a(b,"constructor",{value:v,configurable:!0}),v.displayName=u(b,c,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===v||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,b):(e.__proto__=b,u(e,c,"GeneratorFunction")),e.prototype=Object.create(P),e},t.awrap=function(e){return{__await:e}},S(A.prototype),u(A.prototype,s,(function(){return this})),t.AsyncIterator=A,t.async=function(e,r,n,a,i){void 0===i&&(i=Promise);var o=new A(f(e,r,n,a),i);return t.isGeneratorFunction(r)?o:o.next().then((function(e){return e.done?e.value:o.next()}))},S(P),u(P,c,"Generator"),u(P,o,(function(){return this})),u(P,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},t.values=U,F.prototype={constructor:F,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(L),!t)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function a(n,a){return s.type="throw",s.arg=t,r.next=n,a&&(r.method="next",r.arg=e),!!a}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],s=o.completion;if("root"===o.tryLoc)return a("end");if(o.tryLoc<=this.prev){var c=n.call(o,"catchLoc"),u=n.call(o,"finallyLoc");if(c&&u){if(this.prev<o.catchLoc)return a(o.catchLoc,!0);if(this.prev<o.finallyLoc)return a(o.finallyLoc)}else if(c){if(this.prev<o.catchLoc)return a(o.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return a(o.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc<=this.prev&&n.call(a,"finallyLoc")&&this.prev<a.finallyLoc){var i=a;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var o=i?i.completion:{};return o.type=e,o.arg=t,i?(this.method="next",this.next=i.finallyLoc,y):this.complete(o)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),y},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),L(r),y}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var a=n.arg;L(r)}return a}}throw Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:U(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),y}},t}function D(e,t,r,n,a,i,o){try{var s=e[i](o),c=s.value}catch(e){return void r(e)}s.done?t(c):Promise.resolve(c).then(n,a)}function L(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,F(n.key),n)}}function F(e){var t=function(e,t){if("object"!=I(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=I(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==I(t)?t:t+""}var U=new(function(){return e=function e(){var t,r,n;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),t=this,n={},(r=F(r="workerRegistry"))in t?Object.defineProperty(t,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[r]=n},t=[{key:"registerWorker",value:function(e,t){try{var r=t();if(!r)throw new Error("WorkerFn of worker ".concat(e," is not creating a worker"));this.workerRegistry[e]={instance:g(r),nativeWorker:r}}catch(e){console.warn(e)}}},{key:"executeTask",value:(n=T().mark((function e(t,r,n){var a,i;return T().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=null===(a=this.workerRegistry[t])||void 0===a?void 0:a.instance){e.next=3;break}throw new Error("Worker ".concat(t," not registered"));case 3:return e.prev=3,e.next=6,i[r](n);case 6:return e.abrupt("return",e.sent);case 9:throw e.prev=9,e.t0=e.catch(3),console.error('Error executing task "'.concat(r,'" on worker "').concat(t,'":'),e.t0),new Error('Task "'.concat(r,'" failed: ').concat(e.t0.message));case 13:case"end":return e.stop()}}),e,this,[[3,9]])})),a=function(){var e=this,t=arguments;return new Promise((function(r,a){var i=n.apply(e,t);function o(e){D(i,r,a,o,s,"next",e)}function s(e){D(i,r,a,o,s,"throw",e)}o(void 0)}))},function(e,t,r){return a.apply(this,arguments)})},{key:"addEventListener",value:function(e,t,r){var n=this.workerRegistry[e];n?n.nativeWorker.addEventListener(t,r):console.error("Worker type '".concat(e,"' is not registered."))}},{key:"removeEventListener",value:function(e,t,r){var n=this.workerRegistry[e];n?n.nativeWorker.removeEventListener(t,r):console.error("Worker type '".concat(e,"' is not registered."))}}],t&&L(e.prototype,t),r&&L(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t,r,n,a}());function N(){return U}function _(e){return _="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_(e)}function j(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,a,i,o,s=[],c=!0,u=!1;try{if(i=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=i.call(r)).done)&&(s.push(n.value),s.length!==t);c=!0);}catch(e){u=!0,a=e}finally{try{if(!c&&null!=r.return&&(o=r.return(),Object(o)!==o))return}finally{if(u)throw a}}return s}}(e,t)||function(e,t){if(e){if("string"==typeof e)return M(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?M(e,t):void 0}}(e,t)||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(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function B(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,q(n.key),n)}}function R(e,t,r){return(t=q(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function q(e){var t=function(e,t){if("object"!=_(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=_(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==_(t)?t:t+""}const C=function(){return e=function e(t){var r=t.fileStreamingWorkerName;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),R(this,"files",{}),R(this,"fileStreamingWorkerName",void 0),this.fileStreamingWorkerName=r},(t=[{key:"set",value:function(e,t){this.files[e]=t}},{key:"get",value:function(e,t){return!this.files[e]||t&&this.files[e].position<=t.endByte?null:t?this.files[e].data.slice(t.startByte,t.endByte):this.files[e].data}},{key:"setPosition",value:function(e,t){this.files[e]&&(this.files[e].position=t)}},{key:"getPosition",value:function(e){var t;return null===(t=this.files[e])||void 0===t?void 0:t.position}},{key:"append",value:function(e,t,r){this.files[e]&&r&&(this.files[e].data.set(t,r-t.length),this.setPosition(e,r))}},{key:"getTotalSize",value:function(){return Object.entries(this.files).reduce((function(e,t){var r=j(t,2),n=r[0],a=r[1].position;return n.includes("?bytes=")?e:e+a}),0)}},{key:"remove",value:function(e){var t=this.getPosition(e);delete this.files[e],e.includes("?bytes=")||N().executeTask(this.fileStreamingWorkerName,"decreaseFetchedSize",t)}},{key:"purge",value:function(){var e=this.getTotalSize();this.files={},N().executeTask(this.fileStreamingWorkerName,"decreaseFetchedSize",e)}}])&&B(e.prototype,t),r&&B(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t,r}();var W="https://storage.googleapis.com",G=[".tar",".zip"],z="/dicomweb/",H="filePartial",V="fileStreaming",J=1e4;const Y={Enums:e,url:t,worker:a};function Z(e,t){if(e.includes(Y.url.URL_VALIDATION_STRING)){var r,n=e.split(t+"/")[1],a=n.split("/studies")[0],i=a.split("/"),s=i[0],c=i.slice(1).join("/"),u=n.split(a+"/")[1].split("/"),f=u[1],l=u[3],d="",h=1;switch(!0){case u.includes("thumbnail"):r=o.THUMBNAIL;break;case u.includes("metadata"):u.includes("instances")?(d=u[5],r=o.INSTANCE_METADATA):r=o.SERIES_METADATA;break;case u.includes("frames"):d=u[5],h=+u[7],r=o.FRAME;break;default:throw new Error("Invalid type of request")}return{type:r,bucketName:s,bucketPrefix:c,studyInstanceUID:f,seriesInstanceUID:l,sopInstanceUID:d,frameNumber:h}}}function $(e,t,r,n){var a;if(!e||null===(a=e.cod)||void 0===a||!a.instances)throw new Error("Invalid seriesMetadata provided.");if(null==r)throw new Error("Frame index is required.");var i,o=n.domain,s=n.bucketName,c=n.bucketPrefix;if(e.thumbnail){var u=e.thumbnail.uri;i="".concat(o,"/").concat(u.split("gs://")[1])}var f=Object.values(e.cod.instances).find((function(e){var r;return(null===(r=e.metadata["00080018"])||void 0===r||null===(r=r.Value)||void 0===r?void 0:r[0])===t}));if(!f)return{thumbnailUrl:i};var l,d,h=f.url,p=f.uri,m=f.headers,y=f.offset_tables,g=function(e,t,r,n){var a=e,i=Y.url.FILE_EXTENSIONS.find((function(t){return e.includes(t)}));if(i){a=e.split(i)[0]+i}var o=a.split("studies/")[1];return a="".concat(t,"/").concat(r,"/").concat(n?n+"/":"","studies/").concat(o),a}(h||p,o,s,c),v=y.CustomOffsetTable,b=y.CustomOffsetTableLengths,w=!1;null!=v&&v.length&&null!=b&&b.length&&(d=(l=v[r])+b[r],w=!0);var E=m.start_byte,x=m.end_byte;return{url:g,startByte:void 0!==l?E+l:E,endByte:void 0!==d?E+d:x,thumbnailUrl:i,isMultiframe:w}}function K(e){var t=e.domain,r=void 0===t?Y.url.DOMAIN:t,n=e.bucketName,a=e.bucketPrefix,i=e.studyInstanceUID,o=e.seriesInstanceUID;if(n&&a&&i&&o)return"".concat(r,"/").concat(n,"/").concat(a,"/studies/").concat(i,"/series/").concat(o,"/metadata.json")}function Q(e){return Q="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Q(e)}function X(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */X=function(){return t};var e,t={},r=Object.prototype,n=r.hasOwnProperty,a=Object.defineProperty||function(e,t,r){e[t]=r.value},i="function"==typeof Symbol?Symbol:{},o=i.iterator||"@@iterator",s=i.asyncIterator||"@@asyncIterator",c=i.toStringTag||"@@toStringTag";function u(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(e){u=function(e,t,r){return e[t]=r}}function f(e,t,r,n){var i=t&&t.prototype instanceof g?t:g,o=Object.create(i.prototype),s=new D(n||[]);return a(o,"_invoke",{value:O(e,r,s)}),o}function l(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}t.wrap=f;var d="suspendedStart",h="suspendedYield",p="executing",m="completed",y={};function g(){}function v(){}function b(){}var w={};u(w,o,(function(){return this}));var E=Object.getPrototypeOf,x=E&&E(E(L([])));x&&x!==r&&n.call(x,o)&&(w=x);var P=b.prototype=g.prototype=Object.create(w);function S(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function A(e,t){function r(a,i,o,s){var c=l(e[a],e,i);if("throw"!==c.type){var u=c.arg,f=u.value;return f&&"object"==Q(f)&&n.call(f,"__await")?t.resolve(f.__await).then((function(e){r("next",e,o,s)}),(function(e){r("throw",e,o,s)})):t.resolve(f).then((function(e){u.value=e,o(u)}),(function(e){return r("throw",e,o,s)}))}s(c.arg)}var i;a(this,"_invoke",{value:function(e,n){function a(){return new t((function(t,a){r(e,n,t,a)}))}return i=i?i.then(a,a):a()}})}function O(t,r,n){var a=d;return function(i,o){if(a===p)throw Error("Generator is already running");if(a===m){if("throw"===i)throw o;return{value:e,done:!0}}for(n.method=i,n.arg=o;;){var s=n.delegate;if(s){var c=k(s,n);if(c){if(c===y)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(a===d)throw a=m,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);a=p;var u=l(t,r,n);if("normal"===u.type){if(a=n.done?m:h,u.arg===y)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(a=m,n.method="throw",n.arg=u.arg)}}}function k(t,r){var n=r.method,a=t.iterator[n];if(a===e)return r.delegate=null,"throw"===n&&t.iterator.return&&(r.method="return",r.arg=e,k(t,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),y;var i=l(a,t.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,y;var o=i.arg;return o?o.done?(r[t.resultName]=o.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,y):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,y)}function I(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function T(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function D(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(I,this),this.reset(!0)}function L(t){if(t||""===t){var r=t[o];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var a=-1,i=function r(){for(;++a<t.length;)if(n.call(t,a))return r.value=t[a],r.done=!1,r;return r.value=e,r.done=!0,r};return i.next=i}}throw new TypeError(Q(t)+" is not iterable")}return v.prototype=b,a(P,"constructor",{value:b,configurable:!0}),a(b,"constructor",{value:v,configurable:!0}),v.displayName=u(b,c,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===v||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,b):(e.__proto__=b,u(e,c,"GeneratorFunction")),e.prototype=Object.create(P),e},t.awrap=function(e){return{__await:e}},S(A.prototype),u(A.prototype,s,(function(){return this})),t.AsyncIterator=A,t.async=function(e,r,n,a,i){void 0===i&&(i=Promise);var o=new A(f(e,r,n,a),i);return t.isGeneratorFunction(r)?o:o.next().then((function(e){return e.done?e.value:o.next()}))},S(P),u(P,c,"Generator"),u(P,o,(function(){return this})),u(P,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},t.values=L,D.prototype={constructor:D,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(T),!t)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function a(n,a){return s.type="throw",s.arg=t,r.next=n,a&&(r.method="next",r.arg=e),!!a}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],s=o.completion;if("root"===o.tryLoc)return a("end");if(o.tryLoc<=this.prev){var c=n.call(o,"catchLoc"),u=n.call(o,"finallyLoc");if(c&&u){if(this.prev<o.catchLoc)return a(o.catchLoc,!0);if(this.prev<o.finallyLoc)return a(o.finallyLoc)}else if(c){if(this.prev<o.catchLoc)return a(o.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return a(o.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc<=this.prev&&n.call(a,"finallyLoc")&&this.prev<a.finallyLoc){var i=a;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var o=i?i.completion:{};return o.type=e,o.arg=t,i?(this.method="next",this.next=i.finallyLoc,y):this.complete(o)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),y},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),T(r),y}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var a=n.arg;T(r)}return a}}throw Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:L(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),y}},t}function ee(e,t,r,n,a,i,o){try{var s=e[i](o),c=s.value}catch(e){return void r(e)}s.done?t(c):Promise.resolve(c).then(n,a)}function te(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,re(n.key),n)}}function re(e){var t=function(e,t){if("object"!=Q(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=Q(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==Q(t)?t:t+""}const ne=function(){return e=function e(){var t,r,n;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),t=this,n={},(r=re(r="metadata"))in t?Object.defineProperty(t,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[r]=n},t=[{key:"addDeidMetadata",value:function(e){var t=e.deid_study_uid,r=e.deid_series_uid,n=e.cod;if(n&&t&&r)for(var a in n.instances){var i=n.instances[a];i.metadata.DeidStudyInstanceUID={Value:[t]},i.metadata.DeidSeriesInstanceUID={Value:[r]},i.metadata.DeidSopInstanceUID={Value:[a]}}else console.warn("Missing required metadata properties: cod, deid_study_uid, or deid_series_uid")}},{key:"getMetadataFromCache",value:function(e){return this.metadata[e]}},{key:"getMetadata",value:(n=X().mark((function e(t,r){var n,a,i,o;return X().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=K(t)){e.next=3;break}throw new Error("Error creating metadata json url");case 3:if(!(a=this.getMetadataFromCache(n))){e.next=6;break}return e.abrupt("return",a);case 6:return e.prev=6,e.next=9,fetch(n,{headers:r});case 9:if((i=e.sent).ok){e.next=12;break}throw new Error("Failed to fetch metadata: ".concat(i.statusText));case 12:return e.next=14,i.json();case 14:return o=e.sent,this.addDeidMetadata(o),this.metadata[n]=o,e.abrupt("return",o);case 20:throw e.prev=20,e.t0=e.catch(6),console.error(e.t0),e.t0;case 24:case"end":return e.stop()}}),e,this,[[6,20]])})),a=function(){var e=this,t=arguments;return new Promise((function(r,a){var i=n.apply(e,t);function o(e){ee(i,r,a,o,s,"next",e)}function s(e){ee(i,r,a,o,s,"throw",e)}o(void 0)}))},function(e,t){return a.apply(this,arguments)})}],t&&te(e.prototype,t),r&&te(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t,r,n,a}();function ae(e){return ae="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},ae(e)}function ie(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ie=function(){return t};var e,t={},r=Object.prototype,n=r.hasOwnProperty,a=Object.defineProperty||function(e,t,r){e[t]=r.value},i="function"==typeof Symbol?Symbol:{},o=i.iterator||"@@iterator",s=i.asyncIterator||"@@asyncIterator",c=i.toStringTag||"@@toStringTag";function u(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(e){u=function(e,t,r){return e[t]=r}}function f(e,t,r,n){var i=t&&t.prototype instanceof g?t:g,o=Object.create(i.prototype),s=new D(n||[]);return a(o,"_invoke",{value:O(e,r,s)}),o}function l(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}t.wrap=f;var d="suspendedStart",h="suspendedYield",p="executing",m="completed",y={};function g(){}function v(){}function b(){}var w={};u(w,o,(function(){return this}));var E=Object.getPrototypeOf,x=E&&E(E(L([])));x&&x!==r&&n.call(x,o)&&(w=x);var P=b.prototype=g.prototype=Object.create(w);function S(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function A(e,t){function r(a,i,o,s){var c=l(e[a],e,i);if("throw"!==c.type){var u=c.arg,f=u.value;return f&&"object"==ae(f)&&n.call(f,"__await")?t.resolve(f.__await).then((function(e){r("next",e,o,s)}),(function(e){r("throw",e,o,s)})):t.resolve(f).then((function(e){u.value=e,o(u)}),(function(e){return r("throw",e,o,s)}))}s(c.arg)}var i;a(this,"_invoke",{value:function(e,n){function a(){return new t((function(t,a){r(e,n,t,a)}))}return i=i?i.then(a,a):a()}})}function O(t,r,n){var a=d;return function(i,o){if(a===p)throw Error("Generator is already running");if(a===m){if("throw"===i)throw o;return{value:e,done:!0}}for(n.method=i,n.arg=o;;){var s=n.delegate;if(s){var c=k(s,n);if(c){if(c===y)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(a===d)throw a=m,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);a=p;var u=l(t,r,n);if("normal"===u.type){if(a=n.done?m:h,u.arg===y)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(a=m,n.method="throw",n.arg=u.arg)}}}function k(t,r){var n=r.method,a=t.iterator[n];if(a===e)return r.delegate=null,"throw"===n&&t.iterator.return&&(r.method="return",r.arg=e,k(t,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),y;var i=l(a,t.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,y;var o=i.arg;return o?o.done?(r[t.resultName]=o.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,y):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,y)}function I(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function T(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function D(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(I,this),this.reset(!0)}function L(t){if(t||""===t){var r=t[o];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var a=-1,i=function r(){for(;++a<t.length;)if(n.call(t,a))return r.value=t[a],r.done=!1,r;return r.value=e,r.done=!0,r};return i.next=i}}throw new TypeError(ae(t)+" is not iterable")}return v.prototype=b,a(P,"constructor",{value:b,configurable:!0}),a(b,"constructor",{value:v,configurable:!0}),v.displayName=u(b,c,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===v||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,b):(e.__proto__=b,u(e,c,"GeneratorFunction")),e.prototype=Object.create(P),e},t.awrap=function(e){return{__await:e}},S(A.prototype),u(A.prototype,s,(function(){return this})),t.AsyncIterator=A,t.async=function(e,r,n,a,i){void 0===i&&(i=Promise);var o=new A(f(e,r,n,a),i);return t.isGeneratorFunction(r)?o:o.next().then((function(e){return e.done?e.value:o.next()}))},S(P),u(P,c,"Generator"),u(P,o,(function(){return this})),u(P,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},t.values=L,D.prototype={constructor:D,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(T),!t)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function a(n,a){return s.type="throw",s.arg=t,r.next=n,a&&(r.method="next",r.arg=e),!!a}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],s=o.completion;if("root"===o.tryLoc)return a("end");if(o.tryLoc<=this.prev){var c=n.call(o,"catchLoc"),u=n.call(o,"finallyLoc");if(c&&u){if(this.prev<o.catchLoc)return a(o.catchLoc,!0);if(this.prev<o.finallyLoc)return a(o.finallyLoc)}else if(c){if(this.prev<o.catchLoc)return a(o.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return a(o.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc<=this.prev&&n.call(a,"finallyLoc")&&this.prev<a.finallyLoc){var i=a;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var o=i?i.completion:{};return o.type=e,o.arg=t,i?(this.method="next",this.next=i.finallyLoc,y):this.complete(o)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),y},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),T(r),y}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var a=n.arg;T(r)}return a}}throw Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:L(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),y}},t}function oe(e,t,r,n,a,i,o){try{var s=e[i](o),c=s.value}catch(e){return void r(e)}s.done?t(c):Promise.resolve(c).then(n,a)}function se(e){return function(){var t=this,r=arguments;return new Promise((function(n,a){var i=e.apply(t,r);function o(e){oe(i,n,a,o,s,"next",e)}function s(e){oe(i,n,a,o,s,"throw",e)}o(void 0)}))}}function ce(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,fe(n.key),n)}}function ue(e,t,r){return(t=fe(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function fe(e){var t=function(e,t){if("object"!=ae(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=ae(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==ae(t)?t:t+""}var le=function(){return e=function e(){var t=this,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),ue(this,"filePromises",{}),ue(this,"options",{maxWorkerFetchSize:1/0,domain:Y.url.DOMAIN}),ue(this,"fileManager",void 0),ue(this,"metadataManager",void 0),ue(this,"seriesUidFileUrls",{}),ue(this,"setOptions",(function(e){Object.keys(e).forEach((function(r){void 0!==e[r]&&(t.options[r]=e[r])}))})),ue(this,"getOptions",(function(){return t.options}));var a=n.maxWorkerFetchSize,i=n.domain;this.options.maxWorkerFetchSize=a||this.options.maxWorkerFetchSize,this.options.domain=i||this.options.domain;var o=Y.worker.FILE_STREAMING_WORKER_NAME,s=Y.worker.FILE_PARTIAL_WORKER_NAME;this.fileManager=new C({fileStreamingWorkerName:o}),this.metadataManager=new ne,function(e,t){var n=e.fileStreamingWorkerName,a=e.filePartialWorkerName,i=N();i.registerWorker(n,(function(){return new Worker(new URL(r.p+r.u(170),r.b),{name:n})})),i.executeTask(n,"setMaxFetchSize",t),i.registerWorker(a,(function(){return new Worker(new URL(r.p+r.u(16),r.b),{name:a})}))}({fileStreamingWorkerName:o,filePartialWorkerName:s},this.options.maxWorkerFetchSize)},t=[{key:"addFileUrl",value:function(e,t){this.seriesUidFileUrls[e]?this.seriesUidFileUrls[e].push(t):this.seriesUidFileUrls[e]=[t]}},{key:"fetchCod",value:(c=se(ie().mark((function e(t){var r,n,a,c,u,f,l,d,h,p,m,y,g,v,b,w,E,x,P,S,A,O,k,I=this,T=arguments;return ie().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=T.length>1&&void 0!==T[1]?T[1]:{},a=(n=T.length>2&&void 0!==T[2]?T[2]:{}).useSharedArrayBuffer,c=void 0!==a&&a,u=n.fetchType,f=void 0===u?Y.Enums.FetchType.API_OPTIMIZED:u,e.prev=2,t){e.next=5;break}throw new Error("Url not provided");case 5:if(!(l=Z(t,this.options.domain))){e.next=31;break}return d=l.type,h=l.bucketName,p=l.bucketPrefix,m=l.studyInstanceUID,y=l.seriesInstanceUID,g=l.sopInstanceUID,v=l.frameNumber,e.next=10,this.metadataManager.getMetadata({domain:this.options.domain,bucketName:h,bucketPrefix:p,studyInstanceUID:m,seriesInstanceUID:y},r);case 10:if(b=e.sent){e.next=13;break}throw new Error("Metadata not found for ".concat(t));case 13:w=$(b,g,v-1,{domain:this.options.domain,bucketName:h,bucketPrefix:p}),E=w.url,x=w.startByte,P=w.endByte,S=w.thumbnailUrl,A=w.isMultiframe,e.t0=d,e.next=e.t0===o.THUMBNAIL?17:e.t0===o.FRAME?21:e.t0===o.SERIES_METADATA||e.t0===o.INSTANCE_METADATA?27:28;break;case 17:if(S){e.next=19;break}throw new Error("Thumbnail not found for ".concat(t));case 19:return this.addFileUrl(y,S),e.abrupt("return",this.fetchFile(S,r,{useSharedArrayBuffer:c}));case 21:if(E){e.next=23;break}throw new Error("Url not found for frame");case 23:return O=E,f===i.BYTES_OPTIMIZED&&(O="".concat(E,"?bytes=").concat(x,"-").concat(P)),this.addFileUrl(y,E),e.abrupt("return",this.fetchFile(O,r,{offsets:{startByte:x,endByte:P},useSharedArrayBuffer:c,fetchType:f}).then((function(e){if(null==e||!e.byteLength)throw new Error("File Arraybuffer is not found");if(A)return e;var t=(0,s.parseDicom)(new Uint8Array(e)).elements.x7fe00010,r=t.dataOffset,n=t.length;if(t.hadUndefinedLength&&t.fragments){var a=t.fragments[0];r=a.position,n=a.length}else r+=8;return e.slice(r,r+n)})));case 27:return e.abrupt("return",this.parseMetadata(b,d,g));case 28:throw new Error("Unsupported request type: ".concat(d));case 29:e.next=32;break;case 31:return e.abrupt("return",new Promise((function(e,n){return I.fetchFile(t,r,{useSharedArrayBuffer:c}).then((function(r){if(r instanceof ArrayBuffer)try{var n=(0,s.parseDicom)(new Uint8Array(r)).string("0020000e");n&&I.addFileUrl(n,t)}catch(e){console.warn("CodDicomWebServer.ts: There is some issue parsing the file.",e)}e(r)})).catch((function(e){return n(e)}))})));case 32:e.next=39;break;case 34:throw e.prev=34,e.t1=e.catch(2),k=new Error("CodDicomWebServer.ts: ".concat(e.t1.message||"An error occured when fetching the COD")),console.error(k),k;case 39:case"end":return e.stop()}}),e,this,[[2,34]])}))),function(e){return c.apply(this,arguments)})},{key:"fetchFile",value:(a=se(ie().mark((function e(t,r){var n,a,o,s,c,u,f,l,d,h,p,m,y,g,v,b,w=this,E=arguments;return ie().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(a=(n=E.length>2&&void 0!==E[2]?E[2]:{}).offsets,o=n.useSharedArrayBuffer,s=void 0!==o&&o,c=n.fetchType,u=void 0===c?Y.Enums.FetchType.API_OPTIMIZED:c,f=u===i.BYTES_OPTIMIZED,!(l=this.fileManager.get(t,f?void 0:a))){e.next=5;break}return e.abrupt("return",new Promise((function(e,t){try{e(l.buffer)}catch(e){t(e)}})));case 5:return d=this.getOptions(),h=d.maxWorkerFetchSize,p=N(),m=Y.worker,y=m.FILE_STREAMING_WORKER_NAME,g=m.FILE_PARTIAL_WORKER_NAME,v=m.THRESHOLD,this.filePromises[t]?b=this.filePromises[t]:(b=new Promise((function(e,n){if(w.fileManager.getTotalSize()+v>h)throw new Error("CodDicomWebServer.ts: Maximum size(".concat(h,") for fetching files reached"));var i=Y.Enums.FetchType;if(u===i.API_OPTIMIZED){var o=function(e){if(e instanceof ErrorEvent)throw n(e.error),e.error;var r=e.data,a=r.url,i=r.position,s=r.fileArraybuffer;a===t&&s&&(w.fileManager.set(a,{data:s,position:i}),p.removeEventListener(y,"message",o))};p.addEventListener(y,"message",o),p.executeTask(y,"stream",{url:t,headers:r,useSharedArrayBuffer:s}).then((function(){e()})).catch((function(e){p.removeEventListener(y,"message",o),n(e)})).then((function(){return delete w.filePromises[t]}))}else if(u===i.BYTES_OPTIMIZED&&a){var c=a.startByte,f=a.endByte;r.Range="bytes=".concat(c,"-").concat(f-1);var l=t.split("?bytes=")[0];p.executeTask(g,"partial",{url:l,headers:r,useSharedArrayBuffer:s}).then((function(r){r?(w.fileManager.set(t,{data:new Uint8Array(r),position:r.byteLength}),e()):n(new Error("File - ".concat(l," not found")))})).catch((function(e){n(e)})).then((function(){return delete w.filePromises[t]}))}else n(new Error("CodDicomWebServer.ts: Offsets is needed in bytes optimized fetching"))})),this.filePromises[t]=b),e.abrupt("return",new Promise((function(e,r){var n=!1,i=function(i){if(i instanceof ErrorEvent)throw r(i.message),i.error;var o=i.data,s=o.url,c=o.position,u=o.chunk;if(o.isAppending&&(u?w.fileManager.append(s,u,c):w.fileManager.setPosition(s,c)),!n&&s===t&&a&&c>a.endByte)try{var f=w.fileManager.get(s,a);n=!0,e(null==f?void 0:f.buffer)}catch(e){r(e)}};a&&!f&&p.addEventListener(y,"message",i),b.then((function(){if(!n){var r=w.fileManager.get(t,f?void 0:a);n=!0,e(null==r?void 0:r.buffer)}})).catch((function(e){r(e)})).then((function(){p.removeEventListener(y,"message",i)}))})));case 10:case"end":return e.stop()}}),e,this)}))),function(e,t){return a.apply(this,arguments)})},{key:"delete",value:function(e){var t=this,r=this.seriesUidFileUrls[e];r&&r.forEach((function(e){t.fileManager.remove(e)})),delete this.seriesUidFileUrls[e]}},{key:"deleteAll",value:function(){var e=this;Object.values(this.seriesUidFileUrls).forEach((function(t){t.forEach((function(t){e.fileManager.remove(t)}))})),this.seriesUidFileUrls={}}},{key:"parseMetadata",value:function(e,t,r){var n;return t===o.INSTANCE_METADATA?null===(n=Object.values(e.cod.instances).find((function(e){var t;return(null===(t=e.metadata["00080018"])||void 0===t||null===(t=t.Value)||void 0===t?void 0:t[0])===r})))||void 0===n?void 0:n.metadata:Object.values(e.cod.instances).map((function(e){return e.metadata}))}}],t&&ce(e.prototype,t),n&&ce(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t,n,a,c}();const de=le,he={FetchType:i,CodDicomWebServer:le}})(),n})()));
|
|
20
|
+
const M=Symbol("Comlink.proxy"),R=Symbol("Comlink.endpoint"),B=Symbol("Comlink.releaseProxy"),G=Symbol("Comlink.finalizer"),q=Symbol("Comlink.thrown"),C=e=>"object"==typeof e&&null!==e||"function"==typeof e,z=new Map([["proxy",{canHandle:e=>C(e)&&e[M],serialize(e){const{port1:t,port2:r}=new MessageChannel;return W(e,t),[r,[r]]},deserialize:e=>(e.start(),H(e))}],["throw",{canHandle:e=>C(e)&&q in e,serialize({value:e}){let t;return t=e instanceof Error?{isError:!0,value:{message:e.message,name:e.name,stack:e.stack}}:{isError:!1,value:e},[t,[]]},deserialize(e){if(e.isError)throw Object.assign(new Error(e.value.message),e.value);throw e.value}}]]);function W(e,t=globalThis,r=["*"]){t.addEventListener("message",(function n(i){if(!i||!i.data)return;if(!function(e,t){for(const r of e){if(t===r||"*"===r)return!0;if(r instanceof RegExp&&r.test(t))return!0}return!1}(r,i.origin))return void console.warn(`Invalid origin '${i.origin}' for comlink proxy`);const{id:a,type:o,path:s}=Object.assign({path:[]},i.data),c=(i.data.argumentList||[]).map(te);let u;try{const t=s.slice(0,-1).reduce(((e,t)=>e[t]),e),r=s.reduce(((e,t)=>e[t]),e);switch(o){case"GET":u=r;break;case"SET":t[s.slice(-1)[0]]=te(i.data.value),u=!0;break;case"APPLY":u=r.apply(t,c);break;case"CONSTRUCT":u=function(e){return Object.assign(e,{[M]:!0})}(new r(...c));break;case"ENDPOINT":{const{port1:t,port2:r}=new MessageChannel;W(e,r),u=function(e,t){return X.set(e,t),e}(t,[t])}break;case"RELEASE":u=void 0;break;default:return}}catch(e){u={value:e,[q]:0}}Promise.resolve(u).catch((e=>({value:e,[q]:0}))).then((r=>{const[i,s]=ee(r);t.postMessage(Object.assign(Object.assign({},i),{id:a}),s),"RELEASE"===o&&(t.removeEventListener("message",n),Y(t),G in e&&"function"==typeof e[G]&&e[G]())})).catch((e=>{const[r,n]=ee({value:new TypeError("Unserializable return value"),[q]:0});t.postMessage(Object.assign(Object.assign({},r),{id:a}),n)}))})),t.start&&t.start()}function Y(e){(function(e){return"MessagePort"===e.constructor.name})(e)&&e.close()}function H(e,t){const r=new Map;return e.addEventListener("message",(function(e){const{data:t}=e;if(!t||!t.id)return;const n=r.get(t.id);if(n)try{n(t)}finally{r.delete(t.id)}})),Z(e,r,[],t)}function V(e){if(e)throw new Error("Proxy has been released and is not useable")}function J(e){return re(e,new Map,{type:"RELEASE"}).then((()=>{Y(e)}))}const K=new WeakMap,Q="FinalizationRegistry"in globalThis&&new FinalizationRegistry((e=>{const t=(K.get(e)||0)-1;K.set(e,t),0===t&&J(e)}));function Z(e,t,r=[],n=function(){}){let i=!1;const a=new Proxy(n,{get(n,o){if(V(i),o===B)return()=>{!function(e){Q&&Q.unregister(e)}(a),J(e),t.clear(),i=!0};if("then"===o){if(0===r.length)return{then:()=>a};const n=re(e,t,{type:"GET",path:r.map((e=>e.toString()))}).then(te);return n.then.bind(n)}return Z(e,t,[...r,o])},set(n,a,o){V(i);const[s,c]=ee(o);return re(e,t,{type:"SET",path:[...r,a].map((e=>e.toString())),value:s},c).then(te)},apply(n,a,o){V(i);const s=r[r.length-1];if(s===R)return re(e,t,{type:"ENDPOINT"}).then(te);if("bind"===s)return Z(e,t,r.slice(0,-1));const[c,u]=$(o);return re(e,t,{type:"APPLY",path:r.map((e=>e.toString())),argumentList:c},u).then(te)},construct(n,a){V(i);const[o,s]=$(a);return re(e,t,{type:"CONSTRUCT",path:r.map((e=>e.toString())),argumentList:o},s).then(te)}});return function(e,t){const r=(K.get(t)||0)+1;K.set(t,r),Q&&Q.register(e,t,e)}(a,e),a}function $(e){const t=e.map(ee);return[t.map((e=>e[0])),(r=t.map((e=>e[1])),Array.prototype.concat.apply([],r))];var r}const X=new WeakMap;function ee(e){for(const[t,r]of z)if(r.canHandle(e)){const[n,i]=r.serialize(e);return[{type:"HANDLER",name:t,value:n},i]}return[{type:"RAW",value:e},X.get(e)||[]]}function te(e){switch(e.type){case"HANDLER":return z.get(e.name).deserialize(e.value);case"RAW":return e.value}}function re(e,t,r,n){return new Promise((i=>{const a=new Array(4).fill(0).map((()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16))).join("-");t.set(a,i),e.start&&e.start(),e.postMessage(Object.assign({id:a},r),n)}))}function ne(e){return ne="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},ne(e)}function ie(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ie=function(){return t};var e,t={},r=Object.prototype,n=r.hasOwnProperty,i=Object.defineProperty||function(e,t,r){e[t]=r.value},a="function"==typeof Symbol?Symbol:{},o=a.iterator||"@@iterator",s=a.asyncIterator||"@@asyncIterator",c=a.toStringTag||"@@toStringTag";function u(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(e){u=function(e,t,r){return e[t]=r}}function f(e,t,r,n){var a=t&&t.prototype instanceof v?t:v,o=Object.create(a.prototype),s=new I(n||[]);return i(o,"_invoke",{value:L(e,r,s)}),o}function l(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}t.wrap=f;var h="suspendedStart",d="suspendedYield",p="executing",y="completed",m={};function v(){}function g(){}function b(){}var w={};u(w,o,(function(){return this}));var E=Object.getPrototypeOf,x=E&&E(E(j([])));x&&x!==r&&n.call(x,o)&&(w=x);var P=b.prototype=v.prototype=Object.create(w);function S(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function O(e,t){function r(i,a,o,s){var c=l(e[i],e,a);if("throw"!==c.type){var u=c.arg,f=u.value;return f&&"object"==ne(f)&&n.call(f,"__await")?t.resolve(f.__await).then((function(e){r("next",e,o,s)}),(function(e){r("throw",e,o,s)})):t.resolve(f).then((function(e){u.value=e,o(u)}),(function(e){return r("throw",e,o,s)}))}s(c.arg)}var a;i(this,"_invoke",{value:function(e,n){function i(){return new t((function(t,i){r(e,n,t,i)}))}return a=a?a.then(i,i):i()}})}function L(t,r,n){var i=h;return function(a,o){if(i===p)throw Error("Generator is already running");if(i===y){if("throw"===a)throw o;return{value:e,done:!0}}for(n.method=a,n.arg=o;;){var s=n.delegate;if(s){var c=A(s,n);if(c){if(c===m)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===h)throw i=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=p;var u=l(t,r,n);if("normal"===u.type){if(i=n.done?y:d,u.arg===m)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(i=y,n.method="throw",n.arg=u.arg)}}}function A(t,r){var n=r.method,i=t.iterator[n];if(i===e)return r.delegate=null,"throw"===n&&t.iterator.return&&(r.method="return",r.arg=e,A(t,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),m;var a=l(i,t.iterator,r.arg);if("throw"===a.type)return r.method="throw",r.arg=a.arg,r.delegate=null,m;var o=a.arg;return o?o.done?(r[t.resultName]=o.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,m):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,m)}function k(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function T(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function I(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(k,this),this.reset(!0)}function j(t){if(t||""===t){var r=t[o];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var i=-1,a=function r(){for(;++i<t.length;)if(n.call(t,i))return r.value=t[i],r.done=!1,r;return r.value=e,r.done=!0,r};return a.next=a}}throw new TypeError(ne(t)+" is not iterable")}return g.prototype=b,i(P,"constructor",{value:b,configurable:!0}),i(b,"constructor",{value:g,configurable:!0}),g.displayName=u(b,c,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===g||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,b):(e.__proto__=b,u(e,c,"GeneratorFunction")),e.prototype=Object.create(P),e},t.awrap=function(e){return{__await:e}},S(O.prototype),u(O.prototype,s,(function(){return this})),t.AsyncIterator=O,t.async=function(e,r,n,i,a){void 0===a&&(a=Promise);var o=new O(f(e,r,n,i),a);return t.isGeneratorFunction(r)?o:o.next().then((function(e){return e.done?e.value:o.next()}))},S(P),u(P,c,"Generator"),u(P,o,(function(){return this})),u(P,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},t.values=j,I.prototype={constructor:I,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(T),!t)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function i(n,i){return s.type="throw",s.arg=t,r.next=n,i&&(r.method="next",r.arg=e),!!i}for(var a=this.tryEntries.length-1;a>=0;--a){var o=this.tryEntries[a],s=o.completion;if("root"===o.tryLoc)return i("end");if(o.tryLoc<=this.prev){var c=n.call(o,"catchLoc"),u=n.call(o,"finallyLoc");if(c&&u){if(this.prev<o.catchLoc)return i(o.catchLoc,!0);if(this.prev<o.finallyLoc)return i(o.finallyLoc)}else if(c){if(this.prev<o.catchLoc)return i(o.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return i(o.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var a=i;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=t&&t<=a.finallyLoc&&(a=null);var o=a?a.completion:{};return o.type=e,o.arg=t,a?(this.method="next",this.next=a.finallyLoc,m):this.complete(o)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),m},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),T(r),m}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var i=n.arg;T(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:j(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),m}},t}function ae(e,t,r,n,i,a,o){try{var s=e[a](o),c=s.value}catch(e){return void r(e)}s.done?t(c):Promise.resolve(c).then(n,i)}function oe(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,se(n.key),n)}}function se(e){var t=function(e,t){if("object"!=ne(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=ne(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==ne(t)?t:t+""}const ce=function(){return e=function e(){var t,r,n;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),t=this,n={},(r=se(r="workerRegistry"))in t?Object.defineProperty(t,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[r]=n},t=[{key:"register",value:function(e,t){try{var r=t();if(!r)throw new E("WorkerFn of worker ".concat(e," is not creating a worker"));this.workerRegistry[e]={instance:H(r),nativeWorker:r}}catch(e){console.warn(e)}}},{key:"executeTask",value:(n=ie().mark((function e(t,r,n){var i,a;return ie().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(a=null===(i=this.workerRegistry[t])||void 0===i?void 0:i.instance){e.next=3;break}throw new E("Worker ".concat(t," not registered"));case 3:return e.prev=3,e.next=6,a[r](n);case 6:return e.abrupt("return",e.sent);case 9:throw e.prev=9,e.t0=e.catch(3),console.error('Error executing task "'.concat(r,'" on worker "').concat(t,'":'),e.t0),new E('Task "'.concat(r,'" failed: ').concat(e.t0.message));case 13:case"end":return e.stop()}}),e,this,[[3,9]])})),i=function(){var e=this,t=arguments;return new Promise((function(r,i){var a=n.apply(e,t);function o(e){ae(a,r,i,o,s,"next",e)}function s(e){ae(a,r,i,o,s,"throw",e)}o(void 0)}))},function(e,t,r){return i.apply(this,arguments)})},{key:"addEventListener",value:function(e,t,r){var n=this.workerRegistry[e];n?n.nativeWorker.addEventListener(t,r):console.error("Worker type '".concat(e,"' is not registered."))}},{key:"removeEventListener",value:function(e,t,r){var n=this.workerRegistry[e];n?n.nativeWorker.removeEventListener(t,r):console.error("Worker type '".concat(e,"' is not registered."))}},{key:"reset",value:function(){this.workerRegistry={}}}],t&&oe(e.prototype,t),r&&oe(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t,r,n,i}();function ue(e){return ue="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},ue(e)}function fe(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */fe=function(){return t};var e,t={},r=Object.prototype,n=r.hasOwnProperty,i=Object.defineProperty||function(e,t,r){e[t]=r.value},a="function"==typeof Symbol?Symbol:{},o=a.iterator||"@@iterator",s=a.asyncIterator||"@@asyncIterator",c=a.toStringTag||"@@toStringTag";function u(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(e){u=function(e,t,r){return e[t]=r}}function f(e,t,r,n){var a=t&&t.prototype instanceof v?t:v,o=Object.create(a.prototype),s=new I(n||[]);return i(o,"_invoke",{value:L(e,r,s)}),o}function l(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}t.wrap=f;var h="suspendedStart",d="suspendedYield",p="executing",y="completed",m={};function v(){}function g(){}function b(){}var w={};u(w,o,(function(){return this}));var E=Object.getPrototypeOf,x=E&&E(E(j([])));x&&x!==r&&n.call(x,o)&&(w=x);var P=b.prototype=v.prototype=Object.create(w);function S(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function O(e,t){function r(i,a,o,s){var c=l(e[i],e,a);if("throw"!==c.type){var u=c.arg,f=u.value;return f&&"object"==ue(f)&&n.call(f,"__await")?t.resolve(f.__await).then((function(e){r("next",e,o,s)}),(function(e){r("throw",e,o,s)})):t.resolve(f).then((function(e){u.value=e,o(u)}),(function(e){return r("throw",e,o,s)}))}s(c.arg)}var a;i(this,"_invoke",{value:function(e,n){function i(){return new t((function(t,i){r(e,n,t,i)}))}return a=a?a.then(i,i):i()}})}function L(t,r,n){var i=h;return function(a,o){if(i===p)throw Error("Generator is already running");if(i===y){if("throw"===a)throw o;return{value:e,done:!0}}for(n.method=a,n.arg=o;;){var s=n.delegate;if(s){var c=A(s,n);if(c){if(c===m)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===h)throw i=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=p;var u=l(t,r,n);if("normal"===u.type){if(i=n.done?y:d,u.arg===m)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(i=y,n.method="throw",n.arg=u.arg)}}}function A(t,r){var n=r.method,i=t.iterator[n];if(i===e)return r.delegate=null,"throw"===n&&t.iterator.return&&(r.method="return",r.arg=e,A(t,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),m;var a=l(i,t.iterator,r.arg);if("throw"===a.type)return r.method="throw",r.arg=a.arg,r.delegate=null,m;var o=a.arg;return o?o.done?(r[t.resultName]=o.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,m):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,m)}function k(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function T(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function I(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(k,this),this.reset(!0)}function j(t){if(t||""===t){var r=t[o];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var i=-1,a=function r(){for(;++i<t.length;)if(n.call(t,i))return r.value=t[i],r.done=!1,r;return r.value=e,r.done=!0,r};return a.next=a}}throw new TypeError(ue(t)+" is not iterable")}return g.prototype=b,i(P,"constructor",{value:b,configurable:!0}),i(b,"constructor",{value:g,configurable:!0}),g.displayName=u(b,c,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===g||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,b):(e.__proto__=b,u(e,c,"GeneratorFunction")),e.prototype=Object.create(P),e},t.awrap=function(e){return{__await:e}},S(O.prototype),u(O.prototype,s,(function(){return this})),t.AsyncIterator=O,t.async=function(e,r,n,i,a){void 0===a&&(a=Promise);var o=new O(f(e,r,n,i),a);return t.isGeneratorFunction(r)?o:o.next().then((function(e){return e.done?e.value:o.next()}))},S(P),u(P,c,"Generator"),u(P,o,(function(){return this})),u(P,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},t.values=j,I.prototype={constructor:I,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(T),!t)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function i(n,i){return s.type="throw",s.arg=t,r.next=n,i&&(r.method="next",r.arg=e),!!i}for(var a=this.tryEntries.length-1;a>=0;--a){var o=this.tryEntries[a],s=o.completion;if("root"===o.tryLoc)return i("end");if(o.tryLoc<=this.prev){var c=n.call(o,"catchLoc"),u=n.call(o,"finallyLoc");if(c&&u){if(this.prev<o.catchLoc)return i(o.catchLoc,!0);if(this.prev<o.finallyLoc)return i(o.finallyLoc)}else if(c){if(this.prev<o.catchLoc)return i(o.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return i(o.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var a=i;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=t&&t<=a.finallyLoc&&(a=null);var o=a?a.completion:{};return o.type=e,o.arg=t,a?(this.method="next",this.next=a.finallyLoc,m):this.complete(o)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),m},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),T(r),m}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var i=n.arg;T(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:j(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),m}},t}function le(e,t,r,n,i,a,o){try{var s=e[a](o),c=s.value}catch(e){return void r(e)}s.done?t(c):Promise.resolve(c).then(n,i)}function he(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,pe(n.key),n)}}function de(e,t,r){return(t=pe(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function pe(e){var t=function(e,t){if("object"!=ue(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=ue(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==ue(t)?t:t+""}var ye=new(function(){return e=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),de(this,"dataRetriever",void 0),de(this,"dataRetrieverMode",void 0),"undefined"!=typeof process&&null!=process.versions&&null!=process.versions.node?(this.dataRetriever=new U,this.dataRetrieverMode=s.REQUEST):(this.dataRetriever=new ce,this.dataRetrieverMode=s.WORKER)},t=[{key:"getDataRetrieverMode",value:function(){return this.dataRetrieverMode}},{key:"setDataRetrieverMode",value:function(e){var t=de(de({},s.WORKER,ce),s.REQUEST,U);if(!(e in t))throw new E("Invalid mode");this.dataRetriever.reset(),this.dataRetriever=new t[e],this.dataRetrieverMode=e}},{key:"register",value:function(e,t){this.dataRetriever.register(e,t)}},{key:"executeTask",value:(n=fe().mark((function e(t,r,n){return fe().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.dataRetriever.executeTask(t,r,n);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e,this)})),i=function(){var e=this,t=arguments;return new Promise((function(r,i){var a=n.apply(e,t);function o(e){le(a,r,i,o,s,"next",e)}function s(e){le(a,r,i,o,s,"throw",e)}o(void 0)}))},function(e,t,r){return i.apply(this,arguments)})},{key:"addEventListener",value:function(e,t,r){this.dataRetriever.addEventListener(e,t,r)}},{key:"removeEventListener",value:function(e,t,r){this.dataRetriever.removeEventListener(e,t,r)}},{key:"reset",value:function(){this.dataRetriever.reset()}}],t&&he(e.prototype,t),r&&he(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t,r,n,i}());function me(){return ye}function ve(e){return ve="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},ve(e)}function ge(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,i,a,o,s=[],c=!0,u=!1;try{if(a=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=a.call(r)).done)&&(s.push(n.value),s.length!==t);c=!0);}catch(e){u=!0,i=e}finally{try{if(!c&&null!=r.return&&(o=r.return(),Object(o)!==o))return}finally{if(u)throw i}}return s}}(e,t)||function(e,t){if(e){if("string"==typeof e)return be(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?be(e,t):void 0}}(e,t)||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 be(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function we(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,xe(n.key),n)}}function Ee(e,t,r){return(t=xe(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function xe(e){var t=function(e,t){if("object"!=ve(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=ve(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==ve(t)?t:t+""}const Pe=function(){return e=function e(t){var r=t.fileStreamingWorkerName;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),Ee(this,"files",{}),Ee(this,"fileStreamingWorkerName",void 0),this.fileStreamingWorkerName=r},(t=[{key:"set",value:function(e,t){this.files[e]=t}},{key:"get",value:function(e,t){return!this.files[e]||t&&this.files[e].position<=t.endByte?null:t?this.files[e].data.slice(t.startByte,t.endByte):this.files[e].data}},{key:"setPosition",value:function(e,t){this.files[e]&&(this.files[e].position=t)}},{key:"getPosition",value:function(e){var t;return null===(t=this.files[e])||void 0===t?void 0:t.position}},{key:"append",value:function(e,t,r){this.files[e]&&r&&(this.files[e].data.set(t,r-t.length),this.setPosition(e,r))}},{key:"getTotalSize",value:function(){return Object.entries(this.files).reduce((function(e,t){var r=ge(t,2),n=r[0],i=r[1].position;return n.includes("?bytes=")?e:e+i}),0)}},{key:"remove",value:function(e){var t=this.getPosition(e);delete this.files[e],e.includes("?bytes=")||me().executeTask(this.fileStreamingWorkerName,"decreaseFetchedSize",t)}},{key:"purge",value:function(){var e=this.getTotalSize();this.files={},me().executeTask(this.fileStreamingWorkerName,"decreaseFetchedSize",e)}}])&&we(e.prototype,t),r&&we(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t,r}();function Se(e,t){if(e.includes(T.url.URL_VALIDATION_STRING)){var r,n=e.split(t+"/")[1],i=n.split("/studies")[0],a=i.split("/"),s=a[0],c=a.slice(1).join("/"),u=n.split(i+"/")[1].split("/"),f=u[1],l=u[3],h="",d=1;switch(!0){case u.includes("thumbnail"):r=o.THUMBNAIL;break;case u.includes("metadata"):u.includes("instances")?(h=u[5],r=o.INSTANCE_METADATA):r=o.SERIES_METADATA;break;case u.includes("frames"):h=u[5],d=+u[7],r=o.FRAME;break;default:throw new E("Invalid type of request")}return{type:r,bucketName:s,bucketPrefix:c,studyInstanceUID:f,seriesInstanceUID:l,sopInstanceUID:h,frameNumber:d}}}function Oe(e,t,r,n){var i;if(!e||null===(i=e.cod)||void 0===i||!i.instances)throw new E("Invalid seriesMetadata provided.");if(null==r)throw new E("Frame index is required.");var a,o=n.domain,s=n.bucketName,c=n.bucketPrefix;if(e.thumbnail){var u=e.thumbnail.uri;a="".concat(o,"/").concat(u.split("gs://")[1])}var f=Object.values(e.cod.instances).find((function(e){var r;return(null===(r=e.metadata["00080018"])||void 0===r||null===(r=r.Value)||void 0===r?void 0:r[0])===t}));if(!f)return{thumbnailUrl:a};var l,h,d=f.url,p=f.uri,y=f.headers,m=f.offset_tables,v=function(e,t,r,n){var i=e,a=T.url.FILE_EXTENSIONS.find((function(t){return e.includes(t)}));if(a){i=e.split(a)[0]+a}var o=i.split("studies/")[1];return i="".concat(t,"/").concat(r,"/").concat(n?n+"/":"","studies/").concat(o),i}(d||p,o,s,c),g=m.CustomOffsetTable,b=m.CustomOffsetTableLengths,w=!1;null!=g&&g.length&&null!=b&&b.length&&(h=(l=g[r])+b[r],w=!0);var x=y.start_byte,P=y.end_byte;return{url:v,startByte:void 0!==l?x+l:x,endByte:void 0!==h?x+h:P,thumbnailUrl:a,isMultiframe:w}}function Le(e){var t=e.domain,r=void 0===t?T.url.DOMAIN:t,n=e.bucketName,i=e.bucketPrefix,a=e.studyInstanceUID,o=e.seriesInstanceUID;if(n&&i&&a&&o)return"".concat(r,"/").concat(n,"/").concat(i,"/studies/").concat(a,"/series/").concat(o,"/metadata.json")}function Ae(e){return Ae="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Ae(e)}function ke(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ke=function(){return t};var e,t={},r=Object.prototype,n=r.hasOwnProperty,i=Object.defineProperty||function(e,t,r){e[t]=r.value},a="function"==typeof Symbol?Symbol:{},o=a.iterator||"@@iterator",s=a.asyncIterator||"@@asyncIterator",c=a.toStringTag||"@@toStringTag";function u(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(e){u=function(e,t,r){return e[t]=r}}function f(e,t,r,n){var a=t&&t.prototype instanceof v?t:v,o=Object.create(a.prototype),s=new I(n||[]);return i(o,"_invoke",{value:L(e,r,s)}),o}function l(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}t.wrap=f;var h="suspendedStart",d="suspendedYield",p="executing",y="completed",m={};function v(){}function g(){}function b(){}var w={};u(w,o,(function(){return this}));var E=Object.getPrototypeOf,x=E&&E(E(j([])));x&&x!==r&&n.call(x,o)&&(w=x);var P=b.prototype=v.prototype=Object.create(w);function S(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function O(e,t){function r(i,a,o,s){var c=l(e[i],e,a);if("throw"!==c.type){var u=c.arg,f=u.value;return f&&"object"==Ae(f)&&n.call(f,"__await")?t.resolve(f.__await).then((function(e){r("next",e,o,s)}),(function(e){r("throw",e,o,s)})):t.resolve(f).then((function(e){u.value=e,o(u)}),(function(e){return r("throw",e,o,s)}))}s(c.arg)}var a;i(this,"_invoke",{value:function(e,n){function i(){return new t((function(t,i){r(e,n,t,i)}))}return a=a?a.then(i,i):i()}})}function L(t,r,n){var i=h;return function(a,o){if(i===p)throw Error("Generator is already running");if(i===y){if("throw"===a)throw o;return{value:e,done:!0}}for(n.method=a,n.arg=o;;){var s=n.delegate;if(s){var c=A(s,n);if(c){if(c===m)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===h)throw i=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=p;var u=l(t,r,n);if("normal"===u.type){if(i=n.done?y:d,u.arg===m)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(i=y,n.method="throw",n.arg=u.arg)}}}function A(t,r){var n=r.method,i=t.iterator[n];if(i===e)return r.delegate=null,"throw"===n&&t.iterator.return&&(r.method="return",r.arg=e,A(t,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),m;var a=l(i,t.iterator,r.arg);if("throw"===a.type)return r.method="throw",r.arg=a.arg,r.delegate=null,m;var o=a.arg;return o?o.done?(r[t.resultName]=o.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,m):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,m)}function k(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function T(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function I(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(k,this),this.reset(!0)}function j(t){if(t||""===t){var r=t[o];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var i=-1,a=function r(){for(;++i<t.length;)if(n.call(t,i))return r.value=t[i],r.done=!1,r;return r.value=e,r.done=!0,r};return a.next=a}}throw new TypeError(Ae(t)+" is not iterable")}return g.prototype=b,i(P,"constructor",{value:b,configurable:!0}),i(b,"constructor",{value:g,configurable:!0}),g.displayName=u(b,c,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===g||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,b):(e.__proto__=b,u(e,c,"GeneratorFunction")),e.prototype=Object.create(P),e},t.awrap=function(e){return{__await:e}},S(O.prototype),u(O.prototype,s,(function(){return this})),t.AsyncIterator=O,t.async=function(e,r,n,i,a){void 0===a&&(a=Promise);var o=new O(f(e,r,n,i),a);return t.isGeneratorFunction(r)?o:o.next().then((function(e){return e.done?e.value:o.next()}))},S(P),u(P,c,"Generator"),u(P,o,(function(){return this})),u(P,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},t.values=j,I.prototype={constructor:I,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(T),!t)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function i(n,i){return s.type="throw",s.arg=t,r.next=n,i&&(r.method="next",r.arg=e),!!i}for(var a=this.tryEntries.length-1;a>=0;--a){var o=this.tryEntries[a],s=o.completion;if("root"===o.tryLoc)return i("end");if(o.tryLoc<=this.prev){var c=n.call(o,"catchLoc"),u=n.call(o,"finallyLoc");if(c&&u){if(this.prev<o.catchLoc)return i(o.catchLoc,!0);if(this.prev<o.finallyLoc)return i(o.finallyLoc)}else if(c){if(this.prev<o.catchLoc)return i(o.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return i(o.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var a=i;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=t&&t<=a.finallyLoc&&(a=null);var o=a?a.completion:{};return o.type=e,o.arg=t,a?(this.method="next",this.next=a.finallyLoc,m):this.complete(o)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),m},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),T(r),m}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var i=n.arg;T(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:j(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),m}},t}function Te(e,t,r,n,i,a,o){try{var s=e[a](o),c=s.value}catch(e){return void r(e)}s.done?t(c):Promise.resolve(c).then(n,i)}function Ie(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,je(n.key),n)}}function je(e){var t=function(e,t){if("object"!=Ae(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=Ae(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==Ae(t)?t:t+""}const Fe=function(){return e=function e(){var t,r,n;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),t=this,n={},(r=je(r="metadata"))in t?Object.defineProperty(t,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[r]=n},t=[{key:"addDeidMetadata",value:function(e){var t=e.deid_study_uid,r=e.deid_series_uid,n=e.cod;if(n&&t&&r)for(var i in n.instances){var a=n.instances[i];a.metadata.DeidStudyInstanceUID={Value:[t]},a.metadata.DeidSeriesInstanceUID={Value:[r]},a.metadata.DeidSopInstanceUID={Value:[i]}}else console.warn("Missing required metadata properties: cod, deid_study_uid, or deid_series_uid")}},{key:"getMetadataFromCache",value:function(e){return this.metadata[e]}},{key:"getMetadata",value:(n=ke().mark((function e(t,r){var n,i,a,o;return ke().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=Le(t)){e.next=3;break}throw new E("Error creating metadata json url");case 3:if(!(i=this.getMetadataFromCache(n))){e.next=6;break}return e.abrupt("return",i);case 6:return e.prev=6,e.next=9,fetch(n,{headers:r});case 9:if((a=e.sent).ok){e.next=12;break}throw new E("Failed to fetch metadata: ".concat(a.statusText));case 12:return e.next=14,a.json();case 14:return o=e.sent,this.addDeidMetadata(o),this.metadata[n]=o,e.abrupt("return",o);case 20:throw e.prev=20,e.t0=e.catch(6),console.error(e.t0),e.t0;case 24:case"end":return e.stop()}}),e,this,[[6,20]])})),i=function(){var e=this,t=arguments;return new Promise((function(r,i){var a=n.apply(e,t);function o(e){Te(a,r,i,o,s,"next",e)}function s(e){Te(a,r,i,o,s,"throw",e)}o(void 0)}))},function(e,t){return i.apply(this,arguments)})}],t&&Ie(e.prototype,t),r&&Ie(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t,r,n,i}();function De(e){return De="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},De(e)}function _e(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */_e=function(){return t};var e,t={},r=Object.prototype,n=r.hasOwnProperty,i=Object.defineProperty||function(e,t,r){e[t]=r.value},a="function"==typeof Symbol?Symbol:{},o=a.iterator||"@@iterator",s=a.asyncIterator||"@@asyncIterator",c=a.toStringTag||"@@toStringTag";function u(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(e){u=function(e,t,r){return e[t]=r}}function f(e,t,r,n){var a=t&&t.prototype instanceof v?t:v,o=Object.create(a.prototype),s=new I(n||[]);return i(o,"_invoke",{value:L(e,r,s)}),o}function l(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}t.wrap=f;var h="suspendedStart",d="suspendedYield",p="executing",y="completed",m={};function v(){}function g(){}function b(){}var w={};u(w,o,(function(){return this}));var E=Object.getPrototypeOf,x=E&&E(E(j([])));x&&x!==r&&n.call(x,o)&&(w=x);var P=b.prototype=v.prototype=Object.create(w);function S(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function O(e,t){function r(i,a,o,s){var c=l(e[i],e,a);if("throw"!==c.type){var u=c.arg,f=u.value;return f&&"object"==De(f)&&n.call(f,"__await")?t.resolve(f.__await).then((function(e){r("next",e,o,s)}),(function(e){r("throw",e,o,s)})):t.resolve(f).then((function(e){u.value=e,o(u)}),(function(e){return r("throw",e,o,s)}))}s(c.arg)}var a;i(this,"_invoke",{value:function(e,n){function i(){return new t((function(t,i){r(e,n,t,i)}))}return a=a?a.then(i,i):i()}})}function L(t,r,n){var i=h;return function(a,o){if(i===p)throw Error("Generator is already running");if(i===y){if("throw"===a)throw o;return{value:e,done:!0}}for(n.method=a,n.arg=o;;){var s=n.delegate;if(s){var c=A(s,n);if(c){if(c===m)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===h)throw i=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=p;var u=l(t,r,n);if("normal"===u.type){if(i=n.done?y:d,u.arg===m)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(i=y,n.method="throw",n.arg=u.arg)}}}function A(t,r){var n=r.method,i=t.iterator[n];if(i===e)return r.delegate=null,"throw"===n&&t.iterator.return&&(r.method="return",r.arg=e,A(t,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),m;var a=l(i,t.iterator,r.arg);if("throw"===a.type)return r.method="throw",r.arg=a.arg,r.delegate=null,m;var o=a.arg;return o?o.done?(r[t.resultName]=o.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,m):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,m)}function k(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function T(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function I(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(k,this),this.reset(!0)}function j(t){if(t||""===t){var r=t[o];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var i=-1,a=function r(){for(;++i<t.length;)if(n.call(t,i))return r.value=t[i],r.done=!1,r;return r.value=e,r.done=!0,r};return a.next=a}}throw new TypeError(De(t)+" is not iterable")}return g.prototype=b,i(P,"constructor",{value:b,configurable:!0}),i(b,"constructor",{value:g,configurable:!0}),g.displayName=u(b,c,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===g||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,b):(e.__proto__=b,u(e,c,"GeneratorFunction")),e.prototype=Object.create(P),e},t.awrap=function(e){return{__await:e}},S(O.prototype),u(O.prototype,s,(function(){return this})),t.AsyncIterator=O,t.async=function(e,r,n,i,a){void 0===a&&(a=Promise);var o=new O(f(e,r,n,i),a);return t.isGeneratorFunction(r)?o:o.next().then((function(e){return e.done?e.value:o.next()}))},S(P),u(P,c,"Generator"),u(P,o,(function(){return this})),u(P,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},t.values=j,I.prototype={constructor:I,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(T),!t)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function i(n,i){return s.type="throw",s.arg=t,r.next=n,i&&(r.method="next",r.arg=e),!!i}for(var a=this.tryEntries.length-1;a>=0;--a){var o=this.tryEntries[a],s=o.completion;if("root"===o.tryLoc)return i("end");if(o.tryLoc<=this.prev){var c=n.call(o,"catchLoc"),u=n.call(o,"finallyLoc");if(c&&u){if(this.prev<o.catchLoc)return i(o.catchLoc,!0);if(this.prev<o.finallyLoc)return i(o.finallyLoc)}else if(c){if(this.prev<o.catchLoc)return i(o.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return i(o.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var a=i;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=t&&t<=a.finallyLoc&&(a=null);var o=a?a.completion:{};return o.type=e,o.arg=t,a?(this.method="next",this.next=a.finallyLoc,m):this.complete(o)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),m},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),T(r),m}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var i=n.arg;T(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:j(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),m}},t}function Ne(e,t,r,n,i,a,o){try{var s=e[a](o),c=s.value}catch(e){return void r(e)}s.done?t(c):Promise.resolve(c).then(n,i)}const Ue={partial:function(e,t){return(r=_e().mark((function r(){var n,i;return _e().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return n=e.url,i=e.headers,r.next=3,fetch(n,{headers:i}).then((function(e){return e.arrayBuffer()})).then((function(e){return t({url:n,fileArraybuffer:new Uint8Array(e)})})).catch((function(e){throw new E("filePartial.ts: Error when fetching file: "+(null==e?void 0:e.message))}));case 3:case"end":return r.stop()}}),r)})),function(){var e=this,t=arguments;return new Promise((function(n,i){var a=r.apply(e,t);function o(e){Ne(a,n,i,o,s,"next",e)}function s(e){Ne(a,n,i,o,s,"throw",e)}o(void 0)}))})();var r}};function Me(e){return Me="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Me(e)}function Re(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */Re=function(){return t};var e,t={},r=Object.prototype,n=r.hasOwnProperty,i=Object.defineProperty||function(e,t,r){e[t]=r.value},a="function"==typeof Symbol?Symbol:{},o=a.iterator||"@@iterator",s=a.asyncIterator||"@@asyncIterator",c=a.toStringTag||"@@toStringTag";function u(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(e){u=function(e,t,r){return e[t]=r}}function f(e,t,r,n){var a=t&&t.prototype instanceof v?t:v,o=Object.create(a.prototype),s=new I(n||[]);return i(o,"_invoke",{value:L(e,r,s)}),o}function l(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}t.wrap=f;var h="suspendedStart",d="suspendedYield",p="executing",y="completed",m={};function v(){}function g(){}function b(){}var w={};u(w,o,(function(){return this}));var E=Object.getPrototypeOf,x=E&&E(E(j([])));x&&x!==r&&n.call(x,o)&&(w=x);var P=b.prototype=v.prototype=Object.create(w);function S(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function O(e,t){function r(i,a,o,s){var c=l(e[i],e,a);if("throw"!==c.type){var u=c.arg,f=u.value;return f&&"object"==Me(f)&&n.call(f,"__await")?t.resolve(f.__await).then((function(e){r("next",e,o,s)}),(function(e){r("throw",e,o,s)})):t.resolve(f).then((function(e){u.value=e,o(u)}),(function(e){return r("throw",e,o,s)}))}s(c.arg)}var a;i(this,"_invoke",{value:function(e,n){function i(){return new t((function(t,i){r(e,n,t,i)}))}return a=a?a.then(i,i):i()}})}function L(t,r,n){var i=h;return function(a,o){if(i===p)throw Error("Generator is already running");if(i===y){if("throw"===a)throw o;return{value:e,done:!0}}for(n.method=a,n.arg=o;;){var s=n.delegate;if(s){var c=A(s,n);if(c){if(c===m)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===h)throw i=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=p;var u=l(t,r,n);if("normal"===u.type){if(i=n.done?y:d,u.arg===m)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(i=y,n.method="throw",n.arg=u.arg)}}}function A(t,r){var n=r.method,i=t.iterator[n];if(i===e)return r.delegate=null,"throw"===n&&t.iterator.return&&(r.method="return",r.arg=e,A(t,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),m;var a=l(i,t.iterator,r.arg);if("throw"===a.type)return r.method="throw",r.arg=a.arg,r.delegate=null,m;var o=a.arg;return o?o.done?(r[t.resultName]=o.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,m):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,m)}function k(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function T(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function I(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(k,this),this.reset(!0)}function j(t){if(t||""===t){var r=t[o];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var i=-1,a=function r(){for(;++i<t.length;)if(n.call(t,i))return r.value=t[i],r.done=!1,r;return r.value=e,r.done=!0,r};return a.next=a}}throw new TypeError(Me(t)+" is not iterable")}return g.prototype=b,i(P,"constructor",{value:b,configurable:!0}),i(b,"constructor",{value:g,configurable:!0}),g.displayName=u(b,c,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===g||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,b):(e.__proto__=b,u(e,c,"GeneratorFunction")),e.prototype=Object.create(P),e},t.awrap=function(e){return{__await:e}},S(O.prototype),u(O.prototype,s,(function(){return this})),t.AsyncIterator=O,t.async=function(e,r,n,i,a){void 0===a&&(a=Promise);var o=new O(f(e,r,n,i),a);return t.isGeneratorFunction(r)?o:o.next().then((function(e){return e.done?e.value:o.next()}))},S(P),u(P,c,"Generator"),u(P,o,(function(){return this})),u(P,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},t.values=j,I.prototype={constructor:I,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(T),!t)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function i(n,i){return s.type="throw",s.arg=t,r.next=n,i&&(r.method="next",r.arg=e),!!i}for(var a=this.tryEntries.length-1;a>=0;--a){var o=this.tryEntries[a],s=o.completion;if("root"===o.tryLoc)return i("end");if(o.tryLoc<=this.prev){var c=n.call(o,"catchLoc"),u=n.call(o,"finallyLoc");if(c&&u){if(this.prev<o.catchLoc)return i(o.catchLoc,!0);if(this.prev<o.finallyLoc)return i(o.finallyLoc)}else if(c){if(this.prev<o.catchLoc)return i(o.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return i(o.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var a=i;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=t&&t<=a.finallyLoc&&(a=null);var o=a?a.completion:{};return o.type=e,o.arg=t,a?(this.method="next",this.next=a.finallyLoc,m):this.complete(o)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),m},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),T(r),m}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var i=n.arg;T(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:j(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),m}},t}function Be(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function Ge(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Be(Object(r),!0).forEach((function(t){qe(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Be(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function qe(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=Me(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=Me(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==Me(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Ce(e,t,r,n,i,a,o){try{var s=e[a](o),c=s.value}catch(e){return void r(e)}s.done?t(c):Promise.resolve(c).then(n,i)}const ze={maxFetchSize:4294967296,fetchedSize:0,setMaxFetchSize:function(e){e>0&&(this.maxFetchSize=e)},decreaseFetchedSize:function(e){e>0&&e<=this.fetchedSize&&(this.fetchedSize-=e)},stream:function(e,t){var r,n=this;return(r=Re().mark((function r(){var i,a,o,s,c,u,f,l,h,d,p,y,m,v,g,b;return Re().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return i=e.url,a=e.headers,o=e.useSharedArrayBuffer,s=new AbortController,c=null,u=null,r.prev=4,r.next=7,fetch(i,{headers:Ge({},a),signal:s.signal});case 7:if((l=r.sent).ok){r.next=10;break}throw new E("HTTP error! status: ".concat(l.status));case 10:if(h=null===(f=l.body)||void 0===f?void 0:f.getReader()){r.next=13;break}throw new E("Failed to get reader from response body");case 13:return p=!1,y=parseInt(l.headers.get("Content-Length")||"0",10),r.next=17,h.read();case 17:if(m=r.sent,p=m.done,m.value){r.next=21;break}throw new E("The fetched chunks does not have value");case 21:if(p){r.next=49;break}if(v=m.value.length,!(n.fetchedSize+v>n.maxFetchSize)){r.next=26;break}throw s.abort(),new E("Maximum size(".concat(n.maxFetchSize,") for fetching files reached"));case 26:n.fetchedSize+=v,o?(c=new SharedArrayBuffer(y),u=new Uint8Array(c)):u=new Uint8Array(y),u.set(m.value),t({url:i,position:v,fileArraybuffer:u});case 30:if(p){r.next=49;break}return r.next=33,h.read();case 33:if(!(d=r.sent).done){r.next=37;break}return p=!0,r.abrupt("continue",30);case 37:if(g=d.value,!(n.fetchedSize+g.length>n.maxFetchSize)){r.next=43;break}throw c=null,u=null,s.abort(),new E("Maximum size(".concat(n.maxFetchSize,") for fetching files reached"));case 43:n.fetchedSize+=g.length,u.set(g,v),v+=g.length,t({isAppending:!0,url:i,position:v,chunk:o?void 0:g}),r.next=30;break;case 49:r.next=56;break;case 51:throw r.prev=51,r.t0=r.catch(4),b=new E("fileStreaming.ts: "+r.t0.message||0),console.error(b.message,r.t0),b;case 56:return r.prev=56,c=null,u=null,s.abort(),r.finish(56);case 61:case"end":return r.stop()}}),r,null,[[4,51,56,61]])})),function(){var e=this,t=arguments;return new Promise((function(n,i){var a=r.apply(e,t);function o(e){Ce(a,n,i,o,s,"next",e)}function s(e){Ce(a,n,i,o,s,"throw",e)}o(void 0)}))})()}};function We(e){return We="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},We(e)}function Ye(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */Ye=function(){return t};var e,t={},r=Object.prototype,n=r.hasOwnProperty,i=Object.defineProperty||function(e,t,r){e[t]=r.value},a="function"==typeof Symbol?Symbol:{},o=a.iterator||"@@iterator",s=a.asyncIterator||"@@asyncIterator",c=a.toStringTag||"@@toStringTag";function u(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(e){u=function(e,t,r){return e[t]=r}}function f(e,t,r,n){var a=t&&t.prototype instanceof v?t:v,o=Object.create(a.prototype),s=new I(n||[]);return i(o,"_invoke",{value:L(e,r,s)}),o}function l(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}t.wrap=f;var h="suspendedStart",d="suspendedYield",p="executing",y="completed",m={};function v(){}function g(){}function b(){}var w={};u(w,o,(function(){return this}));var E=Object.getPrototypeOf,x=E&&E(E(j([])));x&&x!==r&&n.call(x,o)&&(w=x);var P=b.prototype=v.prototype=Object.create(w);function S(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function O(e,t){function r(i,a,o,s){var c=l(e[i],e,a);if("throw"!==c.type){var u=c.arg,f=u.value;return f&&"object"==We(f)&&n.call(f,"__await")?t.resolve(f.__await).then((function(e){r("next",e,o,s)}),(function(e){r("throw",e,o,s)})):t.resolve(f).then((function(e){u.value=e,o(u)}),(function(e){return r("throw",e,o,s)}))}s(c.arg)}var a;i(this,"_invoke",{value:function(e,n){function i(){return new t((function(t,i){r(e,n,t,i)}))}return a=a?a.then(i,i):i()}})}function L(t,r,n){var i=h;return function(a,o){if(i===p)throw Error("Generator is already running");if(i===y){if("throw"===a)throw o;return{value:e,done:!0}}for(n.method=a,n.arg=o;;){var s=n.delegate;if(s){var c=A(s,n);if(c){if(c===m)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===h)throw i=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=p;var u=l(t,r,n);if("normal"===u.type){if(i=n.done?y:d,u.arg===m)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(i=y,n.method="throw",n.arg=u.arg)}}}function A(t,r){var n=r.method,i=t.iterator[n];if(i===e)return r.delegate=null,"throw"===n&&t.iterator.return&&(r.method="return",r.arg=e,A(t,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),m;var a=l(i,t.iterator,r.arg);if("throw"===a.type)return r.method="throw",r.arg=a.arg,r.delegate=null,m;var o=a.arg;return o?o.done?(r[t.resultName]=o.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,m):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,m)}function k(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function T(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function I(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(k,this),this.reset(!0)}function j(t){if(t||""===t){var r=t[o];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var i=-1,a=function r(){for(;++i<t.length;)if(n.call(t,i))return r.value=t[i],r.done=!1,r;return r.value=e,r.done=!0,r};return a.next=a}}throw new TypeError(We(t)+" is not iterable")}return g.prototype=b,i(P,"constructor",{value:b,configurable:!0}),i(b,"constructor",{value:g,configurable:!0}),g.displayName=u(b,c,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===g||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,b):(e.__proto__=b,u(e,c,"GeneratorFunction")),e.prototype=Object.create(P),e},t.awrap=function(e){return{__await:e}},S(O.prototype),u(O.prototype,s,(function(){return this})),t.AsyncIterator=O,t.async=function(e,r,n,i,a){void 0===a&&(a=Promise);var o=new O(f(e,r,n,i),a);return t.isGeneratorFunction(r)?o:o.next().then((function(e){return e.done?e.value:o.next()}))},S(P),u(P,c,"Generator"),u(P,o,(function(){return this})),u(P,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},t.values=j,I.prototype={constructor:I,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(T),!t)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function i(n,i){return s.type="throw",s.arg=t,r.next=n,i&&(r.method="next",r.arg=e),!!i}for(var a=this.tryEntries.length-1;a>=0;--a){var o=this.tryEntries[a],s=o.completion;if("root"===o.tryLoc)return i("end");if(o.tryLoc<=this.prev){var c=n.call(o,"catchLoc"),u=n.call(o,"finallyLoc");if(c&&u){if(this.prev<o.catchLoc)return i(o.catchLoc,!0);if(this.prev<o.finallyLoc)return i(o.finallyLoc)}else if(c){if(this.prev<o.catchLoc)return i(o.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return i(o.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var a=i;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=t&&t<=a.finallyLoc&&(a=null);var o=a?a.completion:{};return o.type=e,o.arg=t,a?(this.method="next",this.next=a.finallyLoc,m):this.complete(o)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),m},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),T(r),m}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var i=n.arg;T(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:j(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),m}},t}function He(e,t,r,n,i,a,o){try{var s=e[a](o),c=s.value}catch(e){return void r(e)}s.done?t(c):Promise.resolve(c).then(n,i)}function Ve(e){return function(){var t=this,r=arguments;return new Promise((function(n,i){var a=e.apply(t,r);function o(e){He(a,n,i,o,s,"next",e)}function s(e){He(a,n,i,o,s,"throw",e)}o(void 0)}))}}function Je(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,Qe(n.key),n)}}function Ke(e,t,r){return(t=Qe(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Qe(e){var t=function(e,t){if("object"!=We(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=We(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==We(t)?t:t+""}var Ze=function(){return e=function e(){var t=this,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),Ke(this,"filePromises",{}),Ke(this,"options",{maxWorkerFetchSize:1/0,domain:T.url.DOMAIN}),Ke(this,"fileManager",void 0),Ke(this,"metadataManager",void 0),Ke(this,"seriesUidFileUrls",{}),Ke(this,"setOptions",(function(e){Object.keys(e).forEach((function(r){void 0!==e[r]&&(t.options[r]=e[r])}))})),Ke(this,"getOptions",(function(){return t.options}));var i=n.maxWorkerFetchSize,a=n.domain,o=n.disableWorker;this.options.maxWorkerFetchSize=i||this.options.maxWorkerFetchSize,this.options.domain=a||this.options.domain;var c=T.dataRetrieval.FILE_STREAMING_WORKER_NAME,u=T.dataRetrieval.FILE_PARTIAL_WORKER_NAME;this.fileManager=new Pe({fileStreamingWorkerName:c}),this.metadataManager=new Fe,o&&me().setDataRetrieverMode(s.REQUEST),function(e,t){var n=e.fileStreamingScriptName,i=e.filePartialScriptName,a=me();a.getDataRetrieverMode()===s.REQUEST?(a.register(n,ze),a.register(i,Ue)):(a.register(n,(function(){return new Worker(new URL(r.p+r.u(66),r.b),{name:n})})),a.register(i,(function(){return new Worker(new URL(r.p+r.u(614),r.b),{name:i})}))),a.executeTask(n,"setMaxFetchSize",t)}({fileStreamingScriptName:c,filePartialScriptName:u},this.options.maxWorkerFetchSize)},t=[{key:"addFileUrl",value:function(e,t){this.seriesUidFileUrls[e]?this.seriesUidFileUrls[e].push(t):this.seriesUidFileUrls[e]=[t]}},{key:"fetchCod",value:(u=Ve(Ye().mark((function e(t){var r,n,i,s,u,f,l,h,d,p,y,m,v,g,b,w,x,P,S,O,L,A,k,I=this,j=arguments;return Ye().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=j.length>1&&void 0!==j[1]?j[1]:{},i=(n=j.length>2&&void 0!==j[2]?j[2]:{}).useSharedArrayBuffer,s=void 0!==i&&i,u=n.fetchType,f=void 0===u?T.Enums.FetchType.API_OPTIMIZED:u,e.prev=2,t){e.next=5;break}throw new E("Url not provided");case 5:if(!(l=Se(t,this.options.domain))){e.next=31;break}return h=l.type,d=l.bucketName,p=l.bucketPrefix,y=l.studyInstanceUID,m=l.seriesInstanceUID,v=l.sopInstanceUID,g=l.frameNumber,e.next=10,this.metadataManager.getMetadata({domain:this.options.domain,bucketName:d,bucketPrefix:p,studyInstanceUID:y,seriesInstanceUID:m},r);case 10:if(b=e.sent){e.next=13;break}throw new E("Metadata not found for ".concat(t));case 13:w=Oe(b,v,g-1,{domain:this.options.domain,bucketName:d,bucketPrefix:p}),x=w.url,P=w.startByte,S=w.endByte,O=w.thumbnailUrl,L=w.isMultiframe,e.t0=h,e.next=e.t0===o.THUMBNAIL?17:e.t0===o.FRAME?21:e.t0===o.SERIES_METADATA||e.t0===o.INSTANCE_METADATA?27:28;break;case 17:if(O){e.next=19;break}throw new E("Thumbnail not found for ".concat(t));case 19:return this.addFileUrl(m,O),e.abrupt("return",this.fetchFile(O,r,{useSharedArrayBuffer:s}));case 21:if(x){e.next=23;break}throw new E("Url not found for frame");case 23:return A=x,f===a.BYTES_OPTIMIZED&&(A="".concat(x,"?bytes=").concat(P,"-").concat(S)),this.addFileUrl(m,x),e.abrupt("return",this.fetchFile(A,r,{offsets:{startByte:P,endByte:S},useSharedArrayBuffer:s,fetchType:f}).then((function(e){if(null==e||!e.byteLength)throw new E("File Arraybuffer is not found");if(L)return e;var t=(0,c.parseDicom)(new Uint8Array(e)).elements.x7fe00010,r=t.dataOffset,n=t.length;if(t.hadUndefinedLength&&t.fragments){var i=t.fragments[0];r=i.position,n=i.length}else r+=8;return e.slice(r,r+n)})));case 27:return e.abrupt("return",this.parseMetadata(b,h,v));case 28:throw new E("Unsupported request type: ".concat(h));case 29:e.next=32;break;case 31:return e.abrupt("return",new Promise((function(e,n){return I.fetchFile(t,r,{useSharedArrayBuffer:s}).then((function(r){if(r instanceof ArrayBuffer)try{var n=(0,c.parseDicom)(new Uint8Array(r)).string("0020000e");n&&I.addFileUrl(n,t)}catch(e){console.warn("CodDicomWebServer.ts: There is some issue parsing the file.",e)}e(r)})).catch((function(e){return n(e)}))})));case 32:e.next=39;break;case 34:throw e.prev=34,e.t1=e.catch(2),k=new E("CodDicomWebServer.ts: ".concat(e.t1.message||"An error occured when fetching the COD")),console.error(k),k;case 39:case"end":return e.stop()}}),e,this,[[2,34]])}))),function(e){return u.apply(this,arguments)})},{key:"fetchFile",value:(i=Ve(Ye().mark((function e(t,r){var n,i,o,s,c,u,f,l,h,d,p,y,m,v,g,b,w=this,P=arguments;return Ye().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=(n=P.length>2&&void 0!==P[2]?P[2]:{}).offsets,o=n.useSharedArrayBuffer,s=void 0!==o&&o,c=n.fetchType,u=void 0===c?T.Enums.FetchType.API_OPTIMIZED:c,f=u===a.BYTES_OPTIMIZED,!(l=this.fileManager.get(t,f?void 0:i))){e.next=5;break}return e.abrupt("return",new Promise((function(e,t){try{e(l.buffer)}catch(e){t(e)}})));case 5:return h=this.getOptions(),d=h.maxWorkerFetchSize,p=me(),y=T.dataRetrieval,m=y.FILE_STREAMING_WORKER_NAME,v=y.FILE_PARTIAL_WORKER_NAME,g=y.THRESHOLD,this.filePromises[t]?b=this.filePromises[t]:(b=new Promise((function(e,n){if(w.fileManager.getTotalSize()+g>d)throw new E("CodDicomWebServer.ts: Maximum size(".concat(d,") for fetching files reached"));var a=T.Enums.FetchType;if(u===a.API_OPTIMIZED){var o=function(e){if(e instanceof x)throw n(e.error),e.error;var r=e.data,i=r.url,a=r.position,s=r.fileArraybuffer;i===t&&s&&(w.fileManager.set(i,{data:s,position:a}),p.removeEventListener(m,"message",o))};p.addEventListener(m,"message",o),p.executeTask(m,"stream",{url:t,headers:r,useSharedArrayBuffer:s}).then((function(){w.fileManager.getPosition(t)?e():n(new E("File - ".concat(t," not found")))})).catch((function(e){n(e)})).then((function(){p.removeEventListener(m,"message",o),delete w.filePromises[t]}))}else if(u===a.BYTES_OPTIMIZED&&i){var c=i.startByte,f=i.endByte;r.Range="bytes=".concat(c,"-").concat(f-1);var l=t.split("?bytes=")[0],h=function(e){if(e instanceof x)throw n(e.error),e.error;var r=e.data,i=r.url,a=r.fileArraybuffer;i===l&&(w.fileManager.set(t,{data:a,position:a.length}),p.removeEventListener(v,"message",h))};p.addEventListener(v,"message",h),p.executeTask(v,"partial",{url:l,headers:r,useSharedArrayBuffer:s}).then((function(){w.fileManager.getPosition(t)?e():n(new E("File - ".concat(t," not found")))})).catch((function(e){n(e)})).then((function(){p.removeEventListener(v,"message",h),delete w.filePromises[t]}))}else n(new E("CodDicomWebServer.ts: Offsets is needed in bytes optimized fetching"))})),this.filePromises[t]=b),e.abrupt("return",new Promise((function(e,r){var n=!1,a=function(a){if(a instanceof x)throw r(a.message),a.error;var o=a.data,s=o.url,c=o.position,u=o.chunk;if(o.isAppending&&(u?w.fileManager.append(s,u,c):w.fileManager.setPosition(s,c)),!n&&s===t&&i&&c>i.endByte)try{var f=w.fileManager.get(s,i);n=!0,e(null==f?void 0:f.buffer)}catch(e){r(e)}};i&&!f&&p.addEventListener(m,"message",a),b.then((function(){if(!n){var r=w.fileManager.get(t,f?void 0:i);n=!0,e(null==r?void 0:r.buffer)}})).catch((function(e){r(e)})).then((function(){p.removeEventListener(m,"message",a)}))})));case 10:case"end":return e.stop()}}),e,this)}))),function(e,t){return i.apply(this,arguments)})},{key:"delete",value:function(e){var t=this,r=this.seriesUidFileUrls[e];r&&r.forEach((function(e){t.fileManager.remove(e)})),delete this.seriesUidFileUrls[e]}},{key:"deleteAll",value:function(){var e=this;Object.values(this.seriesUidFileUrls).forEach((function(t){t.forEach((function(t){e.fileManager.remove(t)}))})),this.seriesUidFileUrls={}}},{key:"parseMetadata",value:function(e,t,r){var n;return t===o.INSTANCE_METADATA?null===(n=Object.values(e.cod.instances).find((function(e){var t;return(null===(t=e.metadata["00080018"])||void 0===t||null===(t=t.Value)||void 0===t?void 0:t[0])===r})))||void 0===n?void 0:n.metadata:Object.values(e.cod.instances).map((function(e){return e.metadata}))}}],t&&Je(e.prototype,t),n&&Je(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t,n,i,u}();const $e=Ze,Xe={FetchType:a,CodDicomWebServer:Ze}})(),n})()));
|
|
21
21
|
//# sourceMappingURL=main.js.map
|