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right (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\n/**\n * An IThemingInstruction can specify a rawString to be preserved or a theme slot and a default value\n * to use if that slot is not specified by the theme.\n */\n\n/* eslint-disable @typescript-eslint/no-use-before-define */\n\n// Declaring a global here in case that the execution environment is Node.js (without importing the\n// entire node.js d.ts for now)\ndeclare let global: any; // eslint-disable-line @typescript-eslint/no-explicit-any\n\nexport interface IThemingInstruction {\n theme?: string;\n defaultValue?: string;\n rawString?: string;\n}\n\nexport type ThemableArray = IThemingInstruction[];\n\nexport interface ITheme {\n [key: string]: string;\n}\n\ninterface IStyleSheet {\n cssText: string;\n}\n\ninterface IExtendedHtmlStyleElement extends HTMLStyleElement {\n styleSheet: IStyleSheet;\n}\n\n/**\n * Performance Measurement of loading styles\n */\ninterface IMeasurement {\n /**\n * Count of style element injected, which is the slow operation in IE\n */\n count: number;\n /**\n * Total duration of all loadStyles exections\n */\n duration: number;\n}\n\ninterface IRunState {\n mode: Mode;\n buffer: ThemableArray[];\n flushTimer: number;\n}\n\ninterface IThemeState {\n theme: ITheme | undefined;\n lastStyleElement: IExtendedHtmlStyleElement;\n registeredStyles: IStyleRecord[]; // records of already registered non-themable styles\n registeredThemableStyles: IStyleRecord[]; // records of already registered themable styles\n loadStyles: ((processedStyles: string, rawStyles?: string | ThemableArray) => void) | undefined;\n perf: IMeasurement;\n runState: IRunState;\n}\n\ninterface IStyleRecord {\n styleElement: Element;\n themableStyle: ThemableArray;\n}\n\ninterface ICustomEvent extends Event {\n args?: T;\n}\n\n/**\n * object returned from resolveThemableArray function\n */\ninterface IThemableArrayResolveResult {\n /** this string is the processed styles in string */\n styleString: string;\n\n /** this boolean indicates if this style array is themable */\n themable: boolean;\n}\n\n/**\n * In sync mode, styles are registered as style elements synchronously with loadStyles() call.\n * In async mode, styles are buffered and registered as batch in async timer for performance purpose.\n */\nexport const enum Mode {\n sync,\n async\n}\n\n/**\n * Themable styles and non-themable styles are tracked separately\n * Specify ClearStyleOptions when calling clearStyles API to specify which group of registered styles should be cleared.\n */\nexport const enum ClearStyleOptions {\n /** only themable styles will be cleared */\n onlyThemable = 1,\n /** only non-themable styles will be cleared */\n onlyNonThemable = 2,\n /** both themable and non-themable styles will be cleared */\n all = 3\n}\n\n// Store the theming state in __themeState__ global scope for reuse in the case of duplicate\n// load-themed-styles hosted on the page.\nconst _root: any = typeof window === 'undefined' ? global : window; // eslint-disable-line @typescript-eslint/no-explicit-any\n\n// Nonce string to inject into script tag if one provided. This is used in CSP (Content Security Policy).\nconst _styleNonce: string = _root && _root.CSPSettings && _root.CSPSettings.nonce;\n\nconst _themeState: IThemeState = initializeThemeState();\n\n/**\n * Matches theming tokens. For example, \"[theme: themeSlotName, default: #FFF]\" (including the quotes).\n */\nconst _themeTokenRegex: RegExp =\n /[\\'\\\"]\\[theme:\\s*(\\w+)\\s*(?:\\,\\s*default:\\s*([\\\\\"\\']?[\\.\\,\\(\\)\\#\\-\\s\\w]*[\\.\\,\\(\\)\\#\\-\\w][\\\"\\']?))?\\s*\\][\\'\\\"]/g;\n\nconst now: () => number = () =>\n typeof performance !== 'undefined' && !!performance.now ? performance.now() : Date.now();\n\nfunction measure(func: () => void): void {\n const start: number = now();\n func();\n const end: number = now();\n _themeState.perf.duration += end - start;\n}\n\n/**\n * initialize global state object\n */\nfunction initializeThemeState(): IThemeState {\n let state: IThemeState = _root.__themeState__ || {\n theme: undefined,\n lastStyleElement: undefined,\n registeredStyles: []\n };\n\n if (!state.runState) {\n state = {\n ...state,\n perf: {\n count: 0,\n duration: 0\n },\n runState: {\n flushTimer: 0,\n mode: Mode.sync,\n buffer: []\n }\n };\n }\n if (!state.registeredThemableStyles) {\n state = {\n ...state,\n registeredThemableStyles: []\n };\n }\n _root.__themeState__ = state;\n return state;\n}\n\n/**\n * Loads a set of style text. If it is registered too early, we will register it when the window.load\n * event is fired.\n * @param {string | ThemableArray} styles Themable style text to register.\n * @param {boolean} loadAsync When true, always load styles in async mode, irrespective of current sync mode.\n */\nexport function loadStyles(styles: string | ThemableArray, loadAsync: boolean = false): void {\n measure(() => {\n const styleParts: ThemableArray = Array.isArray(styles) ? styles : splitStyles(styles);\n const { mode, buffer, flushTimer } = _themeState.runState;\n if (loadAsync || mode === Mode.async) {\n buffer.push(styleParts);\n if (!flushTimer) {\n _themeState.runState.flushTimer = asyncLoadStyles();\n }\n } else {\n applyThemableStyles(styleParts);\n }\n });\n}\n\n/**\n * Allows for customizable loadStyles logic. e.g. for server side rendering application\n * @param {(processedStyles: string, rawStyles?: string | ThemableArray) => void}\n * a loadStyles callback that gets called when styles are loaded or reloaded\n */\nexport function configureLoadStyles(\n loadStylesFn: ((processedStyles: string, rawStyles?: string | ThemableArray) => void) | undefined\n): void {\n _themeState.loadStyles = loadStylesFn;\n}\n\n/**\n * Configure run mode of load-themable-styles\n * @param mode load-themable-styles run mode, async or sync\n */\nexport function configureRunMode(mode: Mode): void {\n _themeState.runState.mode = mode;\n}\n\n/**\n * external code can call flush to synchronously force processing of currently buffered styles\n */\nexport function flush(): void {\n measure(() => {\n const styleArrays: ThemableArray[] = _themeState.runState.buffer.slice();\n _themeState.runState.buffer = [];\n const mergedStyleArray: ThemableArray = ([] as ThemableArray).concat.apply([], styleArrays);\n if (mergedStyleArray.length > 0) {\n applyThemableStyles(mergedStyleArray);\n }\n });\n}\n\n/**\n * register async loadStyles\n */\nfunction asyncLoadStyles(): number {\n return setTimeout(() => {\n _themeState.runState.flushTimer = 0;\n flush();\n }, 0);\n}\n\n/**\n * Loads a set of style text. If it is registered too early, we will register it when the window.load event\n * is fired.\n * @param {string} styleText Style to register.\n * @param {IStyleRecord} styleRecord Existing style record to re-apply.\n */\nfunction applyThemableStyles(stylesArray: ThemableArray, styleRecord?: IStyleRecord): void {\n if (_themeState.loadStyles) {\n _themeState.loadStyles(resolveThemableArray(stylesArray).styleString, stylesArray);\n } else {\n registerStyles(stylesArray);\n }\n}\n\n/**\n * Registers a set theme tokens to find and replace. If styles were already registered, they will be\n * replaced.\n * @param {theme} theme JSON object of theme tokens to values.\n */\nexport function loadTheme(theme: ITheme | undefined): void {\n _themeState.theme = theme;\n\n // reload styles.\n reloadStyles();\n}\n\n/**\n * Clear already registered style elements and style records in theme_State object\n * @param option - specify which group of registered styles should be cleared.\n * Default to be both themable and non-themable styles will be cleared\n */\nexport function clearStyles(option: ClearStyleOptions = ClearStyleOptions.all): void {\n if (option === ClearStyleOptions.all || option === ClearStyleOptions.onlyNonThemable) {\n clearStylesInternal(_themeState.registeredStyles);\n _themeState.registeredStyles = [];\n }\n if (option === ClearStyleOptions.all || option === ClearStyleOptions.onlyThemable) {\n clearStylesInternal(_themeState.registeredThemableStyles);\n _themeState.registeredThemableStyles = [];\n }\n}\n\nfunction clearStylesInternal(records: IStyleRecord[]): void {\n records.forEach((styleRecord: IStyleRecord) => {\n const styleElement: HTMLStyleElement = styleRecord && (styleRecord.styleElement as HTMLStyleElement);\n if (styleElement && styleElement.parentElement) {\n styleElement.parentElement.removeChild(styleElement);\n }\n });\n}\n\n/**\n * Reloads styles.\n */\nfunction reloadStyles(): void {\n if (_themeState.theme) {\n const themableStyles: ThemableArray[] = [];\n for (const styleRecord of _themeState.registeredThemableStyles) {\n themableStyles.push(styleRecord.themableStyle);\n }\n if (themableStyles.length > 0) {\n clearStyles(ClearStyleOptions.onlyThemable);\n applyThemableStyles(([] as ThemableArray).concat.apply([], themableStyles));\n }\n }\n}\n\n/**\n * Find theme tokens and replaces them with provided theme values.\n * @param {string} styles Tokenized styles to fix.\n */\nexport function detokenize(styles: string | undefined): string | undefined {\n if (styles) {\n styles = resolveThemableArray(splitStyles(styles)).styleString;\n }\n\n return styles;\n}\n\n/**\n * Resolves ThemingInstruction objects in an array and joins the result into a string.\n * @param {ThemableArray} splitStyleArray ThemableArray to resolve and join.\n */\nfunction resolveThemableArray(splitStyleArray: ThemableArray): IThemableArrayResolveResult {\n const { theme }: IThemeState = _themeState;\n let themable: boolean = false;\n // Resolve the array of theming instructions to an array of strings.\n // Then join the array to produce the final CSS string.\n const resolvedArray: (string | undefined)[] = (splitStyleArray || []).map(\n (currentValue: IThemingInstruction) => {\n const themeSlot: string | undefined = currentValue.theme;\n if (themeSlot) {\n themable = true;\n // A theming annotation. Resolve it.\n const themedValue: string | undefined = theme ? theme[themeSlot] : undefined;\n const defaultValue: string = currentValue.defaultValue || 'inherit';\n\n // Warn to console if we hit an unthemed value even when themes are provided, but only if \"DEBUG\" is true.\n // Allow the themedValue to be undefined to explicitly request the default value.\n if (\n theme &&\n !themedValue &&\n console &&\n !(themeSlot in theme) &&\n typeof DEBUG !== 'undefined' &&\n DEBUG\n ) {\n console.warn(`Theming value not provided for \"${themeSlot}\". Falling back to \"${defaultValue}\".`);\n }\n\n return themedValue || defaultValue;\n } else {\n // A non-themable string. Preserve it.\n return currentValue.rawString;\n }\n }\n );\n\n return {\n styleString: resolvedArray.join(''),\n themable: themable\n };\n}\n\n/**\n * Split tokenized CSS into an array of strings and theme specification objects\n * @param {string} styles Tokenized styles to split.\n */\nexport function splitStyles(styles: string): ThemableArray {\n const result: ThemableArray = [];\n if (styles) {\n let pos: number = 0; // Current position in styles.\n let tokenMatch: RegExpExecArray | null;\n while ((tokenMatch = _themeTokenRegex.exec(styles))) {\n const matchIndex: number = tokenMatch.index;\n if (matchIndex > pos) {\n result.push({\n rawString: styles.substring(pos, matchIndex)\n });\n }\n\n result.push({\n theme: tokenMatch[1],\n defaultValue: tokenMatch[2] // May be undefined\n });\n\n // index of the first character after the current match\n pos = _themeTokenRegex.lastIndex;\n }\n\n // Push the rest of the string after the last match.\n result.push({\n rawString: styles.substring(pos)\n });\n }\n\n return result;\n}\n\n/**\n * Registers a set of style text. If it is registered too early, we will register it when the\n * window.load event is fired.\n * @param {ThemableArray} styleArray Array of IThemingInstruction objects to register.\n * @param {IStyleRecord} styleRecord May specify a style Element to update.\n */\nfunction registerStyles(styleArray: ThemableArray): void {\n if (typeof document === 'undefined') {\n return;\n }\n const head: HTMLHeadElement = document.getElementsByTagName('head')[0];\n const styleElement: HTMLStyleElement = document.createElement('style');\n const { styleString, themable } = resolveThemableArray(styleArray);\n\n styleElement.setAttribute('data-load-themed-styles', 'true');\n if (_styleNonce) {\n styleElement.setAttribute('nonce', _styleNonce);\n }\n styleElement.appendChild(document.createTextNode(styleString));\n _themeState.perf.count++;\n head.appendChild(styleElement);\n\n const ev: ICustomEvent<{ newStyle: HTMLStyleElement }> = document.createEvent('HTMLEvents');\n ev.initEvent('styleinsert', true /* bubbleEvent */, false /* cancelable */);\n ev.args = {\n newStyle: styleElement\n };\n document.dispatchEvent(ev);\n\n const record: IStyleRecord = {\n styleElement: styleElement,\n themableStyle: styleArray\n };\n\n if (themable) {\n _themeState.registeredThemableStyles.push(record);\n } else {\n _themeState.registeredStyles.push(record);\n }\n}\n"],"names":["_root","window","global","_styleNonce","CSPSettings","nonce","_themeState","state","__themeState__","theme","undefined","lastStyleElement","registeredStyles","runState","__assign","perf","count","duration","flushTimer","mode","buffer","registeredThemableStyles","initializeThemeState","applyThemableStyles","stylesArray","styleRecord","loadStyles","resolveThemableArray","styleString","styleArray","document","head","getElementsByTagName","styleElement","createElement","_a","themable","setAttribute","appendChild","createTextNode","ev","createEvent","initEvent","args","newStyle","dispatchEvent","record","themableStyle","push","registerStyles","loadTheme","themableStyles","_i","length","option","clearStylesInternal","clearStyles","concat","apply","reloadStyles","records","forEach","parentElement","removeChild","splitStyleArray","map","currentValue","themeSlot","themedValue","defaultValue","console","DEBUG","warn","rawString","join"],"sourceRoot":""}