{ "version": 3, "sources": ["../../../src/lib/utils/text.ts"], "sourcesContent": ["import { INDENT } from '../shapes/shared/TextHelpers'\n\nconst rtlRegex = /[\\u0590-\\u05FF\\u0600-\\u06FF\\u0750-\\u077F\\u08A0-\\u08FF\\uFB50-\\uFDFF\\uFE70-\\uFEFF]/\nexport function isRightToLeftLanguage(text: string) {\n\treturn rtlRegex.test(text)\n}\n\n/**\n * Replace any tabs with double spaces.\n * @param text - The text to replace tabs in.\n * @internal\n */\nfunction replaceTabsWithSpaces(text: string) {\n\treturn text.replace(/\\t/g, INDENT)\n}\n\n/**\n * Strip common minimum indentation from each line.\n * @param text - The text to strip.\n * @internal\n */\nfunction stripCommonMinimumIndentation(text: string): string {\n\t// Split the text into individual lines\n\tconst lines = text.split('\\n')\n\n\t// remove any leading lines that are only whitespace or newlines\n\twhile (lines[0].trim().length === 0) {\n\t\tlines.shift()\n\t}\n\n\tlet minIndentation = Infinity\n\tfor (const line of lines) {\n\t\tif (line.trim().length > 0) {\n\t\t\tconst indentation = line.length - line.trimStart().length\n\t\t\tminIndentation = Math.min(minIndentation, indentation)\n\t\t}\n\t}\n\n\treturn lines.map((line) => line.slice(minIndentation)).join('\\n')\n}\n\n/**\n * Strip trailing whitespace from each line and remove any trailing newlines.\n * @param text - The text to strip.\n * @internal\n */\nfunction stripTrailingWhitespace(text: string): string {\n\treturn text.replace(/[ \\t]+$/gm, '').replace(/\\n+$/, '')\n}\n\n/** @internal */\nexport function cleanupText(text: string) {\n\treturn stripTrailingWhitespace(stripCommonMinimumIndentation(replaceTabsWithSpaces(text)))\n}\n\n/** @public */\nexport const truncateStringWithEllipsis = (str: string, maxLength: number) => {\n\treturn str.length <= maxLength ? str : str.substring(0, maxLength - 3) + '...'\n}\n"], "mappings": "AAAA,SAAS,cAAc;AAEvB,MAAM,WAAW;AACV,SAAS,sBAAsB,MAAc;AACnD,SAAO,SAAS,KAAK,IAAI;AAC1B;AAOA,SAAS,sBAAsB,MAAc;AAC5C,SAAO,KAAK,QAAQ,OAAO,MAAM;AAClC;AAOA,SAAS,8BAA8B,MAAsB;AAE5D,QAAM,QAAQ,KAAK,MAAM,IAAI;AAG7B,SAAO,MAAM,CAAC,EAAE,KAAK,EAAE,WAAW,GAAG;AACpC,UAAM,MAAM;AAAA,EACb;AAEA,MAAI,iBAAiB;AACrB,aAAW,QAAQ,OAAO;AACzB,QAAI,KAAK,KAAK,EAAE,SAAS,GAAG;AAC3B,YAAM,cAAc,KAAK,SAAS,KAAK,UAAU,EAAE;AACnD,uBAAiB,KAAK,IAAI,gBAAgB,WAAW;AAAA,IACtD;AAAA,EACD;AAEA,SAAO,MAAM,IAAI,CAAC,SAAS,KAAK,MAAM,cAAc,CAAC,EAAE,KAAK,IAAI;AACjE;AAOA,SAAS,wBAAwB,MAAsB;AACtD,SAAO,KAAK,QAAQ,aAAa,EAAE,EAAE,QAAQ,QAAQ,EAAE;AACxD;AAGO,SAAS,YAAY,MAAc;AACzC,SAAO,wBAAwB,8BAA8B,sBAAsB,IAAI,CAAC,CAAC;AAC1F;AAGO,MAAM,6BAA6B,CAAC,KAAa,cAAsB;AAC7E,SAAO,IAAI,UAAU,YAAY,MAAM,IAAI,UAAU,GAAG,YAAY,CAAC,IAAI;AAC1E;", "names": [] }