@svgsketch/cli 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +36 -36
- package/package.json +46 -41
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -14
package/README.md
CHANGED
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
# @svgsketch/cli
|
|
2
|
-
|
|
3
|
-
Command-line interface for working with SVGSketch `.svgs` documents.
|
|
4
|
-
|
|
5
|
-
## Install
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
npm install -g @svgsketch/cli
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
## Commands
|
|
12
|
-
|
|
13
|
-
```bash
|
|
14
|
-
svgsketch validate <input>
|
|
15
|
-
svgsketch render <input> -o <output.svg>
|
|
16
|
-
svgsketch info <input>
|
|
17
|
-
svgsketch vars <input>
|
|
18
|
-
svgsketch codegen <input> -f <svg|react|vue|d3|css>
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
## Examples
|
|
22
|
-
|
|
23
|
-
```bash
|
|
24
|
-
# Validate a document
|
|
25
|
-
svgsketch validate design.svgs
|
|
26
|
-
|
|
27
|
-
# Render to SVG
|
|
28
|
-
svgsketch render design.svgs -o out.svg --background white
|
|
29
|
-
|
|
30
|
-
# Generate React component
|
|
31
|
-
svgsketch codegen icon.svgs -f react -o Icon.tsx --name Icon --typescript
|
|
32
|
-
|
|
33
|
-
# Generate CSS+SVG markup
|
|
34
|
-
svgsketch codegen design.svgs -f css -o design-snippet.svg
|
|
35
|
-
```
|
|
36
|
-
|
|
1
|
+
# @svgsketch/cli
|
|
2
|
+
|
|
3
|
+
Command-line interface for working with SVGSketch `.svgs` documents.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install -g @svgsketch/cli
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Commands
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
svgsketch validate <input>
|
|
15
|
+
svgsketch render <input> -o <output.svg>
|
|
16
|
+
svgsketch info <input>
|
|
17
|
+
svgsketch vars <input>
|
|
18
|
+
svgsketch codegen <input> -f <svg|react|vue|d3|css>
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Examples
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
# Validate a document
|
|
25
|
+
svgsketch validate design.svgs
|
|
26
|
+
|
|
27
|
+
# Render to SVG
|
|
28
|
+
svgsketch render design.svgs -o out.svg --background white
|
|
29
|
+
|
|
30
|
+
# Generate React component
|
|
31
|
+
svgsketch codegen icon.svgs -f react -o Icon.tsx --name Icon --typescript
|
|
32
|
+
|
|
33
|
+
# Generate CSS+SVG markup
|
|
34
|
+
svgsketch codegen design.svgs -f css -o design-snippet.svg
|
|
35
|
+
```
|
|
36
|
+
|
package/package.json
CHANGED
|
@@ -1,41 +1,46 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@svgsketch/cli",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"private": false,
|
|
5
|
-
"description": "CLI tool for rendering and validating SVGSketch documents",
|
|
6
|
-
"main": "dist/index.js",
|
|
7
|
-
"types": "dist/index.d.ts",
|
|
8
|
-
"license": "MIT",
|
|
9
|
-
"homepage": "https://docs.svgsketch.com",
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
"
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
"
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
}
|
|
41
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@svgsketch/cli",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"private": false,
|
|
5
|
+
"description": "CLI tool for rendering and validating SVGSketch documents",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"license": "MIT",
|
|
9
|
+
"homepage": "https://docs.svgsketch.com",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "git+https://github.com/SVGSketch/SVGSketch.git",
|
|
13
|
+
"directory": "packages/cli"
|
|
14
|
+
},
|
|
15
|
+
"bin": {
|
|
16
|
+
"svgsketch": "dist/index.js"
|
|
17
|
+
},
|
|
18
|
+
"keywords": [
|
|
19
|
+
"svg",
|
|
20
|
+
"cli",
|
|
21
|
+
"render",
|
|
22
|
+
"headless",
|
|
23
|
+
"svgsketch"
|
|
24
|
+
],
|
|
25
|
+
"files": [
|
|
26
|
+
"dist",
|
|
27
|
+
"README.md"
|
|
28
|
+
],
|
|
29
|
+
"scripts": {
|
|
30
|
+
"prebuild": "npm run build -w @svgsketch/core",
|
|
31
|
+
"build": "tsup --minify",
|
|
32
|
+
"check": "tsc --noEmit",
|
|
33
|
+
"pretest": "npm run build",
|
|
34
|
+
"test": "vitest run",
|
|
35
|
+
"test:watch": "vitest"
|
|
36
|
+
},
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"@svgsketch/core": "*",
|
|
39
|
+
"commander": "^13.1.0"
|
|
40
|
+
},
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"tsup": "^8.5.0",
|
|
43
|
+
"typescript": "^5.9.3",
|
|
44
|
+
"vitest": "^4.0.18"
|
|
45
|
+
}
|
|
46
|
+
}
|
package/dist/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
package/dist/index.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
"use strict";var Ot=Object.create;var ft=Object.defineProperty;var Et=Object.getOwnPropertyDescriptor;var It=Object.getOwnPropertyNames;var Lt=Object.getPrototypeOf,Gt=Object.prototype.hasOwnProperty;var Vt=(s,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of It(t))!Gt.call(s,i)&&i!==e&&ft(s,i,{get:()=>t[i],enumerable:!(n=Et(t,i))||n.enumerable});return s};var gt=(s,t,e)=>(e=s!=null?Ot(Lt(s)):{},Vt(t||!s||!s.__esModule?ft(e,"default",{value:s,enumerable:!0}):e,s));var U=require("commander"),L=require("fs/promises"),j=require("path");var jt=(s=>(s.LINEAR="linear",s.EASE="ease",s.EASE_IN="ease-in",s.EASE_OUT="ease-out",s.EASE_IN_OUT="ease-in-out",s.EASE_IN_QUAD="ease-in-quad",s.EASE_OUT_QUAD="ease-out-quad",s.EASE_IN_OUT_QUAD="ease-in-out-quad",s.EASE_IN_CUBIC="ease-in-cubic",s.EASE_OUT_CUBIC="ease-out-cubic",s.EASE_IN_OUT_CUBIC="ease-in-out-cubic",s.EASE_IN_QUART="ease-in-quart",s.EASE_OUT_QUART="ease-out-quart",s.EASE_IN_OUT_QUART="ease-in-out-quart",s.EASE_IN_SINE="ease-in-sine",s.EASE_OUT_SINE="ease-out-sine",s.EASE_IN_OUT_SINE="ease-in-out-sine",s.EASE_IN_BACK="ease-in-back",s.EASE_OUT_BACK="ease-out-back",s.EASE_IN_OUT_BACK="ease-in-out-back",s))(jt||{}),Nt={linear:null,ease:[.25,.1,.25,1],"ease-in":[.42,0,1,1],"ease-out":[0,0,.58,1],"ease-in-out":[.42,0,.58,1],"ease-in-quad":[.55,.085,.68,.53],"ease-out-quad":[.25,.46,.45,.94],"ease-in-out-quad":[.455,.03,.515,.955],"ease-in-cubic":[.55,.055,.675,.19],"ease-out-cubic":[.215,.61,.355,1],"ease-in-out-cubic":[.645,.045,.355,1],"ease-in-quart":[.895,.03,.685,.22],"ease-out-quart":[.165,.84,.44,1],"ease-in-out-quart":[.77,0,.175,1],"ease-in-sine":[.47,0,.745,.715],"ease-out-sine":[.39,.575,.565,1],"ease-in-out-sine":[.445,.05,.55,.95],"ease-in-back":[.6,-.28,.735,.045],"ease-out-back":[.175,.885,.32,1.275],"ease-in-out-back":[.68,-.55,.265,1.55]};var Bt=(s=>(s.LINEAR="linear",s.QUADRATIC="quadratic",s.CUBIC="cubic",s.CATMULL_ROM="catmull-rom",s.ARC="arc",s.BASIS="basis",s.MIXED="mixed",s))(Bt||{}),Dt=(s=>(s.SMOOTH="smooth",s.CORNER="corner",s.SYMMETRIC="symmetric",s))(Dt||{}),O=1;function Ft(s){let t=JSON.parse(JSON.stringify(s)),e=t.schemaVersion??1;if(e>=O)return t.schemaVersion=t.schemaVersion??O,t;for(;e<O;)console.warn(`[svgsketch/core] No migration path from schema version ${e}`),e=O,e++;return t.schemaVersion=O,t}var Ut=new Set(["circle","rectangle","square","ellipse","text","triangle","ngon","star","cross","ring","spiral","gear","arrow","line","spline","polyline","image"]);function it(s){let t=[],e=[];if(s==null||typeof s!="object")return t.push({path:"",message:"Snapshot must be a non-null object",severity:"error"}),{valid:!1,errors:t,warnings:e};let n=s;if(n.schemaVersion!==void 0&&(typeof n.schemaVersion!="number"||!Number.isInteger(n.schemaVersion)?t.push({path:"schemaVersion",message:"schemaVersion must be an integer",severity:"error"}):n.schemaVersion>O&&e.push({path:"schemaVersion",message:`schemaVersion ${n.schemaVersion} is newer than supported (${O})`,severity:"warning"})),!Array.isArray(n.shapes))t.push({path:"shapes",message:"shapes must be an array",severity:"error"});else{let i=new Set;n.shapes.forEach((a,o)=>{zt(a,`shapes[${o}]`,t,e,i)})}if(!Array.isArray(n.viewboxes))t.push({path:"viewboxes",message:"viewboxes must be an array",severity:"error"});else{let i=new Set;n.viewboxes.forEach((a,o)=>{Xt(a,`viewboxes[${o}]`,t,e,i)})}return n.guides!==void 0&&(Array.isArray(n.guides)?n.guides.forEach((i,a)=>{qt(i,`guides[${a}]`,t,e)}):t.push({path:"guides",message:"guides must be an array",severity:"error"})),n.groups!==void 0&&(Array.isArray(n.groups)?n.groups.forEach((i,a)=>{Yt(i,`groups[${a}]`,t)}):t.push({path:"groups",message:"groups must be an array",severity:"error"})),n.clipMaskGroups!==void 0&&(Array.isArray(n.clipMaskGroups)?n.clipMaskGroups.forEach((i,a)=>{Zt(i,`clipMaskGroups[${a}]`,t)}):t.push({path:"clipMaskGroups",message:"clipMaskGroups must be an array",severity:"error"})),n.measurements!==void 0&&(Array.isArray(n.measurements)||t.push({path:"measurements",message:"measurements must be an array",severity:"error"})),{valid:t.length===0,errors:t,warnings:e}}function zt(s,t,e,n,i){if(s===null||typeof s!="object"){e.push({path:t,message:"Shape must be a non-null object",severity:"error"});return}let a=s;typeof a.id!="string"||a.id.length===0?e.push({path:`${t}.id`,message:"Shape id must be a non-empty string",severity:"error"}):i.has(a.id)?e.push({path:`${t}.id`,message:`Duplicate shape id: "${a.id}"`,severity:"error"}):i.add(a.id),typeof a.type!="string"?e.push({path:`${t}.type`,message:"Shape type must be a string",severity:"error"}):Ut.has(a.type)||n.push({path:`${t}.type`,message:`Unknown shape type: "${a.type}"`,severity:"warning"}),a.state===void 0||a.state===null||typeof a.state!="object"?e.push({path:`${t}.state`,message:"Shape state must be a non-null object",severity:"error"}):Wt(a.state,`${t}.state`,e,n)}function Wt(s,t,e,n){let i=["x","y","width","height","radius","rx","ry","rotation","fontSize"];for(let o of i)s[o]!==void 0&&(typeof s[o]!="number"||!isFinite(s[o]))&&e.push({path:`${t}.${o}`,message:`${o} must be a finite number`,severity:"error"});let a=["width","height","radius","fontSize"];for(let o of a){let l=s[o];typeof l=="number"&&l<=0&&n.push({path:`${t}.${o}`,message:`${o} should be positive (got ${l})`,severity:"warning"})}}function Xt(s,t,e,n,i){if(s===null||typeof s!="object"){e.push({path:t,message:"Viewbox must be a non-null object",severity:"error"});return}let a=s;typeof a.id!="string"||a.id.length===0?e.push({path:`${t}.id`,message:"Viewbox id must be a non-empty string",severity:"error"}):i.has(a.id)?e.push({path:`${t}.id`,message:`Duplicate viewbox id: "${a.id}"`,severity:"error"}):i.add(a.id);for(let o of["x","y","width","height"])(typeof a[o]!="number"||!isFinite(a[o]))&&e.push({path:`${t}.${o}`,message:`${o} must be a finite number`,severity:"error"});typeof a.width=="number"&&a.width<=0&&e.push({path:`${t}.width`,message:"Viewbox width must be positive",severity:"error"}),typeof a.height=="number"&&a.height<=0&&e.push({path:`${t}.height`,message:"Viewbox height must be positive",severity:"error"})}function qt(s,t,e,n){if(s===null||typeof s!="object"){e.push({path:t,message:"Guide must be a non-null object",severity:"error"});return}let i=s;(typeof i.id!="string"||i.id.length===0)&&e.push({path:`${t}.id`,message:"Guide id must be a non-empty string",severity:"error"}),i.orientation!=="horizontal"&&i.orientation!=="vertical"&&e.push({path:`${t}.orientation`,message:'Guide orientation must be "horizontal" or "vertical"',severity:"error"}),(typeof i.position!="number"||!isFinite(i.position))&&e.push({path:`${t}.position`,message:"Guide position must be a finite number",severity:"error"})}function Yt(s,t,e){if(s===null||typeof s!="object"){e.push({path:t,message:"Group must be a non-null object",severity:"error"});return}let n=s;(typeof n.id!="string"||n.id.length===0)&&e.push({path:`${t}.id`,message:"Group id must be a non-empty string",severity:"error"}),n.parentId!==null&&typeof n.parentId!="string"&&e.push({path:`${t}.parentId`,message:"Group parentId must be a string or null",severity:"error"})}function Zt(s,t,e){if(s===null||typeof s!="object"){e.push({path:t,message:"ClipMaskGroup must be a non-null object",severity:"error"});return}let n=s;(typeof n.id!="string"||n.id.length===0)&&e.push({path:`${t}.id`,message:"ClipMaskGroup id must be a non-empty string",severity:"error"}),n.type!=="clip"&&n.type!=="mask"&&e.push({path:`${t}.type`,message:'ClipMaskGroup type must be "clip" or "mask"',severity:"error"}),(typeof n.clipShapeId!="string"||n.clipShapeId.length===0)&&e.push({path:`${t}.clipShapeId`,message:"clipShapeId must be a non-empty string",severity:"error"}),Array.isArray(n.contentShapeIds)||e.push({path:`${t}.contentShapeIds`,message:"contentShapeIds must be an array",severity:"error"})}function V(s,t={}){let{validate:e=!0,migrate:n=!0}=t,i;try{i=JSON.parse(s)}catch(o){throw new Error(`Failed to parse .svgs document: ${o.message}`)}if(i===null||typeof i!="object"||Array.isArray(i))throw new Error("Invalid .svgs document: root must be a JSON object");let a=i;if(n&&(a=Ft(a)),e){let o=it(a);if(!o.valid){let l=o.errors.map(h=>` ${h.path}: ${h.message}`).join(`
|
|
3
|
-
`);throw new Error(`Invalid .svgs document:
|
|
4
|
-
${l}`)}}return a}var A=/\{\{\s*([\w.\-]+)\s*\}\}/g;function yt(s,t){return s.replace(A,(e,n)=>{let i=t[n];return i!==void 0?String(i):e})}function B(s,t={}){let e={};if(s.templateVariables)for(let i of s.templateVariables)i.defaultValue!==void 0&&i.defaultValue!==""&&(e[i.name]=i.defaultValue);if(Object.assign(e,t),Object.keys(e).length===0)return JSON.parse(JSON.stringify(s));let n=JSON.parse(JSON.stringify(s));for(let i of n.shapes)q(i.state,e);if(n.documentMetadata){let i=n.documentMetadata;q(i,e)}return n}function q(s,t){for(let e of Object.keys(s)){let n=s[e];if(typeof n=="string"){if(A.lastIndex=0,A.test(n)){A.lastIndex=0;let i=yt(n,t);if(Jt(n)){let a=Number(i);if(!isNaN(a)&&Qt(e)){s[e]=a;continue}}s[e]=i}}else if(Array.isArray(n))for(let i=0;i<n.length;i++)typeof n[i]=="string"?(A.lastIndex=0,A.test(n[i])&&(A.lastIndex=0,n[i]=yt(n[i],t))):n[i]!==null&&typeof n[i]=="object"&&q(n[i],t);else n!==null&&typeof n=="object"&&q(n,t)}}function Jt(s){return/^\s*\{\{\s*[\w.\-]+\s*\}\}\s*$/.test(s)}var Ht=new Set(["x","y","width","height","radius","rx","ry","cx","cy","x1","y1","x2","y2","fontSize","borderWidth","cornerRadius","opacity","fillOpacity","strokeOpacity","rotation","skewX","skewY","scaleX","scaleY","letterSpacing","wordSpacing","lineHeight","sides","arms","innerRadiusPercent","armWidthPercent","teeth","toothDepthPercent","holeRadiusPercent","turns","thicknessPercent","direction","headWidthPercent","headLengthPercent","shaftWidthPercent","shiftAngle","dashLength","gapLength","textPathStartOffset","imageOpacity"]);function Qt(s){return Ht.has(s)}function St(s){let t=s.templateVariables??[],e=new Set(t.map(a=>a.name)),n=new Set;for(let a of s.shapes)Y(a.state,n);s.documentMetadata&&Y(s.documentMetadata,n);let i=[...n].filter(a=>!e.has(a)).sort();return{defined:[...t],undeclared:i}}function Y(s,t){for(let e of Object.values(s))if(typeof e=="string"){let n;for(A.lastIndex=0;(n=A.exec(e))!==null;)t.add(n[1])}else if(Array.isArray(e))for(let n of e)if(typeof n=="string"){let i;for(A.lastIndex=0;(i=A.exec(n))!==null;)t.add(i[1])}else n!==null&&typeof n=="object"&&Y(n,t);else e!==null&&typeof e=="object"&&Y(e,t)}function at(s){let t={};for(let e of s){let n=e.indexOf("=");if(n===-1)throw new Error(`Invalid variable format: "${e}". Expected "name=value".`);let i=e.slice(0,n).trim(),a=e.slice(n+1);if(!i)throw new Error(`Invalid variable format: "${e}". Variable name cannot be empty.`);t[i]=a}return t}function mt(s,t,e=-90){let n=[],i=e*Math.PI/180;for(let a=0;a<s;a++){let o=i+a*2*Math.PI/s;n.push({x:t*Math.cos(o),y:t*Math.sin(o)})}return n}function Kt(s,t,e,n=-90){let i=[],a=t*(e/100),o=n*Math.PI/180;for(let l=0;l<s*2;l++){let h=o+l*Math.PI/s,u=l%2===0?t:a;i.push({x:u*Math.cos(h),y:u*Math.sin(h)})}return i}function te(s,t,e=0){let n=s*(t/100)/2,i=[{x:-n,y:-s},{x:n,y:-s},{x:n,y:-n},{x:s,y:-n},{x:s,y:n},{x:n,y:n},{x:n,y:s},{x:-n,y:s},{x:-n,y:n},{x:-s,y:n},{x:-s,y:-n},{x:-n,y:-n}];if(e===0)return i;let a=Math.cos(e*Math.PI/180),o=Math.sin(e*Math.PI/180);return i.map(l=>({x:l.x*a-l.y*o,y:l.x*o+l.y*a}))}function ee(s,t,e,n,i=-90){let a=s*2*(e/100),o=s*(t/100),l=o*(n/100),h=[{x:s,y:0},{x:s-a,y:-o/2},{x:s-a,y:-l/2},{x:-s,y:-l/2},{x:-s,y:l/2},{x:s-a,y:l/2},{x:s-a,y:o/2}];if(i===0)return h;let u=Math.cos(i*Math.PI/180),c=Math.sin(i*Math.PI/180);return h.map(p=>({x:p.x*u-p.y*c,y:p.x*c+p.y*u}))}function G(s,t=0,e=0){if(s.length<3)return"";if(t<=0)return s.map((a,o)=>(o===0?"M":"L")+`${a.x},${a.y}`).join(" ")+" Z";let n=Math.min(t,e*.4),i="";for(let a=0;a<s.length;a++){let o=s[(a-1+s.length)%s.length],l=s[a],h=s[(a+1)%s.length],u={x:o.x-l.x,y:o.y-l.y},c=Math.hypot(u.x,u.y);u.x/=c,u.y/=c;let p={x:h.x-l.x,y:h.y-l.y},d=Math.hypot(p.x,p.y);p.x/=d,p.y/=d;let f=Math.min(n,c/2),g=Math.min(n,d/2),_={x:l.x+u.x*f,y:l.y+u.y*f},m={x:l.x+p.x*g,y:l.y+p.y*g};i+=a===0?`M${_.x},${_.y}`:` L${_.x},${_.y}`,i+=` Q${l.x},${l.y} ${m.x},${m.y}`}return i+" Z"}function se(s,t,e="evenodd"){let n=s*(t/100),i=e==="nonzero"?1:0;return`M ${s} 0 A ${s} ${s} 0 1 1 ${-s} 0 A ${s} ${s} 0 1 1 ${s} 0 Z M ${n} 0 A ${n} ${n} 0 1 ${i} ${-n} 0 A ${n} ${n} 0 1 ${i} ${n} 0 Z`}function re(s,t,e,n=1,i=0){let a=s*(e/100),o=Math.round(t*36),l=t*2*Math.PI,h=(s-a/2)/l,u=i*Math.PI/180,c=[],p=[];for(let g=0;g<=o;g++){let _=g/o,m=_*l*n+u,y=h*(_*l)+a/2,x=a/2;c.push({x:(y+x*.3)*Math.cos(m),y:(y+x*.3)*Math.sin(m)}),p.push({x:Math.max(0,y-x*.3)*Math.cos(m),y:Math.max(0,y-x*.3)*Math.sin(m)})}let d=`M ${c[0].x} ${c[0].y}`;for(let g=1;g<c.length;g++)d+=` L ${c[g].x} ${c[g].y}`;let f=p[p.length-1];d+=` L ${f.x} ${f.y}`;for(let g=p.length-2;g>=0;g--)d+=` L ${p[g].x} ${p[g].y}`;return d+=" Z",d}function ne(s,t,e,n=0){let i=t*(e/100),a=t,o=t-i,l=2*Math.PI/s,h=l*.4,u=l*.1,c=n*Math.PI/180,p=[];for(let d=0;d<s;d++){let f=c+d*l;p.push({x:o*Math.cos(f),y:o*Math.sin(f)}),p.push({x:a*Math.cos(f+u),y:a*Math.sin(f+u)}),p.push({x:a*Math.cos(f+u+h),y:a*Math.sin(f+u+h)}),p.push({x:o*Math.cos(f+l-u),y:o*Math.sin(f+l-u)})}return p}function ie(s,t,e,n=0,i=0,a="evenodd",o=0){let l=ne(s,t,e,o),h=Math.min(n,t*.1),u=G(l,h,t);if(i>0){let c=t*(i/100),p=a==="nonzero"?1:0;u+=` M ${c} 0 A ${c} ${c} 0 1 ${p} ${-c} 0 A ${c} ${c} 0 1 ${p} ${c} 0 Z`}return u}function ae(s,t,e,n,i,a="round",o="uniform",l){let h=Math.min(e,n)/2,u,c,p,d,f,g,_,m;if(o==="non-uniform"&&l?(u=Math.min(l.radiusTL??i,h),c=Math.min(l.radiusTR??i,h),p=Math.min(l.radiusBR??i,h),d=Math.min(l.radiusBL??i,h),f=l.shapeTL??a,g=l.shapeTR??a,_=l.shapeBR??a,m=l.shapeBL??a):(u=c=p=d=Math.min(i,h),f=g=_=m=a),!(a!=="round"||o==="non-uniform"||u>0&&f!=="round"||c>0&&g!=="round"||p>0&&_!=="round"||d>0&&m!=="round")&&u===c&&c===p&&p===d)return null;let y=`M${s+u},${t}`;return y+=` L${s+e-c},${t}`,y+=W(g,c,s+e,t,"tr"),y+=` L${s+e},${t+n-p}`,y+=W(_,p,s+e,t+n,"br"),y+=` L${s+d},${t+n}`,y+=W(m,d,s,t+n,"bl"),y+=` L${s},${t+u}`,y+=W(f,u,s,t,"tl"),y+=" Z",y}function W(s,t,e,n,i){if(t<=0)return"";switch(s){case"round":switch(i){case"tr":return` A${t},${t} 0 0 1 ${e},${n+t}`;case"br":return` A${t},${t} 0 0 1 ${e-t},${n}`;case"bl":return` A${t},${t} 0 0 1 ${e},${n-t}`;case"tl":return` A${t},${t} 0 0 1 ${e+t},${n}`}break;case"scoop":switch(i){case"tr":return` A${t},${t} 0 0 0 ${e},${n+t}`;case"br":return` A${t},${t} 0 0 0 ${e-t},${n}`;case"bl":return` A${t},${t} 0 0 0 ${e},${n-t}`;case"tl":return` A${t},${t} 0 0 0 ${e+t},${n}`}break;case"bevel":switch(i){case"tr":return` L${e},${n+t}`;case"br":return` L${e-t},${n}`;case"bl":return` L${e},${n-t}`;case"tl":return` L${e+t},${n}`}break;case"notch":switch(i){case"tr":return` L${e-t},${n+t} L${e},${n+t}`;case"br":return` L${e-t},${n-t} L${e-t},${n}`;case"bl":return` L${e+t},${n-t} L${e},${n-t}`;case"tl":return` L${e+t},${n+t} L${e+t},${n}`}break}return""}function oe(s,t,e=!1,n=.5,i){if(s.length<2)return s.length===1?`M ${s[0].x} ${s[0].y}`:"";switch(t){case"LINEAR":case"linear":return _t(s,e);case"QUADRATIC":case"quadratic":return le(s,e);case"CUBIC":case"cubic":return ue(s,e);case"ARC":case"arc":return he(s,e,i);case"MIXED":case"mixed":return xt(s,e);case"CATMULL_ROM":case"catmull-rom":return ce(s,e,n);case"BASIS":case"basis":return pe(s,e);default:return s.some(a=>a.segmentType)?xt(s,e):_t(s,e)}}function _t(s,t){let e=`M ${s[0].x} ${s[0].y}`,n=0;for(let i=1;i<s.length;i++)s[i].isSubpathStart?(t&&i-n>2&&(e+=" Z"),e+=` M ${s[i].x} ${s[i].y}`,n=i):e+=` L ${s[i].x} ${s[i].y}`;return t&&s.length-n>2&&(e+=" Z"),e}function le(s,t){let e=`M ${s[0].x} ${s[0].y}`,n=0;for(let i=0;i<s.length-1;i++){let a=s[i],o=s[i+1];if(o.isSubpathStart){if(t&&i-n>=1){let h=s[n],u=a.handleOut??{x:(a.x+h.x)/2,y:(a.y+h.y)/2};e+=` Q ${u.x} ${u.y} ${h.x} ${h.y} Z`}e+=` M ${o.x} ${o.y}`,n=i+1;continue}let l=a.handleOut??{x:(a.x+o.x)/2,y:(a.y+o.y)/2};e+=` Q ${l.x} ${l.y} ${o.x} ${o.y}`}if(t&&s.length-n>1){let i=s[s.length-1],a=s[n],o=i.handleOut??{x:(i.x+a.x)/2,y:(i.y+a.y)/2};e+=` Q ${o.x} ${o.y} ${a.x} ${a.y} Z`}return e}function ue(s,t){let e=`M ${s[0].x} ${s[0].y}`,n=0;for(let i=0;i<s.length-1;i++){let a=s[i],o=s[i+1];if(o.isSubpathStart){if(t&&i-n>=1){let u=s[n],c=a.handleOut??{x:a.x,y:a.y},p=u.handleIn??{x:u.x,y:u.y};e+=` C ${c.x} ${c.y} ${p.x} ${p.y} ${u.x} ${u.y} Z`}e+=` M ${o.x} ${o.y}`,n=i+1;continue}let l=a.handleOut??{x:a.x,y:a.y},h=o.handleIn??{x:o.x,y:o.y};e+=` C ${l.x} ${l.y} ${h.x} ${h.y} ${o.x} ${o.y}`}if(t&&s.length-n>1){let i=s[s.length-1],a=s[n],o=i.handleOut??{x:i.x,y:i.y},l=a.handleIn??{x:a.x,y:a.y};e+=` C ${o.x} ${o.y} ${l.x} ${l.y} ${a.x} ${a.y} Z`}return e}function he(s,t,e){let n=`M ${s[0].x} ${s[0].y}`,i=0,a={rx:50,ry:50,rotation:0,largeArc:!1,sweep:!0};for(let o=0;o<s.length-1;o++){let l=s[o+1];if(l.isSubpathStart){if(t&&o-i>=1){let u=s[i],c=e?.[o]??a;n+=` A ${c.rx} ${c.ry} ${c.rotation} ${c.largeArc?1:0} ${c.sweep?1:0} ${u.x} ${u.y} Z`}n+=` M ${l.x} ${l.y}`,i=o+1;continue}let h=e?.[o]??a;n+=` A ${h.rx} ${h.ry} ${h.rotation} ${h.largeArc?1:0} ${h.sweep?1:0} ${l.x} ${l.y}`}if(t&&s.length-i>1){let o=s[i],l=e?.[s.length-1]??a;n+=` A ${l.rx} ${l.ry} ${l.rotation} ${l.largeArc?1:0} ${l.sweep?1:0} ${o.x} ${o.y} Z`}return n}function xt(s,t){let e=`M ${s[0].x} ${s[0].y}`,n=0;for(let i=0;i<s.length-1;i++){let a=s[i],o=s[i+1];if(o.isSubpathStart){if(t&&i-n>=1){let l=s[n];e+=rt(a,l,l.segmentType),e+=" Z"}e+=` M ${o.x} ${o.y}`,n=i+1;continue}e+=rt(a,o,o.segmentType)}if(t&&s.length-n>1){let i=s[s.length-1],a=s[n];e+=rt(i,a,a.segmentType),e+=" Z"}return e}function rt(s,t,e){let n=(e??(s.handleOut||t.handleIn?"CUBIC":"LINEAR")).toUpperCase();if(n==="LINEAR")return` L ${t.x} ${t.y}`;if(n==="QUADRATIC"){let o=s.handleOut??{x:(s.x+t.x)/2,y:(s.y+t.y)/2};return` Q ${o.x} ${o.y} ${t.x} ${t.y}`}if(n==="ARC"){let o=t.arcParams;return o?` A ${o.rx} ${o.ry} ${o.rotation} ${o.largeArc?1:0} ${o.sweep?1:0} ${t.x} ${t.y}`:` L ${t.x} ${t.y}`}let i=s.handleOut??{x:s.x,y:s.y},a=t.handleIn??{x:t.x,y:t.y};return` C ${i.x} ${i.y} ${a.x} ${a.y} ${t.x} ${t.y}`}function ce(s,t,e){if(s.length<2)return s.length===1?`M ${s[0].x} ${s[0].y}`:"";let n=e,i=t?[s[s.length-1],...s,s[0],s[1]]:[s[0],...s,s[s.length-1]],a=`M ${s[0].x} ${s[0].y}`,o=t?s.length:s.length-1;for(let l=0;l<o;l++){let h=i[l],u=i[l+1],c=i[l+2],p=i[l+3],d=Math.hypot(c.x-u.x,c.y-u.y),f=Math.hypot(u.x-h.x,u.y-h.y),g=Math.hypot(p.x-c.x,p.y-c.y),_=Math.pow(f,n),m=Math.pow(d,n),y=Math.pow(g,n),x=Math.pow(f,2*n),v=Math.pow(d,2*n),C=Math.pow(g,2*n),k,w,M,S;f<1e-8?(k=u.x,w=u.y):(k=(x*c.x-v*h.x+(2*x+3*_*m+v)*u.x)/(3*_*(_+m)),w=(x*c.y-v*h.y+(2*x+3*_*m+v)*u.y)/(3*_*(_+m))),g<1e-8?(M=c.x,S=c.y):(M=(C*u.x-v*p.x+(2*C+3*y*m+v)*c.x)/(3*y*(y+m)),S=(C*u.y-v*p.y+(2*C+3*y*m+v)*c.y)/(3*y*(y+m))),a+=` C ${k} ${w} ${M} ${S} ${c.x} ${c.y}`}return t&&(a+=" Z"),a}function pe(s,t){let e=s.length;if(e<2)return e===1?`M ${s[0].x} ${s[0].y}`:"";if(e===2)return`M ${s[0].x} ${s[0].y} L ${s[1].x} ${s[1].y}`;if(t){let a=(s[0].x+4*s[1].x+s[2].x)/6,o=(s[0].y+4*s[1].y+s[2].y)/6,l=`M ${a} ${o}`;for(let h=0;h<e;h++){let u=s[(h+1)%e],c=s[(h+2)%e],p=s[(h+3)%e];l+=nt(u,c,p)}return l+=" Z",l}let n=s,i=`M ${n[0].x} ${n[0].y}`;i+=` L ${(5*n[0].x+n[1].x)/6} ${(5*n[0].y+n[1].y)/6}`;for(let a=0;a<=e-3;a++)i+=nt(n[a],n[a+1],n[a+2]);return i+=nt(n[e-2],n[e-1],n[e-1]),i+=` L ${n[e-1].x} ${n[e-1].y}`,i}function nt(s,t,e){return` C ${(2*s.x+t.x)/3} ${(2*s.y+t.y)/3} ${(s.x+2*t.x)/3} ${(s.y+2*t.y)/3} ${(s.x+4*t.x+e.x)/6} ${(s.y+4*t.y+e.y)/6}`}function Ct(s,t,e){let n=Number.isFinite(t)?Math.max(1,t):8,i=Number.isFinite(e)?Math.max(1,e):4;switch(s){case"dashed":case"dotted":case"custom":return`${n} ${i}`;default:return null}}function T(s){return s.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function de(s){return s.fillType||(s.fillGradient?s.fillGradient.r!==void 0?"radial-gradient":"linear-gradient":s.linearGradient?"linear-gradient":s.radialGradient?"radial-gradient":"solid")}function Tt(s){let t=new Map,e=s.state,n=e;switch(s.type){case"circle":t.set("cx",String(e.x??0)),t.set("cy",String(e.y??0)),t.set("r",String(e.radius??50));break;case"ellipse":t.set("cx",String(e.cx??0)),t.set("cy",String(e.cy??0)),t.set("rx",String(e.rx??50)),t.set("ry",String(e.ry??30));break;case"rectangle":case"square":t.set("x",String(e.x??0)),t.set("y",String(e.y??0)),t.set("width",String(e.width??100)),t.set("height",String(e.height??100)),(e.cornerRadius??0)>0&&t.set("rx",String(e.cornerRadius));break;case"line":t.set("x1",String(e.x1??0)),t.set("y1",String(e.y1??0)),t.set("x2",String(e.x2??0)),t.set("y2",String(e.y2??0));break;case"text":t.set("x",String(e.x??0)),t.set("y",String(e.y??0)),e.fontSize&&t.set("font-size",String(e.fontSize)),e.fontFamily&&t.set("font-family",e.fontFamily),e.fontWeight&&t.set("font-weight",e.fontWeight),e.fontStyle&&t.set("font-style",e.fontStyle),e.textAnchor&&t.set("text-anchor",e.textAnchor),e.letterSpacing&&t.set("letter-spacing",String(e.letterSpacing));break;case"image":t.set("x",String(e.x??0)),t.set("y",String(e.y??0)),t.set("width",String(e.width??100)),t.set("height",String(e.height??100)),n.href&&t.set("href",String(n.href));break}let i=de(n);i==="none"?t.set("fill","none"):i==="linear-gradient"||i==="radial-gradient"?t.set("fill",`url(#gradient-fill-${s.id})`):i==="pattern"?t.set("fill",`url(#pattern-fill-${s.id})`):t.set("fill",e.fillColor??"#000000");let a=e.opacity;a!==void 0&&a<1&&t.set("opacity",String(a));let o=e.fillOpacity;o!==void 0&&o<1&&t.set("fill-opacity",String(o)),e.fillRule&&e.fillRule!=="nonzero"&&t.set("fill-rule",e.fillRule);let l=n.strokeType??"solid";if(l==="none")t.set("stroke","none");else if(l==="linear-gradient"||l==="radial-gradient")t.set("stroke",`url(#gradient-stroke-${s.id})`);else{let v=e.borderColor??"none";v!=="none"&&t.set("stroke",v)}let h=e.borderWidth;h!=null&&h!==0&&t.set("stroke-width",String(h));let u=e.strokeOpacity;u!==void 0&&u<1&&t.set("stroke-opacity",String(u));let c=e.lineStyle??"solid",p=e.dashLength??8,d=e.gapLength??4,f=Ct(c,p,d);f&&(t.set("stroke-dasharray",f),c==="dotted"&&t.set("stroke-linecap","round"));let g=fe(n);g&&t.set("transform",g);let _=n.filters;_&&_.length>0&&t.set("filter",`url(#filter-${s.id})`);let m=n.startEndpoint,y=n.endEndpoint;m&&m!=="none"&&t.set("marker-start",`url(#line-marker-${m})`),y&&y!=="none"&&t.set("marker-end",`url(#line-marker-${y})`);let x=n.metadata;return x&&(x.role&&t.set("role",x.role),x.ariaLabel&&t.set("aria-label",x.ariaLabel)),t}function $e(s){switch(s.type){case"circle":return"circle";case"ellipse":return"ellipse";case"rectangle":case"square":return"rect";case"line":return"line";case"text":return"text";case"image":return"image";case"spline":case"polyline":case"triangle":case"ngon":case"star":case"cross":case"ring":case"spiral":case"gear":case"arrow":return"path";default:return"g"}}function fe(s){let t=s.rotation??0,e=s.skewX??0,n=s.skewY??0,i=s.scaleX??1,a=s.scaleY??1;if(t===0&&e===0&&n===0&&i===1&&a===1)return null;let o=s.customPivot;if(!o)return null;let l=[];return l.push(`translate(${o.x}, ${o.y})`),t!==0&&l.push(`rotate(${t})`),(i!==1||a!==1)&&l.push(`scale(${i}, ${a})`),e!==0&&l.push(`skewX(${e})`),n!==0&&l.push(`skewY(${n})`),l.push(`translate(${-o.x}, ${-o.y})`),l.join(" ")}function D(s,t){let e=s.viewboxes?.[0];return{width:t.width??e?.width??800,height:t.height??e?.height??600}}function r(s,t){return t==null||t===""?"":` ${s}="${T(String(t))}"`}function Z(s){let t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(s);return t?{r:parseInt(t[1],16)/255,g:parseInt(t[2],16)/255,b:parseInt(t[3],16)/255}:{r:0,g:0,b:0}}function ge(s,t,e){let{offsetX:n,offsetY:i,blurRadius:a,spread:o,color:l,opacity:h}=s,u="";if(o===0)u+=`<feDropShadow${r("in",t)}${r("dx",n)}${r("dy",i)}${r("stdDeviation",a/2)}${r("flood-color",l)}${r("flood-opacity",h)}${r("result",`${e}_shadow`)}/>`,u+=`<feMerge${r("result",e)}><feMergeNode${r("in",`${e}_shadow`)}/><feMergeNode${r("in",t)}/></feMerge>`;else{u+=`<feColorMatrix${r("in",t)}${r("type","matrix")}${r("values","0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0")}${r("result",`${e}_alpha`)}/>`;let c=o>0?"dilate":"erode",p=Math.abs(o);u+=`<feMorphology${r("in",`${e}_alpha`)}${r("operator",c)}${r("radius",p)}${r("result",`${e}_spread`)}/>`,u+=`<feGaussianBlur${r("in",`${e}_spread`)}${r("stdDeviation",a/2)}${r("result",`${e}_blur`)}/>`,u+=`<feOffset${r("in",`${e}_blur`)}${r("dx",n)}${r("dy",i)}${r("result",`${e}_offset`)}/>`,u+=`<feFlood${r("flood-color",l)}${r("flood-opacity",h)}${r("result",`${e}_color`)}/>`,u+=`<feComposite${r("in",`${e}_color`)}${r("in2",`${e}_offset`)}${r("operator","in")}${r("result",`${e}_shadow`)}/>`,u+=`<feMerge${r("result",e)}><feMergeNode${r("in",`${e}_shadow`)}/><feMergeNode${r("in",t)}/></feMerge>`}return u}function ye(s,t,e){let{offsetX:n,offsetY:i,blurRadius:a,choke:o,color:l,opacity:h}=s,u=a*(1-o/100),c="";return c+=`<feColorMatrix${r("in",t)}${r("type","matrix")}${r("values","0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0")}${r("result",`${e}_alpha`)}/>`,c+=`<feComponentTransfer${r("in",`${e}_alpha`)}${r("result",`${e}_inverted`)}><feFuncA${r("type","table")}${r("tableValues","1 0")}/></feComponentTransfer>`,c+=`<feGaussianBlur${r("in",`${e}_inverted`)}${r("stdDeviation",u/2)}${r("result",`${e}_blur`)}/>`,c+=`<feOffset${r("in",`${e}_blur`)}${r("dx",n)}${r("dy",i)}${r("result",`${e}_offset`)}/>`,c+=`<feFlood${r("flood-color",l)}${r("flood-opacity",h)}${r("result",`${e}_color`)}/>`,c+=`<feComposite${r("in",`${e}_color`)}${r("in2",`${e}_offset`)}${r("operator","in")}${r("result",`${e}_coloredShadow`)}/>`,c+=`<feComposite${r("in",`${e}_coloredShadow`)}${r("in2",`${e}_alpha`)}${r("operator","in")}${r("result",`${e}_innerShadow`)}/>`,c+=`<feComposite${r("in",`${e}_innerShadow`)}${r("in2",t)}${r("operator","over")}${r("result",e)}/>`,c}function me(s,t,e){let{blurX:n,blurY:i}=s;return n===0&&i===0?b(t,e):`<feGaussianBlur${r("in",t)}${r("stdDeviation",`${n/2} ${i/2}`)}${r("result",e)}/>`}function _e(s,t,e){let{distance:n,angle:i}=s;if(n===0)return b(t,e);let a=i*Math.PI/180,o=Math.abs(Math.cos(a)*n),l=Math.abs(Math.sin(a)*n);return`<feGaussianBlur${r("in",t)}${r("stdDeviation",`${o/2} ${l/2}`)}${r("result",e)}/>`}function xe(s,t,e){let{x:n,y:i,z:a,color:o,surfaceScale:l,diffuseConstant:h,specularConstant:u,specularExponent:c}=s,p="";return p+=`<feDiffuseLighting${r("in","SourceAlpha")}${r("surfaceScale",l)}${r("diffuseConstant",h)}${r("lighting-color",o)}${r("result",`${e}_diffuse`)}>`,p+=`<fePointLight${r("x",n)}${r("y",i)}${r("z",a)}/>`,p+="</feDiffuseLighting>",p+=`<feSpecularLighting${r("in","SourceAlpha")}${r("surfaceScale",l)}${r("specularConstant",u)}${r("specularExponent",c)}${r("lighting-color",o)}${r("result",`${e}_specular`)}>`,p+=`<fePointLight${r("x",n)}${r("y",i)}${r("z",a)}/>`,p+="</feSpecularLighting>",p+=`<feComposite${r("in",t)}${r("in2",`${e}_diffuse`)}${r("operator","arithmetic")}${r("k1",1)}${r("k2",0)}${r("k3",0)}${r("k4",0)}${r("result",`${e}_lit`)}/>`,p+=`<feComposite${r("in",`${e}_specular`)}${r("in2",`${e}_lit`)}${r("operator","arithmetic")}${r("k1",0)}${r("k2",1)}${r("k3",1)}${r("k4",0)}${r("result",e)}/>`,p}function be(s,t,e){let{x:n,y:i,z:a,pointsAtX:o,pointsAtY:l,pointsAtZ:h,coneAngle:u,color:c,surfaceScale:p,specularConstant:d,specularExponent:f}=s,g="";return g+=`<feSpecularLighting${r("in","SourceAlpha")}${r("surfaceScale",p)}${r("specularConstant",d)}${r("specularExponent",f)}${r("lighting-color",c)}${r("result",`${e}_specular`)}>`,g+=`<feSpotLight${r("x",n)}${r("y",i)}${r("z",a)}${r("pointsAtX",o)}${r("pointsAtY",l)}${r("pointsAtZ",h)}${r("limitingConeAngle",u)}/>`,g+="</feSpecularLighting>",g+=`<feComposite${r("in",`${e}_specular`)}${r("in2","SourceAlpha")}${r("operator","in")}${r("result",`${e}_clipped`)}/>`,g+=`<feComposite${r("in",`${e}_clipped`)}${r("in2",t)}${r("operator","arithmetic")}${r("k1",0)}${r("k2",1)}${r("k3",1)}${r("k4",0)}${r("result",e)}/>`,g}function ke(s,t,e){let{width:n,color:i,opacity:a,position:o}=s,l="";if(o==="inside")l+=`<feMorphology${r("in","SourceAlpha")}${r("operator","erode")}${r("radius",n)}${r("result",`${e}_eroded`)}/>`,l+=`<feComposite${r("in","SourceAlpha")}${r("in2",`${e}_eroded`)}${r("operator","out")}${r("result",`${e}_outlineAlpha`)}/>`,l+=`<feFlood${r("flood-color",i)}${r("flood-opacity",a)}${r("result",`${e}_color`)}/>`,l+=`<feComposite${r("in",`${e}_color`)}${r("in2",`${e}_outlineAlpha`)}${r("operator","in")}${r("result",`${e}_outline`)}/>`,l+=`<feComposite${r("in",`${e}_outline`)}${r("in2",t)}${r("operator","over")}${r("result",e)}/>`;else{let h=o==="outside"?n:n/2;l+=`<feMorphology${r("in","SourceAlpha")}${r("operator","dilate")}${r("radius",h)}${r("result",`${e}_dilated`)}/>`,l+=`<feComposite${r("in",`${e}_dilated`)}${r("in2","SourceAlpha")}${r("operator","out")}${r("result",`${e}_outlineAlpha`)}/>`,l+=`<feFlood${r("flood-color",i)}${r("flood-opacity",a)}${r("result",`${e}_color`)}/>`,l+=`<feComposite${r("in",`${e}_color`)}${r("in2",`${e}_outlineAlpha`)}${r("operator","in")}${r("result",`${e}_outline`)}/>`,l+=`<feMerge${r("result",e)}><feMergeNode${r("in",`${e}_outline`)}/><feMergeNode${r("in",t)}/></feMerge>`}return l}function ve(s,t,e){let{amount:n}=s;if(n===0)return b(t,e);let i=1+4*n,a=-n,o=[0,a,0,a,i,a,0,a,0].join(" ");return`<feConvolveMatrix${r("in",t)}${r("order","3")}${r("kernelMatrix",o)}${r("divisor","1")}${r("bias","0")}${r("preserveAlpha","true")}${r("edgeMode","duplicate")}${r("result",e)}/>`}function we(s,t,e){let{blockSize:n}=s;if(n<=1)return b(t,e);let i=n/2,a="";return a+=`<feMorphology${r("in",t)}${r("operator","erode")}${r("radius",i)}${r("result",`${e}_eroded`)}/>`,a+=`<feMorphology${r("in",`${e}_eroded`)}${r("operator","dilate")}${r("radius",i)}${r("result",e)}/>`,a}function Me(s,t,e){let{scale:n,frequency:i,octaves:a,warpType:o}=s;if(n===0)return b(t,e);let l="";return l+=`<feTurbulence${r("type",o)}${r("baseFrequency",i)}${r("numOctaves",a)}${r("seed",0)}${r("result",`${e}_turbulence`)}/>`,l+=`<feDisplacementMap${r("in",t)}${r("in2",`${e}_turbulence`)}${r("scale",n)}${r("xChannelSelector","R")}${r("yChannelSelector","G")}${r("result",e)}/>`,l}function Se(s,t,e){let{operator:n,radiusX:i,radiusY:a}=s;return i===0&&a===0?b(t,e):`<feMorphology${r("in",t)}${r("operator",n)}${r("radius",`${i} ${a}`)}${r("result",e)}/>`}function Ce(s,t,e){let{levels:n}=s;if(n<2)return b(t,e);let i=[];for(let l=0;l<n;l++)i.push(l/(n-1));let a=i.join(" "),o=`<feComponentTransfer${r("in",t)}${r("result",e)}>`;return o+=`<feFuncR${r("type","discrete")}${r("tableValues",a)}/>`,o+=`<feFuncG${r("type","discrete")}${r("tableValues",a)}/>`,o+=`<feFuncB${r("type","discrete")}${r("tableValues",a)}/>`,o+="</feComponentTransfer>",o}function Te(s,t,e){let{levels:n,contrast:i}=s;if(n<2)return b(t,e);let a=[];for(let h=0;h<n;h++){let u=h/(n-1),c=u;i!==1&&(c=.5+(u-.5)*i,c=Math.max(0,Math.min(1,c))),a.push(c)}let o=a.join(" "),l=`<feComponentTransfer${r("in",t)}${r("result",e)}>`;return l+=`<feFuncR${r("type","table")}${r("tableValues",o)}/>`,l+=`<feFuncG${r("type","table")}${r("tableValues",o)}/>`,l+=`<feFuncB${r("type","table")}${r("tableValues",o)}/>`,l+="</feComponentTransfer>",l}function Ae(s,t,e){let{radius:n}=s;if(n===0)return b(t,e);let i="";return i+=`<feGaussianBlur${r("in","SourceAlpha")}${r("stdDeviation",n)}${r("result",`${e}_blurredAlpha`)}/>`,i+=`<feComponentTransfer${r("in",`${e}_blurredAlpha`)}${r("result",`${e}_thresholdAlpha`)}><feFuncA${r("type","linear")}${r("slope",20)}${r("intercept",-9)}/></feComponentTransfer>`,i+=`<feComposite${r("in",t)}${r("in2",`${e}_thresholdAlpha`)}${r("operator","in")}${r("result",e)}/>`,i}function Pe(s,t,e){let{amount:n}=s;if(n===0)return b(t,e);let i=1-n;return`<feColorMatrix${r("in",t)}${r("type","saturate")}${r("values",i)}${r("result",e)}/>`}function Re(s,t,e){let{red:n,green:i,blue:a}=s;if(n===1&&i===1&&a===1)return b(t,e);let o=`<feComponentTransfer${r("in",t)}${r("result",e)}>`;return o+=`<feFuncR${r("type","linear")}${r("slope",n)}${r("intercept",0)}/>`,o+=`<feFuncG${r("type","linear")}${r("slope",i)}${r("intercept",0)}/>`,o+=`<feFuncB${r("type","linear")}${r("slope",a)}${r("intercept",0)}/>`,o+="</feComponentTransfer>",o}function Oe(s,t,e){let{amount:n}=s;if(n===1)return b(t,e);let i=`<feComponentTransfer${r("in",t)}${r("result",e)}>`;return i+=`<feFuncR${r("type","linear")}${r("slope",n)}${r("intercept",0)}/>`,i+=`<feFuncG${r("type","linear")}${r("slope",n)}${r("intercept",0)}/>`,i+=`<feFuncB${r("type","linear")}${r("slope",n)}${r("intercept",0)}/>`,i+="</feComponentTransfer>",i}function Ee(s,t,e){let{amount:n}=s;if(n===1)return b(t,e);let i=.5*(1-n),a=`<feComponentTransfer${r("in",t)}${r("result",e)}>`;return a+=`<feFuncR${r("type","linear")}${r("slope",n)}${r("intercept",i)}/>`,a+=`<feFuncG${r("type","linear")}${r("slope",n)}${r("intercept",i)}/>`,a+=`<feFuncB${r("type","linear")}${r("slope",n)}${r("intercept",i)}/>`,a+="</feComponentTransfer>",a}function Ie(s,t,e){let{amount:n}=s;if(n===1)return b(t,e);let i=`<feComponentTransfer${r("in",t)}${r("result",e)}>`;return i+=`<feFuncA${r("type","linear")}${r("slope",n)}${r("intercept",0)}/>`,i+="</feComponentTransfer>",i}function Le(s,t,e){let{amount:n}=s;if(n===0)return b(t,e);let i=n,a=1-n,o=`${i} ${a}`,l=`<feComponentTransfer${r("in",t)}${r("result",e)}>`;return l+=`<feFuncR${r("type","table")}${r("tableValues",o)}/>`,l+=`<feFuncG${r("type","table")}${r("tableValues",o)}/>`,l+=`<feFuncB${r("type","table")}${r("tableValues",o)}/>`,l+="</feComponentTransfer>",l}function Ge(s,t,e){let{angle:n}=s;return n===0||n===360?b(t,e):`<feColorMatrix${r("in",t)}${r("type","hueRotate")}${r("values",n)}${r("result",e)}/>`}function Ve(s,t,e){let{amount:n}=s;return n===1?b(t,e):`<feColorMatrix${r("in",t)}${r("type","saturate")}${r("values",n)}${r("result",e)}/>`}function je(s,t,e){let{threshold:n}=s,i="";if(i+=`<feColorMatrix${r("in",t)}${r("type","saturate")}${r("values",0)}${r("result",`${e}_gray`)}/>`,n===.5)i+=`<feComponentTransfer${r("in",`${e}_gray`)}${r("result",e)}>`,i+=`<feFuncR${r("type","discrete")}${r("tableValues","0 1")}/>`,i+=`<feFuncG${r("type","discrete")}${r("tableValues","0 1")}/>`,i+=`<feFuncB${r("type","discrete")}${r("tableValues","0 1")}/>`,i+="</feComponentTransfer>";else{let a=[];for(let l=0;l<256;l++)a.push(l/255<n?0:1);let o=a.join(" ");i+=`<feComponentTransfer${r("in",`${e}_gray`)}${r("result",e)}>`,i+=`<feFuncR${r("type","table")}${r("tableValues",o)}/>`,i+=`<feFuncG${r("type","table")}${r("tableValues",o)}/>`,i+=`<feFuncB${r("type","table")}${r("tableValues",o)}/>`,i+="</feComponentTransfer>"}return i}function Ne(s,t,e){let{amount:n}=s;if(n===0)return b(t,e);let i=[.393,.769,.189,0,0],a=[.349,.686,.168,0,0],o=[.272,.534,.131,0,0],l=[1,0,0,0,0],h=[0,1,0,0,0],u=[0,0,1,0,0],c=(_,m)=>_.map((y,x)=>y*(1-n)+m[x]*n),p=c(l,i),d=c(h,a),f=c(u,o),g=[...p,...d,...f,0,0,0,1,0].join(" ");return`<feColorMatrix${r("in",t)}${r("type","matrix")}${r("values",g)}${r("result",e)}/>`}function Be(s,t,e){let{shadowColor:n,highlightColor:i}=s,a=Z(n),o=Z(i),l="";return l+=`<feColorMatrix${r("in",t)}${r("type","saturate")}${r("values",0)}${r("result",`${e}_gray`)}/>`,l+=`<feComponentTransfer${r("in",`${e}_gray`)}${r("result",e)}>`,l+=`<feFuncR${r("type","table")}${r("tableValues",`${a.r} ${o.r}`)}/>`,l+=`<feFuncG${r("type","table")}${r("tableValues",`${a.g} ${o.g}`)}/>`,l+=`<feFuncB${r("type","table")}${r("tableValues",`${a.b} ${o.b}`)}/>`,l+="</feComponentTransfer>",l}function De(s,t,e){let{intensity:n}=s;if(n===0)return b(t,e);let i="";i+=`<feComponentTransfer${r("in",t)}${r("result",`${e}_invert`)}>`,i+=`<feFuncR${r("type","table")}${r("tableValues","1 0")}/>`,i+=`<feFuncG${r("type","table")}${r("tableValues","1 0")}/>`,i+=`<feFuncB${r("type","table")}${r("tableValues","1 0")}/>`,i+="</feComponentTransfer>",i+=`<feColorMatrix${r("in",`${e}_invert`)}${r("type","saturate")}${r("values",0)}${r("result",`${e}_gray`)}/>`;let a=[.1,.1,.1,0,0],o=[.3,.4,.3,0,0],l=[.5,.5,.8,0,0],h=[1,0,0,0,0],u=[0,1,0,0,0],c=[0,0,1,0,0],p=(m,y)=>m.map((x,v)=>x*(1-n)+y[v]*n),d=p(h,a),f=p(u,o),g=p(c,l),_=[...d,...f,...g,0,0,0,1,0].join(" ");return i+=`<feColorMatrix${r("in",`${e}_gray`)}${r("type","matrix")}${r("values",_)}${r("result",e)}/>`,i}function Fe(s,t,e){let{amount:n,scale:i}=s;if(n===0)return b(t,e);let a=1/i,o="";return o+=`<feTurbulence${r("type","fractalNoise")}${r("baseFrequency",a)}${r("numOctaves",3)}${r("seed",0)}${r("result",`${e}_noise`)}/>`,o+=`<feColorMatrix${r("in",`${e}_noise`)}${r("type","saturate")}${r("values",0)}${r("result",`${e}_noiseGray`)}/>`,o+=`<feBlend${r("in",t)}${r("in2",`${e}_noiseGray`)}${r("mode","overlay")}${r("result",`${e}_blended`)}/>`,o+=`<feComposite${r("in",`${e}_blended`)}${r("in2",t)}${r("operator","arithmetic")}${r("k1",0)}${r("k2",n)}${r("k3",1-n)}${r("k4",0)}${r("result",`${e}_amt`)}/>`,o+=`<feComposite${r("in",`${e}_amt`)}${r("in2",t)}${r("operator","in")}${r("result",e)}/>`,o}function Ue(s,t,e){let{strength:n,angle:i}=s;if(n===0)return b(t,e);let a=i*Math.PI/180,o=Math.cos(a),l=Math.sin(a),h=n,u=[-(h*(o+l)),-(h*l),h*(-o+l),-(h*o),1,h*o,h*(o-l),h*l,h*(o+l)].join(" ");return`<feConvolveMatrix${r("in",t)}${r("order","3 3")}${r("kernelMatrix",u)}${r("divisor",1)}${r("bias",.5)}${r("preserveAlpha","true")}${r("result",e)}/>`}function ze(s,t,e){let{amount:n,size:i}=s;if(n===0)return b(t,e);let a=.5/i,o="";return o+=`<feTurbulence${r("type","fractalNoise")}${r("baseFrequency",`${a} ${a}`)}${r("numOctaves",5)}${r("seed",0)}${r("stitchTiles","stitch")}${r("result",`${e}_grain`)}/>`,o+=`<feColorMatrix${r("in",`${e}_grain`)}${r("type","saturate")}${r("values",0)}${r("result",`${e}_grainGray`)}/>`,o+=`<feBlend${r("in",t)}${r("in2",`${e}_grainGray`)}${r("mode","soft-light")}${r("result",`${e}_blended`)}/>`,o+=`<feComposite${r("in",`${e}_blended`)}${r("in2",t)}${r("operator","arithmetic")}${r("k1",0)}${r("k2",n)}${r("k3",1-n)}${r("k4",0)}${r("result",`${e}_amt`)}/>`,o+=`<feComposite${r("in",`${e}_amt`)}${r("in2",t)}${r("operator","in")}${r("result",e)}/>`,o}function We(s,t,e){let{wetness:n,turbulence:i}=s;if(n===0&&i===0)return b(t,e);let a="";return a+=`<feTurbulence${r("type","fractalNoise")}${r("baseFrequency",.02+i*.03)}${r("numOctaves",4)}${r("seed",42)}${r("result",`${e}_turb`)}/>`,a+=`<feDisplacementMap${r("in",t)}${r("in2",`${e}_turb`)}${r("scale",n*15)}${r("xChannelSelector","R")}${r("yChannelSelector","G")}${r("result",`${e}_disp`)}/>`,a+=`<feGaussianBlur${r("in",`${e}_disp`)}${r("stdDeviation",n*2)}${r("result",`${e}_blur`)}/>`,a+=`<feBlend${r("in",`${e}_blur`)}${r("in2",t)}${r("mode","multiply")}${r("result",e)}/>`,a}function Xe(s,t,e){let{thickness:n,texture:i}=s;if(n===0&&i===0)return b(t,e);let a="";a+=`<feTurbulence${r("type","turbulence")}${r("baseFrequency",.03+i*.02)}${r("numOctaves",3)}${r("seed",1e3)}${r("result",`${e}_brush`)}/>`;let o=Math.max(3,8-Math.floor(n*5)),l=Array.from({length:o+1},(h,u)=>u/o).join(" ");a+=`<feComponentTransfer${r("in",t)}${r("result",`${e}_poster`)}>`;for(let h of["R","G","B"])a+=`<feFunc${h}${r("type","discrete")}${r("tableValues",l)}/>`;return a+="</feComponentTransfer>",a+=`<feDisplacementMap${r("in",`${e}_poster`)}${r("in2",`${e}_brush`)}${r("scale",i*4)}${r("xChannelSelector","R")}${r("yChannelSelector","G")}${r("result",`${e}_disp`)}/>`,a+=`<feMorphology${r("in",`${e}_disp`)}${r("operator","dilate")}${r("radius",n*.5)}${r("result",`${e}_thick`)}/>`,a+=`<feComposite${r("in",`${e}_thick`)}${r("in2",t)}${r("operator","in")}${r("result",e)}/>`,a}function qe(s,t,e){let{spread:n,edges:i}=s;if(n===0&&i===0)return b(t,e);let a="";return a+=`<feTurbulence${r("type","fractalNoise")}${r("baseFrequency",.01+i*.02)}${r("numOctaves",5)}${r("seed",1100)}${r("result",`${e}_ink`)}/>`,a+=`<feMorphology${r("in",t)}${r("operator","dilate")}${r("radius",n*3)}${r("result",`${e}_dilate`)}/>`,a+=`<feDisplacementMap${r("in",`${e}_dilate`)}${r("in2",`${e}_ink`)}${r("scale",i*10)}${r("xChannelSelector","R")}${r("yChannelSelector","G")}${r("result",`${e}_disp`)}/>`,a+=`<feGaussianBlur${r("in",`${e}_disp`)}${r("stdDeviation",n*.5)}${r("result",e)}/>`,a}function Ye(s,t,e){let{wrinkles:n,shine:i}=s;if(n===0&&i===0)return b(t,e);let a="";return a+=`<feTurbulence${r("type","turbulence")}${r("baseFrequency",.02)}${r("numOctaves",4)}${r("seed",1200)}${r("result",`${e}_wrinkle`)}/>`,a+=`<feDisplacementMap${r("in",t)}${r("in2",`${e}_wrinkle`)}${r("scale",n*15)}${r("xChannelSelector","R")}${r("yChannelSelector","G")}${r("result",`${e}_disp`)}/>`,a+=`<feSpecularLighting${r("in",`${e}_wrinkle`)}${r("surfaceScale",n*2)}${r("specularConstant",i*1.5)}${r("specularExponent",20)}${r("result",`${e}_sheen`)}>`,a+=`<feDistantLight${r("azimuth",45)}${r("elevation",60)}/>`,a+="</feSpecularLighting>",a+=`<feBlend${r("in",`${e}_disp`)}${r("in2",`${e}_sheen`)}${r("mode","screen")}${r("result",`${e}_blend`)}/>`,a+=`<feComposite${r("in",`${e}_blend`)}${r("in2",t)}${r("operator","in")}${r("result",e)}/>`,a}function Ze(s,t,e){let{density:n,size:i}=s;if(n===0)return b(t,e);let a="",o=1-n;a+=`<feTurbulence${r("type","turbulence")}${r("baseFrequency",.1/i)}${r("numOctaves",1)}${r("seed",1400)}${r("result",`${e}_hole`)}/>`,a+=`<feComponentTransfer${r("in",`${e}_hole`)}${r("result",`${e}_thresh`)}>`;for(let l of["R","G","B","A"])a+=`<feFunc${l}${r("type","linear")}${r("slope",10)}${r("intercept",-o*10+5)}/>`;a+="</feComponentTransfer>",a+=`<feComponentTransfer${r("in",`${e}_thresh`)}${r("result",`${e}_clamp`)}>`;for(let l of["R","G","B","A"])a+=`<feFunc${l}${r("type","table")}${r("tableValues","0 0 1 1")}/>`;return a+="</feComponentTransfer>",a+=`<feComposite${r("in",t)}${r("in2",`${e}_clamp`)}${r("operator","in")}${r("result",e)}/>`,a}function Je(s,t,e){let{color:n,radius:i,intensity:a}=s;if(a===0||i===0)return b(t,e);let{r:o,g:l,b:h}=Z(n),u="";return u+=`<feColorMatrix${r("in",t)}${r("type","matrix")}${r("values","0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0")}${r("result",`${e}_alpha`)}/>`,u+=`<feGaussianBlur${r("in",`${e}_alpha`)}${r("stdDeviation",i/2)}${r("result",`${e}_blur`)}/>`,u+=`<feColorMatrix${r("in",`${e}_blur`)}${r("type","matrix")}${r("values",`0 0 0 0 ${o} 0 0 0 0 ${l} 0 0 0 0 ${h} 0 0 0 ${a} 0`)}${r("result",`${e}_color`)}/>`,u+=`<feMerge${r("result",e)}><feMergeNode${r("in",`${e}_color`)}/><feMergeNode${r("in",t)}/></feMerge>`,u}function He(s,t,e){let{color:n,radius:i,intensity:a}=s;if(a===0||i===0)return b(t,e);let{r:o,g:l,b:h}=Z(n),u="";return u+=`<feColorMatrix${r("in",t)}${r("type","matrix")}${r("values","0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0")}${r("result",`${e}_alpha`)}/>`,u+=`<feMorphology${r("in",`${e}_alpha`)}${r("operator","erode")}${r("radius",i/4)}${r("result",`${e}_erode`)}/>`,u+=`<feComposite${r("in",`${e}_alpha`)}${r("in2",`${e}_erode`)}${r("operator","out")}${r("result",`${e}_edge`)}/>`,u+=`<feGaussianBlur${r("in",`${e}_edge`)}${r("stdDeviation",i/3)}${r("result",`${e}_blur`)}/>`,u+=`<feColorMatrix${r("in",`${e}_blur`)}${r("type","matrix")}${r("values",`0 0 0 0 ${o} 0 0 0 0 ${l} 0 0 0 0 ${h} 0 0 0 ${a*2} 0`)}${r("result",`${e}_color`)}/>`,u+=`<feComposite${r("in",`${e}_color`)}${r("in2",`${e}_alpha`)}${r("operator","in")}${r("result",`${e}_clipped`)}/>`,u+=`<feComposite${r("in",`${e}_clipped`)}${r("in2",t)}${r("operator","over")}${r("result",e)}/>`,u}function b(s,t){return`<feMerge${r("result",t)}><feMergeNode${r("in",s)}/></feMerge>`}function Qe(s,t,e,n){switch(s.type){case"drop-shadow":return ge(s,t,e);case"inner-shadow":return ye(s,t,e);case"gaussian-blur":return me(s,t,e);case"motion-blur":return _e(s,t,e);case"point-light":{let i=s;return xe(n?{...i,x:i.x+n.x,y:i.y+n.y}:i,t,e)}case"spot-light":{let i=s;return be(n?{...i,x:i.x+n.x,y:i.y+n.y,pointsAtX:i.pointsAtX+n.x,pointsAtY:i.pointsAtY+n.y}:i,t,e)}case"outline":return ke(s,t,e);case"sharpen":return ve(s,t,e);case"pixelate":return we(s,t,e);case"warp":return Me(s,t,e);case"morphology":return Se(s,t,e);case"contouring-discrete":return Ce(s,t,e);case"contouring-table":return Te(s,t,e);case"round-edges":return Ae(s,t,e);case"grayscale":return Pe(s,t,e);case"channel-painter":return Re(s,t,e);case"brightness":return Oe(s,t,e);case"contrast":return Ee(s,t,e);case"opacity":return Ie(s,t,e);case"invert":return Le(s,t,e);case"hue-rotate":return Ge(s,t,e);case"saturate":return Ve(s,t,e);case"black-and-white":return je(s,t,e);case"sepia":return Ne(s,t,e);case"duotone":return Be(s,t,e);case"xray":return De(s,t,e);case"noise":return Fe(s,t,e);case"emboss":return Ue(s,t,e);case"film-grain":return ze(s,t,e);case"watercolor":return We(s,t,e);case"gouache":return Xe(s,t,e);case"ink-blot":return qe(s,t,e);case"crumpled-plastic":return Ye(s,t,e);case"riddled":return Ze(s,t,e);case"glow":return Je(s,t,e);case"inner-glow":return He(s,t,e);default:return b(t,e)}}function Ke(s,t){let e=t.filter(u=>u.enabled);if(e.length===0)return"";let n=e.some(u=>u.type==="gaussian-blur"&&u.quality==="high"||u.type==="motion-blur"&&u.quality==="high"),i=n?"500%":"300%",a=n?"-200%":"-100%",o="",l="SourceGraphic",h=0;for(let u of e){let c=`result${h++}`;o+=Qe(u,l,c),l=c}return`<filter${r("id",s)}${r("x",a)}${r("y",a)}${r("width",i)}${r("height",i)}${r("filterUnits","objectBoundingBox")}${r("primitiveUnits","userSpaceOnUse")}>${o}</filter>`}function H(s){let t="";for(let e of s){let n=e.state.filters;if(!n||n.length===0)continue;let i=n.filter(o=>o.enabled);if(i.length===0)continue;let a=`filter-${e.id}`;t+=Ke(a,i)}return t}function ts(s,t){return!t||t.length===0||t.filter(e=>e.enabled).length===0?"":` filter="url(#filter-${T(s)})"`}function es(s,t,e,n){let i=n?.strokeWidth!=null?Math.max(.5,t*n.strokeWidth):Math.max(1,t/10);switch(s){case"stripes":return[{tag:"rect",attrs:{width:n?.strokeWidth!=null?Math.max(.01,Math.min(1,n.strokeWidth))*t:t/2,height:t,fill:e}}];case"dots":{let a=n?.dotRadius!=null?Math.max(.05,Math.min(.45,n.dotRadius)):.25;return[{tag:"circle",attrs:{cx:t/2,cy:t/2,r:t*a,fill:e}}]}case"grid":return[{tag:"path",attrs:{d:`M ${t} 0 L 0 0 0 ${t}`,fill:"none",stroke:e,"stroke-width":i}}];case"checkerboard":return[{tag:"rect",attrs:{width:t/2,height:t/2,fill:e}},{tag:"rect",attrs:{x:t/2,y:t/2,width:t/2,height:t/2,fill:e}}];case"diagonal":{let a=n?.strokeWidth!=null?Math.max(.5,t*n.strokeWidth):Math.max(1,t/5);return[{tag:"path",attrs:{d:`M 0 ${t} L ${t} 0`,stroke:e,"stroke-width":a}}]}case"crosshatch":return[{tag:"path",attrs:{d:`M 0 ${t} L ${t} 0 M 0 0 L ${t} ${t}`,stroke:e,"stroke-width":i}}];case"zigzag":{let a=n?.amplitude!=null?Math.max(.05,Math.min(.5,n.amplitude)):.25,o=t*a;return[{tag:"path",attrs:{d:`M 0 ${o} L ${t/4} 0 L ${t/2} ${o} L ${t*3/4} 0 L ${t} ${o}`,fill:"none",stroke:e,"stroke-width":i}}]}case"waves":{let a=n?.amplitude!=null?Math.max(.05,Math.min(.5,n.amplitude)):.25,o=t*a,l=t/2;return[{tag:"path",attrs:{d:`M 0 ${l} Q ${t/4} ${l-o} ${t/2} ${l} T ${t} ${l}`,fill:"none",stroke:e,"stroke-width":i}}]}case"triangles":{let a=t*.866;return[{tag:"path",attrs:{d:`M ${t/2} 0 L ${t} ${a} L 0 ${a} Z`,fill:"none",stroke:e,"stroke-width":i}}]}case"hexagons":{let a=t*.866;return[{tag:"path",attrs:{d:`M ${t*.25} 0 L ${t*.75} 0 L ${t} ${a*.5} L ${t*.75} ${a} L ${t*.25} ${a} L 0 ${a*.5} Z`,fill:"none",stroke:e,"stroke-width":i}}]}case"diamonds":return[{tag:"path",attrs:{d:`M ${t/2} 0 L ${t} ${t/2} L ${t/2} ${t} L 0 ${t/2} Z`,fill:"none",stroke:e,"stroke-width":i}}];case"circles":return[{tag:"circle",attrs:{cx:t/2,cy:t/2,r:t/3,fill:"none",stroke:e,"stroke-width":i}}];case"bricks":{let a=n?.strokeWidth!=null?Math.max(.5,t*n.strokeWidth):Math.max(1,t/15);return[{tag:"rect",attrs:{x:0,y:0,width:t,height:t/2,fill:"none",stroke:e,"stroke-width":a}},{tag:"rect",attrs:{x:-t/2,y:t/2,width:t,height:t/2,fill:"none",stroke:e,"stroke-width":a}},{tag:"rect",attrs:{x:t/2,y:t/2,width:t,height:t/2,fill:"none",stroke:e,"stroke-width":a}}]}case"herringbone":return[{tag:"path",attrs:{d:`M 0 0 L ${t/2} ${t/2} L 0 ${t} M ${t/2} ${t/2} L ${t} 0 M ${t/2} ${t/2} L ${t} ${t}`,fill:"none",stroke:e,"stroke-width":i}}];default:return[]}}var ss="0 0 10 10";function rs(){return[{id:"line-marker-arrow",refX:10,refY:5,element:{tag:"path",attrs:{d:"M 0 0 L 10 5 L 0 10 Z",fill:"context-stroke",stroke:"context-stroke"}}},{id:"line-marker-open-arrow",refX:10,refY:5,element:{tag:"path",attrs:{d:"M 0 0 L 10 5 L 0 10",fill:"none",stroke:"context-stroke","stroke-width":1.5,"stroke-linejoin":"round","stroke-linecap":"round"}}},{id:"line-marker-circle",refX:5,refY:5,element:{tag:"circle",attrs:{cx:5,cy:5,r:3.2,fill:"context-stroke",stroke:"context-stroke"}}},{id:"line-marker-diamond",refX:5,refY:5,element:{tag:"path",attrs:{d:"M 5 0 L 10 5 L 5 10 L 0 5 Z",fill:"context-stroke",stroke:"context-stroke"}}},{id:"line-marker-square",refX:5,refY:5,element:{tag:"rect",attrs:{x:1.5,y:1.5,width:7,height:7,fill:"context-stroke",stroke:"context-stroke"}}}]}function $(s,t){return t==null||t===""?"":` ${s}="${T(String(t))}"`}function E(s,t){let e=s.rotation??0,n=s.skewX??0,i=s.skewY??0,a=s.scaleX??1,o=s.scaleY??1;if(e===0&&n===0&&i===0&&a===1&&o===1)return null;let l=s.customPivot??t;if(!l)return null;let h=[];return h.push(`translate(${l.x}, ${l.y})`),e!==0&&h.push(`rotate(${e})`),(a!==1||o!==1)&&h.push(`scale(${a}, ${o})`),n!==0&&h.push(`skewX(${n})`),i!==0&&h.push(`skewY(${i})`),h.push(`translate(${-l.x}, ${-l.y})`),h.join(" ")}function ns(s,t,e){let n=s.rotation??0,i=s.skewX??0,a=s.skewY??0,o=s.scaleX??1,l=s.scaleY??1,h=s.customPivot??{x:t,y:e},u=[];return(n!==0||i!==0||a!==0||o!==1||l!==1)&&(u.push(`translate(${h.x}, ${h.y})`),n!==0&&u.push(`rotate(${n})`),(o!==1||l!==1)&&u.push(`scale(${o}, ${l})`),i!==0&&u.push(`skewX(${i})`),a!==0&&u.push(`skewY(${a})`),u.push(`translate(${-h.x}, ${-h.y})`)),u.push(`translate(${t}, ${e})`),u.join(" ")}function is(s){if(typeof s=="string"){let n=s.trim();return n.length>0?n:void 0}if(!s||typeof s!="object")return;let t=s,e=[];return t.underline&&e.push("underline"),t.strikethrough&&e.push("line-through"),t.overline&&e.push("overline"),e.length>0?e.join(" "):void 0}function as(s){if(typeof s.strokeDasharray=="string")return s.strokeDasharray;let t=s.lineStyle??"solid",e=s.dashLength??8,n=s.gapLength??4;return Ct(t,e,n)}function At(s){return s.fillType||(s.fillGradient?s.fillGradient.r!==void 0?"radial-gradient":"linear-gradient":s.linearGradient?"linear-gradient":s.radialGradient?"radial-gradient":"solid")}function os(s){return s.fillGradient??s.linearGradient??s.radialGradient??void 0}function R(s,t){let e=$("data-shape-id",t),n=At(s);n==="none"?e+=$("fill","none"):n==="linear-gradient"||n==="radial-gradient"?e+=$("fill",`url(#gradient-fill-${t})`):n==="pattern"?e+=$("fill",`url(#pattern-fill-${t})`):e+=$("fill",s.fillColor??"#000000");let i=s.opacity;i!==void 0&&i<1&&(e+=$("opacity",i));let a=s.fillOpacity;a!==void 0&&a<1&&(e+=$("fill-opacity",a));let o=s.fillRule;o&&o!=="nonzero"&&(e+=$("fill-rule",o));let l=s.strokeType??"solid";l==="none"?e+=$("stroke","none"):l==="linear-gradient"||l==="radial-gradient"?e+=$("stroke",`url(#gradient-stroke-${t})`):e+=$("stroke",s.borderColor??"none");let h=s.borderWidth;h!=null&&(e+=$("stroke-width",h));let u=s.strokeOpacity;u!==void 0&&u<1&&(e+=$("stroke-opacity",u));let c=as(s);c&&(e+=$("stroke-dasharray",c),!s.strokeDasharray&&s.lineStyle==="dotted"&&(e+=$("stroke-linecap","round")));let p=s.dashOffset;p!==void 0&&p!==0&&(e+=$("stroke-dashoffset",p)),e+=ts(t,s.filters);let d=s.metadata;return d&&(d.role&&(e+=$("role",d.role)),d.ariaLabel&&(e+=$("aria-label",d.ariaLabel))),e}function ls(s){let t=s.metadata;if(!t)return"";let e="";return t.title&&(e+=`<title>${T(t.title)}</title>`),t.description&&(e+=`<desc>${T(t.description)}</desc>`),e}function us(s,t){let e=ls(t);if(!e)return s;let n=s.lastIndexOf("/>");if(n===-1){let o=s.indexOf(">");return o===-1?s:s.slice(0,o+1)+e+s.slice(o+1)}let i=s.match(/^<(\w+)/),a=i?i[1]:"g";return s.slice(0,n)+">"+e+`</${a}>`}function ot(s){let t="",e=s.startEndpoint,n=s.endEndpoint;return e&&e!=="none"&&(t+=$("marker-start",`url(#line-marker-${e})`)),n&&n!=="none"&&(t+=$("marker-end",`url(#line-marker-${n})`)),t}function hs(s){let t=s.state,e=t.x??0,n=t.y??0,i=t.radius??50,a=E(t,{x:e,y:n});return`<circle${$("cx",e)}${$("cy",n)}${$("r",i)}${R(t,s.id)}${a?$("transform",a):""}/>`}function cs(s){let t=s.state,e=t.cx??0,n=t.cy??0,i=t.rx??50,a=t.ry??30,o=E(t,{x:e,y:n});return`<ellipse${$("cx",e)}${$("cy",n)}${$("rx",i)}${$("ry",a)}${R(t,s.id)}${o?$("transform",o):""}/>`}function ps(s){let t=s.state,e=t,n=t.x??0,i=t.y??0,a=t.width??100,o=t.height??100,l=t.cornerRadius??0,h=e.cornerShape??"round",u=e.cornerMode??"uniform",c={x:n+a/2,y:i+o/2},p=E(t,c);if(h!=="round"||u==="non-uniform"){let d=ae(n,i,a,o,l,h,u,u==="non-uniform"?{radiusTL:e.cornerRadiusTL,radiusTR:e.cornerRadiusTR,radiusBR:e.cornerRadiusBR,radiusBL:e.cornerRadiusBL,shapeTL:e.cornerShapeTL,shapeTR:e.cornerShapeTR,shapeBR:e.cornerShapeBR,shapeBL:e.cornerShapeBL}:void 0);if(d)return`<path${$("d",d)}${R(t,s.id)}${p?$("transform",p):""}/>`}return`<rect${$("x",n)}${$("y",i)}${$("width",a)}${$("height",o)}${l>0?$("rx",l):""}${R(t,s.id)}${p?$("transform",p):""}/>`}function ds(s){let t=s.state,e=t.x1??0,n=t.y1??0,i=t.x2??100,a=t.y2??100,o={x:(e+i)/2,y:(n+a)/2},l=E(t,o);return`<line${$("x1",e)}${$("y1",n)}${$("x2",i)}${$("y2",a)}${R(t,s.id)}${ot(t)}${l?$("transform",l):""}/>`}function $s(s){let t=s.state,e=t.x??0,n=t.y??0,i=t.text??"",a=t.fontSize??16,o=t.fontFamily??"sans-serif",l=t.fontWeight??"normal",h=t.fontStyle??"normal",u=t.textAnchor??"start",c=is(t.textDecoration),p=t.letterSpacing,d=E(t,{x:e,y:n}),f=$("x",e)+$("y",n);f+=$("font-size",a),f+=$("font-family",o),l!=="normal"&&(f+=$("font-weight",l)),h!=="normal"&&(f+=$("font-style",h)),u!=="start"&&(f+=$("text-anchor",u)),c&&(f+=$("text-decoration",c)),p&&(f+=$("letter-spacing",p));let g=t.textDirection;g&&g!=="ltr"&&(f+=$("direction",g));let _=t.unicodeBidi;_&&_!=="normal"&&(f+=$("unicode-bidi",_));let m=t.fontVariationSettings;if(m&&Object.keys(m).length>0){let y=Object.entries(m).map(([x,v])=>`'${x}' ${v}`).join(", ");f+=$("style",`font-variation-settings: ${y}`)}if(f+=R(t,s.id),d&&(f+=$("transform",d)),t.isTextPath&&t.textPathPoints){let y=t.textPathPoints,x=t.textPathStartOffset??0,v=t.textPathSide,C=`text-path-${s.id}`,k="";if(y.length>=2)if(v==="right"){let w=y[y.length-1];k=`M ${w.x} ${w.y}`;for(let M=y.length-1;M>0;M--){let S=y[M],P=y[M-1],N=S.handleIn??S,$t=P.handleOut??P;k+=` C ${N.x} ${N.y}, ${$t.x} ${$t.y}, ${P.x} ${P.y}`}}else{k=`M ${y[0].x} ${y[0].y}`;for(let w=0;w<y.length-1;w++){let M=y[w],S=y[w+1],P=M.handleOut??M,N=S.handleIn??S;k+=` C ${P.x} ${P.y}, ${N.x} ${N.y}, ${S.x} ${S.y}`}}return`<defs><path id="${T(C)}"${$("d",k)} fill="none"/></defs><text${f}><textPath href="#${T(C)}"${$("startOffset",`${x}%`)}>${T(i)}</textPath></text>`}if(t.charOffsets&&Array.isArray(t.charOffsets)&&t.charOffsets.length>0){let y=Array.from(i),x=0,v=0,C="";for(let k=0;k<y.length;k++){let w=t.charOffsets[k]??{x:0,y:0,rotate:0},M=w.x-x,S=w.y-v,P=$("dx",M)+$("dy",S);w.rotate!==0&&(P+=$("rotate",w.rotate)),C+=`<tspan${P}>${T(y[k])}</tspan>`,x=w.x,v=w.y}return`<text${f}>${C}</text>`}return`<text${f}>${T(i)}</text>`}function fs(s){let t=s.state,e=t.splinePoints??[],n=t.splineCurveType??"CUBIC",i=t.splineClosed??!1,a=t.splineTension??.5,o=t.splineArcParams,l=oe(e,n,i,a,o),h=e.length>0?t.customPivot??{x:e[0].x,y:e[0].y}:void 0,u=h?E(t,h):null;return`<path${$("d",l)}${R(t,s.id)}${ot(t)}${u?$("transform",u):""}/>`}function gs(s){let t=s.state,e=t.polylinePoints??[],n=t.polylineClosed??!1,i=e.map(l=>`${l.x},${l.y}`).join(" "),a=e.length>0?t.customPivot??{x:e[0].x,y:e[0].y}:void 0,o=a?E(t,a):null;return`<${n?"polygon":"polyline"}${$("points",i)}${R(t,s.id)}${ot(t)}${o?$("transform",o):""}/>`}function ys(s){let t=s.state,e=t.x??0,n=t.y??0,i=t.width??100,a=t.height??100,o=t.href??"",l=t.imageOpacity,h=t.preserveAspectRatio?"xMidYMid meet":"none",u={x:e+i/2,y:n+a/2},c=E(t,u);return`<image${$("x",e)}${$("y",n)}${$("width",i)}${$("height",a)}${$("href",o)}${$("preserveAspectRatio",h)}${l!==void 0&&l<1?$("opacity",l):""}${R(t,s.id)}${c?$("transform",c):""}/>`}function ms(s){let t=s.state,e=t.cx??0,n=t.cy??0,i=t.radius??50,a=t.cornerRadius??0,o=t.shiftAngle??-90,l=t.fillRule??"nonzero",h=ns(t,e,n),u="";switch(s.type){case"triangle":u=G(mt(3,i,o),a,i);break;case"ngon":{let p=t.sides??6;u=G(mt(p,i,o),a,i);break}case"star":{let p=t.arms??5,d=t.innerRadiusPercent??50;u=G(Kt(p,i,d,o),a,i);break}case"cross":{let p=t.armWidthPercent??40;u=G(te(i,p,o),a,i);break}case"ring":{let p=t.innerRadiusPercent??50;u=se(i,p,l);break}case"spiral":{let p=t.turns??3,d=t.thicknessPercent??20,f=t.direction??1;u=re(i,p,d,f,o);break}case"gear":{let p=t.teeth??8,d=t.toothDepthPercent??30,f=t.holeRadiusPercent??0;u=ie(p,i,d,a,f,l,o);break}case"arrow":{let p=t.headWidthPercent??100,d=t.headLengthPercent??30,f=t.shaftWidthPercent??40;u=G(ee(i,p,d,f,o),a,i);break}default:return`<!-- unsupported polygon shape: ${T(s.type)} -->`}let c="";return(s.type==="ring"||s.type==="gear")&&(c=$("fill-rule",l)),`<path${$("d",u)}${c}${R(t,s.id)}${$("transform",h)}/>`}function F(s){let t;switch(s.type){case"circle":t=hs(s);break;case"ellipse":t=cs(s);break;case"rectangle":case"square":t=ps(s);break;case"line":t=ds(s);break;case"text":t=$s(s);break;case"spline":t=fs(s);break;case"polyline":t=gs(s);break;case"image":t=ys(s);break;case"triangle":case"ngon":case"star":case"cross":case"ring":case"spiral":case"gear":case"arrow":t=ms(s);break;default:return`<!-- unsupported shape type: ${T(s.type)} -->`}return us(t,s.state)}function Q(s){let t="";for(let e of s){let n=e.state,i=At(n),a=os(n),o=n.strokeType??"solid";i==="linear-gradient"&&a&&(t+=bt(`gradient-fill-${e.id}`,a)),i==="radial-gradient"&&a&&(t+=kt(`gradient-fill-${e.id}`,a)),i==="pattern"&&a&&(t+=_s(`pattern-fill-${e.id}`,a)),o==="linear-gradient"&&n.strokeGradient&&(t+=bt(`gradient-stroke-${e.id}`,n.strokeGradient)),o==="radial-gradient"&&n.strokeGradient&&(t+=kt(`gradient-stroke-${e.id}`,n.strokeGradient))}return t}function bt(s,t){let e=(t.stops??[]).map(n=>{let i=`<stop${$("offset",`${n.offset*100}%`)}${$("stop-color",n.color)}`;return n.opacity!==void 0&&n.opacity<1&&(i+=$("stop-opacity",n.opacity)),i+="/>",i}).join("");return`<linearGradient${$("id",s)}${$("x1",`${t.x1*100}%`)}${$("y1",`${t.y1*100}%`)}${$("x2",`${t.x2*100}%`)}${$("y2",`${t.y2*100}%`)}${t.spreadMethod?$("spreadMethod",t.spreadMethod):""}>${e}</linearGradient>`}function kt(s,t){let e=(t.stops??[]).map(o=>{let l=`<stop${$("offset",`${o.offset*100}%`)}${$("stop-color",o.color)}`;return o.opacity!==void 0&&o.opacity<1&&(l+=$("stop-opacity",o.opacity)),l+="/>",l}).join(""),n="",i=t.ry!==void 0&&t.ry!==t.r,a=!!t.rotation;if(i||a){let o=t.cx??.5,l=t.cy??.5,h=[];h.push(`translate(${o}, ${l})`),a&&h.push(`rotate(${t.rotation})`),i&&t.ry!==0&&h.push(`scale(1, ${t.ry/t.r})`),h.push(`translate(-${o}, -${l})`),n=$("gradientTransform",h.join(" "))}return`<radialGradient${$("id",s)}${$("cx",`${t.cx*100}%`)}${$("cy",`${t.cy*100}%`)}${$("fx",`${t.fx*100}%`)}${$("fy",`${t.fy*100}%`)}${$("r",`${t.r*100}%`)}${t.spreadMethod?$("spreadMethod",t.spreadMethod):""}${n}>${e}</radialGradient>`}function _s(s,t){if(t.svgContent!=null){let l=t.width??10,h=t.height??10,u=t.patternUnits??"userSpaceOnUse",c=t.patternContentUnits,p=t.patternTransform,d=t.viewBox,f=t.preserveAspectRatio,g=t.x??0,_=t.y??0,m=`<pattern${$("id",s)}`;return m+=$("patternUnits",u),c&&(m+=$("patternContentUnits",c)),g&&(m+=$("x",g)),_&&(m+=$("y",_)),m+=$("width",l),m+=$("height",h),d&&(m+=$("viewBox",d)),f&&(m+=$("preserveAspectRatio",f)),p&&(m+=$("patternTransform",p)),m+=`>${t.svgContent}</pattern>`,m}let e=10*(t.scale??1),n=t.rotation??0,i=t.color||"#000000",a=t.backgroundColor||"#ffffff",o="";return o+=`<rect${$("width",e)}${$("height",e)}${$("fill",a)}/>`,o+=xs(t.patternType,e,i),`<pattern${$("id",s)}${$("patternUnits","userSpaceOnUse")}${$("width",e)}${$("height",e)}${n?$("patternTransform",`rotate(${n})`):""}>${o}</pattern>`}function xs(s,t,e){return es(s,t,e).map(n=>{let i=Object.entries(n.attrs).map(([a,o])=>$(a,o)).join("");return`<${n.tag}${i}/>`}).join("")}function K(s){let t=new Set;for(let i of s){let a=i.state,o=a.startEndpoint,l=a.endEndpoint;o&&o!=="none"&&t.add(o),l&&l!=="none"&&t.add(l)}if(t.size===0)return"";let e=rs(),n="";for(let i of e){let a=i.id.replace("line-marker-","");if(!t.has(a))continue;let o=i.element,l=Object.entries(o.attrs).map(([u,c])=>$(u,c)).join(""),h=o.tag==="circle"||o.tag==="rect"?`<${o.tag}${l}/>`:`<${o.tag}${l}/>`;n+=`<marker${$("id",i.id)}${$("viewBox",ss)}${$("refX",i.refX)}${$("refY",i.refY)}${$("markerWidth",6)}${$("markerHeight",6)}${$("orient","auto-start-reverse")}>${h}</marker>`}return n}var bs={x:"x",y:"y",cx:"cx",cy:"cy",x1:"x1",y1:"y1",x2:"x2",y2:"y2",posX:"x",posY:"y",radius:"r",r:"r",rx:"rx",ry:"ry",width:"width",height:"height",opacity:"opacity",fillOpacity:"fill-opacity",strokeOpacity:"stroke-opacity",fillColor:"fill",strokeColor:"stroke",strokeWidth:"stroke-width",borderWidth:"stroke-width",cornerRadius:"rx",fontSize:"font-size"},ks=new Set(["rotation","skewX","skewY"]);function vs(s){let t=Nt[s];return t?t.join(" "):"0 0 1 1"}function J(s){return s.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function lt(s){return s.cycleDuration!==void 0&&s.cycleDuration>0?s.cycleDuration:s.keyframes.length===0?0:s.keyframes[s.keyframes.length-1].time}function ut(s,t){let e=s.keyframes;if(e.length===0)return{values:[],keyTimes:[],keySplines:[]};let n=e.map(o=>String(o.value)),i=e.map(o=>t>0?(o.time/t).toFixed(4):"0"),a=[];for(let o=1;o<e.length;o++)a.push(vs(e[o].easing));return{values:n,keyTimes:i,keySplines:a}}function ht(s){let t=s.beginTrigger;if(!t)return"0s";switch(t.type){case"time":return`${t.value}s`;case"event":return t.value;default:return"0s"}}function ct(s){return s.cycleInfinite?"indefinite":s.cycleRepeats&&s.cycleRepeats>1?String(s.cycleRepeats):null}function ws(s){let t=bs[s.property];if(!t)return"";let e=lt(s);if(e<=0)return"";let{values:n,keyTimes:i,keySplines:a}=ut(s,e);if(n.length<2)return"";let o=`<animate attributeName="${J(t)}"`;o+=` values="${J(n.join(";"))}"`,o+=` keyTimes="${i.join(";")}"`,a.length>0&&a.some(h=>h!=="0 0 1 1")&&(o+=' calcMode="spline"',o+=` keySplines="${a.join(";")}"`),o+=` dur="${e}s"`,o+=` begin="${ht(s)}"`;let l=ct(s);return l&&(o+=` repeatCount="${l}"`),o+=' fill="freeze"',o+="/>",o}function Ms(s){let t;switch(s.property){case"rotation":t="rotate";break;case"skewX":t="skewX";break;case"skewY":t="skewY";break;default:return""}let e=lt(s);if(e<=0)return"";let{values:n,keyTimes:i,keySplines:a}=ut(s,e);if(n.length<2)return"";let o=t==="rotate"&&s.transformOrigin?n.map(u=>`${u} ${s.transformOrigin.x} ${s.transformOrigin.y}`):n,l='<animateTransform attributeName="transform"';l+=` type="${t}"`,l+=` values="${J(o.join(";"))}"`,l+=` keyTimes="${i.join(";")}"`,a.length>0&&a.some(u=>u!=="0 0 1 1")&&(l+=' calcMode="spline"',l+=` keySplines="${a.join(";")}"`),l+=` dur="${e}s"`,l+=` begin="${ht(s)}"`;let h=ct(s);return h&&(l+=` repeatCount="${h}"`),l+=` additive="${s.additive??"sum"}"`,l+=' fill="freeze"',l+="/>",l}function Ss(s){if(!s.motionPath)return"";let t=lt(s);if(t<=0)return"";let{keyTimes:e,keySplines:n}=ut(s,t),i=s.keyframes.map(h=>{let u=typeof h.value=="number"?h.value:parseFloat(h.value);return Math.max(0,Math.min(1,u))}),a="<animateMotion";a+=` path="${J(s.motionPath)}"`,a+=` keyTimes="${e.join(";")}"`,a+=` keyPoints="${i.join(";")}"`,n.length>0&&n.some(h=>h!=="0 0 1 1")&&(a+=' calcMode="spline"',a+=` keySplines="${n.join(";")}"`),a+=` dur="${t}s"`,a+=` begin="${ht(s)}"`;let o=ct(s);o&&(a+=` repeatCount="${o}"`),a+=' fill="freeze"';let l=s.motionRotate??"auto";return a+=` rotate="${l}"`,a+="/>",a}function Cs(s){let t=new Map;for(let e of s.tracks){if(!e.enabled||e.keyframes.length<2)continue;let n=[...e.keyframes].sort((o,l)=>o.time-l.time),i={...e,locked:e.locked??!1,keyframes:n.map(o=>({time:o.time,value:o.value,easing:o.easing}))},a="";if(e.property==="pathMotion"&&e.motionPath?a=Ss(i):ks.has(e.property)?a=Ms(i):a=ws(i),a){let o=t.get(e.shapeId)??[];o.push(a),t.set(e.shapeId,o)}}return t}function pt(s,t={}){let{xmlDeclaration:e=!0,backgroundColor:n,indent:i=!0,className:a}=t,o=s.viewboxes?.[0],l=t.width??o?.width??800,h=t.height??o?.height??600,u=t.viewBox??`0 0 ${l} ${h}`,c=i?`
|
|
5
|
-
`:"",p=i?" ":"",d=s.shapes??[],f=Q(d),g=K(d),_=H(d),m=f.length>0||g.length>0||_.length>0,y="";m&&(y=`${c}${p}<defs>${c}`,f.length>0&&(y+=`${p}${p}${f}${c}`),g.length>0&&(y+=`${p}${p}${g}${c}`),_.length>0&&(y+=`${p}${p}${_}${c}`),y+=`${p}</defs>`);let x="";n&&(x=`${c}${p}<rect width="${l}" height="${h}" fill="${n}"/>`);let v=s.animationTimeline?Cs(s.animationTimeline):null,C=d.map(w=>{let M=F(w),S=v?.get(w.id);return S&&S.length>0&&(M=Ts(M,S,p)),`${p}${M}`}).join(c),k="";return e&&(k+=`<?xml version="1.0" encoding="UTF-8"?>${c}`),k+='<svg xmlns="http://www.w3.org/2000/svg"',k+=` width="${l}" height="${h}"`,k+=` viewBox="${u}"`,a&&(k+=` class="${a}"`),k+=">",k+=y,k+=x,d.length>0&&(k+=`${c}${C}`),k+=`${c}</svg>${c}`,k}function Ts(s,t,e){let n=t.join(""),i=s.lastIndexOf("/>");if(i!==-1){let o=s.match(/^<(\w+)/),l=o?o[1]:"g";return s.slice(0,i)+">"+n+`</${l}>`}let a=s.match(/<\/(\w+)>$/);if(a){let o=s.lastIndexOf(`</${a[1]}>`);return s.slice(0,o)+n+s.slice(o)}return s+n}function As(s,t){let e=D(s,t);return pt(s,{width:e.width,height:e.height,xmlDeclaration:t.xmlDeclaration??!1,indent:!0})}function Ps(s){return s==="class"?"className":s==="for"?"htmlFor":s.replace(/-([a-z])/g,(t,e)=>e.toUpperCase())}function X(s){return s.replace(/\s([a-z][a-z-]*?)=/g,(t,e)=>e.startsWith("data-")||e.startsWith("aria-")?t:` ${Ps(e)}=`)}function Rs(s,t){let e=t.componentName??"SvgComponent",n=D(s,t),i=t.indent??" ",a=s.shapes??[],o=t.typescript??!1,l=Q(a),h=K(a),u=H(a),c=l.length>0||h.length>0||u.length>0,p=a.map(f=>{let g=F(f);return`${i}${i}${i}${X(g)}`}),d=[];d.push("import React from 'react';"),d.push(""),o?(d.push(`interface ${e}Props {`),d.push(`${i}className?: string;`),d.push(`${i}style?: React.CSSProperties;`),d.push("}"),d.push(""),d.push(`const ${e}: React.FC<${e}Props> = ({ className, style }) => {`)):d.push(`const ${e} = ({ className, style }) => {`),d.push(`${i}return (`),d.push(`${i}${i}<svg xmlns="http://www.w3.org/2000/svg" width="${n.width}" height="${n.height}" viewBox="0 0 ${n.width} ${n.height}" className={className} style={style}>`),c&&(d.push(`${i}${i}${i}<defs>`),l.length>0&&d.push(`${i}${i}${i}${i}${X(l)}`),h.length>0&&d.push(`${i}${i}${i}${i}${X(h)}`),u.length>0&&d.push(`${i}${i}${i}${i}${X(u)}`),d.push(`${i}${i}${i}</defs>`));for(let f of p)d.push(f);return d.push(`${i}${i}</svg>`),d.push(`${i});`),d.push("};"),d.push(""),d.push(`export default ${e};`),d.push(""),d.join(`
|
|
6
|
-
`)}function Os(s,t){let e=t.componentName??"SvgComponent",n=D(s,t),i=t.indent??" ",a=s.shapes??[],o=t.typescript??!1,l=Q(a),h=K(a),u=H(a),c=l.length>0||h.length>0||u.length>0,p=a.map(f=>`${i}${i}${F(f)}`),d=[];d.push("<template>"),d.push(`${i}<svg xmlns="http://www.w3.org/2000/svg" width="${n.width}" height="${n.height}" viewBox="0 0 ${n.width} ${n.height}" :class="className" :style="style">`),c&&(d.push(`${i}${i}<defs>`),l.length>0&&d.push(`${i}${i}${i}${l}`),h.length>0&&d.push(`${i}${i}${i}${h}`),u.length>0&&d.push(`${i}${i}${i}${u}`),d.push(`${i}${i}</defs>`));for(let f of p)d.push(f);return d.push(`${i}</svg>`),d.push("</template>"),d.push(""),o?d.push('<script setup lang="ts">'):d.push("<script setup>"),d.push(`// ${e}`),o?(d.push("defineProps<{"),d.push(`${i}className?: string;`),d.push(`${i}style?: Record<string, string>;`),d.push("}>();")):(d.push("defineProps({"),d.push(`${i}className: { type: String, default: '' },`),d.push(`${i}style: { type: Object, default: () => ({}) },`),d.push("});")),d.push("</script>"),d.push(""),d.join(`
|
|
7
|
-
`)}var Es=new Set(["circle","ellipse","rectangle","square","line","text","image"]);function vt(s){return s.replace(/\\/g,"\\\\").replace(/'/g,"\\'")}function wt(s){return s.replace(/\\/g,"\\\\").replace(/`/g,"\\`").replace(/\$\{/g,"\\${")}function Is(s){if(!Es.has(s.type))return!0;let t=s.state.metadata;return!!(t?.title||t?.description||s.type==="text"&&s.state.isTextPath)}function Ls(s,t){let e=t.componentName??"createSvg",n=D(s,t),i=t.indent??" ",a=s.shapes??[],o=t.typescript??!1,l=[];l.push("import * as d3 from 'd3';"),l.push(""),o?l.push(`export function ${e}(container: string | HTMLElement): d3.Selection<SVGSVGElement, unknown, HTMLElement, unknown> {`):l.push(`export function ${e}(container) {`),l.push(`${i}const svg = d3.select(container)`),l.push(`${i}${i}.append('svg')`),l.push(`${i}${i}.attr('xmlns', 'http://www.w3.org/2000/svg')`),l.push(`${i}${i}.attr('width', ${n.width})`),l.push(`${i}${i}.attr('height', ${n.height})`),l.push(`${i}${i}.attr('viewBox', '0 0 ${n.width} ${n.height}');`),l.push("");let h=Q(a),u=K(a),c=H(a),p=`${h}${u}${c}`;p.length>0&&(l.push(`${i}svg.append('defs').html(\`${wt(p)}\`);`),l.push(""));for(let d=0;d<a.length;d++){let f=a[d];if(l.push(`${i}// ${f.type}${f.state.metadata?.name?` \u2014 ${f.state.metadata.name}`:""}`),Is(f)){l.push(`${i}svg.append('g').html(\`${wt(F(f))}\`);`),l.push("");continue}let g=$e(f),_=Tt(f),m=`shape${d+1}`;l.push(`${i}const ${m} = svg.append('${g}')`);for(let[y,x]of _)l.push(`${i}${i}.attr('${y}', '${vt(x)}')`);f.type==="text"&&f.state.text&&l.push(`${i}${i}.text('${vt(f.state.text)}')`),l[l.length-1]=l[l.length-1]+";",l.push("")}return l.push(`${i}return svg;`),l.push("}"),l.push(""),l.join(`
|
|
8
|
-
`)}function Mt(s,t){let e=s.state.metadata?.name;return e?e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,""):`${s.type}-${t+1}`}var Gs=new Set(["fill","fill-opacity","fill-rule","stroke","stroke-width","stroke-opacity","stroke-dasharray","stroke-linecap","opacity","transform","filter"]);function Vs(s,t){let e=D(s,t),n=t.indent??" ",i=s.shapes??[],a=[];for(let h=0;h<i.length;h++){let u=i[h],c=Mt(u,h),p=Tt(u),d=[];for(let[f,g]of p)Gs.has(f)&&d.push(`${n}${f}: ${g};`);d.length>0&&a.push(`.${c} {
|
|
9
|
-
${d.join(`
|
|
10
|
-
`)}
|
|
11
|
-
}`)}let o=[];for(let h=0;h<i.length;h++){let u=i[h],c=Mt(u,h),p=F(u),d=p.indexOf(" ");d!==-1&&(p=p.slice(0,d)+` class="${c}"`+p.slice(d)),o.push(`${n}${p}`)}let l=[];l.push("<style>");for(let h of a)l.push(h);l.push("</style>"),l.push(""),l.push(`<svg xmlns="http://www.w3.org/2000/svg" width="${e.width}" height="${e.height}" viewBox="0 0 ${e.width} ${e.height}">`);for(let h of o)l.push(h);return l.push("</svg>"),l.push(""),l.join(`
|
|
12
|
-
`)}function Pt(s,t){let e=js(s,t),n={...t};switch(n.format){case"svg":return As(e,n);case"react":return Rs(e,n);case"vue":return Os(e,n);case"d3":return Ls(e,n);case"css":return Vs(e,n);default:throw new Error(`Unsupported code format: ${n.format}`)}}function js(s,t){return Array.isArray(s)?{shapes:s,viewboxes:[{id:"default",x:0,y:0,width:t.width??800,height:t.height??600}]}:s}var I=new U.Command;I.name("svgsketch").description("CLI for working with SVGSketch .svgs documents").version("0.1.0");async function z(s){let t=(0,j.resolve)(s),e=(0,j.extname)(t).toLowerCase();e!==".svgs"&&console.error(`\u26A0 Warning: expected a .svgs file but got "${e||"(no extension)"}"`);try{await(0,L.access)(t)}catch{return console.error(`\u2717 File not found: ${t}`),process.exitCode=1,null}try{let n=await(0,L.readFile)(t,"utf-8");return{filePath:t,content:n}}catch(n){return console.error(`\u2717 Failed to read file: ${n.message}`),process.exitCode=1,null}}function et(s){let t=s.trim();if(!/^[+-]?(?:\d+\.?\d*|\.\d+)$/.test(t))throw new U.InvalidArgumentError("must be a valid number");let e=Number(t);if(!Number.isFinite(e))throw new U.InvalidArgumentError("must be a finite number");return e}function st(s,t){return s===void 0?!0:isNaN(s)||s<=0||!isFinite(s)?(console.error(`\u2717 Invalid ${t}: must be a positive number`),process.exitCode=1,!1):!0}I.command("validate").description("Validate a .svgs document").argument("<input>","Path to the .svgs file").option("--json","Output result as JSON").action(async(s,t)=>{let e=await z(s);if(!e)return;let{filePath:n,content:i}=e,a;try{a=V(i)}catch(l){t.json?console.log(JSON.stringify({valid:!1,file:n,error:l.message},null,2)):console.error(`\u2717 Parse error: ${l.message}`),process.exitCode=1;return}let o=it(a);if(t.json)console.log(JSON.stringify({valid:o.valid,file:n,version:a.schemaVersion??"unknown",shapes:a.shapes?.length??0,warnings:o.warnings.map(l=>l.message),errors:o.errors.map(l=>l.message)},null,2));else if(o.valid){let l=a.shapes?.length??0;if(console.log(`\u2713 Valid .svgs document (v${a.schemaVersion??"?"}, ${l} shape${l!==1?"s":""})`),o.warnings.length>0)for(let h of o.warnings)console.log(` \u26A0 ${h.message}`)}else{console.error("\u2717 Invalid document:");for(let l of o.errors)console.error(` \u2022 ${l.message}`);process.exitCode=1}});I.command("render").description("Render a .svgs document to SVG").argument("<input>","Path to the .svgs file").requiredOption("-o, --output <path>","Output file path (.svg)").option("-w, --width <n>","Override canvas width",et).option("-H, --height <n>","Override canvas height",et).option("--background <color>","Background color (e.g. #ffffff)").option("--no-xml-declaration","Omit the XML declaration").option("--var <key=value...>","Set template variable (repeatable)",(s,t)=>[...t,s],[]).action(async(s,t)=>{if(!st(t.width,"width")||!st(t.height,"height"))return;let e=await z(s);if(!e)return;let{content:n}=e,i;try{i=V(n)}catch(h){console.error(`Error parsing document: ${h.message}`),process.exitCode=1;return}if(t.var&&t.var.length>0)try{let h=at(t.var);i=B(i,h)}catch(h){console.error(`Error parsing variables: ${h.message}`),process.exitCode=1;return}else i=B(i);let a={width:t.width,height:t.height,backgroundColor:t.background,xmlDeclaration:t.xmlDeclaration},o=pt(i,a),l=(0,j.resolve)(t.output);try{await(0,L.writeFile)(l,o,"utf-8")}catch(h){console.error(`\u2717 Failed to write output: ${h.message}`),process.exitCode=1;return}console.log(`\u2713 Rendered ${i.shapes?.length??0} shapes \u2192 ${l}`)});I.command("info").description("Display document metadata").argument("<input>","Path to the .svgs file").option("--json","Output result as JSON").action(async(s,t)=>{let e=await z(s);if(!e)return;let{filePath:n,content:i}=e,a;try{a=V(i)}catch(d){console.error(`Error parsing document: ${d.message}`),process.exitCode=1;return}let o=a.shapes??[],l={};for(let d of o)l[d.type]=(l[d.type]??0)+1;let h=a.viewboxes?.[0],u=a.documentMetadata,c=a.templateVariables??[],p={file:n,schemaVersion:a.schemaVersion??"unknown",currentVersion:O,canvas:{width:h?.width??"?",height:h?.height??"?"},metadata:u?{title:u.title||void 0,description:u.description||void 0,author:u.author||void 0,keywords:u.keywords&&u.keywords.length>0?u.keywords:void 0,language:u.language||void 0,license:u.license||void 0}:void 0,templateVariables:c.length>0?c.length:void 0,shapes:{total:o.length,byType:l}};if(t.json)console.log(JSON.stringify(p,null,2));else if(console.log(`File: ${p.file}`),console.log(`Version: ${p.schemaVersion} (current: ${p.currentVersion})`),console.log(`Canvas: ${p.canvas.width}\xD7${p.canvas.height}`),u&&(u.title&&console.log(`Title: ${u.title}`),u.author&&console.log(`Author: ${u.author}`),u.description&&console.log(`Description: ${u.description}`),u.language&&console.log(`Language: ${u.language}`),u.license&&console.log(`License: ${u.license}`),u.keywords&&u.keywords.length>0&&console.log(`Keywords: ${u.keywords.join(", ")}`)),c.length>0&&console.log(`Variables: ${c.length}`),console.log(`Shapes: ${p.shapes.total}`),Object.keys(l).length>0)for(let[d,f]of Object.entries(l).sort())console.log(` ${d}: ${f}`)});I.command("vars").description("List template variables defined in a .svgs document").argument("<input>","Path to the .svgs file").option("--json","Output result as JSON").action(async(s,t)=>{let e=await z(s);if(!e)return;let{content:n}=e,i;try{i=V(n)}catch(l){console.error(`Error parsing document: ${l.message}`),process.exitCode=1;return}let{defined:a,undeclared:o}=St(i);if(t.json)console.log(JSON.stringify({defined:a,undeclared:o},null,2));else{if(a.length===0&&o.length===0){console.log("No template variables found.");return}if(a.length>0){console.log("Defined variables:");for(let l of a){let h=l.label?` (${l.label})`:"";console.log(` {{${l.name}}}${h} [${l.type}] default: ${l.defaultValue||"(empty)"}`)}}if(o.length>0){console.log("Undeclared references (used but not defined):");for(let l of o)console.log(` \u26A0 {{${l}}}`)}}});var dt=["svg","react","vue","d3","css"];I.command("codegen").description("Generate code from a .svgs document (React, Vue, D3, CSS, or raw SVG)").argument("<input>","Path to the .svgs file").requiredOption("-f, --format <format>",`Output format: ${dt.join(", ")}`).option("-o, --output <path>","Output file path (prints to stdout if omitted)").option("--name <name>","Component/function name (default: SvgComponent)").option("-w, --width <n>","Override canvas width",et).option("-H, --height <n>","Override canvas height",et).option("--typescript","Use TypeScript syntax (React, Vue, D3)").option("--var <key=value...>","Set template variable (repeatable)",(s,t)=>[...t,s],[]).action(async(s,t)=>{if(!st(t.width,"width")||!st(t.height,"height"))return;let e=t.format;if(!dt.includes(e)){console.error(`\u2717 Invalid format "${t.format}". Valid formats: ${dt.join(", ")}`),process.exitCode=1;return}let n=await z(s);if(!n)return;let{content:i}=n,a;try{a=V(i)}catch(l){console.error(`Error parsing document: ${l.message}`),process.exitCode=1;return}if(t.var&&t.var.length>0)try{let l=at(t.var);a=B(a,l)}catch(l){console.error(`Error parsing variables: ${l.message}`),process.exitCode=1;return}else a=B(a);let o=Pt(a,{format:e,componentName:t.name,width:t.width,height:t.height,typescript:t.typescript??!1});if(t.output){let l=(0,j.resolve)(t.output);try{await(0,L.writeFile)(l,o,"utf-8")}catch(h){console.error(`\u2717 Failed to write output: ${h.message}`),process.exitCode=1;return}console.log(`\u2713 Generated ${e} code \u2192 ${l}`)}else process.stdout.write(o)});var Rt="https://docs.svgsketch.com",tt={document:{url:"/sdk/document/",description:"Document class API"},shapes:{url:"/sdk/shapes/",description:"Shape builders (Circle, Rectangle, Text, ...)"},styles:{url:"/sdk/styles/",description:"Gradients & patterns"},filters:{url:"/sdk/filters/",description:"Filter effects (shadow, blur, artistic, ...)"},animation:{url:"/sdk/animation/",description:"Timeline & Track animation builders"},types:{url:"/sdk/types/",description:"TypeScript types & interfaces"},cli:{url:"/cli/",description:"CLI command reference"},format:{url:"/format/",description:".svgs file format specification"}};I.command("docs").description("Open SDK documentation or show a quick reference").argument("[section]","Section to open: "+Object.keys(tt).join(", ")).option("--url","Print the URL instead of opening the browser").option("--list","List all available documentation sections").action(async(s,t)=>{if(t.list){console.log(`Available documentation sections:
|
|
13
|
-
`);for(let[o,{description:l}]of Object.entries(tt))console.log(` ${o.padEnd(12)} ${l}`);console.log(`
|
|
14
|
-
Usage: svgsketch docs [section]`),console.log(" svgsketch docs --url [section]");return}let e=Rt+"/sdk/";if(s){let o=tt[s.toLowerCase()];if(!o){console.error(`\u2717 Unknown section "${s}". Available: ${Object.keys(tt).join(", ")}`),process.exitCode=1;return}e=Rt+o.url}if(t.url){console.log(e);return}let{exec:n}=await import("child_process"),{platform:i}=await import("os"),a=i()==="win32"?`start "" "${e}"`:i()==="darwin"?`open "${e}"`:`xdg-open "${e}"`;n(a,o=>{o&&console.log(e)})});I.parseAsync().catch(s=>{console.error(`\u2717 ${s instanceof Error?s.message:String(s)}`),process.exitCode=1});
|