contract MyToken is ERC721, Ownable {
    using Counters for Counters.Counter;

    Counters.Counter private _tokenIdCounter;
    uint256 public mintRate = 0.022 ether;
    uint public MAX_SUPPLY = 2222;
    bool prerevrealOn = true;
    string baseURI = "ipfs://QmVF5zAQfQ3B6Wve8RVJc7hcyRBkwGxwArPSDcCwu5LzRe/";

    mapping(address => bool) public whitelistClaimed;

    constructor() ERC721("FortuneAnimalsClub", "FAC") {}

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

    function safeMint(address to, uint mintQuantity) public payable {
        require((_tokenIdCounter.current() + mintQuantity) <= MAX_SUPPLY, "Mint limit reached");
        if ((_tokenIdCounter.current() + mintQuantity) > 222) {
            require(msg.value >= mintRate * mintQuantity, "not enough ether sent");
        }
        

        for(uint256 i; i < mintQuantity; i++){
            _tokenIdCounter.increment();
            uint256 tokenId = _tokenIdCounter.current();
            _safeMint(to, tokenId);
        }

    }

    // The following functions are overrides required by Solidity.

    function _beforeTokenTransfer(address from, address to, uint256 tokenId)
        internal
        override(ERC721)
    {
        super._beforeTokenTransfer(from, to, tokenId);
    }

    function supportsInterface(bytes4 interfaceId)
        public
        view
        override(ERC721)
        returns (bool)
    {
        return super.supportsInterface(interfaceId);
    }

    function withdraw() public onlyOwner {
        require(address(this).balance > 0, "Balance is 0");
        payable(owner()).transfer(address(this).balance);
    }

    function disableMinting() public onlyOwner {
        MAX_SUPPLY = 0;
    }

    function disablePrereveal(string calldata newURI) public onlyOwner {
        require(keccak256(abi.encodePacked(baseURI)) == keccak256(abi.encodePacked("ipfs://QmVF5zAQfQ3B6Wve8RVJc7hcyRBkwGxwArPSDcCwu5LzRe/")), "Prereveal has been disabled");
        baseURI = newURI;
    }

    function tokensMinted() public view returns (uint256) {
        return _tokenIdCounter.current();
    }

}
function _beforeTokenTransfer(address from, address to, uint256 tokenId)
    internal
    override(ERC721)
{
    super._beforeTokenTransfer(from, to, tokenId);
}

// The following functions are overrides required by Solidity.