import { useEnvironment as S, useModuleDictionary as d } from "@m4l/core";
import { useFormatter as v } from "@m4l/graphics";
import { useMemo as D } from "react";
import { useDynamicSortStore as E } from "../../store/useDynamicSortStore.js";
import { SORT_ICONS as m } from "../../icons.js";
import { fieldFactory as $ } from "../FieldTypes/fieldFactory.js";
function b(o) {
  const { host_static_assets: e, environment_assets: t } = S(), { getLabel: r } = d(), i = v(), { hidePopoverSort: n, removeSort: a, showPopoverSortForEdit: c } = E(
    (s) => s.actions
  ), f = o.operator === "asc" ? `${e}/${t}/${m.ASCENDING}` : `${e}/${t}/${m.DESCENDING}`, l = D(() => $().getLabels(o, r, i, o.field), [o, r, i]);
  function u() {
    n(!1), a(o.id);
  }
  function p(s) {
    n(!1), setTimeout(() => c(o), 10);
  }
  return {
    onDelete: u,
    onEditSort: p,
    iconFieldUrl: o.field?.urlIcon,
    labels: l,
    iconSort: f
  };
}
export {
  b as default
};
