"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.ModulePaymentNotice = void 0;
var _reactNative = require("react-native");
var _context = require("../../context");
var _core = require("../../core");
var _badge = require("../badge");
var _icons = require("../icons");
var _layout = require("../layout");
var _skeleton = require("../skeleton");
var _typography = require("../typography");
var _ModuleStatic = require("./ModuleStatic");
var _PressableModuleBase = require("./PressableModuleBase");
var _jsxRuntime = require("react/jsx-runtime");
const styles = _reactNative.StyleSheet.create({
  endBlock: {
    flexDirection: "row",
    alignItems: "center",
    justifyContent: "flex-end"
  }
});
const AmountOrBadgeComponent = ({
  status,
  amount,
  amountAccessibilityLabel,
  badgeText
}) => {
  const theme = (0, _context.useIOTheme)();
  switch (status) {
    case "default":
      return /*#__PURE__*/(0, _jsxRuntime.jsx)(_typography.H6, {
        accessibilityLabel: amountAccessibilityLabel,
        color: theme["interactiveElem-default"],
        numberOfLines: 1,
        children: amount
      });
    case "paid":
      return /*#__PURE__*/(0, _jsxRuntime.jsx)(_badge.Badge, {
        variant: "success",
        text: badgeText
      });
    case "error":
      return /*#__PURE__*/(0, _jsxRuntime.jsx)(_badge.Badge, {
        variant: "error",
        text: badgeText
      });
    case "expired":
    case "revoked":
    case "canceled":
    case "in-progress":
      return /*#__PURE__*/(0, _jsxRuntime.jsx)(_badge.Badge, {
        variant: "default",
        text: badgeText
      });
  }
};
const ModulePaymentNoticeContent = ({
  title,
  subtitle,
  paymentNotice: {
    status,
    amount,
    amountAccessibilityLabel
  },
  badgeText = ""
}) => {
  const theme = (0, _context.useIOTheme)();
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_layout.HStack, {
    space: _core.IOListItemVisualParams.iconMargin,
    children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
      style: {
        flexGrow: 1,
        flexShrink: 1
      },
      children: [title && /*#__PURE__*/(0, _jsxRuntime.jsx)(_typography.BodySmall, {
        numberOfLines: 1,
        weight: "Regular",
        color: theme["textBody-tertiary"],
        children: title
      }), subtitle && /*#__PURE__*/(0, _jsxRuntime.jsx)(_typography.Body, {
        color: theme["interactiveElem-default"],
        numberOfLines: 2,
        weight: "Semibold",
        children: subtitle
      })]
    }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
      style: styles.endBlock,
      children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(AmountOrBadgeComponent, {
        status: status,
        amount: amount,
        amountAccessibilityLabel: amountAccessibilityLabel,
        badgeText: badgeText
      }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_icons.Icon, {
        name: "chevronRightListItem",
        color: theme["interactiveElem-default"],
        size: _core.IOListItemVisualParams.chevronSize
      })]
    })]
  });
};

/**
 * The `ModulePaymentNotice` component is a custom button component with an extended outline style.
 * It provides an animated scaling effect when pressed.
 *
 * @param {boolean} isLoading - If true, displays a skeleton loading component.
 * @param {function} onPress - The function to be executed when the item is pressed.
 * @param {string} title - The title text to display.
 * @param {string} subtitle - The subtitle text to display.
 * @param {string} testID - The test ID for testing purposes.
 * @param {string} paymentNoticeAmount - The payment notice amount to display.
 * @param {string} paymentNoticeStatus - The status of the payment notice.
 */
const ModulePaymentNotice = ({
  isLoading = false,
  testID,
  accessibilityLabel,
  onPress,
  loadingAccessibilityLabel,
  ...rest
}) => {
  if (isLoading) {
    return /*#__PURE__*/(0, _jsxRuntime.jsx)(ModulePaymentNoticeSkeleton, {
      loadingAccessibilityLabel: loadingAccessibilityLabel
    });
  }
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_PressableModuleBase.PressableModuleBase, {
    onPress: onPress,
    accessibilityLabel: accessibilityLabel,
    testID: testID,
    children: /*#__PURE__*/(0, _jsxRuntime.jsx)(ModulePaymentNoticeContent, {
      ...rest
    })
  });
};
exports.ModulePaymentNotice = ModulePaymentNotice;
const ModulePaymentNoticeSkeleton = ({
  loadingAccessibilityLabel
}) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_ModuleStatic.ModuleStatic, {
  accessible: true,
  accessibilityLabel: loadingAccessibilityLabel,
  accessibilityState: {
    busy: true
  },
  startBlock: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_layout.VStack, {
    space: 4,
    children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_skeleton.IOSkeleton, {
      shape: "rectangle",
      width: 120,
      height: 12,
      radius: 8
    }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_skeleton.IOSkeleton, {
      shape: "rectangle",
      width: 180,
      height: 16,
      radius: 8
    })]
  }),
  endBlock: /*#__PURE__*/(0, _jsxRuntime.jsx)(_skeleton.IOSkeleton, {
    shape: "rectangle",
    width: 64,
    height: 24,
    radius: 16
  })
});
//# sourceMappingURL=ModulePaymentNotice.js.map