{"sources":{"AgentCard.sol":{"content":"// SPDX-License-Identifier: MIT\r\npragma solidity 0.8.24;\r\n\r\nimport {ERC721} from \"@openzeppelin/contracts/token/ERC721/ERC721.sol\";\r\nimport {Ownable} from \"@openzeppelin/contracts/access/Ownable.sol\";\r\nimport {ReentrancyGuard} from \"@openzeppelin/contracts/utils/ReentrancyGuard.sol\";\r\nimport {Strings} from \"@openzeppelin/contracts/utils/Strings.sol\";\r\nimport {IERC20} from \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\r\nimport {SafeERC20} from \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\r\n\r\ninterface AggregatorV3Interface {\r\n    function latestRoundData()\r\n        external view\r\n        returns (uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound);\r\n}\r\n\r\ninterface IAgentRegistry {\r\n    function handleOf(address owner) external view returns (string memory);\r\n    function ownerOf(uint256 tokenId) external view returns (address);\r\n}\r\n\r\ninterface ITokenRejects {\r\n    function rejects(address to) external view returns (bool);\r\n}\r\n\r\ninterface IPoolLauncher {\r\n    function finalize() external returns (uint256 liquidity);\r\n    function agentCard() external view returns (address);\r\n    function locked() external view returns (bool);\r\n}\r\n\r\n/**\r\n * @title 葬爱 ZangAI Card（合约名 AgentCard，NFT 名 ZangAI Card / 符号 ZACARD）\r\n * @notice 葬爱元素卡牌，等级 SSR / SR / R。mint 当笔就决定等级，卡里按等级存着对应数量的 ZangAI。\r\n *         代币跟着卡走：卡转给谁，币就归谁；开池后卡主随时用 redeem() 烧卡换币（可一次换多张）。\r\n *         开池前没有人手里有币，不存在提前私下交易；开池那一刻多余的代币直接打进黑洞。\r\n *\r\n * 持卡分红：开池后买入税 1% 每小时分配一次，按卡的等级权重（SSR 130 / SR 115 / R 100，\r\n *         与卡里存的代币数量同比例）记到每张卡上。分红属于卡、跟着卡走，卡主随时 claimDividends()\r\n *         领取；烧卡兑换时自动一起领走，之后这张卡不再参与分红。\r\n *\r\n * 等级怎么定：固定牌堆\r\n *   开售时按概率把总量切成三摞：SSR 张数、SR 张数、R 张数（44,444 张 → 4,444 / 17,777 / 22,223），\r\n *   每 mint 一张就从剩下的牌里随机抽一张（不放回）。抽完为止，三种等级的总张数永远不变，\r\n *   所以发出去的代币总量在开售时就精确确定，卡牌合约里的代币永远不会被发超。\r\n *\r\n * 关于「当笔随机」的取舍：\r\n *   随机数混合了上一个区块哈希、当前区块时间 / 出块者、调用者、tokenId 和一个随每笔 mint 滚动的种子。\r\n *   mint 必须由持有 Agent ID 的钱包发起，agent 合约钱包也可以；因此理论上有人能写合约\r\n *   「抽不到 SSR 就回滚」反复重试。固定牌堆保证这种行为只能和别人抢同一摞 SSR，\r\n *   不能凭空多造 SSR，也不会让代币超发；每个 Agent ID 最多 20 张也限制了单个 ID 的收益。\r\n */\r\ncontract AgentCard is ERC721, Ownable, ReentrancyGuard {\r\n    using SafeERC20 for IERC20;\r\n\r\n    // ======================== 常量 ========================\r\n    uint256 public constant MAX_PER_AGENT = 20;     // 每个 agent ID 最多 20 张\r\n    uint256 public constant FREE_PER_AGENT = 3;     // 每个 agent ID（钱包）前 3 张免费，免费池领完为止，先到先得\r\n    uint256 public constant FREE_TOTAL     = 4_444; // 免费总量（含团队卡）：用户免费 = 4,444 − 团队预留\r\n    uint256 public constant TEAM_CARDS     = 444;   // 团队营销卡：从免费名额中出，只能发到国库\r\n    uint256 public constant TEAM_UNLOCK_FREE = 2_000; // 用户免费卡领到第 2,000 张的那笔交易里，自动给团队分配 444 张\r\n    uint256 public constant TEAM_BATCH     = 100;   // claimTeamCards 单笔上限（审计 F-5）\r\n    uint256 public constant MAX_PER_TX     = 20;    // 每笔最多 20 张（一次 mint 满一个 Agent ID 的上限）\r\n    uint256 public constant TIERS          = 3;     // 1 = SSR, 2 = SR, 3 = R\r\n    uint256 public constant BPS            = 10_000;\r\n\r\n    // 两段价：总量前 50% 1U、后 50% 2U（USDT，18 位）\r\n    uint256 public constant P1 = 1.0e18;\r\n    uint256 public constant P2 = 2.0e18;\r\n\r\n    /// @dev 销售期：openRound 起 72 小时\r\n    uint256 public constant MINT_WINDOW = 72 hours;\r\n\r\n    /// @dev 预言机校验：BNB/USD（8 位小数）必须在合理区间内，且不超过 2 小时未更新\r\n    uint256 public constant FEED_MIN_PRICE = 100e8;      // 100 USD\r\n    uint256 public constant FEED_MAX_PRICE = 10_000e8;   // 10,000 USD\r\n    uint256 public constant FEED_HEARTBEAT = 2 hours;\r\n\r\n    address public constant DEAD = 0x000000000000000000000000000000000000dEaD;\r\n\r\n    // ======================== 依赖 ========================\r\n    AggregatorV3Interface public immutable bnbUsdFeed;\r\n    IAgentRegistry        public immutable registrar;\r\n    address               public immutable poolWallet;   // 未开自动开池时 80% 收入的暂存地址\r\n    address               public immutable teamWallet;   // 国库：mint 收入的 20% + 团队卡\r\n    uint16                public constant POOL_SHARE_BPS = 8_000;   // 80% 进池\r\n\r\n    IERC20                public token;                  // ZangAI 代币（部署后绑定一次）\r\n    IPoolLauncher         public launcher;               // 售罄自动开池器（部署后绑定一次）\r\n    bool                  public launcherLocked;\r\n    mapping(uint256 => bool) public launchOnSellout;     // 本轮售罄是否触发自动开池\r\n\r\n    // ======================== 销售 ========================\r\n    struct Round {\r\n        uint256 nftQuota;        // 总量\r\n        uint256 minted;          // 已 mint（含团队）\r\n        uint256 priceUsd;        // 固定单价（USDT 18 位）；0 = 两段价\r\n        bool    active;\r\n        uint16[3] tierBps;       // SSR / SR / R 概率（基点，合计 10000）\r\n        uint256 teamReserve;     // 团队预留张数（含在 nftQuota 内，从免费名额中出）\r\n        uint256 teamMinted;      // 已分配给团队的张数（自动分配时一次计入）\r\n        uint256 endTime;         // 销售截止时间（openRound + MINT_WINDOW）\r\n    }\r\n\r\n    mapping(uint256 => Round) public rounds;\r\n    uint256 public currentRound;\r\n\r\n    // ======================== 卡牌 ========================\r\n    struct Card {\r\n        uint8  tier;             // 1 = SSR，2 = SR，3 = R（mint 当笔确定）\r\n    }\r\n    mapping(uint256 => Card) public cards;\r\n    mapping(uint256 => uint256) public tokenRound;      // tokenId => 所属轮次\r\n\r\n    /// @dev 每个等级每张卡结算的代币数量（index 0 = SSR，1 = SR，2 = R），openRound 时锁定\r\n    uint256[3] public tierAmount;\r\n    // ======================== 团队卡（自动分配）========================\r\n    bool    public teamAllocated;                       // 是否已自动分配给团队\r\n    uint256 public teamFirstId;                         // 团队卡的起始 tokenId（连续 teamTotal 张）\r\n    uint256 public teamTotal;                           // 分配给团队的张数\r\n    uint256 public teamClaimed;                         // 已铸造到国库的团队 NFT 张数\r\n    uint256[3] public teamTierLeft;                     // 团队卡里还没铸造的 SSR / SR / R 张数\r\n\r\n    /// @dev 已开出各等级张数（index 1..3）\r\n    uint256[4] public tierCount;\r\n    /// @dev 牌堆剩余张数（index 0 = SSR，1 = SR，2 = R），openRound 时按概率切好，每 mint 一张减一\r\n    uint256[3] public deckLeft;\r\n    uint256 public totalPaidOut;                        // 已绑定到卡上的代币总量（含团队卡）\r\n    uint256 public totalRedeemed;                       // 已被卡主兑换走的代币总量\r\n    uint256 public constant REDEEM_BATCH = 200;         // redeem / claimDividends 单笔上限\r\n\r\n    // ======================== 持卡分红（买入税 1%）========================\r\n    uint256 private constant ACC = 1e18;\r\n    uint256 public accDividendPerWeight;                // 每 1 点权重累计分到的代币（× 1e18）\r\n    uint256 public totalWeight;                         // 现存所有卡的权重之和（含已分配、未铸造的团队卡）\r\n    uint256 public dividendCarry;                       // 暂时没有卡时收到的分红，下次一起分\r\n    uint256 public totalDividendsClaimed;               // 卡主已领走的分红\r\n    uint256 public teamAccSnapshot;                     // 团队卡分配时的累计值（团队卡从分配那一刻起算分红）\r\n    mapping(uint256 => uint256) public dividendDebt;    // 每张卡已结算到的位置\r\n    /// @dev 滚动随机种子：每抽一张就更新，让同一区块里的每张卡结果互相依赖\r\n    bytes32 private seed;\r\n\r\n    // ======================== 状态 ========================\r\n    uint256 public totalMinted;\r\n    mapping(uint256 => uint256) public mintedByAgent;   // agentId => 已 mint 张数\r\n    mapping(uint256 => uint256) public freeUsed;        // agentId => 已领的免费张数（≤ 3）\r\n    uint256 public freeMinted;                          // 用户已领免费卡\r\n    uint256 public teamReservedTotal;                   // 已预留给团队的名额（≤ TEAM_CARDS）\r\n    uint256 public nextTeamReserve;                     // openRound 时为团队预留的张数\r\n\r\n    bool public mintOpen;\r\n    bool public transferLocked = true;\r\n    string public baseURI;\r\n\r\n    // ======================== 事件 ========================\r\n    event RoundOpened(uint256 indexed roundId, uint256 quota, uint256 priceUsd, uint16[3] tierBps);\r\n    event Minted(address indexed to, uint256 firstId, uint256 count, uint256 agentId, uint256 paid);\r\n    event Split(uint256 toPool, uint256 toTeam);\r\n    event PoolLaunched(address indexed launcher, uint256 bnb, uint256 liquidity);\r\n    event LauncherSet(address indexed launcher);\r\n    event TokenSet(address indexed token);\r\n    event Revealed(uint256 indexed tokenId, uint8 tier, address indexed holder, uint256 amount);\r\n    event TransferUnlocked();\r\n    event TeamAllocated(address indexed to, uint256 firstId, uint256 count, uint256 ssr, uint256 sr, uint256 r, uint256 amount);\r\n    event TeamCardsClaimed(address indexed to, uint256 firstId, uint256 count);\r\n    event SaleFinished(uint256 indexed roundId);\r\n    event LeftoverBurned(uint256 amount);\r\n    event Redeemed(address indexed holder, uint256 count, uint256 amount);\r\n    event DividendNotified(uint256 amount, uint256 accPerWeight);\r\n    event DividendsClaimed(address indexed holder, uint256 count, uint256 amount);\r\n\r\n    // ======================== 错误 ========================\r\n    error MintClosed();\r\n    error ZeroAddress();\r\n    error AlreadySet();\r\n    error RoundFull();\r\n    error BadCount();\r\n    error NotAgentOwner();\r\n    error AgentQuota();\r\n    error Underpaid();\r\n    error PriceSlippage();\r\n    error Locked();\r\n    error LengthMismatch();\r\n    error PayoutFailed();\r\n    error BadTierBps();\r\n    error MintStillOpen();\r\n    error LauncherNotSet();\r\n    error TokenNotSet();\r\n    error TeamQuota();\r\n    error TeamNotAllocated();\r\n    error SaleEnded();\r\n    error BadFeed();\r\n    error StaleFeed();\r\n    error PoolNotLaunched();\r\n    error ParamsLocked();\r\n    error BadRecipient();\r\n    error BudgetTooLow();\r\n    error NotCardOwner();\r\n    error NotToken();\r\n\r\n    constructor(\r\n        address registry_,\r\n        address feed_,\r\n        address poolWallet_,\r\n        address teamWallet_,\r\n        address owner_\r\n    ) ERC721(\"ZangAI Card\", \"ZACARD\") Ownable(owner_) {\r\n        if (poolWallet_ == address(0) || teamWallet_ == address(0)) revert ZeroAddress();\r\n        registrar  = IAgentRegistry(registry_);\r\n        bnbUsdFeed = AggregatorV3Interface(feed_);\r\n        poolWallet = poolWallet_;\r\n        teamWallet = teamWallet_;\r\n    }\r\n\r\n    // ======================== Agent 校验 ========================\r\n    /// @dev 双校验：handleOf 反推 agentId + ownerOf 确认归属\r\n    function _isAgentOwner(address who, uint256 agentId) internal view returns (bool) {\r\n        try registrar.handleOf(who) returns (string memory h) {\r\n            if (bytes(h).length == 0) return false;\r\n            if (uint256(keccak256(bytes(h))) != agentId) return false;\r\n            try registrar.ownerOf(agentId) returns (address o) {\r\n                return o == who;\r\n            } catch { return false; }\r\n        } catch { return false; }\r\n    }\r\n\r\n    // ======================== 价格 ========================\r\n    function usdToBnb(uint256 usd) public view returns (uint256) {\r\n        (uint80 rid, int256 ans,, uint256 upd, uint80 answeredIn) = bnbUsdFeed.latestRoundData();\r\n        if (ans <= 0) revert BadFeed();\r\n        uint256 p = uint256(ans);\r\n        if (p < FEED_MIN_PRICE || p > FEED_MAX_PRICE) revert BadFeed();\r\n        if (answeredIn < rid) revert StaleFeed();\r\n        if (upd > block.timestamp || block.timestamp - upd > FEED_HEARTBEAT) revert StaleFeed();\r\n        return (usd * 1e8) / p;\r\n    }\r\n\r\n    /**\r\n     * @dev priceUsd > 0：固定价；priceUsd == 0：两段价，按总量对半切：前 50% 1U、后 50% 2U。\r\n     *      团队卡计在前 50% 里，所以用户的第 publicIdx 张卡：publicIdx < 总量/2 − 团队预留 → 1U。\r\n     *      44,444 张 / 团队 444：用户前 21,778 张 1U（其中 4,000 张免费），后 22,222 张 2U。\r\n     */\r\n    function _priceForRound(uint256 roundId, uint256 publicIdx) internal view returns (uint256) {\r\n        Round storage r = rounds[roundId];\r\n        if (r.priceUsd > 0) return r.priceUsd;\r\n        uint256 half = r.nftQuota / 2;\r\n        uint256 boundary = half > r.teamReserve ? half - r.teamReserve : 0;\r\n        return publicIdx < boundary ? P1 : P2;\r\n    }\r\n\r\n    /// @notice 用户（非团队）已 mint 张数\r\n    function publicMinted(uint256 roundId) public view returns (uint256) {\r\n        Round storage r = rounds[roundId];\r\n        return r.minted - r.teamMinted;\r\n    }\r\n\r\n    /// @notice 用户可 mint 的上限 = 总量 − 团队预留\r\n    function publicQuota(uint256 roundId) public view returns (uint256) {\r\n        Round storage r = rounds[roundId];\r\n        return r.nftQuota - r.teamReserve;\r\n    }\r\n\r\n    /// @notice 用户免费名额 = 4,444 − 团队预留（团队卡从免费名额中出）\r\n    function userFreeTotal() public view returns (uint256) {\r\n        return FREE_TOTAL - teamReservedTotal;\r\n    }\r\n\r\n    /// @notice 某 agent 下一张是否免费\r\n    function isNextFree(uint256 agentId) public view returns (bool) {\r\n        return freeLeftFor(agentId) > 0;\r\n    }\r\n\r\n    /// @notice 这个 agent 现在还能免费 mint 几张（自己剩的额度和免费池剩余取小）\r\n    function freeLeftFor(uint256 agentId) public view returns (uint256) {\r\n        uint256 mine = FREE_PER_AGENT - freeUsed[agentId];\r\n        uint256 total = userFreeTotal();\r\n        uint256 pool = freeMinted < total ? total - freeMinted : 0;\r\n        return mine < pool ? mine : pool;\r\n    }\r\n\r\n    /// @dev 计价并登记免费名额：本次的前几张按剩余免费额度（每个 agent 最多 3 张、免费池领完为止）免费\r\n    function _chargeUsd(uint256 agentId, uint256 count) private returns (uint256 usdTotal) {\r\n        uint256 rid = currentRound;\r\n        uint256 pub = publicMinted(rid);\r\n        uint256 nFree = freeLeftFor(agentId);\r\n        if (nFree > count) nFree = count;\r\n        for (uint256 i = nFree; i < count; i++) {          // 本次的前 nFree 张免费，其余按位置计价\r\n            usdTotal += _priceForRound(rid, pub + i);\r\n        }\r\n        if (nFree > 0) {\r\n            freeUsed[agentId] += nFree;\r\n            freeMinted += nFree;\r\n        }\r\n    }\r\n\r\n    // ======================== Mint ========================\r\n    /**\r\n     * @param count       本次 mint 张数（≤ 20）\r\n     * @param agentId     Agent ID（SPACE ID .ai 域名 tokenId）\r\n     * @param maxPriceUsd 本次总价上限（USDT 18 位，滑点保护）\r\n     */\r\n    function mint(uint256 count, uint256 agentId, uint256 maxPriceUsd) external payable nonReentrant {\r\n        if (!mintOpen || currentRound == 0) revert MintClosed();\r\n\r\n        Round storage r = rounds[currentRound];\r\n        if (!r.active) revert MintClosed();\r\n        if (block.timestamp > r.endTime) revert SaleEnded();\r\n        if (count == 0 || count > MAX_PER_TX) revert BadCount();\r\n        // 团队名额不对用户开放\r\n        if (r.minted - r.teamMinted + count > r.nftQuota - r.teamReserve) revert RoundFull();\r\n        if (!_isAgentOwner(msg.sender, agentId)) revert NotAgentOwner();\r\n\r\n        uint256 already = mintedByAgent[agentId];\r\n        if (already + count > MAX_PER_AGENT) revert AgentQuota();\r\n\r\n        uint256 usdTotal = _chargeUsd(agentId, count);\r\n        if (usdTotal > maxPriceUsd) revert PriceSlippage();\r\n        uint256 need = usdTotal == 0 ? 0 : usdToBnb(usdTotal);\r\n        if (msg.value < need) revert Underpaid();\r\n\r\n        uint256 first = _mintCards(msg.sender, count);\r\n        mintedByAgent[agentId] = already + count;\r\n\r\n        // 免费卡领到第 2,000 张：同一笔交易里自动给团队分配 444 张（定等级 + 代币打进国库 + 计数）\r\n        if (!teamAllocated && freeMinted >= TEAM_UNLOCK_FREE) _allocateTeam();\r\n\r\n        if (need > 0) emit Minted(msg.sender, first, count, agentId, need);\r\n\r\n        if (msg.value > need) {\r\n            (bool r1,) = payable(msg.sender).call{value: msg.value - need}(\"\");\r\n            require(r1, \"refund\");\r\n        }\r\n\r\n        uint256 toPool = (need * POOL_SHARE_BPS) / 10_000;\r\n        uint256 toTeam = need - toPool;\r\n        bool soldOut = launchOnSellout[currentRound] && r.minted == r.nftQuota && !launcher.locked();\r\n\r\n        // 80%：只要绑定了 Launcher 就一律累积在 Launcher（售罄自动开池或团队手动开池都有钱，审计 F-2）\r\n        if (toPool > 0) {\r\n            address sink = launcherLocked ? address(launcher) : poolWallet;\r\n            (bool okL,) = payable(sink).call{value: toPool}(\"\");\r\n            if (!okL) revert PayoutFailed();\r\n        }\r\n\r\n        // 售罄：当场加池，LP 打黑洞，自动开启交易\r\n        if (soldOut) _launchAndRenounce();\r\n\r\n        if (toTeam > 0) {\r\n            (bool r3,) = payable(teamWallet).call{value: toTeam}(\"\");\r\n            if (!r3) revert PayoutFailed();\r\n        }\r\n        if (need > 0) emit Split(toPool, toTeam);\r\n    }\r\n\r\n    /// @dev 铸造：每张当笔从牌堆抽等级，代币存在卡里（留在本合约），开池后凭卡兑换\r\n    function _mintCards(address to, uint256 count) private returns (uint256 first) {\r\n        Round storage r = rounds[currentRound];\r\n        first = totalMinted;\r\n        uint256 pay;\r\n        for (uint256 i = 0; i < count; i++) {\r\n            uint256 id = first + i;\r\n            uint8 t = _drawTier(to, id);\r\n            tokenRound[id] = currentRound;\r\n            cards[id].tier = t;\r\n            tierCount[t] += 1;\r\n            uint256 amt = tierAmount[t - 1];\r\n            pay += amt;\r\n            totalWeight += _weight(t);         // mint 只发生在开池前，此时累计值为 0，不需要记 debt\r\n            _mint(to, id);\r\n            emit Revealed(id, t, to, amt);\r\n        }\r\n        totalMinted += count;\r\n        r.minted    += count;\r\n        totalPaidOut += pay;               // 只记账，代币留在合约里跟着卡走（额度在 openRound 时已按牌堆精确校验）\r\n    }\r\n\r\n    // ======================== 团队营销卡 ========================\r\n    /**\r\n     * @dev 自动分配团队卡：在用户领到第 2,000 张免费卡的那笔 mint 里执行，不需要任何人操作。\r\n     *      一次铸造 444 张 NFT 会超过单笔交易 gas 上限，所以这里只做「算数」部分：\r\n     *        1. 占用连续 444 个 tokenId，计入已 mint 总数（前端立即看到 +444）\r\n     *        2. 从牌堆抽 444 张的等级（和用户一样不放回抽取）\r\n     *        3. 按等级把代币一次性打进国库\r\n     *      NFT 本体之后由任何人调用 claimTeamCards() 分批铸造到国库（结果已定，谁来调、何时调都一样）。\r\n     */\r\n    function _allocateTeam() private {\r\n        teamAllocated = true;\r\n        Round storage r = rounds[currentRound];\r\n        uint256 n = r.teamReserve - r.teamMinted;\r\n        if (n == 0) return;\r\n        uint256 first = totalMinted;\r\n        uint256[3] memory c;\r\n        for (uint256 i = 0; i < n; i++) {\r\n            uint8 t = _drawTier(teamWallet, first + i);\r\n            c[t - 1] += 1;\r\n        }\r\n        tierCount[1] += c[0];\r\n        tierCount[2] += c[1];\r\n        tierCount[3] += c[2];\r\n        totalWeight += c[0] * _weight(1) + c[1] * _weight(2) + c[2] * _weight(3);\r\n        teamAccSnapshot = accDividendPerWeight;\r\n        teamTierLeft = c;\r\n        teamFirstId  = first;\r\n        teamTotal    = n;\r\n        totalMinted += n;\r\n        r.minted    += n;\r\n        r.teamMinted += n;\r\n        uint256 pay = c[0] * tierAmount[0] + c[1] * tierAmount[1] + c[2] * tierAmount[2];\r\n        totalPaidOut += pay;               // 团队卡的代币同样存在卡里，铸造成 NFT 后由国库凭卡兑换\r\n        emit TeamAllocated(teamWallet, first, n, c[0], c[1], c[2], pay);\r\n    }\r\n\r\n    /**\r\n     * @notice 把已分配的团队卡 NFT 铸造到国库，每笔最多 100 张。任何人都可以调用，只会铸造到国库。\r\n     * @dev 等级在分配时已经从牌堆抽好（只记各等级张数），这里按 SSR → SR → R 依次落到 tokenId 上；\r\n     *      代币在分配时已经打进国库，这里不再发币。销售结束、开池之后也可以调用。\r\n     */\r\n    function claimTeamCards(uint256 count) external nonReentrant {\r\n        if (!teamAllocated || teamTotal == 0) revert TeamNotAllocated();\r\n        if (count == 0 || count > TEAM_BATCH) revert BadCount();\r\n        uint256 done = teamClaimed;\r\n        if (done + count > teamTotal) revert TeamQuota();\r\n        uint256 first = teamFirstId + done;\r\n        uint256 rid = currentRound;\r\n        for (uint256 i = 0; i < count; i++) {\r\n            uint256 id = first + i;\r\n            uint8 t;\r\n            if (teamTierLeft[0] > 0)      { teamTierLeft[0] -= 1; t = 1; }\r\n            else if (teamTierLeft[1] > 0) { teamTierLeft[1] -= 1; t = 2; }\r\n            else                          { teamTierLeft[2] -= 1; t = 3; }\r\n            cards[id].tier = t;\r\n            tokenRound[id] = rid;\r\n            if (teamAccSnapshot != 0) dividendDebt[id] = _weight(t) * teamAccSnapshot / ACC;\r\n            _mint(teamWallet, id);\r\n            emit Revealed(id, t, teamWallet, tierAmount[t - 1]);\r\n        }\r\n        teamClaimed = done + count;\r\n        emit TeamCardsClaimed(teamWallet, first, count);\r\n    }\r\n\r\n    /// @notice 团队卡里还没铸造成 NFT 的张数\r\n    function teamUnclaimed() external view returns (uint256) {\r\n        return teamTotal - teamClaimed;\r\n    }\r\n\r\n    /// @notice 设置 openRound 时为团队预留的张数（≤ TEAM_CARDS）\r\n    function setNextTeamReserve(uint256 n) external onlyOwner {\r\n        if (currentRound != 0) revert ParamsLocked();   // 审计 F-8\r\n        if (teamReservedTotal + n > TEAM_CARDS) revert TeamQuota();\r\n        nextTeamReserve = n;\r\n    }\r\n\r\n    // ======================== 抽卡 ========================\r\n    /**\r\n     * @dev 从牌堆不放回抽一张：返回 1 = SSR，2 = SR，3 = R。\r\n     *      每张卡被抽中某等级的概率 = 该等级剩余张数 / 剩余总张数。\r\n     */\r\n    function _drawTier(address to, uint256 id) private returns (uint8) {\r\n        uint256 a = deckLeft[0];\r\n        uint256 b = deckLeft[1];\r\n        uint256 c = deckLeft[2];\r\n        uint256 left = a + b + c;\r\n        if (left == 0) revert RoundFull();\r\n        bytes32 sd = keccak256(abi.encode(\r\n            seed, blockhash(block.number - 1), block.timestamp, block.coinbase, block.prevrandao, to, id\r\n        ));\r\n        seed = sd;\r\n        uint256 x = uint256(sd) % left;\r\n        if (x < a) { deckLeft[0] = a - 1; return 1; }\r\n        if (x < a + b) { deckLeft[1] = b - 1; return 2; }\r\n        deckLeft[2] = c - 1;\r\n        return 3;\r\n    }\r\n\r\n    /// @notice 卡牌等级：1 = SSR，2 = SR，3 = R（未 mint 的 tokenId 返回 0）\r\n    function tierOf(uint256 tokenId) external view returns (uint8) {\r\n        return cards[tokenId].tier;\r\n    }\r\n\r\n    /// @notice 这张卡里存着多少 ZangAI（已兑换 / 不存在的卡返回 0）\r\n    function cardValue(uint256 tokenId) public view returns (uint256) {\r\n        if (_ownerOf(tokenId) == address(0)) return 0;\r\n        uint8 t = cards[tokenId].tier;\r\n        return t == 0 ? 0 : tierAmount[t - 1];\r\n    }\r\n\r\n    /**\r\n     * @notice 开池后，卡主烧掉自己的卡，换出卡里存着的 ZangAI。可以一次换多张（≤ 200）。\r\n     * @dev 只有卡主本人能换（授权地址不行），换完卡就销毁了。\r\n     */\r\n    function redeem(uint256[] calldata tokenIds) external nonReentrant {\r\n        if (address(launcher) == address(0) || !launcher.locked()) revert PoolNotLaunched();\r\n        uint256 n = tokenIds.length;\r\n        if (n == 0 || n > REDEEM_BATCH) revert BadCount();\r\n        uint256 amt;\r\n        uint256 div;\r\n        uint256 w;\r\n        for (uint256 i = 0; i < n; i++) {\r\n            uint256 id = tokenIds[i];\r\n            if (_ownerOf(id) != msg.sender) revert NotCardOwner();\r\n            uint8 t = cards[id].tier;\r\n            amt += tierAmount[t - 1];\r\n            div += _pending(id, t);\r\n            w += _weight(t);\r\n            _burn(id);\r\n        }\r\n        totalRedeemed += amt;\r\n        totalWeight -= w;\r\n        totalDividendsClaimed += div;\r\n        token.safeTransfer(msg.sender, amt + div);   // 卡里的币 + 没领的分红一起给\r\n        emit Redeemed(msg.sender, n, amt);\r\n        if (div > 0) emit DividendsClaimed(msg.sender, n, div);\r\n    }\r\n\r\n    // ======================== 持卡分红 ========================\r\n    function _weight(uint8 t) private pure returns (uint256) {\r\n        return t == 1 ? 130 : t == 2 ? 115 : 100;\r\n    }\r\n\r\n    function _pending(uint256 id, uint8 t) private view returns (uint256) {\r\n        return _weight(t) * accDividendPerWeight / ACC - dividendDebt[id];\r\n    }\r\n\r\n    /// @notice 代币合约每小时把买入税转过来后调用，按权重记到每张卡上（只有代币合约能调）\r\n    function notifyDividend(uint256 amount) external {\r\n        if (msg.sender != address(token)) revert NotToken();\r\n        amount += dividendCarry;\r\n        if (totalWeight == 0) { dividendCarry = amount; return; }\r\n        dividendCarry = 0;\r\n        accDividendPerWeight += amount * ACC / totalWeight;\r\n        emit DividendNotified(amount, accDividendPerWeight);\r\n    }\r\n\r\n    /// @notice 卡主领取这些卡上的分红（卡不烧，之后继续分红）。每笔 ≤ 200 张。\r\n    function claimDividends(uint256[] calldata tokenIds) external nonReentrant {\r\n        uint256 n = tokenIds.length;\r\n        if (n == 0 || n > REDEEM_BATCH) revert BadCount();\r\n        uint256 acc = accDividendPerWeight;\r\n        uint256 div;\r\n        for (uint256 i = 0; i < n; i++) {\r\n            uint256 id = tokenIds[i];\r\n            if (_ownerOf(id) != msg.sender) revert NotCardOwner();\r\n            uint8 t = cards[id].tier;\r\n            uint256 due = _weight(t) * acc / ACC;\r\n            div += due - dividendDebt[id];\r\n            dividendDebt[id] = due;\r\n        }\r\n        totalDividendsClaimed += div;\r\n        if (div > 0) token.safeTransfer(msg.sender, div);\r\n        emit DividendsClaimed(msg.sender, n, div);\r\n    }\r\n\r\n    /// @notice 这些卡上还没领的分红合计\r\n    function pendingDividends(uint256[] calldata tokenIds) external view returns (uint256 sum) {\r\n        for (uint256 i = 0; i < tokenIds.length; i++) {\r\n            uint256 id = tokenIds[i];\r\n            if (_ownerOf(id) == address(0)) continue;\r\n            sum += _pending(id, cards[id].tier);\r\n        }\r\n    }\r\n\r\n    /**\r\n     * @notice 查某个地址在 tokenId [from, to) 区间里持有的卡（只读，网页 / 代理用来列出可兑换的卡）。\r\n     * @dev 44,444 张建议分段查，每段 ≤ 10,000。\r\n     */\r\n    function cardsOf(address holder, uint256 from, uint256 to) external view returns (uint256[] memory ids) {\r\n        if (to > totalMinted) to = totalMinted;\r\n        uint256 n;\r\n        for (uint256 i = from; i < to; i++) if (_ownerOf(i) == holder) n++;\r\n        ids = new uint256[](n);\r\n        n = 0;\r\n        for (uint256 i = from; i < to; i++) if (_ownerOf(i) == holder) ids[n++] = i;\r\n    }\r\n\r\n\r\n\r\n    function _update(address to, uint256 tokenId, address auth) internal override returns (address) {\r\n        if (transferLocked && to != address(0) && _ownerOf(tokenId) != address(0)) revert Locked();\r\n        // 审计 F-1：不允许把卡转给代币会拒收的地址（交易对 / 假交易对 / 被封池子）\r\n        if (to != address(0) && address(token) != address(0) && to.code.length > 0) {\r\n            try ITokenRejects(address(token)).rejects(to) returns (bool r) { if (r) revert BadRecipient(); } catch {}\r\n        }\r\n        return super._update(to, tokenId, auth);\r\n    }\r\n\r\n    // ======================== 绑定 ========================\r\n    /// @notice 绑定 ZangAI 代币，只能设置一次\r\n    function setToken(address t) external onlyOwner {\r\n        if (t == address(0)) revert ZeroAddress();\r\n        if (address(token) != address(0)) revert AlreadySet();\r\n        token = IERC20(t);\r\n        emit TokenSet(t);\r\n    }\r\n\r\n    /// @notice 设置每个等级每张卡的代币数量（SSR / SR / R），开售后锁定\r\n    function setTierAmounts(uint256 ssr, uint256 sr, uint256 r) external onlyOwner {\r\n        if (currentRound != 0) revert ParamsLocked();\r\n        tierAmount[0] = ssr;\r\n        tierAmount[1] = sr;\r\n        tierAmount[2] = r;\r\n    }\r\n\r\n    /// @notice 元数据地址（开池放弃 owner 后不可再改）\r\n    function setBaseURI(string calldata u) external onlyOwner {\r\n        baseURI = u;\r\n    }\r\n\r\n    /// @notice 绑定开池器，只能设置一次。要求 launcher 反向指向本合约，防配错\r\n    function setLauncher(address l) external onlyOwner {\r\n        if (launcherLocked) revert AlreadySet();\r\n        if (currentRound != 0) revert ParamsLocked();   // 开售后不能再绑定（否则前面 80% 收入已流向别处）\r\n        require(l != address(0), \"zero\");\r\n        require(IPoolLauncher(l).agentCard() == address(this), \"mismatch\");\r\n        launcher = IPoolLauncher(l);\r\n        launcherLocked = true;\r\n        emit LauncherSet(l);\r\n    }\r\n\r\n    // ======================== 开池 ========================\r\n    /**\r\n     * @notice 未售罄时的手动开池：销售结束（closeRound 或 72 小时到期）后，**只有团队**可以触发。\r\n     * @dev BNB 只能进池子（LP 打黑洞），不会流向任何人。售罄时会自动开池，不需要调用。\r\n     */\r\n    function launchPool() external onlyOwner nonReentrant {\r\n        if (address(launcher) == address(0)) revert LauncherNotSet();\r\n        if (_saleLive()) revert MintStillOpen();\r\n        _launchAndRenounce();\r\n    }\r\n\r\n    /**\r\n     * @dev 开池并放弃全部权限：\r\n     *      1. Launcher 加池、LP 打黑洞、代币自动开启交易（代币合约同时放弃 owner）\r\n     *      2. 结束销售，解除 NFT 转让锁\r\n     *      3. 多余代币打进黑洞，本合约放弃 owner —— 之后卡主凭卡 redeem，无需任何权限\r\n     */\r\n    function _launchAndRenounce() private {\r\n        uint256 bnb = address(launcher).balance;\r\n        uint256 liq = launcher.finalize();\r\n        emit PoolLaunched(address(launcher), bnb, liq);\r\n\r\n        // 多余的代币直接打进黑洞：卡里存着的（含还没铸造成 NFT 的团队卡）全部保留给卡主\r\n        uint256 bal = token.balanceOf(address(this));\r\n        uint256 keep = totalPaidOut - totalRedeemed;\r\n        if (bal > keep) {\r\n            token.safeTransfer(DEAD, bal - keep);\r\n            emit LeftoverBurned(bal - keep);\r\n        }\r\n\r\n        rounds[currentRound].active = false;\r\n        if (mintOpen) {\r\n            mintOpen = false;\r\n            emit SaleFinished(currentRound);\r\n        }\r\n        if (transferLocked) {\r\n            transferLocked = false;\r\n            emit TransferUnlocked();\r\n        }\r\n        if (owner() != address(0)) _transferOwnership(address(0));\r\n    }\r\n\r\n    /// @dev 销售是否仍在进行：已开售、未 closeRound、且未过 72 小时\r\n    function _saleLive() private view returns (bool) {\r\n        return mintOpen && block.timestamp <= rounds[currentRound].endTime;\r\n    }\r\n\r\n    /**\r\n     * @notice 开池前禁止放弃 owner：否则没人能在未售罄时开池，\r\n     *         Launcher 里的 BNB 会永久锁死。开池时会自动放弃，正常流程不需要手动调用。\r\n     */\r\n    function renounceOwnership() public override onlyOwner {\r\n        // 审计 F-6：没开池之前任何情况都不能放弃（含 launcher 还没绑定时）\r\n        if (address(launcher) == address(0) || !launcher.locked()) revert PoolNotLaunched();\r\n        if (_saleLive()) revert MintStillOpen();\r\n        super.renounceOwnership();\r\n    }\r\n\r\n    // ======================== 开售 ========================\r\n    /**\r\n     * @notice 开售（只能一次）\r\n     * @param roundId     轮次编号\r\n     * @param quota       总量（如 44444，含团队）\r\n     * @param priceUsd    固定单价；传 0 = 两段价（总量前 50% 1U、后 50% 2U）\r\n     * @param tierBps     SSR / SR / R 概率，长度 3，合计必须 10000\r\n     * @param launchPool  售罄是否自动开池\r\n     */\r\n    function openRound(\r\n        uint256 roundId,\r\n        uint256 quota,\r\n        uint256 priceUsd,\r\n        uint256[] calldata tierBps,\r\n        bool launchPool\r\n    ) external onlyOwner {\r\n        if (currentRound != 0) revert AlreadySet();          // 只有一次销售\r\n        if (roundId == 0 || quota == 0) revert BadCount();\r\n        if (address(token) == address(0)) revert TokenNotSet();\r\n        // 开启售罄自动开池必须先绑定 launcher，否则 80% 的 BNB 会被打到零地址\r\n        if (launchPool && !launcherLocked) revert LauncherNotSet();\r\n        if (tierBps.length != TIERS) revert LengthMismatch();\r\n        uint256 sum;\r\n        for (uint256 i = 0; i < TIERS; i++) sum += tierBps[i];\r\n        if (sum != BPS) revert BadTierBps();\r\n\r\n        Round storage r = rounds[roundId];\r\n        r.nftQuota  = quota;\r\n        r.priceUsd  = priceUsd;\r\n        r.active    = true;\r\n        uint256 tr = nextTeamReserve;\r\n        if (tr > quota) revert TeamQuota();\r\n        r.teamReserve      = tr;\r\n        r.endTime          = block.timestamp + MINT_WINDOW;\r\n        teamReservedTotal += tr;\r\n        nextTeamReserve    = 0;\r\n        for (uint256 i = 0; i < TIERS; i++) r.tierBps[i] = uint16(tierBps[i]);\r\n        launchOnSellout[roundId] = launchPool;\r\n\r\n        // 切牌堆：SSR / SR 按概率向下取整，余数全部归 R\r\n        uint256 nSsr = quota * tierBps[0] / BPS;\r\n        uint256 nSr  = quota * tierBps[1] / BPS;\r\n        uint256 nR   = quota - nSsr - nSr;\r\n        deckLeft[0] = nSsr;\r\n        deckLeft[1] = nSr;\r\n        deckLeft[2] = nR;\r\n        seed = keccak256(abi.encode(address(this), blockhash(block.number - 1), block.timestamp, quota));\r\n\r\n        // 审计 F-4：牌堆张数固定，所需代币可以精确算出，卡牌合约里必须足额\r\n        uint256 need = nSsr * tierAmount[0] + nSr * tierAmount[1] + nR * tierAmount[2];\r\n        if (need > token.balanceOf(address(this))) revert BudgetTooLow();\r\n\r\n        currentRound = roundId;\r\n        mintOpen = true;\r\n        emit RoundOpened(roundId, quota, priceUsd,\r\n            [uint16(tierBps[0]), uint16(tierBps[1]), uint16(tierBps[2])]);\r\n    }\r\n\r\n    /// @notice 提前结束销售（未售罄时，之后由团队 launchPool 开池）\r\n    function closeRound() external onlyOwner {\r\n        rounds[currentRound].active = false;\r\n        mintOpen = false;\r\n    }\r\n\r\n    // ======================== 视图 ========================\r\n    function roundInfo(uint256 roundId)\r\n        external view\r\n        returns (uint256 quota, uint256 minted, uint256 priceUsd, bool active)\r\n    {\r\n        Round storage r = rounds[roundId];\r\n        return (r.nftQuota, r.minted, r.priceUsd, r.active);\r\n    }\r\n\r\n    function tierProbability(uint256 roundId) external view returns (uint16[3] memory) {\r\n        return rounds[roundId].tierBps;\r\n    }\r\n\r\n    /// @notice 牌堆剩余：SSR / SR / R 各还剩多少张\r\n    function deckRemaining() external view returns (uint256 ssr, uint256 sr, uint256 r) {\r\n        return (deckLeft[0], deckLeft[1], deckLeft[2]);\r\n    }\r\n\r\n    /// @dev 元数据：baseURI + {SSR|SR|R}/{tokenId}.json\r\n    function tokenURI(uint256 tokenId) public view override returns (string memory) {\r\n        _requireOwned(tokenId);\r\n        uint8 t = cards[tokenId].tier;\r\n        string memory dir = t == 1 ? \"SSR/\" : t == 2 ? \"SR/\" : \"R/\";\r\n        return string.concat(baseURI, dir, Strings.toString(tokenId), \".json\");\r\n    }\r\n}\r\n"},"@openzeppelin/contracts/access/Ownable.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)\n\npragma solidity ^0.8.20;\n\nimport {Context} from \"../utils/Context.sol\";\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * The initial owner is set to the address provided by the deployer. This can\n * later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract Ownable is Context {\n    address private _owner;\n\n    /**\n     * @dev The caller account is not authorized to perform an operation.\n     */\n    error OwnableUnauthorizedAccount(address account);\n\n    /**\n     * @dev The owner is not a valid owner account. (eg. `address(0)`)\n     */\n    error OwnableInvalidOwner(address owner);\n\n    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n    /**\n     * @dev Initializes the contract setting the address provided by the deployer as the initial owner.\n     */\n    constructor(address initialOwner) {\n        if (initialOwner == address(0)) {\n            revert OwnableInvalidOwner(address(0));\n        }\n        _transferOwnership(initialOwner);\n    }\n\n    /**\n     * @dev Throws if called by any account other than the owner.\n     */\n    modifier onlyOwner() {\n        _checkOwner();\n        _;\n    }\n\n    /**\n     * @dev Returns the address of the current owner.\n     */\n    function owner() public view virtual returns (address) {\n        return _owner;\n    }\n\n    /**\n     * @dev Throws if the sender is not the owner.\n     */\n    function _checkOwner() internal view virtual {\n        if (owner() != _msgSender()) {\n            revert OwnableUnauthorizedAccount(_msgSender());\n        }\n    }\n\n    /**\n     * @dev Leaves the contract without owner. It will not be possible to call\n     * `onlyOwner` functions. Can only be called by the current owner.\n     *\n     * NOTE: Renouncing ownership will leave the contract without an owner,\n     * thereby disabling any functionality that is only available to the owner.\n     */\n    function renounceOwnership() public virtual onlyOwner {\n        _transferOwnership(address(0));\n    }\n\n    /**\n     * @dev Transfers ownership of the contract to a new account (`newOwner`).\n     * Can only be called by the current owner.\n     */\n    function transferOwnership(address newOwner) public virtual onlyOwner {\n        if (newOwner == address(0)) {\n            revert OwnableInvalidOwner(address(0));\n        }\n        _transferOwnership(newOwner);\n    }\n\n    /**\n     * @dev Transfers ownership of the contract to a new account (`newOwner`).\n     * Internal function without access restriction.\n     */\n    function _transferOwnership(address newOwner) internal virtual {\n        address oldOwner = _owner;\n        _owner = newOwner;\n        emit OwnershipTransferred(oldOwner, newOwner);\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/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        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 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/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"},"@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/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/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/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/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/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/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/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/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"}},"abi":[{"type":"constructor","inputs":[{"name":"registry_","type":"address","internalType":"address"},{"name":"feed_","type":"address","internalType":"address"},{"name":"poolWallet_","type":"address","internalType":"address"},{"name":"teamWallet_","type":"address","internalType":"address"},{"name":"owner_","type":"address","internalType":"address"}],"stateMutability":"nonpayable"},{"name":"AddressEmptyCode","type":"error","inputs":[{"name":"target","type":"address","internalType":"address"}]},{"name":"AddressInsufficientBalance","type":"error","inputs":[{"name":"account","type":"address","internalType":"address"}]},{"name":"AgentQuota","type":"error","inputs":[]},{"name":"AlreadySet","type":"error","inputs":[]},{"name":"BadCount","type":"error","inputs":[]},{"name":"BadFeed","type":"error","inputs":[]},{"name":"BadRecipient","type":"error","inputs":[]},{"name":"BadTierBps","type":"error","inputs":[]},{"name":"BudgetTooLow","type":"error","inputs":[]},{"name":"ERC721IncorrectOwner","type":"error","inputs":[{"name":"sender","type":"address","internalType":"address"},{"name":"tokenId","type":"uint256","internalType":"uint256"},{"name":"owner","type":"address","internalType":"address"}]},{"name":"ERC721InsufficientApproval","type":"error","inputs":[{"name":"operator","type":"address","internalType":"address"},{"name":"tokenId","type":"uint256","internalType":"uint256"}]},{"name":"ERC721InvalidApprover","type":"error","inputs":[{"name":"approver","type":"address","internalType":"address"}]},{"name":"ERC721InvalidOperator","type":"error","inputs":[{"name":"operator","type":"address","internalType":"address"}]},{"name":"ERC721InvalidOwner","type":"error","inputs":[{"name":"owner","type":"address","internalType":"address"}]},{"name":"ERC721InvalidReceiver","type":"error","inputs":[{"name":"receiver","type":"address","internalType":"address"}]},{"name":"ERC721InvalidSender","type":"error","inputs":[{"name":"sender","type":"address","internalType":"address"}]},{"name":"ERC721NonexistentToken","type":"error","inputs":[{"name":"tokenId","type":"uint256","internalType":"uint256"}]},{"name":"FailedInnerCall","type":"error","inputs":[]},{"name":"LauncherNotSet","type":"error","inputs":[]},{"name":"LengthMismatch","type":"error","inputs":[]},{"name":"Locked","type":"error","inputs":[]},{"name":"MintClosed","type":"error","inputs":[]},{"name":"MintStillOpen","type":"error","inputs":[]},{"name":"NotAgentOwner","type":"error","inputs":[]},{"name":"NotCardOwner","type":"error","inputs":[]},{"name":"NotToken","type":"error","inputs":[]},{"name":"OwnableInvalidOwner","type":"error","inputs":[{"name":"owner","type":"address","internalType":"address"}]},{"name":"OwnableUnauthorizedAccount","type":"error","inputs":[{"name":"account","type":"address","internalType":"address"}]},{"name":"ParamsLocked","type":"error","inputs":[]},{"name":"PayoutFailed","type":"error","inputs":[]},{"name":"PoolNotLaunched","type":"error","inputs":[]},{"name":"PriceSlippage","type":"error","inputs":[]},{"name":"ReentrancyGuardReentrantCall","type":"error","inputs":[]},{"name":"RoundFull","type":"error","inputs":[]},{"name":"SafeERC20FailedOperation","type":"error","inputs":[{"name":"token","type":"address","internalType":"address"}]},{"name":"SaleEnded","type":"error","inputs":[]},{"name":"StaleFeed","type":"error","inputs":[]},{"name":"TeamNotAllocated","type":"error","inputs":[]},{"name":"TeamQuota","type":"error","inputs":[]},{"name":"TokenNotSet","type":"error","inputs":[]},{"name":"Underpaid","type":"error","inputs":[]},{"name":"ZeroAddress","type":"error","inputs":[]},{"name":"Approval","type":"event","inputs":[{"name":"owner","type":"address","indexed":true,"internalType":"address"},{"name":"approved","type":"address","indexed":true,"internalType":"address"},{"name":"tokenId","type":"uint256","indexed":true,"internalType":"uint256"}],"anonymous":false},{"name":"ApprovalForAll","type":"event","inputs":[{"name":"owner","type":"address","indexed":true,"internalType":"address"},{"name":"operator","type":"address","indexed":true,"internalType":"address"},{"name":"approved","type":"bool","indexed":false,"internalType":"bool"}],"anonymous":false},{"name":"DividendNotified","type":"event","inputs":[{"name":"amount","type":"uint256","indexed":false,"internalType":"uint256"},{"name":"accPerWeight","type":"uint256","indexed":false,"internalType":"uint256"}],"anonymous":false},{"name":"DividendsClaimed","type":"event","inputs":[{"name":"holder","type":"address","indexed":true,"internalType":"address"},{"name":"count","type":"uint256","indexed":false,"internalType":"uint256"},{"name":"amount","type":"uint256","indexed":false,"internalType":"uint256"}],"anonymous":false},{"name":"LauncherSet","type":"event","inputs":[{"name":"launcher","type":"address","indexed":true,"internalType":"address"}],"anonymous":false},{"name":"LeftoverBurned","type":"event","inputs":[{"name":"amount","type":"uint256","indexed":false,"internalType":"uint256"}],"anonymous":false},{"name":"Minted","type":"event","inputs":[{"name":"to","type":"address","indexed":true,"internalType":"address"},{"name":"firstId","type":"uint256","indexed":false,"internalType":"uint256"},{"name":"count","type":"uint256","indexed":false,"internalType":"uint256"},{"name":"agentId","type":"uint256","indexed":false,"internalType":"uint256"},{"name":"paid","type":"uint256","indexed":false,"internalType":"uint256"}],"anonymous":false},{"name":"OwnershipTransferred","type":"event","inputs":[{"name":"previousOwner","type":"address","indexed":true,"internalType":"address"},{"name":"newOwner","type":"address","indexed":true,"internalType":"address"}],"anonymous":false},{"name":"PoolLaunched","type":"event","inputs":[{"name":"launcher","type":"address","indexed":true,"internalType":"address"},{"name":"bnb","type":"uint256","indexed":false,"internalType":"uint256"},{"name":"liquidity","type":"uint256","indexed":false,"internalType":"uint256"}],"anonymous":false},{"name":"Redeemed","type":"event","inputs":[{"name":"holder","type":"address","indexed":true,"internalType":"address"},{"name":"count","type":"uint256","indexed":false,"internalType":"uint256"},{"name":"amount","type":"uint256","indexed":false,"internalType":"uint256"}],"anonymous":false},{"name":"Revealed","type":"event","inputs":[{"name":"tokenId","type":"uint256","indexed":true,"internalType":"uint256"},{"name":"tier","type":"uint8","indexed":false,"internalType":"uint8"},{"name":"holder","type":"address","indexed":true,"internalType":"address"},{"name":"amount","type":"uint256","indexed":false,"internalType":"uint256"}],"anonymous":false},{"name":"RoundOpened","type":"event","inputs":[{"name":"roundId","type":"uint256","indexed":true,"internalType":"uint256"},{"name":"quota","type":"uint256","indexed":false,"internalType":"uint256"},{"name":"priceUsd","type":"uint256","indexed":false,"internalType":"uint256"},{"name":"tierBps","type":"uint16[3]","indexed":false,"internalType":"uint16[3]"}],"anonymous":false},{"name":"SaleFinished","type":"event","inputs":[{"name":"roundId","type":"uint256","indexed":true,"internalType":"uint256"}],"anonymous":false},{"name":"Split","type":"event","inputs":[{"name":"toPool","type":"uint256","indexed":false,"internalType":"uint256"},{"name":"toTeam","type":"uint256","indexed":false,"internalType":"uint256"}],"anonymous":false},{"name":"TeamAllocated","type":"event","inputs":[{"name":"to","type":"address","indexed":true,"internalType":"address"},{"name":"firstId","type":"uint256","indexed":false,"internalType":"uint256"},{"name":"count","type":"uint256","indexed":false,"internalType":"uint256"},{"name":"ssr","type":"uint256","indexed":false,"internalType":"uint256"},{"name":"sr","type":"uint256","indexed":false,"internalType":"uint256"},{"name":"r","type":"uint256","indexed":false,"internalType":"uint256"},{"name":"amount","type":"uint256","indexed":false,"internalType":"uint256"}],"anonymous":false},{"name":"TeamCardsClaimed","type":"event","inputs":[{"name":"to","type":"address","indexed":true,"internalType":"address"},{"name":"firstId","type":"uint256","indexed":false,"internalType":"uint256"},{"name":"count","type":"uint256","indexed":false,"internalType":"uint256"}],"anonymous":false},{"name":"TokenSet","type":"event","inputs":[{"name":"token","type":"address","indexed":true,"internalType":"address"}],"anonymous":false},{"name":"Transfer","type":"event","inputs":[{"name":"from","type":"address","indexed":true,"internalType":"address"},{"name":"to","type":"address","indexed":true,"internalType":"address"},{"name":"tokenId","type":"uint256","indexed":true,"internalType":"uint256"}],"anonymous":false},{"name":"TransferUnlocked","type":"event","inputs":[],"anonymous":false},{"name":"BPS","type":"function","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"name":"DEAD","type":"function","inputs":[],"outputs":[{"name":"","type":"address","internalType":"address"}],"stateMutability":"view"},{"name":"FEED_HEARTBEAT","type":"function","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"name":"FEED_MAX_PRICE","type":"function","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"name":"FEED_MIN_PRICE","type":"function","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"name":"FREE_PER_AGENT","type":"function","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"name":"FREE_TOTAL","type":"function","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"name":"MAX_PER_AGENT","type":"function","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"name":"MAX_PER_TX","type":"function","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"name":"MINT_WINDOW","type":"function","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"name":"P1","type":"function","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"name":"P2","type":"function","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"name":"POOL_SHARE_BPS","type":"function","inputs":[],"outputs":[{"name":"","type":"uint16","internalType":"uint16"}],"stateMutability":"view"},{"name":"REDEEM_BATCH","type":"function","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"name":"TEAM_BATCH","type":"function","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"name":"TEAM_CARDS","type":"function","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"name":"TEAM_UNLOCK_FREE","type":"function","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"name":"TIERS","type":"function","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"name":"accDividendPerWeight","type":"function","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"name":"approve","type":"function","inputs":[{"name":"to","type":"address","internalType":"address"},{"name":"tokenId","type":"uint256","internalType":"uint256"}],"outputs":[],"stateMutability":"nonpayable"},{"name":"balanceOf","type":"function","inputs":[{"name":"owner","type":"address","internalType":"address"}],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"name":"baseURI","type":"function","inputs":[],"outputs":[{"name":"","type":"string","internalType":"string"}],"stateMutability":"view"},{"name":"bnbUsdFeed","type":"function","inputs":[],"outputs":[{"name":"","type":"address","internalType":"contract AggregatorV3Interface"}],"stateMutability":"view"},{"name":"cardValue","type":"function","inputs":[{"name":"tokenId","type":"uint256","internalType":"uint256"}],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"name":"cards","type":"function","inputs":[{"name":"","type":"uint256","internalType":"uint256"}],"outputs":[{"name":"tier","type":"uint8","internalType":"uint8"}],"stateMutability":"view"},{"name":"cardsOf","type":"function","inputs":[{"name":"holder","type":"address","internalType":"address"},{"name":"from","type":"uint256","internalType":"uint256"},{"name":"to","type":"uint256","internalType":"uint256"}],"outputs":[{"name":"ids","type":"uint256[]","internalType":"uint256[]"}],"stateMutability":"view"},{"name":"claimDividends","type":"function","inputs":[{"name":"tokenIds","type":"uint256[]","internalType":"uint256[]"}],"outputs":[],"stateMutability":"nonpayable"},{"name":"claimTeamCards","type":"function","inputs":[{"name":"count","type":"uint256","internalType":"uint256"}],"outputs":[],"stateMutability":"nonpayable"},{"name":"closeRound","type":"function","inputs":[],"outputs":[],"stateMutability":"nonpayable"},{"name":"currentRound","type":"function","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"name":"deckLeft","type":"function","inputs":[{"name":"","type":"uint256","internalType":"uint256"}],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"name":"deckRemaining","type":"function","inputs":[],"outputs":[{"name":"ssr","type":"uint256","internalType":"uint256"},{"name":"sr","type":"uint256","internalType":"uint256"},{"name":"r","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"name":"dividendCarry","type":"function","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"name":"dividendDebt","type":"function","inputs":[{"name":"","type":"uint256","internalType":"uint256"}],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"name":"freeLeftFor","type":"function","inputs":[{"name":"agentId","type":"uint256","internalType":"uint256"}],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"name":"freeMinted","type":"function","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"name":"freeUsed","type":"function","inputs":[{"name":"","type":"uint256","internalType":"uint256"}],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"name":"getApproved","type":"function","inputs":[{"name":"tokenId","type":"uint256","internalType":"uint256"}],"outputs":[{"name":"","type":"address","internalType":"address"}],"stateMutability":"view"},{"name":"isApprovedForAll","type":"function","inputs":[{"name":"owner","type":"address","internalType":"address"},{"name":"operator","type":"address","internalType":"address"}],"outputs":[{"name":"","type":"bool","internalType":"bool"}],"stateMutability":"view"},{"name":"isNextFree","type":"function","inputs":[{"name":"agentId","type":"uint256","internalType":"uint256"}],"outputs":[{"name":"","type":"bool","internalType":"bool"}],"stateMutability":"view"},{"name":"launchOnSellout","type":"function","inputs":[{"name":"","type":"uint256","internalType":"uint256"}],"outputs":[{"name":"","type":"bool","internalType":"bool"}],"stateMutability":"view"},{"name":"launchPool","type":"function","inputs":[],"outputs":[],"stateMutability":"nonpayable"},{"name":"launcher","type":"function","inputs":[],"outputs":[{"name":"","type":"address","internalType":"contract IPoolLauncher"}],"stateMutability":"view"},{"name":"launcherLocked","type":"function","inputs":[],"outputs":[{"name":"","type":"bool","internalType":"bool"}],"stateMutability":"view"},{"name":"mint","type":"function","inputs":[{"name":"count","type":"uint256","internalType":"uint256"},{"name":"agentId","type":"uint256","internalType":"uint256"},{"name":"maxPriceUsd","type":"uint256","internalType":"uint256"}],"outputs":[],"stateMutability":"payable"},{"name":"mintOpen","type":"function","inputs":[],"outputs":[{"name":"","type":"bool","internalType":"bool"}],"stateMutability":"view"},{"name":"mintedByAgent","type":"function","inputs":[{"name":"","type":"uint256","internalType":"uint256"}],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"name":"name","type":"function","inputs":[],"outputs":[{"name":"","type":"string","internalType":"string"}],"stateMutability":"view"},{"name":"nextTeamReserve","type":"function","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"name":"notifyDividend","type":"function","inputs":[{"name":"amount","type":"uint256","internalType":"uint256"}],"outputs":[],"stateMutability":"nonpayable"},{"name":"openRound","type":"function","inputs":[{"name":"roundId","type":"uint256","internalType":"uint256"},{"name":"quota","type":"uint256","internalType":"uint256"},{"name":"priceUsd","type":"uint256","internalType":"uint256"},{"name":"tierBps","type":"uint256[]","internalType":"uint256[]"},{"name":"launchPool","type":"bool","internalType":"bool"}],"outputs":[],"stateMutability":"nonpayable"},{"name":"owner","type":"function","inputs":[],"outputs":[{"name":"","type":"address","internalType":"address"}],"stateMutability":"view"},{"name":"ownerOf","type":"function","inputs":[{"name":"tokenId","type":"uint256","internalType":"uint256"}],"outputs":[{"name":"","type":"address","internalType":"address"}],"stateMutability":"view"},{"name":"pendingDividends","type":"function","inputs":[{"name":"tokenIds","type":"uint256[]","internalType":"uint256[]"}],"outputs":[{"name":"sum","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"name":"poolWallet","type":"function","inputs":[],"outputs":[{"name":"","type":"address","internalType":"address"}],"stateMutability":"view"},{"name":"publicMinted","type":"function","inputs":[{"name":"roundId","type":"uint256","internalType":"uint256"}],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"name":"publicQuota","type":"function","inputs":[{"name":"roundId","type":"uint256","internalType":"uint256"}],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"name":"redeem","type":"function","inputs":[{"name":"tokenIds","type":"uint256[]","internalType":"uint256[]"}],"outputs":[],"stateMutability":"nonpayable"},{"name":"registrar","type":"function","inputs":[],"outputs":[{"name":"","type":"address","internalType":"contract IAgentRegistry"}],"stateMutability":"view"},{"name":"renounceOwnership","type":"function","inputs":[],"outputs":[],"stateMutability":"nonpayable"},{"name":"roundInfo","type":"function","inputs":[{"name":"roundId","type":"uint256","internalType":"uint256"}],"outputs":[{"name":"quota","type":"uint256","internalType":"uint256"},{"name":"minted","type":"uint256","internalType":"uint256"},{"name":"priceUsd","type":"uint256","internalType":"uint256"},{"name":"active","type":"bool","internalType":"bool"}],"stateMutability":"view"},{"name":"rounds","type":"function","inputs":[{"name":"","type":"uint256","internalType":"uint256"}],"outputs":[{"name":"nftQuota","type":"uint256","internalType":"uint256"},{"name":"minted","type":"uint256","internalType":"uint256"},{"name":"priceUsd","type":"uint256","internalType":"uint256"},{"name":"active","type":"bool","internalType":"bool"},{"name":"teamReserve","type":"uint256","internalType":"uint256"},{"name":"teamMinted","type":"uint256","internalType":"uint256"},{"name":"endTime","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"name":"safeTransferFrom","type":"function","inputs":[{"name":"from","type":"address","internalType":"address"},{"name":"to","type":"address","internalType":"address"},{"name":"tokenId","type":"uint256","internalType":"uint256"}],"outputs":[],"stateMutability":"nonpayable"},{"name":"safeTransferFrom","type":"function","inputs":[{"name":"from","type":"address","internalType":"address"},{"name":"to","type":"address","internalType":"address"},{"name":"tokenId","type":"uint256","internalType":"uint256"},{"name":"data","type":"bytes","internalType":"bytes"}],"outputs":[],"stateMutability":"nonpayable"},{"name":"setApprovalForAll","type":"function","inputs":[{"name":"operator","type":"address","internalType":"address"},{"name":"approved","type":"bool","internalType":"bool"}],"outputs":[],"stateMutability":"nonpayable"},{"name":"setBaseURI","type":"function","inputs":[{"name":"u","type":"string","internalType":"string"}],"outputs":[],"stateMutability":"nonpayable"},{"name":"setLauncher","type":"function","inputs":[{"name":"l","type":"address","internalType":"address"}],"outputs":[],"stateMutability":"nonpayable"},{"name":"setNextTeamReserve","type":"function","inputs":[{"name":"n","type":"uint256","internalType":"uint256"}],"outputs":[],"stateMutability":"nonpayable"},{"name":"setTierAmounts","type":"function","inputs":[{"name":"ssr","type":"uint256","internalType":"uint256"},{"name":"sr","type":"uint256","internalType":"uint256"},{"name":"r","type":"uint256","internalType":"uint256"}],"outputs":[],"stateMutability":"nonpayable"},{"name":"setToken","type":"function","inputs":[{"name":"t","type":"address","internalType":"address"}],"outputs":[],"stateMutability":"nonpayable"},{"name":"supportsInterface","type":"function","inputs":[{"name":"interfaceId","type":"bytes4","internalType":"bytes4"}],"outputs":[{"name":"","type":"bool","internalType":"bool"}],"stateMutability":"view"},{"name":"symbol","type":"function","inputs":[],"outputs":[{"name":"","type":"string","internalType":"string"}],"stateMutability":"view"},{"name":"teamAccSnapshot","type":"function","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"name":"teamAllocated","type":"function","inputs":[],"outputs":[{"name":"","type":"bool","internalType":"bool"}],"stateMutability":"view"},{"name":"teamClaimed","type":"function","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"name":"teamFirstId","type":"function","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"name":"teamReservedTotal","type":"function","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"name":"teamTierLeft","type":"function","inputs":[{"name":"","type":"uint256","internalType":"uint256"}],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"name":"teamTotal","type":"function","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"name":"teamUnclaimed","type":"function","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"name":"teamWallet","type":"function","inputs":[],"outputs":[{"name":"","type":"address","internalType":"address"}],"stateMutability":"view"},{"name":"tierAmount","type":"function","inputs":[{"name":"","type":"uint256","internalType":"uint256"}],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"name":"tierCount","type":"function","inputs":[{"name":"","type":"uint256","internalType":"uint256"}],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"name":"tierOf","type":"function","inputs":[{"name":"tokenId","type":"uint256","internalType":"uint256"}],"outputs":[{"name":"","type":"uint8","internalType":"uint8"}],"stateMutability":"view"},{"name":"tierProbability","type":"function","inputs":[{"name":"roundId","type":"uint256","internalType":"uint256"}],"outputs":[{"name":"","type":"uint16[3]","internalType":"uint16[3]"}],"stateMutability":"view"},{"name":"token","type":"function","inputs":[],"outputs":[{"name":"","type":"address","internalType":"contract IERC20"}],"stateMutability":"view"},{"name":"tokenRound","type":"function","inputs":[{"name":"","type":"uint256","internalType":"uint256"}],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"name":"tokenURI","type":"function","inputs":[{"name":"tokenId","type":"uint256","internalType":"uint256"}],"outputs":[{"name":"","type":"string","internalType":"string"}],"stateMutability":"view"},{"name":"totalDividendsClaimed","type":"function","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"name":"totalMinted","type":"function","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"name":"totalPaidOut","type":"function","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"name":"totalRedeemed","type":"function","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"name":"totalWeight","type":"function","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"name":"transferFrom","type":"function","inputs":[{"name":"from","type":"address","internalType":"address"},{"name":"to","type":"address","internalType":"address"},{"name":"tokenId","type":"uint256","internalType":"uint256"}],"outputs":[],"stateMutability":"nonpayable"},{"name":"transferLocked","type":"function","inputs":[],"outputs":[{"name":"","type":"bool","internalType":"bool"}],"stateMutability":"view"},{"name":"transferOwnership","type":"function","inputs":[{"name":"newOwner","type":"address","internalType":"address"}],"outputs":[],"stateMutability":"nonpayable"},{"name":"usdToBnb","type":"function","inputs":[{"name":"usd","type":"uint256","internalType":"uint256"}],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"name":"userFreeTotal","type":"function","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"}],"matchId":"58089041","creationMatch":"exact_match","runtimeMatch":"exact_match","verifiedAt":"2026-11-02T14:40:13Z","match":"exact_match","chainId":"56","address":"0xBDD571429c3aDF233d913659C9Fc00D26a774f62"}