package com.nexlab.openclaw.node.data.remote;

import android.util.Log;
import com.nexlab.openclaw.node.domain.model.NodeCapabilities;
import com.nexlab.openclaw.node.domain.model.NodeCommand;
import com.nexlab.openclaw.node.domain.model.NodeEvent;
import com.nexlab.openclaw.node.domain.model.NodeResponse;
import kotlinx.coroutines.flow.Flow;
import org.json.JSONArray;
import org.json.JSONObject;
import java.security.KeyPairGenerator;
import java.security.MessageDigest;
import java.security.PrivateKey;
import java.security.Signature;
import java.util.Base64;
import java.util.concurrent.TimeUnit;
import javax.inject.Inject;
import javax.inject.Singleton;

@javax.inject.Singleton
@kotlin.Metadata(mv = {1, 9, 0}, k = 1, xi = 48, d1 = {"\u0000~\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0002\n\u0002\u0010\u000e\n\u0000\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\t\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0007\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u000b\n\u0002\b\u0006\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\b\u0007\n\u0002\u0018\u0002\n\u0002\b\u0004\b\u0007\u0018\u00002\u00020\u0001:\u0001DB\u0005\u00a2\u0006\u0002\u0010\u0002J&\u0010#\u001a\u00020$2\u0006\u0010%\u001a\u00020\u00042\u0006\u0010&\u001a\u00020\u00042\u0006\u0010\'\u001a\u00020\u00042\u0006\u0010(\u001a\u00020)J\u0006\u0010*\u001a\u00020$J\b\u0010+\u001a\u00020$H\u0002J\u0012\u0010,\u001a\u0004\u0018\u00010\t2\u0006\u0010-\u001a\u00020.H\u0002J\u000e\u0010/\u001a\u00020$2\u0006\u0010&\u001a\u00020\u0004J \u00100\u001a\u00020$2\u0006\u0010&\u001a\u00020\u00042\u0006\u0010\'\u001a\u00020\u00042\u0006\u0010(\u001a\u00020)H\u0002J \u00101\u001a\u00020$2\u0006\u0010&\u001a\u00020\u00042\u0006\u0010\'\u001a\u00020\u00042\u0006\u0010(\u001a\u00020)H\u0002J\u000e\u00102\u001a\u00020$2\u0006\u00103\u001a\u000204J\u0010\u00105\u001a\u00020$2\u0006\u0010-\u001a\u00020.H\u0002J \u00106\u001a\u00020$2\u0006\u0010&\u001a\u00020\u00042\u0006\u0010\'\u001a\u00020\u00042\u0006\u0010(\u001a\u00020)H\u0002J\u000e\u00107\u001a\u00020$2\u0006\u00108\u001a\u000209J\u0010\u0010:\u001a\u00020\u00042\u0006\u0010;\u001a\u00020\u0004H\u0002J@\u0010<\u001a\u00020\u00042\u0006\u0010=\u001a\u00020\u00042\u0006\u0010>\u001a\u00020\u00042\u0006\u0010?\u001a\u00020\u00042\u0006\u0010@\u001a\u00020A2\u0006\u0010\'\u001a\u00020\u00042\u0006\u0010B\u001a\u00020\u00042\u0006\u0010C\u001a\u00020\u0004H\u0002R\u000e\u0010\u0003\u001a\u00020\u0004X\u0082D\u00a2\u0006\u0002\n\u0000R\u0014\u0010\u0005\u001a\b\u0012\u0004\u0012\u00020\u00070\u0006X\u0082\u0004\u00a2\u0006\u0002\n\u0000R\u0014\u0010\b\u001a\b\u0012\u0004\u0012\u00020\t0\u0006X\u0082\u0004\u00a2\u0006\u0002\n\u0000R\u000e\u0010\n\u001a\u00020\u0004X\u0082\u000e\u00a2\u0006\u0002\n\u0000R\u000e\u0010\u000b\u001a\u00020\fX\u0082\u000e\u00a2\u0006\u0002\n\u0000R\u000e\u0010\r\u001a\u00020\u000eX\u0082\u0004\u00a2\u0006\u0002\n\u0000R\u0017\u0010\u000f\u001a\b\u0012\u0004\u0012\u00020\u00070\u0010\u00a2\u0006\b\n\u0000\u001a\u0004\b\u0011\u0010\u0012R\u000e\u0010\u0013\u001a\u00020\u0004X\u0082\u000e\u00a2\u0006\u0002\n\u0000R\u000e\u0010\u0014\u001a\u00020\u0004X\u0082\u000e\u00a2\u0006\u0002\n\u0000R\u000e\u0010\u0015\u001a\u00020\u0004X\u0082\u000e\u00a2\u0006\u0002\n\u0000R\u000e\u0010\u0016\u001a\u00020\u0004X\u0082\u000e\u00a2\u0006\u0002\n\u0000R\u0010\u0010\u0017\u001a\u0004\u0018\u00010\u0018X\u0082\u000e\u00a2\u0006\u0002\n\u0000R\u000e\u0010\u0019\u001a\u00020\u0004X\u0082\u000e\u00a2\u0006\u0002\n\u0000R\u000e\u0010\u001a\u001a\u00020\u001bX\u0082\u000e\u00a2\u0006\u0002\n\u0000R\u0017\u0010\u001c\u001a\b\u0012\u0004\u0012\u00020\t0\u0010\u00a2\u0006\b\n\u0000\u001a\u0004\b\u001d\u0010\u0012R\u000e\u0010\u001e\u001a\u00020\u001bX\u0082\u000e\u00a2\u0006\u0002\n\u0000R\u000e\u0010\u001f\u001a\u00020\u001bX\u0082\u000e\u00a2\u0006\u0002\n\u0000R\u0010\u0010 \u001a\u0004\u0018\u00010\u0004X\u0082\u000e\u00a2\u0006\u0002\n\u0000R\u0010\u0010!\u001a\u0004\u0018\u00010\"X\u0082\u000e\u00a2\u0006\u0002\n\u0000\u00a8\u0006E"}, d2 = {"Lcom/nexlab/openclaw/node/data/remote/NodeClient;", "", "()V", "GLOBAL_GATEWAY_TOKEN", "", "_connectionStatus", "Lkotlinx/coroutines/channels/Channel;", "Lcom/nexlab/openclaw/node/data/remote/NodeClient$ConnectionStatus;", "_incomingCommands", "Lcom/nexlab/openclaw/node/domain/model/NodeCommand;", "challengeNonce", "challengeTimestamp", "", "client", "Lokhttp3/OkHttpClient;", "connectionStatus", "Lkotlinx/coroutines/flow/Flow;", "getConnectionStatus", "()Lkotlinx/coroutines/flow/Flow;", "currentNodeId", "currentToken", "deviceId", "devicePrivateKey", "devicePrivateKeyObject", "Ljava/security/PrivateKey;", "devicePublicKey", "hasReceivedChallenge", "", "incomingCommands", "getIncomingCommands", "isConnected", "isPairingMode", "pendingRequestId", "webSocket", "Lokhttp3/WebSocket;", "connect", "", "gatewayUrl", "nodeId", "token", "capabilities", "Lcom/nexlab/openclaw/node/domain/model/NodeCapabilities;", "disconnect", "generateDeviceIdentity", "parseCommand", "json", "Lorg/json/JSONObject;", "requestPairing", "sendConnectRequest", "sendConnectRequestWithChallenge", "sendEvent", "event", "Lcom/nexlab/openclaw/node/domain/model/NodeEvent;", "sendJson", "sendPairingRequest", "sendResponse", "response", "Lcom/nexlab/openclaw/node/domain/model/NodeResponse;", "signData", "data", "signV3Payload", "nonce", "clientId", "role", "scopes", "Lorg/json/JSONArray;", "platform", "deviceFamily", "ConnectionStatus", "app_debug"})
public final class NodeClient {
    @org.jetbrains.annotations.Nullable
    private okhttp3.WebSocket webSocket;
    @org.jetbrains.annotations.NotNull
    private final okhttp3.OkHttpClient client = null;
    @org.jetbrains.annotations.NotNull
    private final kotlinx.coroutines.channels.Channel<com.nexlab.openclaw.node.data.remote.NodeClient.ConnectionStatus> _connectionStatus = null;
    @org.jetbrains.annotations.NotNull
    private final kotlinx.coroutines.flow.Flow<com.nexlab.openclaw.node.data.remote.NodeClient.ConnectionStatus> connectionStatus = null;
    @org.jetbrains.annotations.NotNull
    private final kotlinx.coroutines.channels.Channel<com.nexlab.openclaw.node.domain.model.NodeCommand> _incomingCommands = null;
    @org.jetbrains.annotations.NotNull
    private final kotlinx.coroutines.flow.Flow<com.nexlab.openclaw.node.domain.model.NodeCommand> incomingCommands = null;
    private boolean isConnected = false;
    @org.jetbrains.annotations.NotNull
    private java.lang.String currentNodeId = "";
    @org.jetbrains.annotations.NotNull
    private java.lang.String currentToken = "";
    @org.jetbrains.annotations.Nullable
    private java.lang.String pendingRequestId;
    private boolean isPairingMode = false;
    @org.jetbrains.annotations.NotNull
    private final java.lang.String GLOBAL_GATEWAY_TOKEN = "415fa3c21b7ef06f22aff571697d88c59c2dc67737681267";
    @org.jetbrains.annotations.NotNull
    private java.lang.String deviceId = "";
    @org.jetbrains.annotations.NotNull
    private java.lang.String devicePublicKey = "";
    @org.jetbrains.annotations.NotNull
    private java.lang.String devicePrivateKey = "";
    @org.jetbrains.annotations.Nullable
    private java.security.PrivateKey devicePrivateKeyObject;
    @org.jetbrains.annotations.NotNull
    private java.lang.String challengeNonce = "";
    private long challengeTimestamp = 0L;
    private boolean hasReceivedChallenge = false;
    
