<commit_before>// Dependencies

let builder = require('focus').component.builder;
let camel = require('lodash/string/camelCase');
let capitalize = require('lodash/string/capitalize');

// Components

let FacetBox = require('./facet-box').component;
let ListActionBar = require('./action-bar').component;
let ListSummary = require('./list-summary').component;
let Results = require('../common/component/results').component;

let BackToTopComponent = require('../../../common/button/back-to-top').component;

// Store

let advancedSearchStore = Focus.search.builtInStore.advancedSearchStore;

// Mixins

let CartridgeBehaviour = require('../../mixin/cartridge-behaviour');
let type = require('focus').component.types;

// Actions

let actionBuilder = Focus.search.actionBuilder;

/**
 * Page mixin of the advanced search.
 * @type {Object}
 */
let AdvancedSearch = {
    /**
     * Component's mixins
     * @type {Array}
     */
    mixins: [CartridgeBehaviour],
    /**
     * Display name.
     */
    displayName: 'advanced-search',
    /**
     * Get the default props
     * @return {object} the default props
     */
    getDefaultProps() {
        return {
            facetConfig: {},
            scopesConfig: {},
            isSelection: true,
            hasBackToTop: true,
            backToTopComponent: BackToTopComponent,
            store: advancedSearchStore,
            action: undefined,
            service: undefined,
            orderableColumnList: {},
            lineOperationList: {},
            exportAction: {},
            groupComponent: undefined,
            lineComponentMapper: undefined,
            scrollParentSelector: undefined,
            onLineClick: undefined
        };
    },
    /**
     * Props validation
     * @type {Object}
     */
    propTypes: {
        scopesConfig: type('object'),
        facetConfig: type('object'),
        isSelection: type('boolean'),
        hasBackToTop: type('boolean'),
        backToTopComponent: type('object'),
        store: type('object'),
        action: type('object'),
        service: type('object'),
        orderableColumnList: type('object'),
        lineOperationList: type('object'),
        exportAction: type('function'),
        groupComponent: type('object'),
        lineComponentMapper: type('function'),
        scrollParentSelector: type('string'),
        onLineClick: type('function')
    },
    getInitialState() {
        return ({

        });
    },
    /**
     * Register the store listeners
     */
    componentWillMount() {
        ['query', 'scope', 'selected-facets', 'grouping-key', 'sort-by', 'sort-asc'].forEach((node) => {
            this.props.store[`add${capitalize(camel(node))}ChangeListener`](this._onStoreChangeWithSearch);
        });
        ['facets', 'results', 'total-count'].forEach((node) => {
            this.props.store[`add${capitalize(camel(node))}ChangeListener`](this._onStoreChangeWithoutSearch);
        });
        this._action = this.props.action || actionBuilder({
            service: this.props.service,
            identifier: this.props.store.identifier,
            getSearchOptions: () => {return this.props.store.getValue.call(this.props.store); } // Binding the store in the function call
        });
    },
    /**
     * Un-register the store listeners
     */
    componentWillUnmount() {
        ['query', 'scope', 'selected-facets', 'grouping-key', 'sort-by', 'sort-asc'].forEach((node) => {
            this.props.store[`remove${capitalize(camel(node))}ChangeListener`](this._onStoreChangeWithSearch);
        });
        ['facets', 'results', 'total-count'].forEach((node) => {
            this.props.store[`remove${capitalize(camel(node))}ChangeListener`](this._onStoreChangeWithoutSearch);
        });
    },
    /**<commit_msg>[advanced-search] Init the state on store<commit_after>// Dependencies

let builder = require('focus').component.builder;
let camel = require('lodash/string/camelCase');
let capitalize = require('lodash/string/capitalize');

// Components

let FacetBox = require('./facet-box').component;
let ListActionBar = require('./action-bar').component;
let ListSummary = require('./list-summary').component;
let Results = require('../common/component/results').component;

let BackToTopComponent = require('../../../common/button/back-to-top').component;

// Store

let advancedSearchStore = Focus.search.builtInStore.advancedSearchStore;

// Mixins

let CartridgeBehaviour = require('../../mixin/cartridge-behaviour');
let type = require('focus').component.types;

// Actions

let actionBuilder = Focus.search.actionBuilder;

/**
 * Page mixin of the advanced search.
 * @type {Object}
 */
let AdvancedSearch = {
    /**
     * Component's mixins
     * @type {Array}
     */
    mixins: [CartridgeBehaviour],
    /**
     * Display name.
     */
    displayName: 'advanced-search',
    /**
     * Get the default props
     * @return {object} the default props
     */
    getDefaultProps() {
        return {
            facetConfig: {},
            scopesConfig: {},
            isSelection: true,
            hasBackToTop: true,
            backToTopComponent: BackToTopComponent,
            store: advancedSearchStore,
            action: undefined,
            service: undefined,
            orderableColumnList: {},
            lineOperationList: {},
            exportAction: {},
            groupComponent: undefined,
            lineComponentMapper: undefined,
            scrollParentSelector: undefined,
            onLineClick: undefined
        };
    },
    /**
     * Props validation
     * @type {Object}
     */
    propTypes: {
        scopesConfig: type('object'),
        facetConfig: type('object'),
        isSelection: type('boolean'),
        hasBackToTop: type('boolean'),
        backToTopComponent: type('object'),
        store: type('object'),
        action: type('object'),
        service: type('object'),
        orderableColumnList: type('object'),
        lineOperationList: type('object'),
        exportAction: type('function'),
        groupComponent: type('object'),
        lineComponentMapper: type('function'),
        scrollParentSelector: type('string'),
        onLineClick: type('function')
    },
    getInitialState() {
        return (this._getNewStateFromStore());
    },
    /**
     * Register the store listeners
     */
    componentWillMount() {
        ['query', 'scope', 'selected-facets', 'grouping-key', 'sort-by', 'sort-asc'].forEach((node) => {
            this.props.store[`add${capitalize(camel(node))}ChangeListener`](this._onStoreChangeWithSearch);
        });
        ['facets', 'results', 'total-count'].forEach((node) => {
            this.props.store[`add${capitalize(camel(node))}ChangeListener`](this._onStoreChangeWithoutSearch);
        });
        this._action = this.props.action || actionBuilder({
            service: this.props.service,
            identifier: this.props.store.identifier,
            getSearchOptions: () => {return this.props.store.getValue.call(this.props.store); } // Binding the store in the function call
        });
    },
    /**
     * Un-register the store listeners
     */
    componentWillUnmount() {
        ['query', 'scope', 'selected-facets', 'grouping-key', 'sort-by', 'sort-asc'].forEach((node) => {
            this.props.store[`remove${capitalize(camel(node))}ChangeListener`](this._onStoreChangeWithSearch);
        });
        ['facets', 'results', 'total-count'].forEach((node) => {
            this.props.store[`remove${capitalize(camel(node))}ChangeListener`](this._onStoreChangeWithoutSearch);
        });
    },
    /**
{'fraction_non_alphanumeric': 0.15251572327044025, 'fraction_numerical': 0.0, 'mean_word_length': 2.6347619047619046, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7374254', 'n_tokens_mistral': 2103, 'n_tokens_neox': 2059, 'n_words': 374}