// Contract: Hazel
// Target function: function setApprovalForAll(address _operator, bool _approved)
RK4xCAlVZp950fhmHh6OdvWeTw7u5b+60IvRvcBAm2n6lJtsiLAbP3ayyEvgJupE2sxvvS3Y//r84guEBOikshuf1l/YAA0AzQAAAbJIARh7bGCscjyAR18DmEU1AXBpnAAAB1kGazjSkwQS//fED9D6AHNRMvqlN/QIpwu+rVFDUUAWk8hX6xa8hDfqyKszk8Xp1veRLpwL+vk9I4axnw1fdlX0AONpsi0SWnIfVSqfPB+uGzIHcNMCMChuPz3F+L54QTFv1HSv7jm0oghNXYZnrtvKw4XYlYGBgW8OXeU/VB0iRZIIJtksS+D0aXDflaQ9RRhBptsSmBrxeKRZc97yopC2EYQ8AEd8P1MJYeC/YdItLGHSuWXeDLUKh1E1aDEobCfv+xHz5aMPxFPgjgQWE2qxQ2y7X2doyDkSUA2zEOHxShKIkHfUpfqITYtJRVCT0IVCPkjDzJhIBi9vo9c1MFErsdYEkz/I2EOodH8VdHtf/qEWRIaUcryw0FKhziVWIfFUMgu/Ah1jkVBM3Yx9K4P5XS607fATgCB+ybQnZf29cceKFVpDhyp7EQTSyd6ku+m04fNB7Y/+HlIIxqql6bDhanySTERp+KIpjhDOqXKSaMoBgu7gU/L6Ij6FVmTyEWEdnOSrNWbPzyzzaBaeiGekTK/JtI8AkRvYLm0F3QRVncK86f/2nODpSUg5AZB1XNyTndlAQNPLaMVe2EZ18JC/OQqhONzEEkBwoB26HHKl+ob/dZlmTATopLIbnqb/YAAFflrPDkm7r9LHtr1qUxpoVMA6QBwE8KSiG5/b8fxsB12AbeUrSVWKMA4PgYXoHBJYD56BQ4AAAAElBnuxFESw//wNE+DxGIy1A8Gxdn7GjeLdCM3PA1ZGFY/UC7PPpDGGthrmKQgxeHLSoUElRn0yfB0/tuwgNyrvzUpuW+KDgYd+AARgpADQxd/9dV/xLnP16dczx7BxMVJ4DWNohaK8ZlCAygcAAAAAcAZ8LdEO/BBiBLg+MaSbzsMzkZUjUTAlhQz873wE6KS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bTHWfIZXvDmDcoOztYckO0RCJU2tETustgqf70o44NKoyYoo2KJfcjOctZwf/rTZ/Y8LKOmZ/d0vKEGOYKf7vdXBEVZCRAUIpKCcX/b252AACf1P2nvf3zF+TGjcskbH5igDgAAAAR0GfuEUVLD//Ae8fo2HboSbN2JBdMABx/hkvyEQQ+/UfVGNiJX7apTwghEaCkX+4nyiSH+Js7pZKqnPlhp67r6QXip0YliYNAUYpKILn/j6/f/sAACT6mIAQnDd+yIYmEVTm/W4DgAFGKSiG5n2+P70ADgX3wecdVlR9k0o4vWyVFhP2cAHAAAAAJAGf13RDvwKNuRUEkf5eMa0USfZdDDDEmOZBD7pTeuWwvP6goAFEKSyKsBv0l/wAAa/gUTsMg0AmtCDoPYFSZMAxEOAAAAANAZ/ZRDv/Alq8nSxgWQFGKSiG5+b+//gAA0AztwAAb/4AOv9lFQ5m6+46uN48UhJBPogBwAAAADdBm9w0pMKJh//6WAIBQUtOgBL3YUM3qrB0db+ASg74HNcCJgg8BiwtEYSC74vIbIl3deB5O7mNAU4pLIbnp+P/HHIAAyy0oN5dBPNFgjll6AIUPOQDgAFCKSiG5/WfH9AADQDJPxIBscEcf0cxNNQvoBrTxfZpf69ZMP95gAcAAAARAZ/7RD//Ae3yOm6ymWF6SG8BPCkmT/wAAA0/+zWlE1ElwcBGsEWvIsXn3GLAkA4BQikohufw4/YAAEnxjoU05bSh5uWFamdV3/L0AcABRCkohuf68fv/0AAgb/fxFO1/X3sZHdGZVl9RAOABZikshuZx/j/wAFywnY17A6EP8K+SPvZ0XTD1TCA4AVApKILnz9+v+P9P4566rx1zvz7e4eeUtWvfcT971l6BBIAGIcA=";
        
        string memory docURI =  string.concat('<html><body><video autoplay controls src="data:video/mp4;base64,', videoURI, ' >',
                                    '</video></body></html>');
        bytes memory imageSvg = abi.encodePacked('"animation_url": "data:text/html;base64,', Base64.encode(bytes(docURI)),'",');
        return
            string(
                abi.encodePacked(
                    "data:application/json;base64,",
                    Base64.encode(
                        bytes(
                            abi.encodePacked(
                                '{"name":"Hazel","description":"0xHuskys dog. 100% onchain video",',
                                imageSvg,
                                '"attributes": []}'                                
                            )
                        )
                    )
                )
            );
    }

   

    /***********************************|
    |     Public Transfer Functions     |
    |__________________________________*/

    function safeTransferFrom(address _from, address _to, uint256 _id, uint256 _amount, bytes memory _data)
        public override
    {
        require((msg.sender == _from) || isApprovedForAll(_from, msg.sender), "ERC1155#safeTransferFrom: INVALID_OPERATOR");
        require(_to != address(0),"ERC1155#safeTransferFrom: INVALID_RECIPIENT");

        _safeTransferFrom(_from, _to, _id, _amount);
        _callonERC1155Received(_from, _to, _id, _amount, gasleft(), _data);
    }

    function safeBatchTransferFrom(address _from, address _to, uint256[] memory _ids, uint256[] memory _amounts, bytes memory _data)
        public override
    {
        // Requirements
        require((msg.sender == _from) || isApprovedForAll(_from, msg.sender), "ERC1155#safeBatchTransferFrom: INVALID_OPERATOR");
        require(_to != address(0), "ERC1155#safeBatchTransferFrom: INVALID_RECIPIENT");

        _safeBatchTransferFrom(_from, _to, _ids, _amounts);
        _callonERC1155BatchReceived(_from, _to, _ids, _amounts, gasleft(), _data);
    }


    /***********************************|
    |    Internal Transfer Functions    |
    |__________________________________*/

    function _safeTransferFrom(address _from, address _to, uint256 _id, uint256 _amount)
        internal
    {
        // Update balances
        balances[_from][_id] -= _amount;
        balances[_to][_id] += _amount;

        // Emit event
        emit TransferSingle(msg.sender, _from, _to, _id, _amount);
    }

    /**
    * @notice Verifies if receiver is contract and if so, calls (_to).onERC1155Received(...)
    */
    function _callonERC1155Received(address _from, address _to, uint256 _id, uint256 _amount, uint256 _gasLimit, bytes memory _data) internal {
        // Check if recipient is contract
        if (_to.code.length != 0) {
        bytes4 retval = IERC1155TokenReceiver(_to).onERC1155Received{gas: _gasLimit}(msg.sender, _from, _id, _amount, _data);
        require(retval == ERC1155_RECEIVED_VALUE, "ERC1155#_callonERC1155Received: INVALID_ON_RECEIVE_MESSAGE");
        }
    }

    function _safeBatchTransferFrom(address _from, address _to, uint256[] memory _ids, uint256[] memory _amounts) internal {
        require(_ids.length == _amounts.length, "ERC1155#_safeBatchTransferFrom: INVALID_ARRAYS_LENGTH");

        // Number of transfer to execute
        uint256 nTransfer = _ids.length;

        // Executing all transfers
        for (uint256 i = 0; i < nTransfer; i++) {
            
            balances[_from][_ids[i]] -= _amounts[i];
            balances[_to][_ids[i]]   += _amounts[i];
        }

        // Emit event
        emit TransferBatch(msg.sender, _from, _to, _ids, _amounts);
    }

    /**
    * @notice Verifies if receiver is contract and if so, calls (_to).onERC1155BatchReceived(...)
    */
    function _callonERC1155BatchReceived(address _from, address _to, uint256[] memory _ids, uint256[] memory _amounts, uint256 _gasLimit, bytes memory _data) internal {
        // Pass data if recipient is contract
        if (_to.code.length != 0) {
        bytes4 retval = IERC1155TokenReceiver(_to).onERC1155BatchReceived{gas: _gasLimit}(msg.sender, _from, _ids, _amounts, _data);
        require(retval == ERC1155_BATCH_RECEIVED_VALUE, "ERC1155#_callonERC1155BatchReceived: INVALID_ON_RECEIVE_MESSAGE");
        }
    }