    public NodeClient() {
        super();
    }
    
    @org.jetbrains.annotations.NotNull
    public final kotlinx.coroutines.flow.Flow<com.nexlab.openclaw.node.data.remote.NodeClient.ConnectionStatus> getConnectionStatus() {
        return null;
    }
    
    @org.jetbrains.annotations.NotNull
    public final kotlinx.coroutines.flow.Flow<com.nexlab.openclaw.node.domain.model.NodeCommand> getIncomingCommands() {
        return null;
    }
    
    private final void generateDeviceIdentity() {
    }
    
    private final java.lang.String signData(java.lang.String data) {
        return null;
    }
    
    private final java.lang.String signV3Payload(java.lang.String nonce, java.lang.String clientId, java.lang.String role, org.json.JSONArray scopes, java.lang.String token, java.lang.String platform, java.lang.String deviceFamily) {
        return null;
    }
    
    public final void connect(@org.jetbrains.annotations.NotNull
    java.lang.String gatewayUrl, @org.jetbrains.annotations.NotNull
    java.lang.String nodeId, @org.jetbrains.annotations.NotNull
    java.lang.String token, @org.jetbrains.annotations.NotNull
    com.nexlab.openclaw.node.domain.model.NodeCapabilities capabilities) {
    }
    
    private final void sendConnectRequest(java.lang.String nodeId, java.lang.String token, com.nexlab.openclaw.node.domain.model.NodeCapabilities capabilities) {
    }
    
