contract ApeDoodles is ERC721, Ownable {

    using Strings for uint256;

    bool public isSale = false;

    uint256 public currentToken = 0;
    uint256 public maxSupply = 10000;
    uint256 public price = 0.02 ether;
    string public metaUri = '';



    constructor() ERC721('Ape Doodles', 'APEDOODLESNFT') {

    }

    // Mint Functions

    function mint(uint256 quantity) public payable {
        require(isSale==true, "Public Sale is Not Active");
        require((currentToken + quantity) <= maxSupply, "Quantity Exceeds Tokens Available");
        require((price * quantity) <= msg.value, "Ether Amount Sent Is Incorrect");
        for (uint256 i = 0; i < quantity; i++) {
            _safeMint(msg.sender, currentToken);
            currentToken = currentToken + 1;
        }
    }


    // Owner Mint Functions


    function ownerMint(address[] memory addresses) external onlyOwner {
        require((currentToken + addresses.length) <= maxSupply, "Quantity Exceeds Tokens Available");
        for (uint256 i = 0; i < addresses.length; i++) {
            _safeMint(addresses[i], currentToken);
            currentToken = currentToken + 1;
        }
    }



    // Token URL and Supply Functions - Public

    function tokenURI(uint256 tokenId) override public view returns (string memory) {
        return string(abi.encodePacked(_baseURI(), "", uint256(tokenId).toString()));
    }

    function totalSupply() external view returns (uint256) {
        return currentToken;
    }

    // Setter Functions - onlyOwner

    function triggerSale() public onlyOwner {
        isSale = !isSale;
    }

    function setMetaURI(string memory newURI) external onlyOwner {
        metaUri = newURI;
    }

    function setsupply(uint256 maxxsupply) external onlyOwner {
        maxSupply = maxxsupply;
    }

    function setmintprice(uint256 _price) external onlyOwner {
        price = _price;
    }

    function withdraw() external onlyOwner {
require(payable(0x4794ECE487482a632835D912211C6E9055F11AED).send(address(this).balance));

    }

    // Internal Functions

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

}
function mint(uint256 quantity) public payable {
    require(isSale==true, "Public Sale is Not Active");
    require((currentToken + quantity) <= maxSupply, "Quantity Exceeds Tokens Available");
    require((price * quantity) <= msg.value, "Ether Amount Sent Is Incorrect");
    for (uint256 i = 0; i < quantity; i++) {
        _safeMint(msg.sender, currentToken);
        currentToken = currentToken + 1;
    }
}

// Mint Functions