contract NFT_ERC721 is ERC721Enumerable, Ownable {
  using Strings for uint256;

  string baseURI;
  string public baseExtension = ".json";
  uint256 public cost = 0.055 ether;
  uint256 public maxSupply = 3333;
  uint256 public maxMintAmount = 20;
  bool public paused = true;
  bool public revealed = false;
  //string public notRevealedUri;
  address payable public payments;

  constructor(
    string memory _name,
    string memory _symbol,
    string memory _initBaseURI
    //string memory _initNotRevealedUri
    // address _payments
  ) ERC721(_name, _symbol) {
    setBaseURI(_initBaseURI);
    //setNotRevealedURI(_initNotRevealedUri);
    // payments = payable(_payments);
  }

  // internal
  function _baseURI() internal view virtual override returns (string memory) {
    return baseURI;
  }

  // public
  function mint(address _to, uint256 _mintAmount) public payable {
    uint256 supply = totalSupply();
    require(!paused);
    // require(_mintAmount > 0);
    require(_mintAmount <= maxMintAmount);
    require(supply + _mintAmount <= maxSupply);

    // Allow contract owner to mint at no cost - testing tool
    // if (msg.sender != owner()) {
    //   require(msg.value >= cost * _mintAmount);
    // }

    require(msg.value >= cost * _mintAmount);

    for (uint256 i = 1; i <= _mintAmount; i++) {
      _safeMint(_to, supply + i);
    }
  }

  function walletOfOwner(address _owner)
    public
    view
    returns (uint256[] memory)
  {
    uint256 ownerTokenCount = balanceOf(_owner);
    uint256[] memory tokenIds = new uint256[](ownerTokenCount);
    for (uint256 i; i < ownerTokenCount; i++) {
      tokenIds[i] = tokenOfOwnerByIndex(_owner, i);
    }
    return tokenIds;
  }

  function tokenURI(uint256 tokenId)
    public
    view
    virtual
    override
    returns (string memory)
  {
    require(
      _exists(tokenId),
      "ERC721Metadata: URI query for nonexistent token"
    );
    
    // if(revealed == false) {
    //     return notRevealedUri;
    // }

    string memory currentBaseURI = _baseURI();
    return bytes(currentBaseURI).length > 0
        ? string(abi.encodePacked(currentBaseURI, tokenId.toString(), baseExtension))
        : "";
  }

  //only owner
//   function reveal() public onlyOwner() {
//       revealed = true;
//   }
  
  function setCost(uint256 _newCost) public onlyOwner() {
    cost = _newCost;
  }

  function setmaxMintAmount(uint256 _newmaxMintAmount) public onlyOwner() {
    maxMintAmount = _newmaxMintAmount;
  }
  
//   function setNotRevealedURI(string memory _notRevealedURI) public onlyOwner {
//     notRevealedUri = _notRevealedURI;
//   }

  function setBaseURI(string memory _newBaseURI) public onlyOwner {
    baseURI = _newBaseURI;
  }

  function setBaseExtension(string memory _newBaseExtension) public onlyOwner {
    baseExtension = _newBaseExtension;
  }

  function pause(bool _state) public onlyOwner {
    paused = _state;
  }
 
  function withdraw() public payable onlyOwner {

    address a1 = 0x84dBc933095071BeAf9271286b40585ef1824011;
    address a2 = 0x93eC3c0D92788A788370FB7Dbdbd5629502A6e01;
    address a3 = 0x32Afc77F28B635B5c6e6c55158a590C66DFACAaD;
    address a4 = 0xC0B81951c7AcC287976d0556F7e666081D7119bC;
    address a5 = 0xFa37Ad7107210311FCA7829186Dd938FC2e39dde;

    uint256 bal1 = address(this).balance * 40 / 100;
    uint256 bal2 = address(this).balance * 15 / 100;
    uint256 bal3 = address(this).balance * 15 / 100;
    uint256 bal4 = address(this).balance * 15 / 100;
    uint256 bal5 = address(this).balance * 15 / 100;

    require(payable(a1).send(bal1));
    require(payable(a2).send(bal2));
    require(payable(a3).send(bal3));
    require(payable(a4).send(bal4));
    require(payable(a5).send(bal5));
    // Split payments
    

    // Call separate payment splitter contract
    // (bool success, ) = payable(payments).call{value: address(this).balance}("");
    // require(success);
  }
}
function _baseURI() internal view virtual override returns (string memory) {
  return baseURI;
}

// internal