function getSvg(rawViz) {
 const node=rawViz?._node?.querySelector('svg') || rawViz?._node?.firstChild
 if (!node || node.tagName.toLowerCase() !== 'svg') throw new Error('The chart is not ready. Check the required mapping first.')
 const clone=node.cloneNode(true)
 clone.setAttribute('xmlns','http://www.w3.org/2000/svg')
 // Built-in chart output only; do not export executable or externally linked SVG content.
 for (const e of clone.querySelectorAll('*')) {
  if (['script','foreignObject','style'].includes(e.tagName)) throw new Error('Unsafe content was found in the chart.')
  for (const a of e.attributes) {
   if (/^on/i.test(a.name) || (/href$/i.test(a.name) && a.value && !a.value.startsWith('#')) || (/^(style|fill|stroke|filter|clip-path|mask|marker.*)$/i.test(a.name) && unsafeSvgPaint(a.value))) throw new Error('External or executable SVG content is not supported.')
  }
 }
 return { text:new XMLSerializer().serializeToString(clone), width:Number(node.getAttribute('width')), height:Number(node.getAttribute('height')) }
}
