{"version":3,"file":"fuzzyMatchColumns-C1STZ_T1.mjs","names":[],"sources":["../src/lib/requests/fuzzyMatchColumns.ts"],"sourcesContent":["import fuzzysearch from 'fuzzysearch';\nimport inquirer from 'inquirer';\n\nimport { NONE, BULK_APPLY } from './constants.js';\n\n/**\n * Check if word1 and word2 are a fuzzy match of each other.\n * Returns true if word1 is fuzzy match of word2 or vice versa.\n *\n * @param word1 - First word\n * @param word2 - Second word\n * @returns True if words are fuzzy match\n */\nexport function fuzzySearch(word1: string, word2: string): boolean {\n  return (\n    fuzzysearch(word1.toLowerCase(), word2.toLowerCase()) ||\n    fuzzysearch(word2.toLowerCase(), word1.toLowerCase())\n  );\n}\n\n/**\n * Fuzzy match column names for a particular field\n *\n * @param allColumnNames - List of all column names\n * @param fuzzyMapName - The name of field being mapped to\n * @param isRequired - When true, don't include \"NONE\" as an option\n * @param canApplyAll - When true, include an option to specify the value in bulk\n * @returns The list of suggestions for inquirer\n */\nexport function fuzzyMatchColumns(\n  allColumnNames: string[],\n  fuzzyMapName: string,\n  isRequired: boolean,\n  canApplyAll?: boolean,\n): (string | InstanceType<typeof inquirer.Separator>)[] {\n  const matchingColumnNames = allColumnNames.filter((x) =>\n    fuzzySearch(fuzzyMapName.toLowerCase(), x.toLowerCase()),\n  );\n  return [\n    ...matchingColumnNames,\n    new inquirer.Separator(),\n    ...(isRequired ? [] : [NONE]),\n    ...(canApplyAll ? [BULK_APPLY] : []),\n    ...allColumnNames.filter((x) => !matchingColumnNames.includes(x)),\n  ];\n}\n"],"mappings":"uGAaA,SAAgB,EAAY,EAAe,EAAwB,CACjE,OACE,EAAY,EAAM,aAAa,CAAE,EAAM,aAAa,CAAC,EACrD,EAAY,EAAM,aAAa,CAAE,EAAM,aAAa,CAAC,CAazD,SAAgB,EACd,EACA,EACA,EACA,EACsD,CACtD,IAAM,EAAsB,EAAe,OAAQ,GACjD,EAAY,EAAa,aAAa,CAAE,EAAE,aAAa,CAAC,CACzD,CACD,MAAO,CACL,GAAG,EACH,IAAI,EAAS,UACb,GAAI,EAAa,EAAE,CAAG,CAAC,EAAK,CAC5B,GAAI,EAAc,CAAC,EAAW,CAAG,EAAE,CACnC,GAAG,EAAe,OAAQ,GAAM,CAAC,EAAoB,SAAS,EAAE,CAAC,CAClE"}