{"version":3,"file":"products-cd08f84c.js","sources":["../../client/packages/utils/src/map/products.ts"],"sourcesContent":["import type {ProductListItem} from \"@songfinch/types\";\n\nexport const sortedProducts = (products: ProductListItem[], sortIds: string[]) => {\n if (!products) return undefined;\n if (!sortIds) return products;\n\n // Reverse the sortIds and sort backwards \n // so that products that are not in sortIds are at the end\n const reverseSortIds = [...sortIds].reverse();\n\n const sortedProducts = (products).sort((a, b) => {\n const indexA = reverseSortIds.indexOf(a.name);\n const indexB = reverseSortIds.indexOf(b.name);\n return indexB - indexA;\n });\n\n return sortedProducts;\n};\n\nexport const filterProductsByIds = (products: ProductListItem[], includeIds: string[]) => {\n if (!products) return undefined;\n if (!includeIds) return products;\n\n return sortedProducts(products.filter((product) => includeIds.includes(product.name)), includeIds);\n};\n"],"names":["sortedProducts","products","sortIds","reverseSortIds","a","b","indexA","filterProductsByIds","includeIds","product"],"mappings":"kmBAEa,CAAA,MAAAA,EAAiB,CAACC,EAA6BC,IAAsB,CAC9E,GAAI,CAACD,EAAiB,OACtB,GAAI,CAACC,EAAgB,OAAAD,EAIrB,MAAME,EAAiB,CAAC,GAAGD,CAAO,EAAE,QAAQ,EAQrCF,OANiBC,EAAU,KAAK,CAACG,EAAGC,IAAM,CAC7C,MAAMC,EAASH,EAAe,QAAQC,EAAE,IAAI,EAE5C,OADeD,EAAe,QAAQE,EAAE,IAAI,EAC5BC,CAAA,CACnB,CAGL,EAEaC,EAAsB,CAACN,EAA6BO,IAAyB,CACtF,GAAKP,EACL,OAAKO,EAEER,EAAeC,EAAS,OAAQQ,GAAYD,EAAW,SAASC,EAAQ,IAAI,CAAC,EAAGD,CAAU,EAFzEP,CAG5B"}