/**
* `storySvg` — sibling of {@link storyHtml} for authoring SVG-rooted stories.
*
* @module bquery/storybook
*/
import { escapeHtml } from '../security/sanitize';
import type { StoryValue } from './story-html';
import { isUnsafeHtmlMarker } from './unsafe-html';
const resolveSvgValue = (value: StoryValue): string => {
if (value === null || value === undefined) return '';
if (isUnsafeHtmlMarker(value)) {
// `unsafeHtml()` is an explicit opt-in to bypass escaping. Authors take
// responsibility for the contents of the marker.
return value.value;
}
if (Array.isArray(value)) return value.map(resolveSvgValue).join('');
if (typeof value === 'function') return resolveSvgValue(value());
return escapeHtml(String(value));
};
/**
* Tagged template literal for authoring SVG-rooted Storybook stories.
*
* @remarks
* Unlike {@link storyHtml}, `storySvg` does not run the SVG output through the
* HTML sanitizer (the HTML sanitizer blocks `