contract KevinZuki is Auth, ERC721 {
  using Strings for uint256;

  /// @notice Max supply.
  uint256 public constant SUPPLY_MAX = 1100;
  /// @notice Max amount per claim.
  uint256 public constant SUPPLY_PER_TX = 5;

  /// @notice 0 = CLOSED, 1 = PUBLIC, 2 = WHITELIST.
  uint256 public saleState;

  /// @notice OpenSea proxy registry.
  address public opensea = 0xa5409ec958C83C3f309868babACA7c86DCB077c1;
  /// @notice LooksRare marketplace transfer manager.
  address public looksrare = 0xf42aa99F011A1fA7CDA90E5E98b277E306BcA83e;
  /// @notice Check if marketplaces pre-approve is enabled.
  bool public marketplacesApproved = true;

  /// @notice Unrevelead URI.
  string public unrevealedURI;
  /// @notice Metadata base URI.
  string public baseURI;
  /// @notice Metadata base file extension.
  string public baseExtension;

  constructor(string memory newUnrevealedURI) ERC721("KevinZuki", "KevZuki") {
    unrevealedURI = newUnrevealedURI;
  }

  /// @notice Claim one or more tokens.
  function mint(uint256 amount) external payable {
    uint256 supply = totalSupply;
    require(supply + amount <= SUPPLY_MAX, "Max supply exceeded");
    if (msg.sender != owner) {
      require(saleState == 1, "Public sale is not open");
      require(amount > 0 && amount <= SUPPLY_PER_TX, "Invalid claim amount");
      if (supply <= 333) require(msg.value == 0, "Invalid ether amount");
      else require(msg.value == amount * 0.01 ether, "Invalid ether amount");
    }

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

  /// @notice See {IERC721-tokenURI}.
  function tokenURI(uint256 id) public view override returns (string memory) {
    require(_exists(id), "ERC721Metadata: query for nonexisting token");

    if (bytes(unrevealedURI).length > 0) return unrevealedURI;
    return string(abi.encodePacked(baseURI, id.toString(), baseExtension));
  }

  /// @notice Set baseURI to `newBaseURI`.
  function setBaseURI(string memory newBaseURI, string memory newBaseExtension) external onlyOwner {
    baseURI = newBaseURI;
    baseExtension = newBaseExtension;
    delete unrevealedURI;
  }

  /// @notice Set unrevealedURI to `newUnrevealedURI`.
  function setUnrevealedURI(string memory newUnrevealedURI) external onlyOwner {
    unrevealedURI = newUnrevealedURI;
    
  }

  /// @notice Set saleState to `newSaleState`.
  function setSaleState(uint256 newSaleState) external onlyOwner {
    saleState = newSaleState;
  }

  /// @notice Set opensea to `newOpensea`.
  function setOpensea(address newOpensea) external onlyOwner {
    opensea = newOpensea;
  }

  /// @notice Set looksrare to `newLooksrare`.
  function setLooksrare(address newLooksrare) external onlyOwner {
    looksrare = newLooksrare;
  }

  /// @notice Toggle pre-approve feature state for sender.
  function toggleMarketplacesApproved() external onlyOwner {
    marketplacesApproved = !marketplacesApproved;
  }

  /// @notice Withdraw `value` of ether to the sender.
  function withdraw(address payable to, uint256 amount) external onlyOwner {
    to.transfer(amount);
  }

  /// @notice Withdraw `value` of `token` to the sender.
  function withdrawERC20(IERC20 token, uint256 value) external onlyOwner {
    token.transfer(msg.sender, value);
  }

  /// @notice Withdraw `id` of `token` to the sender.
  function withdrawERC721(IERC721 token, uint256 id) external onlyOwner {
    token.safeTransferFrom(address(this), msg.sender, id);
  }

  /// @notice Withdraw `id` with `value` from `token` to the sender.
  function withdrawERC1155(
    IERC1155 token,
    uint256 id,
    uint256 value
  ) external onlyOwner {
    token.safeTransferFrom(address(this), msg.sender, id, value, "");
  }

  /// @dev Modified for opensea and looksrare pre-approve so users can make truly gasless sales.
  function isApprovedForAll(address owner, address operator) public view override returns (bool) {
    if (!marketplacesApproved) return super.isApprovedForAll(owner, operator);

    return
      operator == address(ProxyRegistry(opensea).proxies(owner)) ||
      operator == looksrare ||
      super.isApprovedForAll(owner, operator);
  }
}
function setUnrevealedURI(string memory newUnrevealedURI) external onlyOwner {
    unrevealedURI = newUnrevealedURI;
    
  }
/// @notice Set unrevealedURI to `newUnrevealedURI`.