import { window } from './facade/browser'; import { currentBsVersion } from './theme-provider'; export class Utils { // eslint-disable-next-line @typescript-eslint/no-explicit-any static reflow(element: any): void { // eslint-disable-next-line @typescript-eslint/no-explicit-any ((bs: any): void => bs)(element.offsetHeight); } // source: https://github.com/jquery/jquery/blob/master/src/css/var/getStyles.js // eslint-disable-next-line @typescript-eslint/no-explicit-any static getStyles(elem: any): any { // Support: IE <=11 only, Firefox <=30 (#15098, #14150) // IE throws on elements created in popups // FF meanwhile throws on frame elements through "defaultView.getComputedStyle" let view = elem.ownerDocument.defaultView; if (!view || !view.opener) { view = window; } return view.getComputedStyle(elem); } static stackOverflowConfig(): { crossorigin?: string, integrity?: string, cdnLink: string } { const bsVer = currentBsVersion(); return { crossorigin: bsVer !== 'bs3' ? "anonymous" : undefined, integrity: bsVer === 'bs5' ? 'sha384-KyZXEAg3QhqLMpG8r+8fhAXLRk2vvoC2f3B09zVXn8CA5QIVfZOJ3BCsw2P0p/We' : bsVer === 'bs4' ? 'sha384-TX8t27EcRE3e/ihU7zmQxVncDAy5uIKz4rEkgIXeMed4M0jlfIDPvg6uqKI2xXr2' : undefined, cdnLink: bsVer === 'bs5' ? 'https://cdn.jsdelivr.net/npm/bootstrap@5.1.0/dist/css/bootstrap.min.css' : bsVer === 'bs4' ? 'https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/css/bootstrap.min.css' : 'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css', }; } }