creation_sourcecode: {{
    "language": "Solidity",
    "sources": {
      "@openzeppelin/contracts/interfaces/draft-IERC6093.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/draft-IERC6093.sol)\npragma solidity ^0.8.20;\n\n/**\n * @dev Standard ERC20 Errors\n * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC20 tokens.\n */\ninterface IERC20Errors {\n    /**\n     * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.\n     * @param sender Address whose tokens are being transferred.\n     * @param balance Current balance for the interacting account.\n     * @param needed Minimum amount required to perform a transfer.\n     */\n    error ERC20InsufficientBalance(address sender, uint256 balance, uint256 needed);\n\n    /**\n     * @dev Indicates a failure with the token `sender`. Used in transfers.\n     * @param sender Address whose tokens are being transferred.\n     */\n    error ERC20InvalidSender(address sender);\n\n    /**\n     * @dev Indicates a failure with the token `receiver`. Used in transfers.\n     * @param receiver Address to which tokens are being transferred.\n     */\n    error ERC20InvalidReceiver(address receiver);\n\n    /**\n     * @dev Indicates a failure with the `spender`’s `allowance`. Used in transfers.\n     * @param spender Address that may be allowed to operate on tokens without being their owner.\n     * @param allowance Amount of tokens a `spender` is allowed to operate with.\n     * @param needed Minimum amount required to perform a transfer.\n     */\n    error ERC20InsufficientAllowance(address spender, uint256 allowance, uint256 needed);\n\n    /**\n     * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.\n     * @param approver Address initiating an approval operation.\n     */\n    error ERC20InvalidApprover(address approver);\n\n    /**\n     * @dev Indicates a failure with the `spender` to be approved. Used in approvals.\n     * @param spender Address that may be allowed to operate on tokens without being their owner.\n     */\n    error ERC20InvalidSpender(address spender);\n}\n\n/**\n * @dev Standard ERC721 Errors\n * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC721 tokens.\n */\ninterface IERC721Errors {\n    /**\n     * @dev Indicates that an address can't be an owner. For example, `address(0)` is a forbidden owner in EIP-20.\n     * Used in balance queries.\n     * @param owner Address of the current owner of a token.\n     */\n    error ERC721InvalidOwner(address owner);\n\n    /**\n     * @dev Indicates a `tokenId` whose `owner` is the zero address.\n     * @param tokenId Identifier number of a token.\n     */\n    error ERC721NonexistentToken(uint256 tokenId);\n\n    /**\n     * @dev Indicates an error related to the ownership over a particular token. Used in transfers.\n     * @param sender Address whose tokens are being transferred.\n     * @param tokenId Identifier number of a token.\n     * @param owner Address of the current owner of a token.\n     */\n    error ERC721IncorrectOwner(address sender, uint256 tokenId, address owner);\n\n    /**\n     * @dev Indicates a failure with the token `sender`. Used in transfers.\n     * @param sender Address whose tokens are being transferred.\n     */\n    error ERC721InvalidSender(address sender);\n\n    /**\n     * @dev Indicates a failure with the token `receiver`. Used in transfers.\n     * @param receiver Address to which tokens are being transferred.\n     */\n    error ERC721InvalidReceiver(address receiver);\n\n    /**\n     * @dev Indicates a failure with the `operator`’s approval. Used in transfers.\n     * @param operator Address that may be allowed to operate on tokens without being their owner.\n     * @param tokenId Identifier number of a token.\n     */\n    error ERC721InsufficientApproval(address operator, uint256 tokenId);\n\n    /**\n     * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.\n     * @param approver Address initiating an approval operation.\n     */\n    error ERC721InvalidApprover(address approver);\n\n    /**\n     * @dev Indicates a failure with the `operator` to be approved. Used in approvals.\n     * @param operator Address that may be allowed to operate on tokens without being their owner.\n     */\n    error ERC721InvalidOperator(address operator);\n}\n\n/**\n * @dev Standard ERC1155 Errors\n * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC1155 tokens.\n */\ninterface IERC1155Errors {\n    /**\n     * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.\n     * @param sender Address whose tokens are being transferred.\n     * @param balance Current balance for the interacting account.\n     * @param needed Minimum amount required to perform a transfer.\n     * @param tokenId Identifier number of a token.\n     */\n    error ERC1155InsufficientBalance(address sender, uint256 balance, uint256 needed, uint256 tokenId);\n\n    /**\n     * @dev Indicates a failure with the token `sender`. Used in transfers.\n     * @param sender Address whose tokens are being transferred.\n     */\n    error ERC1155InvalidSender(address sender);\n\n    /**\n     * @dev Indicates a failure with the token `receiver`. Used in transfers.\n     * @param receiver Address to which tokens are being transferred.\n     */\n    error ERC1155InvalidReceiver(address receiver);\n\n    /**\n     * @dev Indicates a failure with the `operator`’s approval. Used in transfers.\n     * @param operator Address that may be allowed to operate on tokens without being their owner.\n     * @param owner Address of the current owner of a token.\n     */\n    error ERC1155MissingApprovalForAll(address operator, address owner);\n\n    /**\n     * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.\n     * @param approver Address initiating an approval operation.\n     */\n    error ERC1155InvalidApprover(address approver);\n\n    /**\n     * @dev Indicates a failure with the `operator` to be approved. Used in approvals.\n     * @param operator Address that may be allowed to operate on tokens without being their owner.\n     */\n    error ERC1155InvalidOperator(address operator);\n\n    /**\n     * @dev Indicates an array length mismatch between ids and values in a safeBatchTransferFrom operation.\n     * Used in batch transfers.\n     * @param idsLength Length of the array of token identifiers\n     * @param valuesLength Length of the array of token amounts\n     */\n    error ERC1155InvalidArrayLength(uint256 idsLength, uint256 valuesLength);\n}\n"
      },
      "@openzeppelin/contracts/token/ERC20/extensions/IERC20Permit.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Permit.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n *\n * ==== Security Considerations\n *\n * There are two important considerations concerning the use of `permit`. The first is that a valid permit signature\n * expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be\n * considered as an intention to spend the allowance in any specific way. The second is that because permits have\n * built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should\n * take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be\n * generally recommended is:\n *\n * ```solidity\n * function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public {\n *     try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}\n *     doThing(..., value);\n * }\n *\n * function doThing(..., uint256 value) public {\n *     token.safeTransferFrom(msg.sender, address(this), value);\n *     ...\n * }\n * ```\n *\n * Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of\n * `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also\n * {SafeERC20-safeTransferFrom}).\n *\n * Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so\n * contracts should have entry points that don't rely on permit.\n */\ninterface IERC20Permit {\n    /**\n     * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\n     * given ``owner``'s signed approval.\n     *\n     * IMPORTANT: The same issues {IERC20-approve} has related to transaction\n     * ordering also apply here.\n     *\n     * Emits an {Approval} event.\n     *\n     * Requirements:\n     *\n     * - `spender` cannot be the zero address.\n     * - `deadline` must be a timestamp in the future.\n     * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\n     * over the EIP712-formatted function arguments.\n     * - the signature must use ``owner``'s current nonce (see {nonces}).\n     *\n     * For more information on the signature format, see the\n     * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\n     * section].\n     *\n     * CAUTION: See Security Considerations above.\n     */\n    function permit(\n        address owner,\n        address spender,\n        uint256 value,\n        uint256 deadline,\n        uint8 v,\n        bytes32 r,\n        bytes32 s\n    ) external;\n\n    /**\n     * @dev Returns the current nonce for `owner`. This value must be\n     * included whenever a signature is generated for {permit}.\n     *\n     * Every successful call to {permit} increases ``owner``'s nonce by one. This\n     * prevents a signature from being used multiple times.\n     */\n    function nonces(address owner) external view returns (uint256);\n\n    /**\n     * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\n     */\n    // solhint-disable-next-line func-name-mixedcase\n    function DOMAIN_SEPARATOR() external view returns (bytes32);\n}\n"
      },
      "@openzeppelin/contracts/token/ERC20/IERC20.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20 {\n    /**\n     * @dev Emitted when `value` tokens are moved from one account (`from`) to\n     * another (`to`).\n     *\n     * Note that `value` may be zero.\n     */\n    event Transfer(address indexed from, address indexed to, uint256 value);\n\n    /**\n     * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n     * a call to {approve}. `value` is the new allowance.\n     */\n    event Approval(address indexed owner, address indexed spender, uint256 value);\n\n    /**\n     * @dev Returns the value of tokens in existence.\n     */\n    function totalSupply() external view returns (uint256);\n\n    /**\n     * @dev Returns the value of tokens owned by `account`.\n     */\n    function balanceOf(address account) external view returns (uint256);\n\n    /**\n     * @dev Moves a `value` amount of tokens from the caller's account to `to`.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * Emits a {Transfer} event.\n     */\n    function transfer(address to, uint256 value) external returns (bool);\n\n    /**\n     * @dev Returns the remaining number of tokens that `spender` will be\n     * allowed to spend on behalf of `owner` through {transferFrom}. This is\n     * zero by default.\n     *\n     * This value changes when {approve} or {transferFrom} are called.\n     */\n    function allowance(address owner, address spender) external view returns (uint256);\n\n    /**\n     * @dev Sets a `value` amount of tokens as the allowance of `spender` over the\n     * caller's tokens.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * IMPORTANT: Beware that changing an allowance with this method brings the risk\n     * that someone may use both the old and the new allowance by unfortunate\n     * transaction ordering. One possible solution to mitigate this race\n     * condition is to first reduce the spender's allowance to 0 and set the\n     * desired value afterwards:\n     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n     *\n     * Emits an {Approval} event.\n     */\n    function approve(address spender, uint256 value) external returns (bool);\n\n    /**\n     * @dev Moves a `value` amount of tokens from `from` to `to` using the\n     * allowance mechanism. `value` is then deducted from the caller's\n     * allowance.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * Emits a {Transfer} event.\n     */\n    function transferFrom(address from, address to, uint256 value) external returns (bool);\n}\n"
      },
      "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/utils/SafeERC20.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC20} from \"../IERC20.sol\";\nimport {IERC20Permit} from \"../extensions/IERC20Permit.sol\";\nimport {Address} from \"../../../utils/Address.sol\";\n\n/**\n * @title SafeERC20\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\n * contract returns false). Tokens that return no value (and instead revert or\n * throw on failure) are also supported, non-reverting calls are assumed to be\n * successful.\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\n */\nlibrary SafeERC20 {\n    using Address for address;\n\n    /**\n     * @dev An operation with an ERC20 token failed.\n     */\n    error SafeERC20FailedOperation(address token);\n\n    /**\n     * @dev Indicates a failed `decreaseAllowance` request.\n     */\n    error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease);\n\n    /**\n     * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,\n     * non-reverting calls are assumed to be successful.\n     */\n    function safeTransfer(IERC20 token, address to, uint256 value) internal {\n        _callOptionalReturn(token, abi.encodeCall(token.transfer, (to, value)));\n    }\n\n    /**\n     * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the\n     * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.\n     */\n    function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {\n        _callOptionalReturn(token, abi.encodeCall(token.transferFrom, (from, to, value)));\n    }\n\n    /**\n     * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,\n     * non-reverting calls are assumed to be successful.\n     */\n    function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {\n        uint256 oldAllowance = token.allowance(address(this), spender);\n        forceApprove(token, spender, oldAllowance + value);\n    }\n\n    /**\n     * @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no\n     * value, non-reverting calls are assumed to be successful.\n     */\n    function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal {\n        unchecked {\n            uint256 currentAllowance = token.allowance(address(this), spender);\n            if (currentAllowance < requestedDecrease) {\n                revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease);\n            }\n            forceApprove(token, spender, currentAllowance - requestedDecrease);\n        }\n    }\n\n    /**\n     * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,\n     * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval\n     * to be set to zero before setting it to a non-zero value, such as USDT.\n     */\n    function forceApprove(IERC20 token, address spender, uint256 value) internal {\n        bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value));\n\n        if (!_callOptionalReturnBool(token, approvalCall)) {\n            _callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0)));\n            _callOptionalReturn(token, approvalCall);\n        }\n    }\n\n    /**\n     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\n     * on the return value: the return value is optional (but if data is returned, it must not be false).\n     * @param token The token targeted by the call.\n     * @param data The call data (encoded using abi.encode or one of its variants).\n     */\n    function _callOptionalReturn(IERC20 token, bytes memory data) private {\n        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n        // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that\n        // the target address contains contract code and also asserts for success in the low-level call.\n\n        bytes memory returndata = address(token).functionCall(data);\n        if (returndata.length != 0 && !abi.decode(returndata, (bool))) {\n            revert SafeERC20FailedOperation(address(token));\n        }\n    }\n\n    /**\n     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\n     * on the return value: the return value is optional (but if data is returned, it must not be false).\n     * @param token The token targeted by the call.\n     * @param data The call data (encoded using abi.encode or one of its variants).\n     *\n     * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.\n     */\n    function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {\n        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n        // we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false\n        // and not revert is the subcall reverts.\n\n        (bool success, bytes memory returndata) = address(token).call(data);\n        return success && (returndata.length == 0 || abi.decode(returndata, (bool))) && address(token).code.length > 0;\n    }\n}\n"
      },
      "@openzeppelin/contracts/token/ERC721/ERC721.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/ERC721.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC721} from \"./IERC721.sol\";\nimport {IERC721Receiver} from \"./IERC721Receiver.sol\";\nimport {IERC721Metadata} from \"./extensions/IERC721Metadata.sol\";\nimport {Context} from \"../../utils/Context.sol\";\nimport {Strings} from \"../../utils/Strings.sol\";\nimport {IERC165, ERC165} from \"../../utils/introspection/ERC165.sol\";\nimport {IERC721Errors} from \"../../interfaces/draft-IERC6093.sol\";\n\n/**\n * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including\n * the Metadata extension, but not including the Enumerable extension, which is available separately as\n * {ERC721Enumerable}.\n */\nabstract contract ERC721 is Context, ERC165, IERC721, IERC721Metadata, IERC721Errors {\n    using Strings for uint256;\n\n    // Token name\n    string private _name;\n\n    // Token symbol\n    string private _symbol;\n\n    mapping(uint256 tokenId => address) private _owners;\n\n    mapping(address owner => uint256) private _balances;\n\n    mapping(uint256 tokenId => address) private _tokenApprovals;\n\n    mapping(address owner => mapping(address operator => bool)) private _operatorApprovals;\n\n    /**\n     * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.\n     */\n    constructor(string memory name_, string memory symbol_) {\n        _name = name_;\n        _symbol = symbol_;\n    }\n\n    /**\n     * @dev See {IERC165-supportsInterface}.\n     */\n    function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {\n        return\n            interfaceId == type(IERC721).interfaceId ||\n            interfaceId == type(IERC721Metadata).interfaceId ||\n            super.supportsInterface(interfaceId);\n    }\n\n    /**\n     * @dev See {IERC721-balanceOf}.\n     */\n    function balanceOf(address owner) public view virtual returns (uint256) {\n        if (owner == address(0)) {\n            revert ERC721InvalidOwner(address(0));\n        }\n        return _balances[owner];\n    }\n\n    /**\n     * @dev See {IERC721-ownerOf}.\n     */\n    function ownerOf(uint256 tokenId) public view virtual returns (address) {\n        return _requireOwned(tokenId);\n    }\n\n    /**\n     * @dev See {IERC721Metadata-name}.\n     */\n    function name() public view virtual returns (string memory) {\n        return _name;\n    }\n\n    /**\n     * @dev See {IERC721Metadata-symbol}.\n     */\n    function symbol() public view virtual returns (string memory) {\n        return _symbol;\n    }\n\n    /**\n     * @dev See {IERC721Metadata-tokenURI}.\n     */\n    function tokenURI(uint256 tokenId) public view virtual returns (string memory) {\n        _requireOwned(tokenId);\n\n        string memory baseURI = _baseURI();\n        return bytes(baseURI).length > 0 ? string.concat(baseURI, tokenId.toString()) : \"\";\n    }\n\n    /**\n     * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each\n     * token will be the concatenation of the `baseURI` and the `tokenId`. Empty\n     * by default, can be overridden in child contracts.\n     */\n    function _baseURI() internal view virtual returns (string memory) {\n        return \"\";\n    }\n\n    /**\n     * @dev See {IERC721-approve}.\n     */\n    function approve(address to, uint256 tokenId) public virtual {\n        _approve(to, tokenId, _msgSender());\n    }\n\n    /**\n     * @dev See {IERC721-getApproved}.\n     */\n    function getApproved(uint256 tokenId) public view virtual returns (address) {\n        _requireOwned(tokenId);\n\n        return _getApproved(tokenId);\n    }\n\n    /**\n     * @dev See {IERC721-setApprovalForAll}.\n     */\n    function setApprovalForAll(address operator, bool approved) public virtual {\n        _setApprovalForAll(_msgSender(), operator, approved);\n    }\n\n    /**\n     * @dev See {IERC721-isApprovedForAll}.\n     */\n    function isApprovedForAll(address owner, address operator) public view virtual returns (bool) {\n        return _operatorApprovals[owner][operator];\n    }\n\n    /**\n     * @dev See {IERC721-transferFrom}.\n     */\n    function transferFrom(address from, address to, uint256 tokenId) public virtual {\n        if (to == address(0)) {\n            revert ERC721InvalidReceiver(address(0));\n        }\n        // Setting an \"auth\" arguments enables the `_isAuthorized` check which verifies that the token exists\n        // (from != 0). Therefore, it is not needed to verify that the return value is not 0 here.\n        address previousOwner = _update(to, tokenId, _msgSender());\n        if (previousOwner != from) {\n            revert ERC721IncorrectOwner(from, tokenId, previousOwner);\n        }\n    }\n\n    /**\n     * @dev See {IERC721-safeTransferFrom}.\n     */\n    function safeTransferFrom(address from, address to, uint256 tokenId) public {\n        safeTransferFrom(from, to, tokenId, \"\");\n    }\n\n    /**\n     * @dev See {IERC721-safeTransferFrom}.\n     */\n    function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory data) public virtual {\n        transferFrom(from, to, tokenId);\n        _checkOnERC721Received(from, to, tokenId, data);\n    }\n\n    /**\n     * @dev Returns the owner of the `tokenId`. Does NOT revert if token doesn't exist\n     *\n     * IMPORTANT: Any overrides to this function that add ownership of tokens not tracked by the\n     * core ERC721 logic MUST be matched with the use of {_increaseBalance} to keep balances\n     * consistent with ownership. The invariant to preserve is that for any address `a` the value returned by\n     * `balanceOf(a)` must be equal to the number of tokens such that `_ownerOf(tokenId)` is `a`.\n     */\n    function _ownerOf(uint256 tokenId) internal view virtual returns (address) {\n        return _owners[tokenId];\n    }\n\n    /**\n     * @dev Returns the approved address for `tokenId`. Returns 0 if `tokenId` is not minted.\n     */\n    function _getApproved(uint256 tokenId) internal view virtual returns (address) {\n        return _tokenApprovals[tokenId];\n    }\n\n    /**\n     * @dev Returns whether `spender` is allowed to manage `owner`'s tokens, or `tokenId` in\n     * particular (ignoring whether it is owned by `owner`).\n     *\n     * WARNING: This function assumes that `owner` is the actual owner of `tokenId` and does not verify this\n     * assumption.\n     */\n    function _isAuthorized(address owner, address spender, uint256 tokenId) internal view virtual returns (bool) {\n        return\n            spender != address(0) &&\n            (owner == spender || isApprovedForAll(owner, spender) || _getApproved(tokenId) == spender);\n    }\n\n    /**\n     * @dev Checks if `spender` can operate on `tokenId`, assuming the provided `owner` is the actual owner.\n     * Reverts if `spender` does not have approval from the provided `owner` for the given token or for all its assets\n     * the `spender` for the specific `tokenId`.\n     *\n     * WARNING: This function assumes that `owner` is the actual owner of `tokenId` and does not verify this\n     * assumption.\n     */\n    function _checkAuthorized(address owner, address spender, uint256 tokenId) internal view virtual {\n        if (!_isAuthorized(owner, spender, tokenId)) {\n            if (owner == address(0)) {\n                revert ERC721NonexistentToken(tokenId);\n            } else {\n                revert ERC721InsufficientApproval(spender, tokenId);\n            }\n        }\n    }\n\n    /**\n     * @dev Unsafe write access to the balances, used by extensions that \"mint\" tokens using an {ownerOf} override.\n     *\n     * NOTE: the value is limited to type(uint128).max. This protect against _balance overflow. It is unrealistic that\n     * a uint256 would ever overflow from increments when these increments are bounded to uint128 values.\n     *\n     * WARNING: Increasing an account's balance using this function tends to be paired with an override of the\n     * {_ownerOf} function to resolve the ownership of the corresponding tokens so that balances and ownership\n     * remain consistent with one another.\n     */\n    function _increaseBalance(address account, uint128 value) internal virtual {\n        unchecked {\n            _balances[account] += value;\n        }\n    }\n\n    /**\n     * @dev Transfers `tokenId` from its current owner to `to`, or alternatively mints (or burns) if the current owner\n     * (or `to`) is the zero address. Returns the owner of the `tokenId` before the update.\n     *\n     * The `auth` argument is optional. If the value passed is non 0, then this function will check that\n     * `auth` is either the owner of the token, or approved to operate on the token (by the owner).\n     *\n     * Emits a {Transfer} event.\n     *\n     * NOTE: If overriding this function in a way that tracks balances, see also {_increaseBalance}.\n     */\n    function _update(address to, uint256 tokenId, address auth) internal virtual returns (address) {\n        address from = _ownerOf(tokenId);\n\n        // Perform (optional) operator check\n        if (auth != address(0)) {\n            _checkAuthorized(from, auth, tokenId);\n        }\n\n        // Execute the update\n        if (from != address(0)) {\n            // Clear approval. No need to re-authorize or emit the Approval event\n            _approve(address(0), tokenId, address(0), false);\n\n            unchecked {\n                _balances[from] -= 1;\n            }\n        }\n\n        if (to != address(0)) {\n            unchecked {\n                _balances[to] += 1;\n            }\n        }\n\n        _owners[tokenId] = to;\n\n        emit Transfer(from, to, tokenId);\n\n        return from;\n    }\n\n    /**\n     * @dev Mints `tokenId` and transfers it to `to`.\n     *\n     * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible\n     *\n     * Requirements:\n     *\n     * - `tokenId` must not exist.\n     * - `to` cannot be the zero address.\n     *\n     * Emits a {Transfer} event.\n     */\n    function _mint(address to, uint256 tokenId) internal {\n        \n        if (to == address(0)) {\n            revert ERC721InvalidReceiver(address(0));\n        }\n        address previousOwner = _update(to, tokenId, address(0));\n\n        if (previousOwner != address(0)) {\n            revert ERC721InvalidSender(address(0));\n        }\n    }\n\n    /**\n     * @dev Mints `tokenId`, transfers it to `to` and checks for `to` acceptance.\n     *\n     * Requirements:\n     *\n     * - `tokenId` must not exist.\n     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n     *\n     * Emits a {Transfer} event.\n     */\n    function _safeMint(address to, uint256 tokenId) internal {\n        _safeMint(to, tokenId, \"\");\n    }\n\n    /**\n     * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is\n     * forwarded in {IERC721Receiver-onERC721Received} to contract recipients.\n     */\n    function _safeMint(address to, uint256 tokenId, bytes memory data) internal virtual {\n        _mint(to, tokenId);\n        _checkOnERC721Received(address(0), to, tokenId, data);\n    }\n\n    /**\n     * @dev Destroys `tokenId`.\n     * The approval is cleared when the token is burned.\n     * This is an internal function that does not check if the sender is authorized to operate on the token.\n     *\n     * Requirements:\n     *\n     * - `tokenId` must exist.\n     *\n     * Emits a {Transfer} event.\n     */\n    function _burn(uint256 tokenId) internal {\n        address previousOwner = _update(address(0), tokenId, address(0));\n        if (previousOwner == address(0)) {\n            revert ERC721NonexistentToken(tokenId);\n        }\n    }\n\n    /**\n     * @dev Transfers `tokenId` from `from` to `to`.\n     *  As opposed to {transferFrom}, this imposes no restrictions on msg.sender.\n     *\n     * Requirements:\n     *\n     * - `to` cannot be the zero address.\n     * - `tokenId` token must be owned by `from`.\n     *\n     * Emits a {Transfer} event.\n     */\n    function _transfer(address from, address to, uint256 tokenId) internal {\n        if (to == address(0)) {\n            revert ERC721InvalidReceiver(address(0));\n        }\n        address previousOwner = _update(to, tokenId, address(0));\n        if (previousOwner == address(0)) {\n            revert ERC721NonexistentToken(tokenId);\n        } else if (previousOwner != from) {\n            revert ERC721IncorrectOwner(from, tokenId, previousOwner);\n        }\n    }\n\n    /**\n     * @dev Safely transfers `tokenId` token from `from` to `to`, checking that contract recipients\n     * are aware of the ERC721 standard to prevent tokens from being forever locked.\n     *\n     * `data` is additional data, it has no specified format and it is sent in call to `to`.\n     *\n     * This internal function is like {safeTransferFrom} in the sense that it invokes\n     * {IERC721Receiver-onERC721Received} on the receiver, and can be used to e.g.\n     * implement alternative mechanisms to perform token transfer, such as signature-based.\n     *\n     * Requirements:\n     *\n     * - `tokenId` token must exist and be owned by `from`.\n     * - `to` cannot be the zero address.\n     * - `from` cannot be the zero address.\n     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n     *\n     * Emits a {Transfer} event.\n     */\n    function _safeTransfer(address from, address to, uint256 tokenId) internal {\n        _safeTransfer(from, to, tokenId, \"\");\n    }\n\n    /**\n     * @dev Same as {xref-ERC721-_safeTransfer-address-address-uint256-}[`_safeTransfer`], with an additional `data` parameter which is\n     * forwarded in {IERC721Receiver-onERC721Received} to contract recipients.\n     */\n    function _safeTransfer(address from, address to, uint256 tokenId, bytes memory data) internal virtual {\n        _transfer(from, to, tokenId);\n        _checkOnERC721Received(from, to, tokenId, data);\n    }\n\n    /**\n     * @dev Approve `to` to operate on `tokenId`\n     *\n     * The `auth` argument is optional. If the value passed is non 0, then this function will check that `auth` is\n     * either the owner of the token, or approved to operate on all tokens held by this owner.\n     *\n     * Emits an {Approval} event.\n     *\n     * Overrides to this logic should be done to the variant with an additional `bool emitEvent` argument.\n     */\n    function _approve(address to, uint256 tokenId, address auth) internal {\n        _approve(to, tokenId, auth, true);\n    }\n\n    /**\n     * @dev Variant of `_approve` with an optional flag to enable or disable the {Approval} event. The event is not\n     * emitted in the context of transfers.\n     */\n    function _approve(address to, uint256 tokenId, address auth, bool emitEvent) internal virtual {\n        // Avoid reading the owner unless necessary\n        if (emitEvent || auth != address(0)) {\n            address owner = _requireOwned(tokenId);\n\n            // We do not use _isAuthorized because single-token approvals should not be able to call approve\n            if (auth != address(0) && owner != auth && !isApprovedForAll(owner, auth)) {\n                revert ERC721InvalidApprover(auth);\n            }\n\n            if (emitEvent) {\n                emit Approval(owner, to, tokenId);\n            }\n        }\n\n        _tokenApprovals[tokenId] = to;\n    }\n\n    /**\n     * @dev Approve `operator` to operate on all of `owner` tokens\n     *\n     * Requirements:\n     * - operator can't be the address zero.\n     *\n     * Emits an {ApprovalForAll} event.\n     */\n    function _setApprovalForAll(address owner, address operator, bool approved) internal virtual {\n        if (operator == address(0)) {\n            revert ERC721InvalidOperator(operator);\n        }\n        _operatorApprovals[owner][operator] = approved;\n        emit ApprovalForAll(owner, operator, approved);\n    }\n\n    /**\n     * @dev Reverts if the `tokenId` doesn't have a current owner (it hasn't been minted, or it has been burned).\n     * Returns the owner.\n     *\n     * Overrides to ownership logic should be done to {_ownerOf}.\n     */\n    function _requireOwned(uint256 tokenId) internal view returns (address) {\n        address owner = _ownerOf(tokenId);\n        if (owner == address(0)) {\n            revert ERC721NonexistentToken(tokenId);\n        }\n        return owner;\n    }\n\n    /**\n     * @dev Private function to invoke {IERC721Receiver-onERC721Received} on a target address. This will revert if the\n     * recipient doesn't accept the token transfer. The call is not executed if the target address is not a contract.\n     *\n     * @param from address representing the previous owner of the given token ID\n     * @param to target address that will receive the tokens\n     * @param tokenId uint256 ID of the token to be transferred\n     * @param data bytes optional data to send along with the call\n     */\n    function _checkOnERC721Received(address from, address to, uint256 tokenId, bytes memory data) private {\n        if (to.code.length > 0) {\n            try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, data) returns (bytes4 retval) {\n                if (retval != IERC721Receiver.onERC721Received.selector) {\n                    revert ERC721InvalidReceiver(to);\n                }\n            } catch (bytes memory reason) {\n                if (reason.length == 0) {\n                    revert ERC721InvalidReceiver(to);\n                } else {\n                    /// @solidity memory-safe-assembly\n                    assembly {\n                        revert(add(32, reason), mload(reason))\n                    }\n                }\n            }\n        }\n    }\n}\n"
      },
      "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/extensions/ERC721Enumerable.sol)\n\npragma solidity ^0.8.20;\n\nimport {ERC721} from \"../ERC721.sol\";\nimport {IERC721Enumerable} from \"./IERC721Enumerable.sol\";\nimport {IERC165} from \"../../../utils/introspection/ERC165.sol\";\n\n/**\n * @dev This implements an optional extension of {ERC721} defined in the EIP that adds enumerability\n * of all the token ids in the contract as well as all token ids owned by each account.\n *\n * CAUTION: `ERC721` extensions that implement custom `balanceOf` logic, such as `ERC721Consecutive`,\n * interfere with enumerability and should not be used together with `ERC721Enumerable`.\n */\nabstract contract ERC721Enumerable is ERC721, IERC721Enumerable {\n    mapping(address owner => mapping(uint256 index => uint256)) private _ownedTokens;\n    mapping(uint256 tokenId => uint256) private _ownedTokensIndex;\n\n    uint256[] private _allTokens;\n    mapping(uint256 tokenId => uint256) private _allTokensIndex;\n\n    /**\n     * @dev An `owner`'s token query was out of bounds for `index`.\n     *\n     * NOTE: The owner being `address(0)` indicates a global out of bounds index.\n     */\n    error ERC721OutOfBoundsIndex(address owner, uint256 index);\n\n    /**\n     * @dev Batch mint is not allowed.\n     */\n    error ERC721EnumerableForbiddenBatchMint();\n\n    /**\n     * @dev See {IERC165-supportsInterface}.\n     */\n    function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) {\n        return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId);\n    }\n\n    /**\n     * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}.\n     */\n    function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual returns (uint256) {\n        if (index >= balanceOf(owner)) {\n            revert ERC721OutOfBoundsIndex(owner, index);\n        }\n        return _ownedTokens[owner][index];\n    }\n\n    /**\n     * @dev See {IERC721Enumerable-totalSupply}.\n     */\n    function totalSupply() public view virtual returns (uint256) {\n        return _allTokens.length;\n    }\n\n    /**\n     * @dev See {IERC721Enumerable-tokenByIndex}.\n     */\n    function tokenByIndex(uint256 index) public view virtual returns (uint256) {\n        if (index >= totalSupply()) {\n            revert ERC721OutOfBoundsIndex(address(0), index);\n        }\n        return _allTokens[index];\n    }\n\n    /**\n     * @dev See {ERC721-_update}.\n     */\n    function _update(address to, uint256 tokenId, address auth) internal virtual override returns (address) {\n        address previousOwner = super._update(to, tokenId, auth);\n\n        if (previousOwner == address(0)) {\n            _addTokenToAllTokensEnumeration(tokenId);\n        } else if (previousOwner != to) {\n            _removeTokenFromOwnerEnumeration(previousOwner, tokenId);\n        }\n        if (to == address(0)) {\n            _removeTokenFromAllTokensEnumeration(tokenId);\n        } else if (previousOwner != to) {\n            _addTokenToOwnerEnumeration(to, tokenId);\n        }\n\n        return previousOwner;\n    }\n\n    /**\n     * @dev Private function to add a token to this extension's ownership-tracking data structures.\n     * @param to address representing the new owner of the given token ID\n     * @param tokenId uint256 ID of the token to be added to the tokens list of the given address\n     */\n    function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private {\n        uint256 length = balanceOf(to) - 1;\n        _ownedTokens[to][length] = tokenId;\n        _ownedTokensIndex[tokenId] = length;\n    }\n\n    /**\n     * @dev Private function to add a token to this extension's token tracking data structures.\n     * @param tokenId uint256 ID of the token to be added to the tokens list\n     */\n    function _addTokenToAllTokensEnumeration(uint256 tokenId) private {\n        _allTokensIndex[tokenId] = _allTokens.length;\n        _allTokens.push(tokenId);\n    }\n\n    /**\n     * @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that\n     * while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for\n     * gas optimizations e.g. when performing a transfer operation (avoiding double writes).\n     * This has O(1) time complexity, but alters the order of the _ownedTokens array.\n     * @param from address representing the previous owner of the given token ID\n     * @param tokenId uint256 ID of the token to be removed from the tokens list of the given address\n     */\n    function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private {\n        // To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and\n        // then delete the last slot (swap and pop).\n\n        uint256 lastTokenIndex = balanceOf(from);\n        uint256 tokenIndex = _ownedTokensIndex[tokenId];\n\n        // When the token to delete is the last token, the swap operation is unnecessary\n        if (tokenIndex != lastTokenIndex) {\n            uint256 lastTokenId = _ownedTokens[from][lastTokenIndex];\n\n            _ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token\n            _ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index\n        }\n\n        // This also deletes the contents at the last position of the array\n        delete _ownedTokensIndex[tokenId];\n        delete _ownedTokens[from][lastTokenIndex];\n    }\n\n    /**\n     * @dev Private function to remove a token from this extension's token tracking data structures.\n     * This has O(1) time complexity, but alters the order of the _allTokens array.\n     * @param tokenId uint256 ID of the token to be removed from the tokens list\n     */\n    function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private {\n        // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and\n        // then delete the last slot (swap and pop).\n\n        uint256 lastTokenIndex = _allTokens.length - 1;\n        uint256 tokenIndex = _allTokensIndex[tokenId];\n\n        // When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so\n        // rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding\n        // an 'if' statement (like in _removeTokenFromOwnerEnumeration)\n        uint256 lastTokenId = _allTokens[lastTokenIndex];\n\n        _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token\n        _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index\n\n        // This also deletes the contents at the last position of the array\n        delete _allTokensIndex[tokenId];\n        _allTokens.pop();\n    }\n\n    /**\n     * See {ERC721-_increaseBalance}. We need that to account tokens that were minted in batch\n     */\n    function _increaseBalance(address account, uint128 amount) internal virtual override {\n        if (amount > 0) {\n            revert ERC721EnumerableForbiddenBatchMint();\n        }\n        super._increaseBalance(account, amount);\n    }\n}\n"
      },
      "@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/extensions/IERC721Enumerable.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC721} from \"../IERC721.sol\";\n\n/**\n * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension\n * @dev See https://eips.ethereum.org/EIPS/eip-721\n */\ninterface IERC721Enumerable is IERC721 {\n    /**\n     * @dev Returns the total amount of tokens stored by the contract.\n     */\n    function totalSupply() external view returns (uint256);\n\n    /**\n     * @dev Returns a token ID owned by `owner` at a given `index` of its token list.\n     * Use along with {balanceOf} to enumerate all of ``owner``'s tokens.\n     */\n    function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256);\n\n    /**\n     * @dev Returns a token ID at a given `index` of all the tokens stored by the contract.\n     * Use along with {totalSupply} to enumerate all tokens.\n     */\n    function tokenByIndex(uint256 index) external view returns (uint256);\n}\n"
      },
      "@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/extensions/IERC721Metadata.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC721} from \"../IERC721.sol\";\n\n/**\n * @title ERC-721 Non-Fungible Token Standard, optional metadata extension\n * @dev See https://eips.ethereum.org/EIPS/eip-721\n */\ninterface IERC721Metadata is IERC721 {\n    /**\n     * @dev Returns the token collection name.\n     */\n    function name() external view returns (string memory);\n\n    /**\n     * @dev Returns the token collection symbol.\n     */\n    function symbol() external view returns (string memory);\n\n    /**\n     * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.\n     */\n    function tokenURI(uint256 tokenId) external view returns (string memory);\n}\n"
      },
      "@openzeppelin/contracts/token/ERC721/IERC721.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/IERC721.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC165} from \"../../utils/introspection/IERC165.sol\";\n\n/**\n * @dev Required interface of an ERC721 compliant contract.\n */\ninterface IERC721 is IERC165 {\n    /**\n     * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\n     */\n    event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\n\n    /**\n     * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\n     */\n    event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\n\n    /**\n     * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\n     */\n    event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\n\n    /**\n     * @dev Returns the number of tokens in ``owner``'s account.\n     */\n    function balanceOf(address owner) external view returns (uint256 balance);\n\n    /**\n     * @dev Returns the owner of the `tokenId` token.\n     *\n     * Requirements:\n     *\n     * - `tokenId` must exist.\n     */\n    function ownerOf(uint256 tokenId) external view returns (address owner);\n\n    /**\n     * @dev Safely transfers `tokenId` token from `from` to `to`.\n     *\n     * Requirements:\n     *\n     * - `from` cannot be the zero address.\n     * - `to` cannot be the zero address.\n     * - `tokenId` token must exist and be owned by `from`.\n     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon\n     *   a safe transfer.\n     *\n     * Emits a {Transfer} event.\n     */\n    function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external;\n\n    /**\n     * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\n     * are aware of the ERC721 protocol to prevent tokens from being forever locked.\n     *\n     * Requirements:\n     *\n     * - `from` cannot be the zero address.\n     * - `to` cannot be the zero address.\n     * - `tokenId` token must exist and be owned by `from`.\n     * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or\n     *   {setApprovalForAll}.\n     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon\n     *   a safe transfer.\n     *\n     * Emits a {Transfer} event.\n     */\n    function safeTransferFrom(address from, address to, uint256 tokenId) external;\n\n    /**\n     * @dev Transfers `tokenId` token from `from` to `to`.\n     *\n     * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721\n     * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must\n     * understand this adds an external call which potentially creates a reentrancy vulnerability.\n     *\n     * Requirements:\n     *\n     * - `from` cannot be the zero address.\n     * - `to` cannot be the zero address.\n     * - `tokenId` token must be owned by `from`.\n     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n     *\n     * Emits a {Transfer} event.\n     */\n    function transferFrom(address from, address to, uint256 tokenId) external;\n\n    /**\n     * @dev Gives permission to `to` to transfer `tokenId` token to another account.\n     * The approval is cleared when the token is transferred.\n     *\n     * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\n     *\n     * Requirements:\n     *\n     * - The caller must own the token or be an approved operator.\n     * - `tokenId` must exist.\n     *\n     * Emits an {Approval} event.\n     */\n    function approve(address to, uint256 tokenId) external;\n\n    /**\n     * @dev Approve or remove `operator` as an operator for the caller.\n     * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\n     *\n     * Requirements:\n     *\n     * - The `operator` cannot be the address zero.\n     *\n     * Emits an {ApprovalForAll} event.\n     */\n    function setApprovalForAll(address operator, bool approved) external;\n\n    /**\n     * @dev Returns the account approved for `tokenId` token.\n     *\n     * Requirements:\n     *\n     * - `tokenId` must exist.\n     */\n    function getApproved(uint256 tokenId) external view returns (address operator);\n\n    /**\n     * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\n     *\n     * See {setApprovalForAll}\n     */\n    function isApprovedForAll(address owner, address operator) external view returns (bool);\n}\n"
      },
      "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/IERC721Receiver.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @title ERC721 token receiver interface\n * @dev Interface for any contract that wants to support safeTransfers\n * from ERC721 asset contracts.\n */\ninterface IERC721Receiver {\n    /**\n     * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}\n     * by `operator` from `from`, this function is called.\n     *\n     * It must return its Solidity selector to confirm the token transfer.\n     * If any other value is returned or the interface is not implemented by the recipient, the transfer will be\n     * reverted.\n     *\n     * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.\n     */\n    function onERC721Received(\n        address operator,\n        address from,\n        uint256 tokenId,\n        bytes calldata data\n    ) external returns (bytes4);\n}\n"
      },
      "@openzeppelin/contracts/token/ERC721/utils/ERC721Holder.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/utils/ERC721Holder.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC721Receiver} from \"../IERC721Receiver.sol\";\n\n/**\n * @dev Implementation of the {IERC721Receiver} interface.\n *\n * Accepts all token transfers.\n * Make sure the contract is able to use its token with {IERC721-safeTransferFrom}, {IERC721-approve} or\n * {IERC721-setApprovalForAll}.\n */\nabstract contract ERC721Holder is IERC721Receiver {\n    /**\n     * @dev See {IERC721Receiver-onERC721Received}.\n     *\n     * Always returns `IERC721Receiver.onERC721Received.selector`.\n     */\n    function onERC721Received(address, address, uint256, bytes memory) public virtual returns (bytes4) {\n        return this.onERC721Received.selector;\n    }\n}\n"
      },
      "@openzeppelin/contracts/utils/Address.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n    /**\n     * @dev The ETH balance of the account is not enough to perform the operation.\n     */\n    error AddressInsufficientBalance(address account);\n\n    /**\n     * @dev There's no code at `target` (it is not a contract).\n     */\n    error AddressEmptyCode(address target);\n\n    /**\n     * @dev A call to an address target failed. The target may have reverted.\n     */\n    error FailedInnerCall();\n\n    /**\n     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n     * `recipient`, forwarding all available gas and reverting on errors.\n     *\n     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n     * of certain opcodes, possibly making contracts go over the 2300 gas limit\n     * imposed by `transfer`, making them unable to receive funds via\n     * `transfer`. {sendValue} removes this limitation.\n     *\n     * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n     *\n     * IMPORTANT: because control is transferred to `recipient`, care must be\n     * taken to not create reentrancy vulnerabilities. Consider using\n     * {ReentrancyGuard} or the\n     * https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n     */\n    function sendValue(address payable recipient, uint256 amount) internal {\n        if (address(this).balance < amount) {\n            revert AddressInsufficientBalance(address(this));\n        }\n\n        (bool success, ) = recipient.call{value: amount}(\"\");\n        if (!success) {\n            revert FailedInnerCall();\n        }\n    }\n\n    /**\n     * @dev Performs a Solidity function call using a low level `call`. A\n     * plain `call` is an unsafe replacement for a function call: use this\n     * function instead.\n     *\n     * If `target` reverts with a revert reason or custom error, it is bubbled\n     * up by this function (like regular Solidity function calls). However, if\n     * the call reverted with no returned reason, this function reverts with a\n     * {FailedInnerCall} error.\n     *\n     * Returns the raw returned data. To convert to the expected return value,\n     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n     *\n     * Requirements:\n     *\n     * - `target` must be a contract.\n     * - calling `target` with `data` must not revert.\n     */\n    function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n        return functionCallWithValue(target, data, 0);\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n     * but also transferring `value` wei to `target`.\n     *\n     * Requirements:\n     *\n     * - the calling contract must have an ETH balance of at least `value`.\n     * - the called Solidity function must be `payable`.\n     */\n    function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\n        if (address(this).balance < value) {\n            revert AddressInsufficientBalance(address(this));\n        }\n        (bool success, bytes memory returndata) = target.call{value: value}(data);\n        return verifyCallResultFromTarget(target, success, returndata);\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n     * but performing a static call.\n     */\n    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n        (bool success, bytes memory returndata) = target.staticcall(data);\n        return verifyCallResultFromTarget(target, success, returndata);\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n     * but performing a delegate call.\n     */\n    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n        (bool success, bytes memory returndata) = target.delegatecall(data);\n        return verifyCallResultFromTarget(target, success, returndata);\n    }\n\n    /**\n     * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target\n     * was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an\n     * unsuccessful call.\n     */\n    function verifyCallResultFromTarget(\n        address target,\n        bool success,\n        bytes memory returndata\n    ) internal view returns (bytes memory) {\n        if (!success) {\n            _revert(returndata);\n        } else {\n            // only check if target is a contract if the call was successful and the return data is empty\n            // otherwise we already know that it was a contract\n            if (returndata.length == 0 && target.code.length == 0) {\n                revert AddressEmptyCode(target);\n            }\n            return returndata;\n        }\n    }\n\n    /**\n     * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the\n     * revert reason or with a default {FailedInnerCall} error.\n     */\n    function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {\n        if (!success) {\n            _revert(returndata);\n        } else {\n            return returndata;\n        }\n    }\n\n    /**\n     * @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}.\n     */\n    function _revert(bytes memory returndata) private pure {\n        // Look for revert reason and bubble it up if present\n        if (returndata.length > 0) {\n            // The easiest way to bubble the revert reason is using memory via assembly\n            /// @solidity memory-safe-assembly\n            assembly {\n                let returndata_size := mload(returndata)\n                revert(add(32, returndata), returndata_size)\n            }\n        } else {\n            revert FailedInnerCall();\n        }\n    }\n}\n"
      },
      "@openzeppelin/contracts/utils/Context.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n    function _msgSender() internal view virtual returns (address) {\n        return msg.sender;\n    }\n\n    function _msgData() internal view virtual returns (bytes calldata) {\n        return msg.data;\n    }\n\n    function _contextSuffixLength() internal view virtual returns (uint256) {\n        return 0;\n    }\n}\n"
      },
      "@openzeppelin/contracts/utils/introspection/ERC165.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC165} from \"./IERC165.sol\";\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n *     return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n */\nabstract contract ERC165 is IERC165 {\n    /**\n     * @dev See {IERC165-supportsInterface}.\n     */\n    function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {\n        return interfaceId == type(IERC165).interfaceId;\n    }\n}\n"
      },
      "@openzeppelin/contracts/utils/introspection/IERC165.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n    /**\n     * @dev Returns true if this contract implements the interface defined by\n     * `interfaceId`. See the corresponding\n     * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n     * to learn more about how these ids are created.\n     *\n     * This function call must use less than 30 000 gas.\n     */\n    function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n"
      },
      "@openzeppelin/contracts/utils/math/Math.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/math/Math.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Standard math utilities missing in the Solidity language.\n */\nlibrary Math {\n    /**\n     * @dev Muldiv operation overflow.\n     */\n    error MathOverflowedMulDiv();\n\n    enum Rounding {\n        Floor, // Toward negative infinity\n        Ceil, // Toward positive infinity\n        Trunc, // Toward zero\n        Expand // Away from zero\n    }\n\n    /**\n     * @dev Returns the addition of two unsigned integers, with an overflow flag.\n     */\n    function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n        unchecked {\n            uint256 c = a + b;\n            if (c < a) return (false, 0);\n            return (true, c);\n        }\n    }\n\n    /**\n     * @dev Returns the subtraction of two unsigned integers, with an overflow flag.\n     */\n    function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n        unchecked {\n            if (b > a) return (false, 0);\n            return (true, a - b);\n        }\n    }\n\n    /**\n     * @dev Returns the multiplication of two unsigned integers, with an overflow flag.\n     */\n    function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n        unchecked {\n            // Gas optimization: this is cheaper than requiring 'a' not being zero, but the\n            // benefit is lost if 'b' is also tested.\n            // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522\n            if (a == 0) return (true, 0);\n            uint256 c = a * b;\n            if (c / a != b) return (false, 0);\n            return (true, c);\n        }\n    }\n\n    /**\n     * @dev Returns the division of two unsigned integers, with a division by zero flag.\n     */\n    function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n        unchecked {\n            if (b == 0) return (false, 0);\n            return (true, a / b);\n        }\n    }\n\n    /**\n     * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.\n     */\n    function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n        unchecked {\n            if (b == 0) return (false, 0);\n            return (true, a % b);\n        }\n    }\n\n    /**\n     * @dev Returns the largest of two numbers.\n     */\n    function max(uint256 a, uint256 b) internal pure returns (uint256) {\n        return a > b ? a : b;\n    }\n\n    /**\n     * @dev Returns the smallest of two numbers.\n     */\n    function min(uint256 a, uint256 b) internal pure returns (uint256) {\n        return a < b ? a : b;\n    }\n\n    /**\n     * @dev Returns the average of two numbers. The result is rounded towards\n     * zero.\n     */\n    function average(uint256 a, uint256 b) internal pure returns (uint256) {\n        // (a + b) / 2 can overflow.\n        return (a & b) + (a ^ b) / 2;\n    }\n\n    /**\n     * @dev Returns the ceiling of the division of two numbers.\n     *\n     * This differs from standard division with `/` in that it rounds towards infinity instead\n     * of rounding towards zero.\n     */\n    function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\n        if (b == 0) {\n            // Guarantee the same behavior as in a regular Solidity division.\n            return a / b;\n        }\n\n        // (a + b - 1) / b can overflow on addition, so we distribute.\n        return a == 0 ? 0 : (a - 1) / b + 1;\n    }\n\n    /**\n     * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or\n     * denominator == 0.\n     * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) with further edits by\n     * Uniswap Labs also under MIT license.\n     */\n    function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {\n        unchecked {\n            // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\n            // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256\n            // variables such that product = prod1 * 2^256 + prod0.\n            uint256 prod0 = x * y; // Least significant 256 bits of the product\n            uint256 prod1; // Most significant 256 bits of the product\n            assembly {\n                let mm := mulmod(x, y, not(0))\n                prod1 := sub(sub(mm, prod0), lt(mm, prod0))\n            }\n\n            // Handle non-overflow cases, 256 by 256 division.\n            if (prod1 == 0) {\n                // Solidity will revert if denominator == 0, unlike the div opcode on its own.\n                // The surrounding unchecked block does not change this fact.\n                // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.\n                return prod0 / denominator;\n            }\n\n            // Make sure the result is less than 2^256. Also prevents denominator == 0.\n            if (denominator <= prod1) {\n                revert MathOverflowedMulDiv();\n            }\n\n            ///////////////////////////////////////////////\n            // 512 by 256 division.\n            ///////////////////////////////////////////////\n\n            // Make division exact by subtracting the remainder from [prod1 prod0].\n            uint256 remainder;\n            assembly {\n                // Compute remainder using mulmod.\n                remainder := mulmod(x, y, denominator)\n\n                // Subtract 256 bit number from 512 bit number.\n                prod1 := sub(prod1, gt(remainder, prod0))\n                prod0 := sub(prod0, remainder)\n            }\n\n            // Factor powers of two out of denominator and compute largest power of two divisor of denominator.\n            // Always >= 1. See https://cs.stackexchange.com/q/138556/92363.\n\n            uint256 twos = denominator & (0 - denominator);\n            assembly {\n                // Divide denominator by twos.\n                denominator := div(denominator, twos)\n\n                // Divide [prod1 prod0] by twos.\n                prod0 := div(prod0, twos)\n\n                // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.\n                twos := add(div(sub(0, twos), twos), 1)\n            }\n\n            // Shift in bits from prod1 into prod0.\n            prod0 |= prod1 * twos;\n\n            // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\n            // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\n            // four bits. That is, denominator * inv = 1 mod 2^4.\n            uint256 inverse = (3 * denominator) ^ 2;\n\n            // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also\n            // works in modular arithmetic, doubling the correct bits in each step.\n            inverse *= 2 - denominator * inverse; // inverse mod 2^8\n            inverse *= 2 - denominator * inverse; // inverse mod 2^16\n            inverse *= 2 - denominator * inverse; // inverse mod 2^32\n            inverse *= 2 - denominator * inverse; // inverse mod 2^64\n            inverse *= 2 - denominator * inverse; // inverse mod 2^128\n            inverse *= 2 - denominator * inverse; // inverse mod 2^256\n\n            // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.\n            // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is\n            // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1\n            // is no longer required.\n            result = prod0 * inverse;\n            return result;\n        }\n    }\n\n    /**\n     * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.\n     */\n    function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {\n        uint256 result = mulDiv(x, y, denominator);\n        if (unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0) {\n            result += 1;\n        }\n        return result;\n    }\n\n    /**\n     * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded\n     * towards zero.\n     *\n     * Inspired by Henry S. Warren, Jr.'s \"Hacker's Delight\" (Chapter 11).\n     */\n    function sqrt(uint256 a) internal pure returns (uint256) {\n        if (a == 0) {\n            return 0;\n        }\n\n        // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.\n        //\n        // We know that the \"msb\" (most significant bit) of our target number `a` is a power of 2 such that we have\n        // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.\n        //\n        // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`\n        // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`\n        // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`\n        //\n        // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.\n        uint256 result = 1 << (log2(a) >> 1);\n\n        // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,\n        // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at\n        // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision\n        // into the expected uint128 result.\n        unchecked {\n            result = (result + a / result) >> 1;\n            result = (result + a / result) >> 1;\n            result = (result + a / result) >> 1;\n            result = (result + a / result) >> 1;\n            result = (result + a / result) >> 1;\n            result = (result + a / result) >> 1;\n            result = (result + a / result) >> 1;\n            return min(result, a / result);\n        }\n    }\n\n    /**\n     * @notice Calculates sqrt(a), following the selected rounding direction.\n     */\n    function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {\n        unchecked {\n            uint256 result = sqrt(a);\n            return result + (unsignedRoundsUp(rounding) && result * result < a ? 1 : 0);\n        }\n    }\n\n    /**\n     * @dev Return the log in base 2 of a positive value rounded towards zero.\n     * Returns 0 if given 0.\n     */\n    function log2(uint256 value) internal pure returns (uint256) {\n        uint256 result = 0;\n        unchecked {\n            if (value >> 128 > 0) {\n                value >>= 128;\n                result += 128;\n            }\n            if (value >> 64 > 0) {\n                value >>= 64;\n                result += 64;\n            }\n            if (value >> 32 > 0) {\n                value >>= 32;\n                result += 32;\n            }\n            if (value >> 16 > 0) {\n                value >>= 16;\n                result += 16;\n            }\n            if (value >> 8 > 0) {\n                value >>= 8;\n                result += 8;\n            }\n            if (value >> 4 > 0) {\n                value >>= 4;\n                result += 4;\n            }\n            if (value >> 2 > 0) {\n                value >>= 2;\n                result += 2;\n            }\n            if (value >> 1 > 0) {\n                result += 1;\n            }\n        }\n        return result;\n    }\n\n    /**\n     * @dev Return the log in base 2, following the selected rounding direction, of a positive value.\n     * Returns 0 if given 0.\n     */\n    function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {\n        unchecked {\n            uint256 result = log2(value);\n            return result + (unsignedRoundsUp(rounding) && 1 << result < value ? 1 : 0);\n        }\n    }\n\n    /**\n     * @dev Return the log in base 10 of a positive value rounded towards zero.\n     * Returns 0 if given 0.\n     */\n    function log10(uint256 value) internal pure returns (uint256) {\n        uint256 result = 0;\n        unchecked {\n            if (value >= 10 ** 64) {\n                value /= 10 ** 64;\n                result += 64;\n            }\n            if (value >= 10 ** 32) {\n                value /= 10 ** 32;\n                result += 32;\n            }\n            if (value >= 10 ** 16) {\n                value /= 10 ** 16;\n                result += 16;\n            }\n            if (value >= 10 ** 8) {\n                value /= 10 ** 8;\n                result += 8;\n            }\n            if (value >= 10 ** 4) {\n                value /= 10 ** 4;\n                result += 4;\n            }\n            if (value >= 10 ** 2) {\n                value /= 10 ** 2;\n                result += 2;\n            }\n            if (value >= 10 ** 1) {\n                result += 1;\n            }\n        }\n        return result;\n    }\n\n    /**\n     * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\n     * Returns 0 if given 0.\n     */\n    function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {\n        unchecked {\n            uint256 result = log10(value);\n            return result + (unsignedRoundsUp(rounding) && 10 ** result < value ? 1 : 0);\n        }\n    }\n\n    /**\n     * @dev Return the log in base 256 of a positive value rounded towards zero.\n     * Returns 0 if given 0.\n     *\n     * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.\n     */\n    function log256(uint256 value) internal pure returns (uint256) {\n        uint256 result = 0;\n        unchecked {\n            if (value >> 128 > 0) {\n                value >>= 128;\n                result += 16;\n            }\n            if (value >> 64 > 0) {\n                value >>= 64;\n                result += 8;\n            }\n            if (value >> 32 > 0) {\n                value >>= 32;\n                result += 4;\n            }\n            if (value >> 16 > 0) {\n                value >>= 16;\n                result += 2;\n            }\n            if (value >> 8 > 0) {\n                result += 1;\n            }\n        }\n        return result;\n    }\n\n    /**\n     * @dev Return the log in base 256, following the selected rounding direction, of a positive value.\n     * Returns 0 if given 0.\n     */\n    function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {\n        unchecked {\n            uint256 result = log256(value);\n            return result + (unsignedRoundsUp(rounding) && 1 << (result << 3) < value ? 1 : 0);\n        }\n    }\n\n    /**\n     * @dev Returns whether a provided rounding mode is considered rounding up for unsigned integers.\n     */\n    function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) {\n        return uint8(rounding) % 2 == 1;\n    }\n}\n"
      },
      "@openzeppelin/contracts/utils/math/SignedMath.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/math/SignedMath.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Standard signed math utilities missing in the Solidity language.\n */\nlibrary SignedMath {\n    /**\n     * @dev Returns the largest of two signed numbers.\n     */\n    function max(int256 a, int256 b) internal pure returns (int256) {\n        return a > b ? a : b;\n    }\n\n    /**\n     * @dev Returns the smallest of two signed numbers.\n     */\n    function min(int256 a, int256 b) internal pure returns (int256) {\n        return a < b ? a : b;\n    }\n\n    /**\n     * @dev Returns the average of two signed numbers without overflow.\n     * The result is rounded towards zero.\n     */\n    function average(int256 a, int256 b) internal pure returns (int256) {\n        // Formula from the book \"Hacker's Delight\"\n        int256 x = (a & b) + ((a ^ b) >> 1);\n        return x + (int256(uint256(x) >> 255) & (a ^ b));\n    }\n\n    /**\n     * @dev Returns the absolute unsigned value of a signed value.\n     */\n    function abs(int256 n) internal pure returns (uint256) {\n        unchecked {\n            // must be unchecked in order to support `n = type(int256).min`\n            return uint256(n >= 0 ? n : -n);\n        }\n    }\n}\n"
      },
      "@openzeppelin/contracts/utils/ReentrancyGuard.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/ReentrancyGuard.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Contract module that helps prevent reentrant calls to a function.\n *\n * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier\n * available, which can be applied to functions to make sure there are no nested\n * (reentrant) calls to them.\n *\n * Note that because there is a single `nonReentrant` guard, functions marked as\n * `nonReentrant` may not call one another. This can be worked around by making\n * those functions `private`, and then adding `external` `nonReentrant` entry\n * points to them.\n *\n * TIP: If you would like to learn more about reentrancy and alternative ways\n * to protect against it, check out our blog post\n * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].\n */\nabstract contract ReentrancyGuard {\n    // Booleans are more expensive than uint256 or any type that takes up a full\n    // word because each write operation emits an extra SLOAD to first read the\n    // slot's contents, replace the bits taken up by the boolean, and then write\n    // back. This is the compiler's defense against contract upgrades and\n    // pointer aliasing, and it cannot be disabled.\n\n    // The values being non-zero value makes deployment a bit more expensive,\n    // but in exchange the refund on every call to nonReentrant will be lower in\n    // amount. Since refunds are capped to a percentage of the total\n    // transaction's gas, it is best to keep them low in cases like this one, to\n    // increase the likelihood of the full refund coming into effect.\n    uint256 private constant NOT_ENTERED = 1;\n    uint256 private constant ENTERED = 2;\n\n    uint256 private _status;\n\n    /**\n     * @dev Unauthorized reentrant call.\n     */\n    error ReentrancyGuardReentrantCall();\n\n    constructor() {\n        _status = NOT_ENTERED;\n    }\n\n    /**\n     * @dev Prevents a contract from calling itself, directly or indirectly.\n     * Calling a `nonReentrant` function from another `nonReentrant`\n     * function is not supported. It is possible to prevent this from happening\n     * by making the `nonReentrant` function external, and making it call a\n     * `private` function that does the actual work.\n     */\n    modifier nonReentrant() {\n        _nonReentrantBefore();\n        _;\n        _nonReentrantAfter();\n    }\n\n    function _nonReentrantBefore() private {\n        // On the first call to nonReentrant, _status will be NOT_ENTERED\n        if (_status == ENTERED) {\n            revert ReentrancyGuardReentrantCall();\n        }\n\n        // Any calls to nonReentrant after this point will fail\n        _status = ENTERED;\n    }\n\n    function _nonReentrantAfter() private {\n        // By storing the original value once again, a refund is triggered (see\n        // https://eips.ethereum.org/EIPS/eip-2200)\n        _status = NOT_ENTERED;\n    }\n\n    /**\n     * @dev Returns true if the reentrancy guard is currently set to \"entered\", which indicates there is a\n     * `nonReentrant` function in the call stack.\n     */\n    function _reentrancyGuardEntered() internal view returns (bool) {\n        return _status == ENTERED;\n    }\n}\n"
      },
      "@openzeppelin/contracts/utils/Strings.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/Strings.sol)\n\npragma solidity ^0.8.20;\n\nimport {Math} from \"./math/Math.sol\";\nimport {SignedMath} from \"./math/SignedMath.sol\";\n\n/**\n * @dev String operations.\n */\nlibrary Strings {\n    bytes16 private constant HEX_DIGITS = \"0123456789abcdef\";\n    uint8 private constant ADDRESS_LENGTH = 20;\n\n    /**\n     * @dev The `value` string doesn't fit in the specified `length`.\n     */\n    error StringsInsufficientHexLength(uint256 value, uint256 length);\n\n    /**\n     * @dev Converts a `uint256` to its ASCII `string` decimal representation.\n     */\n    function toString(uint256 value) internal pure returns (string memory) {\n        unchecked {\n            uint256 length = Math.log10(value) + 1;\n            string memory buffer = new string(length);\n            uint256 ptr;\n            /// @solidity memory-safe-assembly\n            assembly {\n                ptr := add(buffer, add(32, length))\n            }\n            while (true) {\n                ptr--;\n                /// @solidity memory-safe-assembly\n                assembly {\n                    mstore8(ptr, byte(mod(value, 10), HEX_DIGITS))\n                }\n                value /= 10;\n                if (value == 0) break;\n            }\n            return buffer;\n        }\n    }\n\n    /**\n     * @dev Converts a `int256` to its ASCII `string` decimal representation.\n     */\n    function toStringSigned(int256 value) internal pure returns (string memory) {\n        return string.concat(value < 0 ? \"-\" : \"\", toString(SignedMath.abs(value)));\n    }\n\n    /**\n     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\n     */\n    function toHexString(uint256 value) internal pure returns (string memory) {\n        unchecked {\n            return toHexString(value, Math.log256(value) + 1);\n        }\n    }\n\n    /**\n     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\n     */\n    function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\n        uint256 localValue = value;\n        bytes memory buffer = new bytes(2 * length + 2);\n        buffer[0] = \"0\";\n        buffer[1] = \"x\";\n        for (uint256 i = 2 * length + 1; i > 1; --i) {\n            buffer[i] = HEX_DIGITS[localValue & 0xf];\n            localValue >>= 4;\n        }\n        if (localValue != 0) {\n            revert StringsInsufficientHexLength(value, length);\n        }\n        return string(buffer);\n    }\n\n    /**\n     * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal\n     * representation.\n     */\n    function toHexString(address addr) internal pure returns (string memory) {\n        return toHexString(uint256(uint160(addr)), ADDRESS_LENGTH);\n    }\n\n    /**\n     * @dev Returns true if the two strings are equal.\n     */\n    function equal(string memory a, string memory b) internal pure returns (bool) {\n        return bytes(a).length == bytes(b).length && keccak256(bytes(a)) == keccak256(bytes(b));\n    }\n}\n"
      },
      "contracts/ERC721Delegate/ERC721Delegate.sol": {
        "content": "// SPDX-License-Identifier: MIT\r\n\r\npragma solidity 0.8.24;\r\n\r\nimport './PlanDelegator.sol';\r\n\r\nabstract contract ERC721Delegate is PlanDelegator {\r\n  event TokenDelegated(uint256 indexed tokenId, address indexed delegate);\r\n  event DelegateRemoved(uint256 indexed tokenId, address indexed delegate);\r\n\r\n  function _delegateToken(address delegate, uint256 tokenId) internal {\r\n    require(_isApprovedDelegatorOrOwner(msg.sender, tokenId), '!delegator');\r\n    _transferDelegate(delegate, tokenId);\r\n  }\r\n\r\n  // function for minting should add the token to the delegate and increase the balance\r\n  function _addDelegate(address to, uint256 tokenId) private {\r\n    require(to != address(0), '!address(0)');\r\n    uint256 length = _delegateBalances[to];\r\n    _delegatedTokens[to][length] = tokenId;\r\n    _delegatedTokensIndex[tokenId] = length;\r\n    _delegates[tokenId] = to;\r\n    _delegateBalances[to] += 1;\r\n    emit TokenDelegated(tokenId, to);\r\n  }\r\n\r\n  // function for burning should reduce the balances and set the token mapped to 0x0 address\r\n  function _removeDelegate(uint256 tokenId) private {\r\n    address from = _delegates[tokenId];\r\n    require(from != address(0), '!address(0)');\r\n    uint256 lastTokenIndex = _delegateBalances[from] - 1;\r\n    uint256 tokenIndex = _delegatedTokensIndex[tokenId];\r\n    if (tokenIndex != lastTokenIndex) {\r\n      uint256 lastTokenId = _delegatedTokens[from][lastTokenIndex];\r\n      _delegatedTokens[from][tokenIndex] = lastTokenId;\r\n      _delegatedTokensIndex[lastTokenId] = tokenIndex;\r\n    }\r\n    delete _delegatedTokensIndex[tokenId];\r\n    delete _delegatedTokens[from][lastTokenIndex];\r\n    _delegateBalances[from] -= 1;\r\n    _delegates[tokenId] = address(0);\r\n    emit DelegateRemoved(tokenId, from);\r\n  }\r\n\r\n  // function for transfering should reduce the balances of from by 1, increase the balances of to by 1, and set the delegate address To\r\n  function _transferDelegate(address to, uint256 tokenId) internal {\r\n    _removeDelegate(tokenId);\r\n    _addDelegate(to, tokenId);\r\n  }\r\n\r\n  //mapping from tokenId to the delegate address\r\n  mapping(uint256 => address) private _delegates;\r\n\r\n  // mapping from delegate address to token count\r\n  mapping(address => uint256) private _delegateBalances;\r\n\r\n  // mapping from delegate to the list of delegated token Ids\r\n  mapping(address => mapping(uint256 => uint256)) private _delegatedTokens;\r\n\r\n  // maping from token ID to the index of the delegates token list\r\n  mapping(uint256 => uint256) private _delegatedTokensIndex;\r\n\r\n  function balanceOfDelegate(address delegate) public view returns (uint256) {\r\n    require(delegate != address(0), '!address(0)');\r\n    return _delegateBalances[delegate];\r\n  }\r\n\r\n  function delegatedTo(uint256 tokenId) public view returns (address) {\r\n    address delegate = _delegates[tokenId];\r\n    return delegate;\r\n  }\r\n\r\n  function tokenOfDelegateByIndex(address delegate, uint256 index) public view returns (uint256) {\r\n    require(index < _delegateBalances[delegate], 'out of bounds');\r\n    return _delegatedTokens[delegate][index];\r\n  }\r\n\r\n  function _updateDelegate(address to, uint256 tokenId) internal {\r\n    if (_ownerOf(tokenId) == address(0x0)) {\r\n      _addDelegate(to, tokenId);\r\n    } else if (to == address(0x0)) {\r\n      _removeDelegate(tokenId);\r\n    }\r\n  }\r\n}\r\n"
      },
      "contracts/ERC721Delegate/PlanDelegator.sol": {
        "content": "// SPDX-License-Identifier: BUSL-1.1\r\npragma solidity 0.8.24;\r\nimport '@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol';\r\n\r\nabstract contract PlanDelegator is ERC721Enumerable {\r\n  // mapping of tokenId to address who can delegate an NFT on behalf of the owner\r\n  /// @dev follows tokenApprovals logic\r\n\r\n  /******Storage Variables******************************************************************/\r\n  mapping(uint256 => address) internal _approvedDelegators;\r\n\r\n  /// @dev operatorApprovals simialr to ERC721 standards\r\n  mapping(address => mapping(address => bool)) internal _approvedOperatorDelegators;\r\n\r\n\r\n  /***EVENTS******************************************************************************/\r\n\r\n  /// @dev event that is emitted when a single plan delegator has been approved\r\n  event DelegatorApproved(uint256 indexed id, address owner, address delegator);\r\n\r\n  /// @dev event emit when the operator delegator has been approved to manage all delegation of a single address\r\n  event ApprovalForAllDelegation(address owner, address operator, bool approved);\r\n\r\n\r\n  /***************EXTERNAL FUNCTIONS***************************************************************************/\r\n\r\n  /// @notice function to assign a single planId to a delegator. The delegator then has authority to call functions on other contracts such as delegate\r\n  /// @param delegator is the address of the delegator who can delegate on behalf of the nft owner\r\n  /// @param planId is the id of the vesting or lockup plan\r\n  function approveDelegator(address delegator, uint256 planId) public virtual {\r\n    address owner = ownerOf(planId);\r\n    require(msg.sender == owner || isApprovedForAllDelegation(owner, msg.sender), '!ownerOperator');\r\n    require(delegator != msg.sender, '!self approval');\r\n    _approveDelegator(delegator, planId);\r\n  }\r\n\r\n  /// @notice function that performs both the approveDelegator function and approves a spender\r\n  /// @param spender is the address who is approved to spend and is also a Delegator\r\n  /// @param planId is the vesting plan id\r\n  function approveSpenderDelegator(address spender, uint256 planId) public virtual {\r\n    address owner = ownerOf(planId);\r\n    require(\r\n      msg.sender == owner || (isApprovedForAllDelegation(owner, msg.sender) && isApprovedForAll(owner, msg.sender)),\r\n      '!ownerOperator'\r\n    );\r\n    require(spender != msg.sender, '!self approval');\r\n    _approveDelegator(spender, planId);\r\n    _approve(spender, planId, msg.sender);\r\n  }\r\n\r\n  /// @notice this function sets an address to be an operator delegator for the msg.sender, whereby the operator can delegate all tokens owned by the msg.sender\r\n  /// the operator can also approve other single plan delegators\r\n  /// @param operator address of the operator for the msg.sender\r\n  /// @param approved boolean for approved if true, and false if not\r\n  function setApprovalForAllDelegation(address operator, bool approved) public virtual {\r\n    _setApprovalForAllDelegation(msg.sender, operator, approved);\r\n  }\r\n\r\n  /// @notice functeion to set the approval operator for both delegation and for spending NFTs of the msg.sender\r\n  /// @param operator is the address who will be allowed to spend and delegate\r\n  /// @param approved is the bool determining if they are allowed or not\r\n  function setApprovalForOperator(address operator, bool approved) public virtual {\r\n    _setApprovalForAllDelegation(msg.sender, operator, approved);\r\n    _setApprovalForAll(msg.sender, operator, approved);\r\n  }\r\n\r\n  /****INTERNAL FUNCTIONS**************************************************************************************/\r\n\r\n  /// @notice internal function to update the storage of approvedDelegators and emit the event\r\n  function _approveDelegator(address delegator, uint256 planId) internal virtual {\r\n    _approvedDelegators[planId] = delegator;\r\n    emit DelegatorApproved(planId, ownerOf(planId), delegator);\r\n  }\r\n\r\n  /// @notice internal function to update the storage of approvedOperatorDelegators, and emit the event\r\n  function _setApprovalForAllDelegation(address owner, address operator, bool approved) internal virtual {\r\n    require(owner != operator, '!operator');\r\n    _approvedOperatorDelegators[owner][operator] = approved;\r\n    emit ApprovalForAllDelegation(owner, operator, approved);\r\n  }\r\n\r\n  /// @notice internal view function to determine if a delegator, typically the msg.sender is allowed to delegate a token, based on being either the Owner, Delegator or Operator.\r\n  function _isApprovedDelegatorOrOwner(address delegator, uint256 planId) internal view returns (bool) {\r\n    address owner = ownerOf(planId);\r\n    return (delegator == owner ||\r\n      isApprovedForAllDelegation(owner, delegator) ||\r\n      getApprovedDelegator(planId) == delegator);\r\n  }\r\n\r\n  /***********************PUBLIC VIEW FUNCTIONS***********************************************************/\r\n\r\n  /// @notice function to get the approved delegator of a single planId\r\n  function getApprovedDelegator(uint256 planId) public view returns (address) {\r\n    return _approvedDelegators[planId];\r\n  }\r\n\r\n  /// @notice function to evaluate if an operator is approved to manage delegations of an owner address\r\n  function isApprovedForAllDelegation(address owner, address operator) public view returns (bool) {\r\n    return _approvedOperatorDelegators[owner][operator];\r\n  }\r\n\r\n}\r\n"
      },
      "contracts/interfaces/IVesting.sol": {
        "content": "// SPDX-License-Identifier: BUSL-1.1\r\npragma solidity 0.8.24;\r\n\r\ninterface IVesting {\r\n  struct Plan {\r\n    address token;\r\n    uint256 amount;\r\n    uint256 start;\r\n    uint256 cliff;\r\n    uint256 rate;\r\n    uint256 period;\r\n    address vestingAdmin;\r\n    bool adminTransferOBO;\r\n  }\r\n\r\n  function plans(uint256 planId) external view returns (Plan memory);\r\n\r\n  function redeemPlans(uint256[] calldata planIds) external;\r\n\r\n  function delegate(uint256 planId, address delegatee) external;\r\n\r\n  function delegatePlans(uint256[] calldata planIds, address[] calldata delegatees) external;\r\n\r\n  function setupVoting(uint256 planId) external returns (address votingVault);\r\n\r\n  function toggleAdminTransferOBO(uint256 planId, bool adminTransferOBO) external;\r\n\r\n  function ownerOf(uint256 planId) external view returns (address owner);\r\n\r\n  function planBalanceOf(\r\n    uint256 planId,\r\n    uint256 timeStamp,\r\n    uint256 redemptionTime\r\n  ) external view returns (uint256 balance, uint256 remainder, uint256 latestUnlock);\r\n\r\n  function planEnd(uint256 planId) external view returns (uint256 end);\r\n}"
      },
      "contracts/libraries/TransferHelper.sol": {
        "content": "// SPDX-License-Identifier: BUSL-1.1\r\npragma solidity 0.8.24;\r\n\r\nimport '@openzeppelin/contracts/token/ERC20/IERC20.sol';\r\nimport '@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol';\r\n\r\n\r\n/// @notice Library to help safely transfer tokens to and from contracts, only supports ERC20 tokens that are not deflationary or tax tokens. \r\nlibrary TransferHelper {\r\n  using SafeERC20 for IERC20;\r\n\r\n  /// @notice Internal function used for standard ERC20 transferFrom method\r\n  /// @notice it contains a pre and post balance check\r\n  /// @notice as well as a check on the msg.senders balance\r\n  /// @param token is the address of the ERC20 being transferred\r\n  /// @param from is the remitting address\r\n  /// @param to is the location where they are being delivered\r\n  function transferTokens(\r\n    address token,\r\n    address from,\r\n    address to,\r\n    uint256 amount\r\n  ) internal {\r\n    uint256 priorBalance = IERC20(token).balanceOf(address(to));\r\n    require(IERC20(token).balanceOf(from) >= amount, 'THL01');\r\n    SafeERC20.safeTransferFrom(IERC20(token), from, to, amount);\r\n    uint256 postBalance = IERC20(token).balanceOf(address(to));\r\n    require(postBalance - priorBalance == amount, 'THL02');\r\n  }\r\n\r\n  /// @notice Internal function is used with standard ERC20 transfer method\r\n  /// @notice this function ensures that the amount received is the amount sent with pre and post balance checking\r\n  /// @param token is the ERC20 contract address that is being transferred\r\n  /// @param to is the address of the recipient\r\n  /// @param amount is the amount of tokens that are being transferred\r\n  function withdrawTokens(\r\n    address token,\r\n    address to,\r\n    uint256 amount\r\n  ) internal {\r\n    uint256 priorBalance = IERC20(token).balanceOf(address(to));\r\n    SafeERC20.safeTransfer(IERC20(token), to, amount);\r\n    uint256 postBalance = IERC20(token).balanceOf(address(to));\r\n    require(postBalance - priorBalance == amount, 'THL02');\r\n  }\r\n\r\n}\r\n"
      },
      "contracts/libraries/UnlockLibrary.sol": {
        "content": "// SPDX-License-Identifier: BUSL-1.1\r\npragma solidity 0.8.24;\r\n\r\nlibrary UnlockLibrary {\r\n\r\n  /// @notice function to calculate the end date of a plan based on its start, amount, rate and period\r\n  function endDate(uint256 start, uint256 amount, uint256 rate, uint256 period) internal pure returns (uint256 end) {\r\n    end = (amount % rate == 0) ? (amount / rate) * period + start : ((amount / rate) * period) + period + start;\r\n  }\r\n\r\n  /// @notice function to validate the end date of a vesting lock\r\n  /// @param start is the start date of the lockup\r\n  /// @param cliff is the cliff date of the lockup\r\n  /// @param amount is the total amount of tokens in the lockup, which would be the entire amount of the vesting plan\r\n  /// @param rate is the amount of tokens that unlock per period\r\n  /// @param period is the seconds in each period, a 1 is a period of 1 second whereby tokens unlock every second\r\n  /// @param vestingEnd is the end date of the vesting plan\r\n  /// @dev this function validates the lockup end date against 0 entry values, plus ensures that the cliff date is at least the same as the end date\r\n  /// and finally it chekcs that if the lock isn't a single date unlock, that the end date is beyond the vesting end date\r\n  function validateEnd(\r\n    uint256 start,\r\n    uint256 cliff,\r\n    uint256 amount,\r\n    uint256 rate,\r\n    uint256 period,\r\n    uint256 vestingEnd\r\n  ) internal pure returns (uint256 end) {\r\n    require(amount > 0, '0_amount');\r\n    require(rate > 0, '0_rate');\r\n    require(rate <= amount, 'rate > amount');\r\n    require(period > 0, '0_period');\r\n    end = endDate(start, amount, rate, period);\r\n    require(cliff <= end, 'cliff > end');\r\n    if (rate < amount) {\r\n      require(end >= vestingEnd, 'end error');\r\n    }\r\n  }\r\n\r\n  /// @notice function to calculate the unlocked (claimable) balance, still locked balance, and the most recent timestamp the unlock would take place\r\n  /// the most recent unlock time is based on the periods, so if the periods are 1, then the unlock time will be the same as the redemption time,\r\n  /// however if the period more than 1 second, the latest unlock will be a discrete time stamp\r\n  /// @param start is the start time of the plan\r\n  /// @param cliffDate is the timestamp of the cliff of the plan\r\n  /// @param totalAmount is the total amount of tokens in the vesting plan\r\n  /// @param availableAmount is the total unclaimed amount tokens still in the vesting plan\r\n  /// @param rate is the amount of tokens that unlock per period\r\n  /// @param period is the seconds in each period, a 1 is a period of 1 second whereby tokens unlock every second\r\n  /// @param redemptionTime is the time requested for the plan to be redeemed, this can be the same as the current time or prior to it for partial redemptions\r\n  function balanceAtTime(\r\n    uint256 start,\r\n    uint256 cliffDate,\r\n    uint256 totalAmount,\r\n    uint256 availableAmount,\r\n    uint256 rate,\r\n    uint256 period,\r\n    uint256 redemptionTime\r\n  ) internal pure returns (uint256 unlockedBalance, uint256 lockedBalance, uint256 unlockTime) {\r\n    if (start > redemptionTime || cliffDate > redemptionTime) {\r\n      // if the start date or cliff date are in the future, nothing is unlocked\r\n      lockedBalance = availableAmount;\r\n      unlockTime = start;\r\n      unlockedBalance = 0;\r\n    } else if (availableAmount < rate && totalAmount > rate) {\r\n      // if the available amount is less than the rate, and the total amount is greater than the rate,\r\n      // then it is still mid vesting or unlock stream, and so we cant unlock anything because we need to wait for the available amount to be greater than the rate\r\n      lockedBalance = availableAmount;\r\n      unlockTime = start;\r\n      unlockedBalance = 0;\r\n    } else {\r\n      /// need to make sure clock is set correctly\r\n      uint256 periodsElapsed = (redemptionTime - start) / period;\r\n      uint256 calculatedBalance = periodsElapsed * rate;\r\n      uint256 availablePeriods = availableAmount / rate;\r\n      if (totalAmount <= calculatedBalance && availableAmount <= calculatedBalance) {\r\n        /// if the total and the available are less than the calculated amount, then we can redeem the entire available balance\r\n        lockedBalance = 0;\r\n        unlockTime = start + (period * availablePeriods);\r\n        unlockedBalance = availableAmount;\r\n      } else if (availableAmount < calculatedBalance) {\r\n        // else if the available is less than calculated but total is still more than calculated amount - we are still in the middle of vesting terms\r\n        // so we need to determine the total number of periods we can actually unlock, which is the available amount divided by the rate\r\n        unlockedBalance = availablePeriods * rate;\r\n        lockedBalance = availableAmount - unlockedBalance;\r\n        unlockTime = start + (period * availablePeriods);\r\n      } else {\r\n        // the calculated amount is less than available and total, so we just unlock the calculated amount\r\n        unlockedBalance = calculatedBalance;\r\n        lockedBalance = availableAmount - unlockedBalance;\r\n        unlockTime = start + (period * periodsElapsed);\r\n      }\r\n    }\r\n  }\r\n}\r\n"
      },
      "contracts/periphery/VotingVault.sol": {
        "content": "// SPDX-License-Identifier: BUSL-1.1\r\npragma solidity 0.8.24;\r\n\r\nimport '../libraries/TransferHelper.sol';\r\n\r\ninterface IGovernanceToken {\r\n  function delegate(address delegatee) external;\r\n  function delegates(address wallet) external view returns (address delegate);\r\n}\r\n\r\ncontract VotingVault {\r\n  address public token;\r\n  address public controller;\r\n\r\n  constructor(address _token, address beneficiary) {\r\n    controller = msg.sender;\r\n    token = _token;\r\n    address existingDelegate = IGovernanceToken(token).delegates(beneficiary);\r\n    if (existingDelegate != address(0)) IGovernanceToken(token).delegate(existingDelegate);\r\n    else IGovernanceToken(token).delegate(beneficiary);\r\n  }\r\n\r\n  modifier onlyController() {\r\n    require(msg.sender == controller);\r\n    _;\r\n  }\r\n\r\n    /// @notice function to delegate the tokens of this address\r\n    /// @dev if the delegatee is the existing delegate, skip the delegate function call - would be redundant\r\n  function delegateTokens(address delegatee) external onlyController {\r\n    address existingDelegate = IGovernanceToken(token).delegates(address(this));\r\n    if (existingDelegate != delegatee) {\r\n      uint256 balanceCheck = IERC20(token).balanceOf(address(this));\r\n      IGovernanceToken(token).delegate(delegatee);\r\n      // check to make sure delegate function is not malicious\r\n      require(balanceCheck == IERC20(token).balanceOf(address(this)));\r\n    }\r\n  }\r\n\r\n  function withdrawTokens(address to, uint256 amount) external onlyController {\r\n    TransferHelper.withdrawTokens(token, to, amount);\r\n  }\r\n}\r\n"
      },
      "contracts/TokenVestingLock.sol": {
        "content": "// SPDX-License-Identifier: BUSL-1.1\r\npragma solidity 0.8.24;\r\n\r\nimport '@openzeppelin/contracts/token/ERC721/ERC721.sol';\r\nimport '@openzeppelin/contracts/utils/ReentrancyGuard.sol';\r\nimport './ERC721Delegate/ERC721Delegate.sol';\r\nimport '@openzeppelin/contracts/token/ERC20/IERC20.sol';\r\nimport '@openzeppelin/contracts/token/ERC721/utils/ERC721Holder.sol';\r\n\r\nimport './libraries/UnlockLibrary.sol';\r\nimport './libraries/TransferHelper.sol';\r\nimport './interfaces/IVesting.sol';\r\nimport './periphery/VotingVault.sol';\r\n\r\n/// @title TokenVestingLock\r\n/// @notice This contract is used exclusively as an add-module for the Hedgey Vesting Plans to allow an additional lockup mechanism for tokens that are vesting\r\n/// This contract will point to exactly one specific Hedgey Vesting contract, and it will allow for the holder of the plan to redeem their vesting tokens\r\n/// but will conform to an additional lockup schedule where vested tokens are subject to the lockup, and can only be fully redeemed by the beneficiary\r\n/// based on the combined vesting and lockups schedules.\r\n/// @dev this contract is an ERC721 Enumerable extenstion that physically holds the Hedgey Vesting NFTs and issues recipients an NFT representing both the vesting and lockup schedule\r\n/// @author iceman from Hedgey\r\n\r\ncontract TokenVestingLock is ERC721Delegate, ReentrancyGuard, ERC721Holder {\r\n  /// @dev this is the implementation stored of the specific Hedgey Vesting contract this particular lockup contract is tied to\r\n  IVesting public immutable hedgeyVesting;\r\n\r\n  /// @notice for security only a special hedgey plan creator address is able to mint these NFTs in addition to vesting admin of a plan\r\n  address public hedgeyPlanCreator;\r\n\r\n  string public baseURI;\r\n  /// @dev manager for setting the baseURI & hedgeyPlanCreator contract;\r\n  address internal manager;\r\n\r\n  /// @notice the internal counter of tokenIds that will be mapped to each vestinglock object and the associated NFT\r\n  uint256 internal _tokenIds;\r\n\r\n  /// @notice a struct that is used for creation of a new lockup that defines the beneficiary and if the vesting admin can redeem on behalf\r\n  struct Recipient {\r\n    address beneficiary;\r\n    bool adminRedeem;\r\n  }\r\n\r\n  /// @notice primary struct defining the vesting lockup and its schedule\r\n  /// @param token is the address of the token that is locked up and vesting\r\n  /// @param totalAmount is the total amount - this comes from the vesting plan at inception and has to match\r\n  /// @param availableAmount is the actual amount of tokens that have vested and been redeemed into this contract that are maximally available to unlock at any time\r\n  /// @param start is the start date of the lockup schedule in block time\r\n  /// @param cliff is the cliff date of the lockup schedule in block time\r\n  /// @param rate is the rate at which tokens unlock per period. So if the rate is 100 and period is 1, then 100 tokens unlock per 1 second\r\n  /// @param period is the length of each discrete period. a \"streaming\" version uses a period of 1 for 1 second but daily is 86400 as example\r\n  /// @param vestingTokenId is the specific NFT token ID that is tied to the vesting plan\r\n  /// @param vestingAdmin is the administrator on the vesting plan, this is the only address that can edit the lockup schedule\r\n  /// @param transferable this is a toggle that the admin can define and allow the NFT to be transferred to another wallet by the owner of the lockup\r\n  /// @param adminTransferOBO this is a toggle that would led the vestingAdmin transfer the lockup NFT to another wallet on behalf of the owner in case of emergency\r\n  struct VestingLock {\r\n    address token;\r\n    uint256 totalAmount;\r\n    uint256 availableAmount;\r\n    uint256 start;\r\n    uint256 cliff;\r\n    uint256 rate;\r\n    uint256 period;\r\n    uint256 vestingTokenId;\r\n    address vestingAdmin;\r\n    bool transferable;\r\n    bool adminTransferOBO;\r\n  }\r\n\r\n  /// @notice this is mapping of the VestingLock struct to the tokenIds which represent each NFT\r\n  mapping(uint256 => VestingLock) internal _vestingLocks;\r\n\r\n  /// @notice this is a mapping of the vestingTokenIds that have been allocted to a lockup NFT so that lockup NFTs are always mapped ONLY one to one to a vesting plan\r\n  mapping(uint256 => bool) internal _allocatedVestingTokenIds;\r\n\r\n  /// @notice this is a mapping of the approved redeemeers that can redeem the vested tokens or unlock the unlocked tokens, used as a mechanism for redeeming on behalf\r\n  /// @dev if the user sets the zero address to be true, then it is a global approval for anyone to redeem\r\n  mapping(uint256 => mapping(address => bool)) internal _approvedRedeemers;\r\n\r\n  mapping(address => mapping(address => bool)) internal _redeemerOperators;\r\n\r\n  /// @notice separate mapping specifically defining if the vestingAdmin can redeem on behalf of end users\r\n  mapping(uint256 => bool) internal _adminRedeem;\r\n\r\n  /// @notice this is a mapping of the voting vaults owned by the locked NFTs specifically used for onchain voting and delegation\r\n  mapping(uint256 => address) public votingVaults;\r\n\r\n  /*************EVENTS****************************************************************************************************/\r\n  /// @notice events\r\n  event VestingLockupCreated(\r\n    uint256 indexed lockId,\r\n    uint256 indexed vestingTokenId,\r\n    address indexed beneficiary,\r\n    VestingLock lock,\r\n    uint256 lockEnd\r\n  );\r\n  event TokensUnlocked(uint256 indexed lockId, uint256 unlockedAmount, uint256 remainingTotal, uint256 unlockTime);\r\n  event VestingRedeemed(\r\n    uint256 indexed lockId,\r\n    uint256 indexed vestingId,\r\n    uint256 redeemedAmount,\r\n    uint256 availableAmount,\r\n    uint256 totalAmount\r\n  );\r\n  event LockEdited(uint256 indexed lockId, uint256 start, uint256 cliff, uint256 rate, uint256 period, uint256 end);\r\n\r\n  event RedeemerApproved(uint256 indexed lockId, address redeemer);\r\n  event RedeemerRemoved(uint256 indexed lockId, address redeemer);\r\n  event AdminRedemption(uint256 indexed lockId, bool enabled);\r\n  event VotingVaultCreated(uint256 indexed lockId, address votingVault);\r\n\r\n  event VestingAdminUpdated(uint256 indexed lockId, address newAdmin);\r\n  event TransferabilityUpdated(uint256 indexed lockId, bool transferable);\r\n  event LockAdminTransferToggle(uint256 indexed id, bool transferable);\r\n\r\n  event URISet(string newURI);\r\n  event ManagerChanged(address newManager);\r\n  event PlanCreatorChanged(address newPlanCreator);\r\n\r\n  /*************CONSTRUCTOR & URI ADMIN FUNCTIONS****************************************************************************************************/\r\n\r\n  /// @notice the constructor maps the specific hedgey vesting contract at inception and takes in the hedgeyPlanCreator address for minting the NFTs\r\n  /// @dev note that these cannot be changed after deployment!\r\n  constructor(\r\n    string memory name,\r\n    string memory symbol,\r\n    address _hedgeyVesting,\r\n    address _hedgeyPlanCreator,\r\n    address _manager\r\n  ) ERC721(name, symbol) {\r\n    hedgeyVesting = IVesting(_hedgeyVesting);\r\n    hedgeyPlanCreator = _hedgeyPlanCreator;\r\n    manager = _manager;\r\n  }\r\n\r\n  modifier onlyManager() {\r\n    require(msg.sender == manager, '!M');\r\n    _;\r\n  }\r\n\r\n  /// @notice override function to deliver custom baseURI\r\n  function _baseURI() internal view override returns (string memory) {\r\n    return baseURI;\r\n  }\r\n\r\n  /// @notice function to set the base URI after the contract has been launched, only the admin can call\r\n  /// @param _uri is the new baseURI for the metadata\r\n  function updateBaseURI(string memory _uri) external onlyManager {\r\n    baseURI = _uri;\r\n    emit URISet(_uri);\r\n  }\r\n\r\n  /// @notice function to change the admin address\r\n  /// @param newManager is the new address for the admin\r\n  function changeManager(address newManager) external onlyManager {\r\n    manager = newManager;\r\n    emit ManagerChanged(newManager);\r\n  }\r\n\r\n  /// @notice function to update the plan creator address in the case of updates to the functionality\r\n  /// @param newCreator is the new address for the plan creator\r\n  /// @dev only the admin can call this function\r\n  function updatePlanCreator(address newCreator) external onlyManager {\r\n    hedgeyPlanCreator = newCreator;\r\n    emit PlanCreatorChanged(newCreator);\r\n  }\r\n\r\n  /*****TOKEN ID FUNCTIONS*************************************************************************************/\r\n  /// @notice function to increment the tokenId counter, and returns the current tokenId after inrecmenting\r\n  function incrementTokenId() internal returns (uint256) {\r\n    _tokenIds++;\r\n    return _tokenIds;\r\n  }\r\n  /// @notice function to get the current running total of tokenId, useful for when totalSupply does not match\r\n  function currentTokenId() external view returns (uint256) {\r\n    return _tokenIds;\r\n  }\r\n\r\n  /***PUBLIC GETTER FUNCTIONS***************************************************************************************************/\r\n\r\n  /// @notice function to get the lock details of a specific lock NFT\r\n  /// @param lockId is the token Id of the NFT\r\n  function getVestingLock(uint256 lockId) external view returns (VestingLock memory) {\r\n    return _vestingLocks[lockId];\r\n  }\r\n\r\n  /// @notice function to get the end date of a specific lock NFT\r\n  /// @param lockId is the token Id of the NFT\r\n  function getLockEnd(uint256 lockId) external view returns (uint256 end) {\r\n    VestingLock memory lock = _vestingLocks[lockId];\r\n    end = UnlockLibrary.endDate(lock.start, lock.totalAmount, lock.rate, lock.period);\r\n  }\r\n\r\n  /// @notice function to get the balance of a specific lock NFT at the current time\r\n  /// @param lockId is the token Id of the NFT\r\n  /// @dev the unlockedBalance is the amount of tokens that can be unlocked now, with the upper limit of the available amount that has already been vested and redeemed\r\n  /// @dev the locked balance is the amount of tokens still locked based ont he lockup schedule\r\n  /// @dev the unlockTime is the timestamp when the lock resets based on how many periods were able to be unlocked\r\n  function getLockBalance(\r\n    uint256 lockId\r\n  ) external view returns (uint256 unlockedBalance, uint256 lockedBalance, uint256 unlockTime) {\r\n    VestingLock memory lock = _vestingLocks[lockId];\r\n    (unlockedBalance, lockedBalance, unlockTime) = UnlockLibrary.balanceAtTime(\r\n      lock.start,\r\n      lock.cliff,\r\n      lock.totalAmount,\r\n      lock.availableAmount,\r\n      lock.rate,\r\n      lock.period,\r\n      block.timestamp\r\n    );\r\n  }\r\n\r\n  /***********************REDEEMER FUNCTIONS**********************************************************************/\r\n\r\n  /// @notice function to approve a new redeemer who can call the redeemVesting or unlock functions\r\n  /// @param lockId is the token Id of the NFT\r\n  /// @param redeemer is the address of the new redeemer (it can be the zero address)\r\n  /// @dev only owner of the NFT can call this function\r\n  /// @dev if the zero address is set to true, then it becomes publicly avilable for anyone to redeem\r\n  function approveRedeemer(uint256 lockId, address redeemer) external {\r\n    require(msg.sender == ownerOf(lockId) || _redeemerOperators[ownerOf(lockId)][msg.sender]);\r\n    _approvedRedeemers[lockId][redeemer] = true;\r\n    emit RedeemerApproved(lockId, redeemer);\r\n  }\r\n\r\n  /// @notice function to remove an approved redeemer\r\n  /// @param lockId is the token Id of the NFT\r\n  /// @param redeemer is the address of the redeemer to be removed\r\n  /// @dev this function simply deletes the storage of the approved redeemer\r\n  function removeRedeemer(uint256 lockId, address redeemer) external {\r\n    require(msg.sender == ownerOf(lockId) || _redeemerOperators[ownerOf(lockId)][msg.sender]);\r\n    delete _approvedRedeemers[lockId][redeemer];\r\n    emit RedeemerRemoved(lockId, redeemer);\r\n  }\r\n\r\n  function approveRedeemerOperator(address operator, bool approved) external {\r\n    _redeemerOperators[msg.sender][operator] = approved;\r\n  }\r\n\r\n  /// @notice function to set the admin redemption toggle on a specific lock NFT\r\n  /// @param lockId is the token Id of the NFT\r\n  /// @param enabled is the boolean toggle to allow the vesting admin to redeem on behalf of the owner\r\n  function setAdminRedemption(uint256 lockId, bool enabled) external {\r\n    require(msg.sender == ownerOf(lockId) || _redeemerOperators[ownerOf(lockId)][msg.sender]);\r\n    _adminRedeem[lockId] = enabled;\r\n    emit AdminRedemption(lockId, enabled);\r\n  }\r\n\r\n  /// @notice function to check if the admin can redeem on behalf of the owner\r\n  /// @param lockId is the token Id of the NFT\r\n  /// @param admin is the address of the admin\r\n  function adminCanRedeem(uint256 lockId, address admin) public view returns (bool) {\r\n    return (_adminRedeem[lockId] && admin == _vestingLocks[lockId].vestingAdmin);\r\n  }\r\n\r\n  /// @notice function to check if a specific address is an approved redeemer\r\n  /// @param lockId is the token Id of the NFT\r\n  /// @param redeemer is the address of the redeemer\r\n  /// @dev will return true if the redeemer is the owner of the NFT, if the redeemer is approved or if the 0x0 address is approved, or if the redeemer is the admin address\r\n  function isApprovedRedeemer(uint256 lockId, address redeemer) public view returns (bool) {\r\n    address owner = ownerOf(lockId);\r\n    return (owner == redeemer ||\r\n      _approvedRedeemers[lockId][redeemer] ||\r\n      _approvedRedeemers[lockId][address(0x0)] ||\r\n      _redeemerOperators[owner][redeemer] ||\r\n      adminCanRedeem(lockId, redeemer));\r\n  }\r\n\r\n  /******CORE EXTERNAL FUNCTIONS *********************************************************************************************/\r\n\r\n  /// @notice function to create a new lockup NFT for a vesting plan\r\n  /// @param recipient is the struct that defines the beneficiary and if the vesting admin can redeem on behalf\r\n  /// @param vestingTokenId is the specific NFT token ID that is tied to the vesting plan\r\n  /// @param start is the start date of the lockup schedule in block time\r\n  /// @param cliff is the cliff date of the lockup schedule in block time\r\n  /// @param rate is the rate at which tokens unlock per period\r\n  /// @param period is the length of each discrete period\r\n  /// @param transferable is the toggle that allows the NFT to be transferred to another wallet by the owner of the lockup\r\n  /// @param adminTransferOBO is the toggle that would led the vestingAdmin transfer the lockup NFT to another wallet on behalf of the owner in case of emergency\r\n  /// @dev this function will check that the vesting plan is owned by this contract, and that the vesting plan is not already allocated to a lockup NFT\r\n  /// the function will also check that the caller is the hedgeyPlanCreator or the vestingAdmin of the plan\r\n  /// the function will automatically set the totalAmount to the vesting plan amount, the token address to the vesting plan token address, and the vesting admin to the vestingAdmin of the vesting plan\r\n  /// the function will perform a special check, if the plan is set to unlock the tokens all at once on a single date - where the rate is equal to the total amount\r\n  /// then it will set the period to 1. Otherwise it will check that the lock end is greater than or equal to the vesting end\r\n  /// the function will increment the tokenIds counter and store the new lockup NFT in the _vestingLocks mapping\r\n  /// the function will then safeMint the new NFT to the recipient\r\n  /// the function will toggle the vestingAdminTransfer to false for the vesting plan so that it cannot be pulled out of the lockup contract without approval from the recipient\r\n  /// @dev this function is called either at the creation of both a new vesting plan with a lockup, which is the most common use case and done by the hdedgeyPlanCreator\r\n  /// or it can be done after the fact if a vesting plan is transferred into this contract, and then the vesting admin calls this function to add a lockup schedule to the unallocated vesting plan\r\n  function createVestingLock(\r\n    Recipient memory recipient,\r\n    uint256 vestingTokenId,\r\n    uint256 start,\r\n    uint256 cliff,\r\n    uint256 rate,\r\n    uint256 period,\r\n    bool transferable,\r\n    bool adminTransferOBO\r\n  ) external nonReentrant returns (uint256 newLockId) {\r\n    require(!_allocatedVestingTokenIds[vestingTokenId], 'a');\r\n    require(hedgeyVesting.ownerOf(vestingTokenId) == address(this));\r\n    _allocatedVestingTokenIds[vestingTokenId] = true;\r\n    address vestingAdmin = hedgeyVesting.plans(vestingTokenId).vestingAdmin;\r\n    require(msg.sender == hedgeyPlanCreator || msg.sender == vestingAdmin);\r\n    uint256 totalAmount = hedgeyVesting.plans(vestingTokenId).amount;\r\n    if (rate == totalAmount) period = 1;\r\n    address token = hedgeyVesting.plans(vestingTokenId).token;\r\n    uint256 vestingEnd = hedgeyVesting.planEnd(vestingTokenId);\r\n    uint256 lockEnd = UnlockLibrary.validateEnd(start, cliff, totalAmount, rate, period, vestingEnd);\r\n    newLockId = incrementTokenId();\r\n    _vestingLocks[newLockId] = VestingLock(\r\n      token,\r\n      totalAmount,\r\n      0,\r\n      start,\r\n      cliff,\r\n      rate,\r\n      period,\r\n      vestingTokenId,\r\n      vestingAdmin,\r\n      transferable,\r\n      adminTransferOBO\r\n    );\r\n    if (recipient.adminRedeem) {\r\n      _adminRedeem[newLockId] = true;\r\n      emit AdminRedemption(newLockId, true);\r\n    }\r\n    _safeMint(recipient.beneficiary, newLockId);\r\n    hedgeyVesting.toggleAdminTransferOBO(vestingTokenId, false);\r\n    emit VestingLockupCreated(newLockId, vestingTokenId, recipient.beneficiary, _vestingLocks[newLockId], lockEnd);\r\n  }\r\n\r\n  /// @notice function to redeem the vested tokens and immediateyl unlock whatever is available for multiple vesting lockups\r\n  /// @param lockIds is the array of tokenIds of the lockup NFTs\r\n  /// @dev this function will iterate through the array of lockIds and call the internal _redeemVesting function and then immediately call the internal _unlock function\r\n  /// the function will pull any tokens that are vested into this contract, and then unlock any avilable and unlocked tokens and transfer them to the owner of the NFT - the beneficiary\r\n  /// if there is nothing vested or unlocked, it will simply skip the redemption & unlocking and move onto the next tokenId rather than reverting the whole transaction\r\n  /// this allows for a vestingAdmin who is redeeming on behalf of a group of users to redeem all of the tokens they are an admin for without having to calculate which ones have available balances and which do not\r\n  function redeemAndUnlock(\r\n    uint256[] calldata lockIds\r\n  )\r\n    external\r\n    nonReentrant\r\n    returns (uint256[] memory redeemedBalances, uint256[] memory vestingRemainder, uint256[] memory unlockedBalances)\r\n  {\r\n    uint256 l = lockIds.length;\r\n    redeemedBalances = new uint256[](l);\r\n    vestingRemainder = new uint256[](l);\r\n    unlockedBalances = new uint256[](l);\r\n    for (uint256 i; i < l; i++) {\r\n      (redeemedBalances[i], vestingRemainder[i]) = _redeemVesting(lockIds[i]);\r\n      unlockedBalances[i] = _unlock(lockIds[i]);\r\n    }\r\n  }\r\n\r\n  /// @notice function to unlock tokens from an lockup\r\n  /// @param lockIds is the array of tokenIds of the lockup NFTs\r\n  /// @dev this function assumes that there are tokens that are vested and have already been redeemed and pulled into this contract that are now just locked and ready to be unlocked\r\n  /// if there is nothing to unlock the function will not revert but no tokens will be moved\r\n  function unlock(uint256[] calldata lockIds) external nonReentrant returns (uint256[] memory unlockedBalances) {\r\n    uint256 l = lockIds.length;\r\n    unlockedBalances = new uint256[](l);\r\n    for (uint256 i; i < l; i++) {\r\n      unlockedBalances[i] = _unlock(lockIds[i]);\r\n    }\r\n  }\r\n  /// @notice function to redeem the vested tokens from the vesting plan associated with a specific lockup\r\n  /// @param lockIds is the array of tokenIds of the lockup NFTs\r\n  /// @dev this function will redeem anything that has vested, and the vested tokens will be pulled into this contract\r\n  /// if there are no vested tokens for a specific plan, it will not revert but simply skip it on underlying the vesting contract logic itself\r\n  function redeemVestingPlans(\r\n    uint256[] calldata lockIds\r\n  ) external nonReentrant returns (uint256[] memory balances, uint256[] memory remainders) {\r\n    uint256 l = lockIds.length;\r\n    balances = new uint256[](l);\r\n    remainders = new uint256[](l);\r\n    for (uint256 i; i < l; i++) {\r\n      (balances[i], remainders[i]) = _redeemVesting(lockIds[i]);\r\n    }\r\n  }\r\n\r\n  /// @notice function to burn a lockup NFT where the vesting plan NFT has been revoked and is burned\r\n  /// @param lockId is the token Id of the lockup NFT associated with the revoked vesting plan\r\n  /// @dev this function requires only the owner of the lockup NFT to call it\r\n  /// it will check that the available amount is 0, so that the owner is not burning an NFT and thus losing the tokens that are still locked\r\n  /// it will the use the try / catch patter to attempt to see if this contract is still the owner of the vesting plan.\r\n  /// if this contract is still the owner, then it will revert as clearly the vesting plan has not been burned\r\n  /// if the vesting plan is not owned by this contract anymore, then it will burn the lockup NFT and delete all storage of the lockup NFT\r\n  /// @dev this does allow for the ability for a vestingAdmin to transfer the vestingPlan out of this contract, then the owner to burn this NFT even if the vesting plan is still active\r\n  /// used only for emergency purposes where a mistake was made and the vesting plan was not supposed to be locked up or the lockup was wrong and needs to be adjusted\r\n  /// but since only the owner of the lockup can burn the lock NFT, this allows there to be a safety mechanism in place\r\n  /// such that it can be assumed there is agreement between the owner and the vestingAdmin to perform this emergency action\r\n  function burnRevokedVesting(uint256 lockId) external nonReentrant {\r\n    require(msg.sender == ownerOf(lockId), '!owner');\r\n    VestingLock memory lock = _vestingLocks[lockId];\r\n    require(lock.availableAmount == 0);\r\n    try hedgeyVesting.ownerOf(lock.vestingTokenId) returns (address vestingOwner) {\r\n      require(vestingOwner != address(this));\r\n      _burn(lockId);\r\n      delete _vestingLocks[lockId];\r\n      delete _allocatedVestingTokenIds[lock.vestingTokenId];\r\n    } catch {\r\n      _burn(lockId);\r\n      delete _vestingLocks[lockId];\r\n      delete _allocatedVestingTokenIds[lock.vestingTokenId];\r\n    }\r\n  }\r\n\r\n  /************CORE INTERNAL FUNCTIONS**************************************************************************************************/\r\n\r\n  /// @notice internal function to unlock tokens available for a specific lockup NFT\r\n  /// @param lockId is the token Id of the vestinglock NFT\r\n  /// @dev this function will check that the msg sender is an approved redeemer\r\n  /// then it will get the available balances that can be unlocked at the current time\r\n  /// @dev if the unlocked balance is 0, the function will simply return 0 as the unlocked Balance and will not process anything further\r\n  /// @dev if the function has an available unlocked balance it will check if the tokens are held externally at a voting vault\r\n  /// and then transfer the amount of unlocked tokens from either the voting vualt or this contract to the beneficiary and owner of the lock NFT\r\n  /// if the remaining total is now equal to 0, ie the total amount less the unlocked balance, then the vesting plan is burned and we can burn the lock NFT and delete it from storage\r\n  /// otherwise we will update the available amount to be the lockedBalance - where the locked balance only includes the available amount that has been physically vested and pulled into this contract already\r\n  /// update the start time to the unlock time\r\n  /// and update the totalAmount to be the reaminig total amount which is the initial lock total amount less the unlocked balance\r\n  function _unlock(uint256 lockId) internal returns (uint256 unlockedBalance) {\r\n    require(isApprovedRedeemer(lockId, msg.sender), '!app');\r\n    VestingLock memory lock = _vestingLocks[lockId];\r\n    uint256 lockedBalance;\r\n    uint256 unlockTime;\r\n    (unlockedBalance, lockedBalance, unlockTime) = UnlockLibrary.balanceAtTime(\r\n      lock.start,\r\n      lock.cliff,\r\n      lock.totalAmount,\r\n      lock.availableAmount,\r\n      lock.rate,\r\n      lock.period,\r\n      block.timestamp\r\n    );\r\n    if (unlockedBalance == 0) {\r\n      return 0;\r\n    }\r\n    if (votingVaults[lockId] != address(0)) {\r\n      VotingVault(votingVaults[lockId]).withdrawTokens(ownerOf(lockId), unlockedBalance);\r\n    } else {\r\n      TransferHelper.withdrawTokens(lock.token, ownerOf(lockId), unlockedBalance);\r\n    }\r\n    uint256 remainingTotal = lock.totalAmount - unlockedBalance;\r\n    if (remainingTotal == 0) {\r\n      _burn(lockId);\r\n      delete _vestingLocks[lockId];\r\n      delete _allocatedVestingTokenIds[lock.vestingTokenId];\r\n    } else {\r\n      _vestingLocks[lockId].availableAmount = lockedBalance;\r\n      _vestingLocks[lockId].start = unlockTime;\r\n      _vestingLocks[lockId].totalAmount = remainingTotal;\r\n    }\r\n    emit TokensUnlocked(lockId, unlockedBalance, remainingTotal, unlockTime);\r\n  }\r\n\r\n  /// @notice function to redeem the vested tokens from the vesting plan associated with a specific lockup\r\n  /// @param lockId is the token Id of the vestingLock NFT\r\n  /// @dev this function will check that the msg sender is an approved redeemer\r\n  /// @dev the function will check that the vesting plan is owned by this contract. If it is not then it will simply return 0,0\r\n  /// the function then checks the balance and remainder coming from the vesting plan contract itself. If the balance returns 0, then it will simply return 0,0\r\n  /// the function then calls the redeemPlans function on the vesting plan contract to redeem the vested tokens\r\n  /// the function performs a check ensuring that the balance calculated is the difference between the amount of tokens this contract holds before plus the redeemed balance equals the amount of tokens after\r\n  /// the function then updates the available amount of the vestingLock struct to add the newly received redeemed balance of tokens\r\n  /// then it will update the totalAmount of the lockup to equal the remainder of the vestingPlan plus available amount\r\n  /// so that the total equals the amount still held by the vesting plan contract, and the amount held by this contract address\r\n  // finally the function checks if the lockup has setup a voting vault, and if so it will transfer the tokens to the voting vault from this address\r\n  function _redeemVesting(uint256 lockId) internal returns (uint256 balance, uint256 remainder) {\r\n    require(isApprovedRedeemer(lockId, msg.sender), '!app');\r\n    uint256 vestingId = _vestingLocks[lockId].vestingTokenId;\r\n    require(_allocatedVestingTokenIds[vestingId], '!al');\r\n    try hedgeyVesting.ownerOf(vestingId) returns (address vestingOwner) {\r\n      if (vestingOwner != address(this)) {\r\n        _vestingLocks[lockId].totalAmount = _vestingLocks[lockId].availableAmount;\r\n        return (0, 0);\r\n      }\r\n    } catch {\r\n      // set the total amount to the available amount - this will allow the nft to be unlocked if there is anything left still available but not locked\r\n      _vestingLocks[lockId].totalAmount = _vestingLocks[lockId].availableAmount;\r\n      return (0, 0);\r\n    }\r\n    (balance, remainder, ) = hedgeyVesting.planBalanceOf(vestingId, block.timestamp, block.timestamp);\r\n    if (balance == 0) {\r\n      return (balance, remainder);\r\n    }\r\n    uint256 preRedemptionBalance = IERC20(_vestingLocks[lockId].token).balanceOf(address(this));\r\n    uint256[] memory vestingIds = new uint256[](1);\r\n    vestingIds[0] = vestingId;\r\n    hedgeyVesting.redeemPlans(vestingIds);\r\n    uint256 postRedemptionBalance = IERC20(_vestingLocks[lockId].token).balanceOf(address(this));\r\n    require(postRedemptionBalance - preRedemptionBalance == balance, '!r');\r\n    _vestingLocks[lockId].availableAmount += balance;\r\n    _vestingLocks[lockId].totalAmount = _vestingLocks[lockId].availableAmount + remainder;\r\n    if (votingVaults[lockId] != address(0)) {\r\n      TransferHelper.withdrawTokens(_vestingLocks[lockId].token, votingVaults[lockId], balance);\r\n    }\r\n    emit VestingRedeemed(\r\n      lockId,\r\n      vestingId,\r\n      balance,\r\n      _vestingLocks[lockId].availableAmount,\r\n      _vestingLocks[lockId].totalAmount\r\n    );\r\n  }\r\n\r\n  /************************************VESTING ADMIN FUNCTIONS**********************************************************/\r\n\r\n  /// @notice function for the vesting admin to change their address to a new admin.\r\n  /// @param lockIds is the array of tokenIds of the lockup NFTs\r\n  /// @param newAdmin is the address of the new vesting admin\r\n  /// @dev this function allows an admin to transfer in bulk\r\n  /// @dev this function will check that the msg.sender is either the current admin, or the new vesting plan admin\r\n  /// for the case where they have changed their address on the vesting plan contract and need to adjust it on the lockup contract as well\r\n  /// this function just updates the vestingAdmin storage for each plan to the new admin\r\n  function updateVestingAdmin(uint256[] memory lockIds, address newAdmin) external {\r\n    uint256 l = lockIds.length;\r\n    for (uint16 i; i < l; i++) {\r\n      uint256 lockId = lockIds[i];\r\n      address vestingAdmin = hedgeyVesting.plans(_vestingLocks[lockId].vestingTokenId).vestingAdmin;\r\n      require(msg.sender == _vestingLocks[lockId].vestingAdmin || msg.sender == vestingAdmin, '!vA');\r\n      _vestingLocks[lockId].vestingAdmin = newAdmin;\r\n      emit VestingAdminUpdated(lockId, newAdmin);\r\n    }\r\n  }\r\n\r\n  /// @notice function to update the transferability of a specific lock NFT\r\n  /// @param lockIds is the array of tokenIds of the lockup NFTs\r\n  /// @param transferable is a boolean toggle that allows the NFT to be transferred to another wallet by the owner of the lockup\r\n  /// @dev this function simply checks that only the current vestingAdmin can make this adjustment, and then updates the storage accordingly\r\n  function updateTransferability(uint256[] memory lockIds, bool transferable) external {\r\n    uint256 l = lockIds.length;\r\n    for (uint16 i; i < l; i++) {\r\n      require(msg.sender == _vestingLocks[lockIds[i]].vestingAdmin, '!vA');\r\n      _vestingLocks[lockIds[i]].transferable = transferable;\r\n      emit TransferabilityUpdated(lockIds[i], transferable);\r\n    }\r\n  }\r\n\r\n  /// @notice function to allow the admin to edit the lock details for a lock that hasn't started yet\r\n  /// @param lockId is the token Id of the lockup NFT\r\n  /// @param start is the start date of the new lockup schedule\r\n  /// @param cliff is the cliff date of the new lockup schedule\r\n  /// @param rate is the rate at which tokens unlock per period\r\n  /// @param period is the length of each discrete period\r\n  /// @dev this function can Only be called before the later of the start or the cliff - ie the lock must effectively not have started or have anything unlocked to change it\r\n  /// the function can only be called by the existing vesting admin\r\n  /// the function will update the vestinglock storage with the new start, cliff, rate, and period parameters\r\n  /// the function will also double check and update the vesting plan to pull in the new total amount, being the available amount and the amount still in the vesting plan\r\n  /// the function then validates that the end date\r\n  function editLockDetails(uint256 lockId, uint256 start, uint256 cliff, uint256 rate, uint256 period) external nonReentrant {\r\n    VestingLock storage lock = _vestingLocks[lockId];\r\n    require(msg.sender == lock.vestingAdmin, '!vA');\r\n    // must be before the later of the start or cliff\r\n    uint256 editableDate = lock.start > lock.cliff ? lock.start : lock.cliff;\r\n    require(block.timestamp < editableDate, '!e');\r\n    lock.start = start;\r\n    lock.cliff = cliff;\r\n    lock.rate = rate;\r\n    lock.totalAmount = hedgeyVesting.plans(lock.vestingTokenId).amount + lock.availableAmount;\r\n    lock.period = rate == lock.totalAmount ? 1 : period;\r\n    uint256 vestingEnd = hedgeyVesting.planEnd(lock.vestingTokenId);\r\n    uint256 end = UnlockLibrary.validateEnd(start, cliff, lock.totalAmount, rate, lock.period, vestingEnd);\r\n    emit LockEdited(lockId, start, cliff, rate, lock.period, end);\r\n  }\r\n\r\n  /*****************BENEFICIARY TRANSFERABILITY TOGGLES**********************************************************************/\r\n\r\n  /// @notice function to allow the admin to transfer on behalf of the beneficial owner of the vesting lock NFT\r\n  /// @param lockId is the token Id of the vesting lock NFT\r\n  /// @param adminTransferOBO is the boolean toggle that would led the vestingAdmin transfer the lockup NFT to another wallet on behalf of the owner in case of emergency\r\n  function updateAdminTransferOBO(uint256 lockId, bool adminTransferOBO) external {\r\n    require(msg.sender == ownerOf(lockId), '!owner');\r\n    _vestingLocks[lockId].adminTransferOBO = adminTransferOBO;\r\n    emit LockAdminTransferToggle(lockId, adminTransferOBO);\r\n  }\r\n\r\n  /// @notice function to allow the admin of the actual vesting plan to transfer the vesting plan out of this contract\r\n  /// @param lockId is the token Id of the vesting lock NFT\r\n  /// @param transferable is the a boolean toggle recorded in storage on the vesting contract that determines it the vestingAdmin can transfer the vesting plan to another wallet\r\n  /// @dev this function should be used carefully as it allows the vestingAdmin to transfer the vesting plan out of this contract - meaning the lockup will no longer be tied to the vesting plan\r\n  /// transferring the vesting plan out may be used in case of emergency, but it will also mean the lockup is no longer valid to redeem vesting anymore\r\n  function updateVestingTransferability(uint256 lockId, bool transferable) external {\r\n    require(msg.sender == ownerOf(lockId), '!owner');\r\n    hedgeyVesting.toggleAdminTransferOBO(_vestingLocks[lockId].vestingTokenId, transferable);\r\n  }\r\n\r\n  /***************DELEGATION FUNCTION FOR VESTING PLANS**********************************************************************************/\r\n\r\n  /// @notice function to delegate multiple plans to multiple delegates in a single transaction\r\n  /// @param lockIds is the array of tokenIds of the lockup NFTs\r\n  /// @param delegatees is the array of addresses that each corresponding planId will be delegated to\r\n  /// @dev this function will call the underlying vesting plan contract and delegate the tokens to the delegatee\r\n  function delegatePlans(uint256[] calldata lockIds, address[] calldata delegatees) external nonReentrant {\r\n    require(lockIds.length == delegatees.length);\r\n    uint256 l = lockIds.length;\r\n    uint256[] memory vestingIds = new uint256[](l);\r\n    for (uint256 i; i < l; i++) {\r\n      require(_isApprovedDelegatorOrOwner(msg.sender, lockIds[i]), '!d');\r\n      vestingIds[i] = _vestingLocks[lockIds[i]].vestingTokenId;\r\n    }\r\n    hedgeyVesting.delegatePlans(vestingIds, delegatees);\r\n  }\r\n\r\n  /***************DELEGATION FUNCTION FOR ERC721DELEGATE CONTRACT**********************************************************************************/\r\n\r\n  /// @notice functeion to delegate multiple plans to multiple delegates in a single transaction\r\n  /// @dev this also calls the internal _delegateToken function from ERC721Delegate.sol to delegate an NFT to another wallet.\r\n  /// @dev this function iterates through the array of plans and delegatees, delegating each individual NFT.\r\n  /// @param lockIds is the array of planIds that will be delegated\r\n  /// @param delegatees is the array of addresses that each corresponding planId will be delegated to\r\n  function delegateLockNFTs(uint256[] calldata lockIds, address[] calldata delegatees) external nonReentrant {\r\n    require(lockIds.length == delegatees.length);\r\n    uint256 l = lockIds.length;\r\n    for (uint256 i; i < l; i++) {\r\n      _delegateToken(delegatees[i], lockIds[i]);\r\n    }\r\n  }\r\n\r\n  /***************DELEGATION FUNCTION FOR ONCHAIN VOTING**********************************************************************************/\r\n\r\n  /// @notice this function allows an owner of multiple vesting plans to delegate multiple of them in a single transaction, each planId corresponding to a delegatee address\r\n  /// @dev this function should only be used for onchain voting and delegation with an ERC20Votes token\r\n  /// @param lockIds is the ids of the vesting plan and NFT\r\n  /// @param delegatees is the array of addresses where each vesting plan will delegate the tokens to\r\n  function delegateLockPlans(\r\n    uint256[] calldata lockIds,\r\n    address[] calldata delegatees\r\n  ) external nonReentrant returns (address[] memory) {\r\n    require(lockIds.length == delegatees.length);\r\n    uint256 l = lockIds.length;\r\n    address[] memory vaults = new address[](l);\r\n    for (uint256 i; i < l; i++) {\r\n      vaults[i] = _delegate(lockIds[i], delegatees[i]);\r\n    }\r\n    return vaults;\r\n  }\r\n\r\n  /**************************INTERNAL ONCHAIN VOTING FUNCTIONS*************************************************************************************************************/\r\n\r\n  /// @notice the internal function to setup a voting vault.\r\n  /// @dev this will check that no voting vault exists already and then deploy a new voting vault contract\r\n  // during the constructor setup of the voting vault, it will auto delegate the voting vault address to whatever the existing delegate of the vesting plan holder has delegated to\r\n  // if it has not delegated yet, it will self-delegate the tokens\r\n  /// then transfer the tokens remaining in the vesting plan to the voting vault physically\r\n  /// @param lockId is the id of the vesting plan and NFT\r\n  function _setupVoting(uint256 lockId) internal returns (address) {\r\n    require(_isApprovedDelegatorOrOwner(msg.sender, lockId), '!d');\r\n    require(votingVaults[lockId] == address(0), 'exists');\r\n    VestingLock memory lock = _vestingLocks[lockId];\r\n    VotingVault vault = new VotingVault(lock.token, ownerOf(lockId));\r\n    votingVaults[lockId] = address(vault);\r\n    if (lock.availableAmount > 0) TransferHelper.withdrawTokens(lock.token, address(vault), lock.availableAmount);\r\n    emit VotingVaultCreated(lockId, address(vault));\r\n    return address(vault);\r\n  }\r\n\r\n  /// @notice this internal function will physically delegate tokens held in a voting vault to a delegatee\r\n  /// @dev if a voting vautl has not been setup yet, then the function will call the internal _setupVoting function and setup a new voting vault\r\n  /// and then it will delegate the tokens held in the vault to the delegatee\r\n  /// @param lockId is the id of the vesting plan and NFT\r\n  /// @param delegatee is the address of the delegatee where the tokens in the voting vault will be delegated to\r\n  function _delegate(uint256 lockId, address delegatee) internal returns (address) {\r\n    require(_isApprovedDelegatorOrOwner(msg.sender, lockId), '!d');\r\n    address vault = votingVaults[lockId];\r\n    if (votingVaults[lockId] == address(0)) {\r\n      vault = _setupVoting(lockId);\r\n    }\r\n    VotingVault(vault).delegateTokens(delegatee);\r\n    return vault;\r\n  }\r\n\r\n  /******************************PUBLIC AGGREGATE VIEW FUNCTIONS ***********************************************************************/\r\n\r\n  /// @notice this function will aggregate the available amount for a specific holder across all of their plans, based on a single ERC20 token\r\n  /// @param holder is the address of the beneficiary who owns the vesting plan(s)\r\n  /// @param token is the ERC20 address of the token that is stored across the vesting plans\r\n  function lockedBalances(address holder, address token) external view returns (uint256 lockedBalance) {\r\n    uint256 holdersBalance = balanceOf(holder);\r\n    for (uint256 i; i < holdersBalance; i++) {\r\n      uint256 lockId = tokenOfOwnerByIndex(holder, i);\r\n      VestingLock memory lock = _vestingLocks[lockId];\r\n      if (token == lock.token) {\r\n        lockedBalance += lock.availableAmount;\r\n      }\r\n    }\r\n  }\r\n\r\n  /// @notice this function will pull all of the tokens locked in vesting plans where the NFT has been delegated to a specific delegatee wallet address\r\n  /// this is useful for the snapshot strategy hedgey-delegate, polling this function based on the wallet signed into snapshot\r\n  /// by default all NFTs are self-delegated when they are minted.\r\n  /// @param delegatee is the address of the delegate where NFTs have been delegated to\r\n  /// @param token is the address of the ERC20 token that is locked in vesting plans and has been delegated\r\n  function delegatedBalances(address delegatee, address token) external view returns (uint256 delegatedBalance) {\r\n    uint256 delegateBalance = balanceOfDelegate(delegatee);\r\n    for (uint256 i; i < delegateBalance; i++) {\r\n      uint256 lockId = tokenOfDelegateByIndex(delegatee, i);\r\n      VestingLock memory lock = _vestingLocks[lockId];\r\n      if (token == lock.token) {\r\n        delegatedBalance += lock.availableAmount;\r\n      }\r\n    }\r\n  }\r\n\r\n  /*******INTERNAL NFT TRANSFERABILITY UPDATES*********************************************************************************/\r\n\r\n  /// @notice function that overrides the internal OZ logic to manage the transferability of the NFT\r\n  /// @dev if the auth address is the 0x0 address, then its either mint or burn and we do not need to perform any additional checks\r\n  /// @dev if the auth address is not the 0x0 address, then it will check if the auth address (spender) is the vesting admin, and if it is, will process the transfer and check if the admintransfertoggle is on\r\n  /// we have the function set specifically to check when auth is the vesting admin so that the _isAuthorzied can check if the adminTransferOBO is on\r\n  /// or if the admin has specifically been approved to transfer on behalf of the owner, then it can be done once by the admin in the normal _getApproved function\r\n  /// otherwise we check if the lockup is transferable and then perform the transfer\r\n  function _update(address to, uint256 tokenId, address auth) internal virtual override returns (address) {\r\n    if (auth != address(0x0)) {\r\n      if (auth == _vestingLocks[tokenId].vestingAdmin) {\r\n        return super._update(to, tokenId, auth);\r\n      } else {\r\n        require(_vestingLocks[tokenId].transferable, '!transferable');\r\n        return super._update(to, tokenId, auth);\r\n      }\r\n    } else {\r\n      _updateDelegate(to, tokenId);\r\n      return super._update(to, tokenId, address(0x0));\r\n    }\r\n  }\r\n\r\n  /// @notice this function overrides the internal isAuthorized function specifically for when the vestingAdmin is the spender, and check if the adminTransferOBO is on\r\n  /// @dev we update the authorization logic instead of the update logic for the adminTransferOBO toggle as we want to check this whenever the admin is the spender\r\n  function _isAuthorized(\r\n    address owner,\r\n    address spender,\r\n    uint256 tokenId\r\n  ) internal view virtual override returns (bool) {\r\n    return\r\n      spender != address(0) &&\r\n      (owner == spender ||\r\n        isApprovedForAll(owner, spender) ||\r\n        _getApproved(tokenId) == spender ||\r\n        (spender == _vestingLocks[tokenId].vestingAdmin && _vestingLocks[tokenId].adminTransferOBO));\r\n  }\r\n}\r\n"
      }
    },
    "settings": {
      "optimizer": {
        "enabled": true,
        "runs": 100
      },
      "viaIR": true,
      "evmVersion": "paris",
      "outputSelection": {
        "*": {
          "*": [
            "evm.bytecode",
            "evm.deployedBytecode",
            "devdoc",
            "userdoc",
            "metadata",
            "abi"
          ]
        }
      },
      "libraries": {}
    }
  }}