import { getDownloadURL, getStorage, ref, uploadBytes } from "firebase/storage";
import getExtension from "./getExtension";
export default async function uploadFiles(app, files, options) {
  const results = [];
  const storage = getStorage(app);
  for (const file of files) {
    try {
      const storageRef = ref(storage, `/${(options === null || options === void 0 ? void 0 : options.path) || ""}${new Date().toISOString()}.${await getExtension(file === null || file === void 0 ? void 0 : file.name)}`);
      const upload = await uploadBytes(storageRef, file);
      const url = await getDownloadURL(upload.ref);
      results.push({
        success: true,
        name: file === null || file === void 0 ? void 0 : file.name,
        url,
      });
    }
    catch (error) {
      results.push({ succes: false, error });
    }
  }
  return results;
}
//# sourceMappingURL=uploadFiles.js.map