// +++ NEW FILE: assets/js/blocks-bani.js +++
// Registers the gateway with the WooCommerce Checkout Block.

(function () {
  // Blocks provides a global registry when loaded as a classic script.
  const registry = window.wc && window.wc.wcBlocksRegistry;
  const i18n = window.wp && window.wp.i18n;
  const __ = i18n ? i18n.__ : (s) => s;

  if (!registry || !registry.registerPaymentMethod) {
    // Blocks not present — nothing to do (classic checkout will handle it)
    return;
  }

  const data = window.baniBlocksData || {};
  if (data.isActive === false) {
    // Gateway not available (settings / currency / country), don't register.
    return;
  }

  registry.registerPaymentMethod({
    name: "bani", // must match gateway id and PHP class name property
    label: data.title || __("Bani", "bani-payments-for-woocommerce"),
    ariaLabel: data.title || "Bani",
    canMakePayment: () => true, // add capability tests if needed
    content: () => null, // redirect/hosted flow — no extra UI
    edit: () => null, // editor preview
    supports: {
      features: data.supports || [],
    },
  });
})();
