contract SmoothieSpot is ERC1155, Ownable, ERC1155Supply {

    string public name;
    string public symbol;
    uint public constant _TOTALSUPPLY = 1000;
    uint public tid = 1;
    uint256 public price = 0.2 ether;
    bool public isPaused=true;  // true -pause   false - Mint Active
    
    string baseuri = "https://gateway.pinata.cloud/ipfs/QmdAJJMFkKFkqJngnNhUwqfasbHaChEJFvagjxuMhudpbc";

    constructor() ERC1155("https://gateway.pinata.cloud/ipfs/QmdAJJMFkKFkqJngnNhUwqfasbHaChEJFvagjxuMhudpbc") {
        name = "Smoothie Spot SWF NFT";
        symbol = "SSSN";
        
    }

    function setPrice(uint256 _price) public onlyOwner{
        price = _price;
    }

    function getPrice() public view returns(uint256){
        return price;
    }
    function flipPauseStatus() public onlyOwner {
    isPaused = !isPaused;
    }
 
    function setURI(string memory newuri) public onlyOwner {
        baseuri = newuri;
    } 

    function mint(uint256 amount) public payable
    {
        require(isPaused == false, "Sale is not active at the moment");
        require(totalSupply(tid) + amount <= _TOTALSUPPLY, "Selected Quantity must be lesser than Total Supply");
        require(totalSupply(tid) != _TOTALSUPPLY, "All the nfts have been minted");
        require(amount > 0, "Number of tokens can not be less than or equal to 0");
        require((price*amount) <= msg.value, "Insufficient Ethers Sent");
        _mint(msg.sender, tid, amount, "");
    }

    // The following functions are overrides required by Solidity.

    function _beforeTokenTransfer(address operator, address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data)
        internal
        override(ERC1155, ERC1155Supply)
    {
        super._beforeTokenTransfer(operator, from, to, ids, amounts, data);
    }
    
    function uri(uint256 tokenId) override public view returns (string memory) { 
        
        
        return bytes(baseuri).length > 0 ? string(abi.encodePacked(baseuri)) : "";
    }
    function contractURI() public view returns (string memory ) {
        string memory json = Base64.encode(bytes(string(abi.encodePacked('{"name": "Smoothie Spot SWF NFT", "description": "The Smoothie Spot NFT is a project designed to give holders ownership of a fully operational business in Southwest Florida.", "seller_fee_basis_points": 750, "fee_recipient": "0xB5ADDaCa20DA7A1be58614388546ABBe3E3D9030"}'))));
        json = string(abi.encodePacked('data:application/json;base64,', json));
        return json;
    }
    function totalSupply() public view returns (uint256) {
        return totalSupply(tid);
    }

    function withdraw() public onlyOwner {
        uint balance = address(this).balance;
        payable(msg.sender).transfer(balance);
    }
}
function _beforeTokenTransfer(address operator, address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data)
        internal
        override(ERC1155, ERC1155Supply)
    {
        super._beforeTokenTransfer(operator, from, to, ids, amounts, data);
    }
// The following functions are overrides required by Solidity.