export const getLocalFile = async (accept?: string): Promise => (await open(accept, false))[0]; export const getLocalFiles = (accept?: string): Promise => open(accept, true) const open = (accept?: string, multiple?: boolean): Promise => new Promise((resolve, reject) => { const input = document.createElement("input"); input.type = "file"; if (accept) input.accept = accept; if (multiple) input.multiple = multiple; input.addEventListener("change", () => { resolve(Array.from(input.files ?? [])); }); input.addEventListener("error", reject); input.click(); });