import { Selectors } from "@coveo/headless/commerce";
import { DEFAULT_MOBILE_BREAKPOINT } from "../../../utils/replace-breakpoint-utils.js";
import { createBaseStore, setLoadingFlag, unsetLoadingFlag } from "../../common/interface/store.js";
import { makeDesktopQuery } from "../../search/atomic-search-layout/search-layout.js";
function createCommerceStore(type) {
    const store = createBaseStore({
        loadingFlags: [],
        iconAssetsPath: '',
        resultList: void 0,
        mobileBreakpoint: DEFAULT_MOBILE_BREAKPOINT,
        activeProductChild: void 0
    });
    return {
        ...store,
        unsetLoadingFlag (loadingFlag) {
            unsetLoadingFlag(store, loadingFlag);
        },
        setLoadingFlag (loadingFlag) {
            setLoadingFlag(store, loadingFlag);
        },
        isMobile () {
            return !window.matchMedia(makeDesktopQuery(store.state.mobileBreakpoint)).matches;
        },
        getUniqueIDFromEngine (engine) {
            switch(type){
                case 'search':
                    return Selectors.Search.responseIdSelector(engine);
                case 'product-listing':
                    return Selectors.ProductListing.responseIdSelector(engine);
            }
        }
    };
}
export { createCommerceStore };
