"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.ModuleCheckout = void 0;
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");
const IMAGE_MARGIN = 12;
const ModuleBaseContent = ({
  paymentLogo,
  image,
  title,
  subtitle
}) => {
  const theme = (0, _context.useIOTheme)();
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_layout.HStack, {
    space: IMAGE_MARGIN,
    style: {
      alignItems: "center",
      flexShrink: 1
    },
    children: [paymentLogo ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_logos.LogoPayment, {
      name: paymentLogo
    }) : image && /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Image, {
      source: image,
      style: styles.image,
      accessibilityIgnoresInvertColors: true
    }), /*#__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
      })]
    })]
  });
};
const ModuleCheckout = props => {
  if (props.isLoading) {
    return /*#__PURE__*/(0, _jsxRuntime.jsx)(ModuleCheckoutSkeleton, {
      loadingAccessibilityLabel: props.loadingAccessibilityLabel
    });
  }
  const {
    paymentLogo,
    image,
    title,
    subtitle,
    ctaText,
    onPress
  } = props;
  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, {
        title: title,
        subtitle: subtitle,
        paymentLogo: paymentLogo,
        image: image
      }), /*#__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, {
      title: title,
      subtitle: subtitle,
      paymentLogo: paymentLogo,
      image: image
    })
  });
};
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