"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.ListItemNav = void 0;
var _reactNative = require("react-native");
var _reactNativeReanimated = _interopRequireDefault(require("react-native-reanimated"));
var _context = require("../../context");
var _core = require("../../core");
var _hooks = require("../../hooks");
var _accessibility = require("../../utils/accessibility");
var _avatar = require("../avatar");
var _badge = require("../badge");
var _icons = require("../icons");
var _layout = require("../layout");
var _loadingSpinner = require("../loadingSpinner");
var _typography = require("../typography");
var _jsxRuntime = require("react/jsx-runtime");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
const ListItemNav = ({
  value,
  description,
  onPress,
  icon,
  iconColor,
  avatarProps: avatar,
  paymentLogoUri,
  accessibilityLabel,
  accessibilityHint,
  testID,
  hideChevron = false,
  topElement,
  loading,
  numberOfLines
}) => {
  const {
    onPressIn,
    onPressOut,
    scaleAnimatedStyle,
    backgroundAnimatedStyle
  } = (0, _hooks.useListItemAnimation)();
  const theme = (0, _context.useIOTheme)();
  const defaultIconColor = iconColor ?? theme["icon-decorative"];
  const interactiveColor = theme["interactiveElem-default"];
  const {
    dynamicFontScale,
    hugeFontEnabled
  } = (0, _accessibility.useIOFontDynamicScale)();
  const listItemNavContent = /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
    children: [topElement && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
      children: [topElement.badgeProps && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
        children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
          style: {
            alignSelf: "flex-start"
          },
          children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_badge.Badge, {
            ...topElement.badgeProps
          })
        }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_layout.VSpacer, {
          size: 8
        })]
      }), topElement.dateValue && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
        children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
          style: {
            alignSelf: "flex-start",
            flexDirection: "row"
          },
          children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_icons.Icon, {
            allowFontScaling: true,
            name: "calendar",
            size: 16,
            color: "grey-300"
          }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_layout.HSpacer, {
            size: 4
          }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_typography.Caption, {
            color: theme["textBody-tertiary"],
            children: topElement.dateValue
          })]
        }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_layout.VSpacer, {
          size: 4
        })]
      })]
    }), typeof value === "string" ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_typography.H6, {
      color: theme["textBody-default"],
      numberOfLines: numberOfLines,
      children: value
    }) : value, description && /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
      children: typeof description === "string" ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_typography.BodySmall, {
        weight: "Regular",
        color: theme["textBody-tertiary"],
        children: description
      }) : description
    })]
  });
  const handleOnPress = event => {
    if (!loading) {
      onPress(event);
    }
  };
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Pressable, {
    onPress: handleOnPress,
    onPressIn: onPressIn,
    onPressOut: onPressOut,
    onTouchEnd: onPressOut,
    accessible: true,
    accessibilityState: {
      busy: loading
    },
    accessibilityLabel: accessibilityLabel,
    accessibilityHint: accessibilityHint,
    accessibilityRole: "button",
    testID: testID,
    children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeReanimated.default.View, {
      style: [_core.IOListItemStyles.listItem, backgroundAnimatedStyle],
      children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNativeReanimated.default.View, {
        style: [_core.IOListItemStyles.listItemInner, scaleAnimatedStyle],
        children: [icon && !hugeFontEnabled && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
          children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_icons.Icon, {
            allowFontScaling: true,
            name: icon,
            color: defaultIconColor,
            size: _core.IOListItemVisualParams.iconSize
          }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_layout.HSpacer, {
            allowScaleSpacing: true,
            size: _core.IOVisualCostants.iconMargin
          })]
        }), paymentLogoUri && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
          children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Image, {
            accessibilityIgnoresInvertColors: true,
            source: {
              uri: paymentLogoUri
            },
            style: {
              width: _core.IOSelectionListItemVisualParams.iconSize * dynamicFontScale,
              height: _core.IOSelectionListItemVisualParams.iconSize * dynamicFontScale
            }
          }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_layout.HSpacer, {
            allowScaleSpacing: true,
            size: _core.IOVisualCostants.iconMargin
          })]
        }), avatar && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
          children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_avatar.Avatar, {
            size: "small",
            ...avatar
          }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_layout.HSpacer, {
            allowScaleSpacing: true,
            size: _core.IOVisualCostants.iconMargin
          })]
        }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
          style: {
            flexGrow: 1,
            flexShrink: 1
          },
          children: listItemNavContent
        }), loading && /*#__PURE__*/(0, _jsxRuntime.jsx)(_loadingSpinner.LoadingSpinner, {
          color: _core.IOColors[interactiveColor]
        }), !loading && !hideChevron && /*#__PURE__*/(0, _jsxRuntime.jsx)(_icons.Icon, {
          allowFontScaling: true,
          name: "chevronRightListItem",
          color: interactiveColor,
          size: _core.IOListItemVisualParams.chevronSize
        })]
      })
    })
  });
};
exports.ListItemNav = ListItemNav;
//# sourceMappingURL=ListItemNav.js.map