1(() => { 2 const AppTheme = { 3 Light: 'light', 4 Dark: 'dark', 5 System: 'system', 6 }; 7 const InternalClassName = { 8 BrandLogoImg: '_brand-logo-img_24bb', 9 BrandLogoTitle: '_brand-logo-title_14f7', 10 BackgroundHelper: '_background-helper_ab05', 11 BackgroundImage: '_background-image_40ed', 12 BackgroundSvg: '_background-svg_b4ca', 13 BackgroundSvgLight: '_background-svg-light_42b8', 14 BackgroundSvgDark: '_background-svg-dark_6671', 15 }; 16 const BackgroundImageType = { 17 Default: 'default', 18 Custom: 'custom', 19 FollowLight: 'followLight', 20 }; 21 const getLogoRadius = (radius = 'm') => { 22 return { none: '0px', s: '4px', m: '8px', l: '9999px' }[radius]; 23 }; 24 const PositionMap = { 25 topLeft: { x: 'left', y: 'top' }, 26 topCenter: { x: 'center', y: 'top' }, 27 topRight: { x: 'right', y: 'top' }, 28 left: { x: 'left', y: 'center' }, 29 center: { x: 'center', y: 'center' }, 30 right: { x: 'right', y: 'center' }, 31 bottomLeft: { x: 'left', y: 'bottom' }, 32 bottomCenter: { x: 'center', y: 'bottom' }, 33 bottomRight: { x: 'right', y: 'bottom' }, 34 }; 35 36 function __setDocsTheme( 37 themePrimarySettings, 38 logoSettings, 39 backgroundImageSettings, 40 currentTheme, 41 ) { 42 const html = document.documentElement; 43 44 html.setAttribute('data-theme', currentTheme); 45 const isOldSafari = (() => { 46 if (/Safari/i.test(navigator.userAgent) && navigator.userAgent.includes('Version/')) {
47 const version = navigator.userAgent.split('Version/')?.[1]?.split(' ')?.[0] ?? ''; 48 const [major, minor] = version.split('.'); 49 if (major && minor) { 50 const majorNumber = parseInt(major, 10); 51 const minorNumber = parseInt(minor, 10); 52 if (majorNumber > 18 || (majorNumber === 18 && minorNumber >= 4)) { 53 return false; 54 } 55 } 56 return true; 57 } 58 return false; 59 })(); 60 if (isOldSafari) { 61 html.classList.add('old-safari'); 62 } 63 64 const { accentColor } = themePrimarySettings[currentTheme] ?? {}; 65 html.setAttribute('data-accent-color', accentColor || 'purple'); 66 67 window.__updateThemeElement = () => { 68 const logo = logoSettings[currentTheme].icon; 69 const radius = getLogoRadius(logoSettings[currentTheme].radius); 70 const title = logoSettings[currentTheme].title; 71 const background = backgroundImageSettings[currentTheme]; 72 const finalBackground = 73 background.type === BackgroundImageType.FollowLight 74 ? backgroundImageSettings.light 75 : background; 76 const finalTheme = 77 background.type === BackgroundImageType.FollowLight ? AppTheme.Light : currentTheme; 78 if (logo) { 79 const brandLogos = [...document.getElementsByClassName(InternalClassName.BrandLogoImg)]; 80 brandLogos.forEach((brandLogo) => { 81 if ((brandLogo && brandLogo?.src !== logo) || brandLogo?.style.borderRadius !== radius) { 82 brandLogo.src = logo; 83 brandLogo.style.borderRadius = getLogoRadius(logoSettings[currentTheme].radius); 84 } 85 }); 86 } 87 const brandTitles = [...document.getElementsByClassName(InternalClassName.BrandLogoTitle)];
88 brandTitles.forEach((brandTitle) => { 89 brandTitle.textContent = title; 90 }); 91 const backgroundHelper = document.getElementsByClassName(InternalClassName.BackgroundHelper); 92 if (backgroundHelper.length > 0) { 93 const isCustomCssBgUrl = getComputedStyle(backgroundHelper[0]).backgroundImage !== 'none'; 94 const showSvgBg = 95 !isCustomCssBgUrl && 96 finalBackground.type === BackgroundImageType.Default && 97 finalBackground.backgroundImage !== 'default'; 98 const backgroundImage = document.getElementsByClassName(InternalClassName.BackgroundImage); 99 const backgroundSvg = document.getElementsByClassName(InternalClassName.BackgroundSvg); 100 if (backgroundImage.length > 0) { 101 backgroundImage[0].style.display = showSvgBg ? 'none' : 'block'; 102 const isCustom = finalBackground.type === BackgroundImageType.Custom && !isCustomCssBgUrl; 103 backgroundImage[0].style.opacity = isCustom ? (finalBackground?.opacity ?? 100) / 100 : 1; 104 backgroundImage[0].style.position = isCustom 105 ? finalBackground?.fixed === 'fixed' 106 ? 'fixed' 107 : 'absolute' 108 : ''; 109 backgroundImage[0].style.setProperty( 110 '--custom-background-size', 111 isCustom 112 ? finalBackground?.size === 'stretch' 113 ? '100% 100%' 114 : finalBackground?.size === 'tile' 115 ? `${finalBackground?.imageWidth}px ${finalBackground?.imageHeight}px` 116 : finalBackground?.size || '100% auto' 117 : '', 118 ); 119 backgroundImage[0].style.setProperty( 120 '--custom-background-repeat', 121 isCustom ? (finalBackground?.size === 'tile' ? 'repeat' : 'no-repeat') : '', 122 ); 123 backgroundImage[0].style.setProperty( 124 '--custom-background-position', 125 isCustom 126 ? `${PositionMap[finalBackground?.position ?? 'topLeft']?.x} ${PositionMap[finalBackground?.position ?? 'topLeft']?.y}` 127 : '', 128 ); 129 } 130 if (backgroundSvg.length > 0) { 131 backgroundSvg[0].style.display = showSvgBg ? 'block' : 'none'; 132 } 133 } 134 const backgroundSvgLight = document.getElementsByClassName( 135 InternalClassName.BackgroundSvgLight, 136 ); 137 const backgroundSvgDark = document.getElementsByClassName( 138 InternalClassName.BackgroundSvgDark, 139 ); 140 if (backgroundSvgLight.length > 0) { 141 backgroundSvgLight[0].style.display = finalTheme === AppTheme.Light ? 'block' : 'none'; 142 } 143 if (backgroundSvgDark.length > 0) { 144 backgroundSvgDark[0].style.display = finalTheme === AppTheme.Dark ? 'block' : 'none'; 145 } 146 }; 147 window.__updateThemeElement(); 148 149 window.__currentTheme = currentTheme; 150 } 151 window.__setDocsTheme = __setDocsTheme; 152 153 let isAddEventListener = false;
154 let isResetDocsTheme = false; 155 function __prepareDocsConfigScript(config = {}) { 156 const LocalStorageKey = { 157 get OnlineTheme() { 158 return `onlineShare.theme.${config.id || '0'}`; 159 }, 160 get UserTheme() { 161 return `user.theme.${config.id || '0'}`; 162 }, 163 }; 164 if (!config || typeof config !== 'object') { 165 return; 166 } 167 window.__subdirectory = config.subdirectory; 168 const theme = config.theme || AppTheme.System; 169 170 const localOnlineTheme = (() => { 171 const localStorageTheme = localStorage.getItem(LocalStorageKey.OnlineTheme); 172 if (localStorageTheme && Object.values(AppTheme).includes(localStorageTheme)) { 173 return localStorageTheme; 174 } 175 return AppTheme.System; 176 })(); 177 const localUserTheme = (() => { 178 const localStorageTheme = localStorage.getItem(LocalStorageKey.UserTheme); 179 if ( 180 localStorageTheme && 181 localStorageTheme !== AppTheme.System && 182 Object.values(AppTheme).includes(localStorageTheme) 183 ) { 184 return localStorageTheme; 185 } 186 return undefined; 187 })(); 188 189 const currentTheme = (() => { 190 if (localOnlineTheme === theme && localUserTheme) { 191 return localUserTheme; 192 } 193 194 if (theme === AppTheme.System) { 195 const media = window.matchMedia('(prefers-color-scheme: dark)'); 196 return media.matches ? AppTheme.Dark : AppTheme.Light; 197 } else { 198 return theme; 199 } 200 })(); 201 202 __setDocsTheme( 203 config.themePrimarySettings, 204 config.logoSettings, 205 config.backgroundImageSettings, 206 currentTheme, 207 ); 208 209 if (!isAddEventListener) { 210 isAddEventListener = true; 211 window.addEventListener('error', (e) => { 212 if ( 213 e.message.startsWith('Uncaught Error: Minified React error #418;') || 214 e.message.startsWith('Uncaught Error: Minified React error #423;') 215 ) { 216 if (!isResetDocsTheme) { 217 isResetDocsTheme = true; 218 __setDocsTheme( 219 config.themePrimarySettings, 220 config.logoSettings, 221 config.backgroundImageSettings, 222 currentTheme, 223 ); 224 225 const iconLink = document.head.querySelector('link[rel="icon"]'); 226 if (iconLink) { 227 const iconLinkHref = iconLink.getAttribute('href'); 228 if (typeof iconLinkHref === 'string') { 229 iconLink.setAttribute('href', iconLinkHref); 230 } 231 } 232 } 233 } 234 }); 235 } 236 } 237 window.__prepareDocsConfigScript = __prepareDocsConfigScript; 238})();
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.