保誠-保戶業務員媒合平台
HelenHuang
2022-06-09 9bdb95c9e34cef640534e5e5a1e2225a80442000
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
var initPrefersColorScheme = (function () {
    'use strict';
 
    var colorIndexRegExp = /((?:not )?all and )?(\(color-index: *(22|48|70)\))/i;
    var prefersColorSchemeRegExp = /prefers-color-scheme:/i;
 
    var prefersColorSchemeInit = function prefersColorSchemeInit(initialColorScheme) {
      var mediaQueryString = '(prefers-color-scheme: dark)';
      var mediaQueryList = window.matchMedia && matchMedia(mediaQueryString);
      var hasNativeSupport = mediaQueryList && mediaQueryList.media === mediaQueryString;
 
      var mediaQueryListener = function mediaQueryListener() {
        set(mediaQueryList.matches ? 'dark' : 'light');
      };
 
      var removeListener = function removeListener() {
        if (mediaQueryList) {
          mediaQueryList.removeListener(mediaQueryListener);
        }
      };
 
      var set = function set(colorScheme) {
        if (colorScheme !== currentColorScheme) {
          currentColorScheme = colorScheme;
 
          if (typeof result.onChange === 'function') {
            result.onChange();
          }
        }
 
        [].forEach.call(document.styleSheets || [], function (styleSheet) {
          [].forEach.call(styleSheet.cssRules || [], function (cssRule) {
            var colorSchemeMatch = prefersColorSchemeRegExp.test(Object(cssRule.media).mediaText);
 
            if (colorSchemeMatch) {
              var index = [].indexOf.call(cssRule.parentStyleSheet.cssRules, cssRule);
              cssRule.parentStyleSheet.deleteRule(index);
            } else {
              var colorIndexMatch = (Object(cssRule.media).mediaText || '').match(colorIndexRegExp);
 
              if (colorIndexMatch) {
                cssRule.media.mediaText = ((/^dark$/i.test(colorScheme) ? colorIndexMatch[3] === '48' : /^light$/i.test(colorScheme) ? colorIndexMatch[3] === '70' : colorIndexMatch[3] === '22') ? 'not all and ' : '') + cssRule.media.mediaText.replace(colorIndexRegExp, '$2');
              }
            }
          });
        });
      };
 
      var result = Object.defineProperty({
        hasNativeSupport: hasNativeSupport,
        removeListener: removeListener
      }, 'scheme', {
        get: function get() {
          return currentColorScheme;
        },
        set: set
      }); // initialize the color scheme using the provided value, the system value, or light
 
      var currentColorScheme = initialColorScheme || (mediaQueryList && mediaQueryList.matches ? 'dark' : 'light');
      set(currentColorScheme); // listen for system changes
 
      if (mediaQueryList) {
        mediaQueryList.addListener(mediaQueryListener);
      }
 
      return result;
    };
 
    return prefersColorSchemeInit;
 
}());
//# sourceMappingURL=browser.js.map