UNPKG

otion

Version:

Atomic CSS-in-JS with a featherweight runtime

1 lines 37.3 kB
{"version":3,"file":"bundle.mjs","sources":["../../../../node_modules/@emotion/hash/dist/hash.browser.esm.js","../../../../node_modules/tiny-css-prefixer/dist/tiny-css-prefixer.es.js","../../src/env.ts","../../src/getStyleElement.ts","../../src/injectors.ts","../../src/minify.ts","../../src/propertyMatchers.ts","../../src/pseudos.ts","../../src/rulePrecedence.ts","../../src/createInstance.ts","../../src/index.ts"],"sourcesContent":["/* eslint-disable */\n// Inspired by https://github.com/garycourt/murmurhash-js\n// Ported from https://github.com/aappleby/smhasher/blob/61a0530f28277f2e850bfc39600ce61d02b518de/src/MurmurHash2.cpp#L37-L86\nfunction murmur2(str) {\n // 'm' and 'r' are mixing constants generated offline.\n // They're not really 'magic', they just happen to work well.\n // const m = 0x5bd1e995;\n // const r = 24;\n // Initialize the hash\n var h = 0; // Mix 4 bytes at a time into the hash\n\n var k,\n i = 0,\n len = str.length;\n\n for (; len >= 4; ++i, len -= 4) {\n k = str.charCodeAt(i) & 0xff | (str.charCodeAt(++i) & 0xff) << 8 | (str.charCodeAt(++i) & 0xff) << 16 | (str.charCodeAt(++i) & 0xff) << 24;\n k =\n /* Math.imul(k, m): */\n (k & 0xffff) * 0x5bd1e995 + ((k >>> 16) * 0xe995 << 16);\n k ^=\n /* k >>> r: */\n k >>> 24;\n h =\n /* Math.imul(k, m): */\n (k & 0xffff) * 0x5bd1e995 + ((k >>> 16) * 0xe995 << 16) ^\n /* Math.imul(h, m): */\n (h & 0xffff) * 0x5bd1e995 + ((h >>> 16) * 0xe995 << 16);\n } // Handle the last few bytes of the input array\n\n\n switch (len) {\n case 3:\n h ^= (str.charCodeAt(i + 2) & 0xff) << 16;\n\n case 2:\n h ^= (str.charCodeAt(i + 1) & 0xff) << 8;\n\n case 1:\n h ^= str.charCodeAt(i) & 0xff;\n h =\n /* Math.imul(h, m): */\n (h & 0xffff) * 0x5bd1e995 + ((h >>> 16) * 0xe995 << 16);\n } // Do a few final mixes of the hash to ensure the last few\n // bytes are well-incorporated.\n\n\n h ^= h >>> 13;\n h =\n /* Math.imul(h, m): */\n (h & 0xffff) * 0x5bd1e995 + ((h >>> 16) * 0xe995 << 16);\n return ((h ^ h >>> 15) >>> 0).toString(36);\n}\n\nexport default murmur2;\n","var t=/^(br|hy|us|wr|text-si|scroll-snap-t)/,e=/^(ap|us|tab-|border-e|margin-e|margin-s|padding-e|padding-s|border-sta)/,r=/^(ap|br|hy|us|wr|mas|colu|clip-|box-de|font-k|text-e|font-fe|shape-i|text-or|text-si|border-e|margin-e|margin-s|padding-e|padding-s|border-sta|background-cl|scroll-snap-t|text-decoration-)/,s=/^(pos|background-cl)/,a={},n=function(s){return a[s]?a[s]:a[s]=1*t.test(s)|2*e.test(s)|4*r.test(s)},o=function(t,e){return s.test(t)?e.replace(/(sticky|text)/,\"-webkit-$1, $1\"):e};export{n as prefixProperty,o as prefixValue};\n","export const isBrowser = typeof window !== \"undefined\";\nexport const isDev = process.env.NODE_ENV !== \"production\";\n","export const STYLE_ELEMENT_ID = \"__otion\";\n\nexport function getStyleElement(): HTMLStyleElement {\n\t// Hydrate existing style element if available\n\tlet el = document.getElementById(STYLE_ELEMENT_ID) as HTMLStyleElement | null;\n\tif (el) return el;\n\n\t// Create a new one otherwise\n\tel = document.createElement(\"style\");\n\tel.id = STYLE_ELEMENT_ID;\n\n\treturn document.head.appendChild(el);\n}\n","import { getStyleElement } from \"./getStyleElement\";\n\nexport interface InjectorConfig<T> {\n\t/** Sets a cryptographic nonce (number used once) on the enclosing `<style>` tag when generating a page on demand. Useful for enforcing a [Content Security Policy (CSP)](https://developer.mozilla.org/docs/Web/HTTP/CSP). */\n\tnonce?: string;\n\n\t/** Target to insert rules into. */\n\ttarget?: T;\n}\n\nexport type InjectorInstance = {\n\tsheet?: CSSStyleSheet;\n\tinsert(rule: string, index: number): number;\n};\n\ntype VirtualInjectorInstance = InjectorInstance & {\n\tnonce: string | undefined;\n\truleTexts: string[];\n};\n\n/**\n * Creates an injector which collects style rules during server-side rendering.\n */\nexport function VirtualInjector({\n\tnonce,\n\ttarget: ruleTexts = [],\n}: InjectorConfig<string[]> = {}): VirtualInjectorInstance {\n\treturn {\n\t\tnonce,\n\t\truleTexts,\n\n\t\tinsert(rule, index): number {\n\t\t\truleTexts.splice(index, 0, rule);\n\t\t\treturn index;\n\t\t},\n\t};\n}\n\n/**\n * Creates an injector which inserts style rules through the CSS Object Model.\n */\nexport function CSSOMInjector({\n\tnonce,\n\ttarget = getStyleElement().sheet as CSSStyleSheet,\n}: InjectorConfig<CSSStyleSheet>): InjectorInstance {\n\t// eslint-disable-next-line no-param-reassign\n\t(target.ownerNode as HTMLStyleElement).nonce = nonce;\n\n\treturn {\n\t\tsheet: target,\n\n\t\tinsert(rule, index): number {\n\t\t\t// Avoid render failure during production if a rule cannot be parsed\n\t\t\ttry {\n\t\t\t\treturn target.insertRule(rule, index);\n\t\t\t} catch {\n\t\t\t\treturn -1;\n\t\t\t}\n\t\t},\n\t};\n}\n\n/**\n * Creates an injector which inserts style rules through the Document Object Model.\n */\nexport function DOMInjector({\n\tnonce,\n\ttarget = getStyleElement(),\n}: InjectorConfig<HTMLStyleElement>): InjectorInstance {\n\t// eslint-disable-next-line no-param-reassign\n\ttarget.nonce = nonce;\n\n\treturn {\n\t\tsheet: target.sheet as CSSStyleSheet,\n\n\t\tinsert(rule, index): number {\n\t\t\ttarget.insertBefore(\n\t\t\t\tdocument.createTextNode(rule),\n\t\t\t\ttarget.childNodes[index],\n\t\t\t);\n\t\t\treturn index;\n\t\t},\n\t};\n}\n\n/**\n * An injector placeholder which performs no operations. Useful for avoiding errors in a non-browser environment.\n */\nexport const NoOpInjector: InjectorInstance = {\n\tinsert(): number {\n\t\treturn 0;\n\t},\n};\n","export function minifyValue(value: string): string {\n\t// Remove excess white space characters\n\treturn value.trim().replace(/\\s+/g, \" \");\n}\n\nexport function minifyCondition(condition: string): string {\n\treturn minifyValue(condition).replace(/([([]) | ([)\\]])| ?(:) ?/g, \"$1$2$3\");\n}\n","/*\n\tThe order of rules is influenced by CSS usage metrics:\n\n\t- https://www.cssstats.com/stats/?url=css-tricks.com\n\t- https://www.cssstats.com/stats/?url=joshwcomeau.com\n\t- https://www.cssstats.com/stats/?url=mastery.games\n\t- https://www.cssstats.com/stats/?url=nytimes.com\n\t- https://www.chromestatus.com/metrics/css/popularity\n*/\n\n// Includes support for CSS custom properties\nexport const PROPERTY_ACCEPTS_UNITLESS_VALUES = /^(-|f[lo].*?[^se]$|g.{6,}[^ps]$|z|o[pr]|(-w.{6})?li.*?(t|mp)$|an|(bo|s).{5}im|sca|m.{7}[ds]|ta|c.*?[st]$|wido|ini)/;\n\n// TODO: Add tests to match everything below, without false positives\nexport const propertiesAcceptingUnitlessValues = [\n\t/* ^f[lo].*?[^se]$ */\n\t\"flex\",\n\t\"flex-grow\",\n\t\"flex-shrink\",\n\t\"font-size-adjust\",\n\t\"font-weight\",\n\n\t/* ^g.{6,}[^ps]$ */\n\t\"grid-area\",\n\t\"grid-column\",\n\t\"grid-column-end\",\n\t\"grid-column-start\",\n\t\"grid-row\",\n\t\"grid-row-end\",\n\t\"grid-row-start\",\n\n\t/* ^z */\n\t\"z-index\",\n\n\t/* ^o[pr] */\n\t\"opacity\",\n\t\"order\",\n\t\"orphans\",\n\n\t/* ^(-w.{6})?li.*?(t|mp)$ */\n\t\"line-height\",\n\t\"line-clamp\",\n\t\"-webkit-line-clamp\",\n\n\t/* ^an */\n\t\"animation\",\n\t\"animation-iteration-count\",\n\n\t/* ^(bo|s).{5}im */\n\t\"border-image\",\n\t\"border-image-outset\",\n\t\"border-image-slice\",\n\t\"border-image-width\",\n\t\"shape-image-threshold\",\n\n\t/* ^sca */\n\t\"scale\",\n\n\t/* ^m.{7}[ds] */\n\t\"mask-border\",\n\t\"mask-border-outset\",\n\t\"mask-border-slice\",\n\t\"mask-border-width\",\n\t\"max-lines\",\n\n\t/* ^ta */\n\t\"tab-size\",\n\n\t/* ^c.*?[st]$ */\n\t\"columns\",\n\t\"column-count\",\n\n\t/* ^wido */\n\t\"widows\",\n\n\t/* ^ini */\n\t\"initial-letter\",\n];\n\nexport const PROPERTY_PRECEDENCE_CORRECTION_GROUPS = /^(?:(border-(?!w|c|sty)|[tlbr].{2,4}m?$|c.{7}$)|([fl].{5}l|g.{8}$|pl))/;\n\n// TODO: Add tests to match everything below, with no conflicting longhands\nexport const propertiesByPrecedenceCorrectionGroup = {\n\t\"+1\": [\n\t\t/* ^border-(?!w|c|sty) */\n\t\t\"border-!(width,color,style)\",\n\n\t\t/* ^[tlbr].{2,4}m?$ */\n\t\t\"top\",\n\t\t\"left\",\n\t\t\"bottom\",\n\t\t\"right\",\n\n\t\t/* ^c.{7}$ */\n\t\t\"continue\",\n\t],\n\n\t\"-1\": [\n\t\t/* ^[fl].{5}l */\n\t\t\"flex-flow\",\n\t\t\"line-clamp\",\n\n\t\t/* ^g.{8}$ */\n\t\t\"grid-area\",\n\n\t\t/* ^pl */\n\t\t\"place-content\",\n\t\t\"place-items\",\n\t\t\"place-self\",\n\t],\n};\n","/*\n\tSources:\n\n\t- https://bitsofco.de/when-do-the-hover-focus-and-active-pseudo-classes-apply/#orderofstyleshoverthenfocusthenactive\n\t- https://developer.mozilla.org/docs/Web/CSS/:active#Active_links\n*/\n\nexport const PRECEDENCES_BY_PSEUDO_CLASS = new Map([\n\t[/* li */ \"nk\", 1],\n\t[/* vi */ \"sited\", 2],\n\t[/* em */ \"pty\", 3],\n\t[/* fo */ \"cus-w\" /* ithin */, 4],\n\t[/* ho */ \"ver\", 5],\n\t[/* fo */ \"cus\", 6],\n\t[/* fo */ \"cus-v\" /* isible */, 7],\n\t[/* ac */ \"tive\", 8],\n\t[/* di */ \"sable\" /* d */, 9],\n]);\n\nexport const PSEUDO_CLASS_PRECEDENCE_GROUP_COUNT = 9;\n","import { PROPERTY_PRECEDENCE_CORRECTION_GROUPS } from \"./propertyMatchers\";\nimport {\n\tPRECEDENCES_BY_PSEUDO_CLASS,\n\tPSEUDO_CLASS_PRECEDENCE_GROUP_COUNT,\n} from \"./pseudos\";\n\nexport function rulePrecedence(\n\tproperty: string,\n\tpseudoClass: string,\n\tisConditionalRule: boolean,\n): number {\n\tlet precedence = 0;\n\n\tconst isCustomProperty = property[1] === \"-\";\n\tif (!isCustomProperty) {\n\t\t// The property's baseline precedence is based on \"-\" counting\n\t\tconst unprefixedProperty =\n\t\t\tproperty[0] === \"-\"\n\t\t\t\t? property.slice(property.indexOf(\"-\", 1)) + 1\n\t\t\t\t: property;\n\t\tconst matches = PROPERTY_PRECEDENCE_CORRECTION_GROUPS.exec(\n\t\t\tunprefixedProperty,\n\t\t);\n\t\tprecedence =\n\t\t\t(matches ? +!!matches[1] /* +1 */ || -!!matches[2] /* -1 */ : 0) + 1;\n\t\tlet position = 1; // First character of the property can't be `-`\n\t\twhile (\n\t\t\t// eslint-disable-next-line no-cond-assign\n\t\t\t(position = unprefixedProperty.indexOf(\"-\", position) + 1) /* > 0 */\n\t\t) {\n\t\t\t++precedence;\n\t\t}\n\t}\n\n\t// Pseudo-classes also have an impact on rule precedence\n\tconst conditionalPrecedenceGroupExistenceMultiplier = 2;\n\tprecedence *=\n\t\tconditionalPrecedenceGroupExistenceMultiplier *\n\t\t((pseudoClass &&\n\t\t\tPRECEDENCES_BY_PSEUDO_CLASS.get(\n\t\t\t\tpseudoClass.slice(3, 8), // Uniquely identifies a pseudo selector\n\t\t\t)) ||\n\t\t\tPSEUDO_CLASS_PRECEDENCE_GROUP_COUNT + 1);\n\n\t// Conditional rules should take precedence over non-conditionals\n\tprecedence += +isConditionalRule;\n\n\treturn precedence;\n}\n","import hash from \"@emotion/hash\";\nimport { prefixProperty, prefixValue } from \"tiny-css-prefixer\";\n\nimport { CSSKeyframeRules, ScopedCSSRules } from \"./cssTypes\";\nimport { isBrowser, isDev } from \"./env\";\nimport {\n\tCSSOMInjector,\n\tDOMInjector,\n\tInjectorInstance,\n\tNoOpInjector,\n} from \"./injectors\";\nimport { minifyCondition, minifyValue } from \"./minify\";\nimport { PROPERTY_ACCEPTS_UNITLESS_VALUES } from \"./propertyMatchers\";\nimport { rulePrecedence } from \"./rulePrecedence\";\n\nexport const PRECEDENCE_GROUP_COUNT = 72;\n\nfunction toHyphenLower(match: string): string {\n\treturn `-${match.toLowerCase()}`;\n}\n\nexport interface OtionConfig {\n\t/** Style insertion methodology to be used. */\n\tinjector?: InjectorInstance;\n\n\t/** Auto-prefixer method for CSS property–value pairs. */\n\tprefix?: (property: string, value: string) => string;\n}\n\nexport interface OtionInstance {\n\t/**\n\t * Customizes the otion instance. May only be called once, before using the instance for anything else.\n\t */\n\tsetup(options: OtionConfig): void;\n\n\t/**\n\t * Marks server-rendered CSS identity names as available to avoid re-injecting them to the style sheet during runtime.\n\t */\n\thydrate(): void;\n\n\t/**\n\t * Decomposes CSS into atomic styles. Rules are injected to the style sheet if not already available.\n\t *\n\t * @param rules Scoped CSS as [object styles](https://gist.github.com/threepointone/9f87907a91ec6cbcd376dded7811eb31), with value fallbacks represented as arrays.\n\t *\n\t * - Numbers assigned to non-unitless properties are postfixed with \"px\".\n\t * - Excess white space characters are truncated.\n\t *\n\t * @returns A space-separated list of stably generated unique class names.\n\t *\n\t * @example\n\t * const classNames = css({\n\t * display: \"flex\",\n\t * justifyContent: [\"space-around\", \"space-evenly\"], // Last takes precedence\n\t * padding: 8, // \"8px\"\n\t * lineHeight: 1.5, // \"1.5\" without a unit\n\t * selectors: {\n\t * // Advanced selectors must start with \"&\"\n\t * \"& > * + *\": {\n\t * paddingLeft: 16\n\t * }\n\t * }\n\t * });\n\t */\n\tcss(rules: ScopedCSSRules): string;\n\n\t// used to specify the values for the animating properties at various points during the animation\n\t/**\n\t * Creates keyframes for animating values of given properties over time.\n\t *\n\t * @param rules CSS keyframe rules as [object styles](https://gist.github.com/threepointone/9f87907a91ec6cbcd376dded7811eb31), with value fallbacks represented as arrays.\n\t *\n\t * - Numbers assigned to non-unitless properties are postfixed with \"px\".\n\t * - Excess white space characters are truncated.\n\t *\n\t * @returns Lazy method for stably generating a unique animation name upon usage.\n\t *\n\t * @example\n\t * const pulse = keyframes({\n\t * from: { opacity: 0 },\n\t * to: { opacity: 1 }\n\t * });\n\t *\n\t * // Referencing\n\t * const className = css({\n\t * animation: `${pulse} 3s infinite alternate`\n\t * });\n\t */\n\tkeyframes(rules: CSSKeyframeRules): { /** @private */ toString(): string };\n}\n\n/**\n * Creates a new otion instance. Usable for managing styles of multiple browsing contexts (e.g. an `<iframe>` besides the main document).\n */\nexport function createInstance(): OtionInstance {\n\tlet injector: InjectorInstance;\n\tlet prefix: (property: string, value: string) => string;\n\tlet ruleIndexesByIdentName: Map<string, number>;\n\tlet nextRuleIndexesByPrecedenceGroup: Uint16Array;\n\n\tfunction checkSetup(): void {\n\t\tif (!injector || !prefix || !ruleIndexesByIdentName) {\n\t\t\tthrow new Error(\n\t\t\t\t\"On a custom otion instance, `setup()` must be called before usage.\",\n\t\t\t);\n\t\t}\n\t}\n\n\tfunction updatePrecedenceGroupRanges(fromPrecedence: number) {\n\t\tfor (let i = fromPrecedence; i <= PRECEDENCE_GROUP_COUNT; ++i) {\n\t\t\t++nextRuleIndexesByPrecedenceGroup[i];\n\t\t}\n\t}\n\n\tfunction hydrateScopedSubtree(\n\t\tcssRule: CSSRule,\n\t\tisConditionalRule?: boolean,\n\t): void {\n\t\tif (cssRule.type === 1 /* CSSRule.STYLE_RULE */) {\n\t\t\tconst { selectorText, style } = cssRule as CSSStyleRule;\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\tconst [, identName, pseudoClass] = /^..([0-9a-z]+)(:.*)?/.exec(\n\t\t\t\tselectorText,\n\t\t\t)!;\n\t\t\tconst property = style[0];\n\t\t\tif (property) {\n\t\t\t\t// Broken rule declarations are ignored\n\t\t\t\tupdatePrecedenceGroupRanges(\n\t\t\t\t\trulePrecedence(property, pseudoClass, !!isConditionalRule),\n\t\t\t\t);\n\t\t\t}\n\t\t\truleIndexesByIdentName.set(identName, ruleIndexesByIdentName.size);\n\t\t} else {\n\t\t\t/* cssRule.type === CSSRule.MEDIA_RULE */\n\t\t\thydrateScopedSubtree((cssRule as CSSGroupingRule).cssRules[0], true);\n\t\t}\n\t}\n\n\tfunction normalizeDeclaration(\n\t\tproperty: string,\n\t\tvalue: string | number,\n\t): string {\n\t\tconst formattedValue =\n\t\t\ttypeof value === \"number\" &&\n\t\t\t!PROPERTY_ACCEPTS_UNITLESS_VALUES.test(property)\n\t\t\t\t? `${value}px` // Append missing unit\n\t\t\t\t: minifyValue(`${value}`);\n\t\treturn prefix(property, formattedValue);\n\t}\n\n\tfunction serializeDeclarationList(\n\t\tproperty: string,\n\t\tvalue: string | number | Array<string | number | undefined>,\n\t): string {\n\t\tif (typeof value !== \"object\") {\n\t\t\treturn normalizeDeclaration(property, value);\n\t\t}\n\n\t\tlet cssText = \"\";\n\t\tvalue.forEach((fallbackValue) => {\n\t\t\tif (fallbackValue) {\n\t\t\t\tcssText += `;${normalizeDeclaration(property, fallbackValue)}`;\n\t\t\t}\n\t\t});\n\n\t\t// The leading declaration separator character gets removed\n\t\treturn cssText.slice(1);\n\t}\n\n\tfunction decomposeToClassNames(\n\t\trules: ScopedCSSRules,\n\t\tcssTextHead: string,\n\t\tcssTextTail: string,\n\t\tmaxPrecedingConditionalRuleIndexesByPrecedenceGroup: Uint16Array,\n\t\tclassSelectorStartIndex?: number,\n\t): string {\n\t\tlet classNames = \"\";\n\n\t\t// TODO: Replace `var` with `const` once it minifies equivalently\n\t\t// eslint-disable-next-line guard-for-in, no-restricted-syntax, no-var, vars-on-top\n\t\tfor (var key in rules) {\n\t\t\tconst value = rules[key as keyof typeof rules];\n\n\t\t\tif (value != null) {\n\t\t\t\tif (typeof value !== \"object\" || Array.isArray(value)) {\n\t\t\t\t\t// Class specificities are controlled with repetition, see:\n\t\t\t\t\t// https://csswizardry.com/2014/07/hacks-for-dealing-with-specificity/\n\n\t\t\t\t\t// TODO: Consider removing IE vendor prefix support\n\t\t\t\t\tconst property = key.replace(/^ms|[A-Z]/g, toHyphenLower);\n\t\t\t\t\tconst declarations = serializeDeclarationList(property, value);\n\t\t\t\t\tconst className = `_${hash(cssTextHead + declarations)}`;\n\t\t\t\t\tconst isConditionalRule = cssTextTail;\n\n\t\t\t\t\tlet ruleIndex = ruleIndexesByIdentName.get(className);\n\n\t\t\t\t\tif (ruleIndex == null || isConditionalRule) {\n\t\t\t\t\t\tconst precedence = rulePrecedence(\n\t\t\t\t\t\t\tproperty,\n\t\t\t\t\t\t\tclassSelectorStartIndex == null\n\t\t\t\t\t\t\t\t? \"\"\n\t\t\t\t\t\t\t\t: cssTextHead.slice(classSelectorStartIndex),\n\t\t\t\t\t\t\t!!isConditionalRule,\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\truleIndex == null ||\n\t\t\t\t\t\t\t// Re-insert conditional rule if necessary to fix CSS source order\n\t\t\t\t\t\t\tmaxPrecedingConditionalRuleIndexesByPrecedenceGroup[precedence] >\n\t\t\t\t\t\t\t\truleIndex\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tconst scopeSelector = `.${className}`;\n\t\t\t\t\t\t\tinjector.insert(\n\t\t\t\t\t\t\t\t`${\n\t\t\t\t\t\t\t\t\tcssTextHead.slice(0, classSelectorStartIndex) +\n\t\t\t\t\t\t\t\t\tscopeSelector +\n\t\t\t\t\t\t\t\t\t(classSelectorStartIndex != null\n\t\t\t\t\t\t\t\t\t\t? `${\n\t\t\t\t\t\t\t\t\t\t\t\tcssTextHead\n\t\t\t\t\t\t\t\t\t\t\t\t\t.slice(classSelectorStartIndex)\n\t\t\t\t\t\t\t\t\t\t\t\t\t.replace(/&/g, scopeSelector) // Resolve references\n\t\t\t\t\t\t\t\t\t\t }{`\n\t\t\t\t\t\t\t\t\t\t: \"{\")\n\t\t\t\t\t\t\t\t}${declarations}}${cssTextTail}`,\n\t\t\t\t\t\t\t\tnextRuleIndexesByPrecedenceGroup[precedence],\n\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\tupdatePrecedenceGroupRanges(precedence);\n\n\t\t\t\t\t\t\truleIndex = ruleIndexesByIdentName.size;\n\t\t\t\t\t\t\truleIndexesByIdentName.set(className, ruleIndex);\n\n\t\t\t\t\t\t\tif (isConditionalRule) {\n\t\t\t\t\t\t\t\t// eslint-disable-next-line no-param-reassign\n\t\t\t\t\t\t\t\tmaxPrecedingConditionalRuleIndexesByPrecedenceGroup[\n\t\t\t\t\t\t\t\t\tprecedence\n\t\t\t\t\t\t\t\t] = Math.max(\n\t\t\t\t\t\t\t\t\tmaxPrecedingConditionalRuleIndexesByPrecedenceGroup[\n\t\t\t\t\t\t\t\t\t\tprecedence\n\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\truleIndex,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tclassNames += ` ${className}`;\n\t\t\t\t} else {\n\t\t\t\t\tlet parentRuleHeads: string[] | undefined;\n\t\t\t\t\tlet firstParentRuleHead =\n\t\t\t\t\t\tkey[0] === \":\" || key[0] === \"@\" || key[0] === \"&\"\n\t\t\t\t\t\t\t? key\n\t\t\t\t\t\t\t: minifyCondition(key);\n\t\t\t\t\tlet parentRuleTail = \"\";\n\t\t\t\t\tlet scopeClassSelectorStartIndex = classSelectorStartIndex;\n\n\t\t\t\t\tif (scopeClassSelectorStartIndex == null) {\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tfirstParentRuleHead[0] === \":\" ||\n\t\t\t\t\t\t\tfirstParentRuleHead[0] === \"&\"\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tscopeClassSelectorStartIndex = cssTextHead.length;\n\t\t\t\t\t\t\tparentRuleHeads = firstParentRuleHead\n\t\t\t\t\t\t\t\t.split(\n\t\t\t\t\t\t\t\t\t// Separate selector list items by \",\"\n\t\t\t\t\t\t\t\t\t// Inspired by: https://stackoverflow.com/a/9030062\n\t\t\t\t\t\t\t\t\t/,(?![^[]*?[^\\\\][\"']\\s*?\\])/,\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t.map(\n\t\t\t\t\t\t\t\t\t(singleSelector) =>\n\t\t\t\t\t\t\t\t\t\t// Keep non-first occurrences of \"&\" for later replacement\n\t\t\t\t\t\t\t\t\t\tminifyValue(singleSelector).replace(\"&\", \"\"), // lgtm [js/incomplete-sanitization]\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} else if (firstParentRuleHead === \"selectors\") {\n\t\t\t\t\t\t\tfirstParentRuleHead = \"\";\n\t\t\t\t\t\t} else if (firstParentRuleHead[0] !== \"@\") {\n\t\t\t\t\t\t\tfirstParentRuleHead += \"{\";\n\t\t\t\t\t\t\tparentRuleTail = \"}\";\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t(parentRuleHeads || [firstParentRuleHead]).forEach(\n\t\t\t\t\t\t// eslint-disable-next-line no-loop-func\n\t\t\t\t\t\t(parentRuleHead) => {\n\t\t\t\t\t\t\tclassNames += decomposeToClassNames(\n\t\t\t\t\t\t\t\tvalue as ScopedCSSRules,\n\t\t\t\t\t\t\t\tcssTextHead + parentRuleHead,\n\t\t\t\t\t\t\t\tparentRuleTail + cssTextTail,\n\t\t\t\t\t\t\t\tmaxPrecedingConditionalRuleIndexesByPrecedenceGroup,\n\t\t\t\t\t\t\t\tscopeClassSelectorStartIndex,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t},\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn classNames;\n\t}\n\n\treturn {\n\t\tsetup(options): void {\n\t\t\tinjector =\n\t\t\t\toptions.injector ||\n\t\t\t\t// eslint-disable-next-line no-nested-ternary\n\t\t\t\t(isBrowser\n\t\t\t\t\t? isDev\n\t\t\t\t\t\t? DOMInjector({})\n\t\t\t\t\t\t: CSSOMInjector({})\n\t\t\t\t\t: NoOpInjector);\n\n\t\t\tprefix =\n\t\t\t\toptions.prefix ||\n\t\t\t\t((property: string, value: string): string => {\n\t\t\t\t\tconst declaration = `${property}:${prefixValue(property, value)}`;\n\t\t\t\t\tlet cssText = declaration;\n\t\t\t\t\tconst flag = prefixProperty(property);\n\t\t\t\t\tif (flag & 0b001) cssText += `;-ms-${declaration}`;\n\t\t\t\t\tif (flag & 0b010) cssText += `;-moz-${declaration}`;\n\t\t\t\t\tif (flag & 0b100) cssText += `;-webkit-${declaration}`;\n\t\t\t\t\treturn cssText;\n\t\t\t\t});\n\n\t\t\truleIndexesByIdentName = new Map();\n\t\t\tnextRuleIndexesByPrecedenceGroup = new Uint16Array(\n\t\t\t\tPRECEDENCE_GROUP_COUNT,\n\t\t\t);\n\t\t},\n\n\t\thydrate(): void {\n\t\t\tif (isDev) checkSetup();\n\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\tconst { cssRules } = injector.sheet!;\n\t\t\tfor (let i = 0, { length } = cssRules; i < length; ++i) {\n\t\t\t\tconst cssRule = cssRules[i];\n\t\t\t\tif (cssRule.type === 7 /* CSSRule.KEYFRAMES_RULE */) {\n\t\t\t\t\t// Keyframes needn't be checked recursively, as they are never nested\n\t\t\t\t\truleIndexesByIdentName.set(\n\t\t\t\t\t\t(cssRule as CSSKeyframesRule).name,\n\t\t\t\t\t\truleIndexesByIdentName.size,\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\thydrateScopedSubtree(cssRule);\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\n\t\tcss(rules): string {\n\t\t\tif (isDev) checkSetup();\n\n\t\t\t// The leading white space character gets removed\n\t\t\treturn decomposeToClassNames(\n\t\t\t\trules,\n\t\t\t\t\"\",\n\t\t\t\t\"\",\n\t\t\t\tnew Uint16Array(PRECEDENCE_GROUP_COUNT),\n\t\t\t).slice(1);\n\t\t},\n\n\t\tkeyframes(rules): { toString(): string } {\n\t\t\tif (isDev) checkSetup();\n\n\t\t\tlet identName: string | undefined;\n\n\t\t\treturn {\n\t\t\t\ttoString(): string {\n\t\t\t\t\tif (!identName) {\n\t\t\t\t\t\tlet cssText = \"\";\n\n\t\t\t\t\t\t// TODO: Replace var with const once it minifies equivalently\n\t\t\t\t\t\t// eslint-disable-next-line guard-for-in, no-restricted-syntax, no-var, vars-on-top\n\t\t\t\t\t\tfor (var time in rules) {\n\t\t\t\t\t\t\tcssText += `${time}{`;\n\n\t\t\t\t\t\t\tconst declarations = rules[time as keyof typeof rules];\n\n\t\t\t\t\t\t\t// TODO: Replace var with const once it minifies equivalently\n\t\t\t\t\t\t\t// eslint-disable-next-line guard-for-in, no-restricted-syntax, no-var, vars-on-top\n\t\t\t\t\t\t\tfor (var property in declarations) {\n\t\t\t\t\t\t\t\tconst value =\n\t\t\t\t\t\t\t\t\tdeclarations[property as keyof typeof declarations];\n\n\t\t\t\t\t\t\t\tif (value != null) {\n\t\t\t\t\t\t\t\t\tcssText += serializeDeclarationList(property, value);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tcssText += \"}\";\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tidentName = `_${hash(cssText)}`;\n\t\t\t\t\t\tif (!ruleIndexesByIdentName.has(identName)) {\n\t\t\t\t\t\t\tinjector.insert(\n\t\t\t\t\t\t\t\t`@keyframes ${identName}{${cssText}}`,\n\t\t\t\t\t\t\t\truleIndexesByIdentName.size,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\truleIndexesByIdentName.set(\n\t\t\t\t\t\t\t\tidentName,\n\t\t\t\t\t\t\t\truleIndexesByIdentName.size,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\t\treturn identName!;\n\t\t\t\t},\n\t\t\t};\n\t\t},\n\t};\n}\n","import { createInstance, OtionInstance } from \"./createInstance\";\n\nexport { createInstance };\n\nconst defaultInstance = createInstance();\ndefaultInstance.setup({});\n\n// Make sure to keep documentation comments for aliases\n/* eslint-disable prefer-destructuring */\nexport const setup: OtionInstance[\"setup\"] = defaultInstance.setup;\nexport const hydrate: OtionInstance[\"hydrate\"] = defaultInstance.hydrate;\nexport const css: OtionInstance[\"css\"] = defaultInstance.css;\nexport const keyframes: OtionInstance[\"keyframes\"] = defaultInstance.keyframes;\n/* eslint-enable prefer-destructuring */\n\nexport { CSSOMInjector, DOMInjector, NoOpInjector } from \"./injectors\";\n\nexport type { ScopedCSSRules } from \"./cssTypes\";\n"],"names":["murmur2","str","h","k","i","len","length","charCodeAt","toString","t","e","r","s","a","n","test","o","replace","hash","prefixValue","prefixProperty"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,OAAT,CAAiBC,GAAjB,EAAsB;AACpB;AACA;AACA;AACA;AACA;AACA,MAAIC,CAAC,GAAG,CAAR,CANoB;;AAQpB,MAAIC,CAAJ;AAAA,MACIC,CAAC,GAAG,CADR;AAAA,MAEIC,GAAG,GAAGJ,GAAG,CAACK,MAFd;;AAIA,SAAOD,GAAG,IAAI,CAAd,EAAiB,EAAED,CAAF,EAAKC,GAAG,IAAI,CAA7B,EAAgC;AAC9BF,IAAAA,CAAC,GAAGF,GAAG,CAACM,UAAJ,CAAeH,CAAf,IAAoB,IAApB,GAA2B,CAACH,GAAG,CAACM,UAAJ,CAAe,EAAEH,CAAjB,IAAsB,IAAvB,KAAgC,CAA3D,GAA+D,CAACH,GAAG,CAACM,UAAJ,CAAe,EAAEH,CAAjB,IAAsB,IAAvB,KAAgC,EAA/F,GAAoG,CAACH,GAAG,CAACM,UAAJ,CAAe,EAAEH,CAAjB,IAAsB,IAAvB,KAAgC,EAAxI;AACAD,IAAAA,CAAC;AACD;AACA,KAACA,CAAC,GAAG,MAAL,IAAe,UAAf,IAA6B,CAACA,CAAC,KAAK,EAAP,IAAa,MAAb,IAAuB,EAApD,CAFA;AAGAA,IAAAA,CAA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