"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.ModuleCheckout = void 0;
var React = _interopRequireWildcard(require("react"));
var _reactNative = require("react-native");
var _context = require("../../context");
var _core = require("../../core");
var _buttons = require("../buttons");
var _layout = require("../layout");
var _logos = require("../logos");
var _skeleton = require("../skeleton");
var _typography = require("../typography");
var _ModuleStatic = require("./ModuleStatic");
var _PressableModuleBase = require("./PressableModuleBase");
var _jsxRuntime = require("react/jsx-runtime");
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
const ModuleCheckout = props => {
  const theme = (0, _context.useIOTheme)();
  const imageMargin = 12;
  if (props.isLoading) {
    return /*#__PURE__*/(0, _jsxRuntime.jsx)(ModuleCheckoutSkeleton, {
      loadingAccessibilityLabel: props.loadingAccessibilityLabel
    });
  }
  const {
    paymentLogo,
    image,
    title,
    subtitle,
    ctaText,
    onPress
  } = props;
  const paymentLogoComponent = paymentLogo && /*#__PURE__*/(0, _jsxRuntime.jsx)(_logos.LogoPayment, {
    name: paymentLogo
  });
  const imageComponent = image && /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Image, {
    source: image,
    style: styles.image,
    accessibilityIgnoresInvertColors: true
  });
  const ModuleBaseContent = () => /*#__PURE__*/(0, _jsxRuntime.jsxs)(_layout.HStack, {
    space: imageMargin,
    style: {
      alignItems: "center",
      flexShrink: 1
    },
    children: [paymentLogoComponent ?? imageComponent, /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
      style: {
        flexGrow: 1,
        flexShrink: 1
      },
      children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_typography.H6, {
        color: theme["textBody-default"],
        children: title
      }), subtitle && /*#__PURE__*/(0, _jsxRuntime.jsx)(_typography.BodySmall, {
        weight: "Regular",
        color: theme["textBody-tertiary"],
        children: subtitle
      })]
    })]
  });
  return ctaText ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_PressableModuleBase.PressableModuleBase, {
    onPress: onPress,
    accessibilityLabel: subtitle ? `${title}, ${subtitle}, ${ctaText}` : `${title}, ${ctaText}`,
    children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_layout.HStack, {
      space: 4,
      style: {
        alignItems: "center"
      },
      children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(ModuleBaseContent, {}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
        pointerEvents: "none",
        accessibilityElementsHidden: true,
        importantForAccessibility: "no-hide-descendants",
        children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_buttons.IOButton, {
          variant: "link",
          label: ctaText,
          onPress: () => null
        })
      })]
    })
  }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_ModuleStatic.ModuleStatic, {
    children: /*#__PURE__*/(0, _jsxRuntime.jsx)(ModuleBaseContent, {})
  });
};
exports.ModuleCheckout = ModuleCheckout;
const ModuleCheckoutSkeleton = ({
  loadingAccessibilityLabel
}) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_ModuleStatic.ModuleStatic, {
  accessible: true,
  accessibilityLabel: loadingAccessibilityLabel,
  accessibilityState: {
    busy: true
  },
  startBlock: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_layout.HStack, {
    space: 8,
    style: {
      alignItems: "center"
    },
    children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_skeleton.IOSkeleton, {
      shape: "square",
      size: 24,
      radius: 8
    }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_layout.VStack, {
      space: 8,
      children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_skeleton.IOSkeleton, {
        shape: "rectangle",
        width: 170,
        height: 20,
        radius: 8
      }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_skeleton.IOSkeleton, {
        shape: "rectangle",
        width: 110,
        height: 16,
        radius: 8
      })]
    })]
  }),
  endBlock: /*#__PURE__*/(0, _jsxRuntime.jsx)(_skeleton.IOSkeleton, {
    shape: "rectangle",
    width: 64,
    height: 16,
    radius: 8
  })
});
const styles = _reactNative.StyleSheet.create({
  image: {
    width: _core.IOSelectionListItemVisualParams.iconSize,
    height: _core.IOSelectionListItemVisualParams.iconSize,
    resizeMode: "contain"
  }
});
//# sourceMappingURL=ModuleCheckout.js.map