{"version":3,"sources":["../../src/util/simpleSearch.ts"],"sourcesContent":["/**\n *  Finds all values matching the search values by first mapping the values to a string array and then checking each entry for matches.\n *  Returns the list of all matches.\n *\n *  @param search The list of search strings e.g. `[name, type]`\n *\n *  @param objects The list of objects to be searched in\n *\n *  @param mapping The mapping of objects to the string properties they fulfil\n *\n *  @return The list of objects that match all search strings\n */\nexport const MultiSubjectSearchWithMapping = <T>(search: string[], objects: T[], mapping: (value:T) => (string| undefined)[]) => {\n  return objects.filter(object => {\n    const mappedSearchKeywords = mapping(object).map(value => value ? value.toLowerCase().trim() : undefined)\n    return search.every(searchValue => !!mappedSearchKeywords.find(value => !!value && value.includes(searchValue.toLowerCase().trim())))\n  })\n}\n\n/**\n *  Finds all values matching the search value by first mapping the values to a string array and then checking each entry for matches.\n *  Returns the list of all matches.\n *\n *  @param search The search string e.g `name`\n *\n *  @param objects The list of objects to be searched in\n *\n *  @param mapping The mapping of objects to the string properties they fulfil\n *\n *  @return The list of objects that match the search string\n */\nexport const MultiSearchWithMapping = <T>(search: string, objects: T[], mapping: (value:T) => string[]) => {\n  return objects.filter(object => {\n    const mappedSearchKeywords = mapping(object).map(value => value.toLowerCase().trim())\n    return !!mappedSearchKeywords.find(value => value.includes(search.toLowerCase().trim()))\n  })\n}\n\n/**\n *  Finds all values matching the search value by first mapping the values to a string and returns the list of all matches.\n *\n *  @param search The search string e.g `name`\n *\n *  @param objects The list of objects to be searched in\n *\n *  @param mapping The mapping of objects to a string that is compared to the search\n *\n *  @return The list of objects that match the search string\n */\nexport const SimpleSearchWithMapping = <T>(search: string, objects: T[], mapping: (value:T) => string) => {\n  return MultiSearchWithMapping(search, objects, value => [mapping(value)])\n}\n\n/**\n *  Finds all values matching the search value and returns the list of all matches.\n *\n *  @param search The search string e.g `name`\n *\n *  @param objects The list of objects to be searched in\n *\n *  @return The list of objects that match the search string\n */\nexport const SimpleSearch = (search: string, objects: string[]) => {\n  return SimpleSearchWithMapping(search, objects, value => value)\n}\n"],"mappings":";AAYO,IAAM,gCAAgC,CAAI,QAAkB,SAAc,YAAgD;AAC/H,SAAO,QAAQ,OAAO,YAAU;AAC9B,UAAM,uBAAuB,QAAQ,MAAM,EAAE,IAAI,WAAS,QAAQ,MAAM,YAAY,EAAE,KAAK,IAAI,MAAS;AACxG,WAAO,OAAO,MAAM,iBAAe,CAAC,CAAC,qBAAqB,KAAK,WAAS,CAAC,CAAC,SAAS,MAAM,SAAS,YAAY,YAAY,EAAE,KAAK,CAAC,CAAC,CAAC;AAAA,EACtI,CAAC;AACH;AAcO,IAAM,yBAAyB,CAAI,QAAgB,SAAc,YAAmC;AACzG,SAAO,QAAQ,OAAO,YAAU;AAC9B,UAAM,uBAAuB,QAAQ,MAAM,EAAE,IAAI,WAAS,MAAM,YAAY,EAAE,KAAK,CAAC;AACpF,WAAO,CAAC,CAAC,qBAAqB,KAAK,WAAS,MAAM,SAAS,OAAO,YAAY,EAAE,KAAK,CAAC,CAAC;AAAA,EACzF,CAAC;AACH;AAaO,IAAM,0BAA0B,CAAI,QAAgB,SAAc,YAAiC;AACxG,SAAO,uBAAuB,QAAQ,SAAS,WAAS,CAAC,QAAQ,KAAK,CAAC,CAAC;AAC1E;AAWO,IAAM,eAAe,CAAC,QAAgB,YAAsB;AACjE,SAAO,wBAAwB,QAAQ,SAAS,WAAS,KAAK;AAChE;","names":[]}