class Constants {

	public static String webViewLocation(Parameters parameters) {
		if (isExternalUi(parameters)) {
			return "http://localhost:9000";
		}
		URL selfUri = checkNotNull(Constants.class.getResource(Constants.class.getSimpleName() + ".class"));
		String protocol = selfUri.getProtocol();
		if ("file".equals(protocol)) {
			String path = selfUri.getPath();
			checkState(path.contains("target/classes"));
			String rootPath = path.substring(0, path.indexOf("target/classes"));

			File file = new File(rootPath);

			String localPath = file.getParentFile().getPath() + "/ui/dist/index.html";
			return "file://" + localPath;
		} else if ("jar".equals(protocol)) {
			String path = selfUri.getPath();
			Matcher matcher = Pattern.compile("(.*?/)([^/]+\\.jar!).*").matcher(path);
			checkState(matcher.matches(), "%s", path);

			String prefix = matcher.group(1);
			return prefix + "web-assets/index.html";
		} else {
			throw new IllegalStateException(selfUri.toString());
		}
	}

}