export function isBrowser ( ) { return 'window' in globalThis && 'document' in globalThis ; } export function throwIfNotInBrowser ( ) { if ( ! isBrowser ( ) ) { throw new Error ( '<math-field> is an interactive component that needs to run in a browser environment\n' + 'If you are using nextjs, see https://nextjs.org/docs/advanced-features/dynamic-import#with-no-ssr' ) ; } } export function isTouchCapable ( ) { return ( ( isBrowser ( ) && window . matchMedia ?. ( '(any-pointer: coarse)' ) . matches ) ?? false ) ; } export function canVibrate ( ) { return isBrowser ( ) && typeof navigator . vibrate === 'function' ; } export function osPlatform ( ) { if ( ! isBrowser ( ) ) { return 'other' ; } const platform = navigator . platform ; if ( /^(mac)/i . test ( platform ) ) { if ( navigator . maxTouchPoints === 5 ) return 'ios' ; return 'macos' ; } if ( /^(win)/i . test ( platform ) ) return 'windows' ; if ( /(android)/i . test ( navigator . userAgent ) ) return 'android' ; if ( /(iphone|ipod|ipad)/i . test ( navigator . userAgent ) ) return 'ios' ; if ( /\bcros\b/i . test ( navigator . userAgent ) ) return 'chromeos' ; return 'other' ; } export function supportRegexPropertyEscape ( ) { if ( ! isBrowser ( ) ) return true ; if ( /firefox/i . test ( navigator . userAgent ) ) { const m = navigator . userAgent . match ( /firefox\/(\d+)/i ) ; if ( ! m ) return false ; const version = parseInt ( m [ 1 ] ) ; return version >= 78 ; } if ( /trident/i . test ( navigator . userAgent ) ) return false ; if ( /edge/i . test ( navigator . userAgent ) ) { const m = navigator . userAgent . match ( /edg\/(\d+)/i ) ; if ( ! m ) return false ; const version = parseInt ( m [ 1 ] ) ; return version >= 79 ; } return true ; } export function supportLocalFontEnumeration ( ) { return isBrowser ( ) && ! /firefox|safari/i . test ( navigator . userAgent ) ; }