// DEV File only
import App from "./src";
import testData from "./data-test.json";

declare const window: Window &
  typeof globalThis & { AddressWidget: typeof App };

const CardsCreationWidget: typeof App = App;
const openButton = document.getElementById("widget-test");

const onExit = () => {
  window.location.href = "https://staging-kfc-co.getduna.com/menu";
};

CardsCreationWidget.configure({
  checkoutConfig: {
    publicApiKey: testData.apiKey,
    env: testData.env as any,
  },
  onExit: onExit,
});

if (openButton) {
  openButton.addEventListener("click", () => {
    CardsCreationWidget.show({
      target: "widget-container",
      mode: "modal",
      modalParams: {
        desktop: { size: "container", modalPosition: "center" },
        mobile: { size: "container", modalPosition: "center" },
      },
    });
  });
}
