"use strict";

import React from 'react';
import { Text, TouchableOpacity } from 'react-native';
import { useTheme } from "../theme/use-theme.js";
import { usePromptInput } from "./context.js";
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
export function PromptInputSubmitButton({
  isLoading,
  onStop,
  emptyAction,
  submitIcon,
  stopIcon,
  style,
  testID
}) {
  const {
    onSubmit,
    value,
    attachments
  } = usePromptInput();
  const theme = useTheme();
  const hasContent = value.trim().length > 0 || attachments.length > 0;
  if (isLoading && onStop) {
    return /*#__PURE__*/_jsx(TouchableOpacity, {
      onPress: onStop,
      activeOpacity: 0.7,
      style: [{
        width: 32,
        height: 32,
        borderRadius: 16,
        backgroundColor: theme.colors.primary,
        alignItems: 'center',
        justifyContent: 'center'
      }, style],
      testID: testID,
      children: stopIcon ?? /*#__PURE__*/_jsx(Text, {
        style: {
          fontSize: 12,
          color: theme.colors.primaryForeground,
          fontWeight: '700'
        },
        children: "\u25A0"
      })
    });
  }
  if (!hasContent && emptyAction) {
    return /*#__PURE__*/_jsx(_Fragment, {
      children: emptyAction
    });
  }
  return /*#__PURE__*/_jsx(TouchableOpacity, {
    onPress: onSubmit,
    disabled: !hasContent,
    activeOpacity: 0.7,
    style: [{
      width: 32,
      height: 32,
      borderRadius: 16,
      backgroundColor: theme.colors.primary,
      alignItems: 'center',
      justifyContent: 'center',
      opacity: hasContent ? 1 : 0.4
    }, style],
    testID: testID,
    children: submitIcon ?? /*#__PURE__*/_jsx(Text, {
      style: {
        fontSize: 16,
        color: theme.colors.primaryForeground,
        fontWeight: '700'
      },
      children: "\u2191"
    })
  });
}
PromptInputSubmitButton.displayName = 'PromptInputSubmitButton';
//# sourceMappingURL=SubmitButton.js.map