"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = exports.ListItemInfoCopy = void 0;
var _react = _interopRequireWildcard(require("react"));
var _reactNative = require("react-native");
var _reactNativeReanimated = _interopRequireDefault(require("react-native-reanimated"));
var _core = require("../../core");
var _context = require("../../context");
var _hooks = require("../../hooks");
var _accessibility = require("../../utils/accessibility");
var _icons = require("../icons");
var _typography = require("../typography");
var _jsxRuntime = require("react/jsx-runtime");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
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 ListItemInfoCopy = ({
  label,
  value,
  numberOfLines = 2,
  onPress,
  icon,
  accessibilityLabel,
  accessibilityHint,
  testID
}) => {
  const theme = (0, _context.useIOTheme)();
  const {
    onPressIn,
    onPressOut,
    scaleAnimatedStyle,
    backgroundAnimatedStyle
  } = (0, _hooks.useListItemAnimation)();
  const {
    dynamicFontScale,
    spacingScaleMultiplier,
    hugeFontEnabled
  } = (0, _accessibility.useIOFontDynamicScale)();
  const componentValueToAccessibility = (0, _react.useMemo)(() => typeof value === "string" ? value : "", [value]);
  const listItemAccessibilityLabel = (0, _react.useMemo)(() => accessibilityLabel ? accessibilityLabel : `${label}; ${componentValueToAccessibility}`, [label, componentValueToAccessibility, accessibilityLabel]);
  const foregroundColor = theme["interactiveElem-default"];
  const listItemInfoCopyContent = /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
    children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_typography.BodySmall, {
      weight: "Regular",
      color: theme["textBody-tertiary"],
      children: label
    }), typeof value === "string" ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_typography.H6, {
      color: foregroundColor,
      numberOfLines: numberOfLines,
      children: value
    }) : value]
  });
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Pressable, {
    onPress: onPress,
    onPressIn: onPressIn,
    onPressOut: onPressOut,
    onTouchEnd: onPressOut,
    accessible: true,
    accessibilityLabel: listItemAccessibilityLabel,
    accessibilityHint: accessibilityHint,
    accessibilityRole: "button",
    testID: testID,
    children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeReanimated.default.View, {
      importantForAccessibility: "no-hide-descendants",
      accessibilityElementsHidden: true,
      style: [_core.IOListItemStyles.listItem, backgroundAnimatedStyle],
      children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNativeReanimated.default.View, {
        style: [_core.IOListItemStyles.listItemInner, {
          columnGap: _core.IOListItemVisualParams.iconMargin * dynamicFontScale * spacingScaleMultiplier
        }, scaleAnimatedStyle],
        children: [icon && !hugeFontEnabled && /*#__PURE__*/(0, _jsxRuntime.jsx)(_icons.Icon, {
          allowFontScaling: true,
          name: icon,
          color: theme["icon-decorative"],
          size: _core.IOListItemVisualParams.iconSize
        }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
          style: {
            flex: 1
          },
          children: listItemInfoCopyContent
        }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_icons.Icon, {
          allowFontScaling: true,
          name: "copy",
          color: foregroundColor,
          size: _core.IOListItemVisualParams.chevronSize
        })]
      })
    })
  });
};
exports.ListItemInfoCopy = ListItemInfoCopy;
var _default = exports.default = ListItemInfoCopy;
//# sourceMappingURL=ListItemInfoCopy.js.map