{"file_path":"src/UniversalGaslessDelegate.sol","creation_status":"success","source_code":"// SPDX-License-Identifier: AGPL-3.0-or-later\n// SPDX-FileCopyrightText: Copyright (C) 2025 Fireblocks <support@fireblocks.com>\npragma solidity 0.8.27;\n\nimport { IERC1271 } from \"@openzeppelin/contracts/interfaces/IERC1271.sol\";\nimport { ECDSA } from \"@openzeppelin/contracts/utils/cryptography/ECDSA.sol\";\nimport { Address } from \"@openzeppelin/contracts/utils/Address.sol\";\nimport {\n    ERC7579Utils,\n    Execution,\n    Mode,\n    CallType,\n    ExecType,\n    ModeSelector\n} from \"@openzeppelin/contracts/account/utils/draft-ERC7579Utils.sol\";\nimport { IERC7821 } from \"./interface/IERC7821.sol\";\nimport { TokenReceiver } from \"./mixins/TokenReceiver.sol\";\nimport { TypedAuthorization } from \"./mixins/TypedAuthorization.sol\";\nimport { NonceBitmap } from \"./mixins/NonceBitmap.sol\";\nimport { NonceStorage } from \"./library/NonceStorageStruct.sol\";\nimport { LibErrors } from \"./library/LibErrors.sol\";\nimport { IKillSwitch } from \"./interface/IKillSwitch.sol\";\n\n/**\n * @title UniversalGaslessDelegate\n * @notice An EIP-7702 compatible delegate contract for enabling gasless transactions through delegation. This\n *         contract implements a pattern where logic can execute on behalf of users who have signed authorized payload.\n *\n * @dev Implements flexible standards such as EIP-7821 to enhance the EOA experience with contract functionality. It\n *      allows third parties to submit transactions for execution on behalf of users (i.e. gasless operations), as\n *      long as users have provided the necessary authorization.\n *\n * Core Features:\n * - Leverages on EIP-7702 for delegate-based transaction execution\n * - Supports EIP-7579/EIP-7821 execution modes for single and batch transactions (see {supportsExecutionMode})\n * - Integrates EIP-712 typed data signing for structured transaction authorization\n * - Implements unordered nonces for authorization replay protection\n * - Provides ERC-1271 signature validation compatibility for existing protocols\n * - Includes token receiver capabilities (ERC-721 and ERC-1155)\n * - Emergency pause functionality via KillSwitch contract\n *\n * @custom:security-contact support@fireblocks.com\n */\ncontract UniversalGaslessDelegate is IERC1271, IERC7821, NonceBitmap, TokenReceiver, TypedAuthorization {\n    // =============================================================\n    //                  CONSTANTS / IMMUTABLE\n    // =============================================================\n\n    /**\n     * @notice The address of the implementation contract\n     * @dev This is used to detect direct calls to the implementation contract. It is set to the address of the\n     *      implementation contract at deployment time.\n     */\n    address private immutable __implementation = address(this); // solhint-disable-line immutable-vars-naming\n\n    /**\n     * @dev Storage location for the nonce bitmap. Derived from performing the following operation:\n     * keccak256(abi.encode(uint256(keccak256(\"fireblocks.global.security.nonces\")) - 1)) & ~bytes32(uint256(0xff))\n     */\n    bytes32 private constant _NONCE_STORAGE_LOCATION =\n        0xb035242b6a1b64fd1e2d869c03a3cc0e80fe7f55db29c2560bab38e489fab700;\n\n    /**\n     * @notice Reference to the KillSwitch contract that can pause the Universal Gasless Delegate functionality\n     * @dev This immutable reference points to a contract implementing the IKillSwitch interface\n     *      that can pause operations in case of emergencies. The contract is checked for validity\n     *      and unpaused status during construction.\n     */\n    IKillSwitch private immutable _KILLSWITCH_CONTRACT;\n\n    /**\n     * @notice Enumeration of the different execution modes supported by the contract\n     * @dev These values correspond to the execution modes defined in {supportsExecutionMode}, with INVALID as the\n     *      default 0 state\n     *\n     * - INVALID: Represents an invalid/unsupported execution mode (0)\n     * - SINGLE_CALL_OPDATA_AUTH: Single call with authorization via opData (1)\n     * - BATCH_CALL_OPDATA_AUTH: Batch call with authorization via optional opData (2)\n     * - BATCH_CALL: Batch call with self-call authorization (3)\n     */\n    enum ExecutionModeId {\n        // 0: Invalid mode\n        INVALID,\n        // 1: CallType = Single (0x00), ExecType = Revert (0x00), ModeSelector = Auth via opData (0x78210001)\n        SINGLE_CALL_OPDATA_AUTH,\n        // 2: CallType = Batch (0x01), ExecType = Revert (0x00), ModeSelector = Auth via opData (0x78210001)\n        BATCH_CALL_OPDATA_AUTH,\n        // 3: CallType = Batch (0x01), ExecType = Revert (0x00), ModeSelector = Default (0x00000000)\n        BATCH_CALL\n    }\n\n    // =============================================================\n    //                          STATE STORAGE\n    //\n    // This contract follows ERC-7201 for Namespaced storage\n    // Global storage:\n    // - See {_NONCE_STORAGE_LOCATION} for NonceStorage\n    // =============================================================\n\n    // =============================================================\n    //                           EVENTS\n    // =============================================================\n\n    // =============================================================\n    //                          MODIFIERS\n    // =============================================================\n\n    /**\n     * @notice This modifier is used to ensure that the function is called through a proxy, which in the EIP-7702\n     *         context means that the function is called on a Delegated EOA.\n     * @dev Prevents direct calls to the implementation.\n     */\n    modifier onlyProxy() {\n        if (address(this) == __implementation) revert LibErrors.UnauthorizedCallContext();\n        _;\n    }\n\n    /**\n     * @notice Restricts function access to calls originating solely from the contract itself\n     * @dev Reverts with {LibErrors.UnauthorizedCaller} if msg.sender is not the Delegated EOA itself, in either the\n     * EOA or contract context.\n     */\n    modifier onlySelf() {\n        if (msg.sender != address(this)) revert LibErrors.UnauthorizedCaller();\n        _;\n    }\n\n    /**\n     * @notice This modifier ensures that the contract is not paused via the KillSwitch\n     * @dev Reverts if the KillSwitch contract indicates the system is paused\n     *      This modifier is used to protect state-modifying functions from being executed during\n     *      emergency situations.\n     */\n    modifier whenNotPaused() {\n        if (_KILLSWITCH_CONTRACT.paused()) revert LibErrors.EnforcedPause();\n        _;\n    }\n\n    // =============================================================\n    //                          FUNCTIONS\n    // =============================================================\n\n    /**\n     * @notice Initializes the 7702 delegate implementation contract\n     *\n     * @dev Calling Conditions:\n     *\n     * - `killswitchContract` must not be the zero address\n     * - `killswitchContract` must implement {IKillSwitch}\n     * - `killswitchContract` must not be in paused state\n     *\n     * Reverts with:\n     * - no error data (i.e. standard `revert()`) if the contract does not return a bool value on the\n     *   static-call to `paused()`\n     * - `InvalidImplementation()` if the contract is paused\n     * @param killswitchContract Address of the killswitch contract\n     */\n    constructor(address killswitchContract) TypedAuthorization() {\n        _KILLSWITCH_CONTRACT = IKillSwitch(killswitchContract);\n        // check if it is a valid IKillSwitch contract that is not paused\n        require(!_KILLSWITCH_CONTRACT.paused(), LibErrors.InvalidImplementation());\n    }\n\n    // ==================== EXTERNAL AND PUBLIC ====================\n\n    /**\n     * @notice Allows direct ETH transfers to the contract\n     * @dev Executed when the contract receives a plain ETH transfer (empty calldata)\n     *\n     * Calling Conditions:\n     * - The function should be called in the context of the Delegated EOA. Calling it directly on the implementation\n     *   address will revert due to the `onlyProxy` check.\n     */\n    receive() external payable onlyProxy { }\n\n    /**\n     * @notice Handles non-matching function calls with ETH value\n     * @dev Executed when the contract receives a call with non-empty calldata that doesn't match any function.\n     *      Ensures backward compatibility with EOA-like behavior for receiving transactions with arbitrary calldata,\n     *      like strings on a \"value with memo\" pattern.\n     *\n     * Calling Conditions:\n     * - The function should be called in the context of the Delegated EOA. Calling it directly on the implementation\n     *   address will revert due to the `onlyProxy` check.\n     *\n     * NOTE: Using payable fallback functions for receiving Ether is not recommended, since when calldata is present,\n     * the fallback is invoked and would not fail for interface confusions on the part of the sender. This fallback\n     * exists primarily to ensure backward compatibility with standard EOA behavior.\n     */\n    fallback() external payable onlyProxy { }\n\n    /**\n     * @notice Executes one or more calls on behalf of this Delegated EOA, supporting both single and batch operations\n     * with an optional authorization mechanism. The caller can be either the Delegated EOA itself or another account\n     * provided that the latter has a valid signature for the execution(s) to be made.\n     *\n     * @dev Processes execution requests according to the EIP-7579 and EIP-7821 specification, which define the mode\n     * format and execution data structure. This function supports three different execution modes as detailed in\n     * {supportsExecutionMode}.\n     *\n     * The `executionData` parameter follows EIP-7821 encoding rules:\n     *   - For modes with opData for authorization (SINGLE_CALL_OPDATA_AUTH and BATCH_CALL_OPDATA_AUTH) the following\n     *     encoding is expected `abi.encode(sobExecutionData, opData)`, where:\n     *     - in SINGLE_CALL_OPDATA_AUTH, `sobExecutionData` is abi.encodePacked(target, value, callData)\n     *     - in BATCH_CALL_OPDATA_AUTH, `sobExecutionData` is abi.encode(calls)\n     *     - `opData` is abi.encodePacked(nonce, deadline, signature)\n     *   - For self-call mode (BATCH_CALL): `abi.encode(calls)` with no optional `opData`\n     *\n     * Authorization flow:\n     *\n     * Note that while for mode BATCH_CALL_OPDATA_AUTH, opData is optional (fallback to `msg.sender` verification),\n     * for mode SINGLE_CALL_OPDATA_AUTH, opData is required (no fallback to `msg.sender`). For a single call of this\n     * type, the EOA should be making the call to target directly and not through the delegate contract.\n     *\n     * 1. For modes with opData authorization (SINGLE_CALL_OPDATA_AUTH and BATCH_CALL_OPDATA_AUTH):\n     *   - Calculate authorization digest using EIP-712 typed data signing\n     *   - Validate that the nonce is not already used\n     *   - Verify the signature has not expired (current block timestamp <= deadline)\n     *   - Verify the caller matches the relayer in the signed authorization\n     *   - Verify signature matches the Delegated EOA's\n     * 2. For self-call mode (BATCH_CALL only):\n     *    - Verify caller is the delegated EOA itself (`msg.sender == address(this)`)\n     *\n     * Note: This implementation does NOT perform the target replacement gas optimization listed in EIP-7821.\n     * Explicitly, {_call} will NOT replace `address(0)` with `address(this)` as the `target` parameter.\n     *\n     * Note: The ERC7579Utils.decodeBatch function performs validation and will throw\n     * {ERC7579DecodingError} if the input is not properly formatted.\n     *\n     * Calling Conditions:\n     * - The function should be called in the context of the Delegated EOA. Calling it directly on the implementation\n     *   address will revert. (checked by `onlyProxy`)\n     * - The implementation contract should not be paused. (checked by `whenNotPaused`)\n     * - If the target of the execution is the Delegated EOA itself, it can only call the `invalidateNonce` function.\n     *\n     * @param mode The execution mode that defines how the execution data should be processed\n     * @param executionData The encoded execution data and optional authorization data (opData)\n     */\n    function execute(bytes32 mode, bytes calldata executionData) external payable whenNotPaused onlyProxy {\n        // Decode the execution data according to the mode\n        ExecutionModeId modeId = _executionModeId(mode);\n        // Revert if mode is not supported\n        if (modeId == ExecutionModeId.INVALID) _determineExecutionModeRevertCause(mode);\n\n        bytes calldata sobExecutionData;\n        bytes calldata opData;\n        (sobExecutionData, opData) = _extractExecAndOpData(executionData);\n        // Check if optional opData is present. If not, we rely on the caller being the Delegated EOA itself for auth\n        if (opData.length != 0) {\n            // Decode opData to extract nonce, deadline and signature\n            (uint256 nonce, uint256 deadline, bytes calldata signature) = _decodeOpData(opData);\n            // Check if signature has expired\n            require(block.timestamp <= deadline, LibErrors.ExpiredSignature(deadline));\n            // irrespective of single or batch, the nonce is always used on modes with opData auth\n            _useUnorderedNonce(nonce);\n            if (modeId == ExecutionModeId.SINGLE_CALL_OPDATA_AUTH) {\n                // Perform authentication using opData and execute single call\n                (address target, uint256 value, bytes calldata callData) = ERC7579Utils.decodeSingle(sobExecutionData);\n                // create AuthorizedExecutions EIP712 hash\n                bytes32 sDigest =\n                    _hashTypedSingleExecutionAuthorization(mode, target, value, callData, nonce, deadline, msg.sender);\n                //validate signature\n                require(address(this) == ECDSA.recover(sDigest, signature), LibErrors.UnauthorizedExecution());\n                // Execute the call\n                _call(target, value, callData);\n                return;\n            }\n            if (modeId == ExecutionModeId.BATCH_CALL_OPDATA_AUTH) {\n                // Perform authentication using opData and execute batch calls\n                Execution[] calldata executionBatch = ERC7579Utils.decodeBatch(sobExecutionData);\n                // create AuthorizedExecutions EIP712 hash\n                bytes32 bDigest =\n                    _hashTypedBatchExecutionAuthorization(mode, executionBatch, nonce, deadline, msg.sender);\n                //validate signature\n                require(address(this) == ECDSA.recover(bDigest, signature), LibErrors.UnauthorizedExecution());\n                // Execute the batch calls\n                _execBatch(executionBatch);\n                return;\n            }\n            // BATCH_CALL mode does not support an opData component\n            if (modeId == ExecutionModeId.BATCH_CALL) revert LibErrors.UnauthorizedExecution();\n        } else {\n            require(msg.sender == address(this), LibErrors.UnauthorizedCaller());\n            // For mode SINGLE_CALL_OPDATA_AUTH, opData is required for authorization\n            if (modeId == ExecutionModeId.SINGLE_CALL_OPDATA_AUTH) revert LibErrors.UnauthorizedExecution();\n            // Evaluate modes BATCH_CALL_OPDATA_AUTH  and BATCH_CALL under no opData, self-call authorization\n            Execution[] calldata executionBatch = ERC7579Utils.decodeBatch(executionData);\n            // Execute the batch calls\n            _execBatch(executionBatch);\n            return;\n        }\n    }\n\n    /**\n     * @notice This function marks a nonce as used\n     * @dev This function is used to invalidate a nonce\n     *\n     * Calling Conditions:\n     * - The caller must be the Delegated EOA or the contract itself (checked by `onlySelf`)\n     * - If the contract context is paused, the call must come from the Delegated EOA directly\n     *\n     * Reverts with {LibErrors.InvalidNonce} if the nonce has already been used.\n     *\n     * @param nonce The nonce to invalidate\n     */\n    function invalidateNonce(uint256 nonce) external override onlyProxy onlySelf {\n        _useUnorderedNonce(nonce);\n    }\n\n    /**\n     * @notice Returns the fields and values that describe the domain separator to be used as part of EIP-712\n     * signatures verified by this contract.\n     *\n     * @dev This function overrides {TypedAuthorization.eip712Domain()} to ensure it can only be called in the context\n     * of a delegated EOA (via proxy). Calling it directly on the implementation address will revert with\n     * {LibErrors.UnauthorizedCallContext}.\n     */\n    function eip712Domain()\n        public\n        view\n        virtual\n        override\n        onlyProxy\n        returns (\n            bytes1 fields,\n            string memory name,\n            string memory version,\n            uint256 chainId,\n            address verifyingContract,\n            bytes32 salt,\n            uint256[] memory extensions\n        )\n    {\n        return super.eip712Domain();\n    }\n\n    /**\n     * @inheritdoc NonceBitmap\n     */\n    function getNonceBitmap(uint248 wordPos) public view override onlyProxy returns (uint256 bitmap) {\n        return super.getNonceBitmap(wordPos);\n    }\n\n    /**\n     * @inheritdoc NonceBitmap\n     */\n    function isNonceUsed(uint256 nonce) public view override onlyProxy returns (bool isUsed) {\n        return super.isNonceUsed(nonce);\n    }\n\n    /**\n     * @notice This function provides a standard method for external contracts to validate a signature for a given\n     *         hash, ensuring that such signatures have been created by the Delegated EOA.\n     *\n     * It also provides legacy (pre EIP-7702) compatibility with the ERC-1271 standard for signature validation, where\n     * protocols might choose to validate signatures using this function, if they find in their logic that it is the\n     * way to do it where the account has code.\n     *\n     * @dev Validates if the provided signature is valid for the given data hash and attributable to the Delegated EOA.\n     *      This function is provided for compliance with the ERC-1271 standard for signature validation.\n     *\n     * Calling Conditions:\n     *\n     * - The function should be called in the context of the Delegated EOA. Calling it directly on the implementation\n     *   address will revert.\n     *\n     * @param _hash Hash of the data to be signed\n     * @param _signature Signature byte array associated with the hash\n     * @return magicValue The function selector if signature is valid, or 0xffffffff if invalid\n     */\n    function isValidSignature(\n        bytes32 _hash,\n        bytes calldata _signature\n    )\n        external\n        view\n        onlyProxy\n        returns (bytes4 magicValue)\n    {\n        if (_isValidRawSignature(_hash, _signature)) {\n            return IERC1271.isValidSignature.selector;\n        } else {\n            return 0xffffffff;\n        }\n    }\n\n    /**\n     * @notice Returns whether the delegate contract is currently paused\n     * @dev This function checks the pause state of the KillSwitch contract. Unlike most functions,\n     *      it can be called both on the implementation contract and on delegated EOAs, as it should convey the same\n     * meaning. It signals if delegate implementation is safe to use.\n     *\n     * @return isPausedState True if the contract is paused via the KillSwitch, false otherwise\n     */\n    function isPaused() external view returns (bool isPausedState) {\n        return _KILLSWITCH_CONTRACT.paused();\n    }\n\n    /**\n     * @notice This function is provided for frontends to detect support. It checks if the contract supports\n     *         a specific execution mode.\n     *\n     * @dev Determines whether the contract supports the specified execution mode. Supported execution modes are\n     *      detailed in the table below:\n     *\n     * ```\n     *      +------------------+----------+----------+------------+-------------------+-------------+\n     *      | Mode ID          | CallType | ExecType | Unused     | ModeSelector      | ModePayload |\n     *      |                  | (1 byte) | (1 byte) | (4 bytes)  | (4 bytes)         | (22 bytes)  |\n     *      +------------------+----------+----------+------------+-------------------+-------------+\n     *      | SINGLE_CALL_     | 0x00     | 0x00     | 0x00000000 | 0x78210001        | ANY         |\n     *      | OPDATA_AUTH  (1) | (Single) | (Revert) | (Empty)    | (Auth via opData) |             |\n     *      +------------------+----------+----------+------------+-------------------+-------------+\n     *      | BATCH_CALL_      | 0x01     | 0x00     | 0x00000000 | 0x78210001        | ANY         |\n     *      | OPDATA_AUTH  (2) | (Batch)  | (Revert) | (Empty)    | (Auth via opData) |             |\n     *      +------------------+----------+----------+------------+-------------------+-------------+\n     *      | BATCH_CALL       | 0x01     | 0x00     | 0x00000000 | 0x00000000        | ANY         |\n     *      |              (3) | (Batch)  | (Revert) | (Empty)    | (Default)         |             |\n     *      +------------------+----------+----------+------------+-------------------+-------------+\n     * ```\n     *\n     * @param mode The fully-qualified execution mode to check\n     * @return isSupported True if the mode is supported, false otherwise\n     */\n    function supportsExecutionMode(bytes32 mode) external pure returns (bool isSupported) {\n        return _executionModeId(mode) != ExecutionModeId.INVALID;\n    }\n\n    /**\n     * @notice This function can be queried to check if the contract implements a specific interface\n     * @dev Interface detection as per ERC-165 standard\n     *\n     * Calling Conditions:\n     *\n     * - The function should be called in the context of the Delegated EOA. Calling it directly on the implementation\n     *   address will revert.\n     *\n     * @param interfaceId The interface identifier to check\n     * @return isSupported True when `interfaceId` is either:\n     *   - the {IERC7821} interface id\n     *   - the {IERC1271} interface id\n     *   - the {IERC721Receiver} interface id (checked in TokenReceiver)\n     *   - the {IERC1155Receiver} interface id (checked in ERC1155Holder)\n     *   - the {IERC165} interface id (checked in ERC1155Holder -> ERC165)\n     */\n    function supportsInterface(bytes4 interfaceId) public view override onlyProxy returns (bool isSupported) {\n        return interfaceId == type(IERC7821).interfaceId || interfaceId == type(IERC1271).interfaceId\n            || super.supportsInterface(interfaceId);\n    }\n\n    // ========================= INTERNAL ==========================\n\n    /**\n     * @notice This function calls the target with specified value and data. It is multipurpose and can be used for\n     *         both invoking a function on target contract or for sending ETH to non-contract addresses.\n     * @dev Performs a low-level call to the target contract and verifies the result.\n     *\n     * Note: This function prevents reentrancy when the target is the Delegated EOA. Following a whitelist pattern,\n     * the only function selector allowed in this situation is the `invalidateNonce` function. If any other function,\n     * for example `execute`, is called, it will revert with a `ReentrantCall` error.\n     *\n     * Calling Conditions:\n     *\n     * - The call to perform does not constitute a reentrant call to the execute function.\n     *\n     * @param target The address of the contract to call\n     * @param value The amount of ETH to send with the call\n     * @param data The calldata to send to the target\n     */\n    function _call(address target, uint256 value, bytes calldata data) internal {\n        // Reject any calls to self that are not the invalidateNonce function\n        if (target == address(this) && data.length >= 4 && bytes4(data[:4]) != this.invalidateNonce.selector) {\n            revert LibErrors.ReentrantCall();\n        }\n        (bool success, bytes memory returndata) = target.call{ value: value }(data);\n        Address.verifyCallResult(success, returndata);\n    }\n\n    /**\n     * @notice Internal function that executes a batch of calls sequentially\n     * @dev Processes an array of Execution structs, calling each target with the specified value and calldata.\n     *      This function ensures each call is processed in sequence and bubbles up any errors from failed calls.\n     *\n     * Security considerations:\n     * - All calls are made in the context of the Delegated EOA (address(this))\n     * - This is an internal function without authorization checks\n     *\n     * @param executionBatch An array of Execution structs containing target addresses, values, and calldata\n     */\n    function _execBatch(Execution[] calldata executionBatch) internal {\n        for (uint256 i = 0; i < executionBatch.length; ++i) {\n            _call(executionBatch[i].target, executionBatch[i].value, executionBatch[i].callData);\n        }\n    }\n\n    /**\n     * @notice Identifies the type of execution mode\n     * @dev Analyzes the execution mode and returns the {ExecutionModeId} identifier:\n     *\n     * - INVALID if the mode is not supported\n     * - SINGLE_CALL_OPDATA_AUTH for CallType = Single (0x00), ExecType = Revert on failure (0x00),\n     *   Unused = EMPTY, ModeSelector = Authorization via **required** `opData` (0x78210001), ModePayload = ANY\n     * - BATCH_CALL_OPDATA_AUTH for CallType = Batch (0x01), ExecType = Revert on failure (0x00),\n     *   Unused = EMPTY, ModeSelector = Authorization via optional `opData` (0x78210001), ModePayload = ANY\n     * - BATCH_CALL for CallType = Batch (0x01), ExecType = Revert on failure (0x00),\n     *        Unused = EMPTY, ModeSelector = Default (0x00000000), ModePayload = ANY\n     *\n     * @param mode The execution mode to analyze\n     * @return The enum value representing the execution mode type/identifier\n     */\n    function _executionModeId(bytes32 mode) internal pure returns (ExecutionModeId) {\n        // Check if the mode is supported. Only checks the first 10 bytes of the mode\n        bytes10 execModeMinusPayload = bytes10(mode);\n        if (execModeMinusPayload == bytes10(0x00000000000078210001)) {\n            return ExecutionModeId.SINGLE_CALL_OPDATA_AUTH;\n        }\n        if (execModeMinusPayload == bytes10(0x01000000000078210001)) {\n            return ExecutionModeId.BATCH_CALL_OPDATA_AUTH;\n        }\n        if (execModeMinusPayload == bytes10(0x01000000000000000000)) {\n            return ExecutionModeId.BATCH_CALL;\n        }\n        return ExecutionModeId.INVALID;\n    }\n\n    /**\n     * @notice Provides a custom error (if possible) to convey information when an execution mode is not supported\n     * @dev Analyzes the components of an execution mode and reverts with a specific error message\n     * based on which component is invalid.\n     *\n     * Reverts with:\n     * - {ERC7579UnsupportedCallType} if CallType is neither Single (0x00) nor Batch (0x01)\n     * - {ERC7579UnsupportedExecType} if ExecType is not Revert (0x00)\n     * - {UnsupportedModeSelector} if ModeSelector is neither Auth (0x78210001) nor Default (0x00000000)\n     * - {UnsupportedExecutionMode} for any other unsupported mode configuration\n     *\n     * @param mode The execution mode to analyze for the revert cause\n     */\n    function _determineExecutionModeRevertCause(bytes32 mode) internal pure {\n        // Extract the components from the mode\n        (CallType callType, ExecType execType, ModeSelector modeSelector,) = ERC7579Utils.decodeMode(Mode.wrap(mode));\n\n        // Check for callType being 0x00 (Single) or 0x01 (Batch)\n        if (!(callType == ERC7579Utils.CALLTYPE_SINGLE || callType == ERC7579Utils.CALLTYPE_BATCH)) {\n            revert ERC7579Utils.ERC7579UnsupportedCallType(callType);\n        }\n        // Check for execType being 0x00 (Revert on failure)\n        if (!(execType == ERC7579Utils.EXECTYPE_DEFAULT)) {\n            revert ERC7579Utils.ERC7579UnsupportedExecType(execType);\n        }\n        // Check for modeSelector being 0x78210001 (Auth via opData) or 0x00000000 (Default)\n        if (!(modeSelector == ModeSelector.wrap(0x78210001) || modeSelector == ModeSelector.wrap(0x00000000))) {\n            revert LibErrors.UnsupportedModeSelector(ModeSelector.unwrap(modeSelector));\n        }\n        // Revert with default error for other causes\n        revert LibErrors.UnsupportedExecutionMode();\n    }\n\n    /**\n     * @notice Extracts single/batch execution data and optional opData from `executionData`\n     * @dev Decodes executionData to separate the call(s) from the optional `opData` according to EIP-7821.\n     *\n     * Here, we perform low-level ABI-decoding of dynamic types with the intent of:\n     *   - gracefully handling structural errors that otherwise would result in a generic revert\n     *   - maintaining calldata references\n     *\n     * The function determines if opData is present by examining the offset values:\n     * - If only one dynamic type is present, only `singleOrBatchExecutionData` will be relevant, as `opData` is\n     *   set to empty\n     * - If two dynamic typed values are present, both execution data and opData are extracted\n     *\n     * Reverts:\n     * - with {LibErrors.ExecutionDataExtractionError} if offsets are invalid\n     *\n     * @param executionData The encoded execution data passed to execute()\n     * @return singleOrBatchExecutionData The extracted singleOrBatchExecutionData data\n     * @return opData The extracted operation data (empty if not provided)\n     */\n    function _extractExecAndOpData(bytes calldata executionData)\n        internal\n        pure\n        returns (bytes calldata singleOrBatchExecutionData, bytes calldata opData)\n    {\n        // Read the primary offset in a local variable first\n        uint256 cOffset;\n        assembly {\n            cOffset := calldataload(executionData.offset)\n        }\n\n        if (cOffset < 32) revert LibErrors.ExecutionDataExtractionError();\n\n        assembly {\n            let cPos := add(executionData.offset, cOffset)\n            singleOrBatchExecutionData.offset := add(cPos, 0x20)\n            singleOrBatchExecutionData.length := calldataload(cPos)\n        }\n\n        // If the first offset is 64, we have a second item for opData\n        if (cOffset >= 64) {\n            uint256 oOffset;\n            assembly {\n                oOffset := calldataload(add(executionData.offset, 0x20))\n            }\n            // Revert if the offset is invalid\n            if (oOffset < 64 || oOffset >= executionData.length) revert LibErrors.ExecutionDataExtractionError();\n\n            assembly {\n                let oPos := add(executionData.offset, oOffset)\n                opData.offset := add(oPos, 0x20)\n                opData.length := calldataload(oPos)\n            }\n        } else {\n            assembly {\n                opData.length := 0\n            }\n        }\n    }\n\n    /**\n     * @notice Decodes the `opData` parameter, extracting the nonce, deadline and signature components\n     * @dev Parses the opData byte array to extract the nonce, deadline and ECDSA signature according to an expected\n     *      packed format.\n     *\n     * The opData is expected to be in ABI packed encoding format:\n     *  - 32 bytes for nonce\n     *  - 32 bytes for deadline\n     *  - 65 bytes for signature (r, s, v)\n     *\n     * Reverts with {LibErrors.OpDataDecodingError} if opData is not at least 129 bytes.\n     *\n     * @param opData The data containing nonce, deadline and signature\n     * @return nonce The extracted nonce value used for replay protection\n     * @return deadline The timestamp after which the signature is no longer valid\n     * @return signature The extracted 65-byte ECDSA signature\n     */\n    function _decodeOpData(bytes calldata opData)\n        internal\n        pure\n        returns (uint256 nonce, uint256 deadline, bytes calldata signature)\n    {\n        // opData must contain a nonce, deadline and a signature, for a total of 129 bytes\n        require(opData.length == 129, LibErrors.OpDataDecodingError());\n\n        // Extract nonce from the first 32 bytes\n        nonce = uint256(bytes32(opData[:32]));\n        // Extract deadline from the next 32 bytes\n        deadline = uint256(bytes32(opData[32:64]));\n        // Extract signature from the remaining bytes\n        signature = opData[64:];\n    }\n\n    /**\n     * @notice Verifies if a signature is valid for a given hash in the context of the Delegated EOA, supporting any\n     * ECDSA signature flow including EIP-712.\n     *\n     * @dev Internal implementation for signature validation, reusable to support ERC1271 compatibility and any ECDSA\n     * signature verification requirements, including EIP-712 signatures.\n     *\n     * Note this function does not perform any nonce-validity checks.\n     *\n     * Signature Validity Conditions:\n     *\n     * - The signature does not derive the `address(0)`.\n     * - The signature has invalid length.\n     * - The signature has an S value that is in the lower half order\n     * - The signature must derive `address(this)`.\n     *\n     * @param _hash The hash of the data that was signed\n     * @param _signature A 65-byte ECDSA signature produced by the signer\n     * @return isValid true if the signature is valid, false otherwise\n     */\n    function _isValidRawSignature(bytes32 _hash, bytes calldata _signature) internal view returns (bool isValid) {\n        (address recovered, ECDSA.RecoverError err,) = ECDSA.tryRecover(_hash, _signature);\n        return address(this) == recovered && err == ECDSA.RecoverError.NoError;\n    }\n\n    /**\n     * @notice This function is used to get the namespaced, structured nonce storage\n     * @dev This function is used to get the nonce storage pointer\n     * @custom:storage-location erc7201:fireblocks.global.security.nonces\n     * @return $ The reference to the {NonceStorage} struct in storage\n     */\n    function _nonceStorage() internal pure override returns (NonceStorage storage $) {\n        assembly (\"memory-safe\") {\n            $.slot := _NONCE_STORAGE_LOCATION\n        }\n    }\n\n    /**\n     * @notice Returns the address of the verifying contract to be used in the EIP712 domain separator\n     * @dev The verifyingContract used is the address of the implementation contract, set during deployment, to prevent\n     *      replay attacks if an EOA re-delegates to a different implementation.\n     * @return verifyingContract The address of the implementation contract\n     */\n    function _verifyingContractAddress() internal view override returns (address verifyingContract) {\n        // During the construction phase, the value of `__implementation` might be empty, which is not a valid\n        // verifying contract. Therefore, we coalesce to the eventual implementation address.\n        return __implementation == address(0) ? address(this) : __implementation;\n    }\n}\n","deployed_bytecode":"0x6080806040526004361015610028575b5036156100205761001e61153a565b005b61001e61153a565b60003560e01c90816301ffc9a71461081e57508063150b7a02146107b05780631626ba7e1461072c5780634abb262a1461067b5780635d00bb12146105e457806384b0196e1461049e578063b187bd26146103ef578063b70e36f014610365578063bc197c81146102b5578063d03c791414610284578063e9ae5c531461012c5763f23a6e61146100b9573861000f565b346101275760a0600319360112610127576100d2610990565b506100db6109b3565b5060843567ffffffffffffffff8111610127576100fc903690600401610a7b565b5060206040517ff23a6e61000000000000000000000000000000000000000000000000000000008152f35b600080fd5b61013536610a99565b906040517f5c975abb00000000000000000000000000000000000000000000000000000000815260208160048173ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000fb2736c301e53904409f03de06c8467a165afa90811561027857600091610249575b5061021f5773ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000fb7702036ff9f76044a501ac1aa74cbab16b1630146101f55761001e92610c8a565b7f9f03a0260000000000000000000000000000000000000000000000000000000060005260046000fd5b7fd93c06650000000000000000000000000000000000000000000000000000000060005260046000fd5b61026b915060203d602011610271575b61026381836109d6565b810190610c39565b846101aa565b503d610259565b6040513d6000823e3d90fd5b346101275760206003193601126101275760206102a26004356115ea565b6102ab81610c51565b6040519015158152f35b346101275760a0600319360112610127576102ce610990565b506102d76109b3565b5060443567ffffffffffffffff8111610127576102f8903690600401610b46565b5060643567ffffffffffffffff811161012757610319903690600401610b46565b5060843567ffffffffffffffff81116101275761033a903690600401610a7b565b5060206040517fbc197c81000000000000000000000000000000000000000000000000000000008152f35b346101275760206003193601126101275773ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000fb7702036ff9f76044a501ac1aa74cbab16b1630146101f5573033036103c55761001e600435611579565b7f5c427cd90000000000000000000000000000000000000000000000000000000060005260046000fd5b34610127576000600319360112610127576040517f5c975abb00000000000000000000000000000000000000000000000000000000815260208160048173ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000fb2736c301e53904409f03de06c8467a165afa801561027857602091600091610481575b506040519015158152f35b6104989150823d84116102715761026381836109d6565b82610476565b346101275760006003193601126101275773ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000fb7702036ff9f76044a501ac1aa74cbab16b1630146101f5576105856020604051906104ff81836109d6565b600082526040519061051181836109d6565b6000825261051d6119b2565b73ffffffffffffffffffffffffffffffffffffffff6105936040519461054385876109d6565b6000865260003681376040519788977f0c00000000000000000000000000000000000000000000000000000000000000895260e0878a015260e0890190610aed565b908782036040890152610aed565b91466060870152166080850152600060a085015283810360c085015281808451928381520193019160005b8281106105cd57505050500390f35b8351855286955093810193928101926001016105be565b346101275760206003193601126101275760043573ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000fb7702036ff9f76044a501ac1aa74cbab16b1630146101f557600160209160ff8160081c9116906000527fb035242b6a1b64fd1e2d869c03a3cc0e80fe7f55db29c2560bab38e489fab70083521b604060002054161515604051908152f35b34610127576020600319360112610127576004357effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff81168091036101275773ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000fb7702036ff9f76044a501ac1aa74cbab16b1630146101f5576000527fb035242b6a1b64fd1e2d869c03a3cc0e80fe7f55db29c2560bab38e489fab7006020526020604060002054604051908152f35b346101275761073a36610a99565b73ffffffffffffffffffffffffffffffffffffffff9291927f0000000000000000000000000000fb7702036ff9f76044a501ac1aa74cbab16b1630146101f55760209261078692610ba3565b7fffffffff0000000000000000000000000000000000000000000000000000000060405191168152f35b34610127576080600319360112610127576107c9610990565b506107d26109b3565b5060643567ffffffffffffffff8111610127576107f3903690600401610a7b565b5060206040517f150b7a02000000000000000000000000000000000000000000000000000000008152f35b3461012757602060031936011261012757600435907fffffffff0000000000000000000000000000000000000000000000000000000082168092036101275773ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000fb7702036ff9f76044a501ac1aa74cbab16b1630146101f557817f399225470000000000000000000000000000000000000000000000000000000060209314908115610966575b81156108d6575b5015158152f35b7f150b7a0200000000000000000000000000000000000000000000000000000000811491508115610909575b50836108cf565b7f4e2312e00000000000000000000000000000000000000000000000000000000081149150811561093c575b5083610902565b7f01ffc9a70000000000000000000000000000000000000000000000000000000091501483610935565b7f1626ba7e00000000000000000000000000000000000000000000000000000000811491506108c8565b6004359073ffffffffffffffffffffffffffffffffffffffff8216820361012757565b6024359073ffffffffffffffffffffffffffffffffffffffff8216820361012757565b90601f601f19910116810190811067ffffffffffffffff8211176109f957604052565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b67ffffffffffffffff81116109f957601f01601f191660200190565b929192610a5082610a28565b91610a5e60405193846109d6565b829481845281830111610127578281602093846000960137010152565b9080601f8301121561012757816020610a9693359101610a44565b90565b6040600319820112610127576004359160243567ffffffffffffffff811161012757826023820112156101275780600401359267ffffffffffffffff84116101275760248483010111610127576024019190565b919082519283825260005b848110610b19575050601f19601f8460006020809697860101520116010190565b80602080928401015182828601015201610af8565b67ffffffffffffffff81116109f95760051b60200190565b9080601f83011215610127578135610b5d81610b2e565b92610b6b60405194856109d6565b81845260208085019260051b82010192831161012757602001905b828210610b935750505090565b8135815260209182019101610b86565b610bc7610bcd9273ffffffffffffffffffffffffffffffffffffffff943691610a44565b90611976565b50911630149081610c27575b5015610c03577f1626ba7e0000000000000000000000000000000000000000000000000000000090565b7fffffffff0000000000000000000000000000000000000000000000000000000090565b9050610c3281610c51565b1538610bd9565b90816020910312610127575180151581036101275790565b60041115610c5b57565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b90610c94826115ea565b91610c9e83610c51565b82156113a357369180359060208210611366578181019060208201946040833594101560001461139a57506020810135604081108015611390575b61136657810196602088019735915b8215611308575050608181036112de57806020116101275786359281604011610127576020880135957fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc0604060009a019301938742116112b257610d4b86611579565b610d5489610c51565b6001891461110d5750610d6688610c51565b60028814610db15750505050505050600390610d8181610c51565b14610d895750565b807f7daadde30000000000000000000000000000000000000000000000000000000060049252fd5b610dc392939497509894979598611690565b929091610dcf84610b2e565b98610ddd6040519a8b6109d6565b848a5260208a018560051b85013681116111095785915b81831061103857505050895197610e23610e0d8a610b2e565b99610e1b6040519b8c6109d6565b808b52610b2e565b99601f1960208b019b01368c37885b8c51811015610ee757808b610ee08f938473ffffffffffffffffffffffffffffffffffffffff610e6483600198611962565b515116906040610e83846020610e7a8286611962565b51015193611962565b510151602081519101206040519160208301937fc7893c18b7bfea9418ca400815946cd740f303b74b0ff88fb938f83d0c1bd94e855260408401526060830152608082015260808152610ed760a0826109d6565b51902092611962565b5201610e32565b509295989194979a5092959860405190602082018093519091908d5b818110611022575050509473ffffffffffffffffffffffffffffffffffffffff9794610fcd610bc795610fbf610fe69a9686610f4e610fd598610fdd9d03601f1981018352826109d6565b51902060405194859360208501973393899360a09373ffffffffffffffffffffffffffffffffffffffff939796929760c08701987fddfe073f873bee5d1c9e29281fa37f2d0716a8e75ec88b673b4ec2a7c850ec3f8852602088015260408701526060860152608085015216910152565b03601f1981018352826109d6565b5190206119f3565b923691610a44565b90929192611ae1565b163003610ffa57610ff89293506117a0565b565b6004847f7daadde3000000000000000000000000000000000000000000000000000000008152fd5b8251845260209384019390920191600101610f03565b823567ffffffffffffffff811161110557870160608136031261110557604051906060820182811067ffffffffffffffff8211176110d857604052803573ffffffffffffffffffffffffffffffffffffffff811681036110d457825260208101356020830152604081013567ffffffffffffffff81116110d457916110c4602094928594369101610a7b565b6040820152815201920191610df4565b8c80fd5b60248d7f4e487b710000000000000000000000000000000000000000000000000000000081526041600452fd5b8a80fd5b8880fd5b9591809795985060149a999a116112ae573560601c93866034116112ae57603486013595605401967fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffcc019736611164908a8a610a44565b8051906020012060405160208101917fc7893c18b7bfea9418ca400815946cd740f303b74b0ff88fb938f83d0c1bd94e83528860408301528960608301526080820152608081526111b660a0826109d6565b51902060405160208101918252602081526111d26040826109d6565b519020604080517fddfe073f873bee5d1c9e29281fa37f2d0716a8e75ec88b673b4ec2a7c850ec3f60208201908152918101929092526060820193909352608081019390935260a08301523360c08084019190915282529061123560e0826109d6565b519020611241906119f3565b91369061124d92610a44565b61125691611976565b61125f91611ae1565b73ffffffffffffffffffffffffffffffffffffffff16300361128657610ff8949550611858565b6004867f7daadde3000000000000000000000000000000000000000000000000000000008152fd5b8980fd5b60248a897fbd2a913c000000000000000000000000000000000000000000000000000000008252600452fd5b7f59d8e20f0000000000000000000000000000000000000000000000000000000060005260046000fd5b9695509650505050503033036103c55760019061132481610c51565b1461133c57610ff89161133691611690565b906117a0565b7f7daadde30000000000000000000000000000000000000000000000000000000060005260046000fd5b7fec3e6d970000000000000000000000000000000000000000000000000000000060005260046000fd5b5087811015610cd9565b96600091610ce8565b7fff000000000000000000000000000000000000000000000000000000000000008116907fffffffff000000000000000000000000000000000000000000000000000000007fff000000000000000000000000000000000000000000000000000000000000008260081b169160301b169180158015611511575b156114e45750806114b757507f7821000100000000000000000000000000000000000000000000000000000000811480156114af575b15611482577f7f1812750000000000000000000000000000000000000000000000000000000060005260046000fd5b7fb73f9c5a0000000000000000000000000000000000000000000000000000000060005260045260246000fd5b508015611453565b7f23a240850000000000000000000000000000000000000000000000000000000060005260045260246000fd5b7fb1be6a960000000000000000000000000000000000000000000000000000000060005260045260246000fd5b507f0100000000000000000000000000000000000000000000000000000000000000811461141d565b73ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000fb7702036ff9f76044a501ac1aa74cbab16b1630146101f557565b600160ff8260081c92161b906000527fb035242b6a1b64fd1e2d869c03a3cc0e80fe7f55db29c2560bab38e489fab70060205260406000208181541880915516156115c057565b7f756688fe0000000000000000000000000000000000000000000000000000000060005260046000fd5b7fffffffffffffffffffff0000000000000000000000000000000000000000000016797821000100000000000000000000000000000000000000000000811461168a577f01000000000078210001000000000000000000000000000000000000000000008114611684577f01000000000000000000000000000000000000000000000000000000000000001461167f57600090565b600390565b50600290565b50600190565b919091602083106116eb578260201161012757803590601f19840182116116eb5760006020830180841161172d57851061172a575081019081359367ffffffffffffffff8511918215611715575b50506116eb576020019190565b7feb0bcc5d0000000000000000000000000000000000000000000000000000000060005260046000fd5b601f199192508560051b9203011038806116de565b80fd5b5080fd5b91908110156117715760051b810135907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa181360301821215610127570190565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b9060005b8181106117b057505050565b6117bb818385611731565b359073ffffffffffffffffffffffffffffffffffffffff821682036101275760206117e7828587611731565b0135916117f5828587611731565b6040810135907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe181360301821215610127570180359067ffffffffffffffff82116101275760200181360381136101275760019461185293611858565b016117a4565b9190913073ffffffffffffffffffffffffffffffffffffffff82161480611957575b80611902575b6118d8578360009384936118cd966040519384928337810185815203925af13d156118d0573d906118b082610a28565b916118be60405193846109d6565b82523d6000602084013e611bae565b50565b606090611bae565b7f37ed32e80000000000000000000000000000000000000000000000000000000060005260046000fd5b5083600411610127577fb70e36f0000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008335161415611880565b50600484101561187a565b80518210156117715760209160051b010190565b81519190604183036119a7576119a092506020820151906060604084015193015160001a90611bef565b9192909190565b505060009160029190565b7f0000000000000000000000000000fb7702036ff9f76044a501ac1aa74cbab16b73ffffffffffffffffffffffffffffffffffffffff8116610a9657503090565b604290467f000000000000000000000000000000000000000000000000000000000000000103611a75577f79871c985accdba0e91bb3769ac7881a544c156f9ed801d0b8710c28276b4093905b604051917f19010000000000000000000000000000000000000000000000000000000000008352600283015260228201522090565b611a7d6119b2565b60405173ffffffffffffffffffffffffffffffffffffffff60208201927f47e79534a245952e8b16893a336b85a3d9ea9fa8c573f3d803afb92a79469218845246604084015216606082015260608152611ad86080826109d6565b51902090611a40565b611aea81610c51565b80611af3575050565b611afc81610c51565b60018103611b2e577ff645eedf0000000000000000000000000000000000000000000000000000000060005260046000fd5b611b3781610c51565b60028103611b6d57507ffce698f70000000000000000000000000000000000000000000000000000000060005260045260246000fd5b600390611b7981610c51565b14611b815750565b7fd78bce0c0000000000000000000000000000000000000000000000000000000060005260045260246000fd5b909190610ff85750805115611bc557805190602001fd5b7fd6bda2750000000000000000000000000000000000000000000000000000000060005260046000fd5b91907f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08411611c79579160209360809260ff60009560405194855216868401526040830152606082015282805260015afa156102785760005173ffffffffffffffffffffffffffffffffffffffff811615611c6d5790600090600090565b50600090600190600090565b5050506000916003919056fea164736f6c634300081b000a","optimization_enabled":true,"verified_twin_address_hash":null,"is_verified":true,"compiler_settings":{"evmVersion":"paris","libraries":{},"metadata":{"appendCBOR":true,"bytecodeHash":"none","useLiteralContent":true},"optimizer":{"enabled":true,"runs":10000},"outputSelection":{"*":{"":["*"],"*":["*"]}},"remappings":["@openzeppelin/contracts/=node_modules/@openzeppelin/contracts/","forge-std/=node_modules/forge-std/src/"],"viaIR":true},"optimization_runs":10000,"sourcify_repo_url":null,"decoded_constructor_args":[["0x00000000FB2736C301E53904409f03De06c8467A",{"internalType":"address","name":"killswitchContract","type":"address"}]],"compiler_version":"v0.8.27+commit.40a35a09","is_verified_via_verifier_alliance":false,"verified_at":"2025-12-17T18:11:04.648806Z","implementations":[],"proxy_type":null,"external_libraries":[],"creation_bytecode":"0x61010080604052346101b257602081611e83803803809161002082856101b7565b8339810103126101b257516001600160a01b038116908190036101b2574660a05260c0516004916020916001600160a01b0316806101ad5750305b604051838101917f47e79534a245952e8b16893a336b85a3d9ea9fa8c573f3d803afb92a79469218835246604083015260018060a01b03166060820152606081526100a76080826101b7565b5190206080523060c0528060e05260405192838092635c975abb60e01b82525afa9081156101a15760009161015f575b5061014e57604051611c9290816101f1823960805181611a1f015260a051816119f9015260c0518181816101c60152818161038d015281816104c60152818161060f015281816106cf01528181610754015281816108740152818161155101526119b4015260e05181818161017901526104430152f35b63340aafcd60e11b60005260046000fd5b6020813d602011610199575b81610178602093836101b7565b8101031261019557519081151582036101925750386100d7565b80fd5b5080fd5b3d915061016b565b6040513d6000823e3d90fd5b61005b565b600080fd5b601f909101601f19168101906001600160401b038211908210176101da57604052565b634e487b7160e01b600052604160045260246000fdfe6080806040526004361015610028575b5036156100205761001e61153a565b005b61001e61153a565b60003560e01c90816301ffc9a71461081e57508063150b7a02146107b05780631626ba7e1461072c5780634abb262a1461067b5780635d00bb12146105e457806384b0196e1461049e578063b187bd26146103ef578063b70e36f014610365578063bc197c81146102b5578063d03c791414610284578063e9ae5c531461012c5763f23a6e61146100b9573861000f565b346101275760a0600319360112610127576100d2610990565b506100db6109b3565b5060843567ffffffffffffffff8111610127576100fc903690600401610a7b565b5060206040517ff23a6e61000000000000000000000000000000000000000000000000000000008152f35b600080fd5b61013536610a99565b906040517f5c975abb00000000000000000000000000000000000000000000000000000000815260208160048173ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000165afa90811561027857600091610249575b5061021f5773ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001630146101f55761001e92610c8a565b7f9f03a0260000000000000000000000000000000000000000000000000000000060005260046000fd5b7fd93c06650000000000000000000000000000000000000000000000000000000060005260046000fd5b61026b915060203d602011610271575b61026381836109d6565b810190610c39565b846101aa565b503d610259565b6040513d6000823e3d90fd5b346101275760206003193601126101275760206102a26004356115ea565b6102ab81610c51565b6040519015158152f35b346101275760a0600319360112610127576102ce610990565b506102d76109b3565b5060443567ffffffffffffffff8111610127576102f8903690600401610b46565b5060643567ffffffffffffffff811161012757610319903690600401610b46565b5060843567ffffffffffffffff81116101275761033a903690600401610a7b565b5060206040517fbc197c81000000000000000000000000000000000000000000000000000000008152f35b346101275760206003193601126101275773ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001630146101f5573033036103c55761001e600435611579565b7f5c427cd90000000000000000000000000000000000000000000000000000000060005260046000fd5b34610127576000600319360112610127576040517f5c975abb00000000000000000000000000000000000000000000000000000000815260208160048173ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000165afa801561027857602091600091610481575b506040519015158152f35b6104989150823d84116102715761026381836109d6565b82610476565b346101275760006003193601126101275773ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001630146101f5576105856020604051906104ff81836109d6565b600082526040519061051181836109d6565b6000825261051d6119b2565b73ffffffffffffffffffffffffffffffffffffffff6105936040519461054385876109d6565b6000865260003681376040519788977f0c00000000000000000000000000000000000000000000000000000000000000895260e0878a015260e0890190610aed565b908782036040890152610aed565b91466060870152166080850152600060a085015283810360c085015281808451928381520193019160005b8281106105cd57505050500390f35b8351855286955093810193928101926001016105be565b346101275760206003193601126101275760043573ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001630146101f557600160209160ff8160081c9116906000527fb035242b6a1b64fd1e2d869c03a3cc0e80fe7f55db29c2560bab38e489fab70083521b604060002054161515604051908152f35b34610127576020600319360112610127576004357effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff81168091036101275773ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001630146101f5576000527fb035242b6a1b64fd1e2d869c03a3cc0e80fe7f55db29c2560bab38e489fab7006020526020604060002054604051908152f35b346101275761073a36610a99565b73ffffffffffffffffffffffffffffffffffffffff9291927f00000000000000000000000000000000000000000000000000000000000000001630146101f55760209261078692610ba3565b7fffffffff0000000000000000000000000000000000000000000000000000000060405191168152f35b34610127576080600319360112610127576107c9610990565b506107d26109b3565b5060643567ffffffffffffffff8111610127576107f3903690600401610a7b565b5060206040517f150b7a02000000000000000000000000000000000000000000000000000000008152f35b3461012757602060031936011261012757600435907fffffffff0000000000000000000000000000000000000000000000000000000082168092036101275773ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001630146101f557817f399225470000000000000000000000000000000000000000000000000000000060209314908115610966575b81156108d6575b5015158152f35b7f150b7a0200000000000000000000000000000000000000000000000000000000811491508115610909575b50836108cf565b7f4e2312e00000000000000000000000000000000000000000000000000000000081149150811561093c575b5083610902565b7f01ffc9a70000000000000000000000000000000000000000000000000000000091501483610935565b7f1626ba7e00000000000000000000000000000000000000000000000000000000811491506108c8565b6004359073ffffffffffffffffffffffffffffffffffffffff8216820361012757565b6024359073ffffffffffffffffffffffffffffffffffffffff8216820361012757565b90601f601f19910116810190811067ffffffffffffffff8211176109f957604052565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b67ffffffffffffffff81116109f957601f01601f191660200190565b929192610a5082610a28565b91610a5e60405193846109d6565b829481845281830111610127578281602093846000960137010152565b9080601f8301121561012757816020610a9693359101610a44565b90565b6040600319820112610127576004359160243567ffffffffffffffff811161012757826023820112156101275780600401359267ffffffffffffffff84116101275760248483010111610127576024019190565b919082519283825260005b848110610b19575050601f19601f8460006020809697860101520116010190565b80602080928401015182828601015201610af8565b67ffffffffffffffff81116109f95760051b60200190565b9080601f83011215610127578135610b5d81610b2e565b92610b6b60405194856109d6565b81845260208085019260051b82010192831161012757602001905b828210610b935750505090565b8135815260209182019101610b86565b610bc7610bcd9273ffffffffffffffffffffffffffffffffffffffff943691610a44565b90611976565b50911630149081610c27575b5015610c03577f1626ba7e0000000000000000000000000000000000000000000000000000000090565b7fffffffff0000000000000000000000000000000000000000000000000000000090565b9050610c3281610c51565b1538610bd9565b90816020910312610127575180151581036101275790565b60041115610c5b57565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b90610c94826115ea565b91610c9e83610c51565b82156113a357369180359060208210611366578181019060208201946040833594101560001461139a57506020810135604081108015611390575b61136657810196602088019735915b8215611308575050608181036112de57806020116101275786359281604011610127576020880135957fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc0604060009a019301938742116112b257610d4b86611579565b610d5489610c51565b6001891461110d5750610d6688610c51565b60028814610db15750505050505050600390610d8181610c51565b14610d895750565b807f7daadde30000000000000000000000000000000000000000000000000000000060049252fd5b610dc392939497509894979598611690565b929091610dcf84610b2e565b98610ddd6040519a8b6109d6565b848a5260208a018560051b85013681116111095785915b81831061103857505050895197610e23610e0d8a610b2e565b99610e1b6040519b8c6109d6565b808b52610b2e565b99601f1960208b019b01368c37885b8c51811015610ee757808b610ee08f938473ffffffffffffffffffffffffffffffffffffffff610e6483600198611962565b515116906040610e83846020610e7a8286611962565b51015193611962565b510151602081519101206040519160208301937fc7893c18b7bfea9418ca400815946cd740f303b74b0ff88fb938f83d0c1bd94e855260408401526060830152608082015260808152610ed760a0826109d6565b51902092611962565b5201610e32565b509295989194979a5092959860405190602082018093519091908d5b818110611022575050509473ffffffffffffffffffffffffffffffffffffffff9794610fcd610bc795610fbf610fe69a9686610f4e610fd598610fdd9d03601f1981018352826109d6565b51902060405194859360208501973393899360a09373ffffffffffffffffffffffffffffffffffffffff939796929760c08701987fddfe073f873bee5d1c9e29281fa37f2d0716a8e75ec88b673b4ec2a7c850ec3f8852602088015260408701526060860152608085015216910152565b03601f1981018352826109d6565b5190206119f3565b923691610a44565b90929192611ae1565b163003610ffa57610ff89293506117a0565b565b6004847f7daadde3000000000000000000000000000000000000000000000000000000008152fd5b8251845260209384019390920191600101610f03565b823567ffffffffffffffff811161110557870160608136031261110557604051906060820182811067ffffffffffffffff8211176110d857604052803573ffffffffffffffffffffffffffffffffffffffff811681036110d457825260208101356020830152604081013567ffffffffffffffff81116110d457916110c4602094928594369101610a7b565b6040820152815201920191610df4565b8c80fd5b60248d7f4e487b710000000000000000000000000000000000000000000000000000000081526041600452fd5b8a80fd5b8880fd5b9591809795985060149a999a116112ae573560601c93866034116112ae57603486013595605401967fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffcc019736611164908a8a610a44565b8051906020012060405160208101917fc7893c18b7bfea9418ca400815946cd740f303b74b0ff88fb938f83d0c1bd94e83528860408301528960608301526080820152608081526111b660a0826109d6565b51902060405160208101918252602081526111d26040826109d6565b519020604080517fddfe073f873bee5d1c9e29281fa37f2d0716a8e75ec88b673b4ec2a7c850ec3f60208201908152918101929092526060820193909352608081019390935260a08301523360c08084019190915282529061123560e0826109d6565b519020611241906119f3565b91369061124d92610a44565b61125691611976565b61125f91611ae1565b73ffffffffffffffffffffffffffffffffffffffff16300361128657610ff8949550611858565b6004867f7daadde3000000000000000000000000000000000000000000000000000000008152fd5b8980fd5b60248a897fbd2a913c000000000000000000000000000000000000000000000000000000008252600452fd5b7f59d8e20f0000000000000000000000000000000000000000000000000000000060005260046000fd5b9695509650505050503033036103c55760019061132481610c51565b1461133c57610ff89161133691611690565b906117a0565b7f7daadde30000000000000000000000000000000000000000000000000000000060005260046000fd5b7fec3e6d970000000000000000000000000000000000000000000000000000000060005260046000fd5b5087811015610cd9565b96600091610ce8565b7fff000000000000000000000000000000000000000000000000000000000000008116907fffffffff000000000000000000000000000000000000000000000000000000007fff000000000000000000000000000000000000000000000000000000000000008260081b169160301b169180158015611511575b156114e45750806114b757507f7821000100000000000000000000000000000000000000000000000000000000811480156114af575b15611482577f7f1812750000000000000000000000000000000000000000000000000000000060005260046000fd5b7fb73f9c5a0000000000000000000000000000000000000000000000000000000060005260045260246000fd5b508015611453565b7f23a240850000000000000000000000000000000000000000000000000000000060005260045260246000fd5b7fb1be6a960000000000000000000000000000000000000000000000000000000060005260045260246000fd5b507f0100000000000000000000000000000000000000000000000000000000000000811461141d565b73ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001630146101f557565b600160ff8260081c92161b906000527fb035242b6a1b64fd1e2d869c03a3cc0e80fe7f55db29c2560bab38e489fab70060205260406000208181541880915516156115c057565b7f756688fe0000000000000000000000000000000000000000000000000000000060005260046000fd5b7fffffffffffffffffffff0000000000000000000000000000000000000000000016797821000100000000000000000000000000000000000000000000811461168a577f01000000000078210001000000000000000000000000000000000000000000008114611684577f01000000000000000000000000000000000000000000000000000000000000001461167f57600090565b600390565b50600290565b50600190565b919091602083106116eb578260201161012757803590601f19840182116116eb5760006020830180841161172d57851061172a575081019081359367ffffffffffffffff8511918215611715575b50506116eb576020019190565b7feb0bcc5d0000000000000000000000000000000000000000000000000000000060005260046000fd5b601f199192508560051b9203011038806116de565b80fd5b5080fd5b91908110156117715760051b810135907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa181360301821215610127570190565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b9060005b8181106117b057505050565b6117bb818385611731565b359073ffffffffffffffffffffffffffffffffffffffff821682036101275760206117e7828587611731565b0135916117f5828587611731565b6040810135907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe181360301821215610127570180359067ffffffffffffffff82116101275760200181360381136101275760019461185293611858565b016117a4565b9190913073ffffffffffffffffffffffffffffffffffffffff82161480611957575b80611902575b6118d8578360009384936118cd966040519384928337810185815203925af13d156118d0573d906118b082610a28565b916118be60405193846109d6565b82523d6000602084013e611bae565b50565b606090611bae565b7f37ed32e80000000000000000000000000000000000000000000000000000000060005260046000fd5b5083600411610127577fb70e36f0000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008335161415611880565b50600484101561187a565b80518210156117715760209160051b010190565b81519190604183036119a7576119a092506020820151906060604084015193015160001a90611bef565b9192909190565b505060009160029190565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff8116610a9657503090565b604290467f000000000000000000000000000000000000000000000000000000000000000003611a75577f0000000000000000000000000000000000000000000000000000000000000000905b604051917f19010000000000000000000000000000000000000000000000000000000000008352600283015260228201522090565b611a7d6119b2565b60405173ffffffffffffffffffffffffffffffffffffffff60208201927f47e79534a245952e8b16893a336b85a3d9ea9fa8c573f3d803afb92a79469218845246604084015216606082015260608152611ad86080826109d6565b51902090611a40565b611aea81610c51565b80611af3575050565b611afc81610c51565b60018103611b2e577ff645eedf0000000000000000000000000000000000000000000000000000000060005260046000fd5b611b3781610c51565b60028103611b6d57507ffce698f70000000000000000000000000000000000000000000000000000000060005260045260246000fd5b600390611b7981610c51565b14611b815750565b7fd78bce0c0000000000000000000000000000000000000000000000000000000060005260045260246000fd5b909190610ff85750805115611bc557805190602001fd5b7fd6bda2750000000000000000000000000000000000000000000000000000000060005260046000fd5b91907f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08411611c79579160209360809260ff60009560405194855216868401526040830152606082015282805260015afa156102785760005173ffffffffffffffffffffffffffffffffffffffff811615611c6d5790600090600090565b50600090600190600090565b5050506000916003919056fea164736f6c634300081b000a00000000000000000000000000000000fb2736c301e53904409f03de06c8467a","name":"UniversalGaslessDelegate","is_blueprint":false,"license_type":"none","is_fully_verified":false,"is_verified_via_eth_bytecode_db":false,"language":"solidity","evm_version":"paris","can_be_visualized_via_sol2uml":true,"is_verified_via_sourcify":false,"additional_sources":[{"file_path":"node_modules/@openzeppelin/contracts/account/utils/draft-ERC7579Utils.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.2.0) (account/utils/draft-ERC7579Utils.sol)\n\npragma solidity ^0.8.20;\n\nimport {Execution} from \"../../interfaces/draft-IERC7579.sol\";\nimport {Packing} from \"../../utils/Packing.sol\";\nimport {Address} from \"../../utils/Address.sol\";\n\ntype Mode is bytes32;\ntype CallType is bytes1;\ntype ExecType is bytes1;\ntype ModeSelector is bytes4;\ntype ModePayload is bytes22;\n\n/**\n * @dev Library with common ERC-7579 utility functions.\n *\n * See https://eips.ethereum.org/EIPS/eip-7579[ERC-7579].\n */\n// slither-disable-next-line unused-state\nlibrary ERC7579Utils {\n    using Packing for *;\n\n    /// @dev A single `call` execution.\n    CallType internal constant CALLTYPE_SINGLE = CallType.wrap(0x00);\n\n    /// @dev A batch of `call` executions.\n    CallType internal constant CALLTYPE_BATCH = CallType.wrap(0x01);\n\n    /// @dev A `delegatecall` execution.\n    CallType internal constant CALLTYPE_DELEGATECALL = CallType.wrap(0xFF);\n\n    /// @dev Default execution type that reverts on failure.\n    ExecType internal constant EXECTYPE_DEFAULT = ExecType.wrap(0x00);\n\n    /// @dev Execution type that does not revert on failure.\n    ExecType internal constant EXECTYPE_TRY = ExecType.wrap(0x01);\n\n    /**\n     * @dev Emits when an {EXECTYPE_TRY} execution fails.\n     * @param batchExecutionIndex The index of the failed call in the execution batch.\n     * @param returndata The returned data from the failed call.\n     */\n    event ERC7579TryExecuteFail(uint256 batchExecutionIndex, bytes returndata);\n\n    /// @dev The provided {CallType} is not supported.\n    error ERC7579UnsupportedCallType(CallType callType);\n\n    /// @dev The provided {ExecType} is not supported.\n    error ERC7579UnsupportedExecType(ExecType execType);\n\n    /// @dev The provided module doesn't match the provided module type.\n    error ERC7579MismatchedModuleTypeId(uint256 moduleTypeId, address module);\n\n    /// @dev The module is not installed.\n    error ERC7579UninstalledModule(uint256 moduleTypeId, address module);\n\n    /// @dev The module is already installed.\n    error ERC7579AlreadyInstalledModule(uint256 moduleTypeId, address module);\n\n    /// @dev The module type is not supported.\n    error ERC7579UnsupportedModuleType(uint256 moduleTypeId);\n\n    /// @dev Input calldata not properly formatted and possibly malicious.\n    error ERC7579DecodingError();\n\n    /// @dev Executes a single call.\n    function execSingle(\n        bytes calldata executionCalldata,\n        ExecType execType\n    ) internal returns (bytes[] memory returnData) {\n        (address target, uint256 value, bytes calldata callData) = decodeSingle(executionCalldata);\n        returnData = new bytes[](1);\n        returnData[0] = _call(0, execType, target, value, callData);\n    }\n\n    /// @dev Executes a batch of calls.\n    function execBatch(\n        bytes calldata executionCalldata,\n        ExecType execType\n    ) internal returns (bytes[] memory returnData) {\n        Execution[] calldata executionBatch = decodeBatch(executionCalldata);\n        returnData = new bytes[](executionBatch.length);\n        for (uint256 i = 0; i < executionBatch.length; ++i) {\n            returnData[i] = _call(\n                i,\n                execType,\n                executionBatch[i].target,\n                executionBatch[i].value,\n                executionBatch[i].callData\n            );\n        }\n    }\n\n    /// @dev Executes a delegate call.\n    function execDelegateCall(\n        bytes calldata executionCalldata,\n        ExecType execType\n    ) internal returns (bytes[] memory returnData) {\n        (address target, bytes calldata callData) = decodeDelegate(executionCalldata);\n        returnData = new bytes[](1);\n        returnData[0] = _delegatecall(0, execType, target, callData);\n    }\n\n    /// @dev Encodes the mode with the provided parameters. See {decodeMode}.\n    function encodeMode(\n        CallType callType,\n        ExecType execType,\n        ModeSelector selector,\n        ModePayload payload\n    ) internal pure returns (Mode mode) {\n        return\n            Mode.wrap(\n                CallType\n                    .unwrap(callType)\n                    .pack_1_1(ExecType.unwrap(execType))\n                    .pack_2_4(bytes4(0))\n                    .pack_6_4(ModeSelector.unwrap(selector))\n                    .pack_10_22(ModePayload.unwrap(payload))\n            );\n    }\n\n    /// @dev Decodes the mode into its parameters. See {encodeMode}.\n    function decodeMode(\n        Mode mode\n    ) internal pure returns (CallType callType, ExecType execType, ModeSelector selector, ModePayload payload) {\n        return (\n            CallType.wrap(Packing.extract_32_1(Mode.unwrap(mode), 0)),\n            ExecType.wrap(Packing.extract_32_1(Mode.unwrap(mode), 1)),\n            ModeSelector.wrap(Packing.extract_32_4(Mode.unwrap(mode), 6)),\n            ModePayload.wrap(Packing.extract_32_22(Mode.unwrap(mode), 10))\n        );\n    }\n\n    /// @dev Encodes a single call execution. See {decodeSingle}.\n    function encodeSingle(\n        address target,\n        uint256 value,\n        bytes calldata callData\n    ) internal pure returns (bytes memory executionCalldata) {\n        return abi.encodePacked(target, value, callData);\n    }\n\n    /// @dev Decodes a single call execution. See {encodeSingle}.\n    function decodeSingle(\n        bytes calldata executionCalldata\n    ) internal pure returns (address target, uint256 value, bytes calldata callData) {\n        target = address(bytes20(executionCalldata[0:20]));\n        value = uint256(bytes32(executionCalldata[20:52]));\n        callData = executionCalldata[52:];\n    }\n\n    /// @dev Encodes a delegate call execution. See {decodeDelegate}.\n    function encodeDelegate(\n        address target,\n        bytes calldata callData\n    ) internal pure returns (bytes memory executionCalldata) {\n        return abi.encodePacked(target, callData);\n    }\n\n    /// @dev Decodes a delegate call execution. See {encodeDelegate}.\n    function decodeDelegate(\n        bytes calldata executionCalldata\n    ) internal pure returns (address target, bytes calldata callData) {\n        target = address(bytes20(executionCalldata[0:20]));\n        callData = executionCalldata[20:];\n    }\n\n    /// @dev Encodes a batch of executions. See {decodeBatch}.\n    function encodeBatch(Execution[] memory executionBatch) internal pure returns (bytes memory executionCalldata) {\n        return abi.encode(executionBatch);\n    }\n\n    /// @dev Decodes a batch of executions. See {encodeBatch}.\n    ///\n    /// NOTE: This function runs some checks and will throw a {ERC7579DecodingError} if the input is not properly formatted.\n    function decodeBatch(bytes calldata executionCalldata) internal pure returns (Execution[] calldata executionBatch) {\n        unchecked {\n            uint256 bufferLength = executionCalldata.length;\n\n            // Check executionCalldata is not empty.\n            if (bufferLength < 32) revert ERC7579DecodingError();\n\n            // Get the offset of the array (pointer to the array length).\n            uint256 arrayLengthOffset = uint256(bytes32(executionCalldata[0:32]));\n\n            // The array length (at arrayLengthOffset) should be 32 bytes long. We check that this is within the\n            // buffer bounds. Since we know bufferLength is at least 32, we can subtract with no overflow risk.\n            if (arrayLengthOffset > bufferLength - 32) revert ERC7579DecodingError();\n\n            // Get the array length. arrayLengthOffset + 32 is bounded by bufferLength so it does not overflow.\n            uint256 arrayLength = uint256(bytes32(executionCalldata[arrayLengthOffset:arrayLengthOffset + 32]));\n\n            // Check that the buffer is long enough to store the array elements as \"offset pointer\":\n            // - each element of the array is an \"offset pointer\" to the data.\n            // - each \"offset pointer\" (to an array element) takes 32 bytes.\n            // - validity of the calldata at that location is checked when the array element is accessed, so we only\n            //   need to check that the buffer is large enough to hold the pointers.\n            //\n            // Since we know bufferLength is at least arrayLengthOffset + 32, we can subtract with no overflow risk.\n            // Solidity limits length of such arrays to 2**64-1, this guarantees `arrayLength * 32` does not overflow.\n            if (arrayLength > type(uint64).max || bufferLength - arrayLengthOffset - 32 < arrayLength * 32)\n                revert ERC7579DecodingError();\n\n            assembly (\"memory-safe\") {\n                executionBatch.offset := add(add(executionCalldata.offset, arrayLengthOffset), 32)\n                executionBatch.length := arrayLength\n            }\n        }\n    }\n\n    /// @dev Executes a `call` to the target with the provided {ExecType}.\n    function _call(\n        uint256 index,\n        ExecType execType,\n        address target,\n        uint256 value,\n        bytes calldata data\n    ) private returns (bytes memory) {\n        (bool success, bytes memory returndata) = target.call{value: value}(data);\n        return _validateExecutionMode(index, execType, success, returndata);\n    }\n\n    /// @dev Executes a `delegatecall` to the target with the provided {ExecType}.\n    function _delegatecall(\n        uint256 index,\n        ExecType execType,\n        address target,\n        bytes calldata data\n    ) private returns (bytes memory) {\n        (bool success, bytes memory returndata) = target.delegatecall(data);\n        return _validateExecutionMode(index, execType, success, returndata);\n    }\n\n    /// @dev Validates the execution mode and returns the returndata.\n    function _validateExecutionMode(\n        uint256 index,\n        ExecType execType,\n        bool success,\n        bytes memory returndata\n    ) private returns (bytes memory) {\n        if (execType == ERC7579Utils.EXECTYPE_DEFAULT) {\n            Address.verifyCallResult(success, returndata);\n        } else if (execType == ERC7579Utils.EXECTYPE_TRY) {\n            if (!success) emit ERC7579TryExecuteFail(index, returndata);\n        } else {\n            revert ERC7579UnsupportedExecType(execType);\n        }\n        return returndata;\n    }\n}\n\n// Operators\nusing {eqCallType as ==} for CallType global;\nusing {eqExecType as ==} for ExecType global;\nusing {eqModeSelector as ==} for ModeSelector global;\nusing {eqModePayload as ==} for ModePayload global;\n\n/// @dev Compares two `CallType` values for equality.\nfunction eqCallType(CallType a, CallType b) pure returns (bool) {\n    return CallType.unwrap(a) == CallType.unwrap(b);\n}\n\n/// @dev Compares two `ExecType` values for equality.\nfunction eqExecType(ExecType a, ExecType b) pure returns (bool) {\n    return ExecType.unwrap(a) == ExecType.unwrap(b);\n}\n\n/// @dev Compares two `ModeSelector` values for equality.\nfunction eqModeSelector(ModeSelector a, ModeSelector b) pure returns (bool) {\n    return ModeSelector.unwrap(a) == ModeSelector.unwrap(b);\n}\n\n/// @dev Compares two `ModePayload` values for equality.\nfunction eqModePayload(ModePayload a, ModePayload b) pure returns (bool) {\n    return ModePayload.unwrap(a) == ModePayload.unwrap(b);\n}\n"},{"file_path":"node_modules/@openzeppelin/contracts/interfaces/IERC1271.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.1.0) (interfaces/IERC1271.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Interface of the ERC-1271 standard signature validation method for\n * contracts as defined in https://eips.ethereum.org/EIPS/eip-1271[ERC-1271].\n */\ninterface IERC1271 {\n    /**\n     * @dev Should return whether the signature provided is valid for the provided data\n     * @param hash      Hash of the data to be signed\n     * @param signature Signature byte array associated with _data\n     */\n    function isValidSignature(bytes32 hash, bytes memory signature) external view returns (bytes4 magicValue);\n}\n"},{"file_path":"node_modules/@openzeppelin/contracts/interfaces/IERC5267.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC5267.sol)\n\npragma solidity ^0.8.20;\n\ninterface IERC5267 {\n    /**\n     * @dev MAY be emitted to signal that the domain could have changed.\n     */\n    event EIP712DomainChanged();\n\n    /**\n     * @dev returns the fields and values that describe the domain separator used by this contract for EIP-712\n     * signature.\n     */\n    function eip712Domain()\n        external\n        view\n        returns (\n            bytes1 fields,\n            string memory name,\n            string memory version,\n            uint256 chainId,\n            address verifyingContract,\n            bytes32 salt,\n            uint256[] memory extensions\n        );\n}\n"},{"file_path":"node_modules/@openzeppelin/contracts/interfaces/draft-IERC4337.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.2.0) (interfaces/draft-IERC4337.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev A https://github.com/ethereum/ercs/blob/master/ERCS/erc-4337.md#useroperation[user operation] is composed of the following elements:\n * - `sender` (`address`): The account making the operation\n * - `nonce` (`uint256`): Anti-replay parameter (see “Semi-abstracted Nonce Support” )\n * - `factory` (`address`): account factory, only for new accounts\n * - `factoryData` (`bytes`): data for account factory (only if account factory exists)\n * - `callData` (`bytes`): The data to pass to the sender during the main execution call\n * - `callGasLimit` (`uint256`): The amount of gas to allocate the main execution call\n * - `verificationGasLimit` (`uint256`): The amount of gas to allocate for the verification step\n * - `preVerificationGas` (`uint256`): Extra gas to pay the bundler\n * - `maxFeePerGas` (`uint256`): Maximum fee per gas (similar to EIP-1559 max_fee_per_gas)\n * - `maxPriorityFeePerGas` (`uint256`): Maximum priority fee per gas (similar to EIP-1559 max_priority_fee_per_gas)\n * - `paymaster` (`address`): Address of paymaster contract, (or empty, if account pays for itself)\n * - `paymasterVerificationGasLimit` (`uint256`): The amount of gas to allocate for the paymaster validation code\n * - `paymasterPostOpGasLimit` (`uint256`): The amount of gas to allocate for the paymaster post-operation code\n * - `paymasterData` (`bytes`): Data for paymaster (only if paymaster exists)\n * - `signature` (`bytes`): Data passed into the account to verify authorization\n *\n * When passed to on-chain contacts, the following packed version is used.\n * - `sender` (`address`)\n * - `nonce` (`uint256`)\n * - `initCode` (`bytes`): concatenation of factory address and factoryData (or empty)\n * - `callData` (`bytes`)\n * - `accountGasLimits` (`bytes32`): concatenation of verificationGas (16 bytes) and callGas (16 bytes)\n * - `preVerificationGas` (`uint256`)\n * - `gasFees` (`bytes32`): concatenation of maxPriorityFeePerGas (16 bytes) and maxFeePerGas (16 bytes)\n * - `paymasterAndData` (`bytes`): concatenation of paymaster fields (or empty)\n * - `signature` (`bytes`)\n */\nstruct PackedUserOperation {\n    address sender;\n    uint256 nonce;\n    bytes initCode; // `abi.encodePacked(factory, factoryData)`\n    bytes callData;\n    bytes32 accountGasLimits; // `abi.encodePacked(verificationGasLimit, callGasLimit)` 16 bytes each\n    uint256 preVerificationGas;\n    bytes32 gasFees; // `abi.encodePacked(maxPriorityFeePerGas, maxFeePerGas)` 16 bytes each\n    bytes paymasterAndData; // `abi.encodePacked(paymaster, paymasterVerificationGasLimit, paymasterPostOpGasLimit, paymasterData)` (20 bytes, 16 bytes, 16 bytes, dynamic)\n    bytes signature;\n}\n\n/**\n * @dev Aggregates and validates multiple signatures for a batch of user operations.\n *\n * A contract could implement this interface with custom validation schemes that allow signature aggregation,\n * enabling significant optimizations and gas savings for execution and transaction data cost.\n *\n * Bundlers and clients whitelist supported aggregators.\n *\n * See https://eips.ethereum.org/EIPS/eip-7766[ERC-7766]\n */\ninterface IAggregator {\n    /**\n     * @dev Validates the signature for a user operation.\n     * Returns an alternative signature that should be used during bundling.\n     */\n    function validateUserOpSignature(\n        PackedUserOperation calldata userOp\n    ) external view returns (bytes memory sigForUserOp);\n\n    /**\n     * @dev Returns an aggregated signature for a batch of user operation's signatures.\n     */\n    function aggregateSignatures(\n        PackedUserOperation[] calldata userOps\n    ) external view returns (bytes memory aggregatesSignature);\n\n    /**\n     * @dev Validates that the aggregated signature is valid for the user operations.\n     *\n     * Requirements:\n     *\n     * - The aggregated signature MUST match the given list of operations.\n     */\n    function validateSignatures(PackedUserOperation[] calldata userOps, bytes calldata signature) external view;\n}\n\n/**\n * @dev Handle nonce management for accounts.\n *\n * Nonces are used in accounts as a replay protection mechanism and to ensure the order of user operations.\n * To avoid limiting the number of operations an account can perform, the interface allows using parallel\n * nonces by using a `key` parameter.\n *\n * See https://eips.ethereum.org/EIPS/eip-4337#semi-abstracted-nonce-support[ERC-4337 semi-abstracted nonce support].\n */\ninterface IEntryPointNonces {\n    /**\n     * @dev Returns the nonce for a `sender` account and a `key`.\n     *\n     * Nonces for a certain `key` are always increasing.\n     */\n    function getNonce(address sender, uint192 key) external view returns (uint256 nonce);\n}\n\n/**\n * @dev Handle stake management for entities (i.e. accounts, paymasters, factories).\n *\n * The EntryPoint must implement the following API to let entities like paymasters have a stake,\n * and thus have more flexibility in their storage access\n * (see https://eips.ethereum.org/EIPS/eip-4337#reputation-scoring-and-throttlingbanning-for-global-entities[reputation, throttling and banning.])\n */\ninterface IEntryPointStake {\n    /**\n     * @dev Returns the balance of the account.\n     */\n    function balanceOf(address account) external view returns (uint256);\n\n    /**\n     * @dev Deposits `msg.value` to the account.\n     */\n    function depositTo(address account) external payable;\n\n    /**\n     * @dev Withdraws `withdrawAmount` from the account to `withdrawAddress`.\n     */\n    function withdrawTo(address payable withdrawAddress, uint256 withdrawAmount) external;\n\n    /**\n     * @dev Adds stake to the account with an unstake delay of `unstakeDelaySec`.\n     */\n    function addStake(uint32 unstakeDelaySec) external payable;\n\n    /**\n     * @dev Unlocks the stake of the account.\n     */\n    function unlockStake() external;\n\n    /**\n     * @dev Withdraws the stake of the account to `withdrawAddress`.\n     */\n    function withdrawStake(address payable withdrawAddress) external;\n}\n\n/**\n * @dev Entry point for user operations.\n *\n * User operations are validated and executed by this contract.\n */\ninterface IEntryPoint is IEntryPointNonces, IEntryPointStake {\n    /**\n     * @dev A user operation at `opIndex` failed with `reason`.\n     */\n    error FailedOp(uint256 opIndex, string reason);\n\n    /**\n     * @dev A user operation at `opIndex` failed with `reason` and `inner` returned data.\n     */\n    error FailedOpWithRevert(uint256 opIndex, string reason, bytes inner);\n\n    /**\n     * @dev Batch of aggregated user operations per aggregator.\n     */\n    struct UserOpsPerAggregator {\n        PackedUserOperation[] userOps;\n        IAggregator aggregator;\n        bytes signature;\n    }\n\n    /**\n     * @dev Executes a batch of user operations.\n     * @param beneficiary Address to which gas is refunded up completing the execution.\n     */\n    function handleOps(PackedUserOperation[] calldata ops, address payable beneficiary) external;\n\n    /**\n     * @dev Executes a batch of aggregated user operations per aggregator.\n     * @param beneficiary Address to which gas is refunded up completing the execution.\n     */\n    function handleAggregatedOps(\n        UserOpsPerAggregator[] calldata opsPerAggregator,\n        address payable beneficiary\n    ) external;\n}\n\n/**\n * @dev Base interface for an ERC-4337 account.\n */\ninterface IAccount {\n    /**\n     * @dev Validates a user operation.\n     *\n     * * MUST validate the caller is a trusted EntryPoint\n     * * MUST validate that the signature is a valid signature of the userOpHash, and SHOULD\n     *   return SIG_VALIDATION_FAILED (and not revert) on signature mismatch. Any other error MUST revert.\n     * * MUST pay the entryPoint (caller) at least the “missingAccountFunds” (which might\n     *   be zero, in case the current account’s deposit is high enough)\n     *\n     * Returns an encoded packed validation data that is composed of the following elements:\n     *\n     * - `authorizer` (`address`): 0 for success, 1 for failure, otherwise the address of an authorizer contract\n     * - `validUntil` (`uint48`): The UserOp is valid only up to this time. Zero for “infinite”.\n     * - `validAfter` (`uint48`): The UserOp is valid only after this time.\n     */\n    function validateUserOp(\n        PackedUserOperation calldata userOp,\n        bytes32 userOpHash,\n        uint256 missingAccountFunds\n    ) external returns (uint256 validationData);\n}\n\n/**\n * @dev Support for executing user operations by prepending the {executeUserOp} function selector\n * to the UserOperation's `callData`.\n */\ninterface IAccountExecute {\n    /**\n     * @dev Executes a user operation.\n     */\n    function executeUserOp(PackedUserOperation calldata userOp, bytes32 userOpHash) external;\n}\n\n/**\n * @dev Interface for a paymaster contract that agrees to pay for the gas costs of a user operation.\n *\n * NOTE: A paymaster must hold a stake to cover the required entrypoint stake and also the gas for the transaction.\n */\ninterface IPaymaster {\n    enum PostOpMode {\n        opSucceeded,\n        opReverted,\n        postOpReverted\n    }\n\n    /**\n     * @dev Validates whether the paymaster is willing to pay for the user operation. See\n     * {IAccount-validateUserOp} for additional information on the return value.\n     *\n     * NOTE: Bundlers will reject this method if it modifies the state, unless it's whitelisted.\n     */\n    function validatePaymasterUserOp(\n        PackedUserOperation calldata userOp,\n        bytes32 userOpHash,\n        uint256 maxCost\n    ) external returns (bytes memory context, uint256 validationData);\n\n    /**\n     * @dev Verifies the sender is the entrypoint.\n     * @param actualGasCost the actual amount paid (by account or paymaster) for this UserOperation\n     * @param actualUserOpFeePerGas total gas used by this UserOperation (including preVerification, creation, validation and execution)\n     */\n    function postOp(\n        PostOpMode mode,\n        bytes calldata context,\n        uint256 actualGasCost,\n        uint256 actualUserOpFeePerGas\n    ) external;\n}\n"},{"file_path":"node_modules/@openzeppelin/contracts/interfaces/draft-IERC7579.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.2.0) (interfaces/draft-IERC7579.sol)\npragma solidity ^0.8.20;\n\nimport {PackedUserOperation} from \"./draft-IERC4337.sol\";\n\nuint256 constant VALIDATION_SUCCESS = 0;\nuint256 constant VALIDATION_FAILED = 1;\nuint256 constant MODULE_TYPE_VALIDATOR = 1;\nuint256 constant MODULE_TYPE_EXECUTOR = 2;\nuint256 constant MODULE_TYPE_FALLBACK = 3;\nuint256 constant MODULE_TYPE_HOOK = 4;\n\n/// @dev Minimal configuration interface for ERC-7579 modules\ninterface IERC7579Module {\n    /**\n     * @dev This function is called by the smart account during installation of the module\n     * @param data arbitrary data that may be required on the module during `onInstall` initialization\n     *\n     * MUST revert on error (e.g. if module is already enabled)\n     */\n    function onInstall(bytes calldata data) external;\n\n    /**\n     * @dev This function is called by the smart account during uninstallation of the module\n     * @param data arbitrary data that may be required on the module during `onUninstall` de-initialization\n     *\n     * MUST revert on error\n     */\n    function onUninstall(bytes calldata data) external;\n\n    /**\n     * @dev Returns boolean value if module is a certain type\n     * @param moduleTypeId the module type ID according the ERC-7579 spec\n     *\n     * MUST return true if the module is of the given type and false otherwise\n     */\n    function isModuleType(uint256 moduleTypeId) external view returns (bool);\n}\n\n/**\n * @dev ERC-7579 Validation module (type 1).\n *\n * A module that implements logic to validate user operations and signatures.\n */\ninterface IERC7579Validator is IERC7579Module {\n    /**\n     * @dev Validates a UserOperation\n     * @param userOp the ERC-4337 PackedUserOperation\n     * @param userOpHash the hash of the ERC-4337 PackedUserOperation\n     *\n     * MUST validate that the signature is a valid signature of the userOpHash\n     * SHOULD return ERC-4337's SIG_VALIDATION_FAILED (and not revert) on signature mismatch\n     * See {IAccount-validateUserOp} for additional information on the return value\n     */\n    function validateUserOp(PackedUserOperation calldata userOp, bytes32 userOpHash) external returns (uint256);\n\n    /**\n     * @dev Validates a signature using ERC-1271\n     * @param sender the address that sent the ERC-1271 request to the smart account\n     * @param hash the hash of the ERC-1271 request\n     * @param signature the signature of the ERC-1271 request\n     *\n     * MUST return the ERC-1271 `MAGIC_VALUE` if the signature is valid\n     * MUST NOT modify state\n     */\n    function isValidSignatureWithSender(\n        address sender,\n        bytes32 hash,\n        bytes calldata signature\n    ) external view returns (bytes4);\n}\n\n/**\n * @dev ERC-7579 Hooks module (type 4).\n *\n * A module that implements logic to execute before and after the account executes a user operation,\n * either individually or batched.\n */\ninterface IERC7579Hook is IERC7579Module {\n    /**\n     * @dev Called by the smart account before execution\n     * @param msgSender the address that called the smart account\n     * @param value the value that was sent to the smart account\n     * @param msgData the data that was sent to the smart account\n     *\n     * MAY return arbitrary data in the `hookData` return value\n     */\n    function preCheck(\n        address msgSender,\n        uint256 value,\n        bytes calldata msgData\n    ) external returns (bytes memory hookData);\n\n    /**\n     * @dev Called by the smart account after execution\n     * @param hookData the data that was returned by the `preCheck` function\n     *\n     * MAY validate the `hookData` to validate transaction context of the `preCheck` function\n     */\n    function postCheck(bytes calldata hookData) external;\n}\n\nstruct Execution {\n    address target;\n    uint256 value;\n    bytes callData;\n}\n\n/**\n * @dev ERC-7579 Execution.\n *\n * Accounts should implement this interface so that the Entrypoint and ERC-7579 modules can execute operations.\n */\ninterface IERC7579Execution {\n    /**\n     * @dev Executes a transaction on behalf of the account.\n     * @param mode The encoded execution mode of the transaction. See ModeLib.sol for details\n     * @param executionCalldata The encoded execution call data\n     *\n     * MUST ensure adequate authorization control: e.g. onlyEntryPointOrSelf if used with ERC-4337\n     * If a mode is requested that is not supported by the Account, it MUST revert\n     */\n    function execute(bytes32 mode, bytes calldata executionCalldata) external payable;\n\n    /**\n     * @dev Executes a transaction on behalf of the account.\n     *         This function is intended to be called by Executor Modules\n     * @param mode The encoded execution mode of the transaction. See ModeLib.sol for details\n     * @param executionCalldata The encoded execution call data\n     * @return returnData An array with the returned data of each executed subcall\n     *\n     * MUST ensure adequate authorization control: i.e. onlyExecutorModule\n     * If a mode is requested that is not supported by the Account, it MUST revert\n     */\n    function executeFromExecutor(\n        bytes32 mode,\n        bytes calldata executionCalldata\n    ) external payable returns (bytes[] memory returnData);\n}\n\n/**\n * @dev ERC-7579 Account Config.\n *\n * Accounts should implement this interface to expose information that identifies the account, supported modules and capabilities.\n */\ninterface IERC7579AccountConfig {\n    /**\n     * @dev Returns the account id of the smart account\n     * @return accountImplementationId the account id of the smart account\n     *\n     * MUST return a non-empty string\n     * The accountId SHOULD be structured like so:\n     *        \"vendorname.accountname.semver\"\n     * The id SHOULD be unique across all smart accounts\n     */\n    function accountId() external view returns (string memory accountImplementationId);\n\n    /**\n     * @dev Function to check if the account supports a certain execution mode (see above)\n     * @param encodedMode the encoded mode\n     *\n     * MUST return true if the account supports the mode and false otherwise\n     */\n    function supportsExecutionMode(bytes32 encodedMode) external view returns (bool);\n\n    /**\n     * @dev Function to check if the account supports a certain module typeId\n     * @param moduleTypeId the module type ID according to the ERC-7579 spec\n     *\n     * MUST return true if the account supports the module type and false otherwise\n     */\n    function supportsModule(uint256 moduleTypeId) external view returns (bool);\n}\n\n/**\n * @dev ERC-7579 Module Config.\n *\n * Accounts should implement this interface to allow installing and uninstalling modules.\n */\ninterface IERC7579ModuleConfig {\n    event ModuleInstalled(uint256 moduleTypeId, address module);\n    event ModuleUninstalled(uint256 moduleTypeId, address module);\n\n    /**\n     * @dev Installs a Module of a certain type on the smart account\n     * @param moduleTypeId the module type ID according to the ERC-7579 spec\n     * @param module the module address\n     * @param initData arbitrary data that may be required on the module during `onInstall`\n     * initialization.\n     *\n     * MUST implement authorization control\n     * MUST call `onInstall` on the module with the `initData` parameter if provided\n     * MUST emit ModuleInstalled event\n     * MUST revert if the module is already installed or the initialization on the module failed\n     */\n    function installModule(uint256 moduleTypeId, address module, bytes calldata initData) external;\n\n    /**\n     * @dev Uninstalls a Module of a certain type on the smart account\n     * @param moduleTypeId the module type ID according the ERC-7579 spec\n     * @param module the module address\n     * @param deInitData arbitrary data that may be required on the module during `onInstall`\n     * initialization.\n     *\n     * MUST implement authorization control\n     * MUST call `onUninstall` on the module with the `deInitData` parameter if provided\n     * MUST emit ModuleUninstalled event\n     * MUST revert if the module is not installed or the deInitialization on the module failed\n     */\n    function uninstallModule(uint256 moduleTypeId, address module, bytes calldata deInitData) external;\n\n    /**\n     * @dev Returns whether a module is installed on the smart account\n     * @param moduleTypeId the module type ID according the ERC-7579 spec\n     * @param module the module address\n     * @param additionalContext arbitrary data that may be required to determine if the module is installed\n     *\n     * MUST return true if the module is installed and false otherwise\n     */\n    function isModuleInstalled(\n        uint256 moduleTypeId,\n        address module,\n        bytes calldata additionalContext\n    ) external view returns (bool);\n}\n"},{"file_path":"node_modules/@openzeppelin/contracts/token/ERC1155/IERC1155Receiver.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC1155/IERC1155Receiver.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC165} from \"../../utils/introspection/IERC165.sol\";\n\n/**\n * @dev Interface that must be implemented by smart contracts in order to receive\n * ERC-1155 token transfers.\n */\ninterface IERC1155Receiver is IERC165 {\n    /**\n     * @dev Handles the receipt of a single ERC-1155 token type. This function is\n     * called at the end of a `safeTransferFrom` after the balance has been updated.\n     *\n     * NOTE: To accept the transfer, this must return\n     * `bytes4(keccak256(\"onERC1155Received(address,address,uint256,uint256,bytes)\"))`\n     * (i.e. 0xf23a6e61, or its own function selector).\n     *\n     * @param operator The address which initiated the transfer (i.e. msg.sender)\n     * @param from The address which previously owned the token\n     * @param id The ID of the token being transferred\n     * @param value The amount of tokens being transferred\n     * @param data Additional data with no specified format\n     * @return `bytes4(keccak256(\"onERC1155Received(address,address,uint256,uint256,bytes)\"))` if transfer is allowed\n     */\n    function onERC1155Received(\n        address operator,\n        address from,\n        uint256 id,\n        uint256 value,\n        bytes calldata data\n    ) external returns (bytes4);\n\n    /**\n     * @dev Handles the receipt of a multiple ERC-1155 token types. This function\n     * is called at the end of a `safeBatchTransferFrom` after the balances have\n     * been updated.\n     *\n     * NOTE: To accept the transfer(s), this must return\n     * `bytes4(keccak256(\"onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)\"))`\n     * (i.e. 0xbc197c81, or its own function selector).\n     *\n     * @param operator The address which initiated the batch transfer (i.e. msg.sender)\n     * @param from The address which previously owned the token\n     * @param ids An array containing ids of each token being transferred (order and length must match values array)\n     * @param values An array containing amounts of each token being transferred (order and length must match ids array)\n     * @param data Additional data with no specified format\n     * @return `bytes4(keccak256(\"onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)\"))` if transfer is allowed\n     */\n    function onERC1155BatchReceived(\n        address operator,\n        address from,\n        uint256[] calldata ids,\n        uint256[] calldata values,\n        bytes calldata data\n    ) external returns (bytes4);\n}\n"},{"file_path":"node_modules/@openzeppelin/contracts/token/ERC1155/utils/ERC1155Holder.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC1155/utils/ERC1155Holder.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC165, ERC165} from \"../../../utils/introspection/ERC165.sol\";\nimport {IERC1155Receiver} from \"../IERC1155Receiver.sol\";\n\n/**\n * @dev Simple implementation of `IERC1155Receiver` that will allow a contract to hold ERC-1155 tokens.\n *\n * IMPORTANT: When inheriting this contract, you must include a way to use the received tokens, otherwise they will be\n * stuck.\n */\nabstract contract ERC1155Holder is ERC165, IERC1155Receiver {\n    /**\n     * @dev See {IERC165-supportsInterface}.\n     */\n    function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {\n        return interfaceId == type(IERC1155Receiver).interfaceId || super.supportsInterface(interfaceId);\n    }\n\n    function onERC1155Received(\n        address,\n        address,\n        uint256,\n        uint256,\n        bytes memory\n    ) public virtual override returns (bytes4) {\n        return this.onERC1155Received.selector;\n    }\n\n    function onERC1155BatchReceived(\n        address,\n        address,\n        uint256[] memory,\n        uint256[] memory,\n        bytes memory\n    ) public virtual override returns (bytes4) {\n        return this.onERC1155BatchReceived.selector;\n    }\n}\n"},{"file_path":"node_modules/@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC721/IERC721Receiver.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @title ERC-721 token receiver interface\n * @dev Interface for any contract that wants to support safeTransfers\n * from ERC-721 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"},{"file_path":"node_modules/@openzeppelin/contracts/token/ERC721/utils/ERC721Holder.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/utils/ERC721Holder.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC721Receiver} from \"../IERC721Receiver.sol\";\n\n/**\n * @dev Implementation of the {IERC721Receiver} interface.\n *\n * Accepts all token transfers.\n * Make sure the contract is able to use its token with {IERC721-safeTransferFrom}, {IERC721-approve} or\n * {IERC721-setApprovalForAll}.\n */\nabstract contract ERC721Holder is IERC721Receiver {\n    /**\n     * @dev See {IERC721Receiver-onERC721Received}.\n     *\n     * Always returns `IERC721Receiver.onERC721Received.selector`.\n     */\n    function onERC721Received(address, address, uint256, bytes memory) public virtual returns (bytes4) {\n        return this.onERC721Received.selector;\n    }\n}\n"},{"file_path":"node_modules/@openzeppelin/contracts/utils/Address.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.2.0) (utils/Address.sol)\n\npragma solidity ^0.8.20;\n\nimport {Errors} from \"./Errors.sol\";\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n    /**\n     * @dev There's no code at `target` (it is not a contract).\n     */\n    error AddressEmptyCode(address target);\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 Errors.InsufficientBalance(address(this).balance, amount);\n        }\n\n        (bool success, bytes memory returndata) = recipient.call{value: amount}(\"\");\n        if (!success) {\n            _revert(returndata);\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     * {Errors.FailedCall} 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 Errors.InsufficientBalance(address(this).balance, value);\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 {Errors.FailedCall}) in case\n     * of an 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 {Errors.FailedCall} 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 {Errors.FailedCall}.\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            assembly (\"memory-safe\") {\n                let returndata_size := mload(returndata)\n                revert(add(32, returndata), returndata_size)\n            }\n        } else {\n            revert Errors.FailedCall();\n        }\n    }\n}\n"},{"file_path":"node_modules/@openzeppelin/contracts/utils/Errors.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.1.0) (utils/Errors.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Collection of common custom errors used in multiple contracts\n *\n * IMPORTANT: Backwards compatibility is not guaranteed in future versions of the library.\n * It is recommended to avoid relying on the error API for critical functionality.\n *\n * _Available since v5.1._\n */\nlibrary Errors {\n    /**\n     * @dev The ETH balance of the account is not enough to perform the operation.\n     */\n    error InsufficientBalance(uint256 balance, uint256 needed);\n\n    /**\n     * @dev A call to an address target failed. The target may have reverted.\n     */\n    error FailedCall();\n\n    /**\n     * @dev The deployment failed.\n     */\n    error FailedDeployment();\n\n    /**\n     * @dev A necessary precompile is missing.\n     */\n    error MissingPrecompile(address);\n}\n"},{"file_path":"node_modules/@openzeppelin/contracts/utils/Packing.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.2.0) (utils/Packing.sol)\n// This file was procedurally generated from scripts/generate/templates/Packing.js.\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Helper library packing and unpacking multiple values into bytesXX.\n *\n * Example usage:\n *\n * ```solidity\n * library MyPacker {\n *     type MyType is bytes32;\n *\n *     function _pack(address account, bytes4 selector, uint64 period) external pure returns (MyType) {\n *         bytes12 subpack = Packing.pack_4_8(selector, bytes8(period));\n *         bytes32 pack = Packing.pack_20_12(bytes20(account), subpack);\n *         return MyType.wrap(pack);\n *     }\n *\n *     function _unpack(MyType self) external pure returns (address, bytes4, uint64) {\n *         bytes32 pack = MyType.unwrap(self);\n *         return (\n *             address(Packing.extract_32_20(pack, 0)),\n *             Packing.extract_32_4(pack, 20),\n *             uint64(Packing.extract_32_8(pack, 24))\n *         );\n *     }\n * }\n * ```\n *\n * _Available since v5.1._\n */\n// solhint-disable func-name-mixedcase\nlibrary Packing {\n    error OutOfRangeAccess();\n\n    function pack_1_1(bytes1 left, bytes1 right) internal pure returns (bytes2 result) {\n        assembly (\"memory-safe\") {\n            left := and(left, shl(248, not(0)))\n            right := and(right, shl(248, not(0)))\n            result := or(left, shr(8, right))\n        }\n    }\n\n    function pack_2_2(bytes2 left, bytes2 right) internal pure returns (bytes4 result) {\n        assembly (\"memory-safe\") {\n            left := and(left, shl(240, not(0)))\n            right := and(right, shl(240, not(0)))\n            result := or(left, shr(16, right))\n        }\n    }\n\n    function pack_2_4(bytes2 left, bytes4 right) internal pure returns (bytes6 result) {\n        assembly (\"memory-safe\") {\n            left := and(left, shl(240, not(0)))\n            right := and(right, shl(224, not(0)))\n            result := or(left, shr(16, right))\n        }\n    }\n\n    function pack_2_6(bytes2 left, bytes6 right) internal pure returns (bytes8 result) {\n        assembly (\"memory-safe\") {\n            left := and(left, shl(240, not(0)))\n            right := and(right, shl(208, not(0)))\n            result := or(left, shr(16, right))\n        }\n    }\n\n    function pack_2_8(bytes2 left, bytes8 right) internal pure returns (bytes10 result) {\n        assembly (\"memory-safe\") {\n            left := and(left, shl(240, not(0)))\n            right := and(right, shl(192, not(0)))\n            result := or(left, shr(16, right))\n        }\n    }\n\n    function pack_2_10(bytes2 left, bytes10 right) internal pure returns (bytes12 result) {\n        assembly (\"memory-safe\") {\n            left := and(left, shl(240, not(0)))\n            right := and(right, shl(176, not(0)))\n            result := or(left, shr(16, right))\n        }\n    }\n\n    function pack_2_20(bytes2 left, bytes20 right) internal pure returns (bytes22 result) {\n        assembly (\"memory-safe\") {\n            left := and(left, shl(240, not(0)))\n            right := and(right, shl(96, not(0)))\n            result := or(left, shr(16, right))\n        }\n    }\n\n    function pack_2_22(bytes2 left, bytes22 right) internal pure returns (bytes24 result) {\n        assembly (\"memory-safe\") {\n            left := and(left, shl(240, not(0)))\n            right := and(right, shl(80, not(0)))\n            result := or(left, shr(16, right))\n        }\n    }\n\n    function pack_4_2(bytes4 left, bytes2 right) internal pure returns (bytes6 result) {\n        assembly (\"memory-safe\") {\n            left := and(left, shl(224, not(0)))\n            right := and(right, shl(240, not(0)))\n            result := or(left, shr(32, right))\n        }\n    }\n\n    function pack_4_4(bytes4 left, bytes4 right) internal pure returns (bytes8 result) {\n        assembly (\"memory-safe\") {\n            left := and(left, shl(224, not(0)))\n            right := and(right, shl(224, not(0)))\n            result := or(left, shr(32, right))\n        }\n    }\n\n    function pack_4_6(bytes4 left, bytes6 right) internal pure returns (bytes10 result) {\n        assembly (\"memory-safe\") {\n            left := and(left, shl(224, not(0)))\n            right := and(right, shl(208, not(0)))\n            result := or(left, shr(32, right))\n        }\n    }\n\n    function pack_4_8(bytes4 left, bytes8 right) internal pure returns (bytes12 result) {\n        assembly (\"memory-safe\") {\n            left := and(left, shl(224, not(0)))\n            right := and(right, shl(192, not(0)))\n            result := or(left, shr(32, right))\n        }\n    }\n\n    function pack_4_12(bytes4 left, bytes12 right) internal pure returns (bytes16 result) {\n        assembly (\"memory-safe\") {\n            left := and(left, shl(224, not(0)))\n            right := and(right, shl(160, not(0)))\n            result := or(left, shr(32, right))\n        }\n    }\n\n    function pack_4_16(bytes4 left, bytes16 right) internal pure returns (bytes20 result) {\n        assembly (\"memory-safe\") {\n            left := and(left, shl(224, not(0)))\n            right := and(right, shl(128, not(0)))\n            result := or(left, shr(32, right))\n        }\n    }\n\n    function pack_4_20(bytes4 left, bytes20 right) internal pure returns (bytes24 result) {\n        assembly (\"memory-safe\") {\n            left := and(left, shl(224, not(0)))\n            right := and(right, shl(96, not(0)))\n            result := or(left, shr(32, right))\n        }\n    }\n\n    function pack_4_24(bytes4 left, bytes24 right) internal pure returns (bytes28 result) {\n        assembly (\"memory-safe\") {\n            left := and(left, shl(224, not(0)))\n            right := and(right, shl(64, not(0)))\n            result := or(left, shr(32, right))\n        }\n    }\n\n    function pack_4_28(bytes4 left, bytes28 right) internal pure returns (bytes32 result) {\n        assembly (\"memory-safe\") {\n            left := and(left, shl(224, not(0)))\n            right := and(right, shl(32, not(0)))\n            result := or(left, shr(32, right))\n        }\n    }\n\n    function pack_6_2(bytes6 left, bytes2 right) internal pure returns (bytes8 result) {\n        assembly (\"memory-safe\") {\n            left := and(left, shl(208, not(0)))\n            right := and(right, shl(240, not(0)))\n            result := or(left, shr(48, right))\n        }\n    }\n\n    function pack_6_4(bytes6 left, bytes4 right) internal pure returns (bytes10 result) {\n        assembly (\"memory-safe\") {\n            left := and(left, shl(208, not(0)))\n            right := and(right, shl(224, not(0)))\n            result := or(left, shr(48, right))\n        }\n    }\n\n    function pack_6_6(bytes6 left, bytes6 right) internal pure returns (bytes12 result) {\n        assembly (\"memory-safe\") {\n            left := and(left, shl(208, not(0)))\n            right := and(right, shl(208, not(0)))\n            result := or(left, shr(48, right))\n        }\n    }\n\n    function pack_6_10(bytes6 left, bytes10 right) internal pure returns (bytes16 result) {\n        assembly (\"memory-safe\") {\n            left := and(left, shl(208, not(0)))\n            right := and(right, shl(176, not(0)))\n            result := or(left, shr(48, right))\n        }\n    }\n\n    function pack_6_16(bytes6 left, bytes16 right) internal pure returns (bytes22 result) {\n        assembly (\"memory-safe\") {\n            left := and(left, shl(208, not(0)))\n            right := and(right, shl(128, not(0)))\n            result := or(left, shr(48, right))\n        }\n    }\n\n    function pack_6_22(bytes6 left, bytes22 right) internal pure returns (bytes28 result) {\n        assembly (\"memory-safe\") {\n            left := and(left, shl(208, not(0)))\n            right := and(right, shl(80, not(0)))\n            result := or(left, shr(48, right))\n        }\n    }\n\n    function pack_8_2(bytes8 left, bytes2 right) internal pure returns (bytes10 result) {\n        assembly (\"memory-safe\") {\n            left := and(left, shl(192, not(0)))\n            right := and(right, shl(240, not(0)))\n            result := or(left, shr(64, right))\n        }\n    }\n\n    function pack_8_4(bytes8 left, bytes4 right) internal pure returns (bytes12 result) {\n        assembly (\"memory-safe\") {\n            left := and(left, shl(192, not(0)))\n            right := and(right, shl(224, not(0)))\n            result := or(left, shr(64, right))\n        }\n    }\n\n    function pack_8_8(bytes8 left, bytes8 right) internal pure returns (bytes16 result) {\n        assembly (\"memory-safe\") {\n            left := and(left, shl(192, not(0)))\n            right := and(right, shl(192, not(0)))\n            result := or(left, shr(64, right))\n        }\n    }\n\n    function pack_8_12(bytes8 left, bytes12 right) internal pure returns (bytes20 result) {\n        assembly (\"memory-safe\") {\n            left := and(left, shl(192, not(0)))\n            right := and(right, shl(160, not(0)))\n            result := or(left, shr(64, right))\n        }\n    }\n\n    function pack_8_16(bytes8 left, bytes16 right) internal pure returns (bytes24 result) {\n        assembly (\"memory-safe\") {\n            left := and(left, shl(192, not(0)))\n            right := and(right, shl(128, not(0)))\n            result := or(left, shr(64, right))\n        }\n    }\n\n    function pack_8_20(bytes8 left, bytes20 right) internal pure returns (bytes28 result) {\n        assembly (\"memory-safe\") {\n            left := and(left, shl(192, not(0)))\n            right := and(right, shl(96, not(0)))\n            result := or(left, shr(64, right))\n        }\n    }\n\n    function pack_8_24(bytes8 left, bytes24 right) internal pure returns (bytes32 result) {\n        assembly (\"memory-safe\") {\n            left := and(left, shl(192, not(0)))\n            right := and(right, shl(64, not(0)))\n            result := or(left, shr(64, right))\n        }\n    }\n\n    function pack_10_2(bytes10 left, bytes2 right) internal pure returns (bytes12 result) {\n        assembly (\"memory-safe\") {\n            left := and(left, shl(176, not(0)))\n            right := and(right, shl(240, not(0)))\n            result := or(left, shr(80, right))\n        }\n    }\n\n    function pack_10_6(bytes10 left, bytes6 right) internal pure returns (bytes16 result) {\n        assembly (\"memory-safe\") {\n            left := and(left, shl(176, not(0)))\n            right := and(right, shl(208, not(0)))\n            result := or(left, shr(80, right))\n        }\n    }\n\n    function pack_10_10(bytes10 left, bytes10 right) internal pure returns (bytes20 result) {\n        assembly (\"memory-safe\") {\n            left := and(left, shl(176, not(0)))\n            right := and(right, shl(176, not(0)))\n            result := or(left, shr(80, right))\n        }\n    }\n\n    function pack_10_12(bytes10 left, bytes12 right) internal pure returns (bytes22 result) {\n        assembly (\"memory-safe\") {\n            left := and(left, shl(176, not(0)))\n            right := and(right, shl(160, not(0)))\n            result := or(left, shr(80, right))\n        }\n    }\n\n    function pack_10_22(bytes10 left, bytes22 right) internal pure returns (bytes32 result) {\n        assembly (\"memory-safe\") {\n            left := and(left, shl(176, not(0)))\n            right := and(right, shl(80, not(0)))\n            result := or(left, shr(80, right))\n        }\n    }\n\n    function pack_12_4(bytes12 left, bytes4 right) internal pure returns (bytes16 result) {\n        assembly (\"memory-safe\") {\n            left := and(left, shl(160, not(0)))\n            right := and(right, shl(224, not(0)))\n            result := or(left, shr(96, right))\n        }\n    }\n\n    function pack_12_8(bytes12 left, bytes8 right) internal pure returns (bytes20 result) {\n        assembly (\"memory-safe\") {\n            left := and(left, shl(160, not(0)))\n            right := and(right, shl(192, not(0)))\n            result := or(left, shr(96, right))\n        }\n    }\n\n    function pack_12_10(bytes12 left, bytes10 right) internal pure returns (bytes22 result) {\n        assembly (\"memory-safe\") {\n            left := and(left, shl(160, not(0)))\n            right := and(right, shl(176, not(0)))\n            result := or(left, shr(96, right))\n        }\n    }\n\n    function pack_12_12(bytes12 left, bytes12 right) internal pure returns (bytes24 result) {\n        assembly (\"memory-safe\") {\n            left := and(left, shl(160, not(0)))\n            right := and(right, shl(160, not(0)))\n            result := or(left, shr(96, right))\n        }\n    }\n\n    function pack_12_16(bytes12 left, bytes16 right) internal pure returns (bytes28 result) {\n        assembly (\"memory-safe\") {\n            left := and(left, shl(160, not(0)))\n            right := and(right, shl(128, not(0)))\n            result := or(left, shr(96, right))\n        }\n    }\n\n    function pack_12_20(bytes12 left, bytes20 right) internal pure returns (bytes32 result) {\n        assembly (\"memory-safe\") {\n            left := and(left, shl(160, not(0)))\n            right := and(right, shl(96, not(0)))\n            result := or(left, shr(96, right))\n        }\n    }\n\n    function pack_16_4(bytes16 left, bytes4 right) internal pure returns (bytes20 result) {\n        assembly (\"memory-safe\") {\n            left := and(left, shl(128, not(0)))\n            right := and(right, shl(224, not(0)))\n            result := or(left, shr(128, right))\n        }\n    }\n\n    function pack_16_6(bytes16 left, bytes6 right) internal pure returns (bytes22 result) {\n        assembly (\"memory-safe\") {\n            left := and(left, shl(128, not(0)))\n            right := and(right, shl(208, not(0)))\n            result := or(left, shr(128, right))\n        }\n    }\n\n    function pack_16_8(bytes16 left, bytes8 right) internal pure returns (bytes24 result) {\n        assembly (\"memory-safe\") {\n            left := and(left, shl(128, not(0)))\n            right := and(right, shl(192, not(0)))\n            result := or(left, shr(128, right))\n        }\n    }\n\n    function pack_16_12(bytes16 left, bytes12 right) internal pure returns (bytes28 result) {\n        assembly (\"memory-safe\") {\n            left := and(left, shl(128, not(0)))\n            right := and(right, shl(160, not(0)))\n            result := or(left, shr(128, right))\n        }\n    }\n\n    function pack_16_16(bytes16 left, bytes16 right) internal pure returns (bytes32 result) {\n        assembly (\"memory-safe\") {\n            left := and(left, shl(128, not(0)))\n            right := and(right, shl(128, not(0)))\n            result := or(left, shr(128, right))\n        }\n    }\n\n    function pack_20_2(bytes20 left, bytes2 right) internal pure returns (bytes22 result) {\n        assembly (\"memory-safe\") {\n            left := and(left, shl(96, not(0)))\n            right := and(right, shl(240, not(0)))\n            result := or(left, shr(160, right))\n        }\n    }\n\n    function pack_20_4(bytes20 left, bytes4 right) internal pure returns (bytes24 result) {\n        assembly (\"memory-safe\") {\n            left := and(left, shl(96, not(0)))\n            right := and(right, shl(224, not(0)))\n            result := or(left, shr(160, right))\n        }\n    }\n\n    function pack_20_8(bytes20 left, bytes8 right) internal pure returns (bytes28 result) {\n        assembly (\"memory-safe\") {\n            left := and(left, shl(96, not(0)))\n            right := and(right, shl(192, not(0)))\n            result := or(left, shr(160, right))\n        }\n    }\n\n    function pack_20_12(bytes20 left, bytes12 right) internal pure returns (bytes32 result) {\n        assembly (\"memory-safe\") {\n            left := and(left, shl(96, not(0)))\n            right := and(right, shl(160, not(0)))\n            result := or(left, shr(160, right))\n        }\n    }\n\n    function pack_22_2(bytes22 left, bytes2 right) internal pure returns (bytes24 result) {\n        assembly (\"memory-safe\") {\n            left := and(left, shl(80, not(0)))\n            right := and(right, shl(240, not(0)))\n            result := or(left, shr(176, right))\n        }\n    }\n\n    function pack_22_6(bytes22 left, bytes6 right) internal pure returns (bytes28 result) {\n        assembly (\"memory-safe\") {\n            left := and(left, shl(80, not(0)))\n            right := and(right, shl(208, not(0)))\n            result := or(left, shr(176, right))\n        }\n    }\n\n    function pack_22_10(bytes22 left, bytes10 right) internal pure returns (bytes32 result) {\n        assembly (\"memory-safe\") {\n            left := and(left, shl(80, not(0)))\n            right := and(right, shl(176, not(0)))\n            result := or(left, shr(176, right))\n        }\n    }\n\n    function pack_24_4(bytes24 left, bytes4 right) internal pure returns (bytes28 result) {\n        assembly (\"memory-safe\") {\n            left := and(left, shl(64, not(0)))\n            right := and(right, shl(224, not(0)))\n            result := or(left, shr(192, right))\n        }\n    }\n\n    function pack_24_8(bytes24 left, bytes8 right) internal pure returns (bytes32 result) {\n        assembly (\"memory-safe\") {\n            left := and(left, shl(64, not(0)))\n            right := and(right, shl(192, not(0)))\n            result := or(left, shr(192, right))\n        }\n    }\n\n    function pack_28_4(bytes28 left, bytes4 right) internal pure returns (bytes32 result) {\n        assembly (\"memory-safe\") {\n            left := and(left, shl(32, not(0)))\n            right := and(right, shl(224, not(0)))\n            result := or(left, shr(224, right))\n        }\n    }\n\n    function extract_2_1(bytes2 self, uint8 offset) internal pure returns (bytes1 result) {\n        if (offset > 1) revert OutOfRangeAccess();\n        assembly (\"memory-safe\") {\n            result := and(shl(mul(8, offset), self), shl(248, not(0)))\n        }\n    }\n\n    function replace_2_1(bytes2 self, bytes1 value, uint8 offset) internal pure returns (bytes2 result) {\n        bytes1 oldValue = extract_2_1(self, offset);\n        assembly (\"memory-safe\") {\n            value := and(value, shl(248, not(0)))\n            result := xor(self, shr(mul(8, offset), xor(oldValue, value)))\n        }\n    }\n\n    function extract_4_1(bytes4 self, uint8 offset) internal pure returns (bytes1 result) {\n        if (offset > 3) revert OutOfRangeAccess();\n        assembly (\"memory-safe\") {\n            result := and(shl(mul(8, offset), self), shl(248, not(0)))\n        }\n    }\n\n    function replace_4_1(bytes4 self, bytes1 value, uint8 offset) internal pure returns (bytes4 result) {\n        bytes1 oldValue = extract_4_1(self, offset);\n        assembly (\"memory-safe\") {\n            value := and(value, shl(248, not(0)))\n            result := xor(self, shr(mul(8, offset), xor(oldValue, value)))\n        }\n    }\n\n    function extract_4_2(bytes4 self, uint8 offset) internal pure returns (bytes2 result) {\n        if (offset > 2) revert OutOfRangeAccess();\n        assembly (\"memory-safe\") {\n            result := and(shl(mul(8, offset), self), shl(240, not(0)))\n        }\n    }\n\n    function replace_4_2(bytes4 self, bytes2 value, uint8 offset) internal pure returns (bytes4 result) {\n        bytes2 oldValue = extract_4_2(self, offset);\n        assembly (\"memory-safe\") {\n            value := and(value, shl(240, not(0)))\n            result := xor(self, shr(mul(8, offset), xor(oldValue, value)))\n        }\n    }\n\n    function extract_6_1(bytes6 self, uint8 offset) internal pure returns (bytes1 result) {\n        if (offset > 5) revert OutOfRangeAccess();\n        assembly (\"memory-safe\") {\n            result := and(shl(mul(8, offset), self), shl(248, not(0)))\n        }\n    }\n\n    function replace_6_1(bytes6 self, bytes1 value, uint8 offset) internal pure returns (bytes6 result) {\n        bytes1 oldValue = extract_6_1(self, offset);\n        assembly (\"memory-safe\") {\n            value := and(value, shl(248, not(0)))\n            result := xor(self, shr(mul(8, offset), xor(oldValue, value)))\n        }\n    }\n\n    function extract_6_2(bytes6 self, uint8 offset) internal pure returns (bytes2 result) {\n        if (offset > 4) revert OutOfRangeAccess();\n        assembly (\"memory-safe\") {\n            result := and(shl(mul(8, offset), self), shl(240, not(0)))\n        }\n    }\n\n    function replace_6_2(bytes6 self, bytes2 value, uint8 offset) internal pure returns (bytes6 result) {\n        bytes2 oldValue = extract_6_2(self, offset);\n        assembly (\"memory-safe\") {\n            value := and(value, shl(240, not(0)))\n            result := xor(self, shr(mul(8, offset), xor(oldValue, value)))\n        }\n    }\n\n    function extract_6_4(bytes6 self, uint8 offset) internal pure returns (bytes4 result) {\n        if (offset > 2) revert OutOfRangeAccess();\n        assembly (\"memory-safe\") {\n            result := and(shl(mul(8, offset), self), shl(224, not(0)))\n        }\n    }\n\n    function replace_6_4(bytes6 self, bytes4 value, uint8 offset) internal pure returns (bytes6 result) {\n        bytes4 oldValue = extract_6_4(self, offset);\n        assembly (\"memory-safe\") {\n            value := and(value, shl(224, not(0)))\n            result := xor(self, shr(mul(8, offset), xor(oldValue, value)))\n        }\n    }\n\n    function extract_8_1(bytes8 self, uint8 offset) internal pure returns (bytes1 result) {\n        if (offset > 7) revert OutOfRangeAccess();\n        assembly (\"memory-safe\") {\n            result := and(shl(mul(8, offset), self), shl(248, not(0)))\n        }\n    }\n\n    function replace_8_1(bytes8 self, bytes1 value, uint8 offset) internal pure returns (bytes8 result) {\n        bytes1 oldValue = extract_8_1(self, offset);\n        assembly (\"memory-safe\") {\n            value := and(value, shl(248, not(0)))\n            result := xor(self, shr(mul(8, offset), xor(oldValue, value)))\n        }\n    }\n\n    function extract_8_2(bytes8 self, uint8 offset) internal pure returns (bytes2 result) {\n        if (offset > 6) revert OutOfRangeAccess();\n        assembly (\"memory-safe\") {\n            result := and(shl(mul(8, offset), self), shl(240, not(0)))\n        }\n    }\n\n    function replace_8_2(bytes8 self, bytes2 value, uint8 offset) internal pure returns (bytes8 result) {\n        bytes2 oldValue = extract_8_2(self, offset);\n        assembly (\"memory-safe\") {\n            value := and(value, shl(240, not(0)))\n            result := xor(self, shr(mul(8, offset), xor(oldValue, value)))\n        }\n    }\n\n    function extract_8_4(bytes8 self, uint8 offset) internal pure returns (bytes4 result) {\n        if (offset > 4) revert OutOfRangeAccess();\n        assembly (\"memory-safe\") {\n            result := and(shl(mul(8, offset), self), shl(224, not(0)))\n        }\n    }\n\n    function replace_8_4(bytes8 self, bytes4 value, uint8 offset) internal pure returns (bytes8 result) {\n        bytes4 oldValue = extract_8_4(self, offset);\n        assembly (\"memory-safe\") {\n            value := and(value, shl(224, not(0)))\n            result := xor(self, shr(mul(8, offset), xor(oldValue, value)))\n        }\n    }\n\n    function extract_8_6(bytes8 self, uint8 offset) internal pure returns (bytes6 result) {\n        if (offset > 2) revert OutOfRangeAccess();\n        assembly (\"memory-safe\") {\n            result := and(shl(mul(8, offset), self), shl(208, not(0)))\n        }\n    }\n\n    function replace_8_6(bytes8 self, bytes6 value, uint8 offset) internal pure returns (bytes8 result) {\n        bytes6 oldValue = extract_8_6(self, offset);\n        assembly (\"memory-safe\") {\n            value := and(value, shl(208, not(0)))\n            result := xor(self, shr(mul(8, offset), xor(oldValue, value)))\n        }\n    }\n\n    function extract_10_1(bytes10 self, uint8 offset) internal pure returns (bytes1 result) {\n        if (offset > 9) revert OutOfRangeAccess();\n        assembly (\"memory-safe\") {\n            result := and(shl(mul(8, offset), self), shl(248, not(0)))\n        }\n    }\n\n    function replace_10_1(bytes10 self, bytes1 value, uint8 offset) internal pure returns (bytes10 result) {\n        bytes1 oldValue = extract_10_1(self, offset);\n        assembly (\"memory-safe\") {\n            value := and(value, shl(248, not(0)))\n            result := xor(self, shr(mul(8, offset), xor(oldValue, value)))\n        }\n    }\n\n    function extract_10_2(bytes10 self, uint8 offset) internal pure returns (bytes2 result) {\n        if (offset > 8) revert OutOfRangeAccess();\n        assembly (\"memory-safe\") {\n            result := and(shl(mul(8, offset), self), shl(240, not(0)))\n        }\n    }\n\n    function replace_10_2(bytes10 self, bytes2 value, uint8 offset) internal pure returns (bytes10 result) {\n        bytes2 oldValue = extract_10_2(self, offset);\n        assembly (\"memory-safe\") {\n            value := and(value, shl(240, not(0)))\n            result := xor(self, shr(mul(8, offset), xor(oldValue, value)))\n        }\n    }\n\n    function extract_10_4(bytes10 self, uint8 offset) internal pure returns (bytes4 result) {\n        if (offset > 6) revert OutOfRangeAccess();\n        assembly (\"memory-safe\") {\n            result := and(shl(mul(8, offset), self), shl(224, not(0)))\n        }\n    }\n\n    function replace_10_4(bytes10 self, bytes4 value, uint8 offset) internal pure returns (bytes10 result) {\n        bytes4 oldValue = extract_10_4(self, offset);\n        assembly (\"memory-safe\") {\n            value := and(value, shl(224, not(0)))\n            result := xor(self, shr(mul(8, offset), xor(oldValue, value)))\n        }\n    }\n\n    function extract_10_6(bytes10 self, uint8 offset) internal pure returns (bytes6 result) {\n        if (offset > 4) revert OutOfRangeAccess();\n        assembly (\"memory-safe\") {\n            result := and(shl(mul(8, offset), self), shl(208, not(0)))\n        }\n    }\n\n    function replace_10_6(bytes10 self, bytes6 value, uint8 offset) internal pure returns (bytes10 result) {\n        bytes6 oldValue = extract_10_6(self, offset);\n        assembly (\"memory-safe\") {\n            value := and(value, shl(208, not(0)))\n            result := xor(self, shr(mul(8, offset), xor(oldValue, value)))\n        }\n    }\n\n    function extract_10_8(bytes10 self, uint8 offset) internal pure returns (bytes8 result) {\n        if (offset > 2) revert OutOfRangeAccess();\n        assembly (\"memory-safe\") {\n            result := and(shl(mul(8, offset), self), shl(192, not(0)))\n        }\n    }\n\n    function replace_10_8(bytes10 self, bytes8 value, uint8 offset) internal pure returns (bytes10 result) {\n        bytes8 oldValue = extract_10_8(self, offset);\n        assembly (\"memory-safe\") {\n            value := and(value, shl(192, not(0)))\n            result := xor(self, shr(mul(8, offset), xor(oldValue, value)))\n        }\n    }\n\n    function extract_12_1(bytes12 self, uint8 offset) internal pure returns (bytes1 result) {\n        if (offset > 11) revert OutOfRangeAccess();\n        assembly (\"memory-safe\") {\n            result := and(shl(mul(8, offset), self), shl(248, not(0)))\n        }\n    }\n\n    function replace_12_1(bytes12 self, bytes1 value, uint8 offset) internal pure returns (bytes12 result) {\n        bytes1 oldValue = extract_12_1(self, offset);\n        assembly (\"memory-safe\") {\n            value := and(value, shl(248, not(0)))\n            result := xor(self, shr(mul(8, offset), xor(oldValue, value)))\n        }\n    }\n\n    function extract_12_2(bytes12 self, uint8 offset) internal pure returns (bytes2 result) {\n        if (offset > 10) revert OutOfRangeAccess();\n        assembly (\"memory-safe\") {\n            result := and(shl(mul(8, offset), self), shl(240, not(0)))\n        }\n    }\n\n    function replace_12_2(bytes12 self, bytes2 value, uint8 offset) internal pure returns (bytes12 result) {\n        bytes2 oldValue = extract_12_2(self, offset);\n        assembly (\"memory-safe\") {\n            value := and(value, shl(240, not(0)))\n            result := xor(self, shr(mul(8, offset), xor(oldValue, value)))\n        }\n    }\n\n    function extract_12_4(bytes12 self, uint8 offset) internal pure returns (bytes4 result) {\n        if (offset > 8) revert OutOfRangeAccess();\n        assembly (\"memory-safe\") {\n            result := and(shl(mul(8, offset), self), shl(224, not(0)))\n        }\n    }\n\n    function replace_12_4(bytes12 self, bytes4 value, uint8 offset) internal pure returns (bytes12 result) {\n        bytes4 oldValue = extract_12_4(self, offset);\n        assembly (\"memory-safe\") {\n            value := and(value, shl(224, not(0)))\n            result := xor(self, shr(mul(8, offset), xor(oldValue, value)))\n        }\n    }\n\n    function extract_12_6(bytes12 self, uint8 offset) internal pure returns (bytes6 result) {\n        if (offset > 6) revert OutOfRangeAccess();\n        assembly (\"memory-safe\") {\n            result := and(shl(mul(8, offset), self), shl(208, not(0)))\n        }\n    }\n\n    function replace_12_6(bytes12 self, bytes6 value, uint8 offset) internal pure returns (bytes12 result) {\n        bytes6 oldValue = extract_12_6(self, offset);\n        assembly (\"memory-safe\") {\n            value := and(value, shl(208, not(0)))\n            result := xor(self, shr(mul(8, offset), xor(oldValue, value)))\n        }\n    }\n\n    function extract_12_8(bytes12 self, uint8 offset) internal pure returns (bytes8 result) {\n        if (offset > 4) revert OutOfRangeAccess();\n        assembly (\"memory-safe\") {\n            result := and(shl(mul(8, offset), self), shl(192, not(0)))\n        }\n    }\n\n    function replace_12_8(bytes12 self, bytes8 value, uint8 offset) internal pure returns (bytes12 result) {\n        bytes8 oldValue = extract_12_8(self, offset);\n        assembly (\"memory-safe\") {\n            value := and(value, shl(192, not(0)))\n            result := xor(self, shr(mul(8, offset), xor(oldValue, value)))\n        }\n    }\n\n    function extract_12_10(bytes12 self, uint8 offset) internal pure returns (bytes10 result) {\n        if (offset > 2) revert OutOfRangeAccess();\n        assembly (\"memory-safe\") {\n            result := and(shl(mul(8, offset), self), shl(176, not(0)))\n        }\n    }\n\n    function replace_12_10(bytes12 self, bytes10 value, uint8 offset) internal pure returns (bytes12 result) {\n        bytes10 oldValue = extract_12_10(self, offset);\n        assembly (\"memory-safe\") {\n            value := and(value, shl(176, not(0)))\n            result := xor(self, shr(mul(8, offset), xor(oldValue, value)))\n        }\n    }\n\n    function extract_16_1(bytes16 self, uint8 offset) internal pure returns (bytes1 result) {\n        if (offset > 15) revert OutOfRangeAccess();\n        assembly (\"memory-safe\") {\n            result := and(shl(mul(8, offset), self), shl(248, not(0)))\n        }\n    }\n\n    function replace_16_1(bytes16 self, bytes1 value, uint8 offset) internal pure returns (bytes16 result) {\n        bytes1 oldValue = extract_16_1(self, offset);\n        assembly (\"memory-safe\") {\n            value := and(value, shl(248, not(0)))\n            result := xor(self, shr(mul(8, offset), xor(oldValue, value)))\n        }\n    }\n\n    function extract_16_2(bytes16 self, uint8 offset) internal pure returns (bytes2 result) {\n        if (offset > 14) revert OutOfRangeAccess();\n        assembly (\"memory-safe\") {\n            result := and(shl(mul(8, offset), self), shl(240, not(0)))\n        }\n    }\n\n    function replace_16_2(bytes16 self, bytes2 value, uint8 offset) internal pure returns (bytes16 result) {\n        bytes2 oldValue = extract_16_2(self, offset);\n        assembly (\"memory-safe\") {\n            value := and(value, shl(240, not(0)))\n            result := xor(self, shr(mul(8, offset), xor(oldValue, value)))\n        }\n    }\n\n    function extract_16_4(bytes16 self, uint8 offset) internal pure returns (bytes4 result) {\n        if (offset > 12) revert OutOfRangeAccess();\n        assembly (\"memory-safe\") {\n            result := and(shl(mul(8, offset), self), shl(224, not(0)))\n        }\n    }\n\n    function replace_16_4(bytes16 self, bytes4 value, uint8 offset) internal pure returns (bytes16 result) {\n        bytes4 oldValue = extract_16_4(self, offset);\n        assembly (\"memory-safe\") {\n            value := and(value, shl(224, not(0)))\n            result := xor(self, shr(mul(8, offset), xor(oldValue, value)))\n        }\n    }\n\n    function extract_16_6(bytes16 self, uint8 offset) internal pure returns (bytes6 result) {\n        if (offset > 10) revert OutOfRangeAccess();\n        assembly (\"memory-safe\") {\n            result := and(shl(mul(8, offset), self), shl(208, not(0)))\n        }\n    }\n\n    function replace_16_6(bytes16 self, bytes6 value, uint8 offset) internal pure returns (bytes16 result) {\n        bytes6 oldValue = extract_16_6(self, offset);\n        assembly (\"memory-safe\") {\n            value := and(value, shl(208, not(0)))\n            result := xor(self, shr(mul(8, offset), xor(oldValue, value)))\n        }\n    }\n\n    function extract_16_8(bytes16 self, uint8 offset) internal pure returns (bytes8 result) {\n        if (offset > 8) revert OutOfRangeAccess();\n        assembly (\"memory-safe\") {\n            result := and(shl(mul(8, offset), self), shl(192, not(0)))\n        }\n    }\n\n    function replace_16_8(bytes16 self, bytes8 value, uint8 offset) internal pure returns (bytes16 result) {\n        bytes8 oldValue = extract_16_8(self, offset);\n        assembly (\"memory-safe\") {\n            value := and(value, shl(192, not(0)))\n            result := xor(self, shr(mul(8, offset), xor(oldValue, value)))\n        }\n    }\n\n    function extract_16_10(bytes16 self, uint8 offset) internal pure returns (bytes10 result) {\n        if (offset > 6) revert OutOfRangeAccess();\n        assembly (\"memory-safe\") {\n            result := and(shl(mul(8, offset), self), shl(176, not(0)))\n        }\n    }\n\n    function replace_16_10(bytes16 self, bytes10 value, uint8 offset) internal pure returns (bytes16 result) {\n        bytes10 oldValue = extract_16_10(self, offset);\n        assembly (\"memory-safe\") {\n            value := and(value, shl(176, not(0)))\n            result := xor(self, shr(mul(8, offset), xor(oldValue, value)))\n        }\n    }\n\n    function extract_16_12(bytes16 self, uint8 offset) internal pure returns (bytes12 result) {\n        if (offset > 4) revert OutOfRangeAccess();\n        assembly (\"memory-safe\") {\n            result := and(shl(mul(8, offset), self), shl(160, not(0)))\n        }\n    }\n\n    function replace_16_12(bytes16 self, bytes12 value, uint8 offset) internal pure returns (bytes16 result) {\n        bytes12 oldValue = extract_16_12(self, offset);\n        assembly (\"memory-safe\") {\n            value := and(value, shl(160, not(0)))\n            result := xor(self, shr(mul(8, offset), xor(oldValue, value)))\n        }\n    }\n\n    function extract_20_1(bytes20 self, uint8 offset) internal pure returns (bytes1 result) {\n        if (offset > 19) revert OutOfRangeAccess();\n        assembly (\"memory-safe\") {\n            result := and(shl(mul(8, offset), self), shl(248, not(0)))\n        }\n    }\n\n    function replace_20_1(bytes20 self, bytes1 value, uint8 offset) internal pure returns (bytes20 result) {\n        bytes1 oldValue = extract_20_1(self, offset);\n        assembly (\"memory-safe\") {\n            value := and(value, shl(248, not(0)))\n            result := xor(self, shr(mul(8, offset), xor(oldValue, value)))\n        }\n    }\n\n    function extract_20_2(bytes20 self, uint8 offset) internal pure returns (bytes2 result) {\n        if (offset > 18) revert OutOfRangeAccess();\n        assembly (\"memory-safe\") {\n            result := and(shl(mul(8, offset), self), shl(240, not(0)))\n        }\n    }\n\n    function replace_20_2(bytes20 self, bytes2 value, uint8 offset) internal pure returns (bytes20 result) {\n        bytes2 oldValue = extract_20_2(self, offset);\n        assembly (\"memory-safe\") {\n            value := and(value, shl(240, not(0)))\n            result := xor(self, shr(mul(8, offset), xor(oldValue, value)))\n        }\n    }\n\n    function extract_20_4(bytes20 self, uint8 offset) internal pure returns (bytes4 result) {\n        if (offset > 16) revert OutOfRangeAccess();\n        assembly (\"memory-safe\") {\n            result := and(shl(mul(8, offset), self), shl(224, not(0)))\n        }\n    }\n\n    function replace_20_4(bytes20 self, bytes4 value, uint8 offset) internal pure returns (bytes20 result) {\n        bytes4 oldValue = extract_20_4(self, offset);\n        assembly (\"memory-safe\") {\n            value := and(value, shl(224, not(0)))\n            result := xor(self, shr(mul(8, offset), xor(oldValue, value)))\n        }\n    }\n\n    function extract_20_6(bytes20 self, uint8 offset) internal pure returns (bytes6 result) {\n        if (offset > 14) revert OutOfRangeAccess();\n        assembly (\"memory-safe\") {\n            result := and(shl(mul(8, offset), self), shl(208, not(0)))\n        }\n    }\n\n    function replace_20_6(bytes20 self, bytes6 value, uint8 offset) internal pure returns (bytes20 result) {\n        bytes6 oldValue = extract_20_6(self, offset);\n        assembly (\"memory-safe\") {\n            value := and(value, shl(208, not(0)))\n            result := xor(self, shr(mul(8, offset), xor(oldValue, value)))\n        }\n    }\n\n    function extract_20_8(bytes20 self, uint8 offset) internal pure returns (bytes8 result) {\n        if (offset > 12) revert OutOfRangeAccess();\n        assembly (\"memory-safe\") {\n            result := and(shl(mul(8, offset), self), shl(192, not(0)))\n        }\n    }\n\n    function replace_20_8(bytes20 self, bytes8 value, uint8 offset) internal pure returns (bytes20 result) {\n        bytes8 oldValue = extract_20_8(self, offset);\n        assembly (\"memory-safe\") {\n            value := and(value, shl(192, not(0)))\n            result := xor(self, shr(mul(8, offset), xor(oldValue, value)))\n        }\n    }\n\n    function extract_20_10(bytes20 self, uint8 offset) internal pure returns (bytes10 result) {\n        if (offset > 10) revert OutOfRangeAccess();\n        assembly (\"memory-safe\") {\n            result := and(shl(mul(8, offset), self), shl(176, not(0)))\n        }\n    }\n\n    function replace_20_10(bytes20 self, bytes10 value, uint8 offset) internal pure returns (bytes20 result) {\n        bytes10 oldValue = extract_20_10(self, offset);\n        assembly (\"memory-safe\") {\n            value := and(value, shl(176, not(0)))\n            result := xor(self, shr(mul(8, offset), xor(oldValue, value)))\n        }\n    }\n\n    function extract_20_12(bytes20 self, uint8 offset) internal pure returns (bytes12 result) {\n        if (offset > 8) revert OutOfRangeAccess();\n        assembly (\"memory-safe\") {\n            result := and(shl(mul(8, offset), self), shl(160, not(0)))\n        }\n    }\n\n    function replace_20_12(bytes20 self, bytes12 value, uint8 offset) internal pure returns (bytes20 result) {\n        bytes12 oldValue = extract_20_12(self, offset);\n        assembly (\"memory-safe\") {\n            value := and(value, shl(160, not(0)))\n            result := xor(self, shr(mul(8, offset), xor(oldValue, value)))\n        }\n    }\n\n    function extract_20_16(bytes20 self, uint8 offset) internal pure returns (bytes16 result) {\n        if (offset > 4) revert OutOfRangeAccess();\n        assembly (\"memory-safe\") {\n            result := and(shl(mul(8, offset), self), shl(128, not(0)))\n        }\n    }\n\n    function replace_20_16(bytes20 self, bytes16 value, uint8 offset) internal pure returns (bytes20 result) {\n        bytes16 oldValue = extract_20_16(self, offset);\n        assembly (\"memory-safe\") {\n            value := and(value, shl(128, not(0)))\n            result := xor(self, shr(mul(8, offset), xor(oldValue, value)))\n        }\n    }\n\n    function extract_22_1(bytes22 self, uint8 offset) internal pure returns (bytes1 result) {\n        if (offset > 21) revert OutOfRangeAccess();\n        assembly (\"memory-safe\") {\n            result := and(shl(mul(8, offset), self), shl(248, not(0)))\n        }\n    }\n\n    function replace_22_1(bytes22 self, bytes1 value, uint8 offset) internal pure returns (bytes22 result) {\n        bytes1 oldValue = extract_22_1(self, offset);\n        assembly (\"memory-safe\") {\n            value := and(value, shl(248, not(0)))\n            result := xor(self, shr(mul(8, offset), xor(oldValue, value)))\n        }\n    }\n\n    function extract_22_2(bytes22 self, uint8 offset) internal pure returns (bytes2 result) {\n        if (offset > 20) revert OutOfRangeAccess();\n        assembly (\"memory-safe\") {\n            result := and(shl(mul(8, offset), self), shl(240, not(0)))\n        }\n    }\n\n    function replace_22_2(bytes22 self, bytes2 value, uint8 offset) internal pure returns (bytes22 result) {\n        bytes2 oldValue = extract_22_2(self, offset);\n        assembly (\"memory-safe\") {\n            value := and(value, shl(240, not(0)))\n            result := xor(self, shr(mul(8, offset), xor(oldValue, value)))\n        }\n    }\n\n    function extract_22_4(bytes22 self, uint8 offset) internal pure returns (bytes4 result) {\n        if (offset > 18) revert OutOfRangeAccess();\n        assembly (\"memory-safe\") {\n            result := and(shl(mul(8, offset), self), shl(224, not(0)))\n        }\n    }\n\n    function replace_22_4(bytes22 self, bytes4 value, uint8 offset) internal pure returns (bytes22 result) {\n        bytes4 oldValue = extract_22_4(self, offset);\n        assembly (\"memory-safe\") {\n            value := and(value, shl(224, not(0)))\n            result := xor(self, shr(mul(8, offset), xor(oldValue, value)))\n        }\n    }\n\n    function extract_22_6(bytes22 self, uint8 offset) internal pure returns (bytes6 result) {\n        if (offset > 16) revert OutOfRangeAccess();\n        assembly (\"memory-safe\") {\n            result := and(shl(mul(8, offset), self), shl(208, not(0)))\n        }\n    }\n\n    function replace_22_6(bytes22 self, bytes6 value, uint8 offset) internal pure returns (bytes22 result) {\n        bytes6 oldValue = extract_22_6(self, offset);\n        assembly (\"memory-safe\") {\n            value := and(value, shl(208, not(0)))\n            result := xor(self, shr(mul(8, offset), xor(oldValue, value)))\n        }\n    }\n\n    function extract_22_8(bytes22 self, uint8 offset) internal pure returns (bytes8 result) {\n        if (offset > 14) revert OutOfRangeAccess();\n        assembly (\"memory-safe\") {\n            result := and(shl(mul(8, offset), self), shl(192, not(0)))\n        }\n    }\n\n    function replace_22_8(bytes22 self, bytes8 value, uint8 offset) internal pure returns (bytes22 result) {\n        bytes8 oldValue = extract_22_8(self, offset);\n        assembly (\"memory-safe\") {\n            value := and(value, shl(192, not(0)))\n            result := xor(self, shr(mul(8, offset), xor(oldValue, value)))\n        }\n    }\n\n    function extract_22_10(bytes22 self, uint8 offset) internal pure returns (bytes10 result) {\n        if (offset > 12) revert OutOfRangeAccess();\n        assembly (\"memory-safe\") {\n            result := and(shl(mul(8, offset), self), shl(176, not(0)))\n        }\n    }\n\n    function replace_22_10(bytes22 self, bytes10 value, uint8 offset) internal pure returns (bytes22 result) {\n        bytes10 oldValue = extract_22_10(self, offset);\n        assembly (\"memory-safe\") {\n            value := and(value, shl(176, not(0)))\n            result := xor(self, shr(mul(8, offset), xor(oldValue, value)))\n        }\n    }\n\n    function extract_22_12(bytes22 self, uint8 offset) internal pure returns (bytes12 result) {\n        if (offset > 10) revert OutOfRangeAccess();\n        assembly (\"memory-safe\") {\n            result := and(shl(mul(8, offset), self), shl(160, not(0)))\n        }\n    }\n\n    function replace_22_12(bytes22 self, bytes12 value, uint8 offset) internal pure returns (bytes22 result) {\n        bytes12 oldValue = extract_22_12(self, offset);\n        assembly (\"memory-safe\") {\n            value := and(value, shl(160, not(0)))\n            result := xor(self, shr(mul(8, offset), xor(oldValue, value)))\n        }\n    }\n\n    function extract_22_16(bytes22 self, uint8 offset) internal pure returns (bytes16 result) {\n        if (offset > 6) revert OutOfRangeAccess();\n        assembly (\"memory-safe\") {\n            result := and(shl(mul(8, offset), self), shl(128, not(0)))\n        }\n    }\n\n    function replace_22_16(bytes22 self, bytes16 value, uint8 offset) internal pure returns (bytes22 result) {\n        bytes16 oldValue = extract_22_16(self, offset);\n        assembly (\"memory-safe\") {\n            value := and(value, shl(128, not(0)))\n            result := xor(self, shr(mul(8, offset), xor(oldValue, value)))\n        }\n    }\n\n    function extract_22_20(bytes22 self, uint8 offset) internal pure returns (bytes20 result) {\n        if (offset > 2) revert OutOfRangeAccess();\n        assembly (\"memory-safe\") {\n            result := and(shl(mul(8, offset), self), shl(96, not(0)))\n        }\n    }\n\n    function replace_22_20(bytes22 self, bytes20 value, uint8 offset) internal pure returns (bytes22 result) {\n        bytes20 oldValue = extract_22_20(self, offset);\n        assembly (\"memory-safe\") {\n            value := and(value, shl(96, not(0)))\n            result := xor(self, shr(mul(8, offset), xor(oldValue, value)))\n        }\n    }\n\n    function extract_24_1(bytes24 self, uint8 offset) internal pure returns (bytes1 result) {\n        if (offset > 23) revert OutOfRangeAccess();\n        assembly (\"memory-safe\") {\n            result := and(shl(mul(8, offset), self), shl(248, not(0)))\n        }\n    }\n\n    function replace_24_1(bytes24 self, bytes1 value, uint8 offset) internal pure returns (bytes24 result) {\n        bytes1 oldValue = extract_24_1(self, offset);\n        assembly (\"memory-safe\") {\n            value := and(value, shl(248, not(0)))\n            result := xor(self, shr(mul(8, offset), xor(oldValue, value)))\n        }\n    }\n\n    function extract_24_2(bytes24 self, uint8 offset) internal pure returns (bytes2 result) {\n        if (offset > 22) revert OutOfRangeAccess();\n        assembly (\"memory-safe\") {\n            result := and(shl(mul(8, offset), self), shl(240, not(0)))\n        }\n    }\n\n    function replace_24_2(bytes24 self, bytes2 value, uint8 offset) internal pure returns (bytes24 result) {\n        bytes2 oldValue = extract_24_2(self, offset);\n        assembly (\"memory-safe\") {\n            value := and(value, shl(240, not(0)))\n            result := xor(self, shr(mul(8, offset), xor(oldValue, value)))\n        }\n    }\n\n    function extract_24_4(bytes24 self, uint8 offset) internal pure returns (bytes4 result) {\n        if (offset > 20) revert OutOfRangeAccess();\n        assembly (\"memory-safe\") {\n            result := and(shl(mul(8, offset), self), shl(224, not(0)))\n        }\n    }\n\n    function replace_24_4(bytes24 self, bytes4 value, uint8 offset) internal pure returns (bytes24 result) {\n        bytes4 oldValue = extract_24_4(self, offset);\n        assembly (\"memory-safe\") {\n            value := and(value, shl(224, not(0)))\n            result := xor(self, shr(mul(8, offset), xor(oldValue, value)))\n        }\n    }\n\n    function extract_24_6(bytes24 self, uint8 offset) internal pure returns (bytes6 result) {\n        if (offset > 18) revert OutOfRangeAccess();\n        assembly (\"memory-safe\") {\n            result := and(shl(mul(8, offset), self), shl(208, not(0)))\n        }\n    }\n\n    function replace_24_6(bytes24 self, bytes6 value, uint8 offset) internal pure returns (bytes24 result) {\n        bytes6 oldValue = extract_24_6(self, offset);\n        assembly (\"memory-safe\") {\n            value := and(value, shl(208, not(0)))\n            result := xor(self, shr(mul(8, offset), xor(oldValue, value)))\n        }\n    }\n\n    function extract_24_8(bytes24 self, uint8 offset) internal pure returns (bytes8 result) {\n        if (offset > 16) revert OutOfRangeAccess();\n        assembly (\"memory-safe\") {\n            result := and(shl(mul(8, offset), self), shl(192, not(0)))\n        }\n    }\n\n    function replace_24_8(bytes24 self, bytes8 value, uint8 offset) internal pure returns (bytes24 result) {\n        bytes8 oldValue = extract_24_8(self, offset);\n        assembly (\"memory-safe\") {\n            value := and(value, shl(192, not(0)))\n            result := xor(self, shr(mul(8, offset), xor(oldValue, value)))\n        }\n    }\n\n    function extract_24_10(bytes24 self, uint8 offset) internal pure returns (bytes10 result) {\n        if (offset > 14) revert OutOfRangeAccess();\n        assembly (\"memory-safe\") {\n            result := and(shl(mul(8, offset), self), shl(176, not(0)))\n        }\n    }\n\n    function replace_24_10(bytes24 self, bytes10 value, uint8 offset) internal pure returns (bytes24 result) {\n        bytes10 oldValue = extract_24_10(self, offset);\n        assembly (\"memory-safe\") {\n            value := and(value, shl(176, not(0)))\n            result := xor(self, shr(mul(8, offset), xor(oldValue, value)))\n        }\n    }\n\n    function extract_24_12(bytes24 self, uint8 offset) internal pure returns (bytes12 result) {\n        if (offset > 12) revert OutOfRangeAccess();\n        assembly (\"memory-safe\") {\n            result := and(shl(mul(8, offset), self), shl(160, not(0)))\n        }\n    }\n\n    function replace_24_12(bytes24 self, bytes12 value, uint8 offset) internal pure returns (bytes24 result) {\n        bytes12 oldValue = extract_24_12(self, offset);\n        assembly (\"memory-safe\") {\n            value := and(value, shl(160, not(0)))\n            result := xor(self, shr(mul(8, offset), xor(oldValue, value)))\n        }\n    }\n\n    function extract_24_16(bytes24 self, uint8 offset) internal pure returns (bytes16 result) {\n        if (offset > 8) revert OutOfRangeAccess();\n        assembly (\"memory-safe\") {\n            result := and(shl(mul(8, offset), self), shl(128, not(0)))\n        }\n    }\n\n    function replace_24_16(bytes24 self, bytes16 value, uint8 offset) internal pure returns (bytes24 result) {\n        bytes16 oldValue = extract_24_16(self, offset);\n        assembly (\"memory-safe\") {\n            value := and(value, shl(128, not(0)))\n            result := xor(self, shr(mul(8, offset), xor(oldValue, value)))\n        }\n    }\n\n    function extract_24_20(bytes24 self, uint8 offset) internal pure returns (bytes20 result) {\n        if (offset > 4) revert OutOfRangeAccess();\n        assembly (\"memory-safe\") {\n            result := and(shl(mul(8, offset), self), shl(96, not(0)))\n        }\n    }\n\n    function replace_24_20(bytes24 self, bytes20 value, uint8 offset) internal pure returns (bytes24 result) {\n        bytes20 oldValue = extract_24_20(self, offset);\n        assembly (\"memory-safe\") {\n            value := and(value, shl(96, not(0)))\n            result := xor(self, shr(mul(8, offset), xor(oldValue, value)))\n        }\n    }\n\n    function extract_24_22(bytes24 self, uint8 offset) internal pure returns (bytes22 result) {\n        if (offset > 2) revert OutOfRangeAccess();\n        assembly (\"memory-safe\") {\n            result := and(shl(mul(8, offset), self), shl(80, not(0)))\n        }\n    }\n\n    function replace_24_22(bytes24 self, bytes22 value, uint8 offset) internal pure returns (bytes24 result) {\n        bytes22 oldValue = extract_24_22(self, offset);\n        assembly (\"memory-safe\") {\n            value := and(value, shl(80, not(0)))\n            result := xor(self, shr(mul(8, offset), xor(oldValue, value)))\n        }\n    }\n\n    function extract_28_1(bytes28 self, uint8 offset) internal pure returns (bytes1 result) {\n        if (offset > 27) revert OutOfRangeAccess();\n        assembly (\"memory-safe\") {\n            result := and(shl(mul(8, offset), self), shl(248, not(0)))\n        }\n    }\n\n    function replace_28_1(bytes28 self, bytes1 value, uint8 offset) internal pure returns (bytes28 result) {\n        bytes1 oldValue = extract_28_1(self, offset);\n        assembly (\"memory-safe\") {\n            value := and(value, shl(248, not(0)))\n            result := xor(self, shr(mul(8, offset), xor(oldValue, value)))\n        }\n    }\n\n    function extract_28_2(bytes28 self, uint8 offset) internal pure returns (bytes2 result) {\n        if (offset > 26) revert OutOfRangeAccess();\n        assembly (\"memory-safe\") {\n            result := and(shl(mul(8, offset), self), shl(240, not(0)))\n        }\n    }\n\n    function replace_28_2(bytes28 self, bytes2 value, uint8 offset) internal pure returns (bytes28 result) {\n        bytes2 oldValue = extract_28_2(self, offset);\n        assembly (\"memory-safe\") {\n            value := and(value, shl(240, not(0)))\n            result := xor(self, shr(mul(8, offset), xor(oldValue, value)))\n        }\n    }\n\n    function extract_28_4(bytes28 self, uint8 offset) internal pure returns (bytes4 result) {\n        if (offset > 24) revert OutOfRangeAccess();\n        assembly (\"memory-safe\") {\n            result := and(shl(mul(8, offset), self), shl(224, not(0)))\n        }\n    }\n\n    function replace_28_4(bytes28 self, bytes4 value, uint8 offset) internal pure returns (bytes28 result) {\n        bytes4 oldValue = extract_28_4(self, offset);\n        assembly (\"memory-safe\") {\n            value := and(value, shl(224, not(0)))\n            result := xor(self, shr(mul(8, offset), xor(oldValue, value)))\n        }\n    }\n\n    function extract_28_6(bytes28 self, uint8 offset) internal pure returns (bytes6 result) {\n        if (offset > 22) revert OutOfRangeAccess();\n        assembly (\"memory-safe\") {\n            result := and(shl(mul(8, offset), self), shl(208, not(0)))\n        }\n    }\n\n    function replace_28_6(bytes28 self, bytes6 value, uint8 offset) internal pure returns (bytes28 result) {\n        bytes6 oldValue = extract_28_6(self, offset);\n        assembly (\"memory-safe\") {\n            value := and(value, shl(208, not(0)))\n            result := xor(self, shr(mul(8, offset), xor(oldValue, value)))\n        }\n    }\n\n    function extract_28_8(bytes28 self, uint8 offset) internal pure returns (bytes8 result) {\n        if (offset > 20) revert OutOfRangeAccess();\n        assembly (\"memory-safe\") {\n            result := and(shl(mul(8, offset), self), shl(192, not(0)))\n        }\n    }\n\n    function replace_28_8(bytes28 self, bytes8 value, uint8 offset) internal pure returns (bytes28 result) {\n        bytes8 oldValue = extract_28_8(self, offset);\n        assembly (\"memory-safe\") {\n            value := and(value, shl(192, not(0)))\n            result := xor(self, shr(mul(8, offset), xor(oldValue, value)))\n        }\n    }\n\n    function extract_28_10(bytes28 self, uint8 offset) internal pure returns (bytes10 result) {\n        if (offset > 18) revert OutOfRangeAccess();\n        assembly (\"memory-safe\") {\n            result := and(shl(mul(8, offset), self), shl(176, not(0)))\n        }\n    }\n\n    function replace_28_10(bytes28 self, bytes10 value, uint8 offset) internal pure returns (bytes28 result) {\n        bytes10 oldValue = extract_28_10(self, offset);\n        assembly (\"memory-safe\") {\n            value := and(value, shl(176, not(0)))\n            result := xor(self, shr(mul(8, offset), xor(oldValue, value)))\n        }\n    }\n\n    function extract_28_12(bytes28 self, uint8 offset) internal pure returns (bytes12 result) {\n        if (offset > 16) revert OutOfRangeAccess();\n        assembly (\"memory-safe\") {\n            result := and(shl(mul(8, offset), self), shl(160, not(0)))\n        }\n    }\n\n    function replace_28_12(bytes28 self, bytes12 value, uint8 offset) internal pure returns (bytes28 result) {\n        bytes12 oldValue = extract_28_12(self, offset);\n        assembly (\"memory-safe\") {\n            value := and(value, shl(160, not(0)))\n            result := xor(self, shr(mul(8, offset), xor(oldValue, value)))\n        }\n    }\n\n    function extract_28_16(bytes28 self, uint8 offset) internal pure returns (bytes16 result) {\n        if (offset > 12) revert OutOfRangeAccess();\n        assembly (\"memory-safe\") {\n            result := and(shl(mul(8, offset), self), shl(128, not(0)))\n        }\n    }\n\n    function replace_28_16(bytes28 self, bytes16 value, uint8 offset) internal pure returns (bytes28 result) {\n        bytes16 oldValue = extract_28_16(self, offset);\n        assembly (\"memory-safe\") {\n            value := and(value, shl(128, not(0)))\n            result := xor(self, shr(mul(8, offset), xor(oldValue, value)))\n        }\n    }\n\n    function extract_28_20(bytes28 self, uint8 offset) internal pure returns (bytes20 result) {\n        if (offset > 8) revert OutOfRangeAccess();\n        assembly (\"memory-safe\") {\n            result := and(shl(mul(8, offset), self), shl(96, not(0)))\n        }\n    }\n\n    function replace_28_20(bytes28 self, bytes20 value, uint8 offset) internal pure returns (bytes28 result) {\n        bytes20 oldValue = extract_28_20(self, offset);\n        assembly (\"memory-safe\") {\n            value := and(value, shl(96, not(0)))\n            result := xor(self, shr(mul(8, offset), xor(oldValue, value)))\n        }\n    }\n\n    function extract_28_22(bytes28 self, uint8 offset) internal pure returns (bytes22 result) {\n        if (offset > 6) revert OutOfRangeAccess();\n        assembly (\"memory-safe\") {\n            result := and(shl(mul(8, offset), self), shl(80, not(0)))\n        }\n    }\n\n    function replace_28_22(bytes28 self, bytes22 value, uint8 offset) internal pure returns (bytes28 result) {\n        bytes22 oldValue = extract_28_22(self, offset);\n        assembly (\"memory-safe\") {\n            value := and(value, shl(80, not(0)))\n            result := xor(self, shr(mul(8, offset), xor(oldValue, value)))\n        }\n    }\n\n    function extract_28_24(bytes28 self, uint8 offset) internal pure returns (bytes24 result) {\n        if (offset > 4) revert OutOfRangeAccess();\n        assembly (\"memory-safe\") {\n            result := and(shl(mul(8, offset), self), shl(64, not(0)))\n        }\n    }\n\n    function replace_28_24(bytes28 self, bytes24 value, uint8 offset) internal pure returns (bytes28 result) {\n        bytes24 oldValue = extract_28_24(self, offset);\n        assembly (\"memory-safe\") {\n            value := and(value, shl(64, not(0)))\n            result := xor(self, shr(mul(8, offset), xor(oldValue, value)))\n        }\n    }\n\n    function extract_32_1(bytes32 self, uint8 offset) internal pure returns (bytes1 result) {\n        if (offset > 31) revert OutOfRangeAccess();\n        assembly (\"memory-safe\") {\n            result := and(shl(mul(8, offset), self), shl(248, not(0)))\n        }\n    }\n\n    function replace_32_1(bytes32 self, bytes1 value, uint8 offset) internal pure returns (bytes32 result) {\n        bytes1 oldValue = extract_32_1(self, offset);\n        assembly (\"memory-safe\") {\n            value := and(value, shl(248, not(0)))\n            result := xor(self, shr(mul(8, offset), xor(oldValue, value)))\n        }\n    }\n\n    function extract_32_2(bytes32 self, uint8 offset) internal pure returns (bytes2 result) {\n        if (offset > 30) revert OutOfRangeAccess();\n        assembly (\"memory-safe\") {\n            result := and(shl(mul(8, offset), self), shl(240, not(0)))\n        }\n    }\n\n    function replace_32_2(bytes32 self, bytes2 value, uint8 offset) internal pure returns (bytes32 result) {\n        bytes2 oldValue = extract_32_2(self, offset);\n        assembly (\"memory-safe\") {\n            value := and(value, shl(240, not(0)))\n            result := xor(self, shr(mul(8, offset), xor(oldValue, value)))\n        }\n    }\n\n    function extract_32_4(bytes32 self, uint8 offset) internal pure returns (bytes4 result) {\n        if (offset > 28) revert OutOfRangeAccess();\n        assembly (\"memory-safe\") {\n            result := and(shl(mul(8, offset), self), shl(224, not(0)))\n        }\n    }\n\n    function replace_32_4(bytes32 self, bytes4 value, uint8 offset) internal pure returns (bytes32 result) {\n        bytes4 oldValue = extract_32_4(self, offset);\n        assembly (\"memory-safe\") {\n            value := and(value, shl(224, not(0)))\n            result := xor(self, shr(mul(8, offset), xor(oldValue, value)))\n        }\n    }\n\n    function extract_32_6(bytes32 self, uint8 offset) internal pure returns (bytes6 result) {\n        if (offset > 26) revert OutOfRangeAccess();\n        assembly (\"memory-safe\") {\n            result := and(shl(mul(8, offset), self), shl(208, not(0)))\n        }\n    }\n\n    function replace_32_6(bytes32 self, bytes6 value, uint8 offset) internal pure returns (bytes32 result) {\n        bytes6 oldValue = extract_32_6(self, offset);\n        assembly (\"memory-safe\") {\n            value := and(value, shl(208, not(0)))\n            result := xor(self, shr(mul(8, offset), xor(oldValue, value)))\n        }\n    }\n\n    function extract_32_8(bytes32 self, uint8 offset) internal pure returns (bytes8 result) {\n        if (offset > 24) revert OutOfRangeAccess();\n        assembly (\"memory-safe\") {\n            result := and(shl(mul(8, offset), self), shl(192, not(0)))\n        }\n    }\n\n    function replace_32_8(bytes32 self, bytes8 value, uint8 offset) internal pure returns (bytes32 result) {\n        bytes8 oldValue = extract_32_8(self, offset);\n        assembly (\"memory-safe\") {\n            value := and(value, shl(192, not(0)))\n            result := xor(self, shr(mul(8, offset), xor(oldValue, value)))\n        }\n    }\n\n    function extract_32_10(bytes32 self, uint8 offset) internal pure returns (bytes10 result) {\n        if (offset > 22) revert OutOfRangeAccess();\n        assembly (\"memory-safe\") {\n            result := and(shl(mul(8, offset), self), shl(176, not(0)))\n        }\n    }\n\n    function replace_32_10(bytes32 self, bytes10 value, uint8 offset) internal pure returns (bytes32 result) {\n        bytes10 oldValue = extract_32_10(self, offset);\n        assembly (\"memory-safe\") {\n            value := and(value, shl(176, not(0)))\n            result := xor(self, shr(mul(8, offset), xor(oldValue, value)))\n        }\n    }\n\n    function extract_32_12(bytes32 self, uint8 offset) internal pure returns (bytes12 result) {\n        if (offset > 20) revert OutOfRangeAccess();\n        assembly (\"memory-safe\") {\n            result := and(shl(mul(8, offset), self), shl(160, not(0)))\n        }\n    }\n\n    function replace_32_12(bytes32 self, bytes12 value, uint8 offset) internal pure returns (bytes32 result) {\n        bytes12 oldValue = extract_32_12(self, offset);\n        assembly (\"memory-safe\") {\n            value := and(value, shl(160, not(0)))\n            result := xor(self, shr(mul(8, offset), xor(oldValue, value)))\n        }\n    }\n\n    function extract_32_16(bytes32 self, uint8 offset) internal pure returns (bytes16 result) {\n        if (offset > 16) revert OutOfRangeAccess();\n        assembly (\"memory-safe\") {\n            result := and(shl(mul(8, offset), self), shl(128, not(0)))\n        }\n    }\n\n    function replace_32_16(bytes32 self, bytes16 value, uint8 offset) internal pure returns (bytes32 result) {\n        bytes16 oldValue = extract_32_16(self, offset);\n        assembly (\"memory-safe\") {\n            value := and(value, shl(128, not(0)))\n            result := xor(self, shr(mul(8, offset), xor(oldValue, value)))\n        }\n    }\n\n    function extract_32_20(bytes32 self, uint8 offset) internal pure returns (bytes20 result) {\n        if (offset > 12) revert OutOfRangeAccess();\n        assembly (\"memory-safe\") {\n            result := and(shl(mul(8, offset), self), shl(96, not(0)))\n        }\n    }\n\n    function replace_32_20(bytes32 self, bytes20 value, uint8 offset) internal pure returns (bytes32 result) {\n        bytes20 oldValue = extract_32_20(self, offset);\n        assembly (\"memory-safe\") {\n            value := and(value, shl(96, not(0)))\n            result := xor(self, shr(mul(8, offset), xor(oldValue, value)))\n        }\n    }\n\n    function extract_32_22(bytes32 self, uint8 offset) internal pure returns (bytes22 result) {\n        if (offset > 10) revert OutOfRangeAccess();\n        assembly (\"memory-safe\") {\n            result := and(shl(mul(8, offset), self), shl(80, not(0)))\n        }\n    }\n\n    function replace_32_22(bytes32 self, bytes22 value, uint8 offset) internal pure returns (bytes32 result) {\n        bytes22 oldValue = extract_32_22(self, offset);\n        assembly (\"memory-safe\") {\n            value := and(value, shl(80, not(0)))\n            result := xor(self, shr(mul(8, offset), xor(oldValue, value)))\n        }\n    }\n\n    function extract_32_24(bytes32 self, uint8 offset) internal pure returns (bytes24 result) {\n        if (offset > 8) revert OutOfRangeAccess();\n        assembly (\"memory-safe\") {\n            result := and(shl(mul(8, offset), self), shl(64, not(0)))\n        }\n    }\n\n    function replace_32_24(bytes32 self, bytes24 value, uint8 offset) internal pure returns (bytes32 result) {\n        bytes24 oldValue = extract_32_24(self, offset);\n        assembly (\"memory-safe\") {\n            value := and(value, shl(64, not(0)))\n            result := xor(self, shr(mul(8, offset), xor(oldValue, value)))\n        }\n    }\n\n    function extract_32_28(bytes32 self, uint8 offset) internal pure returns (bytes28 result) {\n        if (offset > 4) revert OutOfRangeAccess();\n        assembly (\"memory-safe\") {\n            result := and(shl(mul(8, offset), self), shl(32, not(0)))\n        }\n    }\n\n    function replace_32_28(bytes32 self, bytes28 value, uint8 offset) internal pure returns (bytes32 result) {\n        bytes28 oldValue = extract_32_28(self, offset);\n        assembly (\"memory-safe\") {\n            value := and(value, shl(32, not(0)))\n            result := xor(self, shr(mul(8, offset), xor(oldValue, value)))\n        }\n    }\n}\n"},{"file_path":"node_modules/@openzeppelin/contracts/utils/Panic.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.1.0) (utils/Panic.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Helper library for emitting standardized panic codes.\n *\n * ```solidity\n * contract Example {\n *      using Panic for uint256;\n *\n *      // Use any of the declared internal constants\n *      function foo() { Panic.GENERIC.panic(); }\n *\n *      // Alternatively\n *      function foo() { Panic.panic(Panic.GENERIC); }\n * }\n * ```\n *\n * Follows the list from https://github.com/ethereum/solidity/blob/v0.8.24/libsolutil/ErrorCodes.h[libsolutil].\n *\n * _Available since v5.1._\n */\n// slither-disable-next-line unused-state\nlibrary Panic {\n    /// @dev generic / unspecified error\n    uint256 internal constant GENERIC = 0x00;\n    /// @dev used by the assert() builtin\n    uint256 internal constant ASSERT = 0x01;\n    /// @dev arithmetic underflow or overflow\n    uint256 internal constant UNDER_OVERFLOW = 0x11;\n    /// @dev division or modulo by zero\n    uint256 internal constant DIVISION_BY_ZERO = 0x12;\n    /// @dev enum conversion error\n    uint256 internal constant ENUM_CONVERSION_ERROR = 0x21;\n    /// @dev invalid encoding in storage\n    uint256 internal constant STORAGE_ENCODING_ERROR = 0x22;\n    /// @dev empty array pop\n    uint256 internal constant EMPTY_ARRAY_POP = 0x31;\n    /// @dev array out of bounds access\n    uint256 internal constant ARRAY_OUT_OF_BOUNDS = 0x32;\n    /// @dev resource error (too large allocation or too large array)\n    uint256 internal constant RESOURCE_ERROR = 0x41;\n    /// @dev calling invalid internal function\n    uint256 internal constant INVALID_INTERNAL_FUNCTION = 0x51;\n\n    /// @dev Reverts with a panic code. Recommended to use with\n    /// the internal constants with predefined codes.\n    function panic(uint256 code) internal pure {\n        assembly (\"memory-safe\") {\n            mstore(0x00, 0x4e487b71)\n            mstore(0x20, code)\n            revert(0x1c, 0x24)\n        }\n    }\n}\n"},{"file_path":"node_modules/@openzeppelin/contracts/utils/Strings.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.2.0) (utils/Strings.sol)\n\npragma solidity ^0.8.20;\n\nimport {Math} from \"./math/Math.sol\";\nimport {SafeCast} from \"./math/SafeCast.sol\";\nimport {SignedMath} from \"./math/SignedMath.sol\";\n\n/**\n * @dev String operations.\n */\nlibrary Strings {\n    using SafeCast for *;\n\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 The string being parsed contains characters that are not in scope of the given base.\n     */\n    error StringsInvalidChar();\n\n    /**\n     * @dev The string being parsed is not a properly formatted address.\n     */\n    error StringsInvalidAddressFormat();\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            assembly (\"memory-safe\") {\n                ptr := add(buffer, add(32, length))\n            }\n            while (true) {\n                ptr--;\n                assembly (\"memory-safe\") {\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 Converts an `address` with fixed length of 20 bytes to its checksummed ASCII `string` hexadecimal\n     * representation, according to EIP-55.\n     */\n    function toChecksumHexString(address addr) internal pure returns (string memory) {\n        bytes memory buffer = bytes(toHexString(addr));\n\n        // hash the hex part of buffer (skip length + 2 bytes, length 40)\n        uint256 hashValue;\n        assembly (\"memory-safe\") {\n            hashValue := shr(96, keccak256(add(buffer, 0x22), 40))\n        }\n\n        for (uint256 i = 41; i > 1; --i) {\n            // possible values for buffer[i] are 48 (0) to 57 (9) and 97 (a) to 102 (f)\n            if (hashValue & 0xf > 7 && uint8(buffer[i]) > 96) {\n                // case shift by xoring with 0x20\n                buffer[i] ^= 0x20;\n            }\n            hashValue >>= 4;\n        }\n        return string(buffer);\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    /**\n     * @dev Parse a decimal string and returns the value as a `uint256`.\n     *\n     * Requirements:\n     * - The string must be formatted as `[0-9]*`\n     * - The result must fit into an `uint256` type\n     */\n    function parseUint(string memory input) internal pure returns (uint256) {\n        return parseUint(input, 0, bytes(input).length);\n    }\n\n    /**\n     * @dev Variant of {parseUint} that parses a substring of `input` located between position `begin` (included) and\n     * `end` (excluded).\n     *\n     * Requirements:\n     * - The substring must be formatted as `[0-9]*`\n     * - The result must fit into an `uint256` type\n     */\n    function parseUint(string memory input, uint256 begin, uint256 end) internal pure returns (uint256) {\n        (bool success, uint256 value) = tryParseUint(input, begin, end);\n        if (!success) revert StringsInvalidChar();\n        return value;\n    }\n\n    /**\n     * @dev Variant of {parseUint-string} that returns false if the parsing fails because of an invalid character.\n     *\n     * NOTE: This function will revert if the result does not fit in a `uint256`.\n     */\n    function tryParseUint(string memory input) internal pure returns (bool success, uint256 value) {\n        return _tryParseUintUncheckedBounds(input, 0, bytes(input).length);\n    }\n\n    /**\n     * @dev Variant of {parseUint-string-uint256-uint256} that returns false if the parsing fails because of an invalid\n     * character.\n     *\n     * NOTE: This function will revert if the result does not fit in a `uint256`.\n     */\n    function tryParseUint(\n        string memory input,\n        uint256 begin,\n        uint256 end\n    ) internal pure returns (bool success, uint256 value) {\n        if (end > bytes(input).length || begin > end) return (false, 0);\n        return _tryParseUintUncheckedBounds(input, begin, end);\n    }\n\n    /**\n     * @dev Implementation of {tryParseUint} that does not check bounds. Caller should make sure that\n     * `begin <= end <= input.length`. Other inputs would result in undefined behavior.\n     */\n    function _tryParseUintUncheckedBounds(\n        string memory input,\n        uint256 begin,\n        uint256 end\n    ) private pure returns (bool success, uint256 value) {\n        bytes memory buffer = bytes(input);\n\n        uint256 result = 0;\n        for (uint256 i = begin; i < end; ++i) {\n            uint8 chr = _tryParseChr(bytes1(_unsafeReadBytesOffset(buffer, i)));\n            if (chr > 9) return (false, 0);\n            result *= 10;\n            result += chr;\n        }\n        return (true, result);\n    }\n\n    /**\n     * @dev Parse a decimal string and returns the value as a `int256`.\n     *\n     * Requirements:\n     * - The string must be formatted as `[-+]?[0-9]*`\n     * - The result must fit in an `int256` type.\n     */\n    function parseInt(string memory input) internal pure returns (int256) {\n        return parseInt(input, 0, bytes(input).length);\n    }\n\n    /**\n     * @dev Variant of {parseInt-string} that parses a substring of `input` located between position `begin` (included) and\n     * `end` (excluded).\n     *\n     * Requirements:\n     * - The substring must be formatted as `[-+]?[0-9]*`\n     * - The result must fit in an `int256` type.\n     */\n    function parseInt(string memory input, uint256 begin, uint256 end) internal pure returns (int256) {\n        (bool success, int256 value) = tryParseInt(input, begin, end);\n        if (!success) revert StringsInvalidChar();\n        return value;\n    }\n\n    /**\n     * @dev Variant of {parseInt-string} that returns false if the parsing fails because of an invalid character or if\n     * the result does not fit in a `int256`.\n     *\n     * NOTE: This function will revert if the absolute value of the result does not fit in a `uint256`.\n     */\n    function tryParseInt(string memory input) internal pure returns (bool success, int256 value) {\n        return _tryParseIntUncheckedBounds(input, 0, bytes(input).length);\n    }\n\n    uint256 private constant ABS_MIN_INT256 = 2 ** 255;\n\n    /**\n     * @dev Variant of {parseInt-string-uint256-uint256} that returns false if the parsing fails because of an invalid\n     * character or if the result does not fit in a `int256`.\n     *\n     * NOTE: This function will revert if the absolute value of the result does not fit in a `uint256`.\n     */\n    function tryParseInt(\n        string memory input,\n        uint256 begin,\n        uint256 end\n    ) internal pure returns (bool success, int256 value) {\n        if (end > bytes(input).length || begin > end) return (false, 0);\n        return _tryParseIntUncheckedBounds(input, begin, end);\n    }\n\n    /**\n     * @dev Implementation of {tryParseInt} that does not check bounds. Caller should make sure that\n     * `begin <= end <= input.length`. Other inputs would result in undefined behavior.\n     */\n    function _tryParseIntUncheckedBounds(\n        string memory input,\n        uint256 begin,\n        uint256 end\n    ) private pure returns (bool success, int256 value) {\n        bytes memory buffer = bytes(input);\n\n        // Check presence of a negative sign.\n        bytes1 sign = begin == end ? bytes1(0) : bytes1(_unsafeReadBytesOffset(buffer, begin)); // don't do out-of-bound (possibly unsafe) read if sub-string is empty\n        bool positiveSign = sign == bytes1(\"+\");\n        bool negativeSign = sign == bytes1(\"-\");\n        uint256 offset = (positiveSign || negativeSign).toUint();\n\n        (bool absSuccess, uint256 absValue) = tryParseUint(input, begin + offset, end);\n\n        if (absSuccess && absValue < ABS_MIN_INT256) {\n            return (true, negativeSign ? -int256(absValue) : int256(absValue));\n        } else if (absSuccess && negativeSign && absValue == ABS_MIN_INT256) {\n            return (true, type(int256).min);\n        } else return (false, 0);\n    }\n\n    /**\n     * @dev Parse a hexadecimal string (with or without \"0x\" prefix), and returns the value as a `uint256`.\n     *\n     * Requirements:\n     * - The string must be formatted as `(0x)?[0-9a-fA-F]*`\n     * - The result must fit in an `uint256` type.\n     */\n    function parseHexUint(string memory input) internal pure returns (uint256) {\n        return parseHexUint(input, 0, bytes(input).length);\n    }\n\n    /**\n     * @dev Variant of {parseHexUint} that parses a substring of `input` located between position `begin` (included) and\n     * `end` (excluded).\n     *\n     * Requirements:\n     * - The substring must be formatted as `(0x)?[0-9a-fA-F]*`\n     * - The result must fit in an `uint256` type.\n     */\n    function parseHexUint(string memory input, uint256 begin, uint256 end) internal pure returns (uint256) {\n        (bool success, uint256 value) = tryParseHexUint(input, begin, end);\n        if (!success) revert StringsInvalidChar();\n        return value;\n    }\n\n    /**\n     * @dev Variant of {parseHexUint-string} that returns false if the parsing fails because of an invalid character.\n     *\n     * NOTE: This function will revert if the result does not fit in a `uint256`.\n     */\n    function tryParseHexUint(string memory input) internal pure returns (bool success, uint256 value) {\n        return _tryParseHexUintUncheckedBounds(input, 0, bytes(input).length);\n    }\n\n    /**\n     * @dev Variant of {parseHexUint-string-uint256-uint256} that returns false if the parsing fails because of an\n     * invalid character.\n     *\n     * NOTE: This function will revert if the result does not fit in a `uint256`.\n     */\n    function tryParseHexUint(\n        string memory input,\n        uint256 begin,\n        uint256 end\n    ) internal pure returns (bool success, uint256 value) {\n        if (end > bytes(input).length || begin > end) return (false, 0);\n        return _tryParseHexUintUncheckedBounds(input, begin, end);\n    }\n\n    /**\n     * @dev Implementation of {tryParseHexUint} that does not check bounds. Caller should make sure that\n     * `begin <= end <= input.length`. Other inputs would result in undefined behavior.\n     */\n    function _tryParseHexUintUncheckedBounds(\n        string memory input,\n        uint256 begin,\n        uint256 end\n    ) private pure returns (bool success, uint256 value) {\n        bytes memory buffer = bytes(input);\n\n        // skip 0x prefix if present\n        bool hasPrefix = (end > begin + 1) && bytes2(_unsafeReadBytesOffset(buffer, begin)) == bytes2(\"0x\"); // don't do out-of-bound (possibly unsafe) read if sub-string is empty\n        uint256 offset = hasPrefix.toUint() * 2;\n\n        uint256 result = 0;\n        for (uint256 i = begin + offset; i < end; ++i) {\n            uint8 chr = _tryParseChr(bytes1(_unsafeReadBytesOffset(buffer, i)));\n            if (chr > 15) return (false, 0);\n            result *= 16;\n            unchecked {\n                // Multiplying by 16 is equivalent to a shift of 4 bits (with additional overflow check).\n                // This guaratees that adding a value < 16 will not cause an overflow, hence the unchecked.\n                result += chr;\n            }\n        }\n        return (true, result);\n    }\n\n    /**\n     * @dev Parse a hexadecimal string (with or without \"0x\" prefix), and returns the value as an `address`.\n     *\n     * Requirements:\n     * - The string must be formatted as `(0x)?[0-9a-fA-F]{40}`\n     */\n    function parseAddress(string memory input) internal pure returns (address) {\n        return parseAddress(input, 0, bytes(input).length);\n    }\n\n    /**\n     * @dev Variant of {parseAddress} that parses a substring of `input` located between position `begin` (included) and\n     * `end` (excluded).\n     *\n     * Requirements:\n     * - The substring must be formatted as `(0x)?[0-9a-fA-F]{40}`\n     */\n    function parseAddress(string memory input, uint256 begin, uint256 end) internal pure returns (address) {\n        (bool success, address value) = tryParseAddress(input, begin, end);\n        if (!success) revert StringsInvalidAddressFormat();\n        return value;\n    }\n\n    /**\n     * @dev Variant of {parseAddress-string} that returns false if the parsing fails because the input is not a properly\n     * formatted address. See {parseAddress} requirements.\n     */\n    function tryParseAddress(string memory input) internal pure returns (bool success, address value) {\n        return tryParseAddress(input, 0, bytes(input).length);\n    }\n\n    /**\n     * @dev Variant of {parseAddress-string-uint256-uint256} that returns false if the parsing fails because input is not a properly\n     * formatted address. See {parseAddress} requirements.\n     */\n    function tryParseAddress(\n        string memory input,\n        uint256 begin,\n        uint256 end\n    ) internal pure returns (bool success, address value) {\n        if (end > bytes(input).length || begin > end) return (false, address(0));\n\n        bool hasPrefix = (end > begin + 1) && bytes2(_unsafeReadBytesOffset(bytes(input), begin)) == bytes2(\"0x\"); // don't do out-of-bound (possibly unsafe) read if sub-string is empty\n        uint256 expectedLength = 40 + hasPrefix.toUint() * 2;\n\n        // check that input is the correct length\n        if (end - begin == expectedLength) {\n            // length guarantees that this does not overflow, and value is at most type(uint160).max\n            (bool s, uint256 v) = _tryParseHexUintUncheckedBounds(input, begin, end);\n            return (s, address(uint160(v)));\n        } else {\n            return (false, address(0));\n        }\n    }\n\n    function _tryParseChr(bytes1 chr) private pure returns (uint8) {\n        uint8 value = uint8(chr);\n\n        // Try to parse `chr`:\n        // - Case 1: [0-9]\n        // - Case 2: [a-f]\n        // - Case 3: [A-F]\n        // - otherwise not supported\n        unchecked {\n            if (value > 47 && value < 58) value -= 48;\n            else if (value > 96 && value < 103) value -= 87;\n            else if (value > 64 && value < 71) value -= 55;\n            else return type(uint8).max;\n        }\n\n        return value;\n    }\n\n    /**\n     * @dev Reads a bytes32 from a bytes array without bounds checking.\n     *\n     * NOTE: making this function internal would mean it could be used with memory unsafe offset, and marking the\n     * assembly block as such would prevent some optimizations.\n     */\n    function _unsafeReadBytesOffset(bytes memory buffer, uint256 offset) private pure returns (bytes32 value) {\n        // This is not memory safe in the general case, but all calls to this private function are within bounds.\n        assembly (\"memory-safe\") {\n            value := mload(add(buffer, add(0x20, offset)))\n        }\n    }\n}\n"},{"file_path":"node_modules/@openzeppelin/contracts/utils/cryptography/ECDSA.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.1.0) (utils/cryptography/ECDSA.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.\n *\n * These functions can be used to verify that a message was signed by the holder\n * of the private keys of a given address.\n */\nlibrary ECDSA {\n    enum RecoverError {\n        NoError,\n        InvalidSignature,\n        InvalidSignatureLength,\n        InvalidSignatureS\n    }\n\n    /**\n     * @dev The signature derives the `address(0)`.\n     */\n    error ECDSAInvalidSignature();\n\n    /**\n     * @dev The signature has an invalid length.\n     */\n    error ECDSAInvalidSignatureLength(uint256 length);\n\n    /**\n     * @dev The signature has an S value that is in the upper half order.\n     */\n    error ECDSAInvalidSignatureS(bytes32 s);\n\n    /**\n     * @dev Returns the address that signed a hashed message (`hash`) with `signature` or an error. This will not\n     * return address(0) without also returning an error description. Errors are documented using an enum (error type)\n     * and a bytes32 providing additional information about the error.\n     *\n     * If no error is returned, then the address can be used for verification purposes.\n     *\n     * The `ecrecover` EVM precompile allows for malleable (non-unique) signatures:\n     * this function rejects them by requiring the `s` value to be in the lower\n     * half order, and the `v` value to be either 27 or 28.\n     *\n     * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n     * verification to be secure: it is possible to craft signatures that\n     * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n     * this is by receiving a hash of the original message (which may otherwise\n     * be too long), and then calling {MessageHashUtils-toEthSignedMessageHash} on it.\n     *\n     * Documentation for signature generation:\n     * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]\n     * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]\n     */\n    function tryRecover(\n        bytes32 hash,\n        bytes memory signature\n    ) internal pure returns (address recovered, RecoverError err, bytes32 errArg) {\n        if (signature.length == 65) {\n            bytes32 r;\n            bytes32 s;\n            uint8 v;\n            // ecrecover takes the signature parameters, and the only way to get them\n            // currently is to use assembly.\n            assembly (\"memory-safe\") {\n                r := mload(add(signature, 0x20))\n                s := mload(add(signature, 0x40))\n                v := byte(0, mload(add(signature, 0x60)))\n            }\n            return tryRecover(hash, v, r, s);\n        } else {\n            return (address(0), RecoverError.InvalidSignatureLength, bytes32(signature.length));\n        }\n    }\n\n    /**\n     * @dev Returns the address that signed a hashed message (`hash`) with\n     * `signature`. This address can then be used for verification purposes.\n     *\n     * The `ecrecover` EVM precompile allows for malleable (non-unique) signatures:\n     * this function rejects them by requiring the `s` value to be in the lower\n     * half order, and the `v` value to be either 27 or 28.\n     *\n     * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n     * verification to be secure: it is possible to craft signatures that\n     * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n     * this is by receiving a hash of the original message (which may otherwise\n     * be too long), and then calling {MessageHashUtils-toEthSignedMessageHash} on it.\n     */\n    function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {\n        (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, signature);\n        _throwError(error, errorArg);\n        return recovered;\n    }\n\n    /**\n     * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.\n     *\n     * See https://eips.ethereum.org/EIPS/eip-2098[ERC-2098 short signatures]\n     */\n    function tryRecover(\n        bytes32 hash,\n        bytes32 r,\n        bytes32 vs\n    ) internal pure returns (address recovered, RecoverError err, bytes32 errArg) {\n        unchecked {\n            bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);\n            // We do not check for an overflow here since the shift operation results in 0 or 1.\n            uint8 v = uint8((uint256(vs) >> 255) + 27);\n            return tryRecover(hash, v, r, s);\n        }\n    }\n\n    /**\n     * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.\n     */\n    function recover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address) {\n        (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, r, vs);\n        _throwError(error, errorArg);\n        return recovered;\n    }\n\n    /**\n     * @dev Overload of {ECDSA-tryRecover} that receives the `v`,\n     * `r` and `s` signature fields separately.\n     */\n    function tryRecover(\n        bytes32 hash,\n        uint8 v,\n        bytes32 r,\n        bytes32 s\n    ) internal pure returns (address recovered, RecoverError err, bytes32 errArg) {\n        // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature\n        // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines\n        // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most\n        // signatures from current libraries generate a unique signature with an s-value in the lower half order.\n        //\n        // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value\n        // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or\n        // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept\n        // these malleable signatures as well.\n        if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {\n            return (address(0), RecoverError.InvalidSignatureS, s);\n        }\n\n        // If the signature is valid (and not malleable), return the signer address\n        address signer = ecrecover(hash, v, r, s);\n        if (signer == address(0)) {\n            return (address(0), RecoverError.InvalidSignature, bytes32(0));\n        }\n\n        return (signer, RecoverError.NoError, bytes32(0));\n    }\n\n    /**\n     * @dev Overload of {ECDSA-recover} that receives the `v`,\n     * `r` and `s` signature fields separately.\n     */\n    function recover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address) {\n        (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, v, r, s);\n        _throwError(error, errorArg);\n        return recovered;\n    }\n\n    /**\n     * @dev Optionally reverts with the corresponding custom error according to the `error` argument provided.\n     */\n    function _throwError(RecoverError error, bytes32 errorArg) private pure {\n        if (error == RecoverError.NoError) {\n            return; // no error: do nothing\n        } else if (error == RecoverError.InvalidSignature) {\n            revert ECDSAInvalidSignature();\n        } else if (error == RecoverError.InvalidSignatureLength) {\n            revert ECDSAInvalidSignatureLength(uint256(errorArg));\n        } else if (error == RecoverError.InvalidSignatureS) {\n            revert ECDSAInvalidSignatureS(errorArg);\n        }\n    }\n}\n"},{"file_path":"node_modules/@openzeppelin/contracts/utils/cryptography/MessageHashUtils.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.1.0) (utils/cryptography/MessageHashUtils.sol)\n\npragma solidity ^0.8.20;\n\nimport {Strings} from \"../Strings.sol\";\n\n/**\n * @dev Signature message hash utilities for producing digests to be consumed by {ECDSA} recovery or signing.\n *\n * The library provides methods for generating a hash of a message that conforms to the\n * https://eips.ethereum.org/EIPS/eip-191[ERC-191] and https://eips.ethereum.org/EIPS/eip-712[EIP 712]\n * specifications.\n */\nlibrary MessageHashUtils {\n    /**\n     * @dev Returns the keccak256 digest of an ERC-191 signed data with version\n     * `0x45` (`personal_sign` messages).\n     *\n     * The digest is calculated by prefixing a bytes32 `messageHash` with\n     * `\"\\x19Ethereum Signed Message:\\n32\"` and hashing the result. It corresponds with the\n     * hash signed when using the https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] JSON-RPC method.\n     *\n     * NOTE: The `messageHash` parameter is intended to be the result of hashing a raw message with\n     * keccak256, although any bytes32 value can be safely used because the final digest will\n     * be re-hashed.\n     *\n     * See {ECDSA-recover}.\n     */\n    function toEthSignedMessageHash(bytes32 messageHash) internal pure returns (bytes32 digest) {\n        assembly (\"memory-safe\") {\n            mstore(0x00, \"\\x19Ethereum Signed Message:\\n32\") // 32 is the bytes-length of messageHash\n            mstore(0x1c, messageHash) // 0x1c (28) is the length of the prefix\n            digest := keccak256(0x00, 0x3c) // 0x3c is the length of the prefix (0x1c) + messageHash (0x20)\n        }\n    }\n\n    /**\n     * @dev Returns the keccak256 digest of an ERC-191 signed data with version\n     * `0x45` (`personal_sign` messages).\n     *\n     * The digest is calculated by prefixing an arbitrary `message` with\n     * `\"\\x19Ethereum Signed Message:\\n\" + len(message)` and hashing the result. It corresponds with the\n     * hash signed when using the https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] JSON-RPC method.\n     *\n     * See {ECDSA-recover}.\n     */\n    function toEthSignedMessageHash(bytes memory message) internal pure returns (bytes32) {\n        return\n            keccak256(bytes.concat(\"\\x19Ethereum Signed Message:\\n\", bytes(Strings.toString(message.length)), message));\n    }\n\n    /**\n     * @dev Returns the keccak256 digest of an ERC-191 signed data with version\n     * `0x00` (data with intended validator).\n     *\n     * The digest is calculated by prefixing an arbitrary `data` with `\"\\x19\\x00\"` and the intended\n     * `validator` address. Then hashing the result.\n     *\n     * See {ECDSA-recover}.\n     */\n    function toDataWithIntendedValidatorHash(address validator, bytes memory data) internal pure returns (bytes32) {\n        return keccak256(abi.encodePacked(hex\"19_00\", validator, data));\n    }\n\n    /**\n     * @dev Returns the keccak256 digest of an EIP-712 typed data (ERC-191 version `0x01`).\n     *\n     * The digest is calculated from a `domainSeparator` and a `structHash`, by prefixing them with\n     * `\\x19\\x01` and hashing the result. It corresponds to the hash signed by the\n     * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`] JSON-RPC method as part of EIP-712.\n     *\n     * See {ECDSA-recover}.\n     */\n    function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32 digest) {\n        assembly (\"memory-safe\") {\n            let ptr := mload(0x40)\n            mstore(ptr, hex\"19_01\")\n            mstore(add(ptr, 0x02), domainSeparator)\n            mstore(add(ptr, 0x22), structHash)\n            digest := keccak256(ptr, 0x42)\n        }\n    }\n}\n"},{"file_path":"node_modules/@openzeppelin/contracts/utils/introspection/ERC165.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.1.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 ERC-165 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"},{"file_path":"node_modules/@openzeppelin/contracts/utils/introspection/IERC165.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.1.0) (utils/introspection/IERC165.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Interface of the ERC-165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[ERC].\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[ERC 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"},{"file_path":"node_modules/@openzeppelin/contracts/utils/math/Math.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.1.0) (utils/math/Math.sol)\n\npragma solidity ^0.8.20;\n\nimport {Panic} from \"../Panic.sol\";\nimport {SafeCast} from \"./SafeCast.sol\";\n\n/**\n * @dev Standard math utilities missing in the Solidity language.\n */\nlibrary Math {\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 success flag (no overflow).\n     */\n    function tryAdd(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {\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 success flag (no overflow).\n     */\n    function trySub(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {\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 success flag (no overflow).\n     */\n    function tryMul(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {\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 success flag (no division by zero).\n     */\n    function tryDiv(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {\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 success flag (no division by zero).\n     */\n    function tryMod(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {\n        unchecked {\n            if (b == 0) return (false, 0);\n            return (true, a % b);\n        }\n    }\n\n    /**\n     * @dev Branchless ternary evaluation for `a ? b : c`. Gas costs are constant.\n     *\n     * IMPORTANT: This function may reduce bytecode size and consume less gas when used standalone.\n     * However, the compiler may optimize Solidity ternary operations (i.e. `a ? b : c`) to only compute\n     * one branch when needed, making this function more expensive.\n     */\n    function ternary(bool condition, uint256 a, uint256 b) internal pure returns (uint256) {\n        unchecked {\n            // branchless ternary works because:\n            // b ^ (a ^ b) == a\n            // b ^ 0 == b\n            return b ^ ((a ^ b) * SafeCast.toUint(condition));\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 ternary(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 ternary(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            Panic.panic(Panic.DIVISION_BY_ZERO);\n        }\n\n        // The following calculation ensures accurate ceiling division without overflow.\n        // Since a is non-zero, (a - 1) / b will not overflow.\n        // The largest possible result occurs when (a - 1) / b is type(uint256).max,\n        // but the largest value we can obtain is type(uint256).max - 1, which happens\n        // when a = type(uint256).max and b = 1.\n        unchecked {\n            return SafeCast.toUint(a > 0) * ((a - 1) / b + 1);\n        }\n    }\n\n    /**\n     * @dev Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or\n     * denominator == 0.\n     *\n     * 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²⁵⁶ and mod 2²⁵⁶ - 1, then use\n            // the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256\n            // variables such that product = prod1 * 2²⁵⁶ + 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²⁵⁶. Also prevents denominator == 0.\n            if (denominator <= prod1) {\n                Panic.panic(ternary(denominator == 0, Panic.DIVISION_BY_ZERO, Panic.UNDER_OVERFLOW));\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²⁵⁶ / 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²⁵⁶. Now that denominator is an odd number, it has an inverse modulo 2²⁵⁶ such\n            // that denominator * inv ≡ 1 mod 2²⁵⁶. Compute the inverse by starting with a seed that is correct for\n            // four bits. That is, denominator * inv ≡ 1 mod 2⁴.\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⁸\n            inverse *= 2 - denominator * inverse; // inverse mod 2¹⁶\n            inverse *= 2 - denominator * inverse; // inverse mod 2³²\n            inverse *= 2 - denominator * inverse; // inverse mod 2⁶⁴\n            inverse *= 2 - denominator * inverse; // inverse mod 2¹²⁸\n            inverse *= 2 - denominator * inverse; // inverse mod 2²⁵⁶\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²⁵⁶. Since the preconditions guarantee that the outcome is\n            // less than 2²⁵⁶, 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     * @dev 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        return mulDiv(x, y, denominator) + SafeCast.toUint(unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0);\n    }\n\n    /**\n     * @dev Calculate the modular multiplicative inverse of a number in Z/nZ.\n     *\n     * If n is a prime, then Z/nZ is a field. In that case all elements are inversible, except 0.\n     * If n is not a prime, then Z/nZ is not a field, and some elements might not be inversible.\n     *\n     * If the input value is not inversible, 0 is returned.\n     *\n     * NOTE: If you know for sure that n is (big) a prime, it may be cheaper to use Fermat's little theorem and get the\n     * inverse using `Math.modExp(a, n - 2, n)`. See {invModPrime}.\n     */\n    function invMod(uint256 a, uint256 n) internal pure returns (uint256) {\n        unchecked {\n            if (n == 0) return 0;\n\n            // The inverse modulo is calculated using the Extended Euclidean Algorithm (iterative version)\n            // Used to compute integers x and y such that: ax + ny = gcd(a, n).\n            // When the gcd is 1, then the inverse of a modulo n exists and it's x.\n            // ax + ny = 1\n            // ax = 1 + (-y)n\n            // ax ≡ 1 (mod n) # x is the inverse of a modulo n\n\n            // If the remainder is 0 the gcd is n right away.\n            uint256 remainder = a % n;\n            uint256 gcd = n;\n\n            // Therefore the initial coefficients are:\n            // ax + ny = gcd(a, n) = n\n            // 0a + 1n = n\n            int256 x = 0;\n            int256 y = 1;\n\n            while (remainder != 0) {\n                uint256 quotient = gcd / remainder;\n\n                (gcd, remainder) = (\n                    // The old remainder is the next gcd to try.\n                    remainder,\n                    // Compute the next remainder.\n                    // Can't overflow given that (a % gcd) * (gcd // (a % gcd)) <= gcd\n                    // where gcd is at most n (capped to type(uint256).max)\n                    gcd - remainder * quotient\n                );\n\n                (x, y) = (\n                    // Increment the coefficient of a.\n                    y,\n                    // Decrement the coefficient of n.\n                    // Can overflow, but the result is casted to uint256 so that the\n                    // next value of y is \"wrapped around\" to a value between 0 and n - 1.\n                    x - y * int256(quotient)\n                );\n            }\n\n            if (gcd != 1) return 0; // No inverse exists.\n            return ternary(x < 0, n - uint256(-x), uint256(x)); // Wrap the result if it's negative.\n        }\n    }\n\n    /**\n     * @dev Variant of {invMod}. More efficient, but only works if `p` is known to be a prime greater than `2`.\n     *\n     * From https://en.wikipedia.org/wiki/Fermat%27s_little_theorem[Fermat's little theorem], we know that if p is\n     * prime, then `a**(p-1) ≡ 1 mod p`. As a consequence, we have `a * a**(p-2) ≡ 1 mod p`, which means that\n     * `a**(p-2)` is the modular multiplicative inverse of a in Fp.\n     *\n     * NOTE: this function does NOT check that `p` is a prime greater than `2`.\n     */\n    function invModPrime(uint256 a, uint256 p) internal view returns (uint256) {\n        unchecked {\n            return Math.modExp(a, p - 2, p);\n        }\n    }\n\n    /**\n     * @dev Returns the modular exponentiation of the specified base, exponent and modulus (b ** e % m)\n     *\n     * Requirements:\n     * - modulus can't be zero\n     * - underlying staticcall to precompile must succeed\n     *\n     * IMPORTANT: The result is only valid if the underlying call succeeds. When using this function, make\n     * sure the chain you're using it on supports the precompiled contract for modular exponentiation\n     * at address 0x05 as specified in https://eips.ethereum.org/EIPS/eip-198[EIP-198]. Otherwise,\n     * the underlying function will succeed given the lack of a revert, but the result may be incorrectly\n     * interpreted as 0.\n     */\n    function modExp(uint256 b, uint256 e, uint256 m) internal view returns (uint256) {\n        (bool success, uint256 result) = tryModExp(b, e, m);\n        if (!success) {\n            Panic.panic(Panic.DIVISION_BY_ZERO);\n        }\n        return result;\n    }\n\n    /**\n     * @dev Returns the modular exponentiation of the specified base, exponent and modulus (b ** e % m).\n     * It includes a success flag indicating if the operation succeeded. Operation will be marked as failed if trying\n     * to operate modulo 0 or if the underlying precompile reverted.\n     *\n     * IMPORTANT: The result is only valid if the success flag is true. When using this function, make sure the chain\n     * you're using it on supports the precompiled contract for modular exponentiation at address 0x05 as specified in\n     * https://eips.ethereum.org/EIPS/eip-198[EIP-198]. Otherwise, the underlying function will succeed given the lack\n     * of a revert, but the result may be incorrectly interpreted as 0.\n     */\n    function tryModExp(uint256 b, uint256 e, uint256 m) internal view returns (bool success, uint256 result) {\n        if (m == 0) return (false, 0);\n        assembly (\"memory-safe\") {\n            let ptr := mload(0x40)\n            // | Offset    | Content    | Content (Hex)                                                      |\n            // |-----------|------------|--------------------------------------------------------------------|\n            // | 0x00:0x1f | size of b  | 0x0000000000000000000000000000000000000000000000000000000000000020 |\n            // | 0x20:0x3f | size of e  | 0x0000000000000000000000000000000000000000000000000000000000000020 |\n            // | 0x40:0x5f | size of m  | 0x0000000000000000000000000000000000000000000000000000000000000020 |\n            // | 0x60:0x7f | value of b | 0x<.............................................................b> |\n            // | 0x80:0x9f | value of e | 0x<.............................................................e> |\n            // | 0xa0:0xbf | value of m | 0x<.............................................................m> |\n            mstore(ptr, 0x20)\n            mstore(add(ptr, 0x20), 0x20)\n            mstore(add(ptr, 0x40), 0x20)\n            mstore(add(ptr, 0x60), b)\n            mstore(add(ptr, 0x80), e)\n            mstore(add(ptr, 0xa0), m)\n\n            // Given the result < m, it's guaranteed to fit in 32 bytes,\n            // so we can use the memory scratch space located at offset 0.\n            success := staticcall(gas(), 0x05, ptr, 0xc0, 0x00, 0x20)\n            result := mload(0x00)\n        }\n    }\n\n    /**\n     * @dev Variant of {modExp} that supports inputs of arbitrary length.\n     */\n    function modExp(bytes memory b, bytes memory e, bytes memory m) internal view returns (bytes memory) {\n        (bool success, bytes memory result) = tryModExp(b, e, m);\n        if (!success) {\n            Panic.panic(Panic.DIVISION_BY_ZERO);\n        }\n        return result;\n    }\n\n    /**\n     * @dev Variant of {tryModExp} that supports inputs of arbitrary length.\n     */\n    function tryModExp(\n        bytes memory b,\n        bytes memory e,\n        bytes memory m\n    ) internal view returns (bool success, bytes memory result) {\n        if (_zeroBytes(m)) return (false, new bytes(0));\n\n        uint256 mLen = m.length;\n\n        // Encode call args in result and move the free memory pointer\n        result = abi.encodePacked(b.length, e.length, mLen, b, e, m);\n\n        assembly (\"memory-safe\") {\n            let dataPtr := add(result, 0x20)\n            // Write result on top of args to avoid allocating extra memory.\n            success := staticcall(gas(), 0x05, dataPtr, mload(result), dataPtr, mLen)\n            // Overwrite the length.\n            // result.length > returndatasize() is guaranteed because returndatasize() == m.length\n            mstore(result, mLen)\n            // Set the memory pointer after the returned data.\n            mstore(0x40, add(dataPtr, mLen))\n        }\n    }\n\n    /**\n     * @dev Returns whether the provided byte array is zero.\n     */\n    function _zeroBytes(bytes memory byteArray) private pure returns (bool) {\n        for (uint256 i = 0; i < byteArray.length; ++i) {\n            if (byteArray[i] != 0) {\n                return false;\n            }\n        }\n        return true;\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     * This method is based on Newton's method for computing square roots; the algorithm is restricted to only\n     * using integer operations.\n     */\n    function sqrt(uint256 a) internal pure returns (uint256) {\n        unchecked {\n            // Take care of easy edge cases when a == 0 or a == 1\n            if (a <= 1) {\n                return a;\n            }\n\n            // In this function, we use Newton's method to get a root of `f(x) := x² - a`. It involves building a\n            // sequence x_n that converges toward sqrt(a). For each iteration x_n, we also define the error between\n            // the current value as `ε_n = | x_n - sqrt(a) |`.\n            //\n            // For our first estimation, we consider `e` the smallest power of 2 which is bigger than the square root\n            // of the target. (i.e. `2**(e-1) ≤ sqrt(a) < 2**e`). We know that `e ≤ 128` because `(2¹²⁸)² = 2²⁵⁶` is\n            // bigger than any uint256.\n            //\n            // By noticing that\n            // `2**(e-1) ≤ sqrt(a) < 2**e → (2**(e-1))² ≤ a < (2**e)² → 2**(2*e-2) ≤ a < 2**(2*e)`\n            // we can deduce that `e - 1` is `log2(a) / 2`. We can thus compute `x_n = 2**(e-1)` using a method similar\n            // to the msb function.\n            uint256 aa = a;\n            uint256 xn = 1;\n\n            if (aa >= (1 << 128)) {\n                aa >>= 128;\n                xn <<= 64;\n            }\n            if (aa >= (1 << 64)) {\n                aa >>= 64;\n                xn <<= 32;\n            }\n            if (aa >= (1 << 32)) {\n                aa >>= 32;\n                xn <<= 16;\n            }\n            if (aa >= (1 << 16)) {\n                aa >>= 16;\n                xn <<= 8;\n            }\n            if (aa >= (1 << 8)) {\n                aa >>= 8;\n                xn <<= 4;\n            }\n            if (aa >= (1 << 4)) {\n                aa >>= 4;\n                xn <<= 2;\n            }\n            if (aa >= (1 << 2)) {\n                xn <<= 1;\n            }\n\n            // We now have x_n such that `x_n = 2**(e-1) ≤ sqrt(a) < 2**e = 2 * x_n`. This implies ε_n ≤ 2**(e-1).\n            //\n            // We can refine our estimation by noticing that the middle of that interval minimizes the error.\n            // If we move x_n to equal 2**(e-1) + 2**(e-2), then we reduce the error to ε_n ≤ 2**(e-2).\n            // This is going to be our x_0 (and ε_0)\n            xn = (3 * xn) >> 1; // ε_0 := | x_0 - sqrt(a) | ≤ 2**(e-2)\n\n            // From here, Newton's method give us:\n            // x_{n+1} = (x_n + a / x_n) / 2\n            //\n            // One should note that:\n            // x_{n+1}² - a = ((x_n + a / x_n) / 2)² - a\n            //              = ((x_n² + a) / (2 * x_n))² - a\n            //              = (x_n⁴ + 2 * a * x_n² + a²) / (4 * x_n²) - a\n            //              = (x_n⁴ + 2 * a * x_n² + a² - 4 * a * x_n²) / (4 * x_n²)\n            //              = (x_n⁴ - 2 * a * x_n² + a²) / (4 * x_n²)\n            //              = (x_n² - a)² / (2 * x_n)²\n            //              = ((x_n² - a) / (2 * x_n))²\n            //              ≥ 0\n            // Which proves that for all n ≥ 1, sqrt(a) ≤ x_n\n            //\n            // This gives us the proof of quadratic convergence of the sequence:\n            // ε_{n+1} = | x_{n+1} - sqrt(a) |\n            //         = | (x_n + a / x_n) / 2 - sqrt(a) |\n            //         = | (x_n² + a - 2*x_n*sqrt(a)) / (2 * x_n) |\n            //         = | (x_n - sqrt(a))² / (2 * x_n) |\n            //         = | ε_n² / (2 * x_n) |\n            //         = ε_n² / | (2 * x_n) |\n            //\n            // For the first iteration, we have a special case where x_0 is known:\n            // ε_1 = ε_0² / | (2 * x_0) |\n            //     ≤ (2**(e-2))² / (2 * (2**(e-1) + 2**(e-2)))\n            //     ≤ 2**(2*e-4) / (3 * 2**(e-1))\n            //     ≤ 2**(e-3) / 3\n            //     ≤ 2**(e-3-log2(3))\n            //     ≤ 2**(e-4.5)\n            //\n            // For the following iterations, we use the fact that, 2**(e-1) ≤ sqrt(a) ≤ x_n:\n            // ε_{n+1} = ε_n² / | (2 * x_n) |\n            //         ≤ (2**(e-k))² / (2 * 2**(e-1))\n            //         ≤ 2**(2*e-2*k) / 2**e\n            //         ≤ 2**(e-2*k)\n            xn = (xn + a / xn) >> 1; // ε_1 := | x_1 - sqrt(a) | ≤ 2**(e-4.5)  -- special case, see above\n            xn = (xn + a / xn) >> 1; // ε_2 := | x_2 - sqrt(a) | ≤ 2**(e-9)    -- general case with k = 4.5\n            xn = (xn + a / xn) >> 1; // ε_3 := | x_3 - sqrt(a) | ≤ 2**(e-18)   -- general case with k = 9\n            xn = (xn + a / xn) >> 1; // ε_4 := | x_4 - sqrt(a) | ≤ 2**(e-36)   -- general case with k = 18\n            xn = (xn + a / xn) >> 1; // ε_5 := | x_5 - sqrt(a) | ≤ 2**(e-72)   -- general case with k = 36\n            xn = (xn + a / xn) >> 1; // ε_6 := | x_6 - sqrt(a) | ≤ 2**(e-144)  -- general case with k = 72\n\n            // Because e ≤ 128 (as discussed during the first estimation phase), we know have reached a precision\n            // ε_6 ≤ 2**(e-144) < 1. Given we're operating on integers, then we can ensure that xn is now either\n            // sqrt(a) or sqrt(a) + 1.\n            return xn - SafeCast.toUint(xn > a / xn);\n        }\n    }\n\n    /**\n     * @dev 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 + SafeCast.toUint(unsignedRoundsUp(rounding) && result * result < a);\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        uint256 exp;\n        unchecked {\n            exp = 128 * SafeCast.toUint(value > (1 << 128) - 1);\n            value >>= exp;\n            result += exp;\n\n            exp = 64 * SafeCast.toUint(value > (1 << 64) - 1);\n            value >>= exp;\n            result += exp;\n\n            exp = 32 * SafeCast.toUint(value > (1 << 32) - 1);\n            value >>= exp;\n            result += exp;\n\n            exp = 16 * SafeCast.toUint(value > (1 << 16) - 1);\n            value >>= exp;\n            result += exp;\n\n            exp = 8 * SafeCast.toUint(value > (1 << 8) - 1);\n            value >>= exp;\n            result += exp;\n\n            exp = 4 * SafeCast.toUint(value > (1 << 4) - 1);\n            value >>= exp;\n            result += exp;\n\n            exp = 2 * SafeCast.toUint(value > (1 << 2) - 1);\n            value >>= exp;\n            result += exp;\n\n            result += SafeCast.toUint(value > 1);\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 + SafeCast.toUint(unsignedRoundsUp(rounding) && 1 << result < value);\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 + SafeCast.toUint(unsignedRoundsUp(rounding) && 10 ** result < value);\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        uint256 isGt;\n        unchecked {\n            isGt = SafeCast.toUint(value > (1 << 128) - 1);\n            value >>= isGt * 128;\n            result += isGt * 16;\n\n            isGt = SafeCast.toUint(value > (1 << 64) - 1);\n            value >>= isGt * 64;\n            result += isGt * 8;\n\n            isGt = SafeCast.toUint(value > (1 << 32) - 1);\n            value >>= isGt * 32;\n            result += isGt * 4;\n\n            isGt = SafeCast.toUint(value > (1 << 16) - 1);\n            value >>= isGt * 16;\n            result += isGt * 2;\n\n            result += SafeCast.toUint(value > (1 << 8) - 1);\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 + SafeCast.toUint(unsignedRoundsUp(rounding) && 1 << (result << 3) < value);\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"},{"file_path":"node_modules/@openzeppelin/contracts/utils/math/SafeCast.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.1.0) (utils/math/SafeCast.sol)\n// This file was procedurally generated from scripts/generate/templates/SafeCast.js.\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Wrappers over Solidity's uintXX/intXX/bool casting operators with added overflow\n * checks.\n *\n * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can\n * easily result in undesired exploitation or bugs, since developers usually\n * assume that overflows raise errors. `SafeCast` restores this intuition by\n * reverting the transaction when such an operation overflows.\n *\n * Using this library instead of the unchecked operations eliminates an entire\n * class of bugs, so it's recommended to use it always.\n */\nlibrary SafeCast {\n    /**\n     * @dev Value doesn't fit in an uint of `bits` size.\n     */\n    error SafeCastOverflowedUintDowncast(uint8 bits, uint256 value);\n\n    /**\n     * @dev An int value doesn't fit in an uint of `bits` size.\n     */\n    error SafeCastOverflowedIntToUint(int256 value);\n\n    /**\n     * @dev Value doesn't fit in an int of `bits` size.\n     */\n    error SafeCastOverflowedIntDowncast(uint8 bits, int256 value);\n\n    /**\n     * @dev An uint value doesn't fit in an int of `bits` size.\n     */\n    error SafeCastOverflowedUintToInt(uint256 value);\n\n    /**\n     * @dev Returns the downcasted uint248 from uint256, reverting on\n     * overflow (when the input is greater than largest uint248).\n     *\n     * Counterpart to Solidity's `uint248` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 248 bits\n     */\n    function toUint248(uint256 value) internal pure returns (uint248) {\n        if (value > type(uint248).max) {\n            revert SafeCastOverflowedUintDowncast(248, value);\n        }\n        return uint248(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint240 from uint256, reverting on\n     * overflow (when the input is greater than largest uint240).\n     *\n     * Counterpart to Solidity's `uint240` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 240 bits\n     */\n    function toUint240(uint256 value) internal pure returns (uint240) {\n        if (value > type(uint240).max) {\n            revert SafeCastOverflowedUintDowncast(240, value);\n        }\n        return uint240(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint232 from uint256, reverting on\n     * overflow (when the input is greater than largest uint232).\n     *\n     * Counterpart to Solidity's `uint232` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 232 bits\n     */\n    function toUint232(uint256 value) internal pure returns (uint232) {\n        if (value > type(uint232).max) {\n            revert SafeCastOverflowedUintDowncast(232, value);\n        }\n        return uint232(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint224 from uint256, reverting on\n     * overflow (when the input is greater than largest uint224).\n     *\n     * Counterpart to Solidity's `uint224` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 224 bits\n     */\n    function toUint224(uint256 value) internal pure returns (uint224) {\n        if (value > type(uint224).max) {\n            revert SafeCastOverflowedUintDowncast(224, value);\n        }\n        return uint224(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint216 from uint256, reverting on\n     * overflow (when the input is greater than largest uint216).\n     *\n     * Counterpart to Solidity's `uint216` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 216 bits\n     */\n    function toUint216(uint256 value) internal pure returns (uint216) {\n        if (value > type(uint216).max) {\n            revert SafeCastOverflowedUintDowncast(216, value);\n        }\n        return uint216(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint208 from uint256, reverting on\n     * overflow (when the input is greater than largest uint208).\n     *\n     * Counterpart to Solidity's `uint208` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 208 bits\n     */\n    function toUint208(uint256 value) internal pure returns (uint208) {\n        if (value > type(uint208).max) {\n            revert SafeCastOverflowedUintDowncast(208, value);\n        }\n        return uint208(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint200 from uint256, reverting on\n     * overflow (when the input is greater than largest uint200).\n     *\n     * Counterpart to Solidity's `uint200` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 200 bits\n     */\n    function toUint200(uint256 value) internal pure returns (uint200) {\n        if (value > type(uint200).max) {\n            revert SafeCastOverflowedUintDowncast(200, value);\n        }\n        return uint200(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint192 from uint256, reverting on\n     * overflow (when the input is greater than largest uint192).\n     *\n     * Counterpart to Solidity's `uint192` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 192 bits\n     */\n    function toUint192(uint256 value) internal pure returns (uint192) {\n        if (value > type(uint192).max) {\n            revert SafeCastOverflowedUintDowncast(192, value);\n        }\n        return uint192(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint184 from uint256, reverting on\n     * overflow (when the input is greater than largest uint184).\n     *\n     * Counterpart to Solidity's `uint184` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 184 bits\n     */\n    function toUint184(uint256 value) internal pure returns (uint184) {\n        if (value > type(uint184).max) {\n            revert SafeCastOverflowedUintDowncast(184, value);\n        }\n        return uint184(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint176 from uint256, reverting on\n     * overflow (when the input is greater than largest uint176).\n     *\n     * Counterpart to Solidity's `uint176` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 176 bits\n     */\n    function toUint176(uint256 value) internal pure returns (uint176) {\n        if (value > type(uint176).max) {\n            revert SafeCastOverflowedUintDowncast(176, value);\n        }\n        return uint176(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint168 from uint256, reverting on\n     * overflow (when the input is greater than largest uint168).\n     *\n     * Counterpart to Solidity's `uint168` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 168 bits\n     */\n    function toUint168(uint256 value) internal pure returns (uint168) {\n        if (value > type(uint168).max) {\n            revert SafeCastOverflowedUintDowncast(168, value);\n        }\n        return uint168(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint160 from uint256, reverting on\n     * overflow (when the input is greater than largest uint160).\n     *\n     * Counterpart to Solidity's `uint160` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 160 bits\n     */\n    function toUint160(uint256 value) internal pure returns (uint160) {\n        if (value > type(uint160).max) {\n            revert SafeCastOverflowedUintDowncast(160, value);\n        }\n        return uint160(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint152 from uint256, reverting on\n     * overflow (when the input is greater than largest uint152).\n     *\n     * Counterpart to Solidity's `uint152` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 152 bits\n     */\n    function toUint152(uint256 value) internal pure returns (uint152) {\n        if (value > type(uint152).max) {\n            revert SafeCastOverflowedUintDowncast(152, value);\n        }\n        return uint152(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint144 from uint256, reverting on\n     * overflow (when the input is greater than largest uint144).\n     *\n     * Counterpart to Solidity's `uint144` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 144 bits\n     */\n    function toUint144(uint256 value) internal pure returns (uint144) {\n        if (value > type(uint144).max) {\n            revert SafeCastOverflowedUintDowncast(144, value);\n        }\n        return uint144(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint136 from uint256, reverting on\n     * overflow (when the input is greater than largest uint136).\n     *\n     * Counterpart to Solidity's `uint136` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 136 bits\n     */\n    function toUint136(uint256 value) internal pure returns (uint136) {\n        if (value > type(uint136).max) {\n            revert SafeCastOverflowedUintDowncast(136, value);\n        }\n        return uint136(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint128 from uint256, reverting on\n     * overflow (when the input is greater than largest uint128).\n     *\n     * Counterpart to Solidity's `uint128` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 128 bits\n     */\n    function toUint128(uint256 value) internal pure returns (uint128) {\n        if (value > type(uint128).max) {\n            revert SafeCastOverflowedUintDowncast(128, value);\n        }\n        return uint128(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint120 from uint256, reverting on\n     * overflow (when the input is greater than largest uint120).\n     *\n     * Counterpart to Solidity's `uint120` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 120 bits\n     */\n    function toUint120(uint256 value) internal pure returns (uint120) {\n        if (value > type(uint120).max) {\n            revert SafeCastOverflowedUintDowncast(120, value);\n        }\n        return uint120(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint112 from uint256, reverting on\n     * overflow (when the input is greater than largest uint112).\n     *\n     * Counterpart to Solidity's `uint112` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 112 bits\n     */\n    function toUint112(uint256 value) internal pure returns (uint112) {\n        if (value > type(uint112).max) {\n            revert SafeCastOverflowedUintDowncast(112, value);\n        }\n        return uint112(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint104 from uint256, reverting on\n     * overflow (when the input is greater than largest uint104).\n     *\n     * Counterpart to Solidity's `uint104` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 104 bits\n     */\n    function toUint104(uint256 value) internal pure returns (uint104) {\n        if (value > type(uint104).max) {\n            revert SafeCastOverflowedUintDowncast(104, value);\n        }\n        return uint104(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint96 from uint256, reverting on\n     * overflow (when the input is greater than largest uint96).\n     *\n     * Counterpart to Solidity's `uint96` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 96 bits\n     */\n    function toUint96(uint256 value) internal pure returns (uint96) {\n        if (value > type(uint96).max) {\n            revert SafeCastOverflowedUintDowncast(96, value);\n        }\n        return uint96(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint88 from uint256, reverting on\n     * overflow (when the input is greater than largest uint88).\n     *\n     * Counterpart to Solidity's `uint88` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 88 bits\n     */\n    function toUint88(uint256 value) internal pure returns (uint88) {\n        if (value > type(uint88).max) {\n            revert SafeCastOverflowedUintDowncast(88, value);\n        }\n        return uint88(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint80 from uint256, reverting on\n     * overflow (when the input is greater than largest uint80).\n     *\n     * Counterpart to Solidity's `uint80` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 80 bits\n     */\n    function toUint80(uint256 value) internal pure returns (uint80) {\n        if (value > type(uint80).max) {\n            revert SafeCastOverflowedUintDowncast(80, value);\n        }\n        return uint80(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint72 from uint256, reverting on\n     * overflow (when the input is greater than largest uint72).\n     *\n     * Counterpart to Solidity's `uint72` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 72 bits\n     */\n    function toUint72(uint256 value) internal pure returns (uint72) {\n        if (value > type(uint72).max) {\n            revert SafeCastOverflowedUintDowncast(72, value);\n        }\n        return uint72(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint64 from uint256, reverting on\n     * overflow (when the input is greater than largest uint64).\n     *\n     * Counterpart to Solidity's `uint64` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 64 bits\n     */\n    function toUint64(uint256 value) internal pure returns (uint64) {\n        if (value > type(uint64).max) {\n            revert SafeCastOverflowedUintDowncast(64, value);\n        }\n        return uint64(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint56 from uint256, reverting on\n     * overflow (when the input is greater than largest uint56).\n     *\n     * Counterpart to Solidity's `uint56` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 56 bits\n     */\n    function toUint56(uint256 value) internal pure returns (uint56) {\n        if (value > type(uint56).max) {\n            revert SafeCastOverflowedUintDowncast(56, value);\n        }\n        return uint56(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint48 from uint256, reverting on\n     * overflow (when the input is greater than largest uint48).\n     *\n     * Counterpart to Solidity's `uint48` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 48 bits\n     */\n    function toUint48(uint256 value) internal pure returns (uint48) {\n        if (value > type(uint48).max) {\n            revert SafeCastOverflowedUintDowncast(48, value);\n        }\n        return uint48(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint40 from uint256, reverting on\n     * overflow (when the input is greater than largest uint40).\n     *\n     * Counterpart to Solidity's `uint40` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 40 bits\n     */\n    function toUint40(uint256 value) internal pure returns (uint40) {\n        if (value > type(uint40).max) {\n            revert SafeCastOverflowedUintDowncast(40, value);\n        }\n        return uint40(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint32 from uint256, reverting on\n     * overflow (when the input is greater than largest uint32).\n     *\n     * Counterpart to Solidity's `uint32` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 32 bits\n     */\n    function toUint32(uint256 value) internal pure returns (uint32) {\n        if (value > type(uint32).max) {\n            revert SafeCastOverflowedUintDowncast(32, value);\n        }\n        return uint32(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint24 from uint256, reverting on\n     * overflow (when the input is greater than largest uint24).\n     *\n     * Counterpart to Solidity's `uint24` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 24 bits\n     */\n    function toUint24(uint256 value) internal pure returns (uint24) {\n        if (value > type(uint24).max) {\n            revert SafeCastOverflowedUintDowncast(24, value);\n        }\n        return uint24(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint16 from uint256, reverting on\n     * overflow (when the input is greater than largest uint16).\n     *\n     * Counterpart to Solidity's `uint16` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 16 bits\n     */\n    function toUint16(uint256 value) internal pure returns (uint16) {\n        if (value > type(uint16).max) {\n            revert SafeCastOverflowedUintDowncast(16, value);\n        }\n        return uint16(value);\n    }\n\n    /**\n     * @dev Returns the downcasted uint8 from uint256, reverting on\n     * overflow (when the input is greater than largest uint8).\n     *\n     * Counterpart to Solidity's `uint8` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 8 bits\n     */\n    function toUint8(uint256 value) internal pure returns (uint8) {\n        if (value > type(uint8).max) {\n            revert SafeCastOverflowedUintDowncast(8, value);\n        }\n        return uint8(value);\n    }\n\n    /**\n     * @dev Converts a signed int256 into an unsigned uint256.\n     *\n     * Requirements:\n     *\n     * - input must be greater than or equal to 0.\n     */\n    function toUint256(int256 value) internal pure returns (uint256) {\n        if (value < 0) {\n            revert SafeCastOverflowedIntToUint(value);\n        }\n        return uint256(value);\n    }\n\n    /**\n     * @dev Returns the downcasted int248 from int256, reverting on\n     * overflow (when the input is less than smallest int248 or\n     * greater than largest int248).\n     *\n     * Counterpart to Solidity's `int248` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 248 bits\n     */\n    function toInt248(int256 value) internal pure returns (int248 downcasted) {\n        downcasted = int248(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(248, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int240 from int256, reverting on\n     * overflow (when the input is less than smallest int240 or\n     * greater than largest int240).\n     *\n     * Counterpart to Solidity's `int240` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 240 bits\n     */\n    function toInt240(int256 value) internal pure returns (int240 downcasted) {\n        downcasted = int240(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(240, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int232 from int256, reverting on\n     * overflow (when the input is less than smallest int232 or\n     * greater than largest int232).\n     *\n     * Counterpart to Solidity's `int232` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 232 bits\n     */\n    function toInt232(int256 value) internal pure returns (int232 downcasted) {\n        downcasted = int232(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(232, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int224 from int256, reverting on\n     * overflow (when the input is less than smallest int224 or\n     * greater than largest int224).\n     *\n     * Counterpart to Solidity's `int224` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 224 bits\n     */\n    function toInt224(int256 value) internal pure returns (int224 downcasted) {\n        downcasted = int224(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(224, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int216 from int256, reverting on\n     * overflow (when the input is less than smallest int216 or\n     * greater than largest int216).\n     *\n     * Counterpart to Solidity's `int216` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 216 bits\n     */\n    function toInt216(int256 value) internal pure returns (int216 downcasted) {\n        downcasted = int216(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(216, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int208 from int256, reverting on\n     * overflow (when the input is less than smallest int208 or\n     * greater than largest int208).\n     *\n     * Counterpart to Solidity's `int208` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 208 bits\n     */\n    function toInt208(int256 value) internal pure returns (int208 downcasted) {\n        downcasted = int208(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(208, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int200 from int256, reverting on\n     * overflow (when the input is less than smallest int200 or\n     * greater than largest int200).\n     *\n     * Counterpart to Solidity's `int200` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 200 bits\n     */\n    function toInt200(int256 value) internal pure returns (int200 downcasted) {\n        downcasted = int200(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(200, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int192 from int256, reverting on\n     * overflow (when the input is less than smallest int192 or\n     * greater than largest int192).\n     *\n     * Counterpart to Solidity's `int192` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 192 bits\n     */\n    function toInt192(int256 value) internal pure returns (int192 downcasted) {\n        downcasted = int192(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(192, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int184 from int256, reverting on\n     * overflow (when the input is less than smallest int184 or\n     * greater than largest int184).\n     *\n     * Counterpart to Solidity's `int184` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 184 bits\n     */\n    function toInt184(int256 value) internal pure returns (int184 downcasted) {\n        downcasted = int184(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(184, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int176 from int256, reverting on\n     * overflow (when the input is less than smallest int176 or\n     * greater than largest int176).\n     *\n     * Counterpart to Solidity's `int176` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 176 bits\n     */\n    function toInt176(int256 value) internal pure returns (int176 downcasted) {\n        downcasted = int176(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(176, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int168 from int256, reverting on\n     * overflow (when the input is less than smallest int168 or\n     * greater than largest int168).\n     *\n     * Counterpart to Solidity's `int168` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 168 bits\n     */\n    function toInt168(int256 value) internal pure returns (int168 downcasted) {\n        downcasted = int168(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(168, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int160 from int256, reverting on\n     * overflow (when the input is less than smallest int160 or\n     * greater than largest int160).\n     *\n     * Counterpart to Solidity's `int160` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 160 bits\n     */\n    function toInt160(int256 value) internal pure returns (int160 downcasted) {\n        downcasted = int160(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(160, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int152 from int256, reverting on\n     * overflow (when the input is less than smallest int152 or\n     * greater than largest int152).\n     *\n     * Counterpart to Solidity's `int152` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 152 bits\n     */\n    function toInt152(int256 value) internal pure returns (int152 downcasted) {\n        downcasted = int152(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(152, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int144 from int256, reverting on\n     * overflow (when the input is less than smallest int144 or\n     * greater than largest int144).\n     *\n     * Counterpart to Solidity's `int144` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 144 bits\n     */\n    function toInt144(int256 value) internal pure returns (int144 downcasted) {\n        downcasted = int144(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(144, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int136 from int256, reverting on\n     * overflow (when the input is less than smallest int136 or\n     * greater than largest int136).\n     *\n     * Counterpart to Solidity's `int136` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 136 bits\n     */\n    function toInt136(int256 value) internal pure returns (int136 downcasted) {\n        downcasted = int136(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(136, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int128 from int256, reverting on\n     * overflow (when the input is less than smallest int128 or\n     * greater than largest int128).\n     *\n     * Counterpart to Solidity's `int128` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 128 bits\n     */\n    function toInt128(int256 value) internal pure returns (int128 downcasted) {\n        downcasted = int128(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(128, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int120 from int256, reverting on\n     * overflow (when the input is less than smallest int120 or\n     * greater than largest int120).\n     *\n     * Counterpart to Solidity's `int120` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 120 bits\n     */\n    function toInt120(int256 value) internal pure returns (int120 downcasted) {\n        downcasted = int120(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(120, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int112 from int256, reverting on\n     * overflow (when the input is less than smallest int112 or\n     * greater than largest int112).\n     *\n     * Counterpart to Solidity's `int112` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 112 bits\n     */\n    function toInt112(int256 value) internal pure returns (int112 downcasted) {\n        downcasted = int112(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(112, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int104 from int256, reverting on\n     * overflow (when the input is less than smallest int104 or\n     * greater than largest int104).\n     *\n     * Counterpart to Solidity's `int104` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 104 bits\n     */\n    function toInt104(int256 value) internal pure returns (int104 downcasted) {\n        downcasted = int104(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(104, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int96 from int256, reverting on\n     * overflow (when the input is less than smallest int96 or\n     * greater than largest int96).\n     *\n     * Counterpart to Solidity's `int96` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 96 bits\n     */\n    function toInt96(int256 value) internal pure returns (int96 downcasted) {\n        downcasted = int96(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(96, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int88 from int256, reverting on\n     * overflow (when the input is less than smallest int88 or\n     * greater than largest int88).\n     *\n     * Counterpart to Solidity's `int88` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 88 bits\n     */\n    function toInt88(int256 value) internal pure returns (int88 downcasted) {\n        downcasted = int88(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(88, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int80 from int256, reverting on\n     * overflow (when the input is less than smallest int80 or\n     * greater than largest int80).\n     *\n     * Counterpart to Solidity's `int80` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 80 bits\n     */\n    function toInt80(int256 value) internal pure returns (int80 downcasted) {\n        downcasted = int80(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(80, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int72 from int256, reverting on\n     * overflow (when the input is less than smallest int72 or\n     * greater than largest int72).\n     *\n     * Counterpart to Solidity's `int72` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 72 bits\n     */\n    function toInt72(int256 value) internal pure returns (int72 downcasted) {\n        downcasted = int72(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(72, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int64 from int256, reverting on\n     * overflow (when the input is less than smallest int64 or\n     * greater than largest int64).\n     *\n     * Counterpart to Solidity's `int64` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 64 bits\n     */\n    function toInt64(int256 value) internal pure returns (int64 downcasted) {\n        downcasted = int64(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(64, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int56 from int256, reverting on\n     * overflow (when the input is less than smallest int56 or\n     * greater than largest int56).\n     *\n     * Counterpart to Solidity's `int56` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 56 bits\n     */\n    function toInt56(int256 value) internal pure returns (int56 downcasted) {\n        downcasted = int56(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(56, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int48 from int256, reverting on\n     * overflow (when the input is less than smallest int48 or\n     * greater than largest int48).\n     *\n     * Counterpart to Solidity's `int48` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 48 bits\n     */\n    function toInt48(int256 value) internal pure returns (int48 downcasted) {\n        downcasted = int48(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(48, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int40 from int256, reverting on\n     * overflow (when the input is less than smallest int40 or\n     * greater than largest int40).\n     *\n     * Counterpart to Solidity's `int40` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 40 bits\n     */\n    function toInt40(int256 value) internal pure returns (int40 downcasted) {\n        downcasted = int40(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(40, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int32 from int256, reverting on\n     * overflow (when the input is less than smallest int32 or\n     * greater than largest int32).\n     *\n     * Counterpart to Solidity's `int32` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 32 bits\n     */\n    function toInt32(int256 value) internal pure returns (int32 downcasted) {\n        downcasted = int32(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(32, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int24 from int256, reverting on\n     * overflow (when the input is less than smallest int24 or\n     * greater than largest int24).\n     *\n     * Counterpart to Solidity's `int24` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 24 bits\n     */\n    function toInt24(int256 value) internal pure returns (int24 downcasted) {\n        downcasted = int24(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(24, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int16 from int256, reverting on\n     * overflow (when the input is less than smallest int16 or\n     * greater than largest int16).\n     *\n     * Counterpart to Solidity's `int16` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 16 bits\n     */\n    function toInt16(int256 value) internal pure returns (int16 downcasted) {\n        downcasted = int16(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(16, value);\n        }\n    }\n\n    /**\n     * @dev Returns the downcasted int8 from int256, reverting on\n     * overflow (when the input is less than smallest int8 or\n     * greater than largest int8).\n     *\n     * Counterpart to Solidity's `int8` operator.\n     *\n     * Requirements:\n     *\n     * - input must fit into 8 bits\n     */\n    function toInt8(int256 value) internal pure returns (int8 downcasted) {\n        downcasted = int8(value);\n        if (downcasted != value) {\n            revert SafeCastOverflowedIntDowncast(8, value);\n        }\n    }\n\n    /**\n     * @dev Converts an unsigned uint256 into a signed int256.\n     *\n     * Requirements:\n     *\n     * - input must be less than or equal to maxInt256.\n     */\n    function toInt256(uint256 value) internal pure returns (int256) {\n        // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive\n        if (value > uint256(type(int256).max)) {\n            revert SafeCastOverflowedUintToInt(value);\n        }\n        return int256(value);\n    }\n\n    /**\n     * @dev Cast a boolean (false or true) to a uint256 (0 or 1) with no jump.\n     */\n    function toUint(bool b) internal pure returns (uint256 u) {\n        assembly (\"memory-safe\") {\n            u := iszero(iszero(b))\n        }\n    }\n}\n"},{"file_path":"node_modules/@openzeppelin/contracts/utils/math/SignedMath.sol","source_code":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.1.0) (utils/math/SignedMath.sol)\n\npragma solidity ^0.8.20;\n\nimport {SafeCast} from \"./SafeCast.sol\";\n\n/**\n * @dev Standard signed math utilities missing in the Solidity language.\n */\nlibrary SignedMath {\n    /**\n     * @dev Branchless ternary evaluation for `a ? b : c`. Gas costs are constant.\n     *\n     * IMPORTANT: This function may reduce bytecode size and consume less gas when used standalone.\n     * However, the compiler may optimize Solidity ternary operations (i.e. `a ? b : c`) to only compute\n     * one branch when needed, making this function more expensive.\n     */\n    function ternary(bool condition, int256 a, int256 b) internal pure returns (int256) {\n        unchecked {\n            // branchless ternary works because:\n            // b ^ (a ^ b) == a\n            // b ^ 0 == b\n            return b ^ ((a ^ b) * int256(SafeCast.toUint(condition)));\n        }\n    }\n\n    /**\n     * @dev Returns the largest of two signed numbers.\n     */\n    function max(int256 a, int256 b) internal pure returns (int256) {\n        return ternary(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 ternary(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            // Formula from the \"Bit Twiddling Hacks\" by Sean Eron Anderson.\n            // Since `n` is a signed integer, the generated bytecode will use the SAR opcode to perform the right shift,\n            // taking advantage of the most significant (or \"sign\" bit) in two's complement representation.\n            // This opcode adds new most significant bits set to the value of the previous most significant bit. As a result,\n            // the mask will either be `bytes32(0)` (if n is positive) or `~bytes32(0)` (if n is negative).\n            int256 mask = n >> 255;\n\n            // A `bytes32(0)` mask leaves the input unchanged, while a `~bytes32(0)` mask complements it.\n            return uint256((n + mask) ^ mask);\n        }\n    }\n}\n"},{"file_path":"src/interface/IERC7821.sol","source_code":"// SPDX-License-Identifier: MIT\n// SPDX-FileCopyrightText: Copyright (c) 2016-2025 Zeppelin Group Ltd\n\npragma solidity 0.8.27;\n\n/**\n * @dev Interface for minimal batch executor.\n *\n * @custom:source\n * https://github.com/OpenZeppelin/openzeppelin-community-contracts/blob/e19d51c/contracts/interfaces/IERC7821.sol\n */\ninterface IERC7821 {\n    /**\n     * @dev Executes the calls in `executionData`.\n     * Reverts and bubbles up error if any call fails.\n     *\n     * `executionData` encoding:\n     * - If `opData` is empty, `executionData` is simply `abi.encode(calls)`.\n     * - Else, `executionData` is `abi.encode(calls, opData)`.\n     *   See: https://eips.ethereum.org/EIPS/eip-7579\n     *\n     * Supported modes:\n     * - `bytes32(0x01000000000000000000...)`: does not support optional `opData`.\n     * - `bytes32(0x01000000000078210001...)`: supports optional `opData`.\n     *\n     * Authorization checks:\n     * - If `opData` is empty, the implementation SHOULD require that\n     *   `msg.sender == address(this)`.\n     * - If `opData` is not empty, the implementation SHOULD use the signature\n     *   encoded in `opData` to determine if the caller can perform the execution.\n     *\n     * `opData` may be used to store additional data for authentication,\n     * paymaster data, gas limits, etc.\n     */\n    function execute(bytes32 mode, bytes calldata executionData) external payable;\n\n    /**\n     * @dev This function is provided for frontends to detect support.\n     * Only returns true for:\n     * - `bytes32(0x01000000000000000000...)`: does not support optional `opData`.\n     * - `bytes32(0x01000000000078210001...)`: supports optional `opData`.\n     */\n    function supportsExecutionMode(bytes32 mode) external view returns (bool);\n}\n"},{"file_path":"src/interface/IKillSwitch.sol","source_code":"// SPDX-License-Identifier: AGPL-3.0-or-later\n// SPDX-FileCopyrightText: Copyright (C) 2025 Fireblocks <support@fireblocks.com>\npragma solidity 0.8.27;\n\n/**\n * @title IKillSwitch\n * @notice Interface for the KillSwitch contract\n * @dev Defines the standard functions for a KillSwitch that can pause and unpause system functionality\n */\ninterface IKillSwitch {\n    // =============================================================\n    //                          FUNCTIONS\n    // =============================================================\n\n    /**\n     * @notice Pauses delegate contract operations for all delegated EOAs\n     */\n    function pause() external;\n\n    /**\n     * @notice Resumes normal operation of delegated EOAs\n     */\n    function unpause() external;\n\n    /**\n     * @notice Checks if the delegate contract functionality is paused\n     * @return True if the contract is paused, false otherwise\n     */\n    function paused() external view returns (bool);\n}\n"},{"file_path":"src/library/LibErrors.sol","source_code":"// SPDX-License-Identifier: AGPL-3.0-or-later\n// SPDX-FileCopyrightText: Copyright (C) 2025 Fireblocks <support@fireblocks.com>\n//\n// This program is free software: you can redistribute it and/or modify\n// it under the terms of the GNU Affero General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// This program is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n// GNU Affero General Public License for more details.\n//\n// You should have received a copy of the GNU Affero General Public License\n// along with this program.  If not, see <https://www.gnu.org/licenses/>.\npragma solidity 0.8.27;\n\n/**\n * @title Errors Library\n * @author Fireblocks\n * @notice The Errors Library provides error messages for the Fireblocks ecosystem of smart contracts.\n */\nlibrary LibErrors {\n    /**\n     * @notice This error indicates that a signature has expired\n     * @dev Indicates that current block timestamp is past the deadline\n     */\n    error ExpiredSignature(uint256 deadline);\n\n    /**\n     * @notice This error indicates that a nonce has already been used.\n     * @dev The nonce has already been used for this account.\n     */\n    error InvalidNonce();\n\n    /**\n     * @notice This error indicates that an address provided does not implement a required interface.\n     * @dev Indicates that a contract does not implement a required interface.\n     */\n    error InvalidImplementation();\n\n    /**\n     * @notice This error indicates that there was an error decoding the opData parameter.\n     * @dev Indicates that there was an error decoding the operation data (opData).\n     */\n    error OpDataDecodingError();\n\n    /**\n     * @notice This error indicates that there was an error extracting data from the execution payload.\n     * @dev Indicates that there was an error decoding the execution payload based on an expected structure.\n     */\n    error ExecutionDataExtractionError();\n\n    /**\n     * @notice This error indicates that a call to the `execute` function on the same Delegate EOA was attempted, from\n     * the context of a running `execute` function. This would indicate a reentrant call, and therefore is blocked.\n     * @dev Thrown when a reentrant call is detected.\n     */\n    error ReentrantCall();\n\n    /**\n     * @notice This error indicates that the function caller is not the expected. For example, not the EOA itself.\n     * @dev Indicates that the function caller is not the expected address.\n     */\n    error UnauthorizedCaller();\n\n    /**\n     * @notice This error indicates that a call is being invoked in the wrong target. For example, the implementation\n     * contract instead of the Delegated EOA address.\n     * @dev Indicates that the call is from an unauthorized context, such as a direct call to the\n     * implementation contract.\n     */\n    error UnauthorizedCallContext();\n\n    /**\n     * @notice This error indicates that an execution request was rejected due to invalid authorization.\n     * @dev Thrown when an execution request fails signature verification checks.\n     *\n     * This can occur when:\n     *   - The signature provided cannot be attributed to the expected signer (the EOA that has performed an EIP-7702\n     *     delegation to this contract)\n     *   - The provided signature does not match the given execution payload\n     *   - The `opData` component was present and non-zero but the mode provided does not support it\n     */\n    error UnauthorizedExecution();\n\n    /**\n     * @notice This error indicates that the requested execution mode is not supported by the contract.\n     * @dev Thrown when an execution request uses an execution mode configuration that is not\n     *      recognized or supported by the contract. This is a general error when the specific\n     *      component causing the unsupported mode cannot be determined.\n     *\n     * See also:\n     *   - {UnsupportedModeSelector}: For more specific errors related to mode selectors\n     *   - {ERC7579UnsupportedCallType}: For errors related to call types\n     *   - {ERC7579UnsupportedExecType}: For errors related to execution types\n     */\n    error UnsupportedExecutionMode();\n\n    /**\n     * @notice This error indicates that the execution mode selector is not supported by the contract.\n     * @dev Indicates that the execution mode selector is not supported by the contract.\n     * @param modeSelector The function selector that was not recognized as a valid mode.\n     */\n    error UnsupportedModeSelector(bytes4 modeSelector);\n\n    // ==================== IMPORTED ERRORS ====================\n    // These are errors that are observed in inherited contracts\n    // or libraries and therefore are known to be thrown by the\n    // contract. They are collated here for developer convenience.\n    // =========================================================\n\n    /**\n     * @notice This error indicates that the operation failed because the contract is paused.\n     * @dev The operation failed because the contract is paused.\n     *\n     * Moved into a library to avoid the need for a contract to inherit/import from {Pausable}. This error is original\n     * from OpenZeppelin's {Pausable} contract:\n     * https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/Pausable.sol\n     */\n    error EnforcedPause();\n\n    /**\n     * @notice This error indicates that an ERC7579 execute \"call type\" is not supported.\n     * @dev Thrown when an unsupported call type is used in an EIP-7579 execution mode.\n     * @param callType The unsupported call type byte.\n     */\n    error ERC7579UnsupportedCallType(bytes1 callType);\n\n    /**\n     * @notice This error indicates that an ERC7579 execute \"execution type\" is not supported.\n     * @dev Thrown when an unsupported exec type is used in an EIP-7579 execution mode.\n     * @param execType The unsupported execution type byte.\n     */\n    error ERC7579UnsupportedExecType(bytes1 execType);\n}\n"},{"file_path":"src/library/NonceStorageStruct.sol","source_code":"// SPDX-License-Identifier: AGPL-3.0-or-later\n// SPDX-FileCopyrightText: Copyright (C) 2025 Fireblocks <support@fireblocks.com>\n//\n// This program is free software: you can redistribute it and/or modify\n// it under the terms of the GNU Affero General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// This program is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n// GNU Affero General Public License for more details.\n//\n// You should have received a copy of the GNU Affero General Public License\n// along with this program.  If not, see <https://www.gnu.org/licenses/>.\npragma solidity 0.8.27;\n\n// =============================================================\n//                           STRUCTS\n// =============================================================\n\n/**\n * @notice Storage structure for nonce bitmap that helps prevent replay attacks of off-chain signatures\n * @dev This structure is used to track used nonces in a memory-efficient way using a bitmap\n *\n * The `@custom:storage-location` tag is to be defined by the implementing contract.\n */\nstruct NonceStorage {\n    /**\n     * @notice Unordered nonces with a bitmap. The key of the mapping is the \"nonce value\".\n     * @dev The first 248 bits of the nonce value is the index of the desired bitmap\n     * @dev The last 8 bits of the nonce value is the position of the bit in the bitmap\n     */\n    mapping(uint256 => uint256) nonceBitmap;\n}\n"},{"file_path":"src/mixins/NonceBitmap.sol","source_code":"// SPDX-License-Identifier: AGPL-3.0-or-later\n// SPDX-FileCopyrightText: Copyright (C) 2025 Fireblocks <support@fireblocks.com>\npragma solidity 0.8.27;\n\nimport { NonceStorage } from \"../library/NonceStorageStruct.sol\";\nimport { LibErrors } from \"../library/LibErrors.sol\";\n\n/**\n * @title NonceBitmap\n * @notice This contract manages unordered nonces using a Bitmap approach to efficiently store and track nonce usage.\n * @dev Provides functionality for managing and querying nonces\n * @custom:security-contact support@fireblocks.com\n */\nabstract contract NonceBitmap {\n    // =============================================================\n    //                          FUNCTIONS\n    // =============================================================\n\n    // ========================= EXTERNAL ==========================\n\n    /**\n     * @notice This function marks a nonce as used\n     * @dev This function is used to invalidate a nonce. Reverts with {LibErrors.InvalidNonce}\n     *      if the nonce has already been used.\n     *\n     * Deriving contracts must ensure proper access control.\n     *\n     * @param nonce The nonce to invalidate\n     */\n    function invalidateNonce(uint256 nonce) external virtual {\n        _useUnorderedNonce(nonce);\n    }\n\n    /**\n     * @notice Returns the nonce bitmap at a given word position\n     * @param wordPos The word position to check\n     * @return bitmap The nonce bitmap at the given position\n     */\n    function getNonceBitmap(uint248 wordPos) public view virtual returns (uint256 bitmap) {\n        return _nonceStorage().nonceBitmap[wordPos];\n    }\n\n    /**\n     * @notice This function checks if a nonce is already used\n     * @dev Checks whether a nonce has been flipped in the bitmap\n     * @param nonce The nonce to check\n     * @return isUsed True if the nonce has been used, false otherwise\n     */\n    function isNonceUsed(uint256 nonce) public view virtual returns (bool isUsed) {\n        (uint256 wordPos, uint256 bitPos) = _bitmapPositions(nonce);\n        uint256 bit = 1 << bitPos;\n        return _nonceStorage().nonceBitmap[wordPos] & bit != 0;\n    }\n\n    // ========================= INTERNAL ==========================\n\n    /**\n     * @notice Returns the index of the bitmap and the bit position within the bitmap\n     * @param nonce The nonce to get the associated word and bit positions\n     * @return wordPos The word position or index into the nonceBitmap\n     * @return bitPos The bit position\n     * @dev The first 248 bits of the nonce value is the index of the desired bitmap\n     * @dev The last 8 bits of the nonce value is the position of the bit in the bitmap\n     */\n    function _bitmapPositions(uint256 nonce) internal pure returns (uint256 wordPos, uint256 bitPos) {\n        wordPos = uint248(nonce >> 8);\n        bitPos = uint8(nonce);\n    }\n\n    /**\n     * @notice This represents the function signature to be used when accessing the Nonce Storage\n     * @dev Returns storage reference for nonce bitmap\n     * @return $ Storage reference to the nonce bitmap\n     */\n    function _nonceStorage() internal pure virtual returns (NonceStorage storage $);\n\n    /**\n     * @notice Sets the nonce to used\n     * @dev Checks whether a nonce is taken and sets the bit at the bit position in the bitmap.\n     *\n     * Reverts with {LibErrors.InvalidNonce} if the nonce has already been used.\n     *\n     * @param nonce The nonce to spend\n     */\n    function _useUnorderedNonce(uint256 nonce) internal {\n        (uint256 wordPos, uint256 bitPos) = _bitmapPositions(nonce);\n        uint256 bit = 1 << bitPos;\n        uint256 flipped = _nonceStorage().nonceBitmap[wordPos] ^= bit;\n\n        if (flipped & bit == 0) revert LibErrors.InvalidNonce();\n    }\n}\n"},{"file_path":"src/mixins/TokenReceiver.sol","source_code":"// SPDX-License-Identifier: AGPL-3.0-or-later\n// SPDX-FileCopyrightText: Copyright (C) 2025 Fireblocks <support@fireblocks.com>\npragma solidity 0.8.27;\n\nimport { IERC721Receiver } from \"@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol\";\nimport { ERC1155Holder } from \"@openzeppelin/contracts/token/ERC1155/utils/ERC1155Holder.sol\";\nimport { ERC721Holder } from \"@openzeppelin/contracts/token/ERC721/utils/ERC721Holder.sol\";\n\n/**\n * @title TokenReceiver\n * @notice This helper contract implements the necessary methods to successfully receive ERC1155 and ERC721 tokens.\n *         It is used as a base contract for accounts that need to handle token transfers.\n *\n * @dev This contract implements:\n *   - the {IERC1155Receiver} interface allowing it to receive ERC1155 tokens\n *   - the {IERC721Receiver} interface allowing it to receive ERC721 tokens\n *   - the EIP-165 standard for interface detection of the same and the two above interfaces\n *\n * @custom:security-contact support@fireblocks.com\n */\nabstract contract TokenReceiver is ERC721Holder, ERC1155Holder {\n    /**\n     * @notice This function can be queried to check if the contract implements a specific interface\n     * @dev Interface detection as per ERC-165 standard\n     *\n     * Returns true when `interfaceId` is either:\n     *   - the {IERC721Receiver} interface id\n     *   - the {IERC1155Receiver} interface id (checked in ERC1155Holder)\n     *   - the {IERC165} interface id (checked in ERC1155Holder -> ERC165)\n     *\n     * @param interfaceId The interface identifier to check\n     * @return isSupported True if the contract supports `interfaceId`\n     */\n    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool isSupported) {\n        return interfaceId == type(IERC721Receiver).interfaceId || super.supportsInterface(interfaceId);\n    }\n}\n"},{"file_path":"src/mixins/TypedAuthorization.sol","source_code":"// SPDX-License-Identifier: AGPL-3.0-or-later\n// SPDX-FileCopyrightText: Copyright (C) 2025 Fireblocks <support@fireblocks.com>\n\npragma solidity 0.8.27;\n\nimport { MessageHashUtils } from \"@openzeppelin/contracts/utils/cryptography/MessageHashUtils.sol\";\nimport { IERC5267 } from \"@openzeppelin/contracts/interfaces/IERC5267.sol\";\nimport { Execution } from \"@openzeppelin/contracts/interfaces/draft-IERC7579.sol\";\n\n/**\n * @title Typed Structured Execution Authorization\n * @notice Implementation of EIP712 that provides structured hashing functions for typed data in the context of\n *         meta-transactions. This contract computes the message digests that off-chain wallets must sign to\n *         authorize executions through the EIP-7702 delegate contract, supporting batch operations out of the box.\n *\n * This contract is an implementation of EIP-712 with select elements being part of the EIP712Domain\n *\n * @dev https://eips.ethereum.org/EIPS/eip-712[EIP-712] is a standard for hashing and signing of typed structured data.\n *\n * This contract implements the EIP-712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding\n * scheme, and the final step of the encoding to obtain the message digest ({_hashTypedDataV4}) that is then signed\n * via ECDSA. This contract also supports ERC-5267, but such proposal does not have a prerequisite on ERC-165 which\n * means that there is no need to signal it via a `supportsInterface` function.\n *\n * The implementation of the domain separator was designed to be as lean as possible, preserving only the chainId and\n * verifyingContract fields. It retains logic for properly updating the chain id to protect against replay attacks on\n * an eventual fork of the chain. The verifyingContract to be used should be defined by deriving contracts, allowing\n * for flexibility in the verification of EIP-712 signatures. This is particularly useful in the context of EIP-7702\n * delegate contracts, where the verifyingContract may be the proxy contract itself or the implementation contract.\n * This contract implements the version of the encoding known as \"signTypedDataV4\".\n *\n * This contract is derived from the OpenZeppelin Contracts implementation of EIP-712 (utils/cryptography/EIP712.sol).\n *\n * @custom:security-contact support@fireblocks.com\n */\nabstract contract TypedAuthorization is IERC5267 {\n    // =============================================================\n    //                   CONSTANTS / IMMUTABLE\n    // =============================================================\n\n    /**\n     * @notice The EIP712 domain typehash used for computing the domain separator\n     * @dev Hash of the type string: \"EIP712Domain(uint256 chainId,address verifyingContract)\"\n     */\n    bytes32 private constant _DOMAIN_TYPEHASH = keccak256(\"EIP712Domain(uint256 chainId,address verifyingContract)\");\n\n    /**\n     * @notice The typehash for the Execution type used in the structured data\n     * @dev Hash of the type string: \"Execution(address target,uint256 value,bytes data)\"\n     */\n    bytes32 internal constant _EXECUTION_TYPEHASH = keccak256(\"Execution(address target,uint256 value,bytes data)\");\n\n    /**\n     * @notice The typehash for the AuthorizedExecutions type used in the typed data\n     * @dev Hash of the type string that combines the execution authorization with the execution data\n     * This defines the structure of the typed data that will be signed for authorizing executions\n     */\n    bytes32 internal constant _EXECUTION_AUTHORIZATION_TYPEHASH = keccak256(\n        // solhint-disable-next-line max-line-length\n        \"AuthorizedExecutions(Execution[] calls,uint256 deadline,bytes32 mode,uint256 nonce,address relayer)Execution(address target,uint256 value,bytes data)\"\n    );\n\n    // Cache the domain separator as an immutable value, but also store the chain id that it corresponds to, in order to\n    // invalidate the cached domain separator if the chain id changes.\n    bytes32 private immutable _cachedDomainSeparator; // solhint-disable-line immutable-vars-naming\n    uint256 private immutable _cachedChainId; // solhint-disable-line immutable-vars-naming\n\n    // =============================================================\n    //                         CONSTRUCTOR\n    // =============================================================\n\n    /**\n     * @notice Initializes the EIP712 domain separator cache using an internally defined verifying-contract address\n     */\n    constructor() {\n        _cachedChainId = block.chainid;\n        _cachedDomainSeparator = _buildDomainSeparator();\n    }\n\n    // =============================================================\n    //                      PUBLIC FUNCTIONS\n    // =============================================================\n\n    /**\n     * @inheritdoc IERC5267\n     */\n    function eip712Domain()\n        public\n        view\n        virtual\n        returns (\n            bytes1 fields,\n            string memory name,\n            string memory version,\n            uint256 chainId,\n            address verifyingContract,\n            bytes32 salt,\n            uint256[] memory extensions\n        )\n    {\n        return (\n            hex\"0c\", // 01100\n            string(\"\"), // empty name\n            string(\"\"), // empty version\n            block.chainid,\n            _verifyingContractAddress(),\n            bytes32(0), // empty salt\n            new uint256[](0)\n        );\n    }\n\n    // =============================================================\n    //                     INTERNAL FUNCTIONS\n    // =============================================================\n\n    /**\n     * @notice Returns the domain separator for the current chain.\n     * @dev Returns the cached separator if the chain id hasn't changed, otherwise rebuilds it.\n     * @return domainSeparator The domain separator bytes32 value\n     */\n    function _domainSeparatorV4() internal view returns (bytes32 domainSeparator) {\n        // Use cached value if chainId matches, otherwise rebuild\n        return block.chainid == _cachedChainId ? _cachedDomainSeparator : _buildDomainSeparator();\n    }\n\n    /**\n     * @notice Builds the EIP712 domain separator using the current chain ID and the implementation-specific address\n     *         as the verifying contract.\n     * @return domainSeparator The domain separator bytes32 value\n     */\n    function _buildDomainSeparator() private view returns (bytes32 domainSeparator) {\n        return keccak256(abi.encode(_DOMAIN_TYPEHASH, block.chainid, _verifyingContractAddress()));\n    }\n\n    /**\n     * @notice Given a hashed struct, returns the hash of the fully encoded EIP712 message for this domain.\n     *\n     * See https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[definition of hashed struct].\n     *\n     * @dev This hash can be used with {ECDSA-recover} to obtain the signer of a message\n     *\n     * @param structHash The hash of the struct being signed\n     * @return hashedData The EIP712 typed data hash\n     */\n    function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32 hashedData) {\n        return MessageHashUtils.toTypedDataHash(_domainSeparatorV4(), structHash);\n    }\n\n    /**\n     * @notice Create a hash of the fully encoded EIP712 message for a single authorized execution\n     * @dev Creates a typed hash for a single execution with the given parameters\n     *\n     * @param mode The execution mode\n     * @param target The target address\n     * @param value The value to send\n     * @param data The call data\n     * @param nonce The nonce\n     * @param deadline The timestamp after which the signature is no longer valid\n     * @param relayer The address of the relayer that is authorized to submit this transaction\n     * @return hashedData The `AuthorizedExecutions` typed hash\n     */\n    function _hashTypedSingleExecutionAuthorization(\n        bytes32 mode,\n        address target,\n        uint256 value,\n        bytes memory data,\n        uint256 nonce,\n        uint256 deadline,\n        address relayer\n    )\n        internal\n        view\n        returns (bytes32 hashedData)\n    {\n        // Directly calculate the execution hash for the single execution\n        bytes32 seHash = keccak256(abi.encode(_EXECUTION_TYPEHASH, target, value, keccak256(data)));\n        // When there's only one item, the executionsHash (plural) is just the packaged single hash\n        bytes32 executionsHash = keccak256(abi.encodePacked(seHash));\n        // Create the final hash including the calls, deadline, mode, nonce and relayer\n        bytes32 structHash =\n            keccak256(abi.encode(_EXECUTION_AUTHORIZATION_TYPEHASH, executionsHash, deadline, mode, nonce, relayer));\n\n        return _hashTypedDataV4(structHash);\n    }\n\n    /**\n     * @notice Create a hash of the fully encoded EIP712 message for a batch of executions\n     * @dev Creates a typed hash for multiple executions with the given parameters\n     *\n     * @param mode The execution mode\n     * @param calls The array of executions\n     * @param nonce The nonce\n     * @param deadline The timestamp after which the signature is no longer valid\n     * @param relayer The address of the relayer that is authorized to submit this transaction\n     * @return hashedData The `AuthorizedExecutions` typed hash\n     */\n    function _hashTypedBatchExecutionAuthorization(\n        bytes32 mode,\n        Execution[] memory calls,\n        uint256 nonce,\n        uint256 deadline,\n        address relayer\n    )\n        internal\n        view\n        returns (bytes32 hashedData)\n    {\n        // Hash each execution in the batch\n        bytes32[] memory executionHashes = new bytes32[](calls.length);\n        for (uint256 i = 0; i < calls.length; i++) {\n            executionHashes[i] = keccak256(\n                abi.encode(_EXECUTION_TYPEHASH, calls[i].target, calls[i].value, keccak256(calls[i].callData))\n            );\n        }\n        // Hash the array of execution hashes\n        bytes32 executionsHash = keccak256(abi.encodePacked(executionHashes));\n        // Create the final hash including the calls, deadline, mode, nonce and relayer\n        bytes32 structHash =\n            keccak256(abi.encode(_EXECUTION_AUTHORIZATION_TYPEHASH, executionsHash, deadline, mode, nonce, relayer));\n\n        return _hashTypedDataV4(structHash);\n    }\n\n    /**\n     * @notice This function determines the address of the verifying contract to be used in the EIP712 domain separator\n     * @dev This function must be overridden by the deriving contract to provide the appropriate contract address,\n     *      which could be the address of the implementation contract or the proxy contract.\n     * @return verifyingContract The address of the verifying contract\n     */\n    function _verifyingContractAddress() internal view virtual returns (address verifyingContract);\n}\n"}],"certified":false,"conflicting_implementations":null,"abi":[{"inputs":[{"internalType":"address","name":"killswitchContract","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"ECDSAInvalidSignature","type":"error"},{"inputs":[{"internalType":"uint256","name":"length","type":"uint256"}],"name":"ECDSAInvalidSignatureLength","type":"error"},{"inputs":[{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"ECDSAInvalidSignatureS","type":"error"},{"inputs":[],"name":"ERC7579DecodingError","type":"error"},{"inputs":[{"internalType":"CallType","name":"callType","type":"bytes1"}],"name":"ERC7579UnsupportedCallType","type":"error"},{"inputs":[{"internalType":"ExecType","name":"execType","type":"bytes1"}],"name":"ERC7579UnsupportedExecType","type":"error"},{"inputs":[],"name":"EnforcedPause","type":"error"},{"inputs":[],"name":"ExecutionDataExtractionError","type":"error"},{"inputs":[{"internalType":"uint256","name":"deadline","type":"uint256"}],"name":"ExpiredSignature","type":"error"},{"inputs":[],"name":"FailedCall","type":"error"},{"inputs":[],"name":"InvalidImplementation","type":"error"},{"inputs":[],"name":"InvalidNonce","type":"error"},{"inputs":[],"name":"OpDataDecodingError","type":"error"},{"inputs":[],"name":"OutOfRangeAccess","type":"error"},{"inputs":[],"name":"ReentrantCall","type":"error"},{"inputs":[],"name":"UnauthorizedCallContext","type":"error"},{"inputs":[],"name":"UnauthorizedCaller","type":"error"},{"inputs":[],"name":"UnauthorizedExecution","type":"error"},{"inputs":[],"name":"UnsupportedExecutionMode","type":"error"},{"inputs":[{"internalType":"bytes4","name":"modeSelector","type":"bytes4"}],"name":"UnsupportedModeSelector","type":"error"},{"anonymous":false,"inputs":[],"name":"EIP712DomainChanged","type":"event"},{"stateMutability":"payable","type":"fallback"},{"inputs":[],"name":"eip712Domain","outputs":[{"internalType":"bytes1","name":"fields","type":"bytes1"},{"internalType":"string","name":"name","type":"string"},{"internalType":"string","name":"version","type":"string"},{"internalType":"uint256","name":"chainId","type":"uint256"},{"internalType":"address","name":"verifyingContract","type":"address"},{"internalType":"bytes32","name":"salt","type":"bytes32"},{"internalType":"uint256[]","name":"extensions","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"mode","type":"bytes32"},{"internalType":"bytes","name":"executionData","type":"bytes"}],"name":"execute","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint248","name":"wordPos","type":"uint248"}],"name":"getNonceBitmap","outputs":[{"internalType":"uint256","name":"bitmap","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"nonce","type":"uint256"}],"name":"invalidateNonce","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"nonce","type":"uint256"}],"name":"isNonceUsed","outputs":[{"internalType":"bool","name":"isUsed","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isPaused","outputs":[{"internalType":"bool","name":"isPausedState","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_hash","type":"bytes32"},{"internalType":"bytes","name":"_signature","type":"bytes"}],"name":"isValidSignature","outputs":[{"internalType":"bytes4","name":"magicValue","type":"bytes4"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256[]","name":"","type":"uint256[]"},{"internalType":"uint256[]","name":"","type":"uint256[]"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"onERC1155BatchReceived","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"onERC1155Received","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"onERC721Received","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"mode","type":"bytes32"}],"name":"supportsExecutionMode","outputs":[{"internalType":"bool","name":"isSupported","type":"bool"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"isSupported","type":"bool"}],"stateMutability":"view","type":"function"},{"stateMutability":"payable","type":"receive"}],"is_changed_bytecode":false,"is_partially_verified":true,"constructor_args":"0x00000000000000000000000000000000fb2736c301e53904409f03de06c8467a"}