"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.ModuleNavigation = void 0;
var _reactNative = require("react-native");
var _context = require("../../context");
var _core = require("../../core");
var _accessibility = require("../../utils/accessibility");
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 ModuleNavigation = props => {
  const theme = (0, _context.useIOTheme)();
  const {
    hugeFontEnabled
  } = (0, _accessibility.useIOFontDynamicScale)();
  if (props.isLoading) {
    return /*#__PURE__*/(0, _jsxRuntime.jsx)(ModuleNavigationSkeleton, {
      loadingAccessibilityLabel: props.loadingAccessibilityLabel
    });
  }
  const {
    icon,
    image,
    title,
    subtitle,
    onPress,
    badge,
    ...pressableProps
  } = props;
  const iconComponent = icon && !hugeFontEnabled && /*#__PURE__*/(0, _jsxRuntime.jsx)(_icons.Icon, {
    name: icon,
    size: _core.IOSelectionListItemVisualParams.iconSize,
    color: "grey-300"
  });
  const imageComponent = image && /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Image, {
    source: image,
    style: styles.image,
    accessibilityIgnoresInvertColors: true
  });
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_PressableModuleBase.PressableModuleBase, {
    ...pressableProps,
    onPress: onPress,
    children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_layout.HStack, {
      space: 8,
      style: {
        alignItems: "center"
      },
      children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_layout.HStack, {
        space: _core.IOVisualCostants.iconMargin,
        style: {
          alignItems: "center",
          flexGrow: 1,
          flexShrink: 1
        },
        children: [iconComponent ?? imageComponent, /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
          style: {
            flexShrink: 1
          },
          children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_typography.BodySmall, {
            color: theme["interactiveElem-default"],
            weight: "Semibold",
            numberOfLines: 2,
            lineBreakMode: "middle",
            style: {
              flexShrink: 1
            },
            children: title
          }), subtitle && /*#__PURE__*/(0, _jsxRuntime.jsx)(_typography.LabelMini, {
            weight: "Regular",
            color: theme["textBody-tertiary"],
            children: subtitle
          })]
        })]
      }), badge ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_badge.Badge, {
        ...badge
      }) : onPress ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_icons.Icon, {
        name: "chevronRightListItem",
        color: theme["interactiveElem-default"],
        size: _core.IOListItemVisualParams.chevronSize
      }) : null]
    })
  });
};
exports.ModuleNavigation = ModuleNavigation;
const ModuleNavigationSkeleton = ({
  loadingAccessibilityLabel
}) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_ModuleStatic.ModuleStatic, {
  accessible: true,
  accessibilityLabel: loadingAccessibilityLabel,
  accessibilityState: {
    busy: true
  },
  startBlock: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_layout.HStack, {
    style: {
      alignItems: "center"
    },
    space: _core.IOVisualCostants.iconMargin,
    children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_skeleton.IOSkeleton, {
      shape: "square",
      size: 24,
      radius: 8
    }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_layout.VStack, {
      space: 4,
      children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_skeleton.IOSkeleton, {
        shape: "rectangle",
        width: 96,
        height: 16,
        radius: 8
      }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_skeleton.IOSkeleton, {
        shape: "rectangle",
        width: 160,
        height: 12,
        radius: 8
      })]
    })]
  }),
  endBlock: /*#__PURE__*/(0, _jsxRuntime.jsx)(_skeleton.IOSkeleton, {
    shape: "rectangle",
    width: 64,
    height: 24,
    radius: 16
  })
});
const styles = _reactNative.StyleSheet.create({
  image: {
    width: _core.IOSelectionListItemVisualParams.iconSize,
    height: _core.IOSelectionListItemVisualParams.iconSize,
    resizeMode: "contain"
  }
});
//# sourceMappingURL=ModuleNavigation.js.map