@svgsketch/core 1.7.0 → 1.8.0

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/dist/index.js CHANGED
@@ -1,15 +1,15 @@
1
- "use strict";var hr=Object.defineProperty;var si=Object.getOwnPropertyDescriptor;var ai=Object.getOwnPropertyNames;var oi=Object.prototype.hasOwnProperty;var li=(r,e)=>{for(var t in e)hr(r,t,{get:e[t],enumerable:!0})},ui=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of ai(e))!oi.call(r,i)&&i!==t&&hr(r,i,{get:()=>e[i],enumerable:!(n=si(e,i))||n.enumerable});return r};var ci=r=>ui(hr({},"__esModule",{value:!0}),r);var ro={};li(ro,{Arrow:()=>qt,Audio:()=>lr,BUILTIN_MARKER_ID_MAP:()=>Rr,COMMON_TRANSFORM_NODE_DEFAULTS:()=>mi,CURRENT_SCHEMA_VERSION:()=>j,Circle:()=>Dt,Cloud:()=>Qt,Container:()=>rr,ContainerShapeBuilder:()=>ce,Cross:()=>Wt,DEFAULT_COORDINATE_PRECISION:()=>gn,Document:()=>It,EASING_CURVES:()=>Ne,EVENT_TRIGGER_OPTIONS:()=>fi,EasingType:()=>pr,Ellipse:()=>Bt,Gear:()=>Yt,Heart:()=>Zt,Hyperlink:()=>er,IDENTITY_AFFINE:()=>un,ImageShape:()=>dr,LIBRARY_EMIT_ORDER:()=>Vr,Lightning:()=>Kt,Line:()=>zt,LinearGradientBuilder:()=>De,MARKER_HEIGHT:()=>kt,MARKER_VIEWBOX:()=>Ee,MARKER_WIDTH:()=>St,MAX_COORDINATE_PRECISION:()=>bn,MIGRATIONS:()=>vr,NGon:()=>Vt,NUMERIC_SHAPE_TRANSFORM_STATE_KEYS:()=>ve,NestedSvg:()=>ir,PUZZLE_DEFAULTS:()=>tn,Path:()=>ur,PathCurveType:()=>mr,PathPointType:()=>ln,PatternBuilder:()=>Oe,Polyline:()=>cr,RadialGradientBuilder:()=>Be,Rectangle:()=>Ot,Ring:()=>Xt,SHAPE_TRANSFORM_STATE_KEYS:()=>pi,ShapeBuilder:()=>U,ShapeReference:()=>sr,SpeechBubble:()=>Jt,Spiral:()=>jt,Square:()=>Gt,Star:()=>Ht,Switch:()=>tr,Text:()=>Ut,Timeline:()=>Et,Track:()=>Lt,Triangle:()=>Nt,Video:()=>or,View:()=>nr,affine:()=>le,affineFromArray:()=>Ve,affineToArray:()=>ue,around:()=>yr,canonicalPolygonTransformString:()=>xr,canonicalTransformString:()=>ge,collectReferencedLibraryIds:()=>In,composeLegacyTransformMatrix:()=>Te,computeArrowVertices:()=>at,computeCloudPath:()=>ct,computeCrossVertices:()=>st,computeDashArray:()=>$e,computeGearPath:()=>ht,computeGearVertices:()=>Tr,computeHeartPath:()=>ut,computeLightningVertices:()=>lt,computePolygonVertices:()=>Ie,computeRectanglePath:()=>pt,computeRingPath:()=>dt,computeSpeechBubbleVertices:()=>ot,computeSpiralPath:()=>ft,computeSplinePath:()=>ye,computeStarVertices:()=>it,createDocument:()=>je,createShape:()=>pn,createViewbox:()=>Re,defaultVariableMode:()=>hi,escXml:()=>O,extractVariables:()=>et,filterAttr:()=>$t,foldLegacyAncestorTransformIntoMatrix:()=>$r,generateCode:()=>Ct,generateCssCode:()=>Rt,generateD3Code:()=>Mt,generateId:()=>T,generatePatternSvgContent:()=>xt,generatePuzzlePieces:()=>jn,generateReactCode:()=>At,generateSudokuPuzzle:()=>ii,generateSvgCode:()=>Tt,generateVueCode:()=>Ft,getBuiltInMarkerDefs:()=>Pn,getEasingCubicBezier:()=>di,getEffectivePrecision:()=>yn,getMarkerDescriptors:()=>he,getPatternElements:()=>Le,isFiniteAffineArray:()=>pe,isIdentityAffine:()=>br,linearGradient:()=>zn,matrixTransformPart:()=>gr,migrateSnapshot:()=>Xe,multiplyAffine:()=>z,parseDocument:()=>qe,parseSvgTransformList:()=>He,parseVariableArgs:()=>mn,pattern:()=>Nn,radialGradient:()=>Un,renderAnimationElements:()=>wt,renderBuiltinMarkerDefs:()=>ie,renderCircle:()=>Lr,renderEllipse:()=>Er,renderFilterDefs:()=>wn,renderFilterLibraryDef:()=>Zr,renderFilterPrimitive:()=>yt,renderFilterPrimitivesForType:()=>Fr,renderImage:()=>Ur,renderLibraryDef:()=>Hr,renderLibraryDefs:()=>Kr,renderLine:()=>Br,renderLinearGradientLibraryDef:()=>jr,renderMarkerLibraryDef:()=>Xr,renderPatternLibraryDef:()=>qr,renderPolygonShape:()=>Nr,renderPolyline:()=>zr,renderRadialGradientLibraryDef:()=>Yr,renderRectangle:()=>Dr,renderReferencedLibraryDefs:()=>se,renderShape:()=>H,renderSpline:()=>Gr,renderSvgPrimitiveChainFilter:()=>Ar,renderSymbolLibraryDef:()=>Wr,renderText:()=>Or,renderToSvg:()=>Se,rotateAffine:()=>me,roundCoord:()=>rt,roundNumberString:()=>_r,roundSerializedShape:()=>tt,roundSnapshot:()=>$n,scaleAffine:()=>_e,skewXAffine:()=>we,skewYAffine:()=>Pe,solveSudoku:()=>ze,stringifyDocument:()=>Ye,substituteString:()=>Ze,substituteVariables:()=>Je,translateAffine:()=>K,validateSnapshot:()=>Me,validateSudokuPuzzle:()=>ni,verticesToPath:()=>J});module.exports=ci(ro);var pr=(A=>(A.LINEAR="linear",A.EASE="ease",A.EASE_IN="ease-in",A.EASE_OUT="ease-out",A.EASE_IN_OUT="ease-in-out",A.EASE_IN_QUAD="ease-in-quad",A.EASE_OUT_QUAD="ease-out-quad",A.EASE_IN_OUT_QUAD="ease-in-out-quad",A.EASE_IN_CUBIC="ease-in-cubic",A.EASE_OUT_CUBIC="ease-out-cubic",A.EASE_IN_OUT_CUBIC="ease-in-out-cubic",A.EASE_IN_QUART="ease-in-quart",A.EASE_OUT_QUART="ease-out-quart",A.EASE_IN_OUT_QUART="ease-in-out-quart",A.EASE_IN_SINE="ease-in-sine",A.EASE_OUT_SINE="ease-out-sine",A.EASE_IN_OUT_SINE="ease-in-out-sine",A.EASE_IN_QUINT="ease-in-quint",A.EASE_OUT_QUINT="ease-out-quint",A.EASE_IN_OUT_QUINT="ease-in-out-quint",A.EASE_IN_EXPO="ease-in-expo",A.EASE_OUT_EXPO="ease-out-expo",A.EASE_IN_OUT_EXPO="ease-in-out-expo",A.EASE_IN_CIRC="ease-in-circ",A.EASE_OUT_CIRC="ease-out-circ",A.EASE_IN_OUT_CIRC="ease-in-out-circ",A.EASE_IN_BACK="ease-in-back",A.EASE_OUT_BACK="ease-out-back",A.EASE_IN_OUT_BACK="ease-in-out-back",A.CUSTOM_BEZIER="custom-bezier",A.LINEAR_FUNCTION="linear-function",A.STEPS="steps",A))(pr||{}),Ne={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-quint":[.755,.05,.855,.06],"ease-out-quint":[.23,1,.32,1],"ease-in-out-quint":[.86,0,.07,1],"ease-in-expo":[.95,.05,.795,.035],"ease-out-expo":[.19,1,.22,1],"ease-in-out-expo":[1,0,0,1],"ease-in-circ":[.6,.04,.98,.335],"ease-out-circ":[.075,.82,.165,1],"ease-in-out-circ":[.785,.135,.15,.86],"ease-in-back":[.6,-.28,.735,.045],"ease-out-back":[.175,.885,.32,1.275],"ease-in-out-back":[.68,-.55,.265,1.55],"custom-bezier":null,"linear-function":null,steps:null};function di(r){let e=Ne[r];return e?`cubic-bezier(${e.join(", ")})`:"linear"}var fi=[{value:"click",label:"Click"},{value:"mouseenter",label:"Mouse Enter"},{value:"mouseleave",label:"Mouse Leave"},{value:"focus",label:"Focus"},{value:"blur",label:"Blur"},{value:"load",label:"Page Load"}];var mr=(l=>(l.LINEAR="linear",l.QUADRATIC="quadratic",l.CUBIC="cubic",l.CATMULL_ROM="catmull-rom",l.ARC="arc",l.BASIS="basis",l.MIXED="mixed",l))(mr||{}),ln=(n=>(n.SMOOTH="smooth",n.CORNER="corner",n.SYMMETRIC="symmetric",n))(ln||{});function hi(r){return r==="color"?"live":"stamped"}var j=4;var pi=["transformMatrix","scaleX","scaleY","translateX","translateY","rotation","skewX","skewY","customPivot","rawTransform"],ve=["transformMatrix","scaleX","scaleY","translateX","translateY","rotation","skewX","skewY"],mi={transformMatrix:null,translateX:0,translateY:0,rotation:0,skewX:0,skewY:0,customPivot:null,rawTransform:null};var un=[1,0,0,1,0,0];function le(r,e,t,n,i,a){return[r,e,t,n,i,a]}function Ve(r){return le(r[0]??1,r[1]??0,r[2]??0,r[3]??1,r[4]??0,r[5]??0)}function ue(r){return[r[0],r[1],r[2],r[3],r[4],r[5]]}function pe(r){return Array.isArray(r)&&r.length>=6&&r.slice(0,6).every(Number.isFinite)}function br(r,e=1e-9){return Math.abs((r[0]??1)-1)<=e&&Math.abs(r[1]??0)<=e&&Math.abs(r[2]??0)<=e&&Math.abs((r[3]??1)-1)<=e&&Math.abs(r[4]??0)<=e&&Math.abs(r[5]??0)<=e}function z(r,e){return le(r[0]*e[0]+r[2]*e[1],r[1]*e[0]+r[3]*e[1],r[0]*e[2]+r[2]*e[3],r[1]*e[2]+r[3]*e[3],r[0]*e[4]+r[2]*e[5]+r[4],r[1]*e[4]+r[3]*e[5]+r[5])}function K(r,e=0){return le(1,0,0,1,r,e)}function _e(r,e=r){return le(r,0,0,e,0,0)}function me(r){let e=r*Math.PI/180;return le(Math.cos(e),Math.sin(e),-Math.sin(e),Math.cos(e),0,0)}function we(r){return le(1,0,Math.tan(r*Math.PI/180),1,0,0)}function Pe(r){return le(1,Math.tan(r*Math.PI/180),0,1,0,0)}function yr(r,e){return z(z(K(r.x,r.y),e),K(-r.x,-r.y))}function He(r){let e=un;if(!r)return e;let t=/(translate|scale|rotate|matrix|skewX|skewY)\s*\(([^)]+)\)/gi,n;for(;(n=t.exec(r))!==null;){let i=n[1].toLowerCase(),a=n[2].trim().split(/[\s,]+/).map(Number).filter(Number.isFinite),o=null;switch(i){case"translate":o=K(a[0]||0,a[1]??0);break;case"scale":o=_e(a[0]||1,a[1]??a[0]??1);break;case"rotate":o=a.length>=3?yr({x:a[1],y:a[2]},me(a[0]||0)):me(a[0]||0);break;case"matrix":a.length>=6&&(o=Ve(a));break;case"skewx":o=we(a[0]||0);break;case"skewy":o=Pe(a[0]||0);break}o&&(e=z(e,o))}return e}function gr(r){return!pe(r)||br(r)?null:`matrix(${r[0]}, ${r[1]}, ${r[2]}, ${r[3]}, ${r[4]}, ${r[5]})`}function Te(r,e){let t=r.translateX??0,n=r.translateY??0,i=typeof r.rawTransform=="string"?r.rawTransform:"",a=K(t,n);if(i)return z(a,He(i));let o=r.rotation??0,l=r.skewX??0,u=r.skewY??0,c=r.scaleX??1,f=r.scaleY??1;if(o===0&&l===0&&u===0&&c===1&&f===1)return a;let d=r.customPivot??e;if(!d)return a;let m=z(z(z(me(o),_e(c,f)),we(l)),Pe(u));return z(a,yr(d,m))}function ge(r,e){let t=gr(r.transformMatrix);return t||(gr(ue(Te(r,e)))??null)}function $r(r,e){let t=r.ancestorTransform;if(!pe(t)){delete r.ancestorTransform;return}if(br(t)){delete r.ancestorTransform;return}let n=pe(r.transformMatrix)?Ve(r.transformMatrix):Te(r,e);r.transformMatrix=ue(z(Ve(t),n)),delete r.ancestorTransform}function xr(r,e,t){let n=ge(r,{x:e,y:t});return n?`${n} translate(${e}, ${t})`:`translate(${e}, ${t})`}function dn(r){let e=r.customPivot;if(e)return e;let t=r.x,n=r.y,i=r.width,a=r.height;if(typeof t=="number"&&typeof n=="number"&&typeof i=="number"&&typeof a=="number")return{x:t+i/2,y:n+a/2};let o=r.radius;if(typeof t=="number"&&typeof n=="number"&&typeof o=="number")return{x:t,y:n};let l=r.cx,u=r.cy;if(typeof l=="number"&&typeof u=="number")return{x:l,y:u};let c=r.x1,f=r.y1,d=r.x2,m=r.y2;if(typeof c=="number"&&typeof f=="number"&&typeof d=="number"&&typeof m=="number")return{x:(c+d)/2,y:(f+m)/2};let p=r.pathPoints;if(p?.[0])return{x:p[0].x,y:p[0].y};let b=r.polylinePoints;if(b?.[0])return{x:b[0].x,y:b[0].y}}function Ae(r){if(Array.isArray(r))for(let e of r){$r(e.state,dn(e.state));let t=e.state.children;Ae(t)}}function gi(r){Ae(r.shapes);for(let e of r.library??[])if(e.kind==="symbol"){Ae(e.shapes);for(let t of Object.values(e.variants??{}))Ae(t)}else e.kind==="marker"&&Ae(e.shapes);return r.schemaVersion=3,r}function Sr(r){let e=r;return e&&typeof e.x=="number"&&Number.isFinite(e.x)&&typeof e.y=="number"&&Number.isFinite(e.y)?{x:e.x,y:e.y}:null}function bi(r,e){let t=r.translateX??0,n=r.translateY??0,i=typeof r.rawTransform=="string"?r.rawTransform:"",a=K(t,n);if(i)return ue(z(a,He(i)));let o=r.rotation??0,l=r.skewX??0,u=r.skewY??0;if(o!==0||l!==0||u!==0){let d=Sr(r.customPivot)??e??Sr(r.scaleAnchor);d&&(a=z(a,K(d.x,d.y)),o!==0&&(a=z(a,me(o))),l!==0&&(a=z(a,we(l))),u!==0&&(a=z(a,Pe(u))),a=z(a,K(-d.x,-d.y)))}let c=r.scaleX??1,f=r.scaleY??1;if(c!==1||f!==1){let d=Sr(r.scaleAnchor)??e;d&&(a=z(a,K(d.x,d.y)),a=z(a,_e(c,f)),a=z(a,K(-d.x,-d.y)))}return ue(a)}function Fe(r){if(Array.isArray(r))for(let e of r){let t=e.state;"scaleAnchor"in t&&(e.type==="text"&&!pe(t.transformMatrix)&&(t.transformMatrix=bi(t,dn(t))),delete t.scaleAnchor);let n=e.state.children;Fe(n)}}function yi(r){Fe(r.shapes);for(let e of r.library??[])if(e.kind==="symbol"){Fe(e.shapes);for(let t of Object.values(e.variants??{}))Fe(t)}else e.kind==="marker"&&Fe(e.shapes);return r.schemaVersion=4,r}function $i(r){let e=Array.isArray(r.library)?[...r.library]:[],t=new Set(e.map(u=>u.id));if(Array.isArray(r.symbols))for(let u of r.symbols)!u||t.has(u.id)||(e.push({...u,kind:"symbol"}),t.add(u.id));if(Array.isArray(r.markers))for(let u of r.markers)!u||t.has(u.id)||(e.push({...u,kind:"marker"}),t.add(u.id));let n=new Map,i=(u,c)=>{let{id:f,sourceId:d,...m}=u,p=JSON.stringify({kind:c,...m}),b=n.get(p);if(b)return b;let g=t.has(u.id)?`grd-${We()}`:u.id;t.add(g),n.set(p,g);let y=c==="linear-gradient"?{kind:"linear-gradient",id:g,name:u.sourceId??g,sourceId:u.sourceId,gradient:cn(u)}:{kind:"radial-gradient",id:g,name:u.sourceId??g,sourceId:u.sourceId,gradient:cn(u)};return e.push(y),g},a=new Map;if(Array.isArray(r.customPatterns))for(let u of r.customPatterns){if(!u)continue;let c=t.has(u.id)?`pat-${We()}`:u.id;t.add(c),a.set(u.id,c),e.push(xi(u,c))}let o=u=>{if(u.customPatternId){let S=a.get(u.customPatternId);if(S)return S}let{id:c,sourceId:f,customPatternId:d,...m}=u,p=JSON.stringify({kind:"pattern",...m}),b=n.get(p);if(b)return b;let g=t.has(u.id)?`pat-${We()}`:u.id;t.add(g),n.set(p,g);let y={kind:"pattern",id:g,name:u.sourceId??g,sourceId:u.sourceId,pattern:m};return e.push(y),g};for(let u of r.shapes??[]){let c=u.state;if(!c)continue;let f=c.fillGradient;f&&(f.type==="linear-gradient"||f.type==="radial-gradient"?c.fillLibraryId=i(f,f.type):f.type==="pattern"&&(c.fillLibraryId=o(f)));let d=c.strokeGradient;d&&(d.type==="linear-gradient"||d.type==="radial-gradient"?c.strokeLibraryId=i(d,d.type):d.type==="pattern"&&(c.strokeLibraryId=o(d)));let m=c.filters;if(Array.isArray(m)&&m.length>0){let p=l(m,c,u.id);c.filterLibraryIds=[p]}}return r.library=e,r;function l(u,c,f){let d={filters:u,colorInterpolation:c.filterColorInterpolation,filterUnits:c.filterUnits,primitiveUnits:c.primitiveUnits,x:c.filterX,y:c.filterY,width:c.filterWidth,height:c.filterHeight},m=JSON.stringify({kind:"filter",...d}),p=n.get(m);if(p)return p;let b=`filter-${f}`,g=t.has(b)?`flt-${We()}`:b;t.add(g),n.set(m,g);let y={kind:"filter",id:g,name:g,filters:d.filters,...d.colorInterpolation?{colorInterpolation:d.colorInterpolation}:{},...d.filterUnits?{filterUnits:d.filterUnits}:{},...d.primitiveUnits?{primitiveUnits:d.primitiveUnits}:{},...d.x!==void 0?{x:d.x}:{},...d.y!==void 0?{y:d.y}:{},...d.width!==void 0?{width:d.width}:{},...d.height!==void 0?{height:d.height}:{}};return e.push(y),g}}function xi(r,e){return{kind:"pattern",id:e,name:r.name??e,pattern:{type:"pattern",svgContent:r.svgContent,width:r.width,height:r.height,patternType:"custom",color:"#000000",backgroundColor:"transparent",scale:1,rotation:0,opacity:1,patternUnits:"userSpaceOnUse"}}}function cn(r){let{id:e,sourceId:t,...n}=r;return n}var kr=0;function We(){return kr=kr+1&65535,`${Date.now().toString(36)}-${kr.toString(36)}`}var vr=Object.freeze({1:$i,2:gi,3:yi});function Si(r){let e=r.schemaVersion;return typeof e!="number"||!Number.isFinite(e)||e<1?1:Math.floor(e)}function Xe(r,e=vr){let t=JSON.parse(JSON.stringify(r)),n=Si(t);if(n>j)return t;if(n===j)return t.schemaVersion=j,t;for(;n<j;){let i=e[n];if(!i)throw new Error(`[svgsketch/core] No migration registered for schema version ${n} \u2192 ${n+1}. Cannot safely upgrade this document to version ${j}.`);t=i(t),n+=1}return t.schemaVersion=j,t}var ki=new Set(["circle","rectangle","square","ellipse","text","triangle","ngon","star","cross","ring","spiral","gear","arrow","line","path","polyline","image"]);function Me(r){let e=[],t=[];if(r==null||typeof r!="object")return e.push({path:"",message:"Snapshot must be a non-null object",severity:"error"}),{valid:!1,errors:e,warnings:t};let n=r;if(n.schemaVersion!==void 0&&(typeof n.schemaVersion!="number"||!Number.isInteger(n.schemaVersion)?e.push({path:"schemaVersion",message:"schemaVersion must be an integer",severity:"error"}):n.schemaVersion>j&&t.push({path:"schemaVersion",message:`schemaVersion ${n.schemaVersion} is newer than supported (${j})`,severity:"warning"})),!Array.isArray(n.shapes))e.push({path:"shapes",message:"shapes must be an array",severity:"error"});else{let i=new Set;n.shapes.forEach((a,o)=>{Ti(a,`shapes[${o}]`,e,t,i)})}if(!Array.isArray(n.viewboxes))e.push({path:"viewboxes",message:"viewboxes must be an array",severity:"error"});else{let i=new Set;n.viewboxes.forEach((a,o)=>{Mi(a,`viewboxes[${o}]`,e,t,i)})}if(n.guides!==void 0&&(Array.isArray(n.guides)?n.guides.forEach((i,a)=>{Ri(i,`guides[${a}]`,e,t)}):e.push({path:"guides",message:"guides must be an array",severity:"error"})),n.groups!==void 0&&(Array.isArray(n.groups)?n.groups.forEach((i,a)=>{Ci(i,`groups[${a}]`,e)}):e.push({path:"groups",message:"groups must be an array",severity:"error"})),n.sceneTree!==void 0)if(!Array.isArray(n.sceneTree))e.push({path:"sceneTree",message:"sceneTree must be an array",severity:"error"});else{let i=vi(n.shapes),a=new Set;n.sceneTree.forEach((o,l)=>{_i(o,`sceneTree[${l}]`,e,t,i,a)})}if(n.clipMaskGroups!==void 0&&(Array.isArray(n.clipMaskGroups)?n.clipMaskGroups.forEach((i,a)=>{Ii(i,`clipMaskGroups[${a}]`,e)}):e.push({path:"clipMaskGroups",message:"clipMaskGroups must be an array",severity:"error"})),n.paintServerDefs!==void 0)if(!Array.isArray(n.paintServerDefs))e.push({path:"paintServerDefs",message:"paintServerDefs must be an array",severity:"error"});else{let i=new Set;n.paintServerDefs.forEach((a,o)=>{Pi(a,`paintServerDefs[${o}]`,e,i)})}return n.measurements!==void 0&&(Array.isArray(n.measurements)||e.push({path:"measurements",message:"measurements must be an array",severity:"error"})),{valid:e.length===0,errors:e,warnings:t}}function vi(r){let e=new Set;if(!Array.isArray(r))return e;let t=n=>{if(n===null||typeof n!="object")return;let i=n;typeof i.id=="string"&&i.id.length>0&&e.add(i.id);let o=i.state?.children;if(Array.isArray(o))for(let l of o)t(l)};for(let n of r)t(n);return e}function fn(r){return r.startsWith("structural:")}function _i(r,e,t,n,i,a){if(r===null||typeof r!="object"){t.push({path:e,message:"Scene tree entry must be a non-null object",severity:"error"});return}let o=r;typeof o.id!="string"||o.id.length===0?t.push({path:`${e}.id`,message:"Scene tree id must be a non-empty string",severity:"error"}):(a.has(o.id)&&t.push({path:`${e}.id`,message:`Duplicate scene tree id: "${o.id}"`,severity:"error"}),a.add(o.id),!i.has(o.id)&&!fn(o.id)&&n.push({path:`${e}.id`,message:`Scene tree id "${o.id}" is not present in shapes`,severity:"warning"})),o.parentId!==null&&typeof o.parentId!="string"?t.push({path:`${e}.parentId`,message:"Scene tree parentId must be a string or null",severity:"error"}):typeof o.parentId=="string"&&!i.has(o.parentId)&&!fn(o.parentId)&&n.push({path:`${e}.parentId`,message:`Scene tree parentId "${o.parentId}" is not present in shapes`,severity:"warning"}),(typeof o.index!="number"||!Number.isInteger(o.index)||o.index<0)&&t.push({path:`${e}.index`,message:"Scene tree index must be a non-negative integer",severity:"error"}),o.updatedAt!==void 0&&(typeof o.updatedAt!="number"||!Number.isFinite(o.updatedAt)||o.updatedAt<0)&&t.push({path:`${e}.updatedAt`,message:"Scene tree updatedAt must be a non-negative finite number",severity:"error"}),o.clientId!==void 0&&typeof o.clientId!="string"&&t.push({path:`${e}.clientId`,message:"Scene tree clientId must be a string",severity:"error"})}var wi=new Set(["mask","clipPath","filter","linearGradient","radialGradient","pattern","symbol"]);function Pi(r,e,t,n){if(r===null||typeof r!="object"){t.push({path:e,message:"Paint server def must be a non-null object",severity:"error"});return}let i=r;typeof i.id!="string"||i.id.length===0?t.push({path:`${e}.id`,message:"Paint server def id must be a non-empty string",severity:"error"}):n.has(i.id)?t.push({path:`${e}.id`,message:`Duplicate paint server def id: "${i.id}"`,severity:"error"}):n.add(i.id),(typeof i.type!="string"||!wi.has(i.type))&&t.push({path:`${e}.type`,message:"Paint server def type must be a supported SVG defs element type",severity:"error"}),(typeof i.markup!="string"||i.markup.length===0)&&t.push({path:`${e}.markup`,message:"Paint server def markup must be a non-empty string",severity:"error"})}function Ti(r,e,t,n,i){if(r===null||typeof r!="object"){t.push({path:e,message:"Shape must be a non-null object",severity:"error"});return}let a=r;typeof a.id!="string"||a.id.length===0?t.push({path:`${e}.id`,message:"Shape id must be a non-empty string",severity:"error"}):i.has(a.id)?t.push({path:`${e}.id`,message:`Duplicate shape id: "${a.id}"`,severity:"error"}):i.add(a.id),typeof a.type!="string"?t.push({path:`${e}.type`,message:"Shape type must be a string",severity:"error"}):ki.has(a.type)||n.push({path:`${e}.type`,message:`Unknown shape type: "${a.type}"`,severity:"warning"}),a.state===void 0||a.state===null||typeof a.state!="object"?t.push({path:`${e}.state`,message:"Shape state must be a non-null object",severity:"error"}):Fi(a.state,`${e}.state`,t,n)}var Ai=/^\s*\{\{\s*[\w.\-]+\s*\}\}\s*$/;function hn(r){return typeof r=="number"?isFinite(r):typeof r=="string"?Ai.test(r):!1}function Fi(r,e,t,n){let i=["x","y","width","height","radius","rx","ry","fontSize"];for(let o of i)r[o]!==void 0&&!hn(r[o])&&t.push({path:`${e}.${o}`,message:`${o} must be a finite number or a {{variable}} reference`,severity:"error"});for(let o of ve){let l=r[o];if(l!=null){if(o==="transformMatrix"){(!Array.isArray(l)||l.length<6||!l.slice(0,6).every(u=>typeof u=="number"&&Number.isFinite(u)))&&t.push({path:`${e}.${o}`,message:`${o} must be a 6-element finite affine matrix`,severity:"error"});continue}hn(l)||t.push({path:`${e}.${o}`,message:`${o} must be a finite number or a {{variable}} reference`,severity:"error"})}}let a=["width","height","radius","fontSize"];for(let o of a){let l=r[o];typeof l=="number"&&l<=0&&n.push({path:`${e}.${o}`,message:`${o} should be positive (got ${l})`,severity:"warning"})}}function Mi(r,e,t,n,i){if(r===null||typeof r!="object"){t.push({path:e,message:"Viewbox must be a non-null object",severity:"error"});return}let a=r;typeof a.id!="string"||a.id.length===0?t.push({path:`${e}.id`,message:"Viewbox id must be a non-empty string",severity:"error"}):i.has(a.id)?t.push({path:`${e}.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]))&&t.push({path:`${e}.${o}`,message:`${o} must be a finite number`,severity:"error"});typeof a.width=="number"&&a.width<=0&&t.push({path:`${e}.width`,message:"Viewbox width must be positive",severity:"error"}),typeof a.height=="number"&&a.height<=0&&t.push({path:`${e}.height`,message:"Viewbox height must be positive",severity:"error"})}function Ri(r,e,t,n){if(r===null||typeof r!="object"){t.push({path:e,message:"Guide must be a non-null object",severity:"error"});return}let i=r;(typeof i.id!="string"||i.id.length===0)&&t.push({path:`${e}.id`,message:"Guide id must be a non-empty string",severity:"error"}),i.orientation!=="horizontal"&&i.orientation!=="vertical"&&t.push({path:`${e}.orientation`,message:'Guide orientation must be "horizontal" or "vertical"',severity:"error"}),(typeof i.position!="number"||!isFinite(i.position))&&t.push({path:`${e}.position`,message:"Guide position must be a finite number",severity:"error"})}function Ci(r,e,t){if(r===null||typeof r!="object"){t.push({path:e,message:"Group must be a non-null object",severity:"error"});return}let n=r;(typeof n.id!="string"||n.id.length===0)&&t.push({path:`${e}.id`,message:"Group id must be a non-empty string",severity:"error"}),n.parentId!==null&&typeof n.parentId!="string"&&t.push({path:`${e}.parentId`,message:"Group parentId must be a string or null",severity:"error"})}function Ii(r,e,t){if(r===null||typeof r!="object"){t.push({path:e,message:"ClipMaskGroup must be a non-null object",severity:"error"});return}let n=r;(typeof n.id!="string"||n.id.length===0)&&t.push({path:`${e}.id`,message:"ClipMaskGroup id must be a non-empty string",severity:"error"}),n.type!=="clip"&&n.type!=="mask"&&t.push({path:`${e}.type`,message:'ClipMaskGroup type must be "clip" or "mask"',severity:"error"}),(typeof n.clipShapeId!="string"||n.clipShapeId.length===0)&&t.push({path:`${e}.clipShapeId`,message:"clipShapeId must be a non-empty string",severity:"error"}),Array.isArray(n.contentShapeIds)||t.push({path:`${e}.contentShapeIds`,message:"contentShapeIds must be an array",severity:"error"})}function T(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?`id-${crypto.randomUUID()}`:`id-${Date.now()}-${Math.random().toString(36).slice(2,11)}`}function je(r={}){let e={schemaVersion:j,shapes:r.shapes?r.shapes.map(t=>({...t})):[],viewboxes:r.viewboxes?r.viewboxes.map(t=>({...t})):[]};return r.metadata&&(e.documentMetadata={title:"",description:"",author:"",keywords:[],license:"",licenseUrl:"",language:"en",customMetadata:{},...r.metadata}),e}function pn(r){let{type:e,id:t,...n}=r,i={};for(let[a,o]of Object.entries(n))o!==void 0&&(i[a]=o);return{id:t??T(),type:e,state:i}}function Re(r,e,t,n,i){return{id:i??T(),x:r,y:e,width:t,height:n}}var Li=["schemaVersion","documentMetadata","documentScripts","documentStyles","templateVariables","viewboxes","guides","measurements","groups","sceneTree","clipMaskGroups","customPatterns","symbols","markers","library","colorGlyphLibrary","paintServerDefs","rawPaintServerDefs","animationTimeline","shapes"];function Ye(r,e={}){let{indent:t=2,trailingNewline:n=!0,validate:i=!1}=e;if(i){let l=Me(r);if(!l.valid){let u=l.errors.map(c=>` ${c.path}: ${c.message}`).join(`
1
+ "use strict";var hr=Object.defineProperty;var si=Object.getOwnPropertyDescriptor;var ai=Object.getOwnPropertyNames;var oi=Object.prototype.hasOwnProperty;var li=(r,e)=>{for(var t in e)hr(r,t,{get:e[t],enumerable:!0})},ui=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of ai(e))!oi.call(r,i)&&i!==t&&hr(r,i,{get:()=>e[i],enumerable:!(n=si(e,i))||n.enumerable});return r};var ci=r=>ui(hr({},"__esModule",{value:!0}),r);var ro={};li(ro,{Arrow:()=>qt,Audio:()=>lr,BUILTIN_MARKER_ID_MAP:()=>Rr,COMMON_TRANSFORM_NODE_DEFAULTS:()=>mi,CURRENT_SCHEMA_VERSION:()=>j,Circle:()=>Dt,Cloud:()=>Qt,Container:()=>rr,ContainerShapeBuilder:()=>ce,Cross:()=>Wt,DEFAULT_COORDINATE_PRECISION:()=>gn,Document:()=>It,EASING_CURVES:()=>Ne,EVENT_TRIGGER_OPTIONS:()=>fi,EasingType:()=>pr,Ellipse:()=>Bt,Gear:()=>Yt,Heart:()=>Zt,Hyperlink:()=>er,IDENTITY_AFFINE:()=>un,ImageShape:()=>dr,LIBRARY_EMIT_ORDER:()=>Vr,Lightning:()=>Kt,Line:()=>zt,LinearGradientBuilder:()=>De,MARKER_HEIGHT:()=>kt,MARKER_VIEWBOX:()=>Ee,MARKER_WIDTH:()=>St,MAX_COORDINATE_PRECISION:()=>bn,MIGRATIONS:()=>vr,NGon:()=>Vt,NUMERIC_SHAPE_TRANSFORM_STATE_KEYS:()=>ve,NestedSvg:()=>ir,PUZZLE_DEFAULTS:()=>tn,Path:()=>ur,PathCurveType:()=>mr,PathPointType:()=>ln,PatternBuilder:()=>Oe,Polyline:()=>cr,RadialGradientBuilder:()=>Be,Rectangle:()=>Ot,Ring:()=>Xt,SHAPE_TRANSFORM_STATE_KEYS:()=>pi,ShapeBuilder:()=>U,ShapeReference:()=>sr,SpeechBubble:()=>Jt,Spiral:()=>jt,Square:()=>Gt,Star:()=>Ht,Switch:()=>tr,Text:()=>Ut,Timeline:()=>Et,Track:()=>Lt,Triangle:()=>Nt,Video:()=>or,View:()=>nr,affine:()=>le,affineFromArray:()=>Ve,affineToArray:()=>ue,around:()=>yr,canonicalPolygonTransformString:()=>xr,canonicalTransformString:()=>ge,collectReferencedLibraryIds:()=>In,composeLegacyTransformMatrix:()=>Te,computeArrowVertices:()=>at,computeCloudPath:()=>ct,computeCrossVertices:()=>st,computeDashArray:()=>$e,computeGearPath:()=>ht,computeGearVertices:()=>Tr,computeHeartPath:()=>ut,computeLightningVertices:()=>lt,computePolygonVertices:()=>Ie,computeRectanglePath:()=>pt,computeRingPath:()=>dt,computeSpeechBubbleVertices:()=>ot,computeSpiralPath:()=>ft,computeSplinePath:()=>ye,computeStarVertices:()=>it,createDocument:()=>je,createShape:()=>pn,createViewbox:()=>Re,defaultVariableMode:()=>hi,escXml:()=>O,extractVariables:()=>et,filterAttr:()=>$t,foldLegacyAncestorTransformIntoMatrix:()=>$r,generateCode:()=>Ct,generateCssCode:()=>Rt,generateD3Code:()=>Ft,generateId:()=>T,generatePatternSvgContent:()=>xt,generatePuzzlePieces:()=>jn,generateReactCode:()=>At,generateSudokuPuzzle:()=>ii,generateSvgCode:()=>Tt,generateVueCode:()=>Mt,getBuiltInMarkerDefs:()=>Pn,getEasingCubicBezier:()=>di,getEffectivePrecision:()=>yn,getMarkerDescriptors:()=>he,getPatternElements:()=>Le,isFiniteAffineArray:()=>pe,isIdentityAffine:()=>br,linearGradient:()=>zn,matrixTransformPart:()=>gr,migrateSnapshot:()=>Xe,multiplyAffine:()=>z,parseDocument:()=>qe,parseSvgTransformList:()=>He,parseVariableArgs:()=>mn,pattern:()=>Nn,radialGradient:()=>Un,renderAnimationElements:()=>wt,renderBuiltinMarkerDefs:()=>ie,renderCircle:()=>Lr,renderEllipse:()=>Er,renderFilterDefs:()=>wn,renderFilterLibraryDef:()=>Zr,renderFilterPrimitive:()=>yt,renderFilterPrimitivesForType:()=>Mr,renderImage:()=>Ur,renderLibraryDef:()=>Hr,renderLibraryDefs:()=>Kr,renderLine:()=>Br,renderLinearGradientLibraryDef:()=>jr,renderMarkerLibraryDef:()=>Xr,renderPatternLibraryDef:()=>qr,renderPolygonShape:()=>Nr,renderPolyline:()=>zr,renderRadialGradientLibraryDef:()=>Yr,renderRectangle:()=>Dr,renderReferencedLibraryDefs:()=>se,renderShape:()=>H,renderSpline:()=>Gr,renderSvgPrimitiveChainFilter:()=>Ar,renderSymbolLibraryDef:()=>Wr,renderText:()=>Or,renderToSvg:()=>Se,rotateAffine:()=>me,roundCoord:()=>rt,roundNumberString:()=>_r,roundSerializedShape:()=>tt,roundSnapshot:()=>$n,scaleAffine:()=>_e,skewXAffine:()=>we,skewYAffine:()=>Pe,solveSudoku:()=>ze,stringifyDocument:()=>Ye,substituteString:()=>Ze,substituteVariables:()=>Je,translateAffine:()=>K,validateSnapshot:()=>Fe,validateSudokuPuzzle:()=>ni,verticesToPath:()=>J});module.exports=ci(ro);var pr=(A=>(A.LINEAR="linear",A.EASE="ease",A.EASE_IN="ease-in",A.EASE_OUT="ease-out",A.EASE_IN_OUT="ease-in-out",A.EASE_IN_QUAD="ease-in-quad",A.EASE_OUT_QUAD="ease-out-quad",A.EASE_IN_OUT_QUAD="ease-in-out-quad",A.EASE_IN_CUBIC="ease-in-cubic",A.EASE_OUT_CUBIC="ease-out-cubic",A.EASE_IN_OUT_CUBIC="ease-in-out-cubic",A.EASE_IN_QUART="ease-in-quart",A.EASE_OUT_QUART="ease-out-quart",A.EASE_IN_OUT_QUART="ease-in-out-quart",A.EASE_IN_SINE="ease-in-sine",A.EASE_OUT_SINE="ease-out-sine",A.EASE_IN_OUT_SINE="ease-in-out-sine",A.EASE_IN_QUINT="ease-in-quint",A.EASE_OUT_QUINT="ease-out-quint",A.EASE_IN_OUT_QUINT="ease-in-out-quint",A.EASE_IN_EXPO="ease-in-expo",A.EASE_OUT_EXPO="ease-out-expo",A.EASE_IN_OUT_EXPO="ease-in-out-expo",A.EASE_IN_CIRC="ease-in-circ",A.EASE_OUT_CIRC="ease-out-circ",A.EASE_IN_OUT_CIRC="ease-in-out-circ",A.EASE_IN_BACK="ease-in-back",A.EASE_OUT_BACK="ease-out-back",A.EASE_IN_OUT_BACK="ease-in-out-back",A.CUSTOM_BEZIER="custom-bezier",A.LINEAR_FUNCTION="linear-function",A.STEPS="steps",A))(pr||{}),Ne={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-quint":[.755,.05,.855,.06],"ease-out-quint":[.23,1,.32,1],"ease-in-out-quint":[.86,0,.07,1],"ease-in-expo":[.95,.05,.795,.035],"ease-out-expo":[.19,1,.22,1],"ease-in-out-expo":[1,0,0,1],"ease-in-circ":[.6,.04,.98,.335],"ease-out-circ":[.075,.82,.165,1],"ease-in-out-circ":[.785,.135,.15,.86],"ease-in-back":[.6,-.28,.735,.045],"ease-out-back":[.175,.885,.32,1.275],"ease-in-out-back":[.68,-.55,.265,1.55],"custom-bezier":null,"linear-function":null,steps:null};function di(r){let e=Ne[r];return e?`cubic-bezier(${e.join(", ")})`:"linear"}var fi=[{value:"click",label:"Click"},{value:"mouseenter",label:"Mouse Enter"},{value:"mouseleave",label:"Mouse Leave"},{value:"focus",label:"Focus"},{value:"blur",label:"Blur"},{value:"load",label:"Page Load"}];var mr=(l=>(l.LINEAR="linear",l.QUADRATIC="quadratic",l.CUBIC="cubic",l.CATMULL_ROM="catmull-rom",l.ARC="arc",l.BASIS="basis",l.MIXED="mixed",l))(mr||{}),ln=(n=>(n.SMOOTH="smooth",n.CORNER="corner",n.SYMMETRIC="symmetric",n))(ln||{});function hi(r){return r==="color"?"live":"stamped"}var j=4;var pi=["transformMatrix","scaleX","scaleY","translateX","translateY","rotation","skewX","skewY","customPivot","rawTransform"],ve=["transformMatrix","scaleX","scaleY","translateX","translateY","rotation","skewX","skewY"],mi={transformMatrix:null,translateX:0,translateY:0,rotation:0,skewX:0,skewY:0,customPivot:null,rawTransform:null};var un=[1,0,0,1,0,0];function le(r,e,t,n,i,a){return[r,e,t,n,i,a]}function Ve(r){return le(r[0]??1,r[1]??0,r[2]??0,r[3]??1,r[4]??0,r[5]??0)}function ue(r){return[r[0],r[1],r[2],r[3],r[4],r[5]]}function pe(r){return Array.isArray(r)&&r.length>=6&&r.slice(0,6).every(Number.isFinite)}function br(r,e=1e-9){return Math.abs((r[0]??1)-1)<=e&&Math.abs(r[1]??0)<=e&&Math.abs(r[2]??0)<=e&&Math.abs((r[3]??1)-1)<=e&&Math.abs(r[4]??0)<=e&&Math.abs(r[5]??0)<=e}function z(r,e){return le(r[0]*e[0]+r[2]*e[1],r[1]*e[0]+r[3]*e[1],r[0]*e[2]+r[2]*e[3],r[1]*e[2]+r[3]*e[3],r[0]*e[4]+r[2]*e[5]+r[4],r[1]*e[4]+r[3]*e[5]+r[5])}function K(r,e=0){return le(1,0,0,1,r,e)}function _e(r,e=r){return le(r,0,0,e,0,0)}function me(r){let e=r*Math.PI/180;return le(Math.cos(e),Math.sin(e),-Math.sin(e),Math.cos(e),0,0)}function we(r){return le(1,0,Math.tan(r*Math.PI/180),1,0,0)}function Pe(r){return le(1,Math.tan(r*Math.PI/180),0,1,0,0)}function yr(r,e){return z(z(K(r.x,r.y),e),K(-r.x,-r.y))}function He(r){let e=un;if(!r)return e;let t=/(translate|scale|rotate|matrix|skewX|skewY)\s*\(([^)]+)\)/gi,n;for(;(n=t.exec(r))!==null;){let i=n[1].toLowerCase(),a=n[2].trim().split(/[\s,]+/).map(Number).filter(Number.isFinite),o=null;switch(i){case"translate":o=K(a[0]||0,a[1]??0);break;case"scale":o=_e(a[0]||1,a[1]??a[0]??1);break;case"rotate":o=a.length>=3?yr({x:a[1],y:a[2]},me(a[0]||0)):me(a[0]||0);break;case"matrix":a.length>=6&&(o=Ve(a));break;case"skewx":o=we(a[0]||0);break;case"skewy":o=Pe(a[0]||0);break}o&&(e=z(e,o))}return e}function gr(r){return!pe(r)||br(r)?null:`matrix(${r[0]}, ${r[1]}, ${r[2]}, ${r[3]}, ${r[4]}, ${r[5]})`}function Te(r,e){let t=r.translateX??0,n=r.translateY??0,i=typeof r.rawTransform=="string"?r.rawTransform:"",a=K(t,n);if(i)return z(a,He(i));let o=r.rotation??0,l=r.skewX??0,u=r.skewY??0,c=r.scaleX??1,f=r.scaleY??1;if(o===0&&l===0&&u===0&&c===1&&f===1)return a;let d=r.customPivot??e;if(!d)return a;let m=z(z(z(me(o),_e(c,f)),we(l)),Pe(u));return z(a,yr(d,m))}function ge(r,e){let t=gr(r.transformMatrix);return t||(gr(ue(Te(r,e)))??null)}function $r(r,e){let t=r.ancestorTransform;if(!pe(t)){delete r.ancestorTransform;return}if(br(t)){delete r.ancestorTransform;return}let n=pe(r.transformMatrix)?Ve(r.transformMatrix):Te(r,e);r.transformMatrix=ue(z(Ve(t),n)),delete r.ancestorTransform}function xr(r,e,t){let n=ge(r,{x:e,y:t});return n?`${n} translate(${e}, ${t})`:`translate(${e}, ${t})`}function dn(r){let e=r.customPivot;if(e)return e;let t=r.x,n=r.y,i=r.width,a=r.height;if(typeof t=="number"&&typeof n=="number"&&typeof i=="number"&&typeof a=="number")return{x:t+i/2,y:n+a/2};let o=r.radius;if(typeof t=="number"&&typeof n=="number"&&typeof o=="number")return{x:t,y:n};let l=r.cx,u=r.cy;if(typeof l=="number"&&typeof u=="number")return{x:l,y:u};let c=r.x1,f=r.y1,d=r.x2,m=r.y2;if(typeof c=="number"&&typeof f=="number"&&typeof d=="number"&&typeof m=="number")return{x:(c+d)/2,y:(f+m)/2};let p=r.pathPoints;if(p?.[0])return{x:p[0].x,y:p[0].y};let b=r.polylinePoints;if(b?.[0])return{x:b[0].x,y:b[0].y}}function Ae(r){if(Array.isArray(r))for(let e of r){$r(e.state,dn(e.state));let t=e.state.children;Ae(t)}}function gi(r){Ae(r.shapes);for(let e of r.library??[])if(e.kind==="symbol"){Ae(e.shapes);for(let t of Object.values(e.variants??{}))Ae(t)}else e.kind==="marker"&&Ae(e.shapes);return r.schemaVersion=3,r}function Sr(r){let e=r;return e&&typeof e.x=="number"&&Number.isFinite(e.x)&&typeof e.y=="number"&&Number.isFinite(e.y)?{x:e.x,y:e.y}:null}function bi(r,e){let t=r.translateX??0,n=r.translateY??0,i=typeof r.rawTransform=="string"?r.rawTransform:"",a=K(t,n);if(i)return ue(z(a,He(i)));let o=r.rotation??0,l=r.skewX??0,u=r.skewY??0;if(o!==0||l!==0||u!==0){let d=Sr(r.customPivot)??e??Sr(r.scaleAnchor);d&&(a=z(a,K(d.x,d.y)),o!==0&&(a=z(a,me(o))),l!==0&&(a=z(a,we(l))),u!==0&&(a=z(a,Pe(u))),a=z(a,K(-d.x,-d.y)))}let c=r.scaleX??1,f=r.scaleY??1;if(c!==1||f!==1){let d=Sr(r.scaleAnchor)??e;d&&(a=z(a,K(d.x,d.y)),a=z(a,_e(c,f)),a=z(a,K(-d.x,-d.y)))}return ue(a)}function Me(r){if(Array.isArray(r))for(let e of r){let t=e.state;"scaleAnchor"in t&&(e.type==="text"&&!pe(t.transformMatrix)&&(t.transformMatrix=bi(t,dn(t))),delete t.scaleAnchor);let n=e.state.children;Me(n)}}function yi(r){Me(r.shapes);for(let e of r.library??[])if(e.kind==="symbol"){Me(e.shapes);for(let t of Object.values(e.variants??{}))Me(t)}else e.kind==="marker"&&Me(e.shapes);return r.schemaVersion=4,r}function $i(r){let e=Array.isArray(r.library)?[...r.library]:[],t=new Set(e.map(u=>u.id));if(Array.isArray(r.symbols))for(let u of r.symbols)!u||t.has(u.id)||(e.push({...u,kind:"symbol"}),t.add(u.id));if(Array.isArray(r.markers))for(let u of r.markers)!u||t.has(u.id)||(e.push({...u,kind:"marker"}),t.add(u.id));let n=new Map,i=(u,c)=>{let{id:f,sourceId:d,...m}=u,p=JSON.stringify({kind:c,...m}),b=n.get(p);if(b)return b;let g=t.has(u.id)?`grd-${We()}`:u.id;t.add(g),n.set(p,g);let y=c==="linear-gradient"?{kind:"linear-gradient",id:g,name:u.sourceId??g,sourceId:u.sourceId,gradient:cn(u)}:{kind:"radial-gradient",id:g,name:u.sourceId??g,sourceId:u.sourceId,gradient:cn(u)};return e.push(y),g},a=new Map;if(Array.isArray(r.customPatterns))for(let u of r.customPatterns){if(!u)continue;let c=t.has(u.id)?`pat-${We()}`:u.id;t.add(c),a.set(u.id,c),e.push(xi(u,c))}let o=u=>{if(u.customPatternId){let S=a.get(u.customPatternId);if(S)return S}let{id:c,sourceId:f,customPatternId:d,...m}=u,p=JSON.stringify({kind:"pattern",...m}),b=n.get(p);if(b)return b;let g=t.has(u.id)?`pat-${We()}`:u.id;t.add(g),n.set(p,g);let y={kind:"pattern",id:g,name:u.sourceId??g,sourceId:u.sourceId,pattern:m};return e.push(y),g};for(let u of r.shapes??[]){let c=u.state;if(!c)continue;let f=c.fillGradient;f&&(f.type==="linear-gradient"||f.type==="radial-gradient"?c.fillLibraryId=i(f,f.type):f.type==="pattern"&&(c.fillLibraryId=o(f)));let d=c.strokeGradient;d&&(d.type==="linear-gradient"||d.type==="radial-gradient"?c.strokeLibraryId=i(d,d.type):d.type==="pattern"&&(c.strokeLibraryId=o(d)));let m=c.filters;if(Array.isArray(m)&&m.length>0){let p=l(m,c,u.id);c.filterLibraryIds=[p]}}return r.library=e,r;function l(u,c,f){let d={filters:u,colorInterpolation:c.filterColorInterpolation,filterUnits:c.filterUnits,primitiveUnits:c.primitiveUnits,x:c.filterX,y:c.filterY,width:c.filterWidth,height:c.filterHeight},m=JSON.stringify({kind:"filter",...d}),p=n.get(m);if(p)return p;let b=`filter-${f}`,g=t.has(b)?`flt-${We()}`:b;t.add(g),n.set(m,g);let y={kind:"filter",id:g,name:g,filters:d.filters,...d.colorInterpolation?{colorInterpolation:d.colorInterpolation}:{},...d.filterUnits?{filterUnits:d.filterUnits}:{},...d.primitiveUnits?{primitiveUnits:d.primitiveUnits}:{},...d.x!==void 0?{x:d.x}:{},...d.y!==void 0?{y:d.y}:{},...d.width!==void 0?{width:d.width}:{},...d.height!==void 0?{height:d.height}:{}};return e.push(y),g}}function xi(r,e){return{kind:"pattern",id:e,name:r.name??e,pattern:{type:"pattern",svgContent:r.svgContent,width:r.width,height:r.height,patternType:"custom",color:"#000000",backgroundColor:"transparent",scale:1,rotation:0,opacity:1,patternUnits:"userSpaceOnUse"}}}function cn(r){let{id:e,sourceId:t,...n}=r;return n}var kr=0;function We(){return kr=kr+1&65535,`${Date.now().toString(36)}-${kr.toString(36)}`}var vr=Object.freeze({1:$i,2:gi,3:yi});function Si(r){let e=r.schemaVersion;return typeof e!="number"||!Number.isFinite(e)||e<1?1:Math.floor(e)}function Xe(r,e=vr){let t=JSON.parse(JSON.stringify(r)),n=Si(t);if(n>j)return t;if(n===j)return t.schemaVersion=j,t;for(;n<j;){let i=e[n];if(!i)throw new Error(`[svgsketch/core] No migration registered for schema version ${n} \u2192 ${n+1}. Cannot safely upgrade this document to version ${j}.`);t=i(t),n+=1}return t.schemaVersion=j,t}var ki=new Set(["circle","rectangle","square","ellipse","text","triangle","ngon","star","cross","ring","spiral","gear","arrow","line","path","polyline","image"]);function Fe(r){let e=[],t=[];if(r==null||typeof r!="object")return e.push({path:"",message:"Snapshot must be a non-null object",severity:"error"}),{valid:!1,errors:e,warnings:t};let n=r;if(n.schemaVersion!==void 0&&(typeof n.schemaVersion!="number"||!Number.isInteger(n.schemaVersion)?e.push({path:"schemaVersion",message:"schemaVersion must be an integer",severity:"error"}):n.schemaVersion>j&&t.push({path:"schemaVersion",message:`schemaVersion ${n.schemaVersion} is newer than supported (${j})`,severity:"warning"})),!Array.isArray(n.shapes))e.push({path:"shapes",message:"shapes must be an array",severity:"error"});else{let i=new Set;n.shapes.forEach((a,o)=>{Ti(a,`shapes[${o}]`,e,t,i)})}if(!Array.isArray(n.viewboxes))e.push({path:"viewboxes",message:"viewboxes must be an array",severity:"error"});else{let i=new Set;n.viewboxes.forEach((a,o)=>{Fi(a,`viewboxes[${o}]`,e,t,i)})}if(n.guides!==void 0&&(Array.isArray(n.guides)?n.guides.forEach((i,a)=>{Ri(i,`guides[${a}]`,e,t)}):e.push({path:"guides",message:"guides must be an array",severity:"error"})),n.groups!==void 0&&(Array.isArray(n.groups)?n.groups.forEach((i,a)=>{Ci(i,`groups[${a}]`,e)}):e.push({path:"groups",message:"groups must be an array",severity:"error"})),n.sceneTree!==void 0)if(!Array.isArray(n.sceneTree))e.push({path:"sceneTree",message:"sceneTree must be an array",severity:"error"});else{let i=vi(n.shapes),a=new Set;n.sceneTree.forEach((o,l)=>{_i(o,`sceneTree[${l}]`,e,t,i,a)})}if(n.clipMaskGroups!==void 0&&(Array.isArray(n.clipMaskGroups)?n.clipMaskGroups.forEach((i,a)=>{Ii(i,`clipMaskGroups[${a}]`,e)}):e.push({path:"clipMaskGroups",message:"clipMaskGroups must be an array",severity:"error"})),n.paintServerDefs!==void 0)if(!Array.isArray(n.paintServerDefs))e.push({path:"paintServerDefs",message:"paintServerDefs must be an array",severity:"error"});else{let i=new Set;n.paintServerDefs.forEach((a,o)=>{Pi(a,`paintServerDefs[${o}]`,e,i)})}return n.measurements!==void 0&&(Array.isArray(n.measurements)||e.push({path:"measurements",message:"measurements must be an array",severity:"error"})),{valid:e.length===0,errors:e,warnings:t}}function vi(r){let e=new Set;if(!Array.isArray(r))return e;let t=n=>{if(n===null||typeof n!="object")return;let i=n;typeof i.id=="string"&&i.id.length>0&&e.add(i.id);let o=i.state?.children;if(Array.isArray(o))for(let l of o)t(l)};for(let n of r)t(n);return e}function fn(r){return r.startsWith("structural:")}function _i(r,e,t,n,i,a){if(r===null||typeof r!="object"){t.push({path:e,message:"Scene tree entry must be a non-null object",severity:"error"});return}let o=r;typeof o.id!="string"||o.id.length===0?t.push({path:`${e}.id`,message:"Scene tree id must be a non-empty string",severity:"error"}):(a.has(o.id)&&t.push({path:`${e}.id`,message:`Duplicate scene tree id: "${o.id}"`,severity:"error"}),a.add(o.id),!i.has(o.id)&&!fn(o.id)&&n.push({path:`${e}.id`,message:`Scene tree id "${o.id}" is not present in shapes`,severity:"warning"})),o.parentId!==null&&typeof o.parentId!="string"?t.push({path:`${e}.parentId`,message:"Scene tree parentId must be a string or null",severity:"error"}):typeof o.parentId=="string"&&!i.has(o.parentId)&&!fn(o.parentId)&&n.push({path:`${e}.parentId`,message:`Scene tree parentId "${o.parentId}" is not present in shapes`,severity:"warning"}),(typeof o.index!="number"||!Number.isInteger(o.index)||o.index<0)&&t.push({path:`${e}.index`,message:"Scene tree index must be a non-negative integer",severity:"error"}),o.updatedAt!==void 0&&(typeof o.updatedAt!="number"||!Number.isFinite(o.updatedAt)||o.updatedAt<0)&&t.push({path:`${e}.updatedAt`,message:"Scene tree updatedAt must be a non-negative finite number",severity:"error"}),o.clientId!==void 0&&typeof o.clientId!="string"&&t.push({path:`${e}.clientId`,message:"Scene tree clientId must be a string",severity:"error"})}var wi=new Set(["mask","clipPath","filter","linearGradient","radialGradient","pattern","symbol"]);function Pi(r,e,t,n){if(r===null||typeof r!="object"){t.push({path:e,message:"Paint server def must be a non-null object",severity:"error"});return}let i=r;typeof i.id!="string"||i.id.length===0?t.push({path:`${e}.id`,message:"Paint server def id must be a non-empty string",severity:"error"}):n.has(i.id)?t.push({path:`${e}.id`,message:`Duplicate paint server def id: "${i.id}"`,severity:"error"}):n.add(i.id),(typeof i.type!="string"||!wi.has(i.type))&&t.push({path:`${e}.type`,message:"Paint server def type must be a supported SVG defs element type",severity:"error"}),(typeof i.markup!="string"||i.markup.length===0)&&t.push({path:`${e}.markup`,message:"Paint server def markup must be a non-empty string",severity:"error"})}function Ti(r,e,t,n,i){if(r===null||typeof r!="object"){t.push({path:e,message:"Shape must be a non-null object",severity:"error"});return}let a=r;typeof a.id!="string"||a.id.length===0?t.push({path:`${e}.id`,message:"Shape id must be a non-empty string",severity:"error"}):i.has(a.id)?t.push({path:`${e}.id`,message:`Duplicate shape id: "${a.id}"`,severity:"error"}):i.add(a.id),typeof a.type!="string"?t.push({path:`${e}.type`,message:"Shape type must be a string",severity:"error"}):ki.has(a.type)||n.push({path:`${e}.type`,message:`Unknown shape type: "${a.type}"`,severity:"warning"}),a.state===void 0||a.state===null||typeof a.state!="object"?t.push({path:`${e}.state`,message:"Shape state must be a non-null object",severity:"error"}):Mi(a.state,`${e}.state`,t,n)}var Ai=/^\s*\{\{\s*[\w.\-]+\s*\}\}\s*$/;function hn(r){return typeof r=="number"?isFinite(r):typeof r=="string"?Ai.test(r):!1}function Mi(r,e,t,n){let i=["x","y","width","height","radius","rx","ry","fontSize"];for(let o of i)r[o]!==void 0&&!hn(r[o])&&t.push({path:`${e}.${o}`,message:`${o} must be a finite number or a {{variable}} reference`,severity:"error"});for(let o of ve){let l=r[o];if(l!=null){if(o==="transformMatrix"){(!Array.isArray(l)||l.length<6||!l.slice(0,6).every(u=>typeof u=="number"&&Number.isFinite(u)))&&t.push({path:`${e}.${o}`,message:`${o} must be a 6-element finite affine matrix`,severity:"error"});continue}hn(l)||t.push({path:`${e}.${o}`,message:`${o} must be a finite number or a {{variable}} reference`,severity:"error"})}}let a=["width","height","radius","fontSize"];for(let o of a){let l=r[o];typeof l=="number"&&l<=0&&n.push({path:`${e}.${o}`,message:`${o} should be positive (got ${l})`,severity:"warning"})}}function Fi(r,e,t,n,i){if(r===null||typeof r!="object"){t.push({path:e,message:"Viewbox must be a non-null object",severity:"error"});return}let a=r;typeof a.id!="string"||a.id.length===0?t.push({path:`${e}.id`,message:"Viewbox id must be a non-empty string",severity:"error"}):i.has(a.id)?t.push({path:`${e}.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]))&&t.push({path:`${e}.${o}`,message:`${o} must be a finite number`,severity:"error"});typeof a.width=="number"&&a.width<=0&&t.push({path:`${e}.width`,message:"Viewbox width must be positive",severity:"error"}),typeof a.height=="number"&&a.height<=0&&t.push({path:`${e}.height`,message:"Viewbox height must be positive",severity:"error"})}function Ri(r,e,t,n){if(r===null||typeof r!="object"){t.push({path:e,message:"Guide must be a non-null object",severity:"error"});return}let i=r;(typeof i.id!="string"||i.id.length===0)&&t.push({path:`${e}.id`,message:"Guide id must be a non-empty string",severity:"error"}),i.orientation!=="horizontal"&&i.orientation!=="vertical"&&t.push({path:`${e}.orientation`,message:'Guide orientation must be "horizontal" or "vertical"',severity:"error"}),(typeof i.position!="number"||!isFinite(i.position))&&t.push({path:`${e}.position`,message:"Guide position must be a finite number",severity:"error"})}function Ci(r,e,t){if(r===null||typeof r!="object"){t.push({path:e,message:"Group must be a non-null object",severity:"error"});return}let n=r;(typeof n.id!="string"||n.id.length===0)&&t.push({path:`${e}.id`,message:"Group id must be a non-empty string",severity:"error"}),n.parentId!==null&&typeof n.parentId!="string"&&t.push({path:`${e}.parentId`,message:"Group parentId must be a string or null",severity:"error"})}function Ii(r,e,t){if(r===null||typeof r!="object"){t.push({path:e,message:"ClipMaskGroup must be a non-null object",severity:"error"});return}let n=r;(typeof n.id!="string"||n.id.length===0)&&t.push({path:`${e}.id`,message:"ClipMaskGroup id must be a non-empty string",severity:"error"}),n.type!=="clip"&&n.type!=="mask"&&t.push({path:`${e}.type`,message:'ClipMaskGroup type must be "clip" or "mask"',severity:"error"}),(typeof n.clipShapeId!="string"||n.clipShapeId.length===0)&&t.push({path:`${e}.clipShapeId`,message:"clipShapeId must be a non-empty string",severity:"error"}),Array.isArray(n.contentShapeIds)||t.push({path:`${e}.contentShapeIds`,message:"contentShapeIds must be an array",severity:"error"})}function T(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?`id-${crypto.randomUUID()}`:`id-${Date.now()}-${Math.random().toString(36).slice(2,11)}`}function je(r={}){let e={schemaVersion:j,shapes:r.shapes?r.shapes.map(t=>({...t})):[],viewboxes:r.viewboxes?r.viewboxes.map(t=>({...t})):[]};return r.metadata&&(e.documentMetadata={title:"",description:"",author:"",keywords:[],license:"",licenseUrl:"",language:"en",customMetadata:{},...r.metadata}),e}function pn(r){let{type:e,id:t,...n}=r,i={};for(let[a,o]of Object.entries(n))o!==void 0&&(i[a]=o);return{id:t??T(),type:e,state:i}}function Re(r,e,t,n,i){return{id:i??T(),x:r,y:e,width:t,height:n}}var Li=["schemaVersion","documentMetadata","documentScripts","documentStyles","templateVariables","viewboxes","guides","measurements","groups","sceneTree","clipMaskGroups","customPatterns","symbols","markers","library","colorGlyphLibrary","paintServerDefs","rawPaintServerDefs","animationTimeline","shapes"];function Ye(r,e={}){let{indent:t=2,trailingNewline:n=!0,validate:i=!1}=e;if(i){let l=Fe(r);if(!l.valid){let u=l.errors.map(c=>` ${c.path}: ${c.message}`).join(`
2
2
  `);throw new Error(`Invalid document:
3
3
  ${u}`)}}let a={};for(let l of Li){let u=r[l];if(u!==void 0)switch(l){case"shapes":a[l]=u.map(Di);break;case"viewboxes":case"guides":case"measurements":case"groups":case"sceneTree":case"clipMaskGroups":case"symbols":case"markers":case"customPatterns":case"library":case"paintServerDefs":case"rawPaintServerDefs":a[l]=Array.isArray(u)&&typeof u[0]=="string"?u:Ei(u).map(fe);break;case"documentMetadata":a[l]=fe(u);break;case"animationTimeline":a[l]=fe(u);break;case"colorGlyphLibrary":a[l]=fe(u);break;default:a[l]=u}}let o=JSON.stringify(a,null,t);return n?o+`
4
- `:o}function qe(r,e={}){let{validate:t=!0,migrate:n=!0}=e,i;try{i=JSON.parse(r)}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=Xe(a)),t){let o=Me(a);if(!o.valid){let l=o.errors.map(u=>` ${u.path}: ${u.message}`).join(`
4
+ `:o}function qe(r,e={}){let{validate:t=!0,migrate:n=!0}=e,i;try{i=JSON.parse(r)}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=Xe(a)),t){let o=Fe(a);if(!o.valid){let l=o.errors.map(u=>` ${u.path}: ${u.message}`).join(`
5
5
  `);throw new Error(`Invalid .svgs document:
6
- ${l}`)}}return a}function Ei(r){return[...r].sort((e,t)=>e.id.localeCompare(t.id))}function fe(r){if(r==null)return r;if(Array.isArray(r))return r.map(fe);if(typeof r!="object")return r;let e={},t=Object.keys(r).sort();for(let n of t)e[n]=fe(r[n]);return e}function Di(r){let e={};return e.id=r.id,e.type=r.type,e.state=fe(r.state),e}var Q=/\{\{\s*([\w.\-]+)\s*\}\}/g;function Ze(r,e){return r.replace(Q,(t,n)=>{let i=e[n];return i!==void 0?String(i):t})}function Je(r,e={}){let t={};if(r.templateVariables)for(let i of r.templateVariables)i.defaultValue!==void 0&&i.defaultValue!==""&&(t[i.name]=i.defaultValue);if(Object.assign(t,e),Object.keys(t).length===0)return JSON.parse(JSON.stringify(r));let n=JSON.parse(JSON.stringify(r));for(let i of n.shapes)Ke(i.state,t);if(n.documentMetadata){let i=n.documentMetadata;Ke(i,t)}return n}function Ke(r,e){for(let t of Object.keys(r)){let n=r[t];if(typeof n=="string"){if(Q.lastIndex=0,Q.test(n)){Q.lastIndex=0;let i=Ze(n,e);if(Bi(n)){let a=Number(i);if(!isNaN(a)&&Gi(t)){r[t]=a;continue}}r[t]=i}}else if(Array.isArray(n))for(let i=0;i<n.length;i++)typeof n[i]=="string"?(Q.lastIndex=0,Q.test(n[i])&&(Q.lastIndex=0,n[i]=Ze(n[i],e))):n[i]!==null&&typeof n[i]=="object"&&Ke(n[i],e);else n!==null&&typeof n=="object"&&Ke(n,e)}}function Bi(r){return/^\s*\{\{\s*[\w.\-]+\s*\}\}\s*$/.test(r)}var Oi=new Set(["x","y","width","height","radius","rx","ry","cx","cy","x1","y1","x2","y2","fontSize","borderWidth","cornerRadius","opacity","fillOpacity","strokeOpacity",...ve,"letterSpacing","wordSpacing","lineHeight","sides","arms","innerRadiusPercent","armWidthPercent","teeth","toothDepthPercent","holeRadiusPercent","turns","thicknessPercent","direction","headWidthPercent","headLengthPercent","shaftWidthPercent","shiftAngle","dashLength","gapLength","textPathStartOffset","imageOpacity"]);function Gi(r){return Oi.has(r)}function et(r){let e=r.templateVariables??[],t=new Set(e.map(a=>a.name)),n=new Set;for(let a of r.shapes)Qe(a.state,n);r.documentMetadata&&Qe(r.documentMetadata,n);let i=[...n].filter(a=>!t.has(a)).sort();return{defined:[...e],undeclared:i}}function Qe(r,e){for(let t of Object.values(r))if(typeof t=="string"){let n;for(Q.lastIndex=0;(n=Q.exec(t))!==null;)e.add(n[1])}else if(Array.isArray(t))for(let n of t)if(typeof n=="string"){let i;for(Q.lastIndex=0;(i=Q.exec(n))!==null;)e.add(i[1])}else n!==null&&typeof n=="object"&&Qe(n,e);else t!==null&&typeof t=="object"&&Qe(t,e)}function mn(r){let e={};for(let t of r){let n=t.indexOf("=");if(n===-1)throw new Error(`Invalid variable format: "${t}". Expected "name=value".`);let i=t.slice(0,n).trim(),a=t.slice(n+1);if(!i)throw new Error(`Invalid variable format: "${t}". Variable name cannot be empty.`);e[i]=a}return e}var gn=3,bn=12;function yn(r){return r==null||!Number.isFinite(r)?3:r<0?0:r>12?12:Math.floor(r)}function rt(r,e){if(!Number.isFinite(r))return r;let t=Math.pow(10,e);return Math.round(r*t)/t}var zi=/-?\d+(?:\.\d+)?(?:[eE][-+]?\d+)?/g;function _r(r,e){return r.replace(zi,t=>{let n=parseFloat(t);return Number.isFinite(n)?String(rt(n,e)):t})}var Ui=new Set(["rawTransform","strokeDasharray","filterX","filterY","filterWidth","filterHeight","cssClipPath"]),Ni=new Set(["metadata","customMetadata","customAttrs","customData","bindings","richTextData","cssMaskProperties","rawMetadata"]);function te(r,e,t){if(e==null)return e;if(typeof e=="number")return rt(e,t);if(typeof e=="string")return Ui.has(r)?_r(e,t):e;if(typeof e=="boolean")return e;if(Array.isArray(e))return e.map(n=>te(r,n,t));if(typeof e=="object"){if(Ni.has(r))return e;if(r==="symbolOverrides"){let i={};for(let[a,o]of Object.entries(e))i[a]=te("state",o,t);return i}let n={};for(let[i,a]of Object.entries(e))n[i]=te(i,a,t);return n}return e}function tt(r,e){return{id:r.id,type:r.type,state:te("state",r.state,e)}}function $n(r,e){let t={...r,shapes:r.shapes.map(n=>tt(n,e)),viewboxes:r.viewboxes.map(n=>te("viewbox",n,e))};return r.guides&&(t.guides=r.guides.map(n=>te("guide",n,e))),r.measurements&&(t.measurements=r.measurements.map(n=>te("measurement",n,e))),r.animationTimeline&&(t.animationTimeline=te("animationTimeline",r.animationTimeline,e)),r.symbols&&(t.symbols=r.symbols.map(n=>({...n,shapes:n.shapes.map(i=>tt(i,e))}))),r.markers&&(t.markers=r.markers.map(n=>te("marker",n,e))),r.customPatterns&&(t.customPatterns=r.customPatterns.map(n=>te("customPattern",n,e))),t}function Ie(r,e,t=-90){let n=[],i=t*Math.PI/180;for(let a=0;a<r;a++){let o=i+a*2*Math.PI/r;n.push({x:e*Math.cos(o),y:e*Math.sin(o)})}return n}function it(r,e,t,n=-90){let i=[],a=e*(t/100),o=n*Math.PI/180;for(let l=0;l<r*2;l++){let u=o+l*Math.PI/r,c=l%2===0?e:a;i.push({x:c*Math.cos(u),y:c*Math.sin(u)})}return i}function st(r,e,t=0){let n=r*(e/100)/2,i=[{x:-n,y:-r},{x:n,y:-r},{x:n,y:-n},{x:r,y:-n},{x:r,y:n},{x:n,y:n},{x:n,y:r},{x:-n,y:r},{x:-n,y:n},{x:-r,y:n},{x:-r,y:-n},{x:-n,y:-n}];if(t===0)return i;let a=Math.cos(t*Math.PI/180),o=Math.sin(t*Math.PI/180);return i.map(l=>({x:l.x*a-l.y*o,y:l.x*o+l.y*a}))}function at(r,e,t,n,i=-90){let o=r*2*(t/100),l=r*(e/100),u=l*(n/100),c=[{x:r,y:0},{x:r-o,y:-l/2},{x:r-o,y:-u/2},{x:-r,y:-u/2},{x:-r,y:u/2},{x:r-o,y:u/2},{x:r-o,y:l/2}];if(i===0)return c;let f=Math.cos(i*Math.PI/180),d=Math.sin(i*Math.PI/180);return c.map(m=>({x:m.x*f-m.y*d,y:m.x*d+m.y*f}))}function ot(r,e,t,n,i=0){let a=r,o=a*(t/100),l=a*(n/100),u=l/2,c=e*Math.PI/180,f=Math.cos(c),d=Math.sin(c),m=Math.abs(f),p=Math.abs(d),b=Math.max(m,p)||1,g={x:f*(a/b),y:d*(a/b)},y={x:g.x+f*o,y:g.y+d*o},S=Math.min(l,a-u),v=-a+u+S,x=a-u-S,k={x:-a,y:-a},P={x:a,y:-a},_={x:a,y:a},$={x:-a,y:a},w;if(m>=p&&f>0){let R=Math.max(v,Math.min(x,g.y)),C={x:a,y:R-u},L={x:a,y:R+u};w=[k,P,C,y,L,_,$]}else if(m>=p&&f<=0){let R=Math.max(v,Math.min(x,g.y)),C={x:-a,y:R+u},L={x:-a,y:R-u};w=[k,P,_,$,C,y,L]}else if(d<0){let R=Math.max(v,Math.min(x,g.x)),C={x:R-u,y:-a},L={x:R+u,y:-a};w=[k,C,y,L,P,_,$]}else{let R=Math.max(v,Math.min(x,g.x)),C={x:R+u,y:a},L={x:R-u,y:a};w=[k,P,_,C,y,L,$]}if(i===0)return w;let F=Math.cos(i*Math.PI/180),I=Math.sin(i*Math.PI/180);return w.map(R=>({x:R.x*F-R.y*I,y:R.x*I+R.y*F}))}function lt(r,e,t,n,i=0){let a=Math.max(2,Math.round(e)),o=r*(t/100),l=r*(n/100)/2,u=a+1,c=[];for(let g=0;g<u;g++){let y=g/(u-1),S=-r+y*2*r,v=0;g>0&&g<u-1&&(v=g%2===1?o:-o),c.push({x:v,y:S})}let f=[],d=[];for(let g=0;g<u;g++){if(g===0||g===u-1){f.push({...c[g]}),d.push({...c[g]});continue}let y=c[g-1],S=c[g],v=c[g+1],x=S.x-y.x,k=S.y-y.y,P=Math.hypot(x,k)||1,_=x/P,$=k/P,w=v.x-S.x,F=v.y-S.y,I=Math.hypot(w,F)||1,R=w/I,C=F/I,L=(_+R)/2,E=($+C)/2,B=Math.hypot(L,E),A,G;B<1e-6?(A=-$,G=_):(A=-E/B,G=L/B),f.push({x:S.x-A*l,y:S.y-G*l}),d.push({x:S.x+A*l,y:S.y+G*l})}let m=[];m.push(f[0]);for(let g=1;g<u-1;g++)m.push(d[g]);m.push(f[u-1]);for(let g=u-2;g>=1;g--)m.push(f[g]);if(i===0)return m;let p=Math.cos(i*Math.PI/180),b=Math.sin(i*Math.PI/180);return m.map(g=>({x:g.x*p-g.y*b,y:g.x*b+g.y*p}))}function ut(r,e,t,n=0){let i=r,a=Math.max(.3,Math.min(.9,e/100)),o=-i*(t/100),l={x:0,y:i},u={x:0,y:o},c={x:-i*a,y:i*.4},f={x:-i*a,y:-i},d={x:i*a,y:-i},m={x:i*a,y:i*.4},p=[l,c,f,u,d,m,l],b=n===0?p:(()=>{let P=Math.cos(n*Math.PI/180),_=Math.sin(n*Math.PI/180);return p.map($=>({x:$.x*P-$.y*_,y:$.x*_+$.y*P}))})(),[g,y,S,v,x,k]=b;return`M ${g.x} ${g.y} C ${y.x} ${y.y} ${S.x} ${S.y} ${v.x} ${v.y} C ${x.x} ${x.y} ${k.x} ${k.y} ${g.x} ${g.y} Z`}function ct(r,e,t,n=0){let i=Math.max(3,Math.round(e)),a=Math.max(.3,Math.min(1,t/100)),o=r,l=o*1.7,u=o*1.15,c=[];for(let $=0;$<i;$++){let F=(90+$/i*360)*Math.PI/180;c.push({x:l/2*Math.cos(F),y:-(u/2)*Math.sin(F)})}let f=.15,d=0;for(let $=0;$<i;$++){let w=c[$],F=c[($+1)%i];d=Math.max(d,Math.hypot(F.x-w.x,F.y-w.y))}let m=d/(2*(1-f))+.001,p=Math.max(m,d*(.68+a*.35)),b=c.map($=>{let w=$.y/(u/2);return p*(1-f*w)});function g($){let w=c[$],F=c[($+1)%i],I=b[$],R=b[($+1)%i],C=F.x-w.x,L=F.y-w.y,E=Math.hypot(C,L)||1,B=(I*I-R*R+E*E)/(2*E),A=Math.sqrt(Math.max(0,I*I-B*B)),G=w.x+B/E*C,q=w.y+B/E*L,W=-L/E,de=C/E,ee={x:G+W*A,y:q+de*A},Y={x:G-W*A,y:q-de*A};return ee.x*ee.x+ee.y*ee.y>Y.x*Y.x+Y.y*Y.y?ee:Y}let y=[];for(let $=0;$<i;$++)y.push(g($));let S=14,v=[];for(let $=0;$<i;$++){let w=c[$],F=b[$],I=y[($-1+i)%i],R=y[$],C=Math.atan2(I.y-w.y,I.x-w.x),E=Math.atan2(R.y-w.y,R.x-w.x)-C;E<=0&&(E+=2*Math.PI);let B=2*Math.PI-E,A=C+E/2,G=C-B/2,q={x:w.x+F*Math.cos(A),y:w.y+F*Math.sin(A)},W={x:w.x+F*Math.cos(G),y:w.y+F*Math.sin(G)},ee=q.x*q.x+q.y*q.y>W.x*W.x+W.y*W.y?E:-B;for(let Y=0;Y<S;Y++){let Ue=Y/S,Z=C+Ue*ee;v.push({x:w.x+F*Math.cos(Z),y:w.y+F*Math.sin(Z)})}}let x=0;for(let $ of v){let w=Math.max(Math.abs($.x),Math.abs($.y));w>x&&(x=w)}if(x>0&&x!==o){let $=o/x;for(let w of v)w.x*=$,w.y*=$}let k=$=>{if(n===0)return $;let w=Math.cos(n*Math.PI/180),F=Math.sin(n*Math.PI/180);return{x:$.x*w-$.y*F,y:$.x*F+$.y*w}},P=v.map(k),_=`M ${P[0].x} ${P[0].y}`;for(let $=1;$<P.length;$++)_+=` L ${P[$].x} ${P[$].y}`;return _+=" Z",_}function J(r,e=0,t=0){if(r.length<3)return"";if(e<=0)return r.map((a,o)=>(o===0?"M":"L")+`${a.x},${a.y}`).join(" ")+" Z";let n=Math.min(e,t*.4),i="";for(let a=0;a<r.length;a++){let o=r[(a-1+r.length)%r.length],l=r[a],u=r[(a+1)%r.length],c={x:o.x-l.x,y:o.y-l.y},f=Math.hypot(c.x,c.y);c.x/=f,c.y/=f;let d={x:u.x-l.x,y:u.y-l.y},m=Math.hypot(d.x,d.y);d.x/=m,d.y/=m;let p=Math.min(n,f/2),b=Math.min(n,m/2),g={x:l.x+c.x*p,y:l.y+c.y*p},y={x:l.x+d.x*b,y:l.y+d.y*b};i+=a===0?`M${g.x},${g.y}`:` L${g.x},${g.y}`,i+=` Q${l.x},${l.y} ${y.x},${y.y}`}return i+" Z"}function dt(r,e,t="evenodd"){let n=r*(e/100),i=t==="nonzero"?1:0;return`M ${r} 0 A ${r} ${r} 0 1 1 ${-r} 0 A ${r} ${r} 0 1 1 ${r} 0 Z M ${n} 0 A ${n} ${n} 0 1 ${i} ${-n} 0 A ${n} ${n} 0 1 ${i} ${n} 0 Z`}function ft(r,e,t,n=1,i=0){let a=r*(t/100),l=Math.round(e*36),u=e*2*Math.PI,c=(r-a/2)/u,f=i*Math.PI/180,d=[],m=[];for(let g=0;g<=l;g++){let y=g/l,S=y*u*n+f,v=c*(y*u)+a/2,x=a/2;d.push({x:(v+x*.3)*Math.cos(S),y:(v+x*.3)*Math.sin(S)}),m.push({x:Math.max(0,v-x*.3)*Math.cos(S),y:Math.max(0,v-x*.3)*Math.sin(S)})}let p=`M ${d[0].x} ${d[0].y}`;for(let g=1;g<d.length;g++)p+=` L ${d[g].x} ${d[g].y}`;let b=m[m.length-1];p+=` L ${b.x} ${b.y}`;for(let g=m.length-2;g>=0;g--)p+=` L ${m[g].x} ${m[g].y}`;return p+=" Z",p}var Vi=.2;function Tr(r,e,t,n=0){let i=e*(t/100),a=e,o=e-i,l=2*Math.PI/r,u=l*Vi/2,c=l/4,f=n*Math.PI/180,d=[];for(let m=0;m<r;m++){let p=f+m*l;d.push({x:o*Math.cos(p),y:o*Math.sin(p)}),d.push({x:a*Math.cos(p+c-u),y:a*Math.sin(p+c-u)}),d.push({x:a*Math.cos(p+c+u),y:a*Math.sin(p+c+u)}),d.push({x:o*Math.cos(p+l/2),y:o*Math.sin(p+l/2)})}return d}function ht(r,e,t,n=0,i=0,a="evenodd",o=0){let l=Tr(r,e,t,o),u=Math.min(n,e*.1),c=J(l,u,e);if(i>0){let f=e*(i/100),d=a==="nonzero"?1:0;c+=` M ${f} 0 A ${f} ${f} 0 1 ${d} ${-f} 0 A ${f} ${f} 0 1 ${d} ${f} 0 Z`}return c}function pt(r,e,t,n,i,a="round",o="uniform",l){let u=Math.min(t,n)/2,c,f,d,m,p,b,g,y;if(o==="non-uniform"&&l?(c=Math.min(l.radiusTL??i,u),f=Math.min(l.radiusTR??i,u),d=Math.min(l.radiusBR??i,u),m=Math.min(l.radiusBL??i,u),p=l.shapeTL??a,b=l.shapeTR??a,g=l.shapeBR??a,y=l.shapeBL??a):(c=f=d=m=Math.min(i,u),p=b=g=y=a),!(a!=="round"||o==="non-uniform"||c>0&&p!=="round"||f>0&&b!=="round"||d>0&&g!=="round"||m>0&&y!=="round")&&c===f&&f===d&&d===m)return null;let v=`M${r+c},${e}`;return v+=` L${r+t-f},${e}`,v+=nt(b,f,r+t,e,"tr"),v+=` L${r+t},${e+n-d}`,v+=nt(g,d,r+t,e+n,"br"),v+=` L${r+m},${e+n}`,v+=nt(y,m,r,e+n,"bl"),v+=` L${r},${e+c}`,v+=nt(p,c,r,e,"tl"),v+=" Z",v}function nt(r,e,t,n,i){if(e<=0)return"";switch(r){case"round":switch(i){case"tr":return` A${e},${e} 0 0 1 ${t},${n+e}`;case"br":return` A${e},${e} 0 0 1 ${t-e},${n}`;case"bl":return` A${e},${e} 0 0 1 ${t},${n-e}`;case"tl":return` A${e},${e} 0 0 1 ${t+e},${n}`}break;case"scoop":switch(i){case"tr":return` A${e},${e} 0 0 0 ${t},${n+e}`;case"br":return` A${e},${e} 0 0 0 ${t-e},${n}`;case"bl":return` A${e},${e} 0 0 0 ${t},${n-e}`;case"tl":return` A${e},${e} 0 0 0 ${t+e},${n}`}break;case"bevel":switch(i){case"tr":return` L${t},${n+e}`;case"br":return` L${t-e},${n}`;case"bl":return` L${t},${n-e}`;case"tl":return` L${t+e},${n}`}break;case"notch":switch(i){case"tr":return` L${t-e},${n+e} L${t},${n+e}`;case"br":return` L${t-e},${n-e} L${t-e},${n}`;case"bl":return` L${t+e},${n-e} L${t},${n-e}`;case"tl":return` L${t+e},${n+e} L${t+e},${n}`}break}return""}function ye(r,e,t=!1,n=.5,i){if(r.length<2)return r.length===1?`M ${r[0].x} ${r[0].y}`:"";switch(e){case"CATMULL_ROM":case"catmull-rom":return ji(r,t,n);case"BASIS":case"basis":return Yi(r,t);case"ARC":case"arc":return i&&i.length>0?Hi(r,t,i):Ce(r,t,"CUBIC");case"LINEAR":case"linear":return Ce(r,t,"LINEAR");case"QUADRATIC":case"quadratic":return Ce(r,t,"QUADRATIC");case"CUBIC":case"cubic":return Ce(r,t,"CUBIC");default:return Ce(r,t)}}function Hi(r,e,t){let n=`M ${r[0].x} ${r[0].y}`,i=0,a={rx:50,ry:50,rotation:0,largeArc:!1,sweep:!0};for(let o=0;o<r.length-1;o++){let l=r[o+1];if(l.isSubpathStart){if(e&&o-i>=1){let c=r[i],f=t?.[o]??a;n+=` A ${f.rx} ${f.ry} ${f.rotation} ${f.largeArc?1:0} ${f.sweep?1:0} ${c.x} ${c.y} Z`}n+=` M ${l.x} ${l.y}`,i=o+1;continue}let u=t?.[o]??a;n+=` A ${u.rx} ${u.ry} ${u.rotation} ${u.largeArc?1:0} ${u.sweep?1:0} ${l.x} ${l.y}`}if(e&&r.length-i>1){let o=r[i],l=t?.[r.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 Ce(r,e,t){let n=`M ${r[0].x} ${r[0].y}`,i=0,a=null,o=null;for(let l=0;l<r.length-1;l++){let u=r[l],c=r[l+1];if(c.isSubpathStart){if(e&&l-i>=1){let d=r[i];n+=wr(u,d,d.segmentType,a,o,t),n+=" Z"}n+=` M ${c.x} ${c.y}`,i=l+1,a=null,o=null;continue}n+=wr(u,c,c.segmentType,a,o,t);let f=Xi(c.segmentType??t,u,c);a=f,f==="quad"?o=u.handleOut??null:o=null}if(e&&r.length-i>1){let l=r[r.length-1],u=r[i],c=(u.segmentType??t??(l.handleOut||u.handleIn?"CUBIC":"LINEAR")).toUpperCase();c==="LINEAR"||c==="HORIZONTAL"||c==="VERTICAL"||(n+=wr(l,u,u.segmentType,a,o,t)),n+=" Z"}return n}var Wi=.001;function be(r,e){return Math.abs(r-e)<Wi}function Xi(r,e,t){let n=(r??(e.handleOut||t.handleIn?"CUBIC":"LINEAR")).toUpperCase();return n==="CUBIC"||n==="SMOOTH_CUBIC"?"cubic":n==="QUADRATIC"||n==="SMOOTH_QUADRATIC"?"quad":null}function wr(r,e,t,n,i,a){let o=(t??a??(r.handleOut||e.handleIn?"CUBIC":"LINEAR")).toUpperCase();if(o==="LINEAR"||o==="HORIZONTAL"||o==="VERTICAL")return(o==="HORIZONTAL"||o==="LINEAR")&&be(r.y,e.y)?` H ${e.x}`:(o==="VERTICAL"||o==="LINEAR")&&be(r.x,e.x)?` V ${e.y}`:` L ${e.x} ${e.y}`;if(o==="ARC"){let c=e.arcParams;return c?` A ${c.rx} ${c.ry} ${c.rotation} ${c.largeArc?1:0} ${c.sweep?1:0} ${e.x} ${e.y}`:` L ${e.x} ${e.y}`}if(o==="QUADRATIC"||o==="SMOOTH_QUADRATIC"){let c=r.handleOut??{x:(r.x+e.x)/2,y:(r.y+e.y)/2};return n==="quad"&&i&&be(c.x,2*r.x-i.x)&&be(c.y,2*r.y-i.y)?` T ${e.x} ${e.y}`:` Q ${c.x} ${c.y} ${e.x} ${e.y}`}let l=r.handleOut??{x:r.x,y:r.y},u=e.handleIn??{x:e.x,y:e.y};return n==="cubic"&&r.handleIn&&r.handleOut&&be(r.handleOut.x,2*r.x-r.handleIn.x)&&be(r.handleOut.y,2*r.y-r.handleIn.y)?` S ${u.x} ${u.y} ${e.x} ${e.y}`:` C ${l.x} ${l.y} ${u.x} ${u.y} ${e.x} ${e.y}`}function ji(r,e,t){if(r.length<2)return r.length===1?`M ${r[0].x} ${r[0].y}`:"";let n=t,i=e?[r[r.length-1],...r,r[0],r[1]]:[r[0],...r,r[r.length-1]],a=`M ${r[0].x} ${r[0].y}`,o=e?r.length:r.length-1;for(let l=0;l<o;l++){let u=i[l],c=i[l+1],f=i[l+2],d=i[l+3],m=Math.hypot(f.x-c.x,f.y-c.y),p=Math.hypot(c.x-u.x,c.y-u.y),b=Math.hypot(d.x-f.x,d.y-f.y),g=Math.pow(p,n),y=Math.pow(m,n),S=Math.pow(b,n),v=Math.pow(p,2*n),x=Math.pow(m,2*n),k=Math.pow(b,2*n),P,_,$,w;p<1e-8?(P=c.x,_=c.y):(P=(v*f.x-x*u.x+(2*v+3*g*y+x)*c.x)/(3*g*(g+y)),_=(v*f.y-x*u.y+(2*v+3*g*y+x)*c.y)/(3*g*(g+y))),b<1e-8?($=f.x,w=f.y):($=(k*c.x-x*d.x+(2*k+3*S*y+x)*f.x)/(3*S*(S+y)),w=(k*c.y-x*d.y+(2*k+3*S*y+x)*f.y)/(3*S*(S+y))),a+=` C ${P} ${_} ${$} ${w} ${f.x} ${f.y}`}return e&&(a+=" Z"),a}function Yi(r,e){let t=r.length;if(t<2)return t===1?`M ${r[0].x} ${r[0].y}`:"";if(t===2)return`M ${r[0].x} ${r[0].y} L ${r[1].x} ${r[1].y}`;if(e){let a=(r[0].x+4*r[1].x+r[2].x)/6,o=(r[0].y+4*r[1].y+r[2].y)/6,l=`M ${a} ${o}`;for(let u=0;u<t;u++){let c=r[(u+1)%t],f=r[(u+2)%t],d=r[(u+3)%t];l+=Pr(c,f,d)}return l+=" Z",l}let n=r,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<=t-3;a++)i+=Pr(n[a],n[a+1],n[a+2]);return i+=Pr(n[t-2],n[t-1],n[t-1]),i+=` L ${n[t-1].x} ${n[t-1].y}`,i}function Pr(r,e,t){return` C ${(2*r.x+e.x)/3} ${(2*r.y+e.y)/3} ${(r.x+2*e.x)/3} ${(r.y+2*e.y)/3} ${(r.x+4*e.x+t.x)/6} ${(r.y+4*e.y+t.y)/6}`}function $e(r,e,t){let n=Number.isFinite(e)?Math.max(1,e):8,i=Number.isFinite(t)?Math.max(1,t):4;switch(r){case"dashed":case"dotted":case"custom":return`${n} ${i}`;default:return null}}var qi=[["fontVariant","font-variant"],["fontVariantLigatures","font-variant-ligatures"],["fontVariantPosition","font-variant-position"],["fontVariantCaps","font-variant-caps"],["fontVariantNumeric","font-variant-numeric"],["fontVariantEastAsian","font-variant-east-asian"]];function O(r){return r.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;")}function Zi(r){let e=r.fillType;return e||(r.fillGradient?r.fillGradient.r!==void 0?"radial-gradient":"linear-gradient":r.linearGradient?"linear-gradient":r.radialGradient?"radial-gradient":"solid")}function mt(r){let e=new Map,t=r.state,n=t;switch(r.type){case"circle":e.set("cx",String(t.x??0)),e.set("cy",String(t.y??0)),e.set("r",String(t.radius??50));break;case"ellipse":e.set("cx",String(t.cx??0)),e.set("cy",String(t.cy??0)),e.set("rx",String(t.rx??50)),e.set("ry",String(t.ry??30));break;case"rectangle":case"square":e.set("x",String(t.x??0)),e.set("y",String(t.y??0)),e.set("width",String(t.width??100)),e.set("height",String(t.height??100));{let k=t.rx??t.cornerRadius??0,P=t.ry??t.cornerRadius??0;(k>0||P>0)&&(e.set("rx",String(k)),e.set("ry",String(P)))}break;case"line":e.set("x1",String(t.x1??0)),e.set("y1",String(t.y1??0)),e.set("x2",String(t.x2??0)),e.set("y2",String(t.y2??0));break;case"text":e.set("x",String(t.x??0)),e.set("y",String(t.y??0)),t.fontSize&&e.set("font-size",String(t.fontSize)),t.fontFamily&&e.set("font-family",t.fontFamily),t.fontWeight&&e.set("font-weight",t.fontWeight),t.fontStyle&&e.set("font-style",t.fontStyle),t.textAnchor&&e.set("text-anchor",t.textAnchor),t.letterSpacing&&e.set("letter-spacing",String(t.letterSpacing));{let k=qi.map(([P,_])=>{let $=typeof t[P]=="string"?String(t[P]).trim():"";return $?`${_}: ${$}`:""}).filter(Boolean).join("; ");k&&e.set("style",k)}break;case"image":e.set("x",String(t.x??0)),e.set("y",String(t.y??0)),e.set("width",String(t.width??100)),e.set("height",String(t.height??100)),n.href&&e.set("href",String(n.href));break}let i=Zi(n);i==="none"?e.set("fill","none"):i==="linear-gradient"||i==="radial-gradient"?e.set("fill",`url(#gradient-fill-${r.id})`):i==="pattern"?e.set("fill",`url(#pattern-fill-${r.id})`):e.set("fill",t.fillColor??"#000000");let a=t.opacity;a!==void 0&&a<1&&e.set("opacity",String(a));let o=t.fillOpacity;o!==void 0&&o<1&&e.set("fill-opacity",String(o)),t.fillRule&&t.fillRule!=="nonzero"&&e.set("fill-rule",t.fillRule);let l=n.strokeType??"solid";if(l==="none")e.set("stroke","none");else if(l==="linear-gradient"||l==="radial-gradient")e.set("stroke",`url(#gradient-stroke-${r.id})`);else{let k=t.borderColor??"none";k!=="none"&&e.set("stroke",k)}let u=t.borderWidth;u!=null&&u!==0&&e.set("stroke-width",String(u));let c=t.strokeOpacity;c!==void 0&&c<1&&e.set("stroke-opacity",String(c));let f=t.lineStyle??"solid",d=t.dashLength??8,m=t.gapLength??4,p=$e(f,d,m);p&&(e.set("stroke-dasharray",p),f==="dotted"&&e.set("stroke-linecap","round"));let b=Ki(n);b&&e.set("transform",b);let g=n.filters;g&&g.length>0&&e.set("filter",`url(#filter-${r.id})`);let y=t.shapeRendering;y&&y!=="auto"&&e.set("shape-rendering",y),t.pathLength!==void 0&&e.set("pathLength",String(t.pathLength));let S=n.startEndpoint,v=n.endEndpoint;S&&S!=="none"&&e.set("marker-start",`url(#line-marker-${S})`),v&&v!=="none"&&e.set("marker-end",`url(#line-marker-${v})`);let x=n.metadata;return x&&(x.role&&e.set("role",x.role),x.ariaLabel&&e.set("aria-label",x.ariaLabel)),e}function xn(r){switch(r.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"path":case"polyline":case"triangle":case"ngon":case"star":case"cross":case"ring":case"spiral":case"gear":case"arrow":return"path";default:return"g"}}function Ki(r){return ge(r)}function re(r,e){let t=r.viewboxes?.[0];return{width:e.width??t?.width??800,height:e.height??t?.height??600}}function s(r,e){return e==null||e===""?"":` ${r}="${O(String(e))}"`}function bt(r){let e=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(r);return e?{r:parseInt(e[1],16)/255,g:parseInt(e[2],16)/255,b:parseInt(e[3],16)/255}:{r:0,g:0,b:0}}function Qi(r,e,t){let{offsetX:n,offsetY:i,blurRadius:a,spread:o,color:l,opacity:u}=r,c="";if(o===0)c+=`<feDropShadow${s("in",e)}${s("dx",n)}${s("dy",i)}${s("stdDeviation",a/2)}${s("flood-color",l)}${s("flood-opacity",u)}${s("result",`${t}_shadow`)}/>`,c+=`<feMerge${s("result",t)}><feMergeNode${s("in",`${t}_shadow`)}/><feMergeNode${s("in",e)}/></feMerge>`;else{c+=`<feColorMatrix${s("in",e)}${s("type","matrix")}${s("values","0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0")}${s("result",`${t}_alpha`)}/>`;let f=o>0?"dilate":"erode",d=Math.abs(o);c+=`<feMorphology${s("in",`${t}_alpha`)}${s("operator",f)}${s("radius",d)}${s("result",`${t}_spread`)}/>`,c+=`<feGaussianBlur${s("in",`${t}_spread`)}${s("stdDeviation",a/2)}${s("result",`${t}_blur`)}/>`,c+=`<feOffset${s("in",`${t}_blur`)}${s("dx",n)}${s("dy",i)}${s("result",`${t}_offset`)}/>`,c+=`<feFlood${s("flood-color",l)}${s("flood-opacity",u)}${s("result",`${t}_color`)}/>`,c+=`<feComposite${s("in",`${t}_color`)}${s("in2",`${t}_offset`)}${s("operator","in")}${s("result",`${t}_shadow`)}/>`,c+=`<feMerge${s("result",t)}><feMergeNode${s("in",`${t}_shadow`)}/><feMergeNode${s("in",e)}/></feMerge>`}return c}function Ji(r,e,t){let{offsetX:n,offsetY:i,blurRadius:a,choke:o,color:l,opacity:u}=r,c=a*(1-o/100),f="";return f+=`<feColorMatrix${s("in",e)}${s("type","matrix")}${s("values","0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0")}${s("result",`${t}_alpha`)}/>`,f+=`<feComponentTransfer${s("in",`${t}_alpha`)}${s("result",`${t}_inverted`)}><feFuncA${s("type","table")}${s("tableValues","1 0")}/></feComponentTransfer>`,f+=`<feGaussianBlur${s("in",`${t}_inverted`)}${s("stdDeviation",c/2)}${s("result",`${t}_blur`)}/>`,f+=`<feOffset${s("in",`${t}_blur`)}${s("dx",n)}${s("dy",i)}${s("result",`${t}_offset`)}/>`,f+=`<feFlood${s("flood-color",l)}${s("flood-opacity",u)}${s("result",`${t}_color`)}/>`,f+=`<feComposite${s("in",`${t}_color`)}${s("in2",`${t}_offset`)}${s("operator","in")}${s("result",`${t}_coloredShadow`)}/>`,f+=`<feComposite${s("in",`${t}_coloredShadow`)}${s("in2",`${t}_alpha`)}${s("operator","in")}${s("result",`${t}_innerShadow`)}/>`,f+=`<feComposite${s("in",`${t}_innerShadow`)}${s("in2",e)}${s("operator","over")}${s("result",t)}/>`,f}function es(r,e,t){let{blurX:n,blurY:i}=r;return n===0&&i===0?D(e,t):`<feGaussianBlur${s("in",e)}${s("stdDeviation",`${n/2} ${i/2}`)}${s("result",t)}/>`}function ts(r,e,t){let{distance:n,angle:i}=r;if(n===0)return D(e,t);let a=i*Math.PI/180,o=Math.abs(Math.cos(a)*n),l=Math.abs(Math.sin(a)*n);return`<feGaussianBlur${s("in",e)}${s("stdDeviation",`${o/2} ${l/2}`)}${s("result",t)}/>`}function Sn(r,e,t){let{x:n,y:i,z:a,color:o,surfaceScale:l,diffuseConstant:u,specularConstant:c,specularExponent:f}=r,d="";return d+=`<feDiffuseLighting${s("in","SourceAlpha")}${s("surfaceScale",l)}${s("diffuseConstant",u)}${s("lighting-color",o)}${s("result",`${t}_diffuse`)}>`,d+=`<fePointLight${s("x",n)}${s("y",i)}${s("z",a)}/>`,d+="</feDiffuseLighting>",d+=`<feSpecularLighting${s("in","SourceAlpha")}${s("surfaceScale",l)}${s("specularConstant",c)}${s("specularExponent",f)}${s("lighting-color",o)}${s("result",`${t}_specular`)}>`,d+=`<fePointLight${s("x",n)}${s("y",i)}${s("z",a)}/>`,d+="</feSpecularLighting>",d+=`<feComposite${s("in",e)}${s("in2",`${t}_diffuse`)}${s("operator","arithmetic")}${s("k1",1)}${s("k2",0)}${s("k3",0)}${s("k4",0)}${s("result",`${t}_lit`)}/>`,d+=`<feComposite${s("in",`${t}_specular`)}${s("in2",`${t}_lit`)}${s("operator","arithmetic")}${s("k1",0)}${s("k2",1)}${s("k3",1)}${s("k4",0)}${s("result",t)}/>`,d}function kn(r,e,t){let{x:n,y:i,z:a,pointsAtX:o,pointsAtY:l,pointsAtZ:u,coneAngle:c,color:f,surfaceScale:d,specularConstant:m,specularExponent:p}=r,b="";return b+=`<feSpecularLighting${s("in","SourceAlpha")}${s("surfaceScale",d)}${s("specularConstant",m)}${s("specularExponent",p)}${s("lighting-color",f)}${s("result",`${t}_specular`)}>`,b+=`<feSpotLight${s("x",n)}${s("y",i)}${s("z",a)}${s("pointsAtX",o)}${s("pointsAtY",l)}${s("pointsAtZ",u)}${s("limitingConeAngle",c)}/>`,b+="</feSpecularLighting>",b+=`<feComposite${s("in",`${t}_specular`)}${s("in2","SourceAlpha")}${s("operator","in")}${s("result",`${t}_clipped`)}/>`,b+=`<feComposite${s("in",`${t}_clipped`)}${s("in2",e)}${s("operator","arithmetic")}${s("k1",0)}${s("k2",1)}${s("k3",1)}${s("k4",0)}${s("result",t)}/>`,b}function vn(r){switch(r.kind){case"point":return`<fePointLight${s("x",r.x)}${s("y",r.y)}${s("z",r.z)}/>`;case"spot":{let e=`<feSpotLight${s("x",r.x)}${s("y",r.y)}${s("z",r.z)}${s("pointsAtX",r.pointsAtX)}${s("pointsAtY",r.pointsAtY)}${s("pointsAtZ",r.pointsAtZ)}`;return r.limitingConeAngle!==void 0&&(e+=s("limitingConeAngle",r.limitingConeAngle)),r.specularExponent!==void 0&&(e+=s("specularExponent",r.specularExponent)),e+"/>"}case"distant":return`<feDistantLight${s("azimuth",r.azimuth)}${s("elevation",r.elevation)}/>`}}function rs(r,e,t){return`<feDiffuseLighting${s("in",e)}${s("surfaceScale",r.surfaceScale)}${s("diffuseConstant",r.diffuseConstant)}${s("lighting-color",r.color)}${s("result",t)}>`+vn(r.lightSource)+"</feDiffuseLighting>"}function ns(r,e,t){return`<feSpecularLighting${s("in",e)}${s("surfaceScale",r.surfaceScale)}${s("specularConstant",r.specularConstant)}${s("specularExponent",r.specularExponent)}${s("lighting-color",r.color)}${s("result",t)}>`+vn(r.lightSource)+"</feSpecularLighting>"}function is(r,e,t){let{width:n,color:i,opacity:a,position:o}=r,l="";if(o==="inside")l+=`<feMorphology${s("in","SourceAlpha")}${s("operator","erode")}${s("radius",n)}${s("result",`${t}_eroded`)}/>`,l+=`<feComposite${s("in","SourceAlpha")}${s("in2",`${t}_eroded`)}${s("operator","out")}${s("result",`${t}_outlineAlpha`)}/>`,l+=`<feFlood${s("flood-color",i)}${s("flood-opacity",a)}${s("result",`${t}_color`)}/>`,l+=`<feComposite${s("in",`${t}_color`)}${s("in2",`${t}_outlineAlpha`)}${s("operator","in")}${s("result",`${t}_outline`)}/>`,l+=`<feComposite${s("in",`${t}_outline`)}${s("in2",e)}${s("operator","over")}${s("result",t)}/>`;else{let u=o==="outside"?n:n/2;l+=`<feMorphology${s("in","SourceAlpha")}${s("operator","dilate")}${s("radius",u)}${s("result",`${t}_dilated`)}/>`,l+=`<feComposite${s("in",`${t}_dilated`)}${s("in2","SourceAlpha")}${s("operator","out")}${s("result",`${t}_outlineAlpha`)}/>`,l+=`<feFlood${s("flood-color",i)}${s("flood-opacity",a)}${s("result",`${t}_color`)}/>`,l+=`<feComposite${s("in",`${t}_color`)}${s("in2",`${t}_outlineAlpha`)}${s("operator","in")}${s("result",`${t}_outline`)}/>`,l+=`<feMerge${s("result",t)}><feMergeNode${s("in",`${t}_outline`)}/><feMergeNode${s("in",e)}/></feMerge>`}return l}function ss(r,e,t){let{amount:n}=r;if(n===0)return D(e,t);let i=1+4*n,a=-n,o=[0,a,0,a,i,a,0,a,0].join(" ");return`<feConvolveMatrix${s("in",e)}${s("order","3")}${s("kernelMatrix",o)}${s("divisor","1")}${s("bias","0")}${s("preserveAlpha","true")}${s("edgeMode","duplicate")}${s("result",t)}/>`}function as(r,e,t){let{blockSize:n}=r;if(n<=1)return D(e,t);let i=n/2,a="";return a+=`<feMorphology${s("in",e)}${s("operator","erode")}${s("radius",i)}${s("result",`${t}_eroded`)}/>`,a+=`<feMorphology${s("in",`${t}_eroded`)}${s("operator","dilate")}${s("radius",i)}${s("result",t)}/>`,a}function os(r,e,t){let{scale:n,frequency:i,octaves:a,warpType:o}=r;if(n===0)return D(e,t);let l="";return l+=`<feTurbulence${s("type",o)}${s("baseFrequency",i)}${s("numOctaves",a)}${s("seed",0)}${s("result",`${t}_turbulence`)}/>`,l+=`<feDisplacementMap${s("in",e)}${s("in2",`${t}_turbulence`)}${s("scale",n)}${s("xChannelSelector","R")}${s("yChannelSelector","G")}${s("result",t)}/>`,l}function ls(r,e,t){let{operator:n,radiusX:i,radiusY:a}=r;return i===0&&a===0?D(e,t):`<feMorphology${s("in",e)}${s("operator",n)}${s("radius",`${i} ${a}`)}${s("result",t)}/>`}function us(r,e,t){let{levels:n}=r;if(n<2)return D(e,t);let i=[];for(let l=0;l<n;l++)i.push(l/(n-1));let a=i.join(" "),o=`<feComponentTransfer${s("in",e)}${s("result",t)}>`;return o+=`<feFuncR${s("type","discrete")}${s("tableValues",a)}/>`,o+=`<feFuncG${s("type","discrete")}${s("tableValues",a)}/>`,o+=`<feFuncB${s("type","discrete")}${s("tableValues",a)}/>`,o+="</feComponentTransfer>",o}function cs(r,e,t){let{levels:n,contrast:i}=r;if(n<2)return D(e,t);let a=[];for(let u=0;u<n;u++){let c=u/(n-1),f=c;i!==1&&(f=.5+(c-.5)*i,f=Math.max(0,Math.min(1,f))),a.push(f)}let o=a.join(" "),l=`<feComponentTransfer${s("in",e)}${s("result",t)}>`;return l+=`<feFuncR${s("type","table")}${s("tableValues",o)}/>`,l+=`<feFuncG${s("type","table")}${s("tableValues",o)}/>`,l+=`<feFuncB${s("type","table")}${s("tableValues",o)}/>`,l+="</feComponentTransfer>",l}function ds(r,e,t){let{radius:n}=r;if(n===0)return D(e,t);let i="";return i+=`<feGaussianBlur${s("in","SourceAlpha")}${s("stdDeviation",n)}${s("result",`${t}_blurredAlpha`)}/>`,i+=`<feComponentTransfer${s("in",`${t}_blurredAlpha`)}${s("result",`${t}_thresholdAlpha`)}><feFuncA${s("type","linear")}${s("slope",20)}${s("intercept",-9)}/></feComponentTransfer>`,i+=`<feComposite${s("in",e)}${s("in2",`${t}_thresholdAlpha`)}${s("operator","in")}${s("result",t)}/>`,i}function fs(r,e,t){let{amount:n}=r;if(n===0)return D(e,t);let i=1-n;return`<feColorMatrix${s("color-interpolation-filters","sRGB")}${s("in",e)}${s("type","saturate")}${s("values",i)}${s("result",t)}/>`}function hs(r,e,t){let{red:n,green:i,blue:a}=r;if(n===1&&i===1&&a===1)return D(e,t);let o=`<feComponentTransfer${s("in",e)}${s("result",t)}>`;return o+=`<feFuncR${s("type","linear")}${s("slope",n)}${s("intercept",0)}/>`,o+=`<feFuncG${s("type","linear")}${s("slope",i)}${s("intercept",0)}/>`,o+=`<feFuncB${s("type","linear")}${s("slope",a)}${s("intercept",0)}/>`,o+="</feComponentTransfer>",o}function ps(r,e,t){let{amount:n}=r;if(n===1)return D(e,t);let i=`<feComponentTransfer${s("color-interpolation-filters","sRGB")}${s("in",e)}${s("result",t)}>`;return i+=`<feFuncR${s("type","linear")}${s("slope",n)}${s("intercept",0)}/>`,i+=`<feFuncG${s("type","linear")}${s("slope",n)}${s("intercept",0)}/>`,i+=`<feFuncB${s("type","linear")}${s("slope",n)}${s("intercept",0)}/>`,i+="</feComponentTransfer>",i}function ms(r,e,t){let{amount:n}=r;if(n===1)return D(e,t);let i=.5*(1-n),a=`<feComponentTransfer${s("color-interpolation-filters","sRGB")}${s("in",e)}${s("result",t)}>`;return a+=`<feFuncR${s("type","linear")}${s("slope",n)}${s("intercept",i)}/>`,a+=`<feFuncG${s("type","linear")}${s("slope",n)}${s("intercept",i)}/>`,a+=`<feFuncB${s("type","linear")}${s("slope",n)}${s("intercept",i)}/>`,a+="</feComponentTransfer>",a}function gs(r,e,t){let{amount:n}=r;if(n===1)return D(e,t);let i=`<feComponentTransfer${s("color-interpolation-filters","sRGB")}${s("in",e)}${s("result",t)}>`;return i+=`<feFuncA${s("type","linear")}${s("slope",n)}${s("intercept",0)}/>`,i+="</feComponentTransfer>",i}function bs(r,e,t){let{amount:n}=r;if(n===0)return D(e,t);let i=n,a=1-n,o=`${i} ${a}`,l=`<feComponentTransfer${s("color-interpolation-filters","sRGB")}${s("in",e)}${s("result",t)}>`;return l+=`<feFuncR${s("type","table")}${s("tableValues",o)}/>`,l+=`<feFuncG${s("type","table")}${s("tableValues",o)}/>`,l+=`<feFuncB${s("type","table")}${s("tableValues",o)}/>`,l+="</feComponentTransfer>",l}function ys(r,e,t){let{angle:n}=r;return n===0||n===360?D(e,t):`<feColorMatrix${s("color-interpolation-filters","sRGB")}${s("in",e)}${s("type","hueRotate")}${s("values",n)}${s("result",t)}/>`}function $s(r,e,t){let{amount:n}=r;return n===1?D(e,t):`<feColorMatrix${s("color-interpolation-filters","sRGB")}${s("in",e)}${s("type","saturate")}${s("values",n)}${s("result",t)}/>`}function xs(r,e,t){let{threshold:n}=r,i="";if(i+=`<feColorMatrix${s("in",e)}${s("type","saturate")}${s("values",0)}${s("result",`${t}_gray`)}/>`,n===.5)i+=`<feComponentTransfer${s("in",`${t}_gray`)}${s("result",t)}>`,i+=`<feFuncR${s("type","discrete")}${s("tableValues","0 1")}/>`,i+=`<feFuncG${s("type","discrete")}${s("tableValues","0 1")}/>`,i+=`<feFuncB${s("type","discrete")}${s("tableValues","0 1")}/>`,i+="</feComponentTransfer>";else{let o=[];for(let u=0;u<256;u++)o.push(u/255<n?0:1);let l=o.join(" ");i+=`<feComponentTransfer${s("in",`${t}_gray`)}${s("result",t)}>`,i+=`<feFuncR${s("type","table")}${s("tableValues",l)}/>`,i+=`<feFuncG${s("type","table")}${s("tableValues",l)}/>`,i+=`<feFuncB${s("type","table")}${s("tableValues",l)}/>`,i+="</feComponentTransfer>"}return i}function Ss(r,e,t){let{amount:n}=r;if(n===0)return D(e,t);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],u=[0,1,0,0,0],c=[0,0,1,0,0],f=(g,y)=>g.map((S,v)=>S*(1-n)+y[v]*n),d=f(l,i),m=f(u,a),p=f(c,o),b=[...d,...m,...p,0,0,0,1,0].join(" ");return`<feColorMatrix${s("color-interpolation-filters","sRGB")}${s("in",e)}${s("type","matrix")}${s("values",b)}${s("result",t)}/>`}function ks(r,e,t){let{shadowColor:n,highlightColor:i}=r,a=bt(n),o=bt(i),l="";return l+=`<feColorMatrix${s("in",e)}${s("type","saturate")}${s("values",0)}${s("result",`${t}_gray`)}/>`,l+=`<feComponentTransfer${s("in",`${t}_gray`)}${s("result",t)}>`,l+=`<feFuncR${s("type","table")}${s("tableValues",`${a.r} ${o.r}`)}/>`,l+=`<feFuncG${s("type","table")}${s("tableValues",`${a.g} ${o.g}`)}/>`,l+=`<feFuncB${s("type","table")}${s("tableValues",`${a.b} ${o.b}`)}/>`,l+="</feComponentTransfer>",l}function vs(r,e,t){let{intensity:n}=r;if(n===0)return D(e,t);let i="";i+=`<feComponentTransfer${s("in",e)}${s("result",`${t}_invert`)}>`,i+=`<feFuncR${s("type","table")}${s("tableValues","1 0")}/>`,i+=`<feFuncG${s("type","table")}${s("tableValues","1 0")}/>`,i+=`<feFuncB${s("type","table")}${s("tableValues","1 0")}/>`,i+="</feComponentTransfer>",i+=`<feColorMatrix${s("in",`${t}_invert`)}${s("type","saturate")}${s("values",0)}${s("result",`${t}_gray`)}/>`;let a=[.1,.1,.1,0,0],o=[.3,.4,.3,0,0],l=[.5,.5,.8,0,0],u=[1,0,0,0,0],c=[0,1,0,0,0],f=[0,0,1,0,0],d=(y,S)=>y.map((v,x)=>v*(1-n)+S[x]*n),m=d(u,a),p=d(c,o),b=d(f,l),g=[...m,...p,...b,0,0,0,1,0].join(" ");return i+=`<feColorMatrix${s("in",`${t}_gray`)}${s("type","matrix")}${s("values",g)}${s("result",t)}/>`,i}function _s(r,e,t){let{amount:n,scale:i}=r;if(n===0)return D(e,t);let a=1/i,o="";return o+=`<feTurbulence${s("type","fractalNoise")}${s("baseFrequency",a)}${s("numOctaves",3)}${s("seed",0)}${s("result",`${t}_noise`)}/>`,o+=`<feColorMatrix${s("in",`${t}_noise`)}${s("type","saturate")}${s("values",0)}${s("result",`${t}_noiseGray`)}/>`,o+=`<feBlend${s("in",e)}${s("in2",`${t}_noiseGray`)}${s("mode","overlay")}${s("result",`${t}_blended`)}/>`,o+=`<feComposite${s("in",`${t}_blended`)}${s("in2",e)}${s("operator","arithmetic")}${s("k1",0)}${s("k2",n)}${s("k3",1-n)}${s("k4",0)}${s("result",`${t}_amt`)}/>`,o+=`<feComposite${s("in",`${t}_amt`)}${s("in2",e)}${s("operator","in")}${s("result",t)}/>`,o}function ws(r,e,t){let{strength:n,angle:i}=r;if(n===0)return D(e,t);let a=i*Math.PI/180,o=Math.cos(a),l=Math.sin(a),u=n,c=[-(u*(o+l)),-(u*l),u*(-o+l),-(u*o),1,u*o,u*(o-l),u*l,u*(o+l)].join(" ");return`<feConvolveMatrix${s("in",e)}${s("order","3 3")}${s("kernelMatrix",c)}${s("divisor",1)}${s("bias",.5)}${s("preserveAlpha","true")}${s("result",t)}/>`}function Ps(r,e,t){let{amount:n,size:i}=r;if(n===0)return D(e,t);let a=.5/i,o="";return o+=`<feTurbulence${s("type","fractalNoise")}${s("baseFrequency",`${a} ${a}`)}${s("numOctaves",5)}${s("seed",0)}${s("stitchTiles","stitch")}${s("result",`${t}_grain`)}/>`,o+=`<feColorMatrix${s("in",`${t}_grain`)}${s("type","saturate")}${s("values",0)}${s("result",`${t}_grainGray`)}/>`,o+=`<feBlend${s("in",e)}${s("in2",`${t}_grainGray`)}${s("mode","soft-light")}${s("result",`${t}_blended`)}/>`,o+=`<feComposite${s("in",`${t}_blended`)}${s("in2",e)}${s("operator","arithmetic")}${s("k1",0)}${s("k2",n)}${s("k3",1-n)}${s("k4",0)}${s("result",`${t}_amt`)}/>`,o+=`<feComposite${s("in",`${t}_amt`)}${s("in2",e)}${s("operator","in")}${s("result",t)}/>`,o}function Ts(r,e,t){let{wetness:n,turbulence:i}=r;if(n===0&&i===0)return D(e,t);let a="";return a+=`<feTurbulence${s("type","fractalNoise")}${s("baseFrequency",.02+i*.03)}${s("numOctaves",4)}${s("seed",42)}${s("result",`${t}_turb`)}/>`,a+=`<feDisplacementMap${s("in",e)}${s("in2",`${t}_turb`)}${s("scale",n*15)}${s("xChannelSelector","R")}${s("yChannelSelector","G")}${s("result",`${t}_disp`)}/>`,a+=`<feGaussianBlur${s("in",`${t}_disp`)}${s("stdDeviation",n*2)}${s("result",`${t}_blur`)}/>`,a+=`<feBlend${s("in",`${t}_blur`)}${s("in2",e)}${s("mode","multiply")}${s("result",t)}/>`,a}function As(r,e,t){let{thickness:n,texture:i}=r;if(n===0&&i===0)return D(e,t);let a="";a+=`<feTurbulence${s("type","turbulence")}${s("baseFrequency",.03+i*.02)}${s("numOctaves",3)}${s("seed",1e3)}${s("result",`${t}_brush`)}/>`;let o=Math.max(3,8-Math.floor(n*5)),l=Array.from({length:o+1},(u,c)=>c/o).join(" ");a+=`<feComponentTransfer${s("in",e)}${s("result",`${t}_poster`)}>`;for(let u of["R","G","B"])a+=`<feFunc${u}${s("type","discrete")}${s("tableValues",l)}/>`;return a+="</feComponentTransfer>",a+=`<feDisplacementMap${s("in",`${t}_poster`)}${s("in2",`${t}_brush`)}${s("scale",i*4)}${s("xChannelSelector","R")}${s("yChannelSelector","G")}${s("result",`${t}_disp`)}/>`,a+=`<feMorphology${s("in",`${t}_disp`)}${s("operator","dilate")}${s("radius",n*.5)}${s("result",`${t}_thick`)}/>`,a+=`<feComposite${s("in",`${t}_thick`)}${s("in2",e)}${s("operator","in")}${s("result",t)}/>`,a}function Fs(r,e,t){let{spread:n,edges:i}=r;if(n===0&&i===0)return D(e,t);let a="";return a+=`<feTurbulence${s("type","fractalNoise")}${s("baseFrequency",.01+i*.02)}${s("numOctaves",5)}${s("seed",1100)}${s("result",`${t}_ink`)}/>`,a+=`<feMorphology${s("in",e)}${s("operator","dilate")}${s("radius",n*3)}${s("result",`${t}_dilate`)}/>`,a+=`<feDisplacementMap${s("in",`${t}_dilate`)}${s("in2",`${t}_ink`)}${s("scale",i*10)}${s("xChannelSelector","R")}${s("yChannelSelector","G")}${s("result",`${t}_disp`)}/>`,a+=`<feGaussianBlur${s("in",`${t}_disp`)}${s("stdDeviation",n*.5)}${s("result",t)}/>`,a}function Ms(r,e,t){let{wrinkles:n,shine:i}=r;if(n===0&&i===0)return D(e,t);let a="";return a+=`<feTurbulence${s("type","turbulence")}${s("baseFrequency",.02)}${s("numOctaves",4)}${s("seed",1200)}${s("result",`${t}_wrinkle`)}/>`,a+=`<feDisplacementMap${s("in",e)}${s("in2",`${t}_wrinkle`)}${s("scale",n*15)}${s("xChannelSelector","R")}${s("yChannelSelector","G")}${s("result",`${t}_disp`)}/>`,a+=`<feSpecularLighting${s("in",`${t}_wrinkle`)}${s("surfaceScale",n*2)}${s("specularConstant",i*1.5)}${s("specularExponent",20)}${s("result",`${t}_sheen`)}>`,a+=`<feDistantLight${s("azimuth",45)}${s("elevation",60)}/>`,a+="</feSpecularLighting>",a+=`<feBlend${s("in",`${t}_disp`)}${s("in2",`${t}_sheen`)}${s("mode","screen")}${s("result",`${t}_blend`)}/>`,a+=`<feComposite${s("in",`${t}_blend`)}${s("in2",e)}${s("operator","in")}${s("result",t)}/>`,a}function Rs(r,e,t){let{density:n,size:i}=r;if(n===0)return D(e,t);let a="",o=1-n;a+=`<feTurbulence${s("type","turbulence")}${s("baseFrequency",.1/i)}${s("numOctaves",1)}${s("seed",1400)}${s("result",`${t}_hole`)}/>`,a+=`<feComponentTransfer${s("in",`${t}_hole`)}${s("result",`${t}_thresh`)}>`;for(let l of["R","G","B","A"])a+=`<feFunc${l}${s("type","linear")}${s("slope",10)}${s("intercept",-o*10+5)}/>`;a+="</feComponentTransfer>",a+=`<feComponentTransfer${s("in",`${t}_thresh`)}${s("result",`${t}_clamp`)}>`;for(let l of["R","G","B","A"])a+=`<feFunc${l}${s("type","table")}${s("tableValues","0 0 1 1")}/>`;return a+="</feComponentTransfer>",a+=`<feComposite${s("in",e)}${s("in2",`${t}_clamp`)}${s("operator","in")}${s("result",t)}/>`,a}function Cs(r,e,t){let{color:n,radius:i,intensity:a}=r;if(a===0||i===0)return D(e,t);let{r:o,g:l,b:u}=bt(n),c="";return c+=`<feColorMatrix${s("in",e)}${s("type","matrix")}${s("values","0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0")}${s("result",`${t}_alpha`)}/>`,c+=`<feGaussianBlur${s("in",`${t}_alpha`)}${s("stdDeviation",i/2)}${s("result",`${t}_blur`)}/>`,c+=`<feColorMatrix${s("in",`${t}_blur`)}${s("type","matrix")}${s("values",`0 0 0 0 ${o} 0 0 0 0 ${l} 0 0 0 0 ${u} 0 0 0 ${a} 0`)}${s("result",`${t}_color`)}/>`,c+=`<feMerge${s("result",t)}><feMergeNode${s("in",`${t}_color`)}/><feMergeNode${s("in",e)}/></feMerge>`,c}function Is(r,e,t){let{color:n,radius:i,intensity:a}=r;if(a===0||i===0)return D(e,t);let{r:o,g:l,b:u}=bt(n),c="";return c+=`<feColorMatrix${s("in",e)}${s("type","matrix")}${s("values","0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0")}${s("result",`${t}_alpha`)}/>`,c+=`<feMorphology${s("in",`${t}_alpha`)}${s("operator","erode")}${s("radius",i/4)}${s("result",`${t}_erode`)}/>`,c+=`<feComposite${s("in",`${t}_alpha`)}${s("in2",`${t}_erode`)}${s("operator","out")}${s("result",`${t}_edge`)}/>`,c+=`<feGaussianBlur${s("in",`${t}_edge`)}${s("stdDeviation",i/3)}${s("result",`${t}_blur`)}/>`,c+=`<feColorMatrix${s("in",`${t}_blur`)}${s("type","matrix")}${s("values",`0 0 0 0 ${o} 0 0 0 0 ${l} 0 0 0 0 ${u} 0 0 0 ${a*2} 0`)}${s("result",`${t}_color`)}/>`,c+=`<feComposite${s("in",`${t}_color`)}${s("in2",`${t}_alpha`)}${s("operator","in")}${s("result",`${t}_clipped`)}/>`,c+=`<feComposite${s("in",`${t}_clipped`)}${s("in2",e)}${s("operator","over")}${s("result",t)}/>`,c}function D(r,e){return`<feMerge${s("result",e)}><feMergeNode${s("in",r)}/></feMerge>`}function yt(r){switch(r.type){case"feBlend":return Ls(r);case"feColorMatrix":return Es(r);case"feComponentTransfer":return Ds(r);case"feComposite":return Bs(r);case"feConvolveMatrix":return Os(r);case"feDiffuseLighting":return Gs(r);case"feSpecularLighting":return zs(r);case"feDisplacementMap":return Us(r);case"feDropShadow":return Ns(r);case"feFlood":return Vs(r);case"feGaussianBlur":return Hs(r);case"feImage":return Ws(r);case"feMerge":return Xs(r);case"feMorphology":return js(r);case"feOffset":return Ys(r);case"feTile":return qs(r);case"feTurbulence":return Zs(r)}}function N(r){let e="";if(e+=s("in",r.in),e+=s("x",r.x),e+=s("y",r.y),e+=s("width",r.width),e+=s("height",r.height),e+=s("color-interpolation-filters",r.colorInterpolationFilters),e+=s("result",r.result),r.unknownAttrs){let t=Object.keys(r.unknownAttrs).sort();for(let n of t)e+=s(n,r.unknownAttrs[n])}return e}function V(r){return r.animations&&r.animations.length>0?r.animations.join(""):""}function Ls(r){let e=`<feBlend${N(r)}${s("in2",r.in2)}${s("mode",r.mode)}`;r.noComposite&&(e+=' no-composite="no-composite"');let t=V(r);return t?`${e}>${t}</feBlend>`:`${e}/>`}function Es(r){let e=`<feColorMatrix${N(r)}${s("type",r.matrixType)}${s("values",r.values)}`,t=V(r);return t?`${e}>${t}</feColorMatrix>`:`${e}/>`}function gt(r,e){if(!e)return"";let t=`feFunc${r}`;switch(e.type){case"identity":return`<${t} type="identity"/>`;case"table":case"discrete":return`<${t} type="${e.type}"${s("tableValues",e.tableValues.join(" "))}/>`;case"linear":return`<${t} type="linear"${s("slope",e.slope)}${s("intercept",e.intercept)}/>`;case"gamma":return`<${t} type="gamma"${s("amplitude",e.amplitude)}${s("exponent",e.exponent)}${s("offset",e.offset)}/>`}}function Ds(r){let e="";return e+=gt("R",r.funcR),e+=gt("G",r.funcG),e+=gt("B",r.funcB),e+=gt("A",r.funcA),e+=V(r),`<feComponentTransfer${N(r)}>${e}</feComponentTransfer>`}function Bs(r){let e=`<feComposite${N(r)}${s("in2",r.in2)}${s("operator",r.operator)}`;r.operator==="arithmetic"&&(e+=s("k1",r.k1),e+=s("k2",r.k2),e+=s("k3",r.k3),e+=s("k4",r.k4));let t=V(r);return t?`${e}>${t}</feComposite>`:`${e}/>`}function Os(r){let e=`<feConvolveMatrix${N(r)}`;e+=s("order",r.order),e+=s("kernelMatrix",r.kernelMatrix),e+=s("divisor",r.divisor),e+=s("bias",r.bias),e+=s("targetX",r.targetX),e+=s("targetY",r.targetY),e+=s("edgeMode",r.edgeMode),e+=s("kernelUnitLength",r.kernelUnitLength),r.preserveAlpha!==void 0&&(e+=s("preserveAlpha",r.preserveAlpha?"true":"false"));let t=V(r);return t?`${e}>${t}</feConvolveMatrix>`:`${e}/>`}function _n(r){switch(r.kind){case"feDistantLight":return`<feDistantLight${s("azimuth",r.azimuth)}${s("elevation",r.elevation)}/>`;case"fePointLight":return`<fePointLight${s("x",r.x)}${s("y",r.y)}${s("z",r.z)}/>`;case"feSpotLight":{let e=`<feSpotLight${s("x",r.x)}${s("y",r.y)}${s("z",r.z)}${s("pointsAtX",r.pointsAtX)}${s("pointsAtY",r.pointsAtY)}${s("pointsAtZ",r.pointsAtZ)}`;return e+=s("specularExponent",r.specularExponent),e+=s("limitingConeAngle",r.limitingConeAngle),e+"/>"}}}function Gs(r){let e=`<feDiffuseLighting${N(r)}`;e+=s("surfaceScale",r.surfaceScale),e+=s("diffuseConstant",r.diffuseConstant),e+=s("kernelUnitLength",r.kernelUnitLength),e+=s("lighting-color",r.lightingColor);let t="";return r.lightSource&&(t+=_n(r.lightSource)),t+=V(r),`${e}>${t}</feDiffuseLighting>`}function zs(r){let e=`<feSpecularLighting${N(r)}`;e+=s("surfaceScale",r.surfaceScale),e+=s("specularConstant",r.specularConstant),e+=s("specularExponent",r.specularExponent),e+=s("kernelUnitLength",r.kernelUnitLength),e+=s("lighting-color",r.lightingColor);let t="";return r.lightSource&&(t+=_n(r.lightSource)),t+=V(r),`${e}>${t}</feSpecularLighting>`}function Us(r){let e=`<feDisplacementMap${N(r)}`;e+=s("in2",r.in2),e+=s("scale",r.scale),e+=s("xChannelSelector",r.xChannelSelector),e+=s("yChannelSelector",r.yChannelSelector);let t=V(r);return t?`${e}>${t}</feDisplacementMap>`:`${e}/>`}function Ns(r){let e=`<feDropShadow${N(r)}`;e+=s("dx",r.dx),e+=s("dy",r.dy),e+=s("stdDeviation",r.stdDeviation),e+=s("flood-color",r.floodColor),e+=s("flood-opacity",r.floodOpacity);let t=V(r);return t?`${e}>${t}</feDropShadow>`:`${e}/>`}function Vs(r){let e=`<feFlood${N(r)}${s("flood-color",r.floodColor)}${s("flood-opacity",r.floodOpacity)}`,t=V(r);return t?`${e}>${t}</feFlood>`:`${e}/>`}function Hs(r){let e=`<feGaussianBlur${N(r)}${s("stdDeviation",r.stdDeviation)}${s("edgeMode",r.edgeMode)}`,t=V(r);return t?`${e}>${t}</feGaussianBlur>`:`${e}/>`}function Ws(r){let e=`<feImage${N(r)}`;r.href!==void 0?e+=s("href",r.href):r.xlinkHref!==void 0&&(e+=s("xlink:href",r.xlinkHref)),e+=s("preserveAspectRatio",r.preserveAspectRatio),e+=s("crossorigin",r.crossorigin);let t=V(r);return t?`${e}>${t}</feImage>`:`${e}/>`}function Xs(r){let e="";for(let t of r.nodes)e+=`<feMergeNode${s("in",t.in)}/>`;return e+=V(r),`<feMerge${N(r)}>${e}</feMerge>`}function js(r){let e=`<feMorphology${N(r)}${s("operator",r.operator)}${s("radius",r.radius)}`,t=V(r);return t?`${e}>${t}</feMorphology>`:`${e}/>`}function Ys(r){let e=`<feOffset${N(r)}${s("dx",r.dx)}${s("dy",r.dy)}`,t=V(r);return t?`${e}>${t}</feOffset>`:`${e}/>`}function qs(r){let e=`<feTile${N(r)}`,t=V(r);return t?`${e}>${t}</feTile>`:`${e}/>`}function Zs(r){let e=`<feTurbulence${N(r)}`;e+=s("baseFrequency",r.baseFrequency),e+=s("numOctaves",r.numOctaves),e+=s("seed",r.seed),e+=s("stitchTiles",r.stitchTiles),e+=s("type",r.turbulenceType);let t=V(r);return t?`${e}>${t}</feTurbulence>`:`${e}/>`}function Ar(r,e){let t=`<filter${s("id",r)}`;t+=s("x",e.x),t+=s("y",e.y),t+=s("width",e.width),t+=s("height",e.height),t+=s("filterUnits",e.filterUnits),t+=s("primitiveUnits",e.primitiveUnits),e.filterColorInterpolation&&e.filterColorInterpolation!=="auto"&&(t+=s("color-interpolation-filters",e.filterColorInterpolation)),t+=s("flood-color",e.floodColor),t+=s("flood-opacity",e.floodOpacity),t+=s("lighting-color",e.lightingColor),t+=">",e.filterTitle&&(t+=`<title>${O(e.filterTitle)}</title>`),e.filterDescription&&(t+=`<desc>${O(e.filterDescription)}</desc>`);for(let n of e.primitives)t+=yt(n);if(e.filterAnimations)for(let n of e.filterAnimations)t+=n;return t+="</filter>",t}function Fr(r,e,t,n){switch(r.type){case"drop-shadow":return Qi(r,e,t);case"inner-shadow":return Ji(r,e,t);case"gaussian-blur":return es(r,e,t);case"motion-blur":return ts(r,e,t);case"point-light":{let i=r;return Sn(n?{...i,x:i.x+n.x,y:i.y+n.y}:i,e,t)}case"spot-light":{let i=r;return kn(n?{...i,x:i.x+n.x,y:i.y+n.y,pointsAtX:i.pointsAtX+n.x,pointsAtY:i.pointsAtY+n.y}:i,e,t)}case"diffuse-lighting":return rs(r,e,t);case"specular-lighting":return ns(r,e,t);case"outline":return is(r,e,t);case"sharpen":return ss(r,e,t);case"pixelate":return as(r,e,t);case"warp":return os(r,e,t);case"morphology":return ls(r,e,t);case"contouring-discrete":return us(r,e,t);case"contouring-table":return cs(r,e,t);case"round-edges":return ds(r,e,t);case"grayscale":return fs(r,e,t);case"channel-painter":return hs(r,e,t);case"brightness":return ps(r,e,t);case"contrast":return ms(r,e,t);case"opacity":return gs(r,e,t);case"invert":return bs(r,e,t);case"hue-rotate":return ys(r,e,t);case"saturate":return $s(r,e,t);case"black-and-white":return xs(r,e,t);case"sepia":return Ss(r,e,t);case"duotone":return ks(r,e,t);case"xray":return vs(r,e,t);case"noise":return _s(r,e,t);case"emboss":return ws(r,e,t);case"film-grain":return Ps(r,e,t);case"watercolor":return Ts(r,e,t);case"gouache":return As(r,e,t);case"ink-blot":return Fs(r,e,t);case"crumpled-plastic":return Ms(r,e,t);case"riddled":return Rs(r,e,t);case"glow":return Cs(r,e,t);case"inner-glow":return Is(r,e,t);case"raw-svg":return r.svgContent;case"svg-primitive-chain":return r.primitives.map(yt).join("");default:return D(e,t)}}function Ks(r){return r.some(e=>e.type==="gaussian-blur"||e.type==="motion-blur"||e.type==="drop-shadow"||e.type==="inner-shadow"||e.type==="glow"||e.type==="inner-glow"||e.type==="outline"||e.type==="morphology"||e.type==="warp"||e.type==="svg-primitive-chain"&&e.primitives.some(t=>t.type==="feGaussianBlur"||t.type==="feDropShadow"||t.type==="feOffset"||t.type==="feMorphology"||t.type==="feDisplacementMap"||t.type==="feTurbulence"))}function Mr(r,e,t={}){let n=e.filter(k=>k.enabled);if(n.length===0)return"";let i=t.colorInterpolation&&t.colorInterpolation!=="auto"?s("color-interpolation-filters",t.colorInterpolation):"",a=n.find(k=>k.type==="raw-svg");if(a){let k=t.colorInterpolation&&t.colorInterpolation!=="auto"?t.colorInterpolation:a.colorInterpolationFilters,P=t.filterUnits??a.filterUnits,_=t.primitiveUnits??a.primitiveUnits,$=t.x??a.x,w=t.y??a.y,F=t.width??a.width,I=t.height??a.height;return`<filter${s("id",r)}${s("x",$)}${s("y",w)}${s("width",F)}${s("height",I)}${s("filterUnits",P)}${s("primitiveUnits",_)}${s("color-interpolation-filters",k)}${s("flood-color",a.floodColor)}${s("flood-opacity",a.floodOpacity)}${s("lighting-color",a.lightingColor)}>${a.svgContent}</filter>`}let o=n.find(k=>k.type==="svg-primitive-chain");if(o){let k={...o,x:t.x??o.x,y:t.y??o.y,width:t.width??o.width,height:t.height??o.height,filterUnits:t.filterUnits??o.filterUnits,primitiveUnits:t.primitiveUnits??o.primitiveUnits,filterColorInterpolation:t.colorInterpolation&&t.colorInterpolation!=="auto"?t.colorInterpolation:o.filterColorInterpolation};return Ar(r,k)}let l=n.some(k=>k.type==="gaussian-blur"&&k.quality==="high"||k.type==="motion-blur"&&k.quality==="high"),u=Ks(n),c=u?l?"-200%":"-100%":"-10%",f=u?l?"500%":"300%":"120%",d="",m="SourceGraphic",p=0;for(let k of n){let P=`result${p++}`;d+=Fr(k,m,P),m=P}let b=t.filterUnits??"objectBoundingBox",g=t.primitiveUnits??"userSpaceOnUse",y=t.x??c,S=t.y??c,v=t.width??f,x=t.height??f;return`<filter${s("id",r)}${s("x",y)}${s("y",S)}${s("width",v)}${s("height",x)}${s("filterUnits",b)}${s("primitiveUnits",g)}${i}>${d}</filter>`}function wn(r){let e="",t=new Set;for(let n of r){let i=n.state.filters;if(!i||i.length===0)continue;let a=i.filter(c=>c.enabled);if(a.length===0)continue;let o=n.state.filterLibraryIds,l=Array.isArray(o)&&o.length>0?o[0]:`filter-${n.id}`;if(t.has(l))continue;t.add(l);let u=n.state;e+=Mr(l,a,{colorInterpolation:u.filterColorInterpolation,filterUnits:u.filterUnits,primitiveUnits:u.primitiveUnits,x:u.filterX,y:u.filterY,width:u.filterWidth,height:u.filterHeight})}return e}function $t(r,e,t){return!e||e.length===0||e.filter(i=>i.enabled).length===0?"":Array.isArray(t)&&t.length>0?` filter="${t.map(a=>`url(#${O(a)})`).join(" ")}"`:` filter="url(#filter-${O(r)})"`}function Le(r,e,t,n){let i=n?.strokeWidth!=null?Math.max(.5,e*n.strokeWidth):Math.max(1,e/10);switch(r){case"stripes":return[{tag:"rect",attrs:{width:n?.strokeWidth!=null?Math.max(.01,Math.min(1,n.strokeWidth))*e:e/2,height:e,fill:t}}];case"dots":{let a=n?.dotRadius!=null?Math.max(.05,Math.min(.45,n.dotRadius)):.25;return[{tag:"circle",attrs:{cx:e/2,cy:e/2,r:e*a,fill:t}}]}case"grid":return[{tag:"path",attrs:{d:`M ${e} 0 L 0 0 0 ${e}`,fill:"none",stroke:t,"stroke-width":i}}];case"checkerboard":return[{tag:"rect",attrs:{width:e/2,height:e/2,fill:t}},{tag:"rect",attrs:{x:e/2,y:e/2,width:e/2,height:e/2,fill:t}}];case"diagonal":{let a=n?.strokeWidth!=null?Math.max(.5,e*n.strokeWidth):Math.max(1,e/5);return[{tag:"path",attrs:{d:`M 0 ${e} L ${e} 0`,stroke:t,"stroke-width":a}}]}case"crosshatch":return[{tag:"path",attrs:{d:`M 0 ${e} L ${e} 0 M 0 0 L ${e} ${e}`,stroke:t,"stroke-width":i}}];case"zigzag":{let a=n?.amplitude!=null?Math.max(.05,Math.min(.5,n.amplitude)):.25,o=e*a;return[{tag:"path",attrs:{d:`M 0 ${o} L ${e/4} 0 L ${e/2} ${o} L ${e*3/4} 0 L ${e} ${o}`,fill:"none",stroke:t,"stroke-width":i}}]}case"waves":{let a=n?.amplitude!=null?Math.max(.05,Math.min(.5,n.amplitude)):.25,o=e*a,l=e/2;return[{tag:"path",attrs:{d:`M 0 ${l} Q ${e/4} ${l-o} ${e/2} ${l} T ${e} ${l}`,fill:"none",stroke:t,"stroke-width":i}}]}case"triangles":{let a=e*.866;return[{tag:"path",attrs:{d:`M ${e/2} 0 L ${e} ${a} L 0 ${a} Z`,fill:"none",stroke:t,"stroke-width":i}}]}case"hexagons":{let a=e*.866;return[{tag:"path",attrs:{d:`M ${e*.25} 0 L ${e*.75} 0 L ${e} ${a*.5} L ${e*.75} ${a} L ${e*.25} ${a} L 0 ${a*.5} Z`,fill:"none",stroke:t,"stroke-width":i}}]}case"diamonds":return[{tag:"path",attrs:{d:`M ${e/2} 0 L ${e} ${e/2} L ${e/2} ${e} L 0 ${e/2} Z`,fill:"none",stroke:t,"stroke-width":i}}];case"circles":return[{tag:"circle",attrs:{cx:e/2,cy:e/2,r:e/3,fill:"none",stroke:t,"stroke-width":i}}];case"bricks":{let a=n?.strokeWidth!=null?Math.max(.5,e*n.strokeWidth):Math.max(1,e/15);return[{tag:"rect",attrs:{x:0,y:0,width:e,height:e/2,fill:"none",stroke:t,"stroke-width":a}},{tag:"rect",attrs:{x:-e/2,y:e/2,width:e,height:e/2,fill:"none",stroke:t,"stroke-width":a}},{tag:"rect",attrs:{x:e/2,y:e/2,width:e,height:e/2,fill:"none",stroke:t,"stroke-width":a}}]}case"herringbone":return[{tag:"path",attrs:{d:`M 0 0 L ${e/2} ${e/2} L 0 ${e} M ${e/2} ${e/2} L ${e} 0 M ${e/2} ${e/2} L ${e} ${e}`,fill:"none",stroke:t,"stroke-width":i}}];default:return[]}}function Qs(r){let e=Object.entries(r.attrs).map(([t,n])=>` ${t}="${n}"`).join("");return`<${r.tag}${e}/>`}function xt(r,e,t,n,i){let a=10*e,o="";o+=`<rect width="${a}" height="${a}" fill="${n}"/>`;let l=Le(r,a,t,i);for(let u of l)o+=Qs(u);return{svgContent:o,width:a,height:a}}var Ee="0 0 10 10",St=6,kt=6;function he(){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"}}}]}var Rr={"line-marker-arrow":"mkr-builtin-arrow","line-marker-open-arrow":"mkr-builtin-open-arrow","line-marker-circle":"mkr-builtin-circle","line-marker-diamond":"mkr-builtin-diamond","line-marker-square":"mkr-builtin-square"},Js={"mkr-builtin-arrow":"Arrow","mkr-builtin-open-arrow":"Open Arrow","mkr-builtin-circle":"Circle","mkr-builtin-diamond":"Diamond","mkr-builtin-square":"Square"};function Pn(){return he().map(r=>{let e=Rr[r.id]??r.id;return{kind:"marker",id:e,name:Js[e]??e,viewBox:Ee,refX:r.refX,refY:r.refY,markerWidth:6,markerHeight:6,markerUnits:"strokeWidth",orient:"auto-start-reverse",shapes:[],builtIn:!0}})}function h(r,e){return e==null||e===""?"":` ${r}="${O(String(e))}"`}var ea=[["fontVariant","font-variant"],["fontVariantLigatures","font-variant-ligatures"],["fontVariantPosition","font-variant-position"],["fontVariantCaps","font-variant-caps"],["fontVariantNumeric","font-variant-numeric"],["fontVariantEastAsian","font-variant-east-asian"]];function Cr(r){return ea.map(([e,t])=>{let n=typeof r[e]=="string"?String(r[e]).trim():"";return n?`${t}: ${n}`:""}).filter(Boolean).join("; ")}function Fn(r){let e=r.map(t=>(t??"").trim().replace(/;$/,"")).filter(Boolean).join("; ");return e?h("style",e):""}function ta(r){if(r&&typeof r=="object"){let e=r;return"dx"in e?{x:typeof e.x=="number"?e.x:null,y:typeof e.y=="number"?e.y:null,dx:typeof e.dx=="number"?e.dx:0,dy:typeof e.dy=="number"?e.dy:0,rotate:typeof e.rotate=="number"?e.rotate:0}:{x:null,y:null,dx:typeof e.x=="number"?e.x:0,dy:typeof e.y=="number"?e.y:0,rotate:typeof e.rotate=="number"?e.rotate:0}}return{x:null,y:null,dx:0,dy:0,rotate:0}}function Tn(r,e){let t=-1;for(let i=r.length-1;i>=0;i--)if(r[i][e]!==null){t=i;break}if(t<0)return[];let n=new Array(t+1);for(let i=0;i<=t;i++)n[i]=r[i][e]??0;return n}function An(r,e){let t=-1;for(let i=r.length-1;i>=0;i--)if(r[i][e]!==0){t=i;break}if(t<0)return[];let n=new Array(t+1);for(let i=0;i<=t;i++)n[i]=r[i][e];return n}function ra(r){if(r.length===0)return[];let e=r.length-1,t=r[e].rotate;for(;e>0&&r[e-1].rotate===t;)e--;if(e===0&&t===0)return[];let n=new Array(e+1);for(let i=0;i<=e;i++)n[i]=r[i].rotate;return n}function ae(r,e){return ge(r,e)}function na(r,e,t){return xr(r,e,t)}function ia(r){if(typeof r=="string"){let n=r.trim();return n.length>0?n:void 0}if(!r||typeof r!="object")return;let e=r,t=[];return e.underline&&t.push("underline"),e.strikethrough&&t.push("line-through"),e.overline&&t.push("overline"),t.length>0?t.join(" "):void 0}function sa(r){if(typeof r.strokeDasharray=="string")return r.strokeDasharray;let e=r.lineStyle??"solid",t=r.dashLength??8,n=r.gapLength??4;return $e(e,t,n)}function aa(r){let e=r.fillType;return e||(r.fillGradient?r.fillGradient.r!==void 0?"radial-gradient":"linear-gradient":r.linearGradient?"linear-gradient":r.radialGradient?"radial-gradient":"solid")}function oa(r){return r.fillGradient??r.linearGradient??r.radialGradient??void 0}function ne(r,e){let t=h("data-shape-id",e),n=aa(r),i=oa(r);if(n==="none")t+=h("fill","none");else if(n==="linear-gradient"||n==="radial-gradient"){let w=r.fillLibraryId??i?.id;t+=h("fill",`url(#${w??`gradient-fill-${e}`})`)}else if(n==="pattern"){let w=r.fillLibraryId??i?.id;t+=h("fill",`url(#${w??`pattern-fill-${e}`})`)}else t+=h("fill",r.fillColor??"#000000");let a=r.opacity;a!==void 0&&a<1&&(t+=h("opacity",a));let o=r.fillOpacity;o!==void 0&&o<1&&(t+=h("fill-opacity",o));let l=r.fillRule;l&&l!=="nonzero"&&(t+=h("fill-rule",l));let u=r.strokeType??"solid",c=r.strokeGradient;if(u==="none")t+=h("stroke","none");else if(u==="linear-gradient"||u==="radial-gradient"){let w=r.strokeLibraryId??c?.id;t+=h("stroke",`url(#${w??`gradient-stroke-${e}`})`)}else if(u==="pattern"){let w=r.strokeLibraryId??c?.id;t+=h("stroke",`url(#${w??`pattern-stroke-${e}`})`)}else t+=h("stroke",r.borderColor??"none");let f=r.borderWidth;f!=null&&(t+=h("stroke-width",f));let d=r.strokeOpacity;d!==void 0&&d<1&&(t+=h("stroke-opacity",d));let m=r.paintOrder;m&&m!=="normal"&&(t+=h("paint-order",m));let p=r.markerStart,b=r.markerMid,g=r.markerEnd;p&&(t+=h("marker-start",`url(#${p})`)),b&&(t+=h("marker-mid",`url(#${b})`)),g&&(t+=h("marker-end",`url(#${g})`));let y=sa(r);y&&(t+=h("stroke-dasharray",y),!r.strokeDasharray&&r.lineStyle==="dotted"&&(t+=h("stroke-linecap","round")));let S=r.dashOffset;S!==void 0&&S!==0&&(t+=h("stroke-dashoffset",S));let v=r.shapeRendering;v&&v!=="auto"&&(t+=h("shape-rendering",v)),t+=$t(e,r.filters,r.filterLibraryIds);let x=r.systemLanguage;x&&(t+=h("systemLanguage",x));let k=r.requiredExtensions;k&&(t+=h("requiredExtensions",k));let P=r.vectorEffect;P&&P!=="none"&&(t+=h("vector-effect",P));let _=r.visibility;_&&_!=="visible"&&(t+=h("visibility",_));let $=r.metadata;return $&&($.role&&(t+=h("role",$.role)),$.ariaLabel&&(t+=h("aria-label",$.ariaLabel))),t}function la(r){let e=r.metadata;if(!e)return"";let t="";return e.title&&(t+=`<title>${O(e.title)}</title>`),e.description&&(t+=`<desc>${O(e.description)}</desc>`),t}function ua(r,e){let t=la(e);if(!t)return r;let n=r.lastIndexOf("/>");if(n===-1){let o=r.indexOf(">");return o===-1?r:r.slice(0,o+1)+t+r.slice(o+1)}let i=r.match(/^<(\w+)/),a=i?i[1]:"g";return r.slice(0,n)+">"+t+`</${a}>`}function Ir(r){let e="",t=r.startEndpoint,n=r.endEndpoint;return t&&t!=="none"&&(e+=h("marker-start",`url(#line-marker-${t})`)),n&&n!=="none"&&(e+=h("marker-end",`url(#line-marker-${n})`)),e}function Lr(r){let e=r.state,t=e.x??0,n=e.y??0,i=e.radius??50,a=ae(e,{x:t,y:n});return`<circle${h("cx",t)}${h("cy",n)}${h("r",i)}${ne(e,r.id)}${a?h("transform",a):""}/>`}function Er(r){let e=r.state,t=e.cx??0,n=e.cy??0,i=e.rx??50,a=e.ry??30,o=e.pathLength,l=ae(e,{x:t,y:n});return`<ellipse${h("cx",t)}${h("cy",n)}${h("rx",i)}${h("ry",a)}${o!==void 0?h("pathLength",o):""}${ne(e,r.id)}${l?h("transform",l):""}/>`}function Dr(r){let e=r.state,t=e,n=e.x??0,i=e.y??0,a=e.width??100,o=e.height??100,l=e.cornerRadius??0,u=e.rx??l,c=e.ry??l,f=t.cornerShape??"round",d=t.cornerMode??"uniform",m={x:n+a/2,y:i+o/2},p=ae(e,m);if(f!=="round"||d==="non-uniform"){let b=pt(n,i,a,o,l,f,d,d==="non-uniform"?{radiusTL:t.cornerRadiusTL,radiusTR:t.cornerRadiusTR,radiusBR:t.cornerRadiusBR,radiusBL:t.cornerRadiusBL,shapeTL:t.cornerShapeTL,shapeTR:t.cornerShapeTR,shapeBR:t.cornerShapeBR,shapeBL:t.cornerShapeBL}:void 0);if(b)return`<path${h("d",b)}${ne(e,r.id)}${p?h("transform",p):""}/>`}return`<rect${h("x",n)}${h("y",i)}${h("width",a)}${h("height",o)}${u>0||c>0?`${h("rx",u)}${h("ry",c)}`:""}${ne(e,r.id)}${p?h("transform",p):""}/>`}function Br(r){let e=r.state,t=e.x1??0,n=e.y1??0,i=e.x2??0,a=e.y2??0,o={x:(t+i)/2,y:(n+a)/2},l=ae(e,o),u={...e,fillType:"none"};return`<line${h("x1",t)}${h("y1",n)}${h("x2",i)}${h("y2",a)}${ne(u,r.id)}${Ir(e)}${l?h("transform",l):""}/>`}function Or(r){let e=r.state,t=e.x??0,n=e.y??0,i=e.text??"",a=e.fontSize??16,o=e.fontFamily??"sans-serif",l=e.fontWeight??"normal",u=e.fontStyle??"normal",c=e.textAnchor??"start",f=ia(e.textDecoration),d=e.letterSpacing,p=ae(e,{x:t,y:n}),b=h("x",t)+h("y",n);b+=h("font-size",a),b+=h("font-family",o),l!=="normal"&&(b+=h("font-weight",l)),u!=="normal"&&(b+=h("font-style",u)),c!=="start"&&(b+=h("text-anchor",c)),f&&(b+=h("text-decoration",f)),d&&(b+=h("letter-spacing",d));let g=e.textLength;g!==void 0&&g>0&&(b+=h("textLength",g),e.lengthAdjust==="spacingAndGlyphs"&&(b+=h("lengthAdjust","spacingAndGlyphs")));let y=e.textDirection;y&&y!=="ltr"&&(b+=h("direction",y));let S=e.unicodeBidi;S&&S!=="normal"&&(b+=h("unicode-bidi",S));let v=Cr(e),x=e.fontVariationSettings,k="";if(x&&Object.keys(x).length>0&&(k=`font-variation-settings: ${Object.entries(x).map(([$,w])=>`'${$}' ${w}`).join(", ")}`),b+=Fn([v,k]),b+=ne(e,r.id),p&&(b+=h("transform",p)),e.isTextPath&&e.textPathPoints){let _=e.textPathPoints,$=e.textPathStartOffset??0,w=e.textPathSide,F=`text-path-${r.id}`,I="";if(_.length>=2)if(w==="right"){let R=_[_.length-1];I=`M ${R.x} ${R.y}`;for(let C=_.length-1;C>0;C--){let L=_[C],E=_[C-1],B=L.handleIn??L,A=E.handleOut??E;I+=` C ${B.x} ${B.y}, ${A.x} ${A.y}, ${E.x} ${E.y}`}}else{I=`M ${_[0].x} ${_[0].y}`;for(let R=0;R<_.length-1;R++){let C=_[R],L=_[R+1],E=C.handleOut??C,B=L.handleIn??L;I+=` C ${E.x} ${E.y}, ${B.x} ${B.y}, ${L.x} ${L.y}`}}return`<defs><path id="${O(F)}"${h("d",I)} fill="none"/></defs><text${b}><textPath href="#${O(F)}"${h("startOffset",`${$}%`)}>${O(i)}</textPath></text>`}if(e.charOffsets&&Array.isArray(e.charOffsets)&&e.charOffsets.length>0){let _=e.charOffsets.map(ta),$=i.split(`
7
- `),w=e.linePositions??[],F=a*1.25,I="",R=0;return $.forEach((C,L)=>{let E=Array.from(C).length,B=_.slice(R,R+E),A=w[L],G=A?t+A.x:L>0?t:NaN,q=A?A.dy:L>0?F:NaN,W="",de=Tn(B,"x");if(Number.isFinite(G)||de.length>0){let fr=de.length>0?de.slice():[];Number.isFinite(G)&&(fr[0]=fr[0]??G),W+=h("x",fr.join(" "))}let ee=Tn(B,"y");ee.length>0&&(W+=h("y",ee.join(" ")));let Y=An(B,"dx");Y.length>0&&(W+=h("dx",Y.join(" ")));let Ue=An(B,"dy"),Z=Ue.length>0||Number.isFinite(q)?Ue.slice():[];for(Number.isFinite(q)&&(Z[0]=(Z[0]??0)+q);Z.length>0&&Z[Z.length-1]===0;)Z.pop();Z.length>0&&(W+=h("dy",Z.join(" ")));let on=ra(B);on.length>0&&(W+=h("rotate",on.join(" "))),I+=`<tspan${W}>${O(C)}</tspan>`,R+=E+1}),`<text${b}>${I}</text>`}if(e.richTextData&&typeof e.richTextData=="object"){let _=e.richTextData;if(Array.isArray(_.lines)&&_.lines.length>0){let $=e.linePositions,w=typeof _.lineHeight=="number"?_.lineHeight:1.2,F=a*w,I=_.baseStyle??{},R="";return _.lines.forEach((C,L)=>{C.segments.forEach((E,B)=>{let A="";if(B===0){let G=$?.[L];G?((Math.abs(G.x)>.001||L>0)&&(A+=h("x",t+G.x)),(Math.abs(G.dy)>.001||L>0)&&(A+=h("dy",G.dy))):L>0&&(A+=h("x",t),A+=h("dy",`${F}px`))}A+=ca(E.style??{},I),A+=' xml:space="preserve"',R+=`<tspan${A}>${O(E.text)}</tspan>`})}),`<text${b}>${R}</text>`}}return`<text${b}>${O(i)}</text>`}function ca(r,e){let t="";r.fontFamily!==void 0&&r.fontFamily!==e.fontFamily&&(t+=h("font-family",String(r.fontFamily))),r.fontSize!==void 0&&r.fontSize!==e.fontSize&&(t+=h("font-size",String(r.fontSize))),r.fontWeight!==void 0&&r.fontWeight!==e.fontWeight&&(t+=h("font-weight",String(r.fontWeight))),r.fontStyle!==void 0&&r.fontStyle!==e.fontStyle&&(t+=h("font-style",String(r.fontStyle)));let n=Cr(r);n&&n!==Cr(e)&&(t+=Fn([n]));let i=r.textDecoration,a=e.textDecoration;if(i&&(!a||i.underline!==a.underline||i.strikethrough!==a.strikethrough||i.overline!==a.overline)){let l=[];i.underline&&l.push("underline"),i.strikethrough&&l.push("line-through"),i.overline&&l.push("overline"),l.length>0&&(t+=h("text-decoration",l.join(" ")))}if(r.baselineShift!==void 0&&r.baselineShift!==e.baselineShift){let o=r.baselineShift;o==="super"||o==="sub"?t+=h("baseline-shift",o):typeof o=="number"&&(t+=h("baseline-shift",`${o}px`))}return r.letterSpacing!==void 0&&r.letterSpacing!==e.letterSpacing&&(t+=h("letter-spacing",String(r.letterSpacing))),r.fill!==void 0&&r.fill!==e.fill&&(t+=h("fill",String(r.fill))),r.fillOpacity!==void 0&&r.fillOpacity!==e.fillOpacity&&(t+=h("fill-opacity",String(r.fillOpacity))),r.direction!==void 0&&r.direction!==e.direction&&(t+=h("direction",String(r.direction))),r.unicodeBidi!==void 0&&r.unicodeBidi!==e.unicodeBidi&&(t+=h("unicode-bidi",String(r.unicodeBidi))),t}function Gr(r){let e=r.state,t=e.pathPoints??[],n=e.pathCurveType??"CUBIC",i=e.pathClosed??!1,a=e.pathTension??.5,o=e.pathArcParams,l=ye(t,n,i,a,o),u=t.length>0?e.customPivot??{x:t[0].x,y:t[0].y}:void 0,c=u?ae(e,u):null;return`<path${h("d",l)}${ne(e,r.id)}${Ir(e)}${c?h("transform",c):""}/>`}function zr(r){let e=r.state,t=e.polylinePoints??[],n=e.polylineClosed??!1,i=t.map(u=>`${u.x},${u.y}`).join(" "),a=t.length>0?e.customPivot??{x:t[0].x,y:t[0].y}:void 0,o=a?ae(e,a):null;return`<${n?"polygon":"polyline"}${h("points",i)}${ne(e,r.id)}${Ir(e)}${o?h("transform",o):""}/>`}function Ur(r){let e=r.state,t=e.x??0,n=e.y??0,i=e.width??100,a=e.height??100,o=e.href??"",l=e.imageOpacity,u=e.preserveAspectRatio?"xMidYMid meet":"none",c={x:t+i/2,y:n+a/2},f=ae(e,c);return`<image${h("x",t)}${h("y",n)}${h("width",i)}${h("height",a)}${h("href",o)}${h("preserveAspectRatio",u)}${l!==void 0&&l<1?h("opacity",l):""}${ne(e,r.id)}${f?h("transform",f):""}/>`}function vt(r){return!r||r.length===0?"":r.map(e=>H(e)).join("")}function da(r){let e=r.state,t=e.href,n=e.hrefXlink,i="<a";return t!==void 0&&(i+=h("href",t)),n!==void 0&&(i+=h("xlink:href",n)),i+=h("target",e.linkTarget),i+=h("rel",e.linkRel),i+=h("download",e.linkDownload),i+=h("ping",e.linkPing),i+=h("hreflang",e.linkHreflang),i+=h("type",e.linkType),i+=h("referrerpolicy",e.linkReferrerPolicy),i+=h("data-shape-id",r.id),i+=">",i+=vt(e.children),i+="</a>",i}function fa(r){let e=r.state,t="<switch";return t+=h("data-shape-id",r.id),t+=">",t+=vt(e.children),t+="</switch>",t}function ha(r){let e=r.state,t=ae(e),n="<g";return n+=h("data-shape-id",r.id),t&&(n+=h("transform",t)),e.opacity!==void 0&&e.opacity<1&&(n+=h("opacity",e.opacity)),e.visibility&&(n+=h("visibility",e.visibility)),e.blendMode&&(n+=h("style",`mix-blend-mode:${e.blendMode}`)),n+=">",n+=vt(e.children),n+="</g>",n}function pa(r){let e=r.state,t=e.viewBoxX,n=e.viewBoxY,i=e.viewBoxWidth,a=e.viewBoxHeight,o=t!==void 0&&n!==void 0&&i!==void 0&&a!==void 0?`${t} ${n} ${i} ${a}`:void 0,l="<view";return l+=h("id",r.id),l+=h("viewBox",o),l+=h("preserveAspectRatio",e.viewPreserveAspectRatio),l+=h("zoomAndPan",e.viewZoomAndPan),l+=h("viewTarget",e.viewTarget),e.viewName&&(l+=h("data-view-name",e.viewName)),l+="/>",l}function ma(r){let e=r.state,t=e.svgX,n=e.svgY,i=e.svgWidth,a=e.svgHeight,o=e.svgViewBoxX,l=e.svgViewBoxY,u=e.svgViewBoxWidth,c=e.svgViewBoxHeight,f=o!==void 0&&l!==void 0&&u!==void 0&&c!==void 0?`${o} ${l} ${u} ${c}`:void 0,d="<svg";return d+=h("xmlns","http://www.w3.org/2000/svg"),d+=h("x",t),d+=h("y",n),d+=h("width",i),d+=h("height",a),d+=h("viewBox",f),d+=h("preserveAspectRatio",e.svgPreserveAspectRatio),d+=h("data-shape-id",r.id),d+=">",d+=vt(e.children),d+="</svg>",d}function ga(r){let e=r.state,t=e.targetShapeId;if(!t)return`<!-- shape-reference ${O(r.id)} has no targetShapeId -->`;let n=e.offsetX??0,i=e.offsetY??0,a="<use";return a+=h("href",`#${t}`),a+=h("x",n),a+=h("y",i),e.width!==void 0&&(a+=h("width",e.width)),e.height!==void 0&&(a+=h("height",e.height)),a+=h("data-shape-id",r.id),e.opacity!==void 0&&e.opacity<1&&(a+=h("opacity",e.opacity)),a+="/>",a}function ba(r){let e=r.state,t=e.mediaKind??r.type,n=e.x??0,i=e.y??0,a=e.width??320,o=e.height??180,l=e.href??"",u=e.mediaMimeType,c=e.posterHref,f=e.mediaOpacity,d=`<${t} xmlns="http://www.w3.org/1999/xhtml"`;d+=h("src",l),u&&(d+=h("type",u)),c&&t==="video"&&(d+=h("poster",c)),e.muted&&(d+=' muted=""'),e.loop&&(d+=' loop=""'),e.playbackRate!==void 0&&(d+=h("data-playback-rate",e.playbackRate)),e.volume!==void 0&&(d+=h("data-volume",e.volume)),d+=' preload="auto" playsinline=""',d+=t==="video"?' style="width:100%;height:100%;display:block;"></video>':"></audio>";let m="<foreignObject";return m+=h("x",n),m+=h("y",i),m+=h("width",a),m+=h("height",o),m+=h("data-shape-id",r.id),m+=h("data-media-kind",t),e.naturalDuration!==void 0&&(m+=h("data-natural-duration",e.naturalDuration)),e.begin!==void 0&&(m+=h("data-begin",e.begin)),e.trimStart!==void 0&&(m+=h("data-trim-start",e.trimStart)),e.trimEnd!==void 0&&(m+=h("data-trim-end",e.trimEnd)),e.fadeInDuration!==void 0&&(m+=h("data-fade-in",e.fadeInDuration)),e.fadeOutDuration!==void 0&&(m+=h("data-fade-out",e.fadeOutDuration)),e.systemLanguage&&(m+=h("systemLanguage",e.systemLanguage)),e.requiredExtensions&&(m+=h("requiredExtensions",e.requiredExtensions)),f!==void 0&&f<1&&(m+=h("opacity",f)),m+=">",m+=d,m+="</foreignObject>",m}function Nr(r){let e=r.state,t=e.cx??0,n=e.cy??0,i=e.radius??50,a=e.cornerRadius??0,o=e.shiftAngle??-90,l=e.fillRule??"nonzero",u=na(e,t,n),c="";switch(r.type){case"triangle":c=J(Ie(3,i,o),a,i);break;case"ngon":{let d=e.sides??6;c=J(Ie(d,i,o),a,i);break}case"star":{let d=e.arms??5,m=e.innerRadiusPercent??50;c=J(it(d,i,m,o),a,i);break}case"cross":{let d=e.armWidthPercent??40;c=J(st(i,d,o),a,i);break}case"ring":{let d=e.innerRadiusPercent??50;c=dt(i,d,l);break}case"spiral":{let d=e.turns??3,m=e.thicknessPercent??20,p=e.spiralDirection??1;c=ft(i,d,m,p,o);break}case"gear":{let d=e.teeth??8,m=e.toothDepthPercent??30,p=e.holeRadiusPercent??0;c=ht(d,i,m,a,p,l,o);break}case"arrow":{let d=e.headWidthPercent??100,m=e.headLengthPercent??30,p=e.shaftWidthPercent??40;c=J(at(i,d,m,p,o),a,i);break}case"speechBubble":{let d=e.tailAngleDeg??45,m=e.tailLengthPercent??40,p=e.tailWidthPercent??25;c=J(ot(i,d,m,p,o),a,i);break}case"lightning":{let d=e.boltSegments??3,m=e.boltJaggednessPercent??40,p=e.boltWidthPercent??30;c=J(lt(i,d,m,p,o),a,i);break}case"heart":{let d=e.lobeRadiusPercent??50,m=e.cleftDepthPercent??25;c=ut(i,d,m,o);break}case"cloud":{let d=e.cloudBumps??5,m=e.cloudPuffinessPercent??60;c=ct(i,d,m,o);break}default:return`<!-- unsupported polygon shape: ${O(r.type)} -->`}let f="";return(r.type==="ring"||r.type==="gear")&&(f=h("fill-rule",l)),`<path${h("d",c)}${f}${ne(e,r.id)}${h("transform",u)}/>`}function H(r){let e;switch(r.type){case"circle":e=Lr(r);break;case"ellipse":e=Er(r);break;case"rectangle":case"square":e=Dr(r);break;case"line":e=Br(r);break;case"text":e=Or(r);break;case"path":e=Gr(r);break;case"polyline":e=zr(r);break;case"image":e=Ur(r);break;case"triangle":case"ngon":case"star":case"cross":case"ring":case"spiral":case"gear":case"arrow":case"speechBubble":case"lightning":case"heart":case"cloud":e=Nr(r);break;case"hyperlink":e=da(r);break;case"switch":e=fa(r);break;case"container":case"group":e=ha(r);break;case"view":e=pa(r);break;case"svg":e=ma(r);break;case"shape-reference":e=ga(r);break;case"audio":case"video":e=ba(r);break;default:return`<!-- unsupported shape type: ${O(r.type)} -->`}return ua(e,r.state)}function Mn(r,e){let t=(e.stops??[]).map(o=>{let l=`<stop${h("offset",`${o.offset*100}%`)}${h("stop-color",o.color)}`;return o.opacity!==void 0&&o.opacity<1&&(l+=h("stop-opacity",o.opacity)),l+="/>",l}).join(""),n=e.gradientUnits==="userSpaceOnUse",i=o=>n?String(o):`${o*100}%`,a=n?h("gradientUnits","userSpaceOnUse"):"";return`<linearGradient${h("id",r)}${a}${h("x1",i(e.x1))}${h("y1",i(e.y1))}${h("x2",i(e.x2))}${h("y2",i(e.y2))}${e.spreadMethod?h("spreadMethod",e.spreadMethod):""}>${t}</linearGradient>`}function Rn(r,e){let t=(e.stops??[]).map(f=>{let d=`<stop${h("offset",`${f.offset*100}%`)}${h("stop-color",f.color)}`;return f.opacity!==void 0&&f.opacity<1&&(d+=h("stop-opacity",f.opacity)),d+="/>",d}).join(""),n=e.gradientUnits==="userSpaceOnUse",i=f=>n?String(f):`${f*100}%`,a=n?h("gradientUnits","userSpaceOnUse"):"",o="",l=e.ry!==void 0&&e.ry!==e.r,u=!!e.rotation;if(l||u){let f=e.cx??(n?0:.5),d=e.cy??(n?0:.5),m=[];m.push(`translate(${f}, ${d})`),u&&m.push(`rotate(${e.rotation})`),l&&e.ry!==0&&m.push(`scale(1, ${e.ry/e.r})`),m.push(`translate(-${f}, -${d})`),o=h("gradientTransform",m.join(" "))}let c=e.fr!==void 0&&e.fr>0?h("fr",i(e.fr)):"";return`<radialGradient${h("id",r)}${a}${h("cx",i(e.cx))}${h("cy",i(e.cy))}${h("fx",i(e.fx))}${h("fy",i(e.fy))}${h("r",i(e.r))}${c}${e.spreadMethod?h("spreadMethod",e.spreadMethod):""}${o}>${t}</radialGradient>`}function Cn(r,e){if(e.svgContent!=null){let l=e.width??10,u=e.height??10,c=e.patternUnits??"userSpaceOnUse",f=e.patternContentUnits,d=e.patternTransform,m=e.viewBox,p=e.preserveAspectRatio,b=e.x??0,g=e.y??0,y=`<pattern${h("id",r)}`;return y+=h("patternUnits",c),f&&(y+=h("patternContentUnits",f)),b&&(y+=h("x",b)),g&&(y+=h("y",g)),y+=h("width",l),y+=h("height",u),m&&(y+=h("viewBox",m)),p&&(y+=h("preserveAspectRatio",p)),d&&(y+=h("patternTransform",d)),y+=`>${e.svgContent}</pattern>`,y}let t=10*(e.scale??1),n=e.rotation??0,i=e.color||"#000000",a=e.backgroundColor||"#ffffff",o="";return o+=`<rect${h("width",t)}${h("height",t)}${h("fill",a)}/>`,o+=ya(e.patternType,t,i),`<pattern${h("id",r)}${h("patternUnits","userSpaceOnUse")}${h("width",t)}${h("height",t)}${n?h("patternTransform",`rotate(${n})`):""}>${o}</pattern>`}function ya(r,e,t){return Le(r,e,t).map(i=>{let a=Object.entries(i.attrs).map(([o,l])=>h(o,l)).join("");return`<${i.tag}${a}/>`}).join("")}function $a(r){let e=new Set,t=new Set;for(let n of r){let i=n.state;i.markerStart&&e.add(i.markerStart),i.markerMid&&e.add(i.markerMid),i.markerEnd&&e.add(i.markerEnd);let a=i.startEndpoint,o=i.endEndpoint;a&&a!=="none"&&t.add(a),o&&o!=="none"&&t.add(o)}return{ids:e,legacyEndpoints:t}}function ie(r){let e=Array.isArray(r)?$a(r):r;if(e.ids.size===0&&e.legacyEndpoints.size===0)return"";let t="",n=he();for(let i of n){let a=i.id,o=a.replace("line-marker-",""),l=`mkr-builtin-${o}`,u=e.legacyEndpoints.has(o)||e.ids.has(a),c=e.ids.has(l);if(!u&&!c)continue;let f=i.element,d=Object.entries(f.attrs).map(([b,g])=>h(b,g)).join(""),m=`<${f.tag}${d}/>`,p=b=>{t+=`<marker${h("id",b)}${h("viewBox",Ee)}${h("refX",i.refX)}${h("refY",i.refY)}${h("markerWidth",6)}${h("markerHeight",6)}${h("orient","auto-start-reverse")}>${m}</marker>`};u&&p(a),c&&p(l)}return t}var oe=r=>r.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;"),Vr=["linear-gradient","radial-gradient","pattern","filter","marker","symbol"];function Hr(r){switch(r.kind){case"symbol":return Wr(r);case"marker":return Xr(r);case"linear-gradient":return jr(r);case"radial-gradient":return Yr(r);case"pattern":return qr(r);case"filter":return Zr(r)}}function Wr(r){let e=r.shapes.map(i=>H(i)).join(""),t=r.viewBox?` viewBox="${oe(r.viewBox)}"`:"",n=r.overflow?` overflow="${oe(r.overflow)}"`:"";return`<symbol id="${oe(r.id)}"${t}${n}>${e}</symbol>`}function Xr(r){let e;if(r.builtIn){let a=he().find(o=>r.id.includes(o.id)||r.id===o.id);if(a){let o=Object.entries(a.element.attrs).map(([l,u])=>` ${l}="${oe(String(u))}"`).join("");e=`<${a.element.tag}${o}/>`}else e=""}else e=r.shapes.map(a=>H(a)).join("");let t=typeof r.orient=="number"?String(r.orient):r.orient,n=r.viewBox?` viewBox="${oe(r.viewBox)}"`:"",i=r.overflow?` overflow="${oe(r.overflow)}"`:"";return`<marker id="${oe(r.id)}"${n} refX="${r.refX}" refY="${r.refY}" markerWidth="${r.markerWidth}" markerHeight="${r.markerHeight}" markerUnits="${oe(r.markerUnits)}" orient="${oe(t)}"${i}>${e}</marker>`}function jr(r){let e={...r.gradient,type:"linear-gradient",id:r.id};return Mn(r.id,e)}function Yr(r){let e={...r.gradient,type:"radial-gradient",id:r.id};return Rn(r.id,e)}function qr(r){let e={...r.pattern,type:"pattern",id:r.id};return Cn(r.id,e)}function Zr(r){return Mr(r.id,r.filters,{colorInterpolation:r.colorInterpolation,filterUnits:r.filterUnits,primitiveUnits:r.primitiveUnits,x:r.x,y:r.y,width:r.width,height:r.height})}function Kr(r){let e=new Map;for(let n of r){let i=e.get(n.kind);i?i.push(n):e.set(n.kind,[n])}let t="";for(let n of Vr){let i=e.get(n);if(i)for(let a of i)t+=Hr(a)}return t}function In(r){let e=new Set,t=n=>{typeof n=="string"&&n&&e.add(n)};for(let n of r){let i=n.state;if(!i)continue;t(i.fillLibraryId),t(i.strokeLibraryId),t(i.markerStart),t(i.markerMid),t(i.markerEnd),t(i.symbolId);let a=i.filterLibraryIds;if(Array.isArray(a))for(let o of a)t(o)}return e}function se(r,e){let t=new Map;for(let l of e)t.set(l.id,l);let n=new Map,i=l=>{if(!l)return;let u=t.get(l);u&&n.set(l,u)},a=(l,u)=>{if(!l||typeof l!="object")return;let c=l;if(!c.id||n.has(c.id))return;let f=u==="linear-gradient"?"linear-gradient":u==="radial-gradient"?"radial-gradient":u==="pattern"?"pattern":null;if(!f)return;let{id:d,sourceId:m,...p}=l,b;if(f==="linear-gradient")b={kind:"linear-gradient",id:c.id,name:m??c.id,sourceId:m,gradient:p};else if(f==="radial-gradient")b={kind:"radial-gradient",id:c.id,name:m??c.id,sourceId:m,gradient:p};else{let{customPatternId:g,...y}=p;b={kind:"pattern",id:c.id,name:m??c.id,sourceId:m,pattern:y}}n.set(c.id,b)},o=(l,u)=>{let c=l.filters;if(!Array.isArray(c)||c.length===0)return;let f=`filter-${u}`;n.has(f)||n.set(f,{kind:"filter",id:f,name:f,filters:c,...l.filterColorInterpolation&&l.filterColorInterpolation!=="auto"?{colorInterpolation:l.filterColorInterpolation}:{},...l.filterUnits?{filterUnits:l.filterUnits}:{},...l.primitiveUnits?{primitiveUnits:l.primitiveUnits}:{},...typeof l.filterX=="string"?{x:l.filterX}:{},...typeof l.filterY=="string"?{y:l.filterY}:{},...typeof l.filterWidth=="string"?{width:l.filterWidth}:{},...typeof l.filterHeight=="string"?{height:l.filterHeight}:{}})};for(let l of r){let u=l.state;if(!u)continue;i(u.fillLibraryId),i(u.strokeLibraryId),i(u.markerStart),i(u.markerMid),i(u.markerEnd),i(u.symbolId);let c=u.filterLibraryIds;if(Array.isArray(c))for(let f of c)typeof f=="string"&&i(f);u.fillLibraryId||a(u.fillGradient,u.fillType),u.strokeLibraryId||a(u.strokeGradient,u.strokeType),(!Array.isArray(c)||c.length===0)&&o(u,l.id)}return n.size===0?"":Kr(Array.from(n.values()))}var xa={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",pathLength:"pathLength",svgX:"x",svgY:"y",svgWidth:"width",svgHeight:"height",opacity:"opacity",fillOpacity:"fill-opacity",strokeOpacity:"stroke-opacity",fillColor:"fill",strokeColor:"stroke",strokeWidth:"stroke-width",borderWidth:"stroke-width",cornerRadius:"rx",fontSize:"font-size",letterSpacing:"letter-spacing",wordSpacing:"word-spacing",textLength:"textLength",d:"d",polylinePoints:"points"},Sa=new Set(["transformMatrix","rotation","skewX","skewY"]);function ka(r){let t=Ne[r];return t?t.join(" "):"0 0 1 1"}function xe(r){return r.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function Qr(r){return r.cycleDuration!==void 0&&r.cycleDuration>0?r.cycleDuration:r.keyframes.length===0?0:r.keyframes[r.keyframes.length-1].time}function Jr(r,e){let t=r.keyframes;if(t.length===0)return{values:[],keyTimes:[],keySplines:[]};let n=t.map(o=>String(o.value)),i=t.map(o=>e>0?(o.time/e).toFixed(4):"0"),a=[];for(let o=1;o<t.length;o++)a.push(ka(t[o].easing));return{values:n,keyTimes:i,keySplines:a}}function _t(r){let e=r.beginTrigger;if(!e)return"0s";switch(e.type){case"time":return`${e.value}s`;case"event":return e.value;default:return"0s"}}function en(r){return r.cycleInfinite?"indefinite":r.cycleRepeats&&r.cycleRepeats>1?String(r.cycleRepeats):null}function va(r){let e=xa[r.property];if(!e)return"";let t=Qr(r);if(t<=0)return"";let{values:n,keyTimes:i,keySplines:a}=Jr(r,t);if(n.length<2)return"";let o=`<animate attributeName="${xe(e)}"`;o+=` values="${xe(n.join(";"))}"`,o+=` keyTimes="${i.join(";")}"`,a.length>0&&a.some(u=>u!=="0 0 1 1")&&(o+=' calcMode="spline"',o+=` keySplines="${a.join(";")}"`),o+=` dur="${t}s"`,o+=` begin="${_t(r)}"`;let l=en(r);return l&&(o+=` repeatCount="${l}"`),o+=' fill="freeze"',o+="/>",o}function _a(r){let e;switch(r.property){case"transformMatrix":e="matrix";break;case"rotation":e="rotate";break;case"skewX":e="skewX";break;case"skewY":e="skewY";break;default:return""}let t=Qr(r);if(t<=0)return"";let{keyTimes:n,keySplines:i}=Jr(r,t),a=e==="matrix"?r.keyframes.map(c=>wa(c.value)):r.keyframes.map(c=>String(c.value));if(a.length<2||a.some(c=>c.length===0))return"";let o=e==="rotate"&&r.transformOrigin?a.map(c=>`${c} ${r.transformOrigin.x} ${r.transformOrigin.y}`):a,l='<animateTransform attributeName="transform"';l+=` type="${e}"`,l+=` values="${xe(o.join(";"))}"`,l+=` keyTimes="${n.join(";")}"`,i.length>0&&i.some(c=>c!=="0 0 1 1")&&(l+=' calcMode="spline"',l+=` keySplines="${i.join(";")}"`),l+=` dur="${t}s"`,l+=` begin="${_t(r)}"`;let u=en(r);return u&&(l+=` repeatCount="${u}"`),l+=` additive="${r.additive??"sum"}"`,l+=' fill="freeze"',l+="/>",l}function wa(r){if(Array.isArray(r)&&r.length>=6){let e=r.slice(0,6);if(e.every(t=>typeof t=="number"&&Number.isFinite(t)))return e.join(" ")}if(typeof r=="string"){let e=r.trim(),t=/^matrix\(([^)]+)\)$/i.exec(e),i=(t?t[1]:e).split(/[\s,]+/).filter(Boolean).map(Number);if(i.length>=6&&i.slice(0,6).every(Number.isFinite))return i.slice(0,6).join(" ")}return""}function Pa(r){if(!r.motionPath)return"";let e=Qr(r);if(e<=0)return"";let{keyTimes:t,keySplines:n}=Jr(r,e),i=r.keyframes.map(c=>{let f=typeof c.value=="number"?c.value:parseFloat(c.value);return Math.max(0,Math.min(1,f))}),a=!!r.motionPathRef&&(r.motionPathRef.mode??"trackShape")==="curveTemplate",o="<animateMotion";a||(o+=` path="${xe(r.motionPath)}"`),o+=` keyTimes="${t.join(";")}"`,o+=` keyPoints="${i.join(";")}"`,n.length>0&&n.some(c=>c!=="0 0 1 1")&&(o+=' calcMode="spline"',o+=` keySplines="${n.join(";")}"`),o+=` dur="${e}s"`,o+=` begin="${_t(r)}"`;let l=en(r);l&&(o+=` repeatCount="${l}"`),o+=' fill="freeze"';let u=r.motionRotate??"auto";return o+=` rotate="${u}"`,a?o+=`><mpath href="#${xe(r.motionPathRef.shapeId)}"/></animateMotion>`:o+="/>",o}function Ta(r){let e=_t(r);if(e!=="0s")return e;let t=r.keyframes[0]?.time??0;return t!==0?`${t}s`:""}function Aa(r){let e=Ta(r);return e?`<discard begin="${xe(e)}"/>`:"<discard/>"}function wt(r){let e=new Map;for(let t of r.tracks){if(!t.enabled||t.property!=="discard"&&t.keyframes.length<2)continue;let n=[...t.keyframes].sort((o,l)=>o.time-l.time),i={...t,locked:t.locked??!1,keyframes:n.map(o=>({time:o.time,value:o.value,easing:o.easing}))},a="";if(t.property==="discard"?a=Aa(i):t.property==="pathMotion"&&t.motionPath?a=Pa(i):Sa.has(t.property)?a=_a(i):a=va(i),a){let o=e.get(t.shapeId)??[];o.push(a),e.set(t.shapeId,o)}}return e}function Se(r,e={}){let{xmlDeclaration:t=!0,backgroundColor:n,indent:i=!0,className:a}=e,o=r.viewboxes?.[0],l=e.width??o?.width??800,u=e.height??o?.height??600,c=e.viewBox??`0 0 ${l} ${u}`,f=i?`
8
- `:"",d=i?" ":"",m=r.shapes??[],p=m.filter(C=>C.state?.displayMode==="motionOnly"),b=m.filter(C=>C.state?.displayMode!=="motionOnly"),g=Ca(r),y=Ia(r),S=[...Array.isArray(r.library)?r.library:[],...(y??[]).filter(C=>!C.builtIn&&!(Array.isArray(r.library)&&r.library.some(L=>L.id===C.id)))],v=se(b,S),x=ie(b),k=Oa(g,b),P=Fa(p),_=v.length>0||x.length>0||k.length>0||P.length>0,$="";_&&($=`${f}${d}<defs>${f}`,v.length>0&&($+=`${d}${d}${v}${f}`),x.length>0&&($+=`${d}${d}${x}${f}`),k.length>0&&($+=`${d}${d}${k}${f}`),P.length>0&&($+=`${d}${d}${P}${f}`),$+=`${d}</defs>`);let w="";n&&(w=`${f}${d}<rect width="${l}" height="${u}" fill="${n}"/>`);let F=r.animationTimeline?wt(r.animationTimeline):null,I=b.map(C=>{let L=C.type==="symbol-instance"?Ba(C,g):H(C),E=F?.get(C.id);return E&&E.length>0&&(L=Ga(L,E,d)),`${d}${L}`}).join(f),R="";return t&&(R+=`<?xml version="1.0" encoding="UTF-8"?>${f}`),R+='<svg xmlns="http://www.w3.org/2000/svg"',R+=` width="${l}" height="${u}"`,R+=` viewBox="${c}"`,a&&(R+=` class="${a}"`),R+=">",R+=$,R+=w,b.length>0&&(R+=`${f}${I}`),R+=`${f}</svg>${f}`,R}function Fa(r){if(r.length===0)return"";let e=[];for(let t of r){let n=Ma(t);if(!n)continue;let i=Ra(n);e.push(`<path id="${Ln(t.id)}" d="${Ln(i)}"/>`)}return e.join("")}function Ma(r){let e=r.state;if(typeof e?.d=="string")return e.d;switch(r.type){case"rectangle":{let t=e?.x??0,n=e?.y??0,i=e?.width??0,a=e?.height??0;return i<=0||a<=0?null:`M${t},${n}h${i}v${a}h${-i}Z`}case"circle":{let t=e?.cx??0,n=e?.cy??0,i=e?.radius??0;return i<=0?null:`M${t-i},${n}A${i},${i} 0 1 0 ${t+i},${n}A${i},${i} 0 1 0 ${t-i},${n}Z`}case"ellipse":{let t=e?.cx??0,n=e?.cy??0,i=e?.rx??0,a=e?.ry??0;return i<=0||a<=0?null:`M${t-i},${n}A${i},${a} 0 1 0 ${t+i},${n}A${i},${a} 0 1 0 ${t-i},${n}Z`}case"line":{let t=e?.x1??0,n=e?.y1??0,i=e?.x2??0,a=e?.y2??0;return`M${t},${n}L${i},${a}`}default:return null}}function Ra(r){let e=/[Mm]\s*(-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)[\s,]+(-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)/.exec(r);if(!e)return r;let t=parseFloat(e[1]),n=parseFloat(e[2]);if(!isFinite(t)||!isFinite(n)||t===0&&n===0)return r;let i=!0;return r.replace(/([MLCQSTHVAZ])\s*([\d\s.,e+-]*)/gi,(a,o,l)=>{let u=o.toUpperCase(),c=o!==u,f=i;if(i=!1,u==="Z")return a;let d=l.trim().split(/[\s,]+/).filter(p=>p.length>0).map(Number);if(d.length===0||c&&!f)return a;let m=[];if(u==="H")for(let p of d)m.push(p-t);else if(u==="V")for(let p of d)m.push(p-n);else if(u==="A")for(let p=0;p<d.length;p+=7)m.push(d[p],d[p+1],d[p+2],d[p+3],d[p+4]),p+5<d.length&&m.push(d[p+5]-t),p+6<d.length&&m.push(d[p+6]-n);else for(let p=0;p<d.length;p+=2)m.push(d[p]-t),p+1<d.length&&m.push(d[p+1]-n);return`${o} ${m.join(" ")}`})}function Ln(r){return r.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;")}function Ca(r){let t=(Array.isArray(r.library)?r.library:[]).filter(n=>n.kind==="symbol");return t.length>0?t:r.symbols??[]}function Ia(r){let t=(Array.isArray(r.library)?r.library:[]).filter(n=>n.kind==="marker");return t.length>0?t:r.markers}var Pt=r=>r.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;"),La=r=>r.replace(/[^a-zA-Z0-9_-]/g,"_");function En(r){let e=r.state.symbolId??"",t=r.state.variantKey??"";return r.state.symbolOverrides&&Object.keys(r.state.symbolOverrides).length>0?`${e}--ovr-${r.id}`:t?`${e}--${La(t)}`:e}function Ea(r,e){return r.map(t=>{let n=e[t.id];return!n||Object.keys(n).length===0?t:{...t,state:{...t.state,...n}}})}function Da(r,e){return e?r.variants?.[e]??r.shapes:r.shapes}function Ba(r,e){let t=En(r),n=r.state.x??0,i=r.state.y??0,a=r.state.width??100,o=r.state.height??100;return`<use href="#${Pt(t)}" x="${n}" y="${i}" width="${a}" height="${o}"/>`}function Oa(r,e){if(r.length===0)return"";let t=new Map;for(let a of r)t.set(a.id,a);let n=new Map;for(let a of e){if(a.type!=="symbol-instance")continue;let o=a.state.symbolId??"",l=t.get(o);if(!l)continue;let u=En(a);if(n.has(u))continue;let c=Da(l,a.state.variantKey??""),f=a.state.symbolOverrides;f&&Object.keys(f).length>0&&(c=Ea(c,f)),n.set(u,{def:l,resolved:c})}if(n.size===0)return"";let i=[];for(let[a,{def:o,resolved:l}]of n){let u=l.map(d=>H(d)).join(""),c=o.viewBox?` viewBox="${Pt(o.viewBox)}"`:"",f=o.overflow?` overflow="${Pt(o.overflow)}"`:"";i.push(`<symbol id="${Pt(a)}"${c}${f}>${u}</symbol>`)}return i.join("")}function Ga(r,e,t){let n=e.join(""),i=0;for(;i<r.length;){let c=r.slice(i);if(!/^<defs[\s>]/.test(c))break;let f=r.indexOf("</defs>",i);if(f===-1)break;i=f+7}let a=r.slice(0,i),o=r.slice(i),l=o.lastIndexOf("/>");if(l!==-1){let c=o.match(/^<(\w+)/),f=c?c[1]:"g";return a+o.slice(0,l)+">"+n+`</${f}>`}let u=o.match(/<\/(\w+)>$/);if(u){let c=o.lastIndexOf(`</${u[1]}>`);return a+o.slice(0,c)+n+o.slice(c)}return a+o+n}function Tt(r,e){let t=re(r,e);return Se(r,{width:t.width,height:t.height,xmlDeclaration:e.xmlDeclaration??!1,indent:!0})}function za(r){return r==="class"?"className":r==="for"?"htmlFor":r.replace(/-([a-z])/g,(e,t)=>t.toUpperCase())}function Dn(r){return r.replace(/\s([a-z][a-z-]*?)=/g,(e,t)=>t.startsWith("data-")||t.startsWith("aria-")?e:` ${za(t)}=`)}function At(r,e){let t=e.componentName??"SvgComponent",n=re(r,e),i=e.indent??" ",a=r.shapes??[],o=e.typescript??!1,l=Array.isArray(r.library)?r.library:[],u=se(a,l),c=ie(a),f=u+c,d=f.length>0,m=a.map(b=>{let g=H(b);return`${i}${i}${i}${Dn(g)}`}),p=[];p.push("import React from 'react';"),p.push(""),o?(p.push(`interface ${t}Props {`),p.push(`${i}className?: string;`),p.push(`${i}style?: React.CSSProperties;`),p.push("}"),p.push(""),p.push(`const ${t}: React.FC<${t}Props> = ({ className, style }) => {`)):p.push(`const ${t} = ({ className, style }) => {`),p.push(`${i}return (`),p.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}>`),d&&(p.push(`${i}${i}${i}<defs>`),p.push(`${i}${i}${i}${i}${Dn(f)}`),p.push(`${i}${i}${i}</defs>`));for(let b of m)p.push(b);return p.push(`${i}${i}</svg>`),p.push(`${i});`),p.push("};"),p.push(""),p.push(`export default ${t};`),p.push(""),p.join(`
9
- `)}function Ft(r,e){let t=e.componentName??"SvgComponent",n=re(r,e),i=e.indent??" ",a=r.shapes??[],o=e.typescript??!1,l=Array.isArray(r.library)?r.library:[],u=se(a,l),c=ie(a),f=u+c,d=f.length>0,m=a.map(b=>`${i}${i}${H(b)}`),p=[];p.push("<template>"),p.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">`),d&&(p.push(`${i}${i}<defs>`),p.push(`${i}${i}${i}${f}`),p.push(`${i}${i}</defs>`));for(let b of m)p.push(b);return p.push(`${i}</svg>`),p.push("</template>"),p.push(""),o?p.push('<script setup lang="ts">'):p.push("<script setup>"),p.push(`// ${t}`),o?(p.push("defineProps<{"),p.push(`${i}className?: string;`),p.push(`${i}style?: Record<string, string>;`),p.push("}>();")):(p.push("defineProps({"),p.push(`${i}className: { type: String, default: '' },`),p.push(`${i}style: { type: Object, default: () => ({}) },`),p.push("});")),p.push("</script>"),p.push(""),p.join(`
10
- `)}var Ua=new Set(["circle","ellipse","rectangle","square","line","text","image"]);function Bn(r){return r.replace(/\\/g,"\\\\").replace(/'/g,"\\'")}function On(r){return r.replace(/\\/g,"\\\\").replace(/`/g,"\\`").replace(/\$\{/g,"\\${")}function Na(r){if(!Ua.has(r.type))return!0;let e=r.state.metadata;return!!(e?.title||e?.description||r.type==="text"&&r.state.isTextPath)}function Mt(r,e){let t=e.componentName??"createSvg",n=re(r,e),i=e.indent??" ",a=r.shapes??[],o=e.typescript??!1,l=[];l.push("import * as d3 from 'd3';"),l.push(""),o?l.push(`export function ${t}(container: string | HTMLElement): d3.Selection<SVGSVGElement, unknown, HTMLElement, unknown> {`):l.push(`export function ${t}(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 u=Array.isArray(r.library)?r.library:[],c=se(a,u),f=ie(a),d=`${c}${f}`;d.length>0&&(l.push(`${i}svg.append('defs').html(\`${On(d)}\`);`),l.push(""));for(let m=0;m<a.length;m++){let p=a[m];if(l.push(`${i}// ${p.type}${p.state.metadata?.name?` \u2014 ${p.state.metadata.name}`:""}`),Na(p)){l.push(`${i}svg.append('g').html(\`${On(H(p))}\`);`),l.push("");continue}let b=xn(p),g=mt(p),y=`shape${m+1}`;l.push(`${i}const ${y} = svg.append('${b}')`);for(let[S,v]of g)l.push(`${i}${i}.attr('${S}', '${Bn(v)}')`);p.type==="text"&&p.state.text&&l.push(`${i}${i}.text('${Bn(p.state.text)}')`),l[l.length-1]=l[l.length-1]+";",l.push("")}return l.push(`${i}return svg;`),l.push("}"),l.push(""),l.join(`
6
+ ${l}`)}}return a}function Ei(r){return[...r].sort((e,t)=>e.id.localeCompare(t.id))}function fe(r){if(r==null)return r;if(Array.isArray(r))return r.map(fe);if(typeof r!="object")return r;let e={},t=Object.keys(r).sort();for(let n of t)e[n]=fe(r[n]);return e}function Di(r){let e={};return e.id=r.id,e.type=r.type,e.state=fe(r.state),e}var Q=/\{\{\s*([\w.\-]+)\s*\}\}/g;function Ze(r,e){return r.replace(Q,(t,n)=>{let i=e[n];return i!==void 0?String(i):t})}function Je(r,e={}){let t={};if(r.templateVariables)for(let i of r.templateVariables)i.defaultValue!==void 0&&i.defaultValue!==""&&(t[i.name]=i.defaultValue);if(Object.assign(t,e),Object.keys(t).length===0)return JSON.parse(JSON.stringify(r));let n=JSON.parse(JSON.stringify(r));for(let i of n.shapes)Ke(i.state,t);if(n.documentMetadata){let i=n.documentMetadata;Ke(i,t)}return n}function Ke(r,e){for(let t of Object.keys(r)){let n=r[t];if(typeof n=="string"){if(Q.lastIndex=0,Q.test(n)){Q.lastIndex=0;let i=Ze(n,e);if(Bi(n)){let a=Number(i);if(!isNaN(a)&&Gi(t)){r[t]=a;continue}}r[t]=i}}else if(Array.isArray(n))for(let i=0;i<n.length;i++)typeof n[i]=="string"?(Q.lastIndex=0,Q.test(n[i])&&(Q.lastIndex=0,n[i]=Ze(n[i],e))):n[i]!==null&&typeof n[i]=="object"&&Ke(n[i],e);else n!==null&&typeof n=="object"&&Ke(n,e)}}function Bi(r){return/^\s*\{\{\s*[\w.\-]+\s*\}\}\s*$/.test(r)}var Oi=new Set(["x","y","width","height","radius","rx","ry","cx","cy","x1","y1","x2","y2","fontSize","borderWidth","cornerRadius","opacity","fillOpacity","strokeOpacity",...ve,"letterSpacing","wordSpacing","lineHeight","sides","arms","innerRadiusPercent","armWidthPercent","teeth","toothDepthPercent","holeRadiusPercent","turns","thicknessPercent","direction","headWidthPercent","headLengthPercent","shaftWidthPercent","shiftAngle","dashLength","gapLength","textPathStartOffset","imageOpacity"]);function Gi(r){return Oi.has(r)}function et(r){let e=r.templateVariables??[],t=new Set(e.map(a=>a.name)),n=new Set;for(let a of r.shapes)Qe(a.state,n);r.documentMetadata&&Qe(r.documentMetadata,n);let i=[...n].filter(a=>!t.has(a)).sort();return{defined:[...e],undeclared:i}}function Qe(r,e){for(let t of Object.values(r))if(typeof t=="string"){let n;for(Q.lastIndex=0;(n=Q.exec(t))!==null;)e.add(n[1])}else if(Array.isArray(t))for(let n of t)if(typeof n=="string"){let i;for(Q.lastIndex=0;(i=Q.exec(n))!==null;)e.add(i[1])}else n!==null&&typeof n=="object"&&Qe(n,e);else t!==null&&typeof t=="object"&&Qe(t,e)}function mn(r){let e={};for(let t of r){let n=t.indexOf("=");if(n===-1)throw new Error(`Invalid variable format: "${t}". Expected "name=value".`);let i=t.slice(0,n).trim(),a=t.slice(n+1);if(!i)throw new Error(`Invalid variable format: "${t}". Variable name cannot be empty.`);e[i]=a}return e}var gn=3,bn=12;function yn(r){return r==null||!Number.isFinite(r)?3:r<0?0:r>12?12:Math.floor(r)}function rt(r,e){if(!Number.isFinite(r))return r;let t=Math.pow(10,e);return Math.round(r*t)/t}var zi=/-?\d+(?:\.\d+)?(?:[eE][-+]?\d+)?/g;function _r(r,e){return r.replace(zi,t=>{let n=parseFloat(t);return Number.isFinite(n)?String(rt(n,e)):t})}var Ui=new Set(["rawTransform","strokeDasharray","filterX","filterY","filterWidth","filterHeight","cssClipPath"]),Ni=new Set(["metadata","customMetadata","customAttrs","customData","bindings","richTextData","cssMaskProperties","rawMetadata"]);function te(r,e,t){if(e==null)return e;if(typeof e=="number")return rt(e,t);if(typeof e=="string")return Ui.has(r)?_r(e,t):e;if(typeof e=="boolean")return e;if(Array.isArray(e))return e.map(n=>te(r,n,t));if(typeof e=="object"){if(Ni.has(r))return e;if(r==="symbolOverrides"){let i={};for(let[a,o]of Object.entries(e))i[a]=te("state",o,t);return i}let n={};for(let[i,a]of Object.entries(e))n[i]=te(i,a,t);return n}return e}function tt(r,e){return{id:r.id,type:r.type,state:te("state",r.state,e)}}function $n(r,e){let t={...r,shapes:r.shapes.map(n=>tt(n,e)),viewboxes:r.viewboxes.map(n=>te("viewbox",n,e))};return r.guides&&(t.guides=r.guides.map(n=>te("guide",n,e))),r.measurements&&(t.measurements=r.measurements.map(n=>te("measurement",n,e))),r.animationTimeline&&(t.animationTimeline=te("animationTimeline",r.animationTimeline,e)),r.symbols&&(t.symbols=r.symbols.map(n=>({...n,shapes:n.shapes.map(i=>tt(i,e))}))),r.markers&&(t.markers=r.markers.map(n=>te("marker",n,e))),r.customPatterns&&(t.customPatterns=r.customPatterns.map(n=>te("customPattern",n,e))),t}function Ie(r,e,t=-90){let n=[],i=t*Math.PI/180;for(let a=0;a<r;a++){let o=i+a*2*Math.PI/r;n.push({x:e*Math.cos(o),y:e*Math.sin(o)})}return n}function it(r,e,t,n=-90){let i=[],a=e*(t/100),o=n*Math.PI/180;for(let l=0;l<r*2;l++){let u=o+l*Math.PI/r,c=l%2===0?e:a;i.push({x:c*Math.cos(u),y:c*Math.sin(u)})}return i}function st(r,e,t=0){let n=r*(e/100)/2,i=[{x:-n,y:-r},{x:n,y:-r},{x:n,y:-n},{x:r,y:-n},{x:r,y:n},{x:n,y:n},{x:n,y:r},{x:-n,y:r},{x:-n,y:n},{x:-r,y:n},{x:-r,y:-n},{x:-n,y:-n}];if(t===0)return i;let a=Math.cos(t*Math.PI/180),o=Math.sin(t*Math.PI/180);return i.map(l=>({x:l.x*a-l.y*o,y:l.x*o+l.y*a}))}function at(r,e,t,n,i=-90){let o=r*2*(t/100),l=r*(e/100),u=l*(n/100),c=[{x:r,y:0},{x:r-o,y:-l/2},{x:r-o,y:-u/2},{x:-r,y:-u/2},{x:-r,y:u/2},{x:r-o,y:u/2},{x:r-o,y:l/2}];if(i===0)return c;let f=Math.cos(i*Math.PI/180),d=Math.sin(i*Math.PI/180);return c.map(m=>({x:m.x*f-m.y*d,y:m.x*d+m.y*f}))}function ot(r,e,t,n,i=0){let a=r,o=a*(t/100),l=a*(n/100),u=l/2,c=e*Math.PI/180,f=Math.cos(c),d=Math.sin(c),m=Math.abs(f),p=Math.abs(d),b=Math.max(m,p)||1,g={x:f*(a/b),y:d*(a/b)},y={x:g.x+f*o,y:g.y+d*o},S=Math.min(l,a-u),v=-a+u+S,x=a-u-S,k={x:-a,y:-a},P={x:a,y:-a},_={x:a,y:a},$={x:-a,y:a},w;if(m>=p&&f>0){let R=Math.max(v,Math.min(x,g.y)),C={x:a,y:R-u},L={x:a,y:R+u};w=[k,P,C,y,L,_,$]}else if(m>=p&&f<=0){let R=Math.max(v,Math.min(x,g.y)),C={x:-a,y:R+u},L={x:-a,y:R-u};w=[k,P,_,$,C,y,L]}else if(d<0){let R=Math.max(v,Math.min(x,g.x)),C={x:R-u,y:-a},L={x:R+u,y:-a};w=[k,C,y,L,P,_,$]}else{let R=Math.max(v,Math.min(x,g.x)),C={x:R+u,y:a},L={x:R-u,y:a};w=[k,P,_,C,y,L,$]}if(i===0)return w;let M=Math.cos(i*Math.PI/180),I=Math.sin(i*Math.PI/180);return w.map(R=>({x:R.x*M-R.y*I,y:R.x*I+R.y*M}))}function lt(r,e,t,n,i=0){let a=Math.max(2,Math.round(e)),o=r*(t/100),l=r*(n/100)/2,u=a+1,c=[];for(let g=0;g<u;g++){let y=g/(u-1),S=-r+y*2*r,v=0;g>0&&g<u-1&&(v=g%2===1?o:-o),c.push({x:v,y:S})}let f=[],d=[];for(let g=0;g<u;g++){if(g===0||g===u-1){f.push({...c[g]}),d.push({...c[g]});continue}let y=c[g-1],S=c[g],v=c[g+1],x=S.x-y.x,k=S.y-y.y,P=Math.hypot(x,k)||1,_=x/P,$=k/P,w=v.x-S.x,M=v.y-S.y,I=Math.hypot(w,M)||1,R=w/I,C=M/I,L=(_+R)/2,E=($+C)/2,B=Math.hypot(L,E),A,G;B<1e-6?(A=-$,G=_):(A=-E/B,G=L/B),f.push({x:S.x-A*l,y:S.y-G*l}),d.push({x:S.x+A*l,y:S.y+G*l})}let m=[];m.push(f[0]);for(let g=1;g<u-1;g++)m.push(d[g]);m.push(f[u-1]);for(let g=u-2;g>=1;g--)m.push(f[g]);if(i===0)return m;let p=Math.cos(i*Math.PI/180),b=Math.sin(i*Math.PI/180);return m.map(g=>({x:g.x*p-g.y*b,y:g.x*b+g.y*p}))}function ut(r,e,t,n=0){let i=r,a=Math.max(.3,Math.min(.9,e/100)),o=-i*(t/100),l={x:0,y:i},u={x:0,y:o},c={x:-i*a,y:i*.4},f={x:-i*a,y:-i},d={x:i*a,y:-i},m={x:i*a,y:i*.4},p=[l,c,f,u,d,m,l],b=n===0?p:(()=>{let P=Math.cos(n*Math.PI/180),_=Math.sin(n*Math.PI/180);return p.map($=>({x:$.x*P-$.y*_,y:$.x*_+$.y*P}))})(),[g,y,S,v,x,k]=b;return`M ${g.x} ${g.y} C ${y.x} ${y.y} ${S.x} ${S.y} ${v.x} ${v.y} C ${x.x} ${x.y} ${k.x} ${k.y} ${g.x} ${g.y} Z`}function ct(r,e,t,n=0){let i=Math.max(3,Math.round(e)),a=Math.max(.3,Math.min(1,t/100)),o=r,l=o*1.7,u=o*1.15,c=[];for(let $=0;$<i;$++){let M=(90+$/i*360)*Math.PI/180;c.push({x:l/2*Math.cos(M),y:-(u/2)*Math.sin(M)})}let f=.15,d=0;for(let $=0;$<i;$++){let w=c[$],M=c[($+1)%i];d=Math.max(d,Math.hypot(M.x-w.x,M.y-w.y))}let m=d/(2*(1-f))+.001,p=Math.max(m,d*(.68+a*.35)),b=c.map($=>{let w=$.y/(u/2);return p*(1-f*w)});function g($){let w=c[$],M=c[($+1)%i],I=b[$],R=b[($+1)%i],C=M.x-w.x,L=M.y-w.y,E=Math.hypot(C,L)||1,B=(I*I-R*R+E*E)/(2*E),A=Math.sqrt(Math.max(0,I*I-B*B)),G=w.x+B/E*C,q=w.y+B/E*L,W=-L/E,de=C/E,ee={x:G+W*A,y:q+de*A},Y={x:G-W*A,y:q-de*A};return ee.x*ee.x+ee.y*ee.y>Y.x*Y.x+Y.y*Y.y?ee:Y}let y=[];for(let $=0;$<i;$++)y.push(g($));let S=14,v=[];for(let $=0;$<i;$++){let w=c[$],M=b[$],I=y[($-1+i)%i],R=y[$],C=Math.atan2(I.y-w.y,I.x-w.x),E=Math.atan2(R.y-w.y,R.x-w.x)-C;E<=0&&(E+=2*Math.PI);let B=2*Math.PI-E,A=C+E/2,G=C-B/2,q={x:w.x+M*Math.cos(A),y:w.y+M*Math.sin(A)},W={x:w.x+M*Math.cos(G),y:w.y+M*Math.sin(G)},ee=q.x*q.x+q.y*q.y>W.x*W.x+W.y*W.y?E:-B;for(let Y=0;Y<S;Y++){let Ue=Y/S,Z=C+Ue*ee;v.push({x:w.x+M*Math.cos(Z),y:w.y+M*Math.sin(Z)})}}let x=0;for(let $ of v){let w=Math.max(Math.abs($.x),Math.abs($.y));w>x&&(x=w)}if(x>0&&x!==o){let $=o/x;for(let w of v)w.x*=$,w.y*=$}let k=$=>{if(n===0)return $;let w=Math.cos(n*Math.PI/180),M=Math.sin(n*Math.PI/180);return{x:$.x*w-$.y*M,y:$.x*M+$.y*w}},P=v.map(k),_=`M ${P[0].x} ${P[0].y}`;for(let $=1;$<P.length;$++)_+=` L ${P[$].x} ${P[$].y}`;return _+=" Z",_}function J(r,e=0,t=0){if(r.length<3)return"";if(e<=0)return r.map((a,o)=>(o===0?"M":"L")+`${a.x},${a.y}`).join(" ")+" Z";let n=Math.min(e,t*.4),i="";for(let a=0;a<r.length;a++){let o=r[(a-1+r.length)%r.length],l=r[a],u=r[(a+1)%r.length],c={x:o.x-l.x,y:o.y-l.y},f=Math.hypot(c.x,c.y);c.x/=f,c.y/=f;let d={x:u.x-l.x,y:u.y-l.y},m=Math.hypot(d.x,d.y);d.x/=m,d.y/=m;let p=Math.min(n,f/2),b=Math.min(n,m/2),g={x:l.x+c.x*p,y:l.y+c.y*p},y={x:l.x+d.x*b,y:l.y+d.y*b};i+=a===0?`M${g.x},${g.y}`:` L${g.x},${g.y}`,i+=` Q${l.x},${l.y} ${y.x},${y.y}`}return i+" Z"}function dt(r,e,t="evenodd"){let n=r*(e/100),i=t==="nonzero"?1:0;return`M ${r} 0 A ${r} ${r} 0 1 1 ${-r} 0 A ${r} ${r} 0 1 1 ${r} 0 Z M ${n} 0 A ${n} ${n} 0 1 ${i} ${-n} 0 A ${n} ${n} 0 1 ${i} ${n} 0 Z`}function ft(r,e,t,n=1,i=0){let a=r*(t/100),l=Math.round(e*36),u=e*2*Math.PI,c=(r-a/2)/u,f=i*Math.PI/180,d=[],m=[];for(let g=0;g<=l;g++){let y=g/l,S=y*u*n+f,v=c*(y*u)+a/2,x=a/2;d.push({x:(v+x*.3)*Math.cos(S),y:(v+x*.3)*Math.sin(S)}),m.push({x:Math.max(0,v-x*.3)*Math.cos(S),y:Math.max(0,v-x*.3)*Math.sin(S)})}let p=`M ${d[0].x} ${d[0].y}`;for(let g=1;g<d.length;g++)p+=` L ${d[g].x} ${d[g].y}`;let b=m[m.length-1];p+=` L ${b.x} ${b.y}`;for(let g=m.length-2;g>=0;g--)p+=` L ${m[g].x} ${m[g].y}`;return p+=" Z",p}var Vi=.2;function Tr(r,e,t,n=0){let i=e*(t/100),a=e,o=e-i,l=2*Math.PI/r,u=l*Vi/2,c=l/4,f=n*Math.PI/180,d=[];for(let m=0;m<r;m++){let p=f+m*l;d.push({x:o*Math.cos(p),y:o*Math.sin(p)}),d.push({x:a*Math.cos(p+c-u),y:a*Math.sin(p+c-u)}),d.push({x:a*Math.cos(p+c+u),y:a*Math.sin(p+c+u)}),d.push({x:o*Math.cos(p+l/2),y:o*Math.sin(p+l/2)})}return d}function ht(r,e,t,n=0,i=0,a="evenodd",o=0){let l=Tr(r,e,t,o),u=Math.min(n,e*.1),c=J(l,u,e);if(i>0){let f=e*(i/100),d=a==="nonzero"?1:0;c+=` M ${f} 0 A ${f} ${f} 0 1 ${d} ${-f} 0 A ${f} ${f} 0 1 ${d} ${f} 0 Z`}return c}function pt(r,e,t,n,i,a="round",o="uniform",l){let u=Math.min(t,n)/2,c,f,d,m,p,b,g,y;if(o==="non-uniform"&&l?(c=Math.min(l.radiusTL??i,u),f=Math.min(l.radiusTR??i,u),d=Math.min(l.radiusBR??i,u),m=Math.min(l.radiusBL??i,u),p=l.shapeTL??a,b=l.shapeTR??a,g=l.shapeBR??a,y=l.shapeBL??a):(c=f=d=m=Math.min(i,u),p=b=g=y=a),!(a!=="round"||o==="non-uniform"||c>0&&p!=="round"||f>0&&b!=="round"||d>0&&g!=="round"||m>0&&y!=="round")&&c===f&&f===d&&d===m)return null;let v=`M${r+c},${e}`;return v+=` L${r+t-f},${e}`,v+=nt(b,f,r+t,e,"tr"),v+=` L${r+t},${e+n-d}`,v+=nt(g,d,r+t,e+n,"br"),v+=` L${r+m},${e+n}`,v+=nt(y,m,r,e+n,"bl"),v+=` L${r},${e+c}`,v+=nt(p,c,r,e,"tl"),v+=" Z",v}function nt(r,e,t,n,i){if(e<=0)return"";switch(r){case"round":switch(i){case"tr":return` A${e},${e} 0 0 1 ${t},${n+e}`;case"br":return` A${e},${e} 0 0 1 ${t-e},${n}`;case"bl":return` A${e},${e} 0 0 1 ${t},${n-e}`;case"tl":return` A${e},${e} 0 0 1 ${t+e},${n}`}break;case"scoop":switch(i){case"tr":return` A${e},${e} 0 0 0 ${t},${n+e}`;case"br":return` A${e},${e} 0 0 0 ${t-e},${n}`;case"bl":return` A${e},${e} 0 0 0 ${t},${n-e}`;case"tl":return` A${e},${e} 0 0 0 ${t+e},${n}`}break;case"bevel":switch(i){case"tr":return` L${t},${n+e}`;case"br":return` L${t-e},${n}`;case"bl":return` L${t},${n-e}`;case"tl":return` L${t+e},${n}`}break;case"notch":switch(i){case"tr":return` L${t-e},${n+e} L${t},${n+e}`;case"br":return` L${t-e},${n-e} L${t-e},${n}`;case"bl":return` L${t+e},${n-e} L${t},${n-e}`;case"tl":return` L${t+e},${n+e} L${t+e},${n}`}break}return""}function ye(r,e,t=!1,n=.5,i){if(r.length<2)return r.length===1?`M ${r[0].x} ${r[0].y}`:"";switch(e){case"CATMULL_ROM":case"catmull-rom":return ji(r,t,n);case"BASIS":case"basis":return Yi(r,t);case"ARC":case"arc":return i&&i.length>0?Hi(r,t,i):Ce(r,t,"CUBIC");case"LINEAR":case"linear":return Ce(r,t,"LINEAR");case"QUADRATIC":case"quadratic":return Ce(r,t,"QUADRATIC");case"CUBIC":case"cubic":return Ce(r,t,"CUBIC");default:return Ce(r,t)}}function Hi(r,e,t){let n=`M ${r[0].x} ${r[0].y}`,i=0,a={rx:50,ry:50,rotation:0,largeArc:!1,sweep:!0};for(let o=0;o<r.length-1;o++){let l=r[o+1];if(l.isSubpathStart){if(e&&o-i>=1){let c=r[i],f=t?.[o]??a;n+=` A ${f.rx} ${f.ry} ${f.rotation} ${f.largeArc?1:0} ${f.sweep?1:0} ${c.x} ${c.y} Z`}n+=` M ${l.x} ${l.y}`,i=o+1;continue}let u=t?.[o]??a;n+=` A ${u.rx} ${u.ry} ${u.rotation} ${u.largeArc?1:0} ${u.sweep?1:0} ${l.x} ${l.y}`}if(e&&r.length-i>1){let o=r[i],l=t?.[r.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 Ce(r,e,t){let n=`M ${r[0].x} ${r[0].y}`,i=0,a=null,o=null;for(let l=0;l<r.length-1;l++){let u=r[l],c=r[l+1];if(c.isSubpathStart){if(e&&l-i>=1){let d=r[i];n+=wr(u,d,d.segmentType,a,o,t),n+=" Z"}n+=` M ${c.x} ${c.y}`,i=l+1,a=null,o=null;continue}n+=wr(u,c,c.segmentType,a,o,t);let f=Xi(c.segmentType??t,u,c);a=f,f==="quad"?o=u.handleOut??null:o=null}if(e&&r.length-i>1){let l=r[r.length-1],u=r[i],c=(u.segmentType??t??(l.handleOut||u.handleIn?"CUBIC":"LINEAR")).toUpperCase();c==="LINEAR"||c==="HORIZONTAL"||c==="VERTICAL"||(n+=wr(l,u,u.segmentType,a,o,t)),n+=" Z"}return n}var Wi=.001;function be(r,e){return Math.abs(r-e)<Wi}function Xi(r,e,t){let n=(r??(e.handleOut||t.handleIn?"CUBIC":"LINEAR")).toUpperCase();return n==="CUBIC"||n==="SMOOTH_CUBIC"?"cubic":n==="QUADRATIC"||n==="SMOOTH_QUADRATIC"?"quad":null}function wr(r,e,t,n,i,a){let o=(t??a??(r.handleOut||e.handleIn?"CUBIC":"LINEAR")).toUpperCase();if(o==="LINEAR"||o==="HORIZONTAL"||o==="VERTICAL")return(o==="HORIZONTAL"||o==="LINEAR")&&be(r.y,e.y)?` H ${e.x}`:(o==="VERTICAL"||o==="LINEAR")&&be(r.x,e.x)?` V ${e.y}`:` L ${e.x} ${e.y}`;if(o==="ARC"){let c=e.arcParams;return c?` A ${c.rx} ${c.ry} ${c.rotation} ${c.largeArc?1:0} ${c.sweep?1:0} ${e.x} ${e.y}`:` L ${e.x} ${e.y}`}if(o==="QUADRATIC"||o==="SMOOTH_QUADRATIC"){let c=r.handleOut??{x:(r.x+e.x)/2,y:(r.y+e.y)/2};return n==="quad"&&i&&be(c.x,2*r.x-i.x)&&be(c.y,2*r.y-i.y)?` T ${e.x} ${e.y}`:` Q ${c.x} ${c.y} ${e.x} ${e.y}`}let l=r.handleOut??{x:r.x,y:r.y},u=e.handleIn??{x:e.x,y:e.y};return n==="cubic"&&r.handleIn&&r.handleOut&&be(r.handleOut.x,2*r.x-r.handleIn.x)&&be(r.handleOut.y,2*r.y-r.handleIn.y)?` S ${u.x} ${u.y} ${e.x} ${e.y}`:` C ${l.x} ${l.y} ${u.x} ${u.y} ${e.x} ${e.y}`}function ji(r,e,t){if(r.length<2)return r.length===1?`M ${r[0].x} ${r[0].y}`:"";let n=t,i=e?[r[r.length-1],...r,r[0],r[1]]:[r[0],...r,r[r.length-1]],a=`M ${r[0].x} ${r[0].y}`,o=e?r.length:r.length-1;for(let l=0;l<o;l++){let u=i[l],c=i[l+1],f=i[l+2],d=i[l+3],m=Math.hypot(f.x-c.x,f.y-c.y),p=Math.hypot(c.x-u.x,c.y-u.y),b=Math.hypot(d.x-f.x,d.y-f.y),g=Math.pow(p,n),y=Math.pow(m,n),S=Math.pow(b,n),v=Math.pow(p,2*n),x=Math.pow(m,2*n),k=Math.pow(b,2*n),P,_,$,w;p<1e-8?(P=c.x,_=c.y):(P=(v*f.x-x*u.x+(2*v+3*g*y+x)*c.x)/(3*g*(g+y)),_=(v*f.y-x*u.y+(2*v+3*g*y+x)*c.y)/(3*g*(g+y))),b<1e-8?($=f.x,w=f.y):($=(k*c.x-x*d.x+(2*k+3*S*y+x)*f.x)/(3*S*(S+y)),w=(k*c.y-x*d.y+(2*k+3*S*y+x)*f.y)/(3*S*(S+y))),a+=` C ${P} ${_} ${$} ${w} ${f.x} ${f.y}`}return e&&(a+=" Z"),a}function Yi(r,e){let t=r.length;if(t<2)return t===1?`M ${r[0].x} ${r[0].y}`:"";if(t===2)return`M ${r[0].x} ${r[0].y} L ${r[1].x} ${r[1].y}`;if(e){let a=(r[0].x+4*r[1].x+r[2].x)/6,o=(r[0].y+4*r[1].y+r[2].y)/6,l=`M ${a} ${o}`;for(let u=0;u<t;u++){let c=r[(u+1)%t],f=r[(u+2)%t],d=r[(u+3)%t];l+=Pr(c,f,d)}return l+=" Z",l}let n=r,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<=t-3;a++)i+=Pr(n[a],n[a+1],n[a+2]);return i+=Pr(n[t-2],n[t-1],n[t-1]),i+=` L ${n[t-1].x} ${n[t-1].y}`,i}function Pr(r,e,t){return` C ${(2*r.x+e.x)/3} ${(2*r.y+e.y)/3} ${(r.x+2*e.x)/3} ${(r.y+2*e.y)/3} ${(r.x+4*e.x+t.x)/6} ${(r.y+4*e.y+t.y)/6}`}function $e(r,e,t){let n=Number.isFinite(e)?Math.max(1,e):8,i=Number.isFinite(t)?Math.max(1,t):4;switch(r){case"dashed":case"dotted":case"custom":return`${n} ${i}`;default:return null}}var qi=[["fontVariant","font-variant"],["fontVariantLigatures","font-variant-ligatures"],["fontVariantPosition","font-variant-position"],["fontVariantCaps","font-variant-caps"],["fontVariantNumeric","font-variant-numeric"],["fontVariantEastAsian","font-variant-east-asian"]];function O(r){return r.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;")}function Zi(r){let e=r.fillType;return e||(r.fillGradient?r.fillGradient.r!==void 0?"radial-gradient":"linear-gradient":r.linearGradient?"linear-gradient":r.radialGradient?"radial-gradient":"solid")}function mt(r){let e=new Map,t=r.state,n=t;switch(r.type){case"circle":e.set("cx",String(t.x??0)),e.set("cy",String(t.y??0)),e.set("r",String(t.radius??50));break;case"ellipse":e.set("cx",String(t.cx??0)),e.set("cy",String(t.cy??0)),e.set("rx",String(t.rx??50)),e.set("ry",String(t.ry??30));break;case"rectangle":case"square":e.set("x",String(t.x??0)),e.set("y",String(t.y??0)),e.set("width",String(t.width??100)),e.set("height",String(t.height??100));{let k=t.rx??t.cornerRadius??0,P=t.ry??t.cornerRadius??0;(k>0||P>0)&&(e.set("rx",String(k)),e.set("ry",String(P)))}break;case"line":e.set("x1",String(t.x1??0)),e.set("y1",String(t.y1??0)),e.set("x2",String(t.x2??0)),e.set("y2",String(t.y2??0));break;case"text":e.set("x",String(t.x??0)),e.set("y",String(t.y??0)),t.fontSize&&e.set("font-size",String(t.fontSize)),t.fontFamily&&e.set("font-family",t.fontFamily),t.fontWeight&&e.set("font-weight",t.fontWeight),t.fontStyle&&e.set("font-style",t.fontStyle),t.textAnchor&&e.set("text-anchor",t.textAnchor),t.letterSpacing&&e.set("letter-spacing",String(t.letterSpacing));{let k=qi.map(([P,_])=>{let $=typeof t[P]=="string"?String(t[P]).trim():"";return $?`${_}: ${$}`:""}).filter(Boolean).join("; ");k&&e.set("style",k)}break;case"image":e.set("x",String(t.x??0)),e.set("y",String(t.y??0)),e.set("width",String(t.width??100)),e.set("height",String(t.height??100)),n.href&&e.set("href",String(n.href));break}let i=Zi(n);i==="none"?e.set("fill","none"):i==="linear-gradient"||i==="radial-gradient"?e.set("fill",`url(#gradient-fill-${r.id})`):i==="pattern"?e.set("fill",`url(#pattern-fill-${r.id})`):e.set("fill",t.fillColor??"#000000");let a=t.opacity;a!==void 0&&a<1&&e.set("opacity",String(a));let o=t.fillOpacity;o!==void 0&&o<1&&e.set("fill-opacity",String(o)),t.fillRule&&t.fillRule!=="nonzero"&&e.set("fill-rule",t.fillRule);let l=n.strokeType??"solid";if(l==="none")e.set("stroke","none");else if(l==="linear-gradient"||l==="radial-gradient")e.set("stroke",`url(#gradient-stroke-${r.id})`);else{let k=t.borderColor??"none";k!=="none"&&e.set("stroke",k)}let u=t.borderWidth;u!=null&&u!==0&&e.set("stroke-width",String(u));let c=t.strokeOpacity;c!==void 0&&c<1&&e.set("stroke-opacity",String(c));let f=t.lineStyle??"solid",d=t.dashLength??8,m=t.gapLength??4,p=$e(f,d,m);p&&(e.set("stroke-dasharray",p),f==="dotted"&&e.set("stroke-linecap","round"));let b=Ki(n);b&&e.set("transform",b);let g=n.filters;g&&g.length>0&&e.set("filter",`url(#filter-${r.id})`);let y=t.shapeRendering;y&&y!=="auto"&&e.set("shape-rendering",y),t.pathLength!==void 0&&e.set("pathLength",String(t.pathLength));let S=n.startEndpoint,v=n.endEndpoint;S&&S!=="none"&&e.set("marker-start",`url(#line-marker-${S})`),v&&v!=="none"&&e.set("marker-end",`url(#line-marker-${v})`);let x=n.metadata;return x&&(x.role&&e.set("role",x.role),x.ariaLabel&&e.set("aria-label",x.ariaLabel)),e}function xn(r){switch(r.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"path":case"polyline":case"triangle":case"ngon":case"star":case"cross":case"ring":case"spiral":case"gear":case"arrow":return"path";default:return"g"}}function Ki(r){return ge(r)}function re(r,e){let t=r.viewboxes?.[0];return{width:e.width??t?.width??800,height:e.height??t?.height??600}}function s(r,e){return e==null||e===""?"":` ${r}="${O(String(e))}"`}function bt(r){let e=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(r);return e?{r:parseInt(e[1],16)/255,g:parseInt(e[2],16)/255,b:parseInt(e[3],16)/255}:{r:0,g:0,b:0}}function Qi(r,e,t){let{offsetX:n,offsetY:i,blurRadius:a,spread:o,color:l,opacity:u}=r,c="";if(o===0)c+=`<feDropShadow${s("in",e)}${s("dx",n)}${s("dy",i)}${s("stdDeviation",a/2)}${s("flood-color",l)}${s("flood-opacity",u)}${s("result",`${t}_shadow`)}/>`,c+=`<feMerge${s("result",t)}><feMergeNode${s("in",`${t}_shadow`)}/><feMergeNode${s("in",e)}/></feMerge>`;else{c+=`<feColorMatrix${s("in",e)}${s("type","matrix")}${s("values","0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0")}${s("result",`${t}_alpha`)}/>`;let f=o>0?"dilate":"erode",d=Math.abs(o);c+=`<feMorphology${s("in",`${t}_alpha`)}${s("operator",f)}${s("radius",d)}${s("result",`${t}_spread`)}/>`,c+=`<feGaussianBlur${s("in",`${t}_spread`)}${s("stdDeviation",a/2)}${s("result",`${t}_blur`)}/>`,c+=`<feOffset${s("in",`${t}_blur`)}${s("dx",n)}${s("dy",i)}${s("result",`${t}_offset`)}/>`,c+=`<feFlood${s("flood-color",l)}${s("flood-opacity",u)}${s("result",`${t}_color`)}/>`,c+=`<feComposite${s("in",`${t}_color`)}${s("in2",`${t}_offset`)}${s("operator","in")}${s("result",`${t}_shadow`)}/>`,c+=`<feMerge${s("result",t)}><feMergeNode${s("in",`${t}_shadow`)}/><feMergeNode${s("in",e)}/></feMerge>`}return c}function Ji(r,e,t){let{offsetX:n,offsetY:i,blurRadius:a,choke:o,color:l,opacity:u}=r,c=a*(1-o/100),f="";return f+=`<feColorMatrix${s("in",e)}${s("type","matrix")}${s("values","0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0")}${s("result",`${t}_alpha`)}/>`,f+=`<feComponentTransfer${s("in",`${t}_alpha`)}${s("result",`${t}_inverted`)}><feFuncA${s("type","table")}${s("tableValues","1 0")}/></feComponentTransfer>`,f+=`<feGaussianBlur${s("in",`${t}_inverted`)}${s("stdDeviation",c/2)}${s("result",`${t}_blur`)}/>`,f+=`<feOffset${s("in",`${t}_blur`)}${s("dx",n)}${s("dy",i)}${s("result",`${t}_offset`)}/>`,f+=`<feFlood${s("flood-color",l)}${s("flood-opacity",u)}${s("result",`${t}_color`)}/>`,f+=`<feComposite${s("in",`${t}_color`)}${s("in2",`${t}_offset`)}${s("operator","in")}${s("result",`${t}_coloredShadow`)}/>`,f+=`<feComposite${s("in",`${t}_coloredShadow`)}${s("in2",`${t}_alpha`)}${s("operator","in")}${s("result",`${t}_innerShadow`)}/>`,f+=`<feComposite${s("in",`${t}_innerShadow`)}${s("in2",e)}${s("operator","over")}${s("result",t)}/>`,f}function es(r,e,t){let{blurX:n,blurY:i}=r;return n===0&&i===0?D(e,t):`<feGaussianBlur${s("in",e)}${s("stdDeviation",`${n/2} ${i/2}`)}${s("result",t)}/>`}function ts(r,e,t){let{distance:n,angle:i}=r;if(n===0)return D(e,t);let a=i*Math.PI/180,o=Math.abs(Math.cos(a)*n),l=Math.abs(Math.sin(a)*n);return`<feGaussianBlur${s("in",e)}${s("stdDeviation",`${o/2} ${l/2}`)}${s("result",t)}/>`}function Sn(r,e,t){let{x:n,y:i,z:a,color:o,surfaceScale:l,diffuseConstant:u,specularConstant:c,specularExponent:f}=r,d="";return d+=`<feDiffuseLighting${s("in","SourceAlpha")}${s("surfaceScale",l)}${s("diffuseConstant",u)}${s("lighting-color",o)}${s("result",`${t}_diffuse`)}>`,d+=`<fePointLight${s("x",n)}${s("y",i)}${s("z",a)}/>`,d+="</feDiffuseLighting>",d+=`<feSpecularLighting${s("in","SourceAlpha")}${s("surfaceScale",l)}${s("specularConstant",c)}${s("specularExponent",f)}${s("lighting-color",o)}${s("result",`${t}_specular`)}>`,d+=`<fePointLight${s("x",n)}${s("y",i)}${s("z",a)}/>`,d+="</feSpecularLighting>",d+=`<feComposite${s("in",e)}${s("in2",`${t}_diffuse`)}${s("operator","arithmetic")}${s("k1",1)}${s("k2",0)}${s("k3",0)}${s("k4",0)}${s("result",`${t}_lit`)}/>`,d+=`<feComposite${s("in",`${t}_specular`)}${s("in2",`${t}_lit`)}${s("operator","arithmetic")}${s("k1",0)}${s("k2",1)}${s("k3",1)}${s("k4",0)}${s("result",t)}/>`,d}function kn(r,e,t){let{x:n,y:i,z:a,pointsAtX:o,pointsAtY:l,pointsAtZ:u,coneAngle:c,color:f,surfaceScale:d,specularConstant:m,specularExponent:p}=r,b="";return b+=`<feSpecularLighting${s("in","SourceAlpha")}${s("surfaceScale",d)}${s("specularConstant",m)}${s("specularExponent",p)}${s("lighting-color",f)}${s("result",`${t}_specular`)}>`,b+=`<feSpotLight${s("x",n)}${s("y",i)}${s("z",a)}${s("pointsAtX",o)}${s("pointsAtY",l)}${s("pointsAtZ",u)}${s("limitingConeAngle",c)}/>`,b+="</feSpecularLighting>",b+=`<feComposite${s("in",`${t}_specular`)}${s("in2","SourceAlpha")}${s("operator","in")}${s("result",`${t}_clipped`)}/>`,b+=`<feComposite${s("in",`${t}_clipped`)}${s("in2",e)}${s("operator","arithmetic")}${s("k1",0)}${s("k2",1)}${s("k3",1)}${s("k4",0)}${s("result",t)}/>`,b}function vn(r){switch(r.kind){case"point":return`<fePointLight${s("x",r.x)}${s("y",r.y)}${s("z",r.z)}/>`;case"spot":{let e=`<feSpotLight${s("x",r.x)}${s("y",r.y)}${s("z",r.z)}${s("pointsAtX",r.pointsAtX)}${s("pointsAtY",r.pointsAtY)}${s("pointsAtZ",r.pointsAtZ)}`;return r.limitingConeAngle!==void 0&&(e+=s("limitingConeAngle",r.limitingConeAngle)),r.specularExponent!==void 0&&(e+=s("specularExponent",r.specularExponent)),e+"/>"}case"distant":return`<feDistantLight${s("azimuth",r.azimuth)}${s("elevation",r.elevation)}/>`}}function rs(r,e,t){return`<feDiffuseLighting${s("in",e)}${s("surfaceScale",r.surfaceScale)}${s("diffuseConstant",r.diffuseConstant)}${s("lighting-color",r.color)}${s("result",t)}>`+vn(r.lightSource)+"</feDiffuseLighting>"}function ns(r,e,t){return`<feSpecularLighting${s("in",e)}${s("surfaceScale",r.surfaceScale)}${s("specularConstant",r.specularConstant)}${s("specularExponent",r.specularExponent)}${s("lighting-color",r.color)}${s("result",t)}>`+vn(r.lightSource)+"</feSpecularLighting>"}function is(r,e,t){let{width:n,color:i,opacity:a,position:o}=r,l="";if(o==="inside")l+=`<feMorphology${s("in","SourceAlpha")}${s("operator","erode")}${s("radius",n)}${s("result",`${t}_eroded`)}/>`,l+=`<feComposite${s("in","SourceAlpha")}${s("in2",`${t}_eroded`)}${s("operator","out")}${s("result",`${t}_outlineAlpha`)}/>`,l+=`<feFlood${s("flood-color",i)}${s("flood-opacity",a)}${s("result",`${t}_color`)}/>`,l+=`<feComposite${s("in",`${t}_color`)}${s("in2",`${t}_outlineAlpha`)}${s("operator","in")}${s("result",`${t}_outline`)}/>`,l+=`<feComposite${s("in",`${t}_outline`)}${s("in2",e)}${s("operator","over")}${s("result",t)}/>`;else{let u=o==="outside"?n:n/2;l+=`<feMorphology${s("in","SourceAlpha")}${s("operator","dilate")}${s("radius",u)}${s("result",`${t}_dilated`)}/>`,l+=`<feComposite${s("in",`${t}_dilated`)}${s("in2","SourceAlpha")}${s("operator","out")}${s("result",`${t}_outlineAlpha`)}/>`,l+=`<feFlood${s("flood-color",i)}${s("flood-opacity",a)}${s("result",`${t}_color`)}/>`,l+=`<feComposite${s("in",`${t}_color`)}${s("in2",`${t}_outlineAlpha`)}${s("operator","in")}${s("result",`${t}_outline`)}/>`,l+=`<feMerge${s("result",t)}><feMergeNode${s("in",`${t}_outline`)}/><feMergeNode${s("in",e)}/></feMerge>`}return l}function ss(r,e,t){let{amount:n}=r;if(n===0)return D(e,t);let i=1+4*n,a=-n,o=[0,a,0,a,i,a,0,a,0].join(" ");return`<feConvolveMatrix${s("in",e)}${s("order","3")}${s("kernelMatrix",o)}${s("divisor","1")}${s("bias","0")}${s("preserveAlpha","true")}${s("edgeMode","duplicate")}${s("result",t)}/>`}function as(r,e,t){let{blockSize:n}=r;if(n<=1)return D(e,t);let i=n/2,a="";return a+=`<feMorphology${s("in",e)}${s("operator","erode")}${s("radius",i)}${s("result",`${t}_eroded`)}/>`,a+=`<feMorphology${s("in",`${t}_eroded`)}${s("operator","dilate")}${s("radius",i)}${s("result",t)}/>`,a}function os(r,e,t){let{scale:n,frequency:i,octaves:a,warpType:o}=r;if(n===0)return D(e,t);let l="";return l+=`<feTurbulence${s("type",o)}${s("baseFrequency",i)}${s("numOctaves",a)}${s("seed",0)}${s("result",`${t}_turbulence`)}/>`,l+=`<feDisplacementMap${s("in",e)}${s("in2",`${t}_turbulence`)}${s("scale",n)}${s("xChannelSelector","R")}${s("yChannelSelector","G")}${s("result",t)}/>`,l}function ls(r,e,t){let{operator:n,radiusX:i,radiusY:a}=r;return i===0&&a===0?D(e,t):`<feMorphology${s("in",e)}${s("operator",n)}${s("radius",`${i} ${a}`)}${s("result",t)}/>`}function us(r,e,t){let{levels:n}=r;if(n<2)return D(e,t);let i=[];for(let l=0;l<n;l++)i.push(l/(n-1));let a=i.join(" "),o=`<feComponentTransfer${s("in",e)}${s("result",t)}>`;return o+=`<feFuncR${s("type","discrete")}${s("tableValues",a)}/>`,o+=`<feFuncG${s("type","discrete")}${s("tableValues",a)}/>`,o+=`<feFuncB${s("type","discrete")}${s("tableValues",a)}/>`,o+="</feComponentTransfer>",o}function cs(r,e,t){let{levels:n,contrast:i}=r;if(n<2)return D(e,t);let a=[];for(let u=0;u<n;u++){let c=u/(n-1),f=c;i!==1&&(f=.5+(c-.5)*i,f=Math.max(0,Math.min(1,f))),a.push(f)}let o=a.join(" "),l=`<feComponentTransfer${s("in",e)}${s("result",t)}>`;return l+=`<feFuncR${s("type","table")}${s("tableValues",o)}/>`,l+=`<feFuncG${s("type","table")}${s("tableValues",o)}/>`,l+=`<feFuncB${s("type","table")}${s("tableValues",o)}/>`,l+="</feComponentTransfer>",l}function ds(r,e,t){let{radius:n}=r;if(n===0)return D(e,t);let i="";return i+=`<feGaussianBlur${s("in","SourceAlpha")}${s("stdDeviation",n)}${s("result",`${t}_blurredAlpha`)}/>`,i+=`<feComponentTransfer${s("in",`${t}_blurredAlpha`)}${s("result",`${t}_thresholdAlpha`)}><feFuncA${s("type","linear")}${s("slope",20)}${s("intercept",-9)}/></feComponentTransfer>`,i+=`<feComposite${s("in",e)}${s("in2",`${t}_thresholdAlpha`)}${s("operator","in")}${s("result",t)}/>`,i}function fs(r,e,t){let{amount:n}=r;if(n===0)return D(e,t);let i=1-n;return`<feColorMatrix${s("color-interpolation-filters","sRGB")}${s("in",e)}${s("type","saturate")}${s("values",i)}${s("result",t)}/>`}function hs(r,e,t){let{red:n,green:i,blue:a}=r;if(n===1&&i===1&&a===1)return D(e,t);let o=`<feComponentTransfer${s("in",e)}${s("result",t)}>`;return o+=`<feFuncR${s("type","linear")}${s("slope",n)}${s("intercept",0)}/>`,o+=`<feFuncG${s("type","linear")}${s("slope",i)}${s("intercept",0)}/>`,o+=`<feFuncB${s("type","linear")}${s("slope",a)}${s("intercept",0)}/>`,o+="</feComponentTransfer>",o}function ps(r,e,t){let{amount:n}=r;if(n===1)return D(e,t);let i=`<feComponentTransfer${s("color-interpolation-filters","sRGB")}${s("in",e)}${s("result",t)}>`;return i+=`<feFuncR${s("type","linear")}${s("slope",n)}${s("intercept",0)}/>`,i+=`<feFuncG${s("type","linear")}${s("slope",n)}${s("intercept",0)}/>`,i+=`<feFuncB${s("type","linear")}${s("slope",n)}${s("intercept",0)}/>`,i+="</feComponentTransfer>",i}function ms(r,e,t){let{amount:n}=r;if(n===1)return D(e,t);let i=.5*(1-n),a=`<feComponentTransfer${s("color-interpolation-filters","sRGB")}${s("in",e)}${s("result",t)}>`;return a+=`<feFuncR${s("type","linear")}${s("slope",n)}${s("intercept",i)}/>`,a+=`<feFuncG${s("type","linear")}${s("slope",n)}${s("intercept",i)}/>`,a+=`<feFuncB${s("type","linear")}${s("slope",n)}${s("intercept",i)}/>`,a+="</feComponentTransfer>",a}function gs(r,e,t){let{amount:n}=r;if(n===1)return D(e,t);let i=`<feComponentTransfer${s("color-interpolation-filters","sRGB")}${s("in",e)}${s("result",t)}>`;return i+=`<feFuncA${s("type","linear")}${s("slope",n)}${s("intercept",0)}/>`,i+="</feComponentTransfer>",i}function bs(r,e,t){let{amount:n}=r;if(n===0)return D(e,t);let i=n,a=1-n,o=`${i} ${a}`,l=`<feComponentTransfer${s("color-interpolation-filters","sRGB")}${s("in",e)}${s("result",t)}>`;return l+=`<feFuncR${s("type","table")}${s("tableValues",o)}/>`,l+=`<feFuncG${s("type","table")}${s("tableValues",o)}/>`,l+=`<feFuncB${s("type","table")}${s("tableValues",o)}/>`,l+="</feComponentTransfer>",l}function ys(r,e,t){let{angle:n}=r;return n===0||n===360?D(e,t):`<feColorMatrix${s("color-interpolation-filters","sRGB")}${s("in",e)}${s("type","hueRotate")}${s("values",n)}${s("result",t)}/>`}function $s(r,e,t){let{amount:n}=r;return n===1?D(e,t):`<feColorMatrix${s("color-interpolation-filters","sRGB")}${s("in",e)}${s("type","saturate")}${s("values",n)}${s("result",t)}/>`}function xs(r,e,t){let{threshold:n}=r,i="";if(i+=`<feColorMatrix${s("in",e)}${s("type","saturate")}${s("values",0)}${s("result",`${t}_gray`)}/>`,n===.5)i+=`<feComponentTransfer${s("in",`${t}_gray`)}${s("result",t)}>`,i+=`<feFuncR${s("type","discrete")}${s("tableValues","0 1")}/>`,i+=`<feFuncG${s("type","discrete")}${s("tableValues","0 1")}/>`,i+=`<feFuncB${s("type","discrete")}${s("tableValues","0 1")}/>`,i+="</feComponentTransfer>";else{let o=[];for(let u=0;u<256;u++)o.push(u/255<n?0:1);let l=o.join(" ");i+=`<feComponentTransfer${s("in",`${t}_gray`)}${s("result",t)}>`,i+=`<feFuncR${s("type","table")}${s("tableValues",l)}/>`,i+=`<feFuncG${s("type","table")}${s("tableValues",l)}/>`,i+=`<feFuncB${s("type","table")}${s("tableValues",l)}/>`,i+="</feComponentTransfer>"}return i}function Ss(r,e,t){let{amount:n}=r;if(n===0)return D(e,t);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],u=[0,1,0,0,0],c=[0,0,1,0,0],f=(g,y)=>g.map((S,v)=>S*(1-n)+y[v]*n),d=f(l,i),m=f(u,a),p=f(c,o),b=[...d,...m,...p,0,0,0,1,0].join(" ");return`<feColorMatrix${s("color-interpolation-filters","sRGB")}${s("in",e)}${s("type","matrix")}${s("values",b)}${s("result",t)}/>`}function ks(r,e,t){let{shadowColor:n,highlightColor:i}=r,a=bt(n),o=bt(i),l="";return l+=`<feColorMatrix${s("in",e)}${s("type","saturate")}${s("values",0)}${s("result",`${t}_gray`)}/>`,l+=`<feComponentTransfer${s("in",`${t}_gray`)}${s("result",t)}>`,l+=`<feFuncR${s("type","table")}${s("tableValues",`${a.r} ${o.r}`)}/>`,l+=`<feFuncG${s("type","table")}${s("tableValues",`${a.g} ${o.g}`)}/>`,l+=`<feFuncB${s("type","table")}${s("tableValues",`${a.b} ${o.b}`)}/>`,l+="</feComponentTransfer>",l}function vs(r,e,t){let{intensity:n}=r;if(n===0)return D(e,t);let i="";i+=`<feComponentTransfer${s("in",e)}${s("result",`${t}_invert`)}>`,i+=`<feFuncR${s("type","table")}${s("tableValues","1 0")}/>`,i+=`<feFuncG${s("type","table")}${s("tableValues","1 0")}/>`,i+=`<feFuncB${s("type","table")}${s("tableValues","1 0")}/>`,i+="</feComponentTransfer>",i+=`<feColorMatrix${s("in",`${t}_invert`)}${s("type","saturate")}${s("values",0)}${s("result",`${t}_gray`)}/>`;let a=[.1,.1,.1,0,0],o=[.3,.4,.3,0,0],l=[.5,.5,.8,0,0],u=[1,0,0,0,0],c=[0,1,0,0,0],f=[0,0,1,0,0],d=(y,S)=>y.map((v,x)=>v*(1-n)+S[x]*n),m=d(u,a),p=d(c,o),b=d(f,l),g=[...m,...p,...b,0,0,0,1,0].join(" ");return i+=`<feColorMatrix${s("in",`${t}_gray`)}${s("type","matrix")}${s("values",g)}${s("result",t)}/>`,i}function _s(r,e,t){let{amount:n,scale:i}=r;if(n===0)return D(e,t);let a=1/i,o="";return o+=`<feTurbulence${s("type","fractalNoise")}${s("baseFrequency",a)}${s("numOctaves",3)}${s("seed",0)}${s("result",`${t}_noise`)}/>`,o+=`<feColorMatrix${s("in",`${t}_noise`)}${s("type","saturate")}${s("values",0)}${s("result",`${t}_noiseGray`)}/>`,o+=`<feBlend${s("in",e)}${s("in2",`${t}_noiseGray`)}${s("mode","overlay")}${s("result",`${t}_blended`)}/>`,o+=`<feComposite${s("in",`${t}_blended`)}${s("in2",e)}${s("operator","arithmetic")}${s("k1",0)}${s("k2",n)}${s("k3",1-n)}${s("k4",0)}${s("result",`${t}_amt`)}/>`,o+=`<feComposite${s("in",`${t}_amt`)}${s("in2",e)}${s("operator","in")}${s("result",t)}/>`,o}function ws(r,e,t){let{strength:n,angle:i}=r;if(n===0)return D(e,t);let a=i*Math.PI/180,o=Math.cos(a),l=Math.sin(a),u=n,c=[-(u*(o+l)),-(u*l),u*(-o+l),-(u*o),1,u*o,u*(o-l),u*l,u*(o+l)].join(" ");return`<feConvolveMatrix${s("in",e)}${s("order","3 3")}${s("kernelMatrix",c)}${s("divisor",1)}${s("bias",.5)}${s("preserveAlpha","true")}${s("result",t)}/>`}function Ps(r,e,t){let{amount:n,size:i}=r;if(n===0)return D(e,t);let a=.5/i,o="";return o+=`<feTurbulence${s("type","fractalNoise")}${s("baseFrequency",`${a} ${a}`)}${s("numOctaves",5)}${s("seed",0)}${s("stitchTiles","stitch")}${s("result",`${t}_grain`)}/>`,o+=`<feColorMatrix${s("in",`${t}_grain`)}${s("type","saturate")}${s("values",0)}${s("result",`${t}_grainGray`)}/>`,o+=`<feBlend${s("in",e)}${s("in2",`${t}_grainGray`)}${s("mode","soft-light")}${s("result",`${t}_blended`)}/>`,o+=`<feComposite${s("in",`${t}_blended`)}${s("in2",e)}${s("operator","arithmetic")}${s("k1",0)}${s("k2",n)}${s("k3",1-n)}${s("k4",0)}${s("result",`${t}_amt`)}/>`,o+=`<feComposite${s("in",`${t}_amt`)}${s("in2",e)}${s("operator","in")}${s("result",t)}/>`,o}function Ts(r,e,t){let{wetness:n,turbulence:i}=r;if(n===0&&i===0)return D(e,t);let a="";return a+=`<feTurbulence${s("type","fractalNoise")}${s("baseFrequency",.02+i*.03)}${s("numOctaves",4)}${s("seed",42)}${s("result",`${t}_turb`)}/>`,a+=`<feDisplacementMap${s("in",e)}${s("in2",`${t}_turb`)}${s("scale",n*15)}${s("xChannelSelector","R")}${s("yChannelSelector","G")}${s("result",`${t}_disp`)}/>`,a+=`<feGaussianBlur${s("in",`${t}_disp`)}${s("stdDeviation",n*2)}${s("result",`${t}_blur`)}/>`,a+=`<feBlend${s("in",`${t}_blur`)}${s("in2",e)}${s("mode","multiply")}${s("result",t)}/>`,a}function As(r,e,t){let{thickness:n,texture:i}=r;if(n===0&&i===0)return D(e,t);let a="";a+=`<feTurbulence${s("type","turbulence")}${s("baseFrequency",.03+i*.02)}${s("numOctaves",3)}${s("seed",1e3)}${s("result",`${t}_brush`)}/>`;let o=Math.max(3,8-Math.floor(n*5)),l=Array.from({length:o+1},(u,c)=>c/o).join(" ");a+=`<feComponentTransfer${s("in",e)}${s("result",`${t}_poster`)}>`;for(let u of["R","G","B"])a+=`<feFunc${u}${s("type","discrete")}${s("tableValues",l)}/>`;return a+="</feComponentTransfer>",a+=`<feDisplacementMap${s("in",`${t}_poster`)}${s("in2",`${t}_brush`)}${s("scale",i*4)}${s("xChannelSelector","R")}${s("yChannelSelector","G")}${s("result",`${t}_disp`)}/>`,a+=`<feMorphology${s("in",`${t}_disp`)}${s("operator","dilate")}${s("radius",n*.5)}${s("result",`${t}_thick`)}/>`,a+=`<feComposite${s("in",`${t}_thick`)}${s("in2",e)}${s("operator","in")}${s("result",t)}/>`,a}function Ms(r,e,t){let{spread:n,edges:i}=r;if(n===0&&i===0)return D(e,t);let a="";return a+=`<feTurbulence${s("type","fractalNoise")}${s("baseFrequency",.01+i*.02)}${s("numOctaves",5)}${s("seed",1100)}${s("result",`${t}_ink`)}/>`,a+=`<feMorphology${s("in",e)}${s("operator","dilate")}${s("radius",n*3)}${s("result",`${t}_dilate`)}/>`,a+=`<feDisplacementMap${s("in",`${t}_dilate`)}${s("in2",`${t}_ink`)}${s("scale",i*10)}${s("xChannelSelector","R")}${s("yChannelSelector","G")}${s("result",`${t}_disp`)}/>`,a+=`<feGaussianBlur${s("in",`${t}_disp`)}${s("stdDeviation",n*.5)}${s("result",t)}/>`,a}function Fs(r,e,t){let{wrinkles:n,shine:i}=r;if(n===0&&i===0)return D(e,t);let a="";return a+=`<feTurbulence${s("type","turbulence")}${s("baseFrequency",.02)}${s("numOctaves",4)}${s("seed",1200)}${s("result",`${t}_wrinkle`)}/>`,a+=`<feDisplacementMap${s("in",e)}${s("in2",`${t}_wrinkle`)}${s("scale",n*15)}${s("xChannelSelector","R")}${s("yChannelSelector","G")}${s("result",`${t}_disp`)}/>`,a+=`<feSpecularLighting${s("in",`${t}_wrinkle`)}${s("surfaceScale",n*2)}${s("specularConstant",i*1.5)}${s("specularExponent",20)}${s("result",`${t}_sheen`)}>`,a+=`<feDistantLight${s("azimuth",45)}${s("elevation",60)}/>`,a+="</feSpecularLighting>",a+=`<feBlend${s("in",`${t}_disp`)}${s("in2",`${t}_sheen`)}${s("mode","screen")}${s("result",`${t}_blend`)}/>`,a+=`<feComposite${s("in",`${t}_blend`)}${s("in2",e)}${s("operator","in")}${s("result",t)}/>`,a}function Rs(r,e,t){let{density:n,size:i}=r;if(n===0)return D(e,t);let a="",o=1-n;a+=`<feTurbulence${s("type","turbulence")}${s("baseFrequency",.1/i)}${s("numOctaves",1)}${s("seed",1400)}${s("result",`${t}_hole`)}/>`,a+=`<feComponentTransfer${s("in",`${t}_hole`)}${s("result",`${t}_thresh`)}>`;for(let l of["R","G","B","A"])a+=`<feFunc${l}${s("type","linear")}${s("slope",10)}${s("intercept",-o*10+5)}/>`;a+="</feComponentTransfer>",a+=`<feComponentTransfer${s("in",`${t}_thresh`)}${s("result",`${t}_clamp`)}>`;for(let l of["R","G","B","A"])a+=`<feFunc${l}${s("type","table")}${s("tableValues","0 0 1 1")}/>`;return a+="</feComponentTransfer>",a+=`<feComposite${s("in",e)}${s("in2",`${t}_clamp`)}${s("operator","in")}${s("result",t)}/>`,a}function Cs(r,e,t){let{color:n,radius:i,intensity:a}=r;if(a===0||i===0)return D(e,t);let{r:o,g:l,b:u}=bt(n),c="";return c+=`<feColorMatrix${s("in",e)}${s("type","matrix")}${s("values","0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0")}${s("result",`${t}_alpha`)}/>`,c+=`<feGaussianBlur${s("in",`${t}_alpha`)}${s("stdDeviation",i/2)}${s("result",`${t}_blur`)}/>`,c+=`<feColorMatrix${s("in",`${t}_blur`)}${s("type","matrix")}${s("values",`0 0 0 0 ${o} 0 0 0 0 ${l} 0 0 0 0 ${u} 0 0 0 ${a} 0`)}${s("result",`${t}_color`)}/>`,c+=`<feMerge${s("result",t)}><feMergeNode${s("in",`${t}_color`)}/><feMergeNode${s("in",e)}/></feMerge>`,c}function Is(r,e,t){let{color:n,radius:i,intensity:a}=r;if(a===0||i===0)return D(e,t);let{r:o,g:l,b:u}=bt(n),c="";return c+=`<feColorMatrix${s("in",e)}${s("type","matrix")}${s("values","0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0")}${s("result",`${t}_alpha`)}/>`,c+=`<feMorphology${s("in",`${t}_alpha`)}${s("operator","erode")}${s("radius",i/4)}${s("result",`${t}_erode`)}/>`,c+=`<feComposite${s("in",`${t}_alpha`)}${s("in2",`${t}_erode`)}${s("operator","out")}${s("result",`${t}_edge`)}/>`,c+=`<feGaussianBlur${s("in",`${t}_edge`)}${s("stdDeviation",i/3)}${s("result",`${t}_blur`)}/>`,c+=`<feColorMatrix${s("in",`${t}_blur`)}${s("type","matrix")}${s("values",`0 0 0 0 ${o} 0 0 0 0 ${l} 0 0 0 0 ${u} 0 0 0 ${a*2} 0`)}${s("result",`${t}_color`)}/>`,c+=`<feComposite${s("in",`${t}_color`)}${s("in2",`${t}_alpha`)}${s("operator","in")}${s("result",`${t}_clipped`)}/>`,c+=`<feComposite${s("in",`${t}_clipped`)}${s("in2",e)}${s("operator","over")}${s("result",t)}/>`,c}function D(r,e){return`<feMerge${s("result",e)}><feMergeNode${s("in",r)}/></feMerge>`}function yt(r){switch(r.type){case"feBlend":return Ls(r);case"feColorMatrix":return Es(r);case"feComponentTransfer":return Ds(r);case"feComposite":return Bs(r);case"feConvolveMatrix":return Os(r);case"feDiffuseLighting":return Gs(r);case"feSpecularLighting":return zs(r);case"feDisplacementMap":return Us(r);case"feDropShadow":return Ns(r);case"feFlood":return Vs(r);case"feGaussianBlur":return Hs(r);case"feImage":return Ws(r);case"feMerge":return Xs(r);case"feMorphology":return js(r);case"feOffset":return Ys(r);case"feTile":return qs(r);case"feTurbulence":return Zs(r)}}function N(r){let e="";if(e+=s("in",r.in),e+=s("x",r.x),e+=s("y",r.y),e+=s("width",r.width),e+=s("height",r.height),e+=s("color-interpolation-filters",r.colorInterpolationFilters),e+=s("result",r.result),r.unknownAttrs){let t=Object.keys(r.unknownAttrs).sort();for(let n of t)e+=s(n,r.unknownAttrs[n])}return e}function V(r){return r.animations&&r.animations.length>0?r.animations.join(""):""}function Ls(r){let e=`<feBlend${N(r)}${s("in2",r.in2)}${s("mode",r.mode)}`;r.noComposite&&(e+=' no-composite="no-composite"');let t=V(r);return t?`${e}>${t}</feBlend>`:`${e}/>`}function Es(r){let e=`<feColorMatrix${N(r)}${s("type",r.matrixType)}${s("values",r.values)}`,t=V(r);return t?`${e}>${t}</feColorMatrix>`:`${e}/>`}function gt(r,e){if(!e)return"";let t=`feFunc${r}`;switch(e.type){case"identity":return`<${t} type="identity"/>`;case"table":case"discrete":return`<${t} type="${e.type}"${s("tableValues",e.tableValues.join(" "))}/>`;case"linear":return`<${t} type="linear"${s("slope",e.slope)}${s("intercept",e.intercept)}/>`;case"gamma":return`<${t} type="gamma"${s("amplitude",e.amplitude)}${s("exponent",e.exponent)}${s("offset",e.offset)}/>`}}function Ds(r){let e="";return e+=gt("R",r.funcR),e+=gt("G",r.funcG),e+=gt("B",r.funcB),e+=gt("A",r.funcA),e+=V(r),`<feComponentTransfer${N(r)}>${e}</feComponentTransfer>`}function Bs(r){let e=`<feComposite${N(r)}${s("in2",r.in2)}${s("operator",r.operator)}`;r.operator==="arithmetic"&&(e+=s("k1",r.k1),e+=s("k2",r.k2),e+=s("k3",r.k3),e+=s("k4",r.k4));let t=V(r);return t?`${e}>${t}</feComposite>`:`${e}/>`}function Os(r){let e=`<feConvolveMatrix${N(r)}`;e+=s("order",r.order),e+=s("kernelMatrix",r.kernelMatrix),e+=s("divisor",r.divisor),e+=s("bias",r.bias),e+=s("targetX",r.targetX),e+=s("targetY",r.targetY),e+=s("edgeMode",r.edgeMode),e+=s("kernelUnitLength",r.kernelUnitLength),r.preserveAlpha!==void 0&&(e+=s("preserveAlpha",r.preserveAlpha?"true":"false"));let t=V(r);return t?`${e}>${t}</feConvolveMatrix>`:`${e}/>`}function _n(r){switch(r.kind){case"feDistantLight":return`<feDistantLight${s("azimuth",r.azimuth)}${s("elevation",r.elevation)}/>`;case"fePointLight":return`<fePointLight${s("x",r.x)}${s("y",r.y)}${s("z",r.z)}/>`;case"feSpotLight":{let e=`<feSpotLight${s("x",r.x)}${s("y",r.y)}${s("z",r.z)}${s("pointsAtX",r.pointsAtX)}${s("pointsAtY",r.pointsAtY)}${s("pointsAtZ",r.pointsAtZ)}`;return e+=s("specularExponent",r.specularExponent),e+=s("limitingConeAngle",r.limitingConeAngle),e+"/>"}}}function Gs(r){let e=`<feDiffuseLighting${N(r)}`;e+=s("surfaceScale",r.surfaceScale),e+=s("diffuseConstant",r.diffuseConstant),e+=s("kernelUnitLength",r.kernelUnitLength),e+=s("lighting-color",r.lightingColor);let t="";return r.lightSource&&(t+=_n(r.lightSource)),t+=V(r),`${e}>${t}</feDiffuseLighting>`}function zs(r){let e=`<feSpecularLighting${N(r)}`;e+=s("surfaceScale",r.surfaceScale),e+=s("specularConstant",r.specularConstant),e+=s("specularExponent",r.specularExponent),e+=s("kernelUnitLength",r.kernelUnitLength),e+=s("lighting-color",r.lightingColor);let t="";return r.lightSource&&(t+=_n(r.lightSource)),t+=V(r),`${e}>${t}</feSpecularLighting>`}function Us(r){let e=`<feDisplacementMap${N(r)}`;e+=s("in2",r.in2),e+=s("scale",r.scale),e+=s("xChannelSelector",r.xChannelSelector),e+=s("yChannelSelector",r.yChannelSelector);let t=V(r);return t?`${e}>${t}</feDisplacementMap>`:`${e}/>`}function Ns(r){let e=`<feDropShadow${N(r)}`;e+=s("dx",r.dx),e+=s("dy",r.dy),e+=s("stdDeviation",r.stdDeviation),e+=s("flood-color",r.floodColor),e+=s("flood-opacity",r.floodOpacity);let t=V(r);return t?`${e}>${t}</feDropShadow>`:`${e}/>`}function Vs(r){let e=`<feFlood${N(r)}${s("flood-color",r.floodColor)}${s("flood-opacity",r.floodOpacity)}`,t=V(r);return t?`${e}>${t}</feFlood>`:`${e}/>`}function Hs(r){let e=`<feGaussianBlur${N(r)}${s("stdDeviation",r.stdDeviation)}${s("edgeMode",r.edgeMode)}`,t=V(r);return t?`${e}>${t}</feGaussianBlur>`:`${e}/>`}function Ws(r){let e=`<feImage${N(r)}`;r.href!==void 0?e+=s("href",r.href):r.xlinkHref!==void 0&&(e+=s("xlink:href",r.xlinkHref)),e+=s("preserveAspectRatio",r.preserveAspectRatio),e+=s("crossorigin",r.crossorigin);let t=V(r);return t?`${e}>${t}</feImage>`:`${e}/>`}function Xs(r){let e="";for(let t of r.nodes)e+=`<feMergeNode${s("in",t.in)}/>`;return e+=V(r),`<feMerge${N(r)}>${e}</feMerge>`}function js(r){let e=`<feMorphology${N(r)}${s("operator",r.operator)}${s("radius",r.radius)}`,t=V(r);return t?`${e}>${t}</feMorphology>`:`${e}/>`}function Ys(r){let e=`<feOffset${N(r)}${s("dx",r.dx)}${s("dy",r.dy)}`,t=V(r);return t?`${e}>${t}</feOffset>`:`${e}/>`}function qs(r){let e=`<feTile${N(r)}`,t=V(r);return t?`${e}>${t}</feTile>`:`${e}/>`}function Zs(r){let e=`<feTurbulence${N(r)}`;e+=s("baseFrequency",r.baseFrequency),e+=s("numOctaves",r.numOctaves),e+=s("seed",r.seed),e+=s("stitchTiles",r.stitchTiles),e+=s("type",r.turbulenceType);let t=V(r);return t?`${e}>${t}</feTurbulence>`:`${e}/>`}function Ar(r,e){let t=`<filter${s("id",r)}`;t+=s("x",e.x),t+=s("y",e.y),t+=s("width",e.width),t+=s("height",e.height),t+=s("filterUnits",e.filterUnits),t+=s("primitiveUnits",e.primitiveUnits),e.filterColorInterpolation&&e.filterColorInterpolation!=="auto"&&(t+=s("color-interpolation-filters",e.filterColorInterpolation)),t+=s("flood-color",e.floodColor),t+=s("flood-opacity",e.floodOpacity),t+=s("lighting-color",e.lightingColor),t+=">",e.filterTitle&&(t+=`<title>${O(e.filterTitle)}</title>`),e.filterDescription&&(t+=`<desc>${O(e.filterDescription)}</desc>`);for(let n of e.primitives)t+=yt(n);if(e.filterAnimations)for(let n of e.filterAnimations)t+=n;return t+="</filter>",t}function Mr(r,e,t,n){switch(r.type){case"drop-shadow":return Qi(r,e,t);case"inner-shadow":return Ji(r,e,t);case"gaussian-blur":return es(r,e,t);case"motion-blur":return ts(r,e,t);case"point-light":{let i=r;return Sn(n?{...i,x:i.x+n.x,y:i.y+n.y}:i,e,t)}case"spot-light":{let i=r;return kn(n?{...i,x:i.x+n.x,y:i.y+n.y,pointsAtX:i.pointsAtX+n.x,pointsAtY:i.pointsAtY+n.y}:i,e,t)}case"diffuse-lighting":return rs(r,e,t);case"specular-lighting":return ns(r,e,t);case"outline":return is(r,e,t);case"sharpen":return ss(r,e,t);case"pixelate":return as(r,e,t);case"warp":return os(r,e,t);case"morphology":return ls(r,e,t);case"contouring-discrete":return us(r,e,t);case"contouring-table":return cs(r,e,t);case"round-edges":return ds(r,e,t);case"grayscale":return fs(r,e,t);case"channel-painter":return hs(r,e,t);case"brightness":return ps(r,e,t);case"contrast":return ms(r,e,t);case"opacity":return gs(r,e,t);case"invert":return bs(r,e,t);case"hue-rotate":return ys(r,e,t);case"saturate":return $s(r,e,t);case"black-and-white":return xs(r,e,t);case"sepia":return Ss(r,e,t);case"duotone":return ks(r,e,t);case"xray":return vs(r,e,t);case"noise":return _s(r,e,t);case"emboss":return ws(r,e,t);case"film-grain":return Ps(r,e,t);case"watercolor":return Ts(r,e,t);case"gouache":return As(r,e,t);case"ink-blot":return Ms(r,e,t);case"crumpled-plastic":return Fs(r,e,t);case"riddled":return Rs(r,e,t);case"glow":return Cs(r,e,t);case"inner-glow":return Is(r,e,t);case"raw-svg":return r.svgContent;case"svg-primitive-chain":return r.primitives.map(yt).join("");default:return D(e,t)}}function Ks(r){return r.some(e=>e.type==="gaussian-blur"||e.type==="motion-blur"||e.type==="drop-shadow"||e.type==="inner-shadow"||e.type==="glow"||e.type==="inner-glow"||e.type==="outline"||e.type==="morphology"||e.type==="warp"||e.type==="svg-primitive-chain"&&e.primitives.some(t=>t.type==="feGaussianBlur"||t.type==="feDropShadow"||t.type==="feOffset"||t.type==="feMorphology"||t.type==="feDisplacementMap"||t.type==="feTurbulence"))}function Fr(r,e,t={}){let n=e.filter(k=>k.enabled);if(n.length===0)return"";let i=t.colorInterpolation&&t.colorInterpolation!=="auto"?s("color-interpolation-filters",t.colorInterpolation):"",a=n.find(k=>k.type==="raw-svg");if(a){let k=t.colorInterpolation&&t.colorInterpolation!=="auto"?t.colorInterpolation:a.colorInterpolationFilters,P=t.filterUnits??a.filterUnits,_=t.primitiveUnits??a.primitiveUnits,$=t.x??a.x,w=t.y??a.y,M=t.width??a.width,I=t.height??a.height;return`<filter${s("id",r)}${s("x",$)}${s("y",w)}${s("width",M)}${s("height",I)}${s("filterUnits",P)}${s("primitiveUnits",_)}${s("color-interpolation-filters",k)}${s("flood-color",a.floodColor)}${s("flood-opacity",a.floodOpacity)}${s("lighting-color",a.lightingColor)}>${a.svgContent}</filter>`}let o=n.find(k=>k.type==="svg-primitive-chain");if(o){let k={...o,x:t.x??o.x,y:t.y??o.y,width:t.width??o.width,height:t.height??o.height,filterUnits:t.filterUnits??o.filterUnits,primitiveUnits:t.primitiveUnits??o.primitiveUnits,filterColorInterpolation:t.colorInterpolation&&t.colorInterpolation!=="auto"?t.colorInterpolation:o.filterColorInterpolation};return Ar(r,k)}let l=n.some(k=>k.type==="gaussian-blur"&&k.quality==="high"||k.type==="motion-blur"&&k.quality==="high"),u=Ks(n),c=u?l?"-200%":"-100%":"-10%",f=u?l?"500%":"300%":"120%",d="",m="SourceGraphic",p=0;for(let k of n){let P=`result${p++}`;d+=Mr(k,m,P),m=P}let b=t.filterUnits??"objectBoundingBox",g=t.primitiveUnits??"userSpaceOnUse",y=t.x??c,S=t.y??c,v=t.width??f,x=t.height??f;return`<filter${s("id",r)}${s("x",y)}${s("y",S)}${s("width",v)}${s("height",x)}${s("filterUnits",b)}${s("primitiveUnits",g)}${i}>${d}</filter>`}function wn(r){let e="",t=new Set;for(let n of r){let i=n.state.filters;if(!i||i.length===0)continue;let a=i.filter(c=>c.enabled);if(a.length===0)continue;let o=n.state.filterLibraryIds,l=Array.isArray(o)&&o.length>0?o[0]:`filter-${n.id}`;if(t.has(l))continue;t.add(l);let u=n.state;e+=Fr(l,a,{colorInterpolation:u.filterColorInterpolation,filterUnits:u.filterUnits,primitiveUnits:u.primitiveUnits,x:u.filterX,y:u.filterY,width:u.filterWidth,height:u.filterHeight})}return e}function $t(r,e,t){return!e||e.length===0||e.filter(i=>i.enabled).length===0?"":Array.isArray(t)&&t.length>0?` filter="${t.map(a=>`url(#${O(a)})`).join(" ")}"`:` filter="url(#filter-${O(r)})"`}function Le(r,e,t,n){let i=n?.strokeWidth!=null?Math.max(.5,e*n.strokeWidth):Math.max(1,e/10);switch(r){case"stripes":return[{tag:"rect",attrs:{width:n?.strokeWidth!=null?Math.max(.01,Math.min(1,n.strokeWidth))*e:e/2,height:e,fill:t}}];case"dots":{let a=n?.dotRadius!=null?Math.max(.05,Math.min(.45,n.dotRadius)):.25;return[{tag:"circle",attrs:{cx:e/2,cy:e/2,r:e*a,fill:t}}]}case"grid":return[{tag:"path",attrs:{d:`M ${e} 0 L 0 0 0 ${e}`,fill:"none",stroke:t,"stroke-width":i}}];case"checkerboard":return[{tag:"rect",attrs:{width:e/2,height:e/2,fill:t}},{tag:"rect",attrs:{x:e/2,y:e/2,width:e/2,height:e/2,fill:t}}];case"diagonal":{let a=n?.strokeWidth!=null?Math.max(.5,e*n.strokeWidth):Math.max(1,e/5);return[{tag:"path",attrs:{d:`M 0 ${e} L ${e} 0`,stroke:t,"stroke-width":a}}]}case"crosshatch":return[{tag:"path",attrs:{d:`M 0 ${e} L ${e} 0 M 0 0 L ${e} ${e}`,stroke:t,"stroke-width":i}}];case"zigzag":{let a=n?.amplitude!=null?Math.max(.05,Math.min(.5,n.amplitude)):.25,o=e*a;return[{tag:"path",attrs:{d:`M 0 ${o} L ${e/4} 0 L ${e/2} ${o} L ${e*3/4} 0 L ${e} ${o}`,fill:"none",stroke:t,"stroke-width":i}}]}case"waves":{let a=n?.amplitude!=null?Math.max(.05,Math.min(.5,n.amplitude)):.25,o=e*a,l=e/2;return[{tag:"path",attrs:{d:`M 0 ${l} Q ${e/4} ${l-o} ${e/2} ${l} T ${e} ${l}`,fill:"none",stroke:t,"stroke-width":i}}]}case"triangles":{let a=e*.866;return[{tag:"path",attrs:{d:`M ${e/2} 0 L ${e} ${a} L 0 ${a} Z`,fill:"none",stroke:t,"stroke-width":i}}]}case"hexagons":{let a=e*.866;return[{tag:"path",attrs:{d:`M ${e*.25} 0 L ${e*.75} 0 L ${e} ${a*.5} L ${e*.75} ${a} L ${e*.25} ${a} L 0 ${a*.5} Z`,fill:"none",stroke:t,"stroke-width":i}}]}case"diamonds":return[{tag:"path",attrs:{d:`M ${e/2} 0 L ${e} ${e/2} L ${e/2} ${e} L 0 ${e/2} Z`,fill:"none",stroke:t,"stroke-width":i}}];case"circles":return[{tag:"circle",attrs:{cx:e/2,cy:e/2,r:e/3,fill:"none",stroke:t,"stroke-width":i}}];case"bricks":{let a=n?.strokeWidth!=null?Math.max(.5,e*n.strokeWidth):Math.max(1,e/15);return[{tag:"rect",attrs:{x:0,y:0,width:e,height:e/2,fill:"none",stroke:t,"stroke-width":a}},{tag:"rect",attrs:{x:-e/2,y:e/2,width:e,height:e/2,fill:"none",stroke:t,"stroke-width":a}},{tag:"rect",attrs:{x:e/2,y:e/2,width:e,height:e/2,fill:"none",stroke:t,"stroke-width":a}}]}case"herringbone":return[{tag:"path",attrs:{d:`M 0 0 L ${e/2} ${e/2} L 0 ${e} M ${e/2} ${e/2} L ${e} 0 M ${e/2} ${e/2} L ${e} ${e}`,fill:"none",stroke:t,"stroke-width":i}}];default:return[]}}function Qs(r){let e=Object.entries(r.attrs).map(([t,n])=>` ${t}="${n}"`).join("");return`<${r.tag}${e}/>`}function xt(r,e,t,n,i){let a=10*e,o="";o+=`<rect width="${a}" height="${a}" fill="${n}"/>`;let l=Le(r,a,t,i);for(let u of l)o+=Qs(u);return{svgContent:o,width:a,height:a}}var Ee="0 0 10 10",St=6,kt=6;function he(){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"}}}]}var Rr={"line-marker-arrow":"mkr-builtin-arrow","line-marker-open-arrow":"mkr-builtin-open-arrow","line-marker-circle":"mkr-builtin-circle","line-marker-diamond":"mkr-builtin-diamond","line-marker-square":"mkr-builtin-square"},Js={"mkr-builtin-arrow":"Arrow","mkr-builtin-open-arrow":"Open Arrow","mkr-builtin-circle":"Circle","mkr-builtin-diamond":"Diamond","mkr-builtin-square":"Square"};function Pn(){return he().map(r=>{let e=Rr[r.id]??r.id;return{kind:"marker",id:e,name:Js[e]??e,viewBox:Ee,refX:r.refX,refY:r.refY,markerWidth:6,markerHeight:6,markerUnits:"strokeWidth",orient:"auto-start-reverse",shapes:[],builtIn:!0}})}function h(r,e){return e==null||e===""?"":` ${r}="${O(String(e))}"`}var ea=[["fontVariant","font-variant"],["fontVariantLigatures","font-variant-ligatures"],["fontVariantPosition","font-variant-position"],["fontVariantCaps","font-variant-caps"],["fontVariantNumeric","font-variant-numeric"],["fontVariantEastAsian","font-variant-east-asian"]];function Cr(r){return ea.map(([e,t])=>{let n=typeof r[e]=="string"?String(r[e]).trim():"";return n?`${t}: ${n}`:""}).filter(Boolean).join("; ")}function Mn(r){let e=r.map(t=>(t??"").trim().replace(/;$/,"")).filter(Boolean).join("; ");return e?h("style",e):""}function ta(r){if(r&&typeof r=="object"){let e=r;return"dx"in e?{x:typeof e.x=="number"?e.x:null,y:typeof e.y=="number"?e.y:null,dx:typeof e.dx=="number"?e.dx:0,dy:typeof e.dy=="number"?e.dy:0,rotate:typeof e.rotate=="number"?e.rotate:0}:{x:null,y:null,dx:typeof e.x=="number"?e.x:0,dy:typeof e.y=="number"?e.y:0,rotate:typeof e.rotate=="number"?e.rotate:0}}return{x:null,y:null,dx:0,dy:0,rotate:0}}function Tn(r,e){let t=-1;for(let i=r.length-1;i>=0;i--)if(r[i][e]!==null){t=i;break}if(t<0)return[];let n=new Array(t+1);for(let i=0;i<=t;i++)n[i]=r[i][e]??0;return n}function An(r,e){let t=-1;for(let i=r.length-1;i>=0;i--)if(r[i][e]!==0){t=i;break}if(t<0)return[];let n=new Array(t+1);for(let i=0;i<=t;i++)n[i]=r[i][e];return n}function ra(r){if(r.length===0)return[];let e=r.length-1,t=r[e].rotate;for(;e>0&&r[e-1].rotate===t;)e--;if(e===0&&t===0)return[];let n=new Array(e+1);for(let i=0;i<=e;i++)n[i]=r[i].rotate;return n}function ae(r,e){return ge(r,e)}function na(r,e,t){return xr(r,e,t)}function ia(r){if(typeof r=="string"){let n=r.trim();return n.length>0?n:void 0}if(!r||typeof r!="object")return;let e=r,t=[];return e.underline&&t.push("underline"),e.strikethrough&&t.push("line-through"),e.overline&&t.push("overline"),t.length>0?t.join(" "):void 0}function sa(r){if(typeof r.strokeDasharray=="string")return r.strokeDasharray;let e=r.lineStyle??"solid",t=r.dashLength??8,n=r.gapLength??4;return $e(e,t,n)}function aa(r){let e=r.fillType;return e||(r.fillGradient?r.fillGradient.r!==void 0?"radial-gradient":"linear-gradient":r.linearGradient?"linear-gradient":r.radialGradient?"radial-gradient":"solid")}function oa(r){return r.fillGradient??r.linearGradient??r.radialGradient??void 0}function ne(r,e){let t=h("data-shape-id",e),n=aa(r),i=oa(r);if(n==="none")t+=h("fill","none");else if(n==="linear-gradient"||n==="radial-gradient"){let w=r.fillLibraryId??i?.id;t+=h("fill",`url(#${w??`gradient-fill-${e}`})`)}else if(n==="pattern"){let w=r.fillLibraryId??i?.id;t+=h("fill",`url(#${w??`pattern-fill-${e}`})`)}else t+=h("fill",r.fillColor??"#000000");let a=r.opacity;a!==void 0&&a<1&&(t+=h("opacity",a));let o=r.fillOpacity;o!==void 0&&o<1&&(t+=h("fill-opacity",o));let l=r.fillRule;l&&l!=="nonzero"&&(t+=h("fill-rule",l));let u=r.strokeType??"solid",c=r.strokeGradient;if(u==="none")t+=h("stroke","none");else if(u==="linear-gradient"||u==="radial-gradient"){let w=r.strokeLibraryId??c?.id;t+=h("stroke",`url(#${w??`gradient-stroke-${e}`})`)}else if(u==="pattern"){let w=r.strokeLibraryId??c?.id;t+=h("stroke",`url(#${w??`pattern-stroke-${e}`})`)}else t+=h("stroke",r.borderColor??"none");let f=r.borderWidth;f!=null&&(t+=h("stroke-width",f));let d=r.strokeOpacity;d!==void 0&&d<1&&(t+=h("stroke-opacity",d));let m=r.paintOrder;m&&m!=="normal"&&(t+=h("paint-order",m));let p=r.markerStart,b=r.markerMid,g=r.markerEnd;p&&(t+=h("marker-start",`url(#${p})`)),b&&(t+=h("marker-mid",`url(#${b})`)),g&&(t+=h("marker-end",`url(#${g})`));let y=sa(r);y&&(t+=h("stroke-dasharray",y),!r.strokeDasharray&&r.lineStyle==="dotted"&&(t+=h("stroke-linecap","round")));let S=r.dashOffset;S!==void 0&&S!==0&&(t+=h("stroke-dashoffset",S));let v=r.shapeRendering;v&&v!=="auto"&&(t+=h("shape-rendering",v)),t+=$t(e,r.filters,r.filterLibraryIds);let x=r.systemLanguage;x&&(t+=h("systemLanguage",x));let k=r.requiredExtensions;k&&(t+=h("requiredExtensions",k));let P=r.vectorEffect;P&&P!=="none"&&(t+=h("vector-effect",P));let _=r.visibility;_&&_!=="visible"&&(t+=h("visibility",_));let $=r.metadata;return $&&($.role&&(t+=h("role",$.role)),$.ariaLabel&&(t+=h("aria-label",$.ariaLabel))),t}function la(r){let e=r.metadata;if(!e)return"";let t="";return e.title&&(t+=`<title>${O(e.title)}</title>`),e.description&&(t+=`<desc>${O(e.description)}</desc>`),t}function ua(r,e){let t=la(e);if(!t)return r;let n=r.lastIndexOf("/>");if(n===-1){let o=r.indexOf(">");return o===-1?r:r.slice(0,o+1)+t+r.slice(o+1)}let i=r.match(/^<(\w+)/),a=i?i[1]:"g";return r.slice(0,n)+">"+t+`</${a}>`}function Ir(r){let e="",t=r.startEndpoint,n=r.endEndpoint;return t&&t!=="none"&&(e+=h("marker-start",`url(#line-marker-${t})`)),n&&n!=="none"&&(e+=h("marker-end",`url(#line-marker-${n})`)),e}function Lr(r){let e=r.state,t=e.x??0,n=e.y??0,i=e.radius??50,a=ae(e,{x:t,y:n});return`<circle${h("cx",t)}${h("cy",n)}${h("r",i)}${ne(e,r.id)}${a?h("transform",a):""}/>`}function Er(r){let e=r.state,t=e.cx??0,n=e.cy??0,i=e.rx??50,a=e.ry??30,o=e.pathLength,l=ae(e,{x:t,y:n});return`<ellipse${h("cx",t)}${h("cy",n)}${h("rx",i)}${h("ry",a)}${o!==void 0?h("pathLength",o):""}${ne(e,r.id)}${l?h("transform",l):""}/>`}function Dr(r){let e=r.state,t=e,n=e.x??0,i=e.y??0,a=e.width??100,o=e.height??100,l=e.cornerRadius??0,u=e.rx??l,c=e.ry??l,f=t.cornerShape??"round",d=t.cornerMode??"uniform",m={x:n+a/2,y:i+o/2},p=ae(e,m);if(f!=="round"||d==="non-uniform"){let b=pt(n,i,a,o,l,f,d,d==="non-uniform"?{radiusTL:t.cornerRadiusTL,radiusTR:t.cornerRadiusTR,radiusBR:t.cornerRadiusBR,radiusBL:t.cornerRadiusBL,shapeTL:t.cornerShapeTL,shapeTR:t.cornerShapeTR,shapeBR:t.cornerShapeBR,shapeBL:t.cornerShapeBL}:void 0);if(b)return`<path${h("d",b)}${ne(e,r.id)}${p?h("transform",p):""}/>`}return`<rect${h("x",n)}${h("y",i)}${h("width",a)}${h("height",o)}${u>0||c>0?`${h("rx",u)}${h("ry",c)}`:""}${ne(e,r.id)}${p?h("transform",p):""}/>`}function Br(r){let e=r.state,t=e.x1??0,n=e.y1??0,i=e.x2??0,a=e.y2??0,o={x:(t+i)/2,y:(n+a)/2},l=ae(e,o),u={...e,fillType:"none"};return`<line${h("x1",t)}${h("y1",n)}${h("x2",i)}${h("y2",a)}${ne(u,r.id)}${Ir(e)}${l?h("transform",l):""}/>`}function Or(r){let e=r.state,t=e.x??0,n=e.y??0,i=e.text??"",a=e.fontSize??16,o=e.fontFamily??"sans-serif",l=e.fontWeight??"normal",u=e.fontStyle??"normal",c=e.textAnchor??"start",f=ia(e.textDecoration),d=e.letterSpacing,p=ae(e,{x:t,y:n}),b=h("x",t)+h("y",n);b+=h("font-size",a),b+=h("font-family",o),l!=="normal"&&(b+=h("font-weight",l)),u!=="normal"&&(b+=h("font-style",u)),c!=="start"&&(b+=h("text-anchor",c)),f&&(b+=h("text-decoration",f)),d&&(b+=h("letter-spacing",d));let g=e.textLength;g!==void 0&&g>0&&(b+=h("textLength",g),e.lengthAdjust==="spacingAndGlyphs"&&(b+=h("lengthAdjust","spacingAndGlyphs")));let y=e.textDirection;y&&y!=="ltr"&&(b+=h("direction",y));let S=e.unicodeBidi;S&&S!=="normal"&&(b+=h("unicode-bidi",S));let v=Cr(e),x=e.fontVariationSettings,k="";if(x&&Object.keys(x).length>0&&(k=`font-variation-settings: ${Object.entries(x).map(([$,w])=>`'${$}' ${w}`).join(", ")}`),b+=Mn([v,k]),b+=ne(e,r.id),p&&(b+=h("transform",p)),e.isTextPath&&e.textPathPoints){let _=e.textPathPoints,$=e.textPathStartOffset??0,w=e.textPathSide,M=`text-path-${r.id}`,I="";if(_.length>=2)if(w==="right"){let R=_[_.length-1];I=`M ${R.x} ${R.y}`;for(let C=_.length-1;C>0;C--){let L=_[C],E=_[C-1],B=L.handleIn??L,A=E.handleOut??E;I+=` C ${B.x} ${B.y}, ${A.x} ${A.y}, ${E.x} ${E.y}`}}else{I=`M ${_[0].x} ${_[0].y}`;for(let R=0;R<_.length-1;R++){let C=_[R],L=_[R+1],E=C.handleOut??C,B=L.handleIn??L;I+=` C ${E.x} ${E.y}, ${B.x} ${B.y}, ${L.x} ${L.y}`}}return`<defs><path id="${O(M)}"${h("d",I)} fill="none"/></defs><text${b}><textPath href="#${O(M)}"${h("startOffset",`${$}%`)}>${O(i)}</textPath></text>`}if(e.charOffsets&&Array.isArray(e.charOffsets)&&e.charOffsets.length>0){let _=e.charOffsets.map(ta),$=i.split(`
7
+ `),w=e.linePositions??[],M=a*1.25,I="",R=0;return $.forEach((C,L)=>{let E=Array.from(C).length,B=_.slice(R,R+E),A=w[L],G=A?t+A.x:L>0?t:NaN,q=A?A.dy:L>0?M:NaN,W="",de=Tn(B,"x");if(Number.isFinite(G)||de.length>0){let fr=de.length>0?de.slice():[];Number.isFinite(G)&&(fr[0]=fr[0]??G),W+=h("x",fr.join(" "))}let ee=Tn(B,"y");ee.length>0&&(W+=h("y",ee.join(" ")));let Y=An(B,"dx");Y.length>0&&(W+=h("dx",Y.join(" ")));let Ue=An(B,"dy"),Z=Ue.length>0||Number.isFinite(q)?Ue.slice():[];for(Number.isFinite(q)&&(Z[0]=(Z[0]??0)+q);Z.length>0&&Z[Z.length-1]===0;)Z.pop();Z.length>0&&(W+=h("dy",Z.join(" ")));let on=ra(B);on.length>0&&(W+=h("rotate",on.join(" "))),I+=`<tspan${W}>${O(C)}</tspan>`,R+=E+1}),`<text${b}>${I}</text>`}if(e.richTextData&&typeof e.richTextData=="object"){let _=e.richTextData;if(Array.isArray(_.lines)&&_.lines.length>0){let $=e.linePositions,w=typeof _.lineHeight=="number"?_.lineHeight:1.2,M=a*w,I=_.baseStyle??{},R="";return _.lines.forEach((C,L)=>{C.segments.forEach((E,B)=>{let A="";if(B===0){let G=$?.[L];G?((Math.abs(G.x)>.001||L>0)&&(A+=h("x",t+G.x)),(Math.abs(G.dy)>.001||L>0)&&(A+=h("dy",G.dy))):L>0&&(A+=h("x",t),A+=h("dy",`${M}px`))}A+=ca(E.style??{},I),A+=' xml:space="preserve"',R+=`<tspan${A}>${O(E.text)}</tspan>`})}),`<text${b}>${R}</text>`}}return`<text${b}>${O(i)}</text>`}function ca(r,e){let t="";r.fontFamily!==void 0&&r.fontFamily!==e.fontFamily&&(t+=h("font-family",String(r.fontFamily))),r.fontSize!==void 0&&r.fontSize!==e.fontSize&&(t+=h("font-size",String(r.fontSize))),r.fontWeight!==void 0&&r.fontWeight!==e.fontWeight&&(t+=h("font-weight",String(r.fontWeight))),r.fontStyle!==void 0&&r.fontStyle!==e.fontStyle&&(t+=h("font-style",String(r.fontStyle)));let n=Cr(r);n&&n!==Cr(e)&&(t+=Mn([n]));let i=r.textDecoration,a=e.textDecoration;if(i&&(!a||i.underline!==a.underline||i.strikethrough!==a.strikethrough||i.overline!==a.overline)){let l=[];i.underline&&l.push("underline"),i.strikethrough&&l.push("line-through"),i.overline&&l.push("overline"),l.length>0&&(t+=h("text-decoration",l.join(" ")))}if(r.baselineShift!==void 0&&r.baselineShift!==e.baselineShift){let o=r.baselineShift;o==="super"||o==="sub"?t+=h("baseline-shift",o):typeof o=="number"&&(t+=h("baseline-shift",`${o}px`))}return r.letterSpacing!==void 0&&r.letterSpacing!==e.letterSpacing&&(t+=h("letter-spacing",String(r.letterSpacing))),r.fill!==void 0&&r.fill!==e.fill&&(t+=h("fill",String(r.fill))),r.fillOpacity!==void 0&&r.fillOpacity!==e.fillOpacity&&(t+=h("fill-opacity",String(r.fillOpacity))),r.direction!==void 0&&r.direction!==e.direction&&(t+=h("direction",String(r.direction))),r.unicodeBidi!==void 0&&r.unicodeBidi!==e.unicodeBidi&&(t+=h("unicode-bidi",String(r.unicodeBidi))),t}function Gr(r){let e=r.state,t=e.pathPoints??[],n=e.pathCurveType??"CUBIC",i=e.pathClosed??!1,a=e.pathTension??.5,o=e.pathArcParams,l=ye(t,n,i,a,o),u=t.length>0?e.customPivot??{x:t[0].x,y:t[0].y}:void 0,c=u?ae(e,u):null;return`<path${h("d",l)}${ne(e,r.id)}${Ir(e)}${c?h("transform",c):""}/>`}function zr(r){let e=r.state,t=e.polylinePoints??[],n=e.polylineClosed??!1,i=t.map(u=>`${u.x},${u.y}`).join(" "),a=t.length>0?e.customPivot??{x:t[0].x,y:t[0].y}:void 0,o=a?ae(e,a):null;return`<${n?"polygon":"polyline"}${h("points",i)}${ne(e,r.id)}${Ir(e)}${o?h("transform",o):""}/>`}function Ur(r){let e=r.state,t=e.x??0,n=e.y??0,i=e.width??100,a=e.height??100,o=e.href??"",l=e.imageOpacity,u=e.preserveAspectRatio?"xMidYMid meet":"none",c={x:t+i/2,y:n+a/2},f=ae(e,c);return`<image${h("x",t)}${h("y",n)}${h("width",i)}${h("height",a)}${h("href",o)}${h("preserveAspectRatio",u)}${l!==void 0&&l<1?h("opacity",l):""}${ne(e,r.id)}${f?h("transform",f):""}/>`}function vt(r){return!r||r.length===0?"":r.map(e=>H(e)).join("")}function da(r){let e=r.state,t=e.href,n=e.hrefXlink,i="<a";return t!==void 0&&(i+=h("href",t)),n!==void 0&&(i+=h("xlink:href",n)),i+=h("target",e.linkTarget),i+=h("rel",e.linkRel),i+=h("download",e.linkDownload),i+=h("ping",e.linkPing),i+=h("hreflang",e.linkHreflang),i+=h("type",e.linkType),i+=h("referrerpolicy",e.linkReferrerPolicy),i+=h("data-shape-id",r.id),i+=">",i+=vt(e.children),i+="</a>",i}function fa(r){let e=r.state,t="<switch";return t+=h("data-shape-id",r.id),t+=">",t+=vt(e.children),t+="</switch>",t}function ha(r){let e=r.state,t=ae(e),n="<g";return n+=h("data-shape-id",r.id),t&&(n+=h("transform",t)),e.opacity!==void 0&&e.opacity<1&&(n+=h("opacity",e.opacity)),e.visibility&&(n+=h("visibility",e.visibility)),e.blendMode&&(n+=h("style",`mix-blend-mode:${e.blendMode}`)),n+=">",n+=vt(e.children),n+="</g>",n}function pa(r){let e=r.state,t=e.viewBoxX,n=e.viewBoxY,i=e.viewBoxWidth,a=e.viewBoxHeight,o=t!==void 0&&n!==void 0&&i!==void 0&&a!==void 0?`${t} ${n} ${i} ${a}`:void 0,l="<view";return l+=h("id",r.id),l+=h("viewBox",o),l+=h("preserveAspectRatio",e.viewPreserveAspectRatio),l+=h("zoomAndPan",e.viewZoomAndPan),l+=h("viewTarget",e.viewTarget),e.viewName&&(l+=h("data-view-name",e.viewName)),l+="/>",l}function ma(r){let e=r.state,t=e.svgX,n=e.svgY,i=e.svgWidth,a=e.svgHeight,o=e.svgViewBoxX,l=e.svgViewBoxY,u=e.svgViewBoxWidth,c=e.svgViewBoxHeight,f=o!==void 0&&l!==void 0&&u!==void 0&&c!==void 0?`${o} ${l} ${u} ${c}`:void 0,d="<svg";return d+=h("xmlns","http://www.w3.org/2000/svg"),d+=h("x",t),d+=h("y",n),d+=h("width",i),d+=h("height",a),d+=h("viewBox",f),d+=h("preserveAspectRatio",e.svgPreserveAspectRatio),d+=h("data-shape-id",r.id),d+=">",d+=vt(e.children),d+="</svg>",d}function ga(r){let e=r.state,t=e.targetShapeId;if(!t)return`<!-- shape-reference ${O(r.id)} has no targetShapeId -->`;let n=e.offsetX??0,i=e.offsetY??0,a="<use";return a+=h("href",`#${t}`),a+=h("x",n),a+=h("y",i),e.width!==void 0&&(a+=h("width",e.width)),e.height!==void 0&&(a+=h("height",e.height)),a+=h("data-shape-id",r.id),e.opacity!==void 0&&e.opacity<1&&(a+=h("opacity",e.opacity)),a+="/>",a}function ba(r){let e=r.state,t=e.mediaKind??r.type,n=e.x??0,i=e.y??0,a=e.width??320,o=e.height??180,l=e.href??"",u=e.mediaMimeType,c=e.posterHref,f=e.mediaOpacity,d=`<${t} xmlns="http://www.w3.org/1999/xhtml"`;d+=h("src",l),u&&(d+=h("type",u)),c&&t==="video"&&(d+=h("poster",c)),e.muted&&(d+=' muted=""'),e.loop&&(d+=' loop=""'),e.playbackRate!==void 0&&(d+=h("data-playback-rate",e.playbackRate)),e.volume!==void 0&&(d+=h("data-volume",e.volume)),d+=' preload="auto" playsinline=""',d+=t==="video"?' style="width:100%;height:100%;display:block;"></video>':"></audio>";let m="<foreignObject";return m+=h("x",n),m+=h("y",i),m+=h("width",a),m+=h("height",o),m+=h("data-shape-id",r.id),m+=h("data-media-kind",t),e.naturalDuration!==void 0&&(m+=h("data-natural-duration",e.naturalDuration)),e.begin!==void 0&&(m+=h("data-begin",e.begin)),e.trimStart!==void 0&&(m+=h("data-trim-start",e.trimStart)),e.trimEnd!==void 0&&(m+=h("data-trim-end",e.trimEnd)),e.fadeInDuration!==void 0&&(m+=h("data-fade-in",e.fadeInDuration)),e.fadeOutDuration!==void 0&&(m+=h("data-fade-out",e.fadeOutDuration)),e.systemLanguage&&(m+=h("systemLanguage",e.systemLanguage)),e.requiredExtensions&&(m+=h("requiredExtensions",e.requiredExtensions)),f!==void 0&&f<1&&(m+=h("opacity",f)),m+=">",m+=d,m+="</foreignObject>",m}function Nr(r){let e=r.state,t=e.cx??0,n=e.cy??0,i=e.radius??50,a=e.cornerRadius??0,o=e.shiftAngle??-90,l=e.fillRule??"nonzero",u=na(e,t,n),c="";switch(r.type){case"triangle":c=J(Ie(3,i,o),a,i);break;case"ngon":{let d=e.sides??6;c=J(Ie(d,i,o),a,i);break}case"star":{let d=e.arms??5,m=e.innerRadiusPercent??50;c=J(it(d,i,m,o),a,i);break}case"cross":{let d=e.armWidthPercent??40;c=J(st(i,d,o),a,i);break}case"ring":{let d=e.innerRadiusPercent??50;c=dt(i,d,l);break}case"spiral":{let d=e.turns??3,m=e.thicknessPercent??20,p=e.spiralDirection??1;c=ft(i,d,m,p,o);break}case"gear":{let d=e.teeth??8,m=e.toothDepthPercent??30,p=e.holeRadiusPercent??0;c=ht(d,i,m,a,p,l,o);break}case"arrow":{let d=e.headWidthPercent??100,m=e.headLengthPercent??30,p=e.shaftWidthPercent??40;c=J(at(i,d,m,p,o),a,i);break}case"speechBubble":{let d=e.tailAngleDeg??45,m=e.tailLengthPercent??40,p=e.tailWidthPercent??25;c=J(ot(i,d,m,p,o),a,i);break}case"lightning":{let d=e.boltSegments??3,m=e.boltJaggednessPercent??40,p=e.boltWidthPercent??30;c=J(lt(i,d,m,p,o),a,i);break}case"heart":{let d=e.lobeRadiusPercent??50,m=e.cleftDepthPercent??25;c=ut(i,d,m,o);break}case"cloud":{let d=e.cloudBumps??5,m=e.cloudPuffinessPercent??60;c=ct(i,d,m,o);break}default:return`<!-- unsupported polygon shape: ${O(r.type)} -->`}let f="";return(r.type==="ring"||r.type==="gear")&&(f=h("fill-rule",l)),`<path${h("d",c)}${f}${ne(e,r.id)}${h("transform",u)}/>`}function H(r){let e;switch(r.type){case"circle":e=Lr(r);break;case"ellipse":e=Er(r);break;case"rectangle":case"square":e=Dr(r);break;case"line":e=Br(r);break;case"text":e=Or(r);break;case"path":e=Gr(r);break;case"polyline":e=zr(r);break;case"image":e=Ur(r);break;case"triangle":case"ngon":case"star":case"cross":case"ring":case"spiral":case"gear":case"arrow":case"speechBubble":case"lightning":case"heart":case"cloud":e=Nr(r);break;case"hyperlink":e=da(r);break;case"switch":e=fa(r);break;case"container":case"group":e=ha(r);break;case"view":e=pa(r);break;case"svg":e=ma(r);break;case"shape-reference":e=ga(r);break;case"audio":case"video":e=ba(r);break;default:return`<!-- unsupported shape type: ${O(r.type)} -->`}return ua(e,r.state)}function Fn(r,e){let t=(e.stops??[]).map(o=>{let l=`<stop${h("offset",`${o.offset*100}%`)}${h("stop-color",o.color)}`;return o.opacity!==void 0&&o.opacity<1&&(l+=h("stop-opacity",o.opacity)),l+="/>",l}).join(""),n=e.gradientUnits==="userSpaceOnUse",i=o=>n?String(o):`${o*100}%`,a=n?h("gradientUnits","userSpaceOnUse"):"";return`<linearGradient${h("id",r)}${a}${h("x1",i(e.x1))}${h("y1",i(e.y1))}${h("x2",i(e.x2))}${h("y2",i(e.y2))}${e.spreadMethod?h("spreadMethod",e.spreadMethod):""}>${t}</linearGradient>`}function Rn(r,e){let t=(e.stops??[]).map(f=>{let d=`<stop${h("offset",`${f.offset*100}%`)}${h("stop-color",f.color)}`;return f.opacity!==void 0&&f.opacity<1&&(d+=h("stop-opacity",f.opacity)),d+="/>",d}).join(""),n=e.gradientUnits==="userSpaceOnUse",i=f=>n?String(f):`${f*100}%`,a=n?h("gradientUnits","userSpaceOnUse"):"",o="",l=e.ry!==void 0&&e.ry!==e.r,u=!!e.rotation;if(l||u){let f=e.cx??(n?0:.5),d=e.cy??(n?0:.5),m=[];m.push(`translate(${f}, ${d})`),u&&m.push(`rotate(${e.rotation})`),l&&e.ry!==0&&m.push(`scale(1, ${e.ry/e.r})`),m.push(`translate(-${f}, -${d})`),o=h("gradientTransform",m.join(" "))}let c=e.fr!==void 0&&e.fr>0?h("fr",i(e.fr)):"";return`<radialGradient${h("id",r)}${a}${h("cx",i(e.cx))}${h("cy",i(e.cy))}${h("fx",i(e.fx))}${h("fy",i(e.fy))}${h("r",i(e.r))}${c}${e.spreadMethod?h("spreadMethod",e.spreadMethod):""}${o}>${t}</radialGradient>`}function Cn(r,e){if(e.svgContent!=null){let l=e.width??10,u=e.height??10,c=e.patternUnits??"userSpaceOnUse",f=e.patternContentUnits,d=e.patternTransform,m=e.viewBox,p=e.preserveAspectRatio,b=e.x??0,g=e.y??0,y=`<pattern${h("id",r)}`;return y+=h("patternUnits",c),f&&(y+=h("patternContentUnits",f)),b&&(y+=h("x",b)),g&&(y+=h("y",g)),y+=h("width",l),y+=h("height",u),m&&(y+=h("viewBox",m)),p&&(y+=h("preserveAspectRatio",p)),d&&(y+=h("patternTransform",d)),y+=`>${e.svgContent}</pattern>`,y}let t=10*(e.scale??1),n=e.rotation??0,i=e.color||"#000000",a=e.backgroundColor||"#ffffff",o="";return o+=`<rect${h("width",t)}${h("height",t)}${h("fill",a)}/>`,o+=ya(e.patternType,t,i),`<pattern${h("id",r)}${h("patternUnits","userSpaceOnUse")}${h("width",t)}${h("height",t)}${n?h("patternTransform",`rotate(${n})`):""}>${o}</pattern>`}function ya(r,e,t){return Le(r,e,t).map(i=>{let a=Object.entries(i.attrs).map(([o,l])=>h(o,l)).join("");return`<${i.tag}${a}/>`}).join("")}function $a(r){let e=new Set,t=new Set;for(let n of r){let i=n.state;i.markerStart&&e.add(i.markerStart),i.markerMid&&e.add(i.markerMid),i.markerEnd&&e.add(i.markerEnd);let a=i.startEndpoint,o=i.endEndpoint;a&&a!=="none"&&t.add(a),o&&o!=="none"&&t.add(o)}return{ids:e,legacyEndpoints:t}}function ie(r){let e=Array.isArray(r)?$a(r):r;if(e.ids.size===0&&e.legacyEndpoints.size===0)return"";let t="",n=he();for(let i of n){let a=i.id,o=a.replace("line-marker-",""),l=`mkr-builtin-${o}`,u=e.legacyEndpoints.has(o)||e.ids.has(a),c=e.ids.has(l);if(!u&&!c)continue;let f=i.element,d=Object.entries(f.attrs).map(([b,g])=>h(b,g)).join(""),m=`<${f.tag}${d}/>`,p=b=>{t+=`<marker${h("id",b)}${h("viewBox",Ee)}${h("refX",i.refX)}${h("refY",i.refY)}${h("markerWidth",6)}${h("markerHeight",6)}${h("orient","auto-start-reverse")}>${m}</marker>`};u&&p(a),c&&p(l)}return t}var oe=r=>r.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;"),Vr=["linear-gradient","radial-gradient","pattern","filter","marker","symbol"];function Hr(r){switch(r.kind){case"symbol":return Wr(r);case"marker":return Xr(r);case"linear-gradient":return jr(r);case"radial-gradient":return Yr(r);case"pattern":return qr(r);case"filter":return Zr(r)}}function Wr(r){let e=r.shapes.map(i=>H(i)).join(""),t=r.viewBox?` viewBox="${oe(r.viewBox)}"`:"",n=r.overflow?` overflow="${oe(r.overflow)}"`:"";return`<symbol id="${oe(r.id)}"${t}${n}>${e}</symbol>`}function Xr(r){let e;if(r.builtIn){let a=he().find(o=>r.id.includes(o.id)||r.id===o.id);if(a){let o=Object.entries(a.element.attrs).map(([l,u])=>` ${l}="${oe(String(u))}"`).join("");e=`<${a.element.tag}${o}/>`}else e=""}else e=r.shapes.map(a=>H(a)).join("");let t=typeof r.orient=="number"?String(r.orient):r.orient,n=r.viewBox?` viewBox="${oe(r.viewBox)}"`:"",i=r.overflow?` overflow="${oe(r.overflow)}"`:"";return`<marker id="${oe(r.id)}"${n} refX="${r.refX}" refY="${r.refY}" markerWidth="${r.markerWidth}" markerHeight="${r.markerHeight}" markerUnits="${oe(r.markerUnits)}" orient="${oe(t)}"${i}>${e}</marker>`}function jr(r){let e={...r.gradient,type:"linear-gradient",id:r.id};return Fn(r.id,e)}function Yr(r){let e={...r.gradient,type:"radial-gradient",id:r.id};return Rn(r.id,e)}function qr(r){let e={...r.pattern,type:"pattern",id:r.id};return Cn(r.id,e)}function Zr(r){return Fr(r.id,r.filters,{colorInterpolation:r.colorInterpolation,filterUnits:r.filterUnits,primitiveUnits:r.primitiveUnits,x:r.x,y:r.y,width:r.width,height:r.height})}function Kr(r){let e=new Map;for(let n of r){let i=e.get(n.kind);i?i.push(n):e.set(n.kind,[n])}let t="";for(let n of Vr){let i=e.get(n);if(i)for(let a of i)t+=Hr(a)}return t}function In(r){let e=new Set,t=n=>{typeof n=="string"&&n&&e.add(n)};for(let n of r){let i=n.state;if(!i)continue;t(i.fillLibraryId),t(i.strokeLibraryId),t(i.markerStart),t(i.markerMid),t(i.markerEnd),t(i.symbolId);let a=i.filterLibraryIds;if(Array.isArray(a))for(let o of a)t(o)}return e}function se(r,e){let t=new Map;for(let l of e)t.set(l.id,l);let n=new Map,i=l=>{if(!l)return;let u=t.get(l);u&&n.set(l,u)},a=(l,u)=>{if(!l||typeof l!="object")return;let c=l;if(!c.id||n.has(c.id))return;let f=u==="linear-gradient"?"linear-gradient":u==="radial-gradient"?"radial-gradient":u==="pattern"?"pattern":null;if(!f)return;let{id:d,sourceId:m,...p}=l,b;if(f==="linear-gradient")b={kind:"linear-gradient",id:c.id,name:m??c.id,sourceId:m,gradient:p};else if(f==="radial-gradient")b={kind:"radial-gradient",id:c.id,name:m??c.id,sourceId:m,gradient:p};else{let{customPatternId:g,...y}=p;b={kind:"pattern",id:c.id,name:m??c.id,sourceId:m,pattern:y}}n.set(c.id,b)},o=(l,u)=>{let c=l.filters;if(!Array.isArray(c)||c.length===0)return;let f=`filter-${u}`;n.has(f)||n.set(f,{kind:"filter",id:f,name:f,filters:c,...l.filterColorInterpolation&&l.filterColorInterpolation!=="auto"?{colorInterpolation:l.filterColorInterpolation}:{},...l.filterUnits?{filterUnits:l.filterUnits}:{},...l.primitiveUnits?{primitiveUnits:l.primitiveUnits}:{},...typeof l.filterX=="string"?{x:l.filterX}:{},...typeof l.filterY=="string"?{y:l.filterY}:{},...typeof l.filterWidth=="string"?{width:l.filterWidth}:{},...typeof l.filterHeight=="string"?{height:l.filterHeight}:{}})};for(let l of r){let u=l.state;if(!u)continue;i(u.fillLibraryId),i(u.strokeLibraryId),i(u.markerStart),i(u.markerMid),i(u.markerEnd),i(u.symbolId);let c=u.filterLibraryIds;if(Array.isArray(c))for(let f of c)typeof f=="string"&&i(f);u.fillLibraryId||a(u.fillGradient,u.fillType),u.strokeLibraryId||a(u.strokeGradient,u.strokeType),(!Array.isArray(c)||c.length===0)&&o(u,l.id)}return n.size===0?"":Kr(Array.from(n.values()))}var xa={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",pathLength:"pathLength",svgX:"x",svgY:"y",svgWidth:"width",svgHeight:"height",opacity:"opacity",fillOpacity:"fill-opacity",strokeOpacity:"stroke-opacity",fillColor:"fill",strokeColor:"stroke",strokeWidth:"stroke-width",borderWidth:"stroke-width",cornerRadius:"rx",fontSize:"font-size",letterSpacing:"letter-spacing",wordSpacing:"word-spacing",textLength:"textLength",d:"d",polylinePoints:"points"},Sa=new Set(["transformMatrix","rotation","skewX","skewY"]);function ka(r){let t=Ne[r];return t?t.join(" "):"0 0 1 1"}function xe(r){return r.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function Qr(r){return r.cycleDuration!==void 0&&r.cycleDuration>0?r.cycleDuration:r.keyframes.length===0?0:r.keyframes[r.keyframes.length-1].time}function Jr(r,e){let t=r.keyframes;if(t.length===0)return{values:[],keyTimes:[],keySplines:[]};let n=t.map(o=>String(o.value)),i=t.map(o=>e>0?(o.time/e).toFixed(4):"0"),a=[];for(let o=1;o<t.length;o++)a.push(ka(t[o].easing));return{values:n,keyTimes:i,keySplines:a}}function _t(r){let e=r.beginTrigger;if(!e)return"0s";switch(e.type){case"time":return`${e.value}s`;case"event":return e.value;default:return"0s"}}function en(r){return r.cycleInfinite?"indefinite":r.cycleRepeats&&r.cycleRepeats>1?String(r.cycleRepeats):null}function va(r){let e=xa[r.property];if(!e)return"";let t=Qr(r);if(t<=0)return"";let{values:n,keyTimes:i,keySplines:a}=Jr(r,t);if(n.length<2)return"";let o=`<animate attributeName="${xe(e)}"`;o+=` values="${xe(n.join(";"))}"`,o+=` keyTimes="${i.join(";")}"`,a.length>0&&a.some(u=>u!=="0 0 1 1")&&(o+=' calcMode="spline"',o+=` keySplines="${a.join(";")}"`),o+=` dur="${t}s"`,o+=` begin="${_t(r)}"`;let l=en(r);return l&&(o+=` repeatCount="${l}"`),o+=' fill="freeze"',o+="/>",o}function _a(r){let e;switch(r.property){case"transformMatrix":e="matrix";break;case"rotation":e="rotate";break;case"skewX":e="skewX";break;case"skewY":e="skewY";break;default:return""}let t=Qr(r);if(t<=0)return"";let{keyTimes:n,keySplines:i}=Jr(r,t),a=e==="matrix"?r.keyframes.map(c=>wa(c.value)):r.keyframes.map(c=>String(c.value));if(a.length<2||a.some(c=>c.length===0))return"";let o=e==="rotate"&&r.transformOrigin?a.map(c=>`${c} ${r.transformOrigin.x} ${r.transformOrigin.y}`):a,l='<animateTransform attributeName="transform"';l+=` type="${e}"`,l+=` values="${xe(o.join(";"))}"`,l+=` keyTimes="${n.join(";")}"`,i.length>0&&i.some(c=>c!=="0 0 1 1")&&(l+=' calcMode="spline"',l+=` keySplines="${i.join(";")}"`),l+=` dur="${t}s"`,l+=` begin="${_t(r)}"`;let u=en(r);return u&&(l+=` repeatCount="${u}"`),l+=` additive="${r.additive??"sum"}"`,l+=' fill="freeze"',l+="/>",l}function wa(r){if(Array.isArray(r)&&r.length>=6){let e=r.slice(0,6);if(e.every(t=>typeof t=="number"&&Number.isFinite(t)))return e.join(" ")}if(typeof r=="string"){let e=r.trim(),t=/^matrix\(([^)]+)\)$/i.exec(e),i=(t?t[1]:e).split(/[\s,]+/).filter(Boolean).map(Number);if(i.length>=6&&i.slice(0,6).every(Number.isFinite))return i.slice(0,6).join(" ")}return""}function Pa(r){if(!r.motionPath)return"";let e=Qr(r);if(e<=0)return"";let{keyTimes:t,keySplines:n}=Jr(r,e),i=r.keyframes.map(c=>{let f=typeof c.value=="number"?c.value:parseFloat(c.value);return Math.max(0,Math.min(1,f))}),a=!!r.motionPathRef&&(r.motionPathRef.mode??"trackShape")==="curveTemplate",o="<animateMotion";a||(o+=` path="${xe(r.motionPath)}"`),o+=` keyTimes="${t.join(";")}"`,o+=` keyPoints="${i.join(";")}"`,n.length>0&&n.some(c=>c!=="0 0 1 1")&&(o+=' calcMode="spline"',o+=` keySplines="${n.join(";")}"`),o+=` dur="${e}s"`,o+=` begin="${_t(r)}"`;let l=en(r);l&&(o+=` repeatCount="${l}"`),o+=' fill="freeze"';let u=r.motionRotate??"auto";return o+=` rotate="${u}"`,a?o+=`><mpath href="#${xe(r.motionPathRef.shapeId)}"/></animateMotion>`:o+="/>",o}function Ta(r){let e=_t(r);if(e!=="0s")return e;let t=r.keyframes[0]?.time??0;return t!==0?`${t}s`:""}function Aa(r){let e=Ta(r);return e?`<discard begin="${xe(e)}"/>`:"<discard/>"}function wt(r){let e=new Map;for(let t of r.tracks){if(!t.enabled||t.property!=="discard"&&t.keyframes.length<2)continue;let n=[...t.keyframes].sort((o,l)=>o.time-l.time),i={...t,locked:t.locked??!1,keyframes:n.map(o=>({time:o.time,value:o.value,easing:o.easing}))},a="";if(t.property==="discard"?a=Aa(i):t.property==="pathMotion"&&t.motionPath?a=Pa(i):Sa.has(t.property)?a=_a(i):a=va(i),a){let o=e.get(t.shapeId)??[];o.push(a),e.set(t.shapeId,o)}}return e}function Se(r,e={}){let{xmlDeclaration:t=!0,backgroundColor:n,indent:i=!0,className:a}=e,o=r.viewboxes?.[0],l=e.width??o?.width??800,u=e.height??o?.height??600,c=e.viewBox??`0 0 ${l} ${u}`,f=i?`
8
+ `:"",d=i?" ":"",m=r.shapes??[],p=m.filter(C=>C.state?.displayMode==="motionOnly"),b=m.filter(C=>C.state?.displayMode!=="motionOnly"),g=Ca(r),y=Ia(r),S=[...Array.isArray(r.library)?r.library:[],...(y??[]).filter(C=>!C.builtIn&&!(Array.isArray(r.library)&&r.library.some(L=>L.id===C.id)))],v=se(b,S),x=ie(b),k=Oa(g,b),P=Ma(p),_=v.length>0||x.length>0||k.length>0||P.length>0,$="";_&&($=`${f}${d}<defs>${f}`,v.length>0&&($+=`${d}${d}${v}${f}`),x.length>0&&($+=`${d}${d}${x}${f}`),k.length>0&&($+=`${d}${d}${k}${f}`),P.length>0&&($+=`${d}${d}${P}${f}`),$+=`${d}</defs>`);let w="";n&&(w=`${f}${d}<rect width="${l}" height="${u}" fill="${n}"/>`);let M=r.animationTimeline?wt(r.animationTimeline):null,I=b.map(C=>{let L=C.type==="symbol-instance"?Ba(C,g):H(C),E=M?.get(C.id);return E&&E.length>0&&(L=Ga(L,E,d)),`${d}${L}`}).join(f),R="";return t&&(R+=`<?xml version="1.0" encoding="UTF-8"?>${f}`),R+='<svg xmlns="http://www.w3.org/2000/svg"',R+=` width="${l}" height="${u}"`,R+=` viewBox="${c}"`,a&&(R+=` class="${a}"`),R+=">",R+=$,R+=w,b.length>0&&(R+=`${f}${I}`),R+=`${f}</svg>${f}`,R}function Ma(r){if(r.length===0)return"";let e=[];for(let t of r){let n=Fa(t);if(!n)continue;let i=Ra(n);e.push(`<path id="${Ln(t.id)}" d="${Ln(i)}"/>`)}return e.join("")}function Fa(r){let e=r.state;if(typeof e?.d=="string")return e.d;switch(r.type){case"rectangle":{let t=e?.x??0,n=e?.y??0,i=e?.width??0,a=e?.height??0;return i<=0||a<=0?null:`M${t},${n}h${i}v${a}h${-i}Z`}case"circle":{let t=e?.cx??0,n=e?.cy??0,i=e?.radius??0;return i<=0?null:`M${t-i},${n}A${i},${i} 0 1 0 ${t+i},${n}A${i},${i} 0 1 0 ${t-i},${n}Z`}case"ellipse":{let t=e?.cx??0,n=e?.cy??0,i=e?.rx??0,a=e?.ry??0;return i<=0||a<=0?null:`M${t-i},${n}A${i},${a} 0 1 0 ${t+i},${n}A${i},${a} 0 1 0 ${t-i},${n}Z`}case"line":{let t=e?.x1??0,n=e?.y1??0,i=e?.x2??0,a=e?.y2??0;return`M${t},${n}L${i},${a}`}default:return null}}function Ra(r){let e=/[Mm]\s*(-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)[\s,]+(-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)/.exec(r);if(!e)return r;let t=parseFloat(e[1]),n=parseFloat(e[2]);if(!isFinite(t)||!isFinite(n)||t===0&&n===0)return r;let i=!0;return r.replace(/([MLCQSTHVAZ])\s*([\d\s.,e+-]*)/gi,(a,o,l)=>{let u=o.toUpperCase(),c=o!==u,f=i;if(i=!1,u==="Z")return a;let d=l.trim().split(/[\s,]+/).filter(p=>p.length>0).map(Number);if(d.length===0||c&&!f)return a;let m=[];if(u==="H")for(let p of d)m.push(p-t);else if(u==="V")for(let p of d)m.push(p-n);else if(u==="A")for(let p=0;p<d.length;p+=7)m.push(d[p],d[p+1],d[p+2],d[p+3],d[p+4]),p+5<d.length&&m.push(d[p+5]-t),p+6<d.length&&m.push(d[p+6]-n);else for(let p=0;p<d.length;p+=2)m.push(d[p]-t),p+1<d.length&&m.push(d[p+1]-n);return`${o} ${m.join(" ")}`})}function Ln(r){return r.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;")}function Ca(r){let t=(Array.isArray(r.library)?r.library:[]).filter(n=>n.kind==="symbol");return t.length>0?t:r.symbols??[]}function Ia(r){let t=(Array.isArray(r.library)?r.library:[]).filter(n=>n.kind==="marker");return t.length>0?t:r.markers}var Pt=r=>r.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;"),La=r=>r.replace(/[^a-zA-Z0-9_-]/g,"_");function En(r){let e=r.state.symbolId??"",t=r.state.variantKey??"";return r.state.symbolOverrides&&Object.keys(r.state.symbolOverrides).length>0?`${e}--ovr-${r.id}`:t?`${e}--${La(t)}`:e}function Ea(r,e){return r.map(t=>{let n=e[t.id];return!n||Object.keys(n).length===0?t:{...t,state:{...t.state,...n}}})}function Da(r,e){return e?r.variants?.[e]??r.shapes:r.shapes}function Ba(r,e){let t=En(r),n=r.state.x??0,i=r.state.y??0,a=r.state.width??100,o=r.state.height??100;return`<use href="#${Pt(t)}" x="${n}" y="${i}" width="${a}" height="${o}"/>`}function Oa(r,e){if(r.length===0)return"";let t=new Map;for(let a of r)t.set(a.id,a);let n=new Map;for(let a of e){if(a.type!=="symbol-instance")continue;let o=a.state.symbolId??"",l=t.get(o);if(!l)continue;let u=En(a);if(n.has(u))continue;let c=Da(l,a.state.variantKey??""),f=a.state.symbolOverrides;f&&Object.keys(f).length>0&&(c=Ea(c,f)),n.set(u,{def:l,resolved:c})}if(n.size===0)return"";let i=[];for(let[a,{def:o,resolved:l}]of n){let u=l.map(d=>H(d)).join(""),c=o.viewBox?` viewBox="${Pt(o.viewBox)}"`:"",f=o.overflow?` overflow="${Pt(o.overflow)}"`:"";i.push(`<symbol id="${Pt(a)}"${c}${f}>${u}</symbol>`)}return i.join("")}function Ga(r,e,t){let n=e.join(""),i=0;for(;i<r.length;){let c=r.slice(i);if(!/^<defs[\s>]/.test(c))break;let f=r.indexOf("</defs>",i);if(f===-1)break;i=f+7}let a=r.slice(0,i),o=r.slice(i),l=o.lastIndexOf("/>");if(l!==-1){let c=o.match(/^<(\w+)/),f=c?c[1]:"g";return a+o.slice(0,l)+">"+n+`</${f}>`}let u=o.match(/<\/(\w+)>$/);if(u){let c=o.lastIndexOf(`</${u[1]}>`);return a+o.slice(0,c)+n+o.slice(c)}return a+o+n}function Tt(r,e){let t=re(r,e);return Se(r,{width:t.width,height:t.height,xmlDeclaration:e.xmlDeclaration??!1,indent:!0})}function za(r){return r==="class"?"className":r==="for"?"htmlFor":r.replace(/-([a-z])/g,(e,t)=>t.toUpperCase())}function Dn(r){return r.replace(/\s([a-z][a-z-]*?)=/g,(e,t)=>t.startsWith("data-")||t.startsWith("aria-")?e:` ${za(t)}=`)}function At(r,e){let t=e.componentName??"SvgComponent",n=re(r,e),i=e.indent??" ",a=r.shapes??[],o=e.typescript??!1,l=Array.isArray(r.library)?r.library:[],u=se(a,l),c=ie(a),f=u+c,d=f.length>0,m=a.map(b=>{let g=H(b);return`${i}${i}${i}${Dn(g)}`}),p=[];p.push("import React from 'react';"),p.push(""),o?(p.push(`interface ${t}Props {`),p.push(`${i}className?: string;`),p.push(`${i}style?: React.CSSProperties;`),p.push("}"),p.push(""),p.push(`const ${t}: React.FC<${t}Props> = ({ className, style }) => {`)):p.push(`const ${t} = ({ className, style }) => {`),p.push(`${i}return (`),p.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}>`),d&&(p.push(`${i}${i}${i}<defs>`),p.push(`${i}${i}${i}${i}${Dn(f)}`),p.push(`${i}${i}${i}</defs>`));for(let b of m)p.push(b);return p.push(`${i}${i}</svg>`),p.push(`${i});`),p.push("};"),p.push(""),p.push(`export default ${t};`),p.push(""),p.join(`
9
+ `)}function Mt(r,e){let t=e.componentName??"SvgComponent",n=re(r,e),i=e.indent??" ",a=r.shapes??[],o=e.typescript??!1,l=Array.isArray(r.library)?r.library:[],u=se(a,l),c=ie(a),f=u+c,d=f.length>0,m=a.map(b=>`${i}${i}${H(b)}`),p=[];p.push("<template>"),p.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">`),d&&(p.push(`${i}${i}<defs>`),p.push(`${i}${i}${i}${f}`),p.push(`${i}${i}</defs>`));for(let b of m)p.push(b);return p.push(`${i}</svg>`),p.push("</template>"),p.push(""),o?p.push('<script setup lang="ts">'):p.push("<script setup>"),p.push(`// ${t}`),o?(p.push("defineProps<{"),p.push(`${i}className?: string;`),p.push(`${i}style?: Record<string, string>;`),p.push("}>();")):(p.push("defineProps({"),p.push(`${i}className: { type: String, default: '' },`),p.push(`${i}style: { type: Object, default: () => ({}) },`),p.push("});")),p.push("</script>"),p.push(""),p.join(`
10
+ `)}var Ua=new Set(["circle","ellipse","rectangle","square","line","text","image"]);function Bn(r){return r.replace(/\\/g,"\\\\").replace(/'/g,"\\'")}function On(r){return r.replace(/\\/g,"\\\\").replace(/`/g,"\\`").replace(/\$\{/g,"\\${")}function Na(r){if(!Ua.has(r.type))return!0;let e=r.state.metadata;return!!(e?.title||e?.description||r.type==="text"&&r.state.isTextPath)}function Ft(r,e){let t=e.componentName??"createSvg",n=re(r,e),i=e.indent??" ",a=r.shapes??[],o=e.typescript??!1,l=[];l.push("import * as d3 from 'd3';"),l.push(""),o?l.push(`export function ${t}(container: string | HTMLElement): d3.Selection<SVGSVGElement, unknown, HTMLElement, unknown> {`):l.push(`export function ${t}(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 u=Array.isArray(r.library)?r.library:[],c=se(a,u),f=ie(a),d=`${c}${f}`;d.length>0&&(l.push(`${i}svg.append('defs').html(\`${On(d)}\`);`),l.push(""));for(let m=0;m<a.length;m++){let p=a[m];if(l.push(`${i}// ${p.type}${p.state.metadata?.name?` \u2014 ${p.state.metadata.name}`:""}`),Na(p)){l.push(`${i}svg.append('g').html(\`${On(H(p))}\`);`),l.push("");continue}let b=xn(p),g=mt(p),y=`shape${m+1}`;l.push(`${i}const ${y} = svg.append('${b}')`);for(let[S,v]of g)l.push(`${i}${i}.attr('${S}', '${Bn(v)}')`);p.type==="text"&&p.state.text&&l.push(`${i}${i}.text('${Bn(p.state.text)}')`),l[l.length-1]=l[l.length-1]+";",l.push("")}return l.push(`${i}return svg;`),l.push("}"),l.push(""),l.join(`
11
11
  `)}function Gn(r,e){let t=r.state.metadata?.name;return t?t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,""):`${r.type}-${e+1}`}var Va=new Set(["fill","fill-opacity","fill-rule","stroke","stroke-width","stroke-opacity","stroke-dasharray","stroke-linecap","opacity","transform","filter"]);function Rt(r,e){let t=re(r,e),n=e.indent??" ",i=r.shapes??[],a=[];for(let u=0;u<i.length;u++){let c=i[u],f=Gn(c,u),d=mt(c),m=[];for(let[p,b]of d)Va.has(p)&&m.push(`${n}${p}: ${b};`);m.length>0&&a.push(`.${f} {
12
12
  ${m.join(`
13
13
  `)}
14
14
  }`)}let o=[];for(let u=0;u<i.length;u++){let c=i[u],f=Gn(c,u),d=H(c),m=d.indexOf(" ");m!==-1&&(d=d.slice(0,m)+` class="${f}"`+d.slice(m)),o.push(`${n}${d}`)}let l=[];l.push("<style>");for(let u of a)l.push(u);l.push("</style>"),l.push(""),l.push(`<svg xmlns="http://www.w3.org/2000/svg" width="${t.width}" height="${t.height}" viewBox="0 0 ${t.width} ${t.height}">`);for(let u of o)l.push(u);return l.push("</svg>"),l.push(""),l.join(`
15
- `)}function Ct(r,e){let t=Ha(r,e),n={...e};switch(n.format){case"svg":return Tt(t,n);case"react":return At(t,n);case"vue":return Ft(t,n);case"d3":return Mt(t,n);case"css":return Rt(t,n);default:throw new Error(`Unsupported code format: ${n.format}`)}}function Ha(r,e){return Array.isArray(r)?{shapes:r,viewboxes:[{id:"default",x:0,y:0,width:e.width??800,height:e.height??600}]}:r}var It=class r{_snapshot;constructor(e={}){let{width:t=800,height:n=600,viewboxId:i}=e,a=Re(0,0,t,n,i);this._snapshot=je({viewboxes:[a]})}static fromSnapshot(e){let t=new r;return t._snapshot=JSON.parse(JSON.stringify(e)),t}static fromJSON(e,t){let n=qe(e,t),i=new r;return i._snapshot=n,i}add(e){let t="build"in e&&typeof e.build=="function"?e.build():e;return this._snapshot.shapes.push(t),this}addAll(...e){for(let t of e)this.add(t);return this}remove(e){let t=this._snapshot.shapes.length;return this._snapshot.shapes=this._snapshot.shapes.filter(n=>n.id!==e),this._snapshot.shapes.length<t}get shapes(){return this._snapshot.shapes}findShape(e){return this._snapshot.shapes.find(t=>t.id===e)}size(e,t){return this._snapshot.viewboxes.length>0?(this._snapshot.viewboxes[0].width=e,this._snapshot.viewboxes[0].height=t):this._snapshot.viewboxes=[Re(0,0,e,t)],this}get width(){return this._snapshot.viewboxes[0]?.width??800}get height(){return this._snapshot.viewboxes[0]?.height??600}title(e){return this._ensureMetadata(),this._snapshot.documentMetadata.title=e,this}description(e){return this._ensureMetadata(),this._snapshot.documentMetadata.description=e,this}author(e){return this._ensureMetadata(),this._snapshot.documentMetadata.author=e,this}keywords(...e){return this._ensureMetadata(),this._snapshot.documentMetadata.keywords=e,this}license(e,t){return this._ensureMetadata(),this._snapshot.documentMetadata.license=e,t!==void 0&&(this._snapshot.documentMetadata.licenseUrl=t),this}language(e){return this._ensureMetadata(),this._snapshot.documentMetadata.language=e,this}customMetadata(e){return this._ensureMetadata(),this._snapshot.documentMetadata.customMetadata={...this._snapshot.documentMetadata.customMetadata,...e},this}get meta(){return this._snapshot.documentMetadata}defineSymbol(e,t,n){this._snapshot.symbols||(this._snapshot.symbols=[]);let i=T(),a=t.map(l=>"build"in l&&typeof l.build=="function"?l.build():l),o={kind:"symbol",id:i,name:e,viewBox:n?.viewBox??"0 0 100 100",shapes:a};return n?.groups&&(o.groups=n.groups),n?.thumbnail&&(o.thumbnail=n.thumbnail),n?.defKind&&(o.defKind=n.defKind),n?.wrapperAttrs&&(o.wrapperAttrs=n.wrapperAttrs),n?.variantAxes&&(o.variantAxes=n.variantAxes),n?.variants&&(o.variants=n.variants),n?.variantThumbnails&&(o.variantThumbnails=n.variantThumbnails),this._snapshot.symbols.push(o),i}placeSymbolInstance(e,t,n,i,a){let o,l={};typeof i=="number"||i===void 0?o=i:(l=i,o=l.width,a=l.height??a);let u={symbolId:e,x:t,y:n,width:o??100,height:a??100};l.variantKey&&(u.variantKey=l.variantKey),l.symbolOverrides&&(u.symbolOverrides=l.symbolOverrides),l.instancePresentation&&(u.instancePresentation=l.instancePresentation);let c={id:T(),type:"symbol-instance",state:u};return this._snapshot.shapes.push(c),this}removeSymbol(e){if(!this._snapshot.symbols)return!1;let t=this._snapshot.symbols.length;return this._snapshot.symbols=this._snapshot.symbols.filter(n=>n.id!==e),this._snapshot.symbols.length<t}get symbols(){return this._snapshot.symbols??[]}defineMarker(e,t,n){let i=T(),a=t.map(l=>"build"in l&&typeof l.build=="function"?l.build():l),o={kind:"marker",id:i,name:e,viewBox:n?.viewBox??"0 0 10 10",refX:n?.refX??5,refY:n?.refY??5,markerWidth:n?.markerWidth??10,markerHeight:n?.markerHeight??10,markerUnits:n?.markerUnits??"strokeWidth",orient:n?.orient??"auto",shapes:a};return n?.groups&&(o.groups=n.groups),n?.thumbnail&&(o.thumbnail=n.thumbnail),this._pushLibraryDef(o),i}defineFilter(e,t,n){let i=T(),a={kind:"filter",id:i,name:e,filters:t};return n?.colorInterpolation&&(a.colorInterpolation=n.colorInterpolation),n?.filterUnits&&(a.filterUnits=n.filterUnits),n?.primitiveUnits&&(a.primitiveUnits=n.primitiveUnits),n?.x!==void 0&&(a.x=n.x),n?.y!==void 0&&(a.y=n.y),n?.width!==void 0&&(a.width=n.width),n?.height!==void 0&&(a.height=n.height),n?.thumbnail&&(a.thumbnail=n.thumbnail),this._pushLibraryDef(a),i}defineLinearGradientLibrary(e,t,n){let i=T(),a="build"in t?t.build():t,{id:o,sourceId:l,...u}=a,c={kind:"linear-gradient",id:i,name:e,gradient:u};return n?.thumbnail&&(c.thumbnail=n.thumbnail),this._pushLibraryDef(c),i}defineRadialGradientLibrary(e,t,n){let i=T(),a="build"in t?t.build():t,{id:o,sourceId:l,...u}=a,c={kind:"radial-gradient",id:i,name:e,gradient:u};return n?.thumbnail&&(c.thumbnail=n.thumbnail),this._pushLibraryDef(c),i}definePatternLibrary(e,t,n){let i=T(),a="build"in t?t.build():t,{id:o,sourceId:l,customPatternId:u,...c}=a,f={kind:"pattern",id:i,name:e,pattern:c};return n?.thumbnail&&(f.thumbnail=n.thumbnail),this._pushLibraryDef(f),i}removeLibraryDef(e){if(!this._snapshot.library)return!1;let t=this._snapshot.library.length;return this._snapshot.library=this._snapshot.library.filter(n=>n.id!==e),this._snapshot.library.length<t}get library(){return this._snapshot.library??[]}_pushLibraryDef(e){this._snapshot.library||(this._snapshot.library=[]);let t=this._snapshot.library.findIndex(n=>n.id===e.id);t>=0?this._snapshot.library[t]=e:this._snapshot.library.push(e)}addClipGroup(e,t,n){this._snapshot.clipMaskGroups||(this._snapshot.clipMaskGroups=[]);let i=T(),a={id:i,type:"clip",clipShapeIds:e,contentShapeIds:t,parentId:null};return n?.clipPathUnits&&(a.clipPathUnits=n.clipPathUnits),n?.rawDefinition&&(a.rawDefinition=n.rawDefinition),this._snapshot.clipMaskGroups.push(a),i}addMaskGroup(e,t,n){this._snapshot.clipMaskGroups||(this._snapshot.clipMaskGroups=[]);let i=T(),a={id:i,type:"mask",clipShapeIds:e,contentShapeIds:t,parentId:null};return n?.maskUnits&&(a.maskUnits=n.maskUnits),n?.maskContentUnits&&(a.maskContentUnits=n.maskContentUnits),n?.maskBounds&&(a.maskBounds=n.maskBounds),n?.maskType&&(a.maskType=n.maskType),n?.rawDefinition&&(a.rawDefinition=n.rawDefinition),this._snapshot.clipMaskGroups.push(a),i}removeClipMaskGroup(e){if(!this._snapshot.clipMaskGroups)return!1;let t=this._snapshot.clipMaskGroups.length;return this._snapshot.clipMaskGroups=this._snapshot.clipMaskGroups.filter(n=>n.id!==e),this._snapshot.clipMaskGroups.length<t}addGuide(e,t,n){this._snapshot.guides||(this._snapshot.guides=[]);let i=T(),a={id:i,orientation:e,position:t,controlPointOffset:0};return n?.color&&(a.color=n.color),n?.opacity!==void 0&&(a.opacity=n.opacity),this._snapshot.guides.push(a),i}removeGuide(e){if(!this._snapshot.guides)return!1;let t=this._snapshot.guides.length;return this._snapshot.guides=this._snapshot.guides.filter(n=>n.id!==e),this._snapshot.guides.length<t}clearGuides(){return this._snapshot.guides=[],this}get guides(){return this._snapshot.guides??[]}addMeasurement(e,t,n){this._snapshot.measurements||(this._snapshot.measurements=[]);let i=T(),a={id:i,type:e,points:t,visible:n?.visible??!0,snapDivisions:n?.snapDivisions??1};return n?.color&&(a.color=n.color),n?.opacity!==void 0&&(a.opacity=n.opacity),this._snapshot.measurements.push(a),i}removeMeasurement(e){if(!this._snapshot.measurements)return!1;let t=this._snapshot.measurements.length;return this._snapshot.measurements=this._snapshot.measurements.filter(n=>n.id!==e),this._snapshot.measurements.length<t}get measurements(){return this._snapshot.measurements??[]}addCustomPattern(e,t,n,i){this._snapshot.customPatterns||(this._snapshot.customPatterns=[]);let a=T();return this._snapshot.customPatterns.push({id:a,name:e,svgContent:t,width:n,height:i}),a}removeCustomPattern(e){if(!this._snapshot.customPatterns)return!1;let t=this._snapshot.customPatterns.length;return this._snapshot.customPatterns=this._snapshot.customPatterns.filter(n=>n.id!==e),this._snapshot.customPatterns.length<t}get customPatterns(){return this._snapshot.customPatterns??[]}addGroup(e,t){this._snapshot.groups||(this._snapshot.groups=[]);let n=e??T();return this._snapshot.groups.push({id:n,parentId:t??null}),n}removeGroup(e){if(!this._snapshot.groups)return!1;let t=this._snapshot.groups.length;this._snapshot.groups=this._snapshot.groups.filter(n=>n.id!==e);for(let n of this._snapshot.shapes)n.state.groupId===e&&delete n.state.groupId;return this._snapshot.groups.length<t}moveToGroup(e,t){let n=this._snapshot.shapes.find(i=>i.id===e);return n&&(n.state.groupId=t),this}removeFromGroup(e){let t=this._snapshot.shapes.find(n=>n.id===e);return t&&delete t.state.groupId,this}bringToFront(e){let t=this._snapshot.shapes.findIndex(n=>n.id===e);if(t>=0){let[n]=this._snapshot.shapes.splice(t,1);this._snapshot.shapes.push(n)}return this}sendToBack(e){let t=this._snapshot.shapes.findIndex(n=>n.id===e);if(t>=0){let[n]=this._snapshot.shapes.splice(t,1);this._snapshot.shapes.unshift(n)}return this}reorder(e,t){let n=this._snapshot.shapes.findIndex(i=>i.id===e);if(n>=0){let[i]=this._snapshot.shapes.splice(n,1),a=Math.max(0,Math.min(t,this._snapshot.shapes.length));this._snapshot.shapes.splice(a,0,i)}return this}defineVariable(e,t,n,i){this._snapshot.templateVariables||(this._snapshot.templateVariables=[]);let a=this._snapshot.templateVariables.find(o=>o.name===e);if(a)a.type=t,a.defaultValue=n,i?.label!==void 0&&(a.label=i.label),i?.description!==void 0&&(a.description=i.description);else{let o={name:e,type:t,defaultValue:n};i?.label!==void 0&&(o.label=i.label),i?.description!==void 0&&(o.description=i.description),this._snapshot.templateVariables.push(o)}return this}removeVariable(e){return this._snapshot.templateVariables&&(this._snapshot.templateVariables=this._snapshot.templateVariables.filter(t=>t.name!==e)),this}get variables(){return this._snapshot.templateVariables??[]}inspectVariables(){return et(this._snapshot)}setTimeline(e){return"build"in e&&typeof e.build=="function"?this._snapshot.animationTimeline=e.build():this._snapshot.animationTimeline=e,this}clearTimeline(){return delete this._snapshot.animationTimeline,this}get timeline(){return this._snapshot.animationTimeline}toSVG(e){let{variables:t,...n}=e??{},i=Je(this._snapshot,t);return Se(i,n)}toJSON(e){return Ye(this._snapshot,e)}toSnapshot(){return JSON.parse(JSON.stringify(this._snapshot))}toCode(e,t){return Ct(this._snapshot,{...t,format:e})}_ensureMetadata(){this._snapshot.documentMetadata||(this._snapshot.documentMetadata={title:"",description:"",author:"",keywords:[],license:"",licenseUrl:"",language:"en",customMetadata:{}})}};var Lt=class{_track;constructor(e,t){this._track={id:T(),shapeId:e,property:t,keyframes:[],enabled:!0,locked:!1}}id(e){return this._track.id=e,this}keyframe(e,t,n="linear"){return this._track.keyframes.push({time:e,value:t,easing:n}),this}keyframeBezier(e,t,n){return this._track.keyframes.push({time:e,value:t,easing:"custom-bezier",customBezier:n}),this}keyframeLinear(e,t,n){return this._track.keyframes.push({time:e,value:t,easing:"linear-function",linearPoints:n}),this}keyframes(...e){return this._track.keyframes.push(...e),this}disabled(){return this._track.enabled=!1,this}locked(){return this._track.locked=!0,this}motionPath(e){return this._track.motionPath=e,this}motionPathRef(e,t="trackShape"){return this._track.motionPathRef={shapeId:e,mode:t},this}beginTrigger(e,t){return this._track.beginTrigger={type:e,value:t},this}endTrigger(e,t){return this._track.endTrigger={type:e,value:t},this}cycleDuration(e){return this._track.cycleDuration=e,this}cycleRepeats(e){return this._track.cycleRepeats=e,this}infinite(){return this._track.cycleInfinite=!0,this}cycle(e){return this._track.cycleBehavior=e,this}transformOrigin(e,t){return this._track.transformOrigin={x:e,y:t},this}motionRotate(e){return this._track.motionRotate=e,this}additive(e){return this._track.additive=e,this}build(){let e=[...this._track.keyframes].sort((t,n)=>t.time-n.time);return{...this._track,keyframes:e}}},Et=class{_duration;_loop=!1;_playbackSpeed=1;_tracks=[];constructor(e){this._duration=e}loop(e=!0){return this._loop=e,this}speed(e){return this._playbackSpeed=e,this}duration(e){return this._duration=e,this}addTrack(e){return this._tracks.push(e),this}addTracks(...e){return this._tracks.push(...e),this}buildTimeline(){return{duration:this._duration,loop:this._loop,playbackSpeed:this._playbackSpeed,tracks:this._tracks.map(e=>e.build())}}build(){let e=this.buildTimeline();return{duration:e.duration,loop:e.loop,playbackSpeed:e.playbackSpeed,tracks:e.tracks.map(t=>({id:t.id,shapeId:t.shapeId,property:t.property,enabled:t.enabled,locked:t.locked||void 0,motionPath:t.motionPath,motionPathRef:t.motionPathRef,beginTrigger:t.beginTrigger,endTrigger:t.endTrigger,cycleDuration:t.cycleDuration,cycleRepeats:t.cycleRepeats,cycleInfinite:t.cycleInfinite,cycleBehavior:t.cycleBehavior,transformOrigin:t.transformOrigin,motionRotate:t.motionRotate,additive:t.additive,keyframes:t.keyframes.map(n=>({time:n.time,value:n.value,easing:n.easing,...n.customBezier?{customBezier:n.customBezier}:{},...n.linearPoints?{linearPoints:n.linearPoints}:{}}))}))}}};var U=class{_id;_type;_state={};constructor(e,t){this._type=e,this._id=t??T()}id(e){return this._id=e,this}locked(e=!0){return this._state.locked=e,this}visible(e=!0){return this._state.visible=e,this}displayMode(e){return this._state.displayMode=e,this}motionOnly(){return this._state.displayMode="motionOnly",this}fill(e,t){return this._state.fillColor=e,this._state.fillType="solid",t!==void 0&&(this._state.fillOpacity=t),this}noFill(){return this._state.fillType="none",this}fillGradient(e){let t="build"in e?e.build():e;return this._state.fillType=t.type,this._state.fillGradient=t,this}fillPattern(e){let t="build"in e?e.build():e;return this._state.fillType="pattern",this._state.fillGradient=t,this}fillOpacity(e){return this._state.fillOpacity=e,this}fillRule(e){return this._state.fillRule=e,this}stroke(e,t){return this._state.borderColor=e,t!==void 0&&(this._state.borderWidth=t),this}noStroke(){return this._state.borderColor="none",this._state.borderWidth=0,this}strokeWidth(e){return this._state.borderWidth=e,this}strokeOpacity(e){return this._state.strokeOpacity=e,this}strokeGradient(e){let t="build"in e?e.build():e;return this._state.strokeType=t.type,this._state.strokeGradient=t,this}strokePattern(e){let t="build"in e?e.build():e;return this._state.strokeType="pattern",this._state.strokeGradient=t,this}strokeLinejoin(e){return this._state.strokeLinejoin=e,this}strokeLinecap(e){return this._state.strokeLinecap=e,this}strokeMiterlimit(e){return this._state.strokeMiterlimit=e,this}dashOffset(e){return this._state.dashOffset=e,this}strokeDasharray(e){return this._state.strokeDasharray=e,this}dash(e,t,n){return this._state.lineStyle=e,e==="custom"&&(t!==void 0&&(this._state.dashLength=t),n!==void 0&&(this._state.gapLength=n)),this}opacity(e){return this._state.opacity=e,this}rotate(e){return this._state.rotation=e,this.refreshTransformMatrix(),this}skew(e,t){return this._state.skewX=e,this._state.skewY=t,this.refreshTransformMatrix(),this}scale(e,t){return this._state.scaleX=e,this._state.scaleY=t??e,this.refreshTransformMatrix(),this}pivot(e,t){return this._state.customPivot={x:e,y:t},this.refreshTransformMatrix(),this}transformMatrix(e){if(e.length<6||!e.slice(0,6).every(Number.isFinite))throw new RangeError("transformMatrix must contain six finite numbers");return this._state.transformMatrix=e.slice(0,6),this}refreshTransformMatrix(){this._state.transformMatrix=ue(Te(this._state,this.defaultTransformPivot()))}defaultTransformPivot(){let e=this._state.customPivot;if(e)return e;let t=this._state.x,n=this._state.y,i=this._state.width,a=this._state.height;if(t!==void 0&&n!==void 0&&i!==void 0&&a!==void 0)return{x:t+i/2,y:n+a/2};let o=this._state.radius;if(t!==void 0&&n!==void 0&&o!==void 0)return{x:t,y:n};let l=this._state.cx,u=this._state.cy;if(l!==void 0&&u!==void 0)return{x:l,y:u};let c=this._state.x1,f=this._state.y1,d=this._state.x2,m=this._state.y2;if(c!==void 0&&f!==void 0&&d!==void 0&&m!==void 0)return{x:(c+d)/2,y:(f+m)/2};let p=this._state.pathPoints;if(p?.[0])return{x:p[0].x,y:p[0].y};let b=this._state.polylinePoints;if(b?.[0])return b[0]}filter(...e){let t=this._state.filters??[];return this._state.filters=[...t,...e],this}dropShadow(e={}){let t={id:`drop-shadow-${T()}`,type:"drop-shadow",enabled:!0,offsetX:e.offsetX??4,offsetY:e.offsetY??4,blurRadius:e.blurRadius??8,spread:e.spread??0,color:e.color??"#000000",opacity:e.opacity??.3};return this.filter(t)}innerShadow(e={}){let t={id:`inner-shadow-${T()}`,type:"inner-shadow",enabled:!0,offsetX:e.offsetX??2,offsetY:e.offsetY??2,blurRadius:e.blurRadius??4,choke:e.choke??0,color:e.color??"#000000",opacity:e.opacity??.5};return this.filter(t)}blur(e,t,n){let i=e??4,a=t??i,o={id:`gaussian-blur-${T()}`,type:"gaussian-blur",enabled:!0,blurX:i,blurY:a,linked:i===a,quality:n?.quality??"normal"};return this.filter(o)}glow(e={}){let t={id:`glow-${T()}`,type:"glow",enabled:!0,color:e.color??"#ffffff",radius:e.radius??10,intensity:e.intensity??.8};return this.filter(t)}innerGlow(e={}){let t={id:`inner-glow-${T()}`,type:"inner-glow",enabled:!0,color:e.color??"#ffffff",radius:e.radius??10,intensity:e.intensity??.8};return this.filter(t)}grayscale(e=1){let t={id:`grayscale-${T()}`,type:"grayscale",enabled:!0,amount:e};return this.filter(t)}sepia(e=1){let t={id:`sepia-${T()}`,type:"sepia",enabled:!0,amount:e};return this.filter(t)}outline(e={}){return this.filter({id:`outline-${T()}`,type:"outline",enabled:!0,width:e.width??3,color:e.color??"#000000",opacity:e.opacity??1,position:e.position??"outside"})}motionBlur(e={}){let t={id:`motion-blur-${T()}`,type:"motion-blur",enabled:!0,distance:e.distance??10,angle:e.angle??0,quality:e.quality??"normal"};return this.filter(t)}pointLight(e={}){let t={id:`point-light-${T()}`,type:"point-light",enabled:!0,x:e.x??100,y:e.y??100,z:e.z??200,color:e.color??"#ffffff",surfaceScale:e.surfaceScale??5,diffuseConstant:e.diffuseConstant??1,specularConstant:e.specularConstant??1,specularExponent:e.specularExponent??20};return this.filter(t)}spotLight(e={}){let t={id:`spot-light-${T()}`,type:"spot-light",enabled:!0,x:e.x??100,y:e.y??0,z:e.z??200,pointsAtX:e.pointsAtX??100,pointsAtY:e.pointsAtY??100,pointsAtZ:e.pointsAtZ??0,coneAngle:e.coneAngle??30,color:e.color??"#ffffff",surfaceScale:e.surfaceScale??5,specularConstant:e.specularConstant??1,specularExponent:e.specularExponent??20};return this.filter(t)}sharpen(e=1){let t={id:`sharpen-${T()}`,type:"sharpen",enabled:!0,amount:e};return this.filter(t)}pixelate(e=8){let t={id:`pixelate-${T()}`,type:"pixelate",enabled:!0,blockSize:e};return this.filter(t)}warp(e={}){let t={id:`warp-${T()}`,type:"warp",enabled:!0,scale:e.scale??10,frequency:e.frequency??.02,octaves:e.octaves??1,warpType:e.warpType??"turbulence"};return this.filter(t)}morphology(e={}){let t=e.radiusX??2,n=e.radiusY??t,i={id:`morphology-${T()}`,type:"morphology",enabled:!0,operator:e.operator??"dilate",radiusX:t,radiusY:n,linked:e.linked??t===n};return this.filter(i)}contouring(e={}){if((e.mode??"discrete")==="table"){let i={id:`contouring-table-${T()}`,type:"contouring-table",enabled:!0,levels:e.levels??4,contrast:e.contrast??1};return this.filter(i)}let n={id:`contouring-discrete-${T()}`,type:"contouring-discrete",enabled:!0,levels:e.levels??4};return this.filter(n)}roundEdges(e=4){let t={id:`round-edges-${T()}`,type:"round-edges",enabled:!0,radius:e};return this.filter(t)}channelPainter(e={}){let t={id:`channel-painter-${T()}`,type:"channel-painter",enabled:!0,red:e.red??1,green:e.green??1,blue:e.blue??1};return this.filter(t)}brightness(e=1){let t={id:`brightness-${T()}`,type:"brightness",enabled:!0,amount:e};return this.filter(t)}contrast(e=1){let t={id:`contrast-${T()}`,type:"contrast",enabled:!0,amount:e};return this.filter(t)}filterOpacity(e=1){let t={id:`opacity-${T()}`,type:"opacity",enabled:!0,amount:e};return this.filter(t)}invert(e=1){let t={id:`invert-${T()}`,type:"invert",enabled:!0,amount:e};return this.filter(t)}hueRotate(e=0){let t={id:`hue-rotate-${T()}`,type:"hue-rotate",enabled:!0,angle:e};return this.filter(t)}saturate(e=1){let t={id:`saturate-${T()}`,type:"saturate",enabled:!0,amount:e};return this.filter(t)}blackAndWhite(e=.5){let t={id:`black-and-white-${T()}`,type:"black-and-white",enabled:!0,threshold:e};return this.filter(t)}duotone(e={}){let t={id:`duotone-${T()}`,type:"duotone",enabled:!0,shadowColor:e.shadowColor??"#000000",highlightColor:e.highlightColor??"#ffffff"};return this.filter(t)}xray(e=1){let t={id:`xray-${T()}`,type:"xray",enabled:!0,intensity:e};return this.filter(t)}noise(e={}){let t={id:`noise-${T()}`,type:"noise",enabled:!0,amount:e.amount??.3,scale:e.scale??1};return this.filter(t)}emboss(e={}){let t={id:`emboss-${T()}`,type:"emboss",enabled:!0,strength:e.strength??1,angle:e.angle??135};return this.filter(t)}filmGrain(e={}){let t={id:`film-grain-${T()}`,type:"film-grain",enabled:!0,amount:e.amount??.3,size:e.size??1};return this.filter(t)}watercolor(e={}){let t={id:`watercolor-${T()}`,type:"watercolor",enabled:!0,wetness:e.wetness??.5,turbulence:e.turbulence??.5};return this.filter(t)}gouache(e={}){let t={id:`gouache-${T()}`,type:"gouache",enabled:!0,thickness:e.thickness??.5,texture:e.texture??.5};return this.filter(t)}inkBlot(e={}){let t={id:`ink-blot-${T()}`,type:"ink-blot",enabled:!0,spread:e.spread??.5,edges:e.edges??.5};return this.filter(t)}crumpledPlastic(e={}){let t={id:`crumpled-plastic-${T()}`,type:"crumpled-plastic",enabled:!0,wrinkles:e.wrinkles??.5,shine:e.shine??.5};return this.filter(t)}riddled(e={}){let t={id:`riddled-${T()}`,type:"riddled",enabled:!0,density:e.density??.5,size:e.size??1};return this.filter(t)}cssClipPath(e){return this._state.cssClipPath=e,this}cssMaskProperties(e){return this._state.cssMaskProperties=e,this}vectorEffect(e){return this._state.vectorEffect=e,this}transformBox(e){return this._state.transformBox=e,this}paintOrder(e){return this._state.paintOrder=e,this}blendMode(e){return this._state.blendMode=e,this}visibility(e){return this._state.visibility=e,this}shapeRendering(e){return this._state.shapeRendering=e,this}filterColorInterpolation(e){return this._state.filterColorInterpolation=e,this}inheritFill(e=!0){return this._state.inheritFill=e,this}inheritStroke(e=!0){return this._state.inheritStroke=e,this}systemLanguage(e){return this._state.systemLanguage=e,this}requiredExtensions(e){return this._state.requiredExtensions=e,this}fillLibrary(e,t="linear-gradient"){return this._state.fillLibraryId=e,this._state.fillType=t,this}strokeLibrary(e,t="linear-gradient"){return this._state.strokeLibraryId=e,this._state.strokeType=t,this}filterLibrary(...e){let t=this._state.filterLibraryIds??[];return this._state.filterLibraryIds=[...t,...e],this}markerStartRef(e){return this._state.markerStart=e,this}markerMidRef(e){return this._state.markerMid=e,this}markerEndRef(e){return this._state.markerEnd=e,this}bind(e,t){let n=this._state.bindings??{};return this._state.bindings={...n,[e]:t},this}metadata(e){return this._state.metadata={...this._state.metadata,...e},this}group(e){return this._state.groupId=e,this}build(){return{id:this._id,type:this._type,state:{...this._state}}}},Dt=class extends U{constructor(e,t,n){if(n<0)throw new RangeError("Circle radius must be non-negative");super("circle"),this._state.x=e,this._state.y=t,this._state.radius=n}position(e,t){return this._state.x=e,this._state.y=t,this}radius(e){return this._state.radius=e,this}},Bt=class extends U{constructor(e,t,n,i){if(n<0||i<0)throw new RangeError("Ellipse radii must be non-negative");super("ellipse"),this._state.cx=e,this._state.cy=t,this._state.rx=n,this._state.ry=i}position(e,t){return this._state.cx=e,this._state.cy=t,this}radii(e,t){return this._state.rx=e,this._state.ry=t,this}},Ot=class extends U{constructor(e,t,n,i){if(n<0||i<0)throw new RangeError("Rectangle dimensions must be non-negative");super("rectangle"),this._state.x=e,this._state.y=t,this._state.width=n,this._state.height=i}position(e,t){return this._state.x=e,this._state.y=t,this}size(e,t){return this._state.width=e,this._state.height=t,this}cornerRadius(e){return this._state.cornerRadius=e,this._state.rx=e,this._state.ry=e,this}radii(e,t){return this._state.rx=e,this._state.ry=t,e===t&&(this._state.cornerRadius=e),this}},Gt=class extends U{constructor(e,t,n){if(n<0)throw new RangeError("Square size must be non-negative");super("square"),this._state.x=e,this._state.y=t,this._state.width=n,this._state.height=n}position(e,t){return this._state.x=e,this._state.y=t,this}size(e){return this._state.width=e,this._state.height=e,this}cornerRadius(e){return this._state.cornerRadius=e,this._state.rx=e,this._state.ry=e,this}radii(e,t){return this._state.rx=e,this._state.ry=t,e===t&&(this._state.cornerRadius=e),this}},zt=class extends U{constructor(e,t,n,i){super("line"),this._state.x1=e,this._state.y1=t,this._state.x2=n,this._state.y2=i}from(e,t){return this._state.x1=e,this._state.y1=t,this}to(e,t){return this._state.x2=e,this._state.y2=t,this}markerStart(e){return this._state.startEndpoint=e,this}markerEnd(e){return this._state.endEndpoint=e,this}markers(e,t){return this._state.startEndpoint=e,this._state.endEndpoint=t,this}},Ut=class extends U{constructor(e,t,n){super("text"),this._state.x=e,this._state.y=t,this._state.text=n}position(e,t){return this._state.x=e,this._state.y=t,this}content(e){return this._state.text=e,this}fontSize(e){return this._state.fontSize=e,this}fontFamily(e){return this._state.fontFamily=e,this}fontWeight(e){return this._state.fontWeight=e,this}fontStyle(e){return this._state.fontStyle=e,this}fontVariant(e){return this._state.fontVariant=e,this}fontVariantLigatures(e){return this._state.fontVariantLigatures=e,this}fontVariantPosition(e){return this._state.fontVariantPosition=e,this}fontVariantCaps(e){return this._state.fontVariantCaps=e,this}fontVariantNumeric(e){return this._state.fontVariantNumeric=e,this}fontVariantEastAsian(e){return this._state.fontVariantEastAsian=e,this}anchor(e){return this._state.textAnchor=e,this}letterSpacing(e){return this._state.letterSpacing=e,this}lineHeight(e){return this._state.lineHeight=e,this}decoration(e){return this._state.textDecoration=e,this}transform(e){return this._state.textTransform=e,this}textPath(e,t=0){return this._state.isTextPath=!0,this._state.textPathPoints=e,this._state.textPathStartOffset=t,this}textPathOffset(e){return this._state.textPathStartOffset=e,this}textPathSide(e){return this._state.textPathSide=e,this}direction(e){return this._state.textDirection=e,this}unicodeBidi(e){return this._state.unicodeBidi=e,this}dominantBaseline(e){return this._state.dominantBaseline=e,this}writingMode(e){return this._state.writingMode=e,this}wordSpacing(e){return this._state.wordSpacing=e,this}baselineShift(e){return this._state.baselineShift=e,this}inlineSize(e){return this._state.inlineSize=e,this}overflowWrap(e){return this._state.overflowWrap=e,this}whiteSpace(e){return this._state.whiteSpace=e,this}fontVariationSettings(e){return this._state.fontVariationSettings=e,this}charOffsets(e){return this._state.charOffsets=e,this}shapeInsideRef(e){return this._state.shapeInsideRef=e,this}shapePadding(e){return this._state.shapePadding=e,this}richTextData(e){return this._state.richTextData=e,this}useRichText(e=!0){return this._state.useRichText=e,this}linePositions(e){return this._state.linePositions=e,this}textLength(e){return this._state.textLength=e,this}lengthAdjust(e){return this._state.lengthAdjust=e,this}},X=class extends U{constructor(e,t,n,i){super(e),this._state.cx=t,this._state.cy=n,this._state.radius=i}position(e,t){return this._state.cx=e,this._state.cy=t,this}radius(e){return this._state.radius=e,this}shiftAngle(e){return this._state.shiftAngle=e,this}cornerRadius(e){return this._state.cornerRadius=e,this}},Nt=class extends X{constructor(e,t,n){super("triangle",e,t,n)}},Vt=class extends X{constructor(e,t,n,i=5){super("ngon",e,t,n),this._state.sides=i}sides(e){return this._state.sides=e,this}},Ht=class extends X{constructor(e,t,n){super("star",e,t,n),this._state.arms=5,this._state.innerRadiusPercent=40}arms(e){return this._state.arms=e,this}innerRadius(e){return this._state.innerRadiusPercent=e,this}},Wt=class extends X{constructor(e,t,n){super("cross",e,t,n),this._state.armWidthPercent=35}armWidth(e){return this._state.armWidthPercent=e,this}},Xt=class extends X{constructor(e,t,n){super("ring",e,t,n),this._state.innerRadiusPercent=60}innerRadius(e){return this._state.innerRadiusPercent=e,this}},jt=class extends X{constructor(e,t,n){super("spiral",e,t,n),this._state.turns=3,this._state.thicknessPercent=15,this._state.spiralDirection=1}turns(e){return this._state.turns=e,this}thickness(e){return this._state.thicknessPercent=e,this}direction(e){return this._state.spiralDirection=e,this}},Yt=class extends X{constructor(e,t,n){super("gear",e,t,n),this._state.teeth=8,this._state.toothDepthPercent=25}teeth(e){return this._state.teeth=e,this}toothDepth(e){return this._state.toothDepthPercent=e,this}holeRadius(e){return this._state.holeRadiusPercent=e,this}},qt=class extends X{constructor(e,t,n){super("arrow",e,t,n),this._state.headWidthPercent=100,this._state.headLengthPercent=35,this._state.shaftWidthPercent=35}headWidth(e){return this._state.headWidthPercent=e,this}headLength(e){return this._state.headLengthPercent=e,this}shaftWidth(e){return this._state.shaftWidthPercent=e,this}},Zt=class extends X{constructor(e,t,n){super("heart",e,t,n),this._state.lobeRadiusPercent=50,this._state.cleftDepthPercent=25}lobeRadius(e){return this._state.lobeRadiusPercent=e,this}cleftDepth(e){return this._state.cleftDepthPercent=e,this}},Kt=class extends X{constructor(e,t,n){super("lightning",e,t,n),this._state.boltSegments=3,this._state.boltJaggednessPercent=40,this._state.boltWidthPercent=30}segments(e){return this._state.boltSegments=e,this}jaggedness(e){return this._state.boltJaggednessPercent=e,this}thickness(e){return this._state.boltWidthPercent=e,this}},Qt=class extends X{constructor(e,t,n){super("cloud",e,t,n),this._state.cloudBumps=5,this._state.cloudPuffinessPercent=60}bumps(e){return this._state.cloudBumps=e,this}puffiness(e){return this._state.cloudPuffinessPercent=e,this}},Jt=class extends X{constructor(e,t,n){super("speechBubble",e,t,n),this._state.tailAngleDeg=45,this._state.tailLengthPercent=40,this._state.tailWidthPercent=25}tailAngle(e){return this._state.tailAngleDeg=e,this}tailLength(e){return this._state.tailLengthPercent=e,this}tailWidth(e){return this._state.tailWidthPercent=e,this}},ce=class extends U{add(e){let t="build"in e&&typeof e.build=="function"?e.build():e,n=this._state.children??[];return this._state.children=[...n,t],this}addAll(...e){for(let t of e)this.add(t);return this}children(e){return this._state.children=e.map(t=>"build"in t&&typeof t.build=="function"?t.build():t),this}},er=class extends ce{constructor(e){super("hyperlink"),e!==void 0&&(this._state.href=e)}href(e){return this._state.href=e,this}hrefXlink(e){return this._state.hrefXlink=e,this}target(e){return this._state.linkTarget=e,this}download(e){return this._state.linkDownload=e,this}rel(e){return this._state.linkRel=e,this}ping(e){return this._state.linkPing=e,this}hreflang(e){return this._state.linkHreflang=e,this}type(e){return this._state.linkType=e,this}referrerPolicy(e){return this._state.linkReferrerPolicy=e,this}},tr=class extends ce{constructor(){super("switch")}},rr=class extends ce{constructor(){super("container")}},nr=class extends U{constructor(e){super("view"),e&&(this._state.viewBoxX=e.x,this._state.viewBoxY=e.y,this._state.viewBoxWidth=e.width,this._state.viewBoxHeight=e.height)}viewBox(e,t,n,i){return this._state.viewBoxX=e,this._state.viewBoxY=t,this._state.viewBoxWidth=n,this._state.viewBoxHeight=i,this}name(e){return this._state.viewName=e,this}preserveAspectRatio(e){return this._state.viewPreserveAspectRatio=e,this}zoomAndPan(e){return this._state.viewZoomAndPan=e,this}viewTarget(e){return this._state.viewTarget=e,this}asHome(e=!0){return this}},ir=class extends ce{constructor(e=0,t=0,n=100,i=100){super("svg"),this._state.svgX=e,this._state.svgY=t,this._state.svgWidth=n,this._state.svgHeight=i}position(e,t){return this._state.svgX=e,this._state.svgY=t,this}size(e,t){return this._state.svgWidth=e,this._state.svgHeight=t,this}viewBox(e,t,n,i){return this._state.svgViewBoxX=e,this._state.svgViewBoxY=t,this._state.svgViewBoxWidth=n,this._state.svgViewBoxHeight=i,this}preserveAspectRatio(e){return this._state.svgPreserveAspectRatio=e,this}asRoot(e=!0){return this._state.isRootSvg=e,this}},sr=class extends U{constructor(e){super("shape-reference"),e!==void 0&&(this._state.targetShapeId=e)}target(e){return this._state.targetShapeId=e,this}offset(e,t){return this._state.offsetX=e,this._state.offsetY=t,this}size(e,t){return this._state.width=e,this._state.height=t,this}},ar=class extends U{position(e,t){return this._state.x=e,this._state.y=t,this}size(e,t){return this._state.width=e,this._state.height=t,this}src(e){return this._state.href=e,this}mimeType(e){return this._state.mediaMimeType=e,this}naturalDuration(e){return this._state.naturalDuration=e,this}begin(e){return this._state.begin=e,this}trim(e,t){return this._state.trimStart=e,this._state.trimEnd=t,this}volume(e){return this._state.volume=e,this}muted(e=!0){return this._state.muted=e,this}loop(e=!0){return this._state.loop=e,this}playbackRate(e){return this._state.playbackRate=e,this}fade(e,t){return this._state.fadeInDuration=e,this._state.fadeOutDuration=t,this}language(e){return this._state.systemLanguage=e,this}},or=class extends ar{constructor(e){super("video"),this._state.mediaKind="video",e!==void 0&&(this._state.href=e)}poster(e){return this._state.posterHref=e,this}sourceRect(e){return this._state.sourceRect=e,this}},lr=class extends ar{constructor(e){super("audio"),this._state.mediaKind="audio",e!==void 0&&(this._state.href=e)}},ur=class extends U{constructor(e=[]){super("path"),this._state.pathPoints=[...e],this._state.pathCurveType="cubic",this._state.pathClosed=!1}points(e){return this._state.pathPoints=[...e],this}addPoint(e,t){let n=this._state.pathPoints??[];return n.push({x:e,y:t}),this._state.pathPoints=n,this}curveType(e){return this._state.pathCurveType=e,this}closed(e=!0){return this._state.pathClosed=e,this}tension(e){return this._state.pathTension=e,this}arcParams(e){return this._state.pathArcParams=e,this}markerStart(e){return this._state.startEndpoint=e,this}markerEnd(e){return this._state.endEndpoint=e,this}markers(e,t){return this._state.startEndpoint=e,this._state.endEndpoint=t,this}toD(){let e=this._state.pathPoints??[],t=this._state.pathCurveType??"CUBIC",n=this._state.pathClosed??!1,i=this._state.pathTension??.5,a=this._state.pathArcParams;return ye(e,t,n,i,a)}},cr=class extends U{constructor(e=[]){super("polyline"),this._state.polylinePoints=[...e],this._state.polylineClosed=!1}points(e){return this._state.polylinePoints=[...e],this}addPoint(e,t){let n=this._state.polylinePoints??[];return n.push({x:e,y:t}),this._state.polylinePoints=n,this}closed(e=!0){return this._state.polylineClosed=e,this}markerStart(e){return this._state.startEndpoint=e,this}markerEnd(e){return this._state.endEndpoint=e,this}markers(e,t){return this._state.startEndpoint=e,this._state.endEndpoint=t,this}},dr=class extends U{constructor(e,t,n,i,a){super("image"),this._state.x=e,this._state.y=t,this._state.width=n,this._state.height=i,this._state.href=a}position(e,t){return this._state.x=e,this._state.y=t,this}size(e,t){return this._state.width=e,this._state.height=t,this}src(e){return this._state.href=e,this}preserveAspectRatio(e){return this._state.preserveAspectRatio=e,this}};var De=class{_x1;_y1;_x2;_y2;_stops=[];_spreadMethod="pad";_opacity=1;_id;constructor(e=0,t=0,n=1,i=0){this._x1=e,this._y1=t,this._x2=n,this._y2=i,this._id=T()}stop(e,t,n=1){return this._stops.push({offset:e,color:t,opacity:n}),this}direction(e,t,n,i){return this._x1=e,this._y1=t,this._x2=n,this._y2=i,this}spread(e){return this._spreadMethod=e,this}opacity(e){return this._opacity=e,this}build(){return{type:"linear-gradient",id:this._id,x1:this._x1,y1:this._y1,x2:this._x2,y2:this._y2,stops:[...this._stops],spreadMethod:this._spreadMethod,opacity:this._opacity}}},Be=class{_cx=.5;_cy=.5;_fx=.5;_fy=.5;_r=.5;_ry=.5;_rotation=0;_stops=[];_spreadMethod="pad";_opacity=1;_id;constructor(){this._id=T()}center(e,t){return this._cx=e,this._cy=t,this}focus(e,t){return this._fx=e,this._fy=t,this}radius(e,t){return this._r=e,this._ry=t??e,this}rotation(e){return this._rotation=e,this}stop(e,t,n=1){return this._stops.push({offset:e,color:t,opacity:n}),this}spread(e){return this._spreadMethod=e,this}opacity(e){return this._opacity=e,this}build(){return{type:"radial-gradient",id:this._id,cx:this._cx,cy:this._cy,fx:this._fx,fy:this._fy,r:this._r,ry:this._ry,rotation:this._rotation,stops:[...this._stops],spreadMethod:this._spreadMethod,opacity:this._opacity}}},Oe=class{_patternType;_color;_backgroundColor;_scale=1;_rotation=0;_opacity=1;_patternParams;_id;_svgContent;_width;_height;_patternUnits;_patternContentUnits;_patternTransform;_viewBox;_preserveAspectRatio;_x;_y;_customPatternId;constructor(e="stripes",t="#000000",n="#ffffff"){this._patternType=e,this._color=t,this._backgroundColor=n,this._id=T()}scale(e){return this._scale=e,this}rotation(e){return this._rotation=e,this}opacity(e){return this._opacity=e,this}params(e){return this._patternParams=e,this}svgContent(e){return this._svgContent=e,this}size(e,t){return this._width=e,this._height=t,this}patternUnits(e){return this._patternUnits=e,this}patternContentUnits(e){return this._patternContentUnits=e,this}patternTransform(e){return this._patternTransform=e,this}viewBox(e){return this._viewBox=e,this}preserveAspectRatio(e){return this._preserveAspectRatio=e,this}position(e,t){return this._x=e,this._y=t,this}customPatternId(e){return this._customPatternId=e,this}build(){let e,t,n;if(this._svgContent!==void 0)e=this._svgContent,t=this._width??10,n=this._height??10;else{let a=xt(this._patternType,this._scale,this._color,this._backgroundColor,this._patternParams);e=a.svgContent,t=this._width??a.width,n=this._height??a.height}let i={type:"pattern",id:this._id,patternType:this._svgContent!==void 0?"custom":this._patternType,color:this._color,backgroundColor:this._backgroundColor,scale:this._scale,rotation:this._rotation,opacity:this._opacity,svgContent:e,width:t,height:n,patternUnits:this._patternUnits??"userSpaceOnUse",patternParams:this._patternParams,patternTransform:this._patternTransform??(this._rotation?`rotate(${this._rotation})`:void 0)};return this._patternContentUnits&&(i.patternContentUnits=this._patternContentUnits),this._viewBox&&(i.viewBox=this._viewBox),this._preserveAspectRatio&&(i.preserveAspectRatio=this._preserveAspectRatio),this._x!==void 0&&(i.x=this._x),this._y!==void 0&&(i.y=this._y),this._customPatternId&&(i.customPatternId=this._customPatternId),i}};function zn(r=0,e=0,t=1,n=0){return new De(r,e,t,n)}function Un(){return new Be}function Nn(r="stripes",e="#000000",t="#ffffff"){return new Oe(r,e,t)}var tn={rows:4,cols:4,style:"classic",tabDepthPercent:20,tabPattern:"random",seed:1},Wa=.04,Xa=0;function ja(r){let e=r>>>0;return()=>{e=e+1831565813>>>0;let t=e;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}}function M(r){return Number(r.toFixed(3)).toString()}function Ya(r,e,t,n,i,a,o,l,u,c,f,d){return[[0,0],[.2,l],[.5+u+f,-a+c],[.5-a+u,a+c],[.5-2*a+u-f,3*a+c],[.5+2*a+u-f,3*a+c],[.5+a+u,a+c],[.5+u+f,-a+c],[.8,d],[1,0]].map(([p,b])=>{let g=e+p*n,y=t+b*i*o;return r?{x:g,y}:{x:y,y:g}})}function Vn(r,e,t,n,i,a,o,l,u,c,f){let d=[],m=(P,_)=>u==="alternating"?0:P+c()*(_-P),p=()=>c()<.5,b=m(-l,l),g=u==="alternating"?f%2===0:p(),y=null,S=b,v=m(-l,l),x=m(-l,l),k=m(-l,l);b=m(-l,l);for(let P=0;P<r;P++){P>0&&(y=g,g=u==="alternating"?(f+P)%2===0:p(),S=g===y?-b:b,v=m(-l,l),x=m(-l,l),k=m(-l,l),b=m(-l,l));let _=g?-1:1,$=t+P*i;d.push(Ya(e,$,n,i,a,o,_,S,v,x,k,b))}return d}function Hn(r,e,t,n,i,a,o){let l=2*a;return[[0,0],[.2,0],[.4,0],[.4,l],[.4,l],[.6,l],[.6,l],[.6,0],[.8,0],[1,0]].map(([c,f])=>{let d=e+c*n,m=t+f*i*o;return r?{x:d,y:m}:{x:m,y:d}})}function Wn(r,e){return r+` C ${M(e[1].x)} ${M(e[1].y)} ${M(e[2].x)} ${M(e[2].y)} ${M(e[3].x)} ${M(e[3].y)} C ${M(e[4].x)} ${M(e[4].y)} ${M(e[5].x)} ${M(e[5].y)} ${M(e[6].x)} ${M(e[6].y)} C ${M(e[7].x)} ${M(e[7].y)} ${M(e[8].x)} ${M(e[8].y)} ${M(e[9].x)} ${M(e[9].y)}`}function Xn(r,e){return r+` C ${M(e[8].x)} ${M(e[8].y)} ${M(e[7].x)} ${M(e[7].y)} ${M(e[6].x)} ${M(e[6].y)} C ${M(e[5].x)} ${M(e[5].y)} ${M(e[4].x)} ${M(e[4].y)} ${M(e[3].x)} ${M(e[3].y)} C ${M(e[2].x)} ${M(e[2].y)} ${M(e[1].x)} ${M(e[1].y)} ${M(e[0].x)} ${M(e[0].y)}`}function jn(r,e={}){let t={...tn,...e};if(t.rows<1||t.cols<1)throw new Error("generatePuzzlePieces: rows and cols must be >= 1");if(!Number.isFinite(r.width)||!Number.isFinite(r.height))throw new Error("generatePuzzlePieces: bounds must have finite width/height");if(r.width<=0||r.height<=0)throw new Error("generatePuzzlePieces: bounds must have positive width/height");let{rows:n,cols:i,style:a,tabDepthPercent:o,tabPattern:l,seed:u}=t,c=ja(u),f=r.width/i,d=r.height/n,m=Math.max(0,Math.min(.4,o/200)),p=(a==="classic"||a==="curved")&&m>0,b=a==="square-tabs"&&m>0,g=a==="classic"&&l==="random"?Wa:Xa,y=[];for(let x=0;x<n-1;x++){let k=r.y+(x+1)*d;if(p)y.push(Vn(i,!0,r.x,k,f,d,m,g,l,c,x));else if(b){let P=[];for(let _=0;_<i;_++){let $=l==="alternating"?(x+_)%2===0?1:-1:c()<.5?1:-1;P.push(Hn(!0,r.x+_*f,k,f,d,m,$))}y.push(P)}else y.push(new Array(i).fill(null))}let S=[];for(let x=0;x<i-1;x++){let k=r.x+(x+1)*f;if(p)S.push(Vn(n,!1,r.y,k,d,f,m,g,l,c,x));else if(b){let P=[];for(let _=0;_<n;_++){let $=l==="alternating"?(_+x)%2===0?1:-1:c()<.5?1:-1;P.push(Hn(!1,r.y+_*d,k,d,f,m,$))}S.push(P)}else S.push(new Array(n).fill(null))}let v=[];for(let x=0;x<n;x++)for(let k=0;k<i;k++){let P=r.x+k*f,_=r.y+x*d,$=P+f,w=_+d,F=`M ${M(P)} ${M(_)}`;if(x===0)F+=` L ${M($)} ${M(_)}`;else{let I=y[x-1][k];I?F=Wn(F,I):F+=` L ${M($)} ${M(_)}`}if(k===i-1)F+=` L ${M($)} ${M(w)}`;else{let I=S[k][x];I?F=Wn(F,I):F+=` L ${M($)} ${M(w)}`}if(x===n-1)F+=` L ${M(P)} ${M(w)}`;else{let I=y[x][k];I?F=Xn(F,I):F+=` L ${M(P)} ${M(w)}`}if(k===0)F+=` L ${M(P)} ${M(_)}`;else{let I=S[k-1][x];I?F=Xn(F,I):F+=` L ${M(P)} ${M(_)}`}F+=" Z",v.push({id:`puzzle-${u}-r${x}-c${k}`,row:x,col:k,d:F})}return v}var Zn=[1,2,3,4,5,6,7,8,9],qa={easy:{minGivens:40,maxGivens:45,maxRating:"singles"},medium:{minGivens:34,maxGivens:39,maxRating:"hidden-singles"},hard:{minGivens:28,maxGivens:33,maxRating:"search"},expert:{minGivens:24,maxGivens:27,maxRating:"search"}};function Ge(r){return r.map(e=>[...e])}function Za(){return Array.from({length:9},()=>Array.from({length:9},()=>0))}function Kn(r){let e=r>>>0;return()=>{e=e+1831565813>>>0;let t=e;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}}function Qn(r,e){let t=[...r];for(let n=t.length-1;n>0;n--){let i=Math.floor(e()*(n+1));[t[n],t[i]]=[t[i],t[n]]}return t}function ke(r){return 1<<r-1}function Jn(r){let e=0,t=r;for(;t;)t&=t-1,e++;return e}function Ka(r){for(let e=1;e<=9;e++)if(r===ke(e))return e;return 0}function nn(r,e){return Math.floor(r/3)*3+Math.floor(e/3)}function rn(r){let e=0;for(let t of r)for(let n of t)n!==0&&e++;return e}function Qa(r){if(!Number.isFinite(r))return 1;let e=Math.floor(r);return e===0?1:e}function ei(r,e){if(!Array.isArray(r)||r.length!==9)return e.push("Grid must contain 9 rows."),!1;let t=!0;for(let n=0;n<9;n++){if(!Array.isArray(r[n])||r[n].length!==9){e.push(`Row ${n+1} must contain 9 cells.`),t=!1;continue}for(let i=0;i<9;i++){let a=r[n][i];(!Number.isInteger(a)||a<0||a>9)&&(e.push(`Cell R${n+1}C${i+1} must be a digit from 0 to 9.`),t=!1)}}return t}function ti(r,e){let t=!0,n=(i,a)=>{let o=0;for(let l of a){if(l===0)continue;let u=ke(l);if(o&u){e.push(`${i} contains duplicate ${l}.`),t=!1;return}o|=u}};for(let i=0;i<9;i++)n(`Row ${i+1}`,r[i]);for(let i=0;i<9;i++)n(`Column ${i+1}`,r.map(a=>a[i]));for(let i=0;i<9;i+=3)for(let a=0;a<9;a+=3){let o=[];for(let l=i;l<i+3;l++)for(let u=a;u<a+3;u++)o.push(r[l][u]);n(`Box ${Math.floor(i/3)*3+Math.floor(a/3)+1}`,o)}return t}function sn(r){let e=Array.from({length:9},()=>0),t=Array.from({length:9},()=>0),n=Array.from({length:9},()=>0);for(let i=0;i<9;i++)for(let a=0;a<9;a++){let o=r[i][a];if(o===0)continue;let l=ke(o),u=nn(i,a);if(e[i]&l||t[a]&l||n[u]&l)return null;e[i]|=l,t[a]|=l,n[u]|=l}return{rows:e,cols:t,boxes:n}}function an(r,e,t,n,i){return 511&~(t[r]|n[e]|i[nn(r,e)])}function ri(r,e,t){let n=sn(r);if(!n)return[];let i=Ge(r),a=[],{rows:o,cols:l,boxes:u}=n,c=()=>{if(a.length>=e)return;let f=-1,d=-1,m=0,p=10;for(let g=0;g<9;g++){for(let y=0;y<9;y++){if(i[g][y]!==0)continue;let S=an(g,y,o,l,u),v=Jn(S);if(v===0)return;if(v<p&&(f=g,d=y,m=S,p=v,v===1))break}if(p===1)break}if(f===-1){a.push(Ge(i));return}let b=Zn.filter(g=>m&ke(g));t&&(b=Qn(b,t));for(let g of b){let y=ke(g),S=nn(f,d);if(i[f][d]=g,o[f]|=y,l[d]|=y,u[S]|=y,c(),u[S]&=~y,l[d]&=~y,o[f]&=~y,i[f][d]=0,a.length>=e)return}};return c(),a}function Ja(r){let e=Za(),t=Kn(r),[n]=ri(e,1,t);if(!n)throw new Error("generateSudokuPuzzle: failed to generate solved grid");return n}function eo(r){let e=sn(r);if(!e)return null;for(let t=0;t<9;t++)for(let n=0;n<9;n++){if(r[t][n]!==0)continue;let i=an(t,n,e.rows,e.cols,e.boxes);if(Jn(i)===1)return{row:t,col:n,value:Ka(i)}}return null}function to(r){let e=sn(r);if(!e)return null;let t=n=>{for(let i of Zn){let a=ke(i),o=null;for(let l of n)if(!(r[l.row][l.col]!==0||!(an(l.row,l.col,e.rows,e.cols,e.boxes)&a))){if(o){o=null;break}o=l}if(o)return{...o,value:i}}return null};for(let n=0;n<9;n++){let i=t(Array.from({length:9},(a,o)=>({row:n,col:o})));if(i)return i}for(let n=0;n<9;n++){let i=t(Array.from({length:9},(a,o)=>({row:o,col:n})));if(i)return i}for(let n=0;n<9;n+=3)for(let i=0;i<9;i+=3){let a=[];for(let l=n;l<n+3;l++)for(let u=i;u<i+3;u++)a.push({row:l,col:u});let o=t(a);if(o)return o}return null}function Yn(r){let e=Ge(r),t=!1;for(;rn(e)<81;){let n=eo(e);if(n){e[n.row][n.col]=n.value;continue}let i=to(e);if(i){t=!0,e[i.row][i.col]=i.value;continue}return"search"}return t?"hidden-singles":"singles"}function qn(r,e){let t={singles:0,"hidden-singles":1,search:2};return t[r]<=t[e]}function ze(r,e={}){let t=[];return ei(r,t)?ti(r,t)?ri(r,Math.max(1,Math.floor(e.maxSolutions??2))):[]:[]}function ni(r){let e=[];if(!ei(r,e))return{valid:!1,unique:!1,solution:null,errors:e};if(ti(r,e),e.length>0)return{valid:!1,unique:!1,solution:null,errors:e};let n=ze(r,{maxSolutions:2});return n.length===0?e.push("Puzzle has no solution."):n.length>1&&e.push("Puzzle has more than one solution."),{valid:e.length===0,unique:n.length===1,solution:n[0]?Ge(n[0]):null,errors:e}}function ii(r){let e=r.difficulty,t=qa[e];if(!t)throw new Error(`generateSudokuPuzzle: unsupported difficulty "${e}"`);let n=Qa(r.seed);for(let i=0;i<30;i++){let a=n+i*104729>>>0,o=Kn(a),l=Ja(a),u=Ge(l),c=t.minGivens+Math.floor(o()*(t.maxGivens-t.minGivens+1)),f=Qn(Array.from({length:81},(b,g)=>({row:Math.floor(g/9),col:g%9})),o);for(let b of f){if(rn(u)<=c)break;let g=u[b.row][b.col];if(u[b.row][b.col]=0,ze(u,{maxSolutions:2}).length!==1){u[b.row][b.col]=g;continue}let S=Yn(u);qn(S,t.maxRating)||(u[b.row][b.col]=g)}let d=rn(u),m=Yn(u);if(ze(u,{maxSolutions:2}).length===1&&d>=t.minGivens&&d<=t.maxGivens&&qn(m,t.maxRating))return{puzzle:u,solution:l,difficulty:e,seed:n,givens:d,rating:m}}throw new Error(`generateSudokuPuzzle: unable to generate a ${e} puzzle`)}0&&(module.exports={Arrow,Audio,BUILTIN_MARKER_ID_MAP,COMMON_TRANSFORM_NODE_DEFAULTS,CURRENT_SCHEMA_VERSION,Circle,Cloud,Container,ContainerShapeBuilder,Cross,DEFAULT_COORDINATE_PRECISION,Document,EASING_CURVES,EVENT_TRIGGER_OPTIONS,EasingType,Ellipse,Gear,Heart,Hyperlink,IDENTITY_AFFINE,ImageShape,LIBRARY_EMIT_ORDER,Lightning,Line,LinearGradientBuilder,MARKER_HEIGHT,MARKER_VIEWBOX,MARKER_WIDTH,MAX_COORDINATE_PRECISION,MIGRATIONS,NGon,NUMERIC_SHAPE_TRANSFORM_STATE_KEYS,NestedSvg,PUZZLE_DEFAULTS,Path,PathCurveType,PathPointType,PatternBuilder,Polyline,RadialGradientBuilder,Rectangle,Ring,SHAPE_TRANSFORM_STATE_KEYS,ShapeBuilder,ShapeReference,SpeechBubble,Spiral,Square,Star,Switch,Text,Timeline,Track,Triangle,Video,View,affine,affineFromArray,affineToArray,around,canonicalPolygonTransformString,canonicalTransformString,collectReferencedLibraryIds,composeLegacyTransformMatrix,computeArrowVertices,computeCloudPath,computeCrossVertices,computeDashArray,computeGearPath,computeGearVertices,computeHeartPath,computeLightningVertices,computePolygonVertices,computeRectanglePath,computeRingPath,computeSpeechBubbleVertices,computeSpiralPath,computeSplinePath,computeStarVertices,createDocument,createShape,createViewbox,defaultVariableMode,escXml,extractVariables,filterAttr,foldLegacyAncestorTransformIntoMatrix,generateCode,generateCssCode,generateD3Code,generateId,generatePatternSvgContent,generatePuzzlePieces,generateReactCode,generateSudokuPuzzle,generateSvgCode,generateVueCode,getBuiltInMarkerDefs,getEasingCubicBezier,getEffectivePrecision,getMarkerDescriptors,getPatternElements,isFiniteAffineArray,isIdentityAffine,linearGradient,matrixTransformPart,migrateSnapshot,multiplyAffine,parseDocument,parseSvgTransformList,parseVariableArgs,pattern,radialGradient,renderAnimationElements,renderBuiltinMarkerDefs,renderCircle,renderEllipse,renderFilterDefs,renderFilterLibraryDef,renderFilterPrimitive,renderFilterPrimitivesForType,renderImage,renderLibraryDef,renderLibraryDefs,renderLine,renderLinearGradientLibraryDef,renderMarkerLibraryDef,renderPatternLibraryDef,renderPolygonShape,renderPolyline,renderRadialGradientLibraryDef,renderRectangle,renderReferencedLibraryDefs,renderShape,renderSpline,renderSvgPrimitiveChainFilter,renderSymbolLibraryDef,renderText,renderToSvg,rotateAffine,roundCoord,roundNumberString,roundSerializedShape,roundSnapshot,scaleAffine,skewXAffine,skewYAffine,solveSudoku,stringifyDocument,substituteString,substituteVariables,translateAffine,validateSnapshot,validateSudokuPuzzle,verticesToPath});
15
+ `)}function Ct(r,e){let t=Ha(r,e),n={...e};switch(n.format){case"svg":return Tt(t,n);case"react":return At(t,n);case"vue":return Mt(t,n);case"d3":return Ft(t,n);case"css":return Rt(t,n);default:throw new Error(`Unsupported code format: ${n.format}`)}}function Ha(r,e){return Array.isArray(r)?{shapes:r,viewboxes:[{id:"default",x:0,y:0,width:e.width??800,height:e.height??600}]}:r}var It=class r{_snapshot;constructor(e={}){let{width:t=800,height:n=600,viewboxId:i}=e,a=Re(0,0,t,n,i);this._snapshot=je({viewboxes:[a]})}static fromSnapshot(e){let t=new r;return t._snapshot=JSON.parse(JSON.stringify(e)),t}static fromJSON(e,t){let n=qe(e,t),i=new r;return i._snapshot=n,i}add(e){let t="build"in e&&typeof e.build=="function"?e.build():e;return this._snapshot.shapes.push(t),this}addAll(...e){for(let t of e)this.add(t);return this}remove(e){let t=this._snapshot.shapes.length;return this._snapshot.shapes=this._snapshot.shapes.filter(n=>n.id!==e),this._snapshot.shapes.length<t}get shapes(){return this._snapshot.shapes}findShape(e){return this._snapshot.shapes.find(t=>t.id===e)}size(e,t){return this._snapshot.viewboxes.length>0?(this._snapshot.viewboxes[0].width=e,this._snapshot.viewboxes[0].height=t):this._snapshot.viewboxes=[Re(0,0,e,t)],this}get width(){return this._snapshot.viewboxes[0]?.width??800}get height(){return this._snapshot.viewboxes[0]?.height??600}title(e){return this._ensureMetadata(),this._snapshot.documentMetadata.title=e,this}description(e){return this._ensureMetadata(),this._snapshot.documentMetadata.description=e,this}author(e){return this._ensureMetadata(),this._snapshot.documentMetadata.author=e,this}keywords(...e){return this._ensureMetadata(),this._snapshot.documentMetadata.keywords=e,this}license(e,t){return this._ensureMetadata(),this._snapshot.documentMetadata.license=e,t!==void 0&&(this._snapshot.documentMetadata.licenseUrl=t),this}language(e){return this._ensureMetadata(),this._snapshot.documentMetadata.language=e,this}customMetadata(e){return this._ensureMetadata(),this._snapshot.documentMetadata.customMetadata={...this._snapshot.documentMetadata.customMetadata,...e},this}get meta(){return this._snapshot.documentMetadata}defineSymbol(e,t,n){this._snapshot.symbols||(this._snapshot.symbols=[]);let i=T(),a=t.map(l=>"build"in l&&typeof l.build=="function"?l.build():l),o={kind:"symbol",id:i,name:e,viewBox:n?.viewBox??"0 0 100 100",shapes:a};return n?.groups&&(o.groups=n.groups),n?.thumbnail&&(o.thumbnail=n.thumbnail),n?.defKind&&(o.defKind=n.defKind),n?.wrapperAttrs&&(o.wrapperAttrs=n.wrapperAttrs),n?.variantAxes&&(o.variantAxes=n.variantAxes),n?.variants&&(o.variants=n.variants),n?.variantThumbnails&&(o.variantThumbnails=n.variantThumbnails),this._snapshot.symbols.push(o),i}placeSymbolInstance(e,t,n,i,a){let o,l={};typeof i=="number"||i===void 0?o=i:(l=i,o=l.width,a=l.height??a);let u={symbolId:e,x:t,y:n,width:o??100,height:a??100};l.variantKey&&(u.variantKey=l.variantKey),l.symbolOverrides&&(u.symbolOverrides=l.symbolOverrides),l.instancePresentation&&(u.instancePresentation=l.instancePresentation);let c={id:T(),type:"symbol-instance",state:u};return this._snapshot.shapes.push(c),this}removeSymbol(e){if(!this._snapshot.symbols)return!1;let t=this._snapshot.symbols.length;return this._snapshot.symbols=this._snapshot.symbols.filter(n=>n.id!==e),this._snapshot.symbols.length<t}get symbols(){return this._snapshot.symbols??[]}defineMarker(e,t,n){let i=T(),a=t.map(l=>"build"in l&&typeof l.build=="function"?l.build():l),o={kind:"marker",id:i,name:e,viewBox:n?.viewBox??"0 0 10 10",refX:n?.refX??5,refY:n?.refY??5,markerWidth:n?.markerWidth??10,markerHeight:n?.markerHeight??10,markerUnits:n?.markerUnits??"strokeWidth",orient:n?.orient??"auto",shapes:a};return n?.groups&&(o.groups=n.groups),n?.thumbnail&&(o.thumbnail=n.thumbnail),this._pushLibraryDef(o),i}defineFilter(e,t,n){let i=T(),a={kind:"filter",id:i,name:e,filters:t};return n?.colorInterpolation&&(a.colorInterpolation=n.colorInterpolation),n?.filterUnits&&(a.filterUnits=n.filterUnits),n?.primitiveUnits&&(a.primitiveUnits=n.primitiveUnits),n?.x!==void 0&&(a.x=n.x),n?.y!==void 0&&(a.y=n.y),n?.width!==void 0&&(a.width=n.width),n?.height!==void 0&&(a.height=n.height),n?.thumbnail&&(a.thumbnail=n.thumbnail),this._pushLibraryDef(a),i}defineLinearGradientLibrary(e,t,n){let i=T(),a="build"in t?t.build():t,{id:o,sourceId:l,...u}=a,c={kind:"linear-gradient",id:i,name:e,gradient:u};return n?.thumbnail&&(c.thumbnail=n.thumbnail),this._pushLibraryDef(c),i}defineRadialGradientLibrary(e,t,n){let i=T(),a="build"in t?t.build():t,{id:o,sourceId:l,...u}=a,c={kind:"radial-gradient",id:i,name:e,gradient:u};return n?.thumbnail&&(c.thumbnail=n.thumbnail),this._pushLibraryDef(c),i}definePatternLibrary(e,t,n){let i=T(),a="build"in t?t.build():t,{id:o,sourceId:l,customPatternId:u,...c}=a,f={kind:"pattern",id:i,name:e,pattern:c};return n?.thumbnail&&(f.thumbnail=n.thumbnail),this._pushLibraryDef(f),i}removeLibraryDef(e){if(!this._snapshot.library)return!1;let t=this._snapshot.library.length;return this._snapshot.library=this._snapshot.library.filter(n=>n.id!==e),this._snapshot.library.length<t}get library(){return this._snapshot.library??[]}_pushLibraryDef(e){this._snapshot.library||(this._snapshot.library=[]);let t=this._snapshot.library.findIndex(n=>n.id===e.id);t>=0?this._snapshot.library[t]=e:this._snapshot.library.push(e)}addClipGroup(e,t,n){this._snapshot.clipMaskGroups||(this._snapshot.clipMaskGroups=[]);let i=T(),a={id:i,type:"clip",clipShapeIds:e,contentShapeIds:t,parentId:null};return n?.clipPathUnits&&(a.clipPathUnits=n.clipPathUnits),n?.rawDefinition&&(a.rawDefinition=n.rawDefinition),this._snapshot.clipMaskGroups.push(a),i}addMaskGroup(e,t,n){this._snapshot.clipMaskGroups||(this._snapshot.clipMaskGroups=[]);let i=T(),a={id:i,type:"mask",clipShapeIds:e,contentShapeIds:t,parentId:null};return n?.maskUnits&&(a.maskUnits=n.maskUnits),n?.maskContentUnits&&(a.maskContentUnits=n.maskContentUnits),n?.maskBounds&&(a.maskBounds=n.maskBounds),n?.maskType&&(a.maskType=n.maskType),n?.rawDefinition&&(a.rawDefinition=n.rawDefinition),this._snapshot.clipMaskGroups.push(a),i}removeClipMaskGroup(e){if(!this._snapshot.clipMaskGroups)return!1;let t=this._snapshot.clipMaskGroups.length;return this._snapshot.clipMaskGroups=this._snapshot.clipMaskGroups.filter(n=>n.id!==e),this._snapshot.clipMaskGroups.length<t}addGuide(e,t,n){this._snapshot.guides||(this._snapshot.guides=[]);let i=T(),a={id:i,orientation:e,position:t,controlPointOffset:0};return n?.color&&(a.color=n.color),n?.opacity!==void 0&&(a.opacity=n.opacity),this._snapshot.guides.push(a),i}removeGuide(e){if(!this._snapshot.guides)return!1;let t=this._snapshot.guides.length;return this._snapshot.guides=this._snapshot.guides.filter(n=>n.id!==e),this._snapshot.guides.length<t}clearGuides(){return this._snapshot.guides=[],this}get guides(){return this._snapshot.guides??[]}addMeasurement(e,t,n){this._snapshot.measurements||(this._snapshot.measurements=[]);let i=T(),a={id:i,type:e,points:t,visible:n?.visible??!0,snapDivisions:n?.snapDivisions??1};return n?.color&&(a.color=n.color),n?.opacity!==void 0&&(a.opacity=n.opacity),this._snapshot.measurements.push(a),i}removeMeasurement(e){if(!this._snapshot.measurements)return!1;let t=this._snapshot.measurements.length;return this._snapshot.measurements=this._snapshot.measurements.filter(n=>n.id!==e),this._snapshot.measurements.length<t}get measurements(){return this._snapshot.measurements??[]}addCustomPattern(e,t,n,i){this._snapshot.customPatterns||(this._snapshot.customPatterns=[]);let a=T();return this._snapshot.customPatterns.push({id:a,name:e,svgContent:t,width:n,height:i}),a}removeCustomPattern(e){if(!this._snapshot.customPatterns)return!1;let t=this._snapshot.customPatterns.length;return this._snapshot.customPatterns=this._snapshot.customPatterns.filter(n=>n.id!==e),this._snapshot.customPatterns.length<t}get customPatterns(){return this._snapshot.customPatterns??[]}addGroup(e,t){this._snapshot.groups||(this._snapshot.groups=[]);let n=e??T();return this._snapshot.groups.push({id:n,parentId:t??null}),n}removeGroup(e){if(!this._snapshot.groups)return!1;let t=this._snapshot.groups.length;this._snapshot.groups=this._snapshot.groups.filter(n=>n.id!==e);for(let n of this._snapshot.shapes)n.state.groupId===e&&delete n.state.groupId;return this._snapshot.groups.length<t}moveToGroup(e,t){let n=this._snapshot.shapes.find(i=>i.id===e);return n&&(n.state.groupId=t),this}removeFromGroup(e){let t=this._snapshot.shapes.find(n=>n.id===e);return t&&delete t.state.groupId,this}bringToFront(e){let t=this._snapshot.shapes.findIndex(n=>n.id===e);if(t>=0){let[n]=this._snapshot.shapes.splice(t,1);this._snapshot.shapes.push(n)}return this}sendToBack(e){let t=this._snapshot.shapes.findIndex(n=>n.id===e);if(t>=0){let[n]=this._snapshot.shapes.splice(t,1);this._snapshot.shapes.unshift(n)}return this}reorder(e,t){let n=this._snapshot.shapes.findIndex(i=>i.id===e);if(n>=0){let[i]=this._snapshot.shapes.splice(n,1),a=Math.max(0,Math.min(t,this._snapshot.shapes.length));this._snapshot.shapes.splice(a,0,i)}return this}defineVariable(e,t,n,i){this._snapshot.templateVariables||(this._snapshot.templateVariables=[]);let a=this._snapshot.templateVariables.find(o=>o.name===e);if(a)a.type=t,a.defaultValue=n,i?.label!==void 0&&(a.label=i.label),i?.description!==void 0&&(a.description=i.description);else{let o={name:e,type:t,defaultValue:n};i?.label!==void 0&&(o.label=i.label),i?.description!==void 0&&(o.description=i.description),this._snapshot.templateVariables.push(o)}return this}removeVariable(e){return this._snapshot.templateVariables&&(this._snapshot.templateVariables=this._snapshot.templateVariables.filter(t=>t.name!==e)),this}get variables(){return this._snapshot.templateVariables??[]}inspectVariables(){return et(this._snapshot)}setTimeline(e){return"build"in e&&typeof e.build=="function"?this._snapshot.animationTimeline=e.build():this._snapshot.animationTimeline=e,this}clearTimeline(){return delete this._snapshot.animationTimeline,this}get timeline(){return this._snapshot.animationTimeline}toSVG(e){let{variables:t,...n}=e??{},i=Je(this._snapshot,t);return Se(i,n)}toJSON(e){return Ye(this._snapshot,e)}toSnapshot(){return JSON.parse(JSON.stringify(this._snapshot))}toCode(e,t){return Ct(this._snapshot,{...t,format:e})}_ensureMetadata(){this._snapshot.documentMetadata||(this._snapshot.documentMetadata={title:"",description:"",author:"",keywords:[],license:"",licenseUrl:"",language:"en",customMetadata:{}})}};var Lt=class{_track;constructor(e,t){this._track={id:T(),shapeId:e,property:t,keyframes:[],enabled:!0,locked:!1}}id(e){return this._track.id=e,this}keyframe(e,t,n="linear"){return this._track.keyframes.push({time:e,value:t,easing:n}),this}keyframeBezier(e,t,n){return this._track.keyframes.push({time:e,value:t,easing:"custom-bezier",customBezier:n}),this}keyframeLinear(e,t,n){return this._track.keyframes.push({time:e,value:t,easing:"linear-function",linearPoints:n}),this}keyframes(...e){return this._track.keyframes.push(...e),this}disabled(){return this._track.enabled=!1,this}locked(){return this._track.locked=!0,this}motionPath(e){return this._track.motionPath=e,this}motionPathRef(e,t="trackShape"){return this._track.motionPathRef={shapeId:e,mode:t},this}beginTrigger(e,t){return this._track.beginTrigger={type:e,value:t},this}endTrigger(e,t){return this._track.endTrigger={type:e,value:t},this}cycleDuration(e){return this._track.cycleDuration=e,this}cycleRepeats(e){return this._track.cycleRepeats=e,this}infinite(){return this._track.cycleInfinite=!0,this}cycle(e){return this._track.cycleBehavior=e,this}transformOrigin(e,t){return this._track.transformOrigin={x:e,y:t},this}motionRotate(e){return this._track.motionRotate=e,this}additive(e){return this._track.additive=e,this}build(){let e=[...this._track.keyframes].sort((t,n)=>t.time-n.time);return{...this._track,keyframes:e}}},Et=class{_duration;_loop=!1;_playbackSpeed=1;_tracks=[];constructor(e){this._duration=e}loop(e=!0){return this._loop=e,this}speed(e){return this._playbackSpeed=e,this}duration(e){return this._duration=e,this}addTrack(e){return this._tracks.push(e),this}addTracks(...e){return this._tracks.push(...e),this}buildTimeline(){return{duration:this._duration,loop:this._loop,playbackSpeed:this._playbackSpeed,tracks:this._tracks.map(e=>e.build())}}build(){let e=this.buildTimeline();return{duration:e.duration,loop:e.loop,playbackSpeed:e.playbackSpeed,tracks:e.tracks.map(t=>({id:t.id,shapeId:t.shapeId,property:t.property,enabled:t.enabled,locked:t.locked||void 0,motionPath:t.motionPath,motionPathRef:t.motionPathRef,beginTrigger:t.beginTrigger,endTrigger:t.endTrigger,cycleDuration:t.cycleDuration,cycleRepeats:t.cycleRepeats,cycleInfinite:t.cycleInfinite,cycleBehavior:t.cycleBehavior,transformOrigin:t.transformOrigin,motionRotate:t.motionRotate,additive:t.additive,keyframes:t.keyframes.map(n=>({time:n.time,value:n.value,easing:n.easing,...n.customBezier?{customBezier:n.customBezier}:{},...n.linearPoints?{linearPoints:n.linearPoints}:{}}))}))}}};var U=class{_id;_type;_state={};constructor(e,t){this._type=e,this._id=t??T()}id(e){return this._id=e,this}locked(e=!0){return this._state.locked=e,this}visible(e=!0){return this._state.visible=e,this}displayMode(e){return this._state.displayMode=e,this}motionOnly(){return this._state.displayMode="motionOnly",this}fill(e,t){return this._state.fillColor=e,this._state.fillType="solid",t!==void 0&&(this._state.fillOpacity=t),this}noFill(){return this._state.fillType="none",this}fillGradient(e){let t="build"in e?e.build():e;return this._state.fillType=t.type,this._state.fillGradient=t,this}fillPattern(e){let t="build"in e?e.build():e;return this._state.fillType="pattern",this._state.fillGradient=t,this}fillOpacity(e){return this._state.fillOpacity=e,this}fillRule(e){return this._state.fillRule=e,this}stroke(e,t){return this._state.borderColor=e,t!==void 0&&(this._state.borderWidth=t),this}noStroke(){return this._state.borderColor="none",this._state.borderWidth=0,this}strokeWidth(e){return this._state.borderWidth=e,this}strokeOpacity(e){return this._state.strokeOpacity=e,this}strokeGradient(e){let t="build"in e?e.build():e;return this._state.strokeType=t.type,this._state.strokeGradient=t,this}strokePattern(e){let t="build"in e?e.build():e;return this._state.strokeType="pattern",this._state.strokeGradient=t,this}strokeLinejoin(e){return this._state.strokeLinejoin=e,this}strokeLinecap(e){return this._state.strokeLinecap=e,this}strokeMiterlimit(e){return this._state.strokeMiterlimit=e,this}dashOffset(e){return this._state.dashOffset=e,this}strokeDasharray(e){return this._state.strokeDasharray=e,this}dash(e,t,n){return this._state.lineStyle=e,e==="custom"&&(t!==void 0&&(this._state.dashLength=t),n!==void 0&&(this._state.gapLength=n)),this}opacity(e){return this._state.opacity=e,this}rotate(e){return this._state.rotation=e,this.refreshTransformMatrix(),this}skew(e,t){return this._state.skewX=e,this._state.skewY=t,this.refreshTransformMatrix(),this}scale(e,t){return this._state.scaleX=e,this._state.scaleY=t??e,this.refreshTransformMatrix(),this}pivot(e,t){return this._state.customPivot={x:e,y:t},this.refreshTransformMatrix(),this}transformMatrix(e){if(e.length<6||!e.slice(0,6).every(Number.isFinite))throw new RangeError("transformMatrix must contain six finite numbers");return this._state.transformMatrix=e.slice(0,6),this}refreshTransformMatrix(){this._state.transformMatrix=ue(Te(this._state,this.defaultTransformPivot()))}defaultTransformPivot(){let e=this._state.customPivot;if(e)return e;let t=this._state.x,n=this._state.y,i=this._state.width,a=this._state.height;if(t!==void 0&&n!==void 0&&i!==void 0&&a!==void 0)return{x:t+i/2,y:n+a/2};let o=this._state.radius;if(t!==void 0&&n!==void 0&&o!==void 0)return{x:t,y:n};let l=this._state.cx,u=this._state.cy;if(l!==void 0&&u!==void 0)return{x:l,y:u};let c=this._state.x1,f=this._state.y1,d=this._state.x2,m=this._state.y2;if(c!==void 0&&f!==void 0&&d!==void 0&&m!==void 0)return{x:(c+d)/2,y:(f+m)/2};let p=this._state.pathPoints;if(p?.[0])return{x:p[0].x,y:p[0].y};let b=this._state.polylinePoints;if(b?.[0])return b[0]}filter(...e){let t=this._state.filters??[];return this._state.filters=[...t,...e],this}dropShadow(e={}){let t={id:`drop-shadow-${T()}`,type:"drop-shadow",enabled:!0,offsetX:e.offsetX??4,offsetY:e.offsetY??4,blurRadius:e.blurRadius??8,spread:e.spread??0,color:e.color??"#000000",opacity:e.opacity??.3};return this.filter(t)}innerShadow(e={}){let t={id:`inner-shadow-${T()}`,type:"inner-shadow",enabled:!0,offsetX:e.offsetX??2,offsetY:e.offsetY??2,blurRadius:e.blurRadius??4,choke:e.choke??0,color:e.color??"#000000",opacity:e.opacity??.5};return this.filter(t)}blur(e,t,n){let i=e??4,a=t??i,o={id:`gaussian-blur-${T()}`,type:"gaussian-blur",enabled:!0,blurX:i,blurY:a,linked:i===a,quality:n?.quality??"normal"};return this.filter(o)}glow(e={}){let t={id:`glow-${T()}`,type:"glow",enabled:!0,color:e.color??"#ffffff",radius:e.radius??10,intensity:e.intensity??.8};return this.filter(t)}innerGlow(e={}){let t={id:`inner-glow-${T()}`,type:"inner-glow",enabled:!0,color:e.color??"#ffffff",radius:e.radius??10,intensity:e.intensity??.8};return this.filter(t)}grayscale(e=1){let t={id:`grayscale-${T()}`,type:"grayscale",enabled:!0,amount:e};return this.filter(t)}sepia(e=1){let t={id:`sepia-${T()}`,type:"sepia",enabled:!0,amount:e};return this.filter(t)}outline(e={}){return this.filter({id:`outline-${T()}`,type:"outline",enabled:!0,width:e.width??3,color:e.color??"#000000",opacity:e.opacity??1,position:e.position??"outside"})}motionBlur(e={}){let t={id:`motion-blur-${T()}`,type:"motion-blur",enabled:!0,distance:e.distance??10,angle:e.angle??0,quality:e.quality??"normal"};return this.filter(t)}pointLight(e={}){let t={id:`point-light-${T()}`,type:"point-light",enabled:!0,x:e.x??100,y:e.y??100,z:e.z??200,color:e.color??"#ffffff",surfaceScale:e.surfaceScale??5,diffuseConstant:e.diffuseConstant??1,specularConstant:e.specularConstant??1,specularExponent:e.specularExponent??20};return this.filter(t)}spotLight(e={}){let t={id:`spot-light-${T()}`,type:"spot-light",enabled:!0,x:e.x??100,y:e.y??0,z:e.z??200,pointsAtX:e.pointsAtX??100,pointsAtY:e.pointsAtY??100,pointsAtZ:e.pointsAtZ??0,coneAngle:e.coneAngle??30,color:e.color??"#ffffff",surfaceScale:e.surfaceScale??5,specularConstant:e.specularConstant??1,specularExponent:e.specularExponent??20};return this.filter(t)}sharpen(e=1){let t={id:`sharpen-${T()}`,type:"sharpen",enabled:!0,amount:e};return this.filter(t)}pixelate(e=8){let t={id:`pixelate-${T()}`,type:"pixelate",enabled:!0,blockSize:e};return this.filter(t)}warp(e={}){let t={id:`warp-${T()}`,type:"warp",enabled:!0,scale:e.scale??10,frequency:e.frequency??.02,octaves:e.octaves??1,warpType:e.warpType??"turbulence"};return this.filter(t)}morphology(e={}){let t=e.radiusX??2,n=e.radiusY??t,i={id:`morphology-${T()}`,type:"morphology",enabled:!0,operator:e.operator??"dilate",radiusX:t,radiusY:n,linked:e.linked??t===n};return this.filter(i)}contouring(e={}){if((e.mode??"discrete")==="table"){let i={id:`contouring-table-${T()}`,type:"contouring-table",enabled:!0,levels:e.levels??4,contrast:e.contrast??1};return this.filter(i)}let n={id:`contouring-discrete-${T()}`,type:"contouring-discrete",enabled:!0,levels:e.levels??4};return this.filter(n)}roundEdges(e=4){let t={id:`round-edges-${T()}`,type:"round-edges",enabled:!0,radius:e};return this.filter(t)}channelPainter(e={}){let t={id:`channel-painter-${T()}`,type:"channel-painter",enabled:!0,red:e.red??1,green:e.green??1,blue:e.blue??1};return this.filter(t)}brightness(e=1){let t={id:`brightness-${T()}`,type:"brightness",enabled:!0,amount:e};return this.filter(t)}contrast(e=1){let t={id:`contrast-${T()}`,type:"contrast",enabled:!0,amount:e};return this.filter(t)}filterOpacity(e=1){let t={id:`opacity-${T()}`,type:"opacity",enabled:!0,amount:e};return this.filter(t)}invert(e=1){let t={id:`invert-${T()}`,type:"invert",enabled:!0,amount:e};return this.filter(t)}hueRotate(e=0){let t={id:`hue-rotate-${T()}`,type:"hue-rotate",enabled:!0,angle:e};return this.filter(t)}saturate(e=1){let t={id:`saturate-${T()}`,type:"saturate",enabled:!0,amount:e};return this.filter(t)}blackAndWhite(e=.5){let t={id:`black-and-white-${T()}`,type:"black-and-white",enabled:!0,threshold:e};return this.filter(t)}duotone(e={}){let t={id:`duotone-${T()}`,type:"duotone",enabled:!0,shadowColor:e.shadowColor??"#000000",highlightColor:e.highlightColor??"#ffffff"};return this.filter(t)}xray(e=1){let t={id:`xray-${T()}`,type:"xray",enabled:!0,intensity:e};return this.filter(t)}noise(e={}){let t={id:`noise-${T()}`,type:"noise",enabled:!0,amount:e.amount??.3,scale:e.scale??1};return this.filter(t)}emboss(e={}){let t={id:`emboss-${T()}`,type:"emboss",enabled:!0,strength:e.strength??1,angle:e.angle??135};return this.filter(t)}filmGrain(e={}){let t={id:`film-grain-${T()}`,type:"film-grain",enabled:!0,amount:e.amount??.3,size:e.size??1};return this.filter(t)}watercolor(e={}){let t={id:`watercolor-${T()}`,type:"watercolor",enabled:!0,wetness:e.wetness??.5,turbulence:e.turbulence??.5};return this.filter(t)}gouache(e={}){let t={id:`gouache-${T()}`,type:"gouache",enabled:!0,thickness:e.thickness??.5,texture:e.texture??.5};return this.filter(t)}inkBlot(e={}){let t={id:`ink-blot-${T()}`,type:"ink-blot",enabled:!0,spread:e.spread??.5,edges:e.edges??.5};return this.filter(t)}crumpledPlastic(e={}){let t={id:`crumpled-plastic-${T()}`,type:"crumpled-plastic",enabled:!0,wrinkles:e.wrinkles??.5,shine:e.shine??.5};return this.filter(t)}riddled(e={}){let t={id:`riddled-${T()}`,type:"riddled",enabled:!0,density:e.density??.5,size:e.size??1};return this.filter(t)}cssClipPath(e){return this._state.cssClipPath=e,this}cssMaskProperties(e){return this._state.cssMaskProperties=e,this}vectorEffect(e){return this._state.vectorEffect=e,this}transformBox(e){return this._state.transformBox=e,this}paintOrder(e){return this._state.paintOrder=e,this}blendMode(e){return this._state.blendMode=e,this}visibility(e){return this._state.visibility=e,this}shapeRendering(e){return this._state.shapeRendering=e,this}filterColorInterpolation(e){return this._state.filterColorInterpolation=e,this}inheritFill(e=!0){return this._state.inheritFill=e,this}inheritStroke(e=!0){return this._state.inheritStroke=e,this}systemLanguage(e){return this._state.systemLanguage=e,this}requiredExtensions(e){return this._state.requiredExtensions=e,this}fillLibrary(e,t="linear-gradient"){return this._state.fillLibraryId=e,this._state.fillType=t,this}strokeLibrary(e,t="linear-gradient"){return this._state.strokeLibraryId=e,this._state.strokeType=t,this}filterLibrary(...e){let t=this._state.filterLibraryIds??[];return this._state.filterLibraryIds=[...t,...e],this}markerStartRef(e){return this._state.markerStart=e,this}markerMidRef(e){return this._state.markerMid=e,this}markerEndRef(e){return this._state.markerEnd=e,this}bind(e,t){let n=this._state.bindings??{};return this._state.bindings={...n,[e]:t},this}metadata(e){return this._state.metadata={...this._state.metadata,...e},this}group(e){return this._state.groupId=e,this}build(){return{id:this._id,type:this._type,state:{...this._state}}}},Dt=class extends U{constructor(e,t,n){if(n<0)throw new RangeError("Circle radius must be non-negative");super("circle"),this._state.x=e,this._state.y=t,this._state.radius=n}position(e,t){return this._state.x=e,this._state.y=t,this}radius(e){return this._state.radius=e,this}},Bt=class extends U{constructor(e,t,n,i){if(n<0||i<0)throw new RangeError("Ellipse radii must be non-negative");super("ellipse"),this._state.cx=e,this._state.cy=t,this._state.rx=n,this._state.ry=i}position(e,t){return this._state.cx=e,this._state.cy=t,this}radii(e,t){return this._state.rx=e,this._state.ry=t,this}},Ot=class extends U{constructor(e,t,n,i){if(n<0||i<0)throw new RangeError("Rectangle dimensions must be non-negative");super("rectangle"),this._state.x=e,this._state.y=t,this._state.width=n,this._state.height=i}position(e,t){return this._state.x=e,this._state.y=t,this}size(e,t){return this._state.width=e,this._state.height=t,this}cornerRadius(e){return this._state.cornerRadius=e,this._state.rx=e,this._state.ry=e,this}radii(e,t){return this._state.rx=e,this._state.ry=t,e===t&&(this._state.cornerRadius=e),this}},Gt=class extends U{constructor(e,t,n){if(n<0)throw new RangeError("Square size must be non-negative");super("square"),this._state.x=e,this._state.y=t,this._state.width=n,this._state.height=n}position(e,t){return this._state.x=e,this._state.y=t,this}size(e){return this._state.width=e,this._state.height=e,this}cornerRadius(e){return this._state.cornerRadius=e,this._state.rx=e,this._state.ry=e,this}radii(e,t){return this._state.rx=e,this._state.ry=t,e===t&&(this._state.cornerRadius=e),this}},zt=class extends U{constructor(e,t,n,i){super("line"),this._state.x1=e,this._state.y1=t,this._state.x2=n,this._state.y2=i}from(e,t){return this._state.x1=e,this._state.y1=t,this}to(e,t){return this._state.x2=e,this._state.y2=t,this}markerStart(e){return this._state.startEndpoint=e,this}markerEnd(e){return this._state.endEndpoint=e,this}markers(e,t){return this._state.startEndpoint=e,this._state.endEndpoint=t,this}},Ut=class extends U{constructor(e,t,n){super("text"),this._state.x=e,this._state.y=t,this._state.text=n}position(e,t){return this._state.x=e,this._state.y=t,this}content(e){return this._state.text=e,this}fontSize(e){return this._state.fontSize=e,this}fontFamily(e){return this._state.fontFamily=e,this}fontWeight(e){return this._state.fontWeight=e,this}fontStyle(e){return this._state.fontStyle=e,this}fontVariant(e){return this._state.fontVariant=e,this}fontVariantLigatures(e){return this._state.fontVariantLigatures=e,this}fontVariantPosition(e){return this._state.fontVariantPosition=e,this}fontVariantCaps(e){return this._state.fontVariantCaps=e,this}fontVariantNumeric(e){return this._state.fontVariantNumeric=e,this}fontVariantEastAsian(e){return this._state.fontVariantEastAsian=e,this}anchor(e){return this._state.textAnchor=e,this}letterSpacing(e){return this._state.letterSpacing=e,this}lineHeight(e){return this._state.lineHeight=e,this}decoration(e){return this._state.textDecoration=e,this}transform(e){return this._state.textTransform=e,this}textPath(e,t=0){return this._state.isTextPath=!0,this._state.textPathPoints=e,this._state.textPathStartOffset=t,this}textPathOffset(e){return this._state.textPathStartOffset=e,this}textPathSide(e){return this._state.textPathSide=e,this}direction(e){return this._state.textDirection=e,this}unicodeBidi(e){return this._state.unicodeBidi=e,this}dominantBaseline(e){return this._state.dominantBaseline=e,this}writingMode(e){return this._state.writingMode=e,this}wordSpacing(e){return this._state.wordSpacing=e,this}baselineShift(e){return this._state.baselineShift=e,this}inlineSize(e){return this._state.inlineSize=e,this}overflowWrap(e){return this._state.overflowWrap=e,this}whiteSpace(e){return this._state.whiteSpace=e,this}fontVariationSettings(e){return this._state.fontVariationSettings=e,this}charOffsets(e){return this._state.charOffsets=e,this}shapeInsideRef(e){return this._state.shapeInsideRef=e,this}shapePadding(e){return this._state.shapePadding=e,this}richTextData(e){return this._state.richTextData=e,this}useRichText(e=!0){return this._state.useRichText=e,this}linePositions(e){return this._state.linePositions=e,this}textLength(e){return this._state.textLength=e,this}lengthAdjust(e){return this._state.lengthAdjust=e,this}},X=class extends U{constructor(e,t,n,i){super(e),this._state.cx=t,this._state.cy=n,this._state.radius=i}position(e,t){return this._state.cx=e,this._state.cy=t,this}radius(e){return this._state.radius=e,this}shiftAngle(e){return this._state.shiftAngle=e,this}cornerRadius(e){return this._state.cornerRadius=e,this}},Nt=class extends X{constructor(e,t,n){super("triangle",e,t,n)}},Vt=class extends X{constructor(e,t,n,i=5){super("ngon",e,t,n),this._state.sides=i}sides(e){return this._state.sides=e,this}},Ht=class extends X{constructor(e,t,n){super("star",e,t,n),this._state.arms=5,this._state.innerRadiusPercent=40}arms(e){return this._state.arms=e,this}innerRadius(e){return this._state.innerRadiusPercent=e,this}},Wt=class extends X{constructor(e,t,n){super("cross",e,t,n),this._state.armWidthPercent=35}armWidth(e){return this._state.armWidthPercent=e,this}},Xt=class extends X{constructor(e,t,n){super("ring",e,t,n),this._state.innerRadiusPercent=60}innerRadius(e){return this._state.innerRadiusPercent=e,this}},jt=class extends X{constructor(e,t,n){super("spiral",e,t,n),this._state.turns=3,this._state.thicknessPercent=15,this._state.spiralDirection=1}turns(e){return this._state.turns=e,this}thickness(e){return this._state.thicknessPercent=e,this}direction(e){return this._state.spiralDirection=e,this}},Yt=class extends X{constructor(e,t,n){super("gear",e,t,n),this._state.teeth=8,this._state.toothDepthPercent=25}teeth(e){return this._state.teeth=e,this}toothDepth(e){return this._state.toothDepthPercent=e,this}holeRadius(e){return this._state.holeRadiusPercent=e,this}},qt=class extends X{constructor(e,t,n){super("arrow",e,t,n),this._state.headWidthPercent=100,this._state.headLengthPercent=35,this._state.shaftWidthPercent=35}headWidth(e){return this._state.headWidthPercent=e,this}headLength(e){return this._state.headLengthPercent=e,this}shaftWidth(e){return this._state.shaftWidthPercent=e,this}},Zt=class extends X{constructor(e,t,n){super("heart",e,t,n),this._state.lobeRadiusPercent=50,this._state.cleftDepthPercent=25}lobeRadius(e){return this._state.lobeRadiusPercent=e,this}cleftDepth(e){return this._state.cleftDepthPercent=e,this}},Kt=class extends X{constructor(e,t,n){super("lightning",e,t,n),this._state.boltSegments=3,this._state.boltJaggednessPercent=40,this._state.boltWidthPercent=30}segments(e){return this._state.boltSegments=e,this}jaggedness(e){return this._state.boltJaggednessPercent=e,this}thickness(e){return this._state.boltWidthPercent=e,this}},Qt=class extends X{constructor(e,t,n){super("cloud",e,t,n),this._state.cloudBumps=5,this._state.cloudPuffinessPercent=60}bumps(e){return this._state.cloudBumps=e,this}puffiness(e){return this._state.cloudPuffinessPercent=e,this}},Jt=class extends X{constructor(e,t,n){super("speechBubble",e,t,n),this._state.tailAngleDeg=45,this._state.tailLengthPercent=40,this._state.tailWidthPercent=25}tailAngle(e){return this._state.tailAngleDeg=e,this}tailLength(e){return this._state.tailLengthPercent=e,this}tailWidth(e){return this._state.tailWidthPercent=e,this}},ce=class extends U{add(e){let t="build"in e&&typeof e.build=="function"?e.build():e,n=this._state.children??[];return this._state.children=[...n,t],this}addAll(...e){for(let t of e)this.add(t);return this}children(e){return this._state.children=e.map(t=>"build"in t&&typeof t.build=="function"?t.build():t),this}},er=class extends ce{constructor(e){super("hyperlink"),e!==void 0&&(this._state.href=e)}href(e){return this._state.href=e,this}hrefXlink(e){return this._state.hrefXlink=e,this}target(e){return this._state.linkTarget=e,this}download(e){return this._state.linkDownload=e,this}rel(e){return this._state.linkRel=e,this}ping(e){return this._state.linkPing=e,this}hreflang(e){return this._state.linkHreflang=e,this}type(e){return this._state.linkType=e,this}referrerPolicy(e){return this._state.linkReferrerPolicy=e,this}},tr=class extends ce{constructor(){super("switch")}},rr=class extends ce{constructor(){super("container")}},nr=class extends U{constructor(e){super("view"),e&&(this._state.viewBoxX=e.x,this._state.viewBoxY=e.y,this._state.viewBoxWidth=e.width,this._state.viewBoxHeight=e.height)}viewBox(e,t,n,i){return this._state.viewBoxX=e,this._state.viewBoxY=t,this._state.viewBoxWidth=n,this._state.viewBoxHeight=i,this}name(e){return this._state.viewName=e,this}preserveAspectRatio(e){return this._state.viewPreserveAspectRatio=e,this}zoomAndPan(e){return this._state.viewZoomAndPan=e,this}viewTarget(e){return this._state.viewTarget=e,this}asHome(e=!0){return this}},ir=class extends ce{constructor(e=0,t=0,n=100,i=100){super("svg"),this._state.svgX=e,this._state.svgY=t,this._state.svgWidth=n,this._state.svgHeight=i}position(e,t){return this._state.svgX=e,this._state.svgY=t,this}size(e,t){return this._state.svgWidth=e,this._state.svgHeight=t,this}viewBox(e,t,n,i){return this._state.svgViewBoxX=e,this._state.svgViewBoxY=t,this._state.svgViewBoxWidth=n,this._state.svgViewBoxHeight=i,this}preserveAspectRatio(e){return this._state.svgPreserveAspectRatio=e,this}asRoot(e=!0){return this._state.isRootSvg=e,this}},sr=class extends U{constructor(e){super("shape-reference"),e!==void 0&&(this._state.targetShapeId=e)}target(e){return this._state.targetShapeId=e,this}offset(e,t){return this._state.offsetX=e,this._state.offsetY=t,this}size(e,t){return this._state.width=e,this._state.height=t,this}},ar=class extends U{position(e,t){return this._state.x=e,this._state.y=t,this}size(e,t){return this._state.width=e,this._state.height=t,this}src(e){return this._state.href=e,this}mimeType(e){return this._state.mediaMimeType=e,this}naturalDuration(e){return this._state.naturalDuration=e,this}begin(e){return this._state.begin=e,this}trim(e,t){return this._state.trimStart=e,this._state.trimEnd=t,this}volume(e){return this._state.volume=e,this}muted(e=!0){return this._state.muted=e,this}loop(e=!0){return this._state.loop=e,this}playbackRate(e){return this._state.playbackRate=e,this}fade(e,t){return this._state.fadeInDuration=e,this._state.fadeOutDuration=t,this}language(e){return this._state.systemLanguage=e,this}},or=class extends ar{constructor(e){super("video"),this._state.mediaKind="video",e!==void 0&&(this._state.href=e)}poster(e){return this._state.posterHref=e,this}sourceRect(e){return this._state.sourceRect=e,this}},lr=class extends ar{constructor(e){super("audio"),this._state.mediaKind="audio",e!==void 0&&(this._state.href=e)}},ur=class extends U{constructor(e=[]){super("path"),this._state.pathPoints=[...e],this._state.pathCurveType="cubic",this._state.pathClosed=!1}points(e){return this._state.pathPoints=[...e],this}addPoint(e,t){let n=this._state.pathPoints??[];return n.push({x:e,y:t}),this._state.pathPoints=n,this}curveType(e){return this._state.pathCurveType=e,this}closed(e=!0){return this._state.pathClosed=e,this}tension(e){return this._state.pathTension=e,this}arcParams(e){return this._state.pathArcParams=e,this}markerStart(e){return this._state.startEndpoint=e,this}markerEnd(e){return this._state.endEndpoint=e,this}markers(e,t){return this._state.startEndpoint=e,this._state.endEndpoint=t,this}toD(){let e=this._state.pathPoints??[],t=this._state.pathCurveType??"CUBIC",n=this._state.pathClosed??!1,i=this._state.pathTension??.5,a=this._state.pathArcParams;return ye(e,t,n,i,a)}},cr=class extends U{constructor(e=[]){super("polyline"),this._state.polylinePoints=[...e],this._state.polylineClosed=!1}points(e){return this._state.polylinePoints=[...e],this}addPoint(e,t){let n=this._state.polylinePoints??[];return n.push({x:e,y:t}),this._state.polylinePoints=n,this}closed(e=!0){return this._state.polylineClosed=e,this}markerStart(e){return this._state.startEndpoint=e,this}markerEnd(e){return this._state.endEndpoint=e,this}markers(e,t){return this._state.startEndpoint=e,this._state.endEndpoint=t,this}},dr=class extends U{constructor(e,t,n,i,a){super("image"),this._state.x=e,this._state.y=t,this._state.width=n,this._state.height=i,this._state.href=a}position(e,t){return this._state.x=e,this._state.y=t,this}size(e,t){return this._state.width=e,this._state.height=t,this}src(e){return this._state.href=e,this}preserveAspectRatio(e){return this._state.preserveAspectRatio=e,this}};var De=class{_x1;_y1;_x2;_y2;_stops=[];_spreadMethod="pad";_opacity=1;_id;constructor(e=0,t=0,n=1,i=0){this._x1=e,this._y1=t,this._x2=n,this._y2=i,this._id=T()}stop(e,t,n=1){return this._stops.push({offset:e,color:t,opacity:n}),this}direction(e,t,n,i){return this._x1=e,this._y1=t,this._x2=n,this._y2=i,this}spread(e){return this._spreadMethod=e,this}opacity(e){return this._opacity=e,this}build(){return{type:"linear-gradient",id:this._id,x1:this._x1,y1:this._y1,x2:this._x2,y2:this._y2,stops:[...this._stops],spreadMethod:this._spreadMethod,opacity:this._opacity}}},Be=class{_cx=.5;_cy=.5;_fx=.5;_fy=.5;_r=.5;_ry=.5;_rotation=0;_stops=[];_spreadMethod="pad";_opacity=1;_id;constructor(){this._id=T()}center(e,t){return this._cx=e,this._cy=t,this}focus(e,t){return this._fx=e,this._fy=t,this}radius(e,t){return this._r=e,this._ry=t??e,this}rotation(e){return this._rotation=e,this}stop(e,t,n=1){return this._stops.push({offset:e,color:t,opacity:n}),this}spread(e){return this._spreadMethod=e,this}opacity(e){return this._opacity=e,this}build(){return{type:"radial-gradient",id:this._id,cx:this._cx,cy:this._cy,fx:this._fx,fy:this._fy,r:this._r,ry:this._ry,rotation:this._rotation,stops:[...this._stops],spreadMethod:this._spreadMethod,opacity:this._opacity}}},Oe=class{_patternType;_color;_backgroundColor;_scale=1;_rotation=0;_opacity=1;_patternParams;_id;_svgContent;_width;_height;_patternUnits;_patternContentUnits;_patternTransform;_viewBox;_preserveAspectRatio;_x;_y;_customPatternId;constructor(e="stripes",t="#000000",n="#ffffff"){this._patternType=e,this._color=t,this._backgroundColor=n,this._id=T()}scale(e){return this._scale=e,this}rotation(e){return this._rotation=e,this}opacity(e){return this._opacity=e,this}params(e){return this._patternParams=e,this}svgContent(e){return this._svgContent=e,this}size(e,t){return this._width=e,this._height=t,this}patternUnits(e){return this._patternUnits=e,this}patternContentUnits(e){return this._patternContentUnits=e,this}patternTransform(e){return this._patternTransform=e,this}viewBox(e){return this._viewBox=e,this}preserveAspectRatio(e){return this._preserveAspectRatio=e,this}position(e,t){return this._x=e,this._y=t,this}customPatternId(e){return this._customPatternId=e,this}build(){let e,t,n;if(this._svgContent!==void 0)e=this._svgContent,t=this._width??10,n=this._height??10;else{let a=xt(this._patternType,this._scale,this._color,this._backgroundColor,this._patternParams);e=a.svgContent,t=this._width??a.width,n=this._height??a.height}let i={type:"pattern",id:this._id,patternType:this._svgContent!==void 0?"custom":this._patternType,color:this._color,backgroundColor:this._backgroundColor,scale:this._scale,rotation:this._rotation,opacity:this._opacity,svgContent:e,width:t,height:n,patternUnits:this._patternUnits??"userSpaceOnUse",patternParams:this._patternParams,patternTransform:this._patternTransform??(this._rotation?`rotate(${this._rotation})`:void 0)};return this._patternContentUnits&&(i.patternContentUnits=this._patternContentUnits),this._viewBox&&(i.viewBox=this._viewBox),this._preserveAspectRatio&&(i.preserveAspectRatio=this._preserveAspectRatio),this._x!==void 0&&(i.x=this._x),this._y!==void 0&&(i.y=this._y),this._customPatternId&&(i.customPatternId=this._customPatternId),i}};function zn(r=0,e=0,t=1,n=0){return new De(r,e,t,n)}function Un(){return new Be}function Nn(r="stripes",e="#000000",t="#ffffff"){return new Oe(r,e,t)}var tn={rows:4,cols:4,style:"classic",tabDepthPercent:20,tabPattern:"random",seed:1},Wa=.04,Xa=0;function ja(r){let e=r>>>0;return()=>{e=e+1831565813>>>0;let t=e;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}}function F(r){return Number(r.toFixed(3)).toString()}function Ya(r,e,t,n,i,a,o,l,u,c,f,d){return[[0,0],[.2,l],[.5+u+f,-a+c],[.5-a+u,a+c],[.5-2*a+u-f,3*a+c],[.5+2*a+u-f,3*a+c],[.5+a+u,a+c],[.5+u+f,-a+c],[.8,d],[1,0]].map(([p,b])=>{let g=e+p*n,y=t+b*i*o;return r?{x:g,y}:{x:y,y:g}})}function Vn(r,e,t,n,i,a,o,l,u,c,f){let d=[],m=(P,_)=>u==="alternating"?0:P+c()*(_-P),p=()=>c()<.5,b=m(-l,l),g=u==="alternating"?f%2===0:p(),y=null,S=b,v=m(-l,l),x=m(-l,l),k=m(-l,l);b=m(-l,l);for(let P=0;P<r;P++){P>0&&(y=g,g=u==="alternating"?(f+P)%2===0:p(),S=g===y?-b:b,v=m(-l,l),x=m(-l,l),k=m(-l,l),b=m(-l,l));let _=g?-1:1,$=t+P*i;d.push(Ya(e,$,n,i,a,o,_,S,v,x,k,b))}return d}function Hn(r,e,t,n,i,a,o){let l=2*a;return[[0,0],[.2,0],[.4,0],[.4,l],[.4,l],[.6,l],[.6,l],[.6,0],[.8,0],[1,0]].map(([c,f])=>{let d=e+c*n,m=t+f*i*o;return r?{x:d,y:m}:{x:m,y:d}})}function Wn(r,e){return r+` C ${F(e[1].x)} ${F(e[1].y)} ${F(e[2].x)} ${F(e[2].y)} ${F(e[3].x)} ${F(e[3].y)} C ${F(e[4].x)} ${F(e[4].y)} ${F(e[5].x)} ${F(e[5].y)} ${F(e[6].x)} ${F(e[6].y)} C ${F(e[7].x)} ${F(e[7].y)} ${F(e[8].x)} ${F(e[8].y)} ${F(e[9].x)} ${F(e[9].y)}`}function Xn(r,e){return r+` C ${F(e[8].x)} ${F(e[8].y)} ${F(e[7].x)} ${F(e[7].y)} ${F(e[6].x)} ${F(e[6].y)} C ${F(e[5].x)} ${F(e[5].y)} ${F(e[4].x)} ${F(e[4].y)} ${F(e[3].x)} ${F(e[3].y)} C ${F(e[2].x)} ${F(e[2].y)} ${F(e[1].x)} ${F(e[1].y)} ${F(e[0].x)} ${F(e[0].y)}`}function jn(r,e={}){let t={...tn,...e};if(t.rows<1||t.cols<1)throw new Error("generatePuzzlePieces: rows and cols must be >= 1");if(!Number.isFinite(r.width)||!Number.isFinite(r.height))throw new Error("generatePuzzlePieces: bounds must have finite width/height");if(r.width<=0||r.height<=0)throw new Error("generatePuzzlePieces: bounds must have positive width/height");let{rows:n,cols:i,style:a,tabDepthPercent:o,tabPattern:l,seed:u}=t,c=ja(u),f=r.width/i,d=r.height/n,m=Math.max(0,Math.min(.4,o/200)),p=(a==="classic"||a==="curved")&&m>0,b=a==="square-tabs"&&m>0,g=a==="classic"&&l==="random"?Wa:Xa,y=[];for(let x=0;x<n-1;x++){let k=r.y+(x+1)*d;if(p)y.push(Vn(i,!0,r.x,k,f,d,m,g,l,c,x));else if(b){let P=[];for(let _=0;_<i;_++){let $=l==="alternating"?(x+_)%2===0?1:-1:c()<.5?1:-1;P.push(Hn(!0,r.x+_*f,k,f,d,m,$))}y.push(P)}else y.push(new Array(i).fill(null))}let S=[];for(let x=0;x<i-1;x++){let k=r.x+(x+1)*f;if(p)S.push(Vn(n,!1,r.y,k,d,f,m,g,l,c,x));else if(b){let P=[];for(let _=0;_<n;_++){let $=l==="alternating"?(_+x)%2===0?1:-1:c()<.5?1:-1;P.push(Hn(!1,r.y+_*d,k,d,f,m,$))}S.push(P)}else S.push(new Array(n).fill(null))}let v=[];for(let x=0;x<n;x++)for(let k=0;k<i;k++){let P=r.x+k*f,_=r.y+x*d,$=P+f,w=_+d,M=`M ${F(P)} ${F(_)}`;if(x===0)M+=` L ${F($)} ${F(_)}`;else{let I=y[x-1][k];I?M=Wn(M,I):M+=` L ${F($)} ${F(_)}`}if(k===i-1)M+=` L ${F($)} ${F(w)}`;else{let I=S[k][x];I?M=Wn(M,I):M+=` L ${F($)} ${F(w)}`}if(x===n-1)M+=` L ${F(P)} ${F(w)}`;else{let I=y[x][k];I?M=Xn(M,I):M+=` L ${F(P)} ${F(w)}`}if(k===0)M+=` L ${F(P)} ${F(_)}`;else{let I=S[k-1][x];I?M=Xn(M,I):M+=` L ${F(P)} ${F(_)}`}M+=" Z",v.push({id:`puzzle-${u}-r${x}-c${k}`,row:x,col:k,d:M})}return v}var Zn=[1,2,3,4,5,6,7,8,9],qa={easy:{minGivens:40,maxGivens:45,maxRating:"singles"},medium:{minGivens:34,maxGivens:39,maxRating:"hidden-singles"},hard:{minGivens:28,maxGivens:33,maxRating:"search"},expert:{minGivens:24,maxGivens:27,maxRating:"search"}};function Ge(r){return r.map(e=>[...e])}function Za(){return Array.from({length:9},()=>Array.from({length:9},()=>0))}function Kn(r){let e=r>>>0;return()=>{e=e+1831565813>>>0;let t=e;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}}function Qn(r,e){let t=[...r];for(let n=t.length-1;n>0;n--){let i=Math.floor(e()*(n+1));[t[n],t[i]]=[t[i],t[n]]}return t}function ke(r){return 1<<r-1}function Jn(r){let e=0,t=r;for(;t;)t&=t-1,e++;return e}function Ka(r){for(let e=1;e<=9;e++)if(r===ke(e))return e;return 0}function nn(r,e){return Math.floor(r/3)*3+Math.floor(e/3)}function rn(r){let e=0;for(let t of r)for(let n of t)n!==0&&e++;return e}function Qa(r){if(!Number.isFinite(r))return 1;let e=Math.floor(r);return e===0?1:e}function ei(r,e){if(!Array.isArray(r)||r.length!==9)return e.push("Grid must contain 9 rows."),!1;let t=!0;for(let n=0;n<9;n++){if(!Array.isArray(r[n])||r[n].length!==9){e.push(`Row ${n+1} must contain 9 cells.`),t=!1;continue}for(let i=0;i<9;i++){let a=r[n][i];(!Number.isInteger(a)||a<0||a>9)&&(e.push(`Cell R${n+1}C${i+1} must be a digit from 0 to 9.`),t=!1)}}return t}function ti(r,e){let t=!0,n=(i,a)=>{let o=0;for(let l of a){if(l===0)continue;let u=ke(l);if(o&u){e.push(`${i} contains duplicate ${l}.`),t=!1;return}o|=u}};for(let i=0;i<9;i++)n(`Row ${i+1}`,r[i]);for(let i=0;i<9;i++)n(`Column ${i+1}`,r.map(a=>a[i]));for(let i=0;i<9;i+=3)for(let a=0;a<9;a+=3){let o=[];for(let l=i;l<i+3;l++)for(let u=a;u<a+3;u++)o.push(r[l][u]);n(`Box ${Math.floor(i/3)*3+Math.floor(a/3)+1}`,o)}return t}function sn(r){let e=Array.from({length:9},()=>0),t=Array.from({length:9},()=>0),n=Array.from({length:9},()=>0);for(let i=0;i<9;i++)for(let a=0;a<9;a++){let o=r[i][a];if(o===0)continue;let l=ke(o),u=nn(i,a);if(e[i]&l||t[a]&l||n[u]&l)return null;e[i]|=l,t[a]|=l,n[u]|=l}return{rows:e,cols:t,boxes:n}}function an(r,e,t,n,i){return 511&~(t[r]|n[e]|i[nn(r,e)])}function ri(r,e,t){let n=sn(r);if(!n)return[];let i=Ge(r),a=[],{rows:o,cols:l,boxes:u}=n,c=()=>{if(a.length>=e)return;let f=-1,d=-1,m=0,p=10;for(let g=0;g<9;g++){for(let y=0;y<9;y++){if(i[g][y]!==0)continue;let S=an(g,y,o,l,u),v=Jn(S);if(v===0)return;if(v<p&&(f=g,d=y,m=S,p=v,v===1))break}if(p===1)break}if(f===-1){a.push(Ge(i));return}let b=Zn.filter(g=>m&ke(g));t&&(b=Qn(b,t));for(let g of b){let y=ke(g),S=nn(f,d);if(i[f][d]=g,o[f]|=y,l[d]|=y,u[S]|=y,c(),u[S]&=~y,l[d]&=~y,o[f]&=~y,i[f][d]=0,a.length>=e)return}};return c(),a}function Ja(r){let e=Za(),t=Kn(r),[n]=ri(e,1,t);if(!n)throw new Error("generateSudokuPuzzle: failed to generate solved grid");return n}function eo(r){let e=sn(r);if(!e)return null;for(let t=0;t<9;t++)for(let n=0;n<9;n++){if(r[t][n]!==0)continue;let i=an(t,n,e.rows,e.cols,e.boxes);if(Jn(i)===1)return{row:t,col:n,value:Ka(i)}}return null}function to(r){let e=sn(r);if(!e)return null;let t=n=>{for(let i of Zn){let a=ke(i),o=null;for(let l of n)if(!(r[l.row][l.col]!==0||!(an(l.row,l.col,e.rows,e.cols,e.boxes)&a))){if(o){o=null;break}o=l}if(o)return{...o,value:i}}return null};for(let n=0;n<9;n++){let i=t(Array.from({length:9},(a,o)=>({row:n,col:o})));if(i)return i}for(let n=0;n<9;n++){let i=t(Array.from({length:9},(a,o)=>({row:o,col:n})));if(i)return i}for(let n=0;n<9;n+=3)for(let i=0;i<9;i+=3){let a=[];for(let l=n;l<n+3;l++)for(let u=i;u<i+3;u++)a.push({row:l,col:u});let o=t(a);if(o)return o}return null}function Yn(r){let e=Ge(r),t=!1;for(;rn(e)<81;){let n=eo(e);if(n){e[n.row][n.col]=n.value;continue}let i=to(e);if(i){t=!0,e[i.row][i.col]=i.value;continue}return"search"}return t?"hidden-singles":"singles"}function qn(r,e){let t={singles:0,"hidden-singles":1,search:2};return t[r]<=t[e]}function ze(r,e={}){let t=[];return ei(r,t)?ti(r,t)?ri(r,Math.max(1,Math.floor(e.maxSolutions??2))):[]:[]}function ni(r){let e=[];if(!ei(r,e))return{valid:!1,unique:!1,solution:null,errors:e};if(ti(r,e),e.length>0)return{valid:!1,unique:!1,solution:null,errors:e};let n=ze(r,{maxSolutions:2});return n.length===0?e.push("Puzzle has no solution."):n.length>1&&e.push("Puzzle has more than one solution."),{valid:e.length===0,unique:n.length===1,solution:n[0]?Ge(n[0]):null,errors:e}}function ii(r){let e=r.difficulty,t=qa[e];if(!t)throw new Error(`generateSudokuPuzzle: unsupported difficulty "${e}"`);let n=Qa(r.seed);for(let i=0;i<30;i++){let a=n+i*104729>>>0,o=Kn(a),l=Ja(a),u=Ge(l),c=t.minGivens+Math.floor(o()*(t.maxGivens-t.minGivens+1)),f=Qn(Array.from({length:81},(b,g)=>({row:Math.floor(g/9),col:g%9})),o);for(let b of f){if(rn(u)<=c)break;let g=u[b.row][b.col];if(u[b.row][b.col]=0,ze(u,{maxSolutions:2}).length!==1){u[b.row][b.col]=g;continue}let S=Yn(u);qn(S,t.maxRating)||(u[b.row][b.col]=g)}let d=rn(u),m=Yn(u);if(ze(u,{maxSolutions:2}).length===1&&d>=t.minGivens&&d<=t.maxGivens&&qn(m,t.maxRating))return{puzzle:u,solution:l,difficulty:e,seed:n,givens:d,rating:m}}throw new Error(`generateSudokuPuzzle: unable to generate a ${e} puzzle`)}0&&(module.exports={Arrow,Audio,BUILTIN_MARKER_ID_MAP,COMMON_TRANSFORM_NODE_DEFAULTS,CURRENT_SCHEMA_VERSION,Circle,Cloud,Container,ContainerShapeBuilder,Cross,DEFAULT_COORDINATE_PRECISION,Document,EASING_CURVES,EVENT_TRIGGER_OPTIONS,EasingType,Ellipse,Gear,Heart,Hyperlink,IDENTITY_AFFINE,ImageShape,LIBRARY_EMIT_ORDER,Lightning,Line,LinearGradientBuilder,MARKER_HEIGHT,MARKER_VIEWBOX,MARKER_WIDTH,MAX_COORDINATE_PRECISION,MIGRATIONS,NGon,NUMERIC_SHAPE_TRANSFORM_STATE_KEYS,NestedSvg,PUZZLE_DEFAULTS,Path,PathCurveType,PathPointType,PatternBuilder,Polyline,RadialGradientBuilder,Rectangle,Ring,SHAPE_TRANSFORM_STATE_KEYS,ShapeBuilder,ShapeReference,SpeechBubble,Spiral,Square,Star,Switch,Text,Timeline,Track,Triangle,Video,View,affine,affineFromArray,affineToArray,around,canonicalPolygonTransformString,canonicalTransformString,collectReferencedLibraryIds,composeLegacyTransformMatrix,computeArrowVertices,computeCloudPath,computeCrossVertices,computeDashArray,computeGearPath,computeGearVertices,computeHeartPath,computeLightningVertices,computePolygonVertices,computeRectanglePath,computeRingPath,computeSpeechBubbleVertices,computeSpiralPath,computeSplinePath,computeStarVertices,createDocument,createShape,createViewbox,defaultVariableMode,escXml,extractVariables,filterAttr,foldLegacyAncestorTransformIntoMatrix,generateCode,generateCssCode,generateD3Code,generateId,generatePatternSvgContent,generatePuzzlePieces,generateReactCode,generateSudokuPuzzle,generateSvgCode,generateVueCode,getBuiltInMarkerDefs,getEasingCubicBezier,getEffectivePrecision,getMarkerDescriptors,getPatternElements,isFiniteAffineArray,isIdentityAffine,linearGradient,matrixTransformPart,migrateSnapshot,multiplyAffine,parseDocument,parseSvgTransformList,parseVariableArgs,pattern,radialGradient,renderAnimationElements,renderBuiltinMarkerDefs,renderCircle,renderEllipse,renderFilterDefs,renderFilterLibraryDef,renderFilterPrimitive,renderFilterPrimitivesForType,renderImage,renderLibraryDef,renderLibraryDefs,renderLine,renderLinearGradientLibraryDef,renderMarkerLibraryDef,renderPatternLibraryDef,renderPolygonShape,renderPolyline,renderRadialGradientLibraryDef,renderRectangle,renderReferencedLibraryDefs,renderShape,renderSpline,renderSvgPrimitiveChainFilter,renderSymbolLibraryDef,renderText,renderToSvg,rotateAffine,roundCoord,roundNumberString,roundSerializedShape,roundSnapshot,scaleAffine,skewXAffine,skewYAffine,solveSudoku,stringifyDocument,substituteString,substituteVariables,translateAffine,validateSnapshot,validateSudokuPuzzle,verticesToPath});