/* jshint node:true */
'use strict';

var helper = {
	/***
	 ** admin catalog
	 */
	getPanelTitleSelectorByProductName: function(productName) {
		return '//span[contains(text(),"- ' + productName + '")]';
	},
	getInputProductNameSelectorByProductName: function(productName) {
		var panelTitleSelector = this.getPanelTitleSelectorByProductName(productName);
		return '//div[ contains(@class,"panel")  and  .' + panelTitleSelector + ']//input[contains(@class,"input-product-name")]';
	},
	getInputBrandNameSelectorByProductName: function(productName) {
		var panelTitleSelector = this.getPanelTitleSelectorByProductName(productName);
		return '//div[ contains(@class,"panel")  and  .' + panelTitleSelector + ']//input[contains(@class,"input-brand-name")]';
	},
	getInputImageUrlSelectorByProductName: function(productName) {
		var panelTitleSelector = this.getPanelTitleSelectorByProductName(productName);
		return '//div[ contains(@class,"panel")  and  .' + panelTitleSelector + ']//input[contains(@class,"input-image-url")]';
	},
	getButtonToUpdateReviewsSelector: function(productName) {
		var panelTitleSelector = this.getPanelTitleSelectorByProductName(productName);
		return '//div[ contains(@class,"panel")  and  .' + panelTitleSelector + ']//button[contains(@class,"btn-update-number-of-reviews")]';
	},
	getButtonToPublishAnalyzedAndUnpublishedReviewsSelector: function(productName) {
		var panelTitleSelector = this.getPanelTitleSelectorByProductName(productName);
		return '//div[ contains(@class,"panel")  and  .' + panelTitleSelector + ']//*[contains(@class,"w-publish-analyzed-and-unpublished-reviews")]';
	},
	getTotalNumberOfReviewsSelector: function(productName) {
		var panelTitleSelector = this.getPanelTitleSelectorByProductName(productName);
		return '//div[ contains(@class,"panel")  and  .' + panelTitleSelector + ']//span[contains(@class,"reviews-number-total")]';
	},
	getNumberOfSampledReviewsSelector: function(productName) {
		var panelTitleSelector = this.getPanelTitleSelectorByProductName(productName);
		return '//div[ contains(@class,"panel")  and  .' + panelTitleSelector + ']//span[contains(@class,"reviews-number-sampled")]';
	},
	getNumberOfAnalyzedReviewsSelector: function(productName) {
		var panelTitleSelector = this.getPanelTitleSelectorByProductName(productName);
		return '//div[ contains(@class,"panel")  and  .' + panelTitleSelector + ']//span[contains(@class,"reviews-number-analyzed")]';
	},
	getPriceRangeMaxSelector: function(productName) {
		var panelTitleSelector = this.getPanelTitleSelectorByProductName(productName);
		return '//div[ contains(@class,"panel")  and  .' + panelTitleSelector + ']//input[contains(@class,"price-range-max-input")]';
	},
	getPriceRangeMinSelector: function(productName) {
		var panelTitleSelector = this.getPanelTitleSelectorByProductName(productName);
		return '//div[ contains(@class,"panel")  and  .' + panelTitleSelector + ']//input[contains(@class,"price-range-min-input")]';
	},
	getButtonToUpdatePriceRangeSelector: function(productName) {
		var panelTitleSelector = this.getPanelTitleSelectorByProductName(productName);
		return '//div[ contains(@class,"panel")  and  .' + panelTitleSelector + ']//button[contains(@class,"price-range-update-btn")]';
	},
	getCountriesSelector: function(productName) {
		var panelTitleSelector = this.getPanelTitleSelectorByProductName(productName);
		return '//div[ contains(@class,"panel")  and  .' + panelTitleSelector + ']//span[contains(@class,"label-country")]';
	},
	getCountryInputByProductName: function(productName) {
		var panelTitleSelector = this.getPanelTitleSelectorByProductName(productName);
		return '//div[ contains(@class,"panel")  and  .' + panelTitleSelector + ']//input[contains(@class,"country-input")]';
	},
	getCountryAddButton: function(productName) {
		var panelTitleSelector = this.getPanelTitleSelectorByProductName(productName);
		return '//div[ contains(@class,"panel")  and  .' + panelTitleSelector + ']//button[contains(@class,"country-add-btn")]';
	},
	getCompanyIDToAddSelector: function(productName) {
		var panelTitleSelector = this.getPanelTitleSelectorByProductName(productName);
		return '//div[ contains(@class,"panel")  and  .' + panelTitleSelector + ']//button[contains(@class,"company-id-input")]';
	},
	// company id
	getCompanyIDSelector: function(productName) {
		var panelTitleSelector = this.getPanelTitleSelectorByProductName(productName);
		return '//div[ contains(@class,"panel")  and  .' + panelTitleSelector + ']//span[contains(@class,"label-company-id")]';
	},
	getCompanyIdInputSelector: function(productName) {
		var panelTitleSelector = this.getPanelTitleSelectorByProductName(productName);
		return '//div[ contains(@class,"panel")  and  .' + panelTitleSelector + ']//input[contains(@class,"company-id-input")]';
	},
	getCompanyIDAddButton: function(productName) {
		var panelTitleSelector = this.getPanelTitleSelectorByProductName(productName);
		return '//div[ contains(@class,"panel")  and  .' + panelTitleSelector + ']//button[contains(@class,"company-id-add-btn")]';
	},
	// sku
	getSkusSelector: function(productName) {
		var panelTitleSelector = this.getPanelTitleSelectorByProductName(productName);
		return '//div[ contains(@class,"panel")  and  .' + panelTitleSelector + ']//span[contains(@class,"label-sku")]';
	},
	getSkuInputSelector: function(productName) {
		var panelTitleSelector = this.getPanelTitleSelectorByProductName(productName);
		return '//div[ contains(@class,"panel")  and  .' + panelTitleSelector + ']//input[contains(@class,"sku-input")]';
	},
	getSkuAddButton: function(productName) {
		var panelTitleSelector = this.getPanelTitleSelectorByProductName(productName);
		return '//div[ contains(@class,"panel")  and  .' + panelTitleSelector + ']//input[contains(@class,"sku-add-btn")]';
	},
	// review title
	getReviewTitlesSelector: function(productName) {
		var panelTitleSelector = this.getPanelTitleSelectorByProductName(productName);
		return '//div[ contains(@class,"panel")  and  .' + panelTitleSelector + ']//span[contains(@class,"label-review-title")]';
	},
	getReviewTitleInputSelector: function(productName) {
		var panelTitleSelector = this.getPanelTitleSelectorByProductName(productName);
		return '//div[ contains(@class,"panel")  and  .' + panelTitleSelector + ']//input[contains(@class,"review-title-input")]';
	},
	getReviewTitleAddButton: function(productName) {
		var panelTitleSelector = this.getPanelTitleSelectorByProductName(productName);
		return '//div[ contains(@class,"panel")  and  .' + panelTitleSelector + ']//input[contains(@class,"review-title-add-btn")]';
	},
	//
	getPriceCategorySelector: function(productName) {
		var panelTitleSelector = this.getPanelTitleSelectorByProductName(productName);
		return '//div[ contains(@class,"panel")  and  .' + panelTitleSelector + ']//select[contains(@class,"price-category-select")]';
	},
	getPriceCategoryOptionSelector: function(productName, value) {
		var panelTitleSelector = this.getPanelTitleSelectorByProductName(productName);
		return '//div[ contains(@class,"panel")  and  .' + panelTitleSelector + ']//select[contains(@class,"price-category-select")]//option[contains(text(),"' + value + '")]';
	},
	getProductCategorySelectValueSelector: function(productName) {
		var panelTitleSelector = this.getPanelTitleSelectorByProductName(productName);
		return '//div[ contains(@class,"panel")  and  .' + panelTitleSelector + ']//select[contains(@class,"product-category-select")]';
	},
	getProductCategoryOptionSelector: function(productName, value) {
		var panelTitleSelector = this.getPanelTitleSelectorByProductName(productName);
		return '//div[ contains(@class,"panel")  and  .' + panelTitleSelector + ']//select[contains(@class,"product-category-select")]//option[contains(text(),"' + value + '")]';
	},
	// assignment analyst 2 language
	getAssignmentsAnalystToLanguageSelector: function(productName) {
		var panelTitleSelector = this.getPanelTitleSelectorByProductName(productName);
		return '//div[ contains(@class,"panel")  and  .' + panelTitleSelector + ']//span[contains(@class,"label-analyst-language-assignment")]';
	},
	getAnalystSelector: function(productName, value) {
		var panelTitleSelector = this.getPanelTitleSelectorByProductName(productName);
		return '//div[ contains(@class,"panel")  and  .' + panelTitleSelector + ']//select[contains(@class,"analyst-select")]//option[contains(text(),"' + value + '")]';
	},
	getLanguageSelector: function(productName, value) {
		var panelTitleSelector = this.getPanelTitleSelectorByProductName(productName);
		//return '//div[ contains(@class,"panel")  and  .' + panelTitleSelector + ']//select[contains(@class,"language-select")]//option[contains(text(),"' + value + '")]';
		return '//div[ contains(@class,"panel")  and  .' + panelTitleSelector + ']//select[contains(@class,"language-select")]//option[ contains(text(),"' + value + '") ]';
	},
	getDataSourceSelector: function(productName, value) {
		var panelTitleSelector = this.getPanelTitleSelectorByProductName(productName);
		return '//div[ contains(@class,"panel")  and  .' + panelTitleSelector + ']//select[contains(@class,"data-source-select")]//option[contains(text(),"' + value + '")]';
	},
	getAssigningButtonSelector: function(productName) {
		var panelTitleSelector = this.getPanelTitleSelectorByProductName(productName);
		return '//div[ contains(@class,"panel")  and  .' + panelTitleSelector + ']//button[contains(@class,"assigning-btn")]';
	},
	getAssignmentAnalystToLanguage: function(productName, analystName, language) {
		var panelTitleSelector = this.getPanelTitleSelectorByProductName(productName);
		return '//div[ contains(@class,"panel")  and  .' + panelTitleSelector + ']//span[contains(@class,"assignment") and contains(text(),"' + analystName + '") and contains(text(),"' + language + '" )]//i';
	},
	// assignment sku 2 language
	getFirstAssignmentSkuToReviewTitleSelector: function(productName) {
		var panelTitleSelector = this.getPanelTitleSelectorByProductName(productName);
		return '//div[ contains(@class,"panel")  and  .' + panelTitleSelector + ']//select[contains(@class,"sku-select")]';
	},
	getSkuSelector: function(productName, value) {
		var panelTitleSelector = this.getPanelTitleSelectorByProductName(productName);
		return '//div[ contains(@class,"panel")  and  .' + panelTitleSelector + ']//select[contains(@class,"sku-select")]//option[contains(text(),"' + value + '")]';
	},
	// channels
	getUpdateChannelButtonSelector: function(productName) {
		var panelTitleSelector = this.getPanelTitleSelectorByProductName(productName);
		return '//div[ contains(@class,"panel")  and  .' + panelTitleSelector + ']//button[contains(@class,"update-channel-btn")]';
	},
	getChannelsSelector: function(productName) {
		var panelTitleSelector = this.getPanelTitleSelectorByProductName(productName);
		return '//div[ contains(@class,"panel")  and  .' + panelTitleSelector + ']//span[contains(@class,"label-channel")]';
	},
	getMinDateSelector: function(productName) {
		var panelTitleSelector = this.getPanelTitleSelectorByProductName(productName);
		return '//div[ contains(@class,"panel")  and  .' + panelTitleSelector + ']//span[contains(@class,"min-date")]';
	},
	getMaxDateSelector: function(productName) {
		var panelTitleSelector = this.getPanelTitleSelectorByProductName(productName);
		return '//div[ contains(@class,"panel")  and  .' + panelTitleSelector + ']//span[contains(@class,"max-date")]';
	},
	getUpdateMinAndMaxDateButtonSelector: function(productName) {
		var panelTitleSelector = this.getPanelTitleSelectorByProductName(productName);
		return '//div[ contains(@class,"panel")  and  .' + panelTitleSelector + ']//button[contains(@class,"min-max-date-updating-button")]';
	},
	getLanguagesSelector: function(productName) {
		var panelTitleSelector = this.getPanelTitleSelectorByProductName(productName);
		return '//div[ contains(@class,"panel")  and  .' + panelTitleSelector + ']//span[contains(@class," language ") ]';
	},
	getUpdateLanguagesButtonSelector: function(productName) {
		var panelTitleSelector = this.getPanelTitleSelectorByProductName(productName);
		return '//div[ contains(@class,"panel")  and  .' + panelTitleSelector + ']//button[contains(@class,"languages-updating-button")]';
	},
	getAvgRatingSelector: function(productName) {
		var panelTitleSelector = this.getPanelTitleSelectorByProductName(productName);
		return '//div[ contains(@class,"panel")  and  .' + panelTitleSelector + ']//span[contains(@class,"avg-rating")]';
	},
	getUpdateAvgRatingButtonSelector: function(productName) {
		var panelTitleSelector = this.getPanelTitleSelectorByProductName(productName);
		return '//div[ contains(@class,"panel")  and  .' + panelTitleSelector + ']//button[contains(@class,"avg-rating-updating-button")]';
	},
	getWonderboardVisibilityCheckboxSelector: function(productName) {
		var panelTitleSelector = this.getPanelTitleSelectorByProductName(productName);
		return '//div[ contains(@class,"panel")  and  .' + panelTitleSelector + ']//input[contains(@class,"wonderboard-visibility-checkbox")]';
	},
	getAnnotationAppVisibilityCheckboxSelector: function(productName) {
		var panelTitleSelector = this.getPanelTitleSelectorByProductName(productName);
		return '//div[ contains(@class,"panel")  and  .' + panelTitleSelector + ']//input[contains(@class,"annotation-app-visibility-checkbox")]';
	},
	getEditInsightsTriggerSelector: function(productName) {
		var panelTitleSelector = this.getPanelTitleSelectorByProductName(productName);
		return '//div[ contains(@class,"panel")  and  .' + panelTitleSelector + ']//*[contains(@class,"w-edit-insights")]';
	},
	/***
	 ** /insights-list
	 */
	getInsightTextInput: function() {
		return '(//*[contains(@class, "insight-container") and position()=1]//*[contains(@class,"insight-text-input")])[1]';
	},
	getFirstInsightSaveButton: function() {
		return '(//*[contains(@class, "insight-container") and position()=1]//*[contains(@class,"save-text-insight-button")  ])[1]';
	},
	getBrandNameSelector: function() {
		return '(//*[contains(@class,"brand-name")])[1]';
	},
	getProductNameSelector: function() {
		return '(//*[contains(@class,"product-name")])[1]';
	},
	getNumberOfPublishedInsightSelector: function() {
		return '//*[contains(@class,"w-number-of-published-insights")]';
	},
	getInsightContainersSelector: function() {
		return '//*[contains(@class, "insight-container")]';
	},
	getFirst2InsightsSelector: function() {
		return '//*[contains(@class, "insight-container") and position()<3]//*[contains(@class, "insight-text-input")]';
	},
	getNumberOfLinkedReviewsOfFirstInsight: function() {
		return '(//*[contains(@class,"number-of-linked-reviews")])[1]';
	},
	getLinkOfLinkedReviewsOfFirstInsightSelector: function() {
		return '(//*[contains(@class, "insight-container") and position()=1]//*[contains(@class, "w-go-to-linked-reviews")])[1]';
	},
	// linked-reviews
	getInsightTextSelector: function() {
		return '//*[contains(@class,"w-insight-text")]';
	},
	getNumberOfLinkedReviewsSelector: function() {
		return '//*[contains(@class,"w-number-of-linked-reviews")]';
	},
	getVisualizedLinkedReviewsSelector: function() {
		return '//*[contains(@class,"w-linked-review-item")]';
	},
	getTitleOfFirstLinkedReviewSelector: function() {
		return '//*[contains(@class,"w-linked-review-item")]//*[contains(@class,"w-linked-review-title")]';
	},
	getButtonToUnlinkFirstLinkedReviewSelector: function() {
		return '(//*[contains(@class,"w-linked-review-item") and position()=1 ]//*[contains(@class,"w-unlink-linked-review")])[1]';
	}
};

module.exports = helper;