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UuC,SAAS,KAKlD,MAAM,IAAIzI,MAAM,mBAAD,OACMqI,EAAiB,4C,KAM5CC,GAAc,qBAAJ,OAAyBD,E,OAEhC,GACLlE,MAAMC,QAAQuB,KACbA,EAAoBsC,SAAS/B,GAE9B,MAAM,IAAIlG,MAAM,cAAD,OACCkG,EAAS,6CAI3BkC,EAAgBrH,KAAKuH,E,IAGhBF,EAAgBxB,KAAK,K,IAG9B,mDAOmD,IAAhBlB,EAAY,UAAH,6CAAG,GAC7C,OAAyB,IAArBA,EAAUvI,OACL,SAAP,OAAgBuI,EAAU,GAAE,KAEL,IAArBA,EAAUvI,OACL,SAAP,OAAgBuI,EAAU,GAAE,YAAIA,EAAU,IAGrC,U,IAGT,0CAQ4BF,GAC1B,IAAMuD,EAAQ,IAAIC,IAElB,OAAKxD,GAAeA,EAAWrI,QAI/BqI,EAAW/F,SAAQ,SAAA0I,GAAQ,IACjBjC,EAAciC,EAAdjC,UACF+C,EAAOvH,EAAekH,gBAAgB1C,GAAW,GACvD6C,EAAMG,IAAI,GAAD,OAAID,EAAI,K,IAGZ9E,MAAMgF,KAAKJ,IATTA,C,IAYX,yCAW2BvD,GACzB,IAAKA,IAAeA,EAAWrI,OAC7B,MAAM,IAAI6C,MAAM,sCAGlB,IAAMoJ,EAAmB1H,EAAeqF,qBAAqBvB,GAC7D,GAAgC,IAA5B4D,EAAiBjM,OACnB,MAAM,IAAI6C,MAAM,wDACX,GAAIoJ,EAAiBjM,OAAS,EACnC,MAAM,IAAI6C,MAAM,mDAGlB,OAAOoJ,EAAiB,E,qFACzB,C,CAz6BiB,G","sources":["webpack:///../../../node_modules/dicomweb-client/src/message.js","webpack:///../../../node_modules/dicomweb-client/src/api.js","webpack:///../../../node_modules/dicomweb-client/src/version.js","webpack:///../../../node_modules/dicomweb-client/src/dicomweb-client.js"],"sourcesContent":["/**\n * Converts a Uint8Array to a String.\n * @param {Uint8Array} array that should be converted\n * @param {Number} offset array offset in case only subset of array items should\n be extracted (default: 0)\n * @param {Number} limit maximum number of array items that should be extracted\n (defaults to length of array)\n * @returns {String}\n */\nfunction uint8ArrayToString(arr, offset = 0, limit) {\n const itemLimit = limit || arr.length - offset;\n let str = '';\n for (let i = offset; i < offset + itemLimit; i++) {\n str += String.fromCharCode(arr[i]);\n }\n return str;\n}\n\n/**\n * Converts a String to a Uint8Array.\n * @param {String} str string that should be converted\n * @returns {Uint8Array}\n */\nfunction stringToUint8Array(str) {\n const arr = new Uint8Array(str.length);\n for (let i = 0, j = str.length; i < j; i++) {\n arr[i] = str.charCodeAt(i);\n }\n return arr;\n}\n\n/**\n * Identifies the boundary in a multipart/related message header.\n * @param {String} header message header\n * @returns {String} boundary\n */\nfunction identifyBoundary(header) {\n const parts = header.split('\\r\\n');\n\n for (let i = 0; i < parts.length; i++) {\n if (parts[i].substr(0, 2) === '--') {\n return parts[i];\n }\n }\n\n return null;\n}\n\n/**\n * Checks whether a given token is contained by a message at a given offset.\n * @param {Uint8Array} message message content\n * @param {Uint8Array} token substring that should be present\n * @param {Number} offset offset in message content from where search should start\n * @returns {Boolean} whether message contains token at offset\n */\nfunction containsToken(message, token, offset = 0) {\n if (offset + token.length > message.length) {\n return false;\n }\n\n let index = offset;\n for (let i = 0; i < token.length; i++) {\n if (token[i] !== message[index]) {\n return false;\n }\n\n index += 1;\n }\n return true;\n}\n\n/**\n * Finds a given token in a message at a given offset.\n * @param {Uint8Array} message message content\n * @param {Uint8Array} token substring that should be found\n * @param {String} offset message body offset from where search should start\n * @returns {Boolean} whether message has a part at given offset or not\n */\nfunction findToken(message, token, offset = 0, maxSearchLength) {\n let searchLength = message.length;\n if (maxSearchLength) {\n searchLength = Math.min(offset + maxSearchLength, message.length);\n }\n\n for (let i = offset; i < searchLength; i++) {\n // If the first value of the message matches\n // the first value of the token, check if\n // this is the full token.\n if (message[i] === token[0]) {\n if (containsToken(message, token, i)) {\n return i;\n }\n }\n }\n\n return -1;\n}\n\n/**\n * Create a random GUID\n *\n * @return {string}\n */\nfunction guid() {\n function s4() {\n return Math.floor((1 + Math.random()) * 0x10000)\n .toString(16)\n .substring(1);\n }\n return `${s4() + s4()}-${s4()}-${s4()}-${s4()}-${s4()}${s4()}${s4()}`;\n}\n\n/**\n * @typedef {Object} MultipartEncodedData\n * @property {ArrayBuffer} data The encoded Multipart Data\n * @property {String} boundary The boundary used to divide pieces of the encoded data\n */\n\n/**\n * Encode one or more DICOM datasets into a single body so it can be\n * sent using the Multipart Content-Type.\n *\n * @param {ArrayBuffer[]} datasets Array containing each file to be encoded in the\n multipart body, passed as ArrayBuffers.\n * @param {String} [boundary] Optional string to define a boundary between each part\n of the multipart body. If this is not specified, a random\n GUID will be generated.\n * @return {MultipartEncodedData} The Multipart encoded data returned as an Object. This\n contains both the data itself, and the boundary string\n used to divide it.\n */\nfunction multipartEncode(\n datasets,\n boundary = guid(),\n contentType = 'application/dicom',\n) {\n const contentTypeString = `Content-Type: ${contentType}`;\n const header = `\\r\\n--${boundary}\\r\\n${contentTypeString}\\r\\n\\r\\n`;\n const footer = `\\r\\n--${boundary}--`;\n const headerArray = stringToUint8Array(header);\n const footerArray = stringToUint8Array(footer);\n const headerLength = headerArray.length;\n const footerLength = footerArray.length;\n\n let length = 0;\n\n // Calculate the total length for the final array\n const contentArrays = datasets.map(datasetBuffer => {\n const contentArray = new Uint8Array(datasetBuffer);\n const contentLength = contentArray.length;\n\n length += headerLength + contentLength + footerLength;\n\n return contentArray;\n });\n\n // Allocate the array\n const multipartArray = new Uint8Array(length);\n\n // Set the initial header\n multipartArray.set(headerArray, 0);\n\n // Write each dataset into the multipart array\n let position = 0;\n contentArrays.forEach(contentArray => {\n multipartArray.set(headerArray, position);\n multipartArray.set(contentArray, position + headerLength);\n\n position += headerLength + contentArray.length;\n });\n\n multipartArray.set(footerArray, position);\n\n return {\n data: multipartArray.buffer,\n boundary,\n };\n}\n\n/**\n * Decode a Multipart encoded ArrayBuffer and return the components as an Array.\n *\n * @param {ArrayBuffer} response Data encoded as a 'multipart/related' message\n * @returns {Array} The content\n */\nfunction multipartDecode(response) {\n const message = new Uint8Array(response);\n\n /* Set a maximum length to search for the header boundaries, otherwise\n findToken can run for a long time\n */\n const maxSearchLength = 1000;\n\n // First look for the multipart mime header\n const separator = stringToUint8Array('\\r\\n\\r\\n');\n const headerIndex = findToken(message, separator, 0, maxSearchLength);\n if (headerIndex === -1) {\n throw new Error('Response message has no multipart mime header');\n }\n\n const header = uint8ArrayToString(message, 0, headerIndex);\n const boundaryString = identifyBoundary(header);\n if (!boundaryString) {\n throw new Error('Header of response message does not specify boundary');\n }\n\n const boundary = stringToUint8Array(boundaryString);\n const boundaryLength = boundary.length;\n const components = [];\n\n let offset = boundaryLength;\n\n // Loop until we cannot find any more boundaries\n let boundaryIndex;\n\n while (boundaryIndex !== -1) {\n // Search for the next boundary in the message, starting\n // from the current offset position\n boundaryIndex = findToken(message, boundary, offset);\n\n // If no further boundaries are found, stop here.\n if (boundaryIndex === -1) {\n break;\n }\n\n const headerTokenIndex = findToken(\n message,\n separator,\n offset,\n maxSearchLength,\n );\n if (headerTokenIndex === -1) {\n throw new Error('Response message part has no mime header');\n }\n offset = headerTokenIndex + separator.length;\n\n // Extract data from response message, excluding \"\\r\\n\"\n const spacingLength = 2;\n const data = response.slice(offset, boundaryIndex - spacingLength);\n\n // Add the data to the array of results\n components.push(data);\n\n // Move the offset to the end of the current section,\n // plus the identified boundary\n offset = boundaryIndex + boundaryLength;\n }\n\n return components;\n}\n\nexport {\n containsToken,\n findToken,\n identifyBoundary,\n uint8ArrayToString,\n stringToUint8Array,\n multipartEncode,\n multipartDecode,\n guid,\n};\n","import { multipartEncode, multipartDecode } from './message.js';\n\nfunction isObject(obj) {\n return typeof obj === 'object' && obj !== null;\n}\n\nfunction isEmptyObject(obj) {\n return Object.keys(obj).length === 0 && obj.constructor === Object;\n}\n\nfunction areValidRequestHooks(requestHooks) {\n const isValid =\n Array.isArray(requestHooks) &&\n requestHooks.every(\n requestHook =>\n typeof requestHook === 'function' && requestHook.length === 2,\n );\n\n if (!isValid) {\n console.warn(\n 'Request hooks should have the following signature: ' +\n 'function requestHook(request, metadata) { return request; }',\n );\n }\n\n return isValid;\n}\n\nconst getFirstResult = result => result[0];\n\nconst MEDIATYPES = {\n DICOM: 'application/dicom',\n DICOM_JSON: 'application/dicom+json',\n OCTET_STREAM: 'application/octet-stream',\n PDF: 'application/pdf',\n JPEG: 'image/jpeg',\n PNG: 'image/png',\n};\n\n/**\n * @typedef { import(\"../types/types\").InstanceMetadata } InstanceMetadata\n */\n\n/**\n * A callback with the request instance and metadata information\n * of the currently request being executed that should necessarily\n * return the given request optionally modified.\n * @typedef {function} RequestHook\n * @param {XMLHttpRequest} request - The original XMLHttpRequest instance.\n * @param {object} metadata - The metadata used by the request.\n */\n\n/**\n * Class for interacting with DICOMweb RESTful services.\n */\nclass DICOMwebClient {\n /**\n * @constructor\n * @param {Object} options\n * @param {String} options.url - URL of the DICOMweb RESTful Service endpoint\n * @param {String=} options.qidoURLPrefix - URL path prefix for QIDO-RS\n * @param {String=} options.wadoURLPrefix - URL path prefix for WADO-RS\n * @param {String=} options.stowURLPrefix - URL path prefix for STOW-RS\n * @param {String=} options.username - Username\n * @param {String=} options.password - Password\n * @param {Object=} options.headers - HTTP headers\n * @param {Array.=} options.requestHooks - Request hooks.\n * @param {Object=} options.verbose - print to console request warnings and errors, default true\n */\n constructor(options) {\n this.baseURL = options.url;\n if (!this.baseURL) {\n console.error('no DICOMweb base url provided - calls that require a URL will fail');\n }\n\n if ('username' in options) {\n this.username = options.username;\n if (!('password' in options)) {\n console.error(\n 'no password provided to authenticate with DICOMweb service',\n );\n }\n this.password = options.password;\n }\n\n if ('qidoURLPrefix' in options) {\n console.log(`use URL prefix for QIDO-RS: ${options.qidoURLPrefix}`);\n this.qidoURL = `${this.baseURL}/${options.qidoURLPrefix}`;\n } else {\n this.qidoURL = this.baseURL;\n }\n\n if ('wadoURLPrefix' in options) {\n console.log(`use URL prefix for WADO-RS: ${options.wadoURLPrefix}`);\n this.wadoURL = `${this.baseURL}/${options.wadoURLPrefix}`;\n } else {\n this.wadoURL = this.baseURL;\n }\n\n if ('stowURLPrefix' in options) {\n console.log(`use URL prefix for STOW-RS: ${options.stowURLPrefix}`);\n this.stowURL = `${this.baseURL}/${options.stowURLPrefix}`;\n } else {\n this.stowURL = this.baseURL;\n }\n\n if ('requestHooks' in options) {\n this.requestHooks = options.requestHooks;\n }\n\n // Headers to pass to requests.\n this.headers = options.headers || {};\n\n // Optional error interceptor callback to handle any failed request.\n this.errorInterceptor = options.errorInterceptor || (() => undefined);\n\n // Verbose - print to console request warnings and errors, default true\n this.verbose = options.verbose !== false;\n }\n\n /**\n * Sets verbose flag.\n *\n * @param {Boolean} verbose\n */\n setVerbose(verbose) {\n this.verbose = verbose;\n }\n\n /**\n * Gets verbose flag.\n *\n * @return {Boolean} verbose\n */\n getVerbose() {\n return this.verbose;\n }\n\n static _parseQueryParameters(params = {}) {\n let queryString = '?';\n Object.keys(params).forEach((key, index) => {\n if (index !== 0) {\n queryString += '&';\n }\n queryString += `${key}=${encodeURIComponent(params[key])}`;\n });\n return queryString;\n }\n\n /**\n * Performs an HTTP request.\n *\n * @param {String} url\n * @param {String} method\n * @param {Object} headers\n * @param {Object} options\n * @param {Array.} options.requestHooks - Request hooks.\n * @param {XMLHttpRequest} [options.request] - if specified, the request to use, otherwise one will be created; useful for adding custom upload and abort listeners/objects\n * @return {*}\n * @private\n */\n _httpRequest(url, method, headers = {}, options = {}) {\n const { errorInterceptor, requestHooks } = this;\n\n return new Promise((resolve, reject) => {\n let request = options.request ? options.request : new XMLHttpRequest();\n\n request.open(method, url, true);\n if ('responseType' in options) {\n request.responseType = options.responseType;\n }\n\n if (typeof headers === 'object') {\n Object.keys(headers).forEach(key => {\n request.setRequestHeader(key, headers[key]);\n });\n }\n\n // now add custom headers from the user\n // (e.g. access tokens)\n const userHeaders = this.headers;\n Object.keys(userHeaders).forEach(key => {\n request.setRequestHeader(key, userHeaders[key]);\n });\n\n // Event triggered when upload starts\n request.onloadstart = function onloadstart() {\n // console.log('upload started: ', url)\n };\n\n // Event triggered when upload ends\n request.onloadend = function onloadend() {\n // console.log('upload finished')\n };\n\n // Handle response message\n request.onreadystatechange = () => {\n if (request.readyState === 4) {\n if (request.status === 200) {\n resolve(request.response);\n } else if (request.status === 202) {\n if (this.verbose) {\n console.warn('some resources already existed: ', request);\n }\n resolve(request.response);\n } else if (request.status === 204) {\n if (this.verbose) {\n console.warn('empty response for request: ', request);\n }\n resolve([]);\n } else {\n const error = new Error('request failed');\n error.request = request;\n error.response = request.response;\n error.status = request.status;\n if (this.verbose) {\n console.error('request failed: ', request);\n console.error(error);\n console.error(error.response);\n }\n\n errorInterceptor(error);\n\n reject(error);\n }\n }\n };\n\n // Event triggered while download progresses\n if ('progressCallback' in options) {\n if (typeof options.progressCallback === 'function') {\n request.onprogress = options.progressCallback;\n }\n }\n\n if (requestHooks && areValidRequestHooks(requestHooks)) {\n const combinedHeaders = Object.assign({}, headers, this.headers);\n const metadata = { method, url, headers: combinedHeaders };\n const pipeRequestHooks = functions => args =>\n functions.reduce((props, fn) => fn(props, metadata), args);\n const pipedRequest = pipeRequestHooks(requestHooks);\n request = pipedRequest(request);\n }\n\n // Add withCredentials to request if needed\n if ('withCredentials' in options) {\n if (options.withCredentials) {\n request.withCredentials = true;\n }\n }\n\n if ('data' in options) {\n request.send(options.data);\n } else {\n request.send();\n }\n });\n }\n\n /**\n * Performs an HTTP GET request.\n *\n * @param {String} url\n * @param {Object} headers\n * @param {Object} responseType\n * @param {Function} progressCallback\n * @return {*}\n * @private\n */\n _httpGet(url, headers, responseType, progressCallback, withCredentials) {\n return this._httpRequest(url, 'get', headers, {\n responseType,\n progressCallback,\n withCredentials,\n });\n }\n\n /**\n * Performs an HTTP GET request that accepts a message with application/json\n * media type.\n *\n * @param {String} url\n * @param {Object} params\n * @param {Function} progressCallback\n * @return {*}\n * @private\n */\n _httpGetApplicationJson(url, params = {}, progressCallback, withCredentials) {\n let urlWithQueryParams = url;\n\n if (typeof params === 'object') {\n if (!isEmptyObject(params)) {\n urlWithQueryParams += DICOMwebClient._parseQueryParameters(params);\n }\n }\n const headers = { Accept: MEDIATYPES.DICOM_JSON };\n const responseType = 'json';\n return this._httpGet(\n urlWithQueryParams,\n headers,\n responseType,\n progressCallback,\n withCredentials,\n );\n }\n\n /**\n * Performs an HTTP GET request that accepts a message with application/pdf\n * media type.\n *\n * @param {String} url\n * @param {Object} params\n * @param {Function} progressCallback\n * @return {*}\n * @private\n */\n _httpGetApplicationPdf(url, params = {}, progressCallback, withCredentials) {\n let urlWithQueryParams = url;\n\n if (typeof params === 'object') {\n if (!isEmptyObject(params)) {\n urlWithQueryParams += DICOMwebClient._parseQueryParameters(params);\n }\n }\n const headers = { Accept: MEDIATYPES.PDF };\n const responseType = 'json';\n return this._httpGet(\n urlWithQueryParams,\n headers,\n responseType,\n progressCallback,\n withCredentials,\n );\n }\n\n /**\n * Performs an HTTP GET request that accepts a message with an image\n media type.\n *\n * @param {String} url\n * @param {Object[]} mediaTypes\n * @param {Object} params\n * @param {Function} progressCallback\n * @return {*}\n * @private\n */\n _httpGetImage(\n url,\n mediaTypes,\n params = {},\n progressCallback,\n withCredentials,\n ) {\n let urlWithQueryParams = url;\n\n if (typeof params === 'object') {\n if (!isEmptyObject(params)) {\n urlWithQueryParams += DICOMwebClient._parseQueryParameters(params);\n }\n }\n\n const supportedMediaTypes = [\n 'image/',\n 'image/*',\n 'image/jpeg',\n 'image/jp2',\n 'image/gif',\n 'image/png',\n ];\n\n const acceptHeaderFieldValue = DICOMwebClient._buildAcceptHeaderFieldValue(\n mediaTypes,\n supportedMediaTypes,\n );\n const headers = { Accept: acceptHeaderFieldValue };\n const responseType = 'arraybuffer';\n return this._httpGet(\n urlWithQueryParams,\n headers,\n responseType,\n progressCallback,\n withCredentials,\n );\n }\n\n /**\n * Performs an HTTP GET request that accepts a message with a text\n media type.\n *\n * @param {String} url\n * @param {Object[]} mediaTypes\n * @param {Object} params\n * @param {Function} progressCallback\n * @return {*}\n * @private\n */\n _httpGetText(\n url,\n mediaTypes,\n params = {},\n progressCallback,\n withCredentials,\n ) {\n let urlWithQueryParams = url;\n\n if (typeof params === 'object') {\n if (!isEmptyObject(params)) {\n urlWithQueryParams += DICOMwebClient._parseQueryParameters(params);\n }\n }\n\n const supportedMediaTypes = [\n 'text/',\n 'text/*',\n 'text/html',\n 'text/plain',\n 'text/rtf',\n 'text/xml',\n ];\n\n const acceptHeaderFieldValue = DICOMwebClient._buildAcceptHeaderFieldValue(\n mediaTypes,\n supportedMediaTypes,\n );\n const headers = { Accept: acceptHeaderFieldValue };\n const responseType = 'arraybuffer';\n return this._httpGet(\n urlWithQueryParams,\n headers,\n responseType,\n progressCallback,\n withCredentials,\n );\n }\n\n /**\n * Performs an HTTP GET request that accepts a message with a video\n media type.\n *\n * @param {String} url\n * @param {Object[]} mediaTypes\n * @param {Object} params\n * @param {Function} progressCallback\n * @return {*}\n * @private\n */\n _httpGetVideo(\n url,\n mediaTypes,\n params = {},\n progressCallback,\n withCredentials,\n ) {\n let urlWithQueryParams = url;\n\n if (typeof params === 'object') {\n if (!isEmptyObject(params)) {\n urlWithQueryParams += DICOMwebClient._parseQueryParameters(params);\n }\n }\n\n const supportedMediaTypes = [\n 'video/',\n 'video/*',\n 'video/mpeg',\n 'video/mp4',\n 'video/H265',\n ];\n\n const acceptHeaderFieldValue = DICOMwebClient._buildAcceptHeaderFieldValue(\n mediaTypes,\n supportedMediaTypes,\n );\n const headers = { Accept: acceptHeaderFieldValue };\n const responseType = 'arraybuffer';\n return this._httpGet(\n urlWithQueryParams,\n headers,\n responseType,\n progressCallback,\n withCredentials,\n );\n }\n\n /**\n * Asserts that a given media type is valid.\n *\n * @params {String} mediaType media type\n */\n static _assertMediaTypeIsValid(mediaType) {\n if (!mediaType) {\n throw new Error(`Not a valid media type: ${mediaType}`);\n }\n\n const sepIndex = mediaType.indexOf('/');\n if (sepIndex === -1) {\n throw new Error(`Not a valid media type: ${mediaType}`);\n }\n\n const mediaTypeType = mediaType.slice(0, sepIndex);\n const types = ['application', 'image', 'text', 'video'];\n if (!types.includes(mediaTypeType)) {\n throw new Error(`Not a valid media type: ${mediaType}`);\n }\n\n if (mediaType.slice(sepIndex + 1).includes('/')) {\n throw new Error(`Not a valid media type: ${mediaType}`);\n }\n }\n\n /**\n * Performs an HTTP GET request that accepts a multipart message with an image media type.\n *\n * @param {String} url - Unique resource locator\n * @param {Object[]} mediaTypes - Acceptable media types and optionally the UIDs of the\n corresponding transfer syntaxes\n * @param {Array} byteRange - Start and end of byte range\n * @param {Object} params - Additional HTTP GET query parameters\n * @param {Boolean} rendered - Whether resource should be requested using rendered media types\n * @param {Function} progressCallback\n * @private\n * @returns {Promise} Content of HTTP message body parts\n */\n _httpGetMultipartImage(\n url,\n mediaTypes,\n byteRange,\n params,\n rendered = false,\n progressCallback,\n withCredentials,\n ) {\n const headers = {};\n let supportedMediaTypes;\n if (rendered) {\n supportedMediaTypes = [\n 'image/jpeg',\n 'image/gif',\n 'image/png',\n 'image/jp2',\n ];\n } else {\n supportedMediaTypes = {\n '1.2.840.10008.1.2.5': ['image/x-dicom-rle'],\n '1.2.840.10008.1.2.4.50': ['image/jpeg'],\n '1.2.840.10008.1.2.4.51': ['image/jpeg'],\n '1.2.840.10008.1.2.4.57': ['image/jpeg'],\n '1.2.840.10008.1.2.4.70': ['image/jpeg'],\n '1.2.840.10008.1.2.4.80': ['image/x-jls', 'image/jls'],\n '1.2.840.10008.1.2.4.81': ['image/x-jls', 'image/jls'],\n '1.2.840.10008.1.2.4.90': ['image/jp2'],\n '1.2.840.10008.1.2.4.91': ['image/jp2'],\n '1.2.840.10008.1.2.4.92': ['image/jpx'],\n '1.2.840.10008.1.2.4.93': ['image/jpx'],\n };\n\n if (byteRange) {\n headers.Range = DICOMwebClient._buildRangeHeaderFieldValue(byteRange);\n }\n }\n\n headers.Accept = DICOMwebClient._buildMultipartAcceptHeaderFieldValue(\n mediaTypes,\n supportedMediaTypes,\n );\n\n return this._httpGet(\n url,\n headers,\n 'arraybuffer',\n progressCallback,\n withCredentials,\n ).then(multipartDecode);\n }\n\n /**\n * Performs an HTTP GET request that accepts a multipart message with a video media type.\n *\n * @param {String} url - Unique resource locator\n * @param {Object[]} mediaTypes - Acceptable media types and optionally the UIDs of the\n corresponding transfer syntaxes\n * @param {Array} byteRange - Start and end of byte range\n * @param {Object} params - Additional HTTP GET query parameters\n * @param {Boolean} rendered - Whether resource should be requested using rendered media types\n * @param {Function} progressCallback\n * @private\n * @returns {Promise} Content of HTTP message body parts\n */\n _httpGetMultipartVideo(\n url,\n mediaTypes,\n byteRange,\n params,\n rendered = false,\n progressCallback,\n withCredentials,\n ) {\n const headers = {};\n let supportedMediaTypes;\n if (rendered) {\n supportedMediaTypes = [\n 'video/',\n 'video/*',\n 'video/mpeg2',\n 'video/mp4',\n 'video/H265',\n ];\n } else {\n supportedMediaTypes = {\n '1.2.840.10008.1.2.4.100': ['video/mpeg2'],\n '1.2.840.10008.1.2.4.101': ['video/mpeg2'],\n '1.2.840.10008.1.2.4.102': ['video/mp4'],\n '1.2.840.10008.1.2.4.103': ['video/mp4'],\n '1.2.840.10008.1.2.4.104': ['video/mp4'],\n '1.2.840.10008.1.2.4.105': ['video/mp4'],\n '1.2.840.10008.1.2.4.106': ['video/mp4'],\n };\n\n if (byteRange) {\n headers.Range = DICOMwebClient._buildRangeHeaderFieldValue(byteRange);\n }\n }\n\n headers.Accept = DICOMwebClient._buildMultipartAcceptHeaderFieldValue(\n mediaTypes,\n supportedMediaTypes,\n );\n\n return this._httpGet(\n url,\n headers,\n 'arraybuffer',\n progressCallback,\n withCredentials,\n ).then(multipartDecode);\n }\n\n /**\n * Performs an HTTP GET request that accepts a multipart message\n * with a application/dicom media type.\n *\n * @param {String} url - Unique resource locator\n * @param {Object[]} mediaTypes - Acceptable media types and optionally the UIDs of the\n corresponding transfer syntaxes\n * @param {Object} params - Additional HTTP GET query parameters\n * @param {Function} progressCallback\n * @private\n * @returns {Promise} Content of HTTP message body parts\n */\n _httpGetMultipartApplicationDicom(\n url,\n mediaTypes,\n params,\n progressCallback,\n withCredentials,\n ) {\n const headers = {};\n const defaultMediaType = 'application/dicom';\n const supportedMediaTypes = {\n '1.2.840.10008.1.2.1': [defaultMediaType],\n '1.2.840.10008.1.2.5': [defaultMediaType],\n '1.2.840.10008.1.2.4.50': [defaultMediaType],\n '1.2.840.10008.1.2.4.51': [defaultMediaType],\n '1.2.840.10008.1.2.4.57': [defaultMediaType],\n '1.2.840.10008.1.2.4.70': [defaultMediaType],\n '1.2.840.10008.1.2.4.80': [defaultMediaType],\n '1.2.840.10008.1.2.4.81': [defaultMediaType],\n '1.2.840.10008.1.2.4.90': [defaultMediaType],\n '1.2.840.10008.1.2.4.91': [defaultMediaType],\n '1.2.840.10008.1.2.4.92': [defaultMediaType],\n '1.2.840.10008.1.2.4.93': [defaultMediaType],\n '1.2.840.10008.1.2.4.100': [defaultMediaType],\n '1.2.840.10008.1.2.4.101': [defaultMediaType],\n '1.2.840.10008.1.2.4.102': [defaultMediaType],\n '1.2.840.10008.1.2.4.103': [defaultMediaType],\n '1.2.840.10008.1.2.4.104': [defaultMediaType],\n '1.2.840.10008.1.2.4.105': [defaultMediaType],\n '1.2.840.10008.1.2.4.106': [defaultMediaType],\n };\n\n let acceptableMediaTypes = mediaTypes;\n if (!mediaTypes) {\n acceptableMediaTypes = [{ mediaType: defaultMediaType }];\n }\n\n headers.Accept = DICOMwebClient._buildMultipartAcceptHeaderFieldValue(\n acceptableMediaTypes,\n supportedMediaTypes,\n );\n\n return this._httpGet(\n url,\n headers,\n 'arraybuffer',\n progressCallback,\n withCredentials,\n ).then(multipartDecode);\n }\n\n /**\n * Performs an HTTP GET request that accepts a multipart message\n * with a application/octet-stream media type.\n *\n * @param {String} url - Unique resource locator\n * @param {Object[]} mediaTypes - Acceptable media types and optionally the UIDs of the\n corresponding transfer syntaxes\n * @param {Array} byteRange start and end of byte range\n * @param {Object} params - Additional HTTP GET query parameters\n * @param {Function} progressCallback\n * @private\n * @returns {Promise} Content of HTTP message body parts\n */\n _httpGetMultipartApplicationOctetStream(\n url,\n mediaTypes,\n byteRange,\n params,\n progressCallback,\n withCredentials,\n ) {\n const headers = {};\n const defaultMediaType = 'application/octet-stream';\n const supportedMediaTypes = {\n '1.2.840.10008.1.2.1': [defaultMediaType],\n };\n\n let acceptableMediaTypes = mediaTypes;\n if (!mediaTypes) {\n acceptableMediaTypes = [{ mediaType: defaultMediaType }];\n }\n\n if (byteRange) {\n headers.Range = DICOMwebClient._buildRangeHeaderFieldValue(byteRange);\n }\n\n headers.Accept = DICOMwebClient._buildMultipartAcceptHeaderFieldValue(\n acceptableMediaTypes,\n supportedMediaTypes,\n );\n\n return this._httpGet(\n url,\n headers,\n 'arraybuffer',\n progressCallback,\n withCredentials,\n ).then(multipartDecode);\n }\n\n /**\n * Performs an HTTP POST request.\n *\n * @param {String} url - Unique resource locator\n * @param {Object} headers - HTTP header fields\n * @param {Array} data - Data that should be stored\n * @param {Function} progressCallback\n * @param {Function} progressCallback\n * @param {XMLHttpRequest} request - if specified, the request to use, otherwise one will be created; useful for adding custom upload and abort listeners/objects\n * @private\n * @returns {Promise} Response\n */\n _httpPost(url, headers, data, progressCallback, withCredentials, request) {\n return this._httpRequest(url, 'post', headers, {\n data,\n progressCallback,\n withCredentials,\n request,\n });\n }\n\n /**\n * Performs an HTTP POST request with content-type application/dicom+json.\n *\n * @param {String} url - Unique resource locator\n * @param {Object} headers - HTTP header fields\n * @param {Array} data - Data that should be stored\n * @param {Function} progressCallback\n * @private\n * @returns {Promise} Response\n */\n _httpPostApplicationJson(url, data, progressCallback, withCredentials) {\n const headers = { 'Content-Type': MEDIATYPES.DICOM_JSON };\n return this._httpPost(\n url,\n headers,\n data,\n progressCallback,\n withCredentials,\n );\n }\n\n /**\n * Parses media type and extracts its type and subtype.\n *\n * @param {String} mediaType - HTTP media type (e.g. image/jpeg)\n * @private\n * @returns {String[]} Media type and subtype\n */\n static _parseMediaType(mediaType) {\n DICOMwebClient._assertMediaTypeIsValid(mediaType);\n\n return mediaType.split('/');\n }\n\n /**\n * Builds an accept header field value for HTTP GET request messages.\n *\n * @param {Object[]} mediaTypes - Acceptable media types\n * @param {Object[]} supportedMediaTypes - Supported media types\n * @return {*}\n * @private\n */\n static _buildAcceptHeaderFieldValue(mediaTypes, supportedMediaTypes) {\n if (!Array.isArray(mediaTypes)) {\n throw new Error('Acceptable media types must be provided as an Array');\n }\n\n const fieldValueParts = mediaTypes.map(item => {\n const { mediaType } = item;\n\n DICOMwebClient._assertMediaTypeIsValid(mediaType);\n if (!supportedMediaTypes.includes(mediaType)) {\n throw new Error(\n `Media type ${mediaType} is not supported for requested resource`,\n );\n }\n\n return mediaType;\n });\n\n return fieldValueParts.join(', ');\n }\n\n /**\n * Builds an accept header field value for HTTP GET multipart request\n messages.\n *\n * @param {Object[]} mediaTypes - Acceptable media types\n * @param {Object[]} supportedMediaTypes - Supported media types\n * @private\n */\n static _buildMultipartAcceptHeaderFieldValue(\n mediaTypes,\n supportedMediaTypes,\n ) {\n if (!Array.isArray(mediaTypes)) {\n throw new Error('Acceptable media types must be provided as an Array');\n }\n\n if (!Array.isArray(supportedMediaTypes) && !isObject(supportedMediaTypes)) {\n throw new Error(\n 'Supported media types must be provided as an Array or an Object',\n );\n }\n\n const fieldValueParts = [];\n\n mediaTypes.forEach(item => {\n const { transferSyntaxUID, mediaType } = item;\n DICOMwebClient._assertMediaTypeIsValid(mediaType);\n let fieldValue = `multipart/related; type=\"${mediaType}\"`;\n\n if (isObject(supportedMediaTypes)) {\n // SupportedMediaTypes is a lookup table that maps Transfer Syntax UID\n // to one or more Media Types\n if (\n !Object.values(supportedMediaTypes)\n .flat(1)\n .includes(mediaType)\n ) {\n if (!mediaType.endsWith('/*') || !mediaType.endsWith('/')) {\n throw new Error(\n `Media type ${mediaType} is not supported for requested resource`,\n );\n }\n }\n\n if (transferSyntaxUID) {\n if (transferSyntaxUID !== '*') {\n if (!Object.keys(supportedMediaTypes).includes(transferSyntaxUID)) {\n throw new Error(\n `Transfer syntax ${transferSyntaxUID} is not supported for requested resource`,\n );\n }\n\n const expectedMediaTypes = supportedMediaTypes[transferSyntaxUID];\n\n if (!expectedMediaTypes.includes(mediaType)) {\n const actualType = DICOMwebClient._parseMediaType(mediaType)[0];\n expectedMediaTypes.map(expectedMediaType => {\n const expectedType = DICOMwebClient._parseMediaType(\n expectedMediaType,\n )[0];\n const haveSameType = actualType === expectedType;\n\n if (\n haveSameType &&\n (mediaType.endsWith('/*') || mediaType.endsWith('/'))\n ) {\n return;\n }\n\n throw new Error(\n `Transfer syntax ${transferSyntaxUID} is not supported for requested resource`,\n );\n });\n }\n }\n\n fieldValue += `; transfer-syntax=${transferSyntaxUID}`;\n }\n } else if (\n Array.isArray(supportedMediaTypes) &&\n !supportedMediaTypes.includes(mediaType)\n ) {\n throw new Error(\n `Media type ${mediaType} is not supported for requested resource`,\n );\n }\n\n fieldValueParts.push(fieldValue);\n });\n\n return fieldValueParts.join(', ');\n }\n\n /**\n * Builds a range header field value for HTTP GET request messages.\n *\n * @param {Array} byteRange - Start and end of byte range\n * @returns {String} Range header field value\n * @private\n */\n static _buildRangeHeaderFieldValue(byteRange = []) {\n if (byteRange.length === 1) {\n return `bytes=${byteRange[0]}-`;\n }\n if (byteRange.length === 2) {\n return `bytes=${byteRange[0]}-${byteRange[1]}`;\n }\n\n return 'bytes=0-';\n }\n\n /**\n * Gets types that are shared among acceptable media types.\n *\n * @param {Object[]} mediaTypes - Acceptable media types and optionally the UIDs of the\n corresponding transfer syntaxes\n * @private\n * @returns {String[]} Types that are shared among acceptable media types\n */\n static _getSharedMediaTypes(mediaTypes) {\n const types = new Set();\n\n if (!mediaTypes || !mediaTypes.length) {\n return types;\n }\n\n mediaTypes.forEach(item => {\n const { mediaType } = item;\n const type = DICOMwebClient._parseMediaType(mediaType)[0];\n types.add(`${type}/`);\n });\n\n return Array.from(types);\n }\n\n /**\n * Gets common type of acceptable media types and asserts that only\n one type is specified. For example, ``(\"image/jpeg\", \"image/jp2\")``\n will pass, but ``(\"image/jpeg\", \"video/mpeg2\")`` will raise an\n exception.\n *\n * @param {Object[]} mediaTypes - Acceptable media types and optionally the UIDs of the\n corresponding transfer syntaxes\n * @private\n * @returns {String[]} Common media type\n */\n static _getCommonMediaType(mediaTypes) {\n if (!mediaTypes || !mediaTypes.length) {\n throw new Error('No acceptable media types provided');\n }\n\n const sharedMediaTypes = DICOMwebClient._getSharedMediaTypes(mediaTypes);\n if (sharedMediaTypes.length === 0) {\n throw new Error('No common acceptable media type could be identified.');\n } else if (sharedMediaTypes.length > 1) {\n throw new Error('Acceptable media types must have the same type.');\n }\n\n return sharedMediaTypes[0];\n }\n\n /**\n * Searches for DICOM studies.\n *\n * @param {Object} options\n * @param {Object} [options.queryParams] - HTTP query parameters\n * @return {Object[]} Study representations (http://dicom.nema.org/medical/dicom/current/output/chtml/part18/sect_6.7.html#table_6.7.1-2)\n */\n searchForStudies(options = {}) {\n console.log('search for studies');\n let withCredentials = false;\n let url = `${this.qidoURL}/studies`;\n if ('queryParams' in options) {\n url += DICOMwebClient._parseQueryParameters(options.queryParams);\n }\n if ('withCredentials' in options) {\n if (options.withCredentials) {\n withCredentials = options.withCredentials;\n }\n }\n return this._httpGetApplicationJson(url, {}, false, withCredentials);\n }\n\n /**\n * Retrieves metadata for a DICOM study.\n *\n * @param {Object} options\n * @param {String} options.studyInstanceUID - Study Instance UID\n * @returns {Promise} Metadata elements in DICOM JSON format for each instance\n belonging to the study\n */\n retrieveStudyMetadata(options) {\n if (!('studyInstanceUID' in options)) {\n throw new Error(\n 'Study Instance UID is required for retrieval of study metadata',\n );\n }\n console.log(`retrieve metadata of study ${options.studyInstanceUID}`);\n const url = `${this.wadoURL}/studies/${options.studyInstanceUID}/metadata`;\n let withCredentials = false;\n if ('withCredentials' in options) {\n if (options.withCredentials) {\n withCredentials = options.withCredentials;\n }\n }\n return this._httpGetApplicationJson(url, {}, false, withCredentials);\n }\n\n /**\n * Searches for DICOM series.\n *\n * @param {Object} options\n * @param {Object} [options.studyInstanceUID] - Study Instance UID\n * @param {Object} [options.queryParams] - HTTP query parameters\n * @returns {Object[]} Series representations (http://dicom.nema.org/medical/dicom/current/output/chtml/part18/sect_6.7.html#table_6.7.1-2a)\n */\n searchForSeries(options = {}) {\n let url = this.qidoURL;\n if ('studyInstanceUID' in options) {\n console.log(`search series of study ${options.studyInstanceUID}`);\n url += `/studies/${options.studyInstanceUID}`;\n }\n url += '/series';\n if ('queryParams' in options) {\n url += DICOMwebClient._parseQueryParameters(options.queryParams);\n }\n let withCredentials = false;\n if ('withCredentials' in options) {\n if (options.withCredentials) {\n withCredentials = options.withCredentials;\n }\n }\n return this._httpGetApplicationJson(url, {}, false, withCredentials);\n }\n\n /**\n * Retrieves metadata for a DICOM series.\n *\n * @param {Object} options\n * @param {String} options.studyInstanceUID - Study Instance UID\n * @param {String} options.seriesInstanceUID - Series Instance UID\n * @returns {Promise} Metadata elements in DICOM JSON format for each instance\n belonging to the series\n */\n retrieveSeriesMetadata(options) {\n if (!('studyInstanceUID' in options)) {\n throw new Error(\n 'Study Instance UID is required for retrieval of series metadata',\n );\n }\n if (!('seriesInstanceUID' in options)) {\n throw new Error(\n 'Series Instance UID is required for retrieval of series metadata',\n );\n }\n\n console.log(`retrieve metadata of series ${options.seriesInstanceUID}`);\n const url = `${this.wadoURL}/studies/${options.studyInstanceUID}/series/${options.seriesInstanceUID}/metadata`;\n let withCredentials = false;\n if ('withCredentials' in options) {\n if (options.withCredentials) {\n withCredentials = options.withCredentials;\n }\n }\n return this._httpGetApplicationJson(url, {}, false, withCredentials);\n }\n\n /**\n * Searches for DICOM Instances.\n *\n * @param {Object} options\n * @param {String} [options.studyInstanceUID] - Study Instance UID\n * @param {String} [options.seriesInstanceUID] - Series Instance UID\n * @param {Object} [options.queryParams] - HTTP query parameters\n * @returns {Object[]} Instance representations (http://dicom.nema.org/medical/dicom/current/output/chtml/part18/sect_6.7.html#table_6.7.1-2b)\n */\n searchForInstances(options = {}) {\n let url = this.qidoURL;\n let withCredentials = false;\n if ('studyInstanceUID' in options) {\n url += `/studies/${options.studyInstanceUID}`;\n if ('seriesInstanceUID' in options) {\n console.log(\n `search for instances of series ${options.seriesInstanceUID}`,\n );\n url += `/series/${options.seriesInstanceUID}`;\n } else {\n console.log(\n `search for instances of study ${options.studyInstanceUID}`,\n );\n }\n } else {\n console.log('search for instances');\n }\n url += '/instances';\n if ('queryParams' in options) {\n url += DICOMwebClient._parseQueryParameters(options.queryParams);\n }\n if ('withCredentials' in options) {\n if (options.withCredentials) {\n withCredentials = options.withCredentials;\n }\n }\n return this._httpGetApplicationJson(url, {}, false, withCredentials);\n }\n\n /** Returns a WADO-URI URL for an instance\n *\n * @param {Object} options\n * @param {String} options.studyInstanceUID - Study Instance UID\n * @param {String} options.seriesInstanceUID - Series Instance UID\n * @param {String} options.sopInstanceUID - SOP Instance UID\n * @returns {String} WADO-URI URL\n */\n buildInstanceWadoURIUrl(options) {\n if (!('studyInstanceUID' in options)) {\n throw new Error('Study Instance UID is required.');\n }\n if (!('seriesInstanceUID' in options)) {\n throw new Error('Series Instance UID is required.');\n }\n if (!('sopInstanceUID' in options)) {\n throw new Error('SOP Instance UID is required.');\n }\n\n const contentType = options.contentType || MEDIATYPES.DICOM;\n const transferSyntax = options.transferSyntax || '*';\n const params = [];\n\n params.push('requestType=WADO');\n params.push(`studyUID=${options.studyInstanceUID}`);\n params.push(`seriesUID=${options.seriesInstanceUID}`);\n params.push(`objectUID=${options.sopInstanceUID}`);\n params.push(`contentType=${contentType}`);\n params.push(`transferSyntax=${transferSyntax}`);\n\n const paramString = params.join('&');\n\n return `${this.wadoURL}?${paramString}`;\n }\n\n /**\n * Retrieves metadata for a DICOM Instance.\n *\n * @param {Object} options object\n * @param {String} options.studyInstanceUID - Study Instance UID\n * @param {String} options.seriesInstanceUID - Series Instance UID\n * @param {String} options.sopInstanceUID - SOP Instance UID\n * @returns {Promise} metadata elements in DICOM JSON format\n */\n retrieveInstanceMetadata(options) {\n if (!('studyInstanceUID' in options)) {\n throw new Error(\n 'Study Instance UID is required for retrieval of instance metadata',\n );\n }\n if (!('seriesInstanceUID' in options)) {\n throw new Error(\n 'Series Instance UID is required for retrieval of instance metadata',\n );\n }\n if (!('sopInstanceUID' in options)) {\n throw new Error(\n 'SOP Instance UID is required for retrieval of instance metadata',\n );\n }\n console.log(`retrieve metadata of instance ${options.sopInstanceUID}`);\n const url = `${this.wadoURL}/studies/${options.studyInstanceUID}/series/${options.seriesInstanceUID}/instances/${options.sopInstanceUID}/metadata`;\n let withCredentials = false;\n if ('withCredentials' in options) {\n if (options.withCredentials) {\n withCredentials = options.withCredentials;\n }\n }\n return this._httpGetApplicationJson(url, {}, false, withCredentials);\n }\n\n /**\n * Retrieves frames for a DICOM Instance.\n * @param {Object} options options object\n * @param {String} options.studyInstanceUID - Study Instance UID\n * @param {String} options.seriesInstanceUID - Series Instance UID\n * @param {String} options.sopInstanceUID - SOP Instance UID\n * @param {String} options.frameNumbers - One-based indices of Frame Items\n * @returns {Array} frame items as byte arrays of the pixel data element\n */\n retrieveInstanceFrames(options) {\n if (!('studyInstanceUID' in options)) {\n throw new Error(\n 'Study Instance UID is required for retrieval of instance frames',\n );\n }\n if (!('seriesInstanceUID' in options)) {\n throw new Error(\n 'Series Instance UID is required for retrieval of instance frames',\n );\n }\n if (!('sopInstanceUID' in options)) {\n throw new Error(\n 'SOP Instance UID is required for retrieval of instance frames',\n );\n }\n if (!('frameNumbers' in options)) {\n throw new Error(\n 'frame numbers are required for retrieval of instance frames',\n );\n }\n console.log(\n `retrieve frames ${options.frameNumbers.toString()} of instance ${\n options.sopInstanceUID\n }`,\n );\n const url = `${this.wadoURL}/studies/${options.studyInstanceUID}/series/${\n options.seriesInstanceUID\n }/instances/${\n options.sopInstanceUID\n }/frames/${options.frameNumbers.toString()}`;\n\n const { mediaTypes } = options;\n let withCredentials = false;\n if ('withCredentials' in options) {\n if (options.withCredentials) {\n withCredentials = options.withCredentials;\n }\n }\n\n let progressCallback = false;\n if ('progressCallback' in options) {\n progressCallback = options.progressCallback;\n }\n\n if (!mediaTypes) {\n return this._httpGetMultipartApplicationOctetStream(\n url,\n false,\n false,\n false,\n progressCallback,\n withCredentials,\n );\n }\n\n const sharedMediaTypes = DICOMwebClient._getSharedMediaTypes(mediaTypes);\n if (sharedMediaTypes.length > 1) {\n /**\n * Enable request of frames that are stored either compressed\n * (image/* media type) or uncompressed (application/octet-stream\n * media type).\n */\n const supportedMediaTypes = {\n '1.2.840.10008.1.2.1': ['application/octet-stream'],\n '1.2.840.10008.1.2.5': ['image/x-dicom-rle'],\n '1.2.840.10008.1.2.4.50': ['image/jpeg'],\n '1.2.840.10008.1.2.4.51': ['image/jpeg'],\n '1.2.840.10008.1.2.4.57': ['image/jpeg'],\n '1.2.840.10008.1.2.4.70': ['image/jpeg'],\n '1.2.840.10008.1.2.4.80': ['image/x-jls', 'image/jls'],\n '1.2.840.10008.1.2.4.81': ['image/x-jls', 'image/jls'],\n '1.2.840.10008.1.2.4.90': ['image/jp2'],\n '1.2.840.10008.1.2.4.91': ['image/jp2'],\n '1.2.840.10008.1.2.4.92': ['image/jpx'],\n '1.2.840.10008.1.2.4.93': ['image/jpx'],\n };\n\n const headers = {\n Accept: DICOMwebClient._buildMultipartAcceptHeaderFieldValue(\n mediaTypes,\n supportedMediaTypes,\n ),\n };\n return this._httpGet(\n url,\n headers,\n 'arraybuffer',\n progressCallback,\n withCredentials,\n ).then(multipartDecode);\n }\n\n const commonMediaType = DICOMwebClient._getCommonMediaType(mediaTypes);\n\n if (commonMediaType.startsWith('application')) {\n return this._httpGetMultipartApplicationOctetStream(\n url,\n mediaTypes,\n false,\n false,\n progressCallback,\n withCredentials,\n );\n }\n if (commonMediaType.startsWith('image')) {\n return this._httpGetMultipartImage(\n url,\n mediaTypes,\n false,\n false,\n false,\n progressCallback,\n withCredentials,\n );\n }\n if (commonMediaType.startsWith('video')) {\n return this._httpGetMultipartVideo(\n url,\n mediaTypes,\n false,\n false,\n false,\n progressCallback,\n withCredentials,\n );\n }\n\n throw new Error(\n `Media type ${commonMediaType} is not supported for retrieval of frames.`,\n );\n }\n\n /**\n * Retrieves an individual, server-side rendered DICOM Instance.\n *\n * @param {Object} options\n * @param {String} options.studyInstanceUID - Study Instance UID\n * @param {String} options.seriesInstanceUID - Series Instance UID\n * @param {String} options.sopInstanceUID - SOP Instance UID\n * @param {String[]} [options.mediaType] - Acceptable HTTP media types\n * @param {Object} [options.queryParams] - HTTP query parameters\n * @returns {Promise} Rendered DICOM Instance\n */\n retrieveInstanceRendered(options) {\n if (!('studyInstanceUID' in options)) {\n throw new Error(\n 'Study Instance UID is required for retrieval of rendered instance',\n );\n }\n if (!('seriesInstanceUID' in options)) {\n throw new Error(\n 'Series Instance UID is required for retrieval of rendered instance',\n );\n }\n if (!('sopInstanceUID' in options)) {\n throw new Error(\n 'SOP Instance UID is required for retrieval of rendered instance',\n );\n }\n\n let url = `${this.wadoURL}/studies/${options.studyInstanceUID}/series/${options.seriesInstanceUID}/instances/${options.sopInstanceUID}/rendered`;\n\n const { mediaTypes, queryParams } = options;\n const headers = {};\n let withCredentials = false;\n if ('withCredentials' in options) {\n if (options.withCredentials) {\n withCredentials = options.withCredentials;\n }\n }\n\n let progressCallback = false;\n if ('progressCallback' in options) {\n progressCallback = options.progressCallback;\n }\n\n if (!mediaTypes) {\n const responseType = 'arraybuffer';\n if (queryParams) {\n url += DICOMwebClient._parseQueryParameters(queryParams);\n }\n return this._httpGet(\n url,\n headers,\n responseType,\n progressCallback,\n withCredentials,\n );\n }\n\n const commonMediaType = DICOMwebClient._getCommonMediaType(mediaTypes);\n if (commonMediaType.startsWith('image')) {\n return this._httpGetImage(\n url,\n mediaTypes,\n queryParams,\n progressCallback,\n withCredentials,\n );\n }\n if (commonMediaType.startsWith('video')) {\n return this._httpGetVideo(\n url,\n mediaTypes,\n queryParams,\n progressCallback,\n withCredentials,\n );\n }\n if (commonMediaType.startsWith('text')) {\n return this._httpGetText(\n url,\n mediaTypes,\n queryParams,\n progressCallback,\n withCredentials,\n );\n }\n if (commonMediaType === MEDIATYPES.PDF) {\n return this._httpGetApplicationPdf(\n url,\n queryParams,\n progressCallback,\n withCredentials,\n );\n }\n\n throw new Error(\n `Media type ${commonMediaType} is not supported ` +\n 'for retrieval of rendered instance.',\n );\n }\n\n /**\n * Retrieves a thumbnail of an DICOM Instance.\n *\n * @param {Object} options\n * @param {String} options.studyInstanceUID - Study Instance UID\n * @param {String} options.seriesInstanceUID - Series Instance UID\n * @param {String} options.sopInstanceUID - SOP Instance UID\n * @param {String[]} [options.mediaType] - Acceptable HTTP media types\n * @param {Object} [options.queryParams] - HTTP query parameters\n * @returns {ArrayBuffer} Thumbnail\n */\n retrieveInstanceThumbnail(options) {\n if (!('studyInstanceUID' in options)) {\n throw new Error(\n 'Study Instance UID is required for retrieval of rendered instance',\n );\n }\n if (!('seriesInstanceUID' in options)) {\n throw new Error(\n 'Series Instance UID is required for retrieval of rendered instance',\n );\n }\n if (!('sopInstanceUID' in options)) {\n throw new Error(\n 'SOP Instance UID is required for retrieval of rendered instance',\n );\n }\n\n let url = `${this.wadoURL}/studies/${options.studyInstanceUID}/series/${options.seriesInstanceUID}/instances/${options.sopInstanceUID}/thumbnail`;\n\n const { mediaTypes, queryParams } = options;\n const headers = {};\n let withCredentials = false;\n if ('withCredentials' in options) {\n if (options.withCredentials) {\n withCredentials = options.withCredentials;\n }\n }\n\n let progressCallback = false;\n if ('progressCallback' in options) {\n progressCallback = options.progressCallback;\n }\n\n if (!mediaTypes) {\n const responseType = 'arraybuffer';\n if (queryParams) {\n url += DICOMwebClient._parseQueryParameters(queryParams);\n }\n return this._httpGet(\n url,\n headers,\n responseType,\n progressCallback,\n withCredentials,\n );\n }\n\n const commonMediaType = DICOMwebClient._getCommonMediaType(mediaTypes);\n if (commonMediaType.startsWith('image')) {\n return this._httpGetImage(\n url,\n mediaTypes,\n queryParams,\n progressCallback,\n withCredentials,\n );\n }\n\n throw new Error(\n `Media type ${commonMediaType} is not supported ` +\n 'for retrieval of rendered instance.',\n );\n }\n\n /**\n * Retrieves rendered frames for a DICOM Instance.\n *\n * @param {Object} options\n * @param {String} options.studyInstanceUID - Study Instance UID\n * @param {String} options.seriesInstanceUID - Series Instance UID\n * @param {String} options.sopInstanceUID - SOP Instance UID\n * @param {String} options.frameNumbers - One-based indices of Frame Items\n * @param {String[]} [options.mediaType] - Acceptable HTTP media types\n * @param {Object} [options.queryParams] - HTTP query parameters\n * @returns {ArrayBuffer[]} Rendered Frame Items as byte arrays\n */\n retrieveInstanceFramesRendered(options) {\n if (!('studyInstanceUID' in options)) {\n throw new Error(\n 'Study Instance UID is required for retrieval of rendered instance frames',\n );\n }\n if (!('seriesInstanceUID' in options)) {\n throw new Error(\n 'Series Instance UID is required for retrieval of rendered instance frames',\n );\n }\n if (!('sopInstanceUID' in options)) {\n throw new Error(\n 'SOP Instance UID is required for retrieval of rendered instance frames',\n );\n }\n if (!('frameNumbers' in options)) {\n throw new Error(\n 'frame numbers are required for retrieval of rendered instance frames',\n );\n }\n\n console.debug(\n `retrieve rendered frames ${options.frameNumbers.toString()} of instance ${\n options.sopInstanceUID\n }`,\n );\n let url = `${this.wadoURL}/studies/${options.studyInstanceUID}/series/${\n options.seriesInstanceUID\n }/instances/${\n options.sopInstanceUID\n }/frames/${options.frameNumbers.toString()}/rendered`;\n\n const { mediaTypes, queryParams } = options;\n const headers = {};\n let withCredentials = false;\n if ('withCredentials' in options) {\n if (options.withCredentials) {\n withCredentials = options.withCredentials;\n }\n }\n let progressCallback = false;\n if ('progressCallback' in options) {\n progressCallback = options.progressCallback;\n }\n\n if (!mediaTypes) {\n const responseType = 'arraybuffer';\n if (queryParams) {\n url += DICOMwebClient._parseQueryParameters(queryParams);\n }\n return this._httpGet(url, headers, responseType, false, withCredentials);\n }\n\n const commonMediaType = DICOMwebClient._getCommonMediaType(mediaTypes);\n if (commonMediaType.startsWith('image')) {\n return this._httpGetImage(\n url,\n mediaTypes,\n queryParams,\n progressCallback,\n withCredentials,\n );\n }\n if (commonMediaType.startsWith('video')) {\n return this._httpGetVideo(\n url,\n mediaTypes,\n queryParams,\n progressCallback,\n withCredentials,\n );\n }\n\n throw new Error(\n `Media type ${commonMediaType} is not supported ` +\n 'for retrieval of rendered frame.',\n );\n }\n\n /**\n * Retrieves thumbnail of frames for a DICOM Instance.\n *\n * @param {Object} options\n * @param {String} options.studyInstanceUID - Study Instance UID\n * @param {String} options.seriesInstanceUID - Series Instance UID\n * @param {String} options.sopInstanceUID - SOP Instance UID\n * @param {String} options.frameNumbers - One-based indices of Frame Items\n * @param {Object} [options.queryParams] - HTTP query parameters\n * @returns {ArrayBuffer[]} Rendered Frame Items as byte arrays\n */\n retrieveInstanceFramesThumbnail(options) {\n if (!('studyInstanceUID' in options)) {\n throw new Error(\n 'Study Instance UID is required for retrieval of rendered instance frames',\n );\n }\n if (!('seriesInstanceUID' in options)) {\n throw new Error(\n 'Series Instance UID is required for retrieval of rendered instance frames',\n );\n }\n if (!('sopInstanceUID' in options)) {\n throw new Error(\n 'SOP Instance UID is required for retrieval of rendered instance frames',\n );\n }\n if (!('frameNumbers' in options)) {\n throw new Error(\n 'frame numbers are required for retrieval of rendered instance frames',\n );\n }\n\n console.debug(\n `retrieve rendered frames ${options.frameNumbers.toString()} of instance ${\n options.sopInstanceUID\n }`,\n );\n let url = `${this.wadoURL}/studies/${options.studyInstanceUID}/series/${\n options.seriesInstanceUID\n }/instances/${\n options.sopInstanceUID\n }/frames/${options.frameNumbers.toString()}/thumbnail`;\n\n const { mediaTypes, queryParams } = options;\n const headers = {};\n let withCredentials = false;\n if ('withCredentials' in options) {\n if (options.withCredentials) {\n withCredentials = options.withCredentials;\n }\n }\n\n let progressCallback = false;\n if ('progressCallback' in options) {\n progressCallback = options.progressCallback;\n }\n\n if (!mediaTypes) {\n const responseType = 'arraybuffer';\n if (queryParams) {\n url += DICOMwebClient._parseQueryParameters(queryParams);\n }\n return this._httpGet(\n url,\n headers,\n responseType,\n progressCallback,\n withCredentials,\n );\n }\n\n const commonMediaType = DICOMwebClient._getCommonMediaType(mediaTypes);\n if (commonMediaType.startsWith('image')) {\n return this._httpGetImage(\n url,\n mediaTypes,\n queryParams,\n progressCallback,\n withCredentials,\n );\n }\n\n throw new Error(\n `Media type ${commonMediaType} is not supported ` +\n 'for retrieval of rendered frame.',\n );\n }\n\n /**\n * Retrieves a DICOM Instance.\n *\n * @param {Object} options\n * @param {String} options.studyInstanceUID - Study Instance UID\n * @param {String} options.seriesInstanceUID - Series Instance UID\n * @param {String} options.sopInstanceUID - SOP Instance UID\n * @returns {Promise} DICOM Part 10 file as Arraybuffer\n */\n retrieveInstance(options) {\n if (!('studyInstanceUID' in options)) {\n throw new Error('Study Instance UID is required');\n }\n if (!('seriesInstanceUID' in options)) {\n throw new Error('Series Instance UID is required');\n }\n if (!('sopInstanceUID' in options)) {\n throw new Error('SOP Instance UID is required');\n }\n const url = `${this.wadoURL}/studies/${options.studyInstanceUID}/series/${options.seriesInstanceUID}/instances/${options.sopInstanceUID}`;\n\n const { mediaTypes } = options;\n const { withCredentials = false } = options;\n const { progressCallback = false } = options;\n\n if (!mediaTypes) {\n return this._httpGetMultipartApplicationDicom(\n url,\n false,\n false,\n progressCallback,\n withCredentials,\n ).then(getFirstResult);\n }\n\n const commonMediaType = DICOMwebClient._getCommonMediaType(mediaTypes);\n if (commonMediaType === MEDIATYPES.DICOM) {\n return this._httpGetMultipartApplicationDicom(\n url,\n mediaTypes,\n false,\n progressCallback,\n withCredentials,\n ).then(getFirstResult);\n }\n\n throw new Error(\n `Media type ${commonMediaType} is not supported for retrieval of instance.`,\n );\n }\n\n /**\n * Retrieves all DICOM Instances of a Series.\n *\n * @param {Object} options\n * @param {String} options.studyInstanceUID - Study Instance UID\n * @param {String} options.seriesInstanceUID - Series Instance UID\n * @param {Function} options.progressCallback\n * @returns {Promise} DICOM Instances\n */\n retrieveSeries(options) {\n if (!('studyInstanceUID' in options)) {\n throw new Error('Study Instance UID is required');\n }\n if (!('seriesInstanceUID' in options)) {\n throw new Error('Series Instance UID is required');\n }\n\n const url = `${this.wadoURL}/studies/${options.studyInstanceUID}/series/${options.seriesInstanceUID}`;\n\n const { mediaTypes } = options;\n let withCredentials = false;\n if ('withCredentials' in options) {\n if (options.withCredentials) {\n withCredentials = options.withCredentials;\n }\n }\n\n let progressCallback = false;\n if ('progressCallback' in options) {\n progressCallback = options.progressCallback;\n }\n\n if (!mediaTypes) {\n return this._httpGetMultipartApplicationDicom(\n url,\n false,\n false,\n progressCallback,\n withCredentials,\n );\n }\n\n const commonMediaType = DICOMwebClient._getCommonMediaType(mediaTypes);\n if (commonMediaType === MEDIATYPES.DICOM) {\n return this._httpGetMultipartApplicationDicom(\n url,\n mediaTypes,\n false,\n progressCallback,\n withCredentials,\n );\n }\n\n throw new Error(\n `Media type ${commonMediaType} is not supported for retrieval of series.`,\n );\n }\n\n /**\n * Retrieves all DICOM Instances of a Study.\n *\n * @param {Object} options\n * @param {String} options.studyInstanceUID - Study Instance UID\n * @returns {ArrayBuffer[]} DICOM Instances\n */\n retrieveStudy(options) {\n if (!('studyInstanceUID' in options)) {\n throw new Error('Study Instance UID is required');\n }\n\n const url = `${this.wadoURL}/studies/${options.studyInstanceUID}`;\n\n const { mediaTypes } = options;\n const { withCredentials = false } = options;\n const { progressCallback = false } = options;\n\n if (!mediaTypes) {\n return this._httpGetMultipartApplicationDicom(\n url,\n false,\n false,\n progressCallback,\n withCredentials,\n );\n }\n\n const commonMediaType = DICOMwebClient._getCommonMediaType(mediaTypes);\n if (commonMediaType === MEDIATYPES.DICOM) {\n return this._httpGetMultipartApplicationDicom(\n url,\n mediaTypes,\n false,\n progressCallback,\n withCredentials,\n );\n }\n\n throw new Error(\n `Media type ${commonMediaType} is not supported for retrieval of study.`,\n );\n }\n\n /**\n * Retrieves and parses BulkData from a BulkDataURI location.\n * Decodes the multipart encoded data and returns the resulting data\n * as an ArrayBuffer.\n *\n * See http://dicom.nema.org/medical/dicom/current/output/chtml/part18/sect_6.5.5.html\n *\n * @param {Object} options\n * @param {String} BulkDataURI - URI for retrieval of bulkdata\n * @returns {Promise} Bulkdata parts\n */\n retrieveBulkData(options) {\n if (!('BulkDataURI' in options)) {\n throw new Error('BulkDataURI is required.');\n }\n\n const url = options.BulkDataURI;\n const { mediaTypes, byteRange } = options;\n const { withCredentials = false } = options;\n const { progressCallback = false } = options;\n\n if (!mediaTypes) {\n return this._httpGetMultipartApplicationOctetStream(\n url,\n mediaTypes,\n byteRange,\n false,\n false,\n withCredentials,\n );\n }\n\n const commonMediaType = DICOMwebClient._getCommonMediaType(mediaTypes);\n\n if (commonMediaType === MEDIATYPES.OCTET_STREAM) {\n return this._httpGetMultipartApplicationOctetStream(\n url,\n mediaTypes,\n byteRange,\n false,\n progressCallback,\n withCredentials,\n );\n }\n if (commonMediaType.startsWith('image')) {\n return this._httpGetMultipartImage(\n url,\n mediaTypes,\n byteRange,\n false,\n false,\n progressCallback,\n withCredentials,\n );\n }\n\n throw new Error(\n `Media type ${commonMediaType} is not supported for retrieval of bulk data.`,\n );\n }\n\n /**\n * Stores DICOM Instances.\n *\n * @param {Object} options\n * @param {ArrayBuffer[]} options.datasets - DICOM Instances in PS3.10 format\n * @param {String} [options.studyInstanceUID] - Study Instance UID\n * @param {XMLHttpRequest} [options.request] - if specified, the request to use, otherwise one will be created; useful for adding custom upload and abort listeners/objects\n * @returns {Promise} Response message\n */\n storeInstances(options) {\n if (!('datasets' in options)) {\n throw new Error('datasets are required for storing');\n }\n\n let url = `${this.stowURL}/studies`;\n if ('studyInstanceUID' in options) {\n url += `/${options.studyInstanceUID}`;\n }\n\n const { data, boundary } = multipartEncode(options.datasets);\n const headers = {\n 'Content-Type': `multipart/related; type=\"application/dicom\"; boundary=\"${boundary}\"`,\n };\n const { withCredentials = false } = options;\n return this._httpPost(\n url,\n headers,\n data,\n options.progressCallback,\n withCredentials,\n options.request,\n );\n }\n}\n\n\nexport { DICOMwebClient };\nexport default DICOMwebClient;\n","export default '0.5.2';\n","import { DICOMwebClient } from './api.js';\nimport {\n getStudyInstanceUIDFromUri,\n getSeriesInstanceUIDFromUri,\n getSOPInstanceUIDFromUri,\n getFrameNumbersFromUri,\n} from './utils.js';\n\nconst api = {\n DICOMwebClient,\n};\nconst utils = {\n getStudyInstanceUIDFromUri,\n getSeriesInstanceUIDFromUri,\n getSOPInstanceUIDFromUri,\n getFrameNumbersFromUri,\n};\n\nexport { default as version } from './version.js';\n\nexport { api, utils };\n"],"names":["stringToUint8Array","str","arr","Uint8Array","length","i","j","charCodeAt","containsToken","message","token","offset","index","findToken","maxSearchLength","searchLength","Math","min","multipartEncode","datasets","boundary","s4","floor","random","toString","substring","guid","contentTypeString","header","footer","headerArray","footerArray","headerLength","footerLength","contentArrays","map","datasetBuffer","contentArray","contentLength","multipartArray","set","position","forEach","data","buffer","multipartDecode","response","separator","headerIndex","Error","itemLimit","String","fromCharCode","uint8ArrayToString","boundaryString","parts","split","substr","identifyBoundary","boundaryIndex","boundaryLength","components","headerTokenIndex","slice","push","isObject","obj","isEmptyObject","Object","keys","constructor","getFirstResult","result","MEDIATYPES","api","DICOMwebClient","options","this","baseURL","url","console","error","username","password","log","qidoURLPrefix","qidoURL","wadoURLPrefix","wadoURL","stowURLPrefix","stowURL","requestHooks","headers","errorInterceptor","verbose","method","Promise","resolve","reject","request","XMLHttpRequest","open","responseType","key","setRequestHeader","functions","userHeaders","onloadstart","onloadend","onreadystatechange","readyState","status","warn","progressCallback","onprogress","isValid","Array","isArray","every","requestHook","areValidRequestHooks","combinedHeaders","assign","metadata","pipedRequest","args","reduce","props","fn","withCredentials","send","_httpRequest","params","urlWithQueryParams","_parseQueryParameters","Accept","_httpGet","mediaTypes","_buildAcceptHeaderFieldValue","byteRange","supportedMediaTypes","Range","_buildRangeHeaderFieldValue","_buildMultipartAcceptHeaderFieldValue","then","defaultMediaType","acceptableMediaTypes","mediaType","_httpPost","queryParams","_httpGetApplicationJson","studyInstanceUID","seriesInstanceUID","contentType","transferSyntax","sopInstanceUID","paramString","join","frameNumbers","_httpGetMultipartApplicationOctetStream","_getSharedMediaTypes","commonMediaType","_getCommonMediaType","startsWith","_httpGetMultipartImage","_httpGetMultipartVideo","_httpGetImage","_httpGetVideo","_httpGetText","_httpGetApplicationPdf","debug","_httpGetMultipartApplicationDicom","BulkDataURI","queryString","encodeURIComponent","sepIndex","indexOf","mediaTypeType","includes","_assertMediaTypeIsValid","item","fieldValueParts","transferSyntaxUID","fieldValue","values","flat","endsWith","expectedMediaTypes","actualType","_parseMediaType","expectedMediaType","expectedType","types","Set","type","add","from","sharedMediaTypes"],"sourceRoot":""}