//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package kinosearch.core;

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.HashSet;
import java.util.Set;
import java.util.regex.Pattern;
import kinosearch.core.browser.Browser;
import kinosearch.core.browser.SimpleBrowser;
import kinosearch.core.warez.Hdrezka;
import kinosearch.core.warez.KinoWarez;
import kinosearch.core.warez.Onlinelife;

public class Tools {
    public static final String VERSION = "2.0.7с";
    private static Set<KinoWarez> kinoWarezSet;

    public static Browser createBrowser() {
        return new SimpleBrowser();
    }

    public static String SafeUrlEncode(String string, String encode) {
        try {
            return URLEncoder.encode(string, encode);
        } catch (UnsupportedEncodingException var3) {
            return string;
        }
    }

    public static String getFileFromURI(String uri, String context) {
        if (context != null && !context.isEmpty()) {
            String[] strArr = uri.split(context);
            return strArr.length < 2 ? uri : strArr[1];
        } else {
            return uri;
        }
    }

    public static Set<KinoWarez> getKinoWarezSet() {
        if (kinoWarezSet == null) {
            kinoWarezSet = new HashSet();
            kinoWarezSet.add(new Onlinelife());
            kinoWarezSet.add(new Hdrezka());
        }

        return kinoWarezSet;
    }

    public static void SafeSleep(long ms) {
        try {
            Thread.sleep(ms);
        } catch (InterruptedException var3) {
        }

    }

    public static Pattern getStrongPattern(String name) {
        return Pattern.compile("(^" + name + "[\\s:])|(\\s" + name + "[\\s:])|(\\s" + name + "$)|(^" + name + "$)");
    }

    public static String cleanString(String string) {
        char ch = 160;
        return string.toLowerCase().replaceAll(ch + "", " ").replaceAll("[_\\+\\-\\.,!@#$%^&*\\(\\);:\\\\\\/\\|<>\"'?=`~№\\[\\]\\{\\}]", " ").replaceAll(" {2,}", " ").trim();
    }
}
