using System;
using Cute;
using UnityEngine;

public class CardDetailFilterKeyWord : MonoBehaviour
{
	[SerializeField]
	private UIToggle _toggle;

	[SerializeField]
	private UILabel _label;

	private bool _checkedCache;

	public bool IsEnableKeyWord => _toggle.value;

	public string KeyWord { get; private set; }

	public Action OnValueChange { get; set; }

	private void Start()
	{
	}

	public void Reset()
	{
		_checkedCache = false;
		_toggle.value = false;
	}

	public void SetChecked()
	{
		_checkedCache = true;
		_toggle.value = true;
	}

	public void Initialize(string keyword)
	{
		EventDelegate.Add(_toggle.onChange, delegate
		{
			if (_toggle.value != _checkedCache)
			{
				_checkedCache = _toggle.value;
				GameMgr.GetIns().GetSoundMgr().PlaySe(_toggle.value ? Se.TYPE.SYS_TOGGLE_ON : Se.TYPE.SYS_TOGGLE_OFF);
			}
			OnValueChange.Call();
		});
		_label.text = keyword;
		KeyWord = keyword;
	}
}
