"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ExampleHookUseResults = void 0;
const react_1 = __importDefault(require("react"));
const hooks_1 = require("../../hooks");
const types_1 = require("../../types");
const ExampleHookUseResults = () => {
    const resultsHook = (0, hooks_1.useResults)();
    const collections = resultsHook.results
        .map((result) => {
        if (result.type === types_1.ElasticDocumentType.Product) {
            return result.collections;
        }
        return [];
    })
        .flat()
        .filter((item, index, self) => self.findIndex((itemNested) => (itemNested === null || itemNested === void 0 ? void 0 : itemNested.id) === (item === null || item === void 0 ? void 0 : item.id)) === index);
    return (react_1.default.createElement("ul", null, collections.map((collection) => (react_1.default.createElement("li", null,
        react_1.default.createElement("a", { href: `/collections/${collection === null || collection === void 0 ? void 0 : collection.handle}` }, collection === null || collection === void 0 ? void 0 : collection.title))))));
};
exports.ExampleHookUseResults = ExampleHookUseResults;
//# sourceMappingURL=ExampleHookUseResults.js.map