using System;
using System.Text.RegularExpressions;
namespace Emby.Naming.Common
{
    /// 
    /// Regular expressions for parsing TV Episodes.
    /// 
    public class EpisodeExpression
    {
        private string _expression;
        private Regex? _regex;
        /// 
        /// Initializes a new instance of the  class.
        /// 
        /// Regular expressions.
        /// True if date is expected.
        public EpisodeExpression(string expression, bool byDate = false)
        {
            _expression = expression;
            IsByDate = byDate;
            DateTimeFormats = Array.Empty();
            SupportsAbsoluteEpisodeNumbers = true;
        }
        /// 
        /// Gets or sets raw expressions string.
        /// 
        public string Expression
        {
            get => _expression;
            set
            {
                _expression = value;
                _regex = null;
            }
        }
        /// 
        /// Gets or sets a value indicating whether gets or sets property indicating if date can be find in expression.
        /// 
        public bool IsByDate { get; set; }
        /// 
        /// Gets or sets a value indicating whether gets or sets property indicating if expression is optimistic.
        /// 
        public bool IsOptimistic { get; set; }
        /// 
        /// Gets or sets a value indicating whether gets or sets property indicating if expression is named.
        /// 
        public bool IsNamed { get; set; }
        /// 
        /// Gets or sets a value indicating whether gets or sets property indicating if expression supports episodes with absolute numbers.
        /// 
        public bool SupportsAbsoluteEpisodeNumbers { get; set; }
        /// 
        /// Gets or sets optional list of date formats used for date parsing.
        /// 
        public string[] DateTimeFormats { get; set; }
        /// 
        /// Gets a  expressions objects (creates it if null).
        /// 
        public Regex Regex => _regex ??= new Regex(Expression, RegexOptions.IgnoreCase | RegexOptions.Compiled);
    }
}