{
  "version": 3,
  "sources": ["../../../src/font-library/utils/filter-fonts.ts"],
  "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport type { CollectionFontFamily } from '@wordpress/core-data';\n\n/**\n * Filters a list of fonts based on the specified filters.\n *\n * This function filters a given array of fonts based on the criteria provided in the filters object.\n * It supports filtering by category and a search term. If the category is provided and not equal to 'all',\n * the function filters the fonts array to include only those fonts that belong to the specified category.\n * Additionally, if a search term is provided, it filters the fonts array to include only those fonts\n * whose name includes the search term, case-insensitively.\n *\n * @param fonts            Array of font objects in font-collection schema fashion to be filtered. Each font object should have a 'categories' property and a 'font_family_settings' property with a 'name' key.\n * @param filters          Object containing the filter criteria. It should have a 'category' key and/or a 'search' key.\n * @param filters.category The category to filter fonts by. If 'all', no category filtering is applied.\n * @param filters.search   The search term to filter fonts by. If provided, only fonts whose\n *\n * @return Array of filtered font objects based on the provided criteria.\n */\nexport default function filterFonts(\n\tfonts: CollectionFontFamily[],\n\tfilters: { category?: string; search?: string }\n): CollectionFontFamily[] {\n\tconst { category, search } = filters;\n\tlet filteredFonts = fonts || [];\n\n\tif ( category && category !== 'all' ) {\n\t\tfilteredFonts = filteredFonts.filter(\n\t\t\t( font ) =>\n\t\t\t\tfont.categories && font.categories.indexOf( category ) !== -1\n\t\t);\n\t}\n\n\tif ( search ) {\n\t\tfilteredFonts = filteredFonts.filter(\n\t\t\t( font ) =>\n\t\t\t\tfont.font_family_settings &&\n\t\t\t\tfont.font_family_settings.name\n\t\t\t\t\t.toLowerCase()\n\t\t\t\t\t.includes( search.toLowerCase() )\n\t\t);\n\t}\n\n\treturn filteredFonts;\n}\n"],
  "mappings": ";AAqBe,SAAR,YACN,OACA,SACyB;AACzB,QAAM,EAAE,UAAU,OAAO,IAAI;AAC7B,MAAI,gBAAgB,SAAS,CAAC;AAE9B,MAAK,YAAY,aAAa,OAAQ;AACrC,oBAAgB,cAAc;AAAA,MAC7B,CAAE,SACD,KAAK,cAAc,KAAK,WAAW,QAAS,QAAS,MAAM;AAAA,IAC7D;AAAA,EACD;AAEA,MAAK,QAAS;AACb,oBAAgB,cAAc;AAAA,MAC7B,CAAE,SACD,KAAK,wBACL,KAAK,qBAAqB,KACxB,YAAY,EACZ,SAAU,OAAO,YAAY,CAAE;AAAA,IACnC;AAAA,EACD;AAEA,SAAO;AACR;",
  "names": []
}
