import * as A from "fp-ts-esm/Array";
import { pipe } from "fp-ts-esm/function";
import * as M from "fp-ts-esm/Monoid";
import { fromNullable } from "fp-ts-esm/Option";
import { Node_Type } from "./../../ricos-schema/legacy/wix/rich_content/v1/index.js";
import { RICOS_NODE_TYPE_TO_DATA_FIELD } from "../consts.js";
import { extract } from "./extract.js";
const getText = (content) => extract(content.nodes ?? []).map(({ textData }) => textData?.text || "").get();
const getPluginData = (content, type) => extract(content.nodes ?? []).map((node) => node[RICOS_NODE_TYPE_TO_DATA_FIELD[type]]).get();
const MediaM = A.getMonoid();
const getMedia = (content) => M.concatAll(MediaM)([
  pipe(
    getPluginData(content, Node_Type.IMAGE),
    A.map(({ image }) => image),
    A.map(fromNullable),
    A.compact
  ),
  pipe(
    getPluginData(content, Node_Type.VIDEO),
    A.map(({ video }) => video),
    A.map(fromNullable),
    A.compact
  ),
  pipe(
    getPluginData(content, Node_Type.GALLERY),
    A.chain(({ items }) => items),
    A.map(({ image, video }) => image?.media || video?.media),
    A.map(fromNullable),
    A.compact
  )
]);
export {
  getMedia,
  getPluginData,
  getText
};
//# sourceMappingURL=extract-by-type.js.map
