{"version":3,"sources":["/home/mkabumattar/work/withrawi/rawi/dist/chunk-ZZSMN3CV.cjs","../src/cli/commands/ask/actions/content-filtering.ts"],"names":["setupContentFilter","filteringEnabled","filterTypes","options","ContentFilter","getAvailablePatternTypes","processFilterTypes","type","chalk","contentFilter","countA"],"mappings":"AAAA;AACA,wDAAwC,wDAAyC,4ECD/D,IAILA,CAAAA,CAAqB,CAChCC,CAAAA,CACAC,CAAAA,CACAC,CAAAA,CAAAA,EAEsB,IAAIC,wBAAAA,CACxB,CACE,OAAA,CAASH,CAAAA,CACT,KAAA,CAAOC,CAAAA,EAAeG,iCAAAA,CAAyB,CAC/C,YAAA,CAAcF,CAAAA,CAAQ,YAAA,EAAgB,CAAA,CAAA,CACtC,iBAAA,CAAmBA,CAAAA,CAAQ,iBAAA,EAAqB,CAAA,CAClD,CAAA,CACA,CAAA,CACF,CAAA,CAKWG,CAAAA,aAAqB,CAChCL,CAAAA,CACAE,CAAAA,CAAAA,EACyB,CACzB,IAAID,CAAAA,CAEJ,OAAID,CAAAA,EAAoBE,CAAAA,CAAQ,WAAA,CAAA,CAC9BD,CAAAA,CAAcC,CAAAA,CAAQ,WAAA,CACnB,KAAA,CAAM,GAAG,CAAA,CACT,GAAA,CAAKI,CAAAA,EAAiBA,CAAAA,CAAK,IAAA,CAAK,CAAC,CAAA,CAEhCJ,CAAAA,CAAQ,OAAA,EACV,OAAA,CAAQ,GAAA,CACNK,eAAAA,CAAM,GAAA,CACJ,CAAA,gDAAA,kBAA4CN,CAAAA,2BAAa,IAAA,mBAAK,IAAI,GAAA,EAAK,EAAE,CAAA,CAAA;AAyCjFO,gCAAAA;AAkDYC,kBAAAA;AAsBI,kDAAA;ADhJwY","file":"/home/mkabumattar/work/withrawi/rawi/dist/chunk-ZZSMN3CV.cjs","sourcesContent":[null,"import chalk from 'chalk';\nimport {ContentFilter} from '../../../../core/content-filter/content-filter.js';\nimport {getAvailablePatternTypes} from '../../../../core/content-filter/patterns.js';\n\nexport const setupContentFilter = (\n  filteringEnabled: boolean,\n  filterTypes: string[] | undefined,\n  options: any,\n): ContentFilter => {\n  const contentFilter = new ContentFilter(\n    {\n      enabled: filteringEnabled,\n      types: filterTypes || getAvailablePatternTypes(),\n      showFiltered: options.showFiltered || false,\n      highlightFiltered: options.highlightFiltered || false,\n    },\n    true,\n  );\n\n  return contentFilter;\n};\n\nexport const processFilterTypes = (\n  filteringEnabled: boolean,\n  options: any,\n): string[] | undefined => {\n  let filterTypes: string[] | undefined;\n\n  if (filteringEnabled && options.filterTypes) {\n    filterTypes = options.filterTypes\n      .split(',')\n      .map((type: string) => type.trim());\n\n    if (options.verbose) {\n      console.log(\n        chalk.dim(\n          `🔒 Content filtering enabled with types: ${filterTypes?.join(', ') || ''}`,\n        ),\n      );\n    }\n  } else if (filteringEnabled) {\n    filterTypes = getAvailablePatternTypes();\n\n    if (options.verbose) {\n      console.log(\n        chalk.dim('🔒 Content filtering enabled with all available types'),\n      );\n    }\n  }\n\n  return filterTypes;\n};\n\nexport const filterAndDisplayQuery = (\n  contentFilter: ContentFilter,\n  query: string,\n  filteringEnabled: boolean,\n  options: any,\n): string => {\n  if (!filteringEnabled) {\n    return query;\n  }\n\n  const filterResult = contentFilter.filterContent(query);\n  const filteredQuery = filterResult.filteredText;\n\n  if (options.verbose) {\n    console.log(chalk.yellow('\\n🔍 Query after filtering:'));\n    console.log(chalk.yellow('─────────────────────────'));\n    console.log(filteredQuery);\n    console.log(chalk.yellow('─────────────────────────'));\n  }\n\n  return filteredQuery;\n};\n\nexport const displayFilterStatistics = (\n  contentFilter: ContentFilter,\n  query: string,\n  filteringEnabled: boolean,\n  options: any,\n): void => {\n  if (\n    !filteringEnabled ||\n    (!options.verbose && !options.showFiltered && !options.highlightFiltered)\n  ) {\n    return;\n  }\n\n  const filterResult = contentFilter.filterContent(query);\n\n  if (Object.keys(filterResult.filterCount).length > 0) {\n    if (options.verbose) {\n      console.log(chalk.yellow('📊 Prompt Filtering Summary:'));\n      console.log(chalk.yellow('─────────────────────────'));\n\n      const totalFiltered = Object.values(filterResult.filterCount).reduce(\n        (sum: number, count: number) => sum + count,\n        0,\n      );\n      console.log(chalk.yellow(`Total filtered items: ${totalFiltered}`));\n\n      console.log(chalk.yellow('\\nBreakdown by type:'));\n      for (const [type, count] of Object.entries(filterResult.filterCount)) {\n        const percentage = Math.round(\n          ((count as number) / totalFiltered) * 100,\n        );\n        const bar = '█'.repeat(Math.min(20, Math.floor(percentage / 5)));\n        console.log(\n          chalk.yellow(\n            `  ${type.padEnd(15)}: ${(count as number).toString().padStart(3)} (${percentage}%) ${bar}`,\n          ),\n        );\n      }\n    } else {\n      const totalFiltered = Object.values(filterResult.filterCount).reduce(\n        (sum: number, count: number) => sum + count,\n        0,\n      );\n      console.log(\n        chalk.yellow(\n          `📊 Filtered ${totalFiltered} sensitive items from prompt`,\n        ),\n      );\n\n      const sortedTypes = Object.entries(filterResult.filterCount)\n        .sort(\n          ([, countA], [, countB]) => (countB as number) - (countA as number),\n        )\n        .slice(0, 3);\n\n      if (sortedTypes.length > 0) {\n        const typesList = sortedTypes\n          .map(([type, count]) => `${type} (${count})`)\n          .join(', ');\n        console.log(chalk.yellow(`   Most common: ${typesList}`));\n      }\n\n      console.log(\n        chalk.dim('   Use --verbose for detailed filtering statistics'),\n      );\n    }\n\n    if (options.highlightFiltered && filterResult.highlightedText) {\n      console.log(\n        chalk.yellow('\\n🔍 Highlighted sensitive content in prompt:'),\n      );\n      console.log('─────────────────────────────────────────');\n      console.log(filterResult.highlightedText);\n      console.log('─────────────────────────────────────────');\n    }\n  }\n};\n\nexport const saveFilterConfig = (\n  contentFilter: ContentFilter,\n  options: any,\n): void => {\n  const success = contentFilter.saveConfiguration();\n\n  if (success) {\n    console.log(chalk.green('✅ Filter configuration saved successfully'));\n    if (options.verbose) {\n      const config = contentFilter.getOptions();\n      console.log(chalk.dim('Enabled:'), config.enabled);\n      console.log(chalk.dim('Filter types:'), config.types.join(', '));\n      console.log(chalk.dim('Show filtered:'), config.showFiltered);\n    }\n  } else {\n    console.error(chalk.red('❌ Failed to save filter configuration'));\n  }\n};\n\nexport const resetFilterConfig = (options: any): ContentFilter => {\n  const contentFilter = new ContentFilter({}, true);\n  const success = contentFilter.resetConfiguration();\n\n  if (success) {\n    console.log(chalk.green('✅ Filter configuration reset to defaults'));\n    if (options.verbose) {\n      console.log(\n        chalk.dim('Default filter types:'),\n        contentFilter.getAvailableFilterTypes().join(', '),\n      );\n    }\n  } else {\n    console.error(chalk.red('❌ Failed to reset filter configuration'));\n  }\n\n  return contentFilter;\n};\n"]}