"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.Item = exports.GroupedButtons = void 0;
var _react = _interopRequireWildcard(require("react"));
var _reactNative = require("react-native");
var _useTheme = require("../theme/use-theme.js");
var _jsxRuntime = require("react/jsx-runtime");
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); }
// ── Item (defined first so it can be attached to GroupedButtons) ─

function ItemComponent({
  label,
  description,
  icon,
  onPress,
  destructive = false,
  disabled = false,
  testID
}) {
  const theme = (0, _useTheme.useTheme)();
  const labelColor = destructive ? theme.colors.negative : theme.colors.text;
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.TouchableOpacity, {
    onPress: onPress,
    disabled: disabled,
    activeOpacity: 0.6,
    testID: testID,
    style: [styles.item, disabled && styles.disabled],
    children: [icon && /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
      style: styles.iconWrapper,
      children: icon
    }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
      style: styles.textWrapper,
      children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
        style: [styles.label, {
          color: labelColor
        }],
        children: label
      }), description && /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
        style: [styles.description, {
          color: theme.colors.textSecondary
        }],
        children: description
      })]
    })]
  });
}
const Item = exports.Item = /*#__PURE__*/(0, _react.memo)(ItemComponent);
Item.displayName = 'GroupedButtons.Item';

// ── GroupedButtons ───────────────────────────────────────────────

function GroupedButtonsComponent({
  children,
  style
}) {
  const theme = (0, _useTheme.useTheme)();
  const childArray = _react.Children.toArray(children);
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
    style: [styles.container, {
      backgroundColor: theme.colors.card
    }, style],
    children: childArray.map((child, index) => /*#__PURE__*/(0, _jsxRuntime.jsxs)(_react.default.Fragment, {
      children: [child, index < childArray.length - 1 && /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
        style: [styles.divider, {
          backgroundColor: theme.colors.borderLight
        }]
      })]
    }, index))
  });
}
const GroupedButtonsMemo = /*#__PURE__*/(0, _react.memo)(GroupedButtonsComponent);
GroupedButtonsMemo.displayName = 'GroupedButtons';
const GroupedButtons = exports.GroupedButtons = Object.assign(GroupedButtonsMemo, {
  Item
});

// ── Styles ──────────────────────────────────────────────────────

const styles = _reactNative.StyleSheet.create({
  container: {
    borderRadius: 12,
    overflow: 'hidden'
  },
  divider: {
    height: 1,
    marginLeft: 16
  },
  item: {
    flexDirection: 'row',
    alignItems: 'center',
    paddingVertical: 12,
    paddingHorizontal: 16
  },
  disabled: {
    opacity: 0.5
  },
  iconWrapper: {
    marginRight: 12
  },
  textWrapper: {
    flex: 1
  },
  label: {
    fontSize: 16
  },
  description: {
    fontSize: 13,
    marginTop: 2
  }
});
//# sourceMappingURL=GroupedButtons.js.map