"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _react = _interopRequireWildcard(require("react"));
var _icons = require("../../assets/icons");
var _Button = _interopRequireDefault(require("../styled/Button"));
var _StyledInputComponents = require("../styled/StyledInputComponents/StyledInputComponents");
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 TextInput = ({
  message,
  setMessage,
  handleSendClick,
  config,
  isLoading,
  onFocus,
  onBlur
}) => {
  const handleInputChange = (0, _react.useCallback)(text => {
    setMessage(text);
  }, [setMessage]);
  const handleKeyDown = (0, _react.useCallback)(event => {
    if (event.nativeEvent.key === 'Enter' && message) {
      handleSendClick();
    }
  }, [handleSendClick, message]);
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
    children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_StyledInputComponents.MessageInput
    // Stable testIDs so Maestro / Detox / Appium can drive the
    // chat-send flow reliably. accessibilityLabel mirrors the
    // testID so iOS accessibility-id lookups also work.
    , {
      testID: "chat-message-input",
      accessibilityLabel: "chat-message-input",
      color: config?.colors?.primary,
      placeholder: "Type message",
      value: message,
      onChangeText: handleInputChange,
      onSubmitEditing: handleSendClick,
      onFocus: onFocus,
      onBlur: onBlur,
      editable: !isLoading
    }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Button.default, {
      testID: "chat-send-button",
      accessibilityLabel: "chat-send-button",
      onPress: handleSendClick,
      EndIcon: /*#__PURE__*/(0, _jsxRuntime.jsx)(_icons.SendIcon, {
        color: !message ? '#D4D4D8' : '#fff'
      }),
      style: {
        borderRadius: 100,
        backgroundColor: !message ? 'transparent' : config?.colors?.primary
      }
    })]
  });
};
var _default = exports.default = TextInput;
//# sourceMappingURL=TextInput.js.map