// Contract: CurseWords
// Target function: function getAssholeRankingResults(uint256 tokenId, string memory keyPrefix) private pure returns (uint8)
Transfer(from, to, tokenId);

        // Clear approvals from the previous owner
        _approve(address(0), tokenId);

        _balances[from] -= 1;
        _balances[to] += 1;
        _owners[tokenId] = to;

        emit Transfer(from, to, tokenId);
    }

    /**
     * @dev Approve `to` to operate on `tokenId`
     *
     * Emits a {Approval} event.
     */
    function _approve(address to, uint256 tokenId) internal virtual {
        _tokenApprovals[tokenId] = to;
        emit Approval(ERC721.ownerOf(tokenId), to, tokenId);
    }

    /**
     * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.
     * The call is not executed if the target address is not a contract.
     *
     * @param from address representing the previous owner of the given token ID
     * @param to target address that will receive the tokens
     * @param tokenId uint256 ID of the token to be transferred
     * @param _data bytes optional data to send along with the call
     * @return bool whether the call correctly returned the expected magic value
     */
    function _checkOnERC721Received(
        address from,
        address to,
        uint256 tokenId,
        bytes memory _data
    ) private returns (bool) {
        if (to.isContract()) {
            try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) {
                return retval == IERC721Receiver(to).onERC721Received.selector;
            } catch (bytes memory reason) {
                if (reason.length == 0) {
                    revert("ERC721: transfer to non ERC721Receiver implementer");
                } else {
                    assembly {
                        revert(add(32, reason), mload(reason))
                    }
                }
            }
        } else {
            return true;
        }
    }

    /**
     * @dev Hook that is called before any token transfer. This includes minting
     * and burning.
     *
     * Calling conditions:
     *
     * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be
     * transferred to `to`.
     * - When `from` is zero, `tokenId` will be minted for `to`.
     * - When `to` is zero, ``from``'s `tokenId` will be burned.
     * - `from` and `to` are never both zero.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _beforeTokenTransfer(
        address from,
        address to,
        uint256 tokenId
    ) internal virtual {}
}







/**
 * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension
 * @dev See https://eips.ethereum.org/EIPS/eip-721
 */
interface IERC721Enumerable is IERC721 {
    /**
     * @dev Returns the total amount of tokens stored by the contract.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns a token ID owned by `owner` at a given `index` of its token list.
     * Use along with {balanceOf} to enumerate all of ``owner``'s tokens.
     */
    function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256 tokenId);

    /**
     * @dev Returns a token ID at a given `index` of all the tokens stored by the contract.
     * Use along with {totalSupply} to enumerate all tokens.
     */
    function tokenByIndex(uint256 index) external view returns (uint256);
}


/**
 * @dev This implements an optional extension of {ERC721} defined in the EIP that adds
 * enumerability of all the token ids in the contract as well as all token ids owned by each
 * account.
 */
