{"version":3,"file":"file.mjs","names":[],"sources":["../../src/file.ts"],"sourcesContent":["/**\n * Read an expected JSON type File.\n *\n * Probably paired with:\n *  <input type='file' accept='application/JSON' ... />\n */\nexport function readJSONFile(file: File): Promise<unknown> {\n  return new Promise((resolve, reject) => {\n    const reader = new FileReader();\n    reader.addEventListener('load', function () {\n      const result = JSON.parse(reader.result as string);\n      resolve(result);\n    });\n\n    reader.addEventListener('error', reject);\n    reader.readAsText(file);\n  });\n}\n\nconst MimeTypeToExtensionMap = Object.freeze({\n  'image/png': 'png',\n  'image/jpeg': 'jpg',\n  'image/gif': 'gif',\n  'image/webp': 'webp',\n  'image/x-icon': 'ico',\n  'image/vnd.microsoft.icon': 'ico',\n} as const);\n\nexport type SupportedMimeType = keyof typeof MimeTypeToExtensionMap;\n\nexport const extension = (mimeType: SupportedMimeType): string => {\n  return MimeTypeToExtensionMap[mimeType];\n};\n"],"mappings":";;;;;;;AAMA,SAAgB,aAAa,MAA8B;AACzD,QAAO,IAAI,SAAS,SAAS,WAAW;EACtC,MAAM,SAAS,IAAI,YAAY;AAC/B,SAAO,iBAAiB,QAAQ,WAAY;AAE1C,WADe,KAAK,MAAM,OAAO,OAAiB,CACnC;IACf;AAEF,SAAO,iBAAiB,SAAS,OAAO;AACxC,SAAO,WAAW,KAAK;GACvB;;AAGJ,MAAM,yBAAyB,OAAO,OAAO;CAC3C,aAAa;CACb,cAAc;CACd,aAAa;CACb,cAAc;CACd,gBAAgB;CAChB,4BAA4B;CAC7B,CAAU;AAIX,MAAa,aAAa,aAAwC;AAChE,QAAO,uBAAuB"}