package com.pichillilorenzo.flutter_inappwebview_android.find_interaction;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.pichillilorenzo.flutter_inappwebview_android.InAppWebViewFlutterPlugin;
import com.pichillilorenzo.flutter_inappwebview_android.types.Disposable;
import com.pichillilorenzo.flutter_inappwebview_android.types.FindSession;
import com.pichillilorenzo.flutter_inappwebview_android.webview.InAppWebViewInterface;
import ed.u;

/* JADX INFO: loaded from: classes.dex */
public class FindInteractionController implements Disposable {
    static final String LOG_TAG = "FindInteractionController";
    public static final String METHOD_CHANNEL_NAME_PREFIX = "com.pichillilorenzo/flutter_inappwebview_find_interaction_";

    @Nullable
    public FindSession activeFindSession;

    @Nullable
    public FindInteractionChannelDelegate channelDelegate;

    @Nullable
    public String searchText;

    @Nullable
    public FindInteractionSettings settings;

    @Nullable
    public InAppWebViewInterface webView;

    public FindInteractionController(@NonNull InAppWebViewInterface inAppWebViewInterface, @NonNull InAppWebViewFlutterPlugin inAppWebViewFlutterPlugin, @NonNull Object obj, @Nullable FindInteractionSettings findInteractionSettings) {
        this.webView = inAppWebViewInterface;
        this.settings = findInteractionSettings;
        this.channelDelegate = new FindInteractionChannelDelegate(this, new u(inAppWebViewFlutterPlugin.messenger, METHOD_CHANNEL_NAME_PREFIX + obj));
    }

    public void clearMatches() {
        InAppWebViewInterface inAppWebViewInterface = this.webView;
        if (inAppWebViewInterface != null) {
            inAppWebViewInterface.clearMatches();
        }
    }

    @Override // com.pichillilorenzo.flutter_inappwebview_android.types.Disposable
    public void dispose() {
        FindInteractionChannelDelegate findInteractionChannelDelegate = this.channelDelegate;
        if (findInteractionChannelDelegate != null) {
            findInteractionChannelDelegate.dispose();
            this.channelDelegate = null;
        }
        this.webView = null;
        this.activeFindSession = null;
        this.searchText = null;
    }

    public void findAll(@Nullable String str) {
        if (str == null) {
            str = this.searchText;
        } else {
            this.searchText = str;
        }
        InAppWebViewInterface inAppWebViewInterface = this.webView;
        if (inAppWebViewInterface == null || str == null) {
            return;
        }
        inAppWebViewInterface.findAllAsync(str);
    }

    public void findNext(boolean z10) {
        InAppWebViewInterface inAppWebViewInterface = this.webView;
        if (inAppWebViewInterface != null) {
            inAppWebViewInterface.findNext(z10);
        }
    }

    public void prepare() {
    }
}
