import { hex2rgb } from '../color_convert/color_convert.js' import { init, getEngineChecksum } from '../theme_data/theme_data_3.service.js' import { getCssRules } from '../theme_data/css_utils.js' import { defaultState } from '../../modules/config.js' import { chunk } from 'lodash' // On platforms where this is not supported, it will return undefined // Otherwise it will return an array const supportsAdoptedStyleSheets = !!document.adoptedStyleSheets const createStyleSheet = (id) => { if (supportsAdoptedStyleSheets) { return { el: null, sheet: new CSSStyleSheet(), rules: [] } } const el = document.getElementById(id) // Clear all rules in it for (let i = el.sheet.cssRules.length - 1; i >= 0; --i) { el.sheet.deleteRule(i) } return { el, sheet: el.sheet, rules: [] } } const EAGER_STYLE_ID = 'pleroma-eager-styles' const LAZY_STYLE_ID = 'pleroma-lazy-styles' const adoptStyleSheets = (styles) => { if (supportsAdoptedStyleSheets) { document.adoptedStyleSheets = styles.map(s => s.sheet) } // Some older browsers do not support document.adoptedStyleSheets. // In this case, we use the