{"version":3,"file":"findHeader-BBCOC_Fx.js","sources":["../../../node_modules/lodash/_createFind.js","../../../node_modules/lodash/findIndex.js","../../../node_modules/lodash/find.js","../../../app/javascript/lib/genres/findHeader.ts"],"sourcesContent":["var baseIteratee = require('./_baseIteratee'),\n isArrayLike = require('./isArrayLike'),\n keys = require('./keys');\n\n/**\n * Creates a `_.find` or `_.findLast` function.\n *\n * @private\n * @param {Function} findIndexFunc The function to find the collection index.\n * @returns {Function} Returns the new find function.\n */\nfunction createFind(findIndexFunc) {\n return function(collection, predicate, fromIndex) {\n var iterable = Object(collection);\n if (!isArrayLike(collection)) {\n var iteratee = baseIteratee(predicate, 3);\n collection = keys(collection);\n predicate = function(key) { return iteratee(iterable[key], key, iterable); };\n }\n var index = findIndexFunc(collection, predicate, fromIndex);\n return index > -1 ? iterable[iteratee ? collection[index] : index] : undefined;\n };\n}\n\nmodule.exports = createFind;\n","var baseFindIndex = require('./_baseFindIndex'),\n baseIteratee = require('./_baseIteratee'),\n toInteger = require('./toInteger');\n\n/* Built-in method references for those with the same name as other `lodash` methods. */\nvar nativeMax = Math.max;\n\n/**\n * This method is like `_.find` except that it returns the index of the first\n * element `predicate` returns truthy for instead of the element itself.\n *\n * @static\n * @memberOf _\n * @since 1.1.0\n * @category Array\n * @param {Array} array The array to inspect.\n * @param {Function} [predicate=_.identity] The function invoked per iteration.\n * @param {number} [fromIndex=0] The index to search from.\n * @returns {number} Returns the index of the found element, else `-1`.\n * @example\n *\n * var users = [\n * { 'user': 'barney', 'active': false },\n * { 'user': 'fred', 'active': false },\n * { 'user': 'pebbles', 'active': true }\n * ];\n *\n * _.findIndex(users, function(o) { return o.user == 'barney'; });\n * // => 0\n *\n * // The `_.matches` iteratee shorthand.\n * _.findIndex(users, { 'user': 'fred', 'active': false });\n * // => 1\n *\n * // The `_.matchesProperty` iteratee shorthand.\n * _.findIndex(users, ['active', false]);\n * // => 0\n *\n * // The `_.property` iteratee shorthand.\n * _.findIndex(users, 'active');\n * // => 2\n */\nfunction findIndex(array, predicate, fromIndex) {\n var length = array == null ? 0 : array.length;\n if (!length) {\n return -1;\n }\n var index = fromIndex == null ? 0 : toInteger(fromIndex);\n if (index < 0) {\n index = nativeMax(length + index, 0);\n }\n return baseFindIndex(array, baseIteratee(predicate, 3), index);\n}\n\nmodule.exports = findIndex;\n","var createFind = require('./_createFind'),\n findIndex = require('./findIndex');\n\n/**\n * Iterates over elements of `collection`, returning the first element\n * `predicate` returns truthy for. The predicate is invoked with three\n * arguments: (value, index|key, collection).\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Collection\n * @param {Array|Object} collection The collection to inspect.\n * @param {Function} [predicate=_.identity] The function invoked per iteration.\n * @param {number} [fromIndex=0] The index to search from.\n * @returns {*} Returns the matched element, else `undefined`.\n * @example\n *\n * var users = [\n * { 'user': 'barney', 'age': 36, 'active': true },\n * { 'user': 'fred', 'age': 40, 'active': false },\n * { 'user': 'pebbles', 'age': 1, 'active': true }\n * ];\n *\n * _.find(users, function(o) { return o.age < 40; });\n * // => object for 'barney'\n *\n * // The `_.matches` iteratee shorthand.\n * _.find(users, { 'age': 1, 'active': true });\n * // => object for 'pebbles'\n *\n * // The `_.matchesProperty` iteratee shorthand.\n * _.find(users, ['active', false]);\n * // => object for 'fred'\n *\n * // The `_.property` iteratee shorthand.\n * _.find(users, 'active');\n * // => object for 'barney'\n */\nvar find = createFind(findIndex);\n\nmodule.exports = find;\n","import { BasicTag } from \"types/TagType\";\nimport find from \"lodash/find\";\nimport { genreLink, moodLink, tagLink } from \"constants/ExploreLinks\";\nimport { cdnUrl } from \"lib/imageTools\";\nimport { TagSerializersBasicTag } from \"types/serializers\";\n\n// Genres with a cover image\nconst genresWithCover = [\n \"adventure\",\n \"classics\",\n \"dystopian\",\n \"fantasy\",\n \"fiction\",\n \"history\",\n \"lgbtq\",\n \"mystery\",\n \"nonfiction\",\n \"science-fiction\",\n \"war\",\n \"young-adult\",\n];\nexport const headerPath = \"/static/bookHeaders\";\nconst defaultHeader = `${headerPath}/bookstore.webp`;\n\nexport const GenresOptions = [\n { value: \"adventure\", label: \"Adventure\" },\n { value: \"classics\", label: \"Classics\" },\n { value: \"dystopian\", label: \"Dystopian\" },\n { value: \"fantasy\", label: \"Fantasy\" },\n { value: \"fiction\", label: \"Fiction\" },\n { value: \"history\", label: \"History\" },\n { value: \"lgbtq\", label: \"LGBTQ\" },\n { value: \"mystery\", label: \"Mystery\" },\n { value: \"nonfiction\", label: \"Nonfiction\" },\n { value: \"science-fiction\", label: \"Science Fiction\" },\n { value: \"war\", label: \"War\" },\n { value: \"young-adult\", label: \"Young Adult\" },\n]\n\nexport function findHeaderImageForGenres(\n tags: BasicTag[] | TagSerializersBasicTag[],\n unknownHeader = defaultHeader\n) {\n const genreSlugs = (tags || []).map((basicTag) => basicTag.tagSlug);\n\n if (genreSlugs.length === 0) {\n return cdnUrl(unknownHeader);\n }\n const headerGenre = find(\n genreSlugs,\n (genreSlug) => genresWithCover.indexOf(genreSlug) !== -1\n );\n\n return cdnUrl(\n headerGenre ? `${headerPath}/${headerGenre}.webp` : unknownHeader\n );\n}\nexport function findHeaderForGenres(\n tags: BasicTag[] | TagSerializersBasicTag[] ,\n unknownHeader = defaultHeader\n) {\n return findHeaderImageForGenres(tags, unknownHeader);\n}\n\nexport function headerForGenre(genre: string) {\n return cdnUrl(`${headerPath}/${genre}.webp`);\n}\n\nexport function tagIconFor(category: string) {\n if (category === \"genre\") {\n return genreLink.iconDuo;\n }\n if (category === \"mood\") {\n return moodLink.iconDuo;\n }\n return tagLink.iconDuo;\n}\n"],"names":["baseIteratee","require$$0","isArrayLike","require$$1","keys","require$$2","createFind","findIndexFunc","collection","predicate","fromIndex","iterable","iteratee","key","index","_createFind","baseFindIndex","toInteger","nativeMax","findIndex","array","length","findIndex_1","find","find_1","genresWithCover","headerPath","defaultHeader","GenresOptions","findHeaderImageForGenres","tags","unknownHeader","genreSlugs","basicTag","cdnUrl","headerGenre","genreSlug","findHeaderForGenres","headerForGenre","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