abstract contract ERC721Enumerable is ERC721, IERC721Enumerable {
    // Mapping from owner to list of owned token IDs
    mapping(address => mapping(uint256 => uint256)) private _ownedTokens;

    // Mapping from token ID to index of the owner tokens list
    mapping(uint256 => uint256) private _ownedTokensIndex;

    // Array with all token ids, used for enumeration
    uint256[] private _allTokens;

    // Mapping from token id to position in the allTokens array
    mapping(uint256 => uint256) private _allTokensIndex;

    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) {
        return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId);
    }

    /**
     * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}.
     */
    function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) {
        require(index < ERC721.balanceOf(owner), "ERC721Enumerable: owner index out of bounds");
        return _ownedTokens[owner][index];
    }

    /**
     * @dev See {IERC721Enumerable-totalSupply}.
     */
    function totalSupply() public view virtual override returns (uint256) {
        return _allTokens.length;
    }

    /**
     * @dev See {IERC721Enumerable-tokenByIndex}.
     */
    function tokenByIndex(uint256 index) public view virtual override returns (uint256) {
        require(index < ERC721Enumerable.totalSupply(), "ERC721Enumerable: global index out of bounds");
        return _allTokens[index];
    }

    /**
     * @dev Hook that is called before any token transfer. This includes minting
     * and burning.
     *
     * Calling conditions:
     *
     * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be
     * transferred to `to`.
     * - When `from` is zero, `tokenId` will be minted for `to`.
     * - When `to` is zero, ``from``'s `tokenId` will be burned.
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _beforeTokenTransfer(
        address from,
        address to,
        uint256 tokenId
    ) internal virtual override {
        super._beforeTokenTransfer(from, to, tokenId);

        if (from == address(0)) {
            _addTokenToAllTokensEnumeration(tokenId);
        } else if (from != to) {
            _removeTokenFromOwnerEnumeration(from, tokenId);
        }
        if (to == address(0)) {
            _removeTokenFromAllTokensEnumeration(tokenId);
        } else if (to != from) {
            _addTokenToOwnerEnumeration(to, tokenId);
        }
    }

    /**
     * @dev Private function to add a token to this extension's ownership-tracking data structures.
     * @param to address representing the new owner of the given token ID
     * @param tokenId uint256 ID of the token to be added to the tokens list of the given address
     */
    function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private {
        uint256 length = ERC721.balanceOf(to);
        _ownedTokens[to][length] = tokenId;
        _ownedTokensIndex[tokenId] = length;
    }

    /**
     * @dev Private function to add a token to this extension's token tracking data structures.
     * @param tokenId uint256 ID of the token to be added to the tokens list
     */
    function _addTokenToAllTokensEnumeration(uint256 tokenId) private {
        _allTokensIndex[tokenId] = _allTokens.length;
        _allTokens.push(tokenId);
    }

    /**
     * @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that
     * while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for
     * gas optimizations e.g. when performing a transfer operation (avoiding double writes).
     * This has O(1) time complexity, but alters the order of the _ownedTokens array.
     * @param from address representing the previous owner of the given token ID
     * @param tokenId uint256 ID of the token to be removed from the tokens list of the given address
     */
    function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private {
        // To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and
        // then delete the last slot (swap and pop).

        uint256 lastTokenIndex = ERC721.balanceOf(from) - 1;
        uint256 tokenIndex = _ownedTokensIndex[tokenId];

        // When the token to delete is the last token, the swap operation is unnecessary
        if (tokenIndex != lastTokenIndex) {
            uint256 lastTokenId = _ownedTokens[from][lastTokenIndex];

            _ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token
            _ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index
        }

        // This also deletes the contents at the last position of the array
        delete _ownedTokensIndex[tokenId];
        delete _ownedTokens[from][lastTokenIndex];
    }

    /**
     * @dev Private function to remove a token from this extension's token tracking data structures.
     * This has O(1) time complexity, but alters the order of the _allTokens array.
     * @param tokenId uint256 ID of the token to be removed from the tokens list
     */
    function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private {
        // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and
        // then delete the last slot (swap and pop).

        uint256 lastTokenIndex = _allTokens.length - 1;
        uint256 tokenIndex = _allTokensIndex[tokenId];

        // When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so
        // rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding
        // an 'if' statement (like in _removeTokenFromOwnerEnumeration)
        uint256 lastTokenId = _allTokens[lastTokenIndex];

        _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token
        _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index

        // This also deletes the contents at the last position of the array
        delete _allTokensIndex[tokenId];
        _allTokens.pop();
    }
}

    function uint2str(uint256 _i) pure returns (string memory str) {
      if (_i == 0) {
        return "0";
      }
      uint256 j = _i;
      uint256 length;
      while (j != 0) {
        length++;
        j /= 10;
      }
      bytes memory bstr = new bytes(length);
      uint256 k = length;
      j = _i;
      while (j != 0) {
        bstr[--k] = bytes1(uint8(48 + j % 10));
        j /= 10;
      }
      str = string(bstr);
    }


