import { EMPTY_ARRAY as T } from "../../../../../../utils/value/constants.js";
import { struct as l } from "../../../../../../utils/struct/main.js";
import { enumerable as d, getter as i } from "../../../../../../utils/struct/property.js";
import { isNullish as k, isFunction as b } from "../../../../../../utils/value/is.js";
import { isEmptyString as m } from "../../../../../../utils/value/string.js";
const A = () => {
  let [t, n, a, o] = T;
  const u = () => !!(t && t === o && a), g = () => !!(t && t === a && o);
  let e = null;
  const v = () => {
    u() && (n = t, t = a, c());
  }, N = () => {
    g() && (n = t, t = o, c());
  }, p = (r, s) => {
    const f = t;
    t = n = a = o = void 0, !m(r) && !m(s) && (a = r, o = s, t = f === a || f === o ? f : a, f !== t && c());
  }, w = (r) => {
    k(r) ? e = null : b(r) && e !== (e = r) && c();
  }, c = () => {
    if (m(t)) return;
    const r = n, s = t;
    n = void 0, e?.(
      l({
        from: i(() => r),
        to: i(() => s)
      })
    );
  };
  return l({
    backward: d(v),
    forward: d(N),
    canNavigateBackward: i(u),
    canNavigateForward: i(g),
    currentTransaction: i(() => t),
    onNavigation: { set: w },
    reset: d(p)
  });
};
export {
  A as createDuplexTransactionNavigator,
  A as default
};
