import { IItem, IUser } from '../../types'; type MatchUsingMultiplePatternsParams = { /** * The item to be checked for searchability. */ item: IItem; /** * The predefined patterns to match against the item's title and snippet. */ predefinedPatterns: RegExp; /** * Additional patterns to match against the item's title and snippet if no match is found with predefined patterns. * These extra matching patterns are the patterns submitted by the user that have been approved by the Living Atlas team. */ extraPatterns: RegExp; /** * Custom terms to match against the item's title and snippet if no match is found with predefined or extra patterns. * These custom terms are the terms users submitted using the Nominatim App */ customTerms: string[]; /** * A set of terms that have been rejected by the Living Atlas team. * any custom term that is found in this set will be ignored. */ rejectedSet: Set; }; /** * Represents the source of a match pattern. * */ export type MatchPatternSource = 'predefined' | 'additional' | 'custom'; /** * Represents the result of a pattern match operation. */ export type MatchResult = { /** * The string that was matched by the pattern. */ matchedString: string; /** * The source of the pattern that was used for matching: `'predefined' | 'additional' | 'custom'` */ patternSource: MatchPatternSource; }; /** * Checks if a string is found in a set of strings. * @param str string to be checked * @param set set of strings to be checked against * @returns true if the string is found in the set, false otherwise */ export declare const isFoundInSet: (str: string, set: Set) => boolean; /** * Matches patterns in an item's title and snippet using a hierarchical approach: * predefined patterns first, followed by extra patterns, and finally custom terms. * * @param {MatchUsingMultiplePatternsParams} params - The parameters for pattern matching. * @param {IItem} params.item - The item containing the title and snippet to search for patterns. * @param {RegExp} params.predefinedPatterns - The predefined patterns to match against the item's title and snippet. * @param {RegExp} params.extraPatterns - Additional patterns to match against the item's title and snippet if no match is found with predefined patterns. These extra matching patterns are the patterns submitted by users and approved by the Living Atlas team. * @param {string[]} params.customTerms - Custom terms to match against the item's title and snippet if no match is found with predefined or extra patterns. These custom terms are user-submitted via the Nominatim App. * @param {Set} params.rejectedSet - A set of terms rejected by the Living Atlas team. Any custom term found in this set will be ignored. * * @returns {string[]} - An array of matched strings after deduplication and filtering. */ export declare const matchUsingMultiplePatterns: ({ item, predefinedPatterns, extraPatterns, customTerms, rejectedSet, }: MatchUsingMultiplePatternsParams) => MatchResult[]; /** * Matches patterns in the title and snippet of an item. * @param item ArcGIS item object to be matched. * @param regex Regular expression to match. * @returns Array of matched strings. */ export declare const matchPatternsInTitleAndSnippet: (item: IItem, regex: RegExp, patternSource: MatchPatternSource) => MatchResult[]; /** * Matches custom patterns in the title and snippet of an item. * @param item ArcGIS item object to be matched. * @param customMatchingPatterns Array of custom patterns to match. * @param rejectedSet Set of rejected patterns. * * @returns Array of matched strings. */ export declare const matchWithCustomPatterns: (item: IItem, customMatchingPatterns: string[], rejectedSet: Set) => MatchResult[]; /** * Get a Set from an array of strings and convert all strings to lowercase. * @param arr - The array of strings to convert to a Set * @returns set - A Set containing the strings from the array */ export declare const toLowercaseSet: (arr: string[]) => Set; /** * Determines if an item is eligible for checking title and snippet searchability. * * @param item {IITem} - The item to check. * @returns {boolean} if the item meets the criteria for checking title and snippet searchability, otherwise `false`. * * The criteria for eligibility are: * 1. The item is a layer. * 2. The item is English-based. * 3. The item's culture is 'en' or the item's owner is one of the English-based owners. * * @remarks * - The locale is determined by both the item's culture and the item's owner. */ export declare const isEligibleForCheckingTitleAndSnippetSearchability: (item: IItem, itemOwner: IUser) => boolean; /** * Clean up matched results by removing empty and duplicate strings. * @param matchedResults array of matched results * @returns an array of cleaned up matched MatchResult */ export declare const cleanUpMatchedResults: (matchedResults: MatchResult[]) => MatchResult[]; export declare const removeOverlapped: (arr: MatchResult[]) => MatchResult[]; /** * Removes duplicate matched results from an array, ignoring case sensitivity. * * @param arr - The array of MatchResult to deduplicate. * @returns A new array with duplicates removed, preserving the original case of the first occurrence. */ export declare const deduplicate: (arr: MatchResult[]) => MatchResult[]; export {};