import { REDUX_ATTRIBUTE_FORM_FIELD_NAME, REDUX_FIELD_NAME } from '../../constants';

import { slice } from '../slices';
import createFormSelector from '@/modules/@common/Form/redux/selectors';

const nameSpace = slice.name;
const formSelectors = createFormSelector(REDUX_FIELD_NAME, nameSpace);
const formAttributeSelectors = createFormSelector(REDUX_ATTRIBUTE_FORM_FIELD_NAME, nameSpace);

export const idSelector = (state) => state[nameSpace].id;
export const providerSelector = (state) => state[nameSpace].provider;
export const displayNameSelector = (state) => state[nameSpace].displayName;
export const allDomainsSelector = (state) => state[nameSpace].allDomains;
export const onlyExistingSelector = (state) => state[nameSpace].onlyExisting;
export const domainsSelector = (state) => state[nameSpace].domains;
export const metadataURLSelector = (state) => state[nameSpace].metadataURL;
export const settingsAllDomainsDisabledSelector = (state) => state[nameSpace].settings.allDomainsDisabled;
export const settingsCannotCreateProfileSelector = (state) => state[nameSpace].settings.cannotCreateProfile;
export const settingsSingleSignOnUrlSelector = (state) => state[nameSpace].settings.singleSignOnUrl;
export const settingsAudienceUriSelector = (state) => state[nameSpace].settings.audienceUri;
export const ssoDefaultHubsSelector = (state) => state[nameSpace].ssoDefaultHubs;
export const allHubsSelectors = (state) => state[nameSpace].allHubs;
export const hubOptionsSelector = (state) => state[nameSpace].hubOptions;
export const ssoCustomAttributesSelector = (state) => state[nameSpace].ssoCustomAttributes;
export const activeTabIdSelector = (state) => state[nameSpace].activeTabId;

// attributes
export const attributeNameSelector = (state) => state[nameSpace].attributeName;
export const attributesKeyValuesSelector = (state) => state[nameSpace].attributesKeyValues;
export const attributeHubsSelector = (state) => state[nameSpace].attributeHubs;
export const attributeAllHubsSelector = (state) => state[nameSpace].attributeAllHubs;

// forms
export const scrollFieldSelector = (state) => formSelectors.getScrollField(state);
export const schemeSelector = (state) => formSelectors.schemeSelector(state);
export const fullAccessToStoreFieldsForValidation = (state) => state[nameSpace];

export const scrollFieldAttributeFormSelector = (state) => formAttributeSelectors.getScrollField(state);
export const schemeAttributeFormSelector = (state) => formAttributeSelectors.schemeSelector(state);
