{"version":3,"file":"ModifyUpload.svelte_svelte_type_style_lang.e946db2d.js","sources":["../../../../ui/packages/upload/src/utils.ts"],"sourcesContent":["import type { FileData } from \"./types\";\n\nexport function normalise_file(\n\tfile: string | FileData | null,\n\troot: string,\n\troot_url: string | null\n): FileData | null;\nexport function normalise_file(\n\tfile: Array<FileData> | FileData | null,\n\troot: string,\n\troot_url: string | null\n): Array<FileData> | FileData | null;\n\nexport function normalise_file(\n\tfile: string | FileData | Array<FileData> | null,\n\troot: string,\n\troot_url: string | null\n): FileData | Array<FileData> | null {\n\tif (file == null) return null;\n\tif (typeof file === \"string\") {\n\t\treturn {\n\t\t\tname: \"file_data\",\n\t\t\tdata: file\n\t\t};\n\t} else if (Array.isArray(file)) {\n\t\tfor (const x of file) {\n\t\t\tnormalise_file(x, root, root_url);\n\t\t}\n\t} else if (file.is_file) {\n\t\tif (root_url == null) {\n\t\t\tfile.data = root + \"/file=\" + file.name;\n\t\t} else {\n\t\t\tfile.data = \"/proxy=\" + root_url + \"/file=\" + file.name;\n\t\t}\n\t}\n\treturn file;\n}\n\nexport const blobToBase64 = (blob: File): Promise<string> => {\n\tconst reader = new FileReader();\n\treader.readAsDataURL(blob);\n\treturn new Promise((resolve) => {\n\t\treader.onloadend = () => {\n\t\t\tresolve(reader.result as string);\n\t\t};\n\t});\n};\n"],"names":[],"mappings":"WAcC,EACA,EACA,EACoC,IAChC,GAAQ,WAAa,SACrB,MAAO,IAAS,eACZ,CACN,KAAM,YACN,KAAM,MAEG,MAAM,QAAQ,CAAI,WACjB,KAAK,KACA,EAAG,EAAM,CAAQ,MAEvB,GAAK,UACX,GAAY,OACV,KAAO,EAAO,SAAW,EAAK,OAE9B,KAAO,UAAY,EAAW,SAAW,EAAK,YAG9C,EACR,MAEa,GAAe,AAAC,GAAgC,MACtD,GAAS,GAAI,qBACZ,cAAc,CAAI,EAClB,GAAI,SAAQ,AAAC,GAAY,GACxB,UAAY,IAAM,GAChB,EAAO,MAAgB,GAEhC,CACF"} |