{"version":3,"sources":["../../../src/vanilla/single-fuzzy.ts"],"sourcesContent":["import { getFuzzyMatchScore } from \"./getScore/getScore\";\nimport normalizeText from \"./normalizeText\";\nimport type { Result } from \"./types\";\n\n/**\n * Finds a fuzzy match between a given text and a query string.\n *\n * Runs a one-off fuzzy search matching on `text` against `queryText`.\n *\n * Use `fuzzyMatch` whenever you have a single item to search.\n *\n * This function normalizes both the input text and query, splits them into words,\n * and calculates a fuzzy match score. If a match is found, it returns the result\n * containing the original text, the match score, and the matched segments.\n *\n * @param text - The input text to search for a fuzzy match.\n * @param query - The query string to match against the input text.\n * @returns A `Result<string>` object containing the match details if a match is found,\n *          or `null` if no match is found.\n */\nexport function singleFuzzy(text: string, query: string): Result<string> | null {\n\t\tconst normalizedQuery = normalizeText(query);\n\t\tconst queryWords = normalizedQuery.split(\" \");\n\n\t\tconst normalizedText = normalizeText(text);\n\t\tconst itemWords = new Set(normalizedText.split(\" \"));\n\n\t\tconst result = getFuzzyMatchScore(\n\t\t\ttext,\n\t\t\tnormalizedText,\n\t\t\titemWords,\n\t\t\tquery,\n\t\t\tnormalizedQuery,\n\t\t\tqueryWords,\n\t\t);\n\t\tif (result) {\n\t\t\treturn { item: text, score: result[0], matches: [result[1]] };\n\t\t}\n\t\treturn null;\n\t}\n"],"mappings":";AAAA,SAAS,0BAA0B;AACnC,OAAO,mBAAmB;AAmBnB,SAAS,YAAY,MAAc,OAAsC;AAC9E,QAAM,kBAAkB,cAAc,KAAK;AAC3C,QAAM,aAAa,gBAAgB,MAAM,GAAG;AAE5C,QAAM,iBAAiB,cAAc,IAAI;AACzC,QAAM,YAAY,IAAI,IAAI,eAAe,MAAM,GAAG,CAAC;AAEnD,QAAM,SAAS;AAAA,IACd;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACA,MAAI,QAAQ;AACX,WAAO,EAAE,MAAM,MAAM,OAAO,OAAO,CAAC,GAAG,SAAS,CAAC,OAAO,CAAC,CAAC,EAAE;AAAA,EAC7D;AACA,SAAO;AACR;","names":[]}