import { useState as P, useCallback as e, useMemo as i, useEffect as b } from "../../external/.pnpm/preact@10.28.2/node_modules/preact/hooks/dist/hooks.module.js";
import { ButtonVariant as E } from "../../components/internal/Button/types.js";
import { CommitAction as t } from "./types.js";
import B from "../../core/Context/preact/useCoreContext.js";
import { EMPTY_OBJECT as Y } from "../../utils/value/constants.js";
import { boolOrFalse as N } from "../../utils/value/bool.js";
const x = ({
  applyDisabled: a,
  applyTitle: r,
  resetDisabled: u,
  resetTitle: A,
  onResetAction: s
} = Y) => {
  const { i18n: n } = B(), [m, o] = P(t.NONE), f = e(() => o(t.APPLY), [o]), l = e(() => {
    o(t.CLEAR), s && s();
  }, [o, s]), c = e(() => o(t.NONE), [o]), C = i(
    () => ({
      disabled: N(a),
      event: f,
      title: r?.trim() || n.get("common.actions.apply.labels.default"),
      variant: E.PRIMARY
    }),
    [n, f, a, r]
  ), p = i(
    () => ({
      disabled: N(u),
      event: l,
      title: A?.trim() || n.get("common.actions.reset.labels.default"),
      variant: E.SECONDARY
    }),
    [n, l, u, A]
  ), d = i(() => [C, p], [C, p]), O = i(() => m !== t.NONE, [m]);
  return b(() => {
    switch (m) {
      case t.APPLY:
      case t.CLEAR:
        c();
        break;
    }
  }, [m, c]), { commitAction: m, commitActionButtons: d, committing: O, resetCommitAction: c };
};
export {
  x as default
};
