UNPKG

cod-dicomweb-server

Version:

A wadors server proxy that get data from a Cloud Optimized Dicom format.

14 lines 139 kB
/*! * * cod-dicomweb-server v1.3.12 * git+https://github.com/gradienthealth/cod-dicomweb-server.git * * Copyright (c) Adithyan Dinesh and project contributors. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * */ !function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var r=e();for(var n in r)("object"==typeof exports?exports:t)[n]=r[n]}}(self,(()=>(()=>{var t={915:function(t,e,r){ /*! dicom-parser - 1.8.12 - 2023-02-20 | (c) 2017 Chris Hafey | https://github.com/cornerstonejs/dicomParser */ t.exports=function(t){return r=[function(e,r){e.exports=t},function(t,e,r){"use strict";r.r(e),r.d(e,"isStringVr",(function(){return o})),r.d(e,"isPrivateTag",(function(){return a})),r.d(e,"parsePN",(function(){return i})),r.d(e,"parseTM",(function(){return c})),r.d(e,"parseDA",(function(){return s})),r.d(e,"explicitElementToString",(function(){return f})),r.d(e,"explicitDataSetToJS",(function(){return l})),r.d(e,"createJPEGBasicOffsetTable",(function(){return p})),r.d(e,"parseDicomDataSetExplicit",(function(){return D})),r.d(e,"parseDicomDataSetImplicit",(function(){return _})),r.d(e,"readFixedString",(function(){return g})),r.d(e,"alloc",(function(){return F})),r.d(e,"version",(function(){return N})),r.d(e,"bigEndianByteArrayParser",(function(){return U})),r.d(e,"ByteStream",(function(){return B})),r.d(e,"sharedCopy",(function(){return M})),r.d(e,"DataSet",(function(){return E})),r.d(e,"findAndSetUNElementLength",(function(){return m})),r.d(e,"findEndOfEncapsulatedElement",(function(){return v})),r.d(e,"findItemDelimitationItemAndSetElementLength",(function(){return x})),r.d(e,"littleEndianByteArrayParser",(function(){return G})),r.d(e,"parseDicom",(function(){return H})),r.d(e,"readDicomElementExplicit",(function(){return I})),r.d(e,"readDicomElementImplicit",(function(){return S})),r.d(e,"readEncapsulatedImageFrame",(function(){return V})),r.d(e,"readEncapsulatedPixelData",(function(){return $})),r.d(e,"readEncapsulatedPixelDataFromFragments",(function(){return z})),r.d(e,"readPart10Header",(function(){return C})),r.d(e,"readSequenceItemsExplicit",(function(){return j})),r.d(e,"readSequenceItemsImplicit",(function(){return A})),r.d(e,"readSequenceItem",(function(){return O})),r.d(e,"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},o=function(t){return n[t]},a=function(t){if(t=parseInt(t[4],16),isNaN(t))throw"dicomParser.isPrivateTag: cannot parse last character of group";return t%2==1},i=function(t){if(void 0!==t)return{familyName:(t=t.split("^"))[0],givenName:t[1],middleName:t[2],prefix:t[3],suffix:t[4]}};function c(t,e){if(2<=t.length){var r=parseInt(t.substring(0,2),10),n=4<=t.length?parseInt(t.substring(2,4),10):void 0,o=6<=t.length?parseInt(t.substring(4,6),10):void 0,a=(a=8<=t.length?t.substring(7,13):void 0)?parseInt(a,10)*Math.pow(10,6-a.length):void 0;if(e&&(isNaN(r)||void 0!==n&&isNaN(n)||void 0!==o&&isNaN(o)||void 0!==a&&isNaN(a)||r<0||23<r||n&&(n<0||59<n)||o&&(o<0||59<o)||a&&(a<0||999999<a)))throw"invalid TM '".concat(t,"'");return{hours:r,minutes:n,seconds:o,fractionalSeconds:a}}if(e)throw"invalid TM '".concat(t,"'")}function u(t,e,r){return!isNaN(r)&&0<e&&e<=12&&0<t&&t<=function(t,e){switch(t){case 2:return e%4==0&&e%100||e%400==0?29:28;case 9:case 4:case 6:case 11:return 30;default:return 31}}(e,r)}function s(t,e){if(t&&8===t.length){var r=parseInt(t.substring(0,4),10),n=parseInt(t.substring(4,6),10),o=parseInt(t.substring(6,8),10);if(e&&!0!==u(o,n,r))throw"invalid DA '".concat(t,"'");return{year:r,month:n,day:o}}if(e)throw"invalid DA '".concat(t,"'")}function f(t,e){if(void 0===t||void 0===e)throw"dicomParser.explicitElementToString: missing required parameters";if(void 0===e.vr)throw"dicomParser.explicitElementToString: cannot convert implicit element to string";var r,n=e.vr,a=e.tag;function i(e,r){for(var n="",o=0;o<e;o++)0!==o&&(n+="/"),n+=r.call(t,a,o).toString();return n}if(!0===o(n))r=t.string(a);else{if("AT"===n){var c=t.uint32(a);return void 0===c?void 0:"x".concat((c=c<0?4294967295+c+1:c).toString(16).toUpperCase())}"US"===n?r=i(e.length/2,t.uint16):"SS"===n?r=i(e.length/2,t.int16):"UL"===n?r=i(e.length/4,t.uint32):"SL"===n?r=i(e.length/4,t.int32):"FD"===n?r=i(e.length/8,t.double):"FL"===n&&(r=i(e.length/4,t.float))}return r}function l(t,e){if(void 0===t)throw"dicomParser.explicitDataSetToJS: missing required parameter dataSet";e=e||{omitPrivateAttibutes:!0,maxElementLength:128};var r,n={};for(r in t.elements){var o=t.elements[r];if(!0!==e.omitPrivateAttibutes||!a(r))if(o.items){for(var i=[],c=0;c<o.items.length;c++)i.push(l(o.items[c].dataSet,e));n[r]=i}else{var u=void 0;o.length<e.maxElementLength&&(u=f(t,o)),n[r]=void 0!==u?u:{dataOffset:o.dataOffset,length:o.length}}}return n}function h(t,e){return 255===t.byteArray[e]&&217===t.byteArray[e+1]}function d(t,e,r){for(var n,o,a=r;a<e.fragments.length;a++)if(o=a,h(n=t,(o=e.fragments[o]).position+o.length-2)||h(n,o.position+o.length-3))return a}function p(t,e,r){if(void 0===t)throw"dicomParser.createJPEGBasicOffsetTable: missing required parameter dataSet";if(void 0===e)throw"dicomParser.createJPEGBasicOffsetTable: missing required parameter pixelDataElement";if("x7fe00010"!==e.tag)throw"dicomParser.createJPEGBasicOffsetTable: parameter 'pixelDataElement' refers to non pixel data tag (expected tag = x7fe00010'";if(!0!==e.encapsulatedPixelData)throw"dicomParser.createJPEGBasicOffsetTable: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(!0!==e.hadUndefinedLength)throw"dicomParser.createJPEGBasicOffsetTable: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(void 0===e.basicOffsetTable)throw"dicomParser.createJPEGBasicOffsetTable: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(void 0===e.fragments)throw"dicomParser.createJPEGBasicOffsetTable: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(e.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||e.fragments;for(var n=[],o=0;;){n.push(e.fragments[o].offset);var a=d(t,e,o);if(void 0===a||a===e.fragments.length-1)return n;o=a+1}}function y(t){if(void 0===t)throw"dicomParser.readTag: missing required parameter 'byteStream'";var e=256*t.readUint16()*256;return t=t.readUint16(),"x".concat("00000000".concat((e+t).toString(16)).substr(-8))}function v(t,e,r){if(void 0===t)throw"dicomParser.findEndOfEncapsulatedElement: missing required parameter 'byteStream'";if(void 0===e)throw"dicomParser.findEndOfEncapsulatedElement: missing required parameter 'element'";if(e.encapsulatedPixelData=!0,e.basicOffsetTable=[],e.fragments=[],"xfffee000"!==y(t))throw"dicomParser.findEndOfEncapsulatedElement: basic offset table not found";for(var n=t.readUint32()/4,o=0;o<n;o++){var a=t.readUint32();e.basicOffsetTable.push(a)}for(var i=t.position;t.position<t.byteArray.length;){var c=y(t),u=t.readUint32();if("xfffee0dd"===c)return t.seek(u),void(e.length=t.position-e.dataOffset);if("xfffee000"!==c)return r&&r.push("unexpected tag ".concat(c," while searching for end of pixel data element with undefined length")),u>t.byteArray.length-t.position&&(u=t.byteArray.length-t.position),e.fragments.push({offset:t.position-i-8,position:t.position,length:u}),t.seek(u),void(e.length=t.position-e.dataOffset);e.fragments.push({offset:t.position-i-8,position:t.position,length:u}),t.seek(u)}r&&r.push("pixel data element ".concat(e.tag," missing sequence delimiter tag xfffee0dd"))}function m(t,e){if(void 0===t)throw"dicomParser.findAndSetUNElementLength: missing required parameter 'byteStream'";for(var r=t.byteArray.length-8;t.position<=r;)if(65534===t.readUint16()&&57565===t.readUint16())return 0!==t.readUint32()&&t.warnings("encountered non zero length following item delimiter at position ".concat(t.position-4," while reading element of undefined length with tag ").concat(e.tag)),void(e.length=t.position-e.dataOffset);e.length=t.byteArray.length-e.dataOffset,t.seek(t.byteArray.length-t.position)}function g(t,e,r){if(r<0)throw"dicomParser.readFixedString - length cannot be less than 0";if(e+r>t.length)throw"dicomParser.readFixedString: attempt to read past end of buffer";for(var n,o="",a=0;a<r;a++){if(0===(n=t[e+a]))return e+=r,o;o+=String.fromCharCode(n)}return o}function b(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function w(t,e){return void 0!==t.parser?t.parser:e}var E=function(){function t(e,r,n){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.byteArrayParser=e,this.byteArray=r,this.elements=n}var e,r,n;return e=t,(r=[{key:"uint16",value:function(t,e){if(e=void 0!==e?e:0,(t=this.elements[t])&&0!==t.length)return w(t,this.byteArrayParser).readUint16(this.byteArray,t.dataOffset+2*e)}},{key:"int16",value:function(t,e){if(e=void 0!==e?e:0,(t=this.elements[t])&&0!==t.length)return w(t,this.byteArrayParser).readInt16(this.byteArray,t.dataOffset+2*e)}},{key:"uint32",value:function(t,e){if(e=void 0!==e?e:0,(t=this.elements[t])&&0!==t.length)return w(t,this.byteArrayParser).readUint32(this.byteArray,t.dataOffset+4*e)}},{key:"int32",value:function(t,e){if(e=void 0!==e?e:0,(t=this.elements[t])&&0!==t.length)return w(t,this.byteArrayParser).readInt32(this.byteArray,t.dataOffset+4*e)}},{key:"float",value:function(t,e){if(e=void 0!==e?e:0,(t=this.elements[t])&&0!==t.length)return w(t,this.byteArrayParser).readFloat(this.byteArray,t.dataOffset+4*e)}},{key:"double",value:function(t,e){if(e=void 0!==e?e:0,(t=this.elements[t])&&0!==t.length)return w(t,this.byteArrayParser).readDouble(this.byteArray,t.dataOffset+8*e)}},{key:"numStringValues",value:function(t){if((t=this.elements[t])&&0<t.length)return null===(t=g(this.byteArray,t.dataOffset,t.length).match(/\\/g))?1:t.length+1}},{key:"string",value:function(t,e){return(t=this.elements[t])&&t.Value?t.Value:t&&0<t.length?(t=g(this.byteArray,t.dataOffset,t.length),0<=e?t.split("\\")[e].trim():t.trim()):void 0}},{key:"text",value:function(t,e){if((t=this.elements[t])&&0<t.length)return t=g(this.byteArray,t.dataOffset,t.length),0<=e?t.split("\\")[e].replace(/ +$/,""):t.replace(/ +$/,"")}},{key:"floatString",value:function(t,e){var r=this.elements[t];if(r&&0<r.length&&void 0!==(e=this.string(t,e=void 0!==e?e:0)))return parseFloat(e)}},{key:"intString",value:function(t,e){var r=this.elements[t];if(r&&0<r.length&&void 0!==(e=this.string(t,e=void 0!==e?e:0)))return parseInt(e)}},{key:"attributeTag",value:function(t){if((r=this.elements[t])&&4===r.length){var e=w(r,this.byteArrayParser).readUint16,r=(t=this.byteArray,r.dataOffset);return"x".concat("00000000".concat((256*e(t,r)*256+e(t,r+2)).toString(16)).substr(-8))}}}])&&b(e.prototype,r),n&&b(e,n),Object.defineProperty(e,"prototype",{writable:!1}),t}();function x(t,e){if(void 0===t)throw"dicomParser.readDicomElementImplicit: missing required parameter 'byteStream'";for(var r=t.byteArray.length-8;t.position<=r;)if(65534===t.readUint16()&&57357===t.readUint16())return 0!==t.readUint32()&&t.warnings("encountered non zero length following item delimiter at position ".concat(t.position-4," while reading element of undefined length with tag ").concat(e.tag)),void(e.length=t.position-e.dataOffset);e.length=t.byteArray.length-e.dataOffset,t.seek(t.byteArray.length-t.position)}var P=function(t,e){return void 0!==t.vr?"SQ"===t.vr:e.position+4<=e.byteArray.length?(t=y(e),e.seek(-4),"xfffee000"===t||"xfffee0dd"===t):(e.warnings.push("eof encountered before finding sequence item tag or sequence delimiter tag in peeking to determine VR"),!1)};function S(t,e,r){if(void 0===t)throw"dicomParser.readDicomElementImplicit: missing required parameter 'byteStream'";var n;return 4294967295===(n={tag:n=y(t),vr:void 0!==r?r(n):void 0,length:t.readUint32(),dataOffset:t.position}).length&&(n.hadUndefinedLength=!0),n.tag===e||(!P(n,t)||a(n.tag)&&!n.hadUndefinedLength?n.hadUndefinedLength?x(t,n):t.seek(n.length):(A(t,n,r),a(n.tag)&&(n.items=void 0))),n}function O(t){if(void 0===t)throw"dicomParser.readSequenceItem: missing required parameter 'byteStream'";var e={tag:y(t),length:t.readUint32(),dataOffset:t.position};if("xfffee000"!==e.tag)throw"dicomParser.readSequenceItem: item tag (FFFE,E000) not found at offset ".concat(t.position);return e}function L(t,e){var r=O(t);return 4294967295===r.length?(r.hadUndefinedLength=!0,r.dataSet=function(t,e){for(var r={};t.position<t.byteArray.length;){var n=S(t,void 0,e);if("xfffee00d"===(r[n.tag]=n).tag)return new E(t.byteArrayParser,t.byteArray,r)}return t.warnings.push("eof encountered before finding sequence item delimiter in sequence item of undefined length"),new E(t.byteArrayParser,t.byteArray,r)}(t,e),r.length=t.position-r.dataOffset):(r.dataSet=new E(t.byteArrayParser,t.byteArray,{}),_(r.dataSet,t,t.position+r.length,{vrCallback:e})),r}function A(t,e,r){if(void 0===t)throw"dicomParser.readSequenceItemsImplicit: missing required parameter 'byteStream'";if(void 0===e)throw"dicomParser.readSequenceItemsImplicit: missing required parameter 'element'";e.items=[],(4294967295===e.length?function(t,e,r){for(;t.position+4<=t.byteArray.length;){var n=y(t);if(t.seek(-4),"xfffee0dd"===n)return e.length=t.position-e.dataOffset,t.seek(8);n=L(t,r),e.items.push(n)}t.warnings.push("eof encountered before finding sequence delimiter in sequence of undefined length"),e.length=t.byteArray.length-e.dataOffset}:function(t,e,r){for(var n=e.dataOffset+e.length;t.position<n;){var o=L(t,r);e.items.push(o)}})(t,e,r)}function k(t,e){var r=O(t);return 4294967295===r.length?(r.hadUndefinedLength=!0,r.dataSet=function(t,e){for(var r={};t.position<t.byteArray.length;){var n=I(t,e);if("xfffee00d"===(r[n.tag]=n).tag)return new E(t.byteArrayParser,t.byteArray,r)}return e.push("eof encountered before finding item delimiter tag while reading sequence item of undefined length"),new E(t.byteArrayParser,t.byteArray,r)}(t,e),r.length=t.position-r.dataOffset):(r.dataSet=new E(t.byteArrayParser,t.byteArray,{}),D(r.dataSet,t,t.position+r.length)),r}function j(t,e,r){if(void 0===t)throw"dicomParser.readSequenceItemsExplicit: missing required parameter 'byteStream'";if(void 0===e)throw"dicomParser.readSequenceItemsExplicit: missing required parameter 'element'";e.items=[],(4294967295===e.length?function(t,e,r){for(;t.position+4<=t.byteArray.length;){var n=y(t);if(t.seek(-4),"xfffee0dd"===n)return e.length=t.position-e.dataOffset,t.seek(8);n=k(t,r),e.items.push(n)}r.push("eof encountered before finding sequence delimitation tag while reading sequence of undefined length"),e.length=t.position-e.dataOffset}:function(t,e,r){for(var n=e.dataOffset+e.length;t.position<n;){var o=k(t,r);e.items.push(o)}})(t,e,r)}var T=function(t){return"OB"===t||"OD"===t||"OL"===t||"OW"===t||"SQ"===t||"OF"===t||"UC"===t||"UR"===t||"UT"===t||"UN"===t?4:2};function I(t,e,r){if(void 0===t)throw"dicomParser.readDicomElementExplicit: missing required parameter 'byteStream'";var n={tag:y(t),vr:t.readFixedString(2)};return 2===T(n.vr)?n.length=t.readUint16():(t.seek(2),n.length=t.readUint32()),n.dataOffset=t.position,4294967295===n.length&&(n.hadUndefinedLength=!0),n.tag===r||("SQ"===n.vr?j(t,n,e):4294967295===n.length?"x7fe00010"===n.tag?v(t,n,e):("UN"===n.vr?A:x)(t,n):t.seek(n.length)),n}function D(t,e,r){var n=3<arguments.length&&void 0!==arguments[3]?arguments[3]:{};if(r=void 0===r?e.byteArray.length:r,void 0===e)throw"dicomParser.parseDicomDataSetExplicit: missing required parameter 'byteStream'";if(r<e.position||r>e.byteArray.length)throw"dicomParser.parseDicomDataSetExplicit: invalid value for parameter 'maxP osition'";for(var o=t.elements;e.position<r;){var a=I(e,t.warnings,n.untilTag);if((o[a.tag]=a).tag===n.untilTag)return}if(e.position>r)throw"dicomParser:parseDicomDataSetExplicit: buffer overrun"}function _(t,e,r){var n=3<arguments.length&&void 0!==arguments[3]?arguments[3]:{};if(r=void 0===r?t.byteArray.length:r,void 0===e)throw"dicomParser.parseDicomDataSetImplicit: missing required parameter 'byteStream'";if(r<e.position||r>e.byteArray.length)throw"dicomParser.parseDicomDataSetImplicit: invalid value for parameter 'maxPosition'";for(var o=t.elements;e.position<r;){var a=S(e,n.untilTag,n.vrCallback);if((o[a.tag]=a).tag===n.untilTag)return}}function F(t,e){if("undefined"!=typeof Buffer&&t instanceof Buffer)return Buffer.alloc(e);if(t instanceof Uint8Array)return new Uint8Array(e);throw"dicomParser.alloc: unknown type for byteArray"}var N="1.8.12",U={readUint16:function(t,e){if(e<0)throw"bigEndianByteArrayParser.readUint16: position cannot be less than 0";if(e+2>t.length)throw"bigEndianByteArrayParser.readUint16: attempt to read past end of buffer";return(t[e]<<8)+t[e+1]},readInt16:function(t,e){if(e<0)throw"bigEndianByteArrayParser.readInt16: position cannot be less than 0";if(e+2>t.length)throw"bigEndianByteArrayParser.readInt16: attempt to read past end of buffer";return 32768&(e=(t[e]<<8)+t[e+1])?e-65535-1:e},readUint32:function(t,e){if(e<0)throw"bigEndianByteArrayParser.readUint32: position cannot be less than 0";if(e+4>t.length)throw"bigEndianByteArrayParser.readUint32: attempt to read past end of buffer";return 256*(256*(256*t[e]+t[e+1])+t[e+2])+t[e+3]},readInt32:function(t,e){if(e<0)throw"bigEndianByteArrayParser.readInt32: position cannot be less than 0";if(e+4>t.length)throw"bigEndianByteArrayParser.readInt32: attempt to read past end of buffer";return(t[e]<<24)+(t[e+1]<<16)+(t[e+2]<<8)+t[e+3]},readFloat:function(t,e){if(e<0)throw"bigEndianByteArrayParser.readFloat: position cannot be less than 0";if(e+4>t.length)throw"bigEndianByteArrayParser.readFloat: attempt to read past end of buffer";var r=new Uint8Array(4);return r[3]=t[e],r[2]=t[e+1],r[1]=t[e+2],r[0]=t[e+3],new Float32Array(r.buffer)[0]},readDouble:function(t,e){if(e<0)throw"bigEndianByteArrayParser.readDouble: position cannot be less than 0";if(e+8>t.length)throw"bigEndianByteArrayParser.readDouble: attempt to read past end of buffer";var r=new Uint8Array(8);return r[7]=t[e],r[6]=t[e+1],r[5]=t[e+2],r[4]=t[e+3],r[3]=t[e+4],r[2]=t[e+5],r[1]=t[e+6],r[0]=t[e+7],new Float64Array(r.buffer)[0]}};function M(t,e,r){if("undefined"!=typeof Buffer&&t instanceof Buffer)return t.slice(e,e+r);if(t instanceof Uint8Array)return new Uint8Array(t.buffer,t.byteOffset+e,r);throw"dicomParser.from: unknown type for byteArray"}function R(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}var B=function(){function t(e,r,n){if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),void 0===e)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=e,this.byteArray=r,this.position=n||0,this.warnings=[]}var e,r,n;return e=t,(r=[{key:"seek",value:function(t){if(this.position+t<0)throw"dicomParser.ByteStream.prototype.seek: cannot seek to position < 0";this.position+=t}},{key:"readByteStream",value:function(e){if(this.position+e>this.byteArray.length)throw"dicomParser.ByteStream.prototype.readByteStream: readByteStream - buffer overread";var r=M(this.byteArray,this.position,e);return this.position+=e,new t(this.byteArrayParser,r)}},{key:"getSize",value:function(){return this.byteArray.length}},{key:"readUint16",value:function(){var t=this.byteArrayParser.readUint16(this.byteArray,this.position);return this.position+=2,t}},{key:"readUint32",value:function(){var t=this.byteArrayParser.readUint32(this.byteArray,this.position);return this.position+=4,t}},{key:"readFixedString",value:function(t){var e=g(this.byteArray,this.position,t);return this.position+=t,e}}])&&R(e.prototype,r),n&&R(e,n),Object.defineProperty(e,"prototype",{writable:!1}),t}(),G={readUint16:function(t,e){if(e<0)throw"littleEndianByteArrayParser.readUint16: position cannot be less than 0";if(e+2>t.length)throw"littleEndianByteArrayParser.readUint16: attempt to read past end of buffer";return t[e]+256*t[e+1]},readInt16:function(t,e){if(e<0)throw"littleEndianByteArrayParser.readInt16: position cannot be less than 0";if(e+2>t.length)throw"littleEndianByteArrayParser.readInt16: attempt to read past end of buffer";return 32768&(e=t[e]+(t[e+1]<<8))?e-65535-1:e},readUint32:function(t,e){if(e<0)throw"littleEndianByteArrayParser.readUint32: position cannot be less than 0";if(e+4>t.length)throw"littleEndianByteArrayParser.readUint32: attempt to read past end of buffer";return t[e]+256*t[e+1]+256*t[e+2]*256+256*t[e+3]*256*256},readInt32:function(t,e){if(e<0)throw"littleEndianByteArrayParser.readInt32: position cannot be less than 0";if(e+4>t.length)throw"littleEndianByteArrayParser.readInt32: attempt to read past end of buffer";return t[e]+(t[e+1]<<8)+(t[e+2]<<16)+(t[e+3]<<24)},readFloat:function(t,e){if(e<0)throw"littleEndianByteArrayParser.readFloat: position cannot be less than 0";if(e+4>t.length)throw"littleEndianByteArrayParser.readFloat: attempt to read past end of buffer";var r=new Uint8Array(4);return r[0]=t[e],r[1]=t[e+1],r[2]=t[e+2],r[3]=t[e+3],new Float32Array(r.buffer)[0]},readDouble:function(t,e){if(e<0)throw"littleEndianByteArrayParser.readDouble: position cannot be less than 0";if(e+8>t.length)throw"littleEndianByteArrayParser.readDouble: attempt to read past end of buffer";var r=new Uint8Array(8);return r[0]=t[e],r[1]=t[e+1],r[2]=t[e+2],r[3]=t[e+3],r[4]=t[e+4],r[5]=t[e+5],r[6]=t[e+6],r[7]=t[e+7],new Float64Array(r.buffer)[0]}};function C(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};if(void 0===t)throw"dicomParser.readPart10Header: missing required parameter 'byteArray'";var r=e.TransferSyntaxUID,n=new B(G,t);return function(){var t=function(){if(n.getSize()<=132&&r)return!1;if(n.seek(128),"DICM"===n.readFixedString(4))return!0;if(!(e||{}).TransferSyntaxUID)throw"dicomParser.readPart10Header: DICM prefix not found at location 132 - this is not a valid DICOM P10 file.";return n.seek(0),!1}(),o=[],a={};if(!t)return n.position=0,{elements:{x00020010:{tag:"x00020010",vr:"UI",Value:r}},warnings:o};for(;n.position<n.byteArray.length;){var i=n.position,c=I(n,o);if("x0002ffff"<c.tag){n.position=i;break}c.parser=G,a[c.tag]=c}return(t=new E(n.byteArrayParser,n.byteArray,a)).warnings=n.warnings,t.position=n.position,t}()}var q="1.2.840.10008.1.2.2";function H(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};if(void 0===t)throw new Error("dicomParser.parseDicom: missing required parameter 'byteArray'");var n,o=function(e){if(void 0===e.elements.x00020010)throw new Error("dicomParser.parseDicom: missing required meta header attribute 0002,0010");return(e=e.elements.x00020010)&&e.Value||g(t,e.dataOffset,e.length)};function a(n){var a="1.2.840.10008.1.2"!==(i=o(n)),i=function(n,o){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===q?U:G,t,o);if(e&&e.inflater)return n=e.inflater(t,o),new B(G,n,0);if(1==a){var i=r(0),c=M(t,o,t.length-o);return i=i.inflateRawSync(c),c=F(t,i.length+o),t.copy(c,0,0,o),i.copy(c,o),new B(G,c,0)}if("undefined"==typeof pako)throw"dicomParser.parseDicom: no inflater available to handle deflate transfer syntax";return i=t.slice(o),c=pako.inflateRaw(i),(i=F(t,c.length+o)).set(t.slice(0,o),0),i.set(c,o),new B(G,i,0)}(i,n.position);(n=new E(i.byteArrayParser,i.byteArray,{})).warnings=i.warnings;try{(a?D:_)(n,i,i.byteArray.length,e)}catch(i){throw{exception:i,dataSet:n}}return n}return function(t,e){for(var r in t.elements)t.elements.hasOwnProperty(r)&&(e.elements[r]=t.elements[r]);return void 0!==t.warnings&&(e.warnings=t.warnings.concat(e.warnings)),e}(n=C(t,e),a(n))}var W=function(t,e,r){for(var n=0,o=e;o<e+r;o++)n+=t[o].length;return n};function z(t,e,r,n,o){if(o=o||e.fragments,void 0===t)throw"dicomParser.readEncapsulatedPixelDataFromFragments: missing required parameter 'dataSet'";if(void 0===e)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"!==e.tag)throw"dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'pixelDataElement' refers to non pixel data tag (expected tag = x7fe00010";if(!0!==e.encapsulatedPixelData)throw"dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(!0!==e.hadUndefinedLength)throw"dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(void 0===e.basicOffsetTable)throw"dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(void 0===e.fragments)throw"dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(e.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>=e.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>e.fragments.length)throw"dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'startFragment' + 'numFragments' < number of fragments";var a=new B(t.byteArrayParser,t.byteArray,e.dataOffset);if("xfffee000"!==(e=O(a)).tag)throw"dicomParser.readEncapsulatedPixelData: missing basic offset table xfffee000";a.seek(e.length);var i=a.position;if(1===n)return M(a.byteArray,i+o[r].offset+8,o[r].length);e=W(o,r,n);for(var c=F(a.byteArray,e),u=0,s=r;s<r+n;s++)for(var f=i+o[s].offset+8,l=0;l<o[s].length;l++)c[u++]=a.byteArray[f++];return c}var Y=function(t,e){for(var r=0;r<t.length;r++)if(t[r].offset===e)return r},J=function(t,e,r,n){if(t===e.length-1)return r.length-n;for(var o=e[t+1],a=n+1;a<r.length;a++)if(r[a].offset===o)return a-n;throw"dicomParser.calculateNumberOfFragmentsForFrame: could not find fragment with offset matching basic offset table"};function V(t,e,r,n,o){if(n=n||e.basicOffsetTable,o=o||e.fragments,void 0===t)throw"dicomParser.readEncapsulatedImageFrame: missing required parameter 'dataSet'";if(void 0===e)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"!==e.tag)throw"dicomParser.readEncapsulatedImageFrame: parameter 'pixelDataElement' refers to non pixel data tag (expected tag = x7fe00010)";if(!0!==e.encapsulatedPixelData)throw"dicomParser.readEncapsulatedImageFrame: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(!0!==e.hadUndefinedLength)throw"dicomParser.readEncapsulatedImageFrame: parameter 'pixelDataElement' refers to pixel data element that does not have undefined length";if(void 0===e.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=Y(o,a)))throw"dicomParser.readEncapsulatedImageFrame: unable to find fragment that matches basic offset table entry";return z(t,e,a,J(r,n,o,a),o)}var K=!1;function $(t,e,r){if(K||(K=!0,console&&console.log&&console.log("WARNING: dicomParser.readEncapsulatedPixelData() has been deprecated")),void 0===t)throw"dicomParser.readEncapsulatedPixelData: missing required parameter 'dataSet'";if(void 0===e)throw"dicomParser.readEncapsulatedPixelData: missing required parameter 'element'";if(void 0===r)throw"dicomParser.readEncapsulatedPixelData: missing required parameter 'frame'";if("x7fe00010"!==e.tag)throw"dicomParser.readEncapsulatedPixelData: parameter 'element' refers to non pixel data tag (expected tag = x7fe00010)";if(!0!==e.encapsulatedPixelData)throw"dicomParser.readEncapsulatedPixelData: parameter 'element' refers to pixel data element that does not have encapsulated pixel data";if(!0!==e.hadUndefinedLength)throw"dicomParser.readEncapsulatedPixelData: parameter 'element' refers to pixel data element that does not have encapsulated pixel data";if(void 0===e.basicOffsetTable)throw"dicomParser.readEncapsulatedPixelData: parameter 'element' refers to pixel data element that does not have encapsulated pixel data";if(void 0===e.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!==e.basicOffsetTable.length?V(t,e,r):z(t,e,0,e.fragments.length)}e.default={isStringVr:o,isPrivateTag:a,parsePN:i,parseTM:c,parseDA:s,explicitElementToString:f,explicitDataSetToJS:l,createJPEGBasicOffsetTable:p,parseDicomDataSetExplicit:D,parseDicomDataSetImplicit:_,readFixedString:g,alloc:F,version:N,bigEndianByteArrayParser:U,ByteStream:B,sharedCopy:M,DataSet:E,findAndSetUNElementLength:m,findEndOfEncapsulatedElement:v,findItemDelimitationItemAndSetElementLength:x,littleEndianByteArrayParser:G,parseDicom:H,readDicomElementExplicit:I,readDicomElementImplicit:S,readEncapsulatedImageFrame:V,readEncapsulatedPixelData:$,readEncapsulatedPixelDataFromFragments:z,readPart10Header:C,readSequenceItemsExplicit:j,readSequenceItemsImplicit:A,readSequenceItem:O,readTag:y,LEI:"1.2.840.10008.1.2",LEE:"1.2.840.10008.1.2.1"}}],n={},e.m=r,e.c=n,e.d=function(t,r,n){e.o(t,r)||Object.defineProperty(t,r,{enumerable:!0,get:n})},e.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},e.t=function(t,r){if(1&r&&(t=e(t)),8&r)return t;if(4&r&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(e.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&r&&"string"!=typeof t)for(var o in t)e.d(n,o,function(e){return t[e]}.bind(null,o));return n},e.n=function(t){var r=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(r,"a",r),r},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=1);function e(t){if(n[t])return n[t].exports;var o=n[t]={i:t,l:!1,exports:{}};return r[t].call(o.exports,o,o.exports,e),o.l=!0,o.exports}var r,n}(r(559))},559:()=>{}},e={};function r(n){var o=e[n];if(void 0!==o)return o.exports;var a=e[n]={exports:{}};return t[n].call(a.exports,a,a.exports,r),a.exports}r.m=t,r.d=(t,e)=>{for(var n in e)r.o(e,n)&&!r.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},r.u=t=>t+".js",r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},(()=>{var t;r.g.importScripts&&(t=r.g.location+"");var e=r.g.document;if(!t&&e&&(e.currentScript&&"SCRIPT"===e.currentScript.tagName.toUpperCase()&&(t=e.currentScript.src),!t)){var n=e.getElementsByTagName("script");if(n.length)for(var o=n.length-1;o>-1&&(!t||!/^http(s?):/.test(t));)t=n[o--].src}if(!t)throw new Error("Automatic publicPath is not supported in this browser");t=t.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),r.p=t})(),r.b=document.baseURI||self.location.href;var n={};return(()=>{"use strict";r.r(n),r.d(n,{CodDicomWebServer:()=>qe,FetchType:()=>a,clearPartialFiles:()=>mt,default:()=>He});var t={};r.r(t),r.d(t,{DataRetrieveMode:()=>c,FetchType:()=>a,RequestType:()=>i,URLType:()=>u});var e={};r.r(e),r.d(e,{DOMAIN:()=>_,FILE_EXTENSIONS:()=>F,URL_VALIDATION_STRING:()=>N});var o={};r.r(o),r.d(o,{FILE_PARTIAL_WORKER_NAME:()=>U,FILE_STREAMING_WORKER_NAME:()=>M,FILE_SYSTEM_ROUTES:()=>G,IDB_DIR_HANDLE_KEY:()=>B,THRESHOLD:()=>R});var a=function(t){return t[t.BYTES_OPTIMIZED=0]="BYTES_OPTIMIZED",t[t.API_OPTIMIZED=1]="API_OPTIMIZED",t}({}),i=function(t){return t[t.FRAME=0]="FRAME",t[t.THUMBNAIL=1]="THUMBNAIL",t[t.SERIES_METADATA=2]="SERIES_METADATA",t[t.INSTANCE_METADATA=3]="INSTANCE_METADATA",t}({}),c=function(t){return t[t.WORKER=0]="WORKER",t[t.REQUEST=1]="REQUEST",t}({}),u=function(t){return t[t.THUMBNAIL=0]="THUMBNAIL",t[t.FILE=1]="FILE",t[t.OTHERS=2]="OTHERS",t}({}),s=r(915);function f(t){return f="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},f(t)}function l(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,a,i,c=[],u=!0,s=!1;try{if(a=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=a.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(i=r.return(),Object(i)!==i))return}finally{if(s)throw o}}return c}}(t,e)||function(t,e){if(t){if("string"==typeof t)return h(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?h(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function h(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function d(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function p(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?d(Object(r),!0).forEach((function(e){v(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):d(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function y(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,m(n.key),n)}}function v(t,e,r){return(e=m(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function m(t){var e=function(t,e){if("object"!=f(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!=f(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==f(e)?e:e+""}const g=function(){return t=function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),v(this,"files",{})},(e=[{key:"set",value:function(t,e){this.files[t]=p(p({},e),{},{lastModified:Date.now()})}},{key:"get",value:function(t,e){return!this.files[t]||e&&this.files[t].position<=e.endByte?null:e?this.files[t].data.slice(e.startByte,e.endByte):this.files[t].data}},{key:"setPosition",value:function(t,e){this.files[t]&&(this.files[t].position=e,this.files[t].lastModified=Date.now())}},{key:"getPosition",value:function(t){var e;return null===(e=this.files[t])||void 0===e?void 0:e.position}},{key:"append",value:function(t,e,r){this.files[t]&&r&&(this.files[t].data.set(e,r-e.length),this.setPosition(t,r))}},{key:"getTotalSize",value:function(){return Object.values(this.files).reduce((function(t,e){return t+e.data.byteLength}),0)}},{key:"remove",value:function(t){try{delete this.files[t],console.log("Removed ".concat(t," from CodDicomwebServer cache"))}catch(e){console.warn("Error removing ".concat(t," from CodDicomwebServer cache:"),e)}}},{key:"purge",value:function(){var t=this,e=Object.keys(this.files),r=this.getTotalSize();e.forEach((function(e){return t.remove(e)})),console.log("Purged ".concat(r-this.getTotalSize()," bytes from CodDicomwebServer cache"))}},{key:"decacheNecessaryBytes",value:function(t,e){var r=this,n=this.getTotalSize(),o=[],a=0;return Object.entries(this.files).sort((function(t,e){var r=l(t,2)[1],n=l(e,2)[1];return r.lastModified-n.lastModified})).forEach((function(r){var n=l(r,2),i=n[0],c=n[1];a<e&&i!==t&&(o.push(i),a+=c.data.byteLength)})),o.forEach((function(t){return r.remove(t)})),console.log("Decached ".concat(n-this.getTotalSize()," bytes")),a}}])&&y(t.prototype,e),r&&y(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,r}();function b(t){return b="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},b(t)}function w(t,e,r){return(e=P(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function E(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,P(n.key),n)}}function x(t,e,r){return e&&E(t.prototype,e),r&&E(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function P(t){var e=function(t,e){if("object"!=b(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!=b(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==b(e)?e:e+""}function S(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function O(t,e,r){return e=T(e),function(t,e){if(e&&("object"==b(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,k()?Reflect.construct(e,r||[],T(t).constructor):e.apply(t,r))}function L(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&j(t,e)}function A(t){var e="function"==typeof Map?new Map:void 0;return A=function(t){if(null===t||!function(t){try{return-1!==Function.toString.call(t).indexOf("[native code]")}catch(e){return"function"==typeof t}}(t))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,r)}function r(){return function(t,e,r){if(k())return Reflect.construct.apply(null,arguments);var n=[null];n.push.apply(n,e);var o=new(t.bind.apply(t,n));return r&&j(o,r.prototype),o}(t,arguments,T(this).constructor)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),j(r,t)},A(t)}function k(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(k=function(){return!!t})()}function j(t,e){return j=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},j(t,e)}function T(t){return T=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},T(t)}var I=function(t){function e(){return S(this,e),O(this,e,arguments)}return L(e,t),x(e)}(A(Error)),D=function(t){function e(t,r){var n;return S(this,e),w(n=O(this,e,[t]),"error",void 0),w(n,"message",void 0),n.message=t,n.error=r,n}return L(e,t),x(e)}(A(Event)),_="https://storage.googleapis.com",F=[".tar",".zip"],N="/dicomweb/",U="filePartial",M="fileStreaming",R=1e4,B="indexed_db_directory_handle_key",G={Partial:"partial"};const C={Enums:t,url:e,dataRetrieval:o};function q(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,a,i,c=[],u=!0,s=!1;try{if(a=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=a.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(i=r.return(),Object(i)!==i))return}finally{if(s)throw o}}return c}}(t,e)||function(t,e){if(t){if("string"==typeof t)return H(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?H(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function H(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function W(t,e){if(t.includes(C.url.URL_VALIDATION_STRING)){var r,n=t.split(e+"/")[1],o=n.split("/studies")[0],a=o.split("/"),c=a[0],u=a.slice(1).join("/"),s=n.split(o+"/")[1].split("/"),f=s[1],l=s[3],h="",d=1;switch(!0){case s.includes("thumbnail"):r=i.THUMBNAIL;break;case s.includes("metadata"):s.includes("instances")?(h=s[5],r=i.INSTANCE_METADATA):r=i.SERIES_METADATA;break;case s.includes("frames"):h=s[5],d=+s[7],r=i.FRAME;break;default:throw new I("Invalid type of request")}return{type:r,bucketName:c,bucketPrefix:u,studyInstanceUID:f,seriesInstanceUID:l,sopInstanceUID:h,frameNumber:d}}}function z(t,e,r,n){var o,a;if(!t||null===(o=t.cod)||void 0===o||!o.instances)throw new I("Invalid seriesMetadata provided.");if(null==r)throw new I("Frame index is required.");var i,c=n.domain,u=n.bucketName,s=n.bucketPrefix;if(t.thumbnail){var f=t.thumbnail.uri;i="".concat(c,"/").concat(f.split("gs://")[1])}var l=null===(a=Object.entries(t.cod.instances).find((function(t){var r=q(t,2),n=r[0];r[1];return n===e})))||void 0===a?void 0:a[1];if(!l)return{thumbnailUrl:i};var h,d,p=l.url,y=l.uri,v=l.headers,m=l.offset_tables,g=function(t,e,r,n){var o=t,a=C.url.FILE_EXTENSIONS.find((function(e){return t.includes(e)}));if(a){o=t.split(a)[0]+a}var i=o.split("studies/")[1];return o="".concat(e,"/").concat(r,"/").concat(n?n+"/":"","studies/").concat(i),o}(p||y,c,u,s),b=m.CustomOffsetTable,w=m.CustomOffsetTableLengths,E=!1;null!=b&&b.length&&null!=w&&w.length&&(d=(h=b[r])+w[r],E=!0);var x=v.start_byte,P=v.end_byte;return{url:g,startByte:void 0!==h?x+h:x,endByte:void 0!==d?x+d:P,thumbnailUrl:i,isMultiframe:E}}function Y(t){var e=t.domain,r=void 0===e?C.url.DOMAIN:e,n=t.bucketName,o=t.bucketPrefix,a=t.studyInstanceUID,i=t.seriesInstanceUID;if(n&&o&&a&&i)return"".concat(r,"/").concat(n,"/").concat(o,"/studies/").concat(a,"/series/").concat(i,"/metadata.json")}function J(t){return new Promise(((e,r)=>{t.oncomplete=t.onsuccess=()=>e(t.result),t.onabort=t.onerror=()=>r(t.error)}))}function V(t,e){let r;return(n,o)=>(()=>{if(r)return r;const n=indexedDB.open(t);return n.onupgradeneeded=()=>n.result.createObjectStore(e),r=J(n),r.then((t=>{t.onclose=()=>r=void 0}),(()=>{})),r})().then((t=>o(t.transaction(e,n).objectStore(e))))}let K;function $(){return K||(K=V("keyval-store","keyval")),K}function Q(t,e=$()){return e("readonly",(e=>J(e.get(t))))}function Z(t){return Z="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Z(t)}function X(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */X=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(t,e,r){t[e]=r.value},a="function"==typeof Symbol?Symbol:{},i=a.iterator||"@@iterator",c=a.asyncIterator||"@@asyncIterator",u=a.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,r){return t[e]=r}}function f(t,e,r,n){var a=e&&e.prototype instanceof m?e:m,i=Object.create(a.prototype),c=new T(n||[]);return o(i,"_invoke",{value:L(t,r,c)}),i}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var h="suspendedStart",d="suspendedYield",p="executing",y="completed",v={};function m(){}function g(){}function b(){}var w={};s(w,i,(function(){return this}));var E=Object.getPrototypeOf,x=E&&E(E(I([])));x&&x!==r&&n.call(x,i)&&(w=x);var P=b.prototype=m.prototype=Object.create(w);function S(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function O(t,e){function r(o,a,i,c){var u=l(t[o],t,a);if("throw"!==u.type){var s=u.arg,f=s.value;return f&&"object"==Z(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,i,c)}),(function(t){r("throw",t,i,c)})):e.resolve(f).then((function(t){s.value=t,i(s)}),(function(t){return r("throw",t,i,c)}))}c(u.arg)}var a;o(this,"_invoke",{value:function(t,n){function o(){return new e((function(e,o){r(t,n,e,o)}))}return a=a?a.then(o,o):o()}})}function L(e,r,n){var o=h;return function(a,i){if(o===p)throw Error("Generator is already running");if(o===y){if("throw"===a)throw i;return{value:t,done:!0}}for(n.method=a,n.arg=i;;){var c=n.delegate;if(c){var u=A(c,n);if(u){if(u===v)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===h)throw o=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=p;var s=l(e,r,n);if("normal"===s.type){if(o=n.done?y:d,s.arg===v)continue;return{value:s.arg,done:n.done}}"throw"===s.type&&(o=y,n.method="throw",n.arg=s.arg)}}}function A(e,r){var n=r.method,o=e.iterator[n];if(o===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,A(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),v;var a=l(o,e.iterator,r.arg);if("throw"===a.type)return r.method="throw",r.arg=a.arg,r.delegate=null,v;var i=a.arg;return i?i.done?(r[e.resultName]=i.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,v):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,v)}function k(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function j(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function T(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(k,this),this.reset(!0)}function I(e){if(e||""===e){var r=e[i];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var o=-1,a=function r(){for(;++o<e.length;)if(n.call(e,o))return r.value=e[o],r.done=!1,r;return r.value=t,r.done=!0,r};return a.next=a}}throw new TypeError(Z(e)+" is not iterable")}return g.prototype=b,o(P,"constructor",{value:b,configurable:!0}),o(b,"constructor",{value:g,configurable:!0}),g.displayName=s(b,u,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===g||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,b):(t.__proto__=b,s(t,u,"GeneratorFunction")),t.prototype=Object.create(P),t},e.awrap=function(t){return{__await:t}},S(O.prototype),s(O.prototype,c,(function(){return this})),e.AsyncIterator=O,e.async=function(t,r,n,o,a){void 0===a&&(a=Promise);var i=new O(f(t,r,n,o),a);return e.isGeneratorFunction(r)?i:i.next().then((function(t){return t.done?t.value:i.next()}))},S(P),s(P,u,"Generator"),s(P,i,(function(){return this})),s(P,"toString",(function(){return"[object Generator]"})),e.keys=function