import { a$ as k, r as d, y as $, aL as X, v as g, b as f, aN as O, aM as q, j as a, c as p, aI as _, aJ as J, b0 as Q, aK as K, ap as Y, aB as Z, aQ as u, al as G, ai as x, aE as ee, aR as m, E as y, _ as b } from "./index-6wLGsgHc.js";
import { d as te } from "./FormClearHelper-Dgu5Halt-DyRdP6JG.js";
import { C as ie, q as se, E as le, S as ae, f as z, A as w, P as re, _ as oe } from "./FileHelper-BCkX4r3T-CuiY0ZEU.js";
import { q as ne, U as de } from "./ProgressBar-bzD0ionS-BU2taYKp.js";
import { o as pe } from "./Hooks-BLb3umpI-DYKqkUO8.js";
import { t as F } from "./UploadFileInfo-B5SttewO-Cfj4jyqp.js";
var U = /* @__PURE__ */ d.forwardRef(function(e, s) {
  var t = {
    fill: "currentColor",
    xmlns: "http://www.w3.org/2000/svg"
  };
  return /* @__PURE__ */ d.createElement(y, b({
    iconAttrs: t,
    iconVerticalAlign: "middle",
    iconViewBox: "0 0 24 24"
  }, e, {
    ref: s
  }), /* @__PURE__ */ d.createElement("path", {
    fill: "none",
    d: "M0 0h24v24H0V0z"
  }), /* @__PURE__ */ d.createElement("path", {
    d: "M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12l4.58-4.59z"
  }));
});
U.displayName = "ChevronLeft";
var v = /* @__PURE__ */ d.forwardRef(function(e, s) {
  var t = {
    fill: "currentColor",
    xmlns: "http://www.w3.org/2000/svg"
  };
  return /* @__PURE__ */ d.createElement(y, b({
    iconAttrs: t,
    iconVerticalAlign: "middle",
    iconViewBox: "0 0 24 24"
  }, e, {
    ref: s
  }), /* @__PURE__ */ d.createElement("path", {
    fill: "none",
    d: "M0 0h24v24H0V0z"
  }), /* @__PURE__ */ d.createElement("path", {
    d: "M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6-6-6z"
  }));
});
v.displayName = "ChevronRight";
var I = /* @__PURE__ */ d.forwardRef(function(e, s) {
  var t = {
    fill: "currentColor",
    xmlns: "http://www.w3.org/2000/svg"
  };
  return /* @__PURE__ */ d.createElement(y, b({
    iconAttrs: t,
    iconVerticalAlign: "middle",
    iconViewBox: "0 0 24 24"
  }, e, {
    ref: s
  }), /* @__PURE__ */ d.createElement("path", {
    fill: "none",
    d: "M0 0h24v24H0V0z"
  }), /* @__PURE__ */ d.createElement("path", {
    d: "M19.35 10.04A7.49 7.49 0 0012 4C9.11 4 6.6 5.64 5.35 8.04A5.994 5.994 0 000 14c0 3.31 2.69 6 6 6h13c2.76 0 5-2.24 5-5 0-2.64-2.05-4.78-4.65-4.96zM19 18H6c-2.21 0-4-1.79-4-4 0-2.05 1.53-3.76 3.56-3.97l1.07-.11.5-.95A5.469 5.469 0 0112 6c2.62 0 4.88 1.86 5.39 4.43l.3 1.5 1.53.11A2.98 2.98 0 0122 15c0 1.65-1.35 3-3 3zM8 13h2.55v3h2.9v-3H16l-4-4z"
  }));
});
I.displayName = "CloudUpload";
var C = /* @__PURE__ */ d.forwardRef(function(e, s) {
  var t = {
    fill: "currentColor",
    xmlns: "http://www.w3.org/2000/svg"
  };
  return /* @__PURE__ */ d.createElement(y, b({
    iconAttrs: t,
    iconVerticalAlign: "middle",
    iconViewBox: "0 0 24 24"
  }, e, {
    ref: s
  }), /* @__PURE__ */ d.createElement("path", {
    d: "M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z"
  }));
});
C.displayName = "Error";
const B = /* @__PURE__ */ p("section", {
  target: "e1b2p2ww17"
})(({
  isDisabled: e,
  theme: s
}) => ({
  display: "flex",
  gap: s.spacing.lg,
  alignItems: "center",
  padding: s.spacing.lg,
  backgroundColor: s.colors.secondaryBg,
  borderRadius: s.radii.default,
  border: s.colors.widgetBorderColor ? `${s.sizes.borderWidth} solid ${s.colors.widgetBorderColor}` : void 0,
  height: s.sizes.largestElementHeight,
  ":focus": {
    outline: "none"
  },
  ":focus-visible": {
    boxShadow: `0 0 0 1px ${s.colors.primary}`
  },
  cursor: e ? "not-allowed" : "pointer"
}), ""), ce = /* @__PURE__ */ p("div", {
  target: "e1b2p2ww16"
})(({
  theme: e
}) => ({
  marginRight: "auto",
  alignItems: "center",
  display: "flex",
  gap: e.spacing.lg,
  // Ensure flex children can shrink and allow text truncation
  minWidth: 0,
  width: "100%"
}), ""), M = /* @__PURE__ */ p("span", {
  target: "e1b2p2ww15"
})(({
  theme: e
}) => ({
  color: e.colors.darkenedBgMix100
}), ""), E = /* @__PURE__ */ p("span", {
  target: "e1b2p2ww14"
})(({
  theme: e,
  disabled: s
}) => ({
  color: s ? e.colors.fadedText40 : e.colors.bodyText
}), ""), he = /* @__PURE__ */ p("span", {
  target: "e1b2p2ww13"
})(({
  theme: e,
  disabled: s
}) => ({
  fontSize: e.fontSizes.sm,
  color: s ? e.colors.fadedText40 : e.colors.fadedText60,
  // Ellipsis requires a block formatting context and constrained width
  display: "block",
  textOverflow: "ellipsis",
  overflow: "hidden",
  whiteSpace: "nowrap",
  maxWidth: "100%"
}), ""), ge = /* @__PURE__ */ p("div", {
  target: "e1b2p2ww12"
})({
  name: "1s8jot1",
  styles: "display:flex;flex-direction:column;min-width:0;max-width:100%"
}), me = /* @__PURE__ */ p("span", {
  target: "e1b2p2ww11"
})({
  name: "1bmnxg7",
  styles: "white-space:nowrap"
}), D = /* @__PURE__ */ p("div", {
  target: "e1b2p2ww10"
})(({
  theme: e
}) => ({
  left: 0,
  right: 0,
  lineHeight: e.lineHeights.tight,
  paddingTop: e.spacing.md,
  paddingLeft: e.spacing.lg,
  paddingRight: e.spacing.lg
}), ""), fe = /* @__PURE__ */ p("ul", {
  target: "e1b2p2ww9"
})(({
  theme: e
}) => ({
  listStyleType: "none",
  margin: e.spacing.none,
  padding: e.spacing.none
}), ""), L = /* @__PURE__ */ p("li", {
  target: "e1b2p2ww8"
})(({
  theme: e
}) => ({
  margin: e.spacing.none,
  padding: e.spacing.none
}), ""), A = /* @__PURE__ */ p("div", {
  target: "e1b2p2ww7"
})(({
  theme: e
}) => ({
  display: "flex",
  alignItems: "baseline",
  flex: 1,
  paddingLeft: e.spacing.lg,
  overflow: "hidden"
}), ""), V = /* @__PURE__ */ p("div", {
  target: "e1b2p2ww6"
})(({
  theme: e,
  disabled: s
}) => ({
  marginRight: e.spacing.sm,
  marginBottom: e.spacing.twoXS,
  overflow: "hidden",
  textOverflow: "ellipsis",
  whiteSpace: "nowrap",
  color: s ? e.colors.fadedText40 : e.colors.bodyText
}), ""), R = /* @__PURE__ */ p("div", {
  target: "e1b2p2ww5"
})(({
  theme: e
}) => ({
  display: "flex",
  alignItems: "center",
  marginBottom: e.spacing.twoXS
}), ""), ue = /* @__PURE__ */ p("span", {
  target: "e1b2p2ww4"
})(({
  theme: e
}) => ({
  marginRight: e.spacing.twoXS
}), ""), xe = /* @__PURE__ */ p("div", {
  target: "e1b2p2ww3"
})(({
  theme: e,
  disabled: s
}) => ({
  display: "flex",
  padding: e.spacing.twoXS,
  color: s ? e.colors.fadedText40 : e.colors.darkenedBgMix100
}), ""), T = /* @__PURE__ */ p("small", {
  target: "e1b2p2ww2"
})(({
  theme: e
}) => ({
  color: e.colors.redTextColor,
  fontSize: e.fontSizes.sm,
  height: e.fontSizes.sm,
  lineHeight: e.fontSizes.sm,
  display: "flex",
  alignItems: "center",
  whiteSpace: "nowrap"
}), ""), N = /* @__PURE__ */ p("span", {
  target: "e1b2p2ww1"
})({
  name: "0",
  styles: ""
}), we = (e) => ({
  // eslint-disable-next-line @typescript-eslint/no-explicit-any -- TODO: Replace 'any' with a more specific type.
  [B]: {
    display: "flex",
    flexDirection: "column",
    alignItems: "flex-start",
    height: "auto",
    gap: e.spacing.sm
  },
  // eslint-disable-next-line @typescript-eslint/no-explicit-any -- TODO: Replace 'any' with a more specific type.
  [M]: {
    display: "none"
  },
  // eslint-disable-next-line @typescript-eslint/no-explicit-any -- TODO: Replace 'any' with a more specific type.
  [E]: {
    marginBottom: e.spacing.twoXS
  },
  // eslint-disable-next-line @typescript-eslint/no-explicit-any -- TODO: Replace 'any' with a more specific type.
  [D]: {
    paddingRight: e.spacing.lg
  },
  // eslint-disable-next-line @typescript-eslint/no-explicit-any -- TODO: Replace 'any' with a more specific type.
  [R]: {
    maxWidth: "inherit",
    flex: 1,
    alignItems: "flex-start",
    marginBottom: e.spacing.sm
  },
  // eslint-disable-next-line @typescript-eslint/no-explicit-any -- TODO: Replace 'any' with a more specific type.
  [V]: {
    width: e.sizes.full
  },
  // eslint-disable-next-line @typescript-eslint/no-explicit-any -- TODO: Replace 'any' with a more specific type.
  [A]: {
    flexDirection: "column"
  },
  // eslint-disable-next-line @typescript-eslint/no-explicit-any -- TODO: Replace 'any' with a more specific type.
  [T]: {
    height: "auto",
    whiteSpace: "initial"
  },
  // eslint-disable-next-line @typescript-eslint/no-explicit-any -- TODO: Replace 'any' with a more specific type.
  [N]: {
    display: "none"
  },
  // eslint-disable-next-line @typescript-eslint/no-explicit-any -- TODO: Replace 'any' with a more specific type.
  [L]: {
    margin: e.spacing.none,
    padding: e.spacing.none
  }
}), ye = /* @__PURE__ */ p("div", {
  target: "e1b2p2ww0"
})(({
  theme: e,
  width: s
}) => {
  if (s < Z("23rem")) return we(e);
}, ""), be = ({
  multiple: e,
  acceptedExtensions: s,
  maxSizeBytes: t,
  acceptDirectory: i = !1,
  disabled: l
}) => {
  const o = () => i ? "directories" : e ? "files" : "file", r = () => s.length ? ` • ${s.map((c) => c.replace(/^\./, "").toUpperCase()).join(", ")}` : null, n = () => `Limit ${z(t, w.Byte, 0)} per file`;
  return /* @__PURE__ */ a.jsxs(ce, {
    "data-testid": "stFileUploaderDropzoneInstructions",
    children: [/* @__PURE__ */ a.jsx(M, {
      children: /* @__PURE__ */ a.jsx(m, {
        content: I,
        size: "threeXL"
      })
    }), /* @__PURE__ */ a.jsxs(ge, {
      children: [/* @__PURE__ */ a.jsxs(E, {
        disabled: l,
        children: ["Drag and drop ", o(), " here"]
      }), /* @__PURE__ */ a.jsxs(he, {
        disabled: l,
        children: [n(), r()]
      })]
    })]
  });
}, Se = d.memo(be), Fe = ({
  onDrop: e,
  multiple: s,
  acceptedExtensions: t,
  maxSizeBytes: i,
  disabled: l,
  label: o,
  acceptDirectory: r = !1
}) => /* @__PURE__ */ a.jsx(le, {
  onDrop: e,
  multiple: s,
  accept: ae(t),
  maxSize: i,
  disabled: l,
  useFsAccessApi: !1,
  children: ({
    getRootProps: n,
    getInputProps: c
  }) => {
    const h = c({
      multiple: s || !!r
    });
    return /* @__PURE__ */ a.jsxs(B, {
      ...n(),
      "data-testid": "stFileUploaderDropzone",
      isDisabled: l,
      "aria-label": o,
      "aria-disabled": l,
      children: [/* @__PURE__ */ a.jsx("input", {
        "data-testid": "stFileUploaderDropzoneInput",
        ...h,
        ...r && {
          webkitdirectory: ""
        }
      }), /* @__PURE__ */ a.jsx(Se, {
        multiple: s,
        acceptedExtensions: t,
        maxSizeBytes: i,
        acceptDirectory: r,
        disabled: l
      }), /* @__PURE__ */ a.jsx(me, {
        children: /* @__PURE__ */ a.jsx(u, {
          kind: x.SECONDARY,
          disabled: l,
          size: G.SMALL,
          children: r ? "Browse directories" : "Browse files"
        })
      })]
    });
  }
}), je = d.memo(Fe), W = /* @__PURE__ */ p("small", {
  target: "e1bju1570"
})(({
  kind: e,
  disabled: s,
  theme: t
}) => {
  const {
    redTextColor: i,
    fadedText60: l,
    fadedText40: o
  } = t.colors;
  let r = l;
  return s && (r = o), e === "danger" && (r = i), {
    color: r,
    fontSize: t.fontSizes.sm,
    lineHeight: t.lineHeights.tight
  };
}, ""), ze = ({
  fileInfo: e,
  disabled: s
}) => e.status.type === "uploading" ? /* @__PURE__ */ a.jsx(ne, {
  value: e.status.progress,
  size: de.SMALL
}) : e.status.type === "error" ? /* @__PURE__ */ a.jsxs(T, {
  children: [/* @__PURE__ */ a.jsx(ue, {
    "data-testid": "stFileUploaderFileErrorMessage",
    children: e.status.errorMessage
  }), /* @__PURE__ */ a.jsx(N, {
    children: /* @__PURE__ */ a.jsx(m, {
      content: C,
      size: "lg"
    })
  })]
}) : e.status.type === "uploaded" ? /* @__PURE__ */ a.jsx(W, {
  disabled: s,
  children: z(e.size, w.Byte)
}) : null, Ue = ({
  fileInfo: e,
  onDelete: s,
  disabled: t
}) => /* @__PURE__ */ a.jsxs(R, {
  className: "stFileUploaderFile",
  "data-testid": "stFileUploaderFile",
  children: [/* @__PURE__ */ a.jsx(xe, {
    disabled: t,
    children: /* @__PURE__ */ a.jsx(m, {
      content: re,
      size: "twoXL"
    })
  }), /* @__PURE__ */ a.jsxs(A, {
    className: "stFileUploaderFileData",
    children: [/* @__PURE__ */ a.jsx(V, {
      className: "stFileUploaderFileName",
      "data-testid": "stFileUploaderFileName",
      title: e.name,
      disabled: t,
      children: e.name
    }), /* @__PURE__ */ a.jsx(ze, {
      fileInfo: e,
      disabled: t
    })]
  }), /* @__PURE__ */ a.jsx("div", {
    "data-testid": "stFileUploaderDeleteBtn",
    children: /* @__PURE__ */ a.jsx(u, {
      onClick: () => s(e.id),
      kind: x.MINIMAL,
      disabled: t,
      "aria-label": `Remove ${e.name}`,
      children: /* @__PURE__ */ a.jsx(m, {
        content: oe,
        size: "lg"
      })
    })
  })]
}), ve = d.memo(Ue), Ie = /* @__PURE__ */ p("div", {
  target: "e1nlpozb1"
})(({
  theme: e
}) => ({
  display: "flex",
  alignItems: "center",
  justifyContent: "space-between",
  paddingBottom: e.spacing.twoXS,
  marginBottom: e.spacing.twoXS
}), ""), Ce = /* @__PURE__ */ p("div", {
  target: "e1nlpozb0"
})(({
  theme: e
}) => ({
  display: "flex",
  alignItems: "center",
  justifyContent: "center",
  color: e.colors.fadedText40
}), ""), Be = ({
  currentPage: e,
  totalPages: s,
  onNext: t,
  onPrevious: i
}) => /* @__PURE__ */ a.jsxs(Ie, {
  "data-testid": "stFileUploaderPagination",
  children: [/* @__PURE__ */ a.jsx(W, {
    children: `Showing page ${e} of ${s}`
  }), /* @__PURE__ */ a.jsxs(Ce, {
    children: [/* @__PURE__ */ a.jsx(u, {
      onClick: i,
      kind: x.MINIMAL,
      children: /* @__PURE__ */ a.jsx(m, {
        content: U,
        size: "xl"
      })
    }), /* @__PURE__ */ a.jsx(u, {
      onClick: t,
      kind: x.MINIMAL,
      children: /* @__PURE__ */ a.jsx(m, {
        content: v,
        size: "xl"
      })
    })]
  })]
}), Me = d.memo(Be), j = (e, s) => Math.ceil(e.length / s), Ee = (e) => ee(({
  pageSize: s,
  items: t,
  resetOnAdd: i,
  ...l
}) => {
  const [o, r] = d.useState(0), [n, c] = d.useState(() => j(t, s)), h = pe(t);
  d.useEffect(() => {
    h && h.length !== t.length && c(j(t, s)), h && h.length < t.length ? i && r(0) : o + 1 >= n && r(n - 1);
  }, [t, o, s, h, i, n]);
  const S = () => {
    r(Math.min(o + 1, n - 1));
  }, H = () => {
    r(Math.max(0, o - 1));
  }, P = t.slice(o * s, o * s + s);
  return /* @__PURE__ */ a.jsxs(a.Fragment, {
    children: [/* @__PURE__ */ a.jsx(e, {
      items: P,
      ...l
    }), t.length > s ? /* @__PURE__ */ a.jsx(Me, {
      pageSize: s,
      totalPages: n,
      currentPage: o + 1,
      onNext: S,
      onPrevious: H
    }) : null]
  });
}, e), De = ({
  items: e,
  onDelete: s,
  disabled: t
}) => /* @__PURE__ */ a.jsx(fe, {
  children: e.map((i) => /* @__PURE__ */ a.jsx(L, {
    children: /* @__PURE__ */ a.jsx(ve, {
      fileInfo: i,
      onDelete: s,
      disabled: t
    })
  }, i.id))
}), Le = Ee(De), Ae = (e) => /* @__PURE__ */ a.jsx(D, {
  children: /* @__PURE__ */ a.jsx(Le, {
    ...e
  })
}), Ve = d.memo(Ae);
class Re extends d.PureComponent {
  constructor(s) {
    super(s), this.formClearHelper = new te(), this.localFileIdCounter = 1, this.forceUpdatingStatus = !1, this.componentDidUpdate = () => {
      if (this.status !== "ready") return;
      const t = this.createWidgetValue(), {
        element: i,
        widgetMgr: l,
        fragmentId: o
      } = this.props, r = l.getFileUploaderStateValue(i);
      $(t, r) || l.setFileUploaderStateValue(i, t, {
        fromUi: !0
      }, o);
    }, this.isFileTypeAllowed = (t) => {
      const {
        element: i
      } = this.props, {
        type: l
      } = i;
      if (!l || l.length === 0) return !0;
      const o = t.name.toLowerCase();
      return l.some((r) => o.endsWith(r.toLowerCase()));
    }, this.filterDirectoryFiles = (t) => {
      const i = [], l = [];
      return t.forEach((o) => {
        this.isFileTypeAllowed(o) ? i.push(o) : l.push({
          file: o,
          errors: [{
            code: "file-invalid-type",
            message: `${o.type} files are not allowed.`
          }]
        });
      }), {
        accepted: i,
        rejected: l
      };
    }, this.dropHandler = (t, i) => {
      const {
        element: l
      } = this.props, {
        multipleFiles: o
      } = l;
      if (l.acceptDirectory && t.length > 0) {
        const {
          accepted: r,
          rejected: n
        } = this.filterDirectoryFiles(t);
        t = r, i = [...i, ...n];
      }
      if (!o && t.length === 0 && i.length > 1) {
        const r = i.findIndex((n) => n.errors.length === 1 && n.errors[0].code === "too-many-files");
        r >= 0 && (t.push(i[r].file), i.splice(r, 1));
      }
      if (this.props.uploadClient.fetchFileURLs(t).then((r) => {
        if (!o && t.length > 0) {
          const n = this.state.files.find((c) => c.status.type !== "error");
          n && (this.forceUpdatingStatus = !0, this.deleteFile(n.id), this.forceUpdatingStatus = !1);
        }
        X(r, t).forEach(([n, c]) => {
          this.uploadFile(n, c);
        });
      }).catch((r) => {
        this.addFiles(t.map((n) => new F(n.name, n.size, this.nextLocalFileId(), {
          type: "error",
          errorMessage: r
        })));
      }), i.length > 0) {
        const r = i.map((n) => ie(n, this.nextLocalFileId(), this.maxUploadSizeInBytes));
        this.addFiles(r);
      }
    }, this.uploadFile = (t, i) => {
      const l = new AbortController(), o = i.webkitRelativePath || i.name, r = new F(o, i.size, this.nextLocalFileId(), {
        type: "uploading",
        abortController: l,
        progress: 1
      });
      this.addFile(r), this.props.uploadClient.uploadFile(this.props.element, t.uploadUrl, i, (n) => this.onUploadProgress(n, r.id), l.signal).then(() => this.onUploadComplete(r.id, t)).catch((n) => {
        n instanceof DOMException && n.name === "AbortError" || this.updateFile(r.id, r.setStatus({
          type: "error",
          errorMessage: n ? n.toString() : "Unknown error"
        }));
      });
    }, this.onUploadComplete = (t, i) => {
      const l = this.getFile(t);
      g(l) || l.status.type !== "uploading" || this.updateFile(l.id, l.setStatus({
        type: "uploaded",
        fileId: i.fileId,
        fileUrls: i
      }));
    }, this.deleteFile = (t) => {
      if (this.props.disabled) return;
      const i = this.getFile(t);
      g(i) || (i.status.type === "uploading" && i.status.abortController.abort(), i.status.type === "uploaded" && i.status.fileUrls.deleteUrl && this.props.uploadClient.deleteFile(i.status.fileUrls.deleteUrl), this.removeFile(t));
    }, this.addFile = (t) => {
      f.flushSync(() => {
        this.setState((i) => ({
          files: [...i.files, t]
        }));
      });
    }, this.addFiles = (t) => {
      f.flushSync(() => {
        this.setState((i) => ({
          files: [...i.files, ...t]
        }));
      });
    }, this.removeFile = (t) => {
      f.flushSync(() => {
        this.setState((i) => ({
          files: i.files.filter((l) => l.id !== t)
        }));
      });
    }, this.getFile = (t) => this.state.files.find((i) => i.id === t), this.updateFile = (t, i) => {
      f.flushSync(() => {
        this.setState((l) => ({
          files: l.files.map((o) => o.id === t ? i : o)
        }));
      });
    }, this.onUploadProgress = (t, i) => {
      const l = this.getFile(i);
      if (g(l) || l.status.type !== "uploading") return;
      const o = Math.round(t.loaded * 100 / t.total);
      l.status.progress !== o && this.updateFile(i, l.setStatus({
        type: "uploading",
        abortController: l.status.abortController,
        progress: o
      }));
    }, this.onFormCleared = () => {
      f.flushSync(() => {
        this.setState({
          files: []
        }, () => {
          const t = this.createWidgetValue();
          if (g(t)) return;
          const {
            widgetMgr: i,
            element: l,
            fragmentId: o
          } = this.props;
          i.setFileUploaderStateValue(l, t, {
            fromUi: !0
          }, o);
        });
      });
    }, this.state = this.initialValue;
  }
  get initialValue() {
    const s = {
      files: []
    }, {
      widgetMgr: t,
      element: i
    } = this.props, l = t.getFileUploaderStateValue(i);
    if (g(l)) return s;
    const {
      uploadedFileInfo: o
    } = l;
    return g(o) || o.length === 0 ? s : {
      files: o.map((r) => {
        const n = r.name, c = r.size, h = r.fileId, S = r.fileUrls;
        return new F(n, c, this.nextLocalFileId(), {
          type: "uploaded",
          fileId: h,
          fileUrls: S
        });
      })
    };
  }
  componentWillUnmount() {
    this.formClearHelper.disconnect();
  }
  /**
   * Return this.props.element.maxUploadSizeMb, converted to bytes.
   */
  get maxUploadSizeInBytes() {
    const s = this.props.element.maxUploadSizeMb;
    return se(s, w.Megabyte, w.Byte);
  }
  /**
   * Return the FileUploader's current status, which is derived from
   * its state.
   */
  get status() {
    const s = (t) => t.status.type === "uploading";
    return this.state.files.some(s) || this.forceUpdatingStatus ? "updating" : "ready";
  }
  componentDidMount() {
    const s = this.createWidgetValue(), {
      element: t,
      widgetMgr: i,
      fragmentId: l
    } = this.props;
    i.getFileUploaderStateValue(t) === void 0 && i.setFileUploaderStateValue(t, s, {
      fromUi: !1
    }, l);
  }
  createWidgetValue() {
    const s = this.state.files.filter((t) => t.status.type === "uploaded").map((t) => {
      const {
        name: i,
        size: l,
        status: o
      } = t, {
        fileId: r,
        fileUrls: n
      } = o;
      return new O({
        fileId: r,
        fileUrls: n,
        name: i,
        size: l
      });
    });
    return new q({
      uploadedFileInfo: s
    });
  }
  render() {
    const {
      files: s
    } = this.state, {
      element: t,
      disabled: i,
      widgetMgr: l,
      width: o
    } = this.props, r = t.type;
    this.formClearHelper.manageFormClearListener(l, t.formId, this.onFormCleared);
    const n = s.slice().reverse();
    return /* @__PURE__ */ a.jsxs(ye, {
      className: "stFileUploader",
      "data-testid": "stFileUploader",
      width: o,
      children: [/* @__PURE__ */ a.jsx(_, {
        label: t.label,
        disabled: i,
        labelVisibility: J(t.labelVisibility?.value),
        children: t.help && /* @__PURE__ */ a.jsx(Q, {
          children: /* @__PURE__ */ a.jsx(K, {
            content: t.help,
            placement: Y.TOP_RIGHT
          })
        })
      }), /* @__PURE__ */ a.jsx(je, {
        onDrop: this.dropHandler,
        multiple: t.multipleFiles,
        acceptedExtensions: r,
        maxSizeBytes: this.maxUploadSizeInBytes,
        label: t.label,
        disabled: i,
        acceptDirectory: !!t.acceptDirectory
      }), n.length > 0 && /* @__PURE__ */ a.jsx(Ve, {
        items: n,
        pageSize: 3,
        onDelete: this.deleteFile,
        resetOnAdd: !0,
        disabled: i
      })]
    });
  }
  nextLocalFileId() {
    return this.localFileIdCounter++;
  }
}
const $e = k(d.memo(Re));
export {
  $e as default
};
//# sourceMappingURL=index-Bo7cn_f6-B4aTnQOb.js.map
