"use client";
import { j as e } from "../../../node_modules/.pnpm/react@19.1.0/node_modules/react/jsx-runtime.mjs";
import { getETAStringFromMs as h } from "../../../node_modules/.pnpm/@hyperplay_utils@0.3.18/node_modules/@hyperplay/utils/dist/index.es.mjs";
import "react";
import { ReactComponent as w } from "../../assets/images/CloseButton.svg.mjs";
import o from "../Button/index.mjs";
import s from "./index.module.scss.mjs";
import { size as u } from "./utils.mjs";
const y = {
  play: "Play",
  pause: "Pause",
  resume: "Resume",
  cancel: "Cancel",
  downloading: "Downloading",
  of: "of"
};
function p(n) {
  const i = { ...y, ...n.i18n };
  let a = n.downloadSizeInBytes > 0 ? Math.round(n.downloadedInBytes / n.downloadSizeInBytes * 100) : 0;
  a > 100 && (a = 100);
  let r = a.toString(), c = n.estimatedCompletionTimeInMs;
  n.estimatedCompletionTimeInMs < 0 && (console.error("Estimated completion time was negative!"), c = 0);
  let d = n.downloadedInBytes;
  d < 0 && (console.error("Downloaded size was negative!"), d = 0);
  let t = n.downloadSizeInBytes;
  t < 0 && (console.error("Download size was negative!"), t = 0);
  let m = h(c);
  const j = u(d);
  let x = u(t);
  t === 0 && (m = "??", x = "??", r = "??");
  const C = {
    "--download-progress-bar-percentage": `${a}%`
  };
  function g(l) {
    if (l === "done")
      return /* @__PURE__ */ e.jsx(o, { type: "primary", size: "small", onClick: n.onPlayClick, children: /* @__PURE__ */ e.jsx("span", { children: i.play }) });
    if (l === "showOnlyCancel" || l === "inExtraction")
      return null;
    if (l === "inProgress")
      return /* @__PURE__ */ e.jsx(o, { type: "primary", size: "small", onClick: n.onPauseClick, children: /* @__PURE__ */ e.jsx("span", { children: i.pause }) });
    if (l === "paused")
      return /* @__PURE__ */ e.jsx(o, { type: "primary", size: "small", onClick: n.onStartClick, children: /* @__PURE__ */ e.jsx("span", { children: i.resume }) });
  }
  return /* @__PURE__ */ e.jsxs("div", { className: s.downloadToastContainer, children: [
    /* @__PURE__ */ e.jsxs("div", { className: s.topBar, children: [
      /* @__PURE__ */ e.jsx("div", { className: "title", children: n.statusText ?? i.downloading }),
      /* @__PURE__ */ e.jsx(
        "button",
        {
          onClick: n.onCloseClick,
          className: s.closeButton,
          children: /* @__PURE__ */ e.jsx(w, {})
        }
      )
    ] }),
    /* @__PURE__ */ e.jsxs("div", { className: s.contentContainer, children: [
      /* @__PURE__ */ e.jsx("div", { children: /* @__PURE__ */ e.jsx("img", { src: n.imgUrl, className: s.gameImage }) }),
      /* @__PURE__ */ e.jsxs("div", { className: s.detailsContainer, children: [
        /* @__PURE__ */ e.jsxs("div", { className: `eyebrow ${s.gameTitle}`, children: [
          n.gameTitle,
          /* @__PURE__ */ e.jsxs(
            "div",
            {
              className: `eyebrow ${s.percentCompletedText}`,
              children: [
                r,
                "%"
              ]
            }
          )
        ] }),
        /* @__PURE__ */ e.jsx(
          "div",
          {
            className: s.progressBar,
            style: C
          }
        ),
        /* @__PURE__ */ e.jsxs("div", { className: s.statusContainer, children: [
          /* @__PURE__ */ e.jsxs("div", { className: "caption-sm", children: [
            "ETA: ",
            m
          ] }),
          /* @__PURE__ */ e.jsxs("div", { className: s.downloadNumberContainer, children: [
            /* @__PURE__ */ e.jsx("div", { className: "caption-sm", children: j }),
            /* @__PURE__ */ e.jsx("div", { className: "caption-sm", children: ` ${i.of} ` }),
            /* @__PURE__ */ e.jsx("div", { className: "caption-sm", children: `${x}` })
          ] })
        ] })
      ] })
    ] }),
    /* @__PURE__ */ e.jsxs("div", { className: s.manageDownloadContainer, children: [
      n.status !== "done" ? /* @__PURE__ */ e.jsx(o, { type: "tertiary", size: "small", onClick: n.onCancelClick, children: /* @__PURE__ */ e.jsx("span", { children: i.cancel }) }) : null,
      g(n.status)
    ] })
  ] });
}
export {
  p as default,
  y as defaultI18n
};
//# sourceMappingURL=index.mjs.map
