{"version":3,"file":"bravura-ui-common.mjs","sources":["../../../projects/ui/common/common-utils.ts","../../../projects/ui/common/common.module.ts","../../../projects/ui/common/bravura-ui-common.ts"],"sourcesContent":["export function generateID() {\r\n\treturn Math.round(Math.random() * Math.pow(2, 50)).toString(36);\r\n}\r\n\r\nexport function isElementInViewport(el: HTMLElement) {\r\n\tconst rect = el.getBoundingClientRect();\r\n\r\n\treturn (\r\n\t\trect.top >= 0 &&\r\n\t\trect.left >= 0 &&\r\n\t\trect.bottom <= (window.innerHeight || document.documentElement.clientHeight) &&\r\n\t\trect.right <= (window.innerWidth || document.documentElement.clientWidth)\r\n\t);\r\n}\r\n\r\n/**\r\n * Uses canvas.measureText to compute and return the width of the given text of given font in pixels.\r\n *\r\n * @param {String} text The text to be rendered.\r\n * @param el the element used to compute the font styles\r\n *\r\n * @see https://stackoverflow.com/questions/118241/calculate-text-width-with-javascript/21015393#21015393\r\n */\r\nexport function getTextWidth(text: string, el: HTMLElement = document.body): number {\r\n\tfunction getCssStyle(element: HTMLElement, prop: string) {\r\n\t\treturn window.getComputedStyle(element, null).getPropertyValue(prop);\r\n\t}\r\n\r\n\tconst fontWeight = getCssStyle(el, 'font-weight') || 'normal';\r\n\tconst fontSize = getCssStyle(el, 'font-size') || '16px';\r\n\tconst fontFamily = getCssStyle(el, 'font-family') || 'Arial';\r\n\r\n\tconst font = `${fontWeight} ${fontSize} ${fontFamily}`;\r\n\r\n\t// re-use canvas object for better performance\r\n\tconst canvas = (getTextWidth as any).canvas || ((getTextWidth as any).canvas = document.createElement('canvas'));\r\n\tconst context = canvas.getContext('2d');\r\n\tcontext.font = font;\r\n\tconst metrics = context.measureText(text);\r\n\treturn Math.round(metrics.width);\r\n}\r\n","import { BidiModule, Direction, Directionality } from '@angular/cdk/bidi';\n\nimport { Inject, NgModule, Optional, SkipSelf, DOCUMENT } from '@angular/core';\n\n/** Regex that matches locales with an RTL script. Taken from `goog.i18n.bidi.isRtlLanguage`. */\nconst RTL_LOCALE_PATTERN =\n\t/^(ar|ckb|dv|he|iw|fa|nqo|ps|sd|ug|ur|yi|.*[-_](Adlm|Arab|Hebr|Nkoo|Rohg|Thaa))(?!.*[-_](Latn|Cyrl)($|-|_))($|-|_)/i;\n\n/** Resolves a string value to a specific direction. */\nexport function _resolveDirectionality(rawValue: string): Direction {\n\tconst value = rawValue?.toLowerCase() || '';\n\n\tif (value === 'auto' && typeof navigator !== 'undefined' && navigator?.language) {\n\t\treturn RTL_LOCALE_PATTERN.test(navigator.language) ? 'rtl' : 'ltr';\n\t}\n\n\treturn value === 'rtl' ? 'rtl' : 'ltr';\n}\n\n@NgModule({\n\tdeclarations: [],\n\timports: [BidiModule],\n\texports: [BidiModule]\n})\nexport class BuiCommonModule {\n\tconstructor(\n\t\tdir: Directionality,\n\t\t@Optional()\n\t\t@SkipSelf()\n\t\tthisModule: BuiCommonModule,\n\t\t@Inject(DOCUMENT) document: Document\n\t) {\n\t\tif (!thisModule) {\n\t\t\tconst observer = new MutationObserver(() => {\n\t\t\t\tconst attr = document.documentElement.getAttribute('dir') || document.body.getAttribute('dir');\n\t\t\t\tif (attr && dir.value !== attr) {\n\t\t\t\t\tconst d = _resolveDirectionality(attr);\n\t\t\t\t\tdir.change.emit(d);\n\t\t\t\t\tif (Object.getOwnPropertyNames(dir).includes('value')) {\n\t\t\t\t\t\t(dir as any).value = d;\n\t\t\t\t\t}\n\t\t\t\t\tsetTimeout(() => dir.change.emit(d));\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tobserver.observe(document.documentElement, { attributes: true });\n\t\t\tobserver.observe(document.body, { attributes: true });\n\t\t}\n\t}\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;SAAgB,UAAU,GAAA;IACzB,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,EA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