import { useMemo as c } from "../../../../../../external/.pnpm/preact@10.28.2/node_modules/preact/hooks/dist/hooks.module.js";
import { useWizardFormContext as A } from "../../../../../../hooks/form/wizard/WizardFormContext.js";
const b = [
  "billingAddress.street",
  "billingAddress.houseNumberOrName",
  "billingAddress.postalCode",
  "billingAddress.city",
  "billingAddress.country"
], m = [
  "deliveryAddress.street",
  "deliveryAddress.houseNumberOrName",
  "deliveryAddress.postalCode",
  "deliveryAddress.city",
  "deliveryAddress.country"
], g = () => {
  const { fieldsConfig: t } = A();
  return c(() => {
    const n = (y) => {
      const l = y.map((e) => t[e]), r = l.filter((e) => e?.visible), u = l.filter((e) => e?.readOnly);
      return {
        isVisible: r.length > 0,
        isRequired: l.some((e) => e?.required),
        allFieldsReadOnly: r.length > 0 && r.every((e) => e?.readOnly),
        hasAnyReadOnlyField: u.length > 0
      };
    }, i = n(b), d = n(m);
    if (!i.isVisible || !d.isVisible)
      return { isSameAddressCopyEnabled: !1, showBillingFirst: !1 };
    const s = i.isRequired && !d.isRequired, o = s ? d : i, a = s ? i : d;
    return o.allFieldsReadOnly && a.allFieldsReadOnly ? { isSameAddressCopyEnabled: !1, showBillingFirst: s } : o.hasAnyReadOnlyField ? { isSameAddressCopyEnabled: !1, showBillingFirst: s } : { isSameAddressCopyEnabled: !0, showBillingFirst: s };
  }, [t]);
};
export {
  g as useSameAddressCheckbox
};
