#ifndef DIRECTORYNODE_H_
#define DIRECTORYNODE_H_

#include <SD.h>
#include <vector>


const String sys_dir = "system";



class DirectoryNode {
private:
  uint16_t id;
  String name;
  std::vector<DirectoryNode*> subdirectories;
  std::vector<String> mp3Files;
  std::vector<uint16_t> ids;
  const String* currentPlaying;
  uint16_t currentPlayingId = 0;
  uint16_t secondsPlayed = 0;
  
  
  

public:
  DirectoryNode(const String& nodeName);
  ~DirectoryNode();
  static uint16_t idCounter;
  

  const String& getName() const;
  const uint16_t getId() const;
  const std::vector<DirectoryNode*>& getSubdirectories() const;
  const std::vector<String>& getMP3Files() const;

  void setCurrentPlaying(const String* mp3File);
  const String* getCurrentPlaying() const;
  const uint16_t getCurrentPlayingId() const;

  void setSecondsPlayed(const uint32_t seconds);
  uint32_t getSecondsPlayed();

  uint16_t getNextId();

  void addSubdirectory(DirectoryNode* subdirectory);
  void addMP3File(const String& mp3File);
  void buildDirectoryTree(const char* currentPath);
  void printDirectoryTree(int level = 0) const;
  DirectoryNode* advanceToMP3(const String* currentGlobal);
  DirectoryNode* advanceToNextMP3(const String* currentGlobal);
  DirectoryNode* goToPreviousMP3(uint32_t thresholdSeconds = 3);
  DirectoryNode* advanceToMP3(const uint16_t id);
  void advanceToFirstMP3InThisNode();
  String getDirectoryStructureHTML() const;
  void appendIndentation(String& html, int level) const;
  DirectoryNode* findFirstDirectoryWithMP3s();
  String getCurrentPlayingFilePath() const;
};




#endif /* DIRECTORYNODE_H_ */
