import { useState as g, useCallback as p } from "react";
import { useHandleAction as f } from "../../internal/useHandleAction.js";
import { useShopActions as d } from "../../internal/useShopActions.js";
import { useImageUpload as I } from "../storage/useImageUpload.js";
const U = () => {
  const { createContent: t } = d(), { uploadImage: a } = I(), [r, o] = g(!1), i = p(
    async (s) => {
      o(!0);
      const { image: e, contentTitle: l, visibility: m } = s;
      if (!e.type)
        throw new Error("Unable to determine file type");
      if (!e.type.startsWith("image/"))
        throw new Error("Invalid file type: must be an image");
      const [c] = await a(e), n = c.imageUrl;
      if (!n)
        throw new Error("Image upload failed");
      const u = await t({
        title: l,
        imageUrl: n,
        visibility: m
      });
      return o(!1), u;
    },
    [t, a]
  );
  return {
    createImageContent: f(i),
    loading: r
  };
};
export {
  U as useCreateImageContent
};
//# sourceMappingURL=useCreateImageContent.js.map