// if you're reading this fuck you, 69
contract CurseWords is ERC721Enumerable, ReentrancyGuard, Ownable {
    // from: https://github.com/GNSPS/solidity-bytes-utils/blob/master/contracts/BytesLib.sol 
    function toUint8(bytes memory _bytes, uint256 _start) internal pure returns (uint8) {
        require(_start + 1 >= _start, "toUint8_overflow");
        require(_bytes.length >= _start + 1 , "toUint8_outOfBounds");
        uint8 tempUint;

        assembly {
            tempUint := mload(add(add(_bytes, 0x1), _start))
        }

        return tempUint;
    }
    
    uint256 public constant MINT_PRICE = 4269000000000000; //0.004269 ETH, guess i'll give it to you if you can ctrl-f
    
    string private mainKey = "CURSE";
    string private auxKey = "AUXCURSE";

    
    string [] private rarity = [
        "base",
        "modified",
        "rare",
        "hurtful base",
        "hurtful modified"
    ];

    string[][] private curseSuiteTM = [
        // base words
        [
            string("fuck"),
            string("shit"),
            string("piss"),
            string("ass"),
            string("bitch"),
            string("cunt"),
            string("dick")
        ],
        // modified words
        [
            string("motherfucker"),
            string("shithead"),
            string("piss baby"),
            string("asshole"),
            string("bad bitch"),
            string("cuntface"),
            string("dickhead")
        ],
        // rare words
        [        
            string("bad dude"),
            string("not nice!"),
            string("say sorry"),
            string("you made me cry"),
            string("i want to puke"),
            string("thot we were frnieds :("),
            string("please say sike")
        ],
        // hurtful base words
        [
            string("you fuck"),
            string("shit!"),
            string("piss off!"),
            string("you ass"),
            string("you bitch"),
            string("you cunt"),
            string("you dick")
        ],
        // hurtful modified words
        [
            string("you motherfucker"),
            string("you shithead"),
            string("you piss baby"),
            string("you asshole"),
            string("you bad bitch"),
            string("you cuntface"),
            string("you dickhead")
        ]
    ];

    string[] private colors = [
        "EF476F",
        "FFD166",
        "06D6A0",
        "118AB2",
        "073B4C"
    ];
    
    string[] private backgroundColors = [
        "000000",
        "000000",
        "000000",
        "000000",
        "ffffff",
        "ffffff",
        "6c70ad",
        "aba3a6"
    ];
    
    string[] private sizes = [
        "42",
        "42",
        "42",
        "42",
        "69",
        "69",
        "69",
        "69",
        "71",
        "88",
        "100",
        "420"
    ];
    
    string[] private auxSizes = [
        "500",
        "25",
        "25",
        "25",
        "16",
        "16",
        "16",
        "16",
        "14",
        "12",
        "5"
    ];
    
    string[] private fonts = [
        "arial",
        "serif",
        "sans-serif",
        "cursive",
        "fantasy",
        "fantasy",
        "monospace"
    ];
    
    string[] private fontMods = [
        "normal",
        "normal",
        "normal",
        "normal",
        "normal",
        "italic"
    ];

    string private rarestCurseWord = "*****"; // so rare you can't have it bby sowwy :'(
    
    function random(string memory input) internal pure returns (uint256) {
        return uint256(keccak256(abi.encodePacked(input)));
    }
    
    function getCurseWord(uint256 tokenId) public view returns (string memory) {
        return multipluck(tokenId, mainKey, curseSuiteTM);
    }

    function getAuxCurseWord(uint256 tokenId) public view returns (string memory) {
        return multipluck(tokenId, auxKey, curseSuiteTM);
    }

    function getPrimaryColor(uint256 tokenId) public view returns (string memory) {
        return pluck(tokenId, "COLOR", colors);
    }

    function getAuxColor(uint256 tokenId) public view returns (string memory) {
        return pluck(tokenId, "AUXCOLOR", colors);
    }
    
    function getPrimarySize(uint256 tokenId) public view returns (string memory) {
        return pluck(tokenId, "SIZE", sizes);
    }
    
    function getAuxSize(uint256 tokenId) public view returns (string memory) {
        return pluck(tokenId, "AUXSIZE", auxSizes);
    }
    
    function getPrimaryFont(uint256 tokenId) public view returns (string memory) {
        return pluck(tokenId, "FONT", fonts);
    }
    
    function getAuxFont(uint256 tokenId) public view returns (string memory) {
        return pluck(tokenId, "AUXFONT", fonts);
    }
    
    function getPrimaryFontModifier(uint256 tokenId) public view returns (string memory) {
        return pluck(tokenId, "AUXFONT", fontMods);
    }
    
    function getPrimaryWordRarity(uint256 tokenId) public view returns (string memory) {
        uint8 index = getAssholeRankingResults(tokenId, mainKey);
        return rarity[index];
    }
    
    function getAuxWordRarity(uint256 tokenId) public view returns (string memory) {
        uint8 index = getAssholeRankingResults(tokenId, auxKey);
        return rarity[index];
    }
    
    function getBackgroundColor(uint256 tokenId) public view returns (string memory) {
        return pluck(tokenId, "BCOLOR", backgroundColors);
    }