import { concat } from '@utils/concat.js' import { isParentNode } from 'extra-dom' import { isString } from '@blackglory/prelude' export function css( strings: TemplateStringsArray , ...values: string[] ): (node: Node) => Iterable export function css( selector: string ): (node: Node) => Iterable export function css(...args: | [selector: string] | [strings: TemplateStringsArray, ...values: string[]] ): (node: Node) => Iterable { if (isString(args[0])) { const [selector] = args return node => { if (isParentNode(node)) { return node.querySelectorAll(selector) } else { return [] } } } else { const [strings, ...values] = args const selector = concat(strings, values).join('') return css(selector) } }