@tracespace/renderer
Version:
Render @tracespace/plotter image trees as SVGs.
1,398 lines (1,397 loc) • 34 kB
JavaScript
import { IMAGE_SHAPE as X, LAYERED_SHAPE as Z, BoundingBox as w, OUTLINE as J, POLYGON as Q, RECTANGLE as nn, CIRCLE as ln, IMAGE_PATH as en, positionsEqual as on, LINE as tn, ARC as rn } from "@tracespace/plotter";
import { random as an } from "@tracespace/xml-id";
class x {
/**
* @constructor
* @param {Properties} property
* @param {Normal} normal
* @param {string} [space]
*/
constructor(l, t, o) {
this.property = l, this.normal = t, o && (this.space = o);
}
}
x.prototype.property = {};
x.prototype.normal = {};
x.prototype.space = null;
function z(n, l) {
const t = {}, o = {};
let r = -1;
for (; ++r < n.length; )
Object.assign(t, n[r].property), Object.assign(o, n[r].normal);
return new x(t, o, l);
}
function v(n) {
return n.toLowerCase();
}
class m {
/**
* @constructor
* @param {string} property
* @param {string} attribute
*/
constructor(l, t) {
this.property = l, this.attribute = t;
}
}
m.prototype.space = null;
m.prototype.boolean = !1;
m.prototype.booleanish = !1;
m.prototype.overloadedBoolean = !1;
m.prototype.number = !1;
m.prototype.commaSeparated = !1;
m.prototype.spaceSeparated = !1;
m.prototype.commaOrSpaceSeparated = !1;
m.prototype.mustUseProperty = !1;
m.prototype.defined = !1;
let un = 0;
const i = S(), c = S(), F = S(), e = S(), s = S(), k = S(), g = S();
function S() {
return 2 ** ++un;
}
const P = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
boolean: i,
booleanish: c,
commaOrSpaceSeparated: g,
commaSeparated: k,
number: e,
overloadedBoolean: F,
spaceSeparated: s
}, Symbol.toStringTag, { value: "Module" })), C = Object.keys(P);
class D extends m {
/**
* @constructor
* @param {string} property
* @param {string} attribute
* @param {number|null} [mask]
* @param {string} [space]
*/
constructor(l, t, o, r) {
let u = -1;
if (super(l, t), R(this, "space", r), typeof o == "number")
for (; ++u < C.length; ) {
const a = C[u];
R(this, C[u], (o & P[a]) === P[a]);
}
}
}
D.prototype.defined = !0;
function R(n, l, t) {
t && (n[l] = t);
}
const sn = {}.hasOwnProperty;
function b(n) {
const l = {}, t = {};
let o;
for (o in n.properties)
if (sn.call(n.properties, o)) {
const r = n.properties[o], u = new D(
o,
n.transform(n.attributes || {}, o),
r,
n.space
);
n.mustUseProperty && n.mustUseProperty.includes(o) && (u.mustUseProperty = !0), l[o] = u, t[v(o)] = o, t[v(u.attribute)] = o;
}
return new x(l, t, n.space);
}
const H = b({
space: "xlink",
transform(n, l) {
return "xlink:" + l.slice(5).toLowerCase();
},
properties: {
xLinkActuate: null,
xLinkArcRole: null,
xLinkHref: null,
xLinkRole: null,
xLinkShow: null,
xLinkTitle: null,
xLinkType: null
}
}), $ = b({
space: "xml",
transform(n, l) {
return "xml:" + l.slice(3).toLowerCase();
},
properties: { xmlLang: null, xmlBase: null, xmlSpace: null }
});
function j(n, l) {
return l in n ? n[l] : l;
}
function V(n, l) {
return j(n, l.toLowerCase());
}
const _ = b({
space: "xmlns",
attributes: { xmlnsxlink: "xmlns:xlink" },
transform: V,
properties: { xmlns: null, xmlnsXLink: null }
}), G = b({
transform(n, l) {
return l === "role" ? l : "aria-" + l.slice(4).toLowerCase();
},
properties: {
ariaActiveDescendant: null,
ariaAtomic: c,
ariaAutoComplete: null,
ariaBusy: c,
ariaChecked: c,
ariaColCount: e,
ariaColIndex: e,
ariaColSpan: e,
ariaControls: s,
ariaCurrent: null,
ariaDescribedBy: s,
ariaDetails: null,
ariaDisabled: c,
ariaDropEffect: s,
ariaErrorMessage: null,
ariaExpanded: c,
ariaFlowTo: s,
ariaGrabbed: c,
ariaHasPopup: null,
ariaHidden: c,
ariaInvalid: null,
ariaKeyShortcuts: null,
ariaLabel: null,
ariaLabelledBy: s,
ariaLevel: e,
ariaLive: null,
ariaModal: c,
ariaMultiLine: c,
ariaMultiSelectable: c,
ariaOrientation: null,
ariaOwns: s,
ariaPlaceholder: null,
ariaPosInSet: e,
ariaPressed: c,
ariaReadOnly: c,
ariaRelevant: null,
ariaRequired: c,
ariaRoleDescription: s,
ariaRowCount: e,
ariaRowIndex: e,
ariaRowSpan: e,
ariaSelected: c,
ariaSetSize: e,
ariaSort: null,
ariaValueMax: e,
ariaValueMin: e,
ariaValueNow: e,
ariaValueText: null,
role: null
}
}), cn = b({
space: "html",
attributes: {
acceptcharset: "accept-charset",
classname: "class",
htmlfor: "for",
httpequiv: "http-equiv"
},
transform: V,
mustUseProperty: ["checked", "multiple", "muted", "selected"],
properties: {
// Standard Properties.
abbr: null,
accept: k,
acceptCharset: s,
accessKey: s,
action: null,
allow: null,
allowFullScreen: i,
allowPaymentRequest: i,
allowUserMedia: i,
alt: null,
as: null,
async: i,
autoCapitalize: null,
autoComplete: s,
autoFocus: i,
autoPlay: i,
capture: i,
charSet: null,
checked: i,
cite: null,
className: s,
cols: e,
colSpan: null,
content: null,
contentEditable: c,
controls: i,
controlsList: s,
coords: e | k,
crossOrigin: null,
data: null,
dateTime: null,
decoding: null,
default: i,
defer: i,
dir: null,
dirName: null,
disabled: i,
download: F,
draggable: c,
encType: null,
enterKeyHint: null,
form: null,
formAction: null,
formEncType: null,
formMethod: null,
formNoValidate: i,
formTarget: null,
headers: s,
height: e,
hidden: i,
high: e,
href: null,
hrefLang: null,
htmlFor: s,
httpEquiv: s,
id: null,
imageSizes: null,
imageSrcSet: null,
inputMode: null,
integrity: null,
is: null,
isMap: i,
itemId: null,
itemProp: s,
itemRef: s,
itemScope: i,
itemType: s,
kind: null,
label: null,
lang: null,
language: null,
list: null,
loading: null,
loop: i,
low: e,
manifest: null,
max: null,
maxLength: e,
media: null,
method: null,
min: null,
minLength: e,
multiple: i,
muted: i,
name: null,
nonce: null,
noModule: i,
noValidate: i,
onAbort: null,
onAfterPrint: null,
onAuxClick: null,
onBeforeMatch: null,
onBeforePrint: null,
onBeforeUnload: null,
onBlur: null,
onCancel: null,
onCanPlay: null,
onCanPlayThrough: null,
onChange: null,
onClick: null,
onClose: null,
onContextLost: null,
onContextMenu: null,
onContextRestored: null,
onCopy: null,
onCueChange: null,
onCut: null,
onDblClick: null,
onDrag: null,
onDragEnd: null,
onDragEnter: null,
onDragExit: null,
onDragLeave: null,
onDragOver: null,
onDragStart: null,
onDrop: null,
onDurationChange: null,
onEmptied: null,
onEnded: null,
onError: null,
onFocus: null,
onFormData: null,
onHashChange: null,
onInput: null,
onInvalid: null,
onKeyDown: null,
onKeyPress: null,
onKeyUp: null,
onLanguageChange: null,
onLoad: null,
onLoadedData: null,
onLoadedMetadata: null,
onLoadEnd: null,
onLoadStart: null,
onMessage: null,
onMessageError: null,
onMouseDown: null,
onMouseEnter: null,
onMouseLeave: null,
onMouseMove: null,
onMouseOut: null,
onMouseOver: null,
onMouseUp: null,
onOffline: null,
onOnline: null,
onPageHide: null,
onPageShow: null,
onPaste: null,
onPause: null,
onPlay: null,
onPlaying: null,
onPopState: null,
onProgress: null,
onRateChange: null,
onRejectionHandled: null,
onReset: null,
onResize: null,
onScroll: null,
onScrollEnd: null,
onSecurityPolicyViolation: null,
onSeeked: null,
onSeeking: null,
onSelect: null,
onSlotChange: null,
onStalled: null,
onStorage: null,
onSubmit: null,
onSuspend: null,
onTimeUpdate: null,
onToggle: null,
onUnhandledRejection: null,
onUnload: null,
onVolumeChange: null,
onWaiting: null,
onWheel: null,
open: i,
optimum: e,
pattern: null,
ping: s,
placeholder: null,
playsInline: i,
poster: null,
preload: null,
readOnly: i,
referrerPolicy: null,
rel: s,
required: i,
reversed: i,
rows: e,
rowSpan: e,
sandbox: s,
scope: null,
scoped: i,
seamless: i,
selected: i,
shape: null,
size: e,
sizes: null,
slot: null,
span: e,
spellCheck: c,
src: null,
srcDoc: null,
srcLang: null,
srcSet: null,
start: e,
step: null,
style: null,
tabIndex: e,
target: null,
title: null,
translate: null,
type: null,
typeMustMatch: i,
useMap: null,
value: c,
width: e,
wrap: null,
// Legacy.
// See: https://html.spec.whatwg.org/#other-elements,-attributes-and-apis
align: null,
// Several. Use CSS `text-align` instead,
aLink: null,
// `<body>`. Use CSS `a:active {color}` instead
archive: s,
// `<object>`. List of URIs to archives
axis: null,
// `<td>` and `<th>`. Use `scope` on `<th>`
background: null,
// `<body>`. Use CSS `background-image` instead
bgColor: null,
// `<body>` and table elements. Use CSS `background-color` instead
border: e,
// `<table>`. Use CSS `border-width` instead,
borderColor: null,
// `<table>`. Use CSS `border-color` instead,
bottomMargin: e,
// `<body>`
cellPadding: null,
// `<table>`
cellSpacing: null,
// `<table>`
char: null,
// Several table elements. When `align=char`, sets the character to align on
charOff: null,
// Several table elements. When `char`, offsets the alignment
classId: null,
// `<object>`
clear: null,
// `<br>`. Use CSS `clear` instead
code: null,
// `<object>`
codeBase: null,
// `<object>`
codeType: null,
// `<object>`
color: null,
// `<font>` and `<hr>`. Use CSS instead
compact: i,
// Lists. Use CSS to reduce space between items instead
declare: i,
// `<object>`
event: null,
// `<script>`
face: null,
// `<font>`. Use CSS instead
frame: null,
// `<table>`
frameBorder: null,
// `<iframe>`. Use CSS `border` instead
hSpace: e,
// `<img>` and `<object>`
leftMargin: e,
// `<body>`
link: null,
// `<body>`. Use CSS `a:link {color: *}` instead
longDesc: null,
// `<frame>`, `<iframe>`, and `<img>`. Use an `<a>`
lowSrc: null,
// `<img>`. Use a `<picture>`
marginHeight: e,
// `<body>`
marginWidth: e,
// `<body>`
noResize: i,
// `<frame>`
noHref: i,
// `<area>`. Use no href instead of an explicit `nohref`
noShade: i,
// `<hr>`. Use background-color and height instead of borders
noWrap: i,
// `<td>` and `<th>`
object: null,
// `<applet>`
profile: null,
// `<head>`
prompt: null,
// `<isindex>`
rev: null,
// `<link>`
rightMargin: e,
// `<body>`
rules: null,
// `<table>`
scheme: null,
// `<meta>`
scrolling: c,
// `<frame>`. Use overflow in the child context
standby: null,
// `<object>`
summary: null,
// `<table>`
text: null,
// `<body>`. Use CSS `color` instead
topMargin: e,
// `<body>`
valueType: null,
// `<param>`
version: null,
// `<html>`. Use a doctype.
vAlign: null,
// Several. Use CSS `vertical-align` instead
vLink: null,
// `<body>`. Use CSS `a:visited {color}` instead
vSpace: e,
// `<img>` and `<object>`
// Non-standard Properties.
allowTransparency: null,
autoCorrect: null,
autoSave: null,
disablePictureInPicture: i,
disableRemotePlayback: i,
prefix: null,
property: null,
results: e,
security: null,
unselectable: null
}
}), pn = b({
space: "svg",
attributes: {
accentHeight: "accent-height",
alignmentBaseline: "alignment-baseline",
arabicForm: "arabic-form",
baselineShift: "baseline-shift",
capHeight: "cap-height",
className: "class",
clipPath: "clip-path",
clipRule: "clip-rule",
colorInterpolation: "color-interpolation",
colorInterpolationFilters: "color-interpolation-filters",
colorProfile: "color-profile",
colorRendering: "color-rendering",
crossOrigin: "crossorigin",
dataType: "datatype",
dominantBaseline: "dominant-baseline",
enableBackground: "enable-background",
fillOpacity: "fill-opacity",
fillRule: "fill-rule",
floodColor: "flood-color",
floodOpacity: "flood-opacity",
fontFamily: "font-family",
fontSize: "font-size",
fontSizeAdjust: "font-size-adjust",
fontStretch: "font-stretch",
fontStyle: "font-style",
fontVariant: "font-variant",
fontWeight: "font-weight",
glyphName: "glyph-name",
glyphOrientationHorizontal: "glyph-orientation-horizontal",
glyphOrientationVertical: "glyph-orientation-vertical",
hrefLang: "hreflang",
horizAdvX: "horiz-adv-x",
horizOriginX: "horiz-origin-x",
horizOriginY: "horiz-origin-y",
imageRendering: "image-rendering",
letterSpacing: "letter-spacing",
lightingColor: "lighting-color",
markerEnd: "marker-end",
markerMid: "marker-mid",
markerStart: "marker-start",
navDown: "nav-down",
navDownLeft: "nav-down-left",
navDownRight: "nav-down-right",
navLeft: "nav-left",
navNext: "nav-next",
navPrev: "nav-prev",
navRight: "nav-right",
navUp: "nav-up",
navUpLeft: "nav-up-left",
navUpRight: "nav-up-right",
onAbort: "onabort",
onActivate: "onactivate",
onAfterPrint: "onafterprint",
onBeforePrint: "onbeforeprint",
onBegin: "onbegin",
onCancel: "oncancel",
onCanPlay: "oncanplay",
onCanPlayThrough: "oncanplaythrough",
onChange: "onchange",
onClick: "onclick",
onClose: "onclose",
onCopy: "oncopy",
onCueChange: "oncuechange",
onCut: "oncut",
onDblClick: "ondblclick",
onDrag: "ondrag",
onDragEnd: "ondragend",
onDragEnter: "ondragenter",
onDragExit: "ondragexit",
onDragLeave: "ondragleave",
onDragOver: "ondragover",
onDragStart: "ondragstart",
onDrop: "ondrop",
onDurationChange: "ondurationchange",
onEmptied: "onemptied",
onEnd: "onend",
onEnded: "onended",
onError: "onerror",
onFocus: "onfocus",
onFocusIn: "onfocusin",
onFocusOut: "onfocusout",
onHashChange: "onhashchange",
onInput: "oninput",
onInvalid: "oninvalid",
onKeyDown: "onkeydown",
onKeyPress: "onkeypress",
onKeyUp: "onkeyup",
onLoad: "onload",
onLoadedData: "onloadeddata",
onLoadedMetadata: "onloadedmetadata",
onLoadStart: "onloadstart",
onMessage: "onmessage",
onMouseDown: "onmousedown",
onMouseEnter: "onmouseenter",
onMouseLeave: "onmouseleave",
onMouseMove: "onmousemove",
onMouseOut: "onmouseout",
onMouseOver: "onmouseover",
onMouseUp: "onmouseup",
onMouseWheel: "onmousewheel",
onOffline: "onoffline",
onOnline: "ononline",
onPageHide: "onpagehide",
onPageShow: "onpageshow",
onPaste: "onpaste",
onPause: "onpause",
onPlay: "onplay",
onPlaying: "onplaying",
onPopState: "onpopstate",
onProgress: "onprogress",
onRateChange: "onratechange",
onRepeat: "onrepeat",
onReset: "onreset",
onResize: "onresize",
onScroll: "onscroll",
onSeeked: "onseeked",
onSeeking: "onseeking",
onSelect: "onselect",
onShow: "onshow",
onStalled: "onstalled",
onStorage: "onstorage",
onSubmit: "onsubmit",
onSuspend: "onsuspend",
onTimeUpdate: "ontimeupdate",
onToggle: "ontoggle",
onUnload: "onunload",
onVolumeChange: "onvolumechange",
onWaiting: "onwaiting",
onZoom: "onzoom",
overlinePosition: "overline-position",
overlineThickness: "overline-thickness",
paintOrder: "paint-order",
panose1: "panose-1",
pointerEvents: "pointer-events",
referrerPolicy: "referrerpolicy",
renderingIntent: "rendering-intent",
shapeRendering: "shape-rendering",
stopColor: "stop-color",
stopOpacity: "stop-opacity",
strikethroughPosition: "strikethrough-position",
strikethroughThickness: "strikethrough-thickness",
strokeDashArray: "stroke-dasharray",
strokeDashOffset: "stroke-dashoffset",
strokeLineCap: "stroke-linecap",
strokeLineJoin: "stroke-linejoin",
strokeMiterLimit: "stroke-miterlimit",
strokeOpacity: "stroke-opacity",
strokeWidth: "stroke-width",
tabIndex: "tabindex",
textAnchor: "text-anchor",
textDecoration: "text-decoration",
textRendering: "text-rendering",
typeOf: "typeof",
underlinePosition: "underline-position",
underlineThickness: "underline-thickness",
unicodeBidi: "unicode-bidi",
unicodeRange: "unicode-range",
unitsPerEm: "units-per-em",
vAlphabetic: "v-alphabetic",
vHanging: "v-hanging",
vIdeographic: "v-ideographic",
vMathematical: "v-mathematical",
vectorEffect: "vector-effect",
vertAdvY: "vert-adv-y",
vertOriginX: "vert-origin-x",
vertOriginY: "vert-origin-y",
wordSpacing: "word-spacing",
writingMode: "writing-mode",
xHeight: "x-height",
// These were camelcased in Tiny. Now lowercased in SVG 2
playbackOrder: "playbackorder",
timelineBegin: "timelinebegin"
},
transform: j,
properties: {
about: g,
accentHeight: e,
accumulate: null,
additive: null,
alignmentBaseline: null,
alphabetic: e,
amplitude: e,
arabicForm: null,
ascent: e,
attributeName: null,
attributeType: null,
azimuth: e,
bandwidth: null,
baselineShift: null,
baseFrequency: null,
baseProfile: null,
bbox: null,
begin: null,
bias: e,
by: null,
calcMode: null,
capHeight: e,
className: s,
clip: null,
clipPath: null,
clipPathUnits: null,
clipRule: null,
color: null,
colorInterpolation: null,
colorInterpolationFilters: null,
colorProfile: null,
colorRendering: null,
content: null,
contentScriptType: null,
contentStyleType: null,
crossOrigin: null,
cursor: null,
cx: null,
cy: null,
d: null,
dataType: null,
defaultAction: null,
descent: e,
diffuseConstant: e,
direction: null,
display: null,
dur: null,
divisor: e,
dominantBaseline: null,
download: i,
dx: null,
dy: null,
edgeMode: null,
editable: null,
elevation: e,
enableBackground: null,
end: null,
event: null,
exponent: e,
externalResourcesRequired: null,
fill: null,
fillOpacity: e,
fillRule: null,
filter: null,
filterRes: null,
filterUnits: null,
floodColor: null,
floodOpacity: null,
focusable: null,
focusHighlight: null,
fontFamily: null,
fontSize: null,
fontSizeAdjust: null,
fontStretch: null,
fontStyle: null,
fontVariant: null,
fontWeight: null,
format: null,
fr: null,
from: null,
fx: null,
fy: null,
g1: k,
g2: k,
glyphName: k,
glyphOrientationHorizontal: null,
glyphOrientationVertical: null,
glyphRef: null,
gradientTransform: null,
gradientUnits: null,
handler: null,
hanging: e,
hatchContentUnits: null,
hatchUnits: null,
height: null,
href: null,
hrefLang: null,
horizAdvX: e,
horizOriginX: e,
horizOriginY: e,
id: null,
ideographic: e,
imageRendering: null,
initialVisibility: null,
in: null,
in2: null,
intercept: e,
k: e,
k1: e,
k2: e,
k3: e,
k4: e,
kernelMatrix: g,
kernelUnitLength: null,
keyPoints: null,
// SEMI_COLON_SEPARATED
keySplines: null,
// SEMI_COLON_SEPARATED
keyTimes: null,
// SEMI_COLON_SEPARATED
kerning: null,
lang: null,
lengthAdjust: null,
letterSpacing: null,
lightingColor: null,
limitingConeAngle: e,
local: null,
markerEnd: null,
markerMid: null,
markerStart: null,
markerHeight: null,
markerUnits: null,
markerWidth: null,
mask: null,
maskContentUnits: null,
maskUnits: null,
mathematical: null,
max: null,
media: null,
mediaCharacterEncoding: null,
mediaContentEncodings: null,
mediaSize: e,
mediaTime: null,
method: null,
min: null,
mode: null,
name: null,
navDown: null,
navDownLeft: null,
navDownRight: null,
navLeft: null,
navNext: null,
navPrev: null,
navRight: null,
navUp: null,
navUpLeft: null,
navUpRight: null,
numOctaves: null,
observer: null,
offset: null,
onAbort: null,
onActivate: null,
onAfterPrint: null,
onBeforePrint: null,
onBegin: null,
onCancel: null,
onCanPlay: null,
onCanPlayThrough: null,
onChange: null,
onClick: null,
onClose: null,
onCopy: null,
onCueChange: null,
onCut: null,
onDblClick: null,
onDrag: null,
onDragEnd: null,
onDragEnter: null,
onDragExit: null,
onDragLeave: null,
onDragOver: null,
onDragStart: null,
onDrop: null,
onDurationChange: null,
onEmptied: null,
onEnd: null,
onEnded: null,
onError: null,
onFocus: null,
onFocusIn: null,
onFocusOut: null,
onHashChange: null,
onInput: null,
onInvalid: null,
onKeyDown: null,
onKeyPress: null,
onKeyUp: null,
onLoad: null,
onLoadedData: null,
onLoadedMetadata: null,
onLoadStart: null,
onMessage: null,
onMouseDown: null,
onMouseEnter: null,
onMouseLeave: null,
onMouseMove: null,
onMouseOut: null,
onMouseOver: null,
onMouseUp: null,
onMouseWheel: null,
onOffline: null,
onOnline: null,
onPageHide: null,
onPageShow: null,
onPaste: null,
onPause: null,
onPlay: null,
onPlaying: null,
onPopState: null,
onProgress: null,
onRateChange: null,
onRepeat: null,
onReset: null,
onResize: null,
onScroll: null,
onSeeked: null,
onSeeking: null,
onSelect: null,
onShow: null,
onStalled: null,
onStorage: null,
onSubmit: null,
onSuspend: null,
onTimeUpdate: null,
onToggle: null,
onUnload: null,
onVolumeChange: null,
onWaiting: null,
onZoom: null,
opacity: null,
operator: null,
order: null,
orient: null,
orientation: null,
origin: null,
overflow: null,
overlay: null,
overlinePosition: e,
overlineThickness: e,
paintOrder: null,
panose1: null,
path: null,
pathLength: e,
patternContentUnits: null,
patternTransform: null,
patternUnits: null,
phase: null,
ping: s,
pitch: null,
playbackOrder: null,
pointerEvents: null,
points: null,
pointsAtX: e,
pointsAtY: e,
pointsAtZ: e,
preserveAlpha: null,
preserveAspectRatio: null,
primitiveUnits: null,
propagate: null,
property: g,
r: null,
radius: null,
referrerPolicy: null,
refX: null,
refY: null,
rel: g,
rev: g,
renderingIntent: null,
repeatCount: null,
repeatDur: null,
requiredExtensions: g,
requiredFeatures: g,
requiredFonts: g,
requiredFormats: g,
resource: null,
restart: null,
result: null,
rotate: null,
rx: null,
ry: null,
scale: null,
seed: null,
shapeRendering: null,
side: null,
slope: null,
snapshotTime: null,
specularConstant: e,
specularExponent: e,
spreadMethod: null,
spacing: null,
startOffset: null,
stdDeviation: null,
stemh: null,
stemv: null,
stitchTiles: null,
stopColor: null,
stopOpacity: null,
strikethroughPosition: e,
strikethroughThickness: e,
string: null,
stroke: null,
strokeDashArray: g,
strokeDashOffset: null,
strokeLineCap: null,
strokeLineJoin: null,
strokeMiterLimit: e,
strokeOpacity: e,
strokeWidth: null,
style: null,
surfaceScale: e,
syncBehavior: null,
syncBehaviorDefault: null,
syncMaster: null,
syncTolerance: null,
syncToleranceDefault: null,
systemLanguage: g,
tabIndex: e,
tableValues: null,
target: null,
targetX: e,
targetY: e,
textAnchor: null,
textDecoration: null,
textRendering: null,
textLength: null,
timelineBegin: null,
title: null,
transformBehavior: null,
type: null,
typeOf: g,
to: null,
transform: null,
u1: null,
u2: null,
underlinePosition: e,
underlineThickness: e,
unicode: null,
unicodeBidi: null,
unicodeRange: null,
unitsPerEm: e,
values: null,
vAlphabetic: e,
vMathematical: e,
vectorEffect: null,
vHanging: e,
vIdeographic: e,
version: null,
vertAdvY: e,
vertOriginX: e,
vertOriginY: e,
viewBox: null,
viewTarget: null,
visibility: null,
width: null,
widths: null,
wordSpacing: null,
writingMode: null,
x: null,
x1: null,
x2: null,
xChannelSelector: null,
xHeight: e,
y: null,
y1: null,
y2: null,
yChannelSelector: null,
z: null,
zoomAndPan: null
}
}), dn = /^data[-\w.:]+$/i, T = /-[a-z]/g, gn = /[A-Z]/g;
function hn(n, l) {
const t = v(l);
let o = l, r = m;
if (t in n.normal)
return n.property[n.normal[t]];
if (t.length > 4 && t.slice(0, 4) === "data" && dn.test(l)) {
if (l.charAt(4) === "-") {
const u = l.slice(5).replace(T, mn);
o = "data" + u.charAt(0).toUpperCase() + u.slice(1);
} else {
const u = l.slice(4);
if (!T.test(u)) {
let a = u.replace(gn, fn);
a.charAt(0) !== "-" && (a = "-" + a), l = "data" + a;
}
}
r = D;
}
return new r(o, l);
}
function fn(n) {
return "-" + n.toLowerCase();
}
function mn(n) {
return n.charAt(1).toUpperCase();
}
z([$, H, _, G, cn], "html");
const yn = z([$, H, _, G, pn], "svg"), I = /[#.]/g;
function Sn(n, l) {
const t = n || "", o = {};
let r = 0, u, a;
for (; r < t.length; ) {
I.lastIndex = r;
const d = I.exec(t), h = t.slice(r, d ? d.index : t.length);
h && (u ? u === "#" ? o.id = h : Array.isArray(o.className) ? o.className.push(h) : o.className = [h] : a = h, r += h.length), d && (u = d[0], r++);
}
return {
type: "element",
// @ts-expect-error: fine.
tagName: a || l || "div",
properties: o,
children: []
};
}
function U(n) {
const l = String(n || "").trim();
return l ? l.split(/[ \t\n\r\f]+/g) : [];
}
function N(n) {
const l = [], t = String(n || "");
let o = t.indexOf(","), r = 0, u = !1;
for (; !u; ) {
o === -1 && (o = t.length, u = !0);
const a = t.slice(r, o).trim();
(a || !u) && l.push(a), r = o + 1, o = t.indexOf(",", r);
}
return l;
}
const kn = /* @__PURE__ */ new Set(["menu", "submit", "reset", "button"]), M = {}.hasOwnProperty;
function bn(n, l, t) {
const o = t && wn(t);
return (
/**
* @type {{
* (): Root
* (selector: null | undefined, ...children: Array<HChild>): Root
* (selector: string, properties?: HProperties, ...children: Array<HChild>): Element
* (selector: string, ...children: Array<HChild>): Element
* }}
*/
/**
* Hyperscript compatible DSL for creating virtual hast trees.
*
* @param {string | null} [selector]
* @param {HProperties | HChild} [properties]
* @param {Array<HChild>} children
* @returns {HResult}
*/
function(u, a, ...d) {
let h = -1, p;
if (u == null)
p = { type: "root", children: [] }, d.unshift(a);
else if (p = Sn(u, l), p.tagName = p.tagName.toLowerCase(), o && M.call(o, p.tagName) && (p.tagName = o[p.tagName]), vn(a, p.tagName)) {
let y;
for (y in a)
M.call(a, y) && xn(n, p.properties, y, a[y]);
} else
d.unshift(a);
for (; ++h < d.length; )
L(p.children, d[h]);
return p.type === "element" && p.tagName === "template" && (p.content = { type: "root", children: p.children }, p.children = []), p;
}
);
}
function vn(n, l) {
return n == null || typeof n != "object" || Array.isArray(n) ? !1 : l === "input" || !n.type || typeof n.type != "string" ? !0 : "children" in n && Array.isArray(n.children) ? !1 : l === "button" ? kn.has(n.type.toLowerCase()) : !("value" in n);
}
function xn(n, l, t, o) {
const r = hn(n, t);
let u = -1, a;
if (o != null) {
if (typeof o == "number") {
if (Number.isNaN(o))
return;
a = o;
} else
typeof o == "boolean" ? a = o : typeof o == "string" ? r.spaceSeparated ? a = U(o) : r.commaSeparated ? a = N(o) : r.commaOrSpaceSeparated ? a = U(N(o).join(" ")) : a = B(r, r.property, o) : Array.isArray(o) ? a = o.concat() : a = r.property === "style" ? Cn(o) : String(o);
if (Array.isArray(a)) {
const d = [];
for (; ++u < a.length; )
d[u] = B(r, r.property, a[u]);
a = d;
}
r.property === "className" && Array.isArray(l.className) && (a = l.className.concat(a)), l[r.property] = a;
}
}
function L(n, l) {
let t = -1;
if (l != null)
if (typeof l == "string" || typeof l == "number")
n.push({ type: "text", value: String(l) });
else if (Array.isArray(l))
for (; ++t < l.length; )
L(n, l[t]);
else if (typeof l == "object" && "type" in l)
l.type === "root" ? L(n, l.children) : n.push(l);
else
throw new Error("Expected node, nodes, or string, got `" + l + "`");
}
function B(n, l, t) {
if (typeof t == "string") {
if (n.number && t && !Number.isNaN(Number(t)))
return Number(t);
if ((n.boolean || n.overloadedBoolean) && (t === "" || v(t) === v(l)))
return !0;
}
return t;
}
function Cn(n) {
const l = [];
let t;
for (t in n)
M.call(n, t) && l.push([t, n[t]].join(": "));
return l.join("; ");
}
function wn(n) {
const l = {};
let t = -1;
for (; ++t < n.length; )
l[n[t].toLowerCase()] = n[t];
return l;
}
const Pn = [
"altGlyph",
"altGlyphDef",
"altGlyphItem",
"animateColor",
"animateMotion",
"animateTransform",
"clipPath",
"feBlend",
"feColorMatrix",
"feComponentTransfer",
"feComposite",
"feConvolveMatrix",
"feDiffuseLighting",
"feDisplacementMap",
"feDistantLight",
"feDropShadow",
"feFlood",
"feFuncA",
"feFuncB",
"feFuncG",
"feFuncR",
"feGaussianBlur",
"feImage",
"feMerge",
"feMergeNode",
"feMorphology",
"feOffset",
"fePointLight",
"feSpecularLighting",
"feSpotLight",
"feTile",
"feTurbulence",
"foreignObject",
"glyphRef",
"linearGradient",
"radialGradient",
"solidColor",
"textArea",
"textPath"
], f = bn(yn, "g", Pn);
function W(n) {
return n.type === X ? Mn(n) : Ln(n);
}
function Mn(n) {
const { shape: l } = n;
return O(l);
}
function O(n) {
switch (n.type) {
case ln: {
const { cx: l, cy: t, r: o } = n;
return f("circle", { cx: l, cy: -t, r: o });
}
case nn: {
const { x: l, y: t, xSize: o, ySize: r, r: u } = n;
return f("rect", {
x: l,
y: -t - r,
width: o,
height: r,
rx: u,
ry: u
});
}
case Q: {
const l = n.points.map(([t, o]) => `${t},${-o}`).join(" ");
return f("polygon", { points: l });
}
case J:
return f("path", { d: q(n.segments) });
case Z: {
const l = w.fromShape(n), t = an(), o = [];
let r = [];
for (const [u, a] of n.shapes.entries())
if (a.erase && !w.isEmpty(l)) {
const d = `${t}__${u}`;
o.push(f("clipPath", { id: d }, [O(a)])), r = [f("g", { clipPath: `url(#${d})` }, r)];
} else
r.push(O(a));
return o.length > 0 && r.unshift(f("defs", o)), r.length === 1 ? r[0] : f("g", r);
}
default:
return f("g");
}
}
function Ln(n) {
const l = q(n.segments), t = n.type === en ? { strokeWidth: n.width, fill: "none" } : {};
return f("path", { ...t, d: l });
}
function q(n) {
const l = [];
for (const [t, o] of n.entries()) {
const r = n[t - 1], { start: u, end: a } = o;
if ((!r || !on(r.end, u)) && l.push(`M${u[0]} ${-u[1]}`), o.type === tn)
l.push(`L${a[0]} ${-a[1]}`);
else if (o.type === rn) {
const d = o.end[2] - o.start[2], h = Math.abs(d), { center: p, radius: y } = o, A = d < 0 ? "1" : "0";
let E = h <= Math.PI ? "0" : "1";
if (h === 2 * Math.PI) {
const [K, Y] = [2 * p[0] - a[0], -(2 * p[1] - a[1])];
E = "0", l.push(`A${y} ${y} 0 0 ${A} ${K} ${Y}`);
}
l.push(
`A${y} ${y} 0 ${E} ${A} ${a[0]} ${-a[1]}`
);
}
}
return l.join("");
}
const On = {
version: "1.1",
xmlns: "http://www.w3.org/2000/svg",
"xmlns:xlink": "http://www.w3.org/1999/xlink"
}, Dn = {
"stroke-linecap": "round",
"stroke-linejoin": "round",
"stroke-width": "0",
"fill-rule": "evenodd",
"clip-rule": "evenodd",
fill: "currentColor",
stroke: "currentColor"
};
function Tn(n, l) {
const { units: t, size: o, children: r } = n;
return l = l ?? An(o), f(
"svg",
{
...On,
...Dn,
viewBox: l.join(" "),
width: `${l[2]}${t}`,
height: `${l[3]}${t}`
},
r.map(W)
);
}
function In(n) {
return f("g", {}, n.children.map(W));
}
function An(n) {
return w.isEmpty(n) ? [0, 0, 0, 0] : [n[0], -n[3], n[2] - n[0], n[3] - n[1]];
}
export {
Dn as BASE_IMAGE_PROPS,
On as BASE_SVG_PROPS,
Tn as render,
In as renderFragment,
W as renderGraphic,
An as sizeToViewBox
};
//# sourceMappingURL=tracespace-renderer.js.map