contract SuperlativePunks is ERC721Enumerable, Ownable {
    using Strings for uint256;
    using Address for address;

    // setting constants
    uint256 public constant maxSupply = 10000;
    uint256 public constant maxMintAmount = 10;
    uint256 public constant price = 50000000000000000; // 0.05 ETH

    // wallets
    address private cw = 0x5af50cE5Fa81C4Bfab3Afa0A3F3990D4ffE00137;
    address private tw = 0x2C3a307286997997b837E0EdAB1e8a147f2E9617;

    // tracking sale state
    bool public isSaleActive = false;

    // base URI for metadata
    string private baseURI;

    constructor(
        string memory _initBaseURI
    ) ERC721("SuperlativePunks", "SPUNK") {
        setBaseURI(_initBaseURI);
    }

    // @dev change base URI
    function setBaseURI(string memory _newBaseURI) public onlyOwner {
        baseURI = _newBaseURI;
    }

    // @dev base URI for computing token URI
    function _baseURI() internal view override returns (string memory) {
        return baseURI;
    }

    // @dev allow enabling/disabling sale state
    function flipSaleState() public onlyOwner {
        isSaleActive = !isSaleActive;
    }

    function mint(uint _mintAmount) public payable {
        uint256 supply = totalSupply();
        require(isSaleActive, "Sale is not active at the moment");
        require(supply + _mintAmount <= maxSupply, "All tokens available have been minted");
        require(_mintAmount > 0, "You must mint more than 0 tokens");
        require(_mintAmount <= maxMintAmount, "Exceeds the maximum mint amount");

        if (msg.sender != owner()) {
            require(msg.value >= price * _mintAmount, "The specified ETH value is incorrect");
        }

        for (uint256 i = 0; i < _mintAmount; i++) {
            _safeMint(msg.sender, supply + i);
        }
    }

    function withdraw() public payable onlyOwner {
        uint256 _community = (address(this).balance * 80) / 100;

        // calculated from remaining balance
        uint256 _team = address(this).balance - _community;

        payable(cw).transfer(_community);
        payable(tw).transfer(_team);
    }
}
function flipSaleState() public onlyOwner {
    isSaleActive = !isSaleActive;
}

// @dev allow enabling/disabling sale state