using System.Collections.Generic;
using UnityEngine;
using Wizard;
using Wizard.DeckCardEdit;
using Wizard.Dialog.Setting;

public class DeckIntroductionCopyDialog : MonoBehaviour
{
	private const float GRID_Y_WITH_MY_ROTATION = -15f;

	private const float HINT_Y_WITH_MY_ROTATION = 53f;

	[SerializeField]
	private UILabel _labelCopyConfirm;

	[SerializeField]
	private UILabel _labelHint;

	[SerializeField]
	private ItemToggle _copyToMyRotation;

	[SerializeField]
	private ItemToggle _premium;

	[SerializeField]
	private ItemToggle _prize;

	[SerializeField]
	private UIGrid _grid;

	public bool IsMyRotationDeck;

	public bool IsResurgentToMyRotationDeck;

	private bool _isRotationPeriod;

	public bool IsCopyToMyRotation
	{
		get
		{
			if (!IsMyRotationDeck)
			{
				if (DisplayCopyToMyRotation)
				{
					return _copyToMyRotation.GetValue();
				}
				return false;
			}
			return true;
		}
	}

	public string LabelCopyConfirm
	{
		set
		{
			_labelCopyConfirm.text = value;
		}
	}

	public string LabelHint
	{
		set
		{
			_labelHint.text = value;
		}
	}

	private bool DisplayCopyToMyRotation
	{
		get
		{
			if (Data.MyRotationAllInfo.IsWithinCopyDeckIntroductionPeriod && !IsMyRotationDeck)
			{
				return !IsDisableMyRotation;
			}
			return false;
		}
	}

	public bool IsDisableMyRotation { get; set; }

	private KeyValuePair<string, int> MyRotationSaveDataKey
	{
		get
		{
			if (!_isRotationPeriod)
			{
				return PlayerPrefsWrapper.DECK_INTRO_IS_MYROTATION_COPY_NOT_EQUAL_PERIOD;
			}
			return PlayerPrefsWrapper.DECK_INTRO_IS_MYROTATION_COPY_EQUAL_PERIOD;
		}
	}

	public void Initialize(bool isRotationPeriod)
	{
		_isRotationPeriod = isRotationPeriod;
	}

	private void Start()
	{
		if (IsResurgentToMyRotationDeck)
		{
			_copyToMyRotation.gameObject.SetActive(value: false);
			_copyToMyRotation.SetValue(value: false);
			_copyToMyRotation.SetActive_SeparatorLine(isActive: false);
		}
		else
		{
			_copyToMyRotation.gameObject.SetActive(DisplayCopyToMyRotation);
			_copyToMyRotation.SetValue(DisplayCopyToMyRotation);
			_copyToMyRotation.SetActive_SeparatorLine(isActive: true);
			_copyToMyRotation.SetValue(PlayerPrefsWrapper.GetBool(MyRotationSaveDataKey));
			_copyToMyRotation.AddChangeCallback(delegate
			{
				PlayerPrefsWrapper.SetValue(MyRotationSaveDataKey, _copyToMyRotation.GetValue() ? 1 : 0);
			});
			if (DisplayCopyToMyRotation)
			{
				ChangeY(_grid.transform, -15f);
				ChangeY(_labelHint.transform, 53f);
			}
		}
		ItemToggle itemPremium = _premium;
		itemPremium.SetValue(Data.Load.data._userConfig.IsFoilPreferred);
		itemPremium.AddChangeCallback(delegate
		{
			DeckCardEditUI.SendConfigUpdateFoilPreferred(itemPremium.GetValue());
		});
		itemPremium.SetActive_SeparatorLine(isActive: true);
		ItemToggle itemPrize = _prize;
		itemPrize.SetValue(Data.Load.data._userConfig.IsPrizePreferred);
		itemPrize.AddChangeCallback(delegate
		{
			DeckCardEditUI.SendConfigUpdatePrizePreferred(itemPrize.GetValue());
		});
		itemPrize.SetActive_SeparatorLine(isActive: true);
		_grid.Reposition();
	}

	private static void ChangeY(Transform trans, float y)
	{
		Vector3 localPosition = trans.localPosition;
		localPosition.y = y;
		trans.localPosition = localPosition;
	}
}
