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AAI,MAAM,CAAC,CAAC,CAAC;gBACvB,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;YAC5B,CAAC;SACF;QACD,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;IAC3B,CAAC;IA1Da,uBAAQ,GAAO,QAAQ,CAAC;IA2DxC,qBAAC;AAAD,CAAC,AA5DD,IA4DC","sourcesContent":["import { latinMap } from './latin-map';\n\nexport class TypeaheadUtils {\n public static latinMap:any = latinMap;\n\n public static latinize(str:string):string {\n if (!str) {\n return '';\n }\n return str.replace(/[^A-Za-z0-9\\[\\] ]/g, function (a:string):string {\n return TypeaheadUtils.latinMap[a] || a;\n });\n }\n\n public static escapeRegexp(queryToEscape:string):string {\n // Regex: capture the whole query string and replace it with the string\n // that will be used to match the results, for example if the capture is\n // 'a' the result will be \\a\n return queryToEscape.replace(/([.?*+^$[\\]\\\\(){}|-])/g, '\\\\$1');\n }\n\n /* tslint:disable */\n public static tokenize(str:string, wordRegexDelimiters = ' ', phraseRegexDelimiters = ''):Array<string> {\n /* tslint:enable */\n let regexStr:string = '(?:[' + phraseRegexDelimiters + '])([^' + phraseRegexDelimiters + ']+)(?:[' + phraseRegexDelimiters + '])|([^' + wordRegexDelimiters + ']+)';\n let preTokenized:string[] = str.split(new RegExp(regexStr, 'g'));\n let result:string[] = [];\n let preTokenizedLength:number = preTokenized.length;\n let token:string;\n let replacePhraseDelimiters = new RegExp('[' + phraseRegexDelimiters + ']+', 'g');\n\n for (let i = 0; i < preTokenizedLength; i += 1) {\n token = preTokenized[i];\n if (token && token.length && token !== wordRegexDelimiters) {\n result.push(token.replace(replacePhraseDelimiters, ''));\n }\n }\n\n return result;\n }\n\n public static getValueFromObject(object:any, option:string):string {\n if (!option || typeof object !== 'object') {\n return object.toString();\n }\n\n if (option.endsWith('()')) {\n let functionName = option.slice(0, option.length - 2);\n return object[functionName]().toString();\n }\n\n let properties:string = option.replace(/\\[(\\w+)\\]/g, '.$1')\n .replace(/^\\./, '');\n let propertiesArray:string[] = properties.split('.');\n\n for (let property of propertiesArray) {\n if (property in object) {\n object = object[property];\n }\n }\n return object.toString();\n }\n}\n\ninterface DecoratorInvocation {\n type: Function;\n args?: any[];\n}\n"]}
\No newline at end of file