    private final void sendConnectRequestWithChallenge(java.lang.String nodeId, java.lang.String token, com.nexlab.openclaw.node.domain.model.NodeCapabilities capabilities) {
    }
    
    private final void sendPairingRequest(java.lang.String nodeId, java.lang.String token, com.nexlab.openclaw.node.domain.model.NodeCapabilities capabilities) {
    }
    
    public final void requestPairing(@org.jetbrains.annotations.NotNull
    java.lang.String nodeId) {
    }
    
    public final void disconnect() {
    }
    
    public final void sendResponse(@org.jetbrains.annotations.NotNull
    com.nexlab.openclaw.node.domain.model.NodeResponse response) {
    }
    
    public final void sendEvent(@org.jetbrains.annotations.NotNull
    com.nexlab.openclaw.node.domain.model.NodeEvent event) {
    }
    
    private final void sendJson(org.json.JSONObject json) {
    }
    
    private final com.nexlab.openclaw.node.domain.model.NodeCommand parseCommand(org.json.JSONObject json) {
        return null;
    }
    
    @kotlin.Metadata(mv = {1, 9, 0}, k = 1, xi = 48, d1 = {"\u0000 \n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0000\n\u0002\u0010\u000b\n\u0000\n\u0002\u0010\u000e\n\u0002\b\u000b\n\u0002\u0010\b\n\u0002\b\u0002\b\u0086\b\u0018\u00002\u00020\u0001B\u0015\u0012\u0006\u0010\u0002\u001a\u00020\u0003\u0012\u0006\u0010\u0004\u001a\u00020\u0005\u00a2\u0006\u0002\u0010\u0006J\t\u0010\u000b\u001a\u00020\u0003H\u00c6\u0003J\t\u0010\f\u001a\u00020\u0005H\u00c6\u0003J\u001d\u0010\r\u001a\u00020\u00002\b\b\u0002\u0010\u0002\u001a\u00020\u00032\b\b\u0002\u0010\u0004\u001a\u00020\u0005H\u00c6\u0001J\u0013\u0010\u000e\u001a\u00020\u00032\b\u0010\u000f\u001a\u0004\u0018\u00010\u0001H\u00d6\u0003J\t\u0010\u0010\u001a\u00020\u0011H\u00d6\u0001J\t\u0010\u0012\u001a\u00020\u0005H\u00d6\u0001R\u0011\u0010\u0002\u001a\u00020\u0003\u00a2\u0006\b\n\u0000\u001a\u0004\b\u0007\u0010\bR\u0011\u0010\u0004\u001a\u00020\u0005\u00a2\u0006\b\n\u0000\u001a\u0004\b\t\u0010\n\u00a8\u0006\u0013"}, d2 = {"Lcom/nexlab/openclaw/node/data/remote/NodeClient$ConnectionStatus;", "", "connected", "", "nodeId", "", "(ZLjava/lang/String;)V", "getConnected", "()Z", "getNodeId", "()Ljava/lang/String;", "component1", "component2", "copy", "equals", "other", "hashCode", "", "toString", "app_debug"})
    public static final class ConnectionStatus {
        private final boolean connected = false;
        @org.jetbrains.annotations.NotNull
        private final java.lang.String nodeId = null;
        
        public ConnectionStatus(boolean connected, @org.jetbrains.annotations.NotNull
        java.lang.String nodeId) {
            super();
        }
        
        public final boolean getConnected() {
            return false;
        }
        
        @org.jetbrains.annotations.NotNull
        public final java.lang.String getNodeId() {
            return null;
        }
        
        public final boolean component1() {
            return false;
        }
        
        @org.jetbrains.annotations.NotNull
        public final java.lang.String component2() {
            return null;
        }
        
        @org.jetbrains.annotations.NotNull
        public final com.nexlab.openclaw.node.data.remote.NodeClient.ConnectionStatus copy(boolean connected, @org.jetbrains.annotations.NotNull
        java.lang.String nodeId) {
            return null;
        }
        
        @java.lang.Override
        public boolean equals(@org.jetbrains.annotations.Nullable
        java.lang.Object other) {
            return false;
        }
        
        @java.lang.Override
        public int hashCode() {
            return 0;
        }
        
        @java.lang.Override
        @org.jetbrains.annotations.NotNull
        public java.lang.String toString() {
            return null;
        }
    }
}