#pragma once

#include "esphome/core/automation.h"
#include "esphome/core/component.h"
#include "esphome/components/pn7150/pn7150.h"

namespace esphome::pn7150 {

template<typename... Ts> class PN7150IsWritingCondition final : public Condition<Ts...>, public Parented<PN7150> {
 public:
  bool check(const Ts &...x) override { return this->parent_->is_writing(); }
};

template<typename... Ts> class EmulationOffAction final : public Action<Ts...>, public Parented<PN7150> {
  void play(const Ts &...x) override { this->parent_->set_tag_emulation_off(); }
};

template<typename... Ts> class EmulationOnAction final : public Action<Ts...>, public Parented<PN7150> {
  void play(const Ts &...x) override { this->parent_->set_tag_emulation_on(); }
};

template<typename... Ts> class PollingOffAction final : public Action<Ts...>, public Parented<PN7150> {
  void play(const Ts &...x) override { this->parent_->set_polling_off(); }
};

template<typename... Ts> class PollingOnAction final : public Action<Ts...>, public Parented<PN7150> {
  void play(const Ts &...x) override { this->parent_->set_polling_on(); }
};

template<typename... Ts> class SetCleanModeAction final : public Action<Ts...>, public Parented<PN7150> {
  void play(const Ts &...x) override { this->parent_->clean_mode(); }
};

template<typename... Ts> class SetFormatModeAction final : public Action<Ts...>, public Parented<PN7150> {
  void play(const Ts &...x) override { this->parent_->format_mode(); }
};

template<typename... Ts> class SetReadModeAction final : public Action<Ts...>, public Parented<PN7150> {
  void play(const Ts &...x) override { this->parent_->read_mode(); }
};

template<typename... Ts> class SetEmulationMessageAction final : public Action<Ts...>, public Parented<PN7150> {
  TEMPLATABLE_VALUE(std::string, message)
  TEMPLATABLE_VALUE(bool, include_android_app_record)

  void play(const Ts &...x) override {
    this->parent_->set_tag_emulation_message(this->message_.optional_value(x...),
                                             this->include_android_app_record_.optional_value(x...));
  }
};

template<typename... Ts> class SetWriteMessageAction final : public Action<Ts...>, public Parented<PN7150> {
  TEMPLATABLE_VALUE(std::string, message)
  TEMPLATABLE_VALUE(bool, include_android_app_record)

  void play(const Ts &...x) override {
    this->parent_->set_tag_write_message(this->message_.optional_value(x...),
                                         this->include_android_app_record_.optional_value(x...));
  }
};

template<typename... Ts> class SetWriteModeAction final : public Action<Ts...>, public Parented<PN7150> {
  void play(const Ts &...x) override { this->parent_->write_mode(); }
};

}  // namespace esphome::pn7150
