{"version":3,"file":"export-from-json-BvevaQwb.js","sources":["../../../node_modules/export-from-json/dist/esm/utils.js","../../../node_modules/export-from-json/dist/esm/processors.js","../../../node_modules/export-from-json/dist/esm/converters.js","../../../node_modules/export-from-json/dist/esm/types.js","../../../node_modules/export-from-json/dist/esm/exportFromJSON.js"],"sourcesContent":["export function isArray(data) {\n return Object.prototype.toString.call(data) === '[object Array]';\n}\nexport function assert(condition, msg) {\n if (!condition)\n throw new Error(msg);\n}\nexport function getValues(data) {\n return Object.keys(data).map(function (key) { return data[key]; });\n}\nexport function getKeys(data) {\n return Object.keys(data);\n}\nexport function getEntries(data) {\n return Object.keys(data).map(function (key) { return [key, data[key]]; });\n}\nexport function normalizeFileName(fileName, extension, fileNameFormatter) {\n var suffix = '.' + extension;\n var extensionPattern = new RegExp(\"(\\\\\".concat(extension, \")?$\"));\n return fileNameFormatter(fileName).replace(extensionPattern, suffix);\n}\nexport function normalizeXMLName(name) {\n '555xmlHello . world!'.trim().replace(/^([0-9,;]|(xml))+/, '');\n return name.replace(/[^_a-zA-Z 0-9:\\-\\.]/g, '').replace(/^([ 0-9-:\\-\\.]|(xml))+/i, '').replace(/ +/g, '-');\n}\nexport function indent(spaces) {\n return Array(spaces + 1).join(' ');\n}\nexport function stripHTML(text) {\n return text.replace(/([<>&])/g, function (_, $1) {\n switch ($1) {\n case '<': return '<';\n case '>': return '>';\n case '&': return '&';\n default: return '';\n }\n });\n}\n","export function generateDataURI(content, type, byBlob) {\n switch (type) {\n case 'txt': {\n var blobType = 'text/plain;charset=utf-8';\n if (byBlob)\n return URL.createObjectURL(new Blob([content], { type: blobType }));\n return \"data:,\".concat(blobType) + encodeURIComponent(content);\n }\n case 'css': {\n var blobType = 'text/css;charset=utf-8';\n if (byBlob)\n return URL.createObjectURL(new Blob([content], { type: blobType }));\n return \"data:,\".concat(blobType) + encodeURIComponent(content);\n }\n case 'html': {\n var blobType = 'text/html;charset=utf-8';\n if (byBlob)\n return URL.createObjectURL(new Blob([content], { type: blobType }));\n return \"data:,\".concat(blobType) + encodeURIComponent(content);\n }\n case 'json': {\n var blobType = 'text/json;charset=utf-8';\n if (byBlob)\n return URL.createObjectURL(new Blob([content], { type: blobType }));\n return \"data:,\".concat(blobType) + encodeURIComponent(content);\n }\n case 'csv': {\n var blobType = 'text/csv;charset=utf-8';\n if (byBlob)\n return URL.createObjectURL(new Blob([content], { type: blobType }));\n return \"data:,\".concat(blobType) + encodeURIComponent(content);\n }\n case 'xls': {\n var blobType = 'text/application/vnd.ms-excel;charset=utf-8';\n if (byBlob)\n return URL.createObjectURL(new Blob([content], { type: blobType }));\n return \"data:,\".concat(blobType) + encodeURIComponent(content);\n }\n case 'xml': {\n var blobType = 'text/application/xml;charset=utf-8';\n if (byBlob)\n return URL.createObjectURL(new Blob([content], { type: blobType }));\n return \"data:,\".concat(blobType) + encodeURIComponent(content);\n }\n default: {\n return '';\n }\n }\n}\nexport function downloadFile(content, type, fileName, byBlob) {\n if (fileName === void 0) { fileName = 'download'; }\n if (byBlob === void 0) { byBlob = true; }\n var dataURI = generateDataURI(content, type, byBlob);\n var anchor = document.createElement('a');\n anchor.href = dataURI;\n anchor.download = fileName;\n anchor.setAttribute('style', 'visibility:hidden');\n document.body.appendChild(anchor);\n anchor.dispatchEvent(new MouseEvent('click', {\n bubbles: false,\n cancelable: false,\n view: window,\n }));\n document.body.removeChild(anchor);\n}\n","var __assign = (this && this.__assign) || function () {\n __assign = Object.assign || function(t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))\n t[p] = s[p];\n }\n return t;\n };\n return __assign.apply(this, arguments);\n};\nvar __read = (this && this.__read) || function (o, n) {\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\n if (!m) return o;\n var i = m.call(o), r, ar = [], e;\n try {\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\n }\n catch (error) { e = { error: error }; }\n finally {\n try {\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\n }\n finally { if (e) throw e.error; }\n }\n return ar;\n};\nimport { isArray, getEntries, normalizeXMLName, indent, stripHTML, assert, getKeys } from './utils.js';\nexport function _createFieldsMapper(fields) {\n if (!fields\n || isArray(fields) && !fields.length\n || !isArray(fields) && !getKeys(fields).length)\n return function (item) { return item; };\n var mapper = isArray(fields)\n ? fields.reduce(function (map, key) {\n var _a;\n return (__assign(__assign({}, map), (_a = {}, _a[key] = key, _a)));\n }, Object.create(null))\n : fields;\n return function (item) {\n if (isArray(item)) {\n return item\n .map(function (i) { return getEntries(i).reduce(function (map, _a) {\n var _b = __read(_a, 2), key = _b[0], value = _b[1];\n if (key in mapper) {\n map[mapper[key]] = value;\n }\n return map;\n }, Object.create(null)); })\n .filter(function (i) { return getKeys(i).length; });\n }\n return getEntries(item).reduce(function (map, _a) {\n var _b = __read(_a, 2), key = _b[0], value = _b[1];\n if (key in mapper) {\n map[mapper[key]] = value;\n }\n return map;\n }, Object.create(null));\n };\n}\nexport function _prepareData(data) {\n var MESSAGE_VALID_JSON_FAIL = 'Invalid export data. Please provide a valid JSON';\n try {\n return (typeof data === 'string' ? JSON.parse(data) : data);\n }\n catch (_a) {\n throw new Error(MESSAGE_VALID_JSON_FAIL);\n }\n}\nexport function _createJSONData(data, replacer, space) {\n if (replacer === void 0) { replacer = null; }\n var MESSAGE_VALID_JSON_FAIL = 'Invalid export data. Please provide valid JSON object';\n try {\n return JSON.stringify(data, replacer, space);\n }\n catch (_a) {\n throw new Error(MESSAGE_VALID_JSON_FAIL);\n }\n}\nexport function _createTableMap(data) {\n return data.map(getEntries).reduce(function (tMap, rowKVs, rowIndex) {\n return rowKVs.reduce(function (map, _a) {\n var _b = __read(_a, 2), key = _b[0], value = _b[1];\n var columnValues = map[key] || Array.from({ length: data.length }).map(function (_) { return ''; });\n columnValues[rowIndex] =\n (typeof value !== 'string' ? JSON.stringify(value) : value) || '';\n map[key] = columnValues;\n return map;\n }, tMap);\n }, Object.create(null));\n}\nexport function _createTableEntries(tableMap, beforeTableEncode) {\n if (beforeTableEncode === void 0) { beforeTableEncode = function (i) { return i; }; }\n return beforeTableEncode(getEntries(tableMap).map(function (_a) {\n var _b = __read(_a, 2), fieldName = _b[0], fieldValues = _b[1];\n return ({\n fieldName: fieldName,\n fieldValues: fieldValues,\n });\n }));\n}\nfunction encloser(value, delimiter) {\n var enclosingTester = new RegExp(\"\".concat(delimiter, \"|\\\"|\\n\"));\n var enclosingCharacter = enclosingTester.test(value) ? '\"' : '';\n var escaped = value.replace(/\"/g, '\"\"');\n return \"\".concat(enclosingCharacter).concat(escaped).concat(enclosingCharacter);\n}\nvar defaultCreateCSVDataOption = { beforeTableEncode: function (i) { return i; }, delimiter: ',' };\nexport function createCSVData(data, options) {\n if (options === void 0) { options = {}; }\n var _a = __assign(__assign({}, defaultCreateCSVDataOption), options), beforeTableEncode = _a.beforeTableEncode, delimiter = _a.delimiter;\n if (!data.length)\n return '';\n var tableMap = _createTableMap(data);\n var tableEntries = _createTableEntries(tableMap, beforeTableEncode);\n var head = tableEntries.map(function (_a) {\n var fieldName = _a.fieldName;\n return fieldName;\n }).join(delimiter) + '\\r\\n';\n var columns = tableEntries.map(function (_a) {\n var fieldValues = _a.fieldValues;\n return fieldValues;\n })\n .map(function (column) { return column.map(function (value) { return encloser(value, delimiter); }); });\n var rows = columns.reduce(function (mergedColumn, column) { return mergedColumn.map(function (value, rowIndex) { return \"\".concat(value).concat(delimiter).concat(column[rowIndex]); }); });\n return head + rows.join('\\r\\n');\n}\nexport function _renderTableHTMLText(data, beforeTableEncode) {\n assert(data.length > 0);\n var tableMap = _createTableMap(data);\n var tableEntries = _createTableEntries(tableMap, beforeTableEncode);\n var head = tableEntries.map(function (_a) {\n var fieldName = _a.fieldName;\n return fieldName;\n })\n .join('
\".concat(head, \" |
---|