import styled, { CSSProperties } from 'styled-components';
import { Flex } from '../../basic/Flex';
import { SessionIconButton } from '../../icon';
import { SubtitleStrings, SubtitleStringsType } from './ConversationHeaderTitle';
function loadDataTestId(currentSubtitle: SubtitleStringsType) {
  if (currentSubtitle === 'disappearingMessages') {
    return 'disappear-messages-type-and-time';
  }
  return 'conversation-header-subtitle';
}
export const StyledSubtitleContainer = styled.div`
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
  min-width: 230px;
  div:first-child {
    span:last-child {
      margin-bottom: 0;
    }
  }
`;
export const StyledSubtitleDotMenu = styled(Flex)``;
const StyledSubtitleDot = styled.span<{ active: boolean }>`
  border-radius: 50%;
  background-color: ${props =>
    props.active ? 'var(--text-primary-color)' : 'var(--text-secondary-color)'};
  height: 5px;
  width: 5px;
  margin: 0 2px;
`;
export const SubtitleDotMenu = ({
  id,
  selectedOptionIndex,
  optionsCount,
  style,
}: {
  id: string;
  selectedOptionIndex: number;
  optionsCount: number;
  style: CSSProperties;
}) => (
  
    {Array(optionsCount)
      .fill(0)
      .map((_, index) => {
        return (
          
        );
      })}
  
);
type ConversationHeaderSubtitleProps = {
  subtitlesArray: Array;
  subtitleStrings: SubtitleStrings;
  currentSubtitle: SubtitleStringsType;
  setCurrentSubtitle: (index: SubtitleStringsType) => void;
  onClickFunction: () => void;
  showDisappearingMessageIcon: boolean;
};
export const ConversationHeaderSubtitle = (props: ConversationHeaderSubtitleProps) => {
  const {
    subtitlesArray,
    subtitleStrings,
    currentSubtitle,
    setCurrentSubtitle,
    onClickFunction,
    showDisappearingMessageIcon,
  } = props;
  const handleTitleCycle = (direction: 1 | -1) => {
    let newIndex = subtitlesArray.indexOf(currentSubtitle) + direction;
    if (newIndex > subtitlesArray.length - 1) {
      newIndex = 0;
    }
    if (newIndex < 0) {
      newIndex = subtitlesArray.length - 1;
    }
    if (subtitlesArray[newIndex]) {
      setCurrentSubtitle(subtitlesArray[newIndex]);
    }
  };
  return (
    
      
         {
            handleTitleCycle(-1);
          }}
          isHidden={subtitlesArray.length < 2}
          tabIndex={0}
        />
        {showDisappearingMessageIcon && (
          
        )}
         {
            if (e.key === 'Enter') {
              e.preventDefault();
              onClickFunction();
            }
          }}
          tabIndex={0}
          data-testid={loadDataTestId(currentSubtitle)}
        >
          {subtitleStrings[currentSubtitle]}
        
         {
            handleTitleCycle(1);
          }}
          isHidden={subtitlesArray.length < 2}
          tabIndex={0}
        />
      
      
    
  );
};