/// import type { SVGAttributes } from "../../types"; import { type DocumentNode, type Node, parse, render } from "ultrahtml"; const EMPTY_STRING_ERR = "`svgSource` must have content"; const MUST_START_WITH_SVG = "`svgSource` must begin with ` { if (!svgSource) { throw new Error(EMPTY_STRING_ERR); } if (!svgSource.trimStart().toLowerCase().startsWith(" type === 1 && /svg/i.test(name), ); const mergedAttributes = Object.fromEntries( Object.entries({ ...firstSVGNode.attributes, ...attributeOverrides, }).filter(([, value]) => !!value), ); const updatedSVG = { ...firstSVGNode, attributes: mergedAttributes, }; return render(updatedSVG); }